[Home] [Help]
PACKAGE BODY: APPS.BEN_PD_COPY_TO_BEN_FOUR
Source
1 Package Body BEN_PD_COPY_TO_BEN_FOUR as
2 /* $Header: bepdccp4.pkb 120.7 2006/04/10 05:41:20 gsehgal noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 --UPD Changes New procedure for getting the dtmodes
6 --
7 procedure get_dt_modes(p_effective_date in date,
8 p_effective_end_date in date,
9 p_effective_start_date in date,
10 p_dml_operation in varchar2,
11 p_datetrack_mode in out nocopy varchar2
12 -- p_update out nocopy boolean
13 ) is
14 l_update boolean := true ;
15 l_datetrack_mode varchar2(80) := p_datetrack_mode ;
16 begin
17 --
18 hr_utility.set_location('Intering get_dt_modes p_dt_mode '||l_datetrack_mode,10);
19 hr_utility.set_location('p_effective_start_date '||p_effective_start_date,10);
20 hr_utility.set_location('p_effective_end_date '||p_effective_end_date,10);
21 hr_utility.set_location('p_effective_date '||p_effective_date,10);
22 --
23 if p_effective_end_date <> hr_api.g_eot then
24 --
25 if p_dml_operation = 'INSERT' then
26 --
27 l_datetrack_mode := hr_api.g_update;
28 l_update := true;
29 --
30 elsif l_datetrack_mode in ('CORRECTION') then
31 --
32 l_datetrack_mode := hr_api.g_correction ;
33 l_update := true;
34 --
35 elsif l_datetrack_mode in ('UPDATE_OVERRIDE','UPDATE' ) then
36 --
37 if p_effective_date = p_effective_start_date then
38 l_datetrack_mode := hr_api.g_correction ;
39 l_update := true;
40 else
41 --
42 if l_datetrack_mode in ('UPDATE_OVERRIDE') then
43 --
44 l_datetrack_mode := hr_api.g_update_override ;
45 l_update := false ;
46 --
47 elsif l_datetrack_mode in ('UPDATE') then
48 --
49 l_datetrack_mode := hr_api.g_update;
50 --
51 end if;
52 --
53 end if;
54 --
55 elsif l_datetrack_mode in ('UPDATE_CHANGE_INSERT') then
56 --
57 if p_effective_date = p_effective_start_date then
58 l_datetrack_mode := hr_api.g_correction ;
59 l_update := true;
60 else
61 l_datetrack_mode := hr_api.g_update_change_insert ;
62 l_update := true;
63 end if;
64 --
65 else
66 --
67 l_datetrack_mode := hr_api.g_update;
68 l_update := false;
69 --
70 end if;
71 --
72 else
73 --
74 if p_dml_operation = 'INSERT' then
75 --
76 l_datetrack_mode := hr_api.g_update;
77 l_update := false;
78 --
79 elsif l_datetrack_mode in ('CORRECTION') then
80 --
81 l_datetrack_mode := hr_api.g_correction ;
82 l_update := false;
83 --
84 elsif l_datetrack_mode in ('UPDATE_OVERRIDE','UPDATE' ) then
85 --
86 if p_effective_date = p_effective_start_date then
87 l_datetrack_mode := hr_api.g_correction ;
88 l_update := true;
89 else
90 l_datetrack_mode := hr_api.g_update ;
91 l_update := false ;
92 end if;
93 --
94 elsif l_datetrack_mode in ('UPDATE_CHANGE_INSERT') then
95 --
96 if p_effective_date = p_effective_start_date then
97 l_datetrack_mode := hr_api.g_correction ;
98 l_update := false;
99 else
100 l_datetrack_mode := hr_api.g_update ;
101 l_update := false;
102 end if;
103 --
104 else
105 --
106 l_datetrack_mode := hr_api.g_update;
107 l_update := false;
108 --
109 end if;
110 --
111 end if ;
112 --
113 p_datetrack_mode := l_datetrack_mode ;
114 -- p_update := l_update ;
115 --
116 hr_utility.set_location('Leaving get_dt_modes p_dt_mode '||p_datetrack_mode,10);
117 --
118 end get_dt_modes ;
119
120 -- |------------------------< get_fk >------------------------|
121 -- ----------------------------------------------------------------------------
122 -- {Start Of Comments}
123 --
124 -- {End Of Comments}
125 --
126 /*
127 function get_fk(p_col_name varchar2, p_old_val number,l_datetrack_mode) return number is
128 l_counter number;
129 l_ret_id number := null;
130 begin
131 --
132 l_counter := nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl.LAST, 0);
133 if l_counter > 0 and p_old_val is not null then
134 for i in 1..l_counter loop
135 if BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(i).pk_id_column = p_col_name and
136 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(i).old_value = p_old_val
137 then
138 l_ret_id := BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(i).new_value;
139 exit;
140 end if;
141 end loop;
142 hr_utility.set_location(' ** In the get_fk ** ',111);
143 hr_utility.set_location(' l_counter '||l_counter,111);
144 hr_utility.set_location(' p_col_name '||p_col_name,111);
145 hr_utility.set_location(' p_old_val '||p_old_val,111);
146 hr_utility.set_location(' p_new_val '||l_ret_id,111);
147 end if;
148 --
149 return l_ret_id;
150 --
151 end;
152 */
153
154 function get_fk(p_col_name varchar2, p_old_val number,p_dml_operation varchar2 default null) return number is
155 l_counter number;
156 l_ret_id number := null;
157 begin
158 --
159 /*
160 if p_dml_operation = 'UPDATE' then
161 --
162 l_ret_id := p_old_val ;
163 --
164 else
165 */
166 --
167 l_counter := nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl.LAST, 0);
168 if l_counter > 0 and p_old_val is not null then
169 for i in 1..l_counter loop
170 if BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(i).pk_id_column = p_col_name and
171 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(i).old_value = p_old_val
172 then
173 l_ret_id := BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(i).new_value;
174 exit;
175 end if;
176 end loop;
177 --
178 end if;
179 --
180 /*
181 end if;
182 */
183 return l_ret_id;
184 --
185 end;
186 --
187 -- ----------------------------------------------------------------------------
188 -- |------------------------< update_cer_with_target >------------------------|
189 -- ----------------------------------------------------------------------------
190 -- {Start Of Comments}
191 --
192 -- Private procedure to update the cer with target details
193 --
194 -- {End Of Comments}
195 --
196 procedure update_cer_with_target(c_pk_rec BEN_PD_COPY_TO_BEN_ONE.g_pk_rec_type, p_copy_entity_txn_id in number) is
197 begin
198 hr_utility.set_location('Inside update_cer_with_target ',233);
199 update ben_copy_entity_results
200 set information9 = c_pk_rec.copy_reuse_type||'-'||c_pk_rec.new_value
201 where copy_entity_txn_id = p_copy_entity_txn_id
202 and table_route_id = c_pk_rec.table_route_id
203 and information1 = c_pk_rec.old_value ;
204 end update_cer_with_target ;
205
206 --
207 --------------------------------------------------------------
208 ----------------------< create_EAN_rows >-----------------------
209 ---------------------------------------------------------------
210 --
211
212 procedure create_EAN_rows
213 (
214 p_validate in number default 0
215 ,p_copy_entity_txn_id in number
216 ,p_effective_date in date
217 ,p_prefix_suffix_text in varchar2 default null
218 ,p_reuse_object_flag in varchar2 default null
219 ,p_target_business_group_id in varchar2 default null
220 ,p_prefix_suffix_cd in varchar2 default null
221 ) is
222 --
223 l_ASSIGNMENT_SET_ID number;
224 l_ELIGY_PRFL_ID number;
225 cursor c_unique_EAN(l_table_alias varchar2) is
226 select distinct cpe.information1,
227 cpe.information2,
228 cpe.information3,
229 cpe.table_route_id
230 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
231 pqh_table_route tr
232 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
233 and cpe.table_route_id = tr.table_route_id
234 -- and tr.where_clause = l_BEN_ELIG_ASNT_SET_PRTE_F
235 and tr.table_alias = l_table_alias
236 and cpe.number_of_copies = 1 -- ADDITION
237 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
238 order by information1, information2; --added for bug: 5151945
239 --
240 --
241 cursor c_EAN_min_max_dates(c_table_route_id number,
242 c_information1 number) is
243 select
244 min(cpe.information2) min_esd,
245 max(cpe.information3) min_eed
246 from ben_copy_entity_results cpe
247 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
248 and cpe.table_route_id = c_table_route_id
249 and cpe.information1 = c_information1 ;
250 --
251 cursor c_EAN(c_table_route_id number,
252 c_information1 number,
253 c_information2 date,
254 c_information3 date ) is
255 select
256 cpe.*
257 from ben_copy_entity_results cpe
258 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
259 and cpe.table_route_id = c_table_route_id
260 and cpe.information1 = c_information1
261 and cpe.information2 = c_information2
262 and cpe.information3 = c_information3
263 and rownum = 1 ;
264 -- Date Track target record
265 cursor c_find_EAN_in_target(
266 c_effective_start_date date,
267 c_effective_end_date date,
268 c_business_group_id number,
269 c_new_pk_id number) is
270 select
271 EAN.elig_asnt_set_prte_id new_value
272 from BEN_ELIG_ASNT_SET_PRTE_F EAN
273 where
274 EAN.ASSIGNMENT_SET_ID = l_ASSIGNMENT_SET_ID and
275 EAN.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
276 EAN.business_group_id = c_business_group_id
277 and EAN.elig_asnt_set_prte_id <> c_new_pk_id
278 --TEMPIK
279 and c_effective_start_date between effective_start_date
280 and effective_end_date ;
281 --END TEMPIK
282 /*TEMPIK
283 and exists ( select null
284 from BEN_ELIG_ASNT_SET_PRTE_F EAN1
285 where
286 EAN1.ASSIGNMENT_SET_ID = l_ASSIGNMENT_SET_ID and
287 EAN1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
288 EAN1.business_group_id = c_business_group_id
289 and EAN1.effective_start_date <= c_effective_start_date )
290 and exists ( select null
291 from BEN_ELIG_ASNT_SET_PRTE_F EAN2
292 where
293 EAN2.ASSIGNMENT_SET_ID = l_ASSIGNMENT_SET_ID and
294 EAN2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
295 EAN2.business_group_id = c_business_group_id
296 and EAN2.effective_end_date >= c_effective_end_date )
297 ;
298 TEMPIK */
299 --TEMPIK
300 l_dt_rec_found boolean ;
301 --END TEMPIK
302 --
303
304 --UPD START
305 --
306 l_update boolean := false ;
307 l_datetrack_mode varchar2(80) := hr_api.g_update;
308 l_process_date date;
309 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
310 --
311 --UPD END
312 l_current_pk_id number := null ;
313
314 l_prev_pk_id number := null ;
315 l_first_rec boolean := true ;
316 r_EAN c_EAN%rowtype;
317 l_elig_asnt_set_prte_id number ;
318 l_object_version_number number ;
319 l_effective_start_date date ;
320 l_effective_end_date date ;
321 l_prefix pqh_copy_entity_attribs.information1%type := null;
322 l_suffix pqh_copy_entity_attribs.information1%type := null;
323 l_new_value number(15);
324 l_object_found_in_target boolean := false ;
325 l_min_esd date;
326 l_max_eed date;
327 l_effective_date date;
328 --
329 begin
330 -- Initialization
331 l_object_found_in_target := false ;
332 -- End Initialization
333 -- Derive the prefix - sufix
334 if p_prefix_suffix_cd = 'PREFIX' then
335 l_prefix := p_prefix_suffix_text ;
336 elsif p_prefix_suffix_cd = 'SUFFIX' then
337 l_suffix := p_prefix_suffix_text ;
338 else
339 l_prefix := null ;
340 l_suffix := null ;
341 end if ;
342 -- End Prefix Sufix derivation
343 for r_EAN_unique in c_unique_EAN('EAN') loop
344
345 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
346 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
347 r_EAN_unique.information3 >=
348 ben_pd_copy_to_ben_one.g_copy_effective_date)
349 ) then
350 --
351 hr_utility.set_location(' r_EAN_unique.table_route_id '||r_EAN_unique.table_route_id,10);
352 hr_utility.set_location(' r_EAN_unique.information1 '||r_EAN_unique.information1,10);
353 hr_utility.set_location( 'r_EAN_unique.information2 '||r_EAN_unique.information2,10);
354 hr_utility.set_location( 'r_EAN_unique.information3 '||r_EAN_unique.information3,10);
355 -- If reuse objects flag is 'Y' then check for the object in the target business group
356 -- if found insert the record into PLSql table and exit the loop else try create the
357 -- object in the target business group
358 --
359 l_object_found_in_target := false ;
360 --UPD START
361 l_update := false;
362 l_process_date := p_effective_date;
363 l_dml_operation:= r_EAN_unique.dml_operation ;
364 --
365 /**********************moved from below **********************/
366 open c_EAN(r_EAN_unique.table_route_id,
367 r_EAN_unique.information1,
368 r_EAN_unique.information2,
369 r_EAN_unique.information3 ) ;
370 --
371 fetch c_EAN into r_EAN ;
372 --
373 close c_EAN ;
374 --
375 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
376 l_ASSIGNMENT_SET_ID := r_EAN.information176;
377 else
378 l_ASSIGNMENT_SET_ID := r_EAN.information174;
379 end if;
380 --
381 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EAN.INFORMATION263,l_dml_operation);
382
383 /**********************************************************/
384
385 if l_dml_operation = 'UPDATE' then
386 --
387 l_object_found_in_target := TRUE;
388 --
389 if l_process_date between r_EAN_unique.information2 and r_EAN_unique.information3 then
390 l_update := true;
391 if r_EAN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
392 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ASNT_SET_PRTE_ID' then
393 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ASNT_SET_PRTE_ID' ;
394 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EAN_unique.information1 ;
395 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EAN_unique.information1 ;
396 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
397 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EAN_unique.table_route_id;
398 --
399 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
400 --
401 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
402 --
403 -- -- log_data('EAN',l_new_value,l_prefix || r_EAN_unique.name|| l_suffix,'REUSED');
404 --
405 end if ;
406 hr_utility.set_location( 'found record for update',10);
407 --
408 else
409 --
410 l_update := false;
411 --
412 end if;
413 else
414 --
415 --UPD END
416 l_min_esd := null ;
417 l_max_eed := null ;
418 open c_EAN_min_max_dates(r_EAN_unique.table_route_id, r_EAN_unique.information1 ) ;
419 fetch c_EAN_min_max_dates into l_min_esd,l_max_eed ;
420 --
421
422 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
423 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
424 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
425 end if;
426
427 l_min_esd := greatest(l_min_esd,r_EAN_unique.information2);
428 /**********************moved up from here **********************
429 open c_EAN(r_EAN_unique.table_route_id,
430 r_EAN_unique.information1,
431 r_EAN_unique.information2,
432 r_EAN_unique.information3 ) ;
433 --
434 fetch c_EAN into r_EAN ;
435 --
436 close c_EAN ;
437 --
438 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
439 l_ASSIGNMENT_SET_ID := r_EAN.information176;
440 else
441 l_ASSIGNMENT_SET_ID := r_EAN.information174;
442 end if;
443 --
444 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EAN.INFORMATION263,l_dml_operation);
445
446 **********************************************************/
447
448
449 if l_ASSIGNMENT_SET_ID is null then
450 close c_EAN_min_max_dates;
451 --
452 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
453 ,p_parent_pk_id => r_EAN.information263
454 ,p_copy_entity_txn_id => p_copy_entity_txn_id
455 ,p_child_table_alias => 'EAN'
456 ,p_child_data => r_EAN.information173 );
457
458 --
459 else
460 if p_reuse_object_flag = 'Y' then
461 if c_EAN_min_max_dates%found then
462 -- cursor to find the object
463 open c_find_EAN_in_target( l_min_esd,l_max_eed,
464 p_target_business_group_id, nvl(l_elig_asnt_set_prte_id, -999) ) ;
465 fetch c_find_EAN_in_target into l_new_value ;
466 if c_find_EAN_in_target%found then
467 --
468 --TEMPIK
469 l_dt_rec_found := dt_api.check_min_max_dates
470 (p_base_table_name => 'BEN_ELIG_ASNT_SET_PRTE_F',
471 p_base_key_column => 'ELIG_ASNT_SET_PRTE_ID',
472 p_base_key_value => l_new_value,
473 p_from_date => l_min_esd,
474 p_to_date => l_max_eed );
475 if l_dt_rec_found THEN
476 --END TEMPIK
477 if r_EAN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
478 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ASNT_SET_PRTE_ID' then
479 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ASNT_SET_PRTE_ID' ;
480 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EAN_unique.information1 ;
481 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
482 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
483 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EAN_unique.table_route_id;
484 --
485 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
486 --
487 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
488 end if ;
489 --
490 l_object_found_in_target := true ;
491 --TEMPIK
492 end if; -- l_dt_rec_found
493 --END TEMPIK
494 end if;
495 close c_find_EAN_in_target ;
496 --
497 end if;
498 end if ;
499 --
500 close c_EAN_min_max_dates ;
501
502 end if; -- bug 4565106
503
504 end if; --if p_dml_operation
505 --
506 if (not l_object_found_in_target OR l_update) and l_assignment_set_id is not null then
507
508 --kopp
509 l_current_pk_id := r_EAN.information1;
510 --
511 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
512 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
513 --
514 if l_current_pk_id = l_prev_pk_id then
515 --
516 l_first_rec := false ;
517 --
518 else
519 --
520 l_first_rec := true ;
521 --
522 end if ;
523 --
524
525 l_effective_date := r_EAN.information2;
526 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
527 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
528 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
529 end if;
530
531 if l_first_rec and not l_update then
532 -- Call Create routine.
533 hr_utility.set_location(' BEN_ELIG_ASNT_SET_PRTE_F CREATE_ELIG_ASNT_SET_PRTE ',20);
534 BEN_ELIG_ASNT_SET_PRTE_API.CREATE_ELIG_ASNT_SET_PRTE(
535 --
536 P_VALIDATE => false
537 ,P_EFFECTIVE_DATE => l_effective_date
538 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
539 --
540 ,P_ASSIGNMENT_SET_ID => l_ASSIGNMENT_SET_ID
541 ,P_EAN_ATTRIBUTE1 => r_EAN.INFORMATION111
542 ,P_EAN_ATTRIBUTE10 => r_EAN.INFORMATION120
543 ,P_EAN_ATTRIBUTE11 => r_EAN.INFORMATION121
544 ,P_EAN_ATTRIBUTE12 => r_EAN.INFORMATION122
545 ,P_EAN_ATTRIBUTE13 => r_EAN.INFORMATION123
546 ,P_EAN_ATTRIBUTE14 => r_EAN.INFORMATION124
547 ,P_EAN_ATTRIBUTE15 => r_EAN.INFORMATION125
548 ,P_EAN_ATTRIBUTE16 => r_EAN.INFORMATION126
549 ,P_EAN_ATTRIBUTE17 => r_EAN.INFORMATION127
550 ,P_EAN_ATTRIBUTE18 => r_EAN.INFORMATION128
551 ,P_EAN_ATTRIBUTE19 => r_EAN.INFORMATION129
552 ,P_EAN_ATTRIBUTE2 => r_EAN.INFORMATION112
553 ,P_EAN_ATTRIBUTE20 => r_EAN.INFORMATION130
554 ,P_EAN_ATTRIBUTE21 => r_EAN.INFORMATION131
555 ,P_EAN_ATTRIBUTE22 => r_EAN.INFORMATION132
556 ,P_EAN_ATTRIBUTE23 => r_EAN.INFORMATION133
557 ,P_EAN_ATTRIBUTE24 => r_EAN.INFORMATION134
558 ,P_EAN_ATTRIBUTE25 => r_EAN.INFORMATION135
559 ,P_EAN_ATTRIBUTE26 => r_EAN.INFORMATION136
560 ,P_EAN_ATTRIBUTE27 => r_EAN.INFORMATION137
561 ,P_EAN_ATTRIBUTE28 => r_EAN.INFORMATION138
562 ,P_EAN_ATTRIBUTE29 => r_EAN.INFORMATION139
563 ,P_EAN_ATTRIBUTE3 => r_EAN.INFORMATION113
564 ,P_EAN_ATTRIBUTE30 => r_EAN.INFORMATION140
565 ,P_EAN_ATTRIBUTE4 => r_EAN.INFORMATION114
566 ,P_EAN_ATTRIBUTE5 => r_EAN.INFORMATION115
567 ,P_EAN_ATTRIBUTE6 => r_EAN.INFORMATION116
568 ,P_EAN_ATTRIBUTE7 => r_EAN.INFORMATION117
569 ,P_EAN_ATTRIBUTE8 => r_EAN.INFORMATION118
570 ,P_EAN_ATTRIBUTE9 => r_EAN.INFORMATION119
571 ,P_EAN_ATTRIBUTE_CATEGORY => r_EAN.INFORMATION110
572 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
573 ,P_ELIG_ASNT_SET_PRTE_ID => l_elig_asnt_set_prte_id
574 ,P_EXCLD_FLAG => r_EAN.INFORMATION11
575 ,P_ORDR_NUM => r_EAN.INFORMATION260
576 -- ****** END CHANGE LINES
577
578 --
579
580 ,P_EFFECTIVE_START_DATE => l_effective_start_date
581 ,P_EFFECTIVE_END_DATE => l_effective_end_date
582 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
583 ,P_CRITERIA_SCORE => r_ean.INFORMATION295
584 ,P_CRITERIA_WEIGHT => r_ean.INFORMATION296
585 );
586 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
587 -- Update all relevent cer records with new pk_id
588 hr_utility.set_location('Before plsql table ',222);
589 hr_utility.set_location('new_value id '||l_elig_asnt_set_prte_id,222);
590 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ASNT_SET_PRTE_ID' ;
591 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EAN.information1 ;
592 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_ASNT_SET_PRTE_ID ;
593 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
594 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EAN_unique.table_route_id;
595 hr_utility.set_location('After plsql table ',222);
596 --
597 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
598 --
599 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
600 --
601 else
602 --
603 -- Call Update routine for the pk_id created in prev run .
604 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
605 hr_utility.set_location(' BEN_ELIG_ASNT_SET_PRTE_F UPDATE_ELIG_ASNT_SET_PRTE ',30);
606 --UPD START
607 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
608 --
609 if l_update then
610 --
611 l_datetrack_mode := r_EAN.datetrack_mode ;
612 --
613 get_dt_modes(
614 p_effective_date => l_process_date,
615 p_effective_end_date => r_EAN.information3,
616 p_effective_start_date => r_EAN.information2,
617 p_dml_operation => r_EAN.dml_operation,
618 p_datetrack_mode => l_datetrack_mode );
619 -- p_update => l_update
620 --
621 l_effective_date := l_process_date;
622 l_ELIG_ASNT_SET_PRTE_ID := r_EAN.information1;
623 l_object_version_number := r_EAN.information265;
624 --
625 end if;
626 --
627 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
628 --
629 IF l_update OR l_dml_operation <> 'UPDATE' THEN
630 --UPD END
631
632
633
634
635 BEN_ELIG_ASNT_SET_PRTE_API.UPDATE_ELIG_ASNT_SET_PRTE(
636 --
637 P_VALIDATE => false
638 ,P_EFFECTIVE_DATE => l_effective_date
639 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
640 --
641 ,P_ASSIGNMENT_SET_ID => l_ASSIGNMENT_SET_ID
642 ,P_EAN_ATTRIBUTE1 => r_EAN.INFORMATION111
643 ,P_EAN_ATTRIBUTE10 => r_EAN.INFORMATION120
644 ,P_EAN_ATTRIBUTE11 => r_EAN.INFORMATION121
645 ,P_EAN_ATTRIBUTE12 => r_EAN.INFORMATION122
646 ,P_EAN_ATTRIBUTE13 => r_EAN.INFORMATION123
647 ,P_EAN_ATTRIBUTE14 => r_EAN.INFORMATION124
648 ,P_EAN_ATTRIBUTE15 => r_EAN.INFORMATION125
649 ,P_EAN_ATTRIBUTE16 => r_EAN.INFORMATION126
650 ,P_EAN_ATTRIBUTE17 => r_EAN.INFORMATION127
651 ,P_EAN_ATTRIBUTE18 => r_EAN.INFORMATION128
652 ,P_EAN_ATTRIBUTE19 => r_EAN.INFORMATION129
653 ,P_EAN_ATTRIBUTE2 => r_EAN.INFORMATION112
654 ,P_EAN_ATTRIBUTE20 => r_EAN.INFORMATION130
655 ,P_EAN_ATTRIBUTE21 => r_EAN.INFORMATION131
656 ,P_EAN_ATTRIBUTE22 => r_EAN.INFORMATION132
657 ,P_EAN_ATTRIBUTE23 => r_EAN.INFORMATION133
658 ,P_EAN_ATTRIBUTE24 => r_EAN.INFORMATION134
659 ,P_EAN_ATTRIBUTE25 => r_EAN.INFORMATION135
660 ,P_EAN_ATTRIBUTE26 => r_EAN.INFORMATION136
661 ,P_EAN_ATTRIBUTE27 => r_EAN.INFORMATION137
662 ,P_EAN_ATTRIBUTE28 => r_EAN.INFORMATION138
663 ,P_EAN_ATTRIBUTE29 => r_EAN.INFORMATION139
664 ,P_EAN_ATTRIBUTE3 => r_EAN.INFORMATION113
665 ,P_EAN_ATTRIBUTE30 => r_EAN.INFORMATION140
666 ,P_EAN_ATTRIBUTE4 => r_EAN.INFORMATION114
667 ,P_EAN_ATTRIBUTE5 => r_EAN.INFORMATION115
668 ,P_EAN_ATTRIBUTE6 => r_EAN.INFORMATION116
669 ,P_EAN_ATTRIBUTE7 => r_EAN.INFORMATION117
670 ,P_EAN_ATTRIBUTE8 => r_EAN.INFORMATION118
671 ,P_EAN_ATTRIBUTE9 => r_EAN.INFORMATION119
672 ,P_EAN_ATTRIBUTE_CATEGORY => r_EAN.INFORMATION110
673 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
674 ,P_ELIG_ASNT_SET_PRTE_ID => l_elig_asnt_set_prte_id
675 ,P_EXCLD_FLAG => r_EAN.INFORMATION11
676 ,P_ORDR_NUM => r_EAN.INFORMATION260
677 --
678 -- ****** END CHANGE LINES
679
680 --
681 ,P_EFFECTIVE_START_DATE => l_effective_start_date
682 ,P_EFFECTIVE_END_DATE => l_effective_end_date
683 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
684 ,P_DATETRACK_MODE => l_datetrack_mode
685 ,P_CRITERIA_SCORE => r_ean.INFORMATION295
686 ,P_CRITERIA_WEIGHT => r_ean.INFORMATION296
687 );
688
689 end if; -- l_update
690 --
691 end if;
692 --
693 -- Delete the row if it is end dated.
694 --
695 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
696 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
697 trunc(l_max_eed) = trunc(r_EAN.information3)) then
698 --
699 BEN_ELIG_ASNT_SET_PRTE_API.delete_ELIG_ASNT_SET_PRTE(
700 --
701 p_validate => false
702 ,p_elig_asnt_set_prte_id => l_elig_asnt_set_prte_id
703 ,p_effective_start_date => l_effective_start_date
704 ,p_effective_end_date => l_effective_end_date
705 ,p_object_version_number => l_object_version_number
706 ,p_effective_date => l_max_eed
707 ,p_datetrack_mode => hr_api.g_delete
708 --
709 );
710 --
711 end if;
712 --
713 l_prev_pk_id := l_current_pk_id ;
714 --
715 -- end if; -- bug 4565106
716 --
717 end if;
718 --
719 end if;
720 --
721 end loop;
722 --
723 exception when others then
724 --
725 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EAN',r_EAN.information5 ) ;
726 --
727 end create_EAN_rows;
728
729 --
730 ---------------------------------------------------------------
731 ----------------------< create_CGP_rows >-----------------------
732 ---------------------------------------------------------------
733 --
734 procedure create_CGP_rows
735 (
736 p_validate in number default 0
737 ,p_copy_entity_txn_id in number
738 ,p_effective_date in date
739 ,p_prefix_suffix_text in varchar2 default null
740 ,p_reuse_object_flag in varchar2 default null
741 ,p_target_business_group_id in varchar2 default null
742 ,p_prefix_suffix_cd in varchar2 default null
743 ) is
744 --
745 l_ELIGY_PRFL_ID number;
746 l_PYMT_MUST_BE_RCVD_RL number;
747 -- IK
748 l_PYMT_MUST_BE_RCVD_NUM BEN_CNTNG_PRTN_ELIG_PRFL_F.PYMT_MUST_BE_RCVD_NUM%type;
749 l_PYMT_MUST_BE_RCVD_UOM BEN_CNTNG_PRTN_ELIG_PRFL_F.PYMT_MUST_BE_RCVD_UOM%type;
750 -- IK
751 cursor c_unique_CGP(l_table_alias varchar2) is
752 select distinct cpe.information1,
753 cpe.information2,
754 cpe.information3,
755 cpe.information170 name,
756 cpe.table_route_id
757 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
758 pqh_table_route tr
759 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
760 and cpe.table_route_id = tr.table_route_id
761 -- and tr.where_clause = l_BEN_CNTNG_PRTN_ELIG_PRFL_F
762 and tr.table_alias = l_table_alias
763 and cpe.number_of_copies = 1 -- ADDITION
764 group by cpe.information1,cpe.information2,cpe.information3, cpe.information170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
765 order by information1, information2; --added for bug: 5151945
766 --
767 --
768 cursor c_CGP_min_max_dates(c_table_route_id number,
769 c_information1 number) is
770 select
771 min(cpe.information2) min_esd,
772 max(cpe.information3) min_eed
773 from ben_copy_entity_results cpe
774 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
775 and cpe.table_route_id = c_table_route_id
776 and cpe.information1 = c_information1 ;
777 --
778 cursor c_CGP(c_table_route_id number,
779 c_information1 number,
780 c_information2 date,
781 c_information3 date) is
782 select
783 cpe.*
784 from ben_copy_entity_results cpe
785 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
786 and cpe.table_route_id = c_table_route_id
787 and cpe.information1 = c_information1
788 and cpe.information2 = c_information2
789 and cpe.information3 = c_information3
790 and rownum = 1 ;
791 -- Date Track target record
792 cursor c_find_CGP_in_target(
793 c_effective_start_date date,
794 c_effective_end_date date,
795 c_business_group_id number,
796 c_new_pk_id number) is
797 select
798 CGP.cntng_prtn_elig_prfl_id new_value
799 from BEN_CNTNG_PRTN_ELIG_PRFL_F CGP
800 where
801 CGP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
802 -- IK
803 nvl(CGP.PYMT_MUST_BE_RCVD_RL,-999) = nvl(l_PYMT_MUST_BE_RCVD_RL,-999) and
804 nvl(CGP.PYMT_MUST_BE_RCVD_NUM,-999)= nvl(l_PYMT_MUST_BE_RCVD_NUM,-999) and
805 nvl(CGP.PYMT_MUST_BE_RCVD_UOM,-999)= nvl(l_PYMT_MUST_BE_RCVD_UOM,-999) and
806 -- IK
807 CGP.business_group_id = c_business_group_id
808 and CGP.cntng_prtn_elig_prfl_id <> c_new_pk_id
809 --TEMPIK
810 and c_effective_start_date between effective_start_date
811 and effective_end_date ;
812 --END TEMPIK
813 /*TEMPIK
814 and exists ( select null
815 from BEN_CNTNG_PRTN_ELIG_PRFL_F CGP1
816 where
817 CGP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
818 -- IK
819 nvl(CGP1.PYMT_MUST_BE_RCVD_RL,-999) = nvl(l_PYMT_MUST_BE_RCVD_RL,-999) and
820 nvl(CGP1.PYMT_MUST_BE_RCVD_NUM,-999)= nvl(l_PYMT_MUST_BE_RCVD_NUM,-999) and
821 nvl(CGP1.PYMT_MUST_BE_RCVD_UOM,-999)= nvl(l_PYMT_MUST_BE_RCVD_UOM,-999) and
822 -- IK
823 CGP1.business_group_id = c_business_group_id
824 and CGP1.effective_start_date <= c_effective_start_date )
825 and exists ( select null
826 from BEN_CNTNG_PRTN_ELIG_PRFL_F CGP2
827 where
828 CGP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
829 -- IK
830 nvl(CGP2.PYMT_MUST_BE_RCVD_RL,-999) = nvl(l_PYMT_MUST_BE_RCVD_RL,-999) and
831 nvl(CGP2.PYMT_MUST_BE_RCVD_NUM,-999)= nvl(l_PYMT_MUST_BE_RCVD_NUM,-999) and
832 nvl(CGP2.PYMT_MUST_BE_RCVD_UOM,-999)= nvl(l_PYMT_MUST_BE_RCVD_UOM,-999) and
833 -- IK
834 CGP2.business_group_id = c_business_group_id
835 and CGP2.effective_end_date >= c_effective_end_date )
836 ;
837 TEMPIK */
838 --TEMPIK
839 l_dt_rec_found boolean ;
840 --END TEMPIK
841 --
842 --l_current_pk_id number := null ;
843 --UPD START
844 --
845 l_update boolean := false ;
846 l_datetrack_mode varchar2(80) := hr_api.g_update;
847 l_process_date date;
848 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
849 --
850 --UPD END
851 l_current_pk_id number := null ;
852
853
854 l_prev_pk_id number := null ;
855 l_first_rec boolean := true ;
856 r_CGP c_CGP%rowtype;
857 l_cntng_prtn_elig_prfl_id number ;
858 l_object_version_number number ;
859 l_effective_start_date date ;
860 l_effective_end_date date ;
861 l_prefix pqh_copy_entity_attribs.information1%type := null;
862 l_suffix pqh_copy_entity_attribs.information1%type := null;
863 l_new_value number(15);
864 l_object_found_in_target boolean := false ;
865 l_min_esd date;
866 l_max_eed date;
867 l_effective_date date;
868 --
869 begin
870 -- Initialization
871 l_object_found_in_target := false ;
872 -- End Initialization
873 -- Derive the prefix - sufix
874 if p_prefix_suffix_cd = 'PREFIX' then
875 l_prefix := p_prefix_suffix_text ;
876 elsif p_prefix_suffix_cd = 'SUFFIX' then
877 l_suffix := p_prefix_suffix_text ;
878 else
879 l_prefix := null ;
880 l_suffix := null ;
881 end if ;
882 -- End Prefix Sufix derivation
883 for r_CGP_unique in c_unique_CGP('CGP') loop
884 --
885 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
886 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
887 r_CGP_unique.information3 >=
888 ben_pd_copy_to_ben_one.g_copy_effective_date)
889 ) then
890 --
891 hr_utility.set_location(' r_CGP_unique.table_route_id '||r_CGP_unique.table_route_id,10);
892 hr_utility.set_location(' r_CGP_unique.information1 '||r_CGP_unique.information1,10);
893 hr_utility.set_location( 'r_CGP_unique.information2 '||r_CGP_unique.information2,10);
894 hr_utility.set_location( 'r_CGP_unique.information3 '||r_CGP_unique.information3,10);
895 -- If reuse objects flag is 'Y' then check for the object in the target business group
896 -- if found insert the record into PLSql table and exit the loop else try create the
897 -- object in the target business group
898 --
899 l_object_found_in_target := false ;
900 --UPD START
901 l_update := false;
902 l_process_date := p_effective_date;
903 l_dml_operation:= r_CGP_unique.dml_operation ;
904 --
905 /* ***Moved here from below ******/
906 open c_CGP(r_CGP_unique.table_route_id,
907 r_CGP_unique.information1,
908 r_CGP_unique.information2,
909 r_CGP_unique.information3 ) ;
910 --
911 fetch c_CGP into r_CGP ;
912 --
913 close c_CGP ;
914 --
915 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_CGP.INFORMATION263,l_dml_operation);
916 l_PYMT_MUST_BE_RCVD_RL := get_fk('FORMULA_ID', r_CGP.INFORMATION260,l_dml_operation);
917 l_PYMT_MUST_BE_RCVD_NUM := r_CGP.INFORMATION259 ;
918 l_PYMT_MUST_BE_RCVD_UOM := r_CGP.INFORMATION11 ;
919 /**********************/
920
921 if l_dml_operation = 'UPDATE' then
922 --
923 l_object_found_in_target := TRUE;
924 --
925 if l_process_date between r_CGP_unique.information2 and r_CGP_unique.information3 then
926 l_update := true;
927 if r_CGP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
928 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'CNTNG_PRTN_ELIG_PRFL_ID' then
929 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'CNTNG_PRTN_ELIG_PRFL_ID' ;
930 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CGP_unique.information1 ;
931 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_CGP_unique.information1 ;
932 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
933 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CGP_unique.table_route_id;
934 --
935 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
936 --
937 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
938 --
939 -- -- log_data('CGP',l_new_value,l_prefix || r_CGP_unique.name|| l_suffix,'REUSED');
940 --
941 end if ;
942 hr_utility.set_location( 'found record for update',10);
943 --
944 else
945 --
946 l_update := false;
947 --
948 end if;
949 else
950 --
951 --UPD END
952 l_min_esd := null ;
953 l_max_eed := null ;
954 open c_CGP_min_max_dates(r_CGP_unique.table_route_id, r_CGP_unique.information1 ) ;
955 fetch c_CGP_min_max_dates into l_min_esd,l_max_eed ;
956 --
957
958 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
959 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
960 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
961 end if;
962 l_min_esd := greatest(l_min_esd,r_CGP_unique.information2);
963 /* ***Moved up ******
964 open c_CGP(r_CGP_unique.table_route_id,
965 r_CGP_unique.information1,
966 r_CGP_unique.information2,
967 r_CGP_unique.information3 ) ;
968 --
969 fetch c_CGP into r_CGP ;
970 --
971 close c_CGP ;
972 --
973 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_CGP.INFORMATION263,l_dml_operation);
974 l_PYMT_MUST_BE_RCVD_RL := get_fk('FORMULA_ID', r_CGP.INFORMATION260,l_dml_operation);
975 l_PYMT_MUST_BE_RCVD_NUM := r_CGP.INFORMATION259 ;
976 l_PYMT_MUST_BE_RCVD_UOM := r_CGP.INFORMATION11 ;
977 **********************/
978 if p_reuse_object_flag = 'Y' then
979 if c_CGP_min_max_dates%found then
980 -- cursor to find the object
981 open c_find_CGP_in_target( l_min_esd,l_max_eed,
982 p_target_business_group_id, nvl(l_cntng_prtn_elig_prfl_id, -999) ) ;
983 fetch c_find_CGP_in_target into l_new_value ;
984 if c_find_CGP_in_target%found then
985 --
986 --TEMPIK
987 l_dt_rec_found := dt_api.check_min_max_dates
988 (p_base_table_name => 'BEN_CNTNG_PRTN_ELIG_PRFL_F',
989 p_base_key_column => 'CNTNG_PRTN_ELIG_PRFL_ID',
990 p_base_key_value => l_new_value,
991 p_from_date => l_min_esd,
992 p_to_date => l_max_eed );
993 if l_dt_rec_found THEN
994 --END TEMPIK
995 if r_CGP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
996 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'CNTNG_PRTN_ELIG_PRFL_ID' then
997 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'CNTNG_PRTN_ELIG_PRFL_ID' ;
998 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CGP_unique.information1 ;
999 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
1000 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
1001 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CGP_unique.table_route_id;
1002 --
1003 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
1004 --
1005 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1006 end if ;
1007 --
1008 l_object_found_in_target := true ;
1009 --TEMPIK
1010 end if; -- l_dt_rec_found
1011 --END TEMPIK
1012 end if;
1013 close c_find_CGP_in_target ;
1014 --
1015 end if;
1016 end if ;
1017 --
1018 close c_CGP_min_max_dates ;
1019 end if; --if p_dml_operation
1020 --
1021 if not l_object_found_in_target OR l_update then
1022
1023 --
1024 l_current_pk_id := r_CGP.information1;
1025 --
1026 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
1027 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
1028 --
1029 if l_current_pk_id = l_prev_pk_id then
1030 --
1031 l_first_rec := false ;
1032 --
1033 else
1034 --
1035 l_first_rec := true ;
1036 --
1037 end if ;
1038 --
1039 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_CNTNG_PRTN_ELIG_PRFL_F',l_prefix || r_CGP.information170 || l_suffix);
1040 --
1041
1042 l_effective_date := r_CGP.information2;
1043 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
1044 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
1045 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
1046 end if;
1047
1048 if l_first_rec and not l_update then
1049 -- Call Create routine.
1050 hr_utility.set_location(' BEN_CNTNG_PRTN_ELIG_PRFL_F CREATE_CNTNG_PRTN_ELIG_PRFL ',20);
1051 BEN_CNTNG_PRTN_ELIG_PRFL_API.CREATE_CNTNG_PRTN_ELIG_PRFL(
1052 --
1053 P_VALIDATE => false
1054 ,P_EFFECTIVE_DATE => l_effective_date
1055 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
1056 --
1057 ,P_CGP_ATTRIBUTE1 => r_CGP.INFORMATION111
1058 ,P_CGP_ATTRIBUTE10 => r_CGP.INFORMATION120
1059 ,P_CGP_ATTRIBUTE11 => r_CGP.INFORMATION121
1060 ,P_CGP_ATTRIBUTE12 => r_CGP.INFORMATION122
1061 ,P_CGP_ATTRIBUTE13 => r_CGP.INFORMATION123
1062 ,P_CGP_ATTRIBUTE14 => r_CGP.INFORMATION124
1063 ,P_CGP_ATTRIBUTE15 => r_CGP.INFORMATION125
1064 ,P_CGP_ATTRIBUTE16 => r_CGP.INFORMATION126
1065 ,P_CGP_ATTRIBUTE17 => r_CGP.INFORMATION127
1066 ,P_CGP_ATTRIBUTE18 => r_CGP.INFORMATION128
1067 ,P_CGP_ATTRIBUTE19 => r_CGP.INFORMATION129
1068 ,P_CGP_ATTRIBUTE2 => r_CGP.INFORMATION112
1069 ,P_CGP_ATTRIBUTE20 => r_CGP.INFORMATION130
1070 ,P_CGP_ATTRIBUTE21 => r_CGP.INFORMATION131
1071 ,P_CGP_ATTRIBUTE22 => r_CGP.INFORMATION132
1072 ,P_CGP_ATTRIBUTE23 => r_CGP.INFORMATION133
1073 ,P_CGP_ATTRIBUTE24 => r_CGP.INFORMATION134
1074 ,P_CGP_ATTRIBUTE25 => r_CGP.INFORMATION135
1075 ,P_CGP_ATTRIBUTE26 => r_CGP.INFORMATION136
1076 ,P_CGP_ATTRIBUTE27 => r_CGP.INFORMATION137
1077 ,P_CGP_ATTRIBUTE28 => r_CGP.INFORMATION138
1078 ,P_CGP_ATTRIBUTE29 => r_CGP.INFORMATION139
1079 ,P_CGP_ATTRIBUTE3 => r_CGP.INFORMATION113
1080 ,P_CGP_ATTRIBUTE30 => r_CGP.INFORMATION140
1081 ,P_CGP_ATTRIBUTE4 => r_CGP.INFORMATION114
1082 ,P_CGP_ATTRIBUTE5 => r_CGP.INFORMATION115
1083 ,P_CGP_ATTRIBUTE6 => r_CGP.INFORMATION116
1084 ,P_CGP_ATTRIBUTE7 => r_CGP.INFORMATION117
1085 ,P_CGP_ATTRIBUTE8 => r_CGP.INFORMATION118
1086 ,P_CGP_ATTRIBUTE9 => r_CGP.INFORMATION119
1087 ,P_CGP_ATTRIBUTE_CATEGORY => r_CGP.INFORMATION110
1088 ,P_CNTNG_PRTN_ELIG_PRFL_ID => l_cntng_prtn_elig_prfl_id
1089 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
1090 ,P_NAME => l_prefix || r_CGP.INFORMATION170 || l_suffix
1091 ,P_PYMT_MUST_BE_RCVD_NUM => r_CGP.INFORMATION259
1092 ,P_PYMT_MUST_BE_RCVD_RL => l_PYMT_MUST_BE_RCVD_RL
1093 ,P_PYMT_MUST_BE_RCVD_UOM => r_CGP.INFORMATION11
1094 --
1095 -- ****** END CHANGE LINES
1096
1097 --
1098
1099 ,P_EFFECTIVE_START_DATE => l_effective_start_date
1100 ,P_EFFECTIVE_END_DATE => l_effective_end_date
1101 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
1102 );
1103
1104 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1105 -- Update all relevent cer records with new pk_id
1106 hr_utility.set_location('Before plsql table ',222);
1107 hr_utility.set_location('new_value id '||l_cntng_prtn_elig_prfl_id,222);
1108 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'CNTNG_PRTN_ELIG_PRFL_ID' ;
1109 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CGP.information1 ;
1110 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_CNTNG_PRTN_ELIG_PRFL_ID ;
1111 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
1112 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CGP_unique.table_route_id;
1113 hr_utility.set_location('After plsql table ',222);
1114 --
1115 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
1116 --
1117 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1118 --
1119 else
1120 --
1121 -- Call Update routine for the pk_id created in prev run .
1122 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1123 hr_utility.set_location(' BEN_CNTNG_PRTN_ELIG_PRFL_F UPDATE_CNTNG_PRTN_ELIG_PRFL ',30);
1124 --UPD START
1125 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
1126 --
1127 if l_update then
1128 --
1129 l_datetrack_mode := r_CGP.datetrack_mode ;
1130 --
1131 get_dt_modes(
1132 p_effective_date => l_process_date,
1133 p_effective_end_date => r_CGP.information3,
1134 p_effective_start_date => r_CGP.information2,
1135 p_dml_operation => r_CGP.dml_operation,
1136 p_datetrack_mode => l_datetrack_mode );
1137 -- p_update => l_update
1138 --
1139 l_effective_date := l_process_date;
1140 l_CNTNG_PRTN_ELIG_PRFL_ID := r_CGP.information1;
1141 l_object_version_number := r_CGP.information265;
1142 --
1143 end if;
1144 --
1145 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
1146 --
1147 IF l_update OR l_dml_operation <> 'UPDATE' THEN
1148 --UPD END
1149
1150
1151 BEN_CNTNG_PRTN_ELIG_PRFL_API.UPDATE_CNTNG_PRTN_ELIG_PRFL(
1152 --
1153 P_VALIDATE => false
1154 ,P_EFFECTIVE_DATE => l_effective_date
1155 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
1156 --
1157 ,P_CGP_ATTRIBUTE1 => r_CGP.INFORMATION111
1158 ,P_CGP_ATTRIBUTE10 => r_CGP.INFORMATION120
1159 ,P_CGP_ATTRIBUTE11 => r_CGP.INFORMATION121
1160 ,P_CGP_ATTRIBUTE12 => r_CGP.INFORMATION122
1161 ,P_CGP_ATTRIBUTE13 => r_CGP.INFORMATION123
1162 ,P_CGP_ATTRIBUTE14 => r_CGP.INFORMATION124
1163 ,P_CGP_ATTRIBUTE15 => r_CGP.INFORMATION125
1164 ,P_CGP_ATTRIBUTE16 => r_CGP.INFORMATION126
1165 ,P_CGP_ATTRIBUTE17 => r_CGP.INFORMATION127
1166 ,P_CGP_ATTRIBUTE18 => r_CGP.INFORMATION128
1167 ,P_CGP_ATTRIBUTE19 => r_CGP.INFORMATION129
1168 ,P_CGP_ATTRIBUTE2 => r_CGP.INFORMATION112
1169 ,P_CGP_ATTRIBUTE20 => r_CGP.INFORMATION130
1170 ,P_CGP_ATTRIBUTE21 => r_CGP.INFORMATION131
1171 ,P_CGP_ATTRIBUTE22 => r_CGP.INFORMATION132
1172 ,P_CGP_ATTRIBUTE23 => r_CGP.INFORMATION133
1173 ,P_CGP_ATTRIBUTE24 => r_CGP.INFORMATION134
1174 ,P_CGP_ATTRIBUTE25 => r_CGP.INFORMATION135
1175 ,P_CGP_ATTRIBUTE26 => r_CGP.INFORMATION136
1176 ,P_CGP_ATTRIBUTE27 => r_CGP.INFORMATION137
1177 ,P_CGP_ATTRIBUTE28 => r_CGP.INFORMATION138
1178 ,P_CGP_ATTRIBUTE29 => r_CGP.INFORMATION139
1179 ,P_CGP_ATTRIBUTE3 => r_CGP.INFORMATION113
1180 ,P_CGP_ATTRIBUTE30 => r_CGP.INFORMATION140
1181 ,P_CGP_ATTRIBUTE4 => r_CGP.INFORMATION114
1182 ,P_CGP_ATTRIBUTE5 => r_CGP.INFORMATION115
1183 ,P_CGP_ATTRIBUTE6 => r_CGP.INFORMATION116
1184 ,P_CGP_ATTRIBUTE7 => r_CGP.INFORMATION117
1185 ,P_CGP_ATTRIBUTE8 => r_CGP.INFORMATION118
1186 ,P_CGP_ATTRIBUTE9 => r_CGP.INFORMATION119
1187 ,P_CGP_ATTRIBUTE_CATEGORY => r_CGP.INFORMATION110
1188 ,P_CNTNG_PRTN_ELIG_PRFL_ID => l_cntng_prtn_elig_prfl_id
1189 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
1190 ,P_NAME => l_prefix || r_CGP.INFORMATION170 || l_suffix
1191 ,P_PYMT_MUST_BE_RCVD_NUM => r_CGP.INFORMATION259
1192 ,P_PYMT_MUST_BE_RCVD_RL => l_PYMT_MUST_BE_RCVD_RL
1193 ,P_PYMT_MUST_BE_RCVD_UOM => r_CGP.INFORMATION11
1194 --
1195 -- ****** END CHANGE LINES
1196
1197 --
1198 ,P_EFFECTIVE_START_DATE => l_effective_start_date
1199 ,P_EFFECTIVE_END_DATE => l_effective_end_date
1200 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
1201 ,P_DATETRACK_MODE => l_datetrack_mode
1202 );
1203 end if; -- l_update
1204 --
1205 end if;
1206 --
1207 -- Delete the row if it is end dated.
1208 --
1209 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
1210 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
1211 trunc(l_max_eed) = trunc(r_CGP.information3)) then
1212 --
1213 BEN_CNTNG_PRTN_ELIG_PRFL_API.delete_CNTNG_PRTN_ELIG_PRFL(
1214 --
1215 p_validate => false
1216 ,p_cntng_prtn_elig_prfl_id => l_cntng_prtn_elig_prfl_id
1217 ,p_effective_start_date => l_effective_start_date
1218 ,p_effective_end_date => l_effective_end_date
1219 ,p_object_version_number => l_object_version_number
1220 ,p_effective_date => l_max_eed
1221 ,p_datetrack_mode => hr_api.g_delete
1222 --
1223 );
1224 --
1225 end if;
1226 --
1227 l_prev_pk_id := l_current_pk_id ;
1228 --
1229 end if;
1230 --
1231 end if;
1232 --
1233 end loop;
1234 --
1235 exception when others then
1236 --
1237 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CGP',l_prefix || r_CGP.information170 || l_suffix) ;
1238 --
1239 end create_CGP_rows;
1240
1241 --
1242 ---------------------------------------------------------------
1243 ----------------------< create_EAP_rows >-----------------------
1244 ---------------------------------------------------------------
1245 --
1246 procedure create_EAP_rows
1247 (
1248 p_validate in number default 0
1249 ,p_copy_entity_txn_id in number
1250 ,p_effective_date in date
1251 ,p_prefix_suffix_text in varchar2 default null
1252 ,p_reuse_object_flag in varchar2 default null
1253 ,p_target_business_group_id in varchar2 default null
1254 ,p_prefix_suffix_cd in varchar2 default null
1255 ) is
1256 --
1257 l_AGE_FCTR_ID number;
1258 l_ELIGY_PRFL_ID number;
1259 cursor c_unique_EAP(l_table_alias varchar2) is
1260 select distinct cpe.information1,
1261 cpe.information2,
1262 cpe.information3,
1263 cpe.table_route_id
1264 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
1265 pqh_table_route tr
1266 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1267 and cpe.table_route_id = tr.table_route_id
1268 -- and tr.where_clause = l_BEN_ELIG_AGE_PRTE_F
1269 and tr.table_alias = l_table_alias
1270 and cpe.number_of_copies = 1 -- ADDITION
1271
1272 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
1273 order by information1, information2; --added for bug: 5151945
1274 --
1275 --
1276 cursor c_EAP_min_max_dates(c_table_route_id number,
1277 c_information1 number) is
1278 select
1279 min(cpe.information2) min_esd,
1280 max(cpe.information3) min_eed
1281 from ben_copy_entity_results cpe
1282 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1283 and cpe.table_route_id = c_table_route_id
1284 and cpe.information1 = c_information1 ;
1285 --
1286 cursor c_EAP(c_table_route_id number,
1287 c_information1 number,
1288 c_information2 date,
1289 c_information3 date) is
1290 select
1291 cpe.*
1292 from ben_copy_entity_results cpe
1293 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1294 and cpe.table_route_id = c_table_route_id
1295 and cpe.information1 = c_information1
1296 and cpe.information2 = c_information2
1297 and cpe.information3 = c_information3
1298 and rownum = 1 ;
1299 -- Date Track target record
1300 cursor c_find_EAP_in_target(
1301 c_effective_start_date date,
1302 c_effective_end_date date,
1303 c_business_group_id number,
1304 c_new_pk_id number) is
1305 select
1306 EAP.elig_age_prte_id new_value
1307 from BEN_ELIG_AGE_PRTE_F EAP
1308 where
1309 EAP.AGE_FCTR_ID = l_AGE_FCTR_ID and -- IK
1310 EAP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
1311 EAP.business_group_id = c_business_group_id
1312 and EAP.elig_age_prte_id <> c_new_pk_id
1313 --TEMPIK
1314 and c_effective_start_date between effective_start_date
1315 and effective_end_date ;
1316 --END TEMPIK
1317 /*TEMPIK
1318 and exists ( select null
1319 from BEN_ELIG_AGE_PRTE_F EAP1
1320 where
1321 EAP1.AGE_FCTR_ID = l_AGE_FCTR_ID and -- IK
1322 EAP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
1323 EAP1.business_group_id = c_business_group_id
1324 and EAP1.effective_start_date <= c_effective_start_date )
1325 and exists ( select null
1326 from BEN_ELIG_AGE_PRTE_F EAP2
1327 where
1328 EAP2.AGE_FCTR_ID = l_AGE_FCTR_ID and -- IK
1329 EAP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
1330 EAP2.business_group_id = c_business_group_id
1331 and EAP2.effective_end_date >= c_effective_end_date )
1332 ;
1333 TEMPIK */
1334 --TEMPIK
1335 l_dt_rec_found boolean ;
1336 --END TEMPIK
1337 --
1338 --l_current_pk_id number := null ;
1339 --UPD START
1340 --
1341 l_update boolean := false ;
1342 l_datetrack_mode varchar2(80) := hr_api.g_update;
1343 l_process_date date;
1344 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
1345 --
1346 --UPD END
1347 l_current_pk_id number := null ;
1348
1349 l_prev_pk_id number := null ;
1350 l_first_rec boolean := true ;
1351 r_EAP c_EAP%rowtype;
1352 l_elig_age_prte_id number ;
1353 l_object_version_number number ;
1354 l_effective_start_date date ;
1355 l_effective_end_date date ;
1356 l_prefix pqh_copy_entity_attribs.information1%type := null;
1357 l_suffix pqh_copy_entity_attribs.information1%type := null;
1358 l_new_value number(15);
1359 l_object_found_in_target boolean := false ;
1360 l_min_esd date;
1361 l_max_eed date;
1362 l_effective_date date;
1363 --
1364 begin
1365 -- Initialization
1366 l_object_found_in_target := false ;
1367 -- End Initialization
1368 -- Derive the prefix - sufix
1369 if p_prefix_suffix_cd = 'PREFIX' then
1370 l_prefix := p_prefix_suffix_text ;
1371 elsif p_prefix_suffix_cd = 'SUFFIX' then
1372 l_suffix := p_prefix_suffix_text ;
1373 else
1374 l_prefix := null ;
1375 l_suffix := null ;
1376 end if ;
1377 -- End Prefix Sufix derivation
1378 for r_EAP_unique in c_unique_EAP('EAP') loop
1379
1380 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
1381 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
1382 r_EAP_unique.information3 >=
1383 ben_pd_copy_to_ben_one.g_copy_effective_date)
1384 ) then
1385 --
1386 hr_utility.set_location(' r_EAP_unique.table_route_id '||r_EAP_unique.table_route_id,10);
1387 hr_utility.set_location(' r_EAP_unique.information1 '||r_EAP_unique.information1,10);
1388 hr_utility.set_location( 'r_EAP_unique.information2 '||r_EAP_unique.information2,10);
1389 hr_utility.set_location( 'r_EAP_unique.information3 '||r_EAP_unique.information3,10);
1390 -- If reuse objects flag is 'Y' then check for the object in the target business group
1391 -- if found insert the record into PLSql table and exit the loop else try create the
1392 -- object in the target business group
1393 --
1394 l_object_found_in_target := false ;
1395 --UPD START
1396 l_update := false;
1397 l_process_date := p_effective_date;
1398 l_dml_operation:= r_EAP_unique.dml_operation ;
1399 --
1400 /*****************moved from below *******************/
1401 open c_EAP(r_EAP_unique.table_route_id,
1402 r_EAP_unique.information1,
1403 r_EAP_unique.information2,
1404 r_EAP_unique.information3 ) ;
1405 --
1406 fetch c_EAP into r_EAP ;
1407 --
1408 close c_EAP ;
1409 --
1410 l_AGE_FCTR_ID := get_fk('AGE_FCTR_ID', r_EAP.INFORMATION246,l_dml_operation);
1411
1412 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EAP.INFORMATION263,l_dml_operation);
1413 /***********************************************/
1414 if l_dml_operation = 'UPDATE' then
1415 --
1416 l_object_found_in_target := TRUE;
1417 --
1418 if l_process_date between r_EAP_unique.information2 and r_EAP_unique.information3 then
1419 l_update := true;
1420 if r_EAP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
1421 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_AGE_PRTE_ID' then
1422 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_AGE_PRTE_ID' ;
1423 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EAP_unique.information1 ;
1424 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EAP_unique.information1 ;
1425 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
1426 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EAP_unique.table_route_id;
1427 --
1428 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
1429 --
1430 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1431 --
1432 -- -- log_data('EAP',l_new_value,l_prefix || r_EAP_unique.name|| l_suffix,'REUSED');
1433 --
1434 end if ;
1435 hr_utility.set_location( 'found record for update',10);
1436 --
1437 else
1438 --
1439 l_update := false;
1440 --
1441 end if;
1442 else
1443 --
1444 --UPD END
1445 l_min_esd := null ;
1446 l_max_eed := null ;
1447 open c_EAP_min_max_dates(r_EAP_unique.table_route_id, r_EAP_unique.information1 ) ;
1448 fetch c_EAP_min_max_dates into l_min_esd,l_max_eed ;
1449 --
1450
1451 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
1452 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
1453 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
1454 end if;
1455 l_min_esd := greatest(l_min_esd,r_EAP_unique.information2);
1456 /*****************moved from here *******************
1457 open c_EAP(r_EAP_unique.table_route_id,
1458 r_EAP_unique.information1,
1459 r_EAP_unique.information2,
1460 r_EAP_unique.information3 ) ;
1461 --
1462 fetch c_EAP into r_EAP ;
1463 --
1464 close c_EAP ;
1465 --
1466 l_AGE_FCTR_ID := get_fk('AGE_FCTR_ID', r_EAP.INFORMATION246,l_dml_operation);
1467
1468 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EAP.INFORMATION263,l_dml_operation);
1469 ***********************************************/
1470 if p_reuse_object_flag = 'Y' then
1471 if c_EAP_min_max_dates%found then
1472 -- cursor to find the object
1473 open c_find_EAP_in_target( l_min_esd,l_max_eed,
1474 p_target_business_group_id, nvl(l_elig_age_prte_id, -999) ) ;
1475 fetch c_find_EAP_in_target into l_new_value ;
1476 if c_find_EAP_in_target%found then
1477 --
1478 --TEMPIK
1479 l_dt_rec_found := dt_api.check_min_max_dates
1480 (p_base_table_name => 'BEN_ELIG_AGE_PRTE_F',
1481 p_base_key_column => 'ELIG_AGE_PRTE_ID',
1482 p_base_key_value => l_new_value,
1483 p_from_date => l_min_esd,
1484 p_to_date => l_max_eed );
1485 if l_dt_rec_found THEN
1486 --END TEMPIK
1487 if r_EAP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
1488 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_AGE_PRTE_ID' then
1489 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_AGE_PRTE_ID' ;
1490 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EAP_unique.information1 ;
1491 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
1492 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
1493 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EAP_unique.table_route_id;
1494 --
1495 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
1496 --
1497 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1498 end if ;
1499 --
1500 l_object_found_in_target := true ;
1501 --TEMPIK
1502 end if; -- l_dt_rec_found
1503 --END TEMPIK
1504 end if;
1505 close c_find_EAP_in_target ;
1506 --
1507 end if;
1508 end if ;
1509 --
1510 close c_EAP_min_max_dates ;
1511 end if; --if p_dml_operation
1512 --
1513 if not l_object_found_in_target OR l_update then
1514
1515 --
1516 l_current_pk_id := r_EAP.information1;
1517 --
1518 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
1519 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
1520 --
1521 if l_current_pk_id = l_prev_pk_id then
1522 --
1523 l_first_rec := false ;
1524 --
1525 else
1526 --
1527 l_first_rec := true ;
1528 --
1529 end if ;
1530 --
1531
1532 l_effective_date := r_EAP.information2;
1533 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
1534 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
1535 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
1536 end if;
1537
1538 if l_first_rec and not l_update then
1539 -- Call Create routine.
1540 hr_utility.set_location(' BEN_ELIG_AGE_PRTE_F CREATE_ELIG_AGE_PRTE ',20);
1541 BEN_ELIG_AGE_PRTE_API.CREATE_ELIG_AGE_PRTE(
1542 --
1543 P_VALIDATE => false
1544 ,P_EFFECTIVE_DATE => l_effective_date
1545 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
1546 --
1547 ,P_AGE_FCTR_ID => l_AGE_FCTR_ID
1548 ,P_EAP_ATTRIBUTE1 => r_EAP.INFORMATION111
1549 ,P_EAP_ATTRIBUTE10 => r_EAP.INFORMATION120
1550 ,P_EAP_ATTRIBUTE11 => r_EAP.INFORMATION121
1551 ,P_EAP_ATTRIBUTE12 => r_EAP.INFORMATION122
1552 ,P_EAP_ATTRIBUTE13 => r_EAP.INFORMATION123
1553 ,P_EAP_ATTRIBUTE14 => r_EAP.INFORMATION124
1554 ,P_EAP_ATTRIBUTE15 => r_EAP.INFORMATION125
1555 ,P_EAP_ATTRIBUTE16 => r_EAP.INFORMATION126
1556 ,P_EAP_ATTRIBUTE17 => r_EAP.INFORMATION127
1557 ,P_EAP_ATTRIBUTE18 => r_EAP.INFORMATION128
1558 ,P_EAP_ATTRIBUTE19 => r_EAP.INFORMATION129
1559 ,P_EAP_ATTRIBUTE2 => r_EAP.INFORMATION112
1560 ,P_EAP_ATTRIBUTE20 => r_EAP.INFORMATION130
1561 ,P_EAP_ATTRIBUTE21 => r_EAP.INFORMATION131
1562 ,P_EAP_ATTRIBUTE22 => r_EAP.INFORMATION132
1563 ,P_EAP_ATTRIBUTE23 => r_EAP.INFORMATION133
1564 ,P_EAP_ATTRIBUTE24 => r_EAP.INFORMATION134
1565 ,P_EAP_ATTRIBUTE25 => r_EAP.INFORMATION135
1566 ,P_EAP_ATTRIBUTE26 => r_EAP.INFORMATION136
1567 ,P_EAP_ATTRIBUTE27 => r_EAP.INFORMATION137
1568 ,P_EAP_ATTRIBUTE28 => r_EAP.INFORMATION138
1569 ,P_EAP_ATTRIBUTE29 => r_EAP.INFORMATION139
1570 ,P_EAP_ATTRIBUTE3 => r_EAP.INFORMATION113
1571 ,P_EAP_ATTRIBUTE30 => r_EAP.INFORMATION140
1572 ,P_EAP_ATTRIBUTE4 => r_EAP.INFORMATION114
1573 ,P_EAP_ATTRIBUTE5 => r_EAP.INFORMATION115
1574 ,P_EAP_ATTRIBUTE6 => r_EAP.INFORMATION116
1575 ,P_EAP_ATTRIBUTE7 => r_EAP.INFORMATION117
1576 ,P_EAP_ATTRIBUTE8 => r_EAP.INFORMATION118
1577 ,P_EAP_ATTRIBUTE9 => r_EAP.INFORMATION119
1578 ,P_EAP_ATTRIBUTE_CATEGORY => r_EAP.INFORMATION110
1579 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
1580 ,P_ELIG_AGE_PRTE_ID => l_elig_age_prte_id
1581 ,P_EXCLD_FLAG => r_EAP.INFORMATION11
1582 ,P_ORDR_NUM => r_EAP.INFORMATION260
1583 --
1584 -- ****** END CHANGE LINES
1585
1586 --
1587
1588 ,P_EFFECTIVE_START_DATE => l_effective_start_date
1589 ,P_EFFECTIVE_END_DATE => l_effective_end_date
1590 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
1591 ,P_CRITERIA_SCORE => r_eap.INFORMATION295
1592 ,P_CRITERIA_WEIGHT => r_eap.INFORMATION296
1593 );
1594
1595 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1596 -- Update all relevent cer records with new pk_id
1597 hr_utility.set_location('Before plsql table ',222);
1598 hr_utility.set_location('new_value id '||l_elig_age_prte_id,222);
1599 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_AGE_PRTE_ID' ;
1600 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EAP.information1 ;
1601 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_AGE_PRTE_ID ;
1602 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
1603 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EAP_unique.table_route_id;
1604 hr_utility.set_location('After plsql table ',222);
1605 --
1606 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
1607 --
1608 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1609 --
1610 else
1611 --
1612 -- Call Update routine for the pk_id created in prev run .
1613 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1614 hr_utility.set_location(' BEN_ELIG_AGE_PRTE_F UPDATE_ELIG_AGE_PRTE ',30);
1615 --UPD START
1616 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
1617 --
1618 if l_update then
1619 --
1620 l_datetrack_mode := r_EAP.datetrack_mode ;
1621 --
1622 get_dt_modes(
1623 p_effective_date => l_process_date,
1624 p_effective_end_date => r_EAP.information3,
1625 p_effective_start_date => r_EAP.information2,
1626 p_dml_operation => r_EAP.dml_operation,
1627 p_datetrack_mode => l_datetrack_mode );
1628 -- p_update => l_update
1629 --
1630 l_effective_date := l_process_date;
1631 l_ELIG_AGE_PRTE_ID := r_EAP.information1;
1632 l_object_version_number := r_EAP.information265;
1633 --
1634 end if;
1635 --
1636 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
1637 --
1638 IF l_update OR l_dml_operation <> 'UPDATE' THEN
1639 --UPD END
1640
1641
1642 BEN_ELIG_AGE_PRTE_API.UPDATE_ELIG_AGE_PRTE(
1643 --
1644 P_VALIDATE => false
1645 ,P_EFFECTIVE_DATE => l_effective_date
1646 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
1647 --
1648 ,P_AGE_FCTR_ID => l_AGE_FCTR_ID
1649 ,P_EAP_ATTRIBUTE1 => r_EAP.INFORMATION111
1650 ,P_EAP_ATTRIBUTE10 => r_EAP.INFORMATION120
1651 ,P_EAP_ATTRIBUTE11 => r_EAP.INFORMATION121
1652 ,P_EAP_ATTRIBUTE12 => r_EAP.INFORMATION122
1653 ,P_EAP_ATTRIBUTE13 => r_EAP.INFORMATION123
1654 ,P_EAP_ATTRIBUTE14 => r_EAP.INFORMATION124
1655 ,P_EAP_ATTRIBUTE15 => r_EAP.INFORMATION125
1656 ,P_EAP_ATTRIBUTE16 => r_EAP.INFORMATION126
1657 ,P_EAP_ATTRIBUTE17 => r_EAP.INFORMATION127
1658 ,P_EAP_ATTRIBUTE18 => r_EAP.INFORMATION128
1659 ,P_EAP_ATTRIBUTE19 => r_EAP.INFORMATION129
1660 ,P_EAP_ATTRIBUTE2 => r_EAP.INFORMATION112
1661 ,P_EAP_ATTRIBUTE20 => r_EAP.INFORMATION130
1662 ,P_EAP_ATTRIBUTE21 => r_EAP.INFORMATION131
1663 ,P_EAP_ATTRIBUTE22 => r_EAP.INFORMATION132
1664 ,P_EAP_ATTRIBUTE23 => r_EAP.INFORMATION133
1665 ,P_EAP_ATTRIBUTE24 => r_EAP.INFORMATION134
1666 ,P_EAP_ATTRIBUTE25 => r_EAP.INFORMATION135
1667 ,P_EAP_ATTRIBUTE26 => r_EAP.INFORMATION136
1668 ,P_EAP_ATTRIBUTE27 => r_EAP.INFORMATION137
1669 ,P_EAP_ATTRIBUTE28 => r_EAP.INFORMATION138
1670 ,P_EAP_ATTRIBUTE29 => r_EAP.INFORMATION139
1671 ,P_EAP_ATTRIBUTE3 => r_EAP.INFORMATION113
1672 ,P_EAP_ATTRIBUTE30 => r_EAP.INFORMATION140
1673 ,P_EAP_ATTRIBUTE4 => r_EAP.INFORMATION114
1674 ,P_EAP_ATTRIBUTE5 => r_EAP.INFORMATION115
1675 ,P_EAP_ATTRIBUTE6 => r_EAP.INFORMATION116
1676 ,P_EAP_ATTRIBUTE7 => r_EAP.INFORMATION117
1677 ,P_EAP_ATTRIBUTE8 => r_EAP.INFORMATION118
1678 ,P_EAP_ATTRIBUTE9 => r_EAP.INFORMATION119
1679 ,P_EAP_ATTRIBUTE_CATEGORY => r_EAP.INFORMATION110
1680 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
1681 ,P_ELIG_AGE_PRTE_ID => l_elig_age_prte_id
1682 ,P_EXCLD_FLAG => r_EAP.INFORMATION11
1683 ,P_ORDR_NUM => r_EAP.INFORMATION260
1684 --
1685 -- ****** END CHANGE LINES
1686
1687 --
1688 ,P_EFFECTIVE_START_DATE => l_effective_start_date
1689 ,P_EFFECTIVE_END_DATE => l_effective_end_date
1690 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
1691 ,P_DATETRACK_MODE => l_datetrack_mode
1692 ,P_CRITERIA_SCORE => r_eap.INFORMATION295
1693 ,P_CRITERIA_WEIGHT => r_eap.INFORMATION296
1694 );
1695 end if; -- l_update
1696 --
1697 end if;
1698 --
1699 -- Delete the row if it is end dated.
1700 --
1701 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
1702 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
1703 trunc(l_max_eed) = trunc(r_EAP.information3)) then
1704 --
1705 BEN_ELIG_AGE_PRTE_API.delete_ELIG_AGE_PRTE(
1706 --
1707 p_validate => false
1708 ,p_elig_age_prte_id => l_elig_age_prte_id
1709 ,p_effective_start_date => l_effective_start_date
1710 ,p_effective_end_date => l_effective_end_date
1711 ,p_object_version_number => l_object_version_number
1712 ,p_effective_date => l_max_eed
1713 ,p_datetrack_mode => hr_api.g_delete
1714 --
1715 );
1716 --
1717 end if;
1718 --
1719 l_prev_pk_id := l_current_pk_id ;
1720 --
1721 end if;
1722 --
1723 end if;
1724 --
1725 end loop;
1726 --
1727 exception when others then
1728 --
1729 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EAP',r_EAP.information5 ) ;
1730 --
1731 end create_EAP_rows;
1732
1733 --
1734 ---------------------------------------------------------------
1735 ----------------------< create_EBN_rows >-----------------------
1736 ---------------------------------------------------------------
1737 --
1738 procedure create_EBN_rows
1739 (
1740 p_validate in number default 0
1741 ,p_copy_entity_txn_id in number
1742 ,p_effective_date in date
1743 ,p_prefix_suffix_text in varchar2 default null
1744 ,p_reuse_object_flag in varchar2 default null
1745 ,p_target_business_group_id in varchar2 default null
1746 ,p_prefix_suffix_cd in varchar2 default null
1747 ) is
1748 --
1749 l_BENFTS_GRP_ID number;
1750 l_ELIGY_PRFL_ID number;
1751 cursor c_unique_EBN(l_table_alias varchar2) is
1752 select distinct cpe.information1,
1753 cpe.information2,
1754 cpe.information3,
1755 cpe.table_route_id
1756 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
1757 pqh_table_route tr
1758 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1759 and cpe.table_route_id = tr.table_route_id
1760 -- and tr.where_clause = l_BEN_ELIG_BENFTS_GRP_PRTE_F
1761 and tr.table_alias = l_table_alias
1762 and cpe.number_of_copies = 1 -- ADDITION
1763 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
1764 order by information1, information2; --added for bug: 5151945
1765 --
1766 --
1767 cursor c_EBN_min_max_dates(c_table_route_id number,
1768 c_information1 number) is
1769 select
1770 min(cpe.information2) min_esd,
1771 max(cpe.information3) min_eed
1772 from ben_copy_entity_results cpe
1773 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1774 and cpe.table_route_id = c_table_route_id
1775 and cpe.information1 = c_information1 ;
1776 --
1777 cursor c_EBN(c_table_route_id number,
1778 c_information1 number,
1779 c_information2 date,
1780 c_information3 date ) is
1781 select
1782 cpe.*
1783 from ben_copy_entity_results cpe
1784 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1785 and cpe.table_route_id = c_table_route_id
1786 and cpe.information1 = c_information1
1787 and cpe.information2 = c_information2
1788 and cpe.information3 = c_information3
1789 and rownum = 1 ;
1790 -- Date Track target record
1791 cursor c_find_EBN_in_target(
1792 c_effective_start_date date,
1793 c_effective_end_date date,
1794 c_business_group_id number,
1795 c_new_pk_id number) is
1796 select
1797 EBN.elig_benfts_grp_prte_id new_value
1798 from BEN_ELIG_BENFTS_GRP_PRTE_F EBN
1799 where
1800 EBN.BENFTS_GRP_ID = l_BENFTS_GRP_ID and -- IK
1801 EBN.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
1802 EBN.business_group_id = c_business_group_id
1803 and EBN.elig_benfts_grp_prte_id <> c_new_pk_id
1804 --TEMPIK
1805 and c_effective_start_date between effective_start_date
1806 and effective_end_date ;
1807 --END TEMPIK
1808 /*TEMPIK
1809 and exists ( select null
1810 from BEN_ELIG_BENFTS_GRP_PRTE_F EBN1
1811 where
1812 EBN1.BENFTS_GRP_ID = l_BENFTS_GRP_ID and -- IK
1813 EBN1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
1814 EBN1.business_group_id = c_business_group_id
1815 and EBN1.effective_start_date <= c_effective_start_date )
1816 and exists ( select null
1817 from BEN_ELIG_BENFTS_GRP_PRTE_F EBN2
1818 where
1819 EBN2.BENFTS_GRP_ID = l_BENFTS_GRP_ID and -- IK
1820 EBN2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
1821 EBN2.business_group_id = c_business_group_id
1822 and EBN2.effective_end_date >= c_effective_end_date )
1823 ;
1824 TEMPIK */
1825 --TEMPIK
1826 l_dt_rec_found boolean ;
1827 --END TEMPIK
1828 --
1829
1830 --UPD START
1831 --
1832 l_update boolean := false ;
1833 l_datetrack_mode varchar2(80) := hr_api.g_update;
1834 l_process_date date;
1835 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
1836 --
1837 --UPD END
1838 l_current_pk_id number := null ;
1839
1840 l_prev_pk_id number := null ;
1841 l_first_rec boolean := true ;
1842 r_EBN c_EBN%rowtype;
1843 l_elig_benfts_grp_prte_id number ;
1844 l_object_version_number number ;
1845 l_effective_start_date date ;
1846 l_effective_end_date date ;
1847 l_prefix pqh_copy_entity_attribs.information1%type := null;
1848 l_suffix pqh_copy_entity_attribs.information1%type := null;
1849 l_new_value number(15);
1850 l_object_found_in_target boolean := false ;
1851 l_min_esd date;
1852 l_max_eed date;
1853 l_effective_date date;
1854 --
1855 begin
1856 -- Initialization
1857 l_object_found_in_target := false ;
1858 -- End Initialization
1859 -- Derive the prefix - sufix
1860 if p_prefix_suffix_cd = 'PREFIX' then
1861 l_prefix := p_prefix_suffix_text ;
1862 elsif p_prefix_suffix_cd = 'SUFFIX' then
1863 l_suffix := p_prefix_suffix_text ;
1864 else
1865 l_prefix := null ;
1866 l_suffix := null ;
1867 end if ;
1868 -- End Prefix Sufix derivation
1869 for r_EBN_unique in c_unique_EBN('EBN') loop
1870
1871 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
1872 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
1873 r_EBN_unique.information3 >=
1874 ben_pd_copy_to_ben_one.g_copy_effective_date)
1875 ) then
1876 --
1877 hr_utility.set_location(' r_EBN_unique.table_route_id '||r_EBN_unique.table_route_id,10);
1878 hr_utility.set_location(' r_EBN_unique.information1 '||r_EBN_unique.information1,10);
1879 hr_utility.set_location( 'r_EBN_unique.information2 '||r_EBN_unique.information2,10);
1880 hr_utility.set_location( 'r_EBN_unique.information3 '||r_EBN_unique.information3,10);
1881 -- If reuse objects flag is 'Y' then check for the object in the target business group
1882 -- if found insert the record into PLSql table and exit the loop else try create the
1883 -- object in the target business group
1884 --
1885 l_object_found_in_target := false ;
1886 --UPD START
1887 l_update := false;
1888 l_process_date := p_effective_date;
1889 l_dml_operation:= r_EBN_unique.dml_operation ;
1890 /*********************moved from below *** *****/
1891 open c_EBN(r_EBN_unique.table_route_id,
1892 r_EBN_unique.information1,
1893 r_EBN_unique.information2,
1894 r_EBN_unique.information3 ) ;
1895 --
1896 fetch c_EBN into r_EBN ;
1897 --
1898 close c_EBN ;
1899 --
1900 l_BENFTS_GRP_ID := get_fk('BENFTS_GRP_ID', r_EBN.INFORMATION222,l_dml_operation);
1901
1902 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EBN.INFORMATION263,l_dml_operation);
1903 /*******************************************/
1904 --
1905 if l_dml_operation = 'UPDATE' then
1906 --
1907 l_object_found_in_target := TRUE;
1908 --
1909 if l_process_date between r_EBN_unique.information2 and r_EBN_unique.information3 then
1910 l_update := true;
1911 if r_EBN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
1912 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_BENFTS_GRP_PRTE_ID' then
1913 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_BENFTS_GRP_PRTE_ID' ;
1914 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EBN_unique.information1 ;
1915 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EBN_unique.information1 ;
1916 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
1917 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EBN_unique.table_route_id;
1918 --
1919 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
1920 --
1921 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1922 --
1923 -- -- log_data('EBN',l_new_value,l_prefix || r_EBN_unique.name|| l_suffix,'REUSED');
1924 --
1925 end if ;
1926 hr_utility.set_location( 'found record for update',10);
1927 --
1928 else
1929 --
1930 l_update := false;
1931 --
1932 end if;
1933 else
1934 --
1935 --UPD END
1936 l_min_esd := null ;
1937 l_max_eed := null ;
1938 open c_EBN_min_max_dates(r_EBN_unique.table_route_id, r_EBN_unique.information1 ) ;
1939 fetch c_EBN_min_max_dates into l_min_esd,l_max_eed ;
1940 --
1941
1942 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
1943 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
1944 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
1945 end if;
1946 l_min_esd := greatest(l_min_esd,r_EBN_unique.information2);
1947 /*********************moved from here *** please see above *****
1948 open c_EBN(r_EBN_unique.table_route_id,
1949 r_EBN_unique.information1,
1950 r_EBN_unique.information2,
1951 r_EBN_unique.information3 ) ;
1952 --
1953 fetch c_EBN into r_EBN ;
1954 --
1955 close c_EBN ;
1956 --
1957 l_BENFTS_GRP_ID := get_fk('BENFTS_GRP_ID', r_EBN.INFORMATION222,l_dml_operation);
1958
1959 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EBN.INFORMATION263,l_dml_operation);
1960 *******************************************/
1961 if p_reuse_object_flag = 'Y' then
1962 if c_EBN_min_max_dates%found then
1963 -- cursor to find the object
1964 open c_find_EBN_in_target( l_min_esd,l_max_eed,
1965 p_target_business_group_id, nvl(l_elig_benfts_grp_prte_id, -999) ) ;
1966 fetch c_find_EBN_in_target into l_new_value ;
1967 if c_find_EBN_in_target%found then
1968 --
1969 --TEMPIK
1970 l_dt_rec_found := dt_api.check_min_max_dates
1971 (p_base_table_name => 'BEN_ELIG_BENFTS_GRP_PRTE_F',
1972 p_base_key_column => 'ELIG_BENFTS_GRP_PRTE_ID',
1973 p_base_key_value => l_new_value,
1974 p_from_date => l_min_esd,
1975 p_to_date => l_max_eed );
1976 if l_dt_rec_found THEN
1977 --END TEMPIK
1978 if r_EBN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
1979 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_BENFTS_GRP_PRTE_ID' then
1980 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_BENFTS_GRP_PRTE_ID' ;
1981 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EBN_unique.information1 ;
1982 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
1983 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
1984 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EBN_unique.table_route_id;
1985 --
1986 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
1987 --
1988 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1989 end if ;
1990 --
1991 l_object_found_in_target := true ;
1992 --TEMPIK
1993 end if; -- l_dt_rec_found
1994 --END TEMPIK
1995 end if;
1996 close c_find_EBN_in_target ;
1997 --
1998 end if;
1999 end if ;
2000 --
2001 close c_EBN_min_max_dates ;
2002 end if; --if p_dml_operation
2003 --
2004 if not l_object_found_in_target OR l_update then
2005
2006 --
2007 l_current_pk_id := r_EBN.information1;
2008 --
2009 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
2010 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
2011 --
2012 if l_current_pk_id = l_prev_pk_id then
2013 --
2014 l_first_rec := false ;
2015 --
2016 else
2017 --
2018 l_first_rec := true ;
2019 --
2020 end if ;
2021 --
2022
2023 l_effective_date := r_EBN.information2;
2024 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2025 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
2026 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
2027 end if;
2028
2029 if l_first_rec and not l_update then
2030 -- Call Create routine.
2031 hr_utility.set_location(' BEN_ELIG_BENFTS_GRP_PRTE_F CREATE_ELIG_BENFTS_GRP_PRTE ',20);
2032 BEN_ELIG_BENFTS_GRP_PRTE_API.CREATE_ELIG_BENFTS_GRP_PRTE(
2033 --
2034 P_VALIDATE => false
2035 ,P_EFFECTIVE_DATE => l_effective_date
2036 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2037 --
2038 ,P_BENFTS_GRP_ID => l_BENFTS_GRP_ID
2039 ,P_EBN_ATTRIBUTE1 => r_EBN.INFORMATION111
2040 ,P_EBN_ATTRIBUTE10 => r_EBN.INFORMATION120
2041 ,P_EBN_ATTRIBUTE11 => r_EBN.INFORMATION121
2042 ,P_EBN_ATTRIBUTE12 => r_EBN.INFORMATION122
2043 ,P_EBN_ATTRIBUTE13 => r_EBN.INFORMATION123
2044 ,P_EBN_ATTRIBUTE14 => r_EBN.INFORMATION124
2045 ,P_EBN_ATTRIBUTE15 => r_EBN.INFORMATION125
2046 ,P_EBN_ATTRIBUTE16 => r_EBN.INFORMATION126
2047 ,P_EBN_ATTRIBUTE17 => r_EBN.INFORMATION127
2048 ,P_EBN_ATTRIBUTE18 => r_EBN.INFORMATION128
2049 ,P_EBN_ATTRIBUTE19 => r_EBN.INFORMATION129
2050 ,P_EBN_ATTRIBUTE2 => r_EBN.INFORMATION112
2051 ,P_EBN_ATTRIBUTE20 => r_EBN.INFORMATION130
2052 ,P_EBN_ATTRIBUTE21 => r_EBN.INFORMATION131
2053 ,P_EBN_ATTRIBUTE22 => r_EBN.INFORMATION132
2054 ,P_EBN_ATTRIBUTE23 => r_EBN.INFORMATION133
2055 ,P_EBN_ATTRIBUTE24 => r_EBN.INFORMATION134
2056 ,P_EBN_ATTRIBUTE25 => r_EBN.INFORMATION135
2057 ,P_EBN_ATTRIBUTE26 => r_EBN.INFORMATION136
2058 ,P_EBN_ATTRIBUTE27 => r_EBN.INFORMATION137
2059 ,P_EBN_ATTRIBUTE28 => r_EBN.INFORMATION138
2060 ,P_EBN_ATTRIBUTE29 => r_EBN.INFORMATION139
2061 ,P_EBN_ATTRIBUTE3 => r_EBN.INFORMATION113
2062 ,P_EBN_ATTRIBUTE30 => r_EBN.INFORMATION140
2063 ,P_EBN_ATTRIBUTE4 => r_EBN.INFORMATION114
2064 ,P_EBN_ATTRIBUTE5 => r_EBN.INFORMATION115
2065 ,P_EBN_ATTRIBUTE6 => r_EBN.INFORMATION116
2066 ,P_EBN_ATTRIBUTE7 => r_EBN.INFORMATION117
2067 ,P_EBN_ATTRIBUTE8 => r_EBN.INFORMATION118
2068 ,P_EBN_ATTRIBUTE9 => r_EBN.INFORMATION119
2069 ,P_EBN_ATTRIBUTE_CATEGORY => r_EBN.INFORMATION110
2070 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
2071 ,P_ELIG_BENFTS_GRP_PRTE_ID => l_elig_benfts_grp_prte_id
2072 ,P_EXCLD_FLAG => r_EBN.INFORMATION11
2073 ,P_ORDR_NUM => r_EBN.INFORMATION260
2074 --
2075 -- ****** END CHANGE LINES
2076
2077 --
2078
2079 ,P_EFFECTIVE_START_DATE => l_effective_start_date
2080 ,P_EFFECTIVE_END_DATE => l_effective_end_date
2081 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
2082 ,P_CRITERIA_SCORE => r_ebn.INFORMATION295
2083 ,P_CRITERIA_WEIGHT => r_ebn.INFORMATION296
2084 );
2085 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
2086 -- Update all relevent cer records with new pk_id
2087 hr_utility.set_location('Before plsql table ',222);
2088 hr_utility.set_location('new_value id '||l_elig_benfts_grp_prte_id,222);
2089 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_BENFTS_GRP_PRTE_ID' ;
2090 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EBN.information1 ;
2091 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_BENFTS_GRP_PRTE_ID ;
2092 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
2093 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EBN_unique.table_route_id;
2094 hr_utility.set_location('After plsql table ',222);
2095 --
2096 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
2097 --
2098 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
2099 --
2100 else
2101 --
2102 -- Call Update routine for the pk_id created in prev run .
2103 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
2104 hr_utility.set_location(' BEN_ELIG_BENFTS_GRP_PRTE_F UPDATE_ELIG_BENFTS_GRP_PRTE ',30);
2105 --UPD START
2106 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
2107 --
2108 if l_update then
2109 --
2110 l_datetrack_mode := r_EBN.datetrack_mode ;
2111 --
2112 get_dt_modes(
2113 p_effective_date => l_process_date,
2114 p_effective_end_date => r_EBN.information3,
2115 p_effective_start_date => r_EBN.information2,
2116 p_dml_operation => r_EBN.dml_operation,
2117 p_datetrack_mode => l_datetrack_mode );
2118 -- p_update => l_update
2119 --
2120 l_effective_date := l_process_date;
2121 l_ELIG_BENFTS_GRP_PRTE_ID := r_EBN.information1;
2122 l_object_version_number := r_EBN.information265;
2123 --
2124 end if;
2125 --
2126 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
2127 --
2128 IF l_update OR l_dml_operation <> 'UPDATE' THEN
2129 --UPD END
2130
2131
2132 BEN_ELIG_BENFTS_GRP_PRTE_API.UPDATE_ELIG_BENFTS_GRP_PRTE(
2133 --
2134 P_VALIDATE => false
2135 ,P_EFFECTIVE_DATE => l_effective_date
2136 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2137 --
2138 ,P_BENFTS_GRP_ID => l_BENFTS_GRP_ID
2139 ,P_EBN_ATTRIBUTE1 => r_EBN.INFORMATION111
2140 ,P_EBN_ATTRIBUTE10 => r_EBN.INFORMATION120
2141 ,P_EBN_ATTRIBUTE11 => r_EBN.INFORMATION121
2142 ,P_EBN_ATTRIBUTE12 => r_EBN.INFORMATION122
2143 ,P_EBN_ATTRIBUTE13 => r_EBN.INFORMATION123
2144 ,P_EBN_ATTRIBUTE14 => r_EBN.INFORMATION124
2145 ,P_EBN_ATTRIBUTE15 => r_EBN.INFORMATION125
2146 ,P_EBN_ATTRIBUTE16 => r_EBN.INFORMATION126
2147 ,P_EBN_ATTRIBUTE17 => r_EBN.INFORMATION127
2148 ,P_EBN_ATTRIBUTE18 => r_EBN.INFORMATION128
2149 ,P_EBN_ATTRIBUTE19 => r_EBN.INFORMATION129
2150 ,P_EBN_ATTRIBUTE2 => r_EBN.INFORMATION112
2151 ,P_EBN_ATTRIBUTE20 => r_EBN.INFORMATION130
2152 ,P_EBN_ATTRIBUTE21 => r_EBN.INFORMATION131
2153 ,P_EBN_ATTRIBUTE22 => r_EBN.INFORMATION132
2154 ,P_EBN_ATTRIBUTE23 => r_EBN.INFORMATION133
2155 ,P_EBN_ATTRIBUTE24 => r_EBN.INFORMATION134
2156 ,P_EBN_ATTRIBUTE25 => r_EBN.INFORMATION135
2157 ,P_EBN_ATTRIBUTE26 => r_EBN.INFORMATION136
2158 ,P_EBN_ATTRIBUTE27 => r_EBN.INFORMATION137
2159 ,P_EBN_ATTRIBUTE28 => r_EBN.INFORMATION138
2160 ,P_EBN_ATTRIBUTE29 => r_EBN.INFORMATION139
2161 ,P_EBN_ATTRIBUTE3 => r_EBN.INFORMATION113
2162 ,P_EBN_ATTRIBUTE30 => r_EBN.INFORMATION140
2163 ,P_EBN_ATTRIBUTE4 => r_EBN.INFORMATION114
2164 ,P_EBN_ATTRIBUTE5 => r_EBN.INFORMATION115
2165 ,P_EBN_ATTRIBUTE6 => r_EBN.INFORMATION116
2166 ,P_EBN_ATTRIBUTE7 => r_EBN.INFORMATION117
2167 ,P_EBN_ATTRIBUTE8 => r_EBN.INFORMATION118
2168 ,P_EBN_ATTRIBUTE9 => r_EBN.INFORMATION119
2169 ,P_EBN_ATTRIBUTE_CATEGORY => r_EBN.INFORMATION110
2170 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
2171 ,P_ELIG_BENFTS_GRP_PRTE_ID => l_elig_benfts_grp_prte_id
2172 ,P_EXCLD_FLAG => r_EBN.INFORMATION11
2173 ,P_ORDR_NUM => r_EBN.INFORMATION260
2174 --
2175 -- ****** END CHANGE LINES
2176
2177 --
2178 ,P_EFFECTIVE_START_DATE => l_effective_start_date
2179 ,P_EFFECTIVE_END_DATE => l_effective_end_date
2180 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
2181 ,P_DATETRACK_MODE => l_datetrack_mode
2182 ,P_CRITERIA_SCORE => r_ebn.INFORMATION295
2183 ,P_CRITERIA_WEIGHT => r_ebn.INFORMATION296
2184 );
2185 end if; -- l_update
2186 --
2187 end if;
2188 --
2189 -- Delete the row if it is end dated.
2190 --
2191 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
2192 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
2193 trunc(l_max_eed) = trunc(r_EBN.information3)) then
2194 --
2195 BEN_ELIG_BENFTS_GRP_PRTE_API.delete_ELIG_BENFTS_GRP_PRTE(
2196 --
2197 p_validate => false
2198 ,p_elig_benfts_grp_prte_id => l_elig_benfts_grp_prte_id
2199 ,p_effective_start_date => l_effective_start_date
2200 ,p_effective_end_date => l_effective_end_date
2201 ,p_object_version_number => l_object_version_number
2202 ,p_effective_date => l_max_eed
2203 ,p_datetrack_mode => hr_api.g_delete
2204 --
2205 );
2206 --
2207 end if;
2208 --
2209 l_prev_pk_id := l_current_pk_id ;
2210 --
2211 end if;
2212 --
2213 end if;
2214 --
2215 end loop;
2216 --
2217 exception when others then
2218 --
2219 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EBN',r_EBN.information5 ) ;
2220 --
2221 end create_EBN_rows;
2222
2223 --
2224 ---------------------------------------------------------------
2225 ----------------------< create_EBU_rows >-----------------------
2226 ---------------------------------------------------------------
2227 --
2228 procedure create_EBU_rows
2229 (
2230 p_validate in number default 0
2231 ,p_copy_entity_txn_id in number
2232 ,p_effective_date in date
2233 ,p_prefix_suffix_text in varchar2 default null
2234 ,p_reuse_object_flag in varchar2 default null
2235 ,p_target_business_group_id in varchar2 default null
2236 ,p_prefix_suffix_cd in varchar2 default null
2237 ) is
2238 --
2239 l_ELIGY_PRFL_ID number;
2240 l_BRGNG_UNIT_CD varchar2(30) ;
2241 --
2242 cursor c_unique_EBU(l_table_alias varchar2) is
2243 select distinct cpe.information1,
2244 cpe.information2,
2245 cpe.information3,
2246 cpe.table_route_id
2247 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
2248 pqh_table_route tr
2249 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2250 and cpe.table_route_id = tr.table_route_id
2251 -- and tr.where_clause = l_BEN_ELIG_BRGNG_UNIT_PRTE_F
2252 and tr.table_alias = l_table_alias
2253 and cpe.number_of_copies = 1 -- ADDITION
2254 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
2255 order by information1, information2; --added for bug: 5151945
2256 --
2257 --
2258 cursor c_EBU_min_max_dates(c_table_route_id number,
2259 c_information1 number) is
2260 select
2261 min(cpe.information2) min_esd,
2262 max(cpe.information3) min_eed
2263 from ben_copy_entity_results cpe
2264 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2265 and cpe.table_route_id = c_table_route_id
2266 and cpe.information1 = c_information1 ;
2267 --
2268 cursor c_EBU(c_table_route_id number,
2269 c_information1 number,
2270 c_information2 date,
2271 c_information3 date ) is
2272 select
2273 cpe.*
2274 from ben_copy_entity_results cpe
2275 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2276 and cpe.table_route_id = c_table_route_id
2277 and cpe.information1 = c_information1
2278 and cpe.information2 = c_information2
2279 and cpe.information3 = c_information3
2280 and rownum = 1 ;
2281 -- Date Track target record
2282 cursor c_find_EBU_in_target(
2283 c_effective_start_date date,
2284 c_effective_end_date date,
2285 c_business_group_id number,
2286 c_new_pk_id number) is
2287 select
2288 EBU.elig_brgng_unit_prte_id new_value
2289 from BEN_ELIG_BRGNG_UNIT_PRTE_F EBU
2290 where
2291 EBU.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
2292 EBU.BRGNG_UNIT_CD = l_BRGNG_UNIT_CD and -- IK
2293 EBU.business_group_id = c_business_group_id
2294 and EBU.elig_brgng_unit_prte_id <> c_new_pk_id
2295 --TEMPIK
2296 and c_effective_start_date between effective_start_date
2297 and effective_end_date ;
2298 --END TEMPIK
2299 /*TEMPIK
2300 and exists ( select null
2301 from BEN_ELIG_BRGNG_UNIT_PRTE_F EBU1
2302 where
2303 EBU1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
2304 EBU1.BRGNG_UNIT_CD = l_BRGNG_UNIT_CD and -- IK
2305 EBU1.business_group_id = c_business_group_id
2306 and EBU1.effective_start_date <= c_effective_start_date )
2307 and exists ( select null
2308 from BEN_ELIG_BRGNG_UNIT_PRTE_F EBU2
2309 where
2310 EBU2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
2311 EBU2.BRGNG_UNIT_CD = l_BRGNG_UNIT_CD and -- IK
2312 EBU2.business_group_id = c_business_group_id
2313 and EBU2.effective_end_date >= c_effective_end_date )
2314 ;
2315 TEMPIK */
2316 --TEMPIK
2317 l_dt_rec_found boolean ;
2318 --END TEMPIK
2319 --
2320
2321 --UPD START
2322 --
2323 l_update boolean := false ;
2324 l_datetrack_mode varchar2(80) := hr_api.g_update;
2325 l_process_date date;
2326 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
2327 --
2328 --UPD END
2329 l_current_pk_id number := null ;
2330
2331 l_prev_pk_id number := null ;
2332 l_first_rec boolean := true ;
2333 r_EBU c_EBU%rowtype;
2334 l_elig_brgng_unit_prte_id number ;
2335 l_object_version_number number ;
2336 l_effective_start_date date ;
2337 l_effective_end_date date ;
2338 l_prefix pqh_copy_entity_attribs.information1%type := null;
2339 l_suffix pqh_copy_entity_attribs.information1%type := null;
2340 l_new_value number(15);
2341 l_object_found_in_target boolean := false ;
2342 l_min_esd date;
2343 l_max_eed date;
2344 l_effective_date date;
2345 --
2346 begin
2347 -- Initialization
2348 l_object_found_in_target := false ;
2349 -- End Initialization
2350 -- Derive the prefix - sufix
2351 if p_prefix_suffix_cd = 'PREFIX' then
2352 l_prefix := p_prefix_suffix_text ;
2353 elsif p_prefix_suffix_cd = 'SUFFIX' then
2354 l_suffix := p_prefix_suffix_text ;
2355 else
2356 l_prefix := null ;
2357 l_suffix := null ;
2358 end if ;
2359 -- End Prefix Sufix derivation
2360 for r_EBU_unique in c_unique_EBU('EBU') loop
2361
2362 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
2363 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2364 r_EBU_unique.information3 >=
2365 ben_pd_copy_to_ben_one.g_copy_effective_date)
2366 ) then
2367 --
2368 hr_utility.set_location(' r_EBU_unique.table_route_id '||r_EBU_unique.table_route_id,10);
2369 hr_utility.set_location(' r_EBU_unique.information1 '||r_EBU_unique.information1,10);
2370 hr_utility.set_location( 'r_EBU_unique.information2 '||r_EBU_unique.information2,10);
2371 hr_utility.set_location( 'r_EBU_unique.information3 '||r_EBU_unique.information3,10);
2372 -- If reuse objects flag is 'Y' then check for the object in the target business group
2373 -- if found insert the record into PLSql table and exit the loop else try create the
2374 -- object in the target business group
2375 --
2376 l_object_found_in_target := false ;
2377 --UPD START
2378 l_update := false;
2379 l_process_date := p_effective_date;
2380 l_dml_operation:= r_EBU_unique.dml_operation ;
2381 --
2382
2383 /**********************moved from below ********************/
2384 open c_EBU(r_EBU_unique.table_route_id,
2385 r_EBU_unique.information1,
2386 r_EBU_unique.information2,
2387 r_EBU_unique.information3 ) ;
2388 --
2389 fetch c_EBU into r_EBU ;
2390 --
2391 close c_EBU ;
2392 --
2393 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EBU.INFORMATION263,l_dml_operation);
2394 l_BRGNG_UNIT_CD := r_EBU.information11 ;
2395
2396 /***********************************************/
2397
2398 if l_dml_operation = 'UPDATE' then
2399 --
2400 l_object_found_in_target := TRUE;
2401 --
2402 if l_process_date between r_EBU_unique.information2 and r_EBU_unique.information3 then
2403 l_update := true;
2404 if r_EBU_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
2405 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_BRGNG_UNIT_PRTE_ID' then
2406 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_BRGNG_UNIT_PRTE_ID' ;
2407 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EBU_unique.information1 ;
2408 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EBU_unique.information1 ;
2409 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
2410 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EBU_unique.table_route_id;
2411 --
2412 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
2413 --
2414 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
2415 --
2416 -- -- log_data('EBU',l_new_value,l_prefix || r_EBU_unique.name|| l_suffix,'REUSED');
2417 --
2418 end if ;
2419 hr_utility.set_location( 'found record for update',10);
2420 --
2421 else
2422 --
2423 l_update := false;
2424 --
2425 end if;
2426 else
2427 --
2428 --UPD END
2429 l_min_esd := null ;
2430 l_max_eed := null ;
2431 open c_EBU_min_max_dates(r_EBU_unique.table_route_id, r_EBU_unique.information1 ) ;
2432 fetch c_EBU_min_max_dates into l_min_esd,l_max_eed ;
2433 --
2434
2435 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2436 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
2437 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
2438 end if;
2439 l_min_esd := greatest(l_min_esd,r_EBU_unique.information2);
2440 /**********************moved above ********************
2441 open c_EBU(r_EBU_unique.table_route_id,
2442 r_EBU_unique.information1,
2443 r_EBU_unique.information2,
2444 r_EBU_unique.information3 ) ;
2445 --
2446 fetch c_EBU into r_EBU ;
2447 --
2448 close c_EBU ;
2449 --
2450 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EBU.INFORMATION263,l_dml_operation);
2451 l_BRGNG_UNIT_CD := r_EBU.information11 ;
2452
2453 ***********************************************/
2454 if p_reuse_object_flag = 'Y' then
2455 if c_EBU_min_max_dates%found then
2456 -- cursor to find the object
2457 open c_find_EBU_in_target( l_min_esd,l_max_eed,
2458 p_target_business_group_id, nvl(l_elig_brgng_unit_prte_id, -999) ) ;
2459 fetch c_find_EBU_in_target into l_new_value ;
2460 if c_find_EBU_in_target%found then
2461 --
2462 --TEMPIK
2463 l_dt_rec_found := dt_api.check_min_max_dates
2464 (p_base_table_name => 'BEN_ELIG_BRGNG_UNIT_PRTE_F',
2465 p_base_key_column => 'ELIG_BRGNG_UNIT_PRTE_ID',
2466 p_base_key_value => l_new_value,
2467 p_from_date => l_min_esd,
2468 p_to_date => l_max_eed );
2469 if l_dt_rec_found THEN
2470 --END TEMPIK
2471 if r_EBU_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
2472 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_BRGNG_UNIT_PRTE_ID' then
2473 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_BRGNG_UNIT_PRTE_ID' ;
2474 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EBU_unique.information1 ;
2475 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
2476 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
2477 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EBU_unique.table_route_id;
2478 --
2479 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
2480 --
2481 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
2482 end if ;
2483 --
2484 l_object_found_in_target := true ;
2485 --TEMPIK
2486 end if; -- l_dt_rec_found
2487 --END TEMPIK
2488 end if;
2489 close c_find_EBU_in_target ;
2490 --
2491 end if;
2492 end if ;
2493 --
2494 close c_EBU_min_max_dates ;
2495 end if; --if p_dml_operation
2496 --
2497 if not l_object_found_in_target OR l_update then
2498
2499 --
2500 l_current_pk_id := r_EBU.information1;
2501 --
2502 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
2503 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
2504 --
2505 if l_current_pk_id = l_prev_pk_id then
2506 --
2507 l_first_rec := false ;
2508 --
2509 else
2510 --
2511 l_first_rec := true ;
2512 --
2513 end if ;
2514 --
2515
2516 l_effective_date := r_EBU.information2;
2517 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2518 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
2519 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
2520 end if;
2521
2522 if l_first_rec and not l_update then
2523 -- Call Create routine.
2524 hr_utility.set_location(' BEN_ELIG_BRGNG_UNIT_PRTE_F CREATE_ELIG_BRGNG_UNIT_PRTE ',20);
2525 BEN_ELIG_BRGNG_UNIT_PRTE_API.CREATE_ELIG_BRGNG_UNIT_PRTE(
2526 --
2527 P_VALIDATE => false
2528 ,P_EFFECTIVE_DATE => l_effective_date
2529 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2530 --
2531 ,P_BRGNG_UNIT_CD => r_EBU.INFORMATION11
2532 ,P_EBU_ATTRIBUTE1 => r_EBU.INFORMATION111
2533 ,P_EBU_ATTRIBUTE10 => r_EBU.INFORMATION120
2534 ,P_EBU_ATTRIBUTE11 => r_EBU.INFORMATION121
2535 ,P_EBU_ATTRIBUTE12 => r_EBU.INFORMATION122
2536 ,P_EBU_ATTRIBUTE13 => r_EBU.INFORMATION123
2537 ,P_EBU_ATTRIBUTE14 => r_EBU.INFORMATION124
2538 ,P_EBU_ATTRIBUTE15 => r_EBU.INFORMATION125
2539 ,P_EBU_ATTRIBUTE16 => r_EBU.INFORMATION126
2540 ,P_EBU_ATTRIBUTE17 => r_EBU.INFORMATION127
2541 ,P_EBU_ATTRIBUTE18 => r_EBU.INFORMATION128
2542 ,P_EBU_ATTRIBUTE19 => r_EBU.INFORMATION129
2543 ,P_EBU_ATTRIBUTE2 => r_EBU.INFORMATION112
2544 ,P_EBU_ATTRIBUTE20 => r_EBU.INFORMATION130
2545 ,P_EBU_ATTRIBUTE21 => r_EBU.INFORMATION131
2546 ,P_EBU_ATTRIBUTE22 => r_EBU.INFORMATION132
2547 ,P_EBU_ATTRIBUTE23 => r_EBU.INFORMATION133
2548 ,P_EBU_ATTRIBUTE24 => r_EBU.INFORMATION134
2549 ,P_EBU_ATTRIBUTE25 => r_EBU.INFORMATION135
2550 ,P_EBU_ATTRIBUTE26 => r_EBU.INFORMATION136
2551 ,P_EBU_ATTRIBUTE27 => r_EBU.INFORMATION137
2552 ,P_EBU_ATTRIBUTE28 => r_EBU.INFORMATION138
2553 ,P_EBU_ATTRIBUTE29 => r_EBU.INFORMATION139
2554 ,P_EBU_ATTRIBUTE3 => r_EBU.INFORMATION113
2555 ,P_EBU_ATTRIBUTE30 => r_EBU.INFORMATION140
2556 ,P_EBU_ATTRIBUTE4 => r_EBU.INFORMATION114
2557 ,P_EBU_ATTRIBUTE5 => r_EBU.INFORMATION115
2558 ,P_EBU_ATTRIBUTE6 => r_EBU.INFORMATION116
2559 ,P_EBU_ATTRIBUTE7 => r_EBU.INFORMATION117
2560 ,P_EBU_ATTRIBUTE8 => r_EBU.INFORMATION118
2561 ,P_EBU_ATTRIBUTE9 => r_EBU.INFORMATION119
2562 ,P_EBU_ATTRIBUTE_CATEGORY => r_EBU.INFORMATION110
2563 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
2564 ,P_ELIG_BRGNG_UNIT_PRTE_ID => l_elig_brgng_unit_prte_id
2565 ,P_EXCLD_FLAG => r_EBU.INFORMATION12
2566 ,P_ORDR_NUM => r_EBU.INFORMATION260
2567 --
2568 -- ****** END CHANGE LINES
2569
2570 --
2571
2572 ,P_EFFECTIVE_START_DATE => l_effective_start_date
2573 ,P_EFFECTIVE_END_DATE => l_effective_end_date
2574 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
2575 ,P_CRITERIA_SCORE => r_ebu.INFORMATION295
2576 ,P_CRITERIA_WEIGHT => r_ebu.INFORMATION296
2577 );
2578 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
2579 -- Update all relevent cer records with new pk_id
2580 hr_utility.set_location('Before plsql table ',222);
2581 hr_utility.set_location('new_value id '||l_elig_brgng_unit_prte_id,222);
2582 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_BRGNG_UNIT_PRTE_ID' ;
2583 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EBU.information1 ;
2584 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_BRGNG_UNIT_PRTE_ID ;
2585 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
2586 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EBU_unique.table_route_id;
2587 hr_utility.set_location('After plsql table ',222);
2588 --
2589 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
2590 --
2591 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
2592 --
2593 else
2594 --
2595 -- Call Update routine for the pk_id created in prev run .
2596 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
2597 hr_utility.set_location(' BEN_ELIG_BRGNG_UNIT_PRTE_F UPDATE_ELIG_BRGNG_UNIT_PRTE ',30);
2598 --UPD START
2599 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
2600 --
2601 if l_update then
2602 --
2603 l_datetrack_mode := r_EBU.datetrack_mode ;
2604 --
2605 get_dt_modes(
2606 p_effective_date => l_process_date,
2607 p_effective_end_date => r_EBU.information3,
2608 p_effective_start_date => r_EBU.information2,
2609 p_dml_operation => r_EBU.dml_operation,
2610 p_datetrack_mode => l_datetrack_mode );
2611 -- p_update => l_update
2612 --
2613 l_effective_date := l_process_date;
2614 l_ELIG_BRGNG_UNIT_PRTE_ID := r_EBU.information1;
2615 l_object_version_number := r_EBU.information265;
2616 --
2617 end if;
2618 --
2619 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
2620 --
2621 IF l_update OR l_dml_operation <> 'UPDATE' THEN
2622 --UPD END
2623
2624
2625 BEN_ELIG_BRGNG_UNIT_PRTE_API.UPDATE_ELIG_BRGNG_UNIT_PRTE(
2626 --
2627 P_VALIDATE => false
2628 ,P_EFFECTIVE_DATE => l_effective_date
2629 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2630 --
2631 ,P_BRGNG_UNIT_CD => r_EBU.INFORMATION11
2632 ,P_EBU_ATTRIBUTE1 => r_EBU.INFORMATION111
2633 ,P_EBU_ATTRIBUTE10 => r_EBU.INFORMATION120
2634 ,P_EBU_ATTRIBUTE11 => r_EBU.INFORMATION121
2635 ,P_EBU_ATTRIBUTE12 => r_EBU.INFORMATION122
2636 ,P_EBU_ATTRIBUTE13 => r_EBU.INFORMATION123
2637 ,P_EBU_ATTRIBUTE14 => r_EBU.INFORMATION124
2638 ,P_EBU_ATTRIBUTE15 => r_EBU.INFORMATION125
2639 ,P_EBU_ATTRIBUTE16 => r_EBU.INFORMATION126
2640 ,P_EBU_ATTRIBUTE17 => r_EBU.INFORMATION127
2641 ,P_EBU_ATTRIBUTE18 => r_EBU.INFORMATION128
2642 ,P_EBU_ATTRIBUTE19 => r_EBU.INFORMATION129
2643 ,P_EBU_ATTRIBUTE2 => r_EBU.INFORMATION112
2644 ,P_EBU_ATTRIBUTE20 => r_EBU.INFORMATION130
2645 ,P_EBU_ATTRIBUTE21 => r_EBU.INFORMATION131
2646 ,P_EBU_ATTRIBUTE22 => r_EBU.INFORMATION132
2647 ,P_EBU_ATTRIBUTE23 => r_EBU.INFORMATION133
2648 ,P_EBU_ATTRIBUTE24 => r_EBU.INFORMATION134
2649 ,P_EBU_ATTRIBUTE25 => r_EBU.INFORMATION135
2650 ,P_EBU_ATTRIBUTE26 => r_EBU.INFORMATION136
2651 ,P_EBU_ATTRIBUTE27 => r_EBU.INFORMATION137
2652 ,P_EBU_ATTRIBUTE28 => r_EBU.INFORMATION138
2653 ,P_EBU_ATTRIBUTE29 => r_EBU.INFORMATION139
2654 ,P_EBU_ATTRIBUTE3 => r_EBU.INFORMATION113
2655 ,P_EBU_ATTRIBUTE30 => r_EBU.INFORMATION140
2656 ,P_EBU_ATTRIBUTE4 => r_EBU.INFORMATION114
2657 ,P_EBU_ATTRIBUTE5 => r_EBU.INFORMATION115
2658 ,P_EBU_ATTRIBUTE6 => r_EBU.INFORMATION116
2659 ,P_EBU_ATTRIBUTE7 => r_EBU.INFORMATION117
2660 ,P_EBU_ATTRIBUTE8 => r_EBU.INFORMATION118
2661 ,P_EBU_ATTRIBUTE9 => r_EBU.INFORMATION119
2662 ,P_EBU_ATTRIBUTE_CATEGORY => r_EBU.INFORMATION110
2663 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
2664 ,P_ELIG_BRGNG_UNIT_PRTE_ID => l_elig_brgng_unit_prte_id
2665 ,P_EXCLD_FLAG => r_EBU.INFORMATION12
2666 ,P_ORDR_NUM => r_EBU.INFORMATION260
2667 --
2668 -- ****** END CHANGE LINES
2669
2670 --
2671 ,P_EFFECTIVE_START_DATE => l_effective_start_date
2672 ,P_EFFECTIVE_END_DATE => l_effective_end_date
2673 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
2674 ,P_DATETRACK_MODE => l_datetrack_mode
2675 ,P_CRITERIA_SCORE => r_ebu.INFORMATION295
2676 ,P_CRITERIA_WEIGHT => r_ebu.INFORMATION296
2677 );
2678 end if; -- l_update
2679 --
2680 end if;
2681 --
2682 -- Delete the row if it is end dated.
2683 --
2684 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
2685 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
2686 trunc(l_max_eed) = trunc(r_EBU.information3)) then
2687 --
2688 BEN_ELIG_BRGNG_UNIT_PRTE_API.delete_ELIG_BRGNG_UNIT_PRTE(
2689 --
2690 p_validate => false
2691 ,p_elig_brgng_unit_prte_id => l_elig_brgng_unit_prte_id
2692 ,p_effective_start_date => l_effective_start_date
2693 ,p_effective_end_date => l_effective_end_date
2694 ,p_object_version_number => l_object_version_number
2695 ,p_effective_date => l_max_eed
2696 ,p_datetrack_mode => hr_api.g_delete
2697 --
2698 );
2699 --
2700 end if;
2701 --
2702 l_prev_pk_id := l_current_pk_id ;
2703 --
2704 end if;
2705 --
2706 end if;
2707 --
2708 end loop;
2709 --
2710 exception when others then
2711 --
2712 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EBU',r_EBU.information5 ) ;
2713 --
2714 end create_EBU_rows;
2715
2716 --
2717 ---------------------------------------------------------------
2718 ----------------------< create_ECL_rows >-----------------------
2719 ---------------------------------------------------------------
2720 --
2721 procedure create_ECL_rows
2722 (
2723 p_validate in number default 0
2724 ,p_copy_entity_txn_id in number
2725 ,p_effective_date in date
2726 ,p_prefix_suffix_text in varchar2 default null
2727 ,p_reuse_object_flag in varchar2 default null
2728 ,p_target_business_group_id in varchar2 default null
2729 ,p_prefix_suffix_cd in varchar2 default null
2730 ) is
2731 --
2732 l_COMP_LVL_FCTR_ID number;
2733 l_ELIGY_PRFL_ID number;
2734 cursor c_unique_ECL(l_table_alias varchar2) is
2735 select distinct cpe.information1,
2736 cpe.information2,
2737 cpe.information3,
2738 cpe.table_route_id
2739 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
2740 pqh_table_route tr
2741 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2742 and cpe.table_route_id = tr.table_route_id
2743 -- and tr.where_clause = l_BEN_ELIG_COMP_LVL_PRTE_F
2744 and tr.table_alias = l_table_alias
2745 and cpe.number_of_copies = 1 -- ADDITION
2746 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
2747 order by information1, information2; --added for bug: 5151945
2748 --
2749 --
2750 cursor c_ECL_min_max_dates(c_table_route_id number,
2751 c_information1 number) is
2752 select
2753 min(cpe.information2) min_esd,
2754 max(cpe.information3) min_eed
2755 from ben_copy_entity_results cpe
2756 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2757 and cpe.table_route_id = c_table_route_id
2758 and cpe.information1 = c_information1 ;
2759 --
2760 cursor c_ECL(c_table_route_id number,
2761 c_information1 number,
2762 c_information2 date,
2763 c_information3 date ) is
2764 select
2765 cpe.*
2766 from ben_copy_entity_results cpe
2767 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2768 and cpe.table_route_id = c_table_route_id
2769 and cpe.information1 = c_information1
2770 and cpe.information2 = c_information2
2771 and cpe.information3 = c_information3
2772 and rownum = 1 ;
2773 -- Date Track target record
2774 cursor c_find_ECL_in_target(
2775 c_effective_start_date date,
2776 c_effective_end_date date,
2777 c_business_group_id number,
2778 c_new_pk_id number) is
2779 select
2780 ECL.elig_comp_lvl_prte_id new_value
2781 from BEN_ELIG_COMP_LVL_PRTE_F ECL
2782 where
2783 ECL.COMP_LVL_FCTR_ID = l_COMP_LVL_FCTR_ID and -- IK removed nvl for all
2784 ECL.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
2785 ECL.business_group_id = c_business_group_id
2786 and ECL.elig_comp_lvl_prte_id <> c_new_pk_id
2787 --TEMPIK
2788 and c_effective_start_date between effective_start_date
2789 and effective_end_date ;
2790 --END TEMPIK
2791 /*TEMPIK
2792 and exists ( select null
2793 from BEN_ELIG_COMP_LVL_PRTE_F ECL1
2794 where
2795 ECL1.COMP_LVL_FCTR_ID = l_COMP_LVL_FCTR_ID and
2796 ECL1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
2797 ECL1.business_group_id = c_business_group_id
2798 and ECL1.effective_start_date <= c_effective_start_date )
2799 and exists ( select null
2800 from BEN_ELIG_COMP_LVL_PRTE_F ECL2
2801 where
2802 ECL2.COMP_LVL_FCTR_ID = l_COMP_LVL_FCTR_ID and
2803 ECL2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
2804 ECL2.business_group_id = c_business_group_id
2805 and ECL2.effective_end_date >= c_effective_end_date )
2806 ;
2807 TEMPIK */
2808 --TEMPIK
2809 l_dt_rec_found boolean ;
2810 --END TEMPIK
2811 --
2812
2813 --UPD START
2814 --
2815 l_update boolean := false ;
2816 l_datetrack_mode varchar2(80) := hr_api.g_update;
2817 l_process_date date;
2818 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
2819 --
2820 --UPD END
2821 l_current_pk_id number := null ;
2822
2823 l_prev_pk_id number := null ;
2824 l_first_rec boolean := true ;
2825 r_ECL c_ECL%rowtype;
2826 l_elig_comp_lvl_prte_id number ;
2827 l_object_version_number number ;
2828 l_effective_start_date date ;
2829 l_effective_end_date date ;
2830 l_prefix pqh_copy_entity_attribs.information1%type := null;
2831 l_suffix pqh_copy_entity_attribs.information1%type := null;
2832 l_new_value number(15);
2833 l_object_found_in_target boolean := false ;
2834 l_min_esd date;
2835 l_max_eed date;
2836 l_effective_date date;
2837 --
2838 begin
2839 -- Initialization
2840 l_object_found_in_target := false ;
2841 -- End Initialization
2842 -- Derive the prefix - sufix
2843 if p_prefix_suffix_cd = 'PREFIX' then
2844 l_prefix := p_prefix_suffix_text ;
2845 elsif p_prefix_suffix_cd = 'SUFFIX' then
2846 l_suffix := p_prefix_suffix_text ;
2847 else
2848 l_prefix := null ;
2849 l_suffix := null ;
2850 end if ;
2851 -- End Prefix Sufix derivation
2852 for r_ECL_unique in c_unique_ECL('ECL') loop
2853
2854 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
2855 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2856 r_ECL_unique.information3 >=
2857 ben_pd_copy_to_ben_one.g_copy_effective_date)
2858 ) then
2859 --
2860 hr_utility.set_location(' r_ECL_unique.table_route_id '||r_ECL_unique.table_route_id,10);
2861 hr_utility.set_location(' r_ECL_unique.information1 '||r_ECL_unique.information1,10);
2862 hr_utility.set_location( 'r_ECL_unique.information2 '||r_ECL_unique.information2,10);
2863 hr_utility.set_location( 'r_ECL_unique.information3 '||r_ECL_unique.information3,10);
2864 -- If reuse objects flag is 'Y' then check for the object in the target business group
2865 -- if found insert the record into PLSql table and exit the loop else try create the
2866 -- object in the target business group
2867 --
2868 l_object_found_in_target := false ;
2869 --UPD START
2870 l_update := false;
2871 l_process_date := p_effective_date;
2872 l_dml_operation:= r_ECL_unique.dml_operation ;
2873 --
2874 /*************************moved from below ***************************/
2875 open c_ECL(r_ECL_unique.table_route_id,
2876 r_ECL_unique.information1,
2877 r_ECL_unique.information2,
2878 r_ECL_unique.information3 ) ;
2879 --
2880 fetch c_ECL into r_ECL ;
2881 --
2882 close c_ECL ;
2883 --
2884 l_COMP_LVL_FCTR_ID := get_fk('COMP_LVL_FCTR_ID', r_ECL.INFORMATION254,l_dml_operation);
2885 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ECL.INFORMATION263,l_dml_operation);
2886
2887 /********************************************/
2888 if l_dml_operation = 'UPDATE' then
2889 --
2890 l_object_found_in_target := TRUE;
2891 --
2892 if l_process_date between r_ECL_unique.information2 and r_ECL_unique.information3 then
2893 l_update := true;
2894 if r_ECL_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
2895 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_COMP_LVL_PRTE_ID' then
2896 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_COMP_LVL_PRTE_ID' ;
2897 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECL_unique.information1 ;
2898 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ECL_unique.information1 ;
2899 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
2900 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECL_unique.table_route_id;
2901 --
2902 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
2903 --
2904 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
2905 --
2906 -- -- log_data('ECL',l_new_value,l_prefix || r_ECL_unique.name|| l_suffix,'REUSED');
2907 --
2908 end if ;
2909 hr_utility.set_location( 'found record for update',10);
2910 --
2911 else
2912 --
2913 l_update := false;
2914 --
2915 end if;
2916 else
2917 --
2918 --UPD END
2919 l_min_esd := null ;
2920 l_max_eed := null ;
2921 open c_ECL_min_max_dates(r_ECL_unique.table_route_id, r_ECL_unique.information1 ) ;
2922 fetch c_ECL_min_max_dates into l_min_esd,l_max_eed ;
2923 --
2924
2925 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2926 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
2927 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
2928 end if;
2929 l_min_esd := greatest(l_min_esd,r_ECL_unique.information2);
2930 /*************************moved above ***************************
2931 open c_ECL(r_ECL_unique.table_route_id,
2932 r_ECL_unique.information1,
2933 r_ECL_unique.information2,
2934 r_ECL_unique.information3 ) ;
2935 --
2936 fetch c_ECL into r_ECL ;
2937 --
2938 close c_ECL ;
2939 --
2940 l_COMP_LVL_FCTR_ID := get_fk('COMP_LVL_FCTR_ID', r_ECL.INFORMATION254,l_dml_operation);
2941 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ECL.INFORMATION263,l_dml_operation);
2942
2943 ********************************************/
2944 if p_reuse_object_flag = 'Y' then
2945 if c_ECL_min_max_dates%found then
2946 -- cursor to find the object
2947 open c_find_ECL_in_target( l_min_esd,l_max_eed,
2948 p_target_business_group_id, nvl(l_elig_comp_lvl_prte_id, -999) ) ;
2949 fetch c_find_ECL_in_target into l_new_value ;
2950 if c_find_ECL_in_target%found then
2951 --
2952 --TEMPIK
2953 l_dt_rec_found := dt_api.check_min_max_dates
2954 (p_base_table_name => 'BEN_ELIG_COMP_LVL_PRTE_F',
2955 p_base_key_column => 'ELIG_COMP_LVL_PRTE_ID',
2956 p_base_key_value => l_new_value,
2957 p_from_date => l_min_esd,
2958 p_to_date => l_max_eed );
2959 if l_dt_rec_found THEN
2960 --END TEMPIK
2961 if r_ECL_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
2962 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_COMP_LVL_PRTE_ID' then
2963 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_COMP_LVL_PRTE_ID' ;
2964 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECL_unique.information1 ;
2965 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
2966 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
2967 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECL_unique.table_route_id;
2968 --
2969 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
2970 --
2971 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
2972 end if ;
2973 --
2974 l_object_found_in_target := true ;
2975 --TEMPIK
2976 end if; -- l_dt_rec_found
2977 --END TEMPIK
2978 end if;
2979 close c_find_ECL_in_target ;
2980 --
2981 end if;
2982 end if ;
2983 --
2984 close c_ECL_min_max_dates ;
2985 end if; --if p_dml_operation
2986 --
2987 if not l_object_found_in_target OR l_update then
2988
2989 --
2990 l_current_pk_id := r_ECL.information1;
2991 --
2992 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
2993 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
2994 --
2995 if l_current_pk_id = l_prev_pk_id then
2996 --
2997 l_first_rec := false ;
2998 --
2999 else
3000 --
3001 l_first_rec := true ;
3002 --
3003 end if ;
3004 --
3005
3006 l_effective_date := r_ECL.information2;
3007 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3008 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
3009 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
3010 end if;
3011
3012 if l_first_rec and not l_update then
3013 -- Call Create routine.
3014 hr_utility.set_location(' BEN_ELIG_COMP_LVL_PRTE_F CREATE_ELIG_COMP_LVL_PRTE ',20);
3015 BEN_ELIG_COMP_LVL_PRTE_API.CREATE_ELIG_COMP_LVL_PRTE(
3016 --
3017 P_VALIDATE => false
3018 ,P_EFFECTIVE_DATE => l_effective_date
3019 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
3020 --
3021 ,P_COMP_LVL_FCTR_ID => l_COMP_LVL_FCTR_ID
3022 ,P_ECL_ATTRIBUTE1 => r_ECL.INFORMATION111
3023 ,P_ECL_ATTRIBUTE10 => r_ECL.INFORMATION120
3024 ,P_ECL_ATTRIBUTE11 => r_ECL.INFORMATION121
3025 ,P_ECL_ATTRIBUTE12 => r_ECL.INFORMATION122
3026 ,P_ECL_ATTRIBUTE13 => r_ECL.INFORMATION123
3027 ,P_ECL_ATTRIBUTE14 => r_ECL.INFORMATION124
3028 ,P_ECL_ATTRIBUTE15 => r_ECL.INFORMATION125
3029 ,P_ECL_ATTRIBUTE16 => r_ECL.INFORMATION126
3030 ,P_ECL_ATTRIBUTE17 => r_ECL.INFORMATION127
3031 ,P_ECL_ATTRIBUTE18 => r_ECL.INFORMATION128
3032 ,P_ECL_ATTRIBUTE19 => r_ECL.INFORMATION129
3033 ,P_ECL_ATTRIBUTE2 => r_ECL.INFORMATION112
3034 ,P_ECL_ATTRIBUTE20 => r_ECL.INFORMATION130
3035 ,P_ECL_ATTRIBUTE21 => r_ECL.INFORMATION131
3036 ,P_ECL_ATTRIBUTE22 => r_ECL.INFORMATION132
3037 ,P_ECL_ATTRIBUTE23 => r_ECL.INFORMATION133
3038 ,P_ECL_ATTRIBUTE24 => r_ECL.INFORMATION134
3039 ,P_ECL_ATTRIBUTE25 => r_ECL.INFORMATION135
3040 ,P_ECL_ATTRIBUTE26 => r_ECL.INFORMATION136
3041 ,P_ECL_ATTRIBUTE27 => r_ECL.INFORMATION137
3042 ,P_ECL_ATTRIBUTE28 => r_ECL.INFORMATION138
3043 ,P_ECL_ATTRIBUTE29 => r_ECL.INFORMATION139
3044 ,P_ECL_ATTRIBUTE3 => r_ECL.INFORMATION113
3045 ,P_ECL_ATTRIBUTE30 => r_ECL.INFORMATION140
3046 ,P_ECL_ATTRIBUTE4 => r_ECL.INFORMATION114
3047 ,P_ECL_ATTRIBUTE5 => r_ECL.INFORMATION115
3048 ,P_ECL_ATTRIBUTE6 => r_ECL.INFORMATION116
3049 ,P_ECL_ATTRIBUTE7 => r_ECL.INFORMATION117
3050 ,P_ECL_ATTRIBUTE8 => r_ECL.INFORMATION118
3051 ,P_ECL_ATTRIBUTE9 => r_ECL.INFORMATION119
3052 ,P_ECL_ATTRIBUTE_CATEGORY => r_ECL.INFORMATION110
3053 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
3054 ,P_ELIG_COMP_LVL_PRTE_ID => l_elig_comp_lvl_prte_id
3055 ,P_EXCLD_FLAG => r_ECL.INFORMATION11
3056 ,P_ORDR_NUM => r_ECL.INFORMATION260
3057 --
3058 -- ****** END CHANGE LINES
3059
3060 --
3061
3062 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3063 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3064 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3065 ,P_CRITERIA_SCORE => r_ecl.INFORMATION295
3066 ,P_CRITERIA_WEIGHT => r_ecl.INFORMATION296
3067 );
3068 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
3069 -- Update all relevent cer records with new pk_id
3070 hr_utility.set_location('Before plsql table ',222);
3071 hr_utility.set_location('new_value id '||l_elig_comp_lvl_prte_id,222);
3072 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_COMP_LVL_PRTE_ID' ;
3073 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECL.information1 ;
3074 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_COMP_LVL_PRTE_ID ;
3075 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
3076 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECL_unique.table_route_id;
3077 hr_utility.set_location('After plsql table ',222);
3078 --
3079 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
3080 --
3081 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
3082 --
3083 else
3084 --
3085 -- Call Update routine for the pk_id created in prev run .
3086 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
3087 hr_utility.set_location(' BEN_ELIG_COMP_LVL_PRTE_F UPDATE_ELIG_COMP_LVL_PRTE ',30);
3088 --UPD START
3089 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
3090 --
3091 if l_update then
3092 --
3093 l_datetrack_mode := r_ECL.datetrack_mode ;
3094 --
3095 get_dt_modes(
3096 p_effective_date => l_process_date,
3097 p_effective_end_date => r_ECL.information3,
3098 p_effective_start_date => r_ECL.information2,
3099 p_dml_operation => r_ECL.dml_operation,
3100 p_datetrack_mode => l_datetrack_mode );
3101 -- p_update => l_update
3102 --
3103 l_effective_date := l_process_date;
3104 l_ELIG_COMP_LVL_PRTE_ID := r_ECL.information1;
3105 l_object_version_number := r_ECL.information265;
3106 --
3107 end if;
3108 --
3109 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
3110 --
3111 IF l_update OR l_dml_operation <> 'UPDATE' THEN
3112 --UPD END
3113
3114
3115 BEN_ELIG_COMP_LVL_PRTE_API.UPDATE_ELIG_COMP_LVL_PRTE(
3116 --
3117 P_VALIDATE => false
3118 ,P_EFFECTIVE_DATE => l_effective_date
3119 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
3120 --
3121 ,P_COMP_LVL_FCTR_ID => l_COMP_LVL_FCTR_ID
3122 ,P_ECL_ATTRIBUTE1 => r_ECL.INFORMATION111
3123 ,P_ECL_ATTRIBUTE10 => r_ECL.INFORMATION120
3124 ,P_ECL_ATTRIBUTE11 => r_ECL.INFORMATION121
3125 ,P_ECL_ATTRIBUTE12 => r_ECL.INFORMATION122
3126 ,P_ECL_ATTRIBUTE13 => r_ECL.INFORMATION123
3127 ,P_ECL_ATTRIBUTE14 => r_ECL.INFORMATION124
3128 ,P_ECL_ATTRIBUTE15 => r_ECL.INFORMATION125
3129 ,P_ECL_ATTRIBUTE16 => r_ECL.INFORMATION126
3130 ,P_ECL_ATTRIBUTE17 => r_ECL.INFORMATION127
3131 ,P_ECL_ATTRIBUTE18 => r_ECL.INFORMATION128
3132 ,P_ECL_ATTRIBUTE19 => r_ECL.INFORMATION129
3133 ,P_ECL_ATTRIBUTE2 => r_ECL.INFORMATION112
3134 ,P_ECL_ATTRIBUTE20 => r_ECL.INFORMATION130
3135 ,P_ECL_ATTRIBUTE21 => r_ECL.INFORMATION131
3136 ,P_ECL_ATTRIBUTE22 => r_ECL.INFORMATION132
3137 ,P_ECL_ATTRIBUTE23 => r_ECL.INFORMATION133
3138 ,P_ECL_ATTRIBUTE24 => r_ECL.INFORMATION134
3139 ,P_ECL_ATTRIBUTE25 => r_ECL.INFORMATION135
3140 ,P_ECL_ATTRIBUTE26 => r_ECL.INFORMATION136
3141 ,P_ECL_ATTRIBUTE27 => r_ECL.INFORMATION137
3142 ,P_ECL_ATTRIBUTE28 => r_ECL.INFORMATION138
3143 ,P_ECL_ATTRIBUTE29 => r_ECL.INFORMATION139
3144 ,P_ECL_ATTRIBUTE3 => r_ECL.INFORMATION113
3145 ,P_ECL_ATTRIBUTE30 => r_ECL.INFORMATION140
3146 ,P_ECL_ATTRIBUTE4 => r_ECL.INFORMATION114
3147 ,P_ECL_ATTRIBUTE5 => r_ECL.INFORMATION115
3148 ,P_ECL_ATTRIBUTE6 => r_ECL.INFORMATION116
3149 ,P_ECL_ATTRIBUTE7 => r_ECL.INFORMATION117
3150 ,P_ECL_ATTRIBUTE8 => r_ECL.INFORMATION118
3151 ,P_ECL_ATTRIBUTE9 => r_ECL.INFORMATION119
3152 ,P_ECL_ATTRIBUTE_CATEGORY => r_ECL.INFORMATION110
3153 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
3154 ,P_ELIG_COMP_LVL_PRTE_ID => l_elig_comp_lvl_prte_id
3155 ,P_EXCLD_FLAG => r_ECL.INFORMATION11
3156 ,P_ORDR_NUM => r_ECL.INFORMATION260
3157 --
3158 -- ****** END CHANGE LINES
3159
3160 --
3161 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3162 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3163 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3164 ,P_DATETRACK_MODE => l_datetrack_mode
3165 ,P_CRITERIA_SCORE => r_ecl.INFORMATION295
3166 ,P_CRITERIA_WEIGHT => r_ecl.INFORMATION296
3167 );
3168 end if; -- l_update
3169 --
3170 end if;
3171 --
3172 -- Delete the row if it is end dated.
3173 --
3174 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
3175 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
3176 trunc(l_max_eed) = trunc(r_ECL.information3)) then
3177 --
3178 BEN_ELIG_COMP_LVL_PRTE_API.delete_ELIG_COMP_LVL_PRTE(
3179 --
3180 p_validate => false
3181 ,p_elig_comp_lvl_prte_id => l_elig_comp_lvl_prte_id
3182 ,p_effective_start_date => l_effective_start_date
3183 ,p_effective_end_date => l_effective_end_date
3184 ,p_object_version_number => l_object_version_number
3185 ,p_effective_date => l_max_eed
3186 ,p_datetrack_mode => hr_api.g_delete
3187 --
3188 );
3189 --
3190 end if;
3191 --
3192 l_prev_pk_id := l_current_pk_id ;
3193 --
3194 end if;
3195 --
3196 end if;
3197 --
3198 end loop;
3199 --
3200 exception when others then
3201 --
3202 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ECL',r_ECL.information5 ) ;
3203 --
3204 end create_ECL_rows;
3205
3206 --
3207 ---------------------------------------------------------------
3208 ----------------------< create_ECP_rows >-----------------------
3209 ---------------------------------------------------------------
3210 --
3211 procedure create_ECP_rows
3212 (
3213 p_validate in number default 0
3214 ,p_copy_entity_txn_id in number
3215 ,p_effective_date in date
3216 ,p_prefix_suffix_text in varchar2 default null
3217 ,p_reuse_object_flag in varchar2 default null
3218 ,p_target_business_group_id in varchar2 default null
3219 ,p_prefix_suffix_cd in varchar2 default null
3220 ) is
3221 --
3222 l_CMBN_AGE_LOS_FCTR_ID number;
3223 l_ELIGY_PRFL_ID number;
3224 cursor c_unique_ECP(l_table_alias varchar2) is
3225 select distinct cpe.information1,
3226 cpe.information2,
3227 cpe.information3,
3228 cpe.table_route_id
3229 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
3230 pqh_table_route tr
3231 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3232 and cpe.table_route_id = tr.table_route_id
3233 -- and tr.where_clause = l_BEN_ELIG_CMBN_AGE_LOS_PRTE_F
3234 and tr.table_alias = l_table_alias
3235 and cpe.number_of_copies = 1 -- ADDITION
3236 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
3237 order by information1, information2; --added for bug: 5151945
3238 --
3239 --
3240 cursor c_ECP_min_max_dates(c_table_route_id number,
3241 c_information1 number) is
3242 select
3243 min(cpe.information2) min_esd,
3244 max(cpe.information3) min_eed
3245 from ben_copy_entity_results cpe
3246 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3247 and cpe.table_route_id = c_table_route_id
3248 and cpe.information1 = c_information1 ;
3249 --
3250 cursor c_ECP(c_table_route_id number,
3251 c_information1 number,
3252 c_information2 date,
3253 c_information3 date ) is
3254 select
3255 cpe.*
3256 from ben_copy_entity_results cpe
3257 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3258 and cpe.table_route_id = c_table_route_id
3259 and cpe.information1 = c_information1
3260 and cpe.information2 = c_information2
3261 and cpe.information3 = c_information3
3262 and rownum = 1 ;
3263 -- Date Track target record
3264 cursor c_find_ECP_in_target(
3265 c_effective_start_date date,
3266 c_effective_end_date date,
3267 c_business_group_id number,
3268 c_new_pk_id number) is
3269 select
3270 ECP.elig_cmbn_age_los_prte_id new_value
3271 from BEN_ELIG_CMBN_AGE_LOS_PRTE_F ECP
3272 where
3273 ECP.CMBN_AGE_LOS_FCTR_ID = l_CMBN_AGE_LOS_FCTR_ID and -- IK removed nvl
3274 ECP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
3275 ECP.business_group_id = c_business_group_id
3276 and ECP.elig_cmbn_age_los_prte_id <> c_new_pk_id
3277 --TEMPIK
3278 and c_effective_start_date between effective_start_date
3279 and effective_end_date ;
3280 --END TEMPIK
3281 /*TEMPIK
3282 and exists ( select null
3283 from BEN_ELIG_CMBN_AGE_LOS_PRTE_F ECP1
3284 where
3285 ECP1.CMBN_AGE_LOS_FCTR_ID = l_CMBN_AGE_LOS_FCTR_ID and
3286 ECP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
3287 ECP1.business_group_id = c_business_group_id
3288 and ECP1.effective_start_date <= c_effective_start_date )
3289 and exists ( select null
3290 from BEN_ELIG_CMBN_AGE_LOS_PRTE_F ECP2
3291 where
3292 ECP2.CMBN_AGE_LOS_FCTR_ID = l_CMBN_AGE_LOS_FCTR_ID and
3293 ECP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
3294 ECP2.business_group_id = c_business_group_id
3295 and ECP2.effective_end_date >= c_effective_end_date )
3296 ;
3297 TEMPIK */
3298 --TEMPIK
3299 l_dt_rec_found boolean ;
3300 --END TEMPIK
3301 --
3302
3303 --UPD START
3304 --
3305 l_update boolean := false ;
3306 l_datetrack_mode varchar2(80) := hr_api.g_update;
3307 l_process_date date;
3308 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
3309 --
3310 --UPD END
3311 l_current_pk_id number := null ;
3312
3313 l_prev_pk_id number := null ;
3314 l_first_rec boolean := true ;
3315 r_ECP c_ECP%rowtype;
3316 l_elig_cmbn_age_los_prte_id number ;
3317 l_object_version_number number ;
3318 l_effective_start_date date ;
3319 l_effective_end_date date ;
3320 l_prefix pqh_copy_entity_attribs.information1%type := null;
3321 l_suffix pqh_copy_entity_attribs.information1%type := null;
3322 l_new_value number(15);
3323 l_object_found_in_target boolean := false ;
3324 l_min_esd date;
3325 l_max_eed date;
3326 l_effective_date date;
3327 --
3328 begin
3329 -- Initialization
3330 l_object_found_in_target := false ;
3331 -- End Initialization
3332 -- Derive the prefix - sufix
3333 if p_prefix_suffix_cd = 'PREFIX' then
3334 l_prefix := p_prefix_suffix_text ;
3335 elsif p_prefix_suffix_cd = 'SUFFIX' then
3336 l_suffix := p_prefix_suffix_text ;
3337 else
3338 l_prefix := null ;
3339 l_suffix := null ;
3340 end if ;
3341 -- End Prefix Sufix derivation
3342 for r_ECP_unique in c_unique_ECP('ECP') loop
3343
3344 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
3345 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3346 r_ECP_unique.information3 >=
3347 ben_pd_copy_to_ben_one.g_copy_effective_date)
3348 ) then
3349 --
3350 hr_utility.set_location(' r_ECP_unique.table_route_id '||r_ECP_unique.table_route_id,10);
3351 hr_utility.set_location(' r_ECP_unique.information1 '||r_ECP_unique.information1,10);
3352 hr_utility.set_location( 'r_ECP_unique.information2 '||r_ECP_unique.information2,10);
3353 hr_utility.set_location( 'r_ECP_unique.information3 '||r_ECP_unique.information3,10);
3354 -- If reuse objects flag is 'Y' then check for the object in the target business group
3355 -- if found insert the record into PLSql table and exit the loop else try create the
3356 -- object in the target business group
3357 --
3358 l_object_found_in_target := false ;
3359 --UPD START
3360 l_update := false;
3361 l_process_date := p_effective_date;
3362 l_dml_operation:= r_ECP_unique.dml_operation ;
3363 --
3364
3365 /**********************moved from below ***************************/
3366 open c_ECP(r_ECP_unique.table_route_id,
3367 r_ECP_unique.information1,
3368 r_ECP_unique.information2,
3369 r_ECP_unique.information3 ) ;
3370 --
3371 fetch c_ECP into r_ECP ;
3372 --
3373 close c_ECP ;
3374 --
3375 l_CMBN_AGE_LOS_FCTR_ID := get_fk('CMBN_AGE_LOS_FCTR_ID', r_ECP.INFORMATION223,l_dml_operation);
3376 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ECP.INFORMATION263,l_dml_operation);
3377
3378 /*****************************************************************/
3379
3380 if l_dml_operation = 'UPDATE' then
3381 --
3382 l_object_found_in_target := TRUE;
3383 --
3384 if l_process_date between r_ECP_unique.information2 and r_ECP_unique.information3 then
3385 l_update := true;
3386 if r_ECP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
3387 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_CMBN_AGE_LOS_PRTE_ID' then
3388 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_CMBN_AGE_LOS_PRTE_ID' ;
3389 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECP_unique.information1 ;
3390 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ECP_unique.information1 ;
3391 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
3392 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECP_unique.table_route_id;
3393 --
3394 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
3395 --
3396 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
3397 --
3398 -- -- log_data('ECP',l_new_value,l_prefix || r_ECP_unique.name|| l_suffix,'REUSED');
3399 --
3400 end if ;
3401 hr_utility.set_location( 'found record for update',10);
3402 --
3403 else
3404 --
3405 l_update := false;
3406 --
3407 end if;
3408 else
3409 --
3410 --UPD END
3411 l_min_esd := null ;
3412 l_max_eed := null ;
3413 open c_ECP_min_max_dates(r_ECP_unique.table_route_id, r_ECP_unique.information1 ) ;
3414 fetch c_ECP_min_max_dates into l_min_esd,l_max_eed ;
3415 --
3416
3417 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3418 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
3419 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
3420 end if;
3421 l_min_esd := greatest(l_min_esd,r_ECP_unique.information2);
3422
3423 /**********************moved above ***************************
3424 open c_ECP(r_ECP_unique.table_route_id,
3425 r_ECP_unique.information1,
3426 r_ECP_unique.information2,
3427 r_ECP_unique.information3 ) ;
3428 --
3429 fetch c_ECP into r_ECP ;
3430 --
3431 close c_ECP ;
3432 --
3433 l_CMBN_AGE_LOS_FCTR_ID := get_fk('CMBN_AGE_LOS_FCTR_ID', r_ECP.INFORMATION223,l_dml_operation);
3434 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ECP.INFORMATION263,l_dml_operation);
3435
3436 *****************************************************************/
3437 if p_reuse_object_flag = 'Y' then
3438 if c_ECP_min_max_dates%found then
3439 -- cursor to find the object
3440 open c_find_ECP_in_target( l_min_esd,l_max_eed,
3441 p_target_business_group_id, nvl(l_elig_cmbn_age_los_prte_id, -999) ) ;
3442 fetch c_find_ECP_in_target into l_new_value ;
3443 if c_find_ECP_in_target%found then
3444 --
3445 --TEMPIK
3446 l_dt_rec_found := dt_api.check_min_max_dates
3447 (p_base_table_name => 'BEN_ELIG_CMBN_AGE_LOS_PRTE_F',
3448 p_base_key_column => 'ELIG_CMBN_AGE_LOS_PRTE_ID',
3449 p_base_key_value => l_new_value,
3450 p_from_date => l_min_esd,
3451 p_to_date => l_max_eed );
3452 if l_dt_rec_found THEN
3453 --END TEMPIK
3454 if r_ECP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
3455 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_CMBN_AGE_LOS_PRTE_ID' then
3456 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_CMBN_AGE_LOS_PRTE_ID' ;
3457 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECP_unique.information1 ;
3458 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
3459 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
3460 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECP_unique.table_route_id;
3461 --
3462 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
3463 --
3464 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
3465 end if ;
3466 --
3467 l_object_found_in_target := true ;
3468 --TEMPIK
3469 end if; -- l_dt_rec_found
3470 --END TEMPIK
3471 end if;
3472 close c_find_ECP_in_target ;
3473 --
3474 end if;
3475 end if ;
3476 --
3477 close c_ECP_min_max_dates ;
3478 end if; --if p_dml_operation
3479 --
3480 if not l_object_found_in_target OR l_update then
3481
3482 --
3483 l_current_pk_id := r_ECP.information1;
3484 --
3485 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
3486 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
3487 --
3488 if l_current_pk_id = l_prev_pk_id then
3489 --
3490 l_first_rec := false ;
3491 --
3492 else
3493 --
3494 l_first_rec := true ;
3495 --
3496 end if ;
3497 --
3498
3499 l_effective_date := r_ECP.information2;
3500 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3501 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
3502 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
3503 end if;
3504
3505 if l_first_rec and not l_update then
3506 -- Call Create routine.
3507 hr_utility.set_location(' BEN_ELIG_CMBN_AGE_LOS_PRTE_F CREATE_ELIG_CMBN_AGE_LOS ',20);
3508 BEN_ELIG_CMBN_AGE_LOS_API.CREATE_ELIG_CMBN_AGE_LOS(
3509 --
3510 P_VALIDATE => false
3511 ,P_EFFECTIVE_DATE => l_effective_date
3512 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
3513 --
3514 ,P_CMBN_AGE_LOS_FCTR_ID => l_CMBN_AGE_LOS_FCTR_ID
3515 ,P_ECP_ATTRIBUTE1 => r_ECP.INFORMATION111
3516 ,P_ECP_ATTRIBUTE10 => r_ECP.INFORMATION120
3517 ,P_ECP_ATTRIBUTE11 => r_ECP.INFORMATION121
3518 ,P_ECP_ATTRIBUTE12 => r_ECP.INFORMATION122
3519 ,P_ECP_ATTRIBUTE13 => r_ECP.INFORMATION123
3520 ,P_ECP_ATTRIBUTE14 => r_ECP.INFORMATION124
3521 ,P_ECP_ATTRIBUTE15 => r_ECP.INFORMATION125
3522 ,P_ECP_ATTRIBUTE16 => r_ECP.INFORMATION126
3523 ,P_ECP_ATTRIBUTE17 => r_ECP.INFORMATION127
3524 ,P_ECP_ATTRIBUTE18 => r_ECP.INFORMATION128
3525 ,P_ECP_ATTRIBUTE19 => r_ECP.INFORMATION129
3526 ,P_ECP_ATTRIBUTE2 => r_ECP.INFORMATION112
3527 ,P_ECP_ATTRIBUTE20 => r_ECP.INFORMATION130
3528 ,P_ECP_ATTRIBUTE21 => r_ECP.INFORMATION131
3529 ,P_ECP_ATTRIBUTE22 => r_ECP.INFORMATION132
3530 ,P_ECP_ATTRIBUTE23 => r_ECP.INFORMATION133
3531 ,P_ECP_ATTRIBUTE24 => r_ECP.INFORMATION134
3532 ,P_ECP_ATTRIBUTE25 => r_ECP.INFORMATION135
3533 ,P_ECP_ATTRIBUTE26 => r_ECP.INFORMATION136
3534 ,P_ECP_ATTRIBUTE27 => r_ECP.INFORMATION137
3535 ,P_ECP_ATTRIBUTE28 => r_ECP.INFORMATION138
3536 ,P_ECP_ATTRIBUTE29 => r_ECP.INFORMATION139
3537 ,P_ECP_ATTRIBUTE3 => r_ECP.INFORMATION113
3538 ,P_ECP_ATTRIBUTE30 => r_ECP.INFORMATION140
3539 ,P_ECP_ATTRIBUTE4 => r_ECP.INFORMATION114
3540 ,P_ECP_ATTRIBUTE5 => r_ECP.INFORMATION115
3541 ,P_ECP_ATTRIBUTE6 => r_ECP.INFORMATION116
3542 ,P_ECP_ATTRIBUTE7 => r_ECP.INFORMATION117
3543 ,P_ECP_ATTRIBUTE8 => r_ECP.INFORMATION118
3544 ,P_ECP_ATTRIBUTE9 => r_ECP.INFORMATION119
3545 ,P_ECP_ATTRIBUTE_CATEGORY => r_ECP.INFORMATION110
3546 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
3547 ,P_ELIG_CMBN_AGE_LOS_PRTE_ID => l_elig_cmbn_age_los_prte_id
3548 ,P_EXCLD_FLAG => r_ECP.INFORMATION11
3549 ,P_MNDTRY_FLAG => r_ECP.INFORMATION12
3550 ,P_ORDR_NUM => r_ECP.INFORMATION260
3551 --
3552 -- ****** END CHANGE LINES
3553
3554 --
3555
3556 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3557 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3558 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3559 ,P_CRITERIA_SCORE => r_ecp.INFORMATION295
3560 ,P_CRITERIA_WEIGHT => r_ecp.INFORMATION296
3561 );
3562 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
3563 -- Update all relevent cer records with new pk_id
3564 hr_utility.set_location('Before plsql table ',222);
3565 hr_utility.set_location('new_value id '||l_elig_cmbn_age_los_prte_id,222);
3566 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_CMBN_AGE_LOS_PRTE_ID' ;
3567 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECP.information1 ;
3568 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_CMBN_AGE_LOS_PRTE_ID ;
3569 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
3570 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECP_unique.table_route_id;
3571 hr_utility.set_location('After plsql table ',222);
3572 --
3573 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
3574 --
3575 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
3576 --
3577 else
3578 --
3579 -- Call Update routine for the pk_id created in prev run .
3580 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
3581 hr_utility.set_location(' BEN_ELIG_CMBN_AGE_LOS_PRTE_F UPDATE_ELIG_CMBN_AGE_LOS ',30);
3582 --UPD START
3583 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
3584 --
3585 if l_update then
3586 --
3587 l_datetrack_mode := r_ECP.datetrack_mode ;
3588 --
3589 get_dt_modes(
3590 p_effective_date => l_process_date,
3591 p_effective_end_date => r_ECP.information3,
3592 p_effective_start_date => r_ECP.information2,
3593 p_dml_operation => r_ECP.dml_operation,
3594 p_datetrack_mode => l_datetrack_mode );
3595 -- p_update => l_update
3596 --
3597 l_effective_date := l_process_date;
3598 l_ELIG_CMBN_AGE_LOS_PRTE_ID := r_ECP.information1;
3599 l_object_version_number := r_ECP.information265;
3600 --
3601 end if;
3602 --
3603 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
3604 --
3605 IF l_update OR l_dml_operation <> 'UPDATE' THEN
3606 --UPD END
3607
3608
3609 BEN_ELIG_CMBN_AGE_LOS_API.UPDATE_ELIG_CMBN_AGE_LOS(
3610 --
3611 P_VALIDATE => false
3612 ,P_EFFECTIVE_DATE => l_effective_date
3613 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
3614 --
3615 ,P_CMBN_AGE_LOS_FCTR_ID => l_CMBN_AGE_LOS_FCTR_ID
3616 ,P_ECP_ATTRIBUTE1 => r_ECP.INFORMATION111
3617 ,P_ECP_ATTRIBUTE10 => r_ECP.INFORMATION120
3618 ,P_ECP_ATTRIBUTE11 => r_ECP.INFORMATION121
3619 ,P_ECP_ATTRIBUTE12 => r_ECP.INFORMATION122
3620 ,P_ECP_ATTRIBUTE13 => r_ECP.INFORMATION123
3621 ,P_ECP_ATTRIBUTE14 => r_ECP.INFORMATION124
3622 ,P_ECP_ATTRIBUTE15 => r_ECP.INFORMATION125
3623 ,P_ECP_ATTRIBUTE16 => r_ECP.INFORMATION126
3624 ,P_ECP_ATTRIBUTE17 => r_ECP.INFORMATION127
3625 ,P_ECP_ATTRIBUTE18 => r_ECP.INFORMATION128
3626 ,P_ECP_ATTRIBUTE19 => r_ECP.INFORMATION129
3627 ,P_ECP_ATTRIBUTE2 => r_ECP.INFORMATION112
3628 ,P_ECP_ATTRIBUTE20 => r_ECP.INFORMATION130
3629 ,P_ECP_ATTRIBUTE21 => r_ECP.INFORMATION131
3630 ,P_ECP_ATTRIBUTE22 => r_ECP.INFORMATION132
3631 ,P_ECP_ATTRIBUTE23 => r_ECP.INFORMATION133
3632 ,P_ECP_ATTRIBUTE24 => r_ECP.INFORMATION134
3633 ,P_ECP_ATTRIBUTE25 => r_ECP.INFORMATION135
3634 ,P_ECP_ATTRIBUTE26 => r_ECP.INFORMATION136
3635 ,P_ECP_ATTRIBUTE27 => r_ECP.INFORMATION137
3636 ,P_ECP_ATTRIBUTE28 => r_ECP.INFORMATION138
3637 ,P_ECP_ATTRIBUTE29 => r_ECP.INFORMATION139
3638 ,P_ECP_ATTRIBUTE3 => r_ECP.INFORMATION113
3639 ,P_ECP_ATTRIBUTE30 => r_ECP.INFORMATION140
3640 ,P_ECP_ATTRIBUTE4 => r_ECP.INFORMATION114
3641 ,P_ECP_ATTRIBUTE5 => r_ECP.INFORMATION115
3642 ,P_ECP_ATTRIBUTE6 => r_ECP.INFORMATION116
3643 ,P_ECP_ATTRIBUTE7 => r_ECP.INFORMATION117
3644 ,P_ECP_ATTRIBUTE8 => r_ECP.INFORMATION118
3645 ,P_ECP_ATTRIBUTE9 => r_ECP.INFORMATION119
3646 ,P_ECP_ATTRIBUTE_CATEGORY => r_ECP.INFORMATION110
3647 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
3648 ,P_ELIG_CMBN_AGE_LOS_PRTE_ID => l_elig_cmbn_age_los_prte_id
3649 ,P_EXCLD_FLAG => r_ECP.INFORMATION11
3650 ,P_MNDTRY_FLAG => r_ECP.INFORMATION12
3651 ,P_ORDR_NUM => r_ECP.INFORMATION260
3652 --
3653 -- ****** END CHANGE LINES
3654
3655 --
3656 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3657 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3658 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3659 ,P_DATETRACK_MODE => l_datetrack_mode
3660 ,P_CRITERIA_SCORE => r_ecp.INFORMATION295
3661 ,P_CRITERIA_WEIGHT => r_ecp.INFORMATION296
3662 );
3663 end if; -- l_update
3664 --
3665 end if;
3666 --
3667 -- Delete the row if it is end dated.
3668 --
3669 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
3670 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
3671 trunc(l_max_eed) = trunc(r_ECP.information3)) then
3672 --
3673 BEN_ELIG_CMBN_AGE_LOS_API.delete_ELIG_CMBN_AGE_LOS(
3674 --
3675 p_validate => false
3676 ,p_elig_cmbn_age_los_prte_id => l_elig_cmbn_age_los_prte_id
3677 ,p_effective_start_date => l_effective_start_date
3678 ,p_effective_end_date => l_effective_end_date
3679 ,p_object_version_number => l_object_version_number
3680 ,p_effective_date => l_max_eed
3681 ,p_datetrack_mode => hr_api.g_delete
3682 --
3683 );
3684 --
3685 end if;
3686 --
3687 l_prev_pk_id := l_current_pk_id ;
3688 --
3689 end if;
3690 --
3691 end if;
3692 --
3693 end loop;
3694 --
3695 exception when others then
3696 --
3697 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ECP',r_ECP.information5 ) ;
3698 --
3699 end create_ECP_rows;
3700
3701 --
3702 ---------------------------------------------------------------
3703 ----------------------< create_ECQ_rows >-----------------------
3704 ---------------------------------------------------------------
3705 --
3706 procedure create_ECQ_rows
3707 (
3708 p_validate in number default 0
3709 ,p_copy_entity_txn_id in number
3710 ,p_effective_date in date
3711 ,p_prefix_suffix_text in varchar2 default null
3712 ,p_reuse_object_flag in varchar2 default null
3713 ,p_target_business_group_id in varchar2 default null
3714 ,p_prefix_suffix_cd in varchar2 default null
3715 ) is
3716 --
3717 l_ELIGY_PRFL_ID number;
3718 l_PGM_ID number;
3719 l_PTIP_ID number;
3720 cursor c_unique_ECQ(l_table_alias varchar2) is
3721 select distinct cpe.information1,
3722 cpe.information2,
3723 cpe.information3,
3724 cpe.table_route_id
3725 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
3726 pqh_table_route tr
3727 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3728 and cpe.table_route_id = tr.table_route_id
3729 -- and tr.where_clause = l_BEN_ELIG_CBR_QUALD_BNF_F
3730 and tr.table_alias = l_table_alias
3731 and cpe.number_of_copies = 1 -- ADDITION
3732 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
3733 order by information1, information2; --added for bug: 5151945
3734 --
3735 --
3736 cursor c_ECQ_min_max_dates(c_table_route_id number,
3737 c_information1 number) is
3738 select
3739 min(cpe.information2) min_esd,
3740 max(cpe.information3) min_eed
3741 from ben_copy_entity_results cpe
3742 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3743 and cpe.table_route_id = c_table_route_id
3744 and cpe.information1 = c_information1 ;
3745 --
3746 cursor c_ECQ(c_table_route_id number,
3747 c_information1 number,
3748 c_information2 date,
3749 c_information3 date) is
3750 select
3751 cpe.*
3752 from ben_copy_entity_results cpe
3753 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3754 and cpe.table_route_id = c_table_route_id
3755 and cpe.information1 = c_information1
3756 and cpe.information2 = c_information2
3757 and cpe.information3 = c_information3
3758 and rownum = 1 ;
3759 -- Date Track target record
3760 cursor c_find_ECQ_in_target(
3761 c_effective_start_date date,
3762 c_effective_end_date date,
3763 c_business_group_id number,
3764 c_new_pk_id number) is
3765 select
3766 ECQ.elig_cbr_quald_bnf_id new_value
3767 from BEN_ELIG_CBR_QUALD_BNF_F ECQ
3768 where
3769 ECQ.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
3770 nvl(ECQ.PGM_ID,-999) = nvl(l_PGM_ID,-999) and -- IK Added nvl conditions
3771 nvl(ECQ.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
3772 ECQ.business_group_id = c_business_group_id
3773 and ECQ.elig_cbr_quald_bnf_id <> c_new_pk_id
3774 --TEMPIK
3775 and c_effective_start_date between effective_start_date
3776 and effective_end_date ;
3777 --END TEMPIK
3778 /*TEMPIK
3779 and exists ( select null
3780 from BEN_ELIG_CBR_QUALD_BNF_F ECQ1
3781 where
3782 ECQ1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
3783 nvl(ECQ1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
3784 nvl(ECQ1.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
3785 ECQ1.business_group_id = c_business_group_id
3786 and ECQ1.effective_start_date <= c_effective_start_date )
3787 and exists ( select null
3788 from BEN_ELIG_CBR_QUALD_BNF_F ECQ2
3789 where
3790 ECQ2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
3791 nvl(ECQ2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
3792 nvl(ECQ2.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
3793 ECQ2.business_group_id = c_business_group_id
3794 and ECQ2.effective_end_date >= c_effective_end_date )
3795 ;
3796 TEMPIK */
3797 --TEMPIK
3798 l_dt_rec_found boolean ;
3799 --END TEMPIK
3800 --
3801
3802 --UPD START
3803 --
3804 l_update boolean := false ;
3805 l_datetrack_mode varchar2(80) := hr_api.g_update;
3806 l_process_date date;
3807 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
3808 --
3809 --UPD END
3810 l_current_pk_id number := null ;
3811
3812 l_prev_pk_id number := null ;
3813 l_first_rec boolean := true ;
3814 r_ECQ c_ECQ%rowtype;
3815 l_elig_cbr_quald_bnf_id number ;
3816 l_object_version_number number ;
3817 l_effective_start_date date ;
3818 l_effective_end_date date ;
3819 l_prefix pqh_copy_entity_attribs.information1%type := null;
3820 l_suffix pqh_copy_entity_attribs.information1%type := null;
3821 l_new_value number(15);
3822 l_object_found_in_target boolean := false ;
3823 l_min_esd date;
3824 l_max_eed date;
3825 l_effective_date date;
3826 --
3827 begin
3828 -- Initialization
3829 l_object_found_in_target := false ;
3830 -- End Initialization
3831 -- Derive the prefix - sufix
3832 if p_prefix_suffix_cd = 'PREFIX' then
3833 l_prefix := p_prefix_suffix_text ;
3834 elsif p_prefix_suffix_cd = 'SUFFIX' then
3835 l_suffix := p_prefix_suffix_text ;
3836 else
3837 l_prefix := null ;
3838 l_suffix := null ;
3839 end if ;
3840 -- End Prefix Sufix derivation
3841 for r_ECQ_unique in c_unique_ECQ('ECQ') loop
3842
3843 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
3844 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3845 r_ECQ_unique.information3 >=
3846 ben_pd_copy_to_ben_one.g_copy_effective_date)
3847 ) then
3848 --
3849 hr_utility.set_location(' r_ECQ_unique.table_route_id '||r_ECQ_unique.table_route_id,10);
3850 hr_utility.set_location(' r_ECQ_unique.information1 '||r_ECQ_unique.information1,10);
3851 hr_utility.set_location( 'r_ECQ_unique.information2 '||r_ECQ_unique.information2,10);
3852 hr_utility.set_location( 'r_ECQ_unique.information3 '||r_ECQ_unique.information3,10);
3853 -- If reuse objects flag is 'Y' then check for the object in the target business group
3854 -- if found insert the record into PLSql table and exit the loop else try create the
3855 -- object in the target business group
3856 --
3857 l_object_found_in_target := false ;
3858 --UPD START
3859 l_update := false;
3860 l_process_date := p_effective_date;
3861 l_dml_operation:= r_ECQ_unique.dml_operation ;
3862
3863 /**********************moved from below ***************************/
3864 open c_ECQ(r_ECQ_unique.table_route_id,
3865 r_ECQ_unique.information1,
3866 r_ECQ_unique.information2,
3867 r_ECQ_unique.information3 ) ;
3868 --
3869 fetch c_ECQ into r_ECQ ;
3870 --
3871 close c_ECQ ;
3872 --
3873 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ECQ.INFORMATION263,l_dml_operation);
3874
3875 -- Only For Use by Create Wizard - Same Business Group
3876 l_PGM_ID := NVL(get_fk('PGM_ID', r_ECQ.INFORMATION260,l_dml_operation),
3877 r_ECQ.INFORMATION260);
3878 l_PTIP_ID := NVL(get_fk('PTIP_ID', r_ECQ.INFORMATION259,l_dml_operation),
3879 r_ECQ.INFORMATION259);
3880
3881
3882 /*****************************************************************/
3883
3884 --
3885 if l_dml_operation = 'UPDATE' then
3886 --
3887 l_object_found_in_target := TRUE;
3888 --
3889 if l_process_date between r_ECQ_unique.information2 and r_ECQ_unique.information3 then
3890 l_update := true;
3891 if r_ECQ_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
3892 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_CBR_QUALD_BNF_ID' then
3893 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_CBR_QUALD_BNF_ID' ;
3894 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECQ_unique.information1 ;
3895 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ECQ_unique.information1 ;
3896 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
3897 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECQ_unique.table_route_id;
3898 --
3899 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
3900 --
3901 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
3902 --
3903 -- -- log_data('ECQ',l_new_value,l_prefix || r_ECQ_unique.name|| l_suffix,'REUSED');
3904 --
3905 end if ;
3906 hr_utility.set_location( 'found record for update',10);
3907 --
3908 else
3909 --
3910 l_update := false;
3911 --
3912 end if;
3913 else
3914 --
3915 --UPD END
3916 l_min_esd := null ;
3917 l_max_eed := null ;
3918 open c_ECQ_min_max_dates(r_ECQ_unique.table_route_id, r_ECQ_unique.information1 ) ;
3919 fetch c_ECQ_min_max_dates into l_min_esd,l_max_eed ;
3920 --
3921
3922 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3923 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
3924 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
3925 end if;
3926 l_min_esd := greatest(l_min_esd,r_ECQ_unique.information2);
3927
3928 /**********************moved above ***************************
3929 open c_ECQ(r_ECQ_unique.table_route_id,
3930 r_ECQ_unique.information1,
3931 r_ECQ_unique.information2,
3932 r_ECQ_unique.information3 ) ;
3933 --
3934 fetch c_ECQ into r_ECQ ;
3935 --
3936 close c_ECQ ;
3937 --
3938 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ECQ.INFORMATION263,l_dml_operation);
3939
3940 -- Only For Use by Create Wizard - Same Business Group
3941 l_PGM_ID := NVL(get_fk('PGM_ID', r_ECQ.INFORMATION260,l_dml_operation),
3942 r_ECQ.INFORMATION260);
3943 l_PTIP_ID := NVL(get_fk('PTIP_ID', r_ECQ.INFORMATION259,l_dml_operation),
3944 r_ECQ.INFORMATION259);
3945
3946
3947 *****************************************************************/
3948 if p_reuse_object_flag = 'Y' then
3949 if c_ECQ_min_max_dates%found then
3950 -- cursor to find the object
3951 open c_find_ECQ_in_target( l_min_esd,l_max_eed,
3952 p_target_business_group_id, nvl(l_elig_cbr_quald_bnf_id, -999) ) ;
3953 fetch c_find_ECQ_in_target into l_new_value ;
3954 if c_find_ECQ_in_target%found then
3955 --
3956 --TEMPIK
3957 l_dt_rec_found := dt_api.check_min_max_dates
3958 (p_base_table_name => 'BEN_ELIG_CBR_QUALD_BNF_F',
3959 p_base_key_column => 'ELIG_CBR_QUALD_BNF_ID',
3960 p_base_key_value => l_new_value,
3961 p_from_date => l_min_esd,
3962 p_to_date => l_max_eed );
3963 if l_dt_rec_found THEN
3964 --END TEMPIK
3965 if r_ECQ_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
3966 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_CBR_QUALD_BNF_ID' then
3967 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_CBR_QUALD_BNF_ID' ;
3968 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECQ_unique.information1 ;
3969 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
3970 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
3971 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECQ_unique.table_route_id;
3972 --
3973 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
3974 --
3975 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
3976 end if ;
3977 --
3978 l_object_found_in_target := true ;
3979 --TEMPIK
3980 end if; -- l_dt_rec_found
3981 --END TEMPIK
3982 end if;
3983 close c_find_ECQ_in_target ;
3984 --
3985 end if;
3986 end if ;
3987 --
3988 close c_ECQ_min_max_dates ;
3989 end if; --if p_dml_operation
3990 --
3991 if not l_object_found_in_target OR l_update then
3992
3993 --
3994 l_current_pk_id := r_ECQ.information1;
3995 --
3996 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
3997 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
3998 --
3999 if l_current_pk_id = l_prev_pk_id then
4000 --
4001 l_first_rec := false ;
4002 --
4003 else
4004 --
4005 l_first_rec := true ;
4006 --
4007 end if ;
4008 --
4009
4010 l_effective_date := r_ECQ.information2;
4011 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
4012 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
4013 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
4014 end if;
4015
4016 if l_first_rec and not l_update then
4017 -- Call Create routine.
4018 hr_utility.set_location(' BEN_ELIG_CBR_QUALD_BNF_F CREATE_ELIG_CBR_QUALD_BNF ',20);
4019 BEN_ELIG_CBR_QUALD_BNF_API.CREATE_ELIG_CBR_QUALD_BNF(
4020 --
4021 P_VALIDATE => false
4022 ,P_EFFECTIVE_DATE => l_effective_date
4023 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
4024 --
4025 ,P_ECQ_ATTRIBUTE1 => r_ECQ.INFORMATION111
4026 ,P_ECQ_ATTRIBUTE10 => r_ECQ.INFORMATION120
4027 ,P_ECQ_ATTRIBUTE11 => r_ECQ.INFORMATION121
4028 ,P_ECQ_ATTRIBUTE12 => r_ECQ.INFORMATION122
4029 ,P_ECQ_ATTRIBUTE13 => r_ECQ.INFORMATION123
4030 ,P_ECQ_ATTRIBUTE14 => r_ECQ.INFORMATION124
4031 ,P_ECQ_ATTRIBUTE15 => r_ECQ.INFORMATION125
4032 ,P_ECQ_ATTRIBUTE16 => r_ECQ.INFORMATION126
4033 ,P_ECQ_ATTRIBUTE17 => r_ECQ.INFORMATION127
4034 ,P_ECQ_ATTRIBUTE18 => r_ECQ.INFORMATION128
4035 ,P_ECQ_ATTRIBUTE19 => r_ECQ.INFORMATION129
4036 ,P_ECQ_ATTRIBUTE2 => r_ECQ.INFORMATION112
4037 ,P_ECQ_ATTRIBUTE20 => r_ECQ.INFORMATION130
4038 ,P_ECQ_ATTRIBUTE21 => r_ECQ.INFORMATION131
4039 ,P_ECQ_ATTRIBUTE22 => r_ECQ.INFORMATION132
4040 ,P_ECQ_ATTRIBUTE23 => r_ECQ.INFORMATION133
4041 ,P_ECQ_ATTRIBUTE24 => r_ECQ.INFORMATION134
4042 ,P_ECQ_ATTRIBUTE25 => r_ECQ.INFORMATION135
4043 ,P_ECQ_ATTRIBUTE26 => r_ECQ.INFORMATION136
4044 ,P_ECQ_ATTRIBUTE27 => r_ECQ.INFORMATION137
4045 ,P_ECQ_ATTRIBUTE28 => r_ECQ.INFORMATION138
4046 ,P_ECQ_ATTRIBUTE29 => r_ECQ.INFORMATION139
4047 ,P_ECQ_ATTRIBUTE3 => r_ECQ.INFORMATION113
4048 ,P_ECQ_ATTRIBUTE30 => r_ECQ.INFORMATION140
4049 ,P_ECQ_ATTRIBUTE4 => r_ECQ.INFORMATION114
4050 ,P_ECQ_ATTRIBUTE5 => r_ECQ.INFORMATION115
4051 ,P_ECQ_ATTRIBUTE6 => r_ECQ.INFORMATION116
4052 ,P_ECQ_ATTRIBUTE7 => r_ECQ.INFORMATION117
4053 ,P_ECQ_ATTRIBUTE8 => r_ECQ.INFORMATION118
4054 ,P_ECQ_ATTRIBUTE9 => r_ECQ.INFORMATION119
4055 ,P_ECQ_ATTRIBUTE_CATEGORY => r_ECQ.INFORMATION110
4056 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
4057 ,P_ELIG_CBR_QUALD_BNF_ID => l_elig_cbr_quald_bnf_id
4058 ,P_ORDR_NUM => r_ECQ.INFORMATION262
4059 ,P_PGM_ID => l_PGM_ID
4060 ,P_PTIP_ID => l_PTIP_ID
4061 ,P_QUALD_BNF_FLAG => r_ECQ.INFORMATION11
4062 --
4063 -- ****** END CHANGE LINES
4064
4065 --
4066
4067 ,P_EFFECTIVE_START_DATE => l_effective_start_date
4068 ,P_EFFECTIVE_END_DATE => l_effective_end_date
4069 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
4070 ,P_CRITERIA_SCORE => r_ecq.INFORMATION295
4071 ,P_CRITERIA_WEIGHT => r_ecq.INFORMATION296
4072 );
4073 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
4074 -- Update all relevent cer records with new pk_id
4075 hr_utility.set_location('Before plsql table ',222);
4076 hr_utility.set_location('new_value id '||l_elig_cbr_quald_bnf_id,222);
4077 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_CBR_QUALD_BNF_ID' ;
4078 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECQ.information1 ;
4079 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_CBR_QUALD_BNF_ID ;
4080 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
4081 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECQ_unique.table_route_id;
4082 hr_utility.set_location('After plsql table ',222);
4083 --
4084 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
4085 --
4086 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
4087 --
4088 else
4089 --
4090 -- Call Update routine for the pk_id created in prev run .
4091 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
4092 hr_utility.set_location(' BEN_ELIG_CBR_QUALD_BNF_F UPDATE_ELIG_CBR_QUALD_BNF ',30);
4093 --UPD START
4094 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
4095 --
4096 if l_update then
4097 --
4098 l_datetrack_mode := r_ECQ.datetrack_mode ;
4099 --
4100 get_dt_modes(
4101 p_effective_date => l_process_date,
4102 p_effective_end_date => r_ECQ.information3,
4103 p_effective_start_date => r_ECQ.information2,
4104 p_dml_operation => r_ECQ.dml_operation,
4105 p_datetrack_mode => l_datetrack_mode );
4106 -- p_update => l_update
4107 --
4108 l_effective_date := l_process_date;
4109 l_ELIG_CBR_QUALD_BNF_ID := r_ECQ.information1;
4110 l_object_version_number := r_ECQ.information265;
4111 --
4112 end if;
4113 --
4114 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
4115 --
4116 IF l_update OR l_dml_operation <> 'UPDATE' THEN
4117 --UPD END
4118
4119
4120 BEN_ELIG_CBR_QUALD_BNF_API.UPDATE_ELIG_CBR_QUALD_BNF(
4121 --
4122 P_VALIDATE => false
4123 ,P_EFFECTIVE_DATE => l_effective_date
4124 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
4125 --
4126 ,P_ECQ_ATTRIBUTE1 => r_ECQ.INFORMATION111
4127 ,P_ECQ_ATTRIBUTE10 => r_ECQ.INFORMATION120
4128 ,P_ECQ_ATTRIBUTE11 => r_ECQ.INFORMATION121
4129 ,P_ECQ_ATTRIBUTE12 => r_ECQ.INFORMATION122
4130 ,P_ECQ_ATTRIBUTE13 => r_ECQ.INFORMATION123
4131 ,P_ECQ_ATTRIBUTE14 => r_ECQ.INFORMATION124
4132 ,P_ECQ_ATTRIBUTE15 => r_ECQ.INFORMATION125
4133 ,P_ECQ_ATTRIBUTE16 => r_ECQ.INFORMATION126
4134 ,P_ECQ_ATTRIBUTE17 => r_ECQ.INFORMATION127
4135 ,P_ECQ_ATTRIBUTE18 => r_ECQ.INFORMATION128
4136 ,P_ECQ_ATTRIBUTE19 => r_ECQ.INFORMATION129
4137 ,P_ECQ_ATTRIBUTE2 => r_ECQ.INFORMATION112
4138 ,P_ECQ_ATTRIBUTE20 => r_ECQ.INFORMATION130
4139 ,P_ECQ_ATTRIBUTE21 => r_ECQ.INFORMATION131
4140 ,P_ECQ_ATTRIBUTE22 => r_ECQ.INFORMATION132
4141 ,P_ECQ_ATTRIBUTE23 => r_ECQ.INFORMATION133
4142 ,P_ECQ_ATTRIBUTE24 => r_ECQ.INFORMATION134
4143 ,P_ECQ_ATTRIBUTE25 => r_ECQ.INFORMATION135
4144 ,P_ECQ_ATTRIBUTE26 => r_ECQ.INFORMATION136
4145 ,P_ECQ_ATTRIBUTE27 => r_ECQ.INFORMATION137
4146 ,P_ECQ_ATTRIBUTE28 => r_ECQ.INFORMATION138
4147 ,P_ECQ_ATTRIBUTE29 => r_ECQ.INFORMATION139
4148 ,P_ECQ_ATTRIBUTE3 => r_ECQ.INFORMATION113
4149 ,P_ECQ_ATTRIBUTE30 => r_ECQ.INFORMATION140
4150 ,P_ECQ_ATTRIBUTE4 => r_ECQ.INFORMATION114
4151 ,P_ECQ_ATTRIBUTE5 => r_ECQ.INFORMATION115
4152 ,P_ECQ_ATTRIBUTE6 => r_ECQ.INFORMATION116
4153 ,P_ECQ_ATTRIBUTE7 => r_ECQ.INFORMATION117
4154 ,P_ECQ_ATTRIBUTE8 => r_ECQ.INFORMATION118
4155 ,P_ECQ_ATTRIBUTE9 => r_ECQ.INFORMATION119
4156 ,P_ECQ_ATTRIBUTE_CATEGORY => r_ECQ.INFORMATION110
4157 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
4158 ,P_ELIG_CBR_QUALD_BNF_ID => l_elig_cbr_quald_bnf_id
4159 ,P_ORDR_NUM => r_ECQ.INFORMATION262
4160 ,P_PGM_ID => l_PGM_ID
4161 ,P_PTIP_ID => l_PTIP_ID
4162 ,P_QUALD_BNF_FLAG => r_ECQ.INFORMATION11
4163 --
4164 --****** END CHANGE LINES
4165
4166 --
4167 ,P_EFFECTIVE_START_DATE => l_effective_start_date
4168 ,P_EFFECTIVE_END_DATE => l_effective_end_date
4169 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
4170 ,P_DATETRACK_MODE => l_datetrack_mode
4171 ,P_CRITERIA_SCORE => r_ecq.INFORMATION295
4172 ,P_CRITERIA_WEIGHT => r_ecq.INFORMATION296
4173 );
4174 end if; -- l_update
4175 --
4176 end if;
4177 --
4178 -- Delete the row if it is end dated.
4179 --
4180 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
4181 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
4182 trunc(l_max_eed) = trunc(r_ECQ.information3)) then
4183 --
4184 BEN_ELIG_CBR_QUALD_BNF_API.delete_ELIG_CBR_QUALD_BNF(
4185 --
4186 p_validate => false
4187 ,p_elig_cbr_quald_bnf_id => l_elig_cbr_quald_bnf_id
4188 ,p_effective_start_date => l_effective_start_date
4189 ,p_effective_end_date => l_effective_end_date
4190 ,p_object_version_number => l_object_version_number
4191 ,p_effective_date => l_max_eed
4192 ,p_datetrack_mode => hr_api.g_delete
4193 --
4194 );
4195 --
4196 end if;
4197 --
4198 l_prev_pk_id := l_current_pk_id ;
4199 --
4200 end if;
4201 --
4202 end if;
4203 --
4204 end loop;
4205 --
4206 exception when others then
4207 --
4208 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ECQ',r_ECQ.information5 ) ;
4209 --
4210 end create_ECQ_rows;
4211
4212 --
4213 ---------------------------------------------------------------
4214 ----------------------< create_ECY_rows >-----------------------
4215 ---------------------------------------------------------------
4216 --
4217 procedure create_ECY_rows
4218 (
4219 p_validate in number default 0
4220 ,p_copy_entity_txn_id in number
4221 ,p_effective_date in date
4222 ,p_prefix_suffix_text in varchar2 default null
4223 ,p_reuse_object_flag in varchar2 default null
4224 ,p_target_business_group_id in varchar2 default null
4225 ,p_prefix_suffix_cd in varchar2 default null
4226 ) is
4227 --
4228 l_COMPETENCE_ID number;
4229 l_ELIGY_PRFL_ID number;
4230 l_RATING_LEVEL_ID number;
4231 cursor c_unique_ECY(l_table_alias varchar2) is
4232 select distinct cpe.information1,
4233 cpe.information2,
4234 cpe.information3,
4235 cpe.table_route_id
4236 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
4237 pqh_table_route tr
4238 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4239 and cpe.table_route_id = tr.table_route_id
4240 -- and tr.where_clause = l_BEN_ELIG_COMPTNCY_PRTE_F
4241 and tr.table_alias = l_table_alias
4242 and cpe.number_of_copies = 1 -- ADDITION
4243 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
4244 order by information1, information2; --added for bug: 5151945
4245 --
4246 --
4247 cursor c_ECY_min_max_dates(c_table_route_id number,
4248 c_information1 number) is
4249 select
4250 min(cpe.information2) min_esd,
4251 max(cpe.information3) min_eed
4252 from ben_copy_entity_results cpe
4253 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4254 and cpe.table_route_id = c_table_route_id
4255 and cpe.information1 = c_information1 ;
4256 --
4257 cursor c_ECY(c_table_route_id number,
4258 c_information1 number,
4259 c_information2 date,
4260 c_information3 date) is
4261 select
4262 cpe.*
4263 from ben_copy_entity_results cpe
4264 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4265 and cpe.table_route_id = c_table_route_id
4266 and cpe.information1 = c_information1
4267 and cpe.information2 = c_information2
4268 and cpe.information3 = c_information3
4269 and rownum = 1 ;
4270 -- Date Track target record
4271 -- IK 9999 Get Competency and rating from mapped columns Needs to Look at Padma Code in bepdcprf.
4272 cursor c_find_ECY_in_target(
4273 c_effective_start_date date,
4274 c_effective_end_date date,
4275 c_business_group_id number,
4276 c_new_pk_id number) is
4277 select
4278 ECY.elig_comptncy_prte_id new_value
4279 from BEN_ELIG_COMPTNCY_PRTE_F ECY
4280 where
4281 ECY.COMPETENCE_ID = l_COMPETENCE_ID and
4282 ECY.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
4283 ECY.RATING_LEVEL_ID = l_RATING_LEVEL_ID and
4284 ECY.business_group_id = c_business_group_id
4285 and ECY.elig_comptncy_prte_id <> c_new_pk_id
4286 and c_effective_start_date between effective_start_date
4287 and effective_end_date ;
4288 --END TEMPIK
4289 /*TEMPIK
4290 and exists ( select null
4291 from BEN_ELIG_COMPTNCY_PRTE_F ECY1
4292 where
4293 ECY1.COMPETENCE_ID = l_COMPETENCE_ID and
4294 ECY1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
4295 ECY1.RATING_LEVEL_ID = l_RATING_LEVEL_ID and
4296 ECY1.business_group_id = c_business_group_id
4297 and ECY1.effective_start_date <= c_effective_start_date )
4298 and exists ( select null
4299 from BEN_ELIG_COMPTNCY_PRTE_F ECY2
4300 where
4301 ECY2.COMPETENCE_ID = l_COMPETENCE_ID and
4302 ECY2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
4303 ECY2.RATING_LEVEL_ID = l_RATING_LEVEL_ID and
4304 ECY2.business_group_id = c_business_group_id
4305 and ECY2.effective_end_date >= c_effective_end_date )
4306 ;
4307 TEMPIK */
4308 --TEMPIK
4309 l_dt_rec_found boolean ;
4310 --END TEMPIK
4311 --
4312
4313 --UPD START
4314 --
4315 l_update boolean := false ;
4316 l_datetrack_mode varchar2(80) := hr_api.g_update;
4317 l_process_date date;
4318 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
4319 --
4320 --UPD END
4321 l_current_pk_id number := null ;
4322
4323 l_prev_pk_id number := null ;
4324 l_first_rec boolean := true ;
4325 r_ECY c_ECY%rowtype;
4326 l_elig_comptncy_prte_id number ;
4327 l_object_version_number number ;
4328 l_effective_start_date date ;
4329 l_effective_end_date date ;
4330 l_prefix pqh_copy_entity_attribs.information1%type := null;
4331 l_suffix pqh_copy_entity_attribs.information1%type := null;
4332 l_new_value number(15);
4333 l_object_found_in_target boolean := false ;
4334 l_min_esd date;
4335 l_max_eed date;
4336 l_effective_date date;
4337 --
4338
4339 --Bug 5081751
4340 l_mapping_done boolean := true;
4341 --End Bug 5081751
4342
4343
4344 begin
4345
4346 -- Initialization
4347 l_object_found_in_target := false ;
4348 -- End Initialization
4349 -- Derive the prefix - sufix
4350 if p_prefix_suffix_cd = 'PREFIX' then
4351 l_prefix := p_prefix_suffix_text ;
4352 elsif p_prefix_suffix_cd = 'SUFFIX' then
4353 l_suffix := p_prefix_suffix_text ;
4354 else
4355 l_prefix := null ;
4356 l_suffix := null ;
4357 end if ;
4358 -- End Prefix Sufix derivation
4359 for r_ECY_unique in c_unique_ECY('ECY') loop
4360
4361 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
4362 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
4363 r_ECY_unique.information3 >=
4364 ben_pd_copy_to_ben_one.g_copy_effective_date)
4365 ) then
4366 --
4367 hr_utility.set_location(' r_ECY_unique.table_route_id '||r_ECY_unique.table_route_id,10);
4368 hr_utility.set_location(' r_ECY_unique.information1 '||r_ECY_unique.information1,10);
4369 hr_utility.set_location( 'r_ECY_unique.information2 '||r_ECY_unique.information2,10);
4370 hr_utility.set_location( 'r_ECY_unique.information3 '||r_ECY_unique.information3,10);
4371 -- If reuse objects flag is 'Y' then check for the object in the target business group
4372 -- if found insert the record into PLSql table and exit the loop else try create the
4373 -- object in the target business group
4374 --
4375 l_object_found_in_target := false ;
4376 --UPD START
4377 l_update := false;
4378 l_process_date := p_effective_date;
4379 l_dml_operation:= r_ECY_unique.dml_operation ;
4380 --
4381 /**********************moved from below ***************************/
4382 open c_ECY(r_ECY_unique.table_route_id,
4383 r_ECY_unique.information1,
4384 r_ECY_unique.information2,
4385 r_ECY_unique.information3 ) ;
4386 --
4387 fetch c_ECY into r_ECY ;
4388 --
4389 close c_ECY ;
4390 --
4391 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
4392 l_COMPETENCE_ID := r_ECY.INFORMATION176;
4393 l_RATING_LEVEL_ID := r_ECY.INFORMATION180;
4394 else
4395 l_COMPETENCE_ID := r_ECY.INFORMATION174;
4396 l_RATING_LEVEL_ID := r_ECY.information178;
4397 end if;
4398
4399 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ECY.INFORMATION263,l_dml_operation);
4400
4401 /*****************************************************************/
4402
4403
4404 if l_dml_operation = 'UPDATE' then
4405 --
4406 l_object_found_in_target := TRUE;
4407 --
4408 if l_process_date between r_ECY_unique.information2 and r_ECY_unique.information3 then
4409 l_update := true;
4410 if r_ECY_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
4411 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_COMPTNCY_PRTE_ID' then
4412 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_COMPTNCY_PRTE_ID' ;
4413 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECY_unique.information1 ;
4414 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ECY_unique.information1 ;
4415 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
4416 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECY_unique.table_route_id;
4417 --
4418 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
4419 --
4420 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
4421 --
4422 -- -- log_data('ECY',l_new_value,l_prefix || r_ECY_unique.name|| l_suffix,'REUSED');
4423 --
4424 end if ;
4425 hr_utility.set_location( 'found record for update',10);
4426 --
4427 else
4428 --
4429 l_update := false;
4430 --
4431 end if;
4432 else
4433 --
4434 --UPD END
4435 l_min_esd := null ;
4436 l_max_eed := null ;
4437 open c_ECY_min_max_dates(r_ECY_unique.table_route_id, r_ECY_unique.information1 ) ;
4438 fetch c_ECY_min_max_dates into l_min_esd,l_max_eed ;
4439 --
4440
4441 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
4442 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
4443 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
4444 end if;
4445 l_min_esd := greatest(l_min_esd,r_ECY_unique.information2);
4446
4447 /**********************moved above ***************************
4448 open c_ECY(r_ECY_unique.table_route_id,
4449 r_ECY_unique.information1,
4450 r_ECY_unique.information2,
4451 r_ECY_unique.information3 ) ;
4452 --
4453 fetch c_ECY into r_ECY ;
4454 --
4455 close c_ECY ;
4456 --
4457 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
4458 l_COMPETENCE_ID := r_ECY.INFORMATION176;
4459 l_RATING_LEVEL_ID := r_ECY.INFORMATION180;
4460 else
4461 l_COMPETENCE_ID := r_ECY.INFORMATION174;
4462 l_RATING_LEVEL_ID := r_ECY.information178;
4463 end if;
4464
4465 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ECY.INFORMATION263,l_dml_operation);
4466
4467 *****************************************************************/
4468
4469
4470 if l_COMPETENCE_ID is null or l_RATING_LEVEL_ID is null then
4471 close c_ECY_min_max_dates;
4472 --
4473 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
4474 ,p_parent_pk_id => r_ECY.information263
4475 ,p_copy_entity_txn_id => p_copy_entity_txn_id
4476 ,p_child_table_alias => 'ECY'
4477 ,p_child_data => r_ECY.information173 );
4478 --Bug 5081751 Set the boolean variable if mapping is not done
4479 l_mapping_done := false;
4480 --End Bug 5081751
4481
4482 --
4483 else
4484 if p_reuse_object_flag = 'Y' then
4485 if c_ECY_min_max_dates%found then
4486 -- cursor to find the object
4487 open c_find_ECY_in_target( l_min_esd,l_max_eed,
4488 p_target_business_group_id, nvl(l_elig_comptncy_prte_id, -999) ) ;
4489 fetch c_find_ECY_in_target into l_new_value ;
4490 if c_find_ECY_in_target%found then
4491 --
4492 --TEMPIK
4493 l_dt_rec_found := dt_api.check_min_max_dates
4494 (p_base_table_name => 'BEN_ELIG_COMPTNCY_PRTE_F',
4495 p_base_key_column => 'ELIG_COMPTNCY_PRTE_ID',
4496 p_base_key_value => l_new_value,
4497 p_from_date => l_min_esd,
4498 p_to_date => l_max_eed );
4499 if l_dt_rec_found THEN
4500 --END TEMPIK
4501 if r_ECY_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
4502 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_COMPTNCY_PRTE_ID' then
4503 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_COMPTNCY_PRTE_ID' ;
4504 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECY_unique.information1 ;
4505 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
4506 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
4507 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECY_unique.table_route_id;
4508 --
4509 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
4510 --
4511 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
4512 end if ;
4513 --
4514 l_object_found_in_target := true ;
4515 --TEMPIK
4516 end if; -- l_dt_rec_found
4517 --END TEMPIK
4518 end if;
4519 close c_find_ECY_in_target ;
4520 --
4521 end if;
4522 end if ;
4523 --
4524 close c_ECY_min_max_dates ;
4525
4526 end if; -- bug 4565106
4527
4528 end if; --if p_dml_operation
4529 --
4530 --Bug 5081751 Bypass all the further statements if mapping is not done
4531 if ((not l_object_found_in_target OR l_update) and (l_mapping_done)) then
4532 -- End Bug 5081751
4533 --
4534 l_current_pk_id := r_ECY.information1;
4535 --
4536 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
4537 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
4538 --
4539 if l_current_pk_id = l_prev_pk_id then
4540 --
4541 l_first_rec := false ;
4542 --
4543 else
4544 --
4545 l_first_rec := true ;
4546 --
4547 end if ;
4548 --
4549
4550 l_effective_date := r_ECY.information2;
4551 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
4552 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
4553 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
4554 end if;
4555
4556 if l_first_rec and not l_update then
4557 -- Call Create routine.
4558 hr_utility.set_location(' BEN_ELIG_COMPTNCY_PRTE_F CREATE_ELIG_COMPTNCY_PRTE ',20);
4559 BEN_ELIG_COMPTNCY_PRTE_API.CREATE_ELIG_COMPTNCY_PRTE(
4560 --
4561 P_VALIDATE => false
4562 ,P_EFFECTIVE_DATE => l_effective_date
4563 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
4564 --
4565 ,P_COMPETENCE_ID => l_COMPETENCE_ID
4566 ,P_ECY_ATTRIBUTE1 => r_ECY.INFORMATION111
4567 ,P_ECY_ATTRIBUTE10 => r_ECY.INFORMATION120
4568 ,P_ECY_ATTRIBUTE11 => r_ECY.INFORMATION121
4569 ,P_ECY_ATTRIBUTE12 => r_ECY.INFORMATION122
4570 ,P_ECY_ATTRIBUTE13 => r_ECY.INFORMATION123
4571 ,P_ECY_ATTRIBUTE14 => r_ECY.INFORMATION124
4572 ,P_ECY_ATTRIBUTE15 => r_ECY.INFORMATION125
4573 ,P_ECY_ATTRIBUTE16 => r_ECY.INFORMATION126
4574 ,P_ECY_ATTRIBUTE17 => r_ECY.INFORMATION127
4575 ,P_ECY_ATTRIBUTE18 => r_ECY.INFORMATION128
4576 ,P_ECY_ATTRIBUTE19 => r_ECY.INFORMATION129
4577 ,P_ECY_ATTRIBUTE2 => r_ECY.INFORMATION112
4578 ,P_ECY_ATTRIBUTE20 => r_ECY.INFORMATION130
4579 ,P_ECY_ATTRIBUTE21 => r_ECY.INFORMATION131
4580 ,P_ECY_ATTRIBUTE22 => r_ECY.INFORMATION132
4581 ,P_ECY_ATTRIBUTE23 => r_ECY.INFORMATION133
4582 ,P_ECY_ATTRIBUTE24 => r_ECY.INFORMATION134
4583 ,P_ECY_ATTRIBUTE25 => r_ECY.INFORMATION135
4584 ,P_ECY_ATTRIBUTE26 => r_ECY.INFORMATION136
4585 ,P_ECY_ATTRIBUTE27 => r_ECY.INFORMATION137
4586 ,P_ECY_ATTRIBUTE28 => r_ECY.INFORMATION138
4587 ,P_ECY_ATTRIBUTE29 => r_ECY.INFORMATION139
4588 ,P_ECY_ATTRIBUTE3 => r_ECY.INFORMATION113
4589 ,P_ECY_ATTRIBUTE30 => r_ECY.INFORMATION140
4590 ,P_ECY_ATTRIBUTE4 => r_ECY.INFORMATION114
4591 ,P_ECY_ATTRIBUTE5 => r_ECY.INFORMATION115
4592 ,P_ECY_ATTRIBUTE6 => r_ECY.INFORMATION116
4593 ,P_ECY_ATTRIBUTE7 => r_ECY.INFORMATION117
4594 ,P_ECY_ATTRIBUTE8 => r_ECY.INFORMATION118
4595 ,P_ECY_ATTRIBUTE9 => r_ECY.INFORMATION119
4596 ,P_ECY_ATTRIBUTE_CATEGORY => r_ECY.INFORMATION110
4597 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
4598 ,P_ELIG_COMPTNCY_PRTE_ID => l_elig_comptncy_prte_id
4599 ,P_EXCLD_FLAG => r_ECY.INFORMATION11
4600 ,P_ORDR_NUM => r_ECY.INFORMATION257
4601 ,P_RATING_LEVEL_ID => l_RATING_LEVEL_ID
4602 --
4603 -- ****** END CHANGE LINES
4604
4605 --
4606
4607 ,P_EFFECTIVE_START_DATE => l_effective_start_date
4608 ,P_EFFECTIVE_END_DATE => l_effective_end_date
4609 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
4610 ,P_CRITERIA_SCORE => r_ecy.INFORMATION295
4611 ,P_CRITERIA_WEIGHT => r_ecy.INFORMATION296
4612 );
4613 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
4614 -- Update all relevent cer records with new pk_id
4615 hr_utility.set_location('Before plsql table ',222);
4616 hr_utility.set_location('new_value id '||l_elig_comptncy_prte_id,222);
4617 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_COMPTNCY_PRTE_ID' ;
4618 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECY.information1 ;
4619 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_COMPTNCY_PRTE_ID ;
4620 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
4621 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECY_unique.table_route_id;
4622 hr_utility.set_location('After plsql table ',222);
4623 --
4624 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
4625 --
4626 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
4627 --
4628 else /* l_first_rec and not l_update */
4629 --
4630 -- Call Update routine for the pk_id created in prev run .
4631 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
4632 hr_utility.set_location(' BEN_ELIG_COMPTNCY_PRTE_F UPDATE_ELIG_COMPTNCY_PRTE ',30);
4633 --UPD START
4634 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
4635 --
4636 if l_update then
4637 --
4638 l_datetrack_mode := r_ECY.datetrack_mode ;
4639 --
4640 get_dt_modes(
4641 p_effective_date => l_process_date,
4642 p_effective_end_date => r_ECY.information3,
4643 p_effective_start_date => r_ECY.information2,
4644 p_dml_operation => r_ECY.dml_operation,
4645 p_datetrack_mode => l_datetrack_mode );
4646 -- p_update => l_update
4647 --
4648 l_effective_date := l_process_date;
4649 l_ELIG_COMPTNCY_PRTE_ID := r_ECY.information1;
4650 l_object_version_number := r_ECY.information265;
4651 --
4652 end if;
4653 --
4654 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
4655 --
4656 IF l_update OR l_dml_operation <> 'UPDATE' THEN
4657 --UPD END
4658
4659
4660 BEN_ELIG_COMPTNCY_PRTE_API.UPDATE_ELIG_COMPTNCY_PRTE(
4661 --
4662 P_VALIDATE => false
4663 ,P_EFFECTIVE_DATE => l_effective_date
4664 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
4665 --
4666 ,P_COMPETENCE_ID => l_COMPETENCE_ID
4667 ,P_ECY_ATTRIBUTE1 => r_ECY.INFORMATION111
4668 ,P_ECY_ATTRIBUTE10 => r_ECY.INFORMATION120
4669 ,P_ECY_ATTRIBUTE11 => r_ECY.INFORMATION121
4670 ,P_ECY_ATTRIBUTE12 => r_ECY.INFORMATION122
4671 ,P_ECY_ATTRIBUTE13 => r_ECY.INFORMATION123
4672 ,P_ECY_ATTRIBUTE14 => r_ECY.INFORMATION124
4673 ,P_ECY_ATTRIBUTE15 => r_ECY.INFORMATION125
4674 ,P_ECY_ATTRIBUTE16 => r_ECY.INFORMATION126
4675 ,P_ECY_ATTRIBUTE17 => r_ECY.INFORMATION127
4676 ,P_ECY_ATTRIBUTE18 => r_ECY.INFORMATION128
4677 ,P_ECY_ATTRIBUTE19 => r_ECY.INFORMATION129
4678 ,P_ECY_ATTRIBUTE2 => r_ECY.INFORMATION112
4679 ,P_ECY_ATTRIBUTE20 => r_ECY.INFORMATION130
4680 ,P_ECY_ATTRIBUTE21 => r_ECY.INFORMATION131
4681 ,P_ECY_ATTRIBUTE22 => r_ECY.INFORMATION132
4682 ,P_ECY_ATTRIBUTE23 => r_ECY.INFORMATION133
4683 ,P_ECY_ATTRIBUTE24 => r_ECY.INFORMATION134
4684 ,P_ECY_ATTRIBUTE25 => r_ECY.INFORMATION135
4685 ,P_ECY_ATTRIBUTE26 => r_ECY.INFORMATION136
4686 ,P_ECY_ATTRIBUTE27 => r_ECY.INFORMATION137
4687 ,P_ECY_ATTRIBUTE28 => r_ECY.INFORMATION138
4688 ,P_ECY_ATTRIBUTE29 => r_ECY.INFORMATION139
4689 ,P_ECY_ATTRIBUTE3 => r_ECY.INFORMATION113
4690 ,P_ECY_ATTRIBUTE30 => r_ECY.INFORMATION140
4691 ,P_ECY_ATTRIBUTE4 => r_ECY.INFORMATION114
4692 ,P_ECY_ATTRIBUTE5 => r_ECY.INFORMATION115
4693 ,P_ECY_ATTRIBUTE6 => r_ECY.INFORMATION116
4694 ,P_ECY_ATTRIBUTE7 => r_ECY.INFORMATION117
4695 ,P_ECY_ATTRIBUTE8 => r_ECY.INFORMATION118
4696 ,P_ECY_ATTRIBUTE9 => r_ECY.INFORMATION119
4697 ,P_ECY_ATTRIBUTE_CATEGORY => r_ECY.INFORMATION110
4698 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
4699 ,P_ELIG_COMPTNCY_PRTE_ID => l_elig_comptncy_prte_id
4700 ,P_EXCLD_FLAG => r_ECY.INFORMATION11
4701 ,P_ORDR_NUM => r_ECY.INFORMATION257
4702 ,P_RATING_LEVEL_ID => l_RATING_LEVEL_ID
4703 --
4704 --****** END CHANGE LINES
4705
4706 --
4707 ,P_EFFECTIVE_START_DATE => l_effective_start_date
4708 ,P_EFFECTIVE_END_DATE => l_effective_end_date
4709 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
4710 ,P_DATETRACK_MODE => l_datetrack_mode
4711 ,P_CRITERIA_SCORE => r_ecy.INFORMATION295
4712 ,P_CRITERIA_WEIGHT => r_ecy.INFORMATION296
4713 );
4714 end if; -- l_update
4715 --
4716 end if; /* l_first_rec and not l_update */
4717 --
4718 -- Delete the row if it is end dated.
4719 --
4720 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
4721 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
4722 trunc(l_max_eed) = trunc(r_ECY.information3)) then
4723 --
4724 BEN_ELIG_COMPTNCY_PRTE_API.delete_ELIG_COMPTNCY_PRTE(
4725 --
4726 p_validate => false
4727 ,p_elig_comptncy_prte_id => l_elig_comptncy_prte_id
4728 ,p_effective_start_date => l_effective_start_date
4729 ,p_effective_end_date => l_effective_end_date
4730 ,p_object_version_number => l_object_version_number
4731 ,p_effective_date => l_max_eed
4732 ,p_datetrack_mode => hr_api.g_delete
4733 --
4734 );
4735 --
4736 end if;
4737 --
4738 l_prev_pk_id := l_current_pk_id ;
4739 --
4740 -- end if; -- bug 4565106
4741 --
4742 end if;
4743 --
4744 end if;
4745 --
4746 end loop;
4747
4748 /*
4749 ----------------------< DISPLAY START >---------------------------
4750 -- Print the Not Copied data to Log File BEN_PD_COPY_TO_BEN_THREE.G_NOT_COPIED_TBL
4751 --
4752 if l_not_copied_ecy_table_count > 0
4753 then
4754 --
4755 l_prev_parent_pk_id :=null;
4756 l_prev_ecy_id := null;
4757
4758 open c_display_name('ELP');
4759 --
4760 fetch c_display_name into l_elp_display_name, l_elp_table_route_id;
4761 --
4762 close c_display_name;
4763 --
4764 open c_display_name('ECY');
4765 --
4766 fetch c_display_name into l_ecy_display_name, l_ecy_table_route_id;
4767 --
4768 close c_display_name;
4769 --
4770 --
4771 ben_pd_copy_to_ben_three.g_not_copied_tbl(ben_pd_copy_to_ben_three.g_not_copied_tbl_count).text
4772 := l_label_start_tag ||
4773 l_elp_display_name ||
4774 l_label_end_tag;
4775 --
4776 ben_pd_copy_to_ben_three.g_not_copied_tbl_count := ben_pd_copy_to_ben_three.g_not_copied_tbl_count + 1;
4777 --
4778 FOR i IN l_not_copied_egl_tbl.FIRST .. l_not_copied_egl_tbl.LAST
4779 LOOP
4780 --
4781 if nvl(l_prev_parent_pk_id, -1) <> l_not_copied_egl_tbl(i).eligy_prfl_id
4782 then
4783 --
4784 open c_parent_data ( l_not_copied_egl_tbl(i).eligy_prfl_id, p_copy_entity_txn_id, l_elp_table_route_id );
4785 --
4786 fetch c_parent_data into l_elpro_name;
4787 --
4788 close c_parent_data;
4789 --
4790 ben_pd_copy_to_ben_three.g_not_copied_tbl(ben_pd_copy_to_ben_three.g_not_copied_tbl_count).text
4791 := l_para_spacer || l_elpro_name;
4792 --
4793 ben_pd_copy_to_ben_three.g_not_copied_tbl_count := ben_pd_copy_to_ben_three.g_not_copied_tbl_count + 1;
4794 --
4795 ben_pd_copy_to_ben_three.g_not_copied_tbl(ben_pd_copy_to_ben_three.g_not_copied_tbl_count).text
4796 := l_label_start_tag || l_para_spacer || l_para_spacer ||
4797 l_ecv_display_name ||
4798 l_label_end_tag;
4799 --
4800 ben_pd_copy_to_ben_three.g_not_copied_tbl_count := ben_pd_copy_to_ben_three.g_not_copied_tbl_count + 1;
4801 --
4802 l_prev_parent_pk_id := l_not_copied_egl_tbl(i).eligy_prfl_id;
4803 --
4804 end if;
4805 --
4806 IF nvl(l_prev_ecy_id, -1) <> l_not_copied_egl_tbl(i).elig_comptncy_prte_id
4807 THEN
4808 --
4809 ben_pd_copy_to_ben_three.g_not_copied_tbl(ben_pd_copy_to_ben_three.g_not_copied_tbl_count).text
4810 := l_para_spacer ||
4811 l_para_spacer || l_para_spacer ||
4812 l_not_copied_egl_tbl(i).text;
4813 --
4814 ben_pd_copy_to_ben_three.g_not_copied_tbl_count := ben_pd_copy_to_ben_three.g_not_copied_tbl_count + 1;
4815 --
4816 l_prev_ecy_id := l_not_copied_egl_tbl(i).elig_comptncy_prte_id;
4817 --
4818 END IF;
4819 --
4820 END LOOP;
4821 --
4822 end if;
4823 --
4824 ----------------------< DISPLAY END >---------------------------
4825 */
4826
4827 --
4828 exception when others then
4829 --
4830 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ECY',r_ECY.information5 ) ;
4831 --
4832 end create_ECY_rows;
4833
4834 --
4835 ---------------------------------------------------------------
4836 ----------------------< create_EDG_rows >-----------------------
4837 ---------------------------------------------------------------
4838 --
4839 procedure create_EDG_rows
4840 (
4841 p_validate in number default 0
4842 ,p_copy_entity_txn_id in number
4843 ,p_effective_date in date
4844 ,p_prefix_suffix_text in varchar2 default null
4845 ,p_reuse_object_flag in varchar2 default null
4846 ,p_target_business_group_id in varchar2 default null
4847 ,p_prefix_suffix_cd in varchar2 default null
4848 ) is
4849 --
4850 l_ELIGY_PRFL_ID number;
4851 l_PGM_ID number;
4852 l_ordr_num number;
4853 cursor c_unique_EDG(l_table_alias varchar2) is
4854 select distinct cpe.information1,
4855 cpe.information2,
4856 cpe.information3,
4857 cpe.table_route_id
4858 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
4859 pqh_table_route tr
4860 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4861 and cpe.table_route_id = tr.table_route_id
4862 -- and tr.where_clause = l_BEN_ELG_DPNT_CVR_OTHR_PGM_F
4863 and tr.table_alias = l_table_alias
4864 and cpe.number_of_copies = 1 -- ADDITION
4865 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
4866 order by information1, information2; --added for bug: 5151945
4867 --
4868 --
4869 cursor c_EDG_min_max_dates(c_table_route_id number,
4870 c_information1 number) is
4871 select
4872 min(cpe.information2) min_esd,
4873 max(cpe.information3) min_eed
4874 from ben_copy_entity_results cpe
4875 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4876 and cpe.table_route_id = c_table_route_id
4877 and cpe.information1 = c_information1 ;
4878 --
4879 cursor c_EDG(c_table_route_id number,
4880 c_information1 number,
4881 c_information2 date,
4882 c_information3 date) is
4883 select
4884 cpe.*
4885 from ben_copy_entity_results cpe
4886 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4887 and cpe.table_route_id = c_table_route_id
4888 and cpe.information1 = c_information1
4889 and cpe.information2 = c_information2
4890 and cpe.information3 = c_information3
4891 and rownum = 1 ;
4892 -- Date Track target record
4893 cursor c_find_EDG_in_target(
4894 c_effective_start_date date,
4895 c_effective_end_date date,
4896 c_business_group_id number,
4897 c_new_pk_id number) is
4898 select
4899 EDG.elig_dpnt_cvrd_othr_pgm_id new_value
4900 from BEN_ELIG_DPNT_CVRD_OTHR_PGM_F EDG
4901 where
4902 EDG.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
4903 EDG.PGM_ID = l_PGM_ID and
4904 EDG.ORDR_NUM = l_ORDR_NUM and
4905 EDG.business_group_id = c_business_group_id
4906 and EDG.elig_dpnt_cvrd_othr_pgm_id <> c_new_pk_id
4907 and c_effective_start_date between effective_start_date
4908 and effective_end_date ;
4909 --END TEMPIK
4910 /*TEMPIK
4911 and exists ( select null
4912 from BEN_ELIG_DPNT_CVRD_OTHR_PGM_F EDG1
4913 where
4914 EDG1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
4915 EDG1.PGM_ID = l_PGM_ID and
4916 EDG1.ORDR_NUM = l_ORDR_NUM and
4917 EDG1.business_group_id = c_business_group_id
4918 and EDG1.effective_start_date <= c_effective_start_date )
4919 and exists ( select null
4920 from BEN_ELIG_DPNT_CVRD_OTHR_PGM_F EDG2
4921 where
4922 EDG2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
4923 EDG2.PGM_ID = l_PGM_ID and
4924 EDG2.ORDR_NUM = l_ORDR_NUM and
4925 EDG2.business_group_id = c_business_group_id
4926 and EDG2.effective_end_date >= c_effective_end_date )
4927 ;
4928 TEMPIK */
4929 --TEMPIK
4930 l_dt_rec_found boolean ;
4931 --END TEMPIK
4932 --
4933
4934 --UPD START
4935 --
4936 l_update boolean := false ;
4937 l_datetrack_mode varchar2(80) := hr_api.g_update;
4938 l_process_date date;
4939 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
4940 --
4941 --UPD END
4942 l_current_pk_id number := null ;
4943
4944 l_prev_pk_id number := null ;
4945 l_first_rec boolean := true ;
4946 r_EDG c_EDG%rowtype;
4947 l_elig_dpnt_cvrd_othr_pgm_id number ;
4948 l_object_version_number number ;
4949 l_effective_start_date date ;
4950 l_effective_end_date date ;
4951 l_prefix pqh_copy_entity_attribs.information1%type := null;
4952 l_suffix pqh_copy_entity_attribs.information1%type := null;
4953 l_new_value number(15);
4954 l_object_found_in_target boolean := false ;
4955 l_min_esd date;
4956 l_max_eed date;
4957 l_effective_date date;
4958 --
4959 begin
4960 -- Initialization
4961 l_object_found_in_target := false ;
4962 -- End Initialization
4963 -- Derive the prefix - sufix
4964 if p_prefix_suffix_cd = 'PREFIX' then
4965 l_prefix := p_prefix_suffix_text ;
4966 elsif p_prefix_suffix_cd = 'SUFFIX' then
4967 l_suffix := p_prefix_suffix_text ;
4968 else
4969 l_prefix := null ;
4970 l_suffix := null ;
4971 end if ;
4972 -- End Prefix Sufix derivation
4973 for r_EDG_unique in c_unique_EDG('EDG') loop
4974
4975 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
4976 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
4977 r_EDG_unique.information3 >=
4978 ben_pd_copy_to_ben_one.g_copy_effective_date)
4979 ) then
4980 --
4981 hr_utility.set_location(' r_EDG_unique.table_route_id '||r_EDG_unique.table_route_id,10);
4982 hr_utility.set_location(' r_EDG_unique.information1 '||r_EDG_unique.information1,10);
4983 hr_utility.set_location( 'r_EDG_unique.information2 '||r_EDG_unique.information2,10);
4984 hr_utility.set_location( 'r_EDG_unique.information3 '||r_EDG_unique.information3,10);
4985 -- If reuse objects flag is 'Y' then check for the object in the target business group
4986 -- if found insert the record into PLSql table and exit the loop else try create the
4987 -- object in the target business group
4988 --
4989 l_object_found_in_target := false ;
4990 --UPD START
4991 l_update := false;
4992 l_process_date := p_effective_date;
4993 l_dml_operation:= r_EDG_unique.dml_operation ;
4994 --
4995
4996 /**********************moved from below **********************/
4997 open c_EDG(r_EDG_unique.table_route_id,
4998 r_EDG_unique.information1,
4999 r_EDG_unique.information2,
5000 r_EDG_unique.information3 ) ;
5001 --
5002 fetch c_EDG into r_EDG ;
5003 --
5004 close c_EDG ;
5005 --
5006 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDG.INFORMATION263,l_dml_operation);
5007 l_ordr_num := r_EDG.INFORMATION261 ; -- IK
5008
5009 -- Only For Use by Create Wizard - Same Business Group
5010 l_PGM_ID := NVL(get_fk('PGM_ID', r_EDG.INFORMATION260,l_dml_operation),
5011 r_EDG.INFORMATION260);
5012 /**********************************************************/
5013
5014 if l_dml_operation = 'UPDATE' then
5015 --
5016 l_object_found_in_target := TRUE;
5017 --
5018 if l_process_date between r_EDG_unique.information2 and r_EDG_unique.information3 then
5019 l_update := true;
5020 if r_EDG_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
5021 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DPNT_CVRD_OTHR_PGM_ID' then
5022 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_CVRD_OTHR_PGM_ID' ;
5023 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDG_unique.information1 ;
5024 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EDG_unique.information1 ;
5025 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
5026 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDG_unique.table_route_id;
5027 --
5028 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
5029 --
5030 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
5031 --
5032 -- log_data('EDG',l_new_value,l_prefix || r_EDG_unique.name|| l_suffix,'REUSED');
5033 --
5034 end if ;
5035 hr_utility.set_location( 'found record for update',10);
5036 --
5037 else
5038 --
5039 l_update := false;
5040 --
5041 end if;
5042 else
5043 --
5044 --UPD END
5045 l_min_esd := null ;
5046 l_max_eed := null ;
5047 open c_EDG_min_max_dates(r_EDG_unique.table_route_id, r_EDG_unique.information1 ) ;
5048 fetch c_EDG_min_max_dates into l_min_esd,l_max_eed ;
5049 --
5050
5051 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
5052 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
5053 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
5054 end if;
5055 l_min_esd := greatest(l_min_esd,r_EDG_unique.information2);
5056 /**********************moved up from here **********************
5057 open c_EDG(r_EDG_unique.table_route_id,
5058 r_EDG_unique.information1,
5059 r_EDG_unique.information2,
5060 r_EDG_unique.information3 ) ;
5061 --
5062 fetch c_EDG into r_EDG ;
5063 --
5064 close c_EDG ;
5065 --
5066 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDG.INFORMATION263,l_dml_operation);
5067 l_ordr_num := r_EDG.INFORMATION261 ; -- IK
5068
5069 -- Only For Use by Create Wizard - Same Business Group
5070 l_PGM_ID := NVL(get_fk('PGM_ID', r_EDG.INFORMATION260,l_dml_operation),
5071 r_EDG.INFORMATION260);
5072 **********************************************************/
5073
5074 if p_reuse_object_flag = 'Y' then
5075 if c_EDG_min_max_dates%found then
5076 -- cursor to find the object
5077 open c_find_EDG_in_target( l_min_esd,l_max_eed,
5078 p_target_business_group_id, nvl(l_elig_dpnt_cvrd_othr_pgm_id, -999) ) ;
5079 fetch c_find_EDG_in_target into l_new_value ;
5080 if c_find_EDG_in_target%found then
5081 --
5082 --TEMPIK
5083 l_dt_rec_found := dt_api.check_min_max_dates
5084 (p_base_table_name => 'BEN_ELIG_DPNT_CVRD_OTHR_PGM_F',
5085 p_base_key_column => 'ELIG_DPNT_CVRD_OTHR_PGM_ID',
5086 p_base_key_value => l_new_value,
5087 p_from_date => l_min_esd,
5088 p_to_date => l_max_eed );
5089 if l_dt_rec_found THEN
5090 --END TEMPIK
5091 if r_EDG_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
5092 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DPNT_CVRD_OTHR_PGM_ID' then
5093 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_CVRD_OTHR_PGM_ID' ;
5094 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDG_unique.information1 ;
5095 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
5096 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
5097 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDG_unique.table_route_id;
5098 --
5099 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
5100 --
5101 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
5102 end if ;
5103 --
5104 l_object_found_in_target := true ;
5105 --TEMPIK
5106 end if; -- l_dt_rec_found
5107 --END TEMPIK
5108 end if;
5109 close c_find_EDG_in_target ;
5110 --
5111 end if;
5112 end if ;
5113 --
5114 close c_EDG_min_max_dates ;
5115 end if; --if p_dml_operation
5116 --
5117 if not l_object_found_in_target OR l_update then
5118
5119 --
5120 l_current_pk_id := r_EDG.information1;
5121 --
5122 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
5123 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
5124 --
5125 if l_current_pk_id = l_prev_pk_id then
5126 --
5127 l_first_rec := false ;
5128 --
5129 else
5130 --
5131 l_first_rec := true ;
5132 --
5133 end if ;
5134 --
5135
5136 l_effective_date := r_EDG.information2;
5137 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
5138 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
5139 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
5140 end if;
5141
5142 if l_first_rec and not l_update then
5143 -- Call Create routine.
5144 hr_utility.set_location(' BEN_ELIG_DPNT_CVRD_OTHR_PGM_F CREATE_ELIG_DPNT_CVRD_O_PGM ',20);
5145 BEN_ELIG_DPNT_CVRD_O_PGM_API.CREATE_ELIG_DPNT_CVRD_O_PGM(
5146 --
5147 P_VALIDATE => false
5148 ,P_EFFECTIVE_DATE => l_effective_date
5149 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5150 --
5151 ,P_EDG_ATTRIBUTE1 => r_EDG.INFORMATION111
5152 ,P_EDG_ATTRIBUTE10 => r_EDG.INFORMATION120
5153 ,P_EDG_ATTRIBUTE11 => r_EDG.INFORMATION121
5154 ,P_EDG_ATTRIBUTE12 => r_EDG.INFORMATION122
5155 ,P_EDG_ATTRIBUTE13 => r_EDG.INFORMATION123
5156 ,P_EDG_ATTRIBUTE14 => r_EDG.INFORMATION124
5157 ,P_EDG_ATTRIBUTE15 => r_EDG.INFORMATION125
5158 ,P_EDG_ATTRIBUTE16 => r_EDG.INFORMATION126
5159 ,P_EDG_ATTRIBUTE17 => r_EDG.INFORMATION127
5160 ,P_EDG_ATTRIBUTE18 => r_EDG.INFORMATION128
5161 ,P_EDG_ATTRIBUTE19 => r_EDG.INFORMATION129
5162 ,P_EDG_ATTRIBUTE2 => r_EDG.INFORMATION112
5163 ,P_EDG_ATTRIBUTE20 => r_EDG.INFORMATION130
5164 ,P_EDG_ATTRIBUTE21 => r_EDG.INFORMATION131
5165 ,P_EDG_ATTRIBUTE22 => r_EDG.INFORMATION132
5166 ,P_EDG_ATTRIBUTE23 => r_EDG.INFORMATION133
5167 ,P_EDG_ATTRIBUTE24 => r_EDG.INFORMATION134
5168 ,P_EDG_ATTRIBUTE25 => r_EDG.INFORMATION135
5169 ,P_EDG_ATTRIBUTE26 => r_EDG.INFORMATION136
5170 ,P_EDG_ATTRIBUTE27 => r_EDG.INFORMATION137
5171 ,P_EDG_ATTRIBUTE28 => r_EDG.INFORMATION138
5172 ,P_EDG_ATTRIBUTE29 => r_EDG.INFORMATION139
5173 ,P_EDG_ATTRIBUTE3 => r_EDG.INFORMATION113
5174 ,P_EDG_ATTRIBUTE30 => r_EDG.INFORMATION140
5175 ,P_EDG_ATTRIBUTE4 => r_EDG.INFORMATION114
5176 ,P_EDG_ATTRIBUTE5 => r_EDG.INFORMATION115
5177 ,P_EDG_ATTRIBUTE6 => r_EDG.INFORMATION116
5178 ,P_EDG_ATTRIBUTE7 => r_EDG.INFORMATION117
5179 ,P_EDG_ATTRIBUTE8 => r_EDG.INFORMATION118
5180 ,P_EDG_ATTRIBUTE9 => r_EDG.INFORMATION119
5181 ,P_EDG_ATTRIBUTE_CATEGORY => r_EDG.INFORMATION110
5182 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
5183 ,P_ELIG_DPNT_CVRD_OTHR_PGM_ID => l_elig_dpnt_cvrd_othr_pgm_id
5184 ,P_ENRL_DET_DT_CD => r_EDG.INFORMATION13
5185 ,P_EXCLD_FLAG => r_EDG.INFORMATION11
5186 ,P_ONLY_PLS_SUBJ_COBRA_FLAG => r_EDG.INFORMATION12
5187 ,P_ORDR_NUM => r_EDG.INFORMATION261
5188 ,P_PGM_ID => l_PGM_ID
5189 --
5190 -- ****** END CHANGE LINES
5191
5192 --
5193
5194 ,P_EFFECTIVE_START_DATE => l_effective_start_date
5195 ,P_EFFECTIVE_END_DATE => l_effective_end_date
5196 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5197 );
5198 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
5199 -- Update all relevent cer records with new pk_id
5200 hr_utility.set_location('Before plsql table ',222);
5201 hr_utility.set_location('new_value id '||l_elig_dpnt_cvrd_othr_pgm_id,222);
5202 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_CVRD_OTHR_PGM_ID' ;
5203 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDG.information1 ;
5204 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_DPNT_CVRD_OTHR_PGM_ID ;
5205 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
5206 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDG_unique.table_route_id;
5207 hr_utility.set_location('After plsql table ',222);
5208 --
5209 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
5210 --
5211 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
5212 --
5213 else
5214 --
5215 -- Call Update routine for the pk_id created in prev run .
5216 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
5217 hr_utility.set_location(' BEN_ELIG_DPNT_CVRD_OTHR_PGM_F UPDATE_ELIG_DPNT_CVRD_O_PGM ',30);
5218 --UPD START
5219 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
5220 --
5221 if l_update then
5222 --
5223 l_datetrack_mode := r_EDG.datetrack_mode ;
5224 --
5225 get_dt_modes(
5226 p_effective_date => l_process_date,
5227 p_effective_end_date => r_EDG.information3,
5228 p_effective_start_date => r_EDG.information2,
5229 p_dml_operation => r_EDG.dml_operation,
5230 p_datetrack_mode => l_datetrack_mode );
5231 -- p_update => l_update
5232 --
5233 l_effective_date := l_process_date;
5234 l_ELIG_DPNT_CVRD_OTHR_PGM_ID := r_EDG.information1;
5235 l_object_version_number := r_EDG.information265;
5236 --
5237 end if;
5238 --
5239 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
5240 --
5241 IF l_update OR l_dml_operation <> 'UPDATE' THEN
5242 --UPD END
5243
5244
5245 BEN_ELIG_DPNT_CVRD_O_PGM_API.UPDATE_ELIG_DPNT_CVRD_O_PGM(
5246 --
5247 P_VALIDATE => false
5248 ,P_EFFECTIVE_DATE => l_effective_date
5249 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5250 --
5251 ,P_EDG_ATTRIBUTE1 => r_EDG.INFORMATION111
5252 ,P_EDG_ATTRIBUTE10 => r_EDG.INFORMATION120
5253 ,P_EDG_ATTRIBUTE11 => r_EDG.INFORMATION121
5254 ,P_EDG_ATTRIBUTE12 => r_EDG.INFORMATION122
5255 ,P_EDG_ATTRIBUTE13 => r_EDG.INFORMATION123
5256 ,P_EDG_ATTRIBUTE14 => r_EDG.INFORMATION124
5257 ,P_EDG_ATTRIBUTE15 => r_EDG.INFORMATION125
5258 ,P_EDG_ATTRIBUTE16 => r_EDG.INFORMATION126
5259 ,P_EDG_ATTRIBUTE17 => r_EDG.INFORMATION127
5260 ,P_EDG_ATTRIBUTE18 => r_EDG.INFORMATION128
5261 ,P_EDG_ATTRIBUTE19 => r_EDG.INFORMATION129
5262 ,P_EDG_ATTRIBUTE2 => r_EDG.INFORMATION112
5263 ,P_EDG_ATTRIBUTE20 => r_EDG.INFORMATION130
5264 ,P_EDG_ATTRIBUTE21 => r_EDG.INFORMATION131
5265 ,P_EDG_ATTRIBUTE22 => r_EDG.INFORMATION132
5266 ,P_EDG_ATTRIBUTE23 => r_EDG.INFORMATION133
5267 ,P_EDG_ATTRIBUTE24 => r_EDG.INFORMATION134
5268 ,P_EDG_ATTRIBUTE25 => r_EDG.INFORMATION135
5269 ,P_EDG_ATTRIBUTE26 => r_EDG.INFORMATION136
5270 ,P_EDG_ATTRIBUTE27 => r_EDG.INFORMATION137
5271 ,P_EDG_ATTRIBUTE28 => r_EDG.INFORMATION138
5272 ,P_EDG_ATTRIBUTE29 => r_EDG.INFORMATION139
5273 ,P_EDG_ATTRIBUTE3 => r_EDG.INFORMATION113
5274 ,P_EDG_ATTRIBUTE30 => r_EDG.INFORMATION140
5275 ,P_EDG_ATTRIBUTE4 => r_EDG.INFORMATION114
5276 ,P_EDG_ATTRIBUTE5 => r_EDG.INFORMATION115
5277 ,P_EDG_ATTRIBUTE6 => r_EDG.INFORMATION116
5278 ,P_EDG_ATTRIBUTE7 => r_EDG.INFORMATION117
5279 ,P_EDG_ATTRIBUTE8 => r_EDG.INFORMATION118
5280 ,P_EDG_ATTRIBUTE9 => r_EDG.INFORMATION119
5281 ,P_EDG_ATTRIBUTE_CATEGORY => r_EDG.INFORMATION110
5282 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
5283 ,P_ELIG_DPNT_CVRD_OTHR_PGM_ID => l_elig_dpnt_cvrd_othr_pgm_id
5284 ,P_ENRL_DET_DT_CD => r_EDG.INFORMATION13
5285 ,P_EXCLD_FLAG => r_EDG.INFORMATION11
5286 ,P_ONLY_PLS_SUBJ_COBRA_FLAG => r_EDG.INFORMATION12
5287 ,P_ORDR_NUM => r_EDG.INFORMATION261
5288 ,P_PGM_ID => l_PGM_ID
5289 --
5290 -- ****** END CHANGE LINES
5291
5292 --
5293 ,P_EFFECTIVE_START_DATE => l_effective_start_date
5294 ,P_EFFECTIVE_END_DATE => l_effective_end_date
5295 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5296 ,P_DATETRACK_MODE => l_datetrack_mode
5297 );
5298 end if; -- l_update
5299 --
5300 end if;
5301 --
5302 -- Delete the row if it is end dated.
5303 --
5304 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
5305 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
5306 trunc(l_max_eed) = trunc(r_EDG.information3)) then
5307 --
5308 BEN_ELIG_DPNT_CVRD_O_PGM_API.delete_ELIG_DPNT_CVRD_O_PGM(
5309 --
5310 p_validate => false
5311 ,p_elig_dpnt_cvrd_othr_pgm_id => l_elig_dpnt_cvrd_othr_pgm_id
5312 ,p_effective_start_date => l_effective_start_date
5313 ,p_effective_end_date => l_effective_end_date
5314 ,p_object_version_number => l_object_version_number
5315 ,p_effective_date => l_max_eed
5316 ,p_datetrack_mode => hr_api.g_delete
5317 --
5318 );
5319 --
5320 end if;
5321 --
5322 l_prev_pk_id := l_current_pk_id ;
5323 --
5324 end if;
5325 --
5326 end if;
5327 --
5328 end loop;
5329 --
5330 exception when others then
5331 --
5332 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EDG',r_EDG.information5 ) ;
5333 --
5334 end create_EDG_rows;
5335
5336 --
5337 ---------------------------------------------------------------
5338 ----------------------< create_EDI_rows >-----------------------
5339 ---------------------------------------------------------------
5340 --
5341 procedure create_EDI_rows
5342 (
5343 p_validate in number default 0
5344 ,p_copy_entity_txn_id in number
5345 ,p_effective_date in date
5346 ,p_prefix_suffix_text in varchar2 default null
5347 ,p_reuse_object_flag in varchar2 default null
5348 ,p_target_business_group_id in varchar2 default null
5349 ,p_prefix_suffix_cd in varchar2 default null
5350 ) is
5351 --
5352 l_ELIGY_PRFL_ID number;
5353 l_PLIP_ID number;
5354 l_ORDR_NUM number;
5355 --
5356 cursor c_unique_EDI(l_table_alias varchar2) is
5357 select distinct cpe.information1,
5358 cpe.information2,
5359 cpe.information3,
5360 cpe.table_route_id
5361 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
5362 pqh_table_route tr
5363 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5364 and cpe.table_route_id = tr.table_route_id
5365 -- and tr.where_clause = l_BEN_ELIG_DPNT_CVRD_PLIP_F
5366 and tr.table_alias = l_table_alias
5367 and cpe.number_of_copies = 1 -- ADDITION
5368 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
5369 order by information1, information2; --added for bug: 5151945
5370 --
5371 --
5372 cursor c_EDI_min_max_dates(c_table_route_id number,
5373 c_information1 number) is
5374 select
5375 min(cpe.information2) min_esd,
5376 max(cpe.information3) min_eed
5377 from ben_copy_entity_results cpe
5378 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5379 and cpe.table_route_id = c_table_route_id
5380 and cpe.information1 = c_information1 ;
5381 --
5382 cursor c_EDI(c_table_route_id number,
5383 c_information1 number,
5384 c_information2 date,
5385 c_information3 date ) is
5386 select
5387 cpe.*
5388 from ben_copy_entity_results cpe
5389 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5390 and cpe.table_route_id = c_table_route_id
5391 and cpe.information1 = c_information1
5392 and cpe.information2 = c_information2
5393 and cpe.information3 = c_information3
5394 and rownum = 1 ;
5395 -- Date Track target record
5396 cursor c_find_EDI_in_target(
5397 c_effective_start_date date,
5398 c_effective_end_date date,
5399 c_business_group_id number,
5400 c_new_pk_id number) is
5401 select
5402 EDI.elig_dpnt_cvrd_plip_id new_value
5403 from BEN_ELIG_DPNT_CVRD_PLIP_F EDI
5404 where
5405 EDI.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
5406 EDI.PLIP_ID = l_PLIP_ID and
5407 EDI.ORDR_NUM = l_ORDR_NUM and -- IK Added this
5408 EDI.business_group_id = c_business_group_id
5409 and EDI.elig_dpnt_cvrd_plip_id <> c_new_pk_id
5410 and c_effective_start_date between effective_start_date
5411 and effective_end_date ;
5412 --END TEMPIK
5413 /*TEMPIK
5414 and exists ( select null
5415 from BEN_ELIG_DPNT_CVRD_PLIP_F EDI1
5416 where
5417 EDI1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
5418 EDI1.PLIP_ID = l_PLIP_ID and
5419 EDI1.ORDR_NUM = l_ORDR_NUM and
5420 EDI1.business_group_id = c_business_group_id
5421 and EDI1.effective_start_date <= c_effective_start_date )
5422 and exists ( select null
5423 from BEN_ELIG_DPNT_CVRD_PLIP_F EDI2
5424 where
5425 EDI2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
5426 EDI2.PLIP_ID = l_PLIP_ID and
5427 EDI2.ORDR_NUM = l_ORDR_NUM and
5428 EDI2.business_group_id = c_business_group_id
5429 and EDI2.effective_end_date >= c_effective_end_date )
5430 ;
5431 TEMPIK */
5432 --TEMPIK
5433 l_dt_rec_found boolean ;
5434 --END TEMPIK
5435 --
5436
5437 --UPD START
5438 --
5439 l_update boolean := false ;
5440 l_datetrack_mode varchar2(80) := hr_api.g_update;
5441 l_process_date date;
5442 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
5443 --
5444 --UPD END
5445 l_current_pk_id number := null ;
5446
5447 l_prev_pk_id number := null ;
5448 l_first_rec boolean := true ;
5449 r_EDI c_EDI%rowtype;
5450 l_elig_dpnt_cvrd_plip_id number ;
5451 l_object_version_number number ;
5452 l_effective_start_date date ;
5453 l_effective_end_date date ;
5454 l_prefix pqh_copy_entity_attribs.information1%type := null;
5455 l_suffix pqh_copy_entity_attribs.information1%type := null;
5456 l_new_value number(15);
5457 l_object_found_in_target boolean := false ;
5458 l_min_esd date;
5459 l_max_eed date;
5460 l_effective_date date;
5461 --
5462 begin
5463 -- Initialization
5464 l_object_found_in_target := false ;
5465 -- End Initialization
5466 -- Derive the prefix - sufix
5467 if p_prefix_suffix_cd = 'PREFIX' then
5468 l_prefix := p_prefix_suffix_text ;
5469 elsif p_prefix_suffix_cd = 'SUFFIX' then
5470 l_suffix := p_prefix_suffix_text ;
5471 else
5472 l_prefix := null ;
5473 l_suffix := null ;
5474 end if ;
5475 -- End Prefix Sufix derivation
5476 for r_EDI_unique in c_unique_EDI('EDI') loop
5477
5478 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
5479 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
5480 r_EDI_unique.information3 >=
5481 ben_pd_copy_to_ben_one.g_copy_effective_date)
5482 ) then
5483 --
5484 hr_utility.set_location(' r_EDI_unique.table_route_id '||r_EDI_unique.table_route_id,10);
5485 hr_utility.set_location(' r_EDI_unique.information1 '||r_EDI_unique.information1,10);
5486 hr_utility.set_location( 'r_EDI_unique.information2 '||r_EDI_unique.information2,10);
5487 hr_utility.set_location( 'r_EDI_unique.information3 '||r_EDI_unique.information3,10);
5488 -- If reuse objects flag is 'Y' then check for the object in the target business group
5489 -- if found insert the record into PLSql table and exit the loop else try create the
5490 -- object in the target business group
5491 --
5492 l_object_found_in_target := false ;
5493 --UPD START
5494 l_update := false;
5495 l_process_date := p_effective_date;
5496 l_dml_operation:= r_EDI_unique.dml_operation ;
5497 --
5498
5499 /**********************moved from below **********************/
5500
5501 open c_EDI(r_EDI_unique.table_route_id,
5502 r_EDI_unique.information1,
5503 r_EDI_unique.information2,
5504 r_EDI_unique.information3 ) ;
5505 --
5506 fetch c_EDI into r_EDI ;
5507 --
5508 close c_EDI ;
5509 --
5510 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDI.INFORMATION263,l_dml_operation);
5511 l_ORDR_NUM := r_EDI.INFORMATION260 ; -- IK
5512
5513 -- Only For Use by Create Wizard - Same Business Group
5514 l_PLIP_ID := NVL(get_fk('PLIP_ID', r_EDI.INFORMATION256,l_dml_operation),
5515 r_EDI.INFORMATION256);
5516 /**********************************************************/
5517
5518 if l_dml_operation = 'UPDATE' then
5519 --
5520 l_object_found_in_target := TRUE;
5521 --
5522 if l_process_date between r_EDI_unique.information2 and r_EDI_unique.information3 then
5523 l_update := true;
5524 if r_EDI_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
5525 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DPNT_CVRD_PLIP_ID' then
5526 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_CVRD_PLIP_ID' ;
5527 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDI_unique.information1 ;
5528 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EDI_unique.information1 ;
5529 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
5530 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDI_unique.table_route_id;
5531 --
5532 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
5533 --
5534 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
5535 --
5536 -- log_data('EDI',l_new_value,l_prefix || r_EDI_unique.name|| l_suffix,'REUSED');
5537 --
5538 end if ;
5539 hr_utility.set_location( 'found record for update',10);
5540 --
5541 else
5542 --
5543 l_update := false;
5544 --
5545 end if;
5546 else
5547 --
5548 --UPD END
5549 l_min_esd := null ;
5550 l_max_eed := null ;
5551 open c_EDI_min_max_dates(r_EDI_unique.table_route_id, r_EDI_unique.information1 ) ;
5552 fetch c_EDI_min_max_dates into l_min_esd,l_max_eed ;
5553 --
5554
5555 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
5556 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
5557 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
5558 end if;
5559 l_min_esd := greatest(l_min_esd,r_EDI_unique.information2);
5560 /**********************moved up from here **********************
5561
5562 open c_EDI(r_EDI_unique.table_route_id,
5563 r_EDI_unique.information1,
5564 r_EDI_unique.information2,
5565 r_EDI_unique.information3 ) ;
5566 --
5567 fetch c_EDI into r_EDI ;
5568 --
5569 close c_EDI ;
5570 --
5571 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDI.INFORMATION263,l_dml_operation);
5572 l_ORDR_NUM := r_EDI.INFORMATION260 ; -- IK
5573
5574 -- Only For Use by Create Wizard - Same Business Group
5575 l_PLIP_ID := NVL(get_fk('PLIP_ID', r_EDI.INFORMATION256,l_dml_operation),
5576 r_EDI.INFORMATION256);
5577
5578 **********************************************************/
5579
5580 if p_reuse_object_flag = 'Y' then
5581 if c_EDI_min_max_dates%found then
5582 -- cursor to find the object
5583 open c_find_EDI_in_target( l_min_esd,l_max_eed,
5584 p_target_business_group_id, nvl(l_elig_dpnt_cvrd_plip_id, -999) ) ;
5585 fetch c_find_EDI_in_target into l_new_value ;
5586 if c_find_EDI_in_target%found then
5587 --
5588 --TEMPIK
5589 l_dt_rec_found := dt_api.check_min_max_dates
5590 (p_base_table_name => 'BEN_ELIG_DPNT_CVRD_PLIP_F',
5591 p_base_key_column => 'ELIG_DPNT_CVRD_PLIP_ID',
5592 p_base_key_value => l_new_value,
5593 p_from_date => l_min_esd,
5594 p_to_date => l_max_eed );
5595 if l_dt_rec_found THEN
5596 --END TEMPIK
5597 if r_EDI_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
5598 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DPNT_CVRD_PLIP_ID' then
5599 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_CVRD_PLIP_ID' ;
5600 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDI_unique.information1 ;
5601 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
5602 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
5603 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDI_unique.table_route_id;
5604 --
5605 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
5606 --
5607 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
5608 end if ;
5609 --
5610 l_object_found_in_target := true ;
5611 --TEMPIK
5612 end if; -- l_dt_rec_found
5613 --END TEMPIK
5614 end if;
5615 close c_find_EDI_in_target ;
5616 --
5617 end if;
5618 end if ;
5619 --
5620 close c_EDI_min_max_dates ;
5621 end if; --if p_dml_operation
5622 --
5623 if not l_object_found_in_target OR l_update then
5624
5625 --
5626 l_current_pk_id := r_EDI.information1;
5627 --
5628 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
5629 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
5630 --
5631 if l_current_pk_id = l_prev_pk_id then
5632 --
5633 l_first_rec := false ;
5634 --
5635 else
5636 --
5637 l_first_rec := true ;
5638 --
5639 end if ;
5640 --
5641
5642 l_effective_date := r_EDI.information2;
5643 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
5644 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
5645 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
5646 end if;
5647
5648 if l_first_rec and not l_update then
5649 -- Call Create routine.
5650 hr_utility.set_location(' BEN_ELIG_DPNT_CVRD_PLIP_F CREATE_ELIG_DPNT_CVRD_PLIP ',20);
5651 BEN_ELIG_DPNT_CVRD_PLIP_API.CREATE_ELIG_DPNT_CVRD_PLIP(
5652 --
5653 P_VALIDATE => false
5654 ,P_EFFECTIVE_DATE => l_effective_date
5655 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5656 --
5657 ,P_EDI_ATTRIBUTE1 => r_EDI.INFORMATION111
5658 ,P_EDI_ATTRIBUTE10 => r_EDI.INFORMATION120
5659 ,P_EDI_ATTRIBUTE11 => r_EDI.INFORMATION121
5660 ,P_EDI_ATTRIBUTE12 => r_EDI.INFORMATION122
5661 ,P_EDI_ATTRIBUTE13 => r_EDI.INFORMATION123
5662 ,P_EDI_ATTRIBUTE14 => r_EDI.INFORMATION124
5663 ,P_EDI_ATTRIBUTE15 => r_EDI.INFORMATION125
5664 ,P_EDI_ATTRIBUTE16 => r_EDI.INFORMATION126
5665 ,P_EDI_ATTRIBUTE17 => r_EDI.INFORMATION127
5666 ,P_EDI_ATTRIBUTE18 => r_EDI.INFORMATION128
5667 ,P_EDI_ATTRIBUTE19 => r_EDI.INFORMATION129
5668 ,P_EDI_ATTRIBUTE2 => r_EDI.INFORMATION112
5669 ,P_EDI_ATTRIBUTE20 => r_EDI.INFORMATION130
5670 ,P_EDI_ATTRIBUTE21 => r_EDI.INFORMATION131
5671 ,P_EDI_ATTRIBUTE22 => r_EDI.INFORMATION132
5672 ,P_EDI_ATTRIBUTE23 => r_EDI.INFORMATION133
5673 ,P_EDI_ATTRIBUTE24 => r_EDI.INFORMATION134
5674 ,P_EDI_ATTRIBUTE25 => r_EDI.INFORMATION135
5675 ,P_EDI_ATTRIBUTE26 => r_EDI.INFORMATION136
5676 ,P_EDI_ATTRIBUTE27 => r_EDI.INFORMATION137
5677 ,P_EDI_ATTRIBUTE28 => r_EDI.INFORMATION138
5678 ,P_EDI_ATTRIBUTE29 => r_EDI.INFORMATION139
5679 ,P_EDI_ATTRIBUTE3 => r_EDI.INFORMATION113
5680 ,P_EDI_ATTRIBUTE30 => r_EDI.INFORMATION140
5681 ,P_EDI_ATTRIBUTE4 => r_EDI.INFORMATION114
5682 ,P_EDI_ATTRIBUTE5 => r_EDI.INFORMATION115
5683 ,P_EDI_ATTRIBUTE6 => r_EDI.INFORMATION116
5684 ,P_EDI_ATTRIBUTE7 => r_EDI.INFORMATION117
5685 ,P_EDI_ATTRIBUTE8 => r_EDI.INFORMATION118
5686 ,P_EDI_ATTRIBUTE9 => r_EDI.INFORMATION119
5687 ,P_EDI_ATTRIBUTE_CATEGORY => r_EDI.INFORMATION110
5688 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
5689 ,P_ELIG_DPNT_CVRD_PLIP_ID => l_elig_dpnt_cvrd_plip_id
5690 ,P_ENRL_DET_DT_CD => r_EDI.INFORMATION11
5691 ,P_EXCLD_FLAG => r_EDI.INFORMATION12
5692 ,P_ORDR_NUM => r_EDI.INFORMATION260
5693 ,P_PLIP_ID => l_PLIP_ID
5694 --
5695 -- ****** END CHANGE LINES
5696
5697 --
5698
5699 ,P_EFFECTIVE_START_DATE => l_effective_start_date
5700 ,P_EFFECTIVE_END_DATE => l_effective_end_date
5701 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5702 );
5703 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
5704 -- Update all relevent cer records with new pk_id
5705 hr_utility.set_location('Before plsql table ',222);
5706 hr_utility.set_location('new_value id '||l_elig_dpnt_cvrd_plip_id,222);
5707 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_CVRD_PLIP_ID' ;
5708 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDI.information1 ;
5709 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_DPNT_CVRD_PLIP_ID ;
5710 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
5711 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDI_unique.table_route_id;
5712 hr_utility.set_location('After plsql table ',222);
5713 --
5714 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
5715 --
5716 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
5717 --
5718 else
5719 --
5720 -- Call Update routine for the pk_id created in prev run .
5721 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
5722 hr_utility.set_location(' BEN_ELIG_DPNT_CVRD_PLIP_F UPDATE_ELIG_DPNT_CVRD_PLIP ',30);
5723 --UPD START
5724 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
5725 --
5726 if l_update then
5727 --
5728 l_datetrack_mode := r_EDI.datetrack_mode ;
5729 --
5730 get_dt_modes(
5731 p_effective_date => l_process_date,
5732 p_effective_end_date => r_EDI.information3,
5733 p_effective_start_date => r_EDI.information2,
5734 p_dml_operation => r_EDI.dml_operation,
5735 p_datetrack_mode => l_datetrack_mode );
5736 -- p_update => l_update
5737 --
5738 l_effective_date := l_process_date;
5739 l_ELIG_DPNT_CVRD_PLIP_ID := r_EDI.information1;
5740 l_object_version_number := r_EDI.information265;
5741 --
5742 end if;
5743 --
5744 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
5745 --
5746 IF l_update OR l_dml_operation <> 'UPDATE' THEN
5747 --UPD END
5748
5749
5750 BEN_ELIG_DPNT_CVRD_PLIP_API.UPDATE_ELIG_DPNT_CVRD_PLIP(
5751 --
5752 P_VALIDATE => false
5753 ,P_EFFECTIVE_DATE => l_effective_date
5754 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5755 --
5756 ,P_EDI_ATTRIBUTE1 => r_EDI.INFORMATION111
5757 ,P_EDI_ATTRIBUTE10 => r_EDI.INFORMATION120
5758 ,P_EDI_ATTRIBUTE11 => r_EDI.INFORMATION121
5759 ,P_EDI_ATTRIBUTE12 => r_EDI.INFORMATION122
5760 ,P_EDI_ATTRIBUTE13 => r_EDI.INFORMATION123
5761 ,P_EDI_ATTRIBUTE14 => r_EDI.INFORMATION124
5762 ,P_EDI_ATTRIBUTE15 => r_EDI.INFORMATION125
5763 ,P_EDI_ATTRIBUTE16 => r_EDI.INFORMATION126
5764 ,P_EDI_ATTRIBUTE17 => r_EDI.INFORMATION127
5765 ,P_EDI_ATTRIBUTE18 => r_EDI.INFORMATION128
5766 ,P_EDI_ATTRIBUTE19 => r_EDI.INFORMATION129
5767 ,P_EDI_ATTRIBUTE2 => r_EDI.INFORMATION112
5768 ,P_EDI_ATTRIBUTE20 => r_EDI.INFORMATION130
5769 ,P_EDI_ATTRIBUTE21 => r_EDI.INFORMATION131
5770 ,P_EDI_ATTRIBUTE22 => r_EDI.INFORMATION132
5771 ,P_EDI_ATTRIBUTE23 => r_EDI.INFORMATION133
5772 ,P_EDI_ATTRIBUTE24 => r_EDI.INFORMATION134
5773 ,P_EDI_ATTRIBUTE25 => r_EDI.INFORMATION135
5774 ,P_EDI_ATTRIBUTE26 => r_EDI.INFORMATION136
5775 ,P_EDI_ATTRIBUTE27 => r_EDI.INFORMATION137
5776 ,P_EDI_ATTRIBUTE28 => r_EDI.INFORMATION138
5777 ,P_EDI_ATTRIBUTE29 => r_EDI.INFORMATION139
5778 ,P_EDI_ATTRIBUTE3 => r_EDI.INFORMATION113
5779 ,P_EDI_ATTRIBUTE30 => r_EDI.INFORMATION140
5780 ,P_EDI_ATTRIBUTE4 => r_EDI.INFORMATION114
5781 ,P_EDI_ATTRIBUTE5 => r_EDI.INFORMATION115
5782 ,P_EDI_ATTRIBUTE6 => r_EDI.INFORMATION116
5783 ,P_EDI_ATTRIBUTE7 => r_EDI.INFORMATION117
5784 ,P_EDI_ATTRIBUTE8 => r_EDI.INFORMATION118
5785 ,P_EDI_ATTRIBUTE9 => r_EDI.INFORMATION119
5786 ,P_EDI_ATTRIBUTE_CATEGORY => r_EDI.INFORMATION110
5787 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
5788 ,P_ELIG_DPNT_CVRD_PLIP_ID => l_elig_dpnt_cvrd_plip_id
5789 ,P_ENRL_DET_DT_CD => r_EDI.INFORMATION11
5790 ,P_EXCLD_FLAG => r_EDI.INFORMATION12
5791 ,P_ORDR_NUM => r_EDI.INFORMATION260
5792 ,P_PLIP_ID => l_PLIP_ID
5793 --
5794 -- ****** END CHANGE LINES
5795
5796 --
5797 ,P_EFFECTIVE_START_DATE => l_effective_start_date
5798 ,P_EFFECTIVE_END_DATE => l_effective_end_date
5799 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5800 ,P_DATETRACK_MODE => l_datetrack_mode
5801 );
5802 end if; -- l_update
5803 --
5804 end if;
5805 --
5806 -- Delete the row if it is end dated.
5807 --
5808 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
5809 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
5810 trunc(l_max_eed) = trunc(r_EDI.information3)) then
5811 --
5812 BEN_ELIG_DPNT_CVRD_PLIP_API.delete_ELIG_DPNT_CVRD_PLIP(
5813 --
5814 p_validate => false
5815 ,p_elig_dpnt_cvrd_plip_id => l_elig_dpnt_cvrd_plip_id
5816 ,p_effective_start_date => l_effective_start_date
5817 ,p_effective_end_date => l_effective_end_date
5818 ,p_object_version_number => l_object_version_number
5819 ,p_effective_date => l_max_eed
5820 ,p_datetrack_mode => hr_api.g_delete
5821 --
5822 );
5823 --
5824 end if;
5825 --
5826 l_prev_pk_id := l_current_pk_id ;
5827 --
5828 end if;
5829 --
5830 end if;
5831 --
5832 end loop;
5833 --
5834 exception when others then
5835 --
5836 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EDI',r_EDI.information5 ) ;
5837 --
5838 end create_EDI_rows;
5839
5840 --
5841 ---------------------------------------------------------------
5842 ----------------------< create_EDP_rows >-----------------------
5843 ---------------------------------------------------------------
5844 --
5845 procedure create_EDP_rows
5846 (
5847 p_validate in number default 0
5848 ,p_copy_entity_txn_id in number
5849 ,p_effective_date in date
5850 ,p_prefix_suffix_text in varchar2 default null
5851 ,p_reuse_object_flag in varchar2 default null
5852 ,p_target_business_group_id in varchar2 default null
5853 ,p_prefix_suffix_cd in varchar2 default null
5854 ) is
5855 --
5856 l_ELIGY_PRFL_ID number;
5857 l_PL_ID number;
5858 l_ORDR_NUM number ;
5859 cursor c_unique_EDP(l_table_alias varchar2) is
5860 select distinct cpe.information1,
5861 cpe.information2,
5862 cpe.information3,
5863 cpe.table_route_id
5864 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
5865 pqh_table_route tr
5866 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5867 and cpe.table_route_id = tr.table_route_id
5868 -- and tr.where_clause = l_BEN_ELIG_DPNT_CVRD_OTHR_PL_F
5869 and tr.table_alias = l_table_alias
5870 and cpe.number_of_copies = 1 -- ADDITION
5871 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
5872 order by information1, information2; --added for bug: 5151945
5873 --
5874 --
5875 cursor c_EDP_min_max_dates(c_table_route_id number,
5876 c_information1 number) is
5877 select
5878 min(cpe.information2) min_esd,
5879 max(cpe.information3) min_eed
5880 from ben_copy_entity_results cpe
5881 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5882 and cpe.table_route_id = c_table_route_id
5883 and cpe.information1 = c_information1 ;
5884 --
5885 cursor c_EDP(c_table_route_id number,
5886 c_information1 number,
5887 c_information2 date,
5888 c_information3 date) is
5889 select
5890 cpe.*
5891 from ben_copy_entity_results cpe
5892 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5893 and cpe.table_route_id = c_table_route_id
5894 and cpe.information1 = c_information1
5895 and cpe.information2 = c_information2
5896 and cpe.information3 = c_information3
5897 and rownum = 1 ;
5898 -- Date Track target record
5899 cursor c_find_EDP_in_target(
5900 c_effective_start_date date,
5901 c_effective_end_date date,
5902 c_business_group_id number,
5903 c_new_pk_id number) is
5904 select
5905 EDP.elig_dpnt_cvrd_othr_pl_id new_value
5906 from BEN_ELIG_DPNT_CVRD_OTHR_PL_F EDP
5907 where
5908 EDP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
5909 EDP.PL_ID = l_PL_ID and
5910 EDP.ORDR_NUM = l_ORDR_NUM and
5911 EDP.business_group_id = c_business_group_id
5912 and EDP.elig_dpnt_cvrd_othr_pl_id <> c_new_pk_id
5913 and c_effective_start_date between effective_start_date
5914 and effective_end_date ;
5915 --END TEMPIK
5916 /*TEMPIK
5917 and exists ( select null
5918 from BEN_ELIG_DPNT_CVRD_OTHR_PL_F EDP1
5919 where
5920 EDP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
5921 EDP1.PL_ID = l_PL_ID and
5922 EDP1.ORDR_NUM = l_ORDR_NUM and
5923 EDP1.business_group_id = c_business_group_id
5924 and EDP1.effective_start_date <= c_effective_start_date )
5925 and exists ( select null
5926 from BEN_ELIG_DPNT_CVRD_OTHR_PL_F EDP2
5927 where
5928 EDP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
5929 EDP2.PL_ID = l_PL_ID and
5930 EDP2.ORDR_NUM = l_ORDR_NUM and
5931 EDP2.business_group_id = c_business_group_id
5932 and EDP2.effective_end_date >= c_effective_end_date )
5933 ;
5934 TEMPIK */
5935 --TEMPIK
5936 l_dt_rec_found boolean ;
5937 --END TEMPIK
5938 --
5939
5940 --UPD START
5941 --
5942 l_update boolean := false ;
5943 l_datetrack_mode varchar2(80) := hr_api.g_update;
5944 l_process_date date;
5945 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
5946 --
5947 --UPD END
5948 l_current_pk_id number := null ;
5949
5950 l_prev_pk_id number := null ;
5951 l_first_rec boolean := true ;
5952 r_EDP c_EDP%rowtype;
5953 l_elig_dpnt_cvrd_othr_pl_id number ;
5954 l_object_version_number number ;
5955 l_effective_start_date date ;
5956 l_effective_end_date date ;
5957 l_prefix pqh_copy_entity_attribs.information1%type := null;
5958 l_suffix pqh_copy_entity_attribs.information1%type := null;
5959 l_new_value number(15);
5960 l_object_found_in_target boolean := false ;
5961 l_min_esd date;
5962 l_max_eed date;
5963 l_effective_date date;
5964 --
5965 begin
5966 -- Initialization
5967 l_object_found_in_target := false ;
5968 -- End Initialization
5969 -- Derive the prefix - sufix
5970 if p_prefix_suffix_cd = 'PREFIX' then
5971 l_prefix := p_prefix_suffix_text ;
5972 elsif p_prefix_suffix_cd = 'SUFFIX' then
5973 l_suffix := p_prefix_suffix_text ;
5974 else
5975 l_prefix := null ;
5976 l_suffix := null ;
5977 end if ;
5978 -- End Prefix Sufix derivation
5979 for r_EDP_unique in c_unique_EDP('EDP') loop
5980
5981 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
5982 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
5983 r_EDP_unique.information3 >=
5984 ben_pd_copy_to_ben_one.g_copy_effective_date)
5985 ) then
5986 --
5987 hr_utility.set_location(' r_EDP_unique.table_route_id '||r_EDP_unique.table_route_id,10);
5988 hr_utility.set_location(' r_EDP_unique.information1 '||r_EDP_unique.information1,10);
5989 hr_utility.set_location( 'r_EDP_unique.information2 '||r_EDP_unique.information2,10);
5990 hr_utility.set_location( 'r_EDP_unique.information3 '||r_EDP_unique.information3,10);
5991 -- If reuse objects flag is 'Y' then check for the object in the target business group
5992 -- if found insert the record into PLSql table and exit the loop else try create the
5993 -- object in the target business group
5994 --
5995 l_object_found_in_target := false ;
5996 --UPD START
5997 l_update := false;
5998 l_process_date := p_effective_date;
5999 l_dml_operation:= r_EDP_unique.dml_operation ;
6000 --
6001 /**********************moved from below **********************/
6002 open c_EDP(r_EDP_unique.table_route_id,
6003 r_EDP_unique.information1,
6004 r_EDP_unique.information2,
6005 r_EDP_unique.information3 ) ;
6006 --
6007 fetch c_EDP into r_EDP ;
6008 --
6009 close c_EDP ;
6010 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDP.information263,l_dml_operation);
6011 l_ORDR_NUM := r_EDP.INFORMATION260 ; -- IK Added this
6012
6013 -- Only For Use by Create Wizard - Same Business Group
6014 l_PL_ID := NVL(get_fk('PL_ID', r_EDP.information261,l_dml_operation),
6015 r_EDP.information261);
6016 /**********************************************************/
6017
6018 if l_dml_operation = 'UPDATE' then
6019 --
6020 l_object_found_in_target := TRUE;
6021 --
6022 if l_process_date between r_EDP_unique.information2 and r_EDP_unique.information3 then
6023 l_update := true;
6024 if r_EDP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
6025 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DPNT_CVRD_OTHR_PL_ID' then
6026 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_CVRD_OTHR_PL_ID' ;
6027 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDP_unique.information1 ;
6028 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EDP_unique.information1 ;
6029 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
6030 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDP_unique.table_route_id;
6031 --
6032 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
6033 --
6034 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
6035 --
6036 -- log_data('EDP',l_new_value,l_prefix || r_EDP_unique.name|| l_suffix,'REUSED');
6037 --
6038 end if ;
6039 hr_utility.set_location( 'found record for update',10);
6040 --
6041 else
6042 --
6043 l_update := false;
6044 --
6045 end if;
6046 else
6047 --
6048 --UPD END
6049 l_min_esd := null ;
6050 l_max_eed := null ;
6051 open c_EDP_min_max_dates(r_EDP_unique.table_route_id, r_EDP_unique.information1 ) ;
6052 fetch c_EDP_min_max_dates into l_min_esd,l_max_eed ;
6053 --
6054
6055 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6056 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
6057 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
6058 end if;
6059 l_min_esd := greatest(l_min_esd,r_EDP_unique.information2);
6060 /**********************moved up from here **********************
6061 open c_EDP(r_EDP_unique.table_route_id,
6062 r_EDP_unique.information1,
6063 r_EDP_unique.information2,
6064 r_EDP_unique.information3 ) ;
6065 --
6066 fetch c_EDP into r_EDP ;
6067 --
6068 close c_EDP ;
6069 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDP.information263,l_dml_operation);
6070 l_ORDR_NUM := r_EDP.INFORMATION260 ; -- IK Added this
6071
6072 -- Only For Use by Create Wizard - Same Business Group
6073 l_PL_ID := NVL(get_fk('PL_ID', r_EDP.information261,l_dml_operation),
6074 r_EDP.information261);
6075
6076 **********************************************************/
6077
6078
6079 if p_reuse_object_flag = 'Y' then
6080 if c_EDP_min_max_dates%found then
6081 -- cursor to find the object
6082 open c_find_EDP_in_target( l_min_esd,l_max_eed,
6083 p_target_business_group_id, nvl(l_elig_dpnt_cvrd_othr_pl_id, -999) ) ;
6084 fetch c_find_EDP_in_target into l_new_value ;
6085 if c_find_EDP_in_target%found then
6086 --
6087 --TEMPIK
6088 l_dt_rec_found := dt_api.check_min_max_dates
6089 (p_base_table_name => 'BEN_ELIG_DPNT_CVRD_OTHR_PL_F',
6090 p_base_key_column => 'ELIG_DPNT_CVRD_OTHR_PL_ID',
6091 p_base_key_value => l_new_value,
6092 p_from_date => l_min_esd,
6093 p_to_date => l_max_eed );
6094 if l_dt_rec_found THEN
6095 --END TEMPIK
6096 if r_EDP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
6097 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DPNT_CVRD_OTHR_PL_ID' then
6098 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_CVRD_OTHR_PL_ID' ;
6099 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDP_unique.information1 ;
6100 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
6101 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
6102 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDP_unique.table_route_id;
6103 --
6104 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
6105 --
6106 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
6107 end if ;
6108 --
6109 l_object_found_in_target := true ;
6110 --TEMPIK
6111 end if; -- l_dt_rec_found
6112 --END TEMPIK
6113 end if;
6114 close c_find_EDP_in_target ;
6115 --
6116 end if;
6117 end if ;
6118 --
6119 close c_EDP_min_max_dates ;
6120 end if; --if p_dml_operation
6121 --
6122 if not l_object_found_in_target OR l_update then
6123
6124 --
6125 l_current_pk_id := r_EDP.information1;
6126 --
6127 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
6128 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
6129 --
6130 if l_current_pk_id = l_prev_pk_id then
6131 --
6132 l_first_rec := false ;
6133 --
6134 else
6135 --
6136 l_first_rec := true ;
6137 --
6138 end if ;
6139 --
6140
6141 l_effective_date := r_EDP.information2;
6142 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6143 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
6144 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
6145 end if;
6146
6147 if l_first_rec and not l_update then
6148 -- Call Create routine.
6149 hr_utility.set_location(' BEN_ELIG_DPNT_CVRD_OTHR_PL_F CREATE_ELIG_DPNT_CVD_OTHR_PL ',20);
6150 BEN_ELIG_DPNT_CVD_OTHR_PL_API.CREATE_ELIG_DPNT_CVD_OTHR_PL(
6151 --
6152 P_VALIDATE => false
6153 ,P_EFFECTIVE_DATE => l_effective_date
6154 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
6155 --
6156 ,P_CVG_DET_DT_CD => r_EDP.INFORMATION12
6157 ,P_EDP_ATTRIBUTE1 => r_EDP.INFORMATION111
6158 ,P_EDP_ATTRIBUTE10 => r_EDP.INFORMATION120
6159 ,P_EDP_ATTRIBUTE11 => r_EDP.INFORMATION121
6160 ,P_EDP_ATTRIBUTE12 => r_EDP.INFORMATION122
6161 ,P_EDP_ATTRIBUTE13 => r_EDP.INFORMATION123
6162 ,P_EDP_ATTRIBUTE14 => r_EDP.INFORMATION124
6163 ,P_EDP_ATTRIBUTE15 => r_EDP.INFORMATION125
6164 ,P_EDP_ATTRIBUTE16 => r_EDP.INFORMATION126
6165 ,P_EDP_ATTRIBUTE17 => r_EDP.INFORMATION127
6166 ,P_EDP_ATTRIBUTE18 => r_EDP.INFORMATION128
6167 ,P_EDP_ATTRIBUTE19 => r_EDP.INFORMATION129
6168 ,P_EDP_ATTRIBUTE2 => r_EDP.INFORMATION112
6169 ,P_EDP_ATTRIBUTE20 => r_EDP.INFORMATION130
6170 ,P_EDP_ATTRIBUTE21 => r_EDP.INFORMATION131
6171 ,P_EDP_ATTRIBUTE22 => r_EDP.INFORMATION132
6172 ,P_EDP_ATTRIBUTE23 => r_EDP.INFORMATION133
6173 ,P_EDP_ATTRIBUTE24 => r_EDP.INFORMATION134
6174 ,P_EDP_ATTRIBUTE25 => r_EDP.INFORMATION135
6175 ,P_EDP_ATTRIBUTE26 => r_EDP.INFORMATION136
6176 ,P_EDP_ATTRIBUTE27 => r_EDP.INFORMATION137
6177 ,P_EDP_ATTRIBUTE28 => r_EDP.INFORMATION138
6178 ,P_EDP_ATTRIBUTE29 => r_EDP.INFORMATION139
6179 ,P_EDP_ATTRIBUTE3 => r_EDP.INFORMATION113
6180 ,P_EDP_ATTRIBUTE30 => r_EDP.INFORMATION140
6181 ,P_EDP_ATTRIBUTE4 => r_EDP.INFORMATION114
6182 ,P_EDP_ATTRIBUTE5 => r_EDP.INFORMATION115
6183 ,P_EDP_ATTRIBUTE6 => r_EDP.INFORMATION116
6184 ,P_EDP_ATTRIBUTE7 => r_EDP.INFORMATION117
6185 ,P_EDP_ATTRIBUTE8 => r_EDP.INFORMATION118
6186 ,P_EDP_ATTRIBUTE9 => r_EDP.INFORMATION119
6187 ,P_EDP_ATTRIBUTE_CATEGORY => r_EDP.INFORMATION110
6188 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
6189 ,P_ELIG_DPNT_CVRD_OTHR_PL_ID => l_elig_dpnt_cvrd_othr_pl_id
6190 ,P_EXCLD_FLAG => r_EDP.INFORMATION11
6191 ,P_ORDR_NUM => r_EDP.INFORMATION260
6192 ,P_PL_ID => l_PL_ID
6193 --
6194 -- ****** END CHANGE LINES
6195
6196 --
6197
6198 ,P_EFFECTIVE_START_DATE => l_effective_start_date
6199 ,P_EFFECTIVE_END_DATE => l_effective_end_date
6200 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
6201 );
6202 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
6203 -- Update all relevent cer records with new pk_id
6204 hr_utility.set_location('Before plsql table ',222);
6205 hr_utility.set_location('new_value id '||l_elig_dpnt_cvrd_othr_pl_id,222);
6206 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_CVRD_OTHR_PL_ID' ;
6207 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDP.information1 ;
6208 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_DPNT_CVRD_OTHR_PL_ID ;
6209 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
6210 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDP_unique.table_route_id;
6211 hr_utility.set_location('After plsql table ',222);
6212 --
6213 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
6214 --
6215 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
6216 --
6217 else
6218 --
6219 -- Call Update routine for the pk_id created in prev run .
6220 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
6221 hr_utility.set_location(' BEN_ELIG_DPNT_CVRD_OTHR_PL_F UPDATE_ELIG_DPNT_CVD_OTHR_PL ',30);
6222 --UPD START
6223 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
6224 --
6225 if l_update then
6226 --
6227 l_datetrack_mode := r_EDP.datetrack_mode ;
6228 --
6229 get_dt_modes(
6230 p_effective_date => l_process_date,
6231 p_effective_end_date => r_EDP.information3,
6232 p_effective_start_date => r_EDP.information2,
6233 p_dml_operation => r_EDP.dml_operation,
6234 p_datetrack_mode => l_datetrack_mode );
6235 -- p_update => l_update
6236 --
6237 l_effective_date := l_process_date;
6238 l_ELIG_DPNT_CVRD_OTHR_PL_ID := r_EDP.information1;
6239 l_object_version_number := r_EDP.information265;
6240 --
6241 end if;
6242 --
6243 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
6244 --
6245 IF l_update OR l_dml_operation <> 'UPDATE' THEN
6246 --UPD END
6247
6248
6249 BEN_ELIG_DPNT_CVD_OTHR_PL_API.UPDATE_ELIG_DPNT_CVD_OTHR_PL(
6250 --
6251 P_VALIDATE => false
6252 ,P_EFFECTIVE_DATE => l_effective_date
6253 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
6254 --
6255 ,P_CVG_DET_DT_CD => r_EDP.INFORMATION12
6256 ,P_EDP_ATTRIBUTE1 => r_EDP.INFORMATION111
6257 ,P_EDP_ATTRIBUTE10 => r_EDP.INFORMATION120
6258 ,P_EDP_ATTRIBUTE11 => r_EDP.INFORMATION121
6259 ,P_EDP_ATTRIBUTE12 => r_EDP.INFORMATION122
6260 ,P_EDP_ATTRIBUTE13 => r_EDP.INFORMATION123
6261 ,P_EDP_ATTRIBUTE14 => r_EDP.INFORMATION124
6262 ,P_EDP_ATTRIBUTE15 => r_EDP.INFORMATION125
6263 ,P_EDP_ATTRIBUTE16 => r_EDP.INFORMATION126
6264 ,P_EDP_ATTRIBUTE17 => r_EDP.INFORMATION127
6265 ,P_EDP_ATTRIBUTE18 => r_EDP.INFORMATION128
6266 ,P_EDP_ATTRIBUTE19 => r_EDP.INFORMATION129
6267 ,P_EDP_ATTRIBUTE2 => r_EDP.INFORMATION112
6268 ,P_EDP_ATTRIBUTE20 => r_EDP.INFORMATION130
6269 ,P_EDP_ATTRIBUTE21 => r_EDP.INFORMATION131
6270 ,P_EDP_ATTRIBUTE22 => r_EDP.INFORMATION132
6271 ,P_EDP_ATTRIBUTE23 => r_EDP.INFORMATION133
6272 ,P_EDP_ATTRIBUTE24 => r_EDP.INFORMATION134
6273 ,P_EDP_ATTRIBUTE25 => r_EDP.INFORMATION135
6274 ,P_EDP_ATTRIBUTE26 => r_EDP.INFORMATION136
6275 ,P_EDP_ATTRIBUTE27 => r_EDP.INFORMATION137
6276 ,P_EDP_ATTRIBUTE28 => r_EDP.INFORMATION138
6277 ,P_EDP_ATTRIBUTE29 => r_EDP.INFORMATION139
6278 ,P_EDP_ATTRIBUTE3 => r_EDP.INFORMATION113
6279 ,P_EDP_ATTRIBUTE30 => r_EDP.INFORMATION140
6280 ,P_EDP_ATTRIBUTE4 => r_EDP.INFORMATION114
6281 ,P_EDP_ATTRIBUTE5 => r_EDP.INFORMATION115
6282 ,P_EDP_ATTRIBUTE6 => r_EDP.INFORMATION116
6283 ,P_EDP_ATTRIBUTE7 => r_EDP.INFORMATION117
6284 ,P_EDP_ATTRIBUTE8 => r_EDP.INFORMATION118
6285 ,P_EDP_ATTRIBUTE9 => r_EDP.INFORMATION119
6286 ,P_EDP_ATTRIBUTE_CATEGORY => r_EDP.INFORMATION110
6287 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
6288 ,P_ELIG_DPNT_CVRD_OTHR_PL_ID => l_elig_dpnt_cvrd_othr_pl_id
6289 ,P_EXCLD_FLAG => r_EDP.INFORMATION11
6290 ,P_ORDR_NUM => r_EDP.INFORMATION260
6291 ,P_PL_ID => l_PL_ID
6292 --
6293 -- ****** END CHANGE LINES
6294
6295 --
6296 ,P_EFFECTIVE_START_DATE => l_effective_start_date
6297 ,P_EFFECTIVE_END_DATE => l_effective_end_date
6298 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
6299 ,P_DATETRACK_MODE => l_datetrack_mode
6300 );
6301 end if; -- l_update
6302 --
6303 end if;
6304 --
6305 -- Delete the row if it is end dated.
6306 --
6307 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
6308 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
6309 trunc(l_max_eed) = trunc(r_EDP.information3)) then
6310 --
6311 BEN_ELIG_DPNT_CVD_OTHR_PL_API.delete_ELIG_DPNT_CVD_OTHR_PL(
6312 --
6313 p_validate => false
6314 ,p_elig_dpnt_cvrd_othr_pl_id => l_elig_dpnt_cvrd_othr_pl_id
6315 ,p_effective_start_date => l_effective_start_date
6316 ,p_effective_end_date => l_effective_end_date
6317 ,p_object_version_number => l_object_version_number
6318 ,p_effective_date => l_max_eed
6319 ,p_datetrack_mode => hr_api.g_delete
6320 --
6321 );
6322 --
6323 end if;
6324 --
6325 l_prev_pk_id := l_current_pk_id ;
6326 --
6327 end if;
6328 --
6329 end if;
6330 --
6331 end loop;
6332 --
6333 exception when others then
6334 --
6335 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EDP',r_EDP.information5 ) ;
6336 --
6337 end create_EDP_rows;
6338
6339 --
6340 ---------------------------------------------------------------
6341 ----------------------< create_EDT_rows >-----------------------
6342 ---------------------------------------------------------------
6343 --
6344 procedure create_EDT_rows
6345 (
6346 p_validate in number default 0
6347 ,p_copy_entity_txn_id in number
6348 ,p_effective_date in date
6349 ,p_prefix_suffix_text in varchar2 default null
6350 ,p_reuse_object_flag in varchar2 default null
6351 ,p_target_business_group_id in varchar2 default null
6352 ,p_prefix_suffix_cd in varchar2 default null
6353 ) is
6354 --
6355 l_ELIGY_PRFL_ID number;
6356 l_PTIP_ID number;
6357 l_ORDR_NUM number ;
6358 cursor c_unique_EDT(l_table_alias varchar2) is
6359 select distinct cpe.information1,
6360 cpe.information2,
6361 cpe.information3,
6362 cpe.table_route_id
6363 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
6364 pqh_table_route tr
6365 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6366 and cpe.table_route_id = tr.table_route_id
6367 -- and tr.where_clause = l_BEN_ELG_DPNT_CVR_OTR_PTIP_F
6368 and tr.table_alias = l_table_alias
6369 and cpe.number_of_copies = 1 -- ADDITION
6370 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
6371 order by information1, information2; --added for bug: 5151945
6372 --
6373 --
6374 cursor c_EDT_min_max_dates(c_table_route_id number,
6375 c_information1 number) is
6376 select
6377 min(cpe.information2) min_esd,
6378 max(cpe.information3) min_eed
6379 from ben_copy_entity_results cpe
6380 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6381 and cpe.table_route_id = c_table_route_id
6382 and cpe.information1 = c_information1 ;
6383 --
6384 cursor c_EDT(c_table_route_id number,
6385 c_information1 number,
6386 c_information2 date,
6387 c_information3 date) is
6388 select
6389 cpe.*
6390 from ben_copy_entity_results cpe
6391 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6392 and cpe.table_route_id = c_table_route_id
6393 and cpe.information1 = c_information1
6394 and cpe.information2 = c_information2
6395 and cpe.information3 = c_information3
6396 and rownum = 1 ;
6397 -- Date Track target record
6398 cursor c_find_EDT_in_target(
6399 c_effective_start_date date,
6400 c_effective_end_date date,
6401 c_business_group_id number,
6402 c_new_pk_id number) is
6403 select
6404 EDT.elig_dpnt_cvrd_othr_ptip_id new_value
6405 from BEN_ELIG_DPNT_CVRD_OTHR_PTIP_F EDT
6406 where
6407 EDT.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
6408 EDT.PTIP_ID = l_PTIP_ID and
6409 EDT.ORDR_NUM = l_ORDR_NUM and
6410 EDT.business_group_id = c_business_group_id
6411 and EDT.elig_dpnt_cvrd_othr_ptip_id <> c_new_pk_id
6412 and c_effective_start_date between effective_start_date
6413 and effective_end_date ;
6414 --END TEMPIK
6415 /*TEMPIK
6416 and exists ( select null
6417 from BEN_ELIG_DPNT_CVRD_OTHR_PTIP_F EDT1
6418 where
6419 EDT1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
6420 EDT1.PTIP_ID = l_PTIP_ID and
6421 EDT1.ORDR_NUM = l_ORDR_NUM and
6422 EDT1.business_group_id = c_business_group_id
6423 and EDT1.effective_start_date <= c_effective_start_date )
6424 and exists ( select null
6425 from BEN_ELIG_DPNT_CVRD_OTHR_PTIP_F EDT2
6426 where
6427 EDT2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
6428 EDT2.PTIP_ID = l_PTIP_ID and
6429 EDT2.ORDR_NUM = l_ORDR_NUM and
6430 EDT2.business_group_id = c_business_group_id
6431 and EDT2.effective_end_date >= c_effective_end_date )
6432 ;
6433 TEMPIK */
6434 --TEMPIK
6435 l_dt_rec_found boolean ;
6436 --END TEMPIK
6437 --
6438
6439 --UPD START
6440 --
6441 l_update boolean := false ;
6442 l_datetrack_mode varchar2(80) := hr_api.g_update;
6443 l_process_date date;
6444 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
6445 --
6446 --UPD END
6447 l_current_pk_id number := null ;
6448
6449 l_prev_pk_id number := null ;
6450 l_first_rec boolean := true ;
6451 r_EDT c_EDT%rowtype;
6452 l_elig_dpnt_cvrd_othr_ptip_id number ;
6453 l_object_version_number number ;
6454 l_effective_start_date date ;
6455 l_effective_end_date date ;
6456 l_prefix pqh_copy_entity_attribs.information1%type := null;
6457 l_suffix pqh_copy_entity_attribs.information1%type := null;
6458 l_new_value number(15);
6459 l_object_found_in_target boolean := false ;
6460 l_min_esd date;
6461 l_max_eed date;
6462 l_effective_date date;
6463 --
6464 begin
6465 -- Initialization
6466 l_object_found_in_target := false ;
6467 -- End Initialization
6468 -- Derive the prefix - sufix
6469 if p_prefix_suffix_cd = 'PREFIX' then
6470 l_prefix := p_prefix_suffix_text ;
6471 elsif p_prefix_suffix_cd = 'SUFFIX' then
6472 l_suffix := p_prefix_suffix_text ;
6473 else
6474 l_prefix := null ;
6475 l_suffix := null ;
6476 end if ;
6477 -- End Prefix Sufix derivation
6478 for r_EDT_unique in c_unique_EDT('EDT') loop
6479
6480 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
6481 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6482 r_EDT_unique.information3 >=
6483 ben_pd_copy_to_ben_one.g_copy_effective_date)
6484 ) then
6485 --
6486 hr_utility.set_location(' r_EDT_unique.table_route_id '||r_EDT_unique.table_route_id,10);
6487 hr_utility.set_location(' r_EDT_unique.information1 '||r_EDT_unique.information1,10);
6488 hr_utility.set_location( 'r_EDT_unique.information2 '||r_EDT_unique.information2,10);
6489 hr_utility.set_location( 'r_EDT_unique.information3 '||r_EDT_unique.information3,10);
6490 -- If reuse objects flag is 'Y' then check for the object in the target business group
6491 -- if found insert the record into PLSql table and exit the loop else try create the
6492 -- object in the target business group
6493 --
6494 l_object_found_in_target := false ;
6495 --UPD START
6496 l_update := false;
6497 l_process_date := p_effective_date;
6498 l_dml_operation:= r_EDT_unique.dml_operation ;
6499 /**********************moved from below **********************/
6500 open c_EDT(r_EDT_unique.table_route_id,
6501 r_EDT_unique.information1,
6502 r_EDT_unique.information2,
6503 r_EDT_unique.information3 ) ;
6504 --
6505 fetch c_EDT into r_EDT ;
6506 --
6507 close c_EDT ;
6508 --
6509 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDT.INFORMATION263,l_dml_operation);
6510 l_ORDR_NUM := r_EDT.INFORMATION261 ; -- IK Added
6511
6512 -- Only For Use by Create Wizard - Same Business Group
6513 l_PTIP_ID := NVL(get_fk('PTIP_ID', r_EDT.INFORMATION259,l_dml_operation),
6514 r_EDT.INFORMATION259);
6515 /**********************************************************/
6516 --
6517 if l_dml_operation = 'UPDATE' then
6518 --
6519 l_object_found_in_target := TRUE;
6520 --
6521 if l_process_date between r_EDT_unique.information2 and r_EDT_unique.information3 then
6522 l_update := true;
6523 if r_EDT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
6524 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DPNT_CVRD_OTHR_PTIP_ID' then
6525 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_CVRD_OTHR_PTIP_ID' ;
6526 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDT_unique.information1 ;
6527 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EDT_unique.information1 ;
6528 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
6529 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDT_unique.table_route_id;
6530 --
6531 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
6532 --
6533 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
6534 --
6535 -- log_data('EDT',l_new_value,l_prefix || r_EDT_unique.name|| l_suffix,'REUSED');
6536 --
6537 end if ;
6538 hr_utility.set_location( 'found record for update',10);
6539 --
6540 else
6541 --
6542 l_update := false;
6543 --
6544 end if;
6545 else
6546 --
6547 --UPD END
6548 l_min_esd := null ;
6549 l_max_eed := null ;
6550 open c_EDT_min_max_dates(r_EDT_unique.table_route_id, r_EDT_unique.information1 ) ;
6551 fetch c_EDT_min_max_dates into l_min_esd,l_max_eed ;
6552 --
6553
6554 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6555 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
6556 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
6557 end if;
6558 l_min_esd := greatest(l_min_esd,r_EDT_unique.information2);
6559 /**********************moved up from here **********************
6560 open c_EDT(r_EDT_unique.table_route_id,
6561 r_EDT_unique.information1,
6562 r_EDT_unique.information2,
6563 r_EDT_unique.information3 ) ;
6564 --
6565 fetch c_EDT into r_EDT ;
6566 --
6567 close c_EDT ;
6568 --
6569 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDT.INFORMATION263,l_dml_operation);
6570 l_ORDR_NUM := r_EDT.INFORMATION261 ; -- IK Added
6571
6572 -- Only For Use by Create Wizard - Same Business Group
6573 l_PTIP_ID := NVL(get_fk('PTIP_ID', r_EDT.INFORMATION259,l_dml_operation),
6574 r_EDT.INFORMATION259);
6575 **********************************************************/
6576
6577 if p_reuse_object_flag = 'Y' then
6578 if c_EDT_min_max_dates%found then
6579 -- cursor to find the object
6580 open c_find_EDT_in_target( l_min_esd,l_max_eed,
6581 p_target_business_group_id, nvl(l_elig_dpnt_cvrd_othr_ptip_id, -999) ) ;
6582 fetch c_find_EDT_in_target into l_new_value ;
6583 if c_find_EDT_in_target%found then
6584 --
6585 --TEMPIK
6586 l_dt_rec_found := dt_api.check_min_max_dates
6587 (p_base_table_name => 'BEN_ELIG_DPNT_CVRD_OTHR_PTIP_F',
6588 p_base_key_column => 'ELIG_DPNT_CVRD_OTHR_PTIP_ID',
6589 p_base_key_value => l_new_value,
6590 p_from_date => l_min_esd,
6591 p_to_date => l_max_eed );
6592 if l_dt_rec_found THEN
6593 --END TEMPIK
6594 if r_EDT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
6595 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DPNT_CVRD_OTHR_PTIP_ID' then
6596 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_CVRD_OTHR_PTIP_ID' ;
6597 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDT_unique.information1 ;
6598 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
6599 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
6600 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDT_unique.table_route_id;
6601 --
6602 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
6603 --
6604 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
6605 end if ;
6606 --
6607 l_object_found_in_target := true ;
6608 --TEMPIK
6609 end if; -- l_dt_rec_found
6610 --END TEMPIK
6611 end if;
6612 close c_find_EDT_in_target ;
6613 --
6614 end if;
6615 end if ;
6616 --
6617 close c_EDT_min_max_dates ;
6618 end if; --if p_dml_operation
6619 --
6620 if not l_object_found_in_target OR l_update then
6621
6622 --
6623 l_current_pk_id := r_EDT.information1;
6624 --
6625 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
6626 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
6627 --
6628 if l_current_pk_id = l_prev_pk_id then
6629 --
6630 l_first_rec := false ;
6631 --
6632 else
6633 --
6634 l_first_rec := true ;
6635 --
6636 end if ;
6637 --
6638
6639 l_effective_date := r_EDT.information2;
6640 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6641 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
6642 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
6643 end if;
6644
6645 if l_first_rec and not l_update then
6646 -- Call Create routine.
6647 hr_utility.set_location(' BEN_ELIG_DPNT_CVRD_OTHR_PTIP_F CREATE_ELIG_DPNT_CVRD_O_PTIP ',20);
6648 BEN_ELIG_DPNT_CVRD_O_PTIP_API.CREATE_ELIG_DPNT_CVRD_O_PTIP(
6649 --
6650 P_VALIDATE => false
6651 ,P_EFFECTIVE_DATE => l_effective_date
6652 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
6653 --
6654 ,P_EDT_ATTRIBUTE1 => r_EDT.INFORMATION111
6655 ,P_EDT_ATTRIBUTE10 => r_EDT.INFORMATION120
6656 ,P_EDT_ATTRIBUTE11 => r_EDT.INFORMATION121
6657 ,P_EDT_ATTRIBUTE12 => r_EDT.INFORMATION122
6658 ,P_EDT_ATTRIBUTE13 => r_EDT.INFORMATION123
6659 ,P_EDT_ATTRIBUTE14 => r_EDT.INFORMATION124
6660 ,P_EDT_ATTRIBUTE15 => r_EDT.INFORMATION125
6661 ,P_EDT_ATTRIBUTE16 => r_EDT.INFORMATION126
6662 ,P_EDT_ATTRIBUTE17 => r_EDT.INFORMATION127
6663 ,P_EDT_ATTRIBUTE18 => r_EDT.INFORMATION128
6664 ,P_EDT_ATTRIBUTE19 => r_EDT.INFORMATION129
6665 ,P_EDT_ATTRIBUTE2 => r_EDT.INFORMATION112
6666 ,P_EDT_ATTRIBUTE20 => r_EDT.INFORMATION130
6667 ,P_EDT_ATTRIBUTE21 => r_EDT.INFORMATION131
6668 ,P_EDT_ATTRIBUTE22 => r_EDT.INFORMATION132
6669 ,P_EDT_ATTRIBUTE23 => r_EDT.INFORMATION133
6670 ,P_EDT_ATTRIBUTE24 => r_EDT.INFORMATION134
6671 ,P_EDT_ATTRIBUTE25 => r_EDT.INFORMATION135
6672 ,P_EDT_ATTRIBUTE26 => r_EDT.INFORMATION136
6673 ,P_EDT_ATTRIBUTE27 => r_EDT.INFORMATION137
6674 ,P_EDT_ATTRIBUTE28 => r_EDT.INFORMATION138
6675 ,P_EDT_ATTRIBUTE29 => r_EDT.INFORMATION139
6676 ,P_EDT_ATTRIBUTE3 => r_EDT.INFORMATION113
6677 ,P_EDT_ATTRIBUTE30 => r_EDT.INFORMATION140
6678 ,P_EDT_ATTRIBUTE4 => r_EDT.INFORMATION114
6679 ,P_EDT_ATTRIBUTE5 => r_EDT.INFORMATION115
6680 ,P_EDT_ATTRIBUTE6 => r_EDT.INFORMATION116
6681 ,P_EDT_ATTRIBUTE7 => r_EDT.INFORMATION117
6682 ,P_EDT_ATTRIBUTE8 => r_EDT.INFORMATION118
6683 ,P_EDT_ATTRIBUTE9 => r_EDT.INFORMATION119
6684 ,P_EDT_ATTRIBUTE_CATEGORY => r_EDT.INFORMATION110
6685 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
6686 ,P_ELIG_DPNT_CVRD_OTHR_PTIP_ID => l_elig_dpnt_cvrd_othr_ptip_id
6687 ,P_ENRL_DET_DT_CD => r_EDT.INFORMATION13
6688 ,P_EXCLD_FLAG => r_EDT.INFORMATION11
6689 ,P_ONLY_PLS_SUBJ_COBRA_FLAG => r_EDT.INFORMATION12
6690 ,P_ORDR_NUM => r_EDT.INFORMATION261
6691 ,P_PTIP_ID => l_PTIP_ID
6692 --
6693 -- ****** END CHANGE LINES
6694
6695 --
6696
6697 ,P_EFFECTIVE_START_DATE => l_effective_start_date
6698 ,P_EFFECTIVE_END_DATE => l_effective_end_date
6699 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
6700 );
6701 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
6702 -- Update all relevent cer records with new pk_id
6703 hr_utility.set_location('Before plsql table ',222);
6704 hr_utility.set_location('new_value id '||l_elig_dpnt_cvrd_othr_ptip_id,222);
6705 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_CVRD_OTHR_PTIP_ID' ;
6706 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDT.information1 ;
6707 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_DPNT_CVRD_OTHR_PTIP_ID ;
6708 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
6709 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDT_unique.table_route_id;
6710 hr_utility.set_location('After plsql table ',222);
6711 --
6712 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
6713 --
6714 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
6715 --
6716 else
6717 --
6718 -- Call Update routine for the pk_id created in prev run .
6719 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
6720 hr_utility.set_location(' BEN_ELIG_DPNT_CVRD_OTHR_PTIP_F UPDATE_ELIG_DPNT_CVRD_O_PTIP ',30);
6721 --UPD START
6722 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
6723 --
6724 if l_update then
6725 --
6726 l_datetrack_mode := r_EDT.datetrack_mode ;
6727 --
6728 get_dt_modes(
6729 p_effective_date => l_process_date,
6730 p_effective_end_date => r_EDT.information3,
6731 p_effective_start_date => r_EDT.information2,
6732 p_dml_operation => r_EDT.dml_operation,
6733 p_datetrack_mode => l_datetrack_mode );
6734 -- p_update => l_update
6735 --
6736 l_effective_date := l_process_date;
6737 l_ELIG_DPNT_CVRD_OTHR_PTIP_ID := r_EDT.information1;
6738 l_object_version_number := r_EDT.information265;
6739 --
6740 end if;
6741 --
6742 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
6743 --
6744 IF l_update OR l_dml_operation <> 'UPDATE' THEN
6745 --UPD END
6746
6747
6748 BEN_ELIG_DPNT_CVRD_O_PTIP_API.UPDATE_ELIG_DPNT_CVRD_O_PTIP(
6749 --
6750 P_VALIDATE => false
6751 ,P_EFFECTIVE_DATE => l_effective_date
6752 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
6753 --
6754 ,P_EDT_ATTRIBUTE1 => r_EDT.INFORMATION111
6755 ,P_EDT_ATTRIBUTE10 => r_EDT.INFORMATION120
6756 ,P_EDT_ATTRIBUTE11 => r_EDT.INFORMATION121
6757 ,P_EDT_ATTRIBUTE12 => r_EDT.INFORMATION122
6758 ,P_EDT_ATTRIBUTE13 => r_EDT.INFORMATION123
6759 ,P_EDT_ATTRIBUTE14 => r_EDT.INFORMATION124
6760 ,P_EDT_ATTRIBUTE15 => r_EDT.INFORMATION125
6761 ,P_EDT_ATTRIBUTE16 => r_EDT.INFORMATION126
6762 ,P_EDT_ATTRIBUTE17 => r_EDT.INFORMATION127
6763 ,P_EDT_ATTRIBUTE18 => r_EDT.INFORMATION128
6764 ,P_EDT_ATTRIBUTE19 => r_EDT.INFORMATION129
6765 ,P_EDT_ATTRIBUTE2 => r_EDT.INFORMATION112
6766 ,P_EDT_ATTRIBUTE20 => r_EDT.INFORMATION130
6767 ,P_EDT_ATTRIBUTE21 => r_EDT.INFORMATION131
6768 ,P_EDT_ATTRIBUTE22 => r_EDT.INFORMATION132
6769 ,P_EDT_ATTRIBUTE23 => r_EDT.INFORMATION133
6770 ,P_EDT_ATTRIBUTE24 => r_EDT.INFORMATION134
6771 ,P_EDT_ATTRIBUTE25 => r_EDT.INFORMATION135
6772 ,P_EDT_ATTRIBUTE26 => r_EDT.INFORMATION136
6773 ,P_EDT_ATTRIBUTE27 => r_EDT.INFORMATION137
6774 ,P_EDT_ATTRIBUTE28 => r_EDT.INFORMATION138
6775 ,P_EDT_ATTRIBUTE29 => r_EDT.INFORMATION139
6776 ,P_EDT_ATTRIBUTE3 => r_EDT.INFORMATION113
6777 ,P_EDT_ATTRIBUTE30 => r_EDT.INFORMATION140
6778 ,P_EDT_ATTRIBUTE4 => r_EDT.INFORMATION114
6779 ,P_EDT_ATTRIBUTE5 => r_EDT.INFORMATION115
6780 ,P_EDT_ATTRIBUTE6 => r_EDT.INFORMATION116
6781 ,P_EDT_ATTRIBUTE7 => r_EDT.INFORMATION117
6782 ,P_EDT_ATTRIBUTE8 => r_EDT.INFORMATION118
6783 ,P_EDT_ATTRIBUTE9 => r_EDT.INFORMATION119
6784 ,P_EDT_ATTRIBUTE_CATEGORY => r_EDT.INFORMATION110
6785 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
6786 ,P_ELIG_DPNT_CVRD_OTHR_PTIP_ID => l_elig_dpnt_cvrd_othr_ptip_id
6787 ,P_ENRL_DET_DT_CD => r_EDT.INFORMATION13
6788 ,P_EXCLD_FLAG => r_EDT.INFORMATION11
6789 ,P_ONLY_PLS_SUBJ_COBRA_FLAG => r_EDT.INFORMATION12
6790 ,P_ORDR_NUM => r_EDT.INFORMATION261
6791 ,P_PTIP_ID => l_PTIP_ID
6792 --
6793 -- ****** END CHANGE LINES
6794
6795 --
6796 ,P_EFFECTIVE_START_DATE => l_effective_start_date
6797 ,P_EFFECTIVE_END_DATE => l_effective_end_date
6798 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
6799 ,P_DATETRACK_MODE => l_datetrack_mode
6800 );
6801 end if; -- l_update
6802 --
6803 end if;
6804 --
6805 -- Delete the row if it is end dated.
6806 --
6807 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
6808 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
6809 trunc(l_max_eed) = trunc(r_EDT.information3)) then
6810 --
6811 BEN_ELIG_DPNT_CVRD_O_PTIP_API.delete_ELIG_DPNT_CVRD_O_PTIP(
6812 --
6813 p_validate => false
6814 ,p_elig_dpnt_cvrd_othr_ptip_id => l_elig_dpnt_cvrd_othr_ptip_id
6815 ,p_effective_start_date => l_effective_start_date
6816 ,p_effective_end_date => l_effective_end_date
6817 ,p_object_version_number => l_object_version_number
6818 ,p_effective_date => l_max_eed
6819 ,p_datetrack_mode => hr_api.g_delete
6820 --
6821 );
6822 --
6823 end if;
6824 --
6825 l_prev_pk_id := l_current_pk_id ;
6826 --
6827 end if;
6828 --
6829 end if;
6830 --
6831 end loop;
6832 --
6833 exception when others then
6834 --
6835 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EDT',r_EDT.information5 ) ;
6836 --
6837 end create_EDT_rows;
6838
6839 --
6840 ---------------------------------------------------------------
6841 ----------------------< create_ERL_rows >-----------------------
6842 ---------------------------------------------------------------
6843 --
6844 procedure create_ERL_rows
6845 (
6846 p_validate in number default 0
6847 ,p_copy_entity_txn_id in number
6848 ,p_effective_date in date
6849 ,p_prefix_suffix_text in varchar2 default null
6850 ,p_reuse_object_flag in varchar2 default null
6851 ,p_target_business_group_id in varchar2 default null
6852 ,p_prefix_suffix_cd in varchar2 default null
6853 ) is
6854 --
6855 l_ELIGY_PRFL_ID number;
6856 l_FORMULA_ID number;
6857 l_ORDR_TO_APLY_NUM number ;
6858 cursor c_unique_ERL(l_table_alias varchar2) is
6859 select distinct cpe.information1,
6860 cpe.information2,
6861 cpe.information3,
6862 cpe.table_route_id
6863 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
6864 pqh_table_route tr
6865 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6866 and cpe.table_route_id = tr.table_route_id
6867 -- and tr.where_clause = l_BEN_ELIGY_PRFL_RL_F
6868 and tr.table_alias = l_table_alias
6869 and cpe.number_of_copies = 1 -- ADDITION
6870 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
6871 order by information1, information2; --added for bug: 5151945
6872 --
6873 --
6874 cursor c_ERL_min_max_dates(c_table_route_id number,
6875 c_information1 number) is
6876 select
6877 min(cpe.information2) min_esd,
6878 max(cpe.information3) min_eed
6879 from ben_copy_entity_results cpe
6880 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6881 and cpe.table_route_id = c_table_route_id
6882 and cpe.information1 = c_information1 ;
6883 --
6884 cursor c_ERL(c_table_route_id number,
6885 c_information1 number,
6886 c_information2 date,
6887 c_information3 date ) is
6888 select
6889 cpe.*
6890 from ben_copy_entity_results cpe
6891 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6892 and cpe.table_route_id = c_table_route_id
6893 and cpe.information1 = c_information1
6894 and cpe.information2 = c_information2
6895 and cpe.information3 = c_information3
6896 and rownum = 1 ;
6897 -- Date Track target record
6898 cursor c_find_ERL_in_target(
6899 c_effective_start_date date,
6900 c_effective_end_date date,
6901 c_business_group_id number,
6902 c_new_pk_id number) is
6903 select
6904 ERL.eligy_prfl_rl_id new_value
6905 from BEN_ELIGY_PRFL_RL_F ERL
6906 where
6907 ERL.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
6908 ERL.FORMULA_ID = l_FORMULA_ID and
6909 ERL.ORDR_TO_APLY_NUM = l_ORDR_TO_APLY_NUM and -- IK Added
6910 ERL.business_group_id = c_business_group_id
6911 and ERL.eligy_prfl_rl_id <> c_new_pk_id
6912 and c_effective_start_date between effective_start_date
6913 and effective_end_date ;
6914 --END TEMPIK
6915 /*TEMPIK
6916 and exists ( select null
6917 from BEN_ELIGY_PRFL_RL_F ERL1
6918 where
6919 ERL1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
6920 ERL1.FORMULA_ID = l_FORMULA_ID and
6921 ERL1.ORDR_TO_APLY_NUM = l_ORDR_TO_APLY_NUM and -- IK Added
6922 ERL1.business_group_id = c_business_group_id
6923 and ERL1.effective_start_date <= c_effective_start_date )
6924 and exists ( select null
6925 from BEN_ELIGY_PRFL_RL_F ERL2
6926 where
6927 ERL2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
6928 ERL2.FORMULA_ID = l_FORMULA_ID and
6929 ERL2.ORDR_TO_APLY_NUM = l_ORDR_TO_APLY_NUM and -- IK Added
6930 ERL2.business_group_id = c_business_group_id
6931 and ERL2.effective_end_date >= c_effective_end_date )
6932 ;
6933 TEMPIK */
6934 --TEMPIK
6935 l_dt_rec_found boolean ;
6936 --END TEMPIK
6937 --
6938
6939 --UPD START
6940 --
6941 l_update boolean := false ;
6942 l_datetrack_mode varchar2(80) := hr_api.g_update;
6943 l_process_date date;
6944 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
6945 --
6946 --UPD END
6947 l_current_pk_id number := null ;
6948
6949 l_prev_pk_id number := null ;
6950 l_first_rec boolean := true ;
6951 r_ERL c_ERL%rowtype;
6952 l_eligy_prfl_rl_id number ;
6953 l_object_version_number number ;
6954 l_effective_start_date date ;
6955 l_effective_end_date date ;
6956 l_prefix pqh_copy_entity_attribs.information1%type := null;
6957 l_suffix pqh_copy_entity_attribs.information1%type := null;
6958 l_new_value number(15);
6959 l_object_found_in_target boolean := false ;
6960 l_min_esd date;
6961 l_max_eed date;
6962 l_effective_date date;
6963 --
6964 begin
6965 -- Initialization
6966 l_object_found_in_target := false ;
6967 -- End Initialization
6968 -- Derive the prefix - sufix
6969 if p_prefix_suffix_cd = 'PREFIX' then
6970 l_prefix := p_prefix_suffix_text ;
6971 elsif p_prefix_suffix_cd = 'SUFFIX' then
6972 l_suffix := p_prefix_suffix_text ;
6973 else
6974 l_prefix := null ;
6975 l_suffix := null ;
6976 end if ;
6977 -- End Prefix Sufix derivation
6978 for r_ERL_unique in c_unique_ERL('ERL') loop
6979
6980 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
6981 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6982 r_ERL_unique.information3 >=
6983 ben_pd_copy_to_ben_one.g_copy_effective_date)
6984 ) then
6985 --
6986 hr_utility.set_location(' r_ERL_unique.table_route_id '||r_ERL_unique.table_route_id,10);
6987 hr_utility.set_location(' r_ERL_unique.information1 '||r_ERL_unique.information1,10);
6988 hr_utility.set_location( 'r_ERL_unique.information2 '||r_ERL_unique.information2,10);
6989 hr_utility.set_location( 'r_ERL_unique.information3 '||r_ERL_unique.information3,10);
6990 -- If reuse objects flag is 'Y' then check for the object in the target business group
6991 -- if found insert the record into PLSql table and exit the loop else try create the
6992 -- object in the target business group
6993 --
6994 l_object_found_in_target := false ;
6995 --UPD START
6996 l_update := false;
6997 l_process_date := p_effective_date;
6998 l_dml_operation:= r_ERL_unique.dml_operation ;
6999 --
7000
7001 /**********************moved from below **********************/
7002 open c_ERL(r_ERL_unique.table_route_id,
7003 r_ERL_unique.information1,
7004 r_ERL_unique.information2,
7005 r_ERL_unique.information3 ) ;
7006 --
7007 fetch c_ERL into r_ERL ;
7008 --
7009 close c_ERL ;
7010 --
7011 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ERL.INFORMATION263,l_dml_operation);
7012 l_FORMULA_ID := get_fk('FORMULA_ID', r_ERL.INFORMATION251,l_dml_operation);
7013 l_ORDR_TO_APLY_NUM := r_ERL.INFORMATION260;
7014 /**********************************************************/
7015
7016 if l_dml_operation = 'UPDATE' then
7017 --
7018 l_object_found_in_target := TRUE;
7019 --
7020 if l_process_date between r_ERL_unique.information2 and r_ERL_unique.information3 then
7021 l_update := true;
7022 if r_ERL_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
7023 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIGY_PRFL_RL_ID' then
7024 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIGY_PRFL_RL_ID' ;
7025 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ERL_unique.information1 ;
7026 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ERL_unique.information1 ;
7027 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
7028 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ERL_unique.table_route_id;
7029 --
7030 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
7031 --
7032 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
7033 --
7034 -- log_data('ERL',l_new_value,l_prefix || r_ERL_unique.name|| l_suffix,'REUSED');
7035 --
7036 end if ;
7037 hr_utility.set_location( 'found record for update',10);
7038 --
7039 else
7040 --
7041 l_update := false;
7042 --
7043 end if;
7044 else
7045 --
7046 --UPD END
7047 l_min_esd := null ;
7048 l_max_eed := null ;
7049 open c_ERL_min_max_dates(r_ERL_unique.table_route_id, r_ERL_unique.information1 ) ;
7050 fetch c_ERL_min_max_dates into l_min_esd,l_max_eed ;
7051 --
7052
7053 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7054 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
7055 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
7056 end if;
7057 l_min_esd := greatest(l_min_esd,r_ERL_unique.information2);
7058 /**********************moved up from here **********************
7059 open c_ERL(r_ERL_unique.table_route_id,
7060 r_ERL_unique.information1,
7061 r_ERL_unique.information2,
7062 r_ERL_unique.information3 ) ;
7063 --
7064 fetch c_ERL into r_ERL ;
7065 --
7066 close c_ERL ;
7067 --
7068 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ERL.INFORMATION263,l_dml_operation);
7069 l_FORMULA_ID := get_fk('FORMULA_ID', r_ERL.INFORMATION251,l_dml_operation);
7070 l_ORDR_TO_APLY_NUM := r_ERL.INFORMATION260;
7071 **********************************************************/
7072
7073 --
7074 if p_reuse_object_flag = 'Y' then
7075 if c_ERL_min_max_dates%found then
7076 -- cursor to find the object
7077 open c_find_ERL_in_target( l_min_esd,l_max_eed,
7078 p_target_business_group_id, nvl(l_eligy_prfl_rl_id, -999) ) ;
7079 fetch c_find_ERL_in_target into l_new_value ;
7080 if c_find_ERL_in_target%found then
7081 --
7082 --TEMPIK
7083 l_dt_rec_found := dt_api.check_min_max_dates
7084 (p_base_table_name => 'BEN_ELIGY_PRFL_RL_F',
7085 p_base_key_column => 'ELIGY_PRFL_RL_ID',
7086 p_base_key_value => l_new_value,
7087 p_from_date => l_min_esd,
7088 p_to_date => l_max_eed );
7089 if l_dt_rec_found THEN
7090 --END TEMPIK
7091 if r_ERL_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
7092 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIGY_PRFL_RL_ID' then
7093 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIGY_PRFL_RL_ID' ;
7094 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ERL_unique.information1 ;
7095 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
7096 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
7097 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ERL_unique.table_route_id;
7098 --
7099 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
7100 --
7101 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
7102 end if ;
7103 --
7104 l_object_found_in_target := true ;
7105 --TEMPIK
7106 end if; -- l_dt_rec_found
7107 --END TEMPIK
7108 end if;
7109 close c_find_ERL_in_target ;
7110 --
7111 end if;
7112 end if ;
7113 --
7114 close c_ERL_min_max_dates ;
7115 end if; --if p_dml_operation
7116 --
7117 if ( not l_object_found_in_target OR l_update ) and (l_FORMULA_ID is not null) then -- bug # 4251900
7118
7119 --
7120 l_current_pk_id := r_ERL.information1;
7121 --
7122 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
7123 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
7124 --
7125 if l_current_pk_id = l_prev_pk_id then
7126 --
7127 l_first_rec := false ;
7128 --
7129 else
7130 --
7131 l_first_rec := true ;
7132 --
7133 end if ;
7134 --
7135
7136 l_effective_date := r_ERL.information2;
7137 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7138 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
7139 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
7140 end if;
7141
7142 if l_first_rec and not l_update then
7143 -- Call Create routine.
7144 hr_utility.set_location(' BEN_ELIGY_PRFL_RL_F CREATE_ELIGY_PROFILE_RULE ',20);
7145 BEN_ELIGY_PROFILE_RULE_API.CREATE_ELIGY_PROFILE_RULE(
7146 --
7147 P_VALIDATE => false
7148 ,P_EFFECTIVE_DATE => l_effective_date
7149 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
7150 --
7151 ,P_DRVBL_FCTR_APLS_FLAG => r_ERL.INFORMATION11
7152 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
7153 ,P_ELIGY_PRFL_RL_ID => l_eligy_prfl_rl_id
7154 ,P_ERL_ATTRIBUTE1 => r_ERL.INFORMATION111
7155 ,P_ERL_ATTRIBUTE10 => r_ERL.INFORMATION120
7156 ,P_ERL_ATTRIBUTE11 => r_ERL.INFORMATION121
7157 ,P_ERL_ATTRIBUTE12 => r_ERL.INFORMATION122
7158 ,P_ERL_ATTRIBUTE13 => r_ERL.INFORMATION123
7159 ,P_ERL_ATTRIBUTE14 => r_ERL.INFORMATION124
7160 ,P_ERL_ATTRIBUTE15 => r_ERL.INFORMATION125
7161 ,P_ERL_ATTRIBUTE16 => r_ERL.INFORMATION126
7162 ,P_ERL_ATTRIBUTE17 => r_ERL.INFORMATION127
7163 ,P_ERL_ATTRIBUTE18 => r_ERL.INFORMATION128
7164 ,P_ERL_ATTRIBUTE19 => r_ERL.INFORMATION129
7165 ,P_ERL_ATTRIBUTE2 => r_ERL.INFORMATION112
7166 ,P_ERL_ATTRIBUTE20 => r_ERL.INFORMATION130
7167 ,P_ERL_ATTRIBUTE21 => r_ERL.INFORMATION131
7168 ,P_ERL_ATTRIBUTE22 => r_ERL.INFORMATION132
7169 ,P_ERL_ATTRIBUTE23 => r_ERL.INFORMATION133
7170 ,P_ERL_ATTRIBUTE24 => r_ERL.INFORMATION134
7171 ,P_ERL_ATTRIBUTE25 => r_ERL.INFORMATION135
7172 ,P_ERL_ATTRIBUTE26 => r_ERL.INFORMATION136
7173 ,P_ERL_ATTRIBUTE27 => r_ERL.INFORMATION137
7174 ,P_ERL_ATTRIBUTE28 => r_ERL.INFORMATION138
7175 ,P_ERL_ATTRIBUTE29 => r_ERL.INFORMATION139
7176 ,P_ERL_ATTRIBUTE3 => r_ERL.INFORMATION113
7177 ,P_ERL_ATTRIBUTE30 => r_ERL.INFORMATION140
7178 ,P_ERL_ATTRIBUTE4 => r_ERL.INFORMATION114
7179 ,P_ERL_ATTRIBUTE5 => r_ERL.INFORMATION115
7180 ,P_ERL_ATTRIBUTE6 => r_ERL.INFORMATION116
7181 ,P_ERL_ATTRIBUTE7 => r_ERL.INFORMATION117
7182 ,P_ERL_ATTRIBUTE8 => r_ERL.INFORMATION118
7183 ,P_ERL_ATTRIBUTE9 => r_ERL.INFORMATION119
7184 ,P_ERL_ATTRIBUTE_CATEGORY => r_ERL.INFORMATION110
7185 ,P_FORMULA_ID => l_FORMULA_ID
7186 ,P_ORDR_TO_APLY_NUM => r_ERL.INFORMATION260
7187 --
7188 -- ****** END CHANGE LINES
7189
7190 --
7191
7192 ,P_EFFECTIVE_START_DATE => l_effective_start_date
7193 ,P_EFFECTIVE_END_DATE => l_effective_end_date
7194 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
7195 ,P_CRITERIA_SCORE => r_ERL.INFORMATION295
7196 ,P_CRITERIA_WEIGHT => r_ERL.INFORMATION296
7197
7198 );
7199
7200 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
7201 -- Update all relevent cer records with new pk_id
7202 hr_utility.set_location('Before plsql table ',222);
7203 hr_utility.set_location('new_value id '||l_eligy_prfl_rl_id,222);
7204 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIGY_PRFL_RL_ID' ;
7205 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ERL.information1 ;
7206 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIGY_PRFL_RL_ID ;
7207 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
7208 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ERL_unique.table_route_id;
7209 hr_utility.set_location('After plsql table ',222);
7210 --
7211 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
7212 --
7213 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
7214 --
7215 else
7216 --
7217 -- Call Update routine for the pk_id created in prev run .
7218 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
7219 hr_utility.set_location(' BEN_ELIGY_PRFL_RL_F UPDATE_ELIGY_PROFILE_RULE ',30);
7220 --UPD START
7221 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
7222 --
7223 if l_update then
7224 --
7225 l_datetrack_mode := r_ERL.datetrack_mode ;
7226 --
7227 get_dt_modes(
7228 p_effective_date => l_process_date,
7229 p_effective_end_date => r_ERL.information3,
7230 p_effective_start_date => r_ERL.information2,
7231 p_dml_operation => r_ERL.dml_operation,
7232 p_datetrack_mode => l_datetrack_mode );
7233 -- p_update => l_update
7234 --
7235 l_effective_date := l_process_date;
7236 l_ELIGY_PRFL_RL_ID := r_ERL.information1;
7237 l_object_version_number := r_ERL.information265;
7238 --
7239 end if;
7240 --
7241 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
7242 --
7243 IF l_update OR l_dml_operation <> 'UPDATE' THEN
7244 --UPD END
7245
7246
7247 BEN_ELIGY_PROFILE_RULE_API.UPDATE_ELIGY_PROFILE_RULE(
7248 --
7249 P_VALIDATE => false
7250 ,P_EFFECTIVE_DATE => l_effective_date
7251 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
7252 --
7253 ,P_DRVBL_FCTR_APLS_FLAG => r_ERL.INFORMATION11
7254 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
7255 ,P_ELIGY_PRFL_RL_ID => l_eligy_prfl_rl_id
7256 ,P_ERL_ATTRIBUTE1 => r_ERL.INFORMATION111
7257 ,P_ERL_ATTRIBUTE10 => r_ERL.INFORMATION120
7258 ,P_ERL_ATTRIBUTE11 => r_ERL.INFORMATION121
7259 ,P_ERL_ATTRIBUTE12 => r_ERL.INFORMATION122
7260 ,P_ERL_ATTRIBUTE13 => r_ERL.INFORMATION123
7261 ,P_ERL_ATTRIBUTE14 => r_ERL.INFORMATION124
7262 ,P_ERL_ATTRIBUTE15 => r_ERL.INFORMATION125
7263 ,P_ERL_ATTRIBUTE16 => r_ERL.INFORMATION126
7264 ,P_ERL_ATTRIBUTE17 => r_ERL.INFORMATION127
7265 ,P_ERL_ATTRIBUTE18 => r_ERL.INFORMATION128
7266 ,P_ERL_ATTRIBUTE19 => r_ERL.INFORMATION129
7267 ,P_ERL_ATTRIBUTE2 => r_ERL.INFORMATION112
7268 ,P_ERL_ATTRIBUTE20 => r_ERL.INFORMATION130
7269 ,P_ERL_ATTRIBUTE21 => r_ERL.INFORMATION131
7270 ,P_ERL_ATTRIBUTE22 => r_ERL.INFORMATION132
7271 ,P_ERL_ATTRIBUTE23 => r_ERL.INFORMATION133
7272 ,P_ERL_ATTRIBUTE24 => r_ERL.INFORMATION134
7273 ,P_ERL_ATTRIBUTE25 => r_ERL.INFORMATION135
7274 ,P_ERL_ATTRIBUTE26 => r_ERL.INFORMATION136
7275 ,P_ERL_ATTRIBUTE27 => r_ERL.INFORMATION137
7276 ,P_ERL_ATTRIBUTE28 => r_ERL.INFORMATION138
7277 ,P_ERL_ATTRIBUTE29 => r_ERL.INFORMATION139
7278 ,P_ERL_ATTRIBUTE3 => r_ERL.INFORMATION113
7279 ,P_ERL_ATTRIBUTE30 => r_ERL.INFORMATION140
7280 ,P_ERL_ATTRIBUTE4 => r_ERL.INFORMATION114
7281 ,P_ERL_ATTRIBUTE5 => r_ERL.INFORMATION115
7282 ,P_ERL_ATTRIBUTE6 => r_ERL.INFORMATION116
7283 ,P_ERL_ATTRIBUTE7 => r_ERL.INFORMATION117
7284 ,P_ERL_ATTRIBUTE8 => r_ERL.INFORMATION118
7285 ,P_ERL_ATTRIBUTE9 => r_ERL.INFORMATION119
7286 ,P_ERL_ATTRIBUTE_CATEGORY => r_ERL.INFORMATION110
7287 ,P_FORMULA_ID => l_FORMULA_ID
7288 ,P_ORDR_TO_APLY_NUM => r_ERL.INFORMATION260
7289 --
7290 -- ****** END CHANGE LINES
7291
7292 --
7293 ,P_EFFECTIVE_START_DATE => l_effective_start_date
7294 ,P_EFFECTIVE_END_DATE => l_effective_end_date
7295 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
7296 ,P_DATETRACK_MODE => l_datetrack_mode
7297 ,P_CRITERIA_SCORE => r_ERL.INFORMATION295
7298 ,P_CRITERIA_WEIGHT => r_ERL.INFORMATION296
7299
7300 );
7301 end if; -- l_update
7302 --
7303 end if;
7304 --
7305 -- Delete the row if it is end dated.
7306 --
7307 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
7308 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
7309 trunc(l_max_eed) = trunc(r_ERL.information3)) then
7310 --
7311 BEN_ELIGY_PROFILE_RULE_API.delete_ELIGY_PROFILE_RULE(
7312 --
7313 p_validate => false
7314 ,p_eligy_prfl_rl_id => l_eligy_prfl_rl_id
7315 ,p_effective_start_date => l_effective_start_date
7316 ,p_effective_end_date => l_effective_end_date
7317 ,p_object_version_number => l_object_version_number
7318 ,p_effective_date => l_max_eed
7319 ,p_datetrack_mode => hr_api.g_delete
7320 --
7321 );
7322 --
7323 end if;
7324 --
7325 l_prev_pk_id := l_current_pk_id ;
7326 --
7327 end if;
7328 --
7329 end if;
7330 --
7331 end loop;
7332 --
7333 exception when others then
7334 --
7335 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ERL',r_ERL.information5 ) ;
7336 --
7337 end create_ERL_rows;
7338
7339 --
7340 --
7341 ---------------------------------------------------------------
7342 ----------------------< create_EHW_rows >-----------------------
7343 ---------------------------------------------------------------
7344 --
7345 procedure create_EHW_rows
7346 (
7347 p_validate in number default 0
7348 ,p_copy_entity_txn_id in number
7349 ,p_effective_date in date
7350 ,p_prefix_suffix_text in varchar2 default null
7351 ,p_reuse_object_flag in varchar2 default null
7352 ,p_target_business_group_id in varchar2 default null
7353 ,p_prefix_suffix_cd in varchar2 default null
7354 ) is
7355 --
7356 l_ELIGY_PRFL_ID number;
7357 l_HRS_WKD_IN_PERD_FCTR_ID number;
7358 cursor c_unique_EHW(l_table_alias varchar2) is
7359 select distinct cpe.information1,
7360 cpe.information2,
7361 cpe.information3,
7362 cpe.table_route_id
7363 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
7364 pqh_table_route tr
7365 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7366 and cpe.table_route_id = tr.table_route_id
7367 -- and tr.where_clause = l_BEN_ELIG_HRS_WKD_PRTE_F
7368 and tr.table_alias = l_table_alias
7369 and cpe.number_of_copies = 1 -- ADDITION
7370 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
7371 order by information1, information2; --added for bug: 5151945
7372 --
7373 --
7374 cursor c_EHW_min_max_dates(c_table_route_id number,
7375 c_information1 number) is
7376 select
7377 min(cpe.information2) min_esd,
7378 max(cpe.information3) min_eed
7379 from ben_copy_entity_results cpe
7380 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7381 and cpe.table_route_id = c_table_route_id
7382 and cpe.information1 = c_information1 ;
7383 --
7384 cursor c_EHW(c_table_route_id number,
7385 c_information1 number,
7386 c_information2 date,
7387 c_information3 date ) is
7388 select
7389 cpe.*
7390 from ben_copy_entity_results cpe
7391 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7392 and cpe.table_route_id = c_table_route_id
7393 and cpe.information1 = c_information1
7394 and cpe.information2 = c_information2
7395 and cpe.information3 = c_information3
7396 and rownum = 1 ;
7397 -- Date Track target record
7398 cursor c_find_EHW_in_target(
7399 c_effective_start_date date,
7400 c_effective_end_date date,
7401 c_business_group_id number,
7402 c_new_pk_id number) is
7403 select
7404 EHW.elig_hrs_wkd_prte_id new_value
7405 from BEN_ELIG_HRS_WKD_PRTE_F EHW
7406 where
7407 EHW.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
7408 EHW.HRS_WKD_IN_PERD_FCTR_ID = l_HRS_WKD_IN_PERD_FCTR_ID and
7409 EHW.business_group_id = c_business_group_id
7410 and EHW.elig_hrs_wkd_prte_id <> c_new_pk_id
7411 and c_effective_start_date between effective_start_date
7412 and effective_end_date ;
7413 --END TEMPIK
7414 /*TEMPIK
7415 and exists ( select null
7416 from BEN_ELIG_HRS_WKD_PRTE_F EHW1
7417 where
7418 EHW1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
7419 EHW1.HRS_WKD_IN_PERD_FCTR_ID = l_HRS_WKD_IN_PERD_FCTR_ID and
7420 EHW1.business_group_id = c_business_group_id
7421 and EHW1.effective_start_date <= c_effective_start_date )
7422 and exists ( select null
7423 from BEN_ELIG_HRS_WKD_PRTE_F EHW2
7424 where
7425 EHW2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
7426 EHW2.HRS_WKD_IN_PERD_FCTR_ID = l_HRS_WKD_IN_PERD_FCTR_ID and
7427 EHW2.business_group_id = c_business_group_id
7428 and EHW2.effective_end_date >= c_effective_end_date )
7429 ;
7430 TEMPIK */
7431 --TEMPIK
7432 l_dt_rec_found boolean ;
7433 --END TEMPIK
7434 --
7435
7436 --UPD START
7437 --
7438 l_update boolean := false ;
7439 l_datetrack_mode varchar2(80) := hr_api.g_update;
7440 l_process_date date;
7441 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
7442 --
7443 --UPD END
7444 l_current_pk_id number := null ;
7445
7446 l_prev_pk_id number := null ;
7447 l_first_rec boolean := true ;
7448 r_EHW c_EHW%rowtype;
7449 l_elig_hrs_wkd_prte_id number ;
7450 l_object_version_number number ;
7451 l_effective_start_date date ;
7452 l_effective_end_date date ;
7453 l_prefix pqh_copy_entity_attribs.information1%type := null;
7454 l_suffix pqh_copy_entity_attribs.information1%type := null;
7455 l_new_value number(15);
7456 l_object_found_in_target boolean := false ;
7457 l_min_esd date;
7458 l_max_eed date;
7459 l_effective_date date;
7460 --
7461 begin
7462 -- Initialization
7463 l_object_found_in_target := false ;
7464 -- End Initialization
7465 -- Derive the prefix - sufix
7466 if p_prefix_suffix_cd = 'PREFIX' then
7467 l_prefix := p_prefix_suffix_text ;
7468 elsif p_prefix_suffix_cd = 'SUFFIX' then
7469 l_suffix := p_prefix_suffix_text ;
7470 else
7471 l_prefix := null ;
7472 l_suffix := null ;
7473 end if ;
7474 -- End Prefix Sufix derivation
7475 for r_EHW_unique in c_unique_EHW('EHW') loop
7476
7477 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
7478 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7479 r_EHW_unique.information3 >=
7480 ben_pd_copy_to_ben_one.g_copy_effective_date)
7481 ) then
7482 --
7483 hr_utility.set_location(' r_EHW_unique.table_route_id '||r_EHW_unique.table_route_id,10);
7484 hr_utility.set_location(' r_EHW_unique.information1 '||r_EHW_unique.information1,10);
7485 hr_utility.set_location( 'r_EHW_unique.information2 '||r_EHW_unique.information2,10);
7486 hr_utility.set_location( 'r_EHW_unique.information3 '||r_EHW_unique.information3,10);
7487 -- If reuse objects flag is 'Y' then check for the object in the target business group
7488 -- if found insert the record into PLSql table and exit the loop else try create the
7489 -- object in the target business group
7490 --
7491 l_object_found_in_target := false ;
7492 --UPD START
7493 l_update := false;
7494 l_process_date := p_effective_date;
7495 l_dml_operation:= r_EHW_unique.dml_operation ;
7496 --
7497
7498 /**********************moved from below **********************/
7499 open c_EHW(r_EHW_unique.table_route_id,
7500 r_EHW_unique.information1,
7501 r_EHW_unique.information2,
7502 r_EHW_unique.information3 ) ;
7503 --
7504 fetch c_EHW into r_EHW ;
7505 --
7506 close c_EHW ;
7507 --
7508 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EHW.INFORMATION263,l_dml_operation);
7509 l_HRS_WKD_IN_PERD_FCTR_ID := get_fk('HRS_WKD_IN_PERD_FCTR_ID', r_EHW.INFORMATION224,l_dml_operation);
7510
7511 /**********************************************************/
7512 if l_dml_operation = 'UPDATE' then
7513 --
7514 l_object_found_in_target := TRUE;
7515 --
7516 if l_process_date between r_EHW_unique.information2 and r_EHW_unique.information3 then
7517 l_update := true;
7518 if r_EHW_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
7519 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_HRS_WKD_PRTE_ID' then
7520 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_HRS_WKD_PRTE_ID' ;
7521 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EHW_unique.information1 ;
7522 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EHW_unique.information1 ;
7523 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
7524 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EHW_unique.table_route_id;
7525 --
7526 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
7527 --
7528 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
7529 --
7530 -- log_data('EHW',l_new_value,l_prefix || r_EHW_unique.name|| l_suffix,'REUSED');
7531 --
7532 end if ;
7533 hr_utility.set_location( 'found record for update',10);
7534 --
7535 else
7536 --
7537 l_update := false;
7538 --
7539 end if;
7540 else
7541 --
7542 --UPD END
7543 l_min_esd := null ;
7544 l_max_eed := null ;
7545 open c_EHW_min_max_dates(r_EHW_unique.table_route_id, r_EHW_unique.information1 ) ;
7546 fetch c_EHW_min_max_dates into l_min_esd,l_max_eed ;
7547 --
7548
7549 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7550 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
7551 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
7552 end if;
7553 l_min_esd := greatest(l_min_esd,r_EHW_unique.information2);
7554 /**********************moved up from here **********************
7555 open c_EHW(r_EHW_unique.table_route_id,
7556 r_EHW_unique.information1,
7557 r_EHW_unique.information2,
7558 r_EHW_unique.information3 ) ;
7559 --
7560 fetch c_EHW into r_EHW ;
7561 --
7562 close c_EHW ;
7563 --
7564 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EHW.INFORMATION263,l_dml_operation);
7565 l_HRS_WKD_IN_PERD_FCTR_ID := get_fk('HRS_WKD_IN_PERD_FCTR_ID', r_EHW.INFORMATION224,l_dml_operation);
7566
7567 **********************************************************/
7568
7569 if p_reuse_object_flag = 'Y' then
7570 if c_EHW_min_max_dates%found then
7571 -- cursor to find the object
7572 open c_find_EHW_in_target( l_min_esd,l_max_eed, p_target_business_group_id,
7573 nvl(l_elig_hrs_wkd_prte_id, -999) ) ;
7574 fetch c_find_EHW_in_target into l_new_value ;
7575 if c_find_EHW_in_target%found then
7576 --
7577 --TEMPIK
7578 l_dt_rec_found := dt_api.check_min_max_dates
7579 (p_base_table_name => 'BEN_ELIG_HRS_WKD_PRTE_F',
7580 p_base_key_column => 'ELIG_HRS_WKD_PRTE_ID',
7581 p_base_key_value => l_new_value,
7582 p_from_date => l_min_esd,
7583 p_to_date => l_max_eed );
7584 if l_dt_rec_found THEN
7585 --END TEMPIK
7586 if r_EHW_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
7587 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_HRS_WKD_PRTE_ID' then
7588 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_HRS_WKD_PRTE_ID' ;
7589 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EHW_unique.information1 ;
7590 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
7591 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
7592 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EHW_unique.table_route_id;
7593 --
7594 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
7595 --
7596 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
7597 end if ;
7598 --
7599 l_object_found_in_target := true ;
7600 --TEMPIK
7601 end if; -- l_dt_rec_found
7602 --END TEMPIK
7603 end if;
7604 close c_find_EHW_in_target ;
7605 --
7606 end if;
7607 end if ;
7608 --
7609 close c_EHW_min_max_dates ;
7610 end if; --if p_dml_operation
7611 --
7612 if not l_object_found_in_target OR l_update then
7613
7614 --
7615 l_current_pk_id := r_EHW.information1;
7616 --
7617 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
7618 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
7619 --
7620 if l_current_pk_id = l_prev_pk_id then
7621 --
7622 l_first_rec := false ;
7623 --
7624 else
7625 --
7626 l_first_rec := true ;
7627 --
7628 end if ;
7629 --
7630
7631 l_effective_date := r_EHW.information2;
7632 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7633 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
7634 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
7635 end if;
7636
7637 if l_first_rec and not l_update then
7638 -- Call Create routine.
7639 hr_utility.set_location(' BEN_ELIG_HRS_WKD_PRTE_F CREATE_ELIG_HRS_WKD_PRTE ',20);
7640 BEN_ELIG_HRS_WKD_PRTE_API.CREATE_ELIG_HRS_WKD_PRTE(
7641 --
7642 P_VALIDATE => false
7643 ,P_EFFECTIVE_DATE => l_effective_date
7644 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
7645 --
7646 ,P_EHW_ATTRIBUTE1 => r_EHW.INFORMATION111
7647 ,P_EHW_ATTRIBUTE10 => r_EHW.INFORMATION120
7648 ,P_EHW_ATTRIBUTE11 => r_EHW.INFORMATION121
7649 ,P_EHW_ATTRIBUTE12 => r_EHW.INFORMATION122
7650 ,P_EHW_ATTRIBUTE13 => r_EHW.INFORMATION123
7651 ,P_EHW_ATTRIBUTE14 => r_EHW.INFORMATION124
7652 ,P_EHW_ATTRIBUTE15 => r_EHW.INFORMATION125
7653 ,P_EHW_ATTRIBUTE16 => r_EHW.INFORMATION126
7654 ,P_EHW_ATTRIBUTE17 => r_EHW.INFORMATION127
7655 ,P_EHW_ATTRIBUTE18 => r_EHW.INFORMATION128
7656 ,P_EHW_ATTRIBUTE19 => r_EHW.INFORMATION129
7657 ,P_EHW_ATTRIBUTE2 => r_EHW.INFORMATION112
7658 ,P_EHW_ATTRIBUTE20 => r_EHW.INFORMATION130
7659 ,P_EHW_ATTRIBUTE21 => r_EHW.INFORMATION131
7660 ,P_EHW_ATTRIBUTE22 => r_EHW.INFORMATION132
7661 ,P_EHW_ATTRIBUTE23 => r_EHW.INFORMATION133
7662 ,P_EHW_ATTRIBUTE24 => r_EHW.INFORMATION134
7663 ,P_EHW_ATTRIBUTE25 => r_EHW.INFORMATION135
7664 ,P_EHW_ATTRIBUTE26 => r_EHW.INFORMATION136
7665 ,P_EHW_ATTRIBUTE27 => r_EHW.INFORMATION137
7666 ,P_EHW_ATTRIBUTE28 => r_EHW.INFORMATION138
7667 ,P_EHW_ATTRIBUTE29 => r_EHW.INFORMATION139
7668 ,P_EHW_ATTRIBUTE3 => r_EHW.INFORMATION113
7669 ,P_EHW_ATTRIBUTE30 => r_EHW.INFORMATION140
7670 ,P_EHW_ATTRIBUTE4 => r_EHW.INFORMATION114
7671 ,P_EHW_ATTRIBUTE5 => r_EHW.INFORMATION115
7672 ,P_EHW_ATTRIBUTE6 => r_EHW.INFORMATION116
7673 ,P_EHW_ATTRIBUTE7 => r_EHW.INFORMATION117
7674 ,P_EHW_ATTRIBUTE8 => r_EHW.INFORMATION118
7675 ,P_EHW_ATTRIBUTE9 => r_EHW.INFORMATION119
7676 ,P_EHW_ATTRIBUTE_CATEGORY => r_EHW.INFORMATION110
7677 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
7678 ,P_ELIG_HRS_WKD_PRTE_ID => l_elig_hrs_wkd_prte_id
7679 ,P_EXCLD_FLAG => r_EHW.INFORMATION11
7680 ,P_HRS_WKD_IN_PERD_FCTR_ID => l_HRS_WKD_IN_PERD_FCTR_ID
7681 ,P_ORDR_NUM => r_EHW.INFORMATION260
7682 --
7683 -- ****** END CHANGE LINES
7684
7685 --
7686
7687 ,P_EFFECTIVE_START_DATE => l_effective_start_date
7688 ,P_EFFECTIVE_END_DATE => l_effective_end_date
7689 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
7690 ,P_CRITERIA_SCORE => r_ehw.INFORMATION295
7691 ,P_CRITERIA_WEIGHT => r_ehw.INFORMATION296
7692 );
7693 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
7694 -- Update all relevent cer records with new pk_id
7695 hr_utility.set_location('Before plsql table ',222);
7696 hr_utility.set_location('new_value id '||l_elig_hrs_wkd_prte_id,222);
7697 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_HRS_WKD_PRTE_ID' ;
7698 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EHW.information1 ;
7699 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_HRS_WKD_PRTE_ID ;
7700 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
7701 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EHW_unique.table_route_id;
7702 hr_utility.set_location('After plsql table ',222);
7703 --
7704 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
7705 --
7706 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
7707 --
7708 else
7709 --
7710 -- Call Update routine for the pk_id created in prev run .
7711 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
7712 hr_utility.set_location(' BEN_ELIG_HRS_WKD_PRTE_F UPDATE_ELIG_HRS_WKD_PRTE ',30);
7713 --UPD START
7714 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
7715 --
7716 if l_update then
7717 --
7718 l_datetrack_mode := r_EHW.datetrack_mode ;
7719 --
7720 get_dt_modes(
7721 p_effective_date => l_process_date,
7722 p_effective_end_date => r_EHW.information3,
7723 p_effective_start_date => r_EHW.information2,
7724 p_dml_operation => r_EHW.dml_operation,
7725 p_datetrack_mode => l_datetrack_mode );
7726 -- p_update => l_update
7727 --
7728 l_effective_date := l_process_date;
7729 l_ELIG_HRS_WKD_PRTE_ID := r_EHW.information1;
7730 l_object_version_number := r_EHW.information265;
7731 --
7732 end if;
7733 --
7734 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
7735 --
7736 IF l_update OR l_dml_operation <> 'UPDATE' THEN
7737 --UPD END
7738
7739
7740 BEN_ELIG_HRS_WKD_PRTE_API.UPDATE_ELIG_HRS_WKD_PRTE(
7741 --
7742 P_VALIDATE => false
7743 ,P_EFFECTIVE_DATE => l_effective_date
7744 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
7745 --
7746 ,P_EHW_ATTRIBUTE1 => r_EHW.INFORMATION111
7747 ,P_EHW_ATTRIBUTE10 => r_EHW.INFORMATION120
7748 ,P_EHW_ATTRIBUTE11 => r_EHW.INFORMATION121
7749 ,P_EHW_ATTRIBUTE12 => r_EHW.INFORMATION122
7750 ,P_EHW_ATTRIBUTE13 => r_EHW.INFORMATION123
7751 ,P_EHW_ATTRIBUTE14 => r_EHW.INFORMATION124
7752 ,P_EHW_ATTRIBUTE15 => r_EHW.INFORMATION125
7753 ,P_EHW_ATTRIBUTE16 => r_EHW.INFORMATION126
7754 ,P_EHW_ATTRIBUTE17 => r_EHW.INFORMATION127
7755 ,P_EHW_ATTRIBUTE18 => r_EHW.INFORMATION128
7756 ,P_EHW_ATTRIBUTE19 => r_EHW.INFORMATION129
7757 ,P_EHW_ATTRIBUTE2 => r_EHW.INFORMATION112
7758 ,P_EHW_ATTRIBUTE20 => r_EHW.INFORMATION130
7759 ,P_EHW_ATTRIBUTE21 => r_EHW.INFORMATION131
7760 ,P_EHW_ATTRIBUTE22 => r_EHW.INFORMATION132
7761 ,P_EHW_ATTRIBUTE23 => r_EHW.INFORMATION133
7762 ,P_EHW_ATTRIBUTE24 => r_EHW.INFORMATION134
7763 ,P_EHW_ATTRIBUTE25 => r_EHW.INFORMATION135
7764 ,P_EHW_ATTRIBUTE26 => r_EHW.INFORMATION136
7765 ,P_EHW_ATTRIBUTE27 => r_EHW.INFORMATION137
7766 ,P_EHW_ATTRIBUTE28 => r_EHW.INFORMATION138
7767 ,P_EHW_ATTRIBUTE29 => r_EHW.INFORMATION139
7768 ,P_EHW_ATTRIBUTE3 => r_EHW.INFORMATION113
7769 ,P_EHW_ATTRIBUTE30 => r_EHW.INFORMATION140
7770 ,P_EHW_ATTRIBUTE4 => r_EHW.INFORMATION114
7771 ,P_EHW_ATTRIBUTE5 => r_EHW.INFORMATION115
7772 ,P_EHW_ATTRIBUTE6 => r_EHW.INFORMATION116
7773 ,P_EHW_ATTRIBUTE7 => r_EHW.INFORMATION117
7774 ,P_EHW_ATTRIBUTE8 => r_EHW.INFORMATION118
7775 ,P_EHW_ATTRIBUTE9 => r_EHW.INFORMATION119
7776 ,P_EHW_ATTRIBUTE_CATEGORY => r_EHW.INFORMATION110
7777 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
7778 ,P_ELIG_HRS_WKD_PRTE_ID => l_elig_hrs_wkd_prte_id
7779 ,P_EXCLD_FLAG => r_EHW.INFORMATION11
7780 ,P_HRS_WKD_IN_PERD_FCTR_ID => l_HRS_WKD_IN_PERD_FCTR_ID
7781 ,P_ORDR_NUM => r_EHW.INFORMATION260
7782 --
7783 -- ****** END CHANGE LINES
7784
7785 --
7786 ,P_EFFECTIVE_START_DATE => l_effective_start_date
7787 ,P_EFFECTIVE_END_DATE => l_effective_end_date
7788 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
7789 ,P_DATETRACK_MODE => l_datetrack_mode
7790 ,P_CRITERIA_SCORE => r_ehw.INFORMATION295
7791 ,P_CRITERIA_WEIGHT => r_ehw.INFORMATION296
7792 );
7793 end if; -- l_update
7794 --
7795 end if;
7796 --
7797 -- Delete the row if it is end dated.
7798 --
7799 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
7800 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
7801 trunc(l_max_eed) = trunc(r_EHW.information3)) then
7802 --
7803 BEN_ELIG_HRS_WKD_PRTE_API.delete_ELIG_HRS_WKD_PRTE(
7804 --
7805 p_validate => false
7806 ,p_elig_hrs_wkd_prte_id => l_elig_hrs_wkd_prte_id
7807 ,p_effective_start_date => l_effective_start_date
7808 ,p_effective_end_date => l_effective_end_date
7809 ,p_object_version_number => l_object_version_number
7810 ,p_effective_date => l_max_eed
7811 ,p_datetrack_mode => hr_api.g_delete
7812 --
7813 );
7814 --
7815 end if;
7816 --
7817 l_prev_pk_id := l_current_pk_id ;
7818 --
7819 end if;
7820 --
7821 end if;
7822 --
7823 end loop;
7824 --
7825 exception when others then
7826 --
7827 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EHW',r_EHW.information5 ) ;
7828 --
7829 end create_EHW_rows;
7830
7831
7832
7833 --
7834 ---------------------------------------------------------------
7835 ----------------------< create_EJP_rows >-----------------------
7836 ---------------------------------------------------------------
7837 --
7838 procedure create_EJP_rows
7839 (
7840 p_validate in number default 0
7841 ,p_copy_entity_txn_id in number
7842 ,p_effective_date in date
7843 ,p_prefix_suffix_text in varchar2 default null
7844 ,p_reuse_object_flag in varchar2 default null
7845 ,p_target_business_group_id in varchar2 default null
7846 ,p_prefix_suffix_cd in varchar2 default null
7847 ) is
7848 --
7849 l_ELIGY_PRFL_ID number;
7850 l_JOB_ID number; -- IK 9999 Mapping fix needed
7851 l_ORDR_NUM number ;
7852 cursor c_unique_EJP(l_table_alias varchar2) is
7853 select distinct cpe.information1,
7854 cpe.information2,
7855 cpe.information3,
7856 cpe.table_route_id
7857 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
7858 pqh_table_route tr
7859 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7860 and cpe.table_route_id = tr.table_route_id
7861 -- and tr.where_clause = l_BEN_ELIG_JOB_PRTE_F
7862 and tr.table_alias = l_table_alias
7863 and cpe.number_of_copies = 1 -- ADDITION
7864 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
7865 order by information1, information2; --added for bug: 5151945
7866 --
7867 --
7868 cursor c_EJP_min_max_dates(c_table_route_id number,
7869 c_information1 number) is
7870 select
7871 min(cpe.information2) min_esd,
7872 max(cpe.information3) min_eed
7873 from ben_copy_entity_results cpe
7874 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7875 and cpe.table_route_id = c_table_route_id
7876 and cpe.information1 = c_information1 ;
7877 --
7878 cursor c_EJP(c_table_route_id number,
7879 c_information1 number,
7880 c_information2 date,
7881 c_information3 date ) is
7882 select
7883 cpe.*
7884 from ben_copy_entity_results cpe
7885 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7886 and cpe.table_route_id = c_table_route_id
7887 and cpe.information1 = c_information1
7888 and cpe.information2 = c_information2
7889 and cpe.information3 = c_information3
7890 and rownum = 1 ;
7891 -- Date Track target record
7892 cursor c_find_EJP_in_target(
7893 c_effective_start_date date,
7894 c_effective_end_date date,
7895 c_business_group_id number,
7896 c_new_pk_id number) is
7897 select
7898 EJP.elig_job_prte_id new_value
7899 from BEN_ELIG_JOB_PRTE_F EJP
7900 where
7901 EJP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
7902 EJP.JOB_ID = l_JOB_ID and
7903 EJP.ORDR_NUM = l_ORDR_NUM and
7904 EJP.business_group_id = c_business_group_id
7905 and EJP.elig_job_prte_id <> c_new_pk_id
7906 and c_effective_start_date between effective_start_date
7907 and effective_end_date ;
7908 --END TEMPIK
7909 /*TEMPIK
7910 and exists ( select null
7911 from BEN_ELIG_JOB_PRTE_F EJP1
7912 where
7913 EJP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
7914 EJP1.JOB_ID = l_JOB_ID and
7915 EJP1.ORDR_NUM = l_ORDR_NUM and
7916 EJP1.business_group_id = c_business_group_id
7917 and EJP1.effective_start_date <= c_effective_start_date )
7918 and exists ( select null
7919 from BEN_ELIG_JOB_PRTE_F EJP2
7920 where
7921 EJP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
7922 EJP2.JOB_ID = l_JOB_ID and
7923 EJP2.ORDR_NUM = l_ORDR_NUM and
7924 EJP2.business_group_id = c_business_group_id
7925 and EJP2.effective_end_date >= c_effective_end_date )
7926 ;
7927 TEMPIK */
7928 --TEMPIK
7929 l_dt_rec_found boolean ;
7930 --END TEMPIK
7931 --
7932
7933 --UPD START
7934 --
7935 l_update boolean := false ;
7936 l_datetrack_mode varchar2(80) := hr_api.g_update;
7937 l_process_date date;
7938 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
7939 --
7940 --UPD END
7941 l_current_pk_id number := null ;
7942
7943 l_prev_pk_id number := null ;
7944 l_first_rec boolean := true ;
7945 r_EJP c_EJP%rowtype;
7946 l_elig_job_prte_id number ;
7947 l_object_version_number number ;
7948 l_effective_start_date date ;
7949 l_effective_end_date date ;
7950 l_prefix pqh_copy_entity_attribs.information1%type := null;
7951 l_suffix pqh_copy_entity_attribs.information1%type := null;
7952 l_new_value number(15);
7953 l_object_found_in_target boolean := false ;
7954 l_min_esd date;
7955 l_max_eed date;
7956 l_effective_date date;
7957 --
7958 begin
7959 -- Initialization
7960 l_object_found_in_target := false ;
7961 -- End Initialization
7962 -- Derive the prefix - sufix
7963 if p_prefix_suffix_cd = 'PREFIX' then
7964 l_prefix := p_prefix_suffix_text ;
7965 elsif p_prefix_suffix_cd = 'SUFFIX' then
7966 l_suffix := p_prefix_suffix_text ;
7967 else
7968 l_prefix := null ;
7969 l_suffix := null ;
7970 end if ;
7971 -- End Prefix Sufix derivation
7972 for r_EJP_unique in c_unique_EJP('EJP') loop
7973
7974 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
7975 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7976 r_EJP_unique.information3 >=
7977 ben_pd_copy_to_ben_one.g_copy_effective_date)
7978 ) then
7979 --
7980 hr_utility.set_location(' r_EJP_unique.table_route_id '||r_EJP_unique.table_route_id,10);
7981 hr_utility.set_location(' r_EJP_unique.information1 '||r_EJP_unique.information1,10);
7982 hr_utility.set_location( 'r_EJP_unique.information2 '||r_EJP_unique.information2,10);
7983 hr_utility.set_location( 'r_EJP_unique.information3 '||r_EJP_unique.information3,10);
7984 -- If reuse objects flag is 'Y' then check for the object in the target business group
7985 -- if found insert the record into PLSql table and exit the loop else try create the
7986 -- object in the target business group
7987 --
7988 l_object_found_in_target := false ;
7989 --UPD START
7990 l_update := false;
7991 l_process_date := p_effective_date;
7992 l_dml_operation:= r_EJP_unique.dml_operation ;
7993 /**********************moved from below **********************/
7994 open c_EJP(r_EJP_unique.table_route_id,
7995 r_EJP_unique.information1,
7996 r_EJP_unique.information2,
7997 r_EJP_unique.information3 ) ;
7998 --
7999 fetch c_EJP into r_EJP ;
8000 --
8001 close c_EJP ;
8002 --
8003 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EJP.INFORMATION263,l_dml_operation);
8004 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
8005 l_JOB_ID := r_EJP.information176;
8006 else
8007 l_JOB_ID := r_EJP.information174;
8008 end if;
8009 --
8010 l_ORDR_NUM := r_EJP.information260 ;
8011
8012
8013 /**********************************************************/
8014 --
8015 if l_dml_operation = 'UPDATE' then
8016 --
8017 l_object_found_in_target := TRUE;
8018 --
8019 if l_process_date between r_EJP_unique.information2 and r_EJP_unique.information3 then
8020 l_update := true;
8021 if r_EJP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
8022 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_JOB_PRTE_ID' then
8023 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_JOB_PRTE_ID' ;
8024 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EJP_unique.information1 ;
8025 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EJP_unique.information1 ;
8026 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
8027 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EJP_unique.table_route_id;
8028 --
8029 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
8030 --
8031 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
8032 --
8033 -- log_data('EJP',l_new_value,l_prefix || r_EJP_unique.name|| l_suffix,'REUSED');
8034 --
8035 end if ;
8036 hr_utility.set_location( 'found record for update',10);
8037 --
8038 else
8039 --
8040 l_update := false;
8041 --
8042 end if;
8043 else
8044 --
8045 --UPD END
8046 l_min_esd := null ;
8047 l_max_eed := null ;
8048 open c_EJP_min_max_dates(r_EJP_unique.table_route_id, r_EJP_unique.information1 ) ;
8049 fetch c_EJP_min_max_dates into l_min_esd,l_max_eed ;
8050 --
8051
8052 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8053 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
8054 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
8055 end if;
8056 l_min_esd := greatest(l_min_esd,r_EJP_unique.information2);
8057 /**********************moved up from here **********************
8058 open c_EJP(r_EJP_unique.table_route_id,
8059 r_EJP_unique.information1,
8060 r_EJP_unique.information2,
8061 r_EJP_unique.information3 ) ;
8062 --
8063 fetch c_EJP into r_EJP ;
8064 --
8065 close c_EJP ;
8066 --
8067 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EJP.INFORMATION263,l_dml_operation);
8068
8069 **********************************************************/
8070
8071
8072 if l_JOB_ID is null then
8073 close c_EJP_min_max_dates;
8074 --
8075 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
8076 ,p_parent_pk_id => r_EJP.information263
8077 ,p_copy_entity_txn_id => p_copy_entity_txn_id
8078 ,p_child_table_alias => 'EJP'
8079 ,p_child_data => r_EJP.information173 );
8080
8081 --
8082 else
8083 if p_reuse_object_flag = 'Y' then
8084 if c_EJP_min_max_dates%found then
8085 -- cursor to find the object
8086 open c_find_EJP_in_target( l_min_esd,l_max_eed,
8087 p_target_business_group_id, nvl(l_elig_job_prte_id, -999) ) ;
8088 fetch c_find_EJP_in_target into l_new_value ;
8089 if c_find_EJP_in_target%found then
8090 --
8091 --TEMPIK
8092 l_dt_rec_found := dt_api.check_min_max_dates
8093 (p_base_table_name => 'BEN_ELIG_JOB_PRTE_F',
8094 p_base_key_column => 'ELIG_JOB_PRTE_ID',
8095 p_base_key_value => l_new_value,
8096 p_from_date => l_min_esd,
8097 p_to_date => l_max_eed );
8098 if l_dt_rec_found THEN
8099 --END TEMPIK
8100 if r_EJP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
8101 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_JOB_PRTE_ID' then
8102 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_JOB_PRTE_ID' ;
8103 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EJP_unique.information1 ;
8104 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
8105 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
8106 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EJP_unique.table_route_id;
8107 --
8108 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
8109 --
8110 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
8111 end if ;
8112 --
8113 l_object_found_in_target := true ;
8114 --TEMPIK
8115 end if; -- l_dt_rec_found
8116 --END TEMPIK
8117 end if;
8118 close c_find_EJP_in_target ;
8119 --
8120 end if;
8121 end if ;
8122 --
8123 close c_EJP_min_max_dates ;
8124
8125 end if ; -- -- bug 4565106
8126 end if; --if p_dml_operation
8127 --
8128 if ( not l_object_found_in_target OR l_update ) and l_job_id is not null then
8129
8130 --
8131 l_current_pk_id := r_EJP.information1;
8132 --
8133 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
8134 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
8135 --
8136 if l_current_pk_id = l_prev_pk_id then
8137 --
8138 l_first_rec := false ;
8139 --
8140 else
8141 --
8142 l_first_rec := true ;
8143 --
8144 end if ;
8145 --
8146
8147 l_effective_date := r_EJP.information2;
8148 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8149 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
8150 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
8151 end if;
8152
8153 if l_first_rec and not l_update then
8154 -- Call Create routine.
8155 hr_utility.set_location(' BEN_ELIG_JOB_PRTE_F CREATE_ELIGY_JOB_PRTE ',20);
8156 BEN_ELIGY_JOB_PRTE_API.CREATE_ELIGY_JOB_PRTE(
8157 --
8158 P_VALIDATE => false
8159 ,P_EFFECTIVE_DATE => l_effective_date
8160 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
8161 --
8162 ,P_EJP_ATTRIBUTE1 => r_EJP.INFORMATION111
8163 ,P_EJP_ATTRIBUTE10 => r_EJP.INFORMATION120
8164 ,P_EJP_ATTRIBUTE11 => r_EJP.INFORMATION121
8165 ,P_EJP_ATTRIBUTE12 => r_EJP.INFORMATION122
8166 ,P_EJP_ATTRIBUTE13 => r_EJP.INFORMATION123
8167 ,P_EJP_ATTRIBUTE14 => r_EJP.INFORMATION124
8168 ,P_EJP_ATTRIBUTE15 => r_EJP.INFORMATION125
8169 ,P_EJP_ATTRIBUTE16 => r_EJP.INFORMATION126
8170 ,P_EJP_ATTRIBUTE17 => r_EJP.INFORMATION127
8171 ,P_EJP_ATTRIBUTE18 => r_EJP.INFORMATION128
8172 ,P_EJP_ATTRIBUTE19 => r_EJP.INFORMATION129
8173 ,P_EJP_ATTRIBUTE2 => r_EJP.INFORMATION112
8174 ,P_EJP_ATTRIBUTE20 => r_EJP.INFORMATION130
8175 ,P_EJP_ATTRIBUTE21 => r_EJP.INFORMATION131
8176 ,P_EJP_ATTRIBUTE22 => r_EJP.INFORMATION132
8177 ,P_EJP_ATTRIBUTE23 => r_EJP.INFORMATION133
8178 ,P_EJP_ATTRIBUTE24 => r_EJP.INFORMATION134
8179 ,P_EJP_ATTRIBUTE25 => r_EJP.INFORMATION135
8180 ,P_EJP_ATTRIBUTE26 => r_EJP.INFORMATION136
8181 ,P_EJP_ATTRIBUTE27 => r_EJP.INFORMATION137
8182 ,P_EJP_ATTRIBUTE28 => r_EJP.INFORMATION138
8183 ,P_EJP_ATTRIBUTE29 => r_EJP.INFORMATION139
8184 ,P_EJP_ATTRIBUTE3 => r_EJP.INFORMATION113
8185 ,P_EJP_ATTRIBUTE30 => r_EJP.INFORMATION140
8186 ,P_EJP_ATTRIBUTE4 => r_EJP.INFORMATION114
8187 ,P_EJP_ATTRIBUTE5 => r_EJP.INFORMATION115
8188 ,P_EJP_ATTRIBUTE6 => r_EJP.INFORMATION116
8189 ,P_EJP_ATTRIBUTE7 => r_EJP.INFORMATION117
8190 ,P_EJP_ATTRIBUTE8 => r_EJP.INFORMATION118
8191 ,P_EJP_ATTRIBUTE9 => r_EJP.INFORMATION119
8192 ,P_EJP_ATTRIBUTE_CATEGORY => r_EJP.INFORMATION110
8193 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
8194 ,P_ELIG_JOB_PRTE_ID => l_elig_job_prte_id
8195 ,P_EXCLD_FLAG => r_EJP.INFORMATION11
8196 ,P_JOB_ID => l_JOB_ID
8197 ,P_ORDR_NUM => r_EJP.INFORMATION260
8198 --
8199 -- ****** END CHANGE LINES
8200
8201 --
8202
8203 ,P_EFFECTIVE_START_DATE => l_effective_start_date
8204 ,P_EFFECTIVE_END_DATE => l_effective_end_date
8205 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8206 ,P_CRITERIA_SCORE => r_ejp.INFORMATION295
8207 ,P_CRITERIA_WEIGHT => r_ejp.INFORMATION296
8208 );
8209 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8210 -- Update all relevent cer records with new pk_id
8211 hr_utility.set_location('Before plsql table ',222);
8212 hr_utility.set_location('new_value id '||l_elig_job_prte_id,222);
8213 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_JOB_PRTE_ID' ;
8214 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EJP.information1 ;
8215 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_JOB_PRTE_ID ;
8216 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
8217 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EJP_unique.table_route_id;
8218 hr_utility.set_location('After plsql table ',222);
8219 --
8220 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
8221 --
8222 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
8223 --
8224 else
8225 --
8226 -- Call Update routine for the pk_id created in prev run .
8227 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8228 hr_utility.set_location(' BEN_ELIG_JOB_PRTE_F UPDATE_ELIGY_JOB_PRTE ',30);
8229 --UPD START
8230 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
8231 --
8232 if l_update then
8233 --
8234 l_datetrack_mode := r_EJP.datetrack_mode ;
8235 --
8236 get_dt_modes(
8237 p_effective_date => l_process_date,
8238 p_effective_end_date => r_EJP.information3,
8239 p_effective_start_date => r_EJP.information2,
8240 p_dml_operation => r_EJP.dml_operation,
8241 p_datetrack_mode => l_datetrack_mode );
8242 -- p_update => l_update
8243 --
8244 l_effective_date := l_process_date;
8245 l_ELIG_JOB_PRTE_ID := r_EJP.information1;
8246 l_object_version_number := r_EJP.information265;
8247 --
8248 end if;
8249 --
8250 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
8251 --
8252 IF l_update OR l_dml_operation <> 'UPDATE' THEN
8253 --UPD END
8254
8255
8256 BEN_ELIGY_JOB_PRTE_API.UPDATE_ELIGY_JOB_PRTE(
8257 --
8258 P_VALIDATE => false
8259 ,P_EFFECTIVE_DATE => l_effective_date
8260 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
8261 --
8262 ,P_EJP_ATTRIBUTE1 => r_EJP.INFORMATION111
8263 ,P_EJP_ATTRIBUTE10 => r_EJP.INFORMATION120
8264 ,P_EJP_ATTRIBUTE11 => r_EJP.INFORMATION121
8265 ,P_EJP_ATTRIBUTE12 => r_EJP.INFORMATION122
8266 ,P_EJP_ATTRIBUTE13 => r_EJP.INFORMATION123
8267 ,P_EJP_ATTRIBUTE14 => r_EJP.INFORMATION124
8268 ,P_EJP_ATTRIBUTE15 => r_EJP.INFORMATION125
8269 ,P_EJP_ATTRIBUTE16 => r_EJP.INFORMATION126
8270 ,P_EJP_ATTRIBUTE17 => r_EJP.INFORMATION127
8271 ,P_EJP_ATTRIBUTE18 => r_EJP.INFORMATION128
8272 ,P_EJP_ATTRIBUTE19 => r_EJP.INFORMATION129
8273 ,P_EJP_ATTRIBUTE2 => r_EJP.INFORMATION112
8274 ,P_EJP_ATTRIBUTE20 => r_EJP.INFORMATION130
8275 ,P_EJP_ATTRIBUTE21 => r_EJP.INFORMATION131
8276 ,P_EJP_ATTRIBUTE22 => r_EJP.INFORMATION132
8277 ,P_EJP_ATTRIBUTE23 => r_EJP.INFORMATION133
8278 ,P_EJP_ATTRIBUTE24 => r_EJP.INFORMATION134
8279 ,P_EJP_ATTRIBUTE25 => r_EJP.INFORMATION135
8280 ,P_EJP_ATTRIBUTE26 => r_EJP.INFORMATION136
8281 ,P_EJP_ATTRIBUTE27 => r_EJP.INFORMATION137
8282 ,P_EJP_ATTRIBUTE28 => r_EJP.INFORMATION138
8283 ,P_EJP_ATTRIBUTE29 => r_EJP.INFORMATION139
8284 ,P_EJP_ATTRIBUTE3 => r_EJP.INFORMATION113
8285 ,P_EJP_ATTRIBUTE30 => r_EJP.INFORMATION140
8286 ,P_EJP_ATTRIBUTE4 => r_EJP.INFORMATION114
8287 ,P_EJP_ATTRIBUTE5 => r_EJP.INFORMATION115
8288 ,P_EJP_ATTRIBUTE6 => r_EJP.INFORMATION116
8289 ,P_EJP_ATTRIBUTE7 => r_EJP.INFORMATION117
8290 ,P_EJP_ATTRIBUTE8 => r_EJP.INFORMATION118
8291 ,P_EJP_ATTRIBUTE9 => r_EJP.INFORMATION119
8292 ,P_EJP_ATTRIBUTE_CATEGORY => r_EJP.INFORMATION110
8293 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
8294 ,P_ELIG_JOB_PRTE_ID => l_elig_job_prte_id
8295 ,P_EXCLD_FLAG => r_EJP.INFORMATION11
8296 ,P_JOB_ID => l_JOB_ID
8297 ,P_ORDR_NUM => r_EJP.INFORMATION260
8298 --
8299 -- ****** END CHANGE LINES
8300
8301 --
8302 ,P_EFFECTIVE_START_DATE => l_effective_start_date
8303 ,P_EFFECTIVE_END_DATE => l_effective_end_date
8304 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8305 ,P_DATETRACK_MODE => l_datetrack_mode
8306 ,P_CRITERIA_SCORE => r_ejp.INFORMATION295
8307 ,P_CRITERIA_WEIGHT => r_ejp.INFORMATION296
8308 );
8309 end if; -- l_update
8310 --
8311 end if;
8312 --
8313 -- Delete the row if it is end dated.
8314 --
8315 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
8316 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
8317 trunc(l_max_eed) = trunc(r_EJP.information3)) then
8318 --
8319 BEN_ELIGY_JOB_PRTE_API.delete_ELIGY_JOB_PRTE(
8320 --
8321 p_validate => false
8322 ,p_elig_job_prte_id => l_elig_job_prte_id
8323 ,p_effective_start_date => l_effective_start_date
8324 ,p_effective_end_date => l_effective_end_date
8325 ,p_object_version_number => l_object_version_number
8326 ,p_effective_date => l_max_eed
8327 ,p_datetrack_mode => hr_api.g_delete
8328 --
8329 );
8330 --
8331 end if;
8332 --
8333 l_prev_pk_id := l_current_pk_id ;
8334 --
8335 -- end if; -- bug 4565106
8336 --
8337 end if;
8338 --
8339 end if;
8340 --
8341 end loop;
8342 --
8343 exception when others then
8344 --
8345 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EJP',r_EJP.information5 ) ;
8346 --
8347 end create_EJP_rows;
8348
8349
8350
8351 --
8352 ---------------------------------------------------------------
8353 ----------------------< create_ELU_rows >-----------------------
8354 ---------------------------------------------------------------
8355 --
8356 procedure create_ELU_rows
8357 (
8358 p_validate in number default 0
8359 ,p_copy_entity_txn_id in number
8360 ,p_effective_date in date
8361 ,p_prefix_suffix_text in varchar2 default null
8362 ,p_reuse_object_flag in varchar2 default null
8363 ,p_target_business_group_id in varchar2 default null
8364 ,p_prefix_suffix_cd in varchar2 default null
8365 ) is
8366 --
8367 l_ELIGY_PRFL_ID number;
8368 l_LBR_MMBR_FLAG varchar2(30); --IK Added
8369 cursor c_unique_ELU(l_table_alias varchar2) is
8370 select distinct cpe.information1,
8371 cpe.information2,
8372 cpe.information3,
8373 cpe.table_route_id
8374 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
8375 pqh_table_route tr
8376 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8377 and cpe.table_route_id = tr.table_route_id
8378 -- and tr.where_clause = l_BEN_ELIG_LBR_MMBR_PRTE_F
8379 and tr.table_alias = l_table_alias
8380 and cpe.number_of_copies = 1 -- ADDITION
8381 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
8382 order by information1, information2; --added for bug: 5151945
8383 --
8384 --
8385 cursor c_ELU_min_max_dates(c_table_route_id number,
8386 c_information1 number) is
8387 select
8388 min(cpe.information2) min_esd,
8389 max(cpe.information3) min_eed
8390 from ben_copy_entity_results cpe
8391 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8392 and cpe.table_route_id = c_table_route_id
8393 and cpe.information1 = c_information1 ;
8394 --
8395 cursor c_ELU(c_table_route_id number,
8396 c_information1 number,
8397 c_information2 date,
8398 c_information3 date ) is
8399 select
8400 cpe.*
8401 from ben_copy_entity_results cpe
8402 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8403 and cpe.table_route_id = c_table_route_id
8404 and cpe.information1 = c_information1
8405 and cpe.information2 = c_information2
8406 and cpe.information3 = c_information3
8407 and rownum = 1 ;
8408 -- Date Track target record
8409 cursor c_find_ELU_in_target(
8410 c_effective_start_date date,
8411 c_effective_end_date date,
8412 c_business_group_id number,
8413 c_new_pk_id number) is
8414 select
8415 ELU.elig_lbr_mmbr_prte_id new_value
8416 from BEN_ELIG_LBR_MMBR_PRTE_F ELU
8417 where
8418 ELU.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
8419 ELU.LBR_MMBR_FLAG = l_LBR_MMBR_FLAG and -- IK Added
8420 ELU.business_group_id = c_business_group_id
8421 and ELU.elig_lbr_mmbr_prte_id <> c_new_pk_id
8422 and c_effective_start_date between effective_start_date
8423 and effective_end_date ;
8424 --END TEMPIK
8425 /*TEMPIK
8426 and exists ( select null
8427 from BEN_ELIG_LBR_MMBR_PRTE_F ELU1
8428 where
8429 ELU1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
8430 ELU1.LBR_MMBR_FLAG = l_LBR_MMBR_FLAG and
8431 ELU1.business_group_id = c_business_group_id
8432 and ELU1.effective_start_date <= c_effective_start_date )
8433 and exists ( select null
8434 from BEN_ELIG_LBR_MMBR_PRTE_F ELU2
8435 where
8436 ELU2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
8437 ELU2.LBR_MMBR_FLAG = l_LBR_MMBR_FLAG and
8438 ELU2.business_group_id = c_business_group_id
8439 and ELU2.effective_end_date >= c_effective_end_date )
8440 ;
8441 TEMPIK */
8442 --TEMPIK
8443 l_dt_rec_found boolean ;
8444 --END TEMPIK
8445 --
8446
8447 --UPD START
8448 --
8449 l_update boolean := false ;
8450 l_datetrack_mode varchar2(80) := hr_api.g_update;
8451 l_process_date date;
8452 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
8453 --
8454 --UPD END
8455 l_current_pk_id number := null ;
8456
8457 l_prev_pk_id number := null ;
8458 l_first_rec boolean := true ;
8459 r_ELU c_ELU%rowtype;
8460 l_elig_lbr_mmbr_prte_id number ;
8461 l_object_version_number number ;
8462 l_effective_start_date date ;
8463 l_effective_end_date date ;
8464 l_prefix pqh_copy_entity_attribs.information1%type := null;
8465 l_suffix pqh_copy_entity_attribs.information1%type := null;
8466 l_new_value number(15);
8467 l_object_found_in_target boolean := false ;
8468 l_min_esd date;
8469 l_max_eed date;
8470 l_effective_date date;
8471 --
8472 begin
8473 -- Initialization
8474 l_object_found_in_target := false ;
8475 -- End Initialization
8476 -- Derive the prefix - sufix
8477 if p_prefix_suffix_cd = 'PREFIX' then
8478 l_prefix := p_prefix_suffix_text ;
8479 elsif p_prefix_suffix_cd = 'SUFFIX' then
8480 l_suffix := p_prefix_suffix_text ;
8481 else
8482 l_prefix := null ;
8483 l_suffix := null ;
8484 end if ;
8485 -- End Prefix Sufix derivation
8486 for r_ELU_unique in c_unique_ELU('ELU') loop
8487
8488 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
8489 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8490 r_ELU_unique.information3 >=
8491 ben_pd_copy_to_ben_one.g_copy_effective_date)
8492 ) then
8493 --
8494 hr_utility.set_location(' r_ELU_unique.table_route_id '||r_ELU_unique.table_route_id,10);
8495 hr_utility.set_location(' r_ELU_unique.information1 '||r_ELU_unique.information1,10);
8496 hr_utility.set_location( 'r_ELU_unique.information2 '||r_ELU_unique.information2,10);
8497 hr_utility.set_location( 'r_ELU_unique.information3 '||r_ELU_unique.information3,10);
8498 -- If reuse objects flag is 'Y' then check for the object in the target business group
8499 -- if found insert the record into PLSql table and exit the loop else try create the
8500 -- object in the target business group
8501 --
8502 l_object_found_in_target := false ;
8503 --UPD START
8504 l_update := false;
8505 l_process_date := p_effective_date;
8506 l_dml_operation:= r_ELU_unique.dml_operation ;
8507 --
8508 /**********************moved from below **********************/
8509 open c_ELU(r_ELU_unique.table_route_id,
8510 r_ELU_unique.information1,
8511 r_ELU_unique.information2,
8512 r_ELU_unique.information3 ) ;
8513 --
8514 fetch c_ELU into r_ELU ;
8515 --
8516 close c_ELU ;
8517 --
8518 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ELU.INFORMATION263,l_dml_operation);--changed from 11
8519 l_LBR_MMBR_FLAG := r_ELU.INFORMATION12 ; -- IK Added
8520 /**********************************************************/
8521 if l_dml_operation = 'UPDATE' then
8522 --
8523 l_object_found_in_target := TRUE;
8524 --
8525 if l_process_date between r_ELU_unique.information2 and r_ELU_unique.information3 then
8526 l_update := true;
8527 if r_ELU_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
8528 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_LBR_MMBR_PRTE_ID' then
8529 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LBR_MMBR_PRTE_ID' ;
8530 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELU_unique.information1 ;
8531 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ELU_unique.information1 ;
8532 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
8533 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELU_unique.table_route_id;
8534 --
8535 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
8536 --
8537 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
8538 --
8539 -- log_data('ELU',l_new_value,l_prefix || r_ELU_unique.name|| l_suffix,'REUSED');
8540 --
8541 end if ;
8542 hr_utility.set_location( 'found record for update',10);
8543 --
8544 else
8545 --
8546 l_update := false;
8547 --
8548 end if;
8549 else
8550 --
8551 --UPD END
8552 l_min_esd := null ;
8553 l_max_eed := null ;
8554 open c_ELU_min_max_dates(r_ELU_unique.table_route_id, r_ELU_unique.information1 ) ;
8555 fetch c_ELU_min_max_dates into l_min_esd,l_max_eed ;
8556 --
8557
8558 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8559 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
8560 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
8561 end if;
8562 l_min_esd := greatest(l_min_esd,r_ELU_unique.information2);
8563 /**********************moved up from here **********************
8564 open c_ELU(r_ELU_unique.table_route_id,
8565 r_ELU_unique.information1,
8566 r_ELU_unique.information2,
8567 r_ELU_unique.information3 ) ;
8568 --
8569 fetch c_ELU into r_ELU ;
8570 --
8571 close c_ELU ;
8572 --
8573 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ELU.INFORMATION263,l_dml_operation);--changed from 11
8574 l_LBR_MMBR_FLAG := r_ELU.INFORMATION12 ; -- IK Added
8575 **********************************************************/
8576
8577 if p_reuse_object_flag = 'Y' then
8578 if c_ELU_min_max_dates%found then
8579 -- cursor to find the object
8580 open c_find_ELU_in_target( l_min_esd,l_max_eed,
8581 p_target_business_group_id, nvl(l_elig_lbr_mmbr_prte_id, -999) ) ;
8582 fetch c_find_ELU_in_target into l_new_value ;
8583 if c_find_ELU_in_target%found then
8584 --
8585 --TEMPIK
8586 l_dt_rec_found := dt_api.check_min_max_dates
8587 (p_base_table_name => 'BEN_ELIG_LBR_MMBR_PRTE_F',
8588 p_base_key_column => 'ELIG_LBR_MMBR_PRTE_ID',
8589 p_base_key_value => l_new_value,
8590 p_from_date => l_min_esd,
8591 p_to_date => l_max_eed );
8592 if l_dt_rec_found THEN
8593 --END TEMPIK
8594 if r_ELU_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
8595 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_LBR_MMBR_PRTE_ID' then
8596 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LBR_MMBR_PRTE_ID' ;
8597 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELU_unique.information1 ;
8598 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
8599 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
8600 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELU_unique.table_route_id;
8601 --
8602 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
8603 --
8604 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
8605 end if ;
8606 --
8607 l_object_found_in_target := true ;
8608 --TEMPIK
8609 end if; -- l_dt_rec_found
8610 --END TEMPIK
8611 end if;
8612 close c_find_ELU_in_target ;
8613 --
8614 end if;
8615 end if ;
8616 --
8617 close c_ELU_min_max_dates ;
8618 end if; --if p_dml_operation
8619 --
8620 if not l_object_found_in_target OR l_update then
8621
8622 --
8623 l_current_pk_id := r_ELU.information1;
8624 --
8625 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
8626 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
8627 --
8628 if l_current_pk_id = l_prev_pk_id then
8629 --
8630 l_first_rec := false ;
8631 --
8632 else
8633 --
8634 l_first_rec := true ;
8635 --
8636 end if ;
8637 --
8638
8639 l_effective_date := r_ELU.information2;
8640 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8641 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
8642 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
8643 end if;
8644
8645 if l_first_rec and not l_update then
8646 -- Call Create routine.
8647 hr_utility.set_location(' BEN_ELIG_LBR_MMBR_PRTE_F CREATE_ELIG_LBR_MMBR_PRTE ',20);
8648 BEN_ELIG_LBR_MMBR_PRTE_API.CREATE_ELIG_LBR_MMBR_PRTE(
8649 --
8650 P_VALIDATE => false
8651 ,P_EFFECTIVE_DATE => l_effective_date
8652 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
8653 --
8654 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
8655 ,P_ELIG_LBR_MMBR_PRTE_ID => l_elig_lbr_mmbr_prte_id
8656 ,P_ELU_ATTRIBUTE1 => r_ELU.INFORMATION111
8657 ,P_ELU_ATTRIBUTE10 => r_ELU.INFORMATION120
8658 ,P_ELU_ATTRIBUTE11 => r_ELU.INFORMATION121
8659 ,P_ELU_ATTRIBUTE12 => r_ELU.INFORMATION122
8660 ,P_ELU_ATTRIBUTE13 => r_ELU.INFORMATION123
8661 ,P_ELU_ATTRIBUTE14 => r_ELU.INFORMATION124
8662 ,P_ELU_ATTRIBUTE15 => r_ELU.INFORMATION125
8663 ,P_ELU_ATTRIBUTE16 => r_ELU.INFORMATION126
8664 ,P_ELU_ATTRIBUTE17 => r_ELU.INFORMATION127
8665 ,P_ELU_ATTRIBUTE18 => r_ELU.INFORMATION128
8666 ,P_ELU_ATTRIBUTE19 => r_ELU.INFORMATION129
8667 ,P_ELU_ATTRIBUTE2 => r_ELU.INFORMATION112
8668 ,P_ELU_ATTRIBUTE20 => r_ELU.INFORMATION130
8669 ,P_ELU_ATTRIBUTE21 => r_ELU.INFORMATION131
8670 ,P_ELU_ATTRIBUTE22 => r_ELU.INFORMATION132
8671 ,P_ELU_ATTRIBUTE23 => r_ELU.INFORMATION133
8672 ,P_ELU_ATTRIBUTE24 => r_ELU.INFORMATION134
8673 ,P_ELU_ATTRIBUTE25 => r_ELU.INFORMATION135
8674 ,P_ELU_ATTRIBUTE26 => r_ELU.INFORMATION136
8675 ,P_ELU_ATTRIBUTE27 => r_ELU.INFORMATION137
8676 ,P_ELU_ATTRIBUTE28 => r_ELU.INFORMATION138
8677 ,P_ELU_ATTRIBUTE29 => r_ELU.INFORMATION139
8678 ,P_ELU_ATTRIBUTE3 => r_ELU.INFORMATION113
8679 ,P_ELU_ATTRIBUTE30 => r_ELU.INFORMATION140
8680 ,P_ELU_ATTRIBUTE4 => r_ELU.INFORMATION114
8681 ,P_ELU_ATTRIBUTE5 => r_ELU.INFORMATION115
8682 ,P_ELU_ATTRIBUTE6 => r_ELU.INFORMATION116
8683 ,P_ELU_ATTRIBUTE7 => r_ELU.INFORMATION117
8684 ,P_ELU_ATTRIBUTE8 => r_ELU.INFORMATION118
8685 ,P_ELU_ATTRIBUTE9 => r_ELU.INFORMATION119
8686 ,P_ELU_ATTRIBUTE_CATEGORY => r_ELU.INFORMATION110
8687 ,P_EXCLD_FLAG => r_ELU.INFORMATION11
8688 ,P_LBR_MMBR_FLAG => r_ELU.INFORMATION12
8689 ,P_ORDR_NUM => r_ELU.INFORMATION260
8690 --
8691 -- ****** END CHANGE LINES
8692
8693 --
8694
8695 ,P_EFFECTIVE_START_DATE => l_effective_start_date
8696 ,P_EFFECTIVE_END_DATE => l_effective_end_date
8697 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8698 ,P_CRITERIA_SCORE => r_elu.INFORMATION295
8699 ,P_CRITERIA_WEIGHT => r_elu.INFORMATION296
8700 );
8701 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8702 -- Update all relevent cer records with new pk_id
8703 hr_utility.set_location('Before plsql table ',222);
8704 hr_utility.set_location('new_value id '||l_elig_lbr_mmbr_prte_id,222);
8705 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LBR_MMBR_PRTE_ID' ;
8706 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELU.information1 ;
8707 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_LBR_MMBR_PRTE_ID ;
8708 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
8709 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELU_unique.table_route_id;
8710 hr_utility.set_location('After plsql table ',222);
8711 --
8712 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
8713 --
8714 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
8715 --
8716 else
8717 --
8718 -- Call Update routine for the pk_id created in prev run .
8719 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8720 hr_utility.set_location(' BEN_ELIG_LBR_MMBR_PRTE_F UPDATE_ELIG_LBR_MMBR_PRTE ',30);
8721 --UPD START
8722 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
8723 --
8724 if l_update then
8725 --
8726 l_datetrack_mode := r_ELU.datetrack_mode ;
8727 --
8728 get_dt_modes(
8729 p_effective_date => l_process_date,
8730 p_effective_end_date => r_ELU.information3,
8731 p_effective_start_date => r_ELU.information2,
8732 p_dml_operation => r_ELU.dml_operation,
8733 p_datetrack_mode => l_datetrack_mode );
8734 -- p_update => l_update
8735 --
8736 l_effective_date := l_process_date;
8737 l_ELIG_LBR_MMBR_PRTE_ID := r_ELU.information1;
8738 l_object_version_number := r_ELU.information265;
8739 --
8740 end if;
8741 --
8742 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
8743 --
8744 IF l_update OR l_dml_operation <> 'UPDATE' THEN
8745 --UPD END
8746
8747
8748 BEN_ELIG_LBR_MMBR_PRTE_API.UPDATE_ELIG_LBR_MMBR_PRTE(
8749 --
8750 P_VALIDATE => false
8751 ,P_EFFECTIVE_DATE => l_effective_date
8752 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
8753 --
8754 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
8755 ,P_ELIG_LBR_MMBR_PRTE_ID => l_elig_lbr_mmbr_prte_id
8756 ,P_ELU_ATTRIBUTE1 => r_ELU.INFORMATION111
8757 ,P_ELU_ATTRIBUTE10 => r_ELU.INFORMATION120
8758 ,P_ELU_ATTRIBUTE11 => r_ELU.INFORMATION121
8759 ,P_ELU_ATTRIBUTE12 => r_ELU.INFORMATION122
8760 ,P_ELU_ATTRIBUTE13 => r_ELU.INFORMATION123
8761 ,P_ELU_ATTRIBUTE14 => r_ELU.INFORMATION124
8762 ,P_ELU_ATTRIBUTE15 => r_ELU.INFORMATION125
8763 ,P_ELU_ATTRIBUTE16 => r_ELU.INFORMATION126
8764 ,P_ELU_ATTRIBUTE17 => r_ELU.INFORMATION127
8765 ,P_ELU_ATTRIBUTE18 => r_ELU.INFORMATION128
8766 ,P_ELU_ATTRIBUTE19 => r_ELU.INFORMATION129
8767 ,P_ELU_ATTRIBUTE2 => r_ELU.INFORMATION112
8768 ,P_ELU_ATTRIBUTE20 => r_ELU.INFORMATION130
8769 ,P_ELU_ATTRIBUTE21 => r_ELU.INFORMATION131
8770 ,P_ELU_ATTRIBUTE22 => r_ELU.INFORMATION132
8771 ,P_ELU_ATTRIBUTE23 => r_ELU.INFORMATION133
8772 ,P_ELU_ATTRIBUTE24 => r_ELU.INFORMATION134
8773 ,P_ELU_ATTRIBUTE25 => r_ELU.INFORMATION135
8774 ,P_ELU_ATTRIBUTE26 => r_ELU.INFORMATION136
8775 ,P_ELU_ATTRIBUTE27 => r_ELU.INFORMATION137
8776 ,P_ELU_ATTRIBUTE28 => r_ELU.INFORMATION138
8777 ,P_ELU_ATTRIBUTE29 => r_ELU.INFORMATION139
8778 ,P_ELU_ATTRIBUTE3 => r_ELU.INFORMATION113
8779 ,P_ELU_ATTRIBUTE30 => r_ELU.INFORMATION140
8780 ,P_ELU_ATTRIBUTE4 => r_ELU.INFORMATION114
8781 ,P_ELU_ATTRIBUTE5 => r_ELU.INFORMATION115
8782 ,P_ELU_ATTRIBUTE6 => r_ELU.INFORMATION116
8783 ,P_ELU_ATTRIBUTE7 => r_ELU.INFORMATION117
8784 ,P_ELU_ATTRIBUTE8 => r_ELU.INFORMATION118
8785 ,P_ELU_ATTRIBUTE9 => r_ELU.INFORMATION119
8786 ,P_ELU_ATTRIBUTE_CATEGORY => r_ELU.INFORMATION110
8787 ,P_EXCLD_FLAG => r_ELU.INFORMATION11
8788 ,P_LBR_MMBR_FLAG => r_ELU.INFORMATION12
8789 ,P_ORDR_NUM => r_ELU.INFORMATION260
8790 --
8791 -- ****** END CHANGE LINES
8792
8793 --
8794 ,P_EFFECTIVE_START_DATE => l_effective_start_date
8795 ,P_EFFECTIVE_END_DATE => l_effective_end_date
8796 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8797 ,P_DATETRACK_MODE => l_datetrack_mode
8798 ,P_CRITERIA_SCORE => r_elu.INFORMATION295
8799 ,P_CRITERIA_WEIGHT => r_elu.INFORMATION296
8800 );
8801 end if; -- l_update
8802 --
8803 end if;
8804 --
8805 -- Delete the row if it is end dated.
8806 --
8807 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
8808 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
8809 trunc(l_max_eed) = trunc(r_ELU.information3)) then
8810 --
8811 BEN_ELIG_LBR_MMBR_PRTE_API.delete_ELIG_LBR_MMBR_PRTE(
8812 --
8813 p_validate => false
8814 ,p_elig_lbr_mmbr_prte_id => l_elig_lbr_mmbr_prte_id
8815 ,p_effective_start_date => l_effective_start_date
8816 ,p_effective_end_date => l_effective_end_date
8817 ,p_object_version_number => l_object_version_number
8818 ,p_effective_date => l_max_eed
8819 ,p_datetrack_mode => hr_api.g_delete
8820 --
8821 );
8822 --
8823 end if;
8824 --
8825 l_prev_pk_id := l_current_pk_id ;
8826 --
8827 end if;
8828 --
8829 end if;
8830 --
8831 end loop;
8832 --
8833 exception when others then
8834 --
8835 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ELU',r_ELU.information5 ) ;
8836 --
8837 end create_ELU_rows;
8838
8839
8840 --
8841 ---------------------------------------------------------------
8842 ----------------------< create_ELN_rows >-----------------------
8843 ---------------------------------------------------------------
8844 --
8845 procedure create_ELN_rows
8846 (
8847 p_validate in number default 0
8848 ,p_copy_entity_txn_id in number
8849 ,p_effective_date in date
8850 ,p_prefix_suffix_text in varchar2 default null
8851 ,p_reuse_object_flag in varchar2 default null
8852 ,p_target_business_group_id in varchar2 default null
8853 ,p_prefix_suffix_cd in varchar2 default null
8854 ) is
8855 --
8856 l_ELIGY_PRFL_ID number;
8857 l_ORGANIZATION_ID number; -- IK 9999 Padma Mapping Required
8858 cursor c_unique_ELN(l_table_alias varchar2) is
8859 select distinct cpe.information1,
8860 cpe.information2,
8861 cpe.information3,
8862 cpe.table_route_id
8863 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
8864 pqh_table_route tr
8865 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8866 and cpe.table_route_id = tr.table_route_id
8867 -- and tr.where_clause = l_BEN_ELIG_LGL_ENTY_PRTE_F
8868 and tr.table_alias = l_table_alias
8869 and cpe.number_of_copies = 1 -- ADDITION
8870 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
8871 order by information1, information2; --added for bug: 5151945
8872 --
8873 --
8874 cursor c_ELN_min_max_dates(c_table_route_id number,
8875 c_information1 number) is
8876 select
8877 min(cpe.information2) min_esd,
8878 max(cpe.information3) min_eed
8879 from ben_copy_entity_results cpe
8880 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8881 and cpe.table_route_id = c_table_route_id
8882 and cpe.information1 = c_information1 ;
8883 --
8884 cursor c_ELN(c_table_route_id number,
8885 c_information1 number,
8886 c_information2 date,
8887 c_information3 date ) is
8888 select
8889 cpe.*
8890 from ben_copy_entity_results cpe
8891 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8892 and cpe.table_route_id = c_table_route_id
8893 and cpe.information1 = c_information1
8894 and cpe.information2 = c_information2
8895 and cpe.information3 = c_information3
8896 and rownum = 1 ;
8897 -- Date Track target record
8898 cursor c_find_ELN_in_target(
8899 c_effective_start_date date,
8900 c_effective_end_date date,
8901 c_business_group_id number,
8902 c_new_pk_id number) is
8903 select
8904 ELN.elig_lgl_enty_prte_id new_value
8905 from BEN_ELIG_LGL_ENTY_PRTE_F ELN
8906 where
8907 ELN.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
8908 ELN.ORGANIZATION_ID = l_ORGANIZATION_ID and
8909 ELN.business_group_id = c_business_group_id
8910 and ELN.elig_lgl_enty_prte_id <> c_new_pk_id
8911 and c_effective_start_date between effective_start_date
8912 and effective_end_date ;
8913 --END TEMPIK
8914 /*TEMPIK
8915 and exists ( select null
8916 from BEN_ELIG_LGL_ENTY_PRTE_F ELN1
8917 where
8918 ELN1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
8919 ELN1.ORGANIZATION_ID = l_ORGANIZATION_ID and
8920 ELN1.business_group_id = c_business_group_id
8921 and ELN1.effective_start_date <= c_effective_start_date )
8922 and exists ( select null
8923 from BEN_ELIG_LGL_ENTY_PRTE_F ELN2
8924 where
8925 ELN2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
8926 ELN2.ORGANIZATION_ID = l_ORGANIZATION_ID and
8927 ELN2.business_group_id = c_business_group_id
8928 and ELN2.effective_end_date >= c_effective_end_date )
8929 ;
8930 TEMPIK */
8931 --TEMPIK
8932 l_dt_rec_found boolean ;
8933 --END TEMPIK
8934 --
8935
8936 --UPD START
8937 --
8938 l_update boolean := false ;
8939 l_datetrack_mode varchar2(80) := hr_api.g_update;
8940 l_process_date date;
8941 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
8942 --
8943 --UPD END
8944 l_current_pk_id number := null ;
8945
8946 l_prev_pk_id number := null ;
8947 l_first_rec boolean := true ;
8948 r_ELN c_ELN%rowtype;
8949 l_elig_lgl_enty_prte_id number ;
8950 l_object_version_number number ;
8951 l_effective_start_date date ;
8952 l_effective_end_date date ;
8953 l_prefix pqh_copy_entity_attribs.information1%type := null;
8954 l_suffix pqh_copy_entity_attribs.information1%type := null;
8955 l_new_value number(15);
8956 l_object_found_in_target boolean := false ;
8957 l_min_esd date;
8958 l_max_eed date;
8959 l_effective_date date;
8960 --
8961 begin
8962 -- Initialization
8963 l_object_found_in_target := false ;
8964 -- End Initialization
8965 -- Derive the prefix - sufix
8966 if p_prefix_suffix_cd = 'PREFIX' then
8967 l_prefix := p_prefix_suffix_text ;
8968 elsif p_prefix_suffix_cd = 'SUFFIX' then
8969 l_suffix := p_prefix_suffix_text ;
8970 else
8971 l_prefix := null ;
8972 l_suffix := null ;
8973 end if ;
8974 -- End Prefix Sufix derivation
8975 for r_ELN_unique in c_unique_ELN('ELN') loop
8976
8977 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
8978 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8979 r_ELN_unique.information3 >=
8980 ben_pd_copy_to_ben_one.g_copy_effective_date)
8981 ) then
8982 --
8983 hr_utility.set_location(' r_ELN_unique.table_route_id '||r_ELN_unique.table_route_id,10);
8984 hr_utility.set_location(' r_ELN_unique.information1 '||r_ELN_unique.information1,10);
8985 hr_utility.set_location( 'r_ELN_unique.information2 '||r_ELN_unique.information2,10);
8986 hr_utility.set_location( 'r_ELN_unique.information3 '||r_ELN_unique.information3,10);
8987 -- If reuse objects flag is 'Y' then check for the object in the target business group
8988 -- if found insert the record into PLSql table and exit the loop else try create the
8989 -- object in the target business group
8990 --
8991 l_object_found_in_target := false ;
8992 --UPD START
8993 l_update := false;
8994 l_process_date := p_effective_date;
8995 l_dml_operation:= r_ELN_unique.dml_operation ;
8996
8997 /**********************moved from below **********************/
8998 open c_ELN(r_ELN_unique.table_route_id,
8999 r_ELN_unique.information1,
9000 r_ELN_unique.information2,
9001 r_ELN_unique.information3 ) ;
9002 --
9003 fetch c_ELN into r_ELN ;
9004 --
9005 close c_ELN ;
9006 --
9007 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ELN.INFORMATION263,l_dml_operation);-- changed from information11
9008
9009 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
9010 l_ORGANIZATION_ID := r_ELN.information176;
9011 else
9012 l_ORGANIZATION_ID := r_ELN.information174;
9013 end if;
9014
9015 /**********************************************************/
9016 --
9017 if l_dml_operation = 'UPDATE' then
9018 --
9019 l_object_found_in_target := TRUE;
9020 --
9021 if l_process_date between r_ELN_unique.information2 and r_ELN_unique.information3 then
9022 l_update := true;
9023 if r_ELN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
9024 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_LGL_ENTY_PRTE_ID' then
9025 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LGL_ENTY_PRTE_ID' ;
9026 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELN_unique.information1 ;
9027 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ELN_unique.information1 ;
9028 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
9029 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELN_unique.table_route_id;
9030 --
9031 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
9032 --
9033 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
9034 --
9035 -- log_data('ELN',l_new_value,l_prefix || r_ELN_unique.name|| l_suffix,'REUSED');
9036 --
9037 end if ;
9038 hr_utility.set_location( 'found record for update',10);
9039 --
9040 else
9041 --
9042 l_update := false;
9043 --
9044 end if;
9045 else
9046 --
9047 --UPD END
9048 l_min_esd := null ;
9049 l_max_eed := null ;
9050 open c_ELN_min_max_dates(r_ELN_unique.table_route_id, r_ELN_unique.information1 ) ;
9051 fetch c_ELN_min_max_dates into l_min_esd,l_max_eed ;
9052 --
9053
9054 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9055 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
9056 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
9057 end if;
9058 l_min_esd := greatest(l_min_esd,r_ELN_unique.information2);
9059 /**********************moved up from here **********************
9060 open c_ELN(r_ELN_unique.table_route_id,
9061 r_ELN_unique.information1,
9062 r_ELN_unique.information2,
9063 r_ELN_unique.information3 ) ;
9064 --
9065 fetch c_ELN into r_ELN ;
9066 --
9067 close c_ELN ;
9068 --
9069 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ELN.INFORMATION263,l_dml_operation);-- changed from information11
9070 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
9071 l_ORGANIZATION_ID := r_ELN.information176;
9072 else
9073 l_ORGANIZATION_ID := r_ELN.information174;
9074 end if;
9075
9076 **********************************************************/
9077 --
9078 if l_ORGANIZATION_ID is null then
9079 close c_ELN_min_max_dates;
9080 --
9081 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
9082 ,p_parent_pk_id => r_ELN.information263
9083 ,p_copy_entity_txn_id => p_copy_entity_txn_id
9084 ,p_child_table_alias => 'ELN'
9085 ,p_child_data => r_ELN.information173 );
9086
9087 --
9088 else
9089 if p_reuse_object_flag = 'Y' then
9090 if c_ELN_min_max_dates%found then
9091 -- cursor to find the object
9092 open c_find_ELN_in_target( l_min_esd,l_max_eed,
9093 p_target_business_group_id, nvl(l_elig_lgl_enty_prte_id, -999) ) ;
9094 fetch c_find_ELN_in_target into l_new_value ;
9095 if c_find_ELN_in_target%found then
9096 --
9097 --TEMPIK
9098 l_dt_rec_found := dt_api.check_min_max_dates
9099 (p_base_table_name => 'BEN_ELIG_LGL_ENTY_PRTE_F',
9100 p_base_key_column => 'ELIG_LGL_ENTY_PRTE_ID',
9101 p_base_key_value => l_new_value,
9102 p_from_date => l_min_esd,
9103 p_to_date => l_max_eed );
9104 if l_dt_rec_found THEN
9105 --END TEMPIK
9106 if r_ELN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
9107 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_LGL_ENTY_PRTE_ID' then
9108 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LGL_ENTY_PRTE_ID' ;
9109 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELN_unique.information1 ;
9110 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
9111 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
9112 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELN_unique.table_route_id;
9113 --
9114 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
9115 --
9116 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
9117 end if ;
9118 --
9119 l_object_found_in_target := true ;
9120 --TEMPIK
9121 end if; -- l_dt_rec_found
9122 --END TEMPIK
9123 end if;
9124 close c_find_ELN_in_target ;
9125 --
9126 end if;
9127 end if ;
9128 --
9129 close c_ELN_min_max_dates ;
9130 end if ; -- bug 4565106
9131
9132 end if; --if p_dml_operation
9133 --
9134 if (not l_object_found_in_target OR l_update) and l_organization_id is not null then
9135
9136 --
9137 l_current_pk_id := r_ELN.information1;
9138 --
9139 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
9140 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
9141 --
9142 if l_current_pk_id = l_prev_pk_id then
9143 --
9144 l_first_rec := false ;
9145 --
9146 else
9147 --
9148 l_first_rec := true ;
9149 --
9150 end if ;
9151 --
9152
9153 l_effective_date := r_ELN.information2;
9154 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9155 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
9156 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
9157 end if;
9158
9159 if l_first_rec and not l_update then
9160 -- Call Create routine.
9161 hr_utility.set_location(' BEN_ELIG_LGL_ENTY_PRTE_F CREATE_ELIG_LGL_ENTY_PRTE ',20);
9162 BEN_ELIG_LGL_ENTY_PRTE_API.CREATE_ELIG_LGL_ENTY_PRTE(
9163 --
9164 P_VALIDATE => false
9165 ,P_EFFECTIVE_DATE => l_effective_date
9166 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
9167 --
9168 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
9169 ,P_ELIG_LGL_ENTY_PRTE_ID => l_elig_lgl_enty_prte_id
9170 ,P_ELN_ATTRIBUTE1 => r_ELN.INFORMATION111
9171 ,P_ELN_ATTRIBUTE10 => r_ELN.INFORMATION120
9172 ,P_ELN_ATTRIBUTE11 => r_ELN.INFORMATION121
9173 ,P_ELN_ATTRIBUTE12 => r_ELN.INFORMATION122
9174 ,P_ELN_ATTRIBUTE13 => r_ELN.INFORMATION123
9175 ,P_ELN_ATTRIBUTE14 => r_ELN.INFORMATION124
9176 ,P_ELN_ATTRIBUTE15 => r_ELN.INFORMATION125
9177 ,P_ELN_ATTRIBUTE16 => r_ELN.INFORMATION126
9178 ,P_ELN_ATTRIBUTE17 => r_ELN.INFORMATION127
9179 ,P_ELN_ATTRIBUTE18 => r_ELN.INFORMATION128
9180 ,P_ELN_ATTRIBUTE19 => r_ELN.INFORMATION129
9181 ,P_ELN_ATTRIBUTE2 => r_ELN.INFORMATION112
9182 ,P_ELN_ATTRIBUTE20 => r_ELN.INFORMATION130
9183 ,P_ELN_ATTRIBUTE21 => r_ELN.INFORMATION131
9184 ,P_ELN_ATTRIBUTE22 => r_ELN.INFORMATION132
9185 ,P_ELN_ATTRIBUTE23 => r_ELN.INFORMATION133
9186 ,P_ELN_ATTRIBUTE24 => r_ELN.INFORMATION134
9187 ,P_ELN_ATTRIBUTE25 => r_ELN.INFORMATION135
9188 ,P_ELN_ATTRIBUTE26 => r_ELN.INFORMATION136
9189 ,P_ELN_ATTRIBUTE27 => r_ELN.INFORMATION137
9190 ,P_ELN_ATTRIBUTE28 => r_ELN.INFORMATION138
9191 ,P_ELN_ATTRIBUTE29 => r_ELN.INFORMATION139
9192 ,P_ELN_ATTRIBUTE3 => r_ELN.INFORMATION113
9193 ,P_ELN_ATTRIBUTE30 => r_ELN.INFORMATION140
9194 ,P_ELN_ATTRIBUTE4 => r_ELN.INFORMATION114
9195 ,P_ELN_ATTRIBUTE5 => r_ELN.INFORMATION115
9196 ,P_ELN_ATTRIBUTE6 => r_ELN.INFORMATION116
9197 ,P_ELN_ATTRIBUTE7 => r_ELN.INFORMATION117
9198 ,P_ELN_ATTRIBUTE8 => r_ELN.INFORMATION118
9199 ,P_ELN_ATTRIBUTE9 => r_ELN.INFORMATION119
9200 ,P_ELN_ATTRIBUTE_CATEGORY => r_ELN.INFORMATION110
9201 ,P_EXCLD_FLAG => r_ELN.INFORMATION11
9202 ,P_ORDR_NUM => r_ELN.INFORMATION260
9203 ,P_ORGANIZATION_ID => l_ORGANIZATION_ID
9204 --
9205 -- ****** END CHANGE LINES
9206
9207 --
9208
9209 ,P_EFFECTIVE_START_DATE => l_effective_start_date
9210 ,P_EFFECTIVE_END_DATE => l_effective_end_date
9211 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
9212 ,P_CRITERIA_SCORE => r_eln.INFORMATION295
9213 ,P_CRITERIA_WEIGHT => r_eln.INFORMATION296
9214 );
9215 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
9216 -- Update all relevent cer records with new pk_id
9217 hr_utility.set_location('Before plsql table ',222);
9218 hr_utility.set_location('new_value id '||l_elig_lgl_enty_prte_id,222);
9219 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LGL_ENTY_PRTE_ID' ;
9220 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELN.information1 ;
9221 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_LGL_ENTY_PRTE_ID ;
9222 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
9223 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELN_unique.table_route_id;
9224 hr_utility.set_location('After plsql table ',222);
9225 --
9226 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
9227 --
9228 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
9229 --
9230 else
9231 --
9232 -- Call Update routine for the pk_id created in prev run .
9233 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
9234 hr_utility.set_location(' BEN_ELIG_LGL_ENTY_PRTE_F UPDATE_ELIG_LGL_ENTY_PRTE ',30);
9235 --UPD START
9236 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
9237 --
9238 if l_update then
9239 --
9240 l_datetrack_mode := r_ELN.datetrack_mode ;
9241 --
9242 get_dt_modes(
9243 p_effective_date => l_process_date,
9244 p_effective_end_date => r_ELN.information3,
9245 p_effective_start_date => r_ELN.information2,
9246 p_dml_operation => r_ELN.dml_operation,
9247 p_datetrack_mode => l_datetrack_mode );
9248 -- p_update => l_update
9249 --
9250 l_effective_date := l_process_date;
9251 l_ELIG_LGL_ENTY_PRTE_ID := r_ELN.information1;
9252 l_object_version_number := r_ELN.information265;
9253 --
9254 end if;
9255 --
9256 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
9257 --
9258 IF l_update OR l_dml_operation <> 'UPDATE' THEN
9259 --UPD END
9260
9261
9262 BEN_ELIG_LGL_ENTY_PRTE_API.UPDATE_ELIG_LGL_ENTY_PRTE(
9263 --
9264 P_VALIDATE => false
9265 ,P_EFFECTIVE_DATE => l_effective_date
9266 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
9267 --
9268 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
9269 ,P_ELIG_LGL_ENTY_PRTE_ID => l_elig_lgl_enty_prte_id
9270 ,P_ELN_ATTRIBUTE1 => r_ELN.INFORMATION111
9271 ,P_ELN_ATTRIBUTE10 => r_ELN.INFORMATION120
9272 ,P_ELN_ATTRIBUTE11 => r_ELN.INFORMATION121
9273 ,P_ELN_ATTRIBUTE12 => r_ELN.INFORMATION122
9274 ,P_ELN_ATTRIBUTE13 => r_ELN.INFORMATION123
9275 ,P_ELN_ATTRIBUTE14 => r_ELN.INFORMATION124
9276 ,P_ELN_ATTRIBUTE15 => r_ELN.INFORMATION125
9277 ,P_ELN_ATTRIBUTE16 => r_ELN.INFORMATION126
9278 ,P_ELN_ATTRIBUTE17 => r_ELN.INFORMATION127
9279 ,P_ELN_ATTRIBUTE18 => r_ELN.INFORMATION128
9280 ,P_ELN_ATTRIBUTE19 => r_ELN.INFORMATION129
9281 ,P_ELN_ATTRIBUTE2 => r_ELN.INFORMATION112
9282 ,P_ELN_ATTRIBUTE20 => r_ELN.INFORMATION130
9283 ,P_ELN_ATTRIBUTE21 => r_ELN.INFORMATION131
9284 ,P_ELN_ATTRIBUTE22 => r_ELN.INFORMATION132
9285 ,P_ELN_ATTRIBUTE23 => r_ELN.INFORMATION133
9286 ,P_ELN_ATTRIBUTE24 => r_ELN.INFORMATION134
9287 ,P_ELN_ATTRIBUTE25 => r_ELN.INFORMATION135
9288 ,P_ELN_ATTRIBUTE26 => r_ELN.INFORMATION136
9289 ,P_ELN_ATTRIBUTE27 => r_ELN.INFORMATION137
9290 ,P_ELN_ATTRIBUTE28 => r_ELN.INFORMATION138
9291 ,P_ELN_ATTRIBUTE29 => r_ELN.INFORMATION139
9292 ,P_ELN_ATTRIBUTE3 => r_ELN.INFORMATION113
9293 ,P_ELN_ATTRIBUTE30 => r_ELN.INFORMATION140
9294 ,P_ELN_ATTRIBUTE4 => r_ELN.INFORMATION114
9295 ,P_ELN_ATTRIBUTE5 => r_ELN.INFORMATION115
9296 ,P_ELN_ATTRIBUTE6 => r_ELN.INFORMATION116
9297 ,P_ELN_ATTRIBUTE7 => r_ELN.INFORMATION117
9298 ,P_ELN_ATTRIBUTE8 => r_ELN.INFORMATION118
9299 ,P_ELN_ATTRIBUTE9 => r_ELN.INFORMATION119
9300 ,P_ELN_ATTRIBUTE_CATEGORY => r_ELN.INFORMATION110
9301 ,P_EXCLD_FLAG => r_ELN.INFORMATION11
9302 ,P_ORDR_NUM => r_ELN.INFORMATION260
9303 ,P_ORGANIZATION_ID => l_ORGANIZATION_ID
9304 --
9305 -- ****** END CHANGE LINES
9306
9307 --
9308 ,P_EFFECTIVE_START_DATE => l_effective_start_date
9309 ,P_EFFECTIVE_END_DATE => l_effective_end_date
9310 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
9311 ,P_DATETRACK_MODE => l_datetrack_mode
9312 ,P_CRITERIA_SCORE => r_eln.INFORMATION295
9313 ,P_CRITERIA_WEIGHT => r_eln.INFORMATION296
9314 );
9315 end if; -- l_update
9316 --
9317 end if;
9318 --
9319 -- Delete the row if it is end dated.
9320 --
9321 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
9322 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
9323 trunc(l_max_eed) = trunc(r_ELN.information3)) then
9324 --
9325 BEN_ELIG_LGL_ENTY_PRTE_API.delete_ELIG_LGL_ENTY_PRTE(
9326 --
9327 p_validate => false
9328 ,p_elig_lgl_enty_prte_id => l_elig_lgl_enty_prte_id
9329 ,p_effective_start_date => l_effective_start_date
9330 ,p_effective_end_date => l_effective_end_date
9331 ,p_object_version_number => l_object_version_number
9332 ,p_effective_date => l_max_eed
9333 ,p_datetrack_mode => hr_api.g_delete
9334 --
9335 );
9336 --
9337 end if;
9338 --
9339 l_prev_pk_id := l_current_pk_id ;
9340 --
9341 -- end if; -- bug 4565106
9342 --
9343 end if;
9344 --
9345 end if;
9346 --
9347 end loop;
9348 --
9349 exception when others then
9350 --
9351 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ELN',r_ELN.information5 ) ;
9352 --
9353 end create_ELN_rows;
9354
9355
9356 --
9357 ---------------------------------------------------------------
9358 ----------------------< create_ELR_rows >-----------------------
9359 ---------------------------------------------------------------
9360 --
9361 procedure create_ELR_rows
9362 (
9363 p_validate in number default 0
9364 ,p_copy_entity_txn_id in number
9365 ,p_effective_date in date
9366 ,p_prefix_suffix_text in varchar2 default null
9367 ,p_reuse_object_flag in varchar2 default null
9368 ,p_target_business_group_id in varchar2 default null
9369 ,p_prefix_suffix_cd in varchar2 default null
9370 ) is
9371 --
9372 l_ABSENCE_ATTENDANCE_TYPE_ID number; -- IK 9999 Mapping required
9373 l_ABS_ATTENDANCE_REASON_ID number;
9374 l_ELIGY_PRFL_ID number;
9375 cursor c_unique_ELR(l_table_alias varchar2) is
9376 select distinct cpe.information1,
9377 cpe.information2,
9378 cpe.information3,
9379 cpe.table_route_id
9380 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
9381 pqh_table_route tr
9382 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9383 and cpe.table_route_id = tr.table_route_id
9384 -- and tr.where_clause = l_BEN_ELIG_LOA_RSN_PRTE_F
9385 and tr.table_alias = l_table_alias
9386 and cpe.number_of_copies = 1 -- ADDITION
9387 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
9388 order by information1, information2; --added for bug: 5151945
9389 --
9390 --
9391 cursor c_ELR_min_max_dates(c_table_route_id number,
9392 c_information1 number) is
9393 select
9394 min(cpe.information2) min_esd,
9395 max(cpe.information3) min_eed
9396 from ben_copy_entity_results cpe
9397 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9398 and cpe.table_route_id = c_table_route_id
9399 and cpe.information1 = c_information1 ;
9400 --
9401 cursor c_ELR(c_table_route_id number,
9402 c_information1 number,
9403 c_information2 date,
9404 c_information3 date ) is
9405 select
9406 cpe.*
9407 from ben_copy_entity_results cpe
9408 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9409 and cpe.table_route_id = c_table_route_id
9410 and cpe.information1 = c_information1
9411 and cpe.information2 = c_information2
9412 and cpe.information3 = c_information3
9413 and rownum = 1 ;
9414 -- Date Track target record
9415 cursor c_find_ELR_in_target(
9416 c_effective_start_date date,
9417 c_effective_end_date date,
9418 c_business_group_id number,
9419 c_new_pk_id number) is
9420 select
9421 ELR.elig_loa_rsn_prte_id new_value
9422 from BEN_ELIG_LOA_RSN_PRTE_F ELR
9423 where
9424 ELR.ABSENCE_ATTENDANCE_TYPE_ID = l_ABSENCE_ATTENDANCE_TYPE_ID and
9425 nvl(ELR.ABS_ATTENDANCE_REASON_ID,-999) = NVL(l_ABS_ATTENDANCE_REASON_ID,-999) and -- 3570016
9426 ELR.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
9427 ELR.business_group_id = c_business_group_id
9428 and ELR.elig_loa_rsn_prte_id <> c_new_pk_id
9429 and c_effective_start_date between effective_start_date
9430 and effective_end_date ;
9431 --END TEMPIK
9432 /*TEMPIK
9433 and exists ( select null
9434 from BEN_ELIG_LOA_RSN_PRTE_F ELR1
9435 where
9436 ELR1.ABSENCE_ATTENDANCE_TYPE_ID = l_ABSENCE_ATTENDANCE_TYPE_ID and
9437 nvl(ELR1.ABS_ATTENDANCE_REASON_ID,-999) = l_ABS_ATTENDANCE_REASON_ID and
9438 ELR1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
9439 ELR1.business_group_id = c_business_group_id
9440 and ELR1.effective_start_date <= c_effective_start_date )
9441 and exists ( select null
9442 from BEN_ELIG_LOA_RSN_PRTE_F ELR2
9443 where
9444 ELR2.ABSENCE_ATTENDANCE_TYPE_ID = l_ABSENCE_ATTENDANCE_TYPE_ID and
9445 nvl(ELR2.ABS_ATTENDANCE_REASON_ID,-999) = l_ABS_ATTENDANCE_REASON_ID and
9446 ELR2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
9447 ELR2.business_group_id = c_business_group_id
9448 and ELR2.effective_end_date >= c_effective_end_date )
9449 ;
9450 TEMPIK */
9451 --TEMPIK
9452 l_dt_rec_found boolean ;
9453 --END TEMPIK
9454 --
9455
9456 --UPD START
9457 --
9458 l_update boolean := false ;
9459 l_datetrack_mode varchar2(80) := hr_api.g_update;
9460 l_process_date date;
9461 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
9462 --
9463 --UPD END
9464 l_current_pk_id number := null ;
9465
9466 l_prev_pk_id number := null ;
9467 l_first_rec boolean := true ;
9468 r_ELR c_ELR%rowtype;
9469 l_elig_loa_rsn_prte_id number ;
9470 l_object_version_number number ;
9471 l_effective_start_date date ;
9472 l_effective_end_date date ;
9473 l_prefix pqh_copy_entity_attribs.information1%type := null;
9474 l_suffix pqh_copy_entity_attribs.information1%type := null;
9475 l_new_value number(15);
9476 l_object_found_in_target boolean := false ;
9477 l_min_esd date;
9478 l_max_eed date;
9479 l_effective_date date;
9480 --
9481 begin
9482 -- hr_utility.trace_on(null,'TRC');
9483 -- Initialization
9484 l_object_found_in_target := false ;
9485 -- End Initialization
9486 -- Derive the prefix - sufix
9487 if p_prefix_suffix_cd = 'PREFIX' then
9488 l_prefix := p_prefix_suffix_text ;
9489 elsif p_prefix_suffix_cd = 'SUFFIX' then
9490 l_suffix := p_prefix_suffix_text ;
9491 else
9492 l_prefix := null ;
9493 l_suffix := null ;
9494 end if ;
9495 -- End Prefix Sufix derivation
9496 for r_ELR_unique in c_unique_ELR('ELR') loop
9497
9498 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
9499 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9500 r_ELR_unique.information3 >=
9501 ben_pd_copy_to_ben_one.g_copy_effective_date)
9502 ) then
9503 --
9504 hr_utility.set_location(' r_ELR_unique.table_route_id '||r_ELR_unique.table_route_id,10);
9505 hr_utility.set_location(' r_ELR_unique.information1 '||r_ELR_unique.information1,10);
9506 hr_utility.set_location( 'r_ELR_unique.information2 '||r_ELR_unique.information2,10);
9507 hr_utility.set_location( 'r_ELR_unique.information3 '||r_ELR_unique.information3,10);
9508 -- If reuse objects flag is 'Y' then check for the object in the target business group
9509 -- if found insert the record into PLSql table and exit the loop else try create the
9510 -- object in the target business group
9511 --
9512 l_object_found_in_target := false ;
9513 --UPD START
9514 l_update := false;
9515 l_process_date := p_effective_date;
9516 l_dml_operation:= r_ELR_unique.dml_operation ;
9517 --
9518
9519 /**********************moved from below **********************/
9520 open c_ELR(r_ELR_unique.table_route_id,
9521 r_ELR_unique.information1,
9522 r_ELR_unique.information2,
9523 r_ELR_unique.information3 ) ;
9524 --
9525 fetch c_ELR into r_ELR ;
9526 --
9527 close c_ELR ;
9528 --
9529 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
9530 l_ABSENCE_ATTENDANCE_TYPE_ID := r_ELR.information176;
9531 --l_ABSENCE_ATTENDANCE_TYPE_ID := r_ELR.information180; -- For bug 3570016
9532 else
9533 l_ABSENCE_ATTENDANCE_TYPE_ID := r_ELR.information174;
9534 -- l_ABSENCE_ATTENDANCE_TYPE_ID := r_ELR.information178; -- For bug 3570016
9535 end if;
9536 --
9537 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
9538 l_ABS_ATTENDANCE_REASON_ID := r_ELR.information180;
9539 --l_ABS_ATTENDANCE_REASON_ID := r_ELR.information176; -- For bug 3570016
9540 else
9541 l_ABS_ATTENDANCE_REASON_ID := r_ELR.information178;
9542 --l_ABS_ATTENDANCE_REASON_ID := r_ELR.information174; -- For bug 3570016
9543 end if;
9544 --
9545 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ELR.INFORMATION263,l_dml_operation);
9546
9547 hr_utility.set_location(' ELIGY_PRFL_ID '|| l_ELIGY_PRFL_ID,10);
9548 hr_utility.set_location(' l_ABS_ATTENDANCE_REASON_ID '|| l_ABS_ATTENDANCE_REASON_ID, 10);
9549 hr_utility.set_location(' l_ABSENCE_ATTENDANCE_TYPE_ID '|| l_ABSENCE_ATTENDANCE_TYPE_ID, 10);
9550 /**********************************************************/
9551
9552 if l_dml_operation = 'UPDATE' then
9553 --
9554 l_object_found_in_target := TRUE;
9555 --
9556 if l_process_date between r_ELR_unique.information2 and r_ELR_unique.information3 then
9557 l_update := true;
9558 if r_ELR_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
9559 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_LOA_RSN_PRTE_ID' then
9560 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LOA_RSN_PRTE_ID' ;
9561 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELR_unique.information1 ;
9562 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ELR_unique.information1 ;
9563 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
9564 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELR_unique.table_route_id;
9565 --
9566 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
9567 --
9568 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
9569 --
9570 -- log_data('ELR',l_new_value,l_prefix || r_ELR_unique.name|| l_suffix,'REUSED');
9571 --
9572 end if ;
9573 hr_utility.set_location( 'found record for update',10);
9574 --
9575 else
9576 --
9577 l_update := false;
9578 --
9579 end if;
9580 else
9581 --
9582 --UPD END
9583 l_min_esd := null ;
9584 l_max_eed := null ;
9585 open c_ELR_min_max_dates(r_ELR_unique.table_route_id, r_ELR_unique.information1 ) ;
9586 fetch c_ELR_min_max_dates into l_min_esd,l_max_eed ;
9587 --
9588
9589 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9590 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
9591 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
9592 end if;
9593 l_min_esd := greatest(l_min_esd,r_ELR_unique.information2);
9594 /**********************moved up from here **********************
9595 open c_ELR(r_ELR_unique.table_route_id,
9596 r_ELR_unique.information1,
9597 r_ELR_unique.information2,
9598 r_ELR_unique.information3 ) ;
9599 --
9600 fetch c_ELR into r_ELR ;
9601 --
9602 close c_ELR ;
9603 --
9604 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
9605 l_ABSENCE_ATTENDANCE_TYPE_ID := r_ELR.information176;
9606 --l_ABSENCE_ATTENDANCE_TYPE_ID := r_ELR.information180; -- For bug 3570016
9607 else
9608 l_ABSENCE_ATTENDANCE_TYPE_ID := r_ELR.information174;
9609 -- l_ABSENCE_ATTENDANCE_TYPE_ID := r_ELR.information178; -- For bug 3570016
9610 end if;
9611 --
9612 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
9613 l_ABS_ATTENDANCE_REASON_ID := r_ELR.information180;
9614 --l_ABS_ATTENDANCE_REASON_ID := r_ELR.information176; -- For bug 3570016
9615 else
9616 l_ABS_ATTENDANCE_REASON_ID := r_ELR.information178;
9617 --l_ABS_ATTENDANCE_REASON_ID := r_ELR.information174; -- For bug 3570016
9618 end if;
9619 --
9620 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ELR.INFORMATION263,l_dml_operation);
9621
9622 hr_utility.set_location(' ELIGY_PRFL_ID '|| l_ELIGY_PRFL_ID,10);
9623 hr_utility.set_location(' l_ABS_ATTENDANCE_REASON_ID '|| l_ABS_ATTENDANCE_REASON_ID, 10);
9624 hr_utility.set_location(' l_ABSENCE_ATTENDANCE_TYPE_ID '|| l_ABSENCE_ATTENDANCE_TYPE_ID, 10);
9625 **********************************************************/
9626
9627 if l_ABSENCE_ATTENDANCE_TYPE_ID is null then
9628 close c_ELR_min_max_dates;
9629 --
9630 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
9631 ,p_parent_pk_id => r_ELR.information263
9632 ,p_copy_entity_txn_id => p_copy_entity_txn_id
9633 ,p_child_table_alias => 'ELR'
9634 ,p_child_data => r_ELR.information173 );
9635
9636 --
9637 else
9638 if p_reuse_object_flag = 'Y' then
9639 if c_ELR_min_max_dates%found then
9640 -- cursor to find the object
9641 open c_find_ELR_in_target( l_min_esd,l_max_eed,
9642 p_target_business_group_id, nvl(l_elig_loa_rsn_prte_id, -999) ) ;
9643 fetch c_find_ELR_in_target into l_new_value ;
9644 if c_find_ELR_in_target%found then
9645 --
9646 --TEMPIK
9647 l_dt_rec_found := dt_api.check_min_max_dates
9648 (p_base_table_name => 'BEN_ELIG_LOA_RSN_PRTE_F',
9649 p_base_key_column => 'ELIG_LOA_RSN_PRTE_ID',
9650 p_base_key_value => l_new_value,
9651 p_from_date => l_min_esd,
9652 p_to_date => l_max_eed );
9653 if l_dt_rec_found THEN
9654 --END TEMPIK
9655 if r_ELR_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
9656 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_LOA_RSN_PRTE_ID' then
9657 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LOA_RSN_PRTE_ID' ;
9658 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELR_unique.information1 ;
9659 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
9660 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
9661 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELR_unique.table_route_id;
9662 --
9663 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
9664 --
9665 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
9666 end if ;
9667 --
9668 l_object_found_in_target := true ;
9669 --TEMPIK
9670 end if; -- l_dt_rec_found
9671 --END TEMPIK
9672 end if;
9673 close c_find_ELR_in_target ;
9674 --
9675 end if;
9676 end if ;
9677 --
9678 close c_ELR_min_max_dates ;
9679
9680 end if; -- bug 4565106
9681
9682 end if; --if p_dml_operation
9683 --
9684 if ( not l_object_found_in_target OR l_update) and (l_ABSENCE_ATTENDANCE_TYPE_ID is not null) then -- bug # 4251900
9685
9686 --
9687 l_current_pk_id := r_ELR.information1;
9688 --
9689 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
9690 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
9691 --
9692 if l_current_pk_id = l_prev_pk_id then
9693 --
9694 l_first_rec := false ;
9695 --
9696 else
9697 --
9698 l_first_rec := true ;
9699 --
9700 end if ;
9701 --
9702
9703 l_effective_date := r_ELR.information2;
9704 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9705 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
9706 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
9707 end if;
9708 if l_first_rec and not l_update then
9709 -- Call Create routine.
9710 hr_utility.set_location(' BEN_ELIG_LOA_RSN_PRTE_F CREATE_ELIG_LOA_RSN_PRTE ',20);
9711 BEN_ELIG_LOA_RSN_PRTE_API.CREATE_ELIG_LOA_RSN_PRTE(
9712 --
9713 P_VALIDATE => false
9714 ,P_EFFECTIVE_DATE => l_effective_date
9715 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
9716 --
9717 ,P_ABSENCE_ATTENDANCE_TYPE_ID => l_ABSENCE_ATTENDANCE_TYPE_ID
9718 ,P_ABS_ATTENDANCE_REASON_ID => l_ABS_ATTENDANCE_REASON_ID
9719 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
9720 ,P_ELIG_LOA_RSN_PRTE_ID => l_elig_loa_rsn_prte_id
9721 ,P_ELR_ATTRIBUTE1 => r_ELR.INFORMATION111
9722 ,P_ELR_ATTRIBUTE10 => r_ELR.INFORMATION120
9723 ,P_ELR_ATTRIBUTE11 => r_ELR.INFORMATION121
9724 ,P_ELR_ATTRIBUTE12 => r_ELR.INFORMATION122
9725 ,P_ELR_ATTRIBUTE13 => r_ELR.INFORMATION123
9726 ,P_ELR_ATTRIBUTE14 => r_ELR.INFORMATION124
9727 ,P_ELR_ATTRIBUTE15 => r_ELR.INFORMATION125
9728 ,P_ELR_ATTRIBUTE16 => r_ELR.INFORMATION126
9729 ,P_ELR_ATTRIBUTE17 => r_ELR.INFORMATION127
9730 ,P_ELR_ATTRIBUTE18 => r_ELR.INFORMATION128
9731 ,P_ELR_ATTRIBUTE19 => r_ELR.INFORMATION129
9732 ,P_ELR_ATTRIBUTE2 => r_ELR.INFORMATION112
9733 ,P_ELR_ATTRIBUTE20 => r_ELR.INFORMATION130
9734 ,P_ELR_ATTRIBUTE21 => r_ELR.INFORMATION131
9735 ,P_ELR_ATTRIBUTE22 => r_ELR.INFORMATION132
9736 ,P_ELR_ATTRIBUTE23 => r_ELR.INFORMATION133
9737 ,P_ELR_ATTRIBUTE24 => r_ELR.INFORMATION134
9738 ,P_ELR_ATTRIBUTE25 => r_ELR.INFORMATION135
9739 ,P_ELR_ATTRIBUTE26 => r_ELR.INFORMATION136
9740 ,P_ELR_ATTRIBUTE27 => r_ELR.INFORMATION137
9741 ,P_ELR_ATTRIBUTE28 => r_ELR.INFORMATION138
9742 ,P_ELR_ATTRIBUTE29 => r_ELR.INFORMATION139
9743 ,P_ELR_ATTRIBUTE3 => r_ELR.INFORMATION113
9744 ,P_ELR_ATTRIBUTE30 => r_ELR.INFORMATION140
9745 ,P_ELR_ATTRIBUTE4 => r_ELR.INFORMATION114
9746 ,P_ELR_ATTRIBUTE5 => r_ELR.INFORMATION115
9747 ,P_ELR_ATTRIBUTE6 => r_ELR.INFORMATION116
9748 ,P_ELR_ATTRIBUTE7 => r_ELR.INFORMATION117
9749 ,P_ELR_ATTRIBUTE8 => r_ELR.INFORMATION118
9750 ,P_ELR_ATTRIBUTE9 => r_ELR.INFORMATION119
9751 ,P_ELR_ATTRIBUTE_CATEGORY => r_ELR.INFORMATION110
9752 ,P_EXCLD_FLAG => r_ELR.INFORMATION11
9753 ,P_ORDR_NUM => r_ELR.INFORMATION259
9754 --
9755 -- ****** END CHANGE LINES
9756
9757 --
9758
9759 ,P_EFFECTIVE_START_DATE => l_effective_start_date
9760 ,P_EFFECTIVE_END_DATE => l_effective_end_date
9761 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
9762 ,P_CRITERIA_SCORE => r_elr.INFORMATION295
9763 ,P_CRITERIA_WEIGHT => r_elr.INFORMATION296
9764 );
9765 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
9766 -- Update all relevent cer records with new pk_id
9767 hr_utility.set_location('Before plsql table ',222);
9768 hr_utility.set_location('new_value id '||l_elig_loa_rsn_prte_id,222);
9769 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LOA_RSN_PRTE_ID' ;
9770 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELR.information1 ;
9771 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_LOA_RSN_PRTE_ID ;
9772 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
9773 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELR_unique.table_route_id;
9774 hr_utility.set_location('After plsql table ',222);
9775 --
9776 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
9777 --
9778 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
9779 --
9780 else
9781
9782 --
9783 -- Call Update routine for the pk_id created in prev run .
9784 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
9785 hr_utility.set_location(' BEN_ELIG_LOA_RSN_PRTE_F UPDATE_ELIG_LOA_RSN_PRTE ',30);
9786 --UPD START
9787 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
9788 --
9789 if l_update then
9790 --
9791 l_datetrack_mode := r_ELR.datetrack_mode ;
9792 --
9793 get_dt_modes(
9794 p_effective_date => l_process_date,
9795 p_effective_end_date => r_ELR.information3,
9796 p_effective_start_date => r_ELR.information2,
9797 p_dml_operation => r_ELR.dml_operation,
9798 p_datetrack_mode => l_datetrack_mode );
9799 -- p_update => l_update
9800 --
9801 l_effective_date := l_process_date;
9802 l_ELIG_LOA_RSN_PRTE_ID := r_ELR.information1;
9803 l_object_version_number := r_ELR.information265;
9804 --
9805 end if;
9806 --
9807 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
9808 --
9809 IF l_update OR l_dml_operation <> 'UPDATE' THEN
9810 --UPD END
9811
9812
9813 BEN_ELIG_LOA_RSN_PRTE_API.UPDATE_ELIG_LOA_RSN_PRTE(
9814 --
9815 P_VALIDATE => false
9816 ,P_EFFECTIVE_DATE => l_effective_date
9817 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
9818 --
9819 ,P_ABSENCE_ATTENDANCE_TYPE_ID => l_ABSENCE_ATTENDANCE_TYPE_ID
9820 ,P_ABS_ATTENDANCE_REASON_ID => l_ABS_ATTENDANCE_REASON_ID
9821 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
9822 ,P_ELIG_LOA_RSN_PRTE_ID => l_elig_loa_rsn_prte_id
9823 ,P_ELR_ATTRIBUTE1 => r_ELR.INFORMATION111
9824 ,P_ELR_ATTRIBUTE10 => r_ELR.INFORMATION120
9825 ,P_ELR_ATTRIBUTE11 => r_ELR.INFORMATION121
9826 ,P_ELR_ATTRIBUTE12 => r_ELR.INFORMATION122
9827 ,P_ELR_ATTRIBUTE13 => r_ELR.INFORMATION123
9828 ,P_ELR_ATTRIBUTE14 => r_ELR.INFORMATION124
9829 ,P_ELR_ATTRIBUTE15 => r_ELR.INFORMATION125
9830 ,P_ELR_ATTRIBUTE16 => r_ELR.INFORMATION126
9831 ,P_ELR_ATTRIBUTE17 => r_ELR.INFORMATION127
9832 ,P_ELR_ATTRIBUTE18 => r_ELR.INFORMATION128
9833 ,P_ELR_ATTRIBUTE19 => r_ELR.INFORMATION129
9834 ,P_ELR_ATTRIBUTE2 => r_ELR.INFORMATION112
9835 ,P_ELR_ATTRIBUTE20 => r_ELR.INFORMATION130
9836 ,P_ELR_ATTRIBUTE21 => r_ELR.INFORMATION131
9837 ,P_ELR_ATTRIBUTE22 => r_ELR.INFORMATION132
9838 ,P_ELR_ATTRIBUTE23 => r_ELR.INFORMATION133
9839 ,P_ELR_ATTRIBUTE24 => r_ELR.INFORMATION134
9840 ,P_ELR_ATTRIBUTE25 => r_ELR.INFORMATION135
9841 ,P_ELR_ATTRIBUTE26 => r_ELR.INFORMATION136
9842 ,P_ELR_ATTRIBUTE27 => r_ELR.INFORMATION137
9843 ,P_ELR_ATTRIBUTE28 => r_ELR.INFORMATION138
9844 ,P_ELR_ATTRIBUTE29 => r_ELR.INFORMATION139
9845 ,P_ELR_ATTRIBUTE3 => r_ELR.INFORMATION113
9846 ,P_ELR_ATTRIBUTE30 => r_ELR.INFORMATION140
9847 ,P_ELR_ATTRIBUTE4 => r_ELR.INFORMATION114
9848 ,P_ELR_ATTRIBUTE5 => r_ELR.INFORMATION115
9849 ,P_ELR_ATTRIBUTE6 => r_ELR.INFORMATION116
9850 ,P_ELR_ATTRIBUTE7 => r_ELR.INFORMATION117
9851 ,P_ELR_ATTRIBUTE8 => r_ELR.INFORMATION118
9852 ,P_ELR_ATTRIBUTE9 => r_ELR.INFORMATION119
9853 ,P_ELR_ATTRIBUTE_CATEGORY => r_ELR.INFORMATION110
9854 ,P_EXCLD_FLAG => r_ELR.INFORMATION11
9855 ,P_ORDR_NUM => r_ELR.INFORMATION259
9856 --
9857 -- ****** END CHANGE LINES
9858
9859 --
9860 ,P_EFFECTIVE_START_DATE => l_effective_start_date
9861 ,P_EFFECTIVE_END_DATE => l_effective_end_date
9862 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
9863 ,P_DATETRACK_MODE => l_datetrack_mode
9864 ,P_CRITERIA_SCORE => r_elr.INFORMATION295
9865 ,P_CRITERIA_WEIGHT => r_elr.INFORMATION296
9866 );
9867 end if; -- l_update
9868 --
9869 end if;
9870 --
9871 -- Delete the row if it is end dated.
9872 --
9873 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
9874 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
9875 trunc(l_max_eed) = trunc(r_ELR.information3)) then
9876 --
9877 BEN_ELIG_LOA_RSN_PRTE_API.delete_ELIG_LOA_RSN_PRTE(
9878 --
9879 p_validate => false
9880 ,p_elig_loa_rsn_prte_id => l_elig_loa_rsn_prte_id
9881 ,p_effective_start_date => l_effective_start_date
9882 ,p_effective_end_date => l_effective_end_date
9883 ,p_object_version_number => l_object_version_number
9884 ,p_effective_date => l_max_eed
9885 ,p_datetrack_mode => hr_api.g_delete
9886 --
9887 );
9888 --
9889 end if;
9890 --
9891 l_prev_pk_id := l_current_pk_id ;
9892 --
9893 -- end if; ---- bug 4565106
9894 --
9895 end if;
9896 --
9897 end if;
9898 --
9899 end loop;
9900 --
9901 -- hr_utility.trace_off;
9902 exception when others then
9903 --
9904 -- hr_utility.trace_off;
9905 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ELR',r_ELR.information5 ) ;
9906 --
9907 end create_ELR_rows;
9908
9909
9910
9911 --
9912 ---------------------------------------------------------------
9913 ----------------------< create_ELS_rows >-----------------------
9914 ---------------------------------------------------------------
9915 --
9916 procedure create_ELS_rows
9917 (
9918 p_validate in number default 0
9919 ,p_copy_entity_txn_id in number
9920 ,p_effective_date in date
9921 ,p_prefix_suffix_text in varchar2 default null
9922 ,p_reuse_object_flag in varchar2 default null
9923 ,p_target_business_group_id in varchar2 default null
9924 ,p_prefix_suffix_cd in varchar2 default null
9925 ) is
9926 --
9927 l_ELIGY_PRFL_ID number;
9928 l_LOS_FCTR_ID number;
9929 cursor c_unique_ELS(l_table_alias varchar2) is
9930 select distinct cpe.information1,
9931 cpe.information2,
9932 cpe.information3,
9933 cpe.table_route_id
9934 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
9935 pqh_table_route tr
9936 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9937 and cpe.table_route_id = tr.table_route_id
9938 -- and tr.where_clause = l_BEN_ELIG_LOS_PRTE_F
9939 and tr.table_alias = l_table_alias
9940 and cpe.number_of_copies = 1 -- ADDITION
9941 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
9942 order by information1, information2; --added for bug: 5151945
9943 --
9944 --
9945 cursor c_ELS_min_max_dates(c_table_route_id number,
9946 c_information1 number) is
9947 select
9948 min(cpe.information2) min_esd,
9949 max(cpe.information3) min_eed
9950 from ben_copy_entity_results cpe
9951 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9952 and cpe.table_route_id = c_table_route_id
9953 and cpe.information1 = c_information1 ;
9954 --
9955 cursor c_ELS(c_table_route_id number,
9956 c_information1 number,
9957 c_information2 date,
9958 c_information3 date ) is
9959 select
9960 cpe.*
9961 from ben_copy_entity_results cpe
9962 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9963 and cpe.table_route_id = c_table_route_id
9964 and cpe.information1 = c_information1
9965 and cpe.information2 = c_information2
9966 and cpe.information3 = c_information3
9967 and rownum = 1 ;
9968 -- Date Track target record
9969 cursor c_find_ELS_in_target(
9970 c_effective_start_date date,
9971 c_effective_end_date date,
9972 c_business_group_id number,
9973 c_new_pk_id number) is
9974 select
9975 ELS.elig_los_prte_id new_value
9976 from BEN_ELIG_LOS_PRTE_F ELS
9977 where
9978 ELS.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
9979 ELS.LOS_FCTR_ID = l_LOS_FCTR_ID and
9980 ELS.business_group_id = c_business_group_id
9981 and ELS.elig_los_prte_id <> c_new_pk_id
9982 and c_effective_start_date between effective_start_date
9983 and effective_end_date ;
9984 --END TEMPIK
9985 /*TEMPIK
9986 and exists ( select null
9987 from BEN_ELIG_LOS_PRTE_F ELS1
9988 where
9989 ELS1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
9990 ELS1.LOS_FCTR_ID = l_LOS_FCTR_ID and
9991 ELS1.business_group_id = c_business_group_id
9992 and ELS1.effective_start_date <= c_effective_start_date )
9993 and exists ( select null
9994 from BEN_ELIG_LOS_PRTE_F ELS2
9995 where
9996 ELS2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
9997 ELS2.LOS_FCTR_ID = l_LOS_FCTR_ID and
9998 ELS2.business_group_id = c_business_group_id
9999 and ELS2.effective_end_date >= c_effective_end_date )
10000 ;
10001 TEMPIK */
10002 --TEMPIK
10003 l_dt_rec_found boolean ;
10004 --END TEMPIK
10005 --
10006
10007 --UPD START
10008 --
10009 l_update boolean := false ;
10010 l_datetrack_mode varchar2(80) := hr_api.g_update;
10011 l_process_date date;
10012 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
10013 --
10014 --UPD END
10015 l_current_pk_id number := null ;
10016
10017 l_prev_pk_id number := null ;
10018 l_first_rec boolean := true ;
10019 r_ELS c_ELS%rowtype;
10020 l_elig_los_prte_id number ;
10021 l_object_version_number number ;
10022 l_effective_start_date date ;
10023 l_effective_end_date date ;
10024 l_prefix pqh_copy_entity_attribs.information1%type := null;
10025 l_suffix pqh_copy_entity_attribs.information1%type := null;
10026 l_new_value number(15);
10027 l_object_found_in_target boolean := false ;
10028 l_min_esd date;
10029 l_max_eed date;
10030 l_effective_date date;
10031 --
10032 begin
10033 -- Initialization
10034 l_object_found_in_target := false ;
10035 -- End Initialization
10036 -- Derive the prefix - sufix
10037 if p_prefix_suffix_cd = 'PREFIX' then
10038 l_prefix := p_prefix_suffix_text ;
10039 elsif p_prefix_suffix_cd = 'SUFFIX' then
10040 l_suffix := p_prefix_suffix_text ;
10041 else
10042 l_prefix := null ;
10043 l_suffix := null ;
10044 end if ;
10045 -- End Prefix Sufix derivation
10046 for r_ELS_unique in c_unique_ELS('ELS') loop
10047
10048 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
10049 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10050 r_ELS_unique.information3 >=
10051 ben_pd_copy_to_ben_one.g_copy_effective_date)
10052 ) then
10053 --
10054 hr_utility.set_location(' r_ELS_unique.table_route_id '||r_ELS_unique.table_route_id,10);
10055 hr_utility.set_location(' r_ELS_unique.information1 '||r_ELS_unique.information1,10);
10056 hr_utility.set_location( 'r_ELS_unique.information2 '||r_ELS_unique.information2,10);
10057 hr_utility.set_location( 'r_ELS_unique.information3 '||r_ELS_unique.information3,10);
10058 -- If reuse objects flag is 'Y' then check for the object in the target business group
10059 -- if found insert the record into PLSql table and exit the loop else try create the
10060 -- object in the target business group
10061 --
10062 l_object_found_in_target := false ;
10063 --UPD START
10064 l_update := false;
10065 l_process_date := p_effective_date;
10066 l_dml_operation:= r_ELS_unique.dml_operation ;
10067 --
10068
10069 /**********************moved from below **********************/
10070 open c_ELS(r_ELS_unique.table_route_id,
10071 r_ELS_unique.information1,
10072 r_ELS_unique.information2,
10073 r_ELS_unique.information3 ) ;
10074 --
10075 fetch c_ELS into r_ELS ;
10076 --
10077 close c_ELS ;
10078 --
10079 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ELS.INFORMATION263,l_dml_operation);
10080 l_LOS_FCTR_ID := get_fk('LOS_FCTR_ID', r_ELS.INFORMATION243,l_dml_operation);
10081
10082 /**********************************************************/
10083 if l_dml_operation = 'UPDATE' then
10084 --
10085 l_object_found_in_target := TRUE;
10086 --
10087 if l_process_date between r_ELS_unique.information2 and r_ELS_unique.information3 then
10088 l_update := true;
10089 if r_ELS_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
10090 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_LOS_PRTE_ID' then
10091 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LOS_PRTE_ID' ;
10092 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELS_unique.information1 ;
10093 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ELS_unique.information1 ;
10094 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
10095 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELS_unique.table_route_id;
10096 --
10097 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
10098 --
10099 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10100 --
10101 -- log_data('ELS',l_new_value,l_prefix || r_ELS_unique.name|| l_suffix,'REUSED');
10102 --
10103 end if ;
10104 hr_utility.set_location( 'found record for update',10);
10105 --
10106 else
10107 --
10108 l_update := false;
10109 --
10110 end if;
10111 else
10112 --
10113 --UPD END
10114 l_min_esd := null ;
10115 l_max_eed := null ;
10116 open c_ELS_min_max_dates(r_ELS_unique.table_route_id, r_ELS_unique.information1 ) ;
10117 fetch c_ELS_min_max_dates into l_min_esd,l_max_eed ;
10118 --
10119
10120 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10121 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
10122 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
10123 end if;
10124 l_min_esd := greatest(l_min_esd,r_ELS_unique.information2);
10125 /**********************moved up from here **********************
10126 open c_ELS(r_ELS_unique.table_route_id,
10127 r_ELS_unique.information1,
10128 r_ELS_unique.information2,
10129 r_ELS_unique.information3 ) ;
10130 --
10131 fetch c_ELS into r_ELS ;
10132 --
10133 close c_ELS ;
10134 --
10135 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ELS.INFORMATION263,l_dml_operation);
10136 l_LOS_FCTR_ID := get_fk('LOS_FCTR_ID', r_ELS.INFORMATION243,l_dml_operation);
10137
10138 **********************************************************/
10139
10140 if p_reuse_object_flag = 'Y' then
10141 if c_ELS_min_max_dates%found then
10142 -- cursor to find the object
10143 open c_find_ELS_in_target( l_min_esd,l_max_eed,
10144 p_target_business_group_id, nvl(l_elig_los_prte_id, -999) ) ;
10145 fetch c_find_ELS_in_target into l_new_value ;
10146 if c_find_ELS_in_target%found then
10147 --
10148 --TEMPIK
10149 l_dt_rec_found := dt_api.check_min_max_dates
10150 (p_base_table_name => 'BEN_ELIG_LOS_PRTE_F',
10151 p_base_key_column => 'ELIG_LOS_PRTE_ID',
10152 p_base_key_value => l_new_value,
10153 p_from_date => l_min_esd,
10154 p_to_date => l_max_eed );
10155 if l_dt_rec_found THEN
10156 --END TEMPIK
10157 if r_ELS_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
10158 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_LOS_PRTE_ID' then
10159 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LOS_PRTE_ID' ;
10160 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELS_unique.information1 ;
10161 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
10162 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
10163 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELS_unique.table_route_id;
10164 --
10165 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
10166 --
10167 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10168 end if ;
10169 --
10170 l_object_found_in_target := true ;
10171 --TEMPIK
10172 end if; -- l_dt_rec_found
10173 --END TEMPIK
10174 end if;
10175 close c_find_ELS_in_target ;
10176 --
10177 end if;
10178 end if ;
10179 --
10180 close c_ELS_min_max_dates ;
10181 end if; --if p_dml_operation
10182 --
10183 if not l_object_found_in_target OR l_update then
10184
10185 --
10186 l_current_pk_id := r_ELS.information1;
10187 --
10188 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
10189 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
10190 --
10191 if l_current_pk_id = l_prev_pk_id then
10192 --
10193 l_first_rec := false ;
10194 --
10195 else
10196 --
10197 l_first_rec := true ;
10198 --
10199 end if ;
10200 --
10201
10202 l_effective_date := r_ELS.information2;
10203 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10204 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
10205 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
10206 end if;
10207
10208 if l_first_rec and not l_update then
10209 -- Call Create routine.
10210 hr_utility.set_location(' BEN_ELIG_LOS_PRTE_F CREATE_ELIG_LOS_PRTE ',20);
10211 BEN_ELIG_LOS_PRTE_API.CREATE_ELIG_LOS_PRTE(
10212 --
10213 P_VALIDATE => false
10214 ,P_EFFECTIVE_DATE => l_effective_date
10215 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
10216 --
10217 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
10218 ,P_ELIG_LOS_PRTE_ID => l_elig_los_prte_id
10219 ,P_ELS_ATTRIBUTE1 => r_ELS.INFORMATION111
10220 ,P_ELS_ATTRIBUTE10 => r_ELS.INFORMATION120
10221 ,P_ELS_ATTRIBUTE11 => r_ELS.INFORMATION121
10222 ,P_ELS_ATTRIBUTE12 => r_ELS.INFORMATION122
10223 ,P_ELS_ATTRIBUTE13 => r_ELS.INFORMATION123
10224 ,P_ELS_ATTRIBUTE14 => r_ELS.INFORMATION124
10225 ,P_ELS_ATTRIBUTE15 => r_ELS.INFORMATION125
10226 ,P_ELS_ATTRIBUTE16 => r_ELS.INFORMATION126
10227 ,P_ELS_ATTRIBUTE17 => r_ELS.INFORMATION127
10228 ,P_ELS_ATTRIBUTE18 => r_ELS.INFORMATION128
10229 ,P_ELS_ATTRIBUTE19 => r_ELS.INFORMATION129
10230 ,P_ELS_ATTRIBUTE2 => r_ELS.INFORMATION112
10231 ,P_ELS_ATTRIBUTE20 => r_ELS.INFORMATION130
10232 ,P_ELS_ATTRIBUTE21 => r_ELS.INFORMATION131
10233 ,P_ELS_ATTRIBUTE22 => r_ELS.INFORMATION132
10234 ,P_ELS_ATTRIBUTE23 => r_ELS.INFORMATION133
10235 ,P_ELS_ATTRIBUTE24 => r_ELS.INFORMATION134
10236 ,P_ELS_ATTRIBUTE25 => r_ELS.INFORMATION135
10237 ,P_ELS_ATTRIBUTE26 => r_ELS.INFORMATION136
10238 ,P_ELS_ATTRIBUTE27 => r_ELS.INFORMATION137
10239 ,P_ELS_ATTRIBUTE28 => r_ELS.INFORMATION138
10240 ,P_ELS_ATTRIBUTE29 => r_ELS.INFORMATION139
10241 ,P_ELS_ATTRIBUTE3 => r_ELS.INFORMATION113
10242 ,P_ELS_ATTRIBUTE30 => r_ELS.INFORMATION140
10243 ,P_ELS_ATTRIBUTE4 => r_ELS.INFORMATION114
10244 ,P_ELS_ATTRIBUTE5 => r_ELS.INFORMATION115
10245 ,P_ELS_ATTRIBUTE6 => r_ELS.INFORMATION116
10246 ,P_ELS_ATTRIBUTE7 => r_ELS.INFORMATION117
10247 ,P_ELS_ATTRIBUTE8 => r_ELS.INFORMATION118
10248 ,P_ELS_ATTRIBUTE9 => r_ELS.INFORMATION119
10249 ,P_ELS_ATTRIBUTE_CATEGORY => r_ELS.INFORMATION110
10250 ,P_EXCLD_FLAG => r_ELS.INFORMATION11
10251 ,P_LOS_FCTR_ID => l_LOS_FCTR_ID
10252 ,P_ORDR_NUM => r_ELS.INFORMATION260
10253 --
10254 -- ****** END CHANGE LINES
10255
10256 --
10257
10258 ,P_EFFECTIVE_START_DATE => l_effective_start_date
10259 ,P_EFFECTIVE_END_DATE => l_effective_end_date
10260 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
10261 ,P_CRITERIA_SCORE => r_els.INFORMATION295
10262 ,P_CRITERIA_WEIGHT => r_els.INFORMATION296
10263 );
10264
10265 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
10266 -- Update all relevent cer records with new pk_id
10267 hr_utility.set_location('Before plsql table ',222);
10268 hr_utility.set_location('new_value id '||l_elig_los_prte_id,222);
10269 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LOS_PRTE_ID' ;
10270 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELS.information1 ;
10271 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_LOS_PRTE_ID ;
10272 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
10273 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELS_unique.table_route_id;
10274 hr_utility.set_location('After plsql table ',222);
10275 --
10276 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
10277 --
10278 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10279 --
10280 else
10281 --
10282 -- Call Update routine for the pk_id created in prev run .
10283 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
10284 hr_utility.set_location(' BEN_ELIG_LOS_PRTE_F UPDATE_ELIG_LOS_PRTE ',30);
10285 --UPD START
10286 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
10287 --
10288 if l_update then
10289 --
10290 l_datetrack_mode := r_ELS.datetrack_mode ;
10291 --
10292 get_dt_modes(
10293 p_effective_date => l_process_date,
10294 p_effective_end_date => r_ELS.information3,
10295 p_effective_start_date => r_ELS.information2,
10296 p_dml_operation => r_ELS.dml_operation,
10297 p_datetrack_mode => l_datetrack_mode );
10298 -- p_update => l_update
10299 --
10300 l_effective_date := l_process_date;
10301 l_ELIG_LOS_PRTE_ID := r_ELS.information1;
10302 l_object_version_number := r_ELS.information265;
10303 --
10304 end if;
10305 --
10306 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
10307 --
10308 IF l_update OR l_dml_operation <> 'UPDATE' THEN
10309 --UPD END
10310
10311
10312 BEN_ELIG_LOS_PRTE_API.UPDATE_ELIG_LOS_PRTE(
10313 --
10314 P_VALIDATE => false
10315 ,P_EFFECTIVE_DATE => l_effective_date
10316 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
10317 --
10318 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
10319 ,P_ELIG_LOS_PRTE_ID => l_elig_los_prte_id
10320 ,P_ELS_ATTRIBUTE1 => r_ELS.INFORMATION111
10321 ,P_ELS_ATTRIBUTE10 => r_ELS.INFORMATION120
10322 ,P_ELS_ATTRIBUTE11 => r_ELS.INFORMATION121
10323 ,P_ELS_ATTRIBUTE12 => r_ELS.INFORMATION122
10324 ,P_ELS_ATTRIBUTE13 => r_ELS.INFORMATION123
10325 ,P_ELS_ATTRIBUTE14 => r_ELS.INFORMATION124
10326 ,P_ELS_ATTRIBUTE15 => r_ELS.INFORMATION125
10327 ,P_ELS_ATTRIBUTE16 => r_ELS.INFORMATION126
10328 ,P_ELS_ATTRIBUTE17 => r_ELS.INFORMATION127
10329 ,P_ELS_ATTRIBUTE18 => r_ELS.INFORMATION128
10330 ,P_ELS_ATTRIBUTE19 => r_ELS.INFORMATION129
10331 ,P_ELS_ATTRIBUTE2 => r_ELS.INFORMATION112
10332 ,P_ELS_ATTRIBUTE20 => r_ELS.INFORMATION130
10333 ,P_ELS_ATTRIBUTE21 => r_ELS.INFORMATION131
10334 ,P_ELS_ATTRIBUTE22 => r_ELS.INFORMATION132
10335 ,P_ELS_ATTRIBUTE23 => r_ELS.INFORMATION133
10336 ,P_ELS_ATTRIBUTE24 => r_ELS.INFORMATION134
10337 ,P_ELS_ATTRIBUTE25 => r_ELS.INFORMATION135
10338 ,P_ELS_ATTRIBUTE26 => r_ELS.INFORMATION136
10339 ,P_ELS_ATTRIBUTE27 => r_ELS.INFORMATION137
10340 ,P_ELS_ATTRIBUTE28 => r_ELS.INFORMATION138
10341 ,P_ELS_ATTRIBUTE29 => r_ELS.INFORMATION139
10342 ,P_ELS_ATTRIBUTE3 => r_ELS.INFORMATION113
10343 ,P_ELS_ATTRIBUTE30 => r_ELS.INFORMATION140
10344 ,P_ELS_ATTRIBUTE4 => r_ELS.INFORMATION114
10345 ,P_ELS_ATTRIBUTE5 => r_ELS.INFORMATION115
10346 ,P_ELS_ATTRIBUTE6 => r_ELS.INFORMATION116
10347 ,P_ELS_ATTRIBUTE7 => r_ELS.INFORMATION117
10348 ,P_ELS_ATTRIBUTE8 => r_ELS.INFORMATION118
10349 ,P_ELS_ATTRIBUTE9 => r_ELS.INFORMATION119
10350 ,P_ELS_ATTRIBUTE_CATEGORY => r_ELS.INFORMATION110
10351 ,P_EXCLD_FLAG => r_ELS.INFORMATION11
10352 ,P_LOS_FCTR_ID => l_LOS_FCTR_ID
10353 ,P_ORDR_NUM => r_ELS.INFORMATION260
10354 --
10355 -- ****** END CHANGE LINES
10356
10357 --
10358 ,P_EFFECTIVE_START_DATE => l_effective_start_date
10359 ,P_EFFECTIVE_END_DATE => l_effective_end_date
10360 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
10361 ,P_DATETRACK_MODE => l_datetrack_mode
10362 ,P_CRITERIA_SCORE => r_els.INFORMATION295
10363 ,P_CRITERIA_WEIGHT => r_els.INFORMATION296
10364 );
10365 end if; -- l_update
10366 --
10367 end if;
10368 --
10369 -- Delete the row if it is end dated.
10370 --
10371 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
10372 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
10373 trunc(l_max_eed) = trunc(r_ELS.information3)) then
10374 --
10375 BEN_ELIG_LOS_PRTE_API.delete_ELIG_LOS_PRTE(
10376 --
10377 p_validate => false
10378 ,p_elig_los_prte_id => l_elig_los_prte_id
10379 ,p_effective_start_date => l_effective_start_date
10380 ,p_effective_end_date => l_effective_end_date
10381 ,p_object_version_number => l_object_version_number
10382 ,p_effective_date => l_max_eed
10383 ,p_datetrack_mode => hr_api.g_delete
10384 --
10385 );
10386 --
10387 end if;
10388 --
10389 l_prev_pk_id := l_current_pk_id ;
10390 --
10391 end if;
10392 --
10393 end if;
10394 --
10395 end loop;
10396 --
10397 exception when others then
10398 --
10399 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ELS',r_ELS.information5 ) ;
10400 --
10401 end create_ELS_rows;
10402
10403
10404
10405 --
10406 ---------------------------------------------------------------
10407 ----------------------< create_ELV_rows >-----------------------
10408 ---------------------------------------------------------------
10409 --
10410 procedure create_ELV_rows
10411 (
10412 p_validate in number default 0
10413 ,p_copy_entity_txn_id in number
10414 ,p_effective_date in date
10415 ,p_prefix_suffix_text in varchar2 default null
10416 ,p_reuse_object_flag in varchar2 default null
10417 ,p_target_business_group_id in varchar2 default null
10418 ,p_prefix_suffix_cd in varchar2 default null
10419 ) is
10420 --
10421 l_ELIGY_PRFL_ID number;
10422 l_LVG_RSN_CD varchar2(30); -- IK Added
10423 cursor c_unique_ELV(l_table_alias varchar2) is
10424 select distinct cpe.information1,
10425 cpe.information2,
10426 cpe.information3,
10427 cpe.table_route_id
10428 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
10429 pqh_table_route tr
10430 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10431 and cpe.table_route_id = tr.table_route_id
10432 -- and tr.where_clause = l_BEN_ELIG_LVG_RSN_PRTE_F
10433 and tr.table_alias = l_table_alias
10434 and cpe.number_of_copies = 1 -- ADDITION
10435 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
10436 order by information1, information2; --added for bug: 5151945
10437 --
10438 --
10439 cursor c_ELV_min_max_dates(c_table_route_id number,
10440 c_information1 number) is
10441 select
10442 min(cpe.information2) min_esd,
10443 max(cpe.information3) min_eed
10444 from ben_copy_entity_results cpe
10445 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10446 and cpe.table_route_id = c_table_route_id
10447 and cpe.information1 = c_information1 ;
10448 --
10449 cursor c_ELV(c_table_route_id number,
10450 c_information1 number,
10451 c_information2 date,
10452 c_information3 date ) is
10453 select
10454 cpe.*
10455 from ben_copy_entity_results cpe
10456 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10457 and cpe.table_route_id = c_table_route_id
10458 and cpe.information1 = c_information1
10459 and cpe.information2 = c_information2
10460 and cpe.information3 = c_information3
10461 and rownum = 1 ;
10462 -- Date Track target record
10463 cursor c_find_ELV_in_target(
10464 c_effective_start_date date,
10465 c_effective_end_date date,
10466 c_business_group_id number,
10467 c_new_pk_id number) is
10468 select
10469 ELV.elig_lvg_rsn_prte_id new_value
10470 from BEN_ELIG_LVG_RSN_PRTE_F ELV
10471 where
10472 ELV.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
10473 ELV.LVG_RSN_CD = l_LVG_RSN_CD and
10474 ELV.business_group_id = c_business_group_id
10475 and ELV.elig_lvg_rsn_prte_id <> c_new_pk_id
10476 and c_effective_start_date between effective_start_date
10477 and effective_end_date ;
10478 --END TEMPIK
10479 /*TEMPIK
10480 and exists ( select null
10481 from BEN_ELIG_LVG_RSN_PRTE_F ELV1
10482 where
10483 ELV1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
10484 ELV1.LVG_RSN_CD = l_LVG_RSN_CD and
10485 ELV1.business_group_id = c_business_group_id
10486 and ELV1.effective_start_date <= c_effective_start_date )
10487 and exists ( select null
10488 from BEN_ELIG_LVG_RSN_PRTE_F ELV2
10489 where
10490 ELV2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
10491 ELV2.LVG_RSN_CD = l_LVG_RSN_CD and
10492 ELV2.business_group_id = c_business_group_id
10493 and ELV2.effective_end_date >= c_effective_end_date )
10494 ;
10495 TEMPIK */
10496 --TEMPIK
10497 l_dt_rec_found boolean ;
10498 --END TEMPIK
10499 --
10500
10501 --UPD START
10502 --
10503 l_update boolean := false ;
10504 l_datetrack_mode varchar2(80) := hr_api.g_update;
10505 l_process_date date;
10506 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
10507 --
10508 --UPD END
10509 l_current_pk_id number := null ;
10510
10511 l_prev_pk_id number := null ;
10512 l_first_rec boolean := true ;
10513 r_ELV c_ELV%rowtype;
10514 l_elig_lvg_rsn_prte_id number ;
10515 l_object_version_number number ;
10516 l_effective_start_date date ;
10517 l_effective_end_date date ;
10518 l_prefix pqh_copy_entity_attribs.information1%type := null;
10519 l_suffix pqh_copy_entity_attribs.information1%type := null;
10520 l_new_value number(15);
10521 l_object_found_in_target boolean := false ;
10522 l_min_esd date;
10523 l_max_eed date;
10524 l_effective_date date;
10525 --
10526 begin
10527 -- Initialization
10528 l_object_found_in_target := false ;
10529 -- End Initialization
10530 -- Derive the prefix - sufix
10531 if p_prefix_suffix_cd = 'PREFIX' then
10532 l_prefix := p_prefix_suffix_text ;
10533 elsif p_prefix_suffix_cd = 'SUFFIX' then
10534 l_suffix := p_prefix_suffix_text ;
10535 else
10536 l_prefix := null ;
10537 l_suffix := null ;
10538 end if ;
10539 -- End Prefix Sufix derivation
10540 for r_ELV_unique in c_unique_ELV('ELV') loop
10541
10542 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
10543 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10544 r_ELV_unique.information3 >=
10545 ben_pd_copy_to_ben_one.g_copy_effective_date)
10546 ) then
10547 --
10548 hr_utility.set_location(' r_ELV_unique.table_route_id '||r_ELV_unique.table_route_id,10);
10549 hr_utility.set_location(' r_ELV_unique.information1 '||r_ELV_unique.information1,10);
10550 hr_utility.set_location( 'r_ELV_unique.information2 '||r_ELV_unique.information2,10);
10551 hr_utility.set_location( 'r_ELV_unique.information3 '||r_ELV_unique.information3,10);
10552 -- If reuse objects flag is 'Y' then check for the object in the target business group
10553 -- if found insert the record into PLSql table and exit the loop else try create the
10554 -- object in the target business group
10555 --
10556 l_object_found_in_target := false ;
10557 --UPD START
10558 l_update := false;
10559 l_process_date := p_effective_date;
10560 l_dml_operation:= r_ELV_unique.dml_operation ;
10561 --
10562
10563 /**********************moved from below **********************/
10564 open c_ELV(r_ELV_unique.table_route_id,
10565 r_ELV_unique.information1,
10566 r_ELV_unique.information2,
10567 r_ELV_unique.information3 ) ;
10568 --
10569 fetch c_ELV into r_ELV ;
10570 --
10571 close c_ELV ;
10572 --
10573 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ELV.INFORMATION263,l_dml_operation);
10574 l_LVG_RSN_CD := r_ELV.INFORMATION12 ;
10575
10576 /**********************************************************/
10577 if l_dml_operation = 'UPDATE' then
10578 --
10579 l_object_found_in_target := TRUE;
10580 --
10581 if l_process_date between r_ELV_unique.information2 and r_ELV_unique.information3 then
10582 l_update := true;
10583 if r_ELV_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
10584 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_LVG_RSN_PRTE_ID' then
10585 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LVG_RSN_PRTE_ID' ;
10586 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELV_unique.information1 ;
10587 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ELV_unique.information1 ;
10588 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
10589 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELV_unique.table_route_id;
10590 --
10591 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
10592 --
10593 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10594 --
10595 -- log_data('ELV',l_new_value,l_prefix || r_ELV_unique.name|| l_suffix,'REUSED');
10596 --
10597 end if ;
10598 hr_utility.set_location( 'found record for update',10);
10599 --
10600 else
10601 --
10602 l_update := false;
10603 --
10604 end if;
10605 else
10606 --
10607 --UPD END
10608 l_min_esd := null ;
10609 l_max_eed := null ;
10610 open c_ELV_min_max_dates(r_ELV_unique.table_route_id, r_ELV_unique.information1 ) ;
10611 fetch c_ELV_min_max_dates into l_min_esd,l_max_eed ;
10612 --
10613
10614 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10615 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
10616 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
10617 end if;
10618 l_min_esd := greatest(l_min_esd,r_ELV_unique.information2);
10619 /**********************moved up from here **********************
10620 open c_ELV(r_ELV_unique.table_route_id,
10621 r_ELV_unique.information1,
10622 r_ELV_unique.information2,
10623 r_ELV_unique.information3 ) ;
10624 --
10625 fetch c_ELV into r_ELV ;
10626 --
10627 close c_ELV ;
10628 --
10629 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ELV.INFORMATION263,l_dml_operation);
10630 l_LVG_RSN_CD := r_ELV.INFORMATION12 ;
10631
10632 **********************************************************/
10633
10634 --
10635 if p_reuse_object_flag = 'Y' then
10636 if c_ELV_min_max_dates%found then
10637 -- cursor to find the object
10638 open c_find_ELV_in_target( l_min_esd,l_max_eed,
10639 p_target_business_group_id, nvl(l_elig_lvg_rsn_prte_id, -999) ) ;
10640 fetch c_find_ELV_in_target into l_new_value ;
10641 if c_find_ELV_in_target%found then
10642 --
10643 --TEMPIK
10644 l_dt_rec_found := dt_api.check_min_max_dates
10645 (p_base_table_name => 'BEN_ELIG_LVG_RSN_PRTE_F',
10646 p_base_key_column => 'ELIG_LVG_RSN_PRTE_ID',
10647 p_base_key_value => l_new_value,
10648 p_from_date => l_min_esd,
10649 p_to_date => l_max_eed );
10650 if l_dt_rec_found THEN
10651 --END TEMPIK
10652 if r_ELV_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
10653 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_LVG_RSN_PRTE_ID' then
10654 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LVG_RSN_PRTE_ID' ;
10655 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELV_unique.information1 ;
10656 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
10657 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
10658 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELV_unique.table_route_id;
10659 --
10660 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
10661 --
10662 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10663 end if ;
10664 --
10665 l_object_found_in_target := true ;
10666 --TEMPIK
10667 end if; -- l_dt_rec_found
10668 --END TEMPIK
10669 end if;
10670 close c_find_ELV_in_target ;
10671 --
10672 end if;
10673 end if ;
10674 --
10675 close c_ELV_min_max_dates ;
10676 end if; --if p_dml_operation
10677 --
10678 if not l_object_found_in_target OR l_update then
10679
10680 --
10681 l_current_pk_id := r_ELV.information1;
10682 --
10683 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
10684 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
10685 --
10686 if l_current_pk_id = l_prev_pk_id then
10687 --
10688 l_first_rec := false ;
10689 --
10690 else
10691 --
10692 l_first_rec := true ;
10693 --
10694 end if ;
10695 --
10696
10697 l_effective_date := r_ELV.information2;
10698 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10699 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
10700 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
10701 end if;
10702
10703 if l_first_rec and not l_update then
10704 -- Call Create routine.
10705 hr_utility.set_location(' BEN_ELIG_LVG_RSN_PRTE_F CREATE_ELIG_LVG_RSN_PRTE ',20);
10706 BEN_ELIG_LVG_RSN_PRTE_API.CREATE_ELIG_LVG_RSN_PRTE(
10707 --
10708 P_VALIDATE => false
10709 ,P_EFFECTIVE_DATE => l_effective_date
10710 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
10711 --
10712 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
10713 ,P_ELIG_LVG_RSN_PRTE_ID => l_elig_lvg_rsn_prte_id
10714 ,P_ELV_ATTRIBUTE1 => r_ELV.INFORMATION111
10715 ,P_ELV_ATTRIBUTE10 => r_ELV.INFORMATION120
10716 ,P_ELV_ATTRIBUTE11 => r_ELV.INFORMATION121
10717 ,P_ELV_ATTRIBUTE12 => r_ELV.INFORMATION122
10718 ,P_ELV_ATTRIBUTE13 => r_ELV.INFORMATION123
10719 ,P_ELV_ATTRIBUTE14 => r_ELV.INFORMATION124
10720 ,P_ELV_ATTRIBUTE15 => r_ELV.INFORMATION125
10721 ,P_ELV_ATTRIBUTE16 => r_ELV.INFORMATION126
10722 ,P_ELV_ATTRIBUTE17 => r_ELV.INFORMATION127
10723 ,P_ELV_ATTRIBUTE18 => r_ELV.INFORMATION128
10724 ,P_ELV_ATTRIBUTE19 => r_ELV.INFORMATION129
10725 ,P_ELV_ATTRIBUTE2 => r_ELV.INFORMATION112
10726 ,P_ELV_ATTRIBUTE20 => r_ELV.INFORMATION130
10727 ,P_ELV_ATTRIBUTE21 => r_ELV.INFORMATION131
10728 ,P_ELV_ATTRIBUTE22 => r_ELV.INFORMATION132
10729 ,P_ELV_ATTRIBUTE23 => r_ELV.INFORMATION133
10730 ,P_ELV_ATTRIBUTE24 => r_ELV.INFORMATION134
10731 ,P_ELV_ATTRIBUTE25 => r_ELV.INFORMATION135
10732 ,P_ELV_ATTRIBUTE26 => r_ELV.INFORMATION136
10733 ,P_ELV_ATTRIBUTE27 => r_ELV.INFORMATION137
10734 ,P_ELV_ATTRIBUTE28 => r_ELV.INFORMATION138
10735 ,P_ELV_ATTRIBUTE29 => r_ELV.INFORMATION139
10736 ,P_ELV_ATTRIBUTE3 => r_ELV.INFORMATION113
10737 ,P_ELV_ATTRIBUTE30 => r_ELV.INFORMATION140
10738 ,P_ELV_ATTRIBUTE4 => r_ELV.INFORMATION114
10739 ,P_ELV_ATTRIBUTE5 => r_ELV.INFORMATION115
10740 ,P_ELV_ATTRIBUTE6 => r_ELV.INFORMATION116
10741 ,P_ELV_ATTRIBUTE7 => r_ELV.INFORMATION117
10742 ,P_ELV_ATTRIBUTE8 => r_ELV.INFORMATION118
10743 ,P_ELV_ATTRIBUTE9 => r_ELV.INFORMATION119
10744 ,P_ELV_ATTRIBUTE_CATEGORY => r_ELV.INFORMATION110
10745 ,P_EXCLD_FLAG => r_ELV.INFORMATION11
10746 ,P_LVG_RSN_CD => r_ELV.INFORMATION12
10747 ,P_ORDR_NUM => r_ELV.INFORMATION260
10748 --
10749 -- ****** END CHANGE LINES
10750
10751 --
10752
10753 ,P_EFFECTIVE_START_DATE => l_effective_start_date
10754 ,P_EFFECTIVE_END_DATE => l_effective_end_date
10755 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
10756 ,P_CRITERIA_SCORE => r_elv.INFORMATION295
10757 ,P_CRITERIA_WEIGHT => r_elv.INFORMATION296
10758 );
10759
10760 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
10761 -- Update all relevent cer records with new pk_id
10762 hr_utility.set_location('Before plsql table ',222);
10763 hr_utility.set_location('new_value id '||l_elig_lvg_rsn_prte_id,222);
10764 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_LVG_RSN_PRTE_ID' ;
10765 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ELV.information1 ;
10766 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_LVG_RSN_PRTE_ID ;
10767 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
10768 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ELV_unique.table_route_id;
10769 hr_utility.set_location('After plsql table ',222);
10770 --
10771 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
10772 --
10773 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10774 --
10775 else
10776 --
10777 -- Call Update routine for the pk_id created in prev run .
10778 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
10779 hr_utility.set_location(' BEN_ELIG_LVG_RSN_PRTE_F UPDATE_ELIG_LVG_RSN_PRTE ',30);
10780 --UPD START
10781 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
10782 --
10783 if l_update then
10784 --
10785 l_datetrack_mode := r_ELV.datetrack_mode ;
10786 --
10787 get_dt_modes(
10788 p_effective_date => l_process_date,
10789 p_effective_end_date => r_ELV.information3,
10790 p_effective_start_date => r_ELV.information2,
10791 p_dml_operation => r_ELV.dml_operation,
10792 p_datetrack_mode => l_datetrack_mode );
10793 -- p_update => l_update
10794 --
10795 l_effective_date := l_process_date;
10796 l_ELIG_LVG_RSN_PRTE_ID := r_ELV.information1;
10797 l_object_version_number := r_ELV.information265;
10798 --
10799 end if;
10800 --
10801 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
10802 --
10803 IF l_update OR l_dml_operation <> 'UPDATE' THEN
10804 --UPD END
10805
10806
10807 BEN_ELIG_LVG_RSN_PRTE_API.UPDATE_ELIG_LVG_RSN_PRTE(
10808 --
10809 P_VALIDATE => false
10810 ,P_EFFECTIVE_DATE => l_effective_date
10811 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
10812 --
10813 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
10814 ,P_ELIG_LVG_RSN_PRTE_ID => l_elig_lvg_rsn_prte_id
10815 ,P_ELV_ATTRIBUTE1 => r_ELV.INFORMATION111
10816 ,P_ELV_ATTRIBUTE10 => r_ELV.INFORMATION120
10817 ,P_ELV_ATTRIBUTE11 => r_ELV.INFORMATION121
10818 ,P_ELV_ATTRIBUTE12 => r_ELV.INFORMATION122
10819 ,P_ELV_ATTRIBUTE13 => r_ELV.INFORMATION123
10820 ,P_ELV_ATTRIBUTE14 => r_ELV.INFORMATION124
10821 ,P_ELV_ATTRIBUTE15 => r_ELV.INFORMATION125
10822 ,P_ELV_ATTRIBUTE16 => r_ELV.INFORMATION126
10823 ,P_ELV_ATTRIBUTE17 => r_ELV.INFORMATION127
10824 ,P_ELV_ATTRIBUTE18 => r_ELV.INFORMATION128
10825 ,P_ELV_ATTRIBUTE19 => r_ELV.INFORMATION129
10826 ,P_ELV_ATTRIBUTE2 => r_ELV.INFORMATION112
10827 ,P_ELV_ATTRIBUTE20 => r_ELV.INFORMATION130
10828 ,P_ELV_ATTRIBUTE21 => r_ELV.INFORMATION131
10829 ,P_ELV_ATTRIBUTE22 => r_ELV.INFORMATION132
10830 ,P_ELV_ATTRIBUTE23 => r_ELV.INFORMATION133
10831 ,P_ELV_ATTRIBUTE24 => r_ELV.INFORMATION134
10832 ,P_ELV_ATTRIBUTE25 => r_ELV.INFORMATION135
10833 ,P_ELV_ATTRIBUTE26 => r_ELV.INFORMATION136
10834 ,P_ELV_ATTRIBUTE27 => r_ELV.INFORMATION137
10835 ,P_ELV_ATTRIBUTE28 => r_ELV.INFORMATION138
10836 ,P_ELV_ATTRIBUTE29 => r_ELV.INFORMATION139
10837 ,P_ELV_ATTRIBUTE3 => r_ELV.INFORMATION113
10838 ,P_ELV_ATTRIBUTE30 => r_ELV.INFORMATION140
10839 ,P_ELV_ATTRIBUTE4 => r_ELV.INFORMATION114
10840 ,P_ELV_ATTRIBUTE5 => r_ELV.INFORMATION115
10841 ,P_ELV_ATTRIBUTE6 => r_ELV.INFORMATION116
10842 ,P_ELV_ATTRIBUTE7 => r_ELV.INFORMATION117
10843 ,P_ELV_ATTRIBUTE8 => r_ELV.INFORMATION118
10844 ,P_ELV_ATTRIBUTE9 => r_ELV.INFORMATION119
10845 ,P_ELV_ATTRIBUTE_CATEGORY => r_ELV.INFORMATION110
10846 ,P_EXCLD_FLAG => r_ELV.INFORMATION11
10847 ,P_LVG_RSN_CD => r_ELV.INFORMATION12
10848 ,P_ORDR_NUM => r_ELV.INFORMATION260
10849 --
10850 -- ****** END CHANGE LINES
10851
10852 --
10853 ,P_EFFECTIVE_START_DATE => l_effective_start_date
10854 ,P_EFFECTIVE_END_DATE => l_effective_end_date
10855 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
10856 ,P_DATETRACK_MODE => l_datetrack_mode
10857 ,P_CRITERIA_SCORE => r_elv.INFORMATION295
10858 ,P_CRITERIA_WEIGHT => r_elv.INFORMATION296
10859 );
10860 end if; -- l_update
10861 --
10862 end if;
10863 --
10864 -- Delete the row if it is end dated.
10865 --
10866 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
10867 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
10868 trunc(l_max_eed) = trunc(r_ELV.information3)) then
10869 --
10870 BEN_ELIG_LVG_RSN_PRTE_API.delete_ELIG_LVG_RSN_PRTE(
10871 --
10872 p_validate => false
10873 ,p_elig_lvg_rsn_prte_id => l_elig_lvg_rsn_prte_id
10874 ,p_effective_start_date => l_effective_start_date
10875 ,p_effective_end_date => l_effective_end_date
10876 ,p_object_version_number => l_object_version_number
10877 ,p_effective_date => l_max_eed
10878 ,p_datetrack_mode => hr_api.g_delete
10879 --
10880 );
10881 --
10882 end if;
10883 --
10884 l_prev_pk_id := l_current_pk_id ;
10885 --
10886 end if;
10887 --
10888 end if;
10889 --
10890 end loop;
10891 --
10892 exception when others then
10893 --
10894 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ELV',r_ELV.information5 ) ;
10895 --
10896 end create_ELV_rows;
10897
10898
10899
10900 --
10901 ---------------------------------------------------------------
10902 ----------------------< create_EMP_rows >-----------------------
10903 ---------------------------------------------------------------
10904 --
10905 procedure create_EMP_rows
10906 (
10907 p_validate in number default 0
10908 ,p_copy_entity_txn_id in number
10909 ,p_effective_date in date
10910 ,p_prefix_suffix_text in varchar2 default null
10911 ,p_reuse_object_flag in varchar2 default null
10912 ,p_target_business_group_id in varchar2 default null
10913 ,p_prefix_suffix_cd in varchar2 default null
10914 ) is
10915 --
10916 l_ELIGY_PRFL_ID number;
10917 l_MARITAL_STATUS ben_elig_mrtl_sts_prte_f.marital_status%type;
10918
10919 cursor c_unique_EMP(l_table_alias varchar2) is
10920 select distinct cpe.information1,
10921 cpe.information2,
10922 cpe.information3,
10923 cpe.table_route_id
10924 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
10925 pqh_table_route tr
10926 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10927 and cpe.table_route_id = tr.table_route_id
10928 -- and tr.where_clause = l_BEN_ELIG_MRTL_STS_PRTE_F
10929 and tr.table_alias = l_table_alias
10930 and cpe.number_of_copies = 1 -- ADDITION
10931 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
10932 order by information1, information2; --added for bug: 5151945
10933 --
10934 --
10935 cursor c_EMP_min_max_dates(c_table_route_id number,
10936 c_information1 number) is
10937 select
10938 min(cpe.information2) min_esd,
10939 max(cpe.information3) min_eed
10940 from ben_copy_entity_results cpe
10941 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10942 and cpe.table_route_id = c_table_route_id
10943 and cpe.information1 = c_information1 ;
10944 --
10945 cursor c_EMP(c_table_route_id number,
10946 c_information1 number,
10947 c_information2 date,
10948 c_information3 date ) is
10949 select
10950 cpe.*
10951 from ben_copy_entity_results cpe
10952 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10953 and cpe.table_route_id = c_table_route_id
10954 and cpe.information1 = c_information1
10955 and cpe.information2 = c_information2
10956 and cpe.information3 = c_information3
10957 and rownum = 1 ;
10958 -- Date Track target record
10959 cursor c_find_EMP_in_target(
10960 c_effective_start_date date,
10961 c_effective_end_date date,
10962 c_business_group_id number,
10963 c_new_pk_id number) is
10964 select
10965 EMP.elig_mrtl_sts_prte_id new_value
10966 from BEN_ELIG_MRTL_STS_PRTE_F EMP
10967 where
10968 EMP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
10969 EMP.business_group_id = c_business_group_id and
10970 EMP.MARITAL_STATUS = l_MARITAL_STATUS and
10971 EMP.elig_mrtl_sts_prte_id <> c_new_pk_id
10972 and c_effective_start_date between effective_start_date
10973 and effective_end_date ;
10974 --END TEMPIK
10975 /*TEMPIK
10976 and exists ( select null
10977 from BEN_ELIG_MRTL_STS_PRTE_F EMP1
10978 where
10979 EMP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
10980 EMP1.MARITAL_STATUS = l_MARITAL_STATUS and
10981 EMP1.business_group_id = c_business_group_id
10982 and EMP1.effective_start_date <= c_effective_start_date )
10983 and exists ( select null
10984 from BEN_ELIG_MRTL_STS_PRTE_F EMP2
10985 where
10986 EMP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
10987 EMP2.MARITAL_STATUS = l_MARITAL_STATUS and
10988 EMP2.business_group_id = c_business_group_id
10989 and EMP2.effective_end_date >= c_effective_end_date )
10990 ;
10991 TEMPIK */
10992 --TEMPIK
10993 l_dt_rec_found boolean ;
10994 --END TEMPIK
10995 --
10996
10997 --UPD START
10998 --
10999 l_update boolean := false ;
11000 l_datetrack_mode varchar2(80) := hr_api.g_update;
11001 l_process_date date;
11002 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
11003 --
11004 --UPD END
11005 l_current_pk_id number := null ;
11006
11007 l_prev_pk_id number := null ;
11008 l_first_rec boolean := true ;
11009 r_EMP c_EMP%rowtype;
11010 l_elig_mrtl_sts_prte_id number ;
11011 l_object_version_number number ;
11012 l_effective_start_date date ;
11013 l_effective_end_date date ;
11014 l_prefix pqh_copy_entity_attribs.information1%type := null;
11015 l_suffix pqh_copy_entity_attribs.information1%type := null;
11016 l_new_value number(15);
11017 l_object_found_in_target boolean := false ;
11018 l_min_esd date;
11019 l_max_eed date;
11020 l_effective_date date;
11021 --
11022 begin
11023 -- Initialization
11024 l_object_found_in_target := false ;
11025 -- End Initialization
11026 -- Derive the prefix - sufix
11027 if p_prefix_suffix_cd = 'PREFIX' then
11028 l_prefix := p_prefix_suffix_text ;
11029 elsif p_prefix_suffix_cd = 'SUFFIX' then
11030 l_suffix := p_prefix_suffix_text ;
11031 else
11032 l_prefix := null ;
11033 l_suffix := null ;
11034 end if ;
11035 -- End Prefix Sufix derivation
11036 for r_EMP_unique in c_unique_EMP('EMP') loop
11037
11038 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
11039 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11040 r_EMP_unique.information3 >=
11041 ben_pd_copy_to_ben_one.g_copy_effective_date)
11042 ) then
11043 --
11044 hr_utility.set_location(' r_EMP_unique.table_route_id '||r_EMP_unique.table_route_id,10);
11045 hr_utility.set_location(' r_EMP_unique.information1 '||r_EMP_unique.information1,10);
11046 hr_utility.set_location( 'r_EMP_unique.information2 '||r_EMP_unique.information2,10);
11047 hr_utility.set_location( 'r_EMP_unique.information3 '||r_EMP_unique.information3,10);
11048 -- If reuse objects flag is 'Y' then check for the object in the target business group
11049 -- if found insert the record into PLSql table and exit the loop else try create the
11050 -- object in the target business group
11051 --
11052 l_object_found_in_target := false ;
11053 --UPD START
11054 l_update := false;
11055 l_process_date := p_effective_date;
11056 l_dml_operation:= r_EMP_unique.dml_operation ;
11057 --
11058 /**********************moved from below **********************/
11059 open c_EMP(r_EMP_unique.table_route_id,
11060 r_EMP_unique.information1,
11061 r_EMP_unique.information2,
11062 r_EMP_unique.information3 ) ;
11063 --
11064 fetch c_EMP into r_EMP ;
11065 --
11066 close c_EMP ;
11067 --
11068 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EMP.INFORMATION263,l_dml_operation);
11069 l_MARITAL_STATUS := r_EMP.INFORMATION11;
11070
11071 /**********************************************************/
11072
11073 if l_dml_operation = 'UPDATE' then
11074 --
11075 l_object_found_in_target := TRUE;
11076 --
11077 if l_process_date between r_EMP_unique.information2 and r_EMP_unique.information3 then
11078 l_update := true;
11079 if r_EMP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
11080 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_MRTL_STS_PRTE_ID' then
11081 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_MRTL_STS_PRTE_ID' ;
11082 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EMP_unique.information1 ;
11083 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EMP_unique.information1 ;
11084 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
11085 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EMP_unique.table_route_id;
11086 --
11087 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
11088 --
11089 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
11090 --
11091 -- log_data('EMP',l_new_value,l_prefix || r_EMP_unique.name|| l_suffix,'REUSED');
11092 --
11093 end if ;
11094 hr_utility.set_location( 'found record for update',10);
11095 --
11096 else
11097 --
11098 l_update := false;
11099 --
11100 end if;
11101 else
11102 --
11103 --UPD END
11104 l_min_esd := null ;
11105 l_max_eed := null ;
11106 open c_EMP_min_max_dates(r_EMP_unique.table_route_id, r_EMP_unique.information1 ) ;
11107 fetch c_EMP_min_max_dates into l_min_esd,l_max_eed ;
11108 --
11109
11110 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11111 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
11112 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
11113 end if;
11114 l_min_esd := greatest(l_min_esd,r_EMP_unique.information2);
11115 /**********************moved up from here **********************
11116 open c_EMP(r_EMP_unique.table_route_id,
11117 r_EMP_unique.information1,
11118 r_EMP_unique.information2,
11119 r_EMP_unique.information3 ) ;
11120 --
11121 fetch c_EMP into r_EMP ;
11122 --
11123 close c_EMP ;
11124 --
11125 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EMP.INFORMATION263,l_dml_operation);
11126 l_MARITAL_STATUS := r_EMP.INFORMATION11;
11127
11128 **********************************************************/
11129
11130
11131 if p_reuse_object_flag = 'Y' then
11132 if c_EMP_min_max_dates%found then
11133 -- cursor to find the object
11134 open c_find_EMP_in_target( l_min_esd,l_max_eed,
11135 p_target_business_group_id, nvl(l_elig_mrtl_sts_prte_id, -999) ) ;
11136 fetch c_find_EMP_in_target into l_new_value ;
11137 if c_find_EMP_in_target%found then
11138 --
11139 --TEMPIK
11140 l_dt_rec_found := dt_api.check_min_max_dates
11141 (p_base_table_name => 'BEN_ELIG_MRTL_STS_PRTE_F',
11142 p_base_key_column => 'ELIG_MRTL_STS_PRTE_ID',
11143 p_base_key_value => l_new_value,
11144 p_from_date => l_min_esd,
11145 p_to_date => l_max_eed );
11146 if l_dt_rec_found THEN
11147 --END TEMPIK
11148 if r_EMP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
11149 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_MRTL_STS_PRTE_ID' then
11150 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_MRTL_STS_PRTE_ID' ;
11151 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EMP_unique.information1 ;
11152 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
11153 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
11154 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EMP_unique.table_route_id;
11155 --
11156 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
11157 --
11158 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
11159 end if ;
11160 --
11161 l_object_found_in_target := true ;
11162 --TEMPIK
11163 end if; -- l_dt_rec_found
11164 --END TEMPIK
11165 end if;
11166 close c_find_EMP_in_target ;
11167 --
11168 end if;
11169 end if ;
11170 --
11171 close c_EMP_min_max_dates ;
11172 end if; --if p_dml_operation
11173 --
11174 if not l_object_found_in_target OR l_update then
11175
11176 --
11177 l_current_pk_id := r_EMP.information1;
11178 --
11179 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
11180 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
11181 --
11182 if l_current_pk_id = l_prev_pk_id then
11183 --
11184 l_first_rec := false ;
11185 --
11186 else
11187 --
11188 l_first_rec := true ;
11189 --
11190 end if ;
11191 --
11192
11193 l_effective_date := r_EMP.information2;
11194 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11195 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
11196 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
11197 end if;
11198
11199 if l_first_rec and not l_update then
11200 -- Call Create routine.
11201 hr_utility.set_location(' BEN_ELIG_MRTL_STS_PRTE_F CREATE_ELIG_MRTL_STS_PRTE ',20);
11202 BEN_ELIG_MRTL_STS_PRTE_API.CREATE_ELIG_MRTL_STS_PRTE(
11203 --
11204 P_VALIDATE => false
11205 ,P_EFFECTIVE_DATE => l_effective_date
11206 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11207 --
11208 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
11209 ,P_ELIG_MRTL_STS_PRTE_ID => l_elig_mrtl_sts_prte_id
11210 ,P_EMP_ATTRIBUTE1 => r_EMP.INFORMATION111
11211 ,P_EMP_ATTRIBUTE10 => r_EMP.INFORMATION120
11212 ,P_EMP_ATTRIBUTE11 => r_EMP.INFORMATION121
11213 ,P_EMP_ATTRIBUTE12 => r_EMP.INFORMATION122
11214 ,P_EMP_ATTRIBUTE13 => r_EMP.INFORMATION123
11215 ,P_EMP_ATTRIBUTE14 => r_EMP.INFORMATION124
11216 ,P_EMP_ATTRIBUTE15 => r_EMP.INFORMATION125
11217 ,P_EMP_ATTRIBUTE16 => r_EMP.INFORMATION126
11218 ,P_EMP_ATTRIBUTE17 => r_EMP.INFORMATION127
11219 ,P_EMP_ATTRIBUTE18 => r_EMP.INFORMATION128
11220 ,P_EMP_ATTRIBUTE19 => r_EMP.INFORMATION129
11221 ,P_EMP_ATTRIBUTE2 => r_EMP.INFORMATION112
11222 ,P_EMP_ATTRIBUTE20 => r_EMP.INFORMATION130
11223 ,P_EMP_ATTRIBUTE21 => r_EMP.INFORMATION131
11224 ,P_EMP_ATTRIBUTE22 => r_EMP.INFORMATION132
11225 ,P_EMP_ATTRIBUTE23 => r_EMP.INFORMATION133
11226 ,P_EMP_ATTRIBUTE24 => r_EMP.INFORMATION134
11227 ,P_EMP_ATTRIBUTE25 => r_EMP.INFORMATION135
11228 ,P_EMP_ATTRIBUTE26 => r_EMP.INFORMATION136
11229 ,P_EMP_ATTRIBUTE27 => r_EMP.INFORMATION137
11230 ,P_EMP_ATTRIBUTE28 => r_EMP.INFORMATION138
11231 ,P_EMP_ATTRIBUTE29 => r_EMP.INFORMATION139
11232 ,P_EMP_ATTRIBUTE3 => r_EMP.INFORMATION113
11233 ,P_EMP_ATTRIBUTE30 => r_EMP.INFORMATION140
11234 ,P_EMP_ATTRIBUTE4 => r_EMP.INFORMATION114
11235 ,P_EMP_ATTRIBUTE5 => r_EMP.INFORMATION115
11236 ,P_EMP_ATTRIBUTE6 => r_EMP.INFORMATION116
11237 ,P_EMP_ATTRIBUTE7 => r_EMP.INFORMATION117
11238 ,P_EMP_ATTRIBUTE8 => r_EMP.INFORMATION118
11239 ,P_EMP_ATTRIBUTE9 => r_EMP.INFORMATION119
11240 ,P_EMP_ATTRIBUTE_CATEGORY => r_EMP.INFORMATION110
11241 ,P_EXCLD_FLAG => r_EMP.INFORMATION12
11242 ,P_MARITAL_STATUS => r_EMP.INFORMATION11
11243 --
11244 -- ****** END CHANGE LINES
11245
11246 --
11247
11248 ,P_EFFECTIVE_START_DATE => l_effective_start_date
11249 ,P_EFFECTIVE_END_DATE => l_effective_end_date
11250 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11251 ,P_CRITERIA_SCORE => r_emp.INFORMATION295
11252 ,P_CRITERIA_WEIGHT => r_emp.INFORMATION296
11253 );
11254 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11255 -- Update all relevent cer records with new pk_id
11256 hr_utility.set_location('Before plsql table ',222);
11257 hr_utility.set_location('new_value id '||l_elig_mrtl_sts_prte_id,222);
11258 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_MRTL_STS_PRTE_ID' ;
11259 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EMP.information1 ;
11260 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_MRTL_STS_PRTE_ID ;
11261 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
11262 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EMP_unique.table_route_id;
11263 hr_utility.set_location('After plsql table ',222);
11264 --
11265 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
11266 --
11267 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
11268 --
11269 else
11270 --
11271 -- Call Update routine for the pk_id created in prev run .
11272 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11273 hr_utility.set_location(' BEN_ELIG_MRTL_STS_PRTE_F UPDATE_ELIG_MRTL_STS_PRTE ',30);
11274 --UPD START
11275 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
11276 --
11277 if l_update then
11278 --
11279 l_datetrack_mode := r_EMP.datetrack_mode ;
11280 --
11281 get_dt_modes(
11282 p_effective_date => l_process_date,
11283 p_effective_end_date => r_EMP.information3,
11284 p_effective_start_date => r_EMP.information2,
11285 p_dml_operation => r_EMP.dml_operation,
11286 p_datetrack_mode => l_datetrack_mode );
11287 -- p_update => l_update
11288 --
11289 l_effective_date := l_process_date;
11290 l_ELIG_MRTL_STS_PRTE_ID := r_EMP.information1;
11291 l_object_version_number := r_EMP.information265;
11292 --
11293 end if;
11294 --
11295 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
11296 --
11297 IF l_update OR l_dml_operation <> 'UPDATE' THEN
11298 --UPD END
11299
11300
11301 BEN_ELIG_MRTL_STS_PRTE_API.UPDATE_ELIG_MRTL_STS_PRTE(
11302 --
11303 P_VALIDATE => false
11304 ,P_EFFECTIVE_DATE => l_effective_date
11305 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11306 --
11307 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
11308 ,P_ELIG_MRTL_STS_PRTE_ID => l_elig_mrtl_sts_prte_id
11309 ,P_EMP_ATTRIBUTE1 => r_EMP.INFORMATION111
11310 ,P_EMP_ATTRIBUTE10 => r_EMP.INFORMATION120
11311 ,P_EMP_ATTRIBUTE11 => r_EMP.INFORMATION121
11312 ,P_EMP_ATTRIBUTE12 => r_EMP.INFORMATION122
11313 ,P_EMP_ATTRIBUTE13 => r_EMP.INFORMATION123
11314 ,P_EMP_ATTRIBUTE14 => r_EMP.INFORMATION124
11315 ,P_EMP_ATTRIBUTE15 => r_EMP.INFORMATION125
11316 ,P_EMP_ATTRIBUTE16 => r_EMP.INFORMATION126
11317 ,P_EMP_ATTRIBUTE17 => r_EMP.INFORMATION127
11318 ,P_EMP_ATTRIBUTE18 => r_EMP.INFORMATION128
11319 ,P_EMP_ATTRIBUTE19 => r_EMP.INFORMATION129
11320 ,P_EMP_ATTRIBUTE2 => r_EMP.INFORMATION112
11321 ,P_EMP_ATTRIBUTE20 => r_EMP.INFORMATION130
11322 ,P_EMP_ATTRIBUTE21 => r_EMP.INFORMATION131
11323 ,P_EMP_ATTRIBUTE22 => r_EMP.INFORMATION132
11324 ,P_EMP_ATTRIBUTE23 => r_EMP.INFORMATION133
11325 ,P_EMP_ATTRIBUTE24 => r_EMP.INFORMATION134
11326 ,P_EMP_ATTRIBUTE25 => r_EMP.INFORMATION135
11327 ,P_EMP_ATTRIBUTE26 => r_EMP.INFORMATION136
11328 ,P_EMP_ATTRIBUTE27 => r_EMP.INFORMATION137
11329 ,P_EMP_ATTRIBUTE28 => r_EMP.INFORMATION138
11330 ,P_EMP_ATTRIBUTE29 => r_EMP.INFORMATION139
11331 ,P_EMP_ATTRIBUTE3 => r_EMP.INFORMATION113
11332 ,P_EMP_ATTRIBUTE30 => r_EMP.INFORMATION140
11333 ,P_EMP_ATTRIBUTE4 => r_EMP.INFORMATION114
11334 ,P_EMP_ATTRIBUTE5 => r_EMP.INFORMATION115
11335 ,P_EMP_ATTRIBUTE6 => r_EMP.INFORMATION116
11336 ,P_EMP_ATTRIBUTE7 => r_EMP.INFORMATION117
11337 ,P_EMP_ATTRIBUTE8 => r_EMP.INFORMATION118
11338 ,P_EMP_ATTRIBUTE9 => r_EMP.INFORMATION119
11339 ,P_EMP_ATTRIBUTE_CATEGORY => r_EMP.INFORMATION110
11340
11341 ,P_EXCLD_FLAG => r_EMP.INFORMATION12
11342 ,P_MARITAL_STATUS => r_EMP.INFORMATION11
11343 --
11344 -- ****** END CHANGE LINES
11345
11346 --
11347 ,P_EFFECTIVE_START_DATE => l_effective_start_date
11348 ,P_EFFECTIVE_END_DATE => l_effective_end_date
11349 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11350 ,P_DATETRACK_MODE => l_datetrack_mode
11351 ,P_CRITERIA_SCORE => r_emp.INFORMATION295
11352 ,P_CRITERIA_WEIGHT => r_emp.INFORMATION296
11353 );
11354 end if; -- l_update
11355 --
11356 end if;
11357 --
11358 -- Delete the row if it is end dated.
11359 --
11360 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
11361 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
11362 trunc(l_max_eed) = trunc(r_EMP.information3)) then
11363 --
11364 BEN_ELIG_MRTL_STS_PRTE_API.delete_ELIG_MRTL_STS_PRTE(
11365 --
11366 p_validate => false
11367 ,p_elig_mrtl_sts_prte_id => l_elig_mrtl_sts_prte_id
11368 ,p_effective_start_date => l_effective_start_date
11369 ,p_effective_end_date => l_effective_end_date
11370 ,p_object_version_number => l_object_version_number
11371 ,p_effective_date => l_max_eed
11372 ,p_datetrack_mode => hr_api.g_delete
11373 --
11374 );
11375 --
11376 end if;
11377 --
11378 l_prev_pk_id := l_current_pk_id ;
11379 --
11380 end if;
11381 --
11382 end if;
11383 --
11384 end loop;
11385 --
11386 exception when others then
11387 --
11388 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EMP',r_EMP.information5 ) ;
11389 --
11390 end create_EMP_rows;
11391
11392
11393
11394 --
11395 ---------------------------------------------------------------
11396 ----------------------< create_ENO_rows >-----------------------
11397 ---------------------------------------------------------------
11398 --
11399 procedure create_ENO_rows
11400 (
11401 p_validate in number default 0
11402 ,p_copy_entity_txn_id in number
11403 ,p_effective_date in date
11404 ,p_prefix_suffix_text in varchar2 default null
11405 ,p_reuse_object_flag in varchar2 default null
11406 ,p_target_business_group_id in varchar2 default null
11407 ,p_prefix_suffix_cd in varchar2 default null
11408 ) is
11409 --
11410 l_ELIGY_PRFL_ID number;
11411 l_COORD_BEN_NO_CVG_FLAG varchar2(30);
11412
11413 cursor c_unique_ENO(l_table_alias varchar2) is
11414 select distinct cpe.information1,
11415 cpe.information2,
11416 cpe.information3,
11417 cpe.table_route_id
11418 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
11419 pqh_table_route tr
11420 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11421 and cpe.table_route_id = tr.table_route_id
11422 -- and tr.where_clause = l_BEN_ELIG_NO_OTHR_CVG_PRTE_F
11423 and tr.table_alias = l_table_alias
11424 and cpe.number_of_copies = 1 -- ADDITION
11425 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
11426 order by information1, information2; --added for bug: 5151945
11427 --
11428 --
11429 cursor c_ENO_min_max_dates(c_table_route_id number,
11430 c_information1 number) is
11431 select
11432 min(cpe.information2) min_esd,
11433 max(cpe.information3) min_eed
11434 from ben_copy_entity_results cpe
11435 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11436 and cpe.table_route_id = c_table_route_id
11437 and cpe.information1 = c_information1 ;
11438 --
11439 cursor c_ENO(c_table_route_id number,
11440 c_information1 number,
11441 c_information2 date,
11442 c_information3 date ) is
11443 select
11444 cpe.*
11445 from ben_copy_entity_results cpe
11446 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11447 and cpe.table_route_id = c_table_route_id
11448 and cpe.information1 = c_information1
11449 and cpe.information2 = c_information2
11450 and cpe.information3 = c_information3
11451 and rownum = 1 ;
11452 -- Date Track target record
11453 cursor c_find_ENO_in_target(
11454 c_effective_start_date date,
11455 c_effective_end_date date,
11456 c_business_group_id number,
11457 c_new_pk_id number) is
11458 select
11459 ENO.elig_no_othr_cvg_prte_id new_value
11460 from BEN_ELIG_NO_OTHR_CVG_PRTE_F ENO
11461 where
11462 ENO.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
11463 ENO.COORD_BEN_NO_CVG_FLAG = l_COORD_BEN_NO_CVG_FLAG and
11464 ENO.business_group_id = c_business_group_id
11465 and ENO.elig_no_othr_cvg_prte_id <> c_new_pk_id
11466 and c_effective_start_date between effective_start_date
11467 and effective_end_date ;
11468 --END TEMPIK
11469 /*TEMPIK
11470 and exists ( select null
11471 from BEN_ELIG_NO_OTHR_CVG_PRTE_F ENO1
11472 where
11473 ENO1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
11474 ENO1.COORD_BEN_NO_CVG_FLAG = l_COORD_BEN_NO_CVG_FLAG and
11475 ENO1.business_group_id = c_business_group_id
11476 and ENO1.effective_start_date <= c_effective_start_date )
11477 and exists ( select null
11478 from BEN_ELIG_NO_OTHR_CVG_PRTE_F ENO2
11479 where
11480 ENO2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
11481 ENO2.COORD_BEN_NO_CVG_FLAG = l_COORD_BEN_NO_CVG_FLAG and
11482 ENO2.business_group_id = c_business_group_id
11483 and ENO2.effective_end_date >= c_effective_end_date )
11484 ;
11485 TEMPIK */
11486 --TEMPIK
11487 l_dt_rec_found boolean ;
11488 --END TEMPIK
11489 --
11490
11491 --UPD START
11492 --
11493 l_update boolean := false ;
11494 l_datetrack_mode varchar2(80) := hr_api.g_update;
11495 l_process_date date;
11496 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
11497 --
11498 --UPD END
11499 l_current_pk_id number := null ;
11500
11501 l_prev_pk_id number := null ;
11502 l_first_rec boolean := true ;
11503 r_ENO c_ENO%rowtype;
11504 l_elig_no_othr_cvg_prte_id number ;
11505 l_object_version_number number ;
11506 l_effective_start_date date ;
11507 l_effective_end_date date ;
11508 l_prefix pqh_copy_entity_attribs.information1%type := null;
11509 l_suffix pqh_copy_entity_attribs.information1%type := null;
11510 l_new_value number(15);
11511 l_object_found_in_target boolean := false ;
11512 l_min_esd date;
11513 l_max_eed date;
11514 l_effective_date date;
11515 --
11516 begin
11517 -- Initialization
11518 l_object_found_in_target := false ;
11519 -- End Initialization
11520 -- Derive the prefix - sufix
11521 if p_prefix_suffix_cd = 'PREFIX' then
11522 l_prefix := p_prefix_suffix_text ;
11523 elsif p_prefix_suffix_cd = 'SUFFIX' then
11524 l_suffix := p_prefix_suffix_text ;
11525 else
11526 l_prefix := null ;
11527 l_suffix := null ;
11528 end if ;
11529 -- End Prefix Sufix derivation
11530 for r_ENO_unique in c_unique_ENO('ENO') loop
11531
11532 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
11533 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11534 r_ENO_unique.information3 >=
11535 ben_pd_copy_to_ben_one.g_copy_effective_date)
11536 ) then
11537 --
11538 hr_utility.set_location(' r_ENO_unique.table_route_id '||r_ENO_unique.table_route_id,10);
11539 hr_utility.set_location(' r_ENO_unique.information1 '||r_ENO_unique.information1,10);
11540 hr_utility.set_location( 'r_ENO_unique.information2 '||r_ENO_unique.information2,10);
11541 hr_utility.set_location( 'r_ENO_unique.information3 '||r_ENO_unique.information3,10);
11542 -- If reuse objects flag is 'Y' then check for the object in the target business group
11543 -- if found insert the record into PLSql table and exit the loop else try create the
11544 -- object in the target business group
11545 --
11546 l_object_found_in_target := false ;
11547 --UPD START
11548 l_update := false;
11549 l_process_date := p_effective_date;
11550 l_dml_operation:= r_ENO_unique.dml_operation ;
11551 --
11552
11553 /**********************moved from below **********************/
11554 open c_ENO(r_ENO_unique.table_route_id,
11555 r_ENO_unique.information1,
11556 r_ENO_unique.information2,
11557 r_ENO_unique.information3 ) ;
11558 --
11559 fetch c_ENO into r_ENO ;
11560 --
11561 close c_ENO ;
11562 --
11563 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ENO.INFORMATION263,l_dml_operation);--changed from information13
11564 l_COORD_BEN_NO_CVG_FLAG := r_ENO.information11 ;
11565
11566 /**********************************************************/
11567 if l_dml_operation = 'UPDATE' then
11568 --
11569 l_object_found_in_target := TRUE;
11570 --
11571 if l_process_date between r_ENO_unique.information2 and r_ENO_unique.information3 then
11572 l_update := true;
11573 if r_ENO_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
11574 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_NO_OTHR_CVG_PRTE_ID' then
11575 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_NO_OTHR_CVG_PRTE_ID' ;
11576 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ENO_unique.information1 ;
11577 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ENO_unique.information1 ;
11578 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
11579 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ENO_unique.table_route_id;
11580 --
11581 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
11582 --
11583 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
11584 --
11585 -- log_data('ENO',l_new_value,l_prefix || r_ENO_unique.name|| l_suffix,'REUSED');
11586 --
11587 end if ;
11588 hr_utility.set_location( 'found record for update',10);
11589 --
11590 else
11591 --
11592 l_update := false;
11593 --
11594 end if;
11595 else
11596 --
11597 --UPD END
11598 l_min_esd := null ;
11599 l_max_eed := null ;
11600 open c_ENO_min_max_dates(r_ENO_unique.table_route_id, r_ENO_unique.information1 ) ;
11601 fetch c_ENO_min_max_dates into l_min_esd,l_max_eed ;
11602 --
11603
11604 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11605 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
11606 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
11607 end if;
11608 l_min_esd := greatest(l_min_esd,r_ENO_unique.information2);
11609 /**********************moved up from here **********************
11610 open c_ENO(r_ENO_unique.table_route_id,
11611 r_ENO_unique.information1,
11612 r_ENO_unique.information2,
11613 r_ENO_unique.information3 ) ;
11614 --
11615 fetch c_ENO into r_ENO ;
11616 --
11617 close c_ENO ;
11618 --
11619 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ENO.INFORMATION263,l_dml_operation);--changed from information13
11620 l_COORD_BEN_NO_CVG_FLAG := r_ENO.information11 ;
11621
11622 **********************************************************/
11623
11624 if p_reuse_object_flag = 'Y' then
11625 if c_ENO_min_max_dates%found then
11626 -- cursor to find the object
11627 open c_find_ENO_in_target( l_min_esd,l_max_eed,
11628 p_target_business_group_id, nvl(l_elig_no_othr_cvg_prte_id, -999) ) ;
11629 fetch c_find_ENO_in_target into l_new_value ;
11630 if c_find_ENO_in_target%found then
11631 --
11632 --TEMPIK
11633 l_dt_rec_found := dt_api.check_min_max_dates
11634 (p_base_table_name => 'BEN_ELIG_NO_OTHR_CVG_PRTE_F',
11635 p_base_key_column => 'ELIG_NO_OTHR_CVG_PRTE_ID',
11636 p_base_key_value => l_new_value,
11637 p_from_date => l_min_esd,
11638 p_to_date => l_max_eed );
11639 if l_dt_rec_found THEN
11640 --END TEMPIK
11641 if r_ENO_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
11642 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_NO_OTHR_CVG_PRTE_ID' then
11643 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_NO_OTHR_CVG_PRTE_ID' ;
11644 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ENO_unique.information1 ;
11645 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
11646 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
11647 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ENO_unique.table_route_id;
11648 --
11649 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
11650 --
11651 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
11652 end if ;
11653 --
11654 l_object_found_in_target := true ;
11655 --TEMPIK
11656 end if; -- l_dt_rec_found
11657 --END TEMPIK
11658 end if;
11659 close c_find_ENO_in_target ;
11660 --
11661 end if;
11662 end if ;
11663 --
11664 close c_ENO_min_max_dates ;
11665 end if; --if p_dml_operation
11666 --
11667 if not l_object_found_in_target OR l_update then
11668
11669 --
11670 l_current_pk_id := r_ENO.information1;
11671 --
11672 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
11673 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
11674 --
11675 if l_current_pk_id = l_prev_pk_id then
11676 --
11677 l_first_rec := false ;
11678 --
11679 else
11680 --
11681 l_first_rec := true ;
11682 --
11683 end if ;
11684 --
11685
11686 l_effective_date := r_ENO.information2;
11687 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11688 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
11689 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
11690 end if;
11691
11692 if l_first_rec and not l_update then
11693 -- Call Create routine.
11694 hr_utility.set_location(' BEN_ELIG_NO_OTHR_CVG_PRTE_F CREATE_ELIG_NO_OTHR_CVG_PRTE ',20);
11695 BEN_ELIG_NO_OTHR_CVG_PRTE_API.CREATE_ELIG_NO_OTHR_CVG_PRTE(
11696 --
11697 P_VALIDATE => false
11698 ,P_EFFECTIVE_DATE => l_effective_date
11699 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11700 --
11701 ,P_COORD_BEN_NO_CVG_FLAG => r_ENO.INFORMATION11
11702 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
11703 ,P_ELIG_NO_OTHR_CVG_PRTE_ID => l_elig_no_othr_cvg_prte_id
11704 ,P_ENO_ATTRIBUTE1 => r_ENO.INFORMATION111
11705 ,P_ENO_ATTRIBUTE10 => r_ENO.INFORMATION120
11706 ,P_ENO_ATTRIBUTE11 => r_ENO.INFORMATION121
11707 ,P_ENO_ATTRIBUTE12 => r_ENO.INFORMATION122
11708 ,P_ENO_ATTRIBUTE13 => r_ENO.INFORMATION123
11709 ,P_ENO_ATTRIBUTE14 => r_ENO.INFORMATION124
11710 ,P_ENO_ATTRIBUTE15 => r_ENO.INFORMATION125
11711 ,P_ENO_ATTRIBUTE16 => r_ENO.INFORMATION126
11712 ,P_ENO_ATTRIBUTE17 => r_ENO.INFORMATION127
11713 ,P_ENO_ATTRIBUTE18 => r_ENO.INFORMATION128
11714 ,P_ENO_ATTRIBUTE19 => r_ENO.INFORMATION129
11715 ,P_ENO_ATTRIBUTE2 => r_ENO.INFORMATION112
11716 ,P_ENO_ATTRIBUTE20 => r_ENO.INFORMATION130
11717 ,P_ENO_ATTRIBUTE21 => r_ENO.INFORMATION131
11718 ,P_ENO_ATTRIBUTE22 => r_ENO.INFORMATION132
11719 ,P_ENO_ATTRIBUTE23 => r_ENO.INFORMATION133
11720 ,P_ENO_ATTRIBUTE24 => r_ENO.INFORMATION134
11721 ,P_ENO_ATTRIBUTE25 => r_ENO.INFORMATION135
11722 ,P_ENO_ATTRIBUTE26 => r_ENO.INFORMATION136
11723 ,P_ENO_ATTRIBUTE27 => r_ENO.INFORMATION137
11724 ,P_ENO_ATTRIBUTE28 => r_ENO.INFORMATION138
11725 ,P_ENO_ATTRIBUTE29 => r_ENO.INFORMATION139
11726 ,P_ENO_ATTRIBUTE3 => r_ENO.INFORMATION113
11727 ,P_ENO_ATTRIBUTE30 => r_ENO.INFORMATION140
11728 ,P_ENO_ATTRIBUTE4 => r_ENO.INFORMATION114
11729 ,P_ENO_ATTRIBUTE5 => r_ENO.INFORMATION115
11730 ,P_ENO_ATTRIBUTE6 => r_ENO.INFORMATION116
11731 ,P_ENO_ATTRIBUTE7 => r_ENO.INFORMATION117
11732 ,P_ENO_ATTRIBUTE8 => r_ENO.INFORMATION118
11733 ,P_ENO_ATTRIBUTE9 => r_ENO.INFORMATION119
11734 ,P_ENO_ATTRIBUTE_CATEGORY => r_ENO.INFORMATION110
11735 --
11736 -- ****** END CHANGE LINES
11737
11738 --
11739
11740 ,P_EFFECTIVE_START_DATE => l_effective_start_date
11741 ,P_EFFECTIVE_END_DATE => l_effective_end_date
11742 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11743 );
11744 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11745 -- Update all relevent cer records with new pk_id
11746 hr_utility.set_location('Before plsql table ',222);
11747 hr_utility.set_location('new_value id '||l_elig_no_othr_cvg_prte_id,222);
11748 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_NO_OTHR_CVG_PRTE_ID' ;
11749 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ENO.information1 ;
11750 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_NO_OTHR_CVG_PRTE_ID ;
11751 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
11752 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ENO_unique.table_route_id;
11753 hr_utility.set_location('After plsql table ',222);
11754 --
11755 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
11756 --
11757 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
11758 --
11759 else
11760 --
11761 -- Call Update routine for the pk_id created in prev run .
11762 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11763 hr_utility.set_location(' BEN_ELIG_NO_OTHR_CVG_PRTE_F UPDATE_ELIG_NO_OTHR_CVG_PRTE ',30);
11764 --UPD START
11765 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
11766 --
11767 if l_update then
11768 --
11769 l_datetrack_mode := r_ENO.datetrack_mode ;
11770 --
11771 get_dt_modes(
11772 p_effective_date => l_process_date,
11773 p_effective_end_date => r_ENO.information3,
11774 p_effective_start_date => r_ENO.information2,
11775 p_dml_operation => r_ENO.dml_operation,
11776 p_datetrack_mode => l_datetrack_mode );
11777 -- p_update => l_update
11778 --
11779 l_effective_date := l_process_date;
11780 l_ELIG_NO_OTHR_CVG_PRTE_ID := r_ENO.information1;
11781 l_object_version_number := r_ENO.information265;
11782 --
11783 end if;
11784 --
11785 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
11786 --
11787 IF l_update OR l_dml_operation <> 'UPDATE' THEN
11788 --UPD END
11789
11790
11791 BEN_ELIG_NO_OTHR_CVG_PRTE_API.UPDATE_ELIG_NO_OTHR_CVG_PRTE(
11792 --
11793 P_VALIDATE => false
11794 ,P_EFFECTIVE_DATE => l_effective_date
11795 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11796 --
11797 ,P_COORD_BEN_NO_CVG_FLAG => r_ENO.INFORMATION11
11798 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
11799 ,P_ELIG_NO_OTHR_CVG_PRTE_ID => l_elig_no_othr_cvg_prte_id
11800 ,P_ENO_ATTRIBUTE1 => r_ENO.INFORMATION111
11801 ,P_ENO_ATTRIBUTE10 => r_ENO.INFORMATION120
11802 ,P_ENO_ATTRIBUTE11 => r_ENO.INFORMATION121
11803 ,P_ENO_ATTRIBUTE12 => r_ENO.INFORMATION122
11804 ,P_ENO_ATTRIBUTE13 => r_ENO.INFORMATION123
11805 ,P_ENO_ATTRIBUTE14 => r_ENO.INFORMATION124
11806 ,P_ENO_ATTRIBUTE15 => r_ENO.INFORMATION125
11807 ,P_ENO_ATTRIBUTE16 => r_ENO.INFORMATION126
11808 ,P_ENO_ATTRIBUTE17 => r_ENO.INFORMATION127
11809 ,P_ENO_ATTRIBUTE18 => r_ENO.INFORMATION128
11810 ,P_ENO_ATTRIBUTE19 => r_ENO.INFORMATION129
11811 ,P_ENO_ATTRIBUTE2 => r_ENO.INFORMATION112
11812 ,P_ENO_ATTRIBUTE20 => r_ENO.INFORMATION130
11813 ,P_ENO_ATTRIBUTE21 => r_ENO.INFORMATION131
11814 ,P_ENO_ATTRIBUTE22 => r_ENO.INFORMATION132
11815 ,P_ENO_ATTRIBUTE23 => r_ENO.INFORMATION133
11816 ,P_ENO_ATTRIBUTE24 => r_ENO.INFORMATION134
11817 ,P_ENO_ATTRIBUTE25 => r_ENO.INFORMATION135
11818 ,P_ENO_ATTRIBUTE26 => r_ENO.INFORMATION136
11819 ,P_ENO_ATTRIBUTE27 => r_ENO.INFORMATION137
11820 ,P_ENO_ATTRIBUTE28 => r_ENO.INFORMATION138
11821 ,P_ENO_ATTRIBUTE29 => r_ENO.INFORMATION139
11822 ,P_ENO_ATTRIBUTE3 => r_ENO.INFORMATION113
11823 ,P_ENO_ATTRIBUTE30 => r_ENO.INFORMATION140
11824 ,P_ENO_ATTRIBUTE4 => r_ENO.INFORMATION114
11825 ,P_ENO_ATTRIBUTE5 => r_ENO.INFORMATION115
11826 ,P_ENO_ATTRIBUTE6 => r_ENO.INFORMATION116
11827 ,P_ENO_ATTRIBUTE7 => r_ENO.INFORMATION117
11828 ,P_ENO_ATTRIBUTE8 => r_ENO.INFORMATION118
11829 ,P_ENO_ATTRIBUTE9 => r_ENO.INFORMATION119
11830 ,P_ENO_ATTRIBUTE_CATEGORY => r_ENO.INFORMATION110
11831 --
11832 -- ****** END CHANGE LINES
11833
11834 --
11835 ,P_EFFECTIVE_START_DATE => l_effective_start_date
11836 ,P_EFFECTIVE_END_DATE => l_effective_end_date
11837 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11838 ,P_DATETRACK_MODE => l_datetrack_mode
11839 );
11840 end if; -- l_update
11841 --
11842 end if;
11843 --
11844 -- Delete the row if it is end dated.
11845 --
11846 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
11847 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
11848 trunc(l_max_eed) = trunc(r_ENO.information3)) then
11849 --
11850 BEN_ELIG_NO_OTHR_CVG_PRTE_API.delete_ELIG_NO_OTHR_CVG_PRTE(
11851 --
11852 p_validate => false
11853 ,p_elig_no_othr_cvg_prte_id => l_elig_no_othr_cvg_prte_id
11854 ,p_effective_start_date => l_effective_start_date
11855 ,p_effective_end_date => l_effective_end_date
11856 ,p_object_version_number => l_object_version_number
11857 ,p_effective_date => l_max_eed
11858 ,p_datetrack_mode => hr_api.g_delete
11859 --
11860 );
11861 --
11862 end if;
11863 --
11864 l_prev_pk_id := l_current_pk_id ;
11865 --
11866 end if;
11867 --
11868 end if;
11869 --
11870 end loop;
11871 --
11872 exception when others then
11873 --
11874 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ENO',r_ENO.information5 ) ;
11875 --
11876 end create_ENO_rows;
11877
11878
11879 --
11880 ---------------------------------------------------------------
11881 ----------------------< create_EOM_rows >-----------------------
11882 ---------------------------------------------------------------
11883 --
11884 procedure create_EOM_rows
11885 (
11886 p_validate in number default 0
11887 ,p_copy_entity_txn_id in number
11888 ,p_effective_date in date
11889 ,p_prefix_suffix_text in varchar2 default null
11890 ,p_reuse_object_flag in varchar2 default null
11891 ,p_target_business_group_id in varchar2 default null
11892 ,p_prefix_suffix_cd in varchar2 default null
11893 ) is
11894 --
11895 l_ELIGY_PRFL_ID number;
11896 l_OPTD_MDCR_FLAG varchar2(30);
11897 --
11898 cursor c_unique_EOM(l_table_alias varchar2) is
11899 select distinct cpe.information1,
11900 cpe.information2,
11901 cpe.information3,
11902 cpe.table_route_id
11903 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
11904 pqh_table_route tr
11905 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11906 and cpe.table_route_id = tr.table_route_id
11907 -- and tr.where_clause = l_BEN_ELIG_OPTD_MDCR_PRTE_F
11908 and tr.table_alias = l_table_alias
11909 and cpe.number_of_copies = 1 -- ADDITION
11910 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
11911 order by information1, information2; --added for bug: 5151945
11912 --
11913 --
11914 cursor c_EOM_min_max_dates(c_table_route_id number,
11915 c_information1 number) is
11916 select
11917 min(cpe.information2) min_esd,
11918 max(cpe.information3) min_eed
11919 from ben_copy_entity_results cpe
11920 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11921 and cpe.table_route_id = c_table_route_id
11922 and cpe.information1 = c_information1 ;
11923 --
11924 cursor c_EOM(c_table_route_id number,
11925 c_information1 number,
11926 c_information2 date,
11927 c_information3 date ) is
11928 select
11929 cpe.*
11930 from ben_copy_entity_results cpe
11931 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11932 and cpe.table_route_id = c_table_route_id
11933 and cpe.information1 = c_information1
11934 and cpe.information2 = c_information2
11935 and cpe.information3 = c_information3
11936 and rownum = 1 ;
11937 -- Date Track target record
11938 cursor c_find_EOM_in_target(
11939 c_effective_start_date date,
11940 c_effective_end_date date,
11941 c_business_group_id number,
11942 c_new_pk_id number) is
11943 select
11944 EOM.elig_optd_mdcr_prte_id new_value
11945 from BEN_ELIG_OPTD_MDCR_PRTE_F EOM
11946 where
11947 EOM.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
11948 EOM.OPTD_MDCR_FLAG = l_OPTD_MDCR_FLAG and
11949 EOM.business_group_id = c_business_group_id
11950 and EOM.elig_optd_mdcr_prte_id <> c_new_pk_id
11951 and c_effective_start_date between effective_start_date
11952 and effective_end_date ;
11953 --END TEMPIK
11954 /*TEMPIK
11955 and exists ( select null
11956 from BEN_ELIG_OPTD_MDCR_PRTE_F EOM1
11957 where
11958 EOM1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
11959 EOM1.OPTD_MDCR_FLAG = l_OPTD_MDCR_FLAG and
11960 EOM1.business_group_id = c_business_group_id
11961 and EOM1.effective_start_date <= c_effective_start_date )
11962 and exists ( select null
11963 from BEN_ELIG_OPTD_MDCR_PRTE_F EOM2
11964 where
11965 EOM2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
11966 EOM2.OPTD_MDCR_FLAG = l_OPTD_MDCR_FLAG and
11967 EOM2.business_group_id = c_business_group_id
11968 and EOM2.effective_end_date >= c_effective_end_date )
11969 ;
11970 TEMPIK */
11971 --TEMPIK
11972 l_dt_rec_found boolean ;
11973 --END TEMPIK
11974 --
11975
11976 --UPD START
11977 --
11978 l_update boolean := false ;
11979 l_datetrack_mode varchar2(80) := hr_api.g_update;
11980 l_process_date date;
11981 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
11982 --
11983 --UPD END
11984 l_current_pk_id number := null ;
11985
11986 l_prev_pk_id number := null ;
11987 l_first_rec boolean := true ;
11988 r_EOM c_EOM%rowtype;
11989 l_elig_optd_mdcr_prte_id number ;
11990 l_object_version_number number ;
11991 l_effective_start_date date ;
11992 l_effective_end_date date ;
11993 l_prefix pqh_copy_entity_attribs.information1%type := null;
11994 l_suffix pqh_copy_entity_attribs.information1%type := null;
11995 l_new_value number(15);
11996 l_object_found_in_target boolean := false ;
11997 l_min_esd date;
11998 l_max_eed date;
11999 l_effective_date date;
12000 --
12001 begin
12002 -- Initialization
12003 l_object_found_in_target := false ;
12004 -- End Initialization
12005 -- Derive the prefix - sufix
12006 if p_prefix_suffix_cd = 'PREFIX' then
12007 l_prefix := p_prefix_suffix_text ;
12008 elsif p_prefix_suffix_cd = 'SUFFIX' then
12009 l_suffix := p_prefix_suffix_text ;
12010 else
12011 l_prefix := null ;
12012 l_suffix := null ;
12013 end if ;
12014 -- End Prefix Sufix derivation
12015 for r_EOM_unique in c_unique_EOM('EOM') loop
12016
12017 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
12018 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12019 r_EOM_unique.information3 >=
12020 ben_pd_copy_to_ben_one.g_copy_effective_date)
12021 ) then
12022 --
12023 hr_utility.set_location(' r_EOM_unique.table_route_id '||r_EOM_unique.table_route_id,10);
12024 hr_utility.set_location(' r_EOM_unique.information1 '||r_EOM_unique.information1,10);
12025 hr_utility.set_location( 'r_EOM_unique.information2 '||r_EOM_unique.information2,10);
12026 hr_utility.set_location( 'r_EOM_unique.information3 '||r_EOM_unique.information3,10);
12027 -- If reuse objects flag is 'Y' then check for the object in the target business group
12028 -- if found insert the record into PLSql table and exit the loop else try create the
12029 -- object in the target business group
12030 --
12031 l_object_found_in_target := false ;
12032 --UPD START
12033 l_update := false;
12034 l_process_date := p_effective_date;
12035 l_dml_operation:= r_EOM_unique.dml_operation ;
12036 --
12037 /**********************moved from below **********************/
12038 open c_EOM(r_EOM_unique.table_route_id,
12039 r_EOM_unique.information1,
12040 r_EOM_unique.information2,
12041 r_EOM_unique.information3 ) ;
12042 --
12043 fetch c_EOM into r_EOM ;
12044 --
12045 close c_EOM ;
12046 --
12047 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EOM.INFORMATION263,l_dml_operation);
12048 l_OPTD_MDCR_FLAG := r_EOM.INFORMATION11 ;
12049
12050 /**********************************************************/
12051
12052 if l_dml_operation = 'UPDATE' then
12053 --
12054 l_object_found_in_target := TRUE;
12055 --
12056 if l_process_date between r_EOM_unique.information2 and r_EOM_unique.information3 then
12057 l_update := true;
12058 if r_EOM_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
12059 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_OPTD_MDCR_PRTE_ID' then
12060 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_OPTD_MDCR_PRTE_ID' ;
12061 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EOM_unique.information1 ;
12062 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EOM_unique.information1 ;
12063 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
12064 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EOM_unique.table_route_id;
12065 --
12066 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
12067 --
12068 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
12069 --
12070 -- log_data('EOM',l_new_value,l_prefix || r_EOM_unique.name|| l_suffix,'REUSED');
12071 --
12072 end if ;
12073 hr_utility.set_location( 'found record for update',10);
12074 --
12075 else
12076 --
12077 l_update := false;
12078 --
12079 end if;
12080 else
12081 --
12082 --UPD END
12083 l_min_esd := null ;
12084 l_max_eed := null ;
12085 open c_EOM_min_max_dates(r_EOM_unique.table_route_id, r_EOM_unique.information1 ) ;
12086 fetch c_EOM_min_max_dates into l_min_esd,l_max_eed ;
12087 --
12088
12089 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12090 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
12091 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
12092 end if;
12093
12094 l_min_esd := greatest(l_min_esd,r_EOM_unique.information2);
12095 /**********************moved up from here **********************
12096 open c_EOM(r_EOM_unique.table_route_id,
12097 r_EOM_unique.information1,
12098 r_EOM_unique.information2,
12099 r_EOM_unique.information3 ) ;
12100 --
12101 fetch c_EOM into r_EOM ;
12102 --
12103 close c_EOM ;
12104 --
12105 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EOM.INFORMATION263,l_dml_operation);
12106 l_OPTD_MDCR_FLAG := r_EOM.INFORMATION11 ;
12107
12108 **********************************************************/
12109
12110 if p_reuse_object_flag = 'Y' then
12111 if c_EOM_min_max_dates%found then
12112 -- cursor to find the object
12113 open c_find_EOM_in_target( l_min_esd,l_max_eed,
12114 p_target_business_group_id, nvl(l_elig_optd_mdcr_prte_id, -999) ) ;
12115 fetch c_find_EOM_in_target into l_new_value ;
12116 if c_find_EOM_in_target%found then
12117 --
12118 --TEMPIK
12119 l_dt_rec_found := dt_api.check_min_max_dates
12120 (p_base_table_name => 'BEN_ELIG_OPTD_MDCR_PRTE_F',
12121 p_base_key_column => 'ELIG_OPTD_MDCR_PRTE_ID',
12122 p_base_key_value => l_new_value,
12123 p_from_date => l_min_esd,
12124 p_to_date => l_max_eed );
12125 if l_dt_rec_found THEN
12126 --END TEMPIK
12127 if r_EOM_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
12128 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_OPTD_MDCR_PRTE_ID' then
12129 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_OPTD_MDCR_PRTE_ID' ;
12130 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EOM_unique.information1 ;
12131 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
12132 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
12133 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EOM_unique.table_route_id;
12134 --
12135 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
12136 --
12137 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
12138 end if ;
12139 --
12140 l_object_found_in_target := true ;
12141 --TEMPIK
12142 end if; -- l_dt_rec_found
12143 --END TEMPIK
12144 end if;
12145 close c_find_EOM_in_target ;
12146 --
12147 end if;
12148 end if ;
12149 --
12150 close c_EOM_min_max_dates ;
12151 end if; --if p_dml_operation
12152 --
12153 if not l_object_found_in_target OR l_update then
12154
12155 --
12156 l_current_pk_id := r_EOM.information1;
12157 --
12158 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
12159 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
12160 --
12161 if l_current_pk_id = l_prev_pk_id then
12162 --
12163 l_first_rec := false ;
12164 --
12165 else
12166 --
12167 l_first_rec := true ;
12168 --
12169 end if ;
12170 --
12171
12172 l_effective_date := r_EOM.information2;
12173 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12174 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
12175 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
12176 end if;
12177
12178 if l_first_rec and not l_update then
12179 -- Call Create routine.
12180 hr_utility.set_location(' BEN_ELIG_OPTD_MDCR_PRTE_F CREATE_ELIG_OPTD_MDCR_PRTE ',20);
12181 BEN_ELIG_OPTD_MDCR_PRTE_API.CREATE_ELIG_OPTD_MDCR_PRTE(
12182 --
12183 P_VALIDATE => false
12184 ,P_EFFECTIVE_DATE => l_effective_date
12185 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
12186 --
12187 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
12188 ,P_ELIG_OPTD_MDCR_PRTE_ID => l_elig_optd_mdcr_prte_id
12189 ,P_EOM_ATTRIBUTE1 => r_EOM.INFORMATION111
12190 ,P_EOM_ATTRIBUTE10 => r_EOM.INFORMATION120
12191 ,P_EOM_ATTRIBUTE11 => r_EOM.INFORMATION121
12192 ,P_EOM_ATTRIBUTE12 => r_EOM.INFORMATION122
12193 ,P_EOM_ATTRIBUTE13 => r_EOM.INFORMATION123
12194 ,P_EOM_ATTRIBUTE14 => r_EOM.INFORMATION124
12195 ,P_EOM_ATTRIBUTE15 => r_EOM.INFORMATION125
12196 ,P_EOM_ATTRIBUTE16 => r_EOM.INFORMATION126
12197 ,P_EOM_ATTRIBUTE17 => r_EOM.INFORMATION127
12198 ,P_EOM_ATTRIBUTE18 => r_EOM.INFORMATION128
12199 ,P_EOM_ATTRIBUTE19 => r_EOM.INFORMATION129
12200 ,P_EOM_ATTRIBUTE2 => r_EOM.INFORMATION112
12201 ,P_EOM_ATTRIBUTE20 => r_EOM.INFORMATION130
12202 ,P_EOM_ATTRIBUTE21 => r_EOM.INFORMATION131
12203 ,P_EOM_ATTRIBUTE22 => r_EOM.INFORMATION132
12204 ,P_EOM_ATTRIBUTE23 => r_EOM.INFORMATION133
12205 ,P_EOM_ATTRIBUTE24 => r_EOM.INFORMATION134
12206 ,P_EOM_ATTRIBUTE25 => r_EOM.INFORMATION135
12207 ,P_EOM_ATTRIBUTE26 => r_EOM.INFORMATION136
12208 ,P_EOM_ATTRIBUTE27 => r_EOM.INFORMATION137
12209 ,P_EOM_ATTRIBUTE28 => r_EOM.INFORMATION138
12210 ,P_EOM_ATTRIBUTE29 => r_EOM.INFORMATION139
12211 ,P_EOM_ATTRIBUTE3 => r_EOM.INFORMATION113
12212 ,P_EOM_ATTRIBUTE30 => r_EOM.INFORMATION140
12213 ,P_EOM_ATTRIBUTE4 => r_EOM.INFORMATION114
12214 ,P_EOM_ATTRIBUTE5 => r_EOM.INFORMATION115
12215 ,P_EOM_ATTRIBUTE6 => r_EOM.INFORMATION116
12216 ,P_EOM_ATTRIBUTE7 => r_EOM.INFORMATION117
12217 ,P_EOM_ATTRIBUTE8 => r_EOM.INFORMATION118
12218 ,P_EOM_ATTRIBUTE9 => r_EOM.INFORMATION119
12219 ,P_EOM_ATTRIBUTE_CATEGORY => r_EOM.INFORMATION110
12220 ,P_EXLCD_FLAG => r_EOM.INFORMATION12
12221 ,P_OPTD_MDCR_FLAG => r_EOM.INFORMATION11
12222 --
12223 -- ****** END CHANGE LINES
12224
12225 --
12226
12227 ,P_EFFECTIVE_START_DATE => l_effective_start_date
12228 ,P_EFFECTIVE_END_DATE => l_effective_end_date
12229 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12230 );
12231 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
12232 -- Update all relevent cer records with new pk_id
12233 hr_utility.set_location('Before plsql table ',222);
12234 hr_utility.set_location('new_value id '||l_elig_optd_mdcr_prte_id,222);
12235 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_OPTD_MDCR_PRTE_ID' ;
12236 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EOM.information1 ;
12237 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_OPTD_MDCR_PRTE_ID ;
12238 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
12239 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EOM_unique.table_route_id;
12240 hr_utility.set_location('After plsql table ',222);
12241 --
12242 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
12243 --
12244 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
12245 --
12246 else
12247 --
12248 -- Call Update routine for the pk_id created in prev run .
12249 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
12250 hr_utility.set_location(' BEN_ELIG_OPTD_MDCR_PRTE_F UPDATE_ELIG_OPTD_MDCR_PRTE ',30);
12251 --UPD START
12252 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
12253 --
12254 if l_update then
12255 --
12256 l_datetrack_mode := r_EOM.datetrack_mode ;
12257 --
12258 get_dt_modes(
12259 p_effective_date => l_process_date,
12260 p_effective_end_date => r_EOM.information3,
12261 p_effective_start_date => r_EOM.information2,
12262 p_dml_operation => r_EOM.dml_operation,
12263 p_datetrack_mode => l_datetrack_mode );
12264 -- p_update => l_update
12265 --
12266 l_effective_date := l_process_date;
12267 l_ELIG_OPTD_MDCR_PRTE_ID := r_EOM.information1;
12268 l_object_version_number := r_EOM.information265;
12269 --
12270 end if;
12271 --
12272 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
12273 --
12274 IF l_update OR l_dml_operation <> 'UPDATE' THEN
12275 --UPD END
12276
12277
12278 BEN_ELIG_OPTD_MDCR_PRTE_API.UPDATE_ELIG_OPTD_MDCR_PRTE(
12279 --
12280 P_VALIDATE => false
12281 ,P_EFFECTIVE_DATE => l_effective_date
12282 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
12283 --
12284 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
12285 ,P_ELIG_OPTD_MDCR_PRTE_ID => l_elig_optd_mdcr_prte_id
12286 ,P_EOM_ATTRIBUTE1 => r_EOM.INFORMATION111
12287 ,P_EOM_ATTRIBUTE10 => r_EOM.INFORMATION120
12288 ,P_EOM_ATTRIBUTE11 => r_EOM.INFORMATION121
12289 ,P_EOM_ATTRIBUTE12 => r_EOM.INFORMATION122
12290 ,P_EOM_ATTRIBUTE13 => r_EOM.INFORMATION123
12291 ,P_EOM_ATTRIBUTE14 => r_EOM.INFORMATION124
12292 ,P_EOM_ATTRIBUTE15 => r_EOM.INFORMATION125
12293 ,P_EOM_ATTRIBUTE16 => r_EOM.INFORMATION126
12294 ,P_EOM_ATTRIBUTE17 => r_EOM.INFORMATION127
12295 ,P_EOM_ATTRIBUTE18 => r_EOM.INFORMATION128
12296 ,P_EOM_ATTRIBUTE19 => r_EOM.INFORMATION129
12297 ,P_EOM_ATTRIBUTE2 => r_EOM.INFORMATION112
12298 ,P_EOM_ATTRIBUTE20 => r_EOM.INFORMATION130
12299 ,P_EOM_ATTRIBUTE21 => r_EOM.INFORMATION131
12300 ,P_EOM_ATTRIBUTE22 => r_EOM.INFORMATION132
12301 ,P_EOM_ATTRIBUTE23 => r_EOM.INFORMATION133
12302 ,P_EOM_ATTRIBUTE24 => r_EOM.INFORMATION134
12303 ,P_EOM_ATTRIBUTE25 => r_EOM.INFORMATION135
12304 ,P_EOM_ATTRIBUTE26 => r_EOM.INFORMATION136
12305 ,P_EOM_ATTRIBUTE27 => r_EOM.INFORMATION137
12306 ,P_EOM_ATTRIBUTE28 => r_EOM.INFORMATION138
12307 ,P_EOM_ATTRIBUTE29 => r_EOM.INFORMATION139
12308 ,P_EOM_ATTRIBUTE3 => r_EOM.INFORMATION113
12309 ,P_EOM_ATTRIBUTE30 => r_EOM.INFORMATION140
12310 ,P_EOM_ATTRIBUTE4 => r_EOM.INFORMATION114
12311 ,P_EOM_ATTRIBUTE5 => r_EOM.INFORMATION115
12312 ,P_EOM_ATTRIBUTE6 => r_EOM.INFORMATION116
12313 ,P_EOM_ATTRIBUTE7 => r_EOM.INFORMATION117
12314 ,P_EOM_ATTRIBUTE8 => r_EOM.INFORMATION118
12315 ,P_EOM_ATTRIBUTE9 => r_EOM.INFORMATION119
12316 ,P_EOM_ATTRIBUTE_CATEGORY => r_EOM.INFORMATION110
12317 ,P_EXLCD_FLAG => r_EOM.INFORMATION12
12318 ,P_OPTD_MDCR_FLAG => r_EOM.INFORMATION11
12319 --
12320 -- ****** END CHANGE LINES
12321
12322 --
12323 ,P_EFFECTIVE_START_DATE => l_effective_start_date
12324 ,P_EFFECTIVE_END_DATE => l_effective_end_date
12325 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12326 ,P_DATETRACK_MODE => l_datetrack_mode
12327 );
12328 end if; -- l_update
12329 --
12330 end if;
12331 --
12332 -- Delete the row if it is end dated.
12333 --
12334 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
12335 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
12336 trunc(l_max_eed) = trunc(r_EOM.information3)) then
12337 --
12338 BEN_ELIG_OPTD_MDCR_PRTE_API.delete_ELIG_OPTD_MDCR_PRTE(
12339 --
12340 p_validate => false
12341 ,p_elig_optd_mdcr_prte_id => l_elig_optd_mdcr_prte_id
12342 ,p_effective_start_date => l_effective_start_date
12343 ,p_effective_end_date => l_effective_end_date
12344 ,p_object_version_number => l_object_version_number
12345 ,p_effective_date => l_max_eed
12346 ,p_datetrack_mode => hr_api.g_delete
12347 --
12348 );
12349 --
12350 end if;
12351 --
12352 l_prev_pk_id := l_current_pk_id ;
12353 --
12354 end if;
12355 --
12356 end if;
12357 --
12358 end loop;
12359 exception when others then
12360 --
12361 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EOM',r_EOM.information5 ) ;
12362 --
12363 --
12364 end create_EOM_rows;
12365 --
12366 ---------------------------------------------------------------
12367 ----------------------< create_EOU_rows >-----------------------
12368 ---------------------------------------------------------------
12369 --
12370 procedure create_EOU_rows
12371 (
12372 p_validate in number default 0
12373 ,p_copy_entity_txn_id in number
12374 ,p_effective_date in date
12375 ,p_prefix_suffix_text in varchar2 default null
12376 ,p_reuse_object_flag in varchar2 default null
12377 ,p_target_business_group_id in varchar2 default null
12378 ,p_prefix_suffix_cd in varchar2 default null
12379 ) is
12380 --
12381 l_ELIGY_PRFL_ID number;
12382 l_ORGANIZATION_ID number;
12383 cursor c_unique_EOU(l_table_alias varchar2) is
12384 select distinct cpe.information1,
12385 cpe.information2,
12386 cpe.information3,
12387 cpe.table_route_id
12388 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
12389 pqh_table_route tr
12390 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12391 and cpe.table_route_id = tr.table_route_id
12392 -- and tr.where_clause = l_BEN_ELIG_ORG_UNIT_PRTE_F
12393 and tr.table_alias = l_table_alias
12394 and cpe.number_of_copies = 1 -- ADDITION
12395 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
12396 order by information1, information2; --added for bug: 5151945
12397 --
12398 --
12399 cursor c_EOU_min_max_dates(c_table_route_id number,
12400 c_information1 number) is
12401 select
12402 min(cpe.information2) min_esd,
12403 max(cpe.information3) min_eed
12404 from ben_copy_entity_results cpe
12405 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12406 and cpe.table_route_id = c_table_route_id
12407 and cpe.information1 = c_information1 ;
12408 --
12409 cursor c_EOU(c_table_route_id number,
12410 c_information1 number,
12411 c_information2 date,
12412 c_information3 date ) is
12413 select
12414 cpe.*
12415 from ben_copy_entity_results cpe
12416 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12417 and cpe.table_route_id = c_table_route_id
12418 and cpe.information1 = c_information1
12419 and cpe.information2 = c_information2
12420 and cpe.information3 = c_information3
12421 and rownum = 1 ;
12422 -- Date Track target record
12423 cursor c_find_EOU_in_target(
12424 c_effective_start_date date,
12425 c_effective_end_date date,
12426 c_business_group_id number,
12427 c_new_pk_id number) is
12428 select
12429 EOU.elig_org_unit_prte_id new_value
12430 from BEN_ELIG_ORG_UNIT_PRTE_F EOU
12431 where
12432 EOU.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
12433 EOU.ORGANIZATION_ID = l_ORGANIZATION_ID and
12434 EOU.business_group_id = c_business_group_id
12435 and EOU.elig_org_unit_prte_id <> c_new_pk_id
12436 and c_effective_start_date between effective_start_date
12437 and effective_end_date ;
12438 --END TEMPIK
12439 /*TEMPIK
12440 and exists ( select null
12441 from BEN_ELIG_ORG_UNIT_PRTE_F EOU1
12442 where
12443 EOU1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
12444 EOU1.ORGANIZATION_ID = l_ORGANIZATION_ID and
12445 EOU1.business_group_id = c_business_group_id
12446 and EOU1.effective_start_date <= c_effective_start_date )
12447 and exists ( select null
12448 from BEN_ELIG_ORG_UNIT_PRTE_F EOU2
12449 where
12450 EOU2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
12451 EOU2.ORGANIZATION_ID = l_ORGANIZATION_ID and
12452 EOU2.business_group_id = c_business_group_id
12453 and EOU2.effective_end_date >= c_effective_end_date )
12454 ;
12455 TEMPIK */
12456 --TEMPIK
12457 l_dt_rec_found boolean ;
12458 --END TEMPIK
12459 --
12460
12461 --UPD START
12462 --
12463 l_update boolean := false ;
12464 l_datetrack_mode varchar2(80) := hr_api.g_update;
12465 l_process_date date;
12466 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
12467 --
12468 --UPD END
12469 l_current_pk_id number := null ;
12470
12471 l_prev_pk_id number := null ;
12472 l_first_rec boolean := true ;
12473 r_EOU c_EOU%rowtype;
12474 l_elig_org_unit_prte_id number ;
12475 l_object_version_number number ;
12476 l_effective_start_date date ;
12477 l_effective_end_date date ;
12478 l_prefix pqh_copy_entity_attribs.information1%type := null;
12479 l_suffix pqh_copy_entity_attribs.information1%type := null;
12480 l_new_value number(15);
12481 l_object_found_in_target boolean := false ;
12482 l_min_esd date;
12483 l_max_eed date;
12484 l_effective_date date;
12485 --
12486 begin
12487 -- Initialization
12488 l_object_found_in_target := false ;
12489 -- End Initialization
12490 -- Derive the prefix - sufix
12491 if p_prefix_suffix_cd = 'PREFIX' then
12492 l_prefix := p_prefix_suffix_text ;
12493 elsif p_prefix_suffix_cd = 'SUFFIX' then
12494 l_suffix := p_prefix_suffix_text ;
12495 else
12496 l_prefix := null ;
12497 l_suffix := null ;
12498 end if ;
12499 -- End Prefix Sufix derivation
12500 for r_EOU_unique in c_unique_EOU('EOU') loop
12501
12502 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
12503 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12504 r_EOU_unique.information3 >=
12505 ben_pd_copy_to_ben_one.g_copy_effective_date)
12506 ) then
12507 --
12508 hr_utility.set_location(' r_EOU_unique.table_route_id '||r_EOU_unique.table_route_id,10);
12509 hr_utility.set_location(' r_EOU_unique.information1 '||r_EOU_unique.information1,10);
12510 hr_utility.set_location( 'r_EOU_unique.information2 '||r_EOU_unique.information2,10);
12511 hr_utility.set_location( 'r_EOU_unique.information3 '||r_EOU_unique.information3,10);
12512 -- If reuse objects flag is 'Y' then check for the object in the target business group
12513 -- if found insert the record into PLSql table and exit the loop else try create the
12514 -- object in the target business group
12515 --
12516 l_object_found_in_target := false ;
12517 --UPD START
12518 l_update := false;
12519 l_process_date := p_effective_date;
12520 l_dml_operation:= r_EOU_unique.dml_operation ;
12521
12522 /**********************moved from below **********************/
12523 open c_EOU(r_EOU_unique.table_route_id,
12524 r_EOU_unique.information1,
12525 r_EOU_unique.information2,
12526 r_EOU_unique.information3 ) ;
12527 --
12528 fetch c_EOU into r_EOU ;
12529 --
12530 close c_EOU ;
12531 --
12532 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EOU.INFORMATION263,l_dml_operation);
12533 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
12534 l_ORGANIZATION_ID := r_EOU.information176;
12535 else
12536 l_ORGANIZATION_ID := r_EOU.information174;
12537 end if;
12538
12539 /**********************************************************/
12540 --
12541 if l_dml_operation = 'UPDATE' then
12542 --
12543 l_object_found_in_target := TRUE;
12544 --
12545 if l_process_date between r_EOU_unique.information2 and r_EOU_unique.information3 then
12546 l_update := true;
12547 if r_EOU_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
12548 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ORG_UNIT_PRTE_ID' then
12549 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ORG_UNIT_PRTE_ID' ;
12550 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EOU_unique.information1 ;
12551 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EOU_unique.information1 ;
12552 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
12553 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EOU_unique.table_route_id;
12554 --
12555 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
12556 --
12557 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
12558 --
12559 -- log_data('EOU',l_new_value,l_prefix || r_EOU_unique.name|| l_suffix,'REUSED');
12560 --
12561 end if ;
12562 hr_utility.set_location( 'found record for update',10);
12563 --
12564 else
12565 --
12566 l_update := false;
12567 --
12568 end if;
12569 else
12570 --
12571 --UPD END
12572 l_min_esd := null ;
12573 l_max_eed := null ;
12574 open c_EOU_min_max_dates(r_EOU_unique.table_route_id, r_EOU_unique.information1 ) ;
12575 fetch c_EOU_min_max_dates into l_min_esd,l_max_eed ;
12576 --
12577
12578 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12579 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
12580 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
12581 end if;
12582 l_min_esd := greatest(l_min_esd,r_EOU_unique.information2);
12583 /**********************moved up from here **********************
12584 open c_EOU(r_EOU_unique.table_route_id,
12585 r_EOU_unique.information1,
12586 r_EOU_unique.information2,
12587 r_EOU_unique.information3 ) ;
12588 --
12589 fetch c_EOU into r_EOU ;
12590 --
12591 close c_EOU ;
12592 --
12593 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EOU.INFORMATION263,l_dml_operation);
12594 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
12595 l_ORGANIZATION_ID := r_EOU.information176;
12596 else
12597 l_ORGANIZATION_ID := r_EOU.information174;
12598 end if;
12599
12600 **********************************************************/
12601
12602 --
12603 if l_ORGANIZATION_ID is null then
12604 close c_EOU_min_max_dates;
12605 --
12606 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
12607 ,p_parent_pk_id => r_EOU.information263
12608 ,p_copy_entity_txn_id => p_copy_entity_txn_id
12609 ,p_child_table_alias => 'EOU'
12610 ,p_child_data => r_EOU.information173 );
12611
12612 --
12613 else
12614 if p_reuse_object_flag = 'Y' then
12615 if c_EOU_min_max_dates%found then
12616 -- cursor to find the object
12617 open c_find_EOU_in_target( l_min_esd,l_max_eed,
12618 p_target_business_group_id, nvl(l_elig_org_unit_prte_id, -999) ) ;
12619 fetch c_find_EOU_in_target into l_new_value ;
12620 if c_find_EOU_in_target%found then
12621 --
12622 --TEMPIK
12623 l_dt_rec_found := dt_api.check_min_max_dates
12624 (p_base_table_name => 'BEN_ELIG_ORG_UNIT_PRTE_F',
12625 p_base_key_column => 'ELIG_ORG_UNIT_PRTE_ID',
12626 p_base_key_value => l_new_value,
12627 p_from_date => l_min_esd,
12628 p_to_date => l_max_eed );
12629 if l_dt_rec_found THEN
12630 --END TEMPIK
12631 if r_EOU_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
12632 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ORG_UNIT_PRTE_ID' then
12633 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ORG_UNIT_PRTE_ID' ;
12634 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EOU_unique.information1 ;
12635 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
12636 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
12637 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EOU_unique.table_route_id;
12638 --
12639 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
12640 --
12641 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
12642 end if ;
12643 --
12644 l_object_found_in_target := true ;
12645 --TEMPIK
12646 end if; -- l_dt_rec_found
12647 --END TEMPIK
12648 end if;
12649 close c_find_EOU_in_target ;
12650 --
12651 end if;
12652 end if ;
12653 --
12654 close c_EOU_min_max_dates ;
12655 end if ; ---- bug 4565106
12656
12657 end if; --if p_dml_operation
12658 --
12659 -- Added l_ORGANIZATION_ID is not null clause for bug 4101596
12660 --
12661 if (not l_object_found_in_target OR l_update ) AND l_ORGANIZATION_ID is not null then
12662
12663 --
12664 l_current_pk_id := r_EOU.information1;
12665 --
12666 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
12667 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
12668 --
12669 if l_current_pk_id = l_prev_pk_id then
12670 --
12671 l_first_rec := false ;
12672 --
12673 else
12674 --
12675 l_first_rec := true ;
12676 --
12677 end if ;
12678 --
12679
12680 l_effective_date := r_EOU.information2;
12681 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12682 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
12683 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
12684 end if;
12685
12686 if l_first_rec and not l_update then
12687 -- Call Create routine.
12688 hr_utility.set_location(' BEN_ELIG_ORG_UNIT_PRTE_F CREATE_ELIG_ORG_UNIT_PRTE ',20);
12689 BEN_ELIG_ORG_UNIT_PRTE_API.CREATE_ELIG_ORG_UNIT_PRTE(
12690 --
12691 P_VALIDATE => false
12692 ,P_EFFECTIVE_DATE => l_effective_date
12693 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
12694 --
12695 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
12696 ,P_ELIG_ORG_UNIT_PRTE_ID => l_elig_org_unit_prte_id
12697 ,P_EOU_ATTRIBUTE1 => r_EOU.INFORMATION111
12698 ,P_EOU_ATTRIBUTE10 => r_EOU.INFORMATION120
12699 ,P_EOU_ATTRIBUTE11 => r_EOU.INFORMATION121
12700 ,P_EOU_ATTRIBUTE12 => r_EOU.INFORMATION122
12701 ,P_EOU_ATTRIBUTE13 => r_EOU.INFORMATION123
12702 ,P_EOU_ATTRIBUTE14 => r_EOU.INFORMATION124
12703 ,P_EOU_ATTRIBUTE15 => r_EOU.INFORMATION125
12704 ,P_EOU_ATTRIBUTE16 => r_EOU.INFORMATION126
12705 ,P_EOU_ATTRIBUTE17 => r_EOU.INFORMATION127
12706 ,P_EOU_ATTRIBUTE18 => r_EOU.INFORMATION128
12707 ,P_EOU_ATTRIBUTE19 => r_EOU.INFORMATION129
12708 ,P_EOU_ATTRIBUTE2 => r_EOU.INFORMATION112
12709 ,P_EOU_ATTRIBUTE20 => r_EOU.INFORMATION130
12710 ,P_EOU_ATTRIBUTE21 => r_EOU.INFORMATION131
12711 ,P_EOU_ATTRIBUTE22 => r_EOU.INFORMATION132
12712 ,P_EOU_ATTRIBUTE23 => r_EOU.INFORMATION133
12713 ,P_EOU_ATTRIBUTE24 => r_EOU.INFORMATION134
12714 ,P_EOU_ATTRIBUTE25 => r_EOU.INFORMATION135
12715 ,P_EOU_ATTRIBUTE26 => r_EOU.INFORMATION136
12716 ,P_EOU_ATTRIBUTE27 => r_EOU.INFORMATION137
12717 ,P_EOU_ATTRIBUTE28 => r_EOU.INFORMATION138
12718 ,P_EOU_ATTRIBUTE29 => r_EOU.INFORMATION139
12719 ,P_EOU_ATTRIBUTE3 => r_EOU.INFORMATION113
12720 ,P_EOU_ATTRIBUTE30 => r_EOU.INFORMATION140
12721 ,P_EOU_ATTRIBUTE4 => r_EOU.INFORMATION114
12722 ,P_EOU_ATTRIBUTE5 => r_EOU.INFORMATION115
12723 ,P_EOU_ATTRIBUTE6 => r_EOU.INFORMATION116
12724 ,P_EOU_ATTRIBUTE7 => r_EOU.INFORMATION117
12725 ,P_EOU_ATTRIBUTE8 => r_EOU.INFORMATION118
12726 ,P_EOU_ATTRIBUTE9 => r_EOU.INFORMATION119
12727 ,P_EOU_ATTRIBUTE_CATEGORY => r_EOU.INFORMATION110
12728 ,P_EXCLD_FLAG => r_EOU.INFORMATION11
12729 ,P_ORDR_NUM => r_EOU.INFORMATION260
12730 ,P_ORGANIZATION_ID => l_ORGANIZATION_ID
12731 --
12732 -- ****** END CHANGE LINES
12733
12734 --
12735
12736 ,P_EFFECTIVE_START_DATE => l_effective_start_date
12737 ,P_EFFECTIVE_END_DATE => l_effective_end_date
12738 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12739 ,P_CRITERIA_SCORE => r_eou.INFORMATION295
12740 ,P_CRITERIA_WEIGHT => r_eou.INFORMATION296
12741 );
12742 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
12743 -- Update all relevent cer records with new pk_id
12744 hr_utility.set_location('Before plsql table ',222);
12745 hr_utility.set_location('new_value id '||l_elig_org_unit_prte_id,222);
12746 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ORG_UNIT_PRTE_ID' ;
12747 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EOU.information1 ;
12748 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_ORG_UNIT_PRTE_ID ;
12749 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
12750 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EOU_unique.table_route_id;
12751 hr_utility.set_location('After plsql table ',222);
12752 --
12753 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
12754 --
12755 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
12756 --
12757 else
12758 --
12759 -- Call Update routine for the pk_id created in prev run .
12760 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
12761 hr_utility.set_location(' BEN_ELIG_ORG_UNIT_PRTE_F UPDATE_ELIG_ORG_UNIT_PRTE ',30);
12762 --UPD START
12763 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
12764 --
12765 if l_update then
12766 --
12767 l_datetrack_mode := r_EOU.datetrack_mode ;
12768 --
12769 get_dt_modes(
12770 p_effective_date => l_process_date,
12771 p_effective_end_date => r_EOU.information3,
12772 p_effective_start_date => r_EOU.information2,
12773 p_dml_operation => r_EOU.dml_operation,
12774 p_datetrack_mode => l_datetrack_mode );
12775 -- p_update => l_update
12776 --
12777 l_effective_date := l_process_date;
12778 l_ELIG_ORG_UNIT_PRTE_ID := r_EOU.information1;
12779 l_object_version_number := r_EOU.information265;
12780 --
12781 end if;
12782 --
12783 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
12784 --
12785 IF l_update OR l_dml_operation <> 'UPDATE' THEN
12786 --UPD END
12787
12788
12789 BEN_ELIG_ORG_UNIT_PRTE_API.UPDATE_ELIG_ORG_UNIT_PRTE(
12790 --
12791 P_VALIDATE => false
12792 ,P_EFFECTIVE_DATE => l_effective_date
12793 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
12794 --
12795 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
12796 ,P_ELIG_ORG_UNIT_PRTE_ID => l_elig_org_unit_prte_id
12797 ,P_EOU_ATTRIBUTE1 => r_EOU.INFORMATION111
12798 ,P_EOU_ATTRIBUTE10 => r_EOU.INFORMATION120
12799 ,P_EOU_ATTRIBUTE11 => r_EOU.INFORMATION121
12800 ,P_EOU_ATTRIBUTE12 => r_EOU.INFORMATION122
12801 ,P_EOU_ATTRIBUTE13 => r_EOU.INFORMATION123
12802 ,P_EOU_ATTRIBUTE14 => r_EOU.INFORMATION124
12803 ,P_EOU_ATTRIBUTE15 => r_EOU.INFORMATION125
12804 ,P_EOU_ATTRIBUTE16 => r_EOU.INFORMATION126
12805 ,P_EOU_ATTRIBUTE17 => r_EOU.INFORMATION127
12806 ,P_EOU_ATTRIBUTE18 => r_EOU.INFORMATION128
12807 ,P_EOU_ATTRIBUTE19 => r_EOU.INFORMATION129
12808 ,P_EOU_ATTRIBUTE2 => r_EOU.INFORMATION112
12809 ,P_EOU_ATTRIBUTE20 => r_EOU.INFORMATION130
12810 ,P_EOU_ATTRIBUTE21 => r_EOU.INFORMATION131
12811 ,P_EOU_ATTRIBUTE22 => r_EOU.INFORMATION132
12812 ,P_EOU_ATTRIBUTE23 => r_EOU.INFORMATION133
12813 ,P_EOU_ATTRIBUTE24 => r_EOU.INFORMATION134
12814 ,P_EOU_ATTRIBUTE25 => r_EOU.INFORMATION135
12815 ,P_EOU_ATTRIBUTE26 => r_EOU.INFORMATION136
12816 ,P_EOU_ATTRIBUTE27 => r_EOU.INFORMATION137
12817 ,P_EOU_ATTRIBUTE28 => r_EOU.INFORMATION138
12818 ,P_EOU_ATTRIBUTE29 => r_EOU.INFORMATION139
12819 ,P_EOU_ATTRIBUTE3 => r_EOU.INFORMATION113
12820 ,P_EOU_ATTRIBUTE30 => r_EOU.INFORMATION140
12821 ,P_EOU_ATTRIBUTE4 => r_EOU.INFORMATION114
12822 ,P_EOU_ATTRIBUTE5 => r_EOU.INFORMATION115
12823 ,P_EOU_ATTRIBUTE6 => r_EOU.INFORMATION116
12824 ,P_EOU_ATTRIBUTE7 => r_EOU.INFORMATION117
12825 ,P_EOU_ATTRIBUTE8 => r_EOU.INFORMATION118
12826 ,P_EOU_ATTRIBUTE9 => r_EOU.INFORMATION119
12827 ,P_EOU_ATTRIBUTE_CATEGORY => r_EOU.INFORMATION110
12828 ,P_EXCLD_FLAG => r_EOU.INFORMATION11
12829 ,P_ORDR_NUM => r_EOU.INFORMATION260
12830 ,P_ORGANIZATION_ID => l_ORGANIZATION_ID
12831 --
12832 -- ****** END CHANGE LINES
12833
12834 --
12835 ,P_EFFECTIVE_START_DATE => l_effective_start_date
12836 ,P_EFFECTIVE_END_DATE => l_effective_end_date
12837 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12838 ,P_DATETRACK_MODE => l_datetrack_mode
12839 ,P_CRITERIA_SCORE => r_eou.INFORMATION295
12840 ,P_CRITERIA_WEIGHT => r_eou.INFORMATION296
12841 );
12842 end if; -- l_update
12843 --
12844 end if;
12845 --
12846 -- Delete the row if it is end dated.
12847 --
12848 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
12849 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
12850 trunc(l_max_eed) = trunc(r_EOU.information3)) then
12851 --
12852 BEN_ELIG_ORG_UNIT_PRTE_API.delete_ELIG_ORG_UNIT_PRTE(
12853 --
12854 p_validate => false
12855 ,p_elig_org_unit_prte_id => l_elig_org_unit_prte_id
12856 ,p_effective_start_date => l_effective_start_date
12857 ,p_effective_end_date => l_effective_end_date
12858 ,p_object_version_number => l_object_version_number
12859 ,p_effective_date => l_max_eed
12860 ,p_datetrack_mode => hr_api.g_delete
12861 --
12862 );
12863 --
12864 end if;
12865 --
12866 l_prev_pk_id := l_current_pk_id ;
12867 --
12868 -- end if; -- bug 4565106
12869 --
12870 end if;
12871 --
12872 end if;
12873 --
12874 end loop;
12875 --
12876 exception when others then
12877 --
12878 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EOU',r_EOU.information5 ) ;
12879 --
12880 end create_EOU_rows;
12881
12882
12883
12884 --
12885 ---------------------------------------------------------------
12886 ----------------------< create_EOY_rows >-----------------------
12887 ---------------------------------------------------------------
12888 --
12889 procedure create_EOY_rows
12890 (
12891 p_validate in number default 0
12892 ,p_copy_entity_txn_id in number
12893 ,p_effective_date in date
12894 ,p_prefix_suffix_text in varchar2 default null
12895 ,p_reuse_object_flag in varchar2 default null
12896 ,p_target_business_group_id in varchar2 default null
12897 ,p_prefix_suffix_cd in varchar2 default null
12898 ) is
12899 --
12900 l_ELIGY_PRFL_ID number;
12901 l_PTIP_ID number;
12902 l_ORDR_NUM number ;
12903 cursor c_unique_EOY(l_table_alias varchar2) is
12904 select distinct cpe.information1,
12905 cpe.information2,
12906 cpe.information3,
12907 cpe.table_route_id
12908 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
12909 pqh_table_route tr
12910 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12911 and cpe.table_route_id = tr.table_route_id
12912 -- and tr.where_clause = l_BEN_ELIG_OTHR_PTIP_PRTE_F
12913 and tr.table_alias = l_table_alias
12914 and cpe.number_of_copies = 1 -- ADDITION
12915 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
12916 order by information1, information2; --added for bug: 5151945
12917 --
12918 --
12919 cursor c_EOY_min_max_dates(c_table_route_id number,
12920 c_information1 number) is
12921 select
12922 min(cpe.information2) min_esd,
12923 max(cpe.information3) min_eed
12924 from ben_copy_entity_results cpe
12925 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12926 and cpe.table_route_id = c_table_route_id
12927 and cpe.information1 = c_information1 ;
12928 --
12929 cursor c_EOY(c_table_route_id number,
12930 c_information1 number,
12931 c_information2 date,
12932 c_information3 date ) is
12933 select
12934 cpe.*
12935 from ben_copy_entity_results cpe
12936 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12937 and cpe.table_route_id = c_table_route_id
12938 and cpe.information1 = c_information1
12939 and cpe.information2 = c_information2
12940 and cpe.information3 = c_information3
12941 and rownum = 1 ;
12942 -- Date Track target record
12943 cursor c_find_EOY_in_target(
12944 c_effective_start_date date,
12945 c_effective_end_date date,
12946 c_business_group_id number,
12947 c_new_pk_id number) is
12948 select
12949 EOY.elig_othr_ptip_prte_id new_value
12950 from BEN_ELIG_OTHR_PTIP_PRTE_F EOY
12951 where
12952 EOY.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
12953 EOY.PTIP_ID = l_PTIP_ID and
12954 EOY.business_group_id = c_business_group_id
12955 and EOY.elig_othr_ptip_prte_id <> c_new_pk_id
12956 and c_effective_start_date between effective_start_date
12957 and effective_end_date ;
12958 --END TEMPIK
12959 /*TEMPIK
12960 and exists ( select null
12961 from BEN_ELIG_OTHR_PTIP_PRTE_F EOY1
12962 where
12963 EOY1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
12964 EOY1.PTIP_ID = l_PTIP_ID and
12965 EOY1.business_group_id = c_business_group_id
12966 and EOY1.effective_start_date <= c_effective_start_date )
12967 and exists ( select null
12968 from BEN_ELIG_OTHR_PTIP_PRTE_F EOY2
12969 where
12970 EOY2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
12971 EOY2.PTIP_ID = l_PTIP_ID and
12972 EOY2.business_group_id = c_business_group_id
12973 and EOY2.effective_end_date >= c_effective_end_date )
12974 ;
12975 TEMPIK */
12976 --TEMPIK
12977 l_dt_rec_found boolean ;
12978 --END TEMPIK
12979 --
12980
12981 --UPD START
12982 --
12983 l_update boolean := false ;
12984 l_datetrack_mode varchar2(80) := hr_api.g_update;
12985 l_process_date date;
12986 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
12987 --
12988 --UPD END
12989 l_current_pk_id number := null ;
12990
12991 l_prev_pk_id number := null ;
12992 l_first_rec boolean := true ;
12993 r_EOY c_EOY%rowtype;
12994 l_elig_othr_ptip_prte_id number ;
12995 l_object_version_number number ;
12996 l_effective_start_date date ;
12997 l_effective_end_date date ;
12998 l_prefix pqh_copy_entity_attribs.information1%type := null;
12999 l_suffix pqh_copy_entity_attribs.information1%type := null;
13000 l_new_value number(15);
13001 l_object_found_in_target boolean := false ;
13002 l_min_esd date;
13003 l_max_eed date;
13004 l_effective_date date;
13005 --
13006 begin
13007 -- Initialization
13008 l_object_found_in_target := false ;
13009 -- End Initialization
13010 -- Derive the prefix - sufix
13011 if p_prefix_suffix_cd = 'PREFIX' then
13012 l_prefix := p_prefix_suffix_text ;
13013 elsif p_prefix_suffix_cd = 'SUFFIX' then
13014 l_suffix := p_prefix_suffix_text ;
13015 else
13016 l_prefix := null ;
13017 l_suffix := null ;
13018 end if ;
13019 -- End Prefix Sufix derivation
13020 for r_EOY_unique in c_unique_EOY('EOY') loop
13021
13022 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
13023 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13024 r_EOY_unique.information3 >=
13025 ben_pd_copy_to_ben_one.g_copy_effective_date)
13026 ) then
13027 --
13028 hr_utility.set_location(' r_EOY_unique.table_route_id '||r_EOY_unique.table_route_id,10);
13029 hr_utility.set_location(' r_EOY_unique.information1 '||r_EOY_unique.information1,10);
13030 hr_utility.set_location( 'r_EOY_unique.information2 '||r_EOY_unique.information2,10);
13031 hr_utility.set_location( 'r_EOY_unique.information3 '||r_EOY_unique.information3,10);
13032 -- If reuse objects flag is 'Y' then check for the object in the target business group
13033 -- if found insert the record into PLSql table and exit the loop else try create the
13034 -- object in the target business group
13035 --
13036 l_object_found_in_target := false ;
13037 --UPD START
13038 l_update := false;
13039 l_process_date := p_effective_date;
13040 l_dml_operation:= r_EOY_unique.dml_operation ;
13041 --
13042 /**********************moved from below **********************/
13043 open c_EOY(r_EOY_unique.table_route_id,
13044 r_EOY_unique.information1,
13045 r_EOY_unique.information2,
13046 r_EOY_unique.information3 ) ;
13047 --
13048 fetch c_EOY into r_EOY ;
13049 --
13050 close c_EOY ;
13051 --
13052 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EOY.INFORMATION263,l_dml_operation);
13053
13054 -- Only For Use by Create Wizard - Same Business Group
13055 l_PTIP_ID := NVL(get_fk('PTIP_ID', r_EOY.INFORMATION259,l_dml_operation),
13056 r_EOY.INFORMATION259);
13057 /**********************************************************/
13058
13059 if l_dml_operation = 'UPDATE' then
13060 --
13061 l_object_found_in_target := TRUE;
13062 --
13063 if l_process_date between r_EOY_unique.information2 and r_EOY_unique.information3 then
13064 l_update := true;
13065 if r_EOY_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
13066 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_OTHR_PTIP_PRTE_ID' then
13067 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_OTHR_PTIP_PRTE_ID' ;
13068 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EOY_unique.information1 ;
13069 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EOY_unique.information1 ;
13070 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
13071 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EOY_unique.table_route_id;
13072 --
13073 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
13074 --
13075 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
13076 --
13077 -- log_data('EOY',l_new_value,l_prefix || r_EOY_unique.name|| l_suffix,'REUSED');
13078 --
13079 end if ;
13080 hr_utility.set_location( 'found record for update',10);
13081 --
13082 else
13083 --
13084 l_update := false;
13085 --
13086 end if;
13087 else
13088 --
13089 --UPD END
13090 l_min_esd := null ;
13091 l_max_eed := null ;
13092 open c_EOY_min_max_dates(r_EOY_unique.table_route_id, r_EOY_unique.information1 ) ;
13093 fetch c_EOY_min_max_dates into l_min_esd,l_max_eed ;
13094 --
13095
13096 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13097 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
13098 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
13099 end if;
13100 l_min_esd := greatest(l_min_esd,r_EOY_unique.information2);
13101 /**********************moved up from here **********************
13102 open c_EOY(r_EOY_unique.table_route_id,
13103 r_EOY_unique.information1,
13104 r_EOY_unique.information2,
13105 r_EOY_unique.information3 ) ;
13106 --
13107 fetch c_EOY into r_EOY ;
13108 --
13109 close c_EOY ;
13110 --
13111 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EOY.INFORMATION263,l_dml_operation);
13112
13113 -- Only For Use by Create Wizard - Same Business Group
13114 l_PTIP_ID := NVL(get_fk('PTIP_ID', r_EOY.INFORMATION259,l_dml_operation),
13115 r_EOY.INFORMATION259);
13116 **********************************************************/
13117
13118 if p_reuse_object_flag = 'Y' then
13119 if c_EOY_min_max_dates%found then
13120 -- cursor to find the object
13121 open c_find_EOY_in_target( l_min_esd,l_max_eed,
13122 p_target_business_group_id, nvl(l_elig_othr_ptip_prte_id, -999) ) ;
13123 fetch c_find_EOY_in_target into l_new_value ;
13124 if c_find_EOY_in_target%found then
13125 --
13126 --TEMPIK
13127 l_dt_rec_found := dt_api.check_min_max_dates
13128 (p_base_table_name => 'BEN_ELIG_OTHR_PTIP_PRTE_F',
13129 p_base_key_column => 'ELIG_OTHR_PTIP_PRTE_ID',
13130 p_base_key_value => l_new_value,
13131 p_from_date => l_min_esd,
13132 p_to_date => l_max_eed );
13133 if l_dt_rec_found THEN
13134 --END TEMPIK
13135 if r_EOY_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
13136 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_OTHR_PTIP_PRTE_ID' then
13137 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_OTHR_PTIP_PRTE_ID' ;
13138 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EOY_unique.information1 ;
13139 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
13140 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
13141 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EOY_unique.table_route_id;
13142 --
13143 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
13144 --
13145 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
13146 end if ;
13147 --
13148 l_object_found_in_target := true ;
13149 --TEMPIK
13150 end if; -- l_dt_rec_found
13151 --END TEMPIK
13152 end if;
13153 close c_find_EOY_in_target ;
13154 --
13155 end if;
13156 end if ;
13157 --
13158 close c_EOY_min_max_dates ;
13159 end if; --if p_dml_operation
13160 --
13161 if not l_object_found_in_target OR l_update then
13162
13163 --
13164 l_current_pk_id := r_EOY.information1;
13165 --
13166 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
13167 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
13168 --
13169 if l_current_pk_id = l_prev_pk_id then
13170 --
13171 l_first_rec := false ;
13172 --
13173 else
13174 --
13175 l_first_rec := true ;
13176 --
13177 end if ;
13178 --
13179
13180 l_effective_date := r_EOY.information2;
13181 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13182 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
13183 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
13184 end if;
13185
13186 if l_first_rec and not l_update then
13187 -- Call Create routine.
13188 hr_utility.set_location(' BEN_ELIG_OTHR_PTIP_PRTE_F CREATE_ELIG_OTHR_PTIP_PRTE ',20);
13189 BEN_ELIG_OTHR_PTIP_PRTE_API.CREATE_ELIG_OTHR_PTIP_PRTE(
13190 --
13191 P_VALIDATE => false
13192 ,P_EFFECTIVE_DATE => l_effective_date
13193 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
13194 --
13195 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
13196 ,P_ELIG_OTHR_PTIP_PRTE_ID => l_elig_othr_ptip_prte_id
13197 ,P_EOY_ATTRIBUTE1 => r_EOY.INFORMATION111
13198 ,P_EOY_ATTRIBUTE10 => r_EOY.INFORMATION120
13199 ,P_EOY_ATTRIBUTE11 => r_EOY.INFORMATION121
13200 ,P_EOY_ATTRIBUTE12 => r_EOY.INFORMATION122
13201 ,P_EOY_ATTRIBUTE13 => r_EOY.INFORMATION123
13202 ,P_EOY_ATTRIBUTE14 => r_EOY.INFORMATION124
13203 ,P_EOY_ATTRIBUTE15 => r_EOY.INFORMATION125
13204 ,P_EOY_ATTRIBUTE16 => r_EOY.INFORMATION126
13205 ,P_EOY_ATTRIBUTE17 => r_EOY.INFORMATION127
13206 ,P_EOY_ATTRIBUTE18 => r_EOY.INFORMATION128
13207 ,P_EOY_ATTRIBUTE19 => r_EOY.INFORMATION129
13208 ,P_EOY_ATTRIBUTE2 => r_EOY.INFORMATION112
13209 ,P_EOY_ATTRIBUTE20 => r_EOY.INFORMATION130
13210 ,P_EOY_ATTRIBUTE21 => r_EOY.INFORMATION131
13211 ,P_EOY_ATTRIBUTE22 => r_EOY.INFORMATION132
13212 ,P_EOY_ATTRIBUTE23 => r_EOY.INFORMATION133
13213 ,P_EOY_ATTRIBUTE24 => r_EOY.INFORMATION134
13214 ,P_EOY_ATTRIBUTE25 => r_EOY.INFORMATION135
13215 ,P_EOY_ATTRIBUTE26 => r_EOY.INFORMATION136
13216 ,P_EOY_ATTRIBUTE27 => r_EOY.INFORMATION137
13217 ,P_EOY_ATTRIBUTE28 => r_EOY.INFORMATION138
13218 ,P_EOY_ATTRIBUTE29 => r_EOY.INFORMATION139
13219 ,P_EOY_ATTRIBUTE3 => r_EOY.INFORMATION113
13220 ,P_EOY_ATTRIBUTE30 => r_EOY.INFORMATION140
13221 ,P_EOY_ATTRIBUTE4 => r_EOY.INFORMATION114
13222 ,P_EOY_ATTRIBUTE5 => r_EOY.INFORMATION115
13223 ,P_EOY_ATTRIBUTE6 => r_EOY.INFORMATION116
13224 ,P_EOY_ATTRIBUTE7 => r_EOY.INFORMATION117
13225 ,P_EOY_ATTRIBUTE8 => r_EOY.INFORMATION118
13226 ,P_EOY_ATTRIBUTE9 => r_EOY.INFORMATION119
13227 ,P_EOY_ATTRIBUTE_CATEGORY => r_EOY.INFORMATION110
13228 ,P_EXCLD_FLAG => r_EOY.INFORMATION11
13229 ,P_ONLY_PLS_SUBJ_COBRA_FLAG => r_EOY.INFORMATION12
13230 ,P_ORDR_NUM => r_EOY.INFORMATION261
13231 ,P_PTIP_ID => l_PTIP_ID
13232 --
13233 -- ****** END CHANGE LINES
13234
13235 --
13236
13237 ,P_EFFECTIVE_START_DATE => l_effective_start_date
13238 ,P_EFFECTIVE_END_DATE => l_effective_end_date
13239 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
13240 );
13241 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
13242 -- Update all relevent cer records with new pk_id
13243 hr_utility.set_location('Before plsql table ',222);
13244 hr_utility.set_location('new_value id '||l_elig_othr_ptip_prte_id,222);
13245 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_OTHR_PTIP_PRTE_ID' ;
13246 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EOY.information1 ;
13247 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_OTHR_PTIP_PRTE_ID ;
13248 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
13249 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EOY_unique.table_route_id;
13250 hr_utility.set_location('After plsql table ',222);
13251 --
13252 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
13253 --
13254 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
13255 --
13256 else
13257 --
13258 -- Call Update routine for the pk_id created in prev run .
13259 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
13260 hr_utility.set_location(' BEN_ELIG_OTHR_PTIP_PRTE_F UPDATE_ELIG_OTHR_PTIP_PRTE ',30);
13261 --UPD START
13262 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
13263 --
13264 if l_update then
13265 --
13266 l_datetrack_mode := r_EOY.datetrack_mode ;
13267 --
13268 get_dt_modes(
13269 p_effective_date => l_process_date,
13270 p_effective_end_date => r_EOY.information3,
13271 p_effective_start_date => r_EOY.information2,
13272 p_dml_operation => r_EOY.dml_operation,
13273 p_datetrack_mode => l_datetrack_mode );
13274 -- p_update => l_update
13275 --
13276 l_effective_date := l_process_date;
13277 l_ELIG_OTHR_PTIP_PRTE_ID := r_EOY.information1;
13278 l_object_version_number := r_EOY.information265;
13279 --
13280 end if;
13281 --
13282 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
13283 --
13284 IF l_update OR l_dml_operation <> 'UPDATE' THEN
13285 --UPD END
13286
13287
13288 BEN_ELIG_OTHR_PTIP_PRTE_API.UPDATE_ELIG_OTHR_PTIP_PRTE(
13289 --
13290 P_VALIDATE => false
13291 ,P_EFFECTIVE_DATE => l_effective_date
13292 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
13293 --
13294 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
13295 ,P_ELIG_OTHR_PTIP_PRTE_ID => l_elig_othr_ptip_prte_id
13296 ,P_EOY_ATTRIBUTE1 => r_EOY.INFORMATION111
13297 ,P_EOY_ATTRIBUTE10 => r_EOY.INFORMATION120
13298 ,P_EOY_ATTRIBUTE11 => r_EOY.INFORMATION121
13299 ,P_EOY_ATTRIBUTE12 => r_EOY.INFORMATION122
13300 ,P_EOY_ATTRIBUTE13 => r_EOY.INFORMATION123
13301 ,P_EOY_ATTRIBUTE14 => r_EOY.INFORMATION124
13302 ,P_EOY_ATTRIBUTE15 => r_EOY.INFORMATION125
13303 ,P_EOY_ATTRIBUTE16 => r_EOY.INFORMATION126
13304 ,P_EOY_ATTRIBUTE17 => r_EOY.INFORMATION127
13305 ,P_EOY_ATTRIBUTE18 => r_EOY.INFORMATION128
13306 ,P_EOY_ATTRIBUTE19 => r_EOY.INFORMATION129
13307 ,P_EOY_ATTRIBUTE2 => r_EOY.INFORMATION112
13308 ,P_EOY_ATTRIBUTE20 => r_EOY.INFORMATION130
13309 ,P_EOY_ATTRIBUTE21 => r_EOY.INFORMATION131
13310 ,P_EOY_ATTRIBUTE22 => r_EOY.INFORMATION132
13311 ,P_EOY_ATTRIBUTE23 => r_EOY.INFORMATION133
13312 ,P_EOY_ATTRIBUTE24 => r_EOY.INFORMATION134
13313 ,P_EOY_ATTRIBUTE25 => r_EOY.INFORMATION135
13314 ,P_EOY_ATTRIBUTE26 => r_EOY.INFORMATION136
13315 ,P_EOY_ATTRIBUTE27 => r_EOY.INFORMATION137
13316 ,P_EOY_ATTRIBUTE28 => r_EOY.INFORMATION138
13317 ,P_EOY_ATTRIBUTE29 => r_EOY.INFORMATION139
13318 ,P_EOY_ATTRIBUTE3 => r_EOY.INFORMATION113
13319 ,P_EOY_ATTRIBUTE30 => r_EOY.INFORMATION140
13320 ,P_EOY_ATTRIBUTE4 => r_EOY.INFORMATION114
13321 ,P_EOY_ATTRIBUTE5 => r_EOY.INFORMATION115
13322 ,P_EOY_ATTRIBUTE6 => r_EOY.INFORMATION116
13323 ,P_EOY_ATTRIBUTE7 => r_EOY.INFORMATION117
13324 ,P_EOY_ATTRIBUTE8 => r_EOY.INFORMATION118
13325 ,P_EOY_ATTRIBUTE9 => r_EOY.INFORMATION119
13326 ,P_EOY_ATTRIBUTE_CATEGORY => r_EOY.INFORMATION110
13327 ,P_EXCLD_FLAG => r_EOY.INFORMATION11
13328 ,P_ONLY_PLS_SUBJ_COBRA_FLAG => r_EOY.INFORMATION12
13329 ,P_ORDR_NUM => r_EOY.INFORMATION261
13330 ,P_PTIP_ID => l_PTIP_ID
13331 --
13332 -- ****** END CHANGE LINES
13333
13334 --
13335 ,P_EFFECTIVE_START_DATE => l_effective_start_date
13336 ,P_EFFECTIVE_END_DATE => l_effective_end_date
13337 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
13338 ,P_DATETRACK_MODE => l_datetrack_mode
13339 );
13340 end if; -- l_update
13341 --
13342 end if;
13343 --
13344 -- Delete the row if it is end dated.
13345 --
13346 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
13347 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
13348 trunc(l_max_eed) = trunc(r_EOY.information3)) then
13349 --
13350 BEN_ELIG_OTHR_PTIP_PRTE_API.delete_ELIG_OTHR_PTIP_PRTE(
13351 --
13352 p_validate => false
13353 ,p_elig_othr_ptip_prte_id => l_elig_othr_ptip_prte_id
13354 ,p_effective_start_date => l_effective_start_date
13355 ,p_effective_end_date => l_effective_end_date
13356 ,p_object_version_number => l_object_version_number
13357 ,p_effective_date => l_max_eed
13358 ,p_datetrack_mode => hr_api.g_delete
13359 --
13360 );
13361 --
13362 end if;
13363 --
13364 l_prev_pk_id := l_current_pk_id ;
13365 --
13366 end if;
13367 --
13368 end if;
13369 --
13370 end loop;
13371 --
13372 exception when others then
13373 --
13374 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EOY',r_EOY.information5 ) ;
13375 --
13376 end create_EOY_rows;
13377
13378
13379
13380 --
13381 ---------------------------------------------------------------
13382 ----------------------< create_EPF_rows >-----------------------
13383 ---------------------------------------------------------------
13384 --
13385 procedure create_EPF_rows
13386 (
13387 p_validate in number default 0
13388 ,p_copy_entity_txn_id in number
13389 ,p_effective_date in date
13390 ,p_prefix_suffix_text in varchar2 default null
13391 ,p_reuse_object_flag in varchar2 default null
13392 ,p_target_business_group_id in varchar2 default null
13393 ,p_prefix_suffix_cd in varchar2 default null
13394 ) is
13395 --
13396 l_ELIGY_PRFL_ID number;
13397 l_PCT_FL_TM_FCTR_ID number;
13398 l_ORDR_NUM number;
13399 cursor c_unique_EPF(l_table_alias varchar2) is
13400 select distinct cpe.information1,
13401 cpe.information2,
13402 cpe.information3,
13403 cpe.table_route_id
13404 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
13405 pqh_table_route tr
13406 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13407 and cpe.table_route_id = tr.table_route_id
13408 -- and tr.where_clause = l_BEN_ELIG_PCT_FL_TM_PRTE_F
13409 and tr.table_alias = l_table_alias
13410 and cpe.number_of_copies = 1 -- ADDITION
13411 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
13412 order by information1, information2; --added for bug: 5151945
13413 --
13414 --
13415 cursor c_EPF_min_max_dates(c_table_route_id number,
13416 c_information1 number) is
13417 select
13418 min(cpe.information2) min_esd,
13419 max(cpe.information3) min_eed
13420 from ben_copy_entity_results cpe
13421 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13422 and cpe.table_route_id = c_table_route_id
13423 and cpe.information1 = c_information1 ;
13424 --
13425 cursor c_EPF(c_table_route_id number,
13426 c_information1 number,
13427 c_information2 date,
13428 c_information3 date ) is
13429 select
13430 cpe.*
13431 from ben_copy_entity_results cpe
13432 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13433 and cpe.table_route_id = c_table_route_id
13434 and cpe.information1 = c_information1
13435 and cpe.information2 = c_information2
13436 and cpe.information3 = c_information3
13437 and rownum = 1 ;
13438 -- Date Track target record
13439 cursor c_find_EPF_in_target(
13440 c_effective_start_date date,
13441 c_effective_end_date date,
13442 c_business_group_id number,
13443 c_new_pk_id number) is
13444 select
13445 EPF.elig_pct_fl_tm_prte_id new_value
13446 from BEN_ELIG_PCT_FL_TM_PRTE_F EPF
13447 where
13448 EPF.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
13449 EPF.PCT_FL_TM_FCTR_ID = l_PCT_FL_TM_FCTR_ID and
13450 EPF.ORDR_NUM = l_ORDR_NUM and
13451 EPF.business_group_id = c_business_group_id
13452 and EPF.elig_pct_fl_tm_prte_id <> c_new_pk_id
13453 and c_effective_start_date between effective_start_date
13454 and effective_end_date ;
13455 --END TEMPIK
13456 /*TEMPIK
13457 and exists ( select null
13458 from BEN_ELIG_PCT_FL_TM_PRTE_F EPF1
13459 where
13460 EPF1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
13461 EPF1.PCT_FL_TM_FCTR_ID = l_PCT_FL_TM_FCTR_ID and
13462 EPF1.ORDR_NUM = l_ORDR_NUM and
13463 EPF1.business_group_id = c_business_group_id
13464 and EPF1.effective_start_date <= c_effective_start_date )
13465 and exists ( select null
13466 from BEN_ELIG_PCT_FL_TM_PRTE_F EPF2
13467 where
13468 EPF2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
13469 EPF2.PCT_FL_TM_FCTR_ID = l_PCT_FL_TM_FCTR_ID and
13470 EPF2.ORDR_NUM = l_ORDR_NUM and
13471 EPF2.business_group_id = c_business_group_id
13472 and EPF2.effective_end_date >= c_effective_end_date )
13473 ;
13474 TEMPIK */
13475 --TEMPIK
13476 l_dt_rec_found boolean ;
13477 --END TEMPIK
13478 --
13479
13480 --UPD START
13481 --
13482 l_update boolean := false ;
13483 l_datetrack_mode varchar2(80) := hr_api.g_update;
13484 l_process_date date;
13485 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
13486 --
13487 --UPD END
13488 l_current_pk_id number := null;
13489
13490 l_prev_pk_id number := null ;
13491 l_first_rec boolean := true ;
13492 r_EPF c_EPF%rowtype;
13493 l_elig_pct_fl_tm_prte_id number ;
13494 l_object_version_number number ;
13495 l_effective_start_date date ;
13496 l_effective_end_date date ;
13497 l_prefix pqh_copy_entity_attribs.information1%type := null;
13498 l_suffix pqh_copy_entity_attribs.information1%type := null;
13499 l_new_value number(15);
13500 l_object_found_in_target boolean := false ;
13501 l_min_esd date;
13502 l_max_eed date;
13503 l_effective_date date;
13504 --
13505 begin
13506 -- Initialization
13507 l_object_found_in_target := false ;
13508 -- End Initialization
13509 -- Derive the prefix - sufix
13510 if p_prefix_suffix_cd = 'PREFIX' then
13511 l_prefix := p_prefix_suffix_text ;
13512 elsif p_prefix_suffix_cd = 'SUFFIX' then
13513 l_suffix := p_prefix_suffix_text ;
13514 else
13515 l_prefix := null ;
13516 l_suffix := null ;
13517 end if ;
13518 -- End Prefix Sufix derivation
13519 for r_EPF_unique in c_unique_EPF('EPF') loop
13520
13521 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
13522 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13523 r_EPF_unique.information3 >=
13524 ben_pd_copy_to_ben_one.g_copy_effective_date)
13525 ) then
13526 --
13527 hr_utility.set_location(' r_EPF_unique.table_route_id '||r_EPF_unique.table_route_id,10);
13528 hr_utility.set_location(' r_EPF_unique.information1 '||r_EPF_unique.information1,10);
13529 hr_utility.set_location( 'r_EPF_unique.information2 '||r_EPF_unique.information2,10);
13530 hr_utility.set_location( 'r_EPF_unique.information3 '||r_EPF_unique.information3,10);
13531 -- If reuse objects flag is 'Y' then check for the object in the target business group
13532 -- if found insert the record into PLSql table and exit the loop else try create the
13533 -- object in the target business group
13534 --
13535 l_object_found_in_target := false ;
13536 --UPD START
13537 l_update := false;
13538 l_process_date := p_effective_date;
13539 l_dml_operation:= r_EPF_unique.dml_operation ;
13540 --
13541 /**********************moved from below **********************/
13542 open c_EPF(r_EPF_unique.table_route_id,
13543 r_EPF_unique.information1,
13544 r_EPF_unique.information2,
13545 r_EPF_unique.information3 ) ;
13546 --
13547 fetch c_EPF into r_EPF ;
13548 --
13549 close c_EPF ;
13550 --
13551 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPF.INFORMATION263,l_dml_operation);
13552 l_PCT_FL_TM_FCTR_ID := get_fk('PCT_FL_TM_FCTR_ID', r_EPF.INFORMATION233,l_dml_operation);
13553 l_ORDR_NUM := r_EPF.INFORMATION260;
13554 /**********************************************************/
13555
13556 if l_dml_operation = 'UPDATE' then
13557 --
13558 l_object_found_in_target := TRUE;
13559 --
13560 if l_process_date between r_EPF_unique.information2 and r_EPF_unique.information3 then
13561 l_update := true;
13562 if r_EPF_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
13563 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PCT_FL_TM_PRTE_ID' then
13564 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PCT_FL_TM_PRTE_ID' ;
13565 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPF_unique.information1 ;
13566 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EPF_unique.information1 ;
13567 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
13568 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPF_unique.table_route_id;
13569 --
13570 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
13571 --
13572 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
13573 --
13574 -- log_data('EPF',l_new_value,l_prefix || r_EPF_unique.name|| l_suffix,'REUSED');
13575 --
13576 end if ;
13577 hr_utility.set_location( 'found record for update',10);
13578 --
13579 else
13580 --
13581 l_update := false;
13582 --
13583 end if;
13584 else
13585 --
13586 --UPD END
13587 l_min_esd := null ;
13588 l_max_eed := null ;
13589 open c_EPF_min_max_dates(r_EPF_unique.table_route_id, r_EPF_unique.information1 ) ;
13590 fetch c_EPF_min_max_dates into l_min_esd,l_max_eed ;
13591 --
13592
13593 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13594 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
13595 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
13596 end if;
13597
13598 l_min_esd := greatest(l_min_esd,r_EPF_unique.information2);
13599 /**********************moved up from here **********************
13600 open c_EPF(r_EPF_unique.table_route_id,
13601 r_EPF_unique.information1,
13602 r_EPF_unique.information2,
13603 r_EPF_unique.information3 ) ;
13604 --
13605 fetch c_EPF into r_EPF ;
13606 --
13607 close c_EPF ;
13608 --
13609 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPF.INFORMATION263,l_dml_operation);
13610 l_PCT_FL_TM_FCTR_ID := get_fk('PCT_FL_TM_FCTR_ID', r_EPF.INFORMATION233,l_dml_operation);
13611 l_ORDR_NUM := r_EPF.INFORMATION260;
13612 **********************************************************/
13613
13614 --
13615 if p_reuse_object_flag = 'Y' then
13616 if c_EPF_min_max_dates%found then
13617 -- cursor to find the object
13618 open c_find_EPF_in_target( l_min_esd,l_max_eed,
13619 p_target_business_group_id, nvl(l_elig_pct_fl_tm_prte_id, -999) ) ;
13620 fetch c_find_EPF_in_target into l_new_value ;
13621 if c_find_EPF_in_target%found then
13622 --
13623 --TEMPIK
13624 l_dt_rec_found := dt_api.check_min_max_dates
13625 (p_base_table_name => 'BEN_ELIG_PCT_FL_TM_PRTE_F',
13626 p_base_key_column => 'ELIG_PCT_FL_TM_PRTE_ID',
13627 p_base_key_value => l_new_value,
13628 p_from_date => l_min_esd,
13629 p_to_date => l_max_eed );
13630 if l_dt_rec_found THEN
13631 --END TEMPIK
13632 if r_EPF_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
13633 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PCT_FL_TM_PRTE_ID' then
13634 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PCT_FL_TM_PRTE_ID' ;
13635 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPF_unique.information1 ;
13636 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
13637 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
13638 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPF_unique.table_route_id;
13639 --
13640 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
13641 --
13642 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
13643 end if ;
13644 --
13645 l_object_found_in_target := true ;
13646 --TEMPIK
13647 end if; -- l_dt_rec_found
13648 --END TEMPIK
13649 end if;
13650 close c_find_EPF_in_target ;
13651 --
13652 end if;
13653 end if ;
13654 --
13655 close c_EPF_min_max_dates ;
13656 end if; --if p_dml_operation
13657 --
13658 if not l_object_found_in_target OR l_update then
13659
13660 --
13661 l_current_pk_id := r_EPF.information1;
13662 --
13663 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
13664 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
13665 --
13666 if l_current_pk_id = l_prev_pk_id then
13667 --
13668 l_first_rec := false ;
13669 --
13670 else
13671 --
13672 l_first_rec := true ;
13673 --
13674 end if ;
13675 --
13676
13677 l_effective_date := r_EPF.information2;
13678 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13679 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
13680 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
13681 end if;
13682
13683 if l_first_rec and not l_update then
13684 -- Call Create routine.
13685 hr_utility.set_location(' BEN_ELIG_PCT_FL_TM_PRTE_F CREATE_ELIG_PCT_FL_TM_PRTE ',20);
13686 BEN_ELIG_PCT_FL_TM_PRTE_API.CREATE_ELIG_PCT_FL_TM_PRTE(
13687 --
13688 P_VALIDATE => false
13689 ,P_EFFECTIVE_DATE => l_effective_date
13690 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
13691 --
13692 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
13693 ,P_ELIG_PCT_FL_TM_PRTE_ID => l_elig_pct_fl_tm_prte_id
13694 ,P_EPF_ATTRIBUTE1 => r_EPF.INFORMATION111
13695 ,P_EPF_ATTRIBUTE10 => r_EPF.INFORMATION120
13696 ,P_EPF_ATTRIBUTE11 => r_EPF.INFORMATION121
13697 ,P_EPF_ATTRIBUTE12 => r_EPF.INFORMATION122
13698 ,P_EPF_ATTRIBUTE13 => r_EPF.INFORMATION123
13699 ,P_EPF_ATTRIBUTE14 => r_EPF.INFORMATION124
13700 ,P_EPF_ATTRIBUTE15 => r_EPF.INFORMATION125
13701 ,P_EPF_ATTRIBUTE16 => r_EPF.INFORMATION126
13702 ,P_EPF_ATTRIBUTE17 => r_EPF.INFORMATION127
13703 ,P_EPF_ATTRIBUTE18 => r_EPF.INFORMATION128
13704 ,P_EPF_ATTRIBUTE19 => r_EPF.INFORMATION129
13705 ,P_EPF_ATTRIBUTE2 => r_EPF.INFORMATION112
13706 ,P_EPF_ATTRIBUTE20 => r_EPF.INFORMATION130
13707 ,P_EPF_ATTRIBUTE21 => r_EPF.INFORMATION131
13708 ,P_EPF_ATTRIBUTE22 => r_EPF.INFORMATION132
13709 ,P_EPF_ATTRIBUTE23 => r_EPF.INFORMATION133
13710 ,P_EPF_ATTRIBUTE24 => r_EPF.INFORMATION134
13711 ,P_EPF_ATTRIBUTE25 => r_EPF.INFORMATION135
13712 ,P_EPF_ATTRIBUTE26 => r_EPF.INFORMATION136
13713 ,P_EPF_ATTRIBUTE27 => r_EPF.INFORMATION137
13714 ,P_EPF_ATTRIBUTE28 => r_EPF.INFORMATION138
13715 ,P_EPF_ATTRIBUTE29 => r_EPF.INFORMATION139
13716 ,P_EPF_ATTRIBUTE3 => r_EPF.INFORMATION113
13717 ,P_EPF_ATTRIBUTE30 => r_EPF.INFORMATION140
13718 ,P_EPF_ATTRIBUTE4 => r_EPF.INFORMATION114
13719 ,P_EPF_ATTRIBUTE5 => r_EPF.INFORMATION115
13720 ,P_EPF_ATTRIBUTE6 => r_EPF.INFORMATION116
13721 ,P_EPF_ATTRIBUTE7 => r_EPF.INFORMATION117
13722 ,P_EPF_ATTRIBUTE8 => r_EPF.INFORMATION118
13723 ,P_EPF_ATTRIBUTE9 => r_EPF.INFORMATION119
13724 ,P_EPF_ATTRIBUTE_CATEGORY => r_EPF.INFORMATION110
13725 ,P_EXCLD_FLAG => r_EPF.INFORMATION11
13726 ,P_ORDR_NUM => r_EPF.INFORMATION260
13727 ,P_PCT_FL_TM_FCTR_ID => l_PCT_FL_TM_FCTR_ID
13728 --
13729 -- ****** END CHANGE LINES
13730
13731 --
13732
13733 ,P_EFFECTIVE_START_DATE => l_effective_start_date
13734 ,P_EFFECTIVE_END_DATE => l_effective_end_date
13735 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
13736 ,P_CRITERIA_SCORE => r_epf.INFORMATION295
13737 ,P_CRITERIA_WEIGHT => r_epf.INFORMATION296
13738 );
13739 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
13740 -- Update all relevent cer records with new pk_id
13741 hr_utility.set_location('Before plsql table ',222);
13742 hr_utility.set_location('new_value id '||l_elig_pct_fl_tm_prte_id,222);
13743 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PCT_FL_TM_PRTE_ID' ;
13744 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPF.information1 ;
13745 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_PCT_FL_TM_PRTE_ID ;
13746 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
13747 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPF_unique.table_route_id;
13748 hr_utility.set_location('After plsql table ',222);
13749 --
13750 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
13751 --
13752 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
13753 --
13754 else
13755 --
13756 -- Call Update routine for the pk_id created in prev run .
13757 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
13758 hr_utility.set_location(' BEN_ELIG_PCT_FL_TM_PRTE_F UPDATE_ELIG_PCT_FL_TM_PRTE ',30);
13759 --UPD START
13760 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
13761 --
13762 if l_update then
13763 --
13764 l_datetrack_mode := r_EPF.datetrack_mode ;
13765 --
13766 get_dt_modes(
13767 p_effective_date => l_process_date,
13768 p_effective_end_date => r_EPF.information3,
13769 p_effective_start_date => r_EPF.information2,
13770 p_dml_operation => r_EPF.dml_operation,
13771 p_datetrack_mode => l_datetrack_mode );
13772 -- p_update => l_update
13773 --
13774 l_effective_date := l_process_date;
13775 l_ELIG_PCT_FL_TM_PRTE_ID := r_EPF.information1;
13776 l_object_version_number := r_EPF.information265;
13777 --
13778 end if;
13779 --
13780 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
13781 --
13782 IF l_update OR l_dml_operation <> 'UPDATE' THEN
13783 --UPD END
13784
13785
13786 BEN_ELIG_PCT_FL_TM_PRTE_API.UPDATE_ELIG_PCT_FL_TM_PRTE(
13787 --
13788 P_VALIDATE => false
13789 ,P_EFFECTIVE_DATE => l_effective_date
13790 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
13791 --
13792 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
13793 ,P_ELIG_PCT_FL_TM_PRTE_ID => l_elig_pct_fl_tm_prte_id
13794 ,P_EPF_ATTRIBUTE1 => r_EPF.INFORMATION111
13795 ,P_EPF_ATTRIBUTE10 => r_EPF.INFORMATION120
13796 ,P_EPF_ATTRIBUTE11 => r_EPF.INFORMATION121
13797 ,P_EPF_ATTRIBUTE12 => r_EPF.INFORMATION122
13798 ,P_EPF_ATTRIBUTE13 => r_EPF.INFORMATION123
13799 ,P_EPF_ATTRIBUTE14 => r_EPF.INFORMATION124
13800 ,P_EPF_ATTRIBUTE15 => r_EPF.INFORMATION125
13801 ,P_EPF_ATTRIBUTE16 => r_EPF.INFORMATION126
13802 ,P_EPF_ATTRIBUTE17 => r_EPF.INFORMATION127
13803 ,P_EPF_ATTRIBUTE18 => r_EPF.INFORMATION128
13804 ,P_EPF_ATTRIBUTE19 => r_EPF.INFORMATION129
13805 ,P_EPF_ATTRIBUTE2 => r_EPF.INFORMATION112
13806 ,P_EPF_ATTRIBUTE20 => r_EPF.INFORMATION130
13807 ,P_EPF_ATTRIBUTE21 => r_EPF.INFORMATION131
13808 ,P_EPF_ATTRIBUTE22 => r_EPF.INFORMATION132
13809 ,P_EPF_ATTRIBUTE23 => r_EPF.INFORMATION133
13810 ,P_EPF_ATTRIBUTE24 => r_EPF.INFORMATION134
13811 ,P_EPF_ATTRIBUTE25 => r_EPF.INFORMATION135
13812 ,P_EPF_ATTRIBUTE26 => r_EPF.INFORMATION136
13813 ,P_EPF_ATTRIBUTE27 => r_EPF.INFORMATION137
13814 ,P_EPF_ATTRIBUTE28 => r_EPF.INFORMATION138
13815 ,P_EPF_ATTRIBUTE29 => r_EPF.INFORMATION139
13816 ,P_EPF_ATTRIBUTE3 => r_EPF.INFORMATION113
13817 ,P_EPF_ATTRIBUTE30 => r_EPF.INFORMATION140
13818 ,P_EPF_ATTRIBUTE4 => r_EPF.INFORMATION114
13819 ,P_EPF_ATTRIBUTE5 => r_EPF.INFORMATION115
13820 ,P_EPF_ATTRIBUTE6 => r_EPF.INFORMATION116
13821 ,P_EPF_ATTRIBUTE7 => r_EPF.INFORMATION117
13822 ,P_EPF_ATTRIBUTE8 => r_EPF.INFORMATION118
13823 ,P_EPF_ATTRIBUTE9 => r_EPF.INFORMATION119
13824 ,P_EPF_ATTRIBUTE_CATEGORY => r_EPF.INFORMATION110
13825 ,P_EXCLD_FLAG => r_EPF.INFORMATION11
13826 ,P_ORDR_NUM => r_EPF.INFORMATION260
13827 ,P_PCT_FL_TM_FCTR_ID => l_PCT_FL_TM_FCTR_ID
13828 --
13829 -- ****** END CHANGE LINES
13830
13831 --
13832 ,P_EFFECTIVE_START_DATE => l_effective_start_date
13833 ,P_EFFECTIVE_END_DATE => l_effective_end_date
13834 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
13835 ,P_DATETRACK_MODE => l_datetrack_mode
13836 ,P_CRITERIA_SCORE => r_epf.INFORMATION29
13837 ,P_CRITERIA_WEIGHT => r_epf.INFORMATION296
13838 );
13839 end if; -- l_update
13840 --
13841 end if;
13842 --
13843 -- Delete the row if it is end dated.
13844 --
13845 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
13846 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
13847 trunc(l_max_eed) = trunc(r_EPF.information3)) then
13848 --
13849 BEN_ELIG_PCT_FL_TM_PRTE_API.delete_ELIG_PCT_FL_TM_PRTE(
13850 --
13851 p_validate => false
13852 ,p_elig_pct_fl_tm_prte_id => l_elig_pct_fl_tm_prte_id
13853 ,p_effective_start_date => l_effective_start_date
13854 ,p_effective_end_date => l_effective_end_date
13855 ,p_object_version_number => l_object_version_number
13856 ,p_effective_date => l_max_eed
13857 ,p_datetrack_mode => hr_api.g_delete
13858 --
13859 );
13860 --
13861 end if;
13862 --
13863 l_prev_pk_id := l_current_pk_id ;
13864 --
13865 end if;
13866 --
13867 end if;
13868 --
13869 end loop;
13870 --
13871 exception when others then
13872 --
13873 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EPF',r_EPF.information5 ) ;
13874 --
13875 end create_EPF_rows;
13876
13877 --
13878 ---------------------------------------------------------------
13879 ----------------------< create_EPT_rows >-----------------------
13880 ---------------------------------------------------------------
13881 --
13882 procedure create_EPT_rows
13883 (
13884 p_validate in number default 0
13885 ,p_copy_entity_txn_id in number
13886 ,p_effective_date in date
13887 ,p_prefix_suffix_text in varchar2 default null
13888 ,p_reuse_object_flag in varchar2 default null
13889 ,p_target_business_group_id in varchar2 default null
13890 ,p_prefix_suffix_cd in varchar2 default null
13891 ) is
13892 --
13893 l_ELIGY_PRFL_ID number;
13894 l_PERSON_TYPE_ID number;
13895 l_ORDR_NUM number;
13896 cursor c_unique_EPT(l_table_alias varchar2) is
13897 select distinct cpe.information1,
13898 cpe.information2,
13899 cpe.information3,
13900 cpe.table_route_id
13901 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
13902 pqh_table_route tr
13903 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13904 and cpe.table_route_id = tr.table_route_id
13905 -- and tr.where_clause = l_BEN_ELIG_PER_TYP_PRTE_F
13906 and tr.table_alias = l_table_alias
13907 and cpe.number_of_copies = 1 -- ADDITION
13908 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
13909 order by information1, information2; --added for bug: 5151945
13910 --
13911 --
13912 cursor c_EPT_min_max_dates(c_table_route_id number,
13913 c_information1 number) is
13914 select
13915 min(cpe.information2) min_esd,
13916 max(cpe.information3) min_eed
13917 from ben_copy_entity_results cpe
13918 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13919 and cpe.table_route_id = c_table_route_id
13920 and cpe.information1 = c_information1 ;
13921 --
13922 cursor c_EPT(c_table_route_id number,
13923 c_information1 number,
13924 c_information2 date,
13925 c_information3 date ) is
13926 select
13927 cpe.*
13928 from ben_copy_entity_results cpe
13929 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13930 and cpe.table_route_id = c_table_route_id
13931 and cpe.information1 = c_information1
13932 and cpe.information2 = c_information2
13933 and cpe.information3 = c_information3
13934 and rownum = 1 ;
13935 -- Date Track target record
13936 cursor c_find_EPT_in_target(
13937 c_effective_start_date date,
13938 c_effective_end_date date,
13939 c_business_group_id number,
13940 c_new_pk_id number) is
13941 select
13942 EPT.elig_per_typ_prte_id new_value
13943 from BEN_ELIG_PER_TYP_PRTE_F EPT
13944 where
13945 EPT.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
13946 EPT.PERSON_TYPE_ID = l_PERSON_TYPE_ID and
13947 EPT.ordr_num = l_ORDR_NUM and
13948 EPT.business_group_id = c_business_group_id
13949 and EPT.elig_per_typ_prte_id <> c_new_pk_id
13950 and c_effective_start_date between effective_start_date
13951 and effective_end_date ;
13952 --END TEMPIK
13953 /*TEMPIK
13954 and exists ( select null
13955 from BEN_ELIG_PER_TYP_PRTE_F EPT1
13956 where
13957 EPT1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
13958 EPT1.PERSON_TYPE_ID = l_PERSON_TYPE_ID and
13959 EPT1.ordr_num = l_ORDR_NUM and -- Added this criteria
13960 EPT1.business_group_id = c_business_group_id
13961 and EPT1.effective_start_date <= c_effective_start_date )
13962 and exists ( select null
13963 from BEN_ELIG_PER_TYP_PRTE_F EPT2
13964 where
13965 EPT2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
13966 EPT2.PERSON_TYPE_ID = l_PERSON_TYPE_ID and
13967 EPT2.ordr_num = l_ORDR_NUM and -- Added this criteria
13968 EPT2.business_group_id = c_business_group_id
13969 and EPT2.effective_end_date >= c_effective_end_date )
13970 ;
13971 TEMPIK */
13972 --TEMPIK
13973 l_dt_rec_found boolean ;
13974 --END TEMPIK
13975 --
13976
13977 --UPD START
13978 --
13979 l_update boolean := false ;
13980 l_datetrack_mode varchar2(80) := hr_api.g_update;
13981 l_process_date date;
13982 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
13983 --
13984 --UPD END
13985 l_current_pk_id number := null ;
13986
13987 l_prev_pk_id number := null ;
13988 l_first_rec boolean := true ;
13989 r_EPT c_EPT%rowtype;
13990 l_elig_per_typ_prte_id number ;
13991 l_object_version_number number ;
13992 l_effective_start_date date ;
13993 l_effective_end_date date ;
13994 l_prefix pqh_copy_entity_attribs.information1%type := null;
13995 l_suffix pqh_copy_entity_attribs.information1%type := null;
13996 l_new_value number(15);
13997 l_object_found_in_target boolean := false ;
13998 l_min_esd date;
13999 l_max_eed date;
14000 l_effective_date date;
14001 --
14002 begin
14003 -- Initialization
14004 l_object_found_in_target := false ;
14005 -- End Initialization
14006 -- Derive the prefix - sufix
14007 if p_prefix_suffix_cd = 'PREFIX' then
14008 l_prefix := p_prefix_suffix_text ;
14009 elsif p_prefix_suffix_cd = 'SUFFIX' then
14010 l_suffix := p_prefix_suffix_text ;
14011 else
14012 l_prefix := null ;
14013 l_suffix := null ;
14014 end if ;
14015 -- End Prefix Sufix derivation
14016 for r_EPT_unique in c_unique_EPT('EPT') loop
14017
14018 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
14019 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14020 r_EPT_unique.information3 >=
14021 ben_pd_copy_to_ben_one.g_copy_effective_date)
14022 ) then
14023 --
14024 hr_utility.set_location(' r_EPT_unique.table_route_id '||r_EPT_unique.table_route_id,10);
14025 hr_utility.set_location(' r_EPT_unique.information1 '||r_EPT_unique.information1,10);
14026 hr_utility.set_location( 'r_EPT_unique.information2 '||r_EPT_unique.information2,10);
14027 hr_utility.set_location( 'r_EPT_unique.information3 '||r_EPT_unique.information3,10);
14028 -- If reuse objects flag is 'Y' then check for the object in the target business group
14029 -- if found insert the record into PLSql table and exit the loop else try create the
14030 -- object in the target business group
14031 --
14032 l_object_found_in_target := false ;
14033 --UPD START
14034 l_update := false;
14035 l_process_date := p_effective_date;
14036 l_dml_operation:= r_EPT_unique.dml_operation ;
14037 --
14038
14039 /**********************moved from below **********************/
14040 open c_EPT(r_EPT_unique.table_route_id,
14041 r_EPT_unique.information1,
14042 r_EPT_unique.information2,
14043 r_EPT_unique.information3 ) ;
14044 --
14045 fetch c_EPT into r_EPT ;
14046 --
14047 close c_EPT ;
14048 --
14049 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPT.INFORMATION263,l_dml_operation);
14050
14051 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
14052 l_PERSON_TYPE_ID := r_EPT.information176;
14053 else
14054 l_PERSON_TYPE_ID := r_EPT.information174;
14055 end if;
14056
14057 l_ORDR_NUM := r_EPT.information260; -- Added this criteria
14058
14059 /**********************************************************/
14060 if l_dml_operation = 'UPDATE' then
14061 --
14062 l_object_found_in_target := TRUE;
14063 --
14064 if l_process_date between r_EPT_unique.information2 and r_EPT_unique.information3 then
14065 l_update := true;
14066 if r_EPT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
14067 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PER_TYP_PRTE_ID' then
14068 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PER_TYP_PRTE_ID' ;
14069 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPT_unique.information1 ;
14070 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EPT_unique.information1 ;
14071 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
14072 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPT_unique.table_route_id;
14073 --
14074 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
14075 --
14076 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
14077 --
14078 -- log_data('EPT',l_new_value,l_prefix || r_EPT_unique.name|| l_suffix,'REUSED');
14079 --
14080 end if ;
14081 hr_utility.set_location( 'found record for update',10);
14082 --
14083 else
14084 --
14085 l_update := false;
14086 --
14087 end if;
14088 else
14089 --
14090 --UPD END
14091 l_min_esd := null ;
14092 l_max_eed := null ;
14093 open c_EPT_min_max_dates(r_EPT_unique.table_route_id, r_EPT_unique.information1 ) ;
14094 fetch c_EPT_min_max_dates into l_min_esd,l_max_eed ;
14095 --
14096
14097 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14098 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
14099 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
14100 end if;
14101 l_min_esd := greatest(l_min_esd,r_EPT_unique.information2);
14102 /**********************moved up from here **********************
14103 open c_EPT(r_EPT_unique.table_route_id,
14104 r_EPT_unique.information1,
14105 r_EPT_unique.information2,
14106 r_EPT_unique.information3 ) ;
14107 --
14108 fetch c_EPT into r_EPT ;
14109 --
14110 close c_EPT ;
14111 --
14112 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPT.INFORMATION263,l_dml_operation);
14113
14114 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
14115 l_PERSON_TYPE_ID := r_EPT.information176;
14116 else
14117 l_PERSON_TYPE_ID := r_EPT.information174;
14118 end if;
14119
14120 l_ORDR_NUM := r_EPT.information260; -- Added this criteria
14121
14122 **********************************************************/
14123
14124
14125 if l_PERSON_TYPE_ID is null then
14126 close c_EPT_min_max_dates;
14127 --
14128 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
14129 ,p_parent_pk_id => r_EPT.information263
14130 ,p_copy_entity_txn_id => p_copy_entity_txn_id
14131 ,p_child_table_alias => 'EPT'
14132 ,p_child_data => r_EPT.information173 );
14133
14134 --
14135 else
14136 if p_reuse_object_flag = 'Y' then
14137 if c_EPT_min_max_dates%found then
14138 -- cursor to find the object
14139 open c_find_EPT_in_target( l_min_esd,l_max_eed,
14140 p_target_business_group_id, nvl(l_elig_per_typ_prte_id, -999) ) ;
14141 fetch c_find_EPT_in_target into l_new_value ;
14142 if c_find_EPT_in_target%found then
14143 --
14144 --TEMPIK
14145 l_dt_rec_found := dt_api.check_min_max_dates
14146 (p_base_table_name => 'BEN_ELIG_PER_TYP_PRTE_F',
14147 p_base_key_column => 'ELIG_PER_TYP_PRTE_ID',
14148 p_base_key_value => l_new_value,
14149 p_from_date => l_min_esd,
14150 p_to_date => l_max_eed );
14151 if l_dt_rec_found THEN
14152 --END TEMPIK
14153 if r_EPT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
14154 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PER_TYP_PRTE_ID' then
14155 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PER_TYP_PRTE_ID' ;
14156 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPT_unique.information1 ;
14157 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
14158 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
14159 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPT_unique.table_route_id;
14160 --
14161 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
14162 --
14163 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
14164 end if ;
14165 --
14166 l_object_found_in_target := true ;
14167 --TEMPIK
14168 end if; -- l_dt_rec_found
14169 --END TEMPIK
14170 end if;
14171 close c_find_EPT_in_target ;
14172 --
14173 end if;
14174 end if ;
14175 --
14176 close c_EPT_min_max_dates ;
14177 end if; -- bug 4565106
14178 end if; --if p_dml_operation
14179 --
14180 if not l_object_found_in_target OR l_update then
14181
14182 --
14183 l_current_pk_id := r_EPT.information1;
14184 --
14185 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
14186 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
14187 --
14188 if l_current_pk_id = l_prev_pk_id then
14189 --
14190 l_first_rec := false ;
14191 --
14192 else
14193 --
14194 l_first_rec := true ;
14195 --
14196 end if ;
14197 --
14198
14199 l_effective_date := r_EPT.information2;
14200 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14201 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
14202 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
14203 end if;
14204
14205 if l_first_rec and not l_update then
14206 -- Call Create routine.
14207 hr_utility.set_location(' BEN_ELIG_PER_TYP_PRTE_F CREATE_ELIG_PER_TYP_PRTE ',20);
14208 BEN_ELIG_PER_TYP_PRTE_API.CREATE_ELIG_PER_TYP_PRTE(
14209 --
14210 P_VALIDATE => false
14211 ,P_EFFECTIVE_DATE => l_effective_date
14212 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
14213 --
14214 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
14215 ,P_ELIG_PER_TYP_PRTE_ID => l_elig_per_typ_prte_id
14216 ,P_EPT_ATTRIBUTE1 => r_EPT.INFORMATION111
14217 ,P_EPT_ATTRIBUTE10 => r_EPT.INFORMATION120
14218 ,P_EPT_ATTRIBUTE11 => r_EPT.INFORMATION121
14219 ,P_EPT_ATTRIBUTE12 => r_EPT.INFORMATION122
14220 ,P_EPT_ATTRIBUTE13 => r_EPT.INFORMATION123
14221 ,P_EPT_ATTRIBUTE14 => r_EPT.INFORMATION124
14222 ,P_EPT_ATTRIBUTE15 => r_EPT.INFORMATION125
14223 ,P_EPT_ATTRIBUTE16 => r_EPT.INFORMATION126
14224 ,P_EPT_ATTRIBUTE17 => r_EPT.INFORMATION127
14225 ,P_EPT_ATTRIBUTE18 => r_EPT.INFORMATION128
14226 ,P_EPT_ATTRIBUTE19 => r_EPT.INFORMATION129
14227 ,P_EPT_ATTRIBUTE2 => r_EPT.INFORMATION112
14228 ,P_EPT_ATTRIBUTE20 => r_EPT.INFORMATION130
14229 ,P_EPT_ATTRIBUTE21 => r_EPT.INFORMATION131
14230 ,P_EPT_ATTRIBUTE22 => r_EPT.INFORMATION132
14231 ,P_EPT_ATTRIBUTE23 => r_EPT.INFORMATION133
14232 ,P_EPT_ATTRIBUTE24 => r_EPT.INFORMATION134
14233 ,P_EPT_ATTRIBUTE25 => r_EPT.INFORMATION135
14234 ,P_EPT_ATTRIBUTE26 => r_EPT.INFORMATION136
14235 ,P_EPT_ATTRIBUTE27 => r_EPT.INFORMATION137
14236 ,P_EPT_ATTRIBUTE28 => r_EPT.INFORMATION138
14237 ,P_EPT_ATTRIBUTE29 => r_EPT.INFORMATION139
14238 ,P_EPT_ATTRIBUTE3 => r_EPT.INFORMATION113
14239 ,P_EPT_ATTRIBUTE30 => r_EPT.INFORMATION140
14240 ,P_EPT_ATTRIBUTE4 => r_EPT.INFORMATION114
14241 ,P_EPT_ATTRIBUTE5 => r_EPT.INFORMATION115
14242 ,P_EPT_ATTRIBUTE6 => r_EPT.INFORMATION116
14243 ,P_EPT_ATTRIBUTE7 => r_EPT.INFORMATION117
14244 ,P_EPT_ATTRIBUTE8 => r_EPT.INFORMATION118
14245 ,P_EPT_ATTRIBUTE9 => r_EPT.INFORMATION119
14246 ,P_EPT_ATTRIBUTE_CATEGORY => r_EPT.INFORMATION110
14247 ,P_EXCLD_FLAG => r_EPT.INFORMATION11
14248 ,P_ORDR_NUM => r_EPT.INFORMATION260
14249 ,P_PERSON_TYPE_ID => l_PERSON_TYPE_ID
14250 ,P_PER_TYP_CD => r_EPT.INFORMATION12
14251 --
14252 -- ****** END CHANGE LINES
14253
14254 --
14255
14256 ,P_EFFECTIVE_START_DATE => l_effective_start_date
14257 ,P_EFFECTIVE_END_DATE => l_effective_end_date
14258 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
14259 ,P_CRITERIA_SCORE => r_ept.INFORMATION295
14260 ,P_CRITERIA_WEIGHT => r_ept.INFORMATION296
14261 );
14262 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
14263 -- Update all relevent cer records with new pk_id
14264 hr_utility.set_location('Before plsql table ',222);
14265 hr_utility.set_location('new_value id '||l_elig_per_typ_prte_id,222);
14266 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PER_TYP_PRTE_ID' ;
14267 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPT.information1 ;
14268 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_PER_TYP_PRTE_ID ;
14269 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
14270 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPT_unique.table_route_id;
14271 hr_utility.set_location('After plsql table ',222);
14272 --
14273 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
14274 --
14275 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
14276 --
14277 else
14278 --
14279 -- Call Update routine for the pk_id created in prev run .
14280 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
14281 hr_utility.set_location(' BEN_ELIG_PER_TYP_PRTE_F UPDATE_ELIG_PER_TYP_PRTE ',30);
14282 --UPD START
14283 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
14284 --
14285 if l_update then
14286 --
14287 l_datetrack_mode := r_EPT.datetrack_mode ;
14288 --
14289 get_dt_modes(
14290 p_effective_date => l_process_date,
14291 p_effective_end_date => r_EPT.information3,
14292 p_effective_start_date => r_EPT.information2,
14293 p_dml_operation => r_EPT.dml_operation,
14294 p_datetrack_mode => l_datetrack_mode );
14295 -- p_update => l_update
14296 --
14297 l_effective_date := l_process_date;
14298 l_ELIG_PER_TYP_PRTE_ID := r_EPT.information1;
14299 l_object_version_number := r_EPT.information265;
14300 --
14301 end if;
14302 --
14303 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
14304 --
14305 IF l_update OR l_dml_operation <> 'UPDATE' THEN
14306 --UPD END
14307
14308
14309 BEN_ELIG_PER_TYP_PRTE_API.UPDATE_ELIG_PER_TYP_PRTE(
14310 --
14311 P_VALIDATE => false
14312 ,P_EFFECTIVE_DATE => l_effective_date
14313 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
14314 --
14315 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
14316 ,P_ELIG_PER_TYP_PRTE_ID => l_elig_per_typ_prte_id
14317 ,P_EPT_ATTRIBUTE1 => r_EPT.INFORMATION111
14318 ,P_EPT_ATTRIBUTE10 => r_EPT.INFORMATION120
14319 ,P_EPT_ATTRIBUTE11 => r_EPT.INFORMATION121
14320 ,P_EPT_ATTRIBUTE12 => r_EPT.INFORMATION122
14321 ,P_EPT_ATTRIBUTE13 => r_EPT.INFORMATION123
14322 ,P_EPT_ATTRIBUTE14 => r_EPT.INFORMATION124
14323 ,P_EPT_ATTRIBUTE15 => r_EPT.INFORMATION125
14324 ,P_EPT_ATTRIBUTE16 => r_EPT.INFORMATION126
14325 ,P_EPT_ATTRIBUTE17 => r_EPT.INFORMATION127
14326 ,P_EPT_ATTRIBUTE18 => r_EPT.INFORMATION128
14327 ,P_EPT_ATTRIBUTE19 => r_EPT.INFORMATION129
14328 ,P_EPT_ATTRIBUTE2 => r_EPT.INFORMATION112
14329 ,P_EPT_ATTRIBUTE20 => r_EPT.INFORMATION130
14330 ,P_EPT_ATTRIBUTE21 => r_EPT.INFORMATION131
14331 ,P_EPT_ATTRIBUTE22 => r_EPT.INFORMATION132
14332 ,P_EPT_ATTRIBUTE23 => r_EPT.INFORMATION133
14333 ,P_EPT_ATTRIBUTE24 => r_EPT.INFORMATION134
14334 ,P_EPT_ATTRIBUTE25 => r_EPT.INFORMATION135
14335 ,P_EPT_ATTRIBUTE26 => r_EPT.INFORMATION136
14336 ,P_EPT_ATTRIBUTE27 => r_EPT.INFORMATION137
14337 ,P_EPT_ATTRIBUTE28 => r_EPT.INFORMATION138
14338 ,P_EPT_ATTRIBUTE29 => r_EPT.INFORMATION139
14339 ,P_EPT_ATTRIBUTE3 => r_EPT.INFORMATION113
14340 ,P_EPT_ATTRIBUTE30 => r_EPT.INFORMATION140
14341 ,P_EPT_ATTRIBUTE4 => r_EPT.INFORMATION114
14342 ,P_EPT_ATTRIBUTE5 => r_EPT.INFORMATION115
14343 ,P_EPT_ATTRIBUTE6 => r_EPT.INFORMATION116
14344 ,P_EPT_ATTRIBUTE7 => r_EPT.INFORMATION117
14345 ,P_EPT_ATTRIBUTE8 => r_EPT.INFORMATION118
14346 ,P_EPT_ATTRIBUTE9 => r_EPT.INFORMATION119
14347 ,P_EPT_ATTRIBUTE_CATEGORY => r_EPT.INFORMATION110
14348 ,P_EXCLD_FLAG => r_EPT.INFORMATION11
14349 ,P_ORDR_NUM => r_EPT.INFORMATION260
14350 ,P_PERSON_TYPE_ID => l_PERSON_TYPE_ID
14351 ,P_PER_TYP_CD => r_EPT.INFORMATION12
14352 --
14353 -- ****** END CHANGE LINES
14354
14355 --
14356 ,P_EFFECTIVE_START_DATE => l_effective_start_date
14357 ,P_EFFECTIVE_END_DATE => l_effective_end_date
14358 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
14359 ,P_DATETRACK_MODE => l_datetrack_mode
14360 ,P_CRITERIA_SCORE => r_ept.INFORMATION295
14361 ,P_CRITERIA_WEIGHT => r_ept.INFORMATION296
14362 );
14363 end if; -- l_update
14364 --
14365 end if;
14366 --
14367 -- Delete the row if it is end dated.
14368 --
14369 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
14370 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
14371 trunc(l_max_eed) = trunc(r_EPT.information3)) then
14372 --
14373 BEN_ELIG_PER_TYP_PRTE_API.delete_ELIG_PER_TYP_PRTE(
14374 --
14375 p_validate => false
14376 ,p_elig_per_typ_prte_id => l_elig_per_typ_prte_id
14377 ,p_effective_start_date => l_effective_start_date
14378 ,p_effective_end_date => l_effective_end_date
14379 ,p_object_version_number => l_object_version_number
14380 ,p_effective_date => l_max_eed
14381 ,p_datetrack_mode => hr_api.g_delete
14382 --
14383 );
14384 --
14385 end if;
14386 --
14387 l_prev_pk_id := l_current_pk_id ;
14388 --
14389 -- end if; -- bug 4565106
14390 --
14391 end if;
14392 --
14393 end if;
14394 --
14395 end loop;
14396 --
14397 exception when others then
14398 --
14399 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EPT',r_EPT.information5 ) ;
14400 --
14401 end create_EPT_rows;
14402
14403
14404 --
14405 ---------------------------------------------------------------
14406 ----------------------< create_EPG_rows >-----------------------
14407 ---------------------------------------------------------------
14408 --
14409 procedure create_EPG_rows
14410 (
14411 p_validate in number default 0
14412 ,p_copy_entity_txn_id in number
14413 ,p_effective_date in date
14414 ,p_prefix_suffix_text in varchar2 default null
14415 ,p_reuse_object_flag in varchar2 default null
14416 ,p_target_business_group_id in varchar2 default null
14417 ,p_prefix_suffix_cd in varchar2 default null
14418 ) is
14419 --
14420 l_ELIGY_PRFL_ID number;
14421 l_PEOPLE_GROUP_ID number;
14422 l_ORDR_NUM number;
14423 cursor c_unique_EPG(l_table_alias varchar2) is
14424 select distinct cpe.information1,
14425 cpe.information2,
14426 cpe.information3,
14427 cpe.table_route_id
14428 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
14429 pqh_table_route tr
14430 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14431 and cpe.table_route_id = tr.table_route_id
14432 -- and tr.where_clause = l_BEN_ELIG_PPL_GRP_PRTE_F
14433 and tr.table_alias = l_table_alias
14434 and cpe.number_of_copies = 1 -- ADDITION
14435 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
14436 order by information1, information2; --added for bug: 5151945
14437 --
14438 --
14439 cursor c_EPG_min_max_dates(c_table_route_id number,
14440 c_information1 number) is
14441 select
14442 min(cpe.information2) min_esd,
14443 max(cpe.information3) min_eed
14444 from ben_copy_entity_results cpe
14445 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14446 and cpe.table_route_id = c_table_route_id
14447 and cpe.information1 = c_information1 ;
14448 --
14449 cursor c_EPG(c_table_route_id number,
14450 c_information1 number,
14451 c_information2 date,
14452 c_information3 date ) is
14453 select
14454 cpe.*
14455 from ben_copy_entity_results cpe
14456 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14457 and cpe.table_route_id = c_table_route_id
14458 and cpe.information1 = c_information1
14459 and cpe.information2 = c_information2
14460 and cpe.information3 = c_information3
14461 and rownum = 1 ;
14462 -- Date Track target record
14463 cursor c_find_EPG_in_target(
14464 c_effective_start_date date,
14465 c_effective_end_date date,
14466 c_business_group_id number,
14467 c_new_pk_id number) is
14468 select
14469 EPG.elig_ppl_grp_prte_id new_value
14470 from BEN_ELIG_PPL_GRP_PRTE_F EPG
14471 where
14472 EPG.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
14473 EPG.PEOPLE_GROUP_ID = l_PEOPLE_GROUP_ID and
14474 EPG.business_group_id = c_business_group_id
14475 and EPG.elig_ppl_grp_prte_id <> c_new_pk_id
14476 and c_effective_start_date between effective_start_date
14477 and effective_end_date ;
14478 --END TEMPIK
14479 /*TEMPIK
14480 and exists ( select null
14481 from BEN_ELIG_PPL_GRP_PRTE_F EPG1
14482 where
14483 EPG1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
14484 EPG1.PEOPLE_GROUP_ID = l_PEOPLE_GROUP_ID and
14485 EPG1.ORDR_NUM = l_ORDR_NUM and
14486 EPG1.business_group_id = c_business_group_id
14487 and EPG1.effective_start_date <= c_effective_start_date )
14488 and exists ( select null
14489 from BEN_ELIG_PPL_GRP_PRTE_F EPG2
14490 where
14491 EPG2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
14492 EPG2.PEOPLE_GROUP_ID = l_PEOPLE_GROUP_ID and
14493 EPG2.ORDR_NUM = l_ORDR_NUM and
14494 EPG2.business_group_id = c_business_group_id
14495 and EPG2.effective_end_date >= c_effective_end_date )
14496 ;
14497 TEMPIK */
14498 --TEMPIK
14499 l_dt_rec_found boolean ;
14500 --END TEMPIK
14501 --
14502
14503 --UPD START
14504 --
14505 l_update boolean := false ;
14506 l_datetrack_mode varchar2(80) := hr_api.g_update;
14507 l_process_date date;
14508 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
14509 --
14510 --UPD END
14511 l_current_pk_id number := null ;
14512
14513 l_prev_pk_id number := null ;
14514 l_first_rec boolean := true ;
14515 r_EPG c_EPG%rowtype;
14516 l_elig_ppl_grp_prte_id number ;
14517 l_object_version_number number ;
14518 l_effective_start_date date ;
14519 l_effective_end_date date ;
14520 l_prefix pqh_copy_entity_attribs.information1%type := null;
14521 l_suffix pqh_copy_entity_attribs.information1%type := null;
14522 l_new_value number(15);
14523 l_object_found_in_target boolean := false ;
14524 l_min_esd date;
14525 l_max_eed date;
14526 l_effective_date date;
14527 --
14528 begin
14529 -- Initialization
14530 l_object_found_in_target := false ;
14531 -- End Initialization
14532 -- Derive the prefix - sufix
14533 if p_prefix_suffix_cd = 'PREFIX' then
14534 l_prefix := p_prefix_suffix_text ;
14535 elsif p_prefix_suffix_cd = 'SUFFIX' then
14536 l_suffix := p_prefix_suffix_text ;
14537 else
14538 l_prefix := null ;
14539 l_suffix := null ;
14540 end if ;
14541 -- End Prefix Sufix derivation
14542 for r_EPG_unique in c_unique_EPG('EPG') loop
14543
14544 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
14545 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14546 r_EPG_unique.information3 >=
14547 ben_pd_copy_to_ben_one.g_copy_effective_date)
14548 ) then
14549 --
14550 hr_utility.set_location(' r_EPG_unique.table_route_id '||r_EPG_unique.table_route_id,10);
14551 hr_utility.set_location(' r_EPG_unique.information1 '||r_EPG_unique.information1,10);
14552 hr_utility.set_location( 'r_EPG_unique.information2 '||r_EPG_unique.information2,10);
14553 hr_utility.set_location( 'r_EPG_unique.information3 '||r_EPG_unique.information3,10);
14554 -- If reuse objects flag is 'Y' then check for the object in the target business group
14555 -- if found insert the record into PLSql table and exit the loop else try create the
14556 -- object in the target business group
14557 --
14558 l_object_found_in_target := false ;
14559 --UPD START
14560 l_update := false;
14561 l_process_date := p_effective_date;
14562 l_dml_operation:= r_EPG_unique.dml_operation ;
14563 --
14564 /**********************moved from below **********************/
14565 open c_EPG(r_EPG_unique.table_route_id,
14566 r_EPG_unique.information1,
14567 r_EPG_unique.information2,
14568 r_EPG_unique.information3 ) ;
14569 --
14570 fetch c_EPG into r_EPG ;
14571 --
14572 close c_EPG ;
14573 --
14574 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPG.INFORMATION263,l_dml_operation);
14575
14576 -- Only For Use by Create Wizard - Same Business Group
14577 l_PEOPLE_GROUP_ID := NVL(get_fk('PEOPLE_GROUP_ID', r_EPG.INFORMATION261,l_dml_operation),
14578 r_EPG.INFORMATION261);
14579
14580 l_ORDR_NUM := r_EPG.INFORMATION257;
14581
14582 /**********************************************************/
14583
14584 if l_dml_operation = 'UPDATE' then
14585 --
14586 l_object_found_in_target := TRUE;
14587 --
14588 if l_process_date between r_EPG_unique.information2 and r_EPG_unique.information3 then
14589 l_update := true;
14590 if r_EPG_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
14591 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PPL_GRP_PRTE_ID' then
14592 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PPL_GRP_PRTE_ID' ;
14593 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPG_unique.information1 ;
14594 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EPG_unique.information1 ;
14595 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
14596 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPG_unique.table_route_id;
14597 --
14598 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
14599 --
14600 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
14601 --
14602 -- log_data('EPG',l_new_value,l_prefix || r_EPG_unique.name|| l_suffix,'REUSED');
14603 --
14604 end if ;
14605 hr_utility.set_location( 'found record for update',10);
14606 --
14607 else
14608 --
14609 l_update := false;
14610 --
14611 end if;
14612 else
14613 --
14614 --UPD END
14615 l_min_esd := null ;
14616 l_max_eed := null ;
14617 open c_EPG_min_max_dates(r_EPG_unique.table_route_id, r_EPG_unique.information1 ) ;
14618 fetch c_EPG_min_max_dates into l_min_esd,l_max_eed ;
14619 --
14620
14621 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14622 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
14623 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
14624 end if;
14625 l_min_esd := greatest(l_min_esd,r_EPG_unique.information2);
14626 /**********************moved up from here **********************
14627 open c_EPG(r_EPG_unique.table_route_id,
14628 r_EPG_unique.information1,
14629 r_EPG_unique.information2,
14630 r_EPG_unique.information3 ) ;
14631 --
14632 fetch c_EPG into r_EPG ;
14633 --
14634 close c_EPG ;
14635 --
14636 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPG.INFORMATION263,l_dml_operation);
14637
14638 -- Only For Use by Create Wizard - Same Business Group
14639 l_PEOPLE_GROUP_ID := NVL(get_fk('PEOPLE_GROUP_ID', r_EPG.INFORMATION261,l_dml_operation),
14640 r_EPG.INFORMATION261);
14641
14642 l_ORDR_NUM := r_EPG.INFORMATION257;
14643
14644 **********************************************************/
14645
14646 if p_reuse_object_flag = 'Y' then
14647 if c_EPG_min_max_dates%found then
14648 -- cursor to find the object
14649 open c_find_EPG_in_target( l_min_esd,l_max_eed,
14650 p_target_business_group_id, nvl(l_elig_ppl_grp_prte_id, -999) ) ;
14651 fetch c_find_EPG_in_target into l_new_value ;
14652 if c_find_EPG_in_target%found then
14653 --
14654 --TEMPIK
14655 l_dt_rec_found := dt_api.check_min_max_dates
14656 (p_base_table_name => 'BEN_ELIG_PPL_GRP_PRTE_F',
14657 p_base_key_column => 'ELIG_PPL_GRP_PRTE_ID',
14658 p_base_key_value => l_new_value,
14659 p_from_date => l_min_esd,
14660 p_to_date => l_max_eed );
14661 if l_dt_rec_found THEN
14662 --END TEMPIK
14663 if r_EPG_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
14664 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PPL_GRP_PRTE_ID' then
14665 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PPL_GRP_PRTE_ID' ;
14666 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPG_unique.information1 ;
14667 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
14668 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
14669 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPG_unique.table_route_id;
14670 --
14671 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
14672 --
14673 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
14674 end if ;
14675 --
14676 l_object_found_in_target := true ;
14677 --TEMPIK
14678 end if; -- l_dt_rec_found
14679 --END TEMPIK
14680 end if;
14681 close c_find_EPG_in_target ;
14682 --
14683 end if;
14684 end if ;
14685 --
14686 close c_EPG_min_max_dates ;
14687 end if; --if p_dml_operation
14688 --
14689 if not l_object_found_in_target OR l_update then
14690
14691 --
14692 l_current_pk_id := r_EPG.information1;
14693 --
14694 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
14695 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
14696 --
14697 if l_current_pk_id = l_prev_pk_id then
14698 --
14699 l_first_rec := false ;
14700 --
14701 else
14702 --
14703 l_first_rec := true ;
14704 --
14705 end if ;
14706 --
14707
14708 l_effective_date := r_EPG.information2;
14709 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14710 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
14711 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
14712 end if;
14713
14714 if l_first_rec and not l_update then
14715 -- Call Create routine.
14716 hr_utility.set_location(' BEN_ELIG_PPL_GRP_PRTE_F CREATE_ELIG_PPL_GRP_PRTE ',20);
14717 BEN_ELIG_PPL_GRP_PRTE_API.CREATE_ELIG_PPL_GRP_PRTE(
14718 --
14719 P_VALIDATE => false
14720 ,P_EFFECTIVE_DATE => l_effective_date
14721 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
14722 --
14723 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
14724 ,P_ELIG_PPL_GRP_PRTE_ID => l_elig_ppl_grp_prte_id
14725 ,P_EPG_ATTRIBUTE1 => r_EPG.INFORMATION111
14726 ,P_EPG_ATTRIBUTE10 => r_EPG.INFORMATION120
14727 ,P_EPG_ATTRIBUTE11 => r_EPG.INFORMATION121
14728 ,P_EPG_ATTRIBUTE12 => r_EPG.INFORMATION122
14729 ,P_EPG_ATTRIBUTE13 => r_EPG.INFORMATION123
14730 ,P_EPG_ATTRIBUTE14 => r_EPG.INFORMATION124
14731 ,P_EPG_ATTRIBUTE15 => r_EPG.INFORMATION125
14732 ,P_EPG_ATTRIBUTE16 => r_EPG.INFORMATION126
14733 ,P_EPG_ATTRIBUTE17 => r_EPG.INFORMATION127
14734 ,P_EPG_ATTRIBUTE18 => r_EPG.INFORMATION128
14735 ,P_EPG_ATTRIBUTE19 => r_EPG.INFORMATION129
14736 ,P_EPG_ATTRIBUTE2 => r_EPG.INFORMATION112
14737 ,P_EPG_ATTRIBUTE20 => r_EPG.INFORMATION130
14738 ,P_EPG_ATTRIBUTE21 => r_EPG.INFORMATION131
14739 ,P_EPG_ATTRIBUTE22 => r_EPG.INFORMATION132
14740 ,P_EPG_ATTRIBUTE23 => r_EPG.INFORMATION133
14741 ,P_EPG_ATTRIBUTE24 => r_EPG.INFORMATION134
14742 ,P_EPG_ATTRIBUTE25 => r_EPG.INFORMATION135
14743 ,P_EPG_ATTRIBUTE26 => r_EPG.INFORMATION136
14744 ,P_EPG_ATTRIBUTE27 => r_EPG.INFORMATION137
14745 ,P_EPG_ATTRIBUTE28 => r_EPG.INFORMATION138
14746 ,P_EPG_ATTRIBUTE29 => r_EPG.INFORMATION139
14747 ,P_EPG_ATTRIBUTE3 => r_EPG.INFORMATION113
14748 ,P_EPG_ATTRIBUTE30 => r_EPG.INFORMATION140
14749 ,P_EPG_ATTRIBUTE4 => r_EPG.INFORMATION114
14750 ,P_EPG_ATTRIBUTE5 => r_EPG.INFORMATION115
14751 ,P_EPG_ATTRIBUTE6 => r_EPG.INFORMATION116
14752 ,P_EPG_ATTRIBUTE7 => r_EPG.INFORMATION117
14753 ,P_EPG_ATTRIBUTE8 => r_EPG.INFORMATION118
14754 ,P_EPG_ATTRIBUTE9 => r_EPG.INFORMATION119
14755 ,P_EPG_ATTRIBUTE_CATEGORY => r_EPG.INFORMATION110
14756 ,P_EXCLD_FLAG => r_EPG.INFORMATION11
14757 ,P_ORDR_NUM => r_EPG.INFORMATION257
14758 ,P_PEOPLE_GROUP_ID => l_PEOPLE_GROUP_ID
14759 --
14760 -- ****** END CHANGE LINES
14761
14762 --
14763
14764 ,P_EFFECTIVE_START_DATE => l_effective_start_date
14765 ,P_EFFECTIVE_END_DATE => l_effective_end_date
14766 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
14767 ,P_CRITERIA_SCORE => r_epg.INFORMATION295
14768 ,P_CRITERIA_WEIGHT => r_epg.INFORMATION296
14769 );
14770 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
14771 -- Update all relevent cer records with new pk_id
14772 hr_utility.set_location('Before plsql table ',222);
14773 hr_utility.set_location('new_value id '||l_elig_ppl_grp_prte_id,222);
14774 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PPL_GRP_PRTE_ID' ;
14775 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPG.information1 ;
14776 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_PPL_GRP_PRTE_ID ;
14777 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
14778 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPG_unique.table_route_id;
14779 hr_utility.set_location('After plsql table ',222);
14780 --
14781 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
14782 --
14783 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
14784 --
14785 else
14786 --
14787 -- Call Update routine for the pk_id created in prev run .
14788 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
14789 hr_utility.set_location(' BEN_ELIG_PPL_GRP_PRTE_F UPDATE_ELIG_PPL_GRP_PRTE ',30);
14790 --UPD START
14791 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
14792 --
14793 if l_update then
14794 --
14795 l_datetrack_mode := r_EPG.datetrack_mode ;
14796 --
14797 get_dt_modes(
14798 p_effective_date => l_process_date,
14799 p_effective_end_date => r_EPG.information3,
14800 p_effective_start_date => r_EPG.information2,
14801 p_dml_operation => r_EPG.dml_operation,
14802 p_datetrack_mode => l_datetrack_mode );
14803 -- p_update => l_update
14804 --
14805 l_effective_date := l_process_date;
14806 l_ELIG_PPL_GRP_PRTE_ID := r_EPG.information1;
14807 l_object_version_number := r_EPG.information265;
14808 --
14809 end if;
14810 --
14811 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
14812 --
14813 IF l_update OR l_dml_operation <> 'UPDATE' THEN
14814 --UPD END
14815
14816
14817 BEN_ELIG_PPL_GRP_PRTE_API.UPDATE_ELIG_PPL_GRP_PRTE(
14818 --
14819 P_VALIDATE => false
14820 ,P_EFFECTIVE_DATE => l_effective_date
14821 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
14822 --
14823 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
14824 ,P_ELIG_PPL_GRP_PRTE_ID => l_elig_ppl_grp_prte_id
14825 ,P_EPG_ATTRIBUTE1 => r_EPG.INFORMATION111
14826 ,P_EPG_ATTRIBUTE10 => r_EPG.INFORMATION120
14827 ,P_EPG_ATTRIBUTE11 => r_EPG.INFORMATION121
14828 ,P_EPG_ATTRIBUTE12 => r_EPG.INFORMATION122
14829 ,P_EPG_ATTRIBUTE13 => r_EPG.INFORMATION123
14830 ,P_EPG_ATTRIBUTE14 => r_EPG.INFORMATION124
14831 ,P_EPG_ATTRIBUTE15 => r_EPG.INFORMATION125
14832 ,P_EPG_ATTRIBUTE16 => r_EPG.INFORMATION126
14833 ,P_EPG_ATTRIBUTE17 => r_EPG.INFORMATION127
14834 ,P_EPG_ATTRIBUTE18 => r_EPG.INFORMATION128
14835 ,P_EPG_ATTRIBUTE19 => r_EPG.INFORMATION129
14836 ,P_EPG_ATTRIBUTE2 => r_EPG.INFORMATION112
14837 ,P_EPG_ATTRIBUTE20 => r_EPG.INFORMATION130
14838 ,P_EPG_ATTRIBUTE21 => r_EPG.INFORMATION131
14839 ,P_EPG_ATTRIBUTE22 => r_EPG.INFORMATION132
14840 ,P_EPG_ATTRIBUTE23 => r_EPG.INFORMATION133
14841 ,P_EPG_ATTRIBUTE24 => r_EPG.INFORMATION134
14842 ,P_EPG_ATTRIBUTE25 => r_EPG.INFORMATION135
14843 ,P_EPG_ATTRIBUTE26 => r_EPG.INFORMATION136
14844 ,P_EPG_ATTRIBUTE27 => r_EPG.INFORMATION137
14845 ,P_EPG_ATTRIBUTE28 => r_EPG.INFORMATION138
14846 ,P_EPG_ATTRIBUTE29 => r_EPG.INFORMATION139
14847 ,P_EPG_ATTRIBUTE3 => r_EPG.INFORMATION113
14848 ,P_EPG_ATTRIBUTE30 => r_EPG.INFORMATION140
14849 ,P_EPG_ATTRIBUTE4 => r_EPG.INFORMATION114
14850 ,P_EPG_ATTRIBUTE5 => r_EPG.INFORMATION115
14851 ,P_EPG_ATTRIBUTE6 => r_EPG.INFORMATION116
14852 ,P_EPG_ATTRIBUTE7 => r_EPG.INFORMATION117
14853 ,P_EPG_ATTRIBUTE8 => r_EPG.INFORMATION118
14854 ,P_EPG_ATTRIBUTE9 => r_EPG.INFORMATION119
14855 ,P_EPG_ATTRIBUTE_CATEGORY => r_EPG.INFORMATION110
14856 ,P_EXCLD_FLAG => r_EPG.INFORMATION11
14857 ,P_ORDR_NUM => r_EPG.INFORMATION257
14858 ,P_PEOPLE_GROUP_ID => l_PEOPLE_GROUP_ID
14859 --
14860 -- ****** END CHANGE LINES
14861
14862 --
14863 ,P_EFFECTIVE_START_DATE => l_effective_start_date
14864 ,P_EFFECTIVE_END_DATE => l_effective_end_date
14865 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
14866 ,P_DATETRACK_MODE => l_datetrack_mode
14867 ,P_CRITERIA_SCORE => r_epg.INFORMATION295
14868 ,P_CRITERIA_WEIGHT => r_epg.INFORMATION296
14869 );
14870 end if; -- l_update
14871 --
14872 end if;
14873 --
14874 -- Delete the row if it is end dated.
14875 --
14876 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
14877 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
14878 trunc(l_max_eed) = trunc(r_EPG.information3)) then
14879 --
14880 BEN_ELIG_PPL_GRP_PRTE_API.delete_ELIG_PPL_GRP_PRTE(
14881 --
14882 p_validate => false
14883 ,p_elig_ppl_grp_prte_id => l_elig_ppl_grp_prte_id
14884 ,p_effective_start_date => l_effective_start_date
14885 ,p_effective_end_date => l_effective_end_date
14886 ,p_object_version_number => l_object_version_number
14887 ,p_effective_date => l_max_eed
14888 ,p_datetrack_mode => hr_api.g_delete
14889 --
14890 );
14891 --
14892 end if;
14893 --
14894 l_prev_pk_id := l_current_pk_id ;
14895 --
14896 end if;
14897 --
14898 end if;
14899 --
14900 end loop;
14901 --
14902 exception when others then
14903 --
14904 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EPG',r_EPG.information5 ) ;
14905 --
14906 end create_EPG_rows;
14907
14908 --
14909
14910 --
14911 ---------------------------------------------------------------
14912 ----------------------< create_EPB_rows >-----------------------
14913 ---------------------------------------------------------------
14914 --
14915 procedure create_EPB_rows
14916 (
14917 p_validate in number default 0
14918 ,p_copy_entity_txn_id in number
14919 ,p_effective_date in date
14920 ,p_prefix_suffix_text in varchar2 default null
14921 ,p_reuse_object_flag in varchar2 default null
14922 ,p_target_business_group_id in varchar2 default null
14923 ,p_prefix_suffix_cd in varchar2 default null
14924 ) is
14925 --
14926 l_ELIGY_PRFL_ID number;
14927 l_PAY_BASIS_ID number;
14928 cursor c_unique_EPB(l_table_alias varchar2) is
14929 select distinct cpe.information1,
14930 cpe.information2,
14931 cpe.information3,
14932 cpe.table_route_id
14933 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
14934 pqh_table_route tr
14935 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14936 and cpe.table_route_id = tr.table_route_id
14937 -- and tr.where_clause = l_BEN_ELIG_PY_BSS_PRTE_F
14938 and tr.table_alias = l_table_alias
14939 and cpe.number_of_copies = 1 -- ADDITION
14940 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
14941 order by information1, information2; --added for bug: 5151945
14942 --
14943 --
14944 cursor c_EPB_min_max_dates(c_table_route_id number,
14945 c_information1 number) is
14946 select
14947 min(cpe.information2) min_esd,
14948 max(cpe.information3) min_eed
14949 from ben_copy_entity_results cpe
14950 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14951 and cpe.table_route_id = c_table_route_id
14952 and cpe.information1 = c_information1 ;
14953 --
14954 cursor c_EPB(c_table_route_id number,
14955 c_information1 number,
14956 c_information2 date,
14957 c_information3 date ) is
14958 select
14959 cpe.*
14960 from ben_copy_entity_results cpe
14961 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14962 and cpe.table_route_id = c_table_route_id
14963 and cpe.information1 = c_information1
14964 and cpe.information2 = c_information2
14965 and cpe.information3 = c_information3
14966 and rownum = 1 ;
14967 -- Date Track target record
14968 cursor c_find_EPB_in_target(
14969 c_effective_start_date date,
14970 c_effective_end_date date,
14971 c_business_group_id number,
14972 c_new_pk_id number) is
14973 select
14974 EPB.elig_py_bss_prte_id new_value
14975 from BEN_ELIG_PY_BSS_PRTE_F EPB
14976 where
14977 EPB.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
14978 EPB.PAY_BASIS_ID = l_PAY_BASIS_ID and
14979 EPB.business_group_id = c_business_group_id
14980 and EPB.elig_py_bss_prte_id <> c_new_pk_id
14981 and c_effective_start_date between effective_start_date
14982 and effective_end_date ;
14983 --END TEMPIK
14984 /*TEMPIK
14985 and exists ( select null
14986 from BEN_ELIG_PY_BSS_PRTE_F EPB1
14987 where
14988 EPB1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
14989 EPB1.PAY_BASIS_ID = l_PAY_BASIS_ID and
14990 EPB1.business_group_id = c_business_group_id
14991 and EPB1.effective_start_date <= c_effective_start_date )
14992 and exists ( select null
14993 from BEN_ELIG_PY_BSS_PRTE_F EPB2
14994 where
14995 EPB2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
14996 EPB2.PAY_BASIS_ID = l_PAY_BASIS_ID and
14997 EPB2.business_group_id = c_business_group_id
14998 and EPB2.effective_end_date >= c_effective_end_date )
14999 ;
15000 TEMPIK */
15001 --TEMPIK
15002 l_dt_rec_found boolean ;
15003 --END TEMPIK
15004 --
15005
15006 --UPD START
15007 --
15008 l_update boolean := false ;
15009 l_datetrack_mode varchar2(80) := hr_api.g_update;
15010 l_process_date date;
15011 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
15012 --
15013 --UPD END
15014 l_current_pk_id number := null ;
15015
15016 l_prev_pk_id number := null ;
15017 l_first_rec boolean := true ;
15018 r_EPB c_EPB%rowtype;
15019 l_elig_py_bss_prte_id number ;
15020 l_object_version_number number ;
15021 l_effective_start_date date ;
15022 l_effective_end_date date ;
15023 l_prefix pqh_copy_entity_attribs.information1%type := null;
15024 l_suffix pqh_copy_entity_attribs.information1%type := null;
15025 l_new_value number(15);
15026 l_object_found_in_target boolean := false ;
15027 l_min_esd date;
15028 l_max_eed date;
15029 l_effective_date date;
15030 --
15031 begin
15032 -- Initialization
15033 l_object_found_in_target := false ;
15034 -- End Initialization
15035 -- Derive the prefix - sufix
15036 if p_prefix_suffix_cd = 'PREFIX' then
15037 l_prefix := p_prefix_suffix_text ;
15038 elsif p_prefix_suffix_cd = 'SUFFIX' then
15039 l_suffix := p_prefix_suffix_text ;
15040 else
15041 l_prefix := null ;
15042 l_suffix := null ;
15043 end if ;
15044 -- End Prefix Sufix derivation
15045 for r_EPB_unique in c_unique_EPB('EPB') loop
15046
15047 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
15048 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15049 r_EPB_unique.information3 >=
15050 ben_pd_copy_to_ben_one.g_copy_effective_date)
15051 ) then
15052 --
15053 hr_utility.set_location(' r_EPB_unique.table_route_id '||r_EPB_unique.table_route_id,10);
15054 hr_utility.set_location(' r_EPB_unique.information1 '||r_EPB_unique.information1,10);
15055 hr_utility.set_location( 'r_EPB_unique.information2 '||r_EPB_unique.information2,10);
15056 hr_utility.set_location( 'r_EPB_unique.information3 '||r_EPB_unique.information3,10);
15057 -- If reuse objects flag is 'Y' then check for the object in the target business group
15058 -- if found insert the record into PLSql table and exit the loop else try create the
15059 -- object in the target business group
15060 --
15061 l_object_found_in_target := false ;
15062 --UPD START
15063 l_update := false;
15064 l_process_date := p_effective_date;
15065 l_dml_operation:= r_EPB_unique.dml_operation ;
15066 --
15067 /**********************moved from below **********************/
15068 open c_EPB(r_EPB_unique.table_route_id,
15069 r_EPB_unique.information1,
15070 r_EPB_unique.information2,
15071 r_EPB_unique.information3 ) ;
15072 --
15073 fetch c_EPB into r_EPB ;
15074 --
15075 close c_EPB ;
15076 --
15077 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPB.INFORMATION263,l_dml_operation);
15078 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
15079 l_PAY_BASIS_ID := r_EPB.information176;
15080 else
15081 l_PAY_BASIS_ID := r_EPB.information174;
15082 end if;
15083 /**********************************************************/
15084
15085 if l_dml_operation = 'UPDATE' then
15086 --
15087 l_object_found_in_target := TRUE;
15088 --
15089 if l_process_date between r_EPB_unique.information2 and r_EPB_unique.information3 then
15090 l_update := true;
15091 if r_EPB_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
15092 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PY_BSS_PRTE_ID' then
15093 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PY_BSS_PRTE_ID' ;
15094 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPB_unique.information1 ;
15095 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EPB_unique.information1 ;
15096 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
15097 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPB_unique.table_route_id;
15098 --
15099 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
15100 --
15101 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
15102 --
15103 -- log_data('EPB',l_new_value,l_prefix || r_EPB_unique.name|| l_suffix,'REUSED');
15104 --
15105 end if ;
15106 hr_utility.set_location( 'found record for update',10);
15107 --
15108 else
15109 --
15110 l_update := false;
15111 --
15112 end if;
15113 else
15114 --
15115 --UPD END
15116 l_min_esd := null ;
15117 l_max_eed := null ;
15118 open c_EPB_min_max_dates(r_EPB_unique.table_route_id, r_EPB_unique.information1 ) ;
15119 fetch c_EPB_min_max_dates into l_min_esd,l_max_eed ;
15120 --
15121
15122 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15123 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
15124 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
15125 end if;
15126 l_min_esd := greatest(l_min_esd,r_EPB_unique.information2);
15127 /**********************moved up from here **********************
15128 open c_EPB(r_EPB_unique.table_route_id,
15129 r_EPB_unique.information1,
15130 r_EPB_unique.information2,
15131 r_EPB_unique.information3 ) ;
15132 --
15133 fetch c_EPB into r_EPB ;
15134 --
15135 close c_EPB ;
15136 --
15137 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPB.INFORMATION263,l_dml_operation);
15138 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
15139 l_PAY_BASIS_ID := r_EPB.information176;
15140 else
15141 l_PAY_BASIS_ID := r_EPB.information174;
15142 end if;
15143 **********************************************************/
15144
15145 --
15146 if l_PAY_BASIS_ID is null then
15147 close c_EPB_min_max_dates;
15148 --
15149 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
15150 ,p_parent_pk_id => r_EPB.information263
15151 ,p_copy_entity_txn_id => p_copy_entity_txn_id
15152 ,p_child_table_alias => 'EPB'
15153 ,p_child_data => r_EPB.information173 );
15154
15155 --
15156 else
15157 if p_reuse_object_flag = 'Y' then
15158 if c_EPB_min_max_dates%found then
15159 -- cursor to find the object
15160 open c_find_EPB_in_target( l_min_esd,l_max_eed,
15161 p_target_business_group_id, nvl(l_elig_py_bss_prte_id, -999) ) ;
15162 fetch c_find_EPB_in_target into l_new_value ;
15163 if c_find_EPB_in_target%found then
15164 --
15165 --TEMPIK
15166 l_dt_rec_found := dt_api.check_min_max_dates
15167 (p_base_table_name => 'BEN_ELIG_PY_BSS_PRTE_F',
15168 p_base_key_column => 'ELIG_PY_BSS_PRTE_ID',
15169 p_base_key_value => l_new_value,
15170 p_from_date => l_min_esd,
15171 p_to_date => l_max_eed );
15172 if l_dt_rec_found THEN
15173 --END TEMPIK
15174 if r_EPB_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
15175 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PY_BSS_PRTE_ID' then
15176 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PY_BSS_PRTE_ID' ;
15177 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPB_unique.information1 ;
15178 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
15179 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
15180 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPB_unique.table_route_id;
15181 --
15182 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
15183 --
15184 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
15185 end if ;
15186 --
15187 l_object_found_in_target := true ;
15188 --TEMPIK
15189 end if; -- l_dt_rec_found
15190 --END TEMPIK
15191 end if;
15192 close c_find_EPB_in_target ;
15193 --
15194 end if;
15195 end if ;
15196 --
15197 close c_EPB_min_max_dates ;
15198 end if ; -- bug 4565106
15199 end if; --if p_dml_operation
15200 --
15201 if (not l_object_found_in_target OR l_update ) AND l_pay_basis_id is not null then
15202
15203 --
15204 l_current_pk_id := r_EPB.information1;
15205 --
15206 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
15207 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
15208 --
15209 if l_current_pk_id = l_prev_pk_id then
15210 --
15211 l_first_rec := false ;
15212 --
15213 else
15214 --
15215 l_first_rec := true ;
15216 --
15217 end if ;
15218 --
15219
15220 l_effective_date := r_EPB.information2;
15221 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15222 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
15223 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
15224 end if;
15225
15226 if l_first_rec and not l_update then
15227 -- Call Create routine.
15228 hr_utility.set_location(' BEN_ELIG_PY_BSS_PRTE_F CREATE_ELIG_PY_BSS_PRTE ',20);
15229 BEN_ELIG_PY_BSS_PRTE_API.CREATE_ELIG_PY_BSS_PRTE(
15230 --
15231 P_VALIDATE => false
15232 ,P_EFFECTIVE_DATE => l_effective_date
15233 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
15234 --
15235 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
15236 ,P_ELIG_PY_BSS_PRTE_ID => l_elig_py_bss_prte_id
15237 ,P_EPB_ATTRIBUTE1 => r_EPB.INFORMATION111
15238 ,P_EPB_ATTRIBUTE10 => r_EPB.INFORMATION120
15239 ,P_EPB_ATTRIBUTE11 => r_EPB.INFORMATION121
15240 ,P_EPB_ATTRIBUTE12 => r_EPB.INFORMATION122
15241 ,P_EPB_ATTRIBUTE13 => r_EPB.INFORMATION123
15242 ,P_EPB_ATTRIBUTE14 => r_EPB.INFORMATION124
15243 ,P_EPB_ATTRIBUTE15 => r_EPB.INFORMATION125
15244 ,P_EPB_ATTRIBUTE16 => r_EPB.INFORMATION126
15245 ,P_EPB_ATTRIBUTE17 => r_EPB.INFORMATION127
15246 ,P_EPB_ATTRIBUTE18 => r_EPB.INFORMATION128
15247 ,P_EPB_ATTRIBUTE19 => r_EPB.INFORMATION129
15248 ,P_EPB_ATTRIBUTE2 => r_EPB.INFORMATION112
15249 ,P_EPB_ATTRIBUTE20 => r_EPB.INFORMATION130
15250 ,P_EPB_ATTRIBUTE21 => r_EPB.INFORMATION131
15251 ,P_EPB_ATTRIBUTE22 => r_EPB.INFORMATION132
15252 ,P_EPB_ATTRIBUTE23 => r_EPB.INFORMATION133
15253 ,P_EPB_ATTRIBUTE24 => r_EPB.INFORMATION134
15254 ,P_EPB_ATTRIBUTE25 => r_EPB.INFORMATION135
15255 ,P_EPB_ATTRIBUTE26 => r_EPB.INFORMATION136
15256 ,P_EPB_ATTRIBUTE27 => r_EPB.INFORMATION137
15257 ,P_EPB_ATTRIBUTE28 => r_EPB.INFORMATION138
15258 ,P_EPB_ATTRIBUTE29 => r_EPB.INFORMATION139
15259 ,P_EPB_ATTRIBUTE3 => r_EPB.INFORMATION113
15260 ,P_EPB_ATTRIBUTE30 => r_EPB.INFORMATION140
15261 ,P_EPB_ATTRIBUTE4 => r_EPB.INFORMATION114
15262 ,P_EPB_ATTRIBUTE5 => r_EPB.INFORMATION115
15263 ,P_EPB_ATTRIBUTE6 => r_EPB.INFORMATION116
15264 ,P_EPB_ATTRIBUTE7 => r_EPB.INFORMATION117
15265 ,P_EPB_ATTRIBUTE8 => r_EPB.INFORMATION118
15266 ,P_EPB_ATTRIBUTE9 => r_EPB.INFORMATION119
15267 ,P_EPB_ATTRIBUTE_CATEGORY => r_EPB.INFORMATION110
15268 ,P_EXCLD_FLAG => r_EPB.INFORMATION11
15269 ,P_ORDR_NUM => r_EPB.INFORMATION260
15270 ,P_PAY_BASIS_ID => l_PAY_BASIS_ID
15271 --
15272 -- ****** END CHANGE LINES
15273
15274 --
15275
15276 ,P_EFFECTIVE_START_DATE => l_effective_start_date
15277 ,P_EFFECTIVE_END_DATE => l_effective_end_date
15278 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
15279 ,P_CRITERIA_SCORE => r_epb.INFORMATION295
15280 ,P_CRITERIA_WEIGHT => r_epb.INFORMATION296
15281 );
15282 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
15283 -- Update all relevent cer records with new pk_id
15284 hr_utility.set_location('Before plsql table ',222);
15285 hr_utility.set_location('new_value id '||l_elig_py_bss_prte_id,222);
15286 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PY_BSS_PRTE_ID' ;
15287 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPB.information1 ;
15288 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_PY_BSS_PRTE_ID ;
15289 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
15290 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPB_unique.table_route_id;
15291 hr_utility.set_location('After plsql table ',222);
15292 --
15293 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
15294 --
15295 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
15296 --
15297 else
15298 --
15299 -- Call Update routine for the pk_id created in prev run .
15300 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
15301 hr_utility.set_location(' BEN_ELIG_PY_BSS_PRTE_F UPDATE_ELIG_PY_BSS_PRTE ',30);
15302 --UPD START
15303 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
15304 --
15305 if l_update then
15306 --
15307 l_datetrack_mode := r_EPB.datetrack_mode ;
15308 --
15309 get_dt_modes(
15310 p_effective_date => l_process_date,
15311 p_effective_end_date => r_EPB.information3,
15312 p_effective_start_date => r_EPB.information2,
15313 p_dml_operation => r_EPB.dml_operation,
15314 p_datetrack_mode => l_datetrack_mode );
15315 -- p_update => l_update
15316 --
15317 l_effective_date := l_process_date;
15318 l_ELIG_PY_BSS_PRTE_ID := r_EPB.information1;
15319 l_object_version_number := r_EPB.information265;
15320 --
15321 end if;
15322 --
15323 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
15324 --
15325 IF l_update OR l_dml_operation <> 'UPDATE' THEN
15326 --UPD END
15327
15328
15329 BEN_ELIG_PY_BSS_PRTE_API.UPDATE_ELIG_PY_BSS_PRTE(
15330 --
15331 P_VALIDATE => false
15332 ,P_EFFECTIVE_DATE => l_effective_date
15333 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
15334 --
15335 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
15336 ,P_ELIG_PY_BSS_PRTE_ID => l_elig_py_bss_prte_id
15337 ,P_EPB_ATTRIBUTE1 => r_EPB.INFORMATION111
15338 ,P_EPB_ATTRIBUTE10 => r_EPB.INFORMATION120
15339 ,P_EPB_ATTRIBUTE11 => r_EPB.INFORMATION121
15340 ,P_EPB_ATTRIBUTE12 => r_EPB.INFORMATION122
15341 ,P_EPB_ATTRIBUTE13 => r_EPB.INFORMATION123
15342 ,P_EPB_ATTRIBUTE14 => r_EPB.INFORMATION124
15343 ,P_EPB_ATTRIBUTE15 => r_EPB.INFORMATION125
15344 ,P_EPB_ATTRIBUTE16 => r_EPB.INFORMATION126
15345 ,P_EPB_ATTRIBUTE17 => r_EPB.INFORMATION127
15346 ,P_EPB_ATTRIBUTE18 => r_EPB.INFORMATION128
15347 ,P_EPB_ATTRIBUTE19 => r_EPB.INFORMATION129
15348 ,P_EPB_ATTRIBUTE2 => r_EPB.INFORMATION112
15349 ,P_EPB_ATTRIBUTE20 => r_EPB.INFORMATION130
15350 ,P_EPB_ATTRIBUTE21 => r_EPB.INFORMATION131
15351 ,P_EPB_ATTRIBUTE22 => r_EPB.INFORMATION132
15352 ,P_EPB_ATTRIBUTE23 => r_EPB.INFORMATION133
15353 ,P_EPB_ATTRIBUTE24 => r_EPB.INFORMATION134
15354 ,P_EPB_ATTRIBUTE25 => r_EPB.INFORMATION135
15355 ,P_EPB_ATTRIBUTE26 => r_EPB.INFORMATION136
15356 ,P_EPB_ATTRIBUTE27 => r_EPB.INFORMATION137
15357 ,P_EPB_ATTRIBUTE28 => r_EPB.INFORMATION138
15358 ,P_EPB_ATTRIBUTE29 => r_EPB.INFORMATION139
15359 ,P_EPB_ATTRIBUTE3 => r_EPB.INFORMATION113
15360 ,P_EPB_ATTRIBUTE30 => r_EPB.INFORMATION140
15361 ,P_EPB_ATTRIBUTE4 => r_EPB.INFORMATION114
15362 ,P_EPB_ATTRIBUTE5 => r_EPB.INFORMATION115
15363 ,P_EPB_ATTRIBUTE6 => r_EPB.INFORMATION116
15364 ,P_EPB_ATTRIBUTE7 => r_EPB.INFORMATION117
15365 ,P_EPB_ATTRIBUTE8 => r_EPB.INFORMATION118
15366 ,P_EPB_ATTRIBUTE9 => r_EPB.INFORMATION119
15367 ,P_EPB_ATTRIBUTE_CATEGORY => r_EPB.INFORMATION110
15368 ,P_EXCLD_FLAG => r_EPB.INFORMATION11
15369 ,P_ORDR_NUM => r_EPB.INFORMATION260
15370 ,P_PAY_BASIS_ID => l_PAY_BASIS_ID
15371 --
15372 -- ****** END CHANGE LINES
15373
15374 --
15375 ,P_EFFECTIVE_START_DATE => l_effective_start_date
15376 ,P_EFFECTIVE_END_DATE => l_effective_end_date
15377 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
15378 ,P_DATETRACK_MODE => l_datetrack_mode
15379 ,P_CRITERIA_SCORE => r_epb.INFORMATION295
15380 ,P_CRITERIA_WEIGHT => r_epb.INFORMATION296
15381 );
15382 end if; -- l_update
15383 --
15384 end if;
15385 --
15386 -- Delete the row if it is end dated.
15387 --
15388 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
15389 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
15390 trunc(l_max_eed) = trunc(r_EPB.information3)) then
15391 --
15392 BEN_ELIG_PY_BSS_PRTE_API.delete_ELIG_PY_BSS_PRTE(
15393 --
15394 p_validate => false
15395 ,p_elig_py_bss_prte_id => l_elig_py_bss_prte_id
15396 ,p_effective_start_date => l_effective_start_date
15397 ,p_effective_end_date => l_effective_end_date
15398 ,p_object_version_number => l_object_version_number
15399 ,p_effective_date => l_max_eed
15400 ,p_datetrack_mode => hr_api.g_delete
15401 --
15402 );
15403 --
15404 end if;
15405 --
15406 l_prev_pk_id := l_current_pk_id ;
15407 --
15408 -- end if; -- bug 4565106
15409 --
15410 end if;
15411 --
15412 end if;
15413 --
15414 end loop;
15415 --
15416 exception when others then
15417 --
15418 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EPB',r_EPB.information5 ) ;
15419 --
15420 end create_EPB_rows;
15421
15422 --
15423 ---------------------------------------------------------------
15424 ----------------------< create_EPN_rows >-----------------------
15425 ---------------------------------------------------------------
15426 --
15427 procedure create_EPN_rows
15428 (
15429 p_validate in number default 0
15430 ,p_copy_entity_txn_id in number
15431 ,p_effective_date in date
15432 ,p_prefix_suffix_text in varchar2 default null
15433 ,p_reuse_object_flag in varchar2 default null
15434 ,p_target_business_group_id in varchar2 default null
15435 ,p_prefix_suffix_cd in varchar2 default null
15436 ) is
15437 --
15438 l_ELIGY_PRFL_ID number;
15439 l_PROBATION_PERIOD number;
15440 l_PROBATION_UNIT BEN_ELIG_PRBTN_PERD_PRTE_F.probation_unit%type;
15441 l_ORDR_NUM number;
15442
15443 cursor c_unique_EPN(l_table_alias varchar2) is
15444 select distinct cpe.information1,
15445 cpe.information2,
15446 cpe.information3,
15447 cpe.table_route_id
15448 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
15449 pqh_table_route tr
15450 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15451 and cpe.table_route_id = tr.table_route_id
15452 -- and tr.where_clause = l_BEN_ELIG_PRBTN_PERD_PRTE_F
15453 and tr.table_alias = l_table_alias
15454 and cpe.number_of_copies = 1 -- ADDITION
15455 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
15456 order by information1, information2; --added for bug: 5151945
15457 --
15458 --
15459 cursor c_EPN_min_max_dates(c_table_route_id number,
15460 c_information1 number) is
15461 select
15462 min(cpe.information2) min_esd,
15463 max(cpe.information3) min_eed
15464 from ben_copy_entity_results cpe
15465 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15466 and cpe.table_route_id = c_table_route_id
15467 and cpe.information1 = c_information1 ;
15468 --
15469 cursor c_EPN(c_table_route_id number,
15470 c_information1 number,
15471 c_information2 date,
15472 c_information3 date ) is
15473 select
15474 cpe.*
15475 from ben_copy_entity_results cpe
15476 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15477 and cpe.table_route_id = c_table_route_id
15478 and cpe.information1 = c_information1
15479 and cpe.information2 = c_information2
15480 and cpe.information3 = c_information3
15481 and rownum = 1 ;
15482 -- Date Track target record
15483 cursor c_find_EPN_in_target(
15484 c_effective_start_date date,
15485 c_effective_end_date date,
15486 c_business_group_id number,
15487 c_new_pk_id number) is
15488 select
15489 EPN.elig_prbtn_perd_prte_id new_value
15490 from BEN_ELIG_PRBTN_PERD_PRTE_F EPN
15491 where
15492 EPN.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
15493 EPN.business_group_id = c_business_group_id and
15494 EPN.PROBATION_PERIOD = l_PROBATION_PERIOD and
15495 EPN.PROBATION_UNIT = l_PROBATION_UNIT and
15496 EPN.ORDR_NUM = l_ORDR_NUM and
15497 EPN.elig_prbtn_perd_prte_id <> c_new_pk_id
15498 and c_effective_start_date between effective_start_date
15499 and effective_end_date ;
15500 --END TEMPIK
15501 /*TEMPIK
15502 and exists ( select null
15503 from BEN_ELIG_PRBTN_PERD_PRTE_F EPN1
15504 where
15505 EPN1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
15506 EPN1.PROBATION_PERIOD = l_PROBATION_PERIOD and -- Added this criteria
15507 EPN1.PROBATION_UNIT = l_PROBATION_UNIT and -- Added this criteria
15508 EPN1.ORDR_NUM = l_ORDR_NUM and -- Added this criteria
15509 EPN1.business_group_id = c_business_group_id
15510 and EPN1.effective_start_date <= c_effective_start_date )
15511 and exists ( select null
15512 from BEN_ELIG_PRBTN_PERD_PRTE_F EPN2
15513 where
15514 EPN2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
15515 EPN2.PROBATION_PERIOD = l_PROBATION_PERIOD and -- Added this criteria
15516 EPN2.PROBATION_UNIT = l_PROBATION_UNIT and -- Added this criteria
15517 EPN2.ORDR_NUM = l_ORDR_NUM and -- Added this criteria
15518 EPN2.business_group_id = c_business_group_id
15519 and EPN2.effective_end_date >= c_effective_end_date )
15520 ;
15521 TEMPIK */
15522 --TEMPIK
15523 l_dt_rec_found boolean ;
15524 --END TEMPIK
15525 --
15526
15527 --UPD START
15528 --
15529 l_update boolean := false ;
15530 l_datetrack_mode varchar2(80) := hr_api.g_update;
15531 l_process_date date;
15532 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
15533 --
15534 --UPD END
15535 l_current_pk_id number := null ;
15536
15537 l_prev_pk_id number := null ;
15538 l_first_rec boolean := true ;
15539 r_EPN c_EPN%rowtype;
15540 l_elig_prbtn_perd_prte_id number ;
15541 l_object_version_number number ;
15542 l_effective_start_date date ;
15543 l_effective_end_date date ;
15544 l_prefix pqh_copy_entity_attribs.information1%type := null;
15545 l_suffix pqh_copy_entity_attribs.information1%type := null;
15546 l_new_value number(15);
15547 l_object_found_in_target boolean := false ;
15548 l_min_esd date;
15549 l_max_eed date;
15550 l_effective_date date;
15551 --
15552 begin
15553 -- Initialization
15554 l_object_found_in_target := false ;
15555 -- End Initialization
15556 -- Derive the prefix - sufix
15557 if p_prefix_suffix_cd = 'PREFIX' then
15558 l_prefix := p_prefix_suffix_text ;
15559 elsif p_prefix_suffix_cd = 'SUFFIX' then
15560 l_suffix := p_prefix_suffix_text ;
15561 else
15562 l_prefix := null ;
15563 l_suffix := null ;
15564 end if ;
15565 -- End Prefix Sufix derivation
15566 for r_EPN_unique in c_unique_EPN('EPN') loop
15567
15568 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
15569 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15570 r_EPN_unique.information3 >=
15571 ben_pd_copy_to_ben_one.g_copy_effective_date)
15572 ) then
15573 --
15574 hr_utility.set_location(' r_EPN_unique.table_route_id '||r_EPN_unique.table_route_id,10);
15575 hr_utility.set_location(' r_EPN_unique.information1 '||r_EPN_unique.information1,10);
15576 hr_utility.set_location( 'r_EPN_unique.information2 '||r_EPN_unique.information2,10);
15577 hr_utility.set_location( 'r_EPN_unique.information3 '||r_EPN_unique.information3,10);
15578 -- If reuse objects flag is 'Y' then check for the object in the target business group
15579 -- if found insert the record into PLSql table and exit the loop else try create the
15580 -- object in the target business group
15581 --
15582 l_object_found_in_target := false ;
15583 --UPD START
15584 l_update := false;
15585 l_process_date := p_effective_date;
15586 l_dml_operation:= r_EPN_unique.dml_operation ;
15587
15588 /**********************moved from below **********************/
15589 open c_EPN(r_EPN_unique.table_route_id,
15590 r_EPN_unique.information1,
15591 r_EPN_unique.information2,
15592 r_EPN_unique.information3 ) ;
15593 --
15594 fetch c_EPN into r_EPN ;
15595 --
15596 close c_EPN ;
15597 --
15598 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPN.INFORMATION263,l_dml_operation); -- Changed from 11
15599 l_PROBATION_PERIOD := r_EPN.INFORMATION287; -- Added this criteria
15600 l_PROBATION_UNIT := r_EPN.INFORMATION11; -- Added this criteria
15601 l_ORDR_NUM := r_EPN.INFORMATION257; -- Added this criteria
15602
15603 /**********************************************************/
15604 --
15605 if l_dml_operation = 'UPDATE' then
15606 --
15607 l_object_found_in_target := TRUE;
15608 --
15609 if l_process_date between r_EPN_unique.information2 and r_EPN_unique.information3 then
15610 l_update := true;
15611 if r_EPN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
15612 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PRBTN_PERD_PRTE_ID' then
15613 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PRBTN_PERD_PRTE_ID' ;
15614 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPN_unique.information1 ;
15615 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EPN_unique.information1 ;
15616 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
15617 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPN_unique.table_route_id;
15618 --
15619 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
15620 --
15621 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
15622 --
15623 -- log_data('EPN',l_new_value,l_prefix || r_EPN_unique.name|| l_suffix,'REUSED');
15624 --
15625 end if ;
15626 hr_utility.set_location( 'found record for update',10);
15627 --
15628 else
15629 --
15630 l_update := false;
15631 --
15632 end if;
15633 else
15634 --
15635 --UPD END
15636 l_min_esd := null ;
15637 l_max_eed := null ;
15638 open c_EPN_min_max_dates(r_EPN_unique.table_route_id, r_EPN_unique.information1 ) ;
15639 fetch c_EPN_min_max_dates into l_min_esd,l_max_eed ;
15640 --
15641
15642 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15643 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
15644 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
15645 end if;
15646 l_min_esd := greatest(l_min_esd,r_EPN_unique.information2);
15647 /**********************moved up from here **********************
15648 open c_EPN(r_EPN_unique.table_route_id,
15649 r_EPN_unique.information1,
15650 r_EPN_unique.information2,
15651 r_EPN_unique.information3 ) ;
15652 --
15653 fetch c_EPN into r_EPN ;
15654 --
15655 close c_EPN ;
15656 --
15657 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPN.INFORMATION263,l_dml_operation); -- Changed from 11
15658 l_PROBATION_PERIOD := r_EPN.INFORMATION287; -- Added this criteria
15659 l_PROBATION_UNIT := r_EPN.INFORMATION11; -- Added this criteria
15660 l_ORDR_NUM := r_EPN.INFORMATION257; -- Added this criteria
15661
15662 **********************************************************/
15663
15664
15665 if p_reuse_object_flag = 'Y' then
15666 if c_EPN_min_max_dates%found then
15667 -- cursor to find the object
15668 open c_find_EPN_in_target( l_min_esd,l_max_eed,
15669 p_target_business_group_id, nvl(l_elig_prbtn_perd_prte_id, -999) ) ;
15670 fetch c_find_EPN_in_target into l_new_value ;
15671 if c_find_EPN_in_target%found then
15672 --
15673 --TEMPIK
15674 l_dt_rec_found := dt_api.check_min_max_dates
15675 (p_base_table_name => 'BEN_ELIG_PRBTN_PERD_PRTE_F',
15676 p_base_key_column => 'ELIG_PRBTN_PERD_PRTE_ID',
15677 p_base_key_value => l_new_value,
15678 p_from_date => l_min_esd,
15679 p_to_date => l_max_eed );
15680 if l_dt_rec_found THEN
15681 --END TEMPIK
15682 if r_EPN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
15683 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PRBTN_PERD_PRTE_ID' then
15684 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PRBTN_PERD_PRTE_ID' ;
15685 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPN_unique.information1 ;
15686 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
15687 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
15688 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPN_unique.table_route_id;
15689 --
15690 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
15691 --
15692 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
15693 end if ;
15694 --
15695 l_object_found_in_target := true ;
15696 --TEMPIK
15697 end if; -- l_dt_rec_found
15698 --END TEMPIK
15699 end if;
15700 close c_find_EPN_in_target ;
15701 --
15702 end if;
15703 end if ;
15704 --
15705 close c_EPN_min_max_dates ;
15706 end if; --if p_dml_operation
15707 --
15708 if not l_object_found_in_target OR l_update then
15709
15710 --
15711 l_current_pk_id := r_EPN.information1;
15712 --
15713 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
15714 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
15715 --
15716 if l_current_pk_id = l_prev_pk_id then
15717 --
15718 l_first_rec := false ;
15719 --
15720 else
15721 --
15722 l_first_rec := true ;
15723 --
15724 end if ;
15725 --
15726
15727 l_effective_date := r_EPN.information2;
15728 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15729 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
15730 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
15731 end if;
15732
15733 if l_first_rec and not l_update then
15734 -- Call Create routine.
15735 hr_utility.set_location(' BEN_ELIG_PRBTN_PERD_PRTE_F CREATE_ELIG_PRBTN_PERD_PRTE ',20);
15736 BEN_ELIG_PRBTN_PERD_PRTE_API.CREATE_ELIG_PRBTN_PERD_PRTE(
15737 --
15738 P_VALIDATE => false
15739 ,P_EFFECTIVE_DATE => l_effective_date
15740 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
15741 --
15742 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
15743 ,P_ELIG_PRBTN_PERD_PRTE_ID => l_elig_prbtn_perd_prte_id
15744 ,P_EPN_ATTRIBUTE1 => r_EPN.INFORMATION111
15745 ,P_EPN_ATTRIBUTE10 => r_EPN.INFORMATION120
15746 ,P_EPN_ATTRIBUTE11 => r_EPN.INFORMATION121
15747 ,P_EPN_ATTRIBUTE12 => r_EPN.INFORMATION122
15748 ,P_EPN_ATTRIBUTE13 => r_EPN.INFORMATION123
15749 ,P_EPN_ATTRIBUTE14 => r_EPN.INFORMATION124
15750 ,P_EPN_ATTRIBUTE15 => r_EPN.INFORMATION125
15751 ,P_EPN_ATTRIBUTE16 => r_EPN.INFORMATION126
15752 ,P_EPN_ATTRIBUTE17 => r_EPN.INFORMATION127
15753 ,P_EPN_ATTRIBUTE18 => r_EPN.INFORMATION128
15754 ,P_EPN_ATTRIBUTE19 => r_EPN.INFORMATION129
15755 ,P_EPN_ATTRIBUTE2 => r_EPN.INFORMATION112
15756 ,P_EPN_ATTRIBUTE20 => r_EPN.INFORMATION130
15757 ,P_EPN_ATTRIBUTE21 => r_EPN.INFORMATION131
15758 ,P_EPN_ATTRIBUTE22 => r_EPN.INFORMATION132
15759 ,P_EPN_ATTRIBUTE23 => r_EPN.INFORMATION133
15760 ,P_EPN_ATTRIBUTE24 => r_EPN.INFORMATION134
15761 ,P_EPN_ATTRIBUTE25 => r_EPN.INFORMATION135
15762 ,P_EPN_ATTRIBUTE26 => r_EPN.INFORMATION136
15763 ,P_EPN_ATTRIBUTE27 => r_EPN.INFORMATION137
15764 ,P_EPN_ATTRIBUTE28 => r_EPN.INFORMATION138
15765 ,P_EPN_ATTRIBUTE29 => r_EPN.INFORMATION139
15766 ,P_EPN_ATTRIBUTE3 => r_EPN.INFORMATION113
15767 ,P_EPN_ATTRIBUTE30 => r_EPN.INFORMATION140
15768 ,P_EPN_ATTRIBUTE4 => r_EPN.INFORMATION114
15769 ,P_EPN_ATTRIBUTE5 => r_EPN.INFORMATION115
15770 ,P_EPN_ATTRIBUTE6 => r_EPN.INFORMATION116
15771 ,P_EPN_ATTRIBUTE7 => r_EPN.INFORMATION117
15772 ,P_EPN_ATTRIBUTE8 => r_EPN.INFORMATION118
15773 ,P_EPN_ATTRIBUTE9 => r_EPN.INFORMATION119
15774 ,P_EPN_ATTRIBUTE_CATEGORY => r_EPN.INFORMATION110
15775 ,P_EXCLD_FLAG => r_EPN.INFORMATION12
15776 ,P_ORDR_NUM => r_EPN.INFORMATION257
15777 ,P_PROBATION_PERIOD => r_EPN.INFORMATION287
15778 ,P_PROBATION_UNIT => r_EPN.INFORMATION11
15779 --
15780 -- ****** END CHANGE LINES
15781
15782 --
15783
15784 ,P_EFFECTIVE_START_DATE => l_effective_start_date
15785 ,P_EFFECTIVE_END_DATE => l_effective_end_date
15786 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
15787 ,P_CRITERIA_SCORE => r_epn.INFORMATION295
15788 ,P_CRITERIA_WEIGHT => r_epn.INFORMATION296
15789 );
15790 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
15791 -- Update all relevent cer records with new pk_id
15792 hr_utility.set_location('Before plsql table ',222);
15793 hr_utility.set_location('new_value id '||l_elig_prbtn_perd_prte_id,222);
15794 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PRBTN_PERD_PRTE_ID' ;
15795 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPN.information1 ;
15796 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_PRBTN_PERD_PRTE_ID ;
15797 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
15798 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPN_unique.table_route_id;
15799 hr_utility.set_location('After plsql table ',222);
15800 --
15801 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
15802 --
15803 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
15804 --
15805 else
15806 --
15807 -- Call Update routine for the pk_id created in prev run .
15808 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
15809 hr_utility.set_location(' BEN_ELIG_PRBTN_PERD_PRTE_F UPDATE_ELIG_PRBTN_PERD_PRTE ',30);
15810 --UPD START
15811 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
15812 --
15813 if l_update then
15814 --
15815 l_datetrack_mode := r_EPN.datetrack_mode ;
15816 --
15817 get_dt_modes(
15818 p_effective_date => l_process_date,
15819 p_effective_end_date => r_EPN.information3,
15820 p_effective_start_date => r_EPN.information2,
15821 p_dml_operation => r_EPN.dml_operation,
15822 p_datetrack_mode => l_datetrack_mode );
15823 -- p_update => l_update
15824 --
15825 l_effective_date := l_process_date;
15826 l_ELIG_PRBTN_PERD_PRTE_ID := r_EPN.information1;
15827 l_object_version_number := r_EPN.information265;
15828 --
15829 end if;
15830 --
15831 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
15832 --
15833 IF l_update OR l_dml_operation <> 'UPDATE' THEN
15834 --UPD END
15835
15836
15837 BEN_ELIG_PRBTN_PERD_PRTE_API.UPDATE_ELIG_PRBTN_PERD_PRTE(
15838 --
15839 P_VALIDATE => false
15840 ,P_EFFECTIVE_DATE => l_effective_date
15841 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
15842 --
15843 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
15844 ,P_ELIG_PRBTN_PERD_PRTE_ID => l_elig_prbtn_perd_prte_id
15845 ,P_EPN_ATTRIBUTE1 => r_EPN.INFORMATION111
15846 ,P_EPN_ATTRIBUTE10 => r_EPN.INFORMATION120
15847 ,P_EPN_ATTRIBUTE11 => r_EPN.INFORMATION121
15848 ,P_EPN_ATTRIBUTE12 => r_EPN.INFORMATION122
15849 ,P_EPN_ATTRIBUTE13 => r_EPN.INFORMATION123
15850 ,P_EPN_ATTRIBUTE14 => r_EPN.INFORMATION124
15851 ,P_EPN_ATTRIBUTE15 => r_EPN.INFORMATION125
15852 ,P_EPN_ATTRIBUTE16 => r_EPN.INFORMATION126
15853 ,P_EPN_ATTRIBUTE17 => r_EPN.INFORMATION127
15854 ,P_EPN_ATTRIBUTE18 => r_EPN.INFORMATION128
15855 ,P_EPN_ATTRIBUTE19 => r_EPN.INFORMATION129
15856 ,P_EPN_ATTRIBUTE2 => r_EPN.INFORMATION112
15857 ,P_EPN_ATTRIBUTE20 => r_EPN.INFORMATION130
15858 ,P_EPN_ATTRIBUTE21 => r_EPN.INFORMATION131
15859 ,P_EPN_ATTRIBUTE22 => r_EPN.INFORMATION132
15860 ,P_EPN_ATTRIBUTE23 => r_EPN.INFORMATION133
15861 ,P_EPN_ATTRIBUTE24 => r_EPN.INFORMATION134
15862 ,P_EPN_ATTRIBUTE25 => r_EPN.INFORMATION135
15863 ,P_EPN_ATTRIBUTE26 => r_EPN.INFORMATION136
15864 ,P_EPN_ATTRIBUTE27 => r_EPN.INFORMATION137
15865 ,P_EPN_ATTRIBUTE28 => r_EPN.INFORMATION138
15866 ,P_EPN_ATTRIBUTE29 => r_EPN.INFORMATION139
15867 ,P_EPN_ATTRIBUTE3 => r_EPN.INFORMATION113
15868 ,P_EPN_ATTRIBUTE30 => r_EPN.INFORMATION140
15869 ,P_EPN_ATTRIBUTE4 => r_EPN.INFORMATION114
15870 ,P_EPN_ATTRIBUTE5 => r_EPN.INFORMATION115
15871 ,P_EPN_ATTRIBUTE6 => r_EPN.INFORMATION116
15872 ,P_EPN_ATTRIBUTE7 => r_EPN.INFORMATION117
15873 ,P_EPN_ATTRIBUTE8 => r_EPN.INFORMATION118
15874 ,P_EPN_ATTRIBUTE9 => r_EPN.INFORMATION119
15875 ,P_EPN_ATTRIBUTE_CATEGORY => r_EPN.INFORMATION110
15876 ,P_EXCLD_FLAG => r_EPN.INFORMATION12
15877 ,P_ORDR_NUM => r_EPN.INFORMATION257
15878 ,P_PROBATION_PERIOD => r_EPN.INFORMATION287
15879 ,P_PROBATION_UNIT => r_EPN.INFORMATION11
15880 --
15881 -- ****** END CHANGE LINES
15882
15883 --
15884 ,P_EFFECTIVE_START_DATE => l_effective_start_date
15885 ,P_EFFECTIVE_END_DATE => l_effective_end_date
15886 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
15887 ,P_DATETRACK_MODE => l_datetrack_mode
15888 ,P_CRITERIA_SCORE => r_epn.INFORMATION295
15889 ,P_CRITERIA_WEIGHT => r_epn.INFORMATION296
15890 );
15891 end if; -- l_update
15892 --
15893 end if;
15894 --
15895 -- Delete the row if it is end dated.
15896 --
15897 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
15898 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
15899 trunc(l_max_eed) = trunc(r_EPN.information3)) then
15900 --
15901 BEN_ELIG_PRBTN_PERD_PRTE_API.delete_ELIG_PRBTN_PERD_PRTE(
15902 --
15903 p_validate => false
15904 ,p_elig_prbtn_perd_prte_id => l_elig_prbtn_perd_prte_id
15905 ,p_effective_start_date => l_effective_start_date
15906 ,p_effective_end_date => l_effective_end_date
15907 ,p_object_version_number => l_object_version_number
15908 ,p_effective_date => l_max_eed
15909 ,p_datetrack_mode => hr_api.g_delete
15910 --
15911 );
15912 --
15913 end if;
15914 --
15915 l_prev_pk_id := l_current_pk_id ;
15916 --
15917 end if;
15918 --
15919 end if;
15920 --
15921 end loop;
15922 --
15923 exception when others then
15924 --
15925 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EPN',r_EPN.information5 ) ;
15926 --
15927 end create_EPN_rows;
15928
15929 --
15930 ---------------------------------------------------------------
15931 ----------------------< create_EPP_rows >-----------------------
15932 ---------------------------------------------------------------
15933 --
15934 procedure create_EPP_rows
15935 (
15936 p_validate in number default 0
15937 ,p_copy_entity_txn_id in number
15938 ,p_effective_date in date
15939 ,p_prefix_suffix_text in varchar2 default null
15940 ,p_reuse_object_flag in varchar2 default null
15941 ,p_target_business_group_id in varchar2 default null
15942 ,p_prefix_suffix_cd in varchar2 default null
15943 ) is
15944 --
15945 l_ELIGY_PRFL_ID number;
15946 l_PL_ID number;
15947 l_ORDR_NUM number;
15948 cursor c_unique_EPP(l_table_alias varchar2) is
15949 select distinct cpe.information1,
15950 cpe.information2,
15951 cpe.information3,
15952 cpe.table_route_id
15953 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
15954 pqh_table_route tr
15955 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15956 and cpe.table_route_id = tr.table_route_id
15957 -- and tr.where_clause = l_BEN_ELG_PRTT_ANTR_PL_PRTE_F
15958 and tr.table_alias = l_table_alias
15959 and cpe.number_of_copies = 1 -- ADDITION
15960 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
15961 order by information1, information2; --added for bug: 5151945
15962 --
15963 --
15964 cursor c_EPP_min_max_dates(c_table_route_id number,
15965 c_information1 number) is
15966 select
15967 min(cpe.information2) min_esd,
15968 max(cpe.information3) min_eed
15969 from ben_copy_entity_results cpe
15970 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15971 and cpe.table_route_id = c_table_route_id
15972 and cpe.information1 = c_information1 ;
15973 --
15974 cursor c_EPP(c_table_route_id number,
15975 c_information1 number,
15976 c_information2 date,
15977 c_information3 date ) is
15978 select
15979 cpe.*
15980 from ben_copy_entity_results cpe
15981 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15982 and cpe.table_route_id = c_table_route_id
15983 and cpe.information1 = c_information1
15984 and cpe.information2 = c_information2
15985 and cpe.information3 = c_information3
15986 and rownum = 1 ;
15987 -- Date Track target record
15988 cursor c_find_EPP_in_target(
15989 c_effective_start_date date,
15990 c_effective_end_date date,
15991 c_business_group_id number,
15992 c_new_pk_id number) is
15993 select
15994 EPP.elig_prtt_anthr_pl_prte_id new_value
15995 from BEN_ELIG_PRTT_ANTHR_PL_PRTE_F EPP
15996 where
15997 EPP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
15998 EPP.PL_ID = l_PL_ID and
15999 EPP.business_group_id = c_business_group_id
16000 and EPP.elig_prtt_anthr_pl_prte_id <> c_new_pk_id
16001 and c_effective_start_date between effective_start_date
16002 and effective_end_date ;
16003 --END TEMPIK
16004 /*TEMPIK
16005 and exists ( select null
16006 from BEN_ELIG_PRTT_ANTHR_PL_PRTE_F EPP1
16007 where
16008 EPP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
16009 EPP1.PL_ID = l_PL_ID and
16010 EPP1.ORDR_NUM = l_ORDR_NUM and -- Added this criteria
16011 EPP1.business_group_id = c_business_group_id
16012 and EPP1.effective_start_date <= c_effective_start_date )
16013 and exists ( select null
16014 from BEN_ELIG_PRTT_ANTHR_PL_PRTE_F EPP2
16015 where
16016 EPP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
16017 EPP2.PL_ID = l_PL_ID and
16018 EPP2.ORDR_NUM = l_ORDR_NUM and -- Added this criteria
16019 EPP2.business_group_id = c_business_group_id
16020 and EPP2.effective_end_date >= c_effective_end_date )
16021 ;
16022 TEMPIK */
16023 --TEMPIK
16024 l_dt_rec_found boolean ;
16025 --END TEMPIK
16026 --
16027
16028 --UPD START
16029 --
16030 l_update boolean := false ;
16031 l_datetrack_mode varchar2(80) := hr_api.g_update;
16032 l_process_date date;
16033 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
16034 --
16035 --UPD END
16036 l_current_pk_id number := null ;
16037
16038 l_prev_pk_id number := null ;
16039 l_first_rec boolean := true ;
16040 r_EPP c_EPP%rowtype;
16041 l_elig_prtt_anthr_pl_prte_id number ;
16042 l_object_version_number number ;
16043 l_effective_start_date date ;
16044 l_effective_end_date date ;
16045 l_prefix pqh_copy_entity_attribs.information1%type := null;
16046 l_suffix pqh_copy_entity_attribs.information1%type := null;
16047 l_new_value number(15);
16048 l_object_found_in_target boolean := false ;
16049 l_min_esd date;
16050 l_max_eed date;
16051 l_effective_date date;
16052 --
16053 begin
16054 -- Initialization
16055 l_object_found_in_target := false ;
16056 -- End Initialization
16057 -- Derive the prefix - sufix
16058 if p_prefix_suffix_cd = 'PREFIX' then
16059 l_prefix := p_prefix_suffix_text ;
16060 elsif p_prefix_suffix_cd = 'SUFFIX' then
16061 l_suffix := p_prefix_suffix_text ;
16062 else
16063 l_prefix := null ;
16064 l_suffix := null ;
16065 end if ;
16066 -- End Prefix Sufix derivation
16067 for r_EPP_unique in c_unique_EPP('EPP') loop
16068
16069 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
16070 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16071 r_EPP_unique.information3 >=
16072 ben_pd_copy_to_ben_one.g_copy_effective_date)
16073 ) then
16074 --
16075 hr_utility.set_location(' r_EPP_unique.table_route_id '||r_EPP_unique.table_route_id,10);
16076 hr_utility.set_location(' r_EPP_unique.information1 '||r_EPP_unique.information1,10);
16077 hr_utility.set_location( 'r_EPP_unique.information2 '||r_EPP_unique.information2,10);
16078 hr_utility.set_location( 'r_EPP_unique.information3 '||r_EPP_unique.information3,10);
16079 -- If reuse objects flag is 'Y' then check for the object in the target business group
16080 -- if found insert the record into PLSql table and exit the loop else try create the
16081 -- object in the target business group
16082 --
16083 l_object_found_in_target := false ;
16084 --UPD START
16085 l_update := false;
16086 l_process_date := p_effective_date;
16087 l_dml_operation:= r_EPP_unique.dml_operation ;
16088 --
16089 /**********************moved from below **********************/
16090 open c_EPP(r_EPP_unique.table_route_id,
16091 r_EPP_unique.information1,
16092 r_EPP_unique.information2,
16093 r_EPP_unique.information3 ) ;
16094 --
16095 fetch c_EPP into r_EPP ;
16096 --
16097 close c_EPP ;
16098 --
16099 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPP.information263,l_dml_operation);
16100
16101 -- Only For Use by Create Wizard - Same Business Group
16102 l_PL_ID := NVL(get_fk('PL_ID', r_EPP.information261,l_dml_operation),
16103 r_EPP.information261);
16104
16105 l_ORDR_NUM := r_EPP.information260;
16106
16107 /**********************************************************/
16108
16109 if l_dml_operation = 'UPDATE' then
16110 --
16111 l_object_found_in_target := TRUE;
16112 --
16113 if l_process_date between r_EPP_unique.information2 and r_EPP_unique.information3 then
16114 l_update := true;
16115 if r_EPP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
16116 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PRTT_ANTHR_PL_PRTE_ID' then
16117 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PRTT_ANTHR_PL_PRTE_ID' ;
16118 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPP_unique.information1 ;
16119 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EPP_unique.information1 ;
16120 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16121 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPP_unique.table_route_id;
16122 --
16123 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
16124 --
16125 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16126 --
16127 -- log_data('EPP',l_new_value,l_prefix || r_EPP_unique.name|| l_suffix,'REUSED');
16128 --
16129 end if ;
16130 hr_utility.set_location( 'found record for update',10);
16131 --
16132 else
16133 --
16134 l_update := false;
16135 --
16136 end if;
16137 else
16138 --
16139 --UPD END
16140 l_min_esd := null ;
16141 l_max_eed := null ;
16142 open c_EPP_min_max_dates(r_EPP_unique.table_route_id, r_EPP_unique.information1 ) ;
16143 fetch c_EPP_min_max_dates into l_min_esd,l_max_eed ;
16144 --
16145
16146 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16147 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
16148 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
16149 end if;
16150 l_min_esd := greatest(l_min_esd,r_EPP_unique.information2);
16151 /**********************moved up from here **********************
16152 open c_EPP(r_EPP_unique.table_route_id,
16153 r_EPP_unique.information1,
16154 r_EPP_unique.information2,
16155 r_EPP_unique.information3 ) ;
16156 --
16157 fetch c_EPP into r_EPP ;
16158 --
16159 close c_EPP ;
16160 --
16161 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPP.information263,l_dml_operation);
16162
16163 -- Only For Use by Create Wizard - Same Business Group
16164 l_PL_ID := NVL(get_fk('PL_ID', r_EPP.information261,l_dml_operation),
16165 r_EPP.information261);
16166
16167 l_ORDR_NUM := r_EPP.information260;
16168
16169 **********************************************************/
16170
16171 if p_reuse_object_flag = 'Y' then
16172 if c_EPP_min_max_dates%found then
16173 -- cursor to find the object
16174 open c_find_EPP_in_target( l_min_esd,l_max_eed,
16175 p_target_business_group_id, nvl(l_elig_prtt_anthr_pl_prte_id, -999) ) ;
16176 fetch c_find_EPP_in_target into l_new_value ;
16177 if c_find_EPP_in_target%found then
16178 --
16179 --TEMPIK
16180 l_dt_rec_found := dt_api.check_min_max_dates
16181 (p_base_table_name => 'BEN_ELIG_PRTT_ANTHR_PL_PRTE_F',
16182 p_base_key_column => 'ELIG_PRTT_ANTHR_PL_PRTE_ID',
16183 p_base_key_value => l_new_value,
16184 p_from_date => l_min_esd,
16185 p_to_date => l_max_eed );
16186 if l_dt_rec_found THEN
16187 --END TEMPIK
16188 if r_EPP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
16189 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PRTT_ANTHR_PL_PRTE_ID' then
16190 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PRTT_ANTHR_PL_PRTE_ID' ;
16191 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPP_unique.information1 ;
16192 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
16193 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16194 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPP_unique.table_route_id;
16195 --
16196 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
16197 --
16198 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16199 end if ;
16200 --
16201 l_object_found_in_target := true ;
16202 --TEMPIK
16203 end if; -- l_dt_rec_found
16204 --END TEMPIK
16205 end if;
16206 close c_find_EPP_in_target ;
16207 --
16208 end if;
16209 end if ;
16210 --
16211 close c_EPP_min_max_dates ;
16212 end if; --if p_dml_operation
16213 --
16214 if not l_object_found_in_target OR l_update then
16215
16216 --
16217 l_current_pk_id := r_EPP.information1;
16218 --
16219 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
16220 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
16221 --
16222 if l_current_pk_id = l_prev_pk_id then
16223 --
16224 l_first_rec := false ;
16225 --
16226 else
16227 --
16228 l_first_rec := true ;
16229 --
16230 end if ;
16231 --
16232
16233 l_effective_date := r_EPP.information2;
16234 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16235 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
16236 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
16237 end if;
16238
16239 if l_first_rec and not l_update then
16240 -- Call Create routine.
16241 hr_utility.set_location(' BEN_ELIG_PRTT_ANTHR_PL_PRTE_F CREATE_ELG_PRT_ANTHR_PL_PT ',20);
16242 BEN_ELG_PRT_ANTHR_PL_PT_API.CREATE_ELG_PRT_ANTHR_PL_PT(
16243 --
16244 P_VALIDATE => false
16245 ,P_EFFECTIVE_DATE => l_effective_date
16246 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16247 --
16248 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
16249 ,P_ELIG_PRTT_ANTHR_PL_PRTE_ID => l_elig_prtt_anthr_pl_prte_id
16250 ,P_EPP_ATTRIBUTE1 => r_EPP.INFORMATION111
16251 ,P_EPP_ATTRIBUTE10 => r_EPP.INFORMATION120
16252 ,P_EPP_ATTRIBUTE11 => r_EPP.INFORMATION121
16253 ,P_EPP_ATTRIBUTE12 => r_EPP.INFORMATION122
16254 ,P_EPP_ATTRIBUTE13 => r_EPP.INFORMATION123
16255 ,P_EPP_ATTRIBUTE14 => r_EPP.INFORMATION124
16256 ,P_EPP_ATTRIBUTE15 => r_EPP.INFORMATION125
16257 ,P_EPP_ATTRIBUTE16 => r_EPP.INFORMATION126
16258 ,P_EPP_ATTRIBUTE17 => r_EPP.INFORMATION127
16259 ,P_EPP_ATTRIBUTE18 => r_EPP.INFORMATION128
16260 ,P_EPP_ATTRIBUTE19 => r_EPP.INFORMATION129
16261 ,P_EPP_ATTRIBUTE2 => r_EPP.INFORMATION112
16262 ,P_EPP_ATTRIBUTE20 => r_EPP.INFORMATION130
16263 ,P_EPP_ATTRIBUTE21 => r_EPP.INFORMATION131
16264 ,P_EPP_ATTRIBUTE22 => r_EPP.INFORMATION132
16265 ,P_EPP_ATTRIBUTE23 => r_EPP.INFORMATION133
16266 ,P_EPP_ATTRIBUTE24 => r_EPP.INFORMATION134
16267 ,P_EPP_ATTRIBUTE25 => r_EPP.INFORMATION135
16268 ,P_EPP_ATTRIBUTE26 => r_EPP.INFORMATION136
16269 ,P_EPP_ATTRIBUTE27 => r_EPP.INFORMATION137
16270 ,P_EPP_ATTRIBUTE28 => r_EPP.INFORMATION138
16271 ,P_EPP_ATTRIBUTE29 => r_EPP.INFORMATION139
16272 ,P_EPP_ATTRIBUTE3 => r_EPP.INFORMATION113
16273 ,P_EPP_ATTRIBUTE30 => r_EPP.INFORMATION140
16274 ,P_EPP_ATTRIBUTE4 => r_EPP.INFORMATION114
16275 ,P_EPP_ATTRIBUTE5 => r_EPP.INFORMATION115
16276 ,P_EPP_ATTRIBUTE6 => r_EPP.INFORMATION116
16277 ,P_EPP_ATTRIBUTE7 => r_EPP.INFORMATION117
16278 ,P_EPP_ATTRIBUTE8 => r_EPP.INFORMATION118
16279 ,P_EPP_ATTRIBUTE9 => r_EPP.INFORMATION119
16280 ,P_EPP_ATTRIBUTE_CATEGORY => r_EPP.INFORMATION110
16281 ,P_EXCLD_FLAG => r_EPP.INFORMATION11
16282 ,P_ORDR_NUM => r_EPP.INFORMATION260
16283 ,P_PL_ID => l_PL_ID
16284 --
16285 ,P_EFFECTIVE_START_DATE => l_effective_start_date
16286 ,P_EFFECTIVE_END_DATE => l_effective_end_date
16287 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16288 );
16289 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16290 -- Update all relevent cer records with new pk_id
16291 hr_utility.set_location('Before plsql table ',222);
16292 hr_utility.set_location('new_value id '||l_elig_prtt_anthr_pl_prte_id,222);
16293 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PRTT_ANTHR_PL_PRTE_ID' ;
16294 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPP.information1 ;
16295 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_PRTT_ANTHR_PL_PRTE_ID ;
16296 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
16297 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPP_unique.table_route_id;
16298 hr_utility.set_location('After plsql table ',222);
16299 --
16300 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
16301 --
16302 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16303 --
16304 else
16305 --
16306 -- Call Update routine for the pk_id created in prev run .
16307 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16308 hr_utility.set_location(' BEN_ELIG_PRTT_ANTHR_PL_PRTE_F UPDATE_ELG_PRT_ANTHR_PL_PT ',30);
16309 --UPD START
16310 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
16311 --
16312 if l_update then
16313 --
16314 l_datetrack_mode := r_EPP.datetrack_mode ;
16315 --
16316 get_dt_modes(
16317 p_effective_date => l_process_date,
16318 p_effective_end_date => r_EPP.information3,
16319 p_effective_start_date => r_EPP.information2,
16320 p_dml_operation => r_EPP.dml_operation,
16321 p_datetrack_mode => l_datetrack_mode );
16322 -- p_update => l_update
16323 --
16324 l_effective_date := l_process_date;
16325 l_ELIG_PRTT_ANTHR_PL_PRTE_ID := r_EPP.information1;
16326 l_object_version_number := r_EPP.information265;
16327 --
16328 end if;
16329 --
16330 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
16331 --
16332 IF l_update OR l_dml_operation <> 'UPDATE' THEN
16333 --UPD END
16334
16335
16336 BEN_ELG_PRT_ANTHR_PL_PT_API.UPDATE_ELG_PRT_ANTHR_PL_PT(
16337 --
16338 P_VALIDATE => false
16339 ,P_EFFECTIVE_DATE => l_effective_date
16340 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16341 --
16342 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
16343 ,P_ELIG_PRTT_ANTHR_PL_PRTE_ID => l_elig_prtt_anthr_pl_prte_id
16344 ,P_EPP_ATTRIBUTE1 => r_EPP.INFORMATION111
16345 ,P_EPP_ATTRIBUTE10 => r_EPP.INFORMATION120
16346 ,P_EPP_ATTRIBUTE11 => r_EPP.INFORMATION121
16347 ,P_EPP_ATTRIBUTE12 => r_EPP.INFORMATION122
16348 ,P_EPP_ATTRIBUTE13 => r_EPP.INFORMATION123
16349 ,P_EPP_ATTRIBUTE14 => r_EPP.INFORMATION124
16350 ,P_EPP_ATTRIBUTE15 => r_EPP.INFORMATION125
16351 ,P_EPP_ATTRIBUTE16 => r_EPP.INFORMATION126
16352 ,P_EPP_ATTRIBUTE17 => r_EPP.INFORMATION127
16353 ,P_EPP_ATTRIBUTE18 => r_EPP.INFORMATION128
16354 ,P_EPP_ATTRIBUTE19 => r_EPP.INFORMATION129
16355 ,P_EPP_ATTRIBUTE2 => r_EPP.INFORMATION112
16356 ,P_EPP_ATTRIBUTE20 => r_EPP.INFORMATION130
16357 ,P_EPP_ATTRIBUTE21 => r_EPP.INFORMATION131
16358 ,P_EPP_ATTRIBUTE22 => r_EPP.INFORMATION132
16359 ,P_EPP_ATTRIBUTE23 => r_EPP.INFORMATION133
16360 ,P_EPP_ATTRIBUTE24 => r_EPP.INFORMATION134
16361 ,P_EPP_ATTRIBUTE25 => r_EPP.INFORMATION135
16362 ,P_EPP_ATTRIBUTE26 => r_EPP.INFORMATION136
16363 ,P_EPP_ATTRIBUTE27 => r_EPP.INFORMATION137
16364 ,P_EPP_ATTRIBUTE28 => r_EPP.INFORMATION138
16365 ,P_EPP_ATTRIBUTE29 => r_EPP.INFORMATION139
16366 ,P_EPP_ATTRIBUTE3 => r_EPP.INFORMATION113
16367 ,P_EPP_ATTRIBUTE30 => r_EPP.INFORMATION140
16368 ,P_EPP_ATTRIBUTE4 => r_EPP.INFORMATION114
16369 ,P_EPP_ATTRIBUTE5 => r_EPP.INFORMATION115
16370 ,P_EPP_ATTRIBUTE6 => r_EPP.INFORMATION116
16371 ,P_EPP_ATTRIBUTE7 => r_EPP.INFORMATION117
16372 ,P_EPP_ATTRIBUTE8 => r_EPP.INFORMATION118
16373 ,P_EPP_ATTRIBUTE9 => r_EPP.INFORMATION119
16374 ,P_EPP_ATTRIBUTE_CATEGORY => r_EPP.INFORMATION110
16375 ,P_EXCLD_FLAG => r_EPP.INFORMATION11
16376 ,P_ORDR_NUM => r_EPP.INFORMATION260
16377 ,P_PL_ID => l_PL_ID
16378 --
16379 ,P_EFFECTIVE_START_DATE => l_effective_start_date
16380 ,P_EFFECTIVE_END_DATE => l_effective_end_date
16381 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16382 ,P_DATETRACK_MODE => l_datetrack_mode
16383 );
16384 end if; -- l_update
16385 --
16386 end if;
16387 --
16388 -- Delete the row if it is end dated.
16389 --
16390 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
16391 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
16392 trunc(l_max_eed) = trunc(r_EPP.information3)) then
16393 --
16394 BEN_ELG_PRT_ANTHR_PL_PT_API.delete_ELG_PRT_ANTHR_PL_PT(
16395 --
16396 p_validate => false
16397 ,p_elig_prtt_anthr_pl_prte_id => l_elig_prtt_anthr_pl_prte_id
16398 ,p_effective_start_date => l_effective_start_date
16399 ,p_effective_end_date => l_effective_end_date
16400 ,p_object_version_number => l_object_version_number
16401 ,p_effective_date => l_max_eed
16402 ,p_datetrack_mode => hr_api.g_delete
16403 --
16404 );
16405 --
16406 end if;
16407 --
16408 l_prev_pk_id := l_current_pk_id ;
16409 --
16410 end if;
16411 --
16412 end if;
16413 --
16414 end loop;
16415 --
16416 exception when others then
16417 --
16418 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EPP',r_EPP.information5 ) ;
16419 --
16420 end create_EPP_rows;
16421
16422 --
16423 ---------------------------------------------------------------
16424 ----------------------< create_EPS_rows >-----------------------
16425 ---------------------------------------------------------------
16426 --
16427 procedure create_EPS_rows
16428 (
16429 p_validate in number default 0
16430 ,p_copy_entity_txn_id in number
16431 ,p_effective_date in date
16432 ,p_prefix_suffix_text in varchar2 default null
16433 ,p_reuse_object_flag in varchar2 default null
16434 ,p_target_business_group_id in varchar2 default null
16435 ,p_prefix_suffix_cd in varchar2 default null
16436 ) is
16437 --
16438 l_ELIGY_PRFL_ID number;
16439 l_POSITION_ID number;
16440 cursor c_unique_EPS(l_table_alias varchar2) is
16441 select distinct cpe.information1,
16442 cpe.information2,
16443 cpe.information3,
16444 cpe.table_route_id
16445 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
16446 pqh_table_route tr
16447 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16448 and cpe.table_route_id = tr.table_route_id
16449 -- and tr.where_clause = l_BEN_ELIG_PSTN_PRTE_F
16450 and tr.table_alias = l_table_alias
16451 and cpe.number_of_copies = 1 -- ADDITION
16452 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
16453 order by information1, information2; --added for bug: 5151945
16454 --
16455 --
16456 cursor c_EPS_min_max_dates(c_table_route_id number,
16457 c_information1 number) is
16458 select
16459 min(cpe.information2) min_esd,
16460 max(cpe.information3) min_eed
16461 from ben_copy_entity_results cpe
16462 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16463 and cpe.table_route_id = c_table_route_id
16464 and cpe.information1 = c_information1 ;
16465 --
16466 cursor c_EPS(c_table_route_id number,
16467 c_information1 number,
16468 c_information2 date,
16469 c_information3 date ) is
16470 select
16471 cpe.*
16472 from ben_copy_entity_results cpe
16473 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16474 and cpe.table_route_id = c_table_route_id
16475 and cpe.information1 = c_information1
16476 and cpe.information2 = c_information2
16477 and cpe.information3 = c_information3
16478 and rownum = 1 ;
16479 -- Date Track target record
16480 cursor c_find_EPS_in_target(
16481 c_effective_start_date date,
16482 c_effective_end_date date,
16483 c_business_group_id number,
16484 c_new_pk_id number) is
16485 select
16486 EPS.elig_pstn_prte_id new_value
16487 from BEN_ELIG_PSTN_PRTE_F EPS
16488 where
16489 EPS.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
16490 EPS.POSITION_ID = l_POSITION_ID and
16491 EPS.business_group_id = c_business_group_id
16492 and EPS.elig_pstn_prte_id <> c_new_pk_id
16493 and c_effective_start_date between effective_start_date
16494 and effective_end_date ;
16495 --END TEMPIK
16496 /*TEMPIK
16497 and exists ( select null
16498 from BEN_ELIG_PSTN_PRTE_F EPS1
16499 where
16500 EPS1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
16501 EPS1.POSITION_ID = l_POSITION_ID and
16502 EPS1.business_group_id = c_business_group_id
16503 and EPS1.effective_start_date <= c_effective_start_date )
16504 and exists ( select null
16505 from BEN_ELIG_PSTN_PRTE_F EPS2
16506 where
16507 EPS2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
16508 EPS2.POSITION_ID = l_POSITION_ID and
16509 EPS2.business_group_id = c_business_group_id
16510 and EPS2.effective_end_date >= c_effective_end_date )
16511 ;
16512 TEMPIK */
16513 --TEMPIK
16514 l_dt_rec_found boolean ;
16515 --END TEMPIK
16516 --
16517
16518 --UPD START
16519 --
16520 l_update boolean := false ;
16521 l_datetrack_mode varchar2(80) := hr_api.g_update;
16522 l_process_date date;
16523 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
16524 --
16525 --UPD END
16526 l_current_pk_id number := null ;
16527
16528 l_prev_pk_id number := null ;
16529 l_first_rec boolean := true ;
16530 r_EPS c_EPS%rowtype;
16531 l_elig_pstn_prte_id number ;
16532 l_object_version_number number ;
16533 l_effective_start_date date ;
16534 l_effective_end_date date ;
16535 l_prefix pqh_copy_entity_attribs.information1%type := null;
16536 l_suffix pqh_copy_entity_attribs.information1%type := null;
16537 l_new_value number(15);
16538 l_object_found_in_target boolean := false ;
16539 l_min_esd date;
16540 l_max_eed date;
16541 l_effective_date date;
16542 --
16543 begin
16544 -- Initialization
16545 l_object_found_in_target := false ;
16546 -- End Initialization
16547 -- Derive the prefix - sufix
16548 if p_prefix_suffix_cd = 'PREFIX' then
16549 l_prefix := p_prefix_suffix_text ;
16550 elsif p_prefix_suffix_cd = 'SUFFIX' then
16551 l_suffix := p_prefix_suffix_text ;
16552 else
16553 l_prefix := null ;
16554 l_suffix := null ;
16555 end if ;
16556 -- End Prefix Sufix derivation
16557 for r_EPS_unique in c_unique_EPS('EPS') loop
16558
16559 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
16560 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16561 r_EPS_unique.information3 >=
16562 ben_pd_copy_to_ben_one.g_copy_effective_date)
16563 ) then
16564 --
16565 hr_utility.set_location(' r_EPS_unique.table_route_id '||r_EPS_unique.table_route_id,10);
16566 hr_utility.set_location(' r_EPS_unique.information1 '||r_EPS_unique.information1,10);
16567 hr_utility.set_location( 'r_EPS_unique.information2 '||r_EPS_unique.information2,10);
16568 hr_utility.set_location( 'r_EPS_unique.information3 '||r_EPS_unique.information3,10);
16569 -- If reuse objects flag is 'Y' then check for the object in the target business group
16570 -- if found insert the record into PLSql table and exit the loop else try create the
16571 -- object in the target business group
16572 --
16573 l_object_found_in_target := false ;
16574 --UPD START
16575 l_update := false;
16576 l_process_date := p_effective_date;
16577 l_dml_operation:= r_EPS_unique.dml_operation ;
16578 --
16579 /**********************moved from below **********************/
16580 open c_EPS(r_EPS_unique.table_route_id,
16581 r_EPS_unique.information1,
16582 r_EPS_unique.information2,
16583 r_EPS_unique.information3 ) ;
16584 --
16585 fetch c_EPS into r_EPS ;
16586 --
16587 close c_EPS ;
16588 --
16589 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPS.INFORMATION263,l_dml_operation);
16590 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
16591 l_POSITION_ID := r_EPS.information176;
16592 else
16593 l_POSITION_ID := r_EPS.information174;
16594 end if;
16595
16596 /**********************************************************/
16597
16598 if l_dml_operation = 'UPDATE' then
16599 --
16600 l_object_found_in_target := TRUE;
16601 --
16602 if l_process_date between r_EPS_unique.information2 and r_EPS_unique.information3 then
16603 l_update := true;
16604 if r_EPS_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
16605 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PSTN_PRTE_ID' then
16606 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PSTN_PRTE_ID' ;
16607 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPS_unique.information1 ;
16608 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EPS_unique.information1 ;
16609 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16610 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPS_unique.table_route_id;
16611 --
16612 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
16613 --
16614 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16615 --
16616 -- log_data('EPS',l_new_value,l_prefix || r_EPS_unique.name|| l_suffix,'REUSED');
16617 --
16618 end if ;
16619 hr_utility.set_location( 'found record for update',10);
16620 --
16621 else
16622 --
16623 l_update := false;
16624 --
16625 end if;
16626 else
16627 --
16628 --UPD END
16629 l_min_esd := null ;
16630 l_max_eed := null ;
16631 open c_EPS_min_max_dates(r_EPS_unique.table_route_id, r_EPS_unique.information1 ) ;
16632 fetch c_EPS_min_max_dates into l_min_esd,l_max_eed ;
16633 --
16634
16635 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16636 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
16637 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
16638 end if;
16639 l_min_esd := greatest(l_min_esd,r_EPS_unique.information2);
16640 /**********************moved up from here **********************
16641 open c_EPS(r_EPS_unique.table_route_id,
16642 r_EPS_unique.information1,
16643 r_EPS_unique.information2,
16644 r_EPS_unique.information3 ) ;
16645 --
16646 fetch c_EPS into r_EPS ;
16647 --
16648 close c_EPS ;
16649 --
16650 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPS.INFORMATION263,l_dml_operation);
16651 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
16652 l_POSITION_ID := r_EPS.information176;
16653 else
16654 l_POSITION_ID := r_EPS.information174;
16655 end if;
16656
16657 **********************************************************/
16658
16659 --
16660 if l_POSITION_ID is null then
16661 close c_EPS_min_max_dates;
16662 --
16663 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
16664 ,p_parent_pk_id => r_EPS.information263
16665 ,p_copy_entity_txn_id => p_copy_entity_txn_id
16666 ,p_child_table_alias => 'EPS'
16667 ,p_child_data => r_EPS.information173 );
16668
16669 --
16670 else
16671 if p_reuse_object_flag = 'Y' then
16672 if c_EPS_min_max_dates%found then
16673 -- cursor to find the object
16674 open c_find_EPS_in_target( l_min_esd,l_max_eed,
16675 p_target_business_group_id, nvl(l_elig_pstn_prte_id, -999) ) ;
16676 fetch c_find_EPS_in_target into l_new_value ;
16677 if c_find_EPS_in_target%found then
16678 --
16679 --TEMPIK
16680 l_dt_rec_found := dt_api.check_min_max_dates
16681 (p_base_table_name => 'BEN_ELIG_PSTN_PRTE_F',
16682 p_base_key_column => 'ELIG_PSTN_PRTE_ID',
16683 p_base_key_value => l_new_value,
16684 p_from_date => l_min_esd,
16685 p_to_date => l_max_eed );
16686 if l_dt_rec_found THEN
16687 --END TEMPIK
16688 if r_EPS_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
16689 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PSTN_PRTE_ID' then
16690 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PSTN_PRTE_ID' ;
16691 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPS_unique.information1 ;
16692 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
16693 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16694 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPS_unique.table_route_id;
16695 --
16696 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
16697 --
16698 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16699 end if ;
16700 --
16701 l_object_found_in_target := true ;
16702 --TEMPIK
16703 end if; -- l_dt_rec_found
16704 --END TEMPIK
16705 end if;
16706 close c_find_EPS_in_target ;
16707 --
16708 end if;
16709 end if ;
16710 --
16711 close c_EPS_min_max_dates ;
16712
16713 end if; -- bug 4565106
16714
16715 end if; --if p_dml_operation
16716 --
16717 if ( not l_object_found_in_target OR l_update ) and ( l_POSITION_ID is not null) then -- bug# 4251900
16718
16719 --
16720 l_current_pk_id := r_EPS.information1;
16721 --
16722 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
16723 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
16724 --
16725 if l_current_pk_id = l_prev_pk_id then
16726 --
16727 l_first_rec := false ;
16728 --
16729 else
16730 --
16731 l_first_rec := true ;
16732 --
16733 end if ;
16734 --
16735
16736 l_effective_date := r_EPS.information2;
16737 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16738 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
16739 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
16740 end if;
16741
16742 if l_first_rec and not l_update then
16743 -- Call Create routine.
16744 hr_utility.set_location(' BEN_ELIG_PSTN_PRTE_F CREATE_ELIG_PSTN_PRTE ',20);
16745 BEN_ELIG_PSTN_PRTE_API.CREATE_ELIG_PSTN_PRTE(
16746 --
16747 P_VALIDATE => false
16748 ,P_EFFECTIVE_DATE => l_effective_date
16749 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16750 --
16751 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
16752 ,P_ELIG_PSTN_PRTE_ID => l_elig_pstn_prte_id
16753 ,P_EPS_ATTRIBUTE1 => r_EPS.INFORMATION111
16754 ,P_EPS_ATTRIBUTE10 => r_EPS.INFORMATION120
16755 ,P_EPS_ATTRIBUTE11 => r_EPS.INFORMATION121
16756 ,P_EPS_ATTRIBUTE12 => r_EPS.INFORMATION122
16757 ,P_EPS_ATTRIBUTE13 => r_EPS.INFORMATION123
16758 ,P_EPS_ATTRIBUTE14 => r_EPS.INFORMATION124
16759 ,P_EPS_ATTRIBUTE15 => r_EPS.INFORMATION125
16760 ,P_EPS_ATTRIBUTE16 => r_EPS.INFORMATION126
16761 ,P_EPS_ATTRIBUTE17 => r_EPS.INFORMATION127
16762 ,P_EPS_ATTRIBUTE18 => r_EPS.INFORMATION128
16763 ,P_EPS_ATTRIBUTE19 => r_EPS.INFORMATION129
16764 ,P_EPS_ATTRIBUTE2 => r_EPS.INFORMATION112
16765 ,P_EPS_ATTRIBUTE20 => r_EPS.INFORMATION130
16766 ,P_EPS_ATTRIBUTE21 => r_EPS.INFORMATION131
16767 ,P_EPS_ATTRIBUTE22 => r_EPS.INFORMATION132
16768 ,P_EPS_ATTRIBUTE23 => r_EPS.INFORMATION133
16769 ,P_EPS_ATTRIBUTE24 => r_EPS.INFORMATION134
16770 ,P_EPS_ATTRIBUTE25 => r_EPS.INFORMATION135
16771 ,P_EPS_ATTRIBUTE26 => r_EPS.INFORMATION136
16772 ,P_EPS_ATTRIBUTE27 => r_EPS.INFORMATION137
16773 ,P_EPS_ATTRIBUTE28 => r_EPS.INFORMATION138
16774 ,P_EPS_ATTRIBUTE29 => r_EPS.INFORMATION139
16775 ,P_EPS_ATTRIBUTE3 => r_EPS.INFORMATION113
16776 ,P_EPS_ATTRIBUTE30 => r_EPS.INFORMATION140
16777 ,P_EPS_ATTRIBUTE4 => r_EPS.INFORMATION114
16778 ,P_EPS_ATTRIBUTE5 => r_EPS.INFORMATION115
16779 ,P_EPS_ATTRIBUTE6 => r_EPS.INFORMATION116
16780 ,P_EPS_ATTRIBUTE7 => r_EPS.INFORMATION117
16781 ,P_EPS_ATTRIBUTE8 => r_EPS.INFORMATION118
16782 ,P_EPS_ATTRIBUTE9 => r_EPS.INFORMATION119
16783 ,P_EPS_ATTRIBUTE_CATEGORY => r_EPS.INFORMATION110
16784 ,P_EXCLD_FLAG => r_EPS.INFORMATION11
16785 ,P_ORDR_NUM => r_EPS.INFORMATION261
16786 ,P_POSITION_ID => l_POSITION_ID
16787 --
16788 -- ****** END CHANGE LINES
16789
16790 --
16791
16792 ,P_EFFECTIVE_START_DATE => l_effective_start_date
16793 ,P_EFFECTIVE_END_DATE => l_effective_end_date
16794 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16795 ,P_CRITERIA_SCORE => r_eps.INFORMATION295
16796 ,P_CRITERIA_WEIGHT => r_eps.INFORMATION296
16797 );
16798 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16799 -- Update all relevent cer records with new pk_id
16800 hr_utility.set_location('Before plsql table ',222);
16801 hr_utility.set_location('new_value id '||l_elig_pstn_prte_id,222);
16802 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PSTN_PRTE_ID' ;
16803 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPS.information1 ;
16804 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_PSTN_PRTE_ID ;
16805 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
16806 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPS_unique.table_route_id;
16807 hr_utility.set_location('After plsql table ',222);
16808 --
16809 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
16810 --
16811 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16812 --
16813 else
16814 --
16815 -- Call Update routine for the pk_id created in prev run .
16816 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16817 hr_utility.set_location(' BEN_ELIG_PSTN_PRTE_F UPDATE_ELIG_PSTN_PRTE ',30);
16818 --UPD START
16819 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
16820 --
16821 if l_update then
16822 --
16823 l_datetrack_mode := r_EPS.datetrack_mode ;
16824 --
16825 get_dt_modes(
16826 p_effective_date => l_process_date,
16827 p_effective_end_date => r_EPS.information3,
16828 p_effective_start_date => r_EPS.information2,
16829 p_dml_operation => r_EPS.dml_operation,
16830 p_datetrack_mode => l_datetrack_mode );
16831 -- p_update => l_update
16832 --
16833 l_effective_date := l_process_date;
16834 l_ELIG_PSTN_PRTE_ID := r_EPS.information1;
16835 l_object_version_number := r_EPS.information265;
16836 --
16837 end if;
16838 --
16839 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
16840 --
16841 IF l_update OR l_dml_operation <> 'UPDATE' THEN
16842 --UPD END
16843
16844
16845 BEN_ELIG_PSTN_PRTE_API.UPDATE_ELIG_PSTN_PRTE(
16846 --
16847 P_VALIDATE => false
16848 ,P_EFFECTIVE_DATE => l_effective_date
16849 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16850 --
16851 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
16852 ,P_ELIG_PSTN_PRTE_ID => l_elig_pstn_prte_id
16853 ,P_EPS_ATTRIBUTE1 => r_EPS.INFORMATION111
16854 ,P_EPS_ATTRIBUTE10 => r_EPS.INFORMATION120
16855 ,P_EPS_ATTRIBUTE11 => r_EPS.INFORMATION121
16856 ,P_EPS_ATTRIBUTE12 => r_EPS.INFORMATION122
16857 ,P_EPS_ATTRIBUTE13 => r_EPS.INFORMATION123
16858 ,P_EPS_ATTRIBUTE14 => r_EPS.INFORMATION124
16859 ,P_EPS_ATTRIBUTE15 => r_EPS.INFORMATION125
16860 ,P_EPS_ATTRIBUTE16 => r_EPS.INFORMATION126
16861 ,P_EPS_ATTRIBUTE17 => r_EPS.INFORMATION127
16862 ,P_EPS_ATTRIBUTE18 => r_EPS.INFORMATION128
16863 ,P_EPS_ATTRIBUTE19 => r_EPS.INFORMATION129
16864 ,P_EPS_ATTRIBUTE2 => r_EPS.INFORMATION112
16865 ,P_EPS_ATTRIBUTE20 => r_EPS.INFORMATION130
16866 ,P_EPS_ATTRIBUTE21 => r_EPS.INFORMATION131
16867 ,P_EPS_ATTRIBUTE22 => r_EPS.INFORMATION132
16868 ,P_EPS_ATTRIBUTE23 => r_EPS.INFORMATION133
16869 ,P_EPS_ATTRIBUTE24 => r_EPS.INFORMATION134
16870 ,P_EPS_ATTRIBUTE25 => r_EPS.INFORMATION135
16871 ,P_EPS_ATTRIBUTE26 => r_EPS.INFORMATION136
16872 ,P_EPS_ATTRIBUTE27 => r_EPS.INFORMATION137
16873 ,P_EPS_ATTRIBUTE28 => r_EPS.INFORMATION138
16874 ,P_EPS_ATTRIBUTE29 => r_EPS.INFORMATION139
16875 ,P_EPS_ATTRIBUTE3 => r_EPS.INFORMATION113
16876 ,P_EPS_ATTRIBUTE30 => r_EPS.INFORMATION140
16877 ,P_EPS_ATTRIBUTE4 => r_EPS.INFORMATION114
16878 ,P_EPS_ATTRIBUTE5 => r_EPS.INFORMATION115
16879 ,P_EPS_ATTRIBUTE6 => r_EPS.INFORMATION116
16880 ,P_EPS_ATTRIBUTE7 => r_EPS.INFORMATION117
16881 ,P_EPS_ATTRIBUTE8 => r_EPS.INFORMATION118
16882 ,P_EPS_ATTRIBUTE9 => r_EPS.INFORMATION119
16883 ,P_EPS_ATTRIBUTE_CATEGORY => r_EPS.INFORMATION110
16884 ,P_EXCLD_FLAG => r_EPS.INFORMATION11
16885 ,P_ORDR_NUM => r_EPS.INFORMATION261
16886 ,P_POSITION_ID => l_POSITION_ID
16887 --
16888 -- ****** END CHANGE LINES
16889
16890 --
16891 ,P_EFFECTIVE_START_DATE => l_effective_start_date
16892 ,P_EFFECTIVE_END_DATE => l_effective_end_date
16893 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16894 ,P_DATETRACK_MODE => l_datetrack_mode
16895 ,P_CRITERIA_SCORE => r_eps.INFORMATION295
16896 ,P_CRITERIA_WEIGHT => r_eps.INFORMATION296
16897 );
16898 end if; -- l_update
16899 --
16900 end if;
16901 --
16902 -- Delete the row if it is end dated.
16903 --
16904 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
16905 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
16906 trunc(l_max_eed) = trunc(r_EPS.information3)) then
16907 --
16908 BEN_ELIG_PSTN_PRTE_API.delete_ELIG_PSTN_PRTE(
16909 --
16910 p_validate => false
16911 ,p_elig_pstn_prte_id => l_elig_pstn_prte_id
16912 ,p_effective_start_date => l_effective_start_date
16913 ,p_effective_end_date => l_effective_end_date
16914 ,p_object_version_number => l_object_version_number
16915 ,p_effective_date => l_max_eed
16916 ,p_datetrack_mode => hr_api.g_delete
16917 --
16918 );
16919 --
16920 end if;
16921 --
16922 l_prev_pk_id := l_current_pk_id ;
16923 --
16924 -- end if; ---- bug 4565106
16925 --
16926 end if;
16927 --
16928 end if;
16929 --
16930 end loop;
16931 --
16932 exception when others then
16933 --
16934 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EPS',r_EPS.information5 ) ;
16935 --
16936 end create_EPS_rows;
16937
16938 --
16939 ---------------------------------------------------------------
16940 ----------------------< create_EPY_rows >-----------------------
16941 ---------------------------------------------------------------
16942 --
16943 procedure create_EPY_rows
16944 (
16945 p_validate in number default 0
16946 ,p_copy_entity_txn_id in number
16947 ,p_effective_date in date
16948 ,p_prefix_suffix_text in varchar2 default null
16949 ,p_reuse_object_flag in varchar2 default null
16950 ,p_target_business_group_id in varchar2 default null
16951 ,p_prefix_suffix_cd in varchar2 default null
16952 ) is
16953 --
16954 l_ELIGY_PRFL_ID number;
16955 l_PAYROLL_ID number;
16956 cursor c_unique_EPY(l_table_alias varchar2) is
16957 select distinct cpe.information1,
16958 cpe.information2,
16959 cpe.information3,
16960 cpe.table_route_id
16961 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
16962 pqh_table_route tr
16963 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16964 and cpe.table_route_id = tr.table_route_id
16965 -- and tr.where_clause = l_BEN_ELIG_PYRL_PRTE_F
16966 and tr.table_alias = l_table_alias
16967 and cpe.number_of_copies = 1 -- ADDITION
16968 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
16969 order by information1, information2; --added for bug: 5151945
16970 --
16971 --
16972 cursor c_EPY_min_max_dates(c_table_route_id number,
16973 c_information1 number) is
16974 select
16975 min(cpe.information2) min_esd,
16976 max(cpe.information3) min_eed
16977 from ben_copy_entity_results cpe
16978 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16979 and cpe.table_route_id = c_table_route_id
16980 and cpe.information1 = c_information1 ;
16981 --
16982 cursor c_EPY(c_table_route_id number,
16983 c_information1 number,
16984 c_information2 date,
16985 c_information3 date ) is
16986 select
16987 cpe.*
16988 from ben_copy_entity_results cpe
16989 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16990 and cpe.table_route_id = c_table_route_id
16991 and cpe.information1 = c_information1
16992 and cpe.information2 = c_information2
16993 and cpe.information3 = c_information3
16994 and rownum = 1 ;
16995 -- Date Track target record
16996 cursor c_find_EPY_in_target(
16997 c_effective_start_date date,
16998 c_effective_end_date date,
16999 c_business_group_id number,
17000 c_new_pk_id number) is
17001 select
17002 EPY.elig_pyrl_prte_id new_value
17003 from BEN_ELIG_PYRL_PRTE_F EPY
17004 where
17005 EPY.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
17006 EPY.PAYROLL_ID = l_PAYROLL_ID and
17007 EPY.business_group_id = c_business_group_id
17008 and EPY.elig_pyrl_prte_id <> c_new_pk_id
17009 and c_effective_start_date between effective_start_date
17010 and effective_end_date ;
17011 --END TEMPIK
17012 /*TEMPIK
17013 and exists ( select null
17014 from BEN_ELIG_PYRL_PRTE_F EPY1
17015 where
17016 EPY1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
17017 EPY1.PAYROLL_ID = l_PAYROLL_ID and
17018 EPY1.business_group_id = c_business_group_id
17019 and EPY1.effective_start_date <= c_effective_start_date )
17020 and exists ( select null
17021 from BEN_ELIG_PYRL_PRTE_F EPY2
17022 where
17023 EPY2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
17024 EPY2.PAYROLL_ID = l_PAYROLL_ID and
17025 EPY2.business_group_id = c_business_group_id
17026 and EPY2.effective_end_date >= c_effective_end_date )
17027 ;
17028 TEMPIK */
17029 --TEMPIK
17030 l_dt_rec_found boolean ;
17031 --END TEMPIK
17032 --
17033
17034 --UPD START
17035 --
17036 l_update boolean := false ;
17037 l_datetrack_mode varchar2(80) := hr_api.g_update;
17038 l_process_date date;
17039 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
17040 --
17041 --UPD END
17042 l_current_pk_id number := null ;
17043
17044 l_prev_pk_id number := null ;
17045 l_first_rec boolean := true ;
17046 r_EPY c_EPY%rowtype;
17047 l_elig_pyrl_prte_id number ;
17048 l_object_version_number number ;
17049 l_effective_start_date date ;
17050 l_effective_end_date date ;
17051 l_prefix pqh_copy_entity_attribs.information1%type := null;
17052 l_suffix pqh_copy_entity_attribs.information1%type := null;
17053 l_new_value number(15);
17054 l_object_found_in_target boolean := false ;
17055 l_min_esd date;
17056 l_max_eed date;
17057 l_effective_date date;
17058 --
17059 begin
17060 -- Initialization
17061 l_object_found_in_target := false ;
17062 -- End Initialization
17063 -- Derive the prefix - sufix
17064 if p_prefix_suffix_cd = 'PREFIX' then
17065 l_prefix := p_prefix_suffix_text ;
17066 elsif p_prefix_suffix_cd = 'SUFFIX' then
17067 l_suffix := p_prefix_suffix_text ;
17068 else
17069 l_prefix := null ;
17070 l_suffix := null ;
17071 end if ;
17072 -- End Prefix Sufix derivation
17073 for r_EPY_unique in c_unique_EPY('EPY') loop
17074
17075 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
17076 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17077 r_EPY_unique.information3 >=
17078 ben_pd_copy_to_ben_one.g_copy_effective_date)
17079 ) then
17080 --
17081 hr_utility.set_location(' r_EPY_unique.table_route_id '||r_EPY_unique.table_route_id,10);
17082 hr_utility.set_location(' r_EPY_unique.information1 '||r_EPY_unique.information1,10);
17083 hr_utility.set_location( 'r_EPY_unique.information2 '||r_EPY_unique.information2,10);
17084 hr_utility.set_location( 'r_EPY_unique.information3 '||r_EPY_unique.information3,10);
17085 -- If reuse objects flag is 'Y' then check for the object in the target business group
17086 -- if found insert the record into PLSql table and exit the loop else try create the
17087 -- object in the target business group
17088 --
17089 l_object_found_in_target := false ;
17090 --UPD START
17091 l_update := false;
17092 l_process_date := p_effective_date;
17093 l_dml_operation:= r_EPY_unique.dml_operation ;
17094 --
17095 /**********************moved from below **********************/
17096 open c_EPY(r_EPY_unique.table_route_id,
17097 r_EPY_unique.information1,
17098 r_EPY_unique.information2,
17099 r_EPY_unique.information3 ) ;
17100 --
17101 fetch c_EPY into r_EPY ;
17102 --
17103 close c_EPY ;
17104 --
17105 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPY.INFORMATION263,l_dml_operation);
17106 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
17107 l_PAYROLL_ID := r_EPY.information176;
17108 else
17109 l_PAYROLL_ID := r_EPY.information174;
17110 end if;
17111
17112 /**********************************************************/
17113
17114 if l_dml_operation = 'UPDATE' then
17115 --
17116 l_object_found_in_target := TRUE;
17117 --
17118 if l_process_date between r_EPY_unique.information2 and r_EPY_unique.information3 then
17119 l_update := true;
17120 if r_EPY_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
17121 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PYRL_PRTE_ID' then
17122 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PYRL_PRTE_ID' ;
17123 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPY_unique.information1 ;
17124 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EPY_unique.information1 ;
17125 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
17126 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPY_unique.table_route_id;
17127 --
17128 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
17129 --
17130 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17131 --
17132 -- log_data('EPY',l_new_value,l_prefix || r_EPY_unique.name|| l_suffix,'REUSED');
17133 --
17134 end if ;
17135 hr_utility.set_location( 'found record for update',10);
17136 --
17137 else
17138 --
17139 l_update := false;
17140 --
17141 end if;
17142 else
17143 --
17144 --UPD END
17145 l_min_esd := null ;
17146 l_max_eed := null ;
17147 open c_EPY_min_max_dates(r_EPY_unique.table_route_id, r_EPY_unique.information1 ) ;
17148 fetch c_EPY_min_max_dates into l_min_esd,l_max_eed ;
17149 --
17150
17151 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17152 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
17153 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
17154 end if;
17155 l_min_esd := greatest(l_min_esd,r_EPY_unique.information2);
17156 /**********************moved up from here **********************
17157 open c_EPY(r_EPY_unique.table_route_id,
17158 r_EPY_unique.information1,
17159 r_EPY_unique.information2,
17160 r_EPY_unique.information3 ) ;
17161 --
17162 fetch c_EPY into r_EPY ;
17163 --
17164 close c_EPY ;
17165 --
17166 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPY.INFORMATION263,l_dml_operation);
17167 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
17168 l_PAYROLL_ID := r_EPY.information176;
17169 else
17170 l_PAYROLL_ID := r_EPY.information174;
17171 end if;
17172
17173 **********************************************************/
17174
17175 --
17176 if l_PAYROLL_ID is null then
17177 close c_EPY_min_max_dates;
17178 --
17179 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
17180 ,p_parent_pk_id => r_EPY.information263
17181 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17182 ,p_child_table_alias => 'EPY'
17183 ,p_child_data => r_EPY.information173 );
17184
17185 --
17186 else
17187 if p_reuse_object_flag = 'Y' then
17188 if c_EPY_min_max_dates%found then
17189 -- cursor to find the object
17190 open c_find_EPY_in_target( l_min_esd,l_max_eed,
17191 p_target_business_group_id, nvl(l_elig_pyrl_prte_id, -999) ) ;
17192 fetch c_find_EPY_in_target into l_new_value ;
17193 if c_find_EPY_in_target%found then
17194 --
17195 --TEMPIK
17196 l_dt_rec_found := dt_api.check_min_max_dates
17197 (p_base_table_name => 'BEN_ELIG_PYRL_PRTE_F',
17198 p_base_key_column => 'ELIG_PYRL_PRTE_ID',
17199 p_base_key_value => l_new_value,
17200 p_from_date => l_min_esd,
17201 p_to_date => l_max_eed );
17202 if l_dt_rec_found THEN
17203 --END TEMPIK
17204 if r_EPY_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
17205 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PYRL_PRTE_ID' then
17206 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PYRL_PRTE_ID' ;
17207 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPY_unique.information1 ;
17208 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
17209 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
17210 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPY_unique.table_route_id;
17211 --
17212 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
17213 --
17214 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17215 end if ;
17216 --
17217 l_object_found_in_target := true ;
17218 --TEMPIK
17219 end if; -- l_dt_rec_found
17220 --END TEMPIK
17221 end if;
17222 close c_find_EPY_in_target ;
17223 --
17224 end if;
17225 end if ;
17226 --
17227 close c_EPY_min_max_dates ;
17228 end if; --if p_dml_operation
17229 --
17230 if (not l_object_found_in_target OR l_update ) and l_payroll_id is not null then
17231
17232 --
17233 l_current_pk_id := r_EPY.information1;
17234 --
17235 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
17236 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
17237 --
17238 if l_current_pk_id = l_prev_pk_id then
17239 --
17240 l_first_rec := false ;
17241 --
17242 else
17243 --
17244 l_first_rec := true ;
17245 --
17246 end if ;
17247 --
17248
17249 l_effective_date := r_EPY.information2;
17250 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17251 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
17252 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
17253 end if;
17254
17255 if l_first_rec and not l_update then
17256 -- Call Create routine.
17257 hr_utility.set_location(' BEN_ELIG_PYRL_PRTE_F CREATE_ELIG_PYRL_PRTE ',20);
17258 BEN_ELIG_PYRL_PRTE_API.CREATE_ELIG_PYRL_PRTE(
17259 --
17260 P_VALIDATE => false
17261 ,P_EFFECTIVE_DATE => l_effective_date
17262 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
17263 --
17264 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
17265 ,P_ELIG_PYRL_PRTE_ID => l_elig_pyrl_prte_id
17266 ,P_EPY_ATTRIBUTE1 => r_EPY.INFORMATION111
17267 ,P_EPY_ATTRIBUTE10 => r_EPY.INFORMATION120
17268 ,P_EPY_ATTRIBUTE11 => r_EPY.INFORMATION121
17269 ,P_EPY_ATTRIBUTE12 => r_EPY.INFORMATION122
17270 ,P_EPY_ATTRIBUTE13 => r_EPY.INFORMATION123
17271 ,P_EPY_ATTRIBUTE14 => r_EPY.INFORMATION124
17272 ,P_EPY_ATTRIBUTE15 => r_EPY.INFORMATION125
17273 ,P_EPY_ATTRIBUTE16 => r_EPY.INFORMATION126
17274 ,P_EPY_ATTRIBUTE17 => r_EPY.INFORMATION127
17275 ,P_EPY_ATTRIBUTE18 => r_EPY.INFORMATION128
17276 ,P_EPY_ATTRIBUTE19 => r_EPY.INFORMATION129
17277 ,P_EPY_ATTRIBUTE2 => r_EPY.INFORMATION112
17278 ,P_EPY_ATTRIBUTE20 => r_EPY.INFORMATION130
17279 ,P_EPY_ATTRIBUTE21 => r_EPY.INFORMATION131
17280 ,P_EPY_ATTRIBUTE22 => r_EPY.INFORMATION132
17281 ,P_EPY_ATTRIBUTE23 => r_EPY.INFORMATION133
17282 ,P_EPY_ATTRIBUTE24 => r_EPY.INFORMATION134
17283 ,P_EPY_ATTRIBUTE25 => r_EPY.INFORMATION135
17284 ,P_EPY_ATTRIBUTE26 => r_EPY.INFORMATION136
17285 ,P_EPY_ATTRIBUTE27 => r_EPY.INFORMATION137
17286 ,P_EPY_ATTRIBUTE28 => r_EPY.INFORMATION138
17287 ,P_EPY_ATTRIBUTE29 => r_EPY.INFORMATION139
17288 ,P_EPY_ATTRIBUTE3 => r_EPY.INFORMATION113
17289 ,P_EPY_ATTRIBUTE30 => r_EPY.INFORMATION140
17290 ,P_EPY_ATTRIBUTE4 => r_EPY.INFORMATION114
17291 ,P_EPY_ATTRIBUTE5 => r_EPY.INFORMATION115
17292 ,P_EPY_ATTRIBUTE6 => r_EPY.INFORMATION116
17293 ,P_EPY_ATTRIBUTE7 => r_EPY.INFORMATION117
17294 ,P_EPY_ATTRIBUTE8 => r_EPY.INFORMATION118
17295 ,P_EPY_ATTRIBUTE9 => r_EPY.INFORMATION119
17296 ,P_EPY_ATTRIBUTE_CATEGORY => r_EPY.INFORMATION110
17297 ,P_EXCLD_FLAG => r_EPY.INFORMATION11
17298 ,P_ORDR_NUM => r_EPY.INFORMATION260
17299 ,P_PAYROLL_ID => l_PAYROLL_ID
17300 --
17301 -- ****** END CHANGE LINES
17302
17303 --
17304
17305 ,P_EFFECTIVE_START_DATE => l_effective_start_date
17306 ,P_EFFECTIVE_END_DATE => l_effective_end_date
17307 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
17308 ,P_CRITERIA_SCORE => r_epy.INFORMATION295
17309 ,P_CRITERIA_WEIGHT => r_epy.INFORMATION296
17310 );
17311 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
17312 -- Update all relevent cer records with new pk_id
17313 hr_utility.set_location('Before plsql table ',222);
17314 hr_utility.set_location('new_value id '||l_elig_pyrl_prte_id,222);
17315 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PYRL_PRTE_ID' ;
17316 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPY.information1 ;
17317 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_PYRL_PRTE_ID ;
17318 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
17319 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPY_unique.table_route_id;
17320 hr_utility.set_location('After plsql table ',222);
17321 --
17322 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
17323 --
17324 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17325 --
17326 else
17327 --
17328 -- Call Update routine for the pk_id created in prev run .
17329 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
17330 hr_utility.set_location(' BEN_ELIG_PYRL_PRTE_F UPDATE_ELIG_PYRL_PRTE ',30);
17331 --UPD START
17332 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
17333 --
17334 if l_update then
17335 --
17336 l_datetrack_mode := r_EPY.datetrack_mode ;
17337 --
17338 get_dt_modes(
17339 p_effective_date => l_process_date,
17340 p_effective_end_date => r_EPY.information3,
17341 p_effective_start_date => r_EPY.information2,
17342 p_dml_operation => r_EPY.dml_operation,
17343 p_datetrack_mode => l_datetrack_mode );
17344 -- p_update => l_update
17345 --
17346 l_effective_date := l_process_date;
17347 l_ELIG_PYRL_PRTE_ID := r_EPY.information1;
17348 l_object_version_number := r_EPY.information265;
17349 --
17350 end if;
17351 --
17352 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
17353 --
17354 IF l_update OR l_dml_operation <> 'UPDATE' THEN
17355 --UPD END
17356
17357
17358 BEN_ELIG_PYRL_PRTE_API.UPDATE_ELIG_PYRL_PRTE(
17359 --
17360 P_VALIDATE => false
17361 ,P_EFFECTIVE_DATE => l_effective_date
17362 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
17363 --
17364 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
17365 ,P_ELIG_PYRL_PRTE_ID => l_elig_pyrl_prte_id
17366 ,P_EPY_ATTRIBUTE1 => r_EPY.INFORMATION111
17367 ,P_EPY_ATTRIBUTE10 => r_EPY.INFORMATION120
17368 ,P_EPY_ATTRIBUTE11 => r_EPY.INFORMATION121
17369 ,P_EPY_ATTRIBUTE12 => r_EPY.INFORMATION122
17370 ,P_EPY_ATTRIBUTE13 => r_EPY.INFORMATION123
17371 ,P_EPY_ATTRIBUTE14 => r_EPY.INFORMATION124
17372 ,P_EPY_ATTRIBUTE15 => r_EPY.INFORMATION125
17373 ,P_EPY_ATTRIBUTE16 => r_EPY.INFORMATION126
17374 ,P_EPY_ATTRIBUTE17 => r_EPY.INFORMATION127
17375 ,P_EPY_ATTRIBUTE18 => r_EPY.INFORMATION128
17376 ,P_EPY_ATTRIBUTE19 => r_EPY.INFORMATION129
17377 ,P_EPY_ATTRIBUTE2 => r_EPY.INFORMATION112
17378 ,P_EPY_ATTRIBUTE20 => r_EPY.INFORMATION130
17379 ,P_EPY_ATTRIBUTE21 => r_EPY.INFORMATION131
17380 ,P_EPY_ATTRIBUTE22 => r_EPY.INFORMATION132
17381 ,P_EPY_ATTRIBUTE23 => r_EPY.INFORMATION133
17382 ,P_EPY_ATTRIBUTE24 => r_EPY.INFORMATION134
17383 ,P_EPY_ATTRIBUTE25 => r_EPY.INFORMATION135
17384 ,P_EPY_ATTRIBUTE26 => r_EPY.INFORMATION136
17385 ,P_EPY_ATTRIBUTE27 => r_EPY.INFORMATION137
17386 ,P_EPY_ATTRIBUTE28 => r_EPY.INFORMATION138
17387 ,P_EPY_ATTRIBUTE29 => r_EPY.INFORMATION139
17388 ,P_EPY_ATTRIBUTE3 => r_EPY.INFORMATION113
17389 ,P_EPY_ATTRIBUTE30 => r_EPY.INFORMATION140
17390 ,P_EPY_ATTRIBUTE4 => r_EPY.INFORMATION114
17391 ,P_EPY_ATTRIBUTE5 => r_EPY.INFORMATION115
17392 ,P_EPY_ATTRIBUTE6 => r_EPY.INFORMATION116
17393 ,P_EPY_ATTRIBUTE7 => r_EPY.INFORMATION117
17394 ,P_EPY_ATTRIBUTE8 => r_EPY.INFORMATION118
17395 ,P_EPY_ATTRIBUTE9 => r_EPY.INFORMATION119
17396 ,P_EPY_ATTRIBUTE_CATEGORY => r_EPY.INFORMATION110
17397 ,P_EXCLD_FLAG => r_EPY.INFORMATION11
17398 ,P_ORDR_NUM => r_EPY.INFORMATION260
17399 ,P_PAYROLL_ID => l_PAYROLL_ID
17400 --
17401 -- ****** END CHANGE LINES
17402
17403 --
17404 ,P_EFFECTIVE_START_DATE => l_effective_start_date
17405 ,P_EFFECTIVE_END_DATE => l_effective_end_date
17406 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
17407 ,P_DATETRACK_MODE => l_datetrack_mode
17408 ,P_CRITERIA_SCORE => r_epy.INFORMATION295
17409 ,P_CRITERIA_WEIGHT => r_epy.INFORMATION296
17410 );
17411 end if; -- l_update
17412 --
17413 end if;
17414 --
17415 -- Delete the row if it is end dated.
17416 --
17417 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
17418 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
17419 trunc(l_max_eed) = trunc(r_EPY.information3)) then
17420 --
17421 BEN_ELIG_PYRL_PRTE_API.delete_ELIG_PYRL_PRTE(
17422 --
17423 p_validate => false
17424 ,p_elig_pyrl_prte_id => l_elig_pyrl_prte_id
17425 ,p_effective_start_date => l_effective_start_date
17426 ,p_effective_end_date => l_effective_end_date
17427 ,p_object_version_number => l_object_version_number
17428 ,p_effective_date => l_max_eed
17429 ,p_datetrack_mode => hr_api.g_delete
17430 --
17431 );
17432 --
17433 end if;
17434 --
17435 l_prev_pk_id := l_current_pk_id ;
17436 --
17437 end if;
17438 --
17439 end if;
17440 --
17441 end if;
17442 --
17443 end loop;
17444 --
17445 exception when others then
17446 --
17447 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EPY',r_EPY.information5 ) ;
17448 --
17449 end create_EPY_rows;
17450
17451 --
17452 ---------------------------------------------------------------
17453 ----------------------< create_EPZ_rows >-----------------------
17454 ---------------------------------------------------------------
17455 --
17456 procedure create_EPZ_rows
17457 (
17458 p_validate in number default 0
17459 ,p_copy_entity_txn_id in number
17460 ,p_effective_date in date
17461 ,p_prefix_suffix_text in varchar2 default null
17462 ,p_reuse_object_flag in varchar2 default null
17463 ,p_target_business_group_id in varchar2 default null
17464 ,p_prefix_suffix_cd in varchar2 default null
17465 ) is
17466 --
17467 l_ELIGY_PRFL_ID number;
17468 l_PSTL_ZIP_RNG_ID number;
17469 cursor c_unique_EPZ(l_table_alias varchar2) is
17470 select distinct cpe.information1,
17471 cpe.information2,
17472 cpe.information3,
17473 cpe.table_route_id
17474 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
17475 pqh_table_route tr
17476 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17477 and cpe.table_route_id = tr.table_route_id
17478 -- and tr.where_clause = l_BEN_ELG_PSL_CD_R_RNG_PRTE_F
17479 and tr.table_alias = l_table_alias
17480 and cpe.number_of_copies = 1 -- ADDITION
17481 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
17482 order by information1, information2; --added for bug: 5151945
17483 --
17484 --
17485 cursor c_EPZ_min_max_dates(c_table_route_id number,
17486 c_information1 number) is
17487 select
17488 min(cpe.information2) min_esd,
17489 max(cpe.information3) min_eed
17490 from ben_copy_entity_results cpe
17491 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17492 and cpe.table_route_id = c_table_route_id
17493 and cpe.information1 = c_information1 ;
17494 --
17495 cursor c_EPZ(c_table_route_id number,
17496 c_information1 number,
17497 c_information2 date,
17498 c_information3 date ) is
17499 select
17500 cpe.*
17501 from ben_copy_entity_results cpe
17502 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17503 and cpe.table_route_id = c_table_route_id
17504 and cpe.information1 = c_information1
17505 and cpe.information2 = c_information2
17506 and cpe.information3 = c_information3
17507 and rownum = 1 ;
17508 -- Date Track target record
17509 cursor c_find_EPZ_in_target(
17510 c_effective_start_date date,
17511 c_effective_end_date date,
17512 c_business_group_id number,
17513 c_new_pk_id number) is
17514 select
17515 EPZ.elig_pstl_cd_r_rng_prte_id new_value
17516 from BEN_ELIG_PSTL_CD_R_RNG_PRTE_F EPZ
17517 where
17518 EPZ.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
17519 EPZ.PSTL_ZIP_RNG_ID = l_PSTL_ZIP_RNG_ID and
17520 EPZ.business_group_id = c_business_group_id
17521 and EPZ.elig_pstl_cd_r_rng_prte_id <> c_new_pk_id
17522 and c_effective_start_date between effective_start_date
17523 and effective_end_date ;
17524 --END TEMPIK
17525 /*TEMPIK
17526 and exists ( select null
17527 from BEN_ELIG_PSTL_CD_R_RNG_PRTE_F EPZ1
17528 where
17529 EPZ1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
17530 EPZ1.PSTL_ZIP_RNG_ID = l_PSTL_ZIP_RNG_ID and
17531 EPZ1.business_group_id = c_business_group_id
17532 and EPZ1.effective_start_date <= c_effective_start_date )
17533 and exists ( select null
17534 from BEN_ELIG_PSTL_CD_R_RNG_PRTE_F EPZ2
17535 where
17536 EPZ2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
17537 EPZ2.PSTL_ZIP_RNG_ID = l_PSTL_ZIP_RNG_ID and
17538 EPZ2.business_group_id = c_business_group_id
17539 and EPZ2.effective_end_date >= c_effective_end_date )
17540 ;
17541 TEMPIK */
17542 --TEMPIK
17543 l_dt_rec_found boolean ;
17544 --END TEMPIK
17545 --
17546
17547 --UPD START
17548 --
17549 l_update boolean := false ;
17550 l_datetrack_mode varchar2(80) := hr_api.g_update;
17551 l_process_date date;
17552 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
17553 --
17554 --UPD END
17555 l_current_pk_id number := null ;
17556
17557 l_prev_pk_id number := null ;
17558 l_first_rec boolean := true ;
17559 r_EPZ c_EPZ%rowtype;
17560 l_elig_pstl_cd_r_rng_prte_id number ;
17561 l_object_version_number number ;
17562 l_effective_start_date date ;
17563 l_effective_end_date date ;
17564 l_prefix pqh_copy_entity_attribs.information1%type := null;
17565 l_suffix pqh_copy_entity_attribs.information1%type := null;
17566 l_new_value number(15);
17567 l_object_found_in_target boolean := false ;
17568 l_min_esd date;
17569 l_max_eed date;
17570 l_effective_date date;
17571 --
17572 begin
17573 -- Initialization
17574 l_object_found_in_target := false ;
17575 -- End Initialization
17576 -- Derive the prefix - sufix
17577 if p_prefix_suffix_cd = 'PREFIX' then
17578 l_prefix := p_prefix_suffix_text ;
17579 elsif p_prefix_suffix_cd = 'SUFFIX' then
17580 l_suffix := p_prefix_suffix_text ;
17581 else
17582 l_prefix := null ;
17583 l_suffix := null ;
17584 end if ;
17585 -- End Prefix Sufix derivation
17586 for r_EPZ_unique in c_unique_EPZ('EPZ') loop
17587
17588 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
17589 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17590 r_EPZ_unique.information3 >=
17591 ben_pd_copy_to_ben_one.g_copy_effective_date)
17592 ) then
17593 --
17594 hr_utility.set_location(' r_EPZ_unique.table_route_id '||r_EPZ_unique.table_route_id,10);
17595 hr_utility.set_location(' r_EPZ_unique.information1 '||r_EPZ_unique.information1,10);
17596 hr_utility.set_location( 'r_EPZ_unique.information2 '||r_EPZ_unique.information2,10);
17597 hr_utility.set_location( 'r_EPZ_unique.information3 '||r_EPZ_unique.information3,10);
17598 -- If reuse objects flag is 'Y' then check for the object in the target business group
17599 -- if found insert the record into PLSql table and exit the loop else try create the
17600 -- object in the target business group
17601 --
17602 l_object_found_in_target := false ;
17603 --UPD START
17604 l_update := false;
17605 l_process_date := p_effective_date;
17606 l_dml_operation:= r_EPZ_unique.dml_operation ;
17607 --
17608 /**********************moved from below **********************/
17609 open c_EPZ(r_EPZ_unique.table_route_id,
17610 r_EPZ_unique.information1,
17611 r_EPZ_unique.information2,
17612 r_EPZ_unique.information3 ) ;
17613 --
17614 fetch c_EPZ into r_EPZ ;
17615 --
17616 close c_EPZ ;
17617 --
17618 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPZ.information263,l_dml_operation);
17619 l_PSTL_ZIP_RNG_ID := get_fk('PSTL_ZIP_RNG_ID', r_EPZ.information245,l_dml_operation);
17620
17621 /**********************************************************/
17622
17623 if l_dml_operation = 'UPDATE' then
17624 --
17625 l_object_found_in_target := TRUE;
17626 --
17627 if l_process_date between r_EPZ_unique.information2 and r_EPZ_unique.information3 then
17628 l_update := true;
17629 if r_EPZ_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
17630 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PSTL_CD_R_RNG_PRTE_ID' then
17631 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PSTL_CD_R_RNG_PRTE_ID' ;
17632 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPZ_unique.information1 ;
17633 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EPZ_unique.information1 ;
17634 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
17635 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPZ_unique.table_route_id;
17636 --
17637 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
17638 --
17639 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17640 --
17641 -- log_data('EPZ',l_new_value,l_prefix || r_EPZ_unique.name|| l_suffix,'REUSED');
17642 --
17643 end if ;
17644 hr_utility.set_location( 'found record for update',10);
17645 --
17646 else
17647 --
17648 l_update := false;
17649 --
17650 end if;
17651 else
17652 --
17653 --UPD END
17654 l_min_esd := null ;
17655 l_max_eed := null ;
17656 open c_EPZ_min_max_dates(r_EPZ_unique.table_route_id, r_EPZ_unique.information1 ) ;
17657 fetch c_EPZ_min_max_dates into l_min_esd,l_max_eed ;
17658 --
17659
17660 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17661 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
17662 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
17663 end if;
17664 l_min_esd := greatest(l_min_esd,r_EPZ_unique.information2);
17665 /**********************moved up from here **********************
17666 open c_EPZ(r_EPZ_unique.table_route_id,
17667 r_EPZ_unique.information1,
17668 r_EPZ_unique.information2,
17669 r_EPZ_unique.information3 ) ;
17670 --
17671 fetch c_EPZ into r_EPZ ;
17672 --
17673 close c_EPZ ;
17674 --
17675 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EPZ.information263,l_dml_operation);
17676 l_PSTL_ZIP_RNG_ID := get_fk('PSTL_ZIP_RNG_ID', r_EPZ.information245,l_dml_operation);
17677
17678 **********************************************************/
17679
17680 if p_reuse_object_flag = 'Y' then
17681 if c_EPZ_min_max_dates%found then
17682 -- cursor to find the object
17683 open c_find_EPZ_in_target( l_min_esd,l_max_eed,
17684 p_target_business_group_id, nvl(l_elig_pstl_cd_r_rng_prte_id, -999) ) ;
17685 fetch c_find_EPZ_in_target into l_new_value ;
17686 if c_find_EPZ_in_target%found then
17687 --
17688 --TEMPIK
17689 l_dt_rec_found := dt_api.check_min_max_dates
17690 (p_base_table_name => 'BEN_ELIG_PSTL_CD_R_RNG_PRTE_F',
17691 p_base_key_column => 'ELIG_PSTL_CD_R_RNG_PRTE_ID',
17692 p_base_key_value => l_new_value,
17693 p_from_date => l_min_esd,
17694 p_to_date => l_max_eed );
17695 if l_dt_rec_found THEN
17696 --END TEMPIK
17697 if r_EPZ_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
17698 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PSTL_CD_R_RNG_PRTE_ID' then
17699 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PSTL_CD_R_RNG_PRTE_ID' ;
17700 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPZ_unique.information1 ;
17701 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
17702 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
17703 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPZ_unique.table_route_id;
17704 --
17705 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
17706 --
17707 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17708 end if ;
17709 --
17710 l_object_found_in_target := true ;
17711 --TEMPIK
17712 end if; -- l_dt_rec_found
17713 --END TEMPIK
17714 end if;
17715 close c_find_EPZ_in_target ;
17716 --
17717 end if;
17718 end if ;
17719 --
17720 close c_EPZ_min_max_dates ;
17721 end if; --if p_dml_operation
17722 --
17723 if not l_object_found_in_target OR l_update then
17724
17725 --
17726 l_current_pk_id := r_EPZ.information1;
17727 --
17728 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
17729 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
17730 --
17731 if l_current_pk_id = l_prev_pk_id then
17732 --
17733 l_first_rec := false ;
17734 --
17735 else
17736 --
17737 l_first_rec := true ;
17738 --
17739 end if ;
17740 --
17741
17742 l_effective_date := r_EPZ.information2;
17743 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17744 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
17745 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
17746 end if;
17747
17748 if l_first_rec and not l_update then
17749 -- Call Create routine.
17750 hr_utility.set_location(' BEN_ELIG_PSTL_CD_R_RNG_PRTE_F CREATE_ELIG_PSTL_CD_RNG_PRTE ',20);
17751 BEN_ELIG_PSTL_CD_RNG_PRTE_API.CREATE_ELIG_PSTL_CD_RNG_PRTE(
17752 --
17753 P_VALIDATE => false
17754 ,P_EFFECTIVE_DATE => l_effective_date
17755 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
17756 --
17757 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
17758 ,P_ELIG_PSTL_CD_R_RNG_PRTE_ID => l_elig_pstl_cd_r_rng_prte_id
17759 ,P_EPZ_ATTRIBUTE1 => r_EPZ.INFORMATION111
17760 ,P_EPZ_ATTRIBUTE10 => r_EPZ.INFORMATION120
17761 ,P_EPZ_ATTRIBUTE11 => r_EPZ.INFORMATION121
17762 ,P_EPZ_ATTRIBUTE12 => r_EPZ.INFORMATION122
17763 ,P_EPZ_ATTRIBUTE13 => r_EPZ.INFORMATION123
17764 ,P_EPZ_ATTRIBUTE14 => r_EPZ.INFORMATION124
17765 ,P_EPZ_ATTRIBUTE15 => r_EPZ.INFORMATION125
17766 ,P_EPZ_ATTRIBUTE16 => r_EPZ.INFORMATION126
17767 ,P_EPZ_ATTRIBUTE17 => r_EPZ.INFORMATION127
17768 ,P_EPZ_ATTRIBUTE18 => r_EPZ.INFORMATION128
17769 ,P_EPZ_ATTRIBUTE19 => r_EPZ.INFORMATION129
17770 ,P_EPZ_ATTRIBUTE2 => r_EPZ.INFORMATION112
17771 ,P_EPZ_ATTRIBUTE20 => r_EPZ.INFORMATION130
17772 ,P_EPZ_ATTRIBUTE21 => r_EPZ.INFORMATION131
17773 ,P_EPZ_ATTRIBUTE22 => r_EPZ.INFORMATION132
17774 ,P_EPZ_ATTRIBUTE23 => r_EPZ.INFORMATION133
17775 ,P_EPZ_ATTRIBUTE24 => r_EPZ.INFORMATION134
17776 ,P_EPZ_ATTRIBUTE25 => r_EPZ.INFORMATION135
17777 ,P_EPZ_ATTRIBUTE26 => r_EPZ.INFORMATION136
17778 ,P_EPZ_ATTRIBUTE27 => r_EPZ.INFORMATION137
17779 ,P_EPZ_ATTRIBUTE28 => r_EPZ.INFORMATION138
17780 ,P_EPZ_ATTRIBUTE29 => r_EPZ.INFORMATION139
17781 ,P_EPZ_ATTRIBUTE3 => r_EPZ.INFORMATION113
17782 ,P_EPZ_ATTRIBUTE30 => r_EPZ.INFORMATION140
17783 ,P_EPZ_ATTRIBUTE4 => r_EPZ.INFORMATION114
17784 ,P_EPZ_ATTRIBUTE5 => r_EPZ.INFORMATION115
17785 ,P_EPZ_ATTRIBUTE6 => r_EPZ.INFORMATION116
17786 ,P_EPZ_ATTRIBUTE7 => r_EPZ.INFORMATION117
17787 ,P_EPZ_ATTRIBUTE8 => r_EPZ.INFORMATION118
17788 ,P_EPZ_ATTRIBUTE9 => r_EPZ.INFORMATION119
17789 ,P_EPZ_ATTRIBUTE_CATEGORY => r_EPZ.INFORMATION110
17790 ,P_EXCLD_FLAG => r_EPZ.INFORMATION11
17791 ,P_ORDR_NUM => r_EPZ.INFORMATION260
17792 ,P_PSTL_ZIP_RNG_ID => l_PSTL_ZIP_RNG_ID
17793 --
17794 ,P_EFFECTIVE_START_DATE => l_effective_start_date
17795 ,P_EFFECTIVE_END_DATE => l_effective_end_date
17796 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
17797 ,P_CRITERIA_SCORE => r_epz.INFORMATION295
17798 ,P_CRITERIA_WEIGHT => r_epz.INFORMATION296
17799 );
17800 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
17801 -- Update all relevent cer records with new pk_id
17802 hr_utility.set_location('Before plsql table ',222);
17803 hr_utility.set_location('new_value id '||l_elig_pstl_cd_r_rng_prte_id,222);
17804 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PSTL_CD_R_RNG_PRTE_ID' ;
17805 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPZ.information1 ;
17806 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_PSTL_CD_R_RNG_PRTE_ID ;
17807 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
17808 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPZ_unique.table_route_id;
17809 hr_utility.set_location('After plsql table ',222);
17810 --
17811 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
17812 --
17813 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17814 --
17815 else
17816 --
17817 -- Call Update routine for the pk_id created in prev run .
17818 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
17819 hr_utility.set_location(' BEN_ELIG_PSTL_CD_R_RNG_PRTE_F UPDATE_ELIG_PSTL_CD_RNG_PRTE ',30);
17820 --UPD START
17821 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
17822 --
17823 if l_update then
17824 --
17825 l_datetrack_mode := r_EPZ.datetrack_mode ;
17826 --
17827 get_dt_modes(
17828 p_effective_date => l_process_date,
17829 p_effective_end_date => r_EPZ.information3,
17830 p_effective_start_date => r_EPZ.information2,
17831 p_dml_operation => r_EPZ.dml_operation,
17832 p_datetrack_mode => l_datetrack_mode );
17833 -- p_update => l_update
17834 --
17835 l_effective_date := l_process_date;
17836 l_ELIG_PSTL_CD_R_RNG_PRTE_ID := r_EPZ.information1;
17837 l_object_version_number := r_EPZ.information265;
17838 --
17839 end if;
17840 --
17841 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
17842 --
17843 IF l_update OR l_dml_operation <> 'UPDATE' THEN
17844 --UPD END
17845
17846
17847 BEN_ELIG_PSTL_CD_RNG_PRTE_API.UPDATE_ELIG_PSTL_CD_RNG_PRTE(
17848 --
17849 P_VALIDATE => false
17850 ,P_EFFECTIVE_DATE => l_effective_date
17851 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
17852 --
17853 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
17854 ,P_ELIG_PSTL_CD_R_RNG_PRTE_ID => l_elig_pstl_cd_r_rng_prte_id
17855 ,P_EPZ_ATTRIBUTE1 => r_EPZ.INFORMATION111
17856 ,P_EPZ_ATTRIBUTE10 => r_EPZ.INFORMATION120
17857 ,P_EPZ_ATTRIBUTE11 => r_EPZ.INFORMATION121
17858 ,P_EPZ_ATTRIBUTE12 => r_EPZ.INFORMATION122
17859 ,P_EPZ_ATTRIBUTE13 => r_EPZ.INFORMATION123
17860 ,P_EPZ_ATTRIBUTE14 => r_EPZ.INFORMATION124
17861 ,P_EPZ_ATTRIBUTE15 => r_EPZ.INFORMATION125
17862 ,P_EPZ_ATTRIBUTE16 => r_EPZ.INFORMATION126
17863 ,P_EPZ_ATTRIBUTE17 => r_EPZ.INFORMATION127
17864 ,P_EPZ_ATTRIBUTE18 => r_EPZ.INFORMATION128
17865 ,P_EPZ_ATTRIBUTE19 => r_EPZ.INFORMATION129
17866 ,P_EPZ_ATTRIBUTE2 => r_EPZ.INFORMATION112
17867 ,P_EPZ_ATTRIBUTE20 => r_EPZ.INFORMATION130
17868 ,P_EPZ_ATTRIBUTE21 => r_EPZ.INFORMATION131
17869 ,P_EPZ_ATTRIBUTE22 => r_EPZ.INFORMATION132
17870 ,P_EPZ_ATTRIBUTE23 => r_EPZ.INFORMATION133
17871 ,P_EPZ_ATTRIBUTE24 => r_EPZ.INFORMATION134
17872 ,P_EPZ_ATTRIBUTE25 => r_EPZ.INFORMATION135
17873 ,P_EPZ_ATTRIBUTE26 => r_EPZ.INFORMATION136
17874 ,P_EPZ_ATTRIBUTE27 => r_EPZ.INFORMATION137
17875 ,P_EPZ_ATTRIBUTE28 => r_EPZ.INFORMATION138
17876 ,P_EPZ_ATTRIBUTE29 => r_EPZ.INFORMATION139
17877 ,P_EPZ_ATTRIBUTE3 => r_EPZ.INFORMATION113
17878 ,P_EPZ_ATTRIBUTE30 => r_EPZ.INFORMATION140
17879 ,P_EPZ_ATTRIBUTE4 => r_EPZ.INFORMATION114
17880 ,P_EPZ_ATTRIBUTE5 => r_EPZ.INFORMATION115
17881 ,P_EPZ_ATTRIBUTE6 => r_EPZ.INFORMATION116
17882 ,P_EPZ_ATTRIBUTE7 => r_EPZ.INFORMATION117
17883 ,P_EPZ_ATTRIBUTE8 => r_EPZ.INFORMATION118
17884 ,P_EPZ_ATTRIBUTE9 => r_EPZ.INFORMATION119
17885 ,P_EPZ_ATTRIBUTE_CATEGORY => r_EPZ.INFORMATION110
17886 ,P_EXCLD_FLAG => r_EPZ.INFORMATION11
17887 ,P_ORDR_NUM => r_EPZ.INFORMATION260
17888 ,P_PSTL_ZIP_RNG_ID => l_PSTL_ZIP_RNG_ID
17889 --
17890 ,P_EFFECTIVE_START_DATE => l_effective_start_date
17891 ,P_EFFECTIVE_END_DATE => l_effective_end_date
17892 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
17893 ,P_DATETRACK_MODE => l_datetrack_mode
17894 ,P_CRITERIA_SCORE => r_epz.INFORMATION295
17895 ,P_CRITERIA_WEIGHT => r_epz.INFORMATION296
17896 );
17897 end if; -- l_update
17898 --
17899 end if;
17900 --
17901 -- Delete the row if it is end dated.
17902 --
17903 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
17904 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
17905 trunc(l_max_eed) = trunc(r_EPZ.information3)) then
17906 --
17907 BEN_ELIG_PSTL_CD_RNG_PRTE_API.delete_ELIG_PSTL_CD_RNG_PRTE(
17908 --
17909 p_validate => false
17910 ,p_elig_pstl_cd_r_rng_prte_id => l_elig_pstl_cd_r_rng_prte_id
17911 ,p_effective_start_date => l_effective_start_date
17912 ,p_effective_end_date => l_effective_end_date
17913 ,p_object_version_number => l_object_version_number
17914 ,p_effective_date => l_max_eed
17915 ,p_datetrack_mode => hr_api.g_delete
17916 --
17917 );
17918 --
17919 end if;
17920 --
17921 l_prev_pk_id := l_current_pk_id ;
17922 --
17923 end if;
17924 --
17925 end if;
17926 --
17927 end loop;
17928 --
17929 exception when others then
17930 --
17931 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EPZ',r_EPZ.information5 ) ;
17932 --
17933 end create_EPZ_rows;
17934
17935 --
17936 ---------------------------------------------------------------
17937 ----------------------< create_EQT_rows >-----------------------
17938 ---------------------------------------------------------------
17939 --
17940 procedure create_EQT_rows
17941 (
17942 p_validate in number default 0
17943 ,p_copy_entity_txn_id in number
17944 ,p_effective_date in date
17945 ,p_prefix_suffix_text in varchar2 default null
17946 ,p_reuse_object_flag in varchar2 default null
17947 ,p_target_business_group_id in varchar2 default null
17948 ,p_prefix_suffix_cd in varchar2 default null
17949 ) is
17950 --
17951 l_ELIGY_PRFL_ID number;
17952 l_QUALIFICATION_TYPE_ID number;
17953 cursor c_unique_EQT(l_table_alias varchar2) is
17954 select distinct cpe.information1,
17955 cpe.information2,
17956 cpe.information3,
17957 cpe.table_route_id
17958 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
17959 pqh_table_route tr
17960 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17961 and cpe.table_route_id = tr.table_route_id
17962 -- and tr.where_clause = l_BEN_ELIG_QUAL_TITL_PRTE_F
17963 and tr.table_alias = l_table_alias
17964 and cpe.number_of_copies = 1 -- ADDITION
17965 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
17966 order by information1, information2; --added for bug: 5151945
17967 --
17968 --
17969 cursor c_EQT_min_max_dates(c_table_route_id number,
17970 c_information1 number) is
17971 select
17972 min(cpe.information2) min_esd,
17973 max(cpe.information3) min_eed
17974 from ben_copy_entity_results cpe
17975 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17976 and cpe.table_route_id = c_table_route_id
17977 and cpe.information1 = c_information1 ;
17978 --
17979 cursor c_EQT(c_table_route_id number,
17980 c_information1 number,
17981 c_information2 date,
17982 c_information3 date ) is
17983 select
17984 cpe.*
17985 from ben_copy_entity_results cpe
17986 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17987 and cpe.table_route_id = c_table_route_id
17988 and cpe.information1 = c_information1
17989 and cpe.information2 = c_information2
17990 and cpe.information3 = c_information3
17991 and rownum = 1 ;
17992 -- Date Track target record
17993 cursor c_find_EQT_in_target(
17994 c_effective_start_date date,
17995 c_effective_end_date date,
17996 c_business_group_id number,
17997 c_new_pk_id number) is
17998 select
17999 EQT.elig_qual_titl_prte_id new_value
18000 from BEN_ELIG_QUAL_TITL_PRTE_F EQT
18001 where
18002 EQT.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
18003 EQT.QUALIFICATION_TYPE_ID = l_QUALIFICATION_TYPE_ID and
18004 EQT.business_group_id = c_business_group_id
18005 and EQT.elig_qual_titl_prte_id <> c_new_pk_id
18006 and c_effective_start_date between effective_start_date
18007 and effective_end_date ;
18008 --END TEMPIK
18009 /*TEMPIK
18010 and exists ( select null
18011 from BEN_ELIG_QUAL_TITL_PRTE_F EQT1
18012 where
18013 EQT1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
18014 EQT1.QUALIFICATION_TYPE_ID = l_QUALIFICATION_TYPE_ID and
18015 EQT1.business_group_id = c_business_group_id
18016 and EQT1.effective_start_date <= c_effective_start_date )
18017 and exists ( select null
18018 from BEN_ELIG_QUAL_TITL_PRTE_F EQT2
18019 where
18020 EQT2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
18021 EQT2.QUALIFICATION_TYPE_ID = l_QUALIFICATION_TYPE_ID and
18022 EQT2.business_group_id = c_business_group_id
18023 and EQT2.effective_end_date >= c_effective_end_date )
18024 ;
18025 TEMPIK */
18026 --TEMPIK
18027 l_dt_rec_found boolean ;
18028 --END TEMPIK
18029 --
18030
18031 --UPD START
18032 --
18033 l_update boolean := false ;
18034 l_datetrack_mode varchar2(80) := hr_api.g_update;
18035 l_process_date date;
18036 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
18037 --
18038 --UPD END
18039 l_current_pk_id number := null ;
18040
18041 l_prev_pk_id number := null ;
18042 l_first_rec boolean := true ;
18043 r_EQT c_EQT%rowtype;
18044 l_elig_qual_titl_prte_id number ;
18045 l_object_version_number number ;
18046 l_effective_start_date date ;
18047 l_effective_end_date date ;
18048 l_prefix pqh_copy_entity_attribs.information1%type := null;
18049 l_suffix pqh_copy_entity_attribs.information1%type := null;
18050 l_new_value number(15);
18051 l_object_found_in_target boolean := false ;
18052 l_min_esd date;
18053 l_max_eed date;
18054 l_effective_date date;
18055 --
18056 begin
18057 -- Initialization
18058 l_object_found_in_target := false ;
18059 -- End Initialization
18060 -- Derive the prefix - sufix
18061 if p_prefix_suffix_cd = 'PREFIX' then
18062 l_prefix := p_prefix_suffix_text ;
18063 elsif p_prefix_suffix_cd = 'SUFFIX' then
18064 l_suffix := p_prefix_suffix_text ;
18065 else
18066 l_prefix := null ;
18067 l_suffix := null ;
18068 end if ;
18069 -- End Prefix Sufix derivation
18070 for r_EQT_unique in c_unique_EQT('EQT') loop
18071
18072 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
18073 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18074 r_EQT_unique.information3 >=
18075 ben_pd_copy_to_ben_one.g_copy_effective_date)
18076 ) then
18077 --
18078 hr_utility.set_location(' r_EQT_unique.table_route_id '||r_EQT_unique.table_route_id,10);
18079 hr_utility.set_location(' r_EQT_unique.information1 '||r_EQT_unique.information1,10);
18080 hr_utility.set_location( 'r_EQT_unique.information2 '||r_EQT_unique.information2,10);
18081 hr_utility.set_location( 'r_EQT_unique.information3 '||r_EQT_unique.information3,10);
18082 -- If reuse objects flag is 'Y' then check for the object in the target business group
18083 -- if found insert the record into PLSql table and exit the loop else try create the
18084 -- object in the target business group
18085 --
18086 l_object_found_in_target := false ;
18087 --UPD START
18088 l_update := false;
18089 l_process_date := p_effective_date;
18090 l_dml_operation:= r_EQT_unique.dml_operation ;
18091 --
18092 /**********************moved from below **********************/
18093 open c_EQT(r_EQT_unique.table_route_id,
18094 r_EQT_unique.information1,
18095 r_EQT_unique.information2,
18096 r_EQT_unique.information3 ) ;
18097 --
18098 fetch c_EQT into r_EQT ;
18099 --
18100 close c_EQT ;
18101 --
18102 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EQT.INFORMATION263,l_dml_operation);
18103 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
18104 l_QUALIFICATION_TYPE_ID := r_EQT.information176;
18105 else
18106 l_QUALIFICATION_TYPE_ID := r_EQT.information174;
18107 end if;
18108
18109 /**********************************************************/
18110
18111 if l_dml_operation = 'UPDATE' then
18112 --
18113 l_object_found_in_target := TRUE;
18114 --
18115 if l_process_date between r_EQT_unique.information2 and r_EQT_unique.information3 then
18116 l_update := true;
18117 if r_EQT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
18118 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_QUAL_TITL_PRTE_ID' then
18119 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_QUAL_TITL_PRTE_ID' ;
18120 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EQT_unique.information1 ;
18121 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EQT_unique.information1 ;
18122 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18123 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EQT_unique.table_route_id;
18124 --
18125 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
18126 --
18127 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18128 --
18129 -- log_data('EQT',l_new_value,l_prefix || r_EQT_unique.name|| l_suffix,'REUSED');
18130 --
18131 end if ;
18132 hr_utility.set_location( 'found record for update',10);
18133 --
18134 else
18135 --
18136 l_update := false;
18137 --
18138 end if;
18139 else
18140 --
18141 --UPD END
18142 l_min_esd := null ;
18143 l_max_eed := null ;
18144 open c_EQT_min_max_dates(r_EQT_unique.table_route_id, r_EQT_unique.information1 ) ;
18145 fetch c_EQT_min_max_dates into l_min_esd,l_max_eed ;
18146 --
18147
18148 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18149 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18150 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
18151 end if;
18152 l_min_esd := greatest(l_min_esd,r_EQT_unique.information2);
18153 /**********************moved up from here **********************
18154 open c_EQT(r_EQT_unique.table_route_id,
18155 r_EQT_unique.information1,
18156 r_EQT_unique.information2,
18157 r_EQT_unique.information3 ) ;
18158 --
18159 fetch c_EQT into r_EQT ;
18160 --
18161 close c_EQT ;
18162 --
18163 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EQT.INFORMATION263,l_dml_operation);
18164 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
18165 l_QUALIFICATION_TYPE_ID := r_EQT.information176;
18166 else
18167 l_QUALIFICATION_TYPE_ID := r_EQT.information174;
18168 end if;
18169
18170 **********************************************************/
18171
18172 --
18173 if l_QUALIFICATION_TYPE_ID is null then
18174 close c_EQT_min_max_dates;
18175 --
18176 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
18177 ,p_parent_pk_id => r_EQT.information263
18178 ,p_copy_entity_txn_id => p_copy_entity_txn_id
18179 ,p_child_table_alias => 'EQT'
18180 ,p_child_data => r_EQT.information173 );
18181
18182 --
18183 else
18184 if p_reuse_object_flag = 'Y' then
18185 if c_EQT_min_max_dates%found then
18186 -- cursor to find the object
18187 open c_find_EQT_in_target( l_min_esd,l_max_eed,
18188 p_target_business_group_id, nvl(l_elig_qual_titl_prte_id, -999) ) ;
18189 fetch c_find_EQT_in_target into l_new_value ;
18190 if c_find_EQT_in_target%found then
18191 --
18192 --TEMPIK
18193 l_dt_rec_found := dt_api.check_min_max_dates
18194 (p_base_table_name => 'BEN_ELIG_QUAL_TITL_PRTE_F',
18195 p_base_key_column => 'ELIG_QUAL_TITL_PRTE_ID',
18196 p_base_key_value => l_new_value,
18197 p_from_date => l_min_esd,
18198 p_to_date => l_max_eed );
18199 if l_dt_rec_found THEN
18200 --END TEMPIK
18201 if r_EQT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
18202 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_QUAL_TITL_PRTE_ID' then
18203 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_QUAL_TITL_PRTE_ID' ;
18204 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EQT_unique.information1 ;
18205 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
18206 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18207 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EQT_unique.table_route_id;
18208 --
18209 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
18210 --
18211 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18212 end if ;
18213 --
18214 l_object_found_in_target := true ;
18215 --TEMPIK
18216 end if; -- l_dt_rec_found
18217 --END TEMPIK
18218 end if;
18219 close c_find_EQT_in_target ;
18220 --
18221 end if;
18222 end if ;
18223 --
18224 close c_EQT_min_max_dates ;
18225 end if; --if p_dml_operation
18226 --
18227 if not l_object_found_in_target OR l_update then
18228
18229 --
18230 l_current_pk_id := r_EQT.information1;
18231 --
18232 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
18233 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
18234 --
18235 if l_current_pk_id = l_prev_pk_id then
18236 --
18237 l_first_rec := false ;
18238 --
18239 else
18240 --
18241 l_first_rec := true ;
18242 --
18243 end if ;
18244 --
18245
18246 l_effective_date := r_EQT.information2;
18247 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18248 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18249 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
18250 end if;
18251
18252 if l_first_rec and not l_update then
18253 -- Call Create routine.
18254 hr_utility.set_location(' BEN_ELIG_QUAL_TITL_PRTE_F CREATE_ELIG_QUAL_TITL_PRTE ',20);
18255 BEN_ELIG_QUAL_TITL_PRTE_API.CREATE_ELIG_QUAL_TITL_PRTE(
18256 --
18257 P_VALIDATE => false
18258 ,P_EFFECTIVE_DATE => l_effective_date
18259 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
18260 --
18261 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
18262 ,P_ELIG_QUAL_TITL_PRTE_ID => l_elig_qual_titl_prte_id
18263 ,P_EQT_ATTRIBUTE1 => r_EQT.INFORMATION111
18264 ,P_EQT_ATTRIBUTE10 => r_EQT.INFORMATION120
18265 ,P_EQT_ATTRIBUTE11 => r_EQT.INFORMATION121
18266 ,P_EQT_ATTRIBUTE12 => r_EQT.INFORMATION122
18267 ,P_EQT_ATTRIBUTE13 => r_EQT.INFORMATION123
18268 ,P_EQT_ATTRIBUTE14 => r_EQT.INFORMATION124
18269 ,P_EQT_ATTRIBUTE15 => r_EQT.INFORMATION125
18270 ,P_EQT_ATTRIBUTE16 => r_EQT.INFORMATION126
18271 ,P_EQT_ATTRIBUTE17 => r_EQT.INFORMATION127
18272 ,P_EQT_ATTRIBUTE18 => r_EQT.INFORMATION128
18273 ,P_EQT_ATTRIBUTE19 => r_EQT.INFORMATION129
18274 ,P_EQT_ATTRIBUTE2 => r_EQT.INFORMATION112
18275 ,P_EQT_ATTRIBUTE20 => r_EQT.INFORMATION130
18276 ,P_EQT_ATTRIBUTE21 => r_EQT.INFORMATION131
18277 ,P_EQT_ATTRIBUTE22 => r_EQT.INFORMATION132
18278 ,P_EQT_ATTRIBUTE23 => r_EQT.INFORMATION133
18279 ,P_EQT_ATTRIBUTE24 => r_EQT.INFORMATION134
18280 ,P_EQT_ATTRIBUTE25 => r_EQT.INFORMATION135
18281 ,P_EQT_ATTRIBUTE26 => r_EQT.INFORMATION136
18282 ,P_EQT_ATTRIBUTE27 => r_EQT.INFORMATION137
18283 ,P_EQT_ATTRIBUTE28 => r_EQT.INFORMATION138
18284 ,P_EQT_ATTRIBUTE29 => r_EQT.INFORMATION139
18285 ,P_EQT_ATTRIBUTE3 => r_EQT.INFORMATION113
18286 ,P_EQT_ATTRIBUTE30 => r_EQT.INFORMATION140
18287 ,P_EQT_ATTRIBUTE4 => r_EQT.INFORMATION114
18288 ,P_EQT_ATTRIBUTE5 => r_EQT.INFORMATION115
18289 ,P_EQT_ATTRIBUTE6 => r_EQT.INFORMATION116
18290 ,P_EQT_ATTRIBUTE7 => r_EQT.INFORMATION117
18291 ,P_EQT_ATTRIBUTE8 => r_EQT.INFORMATION118
18292 ,P_EQT_ATTRIBUTE9 => r_EQT.INFORMATION119
18293 ,P_EQT_ATTRIBUTE_CATEGORY => r_EQT.INFORMATION110
18294 ,P_EXCLD_FLAG => r_EQT.INFORMATION11
18295 ,P_ORDR_NUM => r_EQT.INFORMATION260
18296 ,P_QUALIFICATION_TYPE_ID => l_QUALIFICATION_TYPE_ID
18297 ,P_TITLE => r_EQT.INFORMATION141
18298 --
18299 -- ****** END CHANGE LINES
18300
18301 --
18302
18303 ,P_EFFECTIVE_START_DATE => l_effective_start_date
18304 ,P_EFFECTIVE_END_DATE => l_effective_end_date
18305 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
18306 ,P_CRITERIA_SCORE => r_eqt.INFORMATION295
18307 ,P_CRITERIA_WEIGHT => r_eqt.INFORMATION296
18308 );
18309 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
18310 -- Update all relevent cer records with new pk_id
18311 hr_utility.set_location('Before plsql table ',222);
18312 hr_utility.set_location('new_value id '||l_elig_qual_titl_prte_id,222);
18313 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_QUAL_TITL_PRTE_ID' ;
18314 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EQT.information1 ;
18315 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_QUAL_TITL_PRTE_ID ;
18316 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
18317 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EQT_unique.table_route_id;
18318 hr_utility.set_location('After plsql table ',222);
18319 --
18320 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
18321 --
18322 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18323 --
18324 else
18325 --
18326 -- Call Update routine for the pk_id created in prev run .
18327 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
18328 hr_utility.set_location(' BEN_ELIG_QUAL_TITL_PRTE_F UPDATE_ELIG_QUAL_TITL_PRTE ',30);
18329 --UPD START
18330 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
18331 --
18332 if l_update then
18333 --
18334 l_datetrack_mode := r_EQT.datetrack_mode ;
18335 --
18336 get_dt_modes(
18337 p_effective_date => l_process_date,
18338 p_effective_end_date => r_EQT.information3,
18339 p_effective_start_date => r_EQT.information2,
18340 p_dml_operation => r_EQT.dml_operation,
18341 p_datetrack_mode => l_datetrack_mode );
18342 -- p_update => l_update
18343 --
18344 l_effective_date := l_process_date;
18345 l_ELIG_QUAL_TITL_PRTE_ID := r_EQT.information1;
18346 l_object_version_number := r_EQT.information265;
18347 --
18348 end if;
18349 --
18350 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
18351 --
18352 IF l_update OR l_dml_operation <> 'UPDATE' THEN
18353 --UPD END
18354
18355
18356 BEN_ELIG_QUAL_TITL_PRTE_API.UPDATE_ELIG_QUAL_TITL_PRTE(
18357 --
18358 P_VALIDATE => false
18359 ,P_EFFECTIVE_DATE => l_effective_date
18360 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
18361 --
18362 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
18363 ,P_ELIG_QUAL_TITL_PRTE_ID => l_elig_qual_titl_prte_id
18364 ,P_EQT_ATTRIBUTE1 => r_EQT.INFORMATION111
18365 ,P_EQT_ATTRIBUTE10 => r_EQT.INFORMATION120
18366 ,P_EQT_ATTRIBUTE11 => r_EQT.INFORMATION121
18367 ,P_EQT_ATTRIBUTE12 => r_EQT.INFORMATION122
18368 ,P_EQT_ATTRIBUTE13 => r_EQT.INFORMATION123
18369 ,P_EQT_ATTRIBUTE14 => r_EQT.INFORMATION124
18370 ,P_EQT_ATTRIBUTE15 => r_EQT.INFORMATION125
18371 ,P_EQT_ATTRIBUTE16 => r_EQT.INFORMATION126
18372 ,P_EQT_ATTRIBUTE17 => r_EQT.INFORMATION127
18373 ,P_EQT_ATTRIBUTE18 => r_EQT.INFORMATION128
18374 ,P_EQT_ATTRIBUTE19 => r_EQT.INFORMATION129
18375 ,P_EQT_ATTRIBUTE2 => r_EQT.INFORMATION112
18376 ,P_EQT_ATTRIBUTE20 => r_EQT.INFORMATION130
18377 ,P_EQT_ATTRIBUTE21 => r_EQT.INFORMATION131
18378 ,P_EQT_ATTRIBUTE22 => r_EQT.INFORMATION132
18379 ,P_EQT_ATTRIBUTE23 => r_EQT.INFORMATION133
18380 ,P_EQT_ATTRIBUTE24 => r_EQT.INFORMATION134
18381 ,P_EQT_ATTRIBUTE25 => r_EQT.INFORMATION135
18382 ,P_EQT_ATTRIBUTE26 => r_EQT.INFORMATION136
18383 ,P_EQT_ATTRIBUTE27 => r_EQT.INFORMATION137
18384 ,P_EQT_ATTRIBUTE28 => r_EQT.INFORMATION138
18385 ,P_EQT_ATTRIBUTE29 => r_EQT.INFORMATION139
18386 ,P_EQT_ATTRIBUTE3 => r_EQT.INFORMATION113
18387 ,P_EQT_ATTRIBUTE30 => r_EQT.INFORMATION140
18388 ,P_EQT_ATTRIBUTE4 => r_EQT.INFORMATION114
18389 ,P_EQT_ATTRIBUTE5 => r_EQT.INFORMATION115
18390 ,P_EQT_ATTRIBUTE6 => r_EQT.INFORMATION116
18391 ,P_EQT_ATTRIBUTE7 => r_EQT.INFORMATION117
18392 ,P_EQT_ATTRIBUTE8 => r_EQT.INFORMATION118
18393 ,P_EQT_ATTRIBUTE9 => r_EQT.INFORMATION119
18394 ,P_EQT_ATTRIBUTE_CATEGORY => r_EQT.INFORMATION110
18395 ,P_EXCLD_FLAG => r_EQT.INFORMATION11
18396 ,P_ORDR_NUM => r_EQT.INFORMATION260
18397 ,P_QUALIFICATION_TYPE_ID => l_QUALIFICATION_TYPE_ID
18398 ,P_TITLE => r_EQT.INFORMATION141
18399 --
18400 -- ****** END CHANGE LINES
18401
18402 --
18403 ,P_EFFECTIVE_START_DATE => l_effective_start_date
18404 ,P_EFFECTIVE_END_DATE => l_effective_end_date
18405 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
18406 ,P_DATETRACK_MODE => l_datetrack_mode
18407 ,P_CRITERIA_SCORE => r_eqt.INFORMATION295
18408 ,P_CRITERIA_WEIGHT => r_eqt.INFORMATION296
18409 );
18410 end if; -- l_update
18411 --
18412 end if;
18413 --
18414 -- Delete the row if it is end dated.
18415 --
18416 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
18417 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
18418 trunc(l_max_eed) = trunc(r_EQT.information3)) then
18419 --
18420 BEN_ELIG_QUAL_TITL_PRTE_API.delete_ELIG_QUAL_TITL_PRTE(
18421 --
18422 p_validate => false
18423 ,p_elig_qual_titl_prte_id => l_elig_qual_titl_prte_id
18424 ,p_effective_start_date => l_effective_start_date
18425 ,p_effective_end_date => l_effective_end_date
18426 ,p_object_version_number => l_object_version_number
18427 ,p_effective_date => l_max_eed
18428 ,p_datetrack_mode => hr_api.g_delete
18429 --
18430 );
18431 --
18432 end if;
18433 --
18434 l_prev_pk_id := l_current_pk_id ;
18435 --
18436 end if;
18437 --
18438 end if;
18439 --
18440 end if;
18441 --
18442 end loop;
18443 --
18444 exception when others then
18445 --
18446 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EQT',r_EQT.information5 ) ;
18447 --
18448 end create_EQT_rows;
18449
18450 --
18451 ---------------------------------------------------------------
18452 ----------------------< create_ESA_rows >-----------------------
18453 ---------------------------------------------------------------
18454 --
18455 procedure create_ESA_rows
18456 (
18457 p_validate in number default 0
18458 ,p_copy_entity_txn_id in number
18459 ,p_effective_date in date
18460 ,p_prefix_suffix_text in varchar2 default null
18461 ,p_reuse_object_flag in varchar2 default null
18462 ,p_target_business_group_id in varchar2 default null
18463 ,p_prefix_suffix_cd in varchar2 default null
18464 ) is
18465 --
18466 l_ELIGY_PRFL_ID number;
18467 l_SVC_AREA_ID number;
18468 l_ORDR_NUM number;
18469
18470 cursor c_unique_ESA(l_table_alias varchar2) is
18471 select distinct cpe.information1,
18472 cpe.information2,
18473 cpe.information3,
18474 cpe.table_route_id
18475 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
18476 pqh_table_route tr
18477 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18478 and cpe.table_route_id = tr.table_route_id
18479 -- and tr.where_clause = l_BEN_ELIG_SVC_AREA_PRTE_F
18480 and tr.table_alias = l_table_alias
18481 and cpe.number_of_copies = 1 -- ADDITION
18482 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
18483 order by information1, information2; --added for bug: 5151945
18484 --
18485 --
18486 cursor c_ESA_min_max_dates(c_table_route_id number,
18487 c_information1 number) is
18488 select
18489 min(cpe.information2) min_esd,
18490 max(cpe.information3) min_eed
18491 from ben_copy_entity_results cpe
18492 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18493 and cpe.table_route_id = c_table_route_id
18494 and cpe.information1 = c_information1 ;
18495 --
18496 cursor c_ESA(c_table_route_id number,
18497 c_information1 number,
18498 c_information2 date,
18499 c_information3 date ) is
18500 select
18501 cpe.*
18502 from ben_copy_entity_results cpe
18503 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18504 and cpe.table_route_id = c_table_route_id
18505 and cpe.information1 = c_information1
18506 and cpe.information2 = c_information2
18507 and cpe.information3 = c_information3
18508 and rownum = 1 ;
18509 -- Date Track target record
18510 cursor c_find_ESA_in_target(
18511 c_effective_start_date date,
18512 c_effective_end_date date,
18513 c_business_group_id number,
18514 c_new_pk_id number) is
18515 select
18516 ESA.elig_svc_area_prte_id new_value
18517 from BEN_ELIG_SVC_AREA_PRTE_F ESA
18518 where
18519 ESA.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
18520 ESA.SVC_AREA_ID = l_SVC_AREA_ID and
18521 ESA.business_group_id = c_business_group_id
18522 and ESA.elig_svc_area_prte_id <> c_new_pk_id
18523 and c_effective_start_date between effective_start_date
18524 and effective_end_date ;
18525 --END TEMPIK
18526 /*TEMPIK
18527 and exists ( select null
18528 from BEN_ELIG_SVC_AREA_PRTE_F ESA1
18529 where
18530 ESA1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
18531 ESA1.SVC_AREA_ID = l_SVC_AREA_ID and
18532 ESA1.ORDR_NUM = l_ORDR_NUM and -- Added this criteria
18533 ESA1.business_group_id = c_business_group_id
18534 and ESA1.effective_start_date <= c_effective_start_date )
18535 and exists ( select null
18536 from BEN_ELIG_SVC_AREA_PRTE_F ESA2
18537 where
18538 ESA2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
18539 ESA2.SVC_AREA_ID = l_SVC_AREA_ID and
18540 ESA2.ORDR_NUM = l_ORDR_NUM and -- Added this criteria
18541 ESA2.business_group_id = c_business_group_id
18542 and ESA2.effective_end_date >= c_effective_end_date )
18543 ;
18544 TEMPIK */
18545 --TEMPIK
18546 l_dt_rec_found boolean ;
18547 --END TEMPIK
18548 --
18549
18550 --UPD START
18551 --
18552 l_update boolean := false ;
18553 l_datetrack_mode varchar2(80) := hr_api.g_update;
18554 l_process_date date;
18555 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
18556 --
18557 --UPD END
18558 l_current_pk_id number := null ;
18559
18560 l_prev_pk_id number := null ;
18561 l_first_rec boolean := true ;
18562 r_ESA c_ESA%rowtype;
18563 l_elig_svc_area_prte_id number ;
18564 l_object_version_number number ;
18565 l_effective_start_date date ;
18566 l_effective_end_date date ;
18567 l_prefix pqh_copy_entity_attribs.information1%type := null;
18568 l_suffix pqh_copy_entity_attribs.information1%type := null;
18569 l_new_value number(15);
18570 l_object_found_in_target boolean := false ;
18571 l_min_esd date;
18572 l_max_eed date;
18573 l_effective_date date;
18574 --
18575 begin
18576 -- Initialization
18577 l_object_found_in_target := false ;
18578 -- End Initialization
18579 -- Derive the prefix - sufix
18580 if p_prefix_suffix_cd = 'PREFIX' then
18581 l_prefix := p_prefix_suffix_text ;
18582 elsif p_prefix_suffix_cd = 'SUFFIX' then
18583 l_suffix := p_prefix_suffix_text ;
18584 else
18585 l_prefix := null ;
18586 l_suffix := null ;
18587 end if ;
18588 -- End Prefix Sufix derivation
18589 for r_ESA_unique in c_unique_ESA('ESA') loop
18590
18591 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
18592 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18593 r_ESA_unique.information3 >=
18594 ben_pd_copy_to_ben_one.g_copy_effective_date)
18595 ) then
18596 --
18597 hr_utility.set_location(' r_ESA_unique.table_route_id '||r_ESA_unique.table_route_id,10);
18598 hr_utility.set_location(' r_ESA_unique.information1 '||r_ESA_unique.information1,10);
18599 hr_utility.set_location( 'r_ESA_unique.information2 '||r_ESA_unique.information2,10);
18600 hr_utility.set_location( 'r_ESA_unique.information3 '||r_ESA_unique.information3,10);
18601 -- If reuse objects flag is 'Y' then check for the object in the target business group
18602 -- if found insert the record into PLSql table and exit the loop else try create the
18603 -- object in the target business group
18604 --
18605 l_object_found_in_target := false ;
18606 --UPD START
18607 l_update := false;
18608 l_process_date := p_effective_date;
18609 l_dml_operation:= r_ESA_unique.dml_operation ;
18610 --
18611 /**********************moved from below **********************/
18612 open c_ESA(r_ESA_unique.table_route_id,
18613 r_ESA_unique.information1,
18614 r_ESA_unique.information2,
18615 r_ESA_unique.information3 ) ;
18616 --
18617 fetch c_ESA into r_ESA ;
18618 --
18619 close c_ESA ;
18620 --
18621 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ESA.INFORMATION263,l_dml_operation);
18622 l_SVC_AREA_ID := get_fk('SVC_AREA_ID', r_ESA.INFORMATION241,l_dml_operation);
18623 l_ORDR_NUM := r_ESA.INFORMATION260; -- Added this criteria
18624 hr_utility.set_location(' r_ESA.information46 '||r_ESA.information46,99);
18625 hr_utility.set_location(' l_SVC_AREA_ID '||l_SVC_AREA_ID,99);
18626 hr_utility.set_location(' l_ELIGY_PRFL_ID '||l_ELIGY_PRFL_ID,99);
18627 hr_utility.set_location(' l_ORDR_NUM '||l_ORDR_NUM,99);
18628
18629 /**********************************************************/
18630
18631 if l_dml_operation = 'UPDATE' then
18632 --
18633 l_object_found_in_target := TRUE;
18634 --
18635 if l_process_date between r_ESA_unique.information2 and r_ESA_unique.information3 then
18636 l_update := true;
18637 if r_ESA_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
18638 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_SVC_AREA_PRTE_ID' then
18639 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_SVC_AREA_PRTE_ID' ;
18640 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ESA_unique.information1 ;
18641 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ESA_unique.information1 ;
18642 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18643 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ESA_unique.table_route_id;
18644 --
18645 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
18646 --
18647 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18648 --
18649 -- log_data('ESA',l_new_value,l_prefix || r_ESA_unique.name|| l_suffix,'REUSED');
18650 --
18651 end if ;
18652 hr_utility.set_location( 'found record for update',10);
18653 --
18654 else
18655 --
18656 l_update := false;
18657 --
18658 end if;
18659 else
18660 --
18661 --UPD END
18662 l_min_esd := null ;
18663 l_max_eed := null ;
18664 open c_ESA_min_max_dates(r_ESA_unique.table_route_id, r_ESA_unique.information1 ) ;
18665 fetch c_ESA_min_max_dates into l_min_esd,l_max_eed ;
18666 --
18667
18668 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18669 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18670 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
18671 end if;
18672 l_min_esd := greatest(l_min_esd,r_ESA_unique.information2);
18673 /**********************moved up from here **********************
18674 open c_ESA(r_ESA_unique.table_route_id,
18675 r_ESA_unique.information1,
18676 r_ESA_unique.information2,
18677 r_ESA_unique.information3 ) ;
18678 --
18679 fetch c_ESA into r_ESA ;
18680 --
18681 close c_ESA ;
18682 --
18683 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ESA.INFORMATION263,l_dml_operation);
18684 l_SVC_AREA_ID := get_fk('SVC_AREA_ID', r_ESA.INFORMATION241,l_dml_operation);
18685 l_ORDR_NUM := r_ESA.INFORMATION260; -- Added this criteria
18686 hr_utility.set_location(' r_ESA.information46 '||r_ESA.information46,99);
18687 hr_utility.set_location(' l_SVC_AREA_ID '||l_SVC_AREA_ID,99);
18688 hr_utility.set_location(' l_ELIGY_PRFL_ID '||l_ELIGY_PRFL_ID,99);
18689 hr_utility.set_location(' l_ORDR_NUM '||l_ORDR_NUM,99);
18690
18691 **********************************************************/
18692
18693 --
18694 if p_reuse_object_flag = 'Y' then
18695 if c_ESA_min_max_dates%found then
18696 -- cursor to find the object
18697 open c_find_ESA_in_target( l_min_esd,l_max_eed,
18698 p_target_business_group_id, nvl(l_elig_svc_area_prte_id, -999) ) ;
18699 fetch c_find_ESA_in_target into l_new_value ;
18700 if c_find_ESA_in_target%found then
18701 --
18702 --TEMPIK
18703 l_dt_rec_found := dt_api.check_min_max_dates
18704 (p_base_table_name => 'BEN_ELIG_SVC_AREA_PRTE_F',
18705 p_base_key_column => 'ELIG_SVC_AREA_PRTE_ID',
18706 p_base_key_value => l_new_value,
18707 p_from_date => l_min_esd,
18708 p_to_date => l_max_eed );
18709 if l_dt_rec_found THEN
18710 --END TEMPIK
18711 if r_ESA_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
18712 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_SVC_AREA_PRTE_ID' then
18713 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_SVC_AREA_PRTE_ID' ;
18714 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ESA_unique.information1 ;
18715 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
18716 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18717 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ESA_unique.table_route_id;
18718 --
18719 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
18720 --
18721 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18722 end if ;
18723 --
18724 l_object_found_in_target := true ;
18725 --TEMPIK
18726 end if; -- l_dt_rec_found
18727 --END TEMPIK
18728 end if;
18729 close c_find_ESA_in_target ;
18730 --
18731 end if;
18732 end if ;
18733 --
18734 close c_ESA_min_max_dates ;
18735 end if; --if p_dml_operation
18736 --
18737 if not l_object_found_in_target OR l_update then
18738
18739 --
18740 l_current_pk_id := r_ESA.information1;
18741 --
18742 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
18743 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
18744 --
18745 if l_current_pk_id = l_prev_pk_id then
18746 --
18747 l_first_rec := false ;
18748 --
18749 else
18750 --
18751 l_first_rec := true ;
18752 --
18753 end if ;
18754 --
18755
18756 l_effective_date := r_ESA.information2;
18757 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18758 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18759 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
18760 end if;
18761
18762 if l_first_rec and not l_update then
18763 -- Call Create routine.
18764 hr_utility.set_location(' BEN_ELIG_SVC_AREA_PRTE_F CREATE_ELIG_SVC_AREA_PRTE ',20);
18765 BEN_ELIG_SVC_AREA_PRTE_API.CREATE_ELIG_SVC_AREA_PRTE(
18766 --
18767 P_VALIDATE => false
18768 ,P_EFFECTIVE_DATE => l_effective_date
18769 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
18770 --
18771 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
18772 ,P_ELIG_SVC_AREA_PRTE_ID => l_elig_svc_area_prte_id
18773 ,P_ESA_ATTRIBUTE1 => r_ESA.INFORMATION111
18774 ,P_ESA_ATTRIBUTE10 => r_ESA.INFORMATION120
18775 ,P_ESA_ATTRIBUTE11 => r_ESA.INFORMATION121
18776 ,P_ESA_ATTRIBUTE12 => r_ESA.INFORMATION122
18777 ,P_ESA_ATTRIBUTE13 => r_ESA.INFORMATION123
18778 ,P_ESA_ATTRIBUTE14 => r_ESA.INFORMATION124
18779 ,P_ESA_ATTRIBUTE15 => r_ESA.INFORMATION125
18780 ,P_ESA_ATTRIBUTE16 => r_ESA.INFORMATION126
18781 ,P_ESA_ATTRIBUTE17 => r_ESA.INFORMATION127
18782 ,P_ESA_ATTRIBUTE18 => r_ESA.INFORMATION128
18783 ,P_ESA_ATTRIBUTE19 => r_ESA.INFORMATION129
18784 ,P_ESA_ATTRIBUTE2 => r_ESA.INFORMATION112
18785 ,P_ESA_ATTRIBUTE20 => r_ESA.INFORMATION130
18786 ,P_ESA_ATTRIBUTE21 => r_ESA.INFORMATION131
18787 ,P_ESA_ATTRIBUTE22 => r_ESA.INFORMATION132
18788 ,P_ESA_ATTRIBUTE23 => r_ESA.INFORMATION133
18789 ,P_ESA_ATTRIBUTE24 => r_ESA.INFORMATION134
18790 ,P_ESA_ATTRIBUTE25 => r_ESA.INFORMATION135
18791 ,P_ESA_ATTRIBUTE26 => r_ESA.INFORMATION136
18792 ,P_ESA_ATTRIBUTE27 => r_ESA.INFORMATION137
18793 ,P_ESA_ATTRIBUTE28 => r_ESA.INFORMATION138
18794 ,P_ESA_ATTRIBUTE29 => r_ESA.INFORMATION139
18795 ,P_ESA_ATTRIBUTE3 => r_ESA.INFORMATION113
18796 ,P_ESA_ATTRIBUTE30 => r_ESA.INFORMATION140
18797 ,P_ESA_ATTRIBUTE4 => r_ESA.INFORMATION114
18798 ,P_ESA_ATTRIBUTE5 => r_ESA.INFORMATION115
18799 ,P_ESA_ATTRIBUTE6 => r_ESA.INFORMATION116
18800 ,P_ESA_ATTRIBUTE7 => r_ESA.INFORMATION117
18801 ,P_ESA_ATTRIBUTE8 => r_ESA.INFORMATION118
18802 ,P_ESA_ATTRIBUTE9 => r_ESA.INFORMATION119
18803 ,P_ESA_ATTRIBUTE_CATEGORY => r_ESA.INFORMATION110
18804 ,P_EXCLD_FLAG => r_ESA.INFORMATION11
18805 ,P_ORDR_NUM => r_ESA.INFORMATION260
18806 ,P_SVC_AREA_ID => l_SVC_AREA_ID
18807 --
18808 -- ****** END CHANGE LINES
18809
18810 --
18811
18812 ,P_EFFECTIVE_START_DATE => l_effective_start_date
18813 ,P_EFFECTIVE_END_DATE => l_effective_end_date
18814 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
18815 ,P_CRITERIA_SCORE => r_esa.INFORMATION295
18816 ,P_CRITERIA_WEIGHT => r_esa.INFORMATION296
18817 );
18818 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
18819 -- Update all relevent cer records with new pk_id
18820 hr_utility.set_location('Before plsql table ',222);
18821 hr_utility.set_location('new_value id '||l_elig_svc_area_prte_id,222);
18822 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_SVC_AREA_PRTE_ID' ;
18823 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ESA.information1 ;
18824 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_SVC_AREA_PRTE_ID ;
18825 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
18826 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ESA_unique.table_route_id;
18827 hr_utility.set_location('After plsql table ',222);
18828 --
18829 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
18830 --
18831 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18832 --
18833 else
18834 --
18835 -- Call Update routine for the pk_id created in prev run .
18836 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
18837 hr_utility.set_location(' BEN_ELIG_SVC_AREA_PRTE_F UPDATE_ELIG_SVC_AREA_PRTE ',30);
18838 --UPD START
18839 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
18840 --
18841 if l_update then
18842 --
18843 l_datetrack_mode := r_ESA.datetrack_mode ;
18844 --
18845 get_dt_modes(
18846 p_effective_date => l_process_date,
18847 p_effective_end_date => r_ESA.information3,
18848 p_effective_start_date => r_ESA.information2,
18849 p_dml_operation => r_ESA.dml_operation,
18850 p_datetrack_mode => l_datetrack_mode );
18851 -- p_update => l_update
18852 --
18853 l_effective_date := l_process_date;
18854 l_ELIG_SVC_AREA_PRTE_ID := r_ESA.information1;
18855 l_object_version_number := r_ESA.information265;
18856 --
18857 end if;
18858 --
18859 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
18860 --
18861 IF l_update OR l_dml_operation <> 'UPDATE' THEN
18862 --UPD END
18863
18864
18865 BEN_ELIG_SVC_AREA_PRTE_API.UPDATE_ELIG_SVC_AREA_PRTE(
18866 --
18867 P_VALIDATE => false
18868 ,P_EFFECTIVE_DATE => l_effective_date
18869 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
18870 --
18871 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
18872 ,P_ELIG_SVC_AREA_PRTE_ID => l_elig_svc_area_prte_id
18873 ,P_ESA_ATTRIBUTE1 => r_ESA.INFORMATION111
18874 ,P_ESA_ATTRIBUTE10 => r_ESA.INFORMATION120
18875 ,P_ESA_ATTRIBUTE11 => r_ESA.INFORMATION121
18876 ,P_ESA_ATTRIBUTE12 => r_ESA.INFORMATION122
18877 ,P_ESA_ATTRIBUTE13 => r_ESA.INFORMATION123
18878 ,P_ESA_ATTRIBUTE14 => r_ESA.INFORMATION124
18879 ,P_ESA_ATTRIBUTE15 => r_ESA.INFORMATION125
18880 ,P_ESA_ATTRIBUTE16 => r_ESA.INFORMATION126
18881 ,P_ESA_ATTRIBUTE17 => r_ESA.INFORMATION127
18882 ,P_ESA_ATTRIBUTE18 => r_ESA.INFORMATION128
18883 ,P_ESA_ATTRIBUTE19 => r_ESA.INFORMATION129
18884 ,P_ESA_ATTRIBUTE2 => r_ESA.INFORMATION112
18885 ,P_ESA_ATTRIBUTE20 => r_ESA.INFORMATION130
18886 ,P_ESA_ATTRIBUTE21 => r_ESA.INFORMATION131
18887 ,P_ESA_ATTRIBUTE22 => r_ESA.INFORMATION132
18888 ,P_ESA_ATTRIBUTE23 => r_ESA.INFORMATION133
18889 ,P_ESA_ATTRIBUTE24 => r_ESA.INFORMATION134
18890 ,P_ESA_ATTRIBUTE25 => r_ESA.INFORMATION135
18891 ,P_ESA_ATTRIBUTE26 => r_ESA.INFORMATION136
18892 ,P_ESA_ATTRIBUTE27 => r_ESA.INFORMATION137
18893 ,P_ESA_ATTRIBUTE28 => r_ESA.INFORMATION138
18894 ,P_ESA_ATTRIBUTE29 => r_ESA.INFORMATION139
18895 ,P_ESA_ATTRIBUTE3 => r_ESA.INFORMATION113
18896 ,P_ESA_ATTRIBUTE30 => r_ESA.INFORMATION140
18897 ,P_ESA_ATTRIBUTE4 => r_ESA.INFORMATION114
18898 ,P_ESA_ATTRIBUTE5 => r_ESA.INFORMATION115
18899 ,P_ESA_ATTRIBUTE6 => r_ESA.INFORMATION116
18900 ,P_ESA_ATTRIBUTE7 => r_ESA.INFORMATION117
18901 ,P_ESA_ATTRIBUTE8 => r_ESA.INFORMATION118
18902 ,P_ESA_ATTRIBUTE9 => r_ESA.INFORMATION119
18903 ,P_ESA_ATTRIBUTE_CATEGORY => r_ESA.INFORMATION110
18904 ,P_EXCLD_FLAG => r_ESA.INFORMATION11
18905 ,P_ORDR_NUM => r_ESA.INFORMATION260
18906 ,P_SVC_AREA_ID => l_SVC_AREA_ID
18907 --
18908 -- ****** END CHANGE LINES
18909
18910 --
18911 ,P_EFFECTIVE_START_DATE => l_effective_start_date
18912 ,P_EFFECTIVE_END_DATE => l_effective_end_date
18913 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
18914 ,P_DATETRACK_MODE => l_datetrack_mode
18915 ,P_CRITERIA_SCORE => r_esa.INFORMATION295
18916 ,P_CRITERIA_WEIGHT => r_esa.INFORMATION296
18917 );
18918 end if; -- l_update
18919 --
18920 end if;
18921 --
18922 -- Delete the row if it is end dated.
18923 --
18924 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
18925 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
18926 trunc(l_max_eed) = trunc(r_ESA.information3)) then
18927 --
18928 BEN_ELIG_SVC_AREA_PRTE_API.delete_ELIG_SVC_AREA_PRTE(
18929 --
18930 p_validate => false
18931 ,p_elig_svc_area_prte_id => l_elig_svc_area_prte_id
18932 ,p_effective_start_date => l_effective_start_date
18933 ,p_effective_end_date => l_effective_end_date
18934 ,p_object_version_number => l_object_version_number
18935 ,p_effective_date => l_max_eed
18936 ,p_datetrack_mode => hr_api.g_delete
18937 --
18938 );
18939 --
18940 end if;
18941 --
18942 l_prev_pk_id := l_current_pk_id ;
18943 --
18944 end if;
18945 --
18946 end if;
18947 --
18948 end loop;
18949 --
18950 exception when others then
18951 --
18952 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ESA',r_ESA.information5 ) ;
18953 --
18954 end create_ESA_rows;
18955
18956 --
18957 ---------------------------------------------------------------
18958 ----------------------< create_ESH_rows >-----------------------
18959 ---------------------------------------------------------------
18960 --
18961 procedure create_ESH_rows
18962 (
18963 p_validate in number default 0
18964 ,p_copy_entity_txn_id in number
18965 ,p_effective_date in date
18966 ,p_prefix_suffix_text in varchar2 default null
18967 ,p_reuse_object_flag in varchar2 default null
18968 ,p_target_business_group_id in varchar2 default null
18969 ,p_prefix_suffix_cd in varchar2 default null
18970 ) is
18971 --
18972 l_ELIGY_PRFL_ID number;
18973 l_HRS_NUM number;
18974 l_FREQ_CD varchar2(30);
18975 l_DETERMINATION_CD varchar2(30);
18976 l_DETERMINATION_RL number;
18977 l_MAX_HRS_NUM number;
18978 l_ROUNDING_CD varchar2(30);
18979 l_ROUNDING_RL number;
18980 l_SCHEDD_HRS_RL number;
18981 l_ORDR_NUM number;
18982
18983 cursor c_unique_ESH(l_table_alias varchar2) is
18984 select distinct cpe.information1,
18985 cpe.information2,
18986 cpe.information3,
18987 cpe.table_route_id
18988 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
18989 pqh_table_route tr
18990 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18991 and cpe.table_route_id = tr.table_route_id
18992 -- and tr.where_clause = l_BEN_ELIG_SCHEDD_HRS_PRTE_F
18993 and tr.table_alias = l_table_alias
18994 and cpe.number_of_copies = 1 -- ADDITION
18995 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
18996 order by information1, information2; --added for bug: 5151945
18997 --
18998 --
18999 cursor c_ESH_min_max_dates(c_table_route_id number,
19000 c_information1 number) is
19001 select
19002 min(cpe.information2) min_esd,
19003 max(cpe.information3) min_eed
19004 from ben_copy_entity_results cpe
19005 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19006 and cpe.table_route_id = c_table_route_id
19007 and cpe.information1 = c_information1 ;
19008 --
19009 cursor c_ESH(c_table_route_id number,
19010 c_information1 number,
19011 c_information2 date,
19012 c_information3 date ) is
19013 select
19014 cpe.*
19015 from ben_copy_entity_results cpe
19016 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19017 and cpe.table_route_id = c_table_route_id
19018 and cpe.information1 = c_information1
19019 and cpe.information2 = c_information2
19020 and cpe.information3 = c_information3
19021 and rownum = 1 ;
19022 -- Date Track target record
19023 cursor c_find_ESH_in_target(
19024 c_effective_start_date date,
19025 c_effective_end_date date,
19026 c_business_group_id number,
19027 c_new_pk_id number) is
19028 select
19029 ESH.elig_schedd_hrs_prte_id new_value
19030 from BEN_ELIG_SCHEDD_HRS_PRTE_F ESH
19031 where
19032 ESH.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
19033 NVL(ESH.HRS_NUM,-999) = NVL(l_HRS_NUM,-999) and
19034 NVL(ESH.FREQ_CD,-999) = NVL(l_FREQ_CD,-999) and
19035 NVL(ESH.DETERMINATION_CD,-999) = NVL(l_DETERMINATION_CD,-999) and
19036 NVL(ESH.DETERMINATION_RL,-999) = NVL(l_DETERMINATION_RL,-999) and
19037 NVL(ESH.MAX_HRS_NUM,-999) = NVL(l_MAX_HRS_NUM,-999) and
19038 NVL(ESH.ROUNDING_CD,-999) = NVL(l_ROUNDING_CD,-999) and
19039 NVL(ESH.ROUNDING_RL,-999) = NVL(l_ROUNDING_RL,-999) and
19040 NVL(ESH.SCHEDD_HRS_RL,-999) = NVL(l_SCHEDD_HRS_RL,-999) and
19041 ESH.ORDR_NUM = l_ORDR_NUM and
19042 ESH.business_group_id = c_business_group_id
19043 and ESH.elig_schedd_hrs_prte_id <> c_new_pk_id
19044 and c_effective_start_date between effective_start_date
19045 and effective_end_date ;
19046 --END TEMPIK
19047 /*TEMPIK
19048 and exists ( select null
19049 from BEN_ELIG_SCHEDD_HRS_PRTE_F ESH1
19050 where
19051 ESH1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
19052 NVL(ESH1.HRS_NUM,-999) = NVL(l_HRS_NUM,-999) and
19053 NVL(ESH1.FREQ_CD,-999) = NVL(l_FREQ_CD,-999) and
19054 NVL(ESH1.DETERMINATION_CD,-999) = NVL(l_DETERMINATION_CD,-999) and
19055 NVL(ESH1.DETERMINATION_RL,-999) = NVL(l_DETERMINATION_RL,-999) and
19056 NVL(ESH1.MAX_HRS_NUM,-999) = NVL(l_MAX_HRS_NUM,-999) and
19057 NVL(ESH1.ROUNDING_CD,-999) = NVL(l_ROUNDING_CD,-999) and
19058 NVL(ESH1.ROUNDING_RL,-999) = NVL(l_ROUNDING_RL,-999) and
19059 NVL(ESH1.SCHEDD_HRS_RL,-999) = NVL(l_SCHEDD_HRS_RL,-999) and
19060 ESH1.ORDR_NUM = l_ORDR_NUM and
19061 ESH1.business_group_id = c_business_group_id
19062 and ESH1.effective_start_date <= c_effective_start_date )
19063 and exists ( select null
19064 from BEN_ELIG_SCHEDD_HRS_PRTE_F ESH2
19065 where
19066 ESH2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
19067 NVL(ESH2.HRS_NUM,-999) = NVL(l_HRS_NUM,-999) and
19068 NVL(ESH2.FREQ_CD,-999) = NVL(l_FREQ_CD,-999) and
19069 NVL(ESH2.DETERMINATION_CD,-999) = NVL(l_DETERMINATION_CD,-999) and
19070 NVL(ESH2.DETERMINATION_RL,-999) = NVL(l_DETERMINATION_RL,-999) and
19071 NVL(ESH2.MAX_HRS_NUM,-999) = NVL(l_MAX_HRS_NUM,-999) and
19072 NVL(ESH2.ROUNDING_CD,-999) = NVL(l_ROUNDING_CD,-999) and
19073 NVL(ESH2.ROUNDING_RL,-999) = NVL(l_ROUNDING_RL,-999) and
19074 NVL(ESH2.SCHEDD_HRS_RL,-999) = NVL(l_SCHEDD_HRS_RL,-999) and
19075 ESH2.ORDR_NUM = l_ORDR_NUM and
19076 ESH2.business_group_id = c_business_group_id
19077 and ESH2.effective_end_date >= c_effective_end_date )
19078 ;
19079 TEMPIK */
19080 --TEMPIK
19081 l_dt_rec_found boolean ;
19082 --END TEMPIK
19083 --
19084
19085 --UPD START
19086 --
19087 l_update boolean := false ;
19088 l_datetrack_mode varchar2(80) := hr_api.g_update;
19089 l_process_date date;
19090 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
19091 --
19092 --UPD END
19093 l_current_pk_id number := null ;
19094
19095 l_prev_pk_id number := null ;
19096 l_first_rec boolean := true ;
19097 r_ESH c_ESH%rowtype;
19098 l_elig_schedd_hrs_prte_id number ;
19099 l_object_version_number number ;
19100 l_effective_start_date date ;
19101 l_effective_end_date date ;
19102 l_prefix pqh_copy_entity_attribs.information1%type := null;
19103 l_suffix pqh_copy_entity_attribs.information1%type := null;
19104 l_new_value number(15);
19105 l_object_found_in_target boolean := false ;
19106 l_min_esd date;
19107 l_max_eed date;
19108 l_effective_date date;
19109 --
19110 begin
19111 -- Initialization
19112 l_object_found_in_target := false ;
19113 -- End Initialization
19114 -- Derive the prefix - sufix
19115 if p_prefix_suffix_cd = 'PREFIX' then
19116 l_prefix := p_prefix_suffix_text ;
19117 elsif p_prefix_suffix_cd = 'SUFFIX' then
19118 l_suffix := p_prefix_suffix_text ;
19119 else
19120 l_prefix := null ;
19121 l_suffix := null ;
19122 end if ;
19123 -- End Prefix Sufix derivation
19124 for r_ESH_unique in c_unique_ESH('ESH') loop
19125
19126 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
19127 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19128 r_ESH_unique.information3 >=
19129 ben_pd_copy_to_ben_one.g_copy_effective_date)
19130 ) then
19131 --
19132 hr_utility.set_location(' r_ESH_unique.table_route_id '||r_ESH_unique.table_route_id,10);
19133 hr_utility.set_location(' r_ESH_unique.information1 '||r_ESH_unique.information1,10);
19134 hr_utility.set_location( 'r_ESH_unique.information2 '||r_ESH_unique.information2,10);
19135 hr_utility.set_location( 'r_ESH_unique.information3 '||r_ESH_unique.information3,10);
19136 -- If reuse objects flag is 'Y' then check for the object in the target business group
19137 -- if found insert the record into PLSql table and exit the loop else try create the
19138 -- object in the target business group
19139 --
19140 l_object_found_in_target := false ;
19141 --UPD START
19142 l_update := false;
19143 l_process_date := p_effective_date;
19144 l_dml_operation:= r_ESH_unique.dml_operation ;
19145 --
19146 /**********************moved from below **********************/
19147 open c_ESH(r_ESH_unique.table_route_id,
19148 r_ESH_unique.information1,
19149 r_ESH_unique.information2,
19150 r_ESH_unique.information3 ) ;
19151 --
19152 fetch c_ESH into r_ESH ;
19153 --
19154 close c_ESH ;
19155 --
19156 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ESH.INFORMATION263,l_dml_operation); -- Changed from 11
19157 l_HRS_NUM := r_ESH.INFORMATION288; --Added this criteria
19158 l_FREQ_CD := r_ESH.INFORMATION14; --Added this criteria
19159 l_DETERMINATION_CD := r_ESH.INFORMATION11;
19160 l_DETERMINATION_RL := get_fk('FORMULA_ID', r_ESH.INFORMATION259,l_dml_operation);
19161 l_MAX_HRS_NUM := r_ESH.INFORMATION287;
19162 l_ROUNDING_CD := r_ESH.INFORMATION12;
19163 l_ROUNDING_RL := get_fk('FORMULA_ID', r_ESH.INFORMATION257,l_dml_operation);
19164 l_SCHEDD_HRS_RL := get_fk('FORMULA_ID', r_ESH.INFORMATION258,l_dml_operation);
19165 l_ORDR_NUM := r_ESH.INFORMATION264;
19166
19167 /**********************************************************/
19168
19169 if l_dml_operation = 'UPDATE' then
19170 --
19171 l_object_found_in_target := TRUE;
19172 --
19173 if l_process_date between r_ESH_unique.information2 and r_ESH_unique.information3 then
19174 l_update := true;
19175 if r_ESH_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
19176 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_SCHEDD_HRS_PRTE_ID' then
19177 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_SCHEDD_HRS_PRTE_ID' ;
19178 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ESH_unique.information1 ;
19179 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ESH_unique.information1 ;
19180 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19181 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ESH_unique.table_route_id;
19182 --
19183 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
19184 --
19185 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19186 --
19187 -- log_data('ESH',l_new_value,l_prefix || r_ESH_unique.name|| l_suffix,'REUSED');
19188 --
19189 end if ;
19190 hr_utility.set_location( 'found record for update',10);
19191 --
19192 else
19193 --
19194 l_update := false;
19195 --
19196 end if;
19197 else
19198 --
19199 --UPD END
19200 l_min_esd := null ;
19201 l_max_eed := null ;
19202 open c_ESH_min_max_dates(r_ESH_unique.table_route_id, r_ESH_unique.information1 ) ;
19203 fetch c_ESH_min_max_dates into l_min_esd,l_max_eed ;
19204 --
19205
19206 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19207 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19208 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
19209 end if;
19210 l_min_esd := greatest(l_min_esd,r_ESH_unique.information2);
19211 /**********************moved up from here **********************
19212 open c_ESH(r_ESH_unique.table_route_id,
19213 r_ESH_unique.information1,
19214 r_ESH_unique.information2,
19215 r_ESH_unique.information3 ) ;
19216 --
19217 fetch c_ESH into r_ESH ;
19218 --
19219 close c_ESH ;
19220 --
19221 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ESH.INFORMATION263,l_dml_operation); -- Changed from 11
19222 l_HRS_NUM := r_ESH.INFORMATION288; --Added this criteria
19223 l_FREQ_CD := r_ESH.INFORMATION14; --Added this criteria
19224 l_DETERMINATION_CD := r_ESH.INFORMATION11;
19225 l_DETERMINATION_RL := get_fk('FORMULA_ID', r_ESH.INFORMATION259,l_dml_operation);
19226 l_MAX_HRS_NUM := r_ESH.INFORMATION287;
19227 l_ROUNDING_CD := r_ESH.INFORMATION12;
19228 l_ROUNDING_RL := get_fk('FORMULA_ID', r_ESH.INFORMATION257,l_dml_operation);
19229 l_SCHEDD_HRS_RL := get_fk('FORMULA_ID', r_ESH.INFORMATION258,l_dml_operation);
19230 l_ORDR_NUM := r_ESH.INFORMATION264;
19231
19232 **********************************************************/
19233
19234
19235 if p_reuse_object_flag = 'Y' then
19236 if c_ESH_min_max_dates%found then
19237 -- cursor to find the object
19238 open c_find_ESH_in_target( l_min_esd,l_max_eed,
19239 p_target_business_group_id, nvl(l_elig_schedd_hrs_prte_id, -999) ) ;
19240 fetch c_find_ESH_in_target into l_new_value ;
19241 if c_find_ESH_in_target%found then
19242 --
19243 --TEMPIK
19244 l_dt_rec_found := dt_api.check_min_max_dates
19245 (p_base_table_name => 'BEN_ELIG_SCHEDD_HRS_PRTE_F',
19246 p_base_key_column => 'ELIG_SCHEDD_HRS_PRTE_ID',
19247 p_base_key_value => l_new_value,
19248 p_from_date => l_min_esd,
19249 p_to_date => l_max_eed );
19250 if l_dt_rec_found THEN
19251 --END TEMPIK
19252 if r_ESH_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
19253 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_SCHEDD_HRS_PRTE_ID' then
19254 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_SCHEDD_HRS_PRTE_ID' ;
19255 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ESH_unique.information1 ;
19256 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
19257 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19258 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ESH_unique.table_route_id;
19259 --
19260 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
19261 --
19262 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19263 end if ;
19264 --
19265 l_object_found_in_target := true ;
19266 --TEMPIK
19267 end if; -- l_dt_rec_found
19268 --END TEMPIK
19269 end if;
19270 close c_find_ESH_in_target ;
19271 --
19272 end if;
19273 end if ;
19274 --
19275 close c_ESH_min_max_dates ;
19276 end if; --if p_dml_operation
19277 --
19278 if not l_object_found_in_target OR l_update then
19279
19280 --
19281 l_current_pk_id := r_ESH.information1;
19282 --
19283 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
19284 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
19285 --
19286 if l_current_pk_id = l_prev_pk_id then
19287 --
19288 l_first_rec := false ;
19289 --
19290 else
19291 --
19292 l_first_rec := true ;
19293 --
19294 end if ;
19295 --
19296
19297 l_effective_date := r_ESH.information2;
19298 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19299 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19300 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
19301 end if;
19302
19303 if l_first_rec and not l_update then
19304 -- Call Create routine.
19305 hr_utility.set_location(' BEN_ELIG_SCHEDD_HRS_PRTE_F CREATE_ELIG_SCHEDD_HRS_PRTE ',20);
19306 BEN_ELIG_SCHEDD_HRS_PRTE_API.CREATE_ELIG_SCHEDD_HRS_PRTE(
19307 --
19308 P_VALIDATE => false
19309 ,P_EFFECTIVE_DATE => l_effective_date
19310 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19311 --
19312 ,P_DETERMINATION_CD => r_ESH.INFORMATION11
19313 ,P_DETERMINATION_RL => l_DETERMINATION_RL
19314 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
19315 ,P_ELIG_SCHEDD_HRS_PRTE_ID => l_elig_schedd_hrs_prte_id
19316 ,P_ESH_ATTRIBUTE1 => r_ESH.INFORMATION111
19317 ,P_ESH_ATTRIBUTE10 => r_ESH.INFORMATION120
19318 ,P_ESH_ATTRIBUTE11 => r_ESH.INFORMATION121
19319 ,P_ESH_ATTRIBUTE12 => r_ESH.INFORMATION122
19320 ,P_ESH_ATTRIBUTE13 => r_ESH.INFORMATION123
19321 ,P_ESH_ATTRIBUTE14 => r_ESH.INFORMATION124
19322 ,P_ESH_ATTRIBUTE15 => r_ESH.INFORMATION125
19323 ,P_ESH_ATTRIBUTE16 => r_ESH.INFORMATION126
19324 ,P_ESH_ATTRIBUTE17 => r_ESH.INFORMATION127
19325 ,P_ESH_ATTRIBUTE18 => r_ESH.INFORMATION128
19326 ,P_ESH_ATTRIBUTE19 => r_ESH.INFORMATION129
19327 ,P_ESH_ATTRIBUTE2 => r_ESH.INFORMATION112
19328 ,P_ESH_ATTRIBUTE20 => r_ESH.INFORMATION130
19329 ,P_ESH_ATTRIBUTE21 => r_ESH.INFORMATION131
19330 ,P_ESH_ATTRIBUTE22 => r_ESH.INFORMATION132
19331 ,P_ESH_ATTRIBUTE23 => r_ESH.INFORMATION133
19332 ,P_ESH_ATTRIBUTE24 => r_ESH.INFORMATION134
19333 ,P_ESH_ATTRIBUTE25 => r_ESH.INFORMATION135
19334 ,P_ESH_ATTRIBUTE26 => r_ESH.INFORMATION136
19335 ,P_ESH_ATTRIBUTE27 => r_ESH.INFORMATION137
19336 ,P_ESH_ATTRIBUTE28 => r_ESH.INFORMATION138
19337 ,P_ESH_ATTRIBUTE29 => r_ESH.INFORMATION139
19338 ,P_ESH_ATTRIBUTE3 => r_ESH.INFORMATION113
19339 ,P_ESH_ATTRIBUTE30 => r_ESH.INFORMATION140
19340 ,P_ESH_ATTRIBUTE4 => r_ESH.INFORMATION114
19341 ,P_ESH_ATTRIBUTE5 => r_ESH.INFORMATION115
19342 ,P_ESH_ATTRIBUTE6 => r_ESH.INFORMATION116
19343 ,P_ESH_ATTRIBUTE7 => r_ESH.INFORMATION117
19344 ,P_ESH_ATTRIBUTE8 => r_ESH.INFORMATION118
19345 ,P_ESH_ATTRIBUTE9 => r_ESH.INFORMATION119
19346 ,P_ESH_ATTRIBUTE_CATEGORY => r_ESH.INFORMATION110
19347 ,P_EXCLD_FLAG => r_ESH.INFORMATION13
19348 ,P_FREQ_CD => r_ESH.INFORMATION14
19349 ,P_HRS_NUM => r_ESH.INFORMATION288
19350 ,P_MAX_HRS_NUM => r_ESH.INFORMATION287
19351 ,P_ORDR_NUM => r_ESH.INFORMATION264
19352 ,P_ROUNDING_CD => r_ESH.INFORMATION12
19353 ,P_ROUNDING_RL => l_ROUNDING_RL
19354 ,P_SCHEDD_HRS_RL => l_SCHEDD_HRS_RL
19355 --
19356 --****** END CHANGE LINES
19357
19358 --
19359
19360 ,P_EFFECTIVE_START_DATE => l_effective_start_date
19361 ,P_EFFECTIVE_END_DATE => l_effective_end_date
19362 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
19363 ,P_CRITERIA_SCORE => r_esh.INFORMATION295
19364 ,P_CRITERIA_WEIGHT => r_esh.INFORMATION296
19365 );
19366 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
19367 -- Update all relevent cer records with new pk_id
19368 hr_utility.set_location('Before plsql table ',222);
19369 hr_utility.set_location('new_value id '||l_elig_schedd_hrs_prte_id,222);
19370 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_SCHEDD_HRS_PRTE_ID' ;
19371 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ESH.information1 ;
19372 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_SCHEDD_HRS_PRTE_ID ;
19373 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
19374 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ESH_unique.table_route_id;
19375 hr_utility.set_location('After plsql table ',222);
19376 --
19377 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
19378 --
19379 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19380 --
19381 else
19382 --
19383 -- Call Update routine for the pk_id created in prev run .
19384 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
19385 hr_utility.set_location(' BEN_ELIG_SCHEDD_HRS_PRTE_F UPDATE_ELIG_SCHEDD_HRS_PRTE ',30);
19386 --UPD START
19387 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
19388 --
19389 if l_update then
19390 --
19391 l_datetrack_mode := r_ESH.datetrack_mode ;
19392 --
19393 get_dt_modes(
19394 p_effective_date => l_process_date,
19395 p_effective_end_date => r_ESH.information3,
19396 p_effective_start_date => r_ESH.information2,
19397 p_dml_operation => r_ESH.dml_operation,
19398 p_datetrack_mode => l_datetrack_mode );
19399 -- p_update => l_update
19400 --
19401 l_effective_date := l_process_date;
19402 l_ELIG_SCHEDD_HRS_PRTE_ID := r_ESH.information1;
19403 l_object_version_number := r_ESH.information265;
19404 --
19405 end if;
19406 --
19407 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
19408 --
19409 IF l_update OR l_dml_operation <> 'UPDATE' THEN
19410 --UPD END
19411
19412
19413 BEN_ELIG_SCHEDD_HRS_PRTE_API.UPDATE_ELIG_SCHEDD_HRS_PRTE(
19414 --
19415 P_VALIDATE => false
19416 ,P_EFFECTIVE_DATE => l_effective_date
19417 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19418 --
19419 ,P_DETERMINATION_CD => r_ESH.INFORMATION11
19420 ,P_DETERMINATION_RL => l_DETERMINATION_RL
19421 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
19422 ,P_ELIG_SCHEDD_HRS_PRTE_ID => l_elig_schedd_hrs_prte_id
19423 ,P_ESH_ATTRIBUTE1 => r_ESH.INFORMATION111
19424 ,P_ESH_ATTRIBUTE10 => r_ESH.INFORMATION120
19425 ,P_ESH_ATTRIBUTE11 => r_ESH.INFORMATION121
19426 ,P_ESH_ATTRIBUTE12 => r_ESH.INFORMATION122
19427 ,P_ESH_ATTRIBUTE13 => r_ESH.INFORMATION123
19428 ,P_ESH_ATTRIBUTE14 => r_ESH.INFORMATION124
19429 ,P_ESH_ATTRIBUTE15 => r_ESH.INFORMATION125
19430 ,P_ESH_ATTRIBUTE16 => r_ESH.INFORMATION126
19431 ,P_ESH_ATTRIBUTE17 => r_ESH.INFORMATION127
19432 ,P_ESH_ATTRIBUTE18 => r_ESH.INFORMATION128
19433 ,P_ESH_ATTRIBUTE19 => r_ESH.INFORMATION129
19434 ,P_ESH_ATTRIBUTE2 => r_ESH.INFORMATION112
19435 ,P_ESH_ATTRIBUTE20 => r_ESH.INFORMATION130
19436 ,P_ESH_ATTRIBUTE21 => r_ESH.INFORMATION131
19437 ,P_ESH_ATTRIBUTE22 => r_ESH.INFORMATION132
19438 ,P_ESH_ATTRIBUTE23 => r_ESH.INFORMATION133
19439 ,P_ESH_ATTRIBUTE24 => r_ESH.INFORMATION134
19440 ,P_ESH_ATTRIBUTE25 => r_ESH.INFORMATION135
19441 ,P_ESH_ATTRIBUTE26 => r_ESH.INFORMATION136
19442 ,P_ESH_ATTRIBUTE27 => r_ESH.INFORMATION137
19443 ,P_ESH_ATTRIBUTE28 => r_ESH.INFORMATION138
19444 ,P_ESH_ATTRIBUTE29 => r_ESH.INFORMATION139
19445 ,P_ESH_ATTRIBUTE3 => r_ESH.INFORMATION113
19446 ,P_ESH_ATTRIBUTE30 => r_ESH.INFORMATION140
19447 ,P_ESH_ATTRIBUTE4 => r_ESH.INFORMATION114
19448 ,P_ESH_ATTRIBUTE5 => r_ESH.INFORMATION115
19449 ,P_ESH_ATTRIBUTE6 => r_ESH.INFORMATION116
19450 ,P_ESH_ATTRIBUTE7 => r_ESH.INFORMATION117
19451 ,P_ESH_ATTRIBUTE8 => r_ESH.INFORMATION118
19452 ,P_ESH_ATTRIBUTE9 => r_ESH.INFORMATION119
19453 ,P_ESH_ATTRIBUTE_CATEGORY => r_ESH.INFORMATION110
19454 ,P_EXCLD_FLAG => r_ESH.INFORMATION13
19455 ,P_FREQ_CD => r_ESH.INFORMATION14
19456 ,P_HRS_NUM => r_ESH.INFORMATION288
19457 ,P_MAX_HRS_NUM => r_ESH.INFORMATION287
19458 ,P_ORDR_NUM => r_ESH.INFORMATION264
19459 ,P_ROUNDING_CD => r_ESH.INFORMATION12
19460 ,P_ROUNDING_RL => l_ROUNDING_RL
19461 ,P_SCHEDD_HRS_RL => l_SCHEDD_HRS_RL
19462 --
19463 -- ****** END CHANGE LINES
19464
19465 --
19466 ,P_EFFECTIVE_START_DATE => l_effective_start_date
19467 ,P_EFFECTIVE_END_DATE => l_effective_end_date
19468 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
19469 ,P_DATETRACK_MODE => l_datetrack_mode
19470 ,P_CRITERIA_SCORE => r_esh.INFORMATION295
19471 ,P_CRITERIA_WEIGHT => r_esh.INFORMATION296
19472 );
19473 end if; -- l_update
19474 --
19475 end if;
19476 --
19477 -- Delete the row if it is end dated.
19478 --
19479 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
19480 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
19481 trunc(l_max_eed) = trunc(r_ESH.information3)) then
19482 --
19483 BEN_ELIG_SCHEDD_HRS_PRTE_API.delete_ELIG_SCHEDD_HRS_PRTE(
19484 --
19485 p_validate => false
19486 ,p_elig_schedd_hrs_prte_id => l_elig_schedd_hrs_prte_id
19487 ,p_effective_start_date => l_effective_start_date
19488 ,p_effective_end_date => l_effective_end_date
19489 ,p_object_version_number => l_object_version_number
19490 ,p_effective_date => l_max_eed
19491 ,p_datetrack_mode => hr_api.g_delete
19492 --
19493 );
19494 --
19495 end if;
19496 --
19497 l_prev_pk_id := l_current_pk_id ;
19498 --
19499 end if;
19500 --
19501 end if;
19502 --
19503 end loop;
19504 --
19505 exception when others then
19506 --
19507 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ESH',r_ESH.information5 ) ;
19508 --
19509 end create_ESH_rows;
19510
19511 --
19512 ---------------------------------------------------------------
19513 ----------------------< create_ESP_rows >-----------------------
19514 ---------------------------------------------------------------
19515 --
19516 procedure create_ESP_rows
19517 (
19518 p_validate in number default 0
19519 ,p_copy_entity_txn_id in number
19520 ,p_effective_date in date
19521 ,p_prefix_suffix_text in varchar2 default null
19522 ,p_reuse_object_flag in varchar2 default null
19523 ,p_target_business_group_id in varchar2 default null
19524 ,p_prefix_suffix_cd in varchar2 default null
19525 ) is
19526 --
19527 l_ELIGY_PRFL_ID number;
19528 l_SPECIAL_CEILING_STEP_ID number;
19529 l_ORDR_NUM number;
19530 cursor c_unique_ESP(l_table_alias varchar2) is
19531 select distinct cpe.information1,
19532 cpe.information2,
19533 cpe.information3,
19534 cpe.table_route_id
19535 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
19536 pqh_table_route tr
19537 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19538 and cpe.table_route_id = tr.table_route_id
19539 -- and tr.where_clause = l_BEN_ELIG_SP_CLNG_PRG_PRTE_F
19540 and tr.table_alias = l_table_alias
19541 and cpe.number_of_copies = 1 -- ADDITION
19542 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
19543 order by information1, information2; --added for bug: 5151945
19544 --
19545 --
19546 cursor c_ESP_min_max_dates(c_table_route_id number,
19547 c_information1 number) is
19548 select
19549 min(cpe.information2) min_esd,
19550 max(cpe.information3) min_eed
19551 from ben_copy_entity_results cpe
19552 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19553 and cpe.table_route_id = c_table_route_id
19554 and cpe.information1 = c_information1 ;
19555 --
19556 cursor c_ESP(c_table_route_id number,
19557 c_information1 number,
19558 c_information2 date,
19559 c_information3 date ) is
19560 select
19561 cpe.*
19562 from ben_copy_entity_results cpe
19563 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19564 and cpe.table_route_id = c_table_route_id
19565 and cpe.information1 = c_information1
19566 and cpe.information2 = c_information2
19567 and cpe.information3 = c_information3
19568 and rownum = 1 ;
19569 -- Date Track target record
19570 cursor c_find_ESP_in_target(
19571 c_effective_start_date date,
19572 c_effective_end_date date,
19573 c_business_group_id number,
19574 c_new_pk_id number) is
19575 select
19576 ESP.elig_sp_clng_prg_prte_id new_value
19577 from BEN_ELIG_SP_CLNG_PRG_PRTE_F ESP
19578 where
19579 ESP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
19580 ESP.SPECIAL_CEILING_STEP_ID = l_SPECIAL_CEILING_STEP_ID and
19581 ESP.business_group_id = c_business_group_id
19582 and ESP.elig_sp_clng_prg_prte_id <> c_new_pk_id
19583 and c_effective_start_date between effective_start_date
19584 and effective_end_date ;
19585 --END TEMPIK
19586 /*TEMPIK
19587 and exists ( select null
19588 from BEN_ELIG_SP_CLNG_PRG_PRTE_F ESP1
19589 where
19590 ESP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
19591 ESP1.SPECIAL_CEILING_STEP_ID = l_SPECIAL_CEILING_STEP_ID and
19592 ESP1.ORDR_NUM = l_ORDR_NUM and -- Added this criteria
19593 ESP1.business_group_id = c_business_group_id
19594 and ESP1.effective_start_date <= c_effective_start_date )
19595 and exists ( select null
19596 from BEN_ELIG_SP_CLNG_PRG_PRTE_F ESP2
19597 where
19598 ESP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
19599 ESP2.SPECIAL_CEILING_STEP_ID = l_SPECIAL_CEILING_STEP_ID and
19600 ESP2.ORDR_NUM = l_ORDR_NUM and -- Added this criteria
19601 ESP2.business_group_id = c_business_group_id
19602 and ESP2.effective_end_date >= c_effective_end_date )
19603 ;
19604 TEMPIK */
19605 --TEMPIK
19606 l_dt_rec_found boolean ;
19607 --END TEMPIK
19608 --
19609
19610 --UPD START
19611 --
19612 l_update boolean := false ;
19613 l_datetrack_mode varchar2(80) := hr_api.g_update;
19614 l_process_date date;
19615 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
19616 --
19617 --UPD END
19618 l_current_pk_id number := null ;
19619
19620 l_prev_pk_id number := null ;
19621 l_first_rec boolean := true ;
19622 r_ESP c_ESP%rowtype;
19623 l_elig_sp_clng_prg_prte_id number ;
19624 l_object_version_number number ;
19625 l_effective_start_date date ;
19626 l_effective_end_date date ;
19627 l_prefix pqh_copy_entity_attribs.information1%type := null;
19628 l_suffix pqh_copy_entity_attribs.information1%type := null;
19629 l_new_value number(15);
19630 l_object_found_in_target boolean := false ;
19631 l_min_esd date;
19632 l_max_eed date;
19633 l_effective_date date;
19634 --
19635 begin
19636 -- Initialization
19637 l_object_found_in_target := false ;
19638 -- End Initialization
19639 -- Derive the prefix - sufix
19640 if p_prefix_suffix_cd = 'PREFIX' then
19641 l_prefix := p_prefix_suffix_text ;
19642 elsif p_prefix_suffix_cd = 'SUFFIX' then
19643 l_suffix := p_prefix_suffix_text ;
19644 else
19645 l_prefix := null ;
19646 l_suffix := null ;
19647 end if ;
19648 -- End Prefix Sufix derivation
19649 for r_ESP_unique in c_unique_ESP('ESP') loop
19650
19651 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
19652 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19653 r_ESP_unique.information3 >=
19654 ben_pd_copy_to_ben_one.g_copy_effective_date)
19655 ) then
19656 --
19657 hr_utility.set_location(' r_ESP_unique.table_route_id '||r_ESP_unique.table_route_id,10);
19658 hr_utility.set_location(' r_ESP_unique.information1 '||r_ESP_unique.information1,10);
19659 hr_utility.set_location( 'r_ESP_unique.information2 '||r_ESP_unique.information2,10);
19660 hr_utility.set_location( 'r_ESP_unique.information3 '||r_ESP_unique.information3,10);
19661 -- If reuse objects flag is 'Y' then check for the object in the target business group
19662 -- if found insert the record into PLSql table and exit the loop else try create the
19663 -- object in the target business group
19664 --
19665 l_object_found_in_target := false ;
19666 --UPD START
19667 l_update := false;
19668 l_process_date := p_effective_date;
19669 l_dml_operation:= r_ESP_unique.dml_operation ;
19670 --
19671 /**********************moved from below **********************/
19672 open c_ESP(r_ESP_unique.table_route_id,
19673 r_ESP_unique.information1,
19674 r_ESP_unique.information2,
19675 r_ESP_unique.information3 ) ;
19676 --
19677 fetch c_ESP into r_ESP ;
19678 --
19679 close c_ESP ;
19680 --
19681 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ESP.INFORMATION263,l_dml_operation);
19682 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
19683 l_SPECIAL_CEILING_STEP_ID := r_ESP.information176;
19684 else
19685 l_SPECIAL_CEILING_STEP_ID := r_ESP.information174;
19686 end if;
19687 --
19688 l_ORDR_NUM := r_ESP.INFORMATION257; -- Added this criteria
19689
19690 /**********************************************************/
19691
19692 if l_dml_operation = 'UPDATE' then
19693 --
19694 l_object_found_in_target := TRUE;
19695 --
19696 if l_process_date between r_ESP_unique.information2 and r_ESP_unique.information3 then
19697 l_update := true;
19698 if r_ESP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
19699 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_SP_CLNG_PRG_PRTE_ID' then
19700 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_SP_CLNG_PRG_PRTE_ID' ;
19701 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ESP_unique.information1 ;
19702 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ESP_unique.information1 ;
19703 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19704 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ESP_unique.table_route_id;
19705 --
19706 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
19707 --
19708 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19709 --
19710 -- log_data('ESP',l_new_value,l_prefix || r_ESP_unique.name|| l_suffix,'REUSED');
19711 --
19712 end if ;
19713 hr_utility.set_location( 'found record for update',10);
19714 --
19715 else
19716 --
19717 l_update := false;
19718 --
19719 end if;
19720 else
19721 --
19722 --UPD END
19723 l_min_esd := null ;
19724 l_max_eed := null ;
19725 open c_ESP_min_max_dates(r_ESP_unique.table_route_id, r_ESP_unique.information1 ) ;
19726 fetch c_ESP_min_max_dates into l_min_esd,l_max_eed ;
19727 --
19728
19729 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19730 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19731 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
19732 end if;
19733 l_min_esd := greatest(l_min_esd,r_ESP_unique.information2);
19734 /**********************moved up from here **********************
19735 open c_ESP(r_ESP_unique.table_route_id,
19736 r_ESP_unique.information1,
19737 r_ESP_unique.information2,
19738 r_ESP_unique.information3 ) ;
19739 --
19740 fetch c_ESP into r_ESP ;
19741 --
19742 close c_ESP ;
19743 --
19744 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ESP.INFORMATION263,l_dml_operation);
19745 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
19746 l_SPECIAL_CEILING_STEP_ID := r_ESP.information176;
19747 else
19748 l_SPECIAL_CEILING_STEP_ID := r_ESP.information174;
19749 end if;
19750 --
19751 l_ORDR_NUM := r_ESP.INFORMATION257; -- Added this criteria
19752
19753 **********************************************************/
19754
19755
19756 if l_SPECIAL_CEILING_STEP_ID is null then
19757 close c_ESP_min_max_dates;
19758 --
19759 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
19760 ,p_parent_pk_id => r_ESP.information263
19761 ,p_copy_entity_txn_id => p_copy_entity_txn_id
19762 ,p_child_table_alias => 'ESP'
19763 ,p_child_data => r_ESP.information173 );
19764
19765 --
19766 else
19767 if p_reuse_object_flag = 'Y' then
19768 if c_ESP_min_max_dates%found then
19769 -- cursor to find the object
19770 open c_find_ESP_in_target( l_min_esd,l_max_eed,
19771 p_target_business_group_id, nvl(l_elig_sp_clng_prg_prte_id, -999) ) ;
19772 fetch c_find_ESP_in_target into l_new_value ;
19773 if c_find_ESP_in_target%found then
19774 --
19775 --TEMPIK
19776 l_dt_rec_found := dt_api.check_min_max_dates
19777 (p_base_table_name => 'BEN_ELIG_SP_CLNG_PRG_PRTE_F',
19778 p_base_key_column => 'ELIG_SP_CLNG_PRG_PRTE_ID',
19779 p_base_key_value => l_new_value,
19780 p_from_date => l_min_esd,
19781 p_to_date => l_max_eed );
19782 if l_dt_rec_found THEN
19783 --END TEMPIK
19784 if r_ESP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
19785 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_SP_CLNG_PRG_PRTE_ID' then
19786 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_SP_CLNG_PRG_PRTE_ID' ;
19787 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ESP_unique.information1 ;
19788 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
19789 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19790 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ESP_unique.table_route_id;
19791 --
19792 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
19793 --
19794 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19795 end if ;
19796 --
19797 l_object_found_in_target := true ;
19798 --TEMPIK
19799 end if; -- l_dt_rec_found
19800 --END TEMPIK
19801 end if;
19802 close c_find_ESP_in_target ;
19803 --
19804 end if;
19805 end if ;
19806 --
19807 close c_ESP_min_max_dates ;
19808 end if; --if p_dml_operation
19809 --
19810 if ( not l_object_found_in_target OR l_update) and (l_SPECIAL_CEILING_STEP_ID is not null) then -- bug # 4251900
19811
19812
19813 --
19814 l_current_pk_id := r_ESP.information1;
19815 --
19816 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
19817 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
19818 --
19819 if l_current_pk_id = l_prev_pk_id then
19820 --
19821 l_first_rec := false ;
19822 --
19823 else
19824 --
19825 l_first_rec := true ;
19826 --
19827 end if ;
19828 --
19829
19830 l_effective_date := r_ESP.information2;
19831 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19832 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19833 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
19834 end if;
19835
19836 if l_first_rec and not l_update then
19837 -- Call Create routine.
19838 hr_utility.set_location(' BEN_ELIG_SP_CLNG_PRG_PRTE_F CREATE_ELIG_SP_CLNG_PRG_PRTE ',20);
19839 BEN_ELIG_SP_CLNG_PRG_PRTE_API.CREATE_ELIG_SP_CLNG_PRG_PRTE(
19840 --
19841 P_VALIDATE => false
19842 ,P_EFFECTIVE_DATE => l_effective_date
19843 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19844 --
19845 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
19846 ,P_ELIG_SP_CLNG_PRG_PRTE_ID => l_elig_sp_clng_prg_prte_id
19847 ,P_ESP_ATTRIBUTE1 => r_ESP.INFORMATION111
19848 ,P_ESP_ATTRIBUTE10 => r_ESP.INFORMATION120
19849 ,P_ESP_ATTRIBUTE11 => r_ESP.INFORMATION121
19850 ,P_ESP_ATTRIBUTE12 => r_ESP.INFORMATION122
19851 ,P_ESP_ATTRIBUTE13 => r_ESP.INFORMATION123
19852 ,P_ESP_ATTRIBUTE14 => r_ESP.INFORMATION124
19853 ,P_ESP_ATTRIBUTE15 => r_ESP.INFORMATION125
19854 ,P_ESP_ATTRIBUTE16 => r_ESP.INFORMATION126
19855 ,P_ESP_ATTRIBUTE17 => r_ESP.INFORMATION127
19856 ,P_ESP_ATTRIBUTE18 => r_ESP.INFORMATION128
19857 ,P_ESP_ATTRIBUTE19 => r_ESP.INFORMATION129
19858 ,P_ESP_ATTRIBUTE2 => r_ESP.INFORMATION112
19859 ,P_ESP_ATTRIBUTE20 => r_ESP.INFORMATION130
19860 ,P_ESP_ATTRIBUTE21 => r_ESP.INFORMATION131
19861 ,P_ESP_ATTRIBUTE22 => r_ESP.INFORMATION132
19862 ,P_ESP_ATTRIBUTE23 => r_ESP.INFORMATION133
19863 ,P_ESP_ATTRIBUTE24 => r_ESP.INFORMATION134
19864 ,P_ESP_ATTRIBUTE25 => r_ESP.INFORMATION135
19865 ,P_ESP_ATTRIBUTE26 => r_ESP.INFORMATION136
19866 ,P_ESP_ATTRIBUTE27 => r_ESP.INFORMATION137
19867 ,P_ESP_ATTRIBUTE28 => r_ESP.INFORMATION138
19868 ,P_ESP_ATTRIBUTE29 => r_ESP.INFORMATION139
19869 ,P_ESP_ATTRIBUTE3 => r_ESP.INFORMATION113
19870 ,P_ESP_ATTRIBUTE30 => r_ESP.INFORMATION140
19871 ,P_ESP_ATTRIBUTE4 => r_ESP.INFORMATION114
19872 ,P_ESP_ATTRIBUTE5 => r_ESP.INFORMATION115
19873 ,P_ESP_ATTRIBUTE6 => r_ESP.INFORMATION116
19874 ,P_ESP_ATTRIBUTE7 => r_ESP.INFORMATION117
19875 ,P_ESP_ATTRIBUTE8 => r_ESP.INFORMATION118
19876 ,P_ESP_ATTRIBUTE9 => r_ESP.INFORMATION119
19877 ,P_ESP_ATTRIBUTE_CATEGORY => r_ESP.INFORMATION110
19878 ,P_EXCLD_FLAG => r_ESP.INFORMATION11
19879 ,P_ORDR_NUM => r_ESP.INFORMATION257
19880 ,P_SPECIAL_CEILING_STEP_ID => l_SPECIAL_CEILING_STEP_ID
19881 --
19882 -- ****** END CHANGE LINES
19883
19884 --
19885
19886 ,P_EFFECTIVE_START_DATE => l_effective_start_date
19887 ,P_EFFECTIVE_END_DATE => l_effective_end_date
19888 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
19889 ,P_CRITERIA_SCORE => r_esp.INFORMATION295
19890 ,P_CRITERIA_WEIGHT => r_esp.INFORMATION296
19891 );
19892 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
19893 -- Update all relevent cer records with new pk_id
19894 hr_utility.set_location('Before plsql table ',222);
19895 hr_utility.set_location('new_value id '||l_elig_sp_clng_prg_prte_id,222);
19896 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_SP_CLNG_PRG_PRTE_ID' ;
19897 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ESP.information1 ;
19898 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_SP_CLNG_PRG_PRTE_ID ;
19899 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
19900 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ESP_unique.table_route_id;
19901 hr_utility.set_location('After plsql table ',222);
19902 --
19903 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
19904 --
19905 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19906 --
19907 else
19908 --
19909 -- Call Update routine for the pk_id created in prev run .
19910 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
19911 hr_utility.set_location(' BEN_ELIG_SP_CLNG_PRG_PRTE_F UPDATE_ELIG_SP_CLNG_PRG_PRTE ',30);
19912 --UPD START
19913 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
19914 --
19915 if l_update then
19916 --
19917 l_datetrack_mode := r_ESP.datetrack_mode ;
19918 --
19919 get_dt_modes(
19920 p_effective_date => l_process_date,
19921 p_effective_end_date => r_ESP.information3,
19922 p_effective_start_date => r_ESP.information2,
19923 p_dml_operation => r_ESP.dml_operation,
19924 p_datetrack_mode => l_datetrack_mode );
19925 -- p_update => l_update
19926 --
19927 l_effective_date := l_process_date;
19928 l_ELIG_SP_CLNG_PRG_PRTE_ID := r_ESP.information1;
19929 l_object_version_number := r_ESP.information265;
19930 --
19931 end if;
19932 --
19933 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
19934 --
19935 IF l_update OR l_dml_operation <> 'UPDATE' THEN
19936 --UPD END
19937
19938
19939 BEN_ELIG_SP_CLNG_PRG_PRTE_API.UPDATE_ELIG_SP_CLNG_PRG_PRTE(
19940 --
19941 P_VALIDATE => false
19942 ,P_EFFECTIVE_DATE => l_effective_date
19943 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19944 --
19945 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
19946 ,P_ELIG_SP_CLNG_PRG_PRTE_ID => l_elig_sp_clng_prg_prte_id
19947 ,P_ESP_ATTRIBUTE1 => r_ESP.INFORMATION111
19948 ,P_ESP_ATTRIBUTE10 => r_ESP.INFORMATION120
19949 ,P_ESP_ATTRIBUTE11 => r_ESP.INFORMATION121
19950 ,P_ESP_ATTRIBUTE12 => r_ESP.INFORMATION122
19951 ,P_ESP_ATTRIBUTE13 => r_ESP.INFORMATION123
19952 ,P_ESP_ATTRIBUTE14 => r_ESP.INFORMATION124
19953 ,P_ESP_ATTRIBUTE15 => r_ESP.INFORMATION125
19954 ,P_ESP_ATTRIBUTE16 => r_ESP.INFORMATION126
19955 ,P_ESP_ATTRIBUTE17 => r_ESP.INFORMATION127
19956 ,P_ESP_ATTRIBUTE18 => r_ESP.INFORMATION128
19957 ,P_ESP_ATTRIBUTE19 => r_ESP.INFORMATION129
19958 ,P_ESP_ATTRIBUTE2 => r_ESP.INFORMATION112
19959 ,P_ESP_ATTRIBUTE20 => r_ESP.INFORMATION130
19960 ,P_ESP_ATTRIBUTE21 => r_ESP.INFORMATION131
19961 ,P_ESP_ATTRIBUTE22 => r_ESP.INFORMATION132
19962 ,P_ESP_ATTRIBUTE23 => r_ESP.INFORMATION133
19963 ,P_ESP_ATTRIBUTE24 => r_ESP.INFORMATION134
19964 ,P_ESP_ATTRIBUTE25 => r_ESP.INFORMATION135
19965 ,P_ESP_ATTRIBUTE26 => r_ESP.INFORMATION136
19966 ,P_ESP_ATTRIBUTE27 => r_ESP.INFORMATION137
19967 ,P_ESP_ATTRIBUTE28 => r_ESP.INFORMATION138
19968 ,P_ESP_ATTRIBUTE29 => r_ESP.INFORMATION139
19969 ,P_ESP_ATTRIBUTE3 => r_ESP.INFORMATION113
19970 ,P_ESP_ATTRIBUTE30 => r_ESP.INFORMATION140
19971 ,P_ESP_ATTRIBUTE4 => r_ESP.INFORMATION114
19972 ,P_ESP_ATTRIBUTE5 => r_ESP.INFORMATION115
19973 ,P_ESP_ATTRIBUTE6 => r_ESP.INFORMATION116
19974 ,P_ESP_ATTRIBUTE7 => r_ESP.INFORMATION117
19975 ,P_ESP_ATTRIBUTE8 => r_ESP.INFORMATION118
19976 ,P_ESP_ATTRIBUTE9 => r_ESP.INFORMATION119
19977 ,P_ESP_ATTRIBUTE_CATEGORY => r_ESP.INFORMATION110
19978 ,P_EXCLD_FLAG => r_ESP.INFORMATION11
19979 ,P_ORDR_NUM => r_ESP.INFORMATION257
19980 ,P_SPECIAL_CEILING_STEP_ID => l_SPECIAL_CEILING_STEP_ID
19981 --
19982 -- ****** END CHANGE LINES
19983
19984 --
19985 ,P_EFFECTIVE_START_DATE => l_effective_start_date
19986 ,P_EFFECTIVE_END_DATE => l_effective_end_date
19987 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
19988 ,P_DATETRACK_MODE => l_datetrack_mode
19989 ,P_CRITERIA_SCORE => r_esp.INFORMATION295
19990 ,P_CRITERIA_WEIGHT => r_esp.INFORMATION296
19991 );
19992 end if; -- l_update
19993 --
19994 end if;
19995 --
19996 -- Delete the row if it is end dated.
19997 --
19998 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
19999 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
20000 trunc(l_max_eed) = trunc(r_ESP.information3)) then
20001 --
20002 BEN_ELIG_SP_CLNG_PRG_PRTE_API.delete_ELIG_SP_CLNG_PRG_PRTE(
20003 --
20004 p_validate => false
20005 ,p_elig_sp_clng_prg_prte_id => l_elig_sp_clng_prg_prte_id
20006 ,p_effective_start_date => l_effective_start_date
20007 ,p_effective_end_date => l_effective_end_date
20008 ,p_object_version_number => l_object_version_number
20009 ,p_effective_date => l_max_eed
20010 ,p_datetrack_mode => hr_api.g_delete
20011 --
20012 );
20013 --
20014 end if;
20015 --
20016 l_prev_pk_id := l_current_pk_id ;
20017 --
20018 end if;
20019 --
20020 end if;
20021 --
20022 end if;
20023 --
20024 end loop;
20025 --
20026 exception when others then
20027 --
20028 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ESP',r_ESP.information5 ) ;
20029 --
20030 end create_ESP_rows;
20031
20032 --
20033 ---------------------------------------------------------------
20034 ----------------------< create_EST_rows >-----------------------
20035 ---------------------------------------------------------------
20036 --
20037 procedure create_EST_rows
20038 (
20039 p_validate in number default 0
20040 ,p_copy_entity_txn_id in number
20041 ,p_effective_date in date
20042 ,p_prefix_suffix_text in varchar2 default null
20043 ,p_reuse_object_flag in varchar2 default null
20044 ,p_target_business_group_id in varchar2 default null
20045 ,p_prefix_suffix_cd in varchar2 default null
20046 ) is
20047 --
20048 l_ELIGY_PRFL_ID number;
20049 l_JOB_GROUP_ID number;
20050 l_JOB_ID number;
20051 cursor c_unique_EST(l_table_alias varchar2) is
20052 select distinct cpe.information1,
20053 cpe.information2,
20054 cpe.information3,
20055 cpe.table_route_id
20056 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
20057 pqh_table_route tr
20058 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20059 and cpe.table_route_id = tr.table_route_id
20060 -- and tr.where_clause = l_BEN_ELIG_SUPPL_ROLE_PRTE_F
20061 and tr.table_alias = l_table_alias
20062 and cpe.number_of_copies = 1 -- ADDITION
20063 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
20064 order by information1, information2; --added for bug: 5151945
20065 --
20066 --
20067 cursor c_EST_min_max_dates(c_table_route_id number,
20068 c_information1 number) is
20069 select
20070 min(cpe.information2) min_esd,
20071 max(cpe.information3) min_eed
20072 from ben_copy_entity_results cpe
20073 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20074 and cpe.table_route_id = c_table_route_id
20075 and cpe.information1 = c_information1 ;
20076 --
20077 cursor c_EST(c_table_route_id number,
20078 c_information1 number,
20079 c_information2 date,
20080 c_information3 date ) is
20081 select
20082 cpe.*
20083 from ben_copy_entity_results cpe
20084 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20085 and cpe.table_route_id = c_table_route_id
20086 and cpe.information1 = c_information1
20087 and cpe.information2 = c_information2
20088 and cpe.information3 = c_information3
20089 and rownum = 1 ;
20090 -- Date Track target record
20091 cursor c_find_EST_in_target(
20092 c_effective_start_date date,
20093 c_effective_end_date date,
20094 c_business_group_id number,
20095 c_new_pk_id number) is
20096 select
20097 EST.elig_suppl_role_prte_id new_value
20098 from BEN_ELIG_SUPPL_ROLE_PRTE_F EST
20099 where
20100 nvl(EST.ELIGY_PRFL_ID,-999) = l_ELIGY_PRFL_ID and
20101 nvl(EST.JOB_GROUP_ID,-999) = l_JOB_GROUP_ID and
20102 nvl(EST.JOB_ID,-999) = l_JOB_ID and
20103 EST.business_group_id = c_business_group_id
20104 and EST.elig_suppl_role_prte_id <> c_new_pk_id
20105 and c_effective_start_date between effective_start_date
20106 and effective_end_date ;
20107 --END TEMPIK
20108 /*TEMPIK
20109 and exists ( select null
20110 from BEN_ELIG_SUPPL_ROLE_PRTE_F EST1
20111 where
20112 EST1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
20113 EST1.JOB_GROUP_ID = l_JOB_GROUP_ID and
20114 EST1.JOB_ID = l_JOB_ID and
20115 EST1.business_group_id = c_business_group_id
20116 and EST1.effective_start_date <= c_effective_start_date )
20117 and exists ( select null
20118 from BEN_ELIG_SUPPL_ROLE_PRTE_F EST2
20119 where
20120 EST2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
20121 EST2.JOB_GROUP_ID = l_JOB_GROUP_ID and
20122 EST2.JOB_ID = l_JOB_ID and
20123 EST2.business_group_id = c_business_group_id
20124 and EST2.effective_end_date >= c_effective_end_date )
20125 ;
20126 TEMPIK */
20127 --TEMPIK
20128 l_dt_rec_found boolean ;
20129 --END TEMPIK
20130 --
20131
20132 --UPD START
20133 --
20134 l_update boolean := false ;
20135 l_datetrack_mode varchar2(80) := hr_api.g_update;
20136 l_process_date date;
20137 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
20138 --
20139 --UPD END
20140 l_current_pk_id number := null ;
20141
20142 l_prev_pk_id number := null ;
20143 l_first_rec boolean := true ;
20144 r_EST c_EST%rowtype;
20145 l_elig_suppl_role_prte_id number ;
20146 l_object_version_number number ;
20147 l_effective_start_date date ;
20148 l_effective_end_date date ;
20149 l_prefix pqh_copy_entity_attribs.information1%type := null;
20150 l_suffix pqh_copy_entity_attribs.information1%type := null;
20151 l_new_value number(15);
20152 l_object_found_in_target boolean := false ;
20153 l_min_esd date;
20154 l_max_eed date;
20155 l_effective_date date;
20156 --
20157 begin
20158 -- Initialization
20159 l_object_found_in_target := false ;
20160 -- End Initialization
20161 -- Derive the prefix - sufix
20162 if p_prefix_suffix_cd = 'PREFIX' then
20163 l_prefix := p_prefix_suffix_text ;
20164 elsif p_prefix_suffix_cd = 'SUFFIX' then
20165 l_suffix := p_prefix_suffix_text ;
20166 else
20167 l_prefix := null ;
20168 l_suffix := null ;
20169 end if ;
20170 -- End Prefix Sufix derivation
20171 for r_EST_unique in c_unique_EST('EST') loop
20172
20173 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
20174 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20175 r_EST_unique.information3 >=
20176 ben_pd_copy_to_ben_one.g_copy_effective_date)
20177 ) then
20178 --
20179 hr_utility.set_location(' r_EST_unique.table_route_id '||r_EST_unique.table_route_id,10);
20180 hr_utility.set_location(' r_EST_unique.information1 '||r_EST_unique.information1,10);
20181 hr_utility.set_location( 'r_EST_unique.information2 '||r_EST_unique.information2,10);
20182 hr_utility.set_location( 'r_EST_unique.information3 '||r_EST_unique.information3,10);
20183 -- If reuse objects flag is 'Y' then check for the object in the target business group
20184 -- if found insert the record into PLSql table and exit the loop else try create the
20185 -- object in the target business group
20186 --
20187 l_object_found_in_target := false ;
20188 --UPD START
20189 l_update := false;
20190 l_process_date := p_effective_date;
20191 l_dml_operation:= r_EST_unique.dml_operation ;
20192 --
20193
20194 /**********************moved from below **********************/
20195 open c_EST(r_EST_unique.table_route_id,
20196 r_EST_unique.information1,
20197 r_EST_unique.information2,
20198 r_EST_unique.information3 ) ;
20199 --
20200 fetch c_EST into r_EST ;
20201 --
20202 close c_EST ;
20203 --
20204 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EST.INFORMATION263,l_dml_operation);
20205
20206 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
20207 l_JOB_GROUP_ID := r_EST.information176;
20208 l_JOB_ID := r_EST.information180;
20209 else
20210 l_JOB_GROUP_ID := r_EST.information174;
20211 l_JOB_ID := r_EST.information178;
20212 end if;
20213
20214 /**********************************************************/
20215 if l_dml_operation = 'UPDATE' then
20216 --
20217 l_object_found_in_target := TRUE;
20218 --
20219 if l_process_date between r_EST_unique.information2 and r_EST_unique.information3 then
20220 l_update := true;
20221 if r_EST_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
20222 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_SUPPL_ROLE_PRTE_ID' then
20223 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_SUPPL_ROLE_PRTE_ID' ;
20224 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EST_unique.information1 ;
20225 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EST_unique.information1 ;
20226 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
20227 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EST_unique.table_route_id;
20228 --
20229 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
20230 --
20231 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20232 --
20233 -- log_data('EST',l_new_value,l_prefix || r_EST_unique.name|| l_suffix,'REUSED');
20234 --
20235 end if ;
20236 hr_utility.set_location( 'found record for update',10);
20237 --
20238 else
20239 --
20240 l_update := false;
20241 --
20242 end if;
20243 else
20244 --
20245 --UPD END
20246 l_min_esd := null ;
20247 l_max_eed := null ;
20248 open c_EST_min_max_dates(r_EST_unique.table_route_id, r_EST_unique.information1 ) ;
20249 fetch c_EST_min_max_dates into l_min_esd,l_max_eed ;
20250 --
20251
20252 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20253 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
20254 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
20255 end if;
20256 l_min_esd := greatest(l_min_esd,r_EST_unique.information2);
20257 /**********************moved up from here **********************
20258 open c_EST(r_EST_unique.table_route_id,
20259 r_EST_unique.information1,
20260 r_EST_unique.information2,
20261 r_EST_unique.information3 ) ;
20262 --
20263 fetch c_EST into r_EST ;
20264 --
20265 close c_EST ;
20266 --
20267 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EST.INFORMATION263,l_dml_operation);
20268
20269 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
20270 l_JOB_GROUP_ID := r_EST.information176;
20271 l_JOB_ID := r_EST.information180;
20272 else
20273 l_JOB_GROUP_ID := r_EST.information174;
20274 l_JOB_ID := r_EST.information178;
20275 end if;
20276
20277 **********************************************************/
20278
20279
20280 if l_JOB_GROUP_ID is null or l_JOB_ID is null then
20281 close c_EST_min_max_dates;
20282 --
20283 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
20284 ,p_parent_pk_id => r_EST.information263
20285 ,p_copy_entity_txn_id => p_copy_entity_txn_id
20286 ,p_child_table_alias => 'EST'
20287 ,p_child_data => r_EST.information173 );
20288
20289 --
20290 else
20291 if p_reuse_object_flag = 'Y' then
20292 if c_EST_min_max_dates%found then
20293 -- cursor to find the object
20294 open c_find_EST_in_target( l_min_esd,l_max_eed,
20295 p_target_business_group_id, nvl(l_elig_suppl_role_prte_id, -999) ) ;
20296 fetch c_find_EST_in_target into l_new_value ;
20297 if c_find_EST_in_target%found then
20298 --
20299 --TEMPIK
20300 l_dt_rec_found := dt_api.check_min_max_dates
20301 (p_base_table_name => 'BEN_ELIG_SUPPL_ROLE_PRTE_F',
20302 p_base_key_column => 'ELIG_SUPPL_ROLE_PRTE_ID',
20303 p_base_key_value => l_new_value,
20304 p_from_date => l_min_esd,
20305 p_to_date => l_max_eed );
20306 if l_dt_rec_found THEN
20307 --END TEMPIK
20308 if r_EST_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
20309 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_SUPPL_ROLE_PRTE_ID' then
20310 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_SUPPL_ROLE_PRTE_ID' ;
20311 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EST_unique.information1 ;
20312 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
20313 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
20314 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EST_unique.table_route_id;
20315 --
20316 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
20317 --
20318 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20319 end if ;
20320 --
20321 l_object_found_in_target := true ;
20322 --TEMPIK
20323 end if; -- l_dt_rec_found
20324 --END TEMPIK
20325 end if;
20326 close c_find_EST_in_target ;
20327 --
20328 end if;
20329 end if ;
20330 --
20331 close c_EST_min_max_dates ;
20332 end if; --if p_dml_operation
20333 --
20334 if ( not l_object_found_in_target OR l_update ) and ( l_JOB_GROUP_ID is not null ) and ( l_JOB_ID is not null ) then -- bug # 4251900
20335
20336 --
20337 l_current_pk_id := r_EST.information1;
20338 --
20339 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
20340 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
20341 --
20342 if l_current_pk_id = l_prev_pk_id then
20343 --
20344 l_first_rec := false ;
20345 --
20346 else
20347 --
20348 l_first_rec := true ;
20349 --
20350 end if ;
20351 --
20352
20353 l_effective_date := r_EST.information2;
20354 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20355 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
20356 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
20357 end if;
20358
20359 if l_first_rec and not l_update then
20360 -- Call Create routine.
20361 hr_utility.set_location(' BEN_ELIG_SUPPL_ROLE_PRTE_F CREATE_ELIG_SUPPL_ROLE_PRTE ',20);
20362 BEN_ELIG_SUPPL_ROLE_PRTE_API.CREATE_ELIG_SUPPL_ROLE_PRTE(
20363 --
20364 P_VALIDATE => false
20365 ,P_EFFECTIVE_DATE => l_effective_date
20366 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
20367 --
20368 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
20369 ,P_ELIG_SUPPL_ROLE_PRTE_ID => l_elig_suppl_role_prte_id
20370 ,P_EST_ATTRIBUTE1 => r_EST.INFORMATION111
20371 ,P_EST_ATTRIBUTE10 => r_EST.INFORMATION120
20372 ,P_EST_ATTRIBUTE11 => r_EST.INFORMATION121
20373 ,P_EST_ATTRIBUTE12 => r_EST.INFORMATION122
20374 ,P_EST_ATTRIBUTE13 => r_EST.INFORMATION123
20375 ,P_EST_ATTRIBUTE14 => r_EST.INFORMATION124
20376 ,P_EST_ATTRIBUTE15 => r_EST.INFORMATION125
20377 ,P_EST_ATTRIBUTE16 => r_EST.INFORMATION126
20378 ,P_EST_ATTRIBUTE17 => r_EST.INFORMATION127
20379 ,P_EST_ATTRIBUTE18 => r_EST.INFORMATION128
20380 ,P_EST_ATTRIBUTE19 => r_EST.INFORMATION129
20381 ,P_EST_ATTRIBUTE2 => r_EST.INFORMATION112
20382 ,P_EST_ATTRIBUTE20 => r_EST.INFORMATION130
20383 ,P_EST_ATTRIBUTE21 => r_EST.INFORMATION131
20384 ,P_EST_ATTRIBUTE22 => r_EST.INFORMATION132
20385 ,P_EST_ATTRIBUTE23 => r_EST.INFORMATION133
20386 ,P_EST_ATTRIBUTE24 => r_EST.INFORMATION134
20387 ,P_EST_ATTRIBUTE25 => r_EST.INFORMATION135
20388 ,P_EST_ATTRIBUTE26 => r_EST.INFORMATION136
20389 ,P_EST_ATTRIBUTE27 => r_EST.INFORMATION137
20390 ,P_EST_ATTRIBUTE28 => r_EST.INFORMATION138
20391 ,P_EST_ATTRIBUTE29 => r_EST.INFORMATION139
20392 ,P_EST_ATTRIBUTE3 => r_EST.INFORMATION113
20393 ,P_EST_ATTRIBUTE30 => r_EST.INFORMATION140
20394 ,P_EST_ATTRIBUTE4 => r_EST.INFORMATION114
20395 ,P_EST_ATTRIBUTE5 => r_EST.INFORMATION115
20396 ,P_EST_ATTRIBUTE6 => r_EST.INFORMATION116
20397 ,P_EST_ATTRIBUTE7 => r_EST.INFORMATION117
20398 ,P_EST_ATTRIBUTE8 => r_EST.INFORMATION118
20399 ,P_EST_ATTRIBUTE9 => r_EST.INFORMATION119
20400 ,P_EST_ATTRIBUTE_CATEGORY => r_EST.INFORMATION110
20401 ,P_EXCLD_FLAG => r_EST.INFORMATION11
20402 ,P_JOB_GROUP_ID => l_JOB_GROUP_ID
20403 ,P_JOB_ID => l_JOB_ID
20404 ,P_ORDR_NUM => r_EST.INFORMATION257
20405 --
20406 -- *** END CHANGE LINES
20407
20408 --
20409
20410 ,P_EFFECTIVE_START_DATE => l_effective_start_date
20411 ,P_EFFECTIVE_END_DATE => l_effective_end_date
20412 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
20413 ,P_CRITERIA_SCORE => r_est.INFORMATION295
20414 ,P_CRITERIA_WEIGHT => r_est.INFORMATION296
20415 );
20416 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
20417 -- Update all relevent cer records with new pk_id
20418 hr_utility.set_location('Before plsql table ',222);
20419 hr_utility.set_location('new_value id '||l_elig_suppl_role_prte_id,222);
20420 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_SUPPL_ROLE_PRTE_ID' ;
20421 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EST.information1 ;
20422 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_SUPPL_ROLE_PRTE_ID ;
20423 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
20424 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EST_unique.table_route_id;
20425 hr_utility.set_location('After plsql table ',222);
20426 --
20427 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
20428 --
20429 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20430 --
20431 else
20432 --
20433 -- Call Update routine for the pk_id created in prev run .
20434 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
20435 hr_utility.set_location(' BEN_ELIG_SUPPL_ROLE_PRTE_F UPDATE_ELIG_SUPPL_ROLE_PRTE ',30);
20436 --UPD START
20437 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
20438 --
20439 if l_update then
20440 --
20441 l_datetrack_mode := r_EST.datetrack_mode ;
20442 --
20443 get_dt_modes(
20444 p_effective_date => l_process_date,
20445 p_effective_end_date => r_EST.information3,
20446 p_effective_start_date => r_EST.information2,
20447 p_dml_operation => r_EST.dml_operation,
20448 p_datetrack_mode => l_datetrack_mode );
20449 -- p_update => l_update
20450 --
20451 l_effective_date := l_process_date;
20452 l_ELIG_SUPPL_ROLE_PRTE_ID := r_EST.information1;
20453 l_object_version_number := r_EST.information265;
20454 --
20455 end if;
20456 --
20457 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
20458 --
20459 IF l_update OR l_dml_operation <> 'UPDATE' THEN
20460 --UPD END
20461
20462
20463 BEN_ELIG_SUPPL_ROLE_PRTE_API.UPDATE_ELIG_SUPPL_ROLE_PRTE(
20464 --
20465 P_VALIDATE => false
20466 ,P_EFFECTIVE_DATE => l_effective_date
20467 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
20468 --
20469 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
20470 ,P_ELIG_SUPPL_ROLE_PRTE_ID => l_elig_suppl_role_prte_id
20471 ,P_EST_ATTRIBUTE1 => r_EST.INFORMATION111
20472 ,P_EST_ATTRIBUTE10 => r_EST.INFORMATION120
20473 ,P_EST_ATTRIBUTE11 => r_EST.INFORMATION121
20474 ,P_EST_ATTRIBUTE12 => r_EST.INFORMATION122
20475 ,P_EST_ATTRIBUTE13 => r_EST.INFORMATION123
20476 ,P_EST_ATTRIBUTE14 => r_EST.INFORMATION124
20477 ,P_EST_ATTRIBUTE15 => r_EST.INFORMATION125
20478 ,P_EST_ATTRIBUTE16 => r_EST.INFORMATION126
20479 ,P_EST_ATTRIBUTE17 => r_EST.INFORMATION127
20480 ,P_EST_ATTRIBUTE18 => r_EST.INFORMATION128
20481 ,P_EST_ATTRIBUTE19 => r_EST.INFORMATION129
20482 ,P_EST_ATTRIBUTE2 => r_EST.INFORMATION112
20483 ,P_EST_ATTRIBUTE20 => r_EST.INFORMATION130
20484 ,P_EST_ATTRIBUTE21 => r_EST.INFORMATION131
20485 ,P_EST_ATTRIBUTE22 => r_EST.INFORMATION132
20486 ,P_EST_ATTRIBUTE23 => r_EST.INFORMATION133
20487 ,P_EST_ATTRIBUTE24 => r_EST.INFORMATION134
20488 ,P_EST_ATTRIBUTE25 => r_EST.INFORMATION135
20489 ,P_EST_ATTRIBUTE26 => r_EST.INFORMATION136
20490 ,P_EST_ATTRIBUTE27 => r_EST.INFORMATION137
20491 ,P_EST_ATTRIBUTE28 => r_EST.INFORMATION138
20492 ,P_EST_ATTRIBUTE29 => r_EST.INFORMATION139
20493 ,P_EST_ATTRIBUTE3 => r_EST.INFORMATION113
20494 ,P_EST_ATTRIBUTE30 => r_EST.INFORMATION140
20495 ,P_EST_ATTRIBUTE4 => r_EST.INFORMATION114
20496 ,P_EST_ATTRIBUTE5 => r_EST.INFORMATION115
20497 ,P_EST_ATTRIBUTE6 => r_EST.INFORMATION116
20498 ,P_EST_ATTRIBUTE7 => r_EST.INFORMATION117
20499 ,P_EST_ATTRIBUTE8 => r_EST.INFORMATION118
20500 ,P_EST_ATTRIBUTE9 => r_EST.INFORMATION119
20501 ,P_EST_ATTRIBUTE_CATEGORY => r_EST.INFORMATION110
20502 ,P_EXCLD_FLAG => r_EST.INFORMATION11
20503 ,P_JOB_GROUP_ID => l_JOB_GROUP_ID
20504 ,P_JOB_ID => l_JOB_ID
20505 ,P_ORDR_NUM => r_EST.INFORMATION257
20506 --
20507 -- ****** END CHANGE LINES
20508
20509 --
20510 ,P_EFFECTIVE_START_DATE => l_effective_start_date
20511 ,P_EFFECTIVE_END_DATE => l_effective_end_date
20512 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
20513 ,P_DATETRACK_MODE => l_datetrack_mode
20514 ,P_CRITERIA_SCORE => r_est.INFORMATION295
20515 ,P_CRITERIA_WEIGHT => r_est.INFORMATION296
20516 );
20517 end if; -- l_update
20518 --
20519 end if;
20520 --
20521 -- Delete the row if it is end dated.
20522 --
20523 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
20524 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
20525 trunc(l_max_eed) = trunc(r_EST.information3)) then
20526 --
20527 BEN_ELIG_SUPPL_ROLE_PRTE_API.delete_ELIG_SUPPL_ROLE_PRTE(
20528 --
20529 p_validate => false
20530 ,p_elig_suppl_role_prte_id => l_elig_suppl_role_prte_id
20531 ,p_effective_start_date => l_effective_start_date
20532 ,p_effective_end_date => l_effective_end_date
20533 ,p_object_version_number => l_object_version_number
20534 ,p_effective_date => l_max_eed
20535 ,p_datetrack_mode => hr_api.g_delete
20536 --
20537 );
20538 --
20539 end if;
20540 --
20541 l_prev_pk_id := l_current_pk_id ;
20542 --
20543 end if;
20544 --
20545 end if;
20546 --
20547 end if;
20548 --
20549 end loop;
20550 --
20551 exception when others then
20552 --
20553 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EST',r_EST.information5 ) ;
20554 --
20555 end create_EST_rows;
20556
20557 --
20558 ---------------------------------------------------------------
20559 ----------------------< create_EWL_rows >-----------------------
20560 ---------------------------------------------------------------
20561 --
20562 procedure create_EWL_rows
20563 (
20564 p_validate in number default 0
20565 ,p_copy_entity_txn_id in number
20566 ,p_effective_date in date
20567 ,p_prefix_suffix_text in varchar2 default null
20568 ,p_reuse_object_flag in varchar2 default null
20569 ,p_target_business_group_id in varchar2 default null
20570 ,p_prefix_suffix_cd in varchar2 default null
20571 ) is
20572 --
20573 l_ELIGY_PRFL_ID number;
20574 l_LOCATION_ID number;
20575 cursor c_unique_EWL(l_table_alias varchar2) is
20576 select distinct cpe.information1,
20577 cpe.information2,
20578 cpe.information3,
20579 cpe.table_route_id
20580 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
20581 pqh_table_route tr
20582 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20583 and cpe.table_route_id = tr.table_route_id
20584 -- and tr.where_clause = l_BEN_ELIG_WK_LOC_PRTE_F
20585 and tr.table_alias = l_table_alias
20586 and cpe.number_of_copies = 1 -- ADDITION
20587 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
20588 order by information1, information2; --added for bug: 5151945
20589 --
20590 --
20591 cursor c_EWL_min_max_dates(c_table_route_id number,
20592 c_information1 number) is
20593 select
20594 min(cpe.information2) min_esd,
20595 max(cpe.information3) min_eed
20596 from ben_copy_entity_results cpe
20597 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20598 and cpe.table_route_id = c_table_route_id
20599 and cpe.information1 = c_information1 ;
20600 --
20601 cursor c_EWL(c_table_route_id number,
20602 c_information1 number,
20603 c_information2 date,
20604 c_information3 date ) is
20605 select
20606 cpe.*
20607 from ben_copy_entity_results cpe
20608 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20609 and cpe.table_route_id = c_table_route_id
20610 and cpe.information1 = c_information1
20611 and cpe.information2 = c_information2
20612 and cpe.information3 = c_information3
20613 and rownum = 1 ;
20614 -- Date Track target record
20615 cursor c_find_EWL_in_target(
20616 c_effective_start_date date,
20617 c_effective_end_date date,
20618 c_business_group_id number,
20619 c_new_pk_id number) is
20620 select
20621 EWL.elig_wk_loc_prte_id new_value
20622 from BEN_ELIG_WK_LOC_PRTE_F EWL
20623 where
20624 EWL.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
20625 EWL.LOCATION_ID = l_LOCATION_ID and
20626 EWL.business_group_id = c_business_group_id
20627 and EWL.elig_wk_loc_prte_id <> c_new_pk_id
20628 and c_effective_start_date between effective_start_date
20629 and effective_end_date ;
20630 --END TEMPIK
20631 /*TEMPIK
20632 and exists ( select null
20633 from BEN_ELIG_WK_LOC_PRTE_F EWL1
20634 where
20635 EWL1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
20636 EWL1.LOCATION_ID = l_LOCATION_ID and
20637 EWL1.business_group_id = c_business_group_id
20638 and EWL1.effective_start_date <= c_effective_start_date )
20639 and exists ( select null
20640 from BEN_ELIG_WK_LOC_PRTE_F EWL2
20641 where
20642 EWL2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
20643 EWL2.LOCATION_ID = l_LOCATION_ID and
20644 EWL2.business_group_id = c_business_group_id
20645 and EWL2.effective_end_date >= c_effective_end_date )
20646 ;
20647 TEMPIK */
20648 --TEMPIK
20649 l_dt_rec_found boolean ;
20650 --END TEMPIK
20651 --
20652
20653 --UPD START
20654 --
20655 l_update boolean := false ;
20656 l_datetrack_mode varchar2(80) := hr_api.g_update;
20657 l_process_date date;
20658 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
20659 --
20660 --UPD END
20661 l_current_pk_id number := null ;
20662
20663 l_prev_pk_id number := null ;
20664 l_first_rec boolean := true ;
20665 r_EWL c_EWL%rowtype;
20666 l_elig_wk_loc_prte_id number ;
20667 l_object_version_number number ;
20668 l_effective_start_date date ;
20669 l_effective_end_date date ;
20670 l_prefix pqh_copy_entity_attribs.information1%type := null;
20671 l_suffix pqh_copy_entity_attribs.information1%type := null;
20672 l_new_value number(15);
20673 l_object_found_in_target boolean := false ;
20674 l_min_esd date;
20675 l_max_eed date;
20676 l_effective_date date;
20677 --
20678 begin
20679 -- Initialization
20680 l_object_found_in_target := false ;
20681 -- End Initialization
20682 -- Derive the prefix - sufix
20683 if p_prefix_suffix_cd = 'PREFIX' then
20684 l_prefix := p_prefix_suffix_text ;
20685 elsif p_prefix_suffix_cd = 'SUFFIX' then
20686 l_suffix := p_prefix_suffix_text ;
20687 else
20688 l_prefix := null ;
20689 l_suffix := null ;
20690 end if ;
20691 -- End Prefix Sufix derivation
20692 for r_EWL_unique in c_unique_EWL('EWL') loop
20693
20694 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
20695 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20696 r_EWL_unique.information3 >=
20697 ben_pd_copy_to_ben_one.g_copy_effective_date)
20698 ) then
20699 --
20700 hr_utility.set_location(' r_EWL_unique.table_route_id '||r_EWL_unique.table_route_id,10);
20701 hr_utility.set_location(' r_EWL_unique.information1 '||r_EWL_unique.information1,10);
20702 hr_utility.set_location( 'r_EWL_unique.information2 '||r_EWL_unique.information2,10);
20703 hr_utility.set_location( 'r_EWL_unique.information3 '||r_EWL_unique.information3,10);
20704 -- If reuse objects flag is 'Y' then check for the object in the target business group
20705 -- if found insert the record into PLSql table and exit the loop else try create the
20706 -- object in the target business group
20707 --
20708 l_object_found_in_target := false ;
20709 --UPD START
20710 l_update := false;
20711 l_process_date := p_effective_date;
20712 l_dml_operation:= r_EWL_unique.dml_operation ;
20713 --
20714 /**********************moved from below **********************/
20715 open c_EWL(r_EWL_unique.table_route_id,
20716 r_EWL_unique.information1,
20717 r_EWL_unique.information2,
20718 r_EWL_unique.information3 ) ;
20719 --
20720 fetch c_EWL into r_EWL ;
20721 --
20722 close c_EWL ;
20723 --
20724 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EWL.INFORMATION263,l_dml_operation);
20725 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
20726 l_LOCATION_ID := r_EWL.information176;
20727 else
20728 l_LOCATION_ID := r_EWL.information174;
20729 end if;
20730
20731 /**********************************************************/
20732
20733 if l_dml_operation = 'UPDATE' then
20734 --
20735 l_object_found_in_target := TRUE;
20736 --
20737 if l_process_date between r_EWL_unique.information2 and r_EWL_unique.information3 then
20738 l_update := true;
20739 if r_EWL_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
20740 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_WK_LOC_PRTE_ID' then
20741 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_WK_LOC_PRTE_ID' ;
20742 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EWL_unique.information1 ;
20743 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EWL_unique.information1 ;
20744 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
20745 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EWL_unique.table_route_id;
20746 --
20747 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
20748 --
20749 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20750 --
20751 -- log_data('EWL',l_new_value,l_prefix || r_EWL_unique.name|| l_suffix,'REUSED');
20752 --
20753 end if ;
20754 hr_utility.set_location( 'found record for update',10);
20755 --
20756 else
20757 --
20758 l_update := false;
20759 --
20760 end if;
20761 else
20762 --
20763 --UPD END
20764 l_min_esd := null ;
20765 l_max_eed := null ;
20766 open c_EWL_min_max_dates(r_EWL_unique.table_route_id, r_EWL_unique.information1 ) ;
20767 fetch c_EWL_min_max_dates into l_min_esd,l_max_eed ;
20768 --
20769
20770 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20771 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
20772 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
20773 end if;
20774 l_min_esd := greatest(l_min_esd,r_EWL_unique.information2);
20775 /**********************moved up from here **********************
20776 open c_EWL(r_EWL_unique.table_route_id,
20777 r_EWL_unique.information1,
20778 r_EWL_unique.information2,
20779 r_EWL_unique.information3 ) ;
20780 --
20781 fetch c_EWL into r_EWL ;
20782 --
20783 close c_EWL ;
20784 --
20785 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EWL.INFORMATION263,l_dml_operation);
20786 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
20787 l_LOCATION_ID := r_EWL.information176;
20788 else
20789 l_LOCATION_ID := r_EWL.information174;
20790 end if;
20791
20792 **********************************************************/
20793
20794 if l_LOCATION_ID is null then
20795 close c_EWL_min_max_dates;
20796 --
20797 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
20798 ,p_parent_pk_id => r_EWL.information263
20799 ,p_copy_entity_txn_id => p_copy_entity_txn_id
20800 ,p_child_table_alias => 'EWL'
20801 ,p_child_data => r_EWL.information173 );
20802
20803 --
20804 else
20805 if p_reuse_object_flag = 'Y' then
20806 if c_EWL_min_max_dates%found then
20807 -- cursor to find the object
20808 open c_find_EWL_in_target( l_min_esd,l_max_eed,
20809 p_target_business_group_id, nvl(l_elig_wk_loc_prte_id, -999) ) ;
20810 fetch c_find_EWL_in_target into l_new_value ;
20811 if c_find_EWL_in_target%found then
20812 --
20813 --TEMPIK
20814 l_dt_rec_found := dt_api.check_min_max_dates
20815 (p_base_table_name => 'BEN_ELIG_WK_LOC_PRTE_F',
20816 p_base_key_column => 'ELIG_WK_LOC_PRTE_ID',
20817 p_base_key_value => l_new_value,
20818 p_from_date => l_min_esd,
20819 p_to_date => l_max_eed );
20820 if l_dt_rec_found THEN
20821 --END TEMPIK
20822 if r_EWL_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
20823 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_WK_LOC_PRTE_ID' then
20824 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_WK_LOC_PRTE_ID' ;
20825 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EWL_unique.information1 ;
20826 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
20827 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
20828 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EWL_unique.table_route_id;
20829 --
20830 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
20831 --
20832 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20833 end if ;
20834 --
20835 l_object_found_in_target := true ;
20836 --TEMPIK
20837 end if; -- l_dt_rec_found
20838 --END TEMPIK
20839 end if;
20840 close c_find_EWL_in_target ;
20841 --
20842 end if;
20843 end if ;
20844 --
20845 close c_EWL_min_max_dates ;
20846
20847 end if; -- bug 4565106
20848
20849 end if; --if p_dml_operation
20850 --
20851 if not l_object_found_in_target OR l_update then
20852
20853 --
20854 l_current_pk_id := r_EWL.information1;
20855 --
20856 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
20857 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
20858 --
20859 if l_current_pk_id = l_prev_pk_id then
20860 --
20861 l_first_rec := false ;
20862 --
20863 else
20864 --
20865 l_first_rec := true ;
20866 --
20867 end if ;
20868 --
20869
20870 l_effective_date := r_EWL.information2;
20871 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20872 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
20873 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
20874 end if;
20875
20876 if l_first_rec and not l_update then
20877 -- Call Create routine.
20878 hr_utility.set_location(' BEN_ELIG_WK_LOC_PRTE_F CREATE_ELIG_WK_LOC_PRTE ',20);
20879 BEN_ELIG_WK_LOC_PRTE_API.CREATE_ELIG_WK_LOC_PRTE(
20880 --
20881 P_VALIDATE => false
20882 ,P_EFFECTIVE_DATE => l_effective_date
20883 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
20884 --
20885 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
20886 ,P_ELIG_WK_LOC_PRTE_ID => l_elig_wk_loc_prte_id
20887 ,P_EWL_ATTRIBUTE1 => r_EWL.INFORMATION111
20888 ,P_EWL_ATTRIBUTE10 => r_EWL.INFORMATION120
20889 ,P_EWL_ATTRIBUTE11 => r_EWL.INFORMATION121
20890 ,P_EWL_ATTRIBUTE12 => r_EWL.INFORMATION122
20891 ,P_EWL_ATTRIBUTE13 => r_EWL.INFORMATION123
20892 ,P_EWL_ATTRIBUTE14 => r_EWL.INFORMATION124
20893 ,P_EWL_ATTRIBUTE15 => r_EWL.INFORMATION125
20894 ,P_EWL_ATTRIBUTE16 => r_EWL.INFORMATION126
20895 ,P_EWL_ATTRIBUTE17 => r_EWL.INFORMATION127
20896 ,P_EWL_ATTRIBUTE18 => r_EWL.INFORMATION128
20897 ,P_EWL_ATTRIBUTE19 => r_EWL.INFORMATION129
20898 ,P_EWL_ATTRIBUTE2 => r_EWL.INFORMATION112
20899 ,P_EWL_ATTRIBUTE20 => r_EWL.INFORMATION130
20900 ,P_EWL_ATTRIBUTE21 => r_EWL.INFORMATION131
20901 ,P_EWL_ATTRIBUTE22 => r_EWL.INFORMATION132
20902 ,P_EWL_ATTRIBUTE23 => r_EWL.INFORMATION133
20903 ,P_EWL_ATTRIBUTE24 => r_EWL.INFORMATION134
20904 ,P_EWL_ATTRIBUTE25 => r_EWL.INFORMATION135
20905 ,P_EWL_ATTRIBUTE26 => r_EWL.INFORMATION136
20906 ,P_EWL_ATTRIBUTE27 => r_EWL.INFORMATION137
20907 ,P_EWL_ATTRIBUTE28 => r_EWL.INFORMATION138
20908 ,P_EWL_ATTRIBUTE29 => r_EWL.INFORMATION139
20909 ,P_EWL_ATTRIBUTE3 => r_EWL.INFORMATION113
20910 ,P_EWL_ATTRIBUTE30 => r_EWL.INFORMATION140
20911 ,P_EWL_ATTRIBUTE4 => r_EWL.INFORMATION114
20912 ,P_EWL_ATTRIBUTE5 => r_EWL.INFORMATION115
20913 ,P_EWL_ATTRIBUTE6 => r_EWL.INFORMATION116
20914 ,P_EWL_ATTRIBUTE7 => r_EWL.INFORMATION117
20915 ,P_EWL_ATTRIBUTE8 => r_EWL.INFORMATION118
20916 ,P_EWL_ATTRIBUTE9 => r_EWL.INFORMATION119
20917 ,P_EWL_ATTRIBUTE_CATEGORY => r_EWL.INFORMATION110
20918 ,P_EXCLD_FLAG => r_EWL.INFORMATION11
20919 ,P_LOCATION_ID => l_LOCATION_ID
20920 ,P_ORDR_NUM => r_EWL.INFORMATION260
20921 --
20922 -- ****** END CHANGE LINES
20923
20924 --
20925
20926 ,P_EFFECTIVE_START_DATE => l_effective_start_date
20927 ,P_EFFECTIVE_END_DATE => l_effective_end_date
20928 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
20929 ,P_CRITERIA_SCORE => r_ewl.INFORMATION295
20930 ,P_CRITERIA_WEIGHT => r_ewl.INFORMATION296
20931 );
20932 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
20933 -- Update all relevent cer records with new pk_id
20934 hr_utility.set_location('Before plsql table ',222);
20935 hr_utility.set_location('new_value id '||l_elig_wk_loc_prte_id,222);
20936 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_WK_LOC_PRTE_ID' ;
20937 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EWL.information1 ;
20938 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_WK_LOC_PRTE_ID ;
20939 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
20940 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EWL_unique.table_route_id;
20941 hr_utility.set_location('After plsql table ',222);
20942 --
20943 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
20944 --
20945 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20946 --
20947 else
20948 --
20949 -- Call Update routine for the pk_id created in prev run .
20950 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
20951 hr_utility.set_location(' BEN_ELIG_WK_LOC_PRTE_F UPDATE_ELIG_WK_LOC_PRTE ',30);
20952 --UPD START
20953 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
20954 --
20955 if l_update then
20956 --
20957 l_datetrack_mode := r_EWL.datetrack_mode ;
20958 --
20959 get_dt_modes(
20960 p_effective_date => l_process_date,
20961 p_effective_end_date => r_EWL.information3,
20962 p_effective_start_date => r_EWL.information2,
20963 p_dml_operation => r_EWL.dml_operation,
20964 p_datetrack_mode => l_datetrack_mode );
20965 -- p_update => l_update
20966 --
20967 l_effective_date := l_process_date;
20968 l_ELIG_WK_LOC_PRTE_ID := r_EWL.information1;
20969 l_object_version_number := r_EWL.information265;
20970 --
20971 end if;
20972 --
20973 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
20974 --
20975 IF l_update OR l_dml_operation <> 'UPDATE' THEN
20976 --UPD END
20977
20978
20979 BEN_ELIG_WK_LOC_PRTE_API.UPDATE_ELIG_WK_LOC_PRTE(
20980 --
20981 P_VALIDATE => false
20982 ,P_EFFECTIVE_DATE => l_effective_date
20983 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
20984 --
20985 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
20986 ,P_ELIG_WK_LOC_PRTE_ID => l_elig_wk_loc_prte_id
20987 ,P_EWL_ATTRIBUTE1 => r_EWL.INFORMATION111
20988 ,P_EWL_ATTRIBUTE10 => r_EWL.INFORMATION120
20989 ,P_EWL_ATTRIBUTE11 => r_EWL.INFORMATION121
20990 ,P_EWL_ATTRIBUTE12 => r_EWL.INFORMATION122
20991 ,P_EWL_ATTRIBUTE13 => r_EWL.INFORMATION123
20992 ,P_EWL_ATTRIBUTE14 => r_EWL.INFORMATION124
20993 ,P_EWL_ATTRIBUTE15 => r_EWL.INFORMATION125
20994 ,P_EWL_ATTRIBUTE16 => r_EWL.INFORMATION126
20995 ,P_EWL_ATTRIBUTE17 => r_EWL.INFORMATION127
20996 ,P_EWL_ATTRIBUTE18 => r_EWL.INFORMATION128
20997 ,P_EWL_ATTRIBUTE19 => r_EWL.INFORMATION129
20998 ,P_EWL_ATTRIBUTE2 => r_EWL.INFORMATION112
20999 ,P_EWL_ATTRIBUTE20 => r_EWL.INFORMATION130
21000 ,P_EWL_ATTRIBUTE21 => r_EWL.INFORMATION131
21001 ,P_EWL_ATTRIBUTE22 => r_EWL.INFORMATION132
21002 ,P_EWL_ATTRIBUTE23 => r_EWL.INFORMATION133
21003 ,P_EWL_ATTRIBUTE24 => r_EWL.INFORMATION134
21004 ,P_EWL_ATTRIBUTE25 => r_EWL.INFORMATION135
21005 ,P_EWL_ATTRIBUTE26 => r_EWL.INFORMATION136
21006 ,P_EWL_ATTRIBUTE27 => r_EWL.INFORMATION137
21007 ,P_EWL_ATTRIBUTE28 => r_EWL.INFORMATION138
21008 ,P_EWL_ATTRIBUTE29 => r_EWL.INFORMATION139
21009 ,P_EWL_ATTRIBUTE3 => r_EWL.INFORMATION113
21010 ,P_EWL_ATTRIBUTE30 => r_EWL.INFORMATION140
21011 ,P_EWL_ATTRIBUTE4 => r_EWL.INFORMATION114
21012 ,P_EWL_ATTRIBUTE5 => r_EWL.INFORMATION115
21013 ,P_EWL_ATTRIBUTE6 => r_EWL.INFORMATION116
21014 ,P_EWL_ATTRIBUTE7 => r_EWL.INFORMATION117
21015 ,P_EWL_ATTRIBUTE8 => r_EWL.INFORMATION118
21016 ,P_EWL_ATTRIBUTE9 => r_EWL.INFORMATION119
21017 ,P_EWL_ATTRIBUTE_CATEGORY => r_EWL.INFORMATION110
21018 ,P_EXCLD_FLAG => r_EWL.INFORMATION11
21019 ,P_LOCATION_ID => l_LOCATION_ID
21020 ,P_ORDR_NUM => r_EWL.INFORMATION260
21021 --
21022 -- ****** END CHANGE LINES
21023
21024 --
21025 ,P_EFFECTIVE_START_DATE => l_effective_start_date
21026 ,P_EFFECTIVE_END_DATE => l_effective_end_date
21027 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
21028 ,P_DATETRACK_MODE => l_datetrack_mode
21029 ,P_CRITERIA_SCORE => r_ewl.INFORMATION295
21030 ,P_CRITERIA_WEIGHT => r_ewl.INFORMATION296
21031 );
21032 end if; -- l_update
21033 --
21034 end if;
21035 --
21036 -- Delete the row if it is end dated.
21037 --
21038 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
21039 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
21040 trunc(l_max_eed) = trunc(r_EWL.information3)) then
21041 --
21042 BEN_ELIG_WK_LOC_PRTE_API.delete_ELIG_WK_LOC_PRTE(
21043 --
21044 p_validate => false
21045 ,p_elig_wk_loc_prte_id => l_elig_wk_loc_prte_id
21046 ,p_effective_start_date => l_effective_start_date
21047 ,p_effective_end_date => l_effective_end_date
21048 ,p_object_version_number => l_object_version_number
21049 ,p_effective_date => l_max_eed
21050 ,p_datetrack_mode => hr_api.g_delete
21051 --
21052 );
21053 --
21054 end if;
21055 --
21056 l_prev_pk_id := l_current_pk_id ;
21057 --
21058 -- end if; -- bug 4565106
21059 --
21060 end if;
21061 --
21062 end if;
21063 --
21064 end loop;
21065 --
21066 exception when others then
21067 --
21068 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EWL',r_EWL.information5 ) ;
21069 --
21070 end create_EWL_rows;
21071
21072 --
21073 ---------------------------------------------------------------
21074 ----------------------< create_ETD_rows >-----------------------
21075 ---------------------------------------------------------------
21076 --
21077 procedure create_ETD_rows
21078 (
21079 p_validate in number default 0
21080 ,p_copy_entity_txn_id in number
21081 ,p_effective_date in date
21082 ,p_prefix_suffix_text in varchar2 default null
21083 ,p_reuse_object_flag in varchar2 default null
21084 ,p_target_business_group_id in varchar2 default null
21085 ,p_prefix_suffix_cd in varchar2 default null
21086 ) is
21087 --
21088 l_ELIGY_PRFL_ID number;
21089 l_PTIP_ID number;
21090 l_ORDR_NUM number(15);
21091
21092 cursor c_unique_ETD(l_table_alias varchar2) is
21093 select distinct cpe.information1,
21094 cpe.information2,
21095 cpe.information3,
21096 cpe.table_route_id
21097 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
21098 pqh_table_route tr
21099 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21100 and cpe.table_route_id = tr.table_route_id
21101 -- and tr.where_clause = l_BEN_ELIG_DPNT_OTHR_PTIP_F
21102 and tr.table_alias = l_table_alias
21103 and cpe.number_of_copies = 1 -- ADDITION
21104 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
21105 order by information1, information2; --added for bug: 5151945
21106 --
21107 --
21108 cursor c_ETD_min_max_dates(c_table_route_id number,
21109 c_information1 number) is
21110 select
21111 min(cpe.information2) min_esd,
21112 max(cpe.information3) min_eed
21113 from ben_copy_entity_results cpe
21114 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21115 and cpe.table_route_id = c_table_route_id
21116 and cpe.information1 = c_information1 ;
21117 --
21118 cursor c_ETD(c_table_route_id number,
21119 c_information1 number,
21120 c_information2 date,
21121 c_information3 date ) is
21122 select
21123 cpe.*
21124 from ben_copy_entity_results cpe
21125 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21126 and cpe.table_route_id = c_table_route_id
21127 and cpe.information1 = c_information1
21128 and cpe.information2 = c_information2
21129 and cpe.information3 = c_information3
21130 and rownum = 1 ;
21131 -- Date Track target record
21132 cursor c_find_ETD_in_target(
21133 c_effective_start_date date,
21134 c_effective_end_date date,
21135 c_business_group_id number,
21136 c_new_pk_id number) is
21137 select
21138 ETD.elig_dpnt_othr_ptip_id new_value
21139 from BEN_ELIG_DPNT_OTHR_PTIP_F ETD
21140 where
21141 ETD.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
21142 ETD.PTIP_ID = l_PTIP_ID and
21143 ETD.business_group_id = c_business_group_id
21144 and ETD.elig_dpnt_othr_ptip_id <> c_new_pk_id
21145 and c_effective_start_date between effective_start_date
21146 and effective_end_date ;
21147 --END TEMPIK
21148 /*TEMPIK
21149 and exists ( select null
21150 from BEN_ELIG_DPNT_OTHR_PTIP_F ETD1
21151 where
21152 ETD1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
21153 ETD1.PTIP_ID = l_PTIP_ID and
21154 -- additional filter condition
21155 ETD1.ORDR_NUM = l_ORDR_NUM and
21156 ETD1.business_group_id = c_business_group_id
21157 and ETD1.effective_start_date <= c_effective_start_date )
21158 and exists ( select null
21159 from BEN_ELIG_DPNT_OTHR_PTIP_F ETD2
21160 where
21161 ETD2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
21162 ETD2.PTIP_ID = l_PTIP_ID and
21163 -- additional filter condition
21164 ETD2.ORDR_NUM = l_ORDR_NUM and
21165 ETD2.business_group_id = c_business_group_id
21166 and ETD2.effective_end_date >= c_effective_end_date )
21167 ;
21168 TEMPIK */
21169 --TEMPIK
21170 l_dt_rec_found boolean ;
21171 --END TEMPIK
21172 --
21173
21174 --UPD START
21175 --
21176 l_update boolean := false ;
21177 l_datetrack_mode varchar2(80) := hr_api.g_update;
21178 l_process_date date;
21179 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
21180 --
21181 --UPD END
21182 l_current_pk_id number := null ;
21183
21184 l_prev_pk_id number := null ;
21185 l_first_rec boolean := true ;
21186 r_ETD c_ETD%rowtype;
21187 l_elig_dpnt_othr_ptip_id number ;
21188 l_object_version_number number ;
21189 l_effective_start_date date ;
21190 l_effective_end_date date ;
21191 l_prefix pqh_copy_entity_attribs.information1%type := null;
21192 l_suffix pqh_copy_entity_attribs.information1%type := null;
21193 l_new_value number(15);
21194 l_object_found_in_target boolean := false ;
21195 l_min_esd date;
21196 l_max_eed date;
21197 l_effective_date date;
21198 --
21199 begin
21200 -- Initialization
21201 l_object_found_in_target := false ;
21202 -- End Initialization
21203 -- Derive the prefix - sufix
21204 if p_prefix_suffix_cd = 'PREFIX' then
21205 l_prefix := p_prefix_suffix_text ;
21206 elsif p_prefix_suffix_cd = 'SUFFIX' then
21207 l_suffix := p_prefix_suffix_text ;
21208 else
21209 l_prefix := null ;
21210 l_suffix := null ;
21211 end if ;
21212 -- End Prefix Sufix derivation
21213 for r_ETD_unique in c_unique_ETD('ETD') loop
21214
21215 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
21216 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21217 r_ETD_unique.information3 >=
21218 ben_pd_copy_to_ben_one.g_copy_effective_date)
21219 ) then
21220 --
21221 hr_utility.set_location(' r_ETD_unique.table_route_id '||r_ETD_unique.table_route_id,10);
21222 hr_utility.set_location(' r_ETD_unique.information1 '||r_ETD_unique.information1,10);
21223 hr_utility.set_location( 'r_ETD_unique.information2 '||r_ETD_unique.information2,10);
21224 hr_utility.set_location( 'r_ETD_unique.information3 '||r_ETD_unique.information3,10);
21225 -- If reuse objects flag is 'Y' then check for the object in the target business group
21226 -- if found insert the record into PLSql table and exit the loop else try create the
21227 -- object in the target business group
21228 --
21229 l_object_found_in_target := false ;
21230 --UPD START
21231 l_update := false;
21232 l_process_date := p_effective_date;
21233 l_dml_operation:= r_ETD_unique.dml_operation ;
21234 --
21235 /**********************moved from below **********************/
21236 open c_ETD(r_ETD_unique.table_route_id,
21237 r_ETD_unique.information1,
21238 r_ETD_unique.information2,
21239 r_ETD_unique.information3 ) ;
21240 --
21241 fetch c_ETD into r_ETD ;
21242 --
21243 close c_ETD ;
21244 --
21245 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ETD.INFORMATION263,l_dml_operation);
21246
21247 -- Only For Use by Create Wizard - Same Business Group
21248 l_PTIP_ID := NVL(get_fk('PTIP_ID', r_ETD.INFORMATION259,l_dml_operation),
21249 r_ETD.INFORMATION259);
21250 -- Additional Change
21251 l_ORDR_NUM := r_ETD.INFORMATION257;
21252 /**********************************************************/
21253
21254 if l_dml_operation = 'UPDATE' then
21255 --
21256 l_object_found_in_target := TRUE;
21257 --
21258 if l_process_date between r_ETD_unique.information2 and r_ETD_unique.information3 then
21259 l_update := true;
21260 if r_ETD_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
21261 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DPNT_OTHR_PTIP_ID' then
21262 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_OTHR_PTIP_ID' ;
21263 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ETD_unique.information1 ;
21264 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ETD_unique.information1 ;
21265 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
21266 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ETD_unique.table_route_id;
21267 --
21268 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
21269 --
21270 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21271 --
21272 -- log_data('ETD',l_new_value,l_prefix || r_ETD_unique.name|| l_suffix,'REUSED');
21273 --
21274 end if ;
21275 hr_utility.set_location( 'found record for update',10);
21276 --
21277 else
21278 --
21279 l_update := false;
21280 --
21281 end if;
21282 else
21283 --
21284 --UPD END
21285 l_min_esd := null ;
21286 l_max_eed := null ;
21287 open c_ETD_min_max_dates(r_ETD_unique.table_route_id, r_ETD_unique.information1 ) ;
21288 fetch c_ETD_min_max_dates into l_min_esd,l_max_eed ;
21289 --
21290
21291 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21292 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
21293 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
21294 end if;
21295 l_min_esd := greatest(l_min_esd,r_ETD_unique.information2);
21296 /**********************moved up from here **********************
21297 open c_ETD(r_ETD_unique.table_route_id,
21298 r_ETD_unique.information1,
21299 r_ETD_unique.information2,
21300 r_ETD_unique.information3 ) ;
21301 --
21302 fetch c_ETD into r_ETD ;
21303 --
21304 close c_ETD ;
21305 --
21306 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ETD.INFORMATION263,l_dml_operation);
21307
21308 -- Only For Use by Create Wizard - Same Business Group
21309 l_PTIP_ID := NVL(get_fk('PTIP_ID', r_ETD.INFORMATION259,l_dml_operation),
21310 r_ETD.INFORMATION259);
21311 -- Additional Change
21312 l_ORDR_NUM := r_ETD.INFORMATION257;
21313 **********************************************************/
21314
21315
21316 if p_reuse_object_flag = 'Y' then
21317 if c_ETD_min_max_dates%found then
21318 -- cursor to find the object
21319 open c_find_ETD_in_target( l_min_esd,l_max_eed,
21320 p_target_business_group_id, nvl(l_elig_dpnt_othr_ptip_id, -999) ) ;
21321 fetch c_find_ETD_in_target into l_new_value ;
21322 if c_find_ETD_in_target%found then
21323 --
21324 --TEMPIK
21325 l_dt_rec_found := dt_api.check_min_max_dates
21326 (p_base_table_name => 'BEN_ELIG_DPNT_OTHR_PTIP_F',
21327 p_base_key_column => 'ELIG_DPNT_OTHR_PTIP_ID',
21328 p_base_key_value => l_new_value,
21329 p_from_date => l_min_esd,
21330 p_to_date => l_max_eed );
21331 if l_dt_rec_found THEN
21332 --END TEMPIK
21333 if r_ETD_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
21334 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DPNT_OTHR_PTIP_ID' then
21335 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_OTHR_PTIP_ID' ;
21336 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ETD_unique.information1 ;
21337 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
21338 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
21339 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ETD_unique.table_route_id;
21340 --
21341 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
21342 --
21343 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21344 end if ;
21345 --
21346 l_object_found_in_target := true ;
21347 --TEMPIK
21348 end if; -- l_dt_rec_found
21349 --END TEMPIK
21350 end if;
21351 close c_find_ETD_in_target ;
21352 --
21353 end if;
21354 end if ;
21355 --
21356 close c_ETD_min_max_dates ;
21357 end if; --if p_dml_operation
21358 --
21359 if not l_object_found_in_target OR l_update then
21360
21361 --
21362 l_current_pk_id := r_ETD.information1;
21363 --
21364 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
21365 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
21366 --
21367 if l_current_pk_id = l_prev_pk_id then
21368 --
21369 l_first_rec := false ;
21370 --
21371 else
21372 --
21373 l_first_rec := true ;
21374 --
21375 end if ;
21376 --
21377
21378 l_effective_date := r_ETD.information2;
21379 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21380 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
21381 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
21382 end if;
21383
21384 if l_first_rec and not l_update then
21385 -- Call Create routine.
21386 hr_utility.set_location(' BEN_ELIG_DPNT_OTHR_PTIP_F CREATE_ELIG_DPNT_OTHR_PTIP ',20);
21387 BEN_ELIG_DPNT_OTHR_PTIP_API.CREATE_ELIG_DPNT_OTHR_PTIP(
21388 --
21389 P_VALIDATE => false
21390 ,P_EFFECTIVE_DATE => l_effective_date
21391 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
21392 --
21393 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
21394 ,P_ELIG_DPNT_OTHR_PTIP_ID => l_elig_dpnt_othr_ptip_id
21395 ,P_ETD_ATTRIBUTE1 => r_ETD.INFORMATION111
21396 ,P_ETD_ATTRIBUTE10 => r_ETD.INFORMATION120
21397 ,P_ETD_ATTRIBUTE11 => r_ETD.INFORMATION121
21398 ,P_ETD_ATTRIBUTE12 => r_ETD.INFORMATION122
21399 ,P_ETD_ATTRIBUTE13 => r_ETD.INFORMATION123
21400 ,P_ETD_ATTRIBUTE14 => r_ETD.INFORMATION124
21401 ,P_ETD_ATTRIBUTE15 => r_ETD.INFORMATION125
21402 ,P_ETD_ATTRIBUTE16 => r_ETD.INFORMATION126
21403 ,P_ETD_ATTRIBUTE17 => r_ETD.INFORMATION127
21404 ,P_ETD_ATTRIBUTE18 => r_ETD.INFORMATION128
21405 ,P_ETD_ATTRIBUTE19 => r_ETD.INFORMATION129
21406 ,P_ETD_ATTRIBUTE2 => r_ETD.INFORMATION112
21407 ,P_ETD_ATTRIBUTE20 => r_ETD.INFORMATION130
21408 ,P_ETD_ATTRIBUTE21 => r_ETD.INFORMATION131
21409 ,P_ETD_ATTRIBUTE22 => r_ETD.INFORMATION132
21410 ,P_ETD_ATTRIBUTE23 => r_ETD.INFORMATION133
21411 ,P_ETD_ATTRIBUTE24 => r_ETD.INFORMATION134
21412 ,P_ETD_ATTRIBUTE25 => r_ETD.INFORMATION135
21413 ,P_ETD_ATTRIBUTE26 => r_ETD.INFORMATION136
21414 ,P_ETD_ATTRIBUTE27 => r_ETD.INFORMATION137
21415 ,P_ETD_ATTRIBUTE28 => r_ETD.INFORMATION138
21416 ,P_ETD_ATTRIBUTE29 => r_ETD.INFORMATION139
21417 ,P_ETD_ATTRIBUTE3 => r_ETD.INFORMATION113
21418 ,P_ETD_ATTRIBUTE30 => r_ETD.INFORMATION140
21419 ,P_ETD_ATTRIBUTE4 => r_ETD.INFORMATION114
21420 ,P_ETD_ATTRIBUTE5 => r_ETD.INFORMATION115
21421 ,P_ETD_ATTRIBUTE6 => r_ETD.INFORMATION116
21422 ,P_ETD_ATTRIBUTE7 => r_ETD.INFORMATION117
21423 ,P_ETD_ATTRIBUTE8 => r_ETD.INFORMATION118
21424 ,P_ETD_ATTRIBUTE9 => r_ETD.INFORMATION119
21425 ,P_ETD_ATTRIBUTE_CATEGORY => r_ETD.INFORMATION110
21426 ,P_EXCLD_FLAG => r_ETD.INFORMATION11
21427 ,P_ORDR_NUM => r_ETD.INFORMATION257
21428 ,P_PTIP_ID => l_PTIP_ID
21429 --
21430 -- ****** END CHANGE LINES
21431
21432 --
21433
21434 ,P_EFFECTIVE_START_DATE => l_effective_start_date
21435 ,P_EFFECTIVE_END_DATE => l_effective_end_date
21436 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
21437 );
21438 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
21439 -- Update all relevent cer records with new pk_id
21440 hr_utility.set_location('Before plsql table ',222);
21441 hr_utility.set_location('new_value id '||l_elig_dpnt_othr_ptip_id,222);
21442 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DPNT_OTHR_PTIP_ID' ;
21443 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ETD.information1 ;
21444 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_DPNT_OTHR_PTIP_ID ;
21445 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
21446 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ETD_unique.table_route_id;
21447 hr_utility.set_location('After plsql table ',222);
21448 --
21449 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
21450 --
21451 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21452 --
21453 else
21454 --
21455 -- Call Update routine for the pk_id created in prev run .
21456 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
21457 hr_utility.set_location(' BEN_ELIG_DPNT_OTHR_PTIP_F UPDATE_ELIG_DPNT_OTHR_PTIP ',30);
21458 --UPD START
21459 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
21460 --
21461 if l_update then
21462 --
21463 l_datetrack_mode := r_ETD.datetrack_mode ;
21464 --
21465 get_dt_modes(
21466 p_effective_date => l_process_date,
21467 p_effective_end_date => r_ETD.information3,
21468 p_effective_start_date => r_ETD.information2,
21469 p_dml_operation => r_ETD.dml_operation,
21470 p_datetrack_mode => l_datetrack_mode );
21471 -- p_update => l_update
21472 --
21473 l_effective_date := l_process_date;
21474 l_ELIG_DPNT_OTHR_PTIP_ID := r_ETD.information1;
21475 l_object_version_number := r_ETD.information265;
21476 --
21477 end if;
21478 --
21479 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
21480 --
21481 IF l_update OR l_dml_operation <> 'UPDATE' THEN
21482 --UPD END
21483
21484
21485 BEN_ELIG_DPNT_OTHR_PTIP_API.UPDATE_ELIG_DPNT_OTHR_PTIP(
21486 --
21487 P_VALIDATE => false
21488 ,P_EFFECTIVE_DATE => l_effective_date
21489 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
21490 --
21491 -- Changed From r_ETD.information11 To r_ETD.information12
21492 --
21493 --,P_ELIGY_PRFL_ID => r_ETD.information11
21494 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
21495 ,P_ELIG_DPNT_OTHR_PTIP_ID => l_elig_dpnt_othr_ptip_id
21496 ,P_ETD_ATTRIBUTE1 => r_ETD.INFORMATION111
21497 ,P_ETD_ATTRIBUTE10 => r_ETD.INFORMATION120
21498 ,P_ETD_ATTRIBUTE11 => r_ETD.INFORMATION121
21499 ,P_ETD_ATTRIBUTE12 => r_ETD.INFORMATION122
21500 ,P_ETD_ATTRIBUTE13 => r_ETD.INFORMATION123
21501 ,P_ETD_ATTRIBUTE14 => r_ETD.INFORMATION124
21502 ,P_ETD_ATTRIBUTE15 => r_ETD.INFORMATION125
21503 ,P_ETD_ATTRIBUTE16 => r_ETD.INFORMATION126
21504 ,P_ETD_ATTRIBUTE17 => r_ETD.INFORMATION127
21505 ,P_ETD_ATTRIBUTE18 => r_ETD.INFORMATION128
21506 ,P_ETD_ATTRIBUTE19 => r_ETD.INFORMATION129
21507 ,P_ETD_ATTRIBUTE2 => r_ETD.INFORMATION112
21508 ,P_ETD_ATTRIBUTE20 => r_ETD.INFORMATION130
21509 ,P_ETD_ATTRIBUTE21 => r_ETD.INFORMATION131
21510 ,P_ETD_ATTRIBUTE22 => r_ETD.INFORMATION132
21511 ,P_ETD_ATTRIBUTE23 => r_ETD.INFORMATION133
21512 ,P_ETD_ATTRIBUTE24 => r_ETD.INFORMATION134
21513 ,P_ETD_ATTRIBUTE25 => r_ETD.INFORMATION135
21514 ,P_ETD_ATTRIBUTE26 => r_ETD.INFORMATION136
21515 ,P_ETD_ATTRIBUTE27 => r_ETD.INFORMATION137
21516 ,P_ETD_ATTRIBUTE28 => r_ETD.INFORMATION138
21517 ,P_ETD_ATTRIBUTE29 => r_ETD.INFORMATION139
21518 ,P_ETD_ATTRIBUTE3 => r_ETD.INFORMATION113
21519 ,P_ETD_ATTRIBUTE30 => r_ETD.INFORMATION140
21520 ,P_ETD_ATTRIBUTE4 => r_ETD.INFORMATION114
21521 ,P_ETD_ATTRIBUTE5 => r_ETD.INFORMATION115
21522 ,P_ETD_ATTRIBUTE6 => r_ETD.INFORMATION116
21523 ,P_ETD_ATTRIBUTE7 => r_ETD.INFORMATION117
21524 ,P_ETD_ATTRIBUTE8 => r_ETD.INFORMATION118
21525 ,P_ETD_ATTRIBUTE9 => r_ETD.INFORMATION119
21526 ,P_ETD_ATTRIBUTE_CATEGORY => r_ETD.INFORMATION110
21527 ,P_EXCLD_FLAG => r_ETD.INFORMATION11
21528 ,P_ORDR_NUM => r_ETD.INFORMATION257
21529 ,P_PTIP_ID => l_PTIP_ID
21530 --
21531 -- ****** END CHANGE LINES
21532
21533 --
21534 ,P_EFFECTIVE_START_DATE => l_effective_start_date
21535 ,P_EFFECTIVE_END_DATE => l_effective_end_date
21536 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
21537 ,P_DATETRACK_MODE => l_datetrack_mode
21538 );
21539 end if; -- l_update
21540 --
21541 end if;
21542 --
21543 -- Delete the row if it is end dated.
21544 --
21545 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
21546 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
21547 trunc(l_max_eed) = trunc(r_ETD.information3)) then
21548 --
21549 BEN_ELIG_DPNT_OTHR_PTIP_API.delete_ELIG_DPNT_OTHR_PTIP(
21550 --
21551 p_validate => false
21552 ,p_elig_dpnt_othr_ptip_id => l_elig_dpnt_othr_ptip_id
21553 ,p_effective_start_date => l_effective_start_date
21554 ,p_effective_end_date => l_effective_end_date
21555 ,p_object_version_number => l_object_version_number
21556 ,p_effective_date => l_max_eed
21557 ,p_datetrack_mode => hr_api.g_delete
21558 --
21559 );
21560 --
21561 end if;
21562 --
21563 l_prev_pk_id := l_current_pk_id ;
21564 --
21565 end if;
21566 --
21567 end if;
21568 --
21569 end loop;
21570 --
21571 exception when others then
21572 --
21573 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ETD',r_ETD.information5 ) ;
21574 --
21575 end create_ETD_rows;
21576
21577 --
21578 ---------------------------------------------------------------
21579 ----------------------< create_ECT_rows >-----------------------
21580 ---------------------------------------------------------------
21581 --
21582 procedure create_ECT_rows
21583 (
21584 p_validate in number default 0
21585 ,p_copy_entity_txn_id in number
21586 ,p_effective_date in date
21587 ,p_prefix_suffix_text in varchar2 default null
21588 ,p_reuse_object_flag in varchar2 default null
21589 ,p_target_business_group_id in varchar2 default null
21590 ,p_prefix_suffix_cd in varchar2 default null
21591 ) is
21592 --
21593 l_ELIGY_PRFL_ID number;
21594 l_CATEGORY varchar2(30) ;
21595 l_ORDR_NUM number(15);
21596
21597 cursor c_unique_ECT(l_table_alias varchar2) is
21598 select distinct cpe.information1,
21599 cpe.information2,
21600 cpe.information3,
21601 cpe.table_route_id
21602 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
21603 pqh_table_route tr
21604 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21605 and cpe.table_route_id = tr.table_route_id
21606 -- and tr.where_clause = l_BEN_ELIG_DSBLTY_CTG_PRTE_F
21607 and tr.table_alias = l_table_alias
21608 and cpe.number_of_copies = 1 -- ADDITION
21609 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
21610 order by information1, information2; --added for bug: 5151945
21611 --
21612 --
21613 cursor c_ECT_min_max_dates(c_table_route_id number,
21614 c_information1 number) is
21615 select
21616 min(cpe.information2) min_esd,
21617 max(cpe.information3) min_eed
21618 from ben_copy_entity_results cpe
21619 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21620 and cpe.table_route_id = c_table_route_id
21621 and cpe.information1 = c_information1 ;
21622 --
21623 cursor c_ECT(c_table_route_id number,
21624 c_information1 number,
21625 c_information2 date,
21626 c_information3 date ) is
21627 select
21628 cpe.*
21629 from ben_copy_entity_results cpe
21630 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21631 and cpe.table_route_id = c_table_route_id
21632 and cpe.information1 = c_information1
21633 and cpe.information2 = c_information2
21634 and cpe.information3 = c_information3
21635 and rownum = 1 ;
21636 -- Date Track target record
21637 cursor c_find_ECT_in_target(
21638 c_effective_start_date date,
21639 c_effective_end_date date,
21640 c_business_group_id number,
21641 c_new_pk_id number) is
21642 select
21643 ECT.elig_dsblty_ctg_prte_id new_value
21644 from BEN_ELIG_DSBLTY_CTG_PRTE_F ECT
21645 where
21646 ECT.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
21647 ECT.CATEGORY =l_CATEGORY and
21648 ECT.ORDR_NUM =l_ORDR_NUM and
21649 ECT.business_group_id = c_business_group_id
21650 and ECT.elig_dsblty_ctg_prte_id <> c_new_pk_id
21651 and c_effective_start_date between effective_start_date
21652 and effective_end_date ;
21653 --END TEMPIK
21654 /*TEMPIK
21655 and exists ( select null
21656 from BEN_ELIG_DSBLTY_CTG_PRTE_F ECT1
21657 where
21658 ECT1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
21659 -- Additional Filter Condition
21660 ECT1.CATEGORY =l_CATEGORY and
21661 ECT1.ORDR_NUM =l_ORDR_NUM and
21662
21663 ECT1.business_group_id = c_business_group_id
21664 and ECT1.effective_start_date <= c_effective_start_date )
21665 and exists ( select null
21666 from BEN_ELIG_DSBLTY_CTG_PRTE_F ECT2
21667 where
21668 ECT2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
21669 -- Additional Filter Condition
21670 ECT2.CATEGORY = l_CATEGORY and
21671 ECT2.ORDR_NUM =l_ORDR_NUM and
21672
21673 ECT2.business_group_id = c_business_group_id
21674 and ECT2.effective_end_date >= c_effective_end_date )
21675 ;
21676 TEMPIK */
21677 --TEMPIK
21678 l_dt_rec_found boolean ;
21679 --END TEMPIK
21680 --
21681
21682 --UPD START
21683 --
21684 l_update boolean := false ;
21685 l_datetrack_mode varchar2(80) := hr_api.g_update;
21686 l_process_date date;
21687 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
21688 --
21689 --UPD END
21690 l_current_pk_id number := null ;
21691
21692 l_prev_pk_id number := null ;
21693 l_first_rec boolean := true ;
21694 r_ECT c_ECT%rowtype;
21695 l_elig_dsblty_ctg_prte_id number ;
21696 l_object_version_number number ;
21697 l_effective_start_date date ;
21698 l_effective_end_date date ;
21699 l_prefix pqh_copy_entity_attribs.information1%type := null;
21700 l_suffix pqh_copy_entity_attribs.information1%type := null;
21701 l_new_value number(15);
21702 l_object_found_in_target boolean := false ;
21703 l_min_esd date;
21704 l_max_eed date;
21705 l_effective_date date;
21706 --
21707 begin
21708 -- Initialization
21709 l_object_found_in_target := false ;
21710 -- End Initialization
21711 -- Derive the prefix - sufix
21712 if p_prefix_suffix_cd = 'PREFIX' then
21713 l_prefix := p_prefix_suffix_text ;
21714 elsif p_prefix_suffix_cd = 'SUFFIX' then
21715 l_suffix := p_prefix_suffix_text ;
21716 else
21717 l_prefix := null ;
21718 l_suffix := null ;
21719 end if ;
21720 -- End Prefix Sufix derivation
21721 for r_ECT_unique in c_unique_ECT('ECT') loop
21722
21723 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
21724 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21725 r_ECT_unique.information3 >=
21726 ben_pd_copy_to_ben_one.g_copy_effective_date)
21727 ) then
21728 --
21729 hr_utility.set_location(' r_ECT_unique.table_route_id '||r_ECT_unique.table_route_id,10);
21730 hr_utility.set_location(' r_ECT_unique.information1 '||r_ECT_unique.information1,10);
21731 hr_utility.set_location( 'r_ECT_unique.information2 '||r_ECT_unique.information2,10);
21732 hr_utility.set_location( 'r_ECT_unique.information3 '||r_ECT_unique.information3,10);
21733 -- If reuse objects flag is 'Y' then check for the object in the target business group
21734 -- if found insert the record into PLSql table and exit the loop else try create the
21735 -- object in the target business group
21736 --
21737 l_object_found_in_target := false ;
21738 --UPD START
21739 l_update := false;
21740 l_process_date := p_effective_date;
21741 l_dml_operation:= r_ECT_unique.dml_operation ;
21742 --
21743 /**********************moved from below **********************/
21744 open c_ECT(r_ECT_unique.table_route_id,
21745 r_ECT_unique.information1,
21746 r_ECT_unique.information2,
21747 r_ECT_unique.information3 ) ;
21748 --
21749 fetch c_ECT into r_ECT ;
21750 --
21751 close c_ECT ;
21752 --
21753 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ECT.INFORMATION263,l_dml_operation);
21754
21755 -- Additional Change
21756 l_CATEGORY := r_ECT.INFORMATION12 ;
21757 l_ORDR_NUM := r_ECT.INFORMATION260 ;
21758 /**********************************************************/
21759
21760 if l_dml_operation = 'UPDATE' then
21761 --
21762 l_object_found_in_target := TRUE;
21763 --
21764 if l_process_date between r_ECT_unique.information2 and r_ECT_unique.information3 then
21765 l_update := true;
21766 if r_ECT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
21767 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DSBLTY_CTG_PRTE_ID' then
21768 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DSBLTY_CTG_PRTE_ID' ;
21769 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECT_unique.information1 ;
21770 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ECT_unique.information1 ;
21771 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
21772 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECT_unique.table_route_id;
21773 --
21774 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
21775 --
21776 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21777 --
21778 -- log_data('ECT',l_new_value,l_prefix || r_ECT_unique.name|| l_suffix,'REUSED');
21779 --
21780 end if ;
21781 hr_utility.set_location( 'found record for update',10);
21782 --
21783 else
21784 --
21785 l_update := false;
21786 --
21787 end if;
21788 else
21789 --
21790 --UPD END
21791 l_min_esd := null ;
21792 l_max_eed := null ;
21793 open c_ECT_min_max_dates(r_ECT_unique.table_route_id, r_ECT_unique.information1 ) ;
21794 fetch c_ECT_min_max_dates into l_min_esd,l_max_eed ;
21795 --
21796
21797 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21798 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
21799 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
21800 end if;
21801 l_min_esd := greatest(l_min_esd,r_ECT_unique.information2);
21802 /**********************moved up from here **********************
21803 open c_ECT(r_ECT_unique.table_route_id,
21804 r_ECT_unique.information1,
21805 r_ECT_unique.information2,
21806 r_ECT_unique.information3 ) ;
21807 --
21808 fetch c_ECT into r_ECT ;
21809 --
21810 close c_ECT ;
21811 --
21812 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ECT.INFORMATION263,l_dml_operation);
21813
21814 -- Additional Change
21815 l_CATEGORY := r_ECT.INFORMATION12 ;
21816 l_ORDR_NUM := r_ECT.INFORMATION260 ;
21817 **********************************************************/
21818
21819
21820 if p_reuse_object_flag = 'Y' then
21821 if c_ECT_min_max_dates%found then
21822 -- cursor to find the object
21823 open c_find_ECT_in_target( l_min_esd,l_max_eed,
21824 p_target_business_group_id, nvl(l_elig_dsblty_ctg_prte_id, -999) ) ;
21825 fetch c_find_ECT_in_target into l_new_value ;
21826 if c_find_ECT_in_target%found then
21827 --
21828 --TEMPIK
21829 l_dt_rec_found := dt_api.check_min_max_dates
21830 (p_base_table_name => 'BEN_ELIG_DSBLTY_CTG_PRTE_F',
21831 p_base_key_column => 'ELIG_DSBLTY_CTG_PRTE_ID',
21832 p_base_key_value => l_new_value,
21833 p_from_date => l_min_esd,
21834 p_to_date => l_max_eed );
21835 if l_dt_rec_found THEN
21836 --END TEMPIK
21837 if r_ECT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
21838 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DSBLTY_CTG_PRTE_ID' then
21839 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DSBLTY_CTG_PRTE_ID' ;
21840 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECT_unique.information1 ;
21841 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
21842 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
21843 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECT_unique.table_route_id;
21844 --
21845 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
21846 --
21847 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21848 end if ;
21849 --
21850 l_object_found_in_target := true ;
21851 --TEMPIK
21852 end if; -- l_dt_rec_found
21853 --END TEMPIK
21854 end if;
21855 close c_find_ECT_in_target ;
21856 --
21857 end if;
21858 end if ;
21859 --
21860 close c_ECT_min_max_dates ;
21861 end if; --if p_dml_operation
21862 --
21863 if not l_object_found_in_target OR l_update then
21864
21865 --
21866 l_current_pk_id := r_ECT.information1;
21867 --
21868 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
21869 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
21870 --
21871 if l_current_pk_id = l_prev_pk_id then
21872 --
21873 l_first_rec := false ;
21874 --
21875 else
21876 --
21877 l_first_rec := true ;
21878 --
21879 end if ;
21880 --
21881
21882 l_effective_date := r_ECT.information2;
21883 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21884 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
21885 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
21886 end if;
21887
21888 if l_first_rec and not l_update then
21889 -- Call Create routine.
21890 hr_utility.set_location(' BEN_ELIG_DSBLTY_CTG_PRTE_F CREATE_ELIG_DSBLTY_CTG_PRTE ',20);
21891 BEN_ELIG_DSBLTY_CTG_PRTE_API.CREATE_ELIG_DSBLTY_CTG_PRTE(
21892 --
21893 P_VALIDATE => false
21894 ,P_EFFECTIVE_DATE => l_effective_date
21895 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
21896 --
21897 ,P_CATEGORY => r_ECT.INFORMATION12
21898 ,P_ECT_ATTRIBUTE1 => r_ECT.INFORMATION111
21899 ,P_ECT_ATTRIBUTE10 => r_ECT.INFORMATION120
21900 ,P_ECT_ATTRIBUTE11 => r_ECT.INFORMATION121
21901 ,P_ECT_ATTRIBUTE12 => r_ECT.INFORMATION122
21902 ,P_ECT_ATTRIBUTE13 => r_ECT.INFORMATION123
21903 ,P_ECT_ATTRIBUTE14 => r_ECT.INFORMATION124
21904 ,P_ECT_ATTRIBUTE15 => r_ECT.INFORMATION125
21905 ,P_ECT_ATTRIBUTE16 => r_ECT.INFORMATION126
21906 ,P_ECT_ATTRIBUTE17 => r_ECT.INFORMATION127
21907 ,P_ECT_ATTRIBUTE18 => r_ECT.INFORMATION128
21908 ,P_ECT_ATTRIBUTE19 => r_ECT.INFORMATION129
21909 ,P_ECT_ATTRIBUTE2 => r_ECT.INFORMATION112
21910 ,P_ECT_ATTRIBUTE20 => r_ECT.INFORMATION130
21911 ,P_ECT_ATTRIBUTE21 => r_ECT.INFORMATION131
21912 ,P_ECT_ATTRIBUTE22 => r_ECT.INFORMATION132
21913 ,P_ECT_ATTRIBUTE23 => r_ECT.INFORMATION133
21914 ,P_ECT_ATTRIBUTE24 => r_ECT.INFORMATION134
21915 ,P_ECT_ATTRIBUTE25 => r_ECT.INFORMATION135
21916 ,P_ECT_ATTRIBUTE26 => r_ECT.INFORMATION136
21917 ,P_ECT_ATTRIBUTE27 => r_ECT.INFORMATION137
21918 ,P_ECT_ATTRIBUTE28 => r_ECT.INFORMATION138
21919 ,P_ECT_ATTRIBUTE29 => r_ECT.INFORMATION139
21920 ,P_ECT_ATTRIBUTE3 => r_ECT.INFORMATION113
21921 ,P_ECT_ATTRIBUTE30 => r_ECT.INFORMATION140
21922 ,P_ECT_ATTRIBUTE4 => r_ECT.INFORMATION114
21923 ,P_ECT_ATTRIBUTE5 => r_ECT.INFORMATION115
21924 ,P_ECT_ATTRIBUTE6 => r_ECT.INFORMATION116
21925 ,P_ECT_ATTRIBUTE7 => r_ECT.INFORMATION117
21926 ,P_ECT_ATTRIBUTE8 => r_ECT.INFORMATION118
21927 ,P_ECT_ATTRIBUTE9 => r_ECT.INFORMATION119
21928 ,P_ECT_ATTRIBUTE_CATEGORY => r_ECT.INFORMATION110
21929 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
21930 ,P_ELIG_DSBLTY_CTG_PRTE_ID => l_elig_dsblty_ctg_prte_id
21931 ,P_EXCLD_FLAG => r_ECT.INFORMATION11
21932 ,P_ORDR_NUM => r_ECT.INFORMATION260
21933 --
21934 -- ****** END CHANGE LINES
21935
21936 --
21937
21938 ,P_EFFECTIVE_START_DATE => l_effective_start_date
21939 ,P_EFFECTIVE_END_DATE => l_effective_end_date
21940 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
21941 ,P_CRITERIA_SCORE => r_ect.INFORMATION295
21942 ,P_CRITERIA_WEIGHT => r_ect.INFORMATION296
21943 );
21944 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
21945 -- Update all relevent cer records with new pk_id
21946 hr_utility.set_location('Before plsql table ',222);
21947 hr_utility.set_location('new_value id '||l_elig_dsblty_ctg_prte_id,222);
21948 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DSBLTY_CTG_PRTE_ID' ;
21949 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECT.information1 ;
21950 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_DSBLTY_CTG_PRTE_ID ;
21951 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
21952 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECT_unique.table_route_id;
21953 hr_utility.set_location('After plsql table ',222);
21954 --
21955 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
21956 --
21957 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21958 --
21959 else
21960 --
21961 -- Call Update routine for the pk_id created in prev run .
21962 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
21963 hr_utility.set_location(' BEN_ELIG_DSBLTY_CTG_PRTE_F UPDATE_ELIG_DSBLTY_CTG_PRTE ',30);
21964 --UPD START
21965 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
21966 --
21967 if l_update then
21968 --
21969 l_datetrack_mode := r_ECT.datetrack_mode ;
21970 --
21971 get_dt_modes(
21972 p_effective_date => l_process_date,
21973 p_effective_end_date => r_ECT.information3,
21974 p_effective_start_date => r_ECT.information2,
21975 p_dml_operation => r_ECT.dml_operation,
21976 p_datetrack_mode => l_datetrack_mode );
21977 -- p_update => l_update
21978 --
21979 l_effective_date := l_process_date;
21980 l_ELIG_DSBLTY_CTG_PRTE_ID := r_ECT.information1;
21981 l_object_version_number := r_ECT.information265;
21982 --
21983 end if;
21984 --
21985 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
21986 --
21987 IF l_update OR l_dml_operation <> 'UPDATE' THEN
21988 --UPD END
21989
21990
21991 BEN_ELIG_DSBLTY_CTG_PRTE_API.UPDATE_ELIG_DSBLTY_CTG_PRTE(
21992 --
21993 P_VALIDATE => false
21994 ,P_EFFECTIVE_DATE => l_effective_date
21995 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
21996 --
21997 ,P_CATEGORY => r_ECT.INFORMATION12
21998 ,P_ECT_ATTRIBUTE1 => r_ECT.INFORMATION111
21999 ,P_ECT_ATTRIBUTE10 => r_ECT.INFORMATION120
22000 ,P_ECT_ATTRIBUTE11 => r_ECT.INFORMATION121
22001 ,P_ECT_ATTRIBUTE12 => r_ECT.INFORMATION122
22002 ,P_ECT_ATTRIBUTE13 => r_ECT.INFORMATION123
22003 ,P_ECT_ATTRIBUTE14 => r_ECT.INFORMATION124
22004 ,P_ECT_ATTRIBUTE15 => r_ECT.INFORMATION125
22005 ,P_ECT_ATTRIBUTE16 => r_ECT.INFORMATION126
22006 ,P_ECT_ATTRIBUTE17 => r_ECT.INFORMATION127
22007 ,P_ECT_ATTRIBUTE18 => r_ECT.INFORMATION128
22008 ,P_ECT_ATTRIBUTE19 => r_ECT.INFORMATION129
22009 ,P_ECT_ATTRIBUTE2 => r_ECT.INFORMATION112
22010 ,P_ECT_ATTRIBUTE20 => r_ECT.INFORMATION130
22011 ,P_ECT_ATTRIBUTE21 => r_ECT.INFORMATION131
22012 ,P_ECT_ATTRIBUTE22 => r_ECT.INFORMATION132
22013 ,P_ECT_ATTRIBUTE23 => r_ECT.INFORMATION133
22014 ,P_ECT_ATTRIBUTE24 => r_ECT.INFORMATION134
22015 ,P_ECT_ATTRIBUTE25 => r_ECT.INFORMATION135
22016 ,P_ECT_ATTRIBUTE26 => r_ECT.INFORMATION136
22017 ,P_ECT_ATTRIBUTE27 => r_ECT.INFORMATION137
22018 ,P_ECT_ATTRIBUTE28 => r_ECT.INFORMATION138
22019 ,P_ECT_ATTRIBUTE29 => r_ECT.INFORMATION139
22020 ,P_ECT_ATTRIBUTE3 => r_ECT.INFORMATION113
22021 ,P_ECT_ATTRIBUTE30 => r_ECT.INFORMATION140
22022 ,P_ECT_ATTRIBUTE4 => r_ECT.INFORMATION114
22023 ,P_ECT_ATTRIBUTE5 => r_ECT.INFORMATION115
22024 ,P_ECT_ATTRIBUTE6 => r_ECT.INFORMATION116
22025 ,P_ECT_ATTRIBUTE7 => r_ECT.INFORMATION117
22026 ,P_ECT_ATTRIBUTE8 => r_ECT.INFORMATION118
22027 ,P_ECT_ATTRIBUTE9 => r_ECT.INFORMATION119
22028 ,P_ECT_ATTRIBUTE_CATEGORY => r_ECT.INFORMATION110
22029 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
22030 ,P_ELIG_DSBLTY_CTG_PRTE_ID => l_elig_dsblty_ctg_prte_id
22031 ,P_EXCLD_FLAG => r_ECT.INFORMATION11
22032 ,P_ORDR_NUM => r_ECT.INFORMATION260
22033 --
22034 -- ****** END CHANGE LINES
22035
22036 --
22037 ,P_EFFECTIVE_START_DATE => l_effective_start_date
22038 ,P_EFFECTIVE_END_DATE => l_effective_end_date
22039 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
22040 ,P_DATETRACK_MODE => l_datetrack_mode
22041 ,P_CRITERIA_SCORE => r_ect.INFORMATION295
22042 ,P_CRITERIA_WEIGHT => r_ect.INFORMATION296
22043 );
22044 end if; -- l_update
22045 --
22046 end if;
22047 --
22048 -- Delete the row if it is end dated.
22049 --
22050 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
22051 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
22052 trunc(l_max_eed) = trunc(r_ECT.information3)) then
22053 --
22054 BEN_ELIG_DSBLTY_CTG_PRTE_API.delete_ELIG_DSBLTY_CTG_PRTE(
22055 --
22056 p_validate => false
22057 ,p_elig_dsblty_ctg_prte_id => l_elig_dsblty_ctg_prte_id
22058 ,p_effective_start_date => l_effective_start_date
22059 ,p_effective_end_date => l_effective_end_date
22060 ,p_object_version_number => l_object_version_number
22061 ,p_effective_date => l_max_eed
22062 ,p_datetrack_mode => hr_api.g_delete
22063 --
22064 );
22065 --
22066 end if;
22067 --
22068 l_prev_pk_id := l_current_pk_id ;
22069 --
22070 end if;
22071 --
22072 end if;
22073 --
22074 end loop;
22075 --
22076 exception when others then
22077 --
22078 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ECT',r_ECT.information5 ) ;
22079 --
22080 end create_ECT_rows;
22081
22082 ---------------------------------------------------------------
22083 ----------------------< create_EDD_rows >-----------------------
22084 ---------------------------------------------------------------
22085 --
22086 procedure create_EDD_rows
22087 (
22088 p_validate in number default 0
22089 ,p_copy_entity_txn_id in number
22090 ,p_effective_date in date
22091 ,p_prefix_suffix_text in varchar2 default null
22092 ,p_reuse_object_flag in varchar2 default null
22093 ,p_target_business_group_id in varchar2 default null
22094 ,p_prefix_suffix_cd in varchar2 default null
22095 ) is
22096 --
22097 l_ELIGY_PRFL_ID number;
22098 l_DEGREE number;
22099 l_ORDR_NUM number;
22100
22101 cursor c_unique_EDD(l_table_alias varchar2) is
22102 select distinct cpe.information1,
22103 cpe.information2,
22104 cpe.information3,
22105 cpe.table_route_id
22106 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
22107 pqh_table_route tr
22108 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22109 and cpe.table_route_id = tr.table_route_id
22110 -- and tr.where_clause = l_BEN_ELIG_DSBLTY_DGR_PRTE_F
22111 and tr.table_alias = l_table_alias
22112 and cpe.number_of_copies = 1 -- ADDITION
22113 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
22114 order by information1, information2; --added for bug: 5151945
22115 --
22116 --
22117 cursor c_EDD_min_max_dates(c_table_route_id number,
22118 c_information1 number) is
22119 select
22120 min(cpe.information2) min_esd,
22121 max(cpe.information3) min_eed
22122 from ben_copy_entity_results cpe
22123 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22124 and cpe.table_route_id = c_table_route_id
22125 and cpe.information1 = c_information1 ;
22126 --
22127 cursor c_EDD(c_table_route_id number,
22128 c_information1 number,
22129 c_information2 date,
22130 c_information3 date ) is
22131 select
22132 cpe.*
22133 from ben_copy_entity_results cpe
22134 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22135 and cpe.table_route_id = c_table_route_id
22136 and cpe.information1 = c_information1
22137 and cpe.information2 = c_information2
22138 and cpe.information3 = c_information3
22139 and rownum = 1 ;
22140 -- Date Track target record
22141 cursor c_find_EDD_in_target(
22142 c_effective_start_date date,
22143 c_effective_end_date date,
22144 c_business_group_id number,
22145 c_new_pk_id number) is
22146 select
22147 EDD.elig_dsblty_dgr_prte_id new_value
22148 from BEN_ELIG_DSBLTY_DGR_PRTE_F EDD
22149 where
22150 EDD.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
22151 EDD.DEGREE =l_DEGREE and
22152 EDD.ORDR_NUM = l_ORDR_NUM and
22153 EDD.business_group_id = c_business_group_id
22154 and EDD.elig_dsblty_dgr_prte_id <> c_new_pk_id
22155 and c_effective_start_date between effective_start_date
22156 and effective_end_date ;
22157 --END TEMPIK
22158 /*TEMPIK
22159 and exists ( select null
22160 from BEN_ELIG_DSBLTY_DGR_PRTE_F EDD1
22161 where
22162 EDD1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
22163
22164 -- Additional Filters
22165 EDD1.DEGREE =l_DEGREE and
22166 EDD1.ORDR_NUM = l_ORDR_NUM and
22167
22168 EDD1.business_group_id = c_business_group_id
22169 and EDD1.effective_start_date <= c_effective_start_date )
22170 and exists ( select null
22171 from BEN_ELIG_DSBLTY_DGR_PRTE_F EDD2
22172 where
22173 EDD2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
22174
22175 -- Additional Filters
22176 EDD2.DEGREE = l_DEGREE and
22177 EDD2.ORDR_NUM = l_ORDR_NUM and
22178
22179 EDD2.business_group_id = c_business_group_id
22180 and EDD2.effective_end_date >= c_effective_end_date )
22181 ;
22182 TEMPIK */
22183 --TEMPIK
22184 l_dt_rec_found boolean ;
22185 --END TEMPIK
22186 --
22187
22188 --UPD START
22189 --
22190 l_update boolean := false ;
22191 l_datetrack_mode varchar2(80) := hr_api.g_update;
22192 l_process_date date;
22193 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
22194 --
22195 --UPD END
22196 l_current_pk_id number := null ;
22197
22198 l_prev_pk_id number := null ;
22199 l_first_rec boolean := true ;
22200 r_EDD c_EDD%rowtype;
22201 l_elig_dsblty_dgr_prte_id number ;
22202 l_object_version_number number ;
22203 l_effective_start_date date ;
22204 l_effective_end_date date ;
22205 l_prefix pqh_copy_entity_attribs.information1%type := null;
22206 l_suffix pqh_copy_entity_attribs.information1%type := null;
22207 l_new_value number(15);
22208 l_object_found_in_target boolean := false ;
22209 l_min_esd date;
22210 l_max_eed date;
22211 l_effective_date date;
22212 --
22213 begin
22214 -- Initialization
22215 l_object_found_in_target := false ;
22216 -- End Initialization
22217 -- Derive the prefix - sufix
22218 if p_prefix_suffix_cd = 'PREFIX' then
22219 l_prefix := p_prefix_suffix_text ;
22220 elsif p_prefix_suffix_cd = 'SUFFIX' then
22221 l_suffix := p_prefix_suffix_text ;
22222 else
22223 l_prefix := null ;
22224 l_suffix := null ;
22225 end if ;
22226 -- End Prefix Sufix derivation
22227 for r_EDD_unique in c_unique_EDD('EDD') loop
22228
22229 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
22230 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
22231 r_EDD_unique.information3 >=
22232 ben_pd_copy_to_ben_one.g_copy_effective_date)
22233 ) then
22234 --
22235 hr_utility.set_location(' r_EDD_unique.table_route_id '||r_EDD_unique.table_route_id,10);
22236 hr_utility.set_location(' r_EDD_unique.information1 '||r_EDD_unique.information1,10);
22237 hr_utility.set_location( 'r_EDD_unique.information2 '||r_EDD_unique.information2,10);
22238 hr_utility.set_location( 'r_EDD_unique.information3 '||r_EDD_unique.information3,10);
22239 -- If reuse objects flag is 'Y' then check for the object in the target business group
22240 -- if found insert the record into PLSql table and exit the loop else try create the
22241 -- object in the target business group
22242 --
22243 l_object_found_in_target := false ;
22244 --UPD START
22245 l_update := false;
22246 l_process_date := p_effective_date;
22247 l_dml_operation:= r_EDD_unique.dml_operation ;
22248 --
22249 /**********************moved from below **********************/
22250 open c_EDD(r_EDD_unique.table_route_id,
22251 r_EDD_unique.information1,
22252 r_EDD_unique.information2,
22253 r_EDD_unique.information3 ) ;
22254 --
22255 fetch c_EDD into r_EDD ;
22256 --
22257 close c_EDD ;
22258 --
22259 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDD.INFORMATION263,l_dml_operation);
22260
22261 -- Additional Changes
22262 l_DEGREE := r_EDD.INFORMATION287 ;
22263 l_ORDR_NUM :=r_EDD.INFORMATION288 ;
22264
22265 /**********************************************************/
22266
22267 if l_dml_operation = 'UPDATE' then
22268 --
22269 l_object_found_in_target := TRUE;
22270 --
22271 if l_process_date between r_EDD_unique.information2 and r_EDD_unique.information3 then
22272 l_update := true;
22273 if r_EDD_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
22274 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DSBLTY_DGR_PRTE_ID' then
22275 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DSBLTY_DGR_PRTE_ID' ;
22276 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDD_unique.information1 ;
22277 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EDD_unique.information1 ;
22278 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
22279 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDD_unique.table_route_id;
22280 --
22281 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
22282 --
22283 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22284 --
22285 -- log_data('EDD',l_new_value,l_prefix || r_EDD_unique.name|| l_suffix,'REUSED');
22286 --
22287 end if ;
22288 hr_utility.set_location( 'found record for update',10);
22289 --
22290 else
22291 --
22292 l_update := false;
22293 --
22294 end if;
22295 else
22296 --
22297 --UPD END
22298 l_min_esd := null ;
22299 l_max_eed := null ;
22300 open c_EDD_min_max_dates(r_EDD_unique.table_route_id, r_EDD_unique.information1 ) ;
22301 fetch c_EDD_min_max_dates into l_min_esd,l_max_eed ;
22302 --
22303
22304 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
22305 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
22306 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
22307 end if;
22308 l_min_esd := greatest(l_min_esd,r_EDD_unique.information2);
22309 /**********************moved up from here **********************
22310 open c_EDD(r_EDD_unique.table_route_id,
22311 r_EDD_unique.information1,
22312 r_EDD_unique.information2,
22313 r_EDD_unique.information3 ) ;
22314 --
22315 fetch c_EDD into r_EDD ;
22316 --
22317 close c_EDD ;
22318 --
22319 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDD.INFORMATION263,l_dml_operation);
22320
22321 -- Additional Changes
22322 l_DEGREE := r_EDD.INFORMATION287 ;
22323 l_ORDR_NUM :=r_EDD.INFORMATION288 ;
22324
22325 **********************************************************/
22326
22327
22328 if p_reuse_object_flag = 'Y' then
22329 if c_EDD_min_max_dates%found then
22330 -- cursor to find the object
22331 open c_find_EDD_in_target( l_min_esd,l_max_eed,
22332 p_target_business_group_id, nvl(l_elig_dsblty_dgr_prte_id, -999) ) ;
22333 fetch c_find_EDD_in_target into l_new_value ;
22334 if c_find_EDD_in_target%found then
22335 --
22336 --TEMPIK
22337 l_dt_rec_found := dt_api.check_min_max_dates
22338 (p_base_table_name => 'BEN_ELIG_DSBLTY_DGR_PRTE_F',
22339 p_base_key_column => 'ELIG_DSBLTY_DGR_PRTE_ID',
22340 p_base_key_value => l_new_value,
22341 p_from_date => l_min_esd,
22342 p_to_date => l_max_eed );
22343 if l_dt_rec_found THEN
22344 --END TEMPIK
22345 if r_EDD_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
22346 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DSBLTY_DGR_PRTE_ID' then
22347 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DSBLTY_DGR_PRTE_ID' ;
22348 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDD_unique.information1 ;
22349 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
22350 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
22351 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDD_unique.table_route_id;
22352 --
22353 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
22354 --
22355 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22356 end if ;
22357 --
22358 l_object_found_in_target := true ;
22359 --TEMPIK
22360 end if; -- l_dt_rec_found
22361 --END TEMPIK
22362 end if;
22363 close c_find_EDD_in_target ;
22364 --
22365 end if;
22366 end if ;
22367 --
22368 close c_EDD_min_max_dates ;
22369 end if; --if p_dml_operation
22370 --
22371 if not l_object_found_in_target OR l_update then
22372
22373 --
22374 l_current_pk_id := r_EDD.information1;
22375 --
22376 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
22377 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
22378 --
22379 if l_current_pk_id = l_prev_pk_id then
22380 --
22381 l_first_rec := false ;
22382 --
22383 else
22384 --
22385 l_first_rec := true ;
22386 --
22387 end if ;
22388 --
22389
22390 l_effective_date := r_EDD.information2;
22391 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
22392 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
22393 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
22394 end if;
22395
22396 if l_first_rec and not l_update then
22397 -- Call Create routine.
22398 hr_utility.set_location(' BEN_ELIG_DSBLTY_DGR_PRTE_F CREATE_ELIG_DSBLTY_DGR_PRTE ',20);
22399 BEN_ELIG_DSBLTY_DGR_PRTE_API.CREATE_ELIG_DSBLTY_DGR_PRTE(
22400 --
22401 P_VALIDATE => false
22402 ,P_EFFECTIVE_DATE => l_effective_date
22403 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
22404 --
22405 ,P_DEGREE => r_EDD.INFORMATION287
22406 ,P_EDD_ATTRIBUTE1 => r_EDD.INFORMATION111
22407 ,P_EDD_ATTRIBUTE10 => r_EDD.INFORMATION120
22408 ,P_EDD_ATTRIBUTE11 => r_EDD.INFORMATION121
22409 ,P_EDD_ATTRIBUTE12 => r_EDD.INFORMATION122
22410 ,P_EDD_ATTRIBUTE13 => r_EDD.INFORMATION123
22411 ,P_EDD_ATTRIBUTE14 => r_EDD.INFORMATION124
22412 ,P_EDD_ATTRIBUTE15 => r_EDD.INFORMATION125
22413 ,P_EDD_ATTRIBUTE16 => r_EDD.INFORMATION126
22414 ,P_EDD_ATTRIBUTE17 => r_EDD.INFORMATION127
22415 ,P_EDD_ATTRIBUTE18 => r_EDD.INFORMATION128
22416 ,P_EDD_ATTRIBUTE19 => r_EDD.INFORMATION129
22417 ,P_EDD_ATTRIBUTE2 => r_EDD.INFORMATION112
22418 ,P_EDD_ATTRIBUTE20 => r_EDD.INFORMATION130
22419 ,P_EDD_ATTRIBUTE21 => r_EDD.INFORMATION131
22420 ,P_EDD_ATTRIBUTE22 => r_EDD.INFORMATION132
22421 ,P_EDD_ATTRIBUTE23 => r_EDD.INFORMATION133
22422 ,P_EDD_ATTRIBUTE24 => r_EDD.INFORMATION134
22423 ,P_EDD_ATTRIBUTE25 => r_EDD.INFORMATION135
22424 ,P_EDD_ATTRIBUTE26 => r_EDD.INFORMATION136
22425 ,P_EDD_ATTRIBUTE27 => r_EDD.INFORMATION137
22426 ,P_EDD_ATTRIBUTE28 => r_EDD.INFORMATION138
22427 ,P_EDD_ATTRIBUTE29 => r_EDD.INFORMATION139
22428 ,P_EDD_ATTRIBUTE3 => r_EDD.INFORMATION113
22429 ,P_EDD_ATTRIBUTE30 => r_EDD.INFORMATION140
22430 ,P_EDD_ATTRIBUTE4 => r_EDD.INFORMATION114
22431 ,P_EDD_ATTRIBUTE5 => r_EDD.INFORMATION115
22432 ,P_EDD_ATTRIBUTE6 => r_EDD.INFORMATION116
22433 ,P_EDD_ATTRIBUTE7 => r_EDD.INFORMATION117
22434 ,P_EDD_ATTRIBUTE8 => r_EDD.INFORMATION118
22435 ,P_EDD_ATTRIBUTE9 => r_EDD.INFORMATION119
22436 ,P_EDD_ATTRIBUTE_CATEGORY => r_EDD.INFORMATION110
22437 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
22438 ,P_ELIG_DSBLTY_DGR_PRTE_ID => l_elig_dsblty_dgr_prte_id
22439 ,P_EXCLD_FLAG => r_EDD.INFORMATION11
22440 ,P_ORDR_NUM => r_EDD.INFORMATION288
22441 --
22442 -- ****** END CHANGE LINES
22443
22444 --
22445
22446 ,P_EFFECTIVE_START_DATE => l_effective_start_date
22447 ,P_EFFECTIVE_END_DATE => l_effective_end_date
22448 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
22449 ,P_CRITERIA_SCORE => r_edd.INFORMATION295
22450 ,P_CRITERIA_WEIGHT => r_edd.INFORMATION296
22451 );
22452 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
22453 -- Update all relevent cer records with new pk_id
22454 hr_utility.set_location('Before plsql table ',222);
22455 hr_utility.set_location('new_value id '||l_elig_dsblty_dgr_prte_id,222);
22456 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DSBLTY_DGR_PRTE_ID' ;
22457 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDD.information1 ;
22458 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_DSBLTY_DGR_PRTE_ID ;
22459 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
22460 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDD_unique.table_route_id;
22461 hr_utility.set_location('After plsql table ',222);
22462 --
22463 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
22464 --
22465 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22466 --
22467 else
22468 --
22469 -- Call Update routine for the pk_id created in prev run .
22470 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
22471 hr_utility.set_location(' BEN_ELIG_DSBLTY_DGR_PRTE_F UPDATE_ELIG_DSBLTY_DGR_PRTE ',30);
22472 --UPD START
22473 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
22474 --
22475 if l_update then
22476 --
22477 l_datetrack_mode := r_EDD.datetrack_mode ;
22478 --
22479 get_dt_modes(
22480 p_effective_date => l_process_date,
22481 p_effective_end_date => r_EDD.information3,
22482 p_effective_start_date => r_EDD.information2,
22483 p_dml_operation => r_EDD.dml_operation,
22484 p_datetrack_mode => l_datetrack_mode );
22485 -- p_update => l_update
22486 --
22487 l_effective_date := l_process_date;
22488 l_ELIG_DSBLTY_DGR_PRTE_ID := r_EDD.information1;
22489 l_object_version_number := r_EDD.information265;
22490 --
22491 end if;
22492 --
22493 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
22494 --
22495 IF l_update OR l_dml_operation <> 'UPDATE' THEN
22496 --UPD END
22497
22498
22499 BEN_ELIG_DSBLTY_DGR_PRTE_API.UPDATE_ELIG_DSBLTY_DGR_PRTE(
22500 --
22501 P_VALIDATE => false
22502 ,P_EFFECTIVE_DATE => l_effective_date
22503 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
22504 --
22505 ,P_DEGREE => r_EDD.INFORMATION287
22506 ,P_EDD_ATTRIBUTE1 => r_EDD.INFORMATION111
22507 ,P_EDD_ATTRIBUTE10 => r_EDD.INFORMATION120
22508 ,P_EDD_ATTRIBUTE11 => r_EDD.INFORMATION121
22509 ,P_EDD_ATTRIBUTE12 => r_EDD.INFORMATION122
22510 ,P_EDD_ATTRIBUTE13 => r_EDD.INFORMATION123
22511 ,P_EDD_ATTRIBUTE14 => r_EDD.INFORMATION124
22512 ,P_EDD_ATTRIBUTE15 => r_EDD.INFORMATION125
22513 ,P_EDD_ATTRIBUTE16 => r_EDD.INFORMATION126
22514 ,P_EDD_ATTRIBUTE17 => r_EDD.INFORMATION127
22515 ,P_EDD_ATTRIBUTE18 => r_EDD.INFORMATION128
22516 ,P_EDD_ATTRIBUTE19 => r_EDD.INFORMATION129
22517 ,P_EDD_ATTRIBUTE2 => r_EDD.INFORMATION112
22518 ,P_EDD_ATTRIBUTE20 => r_EDD.INFORMATION130
22519 ,P_EDD_ATTRIBUTE21 => r_EDD.INFORMATION131
22520 ,P_EDD_ATTRIBUTE22 => r_EDD.INFORMATION132
22521 ,P_EDD_ATTRIBUTE23 => r_EDD.INFORMATION133
22522 ,P_EDD_ATTRIBUTE24 => r_EDD.INFORMATION134
22523 ,P_EDD_ATTRIBUTE25 => r_EDD.INFORMATION135
22524 ,P_EDD_ATTRIBUTE26 => r_EDD.INFORMATION136
22525 ,P_EDD_ATTRIBUTE27 => r_EDD.INFORMATION137
22526 ,P_EDD_ATTRIBUTE28 => r_EDD.INFORMATION138
22527 ,P_EDD_ATTRIBUTE29 => r_EDD.INFORMATION139
22528 ,P_EDD_ATTRIBUTE3 => r_EDD.INFORMATION113
22529 ,P_EDD_ATTRIBUTE30 => r_EDD.INFORMATION140
22530 ,P_EDD_ATTRIBUTE4 => r_EDD.INFORMATION114
22531 ,P_EDD_ATTRIBUTE5 => r_EDD.INFORMATION115
22532 ,P_EDD_ATTRIBUTE6 => r_EDD.INFORMATION116
22533 ,P_EDD_ATTRIBUTE7 => r_EDD.INFORMATION117
22534 ,P_EDD_ATTRIBUTE8 => r_EDD.INFORMATION118
22535 ,P_EDD_ATTRIBUTE9 => r_EDD.INFORMATION119
22536 ,P_EDD_ATTRIBUTE_CATEGORY => r_EDD.INFORMATION110
22537 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
22538 ,P_ELIG_DSBLTY_DGR_PRTE_ID => l_elig_dsblty_dgr_prte_id
22539 ,P_EXCLD_FLAG => r_EDD.INFORMATION11
22540 ,P_ORDR_NUM => r_EDD.INFORMATION288
22541 --
22542 -- ****** END CHANGE LINES
22543
22544 --
22545 ,P_EFFECTIVE_START_DATE => l_effective_start_date
22546 ,P_EFFECTIVE_END_DATE => l_effective_end_date
22547 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
22548 ,P_DATETRACK_MODE => l_datetrack_mode
22549 ,P_CRITERIA_SCORE => r_edd.INFORMATION295
22550 ,P_CRITERIA_WEIGHT => r_edd.INFORMATION296
22551 );
22552 end if; -- l_update
22553 --
22554 end if;
22555 --
22556 -- Delete the row if it is end dated.
22557 --
22558 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
22559 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
22560 trunc(l_max_eed) = trunc(r_EDD.information3)) then
22561 --
22562 BEN_ELIG_DSBLTY_DGR_PRTE_API.delete_ELIG_DSBLTY_DGR_PRTE(
22563 --
22564 p_validate => false
22565 ,p_elig_dsblty_dgr_prte_id => l_elig_dsblty_dgr_prte_id
22566 ,p_effective_start_date => l_effective_start_date
22567 ,p_effective_end_date => l_effective_end_date
22568 ,p_object_version_number => l_object_version_number
22569 ,p_effective_date => l_max_eed
22570 ,p_datetrack_mode => hr_api.g_delete
22571 --
22572 );
22573 --
22574 end if;
22575 --
22576 l_prev_pk_id := l_current_pk_id ;
22577 --
22578 end if;
22579 --
22580 end if;
22581 --
22582 end loop;
22583 --
22584 exception when others then
22585 --
22586 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EDD',r_EDD.information5 ) ;
22587 --
22588 end create_EDD_rows;
22589
22590 --
22591 ---------------------------------------------------------------
22592 ----------------------< create_EDR_rows >-----------------------
22593 ---------------------------------------------------------------
22594 --
22595 procedure create_EDR_rows
22596 (
22597 p_validate in number default 0
22598 ,p_copy_entity_txn_id in number
22599 ,p_effective_date in date
22600 ,p_prefix_suffix_text in varchar2 default null
22601 ,p_reuse_object_flag in varchar2 default null
22602 ,p_target_business_group_id in varchar2 default null
22603 ,p_prefix_suffix_cd in varchar2 default null
22604 ) is
22605 --
22606 l_ELIGY_PRFL_ID number;
22607 l_REASON varchar2(30); -- bug# 4251900
22608 l_ORDR_NUM number;
22609
22610 cursor c_unique_EDR(l_table_alias varchar2) is
22611 select distinct cpe.information1,
22612 cpe.information2,
22613 cpe.information3,
22614 cpe.table_route_id
22615 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
22616 pqh_table_route tr
22617 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22618 and cpe.table_route_id = tr.table_route_id
22619 -- and tr.where_clause = l_BEN_ELIG_DSBLTY_RSN_PRTE_F
22620 and tr.table_alias = l_table_alias
22621 and cpe.number_of_copies = 1 -- ADDITION
22622 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
22623 order by information1, information2; --added for bug: 5151945
22624 --
22625 --
22626 cursor c_EDR_min_max_dates(c_table_route_id number,
22627 c_information1 number) is
22628 select
22629 min(cpe.information2) min_esd,
22630 max(cpe.information3) min_eed
22631 from ben_copy_entity_results cpe
22632 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22633 and cpe.table_route_id = c_table_route_id
22634 and cpe.information1 = c_information1 ;
22635 --
22636 cursor c_EDR(c_table_route_id number,
22637 c_information1 number,
22638 c_information2 date,
22639 c_information3 date ) is
22640 select
22641 cpe.*
22642 from ben_copy_entity_results cpe
22643 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22644 and cpe.table_route_id = c_table_route_id
22645 and cpe.information1 = c_information1
22646 and cpe.information2 = c_information2
22647 and cpe.information3 = c_information3
22648 and rownum = 1 ;
22649 -- Date Track target record
22650 cursor c_find_EDR_in_target(
22651 c_effective_start_date date,
22652 c_effective_end_date date,
22653 c_business_group_id number,
22654 c_new_pk_id number) is
22655 select
22656 EDR.elig_dsblty_rsn_prte_id new_value
22657 from BEN_ELIG_DSBLTY_RSN_PRTE_F EDR
22658 where
22659 EDR.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
22660 EDR.REASON = l_REASON and
22661 EDR.ORDR_NUM = l_ORDR_NUM and
22662 EDR.business_group_id = c_business_group_id
22663 and EDR.elig_dsblty_rsn_prte_id <> c_new_pk_id
22664 and c_effective_start_date between effective_start_date
22665 and effective_end_date ;
22666 --END TEMPIK
22667 /*TEMPIK
22668 and exists ( select null
22669 from BEN_ELIG_DSBLTY_RSN_PRTE_F EDR1
22670 where
22671 EDR1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
22672
22673 -- Additional Filters
22674 EDR1.REASON = l_REASON and
22675 EDR1.ORDR_NUM = l_ORDR_NUM and
22676
22677 EDR1.business_group_id = c_business_group_id
22678 and EDR1.effective_start_date <= c_effective_start_date )
22679 and exists ( select null
22680 from BEN_ELIG_DSBLTY_RSN_PRTE_F EDR2
22681 where
22682 EDR2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
22683
22684 -- Additional Filters
22685 EDR2.REASON = l_REASON and
22686 EDR2.ORDR_NUM = l_ORDR_NUM and
22687
22688 EDR2.business_group_id = c_business_group_id
22689 and EDR2.effective_end_date >= c_effective_end_date )
22690 ;
22691 TEMPIK */
22692 --TEMPIK
22693 l_dt_rec_found boolean ;
22694 --END TEMPIK
22695 --
22696
22697 --UPD START
22698 --
22699 l_update boolean := false ;
22700 l_datetrack_mode varchar2(80) := hr_api.g_update;
22701 l_process_date date;
22702 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
22703 --
22704 --UPD END
22705 l_current_pk_id number := null ;
22706
22707 l_prev_pk_id number := null ;
22708 l_first_rec boolean := true ;
22709 r_EDR c_EDR%rowtype;
22710 l_elig_dsblty_rsn_prte_id number ;
22711 l_object_version_number number ;
22712 l_effective_start_date date ;
22713 l_effective_end_date date ;
22714 l_prefix pqh_copy_entity_attribs.information1%type := null;
22715 l_suffix pqh_copy_entity_attribs.information1%type := null;
22716 l_new_value number(15);
22717 l_object_found_in_target boolean := false ;
22718 l_min_esd date;
22719 l_max_eed date;
22720 l_effective_date date;
22721 --
22722 begin
22723
22724
22725
22726 -- Initialization
22727 l_object_found_in_target := false ;
22728 -- End Initialization
22729 -- Derive the prefix - sufix
22730 if p_prefix_suffix_cd = 'PREFIX' then
22731 l_prefix := p_prefix_suffix_text ;
22732 elsif p_prefix_suffix_cd = 'SUFFIX' then
22733 l_suffix := p_prefix_suffix_text ;
22734 else
22735 l_prefix := null ;
22736 l_suffix := null ;
22737 end if ;
22738 -- End Prefix Sufix derivation
22739 for r_EDR_unique in c_unique_EDR('EDR') loop
22740
22741 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
22742 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
22743 r_EDR_unique.information3 >=
22744 ben_pd_copy_to_ben_one.g_copy_effective_date)
22745 ) then
22746 --
22747 hr_utility.set_location(' r_EDR_unique.table_route_id '||r_EDR_unique.table_route_id,10);
22748 hr_utility.set_location(' r_EDR_unique.information1 '||r_EDR_unique.information1,10);
22749 hr_utility.set_location( 'r_EDR_unique.information2 '||r_EDR_unique.information2,10);
22750 hr_utility.set_location( 'r_EDR_unique.information3 '||r_EDR_unique.information3,10);
22751 -- If reuse objects flag is 'Y' then check for the object in the target business group
22752 -- if found insert the record into PLSql table and exit the loop else try create the
22753 -- object in the target business group
22754 --
22755 l_object_found_in_target := false ;
22756 --UPD START
22757 l_update := false;
22758 l_process_date := p_effective_date;
22759 l_dml_operation:= r_EDR_unique.dml_operation ;
22760
22761
22762 --
22763 /**********************moved from below **********************/
22764 open c_EDR(r_EDR_unique.table_route_id,
22765 r_EDR_unique.information1,
22766 r_EDR_unique.information2,
22767 r_EDR_unique.information3 ) ;
22768 --
22769 fetch c_EDR into r_EDR ;
22770 --
22771 close c_EDR ;
22772
22773 --
22774 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDR.INFORMATION263,l_dml_operation);
22775
22776
22777
22778
22779 -- Additional Filters
22780 l_REASON := r_EDR.INFORMATION11 ;
22781
22782 l_ORDR_NUM := r_EDR.INFORMATION257 ;
22783
22784 /**********************************************************/
22785
22786
22787 if l_dml_operation = 'UPDATE' then
22788
22789
22790 --
22791 l_object_found_in_target := TRUE;
22792 --
22793 if l_process_date between r_EDR_unique.information2 and r_EDR_unique.information3 then
22794 l_update := true;
22795 if r_EDR_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
22796 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DSBLTY_RSN_PRTE_ID' then
22797 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DSBLTY_RSN_PRTE_ID' ;
22798 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDR_unique.information1 ;
22799 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EDR_unique.information1 ;
22800 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
22801 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDR_unique.table_route_id;
22802 --
22803 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
22804 --
22805 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22806 --
22807 -- log_data('EDR',l_new_value,l_prefix || r_EDR_unique.name|| l_suffix,'REUSED');
22808 --
22809 end if ;
22810 hr_utility.set_location( 'found record for update',10);
22811 --
22812 else
22813 --
22814
22815 l_update := false;
22816 --
22817 end if;
22818 else
22819 --
22820 --UPD END
22821
22822 l_min_esd := null ;
22823 l_max_eed := null ;
22824
22825 open c_EDR_min_max_dates(r_EDR_unique.table_route_id, r_EDR_unique.information1 ) ;
22826 fetch c_EDR_min_max_dates into l_min_esd,l_max_eed ;
22827 --
22828
22829 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
22830 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
22831
22832 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
22833 end if;
22834 l_min_esd := greatest(l_min_esd,r_EDR_unique.information2);
22835 /**********************moved up from here **********************
22836 open c_EDR(r_EDR_unique.table_route_id,
22837 r_EDR_unique.information1,
22838 r_EDR_unique.information2,
22839 r_EDR_unique.information3 ) ;
22840 --
22841 fetch c_EDR into r_EDR ;
22842 --
22843 close c_EDR ;
22844 --
22845 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDR.INFORMATION263,l_dml_operation);
22846
22847 -- Additional Filters
22848 l_REASON := r_EDR.INFORMATION11 ;
22849 l_ORDR_NUM := r_EDR.INFORMATION257 ;
22850 **********************************************************/
22851
22852
22853 if p_reuse_object_flag = 'Y' then
22854 if c_EDR_min_max_dates%found then
22855
22856
22857 -- cursor to find the object
22858 open c_find_EDR_in_target( l_min_esd,l_max_eed,
22859 p_target_business_group_id, nvl(l_elig_dsblty_rsn_prte_id, -999) ) ;
22860 fetch c_find_EDR_in_target into l_new_value ;
22861 if c_find_EDR_in_target%found then
22862
22863 --
22864 --TEMPIK
22865 l_dt_rec_found := dt_api.check_min_max_dates
22866 (p_base_table_name => 'BEN_ELIG_DSBLTY_RSN_PRTE_F',
22867 p_base_key_column => 'ELIG_DSBLTY_RSN_PRTE_ID',
22868 p_base_key_value => l_new_value,
22869 p_from_date => l_min_esd,
22870 p_to_date => l_max_eed );
22871 if l_dt_rec_found THEN
22872 --END TEMPIK
22873 if r_EDR_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
22874 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DSBLTY_RSN_PRTE_ID' then
22875
22876
22877 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DSBLTY_RSN_PRTE_ID' ;
22878 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDR_unique.information1 ;
22879 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
22880 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
22881 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDR_unique.table_route_id;
22882
22883 --
22884 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
22885 --
22886 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22887 end if ;
22888 --
22889 l_object_found_in_target := true ;
22890
22891 --TEMPIK
22892 end if; -- l_dt_rec_found
22893 --END TEMPIK
22894 end if;
22895 close c_find_EDR_in_target ;
22896 --
22897 end if;
22898 end if ;
22899 --
22900 close c_EDR_min_max_dates ;
22901 end if; --if p_dml_operation
22902 --
22903 if not l_object_found_in_target OR l_update then
22904
22905 --
22906 l_current_pk_id := r_EDR.information1;
22907 --
22908 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
22909 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
22910 --
22911 if l_current_pk_id = l_prev_pk_id then
22912 --
22913 l_first_rec := false ;
22914 --
22915 else
22916 --
22917 l_first_rec := true ;
22918 --
22919 end if ;
22920 --
22921
22922 l_effective_date := r_EDR.information2;
22923 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
22924 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
22925 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
22926 end if;
22927
22928 if l_first_rec and not l_update then
22929 -- Call Create routine.
22930 hr_utility.set_location(' BEN_ELIG_DSBLTY_RSN_PRTE_F CREATE_ELIG_DSBLTY_RSN_PRTE ',20);
22931 BEN_ELIG_DSBLTY_RSN_PRTE_API.CREATE_ELIG_DSBLTY_RSN_PRTE(
22932 --
22933 P_VALIDATE => false
22934 ,P_EFFECTIVE_DATE => l_effective_date
22935 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
22936 ,P_EDR_ATTRIBUTE1 => r_EDR.INFORMATION111
22937 ,P_EDR_ATTRIBUTE10 => r_EDR.INFORMATION120
22938 ,P_EDR_ATTRIBUTE11 => r_EDR.INFORMATION121
22939 ,P_EDR_ATTRIBUTE12 => r_EDR.INFORMATION122
22940 ,P_EDR_ATTRIBUTE13 => r_EDR.INFORMATION123
22941 ,P_EDR_ATTRIBUTE14 => r_EDR.INFORMATION124
22942 ,P_EDR_ATTRIBUTE15 => r_EDR.INFORMATION125
22943 ,P_EDR_ATTRIBUTE16 => r_EDR.INFORMATION126
22944 ,P_EDR_ATTRIBUTE17 => r_EDR.INFORMATION127
22945 ,P_EDR_ATTRIBUTE18 => r_EDR.INFORMATION128
22946 ,P_EDR_ATTRIBUTE19 => r_EDR.INFORMATION129
22947 ,P_EDR_ATTRIBUTE2 => r_EDR.INFORMATION112
22948 ,P_EDR_ATTRIBUTE20 => r_EDR.INFORMATION130
22949 ,P_EDR_ATTRIBUTE21 => r_EDR.INFORMATION131
22950 ,P_EDR_ATTRIBUTE22 => r_EDR.INFORMATION132
22951 ,P_EDR_ATTRIBUTE23 => r_EDR.INFORMATION133
22952 ,P_EDR_ATTRIBUTE24 => r_EDR.INFORMATION134
22953 ,P_EDR_ATTRIBUTE25 => r_EDR.INFORMATION135
22954 ,P_EDR_ATTRIBUTE26 => r_EDR.INFORMATION136
22955 ,P_EDR_ATTRIBUTE27 => r_EDR.INFORMATION137
22956 ,P_EDR_ATTRIBUTE28 => r_EDR.INFORMATION138
22957 ,P_EDR_ATTRIBUTE29 => r_EDR.INFORMATION139
22958 ,P_EDR_ATTRIBUTE3 => r_EDR.INFORMATION113
22959 ,P_EDR_ATTRIBUTE30 => r_EDR.INFORMATION140
22960 ,P_EDR_ATTRIBUTE4 => r_EDR.INFORMATION114
22961 ,P_EDR_ATTRIBUTE5 => r_EDR.INFORMATION115
22962 ,P_EDR_ATTRIBUTE6 => r_EDR.INFORMATION116
22963 ,P_EDR_ATTRIBUTE7 => r_EDR.INFORMATION117
22964 ,P_EDR_ATTRIBUTE8 => r_EDR.INFORMATION118
22965 ,P_EDR_ATTRIBUTE9 => r_EDR.INFORMATION119
22966 ,P_EDR_ATTRIBUTE_CATEGORY => r_EDR.INFORMATION110
22967 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
22968 ,P_ELIG_DSBLTY_RSN_PRTE_ID => l_elig_dsblty_rsn_prte_id
22969 ,P_EXCLD_FLAG => r_EDR.INFORMATION12
22970 ,P_ORDR_NUM => r_EDR.INFORMATION257
22971 ,P_REASON => r_EDR.INFORMATION11
22972 --
22973 -- ****** END CHANGE LINES
22974
22975 --
22976
22977 ,P_EFFECTIVE_START_DATE => l_effective_start_date
22978 ,P_EFFECTIVE_END_DATE => l_effective_end_date
22979 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
22980 ,P_CRITERIA_SCORE => r_edr.INFORMATION295
22981 ,P_CRITERIA_WEIGHT => r_edr.INFORMATION296
22982 );
22983 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
22984 -- Update all relevent cer records with new pk_id
22985 hr_utility.set_location('Before plsql table ',222);
22986 hr_utility.set_location('new_value id '||l_elig_dsblty_rsn_prte_id,222);
22987 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DSBLTY_RSN_PRTE_ID' ;
22988 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDR.information1 ;
22989 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_DSBLTY_RSN_PRTE_ID ;
22990 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
22991 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDR_unique.table_route_id;
22992 hr_utility.set_location('After plsql table ',222);
22993 --
22994 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
22995 --
22996 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22997 --
22998 else
22999 --
23000 -- Call Update routine for the pk_id created in prev run .
23001 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
23002 hr_utility.set_location(' BEN_ELIG_DSBLTY_RSN_PRTE_F UPDATE_ELIG_DSBLTY_RSN_PRTE ',30);
23003 --UPD START
23004 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
23005 --
23006 if l_update then
23007 --
23008 l_datetrack_mode := r_EDR.datetrack_mode ;
23009 --
23010 get_dt_modes(
23011 p_effective_date => l_process_date,
23012 p_effective_end_date => r_EDR.information3,
23013 p_effective_start_date => r_EDR.information2,
23014 p_dml_operation => r_EDR.dml_operation,
23015 p_datetrack_mode => l_datetrack_mode );
23016 -- p_update => l_update
23017 --
23018 l_effective_date := l_process_date;
23019 l_ELIG_DSBLTY_RSN_PRTE_ID := r_EDR.information1;
23020 l_object_version_number := r_EDR.information265;
23021 --
23022 end if;
23023 --
23024 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
23025 --
23026 IF l_update OR l_dml_operation <> 'UPDATE' THEN
23027 --UPD END
23028
23029
23030 BEN_ELIG_DSBLTY_RSN_PRTE_API.UPDATE_ELIG_DSBLTY_RSN_PRTE(
23031 --
23032 P_VALIDATE => false
23033 ,P_EFFECTIVE_DATE => l_effective_date
23034 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
23035 ,P_EDR_ATTRIBUTE1 => r_EDR.INFORMATION111
23036 ,P_EDR_ATTRIBUTE10 => r_EDR.INFORMATION120
23037 ,P_EDR_ATTRIBUTE11 => r_EDR.INFORMATION121
23038 ,P_EDR_ATTRIBUTE12 => r_EDR.INFORMATION122
23039 ,P_EDR_ATTRIBUTE13 => r_EDR.INFORMATION123
23040 ,P_EDR_ATTRIBUTE14 => r_EDR.INFORMATION124
23041 ,P_EDR_ATTRIBUTE15 => r_EDR.INFORMATION125
23042 ,P_EDR_ATTRIBUTE16 => r_EDR.INFORMATION126
23043 ,P_EDR_ATTRIBUTE17 => r_EDR.INFORMATION127
23044 ,P_EDR_ATTRIBUTE18 => r_EDR.INFORMATION128
23045 ,P_EDR_ATTRIBUTE19 => r_EDR.INFORMATION129
23046 ,P_EDR_ATTRIBUTE2 => r_EDR.INFORMATION112
23047 ,P_EDR_ATTRIBUTE20 => r_EDR.INFORMATION130
23048 ,P_EDR_ATTRIBUTE21 => r_EDR.INFORMATION131
23049 ,P_EDR_ATTRIBUTE22 => r_EDR.INFORMATION132
23050 ,P_EDR_ATTRIBUTE23 => r_EDR.INFORMATION133
23051 ,P_EDR_ATTRIBUTE24 => r_EDR.INFORMATION134
23052 ,P_EDR_ATTRIBUTE25 => r_EDR.INFORMATION135
23053 ,P_EDR_ATTRIBUTE26 => r_EDR.INFORMATION136
23054 ,P_EDR_ATTRIBUTE27 => r_EDR.INFORMATION137
23055 ,P_EDR_ATTRIBUTE28 => r_EDR.INFORMATION138
23056 ,P_EDR_ATTRIBUTE29 => r_EDR.INFORMATION139
23057 ,P_EDR_ATTRIBUTE3 => r_EDR.INFORMATION113
23058 ,P_EDR_ATTRIBUTE30 => r_EDR.INFORMATION140
23059 ,P_EDR_ATTRIBUTE4 => r_EDR.INFORMATION114
23060 ,P_EDR_ATTRIBUTE5 => r_EDR.INFORMATION115
23061 ,P_EDR_ATTRIBUTE6 => r_EDR.INFORMATION116
23062 ,P_EDR_ATTRIBUTE7 => r_EDR.INFORMATION117
23063 ,P_EDR_ATTRIBUTE8 => r_EDR.INFORMATION118
23064 ,P_EDR_ATTRIBUTE9 => r_EDR.INFORMATION119
23065 ,P_EDR_ATTRIBUTE_CATEGORY => r_EDR.INFORMATION110
23066 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
23067 ,P_ELIG_DSBLTY_RSN_PRTE_ID => l_elig_dsblty_rsn_prte_id
23068 ,P_EXCLD_FLAG => r_EDR.INFORMATION12
23069 ,P_ORDR_NUM => r_EDR.INFORMATION257
23070 ,P_REASON => r_EDR.INFORMATION11
23071 --
23072 -- ****** END CHANGE LINES
23073
23074 --
23075 ,P_EFFECTIVE_START_DATE => l_effective_start_date
23076 ,P_EFFECTIVE_END_DATE => l_effective_end_date
23077 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
23078 ,P_DATETRACK_MODE => l_datetrack_mode
23079 ,P_CRITERIA_SCORE => r_edr.INFORMATION295
23080 ,P_CRITERIA_WEIGHT => r_edr.INFORMATION296
23081 );
23082 end if; -- l_update
23083 --
23084 end if;
23085 --
23086 -- Delete the row if it is end dated.
23087 --
23088 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
23089 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
23090 trunc(l_max_eed) = trunc(r_EDR.information3)) then
23091 --
23092 BEN_ELIG_DSBLTY_RSN_PRTE_API.delete_ELIG_DSBLTY_RSN_PRTE(
23093 --
23094 p_validate => false
23095 ,p_elig_dsblty_rsn_prte_id => l_elig_dsblty_rsn_prte_id
23096 ,p_effective_start_date => l_effective_start_date
23097 ,p_effective_end_date => l_effective_end_date
23098 ,p_object_version_number => l_object_version_number
23099 ,p_effective_date => l_max_eed
23100 ,p_datetrack_mode => hr_api.g_delete
23101 --
23102 );
23103 --
23104 end if;
23105 --
23106 l_prev_pk_id := l_current_pk_id ;
23107 --
23108 end if;
23109 --
23110 end if;
23111 --
23112 end loop;
23113 --
23114 exception when others then
23115 --
23116
23117 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EDR',r_EDR.information5 ) ;
23118 --
23119 end create_EDR_rows;
23120
23121 ---------------------------------------------------------------
23122 ----------------------< create_EES_rows >-----------------------
23123 ---------------------------------------------------------------
23124 --
23125 procedure create_EES_rows
23126 (
23127 p_validate in number default 0
23128 ,p_copy_entity_txn_id in number
23129 ,p_effective_date in date
23130 ,p_prefix_suffix_text in varchar2 default null
23131 ,p_reuse_object_flag in varchar2 default null
23132 ,p_target_business_group_id in varchar2 default null
23133 ,p_prefix_suffix_cd in varchar2 default null
23134 ) is
23135 --
23136 l_ASSIGNMENT_STATUS_TYPE_ID number;
23137 l_ELIGY_PRFL_ID number;
23138 cursor c_unique_EES(l_table_alias varchar2) is
23139 select distinct cpe.information1,
23140 cpe.information2,
23141 cpe.information3,
23142 cpe.table_route_id
23143 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
23144 pqh_table_route tr
23145 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23146 and cpe.table_route_id = tr.table_route_id
23147 -- and tr.where_clause = l_BEN_ELIG_EE_STAT_PRTE_F
23148 and tr.table_alias = l_table_alias
23149 and cpe.number_of_copies = 1 -- ADDITION
23150 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
23151 order by information1, information2; --added for bug: 5151945
23152 --
23153 --
23154 cursor c_EES_min_max_dates(c_table_route_id number,
23155 c_information1 number) is
23156 select
23157 min(cpe.information2) min_esd,
23158 max(cpe.information3) min_eed
23159 from ben_copy_entity_results cpe
23160 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23161 and cpe.table_route_id = c_table_route_id
23162 and cpe.information1 = c_information1 ;
23163 --
23164 cursor c_EES(c_table_route_id number,
23165 c_information1 number,
23166 c_information2 date,
23167 c_information3 date ) is
23168 select
23169 cpe.*
23170 from ben_copy_entity_results cpe
23171 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23172 and cpe.table_route_id = c_table_route_id
23173 and cpe.information1 = c_information1
23174 and cpe.information2 = c_information2
23175 and cpe.information3 = c_information3
23176 and rownum = 1 ;
23177 -- Date Track target record
23178 cursor c_find_EES_in_target(
23179 c_effective_start_date date,
23180 c_effective_end_date date,
23181 c_business_group_id number,
23182 c_new_pk_id number) is
23183 select
23184 EES.elig_ee_stat_prte_id new_value
23185 from BEN_ELIG_EE_STAT_PRTE_F EES
23186 where
23187 EES.ASSIGNMENT_STATUS_TYPE_ID = l_ASSIGNMENT_STATUS_TYPE_ID and
23188 EES.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
23189 EES.business_group_id = c_business_group_id
23190 and EES.elig_ee_stat_prte_id <> c_new_pk_id
23191 and c_effective_start_date between effective_start_date
23192 and effective_end_date ;
23193 --END TEMPIK
23194 /*TEMPIK
23195 and exists ( select null
23196 from BEN_ELIG_EE_STAT_PRTE_F EES1
23197 where
23198 EES1.ASSIGNMENT_STATUS_TYPE_ID = l_ASSIGNMENT_STATUS_TYPE_ID and
23199 EES1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
23200 EES1.business_group_id = c_business_group_id
23201 and EES1.effective_start_date <= c_effective_start_date )
23202 and exists ( select null
23203 from BEN_ELIG_EE_STAT_PRTE_F EES2
23204 where
23205 EES2.ASSIGNMENT_STATUS_TYPE_ID = l_ASSIGNMENT_STATUS_TYPE_ID and
23206 EES2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
23207 EES2.business_group_id = c_business_group_id
23208 and EES2.effective_end_date >= c_effective_end_date )
23209 ;
23210 TEMPIK */
23211 --TEMPIK
23212 l_dt_rec_found boolean ;
23213 --END TEMPIK
23214 --
23215
23216 --UPD START
23217 --
23218 l_update boolean := false ;
23219 l_datetrack_mode varchar2(80) := hr_api.g_update;
23220 l_process_date date;
23221 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
23222 --
23223 --UPD END
23224 l_current_pk_id number := null ;
23225
23226 l_prev_pk_id number := null ;
23227 l_first_rec boolean := true ;
23228 r_EES c_EES%rowtype;
23229 l_elig_ee_stat_prte_id number ;
23230 l_object_version_number number ;
23231 l_effective_start_date date ;
23232 l_effective_end_date date ;
23233 l_prefix pqh_copy_entity_attribs.information1%type := null;
23234 l_suffix pqh_copy_entity_attribs.information1%type := null;
23235 l_new_value number(15);
23236 l_object_found_in_target boolean := false ;
23237 l_min_esd date;
23238 l_max_eed date;
23239 l_effective_date date;
23240 --
23241 begin
23242 -- Initialization
23243 l_object_found_in_target := false ;
23244 -- End Initialization
23245 -- Derive the prefix - sufix
23246 if p_prefix_suffix_cd = 'PREFIX' then
23247 l_prefix := p_prefix_suffix_text ;
23248 elsif p_prefix_suffix_cd = 'SUFFIX' then
23249 l_suffix := p_prefix_suffix_text ;
23250 else
23251 l_prefix := null ;
23252 l_suffix := null ;
23253 end if ;
23254 -- End Prefix Sufix derivation
23255 for r_EES_unique in c_unique_EES('EES') loop
23256
23257 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
23258 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23259 r_EES_unique.information3 >=
23260 ben_pd_copy_to_ben_one.g_copy_effective_date)
23261 ) then
23262 --
23263 hr_utility.set_location(' r_EES_unique.table_route_id '||r_EES_unique.table_route_id,10);
23264 hr_utility.set_location(' r_EES_unique.information1 '||r_EES_unique.information1,10);
23265 hr_utility.set_location( 'r_EES_unique.information2 '||r_EES_unique.information2,10);
23266 hr_utility.set_location( 'r_EES_unique.information3 '||r_EES_unique.information3,10);
23267 -- If reuse objects flag is 'Y' then check for the object in the target business group
23268 -- if found insert the record into PLSql table and exit the loop else try create the
23269 -- object in the target business group
23270 --
23271 l_object_found_in_target := false ;
23272 --UPD START
23273 l_update := false;
23274 l_process_date := p_effective_date;
23275 l_dml_operation:= r_EES_unique.dml_operation ;
23276 --
23277 /**********************moved from below **********************/
23278 open c_EES(r_EES_unique.table_route_id,
23279 r_EES_unique.information1,
23280 r_EES_unique.information2,
23281 r_EES_unique.information3 ) ;
23282 --
23283 fetch c_EES into r_EES ;
23284 --
23285 close c_EES ;
23286 --
23287 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
23288 l_ASSIGNMENT_STATUS_TYPE_ID := r_EES.information176;
23289 else
23290 l_ASSIGNMENT_STATUS_TYPE_ID := r_EES.information174;
23291 end if;
23292 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EES.INFORMATION263,l_dml_operation);
23293 /**********************************************************/
23294
23295 if l_dml_operation = 'UPDATE' then
23296 --
23297 l_object_found_in_target := TRUE;
23298 --
23299 if l_process_date between r_EES_unique.information2 and r_EES_unique.information3 then
23300 l_update := true;
23301 if r_EES_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
23302 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_EE_STAT_PRTE_ID' then
23303 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_EE_STAT_PRTE_ID' ;
23304 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EES_unique.information1 ;
23305 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EES_unique.information1 ;
23306 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23307 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EES_unique.table_route_id;
23308 --
23309 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
23310 --
23311 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23312 --
23313 -- log_data('EES',l_new_value,l_prefix || r_EES_unique.name|| l_suffix,'REUSED');
23314 --
23315 end if ;
23316 hr_utility.set_location( 'found record for update',10);
23317 --
23318 else
23319 --
23320 l_update := false;
23321 --
23322 end if;
23323 else
23324 --
23325 --UPD END
23326 l_min_esd := null ;
23327 l_max_eed := null ;
23328 open c_EES_min_max_dates(r_EES_unique.table_route_id, r_EES_unique.information1 ) ;
23329 fetch c_EES_min_max_dates into l_min_esd,l_max_eed ;
23330 --
23331
23332 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23333 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
23334 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
23335 end if;
23336 l_min_esd := greatest(l_min_esd,r_EES_unique.information2);
23337 /**********************moved up from here **********************
23338 open c_EES(r_EES_unique.table_route_id,
23339 r_EES_unique.information1,
23340 r_EES_unique.information2,
23341 r_EES_unique.information3 ) ;
23342 --
23343 fetch c_EES into r_EES ;
23344 --
23345 close c_EES ;
23346 --
23347 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
23348 l_ASSIGNMENT_STATUS_TYPE_ID := r_EES.information176;
23349 else
23350 l_ASSIGNMENT_STATUS_TYPE_ID := r_EES.information174;
23351 end if;
23352 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EES.INFORMATION263,l_dml_operation);
23353 **********************************************************/
23354
23355 --
23356 if l_ASSIGNMENT_STATUS_TYPE_ID is null then
23357 close c_EES_min_max_dates;
23358 --
23359 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
23360 ,p_parent_pk_id => r_EES.information263
23361 ,p_copy_entity_txn_id => p_copy_entity_txn_id
23362 ,p_child_table_alias => 'EES'
23363 ,p_child_data => r_EES.information173 );
23364
23365 --
23366 else
23367 if p_reuse_object_flag = 'Y' then
23368 if c_EES_min_max_dates%found then
23369 -- cursor to find the object
23370 open c_find_EES_in_target( l_min_esd,l_max_eed,
23371 p_target_business_group_id, nvl(l_elig_ee_stat_prte_id, -999) ) ;
23372 fetch c_find_EES_in_target into l_new_value ;
23373 if c_find_EES_in_target%found then
23374 --
23375 --TEMPIK
23376 l_dt_rec_found := dt_api.check_min_max_dates
23377 (p_base_table_name => 'BEN_ELIG_EE_STAT_PRTE_F',
23378 p_base_key_column => 'ELIG_EE_STAT_PRTE_ID',
23379 p_base_key_value => l_new_value,
23380 p_from_date => l_min_esd,
23381 p_to_date => l_max_eed );
23382 if l_dt_rec_found THEN
23383 --END TEMPIK
23384 if r_EES_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
23385 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_EE_STAT_PRTE_ID' then
23386 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_EE_STAT_PRTE_ID' ;
23387 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EES_unique.information1 ;
23388 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
23389 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23390 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EES_unique.table_route_id;
23391 --
23392 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
23393 --
23394 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23395 end if ;
23396 --
23397 l_object_found_in_target := true ;
23398 --TEMPIK
23399 end if; -- l_dt_rec_found
23400 --END TEMPIK
23401 end if;
23402 close c_find_EES_in_target ;
23403 --
23404 end if;
23405 end if ;
23406 --
23407 close c_EES_min_max_dates ;
23408
23409 end if ; -- bug 4565106
23410
23411 end if; --if p_dml_operation
23412 --
23413 if not l_object_found_in_target OR l_update then
23414
23415 --
23416 l_current_pk_id := r_EES.information1;
23417 --
23418 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
23419 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
23420 --
23421 if l_current_pk_id = l_prev_pk_id then
23422 --
23423 l_first_rec := false ;
23424 --
23425 else
23426 --
23427 l_first_rec := true ;
23428 --
23429 end if ;
23430 --
23431
23432 l_effective_date := r_EES.information2;
23433 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23434 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
23435 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
23436 end if;
23437
23438 if l_first_rec and not l_update then
23439 -- Call Create routine.
23440 hr_utility.set_location(' BEN_ELIG_EE_STAT_PRTE_F CREATE_ELIG_EE_STAT_PRTE ',20);
23441 BEN_ELIG_EE_STAT_PRTE_API.CREATE_ELIG_EE_STAT_PRTE(
23442 --
23443 P_VALIDATE => false
23444 ,P_EFFECTIVE_DATE => l_effective_date
23445 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
23446 --
23447 ,P_ASSIGNMENT_STATUS_TYPE_ID => l_ASSIGNMENT_STATUS_TYPE_ID
23448 ,P_EES_ATTRIBUTE1 => r_EES.INFORMATION111
23449 ,P_EES_ATTRIBUTE10 => r_EES.INFORMATION120
23450 ,P_EES_ATTRIBUTE11 => r_EES.INFORMATION121
23451 ,P_EES_ATTRIBUTE12 => r_EES.INFORMATION122
23452 ,P_EES_ATTRIBUTE13 => r_EES.INFORMATION123
23453 ,P_EES_ATTRIBUTE14 => r_EES.INFORMATION124
23454 ,P_EES_ATTRIBUTE15 => r_EES.INFORMATION125
23455 ,P_EES_ATTRIBUTE16 => r_EES.INFORMATION126
23456 ,P_EES_ATTRIBUTE17 => r_EES.INFORMATION127
23457 ,P_EES_ATTRIBUTE18 => r_EES.INFORMATION128
23458 ,P_EES_ATTRIBUTE19 => r_EES.INFORMATION129
23459 ,P_EES_ATTRIBUTE2 => r_EES.INFORMATION112
23460 ,P_EES_ATTRIBUTE20 => r_EES.INFORMATION130
23461 ,P_EES_ATTRIBUTE21 => r_EES.INFORMATION131
23462 ,P_EES_ATTRIBUTE22 => r_EES.INFORMATION132
23463 ,P_EES_ATTRIBUTE23 => r_EES.INFORMATION133
23464 ,P_EES_ATTRIBUTE24 => r_EES.INFORMATION134
23465 ,P_EES_ATTRIBUTE25 => r_EES.INFORMATION135
23466 ,P_EES_ATTRIBUTE26 => r_EES.INFORMATION136
23467 ,P_EES_ATTRIBUTE27 => r_EES.INFORMATION137
23468 ,P_EES_ATTRIBUTE28 => r_EES.INFORMATION138
23469 ,P_EES_ATTRIBUTE29 => r_EES.INFORMATION139
23470 ,P_EES_ATTRIBUTE3 => r_EES.INFORMATION113
23471 ,P_EES_ATTRIBUTE30 => r_EES.INFORMATION140
23472 ,P_EES_ATTRIBUTE4 => r_EES.INFORMATION114
23473 ,P_EES_ATTRIBUTE5 => r_EES.INFORMATION115
23474 ,P_EES_ATTRIBUTE6 => r_EES.INFORMATION116
23475 ,P_EES_ATTRIBUTE7 => r_EES.INFORMATION117
23476 ,P_EES_ATTRIBUTE8 => r_EES.INFORMATION118
23477 ,P_EES_ATTRIBUTE9 => r_EES.INFORMATION119
23478 ,P_EES_ATTRIBUTE_CATEGORY => r_EES.INFORMATION110
23479 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
23480 ,P_ELIG_EE_STAT_PRTE_ID => l_elig_ee_stat_prte_id
23481 ,P_EXCLD_FLAG => r_EES.INFORMATION11
23482 ,P_ORDR_NUM => r_EES.INFORMATION260
23483 --
23484 -- ****** END CHANGE LINES
23485
23486 --
23487
23488 ,P_EFFECTIVE_START_DATE => l_effective_start_date
23489 ,P_EFFECTIVE_END_DATE => l_effective_end_date
23490 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
23491 ,P_CRITERIA_SCORE => r_ees.INFORMATION295
23492 ,P_CRITERIA_WEIGHT => r_ees.INFORMATION296
23493 );
23494 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
23495 -- Update all relevent cer records with new pk_id
23496 hr_utility.set_location('Before plsql table ',222);
23497 hr_utility.set_location('new_value id '||l_elig_ee_stat_prte_id,222);
23498 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_EE_STAT_PRTE_ID' ;
23499 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EES.information1 ;
23500 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_EE_STAT_PRTE_ID ;
23501 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
23502 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EES_unique.table_route_id;
23503 hr_utility.set_location('After plsql table ',222);
23504 --
23505 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
23506 --
23507 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23508 --
23509 else
23510 --
23511 -- Call Update routine for the pk_id created in prev run .
23512 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
23513 hr_utility.set_location(' BEN_ELIG_EE_STAT_PRTE_F UPDATE_ELIG_EE_STAT_PRTE ',30);
23514 --UPD START
23515 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
23516 --
23517 if l_update then
23518 --
23519 l_datetrack_mode := r_EES.datetrack_mode ;
23520 --
23521 get_dt_modes(
23522 p_effective_date => l_process_date,
23523 p_effective_end_date => r_EES.information3,
23524 p_effective_start_date => r_EES.information2,
23525 p_dml_operation => r_EES.dml_operation,
23526 p_datetrack_mode => l_datetrack_mode );
23527 -- p_update => l_update
23528 --
23529 l_effective_date := l_process_date;
23530 l_ELIG_EE_STAT_PRTE_ID := r_EES.information1;
23531 l_object_version_number := r_EES.information265;
23532 --
23533 end if;
23534 --
23535 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
23536 --
23537 IF l_update OR l_dml_operation <> 'UPDATE' THEN
23538 --UPD END
23539
23540
23541 BEN_ELIG_EE_STAT_PRTE_API.UPDATE_ELIG_EE_STAT_PRTE(
23542 --
23543 P_VALIDATE => false
23544 ,P_EFFECTIVE_DATE => l_effective_date
23545 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
23546 --
23547 ,P_ASSIGNMENT_STATUS_TYPE_ID => l_ASSIGNMENT_STATUS_TYPE_ID
23548 ,P_EES_ATTRIBUTE1 => r_EES.INFORMATION111
23549 ,P_EES_ATTRIBUTE10 => r_EES.INFORMATION120
23550 ,P_EES_ATTRIBUTE11 => r_EES.INFORMATION121
23551 ,P_EES_ATTRIBUTE12 => r_EES.INFORMATION122
23552 ,P_EES_ATTRIBUTE13 => r_EES.INFORMATION123
23553 ,P_EES_ATTRIBUTE14 => r_EES.INFORMATION124
23554 ,P_EES_ATTRIBUTE15 => r_EES.INFORMATION125
23555 ,P_EES_ATTRIBUTE16 => r_EES.INFORMATION126
23556 ,P_EES_ATTRIBUTE17 => r_EES.INFORMATION127
23557 ,P_EES_ATTRIBUTE18 => r_EES.INFORMATION128
23558 ,P_EES_ATTRIBUTE19 => r_EES.INFORMATION129
23559 ,P_EES_ATTRIBUTE2 => r_EES.INFORMATION112
23560 ,P_EES_ATTRIBUTE20 => r_EES.INFORMATION130
23561 ,P_EES_ATTRIBUTE21 => r_EES.INFORMATION131
23562 ,P_EES_ATTRIBUTE22 => r_EES.INFORMATION132
23563 ,P_EES_ATTRIBUTE23 => r_EES.INFORMATION133
23564 ,P_EES_ATTRIBUTE24 => r_EES.INFORMATION134
23565 ,P_EES_ATTRIBUTE25 => r_EES.INFORMATION135
23566 ,P_EES_ATTRIBUTE26 => r_EES.INFORMATION136
23567 ,P_EES_ATTRIBUTE27 => r_EES.INFORMATION137
23568 ,P_EES_ATTRIBUTE28 => r_EES.INFORMATION138
23569 ,P_EES_ATTRIBUTE29 => r_EES.INFORMATION139
23570 ,P_EES_ATTRIBUTE3 => r_EES.INFORMATION113
23571 ,P_EES_ATTRIBUTE30 => r_EES.INFORMATION140
23572 ,P_EES_ATTRIBUTE4 => r_EES.INFORMATION114
23573 ,P_EES_ATTRIBUTE5 => r_EES.INFORMATION115
23574 ,P_EES_ATTRIBUTE6 => r_EES.INFORMATION116
23575 ,P_EES_ATTRIBUTE7 => r_EES.INFORMATION117
23576 ,P_EES_ATTRIBUTE8 => r_EES.INFORMATION118
23577 ,P_EES_ATTRIBUTE9 => r_EES.INFORMATION119
23578 ,P_EES_ATTRIBUTE_CATEGORY => r_EES.INFORMATION110
23579 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
23580 ,P_ELIG_EE_STAT_PRTE_ID => l_elig_ee_stat_prte_id
23581 ,P_EXCLD_FLAG => r_EES.INFORMATION11
23582 ,P_ORDR_NUM => r_EES.INFORMATION260
23583 --
23584 -- ****** END CHANGE LINES
23585
23586 --
23587 ,P_EFFECTIVE_START_DATE => l_effective_start_date
23588 ,P_EFFECTIVE_END_DATE => l_effective_end_date
23589 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
23590 ,P_DATETRACK_MODE => l_datetrack_mode
23591 ,P_CRITERIA_SCORE => r_ees.INFORMATION295
23592 ,P_CRITERIA_WEIGHT => r_ees.INFORMATION296
23593 );
23594 end if; -- l_update
23595 --
23596 end if;
23597 --
23598 -- Delete the row if it is end dated.
23599 --
23600 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
23601 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
23602 trunc(l_max_eed) = trunc(r_EES.information3)) then
23603 --
23604 BEN_ELIG_EE_STAT_PRTE_API.delete_ELIG_EE_STAT_PRTE(
23605 --
23606 p_validate => false
23607 ,p_elig_ee_stat_prte_id => l_elig_ee_stat_prte_id
23608 ,p_effective_start_date => l_effective_start_date
23609 ,p_effective_end_date => l_effective_end_date
23610 ,p_object_version_number => l_object_version_number
23611 ,p_effective_date => l_max_eed
23612 ,p_datetrack_mode => hr_api.g_delete
23613 --
23614 );
23615 --
23616 end if;
23617 --
23618 l_prev_pk_id := l_current_pk_id ;
23619 --
23620 --end if; -- bug 4565106
23621 --
23622 end if;
23623 --
23624 end if;
23625 --
23626 end loop;
23627 --
23628 exception when others then
23629 --
23630 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EES',r_EES.information5 ) ;
23631 --
23632 end create_EES_rows;
23633
23634 --
23635 ---------------------------------------------------------------
23636 ----------------------< create_EEI_rows >-----------------------
23637 ---------------------------------------------------------------
23638 --
23639 procedure create_EEI_rows
23640 (
23641 p_validate in number default 0
23642 ,p_copy_entity_txn_id in number
23643 ,p_effective_date in date
23644 ,p_prefix_suffix_text in varchar2 default null
23645 ,p_reuse_object_flag in varchar2 default null
23646 ,p_target_business_group_id in varchar2 default null
23647 ,p_prefix_suffix_cd in varchar2 default null
23648 ) is
23649 --
23650 l_ELIGY_PRFL_ID number;
23651 l_OIPL_ID number;
23652 cursor c_unique_EEI(l_table_alias varchar2) is
23653 select distinct cpe.information1,
23654 cpe.information2,
23655 cpe.information3,
23656 cpe.table_route_id
23657 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
23658 pqh_table_route tr
23659 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23660 and cpe.table_route_id = tr.table_route_id
23661 -- and tr.where_clause = l_BEN_ELIG_ENRLD_ANTHR_OIPL_F
23662 and tr.table_alias = l_table_alias
23663 and cpe.number_of_copies = 1 -- ADDITION
23664 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
23665 order by information1, information2; --added for bug: 5151945
23666 --
23667 --
23668 cursor c_EEI_min_max_dates(c_table_route_id number,
23669 c_information1 number) is
23670 select
23671 min(cpe.information2) min_esd,
23672 max(cpe.information3) min_eed
23673 from ben_copy_entity_results cpe
23674 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23675 and cpe.table_route_id = c_table_route_id
23676 and cpe.information1 = c_information1 ;
23677 --
23678 cursor c_EEI(c_table_route_id number,
23679 c_information1 number,
23680 c_information2 date,
23681 c_information3 date ) is
23682 select
23683 cpe.*
23684 from ben_copy_entity_results cpe
23685 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23686 and cpe.table_route_id = c_table_route_id
23687 and cpe.information1 = c_information1
23688 and cpe.information2 = c_information2
23689 and cpe.information3 = c_information3
23690 and rownum = 1 ;
23691 -- Date Track target record
23692 cursor c_find_EEI_in_target(
23693 c_effective_start_date date,
23694 c_effective_end_date date,
23695 c_business_group_id number,
23696 c_new_pk_id number) is
23697 select
23698 EEI.elig_enrld_anthr_oipl_id new_value
23699 from BEN_ELIG_ENRLD_ANTHR_OIPL_F EEI
23700 where
23701 EEI.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
23702 EEI.OIPL_ID = l_OIPL_ID and
23703 EEI.business_group_id = c_business_group_id
23704 and EEI.elig_enrld_anthr_oipl_id <> c_new_pk_id
23705 and c_effective_start_date between effective_start_date
23706 and effective_end_date ;
23707 --END TEMPIK
23708 /*TEMPIK
23709 and exists ( select null
23710 from BEN_ELIG_ENRLD_ANTHR_OIPL_F EEI1
23711 where
23712 EEI1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
23713 EEI1.OIPL_ID = l_OIPL_ID and
23714 EEI1.business_group_id = c_business_group_id
23715 and EEI1.effective_start_date <= c_effective_start_date )
23716 and exists ( select null
23717 from BEN_ELIG_ENRLD_ANTHR_OIPL_F EEI2
23718 where
23719 EEI2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
23720 EEI2.OIPL_ID = l_OIPL_ID and
23721 EEI2.business_group_id = c_business_group_id
23722 and EEI2.effective_end_date >= c_effective_end_date )
23723 ;
23724 TEMPIK */
23725 --TEMPIK
23726 l_dt_rec_found boolean ;
23727 --END TEMPIK
23728 --
23729
23730 --UPD START
23731 --
23732 l_update boolean := false ;
23733 l_datetrack_mode varchar2(80) := hr_api.g_update;
23734 l_process_date date;
23735 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
23736 --
23737 --UPD END
23738 l_current_pk_id number := null ;
23739
23740 l_prev_pk_id number := null ;
23741 l_first_rec boolean := true ;
23742 r_EEI c_EEI%rowtype;
23743 l_elig_enrld_anthr_oipl_id number ;
23744 l_object_version_number number ;
23745 l_effective_start_date date ;
23746 l_effective_end_date date ;
23747 l_prefix pqh_copy_entity_attribs.information1%type := null;
23748 l_suffix pqh_copy_entity_attribs.information1%type := null;
23749 l_new_value number(15);
23750 l_object_found_in_target boolean := false ;
23751 l_min_esd date;
23752 l_max_eed date;
23753 l_effective_date date;
23754 --
23755 begin
23756 -- Initialization
23757 l_object_found_in_target := false ;
23758 -- End Initialization
23759 -- Derive the prefix - sufix
23760 if p_prefix_suffix_cd = 'PREFIX' then
23761 l_prefix := p_prefix_suffix_text ;
23762 elsif p_prefix_suffix_cd = 'SUFFIX' then
23763 l_suffix := p_prefix_suffix_text ;
23764 else
23765 l_prefix := null ;
23766 l_suffix := null ;
23767 end if ;
23768 -- End Prefix Sufix derivation
23769 for r_EEI_unique in c_unique_EEI('EEI') loop
23770
23771 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
23772 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23773 r_EEI_unique.information3 >=
23774 ben_pd_copy_to_ben_one.g_copy_effective_date)
23775 ) then
23776 --
23777 hr_utility.set_location(' r_EEI_unique.table_route_id '||r_EEI_unique.table_route_id,10);
23778 hr_utility.set_location(' r_EEI_unique.information1 '||r_EEI_unique.information1,10);
23779 hr_utility.set_location( 'r_EEI_unique.information2 '||r_EEI_unique.information2,10);
23780 hr_utility.set_location( 'r_EEI_unique.information3 '||r_EEI_unique.information3,10);
23781 -- If reuse objects flag is 'Y' then check for the object in the target business group
23782 -- if found insert the record into PLSql table and exit the loop else try create the
23783 -- object in the target business group
23784 --
23785 l_object_found_in_target := false ;
23786 --UPD START
23787 l_update := false;
23788 l_process_date := p_effective_date;
23789 l_dml_operation:= r_EEI_unique.dml_operation ;
23790 --
23791 /**********************moved from below **********************/
23792 open c_EEI(r_EEI_unique.table_route_id,
23793 r_EEI_unique.information1,
23794 r_EEI_unique.information2,
23795 r_EEI_unique.information3 ) ;
23796 --
23797 fetch c_EEI into r_EEI ;
23798 --
23799 close c_EEI ;
23800 --
23801 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EEI.INFORMATION263,l_dml_operation);
23802
23803 -- Only For Use by Create Wizard - Same Business Group
23804 l_OIPL_ID := NVL(get_fk('OIPL_ID', r_EEI.INFORMATION258,l_dml_operation),
23805 r_EEI.INFORMATION258);
23806 /**********************************************************/
23807
23808 if l_dml_operation = 'UPDATE' then
23809 --
23810 l_object_found_in_target := TRUE;
23811 --
23812 if l_process_date between r_EEI_unique.information2 and r_EEI_unique.information3 then
23813 l_update := true;
23814 if r_EEI_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
23815 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ENRLD_ANTHR_OIPL_ID' then
23816 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_OIPL_ID' ;
23817 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EEI_unique.information1 ;
23818 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EEI_unique.information1 ;
23819 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23820 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EEI_unique.table_route_id;
23821 --
23822 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
23823 --
23824 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23825 --
23826 -- log_data('EEI',l_new_value,l_prefix || r_EEI_unique.name|| l_suffix,'REUSED');
23827 --
23828 end if ;
23829 hr_utility.set_location( 'found record for update',10);
23830 --
23831 else
23832 --
23833 l_update := false;
23834 --
23835 end if;
23836 else
23837 --
23838 --UPD END
23839 l_min_esd := null ;
23840 l_max_eed := null ;
23841 open c_EEI_min_max_dates(r_EEI_unique.table_route_id, r_EEI_unique.information1 ) ;
23842 fetch c_EEI_min_max_dates into l_min_esd,l_max_eed ;
23843 --
23844
23845 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23846 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
23847 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
23848 end if;
23849 l_min_esd := greatest(l_min_esd,r_EEI_unique.information2);
23850 /**********************moved up from here **********************
23851 open c_EEI(r_EEI_unique.table_route_id,
23852 r_EEI_unique.information1,
23853 r_EEI_unique.information2,
23854 r_EEI_unique.information3 ) ;
23855 --
23856 fetch c_EEI into r_EEI ;
23857 --
23858 close c_EEI ;
23859 --
23860 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EEI.INFORMATION263,l_dml_operation);
23861
23862 -- Only For Use by Create Wizard - Same Business Group
23863 l_OIPL_ID := NVL(get_fk('OIPL_ID', r_EEI.INFORMATION258,l_dml_operation),
23864 r_EEI.INFORMATION258);
23865 **********************************************************/
23866
23867
23868 if p_reuse_object_flag = 'Y' then
23869 if c_EEI_min_max_dates%found then
23870 -- cursor to find the object
23871 open c_find_EEI_in_target( l_min_esd,l_max_eed,
23872 p_target_business_group_id, nvl(l_elig_enrld_anthr_oipl_id, -999) ) ;
23873 fetch c_find_EEI_in_target into l_new_value ;
23874 if c_find_EEI_in_target%found then
23875 --
23876 --TEMPIK
23877 l_dt_rec_found := dt_api.check_min_max_dates
23878 (p_base_table_name => 'BEN_ELIG_ENRLD_ANTHR_OIPL_F',
23879 p_base_key_column => 'ELIG_ENRLD_ANTHR_OIPL_ID',
23880 p_base_key_value => l_new_value,
23881 p_from_date => l_min_esd,
23882 p_to_date => l_max_eed );
23883 if l_dt_rec_found THEN
23884 --END TEMPIK
23885 if r_EEI_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
23886 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ENRLD_ANTHR_OIPL_ID' then
23887 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_OIPL_ID' ;
23888 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EEI_unique.information1 ;
23889 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
23890 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23891 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EEI_unique.table_route_id;
23892 --
23893 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
23894 --
23895 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23896 end if ;
23897 --
23898 l_object_found_in_target := true ;
23899 --TEMPIK
23900 end if; -- l_dt_rec_found
23901 --END TEMPIK
23902 end if;
23903 close c_find_EEI_in_target ;
23904 --
23905 end if;
23906 end if ;
23907 --
23908 close c_EEI_min_max_dates ;
23909 end if; --if p_dml_operation
23910 --
23911 if not l_object_found_in_target OR l_update then
23912
23913 --
23914 l_current_pk_id := r_EEI.information1;
23915 --
23916 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
23917 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
23918 --
23919 if l_current_pk_id = l_prev_pk_id then
23920 --
23921 l_first_rec := false ;
23922 --
23923 else
23924 --
23925 l_first_rec := true ;
23926 --
23927 end if ;
23928 --
23929
23930 l_effective_date := r_EEI.information2;
23931 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23932 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
23933 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
23934 end if;
23935
23936 if l_first_rec and not l_update then
23937 -- Call Create routine.
23938 hr_utility.set_location(' BEN_ELIG_ENRLD_ANTHR_OIPL_F CREATE_ELIG_ENRLD_ANTHR_OIPL ',20);
23939 BEN_ELIG_ENRLD_ANTHR_OIPL_API.CREATE_ELIG_ENRLD_ANTHR_OIPL(
23940 --
23941 P_VALIDATE => false
23942 ,P_EFFECTIVE_DATE => l_effective_date
23943 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
23944 --
23945 ,P_EEI_ATTRIBUTE1 => r_EEI.INFORMATION111
23946 ,P_EEI_ATTRIBUTE10 => r_EEI.INFORMATION120
23947 ,P_EEI_ATTRIBUTE11 => r_EEI.INFORMATION121
23948 ,P_EEI_ATTRIBUTE12 => r_EEI.INFORMATION122
23949 ,P_EEI_ATTRIBUTE13 => r_EEI.INFORMATION123
23950 ,P_EEI_ATTRIBUTE14 => r_EEI.INFORMATION124
23951 ,P_EEI_ATTRIBUTE15 => r_EEI.INFORMATION125
23952 ,P_EEI_ATTRIBUTE16 => r_EEI.INFORMATION126
23953 ,P_EEI_ATTRIBUTE17 => r_EEI.INFORMATION127
23954 ,P_EEI_ATTRIBUTE18 => r_EEI.INFORMATION128
23955 ,P_EEI_ATTRIBUTE19 => r_EEI.INFORMATION129
23956 ,P_EEI_ATTRIBUTE2 => r_EEI.INFORMATION112
23957 ,P_EEI_ATTRIBUTE20 => r_EEI.INFORMATION130
23958 ,P_EEI_ATTRIBUTE21 => r_EEI.INFORMATION131
23959 ,P_EEI_ATTRIBUTE22 => r_EEI.INFORMATION132
23960 ,P_EEI_ATTRIBUTE23 => r_EEI.INFORMATION133
23961 ,P_EEI_ATTRIBUTE24 => r_EEI.INFORMATION134
23962 ,P_EEI_ATTRIBUTE25 => r_EEI.INFORMATION135
23963 ,P_EEI_ATTRIBUTE26 => r_EEI.INFORMATION136
23964 ,P_EEI_ATTRIBUTE27 => r_EEI.INFORMATION137
23965 ,P_EEI_ATTRIBUTE28 => r_EEI.INFORMATION138
23966 ,P_EEI_ATTRIBUTE29 => r_EEI.INFORMATION139
23967 ,P_EEI_ATTRIBUTE3 => r_EEI.INFORMATION113
23968 ,P_EEI_ATTRIBUTE30 => r_EEI.INFORMATION140
23969 ,P_EEI_ATTRIBUTE4 => r_EEI.INFORMATION114
23970 ,P_EEI_ATTRIBUTE5 => r_EEI.INFORMATION115
23971 ,P_EEI_ATTRIBUTE6 => r_EEI.INFORMATION116
23972 ,P_EEI_ATTRIBUTE7 => r_EEI.INFORMATION117
23973 ,P_EEI_ATTRIBUTE8 => r_EEI.INFORMATION118
23974 ,P_EEI_ATTRIBUTE9 => r_EEI.INFORMATION119
23975 ,P_EEI_ATTRIBUTE_CATEGORY => r_EEI.INFORMATION110
23976 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
23977 ,P_ELIG_ENRLD_ANTHR_OIPL_ID => l_elig_enrld_anthr_oipl_id
23978 ,P_ENRL_DET_DT_CD => r_EEI.INFORMATION12
23979 ,P_EXCLD_FLAG => r_EEI.INFORMATION11
23980 ,P_OIPL_ID => l_OIPL_ID
23981 ,P_ORDR_NUM => r_EEI.INFORMATION261
23982 --
23983 -- ****** END CHANGE LINES
23984
23985 --
23986
23987 ,P_EFFECTIVE_START_DATE => l_effective_start_date
23988 ,P_EFFECTIVE_END_DATE => l_effective_end_date
23989 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
23990 );
23991 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
23992 -- Update all relevent cer records with new pk_id
23993 hr_utility.set_location('Before plsql table ',222);
23994 hr_utility.set_location('new_value id '||l_elig_enrld_anthr_oipl_id,222);
23995 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_OIPL_ID' ;
23996 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EEI.information1 ;
23997 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_ENRLD_ANTHR_OIPL_ID ;
23998 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
23999 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EEI_unique.table_route_id;
24000 hr_utility.set_location('After plsql table ',222);
24001 --
24002 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
24003 --
24004 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24005 --
24006 else
24007 --
24008 -- Call Update routine for the pk_id created in prev run .
24009 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24010 hr_utility.set_location(' BEN_ELIG_ENRLD_ANTHR_OIPL_F UPDATE_ELIG_ENRLD_ANTHR_OIPL ',30);
24011 --UPD START
24012 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
24013 --
24014 if l_update then
24015 --
24016 l_datetrack_mode := r_EEI.datetrack_mode ;
24017 --
24018 get_dt_modes(
24019 p_effective_date => l_process_date,
24020 p_effective_end_date => r_EEI.information3,
24021 p_effective_start_date => r_EEI.information2,
24022 p_dml_operation => r_EEI.dml_operation,
24023 p_datetrack_mode => l_datetrack_mode );
24024 -- p_update => l_update
24025 --
24026 l_effective_date := l_process_date;
24027 l_ELIG_ENRLD_ANTHR_OIPL_ID := r_EEI.information1;
24028 l_object_version_number := r_EEI.information265;
24029 --
24030 end if;
24031 --
24032 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
24033 --
24034 IF l_update OR l_dml_operation <> 'UPDATE' THEN
24035 --UPD END
24036
24037
24038 BEN_ELIG_ENRLD_ANTHR_OIPL_API.UPDATE_ELIG_ENRLD_ANTHR_OIPL(
24039 --
24040 P_VALIDATE => false
24041 ,P_EFFECTIVE_DATE => l_effective_date
24042 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24043 --
24044 ,P_EEI_ATTRIBUTE1 => r_EEI.INFORMATION111
24045 ,P_EEI_ATTRIBUTE10 => r_EEI.INFORMATION120
24046 ,P_EEI_ATTRIBUTE11 => r_EEI.INFORMATION121
24047 ,P_EEI_ATTRIBUTE12 => r_EEI.INFORMATION122
24048 ,P_EEI_ATTRIBUTE13 => r_EEI.INFORMATION123
24049 ,P_EEI_ATTRIBUTE14 => r_EEI.INFORMATION124
24050 ,P_EEI_ATTRIBUTE15 => r_EEI.INFORMATION125
24051 ,P_EEI_ATTRIBUTE16 => r_EEI.INFORMATION126
24052 ,P_EEI_ATTRIBUTE17 => r_EEI.INFORMATION127
24053 ,P_EEI_ATTRIBUTE18 => r_EEI.INFORMATION128
24054 ,P_EEI_ATTRIBUTE19 => r_EEI.INFORMATION129
24055 ,P_EEI_ATTRIBUTE2 => r_EEI.INFORMATION112
24056 ,P_EEI_ATTRIBUTE20 => r_EEI.INFORMATION130
24057 ,P_EEI_ATTRIBUTE21 => r_EEI.INFORMATION131
24058 ,P_EEI_ATTRIBUTE22 => r_EEI.INFORMATION132
24059 ,P_EEI_ATTRIBUTE23 => r_EEI.INFORMATION133
24060 ,P_EEI_ATTRIBUTE24 => r_EEI.INFORMATION134
24061 ,P_EEI_ATTRIBUTE25 => r_EEI.INFORMATION135
24062 ,P_EEI_ATTRIBUTE26 => r_EEI.INFORMATION136
24063 ,P_EEI_ATTRIBUTE27 => r_EEI.INFORMATION137
24064 ,P_EEI_ATTRIBUTE28 => r_EEI.INFORMATION138
24065 ,P_EEI_ATTRIBUTE29 => r_EEI.INFORMATION139
24066 ,P_EEI_ATTRIBUTE3 => r_EEI.INFORMATION113
24067 ,P_EEI_ATTRIBUTE30 => r_EEI.INFORMATION140
24068 ,P_EEI_ATTRIBUTE4 => r_EEI.INFORMATION114
24069 ,P_EEI_ATTRIBUTE5 => r_EEI.INFORMATION115
24070 ,P_EEI_ATTRIBUTE6 => r_EEI.INFORMATION116
24071 ,P_EEI_ATTRIBUTE7 => r_EEI.INFORMATION117
24072 ,P_EEI_ATTRIBUTE8 => r_EEI.INFORMATION118
24073 ,P_EEI_ATTRIBUTE9 => r_EEI.INFORMATION119
24074 ,P_EEI_ATTRIBUTE_CATEGORY => r_EEI.INFORMATION110
24075 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
24076 ,P_ELIG_ENRLD_ANTHR_OIPL_ID => l_elig_enrld_anthr_oipl_id
24077 ,P_ENRL_DET_DT_CD => r_EEI.INFORMATION12
24078 ,P_EXCLD_FLAG => r_EEI.INFORMATION11
24079 ,P_OIPL_ID => l_OIPL_ID
24080 ,P_ORDR_NUM => r_EEI.INFORMATION261
24081 --
24082 -- ****** END CHANGE LINES
24083
24084 --
24085 ,P_EFFECTIVE_START_DATE => l_effective_start_date
24086 ,P_EFFECTIVE_END_DATE => l_effective_end_date
24087 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24088 ,P_DATETRACK_MODE => l_datetrack_mode
24089 );
24090 end if; -- l_update
24091 --
24092 end if;
24093 --
24094 -- Delete the row if it is end dated.
24095 --
24096 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
24097 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
24098 trunc(l_max_eed) = trunc(r_EEI.information3)) then
24099 --
24100 BEN_ELIG_ENRLD_ANTHR_OIPL_API.delete_ELIG_ENRLD_ANTHR_OIPL(
24101 --
24102 p_validate => false
24103 ,p_elig_enrld_anthr_oipl_id => l_elig_enrld_anthr_oipl_id
24104 ,p_effective_start_date => l_effective_start_date
24105 ,p_effective_end_date => l_effective_end_date
24106 ,p_object_version_number => l_object_version_number
24107 ,p_effective_date => l_max_eed
24108 ,p_datetrack_mode => hr_api.g_delete
24109 --
24110 );
24111 --
24112 end if;
24113 --
24114 l_prev_pk_id := l_current_pk_id ;
24115 --
24116 end if;
24117 --
24118 end if;
24119 --
24120 end loop;
24121 --
24122 exception when others then
24123 --
24124 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EEI',r_EEI.information5 ) ;
24125 --
24126 end create_EEI_rows;
24127
24128 --
24129 ---------------------------------------------------------------
24130 ----------------------< create_EEG_rows >-----------------------
24131 ---------------------------------------------------------------
24132 --
24133 procedure create_EEG_rows
24134 (
24135 p_validate in number default 0
24136 ,p_copy_entity_txn_id in number
24137 ,p_effective_date in date
24138 ,p_prefix_suffix_text in varchar2 default null
24139 ,p_reuse_object_flag in varchar2 default null
24140 ,p_target_business_group_id in varchar2 default null
24141 ,p_prefix_suffix_cd in varchar2 default null
24142 ) is
24143 --
24144 l_ELIGY_PRFL_ID number;
24145 l_PGM_ID number;
24146 cursor c_unique_EEG(l_table_alias varchar2) is
24147 select distinct cpe.information1,
24148 cpe.information2,
24149 cpe.information3,
24150 cpe.table_route_id
24151 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
24152 pqh_table_route tr
24153 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24154 and cpe.table_route_id = tr.table_route_id
24155 -- and tr.where_clause = l_BEN_ELIG_ENRLD_ANTHR_PGM_F
24156 and tr.table_alias = l_table_alias
24157 and cpe.number_of_copies = 1 -- ADDITION
24158 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
24159 order by information1, information2; --added for bug: 5151945
24160 --
24161 --
24162 cursor c_EEG_min_max_dates(c_table_route_id number,
24163 c_information1 number) is
24164 select
24165 min(cpe.information2) min_esd,
24166 max(cpe.information3) min_eed
24167 from ben_copy_entity_results cpe
24168 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24169 and cpe.table_route_id = c_table_route_id
24170 and cpe.information1 = c_information1 ;
24171 --
24172 cursor c_EEG(c_table_route_id number,
24173 c_information1 number,
24174 c_information2 date,
24175 c_information3 date ) is
24176 select
24177 cpe.*
24178 from ben_copy_entity_results cpe
24179 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24180 and cpe.table_route_id = c_table_route_id
24181 and cpe.information1 = c_information1
24182 and cpe.information2 = c_information2
24183 and cpe.information3 = c_information3
24184 and rownum = 1 ;
24185 -- Date Track target record
24186 cursor c_find_EEG_in_target(
24187 c_effective_start_date date,
24188 c_effective_end_date date,
24189 c_business_group_id number,
24190 c_new_pk_id number) is
24191 select
24192 EEG.elig_enrld_anthr_pgm_id new_value
24193 from BEN_ELIG_ENRLD_ANTHR_PGM_F EEG
24194 where
24195 EEG.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
24196 EEG.PGM_ID = l_PGM_ID and
24197 EEG.business_group_id = c_business_group_id
24198 and EEG.elig_enrld_anthr_pgm_id <> c_new_pk_id
24199 and c_effective_start_date between effective_start_date
24200 and effective_end_date ;
24201 --END TEMPIK
24202 /*TEMPIK
24203 and exists ( select null
24204 from BEN_ELIG_ENRLD_ANTHR_PGM_F EEG1
24205 where
24206 EEG1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
24207 EEG1.PGM_ID = l_PGM_ID and
24208 EEG1.business_group_id = c_business_group_id
24209 and EEG1.effective_start_date <= c_effective_start_date )
24210 and exists ( select null
24211 from BEN_ELIG_ENRLD_ANTHR_PGM_F EEG2
24212 where
24213 EEG2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
24214 EEG2.PGM_ID = l_PGM_ID and
24215 EEG2.business_group_id = c_business_group_id
24216 and EEG2.effective_end_date >= c_effective_end_date )
24217 ;
24218 TEMPIK */
24219 --TEMPIK
24220 l_dt_rec_found boolean ;
24221 --END TEMPIK
24222 --
24223
24224 --UPD START
24225 --
24226 l_update boolean := false ;
24227 l_datetrack_mode varchar2(80) := hr_api.g_update;
24228 l_process_date date;
24229 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
24230 --
24231 --UPD END
24232 l_current_pk_id number := null ;
24233
24234 l_prev_pk_id number := null ;
24235 l_first_rec boolean := true ;
24236 r_EEG c_EEG%rowtype;
24237 l_elig_enrld_anthr_pgm_id number ;
24238 l_object_version_number number ;
24239 l_effective_start_date date ;
24240 l_effective_end_date date ;
24241 l_prefix pqh_copy_entity_attribs.information1%type := null;
24242 l_suffix pqh_copy_entity_attribs.information1%type := null;
24243 l_new_value number(15);
24244 l_object_found_in_target boolean := false ;
24245 l_min_esd date;
24246 l_max_eed date;
24247 l_effective_date date;
24248 --
24249 begin
24250 -- Initialization
24251 l_object_found_in_target := false ;
24252 -- End Initialization
24253 -- Derive the prefix - sufix
24254 if p_prefix_suffix_cd = 'PREFIX' then
24255 l_prefix := p_prefix_suffix_text ;
24256 elsif p_prefix_suffix_cd = 'SUFFIX' then
24257 l_suffix := p_prefix_suffix_text ;
24258 else
24259 l_prefix := null ;
24260 l_suffix := null ;
24261 end if ;
24262 -- End Prefix Sufix derivation
24263 for r_EEG_unique in c_unique_EEG('EEG') loop
24264
24265 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
24266 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24267 r_EEG_unique.information3 >=
24268 ben_pd_copy_to_ben_one.g_copy_effective_date)
24269 ) then
24270 --
24271 hr_utility.set_location(' r_EEG_unique.table_route_id '||r_EEG_unique.table_route_id,10);
24272 hr_utility.set_location(' r_EEG_unique.information1 '||r_EEG_unique.information1,10);
24273 hr_utility.set_location( 'r_EEG_unique.information2 '||r_EEG_unique.information2,10);
24274 hr_utility.set_location( 'r_EEG_unique.information3 '||r_EEG_unique.information3,10);
24275 -- If reuse objects flag is 'Y' then check for the object in the target business group
24276 -- if found insert the record into PLSql table and exit the loop else try create the
24277 -- object in the target business group
24278 --
24279 l_object_found_in_target := false ;
24280 --UPD START
24281 l_update := false;
24282 l_process_date := p_effective_date;
24283 l_dml_operation:= r_EEG_unique.dml_operation ;
24284 --
24285 /**********************moved from below **********************/
24286 open c_EEG(r_EEG_unique.table_route_id,
24287 r_EEG_unique.information1,
24288 r_EEG_unique.information2,
24289 r_EEG_unique.information3 ) ;
24290 --
24291 fetch c_EEG into r_EEG ;
24292 --
24293 close c_EEG ;
24294 --
24295 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EEG.INFORMATION263,l_dml_operation);
24296
24297 -- Only For Use by Create Wizard - Same Business Group
24298 l_PGM_ID := NVL(get_fk('PGM_ID', r_EEG.INFORMATION260,l_dml_operation),
24299 r_EEG.INFORMATION260);
24300 /**********************************************************/
24301
24302 if l_dml_operation = 'UPDATE' then
24303 --
24304 l_object_found_in_target := TRUE;
24305 --
24306 if l_process_date between r_EEG_unique.information2 and r_EEG_unique.information3 then
24307 l_update := true;
24308 if r_EEG_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
24309 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ENRLD_ANTHR_PGM_ID' then
24310 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_PGM_ID' ;
24311 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EEG_unique.information1 ;
24312 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EEG_unique.information1 ;
24313 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
24314 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EEG_unique.table_route_id;
24315 --
24316 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
24317 --
24318 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24319 --
24320 -- log_data('EEG',l_new_value,l_prefix || r_EEG_unique.name|| l_suffix,'REUSED');
24321 --
24322 end if ;
24323 hr_utility.set_location( 'found record for update',10);
24324 --
24325 else
24326 --
24327 l_update := false;
24328 --
24329 end if;
24330 else
24331 --
24332 --UPD END
24333 l_min_esd := null ;
24334 l_max_eed := null ;
24335 open c_EEG_min_max_dates(r_EEG_unique.table_route_id, r_EEG_unique.information1 ) ;
24336 fetch c_EEG_min_max_dates into l_min_esd,l_max_eed ;
24337 --
24338
24339 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24340 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
24341 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
24342 end if;
24343 l_min_esd := greatest(l_min_esd,r_EEG_unique.information2);
24344 /**********************moved up from here **********************
24345 open c_EEG(r_EEG_unique.table_route_id,
24346 r_EEG_unique.information1,
24347 r_EEG_unique.information2,
24348 r_EEG_unique.information3 ) ;
24349 --
24350 fetch c_EEG into r_EEG ;
24351 --
24352 close c_EEG ;
24353 --
24354 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EEG.INFORMATION263,l_dml_operation);
24355
24356 -- Only For Use by Create Wizard - Same Business Group
24357 l_PGM_ID := NVL(get_fk('PGM_ID', r_EEG.INFORMATION260,l_dml_operation),
24358 r_EEG.INFORMATION260);
24359 **********************************************************/
24360
24361
24362 if p_reuse_object_flag = 'Y' then
24363 if c_EEG_min_max_dates%found then
24364 -- cursor to find the object
24365 open c_find_EEG_in_target( l_min_esd,l_max_eed,
24366 p_target_business_group_id, nvl(l_elig_enrld_anthr_pgm_id, -999) ) ;
24367 fetch c_find_EEG_in_target into l_new_value ;
24368 if c_find_EEG_in_target%found then
24369 --
24370 --TEMPIK
24371 l_dt_rec_found := dt_api.check_min_max_dates
24372 (p_base_table_name => 'BEN_ELIG_ENRLD_ANTHR_PGM_F',
24373 p_base_key_column => 'ELIG_ENRLD_ANTHR_PGM_ID',
24374 p_base_key_value => l_new_value,
24375 p_from_date => l_min_esd,
24376 p_to_date => l_max_eed );
24377 if l_dt_rec_found THEN
24378 --END TEMPIK
24379 if r_EEG_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
24380 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ENRLD_ANTHR_PGM_ID' then
24381 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_PGM_ID' ;
24382 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EEG_unique.information1 ;
24383 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
24384 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
24385 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EEG_unique.table_route_id;
24386 --
24387 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
24388 --
24389 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24390 end if ;
24391 --
24392 l_object_found_in_target := true ;
24393 --TEMPIK
24394 end if; -- l_dt_rec_found
24395 --END TEMPIK
24396 end if;
24397 close c_find_EEG_in_target ;
24398 --
24399 end if;
24400 end if ;
24401 --
24402 close c_EEG_min_max_dates ;
24403 end if; --if p_dml_operation
24404 --
24405 if not l_object_found_in_target OR l_update then
24406
24407 --
24408 l_current_pk_id := r_EEG.information1;
24409 --
24410 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
24411 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
24412 --
24413 if l_current_pk_id = l_prev_pk_id then
24414 --
24415 l_first_rec := false ;
24416 --
24417 else
24418 --
24419 l_first_rec := true ;
24420 --
24421 end if ;
24422 --
24423
24424 l_effective_date := r_EEG.information2;
24425 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24426 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
24427 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
24428 end if;
24429
24430 if l_first_rec and not l_update then
24431 -- Call Create routine.
24432 hr_utility.set_location(' BEN_ELIG_ENRLD_ANTHR_PGM_F CREATE_ELIG_ENRLD_ANTHR_PGM ',20);
24433 BEN_ELIG_ENRLD_ANTHR_PGM_API.CREATE_ELIG_ENRLD_ANTHR_PGM(
24434 --
24435 P_VALIDATE => false
24436 ,P_EFFECTIVE_DATE => l_effective_date
24437 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24438 --
24439 ,P_EEG_ATTRIBUTE1 => r_EEG.INFORMATION111
24440 ,P_EEG_ATTRIBUTE10 => r_EEG.INFORMATION120
24441 ,P_EEG_ATTRIBUTE11 => r_EEG.INFORMATION121
24442 ,P_EEG_ATTRIBUTE12 => r_EEG.INFORMATION122
24443 ,P_EEG_ATTRIBUTE13 => r_EEG.INFORMATION123
24444 ,P_EEG_ATTRIBUTE14 => r_EEG.INFORMATION124
24445 ,P_EEG_ATTRIBUTE15 => r_EEG.INFORMATION125
24446 ,P_EEG_ATTRIBUTE16 => r_EEG.INFORMATION126
24447 ,P_EEG_ATTRIBUTE17 => r_EEG.INFORMATION127
24448 ,P_EEG_ATTRIBUTE18 => r_EEG.INFORMATION128
24449 ,P_EEG_ATTRIBUTE19 => r_EEG.INFORMATION129
24450 ,P_EEG_ATTRIBUTE2 => r_EEG.INFORMATION112
24451 ,P_EEG_ATTRIBUTE20 => r_EEG.INFORMATION130
24452 ,P_EEG_ATTRIBUTE21 => r_EEG.INFORMATION131
24453 ,P_EEG_ATTRIBUTE22 => r_EEG.INFORMATION132
24454 ,P_EEG_ATTRIBUTE23 => r_EEG.INFORMATION133
24455 ,P_EEG_ATTRIBUTE24 => r_EEG.INFORMATION134
24456 ,P_EEG_ATTRIBUTE25 => r_EEG.INFORMATION135
24457 ,P_EEG_ATTRIBUTE26 => r_EEG.INFORMATION136
24458 ,P_EEG_ATTRIBUTE27 => r_EEG.INFORMATION137
24459 ,P_EEG_ATTRIBUTE28 => r_EEG.INFORMATION138
24460 ,P_EEG_ATTRIBUTE29 => r_EEG.INFORMATION139
24461 ,P_EEG_ATTRIBUTE3 => r_EEG.INFORMATION113
24462 ,P_EEG_ATTRIBUTE30 => r_EEG.INFORMATION140
24463 ,P_EEG_ATTRIBUTE4 => r_EEG.INFORMATION114
24464 ,P_EEG_ATTRIBUTE5 => r_EEG.INFORMATION115
24465 ,P_EEG_ATTRIBUTE6 => r_EEG.INFORMATION116
24466 ,P_EEG_ATTRIBUTE7 => r_EEG.INFORMATION117
24467 ,P_EEG_ATTRIBUTE8 => r_EEG.INFORMATION118
24468 ,P_EEG_ATTRIBUTE9 => r_EEG.INFORMATION119
24469 ,P_EEG_ATTRIBUTE_CATEGORY => r_EEG.INFORMATION110
24470 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
24471 ,P_ELIG_ENRLD_ANTHR_PGM_ID => l_elig_enrld_anthr_pgm_id
24472 ,P_ENRL_DET_DT_CD => r_EEG.INFORMATION11
24473 ,P_EXCLD_FLAG => r_EEG.INFORMATION12
24474 ,P_ORDR_NUM => r_EEG.INFORMATION261
24475 ,P_PGM_ID => l_PGM_ID
24476 --
24477 -- ****** END CHANGE LINES
24478
24479 --
24480
24481 ,P_EFFECTIVE_START_DATE => l_effective_start_date
24482 ,P_EFFECTIVE_END_DATE => l_effective_end_date
24483 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24484 );
24485 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24486 -- Update all relevent cer records with new pk_id
24487 hr_utility.set_location('Before plsql table ',222);
24488 hr_utility.set_location('new_value id '||l_elig_enrld_anthr_pgm_id,222);
24489 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_PGM_ID' ;
24490 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EEG.information1 ;
24491 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_ENRLD_ANTHR_PGM_ID ;
24492 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
24493 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EEG_unique.table_route_id;
24494 hr_utility.set_location('After plsql table ',222);
24495 --
24496 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
24497 --
24498 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24499 --
24500 else
24501 --
24502 -- Call Update routine for the pk_id created in prev run .
24503 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24504 hr_utility.set_location(' BEN_ELIG_ENRLD_ANTHR_PGM_F UPDATE_ELIG_ENRLD_ANTHR_PGM ',30);
24505 --UPD START
24506 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
24507 --
24508 if l_update then
24509 --
24510 l_datetrack_mode := r_EEG.datetrack_mode ;
24511 --
24512 get_dt_modes(
24513 p_effective_date => l_process_date,
24514 p_effective_end_date => r_EEG.information3,
24515 p_effective_start_date => r_EEG.information2,
24516 p_dml_operation => r_EEG.dml_operation,
24517 p_datetrack_mode => l_datetrack_mode );
24518 -- p_update => l_update
24519 --
24520 l_effective_date := l_process_date;
24521 l_ELIG_ENRLD_ANTHR_PGM_ID := r_EEG.information1;
24522 l_object_version_number := r_EEG.information265;
24523 --
24524 end if;
24525 --
24526 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
24527 --
24528 IF l_update OR l_dml_operation <> 'UPDATE' THEN
24529 --UPD END
24530
24531
24532 BEN_ELIG_ENRLD_ANTHR_PGM_API.UPDATE_ELIG_ENRLD_ANTHR_PGM(
24533 --
24534 P_VALIDATE => false
24535 ,P_EFFECTIVE_DATE => l_effective_date
24536 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24537 --
24538 ,P_EEG_ATTRIBUTE1 => r_EEG.INFORMATION111
24539 ,P_EEG_ATTRIBUTE10 => r_EEG.INFORMATION120
24540 ,P_EEG_ATTRIBUTE11 => r_EEG.INFORMATION121
24541 ,P_EEG_ATTRIBUTE12 => r_EEG.INFORMATION122
24542 ,P_EEG_ATTRIBUTE13 => r_EEG.INFORMATION123
24543 ,P_EEG_ATTRIBUTE14 => r_EEG.INFORMATION124
24544 ,P_EEG_ATTRIBUTE15 => r_EEG.INFORMATION125
24545 ,P_EEG_ATTRIBUTE16 => r_EEG.INFORMATION126
24546 ,P_EEG_ATTRIBUTE17 => r_EEG.INFORMATION127
24547 ,P_EEG_ATTRIBUTE18 => r_EEG.INFORMATION128
24548 ,P_EEG_ATTRIBUTE19 => r_EEG.INFORMATION129
24549 ,P_EEG_ATTRIBUTE2 => r_EEG.INFORMATION112
24550 ,P_EEG_ATTRIBUTE20 => r_EEG.INFORMATION130
24551 ,P_EEG_ATTRIBUTE21 => r_EEG.INFORMATION131
24552 ,P_EEG_ATTRIBUTE22 => r_EEG.INFORMATION132
24553 ,P_EEG_ATTRIBUTE23 => r_EEG.INFORMATION133
24554 ,P_EEG_ATTRIBUTE24 => r_EEG.INFORMATION134
24555 ,P_EEG_ATTRIBUTE25 => r_EEG.INFORMATION135
24556 ,P_EEG_ATTRIBUTE26 => r_EEG.INFORMATION136
24557 ,P_EEG_ATTRIBUTE27 => r_EEG.INFORMATION137
24558 ,P_EEG_ATTRIBUTE28 => r_EEG.INFORMATION138
24559 ,P_EEG_ATTRIBUTE29 => r_EEG.INFORMATION139
24560 ,P_EEG_ATTRIBUTE3 => r_EEG.INFORMATION113
24561 ,P_EEG_ATTRIBUTE30 => r_EEG.INFORMATION140
24562 ,P_EEG_ATTRIBUTE4 => r_EEG.INFORMATION114
24563 ,P_EEG_ATTRIBUTE5 => r_EEG.INFORMATION115
24564 ,P_EEG_ATTRIBUTE6 => r_EEG.INFORMATION116
24565 ,P_EEG_ATTRIBUTE7 => r_EEG.INFORMATION117
24566 ,P_EEG_ATTRIBUTE8 => r_EEG.INFORMATION118
24567 ,P_EEG_ATTRIBUTE9 => r_EEG.INFORMATION119
24568 ,P_EEG_ATTRIBUTE_CATEGORY => r_EEG.INFORMATION110
24569 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
24570 ,P_ELIG_ENRLD_ANTHR_PGM_ID => l_elig_enrld_anthr_pgm_id
24571 ,P_ENRL_DET_DT_CD => r_EEG.INFORMATION11
24572 ,P_EXCLD_FLAG => r_EEG.INFORMATION12
24573 ,P_ORDR_NUM => r_EEG.INFORMATION261
24574 ,P_PGM_ID => l_PGM_ID
24575 --
24576 -- ****** END CHANGE LINES
24577
24578 --
24579 ,P_EFFECTIVE_START_DATE => l_effective_start_date
24580 ,P_EFFECTIVE_END_DATE => l_effective_end_date
24581 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24582 ,P_DATETRACK_MODE => l_datetrack_mode
24583 );
24584 end if; -- l_update
24585 --
24586 end if;
24587 --
24588 -- Delete the row if it is end dated.
24589 --
24590 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
24591 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
24592 trunc(l_max_eed) = trunc(r_EEG.information3)) then
24593 --
24594 BEN_ELIG_ENRLD_ANTHR_PGM_API.delete_ELIG_ENRLD_ANTHR_PGM(
24595 --
24596 p_validate => false
24597 ,p_elig_enrld_anthr_pgm_id => l_elig_enrld_anthr_pgm_id
24598 ,p_effective_start_date => l_effective_start_date
24599 ,p_effective_end_date => l_effective_end_date
24600 ,p_object_version_number => l_object_version_number
24601 ,p_effective_date => l_max_eed
24602 ,p_datetrack_mode => hr_api.g_delete
24603 --
24604 );
24605 --
24606 end if;
24607 --
24608 l_prev_pk_id := l_current_pk_id ;
24609 --
24610 end if;
24611 --
24612 end if;
24613 --
24614 end loop;
24615 --
24616 exception when others then
24617 --
24618 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EEG',r_EEG.information5 ) ;
24619 --
24620 end create_EEG_rows;
24621
24622 --
24623 ---------------------------------------------------------------
24624 ----------------------< create_EAI_rows >-----------------------
24625 ---------------------------------------------------------------
24626 --
24627 procedure create_EAI_rows
24628 (
24629 p_validate in number default 0
24630 ,p_copy_entity_txn_id in number
24631 ,p_effective_date in date
24632 ,p_prefix_suffix_text in varchar2 default null
24633 ,p_reuse_object_flag in varchar2 default null
24634 ,p_target_business_group_id in varchar2 default null
24635 ,p_prefix_suffix_cd in varchar2 default null
24636 ) is
24637 --
24638 l_ELIGY_PRFL_ID number;
24639 l_PLIP_ID number;
24640 cursor c_unique_EAI(l_table_alias varchar2) is
24641 select distinct cpe.information1,
24642 cpe.information2,
24643 cpe.information3,
24644 cpe.table_route_id
24645 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
24646 pqh_table_route tr
24647 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24648 and cpe.table_route_id = tr.table_route_id
24649 -- and tr.where_clause = l_BEN_ELIG_ENRLD_ANTHR_PLIP_F
24650 and tr.table_alias = l_table_alias
24651 and cpe.number_of_copies = 1 -- ADDITION
24652 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
24653 order by information1, information2; --added for bug: 5151945
24654 --
24655 --
24656 cursor c_EAI_min_max_dates(c_table_route_id number,
24657 c_information1 number) is
24658 select
24659 min(cpe.information2) min_esd,
24660 max(cpe.information3) min_eed
24661 from ben_copy_entity_results cpe
24662 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24663 and cpe.table_route_id = c_table_route_id
24664 and cpe.information1 = c_information1 ;
24665 --
24666 cursor c_EAI(c_table_route_id number,
24667 c_information1 number,
24668 c_information2 date,
24669 c_information3 date ) is
24670 select
24671 cpe.*
24672 from ben_copy_entity_results cpe
24673 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24674 and cpe.table_route_id = c_table_route_id
24675 and cpe.information1 = c_information1
24676 and cpe.information2 = c_information2
24677 and cpe.information3 = c_information3
24678 and rownum = 1 ;
24679 -- Date Track target record
24680 cursor c_find_EAI_in_target(
24681 c_effective_start_date date,
24682 c_effective_end_date date,
24683 c_business_group_id number,
24684 c_new_pk_id number) is
24685 select
24686 EAI.elig_enrld_anthr_plip_id new_value
24687 from BEN_ELIG_ENRLD_ANTHR_PLIP_F EAI
24688 where
24689 EAI.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
24690 EAI.PLIP_ID = l_PLIP_ID and
24691 EAI.business_group_id = c_business_group_id
24692 and EAI.elig_enrld_anthr_plip_id <> c_new_pk_id
24693 and c_effective_start_date between effective_start_date
24694 and effective_end_date ;
24695 --END TEMPIK
24696 /*TEMPIK
24697 and exists ( select null
24698 from BEN_ELIG_ENRLD_ANTHR_PLIP_F EAI1
24699 where
24700 EAI1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
24701 EAI1.PLIP_ID = l_PLIP_ID and
24702 EAI1.business_group_id = c_business_group_id
24703 and EAI1.effective_start_date <= c_effective_start_date )
24704 and exists ( select null
24705 from BEN_ELIG_ENRLD_ANTHR_PLIP_F EAI2
24706 where
24707 EAI2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
24708 EAI2.PLIP_ID = l_PLIP_ID and
24709 EAI2.business_group_id = c_business_group_id
24710 and EAI2.effective_end_date >= c_effective_end_date )
24711 ;
24712 TEMPIK */
24713 --TEMPIK
24714 l_dt_rec_found boolean ;
24715 --END TEMPIK
24716 --
24717
24718 --UPD START
24719 --
24720 l_update boolean := false ;
24721 l_datetrack_mode varchar2(80) := hr_api.g_update;
24722 l_process_date date;
24723 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
24724 --
24725 --UPD END
24726 l_current_pk_id number := null ;
24727
24728 l_prev_pk_id number := null ;
24729 l_first_rec boolean := true ;
24730 r_EAI c_EAI%rowtype;
24731 l_elig_enrld_anthr_plip_id number ;
24732 l_object_version_number number ;
24733 l_effective_start_date date ;
24734 l_effective_end_date date ;
24735 l_prefix pqh_copy_entity_attribs.information1%type := null;
24736 l_suffix pqh_copy_entity_attribs.information1%type := null;
24737 l_new_value number(15);
24738 l_object_found_in_target boolean := false ;
24739 l_min_esd date;
24740 l_max_eed date;
24741 l_effective_date date;
24742 --
24743 begin
24744 -- Initialization
24745 l_object_found_in_target := false ;
24746 -- End Initialization
24747 -- Derive the prefix - sufix
24748 if p_prefix_suffix_cd = 'PREFIX' then
24749 l_prefix := p_prefix_suffix_text ;
24750 elsif p_prefix_suffix_cd = 'SUFFIX' then
24751 l_suffix := p_prefix_suffix_text ;
24752 else
24753 l_prefix := null ;
24754 l_suffix := null ;
24755 end if ;
24756 -- End Prefix Sufix derivation
24757 for r_EAI_unique in c_unique_EAI('EAI') loop
24758
24759 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
24760 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24761 r_EAI_unique.information3 >=
24762 ben_pd_copy_to_ben_one.g_copy_effective_date)
24763 ) then
24764 --
24765 hr_utility.set_location(' r_EAI_unique.table_route_id '||r_EAI_unique.table_route_id,10);
24766 hr_utility.set_location(' r_EAI_unique.information1 '||r_EAI_unique.information1,10);
24767 hr_utility.set_location( 'r_EAI_unique.information2 '||r_EAI_unique.information2,10);
24768 hr_utility.set_location( 'r_EAI_unique.information3 '||r_EAI_unique.information3,10);
24769 -- If reuse objects flag is 'Y' then check for the object in the target business group
24770 -- if found insert the record into PLSql table and exit the loop else try create the
24771 -- object in the target business group
24772 --
24773 l_object_found_in_target := false ;
24774 --UPD START
24775 l_update := false;
24776 l_process_date := p_effective_date;
24777 l_dml_operation:= r_EAI_unique.dml_operation ;
24778 --
24779 /**********************moved from below **********************/
24780 open c_EAI(r_EAI_unique.table_route_id,
24781 r_EAI_unique.information1,
24782 r_EAI_unique.information2,
24783 r_EAI_unique.information3 ) ;
24784 --
24785 fetch c_EAI into r_EAI ;
24786 --
24787 close c_EAI ;
24788 --
24789 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EAI.INFORMATION263,l_dml_operation);
24790
24791 -- Only For Use by Create Wizard - Same Business Group
24792 l_PLIP_ID := NVL(get_fk('PLIP_ID', r_EAI.INFORMATION256,l_dml_operation),
24793 r_EAI.INFORMATION256);
24794 /**********************************************************/
24795
24796 if l_dml_operation = 'UPDATE' then
24797 --
24798 l_object_found_in_target := TRUE;
24799 --
24800 if l_process_date between r_EAI_unique.information2 and r_EAI_unique.information3 then
24801 l_update := true;
24802 if r_EAI_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
24803 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ENRLD_ANTHR_PLIP_ID' then
24804 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_PLIP_ID' ;
24805 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EAI_unique.information1 ;
24806 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EAI_unique.information1 ;
24807 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
24808 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EAI_unique.table_route_id;
24809 --
24810 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
24811 --
24812 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24813 --
24814 -- log_data('EAI',l_new_value,l_prefix || r_EAI_unique.name|| l_suffix,'REUSED');
24815 --
24816 end if ;
24817 hr_utility.set_location( 'found record for update',10);
24818 --
24819 else
24820 --
24821 l_update := false;
24822 --
24823 end if;
24824 else
24825 --
24826 --UPD END
24827 l_min_esd := null ;
24828 l_max_eed := null ;
24829 open c_EAI_min_max_dates(r_EAI_unique.table_route_id, r_EAI_unique.information1 ) ;
24830 fetch c_EAI_min_max_dates into l_min_esd,l_max_eed ;
24831 --
24832
24833 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24834 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
24835 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
24836 end if;
24837 l_min_esd := greatest(l_min_esd,r_EAI_unique.information2);
24838 /**********************moved up from here **********************
24839 open c_EAI(r_EAI_unique.table_route_id,
24840 r_EAI_unique.information1,
24841 r_EAI_unique.information2,
24842 r_EAI_unique.information3 ) ;
24843 --
24844 fetch c_EAI into r_EAI ;
24845 --
24846 close c_EAI ;
24847 --
24848 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EAI.INFORMATION263,l_dml_operation);
24849
24850 -- Only For Use by Create Wizard - Same Business Group
24851 l_PLIP_ID := NVL(get_fk('PLIP_ID', r_EAI.INFORMATION256,l_dml_operation),
24852 r_EAI.INFORMATION256);
24853 **********************************************************/
24854
24855 if p_reuse_object_flag = 'Y' then
24856 if c_EAI_min_max_dates%found then
24857 -- cursor to find the object
24858 open c_find_EAI_in_target( l_min_esd,l_max_eed,
24859 p_target_business_group_id, nvl(l_elig_enrld_anthr_plip_id, -999) ) ;
24860 fetch c_find_EAI_in_target into l_new_value ;
24861 if c_find_EAI_in_target%found then
24862 --
24863 --TEMPIK
24864 l_dt_rec_found := dt_api.check_min_max_dates
24865 (p_base_table_name => 'BEN_ELIG_ENRLD_ANTHR_PLIP_F',
24866 p_base_key_column => 'ELIG_ENRLD_ANTHR_PLIP_ID',
24867 p_base_key_value => l_new_value,
24868 p_from_date => l_min_esd,
24869 p_to_date => l_max_eed );
24870 if l_dt_rec_found THEN
24871 --END TEMPIK
24872 if r_EAI_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
24873 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ENRLD_ANTHR_PLIP_ID' then
24874 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_PLIP_ID' ;
24875 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EAI_unique.information1 ;
24876 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
24877 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
24878 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EAI_unique.table_route_id;
24879 --
24880 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
24881 --
24882 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24883 end if ;
24884 --
24885 l_object_found_in_target := true ;
24886 --TEMPIK
24887 end if; -- l_dt_rec_found
24888 --END TEMPIK
24889 end if;
24890 close c_find_EAI_in_target ;
24891 --
24892 end if;
24893 end if ;
24894 --
24895 close c_EAI_min_max_dates ;
24896 end if; --if p_dml_operation
24897 --
24898 if not l_object_found_in_target OR l_update then
24899
24900 --
24901 l_current_pk_id := r_EAI.information1;
24902 --
24903 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
24904 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
24905 --
24906 if l_current_pk_id = l_prev_pk_id then
24907 --
24908 l_first_rec := false ;
24909 --
24910 else
24911 --
24912 l_first_rec := true ;
24913 --
24914 end if ;
24915 --
24916
24917 l_effective_date := r_EAI.information2;
24918 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24919 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
24920 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
24921 end if;
24922
24923 if l_first_rec and not l_update then
24924 -- Call Create routine.
24925 hr_utility.set_location(' BEN_ELIG_ENRLD_ANTHR_PLIP_F CREATE_ELIG_ENRLD_ANTHR_PLIP ',20);
24926 BEN_ELIG_ENRLD_ANTHR_PLIP_API.CREATE_ELIG_ENRLD_ANTHR_PLIP(
24927 --
24928 P_VALIDATE => false
24929 ,P_EFFECTIVE_DATE => l_effective_date
24930 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24931 --
24932 ,P_EAI_ATTRIBUTE1 => r_EAI.INFORMATION111
24933 ,P_EAI_ATTRIBUTE10 => r_EAI.INFORMATION120
24934 ,P_EAI_ATTRIBUTE11 => r_EAI.INFORMATION121
24935 ,P_EAI_ATTRIBUTE12 => r_EAI.INFORMATION122
24936 ,P_EAI_ATTRIBUTE13 => r_EAI.INFORMATION123
24937 ,P_EAI_ATTRIBUTE14 => r_EAI.INFORMATION124
24938 ,P_EAI_ATTRIBUTE15 => r_EAI.INFORMATION125
24939 ,P_EAI_ATTRIBUTE16 => r_EAI.INFORMATION126
24940 ,P_EAI_ATTRIBUTE17 => r_EAI.INFORMATION127
24941 ,P_EAI_ATTRIBUTE18 => r_EAI.INFORMATION128
24942 ,P_EAI_ATTRIBUTE19 => r_EAI.INFORMATION129
24943 ,P_EAI_ATTRIBUTE2 => r_EAI.INFORMATION112
24944 ,P_EAI_ATTRIBUTE20 => r_EAI.INFORMATION130
24945 ,P_EAI_ATTRIBUTE21 => r_EAI.INFORMATION131
24946 ,P_EAI_ATTRIBUTE22 => r_EAI.INFORMATION132
24947 ,P_EAI_ATTRIBUTE23 => r_EAI.INFORMATION133
24948 ,P_EAI_ATTRIBUTE24 => r_EAI.INFORMATION134
24949 ,P_EAI_ATTRIBUTE25 => r_EAI.INFORMATION135
24950 ,P_EAI_ATTRIBUTE26 => r_EAI.INFORMATION136
24951 ,P_EAI_ATTRIBUTE27 => r_EAI.INFORMATION137
24952 ,P_EAI_ATTRIBUTE28 => r_EAI.INFORMATION138
24953 ,P_EAI_ATTRIBUTE29 => r_EAI.INFORMATION139
24954 ,P_EAI_ATTRIBUTE3 => r_EAI.INFORMATION113
24955 ,P_EAI_ATTRIBUTE30 => r_EAI.INFORMATION140
24956 ,P_EAI_ATTRIBUTE4 => r_EAI.INFORMATION114
24957 ,P_EAI_ATTRIBUTE5 => r_EAI.INFORMATION115
24958 ,P_EAI_ATTRIBUTE6 => r_EAI.INFORMATION116
24959 ,P_EAI_ATTRIBUTE7 => r_EAI.INFORMATION117
24960 ,P_EAI_ATTRIBUTE8 => r_EAI.INFORMATION118
24961 ,P_EAI_ATTRIBUTE9 => r_EAI.INFORMATION119
24962 ,P_EAI_ATTRIBUTE_CATEGORY => r_EAI.INFORMATION110
24963 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
24964 ,P_ELIG_ENRLD_ANTHR_PLIP_ID => l_elig_enrld_anthr_plip_id
24965 ,P_ENRL_DET_DT_CD => r_EAI.INFORMATION12
24966 ,P_EXCLD_FLAG => r_EAI.INFORMATION11
24967 ,P_ORDR_NUM => r_EAI.INFORMATION260
24968 ,P_PLIP_ID => l_PLIP_ID
24969 --
24970 -- ****** END CHANGE LINES
24971
24972 --
24973
24974 ,P_EFFECTIVE_START_DATE => l_effective_start_date
24975 ,P_EFFECTIVE_END_DATE => l_effective_end_date
24976 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24977 );
24978 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24979 -- Update all relevent cer records with new pk_id
24980 hr_utility.set_location('Before plsql table ',222);
24981 hr_utility.set_location('new_value id '||l_elig_enrld_anthr_plip_id,222);
24982 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_PLIP_ID' ;
24983 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EAI.information1 ;
24984 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_ENRLD_ANTHR_PLIP_ID ;
24985 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
24986 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EAI_unique.table_route_id;
24987 hr_utility.set_location('After plsql table ',222);
24988 --
24989 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
24990 --
24991 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24992 --
24993 else
24994 --
24995 -- Call Update routine for the pk_id created in prev run .
24996 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24997 hr_utility.set_location(' BEN_ELIG_ENRLD_ANTHR_PLIP_F UPDATE_ELIG_ENRLD_ANTHR_PLIP ',30);
24998 --UPD START
24999 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
25000 --
25001 if l_update then
25002 --
25003 l_datetrack_mode := r_EAI.datetrack_mode ;
25004 --
25005 get_dt_modes(
25006 p_effective_date => l_process_date,
25007 p_effective_end_date => r_EAI.information3,
25008 p_effective_start_date => r_EAI.information2,
25009 p_dml_operation => r_EAI.dml_operation,
25010 p_datetrack_mode => l_datetrack_mode );
25011 -- p_update => l_update
25012 --
25013 l_effective_date := l_process_date;
25014 l_ELIG_ENRLD_ANTHR_PLIP_ID := r_EAI.information1;
25015 l_object_version_number := r_EAI.information265;
25016 --
25017 end if;
25018 --
25019 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
25020 --
25021 IF l_update OR l_dml_operation <> 'UPDATE' THEN
25022 --UPD END
25023
25024
25025 BEN_ELIG_ENRLD_ANTHR_PLIP_API.UPDATE_ELIG_ENRLD_ANTHR_PLIP(
25026 --
25027 P_VALIDATE => false
25028 ,P_EFFECTIVE_DATE => l_effective_date
25029 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25030 --
25031 ,P_EAI_ATTRIBUTE1 => r_EAI.INFORMATION111
25032 ,P_EAI_ATTRIBUTE10 => r_EAI.INFORMATION120
25033 ,P_EAI_ATTRIBUTE11 => r_EAI.INFORMATION121
25034 ,P_EAI_ATTRIBUTE12 => r_EAI.INFORMATION122
25035 ,P_EAI_ATTRIBUTE13 => r_EAI.INFORMATION123
25036 ,P_EAI_ATTRIBUTE14 => r_EAI.INFORMATION124
25037 ,P_EAI_ATTRIBUTE15 => r_EAI.INFORMATION125
25038 ,P_EAI_ATTRIBUTE16 => r_EAI.INFORMATION126
25039 ,P_EAI_ATTRIBUTE17 => r_EAI.INFORMATION127
25040 ,P_EAI_ATTRIBUTE18 => r_EAI.INFORMATION128
25041 ,P_EAI_ATTRIBUTE19 => r_EAI.INFORMATION129
25042 ,P_EAI_ATTRIBUTE2 => r_EAI.INFORMATION112
25043 ,P_EAI_ATTRIBUTE20 => r_EAI.INFORMATION130
25044 ,P_EAI_ATTRIBUTE21 => r_EAI.INFORMATION131
25045 ,P_EAI_ATTRIBUTE22 => r_EAI.INFORMATION132
25046 ,P_EAI_ATTRIBUTE23 => r_EAI.INFORMATION133
25047 ,P_EAI_ATTRIBUTE24 => r_EAI.INFORMATION134
25048 ,P_EAI_ATTRIBUTE25 => r_EAI.INFORMATION135
25049 ,P_EAI_ATTRIBUTE26 => r_EAI.INFORMATION136
25050 ,P_EAI_ATTRIBUTE27 => r_EAI.INFORMATION137
25051 ,P_EAI_ATTRIBUTE28 => r_EAI.INFORMATION138
25052 ,P_EAI_ATTRIBUTE29 => r_EAI.INFORMATION139
25053 ,P_EAI_ATTRIBUTE3 => r_EAI.INFORMATION113
25054 ,P_EAI_ATTRIBUTE30 => r_EAI.INFORMATION140
25055 ,P_EAI_ATTRIBUTE4 => r_EAI.INFORMATION114
25056 ,P_EAI_ATTRIBUTE5 => r_EAI.INFORMATION115
25057 ,P_EAI_ATTRIBUTE6 => r_EAI.INFORMATION116
25058 ,P_EAI_ATTRIBUTE7 => r_EAI.INFORMATION117
25059 ,P_EAI_ATTRIBUTE8 => r_EAI.INFORMATION118
25060 ,P_EAI_ATTRIBUTE9 => r_EAI.INFORMATION119
25061 ,P_EAI_ATTRIBUTE_CATEGORY => r_EAI.INFORMATION110
25062 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
25063 ,P_ELIG_ENRLD_ANTHR_PLIP_ID => l_elig_enrld_anthr_plip_id
25064 ,P_ENRL_DET_DT_CD => r_EAI.INFORMATION12
25065 ,P_EXCLD_FLAG => r_EAI.INFORMATION11
25066 ,P_ORDR_NUM => r_EAI.INFORMATION260
25067 ,P_PLIP_ID => l_PLIP_ID
25068 --
25069 -- ****** END CHANGE LINES
25070
25071 --
25072 ,P_EFFECTIVE_START_DATE => l_effective_start_date
25073 ,P_EFFECTIVE_END_DATE => l_effective_end_date
25074 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
25075 ,P_DATETRACK_MODE => l_datetrack_mode
25076 );
25077 end if; -- l_update
25078 --
25079 end if;
25080 --
25081 -- Delete the row if it is end dated.
25082 --
25083 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
25084 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
25085 trunc(l_max_eed) = trunc(r_EAI.information3)) then
25086 --
25087 BEN_ELIG_ENRLD_ANTHR_PLIP_API.delete_ELIG_ENRLD_ANTHR_PLIP(
25088 --
25089 p_validate => false
25090 ,p_elig_enrld_anthr_plip_id => l_elig_enrld_anthr_plip_id
25091 ,p_effective_start_date => l_effective_start_date
25092 ,p_effective_end_date => l_effective_end_date
25093 ,p_object_version_number => l_object_version_number
25094 ,p_effective_date => l_max_eed
25095 ,p_datetrack_mode => hr_api.g_delete
25096 --
25097 );
25098 --
25099 end if;
25100 --
25101 l_prev_pk_id := l_current_pk_id ;
25102 --
25103 end if;
25104 --
25105 end if;
25106 --
25107 end loop;
25108 --
25109 exception when others then
25110 --
25111 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EAI',r_EAI.information5 ) ;
25112 --
25113 end create_EAI_rows;
25114
25115 --
25116 ---------------------------------------------------------------
25117 ----------------------< create_EEP_rows >-----------------------
25118 ---------------------------------------------------------------
25119 --
25120 procedure create_EEP_rows
25121 (
25122 p_validate in number default 0
25123 ,p_copy_entity_txn_id in number
25124 ,p_effective_date in date
25125 ,p_prefix_suffix_text in varchar2 default null
25126 ,p_reuse_object_flag in varchar2 default null
25127 ,p_target_business_group_id in varchar2 default null
25128 ,p_prefix_suffix_cd in varchar2 default null
25129 ) is
25130 --
25131 l_ELIGY_PRFL_ID number;
25132 l_PL_ID number;
25133 cursor c_unique_EEP(l_table_alias varchar2) is
25134 select distinct cpe.information1,
25135 cpe.information2,
25136 cpe.information3,
25137 cpe.table_route_id
25138 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
25139 pqh_table_route tr
25140 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25141 and cpe.table_route_id = tr.table_route_id
25142 -- and tr.where_clause = l_BEN_ELIG_ENRLD_ANTHR_PL_F
25143 and tr.table_alias = l_table_alias
25144 and cpe.number_of_copies = 1 -- ADDITION
25145 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
25146 order by information1, information2; --added for bug: 5151945
25147 --
25148 --
25149 cursor c_EEP_min_max_dates(c_table_route_id number,
25150 c_information1 number) is
25151 select
25152 min(cpe.information2) min_esd,
25153 max(cpe.information3) min_eed
25154 from ben_copy_entity_results cpe
25155 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25156 and cpe.table_route_id = c_table_route_id
25157 and cpe.information1 = c_information1 ;
25158 --
25159 cursor c_EEP(c_table_route_id number,
25160 c_information1 number,
25161 c_information2 date,
25162 c_information3 date ) is
25163 select
25164 cpe.*
25165 from ben_copy_entity_results cpe
25166 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25167 and cpe.table_route_id = c_table_route_id
25168 and cpe.information1 = c_information1
25169 and cpe.information2 = c_information2
25170 and cpe.information3 = c_information3
25171 and rownum = 1 ;
25172 -- Date Track target record
25173 cursor c_find_EEP_in_target(
25174 c_effective_start_date date,
25175 c_effective_end_date date,
25176 c_business_group_id number,
25177 c_new_pk_id number) is
25178 select
25179 EEP.elig_enrld_anthr_pl_id new_value
25180 from BEN_ELIG_ENRLD_ANTHR_PL_F EEP
25181 where
25182 EEP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
25183 EEP.PL_ID = l_PL_ID and
25184 EEP.business_group_id = c_business_group_id
25185 and EEP.elig_enrld_anthr_pl_id <> c_new_pk_id
25186 and c_effective_start_date between effective_start_date
25187 and effective_end_date ;
25188 --END TEMPIK
25189 /*TEMPIK
25190 and exists ( select null
25191 from BEN_ELIG_ENRLD_ANTHR_PL_F EEP1
25192 where
25193 EEP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
25194 EEP1.PL_ID = l_PL_ID and
25195 EEP1.business_group_id = c_business_group_id
25196 and EEP1.effective_start_date <= c_effective_start_date )
25197 and exists ( select null
25198 from BEN_ELIG_ENRLD_ANTHR_PL_F EEP2
25199 where
25200 EEP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
25201 EEP2.PL_ID = l_PL_ID and
25202 EEP2.business_group_id = c_business_group_id
25203 and EEP2.effective_end_date >= c_effective_end_date )
25204 ;
25205 TEMPIK */
25206 --TEMPIK
25207 l_dt_rec_found boolean ;
25208 --END TEMPIK
25209 --
25210
25211 --UPD START
25212 --
25213 l_update boolean := false ;
25214 l_datetrack_mode varchar2(80) := hr_api.g_update;
25215 l_process_date date;
25216 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
25217 --
25218 --UPD END
25219 l_current_pk_id number := null ;
25220
25221 l_prev_pk_id number := null ;
25222 l_first_rec boolean := true ;
25223 r_EEP c_EEP%rowtype;
25224 l_elig_enrld_anthr_pl_id number ;
25225 l_object_version_number number ;
25226 l_effective_start_date date ;
25227 l_effective_end_date date ;
25228 l_prefix pqh_copy_entity_attribs.information1%type := null;
25229 l_suffix pqh_copy_entity_attribs.information1%type := null;
25230 l_new_value number(15);
25231 l_object_found_in_target boolean := false ;
25232 l_min_esd date;
25233 l_max_eed date;
25234 l_effective_date date;
25235 --
25236 begin
25237 -- Initialization
25238 l_object_found_in_target := false ;
25239 -- End Initialization
25240 -- Derive the prefix - sufix
25241 if p_prefix_suffix_cd = 'PREFIX' then
25242 l_prefix := p_prefix_suffix_text ;
25243 elsif p_prefix_suffix_cd = 'SUFFIX' then
25244 l_suffix := p_prefix_suffix_text ;
25245 else
25246 l_prefix := null ;
25247 l_suffix := null ;
25248 end if ;
25249 -- End Prefix Sufix derivation
25250 for r_EEP_unique in c_unique_EEP('EEP') loop
25251
25252 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
25253 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25254 r_EEP_unique.information3 >=
25255 ben_pd_copy_to_ben_one.g_copy_effective_date)
25256 ) then
25257 --
25258 hr_utility.set_location(' r_EEP_unique.table_route_id '||r_EEP_unique.table_route_id,10);
25259 hr_utility.set_location(' r_EEP_unique.information1 '||r_EEP_unique.information1,10);
25260 hr_utility.set_location( 'r_EEP_unique.information2 '||r_EEP_unique.information2,10);
25261 hr_utility.set_location( 'r_EEP_unique.information3 '||r_EEP_unique.information3,10);
25262 -- If reuse objects flag is 'Y' then check for the object in the target business group
25263 -- if found insert the record into PLSql table and exit the loop else try create the
25264 -- object in the target business group
25265 --
25266 l_object_found_in_target := false ;
25267 --UPD START
25268 l_update := false;
25269 l_process_date := p_effective_date;
25270 l_dml_operation:= r_EEP_unique.dml_operation ;
25271 --
25272 /**********************moved from below **********************/
25273 open c_EEP(r_EEP_unique.table_route_id,
25274 r_EEP_unique.information1,
25275 r_EEP_unique.information2,
25276 r_EEP_unique.information3 ) ;
25277 --
25278 fetch c_EEP into r_EEP ;
25279 --
25280 close c_EEP ;
25281 --
25282 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EEP.INFORMATION263,l_dml_operation);
25283
25284 l_PL_ID := NVL(get_fk('PL_ID', r_EEP.INFORMATION261,l_dml_operation),
25285 r_EEP.INFORMATION261);
25286 /**********************************************************/
25287
25288 if l_dml_operation = 'UPDATE' then
25289 --
25290 l_object_found_in_target := TRUE;
25291 --
25292 if l_process_date between r_EEP_unique.information2 and r_EEP_unique.information3 then
25293 l_update := true;
25294 if r_EEP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
25295 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ENRLD_ANTHR_PL_ID' then
25296 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_PL_ID' ;
25297 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EEP_unique.information1 ;
25298 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EEP_unique.information1 ;
25299 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
25300 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EEP_unique.table_route_id;
25301 --
25302 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
25303 --
25304 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25305 --
25306 -- log_data('EEP',l_new_value,l_prefix || r_EEP_unique.name|| l_suffix,'REUSED');
25307 --
25308 end if ;
25309 hr_utility.set_location( 'found record for update',10);
25310 --
25311 else
25312 --
25313 l_update := false;
25314 --
25315 end if;
25316 else
25317 --
25318 --UPD END
25319 l_min_esd := null ;
25320 l_max_eed := null ;
25321 open c_EEP_min_max_dates(r_EEP_unique.table_route_id, r_EEP_unique.information1 ) ;
25322 fetch c_EEP_min_max_dates into l_min_esd,l_max_eed ;
25323 --
25324
25325 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25326 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
25327 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
25328 end if;
25329 l_min_esd := greatest(l_min_esd,r_EEP_unique.information2);
25330 /**********************moved up from here **********************
25331 open c_EEP(r_EEP_unique.table_route_id,
25332 r_EEP_unique.information1,
25333 r_EEP_unique.information2,
25334 r_EEP_unique.information3 ) ;
25335 --
25336 fetch c_EEP into r_EEP ;
25337 --
25338 close c_EEP ;
25339 --
25340 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EEP.INFORMATION263,l_dml_operation);
25341
25342 l_PL_ID := NVL(get_fk('PL_ID', r_EEP.INFORMATION261,l_dml_operation),
25343 r_EEP.INFORMATION261);
25344 **********************************************************/
25345
25346 if p_reuse_object_flag = 'Y' then
25347 if c_EEP_min_max_dates%found then
25348 -- cursor to find the object
25349 open c_find_EEP_in_target( l_min_esd,l_max_eed,
25350 p_target_business_group_id, nvl(l_elig_enrld_anthr_pl_id, -999) ) ;
25351 fetch c_find_EEP_in_target into l_new_value ;
25352 if c_find_EEP_in_target%found then
25353 --
25354 --TEMPIK
25355 l_dt_rec_found := dt_api.check_min_max_dates
25356 (p_base_table_name => 'BEN_ELIG_ENRLD_ANTHR_PL_F',
25357 p_base_key_column => 'ELIG_ENRLD_ANTHR_PL_ID',
25358 p_base_key_value => l_new_value,
25359 p_from_date => l_min_esd,
25360 p_to_date => l_max_eed );
25361 if l_dt_rec_found THEN
25362 --END TEMPIK
25363 if r_EEP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
25364 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ENRLD_ANTHR_PL_ID' then
25365 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_PL_ID' ;
25366 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EEP_unique.information1 ;
25367 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
25368 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
25369 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EEP_unique.table_route_id;
25370 --
25371 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
25372 --
25373 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25374 end if ;
25375 --
25376 l_object_found_in_target := true ;
25377 --TEMPIK
25378 end if; -- l_dt_rec_found
25379 --END TEMPIK
25380 end if;
25381 close c_find_EEP_in_target ;
25382 --
25383 end if;
25384 end if ;
25385 --
25386 close c_EEP_min_max_dates ;
25387 end if; --if p_dml_operation
25388 --
25389 if not l_object_found_in_target OR l_update then
25390
25391 --
25392 l_current_pk_id := r_EEP.information1;
25393 --
25394 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
25395 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
25396 --
25397 if l_current_pk_id = l_prev_pk_id then
25398 --
25399 l_first_rec := false ;
25400 --
25401 else
25402 --
25403 l_first_rec := true ;
25404 --
25405 end if ;
25406 --
25407
25408 l_effective_date := r_EEP.information2;
25409 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25410 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
25411 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
25412 end if;
25413
25414 if l_first_rec and not l_update then
25415 -- Call Create routine.
25416 hr_utility.set_location(' BEN_ELIG_ENRLD_ANTHR_PL_F CREATE_ELIG_ENRLD_ANTHR_PL ',20);
25417 BEN_ELIG_ENRLD_ANTHR_PL_API.CREATE_ELIG_ENRLD_ANTHR_PL(
25418 --
25419 P_VALIDATE => false
25420 ,P_EFFECTIVE_DATE => l_effective_date
25421 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25422 --
25423 ,P_EEP_ATTRIBUTE1 => r_EEP.INFORMATION111
25424 ,P_EEP_ATTRIBUTE10 => r_EEP.INFORMATION120
25425 ,P_EEP_ATTRIBUTE11 => r_EEP.INFORMATION121
25426 ,P_EEP_ATTRIBUTE12 => r_EEP.INFORMATION122
25427 ,P_EEP_ATTRIBUTE13 => r_EEP.INFORMATION123
25428 ,P_EEP_ATTRIBUTE14 => r_EEP.INFORMATION124
25429 ,P_EEP_ATTRIBUTE15 => r_EEP.INFORMATION125
25430 ,P_EEP_ATTRIBUTE16 => r_EEP.INFORMATION126
25431 ,P_EEP_ATTRIBUTE17 => r_EEP.INFORMATION127
25432 ,P_EEP_ATTRIBUTE18 => r_EEP.INFORMATION128
25433 ,P_EEP_ATTRIBUTE19 => r_EEP.INFORMATION129
25434 ,P_EEP_ATTRIBUTE2 => r_EEP.INFORMATION112
25435 ,P_EEP_ATTRIBUTE20 => r_EEP.INFORMATION130
25436 ,P_EEP_ATTRIBUTE21 => r_EEP.INFORMATION131
25437 ,P_EEP_ATTRIBUTE22 => r_EEP.INFORMATION132
25438 ,P_EEP_ATTRIBUTE23 => r_EEP.INFORMATION133
25439 ,P_EEP_ATTRIBUTE24 => r_EEP.INFORMATION134
25440 ,P_EEP_ATTRIBUTE25 => r_EEP.INFORMATION135
25441 ,P_EEP_ATTRIBUTE26 => r_EEP.INFORMATION136
25442 ,P_EEP_ATTRIBUTE27 => r_EEP.INFORMATION137
25443 ,P_EEP_ATTRIBUTE28 => r_EEP.INFORMATION138
25444 ,P_EEP_ATTRIBUTE29 => r_EEP.INFORMATION139
25445 ,P_EEP_ATTRIBUTE3 => r_EEP.INFORMATION113
25446 ,P_EEP_ATTRIBUTE30 => r_EEP.INFORMATION140
25447 ,P_EEP_ATTRIBUTE4 => r_EEP.INFORMATION114
25448 ,P_EEP_ATTRIBUTE5 => r_EEP.INFORMATION115
25449 ,P_EEP_ATTRIBUTE6 => r_EEP.INFORMATION116
25450 ,P_EEP_ATTRIBUTE7 => r_EEP.INFORMATION117
25451 ,P_EEP_ATTRIBUTE8 => r_EEP.INFORMATION118
25452 ,P_EEP_ATTRIBUTE9 => r_EEP.INFORMATION119
25453 ,P_EEP_ATTRIBUTE_CATEGORY => r_EEP.INFORMATION110
25454 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
25455 ,P_ELIG_ENRLD_ANTHR_PL_ID => l_elig_enrld_anthr_pl_id
25456 ,P_ENRL_DET_DT_CD => r_EEP.INFORMATION11
25457 ,P_EXCLD_FLAG => r_EEP.INFORMATION12
25458 ,P_ORDR_NUM => r_EEP.INFORMATION260
25459 ,P_PL_ID => l_PL_ID
25460 --
25461 -- ****** END CHANGE LINES
25462
25463 --
25464
25465 ,P_EFFECTIVE_START_DATE => l_effective_start_date
25466 ,P_EFFECTIVE_END_DATE => l_effective_end_date
25467 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
25468 );
25469 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
25470 -- Update all relevent cer records with new pk_id
25471 hr_utility.set_location('Before plsql table ',222);
25472 hr_utility.set_location('new_value id '||l_elig_enrld_anthr_pl_id,222);
25473 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_PL_ID' ;
25474 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EEP.information1 ;
25475 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_ENRLD_ANTHR_PL_ID ;
25476 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
25477 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EEP_unique.table_route_id;
25478 hr_utility.set_location('After plsql table ',222);
25479 --
25480 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
25481 --
25482 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25483 --
25484 else
25485 --
25486 -- Call Update routine for the pk_id created in prev run .
25487 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
25488 hr_utility.set_location(' BEN_ELIG_ENRLD_ANTHR_PL_F UPDATE_ELIG_ENRLD_ANTHR_PL ',30);
25489 --UPD START
25490 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
25491 --
25492 if l_update then
25493 --
25494 l_datetrack_mode := r_EEP.datetrack_mode ;
25495 --
25496 get_dt_modes(
25497 p_effective_date => l_process_date,
25498 p_effective_end_date => r_EEP.information3,
25499 p_effective_start_date => r_EEP.information2,
25500 p_dml_operation => r_EEP.dml_operation,
25501 p_datetrack_mode => l_datetrack_mode );
25502 -- p_update => l_update
25503 --
25504 l_effective_date := l_process_date;
25505 l_ELIG_ENRLD_ANTHR_PL_ID := r_EEP.information1;
25506 l_object_version_number := r_EEP.information265;
25507 --
25508 end if;
25509 --
25510 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
25511 --
25512 IF l_update OR l_dml_operation <> 'UPDATE' THEN
25513 --UPD END
25514
25515
25516 BEN_ELIG_ENRLD_ANTHR_PL_API.UPDATE_ELIG_ENRLD_ANTHR_PL(
25517 --
25518 P_VALIDATE => false
25519 ,P_EFFECTIVE_DATE => l_effective_date
25520 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25521 --
25522 ,P_EEP_ATTRIBUTE1 => r_EEP.INFORMATION111
25523 ,P_EEP_ATTRIBUTE10 => r_EEP.INFORMATION120
25524 ,P_EEP_ATTRIBUTE11 => r_EEP.INFORMATION121
25525 ,P_EEP_ATTRIBUTE12 => r_EEP.INFORMATION122
25526 ,P_EEP_ATTRIBUTE13 => r_EEP.INFORMATION123
25527 ,P_EEP_ATTRIBUTE14 => r_EEP.INFORMATION124
25528 ,P_EEP_ATTRIBUTE15 => r_EEP.INFORMATION125
25529 ,P_EEP_ATTRIBUTE16 => r_EEP.INFORMATION126
25530 ,P_EEP_ATTRIBUTE17 => r_EEP.INFORMATION127
25531 ,P_EEP_ATTRIBUTE18 => r_EEP.INFORMATION128
25532 ,P_EEP_ATTRIBUTE19 => r_EEP.INFORMATION129
25533 ,P_EEP_ATTRIBUTE2 => r_EEP.INFORMATION112
25534 ,P_EEP_ATTRIBUTE20 => r_EEP.INFORMATION130
25535 ,P_EEP_ATTRIBUTE21 => r_EEP.INFORMATION131
25536 ,P_EEP_ATTRIBUTE22 => r_EEP.INFORMATION132
25537 ,P_EEP_ATTRIBUTE23 => r_EEP.INFORMATION133
25538 ,P_EEP_ATTRIBUTE24 => r_EEP.INFORMATION134
25539 ,P_EEP_ATTRIBUTE25 => r_EEP.INFORMATION135
25540 ,P_EEP_ATTRIBUTE26 => r_EEP.INFORMATION136
25541 ,P_EEP_ATTRIBUTE27 => r_EEP.INFORMATION137
25542 ,P_EEP_ATTRIBUTE28 => r_EEP.INFORMATION138
25543 ,P_EEP_ATTRIBUTE29 => r_EEP.INFORMATION139
25544 ,P_EEP_ATTRIBUTE3 => r_EEP.INFORMATION113
25545 ,P_EEP_ATTRIBUTE30 => r_EEP.INFORMATION140
25546 ,P_EEP_ATTRIBUTE4 => r_EEP.INFORMATION114
25547 ,P_EEP_ATTRIBUTE5 => r_EEP.INFORMATION115
25548 ,P_EEP_ATTRIBUTE6 => r_EEP.INFORMATION116
25549 ,P_EEP_ATTRIBUTE7 => r_EEP.INFORMATION117
25550 ,P_EEP_ATTRIBUTE8 => r_EEP.INFORMATION118
25551 ,P_EEP_ATTRIBUTE9 => r_EEP.INFORMATION119
25552 ,P_EEP_ATTRIBUTE_CATEGORY => r_EEP.INFORMATION110
25553 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
25554 ,P_ELIG_ENRLD_ANTHR_PL_ID => l_elig_enrld_anthr_pl_id
25555 ,P_ENRL_DET_DT_CD => r_EEP.INFORMATION11
25556 ,P_EXCLD_FLAG => r_EEP.INFORMATION12
25557 ,P_ORDR_NUM => r_EEP.INFORMATION260
25558 ,P_PL_ID => l_PL_ID
25559 --
25560 -- ****** END CHANGE LINES
25561
25562 --
25563 ,P_EFFECTIVE_START_DATE => l_effective_start_date
25564 ,P_EFFECTIVE_END_DATE => l_effective_end_date
25565 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
25566 ,P_DATETRACK_MODE => l_datetrack_mode
25567 );
25568 end if; -- l_update
25569 --
25570 end if;
25571 --
25572 -- Delete the row if it is end dated.
25573 --
25574 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
25575 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
25576 trunc(l_max_eed) = trunc(r_EEP.information3)) then
25577 --
25578 BEN_ELIG_ENRLD_ANTHR_PL_API.delete_ELIG_ENRLD_ANTHR_PL(
25579 --
25580 p_validate => false
25581 ,p_elig_enrld_anthr_pl_id => l_elig_enrld_anthr_pl_id
25582 ,p_effective_start_date => l_effective_start_date
25583 ,p_effective_end_date => l_effective_end_date
25584 ,p_object_version_number => l_object_version_number
25585 ,p_effective_date => l_max_eed
25586 ,p_datetrack_mode => hr_api.g_delete
25587 --
25588 );
25589 --
25590 end if;
25591 --
25592 l_prev_pk_id := l_current_pk_id ;
25593 --
25594 end if;
25595 --
25596 end if;
25597 --
25598 end loop;
25599 --
25600 exception when others then
25601 --
25602 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EEP',r_EEP.information5 ) ;
25603 --
25604 end create_EEP_rows;
25605
25606 --
25607 ---------------------------------------------------------------
25608 ----------------------< create_EET_rows >-----------------------
25609 ---------------------------------------------------------------
25610 --
25611 procedure create_EET_rows
25612 (
25613 p_validate in number default 0
25614 ,p_copy_entity_txn_id in number
25615 ,p_effective_date in date
25616 ,p_prefix_suffix_text in varchar2 default null
25617 ,p_reuse_object_flag in varchar2 default null
25618 ,p_target_business_group_id in varchar2 default null
25619 ,p_prefix_suffix_cd in varchar2 default null
25620 ) is
25621 --
25622 l_ELIGY_PRFL_ID number;
25623 l_PTIP_ID number;
25624 cursor c_unique_EET(l_table_alias varchar2) is
25625 select distinct cpe.information1,
25626 cpe.information2,
25627 cpe.information3,
25628 cpe.table_route_id
25629 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
25630 pqh_table_route tr
25631 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25632 and cpe.table_route_id = tr.table_route_id
25633 -- and tr.where_clause = l_BEN_ELIG_ENRLD_ANTHR_PTIP_F
25634 and tr.table_alias = l_table_alias
25635 and cpe.number_of_copies = 1 -- ADDITION
25636 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
25637 order by information1, information2; --added for bug: 5151945
25638 --
25639 --
25640 cursor c_EET_min_max_dates(c_table_route_id number,
25641 c_information1 number) is
25642 select
25643 min(cpe.information2) min_esd,
25644 max(cpe.information3) min_eed
25645 from ben_copy_entity_results cpe
25646 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25647 and cpe.table_route_id = c_table_route_id
25648 and cpe.information1 = c_information1 ;
25649 --
25650 cursor c_EET(c_table_route_id number,
25651 c_information1 number,
25652 c_information2 date,
25653 c_information3 date ) is
25654 select
25655 cpe.*
25656 from ben_copy_entity_results cpe
25657 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25658 and cpe.table_route_id = c_table_route_id
25659 and cpe.information1 = c_information1
25660 and cpe.information2 = c_information2
25661 and cpe.information3 = c_information3
25662 and rownum = 1 ;
25663 -- Date Track target record
25664 cursor c_find_EET_in_target(
25665 c_effective_start_date date,
25666 c_effective_end_date date,
25667 c_business_group_id number,
25668 c_new_pk_id number) is
25669 select
25670 EET.elig_enrld_anthr_ptip_id new_value
25671 from BEN_ELIG_ENRLD_ANTHR_PTIP_F EET
25672 where
25673 EET.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
25674 EET.PTIP_ID = l_PTIP_ID and
25675 EET.business_group_id = c_business_group_id
25676 and EET.elig_enrld_anthr_ptip_id <> c_new_pk_id
25677 and c_effective_start_date between effective_start_date
25678 and effective_end_date ;
25679 --END TEMPIK
25680 /*TEMPIK
25681 and exists ( select null
25682 from BEN_ELIG_ENRLD_ANTHR_PTIP_F EET1
25683 where
25684 EET1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
25685 EET1.PTIP_ID = l_PTIP_ID and
25686 EET1.business_group_id = c_business_group_id
25687 and EET1.effective_start_date <= c_effective_start_date )
25688 and exists ( select null
25689 from BEN_ELIG_ENRLD_ANTHR_PTIP_F EET2
25690 where
25691 EET2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
25692 EET2.PTIP_ID = l_PTIP_ID and
25693 EET2.business_group_id = c_business_group_id
25694 and EET2.effective_end_date >= c_effective_end_date )
25695 ;
25696 TEMPIK */
25697 --TEMPIK
25698 l_dt_rec_found boolean ;
25699 --END TEMPIK
25700 --
25701
25702 --UPD START
25703 --
25704 l_update boolean := false ;
25705 l_datetrack_mode varchar2(80) := hr_api.g_update;
25706 l_process_date date;
25707 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
25708 --
25709 --UPD END
25710 l_current_pk_id number := null ;
25711
25712 l_prev_pk_id number := null ;
25713 l_first_rec boolean := true ;
25714 r_EET c_EET%rowtype;
25715 l_elig_enrld_anthr_ptip_id number ;
25716 l_object_version_number number ;
25717 l_effective_start_date date ;
25718 l_effective_end_date date ;
25719 l_prefix pqh_copy_entity_attribs.information1%type := null;
25720 l_suffix pqh_copy_entity_attribs.information1%type := null;
25721 l_new_value number(15);
25722 l_object_found_in_target boolean := false ;
25723 l_min_esd date;
25724 l_max_eed date;
25725 l_effective_date date;
25726 --
25727 begin
25728 -- Initialization
25729 l_object_found_in_target := false ;
25730 -- End Initialization
25731 -- Derive the prefix - sufix
25732 if p_prefix_suffix_cd = 'PREFIX' then
25733 l_prefix := p_prefix_suffix_text ;
25734 elsif p_prefix_suffix_cd = 'SUFFIX' then
25735 l_suffix := p_prefix_suffix_text ;
25736 else
25737 l_prefix := null ;
25738 l_suffix := null ;
25739 end if ;
25740 -- End Prefix Sufix derivation
25741 for r_EET_unique in c_unique_EET('EET') loop
25742
25743 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
25744 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25745 r_EET_unique.information3 >=
25746 ben_pd_copy_to_ben_one.g_copy_effective_date)
25747 ) then
25748 --
25749 hr_utility.set_location(' r_EET_unique.table_route_id '||r_EET_unique.table_route_id,10);
25750 hr_utility.set_location(' r_EET_unique.information1 '||r_EET_unique.information1,10);
25751 hr_utility.set_location( 'r_EET_unique.information2 '||r_EET_unique.information2,10);
25752 hr_utility.set_location( 'r_EET_unique.information3 '||r_EET_unique.information3,10);
25753 -- If reuse objects flag is 'Y' then check for the object in the target business group
25754 -- if found insert the record into PLSql table and exit the loop else try create the
25755 -- object in the target business group
25756 --
25757 l_object_found_in_target := false ;
25758 --UPD START
25759 l_update := false;
25760 l_process_date := p_effective_date;
25761 l_dml_operation:= r_EET_unique.dml_operation ;
25762 --
25763 /**********************moved from below **********************/
25764 open c_EET(r_EET_unique.table_route_id,
25765 r_EET_unique.information1,
25766 r_EET_unique.information2,
25767 r_EET_unique.information3 ) ;
25768 --
25769 fetch c_EET into r_EET ;
25770 --
25771 close c_EET ;
25772 --
25773 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EET.INFORMATION263,l_dml_operation);
25774
25775 -- Only For Use by Create Wizard - Same Business Group
25776 l_PTIP_ID := NVL(get_fk('PTIP_ID', r_EET.INFORMATION259,l_dml_operation),
25777 r_EET.INFORMATION259);
25778
25779 /**********************************************************/
25780
25781 if l_dml_operation = 'UPDATE' then
25782 --
25783 l_object_found_in_target := TRUE;
25784 --
25785 if l_process_date between r_EET_unique.information2 and r_EET_unique.information3 then
25786 l_update := true;
25787 if r_EET_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
25788 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ENRLD_ANTHR_PTIP_ID' then
25789 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_PTIP_ID' ;
25790 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EET_unique.information1 ;
25791 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EET_unique.information1 ;
25792 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
25793 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EET_unique.table_route_id;
25794 --
25795 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
25796 --
25797 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25798 --
25799 -- log_data('EET',l_new_value,l_prefix || r_EET_unique.name|| l_suffix,'REUSED');
25800 --
25801 end if ;
25802 hr_utility.set_location( 'found record for update',10);
25803 --
25804 else
25805 --
25806 l_update := false;
25807 --
25808 end if;
25809 else
25810 --
25811 --UPD END
25812 l_min_esd := null ;
25813 l_max_eed := null ;
25814 open c_EET_min_max_dates(r_EET_unique.table_route_id, r_EET_unique.information1 ) ;
25815 fetch c_EET_min_max_dates into l_min_esd,l_max_eed ;
25816 --
25817
25818 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25819 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
25820 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
25821 end if;
25822 l_min_esd := greatest(l_min_esd,r_EET_unique.information2);
25823 /**********************moved up from here **********************
25824 open c_EET(r_EET_unique.table_route_id,
25825 r_EET_unique.information1,
25826 r_EET_unique.information2,
25827 r_EET_unique.information3 ) ;
25828 --
25829 fetch c_EET into r_EET ;
25830 --
25831 close c_EET ;
25832 --
25833 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EET.INFORMATION263,l_dml_operation);
25834
25835 -- Only For Use by Create Wizard - Same Business Group
25836 l_PTIP_ID := NVL(get_fk('PTIP_ID', r_EET.INFORMATION259,l_dml_operation),
25837 r_EET.INFORMATION259);
25838
25839 **********************************************************/
25840
25841
25842 if p_reuse_object_flag = 'Y' then
25843 if c_EET_min_max_dates%found then
25844 -- cursor to find the object
25845 open c_find_EET_in_target( l_min_esd,l_max_eed,
25846 p_target_business_group_id, nvl(l_elig_enrld_anthr_ptip_id, -999) ) ;
25847 fetch c_find_EET_in_target into l_new_value ;
25848 if c_find_EET_in_target%found then
25849 --
25850 --TEMPIK
25851 l_dt_rec_found := dt_api.check_min_max_dates
25852 (p_base_table_name => 'BEN_ELIG_ENRLD_ANTHR_PTIP_F',
25853 p_base_key_column => 'ELIG_ENRLD_ANTHR_PTIP_ID',
25854 p_base_key_value => l_new_value,
25855 p_from_date => l_min_esd,
25856 p_to_date => l_max_eed );
25857 if l_dt_rec_found THEN
25858 --END TEMPIK
25859 if r_EET_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
25860 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ENRLD_ANTHR_PTIP_ID' then
25861 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_PTIP_ID' ;
25862 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EET_unique.information1 ;
25863 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
25864 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
25865 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EET_unique.table_route_id;
25866 --
25867 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
25868 --
25869 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25870 end if ;
25871 --
25872 l_object_found_in_target := true ;
25873 --TEMPIK
25874 end if; -- l_dt_rec_found
25875 --END TEMPIK
25876 end if;
25877 close c_find_EET_in_target ;
25878 --
25879 end if;
25880 end if ;
25881 --
25882 close c_EET_min_max_dates ;
25883 end if; --if p_dml_operation
25884 --
25885 if not l_object_found_in_target OR l_update then
25886
25887 --
25888 l_current_pk_id := r_EET.information1;
25889 --
25890 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
25891 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
25892 --
25893 if l_current_pk_id = l_prev_pk_id then
25894 --
25895 l_first_rec := false ;
25896 --
25897 else
25898 --
25899 l_first_rec := true ;
25900 --
25901 end if ;
25902 --
25903
25904 l_effective_date := r_EET.information2;
25905 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25906 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
25907 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
25908 end if;
25909
25910 if l_first_rec and not l_update then
25911 -- Call Create routine.
25912 hr_utility.set_location(' BEN_ELIG_ENRLD_ANTHR_PTIP_F CREATE_ELIG_ENRLD_ANTHR_PTIP ',20);
25913 BEN_ELIG_ENRLD_ANTHR_PTIP_API.CREATE_ELIG_ENRLD_ANTHR_PTIP(
25914 --
25915 P_VALIDATE => false
25916 ,P_EFFECTIVE_DATE => l_effective_date
25917 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25918 --
25919 ,P_EET_ATTRIBUTE1 => r_EET.INFORMATION111
25920 ,P_EET_ATTRIBUTE10 => r_EET.INFORMATION120
25921 ,P_EET_ATTRIBUTE11 => r_EET.INFORMATION121
25922 ,P_EET_ATTRIBUTE12 => r_EET.INFORMATION122
25923 ,P_EET_ATTRIBUTE13 => r_EET.INFORMATION123
25924 ,P_EET_ATTRIBUTE14 => r_EET.INFORMATION124
25925 ,P_EET_ATTRIBUTE15 => r_EET.INFORMATION125
25926 ,P_EET_ATTRIBUTE16 => r_EET.INFORMATION126
25927 ,P_EET_ATTRIBUTE17 => r_EET.INFORMATION127
25928 ,P_EET_ATTRIBUTE18 => r_EET.INFORMATION128
25929 ,P_EET_ATTRIBUTE19 => r_EET.INFORMATION129
25930 ,P_EET_ATTRIBUTE2 => r_EET.INFORMATION112
25931 ,P_EET_ATTRIBUTE20 => r_EET.INFORMATION130
25932 ,P_EET_ATTRIBUTE21 => r_EET.INFORMATION131
25933 ,P_EET_ATTRIBUTE22 => r_EET.INFORMATION132
25934 ,P_EET_ATTRIBUTE23 => r_EET.INFORMATION133
25935 ,P_EET_ATTRIBUTE24 => r_EET.INFORMATION134
25936 ,P_EET_ATTRIBUTE25 => r_EET.INFORMATION135
25937 ,P_EET_ATTRIBUTE26 => r_EET.INFORMATION136
25938 ,P_EET_ATTRIBUTE27 => r_EET.INFORMATION137
25939 ,P_EET_ATTRIBUTE28 => r_EET.INFORMATION138
25940 ,P_EET_ATTRIBUTE29 => r_EET.INFORMATION139
25941 ,P_EET_ATTRIBUTE3 => r_EET.INFORMATION113
25942 ,P_EET_ATTRIBUTE30 => r_EET.INFORMATION140
25943 ,P_EET_ATTRIBUTE4 => r_EET.INFORMATION114
25944 ,P_EET_ATTRIBUTE5 => r_EET.INFORMATION115
25945 ,P_EET_ATTRIBUTE6 => r_EET.INFORMATION116
25946 ,P_EET_ATTRIBUTE7 => r_EET.INFORMATION117
25947 ,P_EET_ATTRIBUTE8 => r_EET.INFORMATION118
25948 ,P_EET_ATTRIBUTE9 => r_EET.INFORMATION119
25949 ,P_EET_ATTRIBUTE_CATEGORY => r_EET.INFORMATION110
25950 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
25951 ,P_ELIG_ENRLD_ANTHR_PTIP_ID => l_elig_enrld_anthr_ptip_id
25952 ,P_ENRL_DET_DT_CD => r_EET.INFORMATION13
25953 ,P_EXCLD_FLAG => r_EET.INFORMATION11
25954 ,P_ONLY_PLS_SUBJ_COBRA_FLAG => r_EET.INFORMATION12
25955 ,P_ORDR_NUM => r_EET.INFORMATION261
25956 ,P_PTIP_ID => l_PTIP_ID
25957 ----
25958 --****** END CHANGE LINES
25959
25960 --
25961
25962 ,P_EFFECTIVE_START_DATE => l_effective_start_date
25963 ,P_EFFECTIVE_END_DATE => l_effective_end_date
25964 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
25965 );
25966 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
25967 -- Update all relevent cer records with new pk_id
25968 hr_utility.set_location('Before plsql table ',222);
25969 hr_utility.set_location('new_value id '||l_elig_enrld_anthr_ptip_id,222);
25970 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ENRLD_ANTHR_PTIP_ID' ;
25971 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EET.information1 ;
25972 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_ENRLD_ANTHR_PTIP_ID ;
25973 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
25974 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EET_unique.table_route_id;
25975 hr_utility.set_location('After plsql table ',222);
25976 --
25977 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
25978 --
25979 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25980 --
25981 else
25982 --
25983 -- Call Update routine for the pk_id created in prev run .
25984 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
25985 hr_utility.set_location(' BEN_ELIG_ENRLD_ANTHR_PTIP_F UPDATE_ELIG_ENRLD_ANTHR_PTIP ',30);
25986 --UPD START
25987 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
25988 --
25989 if l_update then
25990 --
25991 l_datetrack_mode := r_EET.datetrack_mode ;
25992 --
25993 get_dt_modes(
25994 p_effective_date => l_process_date,
25995 p_effective_end_date => r_EET.information3,
25996 p_effective_start_date => r_EET.information2,
25997 p_dml_operation => r_EET.dml_operation,
25998 p_datetrack_mode => l_datetrack_mode );
25999 -- p_update => l_update
26000 --
26001 l_effective_date := l_process_date;
26002 l_ELIG_ENRLD_ANTHR_PTIP_ID := r_EET.information1;
26003 l_object_version_number := r_EET.information265;
26004 --
26005 end if;
26006 --
26007 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
26008 --
26009 IF l_update OR l_dml_operation <> 'UPDATE' THEN
26010 --UPD END
26011
26012
26013 BEN_ELIG_ENRLD_ANTHR_PTIP_API.UPDATE_ELIG_ENRLD_ANTHR_PTIP(
26014 --
26015 P_VALIDATE => false
26016 ,P_EFFECTIVE_DATE => l_effective_date
26017 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
26018 --
26019 ,P_EET_ATTRIBUTE1 => r_EET.INFORMATION111
26020 ,P_EET_ATTRIBUTE10 => r_EET.INFORMATION120
26021 ,P_EET_ATTRIBUTE11 => r_EET.INFORMATION121
26022 ,P_EET_ATTRIBUTE12 => r_EET.INFORMATION122
26023 ,P_EET_ATTRIBUTE13 => r_EET.INFORMATION123
26024 ,P_EET_ATTRIBUTE14 => r_EET.INFORMATION124
26025 ,P_EET_ATTRIBUTE15 => r_EET.INFORMATION125
26026 ,P_EET_ATTRIBUTE16 => r_EET.INFORMATION126
26027 ,P_EET_ATTRIBUTE17 => r_EET.INFORMATION127
26028 ,P_EET_ATTRIBUTE18 => r_EET.INFORMATION128
26029 ,P_EET_ATTRIBUTE19 => r_EET.INFORMATION129
26030 ,P_EET_ATTRIBUTE2 => r_EET.INFORMATION112
26031 ,P_EET_ATTRIBUTE20 => r_EET.INFORMATION130
26032 ,P_EET_ATTRIBUTE21 => r_EET.INFORMATION131
26033 ,P_EET_ATTRIBUTE22 => r_EET.INFORMATION132
26034 ,P_EET_ATTRIBUTE23 => r_EET.INFORMATION133
26035 ,P_EET_ATTRIBUTE24 => r_EET.INFORMATION134
26036 ,P_EET_ATTRIBUTE25 => r_EET.INFORMATION135
26037 ,P_EET_ATTRIBUTE26 => r_EET.INFORMATION136
26038 ,P_EET_ATTRIBUTE27 => r_EET.INFORMATION137
26039 ,P_EET_ATTRIBUTE28 => r_EET.INFORMATION138
26040 ,P_EET_ATTRIBUTE29 => r_EET.INFORMATION139
26041 ,P_EET_ATTRIBUTE3 => r_EET.INFORMATION113
26042 ,P_EET_ATTRIBUTE30 => r_EET.INFORMATION140
26043 ,P_EET_ATTRIBUTE4 => r_EET.INFORMATION114
26044 ,P_EET_ATTRIBUTE5 => r_EET.INFORMATION115
26045 ,P_EET_ATTRIBUTE6 => r_EET.INFORMATION116
26046 ,P_EET_ATTRIBUTE7 => r_EET.INFORMATION117
26047 ,P_EET_ATTRIBUTE8 => r_EET.INFORMATION118
26048 ,P_EET_ATTRIBUTE9 => r_EET.INFORMATION119
26049 ,P_EET_ATTRIBUTE_CATEGORY => r_EET.INFORMATION110
26050 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
26051 ,P_ELIG_ENRLD_ANTHR_PTIP_ID => l_elig_enrld_anthr_ptip_id
26052 ,P_ENRL_DET_DT_CD => r_EET.INFORMATION13
26053 ,P_EXCLD_FLAG => r_EET.INFORMATION11
26054 ,P_ONLY_PLS_SUBJ_COBRA_FLAG => r_EET.INFORMATION12
26055 ,P_ORDR_NUM => r_EET.INFORMATION261
26056 ,P_PTIP_ID => l_PTIP_ID
26057 --
26058 -- ****** END CHANGE LINES
26059
26060 --
26061 ,P_EFFECTIVE_START_DATE => l_effective_start_date
26062 ,P_EFFECTIVE_END_DATE => l_effective_end_date
26063 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
26064 ,P_DATETRACK_MODE => l_datetrack_mode
26065 );
26066 end if; -- l_update
26067 --
26068 end if;
26069 --
26070 -- Delete the row if it is end dated.
26071 --
26072 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
26073 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
26074 trunc(l_max_eed) = trunc(r_EET.information3)) then
26075 --
26076 BEN_ELIG_ENRLD_ANTHR_PTIP_API.delete_ELIG_ENRLD_ANTHR_PTIP(
26077 --
26078 p_validate => false
26079 ,p_elig_enrld_anthr_ptip_id => l_elig_enrld_anthr_ptip_id
26080 ,p_effective_start_date => l_effective_start_date
26081 ,p_effective_end_date => l_effective_end_date
26082 ,p_object_version_number => l_object_version_number
26083 ,p_effective_date => l_max_eed
26084 ,p_datetrack_mode => hr_api.g_delete
26085 --
26086 );
26087 --
26088 end if;
26089 --
26090 l_prev_pk_id := l_current_pk_id ;
26091 --
26092 end if;
26093 --
26094 end if;
26095 --
26096 end loop;
26097 --
26098 exception when others then
26099 --
26100 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EET',r_EET.information5 ) ;
26101 --
26102 end create_EET_rows;
26103
26104 --
26105 ---------------------------------------------------------------
26106 ----------------------< create_EFP_rows >-----------------------
26107 ---------------------------------------------------------------
26108 --
26109 procedure create_EFP_rows
26110 (
26111 p_validate in number default 0
26112 ,p_copy_entity_txn_id in number
26113 ,p_effective_date in date
26114 ,p_prefix_suffix_text in varchar2 default null
26115 ,p_reuse_object_flag in varchar2 default null
26116 ,p_target_business_group_id in varchar2 default null
26117 ,p_prefix_suffix_cd in varchar2 default null
26118 ) is
26119 --
26120 l_ELIGY_PRFL_ID number;
26121 l_FL_TM_PT_TM_CD varchar2(50) ;
26122 l_ORDR_NUM number ;
26123 --
26124 cursor c_unique_EFP(l_table_alias varchar2) is
26125 select distinct cpe.information1,
26126 cpe.information2,
26127 cpe.information3,
26128 cpe.table_route_id
26129 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
26130 pqh_table_route tr
26131 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26132 and cpe.table_route_id = tr.table_route_id
26133 -- and tr.where_clause = l_BEN_ELIG_FL_TM_PT_TM_PRTE_F
26134 and tr.table_alias = l_table_alias
26135 and cpe.number_of_copies = 1 -- ADDITION
26136 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
26137 order by information1, information2; --added for bug: 5151945
26138 --
26139 --
26140 cursor c_EFP_min_max_dates(c_table_route_id number,
26141 c_information1 number) is
26142 select
26143 min(cpe.information2) min_esd,
26144 max(cpe.information3) min_eed
26145 from ben_copy_entity_results cpe
26146 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26147 and cpe.table_route_id = c_table_route_id
26148 and cpe.information1 = c_information1 ;
26149 --
26150 cursor c_EFP(c_table_route_id number,
26151 c_information1 number,
26152 c_information2 date,
26153 c_information3 date ) is
26154 select
26155 cpe.*
26156 from ben_copy_entity_results cpe
26157 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26158 and cpe.table_route_id = c_table_route_id
26159 and cpe.information1 = c_information1
26160 and cpe.information2 = c_information2
26161 and cpe.information3 = c_information3
26162 and rownum = 1 ;
26163 -- Date Track target record
26164 cursor c_find_EFP_in_target(
26165 c_effective_start_date date,
26166 c_effective_end_date date,
26167 c_business_group_id number,
26168 c_new_pk_id number) is
26169 select
26170 EFP.elig_fl_tm_pt_tm_prte_id new_value
26171 from BEN_ELIG_FL_TM_PT_TM_PRTE_F EFP
26172 where
26173 EFP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
26174 EFP.FL_TM_PT_TM_CD = l_FL_TM_PT_TM_CD and
26175 EFP.ORDR_NUM = l_ORDR_NUM and
26176 EFP.business_group_id = c_business_group_id
26177 and EFP.elig_fl_tm_pt_tm_prte_id <> c_new_pk_id
26178 and c_effective_start_date between effective_start_date
26179 and effective_end_date ;
26180 --END TEMPIK
26181 /*TEMPIK
26182 and exists ( select null
26183 from BEN_ELIG_FL_TM_PT_TM_PRTE_F EFP1
26184 where
26185 EFP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
26186 -- Additional Filter
26187 EFP1.FL_TM_PT_TM_CD = l_FL_TM_PT_TM_CD and
26188 EFP1.ORDR_NUM = l_ORDR_NUM and
26189 EFP1.business_group_id = c_business_group_id
26190 and EFP1.effective_start_date <= c_effective_start_date )
26191 and exists ( select null
26192 from BEN_ELIG_FL_TM_PT_TM_PRTE_F EFP2
26193 where
26194 EFP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
26195 -- Additional Filter
26196 EFP2.FL_TM_PT_TM_CD = l_FL_TM_PT_TM_CD and
26197 EFP2.ORDR_NUM = l_ORDR_NUM and
26198 EFP2.business_group_id = c_business_group_id
26199 and EFP2.effective_end_date >= c_effective_end_date )
26200 ;
26201 TEMPIK */
26202 --TEMPIK
26203 l_dt_rec_found boolean ;
26204 --END TEMPIK
26205 --
26206
26207 --UPD START
26208 --
26209 l_update boolean := false ;
26210 l_datetrack_mode varchar2(80) := hr_api.g_update;
26211 l_process_date date;
26212 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
26213 --
26214 --UPD END
26215 l_current_pk_id number := null ;
26216
26217 l_prev_pk_id number := null ;
26218 l_first_rec boolean := true ;
26219 r_EFP c_EFP%rowtype;
26220 l_elig_fl_tm_pt_tm_prte_id number ;
26221 l_object_version_number number ;
26222 l_effective_start_date date ;
26223 l_effective_end_date date ;
26224 l_prefix pqh_copy_entity_attribs.information1%type := null;
26225 l_suffix pqh_copy_entity_attribs.information1%type := null;
26226 l_new_value number(15);
26227 l_object_found_in_target boolean := false ;
26228 l_min_esd date;
26229 l_max_eed date;
26230 l_effective_date date;
26231 --
26232 begin
26233 -- Initialization
26234 l_object_found_in_target := false ;
26235 -- End Initialization
26236 -- Derive the prefix - sufix
26237 if p_prefix_suffix_cd = 'PREFIX' then
26238 l_prefix := p_prefix_suffix_text ;
26239 elsif p_prefix_suffix_cd = 'SUFFIX' then
26240 l_suffix := p_prefix_suffix_text ;
26241 else
26242 l_prefix := null ;
26243 l_suffix := null ;
26244 end if ;
26245 -- End Prefix Sufix derivation
26246 for r_EFP_unique in c_unique_EFP('EFP') loop
26247
26248 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
26249 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26250 r_EFP_unique.information3 >=
26251 ben_pd_copy_to_ben_one.g_copy_effective_date)
26252 ) then
26253 --
26254 hr_utility.set_location(' r_EFP_unique.table_route_id '||r_EFP_unique.table_route_id,10);
26255 hr_utility.set_location(' r_EFP_unique.information1 '||r_EFP_unique.information1,10);
26256 hr_utility.set_location( 'r_EFP_unique.information2 '||r_EFP_unique.information2,10);
26257 hr_utility.set_location( 'r_EFP_unique.information3 '||r_EFP_unique.information3,10);
26258 -- If reuse objects flag is 'Y' then check for the object in the target business group
26259 -- if found insert the record into PLSql table and exit the loop else try create the
26260 -- object in the target business group
26261 --
26262 l_object_found_in_target := false ;
26263 --UPD START
26264 l_update := false;
26265 l_process_date := p_effective_date;
26266 l_dml_operation:= r_EFP_unique.dml_operation ;
26267 --
26268 /**********************moved from below **********************/
26269 open c_EFP(r_EFP_unique.table_route_id,
26270 r_EFP_unique.information1,
26271 r_EFP_unique.information2,
26272 r_EFP_unique.information3 ) ;
26273 --
26274 fetch c_EFP into r_EFP ;
26275 --
26276 close c_EFP ;
26277 --
26278 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EFP.INFORMATION263,l_dml_operation);
26279 -- Additional Changes
26280 l_FL_TM_PT_TM_CD := r_EFP.INFORMATION12 ;
26281 l_ORDR_NUM := r_EFP.INFORMATION260 ;
26282 /**********************************************************/
26283
26284 if l_dml_operation = 'UPDATE' then
26285 --
26286 l_object_found_in_target := TRUE;
26287 --
26288 if l_process_date between r_EFP_unique.information2 and r_EFP_unique.information3 then
26289 l_update := true;
26290 if r_EFP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
26291 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_FL_TM_PT_TM_PRTE_ID' then
26292 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_FL_TM_PT_TM_PRTE_ID' ;
26293 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EFP_unique.information1 ;
26294 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EFP_unique.information1 ;
26295 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
26296 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EFP_unique.table_route_id;
26297 --
26298 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
26299 --
26300 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26301 --
26302 -- log_data('EFP',l_new_value,l_prefix || r_EFP_unique.name|| l_suffix,'REUSED');
26303 --
26304 end if ;
26305 hr_utility.set_location( 'found record for update',10);
26306 --
26307 else
26308 --
26309 l_update := false;
26310 --
26311 end if;
26312 else
26313 --
26314 --UPD END
26315 l_min_esd := null ;
26316 l_max_eed := null ;
26317 open c_EFP_min_max_dates(r_EFP_unique.table_route_id, r_EFP_unique.information1 ) ;
26318 fetch c_EFP_min_max_dates into l_min_esd,l_max_eed ;
26319 --
26320
26321 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26322 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
26323 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
26324 end if;
26325 l_min_esd := greatest(l_min_esd,r_EFP_unique.information2);
26326 /**********************moved up from here **********************
26327 open c_EFP(r_EFP_unique.table_route_id,
26328 r_EFP_unique.information1,
26329 r_EFP_unique.information2,
26330 r_EFP_unique.information3 ) ;
26331 --
26332 fetch c_EFP into r_EFP ;
26333 --
26334 close c_EFP ;
26335 --
26336 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EFP.INFORMATION263,l_dml_operation);
26337 -- Additional Changes
26338 l_FL_TM_PT_TM_CD := r_EFP.INFORMATION12 ;
26339 l_ORDR_NUM := r_EFP.INFORMATION260 ;
26340 **********************************************************/
26341
26342
26343 --
26344 if p_reuse_object_flag = 'Y' then
26345 if c_EFP_min_max_dates%found then
26346 -- cursor to find the object
26347 open c_find_EFP_in_target( l_min_esd,l_max_eed,
26348 p_target_business_group_id, nvl(l_elig_fl_tm_pt_tm_prte_id, -999) ) ;
26349 fetch c_find_EFP_in_target into l_new_value ;
26350 if c_find_EFP_in_target%found then
26351 --
26352 --TEMPIK
26353 l_dt_rec_found := dt_api.check_min_max_dates
26354 (p_base_table_name => 'BEN_ELIG_FL_TM_PT_TM_PRTE_F',
26355 p_base_key_column => 'ELIG_FL_TM_PT_TM_PRTE_ID',
26356 p_base_key_value => l_new_value,
26357 p_from_date => l_min_esd,
26358 p_to_date => l_max_eed );
26359 if l_dt_rec_found THEN
26360 --END TEMPIK
26361 if r_EFP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
26362 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_FL_TM_PT_TM_PRTE_ID' then
26363 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_FL_TM_PT_TM_PRTE_ID' ;
26364 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EFP_unique.information1 ;
26365 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
26366 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
26367 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EFP_unique.table_route_id;
26368 --
26369 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
26370 --
26371 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26372 end if ;
26373 --
26374 l_object_found_in_target := true ;
26375 --TEMPIK
26376 end if; -- l_dt_rec_found
26377 --END TEMPIK
26378 end if;
26379 close c_find_EFP_in_target ;
26380 --
26381 end if;
26382 end if ;
26383 --
26384 close c_EFP_min_max_dates ;
26385 end if; --if p_dml_operation
26386 --
26387 if not l_object_found_in_target OR l_update then
26388
26389 --
26390 l_current_pk_id := r_EFP.information1;
26391 --
26392 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
26393 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
26394 --
26395 if l_current_pk_id = l_prev_pk_id then
26396 --
26397 l_first_rec := false ;
26398 --
26399 else
26400 --
26401 l_first_rec := true ;
26402 --
26403 end if ;
26404 --
26405
26406 l_effective_date := r_EFP.information2;
26407 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26408 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
26409 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
26410 end if;
26411
26412 if l_first_rec and not l_update then
26413 -- Call Create routine.
26414 hr_utility.set_location(' BEN_ELIG_FL_TM_PT_TM_PRTE_F CREATE_ELIG_FL_TM_PT_TM_PRTE ',20);
26415 BEN_ELIG_FL_TM_PT_TM_PRTE_API.CREATE_ELIG_FL_TM_PT_TM_PRTE(
26416 --
26417 P_VALIDATE => false
26418 ,P_EFFECTIVE_DATE => l_effective_date
26419 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
26420 --
26421 ,P_EFP_ATTRIBUTE1 => r_EFP.INFORMATION111
26422 ,P_EFP_ATTRIBUTE10 => r_EFP.INFORMATION120
26423 ,P_EFP_ATTRIBUTE11 => r_EFP.INFORMATION121
26424 ,P_EFP_ATTRIBUTE12 => r_EFP.INFORMATION122
26425 ,P_EFP_ATTRIBUTE13 => r_EFP.INFORMATION123
26426 ,P_EFP_ATTRIBUTE14 => r_EFP.INFORMATION124
26427 ,P_EFP_ATTRIBUTE15 => r_EFP.INFORMATION125
26428 ,P_EFP_ATTRIBUTE16 => r_EFP.INFORMATION126
26429 ,P_EFP_ATTRIBUTE17 => r_EFP.INFORMATION127
26430 ,P_EFP_ATTRIBUTE18 => r_EFP.INFORMATION128
26431 ,P_EFP_ATTRIBUTE19 => r_EFP.INFORMATION129
26432 ,P_EFP_ATTRIBUTE2 => r_EFP.INFORMATION112
26433 ,P_EFP_ATTRIBUTE20 => r_EFP.INFORMATION130
26434 ,P_EFP_ATTRIBUTE21 => r_EFP.INFORMATION131
26435 ,P_EFP_ATTRIBUTE22 => r_EFP.INFORMATION132
26436 ,P_EFP_ATTRIBUTE23 => r_EFP.INFORMATION133
26437 ,P_EFP_ATTRIBUTE24 => r_EFP.INFORMATION134
26438 ,P_EFP_ATTRIBUTE25 => r_EFP.INFORMATION135
26439 ,P_EFP_ATTRIBUTE26 => r_EFP.INFORMATION136
26440 ,P_EFP_ATTRIBUTE27 => r_EFP.INFORMATION137
26441 ,P_EFP_ATTRIBUTE28 => r_EFP.INFORMATION138
26442 ,P_EFP_ATTRIBUTE29 => r_EFP.INFORMATION139
26443 ,P_EFP_ATTRIBUTE3 => r_EFP.INFORMATION113
26444 ,P_EFP_ATTRIBUTE30 => r_EFP.INFORMATION140
26445 ,P_EFP_ATTRIBUTE4 => r_EFP.INFORMATION114
26446 ,P_EFP_ATTRIBUTE5 => r_EFP.INFORMATION115
26447 ,P_EFP_ATTRIBUTE6 => r_EFP.INFORMATION116
26448 ,P_EFP_ATTRIBUTE7 => r_EFP.INFORMATION117
26449 ,P_EFP_ATTRIBUTE8 => r_EFP.INFORMATION118
26450 ,P_EFP_ATTRIBUTE9 => r_EFP.INFORMATION119
26451 ,P_EFP_ATTRIBUTE_CATEGORY => r_EFP.INFORMATION110
26452 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
26453 ,P_ELIG_FL_TM_PT_TM_PRTE_ID => l_elig_fl_tm_pt_tm_prte_id
26454 ,P_EXCLD_FLAG => r_EFP.INFORMATION11
26455 ,P_FL_TM_PT_TM_CD => r_EFP.INFORMATION12
26456 ,P_ORDR_NUM => r_EFP.INFORMATION260
26457 --
26458 -- ****** END CHANGE LINES
26459
26460 --
26461
26462 ,P_EFFECTIVE_START_DATE => l_effective_start_date
26463 ,P_EFFECTIVE_END_DATE => l_effective_end_date
26464 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
26465 ,P_CRITERIA_SCORE => r_efp.INFORMATION295
26466 ,P_CRITERIA_WEIGHT => r_efp.INFORMATION296
26467 );
26468 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
26469 -- Update all relevent cer records with new pk_id
26470 hr_utility.set_location('Before plsql table ',222);
26471 hr_utility.set_location('new_value id '||l_elig_fl_tm_pt_tm_prte_id,222);
26472 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_FL_TM_PT_TM_PRTE_ID' ;
26473 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EFP.information1 ;
26474 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_FL_TM_PT_TM_PRTE_ID ;
26475 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
26476 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EFP_unique.table_route_id;
26477 hr_utility.set_location('After plsql table ',222);
26478 --
26479 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
26480 --
26481 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26482 --
26483 else
26484 --
26485 -- Call Update routine for the pk_id created in prev run .
26486 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
26487 hr_utility.set_location(' BEN_ELIG_FL_TM_PT_TM_PRTE_F UPDATE_ELIG_FL_TM_PT_TM_PRTE ',30);
26488 --UPD START
26489 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
26490 --
26491 if l_update then
26492 --
26493 l_datetrack_mode := r_EFP.datetrack_mode ;
26494 --
26495 get_dt_modes(
26496 p_effective_date => l_process_date,
26497 p_effective_end_date => r_EFP.information3,
26498 p_effective_start_date => r_EFP.information2,
26499 p_dml_operation => r_EFP.dml_operation,
26500 p_datetrack_mode => l_datetrack_mode );
26501 -- p_update => l_update
26502 --
26503 l_effective_date := l_process_date;
26504 l_ELIG_FL_TM_PT_TM_PRTE_ID := r_EFP.information1;
26505 l_object_version_number := r_EFP.information265;
26506 --
26507 end if;
26508 --
26509 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
26510 --
26511 IF l_update OR l_dml_operation <> 'UPDATE' THEN
26512 --UPD END
26513
26514
26515 BEN_ELIG_FL_TM_PT_TM_PRTE_API.UPDATE_ELIG_FL_TM_PT_TM_PRTE(
26516 --
26517 P_VALIDATE => false
26518 ,P_EFFECTIVE_DATE => l_effective_date
26519 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
26520 --
26521 ,P_EFP_ATTRIBUTE1 => r_EFP.INFORMATION111
26522 ,P_EFP_ATTRIBUTE10 => r_EFP.INFORMATION120
26523 ,P_EFP_ATTRIBUTE11 => r_EFP.INFORMATION121
26524 ,P_EFP_ATTRIBUTE12 => r_EFP.INFORMATION122
26525 ,P_EFP_ATTRIBUTE13 => r_EFP.INFORMATION123
26526 ,P_EFP_ATTRIBUTE14 => r_EFP.INFORMATION124
26527 ,P_EFP_ATTRIBUTE15 => r_EFP.INFORMATION125
26528 ,P_EFP_ATTRIBUTE16 => r_EFP.INFORMATION126
26529 ,P_EFP_ATTRIBUTE17 => r_EFP.INFORMATION127
26530 ,P_EFP_ATTRIBUTE18 => r_EFP.INFORMATION128
26531 ,P_EFP_ATTRIBUTE19 => r_EFP.INFORMATION129
26532 ,P_EFP_ATTRIBUTE2 => r_EFP.INFORMATION112
26533 ,P_EFP_ATTRIBUTE20 => r_EFP.INFORMATION130
26534 ,P_EFP_ATTRIBUTE21 => r_EFP.INFORMATION131
26535 ,P_EFP_ATTRIBUTE22 => r_EFP.INFORMATION132
26536 ,P_EFP_ATTRIBUTE23 => r_EFP.INFORMATION133
26537 ,P_EFP_ATTRIBUTE24 => r_EFP.INFORMATION134
26538 ,P_EFP_ATTRIBUTE25 => r_EFP.INFORMATION135
26539 ,P_EFP_ATTRIBUTE26 => r_EFP.INFORMATION136
26540 ,P_EFP_ATTRIBUTE27 => r_EFP.INFORMATION137
26541 ,P_EFP_ATTRIBUTE28 => r_EFP.INFORMATION138
26542 ,P_EFP_ATTRIBUTE29 => r_EFP.INFORMATION139
26543 ,P_EFP_ATTRIBUTE3 => r_EFP.INFORMATION113
26544 ,P_EFP_ATTRIBUTE30 => r_EFP.INFORMATION140
26545 ,P_EFP_ATTRIBUTE4 => r_EFP.INFORMATION114
26546 ,P_EFP_ATTRIBUTE5 => r_EFP.INFORMATION115
26547 ,P_EFP_ATTRIBUTE6 => r_EFP.INFORMATION116
26548 ,P_EFP_ATTRIBUTE7 => r_EFP.INFORMATION117
26549 ,P_EFP_ATTRIBUTE8 => r_EFP.INFORMATION118
26550 ,P_EFP_ATTRIBUTE9 => r_EFP.INFORMATION119
26551 ,P_EFP_ATTRIBUTE_CATEGORY => r_EFP.INFORMATION110
26552 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
26553 ,P_ELIG_FL_TM_PT_TM_PRTE_ID => l_elig_fl_tm_pt_tm_prte_id
26554 ,P_EXCLD_FLAG => r_EFP.INFORMATION11
26555 ,P_FL_TM_PT_TM_CD => r_EFP.INFORMATION12
26556 ,P_ORDR_NUM => r_EFP.INFORMATION260
26557 --
26558 -- ****** END CHANGE LINES
26559
26560 --
26561 ,P_EFFECTIVE_START_DATE => l_effective_start_date
26562 ,P_EFFECTIVE_END_DATE => l_effective_end_date
26563 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
26564 ,P_DATETRACK_MODE => l_datetrack_mode
26565 ,P_CRITERIA_SCORE => r_efp.INFORMATION295
26566 ,P_CRITERIA_WEIGHT => r_efp.INFORMATION296
26567 );
26568 end if; -- l_update
26569 --
26570 end if;
26571 --
26572 -- Delete the row if it is end dated.
26573 --
26574 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
26575 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
26576 trunc(l_max_eed) = trunc(r_EFP.information3)) then
26577 --
26578 BEN_ELIG_FL_TM_PT_TM_PRTE_API.delete_ELIG_FL_TM_PT_TM_PRTE(
26579 --
26580 p_validate => false
26581 ,p_elig_fl_tm_pt_tm_prte_id => l_elig_fl_tm_pt_tm_prte_id
26582 ,p_effective_start_date => l_effective_start_date
26583 ,p_effective_end_date => l_effective_end_date
26584 ,p_object_version_number => l_object_version_number
26585 ,p_effective_date => l_max_eed
26586 ,p_datetrack_mode => hr_api.g_delete
26587 --
26588 );
26589 --
26590 end if;
26591 --
26592 l_prev_pk_id := l_current_pk_id ;
26593 --
26594 end if;
26595 --
26596 end if;
26597 --
26598 end loop;
26599 --
26600 exception when others then
26601 --
26602 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EFP',r_EFP.information5 ) ;
26603 --
26604 end create_EFP_rows;
26605
26606 --
26607 ---------------------------------------------------------------
26608 ----------------------< create_EGR_rows >-----------------------
26609 ---------------------------------------------------------------
26610 --
26611 procedure create_EGR_rows
26612 (
26613 p_validate in number default 0
26614 ,p_copy_entity_txn_id in number
26615 ,p_effective_date in date
26616 ,p_prefix_suffix_text in varchar2 default null
26617 ,p_reuse_object_flag in varchar2 default null
26618 ,p_target_business_group_id in varchar2 default null
26619 ,p_prefix_suffix_cd in varchar2 default null
26620 ) is
26621 --
26622 l_ELIGY_PRFL_ID number;
26623 l_GRADE_ID number;
26624 l_ORDR_NUM number ;
26625
26626 cursor c_unique_EGR(l_table_alias varchar2) is
26627 select distinct cpe.information1,
26628 cpe.information2,
26629 cpe.information3,
26630 cpe.table_route_id
26631 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
26632 pqh_table_route tr
26633 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26634 and cpe.table_route_id = tr.table_route_id
26635 -- and tr.where_clause = l_BEN_ELIG_GRD_PRTE_F
26636 and tr.table_alias = l_table_alias
26637 and cpe.number_of_copies = 1 -- ADDITION
26638 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
26639 order by information1, information2; --added for bug: 5151945
26640 --
26641 --
26642 cursor c_EGR_min_max_dates(c_table_route_id number,
26643 c_information1 number) is
26644 select
26645 min(cpe.information2) min_esd,
26646 max(cpe.information3) min_eed
26647 from ben_copy_entity_results cpe
26648 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26649 and cpe.table_route_id = c_table_route_id
26650 and cpe.information1 = c_information1 ;
26651 --
26652 cursor c_EGR(c_table_route_id number,
26653 c_information1 number,
26654 c_information2 date,
26655 c_information3 date ) is
26656 select
26657 cpe.*
26658 from ben_copy_entity_results cpe
26659 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26660 and cpe.table_route_id = c_table_route_id
26661 and cpe.information1 = c_information1
26662 and cpe.information2 = c_information2
26663 and cpe.information3 = c_information3
26664 and rownum = 1 ;
26665 -- Date Track target record
26666 cursor c_find_EGR_in_target(
26667 c_effective_start_date date,
26668 c_effective_end_date date,
26669 c_business_group_id number,
26670 c_new_pk_id number) is
26671 select
26672 EGR.elig_grd_prte_id new_value
26673 from BEN_ELIG_GRD_PRTE_F EGR
26674 where
26675 EGR.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
26676 EGR.GRADE_ID = l_GRADE_ID and
26677 EGR.ORDR_NUM = l_ORDR_NUM and
26678 EGR.business_group_id = c_business_group_id
26679 and EGR.elig_grd_prte_id <> c_new_pk_id
26680 and c_effective_start_date between effective_start_date
26681 and effective_end_date ;
26682 --END TEMPIK
26683 /*TEMPIK
26684 and exists ( select null
26685 from BEN_ELIG_GRD_PRTE_F EGR1
26686 where
26687 EGR1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
26688
26689 -- Additional Filter
26690 EGR1.GRADE_ID = l_GRADE_ID and
26691 EGR1.ORDR_NUM = l_ORDR_NUM and
26692
26693 EGR1.business_group_id = c_business_group_id
26694 and EGR1.effective_start_date <= c_effective_start_date )
26695 and exists ( select null
26696 from BEN_ELIG_GRD_PRTE_F EGR2
26697 where
26698 EGR2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
26699
26700 -- Additional Filter
26701 EGR2.GRADE_ID = l_GRADE_ID and
26702 EGR2.ORDR_NUM = l_ORDR_NUM and
26703
26704 EGR2.business_group_id = c_business_group_id
26705 and EGR2.effective_end_date >= c_effective_end_date )
26706 ;
26707 TEMPIK */
26708 --TEMPIK
26709 l_dt_rec_found boolean ;
26710 --END TEMPIK
26711 --
26712
26713 --UPD START
26714 --
26715 l_update boolean := false ;
26716 l_datetrack_mode varchar2(80) := hr_api.g_update;
26717 l_process_date date;
26718 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
26719 --
26720 --UPD END
26721 l_current_pk_id number := null ;
26722
26723 l_prev_pk_id number := null ;
26724 l_first_rec boolean := true ;
26725 r_EGR c_EGR%rowtype;
26726 l_elig_grd_prte_id number ;
26727 l_object_version_number number ;
26728 l_effective_start_date date ;
26729 l_effective_end_date date ;
26730 l_prefix pqh_copy_entity_attribs.information1%type := null;
26731 l_suffix pqh_copy_entity_attribs.information1%type := null;
26732 l_new_value number(15);
26733 l_object_found_in_target boolean := false ;
26734 l_min_esd date;
26735 l_max_eed date;
26736 l_effective_date date;
26737 --
26738 begin
26739 -- Initialization
26740 l_object_found_in_target := false ;
26741 -- End Initialization
26742 -- Derive the prefix - sufix
26743 if p_prefix_suffix_cd = 'PREFIX' then
26744 l_prefix := p_prefix_suffix_text ;
26745 elsif p_prefix_suffix_cd = 'SUFFIX' then
26746 l_suffix := p_prefix_suffix_text ;
26747 else
26748 l_prefix := null ;
26749 l_suffix := null ;
26750 end if ;
26751 -- End Prefix Sufix derivation
26752 for r_EGR_unique in c_unique_EGR('EGR') loop
26753
26754 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
26755 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26756 r_EGR_unique.information3 >=
26757 ben_pd_copy_to_ben_one.g_copy_effective_date)
26758 ) then
26759 --
26760 hr_utility.set_location(' r_EGR_unique.table_route_id '||r_EGR_unique.table_route_id,10);
26761 hr_utility.set_location(' r_EGR_unique.information1 '||r_EGR_unique.information1,10);
26762 hr_utility.set_location( 'r_EGR_unique.information2 '||r_EGR_unique.information2,10);
26763 hr_utility.set_location( 'r_EGR_unique.information3 '||r_EGR_unique.information3,10);
26764 -- If reuse objects flag is 'Y' then check for the object in the target business group
26765 -- if found insert the record into PLSql table and exit the loop else try create the
26766 -- object in the target business group
26767 --
26768 l_object_found_in_target := false ;
26769 --UPD START
26770 l_update := false;
26771 l_process_date := p_effective_date;
26772 l_dml_operation:= r_EGR_unique.dml_operation ;
26773 --
26774 /**********************moved from below **********************/
26775 open c_EGR(r_EGR_unique.table_route_id,
26776 r_EGR_unique.information1,
26777 r_EGR_unique.information2,
26778 r_EGR_unique.information3 ) ;
26779 --
26780 fetch c_EGR into r_EGR ;
26781 --
26782 close c_EGR ;
26783 --
26784 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EGR.INFORMATION263,l_dml_operation);
26785 --
26786 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
26787 l_GRADE_ID := r_EGR.information176;
26788 else
26789 l_GRADE_ID := r_EGR.information174;
26790 end if;
26791 --
26792 l_ORDR_NUM := r_EGR.INFORMATION260 ;
26793 /**********************************************************/
26794
26795 if l_dml_operation = 'UPDATE' then
26796 --
26797 l_object_found_in_target := TRUE;
26798 --
26799 if l_process_date between r_EGR_unique.information2 and r_EGR_unique.information3 then
26800 l_update := true;
26801 if r_EGR_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
26802 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_GRD_PRTE_ID' then
26803 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_GRD_PRTE_ID' ;
26804 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EGR_unique.information1 ;
26805 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EGR_unique.information1 ;
26806 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
26807 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EGR_unique.table_route_id;
26808 --
26809 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
26810 --
26811 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26812 --
26813 -- log_data('EGR',l_new_value,l_prefix || r_EGR_unique.name|| l_suffix,'REUSED');
26814 --
26815 end if ;
26816 hr_utility.set_location( 'found record for update',10);
26817 --
26818 else
26819 --
26820 l_update := false;
26821 --
26822 end if;
26823 else
26824 --
26825 --UPD END
26826 l_min_esd := null ;
26827 l_max_eed := null ;
26828 open c_EGR_min_max_dates(r_EGR_unique.table_route_id, r_EGR_unique.information1 ) ;
26829 fetch c_EGR_min_max_dates into l_min_esd,l_max_eed ;
26830 --
26831
26832 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26833 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
26834 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
26835 end if;
26836 l_min_esd := greatest(l_min_esd,r_EGR_unique.information2);
26837 /**********************moved up from here **********************
26838 open c_EGR(r_EGR_unique.table_route_id,
26839 r_EGR_unique.information1,
26840 r_EGR_unique.information2,
26841 r_EGR_unique.information3 ) ;
26842 --
26843 fetch c_EGR into r_EGR ;
26844 --
26845 close c_EGR ;
26846 --
26847 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EGR.INFORMATION263,l_dml_operation);
26848 --
26849 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
26850 l_GRADE_ID := r_EGR.information176;
26851 else
26852 l_GRADE_ID := r_EGR.information174;
26853 end if;
26854 --
26855 l_ORDR_NUM := r_EGR.INFORMATION260 ;
26856 **********************************************************/
26857
26858
26859 if l_GRADE_ID is null then
26860 close c_EGR_min_max_dates;
26861 --
26862 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'ELP'
26863 ,p_parent_pk_id => r_EGR.information263
26864 ,p_copy_entity_txn_id => p_copy_entity_txn_id
26865 ,p_child_table_alias => 'EGR'
26866 ,p_child_data => r_EGR.information173 );
26867
26868 --
26869 else
26870 if p_reuse_object_flag = 'Y' then
26871 if c_EGR_min_max_dates%found then
26872 -- cursor to find the object
26873 open c_find_EGR_in_target( l_min_esd,l_max_eed,
26874 p_target_business_group_id, nvl(l_elig_grd_prte_id, -999) ) ;
26875 fetch c_find_EGR_in_target into l_new_value ;
26876 if c_find_EGR_in_target%found then
26877 --
26878 --TEMPIK
26879 l_dt_rec_found := dt_api.check_min_max_dates
26880 (p_base_table_name => 'BEN_ELIG_GRD_PRTE_F',
26881 p_base_key_column => 'ELIG_GRD_PRTE_ID',
26882 p_base_key_value => l_new_value,
26883 p_from_date => l_min_esd,
26884 p_to_date => l_max_eed );
26885 if l_dt_rec_found THEN
26886 --END TEMPIK
26887 if r_EGR_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
26888 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_GRD_PRTE_ID' then
26889 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_GRD_PRTE_ID' ;
26890 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EGR_unique.information1 ;
26891 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
26892 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
26893 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EGR_unique.table_route_id;
26894 --
26895 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
26896 --
26897 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26898 end if ;
26899 --
26900 l_object_found_in_target := true ;
26901 --TEMPIK
26902 end if; -- l_dt_rec_found
26903 --END TEMPIK
26904 end if;
26905 close c_find_EGR_in_target ;
26906 --
26907 end if;
26908 end if ;
26909 --
26910 close c_EGR_min_max_dates ;
26911
26912 end if; -- bug 4565106
26913
26914 end if; --if p_dml_operation
26915 --
26916 if (not l_object_found_in_target OR l_update) and l_grade_id is not null then
26917
26918 --
26919 l_current_pk_id := r_EGR.information1;
26920 --
26921 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
26922 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
26923 --
26924 if l_current_pk_id = l_prev_pk_id then
26925 --
26926 l_first_rec := false ;
26927 --
26928 else
26929 --
26930 l_first_rec := true ;
26931 --
26932 end if ;
26933 --
26934
26935 l_effective_date := r_EGR.information2;
26936 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26937 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
26938 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
26939 end if;
26940
26941 if l_first_rec and not l_update then
26942 -- Call Create routine.
26943 hr_utility.set_location(' BEN_ELIG_GRD_PRTE_F CREATE_ELIG_GRD_PRTE ',20);
26944 BEN_ELIG_GRD_PRTE_API.CREATE_ELIG_GRD_PRTE(
26945 --
26946 P_VALIDATE => false
26947 ,P_EFFECTIVE_DATE => l_effective_date
26948 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
26949 --
26950 ,P_EGR_ATTRIBUTE1 => r_EGR.INFORMATION111
26951 ,P_EGR_ATTRIBUTE10 => r_EGR.INFORMATION120
26952 ,P_EGR_ATTRIBUTE11 => r_EGR.INFORMATION121
26953 ,P_EGR_ATTRIBUTE12 => r_EGR.INFORMATION122
26954 ,P_EGR_ATTRIBUTE13 => r_EGR.INFORMATION123
26955 ,P_EGR_ATTRIBUTE14 => r_EGR.INFORMATION124
26956 ,P_EGR_ATTRIBUTE15 => r_EGR.INFORMATION125
26957 ,P_EGR_ATTRIBUTE16 => r_EGR.INFORMATION126
26958 ,P_EGR_ATTRIBUTE17 => r_EGR.INFORMATION127
26959 ,P_EGR_ATTRIBUTE18 => r_EGR.INFORMATION128
26960 ,P_EGR_ATTRIBUTE19 => r_EGR.INFORMATION129
26961 ,P_EGR_ATTRIBUTE2 => r_EGR.INFORMATION112
26962 ,P_EGR_ATTRIBUTE20 => r_EGR.INFORMATION130
26963 ,P_EGR_ATTRIBUTE21 => r_EGR.INFORMATION131
26964 ,P_EGR_ATTRIBUTE22 => r_EGR.INFORMATION132
26965 ,P_EGR_ATTRIBUTE23 => r_EGR.INFORMATION133
26966 ,P_EGR_ATTRIBUTE24 => r_EGR.INFORMATION134
26967 ,P_EGR_ATTRIBUTE25 => r_EGR.INFORMATION135
26968 ,P_EGR_ATTRIBUTE26 => r_EGR.INFORMATION136
26969 ,P_EGR_ATTRIBUTE27 => r_EGR.INFORMATION137
26970 ,P_EGR_ATTRIBUTE28 => r_EGR.INFORMATION138
26971 ,P_EGR_ATTRIBUTE29 => r_EGR.INFORMATION139
26972 ,P_EGR_ATTRIBUTE3 => r_EGR.INFORMATION113
26973 ,P_EGR_ATTRIBUTE30 => r_EGR.INFORMATION140
26974 ,P_EGR_ATTRIBUTE4 => r_EGR.INFORMATION114
26975 ,P_EGR_ATTRIBUTE5 => r_EGR.INFORMATION115
26976 ,P_EGR_ATTRIBUTE6 => r_EGR.INFORMATION116
26977 ,P_EGR_ATTRIBUTE7 => r_EGR.INFORMATION117
26978 ,P_EGR_ATTRIBUTE8 => r_EGR.INFORMATION118
26979 ,P_EGR_ATTRIBUTE9 => r_EGR.INFORMATION119
26980 ,P_EGR_ATTRIBUTE_CATEGORY => r_EGR.INFORMATION110
26981 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
26982 ,P_ELIG_GRD_PRTE_ID => l_elig_grd_prte_id
26983 ,P_EXCLD_FLAG => r_EGR.INFORMATION11
26984 ,P_GRADE_ID => l_GRADE_ID
26985 ,P_ORDR_NUM => r_EGR.INFORMATION260
26986 --
26987 -- ****** END CHANGE LINES
26988
26989 --
26990
26991 ,P_EFFECTIVE_START_DATE => l_effective_start_date
26992 ,P_EFFECTIVE_END_DATE => l_effective_end_date
26993 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
26994 ,P_CRITERIA_SCORE => r_egr.INFORMATION295
26995 ,P_CRITERIA_WEIGHT => r_egr.INFORMATION296
26996 );
26997 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
26998 -- Update all relevent cer records with new pk_id
26999 hr_utility.set_location('Before plsql table ',222);
27000 hr_utility.set_location('new_value id '||l_elig_grd_prte_id,222);
27001 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_GRD_PRTE_ID' ;
27002 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EGR.information1 ;
27003 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_GRD_PRTE_ID ;
27004 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
27005 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EGR_unique.table_route_id;
27006 hr_utility.set_location('After plsql table ',222);
27007 --
27008 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
27009 --
27010 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
27011 --
27012 else
27013 --
27014 -- Call Update routine for the pk_id created in prev run .
27015 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
27016 hr_utility.set_location(' BEN_ELIG_GRD_PRTE_F UPDATE_ELIG_GRD_PRTE ',30);
27017 --UPD START
27018 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
27019 --
27020 if l_update then
27021 --
27022 l_datetrack_mode := r_EGR.datetrack_mode ;
27023 --
27024 get_dt_modes(
27025 p_effective_date => l_process_date,
27026 p_effective_end_date => r_EGR.information3,
27027 p_effective_start_date => r_EGR.information2,
27028 p_dml_operation => r_EGR.dml_operation,
27029 p_datetrack_mode => l_datetrack_mode );
27030 -- p_update => l_update
27031 --
27032 l_effective_date := l_process_date;
27033 l_ELIG_GRD_PRTE_ID := r_EGR.information1;
27034 l_object_version_number := r_EGR.information265;
27035 --
27036 end if;
27037 --
27038 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
27039 --
27040 IF l_update OR l_dml_operation <> 'UPDATE' THEN
27041 --UPD END
27042
27043
27044 BEN_ELIG_GRD_PRTE_API.UPDATE_ELIG_GRD_PRTE(
27045 --
27046 P_VALIDATE => false
27047 ,P_EFFECTIVE_DATE => l_effective_date
27048 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
27049 --
27050 ,P_EGR_ATTRIBUTE1 => r_EGR.INFORMATION111
27051 ,P_EGR_ATTRIBUTE10 => r_EGR.INFORMATION120
27052 ,P_EGR_ATTRIBUTE11 => r_EGR.INFORMATION121
27053 ,P_EGR_ATTRIBUTE12 => r_EGR.INFORMATION122
27054 ,P_EGR_ATTRIBUTE13 => r_EGR.INFORMATION123
27055 ,P_EGR_ATTRIBUTE14 => r_EGR.INFORMATION124
27056 ,P_EGR_ATTRIBUTE15 => r_EGR.INFORMATION125
27057 ,P_EGR_ATTRIBUTE16 => r_EGR.INFORMATION126
27058 ,P_EGR_ATTRIBUTE17 => r_EGR.INFORMATION127
27059 ,P_EGR_ATTRIBUTE18 => r_EGR.INFORMATION128
27060 ,P_EGR_ATTRIBUTE19 => r_EGR.INFORMATION129
27061 ,P_EGR_ATTRIBUTE2 => r_EGR.INFORMATION112
27062 ,P_EGR_ATTRIBUTE20 => r_EGR.INFORMATION130
27063 ,P_EGR_ATTRIBUTE21 => r_EGR.INFORMATION131
27064 ,P_EGR_ATTRIBUTE22 => r_EGR.INFORMATION132
27065 ,P_EGR_ATTRIBUTE23 => r_EGR.INFORMATION133
27066 ,P_EGR_ATTRIBUTE24 => r_EGR.INFORMATION134
27067 ,P_EGR_ATTRIBUTE25 => r_EGR.INFORMATION135
27068 ,P_EGR_ATTRIBUTE26 => r_EGR.INFORMATION136
27069 ,P_EGR_ATTRIBUTE27 => r_EGR.INFORMATION137
27070 ,P_EGR_ATTRIBUTE28 => r_EGR.INFORMATION138
27071 ,P_EGR_ATTRIBUTE29 => r_EGR.INFORMATION139
27072 ,P_EGR_ATTRIBUTE3 => r_EGR.INFORMATION113
27073 ,P_EGR_ATTRIBUTE30 => r_EGR.INFORMATION140
27074 ,P_EGR_ATTRIBUTE4 => r_EGR.INFORMATION114
27075 ,P_EGR_ATTRIBUTE5 => r_EGR.INFORMATION115
27076 ,P_EGR_ATTRIBUTE6 => r_EGR.INFORMATION116
27077 ,P_EGR_ATTRIBUTE7 => r_EGR.INFORMATION117
27078 ,P_EGR_ATTRIBUTE8 => r_EGR.INFORMATION118
27079 ,P_EGR_ATTRIBUTE9 => r_EGR.INFORMATION119
27080 ,P_EGR_ATTRIBUTE_CATEGORY => r_EGR.INFORMATION110
27081 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
27082 ,P_ELIG_GRD_PRTE_ID => l_elig_grd_prte_id
27083 ,P_EXCLD_FLAG => r_EGR.INFORMATION11
27084 ,P_GRADE_ID => l_GRADE_ID
27085 ,P_ORDR_NUM => r_EGR.INFORMATION260
27086 --
27087 -- ****** END CHANGE LINES
27088
27089 --
27090 ,P_EFFECTIVE_START_DATE => l_effective_start_date
27091 ,P_EFFECTIVE_END_DATE => l_effective_end_date
27092 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
27093 ,P_DATETRACK_MODE => l_datetrack_mode
27094 ,P_CRITERIA_SCORE => r_egr.INFORMATION295
27095 ,P_CRITERIA_WEIGHT => r_egr.INFORMATION296
27096 );
27097 end if; -- l_update
27098 --
27099 end if;
27100 --
27101 -- Delete the row if it is end dated.
27102 --
27103 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
27104 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
27105 trunc(l_max_eed) = trunc(r_EGR.information3)) then
27106 --
27107 BEN_ELIG_GRD_PRTE_API.delete_ELIG_GRD_PRTE(
27108 --
27109 p_validate => false
27110 ,p_elig_grd_prte_id => l_elig_grd_prte_id
27111 ,p_effective_start_date => l_effective_start_date
27112 ,p_effective_end_date => l_effective_end_date
27113 ,p_object_version_number => l_object_version_number
27114 ,p_effective_date => l_max_eed
27115 ,p_datetrack_mode => hr_api.g_delete
27116 --
27117 );
27118 --
27119 end if;
27120 --
27121 l_prev_pk_id := l_current_pk_id ;
27122 --
27123 -- end if; -- bug 4565106
27124 --
27125 end if;
27126 --
27127 end if;
27128 --
27129 end loop;
27130 --
27131 exception when others then
27132 --
27133 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EGR',r_EGR.information5 ) ;
27134 --
27135 end create_EGR_rows;
27136
27137 --
27138 ---------------------------------------------------------------
27139 ----------------------< create_EHS_rows >-----------------------
27140 ---------------------------------------------------------------
27141 --
27142 procedure create_EHS_rows
27143 (
27144 p_validate in number default 0
27145 ,p_copy_entity_txn_id in number
27146 ,p_effective_date in date
27147 ,p_prefix_suffix_text in varchar2 default null
27148 ,p_reuse_object_flag in varchar2 default null
27149 ,p_target_business_group_id in varchar2 default null
27150 ,p_prefix_suffix_cd in varchar2 default null
27151 ) is
27152 --
27153 l_ELIGY_PRFL_ID number;
27154 l_HRLY_SLRD_CD varchar2(30);
27155
27156 cursor c_unique_EHS(l_table_alias varchar2) is
27157 select distinct cpe.information1,
27158 cpe.information2,
27159 cpe.information3,
27160 cpe.table_route_id
27161 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
27162 pqh_table_route tr
27163 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
27164 and cpe.table_route_id = tr.table_route_id
27165 -- and tr.where_clause = l_BEN_ELIG_HRLY_SLRD_PRTE_F
27166 and tr.table_alias = l_table_alias
27167 and cpe.number_of_copies = 1 -- ADDITION
27168 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
27169 order by information1, information2; --added for bug: 5151945
27170 --
27171 --
27172 cursor c_EHS_min_max_dates(c_table_route_id number,
27173 c_information1 number) is
27174 select
27175 min(cpe.information2) min_esd,
27176 max(cpe.information3) min_eed
27177 from ben_copy_entity_results cpe
27178 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
27179 and cpe.table_route_id = c_table_route_id
27180 and cpe.information1 = c_information1 ;
27181 --
27182 cursor c_EHS(c_table_route_id number,
27183 c_information1 number,
27184 c_information2 date,
27185 c_information3 date ) is
27186 select
27187 cpe.*
27188 from ben_copy_entity_results cpe
27189 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
27190 and cpe.table_route_id = c_table_route_id
27191 and cpe.information1 = c_information1
27192 and cpe.information2 = c_information2
27193 and cpe.information3 = c_information3
27194 and rownum = 1 ;
27195 -- Date Track target record
27196 cursor c_find_EHS_in_target(
27197 c_effective_start_date date,
27198 c_effective_end_date date,
27199 c_business_group_id number,
27200 c_new_pk_id number) is
27201 select
27202 EHS.elig_hrly_slrd_prte_id new_value
27203 from BEN_ELIG_HRLY_SLRD_PRTE_F EHS
27204 where
27205 EHS.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
27206 EHS.business_group_id = c_business_group_id
27207 and EHS.elig_hrly_slrd_prte_id <> c_new_pk_id
27208 and c_effective_start_date between effective_start_date
27209 and effective_end_date ;
27210 --END TEMPIK
27211 /*TEMPIK
27212 and exists ( select null
27213 from BEN_ELIG_HRLY_SLRD_PRTE_F EHS1
27214 where
27215 EHS1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
27216
27217 -- Additional Filter Condition
27218 EHS1.HRLY_SLRD_CD = l_HRLY_SLRD_CD and
27219
27220 EHS1.business_group_id = c_business_group_id
27221 and EHS1.effective_start_date <= c_effective_start_date )
27222 and exists ( select null
27223 from BEN_ELIG_HRLY_SLRD_PRTE_F EHS2
27224 where
27225 EHS2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
27226
27227 -- Additional Filter Condition
27228 EHS2.HRLY_SLRD_CD = l_HRLY_SLRD_CD and
27229
27230 EHS2.business_group_id = c_business_group_id
27231 and EHS2.effective_end_date >= c_effective_end_date )
27232 ;
27233 TEMPIK */
27234 --TEMPIK
27235 l_dt_rec_found boolean ;
27236 --END TEMPIK
27237 --
27238
27239 --UPD START
27240 --
27241 l_update boolean := false ;
27242 l_datetrack_mode varchar2(80) := hr_api.g_update;
27243 l_process_date date;
27244 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
27245 --
27246 --UPD END
27247 l_current_pk_id number := null ;
27248
27249 l_prev_pk_id number := null ;
27250 l_first_rec boolean := true ;
27251 r_EHS c_EHS%rowtype;
27252 l_elig_hrly_slrd_prte_id number ;
27253 l_object_version_number number ;
27254 l_effective_start_date date ;
27255 l_effective_end_date date ;
27256 l_prefix pqh_copy_entity_attribs.information1%type := null;
27257 l_suffix pqh_copy_entity_attribs.information1%type := null;
27258 l_new_value number(15);
27259 l_object_found_in_target boolean := false ;
27260 l_min_esd date;
27261 l_max_eed date;
27262 l_effective_date date;
27263 --
27264 begin
27265 -- Initialization
27266 l_object_found_in_target := false ;
27267 -- End Initialization
27268 -- Derive the prefix - sufix
27269 if p_prefix_suffix_cd = 'PREFIX' then
27270 l_prefix := p_prefix_suffix_text ;
27271 elsif p_prefix_suffix_cd = 'SUFFIX' then
27272 l_suffix := p_prefix_suffix_text ;
27273 else
27274 l_prefix := null ;
27275 l_suffix := null ;
27276 end if ;
27277 -- End Prefix Sufix derivation
27278 for r_EHS_unique in c_unique_EHS('EHS') loop
27279
27280 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
27281 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
27282 r_EHS_unique.information3 >=
27283 ben_pd_copy_to_ben_one.g_copy_effective_date)
27284 ) then
27285 --
27286 hr_utility.set_location(' r_EHS_unique.table_route_id '||r_EHS_unique.table_route_id,10);
27287 hr_utility.set_location(' r_EHS_unique.information1 '||r_EHS_unique.information1,10);
27288 hr_utility.set_location( 'r_EHS_unique.information2 '||r_EHS_unique.information2,10);
27289 hr_utility.set_location( 'r_EHS_unique.information3 '||r_EHS_unique.information3,10);
27290 -- If reuse objects flag is 'Y' then check for the object in the target business group
27291 -- if found insert the record into PLSql table and exit the loop else try create the
27292 -- object in the target business group
27293 --
27294 l_object_found_in_target := false ;
27295 --UPD START
27296 l_update := false;
27297 l_process_date := p_effective_date;
27298 l_dml_operation:= r_EHS_unique.dml_operation ;
27299 --
27300 /**********************moved from below **********************/
27301 open c_EHS(r_EHS_unique.table_route_id,
27302 r_EHS_unique.information1,
27303 r_EHS_unique.information2,
27304 r_EHS_unique.information3 ) ;
27305 --
27306 fetch c_EHS into r_EHS ;
27307 --
27308 close c_EHS ;
27309 --
27310 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EHS.INFORMATION263,l_dml_operation);
27311 -- Additional Change
27312 l_HRLY_SLRD_CD := r_EHS.INFORMATION11 ;
27313
27314 /**********************************************************/
27315
27316 if l_dml_operation = 'UPDATE' then
27317 --
27318 l_object_found_in_target := TRUE;
27319 --
27320 if l_process_date between r_EHS_unique.information2 and r_EHS_unique.information3 then
27321 l_update := true;
27322 if r_EHS_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
27323 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_HRLY_SLRD_PRTE_ID' then
27324 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_HRLY_SLRD_PRTE_ID' ;
27325 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EHS_unique.information1 ;
27326 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EHS_unique.information1 ;
27327 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
27328 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EHS_unique.table_route_id;
27329 --
27330 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
27331 --
27332 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
27333 --
27334 -- log_data('EHS',l_new_value,l_prefix || r_EHS_unique.name|| l_suffix,'REUSED');
27335 --
27336 end if ;
27337 hr_utility.set_location( 'found record for update',10);
27338 --
27339 else
27340 --
27341 l_update := false;
27342 --
27343 end if;
27344 else
27345 --
27346 --UPD END
27347 l_min_esd := null ;
27348 l_max_eed := null ;
27349 open c_EHS_min_max_dates(r_EHS_unique.table_route_id, r_EHS_unique.information1 ) ;
27350 fetch c_EHS_min_max_dates into l_min_esd,l_max_eed ;
27351 --
27352
27353 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
27354 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
27355 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
27356 end if;
27357 l_min_esd := greatest(l_min_esd,r_EHS_unique.information2);
27358 /**********************moved up from here **********************
27359 open c_EHS(r_EHS_unique.table_route_id,
27360 r_EHS_unique.information1,
27361 r_EHS_unique.information2,
27362 r_EHS_unique.information3 ) ;
27363 --
27364 fetch c_EHS into r_EHS ;
27365 --
27366 close c_EHS ;
27367 --
27368 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EHS.INFORMATION263,l_dml_operation);
27369 -- Additional Change
27370 l_HRLY_SLRD_CD := r_EHS.INFORMATION11 ;
27371
27372 **********************************************************/
27373
27374
27375 if p_reuse_object_flag = 'Y' then
27376 if c_EHS_min_max_dates%found then
27377 -- cursor to find the object
27378 open c_find_EHS_in_target( l_min_esd,l_max_eed,
27379 p_target_business_group_id, nvl(l_elig_hrly_slrd_prte_id, -999) ) ;
27380 fetch c_find_EHS_in_target into l_new_value ;
27381 if c_find_EHS_in_target%found then
27382 --
27383 --TEMPIK
27384 l_dt_rec_found := dt_api.check_min_max_dates
27385 (p_base_table_name => 'BEN_ELIG_HRLY_SLRD_PRTE_F',
27386 p_base_key_column => 'ELIG_HRLY_SLRD_PRTE_ID',
27387 p_base_key_value => l_new_value,
27388 p_from_date => l_min_esd,
27389 p_to_date => l_max_eed );
27390 if l_dt_rec_found THEN
27391 --END TEMPIK
27392 if r_EHS_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
27393 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_HRLY_SLRD_PRTE_ID' then
27394 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_HRLY_SLRD_PRTE_ID' ;
27395 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EHS_unique.information1 ;
27396 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
27397 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
27398 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EHS_unique.table_route_id;
27399 --
27400 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
27401 --
27402 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
27403 end if ;
27404 --
27405 l_object_found_in_target := true ;
27406 --TEMPIK
27407 end if; -- l_dt_rec_found
27408 --END TEMPIK
27409 end if;
27410 close c_find_EHS_in_target ;
27411 --
27412 end if;
27413 end if ;
27414 --
27415 close c_EHS_min_max_dates ;
27416 end if; --if p_dml_operation
27417 --
27418 if not l_object_found_in_target OR l_update then
27419
27420 --
27421 l_current_pk_id := r_EHS.information1;
27422 --
27423 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
27424 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
27425 --
27426 if l_current_pk_id = l_prev_pk_id then
27427 --
27428 l_first_rec := false ;
27429 --
27430 else
27431 --
27432 l_first_rec := true ;
27433 --
27434 end if ;
27435 --
27436
27437 l_effective_date := r_EHS.information2;
27438 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
27439 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
27440 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
27441 end if;
27442
27443 if l_first_rec and not l_update then
27444 -- Call Create routine.
27445 hr_utility.set_location(' BEN_ELIG_HRLY_SLRD_PRTE_F CREATE_ELIG_HRLY_SLRD_PRTE ',20);
27446 BEN_ELIG_HRLY_SLRD_PRTE_API.CREATE_ELIG_HRLY_SLRD_PRTE(
27447 --
27448 P_VALIDATE => false
27449 ,P_EFFECTIVE_DATE => l_effective_date
27450 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
27451 --
27452 ,P_EHS_ATTRIBUTE1 => r_EHS.INFORMATION111
27453 ,P_EHS_ATTRIBUTE10 => r_EHS.INFORMATION120
27454 ,P_EHS_ATTRIBUTE11 => r_EHS.INFORMATION121
27455 ,P_EHS_ATTRIBUTE12 => r_EHS.INFORMATION122
27456 ,P_EHS_ATTRIBUTE13 => r_EHS.INFORMATION123
27457 ,P_EHS_ATTRIBUTE14 => r_EHS.INFORMATION124
27458 ,P_EHS_ATTRIBUTE15 => r_EHS.INFORMATION125
27459 ,P_EHS_ATTRIBUTE16 => r_EHS.INFORMATION126
27460 ,P_EHS_ATTRIBUTE17 => r_EHS.INFORMATION127
27461 ,P_EHS_ATTRIBUTE18 => r_EHS.INFORMATION128
27462 ,P_EHS_ATTRIBUTE19 => r_EHS.INFORMATION129
27463 ,P_EHS_ATTRIBUTE2 => r_EHS.INFORMATION112
27464 ,P_EHS_ATTRIBUTE20 => r_EHS.INFORMATION130
27465 ,P_EHS_ATTRIBUTE21 => r_EHS.INFORMATION131
27466 ,P_EHS_ATTRIBUTE22 => r_EHS.INFORMATION132
27467 ,P_EHS_ATTRIBUTE23 => r_EHS.INFORMATION133
27468 ,P_EHS_ATTRIBUTE24 => r_EHS.INFORMATION134
27469 ,P_EHS_ATTRIBUTE25 => r_EHS.INFORMATION135
27470 ,P_EHS_ATTRIBUTE26 => r_EHS.INFORMATION136
27471 ,P_EHS_ATTRIBUTE27 => r_EHS.INFORMATION137
27472 ,P_EHS_ATTRIBUTE28 => r_EHS.INFORMATION138
27473 ,P_EHS_ATTRIBUTE29 => r_EHS.INFORMATION139
27474 ,P_EHS_ATTRIBUTE3 => r_EHS.INFORMATION113
27475 ,P_EHS_ATTRIBUTE30 => r_EHS.INFORMATION140
27476 ,P_EHS_ATTRIBUTE4 => r_EHS.INFORMATION114
27477 ,P_EHS_ATTRIBUTE5 => r_EHS.INFORMATION115
27478 ,P_EHS_ATTRIBUTE6 => r_EHS.INFORMATION116
27479 ,P_EHS_ATTRIBUTE7 => r_EHS.INFORMATION117
27480 ,P_EHS_ATTRIBUTE8 => r_EHS.INFORMATION118
27481 ,P_EHS_ATTRIBUTE9 => r_EHS.INFORMATION119
27482 ,P_EHS_ATTRIBUTE_CATEGORY => r_EHS.INFORMATION110
27483 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
27484 ,P_ELIG_HRLY_SLRD_PRTE_ID => l_elig_hrly_slrd_prte_id
27485 ,P_EXCLD_FLAG => r_EHS.INFORMATION12
27486 ,P_HRLY_SLRD_CD => r_EHS.INFORMATION11
27487 ,P_ORDR_NUM => r_EHS.INFORMATION260
27488 --
27489 -- ****** END CHANGE LINES
27490
27491 --
27492
27493 ,P_EFFECTIVE_START_DATE => l_effective_start_date
27494 ,P_EFFECTIVE_END_DATE => l_effective_end_date
27495 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
27496 ,P_CRITERIA_SCORE => r_ehs.INFORMATION295
27497 ,P_CRITERIA_WEIGHT => r_ehs.INFORMATION296
27498 );
27499 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
27500 -- Update all relevent cer records with new pk_id
27501 hr_utility.set_location('Before plsql table ',222);
27502 hr_utility.set_location('new_value id '||l_elig_hrly_slrd_prte_id,222);
27503 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_HRLY_SLRD_PRTE_ID' ;
27504 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EHS.information1 ;
27505 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_HRLY_SLRD_PRTE_ID ;
27506 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
27507 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EHS_unique.table_route_id;
27508 hr_utility.set_location('After plsql table ',222);
27509 --
27510 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
27511 --
27512 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
27513 --
27514 else
27515 --
27516 -- Call Update routine for the pk_id created in prev run .
27517 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
27518 hr_utility.set_location(' BEN_ELIG_HRLY_SLRD_PRTE_F UPDATE_ELIG_HRLY_SLRD_PRTE ',30);
27519 --UPD START
27520 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
27521 --
27522 if l_update then
27523 --
27524 l_datetrack_mode := r_EHS.datetrack_mode ;
27525 --
27526 get_dt_modes(
27527 p_effective_date => l_process_date,
27528 p_effective_end_date => r_EHS.information3,
27529 p_effective_start_date => r_EHS.information2,
27530 p_dml_operation => r_EHS.dml_operation,
27531 p_datetrack_mode => l_datetrack_mode );
27532 -- p_update => l_update
27533 --
27534 l_effective_date := l_process_date;
27535 l_ELIG_HRLY_SLRD_PRTE_ID := r_EHS.information1;
27536 l_object_version_number := r_EHS.information265;
27537 --
27538 end if;
27539 --
27540 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
27541 --
27542 IF l_update OR l_dml_operation <> 'UPDATE' THEN
27543 --UPD END
27544
27545
27546 BEN_ELIG_HRLY_SLRD_PRTE_API.UPDATE_ELIG_HRLY_SLRD_PRTE(
27547 --
27548 P_VALIDATE => false
27549 ,P_EFFECTIVE_DATE => l_effective_date
27550 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
27551 --
27552 ,P_EHS_ATTRIBUTE1 => r_EHS.INFORMATION111
27553 ,P_EHS_ATTRIBUTE10 => r_EHS.INFORMATION120
27554 ,P_EHS_ATTRIBUTE11 => r_EHS.INFORMATION121
27555 ,P_EHS_ATTRIBUTE12 => r_EHS.INFORMATION122
27556 ,P_EHS_ATTRIBUTE13 => r_EHS.INFORMATION123
27557 ,P_EHS_ATTRIBUTE14 => r_EHS.INFORMATION124
27558 ,P_EHS_ATTRIBUTE15 => r_EHS.INFORMATION125
27559 ,P_EHS_ATTRIBUTE16 => r_EHS.INFORMATION126
27560 ,P_EHS_ATTRIBUTE17 => r_EHS.INFORMATION127
27561 ,P_EHS_ATTRIBUTE18 => r_EHS.INFORMATION128
27562 ,P_EHS_ATTRIBUTE19 => r_EHS.INFORMATION129
27563 ,P_EHS_ATTRIBUTE2 => r_EHS.INFORMATION112
27564 ,P_EHS_ATTRIBUTE20 => r_EHS.INFORMATION130
27565 ,P_EHS_ATTRIBUTE21 => r_EHS.INFORMATION131
27566 ,P_EHS_ATTRIBUTE22 => r_EHS.INFORMATION132
27567 ,P_EHS_ATTRIBUTE23 => r_EHS.INFORMATION133
27568 ,P_EHS_ATTRIBUTE24 => r_EHS.INFORMATION134
27569 ,P_EHS_ATTRIBUTE25 => r_EHS.INFORMATION135
27570 ,P_EHS_ATTRIBUTE26 => r_EHS.INFORMATION136
27571 ,P_EHS_ATTRIBUTE27 => r_EHS.INFORMATION137
27572 ,P_EHS_ATTRIBUTE28 => r_EHS.INFORMATION138
27573 ,P_EHS_ATTRIBUTE29 => r_EHS.INFORMATION139
27574 ,P_EHS_ATTRIBUTE3 => r_EHS.INFORMATION113
27575 ,P_EHS_ATTRIBUTE30 => r_EHS.INFORMATION140
27576 ,P_EHS_ATTRIBUTE4 => r_EHS.INFORMATION114
27577 ,P_EHS_ATTRIBUTE5 => r_EHS.INFORMATION115
27578 ,P_EHS_ATTRIBUTE6 => r_EHS.INFORMATION116
27579 ,P_EHS_ATTRIBUTE7 => r_EHS.INFORMATION117
27580 ,P_EHS_ATTRIBUTE8 => r_EHS.INFORMATION118
27581 ,P_EHS_ATTRIBUTE9 => r_EHS.INFORMATION119
27582 ,P_EHS_ATTRIBUTE_CATEGORY => r_EHS.INFORMATION110
27583 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
27584 ,P_ELIG_HRLY_SLRD_PRTE_ID => l_elig_hrly_slrd_prte_id
27585 ,P_EXCLD_FLAG => r_EHS.INFORMATION12
27586 ,P_HRLY_SLRD_CD => r_EHS.INFORMATION11
27587 ,P_ORDR_NUM => r_EHS.INFORMATION260
27588 --
27589 -- ****** END CHANGE LINES
27590
27591 --
27592 ,P_EFFECTIVE_START_DATE => l_effective_start_date
27593 ,P_EFFECTIVE_END_DATE => l_effective_end_date
27594 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
27595 ,P_DATETRACK_MODE => l_datetrack_mode
27596 ,P_CRITERIA_SCORE => r_ehs.INFORMATION295
27597 ,P_CRITERIA_WEIGHT => r_ehs.INFORMATION296
27598 );
27599 end if; -- l_update
27600 --
27601 end if;
27602 --
27603 -- Delete the row if it is end dated.
27604 --
27605 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
27606 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
27607 trunc(l_max_eed) = trunc(r_EHS.information3)) then
27608 --
27609 BEN_ELIG_HRLY_SLRD_PRTE_API.delete_ELIG_HRLY_SLRD_PRTE(
27610 --
27611 p_validate => false
27612 ,p_elig_hrly_slrd_prte_id => l_elig_hrly_slrd_prte_id
27613 ,p_effective_start_date => l_effective_start_date
27614 ,p_effective_end_date => l_effective_end_date
27615 ,p_object_version_number => l_object_version_number
27616 ,p_effective_date => l_max_eed
27617 ,p_datetrack_mode => hr_api.g_delete
27618 --
27619 );
27620 --
27621 end if;
27622 --
27623 l_prev_pk_id := l_current_pk_id ;
27624 --
27625 end if;
27626 --
27627 end if;
27628 --
27629 end loop;
27630 --
27631 exception when others then
27632 --
27633 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EHS',r_EHS.information5 ) ;
27634 --
27635 end create_EHS_rows;
27636
27637 --
27638 ---------------------------------------------------------------
27639 ----------------------< create_ERG_rows >-----------------------
27640 ---------------------------------------------------------------
27641 --
27642 procedure create_ERG_rows
27643 (
27644 p_validate in number default 0
27645 ,p_copy_entity_txn_id in number
27646 ,p_effective_date in date
27647 ,p_prefix_suffix_text in varchar2 default null
27648 ,p_reuse_object_flag in varchar2 default null
27649 ,p_target_business_group_id in varchar2 default null
27650 ,p_prefix_suffix_cd in varchar2 default null
27651 ) is
27652 --
27653 l_ELIGY_PRFL_ID number;
27654 l_EVENT_TYPE ben_elig_perf_rtng_prte_f.event_type%type;
27655 l_ORDR_NUM ben_elig_perf_rtng_prte_f.ordr_num%type;
27656 l_PERF_RTNG_CD ben_elig_perf_rtng_prte_f.perf_rtng_cd%type;
27657
27658 cursor c_unique_ERG(l_table_alias varchar2) is
27659 select distinct cpe.information1,
27660 cpe.information2,
27661 cpe.information3,
27662 cpe.table_route_id
27663 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
27664 pqh_table_route tr
27665 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
27666 and cpe.table_route_id = tr.table_route_id
27667 -- and tr.where_clause = l_BEN_ELIG_PERF_RTNG_PRTE_F
27668 and tr.table_alias = l_table_alias
27669 and cpe.number_of_copies = 1 -- ADDITION
27670 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
27671 order by information1, information2; --added for bug: 5151945
27672 --
27673 --
27674 cursor c_ERG_min_max_dates(c_table_route_id number,
27675 c_information1 number) is
27676 select
27677 min(cpe.information2) min_esd,
27678 max(cpe.information3) min_eed
27679 from ben_copy_entity_results cpe
27680 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
27681 and cpe.table_route_id = c_table_route_id
27682 and cpe.information1 = c_information1 ;
27683 --
27684 cursor c_ERG(c_table_route_id number,
27685 c_information1 number,
27686 c_information2 date,
27687 c_information3 date ) is
27688 select
27689 cpe.*
27690 from ben_copy_entity_results cpe
27691 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
27692 and cpe.table_route_id = c_table_route_id
27693 and cpe.information1 = c_information1
27694 and cpe.information2 = c_information2
27695 and cpe.information3 = c_information3
27696 and rownum = 1 ;
27697 -- Date Track target record
27698 cursor c_find_ERG_in_target(
27699 c_effective_start_date date,
27700 c_effective_end_date date,
27701 c_business_group_id number,
27702 c_new_pk_id number) is
27703 select
27704 ERG.elig_perf_rtng_prte_id new_value
27705 from BEN_ELIG_PERF_RTNG_PRTE_F ERG
27706 where
27707 ERG.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
27708 ERG.EVENT_TYPE = l_EVENT_TYPE and
27709 ERG.ORDR_NUM = l_ORDR_NUM and
27710 ERG.PERF_RTNG_CD = l_PERF_RTNG_CD and
27711 ERG.business_group_id = c_business_group_id
27712 and ERG.elig_perf_rtng_prte_id <> c_new_pk_id
27713 and c_effective_start_date between effective_start_date
27714 and effective_end_date ;
27715 --END TEMPIK
27716 /*TEMPIK
27717 and exists ( select null
27718 from BEN_ELIG_PERF_RTNG_PRTE_F ERG1
27719 where
27720 ERG1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
27721 ERG1.EVENT_TYPE = l_EVENT_TYPE and
27722 ERG1.ORDR_NUM = l_ORDR_NUM and
27723 ERG1.PERF_RTNG_CD = l_PERF_RTNG_CD and
27724 ERG1.business_group_id = c_business_group_id
27725 and ERG1.effective_start_date <= c_effective_start_date )
27726 and exists ( select null
27727 from BEN_ELIG_PERF_RTNG_PRTE_F ERG2
27728 where
27729 ERG2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
27730 ERG2.EVENT_TYPE = l_EVENT_TYPE and
27731 ERG2.ORDR_NUM = l_ORDR_NUM and
27732 ERG2.PERF_RTNG_CD = l_PERF_RTNG_CD and
27733 ERG2.business_group_id = c_business_group_id
27734 and ERG2.effective_end_date >= c_effective_end_date )
27735 ;
27736 TEMPIK */
27737 --TEMPIK
27738 l_dt_rec_found boolean ;
27739 --END TEMPIK
27740 --
27741
27742 --UPD START
27743 --
27744 l_update boolean := false ;
27745 l_datetrack_mode varchar2(80) := hr_api.g_update;
27746 l_process_date date;
27747 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
27748 --
27749 --UPD END
27750 l_current_pk_id number := null ;
27751
27752 l_prev_pk_id number := null ;
27753 l_first_rec boolean := true ;
27754 r_ERG c_ERG%rowtype;
27755 l_elig_perf_rtng_prte_id number ;
27756 l_object_version_number number ;
27757 l_effective_start_date date ;
27758 l_effective_end_date date ;
27759 l_prefix pqh_copy_entity_attribs.information1%type := null;
27760 l_suffix pqh_copy_entity_attribs.information1%type := null;
27761 l_new_value number(15);
27762 l_object_found_in_target boolean := false ;
27763 l_min_esd date;
27764 l_max_eed date;
27765 l_effective_date date;
27766 --
27767 begin
27768 -- Initialization
27769 l_object_found_in_target := false ;
27770 -- End Initialization
27771 -- Derive the prefix - sufix
27772 if p_prefix_suffix_cd = 'PREFIX' then
27773 l_prefix := p_prefix_suffix_text ;
27774 elsif p_prefix_suffix_cd = 'SUFFIX' then
27775 l_suffix := p_prefix_suffix_text ;
27776 else
27777 l_prefix := null ;
27778 l_suffix := null ;
27779 end if ;
27780 -- End Prefix Sufix derivation
27781 for r_ERG_unique in c_unique_ERG('ERG') loop
27782
27783 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
27784 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
27785 r_ERG_unique.information3 >=
27786 ben_pd_copy_to_ben_one.g_copy_effective_date)
27787 ) then
27788 --
27789 hr_utility.set_location(' r_ERG_unique.table_route_id '||r_ERG_unique.table_route_id,10);
27790 hr_utility.set_location(' r_ERG_unique.information1 '||r_ERG_unique.information1,10);
27791 hr_utility.set_location( 'r_ERG_unique.information2 '||r_ERG_unique.information2,10);
27792 hr_utility.set_location( 'r_ERG_unique.information3 '||r_ERG_unique.information3,10);
27793 -- If reuse objects flag is 'Y' then check for the object in the target business group
27794 -- if found insert the record into PLSql table and exit the loop else try create the
27795 -- object in the target business group
27796 --
27797 l_object_found_in_target := false ;
27798 --UPD START
27799 l_update := false;
27800 l_process_date := p_effective_date;
27801 l_dml_operation:= r_ERG_unique.dml_operation ;
27802 --
27803 /**********************moved from below **********************/
27804 open c_ERG(r_ERG_unique.table_route_id,
27805 r_ERG_unique.information1,
27806 r_ERG_unique.information2,
27807 r_ERG_unique.information3 ) ;
27808 --
27809 fetch c_ERG into r_ERG ;
27810 --
27811 close c_ERG ;
27812 --
27813 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ERG.INFORMATION263,l_dml_operation);
27814 l_EVENT_TYPE := r_ERG.INFORMATION13;
27815 l_ORDR_NUM := r_ERG.INFORMATION257;
27816 l_PERF_RTNG_CD := r_ERG.INFORMATION12;
27817 /**********************************************************/
27818
27819 if l_dml_operation = 'UPDATE' then
27820 --
27821 l_object_found_in_target := TRUE;
27822 --
27823 if l_process_date between r_ERG_unique.information2 and r_ERG_unique.information3 then
27824 l_update := true;
27825 if r_ERG_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
27826 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PERF_RTNG_PRTE_ID' then
27827 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PERF_RTNG_PRTE_ID' ;
27828 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ERG_unique.information1 ;
27829 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ERG_unique.information1 ;
27830 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
27831 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ERG_unique.table_route_id;
27832 --
27833 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
27834 --
27835 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
27836 --
27837 -- log_data('ERG',l_new_value,l_prefix || r_ERG_unique.name|| l_suffix,'REUSED');
27838 --
27839 end if ;
27840 hr_utility.set_location( 'found record for update',10);
27841 --
27842 else
27843 --
27844 l_update := false;
27845 --
27846 end if;
27847 else
27848 --
27849 --UPD END
27850 l_min_esd := null ;
27851 l_max_eed := null ;
27852 open c_ERG_min_max_dates(r_ERG_unique.table_route_id, r_ERG_unique.information1 ) ;
27853 fetch c_ERG_min_max_dates into l_min_esd,l_max_eed ;
27854 --
27855
27856 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
27857 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
27858 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
27859 end if;
27860 l_min_esd := greatest(l_min_esd,r_ERG_unique.information2);
27861 /**********************moved up from here **********************
27862 open c_ERG(r_ERG_unique.table_route_id,
27863 r_ERG_unique.information1,
27864 r_ERG_unique.information2,
27865 r_ERG_unique.information3 ) ;
27866 --
27867 fetch c_ERG into r_ERG ;
27868 --
27869 close c_ERG ;
27870 --
27871 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ERG.INFORMATION263,l_dml_operation);
27872 l_EVENT_TYPE := r_ERG.INFORMATION13;
27873 l_ORDR_NUM := r_ERG.INFORMATION257;
27874 l_PERF_RTNG_CD := r_ERG.INFORMATION12;
27875 **********************************************************/
27876
27877
27878 if p_reuse_object_flag = 'Y' then
27879 if c_ERG_min_max_dates%found then
27880 -- cursor to find the object
27881 open c_find_ERG_in_target( l_min_esd,l_max_eed,
27882 p_target_business_group_id, nvl(l_elig_perf_rtng_prte_id, -999) ) ;
27883 fetch c_find_ERG_in_target into l_new_value ;
27884 if c_find_ERG_in_target%found then
27885 --
27886 --TEMPIK
27887 l_dt_rec_found := dt_api.check_min_max_dates
27888 (p_base_table_name => 'BEN_ELIG_PERF_RTNG_PRTE_F',
27889 p_base_key_column => 'ELIG_PERF_RTNG_PRTE_ID',
27890 p_base_key_value => l_new_value,
27891 p_from_date => l_min_esd,
27892 p_to_date => l_max_eed );
27893 if l_dt_rec_found THEN
27894 --END TEMPIK
27895 if r_ERG_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
27896 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_PERF_RTNG_PRTE_ID' then
27897 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PERF_RTNG_PRTE_ID' ;
27898 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ERG_unique.information1 ;
27899 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
27900 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
27901 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ERG_unique.table_route_id;
27902 --
27903 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
27904 --
27905 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
27906 end if ;
27907 --
27908 l_object_found_in_target := true ;
27909 --TEMPIK
27910 end if; -- l_dt_rec_found
27911 --END TEMPIK
27912 end if;
27913 close c_find_ERG_in_target ;
27914 --
27915 end if;
27916 end if ;
27917 --
27918 close c_ERG_min_max_dates ;
27919 end if; --if p_dml_operation
27920 --
27921 if not l_object_found_in_target OR l_update then
27922
27923 --
27924 l_current_pk_id := r_ERG.information1;
27925 --
27926 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
27927 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
27928 --
27929 if l_current_pk_id = l_prev_pk_id then
27930 --
27931 l_first_rec := false ;
27932 --
27933 else
27934 --
27935 l_first_rec := true ;
27936 --
27937 end if ;
27938 --
27939
27940 l_effective_date := r_ERG.information2;
27941 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
27942 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
27943 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
27944 end if;
27945
27946 if l_first_rec and not l_update then
27947 -- Call Create routine.
27948 hr_utility.set_location(' BEN_ELIG_PERF_RTNG_PRTE_F CREATE_ELIG_PERF_RTNG_PRTE ',20);
27949 BEN_ELIG_PERF_RTNG_PRTE_API.CREATE_ELIG_PERF_RTNG_PRTE(
27950 --
27951 P_VALIDATE => false
27952 ,P_EFFECTIVE_DATE => l_effective_date
27953 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
27954 --
27955 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
27956 ,P_ELIG_PERF_RTNG_PRTE_ID => l_elig_perf_rtng_prte_id
27957 ,P_ERG_ATTRIBUTE1 => r_ERG.INFORMATION111
27958 ,P_ERG_ATTRIBUTE10 => r_ERG.INFORMATION120
27959 ,P_ERG_ATTRIBUTE11 => r_ERG.INFORMATION121
27960 ,P_ERG_ATTRIBUTE12 => r_ERG.INFORMATION122
27961 ,P_ERG_ATTRIBUTE13 => r_ERG.INFORMATION123
27962 ,P_ERG_ATTRIBUTE14 => r_ERG.INFORMATION124
27963 ,P_ERG_ATTRIBUTE15 => r_ERG.INFORMATION125
27964 ,P_ERG_ATTRIBUTE16 => r_ERG.INFORMATION126
27965 ,P_ERG_ATTRIBUTE17 => r_ERG.INFORMATION127
27966 ,P_ERG_ATTRIBUTE18 => r_ERG.INFORMATION128
27967 ,P_ERG_ATTRIBUTE19 => r_ERG.INFORMATION129
27968 ,P_ERG_ATTRIBUTE2 => r_ERG.INFORMATION112
27969 ,P_ERG_ATTRIBUTE20 => r_ERG.INFORMATION130
27970 ,P_ERG_ATTRIBUTE21 => r_ERG.INFORMATION131
27971 ,P_ERG_ATTRIBUTE22 => r_ERG.INFORMATION132
27972 ,P_ERG_ATTRIBUTE23 => r_ERG.INFORMATION133
27973 ,P_ERG_ATTRIBUTE24 => r_ERG.INFORMATION134
27974 ,P_ERG_ATTRIBUTE25 => r_ERG.INFORMATION135
27975 ,P_ERG_ATTRIBUTE26 => r_ERG.INFORMATION136
27976 ,P_ERG_ATTRIBUTE27 => r_ERG.INFORMATION137
27977 ,P_ERG_ATTRIBUTE28 => r_ERG.INFORMATION138
27978 ,P_ERG_ATTRIBUTE29 => r_ERG.INFORMATION139
27979 ,P_ERG_ATTRIBUTE3 => r_ERG.INFORMATION113
27980 ,P_ERG_ATTRIBUTE30 => r_ERG.INFORMATION140
27981 ,P_ERG_ATTRIBUTE4 => r_ERG.INFORMATION114
27982 ,P_ERG_ATTRIBUTE5 => r_ERG.INFORMATION115
27983 ,P_ERG_ATTRIBUTE6 => r_ERG.INFORMATION116
27984 ,P_ERG_ATTRIBUTE7 => r_ERG.INFORMATION117
27985 ,P_ERG_ATTRIBUTE8 => r_ERG.INFORMATION118
27986 ,P_ERG_ATTRIBUTE9 => r_ERG.INFORMATION119
27987 ,P_ERG_ATTRIBUTE_CATEGORY => r_ERG.INFORMATION110
27988 ,P_EVENT_TYPE => r_ERG.INFORMATION13
27989 ,P_EXCLD_FLAG => r_ERG.INFORMATION11
27990 ,P_ORDR_NUM => r_ERG.INFORMATION257
27991 ,P_PERF_RTNG_CD => r_ERG.INFORMATION12
27992 --
27993 -- ****** END CHANGE LINES
27994
27995 --
27996
27997 ,P_EFFECTIVE_START_DATE => l_effective_start_date
27998 ,P_EFFECTIVE_END_DATE => l_effective_end_date
27999 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
28000 ,P_CRITERIA_SCORE => r_erg.INFORMATION295
28001 ,P_CRITERIA_WEIGHT => r_erg.INFORMATION296
28002 );
28003 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
28004 -- Update all relevent cer records with new pk_id
28005 hr_utility.set_location('Before plsql table ',222);
28006 hr_utility.set_location('new_value id '||l_elig_perf_rtng_prte_id,222);
28007 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_PERF_RTNG_PRTE_ID' ;
28008 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ERG.information1 ;
28009 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_PERF_RTNG_PRTE_ID ;
28010 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
28011 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ERG_unique.table_route_id;
28012 hr_utility.set_location('After plsql table ',222);
28013 --
28014 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
28015 --
28016 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
28017 --
28018 else
28019 --
28020 -- Call Update routine for the pk_id created in prev run .
28021 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
28022 hr_utility.set_location(' BEN_ELIG_PERF_RTNG_PRTE_F UPDATE_ELIG_PERF_RTNG_PRTE ',30);
28023 --UPD START
28024 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
28025 --
28026 if l_update then
28027 --
28028 l_datetrack_mode := r_ERG.datetrack_mode ;
28029 --
28030 get_dt_modes(
28031 p_effective_date => l_process_date,
28032 p_effective_end_date => r_ERG.information3,
28033 p_effective_start_date => r_ERG.information2,
28034 p_dml_operation => r_ERG.dml_operation,
28035 p_datetrack_mode => l_datetrack_mode );
28036 -- p_update => l_update
28037 --
28038 l_effective_date := l_process_date;
28039 l_ELIG_PERF_RTNG_PRTE_ID := r_ERG.information1;
28040 l_object_version_number := r_ERG.information265;
28041 --
28042 end if;
28043 --
28044 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
28045 --
28046 IF l_update OR l_dml_operation <> 'UPDATE' THEN
28047 --UPD END
28048
28049
28050 BEN_ELIG_PERF_RTNG_PRTE_API.UPDATE_ELIG_PERF_RTNG_PRTE(
28051 --
28052 P_VALIDATE => false
28053 ,P_EFFECTIVE_DATE => l_effective_date
28054 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
28055 --
28056 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
28057 ,P_ELIG_PERF_RTNG_PRTE_ID => l_elig_perf_rtng_prte_id
28058 ,P_ERG_ATTRIBUTE1 => r_ERG.INFORMATION111
28059 ,P_ERG_ATTRIBUTE10 => r_ERG.INFORMATION120
28060 ,P_ERG_ATTRIBUTE11 => r_ERG.INFORMATION121
28061 ,P_ERG_ATTRIBUTE12 => r_ERG.INFORMATION122
28062 ,P_ERG_ATTRIBUTE13 => r_ERG.INFORMATION123
28063 ,P_ERG_ATTRIBUTE14 => r_ERG.INFORMATION124
28064 ,P_ERG_ATTRIBUTE15 => r_ERG.INFORMATION125
28065 ,P_ERG_ATTRIBUTE16 => r_ERG.INFORMATION126
28066 ,P_ERG_ATTRIBUTE17 => r_ERG.INFORMATION127
28067 ,P_ERG_ATTRIBUTE18 => r_ERG.INFORMATION128
28068 ,P_ERG_ATTRIBUTE19 => r_ERG.INFORMATION129
28069 ,P_ERG_ATTRIBUTE2 => r_ERG.INFORMATION112
28070 ,P_ERG_ATTRIBUTE20 => r_ERG.INFORMATION130
28071 ,P_ERG_ATTRIBUTE21 => r_ERG.INFORMATION131
28072 ,P_ERG_ATTRIBUTE22 => r_ERG.INFORMATION132
28073 ,P_ERG_ATTRIBUTE23 => r_ERG.INFORMATION133
28074 ,P_ERG_ATTRIBUTE24 => r_ERG.INFORMATION134
28075 ,P_ERG_ATTRIBUTE25 => r_ERG.INFORMATION135
28076 ,P_ERG_ATTRIBUTE26 => r_ERG.INFORMATION136
28077 ,P_ERG_ATTRIBUTE27 => r_ERG.INFORMATION137
28078 ,P_ERG_ATTRIBUTE28 => r_ERG.INFORMATION138
28079 ,P_ERG_ATTRIBUTE29 => r_ERG.INFORMATION139
28080 ,P_ERG_ATTRIBUTE3 => r_ERG.INFORMATION113
28081 ,P_ERG_ATTRIBUTE30 => r_ERG.INFORMATION140
28082 ,P_ERG_ATTRIBUTE4 => r_ERG.INFORMATION114
28083 ,P_ERG_ATTRIBUTE5 => r_ERG.INFORMATION115
28084 ,P_ERG_ATTRIBUTE6 => r_ERG.INFORMATION116
28085 ,P_ERG_ATTRIBUTE7 => r_ERG.INFORMATION117
28086 ,P_ERG_ATTRIBUTE8 => r_ERG.INFORMATION118
28087 ,P_ERG_ATTRIBUTE9 => r_ERG.INFORMATION119
28088 ,P_ERG_ATTRIBUTE_CATEGORY => r_ERG.INFORMATION110
28089 ,P_EVENT_TYPE => r_ERG.INFORMATION13
28090 ,P_EXCLD_FLAG => r_ERG.INFORMATION11
28091 ,P_ORDR_NUM => r_ERG.INFORMATION257
28092 ,P_PERF_RTNG_CD => r_ERG.INFORMATION12
28093 --
28094 -- ****** END CHANGE LINES
28095
28096 --
28097 ,P_EFFECTIVE_START_DATE => l_effective_start_date
28098 ,P_EFFECTIVE_END_DATE => l_effective_end_date
28099 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
28100 ,P_DATETRACK_MODE => l_datetrack_mode
28101 ,P_CRITERIA_SCORE => r_erg.INFORMATION295
28102 ,P_CRITERIA_WEIGHT => r_erg.INFORMATION296
28103 );
28104 end if; -- l_update
28105 --
28106 end if;
28107 --
28108 -- Delete the row if it is end dated.
28109 --
28110 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
28111 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
28112 trunc(l_max_eed) = trunc(r_ERG.information3)) then
28113 --
28114 BEN_ELIG_PERF_RTNG_PRTE_API.delete_ELIG_PERF_RTNG_PRTE(
28115 --
28116 p_validate => false
28117 ,p_elig_perf_rtng_prte_id => l_elig_perf_rtng_prte_id
28118 ,p_effective_start_date => l_effective_start_date
28119 ,p_effective_end_date => l_effective_end_date
28120 ,p_object_version_number => l_object_version_number
28121 ,p_effective_date => l_max_eed
28122 ,p_datetrack_mode => hr_api.g_delete
28123 --
28124 );
28125 --
28126 end if;
28127 --
28128 l_prev_pk_id := l_current_pk_id ;
28129 --
28130 end if;
28131 --
28132 end if;
28133 --
28134 end loop;
28135 --
28136 exception when others then
28137 --
28138 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ERG',r_ERG.information5 ) ;
28139 --
28140 end create_ERG_rows;
28141
28142 --
28143 ---------------------------------------------------------------
28144 ----------------------< create_EQG_rows >-----------------------
28145 ---------------------------------------------------------------
28146 --
28147 procedure create_EQG_rows
28148 (
28149 p_validate in number default 0
28150 ,p_copy_entity_txn_id in number
28151 ,p_effective_date in date
28152 ,p_prefix_suffix_text in varchar2 default null
28153 ,p_reuse_object_flag in varchar2 default null
28154 ,p_target_business_group_id in varchar2 default null
28155 ,p_prefix_suffix_cd in varchar2 default null
28156 ) is
28157 --
28158 l_ELIGY_PRFL_ID number;
28159 l_QUAR_IN_GRADE_CD ben_elig_qua_in_gr_prte_f.quar_in_grade_cd%type;
28160 l_ORDR_NUM ben_elig_qua_in_gr_prte_f.ordr_num%type;
28161
28162 cursor c_unique_EQG(l_table_alias varchar2) is
28163 select distinct cpe.information1,
28164 cpe.information2,
28165 cpe.information3,
28166 cpe.table_route_id
28167 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
28168 pqh_table_route tr
28169 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
28170 and cpe.table_route_id = tr.table_route_id
28171 -- and tr.where_clause = l_BEN_ELIG_QUA_IN_GR_PRTE_F
28172 and tr.table_alias = l_table_alias
28173 and cpe.number_of_copies = 1 -- ADDITION
28174 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
28175 order by information1, information2; --added for bug: 5151945
28176 --
28177 --
28178 cursor c_EQG_min_max_dates(c_table_route_id number,
28179 c_information1 number) is
28180 select
28181 min(cpe.information2) min_esd,
28182 max(cpe.information3) min_eed
28183 from ben_copy_entity_results cpe
28184 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
28185 and cpe.table_route_id = c_table_route_id
28186 and cpe.information1 = c_information1 ;
28187 --
28188 cursor c_EQG(c_table_route_id number,
28189 c_information1 number,
28190 c_information2 date,
28191 c_information3 date ) is
28192 select
28193 cpe.*
28194 from ben_copy_entity_results cpe
28195 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
28196 and cpe.table_route_id = c_table_route_id
28197 and cpe.information1 = c_information1
28198 and cpe.information2 = c_information2
28199 and cpe.information3 = c_information3
28200 and rownum = 1 ;
28201 -- Date Track target record
28202 cursor c_find_EQG_in_target(
28203 c_effective_start_date date,
28204 c_effective_end_date date,
28205 c_business_group_id number,
28206 c_new_pk_id number) is
28207 select
28208 EQG.elig_qua_in_gr_prte_id new_value
28209 from BEN_ELIG_QUA_IN_GR_PRTE_F EQG
28210 where
28211 EQG.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
28212 EQG.QUAR_IN_GRADE_CD = l_QUAR_IN_GRADE_CD and
28213 EQG.ORDR_NUM = l_ORDR_NUM and
28214 EQG.business_group_id = c_business_group_id
28215 and EQG.elig_qua_in_gr_prte_id <> c_new_pk_id
28216 and c_effective_start_date between effective_start_date
28217 and effective_end_date ;
28218 --END TEMPIK
28219 /*TEMPIK
28220 and exists ( select null
28221 from BEN_ELIG_QUA_IN_GR_PRTE_F EQG1
28222 where
28223 EQG1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
28224 EQG1.QUAR_IN_GRADE_CD = l_QUAR_IN_GRADE_CD and
28225 EQG1.ORDR_NUM = l_ORDR_NUM and
28226 EQG1.business_group_id = c_business_group_id
28227 and EQG1.effective_start_date <= c_effective_start_date )
28228 and exists ( select null
28229 from BEN_ELIG_QUA_IN_GR_PRTE_F EQG2
28230 where
28231 EQG2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
28232 EQG2.QUAR_IN_GRADE_CD = l_QUAR_IN_GRADE_CD and
28233 EQG2.ORDR_NUM = l_ORDR_NUM and
28234 EQG2.business_group_id = c_business_group_id
28235 and EQG2.effective_end_date >= c_effective_end_date )
28236 ;
28237 TEMPIK */
28238 --TEMPIK
28239 l_dt_rec_found boolean ;
28240 --END TEMPIK
28241 --
28242
28243 --UPD START
28244 --
28245 l_update boolean := false ;
28246 l_datetrack_mode varchar2(80) := hr_api.g_update;
28247 l_process_date date;
28248 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
28249 --
28250 --UPD END
28251 l_current_pk_id number := null ;
28252
28253 l_prev_pk_id number := null ;
28254 l_first_rec boolean := true ;
28255 r_EQG c_EQG%rowtype;
28256 l_elig_qua_in_gr_prte_id number ;
28257 l_object_version_number number ;
28258 l_effective_start_date date ;
28259 l_effective_end_date date ;
28260 l_prefix pqh_copy_entity_attribs.information1%type := null;
28261 l_suffix pqh_copy_entity_attribs.information1%type := null;
28262 l_new_value number(15);
28263 l_object_found_in_target boolean := false ;
28264 l_min_esd date;
28265 l_max_eed date;
28266 l_effective_date date;
28267 --
28268 begin
28269 -- Initialization
28270 l_object_found_in_target := false ;
28271 -- End Initialization
28272 -- Derive the prefix - sufix
28273 if p_prefix_suffix_cd = 'PREFIX' then
28274 l_prefix := p_prefix_suffix_text ;
28275 elsif p_prefix_suffix_cd = 'SUFFIX' then
28276 l_suffix := p_prefix_suffix_text ;
28277 else
28278 l_prefix := null ;
28279 l_suffix := null ;
28280 end if ;
28281 -- End Prefix Sufix derivation
28282 for r_EQG_unique in c_unique_EQG('EQG') loop
28283
28284 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
28285 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
28286 r_EQG_unique.information3 >=
28287 ben_pd_copy_to_ben_one.g_copy_effective_date)
28288 ) then
28289 --
28290 hr_utility.set_location(' r_EQG_unique.table_route_id '||r_EQG_unique.table_route_id,10);
28291 hr_utility.set_location(' r_EQG_unique.information1 '||r_EQG_unique.information1,10);
28292 hr_utility.set_location( 'r_EQG_unique.information2 '||r_EQG_unique.information2,10);
28293 hr_utility.set_location( 'r_EQG_unique.information3 '||r_EQG_unique.information3,10);
28294 -- If reuse objects flag is 'Y' then check for the object in the target business group
28295 -- if found insert the record into PLSql table and exit the loop else try create the
28296 -- object in the target business group
28297 --
28298 l_object_found_in_target := false ;
28299 --UPD START
28300 l_update := false;
28301 l_process_date := p_effective_date;
28302 l_dml_operation:= r_EQG_unique.dml_operation ;
28303 --
28304 /**********************moved from below **********************/
28305 open c_EQG(r_EQG_unique.table_route_id,
28306 r_EQG_unique.information1,
28307 r_EQG_unique.information2,
28308 r_EQG_unique.information3 ) ;
28309 --
28310 fetch c_EQG into r_EQG ;
28311 --
28312 close c_EQG ;
28313 --
28314 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EQG.INFORMATION263,l_dml_operation);
28315 l_QUAR_IN_GRADE_CD := r_EQG.INFORMATION11;
28316 l_ORDR_NUM := r_EQG.INFORMATION260;
28317 /**********************************************************/
28318
28319 if l_dml_operation = 'UPDATE' then
28320 --
28321 l_object_found_in_target := TRUE;
28322 --
28323 if l_process_date between r_EQG_unique.information2 and r_EQG_unique.information3 then
28324 l_update := true;
28325 if r_EQG_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
28326 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_QUA_IN_GR_PRTE_ID' then
28327 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_QUA_IN_GR_PRTE_ID' ;
28328 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EQG_unique.information1 ;
28329 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EQG_unique.information1 ;
28330 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
28331 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EQG_unique.table_route_id;
28332 --
28333 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
28334 --
28335 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
28336 --
28337 -- log_data('EQG',l_new_value,l_prefix || r_EQG_unique.name|| l_suffix,'REUSED');
28338 --
28339 end if ;
28340 hr_utility.set_location( 'found record for update',10);
28341 --
28342 else
28343 --
28344 l_update := false;
28345 --
28346 end if;
28347 else
28348 --
28349 --UPD END
28350 l_min_esd := null ;
28351 l_max_eed := null ;
28352 open c_EQG_min_max_dates(r_EQG_unique.table_route_id, r_EQG_unique.information1 ) ;
28353 fetch c_EQG_min_max_dates into l_min_esd,l_max_eed ;
28354 --
28355
28356 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
28357 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
28358 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
28359 end if;
28360 l_min_esd := greatest(l_min_esd,r_EQG_unique.information2);
28361 /**********************moved up from here **********************
28362 open c_EQG(r_EQG_unique.table_route_id,
28363 r_EQG_unique.information1,
28364 r_EQG_unique.information2,
28365 r_EQG_unique.information3 ) ;
28366 --
28367 fetch c_EQG into r_EQG ;
28368 --
28369 close c_EQG ;
28370 --
28371 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EQG.INFORMATION263,l_dml_operation);
28372 l_QUAR_IN_GRADE_CD := r_EQG.INFORMATION11;
28373 l_ORDR_NUM := r_EQG.INFORMATION260;
28374 **********************************************************/
28375
28376
28377 if p_reuse_object_flag = 'Y' then
28378 if c_EQG_min_max_dates%found then
28379 -- cursor to find the object
28380 open c_find_EQG_in_target( l_min_esd,l_max_eed,
28381 p_target_business_group_id, nvl(l_elig_qua_in_gr_prte_id, -999) ) ;
28382 fetch c_find_EQG_in_target into l_new_value ;
28383 if c_find_EQG_in_target%found then
28384 --
28385 --TEMPIK
28386 l_dt_rec_found := dt_api.check_min_max_dates
28387 (p_base_table_name => 'BEN_ELIG_QUA_IN_GR_PRTE_F',
28388 p_base_key_column => 'ELIG_QUA_IN_GR_PRTE_ID',
28389 p_base_key_value => l_new_value,
28390 p_from_date => l_min_esd,
28391 p_to_date => l_max_eed );
28392 if l_dt_rec_found THEN
28393 --END TEMPIK
28394 if r_EQG_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
28395 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_QUA_IN_GR_PRTE_ID' then
28396 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_QUA_IN_GR_PRTE_ID' ;
28397 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EQG_unique.information1 ;
28398 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
28399 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
28400 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EQG_unique.table_route_id;
28401 --
28402 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
28403 --
28404 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
28405 end if ;
28406 --
28407 l_object_found_in_target := true ;
28408 --TEMPIK
28409 end if; -- l_dt_rec_found
28410 --END TEMPIK
28411 end if;
28412 close c_find_EQG_in_target ;
28413 --
28414 end if;
28415 end if ;
28416 --
28417 close c_EQG_min_max_dates ;
28418 end if; --if p_dml_operation
28419 --
28420 if not l_object_found_in_target OR l_update then
28421
28422 --
28423 l_current_pk_id := r_EQG.information1;
28424 --
28425 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
28426 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
28427 --
28428 if l_current_pk_id = l_prev_pk_id then
28429 --
28430 l_first_rec := false ;
28431 --
28432 else
28433 --
28434 l_first_rec := true ;
28435 --
28436 end if ;
28437 --
28438
28439 l_effective_date := r_EQG.information2;
28440 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
28441 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
28442 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
28443 end if;
28444
28445 if l_first_rec and not l_update then
28446 -- Call Create routine.
28447 hr_utility.set_location(' BEN_ELIG_QUA_IN_GR_PRTE_F CREATE_ELIG_QUA_IN_GR_PRTE ',20);
28448 BEN_ELIG_QUA_IN_GR_PRTE_API.CREATE_ELIG_QUA_IN_GR_PRTE(
28449 --
28450 P_VALIDATE => false
28451 ,P_EFFECTIVE_DATE => l_effective_date
28452 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
28453 --
28454 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
28455 ,P_ELIG_QUA_IN_GR_PRTE_ID => l_elig_qua_in_gr_prte_id
28456 ,P_EQG_ATTRIBUTE1 => r_EQG.INFORMATION111
28457 ,P_EQG_ATTRIBUTE10 => r_EQG.INFORMATION120
28458 ,P_EQG_ATTRIBUTE11 => r_EQG.INFORMATION121
28459 ,P_EQG_ATTRIBUTE12 => r_EQG.INFORMATION122
28460 ,P_EQG_ATTRIBUTE13 => r_EQG.INFORMATION123
28461 ,P_EQG_ATTRIBUTE14 => r_EQG.INFORMATION124
28462 ,P_EQG_ATTRIBUTE15 => r_EQG.INFORMATION125
28463 ,P_EQG_ATTRIBUTE16 => r_EQG.INFORMATION126
28464 ,P_EQG_ATTRIBUTE17 => r_EQG.INFORMATION127
28465 ,P_EQG_ATTRIBUTE18 => r_EQG.INFORMATION128
28466 ,P_EQG_ATTRIBUTE19 => r_EQG.INFORMATION129
28467 ,P_EQG_ATTRIBUTE2 => r_EQG.INFORMATION112
28468 ,P_EQG_ATTRIBUTE20 => r_EQG.INFORMATION130
28469 ,P_EQG_ATTRIBUTE21 => r_EQG.INFORMATION131
28470 ,P_EQG_ATTRIBUTE22 => r_EQG.INFORMATION132
28471 ,P_EQG_ATTRIBUTE23 => r_EQG.INFORMATION133
28472 ,P_EQG_ATTRIBUTE24 => r_EQG.INFORMATION134
28473 ,P_EQG_ATTRIBUTE25 => r_EQG.INFORMATION135
28474 ,P_EQG_ATTRIBUTE26 => r_EQG.INFORMATION136
28475 ,P_EQG_ATTRIBUTE27 => r_EQG.INFORMATION137
28476 ,P_EQG_ATTRIBUTE28 => r_EQG.INFORMATION138
28477 ,P_EQG_ATTRIBUTE29 => r_EQG.INFORMATION139
28478 ,P_EQG_ATTRIBUTE3 => r_EQG.INFORMATION113
28479 ,P_EQG_ATTRIBUTE30 => r_EQG.INFORMATION140
28480 ,P_EQG_ATTRIBUTE4 => r_EQG.INFORMATION114
28481 ,P_EQG_ATTRIBUTE5 => r_EQG.INFORMATION115
28482 ,P_EQG_ATTRIBUTE6 => r_EQG.INFORMATION116
28483 ,P_EQG_ATTRIBUTE7 => r_EQG.INFORMATION117
28484 ,P_EQG_ATTRIBUTE8 => r_EQG.INFORMATION118
28485 ,P_EQG_ATTRIBUTE9 => r_EQG.INFORMATION119
28486 ,P_EQG_ATTRIBUTE_CATEGORY => r_EQG.INFORMATION110
28487 ,P_EXCLD_FLAG => r_EQG.INFORMATION12
28488 ,P_ORDR_NUM => r_EQG.INFORMATION260
28489 ,P_QUAR_IN_GRADE_CD => r_EQG.INFORMATION11
28490 --
28491 -- ****** END CHANGE LINES
28492
28493 --
28494
28495 ,P_EFFECTIVE_START_DATE => l_effective_start_date
28496 ,P_EFFECTIVE_END_DATE => l_effective_end_date
28497 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
28498 ,P_CRITERIA_SCORE => r_eqg.INFORMATION295
28499 ,P_CRITERIA_WEIGHT => r_eqg.INFORMATION296
28500 );
28501 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
28502 -- Update all relevent cer records with new pk_id
28503 hr_utility.set_location('Before plsql table ',222);
28504 hr_utility.set_location('new_value id '||l_elig_qua_in_gr_prte_id,222);
28505 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_QUA_IN_GR_PRTE_ID' ;
28506 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EQG.information1 ;
28507 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_QUA_IN_GR_PRTE_ID ;
28508 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
28509 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EQG_unique.table_route_id;
28510 hr_utility.set_location('After plsql table ',222);
28511 --
28512 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
28513 --
28514 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
28515 --
28516 else
28517 --
28518 -- Call Update routine for the pk_id created in prev run .
28519 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
28520 hr_utility.set_location(' BEN_ELIG_QUA_IN_GR_PRTE_F UPDATE_ELIG_QUA_IN_GR_PRTE ',30);
28521 --UPD START
28522 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
28523 --
28524 if l_update then
28525 --
28526 l_datetrack_mode := r_EQG.datetrack_mode ;
28527 --
28528 get_dt_modes(
28529 p_effective_date => l_process_date,
28530 p_effective_end_date => r_EQG.information3,
28531 p_effective_start_date => r_EQG.information2,
28532 p_dml_operation => r_EQG.dml_operation,
28533 p_datetrack_mode => l_datetrack_mode );
28534 -- p_update => l_update
28535 --
28536 l_effective_date := l_process_date;
28537 l_ELIG_QUA_IN_GR_PRTE_ID := r_EQG.information1;
28538 l_object_version_number := r_EQG.information265;
28539 --
28540 end if;
28541 --
28542 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
28543 --
28544 IF l_update OR l_dml_operation <> 'UPDATE' THEN
28545 --UPD END
28546
28547
28548 BEN_ELIG_QUA_IN_GR_PRTE_API.UPDATE_ELIG_QUA_IN_GR_PRTE(
28549 --
28550 P_VALIDATE => false
28551 ,P_EFFECTIVE_DATE => l_effective_date
28552 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
28553 --
28554 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
28555 ,P_ELIG_QUA_IN_GR_PRTE_ID => l_elig_qua_in_gr_prte_id
28556 ,P_EQG_ATTRIBUTE1 => r_EQG.INFORMATION111
28557 ,P_EQG_ATTRIBUTE10 => r_EQG.INFORMATION120
28558 ,P_EQG_ATTRIBUTE11 => r_EQG.INFORMATION121
28559 ,P_EQG_ATTRIBUTE12 => r_EQG.INFORMATION122
28560 ,P_EQG_ATTRIBUTE13 => r_EQG.INFORMATION123
28561 ,P_EQG_ATTRIBUTE14 => r_EQG.INFORMATION124
28562 ,P_EQG_ATTRIBUTE15 => r_EQG.INFORMATION125
28563 ,P_EQG_ATTRIBUTE16 => r_EQG.INFORMATION126
28564 ,P_EQG_ATTRIBUTE17 => r_EQG.INFORMATION127
28565 ,P_EQG_ATTRIBUTE18 => r_EQG.INFORMATION128
28566 ,P_EQG_ATTRIBUTE19 => r_EQG.INFORMATION129
28567 ,P_EQG_ATTRIBUTE2 => r_EQG.INFORMATION112
28568 ,P_EQG_ATTRIBUTE20 => r_EQG.INFORMATION130
28569 ,P_EQG_ATTRIBUTE21 => r_EQG.INFORMATION131
28570 ,P_EQG_ATTRIBUTE22 => r_EQG.INFORMATION132
28571 ,P_EQG_ATTRIBUTE23 => r_EQG.INFORMATION133
28572 ,P_EQG_ATTRIBUTE24 => r_EQG.INFORMATION134
28573 ,P_EQG_ATTRIBUTE25 => r_EQG.INFORMATION135
28574 ,P_EQG_ATTRIBUTE26 => r_EQG.INFORMATION136
28575 ,P_EQG_ATTRIBUTE27 => r_EQG.INFORMATION137
28576 ,P_EQG_ATTRIBUTE28 => r_EQG.INFORMATION138
28577 ,P_EQG_ATTRIBUTE29 => r_EQG.INFORMATION139
28578 ,P_EQG_ATTRIBUTE3 => r_EQG.INFORMATION113
28579 ,P_EQG_ATTRIBUTE30 => r_EQG.INFORMATION140
28580 ,P_EQG_ATTRIBUTE4 => r_EQG.INFORMATION114
28581 ,P_EQG_ATTRIBUTE5 => r_EQG.INFORMATION115
28582 ,P_EQG_ATTRIBUTE6 => r_EQG.INFORMATION116
28583 ,P_EQG_ATTRIBUTE7 => r_EQG.INFORMATION117
28584 ,P_EQG_ATTRIBUTE8 => r_EQG.INFORMATION118
28585 ,P_EQG_ATTRIBUTE9 => r_EQG.INFORMATION119
28586 ,P_EQG_ATTRIBUTE_CATEGORY => r_EQG.INFORMATION110
28587 ,P_EXCLD_FLAG => r_EQG.INFORMATION12
28588 ,P_ORDR_NUM => r_EQG.INFORMATION260
28589 ,P_QUAR_IN_GRADE_CD => r_EQG.INFORMATION11
28590 --
28591 -- ****** END CHANGE LINES
28592
28593 --
28594 ,P_EFFECTIVE_START_DATE => l_effective_start_date
28595 ,P_EFFECTIVE_END_DATE => l_effective_end_date
28596 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
28597 ,P_DATETRACK_MODE => l_datetrack_mode
28598 ,P_CRITERIA_SCORE => r_eqg.INFORMATION295
28599 ,P_CRITERIA_WEIGHT => r_eqg.INFORMATION296
28600 );
28601 end if; -- l_update
28602 --
28603 end if;
28604 --
28605 -- Delete the row if it is end dated.
28606 --
28607 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
28608 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
28609 trunc(l_max_eed) = trunc(r_EQG.information3)) then
28610 --
28611 BEN_ELIG_QUA_IN_GR_PRTE_API.delete_ELIG_QUA_IN_GR_PRTE(
28612 --
28613 p_validate => false
28614 ,p_elig_qua_in_gr_prte_id => l_elig_qua_in_gr_prte_id
28615 ,p_effective_start_date => l_effective_start_date
28616 ,p_effective_end_date => l_effective_end_date
28617 ,p_object_version_number => l_object_version_number
28618 ,p_effective_date => l_max_eed
28619 ,p_datetrack_mode => hr_api.g_delete
28620 --
28621 );
28622 --
28623 end if;
28624 --
28625 l_prev_pk_id := l_current_pk_id ;
28626 --
28627 end if;
28628 --
28629 end if;
28630 --
28631 end loop;
28632 --
28633 exception when others then
28634 --
28635 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EQG',r_EQG.information5 ) ;
28636 --
28637 end create_EQG_rows;
28638
28639 --
28640 ---------------------------------------------------------------
28641 ----------------------< create_EGN_rows >-----------------------
28642 ---------------------------------------------------------------
28643 --
28644 procedure create_EGN_rows
28645 (
28646 p_validate in number default 0
28647 ,p_copy_entity_txn_id in number
28648 ,p_effective_date in date
28649 ,p_prefix_suffix_text in varchar2 default null
28650 ,p_reuse_object_flag in varchar2 default null
28651 ,p_target_business_group_id in varchar2 default null
28652 ,p_prefix_suffix_cd in varchar2 default null
28653 ) is
28654 --
28655 l_ELIGY_PRFL_ID number;
28656 l_SEX ben_elig_gndr_prte_f.sex%type;
28657 l_ORDR_NUM ben_elig_gndr_prte_f.ordr_num%type;
28658 cursor c_unique_EGN(l_table_alias varchar2) is
28659 select distinct cpe.information1,
28660 cpe.information2,
28661 cpe.information3,
28662 cpe.table_route_id
28663 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
28664 pqh_table_route tr
28665 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
28666 and cpe.table_route_id = tr.table_route_id
28667 -- and tr.where_clause = l_BEN_ELIG_GNDR_PRTE_F
28668 and tr.table_alias = l_table_alias
28669 and cpe.number_of_copies = 1 -- ADDITION
28670 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
28671 order by information1, information2; --added for bug: 5151945
28672 --
28673 --
28674 cursor c_EGN_min_max_dates(c_table_route_id number,
28675 c_information1 number) is
28676 select
28677 min(cpe.information2) min_esd,
28678 max(cpe.information3) min_eed
28679 from ben_copy_entity_results cpe
28680 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
28681 and cpe.table_route_id = c_table_route_id
28682 and cpe.information1 = c_information1 ;
28683 --
28684 cursor c_EGN(c_table_route_id number,
28685 c_information1 number,
28686 c_information2 date,
28687 c_information3 date ) is
28688 select
28689 cpe.*
28690 from ben_copy_entity_results cpe
28691 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
28692 and cpe.table_route_id = c_table_route_id
28693 and cpe.information1 = c_information1
28694 and cpe.information2 = c_information2
28695 and cpe.information3 = c_information3
28696 and rownum = 1 ;
28697 -- Date Track target record
28698 cursor c_find_EGN_in_target(
28699 c_effective_start_date date,
28700 c_effective_end_date date,
28701 c_business_group_id number,
28702 c_new_pk_id number) is
28703 select
28704 EGN.elig_gndr_prte_id new_value
28705 from BEN_ELIG_GNDR_PRTE_F EGN
28706 where
28707 EGN.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
28708 EGN.sex = l_SEX and
28709 EGN.ordr_num = l_ORDR_NUM and
28710 EGN.business_group_id = c_business_group_id
28711 and EGN.elig_gndr_prte_id <> c_new_pk_id
28712 and c_effective_start_date between effective_start_date
28713 and effective_end_date ;
28714 --END TEMPIK
28715 /*TEMPIK
28716 and exists ( select null
28717 from BEN_ELIG_GNDR_PRTE_F EGN1
28718 where
28719 EGN1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
28720 EGN1.sex = l_SEX and
28721 EGN1.ordr_num = l_ORDR_NUM and
28722 EGN1.business_group_id = c_business_group_id
28723 and EGN1.effective_start_date <= c_effective_start_date )
28724 and exists ( select null
28725 from BEN_ELIG_GNDR_PRTE_F EGN2
28726 where
28727 EGN2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
28728 EGN2.sex = l_SEX and
28729 EGN2.ordr_num = l_ORDR_NUM and
28730 EGN2.business_group_id = c_business_group_id
28731 and EGN2.effective_end_date >= c_effective_end_date )
28732 ;
28733 TEMPIK */
28734 --TEMPIK
28735 l_dt_rec_found boolean ;
28736 --END TEMPIK
28737 --
28738
28739 --UPD START
28740 --
28741 l_update boolean := false ;
28742 l_datetrack_mode varchar2(80) := hr_api.g_update;
28743 l_process_date date;
28744 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
28745 --
28746 --UPD END
28747 l_current_pk_id number := null ;
28748
28749 l_prev_pk_id number := null ;
28750 l_first_rec boolean := true ;
28751 r_EGN c_EGN%rowtype;
28752 l_elig_gndr_prte_id number ;
28753 l_object_version_number number ;
28754 l_effective_start_date date ;
28755 l_effective_end_date date ;
28756 l_prefix pqh_copy_entity_attribs.information1%type := null;
28757 l_suffix pqh_copy_entity_attribs.information1%type := null;
28758 l_new_value number(15);
28759 l_object_found_in_target boolean := false ;
28760 l_min_esd date;
28761 l_max_eed date;
28762 l_effective_date date;
28763 --
28764 begin
28765 -- Initialization
28766 l_object_found_in_target := false ;
28767 -- End Initialization
28768 -- Derive the prefix - sufix
28769 if p_prefix_suffix_cd = 'PREFIX' then
28770 l_prefix := p_prefix_suffix_text ;
28771 elsif p_prefix_suffix_cd = 'SUFFIX' then
28772 l_suffix := p_prefix_suffix_text ;
28773 else
28774 l_prefix := null ;
28775 l_suffix := null ;
28776 end if ;
28777 -- End Prefix Sufix derivation
28778 for r_EGN_unique in c_unique_EGN('EGN') loop
28779
28780 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
28781 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
28782 r_EGN_unique.information3 >=
28783 ben_pd_copy_to_ben_one.g_copy_effective_date)
28784 ) then
28785 --
28786 hr_utility.set_location(' r_EGN_unique.table_route_id '||r_EGN_unique.table_route_id,10);
28787 hr_utility.set_location(' r_EGN_unique.information1 '||r_EGN_unique.information1,10);
28788 hr_utility.set_location( 'r_EGN_unique.information2 '||r_EGN_unique.information2,10);
28789 hr_utility.set_location( 'r_EGN_unique.information3 '||r_EGN_unique.information3,10);
28790 -- If reuse objects flag is 'Y' then check for the object in the target business group
28791 -- if found insert the record into PLSql table and exit the loop else try create the
28792 -- object in the target business group
28793 --
28794 l_object_found_in_target := false ;
28795 --UPD START
28796 l_update := false;
28797 l_process_date := p_effective_date;
28798 l_dml_operation:= r_EGN_unique.dml_operation ;
28799 --
28800 /**********************moved from below **********************/
28801 open c_EGN(r_EGN_unique.table_route_id,
28802 r_EGN_unique.information1,
28803 r_EGN_unique.information2,
28804 r_EGN_unique.information3 ) ;
28805 --
28806 fetch c_EGN into r_EGN ;
28807 --
28808 close c_EGN ;
28809 --
28810 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EGN.INFORMATION263,l_dml_operation);
28811 l_SEX := r_EGN.INFORMATION11;
28812 l_ORDR_NUM := r_EGN.INFORMATION257;
28813
28814 /**********************************************************/
28815
28816 if l_dml_operation = 'UPDATE' then
28817 --
28818 l_object_found_in_target := TRUE;
28819 --
28820 if l_process_date between r_EGN_unique.information2 and r_EGN_unique.information3 then
28821 l_update := true;
28822 if r_EGN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
28823 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_GNDR_PRTE_ID' then
28824 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_GNDR_PRTE_ID' ;
28825 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EGN_unique.information1 ;
28826 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EGN_unique.information1 ;
28827 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
28828 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EGN_unique.table_route_id;
28829 --
28830 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
28831 --
28832 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
28833 --
28834 -- log_data('EGN',l_new_value,l_prefix || r_EGN_unique.name|| l_suffix,'REUSED');
28835 --
28836 end if ;
28837 hr_utility.set_location( 'found record for update',10);
28838 --
28839 else
28840 --
28841 l_update := false;
28842 --
28843 end if;
28844 else
28845 --
28846 --UPD END
28847 l_min_esd := null ;
28848 l_max_eed := null ;
28849 open c_EGN_min_max_dates(r_EGN_unique.table_route_id, r_EGN_unique.information1 ) ;
28850 fetch c_EGN_min_max_dates into l_min_esd,l_max_eed ;
28851 --
28852
28853 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
28854 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
28855 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
28856 end if;
28857 l_min_esd := greatest(l_min_esd,r_EGN_unique.information2);
28858 /**********************moved up from here **********************
28859 open c_EGN(r_EGN_unique.table_route_id,
28860 r_EGN_unique.information1,
28861 r_EGN_unique.information2,
28862 r_EGN_unique.information3 ) ;
28863 --
28864 fetch c_EGN into r_EGN ;
28865 --
28866 close c_EGN ;
28867 --
28868 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EGN.INFORMATION263,l_dml_operation);
28869 l_SEX := r_EGN.INFORMATION11;
28870 l_ORDR_NUM := r_EGN.INFORMATION257;
28871
28872 **********************************************************/
28873
28874
28875 if p_reuse_object_flag = 'Y' then
28876 if c_EGN_min_max_dates%found then
28877 -- cursor to find the object
28878 open c_find_EGN_in_target( l_min_esd,l_max_eed,
28879 p_target_business_group_id, nvl(l_elig_gndr_prte_id, -999) ) ;
28880 fetch c_find_EGN_in_target into l_new_value ;
28881 if c_find_EGN_in_target%found then
28882 --
28883 --TEMPIK
28884 l_dt_rec_found := dt_api.check_min_max_dates
28885 (p_base_table_name => 'BEN_ELIG_GNDR_PRTE_F',
28886 p_base_key_column => 'ELIG_GNDR_PRTE_ID',
28887 p_base_key_value => l_new_value,
28888 p_from_date => l_min_esd,
28889 p_to_date => l_max_eed );
28890 if l_dt_rec_found THEN
28891 --END TEMPIK
28892 if r_EGN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
28893 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_GNDR_PRTE_ID' then
28894 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_GNDR_PRTE_ID' ;
28895 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EGN_unique.information1 ;
28896 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
28897 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
28898 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EGN_unique.table_route_id;
28899 --
28900 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
28901 --
28902 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
28903 end if ;
28904 --
28905 l_object_found_in_target := true ;
28906 --TEMPIK
28907 end if; -- l_dt_rec_found
28908 --END TEMPIK
28909 end if;
28910 close c_find_EGN_in_target ;
28911 --
28912 end if;
28913 end if ;
28914 --
28915 close c_EGN_min_max_dates ;
28916 end if; --if p_dml_operation
28917 --
28918 if not l_object_found_in_target OR l_update then
28919
28920 --
28921 l_current_pk_id := r_EGN.information1;
28922 --
28923 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
28924 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
28925 --
28926 if l_current_pk_id = l_prev_pk_id then
28927 --
28928 l_first_rec := false ;
28929 --
28930 else
28931 --
28932 l_first_rec := true ;
28933 --
28934 end if ;
28935 --
28936
28937 l_effective_date := r_EGN.information2;
28938 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
28939 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
28940 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
28941 end if;
28942
28943 if l_first_rec and not l_update then
28944 -- Call Create routine.
28945 hr_utility.set_location(' BEN_ELIG_GNDR_PRTE_F CREATE_ELIG_GNDR_PRTE ',20);
28946 BEN_ELIG_GNDR_PRTE_API.CREATE_ELIG_GNDR_PRTE(
28947 --
28948 P_VALIDATE => false
28949 ,P_EFFECTIVE_DATE => l_effective_date
28950 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
28951 --
28952 ,P_EGN_ATTRIBUTE1 => r_EGN.INFORMATION111
28953 ,P_EGN_ATTRIBUTE10 => r_EGN.INFORMATION120
28954 ,P_EGN_ATTRIBUTE11 => r_EGN.INFORMATION121
28955 ,P_EGN_ATTRIBUTE12 => r_EGN.INFORMATION122
28956 ,P_EGN_ATTRIBUTE13 => r_EGN.INFORMATION123
28957 ,P_EGN_ATTRIBUTE14 => r_EGN.INFORMATION124
28958 ,P_EGN_ATTRIBUTE15 => r_EGN.INFORMATION125
28959 ,P_EGN_ATTRIBUTE16 => r_EGN.INFORMATION126
28960 ,P_EGN_ATTRIBUTE17 => r_EGN.INFORMATION127
28961 ,P_EGN_ATTRIBUTE18 => r_EGN.INFORMATION128
28962 ,P_EGN_ATTRIBUTE19 => r_EGN.INFORMATION129
28963 ,P_EGN_ATTRIBUTE2 => r_EGN.INFORMATION112
28964 ,P_EGN_ATTRIBUTE20 => r_EGN.INFORMATION130
28965 ,P_EGN_ATTRIBUTE21 => r_EGN.INFORMATION131
28966 ,P_EGN_ATTRIBUTE22 => r_EGN.INFORMATION132
28967 ,P_EGN_ATTRIBUTE23 => r_EGN.INFORMATION133
28968 ,P_EGN_ATTRIBUTE24 => r_EGN.INFORMATION134
28969 ,P_EGN_ATTRIBUTE25 => r_EGN.INFORMATION135
28970 ,P_EGN_ATTRIBUTE26 => r_EGN.INFORMATION136
28971 ,P_EGN_ATTRIBUTE27 => r_EGN.INFORMATION137
28972 ,P_EGN_ATTRIBUTE28 => r_EGN.INFORMATION138
28973 ,P_EGN_ATTRIBUTE29 => r_EGN.INFORMATION139
28974 ,P_EGN_ATTRIBUTE3 => r_EGN.INFORMATION113
28975 ,P_EGN_ATTRIBUTE30 => r_EGN.INFORMATION140
28976 ,P_EGN_ATTRIBUTE4 => r_EGN.INFORMATION114
28977 ,P_EGN_ATTRIBUTE5 => r_EGN.INFORMATION115
28978 ,P_EGN_ATTRIBUTE6 => r_EGN.INFORMATION116
28979 ,P_EGN_ATTRIBUTE7 => r_EGN.INFORMATION117
28980 ,P_EGN_ATTRIBUTE8 => r_EGN.INFORMATION118
28981 ,P_EGN_ATTRIBUTE9 => r_EGN.INFORMATION119
28982 ,P_EGN_ATTRIBUTE_CATEGORY => r_EGN.INFORMATION110
28983 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
28984 ,P_ELIG_GNDR_PRTE_ID => l_elig_gndr_prte_id
28985 ,P_EXCLD_FLAG => r_EGN.INFORMATION12
28986 ,P_ORDR_NUM => r_EGN.INFORMATION257
28987 ,P_SEX => r_EGN.INFORMATION11
28988 --
28989 -- ****** END CHANGE LINES
28990
28991 --
28992
28993 ,P_EFFECTIVE_START_DATE => l_effective_start_date
28994 ,P_EFFECTIVE_END_DATE => l_effective_end_date
28995 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
28996 ,P_CRITERIA_SCORE => r_egn.INFORMATION295
28997 ,P_CRITERIA_WEIGHT => r_egn.INFORMATION296
28998 );
28999 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
29000 -- Update all relevent cer records with new pk_id
29001 hr_utility.set_location('Before plsql table ',222);
29002 hr_utility.set_location('new_value id '||l_elig_gndr_prte_id,222);
29003 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_GNDR_PRTE_ID' ;
29004 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EGN.information1 ;
29005 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_GNDR_PRTE_ID ;
29006 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
29007 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EGN_unique.table_route_id;
29008 hr_utility.set_location('After plsql table ',222);
29009 --
29010 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
29011 --
29012 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
29013 --
29014 else
29015 --
29016 -- Call Update routine for the pk_id created in prev run .
29017 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
29018 hr_utility.set_location(' BEN_ELIG_GNDR_PRTE_F UPDATE_ELIG_GNDR_PRTE ',30);
29019 --UPD START
29020 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
29021 --
29022 if l_update then
29023 --
29024 l_datetrack_mode := r_EGN.datetrack_mode ;
29025 --
29026 get_dt_modes(
29027 p_effective_date => l_process_date,
29028 p_effective_end_date => r_EGN.information3,
29029 p_effective_start_date => r_EGN.information2,
29030 p_dml_operation => r_EGN.dml_operation,
29031 p_datetrack_mode => l_datetrack_mode );
29032 -- p_update => l_update
29033 --
29034 l_effective_date := l_process_date;
29035 l_ELIG_GNDR_PRTE_ID := r_EGN.information1;
29036 l_object_version_number := r_EGN.information265;
29037 --
29038 end if;
29039 --
29040 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
29041 --
29042 IF l_update OR l_dml_operation <> 'UPDATE' THEN
29043 --UPD END
29044
29045
29046 BEN_ELIG_GNDR_PRTE_API.UPDATE_ELIG_GNDR_PRTE(
29047 --
29048 P_VALIDATE => false
29049 ,P_EFFECTIVE_DATE => l_effective_date
29050 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
29051 --
29052 ,P_EGN_ATTRIBUTE1 => r_EGN.INFORMATION111
29053 ,P_EGN_ATTRIBUTE10 => r_EGN.INFORMATION120
29054 ,P_EGN_ATTRIBUTE11 => r_EGN.INFORMATION121
29055 ,P_EGN_ATTRIBUTE12 => r_EGN.INFORMATION122
29056 ,P_EGN_ATTRIBUTE13 => r_EGN.INFORMATION123
29057 ,P_EGN_ATTRIBUTE14 => r_EGN.INFORMATION124
29058 ,P_EGN_ATTRIBUTE15 => r_EGN.INFORMATION125
29059 ,P_EGN_ATTRIBUTE16 => r_EGN.INFORMATION126
29060 ,P_EGN_ATTRIBUTE17 => r_EGN.INFORMATION127
29061 ,P_EGN_ATTRIBUTE18 => r_EGN.INFORMATION128
29062 ,P_EGN_ATTRIBUTE19 => r_EGN.INFORMATION129
29063 ,P_EGN_ATTRIBUTE2 => r_EGN.INFORMATION112
29064 ,P_EGN_ATTRIBUTE20 => r_EGN.INFORMATION130
29065 ,P_EGN_ATTRIBUTE21 => r_EGN.INFORMATION131
29066 ,P_EGN_ATTRIBUTE22 => r_EGN.INFORMATION132
29067 ,P_EGN_ATTRIBUTE23 => r_EGN.INFORMATION133
29068 ,P_EGN_ATTRIBUTE24 => r_EGN.INFORMATION134
29069 ,P_EGN_ATTRIBUTE25 => r_EGN.INFORMATION135
29070 ,P_EGN_ATTRIBUTE26 => r_EGN.INFORMATION136
29071 ,P_EGN_ATTRIBUTE27 => r_EGN.INFORMATION137
29072 ,P_EGN_ATTRIBUTE28 => r_EGN.INFORMATION138
29073 ,P_EGN_ATTRIBUTE29 => r_EGN.INFORMATION139
29074 ,P_EGN_ATTRIBUTE3 => r_EGN.INFORMATION113
29075 ,P_EGN_ATTRIBUTE30 => r_EGN.INFORMATION140
29076 ,P_EGN_ATTRIBUTE4 => r_EGN.INFORMATION114
29077 ,P_EGN_ATTRIBUTE5 => r_EGN.INFORMATION115
29078 ,P_EGN_ATTRIBUTE6 => r_EGN.INFORMATION116
29079 ,P_EGN_ATTRIBUTE7 => r_EGN.INFORMATION117
29080 ,P_EGN_ATTRIBUTE8 => r_EGN.INFORMATION118
29081 ,P_EGN_ATTRIBUTE9 => r_EGN.INFORMATION119
29082 ,P_EGN_ATTRIBUTE_CATEGORY => r_EGN.INFORMATION110
29083 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
29084 ,P_ELIG_GNDR_PRTE_ID => l_elig_gndr_prte_id
29085 ,P_EXCLD_FLAG => r_EGN.INFORMATION12
29086 ,P_ORDR_NUM => r_EGN.INFORMATION257
29087 ,P_SEX => r_EGN.INFORMATION11
29088 --
29089 -- ****** END CHANGE LINES
29090
29091 --
29092 ,P_EFFECTIVE_START_DATE => l_effective_start_date
29093 ,P_EFFECTIVE_END_DATE => l_effective_end_date
29094 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
29095 ,P_DATETRACK_MODE => l_datetrack_mode
29096 ,P_CRITERIA_SCORE => r_egn.INFORMATION295
29097 ,P_CRITERIA_WEIGHT => r_egn.INFORMATION296
29098 );
29099 end if; -- l_update
29100 --
29101 end if;
29102 --
29103 -- Delete the row if it is end dated.
29104 --
29105 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
29106 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
29107 trunc(l_max_eed) = trunc(r_EGN.information3)) then
29108 --
29109 BEN_ELIG_GNDR_PRTE_API.delete_ELIG_GNDR_PRTE(
29110 --
29111 p_validate => false
29112 ,p_elig_gndr_prte_id => l_elig_gndr_prte_id
29113 ,p_effective_start_date => l_effective_start_date
29114 ,p_effective_end_date => l_effective_end_date
29115 ,p_object_version_number => l_object_version_number
29116 ,p_effective_date => l_max_eed
29117 ,p_datetrack_mode => hr_api.g_delete
29118 --
29119 );
29120 --
29121 end if;
29122 --
29123 l_prev_pk_id := l_current_pk_id ;
29124 --
29125 end if;
29126 --
29127 end if;
29128 --
29129 end loop;
29130 --
29131 exception when others then
29132 --
29133 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EGN',r_EGN.information5 ) ;
29134 --
29135 end create_EGN_rows;
29136
29137 --
29138 ---------------------------------------------------------------
29139 ----------------------< create_ETU_rows >-----------------------
29140 ---------------------------------------------------------------
29141 --
29142 procedure create_ETU_rows
29143 (
29144 p_validate in number default 0
29145 ,p_copy_entity_txn_id in number
29146 ,p_effective_date in date
29147 ,p_prefix_suffix_text in varchar2 default null
29148 ,p_reuse_object_flag in varchar2 default null
29149 ,p_target_business_group_id in varchar2 default null
29150 ,p_prefix_suffix_cd in varchar2 default null
29151 ) is
29152 --
29153 l_ELIGY_PRFL_ID number;
29154 l_USES_TBCO_FLAG ben_elig_tbco_use_prte_f.uses_tbco_flag%type;
29155
29156 cursor c_unique_ETU(l_table_alias varchar2) is
29157 select distinct cpe.information1,
29158 cpe.information2,
29159 cpe.information3,
29160 cpe.table_route_id
29161 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
29162 pqh_table_route tr
29163 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
29164 and cpe.table_route_id = tr.table_route_id
29165 -- and tr.where_clause = l_BEN_ELIG_TBCO_USE_PRTE_F
29166 and tr.table_alias = l_table_alias
29167 and cpe.number_of_copies = 1 -- ADDITION
29168 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
29169 order by information1, information2; --added for bug: 5151945
29170 --
29171 --
29172 cursor c_ETU_min_max_dates(c_table_route_id number,
29173 c_information1 number) is
29174 select
29175 min(cpe.information2) min_esd,
29176 max(cpe.information3) min_eed
29177 from ben_copy_entity_results cpe
29178 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
29179 and cpe.table_route_id = c_table_route_id
29180 and cpe.information1 = c_information1 ;
29181 --
29182 cursor c_ETU(c_table_route_id number,
29183 c_information1 number,
29184 c_information2 date,
29185 c_information3 date ) is
29186 select
29187 cpe.*
29188 from ben_copy_entity_results cpe
29189 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
29190 and cpe.table_route_id = c_table_route_id
29191 and cpe.information1 = c_information1
29192 and cpe.information2 = c_information2
29193 and cpe.information3 = c_information3
29194 and rownum = 1 ;
29195 -- Date Track target record
29196 cursor c_find_ETU_in_target(
29197 c_effective_start_date date,
29198 c_effective_end_date date,
29199 c_business_group_id number,
29200 c_new_pk_id number) is
29201 select
29202 ETU.elig_tbco_use_prte_id new_value
29203 from BEN_ELIG_TBCO_USE_PRTE_F ETU
29204 where
29205 ETU.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
29206 ETU.USES_TBCO_FLAG = l_USES_TBCO_FLAG and
29207 ETU.business_group_id = c_business_group_id
29208 and ETU.elig_tbco_use_prte_id <> c_new_pk_id
29209 and c_effective_start_date between effective_start_date
29210 and effective_end_date ;
29211 --END TEMPIK
29212 /*TEMPIK
29213 and exists ( select null
29214 from BEN_ELIG_TBCO_USE_PRTE_F ETU1
29215 where
29216 ETU1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
29217 ETU1.USES_TBCO_FLAG = l_USES_TBCO_FLAG and
29218 ETU1.business_group_id = c_business_group_id
29219 and ETU1.effective_start_date <= c_effective_start_date )
29220 and exists ( select null
29221 from BEN_ELIG_TBCO_USE_PRTE_F ETU2
29222 where
29223 ETU2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
29224 ETU2.USES_TBCO_FLAG = l_USES_TBCO_FLAG and
29225 ETU2.business_group_id = c_business_group_id
29226 and ETU2.effective_end_date >= c_effective_end_date )
29227 ;
29228 TEMPIK */
29229 --TEMPIK
29230 l_dt_rec_found boolean ;
29231 --END TEMPIK
29232 --
29233
29234 --UPD START
29235 --
29236 l_update boolean := false ;
29237 l_datetrack_mode varchar2(80) := hr_api.g_update;
29238 l_process_date date;
29239 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
29240 --
29241 --UPD END
29242 l_current_pk_id number := null ;
29243
29244 l_prev_pk_id number := null ;
29245 l_first_rec boolean := true ;
29246 r_ETU c_ETU%rowtype;
29247 l_elig_tbco_use_prte_id number ;
29248 l_object_version_number number ;
29249 l_effective_start_date date ;
29250 l_effective_end_date date ;
29251 l_prefix pqh_copy_entity_attribs.information1%type := null;
29252 l_suffix pqh_copy_entity_attribs.information1%type := null;
29253 l_new_value number(15);
29254 l_object_found_in_target boolean := false ;
29255 l_min_esd date;
29256 l_max_eed date;
29257 l_effective_date date;
29258 --
29259 begin
29260 -- Initialization
29261 l_object_found_in_target := false ;
29262 -- End Initialization
29263 -- Derive the prefix - sufix
29264 if p_prefix_suffix_cd = 'PREFIX' then
29265 l_prefix := p_prefix_suffix_text ;
29266 elsif p_prefix_suffix_cd = 'SUFFIX' then
29267 l_suffix := p_prefix_suffix_text ;
29268 else
29269 l_prefix := null ;
29270 l_suffix := null ;
29271 end if ;
29272 -- End Prefix Sufix derivation
29273 for r_ETU_unique in c_unique_ETU('ETU') loop
29274
29275 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
29276 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
29277 r_ETU_unique.information3 >=
29278 ben_pd_copy_to_ben_one.g_copy_effective_date)
29279 ) then
29280 --
29281 hr_utility.set_location(' r_ETU_unique.table_route_id '||r_ETU_unique.table_route_id,10);
29282 hr_utility.set_location(' r_ETU_unique.information1 '||r_ETU_unique.information1,10);
29283 hr_utility.set_location( 'r_ETU_unique.information2 '||r_ETU_unique.information2,10);
29284 hr_utility.set_location( 'r_ETU_unique.information3 '||r_ETU_unique.information3,10);
29285 -- If reuse objects flag is 'Y' then check for the object in the target business group
29286 -- if found insert the record into PLSql table and exit the loop else try create the
29287 -- object in the target business group
29288 --
29289 l_object_found_in_target := false ;
29290 --UPD START
29291 l_update := false;
29292 l_process_date := p_effective_date;
29293 l_dml_operation:= r_ETU_unique.dml_operation ;
29294 --
29295 /**********************moved from below **********************/
29296 open c_ETU(r_ETU_unique.table_route_id,
29297 r_ETU_unique.information1,
29298 r_ETU_unique.information2,
29299 r_ETU_unique.information3 ) ;
29300 --
29301 fetch c_ETU into r_ETU ;
29302 --
29303 close c_ETU ;
29304 --
29305 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ETU.INFORMATION263,l_dml_operation);
29306 l_USES_TBCO_FLAG := r_ETU.INFORMATION12;
29307 /**********************************************************/
29308
29309 if l_dml_operation = 'UPDATE' then
29310 --
29311 l_object_found_in_target := TRUE;
29312 --
29313 if l_process_date between r_ETU_unique.information2 and r_ETU_unique.information3 then
29314 l_update := true;
29315 if r_ETU_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
29316 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_TBCO_USE_PRTE_ID' then
29317 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_TBCO_USE_PRTE_ID' ;
29318 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ETU_unique.information1 ;
29319 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ETU_unique.information1 ;
29320 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
29321 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ETU_unique.table_route_id;
29322 --
29323 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
29324 --
29325 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
29326 --
29327 -- log_data('ETU',l_new_value,l_prefix || r_ETU_unique.name|| l_suffix,'REUSED');
29328 --
29329 end if ;
29330 hr_utility.set_location( 'found record for update',10);
29331 --
29332 else
29333 --
29334 l_update := false;
29335 --
29336 end if;
29337 else
29338 --
29339 --UPD END
29340 l_min_esd := null ;
29341 l_max_eed := null ;
29342 open c_ETU_min_max_dates(r_ETU_unique.table_route_id, r_ETU_unique.information1 ) ;
29343 fetch c_ETU_min_max_dates into l_min_esd,l_max_eed ;
29344 --
29345
29346 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
29347 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
29348 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
29349 end if;
29350 l_min_esd := greatest(l_min_esd,r_ETU_unique.information2);
29351 /**********************moved up from here **********************
29352 open c_ETU(r_ETU_unique.table_route_id,
29353 r_ETU_unique.information1,
29354 r_ETU_unique.information2,
29355 r_ETU_unique.information3 ) ;
29356 --
29357 fetch c_ETU into r_ETU ;
29358 --
29359 close c_ETU ;
29360 --
29361 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ETU.INFORMATION263,l_dml_operation);
29362 l_USES_TBCO_FLAG := r_ETU.INFORMATION12;
29363 **********************************************************/
29364
29365
29366 if p_reuse_object_flag = 'Y' then
29367 if c_ETU_min_max_dates%found then
29368 -- cursor to find the object
29369 open c_find_ETU_in_target( l_min_esd,l_max_eed,
29370 p_target_business_group_id, nvl(l_elig_tbco_use_prte_id, -999) ) ;
29371 fetch c_find_ETU_in_target into l_new_value ;
29372 if c_find_ETU_in_target%found then
29373 --
29374 --TEMPIK
29375 l_dt_rec_found := dt_api.check_min_max_dates
29376 (p_base_table_name => 'BEN_ELIG_TBCO_USE_PRTE_F',
29377 p_base_key_column => 'ELIG_TBCO_USE_PRTE_ID',
29378 p_base_key_value => l_new_value,
29379 p_from_date => l_min_esd,
29380 p_to_date => l_max_eed );
29381 if l_dt_rec_found THEN
29382 --END TEMPIK
29383 if r_ETU_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
29384 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_TBCO_USE_PRTE_ID' then
29385 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_TBCO_USE_PRTE_ID' ;
29386 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ETU_unique.information1 ;
29387 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
29388 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
29389 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ETU_unique.table_route_id;
29390 --
29391 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
29392 --
29393 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
29394 end if ;
29395 --
29396 l_object_found_in_target := true ;
29397 --TEMPIK
29398 end if; -- l_dt_rec_found
29399 --END TEMPIK
29400 end if;
29401 close c_find_ETU_in_target ;
29402 --
29403 end if;
29404 end if ;
29405 --
29406 close c_ETU_min_max_dates ;
29407 end if; --if p_dml_operation
29408 --
29409 if not l_object_found_in_target OR l_update then
29410
29411 --
29412 l_current_pk_id := r_ETU.information1;
29413 --
29414 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
29415 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
29416 --
29417 if l_current_pk_id = l_prev_pk_id then
29418 --
29419 l_first_rec := false ;
29420 --
29421 else
29422 --
29423 l_first_rec := true ;
29424 --
29425 end if ;
29426 --
29427
29428 l_effective_date := r_ETU.information2;
29429 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
29430 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
29431 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
29432 end if;
29433
29434 if l_first_rec and not l_update then
29435 -- Call Create routine.
29436 hr_utility.set_location(' BEN_ELIG_TBCO_USE_PRTE_F CREATE_ELIG_TBCO_USE_PRTE ',20);
29437 BEN_ELIG_TBCO_USE_PRTE_API.CREATE_ELIG_TBCO_USE_PRTE(
29438 --
29439 P_VALIDATE => false
29440 ,P_EFFECTIVE_DATE => l_effective_date
29441 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
29442 --
29443 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
29444 ,P_ELIG_TBCO_USE_PRTE_ID => l_elig_tbco_use_prte_id
29445 ,P_ETU_ATTRIBUTE1 => r_ETU.INFORMATION111
29446 ,P_ETU_ATTRIBUTE10 => r_ETU.INFORMATION120
29447 ,P_ETU_ATTRIBUTE11 => r_ETU.INFORMATION121
29448 ,P_ETU_ATTRIBUTE12 => r_ETU.INFORMATION122
29449 ,P_ETU_ATTRIBUTE13 => r_ETU.INFORMATION123
29450 ,P_ETU_ATTRIBUTE14 => r_ETU.INFORMATION124
29451 ,P_ETU_ATTRIBUTE15 => r_ETU.INFORMATION125
29452 ,P_ETU_ATTRIBUTE16 => r_ETU.INFORMATION126
29453 ,P_ETU_ATTRIBUTE17 => r_ETU.INFORMATION127
29454 ,P_ETU_ATTRIBUTE18 => r_ETU.INFORMATION128
29455 ,P_ETU_ATTRIBUTE19 => r_ETU.INFORMATION129
29456 ,P_ETU_ATTRIBUTE2 => r_ETU.INFORMATION112
29457 ,P_ETU_ATTRIBUTE20 => r_ETU.INFORMATION130
29458 ,P_ETU_ATTRIBUTE21 => r_ETU.INFORMATION131
29459 ,P_ETU_ATTRIBUTE22 => r_ETU.INFORMATION132
29460 ,P_ETU_ATTRIBUTE23 => r_ETU.INFORMATION133
29461 ,P_ETU_ATTRIBUTE24 => r_ETU.INFORMATION134
29462 ,P_ETU_ATTRIBUTE25 => r_ETU.INFORMATION135
29463 ,P_ETU_ATTRIBUTE26 => r_ETU.INFORMATION136
29464 ,P_ETU_ATTRIBUTE27 => r_ETU.INFORMATION137
29465 ,P_ETU_ATTRIBUTE28 => r_ETU.INFORMATION138
29466 ,P_ETU_ATTRIBUTE29 => r_ETU.INFORMATION139
29467 ,P_ETU_ATTRIBUTE3 => r_ETU.INFORMATION113
29468 ,P_ETU_ATTRIBUTE30 => r_ETU.INFORMATION140
29469 ,P_ETU_ATTRIBUTE4 => r_ETU.INFORMATION114
29470 ,P_ETU_ATTRIBUTE5 => r_ETU.INFORMATION115
29471 ,P_ETU_ATTRIBUTE6 => r_ETU.INFORMATION116
29472 ,P_ETU_ATTRIBUTE7 => r_ETU.INFORMATION117
29473 ,P_ETU_ATTRIBUTE8 => r_ETU.INFORMATION118
29474 ,P_ETU_ATTRIBUTE9 => r_ETU.INFORMATION119
29475 ,P_ETU_ATTRIBUTE_CATEGORY => r_ETU.INFORMATION110
29476 ,P_EXCLD_FLAG => r_ETU.INFORMATION11
29477 ,P_ORDR_NUM => r_ETU.INFORMATION260
29478 ,P_USES_TBCO_FLAG => r_ETU.INFORMATION12
29479 --
29480 -- ****** END CHANGE LINES
29481
29482 --
29483
29484 ,P_EFFECTIVE_START_DATE => l_effective_start_date
29485 ,P_EFFECTIVE_END_DATE => l_effective_end_date
29486 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
29487 ,P_CRITERIA_SCORE => r_etu.INFORMATION295
29488 ,P_CRITERIA_WEIGHT => r_etu.INFORMATION296
29489 );
29490 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
29491 -- Update all relevent cer records with new pk_id
29492 hr_utility.set_location('Before plsql table ',222);
29493 hr_utility.set_location('new_value id '||l_elig_tbco_use_prte_id,222);
29494 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_TBCO_USE_PRTE_ID' ;
29495 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ETU.information1 ;
29496 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_TBCO_USE_PRTE_ID ;
29497 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
29498 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ETU_unique.table_route_id;
29499 hr_utility.set_location('After plsql table ',222);
29500 --
29501 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
29502 --
29503 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
29504 --
29505 else
29506 --
29507 -- Call Update routine for the pk_id created in prev run .
29508 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
29509 hr_utility.set_location(' BEN_ELIG_TBCO_USE_PRTE_F UPDATE_ELIG_TBCO_USE_PRTE ',30);
29510 --UPD START
29511 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
29512 --
29513 if l_update then
29514 --
29515 l_datetrack_mode := r_ETU.datetrack_mode ;
29516 --
29517 get_dt_modes(
29518 p_effective_date => l_process_date,
29519 p_effective_end_date => r_ETU.information3,
29520 p_effective_start_date => r_ETU.information2,
29521 p_dml_operation => r_ETU.dml_operation,
29522 p_datetrack_mode => l_datetrack_mode );
29523 -- p_update => l_update
29524 --
29525 l_effective_date := l_process_date;
29526 l_ELIG_TBCO_USE_PRTE_ID := r_ETU.information1;
29527 l_object_version_number := r_ETU.information265;
29528 --
29529 end if;
29530 --
29531 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
29532 --
29533 IF l_update OR l_dml_operation <> 'UPDATE' THEN
29534 --UPD END
29535
29536
29537 BEN_ELIG_TBCO_USE_PRTE_API.UPDATE_ELIG_TBCO_USE_PRTE(
29538 --
29539 P_VALIDATE => false
29540 ,P_EFFECTIVE_DATE => l_effective_date
29541 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
29542 --
29543 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
29544 ,P_ELIG_TBCO_USE_PRTE_ID => l_elig_tbco_use_prte_id
29545 ,P_ETU_ATTRIBUTE1 => r_ETU.INFORMATION111
29546 ,P_ETU_ATTRIBUTE10 => r_ETU.INFORMATION120
29547 ,P_ETU_ATTRIBUTE11 => r_ETU.INFORMATION121
29548 ,P_ETU_ATTRIBUTE12 => r_ETU.INFORMATION122
29549 ,P_ETU_ATTRIBUTE13 => r_ETU.INFORMATION123
29550 ,P_ETU_ATTRIBUTE14 => r_ETU.INFORMATION124
29551 ,P_ETU_ATTRIBUTE15 => r_ETU.INFORMATION125
29552 ,P_ETU_ATTRIBUTE16 => r_ETU.INFORMATION126
29553 ,P_ETU_ATTRIBUTE17 => r_ETU.INFORMATION127
29554 ,P_ETU_ATTRIBUTE18 => r_ETU.INFORMATION128
29555 ,P_ETU_ATTRIBUTE19 => r_ETU.INFORMATION129
29556 ,P_ETU_ATTRIBUTE2 => r_ETU.INFORMATION112
29557 ,P_ETU_ATTRIBUTE20 => r_ETU.INFORMATION130
29558 ,P_ETU_ATTRIBUTE21 => r_ETU.INFORMATION131
29559 ,P_ETU_ATTRIBUTE22 => r_ETU.INFORMATION132
29560 ,P_ETU_ATTRIBUTE23 => r_ETU.INFORMATION133
29561 ,P_ETU_ATTRIBUTE24 => r_ETU.INFORMATION134
29562 ,P_ETU_ATTRIBUTE25 => r_ETU.INFORMATION135
29563 ,P_ETU_ATTRIBUTE26 => r_ETU.INFORMATION136
29564 ,P_ETU_ATTRIBUTE27 => r_ETU.INFORMATION137
29565 ,P_ETU_ATTRIBUTE28 => r_ETU.INFORMATION138
29566 ,P_ETU_ATTRIBUTE29 => r_ETU.INFORMATION139
29567 ,P_ETU_ATTRIBUTE3 => r_ETU.INFORMATION113
29568 ,P_ETU_ATTRIBUTE30 => r_ETU.INFORMATION140
29569 ,P_ETU_ATTRIBUTE4 => r_ETU.INFORMATION114
29570 ,P_ETU_ATTRIBUTE5 => r_ETU.INFORMATION115
29571 ,P_ETU_ATTRIBUTE6 => r_ETU.INFORMATION116
29572 ,P_ETU_ATTRIBUTE7 => r_ETU.INFORMATION117
29573 ,P_ETU_ATTRIBUTE8 => r_ETU.INFORMATION118
29574 ,P_ETU_ATTRIBUTE9 => r_ETU.INFORMATION119
29575 ,P_ETU_ATTRIBUTE_CATEGORY => r_ETU.INFORMATION110
29576 ,P_EXCLD_FLAG => r_ETU.INFORMATION11
29577 ,P_ORDR_NUM => r_ETU.INFORMATION260
29578 ,P_USES_TBCO_FLAG => r_ETU.INFORMATION12
29579 --
29580 -- ****** END CHANGE LINES
29581
29582 --
29583 ,P_EFFECTIVE_START_DATE => l_effective_start_date
29584 ,P_EFFECTIVE_END_DATE => l_effective_end_date
29585 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
29586 ,P_DATETRACK_MODE => l_datetrack_mode
29587 ,P_CRITERIA_SCORE => r_etu.INFORMATION295
29588 ,P_CRITERIA_WEIGHT => r_etu.INFORMATION296
29589 );
29590 end if; -- l_update
29591 --
29592 end if;
29593 --
29594 -- Delete the row if it is end dated.
29595 --
29596 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
29597 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
29598 trunc(l_max_eed) = trunc(r_ETU.information3)) then
29599 --
29600 BEN_ELIG_TBCO_USE_PRTE_API.delete_ELIG_TBCO_USE_PRTE(
29601 --
29602 p_validate => false
29603 ,p_elig_tbco_use_prte_id => l_elig_tbco_use_prte_id
29604 ,p_effective_start_date => l_effective_start_date
29605 ,p_effective_end_date => l_effective_end_date
29606 ,p_object_version_number => l_object_version_number
29607 ,p_effective_date => l_max_eed
29608 ,p_datetrack_mode => hr_api.g_delete
29609 --
29610 );
29611 --
29612 end if;
29613 --
29614 l_prev_pk_id := l_current_pk_id ;
29615 --
29616 end if;
29617 --
29618 end if;
29619 --
29620 end loop;
29621 --
29622 exception when others then
29623 --
29624 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ETU',r_ETU.information5 ) ;
29625 --
29626 end create_ETU_rows;
29627
29628 --
29629 ---------------------------------------------------------------
29630 ----------------------< create_EDB_rows >-----------------------
29631 ---------------------------------------------------------------
29632 --
29633 procedure create_EDB_rows
29634 (
29635 p_validate in number default 0
29636 ,p_copy_entity_txn_id in number
29637 ,p_effective_date in date
29638 ,p_prefix_suffix_text in varchar2 default null
29639 ,p_reuse_object_flag in varchar2 default null
29640 ,p_target_business_group_id in varchar2 default null
29641 ,p_prefix_suffix_cd in varchar2 default null
29642 ) is
29643 --
29644 l_ELIGY_PRFL_ID number;
29645 l_DSBLD_CD ben_elig_dsbld_prte_f.dsbld_cd%type;
29646
29647 cursor c_unique_EDB(l_table_alias varchar2) is
29648 select distinct cpe.information1,
29649 cpe.information2,
29650 cpe.information3,
29651 cpe.table_route_id
29652 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
29653 pqh_table_route tr
29654 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
29655 and cpe.table_route_id = tr.table_route_id
29656 -- and tr.where_clause = l_BEN_ELIG_DSBLD_PRTE_F
29657 and tr.table_alias = l_table_alias
29658 and cpe.number_of_copies = 1 -- ADDITION
29659 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
29660 order by information1, information2; --added for bug: 5151945
29661 --
29662 --
29663 cursor c_EDB_min_max_dates(c_table_route_id number,
29664 c_information1 number) is
29665 select
29666 min(cpe.information2) min_esd,
29667 max(cpe.information3) min_eed
29668 from ben_copy_entity_results cpe
29669 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
29670 and cpe.table_route_id = c_table_route_id
29671 and cpe.information1 = c_information1 ;
29672 --
29673 cursor c_EDB(c_table_route_id number,
29674 c_information1 number,
29675 c_information2 date,
29676 c_information3 date ) is
29677 select
29678 cpe.*
29679 from ben_copy_entity_results cpe
29680 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
29681 and cpe.table_route_id = c_table_route_id
29682 and cpe.information1 = c_information1
29683 and cpe.information2 = c_information2
29684 and cpe.information3 = c_information3
29685 and rownum = 1 ;
29686 -- Date Track target record
29687 cursor c_find_EDB_in_target(
29688 c_effective_start_date date,
29689 c_effective_end_date date,
29690 c_business_group_id number,
29691 c_new_pk_id number) is
29692 select
29693 EDB.elig_dsbld_prte_id new_value
29694 from BEN_ELIG_DSBLD_PRTE_F EDB
29695 where
29696 EDB.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
29697 EDB.DSBLD_CD = l_DSBLD_CD and
29698 EDB.business_group_id = c_business_group_id
29699 and EDB.elig_dsbld_prte_id <> c_new_pk_id
29700 and c_effective_start_date between effective_start_date
29701 and effective_end_date ;
29702 --END TEMPIK
29703 /*TEMPIK
29704 and exists ( select null
29705 from BEN_ELIG_DSBLD_PRTE_F EDB1
29706 where
29707 EDB1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
29708 EDB1.DSBLD_CD = l_DSBLD_CD and
29709 EDB1.business_group_id = c_business_group_id
29710 and EDB1.effective_start_date <= c_effective_start_date )
29711 and exists ( select null
29712 from BEN_ELIG_DSBLD_PRTE_F EDB2
29713 where
29714 EDB2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
29715 EDB2.DSBLD_CD = l_DSBLD_CD and
29716 EDB2.business_group_id = c_business_group_id
29717 and EDB2.effective_end_date >= c_effective_end_date )
29718 ;
29719 TEMPIK */
29720 --TEMPIK
29721 l_dt_rec_found boolean ;
29722 --END TEMPIK
29723 --
29724
29725 --UPD START
29726 --
29727 l_update boolean := false ;
29728 l_datetrack_mode varchar2(80) := hr_api.g_update;
29729 l_process_date date;
29730 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
29731 --
29732 --UPD END
29733 l_current_pk_id number := null ;
29734
29735 l_prev_pk_id number := null ;
29736 l_first_rec boolean := true ;
29737 r_EDB c_EDB%rowtype;
29738 l_elig_dsbld_prte_id number ;
29739 l_object_version_number number ;
29740 l_effective_start_date date ;
29741 l_effective_end_date date ;
29742 l_prefix pqh_copy_entity_attribs.information1%type := null;
29743 l_suffix pqh_copy_entity_attribs.information1%type := null;
29744 l_new_value number(15);
29745 l_object_found_in_target boolean := false ;
29746 l_min_esd date;
29747 l_max_eed date;
29748 l_effective_date date;
29749 --
29750 begin
29751 -- Initialization
29752 l_object_found_in_target := false ;
29753 -- End Initialization
29754 -- Derive the prefix - sufix
29755 if p_prefix_suffix_cd = 'PREFIX' then
29756 l_prefix := p_prefix_suffix_text ;
29757 elsif p_prefix_suffix_cd = 'SUFFIX' then
29758 l_suffix := p_prefix_suffix_text ;
29759 else
29760 l_prefix := null ;
29761 l_suffix := null ;
29762 end if ;
29763 -- End Prefix Sufix derivation
29764 for r_EDB_unique in c_unique_EDB('EDB') loop
29765
29766 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
29767 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
29768 r_EDB_unique.information3 >=
29769 ben_pd_copy_to_ben_one.g_copy_effective_date)
29770 ) then
29771 --
29772 hr_utility.set_location(' r_EDB_unique.table_route_id '||r_EDB_unique.table_route_id,10);
29773 hr_utility.set_location(' r_EDB_unique.information1 '||r_EDB_unique.information1,10);
29774 hr_utility.set_location( 'r_EDB_unique.information2 '||r_EDB_unique.information2,10);
29775 hr_utility.set_location( 'r_EDB_unique.information3 '||r_EDB_unique.information3,10);
29776 -- If reuse objects flag is 'Y' then check for the object in the target business group
29777 -- if found insert the record into PLSql table and exit the loop else try create the
29778 -- object in the target business group
29779 --
29780 l_object_found_in_target := false ;
29781 --UPD START
29782 l_update := false;
29783 l_process_date := p_effective_date;
29784 l_dml_operation:= r_EDB_unique.dml_operation ;
29785 --
29786 /**********************moved from below **********************/
29787 open c_EDB(r_EDB_unique.table_route_id,
29788 r_EDB_unique.information1,
29789 r_EDB_unique.information2,
29790 r_EDB_unique.information3 ) ;
29791 --
29792 fetch c_EDB into r_EDB ;
29793 --
29794 close c_EDB ;
29795 --
29796 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDB.INFORMATION263,l_dml_operation);
29797 l_DSBLD_CD := r_EDB.INFORMATION12;
29798
29799 /**********************************************************/
29800
29801 if l_dml_operation = 'UPDATE' then
29802 --
29803 l_object_found_in_target := TRUE;
29804 --
29805 if l_process_date between r_EDB_unique.information2 and r_EDB_unique.information3 then
29806 l_update := true;
29807 if r_EDB_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
29808 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DSBLD_PRTE_ID' then
29809 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DSBLD_PRTE_ID' ;
29810 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDB_unique.information1 ;
29811 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EDB_unique.information1 ;
29812 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
29813 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDB_unique.table_route_id;
29814 --
29815 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
29816 --
29817 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
29818 --
29819 -- log_data('EDB',l_new_value,l_prefix || r_EDB_unique.name|| l_suffix,'REUSED');
29820 --
29821 end if ;
29822 hr_utility.set_location( 'found record for update',10);
29823 --
29824 else
29825 --
29826 l_update := false;
29827 --
29828 end if;
29829 else
29830 --
29831 --UPD END
29832 l_min_esd := null ;
29833 l_max_eed := null ;
29834 open c_EDB_min_max_dates(r_EDB_unique.table_route_id, r_EDB_unique.information1 ) ;
29835 fetch c_EDB_min_max_dates into l_min_esd,l_max_eed ;
29836 --
29837
29838 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
29839 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
29840 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
29841 end if;
29842 l_min_esd := greatest(l_min_esd,r_EDB_unique.information2);
29843 /**********************moved up from here **********************
29844 open c_EDB(r_EDB_unique.table_route_id,
29845 r_EDB_unique.information1,
29846 r_EDB_unique.information2,
29847 r_EDB_unique.information3 ) ;
29848 --
29849 fetch c_EDB into r_EDB ;
29850 --
29851 close c_EDB ;
29852 --
29853 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EDB.INFORMATION263,l_dml_operation);
29854 l_DSBLD_CD := r_EDB.INFORMATION12;
29855
29856 **********************************************************/
29857
29858 if p_reuse_object_flag = 'Y' then
29859 if c_EDB_min_max_dates%found then
29860 -- cursor to find the object
29861 open c_find_EDB_in_target( l_min_esd,l_max_eed,
29862 p_target_business_group_id, nvl(l_elig_dsbld_prte_id, -999) ) ;
29863 fetch c_find_EDB_in_target into l_new_value ;
29864 if c_find_EDB_in_target%found then
29865 --
29866 --TEMPIK
29867 l_dt_rec_found := dt_api.check_min_max_dates
29868 (p_base_table_name => 'BEN_ELIG_DSBLD_PRTE_F',
29869 p_base_key_column => 'ELIG_DSBLD_PRTE_ID',
29870 p_base_key_value => l_new_value,
29871 p_from_date => l_min_esd,
29872 p_to_date => l_max_eed );
29873 if l_dt_rec_found THEN
29874 --END TEMPI
29875 if r_EDB_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
29876 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_DSBLD_PRTE_ID' then
29877 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DSBLD_PRTE_ID' ;
29878 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDB_unique.information1 ;
29879 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
29880 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
29881 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDB_unique.table_route_id;
29882 --
29883 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
29884 --
29885 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
29886 end if ;
29887 --
29888 l_object_found_in_target := true ;
29889 --TEMPIK
29890 end if; -- l_dt_rec_found
29891 --END TEMPIK
29892 end if;
29893 close c_find_EDB_in_target ;
29894 --
29895 end if;
29896 end if ;
29897 --
29898 close c_EDB_min_max_dates ;
29899 end if; --if p_dml_operation
29900 --
29901 if not l_object_found_in_target OR l_update then
29902
29903 --
29904 l_current_pk_id := r_EDB.information1;
29905 --
29906 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
29907 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
29908 --
29909 if l_current_pk_id = l_prev_pk_id then
29910 --
29911 l_first_rec := false ;
29912 --
29913 else
29914 --
29915 l_first_rec := true ;
29916 --
29917 end if ;
29918 --
29919
29920 l_effective_date := r_EDB.information2;
29921 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
29922 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
29923 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
29924 end if;
29925
29926 if l_first_rec and not l_update then
29927 -- Call Create routine.
29928 hr_utility.set_location(' BEN_ELIG_DSBLD_PRTE_F CREATE_ELIG_DSBLD_PRTE ',20);
29929 BEN_ELIG_DSBLD_PRTE_API.CREATE_ELIG_DSBLD_PRTE(
29930 --
29931 P_VALIDATE => false
29932 ,P_EFFECTIVE_DATE => l_effective_date
29933 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
29934 --
29935 ,P_DSBLD_CD => r_EDB.INFORMATION12
29936 ,P_EDB_ATTRIBUTE1 => r_EDB.INFORMATION111
29937 ,P_EDB_ATTRIBUTE10 => r_EDB.INFORMATION120
29938 ,P_EDB_ATTRIBUTE11 => r_EDB.INFORMATION121
29939 ,P_EDB_ATTRIBUTE12 => r_EDB.INFORMATION122
29940 ,P_EDB_ATTRIBUTE13 => r_EDB.INFORMATION123
29941 ,P_EDB_ATTRIBUTE14 => r_EDB.INFORMATION124
29942 ,P_EDB_ATTRIBUTE15 => r_EDB.INFORMATION125
29943 ,P_EDB_ATTRIBUTE16 => r_EDB.INFORMATION126
29944 ,P_EDB_ATTRIBUTE17 => r_EDB.INFORMATION127
29945 ,P_EDB_ATTRIBUTE18 => r_EDB.INFORMATION128
29946 ,P_EDB_ATTRIBUTE19 => r_EDB.INFORMATION129
29947 ,P_EDB_ATTRIBUTE2 => r_EDB.INFORMATION112
29948 ,P_EDB_ATTRIBUTE20 => r_EDB.INFORMATION130
29949 ,P_EDB_ATTRIBUTE21 => r_EDB.INFORMATION131
29950 ,P_EDB_ATTRIBUTE22 => r_EDB.INFORMATION132
29951 ,P_EDB_ATTRIBUTE23 => r_EDB.INFORMATION133
29952 ,P_EDB_ATTRIBUTE24 => r_EDB.INFORMATION134
29953 ,P_EDB_ATTRIBUTE25 => r_EDB.INFORMATION135
29954 ,P_EDB_ATTRIBUTE26 => r_EDB.INFORMATION136
29955 ,P_EDB_ATTRIBUTE27 => r_EDB.INFORMATION137
29956 ,P_EDB_ATTRIBUTE28 => r_EDB.INFORMATION138
29957 ,P_EDB_ATTRIBUTE29 => r_EDB.INFORMATION139
29958 ,P_EDB_ATTRIBUTE3 => r_EDB.INFORMATION113
29959 ,P_EDB_ATTRIBUTE30 => r_EDB.INFORMATION140
29960 ,P_EDB_ATTRIBUTE4 => r_EDB.INFORMATION114
29961 ,P_EDB_ATTRIBUTE5 => r_EDB.INFORMATION115
29962 ,P_EDB_ATTRIBUTE6 => r_EDB.INFORMATION116
29963 ,P_EDB_ATTRIBUTE7 => r_EDB.INFORMATION117
29964 ,P_EDB_ATTRIBUTE8 => r_EDB.INFORMATION118
29965 ,P_EDB_ATTRIBUTE9 => r_EDB.INFORMATION119
29966 ,P_EDB_ATTRIBUTE_CATEGORY => r_EDB.INFORMATION110
29967 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
29968 ,P_ELIG_DSBLD_PRTE_ID => l_elig_dsbld_prte_id
29969 ,P_EXCLD_FLAG => r_EDB.INFORMATION11
29970 ,P_ORDR_NUM => r_EDB.INFORMATION260
29971 --
29972 -- ****** END CHANGE LINES
29973
29974 --
29975
29976 ,P_EFFECTIVE_START_DATE => l_effective_start_date
29977 ,P_EFFECTIVE_END_DATE => l_effective_end_date
29978 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
29979 ,P_CRITERIA_SCORE => r_edb.INFORMATION295
29980 ,P_CRITERIA_WEIGHT => r_edb.INFORMATION296
29981 );
29982 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
29983 -- Update all relevent cer records with new pk_id
29984 hr_utility.set_location('Before plsql table ',222);
29985 hr_utility.set_location('new_value id '||l_elig_dsbld_prte_id,222);
29986 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_DSBLD_PRTE_ID' ;
29987 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EDB.information1 ;
29988 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_DSBLD_PRTE_ID ;
29989 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
29990 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EDB_unique.table_route_id;
29991 hr_utility.set_location('After plsql table ',222);
29992 --
29993 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
29994 --
29995 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
29996 --
29997 else
29998 --
29999 -- Call Update routine for the pk_id created in prev run .
30000 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
30001 hr_utility.set_location(' BEN_ELIG_DSBLD_PRTE_F UPDATE_ELIG_DSBLD_PRTE ',30);
30002 --UPD START
30003 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
30004 --
30005 if l_update then
30006 --
30007 l_datetrack_mode := r_EDB.datetrack_mode ;
30008 --
30009 get_dt_modes(
30010 p_effective_date => l_process_date,
30011 p_effective_end_date => r_EDB.information3,
30012 p_effective_start_date => r_EDB.information2,
30013 p_dml_operation => r_EDB.dml_operation,
30014 p_datetrack_mode => l_datetrack_mode );
30015 -- p_update => l_update
30016 --
30017 l_effective_date := l_process_date;
30018 l_ELIG_DSBLD_PRTE_ID := r_EDB.information1;
30019 l_object_version_number := r_EDB.information265;
30020 --
30021 end if;
30022 --
30023 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
30024 --
30025 IF l_update OR l_dml_operation <> 'UPDATE' THEN
30026 --UPD END
30027
30028
30029 BEN_ELIG_DSBLD_PRTE_API.UPDATE_ELIG_DSBLD_PRTE(
30030 --
30031 P_VALIDATE => false
30032 ,P_EFFECTIVE_DATE => l_effective_date
30033 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
30034 --
30035 ,P_DSBLD_CD => r_EDB.INFORMATION12
30036 ,P_EDB_ATTRIBUTE1 => r_EDB.INFORMATION111
30037 ,P_EDB_ATTRIBUTE10 => r_EDB.INFORMATION120
30038 ,P_EDB_ATTRIBUTE11 => r_EDB.INFORMATION121
30039 ,P_EDB_ATTRIBUTE12 => r_EDB.INFORMATION122
30040 ,P_EDB_ATTRIBUTE13 => r_EDB.INFORMATION123
30041 ,P_EDB_ATTRIBUTE14 => r_EDB.INFORMATION124
30042 ,P_EDB_ATTRIBUTE15 => r_EDB.INFORMATION125
30043 ,P_EDB_ATTRIBUTE16 => r_EDB.INFORMATION126
30044 ,P_EDB_ATTRIBUTE17 => r_EDB.INFORMATION127
30045 ,P_EDB_ATTRIBUTE18 => r_EDB.INFORMATION128
30046 ,P_EDB_ATTRIBUTE19 => r_EDB.INFORMATION129
30047 ,P_EDB_ATTRIBUTE2 => r_EDB.INFORMATION112
30048 ,P_EDB_ATTRIBUTE20 => r_EDB.INFORMATION130
30049 ,P_EDB_ATTRIBUTE21 => r_EDB.INFORMATION131
30050 ,P_EDB_ATTRIBUTE22 => r_EDB.INFORMATION132
30051 ,P_EDB_ATTRIBUTE23 => r_EDB.INFORMATION133
30052 ,P_EDB_ATTRIBUTE24 => r_EDB.INFORMATION134
30053 ,P_EDB_ATTRIBUTE25 => r_EDB.INFORMATION135
30054 ,P_EDB_ATTRIBUTE26 => r_EDB.INFORMATION136
30055 ,P_EDB_ATTRIBUTE27 => r_EDB.INFORMATION137
30056 ,P_EDB_ATTRIBUTE28 => r_EDB.INFORMATION138
30057 ,P_EDB_ATTRIBUTE29 => r_EDB.INFORMATION139
30058 ,P_EDB_ATTRIBUTE3 => r_EDB.INFORMATION113
30059 ,P_EDB_ATTRIBUTE30 => r_EDB.INFORMATION140
30060 ,P_EDB_ATTRIBUTE4 => r_EDB.INFORMATION114
30061 ,P_EDB_ATTRIBUTE5 => r_EDB.INFORMATION115
30062 ,P_EDB_ATTRIBUTE6 => r_EDB.INFORMATION116
30063 ,P_EDB_ATTRIBUTE7 => r_EDB.INFORMATION117
30064 ,P_EDB_ATTRIBUTE8 => r_EDB.INFORMATION118
30065 ,P_EDB_ATTRIBUTE9 => r_EDB.INFORMATION119
30066 ,P_EDB_ATTRIBUTE_CATEGORY => r_EDB.INFORMATION110
30067 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
30068 ,P_ELIG_DSBLD_PRTE_ID => l_elig_dsbld_prte_id
30069 ,P_EXCLD_FLAG => r_EDB.INFORMATION11
30070 ,P_ORDR_NUM => r_EDB.INFORMATION260
30071 --
30072 -- ****** END CHANGE LINES
30073
30074 --
30075 ,P_EFFECTIVE_START_DATE => l_effective_start_date
30076 ,P_EFFECTIVE_END_DATE => l_effective_end_date
30077 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
30078 ,P_DATETRACK_MODE => l_datetrack_mode
30079 ,P_CRITERIA_SCORE => r_edb.INFORMATION295
30080 ,P_CRITERIA_WEIGHT => r_edb.INFORMATION296
30081 );
30082 end if; -- l_update
30083 --
30084 end if;
30085 --
30086 -- Delete the row if it is end dated.
30087 --
30088 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
30089 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
30090 trunc(l_max_eed) = trunc(r_EDB.information3)) then
30091 --
30092 BEN_ELIG_DSBLD_PRTE_API.delete_ELIG_DSBLD_PRTE(
30093 --
30094 p_validate => false
30095 ,p_elig_dsbld_prte_id => l_elig_dsbld_prte_id
30096 ,p_effective_start_date => l_effective_start_date
30097 ,p_effective_end_date => l_effective_end_date
30098 ,p_object_version_number => l_object_version_number
30099 ,p_effective_date => l_max_eed
30100 ,p_datetrack_mode => hr_api.g_delete
30101 --
30102 );
30103 --
30104 end if;
30105 --
30106 l_prev_pk_id := l_current_pk_id ;
30107 --
30108 end if;
30109 --
30110 end if;
30111 --
30112 end loop;
30113 --
30114 exception when others then
30115 --
30116 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EDB',r_EDB.information5 ) ;
30117 --
30118 end create_EDB_rows;
30119
30120 --
30121 ---------------------------------------------------------------
30122 ----------------------< create_ETP_rows >-----------------------
30123 ---------------------------------------------------------------
30124 --
30125 procedure create_ETP_rows
30126 (
30127 p_validate in number default 0
30128 ,p_copy_entity_txn_id in number
30129 ,p_effective_date in date
30130 ,p_prefix_suffix_text in varchar2 default null
30131 ,p_reuse_object_flag in varchar2 default null
30132 ,p_target_business_group_id in varchar2 default null
30133 ,p_prefix_suffix_cd in varchar2 default null
30134 ) is
30135 --
30136 l_ELIGY_PRFL_ID number;
30137 l_PRTT_DET_RL number;
30138
30139 l_PRTT_DET_CD ben_elig_ttl_prtt_prte_f.prtt_det_cd%type;
30140 l_MN_PRTT_NUM ben_elig_ttl_prtt_prte_f.mn_prtt_num%type;
30141 l_MX_PRTT_NUM ben_elig_ttl_prtt_prte_f.mx_prtt_num%type;
30142 l_NO_MN_PRTT_NUM_APLS_FLAG ben_elig_ttl_prtt_prte_f.no_mn_prtt_num_apls_flag%type;
30143 l_NO_MX_PRTT_NUM_APLS_FLAG ben_elig_ttl_prtt_prte_f.no_mx_prtt_num_apls_flag%type;
30144
30145 cursor c_unique_ETP(l_table_alias varchar2) is
30146 select distinct cpe.information1,
30147 cpe.information2,
30148 cpe.information3,
30149 cpe.table_route_id
30150 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
30151 pqh_table_route tr
30152 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
30153 and cpe.table_route_id = tr.table_route_id
30154 -- and tr.where_clause = l_BEN_ELIG_TTL_PRTT_PRTE_F
30155 and tr.table_alias = l_table_alias
30156 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
30157 order by information1, information2; --added for bug: 5151945
30158 --
30159 --
30160 cursor c_ETP_min_max_dates(c_table_route_id number,
30161 c_information1 number) is
30162 select
30163 min(cpe.information2) min_esd,
30164 max(cpe.information3) min_eed
30165 from ben_copy_entity_results cpe
30166 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
30167 and cpe.table_route_id = c_table_route_id
30168 and cpe.information1 = c_information1 ;
30169 --
30170 cursor c_ETP(c_table_route_id number,
30171 c_information1 number,
30172 c_information2 date,
30173 c_information3 date ) is
30174 select
30175 cpe.*
30176 from ben_copy_entity_results cpe
30177 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
30178 and cpe.table_route_id = c_table_route_id
30179 and cpe.information1 = c_information1
30180 and cpe.information2 = c_information2
30181 and cpe.information3 = c_information3
30182 and rownum = 1 ;
30183 -- Date Track target record
30184 cursor c_find_ETP_in_target(
30185 c_effective_start_date date,
30186 c_effective_end_date date,
30187 c_business_group_id number,
30188 c_new_pk_id number) is
30189 select
30190 ETP.elig_ttl_prtt_prte_id new_value
30191 from BEN_ELIG_TTL_PRTT_PRTE_F ETP
30192 where
30193 ETP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
30194 nvl(ETP.PRTT_DET_CD, '-YYYY') = nvl(l_PRTT_DET_CD, '-YYYY') and
30195 nvl(ETP.PRTT_DET_RL, -999) = nvl(l_PRTT_DET_RL , -999)and
30196 nvl(ETP.MN_PRTT_NUM, -999) = nvl(l_MN_PRTT_NUM, -999) and
30197 nvl(ETP.MX_PRTT_NUM, -999) = nvl(l_MX_PRTT_NUM, -999) and
30198 nvl(ETP.NO_MN_PRTT_NUM_APLS_FLAG, '-YYYY') = nvl(l_NO_MN_PRTT_NUM_APLS_FLAG, '-YYYY') and
30199 nvl(ETP.NO_MN_PRTT_NUM_APLS_FLAG, '-YYYY') = nvl(l_NO_MN_PRTT_NUM_APLS_FLAG, '-YYYY') and
30200 ETP.business_group_id = c_business_group_id
30201 and ETP.elig_ttl_prtt_prte_id <> c_new_pk_id
30202 and c_effective_start_date between effective_start_date
30203 and effective_end_date ;
30204 --END TEMPIK
30205 /*TEMPIK
30206 and exists ( select null
30207 from BEN_ELIG_TTL_PRTT_PRTE_F ETP1
30208 where
30209 ETP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
30210 nvl(ETP1.PRTT_DET_CD, '-YYYY') = nvl(l_PRTT_DET_CD, '-YYYY') and
30211 nvl(ETP1.PRTT_DET_RL, -999) = nvl(l_PRTT_DET_RL , -999)and
30212 nvl(ETP1.MN_PRTT_NUM, -999) = nvl(l_MN_PRTT_NUM, -999) and
30213 nvl(ETP1.MX_PRTT_NUM, -999) = nvl(l_MX_PRTT_NUM, -999) and
30214 nvl(ETP1.NO_MN_PRTT_NUM_APLS_FLAG, '-YYYY') = nvl(l_NO_MN_PRTT_NUM_APLS_FLAG, '-YYYY') and
30215 nvl(ETP1.NO_MN_PRTT_NUM_APLS_FLAG, '-YYYY') = nvl(l_NO_MN_PRTT_NUM_APLS_FLAG, '-YYYY') and
30216 ETP1.business_group_id = c_business_group_id
30217 and ETP1.effective_start_date <= c_effective_start_date )
30218 and exists ( select null
30219 from BEN_ELIG_TTL_PRTT_PRTE_F ETP2
30220 where
30221 ETP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
30222 nvl(ETP2.PRTT_DET_CD, '-YYYY') = nvl(l_PRTT_DET_CD, '-YYYY') and
30223 nvl(ETP2.PRTT_DET_RL, -999) = nvl(l_PRTT_DET_RL , -999)and
30224 nvl(ETP2.MN_PRTT_NUM, -999) = nvl(l_MN_PRTT_NUM, -999) and
30225 nvl(ETP2.MX_PRTT_NUM, -999) = nvl(l_MX_PRTT_NUM, -999) and
30226 nvl(ETP2.NO_MN_PRTT_NUM_APLS_FLAG, '-YYYY') = nvl(l_NO_MN_PRTT_NUM_APLS_FLAG, '-YYYY') and
30227 nvl(ETP2.NO_MN_PRTT_NUM_APLS_FLAG, '-YYYY') = nvl(l_NO_MN_PRTT_NUM_APLS_FLAG, '-YYYY') and
30228 ETP2.business_group_id = c_business_group_id
30229 and ETP2.effective_end_date >= c_effective_end_date )
30230 ;
30231 TEMPIK */
30232 --TEMPIK
30233 l_dt_rec_found boolean ;
30234 --END TEMPIK
30235 --
30236
30237 --UPD START
30238 --
30239 l_update boolean := false ;
30240 l_datetrack_mode varchar2(80) := hr_api.g_update;
30241 l_process_date date;
30242 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
30243 --
30244 --UPD END
30245 l_current_pk_id number := null ;
30246
30247 l_prev_pk_id number := null ;
30248 l_first_rec boolean := true ;
30249 r_ETP c_ETP%rowtype;
30250 l_elig_ttl_prtt_prte_id number ;
30251 l_object_version_number number ;
30252 l_effective_start_date date ;
30253 l_effective_end_date date ;
30254 l_prefix pqh_copy_entity_attribs.information1%type := null;
30255 l_suffix pqh_copy_entity_attribs.information1%type := null;
30256 l_new_value number(15);
30257 l_object_found_in_target boolean := false ;
30258 l_min_esd date;
30259 l_max_eed date;
30260 l_effective_date date;
30261 --
30262 begin
30263 -- Initialization
30264 l_object_found_in_target := false ;
30265 -- End Initialization
30266 -- Derive the prefix - sufix
30267 if p_prefix_suffix_cd = 'PREFIX' then
30268 l_prefix := p_prefix_suffix_text ;
30269 elsif p_prefix_suffix_cd = 'SUFFIX' then
30270 l_suffix := p_prefix_suffix_text ;
30271 else
30272 l_prefix := null ;
30273 l_suffix := null ;
30274 end if ;
30275 -- End Prefix Sufix derivation
30276 for r_ETP_unique in c_unique_ETP('ETP') loop
30277
30278 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
30279 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
30280 r_ETP_unique.information3 >=
30281 ben_pd_copy_to_ben_one.g_copy_effective_date)
30282 ) then
30283 --
30284 hr_utility.set_location(' r_ETP_unique.table_route_id '||r_ETP_unique.table_route_id,10);
30285 hr_utility.set_location(' r_ETP_unique.information1 '||r_ETP_unique.information1,10);
30286 hr_utility.set_location( 'r_ETP_unique.information2 '||r_ETP_unique.information2,10);
30287 hr_utility.set_location( 'r_ETP_unique.information3 '||r_ETP_unique.information3,10);
30288 -- If reuse objects flag is 'Y' then check for the object in the target business group
30289 -- if found insert the record into PLSql table and exit the loop else try create the
30290 -- object in the target business group
30291 --
30292 l_object_found_in_target := false ;
30293 --UPD START
30294 l_update := false;
30295 l_process_date := p_effective_date;
30296 l_dml_operation:= r_ETP_unique.dml_operation ;
30297 --
30298 /**********************moved from below **********************/
30299 open c_ETP(r_ETP_unique.table_route_id,
30300 r_ETP_unique.information1,
30301 r_ETP_unique.information2,
30302 r_ETP_unique.information3 ) ;
30303 --
30304 fetch c_ETP into r_ETP ;
30305 --
30306 close c_ETP ;
30307 --
30308 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ETP.INFORMATION263,l_dml_operation);
30309 l_PRTT_DET_RL := get_fk('FORMULA_ID', r_ETP.INFORMATION262,l_dml_operation);
30310
30311 l_MN_PRTT_NUM := r_ETP.INFORMATION260;
30312 l_MX_PRTT_NUM := r_ETP.INFORMATION261;
30313 l_NO_MN_PRTT_NUM_APLS_FLAG := r_ETP.INFORMATION12;
30314 l_NO_MX_PRTT_NUM_APLS_FLAG := r_ETP.INFORMATION13;
30315 l_PRTT_DET_CD := r_ETP.INFORMATION11;
30316
30317 /**********************************************************/
30318
30319 if l_dml_operation = 'UPDATE' then
30320 --
30321 l_object_found_in_target := TRUE;
30322 --
30323 if l_process_date between r_ETP_unique.information2 and r_ETP_unique.information3 then
30324 l_update := true;
30325 if r_ETP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
30326 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_TTL_PRTT_PRTE_ID' then
30327 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_TTL_PRTT_PRTE_ID' ;
30328 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ETP_unique.information1 ;
30329 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ETP_unique.information1 ;
30330 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
30331 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ETP_unique.table_route_id;
30332 --
30333 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
30334 --
30335 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
30336 --
30337 -- log_data('ETP',l_new_value,l_prefix || r_ETP_unique.name|| l_suffix,'REUSED');
30338 --
30339 end if ;
30340 hr_utility.set_location( 'found record for update',10);
30341 --
30342 else
30343 --
30344 l_update := false;
30345 --
30346 end if;
30347 else
30348 --
30349 --UPD END
30350 l_min_esd := null ;
30351 l_max_eed := null ;
30352 open c_ETP_min_max_dates(r_ETP_unique.table_route_id, r_ETP_unique.information1 ) ;
30353 fetch c_ETP_min_max_dates into l_min_esd,l_max_eed ;
30354 --
30355
30356 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
30357 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
30358 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
30359 end if;
30360 l_min_esd := greatest(l_min_esd,r_ETP_unique.information2);
30361 /**********************moved up from here **********************
30362 open c_ETP(r_ETP_unique.table_route_id,
30363 r_ETP_unique.information1,
30364 r_ETP_unique.information2,
30365 r_ETP_unique.information3 ) ;
30366 --
30367 fetch c_ETP into r_ETP ;
30368 --
30369 close c_ETP ;
30370 --
30371 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ETP.INFORMATION263,l_dml_operation);
30372 l_PRTT_DET_RL := get_fk('FORMULA_ID', r_ETP.INFORMATION262,l_dml_operation);
30373
30374 l_MN_PRTT_NUM := r_ETP.INFORMATION260;
30375 l_MX_PRTT_NUM := r_ETP.INFORMATION261;
30376 l_NO_MN_PRTT_NUM_APLS_FLAG := r_ETP.INFORMATION12;
30377 l_NO_MX_PRTT_NUM_APLS_FLAG := r_ETP.INFORMATION13;
30378 l_PRTT_DET_CD := r_ETP.INFORMATION11;
30379
30380 **********************************************************/
30381
30382 if p_reuse_object_flag = 'Y' then
30383 if c_ETP_min_max_dates%found then
30384 -- cursor to find the object
30385 open c_find_ETP_in_target( l_min_esd,l_max_eed,
30386 p_target_business_group_id, nvl(l_elig_ttl_prtt_prte_id, -999) ) ;
30387 fetch c_find_ETP_in_target into l_new_value ;
30388 if c_find_ETP_in_target%found then
30389 --
30390 --TEMPIK
30391 l_dt_rec_found := dt_api.check_min_max_dates
30392 (p_base_table_name => 'BEN_ELIG_TTL_PRTT_PRTE_F',
30393 p_base_key_column => 'ELIG_TTL_PRTT_PRTE_ID',
30394 p_base_key_value => l_new_value,
30395 p_from_date => l_min_esd,
30396 p_to_date => l_max_eed );
30397 if l_dt_rec_found THEN
30398 --END TEMPIK
30399 if r_ETP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
30400 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_TTL_PRTT_PRTE_ID' then
30401 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_TTL_PRTT_PRTE_ID' ;
30402 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ETP_unique.information1 ;
30403 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
30404 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
30405 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ETP_unique.table_route_id;
30406 --
30407 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
30408 --
30409 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
30410 end if ;
30411 --
30412 l_object_found_in_target := true ;
30413 --TEMPIK
30414 end if; -- l_dt_rec_found
30415 --END TEMPIK
30416 end if;
30417 close c_find_ETP_in_target ;
30418 --
30419 end if;
30420 end if ;
30421 --
30422 close c_ETP_min_max_dates ;
30423 end if; --if p_dml_operation
30424 --
30425 if not l_object_found_in_target OR l_update then
30426
30427 --
30428 l_current_pk_id := r_ETP.information1;
30429 --
30430 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
30431 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
30432 --
30433 if l_current_pk_id = l_prev_pk_id then
30434 --
30435 l_first_rec := false ;
30436 --
30437 else
30438 --
30439 l_first_rec := true ;
30440 --
30441 end if ;
30442 --
30443
30444 l_effective_date := r_ETP.information2;
30445 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
30446 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
30447 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
30448 end if;
30449
30450 if l_first_rec and not l_update then
30451 -- Call Create routine.
30452 hr_utility.set_location(' BEN_ELIG_TTL_PRTT_PRTE_F CREATE_ELIG_TTL_PRTT_PRTE ',20);
30453 BEN_ELIG_TTL_PRTT_PRTE_API.CREATE_ELIG_TTL_PRTT_PRTE(
30454 --
30455 P_VALIDATE => false
30456 ,P_EFFECTIVE_DATE => l_effective_date
30457 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
30458 --
30459 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
30460 ,P_ELIG_TTL_PRTT_PRTE_ID => l_elig_ttl_prtt_prte_id
30461 ,P_ETP_ATTRIBUTE1 => r_ETP.INFORMATION111
30462 ,P_ETP_ATTRIBUTE10 => r_ETP.INFORMATION120
30463 ,P_ETP_ATTRIBUTE11 => r_ETP.INFORMATION121
30464 ,P_ETP_ATTRIBUTE12 => r_ETP.INFORMATION122
30465 ,P_ETP_ATTRIBUTE13 => r_ETP.INFORMATION123
30466 ,P_ETP_ATTRIBUTE14 => r_ETP.INFORMATION124
30467 ,P_ETP_ATTRIBUTE15 => r_ETP.INFORMATION125
30468 ,P_ETP_ATTRIBUTE16 => r_ETP.INFORMATION126
30469 ,P_ETP_ATTRIBUTE17 => r_ETP.INFORMATION127
30470 ,P_ETP_ATTRIBUTE18 => r_ETP.INFORMATION128
30471 ,P_ETP_ATTRIBUTE19 => r_ETP.INFORMATION129
30472 ,P_ETP_ATTRIBUTE2 => r_ETP.INFORMATION112
30473 ,P_ETP_ATTRIBUTE20 => r_ETP.INFORMATION130
30474 ,P_ETP_ATTRIBUTE21 => r_ETP.INFORMATION131
30475 ,P_ETP_ATTRIBUTE22 => r_ETP.INFORMATION132
30476 ,P_ETP_ATTRIBUTE23 => r_ETP.INFORMATION133
30477 ,P_ETP_ATTRIBUTE24 => r_ETP.INFORMATION134
30478 ,P_ETP_ATTRIBUTE25 => r_ETP.INFORMATION135
30479 ,P_ETP_ATTRIBUTE26 => r_ETP.INFORMATION136
30480 ,P_ETP_ATTRIBUTE27 => r_ETP.INFORMATION137
30481 ,P_ETP_ATTRIBUTE28 => r_ETP.INFORMATION138
30482 ,P_ETP_ATTRIBUTE29 => r_ETP.INFORMATION139
30483 ,P_ETP_ATTRIBUTE3 => r_ETP.INFORMATION113
30484 ,P_ETP_ATTRIBUTE30 => r_ETP.INFORMATION140
30485 ,P_ETP_ATTRIBUTE4 => r_ETP.INFORMATION114
30486 ,P_ETP_ATTRIBUTE5 => r_ETP.INFORMATION115
30487 ,P_ETP_ATTRIBUTE6 => r_ETP.INFORMATION116
30488 ,P_ETP_ATTRIBUTE7 => r_ETP.INFORMATION117
30489 ,P_ETP_ATTRIBUTE8 => r_ETP.INFORMATION118
30490 ,P_ETP_ATTRIBUTE9 => r_ETP.INFORMATION119
30491 ,P_ETP_ATTRIBUTE_CATEGORY => r_ETP.INFORMATION110
30492 ,P_EXCLD_FLAG => r_ETP.INFORMATION14
30493 ,P_MN_PRTT_NUM => r_ETP.INFORMATION260
30494 ,P_MX_PRTT_NUM => r_ETP.INFORMATION261
30495 ,P_NO_MN_PRTT_NUM_APLS_FLAG => r_ETP.INFORMATION12
30496 ,P_NO_MX_PRTT_NUM_APLS_FLAG => r_ETP.INFORMATION13
30497 ,P_ORDR_NUM => r_ETP.INFORMATION259
30498 ,P_PRTT_DET_CD => r_ETP.INFORMATION11
30499 ,P_PRTT_DET_RL => l_PRTT_DET_RL
30500 --
30501 -- ****** END CHANGE LINES
30502
30503 --
30504
30505 ,P_EFFECTIVE_START_DATE => l_effective_start_date
30506 ,P_EFFECTIVE_END_DATE => l_effective_end_date
30507 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
30508 );
30509 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
30510 -- Update all relevent cer records with new pk_id
30511 hr_utility.set_location('Before plsql table ',222);
30512 hr_utility.set_location('new_value id '||l_elig_ttl_prtt_prte_id,222);
30513 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_TTL_PRTT_PRTE_ID' ;
30514 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ETP.information1 ;
30515 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_TTL_PRTT_PRTE_ID ;
30516 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
30517 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ETP_unique.table_route_id;
30518 hr_utility.set_location('After plsql table ',222);
30519 --
30520 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
30521 --
30522 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
30523 --
30524 else
30525 --
30526 -- Call Update routine for the pk_id created in prev run .
30527 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
30528 hr_utility.set_location(' BEN_ELIG_TTL_PRTT_PRTE_F UPDATE_ELIG_TTL_PRTT_PRTE ',30);
30529 --UPD START
30530 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
30531 --
30532 if l_update then
30533 --
30534 l_datetrack_mode := r_ETP.datetrack_mode ;
30535 --
30536 get_dt_modes(
30537 p_effective_date => l_process_date,
30538 p_effective_end_date => r_ETP.information3,
30539 p_effective_start_date => r_ETP.information2,
30540 p_dml_operation => r_ETP.dml_operation,
30541 p_datetrack_mode => l_datetrack_mode );
30542 -- p_update => l_update
30543 --
30544 l_effective_date := l_process_date;
30545 l_ELIG_TTL_PRTT_PRTE_ID := r_ETP.information1;
30546 l_object_version_number := r_ETP.information265;
30547 --
30548 end if;
30549 --
30550 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
30551 --
30552 IF l_update OR l_dml_operation <> 'UPDATE' THEN
30553 --UPD END
30554
30555
30556 BEN_ELIG_TTL_PRTT_PRTE_API.UPDATE_ELIG_TTL_PRTT_PRTE(
30557 --
30558 P_VALIDATE => false
30559 ,P_EFFECTIVE_DATE => l_effective_date
30560 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
30561 --
30562 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
30563 ,P_ELIG_TTL_PRTT_PRTE_ID => l_elig_ttl_prtt_prte_id
30564 ,P_ETP_ATTRIBUTE1 => r_ETP.INFORMATION111
30565 ,P_ETP_ATTRIBUTE10 => r_ETP.INFORMATION120
30566 ,P_ETP_ATTRIBUTE11 => r_ETP.INFORMATION121
30567 ,P_ETP_ATTRIBUTE12 => r_ETP.INFORMATION122
30568 ,P_ETP_ATTRIBUTE13 => r_ETP.INFORMATION123
30569 ,P_ETP_ATTRIBUTE14 => r_ETP.INFORMATION124
30570 ,P_ETP_ATTRIBUTE15 => r_ETP.INFORMATION125
30571 ,P_ETP_ATTRIBUTE16 => r_ETP.INFORMATION126
30572 ,P_ETP_ATTRIBUTE17 => r_ETP.INFORMATION127
30573 ,P_ETP_ATTRIBUTE18 => r_ETP.INFORMATION128
30574 ,P_ETP_ATTRIBUTE19 => r_ETP.INFORMATION129
30575 ,P_ETP_ATTRIBUTE2 => r_ETP.INFORMATION112
30576 ,P_ETP_ATTRIBUTE20 => r_ETP.INFORMATION130
30577 ,P_ETP_ATTRIBUTE21 => r_ETP.INFORMATION131
30578 ,P_ETP_ATTRIBUTE22 => r_ETP.INFORMATION132
30579 ,P_ETP_ATTRIBUTE23 => r_ETP.INFORMATION133
30580 ,P_ETP_ATTRIBUTE24 => r_ETP.INFORMATION134
30581 ,P_ETP_ATTRIBUTE25 => r_ETP.INFORMATION135
30582 ,P_ETP_ATTRIBUTE26 => r_ETP.INFORMATION136
30583 ,P_ETP_ATTRIBUTE27 => r_ETP.INFORMATION137
30584 ,P_ETP_ATTRIBUTE28 => r_ETP.INFORMATION138
30585 ,P_ETP_ATTRIBUTE29 => r_ETP.INFORMATION139
30586 ,P_ETP_ATTRIBUTE3 => r_ETP.INFORMATION113
30587 ,P_ETP_ATTRIBUTE30 => r_ETP.INFORMATION140
30588 ,P_ETP_ATTRIBUTE4 => r_ETP.INFORMATION114
30589 ,P_ETP_ATTRIBUTE5 => r_ETP.INFORMATION115
30590 ,P_ETP_ATTRIBUTE6 => r_ETP.INFORMATION116
30591 ,P_ETP_ATTRIBUTE7 => r_ETP.INFORMATION117
30592 ,P_ETP_ATTRIBUTE8 => r_ETP.INFORMATION118
30593 ,P_ETP_ATTRIBUTE9 => r_ETP.INFORMATION119
30594 ,P_ETP_ATTRIBUTE_CATEGORY => r_ETP.INFORMATION110
30595 ,P_EXCLD_FLAG => r_ETP.INFORMATION14
30596 ,P_MN_PRTT_NUM => r_ETP.INFORMATION260
30597 ,P_MX_PRTT_NUM => r_ETP.INFORMATION261
30598 ,P_NO_MN_PRTT_NUM_APLS_FLAG => r_ETP.INFORMATION12
30599 ,P_NO_MX_PRTT_NUM_APLS_FLAG => r_ETP.INFORMATION13
30600 ,P_ORDR_NUM => r_ETP.INFORMATION259
30601 ,P_PRTT_DET_CD => r_ETP.INFORMATION11
30602 ,P_PRTT_DET_RL => l_PRTT_DET_RL
30603 --
30604 -- ****** END CHANGE LINES
30605
30606 --
30607 ,P_EFFECTIVE_START_DATE => l_effective_start_date
30608 ,P_EFFECTIVE_END_DATE => l_effective_end_date
30609 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
30610 ,P_DATETRACK_MODE => l_datetrack_mode
30611 );
30612 end if; -- l_update
30613 --
30614 end if;
30615 --
30616 -- Delete the row if it is end dated.
30617 --
30618 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
30619 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
30620 trunc(l_max_eed) = trunc(r_ETP.information3)) then
30621 --
30622 BEN_ELIG_TTL_PRTT_PRTE_API.delete_ELIG_TTL_PRTT_PRTE(
30623 --
30624 p_validate => false
30625 ,p_elig_ttl_prtt_prte_id => l_elig_ttl_prtt_prte_id
30626 ,p_effective_start_date => l_effective_start_date
30627 ,p_effective_end_date => l_effective_end_date
30628 ,p_object_version_number => l_object_version_number
30629 ,p_effective_date => l_max_eed
30630 ,p_datetrack_mode => hr_api.g_delete
30631 --
30632 );
30633 --
30634 end if;
30635 --
30636 l_prev_pk_id := l_current_pk_id ;
30637 --
30638 end if;
30639 --
30640 end if;
30641 --
30642 end loop;
30643 --
30644 exception when others then
30645 --
30646 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ETP',r_ETP.information5 ) ;
30647 --
30648 end create_ETP_rows;
30649
30650 --
30651 ---------------------------------------------------------------
30652 ----------------------< create_ETC_rows >-----------------------
30653 ---------------------------------------------------------------
30654 --
30655 procedure create_ETC_rows
30656 (
30657 p_validate in number default 0
30658 ,p_copy_entity_txn_id in number
30659 ,p_effective_date in date
30660 ,p_prefix_suffix_text in varchar2 default null
30661 ,p_reuse_object_flag in varchar2 default null
30662 ,p_target_business_group_id in varchar2 default null
30663 ,p_prefix_suffix_cd in varchar2 default null
30664 ) is
30665 --
30666 l_CVG_VOL_DET_RL number;
30667 l_ELIGY_PRFL_ID number;
30668
30669 l_CVG_VOL_DET_CD ben_elig_ttl_cvg_vol_prte_f.cvg_vol_det_cd%type;
30670 l_MN_CVG_VOL_AMT ben_elig_ttl_cvg_vol_prte_f.mn_cvg_vol_amt%type;
30671 l_MX_CVG_VOL_AMT ben_elig_ttl_cvg_vol_prte_f.mx_cvg_vol_amt%type;
30672 l_NO_MN_CVG_VOL_AMT_APLS_FLAG ben_elig_ttl_cvg_vol_prte_f.no_mn_cvg_vol_amt_apls_flag%type;
30673 l_NO_MX_CVG_VOL_AMT_APLS_FLAG ben_elig_ttl_cvg_vol_prte_f.no_mx_cvg_vol_amt_apls_flag%type;
30674
30675 cursor c_unique_ETC(l_table_alias varchar2) is
30676 select distinct cpe.information1,
30677 cpe.information2,
30678 cpe.information3,
30679 cpe.table_route_id
30680 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
30681 pqh_table_route tr
30682 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
30683 and cpe.table_route_id = tr.table_route_id
30684 -- and tr.where_clause = l_BEN_ELIG_TTL_CVG_VOL_PRTE_F
30685 and tr.table_alias = l_table_alias
30686 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
30687 order by information1, information2; --added for bug: 5151945
30688 --
30689 --
30690 cursor c_ETC_min_max_dates(c_table_route_id number,
30691 c_information1 number) is
30692 select
30693 min(cpe.information2) min_esd,
30694 max(cpe.information3) min_eed
30695 from ben_copy_entity_results cpe
30696 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
30697 and cpe.table_route_id = c_table_route_id
30698 and cpe.information1 = c_information1 ;
30699 --
30700 cursor c_ETC(c_table_route_id number,
30701 c_information1 number,
30702 c_information2 date,
30703 c_information3 date ) is
30704 select
30705 cpe.*
30706 from ben_copy_entity_results cpe
30707 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
30708 and cpe.table_route_id = c_table_route_id
30709 and cpe.information1 = c_information1
30710 and cpe.information2 = c_information2
30711 and cpe.information3 = c_information3
30712 and rownum = 1 ;
30713 -- Date Track target record
30714 cursor c_find_ETC_in_target(
30715 c_effective_start_date date,
30716 c_effective_end_date date,
30717 c_business_group_id number,
30718 c_new_pk_id number) is
30719 select
30720 ETC.elig_ttl_cvg_vol_prte_id new_value
30721 from BEN_ELIG_TTL_CVG_VOL_PRTE_F ETC
30722 where
30723 ETC.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
30724 nvl(ETC.CVG_VOL_DET_CD, '-YYYY') = nvl(l_CVG_VOL_DET_CD, '-YYYY') and
30725 nvl(ETC.CVG_VOL_DET_RL, -999) = nvl(l_CVG_VOL_DET_RL , -999)and
30726 nvl(ETC.MN_CVG_VOL_AMT, -999) = nvl(l_MN_CVG_VOL_AMT, -999) and
30727 nvl(ETC.MX_CVG_VOL_AMT, -999) = nvl(l_MX_CVG_VOL_AMT, -999) and
30728 nvl(ETC.NO_MN_CVG_VOL_AMT_APLS_FLAG, '-YYYY') = nvl(l_NO_MN_CVG_VOL_AMT_APLS_FLAG, '-YYYY') and
30729 nvl(ETC.NO_MX_CVG_VOL_AMT_APLS_FLAG, '-YYYY') = nvl(l_NO_MX_CVG_VOL_AMT_APLS_FLAG, '-YYYY') and
30730 ETC.business_group_id = c_business_group_id
30731 and ETC.elig_ttl_cvg_vol_prte_id <> c_new_pk_id
30732 and c_effective_start_date between effective_start_date
30733 and effective_end_date ;
30734 --END TEMPIK
30735 /*TEMPIK
30736 and exists ( select null
30737 from BEN_ELIG_TTL_CVG_VOL_PRTE_F ETC1
30738 where
30739 ETC1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
30740 nvl(ETC1.CVG_VOL_DET_CD, '-YYYY') = nvl(l_CVG_VOL_DET_CD, '-YYYY') and
30741 nvl(ETC1.CVG_VOL_DET_RL, -999) = nvl(l_CVG_VOL_DET_RL , -999)and
30742 nvl(ETC1.MN_CVG_VOL_AMT, -999) = nvl(l_MN_CVG_VOL_AMT, -999) and
30743 nvl(ETC1.MX_CVG_VOL_AMT, -999) = nvl(l_MX_CVG_VOL_AMT, -999) and
30744 nvl(ETC1.NO_MN_CVG_VOL_AMT_APLS_FLAG, '-YYYY') = nvl(l_NO_MN_CVG_VOL_AMT_APLS_FLAG, '-YYYY') and
30745 nvl(ETC1.NO_MX_CVG_VOL_AMT_APLS_FLAG, '-YYYY') = nvl(l_NO_MX_CVG_VOL_AMT_APLS_FLAG, '-YYYY') and
30746 ETC1.business_group_id = c_business_group_id
30747 and ETC1.effective_start_date <= c_effective_start_date )
30748 and exists ( select null
30749 from BEN_ELIG_TTL_CVG_VOL_PRTE_F ETC2
30750 where
30751 ETC2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
30752 nvl(ETC2.CVG_VOL_DET_CD, '-YYYY') = nvl(l_CVG_VOL_DET_CD, '-YYYY') and
30753 nvl(ETC2.CVG_VOL_DET_RL, -999) = nvl(l_CVG_VOL_DET_RL , -999)and
30754 nvl(ETC2.MN_CVG_VOL_AMT, -999) = nvl(l_MN_CVG_VOL_AMT, -999) and
30755 nvl(ETC2.MX_CVG_VOL_AMT, -999) = nvl(l_MX_CVG_VOL_AMT, -999) and
30756 nvl(ETC2.NO_MN_CVG_VOL_AMT_APLS_FLAG, '-YYYY') = nvl(l_NO_MN_CVG_VOL_AMT_APLS_FLAG, '-YYYY') and
30757 nvl(ETC2.NO_MX_CVG_VOL_AMT_APLS_FLAG, '-YYYY') = nvl(l_NO_MX_CVG_VOL_AMT_APLS_FLAG, '-YYYY') and
30758 ETC2.business_group_id = c_business_group_id
30759 and ETC2.effective_end_date >= c_effective_end_date )
30760 ;
30761 TEMPIK */
30762 --TEMPIK
30763 l_dt_rec_found boolean ;
30764 --END TEMPIK
30765 --
30766
30767 --UPD START
30768 --
30769 l_update boolean := false ;
30770 l_datetrack_mode varchar2(80) := hr_api.g_update;
30771 l_process_date date;
30772 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
30773 --
30774 --UPD END
30775 l_current_pk_id number := null ;
30776
30777 l_prev_pk_id number := null ;
30778 l_first_rec boolean := true ;
30779 r_ETC c_ETC%rowtype;
30780 l_elig_ttl_cvg_vol_prte_id number ;
30781 l_object_version_number number ;
30782 l_effective_start_date date ;
30783 l_effective_end_date date ;
30784 l_prefix pqh_copy_entity_attribs.information1%type := null;
30785 l_suffix pqh_copy_entity_attribs.information1%type := null;
30786 l_new_value number(15);
30787 l_object_found_in_target boolean := false ;
30788 l_min_esd date;
30789 l_max_eed date;
30790 l_effective_date date;
30791 --
30792 begin
30793 -- Initialization
30794 l_object_found_in_target := false ;
30795 -- End Initialization
30796 -- Derive the prefix - sufix
30797 if p_prefix_suffix_cd = 'PREFIX' then
30798 l_prefix := p_prefix_suffix_text ;
30799 elsif p_prefix_suffix_cd = 'SUFFIX' then
30800 l_suffix := p_prefix_suffix_text ;
30801 else
30802 l_prefix := null ;
30803 l_suffix := null ;
30804 end if ;
30805 -- End Prefix Sufix derivation
30806 for r_ETC_unique in c_unique_ETC('ETC') loop
30807
30808 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
30809 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
30810 r_ETC_unique.information3 >=
30811 ben_pd_copy_to_ben_one.g_copy_effective_date)
30812 ) then
30813 --
30814 hr_utility.set_location(' r_ETC_unique.table_route_id '||r_ETC_unique.table_route_id,10);
30815 hr_utility.set_location(' r_ETC_unique.information1 '||r_ETC_unique.information1,10);
30816 hr_utility.set_location( 'r_ETC_unique.information2 '||r_ETC_unique.information2,10);
30817 hr_utility.set_location( 'r_ETC_unique.information3 '||r_ETC_unique.information3,10);
30818 -- If reuse objects flag is 'Y' then check for the object in the target business group
30819 -- if found insert the record into PLSql table and exit the loop else try create the
30820 -- object in the target business group
30821 --
30822 l_object_found_in_target := false ;
30823 --UPD START
30824 l_update := false;
30825 l_process_date := p_effective_date;
30826 l_dml_operation:= r_ETC_unique.dml_operation ;
30827 --
30828 /**********************moved from below **********************/
30829 open c_ETC(r_ETC_unique.table_route_id,
30830 r_ETC_unique.information1,
30831 r_ETC_unique.information2,
30832 r_ETC_unique.information3 ) ;
30833 --
30834 fetch c_ETC into r_ETC ;
30835 --
30836 close c_ETC ;
30837 --
30838 l_CVG_VOL_DET_RL := get_fk('FORMULA_ID', r_ETC.INFORMATION261,l_dml_operation);
30839 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ETC.INFORMATION263,l_dml_operation);
30840
30841 l_CVG_VOL_DET_CD := r_ETC.INFORMATION14;
30842 l_MN_CVG_VOL_AMT := r_ETC.INFORMATION293;
30843 l_MX_CVG_VOL_AMT := r_ETC.INFORMATION294;
30844 l_NO_MN_CVG_VOL_AMT_APLS_FLAG := r_ETC.INFORMATION12;
30845 l_NO_MX_CVG_VOL_AMT_APLS_FLAG := r_ETC.INFORMATION13;
30846
30847 /**********************************************************/
30848
30849 if l_dml_operation = 'UPDATE' then
30850 --
30851 l_object_found_in_target := TRUE;
30852 --
30853 if l_process_date between r_ETC_unique.information2 and r_ETC_unique.information3 then
30854 l_update := true;
30855 if r_ETC_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
30856 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_TTL_CVG_VOL_PRTE_ID' then
30857 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_TTL_CVG_VOL_PRTE_ID' ;
30858 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ETC_unique.information1 ;
30859 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ETC_unique.information1 ;
30860 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
30861 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ETC_unique.table_route_id;
30862 --
30863 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
30864 --
30865 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
30866 --
30867 -- log_data('ETC',l_new_value,l_prefix || r_ETC_unique.name|| l_suffix,'REUSED');
30868 --
30869 end if ;
30870 hr_utility.set_location( 'found record for update',10);
30871 --
30872 else
30873 --
30874 l_update := false;
30875 --
30876 end if;
30877 else
30878 --
30879 --UPD END
30880 l_min_esd := null ;
30881 l_max_eed := null ;
30882 open c_ETC_min_max_dates(r_ETC_unique.table_route_id, r_ETC_unique.information1 ) ;
30883 fetch c_ETC_min_max_dates into l_min_esd,l_max_eed ;
30884 --
30885
30886 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
30887 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
30888 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
30889 end if;
30890 l_min_esd := greatest(l_min_esd,r_ETC_unique.information2);
30891 /**********************moved up from here **********************
30892 open c_ETC(r_ETC_unique.table_route_id,
30893 r_ETC_unique.information1,
30894 r_ETC_unique.information2,
30895 r_ETC_unique.information3 ) ;
30896 --
30897 fetch c_ETC into r_ETC ;
30898 --
30899 close c_ETC ;
30900 --
30901 l_CVG_VOL_DET_RL := get_fk('FORMULA_ID', r_ETC.INFORMATION261,l_dml_operation);
30902 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_ETC.INFORMATION263,l_dml_operation);
30903
30904 l_CVG_VOL_DET_CD := r_ETC.INFORMATION14;
30905 l_MN_CVG_VOL_AMT := r_ETC.INFORMATION293;
30906 l_MX_CVG_VOL_AMT := r_ETC.INFORMATION294;
30907 l_NO_MN_CVG_VOL_AMT_APLS_FLAG := r_ETC.INFORMATION12;
30908 l_NO_MX_CVG_VOL_AMT_APLS_FLAG := r_ETC.INFORMATION13;
30909
30910 **********************************************************/
30911
30912
30913 if p_reuse_object_flag = 'Y' then
30914 if c_ETC_min_max_dates%found then
30915 -- cursor to find the object
30916 open c_find_ETC_in_target( l_min_esd,l_max_eed,
30917 p_target_business_group_id, nvl(l_elig_ttl_cvg_vol_prte_id, -999) ) ;
30918 fetch c_find_ETC_in_target into l_new_value ;
30919 if c_find_ETC_in_target%found then
30920 --
30921 --TEMPIK
30922 l_dt_rec_found := dt_api.check_min_max_dates
30923 (p_base_table_name => 'BEN_ELIG_TTL_CVG_VOL_PRTE_F',
30924 p_base_key_column => 'ELIG_TTL_CVG_VOL_PRTE_ID',
30925 p_base_key_value => l_new_value,
30926 p_from_date => l_min_esd,
30927 p_to_date => l_max_eed );
30928 if l_dt_rec_found THEN
30929 --END TEMPIK
30930 if r_ETC_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
30931 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_TTL_CVG_VOL_PRTE_ID' then
30932 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_TTL_CVG_VOL_PRTE_ID' ;
30933 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ETC_unique.information1 ;
30934 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
30935 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
30936 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ETC_unique.table_route_id;
30937 --
30938 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
30939 --
30940 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
30941 end if ;
30942 --
30943 l_object_found_in_target := true ;
30944 --TEMPIK
30945 end if; -- l_dt_rec_found
30946 --END TEMPIK
30947 end if;
30948 close c_find_ETC_in_target ;
30949 --
30950 end if;
30951 end if ;
30952 --
30953 close c_ETC_min_max_dates ;
30954 end if; --if p_dml_operation
30955 --
30956 if not l_object_found_in_target OR l_update then
30957
30958 --
30959 l_current_pk_id := r_ETC.information1;
30960 --
30961 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
30962 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
30963 --
30964 if l_current_pk_id = l_prev_pk_id then
30965 --
30966 l_first_rec := false ;
30967 --
30968 else
30969 --
30970 l_first_rec := true ;
30971 --
30972 end if ;
30973 --
30974
30975 l_effective_date := r_ETC.information2;
30976 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
30977 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
30978 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
30979 end if;
30980
30981 if l_first_rec and not l_update then
30982 -- Call Create routine.
30983 hr_utility.set_location(' BEN_ELIG_TTL_CVG_VOL_PRTE_F CREATE_ELIG_TTL_CVG_VOL_PRTE ',20);
30984 BEN_ELIG_TTL_CVG_VOL_PRTE_API.CREATE_ELIG_TTL_CVG_VOL_PRTE(
30985 --
30986 P_VALIDATE => false
30987 ,P_EFFECTIVE_DATE => l_effective_date
30988 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
30989 --
30990 ,P_CVG_VOL_DET_CD => r_ETC.INFORMATION14
30991 ,P_CVG_VOL_DET_RL => l_CVG_VOL_DET_RL
30992 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
30993 ,P_ELIG_TTL_CVG_VOL_PRTE_ID => l_elig_ttl_cvg_vol_prte_id
30994 ,P_ETC_ATTRIBUTE1 => r_ETC.INFORMATION111
30995 ,P_ETC_ATTRIBUTE10 => r_ETC.INFORMATION120
30996 ,P_ETC_ATTRIBUTE11 => r_ETC.INFORMATION121
30997 ,P_ETC_ATTRIBUTE12 => r_ETC.INFORMATION122
30998 ,P_ETC_ATTRIBUTE13 => r_ETC.INFORMATION123
30999 ,P_ETC_ATTRIBUTE14 => r_ETC.INFORMATION124
31000 ,P_ETC_ATTRIBUTE15 => r_ETC.INFORMATION125
31001 ,P_ETC_ATTRIBUTE16 => r_ETC.INFORMATION126
31002 ,P_ETC_ATTRIBUTE17 => r_ETC.INFORMATION127
31003 ,P_ETC_ATTRIBUTE18 => r_ETC.INFORMATION128
31004 ,P_ETC_ATTRIBUTE19 => r_ETC.INFORMATION129
31005 ,P_ETC_ATTRIBUTE2 => r_ETC.INFORMATION112
31006 ,P_ETC_ATTRIBUTE20 => r_ETC.INFORMATION130
31007 ,P_ETC_ATTRIBUTE21 => r_ETC.INFORMATION131
31008 ,P_ETC_ATTRIBUTE22 => r_ETC.INFORMATION132
31009 ,P_ETC_ATTRIBUTE23 => r_ETC.INFORMATION133
31010 ,P_ETC_ATTRIBUTE24 => r_ETC.INFORMATION134
31011 ,P_ETC_ATTRIBUTE25 => r_ETC.INFORMATION135
31012 ,P_ETC_ATTRIBUTE26 => r_ETC.INFORMATION136
31013 ,P_ETC_ATTRIBUTE27 => r_ETC.INFORMATION137
31014 ,P_ETC_ATTRIBUTE28 => r_ETC.INFORMATION138
31015 ,P_ETC_ATTRIBUTE29 => r_ETC.INFORMATION139
31016 ,P_ETC_ATTRIBUTE3 => r_ETC.INFORMATION113
31017 ,P_ETC_ATTRIBUTE30 => r_ETC.INFORMATION140
31018 ,P_ETC_ATTRIBUTE4 => r_ETC.INFORMATION114
31019 ,P_ETC_ATTRIBUTE5 => r_ETC.INFORMATION115
31020 ,P_ETC_ATTRIBUTE6 => r_ETC.INFORMATION116
31021 ,P_ETC_ATTRIBUTE7 => r_ETC.INFORMATION117
31022 ,P_ETC_ATTRIBUTE8 => r_ETC.INFORMATION118
31023 ,P_ETC_ATTRIBUTE9 => r_ETC.INFORMATION119
31024 ,P_ETC_ATTRIBUTE_CATEGORY => r_ETC.INFORMATION110
31025 ,P_EXCLD_FLAG => r_ETC.INFORMATION11
31026 ,P_MN_CVG_VOL_AMT => r_ETC.INFORMATION293
31027 ,P_MX_CVG_VOL_AMT => r_ETC.INFORMATION294
31028 ,P_NO_MN_CVG_VOL_AMT_APLS_FLAG => r_ETC.INFORMATION12
31029 ,P_NO_MX_CVG_VOL_AMT_APLS_FLAG => r_ETC.INFORMATION13
31030 ,P_ORDR_NUM => r_ETC.INFORMATION260
31031 --
31032 -- ****** END CHANGE LINES
31033
31034 --
31035
31036 ,P_EFFECTIVE_START_DATE => l_effective_start_date
31037 ,P_EFFECTIVE_END_DATE => l_effective_end_date
31038 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
31039 );
31040 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
31041 -- Update all relevent cer records with new pk_id
31042 hr_utility.set_location('Before plsql table ',222);
31043 hr_utility.set_location('new_value id '||l_elig_ttl_cvg_vol_prte_id,222);
31044 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_TTL_CVG_VOL_PRTE_ID' ;
31045 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ETC.information1 ;
31046 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_TTL_CVG_VOL_PRTE_ID ;
31047 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
31048 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ETC_unique.table_route_id;
31049 hr_utility.set_location('After plsql table ',222);
31050 --
31051 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
31052 --
31053 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
31054 --
31055 else
31056 --
31057 -- Call Update routine for the pk_id created in prev run .
31058 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
31059 hr_utility.set_location(' BEN_ELIG_TTL_CVG_VOL_PRTE_F UPDATE_ELIG_TTL_CVG_VOL_PRTE ',30);
31060 --UPD START
31061 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
31062 --
31063 if l_update then
31064 --
31065 l_datetrack_mode := r_ETC.datetrack_mode ;
31066 --
31067 get_dt_modes(
31068 p_effective_date => l_process_date,
31069 p_effective_end_date => r_ETC.information3,
31070 p_effective_start_date => r_ETC.information2,
31071 p_dml_operation => r_ETC.dml_operation,
31072 p_datetrack_mode => l_datetrack_mode );
31073 -- p_update => l_update
31074 --
31075 l_effective_date := l_process_date;
31076 l_ELIG_TTL_CVG_VOL_PRTE_ID := r_ETC.information1;
31077 l_object_version_number := r_ETC.information265;
31078 --
31079 end if;
31080 --
31081 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
31082 --
31083 IF l_update OR l_dml_operation <> 'UPDATE' THEN
31084 --UPD END
31085
31086
31087 BEN_ELIG_TTL_CVG_VOL_PRTE_API.UPDATE_ELIG_TTL_CVG_VOL_PRTE(
31088 --
31089 P_VALIDATE => false
31090 ,P_EFFECTIVE_DATE => l_effective_date
31091 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
31092 --
31093 ,P_CVG_VOL_DET_CD => r_ETC.INFORMATION14
31094 ,P_CVG_VOL_DET_RL => l_CVG_VOL_DET_RL
31095 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
31096 ,P_ELIG_TTL_CVG_VOL_PRTE_ID => l_elig_ttl_cvg_vol_prte_id
31097 ,P_ETC_ATTRIBUTE1 => r_ETC.INFORMATION111
31098 ,P_ETC_ATTRIBUTE10 => r_ETC.INFORMATION120
31099 ,P_ETC_ATTRIBUTE11 => r_ETC.INFORMATION121
31100 ,P_ETC_ATTRIBUTE12 => r_ETC.INFORMATION122
31101 ,P_ETC_ATTRIBUTE13 => r_ETC.INFORMATION123
31102 ,P_ETC_ATTRIBUTE14 => r_ETC.INFORMATION124
31103 ,P_ETC_ATTRIBUTE15 => r_ETC.INFORMATION125
31104 ,P_ETC_ATTRIBUTE16 => r_ETC.INFORMATION126
31105 ,P_ETC_ATTRIBUTE17 => r_ETC.INFORMATION127
31106 ,P_ETC_ATTRIBUTE18 => r_ETC.INFORMATION128
31107 ,P_ETC_ATTRIBUTE19 => r_ETC.INFORMATION129
31108 ,P_ETC_ATTRIBUTE2 => r_ETC.INFORMATION112
31109 ,P_ETC_ATTRIBUTE20 => r_ETC.INFORMATION130
31110 ,P_ETC_ATTRIBUTE21 => r_ETC.INFORMATION131
31111 ,P_ETC_ATTRIBUTE22 => r_ETC.INFORMATION132
31112 ,P_ETC_ATTRIBUTE23 => r_ETC.INFORMATION133
31113 ,P_ETC_ATTRIBUTE24 => r_ETC.INFORMATION134
31114 ,P_ETC_ATTRIBUTE25 => r_ETC.INFORMATION135
31115 ,P_ETC_ATTRIBUTE26 => r_ETC.INFORMATION136
31116 ,P_ETC_ATTRIBUTE27 => r_ETC.INFORMATION137
31117 ,P_ETC_ATTRIBUTE28 => r_ETC.INFORMATION138
31118 ,P_ETC_ATTRIBUTE29 => r_ETC.INFORMATION139
31119 ,P_ETC_ATTRIBUTE3 => r_ETC.INFORMATION113
31120 ,P_ETC_ATTRIBUTE30 => r_ETC.INFORMATION140
31121 ,P_ETC_ATTRIBUTE4 => r_ETC.INFORMATION114
31122 ,P_ETC_ATTRIBUTE5 => r_ETC.INFORMATION115
31123 ,P_ETC_ATTRIBUTE6 => r_ETC.INFORMATION116
31124 ,P_ETC_ATTRIBUTE7 => r_ETC.INFORMATION117
31125 ,P_ETC_ATTRIBUTE8 => r_ETC.INFORMATION118
31126 ,P_ETC_ATTRIBUTE9 => r_ETC.INFORMATION119
31127 ,P_ETC_ATTRIBUTE_CATEGORY => r_ETC.INFORMATION110
31128 ,P_EXCLD_FLAG => r_ETC.INFORMATION11
31129 ,P_MN_CVG_VOL_AMT => r_ETC.INFORMATION293
31130 ,P_MX_CVG_VOL_AMT => r_ETC.INFORMATION294
31131 ,P_NO_MN_CVG_VOL_AMT_APLS_FLAG => r_ETC.INFORMATION12
31132 ,P_NO_MX_CVG_VOL_AMT_APLS_FLAG => r_ETC.INFORMATION13
31133 ,P_ORDR_NUM => r_ETC.INFORMATION260
31134 --
31135 -- ****** END CHANGE LINES
31136
31137 --
31138 ,P_EFFECTIVE_START_DATE => l_effective_start_date
31139 ,P_EFFECTIVE_END_DATE => l_effective_end_date
31140 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
31141 ,P_DATETRACK_MODE => l_datetrack_mode
31142 );
31143 end if; -- l_update
31144 --
31145 end if;
31146 --
31147 -- Delete the row if it is end dated.
31148 --
31149 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
31150 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
31151 trunc(l_max_eed) = trunc(r_ETC.information3)) then
31152 --
31153 BEN_ELIG_TTL_CVG_VOL_PRTE_API.delete_ELIG_TTL_CVG_VOL_PRTE(
31154 --
31155 p_validate => false
31156 ,p_elig_ttl_cvg_vol_prte_id => l_elig_ttl_cvg_vol_prte_id
31157 ,p_effective_start_date => l_effective_start_date
31158 ,p_effective_end_date => l_effective_end_date
31159 ,p_object_version_number => l_object_version_number
31160 ,p_effective_date => l_max_eed
31161 ,p_datetrack_mode => hr_api.g_delete
31162 --
31163 );
31164 --
31165 end if;
31166 --
31167 l_prev_pk_id := l_current_pk_id ;
31168 --
31169 end if;
31170 --
31171 end if;
31172 --
31173 end loop;
31174 --
31175 exception when others then
31176 --
31177 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ETC',r_ETC.information5 ) ;
31178 --
31179 end create_ETC_rows;
31180 --
31181 ---------------------------------------------------------------
31182 ----------------------< create_EHC_rows >-----------------------
31183 ---------------------------------------------------------------
31184 --
31185 procedure create_EHC_rows
31186 (
31187 p_validate in number default 0
31188 ,p_copy_entity_txn_id in number
31189 ,p_effective_date in date
31190 ,p_prefix_suffix_text in varchar2 default null
31191 ,p_reuse_object_flag in varchar2 default null
31192 ,p_target_business_group_id in varchar2 default null
31193 ,p_prefix_suffix_cd in varchar2 default null
31194 ) is
31195 --
31196 l_ELIGY_PRFL_ID number;
31197 l_PL_TYP_OPT_TYP_ID number;
31198 l_OIPL_ID number;
31199 cursor c_unique_EHC(l_table_alias varchar2) is
31200 select distinct cpe.information1,
31201 cpe.information2,
31202 cpe.information3,
31203 cpe.table_route_id
31204 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
31205 pqh_table_route tr
31206 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
31207 and cpe.table_route_id = tr.table_route_id
31208 -- and tr.where_clause = l_BEN_ELIG_HLTH_CVG_PRTE_F
31209 and tr.table_alias = l_table_alias
31210 and cpe.number_of_copies = 1 -- ADDITION
31211 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
31212 order by information1, information2; --added for bug: 5151945
31213 --
31214 --
31215 cursor c_EHC_min_max_dates(c_table_route_id number,
31216 c_information1 number) is
31217 select
31218 min(cpe.information2) min_esd,
31219 max(cpe.information3) min_eed
31220 from ben_copy_entity_results cpe
31221 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
31222 and cpe.table_route_id = c_table_route_id
31223 and cpe.information1 = c_information1 ;
31224 --
31225 cursor c_EHC(c_table_route_id number,
31226 c_information1 number,
31227 c_information2 date,
31228 c_information3 date ) is
31229 select
31230 cpe.*
31231 from ben_copy_entity_results cpe
31232 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
31233 and cpe.table_route_id = c_table_route_id
31234 and cpe.information1 = c_information1
31235 and cpe.information2 = c_information2
31236 and cpe.information3 = c_information3
31237 and rownum = 1 ;
31238 -- Date Track target record
31239 cursor c_find_EHC_in_target(
31240 c_effective_start_date date,
31241 c_effective_end_date date,
31242 c_business_group_id number,
31243 c_new_pk_id number) is
31244 select
31245 EHC.elig_hlth_cvg_prte_id new_value
31246 from BEN_ELIG_HLTH_CVG_PRTE_F EHC
31247 where
31248 EHC.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
31249 EHC.OIPL_ID = l_OIPL_ID and
31250 EHC.PL_TYP_OPT_TYP_ID = l_PL_TYP_OPT_TYP_ID and
31251 EHC.business_group_id = c_business_group_id
31252 and EHC.elig_hlth_cvg_prte_id <> c_new_pk_id
31253 and c_effective_start_date between effective_start_date
31254 and effective_end_date ;
31255 --END TEMPIK
31256 /*TEMPIK
31257 and exists ( select null
31258 from BEN_ELIG_HLTH_CVG_PRTE_F EHC1
31259 where
31260 EHC1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
31261 EHC1.OIPL_ID = l_OIPL_ID and
31262 EHC1.PL_TYP_OPT_TYP_ID = l_PL_TYP_OPT_TYP_ID and
31263 EHC1.business_group_id = c_business_group_id
31264 and EHC1.effective_start_date <= c_effective_start_date )
31265 and exists ( select null
31266 from BEN_ELIG_HLTH_CVG_PRTE_F EHC2
31267 where
31268 EHC2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
31269 EHC2.OIPL_ID = l_OIPL_ID and
31270 EHC2.PL_TYP_OPT_TYP_ID = l_PL_TYP_OPT_TYP_ID and
31271 EHC2.business_group_id = c_business_group_id
31272 and EHC2.effective_end_date >= c_effective_end_date )
31273 ;
31274 TEMPIK */
31275 --TEMPIK
31276 l_dt_rec_found boolean ;
31277 --END TEMPIK
31278 --
31279
31280 --UPD START
31281 --
31282 l_update boolean := false ;
31283 l_datetrack_mode varchar2(80) := hr_api.g_update;
31284 l_process_date date;
31285 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
31286 --
31287 --UPD END
31288 l_current_pk_id number := null ;
31289
31290 l_prev_pk_id number := null ;
31291 l_first_rec boolean := true ;
31292 r_EHC c_EHC%rowtype;
31293 l_elig_hlth_cvg_prte_id number ;
31294 l_object_version_number number ;
31295 l_effective_start_date date ;
31296 l_effective_end_date date ;
31297 l_prefix pqh_copy_entity_attribs.information1%type := null;
31298 l_suffix pqh_copy_entity_attribs.information1%type := null;
31299 l_new_value number(15);
31300 l_object_found_in_target boolean := false ;
31301 l_min_esd date;
31302 l_max_eed date;
31303 l_effective_date date;
31304 --
31305 begin
31306 -- Initialization
31307 l_object_found_in_target := false ;
31308 -- End Initialization
31309 -- Derive the prefix - sufix
31310 if p_prefix_suffix_cd = 'PREFIX' then
31311 l_prefix := p_prefix_suffix_text ;
31312 elsif p_prefix_suffix_cd = 'SUFFIX' then
31313 l_suffix := p_prefix_suffix_text ;
31314 else
31315 l_prefix := null ;
31316 l_suffix := null ;
31317 end if ;
31318 -- End Prefix Sufix derivation
31319 for r_EHC_unique in c_unique_EHC('EHC') loop
31320
31321 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
31322 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
31323 r_EHC_unique.information3 >=
31324 ben_pd_copy_to_ben_one.g_copy_effective_date)
31325 ) then
31326 --
31327 hr_utility.set_location(' r_EHC_unique.table_route_id '||r_EHC_unique.table_route_id,10);
31328 hr_utility.set_location(' r_EHC_unique.information1 '||r_EHC_unique.information1,10);
31329 hr_utility.set_location( 'r_EHC_unique.information2 '||r_EHC_unique.information2,10);
31330 hr_utility.set_location( 'r_EHC_unique.information3 '||r_EHC_unique.information3,10);
31331 -- If reuse objects flag is 'Y' then check for the object in the target business group
31332 -- if found insert the record into PLSql table and exit the loop else try create the
31333 -- object in the target business group
31334 --
31335 l_object_found_in_target := false ;
31336 --UPD START
31337 l_update := false;
31338 l_process_date := p_effective_date;
31339 l_dml_operation:= r_EHC_unique.dml_operation ;
31340 --
31341 /**********************moved from below **********************/
31342 open c_EHC(r_EHC_unique.table_route_id,
31343 r_EHC_unique.information1,
31344 r_EHC_unique.information2,
31345 r_EHC_unique.information3 ) ;
31346 --
31347 fetch c_EHC into r_EHC ;
31348 --
31349 close c_EHC ;
31350 --
31351 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EHC.INFORMATION263,l_dml_operation);
31352
31353 -- Only For Use by Create Wizard - Same Business Group
31354 l_OIPL_ID := NVL(get_fk('OIPL_ID', r_EHC.INFORMATION258,l_dml_operation),
31355 r_EHC.INFORMATION258);
31356
31357 l_PL_TYP_OPT_TYP_ID := NVL(get_fk('PL_TYP_OPT_TYP_ID',r_EHC.INFORMATION228,l_dml_operation),
31358 r_EHC.INFORMATION228);
31359
31360 /**********************************************************/
31361
31362 if l_dml_operation = 'UPDATE' then
31363 --
31364 l_object_found_in_target := TRUE;
31365 --
31366 if l_process_date between r_EHC_unique.information2 and r_EHC_unique.information3 then
31367 l_update := true;
31368 if r_EHC_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
31369 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_HLTH_CVG_PRTE_ID' then
31370 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_HLTH_CVG_PRTE_ID' ;
31371 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EHC_unique.information1 ;
31372 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EHC_unique.information1 ;
31373 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
31374 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EHC_unique.table_route_id;
31375 --
31376 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
31377 --
31378 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
31379 --
31380 -- log_data('EHC',l_new_value,l_prefix || r_EHC_unique.name|| l_suffix,'REUSED');
31381 --
31382 end if ;
31383 hr_utility.set_location( 'found record for update',10);
31384 --
31385 else
31386 --
31387 l_update := false;
31388 --
31389 end if;
31390 else
31391 --
31392 --UPD END
31393 l_min_esd := null ;
31394 l_max_eed := null ;
31395 open c_EHC_min_max_dates(r_EHC_unique.table_route_id, r_EHC_unique.information1 ) ;
31396 fetch c_EHC_min_max_dates into l_min_esd,l_max_eed ;
31397 --
31398
31399 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
31400 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
31401 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
31402 end if;
31403 l_min_esd := greatest(l_min_esd,r_EHC_unique.information2);
31404 /**********************moved up from here **********************
31405 open c_EHC(r_EHC_unique.table_route_id,
31406 r_EHC_unique.information1,
31407 r_EHC_unique.information2,
31408 r_EHC_unique.information3 ) ;
31409 --
31410 fetch c_EHC into r_EHC ;
31411 --
31412 close c_EHC ;
31413 --
31414 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EHC.INFORMATION263,l_dml_operation);
31415
31416 -- Only For Use by Create Wizard - Same Business Group
31417 l_OIPL_ID := NVL(get_fk('OIPL_ID', r_EHC.INFORMATION258,l_dml_operation),
31418 r_EHC.INFORMATION258);
31419
31420 l_PL_TYP_OPT_TYP_ID := NVL(get_fk('PL_TYP_OPT_TYP_ID',r_EHC.INFORMATION228,l_dml_operation),
31421 r_EHC.INFORMATION228);
31422
31423 **********************************************************/
31424
31425
31426 if p_reuse_object_flag = 'Y' then
31427 if c_EHC_min_max_dates%found then
31428 -- cursor to find the object
31429 open c_find_EHC_in_target( l_min_esd,l_max_eed,
31430 p_target_business_group_id, nvl(l_elig_hlth_cvg_prte_id, -999) ) ;
31431 fetch c_find_EHC_in_target into l_new_value ;
31432 if c_find_EHC_in_target%found then
31433 --
31434 --TEMPIK
31435 l_dt_rec_found := dt_api.check_min_max_dates
31436 (p_base_table_name => 'BEN_ELIG_HLTH_CVG_PRTE_F',
31437 p_base_key_column => 'ELIG_HLTH_CVG_PRTE_ID',
31438 p_base_key_value => l_new_value,
31439 p_from_date => l_min_esd,
31440 p_to_date => l_max_eed );
31441 if l_dt_rec_found THEN
31442 --END TEMPIK
31443 if r_EHC_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
31444 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_HLTH_CVG_PRTE_ID' then
31445 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_HLTH_CVG_PRTE_ID' ;
31446 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EHC_unique.information1 ;
31447 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
31448 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
31449 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EHC_unique.table_route_id;
31450 --
31451 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
31452 --
31453 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
31454 end if ;
31455 --
31456 l_object_found_in_target := true ;
31457 --TEMPIK
31458 end if; -- l_dt_rec_found
31459 --END TEMPIK
31460 end if;
31461 close c_find_EHC_in_target ;
31462 --
31463 end if;
31464 end if ;
31465 --
31466 close c_EHC_min_max_dates ;
31467 end if; --if p_dml_operation
31468 --
31469 if not l_object_found_in_target OR l_update then
31470
31471 --
31472 l_current_pk_id := r_EHC.information1;
31473 --
31474 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
31475 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
31476 --
31477 if l_current_pk_id = l_prev_pk_id then
31478 --
31479 l_first_rec := false ;
31480 --
31481 else
31482 --
31483 l_first_rec := true ;
31484 --
31485 end if ;
31486 --
31487
31488 l_effective_date := r_EHC.information2;
31489 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
31490 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
31491 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
31492 end if;
31493
31494 if l_first_rec and not l_update then
31495 -- Call Create routine.
31496 hr_utility.set_location(' BEN_ELIG_HLTH_CVG_PRTE_F CREATE_ELIG_HLTH_CVG_PRTE ',20);
31497 BEN_ELIG_HLTH_CVG_PRTE_API.CREATE_ELIG_HLTH_CVG_PRTE(
31498 --
31499 P_VALIDATE => false
31500 ,P_EFFECTIVE_DATE => l_effective_date
31501 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
31502 --
31503 ,P_EHC_ATTRIBUTE1 => r_EHC.INFORMATION111
31504 ,P_EHC_ATTRIBUTE10 => r_EHC.INFORMATION120
31505 ,P_EHC_ATTRIBUTE11 => r_EHC.INFORMATION121
31506 ,P_EHC_ATTRIBUTE12 => r_EHC.INFORMATION122
31507 ,P_EHC_ATTRIBUTE13 => r_EHC.INFORMATION123
31508 ,P_EHC_ATTRIBUTE14 => r_EHC.INFORMATION124
31509 ,P_EHC_ATTRIBUTE15 => r_EHC.INFORMATION125
31510 ,P_EHC_ATTRIBUTE16 => r_EHC.INFORMATION126
31511 ,P_EHC_ATTRIBUTE17 => r_EHC.INFORMATION127
31512 ,P_EHC_ATTRIBUTE18 => r_EHC.INFORMATION128
31513 ,P_EHC_ATTRIBUTE19 => r_EHC.INFORMATION129
31514 ,P_EHC_ATTRIBUTE2 => r_EHC.INFORMATION112
31515 ,P_EHC_ATTRIBUTE20 => r_EHC.INFORMATION130
31516 ,P_EHC_ATTRIBUTE21 => r_EHC.INFORMATION131
31517 ,P_EHC_ATTRIBUTE22 => r_EHC.INFORMATION132
31518 ,P_EHC_ATTRIBUTE23 => r_EHC.INFORMATION133
31519 ,P_EHC_ATTRIBUTE24 => r_EHC.INFORMATION134
31520 ,P_EHC_ATTRIBUTE25 => r_EHC.INFORMATION135
31521 ,P_EHC_ATTRIBUTE26 => r_EHC.INFORMATION136
31522 ,P_EHC_ATTRIBUTE27 => r_EHC.INFORMATION137
31523 ,P_EHC_ATTRIBUTE28 => r_EHC.INFORMATION138
31524 ,P_EHC_ATTRIBUTE29 => r_EHC.INFORMATION139
31525 ,P_EHC_ATTRIBUTE3 => r_EHC.INFORMATION113
31526 ,P_EHC_ATTRIBUTE30 => r_EHC.INFORMATION140
31527 ,P_EHC_ATTRIBUTE4 => r_EHC.INFORMATION114
31528 ,P_EHC_ATTRIBUTE5 => r_EHC.INFORMATION115
31529 ,P_EHC_ATTRIBUTE6 => r_EHC.INFORMATION116
31530 ,P_EHC_ATTRIBUTE7 => r_EHC.INFORMATION117
31531 ,P_EHC_ATTRIBUTE8 => r_EHC.INFORMATION118
31532 ,P_EHC_ATTRIBUTE9 => r_EHC.INFORMATION119
31533 ,P_EHC_ATTRIBUTE_CATEGORY => r_EHC.INFORMATION110
31534 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
31535 ,P_ELIG_HLTH_CVG_PRTE_ID => l_elig_hlth_cvg_prte_id
31536 ,P_EXCLD_FLAG => r_EHC.INFORMATION11
31537 ,P_OIPL_ID => l_OIPL_ID
31538 ,P_ORDR_NUM => r_EHC.INFORMATION261
31539 ,P_PL_TYP_OPT_TYP_ID => l_PL_TYP_OPT_TYP_ID
31540
31541 ,P_EFFECTIVE_START_DATE => l_effective_start_date
31542 ,P_EFFECTIVE_END_DATE => l_effective_end_date
31543 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
31544 );
31545 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
31546 -- Update all relevent cer records with new pk_id
31547 hr_utility.set_location('Before plsql table ',222);
31548 hr_utility.set_location('new_value id '||l_elig_hlth_cvg_prte_id,222);
31549 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_HLTH_CVG_PRTE_ID' ;
31550 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EHC.information1 ;
31551 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_HLTH_CVG_PRTE_ID ;
31552 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
31553 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EHC_unique.table_route_id;
31554 hr_utility.set_location('After plsql table ',222);
31555 --
31556 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
31557 --
31558 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
31559 --
31560 else
31561 --
31562 -- Call Update routine for the pk_id created in prev run .
31563 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
31564 hr_utility.set_location(' BEN_ELIG_HLTH_CVG_PRTE_F UPDATE_ELIG_HLTH_CVG_PRTE ',30);
31565 --UPD START
31566 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
31567 --
31568 if l_update then
31569 --
31570 l_datetrack_mode := r_EHC.datetrack_mode ;
31571 --
31572 get_dt_modes(
31573 p_effective_date => l_process_date,
31574 p_effective_end_date => r_EHC.information3,
31575 p_effective_start_date => r_EHC.information2,
31576 p_dml_operation => r_EHC.dml_operation,
31577 p_datetrack_mode => l_datetrack_mode );
31578 -- p_update => l_update
31579 --
31580 l_effective_date := l_process_date;
31581 l_ELIG_HLTH_CVG_PRTE_ID := r_EHC.information1;
31582 l_object_version_number := r_EHC.information265;
31583 --
31584 end if;
31585 --
31586 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
31587 --
31588 IF l_update OR l_dml_operation <> 'UPDATE' THEN
31589 --UPD END
31590
31591
31592 BEN_ELIG_HLTH_CVG_PRTE_API.UPDATE_ELIG_HLTH_CVG_PRTE(
31593 --
31594 P_VALIDATE => false
31595 ,P_EFFECTIVE_DATE => l_effective_date
31596 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
31597 --
31598 ,P_EHC_ATTRIBUTE1 => r_EHC.INFORMATION111
31599 ,P_EHC_ATTRIBUTE10 => r_EHC.INFORMATION120
31600 ,P_EHC_ATTRIBUTE11 => r_EHC.INFORMATION121
31601 ,P_EHC_ATTRIBUTE12 => r_EHC.INFORMATION122
31602 ,P_EHC_ATTRIBUTE13 => r_EHC.INFORMATION123
31603 ,P_EHC_ATTRIBUTE14 => r_EHC.INFORMATION124
31604 ,P_EHC_ATTRIBUTE15 => r_EHC.INFORMATION125
31605 ,P_EHC_ATTRIBUTE16 => r_EHC.INFORMATION126
31606 ,P_EHC_ATTRIBUTE17 => r_EHC.INFORMATION127
31607 ,P_EHC_ATTRIBUTE18 => r_EHC.INFORMATION128
31608 ,P_EHC_ATTRIBUTE19 => r_EHC.INFORMATION129
31609 ,P_EHC_ATTRIBUTE2 => r_EHC.INFORMATION112
31610 ,P_EHC_ATTRIBUTE20 => r_EHC.INFORMATION130
31611 ,P_EHC_ATTRIBUTE21 => r_EHC.INFORMATION131
31612 ,P_EHC_ATTRIBUTE22 => r_EHC.INFORMATION132
31613 ,P_EHC_ATTRIBUTE23 => r_EHC.INFORMATION133
31614 ,P_EHC_ATTRIBUTE24 => r_EHC.INFORMATION134
31615 ,P_EHC_ATTRIBUTE25 => r_EHC.INFORMATION135
31616 ,P_EHC_ATTRIBUTE26 => r_EHC.INFORMATION136
31617 ,P_EHC_ATTRIBUTE27 => r_EHC.INFORMATION137
31618 ,P_EHC_ATTRIBUTE28 => r_EHC.INFORMATION138
31619 ,P_EHC_ATTRIBUTE29 => r_EHC.INFORMATION139
31620 ,P_EHC_ATTRIBUTE3 => r_EHC.INFORMATION113
31621 ,P_EHC_ATTRIBUTE30 => r_EHC.INFORMATION140
31622 ,P_EHC_ATTRIBUTE4 => r_EHC.INFORMATION114
31623 ,P_EHC_ATTRIBUTE5 => r_EHC.INFORMATION115
31624 ,P_EHC_ATTRIBUTE6 => r_EHC.INFORMATION116
31625 ,P_EHC_ATTRIBUTE7 => r_EHC.INFORMATION117
31626 ,P_EHC_ATTRIBUTE8 => r_EHC.INFORMATION118
31627 ,P_EHC_ATTRIBUTE9 => r_EHC.INFORMATION119
31628 ,P_EHC_ATTRIBUTE_CATEGORY => r_EHC.INFORMATION110
31629 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
31630 ,P_ELIG_HLTH_CVG_PRTE_ID => l_elig_hlth_cvg_prte_id
31631 ,P_EXCLD_FLAG => r_EHC.INFORMATION11
31632 ,P_OIPL_ID => l_OIPL_ID
31633 ,P_ORDR_NUM => r_EHC.INFORMATION261
31634 ,P_PL_TYP_OPT_TYP_ID => l_PL_TYP_OPT_TYP_ID
31635
31636 ,P_EFFECTIVE_START_DATE => l_effective_start_date
31637 ,P_EFFECTIVE_END_DATE => l_effective_end_date
31638 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
31639 ,P_DATETRACK_MODE => l_datetrack_mode
31640 );
31641 end if; -- l_update
31642 --
31643 end if;
31644 --
31645 -- Delete the row if it is end dated.
31646 --
31647 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
31648 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
31649 trunc(l_max_eed) = trunc(r_EHC.information3)) then
31650 --
31651 BEN_ELIG_HLTH_CVG_PRTE_API.delete_ELIG_HLTH_CVG_PRTE(
31652 --
31653 p_validate => false
31654 ,p_elig_hlth_cvg_prte_id => l_elig_hlth_cvg_prte_id
31655 ,p_effective_start_date => l_effective_start_date
31656 ,p_effective_end_date => l_effective_end_date
31657 ,p_object_version_number => l_object_version_number
31658 ,p_effective_date => l_max_eed
31659 ,p_datetrack_mode => hr_api.g_delete
31660 --
31661 );
31662 --
31663 end if;
31664 --
31665 l_prev_pk_id := l_current_pk_id ;
31666 --
31667 end if;
31668 --
31669 end if;
31670 --
31671 end loop;
31672 --
31673 exception when others then
31674 --
31675 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EHC',r_EHC.information5 ) ;
31676 --
31677 end create_EHC_rows;
31678
31679 ---------------------------------------------------------------
31680 ----------------------< create_EOP_rows >-----------------------
31681 ---------------------------------------------------------------
31682 --
31683 procedure create_EOP_rows
31684 (
31685 p_validate in number default 0
31686 ,p_copy_entity_txn_id in number
31687 ,p_effective_date in date
31688 ,p_prefix_suffix_text in varchar2 default null
31689 ,p_reuse_object_flag in varchar2 default null
31690 ,p_target_business_group_id in varchar2 default null
31691 ,p_prefix_suffix_cd in varchar2 default null
31692 ) is
31693 --
31694 l_ELIGY_PRFL_ID number;
31695 l_PL_ID number;
31696 cursor c_unique_EOP(l_table_alias varchar2) is
31697 select distinct cpe.information1,
31698 cpe.information2,
31699 cpe.information3,
31700 cpe.table_route_id
31701 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
31702 pqh_table_route tr
31703 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
31704 and cpe.table_route_id = tr.table_route_id
31705 -- and tr.where_clause = l_BEN_ELIG_ANTHR_PL_PRTE_F
31706 and tr.table_alias = l_table_alias
31707 and cpe.number_of_copies = 1 -- ADDITION
31708 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
31709 order by information1, information2; --added for bug: 5151945
31710 --
31711 --
31712 cursor c_EOP_min_max_dates(c_table_route_id number,
31713 c_information1 number) is
31714 select
31715 min(cpe.information2) min_esd,
31716 max(cpe.information3) min_eed
31717 from ben_copy_entity_results cpe
31718 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
31719 and cpe.table_route_id = c_table_route_id
31720 and cpe.information1 = c_information1 ;
31721 --
31722 cursor c_EOP(c_table_route_id number,
31723 c_information1 number,
31724 c_information2 date,
31725 c_information3 date ) is
31726 select
31727 cpe.*
31728 from ben_copy_entity_results cpe
31729 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
31730 and cpe.table_route_id = c_table_route_id
31731 and cpe.information1 = c_information1
31732 and cpe.information2 = c_information2
31733 and cpe.information3 = c_information3
31734 and rownum = 1 ;
31735 -- Date Track target record
31736 cursor c_find_EOP_in_target(
31737 c_effective_start_date date,
31738 c_effective_end_date date,
31739 c_business_group_id number,
31740 c_new_pk_id number) is
31741 select
31742 EOP.elig_anthr_pl_prte_id new_value
31743 from BEN_ELIG_ANTHR_PL_PRTE_F EOP
31744 where
31745 EOP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
31746 EOP.PL_ID = l_PL_ID and
31747 EOP.business_group_id = c_business_group_id
31748 and EOP.elig_anthr_pl_prte_id <> c_new_pk_id
31749 and c_effective_start_date between effective_start_date
31750 and effective_end_date ;
31751 --END TEMPIK
31752 /*TEMPIK
31753 and exists ( select null
31754 from BEN_ELIG_ANTHR_PL_PRTE_F EOP1
31755 where
31756 EOP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
31757 EOP1.PL_ID = l_PL_ID and
31758 EOP1.business_group_id = c_business_group_id
31759 and EOP1.effective_start_date <= c_effective_start_date )
31760 and exists ( select null
31761 from BEN_ELIG_ANTHR_PL_PRTE_F EOP2
31762 where
31763 EOP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
31764 EOP2.PL_ID = l_PL_ID and
31765 EOP2.business_group_id = c_business_group_id
31766 and EOP2.effective_end_date >= c_effective_end_date )
31767 ;
31768 TEMPIK */
31769 --TEMPIK
31770 l_dt_rec_found boolean ;
31771 --END TEMPIK
31772 --
31773
31774 --UPD START
31775 --
31776 l_update boolean := false ;
31777 l_datetrack_mode varchar2(80) := hr_api.g_update;
31778 l_process_date date;
31779 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
31780 --
31781 --UPD END
31782 l_current_pk_id number := null ;
31783
31784 l_prev_pk_id number := null ;
31785 l_first_rec boolean := true ;
31786 r_EOP c_EOP%rowtype;
31787 l_elig_anthr_pl_prte_id number ;
31788 l_object_version_number number ;
31789 l_effective_start_date date ;
31790 l_effective_end_date date ;
31791 l_prefix pqh_copy_entity_attribs.information1%type := null;
31792 l_suffix pqh_copy_entity_attribs.information1%type := null;
31793 l_new_value number(15);
31794 l_object_found_in_target boolean := false ;
31795 l_min_esd date;
31796 l_max_eed date;
31797 l_effective_date date;
31798 --
31799 begin
31800 -- Initialization
31801 l_object_found_in_target := false ;
31802 -- End Initialization
31803 -- Derive the prefix - sufix
31804 if p_prefix_suffix_cd = 'PREFIX' then
31805 l_prefix := p_prefix_suffix_text ;
31806 elsif p_prefix_suffix_cd = 'SUFFIX' then
31807 l_suffix := p_prefix_suffix_text ;
31808 else
31809 l_prefix := null ;
31810 l_suffix := null ;
31811 end if ;
31812 -- End Prefix Sufix derivation
31813 for r_EOP_unique in c_unique_EOP('EOP') loop
31814
31815 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
31816 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
31817 r_EOP_unique.information3 >=
31818 ben_pd_copy_to_ben_one.g_copy_effective_date)
31819 ) then
31820 --
31821 hr_utility.set_location(' r_EOP_unique.table_route_id '||r_EOP_unique.table_route_id,10);
31822 hr_utility.set_location(' r_EOP_unique.information1 '||r_EOP_unique.information1,10);
31823 hr_utility.set_location( 'r_EOP_unique.information2 '||r_EOP_unique.information2,10);
31824 hr_utility.set_location( 'r_EOP_unique.information3 '||r_EOP_unique.information3,10);
31825 -- If reuse objects flag is 'Y' then check for the object in the target business group
31826 -- if found insert the record into PLSql table and exit the loop else try create the
31827 -- object in the target business group
31828 --
31829 l_object_found_in_target := false ;
31830 --UPD START
31831 l_update := false;
31832 l_process_date := p_effective_date;
31833 l_dml_operation:= r_EOP_unique.dml_operation ;
31834 --
31835 /**********************moved from below **********************/
31836 open c_EOP(r_EOP_unique.table_route_id,
31837 r_EOP_unique.information1,
31838 r_EOP_unique.information2,
31839 r_EOP_unique.information3 ) ;
31840 --
31841 fetch c_EOP into r_EOP ;
31842 --
31843 close c_EOP ;
31844 --
31845 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EOP.INFORMATION263,l_dml_operation);
31846
31847 -- Only For Use by Create Wizard - Same Business Group
31848 l_PL_ID := NVL(get_fk('PL_ID', r_EOP.INFORMATION261,l_dml_operation),
31849 r_EOP.INFORMATION261);
31850
31851 /**********************************************************/
31852
31853 if l_dml_operation = 'UPDATE' then
31854 --
31855 l_object_found_in_target := TRUE;
31856 --
31857 if l_process_date between r_EOP_unique.information2 and r_EOP_unique.information3 then
31858 l_update := true;
31859 if r_EOP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
31860 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ANTHR_PL_PRTE_ID' then
31861 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ANTHR_PL_PRTE_ID' ;
31862 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EOP_unique.information1 ;
31863 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EOP_unique.information1 ;
31864 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
31865 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EOP_unique.table_route_id;
31866 --
31867 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
31868 --
31869 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
31870 --
31871 -- log_data('EOP',l_new_value,l_prefix || r_EOP_unique.name|| l_suffix,'REUSED');
31872 --
31873 end if ;
31874 hr_utility.set_location( 'found record for update',10);
31875 --
31876 else
31877 --
31878 l_update := false;
31879 --
31880 end if;
31881 else
31882 --
31883 --UPD END
31884 l_min_esd := null ;
31885 l_max_eed := null ;
31886 open c_EOP_min_max_dates(r_EOP_unique.table_route_id, r_EOP_unique.information1 ) ;
31887 fetch c_EOP_min_max_dates into l_min_esd,l_max_eed ;
31888 --
31889
31890 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
31891 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
31892 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
31893 end if;
31894 l_min_esd := greatest(l_min_esd,r_EOP_unique.information2);
31895 /**********************moved up from here **********************
31896 open c_EOP(r_EOP_unique.table_route_id,
31897 r_EOP_unique.information1,
31898 r_EOP_unique.information2,
31899 r_EOP_unique.information3 ) ;
31900 --
31901 fetch c_EOP into r_EOP ;
31902 --
31903 close c_EOP ;
31904 --
31905 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_EOP.INFORMATION263,l_dml_operation);
31906
31907 -- Only For Use by Create Wizard - Same Business Group
31908 l_PL_ID := NVL(get_fk('PL_ID', r_EOP.INFORMATION261,l_dml_operation),
31909 r_EOP.INFORMATION261);
31910
31911 **********************************************************/
31912
31913 if p_reuse_object_flag = 'Y' then
31914 if c_EOP_min_max_dates%found then
31915 -- cursor to find the object
31916 open c_find_EOP_in_target( l_min_esd,l_max_eed,
31917 p_target_business_group_id, nvl(l_elig_anthr_pl_prte_id, -999) ) ;
31918 fetch c_find_EOP_in_target into l_new_value ;
31919 if c_find_EOP_in_target%found then
31920 --
31921 --TEMPIK
31922 l_dt_rec_found := dt_api.check_min_max_dates
31923 (p_base_table_name => 'BEN_ELIG_ANTHR_PL_PRTE_F',
31924 p_base_key_column => 'ELIG_ANTHR_PL_PRTE_ID',
31925 p_base_key_value => l_new_value,
31926 p_from_date => l_min_esd,
31927 p_to_date => l_max_eed );
31928 if l_dt_rec_found THEN
31929 --END TEMPIK
31930 if r_EOP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999) or
31931 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_ANTHR_PL_PRTE_ID' then
31932 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ANTHR_PL_PRTE_ID' ;
31933 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EOP_unique.information1 ;
31934 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
31935 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
31936 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EOP_unique.table_route_id;
31937 --
31938 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
31939 --
31940 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
31941 end if ;
31942 --
31943 l_object_found_in_target := true ;
31944 --TEMPIK
31945 end if; -- l_dt_rec_found
31946 --END TEMPIK
31947 end if;
31948 close c_find_EOP_in_target ;
31949 --
31950 end if;
31951 end if ;
31952 --
31953 close c_EOP_min_max_dates ;
31954 end if; --if p_dml_operation
31955 --
31956 if not l_object_found_in_target OR l_update then
31957
31958 --
31959 l_current_pk_id := r_EOP.information1;
31960 --
31961 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
31962 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
31963 --
31964 if l_current_pk_id = l_prev_pk_id then
31965 --
31966 l_first_rec := false ;
31967 --
31968 else
31969 --
31970 l_first_rec := true ;
31971 --
31972 end if ;
31973 --
31974
31975 l_effective_date := r_EOP.information2;
31976 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
31977 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
31978 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
31979 end if;
31980
31981 if l_first_rec and not l_update then
31982 -- Call Create routine.
31983 hr_utility.set_location(' BEN_ELIG_ANTHR_PL_PRTE_F CREATE_ELIG_ANTHR_PL_PRTE ',20);
31984 BEN_ELIG_ANTHR_PL_PRTE_API.CREATE_ELIG_ANTHR_PL_PRTE(
31985 --
31986 P_VALIDATE => false
31987 ,P_EFFECTIVE_DATE => l_effective_date
31988 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
31989 --
31990 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
31991 ,P_ELIG_ANTHR_PL_PRTE_ID => l_elig_anthr_pl_prte_id
31992 ,P_EOP_ATTRIBUTE1 => r_EOP.INFORMATION111
31993 ,P_EOP_ATTRIBUTE10 => r_EOP.INFORMATION120
31994 ,P_EOP_ATTRIBUTE11 => r_EOP.INFORMATION121
31995 ,P_EOP_ATTRIBUTE12 => r_EOP.INFORMATION122
31996 ,P_EOP_ATTRIBUTE13 => r_EOP.INFORMATION123
31997 ,P_EOP_ATTRIBUTE14 => r_EOP.INFORMATION124
31998 ,P_EOP_ATTRIBUTE15 => r_EOP.INFORMATION125
31999 ,P_EOP_ATTRIBUTE16 => r_EOP.INFORMATION126
32000 ,P_EOP_ATTRIBUTE17 => r_EOP.INFORMATION127
32001 ,P_EOP_ATTRIBUTE18 => r_EOP.INFORMATION128
32002 ,P_EOP_ATTRIBUTE19 => r_EOP.INFORMATION129
32003 ,P_EOP_ATTRIBUTE2 => r_EOP.INFORMATION112
32004 ,P_EOP_ATTRIBUTE20 => r_EOP.INFORMATION130
32005 ,P_EOP_ATTRIBUTE21 => r_EOP.INFORMATION131
32006 ,P_EOP_ATTRIBUTE22 => r_EOP.INFORMATION132
32007 ,P_EOP_ATTRIBUTE23 => r_EOP.INFORMATION133
32008 ,P_EOP_ATTRIBUTE24 => r_EOP.INFORMATION134
32009 ,P_EOP_ATTRIBUTE25 => r_EOP.INFORMATION135
32010 ,P_EOP_ATTRIBUTE26 => r_EOP.INFORMATION136
32011 ,P_EOP_ATTRIBUTE27 => r_EOP.INFORMATION137
32012 ,P_EOP_ATTRIBUTE28 => r_EOP.INFORMATION138
32013 ,P_EOP_ATTRIBUTE29 => r_EOP.INFORMATION139
32014 ,P_EOP_ATTRIBUTE3 => r_EOP.INFORMATION113
32015 ,P_EOP_ATTRIBUTE30 => r_EOP.INFORMATION140
32016 ,P_EOP_ATTRIBUTE4 => r_EOP.INFORMATION114
32017 ,P_EOP_ATTRIBUTE5 => r_EOP.INFORMATION115
32018 ,P_EOP_ATTRIBUTE6 => r_EOP.INFORMATION116
32019 ,P_EOP_ATTRIBUTE7 => r_EOP.INFORMATION117
32020 ,P_EOP_ATTRIBUTE8 => r_EOP.INFORMATION118
32021 ,P_EOP_ATTRIBUTE9 => r_EOP.INFORMATION119
32022 ,P_EOP_ATTRIBUTE_CATEGORY => r_EOP.INFORMATION110
32023 ,P_EXCLD_FLAG => r_EOP.INFORMATION11
32024 ,P_ORDR_NUM => r_EOP.INFORMATION257
32025 ,P_PL_ID => l_PL_ID
32026
32027 ,P_EFFECTIVE_START_DATE => l_effective_start_date
32028 ,P_EFFECTIVE_END_DATE => l_effective_end_date
32029 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
32030 );
32031 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
32032 -- Update all relevent cer records with new pk_id
32033 hr_utility.set_location('Before plsql table ',222);
32034 hr_utility.set_location('new_value id '||l_elig_anthr_pl_prte_id,222);
32035 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_ANTHR_PL_PRTE_ID' ;
32036 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EOP.information1 ;
32037 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_ANTHR_PL_PRTE_ID ;
32038 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
32039 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EOP_unique.table_route_id;
32040 hr_utility.set_location('After plsql table ',222);
32041 --
32042 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
32043 --
32044 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
32045 --
32046 else
32047 --
32048 -- Call Update routine for the pk_id created in prev run .
32049 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
32050 hr_utility.set_location(' BEN_ELIG_ANTHR_PL_PRTE_F UPDATE_ELIG_ANTHR_PL_PRTE ',30);
32051 --UPD START
32052 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
32053 --
32054 if l_update then
32055 --
32056 l_datetrack_mode := r_EOP.datetrack_mode ;
32057 --
32058 get_dt_modes(
32059 p_effective_date => l_process_date,
32060 p_effective_end_date => r_EOP.information3,
32061 p_effective_start_date => r_EOP.information2,
32062 p_dml_operation => r_EOP.dml_operation,
32063 p_datetrack_mode => l_datetrack_mode );
32064 -- p_update => l_update
32065 --
32066 l_effective_date := l_process_date;
32067 l_ELIG_ANTHR_PL_PRTE_ID := r_EOP.information1;
32068 l_object_version_number := r_EOP.information265;
32069 --
32070 end if;
32071 --
32072 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
32073 --
32074 IF l_update OR l_dml_operation <> 'UPDATE' THEN
32075 --UPD END
32076
32077
32078 BEN_ELIG_ANTHR_PL_PRTE_API.UPDATE_ELIG_ANTHR_PL_PRTE(
32079 --
32080 P_VALIDATE => false
32081 ,P_EFFECTIVE_DATE => l_effective_date
32082 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
32083 --
32084 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
32085 ,P_ELIG_ANTHR_PL_PRTE_ID => l_elig_anthr_pl_prte_id
32086 ,P_EOP_ATTRIBUTE1 => r_EOP.INFORMATION111
32087 ,P_EOP_ATTRIBUTE10 => r_EOP.INFORMATION120
32088 ,P_EOP_ATTRIBUTE11 => r_EOP.INFORMATION121
32089 ,P_EOP_ATTRIBUTE12 => r_EOP.INFORMATION122
32090 ,P_EOP_ATTRIBUTE13 => r_EOP.INFORMATION123
32091 ,P_EOP_ATTRIBUTE14 => r_EOP.INFORMATION124
32092 ,P_EOP_ATTRIBUTE15 => r_EOP.INFORMATION125
32093 ,P_EOP_ATTRIBUTE16 => r_EOP.INFORMATION126
32094 ,P_EOP_ATTRIBUTE17 => r_EOP.INFORMATION127
32095 ,P_EOP_ATTRIBUTE18 => r_EOP.INFORMATION128
32096 ,P_EOP_ATTRIBUTE19 => r_EOP.INFORMATION129
32097 ,P_EOP_ATTRIBUTE2 => r_EOP.INFORMATION112
32098 ,P_EOP_ATTRIBUTE20 => r_EOP.INFORMATION130
32099 ,P_EOP_ATTRIBUTE21 => r_EOP.INFORMATION131
32100 ,P_EOP_ATTRIBUTE22 => r_EOP.INFORMATION132
32101 ,P_EOP_ATTRIBUTE23 => r_EOP.INFORMATION133
32102 ,P_EOP_ATTRIBUTE24 => r_EOP.INFORMATION134
32103 ,P_EOP_ATTRIBUTE25 => r_EOP.INFORMATION135
32104 ,P_EOP_ATTRIBUTE26 => r_EOP.INFORMATION136
32105 ,P_EOP_ATTRIBUTE27 => r_EOP.INFORMATION137
32106 ,P_EOP_ATTRIBUTE28 => r_EOP.INFORMATION138
32107 ,P_EOP_ATTRIBUTE29 => r_EOP.INFORMATION139
32108 ,P_EOP_ATTRIBUTE3 => r_EOP.INFORMATION113
32109 ,P_EOP_ATTRIBUTE30 => r_EOP.INFORMATION140
32110 ,P_EOP_ATTRIBUTE4 => r_EOP.INFORMATION114
32111 ,P_EOP_ATTRIBUTE5 => r_EOP.INFORMATION115
32112 ,P_EOP_ATTRIBUTE6 => r_EOP.INFORMATION116
32113 ,P_EOP_ATTRIBUTE7 => r_EOP.INFORMATION117
32114 ,P_EOP_ATTRIBUTE8 => r_EOP.INFORMATION118
32115 ,P_EOP_ATTRIBUTE9 => r_EOP.INFORMATION119
32116 ,P_EOP_ATTRIBUTE_CATEGORY => r_EOP.INFORMATION110
32117 ,P_EXCLD_FLAG => r_EOP.INFORMATION11
32118 ,P_ORDR_NUM => r_EOP.INFORMATION257
32119 ,P_PL_ID => l_PL_ID
32120
32121 ,P_EFFECTIVE_START_DATE => l_effective_start_date
32122 ,P_EFFECTIVE_END_DATE => l_effective_end_date
32123 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
32124 ,P_DATETRACK_MODE => l_datetrack_mode
32125 );
32126 end if; -- l_update
32127 --
32128 end if;
32129 --
32130 -- Delete the row if it is end dated.
32131 --
32132 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
32133 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
32134 trunc(l_max_eed) = trunc(r_EOP.information3)) then
32135 --
32136 BEN_ELIG_ANTHR_PL_PRTE_API.delete_ELIG_ANTHR_PL_PRTE(
32137 --
32138 p_validate => false
32139 ,p_elig_anthr_pl_prte_id => l_elig_anthr_pl_prte_id
32140 ,p_effective_start_date => l_effective_start_date
32141 ,p_effective_end_date => l_effective_end_date
32142 ,p_object_version_number => l_object_version_number
32143 ,p_effective_date => l_max_eed
32144 ,p_datetrack_mode => hr_api.g_delete
32145 --
32146 );
32147 --
32148 end if;
32149 --
32150 l_prev_pk_id := l_current_pk_id ;
32151 --
32152 end if;
32153 --
32154 end if;
32155 --
32156 end loop;
32157 --
32158 exception when others then
32159 --
32160 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EOP',r_EOP.information5 ) ;
32161 --
32162 end create_EOP_rows;
32163 --
32164 -- Bug 4169120 : Rate By Criteria
32165 --
32166 ---------------------------------------------------------------
32167 ------------------< map_org_hrchy_in_target >------------------
32168 ---------------------------------------------------------------
32169 FUNCTION map_org_hrchy_in_target (
32170 p_org_stru_name IN VARCHAR2,
32171 p_start_org_name IN VARCHAR2,
32172 p_target_business_group_id IN NUMBER,
32173 p_effective_date IN DATE,
32174 p_org_structure_version_id OUT NOCOPY NUMBER,
32175 p_organization_id OUT NOCOPY NUMBER
32176 ) RETURN BOOLEAN
32177 IS
32178 --
32179 l_map_succeed BOOLEAN;
32180 --
32181 CURSOR c_org_stru_ver (
32182 cv_org_stru_name VARCHAR2,
32183 cv_effective_date DATE,
32184 cv_business_group_id NUMBER
32185 )
32186 IS
32187 SELECT osv.org_structure_version_id
32188 FROM per_organization_structures_v os,
32189 per_org_structure_versions osv
32190 WHERE os.business_group_id = cv_business_group_id
32191 AND os.organization_structure_id = osv.organization_structure_id
32192 AND os.NAME = cv_org_stru_name
32193 AND cv_effective_date BETWEEN osv.date_from
32194 AND NVL (osv.date_to, cv_effective_date);
32195 --
32196 CURSOR c_start_org_name (
32197 cv_org_structure_version_id NUMBER,
32198 cv_org_name VARCHAR2,
32199 cv_business_group_id NUMBER
32200 )
32201 IS
32202 SELECT organization_id
32203 FROM hr_all_organization_units org, per_org_structure_elements ose
32204 WHERE ose.org_structure_version_id = cv_org_structure_version_id
32205 AND ( ose.organization_id_parent = org.organization_id
32206 OR ose.organization_id_child = org.organization_id
32207 )
32208 AND org.NAME = cv_org_name
32209 AND org.business_group_id = cv_business_group_id;
32210 --
32211 BEGIN
32212 --
32213 -- Get Organization Hierarchy
32214 --
32215 open c_org_stru_ver (cv_org_stru_name => p_org_stru_name,
32216 cv_effective_date => p_effective_date,
32217 cv_business_group_id => p_target_business_group_id );
32218 --
32219 fetch c_org_stru_ver into p_org_structure_version_id;
32220 --
32221 if c_org_stru_ver%found
32222 then
32223 --
32224 l_map_succeed := true;
32225 --
32226 else
32227 --
32228 l_map_succeed := false;
32229 --
32230 end if;
32231 --
32232 if l_map_succeed = true
32233 then
32234 --
32235 -- Get Start Organization
32236 --
32237 open c_start_org_name ( cv_org_structure_version_id => p_org_structure_version_id,
32238 cv_org_name => p_start_org_name,
32239 cv_business_group_id => p_target_business_group_id );
32240 --
32241 fetch c_start_org_name into p_organization_id;
32242 --
32243 if c_start_org_name%found
32244 then
32245 --
32246 l_map_succeed := true;
32247 --
32248 else
32249 --
32250 l_map_succeed := false;
32251 --
32252 end if; /* c_start_org_name%found */
32253 --
32254 close c_start_org_name;
32255 --
32256 end if; /* l_map_succeed = true */
32257 --
32258 close c_org_stru_ver;
32259 --
32260 if l_map_succeed = false
32261 then
32262 --
32263 p_org_structure_version_id := null;
32264 p_organization_id := null;
32265 --
32266 end if;
32267 --
32268 return l_map_succeed;
32269 --
32270 END map_org_hrchy_in_target;
32271 --
32272 ---------------------------------------------------------------
32273 ------------------< map_pos_hrchy_in_target >------------------
32274 ---------------------------------------------------------------
32275 FUNCTION map_pos_hrchy_in_target (
32276 p_pos_stru_name IN VARCHAR2,
32277 p_start_pos_name IN VARCHAR2,
32278 p_target_business_group_id IN NUMBER,
32279 p_effective_date IN DATE,
32280 p_pos_structure_version_id OUT NOCOPY NUMBER,
32281 p_position_id OUT NOCOPY NUMBER
32282 ) RETURN BOOLEAN
32283 IS
32284 --
32285 l_map_succeed BOOLEAN;
32286 --
32287 CURSOR c_pos_stru_ver (
32288 cv_pos_stru_name VARCHAR2,
32289 cv_effective_date DATE,
32290 cv_business_group_id NUMBER
32291 )
32292 IS
32293 SELECT psv.pos_structure_version_id
32294 FROM per_position_structures_v ps, per_pos_structure_versions psv
32295 WHERE ps.business_group_id = cv_business_group_id
32296 AND ps.position_structure_id = psv.position_structure_id
32297 AND ps.NAME = cv_pos_stru_name
32298 AND cv_effective_date BETWEEN psv.date_from
32299 AND NVL (psv.date_to, cv_effective_date);
32300 --
32301 CURSOR c_start_pos_name (
32302 cv_pos_structure_version_id NUMBER,
32303 cv_pos_name VARCHAR2,
32304 cv_business_group_id NUMBER,
32305 cv_effective_date DATE
32306 )
32307 IS
32308 SELECT position_id
32309 FROM hr_all_positions_f_vl pos, per_pos_structure_elements pse
32310 WHERE pse.pos_structure_version_id = cv_pos_structure_version_id
32311 AND ( pse.parent_position_id = pos.position_id
32312 OR pse.subordinate_position_id = pos.position_id
32313 )
32314 AND pos.NAME = cv_pos_name
32315 AND cv_effective_date BETWEEN pos.effective_start_date
32316 AND pos.effective_end_date
32317 AND pos.business_group_id = cv_business_group_id;
32318 --
32319 BEGIN
32320 --
32321 -- Get Position Hierarchy
32322 --
32323 open c_pos_stru_ver (cv_pos_stru_name => p_pos_stru_name,
32324 cv_effective_date => p_effective_date,
32325 cv_business_group_id => p_target_business_group_id );
32326 --
32327 fetch c_pos_stru_ver into p_pos_structure_version_id;
32328 --
32329 if c_pos_stru_ver%found
32330 then
32331 --
32332 l_map_succeed := true;
32333 --
32334 else
32335 --
32336 l_map_succeed := false;
32337 --
32338 end if;
32339 --
32340 if l_map_succeed = true
32341 then
32342 --
32343 -- Get Start Position
32344 --
32345 open c_start_pos_name ( cv_pos_structure_version_id => p_pos_structure_version_id,
32346 cv_pos_name => p_start_pos_name,
32347 cv_effective_date => p_effective_date,
32348 cv_business_group_id => p_target_business_group_id );
32349 --
32350 fetch c_start_pos_name into p_position_id;
32351 --
32352 if c_start_pos_name%found
32353 then
32354 --
32355 l_map_succeed := true;
32356 --
32357 else
32358 --
32359 l_map_succeed := false;
32360 --
32361 end if; /* c_start_pos_name%found */
32362 --
32363 close c_start_pos_name;
32364 --
32365 end if; /* l_map_succeed = true */
32366 --
32367 close c_pos_stru_ver;
32368 --
32369 if l_map_succeed = false
32370 then
32371 --
32372 p_pos_structure_version_id := null;
32373 p_position_id := null;
32374 --
32375 end if;
32376 --
32377 return l_map_succeed;
32378 --
32379 END map_pos_hrchy_in_target;
32380 --
32381 ---------------------------------------------------------------
32382 ----------------------< create_ECV_rows >-----------------------
32383 ---------------------------------------------------------------
32384 --
32385 PROCEDURE create_ecv_rows (
32386 p_validate IN NUMBER DEFAULT 0,
32387 p_copy_entity_txn_id IN NUMBER,
32388 p_effective_date IN DATE,
32389 p_prefix_suffix_text IN VARCHAR2 DEFAULT NULL,
32390 p_reuse_object_flag IN VARCHAR2 DEFAULT NULL,
32391 p_target_business_group_id IN VARCHAR2 DEFAULT NULL,
32392 p_prefix_suffix_cd IN VARCHAR2 DEFAULT NULL
32393 )
32394 IS
32395 --
32396 l_eligy_prfl_id NUMBER;
32397 l_eligy_criteria_id NUMBER;
32398 --
32399 CURSOR c_unique_ecv (cv_table_alias VARCHAR2)
32400 IS
32401 SELECT DISTINCT cpe.information1, cpe.information2, cpe.information3,
32402 cpe.table_route_id, cpe.dml_operation,
32403 cpe.datetrack_mode, cpe.information263
32404 FROM ben_copy_entity_results cpe, pqh_table_route tr
32405 WHERE cpe.copy_entity_txn_id = p_copy_entity_txn_id
32406 AND cpe.table_route_id = tr.table_route_id
32407 AND tr.table_alias = cv_table_alias
32408 AND cpe.number_of_copies = 1
32409 GROUP BY cpe.information263,
32410 cpe.information1,
32411 cpe.information2,
32412 cpe.information3,
32413 cpe.table_route_id,
32414 cpe.dml_operation,
32415 cpe.datetrack_mode
32416 order by information1, information2; --added for bug: 5151945
32417 --
32418 CURSOR c_ecv_min_max_dates (cv_table_route_id NUMBER, cv_information1 NUMBER)
32419 IS
32420 SELECT MIN (cpe.information2) min_esd, MAX (cpe.information3) min_eed
32421 FROM ben_copy_entity_results cpe
32422 WHERE cpe.copy_entity_txn_id = p_copy_entity_txn_id
32423 AND cpe.table_route_id = cv_table_route_id
32424 AND cpe.information1 = cv_information1;
32425 --
32426 CURSOR c_ecv (
32427 cv_table_route_id NUMBER,
32428 cv_information1 NUMBER,
32429 cv_information2 DATE,
32430 cv_information3 DATE
32431 )
32432 IS
32433 SELECT cpe.*
32434 FROM ben_copy_entity_results cpe
32435 WHERE cpe.copy_entity_txn_id = p_copy_entity_txn_id
32436 AND cpe.table_route_id = cv_table_route_id
32437 AND cpe.information1 = cv_information1
32438 AND cpe.information2 = cv_information2
32439 AND cpe.information3 = cv_information3
32440 AND ROWNUM = 1;
32441 --
32442 CURSOR c_find_ecv_in_target (
32443 cv_effective_start_date DATE,
32444 cv_effective_end_date DATE,
32445 cv_business_group_id NUMBER,
32446 cv_new_pk_id NUMBER
32447 )
32448 IS
32449 SELECT ecv.eligy_crit_values_id new_value
32450 FROM ben_eligy_crit_values_f ecv
32451 WHERE ecv.eligy_prfl_id = l_eligy_prfl_id
32452 AND ecv.eligy_criteria_id = l_eligy_criteria_id
32453 AND ecv.business_group_id = cv_business_group_id
32454 AND ecv.eligy_crit_values_id <> cv_new_pk_id
32455 AND cv_effective_start_date BETWEEN effective_start_date
32456 AND effective_end_date;
32457 --
32458 CURSOR c_unique_ecv_id (cv_table_alias VARCHAR2)
32459 IS
32460 SELECT DISTINCT cpe.information1, cpe.information5, cpe.information263
32461 FROM ben_copy_entity_results cpe, pqh_table_route tr
32462 WHERE cpe.copy_entity_txn_id = p_copy_entity_txn_id
32463 AND cpe.table_route_id = tr.table_route_id
32464 AND tr.table_alias = cv_table_alias
32465 AND cpe.number_of_copies = 1
32466 GROUP BY cpe.information1,
32467 cpe.information5,
32468 cpe.information263
32469 ORDER BY cpe.information263;
32470 --
32471 CURSOR c_target_type
32472 IS
32473 SELECT information3
32474 FROM pqh_copy_entity_attribs
32475 WHERE copy_entity_Txn_id = p_copy_entity_txn_id;
32476 --
32477 CURSOR c_display_name (p_table_alias VARCHAR2)
32478 IS
32479 SELECT display_name, table_route_id
32480 FROM pqh_table_route
32481 WHERE table_alias = p_table_alias;
32482 --
32483 CURSOR c_parent_data (
32484 p_parent_pk_id NUMBER,
32485 p_copy_entity_txn_id NUMBER,
32486 p_table_route_id NUMBER
32487 )
32488 IS
32489 SELECT information5
32490 FROM ben_copy_entity_results
32491 WHERE table_route_id = p_table_route_id
32492 AND copy_entity_txn_id = p_copy_entity_txn_id
32493 AND information1 = p_parent_pk_id;
32494 --
32495 l_dt_rec_found BOOLEAN;
32496 l_update BOOLEAN := FALSE;
32497 l_datetrack_mode VARCHAR2 (80) := hr_api.g_update;
32498 l_process_date DATE;
32499 l_dml_operation ben_copy_entity_results.dml_operation%TYPE;
32500 l_current_pk_id NUMBER := NULL;
32501 l_prev_pk_id NUMBER := NULL;
32502 l_first_rec BOOLEAN := TRUE;
32503 r_ecv c_ecv%ROWTYPE;
32504 l_eligy_crit_values_id NUMBER;
32505 l_object_version_number NUMBER;
32506 l_effective_start_date DATE;
32507 l_effective_end_date DATE;
32508 l_prefix pqh_copy_entity_attribs.information1%TYPE
32509 := NULL;
32510 l_suffix pqh_copy_entity_attribs.information1%TYPE
32511 := NULL;
32512 l_new_value NUMBER (15);
32513 l_object_found_in_target BOOLEAN := FALSE;
32514 l_min_esd DATE;
32515 l_max_eed DATE;
32516 l_effective_date DATE;
32517 l_target_type VARCHAR2(30);
32518 --
32519 l_para_spacer VARCHAR2(50) := ' ';
32520 l_label_start_tag VARCHAR2(50) := '<B>';
32521 l_label_end_tag VARCHAR2(50) := '</B>';
32522 l_elpro_name VARCHAR2(240);
32523 l_elp_display_name VARCHAR2(80);
32524 l_elp_table_route_id NUMBER(15);
32525 l_ecv_display_name VARCHAR2(80);
32526 l_ecv_table_route_id NUMBER(15);
32527 l_prev_parent_pk_id NUMBER(15);
32528 l_prev_ecv_id NUMBER(15);
32529 l_map_succeed BOOLEAN;
32530 l_number_value1 NUMBER(15);
32531 l_number_value2 NUMBER(15);
32532 --
32533 TYPE l_not_copied_egl_rec_type IS RECORD (
32534 eligy_crit_values_id NUMBER (15),
32535 eligy_prfl_id NUMBER (15),
32536 text VARCHAR2 (2000)
32537 );
32538 --
32539 TYPE not_copied_egl_tbl IS TABLE OF l_not_copied_egl_rec_type
32540 INDEX BY BINARY_INTEGER;
32541 --
32542 l_not_copied_egl_tbl NOT_COPIED_EGL_TBL;
32543 l_not_copied_egl_table_count NUMBER(15) := 0;
32544 --
32545 BEGIN
32546 --
32547 l_object_found_in_target := FALSE;
32548 --
32549 IF p_prefix_suffix_cd = 'PREFIX'
32550 THEN
32551 --
32552 l_prefix := p_prefix_suffix_text;
32553 --
32554 ELSIF p_prefix_suffix_cd = 'SUFFIX'
32555 THEN
32556 --
32557 l_suffix := p_prefix_suffix_text;
32558 --
32559 ELSE
32560 --
32561 l_prefix := NULL;
32562 l_suffix := NULL;
32563 --
32564 END IF;
32565 --
32566 open c_target_type;
32567 --
32568 fetch c_target_type into l_target_type;
32569 --
32570 close c_target_type;
32571 --
32572 --
32573 --
32574 -- IF l_target_type = 'BEN_PDSMBG'
32575 -- THEN
32576 --
32577 FOR r_ecv_unique IN c_unique_ecv ('ECV')
32578 LOOP
32579 IF ( ben_pd_copy_to_ben_one.g_copy_effective_date IS NULL
32580 OR ( ben_pd_copy_to_ben_one.g_copy_effective_date IS NOT NULL
32581 AND r_ecv_unique.information3 >=
32582 ben_pd_copy_to_ben_one.g_copy_effective_date
32583 )
32584 )
32585 THEN
32586 --
32587 hr_utility.set_location(' r_ecv_unique.table_route_id ' || r_ecv_unique.table_route_id,10);
32588 hr_utility.set_location(' r_ecv_unique.information1 ' || r_ecv_unique.information1,10);
32589 hr_utility.set_location( 'r_ecv_unique.information2 ' || r_ecv_unique.information2,10);
32590 hr_utility.set_location( 'r_ecv_unique.information3 ' || r_ecv_unique.information3,10);
32591 --
32592 -- If reuse objects flag is 'Y' then check for the object in the target business group
32593 -- if found insert the record into PLSql table and exit the loop else try create the
32594 -- object in the target business group
32595 --
32596 l_object_found_in_target := FALSE;
32597 l_update := FALSE;
32598 l_process_date := p_effective_date;
32599 l_dml_operation := r_ecv_unique.dml_operation;
32600 --
32601 OPEN c_ecv (r_ecv_unique.table_route_id,
32602 r_ecv_unique.information1,
32603 r_ecv_unique.information2,
32604 r_ecv_unique.information3
32605 );
32606 --
32607 FETCH c_ecv INTO r_ecv;
32608 --
32609 CLOSE c_ecv;
32610 --
32611 l_eligy_prfl_id := get_fk ('ELIGY_PRFL_ID', r_ecv.information263, l_dml_operation);
32612 --
32613 -- Only For Use by Create Wizard - Same Business Group
32614 --
32615 l_eligy_criteria_id := get_fk ('ELIGY_CRITERIA_ID', r_ecv.information272, l_dml_operation); /* Bug 4314927 */
32616 --
32617 IF l_dml_operation = 'UPDATE'
32618 THEN
32619 --
32620 l_object_found_in_target := TRUE;
32621 --
32622 IF l_process_date BETWEEN r_ecv_unique.information2
32623 AND r_ecv_unique.information3
32624 THEN
32625 --
32626 l_update := TRUE;
32627 --
32628 IF r_ecv_unique.information1
32629 <> NVL (ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count - 1).old_value, -999 )
32630 OR NVL (ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count - 1).pk_id_column, '999')
32631 <> 'ELIGY_CRIT_VALUES_ID'
32632 THEN
32633 --
32634 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).pk_id_column :='ELIGY_CRIT_VALUES_ID';
32635 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).old_value := r_ecv_unique.information1;
32636 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).new_value := r_ecv_unique.information1;
32637 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'REUSED';
32638 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).table_route_id := r_ecv_unique.table_route_id;
32639 --
32640 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
32641 --
32642 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1;
32643 --
32644 -- log_data('ecv',l_new_value,l_prefix || r_ecv_unique.name|| l_suffix,'REUSED');
32645 --
32646 END IF;
32647 --
32648 hr_utility.set_location ('found record for update', 10);
32649 --
32650 ELSE
32651 --
32652 l_update := FALSE;
32653 --
32654 END IF;
32655 --
32656 ELSE
32657 --
32658 l_min_esd := NULL;
32659 l_max_eed := NULL;
32660 OPEN c_ecv_min_max_dates (r_ecv_unique.table_route_id,
32661 r_ecv_unique.information1
32662 );
32663 FETCH c_ecv_min_max_dates INTO l_min_esd, l_max_eed;
32664 --
32665 IF ( ben_pd_copy_to_ben_one.g_copy_effective_date IS NOT NULL
32666 AND l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date
32667 )
32668 THEN
32669 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
32670 END IF;
32671
32672 l_min_esd := GREATEST (l_min_esd, r_ecv_unique.information2);
32673
32674 IF p_reuse_object_flag = 'Y'
32675 THEN
32676 IF c_ecv_min_max_dates%FOUND
32677 THEN
32678 -- cursor to find the object
32679 OPEN c_find_ecv_in_target (l_min_esd,
32680 l_max_eed,
32681 p_target_business_group_id,
32682 NVL (l_eligy_crit_values_id, -999)
32683 );
32684 FETCH c_find_ecv_in_target INTO l_new_value;
32685 --
32686 IF c_find_ecv_in_target%FOUND
32687 THEN
32688 --
32689 l_dt_rec_found :=
32690 dt_api.check_min_max_dates (p_base_table_name => 'BEN_ELIGY_CRIT_VALUES_F',
32691 p_base_key_column => 'ELIGY_CRIT_VALUES_ID',
32692 p_base_key_value => l_new_value,
32693 p_from_date => l_min_esd,
32694 p_to_date => l_max_eed
32695 );
32696
32697 IF l_dt_rec_found
32698 THEN
32699 IF r_ecv_unique.information1 <>
32700 NVL (ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count - 1).old_value, -999)
32701 OR NVL (ben_pd_copy_to_ben_one.g_pk_tbl ( ben_pd_copy_to_ben_one.g_count - 1).pk_id_column, '999')
32702 <> 'ELIGY_CRIT_VALUES_ID'
32703 THEN
32704 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).pk_id_column := 'ELIGY_CRIT_VALUES_ID';
32705 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).old_value := r_ecv_unique.information1;
32706 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).new_value := l_new_value;
32707 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'REUSED';
32708 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).table_route_id := r_ecv_unique.table_route_id;
32709 --
32710 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
32711 --
32712 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1;
32713 END IF;
32714
32715 --
32716 l_object_found_in_target := TRUE;
32717 END IF; -- l_dt_rec_found
32718 END IF;
32719
32720 CLOSE c_find_ecv_in_target;
32721 --
32722 END IF;
32723 END IF;
32724
32725 --
32726 CLOSE c_ecv_min_max_dates;
32727 END IF;
32728
32729 --
32730 IF NOT l_object_found_in_target OR l_update
32731 THEN
32732 --
32733 l_current_pk_id := r_ecv.information1;
32734 --
32735 hr_utility.set_location (' l_current_pk_id ' || l_current_pk_id, 20 );
32736 hr_utility.set_location (' l_prev_pk_id ' || l_prev_pk_id, 20);
32737 --
32738 IF l_current_pk_id = l_prev_pk_id
32739 THEN
32740 --
32741 l_first_rec := FALSE;
32742 --
32743 ELSE
32744 --
32745 l_first_rec := TRUE;
32746 --
32747 END IF;
32748 --
32749 l_effective_date := r_ecv.information2;
32750 --
32751 IF ( ben_pd_copy_to_ben_one.g_copy_effective_date IS NOT NULL
32752 AND l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date
32753 )
32754 THEN
32755 --
32756 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
32757 --
32758 END IF;
32759 --
32760 --
32761 -- For 1. Organization Hierarchy
32762 -- ORG_STRUCTURE_NAME INFORMATION13
32763 -- START_ORGANIZATION_NAME INFORMATION187
32764 --
32765 -- 2. Position Hierarchy
32766 -- POS_STRUCTURE_NAME INFORMATION14
32767 -- START_POSITION_NAME INFORMATION188
32768 --
32769 -- we will try to auto map in the target business group
32770 -- If we are unable to auto map, then we will not copy corresponding ECV record
32771 --
32772 --
32773 l_map_succeed := true;
32774 l_number_value1 := r_ecv.information293;
32775 l_number_value2 := r_ecv.information294;
32776 --
32777 if r_ecv.information13 is not null
32778 then
32779 --
32780 l_map_succeed := map_org_hrchy_in_target ( p_org_stru_name => r_ecv.information13,
32781 p_start_org_name => r_ecv.information187,
32782 p_target_business_group_id => p_target_business_Group_id,
32783 p_effective_date => l_effective_date,
32784 p_org_structure_version_id => l_number_value1,
32785 p_organization_id => l_number_value2 );
32786 --
32787 elsif r_ecv.information14 is not null
32788 then
32789 --
32790 l_map_succeed := map_pos_hrchy_in_target ( p_pos_stru_name => r_ecv.information14,
32791 p_start_pos_name => r_ecv.information188,
32792 p_target_business_group_id => p_target_business_Group_id,
32793 p_effective_date => l_effective_date,
32794 p_pos_structure_version_id => l_number_value1,
32795 p_position_id => l_number_value2 );
32796 --
32797 end if;
32798 --
32799 IF l_map_succeed = true
32800 THEN
32801 --
32802 IF l_first_rec AND NOT l_update
32803 THEN
32804 -- Call Create routine.
32805 hr_utility.set_location ('BEN_ELIGY_CRIT_VALUES_API.CREATE_ELIGY_CRIT_VALUES ', 20);
32806 --
32807 ben_eligy_crit_values_api.create_eligy_crit_values
32808 (
32809 p_validate => FALSE,
32810 p_eligy_crit_values_id => l_eligy_crit_values_id,
32811 p_eligy_prfl_id => l_eligy_prfl_id,
32812 p_eligy_criteria_id => l_eligy_criteria_id,
32813 p_effective_start_date => l_effective_start_date,
32814 p_effective_end_date => l_effective_end_date,
32815 p_ordr_num => r_ecv.information260, /* Bug 4314927 */
32816 p_number_value1 => l_number_value1,
32817 p_number_value2 => l_number_value2,
32818 p_char_value1 => r_ecv.information185,
32819 p_char_value2 => r_ecv.information186,
32820 p_date_value1 => r_ecv.information306,
32821 p_date_value2 => r_ecv.information307,
32822 p_excld_flag => r_ecv.information11,
32823 p_business_group_id => p_target_business_group_id,
32824 --Bug 4592554
32825 p_char_value3 => r_ecv.information181,
32826 p_char_value4 => r_ecv.information182,
32827 p_number_value3 => r_ecv.information297,
32828 p_number_value4 => r_ecv.information298,
32829 p_date_value3 => r_ecv.information308,
32830 p_date_value4 => r_ecv.information309,
32831 --End Bug 4592554
32832 p_ecv_attribute_category => r_ecv.information110,
32833 p_ecv_attribute1 => r_ecv.information111,
32834 p_ecv_attribute2 => r_ecv.information112,
32835 p_ecv_attribute3 => r_ecv.information113,
32836 p_ecv_attribute4 => r_ecv.information114,
32837 p_ecv_attribute5 => r_ecv.information115,
32838 p_ecv_attribute6 => r_ecv.information116,
32839 p_ecv_attribute7 => r_ecv.information117,
32840 p_ecv_attribute8 => r_ecv.information118,
32841 p_ecv_attribute9 => r_ecv.information119,
32842 p_ecv_attribute10 => r_ecv.information120,
32843 p_ecv_attribute11 => r_ecv.information121,
32844 p_ecv_attribute12 => r_ecv.information122,
32845 p_ecv_attribute13 => r_ecv.information123,
32846 p_ecv_attribute14 => r_ecv.information124,
32847 p_ecv_attribute15 => r_ecv.information125,
32848 p_ecv_attribute16 => r_ecv.information126,
32849 p_ecv_attribute17 => r_ecv.information127,
32850 p_ecv_attribute18 => r_ecv.information128,
32851 p_ecv_attribute19 => r_ecv.information129,
32852 p_ecv_attribute20 => r_ecv.information130,
32853 p_ecv_attribute21 => r_ecv.information131,
32854 p_ecv_attribute22 => r_ecv.information132,
32855 p_ecv_attribute23 => r_ecv.information133,
32856 p_ecv_attribute24 => r_ecv.information134,
32857 p_ecv_attribute25 => r_ecv.information135,
32858 p_ecv_attribute26 => r_ecv.information136,
32859 p_ecv_attribute27 => r_ecv.information137,
32860 p_ecv_attribute28 => r_ecv.information138,
32861 p_ecv_attribute29 => r_ecv.information139,
32862 p_ecv_attribute30 => r_ecv.information140,
32863 p_object_version_number => l_object_version_number,
32864 p_effective_date => l_effective_date,
32865 P_CRITERIA_SCORE => r_ecv.INFORMATION295,
32866 P_CRITERIA_WEIGHT => r_ecv.INFORMATION296
32867 );
32868 --
32869 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
32870 -- Update all relevent cer records with new pk_id
32871 --
32872 hr_utility.set_location ('Before plsql table ', 222);
32873 hr_utility.set_location ('new_value id ' || l_eligy_crit_values_id, 222);
32874 --
32875 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).pk_id_column := 'ELIGY_CRIT_VALUES_ID';
32876 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).old_value := r_ecv.information1;
32877 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).new_value := l_eligy_crit_values_id;
32878 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'COPIED';
32879 ben_pd_copy_to_ben_one.g_pk_tbl (ben_pd_copy_to_ben_one.g_count).table_route_id := r_ecv_unique.table_route_id;
32880 --
32881 hr_utility.set_location ('After plsql table ', 222);
32882 --
32883 -- update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
32884 --
32885 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1;
32886 --
32887 ELSE
32888 --
32889 -- Call Update routine for the pk_id created in prev run .
32890 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
32891 --
32892 hr_utility.set_location ('BEN_ELIGY_CRIT_VALUES_API.UPDATE_ELIGY_CRIT_VALUES ', 30);
32893 hr_utility.set_location ('Before call to get_dt_modes l_dt_mode' || l_datetrack_mode, 5);
32894 --
32895 IF l_update
32896 THEN
32897 --
32898 l_datetrack_mode := r_ecv.datetrack_mode;
32899 --
32900 get_dt_modes (p_effective_date => l_process_date,
32901 p_effective_end_date => r_ecv.information3,
32902 p_effective_start_date => r_ecv.information2,
32903 p_dml_operation => r_ecv.dml_operation,
32904 p_datetrack_mode => l_datetrack_mode
32905 );
32906 --
32907 l_effective_date := l_process_date;
32908 l_eligy_crit_values_id := r_ecv.information1;
32909 l_object_version_number := r_ecv.information265;
32910 --
32911 END IF;
32912 --
32913 hr_utility.set_location ('After call to get_dt_modes l_dt_mode' || l_datetrack_mode, 5);
32914 --
32915 IF l_update OR l_dml_operation <> 'UPDATE'
32916 THEN
32917 --
32918 ben_eligy_crit_values_api.update_eligy_crit_values
32919 (
32920 p_validate => FALSE,
32921 p_eligy_crit_values_id => l_eligy_crit_values_id,
32922 p_eligy_prfl_id => l_eligy_prfl_id,
32923 p_eligy_criteria_id => l_eligy_criteria_id,
32924 p_effective_start_date => l_effective_start_date,
32925 p_effective_end_date => l_effective_end_date,
32926 p_ordr_num => r_ecv.information260, /* Bug 4402051 */
32927 p_number_value1 => l_number_value1,
32928 p_number_value2 => l_number_value2,
32929 p_char_value1 => r_ecv.information185,
32930 p_char_value2 => r_ecv.information186,
32931 p_date_value1 => r_ecv.information306,
32932 p_date_value2 => r_ecv.information307,
32933 p_excld_flag => r_ecv.information11,
32934 p_business_group_id => p_target_business_group_id,
32935 --Bug 4592554
32936 p_char_value3 => r_ecv.information181,
32937 p_char_value4 => r_ecv.information182,
32938 p_number_value3 => r_ecv.information297,
32939 p_number_value4 => r_ecv.information298,
32940 p_date_value3 => r_ecv.information308,
32941 p_date_value4 => r_ecv.information309,
32942 --End Bug 4592554
32943 p_ecv_attribute_category => r_ecv.information110,
32944 p_ecv_attribute1 => r_ecv.information111,
32945 p_ecv_attribute2 => r_ecv.information112,
32946 p_ecv_attribute3 => r_ecv.information113,
32947 p_ecv_attribute4 => r_ecv.information114,
32948 p_ecv_attribute5 => r_ecv.information115,
32949 p_ecv_attribute6 => r_ecv.information116,
32950 p_ecv_attribute7 => r_ecv.information117,
32951 p_ecv_attribute8 => r_ecv.information118,
32952 p_ecv_attribute9 => r_ecv.information119,
32953 p_ecv_attribute10 => r_ecv.information120,
32954 p_ecv_attribute11 => r_ecv.information121,
32955 p_ecv_attribute12 => r_ecv.information122,
32956 p_ecv_attribute13 => r_ecv.information123,
32957 p_ecv_attribute14 => r_ecv.information124,
32958 p_ecv_attribute15 => r_ecv.information125,
32959 p_ecv_attribute16 => r_ecv.information126,
32960 p_ecv_attribute17 => r_ecv.information127,
32961 p_ecv_attribute18 => r_ecv.information128,
32962 p_ecv_attribute19 => r_ecv.information129,
32963 p_ecv_attribute20 => r_ecv.information130,
32964 p_ecv_attribute21 => r_ecv.information131,
32965 p_ecv_attribute22 => r_ecv.information132,
32966 p_ecv_attribute23 => r_ecv.information133,
32967 p_ecv_attribute24 => r_ecv.information134,
32968 p_ecv_attribute25 => r_ecv.information135,
32969 p_ecv_attribute26 => r_ecv.information136,
32970 p_ecv_attribute27 => r_ecv.information137,
32971 p_ecv_attribute28 => r_ecv.information138,
32972 p_ecv_attribute29 => r_ecv.information139,
32973 p_ecv_attribute30 => r_ecv.information140,
32974 p_object_version_number => l_object_version_number,
32975 p_effective_date => l_effective_date,
32976 p_datetrack_mode => l_datetrack_mode,
32977 P_CRITERIA_SCORE => r_ecv.INFORMATION295,
32978 P_CRITERIA_WEIGHT => r_ecv.INFORMATION296
32979 );
32980 ---
32981 END IF;
32982 --
32983 END IF;
32984 --
32985 ELSE /* l_map_succeed = true */
32986 --
32987 -- Prepare Log messages for section Did Not Copy Following Objects.
32988 l_not_copied_egl_tbl(l_not_copied_egl_table_count).eligy_crit_values_id := r_ecv.information1;
32989 l_not_copied_egl_tbl(l_not_copied_egl_table_count).eligy_prfl_id := r_ecv.information263;
32990 l_not_copied_egl_tbl(l_not_copied_egl_table_count).text := r_ecv.information5;
32991 l_not_copied_egl_table_count := l_not_copied_egl_table_count + 1;
32992 --
32993 END IF; /* l_map_succeed = true */
32994 --
32995 --
32996 -- Delete the row if it is end dated.
32997 --
32998 IF ( TRUNC (l_max_eed) <> TRUNC (hr_api.g_eot)
32999 AND TRUNC (l_max_eed) <> l_effective_end_date /* Bug 4302963 */
33000 AND TRUNC (l_max_eed) = TRUNC (r_ecv.information3)
33001 )
33002 THEN
33003 --
33004 ben_eligy_crit_values_api.delete_eligy_crit_values
33005 (
33006 p_validate => FALSE,
33007 p_eligy_crit_values_id => l_eligy_crit_values_id,
33008 p_effective_start_date => l_effective_start_date,
33009 p_effective_end_date => l_effective_end_date,
33010 p_object_version_number => l_object_version_number,
33011 p_effective_date => l_max_eed,
33012 p_datetrack_mode => hr_api.g_delete
33013 );
33014 --
33015 END IF;
33016 --
33017 l_prev_pk_id := l_current_pk_id;
33018 --
33019 END IF;
33020 --
33021 END IF;
33022 --
33023 END LOOP;
33024 --
33025 --
33026 ----------------------< DISPLAY START >---------------------------
33027 -- Print the Not Copied data to Log File BEN_PD_COPY_TO_BEN_THREE.G_NOT_COPIED_TBL
33028 --
33029 if l_not_copied_egl_table_count > 0
33030 then
33031 --
33032 l_prev_parent_pk_id := null;
33033 l_prev_ecv_id := null;
33034 --
33035 open c_display_name('ELP');
33036 --
33037 fetch c_display_name into l_elp_display_name, l_elp_table_route_id;
33038 --
33039 close c_display_name;
33040 --
33041 open c_display_name('ECV');
33042 --
33043 fetch c_display_name into l_ecv_display_name, l_ecv_table_route_id;
33044 --
33045 close c_display_name;
33046 --
33047 --
33048 ben_pd_copy_to_ben_three.g_not_copied_tbl(ben_pd_copy_to_ben_three.g_not_copied_tbl_count).text
33049 := l_label_start_tag ||
33050 l_elp_display_name ||
33051 l_label_end_tag;
33052 --
33053 ben_pd_copy_to_ben_three.g_not_copied_tbl_count := ben_pd_copy_to_ben_three.g_not_copied_tbl_count + 1;
33054 --
33055 FOR i IN l_not_copied_egl_tbl.FIRST .. l_not_copied_egl_tbl.LAST
33056 LOOP
33057 --
33058 if nvl(l_prev_parent_pk_id, -1) <> l_not_copied_egl_tbl(i).eligy_prfl_id
33059 then
33060 --
33061 open c_parent_data ( l_not_copied_egl_tbl(i).eligy_prfl_id, p_copy_entity_txn_id, l_elp_table_route_id );
33062 --
33063 fetch c_parent_data into l_elpro_name;
33064 --
33065 close c_parent_data;
33066 --
33067 ben_pd_copy_to_ben_three.g_not_copied_tbl(ben_pd_copy_to_ben_three.g_not_copied_tbl_count).text
33068 := l_para_spacer || l_elpro_name;
33069 --
33070 ben_pd_copy_to_ben_three.g_not_copied_tbl_count := ben_pd_copy_to_ben_three.g_not_copied_tbl_count + 1;
33071 --
33072 ben_pd_copy_to_ben_three.g_not_copied_tbl(ben_pd_copy_to_ben_three.g_not_copied_tbl_count).text
33073 := l_label_start_tag || l_para_spacer || l_para_spacer ||
33074 l_ecv_display_name ||
33075 l_label_end_tag;
33076 --
33077 ben_pd_copy_to_ben_three.g_not_copied_tbl_count := ben_pd_copy_to_ben_three.g_not_copied_tbl_count + 1;
33078 --
33079 l_prev_parent_pk_id := l_not_copied_egl_tbl(i).eligy_prfl_id;
33080 --
33081 end if;
33082 --
33083 IF nvl(l_prev_ecv_id, -1) <> l_not_copied_egl_tbl(i).eligy_crit_values_id
33084 THEN
33085 --
33086 ben_pd_copy_to_ben_three.g_not_copied_tbl(ben_pd_copy_to_ben_three.g_not_copied_tbl_count).text
33087 := l_para_spacer ||
33088 l_para_spacer || l_para_spacer ||
33089 l_not_copied_egl_tbl(i).text;
33090 --
33091 ben_pd_copy_to_ben_three.g_not_copied_tbl_count := ben_pd_copy_to_ben_three.g_not_copied_tbl_count + 1;
33092 --
33093 l_prev_ecv_id := l_not_copied_egl_tbl(i).eligy_crit_values_id;
33094 --
33095 END IF;
33096 --
33097 END LOOP;
33098 --
33099 end if;
33100 --
33101 ----------------------< DISPLAY END >---------------------------
33102 --
33103 EXCEPTION
33104 WHEN OTHERS
33105 THEN
33106 --
33107 ben_pd_copy_to_ben_one.raise_error_message ('ecv', r_ecv.information5);
33108 --
33109 END create_ecv_rows;
33110 --
33111 --
33112 procedure create_all_elig_prf_ben_rows
33113 (
33114 p_validate in number default 0
33115 ,p_copy_entity_txn_id in number
33116 ,p_effective_date in date
33117 ,p_prefix_suffix_text in varchar2 default null
33118 ,p_reuse_object_flag in varchar2 default null
33119 ,p_target_business_group_id in varchar2 default null
33120 ,p_prefix_suffix_cd in varchar2 default null
33121 ) is
33122 --
33123 CURSOR c_source_business_group
33124 IS
33125 SELECT context_business_group_id
33126 FROM ben_copy_entity_txns_vw
33127 WHERE copy_entity_txn_id = p_copy_entity_txn_id;
33128 --
33129 l_source_business_group_id number(15);
33130 --
33131 begin
33132 --
33133 -- hr_utility.trace_on(null,'pdw');
33134 open c_source_business_group;
33135 --
33136 fetch c_source_business_group into l_source_business_group_id;
33137 --
33138 close c_source_business_group;
33139 --
33140 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EAN') then
33141 create_EAN_rows(
33142 p_validate => p_validate
33143 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33144 ,p_effective_date => p_effective_date
33145 ,p_prefix_suffix_text => p_prefix_suffix_text
33146 ,p_reuse_object_flag => p_reuse_object_flag
33147 ,p_target_business_group_id => p_target_business_group_id
33148 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33149 end if;
33150 --
33151 --
33152 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CGP') then
33153 create_CGP_rows(
33154 p_validate => p_validate
33155 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33156 ,p_effective_date => p_effective_date
33157 ,p_prefix_suffix_text => p_prefix_suffix_text
33158 ,p_reuse_object_flag => p_reuse_object_flag
33159 ,p_target_business_group_id => p_target_business_group_id
33160 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33161 end if;
33162 --
33163 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EAP') then
33164 create_EAP_rows(
33165 p_validate => p_validate
33166 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33167 ,p_effective_date => p_effective_date
33168 ,p_prefix_suffix_text => p_prefix_suffix_text
33169 ,p_reuse_object_flag => p_reuse_object_flag
33170 ,p_target_business_group_id => p_target_business_group_id
33171 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33172 end if;
33173 --
33174 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EBN') then
33175 create_EBN_rows(
33176 p_validate => p_validate
33177 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33178 ,p_effective_date => p_effective_date
33179 ,p_prefix_suffix_text => p_prefix_suffix_text
33180 ,p_reuse_object_flag => p_reuse_object_flag
33181 ,p_target_business_group_id => p_target_business_group_id
33182 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33183 end if;
33184 --
33185 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EBU') then
33186 create_EBU_rows(
33187 p_validate => p_validate
33188 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33189 ,p_effective_date => p_effective_date
33190 ,p_prefix_suffix_text => p_prefix_suffix_text
33191 ,p_reuse_object_flag => p_reuse_object_flag
33192 ,p_target_business_group_id => p_target_business_group_id
33193 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33194 end if;
33195 --
33196 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ECL') then
33197 create_ECL_rows(
33198 p_validate => p_validate
33199 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33200 ,p_effective_date => p_effective_date
33201 ,p_prefix_suffix_text => p_prefix_suffix_text
33202 ,p_reuse_object_flag => p_reuse_object_flag
33203 ,p_target_business_group_id => p_target_business_group_id
33204 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33205 end if;
33206 --
33207 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ECP') then
33208 create_ECP_rows(
33209 p_validate => p_validate
33210 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33211 ,p_effective_date => p_effective_date
33212 ,p_prefix_suffix_text => p_prefix_suffix_text
33213 ,p_reuse_object_flag => p_reuse_object_flag
33214 ,p_target_business_group_id => p_target_business_group_id
33215 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33216 end if;
33217 --
33218
33219 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ECY') then
33220 create_ECY_rows(
33221 p_validate => p_validate
33222 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33223 ,p_effective_date => p_effective_date
33224 ,p_prefix_suffix_text => p_prefix_suffix_text
33225 ,p_reuse_object_flag => p_reuse_object_flag
33226 ,p_target_business_group_id => p_target_business_group_id
33227 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33228 end if;
33229 --
33230 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ERL') then
33231 create_ERL_rows(
33232 p_validate => p_validate
33233 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33234 ,p_effective_date => p_effective_date
33235 ,p_prefix_suffix_text => p_prefix_suffix_text
33236 ,p_reuse_object_flag => p_reuse_object_flag
33237 ,p_target_business_group_id => p_target_business_group_id
33238 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33239 end if;
33240 --
33241 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EHW') then
33242 create_EHW_rows(
33243 p_validate => p_validate
33244 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33245 ,p_effective_date => p_effective_date
33246 ,p_prefix_suffix_text => p_prefix_suffix_text
33247 ,p_reuse_object_flag => p_reuse_object_flag
33248 ,p_target_business_group_id => p_target_business_group_id
33249 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33250 end if;
33251 --
33252 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EJP') then
33253 create_EJP_rows(
33254 p_validate => p_validate
33255 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33256 ,p_effective_date => p_effective_date
33257 ,p_prefix_suffix_text => p_prefix_suffix_text
33258 ,p_reuse_object_flag => p_reuse_object_flag
33259 ,p_target_business_group_id => p_target_business_group_id
33260 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33261 end if;
33262 --
33263 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ELU') then
33264 create_ELU_rows(
33265 p_validate => p_validate
33266 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33267 ,p_effective_date => p_effective_date
33268 ,p_prefix_suffix_text => p_prefix_suffix_text
33269 ,p_reuse_object_flag => p_reuse_object_flag
33270 ,p_target_business_group_id => p_target_business_group_id
33271 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33272 end if;
33273 --
33274 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ELN') then
33275 create_ELN_rows(
33276 p_validate => p_validate
33277 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33278 ,p_effective_date => p_effective_date
33279 ,p_prefix_suffix_text => p_prefix_suffix_text
33280 ,p_reuse_object_flag => p_reuse_object_flag
33281 ,p_target_business_group_id => p_target_business_group_id
33282 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33283 end if;
33284 --
33285 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ELR') then
33286 create_ELR_rows(
33287 p_validate => p_validate
33288 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33289 ,p_effective_date => p_effective_date
33290 ,p_prefix_suffix_text => p_prefix_suffix_text
33291 ,p_reuse_object_flag => p_reuse_object_flag
33292 ,p_target_business_group_id => p_target_business_group_id
33293 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33294 end if;
33295 --
33296 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ELS') then
33297 create_ELS_rows(
33298 p_validate => p_validate
33299 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33300 ,p_effective_date => p_effective_date
33301 ,p_prefix_suffix_text => p_prefix_suffix_text
33302 ,p_reuse_object_flag => p_reuse_object_flag
33303 ,p_target_business_group_id => p_target_business_group_id
33304 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33305 end if;
33306 --
33307 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ELV') then
33308 create_ELV_rows(
33309 p_validate => p_validate
33310 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33311 ,p_effective_date => p_effective_date
33312 ,p_prefix_suffix_text => p_prefix_suffix_text
33313 ,p_reuse_object_flag => p_reuse_object_flag
33314 ,p_target_business_group_id => p_target_business_group_id
33315 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33316 end if;
33317 --
33318 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EMP') then
33319 create_EMP_rows(
33320 p_validate => p_validate
33321 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33322 ,p_effective_date => p_effective_date
33323 ,p_prefix_suffix_text => p_prefix_suffix_text
33324 ,p_reuse_object_flag => p_reuse_object_flag
33325 ,p_target_business_group_id => p_target_business_group_id
33326 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33327 end if;
33328 --
33329 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ENO') then
33330 create_ENO_rows(
33331 p_validate => p_validate
33332 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33333 ,p_effective_date => p_effective_date
33334 ,p_prefix_suffix_text => p_prefix_suffix_text
33335 ,p_reuse_object_flag => p_reuse_object_flag
33336 ,p_target_business_group_id => p_target_business_group_id
33337 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33338 end if;
33339 --
33340 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EOM') then
33341 create_EOM_rows(
33342 p_validate => p_validate
33343 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33344 ,p_effective_date => p_effective_date
33345 ,p_prefix_suffix_text => p_prefix_suffix_text
33346 ,p_reuse_object_flag => p_reuse_object_flag
33347 ,p_target_business_group_id => p_target_business_group_id
33348 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33349 end if;
33350 --
33351 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EOU') then
33352 create_EOU_rows(
33353 p_validate => p_validate
33354 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33355 ,p_effective_date => p_effective_date
33356 ,p_prefix_suffix_text => p_prefix_suffix_text
33357 ,p_reuse_object_flag => p_reuse_object_flag
33358 ,p_target_business_group_id => p_target_business_group_id
33359 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33360 end if;
33361 --
33362 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EPF') then
33363 create_EPF_rows(
33364 p_validate => p_validate
33365 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33366 ,p_effective_date => p_effective_date
33367 ,p_prefix_suffix_text => p_prefix_suffix_text
33368 ,p_reuse_object_flag => p_reuse_object_flag
33369 ,p_target_business_group_id => p_target_business_group_id
33370 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33371 end if;
33372
33373 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EPT') then
33374 create_EPT_rows(
33375 p_validate => p_validate
33376 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33377 ,p_effective_date => p_effective_date
33378 ,p_prefix_suffix_text => p_prefix_suffix_text
33379 ,p_reuse_object_flag => p_reuse_object_flag
33380 ,p_target_business_group_id => p_target_business_group_id
33381 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33382 end if;
33383 --
33384 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EPB') then
33385 create_EPB_rows(
33386 p_validate => p_validate
33387 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33388 ,p_effective_date => p_effective_date
33389 ,p_prefix_suffix_text => p_prefix_suffix_text
33390 ,p_reuse_object_flag => p_reuse_object_flag
33391 ,p_target_business_group_id => p_target_business_group_id
33392 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33393 end if;
33394 --
33395 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EPN') then
33396 create_EPN_rows(
33397 p_validate => p_validate
33398 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33399 ,p_effective_date => p_effective_date
33400 ,p_prefix_suffix_text => p_prefix_suffix_text
33401 ,p_reuse_object_flag => p_reuse_object_flag
33402 ,p_target_business_group_id => p_target_business_group_id
33403 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33404 end if;
33405 --
33406 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EPS') then
33407 create_EPS_rows(
33408 p_validate => p_validate
33409 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33410 ,p_effective_date => p_effective_date
33411 ,p_prefix_suffix_text => p_prefix_suffix_text
33412 ,p_reuse_object_flag => p_reuse_object_flag
33413 ,p_target_business_group_id => p_target_business_group_id
33414 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33415 end if;
33416 --
33417 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EPY') then
33418 create_EPY_rows(
33419 p_validate => p_validate
33420 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33421 ,p_effective_date => p_effective_date
33422 ,p_prefix_suffix_text => p_prefix_suffix_text
33423 ,p_reuse_object_flag => p_reuse_object_flag
33424 ,p_target_business_group_id => p_target_business_group_id
33425 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33426 end if;
33427 --
33428 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EPZ') then
33429 create_EPZ_rows(
33430 p_validate => p_validate
33431 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33432 ,p_effective_date => p_effective_date
33433 ,p_prefix_suffix_text => p_prefix_suffix_text
33434 ,p_reuse_object_flag => p_reuse_object_flag
33435 ,p_target_business_group_id => p_target_business_group_id
33436 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33437 end if;
33438 --
33439 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EQT') then
33440 create_EQT_rows(
33441 p_validate => p_validate
33442 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33443 ,p_effective_date => p_effective_date
33444 ,p_prefix_suffix_text => p_prefix_suffix_text
33445 ,p_reuse_object_flag => p_reuse_object_flag
33446 ,p_target_business_group_id => p_target_business_group_id
33447 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33448 end if;
33449 --
33450
33451
33452 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ESA') then
33453 create_ESA_rows(
33454 p_validate => p_validate
33455 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33456 ,p_effective_date => p_effective_date
33457 ,p_prefix_suffix_text => p_prefix_suffix_text
33458 ,p_reuse_object_flag => p_reuse_object_flag
33459 ,p_target_business_group_id => p_target_business_group_id
33460 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33461
33462 end if;
33463 --
33464 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ESH') then
33465 create_ESH_rows(
33466 p_validate => p_validate
33467 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33468 ,p_effective_date => p_effective_date
33469 ,p_prefix_suffix_text => p_prefix_suffix_text
33470 ,p_reuse_object_flag => p_reuse_object_flag
33471 ,p_target_business_group_id => p_target_business_group_id
33472 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33473 end if;
33474 --
33475 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ESP') then
33476 create_ESP_rows(
33477 p_validate => p_validate
33478 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33479 ,p_effective_date => p_effective_date
33480 ,p_prefix_suffix_text => p_prefix_suffix_text
33481 ,p_reuse_object_flag => p_reuse_object_flag
33482 ,p_target_business_group_id => p_target_business_group_id
33483 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33484 end if;
33485 --
33486 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EST') then
33487 create_EST_rows(
33488 p_validate => p_validate
33489 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33490 ,p_effective_date => p_effective_date
33491 ,p_prefix_suffix_text => p_prefix_suffix_text
33492 ,p_reuse_object_flag => p_reuse_object_flag
33493 ,p_target_business_group_id => p_target_business_group_id
33494 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33495 end if;
33496 --
33497 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EWL') then
33498 create_EWL_rows(
33499 p_validate => p_validate
33500 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33501 ,p_effective_date => p_effective_date
33502 ,p_prefix_suffix_text => p_prefix_suffix_text
33503 ,p_reuse_object_flag => p_reuse_object_flag
33504 ,p_target_business_group_id => p_target_business_group_id
33505 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33506 end if;
33507 --
33508 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ECT') then
33509 create_ECT_rows(
33510 p_validate => p_validate
33511 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33512 ,p_effective_date => p_effective_date
33513 ,p_prefix_suffix_text => p_prefix_suffix_text
33514 ,p_reuse_object_flag => p_reuse_object_flag
33515 ,p_target_business_group_id => p_target_business_group_id
33516 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33517 end if;
33518 --
33519 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EDD') then
33520 create_EDD_rows(
33521 p_validate => p_validate
33522 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33523 ,p_effective_date => p_effective_date
33524 ,p_prefix_suffix_text => p_prefix_suffix_text
33525 ,p_reuse_object_flag => p_reuse_object_flag
33526 ,p_target_business_group_id => p_target_business_group_id
33527 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33528 end if;
33529 --
33530 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EDR') then
33531 create_EDR_rows(
33532 p_validate => p_validate
33533 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33534 ,p_effective_date => p_effective_date
33535 ,p_prefix_suffix_text => p_prefix_suffix_text
33536 ,p_reuse_object_flag => p_reuse_object_flag
33537 ,p_target_business_group_id => p_target_business_group_id
33538 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33539 end if;
33540 --
33541 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EES') then
33542 create_EES_rows(
33543 p_validate => p_validate
33544 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33545 ,p_effective_date => p_effective_date
33546 ,p_prefix_suffix_text => p_prefix_suffix_text
33547 ,p_reuse_object_flag => p_reuse_object_flag
33548 ,p_target_business_group_id => p_target_business_group_id
33549 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33550 end if;
33551 --
33552 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EFP') then
33553 create_EFP_rows(
33554 p_validate => p_validate
33555 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33556 ,p_effective_date => p_effective_date
33557 ,p_prefix_suffix_text => p_prefix_suffix_text
33558 ,p_reuse_object_flag => p_reuse_object_flag
33559 ,p_target_business_group_id => p_target_business_group_id
33560 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33561 end if;
33562 --
33563 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EGR') then
33564 create_EGR_rows(
33565 p_validate => p_validate
33566 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33567 ,p_effective_date => p_effective_date
33568 ,p_prefix_suffix_text => p_prefix_suffix_text
33569 ,p_reuse_object_flag => p_reuse_object_flag
33570 ,p_target_business_group_id => p_target_business_group_id
33571 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33572 end if;
33573 --
33574 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EHS') then
33575 create_EHS_rows(
33576 p_validate => p_validate
33577 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33578 ,p_effective_date => p_effective_date
33579 ,p_prefix_suffix_text => p_prefix_suffix_text
33580 ,p_reuse_object_flag => p_reuse_object_flag
33581 ,p_target_business_group_id => p_target_business_group_id
33582 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33583 end if;
33584 --
33585 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ERG') then
33586 create_ERG_rows(
33587 p_validate => p_validate
33588 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33589 ,p_effective_date => p_effective_date
33590 ,p_prefix_suffix_text => p_prefix_suffix_text
33591 ,p_reuse_object_flag => p_reuse_object_flag
33592 ,p_target_business_group_id => p_target_business_group_id
33593 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33594 end if;
33595 --
33596 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EQG') then
33597 create_EQG_rows(
33598 p_validate => p_validate
33599 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33600 ,p_effective_date => p_effective_date
33601 ,p_prefix_suffix_text => p_prefix_suffix_text
33602 ,p_reuse_object_flag => p_reuse_object_flag
33603 ,p_target_business_group_id => p_target_business_group_id
33604 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33605 end if;
33606 --
33607 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EGN') then
33608 create_EGN_rows(
33609 p_validate => p_validate
33610 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33611 ,p_effective_date => p_effective_date
33612 ,p_prefix_suffix_text => p_prefix_suffix_text
33613 ,p_reuse_object_flag => p_reuse_object_flag
33614 ,p_target_business_group_id => p_target_business_group_id
33615 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33616 end if;
33617 --
33618 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ETU') then
33619 create_ETU_rows(
33620 p_validate => p_validate
33621 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33622 ,p_effective_date => p_effective_date
33623 ,p_prefix_suffix_text => p_prefix_suffix_text
33624 ,p_reuse_object_flag => p_reuse_object_flag
33625 ,p_target_business_group_id => p_target_business_group_id
33626 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33627
33628 end if;
33629 --
33630 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EDB') then
33631 create_EDB_rows(
33632 p_validate => p_validate
33633 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33634 ,p_effective_date => p_effective_date
33635 ,p_prefix_suffix_text => p_prefix_suffix_text
33636 ,p_reuse_object_flag => p_reuse_object_flag
33637 ,p_target_business_group_id => p_target_business_group_id
33638 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33639
33640 end if;
33641 --
33642 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ETP') then
33643 create_ETP_rows(
33644 p_validate => p_validate
33645 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33646 ,p_effective_date => p_effective_date
33647 ,p_prefix_suffix_text => p_prefix_suffix_text
33648 ,p_reuse_object_flag => p_reuse_object_flag
33649 ,p_target_business_group_id => p_target_business_group_id
33650 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33651
33652 end if;
33653 --
33654 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ETC') then
33655 create_ETC_rows(
33656 p_validate => p_validate
33657 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33658 ,p_effective_date => p_effective_date
33659 ,p_prefix_suffix_text => p_prefix_suffix_text
33660 ,p_reuse_object_flag => p_reuse_object_flag
33661 ,p_target_business_group_id => p_target_business_group_id
33662 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33663 end if;
33664 --
33665 -- Bug 4169120 : Rate By Criteria
33666 --
33667 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ECV')
33668 then
33669 --
33670 create_ECV_rows(
33671 p_validate => p_validate
33672 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33673 ,p_effective_date => p_effective_date
33674 ,p_prefix_suffix_text => p_prefix_suffix_text
33675 ,p_reuse_object_flag => p_reuse_object_flag
33676 ,p_target_business_group_id => p_target_business_group_id
33677 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33678 --
33679 end if;
33680 --
33681 --
33682 -- Foll. Criteria to be copied only in Create Plan Wizard flow
33683 --
33684 if BEN_PD_COPY_TO_BEN_ONE.g_transaction_category = 'BEN_PDCRWZ' then
33685
33686 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ECQ') then
33687 create_ECQ_rows(
33688 p_validate => p_validate
33689 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33690 ,p_effective_date => p_effective_date
33691 ,p_prefix_suffix_text => p_prefix_suffix_text
33692 ,p_reuse_object_flag => p_reuse_object_flag
33693 ,p_target_business_group_id => p_target_business_group_id
33694 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33695 end if;
33696 --
33697 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EDG') then
33698 create_EDG_rows(
33699 p_validate => p_validate
33700 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33701 ,p_effective_date => p_effective_date
33702 ,p_prefix_suffix_text => p_prefix_suffix_text
33703 ,p_reuse_object_flag => p_reuse_object_flag
33704 ,p_target_business_group_id => p_target_business_group_id
33705 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33706 end if;
33707 --
33708 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EDI') then
33709 create_EDI_rows(
33710 p_validate => p_validate
33711 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33712 ,p_effective_date => p_effective_date
33713 ,p_prefix_suffix_text => p_prefix_suffix_text
33714 ,p_reuse_object_flag => p_reuse_object_flag
33715 ,p_target_business_group_id => p_target_business_group_id
33716 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33717 end if;
33718 --
33719 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EDP') then
33720 create_EDP_rows(
33721 p_validate => p_validate
33722 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33723 ,p_effective_date => p_effective_date
33724 ,p_prefix_suffix_text => p_prefix_suffix_text
33725 ,p_reuse_object_flag => p_reuse_object_flag
33726 ,p_target_business_group_id => p_target_business_group_id
33727 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33728 end if;
33729 --
33730 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EDT') then
33731 create_EDT_rows(
33732 p_validate => p_validate
33733 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33734 ,p_effective_date => p_effective_date
33735 ,p_prefix_suffix_text => p_prefix_suffix_text
33736 ,p_reuse_object_flag => p_reuse_object_flag
33737 ,p_target_business_group_id => p_target_business_group_id
33738 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33739 end if;
33740 --
33741 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EOY') then
33742 create_EOY_rows(
33743 p_validate => p_validate
33744 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33745 ,p_effective_date => p_effective_date
33746 ,p_prefix_suffix_text => p_prefix_suffix_text
33747 ,p_reuse_object_flag => p_reuse_object_flag
33748 ,p_target_business_group_id => p_target_business_group_id
33749 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33750 end if;
33751 --
33752 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EPG') then
33753 create_EPG_rows(
33754 p_validate => p_validate
33755 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33756 ,p_effective_date => p_effective_date
33757 ,p_prefix_suffix_text => p_prefix_suffix_text
33758 ,p_reuse_object_flag => p_reuse_object_flag
33759 ,p_target_business_group_id => p_target_business_group_id
33760 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33761 end if;
33762 --
33763 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EPP') then
33764 create_EPP_rows(
33765 p_validate => p_validate
33766 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33767 ,p_effective_date => p_effective_date
33768 ,p_prefix_suffix_text => p_prefix_suffix_text
33769 ,p_reuse_object_flag => p_reuse_object_flag
33770 ,p_target_business_group_id => p_target_business_group_id
33771 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33772 end if;
33773 --
33774 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ETD') then
33775 create_ETD_rows(
33776 p_validate => p_validate
33777 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33778 ,p_effective_date => p_effective_date
33779 ,p_prefix_suffix_text => p_prefix_suffix_text
33780 ,p_reuse_object_flag => p_reuse_object_flag
33781 ,p_target_business_group_id => p_target_business_group_id
33782 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33783 end if;
33784 --
33785 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EEI') then
33786 create_EEI_rows(
33787 p_validate => p_validate
33788 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33789 ,p_effective_date => p_effective_date
33790 ,p_prefix_suffix_text => p_prefix_suffix_text
33791 ,p_reuse_object_flag => p_reuse_object_flag
33792 ,p_target_business_group_id => p_target_business_group_id
33793 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33794 end if;
33795 --
33796 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EEG') then
33797 create_EEG_rows(
33798 p_validate => p_validate
33799 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33800 ,p_effective_date => p_effective_date
33801 ,p_prefix_suffix_text => p_prefix_suffix_text
33802 ,p_reuse_object_flag => p_reuse_object_flag
33803 ,p_target_business_group_id => p_target_business_group_id
33804 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33805 end if;
33806 --
33807 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EAI') then
33808 create_EAI_rows(
33809 p_validate => p_validate
33810 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33811 ,p_effective_date => p_effective_date
33812 ,p_prefix_suffix_text => p_prefix_suffix_text
33813 ,p_reuse_object_flag => p_reuse_object_flag
33814 ,p_target_business_group_id => p_target_business_group_id
33815 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33816 end if;
33817 --
33818 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EEP') then
33819 create_EEP_rows(
33820 p_validate => p_validate
33821 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33822 ,p_effective_date => p_effective_date
33823 ,p_prefix_suffix_text => p_prefix_suffix_text
33824 ,p_reuse_object_flag => p_reuse_object_flag
33825 ,p_target_business_group_id => p_target_business_group_id
33826 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33827 end if;
33828 --
33829 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EET') then
33830 create_EET_rows(
33831 p_validate => p_validate
33832 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33833 ,p_effective_date => p_effective_date
33834 ,p_prefix_suffix_text => p_prefix_suffix_text
33835 ,p_reuse_object_flag => p_reuse_object_flag
33836 ,p_target_business_group_id => p_target_business_group_id
33837 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33838 end if;
33839 --
33840 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EHC') then
33841 create_EHC_rows(
33842 p_validate => p_validate
33843 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33844 ,p_effective_date => p_effective_date
33845 ,p_prefix_suffix_text => p_prefix_suffix_text
33846 ,p_reuse_object_flag => p_reuse_object_flag
33847 ,p_target_business_group_id => p_target_business_group_id
33848 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33849
33850 end if;
33851 --
33852 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EOP') then
33853 create_EOP_rows(
33854 p_validate => p_validate
33855 ,p_copy_entity_txn_id => p_copy_entity_txn_id
33856 ,p_effective_date => p_effective_date
33857 ,p_prefix_suffix_text => p_prefix_suffix_text
33858 ,p_reuse_object_flag => p_reuse_object_flag
33859 ,p_target_business_group_id => p_target_business_group_id
33860 ,p_prefix_suffix_cd => p_prefix_suffix_cd );
33861 end if;
33862 --
33863 end if;
33864 end;
33865
33866
33867 END BEN_PD_COPY_TO_BEN_FOUR;