[Home] [Help]
PACKAGE BODY: APPS.BEN_PD_COPY_TO_BEN_TWO
Source
1 Package BODY BEN_PD_COPY_TO_BEN_TWO as
2 /* $Header: bepdccp2.pkb 120.11.12000000.2 2007/08/23 21:29:01 sshetty 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 -- ----------------------------------------------------------------------------
121 -- |------------------------< create_bnb_rows >------------------------|
122 -- ----------------------------------------------------------------------------
123 -- {Start Of Comments}
124 --
125 -- {End Of Comments}
126 --
127 function get_fk(p_col_name varchar2,
128 p_old_val number,
129 p_dml_operation varchar2 default null) return number is
130 l_counter number;
131 l_ret_id number := null;
132 begin
133 --
134 /*
135 if p_dml_operation = 'UPDATE' then
136 --
137 l_ret_id := p_old_val ;
138 --
139 else
140 */
141 --
142 l_counter := nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl.LAST, 0);
143 if l_counter > 0 and p_old_val is not null then
144 for i in 1..l_counter loop
145 if BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(i).pk_id_column = p_col_name and
146 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(i).old_value = p_old_val
147 then
148 l_ret_id := BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(i).new_value;
149 exit;
150 end if;
151 end loop;
152 end if;
153 --
154 /*
155 end if;
156 */
157 return l_ret_id;
158 --
159 end;
160 --
161 -- Private procedure to update the cer with target details
162 --
163 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
164 begin
165 hr_utility.set_location('Inside update_cer_with_target ',233);
166 update ben_copy_entity_results
167 set information9 = c_pk_rec.copy_reuse_type||'-'||c_pk_rec.new_value
168 where copy_entity_txn_id = p_copy_entity_txn_id
169 and table_route_id = c_pk_rec.table_route_id
170 and information1 = c_pk_rec.old_value ;
171 end update_cer_with_target ;
172 --
173 ----------------------------------------------------------------------------
174 -------------------< set_mapping >------------------------------------------
175 ----------------------------------------------------------------------------
176 -- This procedure determines whether the mapping is already done or not.
177 -- BEN_PDSMBG -- Same Business Group
178 procedure set_mapping(p_copy_entity_txn_id number) is
179 --
180 cursor c_cet is
181 select null
182 from ben_copy_entity_txns_vw
183 where copy_entity_txn_id = p_copy_entity_txn_id
184 and target_typ_cd in ('BEN_PDSMBG');
185 --
186 l_dummy varchar2(30);
187 begin
188 null ;
189 open c_cet ;
190 fetch c_cet into l_dummy ;
191 if c_cet%found then
192 BEN_PD_COPY_TO_BEN_ONE.g_mapping_done := false ;
193 else
194 BEN_PD_COPY_TO_BEN_ONE.g_mapping_done := true ;
195 end if;
196 close c_cet ;
197 end set_mapping ;
198
199 --
200 ---------------------------------------------------------------
201 ----------------------< create_PRB_rows >-----------------------
202 ---------------------------------------------------------------
203 --
204 procedure create_PRB_rows
205 (
206 p_validate in number default 0
207 ,p_copy_entity_txn_id in number
208 ,p_effective_date in date
209 ,p_prefix_suffix_text in varchar2 default null
210 ,p_reuse_object_flag in varchar2 default null
211 ,p_target_business_group_id in varchar2 default null
212 ,p_prefix_suffix_cd in varchar2 default null
213 ) is
214 --
215 l_PL_ID number;
216 l_RPTG_GRP_ID number;
217 l_regy_pl_name BEN_PL_REGY_BOD_F.regy_pl_name%type;
218 --
219 cursor c_unique_PRB(l_table_alias varchar2) is
220 select distinct cpe.information1,
221 cpe.information2,
222 cpe.information3,
223 cpe.table_route_id,
224 cpe.dml_operation,
225 cpe.datetrack_mode
226 from ben_copy_entity_results cpe,
227 pqh_table_route tr
228 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
229 and cpe.table_route_id = tr.table_route_id
230 -- and tr.where_clause = l_BEN_PL_REGY_BOD_F
231 and tr.table_alias = l_table_alias
232 and cpe.number_of_copies = 1 --ADDITION
233 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
234 order by information1, information2; --added for bug: 5151945
235 --
236 --
237 cursor c_PRB_min_max_dates(c_table_route_id number,
238 c_information1 number) is
239 select
240 min(cpe.information2) min_esd,
241 max(cpe.information3) min_eed
242 from ben_copy_entity_results cpe
243 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
244 and cpe.table_route_id = c_table_route_id
245 and cpe.information1 = c_information1 ;
246 --
247 cursor c_PRB(c_table_route_id number,
248 c_information1 number,
249 c_information2 date,
250 c_information3 date ) is
251 select
252 cpe.*
253 from ben_copy_entity_results cpe
254 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
255 and cpe.table_route_id = c_table_route_id
256 and cpe.information1 = c_information1
257 and cpe.information2 = c_information2
258 and cpe.information3 = c_information3
259 and rownum = 1 ;
260 -- Date Track target record
261 cursor c_find_PRB_in_target(
262 c_effective_start_date date,
263 c_effective_end_date date,
264 c_business_group_id number,
265 c_new_pk_id number) is
266 select
267 PRB.pl_regy_bod_id new_value
268 from BEN_PL_REGY_BOD_F PRB
269 where
270 nvl(PRB.PL_ID,-999) = nvl(l_PL_ID,-999) and
271 nvl(PRB.RPTG_GRP_ID,-999) = nvl(l_RPTG_GRP_ID,-999) and
272 PRB.regy_pl_name = l_regy_pl_name and
273 PRB.business_group_id = c_business_group_id
274 and PRB.pl_regy_bod_id <> c_new_pk_id
275 --TEMPIK
276 and c_effective_start_date between effective_start_date
277 and effective_end_date ;
278 --END TEMPIK
279 /*TEMPIK
280 and exists ( select null
281 from BEN_PL_REGY_BOD_F PRB1
282 where
283 nvl(PRB1.PL_ID,-999) = nvl(l_PL_ID,-999) and
284 nvl(PRB1.RPTG_GRP_ID,-999) = nvl(l_RPTG_GRP_ID,-999) and
285 PRB1.regy_pl_name = l_regy_pl_name and
286 PRB1.business_group_id = c_business_group_id
287 and PRB1.effective_start_date <= c_effective_start_date )
288 and exists ( select null
289 from BEN_PL_REGY_BOD_F PRB2
290 where
291 nvl(PRB2.PL_ID,-999) = nvl(l_PL_ID,-999) and
292 nvl(PRB2.RPTG_GRP_ID,-999) = nvl(l_RPTG_GRP_ID,-999) and
293 PRB2.regy_pl_name = l_regy_pl_name and
294 PRB2.business_group_id = c_business_group_id
295 and PRB2.effective_end_date >= c_effective_end_date )
296 ;
297 TEMPIK */
298 --TEMPIK
299 l_dt_rec_found boolean ;
300 --END TEMPIK
301 --
302 --UPD START
303 --
304 l_update boolean := false ;
305 l_datetrack_mode varchar2(80) := hr_api.g_update;
306 l_process_date date;
307 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
308 --
309 --UPD END
310 l_current_pk_id number := null ;
311 l_prev_pk_id number := null ;
312 l_first_rec boolean := true ;
313 r_PRB c_PRB%rowtype;
314 l_pl_regy_bod_id number ;
315 l_object_version_number number ;
316 l_effective_start_date date ;
317 l_effective_end_date date ;
318 l_prefix pqh_copy_entity_attribs.information1%type := null;
319 l_suffix pqh_copy_entity_attribs.information1%type := null;
320 l_new_value number(15);
321 l_object_found_in_target boolean := false ;
322 l_min_esd date;
323 l_max_eed date;
324 l_effective_date date;
325 --
326 begin
327 -- Initialization
328 l_object_found_in_target := false ;
329 -- End Initialization
330 -- Derive the prefix - sufix
331 if p_prefix_suffix_cd = 'PREFIX' then
332 l_prefix := p_prefix_suffix_text ;
333 elsif p_prefix_suffix_cd = 'SUFFIX' then
334 l_suffix := p_prefix_suffix_text ;
335 else
336 l_prefix := null ;
337 l_suffix := null ;
338 end if ;
339 -- End Prefix Sufix derivation
340 for r_PRB_unique in c_unique_PRB('PRB') loop
341
342 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
343 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
344 r_PRB_unique.information3 >=
345 ben_pd_copy_to_ben_one.g_copy_effective_date)
346 ) then
347 --
348 hr_utility.set_location(' r_PRB_unique.table_route_id '||r_PRB_unique.table_route_id,10);
349 hr_utility.set_location(' r_PRB_unique.information1 '||r_PRB_unique.information1,10);
350 hr_utility.set_location( 'r_PRB_unique.information2 '||r_PRB_unique.information2,10);
351 hr_utility.set_location( 'r_PRB_unique.information3 '||r_PRB_unique.information3,10);
352 -- If reuse objects flag is 'Y' then check for the object in the target business group
353 -- if found insert the record into PLSql table and exit the loop else try create the
354 -- object in the target business group
355 --
356
357 open c_PRB(r_PRB_unique.table_route_id,
358 r_PRB_unique.information1,
359 r_PRB_unique.information2,
360 r_PRB_unique.information3 ) ;
361 --
362 fetch c_PRB into r_PRB ;
363 --
364 close c_PRB ;
365 --
366 l_dml_operation:= r_PRB_unique.dml_operation ;
367 l_PL_ID := get_fk('PL_ID', r_PRB.INFORMATION261,l_dml_operation);
368 l_RPTG_GRP_ID := get_fk('RPTG_GRP_ID', r_PRB.INFORMATION242,l_dml_operation);
369 --
370
371 l_object_found_in_target := false ;
372 --UPD START
373 l_update := false;
374 l_process_date := p_effective_date;
375 --
376 if l_dml_operation = 'UPDATE' then
377 --
378 l_object_found_in_target := TRUE;
379 --
380 if l_process_date between r_PRB_unique.information2 and r_PRB_unique.information3 then
381 l_update := true;
382 if r_PRB_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
383 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_REGY_BOD_ID'
384 then
385 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_REGY_BOD_ID' ;
386 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PRB_unique.information1 ;
387 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PRB_unique.information1 ;
388 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
389 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PRB_unique.table_route_id;
390 --
391 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
392 --
393 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
394 --
395 --DOUBT log_data('PRB',l_new_value,l_prefix || r_PRB_unique.name|| l_suffix,'REUSED');
396 --
397 end if ;
398 hr_utility.set_location( 'found record for update',10);
399 --
400 else
401 --
402 l_update := false;
403 --
404 end if;
405 else
406 --
407 --UPD END
408 l_min_esd := null ;
409 l_max_eed := null ;
410 open c_PRB_min_max_dates(r_PRB_unique.table_route_id, r_PRB_unique.information1 ) ;
411 fetch c_PRB_min_max_dates into l_min_esd,l_max_eed ;
412 --
413
414 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
415 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
416 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
417 end if;
418 l_min_esd := greatest(l_min_esd,r_PRB_unique.information2);
419
420 --
421 l_regy_pl_name := r_PRB.information185 ;
422 --
423 if l_RPTG_GRP_ID is null then
424 close c_PRB_min_max_dates;
425 else
426 if p_reuse_object_flag = 'Y' then
427 if c_PRB_min_max_dates%found then
428 -- cursor to find the object
429 open c_find_PRB_in_target( l_min_esd,l_max_eed,
430 p_target_business_group_id, nvl(l_pl_regy_bod_id, -999) ) ;
431 fetch c_find_PRB_in_target into l_new_value ;
432 if c_find_PRB_in_target%found then
433 --
434 --TEMPIK
435 l_dt_rec_found := dt_api.check_min_max_dates
436 (p_base_table_name => 'BEN_PL_REGY_BOD_F',
437 p_base_key_column => 'PL_REGY_BOD_ID',
438 p_base_key_value => l_new_value,
439 p_from_date => l_min_esd,
440 p_to_date => l_max_eed );
441 if l_dt_rec_found THEN
442 --END TEMPIK
443 if r_PRB_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
444 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_REGY_BOD_ID' then
445 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_REGY_BOD_ID' ;
446 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PRB_unique.information1 ;
447 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
448 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
449 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PRB_unique.table_route_id;
450 --
451 -- 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) ;
452 --
453 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
454 end if ;
455 --
456 l_object_found_in_target := true ;
457 --TEMPIK
458 end if; -- l_dt_rec_found
459 --END TEMPIK
460 end if;
461 close c_find_PRB_in_target ;
462 --
463 end if;
464 end if ;
465 --
466 close c_PRB_min_max_dates ;
467 end if; --if p_dml_operation
468 --
469 if not l_object_found_in_target OR l_update then
470 --
471 l_current_pk_id := r_PRB.information1;
472 --
473 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
474 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
475 --
476 if l_current_pk_id = l_prev_pk_id then
477 --
478 l_first_rec := false ;
479 --
480 else
481 --
482 l_first_rec := true ;
483 --
484 end if ;
485 --
486
487 l_effective_date := r_PRB.information2;
488 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
489 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
490 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
491 end if;
492
493 if l_first_rec and not l_update then
494 -- Call Create routine.
495 hr_utility.set_location(' BEN_PL_REGY_BOD_F CREATE_PLAN_REGULATORY_BODY ',20);
496 BEN_PLAN_REGULATORY_BODY_API.CREATE_PLAN_REGULATORY_BODY(
497 --
498 P_VALIDATE => false
499 ,P_EFFECTIVE_DATE => l_effective_date
500 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
501 --
502 ,P_APRVD_TRMN_DT => r_PRB.INFORMATION306
503 ,P_PL_ID => l_PL_ID
504 ,P_PL_REGY_BOD_ID => l_pl_regy_bod_id
505 ,P_PRB_ATTRIBUTE1 => r_PRB.INFORMATION111
506 ,P_PRB_ATTRIBUTE10 => r_PRB.INFORMATION120
507 ,P_PRB_ATTRIBUTE11 => r_PRB.INFORMATION121
508 ,P_PRB_ATTRIBUTE12 => r_PRB.INFORMATION122
509 ,P_PRB_ATTRIBUTE13 => r_PRB.INFORMATION123
510 ,P_PRB_ATTRIBUTE14 => r_PRB.INFORMATION124
511 ,P_PRB_ATTRIBUTE15 => r_PRB.INFORMATION125
512 ,P_PRB_ATTRIBUTE16 => r_PRB.INFORMATION126
513 ,P_PRB_ATTRIBUTE17 => r_PRB.INFORMATION127
514 ,P_PRB_ATTRIBUTE18 => r_PRB.INFORMATION128
515 ,P_PRB_ATTRIBUTE19 => r_PRB.INFORMATION129
516 ,P_PRB_ATTRIBUTE2 => r_PRB.INFORMATION112
517 ,P_PRB_ATTRIBUTE20 => r_PRB.INFORMATION130
518 ,P_PRB_ATTRIBUTE21 => r_PRB.INFORMATION131
519 ,P_PRB_ATTRIBUTE22 => r_PRB.INFORMATION132
520 ,P_PRB_ATTRIBUTE23 => r_PRB.INFORMATION133
521 ,P_PRB_ATTRIBUTE24 => r_PRB.INFORMATION134
522 ,P_PRB_ATTRIBUTE25 => r_PRB.INFORMATION135
523 ,P_PRB_ATTRIBUTE26 => r_PRB.INFORMATION136
524 ,P_PRB_ATTRIBUTE27 => r_PRB.INFORMATION137
525 ,P_PRB_ATTRIBUTE28 => r_PRB.INFORMATION138
526 ,P_PRB_ATTRIBUTE29 => r_PRB.INFORMATION139
527 ,P_PRB_ATTRIBUTE3 => r_PRB.INFORMATION113
528 ,P_PRB_ATTRIBUTE30 => r_PRB.INFORMATION140
529 ,P_PRB_ATTRIBUTE4 => r_PRB.INFORMATION114
530 ,P_PRB_ATTRIBUTE5 => r_PRB.INFORMATION115
531 ,P_PRB_ATTRIBUTE6 => r_PRB.INFORMATION116
532 ,P_PRB_ATTRIBUTE7 => r_PRB.INFORMATION117
533 ,P_PRB_ATTRIBUTE8 => r_PRB.INFORMATION118
534 ,P_PRB_ATTRIBUTE9 => r_PRB.INFORMATION119
535 ,P_PRB_ATTRIBUTE_CATEGORY => r_PRB.INFORMATION110
536 ,P_QUALD_DT => r_PRB.INFORMATION309
537 ,P_QUALD_FLAG => r_PRB.INFORMATION11
538 ,P_REGY_PL_NAME => r_PRB.INFORMATION185
539 ,P_RPTG_GRP_ID => l_RPTG_GRP_ID
540 --
541 ,P_EFFECTIVE_START_DATE => l_effective_start_date
542 ,P_EFFECTIVE_END_DATE => l_effective_end_date
543 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
544 );
545 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
546 -- Update all relevent cer records with new pk_id
547 hr_utility.set_location('Before plsql table ',222);
548 hr_utility.set_location('new_value id '||l_pl_regy_bod_id,222);
549 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_REGY_BOD_ID' ;
550 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PRB.information1 ;
551 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PL_REGY_BOD_ID ;
552 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
553 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PRB_unique.table_route_id;
554 hr_utility.set_location('After plsql table ',222);
555 --
556 -- 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 ) ;
557 --
558 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
559 --
560 else
561 --
562 -- Call Update routine for the pk_id created in prev run .
563 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
564 hr_utility.set_location(' BEN_PL_REGY_BOD_F UPDATE_PLAN_REGULATORY_BODY ',30);
565 --UPD START
566 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
567 --
568 if l_update then
569 --
570 l_datetrack_mode := r_PRB.datetrack_mode ;
571 --
572 get_dt_modes(
573 p_effective_date => l_process_date,
574 p_effective_end_date => r_PRB.information3,
575 p_effective_start_date => r_PRB.information2,
576 p_dml_operation => r_PRB.dml_operation,
577 p_datetrack_mode => l_datetrack_mode );
578 -- p_update => l_update
579 --
580 l_effective_date := l_process_date;
581 l_PL_REGY_BOD_ID := r_PRB.information1;
582 l_object_version_number := r_PRB.information265;
583 --
584 end if;
585 --
586 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
587 --
588 IF l_update OR l_dml_operation <> 'UPDATE' THEN
589 --UPD END
590
591 BEN_PLAN_REGULATORY_BODY_API.UPDATE_PLAN_REGULATORY_BODY(
592 --
593 P_VALIDATE => false
594 ,P_EFFECTIVE_DATE => l_effective_date
595 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
596 --
597 ,P_APRVD_TRMN_DT => r_PRB.INFORMATION306
598 ,P_PL_ID => l_PL_ID
599 ,P_PL_REGY_BOD_ID => l_pl_regy_bod_id
600 ,P_PRB_ATTRIBUTE1 => r_PRB.INFORMATION111
601 ,P_PRB_ATTRIBUTE10 => r_PRB.INFORMATION120
602 ,P_PRB_ATTRIBUTE11 => r_PRB.INFORMATION121
603 ,P_PRB_ATTRIBUTE12 => r_PRB.INFORMATION122
604 ,P_PRB_ATTRIBUTE13 => r_PRB.INFORMATION123
605 ,P_PRB_ATTRIBUTE14 => r_PRB.INFORMATION124
606 ,P_PRB_ATTRIBUTE15 => r_PRB.INFORMATION125
607 ,P_PRB_ATTRIBUTE16 => r_PRB.INFORMATION126
608 ,P_PRB_ATTRIBUTE17 => r_PRB.INFORMATION127
609 ,P_PRB_ATTRIBUTE18 => r_PRB.INFORMATION128
610 ,P_PRB_ATTRIBUTE19 => r_PRB.INFORMATION129
611 ,P_PRB_ATTRIBUTE2 => r_PRB.INFORMATION112
612 ,P_PRB_ATTRIBUTE20 => r_PRB.INFORMATION130
613 ,P_PRB_ATTRIBUTE21 => r_PRB.INFORMATION131
614 ,P_PRB_ATTRIBUTE22 => r_PRB.INFORMATION132
615 ,P_PRB_ATTRIBUTE23 => r_PRB.INFORMATION133
616 ,P_PRB_ATTRIBUTE24 => r_PRB.INFORMATION134
617 ,P_PRB_ATTRIBUTE25 => r_PRB.INFORMATION135
618 ,P_PRB_ATTRIBUTE26 => r_PRB.INFORMATION136
619 ,P_PRB_ATTRIBUTE27 => r_PRB.INFORMATION137
620 ,P_PRB_ATTRIBUTE28 => r_PRB.INFORMATION138
621 ,P_PRB_ATTRIBUTE29 => r_PRB.INFORMATION139
622 ,P_PRB_ATTRIBUTE3 => r_PRB.INFORMATION113
623 ,P_PRB_ATTRIBUTE30 => r_PRB.INFORMATION140
624 ,P_PRB_ATTRIBUTE4 => r_PRB.INFORMATION114
625 ,P_PRB_ATTRIBUTE5 => r_PRB.INFORMATION115
626 ,P_PRB_ATTRIBUTE6 => r_PRB.INFORMATION116
627 ,P_PRB_ATTRIBUTE7 => r_PRB.INFORMATION117
628 ,P_PRB_ATTRIBUTE8 => r_PRB.INFORMATION118
629 ,P_PRB_ATTRIBUTE9 => r_PRB.INFORMATION119
630 ,P_PRB_ATTRIBUTE_CATEGORY => r_PRB.INFORMATION110
631 ,P_QUALD_DT => r_PRB.INFORMATION309
632 ,P_QUALD_FLAG => r_PRB.INFORMATION11
633 ,P_REGY_PL_NAME => r_PRB.INFORMATION185
634 ,P_RPTG_GRP_ID => l_RPTG_GRP_ID
635 --
636 ,P_EFFECTIVE_START_DATE => l_effective_start_date
637 ,P_EFFECTIVE_END_DATE => l_effective_end_date
638 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
639 ,P_DATETRACK_MODE => l_datetrack_mode
640 );
641
642 end if; -- l_update
643
644 --
645 end if;
646 --
647 -- Delete the row if it is end dated.
648 --
649 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
650 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
651 trunc(l_max_eed) = r_PRB.information3) then
652 --
653 BEN_PLAN_REGULATORY_BODY_API.delete_PLAN_REGULATORY_BODY(
654 --
655 p_validate => false
656 ,p_pl_regy_bod_id => l_pl_regy_bod_id
657 ,p_effective_start_date => l_effective_start_date
658 ,p_effective_end_date => l_effective_end_date
659 ,p_object_version_number => l_object_version_number
660 ,p_effective_date => l_max_eed
661 ,p_datetrack_mode => hr_api.g_delete
662 --
663 );
664 --
665 end if;
666 --
667 l_prev_pk_id := l_current_pk_id ;
668 --
669 end if;
670 --
671 end if;
672 --
673 end if;
674 --
675 end loop;
676 --
677 exception when others then
678 --
679 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PRB',r_prb.information5 );
680 --
681 end create_PRB_rows;
682
683 --
684 ---------------------------------------------------------------
685 ----------------------< create_SAZ_rows >-----------------------
686 ---------------------------------------------------------------
687 --
688 procedure create_SAZ_rows
689 (
690 p_validate in number default 0
691 ,p_copy_entity_txn_id in number
692 ,p_effective_date in date
693 ,p_prefix_suffix_text in varchar2 default null
694 ,p_reuse_object_flag in varchar2 default null
695 ,p_target_business_group_id in varchar2 default null
696 ,p_prefix_suffix_cd in varchar2 default null
697 ) is
698 --
699 l_PSTL_ZIP_RNG_ID number;
700 l_SVC_AREA_ID number;
701 cursor c_unique_SAZ(l_table_alias varchar2) is
702 select distinct cpe.information1,
703 cpe.information2,
704 cpe.information3,
705 cpe.table_route_id,
706 cpe.dml_operation,
707 cpe.datetrack_mode
708 from ben_copy_entity_results cpe,
709 pqh_table_route tr
710 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
711 and cpe.table_route_id = tr.table_route_id
712 -- and tr.where_clause = l_BEN_SVC_AREA_PSTL_ZIP_RNG_F
713 and tr.table_alias = l_table_alias
714 and cpe.number_of_copies = 1 --ADDITION
715 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
716 order by information1, information2; --added for bug: 5151945
717 --
718 --
719 cursor c_SAZ_min_max_dates(c_table_route_id number,
720 c_information1 number) is
721 select
722 min(cpe.information2) min_esd,
723 max(cpe.information3) min_eed
724 from ben_copy_entity_results cpe
725 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
726 and cpe.table_route_id = c_table_route_id
727 and cpe.information1 = c_information1 ;
728 --
729 cursor c_SAZ(c_table_route_id number,
730 c_information1 number,
731 c_information2 date,
732 c_information3 date ) is
733 select
734 cpe.*
735 from ben_copy_entity_results cpe
736 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
737 and cpe.table_route_id = c_table_route_id
738 and cpe.information1 = c_information1
739 and cpe.information2 = c_information2
740 and cpe.information3 = c_information3
741 and rownum = 1 ;
742 -- Date Track target record
743 cursor c_find_SAZ_in_target(
744 c_effective_start_date date,
745 c_effective_end_date date,
746 c_business_group_id number,
747 c_new_pk_id number) is
748 select
749 SAZ.svc_area_pstl_zip_rng_id new_value
750 from BEN_SVC_AREA_PSTL_ZIP_RNG_F SAZ
751 where
752 SAZ.PSTL_ZIP_RNG_ID = l_PSTL_ZIP_RNG_ID and
753 SAZ.SVC_AREA_ID = l_SVC_AREA_ID and
754 SAZ.business_group_id = c_business_group_id
755 and SAZ.svc_area_pstl_zip_rng_id <> c_new_pk_id
756 --TEMPIK
757 and c_effective_start_date between effective_start_date
758 and effective_end_date ;
759 --END TEMPIK
760 /*TEMPIK
761 and exists ( select null
762 from BEN_SVC_AREA_PSTL_ZIP_RNG_F SAZ1
763 where
764 SAZ1.PSTL_ZIP_RNG_ID = l_PSTL_ZIP_RNG_ID and
765 SAZ1.SVC_AREA_ID = l_SVC_AREA_ID and
766 SAZ1.business_group_id = c_business_group_id
767 and SAZ1.effective_start_date <= c_effective_start_date )
768 and exists ( select null
769 from BEN_SVC_AREA_PSTL_ZIP_RNG_F SAZ2
770 where
771 SAZ2.PSTL_ZIP_RNG_ID = l_PSTL_ZIP_RNG_ID and
772 SAZ2.SVC_AREA_ID = l_SVC_AREA_ID and
773 SAZ2.business_group_id = c_business_group_id
774 and SAZ2.effective_end_date >= c_effective_end_date )
775 ;
776 TEMPIK */
777 --TEMPIK
778 l_dt_rec_found boolean ;
779 --END TEMPIK
780 --
781 --UPD START
782 --
783 l_update boolean := false ;
784 l_datetrack_mode varchar2(80) := hr_api.g_update;
785 l_process_date date;
786 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
787 --
788 --UPD END
789 l_current_pk_id number := null ;
790 l_prev_pk_id number := null ;
791 l_first_rec boolean := true ;
792 r_SAZ c_SAZ%rowtype;
793 l_svc_area_pstl_zip_rng_id number ;
794 l_object_version_number number ;
795 l_effective_start_date date ;
796 l_effective_end_date date ;
797 l_prefix pqh_copy_entity_attribs.information1%type := null;
798 l_suffix pqh_copy_entity_attribs.information1%type := null;
799 l_new_value number(15);
800 l_object_found_in_target boolean := false ;
801 l_min_esd date;
802 l_max_eed date;
803 l_effective_date date;
804 --
805 begin
806 -- Initialization
807 l_object_found_in_target := false ;
808 -- End Initialization
809 -- Derive the prefix - sufix
810 if p_prefix_suffix_cd = 'PREFIX' then
811 l_prefix := p_prefix_suffix_text ;
812 elsif p_prefix_suffix_cd = 'SUFFIX' then
813 l_suffix := p_prefix_suffix_text ;
814 else
815 l_prefix := null ;
816 l_suffix := null ;
817 end if ;
818 -- End Prefix Sufix derivation
819 for r_SAZ_unique in c_unique_SAZ('SAZ') loop
820
821 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
822 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
823 r_SAZ_unique.information3 >=
824 ben_pd_copy_to_ben_one.g_copy_effective_date)
825 ) then
826 --
827 hr_utility.set_location(' r_SAZ_unique.table_route_id '||r_SAZ_unique.table_route_id,10);
828 hr_utility.set_location(' r_SAZ_unique.information1 '||r_SAZ_unique.information1,10);
829 hr_utility.set_location( 'r_SAZ_unique.information2 '||r_SAZ_unique.information2,10);
830 hr_utility.set_location( 'r_SAZ_unique.information3 '||r_SAZ_unique.information3,10);
831 -- If reuse objects flag is 'Y' then check for the object in the target business group
832 -- if found insert the record into PLSql table and exit the loop else try create the
833 -- object in the target business group
834 --
835 l_object_found_in_target := false ;
836 --UPD START
837 open c_SAZ(r_SAZ_unique.table_route_id,
838 r_SAZ_unique.information1,
839 r_SAZ_unique.information2,
840 r_SAZ_unique.information3 ) ;
841 --
842 fetch c_SAZ into r_SAZ ;
843 --
844 close c_SAZ ;
845 --
846 l_dml_operation:= r_SAZ_unique.dml_operation ;
847 l_PSTL_ZIP_RNG_ID := get_fk('PSTL_ZIP_RNG_ID', r_SAZ.INFORMATION245,l_dml_operation);
848 l_SVC_AREA_ID := get_fk('SVC_AREA_ID', r_SAZ.INFORMATION241,l_dml_operation);
849 --
850 l_update := false;
851 l_process_date := p_effective_date;
852 --
853 if l_dml_operation = 'UPDATE' then
854 --
855 l_object_found_in_target := TRUE;
856 --
857 if l_process_date between r_SAZ_unique.information2 and r_SAZ_unique.information3 then
858 l_update := true;
859 if r_SAZ_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
860 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'SVC_AREA_PSTL_ZIP_RNG_ID'
861 then
862 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'SVC_AREA_PSTL_ZIP_RNG_ID' ;
863 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_SAZ_unique.information1 ;
864 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_SAZ_unique.information1 ;
865 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
866 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_SAZ_unique.table_route_id;
867 --
868 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
869 --
870 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
871 --
872 --DOUBT log_data('SAZ',l_new_value,l_prefix || r_SAZ_unique.name|| l_suffix,'REUSED');
873 --
874 end if ;
875 hr_utility.set_location( 'found record for update',10);
876 --
877 else
878 --
879 l_update := false;
880 --
881 end if;
882 else
883 --
884 --UPD END
885 l_min_esd := null ;
886 l_max_eed := null ;
887 open c_SAZ_min_max_dates(r_SAZ_unique.table_route_id, r_SAZ_unique.information1 ) ;
888 fetch c_SAZ_min_max_dates into l_min_esd,l_max_eed ;
889 --
890
891 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
892 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
893 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
894 end if;
895 l_min_esd := greatest(l_min_esd,r_SAZ_unique.information2);
896
897 --
898 if p_reuse_object_flag = 'Y' then
899 if c_SAZ_min_max_dates%found then
900 -- cursor to find the object
901 open c_find_SAZ_in_target( l_min_esd,l_max_eed,
902 p_target_business_group_id, nvl(l_svc_area_pstl_zip_rng_id, -999) ) ;
903 fetch c_find_SAZ_in_target into l_new_value ;
904 if c_find_SAZ_in_target%found then
905 --
906 --TEMPIK
907 l_dt_rec_found := dt_api.check_min_max_dates
908 (p_base_table_name => 'BEN_SVC_AREA_PSTL_ZIP_RNG_F',
909 p_base_key_column => 'SVC_AREA_PSTL_ZIP_RNG_ID',
910 p_base_key_value => l_new_value,
911 p_from_date => l_min_esd,
912 p_to_date => l_max_eed );
913 if l_dt_rec_found THEN
914 --END TEMPIK
915 if r_SAZ_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
916 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'SVC_AREA_PSTL_ZIP_RNG_ID' then
917 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'SVC_AREA_PSTL_ZIP_RNG_ID' ;
918 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_SAZ_unique.information1 ;
919 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
920 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
921 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_SAZ_unique.table_route_id;
922 --
923 -- 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) ;
924 --
925 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
926 end if ;
927 --
928 l_object_found_in_target := true ;
929 --TEMPIK
930 end if; -- l_dt_rec_found
931 --END TEMPIK
932 end if;
933 close c_find_SAZ_in_target ;
934 --
935 end if;
936 end if ;
937 --
938 close c_SAZ_min_max_dates ;
939
940 end if; --if p_dml_operation
941 --
942 if not l_object_found_in_target OR l_update then
943 --
944 l_current_pk_id := r_SAZ.information1;
945 --
946 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
947 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
948 --
949 if l_current_pk_id = l_prev_pk_id then
950 --
951 l_first_rec := false ;
952 --
953 else
954 --
955 l_first_rec := true ;
956 --
957 end if ;
958 --
959
960 l_effective_date := r_SAZ.information2;
961 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
962 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
963 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
964 end if;
965
966 if l_first_rec and not l_update then
967 -- Call Create routine.
968 hr_utility.set_location(' BEN_SVC_AREA_PSTL_ZIP_RNG_F CREATE_SVC_AREA_PSTL_ZIP_RNG ',20);
969 BEN_SVC_AREA_PSTL_ZIP_RNG_API.CREATE_SVC_AREA_PSTL_ZIP_RNG(
970 --
971 P_VALIDATE => false
972 ,P_EFFECTIVE_DATE => l_effective_date
973 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
974 --
975 ,P_PSTL_ZIP_RNG_ID => l_PSTL_ZIP_RNG_ID
976 ,P_SAZ_ATTRIBUTE1 => r_SAZ.INFORMATION111
977 ,P_SAZ_ATTRIBUTE10 => r_SAZ.INFORMATION120
978 ,P_SAZ_ATTRIBUTE11 => r_SAZ.INFORMATION121
979 ,P_SAZ_ATTRIBUTE12 => r_SAZ.INFORMATION122
980 ,P_SAZ_ATTRIBUTE13 => r_SAZ.INFORMATION123
981 ,P_SAZ_ATTRIBUTE14 => r_SAZ.INFORMATION124
982 ,P_SAZ_ATTRIBUTE15 => r_SAZ.INFORMATION125
983 ,P_SAZ_ATTRIBUTE16 => r_SAZ.INFORMATION126
984 ,P_SAZ_ATTRIBUTE17 => r_SAZ.INFORMATION127
985 ,P_SAZ_ATTRIBUTE18 => r_SAZ.INFORMATION128
986 ,P_SAZ_ATTRIBUTE19 => r_SAZ.INFORMATION129
987 ,P_SAZ_ATTRIBUTE2 => r_SAZ.INFORMATION112
988 ,P_SAZ_ATTRIBUTE20 => r_SAZ.INFORMATION130
989 ,P_SAZ_ATTRIBUTE21 => r_SAZ.INFORMATION131
990 ,P_SAZ_ATTRIBUTE22 => r_SAZ.INFORMATION132
991 ,P_SAZ_ATTRIBUTE23 => r_SAZ.INFORMATION133
992 ,P_SAZ_ATTRIBUTE24 => r_SAZ.INFORMATION134
993 ,P_SAZ_ATTRIBUTE25 => r_SAZ.INFORMATION135
994 ,P_SAZ_ATTRIBUTE26 => r_SAZ.INFORMATION136
995 ,P_SAZ_ATTRIBUTE27 => r_SAZ.INFORMATION137
996 ,P_SAZ_ATTRIBUTE28 => r_SAZ.INFORMATION138
997 ,P_SAZ_ATTRIBUTE29 => r_SAZ.INFORMATION139
998 ,P_SAZ_ATTRIBUTE3 => r_SAZ.INFORMATION113
999 ,P_SAZ_ATTRIBUTE30 => r_SAZ.INFORMATION140
1000 ,P_SAZ_ATTRIBUTE4 => r_SAZ.INFORMATION114
1001 ,P_SAZ_ATTRIBUTE5 => r_SAZ.INFORMATION115
1002 ,P_SAZ_ATTRIBUTE6 => r_SAZ.INFORMATION116
1003 ,P_SAZ_ATTRIBUTE7 => r_SAZ.INFORMATION117
1004 ,P_SAZ_ATTRIBUTE8 => r_SAZ.INFORMATION118
1005 ,P_SAZ_ATTRIBUTE9 => r_SAZ.INFORMATION119
1006 ,P_SAZ_ATTRIBUTE_CATEGORY => r_SAZ.INFORMATION110
1007 ,P_SVC_AREA_ID => l_SVC_AREA_ID
1008 ,P_SVC_AREA_PSTL_ZIP_RNG_ID => l_svc_area_pstl_zip_rng_id
1009 --
1010 ,P_EFFECTIVE_START_DATE => l_effective_start_date
1011 ,P_EFFECTIVE_END_DATE => l_effective_end_date
1012 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
1013 );
1014 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1015 -- Update all relevent cer records with new pk_id
1016 hr_utility.set_location('Before plsql table ',222);
1017 hr_utility.set_location('new_value id '||l_svc_area_pstl_zip_rng_id,222);
1018 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'SVC_AREA_PSTL_ZIP_RNG_ID' ;
1019 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_SAZ.information1 ;
1020 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_SVC_AREA_PSTL_ZIP_RNG_ID ;
1021 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
1022 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_SAZ_unique.table_route_id;
1023 hr_utility.set_location('After plsql table ',222);
1024 --
1025 -- 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 ) ;
1026 --
1027 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1028 --
1029 else
1030 --
1031 -- Call Update routine for the pk_id created in prev run .
1032 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1033 hr_utility.set_location(' BEN_SVC_AREA_PSTL_ZIP_RNG_F UPDATE_SVC_AREA_PSTL_ZIP_RNG ',30);
1034 --UPD START
1035 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
1036 --
1037 if l_update then
1038 --
1039 l_datetrack_mode := r_SAZ.datetrack_mode ;
1040 --
1041 get_dt_modes(
1042 p_effective_date => l_process_date,
1043 p_effective_end_date => r_SAZ.information3,
1044 p_effective_start_date => r_SAZ.information2,
1045 p_dml_operation => r_SAZ.dml_operation,
1046 p_datetrack_mode => l_datetrack_mode );
1047 -- p_update => l_update
1048 --
1049 l_effective_date := l_process_date;
1050 l_SVC_AREA_PSTL_ZIP_RNG_ID := r_SAZ.information1;
1051 l_object_version_number := r_SAZ.information265;
1052 --
1053 end if;
1054 --
1055 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
1056 --
1057 IF l_update OR l_dml_operation <> 'UPDATE' THEN
1058 --UPD END
1059
1060 BEN_SVC_AREA_PSTL_ZIP_RNG_API.UPDATE_SVC_AREA_PSTL_ZIP_RNG(
1061 --
1062 P_VALIDATE => false
1063 ,P_EFFECTIVE_DATE => l_effective_date
1064 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
1065 --
1066 ,P_PSTL_ZIP_RNG_ID => l_PSTL_ZIP_RNG_ID
1067 ,P_SAZ_ATTRIBUTE1 => r_SAZ.INFORMATION111
1068 ,P_SAZ_ATTRIBUTE10 => r_SAZ.INFORMATION120
1069 ,P_SAZ_ATTRIBUTE11 => r_SAZ.INFORMATION121
1070 ,P_SAZ_ATTRIBUTE12 => r_SAZ.INFORMATION122
1071 ,P_SAZ_ATTRIBUTE13 => r_SAZ.INFORMATION123
1072 ,P_SAZ_ATTRIBUTE14 => r_SAZ.INFORMATION124
1073 ,P_SAZ_ATTRIBUTE15 => r_SAZ.INFORMATION125
1074 ,P_SAZ_ATTRIBUTE16 => r_SAZ.INFORMATION126
1075 ,P_SAZ_ATTRIBUTE17 => r_SAZ.INFORMATION127
1076 ,P_SAZ_ATTRIBUTE18 => r_SAZ.INFORMATION128
1077 ,P_SAZ_ATTRIBUTE19 => r_SAZ.INFORMATION129
1078 ,P_SAZ_ATTRIBUTE2 => r_SAZ.INFORMATION112
1079 ,P_SAZ_ATTRIBUTE20 => r_SAZ.INFORMATION130
1080 ,P_SAZ_ATTRIBUTE21 => r_SAZ.INFORMATION131
1081 ,P_SAZ_ATTRIBUTE22 => r_SAZ.INFORMATION132
1082 ,P_SAZ_ATTRIBUTE23 => r_SAZ.INFORMATION133
1083 ,P_SAZ_ATTRIBUTE24 => r_SAZ.INFORMATION134
1084 ,P_SAZ_ATTRIBUTE25 => r_SAZ.INFORMATION135
1085 ,P_SAZ_ATTRIBUTE26 => r_SAZ.INFORMATION136
1086 ,P_SAZ_ATTRIBUTE27 => r_SAZ.INFORMATION137
1087 ,P_SAZ_ATTRIBUTE28 => r_SAZ.INFORMATION138
1088 ,P_SAZ_ATTRIBUTE29 => r_SAZ.INFORMATION139
1089 ,P_SAZ_ATTRIBUTE3 => r_SAZ.INFORMATION113
1090 ,P_SAZ_ATTRIBUTE30 => r_SAZ.INFORMATION140
1091 ,P_SAZ_ATTRIBUTE4 => r_SAZ.INFORMATION114
1092 ,P_SAZ_ATTRIBUTE5 => r_SAZ.INFORMATION115
1093 ,P_SAZ_ATTRIBUTE6 => r_SAZ.INFORMATION116
1094 ,P_SAZ_ATTRIBUTE7 => r_SAZ.INFORMATION117
1095 ,P_SAZ_ATTRIBUTE8 => r_SAZ.INFORMATION118
1096 ,P_SAZ_ATTRIBUTE9 => r_SAZ.INFORMATION119
1097 ,P_SAZ_ATTRIBUTE_CATEGORY => r_SAZ.INFORMATION110
1098 ,P_SVC_AREA_ID => l_SVC_AREA_ID
1099 ,P_SVC_AREA_PSTL_ZIP_RNG_ID => l_svc_area_pstl_zip_rng_id
1100 --
1101 ,P_EFFECTIVE_START_DATE => l_effective_start_date
1102 ,P_EFFECTIVE_END_DATE => l_effective_end_date
1103 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
1104 ,P_DATETRACK_MODE => l_datetrack_mode
1105 );
1106 --
1107 end if; -- l_update
1108 end if;
1109 --
1110 -- Delete the row if it is end dated.
1111 --
1112 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
1113 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
1114 trunc(l_max_eed) = r_SAZ.information3) then
1115 --
1116 BEN_SVC_AREA_PSTL_ZIP_RNG_API.delete_SVC_AREA_PSTL_ZIP_RNG(
1117 --
1118 p_validate => false
1119 ,p_svc_area_pstl_zip_rng_id => l_svc_area_pstl_zip_rng_id
1120 ,p_effective_start_date => l_effective_start_date
1121 ,p_effective_end_date => l_effective_end_date
1122 ,p_object_version_number => l_object_version_number
1123 ,p_effective_date => l_max_eed
1124 ,p_datetrack_mode => hr_api.g_delete
1125 --
1126 );
1127 --
1128 end if;
1129 --
1130 l_prev_pk_id := l_current_pk_id ;
1131 --
1132 end if;
1133 --
1134 end if;
1135 --
1136 end loop;
1137 --
1138 exception when others then
1139 --
1140 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'SAZ',r_saz.information5 );
1141 --
1142 end create_SAZ_rows;
1143 ---------------------------------------------------------------
1144 ----------------------< create_PCX_rows >-----------------------
1145 ---------------------------------------------------------------
1146 --
1147 procedure create_PCX_rows
1148 (
1149 p_validate in number default 0
1150 ,p_copy_entity_txn_id in number
1151 ,p_effective_date in date
1152 ,p_prefix_suffix_text in varchar2 default null
1153 ,p_reuse_object_flag in varchar2 default null
1154 ,p_target_business_group_id in varchar2 default null
1155 ,p_prefix_suffix_cd in varchar2 default null
1156 ) is
1157 --
1158 l_CTFN_RQD_WHEN_RL number;
1159 l_PL_ID number;
1160 l_BNF_CTFN_TYP_CD varchar2(30);
1161 l_BNF_TYP_CD varchar2(30);
1162 l_RLSHP_TYP_CD varchar2(30);
1163 --
1164 cursor c_unique_PCX(l_table_alias varchar2) is
1165 select distinct cpe.information1,
1166 cpe.information2,
1167 cpe.information3,
1168 cpe.table_route_id
1169 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
1170 pqh_table_route tr
1171 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1172 and cpe.table_route_id = tr.table_route_id
1173 -- and tr.where_clause = l_BEN_PL_BNF_CTFN_F
1174 and tr.table_alias = l_table_alias
1175 and cpe.number_of_copies = 1 --ADDITION
1176 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
1177 order by information1, information2; --added for bug: 5151945
1178 --
1179 --
1180 cursor c_PCX_min_max_dates(c_table_route_id number,
1181 c_information1 number) is
1182 select
1183 min(cpe.information2) min_esd,
1184 max(cpe.information3) min_eed
1185 from ben_copy_entity_results cpe
1186 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1187 and cpe.table_route_id = c_table_route_id
1188 and cpe.information1 = c_information1 ;
1189 --
1190 cursor c_PCX(c_table_route_id number,
1191 c_information1 number,
1192 c_information2 date,
1193 c_information3 date ) is
1194 select
1195 cpe.*
1196 from ben_copy_entity_results cpe
1197 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1198 and cpe.table_route_id = c_table_route_id
1199 and cpe.information1 = c_information1
1200 and cpe.information2 = c_information2
1201 and cpe.information3 = c_information3
1202 and rownum = 1 ;
1203 -- Date Track target record
1204 cursor c_find_PCX_in_target(
1205 c_effective_start_date date,
1206 c_effective_end_date date,
1207 c_business_group_id number,
1208 c_new_pk_id number) is
1209 select
1210 PCX.pl_bnf_ctfn_id new_value
1211 from BEN_PL_BNF_CTFN_F PCX
1212 where
1213 nvl(PCX.PL_ID,-999) = nvl(l_PL_ID,-999) and
1214 nvl(PCX.BNF_CTFN_TYP_CD,-999) = nvl(l_BNF_CTFN_TYP_CD,-999) and
1215 nvl(PCX.BNF_TYP_CD,-999) = nvl(l_BNF_TYP_CD,-999) and
1216 nvl(PCX.RLSHP_TYP_CD,-999) = nvl(l_RLSHP_TYP_CD,-999) and
1217 PCX.business_group_id = c_business_group_id
1218 and PCX.pl_bnf_ctfn_id <> c_new_pk_id
1219 --TEMPIK
1220 and c_effective_start_date between effective_start_date
1221 and effective_end_date ;
1222 --END TEMPIK
1223 /* TEMPIK
1224 and exists ( select null
1225 from BEN_PL_BNF_CTFN_F PCX1
1226 where
1227 nvl(PCX1.PL_ID,-999) = nvl(l_PL_ID,-999) and
1228 nvl(PCX1.BNF_CTFN_TYP_CD,-999) = nvl(l_BNF_CTFN_TYP_CD,-999) and
1229 nvl(PCX1.BNF_TYP_CD,-999) = nvl(l_BNF_TYP_CD,-999) and
1230 nvl(PCX1.RLSHP_TYP_CD,-999) = nvl(l_RLSHP_TYP_CD,-999) and
1231 PCX1.business_group_id = c_business_group_id
1232 and PCX1.effective_start_date <= c_effective_start_date )
1233 and exists ( select null
1234 from BEN_PL_BNF_CTFN_F PCX2
1235 where
1236 nvl(PCX2.PL_ID,-999) = nvl(l_PL_ID,-999) and
1237 nvl(PCX2.BNF_CTFN_TYP_CD,-999) = nvl(l_BNF_CTFN_TYP_CD,-999) and
1238 nvl(PCX2.BNF_TYP_CD,-999) = nvl(l_BNF_TYP_CD,-999) and
1239 nvl(PCX2.RLSHP_TYP_CD,-999) = nvl(l_RLSHP_TYP_CD,-999) and
1240 PCX2.business_group_id = c_business_group_id
1241 and PCX2.effective_end_date >= c_effective_end_date )
1242 ;
1243 TEMPIK */
1244 --
1245 --UPD START
1246 --
1247 l_update boolean := false ;
1248 l_datetrack_mode varchar2(80) := hr_api.g_update;
1249 l_process_date date;
1250 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
1251 --
1252 --UPD END
1253 l_current_pk_id number := null ;
1254 l_prev_pk_id number := null ;
1255 l_first_rec boolean := true ;
1256 r_PCX c_PCX%rowtype;
1257 l_pl_bnf_ctfn_id number ;
1258 l_object_version_number number ;
1259 l_effective_start_date date ;
1260 l_effective_end_date date ;
1261 l_prefix pqh_copy_entity_attribs.information1%type := null;
1262 l_suffix pqh_copy_entity_attribs.information1%type := null;
1263 l_new_value number(15);
1264 l_object_found_in_target boolean := false ;
1265 l_min_esd date;
1266 l_max_eed date;
1267 l_effective_date date;
1268 --
1269 --TEMPIK
1270 l_dt_rec_found boolean ;
1271 --END TEMPIK
1272 --
1273 begin
1274 -- Initialization
1275 l_object_found_in_target := false ;
1276 -- End Initialization
1277 -- Derive the prefix - sufix
1278 if p_prefix_suffix_cd = 'PREFIX' then
1279 l_prefix := p_prefix_suffix_text ;
1280 elsif p_prefix_suffix_cd = 'SUFFIX' then
1281 l_suffix := p_prefix_suffix_text ;
1282 else
1283 l_prefix := null ;
1284 l_suffix := null ;
1285 end if ;
1286 -- End Prefix Sufix derivation
1287 for r_PCX_unique in c_unique_PCX('PCX') loop
1288
1289 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
1290 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
1291 r_PCX_unique.information3 >=
1292 ben_pd_copy_to_ben_one.g_copy_effective_date)
1293 ) then
1294 --
1295 hr_utility.set_location(' r_PCX_unique.table_route_id '||r_PCX_unique.table_route_id,10);
1296 hr_utility.set_location(' r_PCX_unique.information1 '||r_PCX_unique.information1,10);
1297 hr_utility.set_location( 'r_PCX_unique.information2 '||r_PCX_unique.information2,10);
1298 hr_utility.set_location( 'r_PCX_unique.information3 '||r_PCX_unique.information3,10);
1299 -- If reuse objects flag is 'Y' then check for the object in the target business group
1300 -- if found insert the record into PLSql table and exit the loop else try create the
1301 -- object in the target business group
1302 --
1303 l_object_found_in_target := false ;
1304 --
1305 open c_PCX(r_PCX_unique.table_route_id,
1306 r_PCX_unique.information1,
1307 r_PCX_unique.information2,
1308 r_PCX_unique.information3 ) ;
1309 --
1310 fetch c_PCX into r_PCX ;
1311 --
1312 close c_PCX ;
1313 --
1314 l_dml_operation:= r_PCX_unique.dml_operation ;
1315 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_PCX.INFORMATION260,l_dml_operation);
1316 l_PL_ID := get_fk('PL_ID', r_PCX.INFORMATION261,l_dml_operation);
1317 --
1318 --UPD START
1319 l_update := false;
1320 l_process_date := p_effective_date;
1321 --
1322 if l_dml_operation = 'UPDATE' then
1323 --
1324 l_object_found_in_target := TRUE;
1325 --
1326 if l_process_date between r_PCX_unique.information2 and r_PCX_unique.information3 then
1327 l_update := true;
1328 if r_PCX_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
1329 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_BNF_CTFN_ID'
1330 then
1331 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_BNF_CTFN_ID' ;
1332 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PCX_unique.information1 ;
1333 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PCX_unique.information1 ;
1334 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
1335 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PCX_unique.table_route_id;
1336 --
1337 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
1338 --
1339 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1340 --
1341 -- log_data('PCX',l_new_value,l_prefix || r_PCX_unique.name|| l_suffix,'REUSED');
1342 --
1343 end if ;
1344 hr_utility.set_location( 'found record for update',10);
1345 --
1346 else
1347 --
1348 l_update := false;
1349 --
1350 end if;
1351 else
1352 --
1353 --UPD END
1354
1355 l_min_esd := null ;
1356 l_max_eed := null ;
1357 open c_PCX_min_max_dates(r_PCX_unique.table_route_id, r_PCX_unique.information1 ) ;
1358 fetch c_PCX_min_max_dates into l_min_esd,l_max_eed ;
1359
1360 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
1361 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
1362 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
1363 end if;
1364 l_min_esd := greatest(l_min_esd,r_PCX_unique.information2);
1365
1366 --
1367 l_BNF_CTFN_TYP_CD := r_PCX.information11;
1368 l_BNF_TYP_CD := r_PCX.information15;
1369 l_RLSHP_TYP_CD := r_PCX.information16;
1370 --
1371 if p_reuse_object_flag = 'Y' then
1372 if c_PCX_min_max_dates%found then
1373 -- cursor to find the object
1374 open c_find_PCX_in_target( l_min_esd,l_max_eed,
1375 p_target_business_group_id, nvl(l_pl_bnf_ctfn_id, -999) ) ;
1376 fetch c_find_PCX_in_target into l_new_value ;
1377 if c_find_PCX_in_target%found then
1378 --
1379 --TEMPIK
1380 l_dt_rec_found := dt_api.check_min_max_dates
1381 (p_base_table_name => 'BEN_PL_BNF_CTFN_F',
1382 p_base_key_column => 'PL_BNF_CTFN_ID',
1383 p_base_key_value => l_new_value,
1384 p_from_date => l_min_esd,
1385 p_to_date => l_max_eed );
1386 if l_dt_rec_found THEN
1387 --END TEMPIK
1388 if r_PCX_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
1389 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_BNF_CTFN_ID' then
1390 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_BNF_CTFN_ID' ;
1391 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PCX_unique.information1 ;
1392 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
1393 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
1394 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PCX_unique.table_route_id;
1395 --
1396 -- 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) ;
1397 --
1398 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1399 end if ;
1400 --
1401 l_object_found_in_target := true ;
1402 --TEMPIK
1403 end if; -- l_dt_rec_found
1404 --END TEMPIK
1405 end if;
1406 close c_find_PCX_in_target ;
1407 --
1408 end if;
1409 end if ;
1410 --
1411 close c_PCX_min_max_dates ;
1412 end if; --if p_dml_operation
1413 --
1414 if not l_object_found_in_target OR l_update then
1415
1416
1417 --
1418 l_current_pk_id := r_PCX.information1;
1419 --
1420 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
1421 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
1422 --
1423 if l_current_pk_id = l_prev_pk_id then
1424 --
1425 l_first_rec := false ;
1426 --
1427 else
1428 --
1429 l_first_rec := true ;
1430 --
1431 end if ;
1432 --
1433
1434 l_effective_date := r_PCX.information2;
1435 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
1436 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
1437 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
1438 end if;
1439
1440 if l_first_rec and not l_update then
1441
1442 -- Call Create routine.
1443 hr_utility.set_location(' BEN_PL_BNF_CTFN_F CREATE_PLAN_BENEFICIARY_CTFN ',20);
1444 BEN_PLAN_BENEFICIARY_CTFN_API.CREATE_PLAN_BENEFICIARY_CTFN(
1445 --
1446 P_VALIDATE => false
1447 ,P_EFFECTIVE_DATE => l_effective_date
1448 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
1449 --
1450 ,P_BNF_CTFN_TYP_CD => r_PCX.INFORMATION11
1451 ,P_BNF_TYP_CD => r_PCX.INFORMATION15
1452 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
1453 ,P_LACK_CTFN_SSPND_ENRT_FLAG => r_PCX.INFORMATION12
1454 ,P_PCX_ATTRIBUTE1 => r_PCX.INFORMATION111
1455 ,P_PCX_ATTRIBUTE10 => r_PCX.INFORMATION120
1456 ,P_PCX_ATTRIBUTE11 => r_PCX.INFORMATION121
1457 ,P_PCX_ATTRIBUTE12 => r_PCX.INFORMATION122
1458 ,P_PCX_ATTRIBUTE13 => r_PCX.INFORMATION123
1459 ,P_PCX_ATTRIBUTE14 => r_PCX.INFORMATION124
1460 ,P_PCX_ATTRIBUTE15 => r_PCX.INFORMATION125
1461 ,P_PCX_ATTRIBUTE16 => r_PCX.INFORMATION126
1462 ,P_PCX_ATTRIBUTE17 => r_PCX.INFORMATION127
1463 ,P_PCX_ATTRIBUTE18 => r_PCX.INFORMATION128
1464 ,P_PCX_ATTRIBUTE19 => r_PCX.INFORMATION129
1465 ,P_PCX_ATTRIBUTE2 => r_PCX.INFORMATION112
1466 ,P_PCX_ATTRIBUTE20 => r_PCX.INFORMATION130
1467 ,P_PCX_ATTRIBUTE21 => r_PCX.INFORMATION131
1468 ,P_PCX_ATTRIBUTE22 => r_PCX.INFORMATION132
1469 ,P_PCX_ATTRIBUTE23 => r_PCX.INFORMATION133
1470 ,P_PCX_ATTRIBUTE24 => r_PCX.INFORMATION134
1471 ,P_PCX_ATTRIBUTE25 => r_PCX.INFORMATION135
1472 ,P_PCX_ATTRIBUTE26 => r_PCX.INFORMATION136
1473 ,P_PCX_ATTRIBUTE27 => r_PCX.INFORMATION137
1474 ,P_PCX_ATTRIBUTE28 => r_PCX.INFORMATION138
1475 ,P_PCX_ATTRIBUTE29 => r_PCX.INFORMATION139
1476 ,P_PCX_ATTRIBUTE3 => r_PCX.INFORMATION113
1477 ,P_PCX_ATTRIBUTE30 => r_PCX.INFORMATION140
1478 ,P_PCX_ATTRIBUTE4 => r_PCX.INFORMATION114
1479 ,P_PCX_ATTRIBUTE5 => r_PCX.INFORMATION115
1480 ,P_PCX_ATTRIBUTE6 => r_PCX.INFORMATION116
1481 ,P_PCX_ATTRIBUTE7 => r_PCX.INFORMATION117
1482 ,P_PCX_ATTRIBUTE8 => r_PCX.INFORMATION118
1483 ,P_PCX_ATTRIBUTE9 => r_PCX.INFORMATION119
1484 ,P_PCX_ATTRIBUTE_CATEGORY => r_PCX.INFORMATION110
1485 ,P_PFD_FLAG => r_PCX.INFORMATION13
1486 ,P_PL_BNF_CTFN_ID => l_pl_bnf_ctfn_id
1487 ,P_PL_ID => l_PL_ID
1488 ,P_RLSHP_TYP_CD => r_PCX.INFORMATION16
1489 ,P_RQD_FLAG => r_PCX.INFORMATION14
1490 --
1491 ,P_EFFECTIVE_START_DATE => l_effective_start_date
1492 ,P_EFFECTIVE_END_DATE => l_effective_end_date
1493 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
1494 );
1495 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1496 -- Update all relevent cer records with new pk_id
1497 hr_utility.set_location('Before plsql table ',222);
1498 hr_utility.set_location('new_value id '||l_pl_bnf_ctfn_id,222);
1499 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_BNF_CTFN_ID' ;
1500 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PCX.information1 ;
1501 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PL_BNF_CTFN_ID ;
1502 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
1503 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PCX_unique.table_route_id;
1504 hr_utility.set_location('After plsql table ',222);
1505 --
1506 -- 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 ) ;
1507 --
1508 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1509 --
1510 else
1511 --
1512 -- Call Update routine for the pk_id created in prev run .
1513 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1514 hr_utility.set_location(' BEN_PL_BNF_CTFN_F UPDATE_PLAN_BENEFICIARY_CTFN ',30);
1515 --UPD START
1516 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
1517 --
1518 if l_update then
1519 --
1520 l_datetrack_mode := r_PCX.datetrack_mode ;
1521 --
1522 get_dt_modes(
1523 p_effective_date => l_process_date,
1524 p_effective_end_date => r_PCX.information3,
1525 p_effective_start_date => r_PCX.information2,
1526 p_dml_operation => r_PCX.dml_operation,
1527 p_datetrack_mode => l_datetrack_mode );
1528 -- p_update => l_update
1529 --
1530 l_effective_date := l_process_date;
1531 l_PL_BNF_CTFN_ID := r_PCX.information1;
1532 l_object_version_number := r_PCX.information265;
1533 --
1534 end if;
1535 --
1536 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
1537 --
1538 IF l_update OR l_dml_operation <> 'UPDATE' THEN
1539 --UPD END
1540
1541
1542 BEN_PLAN_BENEFICIARY_CTFN_API.UPDATE_PLAN_BENEFICIARY_CTFN(
1543 --
1544 P_VALIDATE => false
1545 ,P_EFFECTIVE_DATE => l_effective_date
1546 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
1547 --
1548 ,P_BNF_CTFN_TYP_CD => r_PCX.INFORMATION11
1549 ,P_BNF_TYP_CD => r_PCX.INFORMATION15
1550 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
1551 ,P_LACK_CTFN_SSPND_ENRT_FLAG => r_PCX.INFORMATION12
1552 ,P_PCX_ATTRIBUTE1 => r_PCX.INFORMATION111
1553 ,P_PCX_ATTRIBUTE10 => r_PCX.INFORMATION120
1554 ,P_PCX_ATTRIBUTE11 => r_PCX.INFORMATION121
1555 ,P_PCX_ATTRIBUTE12 => r_PCX.INFORMATION122
1556 ,P_PCX_ATTRIBUTE13 => r_PCX.INFORMATION123
1557 ,P_PCX_ATTRIBUTE14 => r_PCX.INFORMATION124
1558 ,P_PCX_ATTRIBUTE15 => r_PCX.INFORMATION125
1559 ,P_PCX_ATTRIBUTE16 => r_PCX.INFORMATION126
1560 ,P_PCX_ATTRIBUTE17 => r_PCX.INFORMATION127
1561 ,P_PCX_ATTRIBUTE18 => r_PCX.INFORMATION128
1562 ,P_PCX_ATTRIBUTE19 => r_PCX.INFORMATION129
1563 ,P_PCX_ATTRIBUTE2 => r_PCX.INFORMATION112
1564 ,P_PCX_ATTRIBUTE20 => r_PCX.INFORMATION130
1565 ,P_PCX_ATTRIBUTE21 => r_PCX.INFORMATION131
1566 ,P_PCX_ATTRIBUTE22 => r_PCX.INFORMATION132
1567 ,P_PCX_ATTRIBUTE23 => r_PCX.INFORMATION133
1568 ,P_PCX_ATTRIBUTE24 => r_PCX.INFORMATION134
1569 ,P_PCX_ATTRIBUTE25 => r_PCX.INFORMATION135
1570 ,P_PCX_ATTRIBUTE26 => r_PCX.INFORMATION136
1571 ,P_PCX_ATTRIBUTE27 => r_PCX.INFORMATION137
1572 ,P_PCX_ATTRIBUTE28 => r_PCX.INFORMATION138
1573 ,P_PCX_ATTRIBUTE29 => r_PCX.INFORMATION139
1574 ,P_PCX_ATTRIBUTE3 => r_PCX.INFORMATION113
1575 ,P_PCX_ATTRIBUTE30 => r_PCX.INFORMATION140
1576 ,P_PCX_ATTRIBUTE4 => r_PCX.INFORMATION114
1577 ,P_PCX_ATTRIBUTE5 => r_PCX.INFORMATION115
1578 ,P_PCX_ATTRIBUTE6 => r_PCX.INFORMATION116
1579 ,P_PCX_ATTRIBUTE7 => r_PCX.INFORMATION117
1580 ,P_PCX_ATTRIBUTE8 => r_PCX.INFORMATION118
1581 ,P_PCX_ATTRIBUTE9 => r_PCX.INFORMATION119
1582 ,P_PCX_ATTRIBUTE_CATEGORY => r_PCX.INFORMATION110
1583 ,P_PFD_FLAG => r_PCX.INFORMATION13
1584 ,P_PL_BNF_CTFN_ID => l_pl_bnf_ctfn_id
1585 ,P_PL_ID => l_PL_ID
1586 ,P_RLSHP_TYP_CD => r_PCX.INFORMATION16
1587 ,P_RQD_FLAG => r_PCX.INFORMATION14
1588 --
1589 ,P_EFFECTIVE_START_DATE => l_effective_start_date
1590 ,P_EFFECTIVE_END_DATE => l_effective_end_date
1591 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
1592 ,P_DATETRACK_MODE => l_datetrack_mode
1593 );
1594 --
1595 end if; -- l_update
1596 end if;
1597 --
1598 -- Delete the row if it is end dated.
1599 --
1600 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
1601 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
1602 trunc(l_max_eed) = r_PCX.information3) then
1603 --
1604 BEN_PLAN_BENEFICIARY_CTFN_API.delete_PLAN_BENEFICIARY_CTFN(
1605 --
1606 p_validate => false
1607 ,p_pl_bnf_ctfn_id => l_pl_bnf_ctfn_id
1608 ,p_effective_start_date => l_effective_start_date
1609 ,p_effective_end_date => l_effective_end_date
1610 ,p_object_version_number => l_object_version_number
1611 ,p_effective_date => l_max_eed
1612 ,p_datetrack_mode => hr_api.g_delete
1613 --
1614 );
1615 --
1616 end if;
1617 --
1618 l_prev_pk_id := l_current_pk_id ;
1619 --
1620 end if;
1621 --
1622 end if;
1623 --
1624 end loop;
1625 --
1626 exception when others then
1627 --
1628 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PCX',r_pcx.information5 );
1629 --
1630 end create_PCX_rows;
1631
1632 --
1633 ---------------------------------------------------------------
1634 ----------------------< create_PND_rows >-----------------------
1635 ---------------------------------------------------------------
1636 --
1637 procedure create_PND_rows
1638 (
1639 p_validate in number default 0
1640 ,p_copy_entity_txn_id in number
1641 ,p_effective_date in date
1642 ,p_prefix_suffix_text in varchar2 default null
1643 ,p_reuse_object_flag in varchar2 default null
1644 ,p_target_business_group_id in varchar2 default null
1645 ,p_prefix_suffix_cd in varchar2 default null
1646 ) is
1647 --
1648 l_CTFN_RQD_WHEN_RL number;
1649 l_PL_ID number;
1650 l_DPNT_CVG_CTFN_TYP_CD varchar2(30);
1651 --
1652 cursor c_unique_PND(l_table_alias varchar2) is
1653 select distinct cpe.information1,
1654 cpe.information2,
1655 cpe.information3,
1656 cpe.table_route_id
1657 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe, pqh_table_route tr
1658 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1659 and cpe.table_route_id = tr.table_route_id
1660 -- and tr.where_clause = l_BEN_PL_DPNT_CVG_CTFN_F
1661 and tr.table_alias = l_table_alias
1662 and cpe.number_of_copies = 1 --ADDITION
1663 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
1664 order by information1, information2; --added for bug: 5151945
1665 --
1666 --
1667 cursor c_PND_min_max_dates(c_table_route_id number,
1668 c_information1 number) is
1669 select
1670 min(cpe.information2) min_esd,
1671 max(cpe.information3) min_eed
1672 from ben_copy_entity_results cpe
1673 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1674 and cpe.table_route_id = c_table_route_id
1675 and cpe.information1 = c_information1 ;
1676 --
1677 cursor c_PND(c_table_route_id number,
1678 c_information1 number,
1679 c_information2 date,
1680 c_information3 date ) is
1681 select
1682 cpe.*
1683 from ben_copy_entity_results cpe
1684 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1685 and cpe.table_route_id = c_table_route_id
1686 and cpe.information1 = c_information1
1687 and cpe.information2 = c_information2
1688 and cpe.information3 = c_information3
1689 and rownum = 1 ;
1690 -- Date Track target record
1691 cursor c_find_PND_in_target(
1692 c_effective_start_date date,
1693 c_effective_end_date date,
1694 c_business_group_id number,
1695 c_new_pk_id number) is
1696 select
1697 PND.pl_dpnt_cvg_ctfn_id new_value
1698 from BEN_PL_DPNT_CVG_CTFN_F PND
1699 where
1700 nvl(PND.PL_ID,-999) = nvl(l_PL_ID,-999) and
1701 PND.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
1702 PND.business_group_id = c_business_group_id
1703 and PND.pl_dpnt_cvg_ctfn_id <> c_new_pk_id
1704 --TEMPIK
1705 and c_effective_start_date between effective_start_date
1706 and effective_end_date ;
1707 --END TEMPIK
1708 /* TEMPIK
1709 and exists ( select null
1710 from BEN_PL_DPNT_CVG_CTFN_F PND1
1711 where
1712 nvl(PND1.PL_ID,-999) = nvl(l_PL_ID,-999) and
1713 PND1.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
1714 PND1.business_group_id = c_business_group_id
1715 and PND1.effective_start_date <= c_effective_start_date )
1716 and exists ( select null
1717 from BEN_PL_DPNT_CVG_CTFN_F PND2
1718 where
1719 nvl(PND2.PL_ID,-999) = nvl(l_PL_ID,-999) and
1720 PND2.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
1721 PND2.business_group_id = c_business_group_id
1722 and PND2.effective_end_date >= c_effective_end_date )
1723 ;
1724 TEMPIK */
1725 --
1726 --UPD START
1727 --
1728 l_update boolean := false ;
1729 l_datetrack_mode varchar2(80) := hr_api.g_update;
1730 l_process_date date;
1731 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
1732 --
1733 --UPD END
1734 l_current_pk_id number := null ;
1735 l_prev_pk_id number := null ;
1736 l_first_rec boolean := true ;
1737 r_PND c_PND%rowtype;
1738 l_pl_dpnt_cvg_ctfn_id number ;
1739 l_object_version_number number ;
1740 l_effective_start_date date ;
1741 l_effective_end_date date ;
1742 l_prefix pqh_copy_entity_attribs.information1%type := null;
1743 l_suffix pqh_copy_entity_attribs.information1%type := null;
1744 l_new_value number(15);
1745 l_object_found_in_target boolean := false ;
1746 l_min_esd date;
1747 l_max_eed date;
1748 l_effective_date date;
1749 --TEMPIK
1750 l_dt_rec_found boolean ;
1751 --END TEMPIK
1752 --
1753 begin
1754 -- Initialization
1755 l_object_found_in_target := false ;
1756 -- End Initialization
1757 -- Derive the prefix - sufix
1758 if p_prefix_suffix_cd = 'PREFIX' then
1759 l_prefix := p_prefix_suffix_text ;
1760 elsif p_prefix_suffix_cd = 'SUFFIX' then
1761 l_suffix := p_prefix_suffix_text ;
1762 else
1763 l_prefix := null ;
1764 l_suffix := null ;
1765 end if ;
1766 -- End Prefix Sufix derivation
1767 for r_PND_unique in c_unique_PND('PND') loop
1768
1769 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
1770 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
1771 r_PND_unique.information3 >=
1772 ben_pd_copy_to_ben_one.g_copy_effective_date)
1773 ) then
1774
1775 --
1776 hr_utility.set_location(' r_PND_unique.table_route_id '||r_PND_unique.table_route_id,10);
1777 hr_utility.set_location(' r_PND_unique.information1 '||r_PND_unique.information1,10);
1778 hr_utility.set_location( 'r_PND_unique.information2 '||r_PND_unique.information2,10);
1779 hr_utility.set_location( 'r_PND_unique.information3 '||r_PND_unique.information3,10);
1780 -- If reuse objects flag is 'Y' then check for the object in the target business group
1781 -- if found insert the record into PLSql table and exit the loop else try create the
1782 -- object in the target business group
1783 --
1784 l_object_found_in_target := false ;
1785 --UPD START
1786 l_update := false;
1787 l_process_date := p_effective_date;
1788 --
1789 open c_PND(r_PND_unique.table_route_id,
1790 r_PND_unique.information1,
1791 r_PND_unique.information2,
1792 r_PND_unique.information3 ) ;
1793 --
1794 fetch c_PND into r_PND ;
1795 --
1796 close c_PND ;
1797 --
1798 l_dml_operation:= r_PND_unique.dml_operation ;
1799 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_PND.INFORMATION257,l_dml_operation);
1800 l_PL_ID := get_fk('PL_ID', r_PND.INFORMATION261,l_dml_operation);
1801 --
1802 if l_dml_operation = 'UPDATE' then
1803 --
1804 l_object_found_in_target := TRUE;
1805 --
1806 if l_process_date between r_PND_unique.information2 and r_PND_unique.information3 then
1807 l_update := true;
1808 if r_PND_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
1809 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_DPNT_CVG_CTFN_ID'
1810 then
1811 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_DPNT_CVG_CTFN_ID' ;
1812 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PND_unique.information1 ;
1813 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PND_unique.information1 ;
1814 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
1815 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PND_unique.table_route_id;
1816 --
1817 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
1818 --
1819 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1820 --
1821 --DOUBT log_data('PND',l_new_value,l_prefix || r_PND_unique.name|| l_suffix,'REUSED');
1822 --
1823 end if ;
1824 hr_utility.set_location( 'found record for update',10);
1825 --
1826 else
1827 --
1828 l_update := false;
1829 --
1830 end if;
1831 else
1832 --
1833 --UPD END
1834
1835 l_min_esd := null ;
1836 l_max_eed := null ;
1837 open c_PND_min_max_dates(r_PND_unique.table_route_id, r_PND_unique.information1 ) ;
1838 fetch c_PND_min_max_dates into l_min_esd,l_max_eed ;
1839 --
1840
1841 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
1842 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
1843 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
1844 end if;
1845 l_min_esd := greatest(l_min_esd,r_PND_unique.information2);
1846
1847 --
1848 l_DPNT_CVG_CTFN_TYP_CD := r_PND.information13 ;
1849 --
1850 if p_reuse_object_flag = 'Y' then
1851 if c_PND_min_max_dates%found then
1852 -- cursor to find the object
1853 open c_find_PND_in_target( l_min_esd,l_max_eed,
1854 p_target_business_group_id, nvl(l_pl_dpnt_cvg_ctfn_id, -999) ) ;
1855 fetch c_find_PND_in_target into l_new_value ;
1856 if c_find_PND_in_target%found then
1857 --
1858 --TEMPIK
1859 l_dt_rec_found := dt_api.check_min_max_dates
1860 (p_base_table_name => 'BEN_PL_DPNT_CVG_CTFN_F',
1861 p_base_key_column => 'PL_DPNT_CVG_CTFN_ID',
1862 p_base_key_value => l_new_value,
1863 p_from_date => l_min_esd,
1864 p_to_date => l_max_eed );
1865 if l_dt_rec_found THEN
1866 --END TEMPIK
1867 if r_PND_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
1868 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_DPNT_CVG_CTFN_ID' then
1869 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_DPNT_CVG_CTFN_ID' ;
1870 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PND_unique.information1 ;
1871 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
1872 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
1873 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PND_unique.table_route_id;
1874 --
1875 -- 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) ;
1876 --
1877 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1878 end if ;
1879 --
1880 l_object_found_in_target := true ;
1881 --TEMPIK
1882 end if; -- l_dt_rec_found
1883 --END TEMPIK
1884 end if;
1885 close c_find_PND_in_target ;
1886 --
1887 end if;
1888 end if ;
1889 --
1890 close c_PND_min_max_dates ;
1891 end if; --if p_dml_operation
1892 --
1893 if not l_object_found_in_target OR l_update then
1894
1895 --
1896 l_current_pk_id := r_PND.information1;
1897 --
1898 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
1899 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
1900 --
1901 if l_current_pk_id = l_prev_pk_id then
1902 --
1903 l_first_rec := false ;
1904 --
1905 else
1906 --
1907 l_first_rec := true ;
1908 --
1909 end if ;
1910 --
1911
1912 l_effective_date := r_PND.information2;
1913 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
1914 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
1915 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
1916 end if;
1917
1918 if l_first_rec and not l_update then
1919 -- Call Create routine.
1920 hr_utility.set_location(' BEN_PL_DPNT_CVG_CTFN_F CREATE_PLAN_DPNT_CVG_CTFN ',20);
1921 BEN_PLAN_DPNT_CVG_CTFN_API.CREATE_PLAN_DPNT_CVG_CTFN(
1922 --
1923 P_VALIDATE => false
1924 ,P_EFFECTIVE_DATE => l_effective_date
1925 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
1926 --
1927 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
1928 ,P_DPNT_CVG_CTFN_TYP_CD => r_PND.INFORMATION13
1929 ,P_LACK_CTFN_SSPND_ENRT_FLAG => r_PND.INFORMATION12
1930 ,P_PFD_FLAG => r_PND.INFORMATION11
1931 ,P_PL_DPNT_CVG_CTFN_ID => l_pl_dpnt_cvg_ctfn_id
1932 ,P_PL_ID => l_PL_ID
1933 ,P_PND_ATTRIBUTE1 => r_PND.INFORMATION111
1934 ,P_PND_ATTRIBUTE10 => r_PND.INFORMATION120
1935 ,P_PND_ATTRIBUTE11 => r_PND.INFORMATION121
1936 ,P_PND_ATTRIBUTE12 => r_PND.INFORMATION122
1937 ,P_PND_ATTRIBUTE13 => r_PND.INFORMATION123
1938 ,P_PND_ATTRIBUTE14 => r_PND.INFORMATION124
1939 ,P_PND_ATTRIBUTE15 => r_PND.INFORMATION125
1940 ,P_PND_ATTRIBUTE16 => r_PND.INFORMATION126
1941 ,P_PND_ATTRIBUTE17 => r_PND.INFORMATION127
1942 ,P_PND_ATTRIBUTE18 => r_PND.INFORMATION128
1943 ,P_PND_ATTRIBUTE19 => r_PND.INFORMATION129
1944 ,P_PND_ATTRIBUTE2 => r_PND.INFORMATION112
1945 ,P_PND_ATTRIBUTE20 => r_PND.INFORMATION130
1946 ,P_PND_ATTRIBUTE21 => r_PND.INFORMATION131
1947 ,P_PND_ATTRIBUTE22 => r_PND.INFORMATION132
1948 ,P_PND_ATTRIBUTE23 => r_PND.INFORMATION133
1949 ,P_PND_ATTRIBUTE24 => r_PND.INFORMATION134
1950 ,P_PND_ATTRIBUTE25 => r_PND.INFORMATION135
1951 ,P_PND_ATTRIBUTE26 => r_PND.INFORMATION136
1952 ,P_PND_ATTRIBUTE27 => r_PND.INFORMATION137
1953 ,P_PND_ATTRIBUTE28 => r_PND.INFORMATION138
1954 ,P_PND_ATTRIBUTE29 => r_PND.INFORMATION139
1955 ,P_PND_ATTRIBUTE3 => r_PND.INFORMATION113
1956 ,P_PND_ATTRIBUTE30 => r_PND.INFORMATION140
1957 ,P_PND_ATTRIBUTE4 => r_PND.INFORMATION114
1958 ,P_PND_ATTRIBUTE5 => r_PND.INFORMATION115
1959 ,P_PND_ATTRIBUTE6 => r_PND.INFORMATION116
1960 ,P_PND_ATTRIBUTE7 => r_PND.INFORMATION117
1961 ,P_PND_ATTRIBUTE8 => r_PND.INFORMATION118
1962 ,P_PND_ATTRIBUTE9 => r_PND.INFORMATION119
1963 ,P_PND_ATTRIBUTE_CATEGORY => r_PND.INFORMATION110
1964 ,P_RLSHP_TYP_CD => r_PND.INFORMATION15
1965 ,P_RQD_FLAG => r_PND.INFORMATION14
1966 --
1967 ,P_EFFECTIVE_START_DATE => l_effective_start_date
1968 ,P_EFFECTIVE_END_DATE => l_effective_end_date
1969 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
1970 );
1971 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1972 -- Update all relevent cer records with new pk_id
1973 hr_utility.set_location('Before plsql table ',222);
1974 hr_utility.set_location('new_value id '||l_pl_dpnt_cvg_ctfn_id,222);
1975 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_DPNT_CVG_CTFN_ID' ;
1976 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PND.information1 ;
1977 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PL_DPNT_CVG_CTFN_ID ;
1978 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
1979 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PND_unique.table_route_id;
1980 hr_utility.set_location('After plsql table ',222);
1981 --
1982 -- 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 ) ;
1983 --
1984 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
1985 --
1986 else
1987 --
1988 -- Call Update routine for the pk_id created in prev run .
1989 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1990 hr_utility.set_location(' BEN_PL_DPNT_CVG_CTFN_F UPDATE_PLAN_DPNT_CVG_CTFN ',30);
1991 --UPD START
1992 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
1993 --
1994 if l_update then
1995 --
1996 l_datetrack_mode := r_PND.datetrack_mode ;
1997 --
1998 get_dt_modes(
1999 p_effective_date => l_process_date,
2000 p_effective_end_date => r_PND.information3,
2001 p_effective_start_date => r_PND.information2,
2002 p_dml_operation => r_PND.dml_operation,
2003 p_datetrack_mode => l_datetrack_mode );
2004 -- p_update => l_update
2005 --
2006 l_effective_date := l_process_date;
2007 l_PL_DPNT_CVG_CTFN_ID := r_PND.information1;
2008 l_object_version_number := r_PND.information265;
2009 --
2010 end if;
2011 --
2012 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
2013 --
2014 IF l_update OR l_dml_operation <> 'UPDATE' THEN
2015 --UPD END
2016
2017 BEN_PLAN_DPNT_CVG_CTFN_API.UPDATE_PLAN_DPNT_CVG_CTFN(
2018 --
2019 P_VALIDATE => false
2020 ,P_EFFECTIVE_DATE => l_effective_date
2021 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2022 --
2023 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
2024 ,P_DPNT_CVG_CTFN_TYP_CD => r_PND.INFORMATION13
2025 ,P_LACK_CTFN_SSPND_ENRT_FLAG => r_PND.INFORMATION12
2026 ,P_PFD_FLAG => r_PND.INFORMATION11
2027 ,P_PL_DPNT_CVG_CTFN_ID => l_pl_dpnt_cvg_ctfn_id
2028 ,P_PL_ID => l_PL_ID
2029 ,P_PND_ATTRIBUTE1 => r_PND.INFORMATION111
2030 ,P_PND_ATTRIBUTE10 => r_PND.INFORMATION120
2031 ,P_PND_ATTRIBUTE11 => r_PND.INFORMATION121
2032 ,P_PND_ATTRIBUTE12 => r_PND.INFORMATION122
2033 ,P_PND_ATTRIBUTE13 => r_PND.INFORMATION123
2034 ,P_PND_ATTRIBUTE14 => r_PND.INFORMATION124
2035 ,P_PND_ATTRIBUTE15 => r_PND.INFORMATION125
2036 ,P_PND_ATTRIBUTE16 => r_PND.INFORMATION126
2037 ,P_PND_ATTRIBUTE17 => r_PND.INFORMATION127
2038 ,P_PND_ATTRIBUTE18 => r_PND.INFORMATION128
2039 ,P_PND_ATTRIBUTE19 => r_PND.INFORMATION129
2040 ,P_PND_ATTRIBUTE2 => r_PND.INFORMATION112
2041 ,P_PND_ATTRIBUTE20 => r_PND.INFORMATION130
2042 ,P_PND_ATTRIBUTE21 => r_PND.INFORMATION131
2043 ,P_PND_ATTRIBUTE22 => r_PND.INFORMATION132
2044 ,P_PND_ATTRIBUTE23 => r_PND.INFORMATION133
2045 ,P_PND_ATTRIBUTE24 => r_PND.INFORMATION134
2046 ,P_PND_ATTRIBUTE25 => r_PND.INFORMATION135
2047 ,P_PND_ATTRIBUTE26 => r_PND.INFORMATION136
2048 ,P_PND_ATTRIBUTE27 => r_PND.INFORMATION137
2049 ,P_PND_ATTRIBUTE28 => r_PND.INFORMATION138
2050 ,P_PND_ATTRIBUTE29 => r_PND.INFORMATION139
2051 ,P_PND_ATTRIBUTE3 => r_PND.INFORMATION113
2052 ,P_PND_ATTRIBUTE30 => r_PND.INFORMATION140
2053 ,P_PND_ATTRIBUTE4 => r_PND.INFORMATION114
2054 ,P_PND_ATTRIBUTE5 => r_PND.INFORMATION115
2055 ,P_PND_ATTRIBUTE6 => r_PND.INFORMATION116
2056 ,P_PND_ATTRIBUTE7 => r_PND.INFORMATION117
2057 ,P_PND_ATTRIBUTE8 => r_PND.INFORMATION118
2058 ,P_PND_ATTRIBUTE9 => r_PND.INFORMATION119
2059 ,P_PND_ATTRIBUTE_CATEGORY => r_PND.INFORMATION110
2060 ,P_RLSHP_TYP_CD => r_PND.INFORMATION15
2061 ,P_RQD_FLAG => r_PND.INFORMATION14
2062 --
2063 ,P_EFFECTIVE_START_DATE => l_effective_start_date
2064 ,P_EFFECTIVE_END_DATE => l_effective_end_date
2065 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
2066 ,P_DATETRACK_MODE => l_datetrack_mode
2067 );
2068 --
2069 end if; -- l_update
2070 end if;
2071 --
2072 -- Delete the row if it is end dated.
2073 --
2074 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
2075 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
2076 trunc(l_max_eed) = r_PND.information3) then
2077 --
2078 BEN_PLAN_DPNT_CVG_CTFN_API.delete_PLAN_DPNT_CVG_CTFN(
2079 --
2080 p_validate => false
2081 ,p_pl_dpnt_cvg_ctfn_id => l_pl_dpnt_cvg_ctfn_id
2082 ,p_effective_start_date => l_effective_start_date
2083 ,p_effective_end_date => l_effective_end_date
2084 ,p_object_version_number => l_object_version_number
2085 ,p_effective_date => l_max_eed
2086 ,p_datetrack_mode => hr_api.g_delete
2087 --
2088 );
2089 --
2090 end if;
2091 --
2092 l_prev_pk_id := l_current_pk_id ;
2093 --
2094 end if;
2095 --
2096 end if;
2097 --
2098 end loop;
2099 --
2100 exception when others then
2101 --
2102 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PND',r_pnd.information5 );
2103 --
2104 end create_PND_rows;
2105
2106 --
2107 ---------------------------------------------------------------
2108 ----------------------< create_LPE_rows >-----------------------
2109 ---------------------------------------------------------------
2110 --
2111 procedure create_LPE_rows
2112 (
2113 p_validate in number default 0
2114 ,p_copy_entity_txn_id in number
2115 ,p_effective_date in date
2116 ,p_prefix_suffix_text in varchar2 default null
2117 ,p_reuse_object_flag in varchar2 default null
2118 ,p_target_business_group_id in varchar2 default null
2119 ,p_prefix_suffix_cd in varchar2 default null
2120 ) is
2121 --
2122 l_AUTO_ENRT_MTHD_RL number;
2123 l_DFLT_ENRT_RL number;
2124 l_ENRT_RL number;
2125 l_LER_ID number;
2126 l_PL_ID number;
2127 cursor c_unique_LPE(l_table_alias varchar2) is
2128 select distinct cpe.information1,
2129 cpe.information2,
2130 cpe.information3,
2131 cpe.table_route_id
2132 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe, pqh_table_route tr
2133 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2134 and cpe.table_route_id = tr.table_route_id
2135 -- and tr.where_clause = l_BEN_LER_CHG_PL_NIP_ENRT_F
2136 and tr.table_alias = l_table_alias
2137 and cpe.number_of_copies = 1 --ADDITION
2138 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
2139 order by information1, information2; --added for bug: 5151945
2140 --
2141 --
2142 cursor c_LPE_min_max_dates(c_table_route_id number,
2143 c_information1 number) is
2144 select
2145 min(cpe.information2) min_esd,
2146 max(cpe.information3) min_eed
2147 from ben_copy_entity_results cpe
2148 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2149 and cpe.table_route_id = c_table_route_id
2150 and cpe.information1 = c_information1 ;
2151 --
2152 cursor c_LPE(c_table_route_id number,
2153 c_information1 number,
2154 c_information2 date,
2155 c_information3 date ) is
2156 select
2157 cpe.*
2158 from ben_copy_entity_results cpe
2159 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2160 and cpe.table_route_id = c_table_route_id
2161 and cpe.information1 = c_information1
2162 and cpe.information2 = c_information2
2163 and cpe.information3 = c_information3
2164 and rownum = 1 ;
2165 -- Date Track target record
2166 cursor c_find_LPE_in_target(
2167 c_effective_start_date date,
2168 c_effective_end_date date,
2169 c_business_group_id number,
2170 c_new_pk_id number) is
2171 select
2172 LPE.ler_chg_pl_nip_enrt_id new_value
2173 from BEN_LER_CHG_PL_NIP_ENRT_F LPE
2174 where
2175 nvl(LPE.LER_ID,-999) = nvl(l_LER_ID,-999) and
2176 nvl(LPE.PL_ID,-999) = nvl(l_PL_ID,-999) and
2177 LPE.business_group_id = c_business_group_id
2178 and LPE.ler_chg_pl_nip_enrt_id <> c_new_pk_id
2179 --TEMPIK
2180 and c_effective_start_date between effective_start_date
2181 and effective_end_date ;
2182 --END TEMPIK
2183 /*TEMPIK
2184 and exists ( select null
2185 from BEN_LER_CHG_PL_NIP_ENRT_F LPE1
2186 where
2187 nvl(LPE1.LER_ID,-999) = nvl(l_LER_ID,-999) and
2188 nvl(LPE1.PL_ID,-999) = nvl(l_PL_ID,-999) and
2189 LPE1.business_group_id = c_business_group_id
2190 and LPE1.effective_start_date <= c_effective_start_date )
2191 and exists ( select null
2192 from BEN_LER_CHG_PL_NIP_ENRT_F LPE2
2193 where
2194 nvl(LPE2.LER_ID,-999) = nvl(l_LER_ID,-999) and
2195 nvl(LPE2.PL_ID,-999) = nvl(l_PL_ID,-999) and
2196 LPE2.business_group_id = c_business_group_id
2197 and LPE2.effective_end_date >= c_effective_end_date )
2198 ;
2199 TEMPIK */
2200 --TEMPIK
2201 l_dt_rec_found boolean ;
2202 --END TEMPIK
2203 --
2204 --UPD START
2205 --
2206 l_update boolean := false ;
2207 l_datetrack_mode varchar2(80) := hr_api.g_update;
2208 l_process_date date;
2209 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
2210 --
2211 --UPD END
2212
2213 l_current_pk_id number := null ;
2214 l_prev_pk_id number := null ;
2215 l_first_rec boolean := true ;
2216 r_LPE c_LPE%rowtype;
2217 l_ler_chg_pl_nip_enrt_id number ;
2218 l_object_version_number number ;
2219 l_effective_start_date date ;
2220 l_effective_end_date date ;
2221 l_prefix pqh_copy_entity_attribs.information1%type := null;
2222 l_suffix pqh_copy_entity_attribs.information1%type := null;
2223 l_new_value number(15);
2224 l_object_found_in_target boolean := false ;
2225 l_min_esd date;
2226 l_max_eed date;
2227 l_effective_date date;
2228 --
2229 begin
2230 -- Initialization
2231 l_object_found_in_target := false ;
2232 -- End Initialization
2233 -- Derive the prefix - sufix
2234 if p_prefix_suffix_cd = 'PREFIX' then
2235 l_prefix := p_prefix_suffix_text ;
2236 elsif p_prefix_suffix_cd = 'SUFFIX' then
2237 l_suffix := p_prefix_suffix_text ;
2238 else
2239 l_prefix := null ;
2240 l_suffix := null ;
2241 end if ;
2242 -- End Prefix Sufix derivation
2243 for r_LPE_unique in c_unique_LPE('LPE') loop
2244
2245 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
2246 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2247 r_LPE_unique.information3 >=
2248 ben_pd_copy_to_ben_one.g_copy_effective_date)
2249 ) then
2250
2251 --
2252 hr_utility.set_location(' r_LPE_unique.table_route_id '||r_LPE_unique.table_route_id,10);
2253 hr_utility.set_location(' r_LPE_unique.information1 '||r_LPE_unique.information1,10);
2254 hr_utility.set_location( 'r_LPE_unique.information2 '||r_LPE_unique.information2,10);
2255 hr_utility.set_location( 'r_LPE_unique.information3 '||r_LPE_unique.information3,10);
2256 -- If reuse objects flag is 'Y' then check for the object in the target business group
2257 -- if found insert the record into PLSql table and exit the loop else try create the
2258 -- object in the target business group
2259 --
2260 l_object_found_in_target := false ;
2261 --UPD START
2262
2263 open c_LPE(r_LPE_unique.table_route_id,
2264 r_LPE_unique.information1,
2265 r_LPE_unique.information2,
2266 r_LPE_unique.information3 ) ;
2267 --
2268 fetch c_LPE into r_LPE ;
2269 --
2270 close c_LPE ;
2271 --
2272 l_dml_operation:= r_LPE_unique.dml_operation ;
2273 l_AUTO_ENRT_MTHD_RL := get_fk('FORMULA_ID', r_LPE.INFORMATION258,l_dml_operation);
2274 l_DFLT_ENRT_RL := get_fk('FORMULA_ID', r_LPE.INFORMATION263,l_dml_operation);
2275 l_ENRT_RL := get_fk('FORMULA_ID', r_LPE.INFORMATION264,l_dml_operation);
2276 l_LER_ID := get_fk('LER_ID', r_LPE.INFORMATION257,l_dml_operation);
2277 l_PL_ID := get_fk('PL_ID', r_LPE.INFORMATION261,l_dml_operation);
2278 --
2279
2280 l_update := false;
2281 l_process_date := p_effective_date;
2282 --
2283 if l_dml_operation = 'UPDATE' then
2284 --
2285 l_object_found_in_target := TRUE;
2286 --
2287 if l_process_date between r_LPE_unique.information2 and r_LPE_unique.information3 then
2288 l_update := true;
2289 if r_LPE_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
2290 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_PL_NIP_ENRT_ID'
2291 then
2292 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_PL_NIP_ENRT_ID' ;
2293 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LPE_unique.information1 ;
2294 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LPE_unique.information1 ;
2295 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
2296 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LPE_unique.table_route_id;
2297 --
2298 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
2299 --
2300 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
2301 --
2302 --DOUBT log_data('LPE',l_new_value,l_prefix || r_LPE_unique.name|| l_suffix,'REUSED');
2303 --
2304 end if ;
2305 hr_utility.set_location( 'found record for update',10);
2306 --
2307 else
2308 --
2309 l_update := false;
2310 --
2311 end if;
2312 else
2313 --
2314 --UPD END
2315 l_min_esd := null ;
2316 l_max_eed := null ;
2317 open c_LPE_min_max_dates(r_LPE_unique.table_route_id, r_LPE_unique.information1 ) ;
2318 fetch c_LPE_min_max_dates into l_min_esd,l_max_eed ;
2319 --
2320
2321 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2322 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
2323 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
2324 end if;
2325 l_min_esd := greatest(l_min_esd,r_LPE_unique.information2);
2326
2327 --
2328 if p_reuse_object_flag = 'Y' then
2329 if c_LPE_min_max_dates%found then
2330 -- cursor to find the object
2331 open c_find_LPE_in_target( l_min_esd,l_max_eed,
2332 p_target_business_group_id, nvl(l_ler_chg_pl_nip_enrt_id, -999) ) ;
2333 fetch c_find_LPE_in_target into l_new_value ;
2334 if c_find_LPE_in_target%found then
2335 --
2336 --TEMPIK
2337 l_dt_rec_found := dt_api.check_min_max_dates
2338 (p_base_table_name => 'BEN_LER_CHG_PL_NIP_ENRT_F',
2339 p_base_key_column => 'LER_CHG_PL_NIP_ENRT_ID',
2340 p_base_key_value => l_new_value,
2341 p_from_date => l_min_esd,
2342 p_to_date => l_max_eed );
2343 if l_dt_rec_found THEN
2344 --END TEMPIK
2345 if r_LPE_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
2346 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_PL_NIP_ENRT_ID' then
2347 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_PL_NIP_ENRT_ID' ;
2348 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LPE_unique.information1 ;
2349 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
2350 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
2351 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LPE_unique.table_route_id;
2352 --
2353 -- 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) ;
2354 --
2355 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
2356 end if ;
2357 --
2358 l_object_found_in_target := true ;
2359 --TEMPIK
2360 end if; -- l_dt_rec_found
2361 --END TEMPIK
2362 end if;
2363 close c_find_LPE_in_target ;
2364 --
2365 end if;
2366 end if ;
2367 --
2368 close c_LPE_min_max_dates ;
2369 end if; --if p_dml_operation
2370 --
2371 if not l_object_found_in_target OR l_update then
2372 --
2373 l_current_pk_id := r_LPE.information1;
2374 --
2375 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
2376 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
2377 --
2378 if l_current_pk_id = l_prev_pk_id then
2379 --
2380 l_first_rec := false ;
2381 --
2382 else
2383 --
2384 l_first_rec := true ;
2385 --
2386 end if ;
2387 --
2388
2389 l_effective_date := r_LPE.information2;
2390 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2391 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
2392 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
2393 end if;
2394
2395 if l_first_rec and not l_update then
2396 -- Call Create routine.
2397 hr_utility.set_location(' BEN_LER_CHG_PL_NIP_ENRT_F CREATE_LER_CHG_PL_NIP_ENRT ',20);
2398 BEN_LER_CHG_PL_NIP_ENRT_API.CREATE_LER_CHG_PL_NIP_ENRT(
2399 --
2400 P_VALIDATE => false
2401 ,P_EFFECTIVE_DATE => l_effective_date
2402 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2403 --
2404 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
2405 ,P_CRNT_ENRT_PRCLDS_CHG_FLAG => r_LPE.INFORMATION12
2406 ,P_DFLT_ENRT_CD => r_LPE.INFORMATION16
2407 ,P_DFLT_ENRT_RL => l_DFLT_ENRT_RL
2408 ,P_DFLT_FLAG => r_LPE.INFORMATION13
2409 ,P_ENRT_CD => r_LPE.INFORMATION17
2410 ,P_ENRT_MTHD_CD => r_LPE.INFORMATION15
2411 ,P_ENRT_RL => l_ENRT_RL
2412 ,P_LER_CHG_PL_NIP_ENRT_ID => l_ler_chg_pl_nip_enrt_id
2413 ,P_LER_ID => l_LER_ID
2414 ,P_LPE_ATTRIBUTE1 => r_LPE.INFORMATION111
2415 ,P_LPE_ATTRIBUTE10 => r_LPE.INFORMATION120
2416 ,P_LPE_ATTRIBUTE11 => r_LPE.INFORMATION121
2417 ,P_LPE_ATTRIBUTE12 => r_LPE.INFORMATION122
2418 ,P_LPE_ATTRIBUTE13 => r_LPE.INFORMATION123
2419 ,P_LPE_ATTRIBUTE14 => r_LPE.INFORMATION124
2420 ,P_LPE_ATTRIBUTE15 => r_LPE.INFORMATION125
2421 ,P_LPE_ATTRIBUTE16 => r_LPE.INFORMATION126
2422 ,P_LPE_ATTRIBUTE17 => r_LPE.INFORMATION127
2423 ,P_LPE_ATTRIBUTE18 => r_LPE.INFORMATION128
2424 ,P_LPE_ATTRIBUTE19 => r_LPE.INFORMATION129
2425 ,P_LPE_ATTRIBUTE2 => r_LPE.INFORMATION112
2426 ,P_LPE_ATTRIBUTE20 => r_LPE.INFORMATION130
2427 ,P_LPE_ATTRIBUTE21 => r_LPE.INFORMATION131
2428 ,P_LPE_ATTRIBUTE22 => r_LPE.INFORMATION132
2429 ,P_LPE_ATTRIBUTE23 => r_LPE.INFORMATION133
2430 ,P_LPE_ATTRIBUTE24 => r_LPE.INFORMATION134
2431 ,P_LPE_ATTRIBUTE25 => r_LPE.INFORMATION135
2432 ,P_LPE_ATTRIBUTE26 => r_LPE.INFORMATION136
2433 ,P_LPE_ATTRIBUTE27 => r_LPE.INFORMATION137
2434 ,P_LPE_ATTRIBUTE28 => r_LPE.INFORMATION138
2435 ,P_LPE_ATTRIBUTE29 => r_LPE.INFORMATION139
2436 ,P_LPE_ATTRIBUTE3 => r_LPE.INFORMATION113
2437 ,P_LPE_ATTRIBUTE30 => r_LPE.INFORMATION140
2438 ,P_LPE_ATTRIBUTE4 => r_LPE.INFORMATION114
2439 ,P_LPE_ATTRIBUTE5 => r_LPE.INFORMATION115
2440 ,P_LPE_ATTRIBUTE6 => r_LPE.INFORMATION116
2441 ,P_LPE_ATTRIBUTE7 => r_LPE.INFORMATION117
2442 ,P_LPE_ATTRIBUTE8 => r_LPE.INFORMATION118
2443 ,P_LPE_ATTRIBUTE9 => r_LPE.INFORMATION119
2444 ,P_LPE_ATTRIBUTE_CATEGORY => r_LPE.INFORMATION110
2445 ,P_PL_ID => l_PL_ID
2446 ,P_STL_ELIG_CANT_CHG_FLAG => r_LPE.INFORMATION14
2447 ,P_TCO_CHG_ENRT_CD => r_LPE.INFORMATION11
2448 --
2449 ,P_EFFECTIVE_START_DATE => l_effective_start_date
2450 ,P_EFFECTIVE_END_DATE => l_effective_end_date
2451 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
2452 );
2453 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
2454 -- Update all relevent cer records with new pk_id
2455 hr_utility.set_location('Before plsql table ',222);
2456 hr_utility.set_location('new_value id '||l_ler_chg_pl_nip_enrt_id,222);
2457 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_PL_NIP_ENRT_ID' ;
2458 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LPE.information1 ;
2459 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LER_CHG_PL_NIP_ENRT_ID ;
2460 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
2461 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LPE_unique.table_route_id;
2462 hr_utility.set_location('After plsql table ',222);
2463 --
2464 -- 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 ) ;
2465 --
2466 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
2467 --
2468 else
2469 --
2470 -- Call Update routine for the pk_id created in prev run .
2471 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
2472 hr_utility.set_location(' BEN_LER_CHG_PL_NIP_ENRT_F UPDATE_LER_CHG_PL_NIP_ENRT ',30);
2473 --UPD START
2474 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
2475 --
2476 if l_update then
2477 --
2478 l_datetrack_mode := r_LPE.datetrack_mode ;
2479 --
2480 get_dt_modes(
2481 p_effective_date => l_process_date,
2482 p_effective_end_date => r_LPE.information3,
2483 p_effective_start_date => r_LPE.information2,
2484 p_dml_operation => r_LPE.dml_operation,
2485 p_datetrack_mode => l_datetrack_mode );
2486 -- p_update => l_update
2487 --
2488 l_effective_date := l_process_date;
2489 l_LER_CHG_PL_NIP_ENRT_ID := r_LPE.information1;
2490 l_object_version_number := r_LPE.information265;
2491 --
2492 end if;
2493 --
2494 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
2495 --
2496 IF l_update OR l_dml_operation <> 'UPDATE' THEN
2497 --UPD END
2498
2499 BEN_LER_CHG_PL_NIP_ENRT_API.UPDATE_LER_CHG_PL_NIP_ENRT(
2500 --
2501 P_VALIDATE => false
2502 ,P_EFFECTIVE_DATE => l_effective_date
2503 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2504 --
2505 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
2506 ,P_CRNT_ENRT_PRCLDS_CHG_FLAG => r_LPE.INFORMATION12
2507 ,P_DFLT_ENRT_CD => r_LPE.INFORMATION16
2508 ,P_DFLT_ENRT_RL => l_DFLT_ENRT_RL
2509 ,P_DFLT_FLAG => r_LPE.INFORMATION13
2510 ,P_ENRT_CD => r_LPE.INFORMATION17
2511 ,P_ENRT_MTHD_CD => r_LPE.INFORMATION15
2512 ,P_ENRT_RL => l_ENRT_RL
2513 ,P_LER_CHG_PL_NIP_ENRT_ID => l_ler_chg_pl_nip_enrt_id
2514 ,P_LER_ID => l_LER_ID
2515 ,P_LPE_ATTRIBUTE1 => r_LPE.INFORMATION111
2516 ,P_LPE_ATTRIBUTE10 => r_LPE.INFORMATION120
2517 ,P_LPE_ATTRIBUTE11 => r_LPE.INFORMATION121
2518 ,P_LPE_ATTRIBUTE12 => r_LPE.INFORMATION122
2519 ,P_LPE_ATTRIBUTE13 => r_LPE.INFORMATION123
2520 ,P_LPE_ATTRIBUTE14 => r_LPE.INFORMATION124
2521 ,P_LPE_ATTRIBUTE15 => r_LPE.INFORMATION125
2522 ,P_LPE_ATTRIBUTE16 => r_LPE.INFORMATION126
2523 ,P_LPE_ATTRIBUTE17 => r_LPE.INFORMATION127
2524 ,P_LPE_ATTRIBUTE18 => r_LPE.INFORMATION128
2525 ,P_LPE_ATTRIBUTE19 => r_LPE.INFORMATION129
2526 ,P_LPE_ATTRIBUTE2 => r_LPE.INFORMATION112
2527 ,P_LPE_ATTRIBUTE20 => r_LPE.INFORMATION130
2528 ,P_LPE_ATTRIBUTE21 => r_LPE.INFORMATION131
2529 ,P_LPE_ATTRIBUTE22 => r_LPE.INFORMATION132
2530 ,P_LPE_ATTRIBUTE23 => r_LPE.INFORMATION133
2531 ,P_LPE_ATTRIBUTE24 => r_LPE.INFORMATION134
2532 ,P_LPE_ATTRIBUTE25 => r_LPE.INFORMATION135
2533 ,P_LPE_ATTRIBUTE26 => r_LPE.INFORMATION136
2534 ,P_LPE_ATTRIBUTE27 => r_LPE.INFORMATION137
2535 ,P_LPE_ATTRIBUTE28 => r_LPE.INFORMATION138
2536 ,P_LPE_ATTRIBUTE29 => r_LPE.INFORMATION139
2537 ,P_LPE_ATTRIBUTE3 => r_LPE.INFORMATION113
2538 ,P_LPE_ATTRIBUTE30 => r_LPE.INFORMATION140
2539 ,P_LPE_ATTRIBUTE4 => r_LPE.INFORMATION114
2540 ,P_LPE_ATTRIBUTE5 => r_LPE.INFORMATION115
2541 ,P_LPE_ATTRIBUTE6 => r_LPE.INFORMATION116
2542 ,P_LPE_ATTRIBUTE7 => r_LPE.INFORMATION117
2543 ,P_LPE_ATTRIBUTE8 => r_LPE.INFORMATION118
2544 ,P_LPE_ATTRIBUTE9 => r_LPE.INFORMATION119
2545 ,P_LPE_ATTRIBUTE_CATEGORY => r_LPE.INFORMATION110
2546 ,P_PL_ID => l_PL_ID
2547 ,P_STL_ELIG_CANT_CHG_FLAG => r_LPE.INFORMATION14
2548 ,P_TCO_CHG_ENRT_CD => r_LPE.INFORMATION11
2549 --
2550 ,P_EFFECTIVE_START_DATE => l_effective_start_date
2551 ,P_EFFECTIVE_END_DATE => l_effective_end_date
2552 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
2553 ,P_DATETRACK_MODE => l_datetrack_mode
2554 );
2555 --
2556 end if; -- l_update
2557
2558 end if;
2559 --
2560 -- Delete the row if it is end dated.
2561 --
2562 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
2563 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
2564 trunc(l_max_eed) = r_LPE.information3) then
2565 --
2566 BEN_LER_CHG_PL_NIP_ENRT_API.delete_LER_CHG_PL_NIP_ENRT(
2567 --
2568 p_validate => false
2569 ,p_ler_chg_pl_nip_enrt_id => l_ler_chg_pl_nip_enrt_id
2570 ,p_effective_start_date => l_effective_start_date
2571 ,p_effective_end_date => l_effective_end_date
2572 ,p_object_version_number => l_object_version_number
2573 ,p_effective_date => l_max_eed
2574 ,p_datetrack_mode => hr_api.g_delete
2575 --
2576 );
2577 --
2578 end if;
2579 --
2580 l_prev_pk_id := l_current_pk_id ;
2581 --
2582 end if;
2583 --
2584 end if;
2585 --
2586 end loop;
2587 --
2588 exception when others then
2589 --
2590 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LPE',r_lpe.information5 );
2591 --
2592 end create_LPE_rows;
2593
2594 --
2595 ---------------------------------------------------------------
2596 ----------------------< create_LOP_rows >-----------------------
2597 ---------------------------------------------------------------
2598 --
2599 procedure create_LOP_rows
2600 (
2601 p_validate in number default 0
2602 ,p_copy_entity_txn_id in number
2603 ,p_effective_date in date
2604 ,p_prefix_suffix_text in varchar2 default null
2605 ,p_reuse_object_flag in varchar2 default null
2606 ,p_target_business_group_id in varchar2 default null
2607 ,p_prefix_suffix_cd in varchar2 default null
2608 ) is
2609 --
2610 l_AUTO_ENRT_MTHD_RL number;
2611 l_DFLT_ENRT_RL number;
2612 l_ENRT_RL number;
2613 l_LER_ID number;
2614 l_OIPL_ID number;
2615 cursor c_unique_LOP(l_table_alias varchar2) is
2616 select distinct cpe.information1,
2617 cpe.information2,
2618 cpe.information3,
2619 cpe.table_route_id
2620 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe, pqh_table_route tr
2621 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2622 and cpe.table_route_id = tr.table_route_id
2623 -- and tr.where_clause = l_BEN_LER_CHG_OIPL_ENRT_F
2624 and tr.table_alias = l_table_alias
2625 and cpe.number_of_copies = 1 -- ADDITION
2626 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
2627 order by information1, information2; --added for bug: 5151945
2628 --
2629 --
2630 cursor c_LOP_min_max_dates(c_table_route_id number,
2631 c_information1 number) is
2632 select
2633 min(cpe.information2) min_esd,
2634 max(cpe.information3) min_eed
2635 from ben_copy_entity_results cpe
2636 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2637 and cpe.table_route_id = c_table_route_id
2638 and cpe.information1 = c_information1 ;
2639 --
2640 cursor c_LOP(c_table_route_id number,
2641 c_information1 number,
2642 c_information2 date,
2643 c_information3 date ) is
2644 select
2645 cpe.*
2646 from ben_copy_entity_results cpe
2647 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2648 and cpe.table_route_id = c_table_route_id
2649 and cpe.information1 = c_information1
2650 and cpe.information2 = c_information2
2651 and cpe.information3 = c_information3
2652 and rownum = 1 ;
2653 -- Date Track target record
2654 cursor c_find_LOP_in_target(
2655 c_effective_start_date date,
2656 c_effective_end_date date,
2657 c_business_group_id number,
2658 c_new_pk_id number) is
2659 select
2660 LOP.ler_chg_oipl_enrt_id new_value
2661 from BEN_LER_CHG_OIPL_ENRT_F LOP
2662 where
2663 LOP.LER_ID = l_LER_ID and
2664 LOP.OIPL_ID = l_OIPL_ID and
2665 LOP.business_group_id = c_business_group_id
2666 and LOP.ler_chg_oipl_enrt_id <> c_new_pk_id
2667 --TEMPIK
2668 and c_effective_start_date between effective_start_date
2669 and effective_end_date ;
2670 --END TEMPIK
2671 /*TEMPIK
2672 and exists ( select null
2673 from BEN_LER_CHG_OIPL_ENRT_F LOP1
2674 where
2675 LOP1.LER_ID = l_LER_ID and
2676 LOP1.OIPL_ID =l_OIPL_ID and
2677 LOP1.business_group_id = c_business_group_id
2678 and LOP1.effective_start_date <= c_effective_start_date )
2679 and exists ( select null
2680 from BEN_LER_CHG_OIPL_ENRT_F LOP2
2681 where
2682 LOP2.LER_ID = l_LER_ID and
2683 LOP2.OIPL_ID = l_OIPL_ID and
2684 LOP2.business_group_id = c_business_group_id
2685 and LOP2.effective_end_date >= c_effective_end_date )
2686 ;
2687 TEMPIK */
2688 --TEMPIK
2689 l_dt_rec_found boolean ;
2690 --END TEMPIK
2691 --
2692 --UPD START
2693 --
2694 l_update boolean := false ;
2695 l_datetrack_mode varchar2(80) := hr_api.g_update;
2696 l_process_date date;
2697 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
2698 --
2699 --UPD END
2700
2701 l_current_pk_id number := null ;
2702 l_prev_pk_id number := null ;
2703 l_first_rec boolean := true ;
2704 r_LOP c_LOP%rowtype;
2705 l_ler_chg_oipl_enrt_id number ;
2706 l_object_version_number number ;
2707 l_effective_start_date date ;
2708 l_effective_end_date date ;
2709 l_prefix pqh_copy_entity_attribs.information1%type := null;
2710 l_suffix pqh_copy_entity_attribs.information1%type := null;
2711 l_new_value number(15);
2712 l_object_found_in_target boolean := false ;
2713 l_min_esd date;
2714 l_max_eed date;
2715 l_effective_date date;
2716 --
2717 begin
2718 -- Initialization
2719 l_object_found_in_target := false ;
2720 -- End Initialization
2721 -- Derive the prefix - sufix
2722 if p_prefix_suffix_cd = 'PREFIX' then
2723 l_prefix := p_prefix_suffix_text ;
2724 elsif p_prefix_suffix_cd = 'SUFFIX' then
2725 l_suffix := p_prefix_suffix_text ;
2726 else
2727 l_prefix := null ;
2728 l_suffix := null ;
2729 end if ;
2730 -- End Prefix Sufix derivation
2731 for r_LOP_unique in c_unique_LOP('LOP') loop
2732
2733 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
2734 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2735 r_LOP_unique.information3 >=
2736 ben_pd_copy_to_ben_one.g_copy_effective_date)
2737 ) then
2738 --
2739 hr_utility.set_location(' r_LOP_unique.table_route_id '||r_LOP_unique.table_route_id,10);
2740 hr_utility.set_location(' r_LOP_unique.information1 '||r_LOP_unique.information1,10);
2741 hr_utility.set_location( 'r_LOP_unique.information2 '||r_LOP_unique.information2,10);
2742 hr_utility.set_location( 'r_LOP_unique.information3 '||r_LOP_unique.information3,10);
2743 -- If reuse objects flag is 'Y' then check for the object in the target business group
2744 -- if found insert the record into PLSql table and exit the loop else try create the
2745 -- object in the target business group
2746 --
2747 l_object_found_in_target := false ;
2748 --UPD START
2749 open c_LOP(r_LOP_unique.table_route_id,
2750 r_LOP_unique.information1,
2751 r_LOP_unique.information2,
2752 r_LOP_unique.information3 ) ;
2753 --
2754 fetch c_LOP into r_LOP ;
2755 --
2756 close c_LOP ;
2757 --
2758 l_dml_operation:= r_LOP_unique.dml_operation ;
2759 l_AUTO_ENRT_MTHD_RL := get_fk('FORMULA_ID', r_LOP.INFORMATION262,l_dml_operation);
2760 l_DFLT_ENRT_RL := get_fk('FORMULA_ID', r_LOP.INFORMATION264,l_dml_operation);
2761 l_ENRT_RL := get_fk('FORMULA_ID', r_LOP.INFORMATION263,l_dml_operation);
2762 l_LER_ID := get_fk('LER_ID', r_LOP.INFORMATION257,l_dml_operation);
2763 l_OIPL_ID := get_fk('OIPL_ID', r_LOP.INFORMATION258,l_dml_operation);
2764 --
2765 l_update := false;
2766 l_process_date := p_effective_date;
2767 --
2768 if l_dml_operation = 'UPDATE' then
2769 --
2770 l_object_found_in_target := TRUE;
2771 --
2772 if l_process_date between r_LOP_unique.information2 and r_LOP_unique.information3 then
2773 l_update := true;
2774 if r_LOP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
2775 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_OIPL_ENRT_ID'
2776 then
2777 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_OIPL_ENRT_ID' ;
2778 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LOP_unique.information1 ;
2779 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LOP_unique.information1 ;
2780 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
2781 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LOP_unique.table_route_id;
2782 --
2783 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
2784 --
2785 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
2786 --
2787 --DOUBT log_data('LOP',l_new_value,l_prefix || r_LOP_unique.name|| l_suffix,'REUSED');
2788 --
2789 end if ;
2790 hr_utility.set_location( 'found record for update',10);
2791 --
2792 else
2793 --
2794 l_update := false;
2795 --
2796 end if;
2797 else
2798 --
2799 --UPD END
2800 l_min_esd := null ;
2801 l_max_eed := null ;
2802 open c_LOP_min_max_dates(r_LOP_unique.table_route_id, r_LOP_unique.information1 ) ;
2803 fetch c_LOP_min_max_dates into l_min_esd,l_max_eed ;
2804 --
2805
2806 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2807 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
2808 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
2809 end if;
2810 l_min_esd := greatest(l_min_esd,r_LOP_unique.information2);
2811
2812 --
2813 if p_reuse_object_flag = 'Y' then
2814 if c_LOP_min_max_dates%found then
2815 -- cursor to find the object
2816 open c_find_LOP_in_target( l_min_esd,l_max_eed,
2817 p_target_business_group_id, nvl(l_ler_chg_oipl_enrt_id, -999) ) ;
2818 fetch c_find_LOP_in_target into l_new_value ;
2819 if c_find_LOP_in_target%found then
2820 --
2821 --TEMPIK
2822 l_dt_rec_found := dt_api.check_min_max_dates
2823 (p_base_table_name => 'BEN_LER_CHG_OIPL_ENRT_F',
2824 p_base_key_column => 'LER_CHG_OIPL_ENRT_ID',
2825 p_base_key_value => l_new_value,
2826 p_from_date => l_min_esd,
2827 p_to_date => l_max_eed );
2828 if l_dt_rec_found THEN
2829 --END TEMPIK
2830 if r_LOP_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
2831 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_OIPL_ENRT_ID' then
2832 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_OIPL_ENRT_ID' ;
2833 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LOP_unique.information1 ;
2834 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
2835 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
2836 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LOP_unique.table_route_id;
2837 --
2838 -- 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) ;
2839 --
2840 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
2841 end if ;
2842 --
2843 l_object_found_in_target := true ;
2844 --TEMPIK
2845 end if; -- l_dt_rec_found
2846 --END TEMPIK
2847 end if;
2848 close c_find_LOP_in_target ;
2849 --
2850 end if;
2851 end if ;
2852 --
2853 close c_LOP_min_max_dates ;
2854 end if; --if p_dml_operation
2855 --
2856 if not l_object_found_in_target OR l_update then
2857
2858 --
2859 l_current_pk_id := r_LOP.information1;
2860 --
2861 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
2862 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
2863 --
2864 if l_current_pk_id = l_prev_pk_id then
2865 --
2866 l_first_rec := false ;
2867 --
2868 else
2869 --
2870 l_first_rec := true ;
2871 --
2872 end if ;
2873 --
2874
2875 l_effective_date := r_LOP.information2;
2876 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2877 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
2878 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
2879 end if;
2880
2881 if l_first_rec and not l_update then
2882 -- Call Create routine.
2883 hr_utility.set_location(' BEN_LER_CHG_OIPL_ENRT_F CREATE_LER_CHG_OIPL_ENRT ',20);
2884 BEN_LER_CHG_OIPL_ENRT_API.CREATE_LER_CHG_OIPL_ENRT(
2885 --
2886 P_VALIDATE => false
2887 ,P_EFFECTIVE_DATE => l_effective_date
2888 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2889 --
2890 ,P_AUTO_ENRT_FLAG => r_LOP.INFORMATION14
2891 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
2892 ,P_CRNT_ENRT_PRCLDS_CHG_FLAG => r_LOP.INFORMATION11
2893 ,P_DFLT_ENRT_CD => r_LOP.INFORMATION16
2894 ,P_DFLT_ENRT_RL => l_DFLT_ENRT_RL
2895 ,P_DFLT_FLAG => r_LOP.INFORMATION12
2896 ,P_ENRT_CD => r_LOP.INFORMATION15
2897 ,P_ENRT_RL => l_ENRT_RL
2898 ,P_LER_CHG_OIPL_ENRT_ID => l_ler_chg_oipl_enrt_id
2899 ,P_LER_ID => l_LER_ID
2900 ,P_LOP_ATTRIBUTE1 => r_LOP.INFORMATION111
2901 ,P_LOP_ATTRIBUTE10 => r_LOP.INFORMATION120
2902 ,P_LOP_ATTRIBUTE11 => r_LOP.INFORMATION121
2903 ,P_LOP_ATTRIBUTE12 => r_LOP.INFORMATION122
2904 ,P_LOP_ATTRIBUTE13 => r_LOP.INFORMATION123
2905 ,P_LOP_ATTRIBUTE14 => r_LOP.INFORMATION124
2906 ,P_LOP_ATTRIBUTE15 => r_LOP.INFORMATION125
2907 ,P_LOP_ATTRIBUTE16 => r_LOP.INFORMATION126
2908 ,P_LOP_ATTRIBUTE17 => r_LOP.INFORMATION127
2909 ,P_LOP_ATTRIBUTE18 => r_LOP.INFORMATION128
2910 ,P_LOP_ATTRIBUTE19 => r_LOP.INFORMATION129
2911 ,P_LOP_ATTRIBUTE2 => r_LOP.INFORMATION112
2912 ,P_LOP_ATTRIBUTE20 => r_LOP.INFORMATION130
2913 ,P_LOP_ATTRIBUTE21 => r_LOP.INFORMATION131
2914 ,P_LOP_ATTRIBUTE22 => r_LOP.INFORMATION132
2915 ,P_LOP_ATTRIBUTE23 => r_LOP.INFORMATION133
2916 ,P_LOP_ATTRIBUTE24 => r_LOP.INFORMATION134
2917 ,P_LOP_ATTRIBUTE25 => r_LOP.INFORMATION135
2918 ,P_LOP_ATTRIBUTE26 => r_LOP.INFORMATION136
2919 ,P_LOP_ATTRIBUTE27 => r_LOP.INFORMATION137
2920 ,P_LOP_ATTRIBUTE28 => r_LOP.INFORMATION138
2921 ,P_LOP_ATTRIBUTE29 => r_LOP.INFORMATION139
2922 ,P_LOP_ATTRIBUTE3 => r_LOP.INFORMATION113
2923 ,P_LOP_ATTRIBUTE30 => r_LOP.INFORMATION140
2924 ,P_LOP_ATTRIBUTE4 => r_LOP.INFORMATION114
2925 ,P_LOP_ATTRIBUTE5 => r_LOP.INFORMATION115
2926 ,P_LOP_ATTRIBUTE6 => r_LOP.INFORMATION116
2927 ,P_LOP_ATTRIBUTE7 => r_LOP.INFORMATION117
2928 ,P_LOP_ATTRIBUTE8 => r_LOP.INFORMATION118
2929 ,P_LOP_ATTRIBUTE9 => r_LOP.INFORMATION119
2930 ,P_LOP_ATTRIBUTE_CATEGORY => r_LOP.INFORMATION110
2931 ,P_OIPL_ID => l_OIPL_ID
2932 ,P_STL_ELIG_CANT_CHG_FLAG => r_LOP.INFORMATION13
2933 --
2934 ,P_EFFECTIVE_START_DATE => l_effective_start_date
2935 ,P_EFFECTIVE_END_DATE => l_effective_end_date
2936 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
2937 );
2938 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
2939 -- Update all relevent cer records with new pk_id
2940 hr_utility.set_location('Before plsql table ',222);
2941 hr_utility.set_location('new_value id '||l_ler_chg_oipl_enrt_id,222);
2942 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_OIPL_ENRT_ID' ;
2943 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LOP.information1 ;
2944 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LER_CHG_OIPL_ENRT_ID ;
2945 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
2946 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LOP_unique.table_route_id;
2947 hr_utility.set_location('After plsql table ',222);
2948 --
2949 -- 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 ) ;
2950 --
2951 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
2952 --
2953 else
2954 --
2955 -- Call Update routine for the pk_id created in prev run .
2956 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
2957 hr_utility.set_location(' BEN_LER_CHG_OIPL_ENRT_F UPDATE_LER_CHG_OIPL_ENRT ',30);
2958 --UPD START
2959 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
2960 --
2961 if l_update then
2962 --
2963 l_datetrack_mode := r_LOP.datetrack_mode ;
2964 --
2965 get_dt_modes(
2966 p_effective_date => l_process_date,
2967 p_effective_end_date => r_LOP.information3,
2968 p_effective_start_date => r_LOP.information2,
2969 p_dml_operation => r_LOP.dml_operation,
2970 p_datetrack_mode => l_datetrack_mode );
2971 -- p_update => l_update
2972 --
2973 l_effective_date := l_process_date;
2974 l_LER_CHG_OIPL_ENRT_ID := r_LOP.information1;
2975 l_object_version_number := r_LOP.information265;
2976 --
2977 end if;
2978 --
2979 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
2980 --
2981 IF l_update OR l_dml_operation <> 'UPDATE' THEN
2982 --UPD END
2983 BEN_LER_CHG_OIPL_ENRT_API.UPDATE_LER_CHG_OIPL_ENRT(
2984 --
2985 P_VALIDATE => false
2986 ,P_EFFECTIVE_DATE => l_effective_date
2987 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2988 --
2989 ,P_AUTO_ENRT_FLAG => r_LOP.INFORMATION14
2990 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
2991 ,P_CRNT_ENRT_PRCLDS_CHG_FLAG => r_LOP.INFORMATION11
2992 ,P_DFLT_ENRT_CD => r_LOP.INFORMATION16
2993 ,P_DFLT_ENRT_RL => l_DFLT_ENRT_RL
2994 ,P_DFLT_FLAG => r_LOP.INFORMATION12
2995 ,P_ENRT_CD => r_LOP.INFORMATION15
2996 ,P_ENRT_RL => l_ENRT_RL
2997 ,P_LER_CHG_OIPL_ENRT_ID => l_ler_chg_oipl_enrt_id
2998 ,P_LER_ID => l_LER_ID
2999 ,P_LOP_ATTRIBUTE1 => r_LOP.INFORMATION111
3000 ,P_LOP_ATTRIBUTE10 => r_LOP.INFORMATION120
3001 ,P_LOP_ATTRIBUTE11 => r_LOP.INFORMATION121
3002 ,P_LOP_ATTRIBUTE12 => r_LOP.INFORMATION122
3003 ,P_LOP_ATTRIBUTE13 => r_LOP.INFORMATION123
3004 ,P_LOP_ATTRIBUTE14 => r_LOP.INFORMATION124
3005 ,P_LOP_ATTRIBUTE15 => r_LOP.INFORMATION125
3006 ,P_LOP_ATTRIBUTE16 => r_LOP.INFORMATION126
3007 ,P_LOP_ATTRIBUTE17 => r_LOP.INFORMATION127
3008 ,P_LOP_ATTRIBUTE18 => r_LOP.INFORMATION128
3009 ,P_LOP_ATTRIBUTE19 => r_LOP.INFORMATION129
3010 ,P_LOP_ATTRIBUTE2 => r_LOP.INFORMATION112
3011 ,P_LOP_ATTRIBUTE20 => r_LOP.INFORMATION130
3012 ,P_LOP_ATTRIBUTE21 => r_LOP.INFORMATION131
3013 ,P_LOP_ATTRIBUTE22 => r_LOP.INFORMATION132
3014 ,P_LOP_ATTRIBUTE23 => r_LOP.INFORMATION133
3015 ,P_LOP_ATTRIBUTE24 => r_LOP.INFORMATION134
3016 ,P_LOP_ATTRIBUTE25 => r_LOP.INFORMATION135
3017 ,P_LOP_ATTRIBUTE26 => r_LOP.INFORMATION136
3018 ,P_LOP_ATTRIBUTE27 => r_LOP.INFORMATION137
3019 ,P_LOP_ATTRIBUTE28 => r_LOP.INFORMATION138
3020 ,P_LOP_ATTRIBUTE29 => r_LOP.INFORMATION139
3021 ,P_LOP_ATTRIBUTE3 => r_LOP.INFORMATION113
3022 ,P_LOP_ATTRIBUTE30 => r_LOP.INFORMATION140
3023 ,P_LOP_ATTRIBUTE4 => r_LOP.INFORMATION114
3024 ,P_LOP_ATTRIBUTE5 => r_LOP.INFORMATION115
3025 ,P_LOP_ATTRIBUTE6 => r_LOP.INFORMATION116
3026 ,P_LOP_ATTRIBUTE7 => r_LOP.INFORMATION117
3027 ,P_LOP_ATTRIBUTE8 => r_LOP.INFORMATION118
3028 ,P_LOP_ATTRIBUTE9 => r_LOP.INFORMATION119
3029 ,P_LOP_ATTRIBUTE_CATEGORY => r_LOP.INFORMATION110
3030 ,P_OIPL_ID => l_OIPL_ID
3031 ,P_STL_ELIG_CANT_CHG_FLAG => r_LOP.INFORMATION13
3032 --
3033 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3034 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3035 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3036 ,P_DATETRACK_MODE => l_datetrack_mode
3037 );
3038 end if; -- l_update
3039 end if;
3040 --
3041 -- Delete the row if it is end dated.
3042 --
3043 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
3044 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
3045 trunc(l_max_eed) = r_LOP.information3) then
3046 --
3047 BEN_LER_CHG_OIPL_ENRT_API.delete_LER_CHG_OIPL_ENRT(
3048 --
3049 p_validate => false
3050 ,p_ler_chg_oipl_enrt_id => l_ler_chg_oipl_enrt_id
3051 ,p_effective_start_date => l_effective_start_date
3052 ,p_effective_end_date => l_effective_end_date
3053 ,p_object_version_number => l_object_version_number
3054 ,p_effective_date => l_max_eed
3055 ,p_datetrack_mode => hr_api.g_delete
3056 --
3057 );
3058 --
3059 end if;
3060 --
3061 l_prev_pk_id := l_current_pk_id ;
3062 --
3063 end if;
3064 --
3065 end if;
3066 --
3067 end loop;
3068 --
3069 exception when others then
3070 --
3071 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LOP',r_lOP.information5 );
3072 --
3073 end create_LOP_rows;
3074
3075 --
3076 ---------------------------------------------------------------
3077 ----------------------< create_LNC_rows >-----------------------
3078 ---------------------------------------------------------------
3079 --
3080 procedure create_LNC_rows
3081 (
3082 p_validate in number default 0
3083 ,p_copy_entity_txn_id in number
3084 ,p_effective_date in date
3085 ,p_prefix_suffix_text in varchar2 default null
3086 ,p_reuse_object_flag in varchar2 default null
3087 ,p_target_business_group_id in varchar2 default null
3088 ,p_prefix_suffix_cd in varchar2 default null
3089 ) is
3090 --
3091 l_CTFN_RQD_WHEN_RL number;
3092 l_LER_RQRS_ENRT_CTFN_ID number;
3093 l_ENRT_CTFN_TYP_CD varchar2(30);
3094 --
3095 cursor c_unique_LNC(l_table_alias varchar2) is
3096 select distinct cpe.information1,
3097 cpe.information2,
3098 cpe.information3,
3099 cpe.table_route_id
3100 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe, pqh_table_route tr
3101 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3102 and cpe.table_route_id = tr.table_route_id
3103 -- and tr.where_clause = l_BEN_LER_ENRT_CTFN_F
3104 and tr.table_alias = l_table_alias
3105 and cpe.number_of_copies = 1 --ADDITION
3106 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
3107 order by information1, information2; --added for bug: 5151945
3108 --
3109 --
3110 cursor c_LNC_min_max_dates(c_table_route_id number,
3111 c_information1 number) is
3112 select
3113 min(cpe.information2) min_esd,
3114 max(cpe.information3) min_eed
3115 from ben_copy_entity_results cpe
3116 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3117 and cpe.table_route_id = c_table_route_id
3118 and cpe.information1 = c_information1 ;
3119 --
3120 cursor c_LNC(c_table_route_id number,
3121 c_information1 number,
3122 c_information2 date,
3123 c_information3 date ) is
3124 select
3125 cpe.*
3126 from ben_copy_entity_results cpe
3127 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3128 and cpe.table_route_id = c_table_route_id
3129 and cpe.information1 = c_information1
3130 and cpe.information2 = c_information2
3131 and cpe.information3 = c_information3
3132 and rownum = 1 ;
3133 -- Date Track target record
3134 cursor c_find_LNC_in_target(
3135 c_effective_start_date date,
3136 c_effective_end_date date,
3137 c_business_group_id number,
3138 c_new_pk_id number) is
3139 select
3140 LNC.ler_enrt_ctfn_id new_value
3141 from BEN_LER_ENRT_CTFN_F LNC
3142 where
3143 nvl(LNC.LER_RQRS_ENRT_CTFN_ID,-999) = nvl(l_LER_RQRS_ENRT_CTFN_ID,-999) and
3144 nvl(LNC.ENRT_CTFN_TYP_CD,'XXX') = nvl(l_ENRT_CTFN_TYP_CD,'XXX') and
3145 LNC.business_group_id = c_business_group_id
3146 and LNC.ler_enrt_ctfn_id <> c_new_pk_id
3147 --TEMPIK
3148 and c_effective_start_date between effective_start_date
3149 and effective_end_date ;
3150 --END TEMPIK
3151 /*TEMPIK
3152 and exists ( select null
3153 from BEN_LER_ENRT_CTFN_F LNC1
3154 where
3155 nvl(LNC1.LER_RQRS_ENRT_CTFN_ID,-999) = nvl(l_LER_RQRS_ENRT_CTFN_ID,-999) and
3156 LNC1.ENRT_CTFN_TYP_CD = l_ENRT_CTFN_TYP_CD and
3157 LNC1.business_group_id = c_business_group_id
3158 and LNC1.effective_start_date <= c_effective_start_date )
3159 and exists ( select null
3160 from BEN_LER_ENRT_CTFN_F LNC2
3161 where
3162 nvl(LNC2.LER_RQRS_ENRT_CTFN_ID,-999) = nvl(l_LER_RQRS_ENRT_CTFN_ID,-999) and
3163 LNC2.ENRT_CTFN_TYP_CD = l_ENRT_CTFN_TYP_CD and
3164 LNC2.business_group_id = c_business_group_id
3165 and LNC2.effective_end_date >= c_effective_end_date )
3166 ;
3167 TEMPIK */
3168 --TEMPIK
3169 l_dt_rec_found boolean ;
3170 --END TEMPIK
3171 --
3172 --UPD START
3173 --
3174 l_update boolean := false ;
3175 l_datetrack_mode varchar2(80) := hr_api.g_update;
3176 l_process_date date;
3177 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
3178 --
3179 --UPD END
3180 l_current_pk_id number := null ;
3181 l_prev_pk_id number := null ;
3182 l_first_rec boolean := true ;
3183 r_LNC c_LNC%rowtype;
3184 l_ler_enrt_ctfn_id number ;
3185 l_object_version_number number ;
3186 l_effective_start_date date ;
3187 l_effective_end_date date ;
3188 l_prefix pqh_copy_entity_attribs.information1%type := null;
3189 l_suffix pqh_copy_entity_attribs.information1%type := null;
3190 l_new_value number(15);
3191 l_object_found_in_target boolean := false ;
3192 l_min_esd date;
3193 l_max_eed date;
3194 l_effective_date date;
3195 --
3196 begin
3197 -- Initialization
3198 l_object_found_in_target := false ;
3199 -- End Initialization
3200 -- Derive the prefix - sufix
3201 if p_prefix_suffix_cd = 'PREFIX' then
3202 l_prefix := p_prefix_suffix_text ;
3203 elsif p_prefix_suffix_cd = 'SUFFIX' then
3204 l_suffix := p_prefix_suffix_text ;
3205 else
3206 l_prefix := null ;
3207 l_suffix := null ;
3208 end if ;
3209 -- End Prefix Sufix derivation
3210 for r_LNC_unique in c_unique_LNC('LNC') loop
3211
3212 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
3213 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3214 r_LNC_unique.information3 >=
3215 ben_pd_copy_to_ben_one.g_copy_effective_date)
3216 ) then
3217 --
3218 hr_utility.set_location(' r_LNC_unique.table_route_id '||r_LNC_unique.table_route_id,10);
3219 hr_utility.set_location(' r_LNC_unique.information1 '||r_LNC_unique.information1,10);
3220 hr_utility.set_location( 'r_LNC_unique.information2 '||r_LNC_unique.information2,10);
3221 hr_utility.set_location( 'r_LNC_unique.information3 '||r_LNC_unique.information3,10);
3222 -- If reuse objects flag is 'Y' then check for the object in the target business group
3223 -- if found insert the record into PLSql table and exit the loop else try create the
3224 -- object in the target business group
3225 --
3226 l_object_found_in_target := false ;
3227 --UPD START
3228 open c_LNC(r_LNC_unique.table_route_id,
3229 r_LNC_unique.information1,
3230 r_LNC_unique.information2,
3231 r_LNC_unique.information3 ) ;
3232 --
3233 fetch c_LNC into r_LNC ;
3234 --
3235 close c_LNC ;
3236 --
3237 l_dml_operation:= r_LNC_unique.dml_operation ;
3238 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_LNC.INFORMATION258,l_dml_operation);
3239 l_LER_RQRS_ENRT_CTFN_ID := get_fk('LER_RQRS_ENRT_CTFN_ID', r_LNC.INFORMATION257,l_dml_operation);
3240 l_ENRT_CTFN_TYP_CD := r_LNC.information12 ;
3241 --
3242
3243 l_update := false;
3244 l_process_date := p_effective_date;
3245 --
3246 if l_dml_operation = 'UPDATE' then
3247 --
3248 l_object_found_in_target := TRUE;
3249 --
3250 if l_process_date between r_LNC_unique.information2 and r_LNC_unique.information3 then
3251 l_update := true;
3252 if r_LNC_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
3253 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_ENRT_CTFN_ID'
3254 then
3255 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_ENRT_CTFN_ID' ;
3256 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LNC_unique.information1 ;
3257 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LNC_unique.information1 ;
3258 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
3259 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LNC_unique.table_route_id;
3260 --
3261 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
3262 --
3263 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
3264 --
3265 --DOUBT log_data('LNC',l_new_value,l_prefix || r_LNC_unique.name|| l_suffix,'REUSED');
3266 --
3267 end if ;
3268 hr_utility.set_location( 'found record for update',10);
3269 --
3270 else
3271 --
3272 l_update := false;
3273 --
3274 end if;
3275 else
3276 --
3277 --UPD END
3278 l_min_esd := null ;
3279 l_max_eed := null ;
3280 open c_LNC_min_max_dates(r_LNC_unique.table_route_id, r_LNC_unique.information1 ) ;
3281 fetch c_LNC_min_max_dates into l_min_esd,l_max_eed ;
3282 --
3283
3284 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3285 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
3286 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
3287 end if;
3288 l_min_esd := greatest(l_min_esd,r_LNC_unique.information2);
3289 /* open c_LNC(r_LNC_unique.table_route_id,
3290 r_LNC_unique.information1,
3291 r_LNC_unique.information2,
3292 r_LNC_unique.information3 ) ;
3293 --
3294 fetch c_LNC into r_LNC ;
3295 --
3296 close c_LNC ; */
3297 --
3298 --
3299 if p_reuse_object_flag = 'Y' then
3300 if c_LNC_min_max_dates%found then
3301 -- cursor to find the object
3302 open c_find_LNC_in_target( l_min_esd,l_max_eed,
3303 p_target_business_group_id, nvl(l_ler_enrt_ctfn_id, -999) ) ;
3304 fetch c_find_LNC_in_target into l_new_value ;
3305 if c_find_LNC_in_target%found then
3306 --
3307 --TEMPIK
3308 l_dt_rec_found := dt_api.check_min_max_dates
3309 (p_base_table_name => 'BEN_LER_ENRT_CTFN_F',
3310 p_base_key_column => 'LER_ENRT_CTFN_ID',
3311 p_base_key_value => l_new_value,
3312 p_from_date => l_min_esd,
3313 p_to_date => l_max_eed );
3314 if l_dt_rec_found THEN
3315 --END TEMPIK
3316 if r_LNC_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
3317 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_ENRT_CTFN_ID' then
3318 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_ENRT_CTFN_ID' ;
3319 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LNC_unique.information1 ;
3320 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
3321 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
3322 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LNC_unique.table_route_id;
3323 --
3324 -- 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) ;
3325 --
3326 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
3327 end if ;
3328 --
3329 l_object_found_in_target := true ;
3330 --TEMPIK
3331 end if; -- l_dt_rec_found
3332 --END TEMPIK
3333 end if;
3334 close c_find_LNC_in_target ;
3335 --
3336 end if;
3337 end if ;
3338 --
3339 close c_LNC_min_max_dates ;
3340 end if; --if p_dml_operation
3341 --
3342 if not l_object_found_in_target OR l_update then
3343
3344 --
3345 l_current_pk_id := r_LNC.information1;
3346 --
3347 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
3348 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
3349 --
3350 if l_current_pk_id = l_prev_pk_id then
3351 --
3352 l_first_rec := false ;
3353 --
3354 else
3355 --
3356 l_first_rec := true ;
3357 --
3358 end if ;
3359 --
3360
3361 l_effective_date := r_LNC.information2;
3362 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3363 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
3364 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
3365 end if;
3366
3367 if l_first_rec and not l_update then
3368 -- Call Create routine.
3369 hr_utility.set_location(' BEN_LER_ENRT_CTFN_F CREATE_LER_ENRT_CTFN ',20);
3370 BEN_LER_ENRT_CTFN_API.CREATE_LER_ENRT_CTFN(
3371 --
3372 P_VALIDATE => false
3373 ,P_EFFECTIVE_DATE => l_effective_date
3374 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
3375 --
3376 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
3377 ,P_ENRT_CTFN_TYP_CD => r_LNC.INFORMATION12
3378 ,P_LER_ENRT_CTFN_ID => l_ler_enrt_ctfn_id
3379 ,P_LER_RQRS_ENRT_CTFN_ID => l_LER_RQRS_ENRT_CTFN_ID
3380 ,P_LNC_ATTRIBUTE1 => r_LNC.INFORMATION111
3381 ,P_LNC_ATTRIBUTE10 => r_LNC.INFORMATION120
3382 ,P_LNC_ATTRIBUTE11 => r_LNC.INFORMATION121
3383 ,P_LNC_ATTRIBUTE12 => r_LNC.INFORMATION122
3384 ,P_LNC_ATTRIBUTE13 => r_LNC.INFORMATION123
3385 ,P_LNC_ATTRIBUTE14 => r_LNC.INFORMATION124
3386 ,P_LNC_ATTRIBUTE15 => r_LNC.INFORMATION125
3387 ,P_LNC_ATTRIBUTE16 => r_LNC.INFORMATION126
3388 ,P_LNC_ATTRIBUTE17 => r_LNC.INFORMATION127
3389 ,P_LNC_ATTRIBUTE18 => r_LNC.INFORMATION128
3390 ,P_LNC_ATTRIBUTE19 => r_LNC.INFORMATION129
3391 ,P_LNC_ATTRIBUTE2 => r_LNC.INFORMATION112
3392 ,P_LNC_ATTRIBUTE20 => r_LNC.INFORMATION130
3393 ,P_LNC_ATTRIBUTE21 => r_LNC.INFORMATION131
3394 ,P_LNC_ATTRIBUTE22 => r_LNC.INFORMATION132
3395 ,P_LNC_ATTRIBUTE23 => r_LNC.INFORMATION133
3396 ,P_LNC_ATTRIBUTE24 => r_LNC.INFORMATION134
3397 ,P_LNC_ATTRIBUTE25 => r_LNC.INFORMATION135
3398 ,P_LNC_ATTRIBUTE26 => r_LNC.INFORMATION136
3399 ,P_LNC_ATTRIBUTE27 => r_LNC.INFORMATION137
3400 ,P_LNC_ATTRIBUTE28 => r_LNC.INFORMATION138
3401 ,P_LNC_ATTRIBUTE29 => r_LNC.INFORMATION139
3402 ,P_LNC_ATTRIBUTE3 => r_LNC.INFORMATION113
3403 ,P_LNC_ATTRIBUTE30 => r_LNC.INFORMATION140
3404 ,P_LNC_ATTRIBUTE4 => r_LNC.INFORMATION114
3405 ,P_LNC_ATTRIBUTE5 => r_LNC.INFORMATION115
3406 ,P_LNC_ATTRIBUTE6 => r_LNC.INFORMATION116
3407 ,P_LNC_ATTRIBUTE7 => r_LNC.INFORMATION117
3408 ,P_LNC_ATTRIBUTE8 => r_LNC.INFORMATION118
3409 ,P_LNC_ATTRIBUTE9 => r_LNC.INFORMATION119
3410 ,P_LNC_ATTRIBUTE_CATEGORY => r_LNC.INFORMATION110
3411 ,P_RQD_FLAG => r_LNC.INFORMATION11
3412 --
3413 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3414 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3415 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3416 );
3417 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
3418 -- Update all relevent cer records with new pk_id
3419 hr_utility.set_location('Before plsql table ',222);
3420 hr_utility.set_location('new_value id '||l_ler_enrt_ctfn_id,222);
3421 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_ENRT_CTFN_ID' ;
3422 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LNC.information1 ;
3423 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LER_ENRT_CTFN_ID ;
3424 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
3425 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LNC_unique.table_route_id;
3426 hr_utility.set_location('After plsql table ',222);
3427 --
3428 -- 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 ) ;
3429 --
3430 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
3431 --
3432 else
3433 --
3434 -- Call Update routine for the pk_id created in prev run .
3435 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
3436 hr_utility.set_location(' BEN_LER_ENRT_CTFN_F UPDATE_LER_ENRT_CTFN ',30);
3437 --UPD START
3438 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
3439 --
3440 if l_update then
3441 --
3442 l_datetrack_mode := r_LNC.datetrack_mode ;
3443 --
3444 get_dt_modes(
3445 p_effective_date => l_process_date,
3446 p_effective_end_date => r_LNC.information3,
3447 p_effective_start_date => r_LNC.information2,
3448 p_dml_operation => r_LNC.dml_operation,
3449 p_datetrack_mode => l_datetrack_mode );
3450 -- p_update => l_update
3451 --
3452 l_effective_date := l_process_date;
3453 l_LER_ENRT_CTFN_ID := r_LNC.information1;
3454 l_object_version_number := r_LNC.information265;
3455 --
3456 end if;
3457 --
3458 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
3459 --
3460 IF l_update OR l_dml_operation <> 'UPDATE' THEN
3461 --UPD END
3462
3463 BEN_LER_ENRT_CTFN_API.UPDATE_LER_ENRT_CTFN(
3464 --
3465 P_VALIDATE => false
3466 ,P_EFFECTIVE_DATE => l_effective_date
3467 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
3468 --
3469 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
3470 ,P_ENRT_CTFN_TYP_CD => r_LNC.INFORMATION12
3471 ,P_LER_ENRT_CTFN_ID => l_ler_enrt_ctfn_id
3472 ,P_LER_RQRS_ENRT_CTFN_ID => l_LER_RQRS_ENRT_CTFN_ID
3473 ,P_LNC_ATTRIBUTE1 => r_LNC.INFORMATION111
3474 ,P_LNC_ATTRIBUTE10 => r_LNC.INFORMATION120
3475 ,P_LNC_ATTRIBUTE11 => r_LNC.INFORMATION121
3476 ,P_LNC_ATTRIBUTE12 => r_LNC.INFORMATION122
3477 ,P_LNC_ATTRIBUTE13 => r_LNC.INFORMATION123
3478 ,P_LNC_ATTRIBUTE14 => r_LNC.INFORMATION124
3479 ,P_LNC_ATTRIBUTE15 => r_LNC.INFORMATION125
3480 ,P_LNC_ATTRIBUTE16 => r_LNC.INFORMATION126
3481 ,P_LNC_ATTRIBUTE17 => r_LNC.INFORMATION127
3482 ,P_LNC_ATTRIBUTE18 => r_LNC.INFORMATION128
3483 ,P_LNC_ATTRIBUTE19 => r_LNC.INFORMATION129
3484 ,P_LNC_ATTRIBUTE2 => r_LNC.INFORMATION112
3485 ,P_LNC_ATTRIBUTE20 => r_LNC.INFORMATION130
3486 ,P_LNC_ATTRIBUTE21 => r_LNC.INFORMATION131
3487 ,P_LNC_ATTRIBUTE22 => r_LNC.INFORMATION132
3488 ,P_LNC_ATTRIBUTE23 => r_LNC.INFORMATION133
3489 ,P_LNC_ATTRIBUTE24 => r_LNC.INFORMATION134
3490 ,P_LNC_ATTRIBUTE25 => r_LNC.INFORMATION135
3491 ,P_LNC_ATTRIBUTE26 => r_LNC.INFORMATION136
3492 ,P_LNC_ATTRIBUTE27 => r_LNC.INFORMATION137
3493 ,P_LNC_ATTRIBUTE28 => r_LNC.INFORMATION138
3494 ,P_LNC_ATTRIBUTE29 => r_LNC.INFORMATION139
3495 ,P_LNC_ATTRIBUTE3 => r_LNC.INFORMATION113
3496 ,P_LNC_ATTRIBUTE30 => r_LNC.INFORMATION140
3497 ,P_LNC_ATTRIBUTE4 => r_LNC.INFORMATION114
3498 ,P_LNC_ATTRIBUTE5 => r_LNC.INFORMATION115
3499 ,P_LNC_ATTRIBUTE6 => r_LNC.INFORMATION116
3500 ,P_LNC_ATTRIBUTE7 => r_LNC.INFORMATION117
3501 ,P_LNC_ATTRIBUTE8 => r_LNC.INFORMATION118
3502 ,P_LNC_ATTRIBUTE9 => r_LNC.INFORMATION119
3503 ,P_LNC_ATTRIBUTE_CATEGORY => r_LNC.INFORMATION110
3504 ,P_RQD_FLAG => r_LNC.INFORMATION11
3505 --
3506 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3507 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3508 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3509 ,P_DATETRACK_MODE => l_datetrack_mode
3510
3511 );
3512 --
3513 end if; -- l_update
3514 end if;
3515 --
3516 -- Delete the row if it is end dated.
3517 --
3518 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
3519 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
3520 trunc(l_max_eed) = r_LNC.information3) then
3521 --
3522 BEN_LER_ENRT_CTFN_API.delete_LER_ENRT_CTFN(
3523 --
3524 p_validate => false
3525 ,p_ler_enrt_ctfn_id => l_ler_enrt_ctfn_id
3526 ,p_effective_start_date => l_effective_start_date
3527 ,p_effective_end_date => l_effective_end_date
3528 ,p_object_version_number => l_object_version_number
3529 ,p_effective_date => l_max_eed
3530 ,p_datetrack_mode => hr_api.g_delete
3531 --
3532 );
3533 --
3534 end if;
3535 --
3536 l_prev_pk_id := l_current_pk_id ;
3537 --
3538 end if;
3539 --
3540 end if;
3541 --
3542 end loop;
3543 --
3544 exception when others then
3545 --
3546 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LNC',r_lnc.information5 );
3547 --
3548 end create_LNC_rows;
3549
3550 --
3551 ---------------------------------------------------------------
3552 ----------------------< create_LRE_rows >-----------------------
3553 ---------------------------------------------------------------
3554 --
3555 procedure create_LRE_rows
3556 (
3557 p_validate in number default 0
3558 ,p_copy_entity_txn_id in number
3559 ,p_effective_date in date
3560 ,p_prefix_suffix_text in varchar2 default null
3561 ,p_reuse_object_flag in varchar2 default null
3562 ,p_target_business_group_id in varchar2 default null
3563 ,p_prefix_suffix_cd in varchar2 default null
3564 ) is
3565 --
3566 l_CTFN_RQD_WHEN_RL number;
3567 l_LER_ID number;
3568 l_OIPL_ID number;
3569 l_PL_ID number;
3570 cursor c_unique_LRE(l_table_alias varchar2) is
3571 select distinct cpe.information1,
3572 cpe.information2,
3573 cpe.information3,
3574 cpe.table_route_id
3575 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe, pqh_table_route tr
3576 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3577 and cpe.table_route_id = tr.table_route_id
3578 -- and tr.where_clause = l_BEN_LER_RQRS_ENRT_CTFN_F
3579 and tr.table_alias = l_table_alias
3580 and cpe.number_of_copies = 1 --ADDITION
3581 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
3582 order by information1, information2; --added for bug: 5151945
3583 --
3584 --
3585 cursor c_LRE_min_max_dates(c_table_route_id number,
3586 c_information1 number) is
3587 select
3588 min(cpe.information2) min_esd,
3589 max(cpe.information3) min_eed
3590 from ben_copy_entity_results cpe
3591 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3592 and cpe.table_route_id = c_table_route_id
3593 and cpe.information1 = c_information1 ;
3594 --
3595 cursor c_LRE(c_table_route_id number,
3596 c_information1 number,
3597 c_information2 date,
3598 c_information3 date ) is
3599 select
3600 cpe.*
3601 from ben_copy_entity_results cpe
3602 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3603 and cpe.table_route_id = c_table_route_id
3604 and cpe.information1 = c_information1
3605 and cpe.information2 = c_information2
3606 and cpe.information3 = c_information3
3607 and rownum = 1 ;
3608 -- Date Track target record
3609 cursor c_find_LRE_in_target(
3610 c_effective_start_date date,
3611 c_effective_end_date date,
3612 c_business_group_id number,
3613 c_new_pk_id number) is
3614 select
3615 LRE.ler_rqrs_enrt_ctfn_id new_value
3616 from BEN_LER_RQRS_ENRT_CTFN_F LRE
3617 where
3618 nvl(LRE.LER_ID,-999) = nvl(l_LER_ID,-999) and
3619 nvl(LRE.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
3620 nvl(LRE.PL_ID,-999) = nvl(l_PL_ID,-999) and
3621 LRE.business_group_id = c_business_group_id
3622 and LRE.ler_rqrs_enrt_ctfn_id <> c_new_pk_id
3623 --TEMPIK
3624 and c_effective_start_date between effective_start_date
3625 and effective_end_date ;
3626 --END TEMPIK
3627 /*TEMPIK
3628 and exists ( select null
3629 from BEN_LER_RQRS_ENRT_CTFN_F LRE1
3630 where
3631 nvl(LRE1.LER_ID,-999) = nvl(l_LER_ID,-999) and
3632 nvl(LRE1.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
3633 nvl(LRE1.PL_ID,-999) = nvl(l_PL_ID,-999) and
3634 LRE1.business_group_id = c_business_group_id
3635 and LRE1.effective_start_date <= c_effective_start_date )
3636 and exists ( select null
3637 from BEN_LER_RQRS_ENRT_CTFN_F LRE2
3638 where
3639 nvl(LRE2.LER_ID,-999) = nvl(l_LER_ID,-999) and
3640 nvl(LRE2.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
3641 nvl(LRE2.PL_ID,-999) = nvl(l_PL_ID,-999) and
3642 LRE2.business_group_id = c_business_group_id
3643 and LRE2.effective_end_date >= c_effective_end_date )
3644 ;
3645 TEMPIK */
3646 --TEMPIK
3647 l_dt_rec_found boolean ;
3648 --END TEMPIK
3649 --
3650 --UPD START
3651 --
3652 l_update boolean := false ;
3653 l_datetrack_mode varchar2(80) := hr_api.g_update;
3654 l_process_date date;
3655 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
3656 --
3657 --UPD END
3658 l_current_pk_id number := null ;
3659 l_prev_pk_id number := null ;
3660 l_first_rec boolean := true ;
3661 r_LRE c_LRE%rowtype;
3662 l_ler_rqrs_enrt_ctfn_id number ;
3663 l_object_version_number number ;
3664 l_effective_start_date date ;
3665 l_effective_end_date date ;
3666 l_prefix pqh_copy_entity_attribs.information1%type := null;
3667 l_suffix pqh_copy_entity_attribs.information1%type := null;
3668 l_new_value number(15);
3669 l_object_found_in_target boolean := false ;
3670 l_min_esd date;
3671 l_max_eed date;
3672 l_effective_date date;
3673 --
3674 begin
3675 -- Initialization
3676 l_object_found_in_target := false ;
3677 -- End Initialization
3678 -- Derive the prefix - sufix
3679 if p_prefix_suffix_cd = 'PREFIX' then
3680 l_prefix := p_prefix_suffix_text ;
3681 elsif p_prefix_suffix_cd = 'SUFFIX' then
3682 l_suffix := p_prefix_suffix_text ;
3683 else
3684 l_prefix := null ;
3685 l_suffix := null ;
3686 end if ;
3687 -- End Prefix Sufix derivation
3688 for r_LRE_unique in c_unique_LRE('LRE') loop
3689
3690 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
3691 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3692 r_LRE_unique.information3 >=
3693 ben_pd_copy_to_ben_one.g_copy_effective_date)
3694 ) then
3695 --
3696 hr_utility.set_location(' r_LRE_unique.table_route_id '||r_LRE_unique.table_route_id,10);
3697 hr_utility.set_location(' r_LRE_unique.information1 '||r_LRE_unique.information1,10);
3698 hr_utility.set_location( 'r_LRE_unique.information2 '||r_LRE_unique.information2,10);
3699 hr_utility.set_location( 'r_LRE_unique.information3 '||r_LRE_unique.information3,10);
3700 -- If reuse objects flag is 'Y' then check for the object in the target business group
3701 -- if found insert the record into PLSql table and exit the loop else try create the
3702 -- object in the target business group
3703 --
3704 l_object_found_in_target := false ;
3705 --UPD START
3706 open c_LRE(r_LRE_unique.table_route_id,
3707 r_LRE_unique.information1,
3708 r_LRE_unique.information2,
3709 r_LRE_unique.information3 ) ;
3710 --
3711 fetch c_LRE into r_LRE ;
3712 --
3713 close c_LRE ;
3714 --
3715 l_dml_operation:= r_LRE_unique.dml_operation ;
3716 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_LRE.INFORMATION263,l_dml_operation);
3717 l_LER_ID := get_fk('LER_ID', r_LRE.INFORMATION257,l_dml_operation);
3718 l_OIPL_ID := get_fk('OIPL_ID', r_LRE.INFORMATION258,l_dml_operation);
3719 l_PL_ID := get_fk('PL_ID', r_LRE.INFORMATION261,l_dml_operation);
3720 --
3721 l_update := false;
3722 l_process_date := p_effective_date;
3723 --
3724 if l_dml_operation = 'UPDATE' then
3725 --
3726 l_object_found_in_target := TRUE;
3727 --
3728 if l_process_date between r_LRE_unique.information2 and r_LRE_unique.information3 then
3729 l_update := true;
3730 if r_LRE_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
3731 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_RQRS_ENRT_CTFN_ID'
3732 then
3733 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_RQRS_ENRT_CTFN_ID' ;
3734 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LRE_unique.information1 ;
3735 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LRE_unique.information1 ;
3736 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
3737 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LRE_unique.table_route_id;
3738 --
3739 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
3740 --
3741 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
3742 --
3743 -- log_data('LER',l_new_value,l_prefix || r_LRE_unique.name|| l_suffix,'REUSED');
3744 --
3745 end if ;
3746 hr_utility.set_location( 'found record for update',10);
3747 --
3748 else
3749 --
3750 l_update := false;
3751 --
3752 end if;
3753 else
3754 --
3755 --UPD END
3756 l_min_esd := null ;
3757 l_max_eed := null ;
3758 open c_LRE_min_max_dates(r_LRE_unique.table_route_id, r_LRE_unique.information1 ) ;
3759 fetch c_LRE_min_max_dates into l_min_esd,l_max_eed ;
3760 --
3761
3762 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3763 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
3764 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
3765 end if;
3766 l_min_esd := greatest(l_min_esd,r_LRE_unique.information2);
3767 /* open c_LRE(r_LRE_unique.table_route_id,
3768 r_LRE_unique.information1,
3769 r_LRE_unique.information2,
3770 r_LRE_unique.information3 ) ;
3771 --
3772 fetch c_LRE into r_LRE ;
3773 --
3774 close c_LRE ; */
3775 --
3776 if p_reuse_object_flag = 'Y' then
3777 if c_LRE_min_max_dates%found then
3778 -- cursor to find the object
3779 open c_find_LRE_in_target( l_min_esd,l_max_eed,
3780 p_target_business_group_id, nvl(l_ler_rqrs_enrt_ctfn_id, -999) ) ;
3781 fetch c_find_LRE_in_target into l_new_value ;
3782 if c_find_LRE_in_target%found then
3783 --
3784 --TEMPIK
3785 l_dt_rec_found := dt_api.check_min_max_dates
3786 (p_base_table_name => 'BEN_LER_RQRS_ENRT_CTFN_F',
3787 p_base_key_column => 'LER_RQRS_ENRT_CTFN_ID',
3788 p_base_key_value => l_new_value,
3789 p_from_date => l_min_esd,
3790 p_to_date => l_max_eed );
3791 if l_dt_rec_found THEN
3792 --END TEMPIK
3793 if r_LRE_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
3794 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_RQRS_ENRT_CTFN_ID' then
3795 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_RQRS_ENRT_CTFN_ID' ;
3796 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LRE_unique.information1 ;
3797 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
3798 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
3799 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LRE_unique.table_route_id;
3800 --
3801 -- 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) ;
3802 --
3803 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
3804 end if ;
3805 --
3806 l_object_found_in_target := true ;
3807 --TEMPIK
3808 end if; -- l_dt_rec_found
3809 --END TEMPIK
3810 end if;
3811 close c_find_LRE_in_target ;
3812 --
3813 end if;
3814 end if ;
3815 --
3816 close c_LRE_min_max_dates ;
3817 end if; --if p_dml_operation
3818 --
3819 if not l_object_found_in_target OR l_update then
3820
3821 --
3822 l_current_pk_id := r_LRE.information1;
3823 --
3824 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
3825 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
3826 --
3827 if l_current_pk_id = l_prev_pk_id then
3828 --
3829 l_first_rec := false ;
3830 --
3831 else
3832 --
3833 l_first_rec := true ;
3834 --
3835 end if ;
3836 --
3837
3838 l_effective_date := r_LRE.information2;
3839 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3840 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
3841 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
3842 end if;
3843
3844 if l_first_rec and not l_update then
3845 -- Call Create routine.
3846
3847 hr_utility.set_location(' BEN_LER_RQRS_ENRT_CTFN_F CREATE_LER_RQRS_ENRT_CTFN ',20);
3848 BEN_LER_RQRS_ENRT_CTFN_API.CREATE_LER_RQRS_ENRT_CTFN(
3849 --
3850 P_VALIDATE => false
3851 ,P_EFFECTIVE_DATE => l_effective_date
3852 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
3853 --
3854 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
3855 ,P_EXCLD_FLAG => r_LRE.INFORMATION11
3856 ,P_LER_ID => l_LER_ID
3857 ,P_LER_RQRS_ENRT_CTFN_ID => l_ler_rqrs_enrt_ctfn_id
3858 ,P_LRE_ATTRIBUTE1 => r_LRE.INFORMATION111
3859 ,P_LRE_ATTRIBUTE10 => r_LRE.INFORMATION120
3860 ,P_LRE_ATTRIBUTE11 => r_LRE.INFORMATION121
3861 ,P_LRE_ATTRIBUTE12 => r_LRE.INFORMATION122
3862 ,P_LRE_ATTRIBUTE13 => r_LRE.INFORMATION123
3863 ,P_LRE_ATTRIBUTE14 => r_LRE.INFORMATION124
3864 ,P_LRE_ATTRIBUTE15 => r_LRE.INFORMATION125
3865 ,P_LRE_ATTRIBUTE16 => r_LRE.INFORMATION126
3866 ,P_LRE_ATTRIBUTE17 => r_LRE.INFORMATION127
3867 ,P_LRE_ATTRIBUTE18 => r_LRE.INFORMATION128
3868 ,P_LRE_ATTRIBUTE19 => r_LRE.INFORMATION129
3869 ,P_LRE_ATTRIBUTE2 => r_LRE.INFORMATION112
3870 ,P_LRE_ATTRIBUTE20 => r_LRE.INFORMATION130
3871 ,P_LRE_ATTRIBUTE21 => r_LRE.INFORMATION131
3872 ,P_LRE_ATTRIBUTE22 => r_LRE.INFORMATION132
3873 ,P_LRE_ATTRIBUTE23 => r_LRE.INFORMATION133
3874 ,P_LRE_ATTRIBUTE24 => r_LRE.INFORMATION134
3875 ,P_LRE_ATTRIBUTE25 => r_LRE.INFORMATION135
3876 ,P_LRE_ATTRIBUTE26 => r_LRE.INFORMATION136
3877 ,P_LRE_ATTRIBUTE27 => r_LRE.INFORMATION137
3878 ,P_LRE_ATTRIBUTE28 => r_LRE.INFORMATION138
3879 ,P_LRE_ATTRIBUTE29 => r_LRE.INFORMATION139
3880 ,P_LRE_ATTRIBUTE3 => r_LRE.INFORMATION113
3881 ,P_LRE_ATTRIBUTE30 => r_LRE.INFORMATION140
3882 ,P_LRE_ATTRIBUTE4 => r_LRE.INFORMATION114
3883 ,P_LRE_ATTRIBUTE5 => r_LRE.INFORMATION115
3884 ,P_LRE_ATTRIBUTE6 => r_LRE.INFORMATION116
3885 ,P_LRE_ATTRIBUTE7 => r_LRE.INFORMATION117
3886 ,P_LRE_ATTRIBUTE8 => r_LRE.INFORMATION118
3887 ,P_LRE_ATTRIBUTE9 => r_LRE.INFORMATION119
3888 ,P_LRE_ATTRIBUTE_CATEGORY => r_LRE.INFORMATION110
3889 ,P_OIPL_ID => l_OIPL_ID
3890 ,P_PL_ID => l_PL_ID
3891 --ML
3892 ,P_SUSP_IF_CTFN_NOT_PRVD_FLAG => nvl(r_LRE.INFORMATION198,'Y')
3893 ,P_CTFN_DETERMINE_CD => r_LRE.INFORMATION197
3894 -- ML END
3895 -- 9999 NO PLIP here But there is PLIP level in API Call
3896 --
3897 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3898 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3899 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3900 );
3901 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
3902 -- Update all relevent cer records with new pk_id
3903 hr_utility.set_location('Before plsql table ',222);
3904 hr_utility.set_location('new_value id '||l_ler_rqrs_enrt_ctfn_id,222);
3905 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_RQRS_ENRT_CTFN_ID' ;
3906 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LRE.information1 ;
3907 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LER_RQRS_ENRT_CTFN_ID ;
3908 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
3909 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LRE_unique.table_route_id;
3910 hr_utility.set_location('After plsql table ',222);
3911 --
3912 -- 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 ) ;
3913 --
3914 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
3915 --
3916 else
3917 --
3918 -- Call Update routine for the pk_id created in prev run .
3919 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
3920 hr_utility.set_location(' BEN_LER_RQRS_ENRT_CTFN_F UPDATE_LER_RQRS_ENRT_CTFN ',30);
3921 --UPD START
3922 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
3923 --
3924 if l_update then
3925 --
3926 l_datetrack_mode := r_LRE.datetrack_mode ;
3927 --
3928 get_dt_modes(
3929 p_effective_date => l_process_date,
3930 p_effective_end_date => r_LRE.information3,
3931 p_effective_start_date => r_LRE.information2,
3932 p_dml_operation => r_LRE.dml_operation,
3933 p_datetrack_mode => l_datetrack_mode );
3934 -- p_update => l_update
3935 --
3936 l_effective_date := l_process_date;
3937 l_LER_RQRS_ENRT_CTFN_ID := r_LRE.information1;
3938 l_object_version_number := r_LRE.information265;
3939 --
3940 end if;
3941 --
3942 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
3943 --
3944 IF l_update OR l_dml_operation <> 'UPDATE' THEN
3945 --UPD END
3946
3947 BEN_LER_RQRS_ENRT_CTFN_API.UPDATE_LER_RQRS_ENRT_CTFN(
3948 --
3949 P_VALIDATE => false
3950 ,P_EFFECTIVE_DATE => l_effective_date
3951 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
3952 --
3953 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
3954 ,P_EXCLD_FLAG => r_LRE.INFORMATION11
3955 ,P_LER_ID => l_LER_ID
3956 ,P_LER_RQRS_ENRT_CTFN_ID => l_ler_rqrs_enrt_ctfn_id
3957 ,P_LRE_ATTRIBUTE1 => r_LRE.INFORMATION111
3958 ,P_LRE_ATTRIBUTE10 => r_LRE.INFORMATION120
3959 ,P_LRE_ATTRIBUTE11 => r_LRE.INFORMATION121
3960 ,P_LRE_ATTRIBUTE12 => r_LRE.INFORMATION122
3961 ,P_LRE_ATTRIBUTE13 => r_LRE.INFORMATION123
3962 ,P_LRE_ATTRIBUTE14 => r_LRE.INFORMATION124
3963 ,P_LRE_ATTRIBUTE15 => r_LRE.INFORMATION125
3964 ,P_LRE_ATTRIBUTE16 => r_LRE.INFORMATION126
3965 ,P_LRE_ATTRIBUTE17 => r_LRE.INFORMATION127
3966 ,P_LRE_ATTRIBUTE18 => r_LRE.INFORMATION128
3967 ,P_LRE_ATTRIBUTE19 => r_LRE.INFORMATION129
3968 ,P_LRE_ATTRIBUTE2 => r_LRE.INFORMATION112
3969 ,P_LRE_ATTRIBUTE20 => r_LRE.INFORMATION130
3970 ,P_LRE_ATTRIBUTE21 => r_LRE.INFORMATION131
3971 ,P_LRE_ATTRIBUTE22 => r_LRE.INFORMATION132
3972 ,P_LRE_ATTRIBUTE23 => r_LRE.INFORMATION133
3973 ,P_LRE_ATTRIBUTE24 => r_LRE.INFORMATION134
3974 ,P_LRE_ATTRIBUTE25 => r_LRE.INFORMATION135
3975 ,P_LRE_ATTRIBUTE26 => r_LRE.INFORMATION136
3976 ,P_LRE_ATTRIBUTE27 => r_LRE.INFORMATION137
3977 ,P_LRE_ATTRIBUTE28 => r_LRE.INFORMATION138
3978 ,P_LRE_ATTRIBUTE29 => r_LRE.INFORMATION139
3979 ,P_LRE_ATTRIBUTE3 => r_LRE.INFORMATION113
3980 ,P_LRE_ATTRIBUTE30 => r_LRE.INFORMATION140
3981 ,P_LRE_ATTRIBUTE4 => r_LRE.INFORMATION114
3982 ,P_LRE_ATTRIBUTE5 => r_LRE.INFORMATION115
3983 ,P_LRE_ATTRIBUTE6 => r_LRE.INFORMATION116
3984 ,P_LRE_ATTRIBUTE7 => r_LRE.INFORMATION117
3985 ,P_LRE_ATTRIBUTE8 => r_LRE.INFORMATION118
3986 ,P_LRE_ATTRIBUTE9 => r_LRE.INFORMATION119
3987 ,P_LRE_ATTRIBUTE_CATEGORY => r_LRE.INFORMATION110
3988 ,P_OIPL_ID => l_OIPL_ID
3989 ,P_PL_ID => l_PL_ID
3990 --ML
3991 ,P_SUSP_IF_CTFN_NOT_PRVD_FLAG => nvl(r_LRE.INFORMATION198,'Y')
3992 ,P_CTFN_DETERMINE_CD => r_LRE.INFORMATION197
3993 -- ML END
3994 --
3995 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3996 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3997 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3998 ,P_DATETRACK_MODE => l_datetrack_mode
3999 );
4000 --
4001 end if; -- l_update
4002
4003 end if;
4004 --
4005 -- Delete the row if it is end dated.
4006 --
4007 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
4008 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
4009 trunc(l_max_eed) = r_LRE.information3) then
4010 --
4011 BEN_LER_RQRS_ENRT_CTFN_API.delete_LER_RQRS_ENRT_CTFN(
4012 --
4013 p_validate => false
4014 ,p_ler_rqrs_enrt_ctfn_id => l_ler_rqrs_enrt_ctfn_id
4015 ,p_effective_start_date => l_effective_start_date
4016 ,p_effective_end_date => l_effective_end_date
4017 ,p_object_version_number => l_object_version_number
4018 ,p_effective_date => l_max_eed
4019 ,p_datetrack_mode => hr_api.g_delete
4020 --
4021 );
4022 --
4023 end if;
4024 --
4025 l_prev_pk_id := l_current_pk_id ;
4026 --
4027 end if;
4028 --
4029 end if;
4030 --
4031 end loop;
4032 --
4033 exception when others then
4034 --
4035 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LRE',r_lre.information5 );
4036 --
4037 end create_LRE_rows;
4038
4039 --
4040 ---------------------------------------------------------------
4041 ----------------------< create_LBC_rows >-----------------------
4042 ---------------------------------------------------------------
4043 --
4044 procedure create_LBC_rows
4045 (
4046 p_validate in number default 0
4047 ,p_copy_entity_txn_id in number
4048 ,p_effective_date in date
4049 ,p_prefix_suffix_text in varchar2 default null
4050 ,p_reuse_object_flag in varchar2 default null
4051 ,p_target_business_group_id in varchar2 default null
4052 ,p_prefix_suffix_cd in varchar2 default null
4053 ) is
4054 --
4055 l_CTFN_RQD_WHEN_RL number;
4056 l_LER_BNFT_RSTRN_ID number;
4057 l_ENRT_CTFN_TYP_CD varchar2(30);
4058 --
4059 cursor c_unique_LBC(l_table_alias varchar2) is
4060 select distinct cpe.information1,
4061 cpe.information2,
4062 cpe.information3,
4063 cpe.table_route_id
4064 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
4065 pqh_table_route tr
4066 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4067 and cpe.table_route_id = tr.table_route_id
4068 -- and tr.where_clause = l_BEN_LER_BNFT_RSTRN_CTFN_F
4069 and tr.table_alias = l_table_alias
4070 and cpe.number_of_copies = 1 --ADDITION
4071 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
4072 order by information1, information2; --added for bug: 5151945
4073 --
4074 --
4075 cursor c_LBC_min_max_dates(c_table_route_id number,
4076 c_information1 number) is
4077 select
4078 min(cpe.information2) min_esd,
4079 max(cpe.information3) min_eed
4080 from ben_copy_entity_results cpe
4081 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4082 and cpe.table_route_id = c_table_route_id
4083 and cpe.information1 = c_information1 ;
4084 --
4085 cursor c_LBC(c_table_route_id number,
4086 c_information1 number,
4087 c_information2 date,
4088 c_information3 date) is
4089 select
4090 cpe.*
4091 from ben_copy_entity_results cpe
4092 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4093 and cpe.table_route_id = c_table_route_id
4094 and cpe.information1 = c_information1
4095 and cpe.information2 = c_information2
4096 and cpe.information3 = c_information3
4097 and rownum = 1 ;
4098 -- Date Track target record
4099 cursor c_find_LBC_in_target(
4100 c_effective_start_date date,
4101 c_effective_end_date date,
4102 c_business_group_id number,
4103 c_new_pk_id number) is
4104 select
4105 LBC.ler_bnft_rstrn_ctfn_id new_value
4106 from BEN_LER_BNFT_RSTRN_CTFN_F LBC
4107 where
4108 nvl(LBC.LER_BNFT_RSTRN_ID,-999) = nvl(l_LER_BNFT_RSTRN_ID,-999) and
4109 nvl(LBC.ENRT_CTFN_TYP_CD,'XXX') = nvl(l_ENRT_CTFN_TYP_CD,'XXX') and
4110 LBC.business_group_id = c_business_group_id
4111 and LBC.ler_bnft_rstrn_ctfn_id <> c_new_pk_id
4112 --TEMPIK
4113 and c_effective_start_date between effective_start_date
4114 and effective_end_date ;
4115 --END TEMPIK
4116 /*TEMPIK
4117 and exists ( select null
4118 from BEN_LER_BNFT_RSTRN_CTFN_F LBC1
4119 where
4120 nvl(LBC1.LER_BNFT_RSTRN_ID,-999) = nvl(l_LER_BNFT_RSTRN_ID,-999) and
4121 LBC1.ENRT_CTFN_TYP_CD = l_ENRT_CTFN_TYP_CD and
4122 LBC1.business_group_id = c_business_group_id
4123 and LBC1.effective_start_date <= c_effective_start_date )
4124 and exists ( select null
4125 from BEN_LER_BNFT_RSTRN_CTFN_F LBC2
4126 where
4127 nvl(LBC2.LER_BNFT_RSTRN_ID,-999) = nvl(l_LER_BNFT_RSTRN_ID,-999) and
4128 LBC2.ENRT_CTFN_TYP_CD = l_ENRT_CTFN_TYP_CD and
4129 LBC2.business_group_id = c_business_group_id
4130 and LBC2.effective_end_date >= c_effective_end_date )
4131 ;
4132 TEMPIK */
4133 --TEMPIK
4134 l_dt_rec_found boolean ;
4135 --END TEMPIK
4136 --
4137 --UPD START
4138 --
4139 l_update boolean := false ;
4140 l_datetrack_mode varchar2(80) := hr_api.g_update;
4141 l_process_date date;
4142 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
4143 --
4144 --UPD END
4145 l_current_pk_id number := null ;
4146 l_prev_pk_id number := null ;
4147 l_first_rec boolean := true ;
4148 r_LBC c_LBC%rowtype;
4149 l_ler_bnft_rstrn_ctfn_id number ;
4150 l_object_version_number number ;
4151 l_effective_start_date date ;
4152 l_effective_end_date date ;
4153 l_prefix pqh_copy_entity_attribs.information1%type := null;
4154 l_suffix pqh_copy_entity_attribs.information1%type := null;
4155 l_new_value number(15);
4156 l_object_found_in_target boolean := false ;
4157 l_min_esd date;
4158 l_max_eed date;
4159 l_effective_date date;
4160 --
4161 begin
4162 -- Initialization
4163 l_object_found_in_target := false ;
4164 -- End Initialization
4165 -- Derive the prefix - sufix
4166 if p_prefix_suffix_cd = 'PREFIX' then
4167 l_prefix := p_prefix_suffix_text ;
4168 elsif p_prefix_suffix_cd = 'SUFFIX' then
4169 l_suffix := p_prefix_suffix_text ;
4170 else
4171 l_prefix := null ;
4172 l_suffix := null ;
4173 end if ;
4174 -- End Prefix Sufix derivation
4175 for r_LBC_unique in c_unique_LBC('LBC') loop
4176
4177 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
4178 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
4179 r_LBC_unique.information3 >=
4180 ben_pd_copy_to_ben_one.g_copy_effective_date)
4181 ) then
4182 --
4183 hr_utility.set_location(' r_LBC_unique.table_route_id '||r_LBC_unique.table_route_id,10);
4184 hr_utility.set_location(' r_LBC_unique.information1 '||r_LBC_unique.information1,10);
4185 hr_utility.set_location( 'r_LBC_unique.information2 '||r_LBC_unique.information2,10);
4186 hr_utility.set_location( 'r_LBC_unique.information3 '||r_LBC_unique.information3,10);
4187 -- If reuse objects flag is 'Y' then check for the object in the target business group
4188 -- if found insert the record into PLSql table and exit the loop else try create the
4189 -- object in the target business group
4190 --
4191 l_object_found_in_target := false ;
4192 --UPD START
4193 open c_LBC(r_LBC_unique.table_route_id,
4194 r_LBC_unique.information1,
4195 r_LBC_unique.information2,
4196 r_LBC_unique.information3 ) ;
4197 --
4198 fetch c_LBC into r_LBC ;
4199 --
4200 close c_LBC ;
4201 --
4202 l_dml_operation:= r_LBC_unique.dml_operation ;
4203 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_LBC.INFORMATION261);
4204 l_LER_BNFT_RSTRN_ID := get_fk('LER_BNFT_RSTRN_ID', r_LBC.INFORMATION257);
4205 l_ENRT_CTFN_TYP_CD := r_LBC.information12 ;
4206 --
4207 l_update := false;
4208 l_process_date := p_effective_date;
4209 --
4210 if l_dml_operation = 'UPDATE' then
4211 --
4212 l_object_found_in_target := TRUE;
4213 --
4214 if l_process_date between r_LBC_unique.information2 and r_LBC_unique.information3 then
4215 l_update := true;
4216 if r_LBC_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
4217 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_BNFT_RSTRN_CTFN_ID'
4218 then
4219 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_BNFT_RSTRN_CTFN_ID' ;
4220 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LBC_unique.information1 ;
4221 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LBC_unique.information1 ;
4222 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
4223 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LBC_unique.table_route_id;
4224 --
4225 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
4226 --
4227 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
4228 --
4229 --DOUBT log_data('LBC',l_new_value,l_prefix || r_LBC_unique.name|| l_suffix,'REUSED');
4230 --
4231 end if ;
4232 hr_utility.set_location( 'found record for update',10);
4233 --
4234 else
4235 --
4236 l_update := false;
4237 --
4238 end if;
4239 else
4240 --
4241 --UPD END
4242 l_min_esd := null ;
4243 l_max_eed := null ;
4244 open c_LBC_min_max_dates(r_LBC_unique.table_route_id, r_LBC_unique.information1 ) ;
4245 fetch c_LBC_min_max_dates into l_min_esd,l_max_eed ;
4246 --
4247
4248 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
4249 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
4250 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
4251 end if;
4252 l_min_esd := greatest(l_min_esd,r_LBC_unique.information2);
4253 /* open c_LBC(r_LBC_unique.table_route_id,
4254 r_LBC_unique.information1,
4255 r_LBC_unique.information2,
4256 r_LBC_unique.information3 ) ;
4257 --
4258 fetch c_LBC into r_LBC ;
4259 --
4260 close c_LBC ; */
4261 --
4262 if p_reuse_object_flag = 'Y' then
4263 if c_LBC_min_max_dates%found then
4264 -- cursor to find the object
4265 open c_find_LBC_in_target( l_min_esd,l_max_eed,
4266 p_target_business_group_id, nvl(l_ler_bnft_rstrn_ctfn_id, -999) ) ;
4267 fetch c_find_LBC_in_target into l_new_value ;
4268 if c_find_LBC_in_target%found then
4269 --
4270 --TEMPIK
4271 l_dt_rec_found := dt_api.check_min_max_dates
4272 (p_base_table_name => 'BEN_LER_BNFT_RSTRN_CTFN_F',
4273 p_base_key_column => 'LER_BNFT_RSTRN_CTFN_ID',
4274 p_base_key_value => l_new_value,
4275 p_from_date => l_min_esd,
4276 p_to_date => l_max_eed );
4277 if l_dt_rec_found THEN
4278 --END TEMPIK
4279 if r_LBC_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
4280 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_BNFT_RSTRN_CTFN_ID' then
4281 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_BNFT_RSTRN_CTFN_ID' ;
4282 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LBC_unique.information1 ;
4283 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
4284 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
4285 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LBC_unique.table_route_id;
4286 --
4287 -- 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) ;
4288 --
4289 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
4290 end if ;
4291 --
4292 l_object_found_in_target := true ;
4293 --TEMPIK
4294 end if; -- l_dt_rec_found
4295 --END TEMPIK
4296 end if;
4297 close c_find_LBC_in_target ;
4298 --
4299 end if;
4300 end if ;
4301 --
4302 close c_LBC_min_max_dates ;
4303 end if; --if p_dml_operation
4304 --
4305 if not l_object_found_in_target OR l_update then
4306
4307 --
4308 l_current_pk_id := r_LBC.information1;
4309 --
4310 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
4311 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
4312 --
4313 if l_current_pk_id = l_prev_pk_id then
4314 --
4315 l_first_rec := false ;
4316 --
4317 else
4318 --
4319 l_first_rec := true ;
4320 --
4321 end if ;
4322 --
4323
4324 l_effective_date := r_LBC.information2;
4325 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
4326 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
4327 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
4328 end if;
4329
4330 if l_first_rec and not l_update then
4331 -- Call Create routine.
4332 hr_utility.set_location(' BEN_LER_BNFT_RSTRN_CTFN_F CREATE_LER_BNFT_RSTRN_CTFN ',20);
4333 BEN_LER_BNFT_RSTRN_CTFN_API.CREATE_LER_BNFT_RSTRN_CTFN(
4334 --
4335 P_VALIDATE => false
4336 ,P_EFFECTIVE_DATE => l_effective_date
4337 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
4338 --
4339 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
4340 ,P_ENRT_CTFN_TYP_CD => r_LBC.INFORMATION12
4341 ,P_LBC_ATTRIBUTE1 => r_LBC.INFORMATION111
4342 ,P_LBC_ATTRIBUTE10 => r_LBC.INFORMATION120
4343 ,P_LBC_ATTRIBUTE11 => r_LBC.INFORMATION121
4344 ,P_LBC_ATTRIBUTE12 => r_LBC.INFORMATION122
4345 ,P_LBC_ATTRIBUTE13 => r_LBC.INFORMATION123
4346 ,P_LBC_ATTRIBUTE14 => r_LBC.INFORMATION124
4347 ,P_LBC_ATTRIBUTE15 => r_LBC.INFORMATION125
4348 ,P_LBC_ATTRIBUTE16 => r_LBC.INFORMATION126
4349 ,P_LBC_ATTRIBUTE17 => r_LBC.INFORMATION127
4350 ,P_LBC_ATTRIBUTE18 => r_LBC.INFORMATION128
4351 ,P_LBC_ATTRIBUTE19 => r_LBC.INFORMATION129
4352 ,P_LBC_ATTRIBUTE2 => r_LBC.INFORMATION112
4353 ,P_LBC_ATTRIBUTE20 => r_LBC.INFORMATION130
4354 ,P_LBC_ATTRIBUTE21 => r_LBC.INFORMATION131
4355 ,P_LBC_ATTRIBUTE22 => r_LBC.INFORMATION132
4356 ,P_LBC_ATTRIBUTE23 => r_LBC.INFORMATION133
4357 ,P_LBC_ATTRIBUTE24 => r_LBC.INFORMATION134
4358 ,P_LBC_ATTRIBUTE25 => r_LBC.INFORMATION135
4359 ,P_LBC_ATTRIBUTE26 => r_LBC.INFORMATION136
4360 ,P_LBC_ATTRIBUTE27 => r_LBC.INFORMATION137
4361 ,P_LBC_ATTRIBUTE28 => r_LBC.INFORMATION138
4362 ,P_LBC_ATTRIBUTE29 => r_LBC.INFORMATION139
4363 ,P_LBC_ATTRIBUTE3 => r_LBC.INFORMATION113
4364 ,P_LBC_ATTRIBUTE30 => r_LBC.INFORMATION140
4365 ,P_LBC_ATTRIBUTE4 => r_LBC.INFORMATION114
4366 ,P_LBC_ATTRIBUTE5 => r_LBC.INFORMATION115
4367 ,P_LBC_ATTRIBUTE6 => r_LBC.INFORMATION116
4368 ,P_LBC_ATTRIBUTE7 => r_LBC.INFORMATION117
4369 ,P_LBC_ATTRIBUTE8 => r_LBC.INFORMATION118
4370 ,P_LBC_ATTRIBUTE9 => r_LBC.INFORMATION119
4371 ,P_LBC_ATTRIBUTE_CATEGORY => r_LBC.INFORMATION110
4372 ,P_LER_BNFT_RSTRN_CTFN_ID => l_ler_bnft_rstrn_ctfn_id
4373 ,P_LER_BNFT_RSTRN_ID => l_LER_BNFT_RSTRN_ID
4374 ,P_RQD_FLAG => r_LBC.INFORMATION11
4375 --
4376 ,P_EFFECTIVE_START_DATE => l_effective_start_date
4377 ,P_EFFECTIVE_END_DATE => l_effective_end_date
4378 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
4379 );
4380 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
4381 -- Update all relevent cer records with new pk_id
4382 hr_utility.set_location('Before plsql table ',222);
4383 hr_utility.set_location('new_value id '||l_ler_bnft_rstrn_ctfn_id,222);
4384 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_BNFT_RSTRN_CTFN_ID' ;
4385 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LBC.information1 ;
4386 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LER_BNFT_RSTRN_CTFN_ID ;
4387 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
4388 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LBC_unique.table_route_id;
4389 hr_utility.set_location('After plsql table ',222);
4390 --
4391 -- 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 ) ;
4392 --
4393 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
4394 --
4395 else
4396 --
4397 -- Call Update routine for the pk_id created in prev run .
4398 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
4399 hr_utility.set_location(' BEN_LER_BNFT_RSTRN_CTFN_F UPDATE_LER_BNFT_RSTRN_CTFN ',30);
4400 --UPD START
4401 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
4402 --
4403 if l_update then
4404 --
4405 l_datetrack_mode := r_LBC.datetrack_mode ;
4406 --
4407 get_dt_modes(
4408 p_effective_date => l_process_date,
4409 p_effective_end_date => r_LBC.information3,
4410 p_effective_start_date => r_LBC.information2,
4411 p_dml_operation => r_LBC.dml_operation,
4412 p_datetrack_mode => l_datetrack_mode );
4413 -- p_update => l_update
4414 --
4415 l_effective_date := l_process_date;
4416 l_LER_BNFT_RSTRN_CTFN_ID := r_LBC.information1;
4417 l_object_version_number := r_LBC.information265;
4418 --
4419 end if;
4420 --
4421 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
4422 --
4423 IF l_update OR l_dml_operation <> 'UPDATE' THEN
4424 --UPD END
4425
4426
4427 BEN_LER_BNFT_RSTRN_CTFN_API.UPDATE_LER_BNFT_RSTRN_CTFN(
4428 --
4429 P_VALIDATE => false
4430 ,P_EFFECTIVE_DATE => l_effective_date
4431 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
4432 --
4433 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
4434 ,P_ENRT_CTFN_TYP_CD => r_LBC.INFORMATION12
4435 ,P_LBC_ATTRIBUTE1 => r_LBC.INFORMATION111
4436 ,P_LBC_ATTRIBUTE10 => r_LBC.INFORMATION120
4437 ,P_LBC_ATTRIBUTE11 => r_LBC.INFORMATION121
4438 ,P_LBC_ATTRIBUTE12 => r_LBC.INFORMATION122
4439 ,P_LBC_ATTRIBUTE13 => r_LBC.INFORMATION123
4440 ,P_LBC_ATTRIBUTE14 => r_LBC.INFORMATION124
4441 ,P_LBC_ATTRIBUTE15 => r_LBC.INFORMATION125
4442 ,P_LBC_ATTRIBUTE16 => r_LBC.INFORMATION126
4443 ,P_LBC_ATTRIBUTE17 => r_LBC.INFORMATION127
4444 ,P_LBC_ATTRIBUTE18 => r_LBC.INFORMATION128
4445 ,P_LBC_ATTRIBUTE19 => r_LBC.INFORMATION129
4446 ,P_LBC_ATTRIBUTE2 => r_LBC.INFORMATION112
4447 ,P_LBC_ATTRIBUTE20 => r_LBC.INFORMATION130
4448 ,P_LBC_ATTRIBUTE21 => r_LBC.INFORMATION131
4449 ,P_LBC_ATTRIBUTE22 => r_LBC.INFORMATION132
4450 ,P_LBC_ATTRIBUTE23 => r_LBC.INFORMATION133
4451 ,P_LBC_ATTRIBUTE24 => r_LBC.INFORMATION134
4452 ,P_LBC_ATTRIBUTE25 => r_LBC.INFORMATION135
4453 ,P_LBC_ATTRIBUTE26 => r_LBC.INFORMATION136
4454 ,P_LBC_ATTRIBUTE27 => r_LBC.INFORMATION137
4455 ,P_LBC_ATTRIBUTE28 => r_LBC.INFORMATION138
4456 ,P_LBC_ATTRIBUTE29 => r_LBC.INFORMATION139
4457 ,P_LBC_ATTRIBUTE3 => r_LBC.INFORMATION113
4458 ,P_LBC_ATTRIBUTE30 => r_LBC.INFORMATION140
4459 ,P_LBC_ATTRIBUTE4 => r_LBC.INFORMATION114
4460 ,P_LBC_ATTRIBUTE5 => r_LBC.INFORMATION115
4461 ,P_LBC_ATTRIBUTE6 => r_LBC.INFORMATION116
4462 ,P_LBC_ATTRIBUTE7 => r_LBC.INFORMATION117
4463 ,P_LBC_ATTRIBUTE8 => r_LBC.INFORMATION118
4464 ,P_LBC_ATTRIBUTE9 => r_LBC.INFORMATION119
4465 ,P_LBC_ATTRIBUTE_CATEGORY => r_LBC.INFORMATION110
4466 ,P_LER_BNFT_RSTRN_CTFN_ID => l_ler_bnft_rstrn_ctfn_id
4467 ,P_LER_BNFT_RSTRN_ID => l_LER_BNFT_RSTRN_ID
4468 ,P_RQD_FLAG => r_LBC.INFORMATION11
4469 --
4470 ,P_EFFECTIVE_START_DATE => l_effective_start_date
4471 ,P_EFFECTIVE_END_DATE => l_effective_end_date
4472 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
4473 ,P_DATETRACK_MODE => l_datetrack_mode
4474 );
4475 --
4476 end if; -- l_update
4477 end if;
4478 --
4479 -- Delete the row if it is end dated.
4480 --
4481 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
4482 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
4483 trunc(l_max_eed) = r_LBC.information3) then
4484 --
4485 BEN_LER_BNFT_RSTRN_CTFN_API.delete_LER_BNFT_RSTRN_CTFN(
4486 --
4487 p_validate => false
4488 ,p_ler_bnft_rstrn_ctfn_id => l_ler_bnft_rstrn_ctfn_id
4489 ,p_effective_start_date => l_effective_start_date
4490 ,p_effective_end_date => l_effective_end_date
4491 ,p_object_version_number => l_object_version_number
4492 ,p_effective_date => l_max_eed
4493 ,p_datetrack_mode => hr_api.g_delete
4494 --
4495 );
4496 --
4497 end if;
4498 --
4499 l_prev_pk_id := l_current_pk_id ;
4500 --
4501 end if;
4502 --
4503 end if;
4504 --
4505 end loop;
4506 --
4507 exception when others then
4508 --
4509 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LBC',r_lbc.information5 );
4510 --
4511 end create_LBC_rows;
4512
4513 --
4514 ---------------------------------------------------------------
4515 ----------------------< create_BRC_rows >-----------------------
4516 ---------------------------------------------------------------
4517 --
4518 procedure create_BRC_rows
4519 (
4520 p_validate in number default 0
4521 ,p_copy_entity_txn_id in number
4522 ,p_effective_date in date
4523 ,p_prefix_suffix_text in varchar2 default null
4524 ,p_reuse_object_flag in varchar2 default null
4525 ,p_target_business_group_id in varchar2 default null
4526 ,p_prefix_suffix_cd in varchar2 default null
4527 ) is
4528 --
4529 l_CTFN_RQD_WHEN_RL number;
4530 l_PL_ID number;
4531 l_ENRT_CTFN_TYP_CD varchar2(30);
4532 --
4533 cursor c_unique_BRC(l_table_alias varchar2) is
4534 select distinct cpe.information1,
4535 cpe.information2,
4536 cpe.information3,
4537 cpe.table_route_id
4538 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
4539 pqh_table_route tr
4540 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4541 and cpe.table_route_id = tr.table_route_id
4542 -- and tr.where_clause = l_BEN_BNFT_RSTRN_CTFN_F
4543 and tr.table_alias = l_table_alias
4544 and cpe.number_of_copies = 1 -- ADDITION
4545 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
4546 order by information1, information2; --added for bug: 5151945
4547 --
4548 --
4549 cursor c_BRC_min_max_dates(c_table_route_id number,
4550 c_information1 number) is
4551 select
4552 min(cpe.information2) min_esd,
4553 max(cpe.information3) min_eed
4554 from ben_copy_entity_results cpe
4555 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4556 and cpe.table_route_id = c_table_route_id
4557 and cpe.information1 = c_information1 ;
4558 --
4559 cursor c_BRC(c_table_route_id number,
4560 c_information1 number,
4561 c_information2 date,
4562 c_information3 date) is
4563 select
4564 cpe.*
4565 from ben_copy_entity_results cpe
4566 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4567 and cpe.table_route_id = c_table_route_id
4568 and cpe.information1 = c_information1
4569 and cpe.information2 = c_information2
4570 and cpe.information3 = c_information3
4571 and rownum = 1 ;
4572 -- Date Track target record
4573 cursor c_find_BRC_in_target(
4574 c_effective_start_date date,
4575 c_effective_end_date date,
4576 c_business_group_id number,
4577 c_new_pk_id number) is
4578 select
4579 BRC.bnft_rstrn_ctfn_id new_value
4580 from BEN_BNFT_RSTRN_CTFN_F BRC
4581 where
4582 BRC.PL_ID = l_PL_ID and
4583 nvl(BRC.ENRT_CTFN_TYP_CD, 'XXX') = nvl(l_ENRT_CTFN_TYP_CD, 'XXX') and
4584 BRC.business_group_id = c_business_group_id
4585 and BRC.bnft_rstrn_ctfn_id <> c_new_pk_id
4586 --TEMPIK
4587 and c_effective_start_date between effective_start_date
4588 and effective_end_date ;
4589 --END TEMPIK
4590 /*TEMPIK
4591 and exists ( select null
4592 from BEN_BNFT_RSTRN_CTFN_F BRC1
4593 where
4594 BRC1.PL_ID = l_PL_ID and
4595 BRC1.ENRT_CTFN_TYP_CD = l_ENRT_CTFN_TYP_CD and
4596 BRC1.business_group_id = c_business_group_id
4597 and BRC1.effective_start_date <= c_effective_start_date )
4598 and exists ( select null
4599 from BEN_BNFT_RSTRN_CTFN_F BRC2
4600 where
4601 BRC2.PL_ID = l_PL_ID and
4602 BRC2.ENRT_CTFN_TYP_CD = l_ENRT_CTFN_TYP_CD and
4603 BRC2.business_group_id = c_business_group_id
4604 and BRC2.effective_end_date >= c_effective_end_date )
4605 ;
4606 TEMPIK */
4607 --TEMPIK
4608 l_dt_rec_found boolean ;
4609 --END TEMPIK
4610 --
4611 --UPD START
4612 --
4613 l_update boolean := false ;
4614 l_datetrack_mode varchar2(80) := hr_api.g_update;
4615 l_process_date date;
4616 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
4617 --
4618 --UPD END
4619 l_current_pk_id number := null ;
4620 l_prev_pk_id number := null ;
4621 l_first_rec boolean := true ;
4622 r_BRC c_BRC%rowtype;
4623 l_bnft_rstrn_ctfn_id number ;
4624 l_object_version_number number ;
4625 l_effective_start_date date ;
4626 l_effective_end_date date ;
4627 l_prefix pqh_copy_entity_attribs.information1%type := null;
4628 l_suffix pqh_copy_entity_attribs.information1%type := null;
4629 l_new_value number(15);
4630 l_object_found_in_target boolean := false ;
4631 l_min_esd date;
4632 l_max_eed date;
4633 l_effective_date date;
4634 --
4635 begin
4636 -- Initialization
4637 l_object_found_in_target := false ;
4638 -- End Initialization
4639 -- Derive the prefix - sufix
4640 if p_prefix_suffix_cd = 'PREFIX' then
4641 l_prefix := p_prefix_suffix_text ;
4642 elsif p_prefix_suffix_cd = 'SUFFIX' then
4643 l_suffix := p_prefix_suffix_text ;
4644 else
4645 l_prefix := null ;
4646 l_suffix := null ;
4647 end if ;
4648 -- End Prefix Sufix derivation
4649 for r_BRC_unique in c_unique_BRC('BRC') loop
4650
4651 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
4652 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
4653 r_BRC_unique.information3 >=
4654 ben_pd_copy_to_ben_one.g_copy_effective_date)
4655 ) then
4656
4657 --
4658 hr_utility.set_location(' r_BRC_unique.table_route_id '||r_BRC_unique.table_route_id,10);
4659 hr_utility.set_location(' r_BRC_unique.information1 '||r_BRC_unique.information1,10);
4660 hr_utility.set_location( 'r_BRC_unique.information2 '||r_BRC_unique.information2,10);
4661 hr_utility.set_location( 'r_BRC_unique.information3 '||r_BRC_unique.information3,10);
4662 -- If reuse objects flag is 'Y' then check for the object in the target business group
4663 -- if found insert the record into PLSql table and exit the loop else try create the
4664 -- object in the target business group
4665 --
4666 l_object_found_in_target := false ;
4667 --UPD START
4668 l_update := false;
4669 l_process_date := p_effective_date;
4670 l_dml_operation:= r_BRC_unique.dml_operation ;
4671 --
4672 open c_BRC(r_BRC_unique.table_route_id,
4673 r_BRC_unique.information1,
4674 r_BRC_unique.information2,
4675 r_BRC_unique.information3 ) ;
4676 --
4677 fetch c_BRC into r_BRC ;
4678 --
4679 close c_BRC ;
4680 --
4681
4682 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_BRC.information257,l_dml_operation);
4683 l_PL_ID := get_fk('PL_ID', r_BRC.information261,l_dml_operation);
4684 l_ENRT_CTFN_TYP_CD := r_BRC.information12 ;
4685 --
4686 if l_dml_operation = 'UPDATE' then
4687 --
4688 l_object_found_in_target := TRUE;
4689 --
4690 if l_process_date between r_BRC_unique.information2 and r_BRC_unique.information3 then
4691 l_update := true;
4692 if r_BRC_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
4693 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'BNFT_RSTRN_CTFN_ID'
4694 then
4695 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'BNFT_RSTRN_CTFN_ID' ;
4696 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_BRC_unique.information1 ;
4697 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_BRC_unique.information1 ;
4698 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
4699 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_BRC_unique.table_route_id;
4700 --
4701 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
4702 --
4703 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
4704 --
4705 --DOUBT log_data('BRC',l_new_value,l_prefix || r_BRC_unique.name|| l_suffix,'REUSED');
4706 --
4707 end if ;
4708 hr_utility.set_location( 'found record for update',10);
4709 --
4710 else
4711 --
4712 l_update := false;
4713 --
4714 end if;
4715 else
4716 --
4717 --UPD END
4718
4719 l_min_esd := null ;
4720 l_max_eed := null ;
4721 open c_BRC_min_max_dates(r_BRC_unique.table_route_id, r_BRC_unique.information1 ) ;
4722 fetch c_BRC_min_max_dates into l_min_esd,l_max_eed ;
4723 --
4724
4725 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
4726 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
4727 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
4728 end if;
4729 l_min_esd := greatest(l_min_esd,r_BRC_unique.information2);
4730 --
4731 if p_reuse_object_flag = 'Y' then
4732 if c_BRC_min_max_dates%found then
4733 -- cursor to find the object
4734 open c_find_BRC_in_target( l_min_esd,l_max_eed,
4735 p_target_business_group_id, nvl(l_bnft_rstrn_ctfn_id, -999) ) ;
4736 fetch c_find_BRC_in_target into l_new_value ;
4737 if c_find_BRC_in_target%found then
4738 --
4739 --TEMPIK
4740 l_dt_rec_found := dt_api.check_min_max_dates
4741 (p_base_table_name => 'BEN_BNFT_RSTRN_CTFN_F',
4742 p_base_key_column => 'BNFT_RSTRN_CTFN_ID',
4743 p_base_key_value => l_new_value,
4744 p_from_date => l_min_esd,
4745 p_to_date => l_max_eed );
4746 if l_dt_rec_found THEN
4747 --END TEMPIK
4748 if r_BRC_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
4749 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'BNFT_RSTRN_CTFN_ID' then
4750 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'BNFT_RSTRN_CTFN_ID' ;
4751 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_BRC_unique.information1 ;
4752 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
4753 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
4754 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_BRC_unique.table_route_id;
4755 --
4756 -- 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) ;
4757 --
4758 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
4759 end if ;
4760 --
4761 l_object_found_in_target := true ;
4762 --TEMPIK
4763 end if; -- l_dt_rec_found
4764 --END TEMPIK
4765 end if;
4766 close c_find_BRC_in_target ;
4767 --
4768 end if;
4769 end if ;
4770 --
4771 close c_BRC_min_max_dates ;
4772 end if; --if p_dml_operation
4773 --
4774 if not l_object_found_in_target OR l_update then
4775
4776 --
4777 l_current_pk_id := r_BRC.information1;
4778 --
4779 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
4780 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
4781 --
4782 if l_current_pk_id = l_prev_pk_id then
4783 --
4784 l_first_rec := false ;
4785 --
4786 else
4787 --
4788 l_first_rec := true ;
4789 --
4790 end if ;
4791 --
4792
4793 l_effective_date := r_BRC.information2;
4794 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
4795 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
4796 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
4797 end if;
4798 if l_first_rec and not l_update then
4799 -- Call Create routine.
4800 hr_utility.set_location(' BEN_BNFT_RSTRN_CTFN_F CREATE_BNFT_RSTRN_CTFN ',20);
4801 BEN_BNFT_RSTRN_CTFN_API.CREATE_BNFT_RSTRN_CTFN(
4802 --
4803 P_VALIDATE => false
4804 ,P_EFFECTIVE_DATE => l_effective_date
4805 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
4806 --
4807 ,P_BNFT_RSTRN_CTFN_ID => l_bnft_rstrn_ctfn_id
4808 ,P_BRC_ATTRIBUTE1 => r_BRC.INFORMATION111
4809 ,P_BRC_ATTRIBUTE10 => r_BRC.INFORMATION120
4810 ,P_BRC_ATTRIBUTE11 => r_BRC.INFORMATION121
4811 ,P_BRC_ATTRIBUTE12 => r_BRC.INFORMATION122
4812 ,P_BRC_ATTRIBUTE13 => r_BRC.INFORMATION123
4813 ,P_BRC_ATTRIBUTE14 => r_BRC.INFORMATION124
4814 ,P_BRC_ATTRIBUTE15 => r_BRC.INFORMATION125
4815 ,P_BRC_ATTRIBUTE16 => r_BRC.INFORMATION126
4816 ,P_BRC_ATTRIBUTE17 => r_BRC.INFORMATION127
4817 ,P_BRC_ATTRIBUTE18 => r_BRC.INFORMATION128
4818 ,P_BRC_ATTRIBUTE19 => r_BRC.INFORMATION129
4819 ,P_BRC_ATTRIBUTE2 => r_BRC.INFORMATION112
4820 ,P_BRC_ATTRIBUTE20 => r_BRC.INFORMATION130
4821 ,P_BRC_ATTRIBUTE21 => r_BRC.INFORMATION131
4822 ,P_BRC_ATTRIBUTE22 => r_BRC.INFORMATION132
4823 ,P_BRC_ATTRIBUTE23 => r_BRC.INFORMATION133
4824 ,P_BRC_ATTRIBUTE24 => r_BRC.INFORMATION134
4825 ,P_BRC_ATTRIBUTE25 => r_BRC.INFORMATION135
4826 ,P_BRC_ATTRIBUTE26 => r_BRC.INFORMATION136
4827 ,P_BRC_ATTRIBUTE27 => r_BRC.INFORMATION137
4828 ,P_BRC_ATTRIBUTE28 => r_BRC.INFORMATION138
4829 ,P_BRC_ATTRIBUTE29 => r_BRC.INFORMATION139
4830 ,P_BRC_ATTRIBUTE3 => r_BRC.INFORMATION113
4831 ,P_BRC_ATTRIBUTE30 => r_BRC.INFORMATION140
4832 ,P_BRC_ATTRIBUTE4 => r_BRC.INFORMATION114
4833 ,P_BRC_ATTRIBUTE5 => r_BRC.INFORMATION115
4834 ,P_BRC_ATTRIBUTE6 => r_BRC.INFORMATION116
4835 ,P_BRC_ATTRIBUTE7 => r_BRC.INFORMATION117
4836 ,P_BRC_ATTRIBUTE8 => r_BRC.INFORMATION118
4837 ,P_BRC_ATTRIBUTE9 => r_BRC.INFORMATION119
4838 ,P_BRC_ATTRIBUTE_CATEGORY => r_BRC.INFORMATION110
4839 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
4840 ,P_ENRT_CTFN_TYP_CD => r_BRC.INFORMATION12
4841 ,P_PL_ID => l_PL_ID
4842 ,P_RQD_FLAG => r_BRC.INFORMATION11
4843 --
4844 ,P_EFFECTIVE_START_DATE => l_effective_start_date
4845 ,P_EFFECTIVE_END_DATE => l_effective_end_date
4846 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
4847 );
4848 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
4849 -- Update all relevent cer records with new pk_id
4850 hr_utility.set_location('Before plsql table ',222);
4851 hr_utility.set_location('new_value id '||l_bnft_rstrn_ctfn_id,222);
4852 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'BNFT_RSTRN_CTFN_ID' ;
4853 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_BRC.information1 ;
4854 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_BNFT_RSTRN_CTFN_ID ;
4855 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
4856 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_BRC_unique.table_route_id;
4857 hr_utility.set_location('After plsql table ',222);
4858 --
4859 -- 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 ) ;
4860 --
4861 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
4862 --
4863 else
4864 --
4865 -- Call Update routine for the pk_id created in prev run .
4866 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
4867 hr_utility.set_location(' BEN_BNFT_RSTRN_CTFN_F UPDATE_BNFT_RSTRN_CTFN ',30);
4868 --UPD START
4869 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
4870 --
4871 if l_update then
4872 --
4873 l_datetrack_mode := r_BRC.datetrack_mode ;
4874 --
4875 get_dt_modes(
4876 p_effective_date => l_process_date,
4877 p_effective_end_date => r_BRC.information3,
4878 p_effective_start_date => r_BRC.information2,
4879 p_dml_operation => r_BRC.dml_operation,
4880 p_datetrack_mode => l_datetrack_mode );
4881 -- p_update => l_update
4882 --
4883 l_effective_date := l_process_date;
4884 l_BNFT_RSTRN_CTFN_ID := r_BRC.information1;
4885 l_object_version_number := r_BRC.information265;
4886 --
4887 end if;
4888 --
4889 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
4890 --
4891 IF l_update OR l_dml_operation <> 'UPDATE' THEN
4892 --UPD END
4893
4894 BEN_BNFT_RSTRN_CTFN_API.UPDATE_BNFT_RSTRN_CTFN(
4895 --
4896 P_VALIDATE => false
4897 ,P_EFFECTIVE_DATE => l_effective_date
4898 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
4899 --
4900 ,P_BNFT_RSTRN_CTFN_ID => l_bnft_rstrn_ctfn_id
4901 ,P_BRC_ATTRIBUTE1 => r_BRC.INFORMATION111
4902 ,P_BRC_ATTRIBUTE10 => r_BRC.INFORMATION120
4903 ,P_BRC_ATTRIBUTE11 => r_BRC.INFORMATION121
4904 ,P_BRC_ATTRIBUTE12 => r_BRC.INFORMATION122
4905 ,P_BRC_ATTRIBUTE13 => r_BRC.INFORMATION123
4906 ,P_BRC_ATTRIBUTE14 => r_BRC.INFORMATION124
4907 ,P_BRC_ATTRIBUTE15 => r_BRC.INFORMATION125
4908 ,P_BRC_ATTRIBUTE16 => r_BRC.INFORMATION126
4909 ,P_BRC_ATTRIBUTE17 => r_BRC.INFORMATION127
4910 ,P_BRC_ATTRIBUTE18 => r_BRC.INFORMATION128
4911 ,P_BRC_ATTRIBUTE19 => r_BRC.INFORMATION129
4912 ,P_BRC_ATTRIBUTE2 => r_BRC.INFORMATION112
4913 ,P_BRC_ATTRIBUTE20 => r_BRC.INFORMATION130
4914 ,P_BRC_ATTRIBUTE21 => r_BRC.INFORMATION131
4915 ,P_BRC_ATTRIBUTE22 => r_BRC.INFORMATION132
4916 ,P_BRC_ATTRIBUTE23 => r_BRC.INFORMATION133
4917 ,P_BRC_ATTRIBUTE24 => r_BRC.INFORMATION134
4918 ,P_BRC_ATTRIBUTE25 => r_BRC.INFORMATION135
4919 ,P_BRC_ATTRIBUTE26 => r_BRC.INFORMATION136
4920 ,P_BRC_ATTRIBUTE27 => r_BRC.INFORMATION137
4921 ,P_BRC_ATTRIBUTE28 => r_BRC.INFORMATION138
4922 ,P_BRC_ATTRIBUTE29 => r_BRC.INFORMATION139
4923 ,P_BRC_ATTRIBUTE3 => r_BRC.INFORMATION113
4924 ,P_BRC_ATTRIBUTE30 => r_BRC.INFORMATION140
4925 ,P_BRC_ATTRIBUTE4 => r_BRC.INFORMATION114
4926 ,P_BRC_ATTRIBUTE5 => r_BRC.INFORMATION115
4927 ,P_BRC_ATTRIBUTE6 => r_BRC.INFORMATION116
4928 ,P_BRC_ATTRIBUTE7 => r_BRC.INFORMATION117
4929 ,P_BRC_ATTRIBUTE8 => r_BRC.INFORMATION118
4930 ,P_BRC_ATTRIBUTE9 => r_BRC.INFORMATION119
4931 ,P_BRC_ATTRIBUTE_CATEGORY => r_BRC.INFORMATION110
4932 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
4933 ,P_ENRT_CTFN_TYP_CD => r_BRC.INFORMATION12
4934 ,P_PL_ID => l_PL_ID
4935 ,P_RQD_FLAG => r_BRC.INFORMATION11
4936 --
4937 ,P_EFFECTIVE_START_DATE => l_effective_start_date
4938 ,P_EFFECTIVE_END_DATE => l_effective_end_date
4939 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
4940 ,P_DATETRACK_MODE => l_datetrack_mode
4941 );
4942 --
4943 end if; -- l_update
4944 end if;
4945 --
4946 -- Delete the row if it is end dated.
4947 --
4948 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
4949 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
4950 trunc(l_max_eed) = r_BRC.information3) then
4951 --
4952 BEN_BNFT_RSTRN_CTFN_API.delete_BNFT_RSTRN_CTFN(
4953 --
4954 p_validate => false
4955 ,p_bnft_rstrn_ctfn_id => l_bnft_rstrn_ctfn_id
4956 ,p_effective_start_date => l_effective_start_date
4957 ,p_effective_end_date => l_effective_end_date
4958 ,p_object_version_number => l_object_version_number
4959 ,p_effective_date => l_max_eed
4960 ,p_datetrack_mode => hr_api.g_delete
4961 --
4962 );
4963 --
4964 end if;
4965 --
4966 l_prev_pk_id := l_current_pk_id ;
4967 --
4968 end if;
4969 --
4970 end if;
4971 --
4972 end loop;
4973 --
4974 exception when others then
4975 --
4976 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'BRC',r_brc.information5 );
4977 --
4978 end create_BRC_rows;
4979
4980 --
4981 ---------------------------------------------------------------
4982 ----------------------< create_WCN_rows >-----------------------
4983 ---------------------------------------------------------------
4984 --
4985 procedure create_WCN_rows
4986 (
4987 p_validate in number default 0
4988 ,p_copy_entity_txn_id in number
4989 ,p_effective_date in date
4990 ,p_prefix_suffix_text in varchar2 default null
4991 ,p_reuse_object_flag in varchar2 default null
4992 ,p_target_business_group_id in varchar2 default null
4993 ,p_prefix_suffix_cd in varchar2 default null
4994 ) is
4995 --
4996 l_CTFN_RQD_WHEN_RL number;
4997 l_WV_PRTN_RSN_PL_ID number;
4998 l_WV_PRTN_CTFN_TYP_CD varchar2(30);
4999 --
5000 cursor c_unique_WCN(l_table_alias varchar2) is
5001 select distinct cpe.information1,
5002 cpe.information2,
5003 cpe.information3,
5004 cpe.table_route_id
5005 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
5006 pqh_table_route tr
5007 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5008 and cpe.table_route_id = tr.table_route_id
5009 -- and tr.where_clause = l_BEN_WV_PRTN_RSN_CTFN_PL_F
5010 and tr.table_alias = l_table_alias
5011 and cpe.number_of_copies = 1 -- ADDITION
5012 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
5013 order by information1, information2; --added for bug: 5151945
5014 --
5015 --
5016 cursor c_WCN_min_max_dates(c_table_route_id number,
5017 c_information1 number) is
5018 select
5019 min(cpe.information2) min_esd,
5020 max(cpe.information3) min_eed
5021 from ben_copy_entity_results cpe
5022 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5023 and cpe.table_route_id = c_table_route_id
5024 and cpe.information1 = c_information1 ;
5025 --
5026 cursor c_WCN(c_table_route_id number,
5027 c_information1 number,
5028 c_information2 date,
5029 c_information3 date ) is
5030 select
5031 cpe.*
5032 from ben_copy_entity_results cpe
5033 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5034 and cpe.table_route_id = c_table_route_id
5035 and cpe.information1 = c_information1
5036 and cpe.information2 = c_information2
5037 and cpe.information3 = c_information3
5038 and rownum = 1 ;
5039 -- Date Track target record
5040 cursor c_find_WCN_in_target(
5041 c_effective_start_date date,
5042 c_effective_end_date date,
5043 c_business_group_id number,
5044 c_new_pk_id number) is
5045 select
5046 WCN.wv_prtn_rsn_ctfn_pl_id new_value
5047 from BEN_WV_PRTN_RSN_CTFN_PL_F WCN
5048 where
5049 WCN.WV_PRTN_RSN_PL_ID = l_WV_PRTN_RSN_PL_ID and
5050 WCN.WV_PRTN_CTFN_TYP_CD = l_WV_PRTN_CTFN_TYP_CD and
5051 WCN.business_group_id = c_business_group_id
5052 and WCN.wv_prtn_rsn_ctfn_pl_id <> c_new_pk_id
5053 --TEMPIK
5054 and c_effective_start_date between effective_start_date
5055 and effective_end_date ;
5056 --END TEMPIK
5057 /*TEMPIK
5058 and exists ( select null
5059 from BEN_WV_PRTN_RSN_CTFN_PL_F WCN1
5060 where
5061 WCN1.WV_PRTN_RSN_PL_ID = l_WV_PRTN_RSN_PL_ID and
5062 WCN1.WV_PRTN_CTFN_TYP_CD = l_WV_PRTN_CTFN_TYP_CD and
5063 WCN1.business_group_id = c_business_group_id
5064 and WCN1.effective_start_date <= c_effective_start_date )
5065 and exists ( select null
5066 from BEN_WV_PRTN_RSN_CTFN_PL_F WCN2
5067 where
5068 WCN2.WV_PRTN_RSN_PL_ID = l_WV_PRTN_RSN_PL_ID and
5069 WCN2.WV_PRTN_CTFN_TYP_CD = l_WV_PRTN_CTFN_TYP_CD and
5070 WCN2.business_group_id = c_business_group_id
5071 and WCN2.effective_end_date >= c_effective_end_date )
5072 ;
5073 TEMPIK */
5074 --TEMPIK
5075 l_dt_rec_found boolean ;
5076 --END TEMPIK
5077 --
5078 --UPD START
5079 --
5080 l_update boolean := false ;
5081 l_datetrack_mode varchar2(80) := hr_api.g_update;
5082 l_process_date date;
5083 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
5084 --
5085 --UPD END
5086
5087 l_current_pk_id number := null ;
5088 l_prev_pk_id number := null ;
5089 l_first_rec boolean := true ;
5090 r_WCN c_WCN%rowtype;
5091 l_wv_prtn_rsn_ctfn_pl_id number ;
5092 l_object_version_number number ;
5093 l_effective_start_date date ;
5094 l_effective_end_date date ;
5095 l_prefix pqh_copy_entity_attribs.information1%type := null;
5096 l_suffix pqh_copy_entity_attribs.information1%type := null;
5097 l_new_value number(15);
5098 l_object_found_in_target boolean := false ;
5099 l_min_esd date;
5100 l_max_eed date;
5101 l_effective_date date;
5102 --
5103 begin
5104 -- Initialization
5105 l_object_found_in_target := false ;
5106 -- End Initialization
5107 -- Derive the prefix - sufix
5108 if p_prefix_suffix_cd = 'PREFIX' then
5109 l_prefix := p_prefix_suffix_text ;
5110 elsif p_prefix_suffix_cd = 'SUFFIX' then
5111 l_suffix := p_prefix_suffix_text ;
5112 else
5113 l_prefix := null ;
5114 l_suffix := null ;
5115 end if ;
5116 -- End Prefix Sufix derivation
5117 for r_WCN_unique in c_unique_WCN('WCN') loop
5118
5119 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
5120 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
5121 r_WCN_unique.information3 >=
5122 ben_pd_copy_to_ben_one.g_copy_effective_date)
5123 ) then
5124 --
5125 hr_utility.set_location(' r_WCN_unique.table_route_id '||r_WCN_unique.table_route_id,10);
5126 hr_utility.set_location(' r_WCN_unique.information1 '||r_WCN_unique.information1,10);
5127 hr_utility.set_location( 'r_WCN_unique.information2 '||r_WCN_unique.information2,10);
5128 hr_utility.set_location( 'r_WCN_unique.information3 '||r_WCN_unique.information3,10);
5129 -- If reuse objects flag is 'Y' then check for the object in the target business group
5130 -- if found insert the record into PLSql table and exit the loop else try create the
5131 -- object in the target business group
5132 --
5133 l_object_found_in_target := false ;
5134 --UPD START
5135 open c_WCN(r_WCN_unique.table_route_id,
5136 r_WCN_unique.information1,
5137 r_WCN_unique.information2,
5138 r_WCN_unique.information3 ) ;
5139 --
5140 fetch c_WCN into r_WCN ;
5141 --
5142 close c_WCN ;
5143 --
5144 l_dml_operation:= r_WCN_unique.dml_operation ;
5145 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_WCN.INFORMATION261,l_dml_operation);
5146 l_WV_PRTN_RSN_PL_ID := get_fk('WV_PRTN_RSN_PL_ID', r_WCN.INFORMATION257,l_dml_operation);
5147 l_WV_PRTN_CTFN_TYP_CD := r_WCN.information14 ;
5148 --
5149 l_update := false;
5150 l_process_date := p_effective_date;
5151 --
5152 if l_dml_operation = 'UPDATE' then
5153 --
5154 l_object_found_in_target := TRUE;
5155 --
5156 if l_process_date between r_WCN_unique.information2 and r_WCN_unique.information3 then
5157 l_update := true;
5158 if r_WCN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
5159 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'WV_PRTN_RSN_CTFN_PL_ID'
5160 then
5161 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'WV_PRTN_RSN_CTFN_PL_ID' ;
5162 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_WCN_unique.information1 ;
5163 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_WCN_unique.information1 ;
5164 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
5165 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_WCN_unique.table_route_id;
5166 --
5167 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
5168 --
5169 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
5170 --
5171 --DOUBT log_data('WCN',l_new_value,l_prefix || r_WCN_unique.name|| l_suffix,'REUSED');
5172 --
5173 end if ;
5174 hr_utility.set_location( 'found record for update',10);
5175 --
5176 else
5177 --
5178 l_update := false;
5179 --
5180 end if;
5181 else
5182 --
5183 --UPD END
5184 l_min_esd := null ;
5185 l_max_eed := null ;
5186 open c_WCN_min_max_dates(r_WCN_unique.table_route_id, r_WCN_unique.information1 ) ;
5187 fetch c_WCN_min_max_dates into l_min_esd,l_max_eed ;
5188 --
5189
5190 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
5191 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
5192 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
5193 end if;
5194 l_min_esd := greatest(l_min_esd,r_WCN_unique.information2);
5195 /* open c_WCN(r_WCN_unique.table_route_id,
5196 r_WCN_unique.information1,
5197 r_WCN_unique.information2,
5198 r_WCN_unique.information3 ) ;
5199 --
5200 fetch c_WCN into r_WCN ;
5201 --
5202 close c_WCN ; */
5203 --
5204
5205 if p_reuse_object_flag = 'Y' then
5206 if c_WCN_min_max_dates%found then
5207 -- cursor to find the object
5208 open c_find_WCN_in_target( l_min_esd,l_max_eed,
5209 p_target_business_group_id, nvl(l_wv_prtn_rsn_ctfn_pl_id, -999) ) ;
5210 fetch c_find_WCN_in_target into l_new_value ;
5211 if c_find_WCN_in_target%found then
5212 --
5213 --TEMPIK
5214 l_dt_rec_found := dt_api.check_min_max_dates
5215 (p_base_table_name => 'BEN_WV_PRTN_RSN_CTFN_PL_F',
5216 p_base_key_column => 'WV_PRTN_RSN_CTFN_PL_ID',
5217 p_base_key_value => l_new_value,
5218 p_from_date => l_min_esd,
5219 p_to_date => l_max_eed );
5220 if l_dt_rec_found THEN
5221 --END TEMPIK
5222 if r_WCN_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
5223 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'WV_PRTN_RSN_CTFN_PL_ID' then
5224 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'WV_PRTN_RSN_CTFN_PL_ID' ;
5225 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_WCN_unique.information1 ;
5226 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
5227 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
5228 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_WCN_unique.table_route_id;
5229 --
5230 -- 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) ;
5231 --
5232 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
5233 end if ;
5234 --
5235 l_object_found_in_target := true ;
5236 --TEMPIK
5237 end if; -- l_dt_rec_found
5238 --END TEMPIK
5239 end if;
5240 close c_find_WCN_in_target ;
5241 --
5242 end if;
5243 end if ;
5244 --
5245 close c_WCN_min_max_dates ;
5246 end if; --if p_dml_operation
5247 --
5248 if not l_object_found_in_target OR l_update then
5249 --
5250 l_current_pk_id := r_WCN.information1;
5251 --
5252 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
5253 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
5254 --
5255 if l_current_pk_id = l_prev_pk_id then
5256 --
5257 l_first_rec := false ;
5258 --
5259 else
5260 --
5261 l_first_rec := true ;
5262 --
5263 end if ;
5264 --
5265
5266 l_effective_date := r_WCN.information2;
5267 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
5268 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
5269 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
5270 end if;
5271
5272 if l_first_rec and not l_update then
5273 -- Call Create routine.
5274 hr_utility.set_location(' BEN_WV_PRTN_RSN_CTFN_PL_F CREATE_WV_PRTN_RSN_CTFN_PL ',20);
5275 BEN_WV_PRTN_RSN_CTFN_PL_API.CREATE_WV_PRTN_RSN_CTFN_PL(
5276 --
5277 P_VALIDATE => false
5278 ,P_EFFECTIVE_DATE => l_effective_date
5279 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5280 --
5281 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
5282 ,P_LACK_CTFN_SSPND_WVR_FLAG => r_WCN.INFORMATION12
5283 ,P_PFD_FLAG => r_WCN.INFORMATION11
5284 ,P_RQD_FLAG => r_WCN.INFORMATION13
5285 ,P_WCN_ATTRIBUTE1 => r_WCN.INFORMATION111
5286 ,P_WCN_ATTRIBUTE10 => r_WCN.INFORMATION120
5287 ,P_WCN_ATTRIBUTE11 => r_WCN.INFORMATION121
5288 ,P_WCN_ATTRIBUTE12 => r_WCN.INFORMATION122
5289 ,P_WCN_ATTRIBUTE13 => r_WCN.INFORMATION123
5290 ,P_WCN_ATTRIBUTE14 => r_WCN.INFORMATION124
5291 ,P_WCN_ATTRIBUTE15 => r_WCN.INFORMATION125
5292 ,P_WCN_ATTRIBUTE16 => r_WCN.INFORMATION126
5293 ,P_WCN_ATTRIBUTE17 => r_WCN.INFORMATION127
5294 ,P_WCN_ATTRIBUTE18 => r_WCN.INFORMATION128
5295 ,P_WCN_ATTRIBUTE19 => r_WCN.INFORMATION129
5296 ,P_WCN_ATTRIBUTE2 => r_WCN.INFORMATION112
5297 ,P_WCN_ATTRIBUTE20 => r_WCN.INFORMATION130
5298 ,P_WCN_ATTRIBUTE21 => r_WCN.INFORMATION131
5299 ,P_WCN_ATTRIBUTE22 => r_WCN.INFORMATION132
5300 ,P_WCN_ATTRIBUTE23 => r_WCN.INFORMATION133
5301 ,P_WCN_ATTRIBUTE24 => r_WCN.INFORMATION134
5302 ,P_WCN_ATTRIBUTE25 => r_WCN.INFORMATION135
5303 ,P_WCN_ATTRIBUTE26 => r_WCN.INFORMATION136
5304 ,P_WCN_ATTRIBUTE27 => r_WCN.INFORMATION137
5305 ,P_WCN_ATTRIBUTE28 => r_WCN.INFORMATION138
5306 ,P_WCN_ATTRIBUTE29 => r_WCN.INFORMATION139
5307 ,P_WCN_ATTRIBUTE3 => r_WCN.INFORMATION113
5308 ,P_WCN_ATTRIBUTE30 => r_WCN.INFORMATION140
5309 ,P_WCN_ATTRIBUTE4 => r_WCN.INFORMATION114
5310 ,P_WCN_ATTRIBUTE5 => r_WCN.INFORMATION115
5311 ,P_WCN_ATTRIBUTE6 => r_WCN.INFORMATION116
5312 ,P_WCN_ATTRIBUTE7 => r_WCN.INFORMATION117
5313 ,P_WCN_ATTRIBUTE8 => r_WCN.INFORMATION118
5314 ,P_WCN_ATTRIBUTE9 => r_WCN.INFORMATION119
5315 ,P_WCN_ATTRIBUTE_CATEGORY => r_WCN.INFORMATION110
5316 ,P_WV_PRTN_CTFN_TYP_CD => r_WCN.INFORMATION14
5317 ,P_WV_PRTN_RSN_CTFN_PL_ID => l_wv_prtn_rsn_ctfn_pl_id
5318 ,P_WV_PRTN_RSN_PL_ID => l_WV_PRTN_RSN_PL_ID
5319 --
5320 ,P_EFFECTIVE_START_DATE => l_effective_start_date
5321 ,P_EFFECTIVE_END_DATE => l_effective_end_date
5322 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5323 );
5324 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
5325 -- Update all relevent cer records with new pk_id
5326 hr_utility.set_location('Before plsql table ',222);
5327 hr_utility.set_location('new_value id '||l_wv_prtn_rsn_ctfn_pl_id,222);
5328 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'WV_PRTN_RSN_CTFN_PL_ID' ;
5329 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_WCN.information1 ;
5330 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_WV_PRTN_RSN_CTFN_PL_ID ;
5331 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
5332 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_WCN_unique.table_route_id;
5333 hr_utility.set_location('After plsql table ',222);
5334 --
5335 -- 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 ) ;
5336 --
5337 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
5338 --
5339 else
5340 --
5341 -- Call Update routine for the pk_id created in prev run .
5342 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
5343 hr_utility.set_location(' BEN_WV_PRTN_RSN_CTFN_PL_F UPDATE_WV_PRTN_RSN_CTFN_PL ',30);
5344 --UPD START
5345 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
5346 --
5347 if l_update then
5348 --
5349 l_datetrack_mode := r_WCN.datetrack_mode ;
5350 --
5351 get_dt_modes(
5352 p_effective_date => l_process_date,
5353 p_effective_end_date => r_WCN.information3,
5354 p_effective_start_date => r_WCN.information2,
5355 p_dml_operation => r_WCN.dml_operation,
5356 p_datetrack_mode => l_datetrack_mode );
5357 -- p_update => l_update
5358 --
5359 l_effective_date := l_process_date;
5360 l_WV_PRTN_RSN_CTFN_PL_ID := r_WCN.information1;
5361 l_object_version_number := r_WCN.information265;
5362 --
5363 end if;
5364 --
5365 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
5366 --
5367 IF l_update OR l_dml_operation <> 'UPDATE' THEN
5368 --UPD END
5369
5370 BEN_WV_PRTN_RSN_CTFN_PL_API.UPDATE_WV_PRTN_RSN_CTFN_PL(
5371 --
5372 P_VALIDATE => false
5373 ,P_EFFECTIVE_DATE => l_effective_date
5374 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5375 --
5376 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
5377 ,P_LACK_CTFN_SSPND_WVR_FLAG => r_WCN.INFORMATION12
5378 ,P_PFD_FLAG => r_WCN.INFORMATION11
5379 ,P_RQD_FLAG => r_WCN.INFORMATION13
5380 ,P_WCN_ATTRIBUTE1 => r_WCN.INFORMATION111
5381 ,P_WCN_ATTRIBUTE10 => r_WCN.INFORMATION120
5382 ,P_WCN_ATTRIBUTE11 => r_WCN.INFORMATION121
5383 ,P_WCN_ATTRIBUTE12 => r_WCN.INFORMATION122
5384 ,P_WCN_ATTRIBUTE13 => r_WCN.INFORMATION123
5385 ,P_WCN_ATTRIBUTE14 => r_WCN.INFORMATION124
5386 ,P_WCN_ATTRIBUTE15 => r_WCN.INFORMATION125
5387 ,P_WCN_ATTRIBUTE16 => r_WCN.INFORMATION126
5388 ,P_WCN_ATTRIBUTE17 => r_WCN.INFORMATION127
5389 ,P_WCN_ATTRIBUTE18 => r_WCN.INFORMATION128
5390 ,P_WCN_ATTRIBUTE19 => r_WCN.INFORMATION129
5391 ,P_WCN_ATTRIBUTE2 => r_WCN.INFORMATION112
5392 ,P_WCN_ATTRIBUTE20 => r_WCN.INFORMATION130
5393 ,P_WCN_ATTRIBUTE21 => r_WCN.INFORMATION131
5394 ,P_WCN_ATTRIBUTE22 => r_WCN.INFORMATION132
5395 ,P_WCN_ATTRIBUTE23 => r_WCN.INFORMATION133
5396 ,P_WCN_ATTRIBUTE24 => r_WCN.INFORMATION134
5397 ,P_WCN_ATTRIBUTE25 => r_WCN.INFORMATION135
5398 ,P_WCN_ATTRIBUTE26 => r_WCN.INFORMATION136
5399 ,P_WCN_ATTRIBUTE27 => r_WCN.INFORMATION137
5400 ,P_WCN_ATTRIBUTE28 => r_WCN.INFORMATION138
5401 ,P_WCN_ATTRIBUTE29 => r_WCN.INFORMATION139
5402 ,P_WCN_ATTRIBUTE3 => r_WCN.INFORMATION113
5403 ,P_WCN_ATTRIBUTE30 => r_WCN.INFORMATION140
5404 ,P_WCN_ATTRIBUTE4 => r_WCN.INFORMATION114
5405 ,P_WCN_ATTRIBUTE5 => r_WCN.INFORMATION115
5406 ,P_WCN_ATTRIBUTE6 => r_WCN.INFORMATION116
5407 ,P_WCN_ATTRIBUTE7 => r_WCN.INFORMATION117
5408 ,P_WCN_ATTRIBUTE8 => r_WCN.INFORMATION118
5409 ,P_WCN_ATTRIBUTE9 => r_WCN.INFORMATION119
5410 ,P_WCN_ATTRIBUTE_CATEGORY => r_WCN.INFORMATION110
5411 ,P_WV_PRTN_CTFN_TYP_CD => r_WCN.INFORMATION14
5412 ,P_WV_PRTN_RSN_CTFN_PL_ID => l_wv_prtn_rsn_ctfn_pl_id
5413 ,P_WV_PRTN_RSN_PL_ID => l_WV_PRTN_RSN_PL_ID
5414 --
5415 ,P_EFFECTIVE_START_DATE => l_effective_start_date
5416 ,P_EFFECTIVE_END_DATE => l_effective_end_date
5417 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5418 ,P_DATETRACK_MODE => l_datetrack_mode
5419
5420 );
5421 --
5422 end if; -- l_update
5423 end if;
5424 --
5425 -- Delete the row if it is end dated.
5426 --
5427 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
5428 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
5429 trunc(l_max_eed) = r_WCN.information3) then
5430 --
5431 BEN_WV_PRTN_RSN_CTFN_PL_API.delete_WV_PRTN_RSN_CTFN_PL(
5432 --
5433 p_validate => false
5434 ,p_wv_prtn_rsn_ctfn_pl_id => l_wv_prtn_rsn_ctfn_pl_id
5435 ,p_effective_start_date => l_effective_start_date
5436 ,p_effective_end_date => l_effective_end_date
5437 ,p_object_version_number => l_object_version_number
5438 ,p_effective_date => l_max_eed
5439 ,p_datetrack_mode => hr_api.g_delete
5440 --
5441 );
5442 --
5443 end if;
5444 --
5445 l_prev_pk_id := l_current_pk_id ;
5446 --
5447 end if;
5448 --
5449 end if;
5450 --
5451 end loop;
5452 --
5453 exception when others then
5454 --
5455 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'WCN',r_wcn.information5 );
5456 --
5457 end create_WCN_rows;
5458
5459 --
5460 ---------------------------------------------------------------
5461 ----------------------< create_WPN_rows >-----------------------
5462 ---------------------------------------------------------------
5463 --
5464 procedure create_WPN_rows
5465 (
5466 p_validate in number default 0
5467 ,p_copy_entity_txn_id in number
5468 ,p_effective_date in date
5469 ,p_prefix_suffix_text in varchar2 default null
5470 ,p_reuse_object_flag in varchar2 default null
5471 ,p_target_business_group_id in varchar2 default null
5472 ,p_prefix_suffix_cd in varchar2 default null
5473 ) is
5474 --
5475 l_PL_ID number;
5476 l_WV_PRTN_RSN_CD varchar2(30);
5477 --
5478 cursor c_unique_WPN(l_table_alias varchar2) is
5479 select distinct cpe.information1,
5480 cpe.information2,
5481 cpe.information3,
5482 cpe.table_route_id
5483 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
5484 pqh_table_route tr
5485 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5486 and cpe.table_route_id = tr.table_route_id
5487 -- and tr.where_clause = l_BEN_WV_PRTN_RSN_PL_F
5488 and tr.table_alias = l_table_alias
5489 and cpe.number_of_copies = 1 -- ADDITION
5490 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
5491 order by information1, information2; --added for bug: 5151945
5492 --
5493 --
5494 cursor c_WPN_min_max_dates(c_table_route_id number,
5495 c_information1 number) is
5496 select
5497 min(cpe.information2) min_esd,
5498 max(cpe.information3) min_eed
5499 from ben_copy_entity_results cpe
5500 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5501 and cpe.table_route_id = c_table_route_id
5502 and cpe.information1 = c_information1 ;
5503 --
5504 cursor c_WPN(c_table_route_id number,
5505 c_information1 number,
5506 c_information2 date,
5507 c_information3 date ) is
5508 select
5509 cpe.*
5510 from ben_copy_entity_results cpe
5511 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5512 and cpe.table_route_id = c_table_route_id
5513 and cpe.information1 = c_information1
5514 and cpe.information2 = c_information2
5515 and cpe.information3 = c_information3
5516 and rownum = 1 ;
5517 -- Date Track target record
5518 cursor c_find_WPN_in_target(
5519 c_effective_start_date date,
5520 c_effective_end_date date,
5521 c_business_group_id number,
5522 c_new_pk_id number) is
5523 select
5524 WPN.wv_prtn_rsn_pl_id new_value
5525 from BEN_WV_PRTN_RSN_PL_F WPN
5526 where
5527 WPN.PL_ID = l_PL_ID and
5528 WPN.WV_PRTN_RSN_CD = l_WV_PRTN_RSN_CD and
5529 WPN.business_group_id = c_business_group_id
5530 and WPN.wv_prtn_rsn_pl_id <> c_new_pk_id
5531 --TEMPIK
5532 and c_effective_start_date between effective_start_date
5533 and effective_end_date ;
5534 --END TEMPIK
5535 /*TEMPIK
5536 and exists ( select null
5537 from BEN_WV_PRTN_RSN_PL_F WPN1
5538 where
5539 WPN1.PL_ID = l_PL_ID and
5540 WPN1.WV_PRTN_RSN_CD = l_WV_PRTN_RSN_CD and
5541 WPN1.business_group_id = c_business_group_id
5542 and WPN1.effective_start_date <= c_effective_start_date )
5543 and exists ( select null
5544 from BEN_WV_PRTN_RSN_PL_F WPN2
5545 where
5546 WPN2.PL_ID = l_PL_ID and
5547 WPN2.WV_PRTN_RSN_CD = l_WV_PRTN_RSN_CD and
5548 WPN2.business_group_id = c_business_group_id
5549 and WPN2.effective_end_date >= c_effective_end_date )
5550 ;
5551 TEMPIK */
5552 --TEMPIK
5553 l_dt_rec_found boolean ;
5554 --END TEMPIK
5555 --
5556 --UPD START
5557 --
5558 l_update boolean := false ;
5559 l_datetrack_mode varchar2(80) := hr_api.g_update;
5560 l_process_date date;
5561 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
5562 --
5563 --UPD END
5564 l_current_pk_id number := null ;
5565 l_prev_pk_id number := null ;
5566 l_first_rec boolean := true ;
5567 r_WPN c_WPN%rowtype;
5568 l_wv_prtn_rsn_pl_id number ;
5569 l_object_version_number number ;
5570 l_effective_start_date date ;
5571 l_effective_end_date date ;
5572 l_prefix pqh_copy_entity_attribs.information1%type := null;
5573 l_suffix pqh_copy_entity_attribs.information1%type := null;
5574 l_new_value number(15);
5575 l_object_found_in_target boolean := false ;
5576 l_min_esd date;
5577 l_max_eed date;
5578 l_effective_date date;
5579 --
5580 begin
5581 -- Initialization
5582 l_object_found_in_target := false ;
5583 -- End Initialization
5584 -- Derive the prefix - sufix
5585 if p_prefix_suffix_cd = 'PREFIX' then
5586 l_prefix := p_prefix_suffix_text ;
5587 elsif p_prefix_suffix_cd = 'SUFFIX' then
5588 l_suffix := p_prefix_suffix_text ;
5589 else
5590 l_prefix := null ;
5591 l_suffix := null ;
5592 end if ;
5593 -- End Prefix Sufix derivation
5594 for r_WPN_unique in c_unique_WPN('WPN') loop
5595
5596 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
5597 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
5598 r_WPN_unique.information3 >=
5599 ben_pd_copy_to_ben_one.g_copy_effective_date)
5600 ) then
5601
5602 --
5603 hr_utility.set_location(' r_WPN_unique.table_route_id '||r_WPN_unique.table_route_id,10);
5604 hr_utility.set_location(' r_WPN_unique.information1 '||r_WPN_unique.information1,10);
5605 hr_utility.set_location( 'r_WPN_unique.information2 '||r_WPN_unique.information2,10);
5606 hr_utility.set_location( 'r_WPN_unique.information3 '||r_WPN_unique.information3,10);
5607 -- If reuse objects flag is 'Y' then check for the object in the target business group
5608 -- if found insert the record into PLSql table and exit the loop else try create the
5609 -- object in the target business group
5610 --
5611 l_object_found_in_target := false ;
5612 --UPD START
5613 open c_WPN(r_WPN_unique.table_route_id,
5614 r_WPN_unique.information1,
5615 r_WPN_unique.information2,
5616 r_WPN_unique.information3 ) ;
5617 --
5618 fetch c_WPN into r_WPN ;
5619 --
5620 close c_WPN ;
5621 --
5622 l_dml_operation:= r_WPN_unique.dml_operation ;
5623 l_PL_ID := get_fk('PL_ID', r_WPN.INFORMATION261,l_dml_operation);
5624 l_WV_PRTN_RSN_CD := r_WPN.information12 ;
5625 --
5626 l_update := false;
5627 l_process_date := p_effective_date;
5628 --
5629 if l_dml_operation = 'UPDATE' then
5630 --
5631 l_object_found_in_target := TRUE;
5632 --
5633 if l_process_date between r_WPN_unique.information2 and r_WPN_unique.information3 then
5634 l_update := true;
5635 if r_WPN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
5636 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'WV_PRTN_RSN_PL_ID'
5637 then
5638 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'WV_PRTN_RSN_PL_ID' ;
5639 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_WPN_unique.information1 ;
5640 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_WPN_unique.information1 ;
5641 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
5642 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_WPN_unique.table_route_id;
5643 --
5644 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
5645 --
5646 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
5647 --
5648 -- DOUBT log_data('WPN',l_new_value,l_prefix || r_WPN_unique.name|| l_suffix,'REUSED');
5649 --
5650 end if ;
5651 hr_utility.set_location( 'found record for update',10);
5652 --
5653 else
5654 --
5655 l_update := false;
5656 --
5657 end if;
5658 else
5659 --
5660 --UPD END
5661 l_min_esd := null ;
5662 l_max_eed := null ;
5663 open c_WPN_min_max_dates(r_WPN_unique.table_route_id, r_WPN_unique.information1 ) ;
5664 fetch c_WPN_min_max_dates into l_min_esd,l_max_eed ;
5665 --
5666
5667 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
5668 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
5669 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
5670 end if;
5671 l_min_esd := greatest(l_min_esd,r_WPN_unique.information2);
5672 /* open c_WPN(r_WPN_unique.table_route_id,
5673 r_WPN_unique.information1,
5674 r_WPN_unique.information2,
5675 r_WPN_unique.information3 ) ;
5676 --
5677 fetch c_WPN into r_WPN ;
5678 --
5679 close c_WPN ; */
5680 --
5681 if p_reuse_object_flag = 'Y' then
5682 if c_WPN_min_max_dates%found then
5683 -- cursor to find the object
5684 open c_find_WPN_in_target( l_min_esd,l_max_eed,
5685 p_target_business_group_id, nvl(l_wv_prtn_rsn_pl_id, -999) ) ;
5686 fetch c_find_WPN_in_target into l_new_value ;
5687 if c_find_WPN_in_target%found then
5688 --
5689 --TEMPIK
5690 l_dt_rec_found := dt_api.check_min_max_dates
5691 (p_base_table_name => 'BEN_WV_PRTN_RSN_PL_F',
5692 p_base_key_column => 'WV_PRTN_RSN_PL_ID',
5693 p_base_key_value => l_new_value,
5694 p_from_date => l_min_esd,
5695 p_to_date => l_max_eed );
5696 if l_dt_rec_found THEN
5697 --END TEMPIK
5698 if r_WPN_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
5699 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'WV_PRTN_RSN_PL_ID' then
5700 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'WV_PRTN_RSN_PL_ID' ;
5701 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_WPN_unique.information1 ;
5702 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
5703 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
5704 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_WPN_unique.table_route_id;
5705 --
5706 -- 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) ;
5707 --
5708 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
5709 end if ;
5710 --
5711 l_object_found_in_target := true ;
5712 --TEMPIK
5713 end if; -- l_dt_rec_found
5714 --END TEMPIK
5715 end if;
5716 close c_find_WPN_in_target ;
5717 --
5718 end if;
5719 end if ;
5720 --
5721 close c_WPN_min_max_dates ;
5722 end if; --if p_dml_operation
5723 --
5724 if not l_object_found_in_target OR l_update then
5725 --
5726 l_current_pk_id := r_WPN.information1;
5727 --
5728 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
5729 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
5730 --
5731 if l_current_pk_id = l_prev_pk_id then
5732 --
5733 l_first_rec := false ;
5734 --
5735 else
5736 --
5737 l_first_rec := true ;
5738 --
5739 end if ;
5740 --
5741
5742 l_effective_date := r_WPN.information2;
5743 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
5744 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
5745 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
5746 end if;
5747
5748 if l_first_rec and not l_update then
5749 -- Call Create routine.
5750 hr_utility.set_location(' BEN_WV_PRTN_RSN_PL_F CREATE_WV_PRTN_REASON_PL ',20);
5751 BEN_WV_PRTN_REASON_PL_API.CREATE_WV_PRTN_REASON_PL(
5752 --
5753 P_VALIDATE => false
5754 ,P_EFFECTIVE_DATE => l_effective_date
5755 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5756 --
5757 ,P_DFLT_FLAG => r_WPN.INFORMATION11
5758 ,P_PL_ID => l_PL_ID
5759 ,P_WPN_ATTRIBUTE1 => r_WPN.INFORMATION111
5760 ,P_WPN_ATTRIBUTE10 => r_WPN.INFORMATION120
5761 ,P_WPN_ATTRIBUTE11 => r_WPN.INFORMATION121
5762 ,P_WPN_ATTRIBUTE12 => r_WPN.INFORMATION122
5763 ,P_WPN_ATTRIBUTE13 => r_WPN.INFORMATION123
5764 ,P_WPN_ATTRIBUTE14 => r_WPN.INFORMATION124
5765 ,P_WPN_ATTRIBUTE15 => r_WPN.INFORMATION125
5766 ,P_WPN_ATTRIBUTE16 => r_WPN.INFORMATION126
5767 ,P_WPN_ATTRIBUTE17 => r_WPN.INFORMATION127
5768 ,P_WPN_ATTRIBUTE18 => r_WPN.INFORMATION128
5769 ,P_WPN_ATTRIBUTE19 => r_WPN.INFORMATION129
5770 ,P_WPN_ATTRIBUTE2 => r_WPN.INFORMATION112
5771 ,P_WPN_ATTRIBUTE20 => r_WPN.INFORMATION130
5772 ,P_WPN_ATTRIBUTE21 => r_WPN.INFORMATION131
5773 ,P_WPN_ATTRIBUTE22 => r_WPN.INFORMATION132
5774 ,P_WPN_ATTRIBUTE23 => r_WPN.INFORMATION133
5775 ,P_WPN_ATTRIBUTE24 => r_WPN.INFORMATION134
5776 ,P_WPN_ATTRIBUTE25 => r_WPN.INFORMATION135
5777 ,P_WPN_ATTRIBUTE26 => r_WPN.INFORMATION136
5778 ,P_WPN_ATTRIBUTE27 => r_WPN.INFORMATION137
5779 ,P_WPN_ATTRIBUTE28 => r_WPN.INFORMATION138
5780 ,P_WPN_ATTRIBUTE29 => r_WPN.INFORMATION139
5781 ,P_WPN_ATTRIBUTE3 => r_WPN.INFORMATION113
5782 ,P_WPN_ATTRIBUTE30 => r_WPN.INFORMATION140
5783 ,P_WPN_ATTRIBUTE4 => r_WPN.INFORMATION114
5784 ,P_WPN_ATTRIBUTE5 => r_WPN.INFORMATION115
5785 ,P_WPN_ATTRIBUTE6 => r_WPN.INFORMATION116
5786 ,P_WPN_ATTRIBUTE7 => r_WPN.INFORMATION117
5787 ,P_WPN_ATTRIBUTE8 => r_WPN.INFORMATION118
5788 ,P_WPN_ATTRIBUTE9 => r_WPN.INFORMATION119
5789 ,P_WPN_ATTRIBUTE_CATEGORY => r_WPN.INFORMATION110
5790 ,P_WV_PRTN_RSN_CD => r_WPN.INFORMATION12
5791 ,P_WV_PRTN_RSN_PL_ID => l_wv_prtn_rsn_pl_id
5792 --
5793 ,P_EFFECTIVE_START_DATE => l_effective_start_date
5794 ,P_EFFECTIVE_END_DATE => l_effective_end_date
5795 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5796 );
5797 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
5798 -- Update all relevent cer records with new pk_id
5799 hr_utility.set_location('Before plsql table ',222);
5800 hr_utility.set_location('new_value id '||l_wv_prtn_rsn_pl_id,222);
5801 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'WV_PRTN_RSN_PL_ID' ;
5802 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_WPN.information1 ;
5803 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_WV_PRTN_RSN_PL_ID ;
5804 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
5805 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_WPN_unique.table_route_id;
5806 hr_utility.set_location('After plsql table ',222);
5807 --
5808 -- 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 ) ;
5809 --
5810 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
5811 --
5812 else
5813 --
5814 -- Call Update routine for the pk_id created in prev run .
5815 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
5816 hr_utility.set_location(' BEN_WV_PRTN_RSN_PL_F UPDATE_WV_PRTN_REASON_PL ',30);
5817 --UPD START
5818 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
5819 --
5820 if l_update then
5821 --
5822 l_datetrack_mode := r_WPN.datetrack_mode ;
5823 --
5824 get_dt_modes(
5825 p_effective_date => l_process_date,
5826 p_effective_end_date => r_WPN.information3,
5827 p_effective_start_date => r_WPN.information2,
5828 p_dml_operation => r_WPN.dml_operation,
5829 p_datetrack_mode => l_datetrack_mode );
5830 -- p_update => l_update
5831 --
5832 l_effective_date := l_process_date;
5833 l_WV_PRTN_RSN_PL_ID := r_WPN.information1;
5834 l_object_version_number := r_WPN.information265;
5835 --
5836 end if;
5837 --
5838 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
5839 --
5840 IF l_update OR l_dml_operation <> 'UPDATE' THEN
5841 --UPD END
5842
5843 BEN_WV_PRTN_REASON_PL_API.UPDATE_WV_PRTN_REASON_PL(
5844 --
5845 P_VALIDATE => false
5846 ,P_EFFECTIVE_DATE => l_effective_date
5847 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5848 --
5849 ,P_DFLT_FLAG => r_WPN.INFORMATION11
5850 ,P_PL_ID => l_PL_ID
5851 ,P_WPN_ATTRIBUTE1 => r_WPN.INFORMATION111
5852 ,P_WPN_ATTRIBUTE10 => r_WPN.INFORMATION120
5853 ,P_WPN_ATTRIBUTE11 => r_WPN.INFORMATION121
5854 ,P_WPN_ATTRIBUTE12 => r_WPN.INFORMATION122
5855 ,P_WPN_ATTRIBUTE13 => r_WPN.INFORMATION123
5856 ,P_WPN_ATTRIBUTE14 => r_WPN.INFORMATION124
5857 ,P_WPN_ATTRIBUTE15 => r_WPN.INFORMATION125
5858 ,P_WPN_ATTRIBUTE16 => r_WPN.INFORMATION126
5859 ,P_WPN_ATTRIBUTE17 => r_WPN.INFORMATION127
5860 ,P_WPN_ATTRIBUTE18 => r_WPN.INFORMATION128
5861 ,P_WPN_ATTRIBUTE19 => r_WPN.INFORMATION129
5862 ,P_WPN_ATTRIBUTE2 => r_WPN.INFORMATION112
5863 ,P_WPN_ATTRIBUTE20 => r_WPN.INFORMATION130
5864 ,P_WPN_ATTRIBUTE21 => r_WPN.INFORMATION131
5865 ,P_WPN_ATTRIBUTE22 => r_WPN.INFORMATION132
5866 ,P_WPN_ATTRIBUTE23 => r_WPN.INFORMATION133
5867 ,P_WPN_ATTRIBUTE24 => r_WPN.INFORMATION134
5868 ,P_WPN_ATTRIBUTE25 => r_WPN.INFORMATION135
5869 ,P_WPN_ATTRIBUTE26 => r_WPN.INFORMATION136
5870 ,P_WPN_ATTRIBUTE27 => r_WPN.INFORMATION137
5871 ,P_WPN_ATTRIBUTE28 => r_WPN.INFORMATION138
5872 ,P_WPN_ATTRIBUTE29 => r_WPN.INFORMATION139
5873 ,P_WPN_ATTRIBUTE3 => r_WPN.INFORMATION113
5874 ,P_WPN_ATTRIBUTE30 => r_WPN.INFORMATION140
5875 ,P_WPN_ATTRIBUTE4 => r_WPN.INFORMATION114
5876 ,P_WPN_ATTRIBUTE5 => r_WPN.INFORMATION115
5877 ,P_WPN_ATTRIBUTE6 => r_WPN.INFORMATION116
5878 ,P_WPN_ATTRIBUTE7 => r_WPN.INFORMATION117
5879 ,P_WPN_ATTRIBUTE8 => r_WPN.INFORMATION118
5880 ,P_WPN_ATTRIBUTE9 => r_WPN.INFORMATION119
5881 ,P_WPN_ATTRIBUTE_CATEGORY => r_WPN.INFORMATION110
5882 ,P_WV_PRTN_RSN_CD => r_WPN.INFORMATION12
5883 ,P_WV_PRTN_RSN_PL_ID => l_wv_prtn_rsn_pl_id
5884 --
5885 ,P_EFFECTIVE_START_DATE => l_effective_start_date
5886 ,P_EFFECTIVE_END_DATE => l_effective_end_date
5887 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5888 ,P_DATETRACK_MODE => l_datetrack_mode
5889
5890 );
5891 --
5892 end if; -- l_update
5893 end if;
5894 --
5895 -- Delete the row if it is end dated.
5896 --
5897 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
5898 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
5899 trunc(l_max_eed) = r_WPN.information3) then
5900 --
5901 BEN_WV_PRTN_REASON_PL_API.delete_WV_PRTN_REASON_PL(
5902 --
5903 p_validate => false
5904 ,p_wv_prtn_rsn_pl_id => l_wv_prtn_rsn_pl_id
5905 ,p_effective_start_date => l_effective_start_date
5906 ,p_effective_end_date => l_effective_end_date
5907 ,p_object_version_number => l_object_version_number
5908 ,p_effective_date => l_max_eed
5909 ,p_datetrack_mode => hr_api.g_delete
5910 --
5911 );
5912 --
5913 end if;
5914 --
5915 l_prev_pk_id := l_current_pk_id ;
5916 --
5917 end if;
5918 --
5919 end if;
5920 --
5921 end loop;
5922 --
5923 exception when others then
5924 --
5925 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'WPN',r_wpn.information5 );
5926 --
5927 end create_WPN_rows;
5928
5929 --
5930 ---------------------------------------------------------------
5931 ----------------------< create_VRP_rows >-----------------------
5932 ---------------------------------------------------------------
5933 --
5934 procedure create_VRP_rows
5935 (
5936 p_validate in number default 0
5937 ,p_copy_entity_txn_id in number
5938 ,p_effective_date in date
5939 ,p_prefix_suffix_text in varchar2 default null
5940 ,p_reuse_object_flag in varchar2 default null
5941 ,p_target_business_group_id in varchar2 default null
5942 ,p_prefix_suffix_cd in varchar2 default null
5943 ) is
5944 --
5945 l_PL_ID number;
5946 l_RLSHP_TYP_CD ben_vald_rlshp_for_reimb_f.rlshp_typ_cd%type;
5947 cursor c_unique_VRP(l_table_alias varchar2) is
5948 select distinct cpe.information1,
5949 cpe.information2,
5950 cpe.information3,
5951 cpe.table_route_id
5952 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
5953 pqh_table_route tr
5954 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5955 and cpe.table_route_id = tr.table_route_id
5956 -- and tr.where_clause = l_BEN_VALD_RLSHP_FOR_REIMB_F
5957 and tr.table_alias = l_table_alias
5958 and cpe.number_of_copies = 1 -- ADDITION
5959 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
5960 order by information1, information2; --added for bug: 5151945
5961 --
5962 --
5963 cursor c_VRP_min_max_dates(c_table_route_id number,
5964 c_information1 number) is
5965 select
5966 min(cpe.information2) min_esd,
5967 max(cpe.information3) min_eed
5968 from ben_copy_entity_results cpe
5969 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5970 and cpe.table_route_id = c_table_route_id
5971 and cpe.information1 = c_information1 ;
5972 --
5973 cursor c_VRP(c_table_route_id number,
5974 c_information1 number,
5975 c_information2 date,
5976 c_information3 date ) is
5977 select
5978 cpe.*
5979 from ben_copy_entity_results cpe
5980 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5981 and cpe.table_route_id = c_table_route_id
5982 and cpe.information1 = c_information1
5983 and cpe.information2 = c_information2
5984 and cpe.information3 = c_information3
5985 and rownum = 1 ;
5986 -- Date Track target record
5987 cursor c_find_VRP_in_target(
5988 c_effective_start_date date,
5989 c_effective_end_date date,
5990 c_business_group_id number,
5991 c_new_pk_id number) is
5992 select
5993 VRP.vald_rlshp_for_reimb_id new_value
5994 from BEN_VALD_RLSHP_FOR_REIMB_F VRP
5995 where
5996 VRP.PL_ID = l_PL_ID and
5997 VRP.RLSHP_TYP_CD = l_RLSHP_TYP_CD and
5998 VRP.business_group_id = c_business_group_id
5999 and VRP.vald_rlshp_for_reimb_id <> c_new_pk_id
6000 --TEMPIK
6001 and c_effective_start_date between effective_start_date
6002 and effective_end_date ;
6003 --END TEMPIK
6004 /*TEMPIK
6005 and exists ( select null
6006 from BEN_VALD_RLSHP_FOR_REIMB_F VRP1
6007 where
6008 VRP1.PL_ID = l_PL_ID and
6009 VRP1.RLSHP_TYP_CD = l_RLSHP_TYP_CD and
6010 VRP1.business_group_id = c_business_group_id
6011 and VRP1.effective_start_date <= c_effective_start_date )
6012 and exists ( select null
6013 from BEN_VALD_RLSHP_FOR_REIMB_F VRP2
6014 where
6015 VRP2.PL_ID = l_PL_ID and
6016 VRP2.RLSHP_TYP_CD = l_RLSHP_TYP_CD and
6017 VRP2.business_group_id = c_business_group_id
6018 and VRP2.effective_end_date >= c_effective_end_date )
6019 ;
6020 TEMPIK */
6021 --TEMPIK
6022 l_dt_rec_found boolean ;
6023 --END TEMPIK
6024 --
6025 --UPD START
6026 --
6027 l_update boolean := false ;
6028 l_datetrack_mode varchar2(80) := hr_api.g_update;
6029 l_process_date date;
6030 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
6031 --
6032 --UPD END
6033 l_current_pk_id number := null ;
6034 l_prev_pk_id number := null ;
6035 l_first_rec boolean := true ;
6036 r_VRP c_VRP%rowtype;
6037 l_vald_rlshp_for_reimb_id number ;
6038 l_object_version_number number ;
6039 l_effective_start_date date ;
6040 l_effective_end_date date ;
6041 l_prefix pqh_copy_entity_attribs.information1%type := null;
6042 l_suffix pqh_copy_entity_attribs.information1%type := null;
6043 l_new_value number(15);
6044 l_object_found_in_target boolean := false ;
6045 l_min_esd date;
6046 l_max_eed date;
6047 l_effective_date date;
6048 --
6049 begin
6050 -- Initialization
6051 l_object_found_in_target := false ;
6052 -- End Initialization
6053 -- Derive the prefix - sufix
6054 if p_prefix_suffix_cd = 'PREFIX' then
6055 l_prefix := p_prefix_suffix_text ;
6056 elsif p_prefix_suffix_cd = 'SUFFIX' then
6057 l_suffix := p_prefix_suffix_text ;
6058 else
6059 l_prefix := null ;
6060 l_suffix := null ;
6061 end if ;
6062 -- End Prefix Sufix derivation
6063 for r_VRP_unique in c_unique_VRP('VRP') loop
6064
6065 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
6066 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6067 r_VRP_unique.information3 >=
6068 ben_pd_copy_to_ben_one.g_copy_effective_date)
6069 ) then
6070
6071 --
6072 hr_utility.set_location(' r_VRP_unique.table_route_id '||r_VRP_unique.table_route_id,10);
6073 hr_utility.set_location(' r_VRP_unique.information1 '||r_VRP_unique.information1,10);
6074 hr_utility.set_location( 'r_VRP_unique.information2 '||r_VRP_unique.information2,10);
6075 hr_utility.set_location( 'r_VRP_unique.information3 '||r_VRP_unique.information3,10);
6076 -- If reuse objects flag is 'Y' then check for the object in the target business group
6077 -- if found insert the record into PLSql table and exit the loop else try create the
6078 -- object in the target business group
6079 --
6080 l_object_found_in_target := false ;
6081 --UPD START
6082 open c_VRP(r_VRP_unique.table_route_id,
6083 r_VRP_unique.information1,
6084 r_VRP_unique.information2,
6085 r_VRP_unique.information3 ) ;
6086 --
6087 fetch c_VRP into r_VRP ;
6088 --
6089 close c_VRP ;
6090 --
6091 l_dml_operation:= r_VRP_unique.dml_operation ;
6092 l_PL_ID := get_fk('PL_ID', r_VRP.INFORMATION261,l_dml_operation);
6093 l_RLSHP_TYP_CD := r_VRP.information11;
6094 --
6095 l_update := false;
6096 l_process_date := p_effective_date;
6097 --
6098 if l_dml_operation = 'UPDATE' then
6099 --
6100 l_object_found_in_target := TRUE;
6101 --
6102 if l_process_date between r_VRP_unique.information2 and r_VRP_unique.information3 then
6103 l_update := true;
6104 if r_VRP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
6105 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'VALD_RLSHP_FOR_REIMB_ID'
6106 then
6107 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'VALD_RLSHP_FOR_REIMB_ID' ;
6108 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_VRP_unique.information1 ;
6109 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_VRP_unique.information1 ;
6110 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
6111 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_VRP_unique.table_route_id;
6112 --
6113 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
6114 --
6115 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
6116 --
6117 --DOUBT log_data('VRP',l_new_value,l_prefix || r_VRP_unique.name|| l_suffix,'REUSED');
6118 --
6119 end if ;
6120 hr_utility.set_location( 'found record for update',10);
6121 --
6122 else
6123 --
6124 l_update := false;
6125 --
6126 end if;
6127 else
6128 --
6129 --UPD END
6130 l_min_esd := null ;
6131 l_max_eed := null ;
6132 open c_VRP_min_max_dates(r_VRP_unique.table_route_id, r_VRP_unique.information1 ) ;
6133 fetch c_VRP_min_max_dates into l_min_esd,l_max_eed ;
6134 --
6135
6136 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6137 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
6138 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
6139 end if;
6140 l_min_esd := greatest(l_min_esd,r_VRP_unique.information2);
6141 /* open c_VRP(r_VRP_unique.table_route_id,
6142 r_VRP_unique.information1,
6143 r_VRP_unique.information2,
6144 r_VRP_unique.information3 ) ;
6145 --
6146 fetch c_VRP into r_VRP ;
6147 --
6148 close c_VRP ; */
6149 --
6150 if p_reuse_object_flag = 'Y' then
6151 if c_VRP_min_max_dates%found then
6152 -- cursor to find the object
6153 open c_find_VRP_in_target( l_min_esd,l_max_eed,
6154 p_target_business_group_id, nvl(l_vald_rlshp_for_reimb_id, -999) ) ;
6155 fetch c_find_VRP_in_target into l_new_value ;
6156 if c_find_VRP_in_target%found then
6157 --
6158 --TEMPIK
6159 l_dt_rec_found := dt_api.check_min_max_dates
6160 (p_base_table_name => 'BEN_VALD_RLSHP_FOR_REIMB_F',
6161 p_base_key_column => 'VALD_RLSHP_FOR_REIMB_ID',
6162 p_base_key_value => l_new_value,
6163 p_from_date => l_min_esd,
6164 p_to_date => l_max_eed );
6165 if l_dt_rec_found THEN
6166 --END TEMPIK
6167 if r_VRP_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
6168 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'VALD_RLSHP_FOR_REIMB_ID' then
6169 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'VALD_RLSHP_FOR_REIMB_ID' ;
6170 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_VRP_unique.information1 ;
6171 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
6172 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
6173 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_VRP_unique.table_route_id;
6174 --
6175 -- 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) ;
6176 --
6177 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
6178 end if ;
6179 --
6180 l_object_found_in_target := true ;
6181 --TEMPIK
6182 end if; -- l_dt_rec_found
6183 --END TEMPIK
6184 end if;
6185 close c_find_VRP_in_target ;
6186 --
6187 end if;
6188 end if ;
6189 --
6190 close c_VRP_min_max_dates ;
6191 end if; --if p_dml_operation
6192 --
6193 if not l_object_found_in_target OR l_update then
6194 --
6195 l_current_pk_id := r_VRP.information1;
6196 --
6197 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
6198 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
6199 --
6200 if l_current_pk_id = l_prev_pk_id then
6201 --
6202 l_first_rec := false ;
6203 --
6204 else
6205 --
6206 l_first_rec := true ;
6207 --
6208 end if ;
6209 --
6210
6211 l_effective_date := r_VRP.information2;
6212 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6213 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
6214 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
6215 end if;
6216
6217 if l_first_rec and not l_update then
6218 -- Call Create routine.
6219 hr_utility.set_location(' BEN_VALD_RLSHP_FOR_REIMB_F CREATE_VALD_RLSHP_FOR_REIMB ',20);
6220 BEN_VALD_RLSHP_FOR_REIMB_API.CREATE_VALD_RLSHP_FOR_REIMB(
6221 --
6222 P_VALIDATE => false
6223 ,P_EFFECTIVE_DATE => l_effective_date
6224 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
6225 --
6226 ,P_PL_ID => l_PL_ID
6227 ,P_RLSHP_TYP_CD => r_VRP.INFORMATION11
6228 ,P_VALD_RLSHP_FOR_REIMB_ID => l_vald_rlshp_for_reimb_id
6229 ,P_VRP_ATTRIBUTE1 => r_VRP.INFORMATION111
6230 ,P_VRP_ATTRIBUTE10 => r_VRP.INFORMATION120
6231 ,P_VRP_ATTRIBUTE11 => r_VRP.INFORMATION121
6232 ,P_VRP_ATTRIBUTE12 => r_VRP.INFORMATION122
6233 ,P_VRP_ATTRIBUTE13 => r_VRP.INFORMATION123
6234 ,P_VRP_ATTRIBUTE14 => r_VRP.INFORMATION124
6235 ,P_VRP_ATTRIBUTE15 => r_VRP.INFORMATION125
6236 ,P_VRP_ATTRIBUTE16 => r_VRP.INFORMATION126
6237 ,P_VRP_ATTRIBUTE17 => r_VRP.INFORMATION127
6238 ,P_VRP_ATTRIBUTE18 => r_VRP.INFORMATION128
6239 ,P_VRP_ATTRIBUTE19 => r_VRP.INFORMATION129
6240 ,P_VRP_ATTRIBUTE2 => r_VRP.INFORMATION112
6241 ,P_VRP_ATTRIBUTE20 => r_VRP.INFORMATION130
6242 ,P_VRP_ATTRIBUTE21 => r_VRP.INFORMATION131
6243 ,P_VRP_ATTRIBUTE22 => r_VRP.INFORMATION132
6244 ,P_VRP_ATTRIBUTE23 => r_VRP.INFORMATION133
6245 ,P_VRP_ATTRIBUTE24 => r_VRP.INFORMATION134
6246 ,P_VRP_ATTRIBUTE25 => r_VRP.INFORMATION135
6247 ,P_VRP_ATTRIBUTE26 => r_VRP.INFORMATION136
6248 ,P_VRP_ATTRIBUTE27 => r_VRP.INFORMATION137
6249 ,P_VRP_ATTRIBUTE28 => r_VRP.INFORMATION138
6250 ,P_VRP_ATTRIBUTE29 => r_VRP.INFORMATION139
6251 ,P_VRP_ATTRIBUTE3 => r_VRP.INFORMATION113
6252 ,P_VRP_ATTRIBUTE30 => r_VRP.INFORMATION140
6253 ,P_VRP_ATTRIBUTE4 => r_VRP.INFORMATION114
6254 ,P_VRP_ATTRIBUTE5 => r_VRP.INFORMATION115
6255 ,P_VRP_ATTRIBUTE6 => r_VRP.INFORMATION116
6256 ,P_VRP_ATTRIBUTE7 => r_VRP.INFORMATION117
6257 ,P_VRP_ATTRIBUTE8 => r_VRP.INFORMATION118
6258 ,P_VRP_ATTRIBUTE9 => r_VRP.INFORMATION119
6259 ,P_VRP_ATTRIBUTE_CATEGORY => r_VRP.INFORMATION110
6260 --
6261 ,P_EFFECTIVE_START_DATE => l_effective_start_date
6262 ,P_EFFECTIVE_END_DATE => l_effective_end_date
6263 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
6264 );
6265 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
6266 -- Update all relevent cer records with new pk_id
6267 hr_utility.set_location('Before plsql table ',222);
6268 hr_utility.set_location('new_value id '||l_vald_rlshp_for_reimb_id,222);
6269 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'VALD_RLSHP_FOR_REIMB_ID' ;
6270 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_VRP.information1 ;
6271 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_VALD_RLSHP_FOR_REIMB_ID ;
6272 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
6273 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_VRP_unique.table_route_id;
6274 hr_utility.set_location('After plsql table ',222);
6275 --
6276 -- 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 ) ;
6277 --
6278 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
6279 --
6280 else
6281 --
6282 -- Call Update routine for the pk_id created in prev run .
6283 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
6284 hr_utility.set_location(' BEN_VALD_RLSHP_FOR_REIMB_F UPDATE_VALD_RLSHP_FOR_REIMB ',30);
6285 --UPD START
6286 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
6287 --
6288 if l_update then
6289 --
6290 l_datetrack_mode := r_VRP.datetrack_mode ;
6291 --
6292 get_dt_modes(
6293 p_effective_date => l_process_date,
6294 p_effective_end_date => r_VRP.information3,
6295 p_effective_start_date => r_VRP.information2,
6296 p_dml_operation => r_VRP.dml_operation,
6297 p_datetrack_mode => l_datetrack_mode );
6298 -- p_update => l_update
6299 --
6300 l_effective_date := l_process_date;
6301 l_VALD_RLSHP_FOR_REIMB_ID := r_VRP.information1;
6302 l_object_version_number := r_VRP.information265;
6303 --
6304 end if;
6305 --
6306 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
6307 --
6308 IF l_update OR l_dml_operation <> 'UPDATE' THEN
6309 --UPD END
6310
6311 BEN_VALD_RLSHP_FOR_REIMB_API.UPDATE_VALD_RLSHP_FOR_REIMB(
6312 --
6313 P_VALIDATE => false
6314 ,P_EFFECTIVE_DATE => l_effective_date
6315 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
6316 --
6317 ,P_PL_ID => l_PL_ID
6318 ,P_RLSHP_TYP_CD => r_VRP.INFORMATION11
6319 ,P_VALD_RLSHP_FOR_REIMB_ID => l_vald_rlshp_for_reimb_id
6320 ,P_VRP_ATTRIBUTE1 => r_VRP.INFORMATION111
6321 ,P_VRP_ATTRIBUTE10 => r_VRP.INFORMATION120
6322 ,P_VRP_ATTRIBUTE11 => r_VRP.INFORMATION121
6323 ,P_VRP_ATTRIBUTE12 => r_VRP.INFORMATION122
6324 ,P_VRP_ATTRIBUTE13 => r_VRP.INFORMATION123
6325 ,P_VRP_ATTRIBUTE14 => r_VRP.INFORMATION124
6326 ,P_VRP_ATTRIBUTE15 => r_VRP.INFORMATION125
6327 ,P_VRP_ATTRIBUTE16 => r_VRP.INFORMATION126
6328 ,P_VRP_ATTRIBUTE17 => r_VRP.INFORMATION127
6329 ,P_VRP_ATTRIBUTE18 => r_VRP.INFORMATION128
6330 ,P_VRP_ATTRIBUTE19 => r_VRP.INFORMATION129
6331 ,P_VRP_ATTRIBUTE2 => r_VRP.INFORMATION112
6332 ,P_VRP_ATTRIBUTE20 => r_VRP.INFORMATION130
6333 ,P_VRP_ATTRIBUTE21 => r_VRP.INFORMATION131
6334 ,P_VRP_ATTRIBUTE22 => r_VRP.INFORMATION132
6335 ,P_VRP_ATTRIBUTE23 => r_VRP.INFORMATION133
6336 ,P_VRP_ATTRIBUTE24 => r_VRP.INFORMATION134
6337 ,P_VRP_ATTRIBUTE25 => r_VRP.INFORMATION135
6338 ,P_VRP_ATTRIBUTE26 => r_VRP.INFORMATION136
6339 ,P_VRP_ATTRIBUTE27 => r_VRP.INFORMATION137
6340 ,P_VRP_ATTRIBUTE28 => r_VRP.INFORMATION138
6341 ,P_VRP_ATTRIBUTE29 => r_VRP.INFORMATION139
6342 ,P_VRP_ATTRIBUTE3 => r_VRP.INFORMATION113
6343 ,P_VRP_ATTRIBUTE30 => r_VRP.INFORMATION140
6344 ,P_VRP_ATTRIBUTE4 => r_VRP.INFORMATION114
6345 ,P_VRP_ATTRIBUTE5 => r_VRP.INFORMATION115
6346 ,P_VRP_ATTRIBUTE6 => r_VRP.INFORMATION116
6347 ,P_VRP_ATTRIBUTE7 => r_VRP.INFORMATION117
6348 ,P_VRP_ATTRIBUTE8 => r_VRP.INFORMATION118
6349 ,P_VRP_ATTRIBUTE9 => r_VRP.INFORMATION119
6350 ,P_VRP_ATTRIBUTE_CATEGORY => r_VRP.INFORMATION110
6351 --
6352 ,P_EFFECTIVE_START_DATE => l_effective_start_date
6353 ,P_EFFECTIVE_END_DATE => l_effective_end_date
6354 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
6355 ,P_DATETRACK_MODE => l_datetrack_mode
6356 );
6357 --
6358 end if; -- l_update
6359 end if;
6360 --
6361 -- Delete the row if it is end dated.
6362 --
6363 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
6364 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
6365 trunc(l_max_eed) = r_VRP.information3) then
6366 --
6367 BEN_VALD_RLSHP_FOR_REIMB_API.delete_VALD_RLSHP_FOR_REIMB(
6368 --
6369 p_validate => false
6370 ,p_vald_rlshp_for_reimb_id => l_vald_rlshp_for_reimb_id
6371 ,p_effective_start_date => l_effective_start_date
6372 ,p_effective_end_date => l_effective_end_date
6373 ,p_object_version_number => l_object_version_number
6374 ,p_effective_date => l_max_eed
6375 ,p_datetrack_mode => hr_api.g_delete
6376 --
6377 );
6378 --
6379 end if;
6380 --
6381 l_prev_pk_id := l_current_pk_id ;
6382 --
6383 end if;
6384 --
6385 end if;
6386 --
6387 end loop;
6388 --
6389 exception when others then
6390 --
6391 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'VRP',r_vrp.information5 );
6392 --
6393 end create_VRP_rows;
6394
6395 --
6396 ---------------------------------------------------------------
6397 ----------------------< create_PCT_rows >-----------------------
6398 ---------------------------------------------------------------
6399 --
6400 procedure create_PCT_rows
6401 (
6402 p_validate in number default 0
6403 ,p_copy_entity_txn_id in number
6404 ,p_effective_date in date
6405 ,p_prefix_suffix_text in varchar2 default null
6406 ,p_reuse_object_flag in varchar2 default null
6407 ,p_target_business_group_id in varchar2 default null
6408 ,p_prefix_suffix_cd in varchar2 default null
6409 ) is
6410 --
6411 l_CTFN_RQD_WHEN_RL number;
6412 l_LACK_CTFN_DENY_RMBMT_RL number;
6413 l_PL_GD_OR_SVC_ID number;
6414 l_RMBMT_CTFN_TYP_CD varchar2(30);
6415 --
6416 cursor c_unique_PCT(l_table_alias varchar2) is
6417 select distinct cpe.information1,
6418 cpe.information2,
6419 cpe.information3,
6420 cpe.table_route_id
6421 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
6422 pqh_table_route tr
6423 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6424 and cpe.table_route_id = tr.table_route_id
6425 -- and tr.where_clause = l_BEN_PL_GD_R_SVC_CTFN_F
6426 and tr.table_alias = l_table_alias
6427 and cpe.number_of_copies = 1 -- ADDITION
6428 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
6429 order by information1, information2; --added for bug: 5151945
6430 --
6431 --
6432 cursor c_PCT_min_max_dates(c_table_route_id number,
6433 c_information1 number) is
6434 select
6435 min(cpe.information2) min_esd,
6436 max(cpe.information3) min_eed
6437 from ben_copy_entity_results cpe
6438 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6439 and cpe.table_route_id = c_table_route_id
6440 and cpe.information1 = c_information1 ;
6441 --
6442 cursor c_PCT(c_table_route_id number,
6443 c_information1 number,
6444 c_information2 date,
6445 c_information3 date ) is
6446 select
6447 cpe.*
6448 from ben_copy_entity_results cpe
6449 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6450 and cpe.table_route_id = c_table_route_id
6451 and cpe.information1 = c_information1
6452 and cpe.information2 = c_information2
6453 and cpe.information3 = c_information3
6454 and rownum = 1 ;
6455 -- Date Track target record
6456 cursor c_find_PCT_in_target(
6457 c_effective_start_date date,
6458 c_effective_end_date date,
6459 c_business_group_id number,
6460 c_new_pk_id number) is
6461 select
6462 PCT.pl_gd_r_svc_ctfn_id new_value
6463 from BEN_PL_GD_R_SVC_CTFN_F PCT
6464 where
6465 PCT.PL_GD_OR_SVC_ID = l_PL_GD_OR_SVC_ID and
6466 PCT.RMBMT_CTFN_TYP_CD = l_RMBMT_CTFN_TYP_CD and
6467 PCT.business_group_id = c_business_group_id
6468 and PCT.pl_gd_r_svc_ctfn_id <> c_new_pk_id
6469 --TEMPIK
6470 and c_effective_start_date between effective_start_date
6471 and effective_end_date ;
6472 --END TEMPIK
6473 /*TEMPIK
6474 and exists ( select null
6475 from BEN_PL_GD_R_SVC_CTFN_F PCT1
6476 where
6477 PCT1.PL_GD_OR_SVC_ID = l_PL_GD_OR_SVC_ID and
6478 PCT1.RMBMT_CTFN_TYP_CD = l_RMBMT_CTFN_TYP_CD and
6479 PCT1.business_group_id = c_business_group_id
6480 and PCT1.effective_start_date <= c_effective_start_date )
6481 and exists ( select null
6482 from BEN_PL_GD_R_SVC_CTFN_F PCT2
6483 where
6484 PCT2.PL_GD_OR_SVC_ID = l_PL_GD_OR_SVC_ID and
6485 PCT2.RMBMT_CTFN_TYP_CD = l_RMBMT_CTFN_TYP_CD and
6486 PCT2.business_group_id = c_business_group_id
6487 and PCT2.effective_end_date >= c_effective_end_date )
6488 ;
6489 TEMPIK */
6490 --TEMPIK
6491 l_dt_rec_found boolean ;
6492 --END TEMPIK
6493 --
6494 --UPD START
6495 --
6496 l_update boolean := false ;
6497 l_datetrack_mode varchar2(80) := hr_api.g_update;
6498 l_process_date date;
6499 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
6500 --
6501 --UPD END
6502 l_current_pk_id number := null ;
6503 l_prev_pk_id number := null ;
6504 l_first_rec boolean := true ;
6505 r_PCT c_PCT%rowtype;
6506 l_pl_gd_r_svc_ctfn_id number ;
6507 l_object_version_number number ;
6508 l_effective_start_date date ;
6509 l_effective_end_date date ;
6510 l_prefix pqh_copy_entity_attribs.information1%type := null;
6511 l_suffix pqh_copy_entity_attribs.information1%type := null;
6512 l_new_value number(15);
6513 l_object_found_in_target boolean := false ;
6514 l_min_esd date;
6515 l_max_eed date;
6516 l_effective_date date;
6517 --
6518 begin
6519 -- Initialization
6520 l_object_found_in_target := false ;
6521 -- End Initialization
6522 -- Derive the prefix - sufix
6523 if p_prefix_suffix_cd = 'PREFIX' then
6524 l_prefix := p_prefix_suffix_text ;
6525 elsif p_prefix_suffix_cd = 'SUFFIX' then
6526 l_suffix := p_prefix_suffix_text ;
6527 else
6528 l_prefix := null ;
6529 l_suffix := null ;
6530 end if ;
6531 -- End Prefix Sufix derivation
6532 for r_PCT_unique in c_unique_PCT('PCT') loop
6533
6534 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
6535 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6536 r_PCT_unique.information3 >=
6537 ben_pd_copy_to_ben_one.g_copy_effective_date)
6538 ) then
6539 --
6540 hr_utility.set_location(' r_PCT_unique.table_route_id '||r_PCT_unique.table_route_id,10);
6541 hr_utility.set_location(' r_PCT_unique.information1 '||r_PCT_unique.information1,10);
6542 hr_utility.set_location( 'r_PCT_unique.information2 '||r_PCT_unique.information2,10);
6543 hr_utility.set_location( 'r_PCT_unique.information3 '||r_PCT_unique.information3,10);
6544 -- If reuse objects flag is 'Y' then check for the object in the target business group
6545 -- if found insert the record into PLSql table and exit the loop else try create the
6546 -- object in the target business group
6547 --
6548 l_object_found_in_target := false ;
6549 --UPD START
6550 open c_PCT(r_PCT_unique.table_route_id,
6551 r_PCT_unique.information1,
6552 r_PCT_unique.information2,
6553 r_PCT_unique.information3 ) ;
6554 --
6555 fetch c_PCT into r_PCT ;
6556 --
6557 close c_PCT ;
6558 --
6559 l_dml_operation:= r_PCT_unique.dml_operation ;
6560 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_PCT.INFORMATION257,l_dml_operation);
6561 l_LACK_CTFN_DENY_RMBMT_RL := get_fk('FORMULA_ID', r_PCT.INFORMATION259,l_dml_operation);
6562 l_PL_GD_OR_SVC_ID := get_fk('PL_GD_OR_SVC_ID', r_PCT.INFORMATION258,l_dml_operation);
6563 l_RMBMT_CTFN_TYP_CD := r_PCT.information12 ;
6564 --
6565 l_update := false;
6566 l_process_date := p_effective_date;
6567 --
6568 if l_dml_operation = 'UPDATE' then
6569 --
6570 l_object_found_in_target := TRUE;
6571 --
6572 if l_process_date between r_PCT_unique.information2 and r_PCT_unique.information3 then
6573 l_update := true;
6574 if r_PCT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
6575 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_GD_R_SVC_CTFN_ID'
6576 then
6577 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_GD_R_SVC_CTFN_ID' ;
6578 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PCT_unique.information1 ;
6579 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PCT_unique.information1 ;
6580 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
6581 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PCT_unique.table_route_id;
6582 --
6583 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
6584 --
6585 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
6586 --
6587 --DOUBT log_data('PCT',l_new_value,l_prefix || r_PCT_unique.name|| l_suffix,'REUSED');
6588 --
6589 end if ;
6590 hr_utility.set_location( 'found record for update',10);
6591 --
6592 else
6593 --
6594 l_update := false;
6595 --
6596 end if;
6597 else
6598 --
6599 --UPD END
6600 l_min_esd := null ;
6601 l_max_eed := null ;
6602 open c_PCT_min_max_dates(r_PCT_unique.table_route_id, r_PCT_unique.information1 ) ;
6603 fetch c_PCT_min_max_dates into l_min_esd,l_max_eed ;
6604 --
6605
6606 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6607 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
6608 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
6609 end if;
6610 l_min_esd := greatest(l_min_esd,r_PCT_unique.information2);
6611 /* open c_PCT(r_PCT_unique.table_route_id,
6612 r_PCT_unique.information1,
6613 r_PCT_unique.information2,
6614 r_PCT_unique.information3 ) ;
6615 --
6616 fetch c_PCT into r_PCT ;
6617 --
6618 close c_PCT ; */
6619 --
6620 if p_reuse_object_flag = 'Y' then
6621 if c_PCT_min_max_dates%found then
6622 -- cursor to find the object
6623 open c_find_PCT_in_target( l_min_esd,l_max_eed,
6624 p_target_business_group_id, nvl(l_pl_gd_r_svc_ctfn_id, -999) ) ;
6625 fetch c_find_PCT_in_target into l_new_value ;
6626 if c_find_PCT_in_target%found then
6627 --
6628 --TEMPIK
6629 l_dt_rec_found := dt_api.check_min_max_dates
6630 (p_base_table_name => 'BEN_PL_GD_R_SVC_CTFN_F',
6631 p_base_key_column => 'PL_GD_R_SVC_CTFN_ID',
6632 p_base_key_value => l_new_value,
6633 p_from_date => l_min_esd,
6634 p_to_date => l_max_eed );
6635 if l_dt_rec_found THEN
6636 --END TEMPIK
6637 if r_PCT_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
6638 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_GD_R_SVC_CTFN_ID' then
6639 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_GD_R_SVC_CTFN_ID' ;
6640 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PCT_unique.information1 ;
6641 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
6642 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
6643 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PCT_unique.table_route_id;
6644 --
6645 -- 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) ;
6646 --
6647 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
6648 end if ;
6649 --
6650 l_object_found_in_target := true ;
6651 --TEMPIK
6652 end if; -- l_dt_rec_found
6653 --END TEMPIK
6654 end if;
6655 close c_find_PCT_in_target ;
6656 --
6657 end if;
6658 end if ;
6659 --
6660 close c_PCT_min_max_dates ;
6661 end if; --if p_dml_operation
6662 --
6663 if not l_object_found_in_target OR l_update then
6664
6665 --
6666 l_current_pk_id := r_PCT.information1;
6667 --
6668 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
6669 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
6670 --
6671 if l_current_pk_id = l_prev_pk_id then
6672 --
6673 l_first_rec := false ;
6674 --
6675 else
6676 --
6677 l_first_rec := true ;
6678 --
6679 end if ;
6680 --
6681
6682 l_effective_date := r_PCT.information2;
6683 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6684 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
6685 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
6686 end if;
6687
6688 if l_first_rec and not l_update then
6689 -- Call Create routine.
6690 hr_utility.set_location(' BEN_PL_GD_R_SVC_CTFN_F CREATE_PLAN_GOODS_SERV_CERT ',20);
6691 BEN_PLAN_GOODS_SERV_CERT_API.CREATE_PLAN_GOODS_SERV_CERT(
6692 --
6693 P_VALIDATE => false
6694 ,P_EFFECTIVE_DATE => l_effective_date
6695 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
6696 --
6697 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
6698 ,P_LACK_CTFN_DENY_RMBMT_FLAG => r_PCT.INFORMATION14
6699 ,P_LACK_CTFN_DENY_RMBMT_RL => l_LACK_CTFN_DENY_RMBMT_RL
6700 ,P_PCT_ATTRIBUTE1 => r_PCT.INFORMATION111
6701 ,P_PCT_ATTRIBUTE10 => r_PCT.INFORMATION120
6702 ,P_PCT_ATTRIBUTE11 => r_PCT.INFORMATION121
6703 ,P_PCT_ATTRIBUTE12 => r_PCT.INFORMATION122
6704 ,P_PCT_ATTRIBUTE13 => r_PCT.INFORMATION123
6705 ,P_PCT_ATTRIBUTE14 => r_PCT.INFORMATION124
6706 ,P_PCT_ATTRIBUTE15 => r_PCT.INFORMATION125
6707 ,P_PCT_ATTRIBUTE16 => r_PCT.INFORMATION126
6708 ,P_PCT_ATTRIBUTE17 => r_PCT.INFORMATION127
6709 ,P_PCT_ATTRIBUTE18 => r_PCT.INFORMATION128
6710 ,P_PCT_ATTRIBUTE19 => r_PCT.INFORMATION129
6711 ,P_PCT_ATTRIBUTE2 => r_PCT.INFORMATION112
6712 ,P_PCT_ATTRIBUTE20 => r_PCT.INFORMATION130
6713 ,P_PCT_ATTRIBUTE21 => r_PCT.INFORMATION131
6714 ,P_PCT_ATTRIBUTE22 => r_PCT.INFORMATION132
6715 ,P_PCT_ATTRIBUTE23 => r_PCT.INFORMATION133
6716 ,P_PCT_ATTRIBUTE24 => r_PCT.INFORMATION134
6717 ,P_PCT_ATTRIBUTE25 => r_PCT.INFORMATION135
6718 ,P_PCT_ATTRIBUTE26 => r_PCT.INFORMATION136
6719 ,P_PCT_ATTRIBUTE27 => r_PCT.INFORMATION137
6720 ,P_PCT_ATTRIBUTE28 => r_PCT.INFORMATION138
6721 ,P_PCT_ATTRIBUTE29 => r_PCT.INFORMATION139
6722 ,P_PCT_ATTRIBUTE3 => r_PCT.INFORMATION113
6723 ,P_PCT_ATTRIBUTE30 => r_PCT.INFORMATION140
6724 ,P_PCT_ATTRIBUTE4 => r_PCT.INFORMATION114
6725 ,P_PCT_ATTRIBUTE5 => r_PCT.INFORMATION115
6726 ,P_PCT_ATTRIBUTE6 => r_PCT.INFORMATION116
6727 ,P_PCT_ATTRIBUTE7 => r_PCT.INFORMATION117
6728 ,P_PCT_ATTRIBUTE8 => r_PCT.INFORMATION118
6729 ,P_PCT_ATTRIBUTE9 => r_PCT.INFORMATION119
6730 ,P_PCT_ATTRIBUTE_CATEGORY => r_PCT.INFORMATION110
6731 ,P_PFD_FLAG => r_PCT.INFORMATION13
6732 ,P_PL_GD_OR_SVC_ID => l_PL_GD_OR_SVC_ID
6733 ,P_PL_GD_R_SVC_CTFN_ID => l_pl_gd_r_svc_ctfn_id
6734 ,P_RMBMT_CTFN_TYP_CD => r_PCT.INFORMATION12
6735 ,P_RQD_FLAG => r_PCT.INFORMATION11
6736 --
6737 ,P_EFFECTIVE_START_DATE => l_effective_start_date
6738 ,P_EFFECTIVE_END_DATE => l_effective_end_date
6739 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
6740 );
6741 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
6742 -- Update all relevent cer records with new pk_id
6743
6744 hr_utility.set_location('Before plsql table ',222);
6745 hr_utility.set_location('new_value id '||l_pl_gd_r_svc_ctfn_id,222);
6746 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_GD_R_SVC_CTFN_ID' ;
6747 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PCT.information1 ;
6748 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PL_GD_R_SVC_CTFN_ID ;
6749 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
6750 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PCT_unique.table_route_id;
6751 hr_utility.set_location('After plsql table ',222);
6752 --
6753 -- 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 ) ;
6754 --
6755 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
6756 --
6757 else
6758 --
6759 -- Call Update routine for the pk_id created in prev run .
6760 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
6761 hr_utility.set_location(' BEN_PL_GD_R_SVC_CTFN_F UPDATE_PLAN_GOODS_SERV_CERT ',30);
6762 --UPD START
6763 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
6764 --
6765 if l_update then
6766 --
6767 l_datetrack_mode := r_PCT.datetrack_mode ;
6768 --
6769 get_dt_modes(
6770 p_effective_date => l_process_date,
6771 p_effective_end_date => r_PCT.information3,
6772 p_effective_start_date => r_PCT.information2,
6773 p_dml_operation => r_PCT.dml_operation,
6774 p_datetrack_mode => l_datetrack_mode );
6775 -- p_update => l_update
6776 --
6777 l_effective_date := l_process_date;
6778 l_PL_GD_R_SVC_CTFN_ID := r_PCT.information1;
6779 l_object_version_number := r_PCT.information265;
6780 --
6781 end if;
6782 --
6783 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
6784 --
6785 IF l_update OR l_dml_operation <> 'UPDATE' THEN
6786 --UPD END
6787 BEN_PLAN_GOODS_SERV_CERT_API.UPDATE_PLAN_GOODS_SERV_CERT(
6788 --
6789 P_VALIDATE => false
6790 ,P_EFFECTIVE_DATE => l_effective_date
6791 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
6792 --
6793 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
6794 ,P_LACK_CTFN_DENY_RMBMT_FLAG => r_PCT.INFORMATION14
6795 ,P_LACK_CTFN_DENY_RMBMT_RL => l_LACK_CTFN_DENY_RMBMT_RL
6796 ,P_PCT_ATTRIBUTE1 => r_PCT.INFORMATION111
6797 ,P_PCT_ATTRIBUTE10 => r_PCT.INFORMATION120
6798 ,P_PCT_ATTRIBUTE11 => r_PCT.INFORMATION121
6799 ,P_PCT_ATTRIBUTE12 => r_PCT.INFORMATION122
6800 ,P_PCT_ATTRIBUTE13 => r_PCT.INFORMATION123
6801 ,P_PCT_ATTRIBUTE14 => r_PCT.INFORMATION124
6802 ,P_PCT_ATTRIBUTE15 => r_PCT.INFORMATION125
6803 ,P_PCT_ATTRIBUTE16 => r_PCT.INFORMATION126
6804 ,P_PCT_ATTRIBUTE17 => r_PCT.INFORMATION127
6805 ,P_PCT_ATTRIBUTE18 => r_PCT.INFORMATION128
6806 ,P_PCT_ATTRIBUTE19 => r_PCT.INFORMATION129
6807 ,P_PCT_ATTRIBUTE2 => r_PCT.INFORMATION112
6808 ,P_PCT_ATTRIBUTE20 => r_PCT.INFORMATION130
6809 ,P_PCT_ATTRIBUTE21 => r_PCT.INFORMATION131
6810 ,P_PCT_ATTRIBUTE22 => r_PCT.INFORMATION132
6811 ,P_PCT_ATTRIBUTE23 => r_PCT.INFORMATION133
6812 ,P_PCT_ATTRIBUTE24 => r_PCT.INFORMATION134
6813 ,P_PCT_ATTRIBUTE25 => r_PCT.INFORMATION135
6814 ,P_PCT_ATTRIBUTE26 => r_PCT.INFORMATION136
6815 ,P_PCT_ATTRIBUTE27 => r_PCT.INFORMATION137
6816 ,P_PCT_ATTRIBUTE28 => r_PCT.INFORMATION138
6817 ,P_PCT_ATTRIBUTE29 => r_PCT.INFORMATION139
6818 ,P_PCT_ATTRIBUTE3 => r_PCT.INFORMATION113
6819 ,P_PCT_ATTRIBUTE30 => r_PCT.INFORMATION140
6820 ,P_PCT_ATTRIBUTE4 => r_PCT.INFORMATION114
6821 ,P_PCT_ATTRIBUTE5 => r_PCT.INFORMATION115
6822 ,P_PCT_ATTRIBUTE6 => r_PCT.INFORMATION116
6823 ,P_PCT_ATTRIBUTE7 => r_PCT.INFORMATION117
6824 ,P_PCT_ATTRIBUTE8 => r_PCT.INFORMATION118
6825 ,P_PCT_ATTRIBUTE9 => r_PCT.INFORMATION119
6826 ,P_PCT_ATTRIBUTE_CATEGORY => r_PCT.INFORMATION110
6827 ,P_PFD_FLAG => r_PCT.INFORMATION13
6828 ,P_PL_GD_OR_SVC_ID => l_PL_GD_OR_SVC_ID
6829 ,P_PL_GD_R_SVC_CTFN_ID => l_pl_gd_r_svc_ctfn_id
6830 ,P_RMBMT_CTFN_TYP_CD => r_PCT.INFORMATION12
6831 ,P_RQD_FLAG => r_PCT.INFORMATION11
6832 --
6833 ,P_EFFECTIVE_START_DATE => l_effective_start_date
6834 ,P_EFFECTIVE_END_DATE => l_effective_end_date
6835 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
6836 ,P_DATETRACK_MODE => l_datetrack_mode
6837 );
6838 --
6839 end if; -- l_update
6840 end if;
6841 --
6842 -- Delete the row if it is end dated.
6843 --
6844 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
6845 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
6846 trunc(l_max_eed) = r_PCT.information3) then
6847 --
6848 BEN_PLAN_GOODS_SERV_CERT_API.delete_PLAN_GOODS_SERV_CERT(
6849 --
6850 p_validate => false
6851 ,p_pl_gd_r_svc_ctfn_id => l_pl_gd_r_svc_ctfn_id
6852 ,p_effective_start_date => l_effective_start_date
6853 ,p_effective_end_date => l_effective_end_date
6854 ,p_object_version_number => l_object_version_number
6855 ,p_effective_date => l_max_eed
6856 ,p_datetrack_mode => hr_api.g_delete
6857 --
6858 );
6859 --
6860 end if;
6861 --
6862 l_prev_pk_id := l_current_pk_id ;
6863 --
6864 end if;
6865 --
6866 end if;
6867 --
6868 end loop;
6869 --
6870 exception when others then
6871 --
6872 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PCT',r_pct.information5 );
6873 --
6874 end create_PCT_rows;
6875
6876 --
6877 ---------------------------------------------------------------
6878 ----------------------< create_VGS_rows >-----------------------
6879 ---------------------------------------------------------------
6880 --
6881 procedure create_VGS_rows
6882 (
6883 p_validate in number default 0
6884 ,p_copy_entity_txn_id in number
6885 ,p_effective_date in date
6886 ,p_prefix_suffix_text in varchar2 default null
6887 ,p_reuse_object_flag in varchar2 default null
6888 ,p_target_business_group_id in varchar2 default null
6889 ,p_prefix_suffix_cd in varchar2 default null
6890 ) is
6891 --
6892 l_GD_OR_SVC_TYP_ID number;
6893 l_PL_ID number;
6894 cursor c_unique_VGS(l_table_alias varchar2) is
6895 select distinct cpe.information1,
6896 cpe.information2,
6897 cpe.information3,
6898 cpe.table_route_id
6899 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
6900 pqh_table_route tr
6901 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6902 and cpe.table_route_id = tr.table_route_id
6903 -- and tr.where_clause = l_BEN_PL_GD_OR_SVC_F
6904 and tr.table_alias = l_table_alias
6905 and cpe.number_of_copies = 1 -- ADDITION
6906 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
6907 order by information1, information2; --added for bug: 5151945
6908 --
6909 --
6910 cursor c_VGS_min_max_dates(c_table_route_id number,
6911 c_information1 number) is
6912 select
6913 min(cpe.information2) min_esd,
6914 max(cpe.information3) min_eed
6915 from ben_copy_entity_results cpe
6916 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6917 and cpe.table_route_id = c_table_route_id
6918 and cpe.information1 = c_information1 ;
6919 --
6920 cursor c_VGS(c_table_route_id number,
6921 c_information1 number,
6922 c_information2 date,
6923 c_information3 date ) is
6924 select
6925 cpe.*
6926 from ben_copy_entity_results cpe
6927 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6928 and cpe.table_route_id = c_table_route_id
6929 and cpe.information1 = c_information1
6930 and cpe.information2 = c_information2
6931 and cpe.information3 = c_information3
6932 and rownum = 1 ;
6933 -- Date Track target record
6934 cursor c_find_VGS_in_target(
6935 c_effective_start_date date,
6936 c_effective_end_date date,
6937 c_business_group_id number,
6938 c_new_pk_id number) is
6939 select
6940 VGS.pl_gd_or_svc_id new_value
6941 from BEN_PL_GD_OR_SVC_F VGS
6942 where
6943 VGS.GD_OR_SVC_TYP_ID = l_GD_OR_SVC_TYP_ID and
6944 VGS.PL_ID = l_PL_ID and
6945 VGS.business_group_id = c_business_group_id
6946 and VGS.pl_gd_or_svc_id <> c_new_pk_id
6947 --TEMPIK
6948 and c_effective_start_date between effective_start_date
6949 and effective_end_date ;
6950 --END TEMPIK
6951 /*TEMPIK
6952 and exists ( select null
6953 from BEN_PL_GD_OR_SVC_F VGS1
6954 where
6955 VGS1.GD_OR_SVC_TYP_ID = l_GD_OR_SVC_TYP_ID and
6956 VGS1.PL_ID = l_PL_ID and
6957 VGS1.business_group_id = c_business_group_id
6958 and VGS1.effective_start_date <= c_effective_start_date )
6959 and exists ( select null
6960 from BEN_PL_GD_OR_SVC_F VGS2
6961 where
6962 VGS2.GD_OR_SVC_TYP_ID = l_GD_OR_SVC_TYP_ID and
6963 VGS2.PL_ID = l_PL_ID and
6964 VGS2.business_group_id = c_business_group_id
6965 and VGS2.effective_end_date >= c_effective_end_date )
6966 ;
6967 TEMPIK */
6968 --TEMPIK
6969 l_dt_rec_found boolean ;
6970 --END TEMPIK
6971 --
6972 --UPD START
6973 --
6974 l_update boolean := false ;
6975 l_datetrack_mode varchar2(80) := hr_api.g_update;
6976 l_process_date date;
6977 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
6978 --
6979 --UPD END
6980 l_current_pk_id number := null ;
6981 l_prev_pk_id number := null ;
6982 l_first_rec boolean := true ;
6983 r_VGS c_VGS%rowtype;
6984 l_pl_gd_or_svc_id number ;
6985 l_object_version_number number ;
6986 l_effective_start_date date ;
6987 l_effective_end_date date ;
6988 l_prefix pqh_copy_entity_attribs.information1%type := null;
6989 l_suffix pqh_copy_entity_attribs.information1%type := null;
6990 l_new_value number(15);
6991 l_object_found_in_target boolean := false ;
6992 l_min_esd date;
6993 l_max_eed date;
6994 l_effective_date date;
6995 --
6996 begin
6997 -- Initialization
6998 l_object_found_in_target := false ;
6999 -- End Initialization
7000 -- Derive the prefix - sufix
7001 if p_prefix_suffix_cd = 'PREFIX' then
7002 l_prefix := p_prefix_suffix_text ;
7003 elsif p_prefix_suffix_cd = 'SUFFIX' then
7004 l_suffix := p_prefix_suffix_text ;
7005 else
7006 l_prefix := null ;
7007 l_suffix := null ;
7008 end if ;
7009 -- End Prefix Sufix derivation
7010 for r_VGS_unique in c_unique_VGS('VGS') loop
7011
7012 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
7013 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7014 r_VGS_unique.information3 >=
7015 ben_pd_copy_to_ben_one.g_copy_effective_date)
7016 ) then
7017 --
7018 hr_utility.set_location(' r_VGS_unique.table_route_id '||r_VGS_unique.table_route_id,10);
7019 hr_utility.set_location(' r_VGS_unique.information1 '||r_VGS_unique.information1,10);
7020 hr_utility.set_location( 'r_VGS_unique.information2 '||r_VGS_unique.information2,10);
7021 hr_utility.set_location( 'r_VGS_unique.information3 '||r_VGS_unique.information3,10);
7022 -- If reuse objects flag is 'Y' then check for the object in the target business group
7023 -- if found insert the record into PLSql table and exit the loop else try create the
7024 -- object in the target business group
7025 --
7026 l_object_found_in_target := false ;
7027 --UPD START
7028 open c_VGS(r_VGS_unique.table_route_id,
7029 r_VGS_unique.information1,
7030 r_VGS_unique.information2,
7031 r_VGS_unique.information3 ) ;
7032 --
7033 fetch c_VGS into r_VGS ;
7034 --
7035 close c_VGS ;
7036 --
7037 l_dml_operation:= r_VGS_unique.dml_operation ;
7038 l_GD_OR_SVC_TYP_ID := get_fk('GD_OR_SVC_TYP_ID', r_VGS.INFORMATION262,l_dml_operation);
7039 l_PL_ID := get_fk('PL_ID', r_VGS.INFORMATION261,l_dml_operation);
7040 --
7041 l_update := false;
7042 l_process_date := p_effective_date;
7043 --
7044 if l_dml_operation = 'UPDATE' then
7045 --
7046 l_object_found_in_target := TRUE;
7047 --
7048 if l_process_date between r_VGS_unique.information2 and r_VGS_unique.information3 then
7049 l_update := true;
7050 if r_VGS_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
7051 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_GD_OR_SVC_ID'
7052 then
7053 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_GD_OR_SVC_ID' ;
7054 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_VGS_unique.information1 ;
7055 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_VGS_unique.information1 ;
7056 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
7057 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_VGS_unique.table_route_id;
7058 --
7059 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
7060 --
7061 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
7062 --
7063 --DOUBT log_data('VGS',l_new_value,l_prefix || r_VGS_unique.name|| l_suffix,'REUSED');
7064 --
7065 end if ;
7066 hr_utility.set_location( 'found record for update',10);
7067 --
7068 else
7069 --
7070 l_update := false;
7071 --
7072 end if;
7073 else
7074 --
7075 --UPD END
7076
7077 l_min_esd := null ;
7078 l_max_eed := null ;
7079 open c_VGS_min_max_dates(r_VGS_unique.table_route_id, r_VGS_unique.information1 ) ;
7080 fetch c_VGS_min_max_dates into l_min_esd,l_max_eed ;
7081 --
7082
7083 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7084 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
7085 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
7086 end if;
7087 l_min_esd := greatest(l_min_esd,r_VGS_unique.information2);
7088 /* open c_VGS(r_VGS_unique.table_route_id,
7089 r_VGS_unique.information1,
7090 r_VGS_unique.information2,
7091 r_VGS_unique.information3 ) ;
7092 --
7093 fetch c_VGS into r_VGS ;
7094 --
7095 close c_VGS ; */
7096 --
7097 if p_reuse_object_flag = 'Y' then
7098 if c_VGS_min_max_dates%found then
7099 -- cursor to find the object
7100 open c_find_VGS_in_target( l_min_esd,l_max_eed,
7101 p_target_business_group_id, nvl(l_pl_gd_or_svc_id, -999) ) ;
7102 fetch c_find_VGS_in_target into l_new_value ;
7103 if c_find_VGS_in_target%found then
7104 --
7105 --TEMPIK
7106 l_dt_rec_found := dt_api.check_min_max_dates
7107 (p_base_table_name => 'BEN_PL_GD_OR_SVC_F',
7108 p_base_key_column => 'PL_GD_OR_SVC_ID',
7109 p_base_key_value => l_new_value,
7110 p_from_date => l_min_esd,
7111 p_to_date => l_max_eed );
7112 if l_dt_rec_found THEN
7113 --END TEMPIK
7114 if r_VGS_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
7115 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_GD_OR_SVC_ID' then
7116 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_GD_OR_SVC_ID' ;
7117 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_VGS_unique.information1 ;
7118 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
7119 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
7120 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_VGS_unique.table_route_id;
7121 --
7122 -- 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) ;
7123 --
7124 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
7125 end if ;
7126 --
7127 l_object_found_in_target := true ;
7128 --TEMPIK
7129 end if; -- l_dt_rec_found
7130 --END TEMPIK
7131 end if;
7132 close c_find_VGS_in_target ;
7133 --
7134 end if;
7135 end if ;
7136 --
7137 close c_VGS_min_max_dates ;
7138 end if; --if p_dml_operation
7139 --
7140 if not l_object_found_in_target OR l_update then
7141 --
7142 l_current_pk_id := r_VGS.information1;
7143 --
7144 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
7145 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
7146 --
7147 if l_current_pk_id = l_prev_pk_id then
7148 --
7149 l_first_rec := false ;
7150 --
7151 else
7152 --
7153 l_first_rec := true ;
7154 --
7155 end if ;
7156 --
7157
7158 l_effective_date := r_VGS.information2;
7159 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7160 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
7161 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
7162 end if;
7163
7164 if l_first_rec and not l_update then
7165 -- Call Create routine.
7166 hr_utility.set_location(' BEN_PL_GD_OR_SVC_F CREATE_PLAN_GOODS_SERVICES ',20);
7167 BEN_PLAN_GOODS_SERVICES_API.CREATE_PLAN_GOODS_SERVICES(
7168 --
7169 P_VALIDATE => false
7170 ,P_EFFECTIVE_DATE => l_effective_date
7171 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
7172 --
7173 ,P_ALW_RCRRG_CLMS_FLAG => r_VGS.INFORMATION13
7174 ,P_GD_OR_SVC_TYP_ID => l_GD_OR_SVC_TYP_ID
7175 ,P_GD_OR_SVC_USG_CD => r_VGS.INFORMATION12
7176 ,P_GD_SVC_RECD_BASIS_CD => r_VGS.INFORMATION11
7177 ,P_GD_SVC_RECD_BASIS_DT => r_VGS.INFORMATION306
7178 ,P_GD_SVC_RECD_BASIS_MO => r_VGS.INFORMATION257
7179 ,P_PL_GD_OR_SVC_ID => l_pl_gd_or_svc_id
7180 ,P_PL_ID => l_PL_ID
7181 ,P_VGS_ATTRIBUTE1 => r_VGS.INFORMATION111
7182 ,P_VGS_ATTRIBUTE10 => r_VGS.INFORMATION120
7183 ,P_VGS_ATTRIBUTE11 => r_VGS.INFORMATION121
7184 ,P_VGS_ATTRIBUTE12 => r_VGS.INFORMATION122
7185 ,P_VGS_ATTRIBUTE13 => r_VGS.INFORMATION123
7186 ,P_VGS_ATTRIBUTE14 => r_VGS.INFORMATION124
7187 ,P_VGS_ATTRIBUTE15 => r_VGS.INFORMATION125
7188 ,P_VGS_ATTRIBUTE16 => r_VGS.INFORMATION126
7189 ,P_VGS_ATTRIBUTE17 => r_VGS.INFORMATION127
7190 ,P_VGS_ATTRIBUTE18 => r_VGS.INFORMATION128
7191 ,P_VGS_ATTRIBUTE19 => r_VGS.INFORMATION129
7192 ,P_VGS_ATTRIBUTE2 => r_VGS.INFORMATION112
7193 ,P_VGS_ATTRIBUTE20 => r_VGS.INFORMATION130
7194 ,P_VGS_ATTRIBUTE21 => r_VGS.INFORMATION131
7195 ,P_VGS_ATTRIBUTE22 => r_VGS.INFORMATION132
7196 ,P_VGS_ATTRIBUTE23 => r_VGS.INFORMATION133
7197 ,P_VGS_ATTRIBUTE24 => r_VGS.INFORMATION134
7198 ,P_VGS_ATTRIBUTE25 => r_VGS.INFORMATION135
7199 ,P_VGS_ATTRIBUTE26 => r_VGS.INFORMATION136
7200 ,P_VGS_ATTRIBUTE27 => r_VGS.INFORMATION137
7201 ,P_VGS_ATTRIBUTE28 => r_VGS.INFORMATION138
7202 ,P_VGS_ATTRIBUTE29 => r_VGS.INFORMATION139
7203 ,P_VGS_ATTRIBUTE3 => r_VGS.INFORMATION113
7204 ,P_VGS_ATTRIBUTE30 => r_VGS.INFORMATION140
7205 ,P_VGS_ATTRIBUTE4 => r_VGS.INFORMATION114
7206 ,P_VGS_ATTRIBUTE5 => r_VGS.INFORMATION115
7207 ,P_VGS_ATTRIBUTE6 => r_VGS.INFORMATION116
7208 ,P_VGS_ATTRIBUTE7 => r_VGS.INFORMATION117
7209 ,P_VGS_ATTRIBUTE8 => r_VGS.INFORMATION118
7210 ,P_VGS_ATTRIBUTE9 => r_VGS.INFORMATION119
7211 ,P_VGS_ATTRIBUTE_CATEGORY => r_VGS.INFORMATION110
7212 --
7213 ,P_EFFECTIVE_START_DATE => l_effective_start_date
7214 ,P_EFFECTIVE_END_DATE => l_effective_end_date
7215 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
7216 );
7217 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
7218 -- Update all relevent cer records with new pk_id
7219 hr_utility.set_location('Before plsql table ',222);
7220 hr_utility.set_location('new_value id '||l_pl_gd_or_svc_id,222);
7221 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_GD_OR_SVC_ID' ;
7222 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_VGS.information1 ;
7223 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PL_GD_OR_SVC_ID ;
7224 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
7225 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_VGS_unique.table_route_id;
7226 hr_utility.set_location('After plsql table ',222);
7227 --
7228 -- 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 ) ;
7229 --
7230 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
7231 --
7232 else
7233 --
7234 -- Call Update routine for the pk_id created in prev run .
7235 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
7236 hr_utility.set_location(' BEN_PL_GD_OR_SVC_F UPDATE_PLAN_GOODS_SERVICES ',30);
7237 --UPD START
7238 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
7239 --
7240 if l_update then
7241 --
7242 l_datetrack_mode := r_VGS.datetrack_mode ;
7243 --
7244 get_dt_modes(
7245 p_effective_date => l_process_date,
7246 p_effective_end_date => r_VGS.information3,
7247 p_effective_start_date => r_VGS.information2,
7248 p_dml_operation => r_VGS.dml_operation,
7249 p_datetrack_mode => l_datetrack_mode );
7250 -- p_update => l_update
7251 --
7252 l_effective_date := l_process_date;
7253 l_PL_GD_OR_SVC_ID := r_VGS.information1;
7254 l_object_version_number := r_VGS.information265;
7255 --
7256 end if;
7257 --
7258 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
7259 --
7260 IF l_update OR l_dml_operation <> 'UPDATE' THEN
7261 --UPD END
7262
7263 BEN_PLAN_GOODS_SERVICES_API.UPDATE_PLAN_GOODS_SERVICES(
7264 --
7265 P_VALIDATE => false
7266 ,P_EFFECTIVE_DATE => l_effective_date
7267 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
7268 --
7269 ,P_ALW_RCRRG_CLMS_FLAG => r_VGS.INFORMATION13
7270 ,P_GD_OR_SVC_TYP_ID => l_GD_OR_SVC_TYP_ID
7271 ,P_GD_OR_SVC_USG_CD => r_VGS.INFORMATION12
7272 ,P_GD_SVC_RECD_BASIS_CD => r_VGS.INFORMATION11
7273 ,P_GD_SVC_RECD_BASIS_DT => r_VGS.INFORMATION306
7274 ,P_GD_SVC_RECD_BASIS_MO => r_VGS.INFORMATION257
7275 ,P_PL_GD_OR_SVC_ID => l_pl_gd_or_svc_id
7276 ,P_PL_ID => l_PL_ID
7277 ,P_VGS_ATTRIBUTE1 => r_VGS.INFORMATION111
7278 ,P_VGS_ATTRIBUTE10 => r_VGS.INFORMATION120
7279 ,P_VGS_ATTRIBUTE11 => r_VGS.INFORMATION121
7280 ,P_VGS_ATTRIBUTE12 => r_VGS.INFORMATION122
7281 ,P_VGS_ATTRIBUTE13 => r_VGS.INFORMATION123
7282 ,P_VGS_ATTRIBUTE14 => r_VGS.INFORMATION124
7283 ,P_VGS_ATTRIBUTE15 => r_VGS.INFORMATION125
7284 ,P_VGS_ATTRIBUTE16 => r_VGS.INFORMATION126
7285 ,P_VGS_ATTRIBUTE17 => r_VGS.INFORMATION127
7286 ,P_VGS_ATTRIBUTE18 => r_VGS.INFORMATION128
7287 ,P_VGS_ATTRIBUTE19 => r_VGS.INFORMATION129
7288 ,P_VGS_ATTRIBUTE2 => r_VGS.INFORMATION112
7289 ,P_VGS_ATTRIBUTE20 => r_VGS.INFORMATION130
7290 ,P_VGS_ATTRIBUTE21 => r_VGS.INFORMATION131
7291 ,P_VGS_ATTRIBUTE22 => r_VGS.INFORMATION132
7292 ,P_VGS_ATTRIBUTE23 => r_VGS.INFORMATION133
7293 ,P_VGS_ATTRIBUTE24 => r_VGS.INFORMATION134
7294 ,P_VGS_ATTRIBUTE25 => r_VGS.INFORMATION135
7295 ,P_VGS_ATTRIBUTE26 => r_VGS.INFORMATION136
7296 ,P_VGS_ATTRIBUTE27 => r_VGS.INFORMATION137
7297 ,P_VGS_ATTRIBUTE28 => r_VGS.INFORMATION138
7298 ,P_VGS_ATTRIBUTE29 => r_VGS.INFORMATION139
7299 ,P_VGS_ATTRIBUTE3 => r_VGS.INFORMATION113
7300 ,P_VGS_ATTRIBUTE30 => r_VGS.INFORMATION140
7301 ,P_VGS_ATTRIBUTE4 => r_VGS.INFORMATION114
7302 ,P_VGS_ATTRIBUTE5 => r_VGS.INFORMATION115
7303 ,P_VGS_ATTRIBUTE6 => r_VGS.INFORMATION116
7304 ,P_VGS_ATTRIBUTE7 => r_VGS.INFORMATION117
7305 ,P_VGS_ATTRIBUTE8 => r_VGS.INFORMATION118
7306 ,P_VGS_ATTRIBUTE9 => r_VGS.INFORMATION119
7307 ,P_VGS_ATTRIBUTE_CATEGORY => r_VGS.INFORMATION110
7308 --
7309 ,P_EFFECTIVE_START_DATE => l_effective_start_date
7310 ,P_EFFECTIVE_END_DATE => l_effective_end_date
7311 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
7312 ,P_DATETRACK_MODE => hr_api.g_update
7313 );
7314 --
7315 end if;
7316 --
7317 -- Delete the row if it is end dated.
7318 --
7319 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
7320 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
7321 trunc(l_max_eed) = r_VGS.information3) then
7322 --
7323 BEN_PLAN_GOODS_SERVICES_API.delete_PLAN_GOODS_SERVICES(
7324 --
7325 p_validate => false
7326 ,p_pl_gd_or_svc_id => l_pl_gd_or_svc_id
7327 ,p_effective_start_date => l_effective_start_date
7328 ,p_effective_end_date => l_effective_end_date
7329 ,p_object_version_number => l_object_version_number
7330 ,p_effective_date => l_max_eed
7331 ,P_DATETRACK_MODE => l_datetrack_mode
7332 --
7333 );
7334 --
7335 end if; -- l_update
7336 end if;
7337 --
7338 l_prev_pk_id := l_current_pk_id ;
7339 --
7340 end if;
7341 --
7342 end if;
7343 --
7344 end loop;
7345 --
7346 exception when others then
7347 --
7348 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'VGS',r_vgs.information5 );
7349 --
7350 end create_VGS_rows;
7351
7352 --
7353 ---------------------------------------------------------------
7354 ----------------------< create_LBR_rows >-----------------------
7355 ---------------------------------------------------------------
7356 --
7357 procedure create_LBR_rows
7358 (
7359 p_validate in number default 0
7360 ,p_copy_entity_txn_id in number
7361 ,p_effective_date in date
7362 ,p_prefix_suffix_text in varchar2 default null
7363 ,p_reuse_object_flag in varchar2 default null
7364 ,p_target_business_group_id in varchar2 default null
7365 ,p_prefix_suffix_cd in varchar2 default null
7366 ) is
7367 --
7368 l_DFLT_TO_ASN_PNDG_CTFN_RL number;
7369 l_LER_ID number;
7370 l_MN_CVG_RL number;
7371 l_MX_CVG_RL number;
7372 l_PLIP_ID number;
7373 l_PL_ID number;
7374 cursor c_unique_LBR(l_table_alias varchar2) is
7375 select distinct cpe.information1,
7376 cpe.information2,
7377 cpe.information3,
7378 cpe.table_route_id
7379 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
7380 pqh_table_route tr
7381 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7382 and cpe.table_route_id = tr.table_route_id
7383 -- and tr.where_clause = l_BEN_LER_BNFT_RSTRN_F
7384 and tr.table_alias = l_table_alias
7385 and cpe.number_of_copies = 1 -- ADDITION
7386 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
7387 order by information1, information2; --added for bug: 5151945
7388 --
7389 --
7390 cursor c_LBR_min_max_dates(c_table_route_id number,
7391 c_information1 number) is
7392 select
7393 min(cpe.information2) min_esd,
7394 max(cpe.information3) min_eed
7395 from ben_copy_entity_results cpe
7396 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7397 and cpe.table_route_id = c_table_route_id
7398 and cpe.information1 = c_information1 ;
7399 --
7400 cursor c_LBR(c_table_route_id number,
7401 c_information1 number,
7402 c_information2 date,
7403 c_information3 date ) is
7404 select
7405 cpe.*
7406 from ben_copy_entity_results cpe
7407 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7408 and cpe.table_route_id = c_table_route_id
7409 and cpe.information1 = c_information1
7410 and cpe.information2 = c_information2
7411 and cpe.information3 = c_information3
7412 and rownum = 1 ;
7413 -- Date Track target record
7414 cursor c_find_LBR_in_target(
7415 c_effective_start_date date,
7416 c_effective_end_date date,
7417 c_business_group_id number,
7418 c_new_pk_id number) is
7419 select
7420 LBR.ler_bnft_rstrn_id new_value
7421 from BEN_LER_BNFT_RSTRN_F LBR
7422 where
7423 LBR.LER_ID = l_LER_ID and
7424 nvl(LBR.PLIP_ID,-999) = nvl(l_PLIP_ID,-999) and
7425 nvl(LBR.PL_ID,-999) = nvl(l_PL_ID,-999) and
7426 LBR.business_group_id = c_business_group_id
7427 and LBR.ler_bnft_rstrn_id <> c_new_pk_id
7428 --TEMPIK
7429 and c_effective_start_date between effective_start_date
7430 and effective_end_date ;
7431 --END TEMPIK
7432 /*TEMPIK
7433 and exists ( select null
7434 from BEN_LER_BNFT_RSTRN_F LBR1
7435 where
7436 LBR1.LER_ID = l_LER_ID and
7437 nvl(LBR1.PLIP_ID,-999) = nvl(l_PLIP_ID,-999) and
7438 nvl(LBR1.PL_ID,-999) = nvl(l_PL_ID,-999) and
7439 LBR1.business_group_id = c_business_group_id
7440 and LBR1.effective_start_date <= c_effective_start_date )
7441 and exists ( select null
7442 from BEN_LER_BNFT_RSTRN_F LBR2
7443 where
7444 LBR2.LER_ID = l_LER_ID and
7445 nvl(LBR2.PLIP_ID,-999) = nvl(l_PLIP_ID,-999) and
7446 nvl(LBR2.PL_ID,-999) = nvl(l_PL_ID,-999) and
7447 LBR2.business_group_id = c_business_group_id
7448 and LBR2.effective_end_date >= c_effective_end_date )
7449 ;
7450 TEMPIK */
7451 --TEMPIK
7452 l_dt_rec_found boolean ;
7453 --END TEMPIK
7454 --
7455 --UPD START
7456 --
7457 l_update boolean := false ;
7458 l_datetrack_mode varchar2(80) := hr_api.g_update;
7459 l_process_date date;
7460 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
7461 --
7462 --UPD END
7463 l_current_pk_id number := null ;
7464 l_prev_pk_id number := null ;
7465 l_first_rec boolean := true ;
7466 r_LBR c_LBR%rowtype;
7467 l_ler_bnft_rstrn_id number ;
7468 l_object_version_number number ;
7469 l_effective_start_date date ;
7470 l_effective_end_date date ;
7471 l_prefix pqh_copy_entity_attribs.information1%type := null;
7472 l_suffix pqh_copy_entity_attribs.information1%type := null;
7473 l_new_value number(15);
7474 l_object_found_in_target boolean := false ;
7475 l_min_esd date;
7476 l_max_eed date;
7477 l_effective_date date;
7478 --
7479 begin
7480 -- Initialization
7481 l_object_found_in_target := false ;
7482 -- End Initialization
7483 -- Derive the prefix - sufix
7484 if p_prefix_suffix_cd = 'PREFIX' then
7485 l_prefix := p_prefix_suffix_text ;
7486 elsif p_prefix_suffix_cd = 'SUFFIX' then
7487 l_suffix := p_prefix_suffix_text ;
7488 else
7489 l_prefix := null ;
7490 l_suffix := null ;
7491 end if ;
7492 -- End Prefix Sufix derivation
7493 for r_LBR_unique in c_unique_LBR('LBR') loop
7494
7495 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
7496 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7497 r_LBR_unique.information3 >=
7498 ben_pd_copy_to_ben_one.g_copy_effective_date)
7499 ) then
7500
7501 --
7502 hr_utility.set_location(' r_LBR_unique.table_route_id '||r_LBR_unique.table_route_id,10);
7503 hr_utility.set_location(' r_LBR_unique.information1 '||r_LBR_unique.information1,10);
7504 hr_utility.set_location( 'r_LBR_unique.information2 '||r_LBR_unique.information2,10);
7505 hr_utility.set_location( 'r_LBR_unique.information3 '||r_LBR_unique.information3,10);
7506 -- If reuse objects flag is 'Y' then check for the object in the target business group
7507 -- if found insert the record into PLSql table and exit the loop else try create the
7508 -- object in the target business group
7509 --
7510 l_object_found_in_target := false ;
7511 --UPD START
7512 open c_LBR(r_LBR_unique.table_route_id,
7513 r_LBR_unique.information1,
7514 r_LBR_unique.information2,
7515 r_LBR_unique.information3 ) ;
7516 --
7517 fetch c_LBR into r_LBR ;
7518 --
7519 close c_LBR ;
7520 --
7521 l_dml_operation:= r_LBR_unique.dml_operation ;
7522 l_DFLT_TO_ASN_PNDG_CTFN_RL := get_fk('FORMULA_ID', r_LBR.INFORMATION262,l_dml_operation);
7523 l_LER_ID := get_fk('LER_ID', r_LBR.INFORMATION257,l_dml_operation);
7524 l_MN_CVG_RL := get_fk('FORMULA_ID', r_LBR.INFORMATION268,l_dml_operation);
7525 l_MX_CVG_RL := get_fk('FORMULA_ID', r_LBR.INFORMATION266,l_dml_operation);
7526 l_PLIP_ID := get_fk('PLIP_ID', r_LBR.INFORMATION256,l_dml_operation);
7527 l_PL_ID := get_fk('PL_ID', r_LBR.INFORMATION261,l_dml_operation);
7528 --
7529 l_update := false;
7530 l_process_date := p_effective_date;
7531 --
7532 if l_dml_operation = 'UPDATE' then
7533 --
7534 l_object_found_in_target := TRUE;
7535 --
7536 if l_process_date between r_LBR_unique.information2 and r_LBR_unique.information3 then
7537 l_update := true;
7538 if r_LBR_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
7539 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_BNFT_RSTRN_ID'
7540 then
7541 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_BNFT_RSTRN_ID' ;
7542 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LBR_unique.information1 ;
7543 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LBR_unique.information1 ;
7544 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
7545 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LBR_unique.table_route_id;
7546 --
7547 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
7548 --
7549 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
7550 --
7551 --DOUBT log_data('LBR',l_new_value,l_prefix || r_LBR_unique.name|| l_suffix,'REUSED');
7552 --
7553 end if ;
7554 hr_utility.set_location( 'found record for update',10);
7555 --
7556 else
7557 --
7558 l_update := false;
7559 --
7560 end if;
7561 else
7562 --
7563 --UPD END
7564 l_min_esd := null ;
7565 l_max_eed := null ;
7566 open c_LBR_min_max_dates(r_LBR_unique.table_route_id, r_LBR_unique.information1 ) ;
7567 fetch c_LBR_min_max_dates into l_min_esd,l_max_eed ;
7568 --
7569
7570 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7571 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
7572 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
7573 end if;
7574 l_min_esd := greatest(l_min_esd,r_LBR_unique.information2);
7575 /* open c_LBR(r_LBR_unique.table_route_id,
7576 r_LBR_unique.information1,
7577 r_LBR_unique.information2,
7578 r_LBR_unique.information3 ) ;
7579 --
7580 fetch c_LBR into r_LBR ;
7581 --
7582 close c_LBR ; */
7583 --
7584
7585 if p_reuse_object_flag = 'Y' then
7586 if c_LBR_min_max_dates%found then
7587 -- cursor to find the object
7588 open c_find_LBR_in_target( l_min_esd,l_max_eed,
7589 p_target_business_group_id, nvl(l_ler_bnft_rstrn_id, -999) ) ;
7590 fetch c_find_LBR_in_target into l_new_value ;
7591 if c_find_LBR_in_target%found then
7592 --
7593 --TEMPIK
7594 l_dt_rec_found := dt_api.check_min_max_dates
7595 (p_base_table_name => 'BEN_LER_BNFT_RSTRN_F',
7596 p_base_key_column => 'LER_BNFT_RSTRN_ID',
7597 p_base_key_value => l_new_value,
7598 p_from_date => l_min_esd,
7599 p_to_date => l_max_eed );
7600 if l_dt_rec_found THEN
7601 --END TEMPIK
7602 if r_LBR_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
7603 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_BNFT_RSTRN_ID' then
7604 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_BNFT_RSTRN_ID' ;
7605 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LBR_unique.information1 ;
7606 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
7607 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
7608 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LBR_unique.table_route_id;
7609 --
7610 -- 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) ;
7611 --
7612 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
7613 end if ;
7614 --
7615 l_object_found_in_target := true ;
7616 --TEMPIK
7617 end if; -- l_dt_rec_found
7618 --END TEMPIK
7619 end if;
7620 close c_find_LBR_in_target ;
7621 --
7622 end if;
7623 end if ;
7624 --
7625 close c_LBR_min_max_dates ;
7626 end if; --if p_dml_operation
7627 --
7628 if not l_object_found_in_target OR l_update then
7629
7630 --
7631 l_current_pk_id := r_LBR.information1;
7632 --
7633 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
7634 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
7635 --
7636 if l_current_pk_id = l_prev_pk_id then
7637 --
7638 l_first_rec := false ;
7639 --
7640 else
7641 --
7642 l_first_rec := true ;
7643 --
7644 end if ;
7645 --
7646
7647 l_effective_date := r_LBR.information2;
7648 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7649 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
7650 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
7651 end if;
7652
7653 if l_first_rec and not l_update then
7654 -- Call Create routine.
7655 hr_utility.set_location(' BEN_LER_BNFT_RSTRN_F CREATE_LER_BNFT_RSTRN ',20);
7656 BEN_LER_BNFT_RSTRN_API.CREATE_LER_BNFT_RSTRN(
7657 --
7658 P_VALIDATE => false
7659 ,P_EFFECTIVE_DATE => l_effective_date
7660 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
7661 --
7662 ,P_CVG_INCR_R_DECR_ONLY_CD => r_LBR.INFORMATION12
7663 ,P_DFLT_TO_ASN_PNDG_CTFN_CD => r_LBR.INFORMATION11
7664 ,P_DFLT_TO_ASN_PNDG_CTFN_RL => l_DFLT_TO_ASN_PNDG_CTFN_RL
7665 ,P_LBR_ATTRIBUTE1 => r_LBR.INFORMATION111
7666 ,P_LBR_ATTRIBUTE10 => r_LBR.INFORMATION120
7667 ,P_LBR_ATTRIBUTE11 => r_LBR.INFORMATION121
7668 ,P_LBR_ATTRIBUTE12 => r_LBR.INFORMATION122
7669 ,P_LBR_ATTRIBUTE13 => r_LBR.INFORMATION123
7670 ,P_LBR_ATTRIBUTE14 => r_LBR.INFORMATION124
7671 ,P_LBR_ATTRIBUTE15 => r_LBR.INFORMATION125
7672 ,P_LBR_ATTRIBUTE16 => r_LBR.INFORMATION126
7673 ,P_LBR_ATTRIBUTE17 => r_LBR.INFORMATION127
7674 ,P_LBR_ATTRIBUTE18 => r_LBR.INFORMATION128
7675 ,P_LBR_ATTRIBUTE19 => r_LBR.INFORMATION129
7676 ,P_LBR_ATTRIBUTE2 => r_LBR.INFORMATION112
7677 ,P_LBR_ATTRIBUTE20 => r_LBR.INFORMATION130
7678 ,P_LBR_ATTRIBUTE21 => r_LBR.INFORMATION131
7679 ,P_LBR_ATTRIBUTE22 => r_LBR.INFORMATION132
7680 ,P_LBR_ATTRIBUTE23 => r_LBR.INFORMATION133
7681 ,P_LBR_ATTRIBUTE24 => r_LBR.INFORMATION134
7682 ,P_LBR_ATTRIBUTE25 => r_LBR.INFORMATION135
7683 ,P_LBR_ATTRIBUTE26 => r_LBR.INFORMATION136
7684 ,P_LBR_ATTRIBUTE27 => r_LBR.INFORMATION137
7685 ,P_LBR_ATTRIBUTE28 => r_LBR.INFORMATION138
7686 ,P_LBR_ATTRIBUTE29 => r_LBR.INFORMATION139
7687 ,P_LBR_ATTRIBUTE3 => r_LBR.INFORMATION113
7688 ,P_LBR_ATTRIBUTE30 => r_LBR.INFORMATION140
7689 ,P_LBR_ATTRIBUTE4 => r_LBR.INFORMATION114
7690 ,P_LBR_ATTRIBUTE5 => r_LBR.INFORMATION115
7691 ,P_LBR_ATTRIBUTE6 => r_LBR.INFORMATION116
7692 ,P_LBR_ATTRIBUTE7 => r_LBR.INFORMATION117
7693 ,P_LBR_ATTRIBUTE8 => r_LBR.INFORMATION118
7694 ,P_LBR_ATTRIBUTE9 => r_LBR.INFORMATION119
7695 ,P_LBR_ATTRIBUTE_CATEGORY => r_LBR.INFORMATION110
7696 ,P_LER_BNFT_RSTRN_ID => l_ler_bnft_rstrn_id
7697 ,P_LER_ID => l_LER_ID
7698 ,P_MN_CVG_AMT => r_LBR.INFORMATION297
7699 ,P_MN_CVG_RL => l_MN_CVG_RL
7700 ,P_MX_CVG_ALWD_AMT => r_LBR.INFORMATION295
7701 ,P_MX_CVG_INCR_ALWD_AMT => r_LBR.INFORMATION294
7702 ,P_MX_CVG_INCR_WCF_ALWD_AMT => r_LBR.INFORMATION293
7703 ,P_MX_CVG_MLT_INCR_NUM => r_LBR.INFORMATION263
7704 ,P_MX_CVG_MLT_INCR_WCF_NUM => r_LBR.INFORMATION264
7705 ,P_MX_CVG_RL => l_MX_CVG_RL
7706 ,P_MX_CVG_WCFN_AMT => r_LBR.INFORMATION296
7707 ,P_MX_CVG_WCFN_MLT_NUM => r_LBR.INFORMATION267
7708 ,P_NO_MN_CVG_INCR_APLS_FLAG => r_LBR.INFORMATION14
7709 ,P_NO_MX_CVG_AMT_APLS_FLAG => r_LBR.INFORMATION15
7710 ,P_NO_MX_CVG_INCR_APLS_FLAG => r_LBR.INFORMATION16
7711 ,P_PLIP_ID => l_PLIP_ID
7712 ,P_PL_ID => l_PL_ID
7713 ,P_UNSSPND_ENRT_CD => r_LBR.INFORMATION13
7714 --ML
7715 ,P_SUSP_IF_CTFN_NOT_PRVD_FLAG =>nvl(r_LBR.INFORMATION198,'Y')
7716 ,P_CTFN_DETERMINE_CD => r_LBR.INFORMATION197
7717 --ML END
7718 ,P_EFFECTIVE_START_DATE => l_effective_start_date
7719 ,P_EFFECTIVE_END_DATE => l_effective_end_date
7720 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
7721 );
7722 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
7723 -- Update all relevent cer records with new pk_id
7724 hr_utility.set_location('Before plsql table ',222);
7725 hr_utility.set_location('new_value id '||l_ler_bnft_rstrn_id,222);
7726 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_BNFT_RSTRN_ID' ;
7727 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LBR.information1 ;
7728 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LER_BNFT_RSTRN_ID ;
7729 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
7730 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LBR_unique.table_route_id;
7731 hr_utility.set_location('After plsql table ',222);
7732 --
7733 -- 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 ) ;
7734 --
7735 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
7736 --
7737 else
7738 --
7739 -- Call Update routine for the pk_id created in prev run .
7740 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
7741 hr_utility.set_location(' BEN_LER_BNFT_RSTRN_F UPDATE_LER_BNFT_RSTRN ',30);
7742 --UPD START
7743 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
7744 --
7745 if l_update then
7746 --
7747 l_datetrack_mode := r_LBR.datetrack_mode ;
7748 --
7749 get_dt_modes(
7750 p_effective_date => l_process_date,
7751 p_effective_end_date => r_LBR.information3,
7752 p_effective_start_date => r_LBR.information2,
7753 p_dml_operation => r_LBR.dml_operation,
7754 p_datetrack_mode => l_datetrack_mode );
7755 -- p_update => l_update
7756 --
7757 l_effective_date := l_process_date;
7758 l_LER_BNFT_RSTRN_ID := r_LBR.information1;
7759 l_object_version_number := r_LBR.information265;
7760 --
7761 end if;
7762 --
7763 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
7764 --
7765 IF l_update OR l_dml_operation <> 'UPDATE' THEN
7766 --UPD END
7767
7768 BEN_LER_BNFT_RSTRN_API.UPDATE_LER_BNFT_RSTRN(
7769 --
7770 P_VALIDATE => false
7771 ,P_EFFECTIVE_DATE => l_effective_date
7772 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
7773 --
7774 ,P_CVG_INCR_R_DECR_ONLY_CD => r_LBR.INFORMATION12
7775 ,P_DFLT_TO_ASN_PNDG_CTFN_CD => r_LBR.INFORMATION11
7776 ,P_DFLT_TO_ASN_PNDG_CTFN_RL => l_DFLT_TO_ASN_PNDG_CTFN_RL
7777 ,P_LBR_ATTRIBUTE1 => r_LBR.INFORMATION111
7778 ,P_LBR_ATTRIBUTE10 => r_LBR.INFORMATION120
7779 ,P_LBR_ATTRIBUTE11 => r_LBR.INFORMATION121
7780 ,P_LBR_ATTRIBUTE12 => r_LBR.INFORMATION122
7781 ,P_LBR_ATTRIBUTE13 => r_LBR.INFORMATION123
7782 ,P_LBR_ATTRIBUTE14 => r_LBR.INFORMATION124
7783 ,P_LBR_ATTRIBUTE15 => r_LBR.INFORMATION125
7784 ,P_LBR_ATTRIBUTE16 => r_LBR.INFORMATION126
7785 ,P_LBR_ATTRIBUTE17 => r_LBR.INFORMATION127
7786 ,P_LBR_ATTRIBUTE18 => r_LBR.INFORMATION128
7787 ,P_LBR_ATTRIBUTE19 => r_LBR.INFORMATION129
7788 ,P_LBR_ATTRIBUTE2 => r_LBR.INFORMATION112
7789 ,P_LBR_ATTRIBUTE20 => r_LBR.INFORMATION130
7790 ,P_LBR_ATTRIBUTE21 => r_LBR.INFORMATION131
7791 ,P_LBR_ATTRIBUTE22 => r_LBR.INFORMATION132
7792 ,P_LBR_ATTRIBUTE23 => r_LBR.INFORMATION133
7793 ,P_LBR_ATTRIBUTE24 => r_LBR.INFORMATION134
7794 ,P_LBR_ATTRIBUTE25 => r_LBR.INFORMATION135
7795 ,P_LBR_ATTRIBUTE26 => r_LBR.INFORMATION136
7796 ,P_LBR_ATTRIBUTE27 => r_LBR.INFORMATION137
7797 ,P_LBR_ATTRIBUTE28 => r_LBR.INFORMATION138
7798 ,P_LBR_ATTRIBUTE29 => r_LBR.INFORMATION139
7799 ,P_LBR_ATTRIBUTE3 => r_LBR.INFORMATION113
7800 ,P_LBR_ATTRIBUTE30 => r_LBR.INFORMATION140
7801 ,P_LBR_ATTRIBUTE4 => r_LBR.INFORMATION114
7802 ,P_LBR_ATTRIBUTE5 => r_LBR.INFORMATION115
7803 ,P_LBR_ATTRIBUTE6 => r_LBR.INFORMATION116
7804 ,P_LBR_ATTRIBUTE7 => r_LBR.INFORMATION117
7805 ,P_LBR_ATTRIBUTE8 => r_LBR.INFORMATION118
7806 ,P_LBR_ATTRIBUTE9 => r_LBR.INFORMATION119
7807 ,P_LBR_ATTRIBUTE_CATEGORY => r_LBR.INFORMATION110
7808 ,P_LER_BNFT_RSTRN_ID => l_ler_bnft_rstrn_id
7809 ,P_LER_ID => l_LER_ID
7810 ,P_MN_CVG_AMT => r_LBR.INFORMATION297
7811 ,P_MN_CVG_RL => l_MN_CVG_RL
7812 ,P_MX_CVG_ALWD_AMT => r_LBR.INFORMATION295
7813 ,P_MX_CVG_INCR_ALWD_AMT => r_LBR.INFORMATION294
7814 ,P_MX_CVG_INCR_WCF_ALWD_AMT => r_LBR.INFORMATION293
7815 ,P_MX_CVG_MLT_INCR_NUM => r_LBR.INFORMATION263
7816 ,P_MX_CVG_MLT_INCR_WCF_NUM => r_LBR.INFORMATION264
7817 ,P_MX_CVG_RL => l_MX_CVG_RL
7818 ,P_MX_CVG_WCFN_AMT => r_LBR.INFORMATION296
7819 ,P_MX_CVG_WCFN_MLT_NUM => r_LBR.INFORMATION267
7820 ,P_NO_MN_CVG_INCR_APLS_FLAG => r_LBR.INFORMATION14
7821 ,P_NO_MX_CVG_AMT_APLS_FLAG => r_LBR.INFORMATION15
7822 ,P_NO_MX_CVG_INCR_APLS_FLAG => r_LBR.INFORMATION16
7823 ,P_PLIP_ID => l_PLIP_ID
7824 ,P_PL_ID => l_PL_ID
7825 ,P_UNSSPND_ENRT_CD => r_LBR.INFORMATION13
7826 --ML
7827 ,P_SUSP_IF_CTFN_NOT_PRVD_FLAG =>nvl(r_LBR.INFORMATION198,'Y')
7828 ,P_CTFN_DETERMINE_CD => r_LBR.INFORMATION197
7829 --ML END
7830 ,P_EFFECTIVE_START_DATE => l_effective_start_date
7831 ,P_EFFECTIVE_END_DATE => l_effective_end_date
7832 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
7833 ,P_DATETRACK_MODE => l_datetrack_mode
7834 );
7835 --
7836 end if; -- l_update
7837 end if;
7838 --
7839 -- Delete the row if it is end dated.
7840 --
7841 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
7842 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
7843 trunc(l_max_eed) = r_LBR.information3) then
7844 --
7845 BEN_LER_BNFT_RSTRN_API.delete_LER_BNFT_RSTRN(
7846 --
7847 p_validate => false
7848 ,p_ler_bnft_rstrn_id => l_ler_bnft_rstrn_id
7849 ,p_effective_start_date => l_effective_start_date
7850 ,p_effective_end_date => l_effective_end_date
7851 ,p_object_version_number => l_object_version_number
7852 ,p_effective_date => l_max_eed
7853 ,p_datetrack_mode => hr_api.g_delete
7854 --
7855 );
7856 --
7857
7858 end if;
7859 --
7860 l_prev_pk_id := l_current_pk_id ;
7861 --
7862 end if;
7863 --
7864 end if;
7865 --
7866 end loop;
7867 --
7868 exception when others then
7869 --
7870 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LBR',r_lbr.information5 );
7871 --
7872 end create_LBR_rows;
7873
7874 --
7875 ---------------------------------------------------------------
7876 ----------------------< create_LPR1_rows >-----------------------
7877 ---------------------------------------------------------------
7878 --
7879 procedure create_LPR1_rows
7880 (
7881 p_validate in number default 0
7882 ,p_copy_entity_txn_id in number
7883 ,p_effective_date in date
7884 ,p_prefix_suffix_text in varchar2 default null
7885 ,p_reuse_object_flag in varchar2 default null
7886 ,p_target_business_group_id in varchar2 default null
7887 ,p_prefix_suffix_cd in varchar2 default null
7888 ) is
7889 --
7890 l_AUTO_ENRT_MTHD_RL number;
7891 l_DFLT_ENRT_RL number;
7892 l_ENRT_RL number;
7893 l_LER_ID number;
7894 l_PLIP_ID number;
7895 cursor c_unique_LPR1(l_table_alias varchar2) is
7896 select distinct cpe.information1,
7897 cpe.information2,
7898 cpe.information3,
7899 cpe.table_route_id
7900 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
7901 pqh_table_route tr
7902 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7903 and cpe.table_route_id = tr.table_route_id
7904 -- and tr.where_clause = l_BEN_LER_CHG_PLIP_ENRT_F
7905 and tr.table_alias = l_table_alias
7906 and cpe.number_of_copies = 1 -- ADDITION
7907 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
7908 order by information1, information2; --added for bug: 5151945
7909 --
7910 --
7911 cursor c_LPR1_min_max_dates(c_table_route_id number,
7912 c_information1 number) is
7913 select
7914 min(cpe.information2) min_esd,
7915 max(cpe.information3) min_eed
7916 from ben_copy_entity_results cpe
7917 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7918 and cpe.table_route_id = c_table_route_id
7919 and cpe.information1 = c_information1 ;
7920 --
7921 cursor c_LPR1(c_table_route_id number,
7922 c_information1 number,
7923 c_information2 date,
7924 c_information3 date ) is
7925 select
7926 cpe.*
7927 from ben_copy_entity_results cpe
7928 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7929 and cpe.table_route_id = c_table_route_id
7930 and cpe.information1 = c_information1
7931 and cpe.information2 = c_information2
7932 and cpe.information3 = c_information3
7933 and rownum = 1 ;
7934 -- Date Track target record
7935 cursor c_find_LPR1_in_target(
7936 c_effective_start_date date,
7937 c_effective_end_date date,
7938 c_business_group_id number,
7939 c_new_pk_id number) is
7940 select
7941 LPR1.ler_chg_plip_enrt_id new_value
7942 from BEN_LER_CHG_PLIP_ENRT_F LPR1
7943 where
7944 LPR1.LER_ID = l_LER_ID and
7945 LPR1.PLIP_ID = l_PLIP_ID and
7946 LPR1.business_group_id = c_business_group_id
7947 and LPR1.ler_chg_plip_enrt_id <> c_new_pk_id
7948 --TEMPIK
7949 and c_effective_start_date between effective_start_date
7950 and effective_end_date ;
7951 --END TEMPIK
7952 /*TEMPIK
7953 and exists ( select null
7954 from BEN_LER_CHG_PLIP_ENRT_F LPR11
7955 where
7956 LPR11.LER_ID = l_LER_ID and
7957 LPR11.PLIP_ID = l_PLIP_ID and
7958 LPR11.business_group_id = c_business_group_id
7959 and LPR11.effective_start_date <= c_effective_start_date )
7960 and exists ( select null
7961 from BEN_LER_CHG_PLIP_ENRT_F LPR12
7962 where
7963 LPR12.LER_ID = l_LER_ID and
7964 LPR12.PLIP_ID = l_PLIP_ID and
7965 LPR12.business_group_id = c_business_group_id
7966 and LPR12.effective_end_date >= c_effective_end_date )
7967 ;
7968 TEMPIK */
7969 --TEMPIK
7970 l_dt_rec_found boolean ;
7971 --END TEMPIK
7972 --
7973 --UPD START
7974 --
7975 l_update boolean := false ;
7976 l_datetrack_mode varchar2(80) := hr_api.g_update;
7977 l_process_date date;
7978 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
7979 --
7980 --UPD END
7981 l_current_pk_id number := null ;
7982 l_prev_pk_id number := null ;
7983 l_first_rec boolean := true ;
7984 r_LPR1 c_LPR1%rowtype;
7985 l_ler_chg_plip_enrt_id number ;
7986 l_object_version_number number ;
7987 l_effective_start_date date ;
7988 l_effective_end_date date ;
7989 l_prefix pqh_copy_entity_attribs.information1%type := null;
7990 l_suffix pqh_copy_entity_attribs.information1%type := null;
7991 l_new_value number(15);
7992 l_object_found_in_target boolean := false ;
7993 l_min_esd date;
7994 l_max_eed date;
7995 l_effective_date date;
7996 --
7997 begin
7998 -- Initialization
7999 l_object_found_in_target := false ;
8000 -- End Initialization
8001 -- Derive the prefix - sufix
8002 if p_prefix_suffix_cd = 'PREFIX' then
8003 l_prefix := p_prefix_suffix_text ;
8004 elsif p_prefix_suffix_cd = 'SUFFIX' then
8005 l_suffix := p_prefix_suffix_text ;
8006 else
8007 l_prefix := null ;
8008 l_suffix := null ;
8009 end if ;
8010 -- End Prefix Sufix derivation
8011 for r_LPR1_unique in c_unique_LPR1('LPR1') loop
8012
8013 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
8014 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8015 r_LPR1_unique.information3 >=
8016 ben_pd_copy_to_ben_one.g_copy_effective_date)
8017 ) then
8018
8019 --
8020 hr_utility.set_location(' r_LPR1_unique.table_route_id '||r_LPR1_unique.table_route_id,10);
8021 hr_utility.set_location(' r_LPR1_unique.information1 '||r_LPR1_unique.information1,10);
8022 hr_utility.set_location( 'r_LPR1_unique.information2 '||r_LPR1_unique.information2,10);
8023 hr_utility.set_location( 'r_LPR1_unique.information3 '||r_LPR1_unique.information3,10);
8024 -- If reuse objects flag is 'Y' then check for the object in the target business group
8025 -- if found insert the record into PLSql table and exit the loop else try create the
8026 -- object in the target business group
8027 --
8028 l_object_found_in_target := false ;
8029 --UPD START
8030 open c_LPR1(r_LPR1_unique.table_route_id,
8031 r_LPR1_unique.information1,
8032 r_LPR1_unique.information2,
8033 r_LPR1_unique.information3 ) ;
8034 --
8035 fetch c_LPR1 into r_LPR1 ;
8036 --
8037 close c_LPR1 ;
8038 l_update := false;
8039 l_process_date := p_effective_date;
8040 l_dml_operation:= r_LPR1_unique.dml_operation ;
8041 l_AUTO_ENRT_MTHD_RL := get_fk('FORMULA_ID', r_LPR1.INFORMATION262,l_dml_operation );
8042 l_DFLT_ENRT_RL := get_fk('FORMULA_ID', r_LPR1.INFORMATION263,l_dml_operation );
8043 l_ENRT_RL := get_fk('FORMULA_ID', r_LPR1.INFORMATION258,l_dml_operation );
8044 l_LER_ID := get_fk('LER_ID', r_LPR1.INFORMATION257,l_dml_operation );
8045 l_PLIP_ID := get_fk('PLIP_ID', r_LPR1.INFORMATION256,l_dml_operation );
8046 --
8047 if l_dml_operation = 'UPDATE' then
8048 --
8049 l_object_found_in_target := TRUE;
8050 --
8051 if l_process_date between r_LPR1_unique.information2 and r_LPR1_unique.information3 then
8052 l_update := true;
8053 if r_LPR1_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
8054 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_PLIP_ENRT_ID'
8055 then
8056 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_PLIP_ENRT_ID' ;
8057 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LPR1_unique.information1 ;
8058 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LPR1_unique.information1 ;
8059 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
8060 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LPR1_unique.table_route_id;
8061 --
8062 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
8063 --
8064 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
8065 --
8066 --DOUBT log_data('LPR1',l_new_value,l_prefix || r_LPR1_unique.name|| l_suffix,'REUSED');
8067 --
8068 end if ;
8069 hr_utility.set_location( 'found record for update',10);
8070 --
8071 else
8072 --
8073 l_update := false;
8074 --
8075 end if;
8076 else
8077 --
8078 --UPD END
8079
8080 l_min_esd := null ;
8081 l_max_eed := null ;
8082 open c_LPR1_min_max_dates(r_LPR1_unique.table_route_id, r_LPR1_unique.information1 ) ;
8083 fetch c_LPR1_min_max_dates into l_min_esd,l_max_eed ;
8084 --
8085
8086 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8087 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
8088 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
8089 end if;
8090 l_min_esd := greatest(l_min_esd,r_LPR1_unique.information2);
8091 /* open c_LPR1(r_LPR1_unique.table_route_id,
8092 r_LPR1_unique.information1,
8093 r_LPR1_unique.information2,
8094 r_LPR1_unique.information3 ) ;
8095 --
8096 fetch c_LPR1 into r_LPR1 ;
8097 --
8098 close c_LPR1 ; */
8099 --
8100 if p_reuse_object_flag = 'Y' then
8101 if c_LPR1_min_max_dates%found then
8102 -- cursor to find the object
8103 open c_find_LPR1_in_target( l_min_esd,l_max_eed,
8104 p_target_business_group_id, nvl(l_ler_chg_plip_enrt_id, -999) ) ;
8105 fetch c_find_LPR1_in_target into l_new_value ;
8106 if c_find_LPR1_in_target%found then
8107 --
8108 --TEMPIK
8109 l_dt_rec_found := dt_api.check_min_max_dates
8110 (p_base_table_name => 'BEN_LER_CHG_PLIP_ENRT_F',
8111 p_base_key_column => 'LER_CHG_PLIP_ENRT_ID',
8112 p_base_key_value => l_new_value,
8113 p_from_date => l_min_esd,
8114 p_to_date => l_max_eed );
8115 if l_dt_rec_found THEN
8116 --END TEMPIK
8117 if r_LPR1_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
8118 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_PLIP_ENRT_ID' then
8119 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_PLIP_ENRT_ID' ;
8120 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LPR1_unique.information1 ;
8121 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
8122 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
8123 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LPR1_unique.table_route_id;
8124 --
8125 -- 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) ;
8126 --
8127 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
8128 end if ;
8129 --
8130 l_object_found_in_target := true ;
8131 --TEMPIK
8132 end if; -- l_dt_rec_found
8133 --END TEMPIK
8134 end if;
8135 close c_find_LPR1_in_target ;
8136 --
8137 end if;
8138 end if ;
8139 --
8140 close c_LPR1_min_max_dates ;
8141 end if; --if p_dml_operation
8142 --
8143 if not l_object_found_in_target OR l_update then
8144
8145 --
8146 l_current_pk_id := r_LPR1.information1;
8147 --
8148 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
8149 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
8150 --
8151 if l_current_pk_id = l_prev_pk_id then
8152 --
8153 l_first_rec := false ;
8154 --
8155 else
8156 --
8157 l_first_rec := true ;
8158 --
8159 end if ;
8160 --
8161
8162 l_effective_date := r_LPR1.information2;
8163 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8164 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
8165 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
8166 end if;
8167
8168 if l_first_rec and not l_update then
8169 -- Call Create routine.
8170 hr_utility.set_location(' BEN_LER_CHG_PLIP_ENRT_F CREATE_LER_CHG_PLAN_ENRT ',20);
8171 BEN_LER_CHG_PLAN_ENRT_API.CREATE_LER_CHG_PLAN_ENRT(
8172 --
8173 P_VALIDATE => false
8174 ,P_EFFECTIVE_DATE => l_effective_date
8175 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
8176 --
8177 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
8178 ,P_CRNT_ENRT_PRCLDS_CHG_FLAG => r_LPR1.INFORMATION12
8179 ,P_DFLT_ENRT_CD => r_LPR1.INFORMATION15
8180 ,P_DFLT_ENRT_RL => l_DFLT_ENRT_RL
8181 ,P_DFLT_FLAG => r_LPR1.INFORMATION13
8182 ,P_ENRT_CD => r_LPR1.INFORMATION16
8183 ,P_ENRT_MTHD_CD => r_LPR1.INFORMATION17
8184 ,P_ENRT_RL => l_ENRT_RL
8185 ,P_LER_CHG_PLIP_ENRT_ID => l_ler_chg_plip_enrt_id
8186 ,P_LER_ID => l_LER_ID
8187 ,P_LPR_ATTRIBUTE1 => r_LPR1.INFORMATION111
8188 ,P_LPR_ATTRIBUTE10 => r_LPR1.INFORMATION120
8189 ,P_LPR_ATTRIBUTE11 => r_LPR1.INFORMATION121
8190 ,P_LPR_ATTRIBUTE12 => r_LPR1.INFORMATION122
8191 ,P_LPR_ATTRIBUTE13 => r_LPR1.INFORMATION123
8192 ,P_LPR_ATTRIBUTE14 => r_LPR1.INFORMATION124
8193 ,P_LPR_ATTRIBUTE15 => r_LPR1.INFORMATION125
8194 ,P_LPR_ATTRIBUTE16 => r_LPR1.INFORMATION126
8195 ,P_LPR_ATTRIBUTE17 => r_LPR1.INFORMATION127
8196 ,P_LPR_ATTRIBUTE18 => r_LPR1.INFORMATION128
8197 ,P_LPR_ATTRIBUTE19 => r_LPR1.INFORMATION129
8198 ,P_LPR_ATTRIBUTE2 => r_LPR1.INFORMATION112
8199 ,P_LPR_ATTRIBUTE20 => r_LPR1.INFORMATION130
8200 ,P_LPR_ATTRIBUTE21 => r_LPR1.INFORMATION131
8201 ,P_LPR_ATTRIBUTE22 => r_LPR1.INFORMATION132
8202 ,P_LPR_ATTRIBUTE23 => r_LPR1.INFORMATION133
8203 ,P_LPR_ATTRIBUTE24 => r_LPR1.INFORMATION134
8204 ,P_LPR_ATTRIBUTE25 => r_LPR1.INFORMATION135
8205 ,P_LPR_ATTRIBUTE26 => r_LPR1.INFORMATION136
8206 ,P_LPR_ATTRIBUTE27 => r_LPR1.INFORMATION137
8207 ,P_LPR_ATTRIBUTE28 => r_LPR1.INFORMATION138
8208 ,P_LPR_ATTRIBUTE29 => r_LPR1.INFORMATION139
8209 ,P_LPR_ATTRIBUTE3 => r_LPR1.INFORMATION113
8210 ,P_LPR_ATTRIBUTE30 => r_LPR1.INFORMATION140
8211 ,P_LPR_ATTRIBUTE4 => r_LPR1.INFORMATION114
8212 ,P_LPR_ATTRIBUTE5 => r_LPR1.INFORMATION115
8213 ,P_LPR_ATTRIBUTE6 => r_LPR1.INFORMATION116
8214 ,P_LPR_ATTRIBUTE7 => r_LPR1.INFORMATION117
8215 ,P_LPR_ATTRIBUTE8 => r_LPR1.INFORMATION118
8216 ,P_LPR_ATTRIBUTE9 => r_LPR1.INFORMATION119
8217 ,P_LPR_ATTRIBUTE_CATEGORY => r_LPR1.INFORMATION110
8218 ,P_PLIP_ID => l_PLIP_ID
8219 ,P_STL_ELIG_CANT_CHG_FLAG => r_LPR1.INFORMATION14
8220 ,P_TCO_CHG_ENRT_CD => r_LPR1.INFORMATION11
8221 --
8222 ,P_EFFECTIVE_START_DATE => l_effective_start_date
8223 ,P_EFFECTIVE_END_DATE => l_effective_end_date
8224 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8225 );
8226 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8227 -- Update all relevent cer records with new pk_id
8228 hr_utility.set_location('Before plsql table ',222);
8229 hr_utility.set_location('new_value id '||l_ler_chg_plip_enrt_id,222);
8230 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_PLIP_ENRT_ID' ;
8231 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LPR1.information1 ;
8232 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LER_CHG_PLIP_ENRT_ID ;
8233 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
8234 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LPR1_unique.table_route_id;
8235 hr_utility.set_location('After plsql table ',222);
8236 --
8237 -- 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 ) ;
8238 --
8239 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
8240 --
8241 else
8242 --
8243 -- Call Update routine for the pk_id created in prev run .
8244 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8245 hr_utility.set_location(' BEN_LER_CHG_PLIP_ENRT_F UPDATE_LER_CHG_PLAN_ENRT ',30);
8246 --UPD START
8247 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
8248 --
8249 if l_update then
8250 --
8251 l_datetrack_mode := r_LPR1.datetrack_mode ;
8252 --
8253 get_dt_modes(
8254 p_effective_date => l_process_date,
8255 p_effective_end_date => r_LPR1.information3,
8256 p_effective_start_date => r_LPR1.information2,
8257 p_dml_operation => r_LPR1.dml_operation,
8258 p_datetrack_mode => l_datetrack_mode );
8259 -- p_update => l_update
8260 --
8261 l_effective_date := l_process_date;
8262 l_LER_CHG_PLIP_ENRT_ID := r_LPR1.information1;
8263 l_object_version_number := r_LPR1.information265;
8264 --
8265 end if;
8266 --
8267 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
8268 --
8269 IF l_update OR l_dml_operation <> 'UPDATE' THEN
8270 --UPD END
8271
8272 BEN_LER_CHG_PLAN_ENRT_API.UPDATE_LER_CHG_PLAN_ENRT(
8273 --
8274 P_VALIDATE => false
8275 ,P_EFFECTIVE_DATE => l_effective_date
8276 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
8277 --
8278 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
8279 ,P_CRNT_ENRT_PRCLDS_CHG_FLAG => r_LPR1.INFORMATION12
8280 ,P_DFLT_ENRT_CD => r_LPR1.INFORMATION15
8281 ,P_DFLT_ENRT_RL => l_DFLT_ENRT_RL
8282 ,P_DFLT_FLAG => r_LPR1.INFORMATION13
8283 ,P_ENRT_CD => r_LPR1.INFORMATION16
8284 ,P_ENRT_MTHD_CD => r_LPR1.INFORMATION17
8285 ,P_ENRT_RL => l_ENRT_RL
8286 ,P_LER_CHG_PLIP_ENRT_ID => l_ler_chg_plip_enrt_id
8287 ,P_LER_ID => l_LER_ID
8288 ,P_LPR_ATTRIBUTE1 => r_LPR1.INFORMATION111
8289 ,P_LPR_ATTRIBUTE10 => r_LPR1.INFORMATION120
8290 ,P_LPR_ATTRIBUTE11 => r_LPR1.INFORMATION121
8291 ,P_LPR_ATTRIBUTE12 => r_LPR1.INFORMATION122
8292 ,P_LPR_ATTRIBUTE13 => r_LPR1.INFORMATION123
8293 ,P_LPR_ATTRIBUTE14 => r_LPR1.INFORMATION124
8294 ,P_LPR_ATTRIBUTE15 => r_LPR1.INFORMATION125
8295 ,P_LPR_ATTRIBUTE16 => r_LPR1.INFORMATION126
8296 ,P_LPR_ATTRIBUTE17 => r_LPR1.INFORMATION127
8297 ,P_LPR_ATTRIBUTE18 => r_LPR1.INFORMATION128
8298 ,P_LPR_ATTRIBUTE19 => r_LPR1.INFORMATION129
8299 ,P_LPR_ATTRIBUTE2 => r_LPR1.INFORMATION112
8300 ,P_LPR_ATTRIBUTE20 => r_LPR1.INFORMATION130
8301 ,P_LPR_ATTRIBUTE21 => r_LPR1.INFORMATION131
8302 ,P_LPR_ATTRIBUTE22 => r_LPR1.INFORMATION132
8303 ,P_LPR_ATTRIBUTE23 => r_LPR1.INFORMATION133
8304 ,P_LPR_ATTRIBUTE24 => r_LPR1.INFORMATION134
8305 ,P_LPR_ATTRIBUTE25 => r_LPR1.INFORMATION135
8306 ,P_LPR_ATTRIBUTE26 => r_LPR1.INFORMATION136
8307 ,P_LPR_ATTRIBUTE27 => r_LPR1.INFORMATION137
8308 ,P_LPR_ATTRIBUTE28 => r_LPR1.INFORMATION138
8309 ,P_LPR_ATTRIBUTE29 => r_LPR1.INFORMATION139
8310 ,P_LPR_ATTRIBUTE3 => r_LPR1.INFORMATION113
8311 ,P_LPR_ATTRIBUTE30 => r_LPR1.INFORMATION140
8312 ,P_LPR_ATTRIBUTE4 => r_LPR1.INFORMATION114
8313 ,P_LPR_ATTRIBUTE5 => r_LPR1.INFORMATION115
8314 ,P_LPR_ATTRIBUTE6 => r_LPR1.INFORMATION116
8315 ,P_LPR_ATTRIBUTE7 => r_LPR1.INFORMATION117
8316 ,P_LPR_ATTRIBUTE8 => r_LPR1.INFORMATION118
8317 ,P_LPR_ATTRIBUTE9 => r_LPR1.INFORMATION119
8318 ,P_LPR_ATTRIBUTE_CATEGORY => r_LPR1.INFORMATION110
8319 ,P_PLIP_ID => l_PLIP_ID
8320 ,P_STL_ELIG_CANT_CHG_FLAG => r_LPR1.INFORMATION14
8321 ,P_TCO_CHG_ENRT_CD => r_LPR1.INFORMATION11
8322 --
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_DATETRACK_MODE => l_datetrack_mode
8327 );
8328 end if; -- l_update
8329 end if;
8330 --
8331 -- Delete the row if it is end dated.
8332 --
8333 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
8334 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
8335 trunc(l_max_eed) = r_LPR1.information3) then
8336 --
8337 BEN_LER_CHG_PLAN_ENRT_API.delete_LER_CHG_PLAN_ENRT(
8338 --
8339 p_validate => false
8340 ,p_ler_chg_plip_enrt_id => l_ler_chg_plip_enrt_id
8341 ,p_effective_start_date => l_effective_start_date
8342 ,p_effective_end_date => l_effective_end_date
8343 ,p_object_version_number => l_object_version_number
8344 ,p_effective_date => l_max_eed
8345 ,p_datetrack_mode => hr_api.g_delete
8346 --
8347 );
8348 --
8349 end if;
8350 --
8351 l_prev_pk_id := l_current_pk_id ;
8352 --
8353 end if;
8354 --
8355 end if;
8356 --
8357 end loop;
8358 --
8359 exception when others then
8360 --
8361 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LPR1',r_LPR1.information5 );
8362 --
8363 end create_LPR1_rows;
8364
8365 --
8366 ---------------------------------------------------------------
8367 ----------------------< create_CPP_rows >-----------------------
8368 ---------------------------------------------------------------
8369 --
8370 procedure create_CPP_rows
8371 (
8372 p_validate in number default 0
8373 ,p_copy_entity_txn_id in number
8374 ,p_effective_date in date
8375 ,p_prefix_suffix_text in varchar2 default null
8376 ,p_reuse_object_flag in varchar2 default null
8377 ,p_target_business_group_id in varchar2 default null
8378 ,p_prefix_suffix_cd in varchar2 default null
8379 ) is
8380 --
8381 l_AUTO_ENRT_MTHD_RL number;
8382 l_CMBN_PLIP_ID number;
8383 l_DFLT_ENRT_DET_RL number;
8384 l_DFLT_TO_ASN_PNDG_CTFN_RL number;
8385 l_ENRT_CVG_END_DT_RL number;
8386 l_ENRT_CVG_STRT_DT_RL number;
8387 l_ENRT_RL number;
8388 l_MN_CVG_RL number;
8389 l_MX_CVG_RL number;
8390 l_PGM_ID number;
8391 l_PL_ID number;
8392 l_POSTELCN_EDIT_RL number;
8393 l_PRORT_PRTL_YR_CVG_RSTRN_RL number;
8394 l_RT_END_DT_RL number;
8395 l_RT_STRT_DT_RL number;
8396 l_VRFY_FMLY_MMBR_RL number;
8397 cursor c_unique_CPP(l_table_alias varchar2) is
8398 select distinct cpe.information1,
8399 cpe.information2,
8400 cpe.information3,
8401 cpe.table_route_id
8402 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
8403 pqh_table_route tr
8404 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8405 and cpe.table_route_id = tr.table_route_id
8406 -- and tr.where_clause = l_BEN_PLIP_F
8407 and tr.table_alias = l_table_alias
8408 and cpe.number_of_copies = 1 -- ADDITION
8409 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
8410 order by cpe.information1, cpe.information2 /* Bug 5076363 */;
8411 --
8412 --
8413 cursor c_CPP_min_max_dates(c_table_route_id number,
8414 c_information1 number) is
8415 select
8416 min(cpe.information2) min_esd,
8417 max(cpe.information3) min_eed
8418 from ben_copy_entity_results cpe
8419 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8420 and cpe.table_route_id = c_table_route_id
8421 and cpe.information1 = c_information1 ;
8422 --
8423 cursor c_CPP(c_table_route_id number,
8424 c_information1 number,
8425 c_information2 date,
8426 c_information3 date ) is
8427 select
8428 cpe.*
8429 from ben_copy_entity_results cpe
8430 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8431 and cpe.table_route_id = c_table_route_id
8432 and cpe.information1 = c_information1
8433 and cpe.information2 = c_information2
8434 and cpe.information3 = c_information3
8435 and rownum = 1 ;
8436 -- Date Track target record
8437 cursor c_find_CPP_in_target(
8438 c_effective_start_date date,
8439 c_effective_end_date date,
8440 c_business_group_id number,
8441 c_new_pk_id number) is
8442 select
8443 CPP.plip_id new_value
8444 from BEN_PLIP_F CPP
8445 where
8446 -- nvl(CPP.CMBN_PLIP_ID,-999) = nvl(l_CMBN_PLIP_ID,-999) and
8447 CPP.PGM_ID = l_PGM_ID and
8448 CPP.PL_ID = l_PL_ID and
8449 CPP.business_group_id = c_business_group_id
8450 --TEMPIK
8451 and c_effective_start_date between effective_start_date
8452 and effective_end_date ;
8453 --END TEMPIK
8454 /*TEMPIK
8455 and CPP.plip_id <> c_new_pk_id
8456 and exists ( select null
8457 from BEN_PLIP_F CPP1
8458 where
8459 -- nvl(CPP1.CMBN_PLIP_ID,-999) = nvl(l_CMBN_PLIP_ID,-999) and
8460 CPP1.PGM_ID = l_PGM_ID and
8461 CPP1.PL_ID = l_PL_ID and
8462 CPP1.business_group_id = c_business_group_id
8463 and CPP1.effective_start_date <= c_effective_start_date )
8464 and exists ( select null
8465 from BEN_PLIP_F CPP2
8466 where
8467 -- nvl(CPP2.CMBN_PLIP_ID,-999) = nvl(l_CMBN_PLIP_ID,-999) and
8468 CPP2.PGM_ID = l_PGM_ID and
8469 CPP2.PL_ID = l_PL_ID and
8470 CPP2.business_group_id = c_business_group_id
8471 and CPP2.effective_end_date >= c_effective_end_date )
8472 ;
8473 TEMPIK */
8474 --TEMPIK
8475 l_dt_rec_found boolean ;
8476 --END TEMPIK
8477 --
8478 --UPD START
8479 --
8480 l_update boolean := false ;
8481 l_datetrack_mode varchar2(80) := hr_api.g_update;
8482 l_process_date date;
8483 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
8484 --
8485 --UPD END
8486 l_current_pk_id number := null ;
8487 l_prev_pk_id number := null ;
8488 l_first_rec boolean := true ;
8489 r_CPP c_CPP%rowtype;
8490 l_plip_id number ;
8491 l_object_version_number number ;
8492 l_effective_start_date date ;
8493 l_effective_end_date date ;
8494 l_prefix pqh_copy_entity_attribs.information1%type := null;
8495 l_suffix pqh_copy_entity_attribs.information1%type := null;
8496 l_new_value number(15);
8497 l_object_found_in_target boolean := false ;
8498 l_min_esd date;
8499 l_max_eed date;
8500 l_effective_date date;
8501 --
8502 begin
8503 -- Initialization
8504 l_object_found_in_target := false ;
8505 -- End Initialization
8506 -- Derive the prefix - sufix
8507 if p_prefix_suffix_cd = 'PREFIX' then
8508 l_prefix := p_prefix_suffix_text ;
8509 elsif p_prefix_suffix_cd = 'SUFFIX' then
8510 l_suffix := p_prefix_suffix_text ;
8511 else
8512 l_prefix := null ;
8513 l_suffix := null ;
8514 end if ;
8515 -- End Prefix Sufix derivation
8516 for r_CPP_unique in c_unique_CPP('CPP') loop
8517
8518 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
8519 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8520 r_CPP_unique.information3 >=
8521 ben_pd_copy_to_ben_one.g_copy_effective_date)
8522 ) then
8523 --
8524 hr_utility.set_location(' r_CPP_unique.table_route_id '||r_CPP_unique.table_route_id,10);
8525 hr_utility.set_location(' r_CPP_unique.information1 '||r_CPP_unique.information1,10);
8526 hr_utility.set_location( 'r_CPP_unique.information2 '||r_CPP_unique.information2,10);
8527 hr_utility.set_location( 'r_CPP_unique.information3 '||r_CPP_unique.information3,10);
8528 -- If reuse objects flag is 'Y' then check for the object in the target business group
8529 -- if found insert the record into PLSql table and exit the loop else try create the
8530 -- object in the target business group
8531 --
8532 l_object_found_in_target := false ;
8533 --UPD START
8534 open c_CPP(r_CPP_unique.table_route_id,
8535 r_CPP_unique.information1,
8536 r_CPP_unique.information2,
8537 r_CPP_unique.information3 ) ;
8538 --
8539 fetch c_CPP into r_CPP ;
8540 --
8541 close c_CPP ;
8542 --
8543 l_process_date := p_effective_date;
8544 l_dml_operation:= r_CPP_unique.dml_operation ;
8545 l_AUTO_ENRT_MTHD_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION266,l_dml_operation );
8546 l_CMBN_PLIP_ID := get_fk('CMBN_PLIP_ID', r_CPP.INFORMATION239,l_dml_operation );
8547 l_DFLT_ENRT_DET_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION264,l_dml_operation );
8548 l_DFLT_TO_ASN_PNDG_CTFN_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION272,l_dml_operation );
8549 l_ENRT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION269,l_dml_operation );
8550 l_ENRT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION268,l_dml_operation );
8551 l_ENRT_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION267,l_dml_operation );
8552 l_MN_CVG_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION273,l_dml_operation );
8553 l_MX_CVG_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION276,l_dml_operation );
8554 l_PGM_ID := get_fk('PGM_ID', r_CPP.INFORMATION260,l_dml_operation );
8555 l_PL_ID := get_fk('PL_ID', r_CPP.INFORMATION261,l_dml_operation );
8556 l_POSTELCN_EDIT_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION257);
8557 l_PRORT_PRTL_YR_CVG_RSTRN_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION278,l_dml_operation );
8558 l_RT_END_DT_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION271,l_dml_operation );
8559 l_RT_STRT_DT_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION270,l_dml_operation );
8560 l_VRFY_FMLY_MMBR_RL := get_fk('FORMULA_ID', r_CPP.INFORMATION279,l_dml_operation );
8561 --
8562 l_update := false;
8563 --
8564 if l_dml_operation = 'UPDATE' then
8565 --
8566 l_object_found_in_target := TRUE;
8567 --
8568 if l_process_date between r_CPP_unique.information2 and r_CPP_unique.information3 then
8569 l_update := true;
8570 if r_CPP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
8571 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PLIP_ID'
8572 then
8573 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PLIP_ID' ;
8574 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPP_unique.information1 ;
8575 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_CPP_unique.information1 ;
8576 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
8577 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CPP_unique.table_route_id;
8578 --
8579 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
8580 --
8581 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
8582 --
8583 --DOUBT log_data('CPP',l_new_value,l_prefix || r_CPP_unique.name|| l_suffix,'REUSED');
8584 --
8585 end if ;
8586 hr_utility.set_location( 'found record for update',10);
8587 --
8588 else
8589 --
8590 l_update := false;
8591 --
8592 end if;
8593 else
8594 --
8595 --UPD END
8596 l_min_esd := null ;
8597 l_max_eed := null ;
8598 open c_CPP_min_max_dates(r_CPP_unique.table_route_id, r_CPP_unique.information1 ) ;
8599 fetch c_CPP_min_max_dates into l_min_esd,l_max_eed ;
8600 --
8601
8602 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8603 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
8604 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
8605 end if;
8606 l_min_esd := greatest(l_min_esd,r_CPP_unique.information2);
8607 /* open c_CPP(r_CPP_unique.table_route_id,
8608 r_CPP_unique.information1,
8609 r_CPP_unique.information2,
8610 r_CPP_unique.information3 ) ;
8611 --
8612 fetch c_CPP into r_CPP ;
8613 --
8614 close c_CPP ; */
8615 --
8616 if p_reuse_object_flag = 'Y' then
8617 if c_CPP_min_max_dates%found then
8618 -- cursor to find the object
8619 open c_find_CPP_in_target( l_min_esd,l_max_eed,
8620 p_target_business_group_id, nvl(l_plip_id, -999) ) ;
8621 fetch c_find_CPP_in_target into l_new_value ;
8622 if c_find_CPP_in_target%found then
8623 --
8624 --TEMPIK
8625 l_dt_rec_found := dt_api.check_min_max_dates
8626 (p_base_table_name => 'BEN_PLIP_F',
8627 p_base_key_column => 'PLIP_ID',
8628 p_base_key_value => l_new_value,
8629 p_from_date => l_min_esd,
8630 p_to_date => l_max_eed );
8631 if l_dt_rec_found THEN
8632 --END TEMPIK
8633 if r_CPP_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
8634 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PLIP_ID' then
8635 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PLIP_ID' ;
8636 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPP_unique.information1 ;
8637 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
8638 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
8639 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CPP_unique.table_route_id;
8640 --
8641 -- 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) ;
8642 --
8643 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
8644 end if ;
8645 --
8646 l_object_found_in_target := true ;
8647 --TEMPIK
8648 end if; -- l_dt_rec_found
8649 --END TEMPIK
8650 end if;
8651 close c_find_CPP_in_target ;
8652 --
8653 end if;
8654 end if ;
8655 --
8656 close c_CPP_min_max_dates ;
8657 end if; --if p_dml_operation
8658 --
8659 if not l_object_found_in_target OR l_update then
8660 --
8661 l_current_pk_id := r_CPP.information1;
8662 --
8663 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
8664 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
8665 --
8666 if l_current_pk_id = l_prev_pk_id then
8667 --
8668 l_first_rec := false ;
8669 --
8670 else
8671 --
8672 l_first_rec := true ;
8673 --
8674 end if ;
8675 --
8676
8677 l_effective_date := r_CPP.information2;
8678 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8679 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
8680 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
8681 end if;
8682
8683 if l_first_rec and not l_update then
8684
8685 -- Call Create routine.
8686 hr_utility.set_location(' BEN_PLIP_F CREATE_PLAN_IN_PROGRAM ',20);
8687 BEN_PLAN_IN_PROGRAM_API.CREATE_PLAN_IN_PROGRAM(
8688 --
8689 P_VALIDATE => false
8690 ,P_EFFECTIVE_DATE => l_effective_date
8691 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
8692 --
8693 ,P_ALWS_UNRSTRCTD_ENRT_FLAG => r_CPP.INFORMATION15
8694 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
8695 ,P_BNFT_OR_OPTION_RSTRCTN_CD => r_CPP.INFORMATION36
8696 ,P_CMBN_PLIP_ID => l_CMBN_PLIP_ID
8697 ,P_CPP_ATTRIBUTE1 => r_CPP.INFORMATION111
8698 ,P_CPP_ATTRIBUTE10 => r_CPP.INFORMATION120
8699 ,P_CPP_ATTRIBUTE11 => r_CPP.INFORMATION121
8700 ,P_CPP_ATTRIBUTE12 => r_CPP.INFORMATION122
8701 ,P_CPP_ATTRIBUTE13 => r_CPP.INFORMATION123
8702 ,P_CPP_ATTRIBUTE14 => r_CPP.INFORMATION124
8703 ,P_CPP_ATTRIBUTE15 => r_CPP.INFORMATION125
8704 ,P_CPP_ATTRIBUTE16 => r_CPP.INFORMATION126
8705 ,P_CPP_ATTRIBUTE17 => r_CPP.INFORMATION127
8706 ,P_CPP_ATTRIBUTE18 => r_CPP.INFORMATION128
8707 ,P_CPP_ATTRIBUTE19 => r_CPP.INFORMATION129
8708 ,P_CPP_ATTRIBUTE2 => r_CPP.INFORMATION112
8709 ,P_CPP_ATTRIBUTE20 => r_CPP.INFORMATION130
8710 ,P_CPP_ATTRIBUTE21 => r_CPP.INFORMATION131
8711 ,P_CPP_ATTRIBUTE22 => r_CPP.INFORMATION132
8712 ,P_CPP_ATTRIBUTE23 => r_CPP.INFORMATION133
8713 ,P_CPP_ATTRIBUTE24 => r_CPP.INFORMATION134
8714 ,P_CPP_ATTRIBUTE25 => r_CPP.INFORMATION135
8715 ,P_CPP_ATTRIBUTE26 => r_CPP.INFORMATION136
8716 ,P_CPP_ATTRIBUTE27 => r_CPP.INFORMATION137
8717 ,P_CPP_ATTRIBUTE28 => r_CPP.INFORMATION138
8718 ,P_CPP_ATTRIBUTE29 => r_CPP.INFORMATION139
8719 ,P_CPP_ATTRIBUTE3 => r_CPP.INFORMATION113
8720 ,P_CPP_ATTRIBUTE30 => r_CPP.INFORMATION140
8721 ,P_CPP_ATTRIBUTE4 => r_CPP.INFORMATION114
8722 ,P_CPP_ATTRIBUTE5 => r_CPP.INFORMATION115
8723 ,P_CPP_ATTRIBUTE6 => r_CPP.INFORMATION116
8724 ,P_CPP_ATTRIBUTE7 => r_CPP.INFORMATION117
8725 ,P_CPP_ATTRIBUTE8 => r_CPP.INFORMATION118
8726 ,P_CPP_ATTRIBUTE9 => r_CPP.INFORMATION119
8727 ,P_CPP_ATTRIBUTE_CATEGORY => r_CPP.INFORMATION110
8728 ,P_CVG_INCR_R_DECR_ONLY_CD => r_CPP.INFORMATION28
8729 ,P_DFLT_ENRT_CD => r_CPP.INFORMATION21
8730 ,P_DFLT_ENRT_DET_RL => l_DFLT_ENRT_DET_RL
8731 ,P_DFLT_FLAG => r_CPP.INFORMATION13
8732 ,P_DFLT_TO_ASN_PNDG_CTFN_CD => r_CPP.INFORMATION29
8733 ,P_DFLT_TO_ASN_PNDG_CTFN_RL => l_DFLT_TO_ASN_PNDG_CTFN_RL
8734 ,P_DRVBL_FCTR_APLS_RTS_FLAG => r_CPP.INFORMATION16
8735 ,P_DRVBL_FCTR_PRTN_ELIG_FLAG => r_CPP.INFORMATION17
8736 ,P_ELIG_APLS_FLAG => r_CPP.INFORMATION18
8737 ,P_ENRT_CD => r_CPP.INFORMATION22
8738 ,P_ENRT_CVG_END_DT_CD => r_CPP.INFORMATION25
8739 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
8740 ,P_ENRT_CVG_STRT_DT_CD => r_CPP.INFORMATION24
8741 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
8742 ,P_ENRT_MTHD_CD => r_CPP.INFORMATION23
8743 ,P_ENRT_RL => l_ENRT_RL
8744 ,P_IVR_IDENT => r_CPP.INFORMATION141
8745 ,P_MN_CVG_AMT => r_CPP.INFORMATION293
8746 ,P_MN_CVG_RL => l_MN_CVG_RL
8747 ,P_MX_CVG_ALWD_AMT => r_CPP.INFORMATION294
8748 ,P_MX_CVG_INCR_ALWD_AMT => r_CPP.INFORMATION295
8749 ,P_MX_CVG_INCR_WCF_ALWD_AMT => r_CPP.INFORMATION296
8750 ,P_MX_CVG_MLT_INCR_NUM => r_CPP.INFORMATION274
8751 ,P_MX_CVG_MLT_INCR_WCF_NUM => r_CPP.INFORMATION275
8752 ,P_MX_CVG_RL => l_MX_CVG_RL
8753 ,P_MX_CVG_WCFN_AMT => r_CPP.INFORMATION297
8754 ,P_MX_CVG_WCFN_MLT_NUM => r_CPP.INFORMATION277
8755 ,P_NO_MN_CVG_AMT_APLS_FLAG => r_CPP.INFORMATION30
8756 ,P_NO_MN_CVG_INCR_APLS_FLAG => r_CPP.INFORMATION31
8757 ,P_NO_MX_CVG_AMT_APLS_FLAG => r_CPP.INFORMATION32
8758 ,P_NO_MX_CVG_INCR_APLS_FLAG => r_CPP.INFORMATION33
8759 ,P_ORDR_NUM => r_CPP.INFORMATION263
8760 ,P_PER_CVRD_CD => r_CPP.INFORMATION38
8761 ,P_PGM_ID => l_PGM_ID
8762 ,P_PLIP_ID => l_plip_id
8763 ,P_PLIP_STAT_CD => r_CPP.INFORMATION14
8764 ,P_PL_ID => l_PL_ID
8765 ,P_POSTELCN_EDIT_RL => l_POSTELCN_EDIT_RL
8766 ,P_PRORT_PRTL_YR_CVG_RSTRN_CD => r_CPP.INFORMATION35
8767 ,P_PRORT_PRTL_YR_CVG_RSTRN_RL => l_PRORT_PRTL_YR_CVG_RSTRN_RL
8768 ,P_PRTN_ELIG_OVRID_ALWD_FLAG => r_CPP.INFORMATION19
8769 ,P_RT_END_DT_CD => r_CPP.INFORMATION27
8770 ,P_RT_END_DT_RL => l_RT_END_DT_RL
8771 ,P_RT_STRT_DT_CD => r_CPP.INFORMATION26
8772 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
8773 ,P_SHORT_CODE => r_CPP.INFORMATION11
8774 ,P_SHORT_NAME => r_CPP.INFORMATION12
8775 ,P_TRK_INELIG_PER_FLAG => r_CPP.INFORMATION20
8776 ,P_UNSSPND_ENRT_CD => r_CPP.INFORMATION34
8777 ,P_URL_REF_NAME => r_CPP.INFORMATION185
8778 ,P_VRFY_FMLY_MMBR_CD => r_CPP.INFORMATION37
8779 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
8780 --
8781 ,P_EFFECTIVE_START_DATE => l_effective_start_date
8782 ,P_EFFECTIVE_END_DATE => l_effective_end_date
8783 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8784 );
8785 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8786 -- Update all relevent cer records with new pk_id
8787 hr_utility.set_location('Before plsql table ',222);
8788 hr_utility.set_location('new_value id '||l_plip_id,222);
8789 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PLIP_ID' ;
8790 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPP.information1 ;
8791 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PLIP_ID ;
8792 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
8793 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CPP_unique.table_route_id;
8794 hr_utility.set_location('After plsql table ',222);
8795 --
8796 -- 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 ) ;
8797 --
8798 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
8799 --
8800 else
8801 --
8802 -- Call Update routine for the pk_id created in prev run .
8803 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8804 hr_utility.set_location(' BEN_PLIP_F UPDATE_PLAN_IN_PROGRAM ',30);
8805 --UPD START
8806 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
8807 --
8808 if l_update then
8809 --
8810 l_datetrack_mode := r_CPP.datetrack_mode ;
8811 --
8812 get_dt_modes(
8813 p_effective_date => l_process_date,
8814 p_effective_end_date => r_CPP.information3,
8815 p_effective_start_date => r_CPP.information2,
8816 p_dml_operation => r_CPP.dml_operation,
8817 p_datetrack_mode => l_datetrack_mode );
8818 -- p_update => l_update
8819 --
8820 l_effective_date := l_process_date;
8821 l_PLIP_ID := r_CPP.information1;
8822 l_object_version_number := r_CPP.information265;
8823 --
8824 end if;
8825 --
8826 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
8827 --
8828 IF l_update OR l_dml_operation <> 'UPDATE' THEN
8829 --UPD END
8830
8831
8832 BEN_PLAN_IN_PROGRAM_API.UPDATE_PLAN_IN_PROGRAM(
8833 --
8834 P_VALIDATE => false
8835 ,P_EFFECTIVE_DATE => l_effective_date
8836 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
8837 --
8838 ,P_ALWS_UNRSTRCTD_ENRT_FLAG => r_CPP.INFORMATION15
8839 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
8840 ,P_BNFT_OR_OPTION_RSTRCTN_CD => r_CPP.INFORMATION36
8841 ,P_CMBN_PLIP_ID => l_CMBN_PLIP_ID
8842 ,P_CPP_ATTRIBUTE1 => r_CPP.INFORMATION111
8843 ,P_CPP_ATTRIBUTE10 => r_CPP.INFORMATION120
8844 ,P_CPP_ATTRIBUTE11 => r_CPP.INFORMATION121
8845 ,P_CPP_ATTRIBUTE12 => r_CPP.INFORMATION122
8846 ,P_CPP_ATTRIBUTE13 => r_CPP.INFORMATION123
8847 ,P_CPP_ATTRIBUTE14 => r_CPP.INFORMATION124
8848 ,P_CPP_ATTRIBUTE15 => r_CPP.INFORMATION125
8849 ,P_CPP_ATTRIBUTE16 => r_CPP.INFORMATION126
8850 ,P_CPP_ATTRIBUTE17 => r_CPP.INFORMATION127
8851 ,P_CPP_ATTRIBUTE18 => r_CPP.INFORMATION128
8852 ,P_CPP_ATTRIBUTE19 => r_CPP.INFORMATION129
8853 ,P_CPP_ATTRIBUTE2 => r_CPP.INFORMATION112
8854 ,P_CPP_ATTRIBUTE20 => r_CPP.INFORMATION130
8855 ,P_CPP_ATTRIBUTE21 => r_CPP.INFORMATION131
8856 ,P_CPP_ATTRIBUTE22 => r_CPP.INFORMATION132
8857 ,P_CPP_ATTRIBUTE23 => r_CPP.INFORMATION133
8858 ,P_CPP_ATTRIBUTE24 => r_CPP.INFORMATION134
8859 ,P_CPP_ATTRIBUTE25 => r_CPP.INFORMATION135
8860 ,P_CPP_ATTRIBUTE26 => r_CPP.INFORMATION136
8861 ,P_CPP_ATTRIBUTE27 => r_CPP.INFORMATION137
8862 ,P_CPP_ATTRIBUTE28 => r_CPP.INFORMATION138
8863 ,P_CPP_ATTRIBUTE29 => r_CPP.INFORMATION139
8864 ,P_CPP_ATTRIBUTE3 => r_CPP.INFORMATION113
8865 ,P_CPP_ATTRIBUTE30 => r_CPP.INFORMATION140
8866 ,P_CPP_ATTRIBUTE4 => r_CPP.INFORMATION114
8867 ,P_CPP_ATTRIBUTE5 => r_CPP.INFORMATION115
8868 ,P_CPP_ATTRIBUTE6 => r_CPP.INFORMATION116
8869 ,P_CPP_ATTRIBUTE7 => r_CPP.INFORMATION117
8870 ,P_CPP_ATTRIBUTE8 => r_CPP.INFORMATION118
8871 ,P_CPP_ATTRIBUTE9 => r_CPP.INFORMATION119
8872 ,P_CPP_ATTRIBUTE_CATEGORY => r_CPP.INFORMATION110
8873 ,P_CVG_INCR_R_DECR_ONLY_CD => r_CPP.INFORMATION28
8874 ,P_DFLT_ENRT_CD => r_CPP.INFORMATION21
8875 ,P_DFLT_ENRT_DET_RL => l_DFLT_ENRT_DET_RL
8876 ,P_DFLT_FLAG => r_CPP.INFORMATION13
8877 ,P_DFLT_TO_ASN_PNDG_CTFN_CD => r_CPP.INFORMATION29
8878 ,P_DFLT_TO_ASN_PNDG_CTFN_RL => l_DFLT_TO_ASN_PNDG_CTFN_RL
8879 ,P_DRVBL_FCTR_APLS_RTS_FLAG => r_CPP.INFORMATION16
8880 ,P_DRVBL_FCTR_PRTN_ELIG_FLAG => r_CPP.INFORMATION17
8881 ,P_ELIG_APLS_FLAG => r_CPP.INFORMATION18
8882 ,P_ENRT_CD => r_CPP.INFORMATION22
8883 ,P_ENRT_CVG_END_DT_CD => r_CPP.INFORMATION25
8884 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
8885 ,P_ENRT_CVG_STRT_DT_CD => r_CPP.INFORMATION24
8886 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
8887 ,P_ENRT_MTHD_CD => r_CPP.INFORMATION23
8888 ,P_ENRT_RL => l_ENRT_RL
8889 ,P_IVR_IDENT => r_CPP.INFORMATION141
8890 ,P_MN_CVG_AMT => r_CPP.INFORMATION293
8891 ,P_MN_CVG_RL => l_MN_CVG_RL
8892 ,P_MX_CVG_ALWD_AMT => r_CPP.INFORMATION294
8893 ,P_MX_CVG_INCR_ALWD_AMT => r_CPP.INFORMATION295
8894 ,P_MX_CVG_INCR_WCF_ALWD_AMT => r_CPP.INFORMATION296
8895 ,P_MX_CVG_MLT_INCR_NUM => r_CPP.INFORMATION274
8896 ,P_MX_CVG_MLT_INCR_WCF_NUM => r_CPP.INFORMATION275
8897 ,P_MX_CVG_RL => l_MX_CVG_RL
8898 ,P_MX_CVG_WCFN_AMT => r_CPP.INFORMATION297
8899 ,P_MX_CVG_WCFN_MLT_NUM => r_CPP.INFORMATION277
8900 ,P_NO_MN_CVG_AMT_APLS_FLAG => r_CPP.INFORMATION30
8901 ,P_NO_MN_CVG_INCR_APLS_FLAG => r_CPP.INFORMATION31
8902 ,P_NO_MX_CVG_AMT_APLS_FLAG => r_CPP.INFORMATION32
8903 ,P_NO_MX_CVG_INCR_APLS_FLAG => r_CPP.INFORMATION33
8904 ,P_ORDR_NUM => r_CPP.INFORMATION263
8905 ,P_PER_CVRD_CD => r_CPP.INFORMATION38
8906 ,P_PGM_ID => l_PGM_ID
8907 ,P_PLIP_ID => l_plip_id
8908 ,P_PLIP_STAT_CD => r_CPP.INFORMATION14
8909 ,P_PL_ID => l_PL_ID
8910 ,P_POSTELCN_EDIT_RL => l_POSTELCN_EDIT_RL
8911 ,P_PRORT_PRTL_YR_CVG_RSTRN_CD => r_CPP.INFORMATION35
8912 ,P_PRORT_PRTL_YR_CVG_RSTRN_RL => l_PRORT_PRTL_YR_CVG_RSTRN_RL
8913 ,P_PRTN_ELIG_OVRID_ALWD_FLAG => r_CPP.INFORMATION19
8914 ,P_RT_END_DT_CD => r_CPP.INFORMATION27
8915 ,P_RT_END_DT_RL => l_RT_END_DT_RL
8916 ,P_RT_STRT_DT_CD => r_CPP.INFORMATION26
8917 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
8918 ,P_SHORT_CODE => r_CPP.INFORMATION11
8919 ,P_SHORT_NAME => r_CPP.INFORMATION12
8920 ,P_TRK_INELIG_PER_FLAG => r_CPP.INFORMATION20
8921 ,P_UNSSPND_ENRT_CD => r_CPP.INFORMATION34
8922 ,P_URL_REF_NAME => r_CPP.INFORMATION185
8923 ,P_VRFY_FMLY_MMBR_CD => r_CPP.INFORMATION37
8924 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
8925 --
8926 ,P_EFFECTIVE_START_DATE => l_effective_start_date
8927 ,P_EFFECTIVE_END_DATE => l_effective_end_date
8928 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8929 ,P_DATETRACK_MODE => l_datetrack_mode
8930 );
8931 --
8932 end if; -- l_update
8933 end if;
8934 --
8935 -- Delete the row if it is end dated.
8936 --
8937 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
8938 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
8939 trunc(l_max_eed) = r_CPP.information3) then
8940 --
8941 BEN_PLAN_IN_PROGRAM_API.delete_PLAN_IN_PROGRAM(
8942 --
8943 p_validate => false
8944 ,p_plip_id => l_plip_id
8945 ,p_effective_start_date => l_effective_start_date
8946 ,p_effective_end_date => l_effective_end_date
8947 ,p_object_version_number => l_object_version_number
8948 ,p_effective_date => l_max_eed
8949 ,p_datetrack_mode => hr_api.g_delete
8950 --
8951 );
8952 --
8953 end if;
8954 --
8955 l_prev_pk_id := l_current_pk_id ;
8956 --
8957 end if;
8958 --
8959 end if;
8960 --
8961 end loop;
8962 --
8963 exception when others then
8964 --
8965 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CPP',r_cpp.information5 );
8966 --
8967 end create_CPP_rows;
8968
8969 --
8970 ---------------------------------------------------------------
8971 ----------------------< create_PYD_rows >-----------------------
8972 ---------------------------------------------------------------
8973 --
8974 procedure create_PYD_rows
8975 (
8976 p_validate in number default 0
8977 ,p_copy_entity_txn_id in number
8978 ,p_effective_date in date
8979 ,p_prefix_suffix_text in varchar2 default null
8980 ,p_reuse_object_flag in varchar2 default null
8981 ,p_target_business_group_id in varchar2 default null
8982 ,p_prefix_suffix_cd in varchar2 default null
8983 ) is
8984 --
8985 l_CTFN_RQD_WHEN_RL number;
8986 l_PTIP_ID number;
8987 l_DPNT_CVG_CTFN_TYP_CD varchar2(30);
8988 l_RLSHP_TYP_CD varchar2(30);
8989 --
8990 cursor c_unique_PYD(l_table_alias varchar2) is
8991 select distinct cpe.information1,
8992 cpe.information2,
8993 cpe.information3,
8994 cpe.table_route_id
8995 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
8996 pqh_table_route tr
8997 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8998 and cpe.table_route_id = tr.table_route_id
8999 -- and tr.where_clause = l_BEN_PTIP_DPNT_CVG_CTFN_F
9000 and tr.table_alias = l_table_alias
9001 and cpe.number_of_copies = 1 -- ADDITION
9002 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
9003 order by information1, information2; --added for bug: 5151945
9004 --
9005 --
9006 cursor c_PYD_min_max_dates(c_table_route_id number,
9007 c_information1 number) is
9008 select
9009 min(cpe.information2) min_esd,
9010 max(cpe.information3) min_eed
9011 from ben_copy_entity_results cpe
9012 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9013 and cpe.table_route_id = c_table_route_id
9014 and cpe.information1 = c_information1 ;
9015 --
9016 cursor c_PYD(c_table_route_id number,
9017 c_information1 number,
9018 c_information2 date,
9019 c_information3 date ) is
9020 select
9021 cpe.*
9022 from ben_copy_entity_results cpe
9023 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9024 and cpe.table_route_id = c_table_route_id
9025 and cpe.information1 = c_information1
9026 and cpe.information2 = c_information2
9027 and cpe.information3 = c_information3
9028 and rownum = 1 ;
9029 -- Date Track target record
9030 cursor c_find_PYD_in_target(
9031 c_effective_start_date date,
9032 c_effective_end_date date,
9033 c_business_group_id number,
9034 c_new_pk_id number) is
9035 select
9036 PYD.ptip_dpnt_cvg_ctfn_id new_value
9037 from BEN_PTIP_DPNT_CVG_CTFN_F PYD
9038 where
9039 PYD.PTIP_ID = l_PTIP_ID and
9040 PYD.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
9041 nvl(PYD.RLSHP_TYP_CD,-999) = nvl(l_RLSHP_TYP_CD,-999) and
9042 PYD.business_group_id = c_business_group_id
9043 and PYD.ptip_dpnt_cvg_ctfn_id <> c_new_pk_id
9044 --TEMPIK
9045 and c_effective_start_date between effective_start_date
9046 and effective_end_date ;
9047 --END TEMPIK
9048 /*TEMPIK
9049 and exists ( select null
9050 from BEN_PTIP_DPNT_CVG_CTFN_F PYD1
9051 where
9052 PYD1.PTIP_ID = l_PTIP_ID and
9053 PYD1.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
9054 nvl(PYD1.RLSHP_TYP_CD,-999) = nvl(l_RLSHP_TYP_CD,-999) and
9055 PYD1.business_group_id = c_business_group_id
9056 and PYD1.effective_start_date <= c_effective_start_date )
9057 and exists ( select null
9058 from BEN_PTIP_DPNT_CVG_CTFN_F PYD2
9059 where
9060 PYD2.PTIP_ID = l_PTIP_ID and
9061 PYD2.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
9062 nvl(PYD2.RLSHP_TYP_CD,-999) = nvl(l_RLSHP_TYP_CD,-999) and
9063 PYD2.business_group_id = c_business_group_id
9064 and PYD2.effective_end_date >= c_effective_end_date )
9065 ;
9066 TEMPIK */
9067 --TEMPIK
9068 l_dt_rec_found boolean ;
9069 --END TEMPIK
9070 --
9071 --UPD START
9072 --
9073 l_update boolean := false ;
9074 l_datetrack_mode varchar2(80) := hr_api.g_update;
9075 l_process_date date;
9076 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
9077 --
9078 --UPD END
9079 l_current_pk_id number := null ;
9080 l_prev_pk_id number := null ;
9081 l_first_rec boolean := true ;
9082 r_PYD c_PYD%rowtype;
9083 l_ptip_dpnt_cvg_ctfn_id number ;
9084 l_object_version_number number ;
9085 l_effective_start_date date ;
9086 l_effective_end_date date ;
9087 l_prefix pqh_copy_entity_attribs.information1%type := null;
9088 l_suffix pqh_copy_entity_attribs.information1%type := null;
9089 l_new_value number(15);
9090 l_object_found_in_target boolean := false ;
9091 l_min_esd date;
9092 l_max_eed date;
9093 l_effective_date date;
9094 --
9095 begin
9096 -- Initialization
9097 l_object_found_in_target := false ;
9098 -- End Initialization
9099 -- Derive the prefix - sufix
9100 if p_prefix_suffix_cd = 'PREFIX' then
9101 l_prefix := p_prefix_suffix_text ;
9102 elsif p_prefix_suffix_cd = 'SUFFIX' then
9103 l_suffix := p_prefix_suffix_text ;
9104 else
9105 l_prefix := null ;
9106 l_suffix := null ;
9107 end if ;
9108 -- End Prefix Sufix derivation
9109 for r_PYD_unique in c_unique_PYD('PYD') loop
9110
9111 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
9112 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9113 r_PYD_unique.information3 >=
9114 ben_pd_copy_to_ben_one.g_copy_effective_date)
9115 ) then
9116 --
9117 hr_utility.set_location(' r_PYD_unique.table_route_id '||r_PYD_unique.table_route_id,10);
9118 hr_utility.set_location(' r_PYD_unique.information1 '||r_PYD_unique.information1,10);
9119 hr_utility.set_location( 'r_PYD_unique.information2 '||r_PYD_unique.information2,10);
9120 hr_utility.set_location( 'r_PYD_unique.information3 '||r_PYD_unique.information3,10);
9121 -- If reuse objects flag is 'Y' then check for the object in the target business group
9122 -- if found insert the record into PLSql table and exit the loop else try create the
9123 -- object in the target business group
9124 --
9125 l_object_found_in_target := false ;
9126 --UPD START
9127 open c_PYD(r_PYD_unique.table_route_id,
9128 r_PYD_unique.information1,
9129 r_PYD_unique.information2,
9130 r_PYD_unique.information3 ) ;
9131 --
9132 fetch c_PYD into r_PYD ;
9133 --
9134 close c_PYD ;
9135 --
9136 l_dml_operation:= r_PYD_unique.dml_operation ;
9137 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_PYD.INFORMATION257,l_dml_operation );
9138 l_PTIP_ID := get_fk('PTIP_ID', r_PYD.INFORMATION259,l_dml_operation );
9139 l_DPNT_CVG_CTFN_TYP_CD := r_PYD.information12 ;
9140 l_RLSHP_TYP_CD := r_PYD.information48 ;
9141 --
9142 l_update := false;
9143 l_process_date := p_effective_date;
9144 --
9145 if l_dml_operation = 'UPDATE' then
9146 --
9147 l_object_found_in_target := TRUE;
9148 --
9149 if l_process_date between r_PYD_unique.information2 and r_PYD_unique.information3 then
9150 l_update := true;
9151 if r_PYD_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
9152 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PTIP_DPNT_CVG_CTFN_ID'
9153 then
9154 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PTIP_DPNT_CVG_CTFN_ID' ;
9155 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PYD_unique.information1 ;
9156 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PYD_unique.information1 ;
9157 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
9158 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PYD_unique.table_route_id;
9159 --
9160 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
9161 --
9162 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
9163 --
9164 --DOUBT log_data('PYD',l_new_value,l_prefix || r_PYD_unique.name|| l_suffix,'REUSED');
9165 --
9166 end if ;
9167 hr_utility.set_location( 'found record for update',10);
9168 --
9169 else
9170 --
9171 l_update := false;
9172 --
9173 end if;
9174 else
9175 --
9176 --UPD END
9177
9178 l_min_esd := null ;
9179 l_max_eed := null ;
9180 open c_PYD_min_max_dates(r_PYD_unique.table_route_id, r_PYD_unique.information1 ) ;
9181 fetch c_PYD_min_max_dates into l_min_esd,l_max_eed ;
9182 --
9183
9184 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9185 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
9186 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
9187 end if;
9188 l_min_esd := greatest(l_min_esd,r_PYD_unique.information2);
9189 /* open c_PYD(r_PYD_unique.table_route_id,
9190 r_PYD_unique.information1,
9191 r_PYD_unique.information2,
9192 r_PYD_unique.information3 ) ;
9193 --
9194 fetch c_PYD into r_PYD ;
9195 --
9196 close c_PYD ; */
9197 --
9198
9199 --
9200 if p_reuse_object_flag = 'Y' then
9201 if c_PYD_min_max_dates%found then
9202 -- cursor to find the object
9203 open c_find_PYD_in_target( l_min_esd,l_max_eed,
9204 p_target_business_group_id, nvl(l_ptip_dpnt_cvg_ctfn_id, -999) ) ;
9205 fetch c_find_PYD_in_target into l_new_value ;
9206 if c_find_PYD_in_target%found then
9207 --
9208 --TEMPIK
9209 l_dt_rec_found := dt_api.check_min_max_dates
9210 (p_base_table_name => 'BEN_PTIP_DPNT_CVG_CTFN_F',
9211 p_base_key_column => 'PTIP_DPNT_CVG_CTFN_ID',
9212 p_base_key_value => l_new_value,
9213 p_from_date => l_min_esd,
9214 p_to_date => l_max_eed );
9215 if l_dt_rec_found THEN
9216 --END TEMPIK
9217 if r_PYD_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
9218 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PTIP_DPNT_CVG_CTFN_ID' then
9219 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PTIP_DPNT_CVG_CTFN_ID' ;
9220 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PYD_unique.information1 ;
9221 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
9222 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
9223 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PYD_unique.table_route_id;
9224 --
9225 -- 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) ;
9226 --
9227 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
9228 end if ;
9229 --
9230 l_object_found_in_target := true ;
9231 --TEMPIK
9232 end if; -- l_dt_rec_found
9233 --END TEMPIK
9234 end if;
9235 close c_find_PYD_in_target ;
9236 --
9237 end if;
9238 end if ;
9239 --
9240 close c_PYD_min_max_dates ;
9241 end if; --if p_dml_operation
9242 --
9243 if not l_object_found_in_target OR l_update then
9244 --
9245 l_current_pk_id := r_PYD.information1;
9246 --
9247 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
9248 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
9249 --
9250 if l_current_pk_id = l_prev_pk_id then
9251 --
9252 l_first_rec := false ;
9253 --
9254 else
9255 --
9256 l_first_rec := true ;
9257 --
9258 end if ;
9259 --
9260
9261 l_effective_date := r_PYD.information2;
9262 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9263 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
9264 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
9265 end if;
9266
9267 if l_first_rec and not l_update then
9268 -- Call Create routine.
9269 hr_utility.set_location(' BEN_PTIP_DPNT_CVG_CTFN_F CREATE_PTIP_DPNT_CVG_CTFN ',20);
9270 BEN_PTIP_DPNT_CVG_CTFN_API.CREATE_PTIP_DPNT_CVG_CTFN(
9271 --
9272 P_VALIDATE => false
9273 ,P_EFFECTIVE_DATE => l_effective_date
9274 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
9275 --
9276 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
9277 ,P_DPNT_CVG_CTFN_TYP_CD => r_PYD.INFORMATION13
9278 ,P_LACK_CTFN_SSPND_ENRT_FLAG => r_PYD.INFORMATION12
9279 ,P_PFD_FLAG => r_PYD.INFORMATION11
9280 ,P_PTIP_DPNT_CVG_CTFN_ID => l_ptip_dpnt_cvg_ctfn_id
9281 ,P_PTIP_ID => l_PTIP_ID
9282 ,P_PYD_ATTRIBUTE1 => r_PYD.INFORMATION111
9283 ,P_PYD_ATTRIBUTE10 => r_PYD.INFORMATION120
9284 ,P_PYD_ATTRIBUTE11 => r_PYD.INFORMATION121
9285 ,P_PYD_ATTRIBUTE12 => r_PYD.INFORMATION122
9286 ,P_PYD_ATTRIBUTE13 => r_PYD.INFORMATION123
9287 ,P_PYD_ATTRIBUTE14 => r_PYD.INFORMATION124
9288 ,P_PYD_ATTRIBUTE15 => r_PYD.INFORMATION125
9289 ,P_PYD_ATTRIBUTE16 => r_PYD.INFORMATION126
9290 ,P_PYD_ATTRIBUTE17 => r_PYD.INFORMATION127
9291 ,P_PYD_ATTRIBUTE18 => r_PYD.INFORMATION128
9292 ,P_PYD_ATTRIBUTE19 => r_PYD.INFORMATION129
9293 ,P_PYD_ATTRIBUTE2 => r_PYD.INFORMATION112
9294 ,P_PYD_ATTRIBUTE20 => r_PYD.INFORMATION130
9295 ,P_PYD_ATTRIBUTE21 => r_PYD.INFORMATION131
9296 ,P_PYD_ATTRIBUTE22 => r_PYD.INFORMATION132
9297 ,P_PYD_ATTRIBUTE23 => r_PYD.INFORMATION133
9298 ,P_PYD_ATTRIBUTE24 => r_PYD.INFORMATION134
9299 ,P_PYD_ATTRIBUTE25 => r_PYD.INFORMATION135
9300 ,P_PYD_ATTRIBUTE26 => r_PYD.INFORMATION136
9301 ,P_PYD_ATTRIBUTE27 => r_PYD.INFORMATION137
9302 ,P_PYD_ATTRIBUTE28 => r_PYD.INFORMATION138
9303 ,P_PYD_ATTRIBUTE29 => r_PYD.INFORMATION139
9304 ,P_PYD_ATTRIBUTE3 => r_PYD.INFORMATION113
9305 ,P_PYD_ATTRIBUTE30 => r_PYD.INFORMATION140
9306 ,P_PYD_ATTRIBUTE4 => r_PYD.INFORMATION114
9307 ,P_PYD_ATTRIBUTE5 => r_PYD.INFORMATION115
9308 ,P_PYD_ATTRIBUTE6 => r_PYD.INFORMATION116
9309 ,P_PYD_ATTRIBUTE7 => r_PYD.INFORMATION117
9310 ,P_PYD_ATTRIBUTE8 => r_PYD.INFORMATION118
9311 ,P_PYD_ATTRIBUTE9 => r_PYD.INFORMATION119
9312 ,P_PYD_ATTRIBUTE_CATEGORY => r_PYD.INFORMATION110
9313 ,P_RLSHP_TYP_CD => r_PYD.INFORMATION15
9314 ,P_RQD_FLAG => r_PYD.INFORMATION14
9315 --
9316 ,P_EFFECTIVE_START_DATE => l_effective_start_date
9317 ,P_EFFECTIVE_END_DATE => l_effective_end_date
9318 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
9319 );
9320 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
9321 -- Update all relevent cer records with new pk_id
9322 hr_utility.set_location('Before plsql table ',222);
9323 hr_utility.set_location('new_value id '||l_ptip_dpnt_cvg_ctfn_id,222);
9324 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PTIP_DPNT_CVG_CTFN_ID' ;
9325 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PYD.information1 ;
9326 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PTIP_DPNT_CVG_CTFN_ID ;
9327 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
9328 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PYD_unique.table_route_id;
9329 hr_utility.set_location('After plsql table ',222);
9330 --
9331 -- 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 ) ;
9332 --
9333 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
9334 --
9335 else
9336 --
9337 -- Call Update routine for the pk_id created in prev run .
9338 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
9339 hr_utility.set_location(' BEN_PTIP_DPNT_CVG_CTFN_F UPDATE_PTIP_DPNT_CVG_CTFN ',30);
9340 --UPD START
9341 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
9342 --
9343 if l_update then
9344 --
9345 l_datetrack_mode := r_PYD.datetrack_mode ;
9346 --
9347 get_dt_modes(
9348 p_effective_date => l_process_date,
9349 p_effective_end_date => r_PYD.information3,
9350 p_effective_start_date => r_PYD.information2,
9351 p_dml_operation => r_PYD.dml_operation,
9352 p_datetrack_mode => l_datetrack_mode );
9353 -- p_update => l_update
9354 --
9355 l_effective_date := l_process_date;
9356 l_PTIP_DPNT_CVG_CTFN_ID := r_PYD.information1;
9357 l_object_version_number := r_PYD.information265;
9358 --
9359 end if;
9360 --
9361 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
9362 --
9363 IF l_update OR l_dml_operation <> 'UPDATE' THEN
9364 --UPD END
9365
9366 BEN_PTIP_DPNT_CVG_CTFN_API.UPDATE_PTIP_DPNT_CVG_CTFN(
9367 --
9368 P_VALIDATE => false
9369 ,P_EFFECTIVE_DATE => l_effective_date
9370 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
9371 --
9372 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
9373 ,P_DPNT_CVG_CTFN_TYP_CD => r_PYD.INFORMATION13
9374 ,P_LACK_CTFN_SSPND_ENRT_FLAG => r_PYD.INFORMATION12
9375 ,P_PFD_FLAG => r_PYD.INFORMATION11
9376 ,P_PTIP_DPNT_CVG_CTFN_ID => l_ptip_dpnt_cvg_ctfn_id
9377 ,P_PTIP_ID => l_PTIP_ID
9378 ,P_PYD_ATTRIBUTE1 => r_PYD.INFORMATION111
9379 ,P_PYD_ATTRIBUTE10 => r_PYD.INFORMATION120
9380 ,P_PYD_ATTRIBUTE11 => r_PYD.INFORMATION121
9381 ,P_PYD_ATTRIBUTE12 => r_PYD.INFORMATION122
9382 ,P_PYD_ATTRIBUTE13 => r_PYD.INFORMATION123
9383 ,P_PYD_ATTRIBUTE14 => r_PYD.INFORMATION124
9384 ,P_PYD_ATTRIBUTE15 => r_PYD.INFORMATION125
9385 ,P_PYD_ATTRIBUTE16 => r_PYD.INFORMATION126
9386 ,P_PYD_ATTRIBUTE17 => r_PYD.INFORMATION127
9387 ,P_PYD_ATTRIBUTE18 => r_PYD.INFORMATION128
9388 ,P_PYD_ATTRIBUTE19 => r_PYD.INFORMATION129
9389 ,P_PYD_ATTRIBUTE2 => r_PYD.INFORMATION112
9390 ,P_PYD_ATTRIBUTE20 => r_PYD.INFORMATION130
9391 ,P_PYD_ATTRIBUTE21 => r_PYD.INFORMATION131
9392 ,P_PYD_ATTRIBUTE22 => r_PYD.INFORMATION132
9393 ,P_PYD_ATTRIBUTE23 => r_PYD.INFORMATION133
9394 ,P_PYD_ATTRIBUTE24 => r_PYD.INFORMATION134
9395 ,P_PYD_ATTRIBUTE25 => r_PYD.INFORMATION135
9396 ,P_PYD_ATTRIBUTE26 => r_PYD.INFORMATION136
9397 ,P_PYD_ATTRIBUTE27 => r_PYD.INFORMATION137
9398 ,P_PYD_ATTRIBUTE28 => r_PYD.INFORMATION138
9399 ,P_PYD_ATTRIBUTE29 => r_PYD.INFORMATION139
9400 ,P_PYD_ATTRIBUTE3 => r_PYD.INFORMATION113
9401 ,P_PYD_ATTRIBUTE30 => r_PYD.INFORMATION140
9402 ,P_PYD_ATTRIBUTE4 => r_PYD.INFORMATION114
9403 ,P_PYD_ATTRIBUTE5 => r_PYD.INFORMATION115
9404 ,P_PYD_ATTRIBUTE6 => r_PYD.INFORMATION116
9405 ,P_PYD_ATTRIBUTE7 => r_PYD.INFORMATION117
9406 ,P_PYD_ATTRIBUTE8 => r_PYD.INFORMATION118
9407 ,P_PYD_ATTRIBUTE9 => r_PYD.INFORMATION119
9408 ,P_PYD_ATTRIBUTE_CATEGORY => r_PYD.INFORMATION110
9409 ,P_RLSHP_TYP_CD => r_PYD.INFORMATION15
9410 ,P_RQD_FLAG => r_PYD.INFORMATION14
9411 --
9412 ,P_EFFECTIVE_START_DATE => l_effective_start_date
9413 ,P_EFFECTIVE_END_DATE => l_effective_end_date
9414 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
9415 ,P_DATETRACK_MODE => l_datetrack_mode
9416 );
9417 --
9418 end if; -- l_update
9419 end if;
9420 --
9421 -- Delete the row if it is end dated.
9422 --
9423 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
9424 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
9425 trunc(l_max_eed) = r_PYD.information3) then
9426 --
9427 BEN_PTIP_DPNT_CVG_CTFN_API.delete_PTIP_DPNT_CVG_CTFN(
9428 --
9429 p_validate => false
9430 ,p_ptip_dpnt_cvg_ctfn_id => l_ptip_dpnt_cvg_ctfn_id
9431 ,p_effective_start_date => l_effective_start_date
9432 ,p_effective_end_date => l_effective_end_date
9433 ,p_object_version_number => l_object_version_number
9434 ,p_effective_date => l_max_eed
9435 ,p_datetrack_mode => hr_api.g_delete
9436 --
9437 );
9438 --
9439 end if;
9440 --
9441 l_prev_pk_id := l_current_pk_id ;
9442 --
9443 end if;
9444 --
9445 end if;
9446 --
9447 end loop;
9448 --
9449 exception when others then
9450 --
9451 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PYD',r_pyd.information5 );
9452 --
9453 end create_PYD_rows;
9454
9455 --
9456 ---------------------------------------------------------------
9457 ----------------------< create_LCT_rows >-----------------------
9458 ---------------------------------------------------------------
9459 --
9460 procedure create_LCT_rows
9461 (
9462 p_validate in number default 0
9463 ,p_copy_entity_txn_id in number
9464 ,p_effective_date in date
9465 ,p_prefix_suffix_text in varchar2 default null
9466 ,p_reuse_object_flag in varchar2 default null
9467 ,p_target_business_group_id in varchar2 default null
9468 ,p_prefix_suffix_cd in varchar2 default null
9469 ) is
9470 --
9471 l_DFLT_ENRT_RL number;
9472 l_ENRT_RL number;
9473 l_LER_ID number;
9474 l_PTIP_ID number;
9475 cursor c_unique_LCT(l_table_alias varchar2) is
9476 select distinct cpe.information1,
9477 cpe.information2,
9478 cpe.information3,
9479 cpe.table_route_id
9480 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
9481 pqh_table_route tr
9482 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9483 and cpe.table_route_id = tr.table_route_id
9484 -- and tr.where_clause = l_BEN_LER_CHG_PTIP_ENRT_F
9485 and tr.table_alias = l_table_alias
9486 and cpe.number_of_copies = 1 -- ADDITION
9487 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
9488 order by information1, information2; --added for bug: 5151945
9489 --
9490 --
9491 cursor c_LCT_min_max_dates(c_table_route_id number,
9492 c_information1 number) is
9493 select
9494 min(cpe.information2) min_esd,
9495 max(cpe.information3) min_eed
9496 from ben_copy_entity_results cpe
9497 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9498 and cpe.table_route_id = c_table_route_id
9499 and cpe.information1 = c_information1 ;
9500 --
9501 cursor c_LCT(c_table_route_id number,
9502 c_information1 number,
9503 c_information2 date,
9504 c_information3 date ) is
9505 select
9506 cpe.*
9507 from ben_copy_entity_results cpe
9508 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9509 and cpe.table_route_id = c_table_route_id
9510 and cpe.information1 = c_information1
9511 and cpe.information2 = c_information2
9512 and cpe.information3 = c_information3
9513 and rownum = 1 ;
9514 -- Date Track target record
9515 cursor c_find_LCT_in_target(
9516 c_effective_start_date date,
9517 c_effective_end_date date,
9518 c_business_group_id number,
9519 c_new_pk_id number) is
9520 select
9521 LCT.ler_chg_ptip_enrt_id new_value
9522 from BEN_LER_CHG_PTIP_ENRT_F LCT
9523 where
9524 LCT.LER_ID = l_LER_ID and
9525 LCT.PTIP_ID = l_PTIP_ID and
9526 LCT.business_group_id = c_business_group_id
9527 and LCT.ler_chg_ptip_enrt_id <> c_new_pk_id
9528 --TEMPIK
9529 and c_effective_start_date between effective_start_date
9530 and effective_end_date ;
9531 --END TEMPIK
9532 /*TEMPIK
9533 and exists ( select null
9534 from BEN_LER_CHG_PTIP_ENRT_F LCT1
9535 where
9536 LCT1.LER_ID = l_LER_ID and
9537 LCT1.PTIP_ID = l_PTIP_ID and
9538 LCT1.business_group_id = c_business_group_id
9539 and LCT1.effective_start_date <= c_effective_start_date )
9540 and exists ( select null
9541 from BEN_LER_CHG_PTIP_ENRT_F LCT2
9542 where
9543 LCT2.LER_ID = l_LER_ID and
9544 LCT2.PTIP_ID = l_PTIP_ID and
9545 LCT2.business_group_id = c_business_group_id
9546 and LCT2.effective_end_date >= c_effective_end_date )
9547 ;
9548 TEMPIK */
9549 --TEMPIK
9550 l_dt_rec_found boolean ;
9551 --END TEMPIK
9552 --
9553 --UPD START
9554 --
9555 l_update boolean := false ;
9556 l_datetrack_mode varchar2(80) := hr_api.g_update;
9557 l_process_date date;
9558 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
9559 --
9560 --UPD END
9561 l_current_pk_id number := null ;
9562 l_prev_pk_id number := null ;
9563 l_first_rec boolean := true ;
9564 r_LCT c_LCT%rowtype;
9565 l_ler_chg_ptip_enrt_id number ;
9566 l_object_version_number number ;
9567 l_effective_start_date date ;
9568 l_effective_end_date date ;
9569 l_prefix pqh_copy_entity_attribs.information1%type := null;
9570 l_suffix pqh_copy_entity_attribs.information1%type := null;
9571 l_new_value number(15);
9572 l_object_found_in_target boolean := false ;
9573 l_min_esd date;
9574 l_max_eed date;
9575 l_effective_date date;
9576 --
9577 begin
9578 -- Initialization
9579 l_object_found_in_target := false ;
9580 -- End Initialization
9581 -- Derive the prefix - sufix
9582 if p_prefix_suffix_cd = 'PREFIX' then
9583 l_prefix := p_prefix_suffix_text ;
9584 elsif p_prefix_suffix_cd = 'SUFFIX' then
9585 l_suffix := p_prefix_suffix_text ;
9586 else
9587 l_prefix := null ;
9588 l_suffix := null ;
9589 end if ;
9590 -- End Prefix Sufix derivation
9591 for r_LCT_unique in c_unique_LCT('LCT') loop
9592
9593 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
9594 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9595 r_LCT_unique.information3 >=
9596 ben_pd_copy_to_ben_one.g_copy_effective_date)
9597 ) then
9598
9599 --
9600 hr_utility.set_location(' r_LCT_unique.table_route_id '||r_LCT_unique.table_route_id,10);
9601 hr_utility.set_location(' r_LCT_unique.information1 '||r_LCT_unique.information1,10);
9602 hr_utility.set_location( 'r_LCT_unique.information2 '||r_LCT_unique.information2,10);
9603 hr_utility.set_location( 'r_LCT_unique.information3 '||r_LCT_unique.information3,10);
9604 -- If reuse objects flag is 'Y' then check for the object in the target business group
9605 -- if found insert the record into PLSql table and exit the loop else try create the
9606 -- object in the target business group
9607 --
9608 l_object_found_in_target := false ;
9609 --UPD START
9610 l_update := false;
9611 l_process_date := p_effective_date;
9612 l_dml_operation:= r_LCT_unique.dml_operation ;
9613 --
9614 open c_LCT(r_LCT_unique.table_route_id,
9615 r_LCT_unique.information1,
9616 r_LCT_unique.information2,
9617 r_LCT_unique.information3 ) ;
9618 --
9619 fetch c_LCT into r_LCT ;
9620 --
9621 close c_LCT ;
9622 --
9623 l_DFLT_ENRT_RL := get_fk('FORMULA_ID', r_LCT.INFORMATION13,l_dml_operation);
9624 l_ENRT_RL := get_fk('FORMULA_ID', r_LCT.INFORMATION16,l_dml_operation);
9625 l_LER_ID := get_fk('LER_ID', r_LCT.INFORMATION257,l_dml_operation);
9626 l_PTIP_ID := get_fk('PTIP_ID', r_LCT.INFORMATION259,l_dml_operation);
9627 if l_dml_operation = 'UPDATE' then
9628 --
9629 l_object_found_in_target := TRUE;
9630 --
9631 if l_process_date between r_LCT_unique.information2 and r_LCT_unique.information3 then
9632 l_update := true;
9633 if r_LCT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
9634 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_PTIP_ENRT_ID'
9635 then
9636 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_PTIP_ENRT_ID' ;
9637 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LCT_unique.information1 ;
9638 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LCT_unique.information1 ;
9639 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
9640 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LCT_unique.table_route_id;
9641 --
9642 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
9643 --
9644 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
9645 --
9646 --DOUBT log_data('LCT',l_new_value,l_prefix || r_LCT_unique.name|| l_suffix,'REUSED');
9647 --
9648 end if ;
9649 hr_utility.set_location( 'found record for update',10);
9650 --
9651 else
9652 --
9653 l_update := false;
9654 --
9655 end if;
9656 else
9657 --
9658 --UPD END
9659
9660 l_min_esd := null ;
9661 l_max_eed := null ;
9662 open c_LCT_min_max_dates(r_LCT_unique.table_route_id, r_LCT_unique.information1 ) ;
9663 fetch c_LCT_min_max_dates into l_min_esd,l_max_eed ;
9664 --
9665
9666 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9667 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
9668 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
9669 end if;
9670 l_min_esd := greatest(l_min_esd,r_LCT_unique.information2);
9671 /*
9672 open c_LCT(r_LCT_unique.table_route_id,
9673 r_LCT_unique.information1,
9674 r_LCT_unique.information2,
9675 r_LCT_unique.information3 ) ;
9676 --
9677 fetch c_LCT into r_LCT ;
9678 --
9679 close c_LCT ;
9680 --
9681 l_DFLT_ENRT_RL := get_fk('FORMULA_ID', r_LCT.INFORMATION13,l_dml_operation);
9682 l_ENRT_RL := get_fk('FORMULA_ID', r_LCT.INFORMATION16,l_dml_operation);
9683 l_LER_ID := get_fk('LER_ID', r_LCT.INFORMATION257,l_dml_operation);
9684 l_PTIP_ID := get_fk('PTIP_ID', r_LCT.INFORMATION259,l_dml_operation);
9685 */
9686 if p_reuse_object_flag = 'Y' then
9687 if c_LCT_min_max_dates%found then
9688 -- cursor to find the object
9689 open c_find_LCT_in_target( l_min_esd,l_max_eed,
9690 p_target_business_group_id, nvl(l_ler_chg_ptip_enrt_id, -999) ) ;
9691 fetch c_find_LCT_in_target into l_new_value ;
9692 if c_find_LCT_in_target%found then
9693 --
9694 --TEMPIK
9695 l_dt_rec_found := dt_api.check_min_max_dates
9696 (p_base_table_name => 'BEN_LER_CHG_PTIP_ENRT_F',
9697 p_base_key_column => 'LER_CHG_PTIP_ENRT_ID',
9698 p_base_key_value => l_new_value,
9699 p_from_date => l_min_esd,
9700 p_to_date => l_max_eed );
9701 if l_dt_rec_found THEN
9702 --END TEMPIK
9703 if r_LCT_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
9704 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_PTIP_ENRT_ID' then
9705 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_PTIP_ENRT_ID' ;
9706 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LCT_unique.information1 ;
9707 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
9708 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
9709 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LCT_unique.table_route_id;
9710 --
9711 -- 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) ;
9712 --
9713 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
9714 end if ;
9715 --
9716 l_object_found_in_target := true ;
9717 --TEMPIK
9718 end if; -- l_dt_rec_found
9719 --END TEMPIK
9720 end if;
9721 close c_find_LCT_in_target ;
9722 --
9723 end if;
9724 end if ;
9725 --
9726 close c_LCT_min_max_dates ;
9727 end if; --if p_dml_operation
9728 --
9729 if not l_object_found_in_target OR l_update then
9730
9731 --
9732 l_current_pk_id := r_LCT.information1;
9733 --
9734 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
9735 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
9736 --
9737 if l_current_pk_id = l_prev_pk_id then
9738 --
9739 l_first_rec := false ;
9740 --
9741 else
9742 --
9743 l_first_rec := true ;
9744 --
9745 end if ;
9746 --
9747
9748 l_effective_date := r_LCT.information2;
9749 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9750 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
9751 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
9752 end if;
9753
9754 if l_first_rec and not l_update then
9755
9756 -- Call Create routine.
9757 hr_utility.set_location(' BEN_LER_CHG_PTIP_ENRT_F CREATE_LER_CHG_PTIP_ENRT ',20);
9758 BEN_LER_CHG_PTIP_ENRT_API.CREATE_LER_CHG_PTIP_ENRT(
9759 --
9760 P_VALIDATE => false
9761 ,P_EFFECTIVE_DATE => l_effective_date
9762 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
9763 --
9764 ,P_CRNT_ENRT_PRCLDS_CHG_FLAG => r_LCT.INFORMATION18
9765 ,P_DFLT_ENRT_CD => r_LCT.INFORMATION12
9766 ,P_DFLT_ENRT_RL => l_DFLT_ENRT_RL
9767 ,P_DFLT_FLAG => r_LCT.INFORMATION11
9768 ,P_ENRT_CD => r_LCT.INFORMATION14
9769 ,P_ENRT_MTHD_CD => r_LCT.INFORMATION15
9770 ,P_ENRT_RL => l_ENRT_RL
9771 ,P_LCT_ATTRIBUTE1 => r_LCT.INFORMATION111
9772 ,P_LCT_ATTRIBUTE10 => r_LCT.INFORMATION120
9773 ,P_LCT_ATTRIBUTE11 => r_LCT.INFORMATION121
9774 ,P_LCT_ATTRIBUTE12 => r_LCT.INFORMATION122
9775 ,P_LCT_ATTRIBUTE13 => r_LCT.INFORMATION123
9776 ,P_LCT_ATTRIBUTE14 => r_LCT.INFORMATION124
9777 ,P_LCT_ATTRIBUTE15 => r_LCT.INFORMATION125
9778 ,P_LCT_ATTRIBUTE16 => r_LCT.INFORMATION126
9779 ,P_LCT_ATTRIBUTE17 => r_LCT.INFORMATION127
9780 ,P_LCT_ATTRIBUTE18 => r_LCT.INFORMATION128
9781 ,P_LCT_ATTRIBUTE19 => r_LCT.INFORMATION129
9782 ,P_LCT_ATTRIBUTE2 => r_LCT.INFORMATION112
9783 ,P_LCT_ATTRIBUTE20 => r_LCT.INFORMATION130
9784 ,P_LCT_ATTRIBUTE21 => r_LCT.INFORMATION131
9785 ,P_LCT_ATTRIBUTE22 => r_LCT.INFORMATION132
9786 ,P_LCT_ATTRIBUTE23 => r_LCT.INFORMATION133
9787 ,P_LCT_ATTRIBUTE24 => r_LCT.INFORMATION134
9788 ,P_LCT_ATTRIBUTE25 => r_LCT.INFORMATION135
9789 ,P_LCT_ATTRIBUTE26 => r_LCT.INFORMATION136
9790 ,P_LCT_ATTRIBUTE27 => r_LCT.INFORMATION137
9791 ,P_LCT_ATTRIBUTE28 => r_LCT.INFORMATION138
9792 ,P_LCT_ATTRIBUTE29 => r_LCT.INFORMATION139
9793 ,P_LCT_ATTRIBUTE3 => r_LCT.INFORMATION113
9794 ,P_LCT_ATTRIBUTE30 => r_LCT.INFORMATION140
9795 ,P_LCT_ATTRIBUTE4 => r_LCT.INFORMATION114
9796 ,P_LCT_ATTRIBUTE5 => r_LCT.INFORMATION115
9797 ,P_LCT_ATTRIBUTE6 => r_LCT.INFORMATION116
9798 ,P_LCT_ATTRIBUTE7 => r_LCT.INFORMATION117
9799 ,P_LCT_ATTRIBUTE8 => r_LCT.INFORMATION118
9800 ,P_LCT_ATTRIBUTE9 => r_LCT.INFORMATION119
9801 ,P_LCT_ATTRIBUTE_CATEGORY => r_LCT.INFORMATION110
9802 ,P_LER_CHG_PTIP_ENRT_ID => l_ler_chg_ptip_enrt_id
9803 ,P_LER_ID => l_LER_ID
9804 ,P_PTIP_ID => l_PTIP_ID
9805 ,P_STL_ELIG_CANT_CHG_FLAG => r_LCT.INFORMATION19
9806 ,P_TCO_CHG_ENRT_CD => r_LCT.INFORMATION17
9807 --
9808 ,P_EFFECTIVE_START_DATE => l_effective_start_date
9809 ,P_EFFECTIVE_END_DATE => l_effective_end_date
9810 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
9811 );
9812 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
9813 -- Update all relevent cer records with new pk_id
9814 hr_utility.set_location('Before plsql table ',222);
9815 hr_utility.set_location('new_value id '||l_ler_chg_ptip_enrt_id,222);
9816 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_PTIP_ENRT_ID' ;
9817 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LCT.information1 ;
9818 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LER_CHG_PTIP_ENRT_ID ;
9819 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
9820 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LCT_unique.table_route_id;
9821 hr_utility.set_location('After plsql table ',222);
9822 --
9823 -- 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 ) ;
9824 --
9825 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
9826 --
9827 else
9828 --
9829 -- Call Update routine for the pk_id created in prev run .
9830 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
9831 hr_utility.set_location(' BEN_LER_CHG_PTIP_ENRT_F UPDATE_LER_CHG_PTIP_ENRT ',30);
9832 --UPD START
9833 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
9834 --
9835 if l_update then
9836 --
9837 l_datetrack_mode := r_LCT.datetrack_mode ;
9838 --
9839 get_dt_modes(
9840 p_effective_date => l_process_date,
9841 p_effective_end_date => r_LCT.information3,
9842 p_effective_start_date => r_LCT.information2,
9843 p_dml_operation => r_LCT.dml_operation,
9844 p_datetrack_mode => l_datetrack_mode );
9845 -- p_update => l_update
9846 --
9847 l_effective_date := l_process_date;
9848 l_LER_CHG_PTIP_ENRT_ID := r_LCT.information1;
9849 l_object_version_number := r_LCT.information265;
9850 --
9851 end if;
9852 --
9853 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
9854 --
9855 IF l_update OR l_dml_operation <> 'UPDATE' THEN
9856 --UPD END
9857
9858 BEN_LER_CHG_PTIP_ENRT_API.UPDATE_LER_CHG_PTIP_ENRT(
9859 --
9860 P_VALIDATE => false
9861 ,P_EFFECTIVE_DATE => l_effective_date
9862 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
9863 --
9864 ,P_CRNT_ENRT_PRCLDS_CHG_FLAG => r_LCT.INFORMATION18
9865 ,P_DFLT_ENRT_CD => r_LCT.INFORMATION12
9866 ,P_DFLT_ENRT_RL => l_DFLT_ENRT_RL
9867 ,P_DFLT_FLAG => r_LCT.INFORMATION11
9868 ,P_ENRT_CD => r_LCT.INFORMATION14
9869 ,P_ENRT_MTHD_CD => r_LCT.INFORMATION15
9870 ,P_ENRT_RL => l_ENRT_RL
9871 ,P_LCT_ATTRIBUTE1 => r_LCT.INFORMATION111
9872 ,P_LCT_ATTRIBUTE10 => r_LCT.INFORMATION120
9873 ,P_LCT_ATTRIBUTE11 => r_LCT.INFORMATION121
9874 ,P_LCT_ATTRIBUTE12 => r_LCT.INFORMATION122
9875 ,P_LCT_ATTRIBUTE13 => r_LCT.INFORMATION123
9876 ,P_LCT_ATTRIBUTE14 => r_LCT.INFORMATION124
9877 ,P_LCT_ATTRIBUTE15 => r_LCT.INFORMATION125
9878 ,P_LCT_ATTRIBUTE16 => r_LCT.INFORMATION126
9879 ,P_LCT_ATTRIBUTE17 => r_LCT.INFORMATION127
9880 ,P_LCT_ATTRIBUTE18 => r_LCT.INFORMATION128
9881 ,P_LCT_ATTRIBUTE19 => r_LCT.INFORMATION129
9882 ,P_LCT_ATTRIBUTE2 => r_LCT.INFORMATION112
9883 ,P_LCT_ATTRIBUTE20 => r_LCT.INFORMATION130
9884 ,P_LCT_ATTRIBUTE21 => r_LCT.INFORMATION131
9885 ,P_LCT_ATTRIBUTE22 => r_LCT.INFORMATION132
9886 ,P_LCT_ATTRIBUTE23 => r_LCT.INFORMATION133
9887 ,P_LCT_ATTRIBUTE24 => r_LCT.INFORMATION134
9888 ,P_LCT_ATTRIBUTE25 => r_LCT.INFORMATION135
9889 ,P_LCT_ATTRIBUTE26 => r_LCT.INFORMATION136
9890 ,P_LCT_ATTRIBUTE27 => r_LCT.INFORMATION137
9891 ,P_LCT_ATTRIBUTE28 => r_LCT.INFORMATION138
9892 ,P_LCT_ATTRIBUTE29 => r_LCT.INFORMATION139
9893 ,P_LCT_ATTRIBUTE3 => r_LCT.INFORMATION113
9894 ,P_LCT_ATTRIBUTE30 => r_LCT.INFORMATION140
9895 ,P_LCT_ATTRIBUTE4 => r_LCT.INFORMATION114
9896 ,P_LCT_ATTRIBUTE5 => r_LCT.INFORMATION115
9897 ,P_LCT_ATTRIBUTE6 => r_LCT.INFORMATION116
9898 ,P_LCT_ATTRIBUTE7 => r_LCT.INFORMATION117
9899 ,P_LCT_ATTRIBUTE8 => r_LCT.INFORMATION118
9900 ,P_LCT_ATTRIBUTE9 => r_LCT.INFORMATION119
9901 ,P_LCT_ATTRIBUTE_CATEGORY => r_LCT.INFORMATION110
9902 ,P_LER_CHG_PTIP_ENRT_ID => l_ler_chg_ptip_enrt_id
9903 ,P_LER_ID => l_LER_ID
9904 ,P_PTIP_ID => l_PTIP_ID
9905 ,P_STL_ELIG_CANT_CHG_FLAG => r_LCT.INFORMATION19
9906 ,P_TCO_CHG_ENRT_CD => r_LCT.INFORMATION17
9907 --
9908 ,P_EFFECTIVE_START_DATE => l_effective_start_date
9909 ,P_EFFECTIVE_END_DATE => l_effective_end_date
9910 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
9911 ,P_DATETRACK_MODE => l_datetrack_mode
9912 );
9913 --
9914 end if; -- l_update
9915 end if;
9916 --
9917 -- Delete the row if it is end dated.
9918 --
9919 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
9920 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
9921 trunc(l_max_eed) = r_LCT.information3) then
9922 --
9923 BEN_LER_CHG_PTIP_ENRT_API.delete_LER_CHG_PTIP_ENRT(
9924 --
9925 p_validate => false
9926 ,p_ler_chg_ptip_enrt_id => l_ler_chg_ptip_enrt_id
9927 ,p_effective_start_date => l_effective_start_date
9928 ,p_effective_end_date => l_effective_end_date
9929 ,p_object_version_number => l_object_version_number
9930 ,p_effective_date => l_max_eed
9931 ,p_datetrack_mode => hr_api.g_delete
9932 --
9933 );
9934 --
9935 end if;
9936 --
9937 l_prev_pk_id := l_current_pk_id ;
9938 --
9939 end if;
9940 --
9941 end if;
9942 --
9943 end loop;
9944 --
9945 exception when others then
9946 --
9947 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LCT',r_lct.information5 );
9948 --
9949 end create_LCT_rows;
9950
9951 --
9952 ---------------------------------------------------------------
9953 ----------------------< create_WCT_rows >-----------------------
9954 ---------------------------------------------------------------
9955 --
9956 procedure create_WCT_rows
9957 (
9958 p_validate in number default 0
9959 ,p_copy_entity_txn_id in number
9960 ,p_effective_date in date
9961 ,p_prefix_suffix_text in varchar2 default null
9962 ,p_reuse_object_flag in varchar2 default null
9963 ,p_target_business_group_id in varchar2 default null
9964 ,p_prefix_suffix_cd in varchar2 default null
9965 ) is
9966 --
9967 l_CTFN_RQD_WHEN_RL number;
9968 l_WV_PRTN_RSN_PTIP_ID number;
9969 l_WV_PRTN_CTFN_TYP_CD varchar2(30) ;
9970 cursor c_unique_WCT(l_table_alias varchar2) is
9971 select distinct cpe.information1,
9972 cpe.information2,
9973 cpe.information3,
9974 cpe.table_route_id
9975 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
9976 pqh_table_route tr
9977 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9978 and cpe.table_route_id = tr.table_route_id
9979 -- and tr.where_clause = l_BEN_WV_PRTN_RSN_CTFN_PTIP_F
9980 and tr.table_alias = l_table_alias
9981 and cpe.number_of_copies = 1 -- ADDITION
9982 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
9983 order by information1, information2; --added for bug: 5151945
9984 --
9985 --
9986 cursor c_WCT_min_max_dates(c_table_route_id number,
9987 c_information1 number) is
9988 select
9989 min(cpe.information2) min_esd,
9990 max(cpe.information3) min_eed
9991 from ben_copy_entity_results cpe
9992 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9993 and cpe.table_route_id = c_table_route_id
9994 and cpe.information1 = c_information1 ;
9995 --
9996 cursor c_WCT(c_table_route_id number,
9997 c_information1 number,
9998 c_information2 date,
9999 c_information3 date ) is
10000 select
10001 cpe.*
10002 from ben_copy_entity_results cpe
10003 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10004 and cpe.table_route_id = c_table_route_id
10005 and cpe.information1 = c_information1
10006 and cpe.information2 = c_information2
10007 and cpe.information3 = c_information3
10008 and rownum = 1 ;
10009 -- Date Track target record
10010 cursor c_find_WCT_in_target(
10011 c_effective_start_date date,
10012 c_effective_end_date date,
10013 c_business_group_id number,
10014 c_new_pk_id number) is
10015 select
10016 WCT.wv_prtn_rsn_ctfn_ptip_id new_value
10017 from BEN_WV_PRTN_RSN_CTFN_PTIP_F WCT
10018 where
10019 WCT.WV_PRTN_RSN_PTIP_ID = l_WV_PRTN_RSN_PTIP_ID and
10020 WCT.WV_PRTN_CTFN_TYP_CD = l_WV_PRTN_CTFN_TYP_CD and
10021 WCT.business_group_id = c_business_group_id
10022 and WCT.wv_prtn_rsn_ctfn_ptip_id <> c_new_pk_id
10023 --TEMPIK
10024 and c_effective_start_date between effective_start_date
10025 and effective_end_date ;
10026 --END TEMPIK
10027 /*TEMPIK
10028 and exists ( select null
10029 from BEN_WV_PRTN_RSN_CTFN_PTIP_F WCT1
10030 where
10031 WCT1.WV_PRTN_RSN_PTIP_ID = l_WV_PRTN_RSN_PTIP_ID and
10032 WCT1.WV_PRTN_CTFN_TYP_CD = l_WV_PRTN_CTFN_TYP_CD and
10033 WCT1.business_group_id = c_business_group_id
10034 and WCT1.effective_start_date <= c_effective_start_date )
10035 and exists ( select null
10036 from BEN_WV_PRTN_RSN_CTFN_PTIP_F WCT2
10037 where
10038 WCT2.WV_PRTN_RSN_PTIP_ID = l_WV_PRTN_RSN_PTIP_ID and
10039 WCT2.WV_PRTN_CTFN_TYP_CD = l_WV_PRTN_CTFN_TYP_CD and
10040 WCT2.business_group_id = c_business_group_id
10041 and WCT2.effective_end_date >= c_effective_end_date )
10042 ;
10043 TEMPIK */
10044 --TEMPIK
10045 l_dt_rec_found boolean ;
10046 --END TEMPIK
10047 --
10048 --UPD START
10049 --
10050 l_update boolean := false ;
10051 l_datetrack_mode varchar2(80) := hr_api.g_update;
10052 l_process_date date;
10053 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
10054 --
10055 --UPD END
10056 l_current_pk_id number := null ;
10057 l_prev_pk_id number := null ;
10058 l_first_rec boolean := true ;
10059 r_WCT c_WCT%rowtype;
10060 l_wv_prtn_rsn_ctfn_ptip_id number ;
10061 l_object_version_number number ;
10062 l_effective_start_date date ;
10063 l_effective_end_date date ;
10064 l_prefix pqh_copy_entity_attribs.information1%type := null;
10065 l_suffix pqh_copy_entity_attribs.information1%type := null;
10066 l_new_value number(15);
10067 l_object_found_in_target boolean := false ;
10068 l_min_esd date;
10069 l_max_eed date;
10070 l_effective_date date;
10071 --
10072 begin
10073 -- Initialization
10074 l_object_found_in_target := false ;
10075 -- End Initialization
10076 -- Derive the prefix - sufix
10077 if p_prefix_suffix_cd = 'PREFIX' then
10078 l_prefix := p_prefix_suffix_text ;
10079 elsif p_prefix_suffix_cd = 'SUFFIX' then
10080 l_suffix := p_prefix_suffix_text ;
10081 else
10082 l_prefix := null ;
10083 l_suffix := null ;
10084 end if ;
10085 -- End Prefix Sufix derivation
10086 for r_WCT_unique in c_unique_WCT('WCT') loop
10087
10088 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
10089 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10090 r_WCT_unique.information3 >=
10091 ben_pd_copy_to_ben_one.g_copy_effective_date)
10092 ) then
10093 --
10094 hr_utility.set_location(' r_WCT_unique.table_route_id '||r_WCT_unique.table_route_id,10);
10095 hr_utility.set_location(' r_WCT_unique.information1 '||r_WCT_unique.information1,10);
10096 hr_utility.set_location( 'r_WCT_unique.information2 '||r_WCT_unique.information2,10);
10097 hr_utility.set_location( 'r_WCT_unique.information3 '||r_WCT_unique.information3,10);
10098 -- If reuse objects flag is 'Y' then check for the object in the target business group
10099 -- if found insert the record into PLSql table and exit the loop else try create the
10100 -- object in the target business group
10101 --
10102 l_object_found_in_target := false ;
10103 --UPD START
10104 open c_WCT(r_WCT_unique.table_route_id,
10105 r_WCT_unique.information1,
10106 r_WCT_unique.information2,
10107 r_WCT_unique.information3 ) ;
10108 --
10109 fetch c_WCT into r_WCT ;
10110 --
10111 close c_WCT ;
10112 --
10113 l_dml_operation:= r_WCT_unique.dml_operation ;
10114 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_WCT.INFORMATION258,l_dml_operation );
10115 l_WV_PRTN_RSN_PTIP_ID := get_fk('WV_PRTN_RSN_PTIP_ID', r_WCT.INFORMATION257,l_dml_operation );
10116 l_WV_PRTN_CTFN_TYP_CD := r_WCT.information15 ;
10117 --
10118 l_update := false;
10119 l_process_date := p_effective_date;
10120 --
10121 if l_dml_operation = 'UPDATE' then
10122 --
10123 l_object_found_in_target := TRUE;
10124 --
10125 if l_process_date between r_WCT_unique.information2 and r_WCT_unique.information3 then
10126 l_update := true;
10127 if r_WCT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
10128 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'WV_PRTN_RSN_CTFN_PTIP_ID'
10129 then
10130 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'WV_PRTN_RSN_CTFN_PTIP_ID' ;
10131 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_WCT_unique.information1 ;
10132 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_WCT_unique.information1 ;
10133 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
10134 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_WCT_unique.table_route_id;
10135 --
10136 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
10137 --
10138 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10139 --
10140 --DOUBT log_data('WCT',l_new_value,l_prefix || r_WCT_unique.name|| l_suffix,'REUSED');
10141 --
10142 end if ;
10143 hr_utility.set_location( 'found record for update',10);
10144 --
10145 else
10146 --
10147 l_update := false;
10148 --
10149 end if;
10150 else
10151 --
10152 --UPD END
10153 l_min_esd := null ;
10154 l_max_eed := null ;
10155 open c_WCT_min_max_dates(r_WCT_unique.table_route_id, r_WCT_unique.information1 ) ;
10156 fetch c_WCT_min_max_dates into l_min_esd,l_max_eed ;
10157 --
10158
10159 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10160 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
10161 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
10162 end if;
10163 l_min_esd := greatest(l_min_esd,r_WCT_unique.information2);
10164 /* open c_WCT(r_WCT_unique.table_route_id,
10165 r_WCT_unique.information1,
10166 r_WCT_unique.information2,
10167 r_WCT_unique.information3 ) ;
10168 --
10169 fetch c_WCT into r_WCT ;
10170 --
10171 close c_WCT ; */
10172 --
10173 if p_reuse_object_flag = 'Y' then
10174 if c_WCT_min_max_dates%found then
10175 -- cursor to find the object
10176 open c_find_WCT_in_target( l_min_esd,l_max_eed,
10177 p_target_business_group_id, nvl(l_wv_prtn_rsn_ctfn_ptip_id, -999) ) ;
10178 fetch c_find_WCT_in_target into l_new_value ;
10179 if c_find_WCT_in_target%found then
10180 --
10181 --TEMPIK
10182 l_dt_rec_found := dt_api.check_min_max_dates
10183 (p_base_table_name => 'BEN_WV_PRTN_RSN_CTFN_PTIP_F',
10184 p_base_key_column => 'WV_PRTN_RSN_CTFN_PTIP_ID',
10185 p_base_key_value => l_new_value,
10186 p_from_date => l_min_esd,
10187 p_to_date => l_max_eed );
10188 if l_dt_rec_found THEN
10189 --END TEMPIK
10190 if r_WCT_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
10191 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'WV_PRTN_RSN_CTFN_PTIP_ID' then
10192 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'WV_PRTN_RSN_CTFN_PTIP_ID' ;
10193 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_WCT_unique.information1 ;
10194 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
10195 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
10196 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_WCT_unique.table_route_id;
10197 --
10198 -- 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) ;
10199 --
10200 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10201 end if ;
10202 --
10203 l_object_found_in_target := true ;
10204 --TEMPIK
10205 end if; -- l_dt_rec_found
10206 --END TEMPIK
10207 end if;
10208 close c_find_WCT_in_target ;
10209 --
10210 end if;
10211 end if ;
10212 --
10213 close c_WCT_min_max_dates ;
10214 end if; --if p_dml_operation
10215 --
10216 if not l_object_found_in_target OR l_update then
10217 --
10218 l_current_pk_id := r_WCT.information1;
10219 --
10220 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
10221 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
10222 --
10223 if l_current_pk_id = l_prev_pk_id then
10224 --
10225 l_first_rec := false ;
10226 --
10227 else
10228 --
10229 l_first_rec := true ;
10230 --
10231 end if ;
10232 --
10233
10234 l_effective_date := r_WCT.information2;
10235 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10236 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
10237 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
10238 end if;
10239
10240 if l_first_rec and not l_update then
10241 -- Call Create routine.
10242 hr_utility.set_location(' BEN_WV_PRTN_RSN_CTFN_PTIP_F CREATE_WV_PRTN_RSN_CTFN_PTIP ',20);
10243 BEN_WV_PRTN_RSN_CTFN_PTIP_API.CREATE_WV_PRTN_RSN_CTFN_PTIP(
10244 --
10245 P_VALIDATE => false
10246 ,P_EFFECTIVE_DATE => l_effective_date
10247 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
10248 --
10249 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
10250 ,P_LACK_CTFN_SSPND_WVR_FLAG => r_WCT.INFORMATION11
10251 ,P_PFD_FLAG => r_WCT.INFORMATION13
10252 ,P_RQD_FLAG => r_WCT.INFORMATION12
10253 ,P_WCT_ATTRIBUTE1 => r_WCT.INFORMATION111
10254 ,P_WCT_ATTRIBUTE10 => r_WCT.INFORMATION120
10255 ,P_WCT_ATTRIBUTE11 => r_WCT.INFORMATION121
10256 ,P_WCT_ATTRIBUTE12 => r_WCT.INFORMATION122
10257 ,P_WCT_ATTRIBUTE13 => r_WCT.INFORMATION123
10258 ,P_WCT_ATTRIBUTE14 => r_WCT.INFORMATION124
10259 ,P_WCT_ATTRIBUTE15 => r_WCT.INFORMATION125
10260 ,P_WCT_ATTRIBUTE16 => r_WCT.INFORMATION126
10261 ,P_WCT_ATTRIBUTE17 => r_WCT.INFORMATION127
10262 ,P_WCT_ATTRIBUTE18 => r_WCT.INFORMATION128
10263 ,P_WCT_ATTRIBUTE19 => r_WCT.INFORMATION129
10264 ,P_WCT_ATTRIBUTE2 => r_WCT.INFORMATION112
10265 ,P_WCT_ATTRIBUTE20 => r_WCT.INFORMATION130
10266 ,P_WCT_ATTRIBUTE21 => r_WCT.INFORMATION131
10267 ,P_WCT_ATTRIBUTE22 => r_WCT.INFORMATION132
10268 ,P_WCT_ATTRIBUTE23 => r_WCT.INFORMATION133
10269 ,P_WCT_ATTRIBUTE24 => r_WCT.INFORMATION134
10270 ,P_WCT_ATTRIBUTE25 => r_WCT.INFORMATION135
10271 ,P_WCT_ATTRIBUTE26 => r_WCT.INFORMATION136
10272 ,P_WCT_ATTRIBUTE27 => r_WCT.INFORMATION137
10273 ,P_WCT_ATTRIBUTE28 => r_WCT.INFORMATION138
10274 ,P_WCT_ATTRIBUTE29 => r_WCT.INFORMATION139
10275 ,P_WCT_ATTRIBUTE3 => r_WCT.INFORMATION113
10276 ,P_WCT_ATTRIBUTE30 => r_WCT.INFORMATION140
10277 ,P_WCT_ATTRIBUTE4 => r_WCT.INFORMATION114
10278 ,P_WCT_ATTRIBUTE5 => r_WCT.INFORMATION115
10279 ,P_WCT_ATTRIBUTE6 => r_WCT.INFORMATION116
10280 ,P_WCT_ATTRIBUTE7 => r_WCT.INFORMATION117
10281 ,P_WCT_ATTRIBUTE8 => r_WCT.INFORMATION118
10282 ,P_WCT_ATTRIBUTE9 => r_WCT.INFORMATION119
10283 ,P_WCT_ATTRIBUTE_CATEGORY => r_WCT.INFORMATION110
10284 ,P_WV_PRTN_CTFN_CD => r_WCT.INFORMATION15
10285 ,P_WV_PRTN_CTFN_TYP_CD => r_WCT.INFORMATION14
10286 ,P_WV_PRTN_RSN_CTFN_PTIP_ID => l_wv_prtn_rsn_ctfn_ptip_id
10287 ,P_WV_PRTN_RSN_PTIP_ID => l_WV_PRTN_RSN_PTIP_ID
10288 --
10289 ,P_EFFECTIVE_START_DATE => l_effective_start_date
10290 ,P_EFFECTIVE_END_DATE => l_effective_end_date
10291 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
10292 );
10293 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
10294 -- Update all relevent cer records with new pk_id
10295 hr_utility.set_location('Before plsql table ',222);
10296 hr_utility.set_location('new_value id '||l_wv_prtn_rsn_ctfn_ptip_id,222);
10297 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'WV_PRTN_RSN_CTFN_PTIP_ID' ;
10298 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_WCT.information1 ;
10299 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_WV_PRTN_RSN_CTFN_PTIP_ID ;
10300 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
10301 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_WCT_unique.table_route_id;
10302 hr_utility.set_location('After plsql table ',222);
10303 --
10304 -- 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 ) ;
10305 --
10306 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10307 --
10308 else
10309 --
10310 -- Call Update routine for the pk_id created in prev run .
10311 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
10312 hr_utility.set_location(' BEN_WV_PRTN_RSN_CTFN_PTIP_F UPDATE_WV_PRTN_RSN_CTFN_PTIP ',30);
10313 --UPD START
10314 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
10315 --
10316 if l_update then
10317 --
10318 l_datetrack_mode := r_WCT.datetrack_mode ;
10319 --
10320 get_dt_modes(
10321 p_effective_date => l_process_date,
10322 p_effective_end_date => r_WCT.information3,
10323 p_effective_start_date => r_WCT.information2,
10324 p_dml_operation => r_WCT.dml_operation,
10325 p_datetrack_mode => l_datetrack_mode );
10326 -- p_update => l_update
10327 --
10328 l_effective_date := l_process_date;
10329 l_WV_PRTN_RSN_CTFN_PTIP_ID := r_WCT.information1;
10330 l_object_version_number := r_WCT.information265;
10331 --
10332 end if;
10333 --
10334 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
10335 --
10336 IF l_update OR l_dml_operation <> 'UPDATE' THEN
10337 --UPD END
10338
10339
10340 BEN_WV_PRTN_RSN_CTFN_PTIP_API.UPDATE_WV_PRTN_RSN_CTFN_PTIP(
10341 --
10342 P_VALIDATE => false
10343 ,P_EFFECTIVE_DATE => l_effective_date
10344 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
10345 --
10346 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
10347 ,P_LACK_CTFN_SSPND_WVR_FLAG => r_WCT.INFORMATION11
10348 ,P_PFD_FLAG => r_WCT.INFORMATION13
10349 ,P_RQD_FLAG => r_WCT.INFORMATION12
10350 ,P_WCT_ATTRIBUTE1 => r_WCT.INFORMATION111
10351 ,P_WCT_ATTRIBUTE10 => r_WCT.INFORMATION120
10352 ,P_WCT_ATTRIBUTE11 => r_WCT.INFORMATION121
10353 ,P_WCT_ATTRIBUTE12 => r_WCT.INFORMATION122
10354 ,P_WCT_ATTRIBUTE13 => r_WCT.INFORMATION123
10355 ,P_WCT_ATTRIBUTE14 => r_WCT.INFORMATION124
10356 ,P_WCT_ATTRIBUTE15 => r_WCT.INFORMATION125
10357 ,P_WCT_ATTRIBUTE16 => r_WCT.INFORMATION126
10358 ,P_WCT_ATTRIBUTE17 => r_WCT.INFORMATION127
10359 ,P_WCT_ATTRIBUTE18 => r_WCT.INFORMATION128
10360 ,P_WCT_ATTRIBUTE19 => r_WCT.INFORMATION129
10361 ,P_WCT_ATTRIBUTE2 => r_WCT.INFORMATION112
10362 ,P_WCT_ATTRIBUTE20 => r_WCT.INFORMATION130
10363 ,P_WCT_ATTRIBUTE21 => r_WCT.INFORMATION131
10364 ,P_WCT_ATTRIBUTE22 => r_WCT.INFORMATION132
10365 ,P_WCT_ATTRIBUTE23 => r_WCT.INFORMATION133
10366 ,P_WCT_ATTRIBUTE24 => r_WCT.INFORMATION134
10367 ,P_WCT_ATTRIBUTE25 => r_WCT.INFORMATION135
10368 ,P_WCT_ATTRIBUTE26 => r_WCT.INFORMATION136
10369 ,P_WCT_ATTRIBUTE27 => r_WCT.INFORMATION137
10370 ,P_WCT_ATTRIBUTE28 => r_WCT.INFORMATION138
10371 ,P_WCT_ATTRIBUTE29 => r_WCT.INFORMATION139
10372 ,P_WCT_ATTRIBUTE3 => r_WCT.INFORMATION113
10373 ,P_WCT_ATTRIBUTE30 => r_WCT.INFORMATION140
10374 ,P_WCT_ATTRIBUTE4 => r_WCT.INFORMATION114
10375 ,P_WCT_ATTRIBUTE5 => r_WCT.INFORMATION115
10376 ,P_WCT_ATTRIBUTE6 => r_WCT.INFORMATION116
10377 ,P_WCT_ATTRIBUTE7 => r_WCT.INFORMATION117
10378 ,P_WCT_ATTRIBUTE8 => r_WCT.INFORMATION118
10379 ,P_WCT_ATTRIBUTE9 => r_WCT.INFORMATION119
10380 ,P_WCT_ATTRIBUTE_CATEGORY => r_WCT.INFORMATION110
10381 ,P_WV_PRTN_CTFN_CD => r_WCT.INFORMATION15
10382 ,P_WV_PRTN_CTFN_TYP_CD => r_WCT.INFORMATION14
10383 ,P_WV_PRTN_RSN_CTFN_PTIP_ID => l_wv_prtn_rsn_ctfn_ptip_id
10384 ,P_WV_PRTN_RSN_PTIP_ID => l_WV_PRTN_RSN_PTIP_ID
10385 --
10386 ,P_EFFECTIVE_START_DATE => l_effective_start_date
10387 ,P_EFFECTIVE_END_DATE => l_effective_end_date
10388 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
10389 ,P_DATETRACK_MODE => l_datetrack_mode
10390 );
10391 --
10392 end if; -- l_update
10393 end if;
10394 --
10395 -- Delete the row if it is end dated.
10396 --
10397 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
10398 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
10399 trunc(l_max_eed) = r_WCT.information3) then
10400 --
10401 BEN_WV_PRTN_RSN_CTFN_PTIP_API.delete_WV_PRTN_RSN_CTFN_PTIP(
10402 --
10403 p_validate => false
10404 ,p_wv_prtn_rsn_ctfn_ptip_id => l_wv_prtn_rsn_ctfn_ptip_id
10405 ,p_effective_start_date => l_effective_start_date
10406 ,p_effective_end_date => l_effective_end_date
10407 ,p_object_version_number => l_object_version_number
10408 ,p_effective_date => l_max_eed
10409 ,p_datetrack_mode => hr_api.g_delete
10410 --
10411 );
10412 --
10413 end if;
10414 --
10415 l_prev_pk_id := l_current_pk_id ;
10416 --
10417 end if;
10418 --
10419 end if;
10420 --
10421 end loop;
10422 --
10423 exception when others then
10424 --
10425 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'WCT',r_wct.information5 );
10426 --
10427 end create_WCT_rows;
10428
10429 --
10430 ---------------------------------------------------------------
10431 ----------------------< create_WPT_rows >-----------------------
10432 ---------------------------------------------------------------
10433 --
10434 procedure create_WPT_rows
10435 (
10436 p_validate in number default 0
10437 ,p_copy_entity_txn_id in number
10438 ,p_effective_date in date
10439 ,p_prefix_suffix_text in varchar2 default null
10440 ,p_reuse_object_flag in varchar2 default null
10441 ,p_target_business_group_id in varchar2 default null
10442 ,p_prefix_suffix_cd in varchar2 default null
10443 ) is
10444 --
10445 l_PTIP_ID number;
10446 l_WV_PRTN_RSN_CD varchar2(30);
10447 --
10448 cursor c_unique_WPT(l_table_alias varchar2) is
10449 select distinct cpe.information1,
10450 cpe.information2,
10451 cpe.information3,
10452 cpe.table_route_id
10453 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
10454 pqh_table_route tr
10455 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10456 and cpe.table_route_id = tr.table_route_id
10457 -- and tr.where_clause = l_BEN_WV_PRTN_RSN_PTIP_F
10458 and tr.table_alias = l_table_alias
10459 and cpe.number_of_copies = 1 -- ADDITION
10460 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
10461 order by information1, information2; --added for bug: 5151945
10462 --
10463 --
10464 cursor c_WPT_min_max_dates(c_table_route_id number,
10465 c_information1 number) is
10466 select
10467 min(cpe.information2) min_esd,
10468 max(cpe.information3) min_eed
10469 from ben_copy_entity_results cpe
10470 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10471 and cpe.table_route_id = c_table_route_id
10472 and cpe.information1 = c_information1 ;
10473 --
10474 cursor c_WPT(c_table_route_id number,
10475 c_information1 number,
10476 c_information2 date,
10477 c_information3 date ) is
10478 select
10479 cpe.*
10480 from ben_copy_entity_results cpe
10481 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10482 and cpe.table_route_id = c_table_route_id
10483 and cpe.information1 = c_information1
10484 and cpe.information2 = c_information2
10485 and cpe.information3 = c_information3
10486 and rownum = 1 ;
10487 -- Date Track target record
10488 cursor c_find_WPT_in_target(
10489 c_effective_start_date date,
10490 c_effective_end_date date,
10491 c_business_group_id number,
10492 c_new_pk_id number) is
10493 select
10494 WPT.wv_prtn_rsn_ptip_id new_value
10495 from BEN_WV_PRTN_RSN_PTIP_F WPT
10496 where
10497 WPT.PTIP_ID = l_PTIP_ID and
10498 WPT.WV_PRTN_RSN_CD = l_WV_PRTN_RSN_CD and
10499 WPT.business_group_id = c_business_group_id
10500 and WPT.wv_prtn_rsn_ptip_id <> c_new_pk_id
10501 --TEMPIK
10502 and c_effective_start_date between effective_start_date
10503 and effective_end_date ;
10504 --END TEMPIK
10505 /*TEMPIK
10506 and exists ( select null
10507 from BEN_WV_PRTN_RSN_PTIP_F WPT1
10508 where
10509 WPT1.PTIP_ID = l_PTIP_ID and
10510 WPT1.WV_PRTN_RSN_CD = l_WV_PRTN_RSN_CD and
10511 WPT1.business_group_id = c_business_group_id
10512 and WPT1.effective_start_date <= c_effective_start_date )
10513 and exists ( select null
10514 from BEN_WV_PRTN_RSN_PTIP_F WPT2
10515 where
10516 WPT2.PTIP_ID = l_PTIP_ID and
10517 WPT2.WV_PRTN_RSN_CD = l_WV_PRTN_RSN_CD and
10518 WPT2.business_group_id = c_business_group_id
10519 and WPT2.effective_end_date >= c_effective_end_date )
10520 ;
10521 TEMPIK */
10522 --TEMPIK
10523 l_dt_rec_found boolean ;
10524 --END TEMPIK
10525 --
10526 --UPD START
10527 --
10528 l_update boolean := false ;
10529 l_datetrack_mode varchar2(80) := hr_api.g_update;
10530 l_process_date date;
10531 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
10532 --
10533 --UPD END
10534 l_current_pk_id number := null ;
10535 l_prev_pk_id number := null ;
10536 l_first_rec boolean := true ;
10537 r_WPT c_WPT%rowtype;
10538 l_wv_prtn_rsn_ptip_id number ;
10539 l_object_version_number number ;
10540 l_effective_start_date date ;
10541 l_effective_end_date date ;
10542 l_prefix pqh_copy_entity_attribs.information1%type := null;
10543 l_suffix pqh_copy_entity_attribs.information1%type := null;
10544 l_new_value number(15);
10545 l_object_found_in_target boolean := false ;
10546 l_min_esd date;
10547 l_max_eed date;
10548 l_effective_date date;
10549 --
10550 begin
10551 -- Initialization
10552 l_object_found_in_target := false ;
10553 -- End Initialization
10554 -- Derive the prefix - sufix
10555 if p_prefix_suffix_cd = 'PREFIX' then
10556 l_prefix := p_prefix_suffix_text ;
10557 elsif p_prefix_suffix_cd = 'SUFFIX' then
10558 l_suffix := p_prefix_suffix_text ;
10559 else
10560 l_prefix := null ;
10561 l_suffix := null ;
10562 end if ;
10563 -- End Prefix Sufix derivation
10564 for r_WPT_unique in c_unique_WPT('WPT') loop
10565
10566 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
10567 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10568 r_WPT_unique.information3 >=
10569 ben_pd_copy_to_ben_one.g_copy_effective_date)
10570 ) then
10571 --
10572 hr_utility.set_location(' r_WPT_unique.table_route_id '||r_WPT_unique.table_route_id,10);
10573 hr_utility.set_location(' r_WPT_unique.information1 '||r_WPT_unique.information1,10);
10574 hr_utility.set_location( 'r_WPT_unique.information2 '||r_WPT_unique.information2,10);
10575 hr_utility.set_location( 'r_WPT_unique.information3 '||r_WPT_unique.information3,10);
10576 -- If reuse objects flag is 'Y' then check for the object in the target business group
10577 -- if found insert the record into PLSql table and exit the loop else try create the
10578 -- object in the target business group
10579 --
10580 l_object_found_in_target := false ;
10581 --UPD START
10582 open c_WPT(r_WPT_unique.table_route_id,
10583 r_WPT_unique.information1,
10584 r_WPT_unique.information2,
10585 r_WPT_unique.information3 ) ;
10586 --
10587 fetch c_WPT into r_WPT ;
10588 --
10589 close c_WPT ;
10590 --
10591 l_dml_operation:= r_WPT_unique.dml_operation ;
10592 l_PTIP_ID := get_fk('PTIP_ID', r_WPT.INFORMATION259,l_dml_operation);
10593 l_WV_PRTN_RSN_CD := r_WPT.information12 ;
10594 --
10595 l_update := false;
10596 l_process_date := p_effective_date;
10597 --
10598 if l_dml_operation = 'UPDATE' then
10599 --
10600 l_object_found_in_target := TRUE;
10601 --
10602 if l_process_date between r_WPT_unique.information2 and r_WPT_unique.information3 then
10603 l_update := true;
10604 if r_WPT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
10605 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'WV_PRTN_RSN_PTIP_ID'
10606 then
10607 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'WV_PRTN_RSN_PTIP_ID' ;
10608 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_WPT_unique.information1 ;
10609 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_WPT_unique.information1 ;
10610 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
10611 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_WPT_unique.table_route_id;
10612 --
10613 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
10614 --
10615 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10616 --
10617 --DOUBT log_data('WPT',l_new_value,l_prefix || r_WPT_unique.name|| l_suffix,'REUSED');
10618 --
10619 end if ;
10620 hr_utility.set_location( 'found record for update',10);
10621 --
10622 else
10623 --
10624 l_update := false;
10625 --
10626 end if;
10627 else
10628 --
10629 --UPD END
10630 l_min_esd := null ;
10631 l_max_eed := null ;
10632 open c_WPT_min_max_dates(r_WPT_unique.table_route_id, r_WPT_unique.information1 ) ;
10633 fetch c_WPT_min_max_dates into l_min_esd,l_max_eed ;
10634 --
10635
10636 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10637 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
10638 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
10639 end if;
10640 l_min_esd := greatest(l_min_esd,r_WPT_unique.information2);
10641 /* open c_WPT(r_WPT_unique.table_route_id,
10642 r_WPT_unique.information1,
10643 r_WPT_unique.information2,
10644 r_WPT_unique.information3 ) ;
10645 --
10646 fetch c_WPT into r_WPT ;
10647 --
10648 close c_WPT ; */
10649 --
10650 --
10651 if p_reuse_object_flag = 'Y' then
10652 if c_WPT_min_max_dates%found then
10653 -- cursor to find the object
10654 open c_find_WPT_in_target( l_min_esd,l_max_eed,
10655 p_target_business_group_id, nvl(l_wv_prtn_rsn_ptip_id, -999) ) ;
10656 fetch c_find_WPT_in_target into l_new_value ;
10657 if c_find_WPT_in_target%found then
10658 --
10659 --TEMPIK
10660 l_dt_rec_found := dt_api.check_min_max_dates
10661 (p_base_table_name => 'BEN_WV_PRTN_RSN_PTIP_F',
10662 p_base_key_column => 'WV_PRTN_RSN_PTIP_ID',
10663 p_base_key_value => l_new_value,
10664 p_from_date => l_min_esd,
10665 p_to_date => l_max_eed );
10666 if l_dt_rec_found THEN
10667 --END TEMPIK
10668 if r_WPT_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
10669 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'WV_PRTN_RSN_PTIP_ID' then
10670 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'WV_PRTN_RSN_PTIP_ID' ;
10671 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_WPT_unique.information1 ;
10672 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
10673 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
10674 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_WPT_unique.table_route_id;
10675 --
10676 -- 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) ;
10677 --
10678 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10679 end if ;
10680 --
10681 l_object_found_in_target := true ;
10682 --TEMPIK
10683 end if; -- l_dt_rec_found
10684 --END TEMPIK
10685 end if;
10686 close c_find_WPT_in_target ;
10687 --
10688 end if;
10689 end if ;
10690 --
10691 close c_WPT_min_max_dates ;
10692 end if; --if p_dml_operation
10693 --
10694 if not l_object_found_in_target OR l_update then
10695
10696 --
10697 l_current_pk_id := r_WPT.information1;
10698 --
10699 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
10700 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
10701 --
10702 if l_current_pk_id = l_prev_pk_id then
10703 --
10704 l_first_rec := false ;
10705 --
10706 else
10707 --
10708 l_first_rec := true ;
10709 --
10710 end if ;
10711 --
10712
10713 l_effective_date := r_WPT.information2;
10714 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10715 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
10716 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
10717 end if;
10718
10719 if l_first_rec and not l_update then
10720 -- Call Create routine.
10721 hr_utility.set_location(' BEN_WV_PRTN_RSN_PTIP_F CREATE_WV_PRTN_RSN_PTIP ',20);
10722 BEN_WV_PRTN_RSN_PTIP_API.CREATE_WV_PRTN_RSN_PTIP(
10723 --
10724 P_VALIDATE => false
10725 ,P_EFFECTIVE_DATE => l_effective_date
10726 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
10727 --
10728 ,P_DFLT_FLAG => r_WPT.INFORMATION11
10729 ,P_PTIP_ID => l_PTIP_ID
10730 ,P_WPT_ATTRIBUTE1 => r_WPT.INFORMATION111
10731 ,P_WPT_ATTRIBUTE10 => r_WPT.INFORMATION120
10732 ,P_WPT_ATTRIBUTE11 => r_WPT.INFORMATION121
10733 ,P_WPT_ATTRIBUTE12 => r_WPT.INFORMATION122
10734 ,P_WPT_ATTRIBUTE13 => r_WPT.INFORMATION123
10735 ,P_WPT_ATTRIBUTE14 => r_WPT.INFORMATION124
10736 ,P_WPT_ATTRIBUTE15 => r_WPT.INFORMATION125
10737 ,P_WPT_ATTRIBUTE16 => r_WPT.INFORMATION126
10738 ,P_WPT_ATTRIBUTE17 => r_WPT.INFORMATION127
10739 ,P_WPT_ATTRIBUTE18 => r_WPT.INFORMATION128
10740 ,P_WPT_ATTRIBUTE19 => r_WPT.INFORMATION129
10741 ,P_WPT_ATTRIBUTE2 => r_WPT.INFORMATION112
10742 ,P_WPT_ATTRIBUTE20 => r_WPT.INFORMATION130
10743 ,P_WPT_ATTRIBUTE21 => r_WPT.INFORMATION131
10744 ,P_WPT_ATTRIBUTE22 => r_WPT.INFORMATION132
10745 ,P_WPT_ATTRIBUTE23 => r_WPT.INFORMATION133
10746 ,P_WPT_ATTRIBUTE24 => r_WPT.INFORMATION134
10747 ,P_WPT_ATTRIBUTE25 => r_WPT.INFORMATION135
10748 ,P_WPT_ATTRIBUTE26 => r_WPT.INFORMATION136
10749 ,P_WPT_ATTRIBUTE27 => r_WPT.INFORMATION137
10750 ,P_WPT_ATTRIBUTE28 => r_WPT.INFORMATION138
10751 ,P_WPT_ATTRIBUTE29 => r_WPT.INFORMATION139
10752 ,P_WPT_ATTRIBUTE3 => r_WPT.INFORMATION113
10753 ,P_WPT_ATTRIBUTE30 => r_WPT.INFORMATION140
10754 ,P_WPT_ATTRIBUTE4 => r_WPT.INFORMATION114
10755 ,P_WPT_ATTRIBUTE5 => r_WPT.INFORMATION115
10756 ,P_WPT_ATTRIBUTE6 => r_WPT.INFORMATION116
10757 ,P_WPT_ATTRIBUTE7 => r_WPT.INFORMATION117
10758 ,P_WPT_ATTRIBUTE8 => r_WPT.INFORMATION118
10759 ,P_WPT_ATTRIBUTE9 => r_WPT.INFORMATION119
10760 ,P_WPT_ATTRIBUTE_CATEGORY => r_WPT.INFORMATION110
10761 ,P_WV_PRTN_RSN_CD => r_WPT.INFORMATION12
10762 ,P_WV_PRTN_RSN_PTIP_ID => l_wv_prtn_rsn_ptip_id
10763 --
10764 ,P_EFFECTIVE_START_DATE => l_effective_start_date
10765 ,P_EFFECTIVE_END_DATE => l_effective_end_date
10766 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
10767 );
10768 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
10769 -- Update all relevent cer records with new pk_id
10770 hr_utility.set_location('Before plsql table ',222);
10771 hr_utility.set_location('new_value id '||l_wv_prtn_rsn_ptip_id,222);
10772 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'WV_PRTN_RSN_PTIP_ID' ;
10773 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_WPT.information1 ;
10774 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_WV_PRTN_RSN_PTIP_ID ;
10775 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
10776 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_WPT_unique.table_route_id;
10777 hr_utility.set_location('After plsql table ',222);
10778 --
10779 -- 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 ) ;
10780 --
10781 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10782 --
10783 else
10784 --
10785 -- Call Update routine for the pk_id created in prev run .
10786 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
10787 hr_utility.set_location(' BEN_WV_PRTN_RSN_PTIP_F UPDATE_WV_PRTN_RSN_PTIP ',30);
10788 --UPD START
10789 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
10790 --
10791 if l_update then
10792 --
10793 l_datetrack_mode := r_WPT.datetrack_mode ;
10794 --
10795 get_dt_modes(
10796 p_effective_date => l_process_date,
10797 p_effective_end_date => r_WPT.information3,
10798 p_effective_start_date => r_WPT.information2,
10799 p_dml_operation => r_WPT.dml_operation,
10800 p_datetrack_mode => l_datetrack_mode );
10801 -- p_update => l_update
10802 --
10803 l_effective_date := l_process_date;
10804 l_WV_PRTN_RSN_PTIP_ID := r_WPT.information1;
10805 l_object_version_number := r_WPT.information265;
10806 --
10807 end if;
10808 --
10809 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
10810 --
10811 IF l_update OR l_dml_operation <> 'UPDATE' THEN
10812 --UPD END
10813
10814 BEN_WV_PRTN_RSN_PTIP_API.UPDATE_WV_PRTN_RSN_PTIP(
10815 --
10816 P_VALIDATE => false
10817 ,P_EFFECTIVE_DATE => l_effective_date
10818 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
10819 --
10820 ,P_DFLT_FLAG => r_WPT.INFORMATION11
10821 ,P_PTIP_ID => l_PTIP_ID
10822 ,P_WPT_ATTRIBUTE1 => r_WPT.INFORMATION111
10823 ,P_WPT_ATTRIBUTE10 => r_WPT.INFORMATION120
10824 ,P_WPT_ATTRIBUTE11 => r_WPT.INFORMATION121
10825 ,P_WPT_ATTRIBUTE12 => r_WPT.INFORMATION122
10826 ,P_WPT_ATTRIBUTE13 => r_WPT.INFORMATION123
10827 ,P_WPT_ATTRIBUTE14 => r_WPT.INFORMATION124
10828 ,P_WPT_ATTRIBUTE15 => r_WPT.INFORMATION125
10829 ,P_WPT_ATTRIBUTE16 => r_WPT.INFORMATION126
10830 ,P_WPT_ATTRIBUTE17 => r_WPT.INFORMATION127
10831 ,P_WPT_ATTRIBUTE18 => r_WPT.INFORMATION128
10832 ,P_WPT_ATTRIBUTE19 => r_WPT.INFORMATION129
10833 ,P_WPT_ATTRIBUTE2 => r_WPT.INFORMATION112
10834 ,P_WPT_ATTRIBUTE20 => r_WPT.INFORMATION130
10835 ,P_WPT_ATTRIBUTE21 => r_WPT.INFORMATION131
10836 ,P_WPT_ATTRIBUTE22 => r_WPT.INFORMATION132
10837 ,P_WPT_ATTRIBUTE23 => r_WPT.INFORMATION133
10838 ,P_WPT_ATTRIBUTE24 => r_WPT.INFORMATION134
10839 ,P_WPT_ATTRIBUTE25 => r_WPT.INFORMATION135
10840 ,P_WPT_ATTRIBUTE26 => r_WPT.INFORMATION136
10841 ,P_WPT_ATTRIBUTE27 => r_WPT.INFORMATION137
10842 ,P_WPT_ATTRIBUTE28 => r_WPT.INFORMATION138
10843 ,P_WPT_ATTRIBUTE29 => r_WPT.INFORMATION139
10844 ,P_WPT_ATTRIBUTE3 => r_WPT.INFORMATION113
10845 ,P_WPT_ATTRIBUTE30 => r_WPT.INFORMATION140
10846 ,P_WPT_ATTRIBUTE4 => r_WPT.INFORMATION114
10847 ,P_WPT_ATTRIBUTE5 => r_WPT.INFORMATION115
10848 ,P_WPT_ATTRIBUTE6 => r_WPT.INFORMATION116
10849 ,P_WPT_ATTRIBUTE7 => r_WPT.INFORMATION117
10850 ,P_WPT_ATTRIBUTE8 => r_WPT.INFORMATION118
10851 ,P_WPT_ATTRIBUTE9 => r_WPT.INFORMATION119
10852 ,P_WPT_ATTRIBUTE_CATEGORY => r_WPT.INFORMATION110
10853 ,P_WV_PRTN_RSN_CD => r_WPT.INFORMATION12
10854 ,P_WV_PRTN_RSN_PTIP_ID => l_wv_prtn_rsn_ptip_id
10855 --
10856 ,P_EFFECTIVE_START_DATE => l_effective_start_date
10857 ,P_EFFECTIVE_END_DATE => l_effective_end_date
10858 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
10859 ,P_DATETRACK_MODE => l_datetrack_mode
10860 );
10861 --
10862 end if; -- l_update
10863 end if;
10864 --
10865 -- Delete the row if it is end dated.
10866 --
10867 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
10868 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
10869 trunc(l_max_eed) = r_WPT.information3) then
10870 --
10871 BEN_WV_PRTN_RSN_PTIP_API.delete_WV_PRTN_RSN_PTIP(
10872 --
10873 p_validate => false
10874 ,p_wv_prtn_rsn_ptip_id => l_wv_prtn_rsn_ptip_id
10875 ,p_effective_start_date => l_effective_start_date
10876 ,p_effective_end_date => l_effective_end_date
10877 ,p_object_version_number => l_object_version_number
10878 ,p_effective_date => l_max_eed
10879 ,p_datetrack_mode => hr_api.g_delete
10880 --
10881 );
10882 --
10883 end if;
10884 --
10885 l_prev_pk_id := l_current_pk_id ;
10886 --
10887 end if;
10888 --
10889 end if;
10890 --
10891 end loop;
10892 --
10893 exception when others then
10894 --
10895 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'WPT',r_wpt.information5 );
10896 --
10897 end create_WPT_rows;
10898
10899 --
10900 ---------------------------------------------------------------
10901 ----------------------< create_CTP_rows >-----------------------
10902 ---------------------------------------------------------------
10903 --
10904 procedure create_CTP_rows
10905 (
10906 p_validate in number default 0
10907 ,p_copy_entity_txn_id in number
10908 ,p_effective_date in date
10909 ,p_prefix_suffix_text in varchar2 default null
10910 ,p_reuse_object_flag in varchar2 default null
10911 ,p_target_business_group_id in varchar2 default null
10912 ,p_prefix_suffix_cd in varchar2 default null
10913 ) is
10914 --
10915 l_ACRS_PTIP_CVG_ID number;
10916 l_AUTO_ENRT_MTHD_RL number;
10917 l_CMBN_PTIP_ID number;
10918 l_CMBN_PTIP_OPT_ID number;
10919 l_DFLT_ENRT_DET_RL number;
10920 l_DPNT_CVG_END_DT_RL number;
10921 l_DPNT_CVG_STRT_DT_RL number;
10922 l_ENRT_CVG_END_DT_RL number;
10923 l_ENRT_CVG_STRT_DT_RL number;
10924 l_ENRT_RL number;
10925 l_PGM_ID number;
10926 l_PL_TYP_ID number;
10927 l_POSTELCN_EDIT_RL number;
10928 l_RQD_PERD_ENRT_NENRT_RL number;
10929 l_RT_END_DT_RL number;
10930 l_RT_STRT_DT_RL number;
10931 l_VRFY_FMLY_MMBR_RL number;
10932 cursor c_unique_CTP(l_table_alias varchar2) is
10933 select distinct cpe.information1,
10934 cpe.information2,
10935 cpe.information3,
10936 cpe.table_route_id
10937 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
10938 pqh_table_route tr
10939 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10940 and cpe.table_route_id = tr.table_route_id
10941 -- and tr.where_clause = l_BEN_PTIP_F
10942 and tr.table_alias = l_table_alias
10943 and cpe.number_of_copies = 1 -- ADDITION
10944 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
10945 order by information1, information2; --added for bug: 5151945
10946 --
10947 --
10948 cursor c_CTP_min_max_dates(c_table_route_id number,
10949 c_information1 number) is
10950 select
10951 min(cpe.information2) min_esd,
10952 max(cpe.information3) min_eed
10953 from ben_copy_entity_results cpe
10954 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10955 and cpe.table_route_id = c_table_route_id
10956 and cpe.information1 = c_information1 ;
10957 --
10958 cursor c_CTP(c_table_route_id number,
10959 c_information1 number,
10960 c_information2 date,
10961 c_information3 date ) is
10962 select
10963 cpe.*
10964 from ben_copy_entity_results cpe
10965 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10966 and cpe.table_route_id = c_table_route_id
10967 and cpe.information1 = c_information1
10968 and cpe.information2 = c_information2
10969 and cpe.information3 = c_information3
10970 and rownum = 1 ;
10971 -- Date Track target record
10972 cursor c_find_CTP_in_target(
10973 c_effective_start_date date,
10974 c_effective_end_date date,
10975 c_business_group_id number,
10976 c_new_pk_id number) is
10977 select
10978 CTP.ptip_id new_value
10979 from BEN_PTIP_F CTP
10980 where
10981 --nvl(CTP.ACRS_PTIP_CVG_ID,-999) = nvl(l_ACRS_PTIP_CVG_ID,-999) and
10982 --nvl(CTP.CMBN_PTIP_ID,-999) = nvl(l_CMBN_PTIP_ID,-999) and
10983 --nvl(CTP.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999) and
10984 CTP.PGM_ID = l_PGM_ID and
10985 CTP.PL_TYP_ID = l_PL_TYP_ID and
10986 CTP.business_group_id = c_business_group_id
10987 and CTP.ptip_id <> c_new_pk_id
10988 --TEMPIK
10989 and c_effective_start_date between effective_start_date
10990 and effective_end_date ;
10991 --END TEMPIK
10992 /*TEMPIK
10993 and exists ( select null
10994 from BEN_PTIP_F CTP1
10995 where
10996 --nvl(CTP1.ACRS_PTIP_CVG_ID,-999) = nvl(l_ACRS_PTIP_CVG_ID,-999) and
10997 --nvl(CTP1.CMBN_PTIP_ID,-999) = nvl(l_CMBN_PTIP_ID,-999) and
10998 --nvl(CTP1.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999) and
10999 CTP1.PGM_ID = l_PGM_ID and
11000 CTP1.PL_TYP_ID = l_PL_TYP_ID and
11001 CTP1.business_group_id = c_business_group_id
11002 and CTP1.effective_start_date <= c_effective_start_date )
11003 and exists ( select null
11004 from BEN_PTIP_F CTP2
11005 where
11006 --nvl(CTP2.ACRS_PTIP_CVG_ID,-999) = nvl(l_ACRS_PTIP_CVG_ID,-999) and
11007 --nvl(CTP2.CMBN_PTIP_ID,-999) = nvl(l_CMBN_PTIP_ID,-999) and
11008 --nvl(CTP2.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999) and
11009 CTP2.PGM_ID = l_PGM_ID and
11010 CTP2.PL_TYP_ID = l_PL_TYP_ID and
11011 CTP2.business_group_id = c_business_group_id
11012 and CTP2.effective_end_date >= c_effective_end_date )
11013 ;
11014 TEMPIK */
11015 --TEMPIK
11016 l_dt_rec_found boolean ;
11017 --END TEMPIK
11018 --
11019 --UPD START
11020 --
11021 l_update boolean := false ;
11022 l_datetrack_mode varchar2(80) := hr_api.g_update;
11023 l_process_date date;
11024 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
11025 --
11026 --UPD END
11027 l_current_pk_id number := null ;
11028 l_prev_pk_id number := null ;
11029 l_first_rec boolean := true ;
11030 r_CTP c_CTP%rowtype;
11031 l_ptip_id number ;
11032 l_object_version_number number ;
11033 l_effective_start_date date ;
11034 l_effective_end_date date ;
11035 l_prefix pqh_copy_entity_attribs.information1%type := null;
11036 l_suffix pqh_copy_entity_attribs.information1%type := null;
11037 l_new_value number(15);
11038 l_object_found_in_target boolean := false ;
11039 l_min_esd date;
11040 l_max_eed date;
11041 l_effective_date date;
11042 --
11043 l_susp_if_dpnt_ssn_nt_prv_cd ben_ptip_f.susp_if_dpnt_ssn_nt_prv_cd%type;
11044 l_susp_if_dpnt_dob_nt_prv_cd ben_ptip_f.susp_if_dpnt_dob_nt_prv_cd%type;
11045 l_susp_if_dpnt_adr_nt_prv_cd ben_ptip_f.susp_if_dpnt_adr_nt_prv_cd%type;
11046 --
11047 begin
11048 -- Initialization
11049 l_object_found_in_target := false ;
11050 -- End Initialization
11051 -- Derive the prefix - sufix
11052 if p_prefix_suffix_cd = 'PREFIX' then
11053 l_prefix := p_prefix_suffix_text ;
11054 elsif p_prefix_suffix_cd = 'SUFFIX' then
11055 l_suffix := p_prefix_suffix_text ;
11056 else
11057 l_prefix := null ;
11058 l_suffix := null ;
11059 end if ;
11060 -- End Prefix Sufix derivation
11061 for r_CTP_unique in c_unique_CTP('CTP') loop
11062
11063 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
11064 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11065 r_CTP_unique.information3 >=
11066 ben_pd_copy_to_ben_one.g_copy_effective_date)
11067 ) then
11068 --
11069 hr_utility.set_location(' r_CTP_unique.table_route_id '||r_CTP_unique.table_route_id,10);
11070 hr_utility.set_location(' r_CTP_unique.information1 '||r_CTP_unique.information1,10);
11071 hr_utility.set_location( 'r_CTP_unique.information2 '||r_CTP_unique.information2,10);
11072 hr_utility.set_location( 'r_CTP_unique.information3 '||r_CTP_unique.information3,10);
11073 -- If reuse objects flag is 'Y' then check for the object in the target business group
11074 -- if found insert the record into PLSql table and exit the loop else try create the
11075 -- object in the target business group
11076 --
11077 l_object_found_in_target := false ;
11078 --UPD START
11079 open c_CTP(r_CTP_unique.table_route_id,
11080 r_CTP_unique.information1,
11081 r_CTP_unique.information2,
11082 r_CTP_unique.information3 ) ;
11083 --
11084 fetch c_CTP into r_CTP ;
11085 --
11086 close c_CTP ;
11087 --
11088 l_dml_operation:= r_CTP_unique.dml_operation ;
11089 l_ACRS_PTIP_CVG_ID := get_fk('ACRS_PTIP_CVG_ID', r_CTP.INFORMATION274,l_dml_operation);
11090 l_AUTO_ENRT_MTHD_RL := get_fk('FORMULA_ID', r_CTP.INFORMATION275,l_dml_operation);
11091 l_CMBN_PTIP_ID := get_fk('CMBN_PTIP_ID', r_CTP.INFORMATION236,l_dml_operation);
11092 l_CMBN_PTIP_OPT_ID := get_fk('CMBN_PTIP_OPT_ID', r_CTP.INFORMATION249,l_dml_operation);
11093 l_DFLT_ENRT_DET_RL := get_fk('FORMULA_ID', r_CTP.INFORMATION277,l_dml_operation);
11094 l_DPNT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_CTP.INFORMATION263,l_dml_operation);
11095 l_DPNT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_CTP.INFORMATION262,l_dml_operation);
11096 l_ENRT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_CTP.INFORMATION271,l_dml_operation);
11097 l_ENRT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_CTP.INFORMATION270,l_dml_operation);
11098 l_ENRT_RL := get_fk('FORMULA_ID', r_CTP.INFORMATION276,l_dml_operation);
11099 l_PGM_ID := get_fk('PGM_ID', r_CTP.INFORMATION260,l_dml_operation);
11100 l_PL_TYP_ID := get_fk('PL_TYP_ID', r_CTP.INFORMATION248,l_dml_operation);
11101 l_POSTELCN_EDIT_RL := get_fk('FORMULA_ID', r_CTP.INFORMATION264,l_dml_operation);
11102 l_RQD_PERD_ENRT_NENRT_RL := get_fk('FORMULA_ID', r_CTP.INFORMATION269,l_dml_operation);
11103 l_RT_END_DT_RL := get_fk('FORMULA_ID', r_CTP.INFORMATION273,l_dml_operation);
11104 l_RT_STRT_DT_RL := get_fk('FORMULA_ID', r_CTP.INFORMATION272,l_dml_operation);
11105 l_VRFY_FMLY_MMBR_RL := get_fk('FORMULA_ID', r_CTP.INFORMATION278,l_dml_operation);
11106 --
11107 l_update := false;
11108 l_process_date := p_effective_date;
11109 --
11110 if l_dml_operation = 'UPDATE' then
11111 --
11112 l_object_found_in_target := TRUE;
11113 --
11114 if l_process_date between r_CTP_unique.information2 and r_CTP_unique.information3 then
11115 l_update := true;
11116 if r_CTP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
11117 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PTIP_ID'
11118 then
11119 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PTIP_ID' ;
11120 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CTP_unique.information1 ;
11121 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_CTP_unique.information1 ;
11122 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
11123 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CTP_unique.table_route_id;
11124 --
11125 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
11126 --
11127 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
11128 --
11129 --DOUBT log_data('CTP',l_new_value,l_prefix || r_CTP_unique.name|| l_suffix,'REUSED');
11130 --
11131 end if ;
11132 hr_utility.set_location( 'found record for update',10);
11133 --
11134 else
11135 --
11136 l_update := false;
11137 --
11138 end if;
11139 else
11140 --
11141 --UPD END
11142
11143 l_min_esd := null ;
11144 l_max_eed := null ;
11145 open c_CTP_min_max_dates(r_CTP_unique.table_route_id, r_CTP_unique.information1 ) ;
11146 fetch c_CTP_min_max_dates into l_min_esd,l_max_eed ;
11147 --
11148
11149 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11150 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
11151 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
11152 end if;
11153 l_min_esd := greatest(l_min_esd,r_CTP_unique.information2);
11154 /* open c_CTP(r_CTP_unique.table_route_id,
11155 r_CTP_unique.information1,
11156 r_CTP_unique.information2,
11157 r_CTP_unique.information3 ) ;
11158 --
11159 fetch c_CTP into r_CTP ;
11160 --
11161 close c_CTP ;
11162 -- moved get_fk's to top
11163 */
11164 if p_reuse_object_flag = 'Y' then
11165 if c_CTP_min_max_dates%found then
11166 -- cursor to find the object
11167 open c_find_CTP_in_target( l_min_esd,l_max_eed,
11168 p_target_business_group_id, nvl(l_ptip_id, -999) ) ;
11169 fetch c_find_CTP_in_target into l_new_value ;
11170 if c_find_CTP_in_target%found then
11171 --
11172 --TEMPIK
11173 l_dt_rec_found := dt_api.check_min_max_dates
11174 (p_base_table_name => 'BEN_PTIP_F',
11175 p_base_key_column => 'PTIP_ID',
11176 p_base_key_value => l_new_value,
11177 p_from_date => l_min_esd,
11178 p_to_date => l_max_eed );
11179 if l_dt_rec_found THEN
11180 --END TEMPIK
11181 if r_CTP_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
11182 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PTIP_ID' then
11183 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PTIP_ID' ;
11184 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CTP_unique.information1 ;
11185 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
11186 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
11187 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CTP_unique.table_route_id;
11188 --
11189 -- 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) ;
11190 --
11191 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
11192 end if ;
11193 --
11194 l_object_found_in_target := true ;
11195
11196 --TEMPIK
11197 end if; -- l_dt_rec_found
11198 --END TEMPIK
11199 end if;
11200 close c_find_CTP_in_target ;
11201 --
11202 end if;
11203 end if ;
11204 --
11205 close c_CTP_min_max_dates ;
11206 end if; --if p_dml_operation
11207 --
11208 if not l_object_found_in_target OR l_update then
11209 --
11210 l_current_pk_id := r_CTP.information1;
11211 --
11212 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
11213 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
11214 --
11215 if l_current_pk_id = l_prev_pk_id then
11216 --
11217 l_first_rec := false ;
11218 --
11219 else
11220 --
11221 l_first_rec := true ;
11222 --
11223 end if ;
11224 --
11225
11226 l_effective_date := r_CTP.information2;
11227 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11228 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
11229 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
11230 end if;
11231
11232 --ML
11233 if r_CTP.INFORMATION18 = 'Y' and r_CTP.INFORMATION196 is null then
11234 l_susp_if_dpnt_ssn_nt_prv_cd := 'RQDS';
11235 else
11236 l_susp_if_dpnt_ssn_nt_prv_cd := r_CTP.INFORMATION196;
11237 end if;
11238 --
11239 if r_CTP.INFORMATION19 = 'Y' and r_ctp.INFORMATION190 is null then
11240 l_susp_if_dpnt_dob_nt_prv_cd := 'RQDS';
11241 else
11242 l_susp_if_dpnt_dob_nt_prv_cd := r_ctp.INFORMATION190;
11243 end if;
11244 --
11245 if r_CTP.INFORMATION17 = 'Y' and r_ctp.INFORMATION191 is null then
11246 l_susp_if_dpnt_adr_nt_prv_cd := 'RQDS';
11247 else
11248 l_susp_if_dpnt_adr_nt_prv_cd := r_ctp.INFORMATION191;
11249 end if;
11250 --
11251 if l_first_rec and not l_update then
11252 -- Call Create routine.
11253
11254 BEN_PLAN_TYPE_IN_PROGRAM_API.CREATE_PLAN_TYPE_IN_PROGRAM(
11255 --
11256 P_VALIDATE => false
11257 ,P_EFFECTIVE_DATE => l_effective_date
11258 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11259 --
11260 ,P_ACRS_PTIP_CVG_ID => l_ACRS_PTIP_CVG_ID
11261 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
11262 ,P_CMBN_PTIP_ID => l_CMBN_PTIP_ID
11263 ,P_CMBN_PTIP_OPT_ID => l_CMBN_PTIP_OPT_ID
11264 ,P_COORD_CVG_FOR_ALL_PLS_FLAG => r_CTP.INFORMATION15
11265 ,P_CRS_THIS_PL_TYP_ONLY_FLAG => r_CTP.INFORMATION20
11266 ,P_CTP_ATTRIBUTE1 => r_CTP.INFORMATION111
11267 ,P_CTP_ATTRIBUTE10 => r_CTP.INFORMATION120
11268 ,P_CTP_ATTRIBUTE11 => r_CTP.INFORMATION121
11269 ,P_CTP_ATTRIBUTE12 => r_CTP.INFORMATION122
11270 ,P_CTP_ATTRIBUTE13 => r_CTP.INFORMATION123
11271 ,P_CTP_ATTRIBUTE14 => r_CTP.INFORMATION124
11272 ,P_CTP_ATTRIBUTE15 => r_CTP.INFORMATION125
11273 ,P_CTP_ATTRIBUTE16 => r_CTP.INFORMATION126
11274 ,P_CTP_ATTRIBUTE17 => r_CTP.INFORMATION127
11275 ,P_CTP_ATTRIBUTE18 => r_CTP.INFORMATION128
11276 ,P_CTP_ATTRIBUTE19 => r_CTP.INFORMATION129
11277 ,P_CTP_ATTRIBUTE2 => r_CTP.INFORMATION112
11278 ,P_CTP_ATTRIBUTE20 => r_CTP.INFORMATION130
11279 ,P_CTP_ATTRIBUTE21 => r_CTP.INFORMATION131
11280 ,P_CTP_ATTRIBUTE22 => r_CTP.INFORMATION132
11281 ,P_CTP_ATTRIBUTE23 => r_CTP.INFORMATION133
11282 ,P_CTP_ATTRIBUTE24 => r_CTP.INFORMATION134
11283 ,P_CTP_ATTRIBUTE25 => r_CTP.INFORMATION135
11284 ,P_CTP_ATTRIBUTE26 => r_CTP.INFORMATION136
11285 ,P_CTP_ATTRIBUTE27 => r_CTP.INFORMATION137
11286 ,P_CTP_ATTRIBUTE28 => r_CTP.INFORMATION138
11287 ,P_CTP_ATTRIBUTE29 => r_CTP.INFORMATION139
11288 ,P_CTP_ATTRIBUTE3 => r_CTP.INFORMATION113
11289 ,P_CTP_ATTRIBUTE30 => r_CTP.INFORMATION140
11290 ,P_CTP_ATTRIBUTE4 => r_CTP.INFORMATION114
11291 ,P_CTP_ATTRIBUTE5 => r_CTP.INFORMATION115
11292 ,P_CTP_ATTRIBUTE6 => r_CTP.INFORMATION116
11293 ,P_CTP_ATTRIBUTE7 => r_CTP.INFORMATION117
11294 ,P_CTP_ATTRIBUTE8 => r_CTP.INFORMATION118
11295 ,P_CTP_ATTRIBUTE9 => r_CTP.INFORMATION119
11296 ,P_CTP_ATTRIBUTE_CATEGORY => r_CTP.INFORMATION110
11297 ,P_DFLT_ENRT_CD => r_CTP.INFORMATION45
11298 ,P_DFLT_ENRT_DET_RL => l_DFLT_ENRT_DET_RL
11299 ,P_DPNT_ADRS_RQD_FLAG => r_CTP.INFORMATION17
11300 ,P_DPNT_CVG_END_DT_CD => r_CTP.INFORMATION36
11301 ,P_DPNT_CVG_END_DT_RL => l_DPNT_CVG_END_DT_RL
11302 ,P_DPNT_CVG_NO_CTFN_RQD_FLAG => r_CTP.INFORMATION16
11303 ,P_DPNT_CVG_STRT_DT_CD => r_CTP.INFORMATION35
11304 ,P_DPNT_CVG_STRT_DT_RL => l_DPNT_CVG_STRT_DT_RL
11305 ,P_DPNT_DOB_RQD_FLAG => r_CTP.INFORMATION19
11306 ,P_DPNT_DSGN_CD => r_CTP.INFORMATION34
11307 ,P_DPNT_LEGV_ID_RQD_FLAG => r_CTP.INFORMATION18
11308 ,P_DRVBL_FCTR_APLS_RTS_FLAG => r_CTP.INFORMATION29
11309 ,P_DRVBL_FCTR_PRTN_ELIG_FLAG => r_CTP.INFORMATION30
11310 ,P_DRVD_FCTR_DPNT_CVG_FLAG => r_CTP.INFORMATION24
11311 ,P_ELIG_APLS_FLAG => r_CTP.INFORMATION31
11312 ,P_ENRT_CD => r_CTP.INFORMATION44
11313 ,P_ENRT_CVG_END_DT_CD => r_CTP.INFORMATION40
11314 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
11315 ,P_ENRT_CVG_STRT_DT_CD => r_CTP.INFORMATION39
11316 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
11317 ,P_ENRT_MTHD_CD => r_CTP.INFORMATION43
11318 ,P_ENRT_RL => l_ENRT_RL
11319 ,P_IVR_IDENT => r_CTP.INFORMATION141
11320 ,P_MN_ENRD_RQD_OVRID_NUM => r_CTP.INFORMATION266
11321 ,P_MX_CVG_ALWD_AMT => r_CTP.INFORMATION293
11322 ,P_MX_ENRD_ALWD_OVRID_NUM => r_CTP.INFORMATION267
11323 ,P_NO_MN_PL_TYP_OVERID_FLAG => r_CTP.INFORMATION25
11324 ,P_NO_MX_PL_TYP_OVRID_FLAG => r_CTP.INFORMATION21
11325 ,P_ORDR_NUM => r_CTP.INFORMATION268
11326 ,P_PER_CVRD_CD => r_CTP.INFORMATION11
11327 ,P_PGM_ID => l_PGM_ID
11328 ,P_PL_TYP_ID => l_PL_TYP_ID
11329 ,P_POSTELCN_EDIT_RL => l_POSTELCN_EDIT_RL
11330 ,P_PRTN_ELIG_OVRID_ALWD_FLAG => r_CTP.INFORMATION32
11331 ,P_PRVDS_CR_FLAG => r_CTP.INFORMATION22
11332 ,P_PTIP_ID => l_ptip_id
11333 ,P_PTIP_STAT_CD => r_CTP.INFORMATION14
11334 ,P_RQD_ENRT_PERD_TCO_CD => r_CTP.INFORMATION38
11335 ,P_RQD_PERD_ENRT_NENRT_RL => l_RQD_PERD_ENRT_NENRT_RL
11336 ,P_RQD_PERD_ENRT_NENRT_TM_UOM => r_CTP.INFORMATION37
11337 ,P_RQD_PERD_ENRT_NENRT_VAL => r_CTP.INFORMATION287
11338 ,P_RT_END_DT_CD => r_CTP.INFORMATION42
11339 ,P_RT_END_DT_RL => l_RT_END_DT_RL
11340 ,P_RT_STRT_DT_CD => r_CTP.INFORMATION41
11341 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
11342 ,P_SBJ_TO_DPNT_LF_INS_MX_FLAG => r_CTP.INFORMATION27
11343 ,P_SBJ_TO_SPS_LF_INS_MX_FLAG => r_CTP.INFORMATION26
11344 ,P_SHORT_CODE => r_CTP.INFORMATION12
11345 ,P_SHORT_NAME => r_CTP.INFORMATION13
11346 ,P_TRK_INELIG_PER_FLAG => r_CTP.INFORMATION33
11347 ,P_URL_REF_NAME => r_CTP.INFORMATION185
11348 ,P_USE_TO_SUM_EE_LF_INS_FLAG => r_CTP.INFORMATION28
11349 ,P_VRFY_FMLY_MMBR_CD => r_CTP.INFORMATION46
11350 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
11351 ,P_WVBL_FLAG => r_CTP.INFORMATION23
11352 --ML
11353 ,p_SUSP_IF_DPNT_SSN_NT_PRV_CD => l_susp_if_dpnt_ssn_nt_prv_cd
11354 ,p_SUSP_IF_DPNT_DOB_NT_PRV_CD => l_susp_if_dpnt_dob_nt_prv_cd
11355 ,p_SUSP_IF_DPNT_ADR_NT_PRV_CD => l_susp_if_dpnt_adr_nt_prv_cd
11356 ,p_SUSP_IF_CTFN_NOT_DPNT_FLAG => nvl(r_CTP.INFORMATION192,'Y')
11357 ,p_DPNT_CTFN_DETERMINE_CD => r_CTP.INFORMATION193
11358 --
11359 ,P_EFFECTIVE_START_DATE => l_effective_start_date
11360 ,P_EFFECTIVE_END_DATE => l_effective_end_date
11361 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11362 );
11363 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11364 -- Update all relevent cer records with new pk_id
11365 hr_utility.set_location('Before plsql table ',222);
11366 hr_utility.set_location('new_value id '||l_ptip_id,222);
11367 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PTIP_ID' ;
11368 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CTP.information1 ;
11369 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PTIP_ID ;
11370 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
11371 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CTP_unique.table_route_id;
11372 hr_utility.set_location('After plsql table ',222);
11373 --
11374 -- 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 ) ;
11375 --
11376 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
11377 --
11378 else
11379 --
11380 -- Call Update routine for the pk_id created in prev run .
11381 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11382 hr_utility.set_location(' BEN_PTIP_F UPDATE_PLAN_TYPE_IN_PROGRAM ',30);
11383 --UPD START
11384 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
11385 --
11386 if l_update then
11387 --
11388 l_datetrack_mode := r_CTP.datetrack_mode ;
11389 --
11390 get_dt_modes(
11391 p_effective_date => l_process_date,
11392 p_effective_end_date => r_CTP.information3,
11393 p_effective_start_date => r_CTP.information2,
11394 p_dml_operation => r_CTP.dml_operation,
11395 p_datetrack_mode => l_datetrack_mode );
11396 -- p_update => l_update
11397 --
11398 l_effective_date := l_process_date;
11399 l_PTIP_ID := r_CTP.information1;
11400 l_object_version_number := r_CTP.information265;
11401 --
11402 end if;
11403 --
11404 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
11405 --
11406 IF l_update OR l_dml_operation <> 'UPDATE' THEN
11407 --UPD END
11408
11409 BEN_PLAN_TYPE_IN_PROGRAM_API.UPDATE_PLAN_TYPE_IN_PROGRAM(
11410 --
11411 P_VALIDATE => false
11412 ,P_EFFECTIVE_DATE => l_effective_date
11413 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11414 --
11415 ,P_ACRS_PTIP_CVG_ID => l_ACRS_PTIP_CVG_ID
11416 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
11417 ,P_CMBN_PTIP_ID => l_CMBN_PTIP_ID
11418 ,P_CMBN_PTIP_OPT_ID => l_CMBN_PTIP_OPT_ID
11419 ,P_COORD_CVG_FOR_ALL_PLS_FLAG => r_CTP.INFORMATION15
11420 ,P_CRS_THIS_PL_TYP_ONLY_FLAG => r_CTP.INFORMATION20
11421 ,P_CTP_ATTRIBUTE1 => r_CTP.INFORMATION111
11422 ,P_CTP_ATTRIBUTE10 => r_CTP.INFORMATION120
11423 ,P_CTP_ATTRIBUTE11 => r_CTP.INFORMATION121
11424 ,P_CTP_ATTRIBUTE12 => r_CTP.INFORMATION122
11425 ,P_CTP_ATTRIBUTE13 => r_CTP.INFORMATION123
11426 ,P_CTP_ATTRIBUTE14 => r_CTP.INFORMATION124
11427 ,P_CTP_ATTRIBUTE15 => r_CTP.INFORMATION125
11428 ,P_CTP_ATTRIBUTE16 => r_CTP.INFORMATION126
11429 ,P_CTP_ATTRIBUTE17 => r_CTP.INFORMATION127
11430 ,P_CTP_ATTRIBUTE18 => r_CTP.INFORMATION128
11431 ,P_CTP_ATTRIBUTE19 => r_CTP.INFORMATION129
11432 ,P_CTP_ATTRIBUTE2 => r_CTP.INFORMATION112
11433 ,P_CTP_ATTRIBUTE20 => r_CTP.INFORMATION130
11434 ,P_CTP_ATTRIBUTE21 => r_CTP.INFORMATION131
11435 ,P_CTP_ATTRIBUTE22 => r_CTP.INFORMATION132
11436 ,P_CTP_ATTRIBUTE23 => r_CTP.INFORMATION133
11437 ,P_CTP_ATTRIBUTE24 => r_CTP.INFORMATION134
11438 ,P_CTP_ATTRIBUTE25 => r_CTP.INFORMATION135
11439 ,P_CTP_ATTRIBUTE26 => r_CTP.INFORMATION136
11440 ,P_CTP_ATTRIBUTE27 => r_CTP.INFORMATION137
11441 ,P_CTP_ATTRIBUTE28 => r_CTP.INFORMATION138
11442 ,P_CTP_ATTRIBUTE29 => r_CTP.INFORMATION139
11443 ,P_CTP_ATTRIBUTE3 => r_CTP.INFORMATION113
11444 ,P_CTP_ATTRIBUTE30 => r_CTP.INFORMATION140
11445 ,P_CTP_ATTRIBUTE4 => r_CTP.INFORMATION114
11446 ,P_CTP_ATTRIBUTE5 => r_CTP.INFORMATION115
11447 ,P_CTP_ATTRIBUTE6 => r_CTP.INFORMATION116
11448 ,P_CTP_ATTRIBUTE7 => r_CTP.INFORMATION117
11449 ,P_CTP_ATTRIBUTE8 => r_CTP.INFORMATION118
11450 ,P_CTP_ATTRIBUTE9 => r_CTP.INFORMATION119
11451 ,P_CTP_ATTRIBUTE_CATEGORY => r_CTP.INFORMATION110
11452 ,P_DFLT_ENRT_CD => r_CTP.INFORMATION45
11453 ,P_DFLT_ENRT_DET_RL => l_DFLT_ENRT_DET_RL
11454 ,P_DPNT_ADRS_RQD_FLAG => r_CTP.INFORMATION17
11455 ,P_DPNT_CVG_END_DT_CD => r_CTP.INFORMATION36
11456 ,P_DPNT_CVG_END_DT_RL => l_DPNT_CVG_END_DT_RL
11457 ,P_DPNT_CVG_NO_CTFN_RQD_FLAG => r_CTP.INFORMATION16
11458 ,P_DPNT_CVG_STRT_DT_CD => r_CTP.INFORMATION35
11459 ,P_DPNT_CVG_STRT_DT_RL => l_DPNT_CVG_STRT_DT_RL
11460 ,P_DPNT_DOB_RQD_FLAG => r_CTP.INFORMATION19
11461 ,P_DPNT_DSGN_CD => r_CTP.INFORMATION34
11462 ,P_DPNT_LEGV_ID_RQD_FLAG => r_CTP.INFORMATION18
11463 ,P_DRVBL_FCTR_APLS_RTS_FLAG => r_CTP.INFORMATION29
11464 ,P_DRVBL_FCTR_PRTN_ELIG_FLAG => r_CTP.INFORMATION30
11465 ,P_DRVD_FCTR_DPNT_CVG_FLAG => r_CTP.INFORMATION24
11466 ,P_ELIG_APLS_FLAG => r_CTP.INFORMATION31
11467 ,P_ENRT_CD => r_CTP.INFORMATION44
11468 ,P_ENRT_CVG_END_DT_CD => r_CTP.INFORMATION40
11469 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
11470 ,P_ENRT_CVG_STRT_DT_CD => r_CTP.INFORMATION39
11471 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
11472 ,P_ENRT_MTHD_CD => r_CTP.INFORMATION43
11473 ,P_ENRT_RL => l_ENRT_RL
11474 ,P_IVR_IDENT => r_CTP.INFORMATION141
11475 ,P_MN_ENRD_RQD_OVRID_NUM => r_CTP.INFORMATION266
11476 ,P_MX_CVG_ALWD_AMT => r_CTP.INFORMATION293
11477 ,P_MX_ENRD_ALWD_OVRID_NUM => r_CTP.INFORMATION267
11478 ,P_NO_MN_PL_TYP_OVERID_FLAG => r_CTP.INFORMATION25
11479 ,P_NO_MX_PL_TYP_OVRID_FLAG => r_CTP.INFORMATION21
11480 ,P_ORDR_NUM => r_CTP.INFORMATION268
11481 ,P_PER_CVRD_CD => r_CTP.INFORMATION11
11482 ,P_PGM_ID => l_PGM_ID
11483 ,P_PL_TYP_ID => l_PL_TYP_ID
11484 ,P_POSTELCN_EDIT_RL => l_POSTELCN_EDIT_RL
11485 ,P_PRTN_ELIG_OVRID_ALWD_FLAG => r_CTP.INFORMATION32
11486 ,P_PRVDS_CR_FLAG => r_CTP.INFORMATION22
11487 ,P_PTIP_ID => l_ptip_id
11488 ,P_PTIP_STAT_CD => r_CTP.INFORMATION14
11489 ,P_RQD_ENRT_PERD_TCO_CD => r_CTP.INFORMATION38
11490 ,P_RQD_PERD_ENRT_NENRT_RL => l_RQD_PERD_ENRT_NENRT_RL
11491 ,P_RQD_PERD_ENRT_NENRT_TM_UOM => r_CTP.INFORMATION37
11492 ,P_RQD_PERD_ENRT_NENRT_VAL => r_CTP.INFORMATION287
11493 ,P_RT_END_DT_CD => r_CTP.INFORMATION42
11494 ,P_RT_END_DT_RL => l_RT_END_DT_RL
11495 ,P_RT_STRT_DT_CD => r_CTP.INFORMATION41
11496 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
11497 ,P_SBJ_TO_DPNT_LF_INS_MX_FLAG => r_CTP.INFORMATION27
11498 ,P_SBJ_TO_SPS_LF_INS_MX_FLAG => r_CTP.INFORMATION26
11499 ,P_SHORT_CODE => r_CTP.INFORMATION12
11500 ,P_SHORT_NAME => r_CTP.INFORMATION13
11501 ,P_TRK_INELIG_PER_FLAG => r_CTP.INFORMATION33
11502 ,P_URL_REF_NAME => r_CTP.INFORMATION185
11503 ,P_USE_TO_SUM_EE_LF_INS_FLAG => r_CTP.INFORMATION28
11504 ,P_VRFY_FMLY_MMBR_CD => r_CTP.INFORMATION46
11505 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
11506 ,P_WVBL_FLAG => r_CTP.INFORMATION23
11507 --ML
11508 ,p_SUSP_IF_DPNT_SSN_NT_PRV_CD => l_susp_if_dpnt_ssn_nt_prv_cd
11509 ,p_SUSP_IF_DPNT_DOB_NT_PRV_CD => l_susp_if_dpnt_dob_nt_prv_cd
11510 ,p_SUSP_IF_DPNT_ADR_NT_PRV_CD => l_susp_if_dpnt_adr_nt_prv_cd
11511 ,p_SUSP_IF_CTFN_NOT_DPNT_FLAG => nvl(r_CTP.INFORMATION192,'Y')
11512 ,p_DPNT_CTFN_DETERMINE_CD => r_CTP.INFORMATION193
11513 --
11514 ,P_EFFECTIVE_START_DATE => l_effective_start_date
11515 ,P_EFFECTIVE_END_DATE => l_effective_end_date
11516 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11517 ,P_DATETRACK_MODE => l_datetrack_mode
11518 );
11519 --
11520 end if; -- l_update
11521 end if;
11522 --
11523 -- Delete the row if it is end dated.
11524 --
11525 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
11526 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
11527 trunc(l_max_eed) = r_CTP.information3) then
11528 --
11529 BEN_PLAN_TYPE_IN_PROGRAM_API.delete_PLAN_TYPE_IN_PROGRAM(
11530 --
11531 p_validate => false
11532 ,p_ptip_id => l_ptip_id
11533 ,p_effective_start_date => l_effective_start_date
11534 ,p_effective_end_date => l_effective_end_date
11535 ,p_object_version_number => l_object_version_number
11536 ,p_effective_date => l_max_eed
11537 ,p_datetrack_mode => hr_api.g_delete
11538 --
11539 );
11540 --
11541 end if;
11542 --
11543 l_prev_pk_id := l_current_pk_id ;
11544 --
11545 end if;
11546 --
11547 end if;
11548 --
11549 end loop;
11550 --
11551 exception when others then
11552 --
11553 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CTP',r_ctp.information5 );
11554 --
11555 end create_CTP_rows;
11556
11557 --
11558 ---------------------------------------------------------------
11559 ----------------------< create_LCC_rows >-----------------------
11560 ---------------------------------------------------------------
11561 --
11562 procedure create_LCC_rows
11563 (
11564 p_validate in number default 0
11565 ,p_copy_entity_txn_id in number
11566 ,p_effective_date in date
11567 ,p_prefix_suffix_text in varchar2 default null
11568 ,p_reuse_object_flag in varchar2 default null
11569 ,p_target_business_group_id in varchar2 default null
11570 ,p_prefix_suffix_cd in varchar2 default null
11571 ) is
11572 --
11573 l_CTFN_RQD_WHEN_RL number;
11574 l_LER_CHG_DPNT_CVG_ID number;
11575 l_DPNT_CVG_CTFN_TYP_CD varchar2(30);
11576 --
11577 cursor c_unique_LCC(l_table_alias varchar2) is
11578 select distinct cpe.information1,
11579 cpe.information2,
11580 cpe.information3,
11581 cpe.table_route_id
11582 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
11583 pqh_table_route tr
11584 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11585 and cpe.table_route_id = tr.table_route_id
11586 -- and tr.where_clause = l_BEN_LER_CHG_DPNT_CVG_CTFN_F
11587 and tr.table_alias = l_table_alias
11588 and cpe.number_of_copies = 1 -- ADDITION
11589 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
11590 order by information1, information2; --added for bug: 5151945
11591 --
11592 --
11593 cursor c_LCC_min_max_dates(c_table_route_id number,
11594 c_information1 number) is
11595 select
11596 min(cpe.information2) min_esd,
11597 max(cpe.information3) min_eed
11598 from ben_copy_entity_results cpe
11599 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11600 and cpe.table_route_id = c_table_route_id
11601 and cpe.information1 = c_information1 ;
11602 --
11603 cursor c_LCC(c_table_route_id number,
11604 c_information1 number,
11605 c_information2 date,
11606 c_information3 date ) is
11607 select
11608 cpe.*
11609 from ben_copy_entity_results cpe
11610 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11611 and cpe.table_route_id = c_table_route_id
11612 and cpe.information1 = c_information1
11613 and cpe.information2 = c_information2
11614 and cpe.information3 = c_information3
11615 and rownum = 1 ;
11616 -- Date Track target record
11617 cursor c_find_LCC_in_target(
11618 c_effective_start_date date,
11619 c_effective_end_date date,
11620 c_business_group_id number,
11621 c_new_pk_id number) is
11622 select
11623 LCC.ler_chg_dpnt_cvg_ctfn_id new_value
11624 from BEN_LER_CHG_DPNT_CVG_CTFN_F LCC
11625 where
11626 LCC.LER_CHG_DPNT_CVG_ID = l_LER_CHG_DPNT_CVG_ID and
11627 LCC.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
11628 LCC.business_group_id = c_business_group_id
11629 and LCC.ler_chg_dpnt_cvg_ctfn_id <> c_new_pk_id
11630 --TEMPIK
11631 and c_effective_start_date between effective_start_date
11632 and effective_end_date ;
11633 --END TEMPIK
11634 /*TEMPIK
11635 and exists ( select null
11636 from BEN_LER_CHG_DPNT_CVG_CTFN_F LCC1
11637 where
11638 LCC1.LER_CHG_DPNT_CVG_ID = l_LER_CHG_DPNT_CVG_ID and
11639 LCC1.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
11640 LCC1.business_group_id = c_business_group_id
11641 and LCC1.effective_start_date <= c_effective_start_date )
11642 and exists ( select null
11643 from BEN_LER_CHG_DPNT_CVG_CTFN_F LCC2
11644 where
11645 LCC2.LER_CHG_DPNT_CVG_ID = l_LER_CHG_DPNT_CVG_ID and
11646 LCC2.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
11647 LCC2.business_group_id = c_business_group_id
11648 and LCC2.effective_end_date >= c_effective_end_date )
11649 ;
11650 TEMPIK */
11651 --TEMPIK
11652 l_dt_rec_found boolean ;
11653 --END TEMPIK
11654 --
11655 --UPD START
11656 --
11657 l_update boolean := false ;
11658 l_datetrack_mode varchar2(80) := hr_api.g_update;
11659 l_process_date date;
11660 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
11661 --
11662 --UPD END
11663 l_current_pk_id number := null ;
11664 l_prev_pk_id number := null ;
11665 l_first_rec boolean := true ;
11666 r_LCC c_LCC%rowtype;
11667 l_ler_chg_dpnt_cvg_ctfn_id number ;
11668 l_object_version_number number ;
11669 l_effective_start_date date ;
11670 l_effective_end_date date ;
11671 l_prefix pqh_copy_entity_attribs.information1%type := null;
11672 l_suffix pqh_copy_entity_attribs.information1%type := null;
11673 l_new_value number(15);
11674 l_object_found_in_target boolean := false ;
11675 l_min_esd date;
11676 l_max_eed date;
11677 l_effective_date date;
11678 --
11679 begin
11680 -- Initialization
11681 l_object_found_in_target := false ;
11682 -- End Initialization
11683 -- Derive the prefix - sufix
11684 if p_prefix_suffix_cd = 'PREFIX' then
11685 l_prefix := p_prefix_suffix_text ;
11686 elsif p_prefix_suffix_cd = 'SUFFIX' then
11687 l_suffix := p_prefix_suffix_text ;
11688 else
11689 l_prefix := null ;
11690 l_suffix := null ;
11691 end if ;
11692 -- End Prefix Sufix derivation
11693 for r_LCC_unique in c_unique_LCC('LCC') loop
11694
11695 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
11696 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11697 r_LCC_unique.information3 >=
11698 ben_pd_copy_to_ben_one.g_copy_effective_date)
11699 ) then
11700 --
11701 hr_utility.set_location(' r_LCC_unique.table_route_id '||r_LCC_unique.table_route_id,10);
11702 hr_utility.set_location(' r_LCC_unique.information1 '||r_LCC_unique.information1,10);
11703 hr_utility.set_location( 'r_LCC_unique.information2 '||r_LCC_unique.information2,10);
11704 hr_utility.set_location( 'r_LCC_unique.information3 '||r_LCC_unique.information3,10);
11705 -- If reuse objects flag is 'Y' then check for the object in the target business group
11706 -- if found insert the record into PLSql table and exit the loop else try create the
11707 -- object in the target business group
11708 --
11709 l_object_found_in_target := false ;
11710 --UPD START
11711 open c_LCC(r_LCC_unique.table_route_id,
11712 r_LCC_unique.information1,
11713 r_LCC_unique.information2,
11714 r_LCC_unique.information3 ) ;
11715 --
11716 fetch c_LCC into r_LCC ;
11717 --
11718 close c_LCC ;
11719 --
11720 l_dml_operation:= r_LCC_unique.dml_operation ;
11721 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_LCC.INFORMATION261,l_dml_operation );
11722 l_LER_CHG_DPNT_CVG_ID := get_fk('LER_CHG_DPNT_CVG_ID', r_LCC.INFORMATION260,l_dml_operation );
11723 l_DPNT_CVG_CTFN_TYP_CD := r_LCC.information12 ;
11724 --
11725 l_update := false;
11726 l_process_date := p_effective_date;
11727 --
11728 if l_dml_operation = 'UPDATE' then
11729 --
11730 l_object_found_in_target := TRUE;
11731 --
11732 if l_process_date between r_LCC_unique.information2 and r_LCC_unique.information3 then
11733 l_update := true;
11734 if r_LCC_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
11735 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_DPNT_CVG_CTFN_ID'
11736 then
11737 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_DPNT_CVG_CTFN_ID' ;
11738 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LCC_unique.information1 ;
11739 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LCC_unique.information1 ;
11740 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
11741 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LCC_unique.table_route_id;
11742 --
11743 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
11744 --
11745 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
11746 --
11747 --DOUBT log_data('LCC',l_new_value,l_prefix || r_LCC_unique.name|| l_suffix,'REUSED');
11748 --
11749 end if ;
11750 hr_utility.set_location( 'found record for update',10);
11751 --
11752 else
11753 --
11754 l_update := false;
11755 --
11756 end if;
11757 else
11758 --
11759 --UPD END
11760 l_min_esd := null ;
11761 l_max_eed := null ;
11762 open c_LCC_min_max_dates(r_LCC_unique.table_route_id, r_LCC_unique.information1 ) ;
11763 fetch c_LCC_min_max_dates into l_min_esd,l_max_eed ;
11764 --
11765
11766 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11767 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
11768 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
11769 end if;
11770 l_min_esd := greatest(l_min_esd,r_LCC_unique.information2);
11771 /* open c_LCC(r_LCC_unique.table_route_id,
11772 r_LCC_unique.information1,
11773 r_LCC_unique.information2,
11774 r_LCC_unique.information3 ) ;
11775 --
11776 fetch c_LCC into r_LCC ;
11777 --
11778 close c_LCC ; */
11779 --
11780
11781 if p_reuse_object_flag = 'Y' then
11782 if c_LCC_min_max_dates%found then
11783 -- cursor to find the object
11784 open c_find_LCC_in_target( l_min_esd,l_max_eed,
11785 p_target_business_group_id, nvl(l_ler_chg_dpnt_cvg_ctfn_id, -999) ) ;
11786 fetch c_find_LCC_in_target into l_new_value ;
11787 if c_find_LCC_in_target%found then
11788 --
11789 --TEMPIK
11790 l_dt_rec_found := dt_api.check_min_max_dates
11791 (p_base_table_name => 'BEN_LER_CHG_DPNT_CVG_CTFN_F',
11792 p_base_key_column => 'LER_CHG_DPNT_CVG_CTFN_ID',
11793 p_base_key_value => l_new_value,
11794 p_from_date => l_min_esd,
11795 p_to_date => l_max_eed );
11796 if l_dt_rec_found THEN
11797 --END TEMPIK
11798 if r_LCC_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
11799 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_DPNT_CVG_CTFN_ID' then
11800 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_DPNT_CVG_CTFN_ID' ;
11801 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LCC_unique.information1 ;
11802 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
11803 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
11804 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LCC_unique.table_route_id;
11805 --
11806 -- 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) ;
11807 --
11808 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
11809 end if ;
11810 --
11811 l_object_found_in_target := true ;
11812 --TEMPIK
11813 end if; -- l_dt_rec_found
11814 --END TEMPIK
11815 end if;
11816 close c_find_LCC_in_target ;
11817 --
11818 end if;
11819 end if ;
11820 --
11821 close c_LCC_min_max_dates ;
11822 end if; --if p_dml_operation
11823 --
11824 if not l_object_found_in_target OR l_update then
11825 --
11826 l_current_pk_id := r_LCC.information1;
11827 --
11828 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
11829 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
11830 --
11831 if l_current_pk_id = l_prev_pk_id then
11832 --
11833 l_first_rec := false ;
11834 --
11835 else
11836 --
11837 l_first_rec := true ;
11838 --
11839 end if ;
11840 --
11841
11842 l_effective_date := r_LCC.information2;
11843 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11844 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
11845 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
11846 end if;
11847
11848 if l_first_rec and not l_update then
11849 -- Call Create routine.
11850 hr_utility.set_location(' BEN_LER_CHG_DPNT_CVG_CTFN_F CREATE_LER_CHG_DPNT_CVG_CTF ',20);
11851 BEN_LER_CHG_DPNT_CVG_CTF_API.CREATE_LER_CHG_DPNT_CVG_CTF(
11852 --
11853 P_VALIDATE => false
11854 ,P_EFFECTIVE_DATE => l_effective_date
11855 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11856 --
11857 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
11858 ,P_DPNT_CVG_CTFN_TYP_CD => r_LCC.INFORMATION12
11859 ,P_LACK_CTFN_SSPND_ENRT_FLAG => r_LCC.INFORMATION13
11860 ,P_LCC_ATTRIBUTE1 => r_LCC.INFORMATION111
11861 ,P_LCC_ATTRIBUTE10 => r_LCC.INFORMATION120
11862 ,P_LCC_ATTRIBUTE11 => r_LCC.INFORMATION121
11863 ,P_LCC_ATTRIBUTE12 => r_LCC.INFORMATION122
11864 ,P_LCC_ATTRIBUTE13 => r_LCC.INFORMATION123
11865 ,P_LCC_ATTRIBUTE14 => r_LCC.INFORMATION124
11866 ,P_LCC_ATTRIBUTE15 => r_LCC.INFORMATION125
11867 ,P_LCC_ATTRIBUTE16 => r_LCC.INFORMATION126
11868 ,P_LCC_ATTRIBUTE17 => r_LCC.INFORMATION127
11869 ,P_LCC_ATTRIBUTE18 => r_LCC.INFORMATION128
11870 ,P_LCC_ATTRIBUTE19 => r_LCC.INFORMATION129
11871 ,P_LCC_ATTRIBUTE2 => r_LCC.INFORMATION112
11872 ,P_LCC_ATTRIBUTE20 => r_LCC.INFORMATION130
11873 ,P_LCC_ATTRIBUTE21 => r_LCC.INFORMATION131
11874 ,P_LCC_ATTRIBUTE22 => r_LCC.INFORMATION132
11875 ,P_LCC_ATTRIBUTE23 => r_LCC.INFORMATION133
11876 ,P_LCC_ATTRIBUTE24 => r_LCC.INFORMATION134
11877 ,P_LCC_ATTRIBUTE25 => r_LCC.INFORMATION135
11878 ,P_LCC_ATTRIBUTE26 => r_LCC.INFORMATION136
11879 ,P_LCC_ATTRIBUTE27 => r_LCC.INFORMATION137
11880 ,P_LCC_ATTRIBUTE28 => r_LCC.INFORMATION138
11881 ,P_LCC_ATTRIBUTE29 => r_LCC.INFORMATION139
11882 ,P_LCC_ATTRIBUTE3 => r_LCC.INFORMATION113
11883 ,P_LCC_ATTRIBUTE30 => r_LCC.INFORMATION140
11884 ,P_LCC_ATTRIBUTE4 => r_LCC.INFORMATION114
11885 ,P_LCC_ATTRIBUTE5 => r_LCC.INFORMATION115
11886 ,P_LCC_ATTRIBUTE6 => r_LCC.INFORMATION116
11887 ,P_LCC_ATTRIBUTE7 => r_LCC.INFORMATION117
11888 ,P_LCC_ATTRIBUTE8 => r_LCC.INFORMATION118
11889 ,P_LCC_ATTRIBUTE9 => r_LCC.INFORMATION119
11890 ,P_LCC_ATTRIBUTE_CATEGORY => r_LCC.INFORMATION110
11891 ,P_LER_CHG_DPNT_CVG_CTFN_ID => l_ler_chg_dpnt_cvg_ctfn_id
11892 ,P_LER_CHG_DPNT_CVG_ID => l_LER_CHG_DPNT_CVG_ID
11893 ,P_RLSHP_TYP_CD => r_LCC.INFORMATION14
11894 ,P_RQD_FLAG => r_LCC.INFORMATION11
11895 --
11896 ,P_EFFECTIVE_START_DATE => l_effective_start_date
11897 ,P_EFFECTIVE_END_DATE => l_effective_end_date
11898 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11899 );
11900 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11901 -- Update all relevent cer records with new pk_id
11902 hr_utility.set_location('Before plsql table ',222);
11903 hr_utility.set_location('new_value id '||l_ler_chg_dpnt_cvg_ctfn_id,222);
11904 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_DPNT_CVG_CTFN_ID' ;
11905 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LCC.information1 ;
11906 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LER_CHG_DPNT_CVG_CTFN_ID ;
11907 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
11908 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LCC_unique.table_route_id;
11909 hr_utility.set_location('After plsql table ',222);
11910 --
11911 -- 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 ) ;
11912 --
11913 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
11914 --
11915 else
11916 --
11917 -- Call Update routine for the pk_id created in prev run .
11918 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11919 hr_utility.set_location(' BEN_LER_CHG_DPNT_CVG_CTFN_F UPDATE_LER_CHG_DPNT_CVG_CTF ',30);
11920 --UPD START
11921 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
11922 --
11923 if l_update then
11924 --
11925 l_datetrack_mode := r_LCC.datetrack_mode ;
11926 --
11927 get_dt_modes(
11928 p_effective_date => l_process_date,
11929 p_effective_end_date => r_LCC.information3,
11930 p_effective_start_date => r_LCC.information2,
11931 p_dml_operation => r_LCC.dml_operation,
11932 p_datetrack_mode => l_datetrack_mode );
11933 -- p_update => l_update
11934 --
11935 l_effective_date := l_process_date;
11936 l_LER_CHG_DPNT_CVG_CTFN_ID := r_LCC.information1;
11937 l_object_version_number := r_LCC.information265;
11938 --
11939 end if;
11940 --
11941 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
11942 --
11943 IF l_update OR l_dml_operation <> 'UPDATE' THEN
11944 --UPD END
11945
11946
11947 BEN_LER_CHG_DPNT_CVG_CTF_API.UPDATE_LER_CHG_DPNT_CVG_CTF(
11948 --
11949 P_VALIDATE => false
11950 ,P_EFFECTIVE_DATE => l_effective_date
11951 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11952 --
11953 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
11954 ,P_DPNT_CVG_CTFN_TYP_CD => r_LCC.INFORMATION12
11955 ,P_LACK_CTFN_SSPND_ENRT_FLAG => r_LCC.INFORMATION13
11956 ,P_LCC_ATTRIBUTE1 => r_LCC.INFORMATION111
11957 ,P_LCC_ATTRIBUTE10 => r_LCC.INFORMATION120
11958 ,P_LCC_ATTRIBUTE11 => r_LCC.INFORMATION121
11959 ,P_LCC_ATTRIBUTE12 => r_LCC.INFORMATION122
11960 ,P_LCC_ATTRIBUTE13 => r_LCC.INFORMATION123
11961 ,P_LCC_ATTRIBUTE14 => r_LCC.INFORMATION124
11962 ,P_LCC_ATTRIBUTE15 => r_LCC.INFORMATION125
11963 ,P_LCC_ATTRIBUTE16 => r_LCC.INFORMATION126
11964 ,P_LCC_ATTRIBUTE17 => r_LCC.INFORMATION127
11965 ,P_LCC_ATTRIBUTE18 => r_LCC.INFORMATION128
11966 ,P_LCC_ATTRIBUTE19 => r_LCC.INFORMATION129
11967 ,P_LCC_ATTRIBUTE2 => r_LCC.INFORMATION112
11968 ,P_LCC_ATTRIBUTE20 => r_LCC.INFORMATION130
11969 ,P_LCC_ATTRIBUTE21 => r_LCC.INFORMATION131
11970 ,P_LCC_ATTRIBUTE22 => r_LCC.INFORMATION132
11971 ,P_LCC_ATTRIBUTE23 => r_LCC.INFORMATION133
11972 ,P_LCC_ATTRIBUTE24 => r_LCC.INFORMATION134
11973 ,P_LCC_ATTRIBUTE25 => r_LCC.INFORMATION135
11974 ,P_LCC_ATTRIBUTE26 => r_LCC.INFORMATION136
11975 ,P_LCC_ATTRIBUTE27 => r_LCC.INFORMATION137
11976 ,P_LCC_ATTRIBUTE28 => r_LCC.INFORMATION138
11977 ,P_LCC_ATTRIBUTE29 => r_LCC.INFORMATION139
11978 ,P_LCC_ATTRIBUTE3 => r_LCC.INFORMATION113
11979 ,P_LCC_ATTRIBUTE30 => r_LCC.INFORMATION140
11980 ,P_LCC_ATTRIBUTE4 => r_LCC.INFORMATION114
11981 ,P_LCC_ATTRIBUTE5 => r_LCC.INFORMATION115
11982 ,P_LCC_ATTRIBUTE6 => r_LCC.INFORMATION116
11983 ,P_LCC_ATTRIBUTE7 => r_LCC.INFORMATION117
11984 ,P_LCC_ATTRIBUTE8 => r_LCC.INFORMATION118
11985 ,P_LCC_ATTRIBUTE9 => r_LCC.INFORMATION119
11986 ,P_LCC_ATTRIBUTE_CATEGORY => r_LCC.INFORMATION110
11987 ,P_LER_CHG_DPNT_CVG_CTFN_ID => l_ler_chg_dpnt_cvg_ctfn_id
11988 ,P_LER_CHG_DPNT_CVG_ID => l_LER_CHG_DPNT_CVG_ID
11989 ,P_RLSHP_TYP_CD => r_LCC.INFORMATION14
11990 ,P_RQD_FLAG => r_LCC.INFORMATION11
11991 --
11992 ,P_EFFECTIVE_START_DATE => l_effective_start_date
11993 ,P_EFFECTIVE_END_DATE => l_effective_end_date
11994 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11995 ,P_DATETRACK_MODE => l_datetrack_mode
11996 );
11997 --
11998 end if; -- l_update
11999 end if;
12000 --
12001 -- Delete the row if it is end dated.
12002 --
12003 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
12004 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
12005 trunc(l_max_eed) = r_LCC.information3) then
12006 --
12007 BEN_LER_CHG_DPNT_CVG_CTF_API.delete_LER_CHG_DPNT_CVG_CTF(
12008 --
12009 p_validate => false
12010 ,p_ler_chg_dpnt_cvg_ctfn_id => l_ler_chg_dpnt_cvg_ctfn_id
12011 ,p_effective_start_date => l_effective_start_date
12012 ,p_effective_end_date => l_effective_end_date
12013 ,p_object_version_number => l_object_version_number
12014 ,p_effective_date => l_max_eed
12015 ,p_datetrack_mode => hr_api.g_delete
12016 --
12017 );
12018 --
12019 end if;
12020 --
12021 l_prev_pk_id := l_current_pk_id ;
12022 --
12023 end if;
12024 --
12025 end if;
12026 --
12027 end loop;
12028 --
12029 exception when others then
12030 --
12031 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LCC',r_lcc.information5 );
12032 --
12033 end create_LCC_rows;
12034
12035 --
12036 ---------------------------------------------------------------
12037 ----------------------< create_CER_rows >-----------------------
12038 ---------------------------------------------------------------
12039 --
12040 procedure create_CER_rows
12041 (
12042 p_validate in number default 0
12043 ,p_copy_entity_txn_id in number
12044 ,p_effective_date in date
12045 ,p_prefix_suffix_text in varchar2 default null
12046 ,p_reuse_object_flag in varchar2 default null
12047 ,p_target_business_group_id in varchar2 default null
12048 ,p_prefix_suffix_cd in varchar2 default null
12049 ) is
12050 --
12051 l_FORMULA_ID number;
12052 l_PRTN_ELIG_ID number;
12053 cursor c_unique_CER(l_table_alias varchar2) is
12054 select distinct cpe.information1,
12055 cpe.information2,
12056 cpe.information3,
12057 cpe.table_route_id
12058 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
12059 pqh_table_route tr
12060 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12061 and cpe.table_route_id = tr.table_route_id
12062 -- and tr.where_clause = l_BEN_PRTN_ELIGY_RL_F
12063 and tr.table_alias = l_table_alias
12064 and cpe.number_of_copies = 1 -- ADDITION
12065 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
12066 order by information1, information2; --added for bug: 5151945
12067 --
12068 --
12069 cursor c_CER_min_max_dates(c_table_route_id number,
12070 c_information1 number) is
12071 select
12072 min(cpe.information2) min_esd,
12073 max(cpe.information3) min_eed
12074 from ben_copy_entity_results cpe
12075 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12076 and cpe.table_route_id = c_table_route_id
12077 and cpe.information1 = c_information1 ;
12078 --
12079 cursor c_CER(c_table_route_id number,
12080 c_information1 number,
12081 c_information2 date,
12082 c_information3 date ) is
12083 select
12084 cpe.*
12085 from ben_copy_entity_results cpe
12086 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12087 and cpe.table_route_id = c_table_route_id
12088 and cpe.information1 = c_information1
12089 and cpe.information2 = c_information2
12090 and cpe.information3 = c_information3
12091 and rownum = 1 ;
12092 -- Date Track target record
12093 cursor c_find_CER_in_target(
12094 c_effective_start_date date,
12095 c_effective_end_date date,
12096 c_business_group_id number,
12097 c_new_pk_id number) is
12098 select
12099 cer.prtn_eligy_rl_id new_value
12100 from BEN_PRTN_ELIGY_RL_F CER
12101 where
12102 cer.FORMULA_ID = l_FORMULA_ID and
12103 cer.PRTN_ELIG_ID = l_PRTN_ELIG_ID and
12104 cer.business_group_id = c_business_group_id
12105 and cer.prtn_eligy_rl_id <> c_new_pk_id
12106 --TEMPIK
12107 and c_effective_start_date between effective_start_date
12108 and effective_end_date ;
12109 --END TEMPIK
12110 /*TEMPIK
12111 and exists ( select null
12112 from BEN_PRTN_ELIGY_RL_F CER1
12113 where
12114 CER1.FORMULA_ID = l_FORMULA_ID and
12115 CER1.PRTN_ELIG_ID = l_PRTN_ELIG_ID and
12116 CER1.business_group_id = c_business_group_id
12117 and CER1.effective_start_date <= c_effective_start_date )
12118 and exists ( select null
12119 from BEN_PRTN_ELIGY_RL_F CER2
12120 where
12121 CER2.FORMULA_ID = l_FORMULA_ID and
12122 CER2.PRTN_ELIG_ID = l_PRTN_ELIG_ID and
12123 CER2.business_group_id = c_business_group_id
12124 and CER2.effective_end_date >= c_effective_end_date )
12125 ;
12126 TEMPIK */
12127 --TEMPIK
12128 l_dt_rec_found boolean ;
12129 --END TEMPIK
12130 --
12131 --UPD START
12132 --
12133 l_update boolean := false ;
12134 l_datetrack_mode varchar2(80) := hr_api.g_update;
12135 l_process_date date;
12136 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
12137 --
12138 --UPD END
12139 l_current_pk_id number := null ;
12140 l_prev_pk_id number := null ;
12141 l_first_rec boolean := true ;
12142 r_CER c_CER%rowtype;
12143 l_prtn_eligy_rl_id number ;
12144 l_object_version_number number ;
12145 l_effective_start_date date ;
12146 l_effective_end_date date ;
12147 l_prefix pqh_copy_entity_attribs.information1%type := null;
12148 l_suffix pqh_copy_entity_attribs.information1%type := null;
12149 l_new_value number(15);
12150 l_object_found_in_target boolean := false ;
12151 l_min_esd date;
12152 l_max_eed date;
12153 l_effective_date date;
12154 --
12155 begin
12156 -- Initialization
12157 l_object_found_in_target := false ;
12158 -- End Initialization
12159 -- Derive the prefix - sufix
12160 if p_prefix_suffix_cd = 'PREFIX' then
12161 l_prefix := p_prefix_suffix_text ;
12162 elsif p_prefix_suffix_cd = 'SUFFIX' then
12163 l_suffix := p_prefix_suffix_text ;
12164 else
12165 l_prefix := null ;
12166 l_suffix := null ;
12167 end if ;
12168 -- End Prefix Sufix derivation
12169 for r_CER_unique in c_unique_CER('CER') loop
12170
12171 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
12172 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12173 r_CER_unique.information3 >=
12174 ben_pd_copy_to_ben_one.g_copy_effective_date)
12175 ) then
12176 --
12177 hr_utility.set_location(' r_CER_unique.table_route_id '||r_CER_unique.table_route_id,10);
12178 hr_utility.set_location(' r_CER_unique.information1 '||r_CER_unique.information1,10);
12179 hr_utility.set_location( 'r_CER_unique.information2 '||r_CER_unique.information2,10);
12180 hr_utility.set_location( 'r_CER_unique.information3 '||r_CER_unique.information3,10);
12181 -- If reuse objects flag is 'Y' then check for the object in the target business group
12182 -- if found insert the record into PLSql table and exit the loop else try create the
12183 -- object in the target business group
12184 --
12185 l_object_found_in_target := false ;
12186 --UPD START
12187 open c_CER(r_CER_unique.table_route_id,
12188 r_CER_unique.information1,
12189 r_CER_unique.information2,
12190 r_CER_unique.information3 ) ;
12191 --
12192 fetch c_CER into r_CER;
12193 --
12194 close c_CER ;
12195 --
12196 l_dml_operation:= r_CER_unique.dml_operation ;
12197 l_FORMULA_ID := get_fk('FORMULA_ID', r_CER.INFORMATION251,l_dml_operation );
12198 l_PRTN_ELIG_ID := get_fk('PRTN_ELIG_ID', r_CER.INFORMATION229,l_dml_operation );
12199 --
12200 l_update := false;
12201 l_process_date := p_effective_date;
12202 --
12203 if l_dml_operation = 'UPDATE' then
12204 --
12205 l_object_found_in_target := TRUE;
12206 --
12207 if l_process_date between r_CER_unique.information2 and r_CER_unique.information3 then
12208 l_update := true;
12209 if r_CER_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
12210 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PRTN_ELIGY_RL_ID'
12211 then
12212 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PRTN_ELIGY_RL_ID' ;
12213 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CER_unique.information1 ;
12214 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_CER_unique.information1 ;
12215 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
12216 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CER_unique.table_route_id;
12217 --
12218 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
12219 --
12220 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
12221 --
12222 --DOUBT log_data('CER',l_new_value,l_prefix || r_CER_unique.name|| l_suffix,'REUSED');
12223 --
12224 end if ;
12225 hr_utility.set_location( 'found record for update',10);
12226 --
12227 else
12228 --
12229 l_update := false;
12230 --
12231 end if;
12232 else
12233 --
12234 --UPD END
12235 l_min_esd := null ;
12236 l_max_eed := null ;
12237 open c_CER_min_max_dates(r_CER_unique.table_route_id, r_CER_unique.information1 ) ;
12238 fetch c_CER_min_max_dates into l_min_esd,l_max_eed ;
12239 --
12240
12241 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12242 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
12243 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
12244 end if;
12245 l_min_esd := greatest(l_min_esd,r_CER_unique.information2);
12246 /* open c_CER(r_CER_unique.table_route_id,
12247 r_CER_unique.information1,
12248 r_CER_unique.information2,
12249 r_CER_unique.information3 ) ;
12250 --
12251 fetch c_CER into r_CER;
12252 --
12253 close c_CER ; */
12254 --
12255
12256 if p_reuse_object_flag = 'Y' then
12257 if c_CER_min_max_dates%found then
12258 -- cursor to find the object
12259 open c_find_CER_in_target( l_min_esd,l_max_eed,
12260 p_target_business_group_id, nvl(l_prtn_eligy_rl_id, -999) ) ;
12261 fetch c_find_CER_in_target into l_new_value ;
12262 if c_find_CER_in_target%found then
12263 --
12264 --TEMPIK
12265 l_dt_rec_found := dt_api.check_min_max_dates
12266 (p_base_table_name => 'BEN_PRTN_ELIGY_RL_F',
12267 p_base_key_column => 'PRTN_ELIGY_RL_ID',
12268 p_base_key_value => l_new_value,
12269 p_from_date => l_min_esd,
12270 p_to_date => l_max_eed );
12271 if l_dt_rec_found THEN
12272 --END TEMPIK
12273 if r_CER_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
12274 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PRTN_ELIGY_RL_ID' then
12275 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PRTN_ELIGY_RL_ID' ;
12276 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CER_unique.information1 ;
12277 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
12278 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
12279 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CER_unique.table_route_id;
12280 --
12281 -- 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) ;
12282 --
12283 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
12284 end if ;
12285 --
12286 l_object_found_in_target := true ;
12287 --TEMPIK
12288 end if; -- l_dt_rec_found
12289 --END TEMPIK
12290 end if;
12291 close c_find_CER_in_target ;
12292 --
12293 end if;
12294 end if ;
12295 --
12296 close c_CER_min_max_dates ;
12297 end if; --if p_dml_operation
12298 --
12299 if not l_object_found_in_target OR l_update then
12300 --
12301 l_current_pk_id := r_CER.information1;
12302 --
12303 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
12304 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
12305 --
12306 if l_current_pk_id = l_prev_pk_id then
12307 --
12308 l_first_rec := false ;
12309 --
12310 else
12311 --
12312 l_first_rec := true ;
12313 --
12314 end if ;
12315 --
12316
12317 l_effective_date := r_cer.information2;
12318 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12319 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
12320 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
12321 end if;
12322
12323 if l_first_rec and not l_update then
12324 -- Call Create routine.
12325 hr_utility.set_location(' BEN_PRTN_ELIGY_RL_F CREATE_ELIGIBILITY_RULE ',20);
12326 BEN_ELIGIBILITY_RULE_API.CREATE_ELIGIBILITY_RULE(
12327 --
12328 P_VALIDATE => false
12329 ,P_EFFECTIVE_DATE => l_effective_date
12330 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
12331 --
12332 ,P_CER_ATTRIBUTE1 => r_CER.INFORMATION111
12333 ,P_CER_ATTRIBUTE10 => r_CER.INFORMATION120
12334 ,P_CER_ATTRIBUTE11 => r_CER.INFORMATION121
12335 ,P_CER_ATTRIBUTE12 => r_CER.INFORMATION122
12336 ,P_CER_ATTRIBUTE13 => r_CER.INFORMATION123
12337 ,P_CER_ATTRIBUTE14 => r_CER.INFORMATION124
12338 ,P_CER_ATTRIBUTE15 => r_CER.INFORMATION125
12339 ,P_CER_ATTRIBUTE16 => r_CER.INFORMATION126
12340 ,P_CER_ATTRIBUTE17 => r_CER.INFORMATION127
12341 ,P_CER_ATTRIBUTE18 => r_CER.INFORMATION128
12342 ,P_CER_ATTRIBUTE19 => r_CER.INFORMATION129
12343 ,P_CER_ATTRIBUTE2 => r_CER.INFORMATION112
12344 ,P_CER_ATTRIBUTE20 => r_CER.INFORMATION130
12345 ,P_CER_ATTRIBUTE21 => r_CER.INFORMATION131
12346 ,P_CER_ATTRIBUTE22 => r_CER.INFORMATION132
12347 ,P_CER_ATTRIBUTE23 => r_CER.INFORMATION133
12348 ,P_CER_ATTRIBUTE24 => r_CER.INFORMATION134
12349 ,P_CER_ATTRIBUTE25 => r_CER.INFORMATION135
12350 ,P_CER_ATTRIBUTE26 => r_CER.INFORMATION136
12351 ,P_CER_ATTRIBUTE27 => r_CER.INFORMATION137
12352 ,P_CER_ATTRIBUTE28 => r_CER.INFORMATION138
12353 ,P_CER_ATTRIBUTE29 => r_CER.INFORMATION139
12354 ,P_CER_ATTRIBUTE3 => r_CER.INFORMATION113
12355 ,P_CER_ATTRIBUTE30 => r_CER.INFORMATION140
12356 ,P_CER_ATTRIBUTE4 => r_CER.INFORMATION114
12357 ,P_CER_ATTRIBUTE5 => r_CER.INFORMATION115
12358 ,P_CER_ATTRIBUTE6 => r_CER.INFORMATION116
12359 ,P_CER_ATTRIBUTE7 => r_CER.INFORMATION117
12360 ,P_CER_ATTRIBUTE8 => r_CER.INFORMATION118
12361 ,P_CER_ATTRIBUTE9 => r_CER.INFORMATION119
12362 ,P_CER_ATTRIBUTE_CATEGORY => r_CER.INFORMATION110
12363 ,P_DRVBL_FCTR_APLS_FLAG => r_CER.INFORMATION11
12364 ,P_FORMULA_ID => l_FORMULA_ID
12365 ,P_MNDTRY_FLAG => r_CER.INFORMATION12
12366 ,P_ORDR_TO_APLY_NUM => r_CER.INFORMATION260
12367 ,P_PRTN_ELIGY_RL_ID => l_prtn_eligy_rl_id
12368 ,P_PRTN_ELIG_ID => l_PRTN_ELIG_ID
12369 --
12370 ,P_EFFECTIVE_START_DATE => l_effective_start_date
12371 ,P_EFFECTIVE_END_DATE => l_effective_end_date
12372 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12373 );
12374 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
12375 -- Update all relevent cer records with new pk_id
12376 hr_utility.set_location('Before plsql table ',222);
12377 hr_utility.set_location('new_value id '||l_prtn_eligy_rl_id,222);
12378 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PRTN_ELIGY_RL_ID' ;
12379 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_cer.information1 ;
12380 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PRTN_ELIGY_RL_ID ;
12381 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
12382 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CER_unique.table_route_id;
12383 hr_utility.set_location('After plsql table ',222);
12384 --
12385 -- 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 ) ;
12386 --
12387 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
12388 --
12389 else
12390 --
12391 -- Call Update routine for the pk_id created in prev run .
12392 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
12393 hr_utility.set_location(' BEN_PRTN_ELIGY_RL_F UPDATE_ELIGIBILITY_RULE ',30);
12394 --UPD START
12395 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
12396 --
12397 if l_update then
12398 --
12399 l_datetrack_mode := r_CER.datetrack_mode ;
12400 --
12401 get_dt_modes(
12402 p_effective_date => l_process_date,
12403 p_effective_end_date => r_CER.information3,
12404 p_effective_start_date => r_CER.information2,
12405 p_dml_operation => r_CER.dml_operation,
12406 p_datetrack_mode => l_datetrack_mode );
12407 -- p_update => l_update
12408 --
12409 l_effective_date := l_process_date;
12410 l_PRTN_ELIGY_RL_ID := r_CER.information1;
12411 l_object_version_number := r_CER.information265;
12412 --
12413 end if;
12414 --
12415 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
12416 --
12417 IF l_update OR l_dml_operation <> 'UPDATE' THEN
12418 --UPD END
12419
12420 BEN_ELIGIBILITY_RULE_API.UPDATE_ELIGIBILITY_RULE(
12421 --
12422 P_VALIDATE => false
12423 ,P_EFFECTIVE_DATE => l_effective_date
12424 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
12425 --
12426 ,P_CER_ATTRIBUTE1 => r_CER.INFORMATION111
12427 ,P_CER_ATTRIBUTE10 => r_CER.INFORMATION120
12428 ,P_CER_ATTRIBUTE11 => r_CER.INFORMATION121
12429 ,P_CER_ATTRIBUTE12 => r_CER.INFORMATION122
12430 ,P_CER_ATTRIBUTE13 => r_CER.INFORMATION123
12431 ,P_CER_ATTRIBUTE14 => r_CER.INFORMATION124
12432 ,P_CER_ATTRIBUTE15 => r_CER.INFORMATION125
12433 ,P_CER_ATTRIBUTE16 => r_CER.INFORMATION126
12434 ,P_CER_ATTRIBUTE17 => r_CER.INFORMATION127
12435 ,P_CER_ATTRIBUTE18 => r_CER.INFORMATION128
12436 ,P_CER_ATTRIBUTE19 => r_CER.INFORMATION129
12437 ,P_CER_ATTRIBUTE2 => r_CER.INFORMATION112
12438 ,P_CER_ATTRIBUTE20 => r_CER.INFORMATION130
12439 ,P_CER_ATTRIBUTE21 => r_CER.INFORMATION131
12440 ,P_CER_ATTRIBUTE22 => r_CER.INFORMATION132
12441 ,P_CER_ATTRIBUTE23 => r_CER.INFORMATION133
12442 ,P_CER_ATTRIBUTE24 => r_CER.INFORMATION134
12443 ,P_CER_ATTRIBUTE25 => r_CER.INFORMATION135
12444 ,P_CER_ATTRIBUTE26 => r_CER.INFORMATION136
12445 ,P_CER_ATTRIBUTE27 => r_CER.INFORMATION137
12446 ,P_CER_ATTRIBUTE28 => r_CER.INFORMATION138
12447 ,P_CER_ATTRIBUTE29 => r_CER.INFORMATION139
12448 ,P_CER_ATTRIBUTE3 => r_CER.INFORMATION113
12449 ,P_CER_ATTRIBUTE30 => r_CER.INFORMATION140
12450 ,P_CER_ATTRIBUTE4 => r_CER.INFORMATION114
12451 ,P_CER_ATTRIBUTE5 => r_CER.INFORMATION115
12452 ,P_CER_ATTRIBUTE6 => r_CER.INFORMATION116
12453 ,P_CER_ATTRIBUTE7 => r_CER.INFORMATION117
12454 ,P_CER_ATTRIBUTE8 => r_CER.INFORMATION118
12455 ,P_CER_ATTRIBUTE9 => r_CER.INFORMATION119
12456 ,P_CER_ATTRIBUTE_CATEGORY => r_CER.INFORMATION110
12457 ,P_DRVBL_FCTR_APLS_FLAG => r_CER.INFORMATION11
12458 ,P_FORMULA_ID => l_FORMULA_ID
12459 ,P_MNDTRY_FLAG => r_CER.INFORMATION12
12460 ,P_ORDR_TO_APLY_NUM => r_CER.INFORMATION260
12461 ,P_PRTN_ELIGY_RL_ID => l_prtn_eligy_rl_id
12462 ,P_PRTN_ELIG_ID => l_PRTN_ELIG_ID
12463 --
12464 ,P_EFFECTIVE_START_DATE => l_effective_start_date
12465 ,P_EFFECTIVE_END_DATE => l_effective_end_date
12466 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12467 ,P_DATETRACK_MODE => l_datetrack_mode
12468 );
12469 --
12470 end if; -- l_update
12471 end if;
12472 --
12473 -- Delete the row if it is end dated.
12474 --
12475 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
12476 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
12477 trunc(l_max_eed) = r_cer.information3) then
12478 --
12479 BEN_ELIGIBILITY_RULE_API.delete_ELIGIBILITY_RULE(
12480 --
12481 p_validate => false
12482 ,p_prtn_eligy_rl_id => l_prtn_eligy_rl_id
12483 ,p_effective_start_date => l_effective_start_date
12484 ,p_effective_end_date => l_effective_end_date
12485 ,p_object_version_number => l_object_version_number
12486 ,p_effective_date => l_max_eed
12487 ,p_datetrack_mode => hr_api.g_delete
12488 --
12489 );
12490 --
12491 end if;
12492 --
12493 l_prev_pk_id := l_current_pk_id ;
12494 --
12495 end if;
12496 --
12497 end if;
12498 --
12499 end loop;
12500 --
12501 exception when others then
12502 --
12503 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CER',r_cer.information5 );
12504 --
12505 end create_CER_rows;
12506
12507 --
12508 ---------------------------------------------------------------
12509 ----------------------< create_CEP_rows >-----------------------
12510 ---------------------------------------------------------------
12511 --
12512 procedure create_CEP_rows
12513 (
12514 p_validate in number default 0
12515 ,p_copy_entity_txn_id in number
12516 ,p_effective_date in date
12517 ,p_prefix_suffix_text in varchar2 default null
12518 ,p_reuse_object_flag in varchar2 default null
12519 ,p_target_business_group_id in varchar2 default null
12520 ,p_prefix_suffix_cd in varchar2 default null
12521 ) is
12522 --
12523 l_ELIGY_PRFL_ID number;
12524 l_PRTN_ELIG_ID number;
12525 cursor c_unique_CEP(l_table_alias varchar2) is
12526 select distinct cpe.information1,
12527 cpe.information2,
12528 cpe.information3,
12529 cpe.table_route_id
12530 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
12531 pqh_table_route tr
12532 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12533 and cpe.table_route_id = tr.table_route_id
12534 -- and tr.where_clause = l_BEN_PRTN_ELIG_PRFL_F
12535 and tr.table_alias = l_table_alias
12536 and cpe.number_of_copies = 1 -- ADDITION
12537 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
12538 order by information1, information2; --added for bug: 5151945
12539 --
12540 --
12541 cursor c_CEP_min_max_dates(c_table_route_id number,
12542 c_information1 number) is
12543 select
12544 min(cpe.information2) min_esd,
12545 max(cpe.information3) min_eed
12546 from ben_copy_entity_results cpe
12547 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12548 and cpe.table_route_id = c_table_route_id
12549 and cpe.information1 = c_information1 ;
12550 --
12551 cursor c_CEP(c_table_route_id number,
12552 c_information1 number,
12553 c_information2 date,
12554 c_information3 date ) is
12555 select
12556 cpe.*
12557 from ben_copy_entity_results cpe
12558 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12559 and cpe.table_route_id = c_table_route_id
12560 and cpe.information1 = c_information1
12561 and cpe.information2 = c_information2
12562 and cpe.information3 = c_information3
12563 and rownum = 1 ;
12564 -- Date Track target record
12565 cursor c_find_CEP_in_target(
12566 c_effective_start_date date,
12567 c_effective_end_date date,
12568 c_business_group_id number,
12569 c_new_pk_id number) is
12570 select
12571 CEP.prtn_elig_prfl_id new_value
12572 from BEN_PRTN_ELIG_PRFL_F CEP
12573 where
12574 CEP.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
12575 CEP.PRTN_ELIG_ID = l_PRTN_ELIG_ID and
12576 CEP.business_group_id = c_business_group_id
12577 and CEP.prtn_elig_prfl_id <> c_new_pk_id
12578 --TEMPIK
12579 and c_effective_start_date between effective_start_date
12580 and effective_end_date ;
12581 --END TEMPIK
12582 /*TEMPIK
12583 and exists ( select null
12584 from BEN_PRTN_ELIG_PRFL_F CEP1
12585 where
12586 CEP1.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
12587 CEP1.PRTN_ELIG_ID = l_PRTN_ELIG_ID and
12588 CEP1.business_group_id = c_business_group_id
12589 and CEP1.effective_start_date <= c_effective_start_date )
12590 and exists ( select null
12591 from BEN_PRTN_ELIG_PRFL_F CEP2
12592 where
12593 CEP2.ELIGY_PRFL_ID = l_ELIGY_PRFL_ID and
12594 CEP2.PRTN_ELIG_ID = l_PRTN_ELIG_ID and
12595 CEP2.business_group_id = c_business_group_id
12596 and CEP2.effective_end_date >= c_effective_end_date )
12597 ;
12598 TEMPIK */
12599 --TEMPIK
12600 l_dt_rec_found boolean ;
12601 --END TEMPIK
12602 --
12603 --UPD START
12604 --
12605 l_update boolean := false ;
12606 l_datetrack_mode varchar2(80) := hr_api.g_update;
12607 l_process_date date;
12608 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
12609 --
12610 --UPD END
12611 l_current_pk_id number := null ;
12612 l_prev_pk_id number := null ;
12613 l_first_rec boolean := true ;
12614 r_CEP c_CEP%rowtype;
12615 l_prtn_elig_prfl_id number ;
12616 l_object_version_number number ;
12617 l_effective_start_date date ;
12618 l_effective_end_date date ;
12619 l_prefix pqh_copy_entity_attribs.information1%type := null;
12620 l_suffix pqh_copy_entity_attribs.information1%type := null;
12621 l_new_value number(15);
12622 l_object_found_in_target boolean := false ;
12623 l_min_esd date;
12624 l_max_eed date;
12625 l_effective_date date;
12626 --
12627 begin
12628 -- Initialization
12629 l_object_found_in_target := false ;
12630 -- End Initialization
12631 -- Derive the prefix - sufix
12632 if p_prefix_suffix_cd = 'PREFIX' then
12633 l_prefix := p_prefix_suffix_text ;
12634 elsif p_prefix_suffix_cd = 'SUFFIX' then
12635 l_suffix := p_prefix_suffix_text ;
12636 else
12637 l_prefix := null ;
12638 l_suffix := null ;
12639 end if ;
12640 -- End Prefix Sufix derivation
12641 for r_CEP_unique in c_unique_CEP('CEP') loop
12642
12643 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
12644 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12645 r_CEP_unique.information3 >=
12646 ben_pd_copy_to_ben_one.g_copy_effective_date)
12647 ) then
12648 --
12649 hr_utility.set_location(' r_CEP_unique.table_route_id '||r_CEP_unique.table_route_id,10);
12650 hr_utility.set_location(' r_CEP_unique.information1 '||r_CEP_unique.information1,10);
12651 hr_utility.set_location( 'r_CEP_unique.information2 '||r_CEP_unique.information2,10);
12652 hr_utility.set_location( 'r_CEP_unique.information3 '||r_CEP_unique.information3,10);
12653 -- If reuse objects flag is 'Y' then check for the object in the target business group
12654 -- if found insert the record into PLSql table and exit the loop else try create the
12655 -- object in the target business group
12656 --
12657 l_object_found_in_target := false ;
12658 --UPD START
12659 open c_CEP(r_CEP_unique.table_route_id,
12660 r_CEP_unique.information1,
12661 r_CEP_unique.information2,
12662 r_CEP_unique.information3 ) ;
12663 --
12664 fetch c_CEP into r_CEP ;
12665 --
12666 close c_CEP ;
12667 --
12668 l_dml_operation:= r_CEP_unique.dml_operation ;
12669 l_ELIGY_PRFL_ID := get_fk('ELIGY_PRFL_ID', r_CEP.INFORMATION263,l_dml_operation );
12670 l_PRTN_ELIG_ID := get_fk('PRTN_ELIG_ID', r_CEP.INFORMATION229,l_dml_operation );
12671 --
12672 l_update := false;
12673 l_process_date := p_effective_date;
12674 --
12675 if l_dml_operation = 'UPDATE' then
12676 --
12677 l_object_found_in_target := TRUE;
12678 --
12679 if l_process_date between r_CEP_unique.information2 and r_CEP_unique.information3 then
12680 l_update := true;
12681 if r_CEP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
12682 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PRTN_ELIG_PRFL_ID'
12683 then
12684 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PRTN_ELIG_PRFL_ID' ;
12685 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CEP_unique.information1 ;
12686 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_CEP_unique.information1 ;
12687 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
12688 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CEP_unique.table_route_id;
12689 --
12690 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
12691 --
12692 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
12693 --
12694 --DOUBT log_data('CEP',l_new_value,l_prefix || r_CEP_unique.name|| l_suffix,'REUSED');
12695 --
12696 end if ;
12697 hr_utility.set_location( 'found record for update',10);
12698 --
12699 else
12700 --
12701 l_update := false;
12702 --
12703 end if;
12704 else
12705 --
12706 --UPD END
12707 l_min_esd := null ;
12708 l_max_eed := null ;
12709 open c_CEP_min_max_dates(r_CEP_unique.table_route_id, r_CEP_unique.information1 ) ;
12710 fetch c_CEP_min_max_dates into l_min_esd,l_max_eed ;
12711 --
12712
12713 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12714 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
12715 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
12716 end if;
12717 l_min_esd := greatest(l_min_esd,r_CEP_unique.information2);
12718 /* open c_CEP(r_CEP_unique.table_route_id,
12719 r_CEP_unique.information1,
12720 r_CEP_unique.information2,
12721 r_CEP_unique.information3 ) ;
12722 --
12723 fetch c_CEP into r_CEP ;
12724 --
12725 close c_CEP ; */
12726 --
12727 if p_reuse_object_flag = 'Y' then
12728 if c_CEP_min_max_dates%found then
12729 -- cursor to find the object
12730 open c_find_CEP_in_target( l_min_esd,l_max_eed,
12731 p_target_business_group_id, nvl(l_prtn_elig_prfl_id, -999) ) ;
12732 fetch c_find_CEP_in_target into l_new_value ;
12733 if c_find_CEP_in_target%found then
12734 --
12735 --TEMPIK
12736 l_dt_rec_found := dt_api.check_min_max_dates
12737 (p_base_table_name => 'BEN_PRTN_ELIG_PRFL_F',
12738 p_base_key_column => 'PRTN_ELIG_PRFL_ID',
12739 p_base_key_value => l_new_value,
12740 p_from_date => l_min_esd,
12741 p_to_date => l_max_eed );
12742 if l_dt_rec_found THEN
12743 --END TEMPIK
12744 if r_CEP_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
12745 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PRTN_ELIG_PRFL_ID' then
12746 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PRTN_ELIG_PRFL_ID' ;
12747 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CEP_unique.information1 ;
12748 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
12749 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
12750 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CEP_unique.table_route_id;
12751 --
12752 -- 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) ;
12753 --
12754 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
12755 end if ;
12756 --
12757 l_object_found_in_target := true ;
12758 --TEMPIK
12759 end if; -- l_dt_rec_found
12760 --END TEMPIK
12761 end if;
12762 close c_find_CEP_in_target ;
12763 --
12764 end if;
12765 end if ;
12766 --
12767 close c_CEP_min_max_dates ;
12768 end if; --if p_dml_operation
12769 --
12770 if not l_object_found_in_target OR l_update then
12771 --
12772 l_current_pk_id := r_CEP.information1;
12773 --
12774 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
12775 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
12776 --
12777 if l_current_pk_id = l_prev_pk_id then
12778 --
12779 l_first_rec := false ;
12780 --
12781 else
12782 --
12783 l_first_rec := true ;
12784 --
12785 end if ;
12786 --
12787
12788 l_effective_date := r_CEP.information2;
12789 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12790 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
12791 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
12792 end if;
12793
12794 if l_first_rec and not l_update then
12795 -- Call Create routine.
12796 hr_utility.set_location(' BEN_PRTN_ELIG_PRFL_F CREATE_PRTN_ELIG_PRFL ',20);
12797 BEN_PRTN_ELIG_PRFL_API.CREATE_PRTN_ELIG_PRFL(
12798 --
12799 P_VALIDATE => false
12800 ,P_EFFECTIVE_DATE => l_effective_date
12801 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
12802 --
12803 ,P_CEP_ATTRIBUTE1 => r_CEP.INFORMATION111
12804 ,P_CEP_ATTRIBUTE10 => r_CEP.INFORMATION120
12805 ,P_CEP_ATTRIBUTE11 => r_CEP.INFORMATION121
12806 ,P_CEP_ATTRIBUTE12 => r_CEP.INFORMATION122
12807 ,P_CEP_ATTRIBUTE13 => r_CEP.INFORMATION123
12808 ,P_CEP_ATTRIBUTE14 => r_CEP.INFORMATION124
12809 ,P_CEP_ATTRIBUTE15 => r_CEP.INFORMATION125
12810 ,P_CEP_ATTRIBUTE16 => r_CEP.INFORMATION126
12811 ,P_CEP_ATTRIBUTE17 => r_CEP.INFORMATION127
12812 ,P_CEP_ATTRIBUTE18 => r_CEP.INFORMATION128
12813 ,P_CEP_ATTRIBUTE19 => r_CEP.INFORMATION129
12814 ,P_CEP_ATTRIBUTE2 => r_CEP.INFORMATION112
12815 ,P_CEP_ATTRIBUTE20 => r_CEP.INFORMATION130
12816 ,P_CEP_ATTRIBUTE21 => r_CEP.INFORMATION131
12817 ,P_CEP_ATTRIBUTE22 => r_CEP.INFORMATION132
12818 ,P_CEP_ATTRIBUTE23 => r_CEP.INFORMATION133
12819 ,P_CEP_ATTRIBUTE24 => r_CEP.INFORMATION134
12820 ,P_CEP_ATTRIBUTE25 => r_CEP.INFORMATION135
12821 ,P_CEP_ATTRIBUTE26 => r_CEP.INFORMATION136
12822 ,P_CEP_ATTRIBUTE27 => r_CEP.INFORMATION137
12823 ,P_CEP_ATTRIBUTE28 => r_CEP.INFORMATION138
12824 ,P_CEP_ATTRIBUTE29 => r_CEP.INFORMATION139
12825 ,P_CEP_ATTRIBUTE3 => r_CEP.INFORMATION113
12826 ,P_CEP_ATTRIBUTE30 => r_CEP.INFORMATION140
12827 ,P_CEP_ATTRIBUTE4 => r_CEP.INFORMATION114
12828 ,P_CEP_ATTRIBUTE5 => r_CEP.INFORMATION115
12829 ,P_CEP_ATTRIBUTE6 => r_CEP.INFORMATION116
12830 ,P_CEP_ATTRIBUTE7 => r_CEP.INFORMATION117
12831 ,P_CEP_ATTRIBUTE8 => r_CEP.INFORMATION118
12832 ,P_CEP_ATTRIBUTE9 => r_CEP.INFORMATION119
12833 ,P_CEP_ATTRIBUTE_CATEGORY => r_CEP.INFORMATION110
12834 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
12835 ,P_ELIG_PRFL_TYPE_CD => r_CEP.INFORMATION11
12836 ,P_MNDTRY_FLAG => r_CEP.INFORMATION12
12837 ,P_PRTN_ELIG_ID => l_PRTN_ELIG_ID
12838 ,P_PRTN_ELIG_PRFL_ID => l_prtn_elig_prfl_id
12839 ,p_COMPUTE_SCORE_FLAG => r_CEP.INFORMATION13 -- Bug 4242438
12840 --
12841 ,P_EFFECTIVE_START_DATE => l_effective_start_date
12842 ,P_EFFECTIVE_END_DATE => l_effective_end_date
12843 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12844 );
12845 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
12846 -- Update all relevent cer records with new pk_id
12847 hr_utility.set_location('Before plsql table ',222);
12848 hr_utility.set_location('new_value id '||l_prtn_elig_prfl_id,222);
12849 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PRTN_ELIG_PRFL_ID' ;
12850 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CEP.information1 ;
12851 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PRTN_ELIG_PRFL_ID ;
12852 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
12853 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CEP_unique.table_route_id;
12854 hr_utility.set_location('After plsql table ',222);
12855 --
12856 -- 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 ) ;
12857 --
12858 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
12859 --
12860 else
12861 --
12862 -- Call Update routine for the pk_id created in prev run .
12863 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
12864 hr_utility.set_location(' BEN_PRTN_ELIG_PRFL_F UPDATE_PRTN_ELIG_PRFL ',30);
12865 --UPD START
12866 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
12867 --
12868 if l_update then
12869 --
12870 l_datetrack_mode := r_CEP.datetrack_mode ;
12871 --
12872 get_dt_modes(
12873 p_effective_date => l_process_date,
12874 p_effective_end_date => r_CEP.information3,
12875 p_effective_start_date => r_CEP.information2,
12876 p_dml_operation => r_CEP.dml_operation,
12877 p_datetrack_mode => l_datetrack_mode );
12878 -- p_update => l_update
12879 --
12880 l_effective_date := l_process_date;
12881 l_PRTN_ELIG_PRFL_ID := r_CEP.information1;
12882 l_object_version_number := r_CEP.information265;
12883 --
12884 end if;
12885 --
12886 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
12887 --
12888 IF l_update OR l_dml_operation <> 'UPDATE' THEN
12889 --UPD END
12890 BEN_PRTN_ELIG_PRFL_API.UPDATE_PRTN_ELIG_PRFL(
12891 --
12892 P_VALIDATE => false
12893 ,P_EFFECTIVE_DATE => l_effective_date
12894 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
12895 --
12896 ,P_CEP_ATTRIBUTE1 => r_CEP.INFORMATION111
12897 ,P_CEP_ATTRIBUTE10 => r_CEP.INFORMATION120
12898 ,P_CEP_ATTRIBUTE11 => r_CEP.INFORMATION121
12899 ,P_CEP_ATTRIBUTE12 => r_CEP.INFORMATION122
12900 ,P_CEP_ATTRIBUTE13 => r_CEP.INFORMATION123
12901 ,P_CEP_ATTRIBUTE14 => r_CEP.INFORMATION124
12902 ,P_CEP_ATTRIBUTE15 => r_CEP.INFORMATION125
12903 ,P_CEP_ATTRIBUTE16 => r_CEP.INFORMATION126
12904 ,P_CEP_ATTRIBUTE17 => r_CEP.INFORMATION127
12905 ,P_CEP_ATTRIBUTE18 => r_CEP.INFORMATION128
12906 ,P_CEP_ATTRIBUTE19 => r_CEP.INFORMATION129
12907 ,P_CEP_ATTRIBUTE2 => r_CEP.INFORMATION112
12908 ,P_CEP_ATTRIBUTE20 => r_CEP.INFORMATION130
12909 ,P_CEP_ATTRIBUTE21 => r_CEP.INFORMATION131
12910 ,P_CEP_ATTRIBUTE22 => r_CEP.INFORMATION132
12911 ,P_CEP_ATTRIBUTE23 => r_CEP.INFORMATION133
12912 ,P_CEP_ATTRIBUTE24 => r_CEP.INFORMATION134
12913 ,P_CEP_ATTRIBUTE25 => r_CEP.INFORMATION135
12914 ,P_CEP_ATTRIBUTE26 => r_CEP.INFORMATION136
12915 ,P_CEP_ATTRIBUTE27 => r_CEP.INFORMATION137
12916 ,P_CEP_ATTRIBUTE28 => r_CEP.INFORMATION138
12917 ,P_CEP_ATTRIBUTE29 => r_CEP.INFORMATION139
12918 ,P_CEP_ATTRIBUTE3 => r_CEP.INFORMATION113
12919 ,P_CEP_ATTRIBUTE30 => r_CEP.INFORMATION140
12920 ,P_CEP_ATTRIBUTE4 => r_CEP.INFORMATION114
12921 ,P_CEP_ATTRIBUTE5 => r_CEP.INFORMATION115
12922 ,P_CEP_ATTRIBUTE6 => r_CEP.INFORMATION116
12923 ,P_CEP_ATTRIBUTE7 => r_CEP.INFORMATION117
12924 ,P_CEP_ATTRIBUTE8 => r_CEP.INFORMATION118
12925 ,P_CEP_ATTRIBUTE9 => r_CEP.INFORMATION119
12926 ,P_CEP_ATTRIBUTE_CATEGORY => r_CEP.INFORMATION110
12927 ,P_ELIGY_PRFL_ID => l_ELIGY_PRFL_ID
12928 ,P_ELIG_PRFL_TYPE_CD => r_CEP.INFORMATION11
12929 ,P_MNDTRY_FLAG => r_CEP.INFORMATION12
12930 ,P_PRTN_ELIG_ID => l_PRTN_ELIG_ID
12931 ,P_PRTN_ELIG_PRFL_ID => l_prtn_elig_prfl_id
12932 ,p_COMPUTE_SCORE_FLAG => r_CEP.INFORMATION13 -- bug 4242438
12933 --
12934 ,P_EFFECTIVE_START_DATE => l_effective_start_date
12935 ,P_EFFECTIVE_END_DATE => l_effective_end_date
12936 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12937 ,P_DATETRACK_MODE => l_datetrack_mode
12938 );
12939 --
12940 end if; -- l_update
12941 end if;
12942 --
12943 -- Delete the row if it is end dated.
12944 --
12945 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
12946 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
12947 trunc(l_max_eed) = r_CEP.information3) then
12948 --
12949 BEN_PRTN_ELIG_PRFL_API.delete_PRTN_ELIG_PRFL(
12950 --
12951 p_validate => false
12952 ,p_prtn_elig_prfl_id => l_prtn_elig_prfl_id
12953 ,p_effective_start_date => l_effective_start_date
12954 ,p_effective_end_date => l_effective_end_date
12955 ,p_object_version_number => l_object_version_number
12956 ,p_effective_date => l_max_eed
12957 ,p_datetrack_mode => hr_api.g_delete
12958 --
12959 );
12960 --
12961 end if;
12962 --
12963 l_prev_pk_id := l_current_pk_id ;
12964 --
12965 end if;
12966 --
12967 end if;
12968 --
12969 end loop;
12970 --
12971 exception when others then
12972 --
12973 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CEP',r_cep.information5 );
12974 --
12975 end create_CEP_rows;
12976
12977 --
12978 ---------------------------------------------------------------
12979 ----------------------< create_CPR_rows >-----------------------
12980 ---------------------------------------------------------------
12981 --
12982 procedure create_CPR_rows
12983 (
12984 p_validate in number default 0
12985 ,p_copy_entity_txn_id in number
12986 ,p_effective_date in date
12987 ,p_prefix_suffix_text in varchar2 default null
12988 ,p_reuse_object_flag in varchar2 default null
12989 ,p_target_business_group_id in varchar2 default null
12990 ,p_prefix_suffix_cd in varchar2 default null
12991 ) is
12992 --
12993 l_POPL_ORG_ID number;
12994 l_NAME BEN_POPL_ORG_ROLE_F.name%TYPE ;
12995 l_org_role_typ_cd BEN_POPL_ORG_ROLE_F.org_role_typ_cd%TYPE;
12996 --
12997 cursor c_unique_CPR(l_table_alias varchar2) is
12998 select distinct cpe.information1,
12999 cpe.information2,
13000 cpe.information3,
13001 cpe.table_route_id
13002 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
13003 pqh_table_route tr
13004 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13005 and cpe.table_route_id = tr.table_route_id
13006 -- and tr.where_clause = l_BEN_POPL_ORG_ROLE_F
13007 and tr.table_alias = l_table_alias
13008 and cpe.number_of_copies = 1 -- ADDITION
13009 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
13010 order by information1, information2; --added for bug: 5151945
13011 --
13012 --
13013 cursor c_CPR_min_max_dates(c_table_route_id number,
13014 c_information1 number) is
13015 select
13016 min(cpe.information2) min_esd,
13017 max(cpe.information3) min_eed
13018 from ben_copy_entity_results cpe
13019 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13020 and cpe.table_route_id = c_table_route_id
13021 and cpe.information1 = c_information1 ;
13022 --
13023 cursor c_CPR(c_table_route_id number,
13024 c_information1 number,
13025 c_information2 date,
13026 c_information3 date ) is
13027 select
13028 cpe.*
13029 from ben_copy_entity_results cpe
13030 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13031 and cpe.table_route_id = c_table_route_id
13032 and cpe.information1 = c_information1
13033 and cpe.information2 = c_information2
13034 and cpe.information3 = c_information3
13035 and rownum = 1 ;
13036 -- Date Track target record
13037 cursor c_find_CPR_in_target(
13038 c_effective_start_date date,
13039 c_effective_end_date date,
13040 c_business_group_id number,
13041 c_new_pk_id number) is
13042 select
13043 CPR.popl_org_role_id new_value
13044 from BEN_POPL_ORG_ROLE_F CPR
13045 where
13046 CPR.POPL_ORG_ID = l_POPL_ORG_ID and
13047 CPR.NAME = l_NAME and
13048 CPR.org_role_typ_cd= l_org_role_typ_cd and
13049 CPR.business_group_id = c_business_group_id
13050 and CPR.popl_org_role_id <> c_new_pk_id
13051 --TEMPIK
13052 and c_effective_start_date between effective_start_date
13053 and effective_end_date ;
13054 --END TEMPIK
13055 /*TEMPIK
13056 and exists ( select null
13057 from BEN_POPL_ORG_ROLE_F CPR1
13058 where
13059 CPR1.POPL_ORG_ID = l_POPL_ORG_ID and
13060 CPR1.NAME = l_NAME and
13061 CPR1.org_role_typ_cd= l_org_role_typ_cd and
13062 CPR1.business_group_id = c_business_group_id
13063 and CPR1.effective_start_date <= c_effective_start_date )
13064 and exists ( select null
13065 from BEN_POPL_ORG_ROLE_F CPR2
13066 where
13067 CPR2.POPL_ORG_ID = l_POPL_ORG_ID and
13068 CPR2.NAME = l_NAME and
13069 CPR2.org_role_typ_cd= l_org_role_typ_cd and
13070 CPR2.business_group_id = c_business_group_id
13071 and CPR2.effective_end_date >= c_effective_end_date )
13072 ;
13073 TEMPIK */
13074 --TEMPIK
13075 l_dt_rec_found boolean ;
13076 --END TEMPIK
13077 --
13078 --UPD START
13079 --
13080 l_update boolean := false ;
13081 l_datetrack_mode varchar2(80) := hr_api.g_update;
13082 l_process_date date;
13083 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
13084 --
13085 --UPD END
13086 l_current_pk_id number := null ;
13087 l_prev_pk_id number := null ;
13088 l_first_rec boolean := true ;
13089 r_CPR c_CPR%rowtype;
13090 l_popl_org_role_id number ;
13091 l_object_version_number number ;
13092 l_effective_start_date date ;
13093 l_effective_end_date date ;
13094 l_prefix pqh_copy_entity_attribs.information1%type := null;
13095 l_suffix pqh_copy_entity_attribs.information1%type := null;
13096 l_new_value number(15);
13097 l_object_found_in_target boolean := false ;
13098 l_min_esd date;
13099 l_max_eed date;
13100 l_effective_date date;
13101 --
13102 begin
13103 -- Initialization
13104 l_object_found_in_target := false ;
13105 -- End Initialization
13106 -- Derive the prefix - sufix
13107 if p_prefix_suffix_cd = 'PREFIX' then
13108 l_prefix := p_prefix_suffix_text ;
13109 elsif p_prefix_suffix_cd = 'SUFFIX' then
13110 l_suffix := p_prefix_suffix_text ;
13111 else
13112 l_prefix := null ;
13113 l_suffix := null ;
13114 end if ;
13115 -- End Prefix Sufix derivation
13116 for r_CPR_unique in c_unique_CPR('CPR') loop
13117
13118 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
13119 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13120 r_CPR_unique.information3 >=
13121 ben_pd_copy_to_ben_one.g_copy_effective_date)
13122 ) then
13123 --
13124 hr_utility.set_location(' r_CPR_unique.table_route_id '||r_CPR_unique.table_route_id,10);
13125 hr_utility.set_location(' r_CPR_unique.information1 '||r_CPR_unique.information1,10);
13126 hr_utility.set_location( 'r_CPR_unique.information2 '||r_CPR_unique.information2,10);
13127 hr_utility.set_location( 'r_CPR_unique.information3 '||r_CPR_unique.information3,10);
13128 -- If reuse objects flag is 'Y' then check for the object in the target business group
13129 -- if found insert the record into PLSql table and exit the loop else try create the
13130 -- object in the target business group
13131 --
13132 l_object_found_in_target := false ;
13133 --UPD START
13134 open c_CPR(r_CPR_unique.table_route_id,
13135 r_CPR_unique.information1,
13136 r_CPR_unique.information2,
13137 r_CPR_unique.information3 ) ;
13138 --
13139 fetch c_CPR into r_CPR ;
13140 --
13141 close c_CPR ;
13142 --
13143 l_dml_operation:= r_CPR_unique.dml_operation ;
13144 l_POPL_ORG_ID := get_fk('POPL_ORG_ID', r_CPR.INFORMATION260,l_dml_operation);
13145 l_NAME := r_CPR.information170 ;
13146 l_org_role_typ_cd := r_CPR.information11 ;
13147 --
13148 l_update := false;
13149 l_process_date := p_effective_date;
13150 --
13151 if l_dml_operation = 'UPDATE' then
13152 --
13153 l_object_found_in_target := TRUE;
13154 --
13155 if l_process_date between r_CPR_unique.information2 and r_CPR_unique.information3 then
13156 l_update := true;
13157 if r_CPR_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
13158 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'POPL_ORG_ROLE_ID'
13159 then
13160 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ORG_ROLE_ID' ;
13161 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPR_unique.information1 ;
13162 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_CPR_unique.information1 ;
13163 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
13164 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CPR_unique.table_route_id;
13165 --
13166 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
13167 --
13168 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
13169 --
13170 --DOUBT log_data('CPR',l_new_value,l_prefix || r_CPR_unique.name|| l_suffix,'REUSED');
13171 --
13172 end if ;
13173 hr_utility.set_location( 'found record for update',10);
13174 --
13175 else
13176 --
13177 l_update := false;
13178 --
13179 end if;
13180 else
13181 --
13182 --UPD END
13183 l_min_esd := null ;
13184 l_max_eed := null ;
13185 open c_CPR_min_max_dates(r_CPR_unique.table_route_id, r_CPR_unique.information1 ) ;
13186 fetch c_CPR_min_max_dates into l_min_esd,l_max_eed ;
13187 --
13188
13189 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13190 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
13191 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
13192 end if;
13193 l_min_esd := greatest(l_min_esd,r_CPR_unique.information2);
13194 /* open c_CPR(r_CPR_unique.table_route_id,
13195 r_CPR_unique.information1,
13196 r_CPR_unique.information2,
13197 r_CPR_unique.information3 ) ;
13198 --
13199 fetch c_CPR into r_CPR ;
13200 --
13201 close c_CPR ; */
13202 --
13203 --
13204 if l_POPL_ORG_ID is null then
13205 close c_CPR_min_max_dates;
13206 else
13207 if p_reuse_object_flag = 'Y' then
13208 if c_CPR_min_max_dates%found then
13209 -- cursor to find the object
13210 open c_find_CPR_in_target( l_min_esd,l_max_eed,
13211 p_target_business_group_id, nvl(l_popl_org_role_id, -999) ) ;
13212 fetch c_find_CPR_in_target into l_new_value ;
13213 if c_find_CPR_in_target%found then
13214 --
13215 --TEMPIK
13216 l_dt_rec_found := dt_api.check_min_max_dates
13217 (p_base_table_name => 'BEN_POPL_ORG_ROLE_F',
13218 p_base_key_column => 'POPL_ORG_ROLE_ID',
13219 p_base_key_value => l_new_value,
13220 p_from_date => l_min_esd,
13221 p_to_date => l_max_eed );
13222 if l_dt_rec_found THEN
13223 --END TEMPIK
13224 if r_CPR_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
13225 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'POPL_ORG_ROLE_ID' then
13226 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ORG_ROLE_ID' ;
13227 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPR_unique.information1 ;
13228 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
13229 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
13230 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CPR_unique.table_route_id;
13231 --
13232 -- 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) ;
13233 --
13234 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
13235 end if ;
13236 --
13237 l_object_found_in_target := true ;
13238 --TEMPIK
13239 end if; -- l_dt_rec_found
13240 --END TEMPIK
13241 end if;
13242 close c_find_CPR_in_target ;
13243 --
13244 end if;
13245 end if ;
13246 --
13247 close c_CPR_min_max_dates ;
13248 end if; --if p_dml_operation
13249 --
13250 if ( not l_object_found_in_target OR l_update ) and l_POPL_ORG_ID is not null then
13251 --
13252 l_current_pk_id := r_CPR.information1;
13253 --
13254 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
13255 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
13256 --
13257 if l_current_pk_id = l_prev_pk_id then
13258 --
13259 l_first_rec := false ;
13260 --
13261 else
13262 --
13263 l_first_rec := true ;
13264 --
13265 end if ;
13266 --
13267 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_POPL_ORG_ROLE_F',l_prefix || r_CPR.information170 || l_suffix);
13268 --
13269
13270 l_effective_date := r_CPR.information2;
13271 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13272 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
13273 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
13274 end if;
13275
13276 if l_first_rec and not l_update then
13277 -- Call Create routine.
13278 hr_utility.set_location(' BEN_POPL_ORG_ROLE_F CREATE_POPL_ORG_ROLE ',20);
13279 BEN_POPL_ORG_ROLE_API.CREATE_POPL_ORG_ROLE(
13280 --
13281 P_VALIDATE => false
13282 ,P_EFFECTIVE_DATE => l_effective_date
13283 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
13284 --
13285 ,P_CPR_ATTRIBUTE1 => r_CPR.INFORMATION111
13286 ,P_CPR_ATTRIBUTE10 => r_CPR.INFORMATION120
13287 ,P_CPR_ATTRIBUTE11 => r_CPR.INFORMATION121
13288 ,P_CPR_ATTRIBUTE12 => r_CPR.INFORMATION122
13289 ,P_CPR_ATTRIBUTE13 => r_CPR.INFORMATION123
13290 ,P_CPR_ATTRIBUTE14 => r_CPR.INFORMATION124
13291 ,P_CPR_ATTRIBUTE15 => r_CPR.INFORMATION125
13292 ,P_CPR_ATTRIBUTE16 => r_CPR.INFORMATION126
13293 ,P_CPR_ATTRIBUTE17 => r_CPR.INFORMATION127
13294 ,P_CPR_ATTRIBUTE18 => r_CPR.INFORMATION128
13295 ,P_CPR_ATTRIBUTE19 => r_CPR.INFORMATION129
13296 ,P_CPR_ATTRIBUTE2 => r_CPR.INFORMATION112
13297 ,P_CPR_ATTRIBUTE20 => r_CPR.INFORMATION130
13298 ,P_CPR_ATTRIBUTE21 => r_CPR.INFORMATION131
13299 ,P_CPR_ATTRIBUTE22 => r_CPR.INFORMATION132
13300 ,P_CPR_ATTRIBUTE23 => r_CPR.INFORMATION133
13301 ,P_CPR_ATTRIBUTE24 => r_CPR.INFORMATION134
13302 ,P_CPR_ATTRIBUTE25 => r_CPR.INFORMATION135
13303 ,P_CPR_ATTRIBUTE26 => r_CPR.INFORMATION136
13304 ,P_CPR_ATTRIBUTE27 => r_CPR.INFORMATION137
13305 ,P_CPR_ATTRIBUTE28 => r_CPR.INFORMATION138
13306 ,P_CPR_ATTRIBUTE29 => r_CPR.INFORMATION139
13307 ,P_CPR_ATTRIBUTE3 => r_CPR.INFORMATION113
13308 ,P_CPR_ATTRIBUTE30 => r_CPR.INFORMATION140
13309 ,P_CPR_ATTRIBUTE4 => r_CPR.INFORMATION114
13310 ,P_CPR_ATTRIBUTE5 => r_CPR.INFORMATION115
13311 ,P_CPR_ATTRIBUTE6 => r_CPR.INFORMATION116
13312 ,P_CPR_ATTRIBUTE7 => r_CPR.INFORMATION117
13313 ,P_CPR_ATTRIBUTE8 => r_CPR.INFORMATION118
13314 ,P_CPR_ATTRIBUTE9 => r_CPR.INFORMATION119
13315 ,P_CPR_ATTRIBUTE_CATEGORY => r_CPR.INFORMATION110
13316 ,P_NAME => l_prefix || r_CPR.INFORMATION170 || l_suffix
13317 ,P_ORG_ROLE_TYP_CD => r_CPR.INFORMATION11
13318 ,P_POPL_ORG_ID => l_POPL_ORG_ID
13319 ,P_POPL_ORG_ROLE_ID => l_popl_org_role_id
13320 --
13321 ,P_EFFECTIVE_START_DATE => l_effective_start_date
13322 ,P_EFFECTIVE_END_DATE => l_effective_end_date
13323 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
13324 );
13325 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
13326 -- Update all relevent cer records with new pk_id
13327 hr_utility.set_location('Before plsql table ',222);
13328 hr_utility.set_location('new_value id '||l_popl_org_role_id,222);
13329 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ORG_ROLE_ID' ;
13330 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPR.information1 ;
13331 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_POPL_ORG_ROLE_ID ;
13332 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
13333 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CPR_unique.table_route_id;
13334 hr_utility.set_location('After plsql table ',222);
13335 --
13336 -- 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 ) ;
13337 --
13338 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
13339 --
13340 else
13341 --
13342 -- Call Update routine for the pk_id created in prev run .
13343 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
13344 hr_utility.set_location(' BEN_POPL_ORG_ROLE_F UPDATE_POPL_ORG_ROLE ',30);
13345 --UPD START
13346 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
13347 --
13348 if l_update then
13349 --
13350 l_datetrack_mode := r_CPR.datetrack_mode ;
13351 --
13352 get_dt_modes(
13353 p_effective_date => l_process_date,
13354 p_effective_end_date => r_CPR.information3,
13355 p_effective_start_date => r_CPR.information2,
13356 p_dml_operation => r_CPR.dml_operation,
13357 p_datetrack_mode => l_datetrack_mode );
13358 -- p_update => l_update
13359 --
13360 l_effective_date := l_process_date;
13361 l_POPL_ORG_ROLE_ID := r_CPR.information1;
13362 l_object_version_number := r_CPR.information265;
13363 --
13364 end if;
13365 --
13366 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
13367 --
13368 IF l_update OR l_dml_operation <> 'UPDATE' THEN
13369 --UPD END
13370 BEN_POPL_ORG_ROLE_API.UPDATE_POPL_ORG_ROLE(
13371 --
13372 P_VALIDATE => false
13373 ,P_EFFECTIVE_DATE => l_effective_date
13374 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
13375 --
13376 ,P_CPR_ATTRIBUTE1 => r_CPR.INFORMATION111
13377 ,P_CPR_ATTRIBUTE10 => r_CPR.INFORMATION120
13378 ,P_CPR_ATTRIBUTE11 => r_CPR.INFORMATION121
13379 ,P_CPR_ATTRIBUTE12 => r_CPR.INFORMATION122
13380 ,P_CPR_ATTRIBUTE13 => r_CPR.INFORMATION123
13381 ,P_CPR_ATTRIBUTE14 => r_CPR.INFORMATION124
13382 ,P_CPR_ATTRIBUTE15 => r_CPR.INFORMATION125
13383 ,P_CPR_ATTRIBUTE16 => r_CPR.INFORMATION126
13384 ,P_CPR_ATTRIBUTE17 => r_CPR.INFORMATION127
13385 ,P_CPR_ATTRIBUTE18 => r_CPR.INFORMATION128
13386 ,P_CPR_ATTRIBUTE19 => r_CPR.INFORMATION129
13387 ,P_CPR_ATTRIBUTE2 => r_CPR.INFORMATION112
13388 ,P_CPR_ATTRIBUTE20 => r_CPR.INFORMATION130
13389 ,P_CPR_ATTRIBUTE21 => r_CPR.INFORMATION131
13390 ,P_CPR_ATTRIBUTE22 => r_CPR.INFORMATION132
13391 ,P_CPR_ATTRIBUTE23 => r_CPR.INFORMATION133
13392 ,P_CPR_ATTRIBUTE24 => r_CPR.INFORMATION134
13393 ,P_CPR_ATTRIBUTE25 => r_CPR.INFORMATION135
13394 ,P_CPR_ATTRIBUTE26 => r_CPR.INFORMATION136
13395 ,P_CPR_ATTRIBUTE27 => r_CPR.INFORMATION137
13396 ,P_CPR_ATTRIBUTE28 => r_CPR.INFORMATION138
13397 ,P_CPR_ATTRIBUTE29 => r_CPR.INFORMATION139
13398 ,P_CPR_ATTRIBUTE3 => r_CPR.INFORMATION113
13399 ,P_CPR_ATTRIBUTE30 => r_CPR.INFORMATION140
13400 ,P_CPR_ATTRIBUTE4 => r_CPR.INFORMATION114
13401 ,P_CPR_ATTRIBUTE5 => r_CPR.INFORMATION115
13402 ,P_CPR_ATTRIBUTE6 => r_CPR.INFORMATION116
13403 ,P_CPR_ATTRIBUTE7 => r_CPR.INFORMATION117
13404 ,P_CPR_ATTRIBUTE8 => r_CPR.INFORMATION118
13405 ,P_CPR_ATTRIBUTE9 => r_CPR.INFORMATION119
13406 ,P_CPR_ATTRIBUTE_CATEGORY => r_CPR.INFORMATION110
13407 ,P_NAME => l_prefix || r_CPR.INFORMATION170 || l_suffix
13408 ,P_ORG_ROLE_TYP_CD => r_CPR.INFORMATION11
13409 ,P_POPL_ORG_ID => l_POPL_ORG_ID
13410 ,P_POPL_ORG_ROLE_ID => l_popl_org_role_id
13411 --
13412 ,P_EFFECTIVE_START_DATE => l_effective_start_date
13413 ,P_EFFECTIVE_END_DATE => l_effective_end_date
13414 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
13415 ,P_DATETRACK_MODE => l_datetrack_mode
13416 );
13417 --
13418 end if; -- l_update
13419 end if;
13420 --
13421 -- Delete the row if it is end dated.
13422 --
13423 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
13424 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
13425 trunc(l_max_eed) = r_CPR.information3) then
13426 --
13427 BEN_POPL_ORG_ROLE_API.delete_POPL_ORG_ROLE(
13428 --
13429 p_validate => false
13430 ,p_popl_org_role_id => l_popl_org_role_id
13431 ,p_effective_start_date => l_effective_start_date
13432 ,p_effective_end_date => l_effective_end_date
13433 ,p_object_version_number => l_object_version_number
13434 ,p_effective_date => l_max_eed
13435 ,p_datetrack_mode => hr_api.g_delete
13436 --
13437 );
13438 --
13439 end if;
13440 --
13441 l_prev_pk_id := l_current_pk_id ;
13442 --
13443 end if;
13444 --
13445 end if;
13446 --
13447 end if;
13448 --
13449 end loop;
13450 --
13451 exception when others then
13452 --
13453 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CPR',l_prefix || r_CPR.information170 || l_suffix);
13454 --
13455 end create_CPR_rows;
13456
13457 --
13458 ---------------------------------------------------------------
13459 ----------------------< create_CPO_rows >-----------------------
13460 ---------------------------------------------------------------
13461 --
13462 procedure create_CPO_rows
13463 (
13464 p_validate in number default 0
13465 ,p_copy_entity_txn_id in number
13466 ,p_effective_date in date
13467 ,p_prefix_suffix_text in varchar2 default null
13468 ,p_reuse_object_flag in varchar2 default null
13469 ,p_target_business_group_id in varchar2 default null
13470 ,p_prefix_suffix_cd in varchar2 default null
13471 ) is
13472 --
13473 l_ORGANIZATION_ID number;
13474 l_PERSON_ID number;
13475 l_PGM_ID number;
13476 l_PL_ID number;
13477 cursor c_unique_CPO(l_table_alias varchar2) is
13478 select distinct cpe.information1,
13479 cpe.information2,
13480 cpe.information3,
13481 cpe.table_route_id
13482 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
13483 pqh_table_route tr
13484 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13485 and cpe.table_route_id = tr.table_route_id
13486 -- and tr.where_clause = l_BEN_POPL_ORG_F
13487 and tr.table_alias = l_table_alias
13488 and cpe.number_of_copies = 1 -- ADDITION
13489 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
13490 order by information1, information2; --added for bug: 5151945
13491 --
13492 --
13493 cursor c_CPO_min_max_dates(c_table_route_id number,
13494 c_information1 number) is
13495 select
13496 min(cpe.information2) min_esd,
13497 max(cpe.information3) min_eed
13498 from ben_copy_entity_results cpe
13499 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13500 and cpe.table_route_id = c_table_route_id
13501 and cpe.information1 = c_information1 ;
13502 --
13503 cursor c_CPO(c_table_route_id number,
13504 c_information1 number,
13505 c_information2 date,
13506 c_information3 date ) is
13507 select
13508 cpe.*
13509 from ben_copy_entity_results cpe
13510 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13511 and cpe.table_route_id = c_table_route_id
13512 and cpe.information1 = c_information1
13513 and cpe.information2 = c_information2
13514 and cpe.information3 = c_information3
13515 and rownum = 1 ;
13516 -- Date Track target record
13517 cursor c_find_CPO_in_target(
13518 c_effective_start_date date,
13519 c_effective_end_date date,
13520 c_business_group_id number,
13521 c_new_pk_id number) is
13522 select
13523 CPO.popl_org_id new_value
13524 from BEN_POPL_ORG_F CPO
13525 where
13526 CPO.ORGANIZATION_ID = l_ORGANIZATION_ID and
13527 nvl(CPO.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
13528 nvl(CPO.PL_ID,-999) = nvl(l_PL_ID,-999) and
13529 CPO.business_group_id = c_business_group_id
13530 and CPO.popl_org_id <> c_new_pk_id
13531 --TEMPIK
13532 and c_effective_start_date between effective_start_date
13533 and effective_end_date ;
13534 --END TEMPIK
13535 /*TEMPIK
13536 and exists ( select null
13537 from BEN_POPL_ORG_F CPO1
13538 where
13539 CPO1.ORGANIZATION_ID = l_ORGANIZATION_ID and
13540 nvl(CPO1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
13541 nvl(CPO1.PL_ID,-999) = nvl(l_PL_ID,-999) and
13542 CPO1.business_group_id = c_business_group_id
13543 and CPO1.effective_start_date <= c_effective_start_date )
13544 and exists ( select null
13545 from BEN_POPL_ORG_F CPO2
13546 where
13547 CPO2.ORGANIZATION_ID = l_ORGANIZATION_ID and
13548 nvl(CPO2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
13549 nvl(CPO2.PL_ID,-999) = nvl(l_PL_ID,-999) and
13550 CPO2.business_group_id = c_business_group_id
13551 and CPO2.effective_end_date >= c_effective_end_date )
13552 ;
13553 TEMPIK */
13554 --TEMPIK
13555 l_dt_rec_found boolean ;
13556 --END TEMPIK
13557 --
13558 --UPD START
13559 --
13560 l_update boolean := false ;
13561 l_datetrack_mode varchar2(80) := hr_api.g_update;
13562 l_process_date date;
13563 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
13564 --
13565 --UPD END
13566 l_current_pk_id number := null ;
13567 l_prev_pk_id number := null ;
13568 l_first_rec boolean := true ;
13569 r_CPO c_CPO%rowtype;
13570 l_popl_org_id number ;
13571 l_object_version_number number ;
13572 l_effective_start_date date ;
13573 l_effective_end_date date ;
13574 l_prefix pqh_copy_entity_attribs.information1%type := null;
13575 l_suffix pqh_copy_entity_attribs.information1%type := null;
13576 l_new_value number(15);
13577 l_object_found_in_target boolean := false ;
13578 l_min_esd date;
13579 l_max_eed date;
13580 l_effective_date date;
13581 --
13582 begin
13583 -- Initialization
13584 l_object_found_in_target := false ;
13585 -- End Initialization
13586 -- Derive the prefix - sufix
13587 if p_prefix_suffix_cd = 'PREFIX' then
13588 l_prefix := p_prefix_suffix_text ;
13589 elsif p_prefix_suffix_cd = 'SUFFIX' then
13590 l_suffix := p_prefix_suffix_text ;
13591 else
13592 l_prefix := null ;
13593 l_suffix := null ;
13594 end if ;
13595 -- End Prefix Sufix derivation
13596 for r_CPO_unique in c_unique_CPO('CPO') loop
13597
13598 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
13599 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13600 r_CPO_unique.information3 >=
13601 ben_pd_copy_to_ben_one.g_copy_effective_date)
13602 ) then
13603 --
13604 hr_utility.set_location(' r_CPO_unique.table_route_id '||r_CPO_unique.table_route_id,10);
13605 hr_utility.set_location(' r_CPO_unique.information1 '||r_CPO_unique.information1,10);
13606 hr_utility.set_location( 'r_CPO_unique.information2 '||r_CPO_unique.information2,10);
13607 hr_utility.set_location( 'r_CPO_unique.information3 '||r_CPO_unique.information3,10);
13608 -- If reuse objects flag is 'Y' then check for the object in the target business group
13609 -- if found insert the record into PLSql table and exit the loop else try create the
13610 -- object in the target business group
13611 --
13612 l_object_found_in_target := false ;
13613 --UPD START
13614 open c_CPO(r_CPO_unique.table_route_id,
13615 r_CPO_unique.information1,
13616 r_CPO_unique.information2,
13617 r_CPO_unique.information3 ) ;
13618 --
13619 fetch c_CPO into r_CPO ;
13620 --
13621 close c_CPO ;
13622 --
13623 l_dml_operation:= r_CPO_unique.dml_operation ;
13624 l_PERSON_ID := get_fk('PERSON_ID', r_CPO.INFORMATION258,l_dml_operation );
13625 l_PGM_ID := get_fk('PGM_ID', r_CPO.INFORMATION260,l_dml_operation );
13626 l_PL_ID := get_fk('PL_ID', r_CPO.INFORMATION261,l_dml_operation );
13627 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
13628 l_ORGANIZATION_ID := r_CPO.information176 ;
13629 else
13630 l_ORGANIZATION_ID := r_CPO.information174 ;
13631 end if;
13632 --
13633 l_update := false;
13634 l_process_date := p_effective_date;
13635 --
13636 if l_dml_operation = 'UPDATE' then
13637 --
13638 l_object_found_in_target := TRUE;
13639 --
13640 if l_process_date between r_CPO_unique.information2 and r_CPO_unique.information3 then
13641 l_update := true;
13642 if r_CPO_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
13643 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'POPL_ORG_ID'
13644 then
13645 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ORG_ID' ;
13646 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPO_unique.information1 ;
13647 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_CPO_unique.information1 ;
13648 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
13649 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CPO_unique.table_route_id;
13650 --
13651 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
13652 --
13653 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
13654 --
13655 --DOUBT log_data('CPO',l_new_value,l_prefix || r_CPO_unique.name|| l_suffix,'REUSED');
13656 --
13657 end if ;
13658 hr_utility.set_location( 'found record for update',10);
13659 --
13660 else
13661 --
13662 l_update := false;
13663 --
13664 end if;
13665 else
13666 --
13667 --UPD END
13668 l_min_esd := null ;
13669 l_max_eed := null ;
13670 open c_CPO_min_max_dates(r_CPO_unique.table_route_id, r_CPO_unique.information1 ) ;
13671 fetch c_CPO_min_max_dates into l_min_esd,l_max_eed ;
13672 --
13673
13674 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13675 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
13676 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
13677 end if;
13678 l_min_esd := greatest(l_min_esd,r_CPO_unique.information2);
13679 /* open c_CPO(r_CPO_unique.table_route_id,
13680 r_CPO_unique.information1,
13681 r_CPO_unique.information2,
13682 r_CPO_unique.information3 ) ;
13683 --
13684 fetch c_CPO into r_CPO ;
13685 --
13686 close c_CPO ;
13687 --
13688 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
13689 l_ORGANIZATION_ID := r_CPO.information176 ;
13690 else
13691 l_ORGANIZATION_ID := r_CPO.information174 ;
13692 end if;
13693 */
13694 --
13695 if l_ORGANIZATION_ID is null then
13696 close c_CPO_min_max_dates;
13697 --
13698 -- DATA not COPIED
13699 --
13700 if l_PGM_ID is not null then
13701 --
13702 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'PGM'
13703 ,p_parent_pk_id => r_CPO.information260
13704 ,p_copy_entity_txn_id => p_copy_entity_txn_id
13705 ,p_child_table_alias => 'CPO'
13706 ,p_child_data => r_CPO.information173 );
13707 else
13708 --
13709 BEN_PD_COPY_TO_BEN_three.log_nomapping_data(p_parent_table_alias =>'PLN'
13710 ,p_parent_pk_id => r_CPO.information261
13711 ,p_copy_entity_txn_id => p_copy_entity_txn_id
13712 ,p_child_table_alias => 'CPO'
13713 ,p_child_data => r_CPO.information173 );
13714 --
13715 end if;
13716 --
13717 else
13718 if p_reuse_object_flag = 'Y' then
13719 if c_CPO_min_max_dates%found then
13720 -- cursor to find the object
13721 open c_find_CPO_in_target( l_min_esd,l_max_eed,
13722 p_target_business_group_id, nvl(l_popl_org_id, -999) ) ;
13723 fetch c_find_CPO_in_target into l_new_value ;
13724 if c_find_CPO_in_target%found then
13725 --
13726 --TEMPIK
13727 l_dt_rec_found := dt_api.check_min_max_dates
13728 (p_base_table_name => 'BEN_POPL_ORG_F',
13729 p_base_key_column => 'POPL_ORG_ID',
13730 p_base_key_value => l_new_value,
13731 p_from_date => l_min_esd,
13732 p_to_date => l_max_eed );
13733 if l_dt_rec_found THEN
13734 --END TEMPIK
13735 if r_CPO_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
13736 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'POPL_ORG_ID' then
13737 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ORG_ID' ;
13738 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPO_unique.information1 ;
13739 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
13740 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
13741 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CPO_unique.table_route_id;
13742 --
13743 -- 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) ;
13744 --
13745 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
13746 end if ;
13747 --
13748 l_object_found_in_target := true ;
13749 --TEMPIK
13750 end if; -- l_dt_rec_found
13751 --END TEMPIK
13752 end if;
13753 close c_find_CPO_in_target ;
13754 --
13755 end if;
13756 end if ;
13757 --
13758 close c_CPO_min_max_dates ;
13759 end if; --if p_dml_operation
13760 --
13761 if ( not l_object_found_in_target OR l_update ) and l_ORGANIZATION_ID is not null then
13762 --
13763 l_current_pk_id := r_CPO.information1;
13764 --
13765 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
13766 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
13767 --
13768 if l_current_pk_id = l_prev_pk_id then
13769 --
13770 l_first_rec := false ;
13771 --
13772 else
13773 --
13774 l_first_rec := true ;
13775 --
13776 end if ;
13777 --
13778
13779 l_effective_date := r_CPO.information2;
13780 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13781 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
13782 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
13783 end if;
13784
13785 if l_first_rec and not l_update then
13786 -- Call Create routine.
13787 hr_utility.set_location(' BEN_POPL_ORG_F CREATE_POPL_ORG ',20);
13788 BEN_POPL_ORG_API.CREATE_POPL_ORG(
13789 --
13790 P_VALIDATE => false
13791 ,P_EFFECTIVE_DATE => l_effective_date
13792 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
13793 --
13794 ,P_CPO_ATTRIBUTE1 => r_CPO.INFORMATION111
13795 ,P_CPO_ATTRIBUTE10 => r_CPO.INFORMATION120
13796 ,P_CPO_ATTRIBUTE11 => r_CPO.INFORMATION121
13797 ,P_CPO_ATTRIBUTE12 => r_CPO.INFORMATION122
13798 ,P_CPO_ATTRIBUTE13 => r_CPO.INFORMATION123
13799 ,P_CPO_ATTRIBUTE14 => r_CPO.INFORMATION124
13800 ,P_CPO_ATTRIBUTE15 => r_CPO.INFORMATION125
13801 ,P_CPO_ATTRIBUTE16 => r_CPO.INFORMATION126
13802 ,P_CPO_ATTRIBUTE17 => r_CPO.INFORMATION127
13803 ,P_CPO_ATTRIBUTE18 => r_CPO.INFORMATION128
13804 ,P_CPO_ATTRIBUTE19 => r_CPO.INFORMATION129
13805 ,P_CPO_ATTRIBUTE2 => r_CPO.INFORMATION112
13806 ,P_CPO_ATTRIBUTE20 => r_CPO.INFORMATION130
13807 ,P_CPO_ATTRIBUTE21 => r_CPO.INFORMATION131
13808 ,P_CPO_ATTRIBUTE22 => r_CPO.INFORMATION132
13809 ,P_CPO_ATTRIBUTE23 => r_CPO.INFORMATION133
13810 ,P_CPO_ATTRIBUTE24 => r_CPO.INFORMATION134
13811 ,P_CPO_ATTRIBUTE25 => r_CPO.INFORMATION135
13812 ,P_CPO_ATTRIBUTE26 => r_CPO.INFORMATION136
13813 ,P_CPO_ATTRIBUTE27 => r_CPO.INFORMATION137
13814 ,P_CPO_ATTRIBUTE28 => r_CPO.INFORMATION138
13815 ,P_CPO_ATTRIBUTE29 => r_CPO.INFORMATION139
13816 ,P_CPO_ATTRIBUTE3 => r_CPO.INFORMATION113
13817 ,P_CPO_ATTRIBUTE30 => r_CPO.INFORMATION140
13818 ,P_CPO_ATTRIBUTE4 => r_CPO.INFORMATION114
13819 ,P_CPO_ATTRIBUTE5 => r_CPO.INFORMATION115
13820 ,P_CPO_ATTRIBUTE6 => r_CPO.INFORMATION116
13821 ,P_CPO_ATTRIBUTE7 => r_CPO.INFORMATION117
13822 ,P_CPO_ATTRIBUTE8 => r_CPO.INFORMATION118
13823 ,P_CPO_ATTRIBUTE9 => r_CPO.INFORMATION119
13824 ,P_CPO_ATTRIBUTE_CATEGORY => r_CPO.INFORMATION110
13825 ,P_CSTMR_NUM => r_CPO.INFORMATION257
13826 ,P_ORGANIZATION_ID => l_ORGANIZATION_ID
13827 ,P_PERSON_ID => l_PERSON_ID
13828 ,P_PGM_ID => l_PGM_ID
13829 ,P_PLCY_R_GRP => r_CPO.INFORMATION141
13830 ,P_PL_ID => l_PL_ID
13831 ,P_POPL_ORG_ID => l_popl_org_id
13832 --
13833 ,P_EFFECTIVE_START_DATE => l_effective_start_date
13834 ,P_EFFECTIVE_END_DATE => l_effective_end_date
13835 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
13836 );
13837 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
13838 -- Update all relevent cer records with new pk_id
13839 hr_utility.set_location('Before plsql table ',222);
13840 hr_utility.set_location('new_value id '||l_popl_org_id,222);
13841 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ORG_ID' ;
13842 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPO.information1 ;
13843 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_POPL_ORG_ID ;
13844 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
13845 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CPO_unique.table_route_id;
13846 hr_utility.set_location('After plsql table ',222);
13847 --
13848 -- 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 ) ;
13849 --
13850 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
13851 --
13852 else
13853 --
13854 -- Call Update routine for the pk_id created in prev run .
13855 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
13856 hr_utility.set_location(' BEN_POPL_ORG_F UPDATE_POPL_ORG ',30);
13857 --UPD START
13858 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
13859 --
13860 if l_update then
13861 --
13862 l_datetrack_mode := r_CPO.datetrack_mode ;
13863 --
13864 get_dt_modes(
13865 p_effective_date => l_process_date,
13866 p_effective_end_date => r_CPO.information3,
13867 p_effective_start_date => r_CPO.information2,
13868 p_dml_operation => r_CPO.dml_operation,
13869 p_datetrack_mode => l_datetrack_mode );
13870 -- p_update => l_update
13871 --
13872 l_effective_date := l_process_date;
13873 l_POPL_ORG_ID := r_CPO.information1;
13874 l_object_version_number := r_CPO.information265;
13875 --
13876 end if;
13877 --
13878 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
13879 --
13880 IF l_update OR l_dml_operation <> 'UPDATE' THEN
13881 --UPD END
13882 BEN_POPL_ORG_API.UPDATE_POPL_ORG(
13883 --
13884 P_VALIDATE => false
13885 ,P_EFFECTIVE_DATE => l_effective_date
13886 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
13887 --
13888 ,P_CPO_ATTRIBUTE1 => r_CPO.INFORMATION111
13889 ,P_CPO_ATTRIBUTE10 => r_CPO.INFORMATION120
13890 ,P_CPO_ATTRIBUTE11 => r_CPO.INFORMATION121
13891 ,P_CPO_ATTRIBUTE12 => r_CPO.INFORMATION122
13892 ,P_CPO_ATTRIBUTE13 => r_CPO.INFORMATION123
13893 ,P_CPO_ATTRIBUTE14 => r_CPO.INFORMATION124
13894 ,P_CPO_ATTRIBUTE15 => r_CPO.INFORMATION125
13895 ,P_CPO_ATTRIBUTE16 => r_CPO.INFORMATION126
13896 ,P_CPO_ATTRIBUTE17 => r_CPO.INFORMATION127
13897 ,P_CPO_ATTRIBUTE18 => r_CPO.INFORMATION128
13898 ,P_CPO_ATTRIBUTE19 => r_CPO.INFORMATION129
13899 ,P_CPO_ATTRIBUTE2 => r_CPO.INFORMATION112
13900 ,P_CPO_ATTRIBUTE20 => r_CPO.INFORMATION130
13901 ,P_CPO_ATTRIBUTE21 => r_CPO.INFORMATION131
13902 ,P_CPO_ATTRIBUTE22 => r_CPO.INFORMATION132
13903 ,P_CPO_ATTRIBUTE23 => r_CPO.INFORMATION133
13904 ,P_CPO_ATTRIBUTE24 => r_CPO.INFORMATION134
13905 ,P_CPO_ATTRIBUTE25 => r_CPO.INFORMATION135
13906 ,P_CPO_ATTRIBUTE26 => r_CPO.INFORMATION136
13907 ,P_CPO_ATTRIBUTE27 => r_CPO.INFORMATION137
13908 ,P_CPO_ATTRIBUTE28 => r_CPO.INFORMATION138
13909 ,P_CPO_ATTRIBUTE29 => r_CPO.INFORMATION139
13910 ,P_CPO_ATTRIBUTE3 => r_CPO.INFORMATION113
13911 ,P_CPO_ATTRIBUTE30 => r_CPO.INFORMATION140
13912 ,P_CPO_ATTRIBUTE4 => r_CPO.INFORMATION114
13913 ,P_CPO_ATTRIBUTE5 => r_CPO.INFORMATION115
13914 ,P_CPO_ATTRIBUTE6 => r_CPO.INFORMATION116
13915 ,P_CPO_ATTRIBUTE7 => r_CPO.INFORMATION117
13916 ,P_CPO_ATTRIBUTE8 => r_CPO.INFORMATION118
13917 ,P_CPO_ATTRIBUTE9 => r_CPO.INFORMATION119
13918 ,P_CPO_ATTRIBUTE_CATEGORY => r_CPO.INFORMATION110
13919 ,P_CSTMR_NUM => r_CPO.INFORMATION257
13920 ,P_ORGANIZATION_ID => l_ORGANIZATION_ID
13921 ,P_PERSON_ID => l_PERSON_ID
13922 ,P_PGM_ID => l_PGM_ID
13923 ,P_PLCY_R_GRP => r_CPO.INFORMATION141
13924 ,P_PL_ID => l_PL_ID
13925 ,P_POPL_ORG_ID => l_popl_org_id
13926 --
13927 ,P_EFFECTIVE_START_DATE => l_effective_start_date
13928 ,P_EFFECTIVE_END_DATE => l_effective_end_date
13929 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
13930 ,P_DATETRACK_MODE => l_datetrack_mode
13931 );
13932 --
13933 end if; -- l_update
13934 end if;
13935 --
13936 -- Delete the row if it is end dated.
13937 --
13938 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
13939 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
13940 trunc(l_max_eed) = r_CPO.information3) then
13941 --
13942 BEN_POPL_ORG_API.delete_POPL_ORG(
13943 --
13944 p_validate => false
13945 ,p_popl_org_id => l_popl_org_id
13946 ,p_effective_start_date => l_effective_start_date
13947 ,p_effective_end_date => l_effective_end_date
13948 ,p_object_version_number => l_object_version_number
13949 ,p_effective_date => l_max_eed
13950 ,p_datetrack_mode => hr_api.g_delete
13951 --
13952 );
13953 --
13954 end if;
13955 --
13956 l_prev_pk_id := l_current_pk_id ;
13957 --
13958 end if;
13959 --
13960 end if;
13961 --
13962 end if;
13963 --
13964 end loop;
13965 --
13966 exception when others then
13967 --
13968 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CPO',r_cpo.information5 );
13969 --
13970 end create_CPO_rows;
13971
13972 --
13973 ---------------------------------------------------------------
13974 ----------------------< create_PRG_rows >-----------------------
13975 ---------------------------------------------------------------
13976 --
13977 procedure create_PRG_rows
13978 (
13979 p_validate in number default 0
13980 ,p_copy_entity_txn_id in number
13981 ,p_effective_date in date
13982 ,p_prefix_suffix_text in varchar2 default null
13983 ,p_reuse_object_flag in varchar2 default null
13984 ,p_target_business_group_id in varchar2 default null
13985 ,p_prefix_suffix_cd in varchar2 default null
13986 ) is
13987 --
13988 l_CNTR_NNDSCRN_RL number;
13989 l_CVG_NNDSCRN_RL number;
13990 l_FIVE_PCT_OWNR_RL number;
13991 l_HGHLY_COMPD_DET_RL number;
13992 l_KEY_EE_DET_RL number;
13993 l_PL_ID number;
13994 l_REGN_ID number;
13995 l_RPTG_GRP_ID number;
13996 cursor c_unique_PRG(l_table_alias varchar2) is
13997 select distinct cpe.information1,
13998 cpe.information2,
13999 cpe.information3,
14000 cpe.table_route_id
14001 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
14002 pqh_table_route tr
14003 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14004 and cpe.table_route_id = tr.table_route_id
14005 -- and tr.where_clause = l_BEN_PL_REGN_F
14006 and tr.table_alias = l_table_alias
14007 and cpe.number_of_copies = 1 -- ADDITION
14008 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
14009 order by information1, information2; --added for bug: 5151945
14010 --
14011 --
14012 cursor c_PRG_min_max_dates(c_table_route_id number,
14013 c_information1 number) is
14014 select
14015 min(cpe.information2) min_esd,
14016 max(cpe.information3) min_eed
14017 from ben_copy_entity_results cpe
14018 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14019 and cpe.table_route_id = c_table_route_id
14020 and cpe.information1 = c_information1 ;
14021 --
14022 cursor c_PRG(c_table_route_id number,
14023 c_information1 number,
14024 c_information2 date,
14025 c_information3 date ) is
14026 select
14027 cpe.*
14028 from ben_copy_entity_results cpe
14029 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14030 and cpe.table_route_id = c_table_route_id
14031 and cpe.information1 = c_information1
14032 and cpe.information2 = c_information2
14033 and cpe.information3 = c_information3
14034 and rownum = 1 ;
14035 -- Date Track target record
14036 cursor c_find_PRG_in_target(
14037 c_effective_start_date date,
14038 c_effective_end_date date,
14039 c_business_group_id number,
14040 c_new_pk_id number) is
14041 select
14042 PRG.pl_regn_id new_value
14043 from BEN_PL_REGN_F PRG
14044 where
14045 nvl(PRG.PL_ID,-999) = nvl(l_PL_ID,-999) and
14046 PRG.REGN_ID = l_REGN_ID and
14047 nvl(PRG.RPTG_GRP_ID,-999) = nvl(l_RPTG_GRP_ID,-999) and
14048 PRG.business_group_id = c_business_group_id
14049 and PRG.pl_regn_id <> c_new_pk_id
14050 --TEMPIK
14051 and c_effective_start_date between effective_start_date
14052 and effective_end_date ;
14053 --END TEMPIK
14054 /*TEMPIK
14055 and exists ( select null
14056 from BEN_PL_REGN_F PRG1
14057 where
14058 nvl(PRG1.PL_ID,-999) = nvl(l_PL_ID,-999) and
14059 PRG1.REGN_ID = l_REGN_ID and
14060 nvl(PRG1.RPTG_GRP_ID,-999) = nvl(l_RPTG_GRP_ID,-999) and
14061 PRG1.business_group_id = c_business_group_id
14062 and PRG1.effective_start_date <= c_effective_start_date )
14063 and exists ( select null
14064 from BEN_PL_REGN_F PRG2
14065 where
14066 nvl(PRG2.PL_ID,-999) = nvl(l_PL_ID,-999) and
14067 PRG2.REGN_ID = l_REGN_ID and
14068 nvl(PRG2.RPTG_GRP_ID,-999) = nvl(l_RPTG_GRP_ID,-999) and
14069 PRG2.business_group_id = c_business_group_id
14070 and PRG2.effective_end_date >= c_effective_end_date )
14071 ;
14072 TEMPIK */
14073 --TEMPIK
14074 l_dt_rec_found boolean ;
14075 --END TEMPIK
14076 --
14077 cursor c_regn(c_name in varchar2,
14078 c_business_group_id in number,
14079 c_effective_date in date
14080 ) is
14081 select reg.regn_id
14082 from ben_regn_f reg
14083 where reg.name = c_name
14084 and reg.business_group_id = c_business_group_id
14085 and c_effective_date between reg.effective_start_date
14086 and reg.effective_end_date;
14087 --
14088 --UPD START
14089 --
14090 l_update boolean := false ;
14091 l_datetrack_mode varchar2(80) := hr_api.g_update;
14092 l_process_date date;
14093 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
14094 --
14095 --UPD END
14096 l_current_pk_id number := null ;
14097 l_prev_pk_id number := null ;
14098 l_first_rec boolean := true ;
14099 r_PRG c_PRG%rowtype;
14100 l_pl_regn_id number ;
14101 l_object_version_number number ;
14102 l_effective_start_date date ;
14103 l_effective_end_date date ;
14104 l_prefix pqh_copy_entity_attribs.information1%type := null;
14105 l_suffix pqh_copy_entity_attribs.information1%type := null;
14106 l_new_value number(15);
14107 l_object_found_in_target boolean := false ;
14108 l_min_esd date;
14109 l_max_eed date;
14110 l_effective_date date;
14111 --
14112 begin
14113 -- Initialization
14114 l_object_found_in_target := false ;
14115 -- End Initialization
14116 -- Derive the prefix - sufix
14117 if p_prefix_suffix_cd = 'PREFIX' then
14118 l_prefix := p_prefix_suffix_text ;
14119 elsif p_prefix_suffix_cd = 'SUFFIX' then
14120 l_suffix := p_prefix_suffix_text ;
14121 else
14122 l_prefix := null ;
14123 l_suffix := null ;
14124 end if ;
14125 -- End Prefix Sufix derivation
14126 for r_PRG_unique in c_unique_PRG('PRG') loop
14127
14128 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
14129 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14130 r_PRG_unique.information3 >=
14131 ben_pd_copy_to_ben_one.g_copy_effective_date)
14132 ) then
14133 --
14134 hr_utility.set_location(' r_PRG_unique.table_route_id '||r_PRG_unique.table_route_id,10);
14135 hr_utility.set_location(' r_PRG_unique.information1 '||r_PRG_unique.information1,10);
14136 hr_utility.set_location( 'r_PRG_unique.information2 '||r_PRG_unique.information2,10);
14137 hr_utility.set_location( 'r_PRG_unique.information3 '||r_PRG_unique.information3,10);
14138 -- If reuse objects flag is 'Y' then check for the object in the target business group
14139 -- if found insert the record into PLSql table and exit the loop else try create the
14140 -- object in the target business group
14141 --
14142 l_object_found_in_target := false ;
14143 --UPD START
14144 open c_PRG(r_PRG_unique.table_route_id,
14145 r_PRG_unique.information1,
14146 r_PRG_unique.information2,
14147 r_PRG_unique.information3 ) ;
14148 --
14149 fetch c_PRG into r_PRG ;
14150 --
14151 close c_PRG ;
14152
14153 l_dml_operation:= r_PRG_unique.dml_operation ;
14154 l_CNTR_NNDSCRN_RL := get_fk('FORMULA_ID', r_PRG.INFORMATION259,l_dml_operation );
14155 l_CVG_NNDSCRN_RL := get_fk('FORMULA_ID', r_PRG.INFORMATION260,l_dml_operation );
14156 l_FIVE_PCT_OWNR_RL := get_fk('FORMULA_ID', r_PRG.INFORMATION262,l_dml_operation );
14157 l_HGHLY_COMPD_DET_RL := get_fk('FORMULA_ID', r_PRG.INFORMATION257,l_dml_operation );
14158 l_KEY_EE_DET_RL := get_fk('FORMULA_ID', r_PRG.INFORMATION258,l_dml_operation );
14159 l_PL_ID := get_fk('PL_ID', r_PRG.INFORMATION261,l_dml_operation );
14160 l_REGN_ID := get_fk('REGN_ID', r_PRG.INFORMATION231,l_dml_operation );
14161 l_RPTG_GRP_ID := get_fk('RPTG_GRP_ID', r_PRG.INFORMATION242,l_dml_operation );
14162 l_update := false;
14163 l_process_date := p_effective_date;
14164 --
14165 if l_dml_operation = 'UPDATE' then
14166 --
14167 l_object_found_in_target := TRUE;
14168 --
14169 if l_process_date between r_PRG_unique.information2 and r_PRG_unique.information3 then
14170 l_update := true;
14171 if r_PRG_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
14172 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_REGN_ID'
14173 then
14174 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_REGN_ID' ;
14175 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PRG_unique.information1 ;
14176 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PRG_unique.information1 ;
14177 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
14178 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PRG_unique.table_route_id;
14179 --
14180 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
14181 --
14182 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
14183 --
14184 --DOUBT log_data('PRG',l_new_value,l_prefix || r_PRG_unique.name|| l_suffix,'REUSED');
14185 --
14186 end if ;
14187 hr_utility.set_location( 'found record for update',10);
14188 --
14189 else
14190 --
14191 l_update := false;
14192 --
14193 end if;
14194 else
14195 --
14196 --UPD END
14197 l_min_esd := null ;
14198 l_max_eed := null ;
14199 open c_PRG_min_max_dates(r_PRG_unique.table_route_id, r_PRG_unique.information1 ) ;
14200 fetch c_PRG_min_max_dates into l_min_esd,l_max_eed ;
14201 --
14202
14203 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14204 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
14205 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
14206 end if;
14207 l_min_esd := greatest(l_min_esd,r_PRG_unique.information2);
14208 /* open c_PRG(r_PRG_unique.table_route_id,
14209 r_PRG_unique.information1,
14210 r_PRG_unique.information2,
14211 r_PRG_unique.information3 ) ;
14212 --
14213 fetch c_PRG into r_PRG ;
14214 --
14215 close c_PRG ; */
14216 --
14217 -- Regulations will not be created, they will be mapped based on the
14218 -- Regulation name in the Source Business Group
14219 -- create_REG_rows will store the required regn_id in g_pk_tbl
14220
14221 /*
14222 -- NOT REQUIRED as create_REG_rows has been uncommented
14223 -- and will store the required regn_id in g_pk_tbl
14224 -- so that it can be got by get_fk
14225
14226 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
14227 open c_regn(r_PRG.information185,
14228 p_target_business_group_id,
14229 r_PRG.information2)
14230 );
14231 fetch c_regn into l_REGN_ID;
14232 if c_regn%notfound then
14233 l_REGN_ID := null;
14234 end if;
14235 close c_regn;
14236 else
14237 l_REGN_ID := r_PRG.information49; -- Regulation id from Source business group
14238 end if;
14239 --
14240 */
14241
14242 if l_REGN_ID is null then
14243 close c_PRG_min_max_dates;
14244 else
14245 if p_reuse_object_flag = 'Y' then
14246 if c_PRG_min_max_dates%found then
14247 -- cursor to find the object
14248 open c_find_PRG_in_target( l_min_esd,l_max_eed,
14249 p_target_business_group_id, nvl(l_pl_regn_id, -999) ) ;
14250 fetch c_find_PRG_in_target into l_new_value ;
14251 if c_find_PRG_in_target%found then
14252 --
14253 --TEMPIK
14254 l_dt_rec_found := dt_api.check_min_max_dates
14255 (p_base_table_name => 'BEN_PL_REGN_F',
14256 p_base_key_column => 'PL_REGN_ID',
14257 p_base_key_value => l_new_value,
14258 p_from_date => l_min_esd,
14259 p_to_date => l_max_eed );
14260 if l_dt_rec_found THEN
14261 --END TEMPIK
14262 if r_PRG_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
14263 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_REGN_ID' then
14264 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_REGN_ID' ;
14265 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PRG_unique.information1 ;
14266 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
14267 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
14268 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PRG_unique.table_route_id;
14269 --
14270 -- 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) ;
14271 --
14272 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
14273 end if ;
14274 --
14275 l_object_found_in_target := true ;
14276 --TEMPIK
14277 end if; -- l_dt_rec_found
14278 --END TEMPIK
14279 end if;
14280 close c_find_PRG_in_target ;
14281 --
14282 end if;
14283 end if ;
14284 --
14285 close c_PRG_min_max_dates ;
14286 end if; --if p_dml_operation
14287 --
14288 if not l_object_found_in_target OR l_update then
14289 --
14290 l_current_pk_id := r_PRG.information1;
14291 --
14292 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
14293 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
14294 --
14295 if l_current_pk_id = l_prev_pk_id then
14296 --
14297 l_first_rec := false ;
14298 --
14299 else
14300 --
14301 l_first_rec := true ;
14302 --
14303 end if ;
14304 --
14305
14306 l_effective_date := r_PRG.information2;
14307 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14308 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
14309 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
14310 end if;
14311
14312 if l_first_rec and not l_update then
14313 -- Call Create routine.
14314 hr_utility.set_location(' BEN_PL_REGN_F CREATE_PLAN_REGULATION ',20);
14315 BEN_PLAN_REGULATION_API.CREATE_PLAN_REGULATION(
14316 --
14317 P_VALIDATE => false
14318 ,P_EFFECTIVE_DATE => l_effective_date
14319 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
14320 --
14321 ,P_CNTR_NNDSCRN_RL => l_CNTR_NNDSCRN_RL
14322 ,P_CVG_NNDSCRN_RL => l_CVG_NNDSCRN_RL
14323 ,P_FIVE_PCT_OWNR_RL => l_FIVE_PCT_OWNR_RL
14324 ,P_HGHLY_COMPD_DET_RL => l_HGHLY_COMPD_DET_RL
14325 ,P_KEY_EE_DET_RL => l_KEY_EE_DET_RL
14326 ,P_PL_ID => l_PL_ID
14327 ,P_PL_REGN_ID => l_pl_regn_id
14328 ,P_PRG_ATTRIBUTE1 => r_PRG.INFORMATION111
14329 ,P_PRG_ATTRIBUTE10 => r_PRG.INFORMATION120
14330 ,P_PRG_ATTRIBUTE11 => r_PRG.INFORMATION121
14331 ,P_PRG_ATTRIBUTE12 => r_PRG.INFORMATION122
14332 ,P_PRG_ATTRIBUTE13 => r_PRG.INFORMATION123
14333 ,P_PRG_ATTRIBUTE14 => r_PRG.INFORMATION124
14334 ,P_PRG_ATTRIBUTE15 => r_PRG.INFORMATION125
14335 ,P_PRG_ATTRIBUTE16 => r_PRG.INFORMATION126
14336 ,P_PRG_ATTRIBUTE17 => r_PRG.INFORMATION127
14337 ,P_PRG_ATTRIBUTE18 => r_PRG.INFORMATION128
14338 ,P_PRG_ATTRIBUTE19 => r_PRG.INFORMATION129
14339 ,P_PRG_ATTRIBUTE2 => r_PRG.INFORMATION112
14340 ,P_PRG_ATTRIBUTE20 => r_PRG.INFORMATION130
14341 ,P_PRG_ATTRIBUTE21 => r_PRG.INFORMATION131
14342 ,P_PRG_ATTRIBUTE22 => r_PRG.INFORMATION132
14343 ,P_PRG_ATTRIBUTE23 => r_PRG.INFORMATION133
14344 ,P_PRG_ATTRIBUTE24 => r_PRG.INFORMATION134
14345 ,P_PRG_ATTRIBUTE25 => r_PRG.INFORMATION135
14346 ,P_PRG_ATTRIBUTE26 => r_PRG.INFORMATION136
14347 ,P_PRG_ATTRIBUTE27 => r_PRG.INFORMATION137
14348 ,P_PRG_ATTRIBUTE28 => r_PRG.INFORMATION138
14349 ,P_PRG_ATTRIBUTE29 => r_PRG.INFORMATION139
14350 ,P_PRG_ATTRIBUTE3 => r_PRG.INFORMATION113
14351 ,P_PRG_ATTRIBUTE30 => r_PRG.INFORMATION140
14352 ,P_PRG_ATTRIBUTE4 => r_PRG.INFORMATION114
14353 ,P_PRG_ATTRIBUTE5 => r_PRG.INFORMATION115
14354 ,P_PRG_ATTRIBUTE6 => r_PRG.INFORMATION116
14355 ,P_PRG_ATTRIBUTE7 => r_PRG.INFORMATION117
14356 ,P_PRG_ATTRIBUTE8 => r_PRG.INFORMATION118
14357 ,P_PRG_ATTRIBUTE9 => r_PRG.INFORMATION119
14358 ,P_PRG_ATTRIBUTE_CATEGORY => r_PRG.INFORMATION110
14359 ,P_REGN_ID => l_REGN_ID
14360 ,P_REGY_PL_TYP_CD => r_PRG.INFORMATION11
14361 ,P_RPTG_GRP_ID => l_RPTG_GRP_ID
14362 --
14363 ,P_EFFECTIVE_START_DATE => l_effective_start_date
14364 ,P_EFFECTIVE_END_DATE => l_effective_end_date
14365 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
14366 );
14367 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
14368 -- Update all relevent cer records with new pk_id
14369 hr_utility.set_location('Before plsql table ',222);
14370 hr_utility.set_location('new_value id '||l_pl_regn_id,222);
14371 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_REGN_ID' ;
14372 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PRG.information1 ;
14373 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PL_REGN_ID ;
14374 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
14375 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PRG_unique.table_route_id;
14376 hr_utility.set_location('After plsql table ',222);
14377 --
14378 -- 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 ) ;
14379 --
14380 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
14381 --
14382 else
14383 --
14384 -- Call Update routine for the pk_id created in prev run .
14385 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
14386 hr_utility.set_location(' BEN_PL_REGN_F UPDATE_PLAN_REGULATION ',30);
14387 --UPD START
14388 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
14389 --
14390 if l_update then
14391 --
14392 l_datetrack_mode := r_PRG.datetrack_mode ;
14393 --
14394 get_dt_modes(
14395 p_effective_date => l_process_date,
14396 p_effective_end_date => r_PRG.information3,
14397 p_effective_start_date => r_PRG.information2,
14398 p_dml_operation => r_PRG.dml_operation,
14399 p_datetrack_mode => l_datetrack_mode );
14400 -- p_update => l_update
14401 --
14402 l_effective_date := l_process_date;
14403 l_PL_REGN_ID := r_PRG.information1;
14404 l_object_version_number := r_PRG.information265;
14405 --
14406 end if;
14407 --
14408 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
14409 --
14410 IF l_update OR l_dml_operation <> 'UPDATE' THEN
14411 --UPD END
14412 BEN_PLAN_REGULATION_API.UPDATE_PLAN_REGULATION(
14413 --
14414 P_VALIDATE => false
14415 ,P_EFFECTIVE_DATE => l_effective_date
14416 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
14417 --
14418 ,P_CNTR_NNDSCRN_RL => l_CNTR_NNDSCRN_RL
14419 ,P_CVG_NNDSCRN_RL => l_CVG_NNDSCRN_RL
14420 ,P_FIVE_PCT_OWNR_RL => l_FIVE_PCT_OWNR_RL
14421 ,P_HGHLY_COMPD_DET_RL => l_HGHLY_COMPD_DET_RL
14422 ,P_KEY_EE_DET_RL => l_KEY_EE_DET_RL
14423 ,P_PL_ID => l_PL_ID
14424 ,P_PL_REGN_ID => l_pl_regn_id
14425 ,P_PRG_ATTRIBUTE1 => r_PRG.INFORMATION111
14426 ,P_PRG_ATTRIBUTE10 => r_PRG.INFORMATION120
14427 ,P_PRG_ATTRIBUTE11 => r_PRG.INFORMATION121
14428 ,P_PRG_ATTRIBUTE12 => r_PRG.INFORMATION122
14429 ,P_PRG_ATTRIBUTE13 => r_PRG.INFORMATION123
14430 ,P_PRG_ATTRIBUTE14 => r_PRG.INFORMATION124
14431 ,P_PRG_ATTRIBUTE15 => r_PRG.INFORMATION125
14432 ,P_PRG_ATTRIBUTE16 => r_PRG.INFORMATION126
14433 ,P_PRG_ATTRIBUTE17 => r_PRG.INFORMATION127
14434 ,P_PRG_ATTRIBUTE18 => r_PRG.INFORMATION128
14435 ,P_PRG_ATTRIBUTE19 => r_PRG.INFORMATION129
14436 ,P_PRG_ATTRIBUTE2 => r_PRG.INFORMATION112
14437 ,P_PRG_ATTRIBUTE20 => r_PRG.INFORMATION130
14438 ,P_PRG_ATTRIBUTE21 => r_PRG.INFORMATION131
14439 ,P_PRG_ATTRIBUTE22 => r_PRG.INFORMATION132
14440 ,P_PRG_ATTRIBUTE23 => r_PRG.INFORMATION133
14441 ,P_PRG_ATTRIBUTE24 => r_PRG.INFORMATION134
14442 ,P_PRG_ATTRIBUTE25 => r_PRG.INFORMATION135
14443 ,P_PRG_ATTRIBUTE26 => r_PRG.INFORMATION136
14444 ,P_PRG_ATTRIBUTE27 => r_PRG.INFORMATION137
14445 ,P_PRG_ATTRIBUTE28 => r_PRG.INFORMATION138
14446 ,P_PRG_ATTRIBUTE29 => r_PRG.INFORMATION139
14447 ,P_PRG_ATTRIBUTE3 => r_PRG.INFORMATION113
14448 ,P_PRG_ATTRIBUTE30 => r_PRG.INFORMATION140
14449 ,P_PRG_ATTRIBUTE4 => r_PRG.INFORMATION114
14450 ,P_PRG_ATTRIBUTE5 => r_PRG.INFORMATION115
14451 ,P_PRG_ATTRIBUTE6 => r_PRG.INFORMATION116
14452 ,P_PRG_ATTRIBUTE7 => r_PRG.INFORMATION117
14453 ,P_PRG_ATTRIBUTE8 => r_PRG.INFORMATION118
14454 ,P_PRG_ATTRIBUTE9 => r_PRG.INFORMATION119
14455 ,P_PRG_ATTRIBUTE_CATEGORY => r_PRG.INFORMATION110
14456 ,P_REGN_ID => l_REGN_ID
14457 ,P_REGY_PL_TYP_CD => r_PRG.INFORMATION11
14458 ,P_RPTG_GRP_ID => l_RPTG_GRP_ID
14459 --
14460 ,P_EFFECTIVE_START_DATE => l_effective_start_date
14461 ,P_EFFECTIVE_END_DATE => l_effective_end_date
14462 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
14463 ,P_DATETRACK_MODE => l_datetrack_mode
14464 );
14465 --
14466 end if; -- l_update
14467 end if;
14468 --
14469 -- Delete the row if it is end dated.
14470 --
14471 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
14472 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
14473 trunc(l_max_eed) = r_PRG.information3) then
14474 --
14475 BEN_PLAN_REGULATION_API.delete_PLAN_REGULATION(
14476 --
14477 p_validate => false
14478 ,p_pl_regn_id => l_pl_regn_id
14479 ,p_effective_start_date => l_effective_start_date
14480 ,p_effective_end_date => l_effective_end_date
14481 ,p_object_version_number => l_object_version_number
14482 ,p_effective_date => l_max_eed
14483 ,p_datetrack_mode => hr_api.g_delete
14484 --
14485 );
14486 --
14487 end if;
14488 --
14489 l_prev_pk_id := l_current_pk_id ;
14490 --
14491 end if;
14492 --
14493 end if;
14494 end if;
14495 --
14496 end loop;
14497 --
14498 exception when others then
14499 --
14500 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PRG',r_prg.information5 );
14501 --
14502 end create_PRG_rows;
14503
14504 --
14505 ---------------------------------------------------------------
14506 ----------------------< create_RGR_rows >-----------------------
14507 ---------------------------------------------------------------
14508 --
14509 procedure create_RGR_rows
14510 (
14511 p_validate in number default 0
14512 ,p_copy_entity_txn_id in number
14513 ,p_effective_date in date
14514 ,p_prefix_suffix_text in varchar2 default null
14515 ,p_reuse_object_flag in varchar2 default null
14516 ,p_target_business_group_id in varchar2 default null
14517 ,p_prefix_suffix_cd in varchar2 default null
14518 ) is
14519 --
14520 l_PGM_ID number;
14521 l_PL_ID number;
14522 l_RPTG_GRP_ID number;
14523 cursor c_unique_RGR(l_table_alias varchar2) is
14524 select distinct cpe.information1,
14525 cpe.information2,
14526 cpe.information3,
14527 cpe.table_route_id
14528 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
14529 pqh_table_route tr
14530 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14531 and cpe.table_route_id = tr.table_route_id
14532 -- and tr.where_clause = l_BEN_POPL_RPTG_GRP_F
14533 and tr.table_alias = l_table_alias
14534 and cpe.number_of_copies = 1 -- ADDITION
14535 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
14536 order by information1, information2; --added for bug: 5151945
14537 --
14538 --
14539 cursor c_RGR_min_max_dates(c_table_route_id number,
14540 c_information1 number) is
14541 select
14542 min(cpe.information2) min_esd,
14543 max(cpe.information3) min_eed
14544 from ben_copy_entity_results cpe
14545 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14546 and cpe.table_route_id = c_table_route_id
14547 and cpe.information1 = c_information1 ;
14548 --
14549 cursor c_RGR(c_table_route_id number,
14550 c_information1 number,
14551 c_information2 date,
14552 c_information3 date ) is
14553 select
14554 cpe.*
14555 from ben_copy_entity_results cpe
14556 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14557 and cpe.table_route_id = c_table_route_id
14558 and cpe.information1 = c_information1
14559 and cpe.information2 = c_information2
14560 and cpe.information3 = c_information3
14561 and rownum = 1 ;
14562 -- Date Track target record
14563 cursor c_find_RGR_in_target(
14564 c_effective_start_date date,
14565 c_effective_end_date date,
14566 c_business_group_id number,
14567 c_new_pk_id number) is
14568 select
14569 RGR.popl_rptg_grp_id new_value
14570 from BEN_POPL_RPTG_GRP_F RGR
14571 where
14572 nvl(RGR.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
14573 nvl(RGR.PL_ID,-999) = nvl(l_PL_ID,-999) and
14574 RGR.RPTG_GRP_ID = l_RPTG_GRP_ID and
14575 RGR.business_group_id = c_business_group_id
14576 and RGR.popl_rptg_grp_id <> c_new_pk_id
14577 --TEMPIK
14578 and c_effective_start_date between effective_start_date
14579 and effective_end_date ;
14580 --END TEMPIK
14581 /*TEMPIK
14582 and exists ( select null
14583 from BEN_POPL_RPTG_GRP_F RGR1
14584 where
14585 nvl(RGR1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
14586 nvl(RGR1.PL_ID,-999) = nvl(l_PL_ID,-999) and
14587 RGR1.RPTG_GRP_ID = l_RPTG_GRP_ID and
14588 RGR1.business_group_id = c_business_group_id
14589 and RGR1.effective_start_date <= c_effective_start_date )
14590 and exists ( select null
14591 from BEN_POPL_RPTG_GRP_F RGR2
14592 where
14593 nvl(RGR2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
14594 nvl(RGR2.PL_ID,-999) = nvl(l_PL_ID,-999) and
14595 RGR2.RPTG_GRP_ID = l_RPTG_GRP_ID and
14596 RGR2.business_group_id = c_business_group_id
14597 and RGR2.effective_end_date >= c_effective_end_date )
14598 ;
14599 TEMPIK */
14600 --TEMPIK
14601 l_dt_rec_found boolean ;
14602 --END TEMPIK
14603 --
14604 --UPD START
14605 --
14606 l_update boolean := false ;
14607 l_datetrack_mode varchar2(80) := hr_api.g_update;
14608 l_process_date date;
14609 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
14610 --
14611 --UPD END
14612 l_current_pk_id number := null ;
14613 l_prev_pk_id number := null ;
14614 l_first_rec boolean := true ;
14615 r_RGR c_RGR%rowtype;
14616 l_popl_rptg_grp_id number ;
14617 l_object_version_number number ;
14618 l_effective_start_date date ;
14619 l_effective_end_date date ;
14620 l_prefix pqh_copy_entity_attribs.information1%type := null;
14621 l_suffix pqh_copy_entity_attribs.information1%type := null;
14622 l_new_value number(15);
14623 l_object_found_in_target boolean := false ;
14624 l_min_esd date;
14625 l_max_eed date;
14626 l_effective_date date;
14627 --
14628 begin
14629 -- Initialization
14630 l_object_found_in_target := false ;
14631 -- End Initialization
14632 -- Derive the prefix - sufix
14633 if p_prefix_suffix_cd = 'PREFIX' then
14634 l_prefix := p_prefix_suffix_text ;
14635 elsif p_prefix_suffix_cd = 'SUFFIX' then
14636 l_suffix := p_prefix_suffix_text ;
14637 else
14638 l_prefix := null ;
14639 l_suffix := null ;
14640 end if ;
14641 -- End Prefix Sufix derivation
14642 for r_RGR_unique in c_unique_RGR('RGR') loop
14643
14644 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
14645 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14646 r_RGR_unique.information3 >=
14647 ben_pd_copy_to_ben_one.g_copy_effective_date)
14648 ) then
14649 --
14650 hr_utility.set_location(' r_RGR_unique.table_route_id '||r_RGR_unique.table_route_id,10);
14651 hr_utility.set_location(' r_RGR_unique.information1 '||r_RGR_unique.information1,10);
14652 hr_utility.set_location( 'r_RGR_unique.information2 '||r_RGR_unique.information2,10);
14653 hr_utility.set_location( 'r_RGR_unique.information3 '||r_RGR_unique.information3,10);
14654 -- If reuse objects flag is 'Y' then check for the object in the target business group
14655 -- if found insert the record into PLSql table and exit the loop else try create the
14656 -- object in the target business group
14657 --
14658 l_object_found_in_target := false ;
14659 --UPD START
14660 open c_RGR(r_RGR_unique.table_route_id,
14661 r_RGR_unique.information1,
14662 r_RGR_unique.information2,
14663 r_RGR_unique.information3 ) ;
14664 --
14665 fetch c_RGR into r_RGR ;
14666 --
14667 close c_RGR ;
14668
14669 l_dml_operation:= r_RGR_unique.dml_operation ;
14670 l_PGM_ID := get_fk('PGM_ID', r_RGR.INFORMATION260,l_dml_operation );
14671 l_PL_ID := get_fk('PL_ID', r_RGR.INFORMATION261,l_dml_operation );
14672 l_RPTG_GRP_ID := get_fk('RPTG_GRP_ID', r_RGR.INFORMATION242,l_dml_operation );
14673 l_update := false;
14674 l_process_date := p_effective_date;
14675 --
14676 if l_dml_operation = 'UPDATE' then
14677 --
14678 l_object_found_in_target := TRUE;
14679 --
14680 if l_process_date between r_RGR_unique.information2 and r_RGR_unique.information3 then
14681 l_update := true;
14682 if r_RGR_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
14683 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'POPL_RPTG_GRP_ID'
14684 then
14685 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_RPTG_GRP_ID' ;
14686 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_RGR_unique.information1 ;
14687 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_RGR_unique.information1 ;
14688 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
14689 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_RGR_unique.table_route_id;
14690 --
14691 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
14692 --
14693 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
14694 --
14695 --DOUBT log_data('RGR',l_new_value,l_prefix || r_RGR_unique.name|| l_suffix,'REUSED');
14696 --
14697 end if ;
14698 hr_utility.set_location( 'found record for update',10);
14699 --
14700 else
14701 --
14702 l_update := false;
14703 --
14704 end if;
14705 else
14706 --
14707 --UPD END
14708 l_min_esd := null ;
14709 l_max_eed := null ;
14710 open c_RGR_min_max_dates(r_RGR_unique.table_route_id, r_RGR_unique.information1 ) ;
14711 fetch c_RGR_min_max_dates into l_min_esd,l_max_eed ;
14712 --
14713
14714 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14715 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
14716 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
14717 end if;
14718 l_min_esd := greatest(l_min_esd,r_RGR_unique.information2);
14719 /* open c_RGR(r_RGR_unique.table_route_id,
14720 r_RGR_unique.information1,
14721 r_RGR_unique.information2,
14722 r_RGR_unique.information3 ) ;
14723 --
14724 fetch c_RGR into r_RGR ;
14725 --
14726 close c_RGR ; */
14727 --
14728 -- There could exist multiple componets[Programs and Plans] to the Reporting group
14729 -- which are not getting copied due to the selection criteria
14730 -- So we need to make sure that pl or pgm is getting copied
14731 --
14732 if l_PGM_ID is null and l_PL_ID is null then
14733 close c_RGR_min_max_dates;
14734 else
14735 if p_reuse_object_flag = 'Y' then
14736 if c_RGR_min_max_dates%found then
14737 -- cursor to find the object
14738 open c_find_RGR_in_target( l_min_esd,l_max_eed,
14739 p_target_business_group_id, nvl(l_popl_rptg_grp_id, -999) ) ;
14740 fetch c_find_RGR_in_target into l_new_value ;
14741 if c_find_RGR_in_target%found then
14742 --
14743 --TEMPIK
14744 l_dt_rec_found := dt_api.check_min_max_dates
14745 (p_base_table_name => 'BEN_POPL_RPTG_GRP_F',
14746 p_base_key_column => 'POPL_RPTG_GRP_ID',
14747 p_base_key_value => l_new_value,
14748 p_from_date => l_min_esd,
14749 p_to_date => l_max_eed );
14750 if l_dt_rec_found THEN
14751 --END TEMPIK
14752 if r_RGR_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
14753 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'POPL_RPTG_GRP_ID' then
14754 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_RPTG_GRP_ID' ;
14755 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_RGR_unique.information1 ;
14756 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
14757 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
14758 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_RGR_unique.table_route_id;
14759 --
14760 -- 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) ;
14761 --
14762 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
14763 end if ;
14764 --
14765 l_object_found_in_target := true ;
14766 --TEMPIK
14767 end if; -- l_dt_rec_found
14768 --END TEMPIK
14769 end if;
14770 close c_find_RGR_in_target ;
14771 --
14772 end if;
14773 end if ;
14774 --
14775 close c_RGR_min_max_dates ;
14776
14777 end if; --if p_dml_operation
14778 --
14779 if not l_object_found_in_target OR l_update then
14780 --
14781 l_current_pk_id := r_RGR.information1;
14782 --
14783 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
14784 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
14785 --
14786 if l_current_pk_id = l_prev_pk_id then
14787 --
14788 l_first_rec := false ;
14789 --
14790 else
14791 --
14792 l_first_rec := true ;
14793 --
14794 end if ;
14795 --
14796
14797 l_effective_date := r_RGR.information2;
14798 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14799 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
14800 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
14801 end if;
14802
14803 if l_first_rec and not l_update then
14804 -- Call Create routine.
14805 hr_utility.set_location(' BEN_POPL_RPTG_GRP_F CREATE_POPL_RPTG_GRP ',20);
14806 BEN_POPL_RPTG_GRP_API.CREATE_POPL_RPTG_GRP(
14807 --
14808 P_VALIDATE => false
14809 ,P_EFFECTIVE_DATE => l_effective_date
14810 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
14811 --
14812 ,P_PGM_ID => l_PGM_ID
14813 ,P_PL_ID => l_PL_ID
14814 ,P_POPL_RPTG_GRP_ID => l_popl_rptg_grp_id
14815 ,P_RGR_ATTRIBUTE1 => r_RGR.INFORMATION111
14816 ,P_RGR_ATTRIBUTE10 => r_RGR.INFORMATION120
14817 ,P_RGR_ATTRIBUTE11 => r_RGR.INFORMATION121
14818 ,P_RGR_ATTRIBUTE12 => r_RGR.INFORMATION122
14819 ,P_RGR_ATTRIBUTE13 => r_RGR.INFORMATION123
14820 ,P_RGR_ATTRIBUTE14 => r_RGR.INFORMATION124
14821 ,P_RGR_ATTRIBUTE15 => r_RGR.INFORMATION125
14822 ,P_RGR_ATTRIBUTE16 => r_RGR.INFORMATION126
14823 ,P_RGR_ATTRIBUTE17 => r_RGR.INFORMATION127
14824 ,P_RGR_ATTRIBUTE18 => r_RGR.INFORMATION128
14825 ,P_RGR_ATTRIBUTE19 => r_RGR.INFORMATION129
14826 ,P_RGR_ATTRIBUTE2 => r_RGR.INFORMATION112
14827 ,P_RGR_ATTRIBUTE20 => r_RGR.INFORMATION130
14828 ,P_RGR_ATTRIBUTE21 => r_RGR.INFORMATION131
14829 ,P_RGR_ATTRIBUTE22 => r_RGR.INFORMATION132
14830 ,P_RGR_ATTRIBUTE23 => r_RGR.INFORMATION133
14831 ,P_RGR_ATTRIBUTE24 => r_RGR.INFORMATION134
14832 ,P_RGR_ATTRIBUTE25 => r_RGR.INFORMATION135
14833 ,P_RGR_ATTRIBUTE26 => r_RGR.INFORMATION136
14834 ,P_RGR_ATTRIBUTE27 => r_RGR.INFORMATION137
14835 ,P_RGR_ATTRIBUTE28 => r_RGR.INFORMATION138
14836 ,P_RGR_ATTRIBUTE29 => r_RGR.INFORMATION139
14837 ,P_RGR_ATTRIBUTE3 => r_RGR.INFORMATION113
14838 ,P_RGR_ATTRIBUTE30 => r_RGR.INFORMATION140
14839 ,P_RGR_ATTRIBUTE4 => r_RGR.INFORMATION114
14840 ,P_RGR_ATTRIBUTE5 => r_RGR.INFORMATION115
14841 ,P_RGR_ATTRIBUTE6 => r_RGR.INFORMATION116
14842 ,P_RGR_ATTRIBUTE7 => r_RGR.INFORMATION117
14843 ,P_RGR_ATTRIBUTE8 => r_RGR.INFORMATION118
14844 ,P_RGR_ATTRIBUTE9 => r_RGR.INFORMATION119
14845 ,P_RGR_ATTRIBUTE_CATEGORY => r_RGR.INFORMATION110
14846 ,P_RPTG_GRP_ID => l_RPTG_GRP_ID
14847 --
14848 ,P_EFFECTIVE_START_DATE => l_effective_start_date
14849 ,P_EFFECTIVE_END_DATE => l_effective_end_date
14850 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
14851 );
14852 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
14853 -- Update all relevent cer records with new pk_id
14854 hr_utility.set_location('Before plsql table ',222);
14855 hr_utility.set_location('new_value id '||l_popl_rptg_grp_id,222);
14856 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_RPTG_GRP_ID' ;
14857 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_RGR.information1 ;
14858 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_POPL_RPTG_GRP_ID ;
14859 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
14860 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_RGR_unique.table_route_id;
14861 hr_utility.set_location('After plsql table ',222);
14862 --
14863 -- 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 ) ;
14864 --
14865 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
14866 --
14867 else
14868 --
14869 -- Call Update routine for the pk_id created in prev run .
14870 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
14871 hr_utility.set_location(' BEN_POPL_RPTG_GRP_F UPDATE_POPL_RPTG_GRP ',30);
14872 --UPD START
14873 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
14874 --
14875 if l_update then
14876 --
14877 l_datetrack_mode := r_RGR.datetrack_mode ;
14878 --
14879 get_dt_modes(
14880 p_effective_date => l_process_date,
14881 p_effective_end_date => r_RGR.information3,
14882 p_effective_start_date => r_RGR.information2,
14883 p_dml_operation => r_RGR.dml_operation,
14884 p_datetrack_mode => l_datetrack_mode );
14885 -- p_update => l_update
14886 --
14887 l_effective_date := l_process_date;
14888 l_POPL_RPTG_GRP_ID := r_RGR.information1;
14889 l_object_version_number := r_RGR.information265;
14890 --
14891 end if;
14892 --
14893 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
14894 --
14895 IF l_update OR l_dml_operation <> 'UPDATE' THEN
14896 --UPD END
14897
14898 BEN_POPL_RPTG_GRP_API.UPDATE_POPL_RPTG_GRP(
14899 --
14900 P_VALIDATE => false
14901 ,P_EFFECTIVE_DATE => l_effective_date
14902 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
14903 --
14904 ,P_PGM_ID => l_PGM_ID
14905 ,P_PL_ID => l_PL_ID
14906 ,P_POPL_RPTG_GRP_ID => l_popl_rptg_grp_id
14907 ,P_RGR_ATTRIBUTE1 => r_RGR.INFORMATION111
14908 ,P_RGR_ATTRIBUTE10 => r_RGR.INFORMATION120
14909 ,P_RGR_ATTRIBUTE11 => r_RGR.INFORMATION121
14910 ,P_RGR_ATTRIBUTE12 => r_RGR.INFORMATION122
14911 ,P_RGR_ATTRIBUTE13 => r_RGR.INFORMATION123
14912 ,P_RGR_ATTRIBUTE14 => r_RGR.INFORMATION124
14913 ,P_RGR_ATTRIBUTE15 => r_RGR.INFORMATION125
14914 ,P_RGR_ATTRIBUTE16 => r_RGR.INFORMATION126
14915 ,P_RGR_ATTRIBUTE17 => r_RGR.INFORMATION127
14916 ,P_RGR_ATTRIBUTE18 => r_RGR.INFORMATION128
14917 ,P_RGR_ATTRIBUTE19 => r_RGR.INFORMATION129
14918 ,P_RGR_ATTRIBUTE2 => r_RGR.INFORMATION112
14919 ,P_RGR_ATTRIBUTE20 => r_RGR.INFORMATION130
14920 ,P_RGR_ATTRIBUTE21 => r_RGR.INFORMATION131
14921 ,P_RGR_ATTRIBUTE22 => r_RGR.INFORMATION132
14922 ,P_RGR_ATTRIBUTE23 => r_RGR.INFORMATION133
14923 ,P_RGR_ATTRIBUTE24 => r_RGR.INFORMATION134
14924 ,P_RGR_ATTRIBUTE25 => r_RGR.INFORMATION135
14925 ,P_RGR_ATTRIBUTE26 => r_RGR.INFORMATION136
14926 ,P_RGR_ATTRIBUTE27 => r_RGR.INFORMATION137
14927 ,P_RGR_ATTRIBUTE28 => r_RGR.INFORMATION138
14928 ,P_RGR_ATTRIBUTE29 => r_RGR.INFORMATION139
14929 ,P_RGR_ATTRIBUTE3 => r_RGR.INFORMATION113
14930 ,P_RGR_ATTRIBUTE30 => r_RGR.INFORMATION140
14931 ,P_RGR_ATTRIBUTE4 => r_RGR.INFORMATION114
14932 ,P_RGR_ATTRIBUTE5 => r_RGR.INFORMATION115
14933 ,P_RGR_ATTRIBUTE6 => r_RGR.INFORMATION116
14934 ,P_RGR_ATTRIBUTE7 => r_RGR.INFORMATION117
14935 ,P_RGR_ATTRIBUTE8 => r_RGR.INFORMATION118
14936 ,P_RGR_ATTRIBUTE9 => r_RGR.INFORMATION119
14937 ,P_RGR_ATTRIBUTE_CATEGORY => r_RGR.INFORMATION110
14938 ,P_RPTG_GRP_ID => l_RPTG_GRP_ID
14939 --
14940 ,P_EFFECTIVE_START_DATE => l_effective_start_date
14941 ,P_EFFECTIVE_END_DATE => l_effective_end_date
14942 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
14943 ,P_DATETRACK_MODE => l_datetrack_mode
14944 );
14945 --
14946 end if; -- l_update
14947 end if;
14948 --
14949 -- Delete the row if it is end dated.
14950 --
14951 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
14952 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
14953 trunc(l_max_eed) = r_RGR.information3) then
14954 --
14955 BEN_POPL_RPTG_GRP_API.delete_POPL_RPTG_GRP(
14956 --
14957 p_validate => false
14958 ,p_popl_rptg_grp_id => l_popl_rptg_grp_id
14959 ,p_effective_start_date => l_effective_start_date
14960 ,p_effective_end_date => l_effective_end_date
14961 ,p_object_version_number => l_object_version_number
14962 ,p_effective_date => l_max_eed
14963 ,p_datetrack_mode => hr_api.g_delete
14964 --
14965 );
14966 --
14967 end if;
14968 --
14969 l_prev_pk_id := l_current_pk_id ;
14970 --
14971 end if;
14972 --
14973 end if;
14974 --
14975 end if;
14976 --
14977 end loop;
14978 --
14979 exception when others then
14980 --
14981 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'RGR',r_rgr.information5 );
14982 --
14983 end create_RGR_rows;
14984
14985 ---------------------------------------------------------------
14986 ----------------------< create_ECF_rows >-----------------------
14987 ---------------------------------------------------------------
14988 --
14989 procedure create_ECF_rows
14990 (
14991 p_validate in number default 0
14992 ,p_copy_entity_txn_id in number
14993 ,p_effective_date in date
14994 ,p_prefix_suffix_text in varchar2 default null
14995 ,p_reuse_object_flag in varchar2 default null
14996 ,p_target_business_group_id in varchar2 default null
14997 ,p_prefix_suffix_cd in varchar2 default null
14998 ) is
14999 --
15000 l_CTFN_RQD_WHEN_RL number;
15001 l_OIPL_ID number;
15002 l_PL_ID number;
15003 l_ENRT_CTFN_TYP_CD varchar2(30) ;
15004 --
15005 cursor c_unique_ECF(l_table_alias varchar2) is
15006 select distinct cpe.information1,
15007 cpe.information2,
15008 cpe.information3,
15009 cpe.table_route_id
15010 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
15011 pqh_table_route tr
15012 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15013 and cpe.table_route_id = tr.table_route_id
15014 -- and tr.where_clause = l_BEN_ENRT_CTFN_F
15015 and tr.table_alias = l_table_alias
15016 and cpe.number_of_copies = 1 -- ADDITION
15017 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
15018 order by information1, information2; --added for bug: 5151945
15019 --
15020 --
15021 cursor c_ECF_min_max_dates(c_table_route_id number,
15022 c_information1 number) is
15023 select
15024 min(cpe.information2) min_esd,
15025 max(cpe.information3) min_eed
15026 from ben_copy_entity_results cpe
15027 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15028 and cpe.table_route_id = c_table_route_id
15029 and cpe.information1 = c_information1 ;
15030 --
15031 cursor c_ECF(c_table_route_id number,
15032 c_information1 number,
15033 c_information2 date,
15034 c_information3 date) is
15035 select
15036 cpe.*
15037 from ben_copy_entity_results cpe
15038 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15039 and cpe.table_route_id = c_table_route_id
15040 and cpe.information1 = c_information1
15041 and cpe.information2 = c_information2
15042 and cpe.information3 = c_information3
15043 and rownum = 1 ;
15044 -- Date Track target record
15045 cursor c_find_ECF_in_target(
15046 c_effective_start_date date,
15047 c_effective_end_date date,
15048 c_business_group_id number,
15049 c_new_pk_id number) is
15050 select
15051 ECF.enrt_ctfn_id new_value
15052 from BEN_ENRT_CTFN_F ECF
15053 where
15054 nvl(ECF.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
15055 nvl(ECF.PL_ID,-999) = nvl(l_PL_ID,-999) and
15056 nvl(ECF.ENRT_CTFN_TYP_CD,'XXX') = nvl(l_ENRT_CTFN_TYP_CD,'XXX') and
15057 ECF.business_group_id = c_business_group_id
15058 and ECF.enrt_ctfn_id <> c_new_pk_id
15059 --TEMPIK
15060 and c_effective_start_date between effective_start_date
15061 and effective_end_date ;
15062 --END TEMPIK
15063 /*TEMPIK
15064 and exists ( select null
15065 from BEN_ENRT_CTFN_F ECF1
15066 where
15067 nvl(ECF1.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
15068 nvl(ECF1.PL_ID,-999) = nvl(l_PL_ID,-999) and
15069 ECF1.ENRT_CTFN_TYP_CD = l_ENRT_CTFN_TYP_CD and
15070 ECF1.business_group_id = c_business_group_id
15071 and ECF1.effective_start_date <= c_effective_start_date )
15072 and exists ( select null
15073 from BEN_ENRT_CTFN_F ECF2
15074 where
15075 nvl(ECF2.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
15076 nvl(ECF2.PL_ID,-999) = nvl(l_PL_ID,-999) and
15077 ECF2.ENRT_CTFN_TYP_CD = l_ENRT_CTFN_TYP_CD and
15078 ECF2.business_group_id = c_business_group_id
15079 and ECF2.effective_end_date >= c_effective_end_date )
15080 ;
15081 TEMPIK */
15082 --TEMPIK
15083 l_dt_rec_found boolean ;
15084 --END TEMPIK
15085 --
15086 --UPD START
15087 --
15088 l_update boolean := false ;
15089 l_datetrack_mode varchar2(80) := hr_api.g_update;
15090 l_process_date date;
15091 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
15092 --
15093 --UPD END
15094 l_current_pk_id number := null ;
15095 l_prev_pk_id number := null ;
15096 l_first_rec boolean := true ;
15097 r_ECF c_ECF%rowtype;
15098 l_enrt_ctfn_id number ;
15099 l_object_version_number number ;
15100 l_effective_start_date date ;
15101 l_effective_end_date date ;
15102 l_prefix pqh_copy_entity_attribs.information1%type := null;
15103 l_suffix pqh_copy_entity_attribs.information1%type := null;
15104 l_new_value number(15);
15105 l_object_found_in_target boolean := false ;
15106 l_min_esd date;
15107 l_max_eed date;
15108 l_effective_date date;
15109 --
15110 begin
15111 -- Initialization
15112 l_object_found_in_target := false ;
15113 -- End Initialization
15114 -- Derive the prefix - sufix
15115 if p_prefix_suffix_cd = 'PREFIX' then
15116 l_prefix := p_prefix_suffix_text ;
15117 elsif p_prefix_suffix_cd = 'SUFFIX' then
15118 l_suffix := p_prefix_suffix_text ;
15119 else
15120 l_prefix := null ;
15121 l_suffix := null ;
15122 end if ;
15123 -- End Prefix Sufix derivation
15124 for r_ECF_unique in c_unique_ECF('ECF') loop
15125
15126 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
15127 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15128 r_ECF_unique.information3 >=
15129 ben_pd_copy_to_ben_one.g_copy_effective_date)
15130 ) then
15131
15132 --
15133 hr_utility.set_location(' r_ECF_unique.table_route_id '||r_ECF_unique.table_route_id,10);
15134 hr_utility.set_location(' r_ECF_unique.information1 '||r_ECF_unique.information1,10);
15135 hr_utility.set_location( 'r_ECF_unique.information2 '||r_ECF_unique.information2,10);
15136 hr_utility.set_location( 'r_ECF_unique.information3 '||r_ECF_unique.information3,10);
15137 -- If reuse objects flag is 'Y' then check for the object in the target business group
15138 -- if found insert the record into PLSql table and exit the loop else try create the
15139 -- object in the target business group
15140 --
15141 l_object_found_in_target := false ;
15142 --UPD START
15143 open c_ECF(r_ECF_unique.table_route_id,
15144 r_ECF_unique.information1,
15145 r_ECF_unique.information2,
15146 r_ECF_unique.information3 ) ;
15147 --
15148 fetch c_ECF into r_ECF ;
15149 --
15150 close c_ECF ;
15151 l_dml_operation:= r_ECF_unique.dml_operation ;
15152 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_ECF.INFORMATION262,l_dml_operation);
15153 l_OIPL_ID := get_fk('OIPL_ID', r_ECF.INFORMATION258,l_dml_operation);
15154 l_PL_ID := get_fk('PL_ID', r_ECF.INFORMATION261,l_dml_operation);
15155 l_update := false;
15156 l_process_date := p_effective_date;
15157 --
15158 if l_dml_operation = 'UPDATE' then
15159 --
15160 l_object_found_in_target := TRUE;
15161 --
15162 if l_process_date between r_ECF_unique.information2 and r_ECF_unique.information3 then
15163 l_update := true;
15164 if r_ECF_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
15165 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ENRT_CTFN_ID'
15166 then
15167 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ENRT_CTFN_ID' ;
15168 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECF_unique.information1 ;
15169 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ECF_unique.information1 ;
15170 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
15171 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECF_unique.table_route_id;
15172 --
15173 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
15174 --
15175 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
15176 --
15177 --DOUBT log_data('ECF',l_new_value,l_prefix || r_ECF_unique.name|| l_suffix,'REUSED');
15178 --
15179 end if ;
15180 hr_utility.set_location( 'found record for update',10);
15181 --
15182 else
15183 --
15184 l_update := false;
15185 --
15186 end if;
15187 else
15188 --
15189 --UPD END
15190 l_min_esd := null ;
15191 l_max_eed := null ;
15192 open c_ECF_min_max_dates(r_ECF_unique.table_route_id, r_ECF_unique.information1 ) ;
15193 fetch c_ECF_min_max_dates into l_min_esd,l_max_eed ;
15194 --
15195
15196 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15197 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
15198 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
15199 end if;
15200 l_min_esd := greatest(l_min_esd,r_ECF_unique.information2);
15201 /* open c_ECF(r_ECF_unique.table_route_id,
15202 r_ECF_unique.information1,
15203 r_ECF_unique.information2,
15204 r_ECF_unique.information3 ) ;
15205 --
15206 fetch c_ECF into r_ECF ;
15207 --
15208 close c_ECF ; */
15209 --
15210 l_ENRT_CTFN_TYP_CD := r_ECF.information11;
15211 --
15212 if p_reuse_object_flag = 'Y' then
15213 if c_ECF_min_max_dates%found then
15214 -- cursor to find the object
15215 open c_find_ECF_in_target( l_min_esd,l_max_eed,
15216 p_target_business_group_id, nvl(l_enrt_ctfn_id, -999) ) ;
15217 fetch c_find_ECF_in_target into l_new_value ;
15218 if c_find_ECF_in_target%found then
15219 --
15220 --TEMPIK
15221 l_dt_rec_found := dt_api.check_min_max_dates
15222 (p_base_table_name => 'BEN_ENRT_CTFN_F',
15223 p_base_key_column => 'ENRT_CTFN_ID',
15224 p_base_key_value => l_new_value,
15225 p_from_date => l_min_esd,
15226 p_to_date => l_max_eed );
15227 if l_dt_rec_found THEN
15228 --END TEMPIK
15229 if r_ECF_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
15230 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ENRT_CTFN_ID' then
15231 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ENRT_CTFN_ID' ;
15232 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECF_unique.information1 ;
15233 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
15234 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
15235 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECF_unique.table_route_id;
15236 --
15237 -- 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) ;
15238 --
15239 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
15240 end if ;
15241 --
15242 l_object_found_in_target := true ;
15243 --TEMPIK
15244 end if; -- l_dt_rec_found
15245 --END TEMPIK
15246 end if;
15247 close c_find_ECF_in_target ;
15248 --
15249 end if;
15250 end if ;
15251 --
15252 close c_ECF_min_max_dates ;
15253 end if; --if p_dml_operation
15254 --
15255 if not l_object_found_in_target OR l_update then
15256 --
15257 l_current_pk_id := r_ECF.information1;
15258 --
15259 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
15260 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
15261 --
15262 if l_current_pk_id = l_prev_pk_id then
15263 --
15264 l_first_rec := false ;
15265 --
15266 else
15267 --
15268 l_first_rec := true ;
15269 --
15270 end if ;
15271 --
15272
15273 l_effective_date := r_ECF.information2;
15274 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15275 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
15276 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
15277 end if;
15278
15279 if l_first_rec and not l_update then
15280 -- Call Create routine.
15281 hr_utility.set_location(' BEN_ENRT_CTFN_F CREATE_ENRT_CTFN ',20);
15282 BEN_ENRT_CTFN_API.CREATE_ENRT_CTFN(
15283 --
15284 P_VALIDATE => false
15285 ,P_EFFECTIVE_DATE => l_effective_date
15286 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
15287 --
15288 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
15289 ,P_ECF_ATTRIBUTE1 => r_ECF.INFORMATION111
15290 ,P_ECF_ATTRIBUTE10 => r_ECF.INFORMATION120
15291 ,P_ECF_ATTRIBUTE11 => r_ECF.INFORMATION121
15292 ,P_ECF_ATTRIBUTE12 => r_ECF.INFORMATION122
15293 ,P_ECF_ATTRIBUTE13 => r_ECF.INFORMATION123
15294 ,P_ECF_ATTRIBUTE14 => r_ECF.INFORMATION124
15295 ,P_ECF_ATTRIBUTE15 => r_ECF.INFORMATION125
15296 ,P_ECF_ATTRIBUTE16 => r_ECF.INFORMATION126
15297 ,P_ECF_ATTRIBUTE17 => r_ECF.INFORMATION127
15298 ,P_ECF_ATTRIBUTE18 => r_ECF.INFORMATION128
15299 ,P_ECF_ATTRIBUTE19 => r_ECF.INFORMATION129
15300 ,P_ECF_ATTRIBUTE2 => r_ECF.INFORMATION112
15301 ,P_ECF_ATTRIBUTE20 => r_ECF.INFORMATION130
15302 ,P_ECF_ATTRIBUTE21 => r_ECF.INFORMATION131
15303 ,P_ECF_ATTRIBUTE22 => r_ECF.INFORMATION132
15304 ,P_ECF_ATTRIBUTE23 => r_ECF.INFORMATION133
15305 ,P_ECF_ATTRIBUTE24 => r_ECF.INFORMATION134
15306 ,P_ECF_ATTRIBUTE25 => r_ECF.INFORMATION135
15307 ,P_ECF_ATTRIBUTE26 => r_ECF.INFORMATION136
15308 ,P_ECF_ATTRIBUTE27 => r_ECF.INFORMATION137
15309 ,P_ECF_ATTRIBUTE28 => r_ECF.INFORMATION138
15310 ,P_ECF_ATTRIBUTE29 => r_ECF.INFORMATION139
15311 ,P_ECF_ATTRIBUTE3 => r_ECF.INFORMATION113
15312 ,P_ECF_ATTRIBUTE30 => r_ECF.INFORMATION140
15313 ,P_ECF_ATTRIBUTE4 => r_ECF.INFORMATION114
15314 ,P_ECF_ATTRIBUTE5 => r_ECF.INFORMATION115
15315 ,P_ECF_ATTRIBUTE6 => r_ECF.INFORMATION116
15316 ,P_ECF_ATTRIBUTE7 => r_ECF.INFORMATION117
15317 ,P_ECF_ATTRIBUTE8 => r_ECF.INFORMATION118
15318 ,P_ECF_ATTRIBUTE9 => r_ECF.INFORMATION119
15319 ,P_ECF_ATTRIBUTE_CATEGORY => r_ECF.INFORMATION110
15320 ,P_ENRT_CTFN_ID => l_enrt_ctfn_id
15321 ,P_ENRT_CTFN_TYP_CD => r_ECF.INFORMATION11
15322 ,P_OIPL_ID => l_OIPL_ID
15323 ,P_PL_ID => l_PL_ID
15324 ,P_RQD_FLAG => r_ECF.INFORMATION12
15325 --
15326 ,P_EFFECTIVE_START_DATE => l_effective_start_date
15327 ,P_EFFECTIVE_END_DATE => l_effective_end_date
15328 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
15329 );
15330 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
15331 -- Update all relevent cer records with new pk_id
15332 hr_utility.set_location('Before plsql table ',222);
15333 hr_utility.set_location('new_value id '||l_enrt_ctfn_id,222);
15334 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ENRT_CTFN_ID' ;
15335 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ECF.information1 ;
15336 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ENRT_CTFN_ID ;
15337 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
15338 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ECF_unique.table_route_id;
15339 hr_utility.set_location('After plsql table ',222);
15340 --
15341 -- 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 ) ;
15342 --
15343 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
15344 --
15345 else
15346 --
15347 -- Call Update routine for the pk_id created in prev run .
15348 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
15349 hr_utility.set_location(' BEN_ENRT_CTFN_F UPDATE_ENRT_CTFN ',30);
15350 --UPD START
15351 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
15352 --
15353 if l_update then
15354 --
15355 l_datetrack_mode := r_ECF.datetrack_mode ;
15356 --
15357 get_dt_modes(
15358 p_effective_date => l_process_date,
15359 p_effective_end_date => r_ECF.information3,
15360 p_effective_start_date => r_ECF.information2,
15361 p_dml_operation => r_ECF.dml_operation,
15362 p_datetrack_mode => l_datetrack_mode );
15363 -- p_update => l_update
15364 --
15365 l_effective_date := l_process_date;
15366 l_ENRT_CTFN_ID := r_ECF.information1;
15367 l_object_version_number := r_ECF.information265;
15368 --
15369 end if;
15370 --
15371 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
15372 --
15373 IF l_update OR l_dml_operation <> 'UPDATE' THEN
15374 --UPD END
15375
15376 BEN_ENRT_CTFN_API.UPDATE_ENRT_CTFN(
15377 --
15378 P_VALIDATE => false
15379 ,P_EFFECTIVE_DATE => l_effective_date
15380 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
15381 --
15382 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
15383 ,P_ECF_ATTRIBUTE1 => r_ECF.INFORMATION111
15384 ,P_ECF_ATTRIBUTE10 => r_ECF.INFORMATION120
15385 ,P_ECF_ATTRIBUTE11 => r_ECF.INFORMATION121
15386 ,P_ECF_ATTRIBUTE12 => r_ECF.INFORMATION122
15387 ,P_ECF_ATTRIBUTE13 => r_ECF.INFORMATION123
15388 ,P_ECF_ATTRIBUTE14 => r_ECF.INFORMATION124
15389 ,P_ECF_ATTRIBUTE15 => r_ECF.INFORMATION125
15390 ,P_ECF_ATTRIBUTE16 => r_ECF.INFORMATION126
15391 ,P_ECF_ATTRIBUTE17 => r_ECF.INFORMATION127
15392 ,P_ECF_ATTRIBUTE18 => r_ECF.INFORMATION128
15393 ,P_ECF_ATTRIBUTE19 => r_ECF.INFORMATION129
15394 ,P_ECF_ATTRIBUTE2 => r_ECF.INFORMATION112
15395 ,P_ECF_ATTRIBUTE20 => r_ECF.INFORMATION130
15396 ,P_ECF_ATTRIBUTE21 => r_ECF.INFORMATION131
15397 ,P_ECF_ATTRIBUTE22 => r_ECF.INFORMATION132
15398 ,P_ECF_ATTRIBUTE23 => r_ECF.INFORMATION133
15399 ,P_ECF_ATTRIBUTE24 => r_ECF.INFORMATION134
15400 ,P_ECF_ATTRIBUTE25 => r_ECF.INFORMATION135
15401 ,P_ECF_ATTRIBUTE26 => r_ECF.INFORMATION136
15402 ,P_ECF_ATTRIBUTE27 => r_ECF.INFORMATION137
15403 ,P_ECF_ATTRIBUTE28 => r_ECF.INFORMATION138
15404 ,P_ECF_ATTRIBUTE29 => r_ECF.INFORMATION139
15405 ,P_ECF_ATTRIBUTE3 => r_ECF.INFORMATION113
15406 ,P_ECF_ATTRIBUTE30 => r_ECF.INFORMATION140
15407 ,P_ECF_ATTRIBUTE4 => r_ECF.INFORMATION114
15408 ,P_ECF_ATTRIBUTE5 => r_ECF.INFORMATION115
15409 ,P_ECF_ATTRIBUTE6 => r_ECF.INFORMATION116
15410 ,P_ECF_ATTRIBUTE7 => r_ECF.INFORMATION117
15411 ,P_ECF_ATTRIBUTE8 => r_ECF.INFORMATION118
15412 ,P_ECF_ATTRIBUTE9 => r_ECF.INFORMATION119
15413 ,P_ECF_ATTRIBUTE_CATEGORY => r_ECF.INFORMATION110
15414 ,P_ENRT_CTFN_ID => l_enrt_ctfn_id
15415 ,P_ENRT_CTFN_TYP_CD => r_ECF.INFORMATION11
15416 ,P_OIPL_ID => l_OIPL_ID
15417 ,P_PL_ID => l_PL_ID
15418 ,P_RQD_FLAG => r_ECF.INFORMATION12
15419 --
15420 ,P_EFFECTIVE_START_DATE => l_effective_start_date
15421 ,P_EFFECTIVE_END_DATE => l_effective_end_date
15422 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
15423 ,P_DATETRACK_MODE => l_datetrack_mode
15424 );
15425 --
15426 end if; -- l_update
15427 end if;
15428 --
15429 -- Delete the row if it is end dated.
15430 --
15431 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
15432 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
15433 trunc(l_max_eed) = r_ECF.information3) then
15434 --
15435 BEN_ENRT_CTFN_API.delete_ENRT_CTFN(
15436 --
15437 p_validate => false
15438 ,p_enrt_ctfn_id => l_enrt_ctfn_id
15439 ,p_effective_start_date => l_effective_start_date
15440 ,p_effective_end_date => l_effective_end_date
15441 ,p_object_version_number => l_object_version_number
15442 ,p_effective_date => l_max_eed
15443 ,p_datetrack_mode => hr_api.g_delete
15444 --
15445 );
15446 --
15447 end if;
15448 --
15449 l_prev_pk_id := l_current_pk_id ;
15450 --
15451 end if;
15452 --
15453 end if;
15454 --
15455 end loop;
15456 --
15457 exception when others then
15458 --
15459 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ECF',r_ecf.information5 );
15460 --
15461 end create_ECF_rows;
15462
15463 --
15464 ---------------------------------------------------------------
15465 ----------------------< create_EPA_rows >-----------------------
15466 ---------------------------------------------------------------
15467 --
15468 procedure create_EPA_rows
15469 (
15470 p_validate in number default 0
15471 ,p_copy_entity_txn_id in number
15472 ,p_effective_date in date
15473 ,p_prefix_suffix_text in varchar2 default null
15474 ,p_reuse_object_flag in varchar2 default null
15475 ,p_target_business_group_id in varchar2 default null
15476 ,p_prefix_suffix_cd in varchar2 default null
15477 ) is
15478 --
15479 l_MX_POE_DET_DT_RL number;
15480 l_MX_POE_RL number;
15481 l_OIPL_ID number;
15482 l_PGM_ID number;
15483 l_PLIP_ID number;
15484 l_PL_ID number;
15485 l_PRTN_EFF_END_DT_RL number;
15486 l_PRTN_EFF_STRT_DT_RL number;
15487 l_PTIP_ID number;
15488 l_WAIT_PERD_DT_TO_USE_RL number;
15489 l_WAIT_PERD_RL number;
15490 cursor c_unique_EPA(l_table_alias varchar2) is
15491 select distinct cpe.information1,
15492 cpe.information2,
15493 cpe.information3,
15494 cpe.table_route_id
15495 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
15496 pqh_table_route tr
15497 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15498 and cpe.table_route_id = tr.table_route_id
15499 -- and tr.where_clause = l_BEN_PRTN_ELIG_F
15500 and tr.table_alias = l_table_alias
15501 and cpe.number_of_copies = 1 -- ADDITION
15502 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
15503 order by information1, information2; --added for bug: 5151945
15504 --
15505 --
15506 cursor c_EPA_min_max_dates(c_table_route_id number,
15507 c_information1 number) is
15508 select
15509 min(cpe.information2) min_esd,
15510 max(cpe.information3) min_eed
15511 from ben_copy_entity_results cpe
15512 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15513 and cpe.table_route_id = c_table_route_id
15514 and cpe.information1 = c_information1 ;
15515 --
15516 cursor c_EPA(c_table_route_id number,
15517 c_information1 number,
15518 c_information2 date,
15519 c_information3 date ) is
15520 select
15521 cpe.*
15522 from ben_copy_entity_results cpe
15523 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15524 and cpe.table_route_id = c_table_route_id
15525 and cpe.information1 = c_information1
15526 and cpe.information2 = c_information2
15527 and cpe.information3 = c_information3
15528 and rownum = 1 ;
15529 -- Date Track target record
15530 cursor c_find_EPA_in_target(
15531 c_effective_start_date date,
15532 c_effective_end_date date,
15533 c_business_group_id number,
15534 c_new_pk_id number) is
15535 select
15536 EPA.prtn_elig_id new_value
15537 from BEN_PRTN_ELIG_F EPA
15538 where
15539 nvl(EPA.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
15540 nvl(EPA.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
15541 nvl(EPA.PLIP_ID,-999) = nvl(l_PLIP_ID,-999) and
15542 nvl(EPA.PL_ID,-999) = nvl(l_PL_ID,-999) and
15543 nvl(EPA.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
15544 EPA.business_group_id = c_business_group_id
15545 and EPA.prtn_elig_id <> c_new_pk_id
15546 --TEMPIK
15547 and c_effective_start_date between effective_start_date
15548 and effective_end_date ;
15549 --END TEMPIK
15550 /*TEMPIK
15551 and exists ( select null
15552 from BEN_PRTN_ELIG_F EPA1
15553 where
15554 nvl(EPA1.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
15555 nvl(EPA1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
15556 nvl(EPA1.PLIP_ID,-999) = nvl(l_PLIP_ID,-999) and
15557 nvl(EPA1.PL_ID,-999) = nvl(l_PL_ID,-999) and
15558 nvl(EPA1.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
15559 EPA1.business_group_id = c_business_group_id
15560 and EPA1.effective_start_date <= c_effective_start_date )
15561 and exists ( select null
15562 from BEN_PRTN_ELIG_F EPA2
15563 where
15564 nvl(EPA2.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
15565 nvl(EPA2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
15566 nvl(EPA2.PLIP_ID,-999) = nvl(l_PLIP_ID,-999) and
15567 nvl(EPA2.PL_ID,-999) = nvl(l_PL_ID,-999) and
15568 nvl(EPA2.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
15569 EPA2.business_group_id = c_business_group_id
15570 and EPA2.effective_end_date >= c_effective_end_date )
15571 ;
15572 TEMPIK */
15573 --TEMPIK
15574 l_dt_rec_found boolean ;
15575 --END TEMPIK
15576 --
15577 --UPD START
15578 --
15579 l_update boolean := false ;
15580 l_datetrack_mode varchar2(80) := hr_api.g_update;
15581 l_process_date date;
15582 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
15583 --
15584 --UPD END
15585 l_current_pk_id number := null ;
15586 l_prev_pk_id number := null ;
15587 l_first_rec boolean := true ;
15588 r_EPA c_EPA%rowtype;
15589 l_prtn_elig_id number ;
15590 l_object_version_number number ;
15591 l_effective_start_date date ;
15592 l_effective_end_date date ;
15593 l_prefix pqh_copy_entity_attribs.information1%type := null;
15594 l_suffix pqh_copy_entity_attribs.information1%type := null;
15595 l_new_value number(15);
15596 l_object_found_in_target boolean := false ;
15597 l_min_esd date;
15598 l_max_eed date;
15599 l_effective_date date;
15600 --
15601 begin
15602 -- Initialization
15603 l_object_found_in_target := false ;
15604 -- End Initialization
15605 -- Derive the prefix - sufix
15606 if p_prefix_suffix_cd = 'PREFIX' then
15607 l_prefix := p_prefix_suffix_text ;
15608 elsif p_prefix_suffix_cd = 'SUFFIX' then
15609 l_suffix := p_prefix_suffix_text ;
15610 else
15611 l_prefix := null ;
15612 l_suffix := null ;
15613 end if ;
15614 -- End Prefix Sufix derivation
15615 for r_EPA_unique in c_unique_EPA('EPA') loop
15616
15617 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
15618 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15619 r_EPA_unique.information3 >=
15620 ben_pd_copy_to_ben_one.g_copy_effective_date)
15621 ) then
15622 --
15623 hr_utility.set_location(' r_EPA_unique.table_route_id '||r_EPA_unique.table_route_id,10);
15624 hr_utility.set_location(' r_EPA_unique.information1 '||r_EPA_unique.information1,10);
15625 hr_utility.set_location( 'r_EPA_unique.information2 '||r_EPA_unique.information2,10);
15626 hr_utility.set_location( 'r_EPA_unique.information3 '||r_EPA_unique.information3,10);
15627 -- If reuse objects flag is 'Y' then check for the object in the target business group
15628 -- if found insert the record into PLSql table and exit the loop else try create the
15629 -- object in the target business group
15630 --
15631 l_object_found_in_target := false ;
15632 --UPD START
15633 open c_EPA(r_EPA_unique.table_route_id,
15634 r_EPA_unique.information1,
15635 r_EPA_unique.information2,
15636 r_EPA_unique.information3 ) ;
15637 --
15638 fetch c_EPA into r_EPA ;
15639 --
15640 close c_EPA ;
15641 l_dml_operation:= r_EPA_unique.dml_operation ;
15642 l_MX_POE_DET_DT_RL := get_fk('FORMULA_ID', r_EPA.INFORMATION269,l_dml_operation );
15643 l_MX_POE_RL := get_fk('FORMULA_ID', r_EPA.INFORMATION267,l_dml_operation );
15644 l_OIPL_ID := get_fk('OIPL_ID', r_EPA.INFORMATION258,l_dml_operation );
15645 l_PGM_ID := get_fk('PGM_ID', r_EPA.INFORMATION260,l_dml_operation );
15646 l_PLIP_ID := get_fk('PLIP_ID', r_EPA.INFORMATION256,l_dml_operation );
15647 l_PL_ID := get_fk('PL_ID', r_EPA.INFORMATION261,l_dml_operation );
15648 l_PRTN_EFF_END_DT_RL := get_fk('FORMULA_ID', r_EPA.INFORMATION271,l_dml_operation );
15649 l_PRTN_EFF_STRT_DT_RL := get_fk('FORMULA_ID', r_EPA.INFORMATION270,l_dml_operation );
15650 l_PTIP_ID := get_fk('PTIP_ID', r_EPA.INFORMATION259,l_dml_operation );
15651 l_WAIT_PERD_DT_TO_USE_RL := get_fk('FORMULA_ID', r_EPA.INFORMATION264,l_dml_operation );
15652 l_WAIT_PERD_RL := get_fk('FORMULA_ID', r_EPA.INFORMATION268,l_dml_operation );
15653 l_update := false;
15654 l_process_date := p_effective_date;
15655 --
15656 if l_dml_operation = 'UPDATE' then
15657 --
15658 l_object_found_in_target := TRUE;
15659 --
15660 if l_process_date between r_EPA_unique.information2 and r_EPA_unique.information3 then
15661 l_update := true;
15662 if r_EPA_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
15663 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PRTN_ELIG_ID'
15664 then
15665 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PRTN_ELIG_ID' ;
15666 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPA_unique.information1 ;
15667 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_EPA_unique.information1 ;
15668 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
15669 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPA_unique.table_route_id;
15670 --
15671 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
15672 --
15673 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
15674 --
15675 --DOUBT log_data('EPA',l_new_value,l_prefix || r_EPA_unique.name|| l_suffix,'REUSED');
15676 --
15677 end if ;
15678 hr_utility.set_location( 'found record for update',10);
15679 --
15680 else
15681 --
15682 l_update := false;
15683 --
15684 end if;
15685 else
15686 --
15687 --UPD END
15688 l_min_esd := null ;
15689 l_max_eed := null ;
15690 open c_EPA_min_max_dates(r_EPA_unique.table_route_id, r_EPA_unique.information1 ) ;
15691 fetch c_EPA_min_max_dates into l_min_esd,l_max_eed ;
15692 --
15693
15694 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15695 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
15696 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
15697 end if;
15698 l_min_esd := greatest(l_min_esd,r_EPA_unique.information2);
15699 /* open c_EPA(r_EPA_unique.table_route_id,
15700 r_EPA_unique.information1,
15701 r_EPA_unique.information2,
15702 r_EPA_unique.information3 ) ;
15703 --
15704 fetch c_EPA into r_EPA ;
15705 --
15706 close c_EPA ; */
15707 --
15708 if p_reuse_object_flag = 'Y' then
15709 if c_EPA_min_max_dates%found then
15710 -- cursor to find the object
15711 open c_find_EPA_in_target( l_min_esd,l_max_eed,
15712 p_target_business_group_id, nvl(l_prtn_elig_id, -999) ) ;
15713 fetch c_find_EPA_in_target into l_new_value ;
15714 if c_find_EPA_in_target%found then
15715 --
15716 --TEMPIK
15717 l_dt_rec_found := dt_api.check_min_max_dates
15718 (p_base_table_name => 'BEN_PRTN_ELIG_F',
15719 p_base_key_column => 'PRTN_ELIG_ID',
15720 p_base_key_value => l_new_value,
15721 p_from_date => l_min_esd,
15722 p_to_date => l_max_eed );
15723 if l_dt_rec_found THEN
15724 --END TEMPIK
15725 if r_EPA_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
15726 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PRTN_ELIG_ID' then
15727 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PRTN_ELIG_ID' ;
15728 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPA_unique.information1 ;
15729 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
15730 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
15731 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPA_unique.table_route_id;
15732 --
15733 -- 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) ;
15734 --
15735 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
15736 end if ;
15737 --
15738 l_object_found_in_target := true ;
15739 --TEMPIK
15740 end if; -- l_dt_rec_found
15741 --END TEMPIK
15742 end if;
15743 close c_find_EPA_in_target ;
15744 --
15745 end if;
15746 end if ;
15747 --
15748 close c_EPA_min_max_dates ;
15749 end if; --if p_dml_operation
15750 --
15751 if not l_object_found_in_target OR l_update then
15752 --
15753 l_current_pk_id := r_EPA.information1;
15754 --
15755 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
15756 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
15757 --
15758 if l_current_pk_id = l_prev_pk_id then
15759 --
15760 l_first_rec := false ;
15761 --
15762 else
15763 --
15764 l_first_rec := true ;
15765 --
15766 end if ;
15767 --
15768
15769 l_effective_date := r_EPA.information2;
15770 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15771 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
15772 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
15773 end if;
15774
15775 if l_first_rec and not l_update then
15776 -- Call Create routine.
15777 hr_utility.set_location(' BEN_PRTN_ELIG_F CREATE_PARTICIPATION_ELIG ',20);
15778 BEN_PARTICIPATION_ELIG_API.CREATE_PARTICIPATION_ELIG(
15779 --
15780 P_VALIDATE => false
15781 ,P_EFFECTIVE_DATE => l_effective_date
15782 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
15783 --
15784 ,P_EPA_ATTRIBUTE1 => r_EPA.INFORMATION111
15785 ,P_EPA_ATTRIBUTE10 => r_EPA.INFORMATION120
15786 ,P_EPA_ATTRIBUTE11 => r_EPA.INFORMATION121
15787 ,P_EPA_ATTRIBUTE12 => r_EPA.INFORMATION122
15788 ,P_EPA_ATTRIBUTE13 => r_EPA.INFORMATION123
15789 ,P_EPA_ATTRIBUTE14 => r_EPA.INFORMATION124
15790 ,P_EPA_ATTRIBUTE15 => r_EPA.INFORMATION125
15791 ,P_EPA_ATTRIBUTE16 => r_EPA.INFORMATION126
15792 ,P_EPA_ATTRIBUTE17 => r_EPA.INFORMATION127
15793 ,P_EPA_ATTRIBUTE18 => r_EPA.INFORMATION128
15794 ,P_EPA_ATTRIBUTE19 => r_EPA.INFORMATION129
15795 ,P_EPA_ATTRIBUTE2 => r_EPA.INFORMATION112
15796 ,P_EPA_ATTRIBUTE20 => r_EPA.INFORMATION130
15797 ,P_EPA_ATTRIBUTE21 => r_EPA.INFORMATION131
15798 ,P_EPA_ATTRIBUTE22 => r_EPA.INFORMATION132
15799 ,P_EPA_ATTRIBUTE23 => r_EPA.INFORMATION133
15800 ,P_EPA_ATTRIBUTE24 => r_EPA.INFORMATION134
15801 ,P_EPA_ATTRIBUTE25 => r_EPA.INFORMATION135
15802 ,P_EPA_ATTRIBUTE26 => r_EPA.INFORMATION136
15803 ,P_EPA_ATTRIBUTE27 => r_EPA.INFORMATION137
15804 ,P_EPA_ATTRIBUTE28 => r_EPA.INFORMATION138
15805 ,P_EPA_ATTRIBUTE29 => r_EPA.INFORMATION139
15806 ,P_EPA_ATTRIBUTE3 => r_EPA.INFORMATION113
15807 ,P_EPA_ATTRIBUTE30 => r_EPA.INFORMATION140
15808 ,P_EPA_ATTRIBUTE4 => r_EPA.INFORMATION114
15809 ,P_EPA_ATTRIBUTE5 => r_EPA.INFORMATION115
15810 ,P_EPA_ATTRIBUTE6 => r_EPA.INFORMATION116
15811 ,P_EPA_ATTRIBUTE7 => r_EPA.INFORMATION117
15812 ,P_EPA_ATTRIBUTE8 => r_EPA.INFORMATION118
15813 ,P_EPA_ATTRIBUTE9 => r_EPA.INFORMATION119
15814 ,P_EPA_ATTRIBUTE_CATEGORY => r_EPA.INFORMATION110
15815 ,P_MX_POE_APLS_CD => r_EPA.INFORMATION17
15816 ,P_MX_POE_DET_DT_CD => r_EPA.INFORMATION13
15817 ,P_MX_POE_DET_DT_RL => l_MX_POE_DET_DT_RL
15818 ,P_MX_POE_RL => l_MX_POE_RL
15819 ,P_MX_POE_UOM => r_EPA.INFORMATION11
15820 ,P_MX_POE_VAL => r_EPA.INFORMATION266
15821 ,P_OIPL_ID => l_OIPL_ID
15822 ,P_PGM_ID => l_PGM_ID
15823 ,P_PLIP_ID => l_PLIP_ID
15824 ,P_PL_ID => l_PL_ID
15825 ,P_PRTN_EFF_END_DT_CD => r_EPA.INFORMATION16
15826 ,P_PRTN_EFF_END_DT_RL => l_PRTN_EFF_END_DT_RL
15827 ,P_PRTN_EFF_STRT_DT_CD => r_EPA.INFORMATION15
15828 ,P_PRTN_EFF_STRT_DT_RL => l_PRTN_EFF_STRT_DT_RL
15829 ,P_PRTN_ELIG_ID => l_prtn_elig_id
15830 ,P_PTIP_ID => l_PTIP_ID
15831 ,P_WAIT_PERD_DT_TO_USE_CD => r_EPA.INFORMATION12
15832 ,P_WAIT_PERD_DT_TO_USE_RL => l_WAIT_PERD_DT_TO_USE_RL
15833 ,P_WAIT_PERD_RL => l_WAIT_PERD_RL
15834 ,P_WAIT_PERD_UOM => r_EPA.INFORMATION14
15835 ,P_WAIT_PERD_VAL => r_EPA.INFORMATION287
15836 ,P_TRK_SCR_FOR_INELG_FLAG => r_EPA.INFORMATION18 --BugNo 4242438
15837 --
15838 ,P_EFFECTIVE_START_DATE => l_effective_start_date
15839 ,P_EFFECTIVE_END_DATE => l_effective_end_date
15840 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
15841 );
15842 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
15843 -- Update all relevent cer records with new pk_id
15844 hr_utility.set_location('Before plsql table ',222);
15845 hr_utility.set_location('new_value id '||l_prtn_elig_id,222);
15846 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PRTN_ELIG_ID' ;
15847 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_EPA.information1 ;
15848 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PRTN_ELIG_ID ;
15849 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
15850 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_EPA_unique.table_route_id;
15851 hr_utility.set_location('After plsql table ',222);
15852 --
15853 -- 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 ) ;
15854 --
15855 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
15856 --
15857 else
15858 --
15859 -- Call Update routine for the pk_id created in prev run .
15860 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
15861 hr_utility.set_location(' BEN_PRTN_ELIG_F UPDATE_PARTICIPATION_ELIG ',30);
15862 --UPD START
15863 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
15864 --
15865 if l_update then
15866 --
15867 l_datetrack_mode := r_EPA.datetrack_mode ;
15868 --
15869 get_dt_modes(
15870 p_effective_date => l_process_date,
15871 p_effective_end_date => r_EPA.information3,
15872 p_effective_start_date => r_EPA.information2,
15873 p_dml_operation => r_EPA.dml_operation,
15874 p_datetrack_mode => l_datetrack_mode );
15875 -- p_update => l_update
15876 --
15877 l_effective_date := l_process_date;
15878 l_PRTN_ELIG_ID := r_EPA.information1;
15879 l_object_version_number := r_EPA.information265;
15880 --
15881 end if;
15882 --
15883 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
15884 --
15885 IF l_update OR l_dml_operation <> 'UPDATE' THEN
15886 --UPD END
15887
15888 BEN_PARTICIPATION_ELIG_API.UPDATE_PARTICIPATION_ELIG(
15889 --
15890 P_VALIDATE => false
15891 ,P_EFFECTIVE_DATE => l_effective_date
15892 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
15893 --
15894 ,P_EPA_ATTRIBUTE1 => r_EPA.INFORMATION111
15895 ,P_EPA_ATTRIBUTE10 => r_EPA.INFORMATION120
15896 ,P_EPA_ATTRIBUTE11 => r_EPA.INFORMATION121
15897 ,P_EPA_ATTRIBUTE12 => r_EPA.INFORMATION122
15898 ,P_EPA_ATTRIBUTE13 => r_EPA.INFORMATION123
15899 ,P_EPA_ATTRIBUTE14 => r_EPA.INFORMATION124
15900 ,P_EPA_ATTRIBUTE15 => r_EPA.INFORMATION125
15901 ,P_EPA_ATTRIBUTE16 => r_EPA.INFORMATION126
15902 ,P_EPA_ATTRIBUTE17 => r_EPA.INFORMATION127
15903 ,P_EPA_ATTRIBUTE18 => r_EPA.INFORMATION128
15904 ,P_EPA_ATTRIBUTE19 => r_EPA.INFORMATION129
15905 ,P_EPA_ATTRIBUTE2 => r_EPA.INFORMATION112
15906 ,P_EPA_ATTRIBUTE20 => r_EPA.INFORMATION130
15907 ,P_EPA_ATTRIBUTE21 => r_EPA.INFORMATION131
15908 ,P_EPA_ATTRIBUTE22 => r_EPA.INFORMATION132
15909 ,P_EPA_ATTRIBUTE23 => r_EPA.INFORMATION133
15910 ,P_EPA_ATTRIBUTE24 => r_EPA.INFORMATION134
15911 ,P_EPA_ATTRIBUTE25 => r_EPA.INFORMATION135
15912 ,P_EPA_ATTRIBUTE26 => r_EPA.INFORMATION136
15913 ,P_EPA_ATTRIBUTE27 => r_EPA.INFORMATION137
15914 ,P_EPA_ATTRIBUTE28 => r_EPA.INFORMATION138
15915 ,P_EPA_ATTRIBUTE29 => r_EPA.INFORMATION139
15916 ,P_EPA_ATTRIBUTE3 => r_EPA.INFORMATION113
15917 ,P_EPA_ATTRIBUTE30 => r_EPA.INFORMATION140
15918 ,P_EPA_ATTRIBUTE4 => r_EPA.INFORMATION114
15919 ,P_EPA_ATTRIBUTE5 => r_EPA.INFORMATION115
15920 ,P_EPA_ATTRIBUTE6 => r_EPA.INFORMATION116
15921 ,P_EPA_ATTRIBUTE7 => r_EPA.INFORMATION117
15922 ,P_EPA_ATTRIBUTE8 => r_EPA.INFORMATION118
15923 ,P_EPA_ATTRIBUTE9 => r_EPA.INFORMATION119
15924 ,P_EPA_ATTRIBUTE_CATEGORY => r_EPA.INFORMATION110
15925 ,P_MX_POE_APLS_CD => r_EPA.INFORMATION17
15926 ,P_MX_POE_DET_DT_CD => r_EPA.INFORMATION13
15927 ,P_MX_POE_DET_DT_RL => l_MX_POE_DET_DT_RL
15928 ,P_MX_POE_RL => l_MX_POE_RL
15929 ,P_MX_POE_UOM => r_EPA.INFORMATION11
15930 ,P_MX_POE_VAL => r_EPA.INFORMATION266
15931 ,P_OIPL_ID => l_OIPL_ID
15932 ,P_PGM_ID => l_PGM_ID
15933 ,P_PLIP_ID => l_PLIP_ID
15934 ,P_PL_ID => l_PL_ID
15935 ,P_PRTN_EFF_END_DT_CD => r_EPA.INFORMATION16
15936 ,P_PRTN_EFF_END_DT_RL => l_PRTN_EFF_END_DT_RL
15937 ,P_PRTN_EFF_STRT_DT_CD => r_EPA.INFORMATION15
15938 ,P_PRTN_EFF_STRT_DT_RL => l_PRTN_EFF_STRT_DT_RL
15939 ,P_PRTN_ELIG_ID => l_prtn_elig_id
15940 ,P_PTIP_ID => l_PTIP_ID
15941 ,P_WAIT_PERD_DT_TO_USE_CD => r_EPA.INFORMATION12
15942 ,P_WAIT_PERD_DT_TO_USE_RL => l_WAIT_PERD_DT_TO_USE_RL
15943 ,P_WAIT_PERD_RL => l_WAIT_PERD_RL
15944 ,P_WAIT_PERD_UOM => r_EPA.INFORMATION14
15945 ,P_WAIT_PERD_VAL => r_EPA.INFORMATION287
15946 ,P_TRK_SCR_FOR_INELG_FLAG => r_EPA.INFORMATION18 --BugNo 4242438
15947 --
15948 ,P_EFFECTIVE_START_DATE => l_effective_start_date
15949 ,P_EFFECTIVE_END_DATE => l_effective_end_date
15950 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
15951 ,P_DATETRACK_MODE => l_datetrack_mode
15952 );
15953 --
15954 end if; -- l_update
15955 end if;
15956 --
15957 -- Delete the row if it is end dated.
15958 --
15959 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
15960 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
15961 trunc(l_max_eed) = r_EPA.information3) then
15962 --
15963 BEN_PARTICIPATION_ELIG_API.delete_PARTICIPATION_ELIG(
15964 --
15965 p_validate => false
15966 ,p_prtn_elig_id => l_prtn_elig_id
15967 ,p_effective_start_date => l_effective_start_date
15968 ,p_effective_end_date => l_effective_end_date
15969 ,p_object_version_number => l_object_version_number
15970 ,p_effective_date => l_max_eed
15971 ,p_datetrack_mode => hr_api.g_delete
15972 --
15973 );
15974 --
15975 end if;
15976 --
15977 l_prev_pk_id := l_current_pk_id ;
15978 --
15979 end if;
15980 --
15981 end if;
15982 --
15983 end loop;
15984 --
15985 exception when others then
15986 --
15987 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EPA',r_epa.information5 );
15988 --
15989 end create_EPA_rows;
15990
15991 ---------------------------------------------------------------
15992 ----------------------< create_CPY_rows >-----------------------
15993 ---------------------------------------------------------------
15994 --
15995 procedure create_CPY_rows
15996 (
15997 p_validate in number default 0
15998 ,p_copy_entity_txn_id in number
15999 ,p_effective_date in date
16000 ,p_prefix_suffix_text in varchar2 default null
16001 ,p_reuse_object_flag in varchar2 default null
16002 ,p_target_business_group_id in varchar2 default null
16003 ,p_prefix_suffix_cd in varchar2 default null
16004 ) is
16005 --
16006 l_PGM_ID number;
16007 l_PL_ID number;
16008 l_YR_PERD_ID number;
16009 cursor c_unique_CPY(l_table_alias varchar2) is
16010 select distinct cpe.information1,
16011 cpe.information2,
16012 cpe.information3,
16013 cpe.table_route_id
16014 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
16015 pqh_table_route tr
16016 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16017 and cpe.table_route_id = tr.table_route_id
16018 -- and tr.where_clause = l_BEN_POPL_YR_PERD
16019 and tr.table_alias = l_table_alias
16020 and cpe.number_of_copies = 1 -- ADDITION
16021 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
16022 order by information1, information2; --added for bug: 5151945
16023 --
16024 --
16025 cursor c_CPY_min_max_dates(c_table_route_id number,
16026 c_information1 number) is
16027 select
16028 min(cpe.information2) min_esd,
16029 max(cpe.information3) min_eed
16030 from ben_copy_entity_results cpe
16031 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16032 and cpe.table_route_id = c_table_route_id
16033 and cpe.information1 = c_information1 ;
16034 --
16035 cursor c_CPY(c_table_route_id number,
16036 c_information1 number,
16037 c_information2 date,
16038 c_information3 date ) is
16039 select
16040 cpe.*
16041 from ben_copy_entity_results cpe
16042 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16043 and cpe.table_route_id = c_table_route_id
16044 and cpe.information1 = c_information1
16045 and rownum = 1 ;
16046 -- Date Track target record
16047 cursor c_find_CPY_in_target(
16048 c_effective_start_date date,
16049 c_effective_end_date date,
16050 c_business_group_id number,
16051 c_new_pk_id number) is
16052 select
16053 CPY.popl_yr_perd_id new_value
16054 from BEN_POPL_YR_PERD CPY
16055 where
16056 nvl(CPY.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
16057 nvl(CPY.PL_ID,-999) = nvl(l_PL_ID,-999) and
16058 CPY.YR_PERD_ID = l_YR_PERD_ID and
16059 CPY.business_group_id = c_business_group_id
16060 and CPY.popl_yr_perd_id <> c_new_pk_id
16061 ;
16062 --
16063 --UPD START
16064 --
16065 l_update boolean := false ;
16066 l_datetrack_mode varchar2(80) := hr_api.g_update;
16067 l_process_date date;
16068 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
16069 --
16070 --UPD END
16071 l_current_pk_id number := null ;
16072 l_prev_pk_id number := null ;
16073 l_first_rec boolean := true ;
16074 r_CPY c_CPY%rowtype;
16075 l_popl_yr_perd_id number ;
16076 l_object_version_number number ;
16077 l_effective_start_date date ;
16078 l_effective_end_date date ;
16079 l_prefix pqh_copy_entity_attribs.information1%type := null;
16080 l_suffix pqh_copy_entity_attribs.information1%type := null;
16081 l_new_value number(15);
16082 l_object_found_in_target boolean := false ;
16083 l_min_esd date;
16084 l_max_eed date;
16085 --
16086 begin
16087 -- Initialization
16088 l_object_found_in_target := false ;
16089 -- End Initialization
16090 -- Derive the prefix - sufix
16091 if p_prefix_suffix_cd = 'PREFIX' then
16092 l_prefix := p_prefix_suffix_text ;
16093 elsif p_prefix_suffix_cd = 'SUFFIX' then
16094 l_suffix := p_prefix_suffix_text ;
16095 else
16096 l_prefix := null ;
16097 l_suffix := null ;
16098 end if ;
16099 -- End Prefix Sufix derivation
16100 for r_CPY_unique in c_unique_CPY('CPY') loop
16101 --
16102 hr_utility.set_location(' r_CPY_unique.table_route_id '||r_CPY_unique.table_route_id,10);
16103 hr_utility.set_location(' r_CPY_unique.information1 '||r_CPY_unique.information1,10);
16104 hr_utility.set_location( 'r_CPY_unique.information2 '||r_CPY_unique.information2,10);
16105 hr_utility.set_location( 'r_CPY_unique.information3 '||r_CPY_unique.information3,10);
16106 -- If reuse objects flag is 'Y' then check for the object in the target business group
16107 -- if found insert the record into PLSql table and exit the loop else try create the
16108 -- object in the target business group
16109 --
16110 l_object_found_in_target := false ;
16111 l_min_esd := null ;
16112 l_max_eed := null ;
16113 --
16114 open c_CPY(r_CPY_unique.table_route_id,
16115 r_CPY_unique.information1,
16116 r_CPY_unique.information2,
16117 r_CPY_unique.information3 ) ;
16118 --
16119 fetch c_CPY into r_CPY ;
16120 --
16121 close c_CPY ;
16122 --
16123 l_update := false;
16124 l_process_date := p_effective_date;
16125 l_dml_operation:= r_CPY_unique.dml_operation ;
16126 l_PGM_ID := get_fk('PGM_ID', r_CPY.INFORMATION260,l_dml_operation);
16127 l_PL_ID := get_fk('PL_ID', r_CPY.INFORMATION261,l_dml_operation);
16128 l_YR_PERD_ID := get_fk('YR_PERD_ID', r_CPY.INFORMATION240,l_dml_operation);
16129 --UPD START
16130 --
16131 if l_dml_operation = 'UPDATE' then
16132 --
16133 l_update := true;
16134 if r_CPY_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
16135 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'POPL_YR_PERD_ID' then
16136 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_YR_PERD_ID' ;
16137 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPY_unique.information1 ;
16138 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_CPY_unique.information1 ;
16139 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16140 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CPY_unique.table_route_id;
16141 --
16142 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ; -- NEW
16143 --
16144 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16145 --
16146 --DOUBT log_data('CPY',l_new_value,l_prefix || r_CPY_unique.name|| l_suffix,'REUSED');
16147 --
16148 end if ;
16149 l_POPL_YR_PERD_ID := r_CPY_unique.information1 ;
16150 l_object_version_number := r_CPY.information265 ;
16151 hr_utility.set_location( 'found record for update',10);
16152 --
16153 else
16154 --
16155 --UPD END
16156 if p_reuse_object_flag = 'Y' then
16157 -- cursor to find the object
16158 open c_find_CPY_in_target( r_CPY_unique.information2,l_max_eed,
16159 p_target_business_group_id, nvl(l_popl_yr_perd_id, -999) ) ;
16160 fetch c_find_CPY_in_target into l_new_value ;
16161 if c_find_CPY_in_target%found then
16162 --
16163 if r_CPY_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
16164 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'POPL_YR_PERD_ID' then
16165 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_YR_PERD_ID' ;
16166 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPY_unique.information1 ;
16167 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
16168 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16169 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CPY_unique.table_route_id;
16170 --
16171 -- 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) ;
16172 --
16173 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16174 end if ;
16175 --
16176 l_object_found_in_target := true ;
16177 end if;
16178 close c_find_CPY_in_target ;
16179 --
16180 end if ;
16181 --
16182 end if; --if p_dml_operation
16183 --
16184 if not l_object_found_in_target OR l_update then
16185 --
16186 l_current_pk_id := r_CPY.information1;
16187 --
16188 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
16189 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
16190 --
16191 if l_current_pk_id = l_prev_pk_id then
16192 --
16193 l_first_rec := false ;
16194 --
16195 else
16196 --
16197 l_first_rec := true ;
16198 --
16199 end if ;
16200 --
16201 -- To avoid creating a child with out a parent
16202 --
16203 --
16204 if l_PGM_ID is null and l_PL_ID is null then
16205 l_first_rec := false ;
16206 end if;
16207 --
16208 if l_first_rec and not l_update then
16209 -- Call Create routine.
16210 hr_utility.set_location(' BEN_POPL_YR_PERD CREATE_POPL_YR_PERD ',20);
16211 BEN_POPL_YR_PERD_API.CREATE_POPL_YR_PERD(
16212 --
16213 P_VALIDATE => false
16214 --,P_EFFECTIVE_DATE => p_effective_date
16215 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16216 --
16217 ,P_ACPT_CLM_RQSTS_THRU_DT => r_CPY.INFORMATION308
16218 ,P_CPY_ATTRIBUTE1 => r_CPY.INFORMATION111
16219 ,P_CPY_ATTRIBUTE10 => r_CPY.INFORMATION120
16220 ,P_CPY_ATTRIBUTE11 => r_CPY.INFORMATION121
16221 ,P_CPY_ATTRIBUTE12 => r_CPY.INFORMATION122
16222 ,P_CPY_ATTRIBUTE13 => r_CPY.INFORMATION123
16223 ,P_CPY_ATTRIBUTE14 => r_CPY.INFORMATION124
16224 ,P_CPY_ATTRIBUTE15 => r_CPY.INFORMATION125
16225 ,P_CPY_ATTRIBUTE16 => r_CPY.INFORMATION126
16226 ,P_CPY_ATTRIBUTE17 => r_CPY.INFORMATION127
16227 ,P_CPY_ATTRIBUTE18 => r_CPY.INFORMATION128
16228 ,P_CPY_ATTRIBUTE19 => r_CPY.INFORMATION129
16229 ,P_CPY_ATTRIBUTE2 => r_CPY.INFORMATION112
16230 ,P_CPY_ATTRIBUTE20 => r_CPY.INFORMATION130
16231 ,P_CPY_ATTRIBUTE21 => r_CPY.INFORMATION131
16232 ,P_CPY_ATTRIBUTE22 => r_CPY.INFORMATION132
16233 ,P_CPY_ATTRIBUTE23 => r_CPY.INFORMATION133
16234 ,P_CPY_ATTRIBUTE24 => r_CPY.INFORMATION134
16235 ,P_CPY_ATTRIBUTE25 => r_CPY.INFORMATION135
16236 ,P_CPY_ATTRIBUTE26 => r_CPY.INFORMATION136
16237 ,P_CPY_ATTRIBUTE27 => r_CPY.INFORMATION137
16238 ,P_CPY_ATTRIBUTE28 => r_CPY.INFORMATION138
16239 ,P_CPY_ATTRIBUTE29 => r_CPY.INFORMATION139
16240 ,P_CPY_ATTRIBUTE3 => r_CPY.INFORMATION113
16241 ,P_CPY_ATTRIBUTE30 => r_CPY.INFORMATION140
16242 ,P_CPY_ATTRIBUTE4 => r_CPY.INFORMATION114
16243 ,P_CPY_ATTRIBUTE5 => r_CPY.INFORMATION115
16244 ,P_CPY_ATTRIBUTE6 => r_CPY.INFORMATION116
16245 ,P_CPY_ATTRIBUTE7 => r_CPY.INFORMATION117
16246 ,P_CPY_ATTRIBUTE8 => r_CPY.INFORMATION118
16247 ,P_CPY_ATTRIBUTE9 => r_CPY.INFORMATION119
16248 ,P_CPY_ATTRIBUTE_CATEGORY => r_CPY.INFORMATION110
16249 ,P_ORDR_NUM => r_CPY.INFORMATION262
16250 ,P_PGM_ID => l_PGM_ID
16251 ,P_PL_ID => l_PL_ID
16252 ,P_POPL_YR_PERD_ID => l_popl_yr_perd_id
16253 ,P_PY_CLMS_THRU_DT => r_CPY.INFORMATION309
16254 ,P_YR_PERD_ID => l_YR_PERD_ID
16255 --
16256 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16257 );
16258 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16259 -- Update all relevent cer records with new pk_id
16260 hr_utility.set_location('Before plsql table ',222);
16261 hr_utility.set_location('new_value id '||l_popl_yr_perd_id,222);
16262 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_YR_PERD_ID' ;
16263 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPY.information1 ;
16264 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_POPL_YR_PERD_ID ;
16265 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
16266 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CPY_unique.table_route_id;
16267 hr_utility.set_location('After plsql table ',222);
16268 --
16269 -- 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 ) ;
16270 --
16271 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16272 elsif l_update then
16273 BEN_POPL_YR_PERD_API.UPDATE_POPL_YR_PERD(
16274 --
16275 P_VALIDATE => false
16276 --,P_EFFECTIVE_DATE => p_effective_date
16277 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16278 --
16279 ,P_ACPT_CLM_RQSTS_THRU_DT => r_CPY.INFORMATION308
16280 ,P_CPY_ATTRIBUTE1 => r_CPY.INFORMATION111
16281 ,P_CPY_ATTRIBUTE10 => r_CPY.INFORMATION120
16282 ,P_CPY_ATTRIBUTE11 => r_CPY.INFORMATION121
16283 ,P_CPY_ATTRIBUTE12 => r_CPY.INFORMATION122
16284 ,P_CPY_ATTRIBUTE13 => r_CPY.INFORMATION123
16285 ,P_CPY_ATTRIBUTE14 => r_CPY.INFORMATION124
16286 ,P_CPY_ATTRIBUTE15 => r_CPY.INFORMATION125
16287 ,P_CPY_ATTRIBUTE16 => r_CPY.INFORMATION126
16288 ,P_CPY_ATTRIBUTE17 => r_CPY.INFORMATION127
16289 ,P_CPY_ATTRIBUTE18 => r_CPY.INFORMATION128
16290 ,P_CPY_ATTRIBUTE19 => r_CPY.INFORMATION129
16291 ,P_CPY_ATTRIBUTE2 => r_CPY.INFORMATION112
16292 ,P_CPY_ATTRIBUTE20 => r_CPY.INFORMATION130
16293 ,P_CPY_ATTRIBUTE21 => r_CPY.INFORMATION131
16294 ,P_CPY_ATTRIBUTE22 => r_CPY.INFORMATION132
16295 ,P_CPY_ATTRIBUTE23 => r_CPY.INFORMATION133
16296 ,P_CPY_ATTRIBUTE24 => r_CPY.INFORMATION134
16297 ,P_CPY_ATTRIBUTE25 => r_CPY.INFORMATION135
16298 ,P_CPY_ATTRIBUTE26 => r_CPY.INFORMATION136
16299 ,P_CPY_ATTRIBUTE27 => r_CPY.INFORMATION137
16300 ,P_CPY_ATTRIBUTE28 => r_CPY.INFORMATION138
16301 ,P_CPY_ATTRIBUTE29 => r_CPY.INFORMATION139
16302 ,P_CPY_ATTRIBUTE3 => r_CPY.INFORMATION113
16303 ,P_CPY_ATTRIBUTE30 => r_CPY.INFORMATION140
16304 ,P_CPY_ATTRIBUTE4 => r_CPY.INFORMATION114
16305 ,P_CPY_ATTRIBUTE5 => r_CPY.INFORMATION115
16306 ,P_CPY_ATTRIBUTE6 => r_CPY.INFORMATION116
16307 ,P_CPY_ATTRIBUTE7 => r_CPY.INFORMATION117
16308 ,P_CPY_ATTRIBUTE8 => r_CPY.INFORMATION118
16309 ,P_CPY_ATTRIBUTE9 => r_CPY.INFORMATION119
16310 ,P_CPY_ATTRIBUTE_CATEGORY => r_CPY.INFORMATION110
16311 ,P_ORDR_NUM => r_CPY.INFORMATION262
16312 ,P_PGM_ID => l_PGM_ID
16313 ,P_PL_ID => l_PL_ID
16314 ,P_POPL_YR_PERD_ID => l_popl_yr_perd_id
16315 ,P_PY_CLMS_THRU_DT => r_CPY.INFORMATION309
16316 ,P_YR_PERD_ID => l_YR_PERD_ID
16317 --
16318 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16319 );
16320 --
16321 end if;
16322 --
16323 l_prev_pk_id := l_current_pk_id ;
16324 --
16325 end if;
16326 --
16327 end loop;
16328 --
16329 exception when others then
16330 --
16331 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CPY',r_cpy.information5 );
16332 --
16333 end create_CPY_rows;
16334
16335 --
16336 ---------------------------------------------------------------
16337 ----------------------< create_PET_rows >-----------------------
16338 ---------------------------------------------------------------
16339 --
16340 procedure create_PET_rows
16341 (
16342 p_validate in number default 0
16343 ,p_copy_entity_txn_id in number
16344 ,p_effective_date in date
16345 ,p_prefix_suffix_text in varchar2 default null
16346 ,p_reuse_object_flag in varchar2 default null
16347 ,p_target_business_group_id in varchar2 default null
16348 ,p_prefix_suffix_cd in varchar2 default null
16349 ) is
16350 --
16351 l_PGM_ID number;
16352 l_PL_ID number;
16353 l_ENRT_TYP_CYCL_CD varchar2(30);
16354 --
16355 cursor c_unique_PET(l_table_alias varchar2) is
16356 select distinct cpe.information1,
16357 cpe.information2,
16358 cpe.information3,
16359 cpe.table_route_id
16360 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
16361 pqh_table_route tr
16362 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16363 and cpe.table_route_id = tr.table_route_id
16364 -- and tr.where_clause = l_BEN_POPL_ENRT_TYP_CYCL_F
16365 and tr.table_alias = l_table_alias
16366 and cpe.number_of_copies = 1 -- ADDITION
16367 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
16368 order by information1, information2; --added for bug: 5151945
16369 --
16370 --
16371 cursor c_PET_min_max_dates(c_table_route_id number,
16372 c_information1 number) is
16373 select
16374 min(cpe.information2) min_esd,
16375 max(cpe.information3) min_eed
16376 from ben_copy_entity_results cpe
16377 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16378 and cpe.table_route_id = c_table_route_id
16379 and cpe.information1 = c_information1 ;
16380 --
16381 cursor c_PET(c_table_route_id number,
16382 c_information1 number,
16383 c_information2 date,
16384 c_information3 date ) is
16385 select
16386 cpe.*
16387 from ben_copy_entity_results cpe
16388 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16389 and cpe.table_route_id = c_table_route_id
16390 and cpe.information1 = c_information1
16391 and cpe.information2 = c_information2
16392 and cpe.information3 = c_information3
16393 and rownum = 1 ;
16394 -- Date Track target record
16395 cursor c_find_PET_in_target(
16396 c_effective_start_date date,
16397 c_effective_end_date date,
16398 c_business_group_id number,
16399 c_new_pk_id number) is
16400 select
16401 PET.popl_enrt_typ_cycl_id new_value
16402 from BEN_POPL_ENRT_TYP_CYCL_F PET
16403 where
16404 nvl(PET.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
16405 nvl(PET.PL_ID,-999) = nvl(l_PL_ID,-999) and
16406 PET.ENRT_TYP_CYCL_CD = l_ENRT_TYP_CYCL_CD and
16407 PET.business_group_id = c_business_group_id
16408 and PET.popl_enrt_typ_cycl_id <> c_new_pk_id
16409 --TEMPIK
16410 and c_effective_start_date between effective_start_date
16411 and effective_end_date ;
16412 --END TEMPIK
16413 /*TEMPIK
16414 and exists ( select null
16415 from BEN_POPL_ENRT_TYP_CYCL_F PET1
16416 where
16417 nvl(PET1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
16418 nvl(PET1.PL_ID,-999) = nvl(l_PL_ID,-999) and
16419 PET1.ENRT_TYP_CYCL_CD = l_ENRT_TYP_CYCL_CD and
16420 PET1.business_group_id = c_business_group_id
16421 and PET1.effective_start_date <= c_effective_start_date )
16422 and exists ( select null
16423 from BEN_POPL_ENRT_TYP_CYCL_F PET2
16424 where
16425 nvl(PET2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
16426 nvl(PET2.PL_ID,-999) = nvl(l_PL_ID,-999) and
16427 PET2.ENRT_TYP_CYCL_CD = l_ENRT_TYP_CYCL_CD and
16428 PET2.business_group_id = c_business_group_id
16429 and PET2.effective_end_date >= c_effective_end_date )
16430 ;
16431 TEMPIK */
16432 --TEMPIK
16433 l_dt_rec_found boolean ;
16434 --END TEMPIK
16435 --
16436 --UPD START
16437 --
16438 l_update boolean := false ;
16439 l_datetrack_mode varchar2(80) := hr_api.g_update;
16440 l_process_date date;
16441 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
16442 --
16443 --UPD END
16444 l_current_pk_id number := null ;
16445 l_prev_pk_id number := null ;
16446 l_first_rec boolean := true ;
16447 r_PET c_PET%rowtype;
16448 l_popl_enrt_typ_cycl_id number ;
16449 l_object_version_number number ;
16450 l_effective_start_date date ;
16451 l_effective_end_date date ;
16452 l_prefix pqh_copy_entity_attribs.information1%type := null;
16453 l_suffix pqh_copy_entity_attribs.information1%type := null;
16454 l_new_value number(15);
16455 l_object_found_in_target boolean := false ;
16456 l_min_esd date;
16457 l_max_eed date;
16458 l_effective_date date;
16459 --
16460 begin
16461 -- Initialization
16462 l_object_found_in_target := false ;
16463 -- End Initialization
16464 -- Derive the prefix - sufix
16465 if p_prefix_suffix_cd = 'PREFIX' then
16466 l_prefix := p_prefix_suffix_text ;
16467 elsif p_prefix_suffix_cd = 'SUFFIX' then
16468 l_suffix := p_prefix_suffix_text ;
16469 else
16470 l_prefix := null ;
16471 l_suffix := null ;
16472 end if ;
16473 -- End Prefix Sufix derivation
16474 for r_PET_unique in c_unique_PET('PET') loop
16475
16476 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
16477 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16478 r_PET_unique.information3 >=
16479 ben_pd_copy_to_ben_one.g_copy_effective_date)
16480 ) then
16481 --
16482 hr_utility.set_location(' r_PET_unique.table_route_id '||r_PET_unique.table_route_id,10);
16483 hr_utility.set_location(' r_PET_unique.information1 '||r_PET_unique.information1,10);
16484 hr_utility.set_location( 'r_PET_unique.information2 '||r_PET_unique.information2,10);
16485 hr_utility.set_location( 'r_PET_unique.information3 '||r_PET_unique.information3,10);
16486 -- If reuse objects flag is 'Y' then check for the object in the target business group
16487 -- if found insert the record into PLSql table and exit the loop else try create the
16488 -- object in the target business group
16489 --
16490 l_object_found_in_target := false ;
16491 --UPD START
16492 open c_PET(r_PET_unique.table_route_id,
16493 r_PET_unique.information1,
16494 r_PET_unique.information2,
16495 r_PET_unique.information3 ) ;
16496 --
16497 fetch c_PET into r_PET ;
16498 --
16499 close c_PET ;
16500 l_dml_operation:= r_PET_unique.dml_operation ;
16501 l_PGM_ID := get_fk('PGM_ID', r_PET.INFORMATION260,l_dml_operation );
16502 l_PL_ID := get_fk('PL_ID', r_PET.INFORMATION261,l_dml_operation );
16503 l_ENRT_TYP_CYCL_CD := r_PET.information11 ;
16504 l_update := false;
16505 l_process_date := p_effective_date;
16506 --
16507 if l_dml_operation = 'UPDATE' then
16508 --
16509 l_object_found_in_target := TRUE;
16510 --
16511 if l_process_date between r_PET_unique.information2 and r_PET_unique.information3 then
16512 l_update := true;
16513 if r_PET_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
16514 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'POPL_ENRT_TYP_CYCL_ID'
16515 then
16516 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ENRT_TYP_CYCL_ID' ;
16517 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PET_unique.information1 ;
16518 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PET_unique.information1 ;
16519 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16520 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PET_unique.table_route_id;
16521 --
16522 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
16523 --
16524 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16525 --
16526 --DOUBT log_data('PET',l_new_value,l_prefix || r_PET_unique.name|| l_suffix,'REUSED');
16527 --
16528 end if ;
16529 hr_utility.set_location( 'found record for update',10);
16530 --
16531 else
16532 --
16533 l_update := false;
16534 --
16535 end if;
16536 else
16537 --
16538 --UPD END
16539 l_min_esd := null ;
16540 l_max_eed := null ;
16541 open c_PET_min_max_dates(r_PET_unique.table_route_id, r_PET_unique.information1 ) ;
16542 fetch c_PET_min_max_dates into l_min_esd,l_max_eed ;
16543 --
16544
16545 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16546 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
16547 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
16548 end if;
16549 l_min_esd := greatest(l_min_esd,r_PET_unique.information2);
16550 /* open c_PET(r_PET_unique.table_route_id,
16551 r_PET_unique.information1,
16552 r_PET_unique.information2,
16553 r_PET_unique.information3 ) ;
16554 --
16555 fetch c_PET into r_PET ;
16556 --
16557 close c_PET ; */
16558 --
16559 if p_reuse_object_flag = 'Y' then
16560 if c_PET_min_max_dates%found then
16561 -- cursor to find the object
16562 open c_find_PET_in_target( l_min_esd,l_max_eed,
16563 p_target_business_group_id, nvl(l_popl_enrt_typ_cycl_id, -999) ) ;
16564 fetch c_find_PET_in_target into l_new_value ;
16565 if c_find_PET_in_target%found then
16566 --
16567 --TEMPIK
16568 l_dt_rec_found := dt_api.check_min_max_dates
16569 (p_base_table_name => 'BEN_POPL_ENRT_TYP_CYCL_F',
16570 p_base_key_column => 'POPL_ENRT_TYP_CYCL_ID',
16571 p_base_key_value => l_new_value,
16572 p_from_date => l_min_esd,
16573 p_to_date => l_max_eed );
16574 if l_dt_rec_found THEN
16575 --END TEMPIK
16576 if r_PET_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
16577 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'POPL_ENRT_TYP_CYCL_ID' then
16578 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ENRT_TYP_CYCL_ID' ;
16579 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PET_unique.information1 ;
16580 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
16581 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16582 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PET_unique.table_route_id;
16583 --
16584 -- 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) ;
16585 --
16586 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16587 end if ;
16588 --
16589 l_object_found_in_target := true ;
16590 --TEMPIK
16591 end if; -- l_dt_rec_found
16592 --END TEMPIK
16593 end if;
16594 close c_find_PET_in_target ;
16595 --
16596 end if;
16597 end if ;
16598 --
16599 close c_PET_min_max_dates ;
16600 end if; --if p_dml_operation
16601 --
16602 if not l_object_found_in_target OR l_update then
16603 --
16604 l_current_pk_id := r_PET.information1;
16605 --
16606 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
16607 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
16608 --
16609 if l_current_pk_id = l_prev_pk_id then
16610 --
16611 l_first_rec := false ;
16612 --
16613 else
16614 --
16615 l_first_rec := true ;
16616 --
16617 end if ;
16618 --
16619
16620 l_effective_date := r_PET.information2;
16621 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16622 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
16623 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
16624 end if;
16625
16626 if l_first_rec and not l_update then
16627 -- Call Create routine.
16628 hr_utility.set_location(' BEN_POPL_ENRT_TYP_CYCL_F CREATE_POPL_ENRT_TYP_CYCL ',20);
16629 BEN_POPL_ENRT_TYP_CYCL_API.CREATE_POPL_ENRT_TYP_CYCL(
16630 --
16631 P_VALIDATE => false
16632 ,P_EFFECTIVE_DATE => l_effective_date
16633 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16634 --
16635 ,P_ENRT_TYP_CYCL_CD => r_PET.INFORMATION11
16636 ,P_PET_ATTRIBUTE1 => r_PET.INFORMATION111
16637 ,P_PET_ATTRIBUTE10 => r_PET.INFORMATION120
16638 ,P_PET_ATTRIBUTE11 => r_PET.INFORMATION121
16639 ,P_PET_ATTRIBUTE12 => r_PET.INFORMATION122
16640 ,P_PET_ATTRIBUTE13 => r_PET.INFORMATION123
16641 ,P_PET_ATTRIBUTE14 => r_PET.INFORMATION124
16642 ,P_PET_ATTRIBUTE15 => r_PET.INFORMATION125
16643 ,P_PET_ATTRIBUTE16 => r_PET.INFORMATION126
16644 ,P_PET_ATTRIBUTE17 => r_PET.INFORMATION127
16645 ,P_PET_ATTRIBUTE18 => r_PET.INFORMATION128
16646 ,P_PET_ATTRIBUTE19 => r_PET.INFORMATION129
16647 ,P_PET_ATTRIBUTE2 => r_PET.INFORMATION112
16648 ,P_PET_ATTRIBUTE20 => r_PET.INFORMATION130
16649 ,P_PET_ATTRIBUTE21 => r_PET.INFORMATION131
16650 ,P_PET_ATTRIBUTE22 => r_PET.INFORMATION132
16651 ,P_PET_ATTRIBUTE23 => r_PET.INFORMATION133
16652 ,P_PET_ATTRIBUTE24 => r_PET.INFORMATION134
16653 ,P_PET_ATTRIBUTE25 => r_PET.INFORMATION135
16654 ,P_PET_ATTRIBUTE26 => r_PET.INFORMATION136
16655 ,P_PET_ATTRIBUTE27 => r_PET.INFORMATION137
16656 ,P_PET_ATTRIBUTE28 => r_PET.INFORMATION138
16657 ,P_PET_ATTRIBUTE29 => r_PET.INFORMATION139
16658 ,P_PET_ATTRIBUTE3 => r_PET.INFORMATION113
16659 ,P_PET_ATTRIBUTE30 => r_PET.INFORMATION140
16660 ,P_PET_ATTRIBUTE4 => r_PET.INFORMATION114
16661 ,P_PET_ATTRIBUTE5 => r_PET.INFORMATION115
16662 ,P_PET_ATTRIBUTE6 => r_PET.INFORMATION116
16663 ,P_PET_ATTRIBUTE7 => r_PET.INFORMATION117
16664 ,P_PET_ATTRIBUTE8 => r_PET.INFORMATION118
16665 ,P_PET_ATTRIBUTE9 => r_PET.INFORMATION119
16666 ,P_PET_ATTRIBUTE_CATEGORY => r_PET.INFORMATION110
16667 ,P_PGM_ID => l_PGM_ID
16668 ,P_PL_ID => l_PL_ID
16669 ,P_POPL_ENRT_TYP_CYCL_ID => l_popl_enrt_typ_cycl_id
16670 --
16671 ,P_EFFECTIVE_START_DATE => l_effective_start_date
16672 ,P_EFFECTIVE_END_DATE => l_effective_end_date
16673 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16674 );
16675 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16676 -- Update all relevent cer records with new pk_id
16677 hr_utility.set_location('Before plsql table ',222);
16678 hr_utility.set_location('new_value id '||l_popl_enrt_typ_cycl_id,222);
16679 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ENRT_TYP_CYCL_ID' ;
16680 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PET.information1 ;
16681 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_POPL_ENRT_TYP_CYCL_ID ;
16682 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
16683 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PET_unique.table_route_id;
16684 hr_utility.set_location('After plsql table ',222);
16685 --
16686 -- 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 ) ;
16687 --
16688 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16689 --
16690 else
16691 --
16692 -- Call Update routine for the pk_id created in prev run .
16693 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16694 hr_utility.set_location(' BEN_POPL_ENRT_TYP_CYCL_F UPDATE_POPL_ENRT_TYP_CYCL ',30);
16695 --UPD START
16696 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
16697 --
16698 if l_update then
16699 --
16700 l_datetrack_mode := r_PET.datetrack_mode ;
16701 --
16702 get_dt_modes(
16703 p_effective_date => l_process_date,
16704 p_effective_end_date => r_PET.information3,
16705 p_effective_start_date => r_PET.information2,
16706 p_dml_operation => r_PET.dml_operation,
16707 p_datetrack_mode => l_datetrack_mode );
16708 -- p_update => l_update
16709 --
16710 l_effective_date := l_process_date;
16711 l_POPL_ENRT_TYP_CYCL_ID := r_PET.information1;
16712 l_object_version_number := r_PET.information265;
16713 --
16714 end if;
16715 --
16716 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
16717 --
16718 IF l_update OR l_dml_operation <> 'UPDATE' THEN
16719 --UPD END
16720 BEN_POPL_ENRT_TYP_CYCL_API.UPDATE_POPL_ENRT_TYP_CYCL(
16721 --
16722 P_VALIDATE => false
16723 ,P_EFFECTIVE_DATE => l_effective_date
16724 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16725 --
16726 ,P_ENRT_TYP_CYCL_CD => r_PET.INFORMATION11
16727 ,P_PET_ATTRIBUTE1 => r_PET.INFORMATION111
16728 ,P_PET_ATTRIBUTE10 => r_PET.INFORMATION120
16729 ,P_PET_ATTRIBUTE11 => r_PET.INFORMATION121
16730 ,P_PET_ATTRIBUTE12 => r_PET.INFORMATION122
16731 ,P_PET_ATTRIBUTE13 => r_PET.INFORMATION123
16732 ,P_PET_ATTRIBUTE14 => r_PET.INFORMATION124
16733 ,P_PET_ATTRIBUTE15 => r_PET.INFORMATION125
16734 ,P_PET_ATTRIBUTE16 => r_PET.INFORMATION126
16735 ,P_PET_ATTRIBUTE17 => r_PET.INFORMATION127
16736 ,P_PET_ATTRIBUTE18 => r_PET.INFORMATION128
16737 ,P_PET_ATTRIBUTE19 => r_PET.INFORMATION129
16738 ,P_PET_ATTRIBUTE2 => r_PET.INFORMATION112
16739 ,P_PET_ATTRIBUTE20 => r_PET.INFORMATION130
16740 ,P_PET_ATTRIBUTE21 => r_PET.INFORMATION131
16741 ,P_PET_ATTRIBUTE22 => r_PET.INFORMATION132
16742 ,P_PET_ATTRIBUTE23 => r_PET.INFORMATION133
16743 ,P_PET_ATTRIBUTE24 => r_PET.INFORMATION134
16744 ,P_PET_ATTRIBUTE25 => r_PET.INFORMATION135
16745 ,P_PET_ATTRIBUTE26 => r_PET.INFORMATION136
16746 ,P_PET_ATTRIBUTE27 => r_PET.INFORMATION137
16747 ,P_PET_ATTRIBUTE28 => r_PET.INFORMATION138
16748 ,P_PET_ATTRIBUTE29 => r_PET.INFORMATION139
16749 ,P_PET_ATTRIBUTE3 => r_PET.INFORMATION113
16750 ,P_PET_ATTRIBUTE30 => r_PET.INFORMATION140
16751 ,P_PET_ATTRIBUTE4 => r_PET.INFORMATION114
16752 ,P_PET_ATTRIBUTE5 => r_PET.INFORMATION115
16753 ,P_PET_ATTRIBUTE6 => r_PET.INFORMATION116
16754 ,P_PET_ATTRIBUTE7 => r_PET.INFORMATION117
16755 ,P_PET_ATTRIBUTE8 => r_PET.INFORMATION118
16756 ,P_PET_ATTRIBUTE9 => r_PET.INFORMATION119
16757 ,P_PET_ATTRIBUTE_CATEGORY => r_PET.INFORMATION110
16758 ,P_PGM_ID => l_PGM_ID
16759 ,P_PL_ID => l_PL_ID
16760 ,P_POPL_ENRT_TYP_CYCL_ID => l_popl_enrt_typ_cycl_id
16761 --
16762 ,P_EFFECTIVE_START_DATE => l_effective_start_date
16763 ,P_EFFECTIVE_END_DATE => l_effective_end_date
16764 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16765 ,P_DATETRACK_MODE => l_datetrack_mode
16766 );
16767 --
16768 end if; -- l_update
16769 end if;
16770 --
16771 -- Delete the row if it is end dated.
16772 --
16773 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
16774 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
16775 trunc(l_max_eed) = r_PET.information3) then
16776 --
16777 BEN_POPL_ENRT_TYP_CYCL_API.delete_POPL_ENRT_TYP_CYCL(
16778 --
16779 p_validate => false
16780 ,p_popl_enrt_typ_cycl_id => l_popl_enrt_typ_cycl_id
16781 ,p_effective_start_date => l_effective_start_date
16782 ,p_effective_end_date => l_effective_end_date
16783 ,p_object_version_number => l_object_version_number
16784 ,p_effective_date => l_max_eed
16785 ,p_datetrack_mode => hr_api.g_delete
16786 --
16787 );
16788 --
16789 end if;
16790 --
16791 l_prev_pk_id := l_current_pk_id ;
16792 --
16793 end if;
16794 --
16795 end if;
16796 --
16797 end loop;
16798 --
16799 exception when others then
16800 --
16801 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PET',r_pet.information5 );
16802 --
16803 end create_PET_rows;
16804
16805 --
16806 ---------------------------------------------------------------
16807 ----------------------< create_ENP_rows >-----------------------
16808 ---------------------------------------------------------------
16809 --
16810 procedure create_ENP_rows
16811 (
16812 p_validate in number default 0
16813 ,p_copy_entity_txn_id in number
16814 ,p_effective_date in date
16815 ,p_prefix_suffix_text in varchar2 default null
16816 ,p_reuse_object_flag in varchar2 default null
16817 ,p_target_business_group_id in varchar2 default null
16818 ,p_prefix_suffix_cd in varchar2 default null
16819 ) is
16820 --
16821 l_ENRT_CVG_END_DT_RL number;
16822 l_ENRT_CVG_STRT_DT_RL number;
16823 l_LER_ID number;
16824 l_POPL_ENRT_TYP_CYCL_ID number;
16825 l_POS_STRUCTURE_VERSION_ID number;
16826 l_RT_END_DT_RL number;
16827 l_RT_STRT_DT_RL number;
16828 l_HRCHY_RL number;
16829 l_WTHN_YR_PERD_ID number;
16830 l_YR_PERD_ID number;
16831 cursor c_unique_ENP(l_table_alias varchar2) is
16832 select distinct cpe.information1,
16833 cpe.information2,
16834 cpe.information3,
16835 cpe.table_route_id
16836 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
16837 pqh_table_route tr
16838 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16839 and cpe.table_route_id = tr.table_route_id
16840 -- and tr.where_clause = l_BEN_ENRT_PERD
16841 and tr.table_alias = l_table_alias
16842 and cpe.number_of_copies = 1 -- ADDITION
16843 group by cpe.information1,cpe.information2,
16844 cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
16845 order by information1, information2; --added for bug: 5151945
16846 --
16847 --
16848 cursor c_ENP_min_max_dates(c_table_route_id number,
16849 c_information1 number) is
16850 select
16851 min(cpe.information2) min_esd,
16852 max(cpe.information3) min_eed
16853 from ben_copy_entity_results cpe
16854 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16855 and cpe.table_route_id = c_table_route_id
16856 and cpe.information1 = c_information1 ;
16857 --
16858 cursor c_ENP(c_table_route_id number,
16859 c_information1 number,
16860 c_information2 date,
16861 c_information3 date) is
16862 select
16863 cpe.*
16864 from ben_copy_entity_results cpe
16865 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16866 and cpe.table_route_id = c_table_route_id
16867 and cpe.information1 = c_information1
16868 and rownum = 1 ;
16869 -- Date Track target record
16870 cursor c_find_ENP_in_target(
16871 c_effective_start_date date,
16872 c_effective_end_date date,
16873 c_business_group_id number,
16874 c_new_pk_id number) is
16875 select
16876 ENP.enrt_perd_id new_value
16877 from BEN_ENRT_PERD ENP
16878 where
16879 ENP.POPL_ENRT_TYP_CYCL_ID = l_POPL_ENRT_TYP_CYCL_ID and
16880 nvl(ENP.LER_ID,-999) = nvl(l_LER_ID,-999) and
16881 nvl(ENP.YR_PERD_ID,-999) = nvl(l_YR_PERD_ID,-999) and
16882 ENP.business_group_id = c_business_group_id
16883 and ENP.enrt_perd_id <> c_new_pk_id
16884 ;
16885 --
16886 --UPD START
16887 --
16888 l_update boolean := false ;
16889 l_datetrack_mode varchar2(80) := hr_api.g_update;
16890 l_process_date date;
16891 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
16892 --
16893 --UPD END
16894 l_current_pk_id number := null ;
16895 l_prev_pk_id number := null ;
16896 l_first_rec boolean := true ;
16897 r_ENP c_ENP%rowtype;
16898 l_enrt_perd_id number ;
16899 l_object_version_number number ;
16900 l_effective_start_date date ;
16901 l_effective_end_date date ;
16902 l_prefix pqh_copy_entity_attribs.information1%type := null;
16903 l_suffix pqh_copy_entity_attribs.information1%type := null;
16904 l_new_value number(15);
16905 l_object_found_in_target boolean := false ;
16906 l_min_esd date;
16907 l_max_eed date;
16908 l_parent_effective_start_date date;
16909 --
16910 begin
16911 -- Initialization
16912 l_object_found_in_target := false ;
16913 -- End Initialization
16914 -- Derive the prefix - sufix
16915 if p_prefix_suffix_cd = 'PREFIX' then
16916 l_prefix := p_prefix_suffix_text ;
16917 elsif p_prefix_suffix_cd = 'SUFFIX' then
16918 l_suffix := p_prefix_suffix_text ;
16919 else
16920 l_prefix := null ;
16921 l_suffix := null ;
16922 end if ;
16923 -- End Prefix Sufix derivation
16924 for r_ENP_unique in c_unique_ENP('ENP') loop
16925 --
16926 hr_utility.set_location(' r_ENP_unique.table_route_id '||r_ENP_unique.table_route_id,10);
16927 hr_utility.set_location(' r_ENP_unique.information1 '||r_ENP_unique.information1,10);
16928 hr_utility.set_location( 'r_ENP_unique.information2 '||r_ENP_unique.information2,10);
16929 hr_utility.set_location( 'r_ENP_unique.information3 '||r_ENP_unique.information3,10);
16930 -- If reuse objects flag is 'Y' then check for the object in the target business group
16931 -- if found insert the record into PLSql table and exit the loop else try create the
16932 -- object in the target business group
16933 --
16934 l_object_found_in_target := false ;
16935 l_min_esd := null ;
16936 l_max_eed := null ;
16937 --
16938 open c_ENP(r_ENP_unique.table_route_id,
16939 r_ENP_unique.information1,
16940 r_ENP_unique.information2,
16941 r_ENP_unique.information3 ) ;
16942 --
16943 fetch c_ENP into r_ENP ;
16944 --
16945 close c_ENP ;
16946 --
16947 l_update := false;
16948 l_process_date := p_effective_date;
16949 l_dml_operation:= r_ENP_unique.dml_operation ;
16950 l_ENRT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_ENP.INFORMATION263,l_dml_operation);
16951 l_ENRT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_ENP.INFORMATION262,l_dml_operation);
16952 l_LER_ID := get_fk('LER_ID', r_ENP.INFORMATION257,l_dml_operation);
16953 l_POPL_ENRT_TYP_CYCL_ID := get_fk('POPL_ENRT_TYP_CYCL_ID', r_ENP.INFORMATION232,l_dml_operation);
16954 l_RT_END_DT_RL := get_fk('FORMULA_ID', r_ENP.INFORMATION264,l_dml_operation);
16955 l_RT_STRT_DT_RL := get_fk('FORMULA_ID', r_ENP.INFORMATION261,l_dml_operation);
16956 l_HRCHY_RL := get_fk('FORMULA_ID', r_ENP.INFORMATION267,l_dml_operation);
16957 l_WTHN_YR_PERD_ID := get_fk('WTHN_YR_PERD_ID', r_ENP.INFORMATION266,l_dml_operation);
16958 l_YR_PERD_ID := get_fk('YR_PERD_ID', r_ENP.INFORMATION240,l_dml_operation);
16959
16960
16961
16962 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
16963 l_POS_STRUCTURE_VERSION_ID := r_ENP.information176 ;
16964 else
16965 l_POS_STRUCTURE_VERSION_ID := r_ENP.information174 ;
16966 end if;
16967
16968
16969 if l_POPL_ENRT_TYP_CYCL_ID is not null then -- Do not create if parent record does not exist
16970
16971 --UPD START
16972 --
16973 if l_dml_operation = 'UPDATE' then
16974 --
16975 l_update := true;
16976 if r_ENP_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
16977 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ENRT_PERD_ID' then
16978 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ENRT_PERD_ID' ;
16979 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ENP_unique.information1 ;
16980 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ENP_unique.information1 ;
16981 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16982 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ENP_unique.table_route_id;
16983 --
16984 -- 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 ) ; -- NEW
16985 --
16986 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16987 --
16988 --DOUBT log_data('ENP',l_new_value,l_prefix || r_ENP_unique.name|| l_suffix,'REUSED');
16989 --
16990 end if ;
16991 l_ENRT_PERD_ID := r_ENP_unique.information1 ;
16992 l_object_version_number := r_ENP.information265 ;
16993 hr_utility.set_location( 'found record for update',10);
16994 --
16995 else
16996 --
16997 --UPD END
16998 if p_reuse_object_flag = 'Y' then
16999 -- cursor to find the object
17000 open c_find_ENP_in_target( r_ENP_unique.information2,l_max_eed,
17001 p_target_business_group_id, nvl(l_enrt_perd_id, -999) ) ;
17002 fetch c_find_ENP_in_target into l_new_value ;
17003 if c_find_ENP_in_target%found then
17004 --
17005 if r_ENP_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
17006 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ENRT_PERD_ID' then
17007 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ENRT_PERD_ID' ;
17008 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ENP_unique.information1 ;
17009 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
17010 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
17011 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ENP_unique.table_route_id;
17012 --
17013 -- 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) ;
17014 --
17015 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17016 end if ;
17017 --
17018 l_object_found_in_target := true ;
17019 end if;
17020 close c_find_ENP_in_target ;
17021 --
17022 end if ;
17023 --
17024 end if; --if p_dml_operation
17025 --
17026 if not l_object_found_in_target OR l_update then
17027 --
17028 l_current_pk_id := r_ENP.information1;
17029 --
17030 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
17031 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
17032 --
17033 if l_current_pk_id = l_prev_pk_id then
17034 --
17035 l_first_rec := false ;
17036 --
17037 else
17038 --
17039 l_first_rec := true ;
17040 --
17041 end if ;
17042 --
17043
17044 l_parent_effective_start_date := r_ENP.information10;
17045 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null ) then
17046 if l_parent_effective_start_date is null then
17047 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
17048 elsif l_parent_effective_start_date < ben_pd_copy_to_ben_one.g_copy_effective_date then
17049 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
17050 end if;
17051 end if;
17052 --
17053 -- To avoid creating a child with out a parent
17054 --
17055 --
17056 if l_LER_ID is null and l_POPL_ENRT_TYP_CYCL_ID is null then
17057 l_first_rec := false ;
17058 end if;
17059 --
17060 if l_first_rec and not l_update then
17061 -- Call Create routine.
17062 hr_utility.set_location(' BEN_ENRT_PERD CREATE_ENROLLMENT_PERIOD ',20);
17063 BEN_ENROLLMENT_PERIOD_API.CREATE_ENROLLMENT_PERIOD(
17064 --
17065 P_VALIDATE => false
17066 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
17067 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
17068 --
17069 ,P_ASG_UPDT_EFF_DATE => r_ENP.INFORMATION306
17070 ,P_ASND_LF_EVT_DT => r_ENP.INFORMATION316
17071 ,P_AUTO_DISTR_FLAG => r_ENP.INFORMATION11
17072 ,P_BDGT_UPD_END_DT => r_ENP.INFORMATION308
17073 ,P_BDGT_UPD_STRT_DT => r_ENP.INFORMATION309
17074 ,P_CLS_ENRT_DT_TO_USE_CD => r_ENP.INFORMATION16
17075 ,P_DFLT_ENRT_DT => r_ENP.INFORMATION312
17076 ,P_DFLT_WS_ACC_CD => r_ENP.INFORMATION12
17077 ,P_EMP_INTERVIEW_TYPE_CD => r_ENP.INFORMATION13
17078 ,P_END_DT => r_ENP.INFORMATION317
17079 ,P_ENP_ATTRIBUTE1 => r_ENP.INFORMATION111
17080 ,P_ENP_ATTRIBUTE10 => r_ENP.INFORMATION120
17081 ,P_ENP_ATTRIBUTE11 => r_ENP.INFORMATION121
17082 ,P_ENP_ATTRIBUTE12 => r_ENP.INFORMATION122
17083 ,P_ENP_ATTRIBUTE13 => r_ENP.INFORMATION123
17084 ,P_ENP_ATTRIBUTE14 => r_ENP.INFORMATION124
17085 ,P_ENP_ATTRIBUTE15 => r_ENP.INFORMATION125
17086 ,P_ENP_ATTRIBUTE16 => r_ENP.INFORMATION126
17087 ,P_ENP_ATTRIBUTE17 => r_ENP.INFORMATION127
17088 ,P_ENP_ATTRIBUTE18 => r_ENP.INFORMATION128
17089 ,P_ENP_ATTRIBUTE19 => r_ENP.INFORMATION129
17090 ,P_ENP_ATTRIBUTE2 => r_ENP.INFORMATION112
17091 ,P_ENP_ATTRIBUTE20 => r_ENP.INFORMATION130
17092 ,P_ENP_ATTRIBUTE21 => r_ENP.INFORMATION131
17093 ,P_ENP_ATTRIBUTE22 => r_ENP.INFORMATION132
17094 ,P_ENP_ATTRIBUTE23 => r_ENP.INFORMATION133
17095 ,P_ENP_ATTRIBUTE24 => r_ENP.INFORMATION134
17096 ,P_ENP_ATTRIBUTE25 => r_ENP.INFORMATION135
17097 ,P_ENP_ATTRIBUTE26 => r_ENP.INFORMATION136
17098 ,P_ENP_ATTRIBUTE27 => r_ENP.INFORMATION137
17099 ,P_ENP_ATTRIBUTE28 => r_ENP.INFORMATION138
17100 ,P_ENP_ATTRIBUTE29 => r_ENP.INFORMATION139
17101 ,P_ENP_ATTRIBUTE3 => r_ENP.INFORMATION113
17102 ,P_ENP_ATTRIBUTE30 => r_ENP.INFORMATION140
17103 ,P_ENP_ATTRIBUTE4 => r_ENP.INFORMATION114
17104 ,P_ENP_ATTRIBUTE5 => r_ENP.INFORMATION115
17105 ,P_ENP_ATTRIBUTE6 => r_ENP.INFORMATION116
17106 ,P_ENP_ATTRIBUTE7 => r_ENP.INFORMATION117
17107 ,P_ENP_ATTRIBUTE8 => r_ENP.INFORMATION118
17108 ,P_ENP_ATTRIBUTE9 => r_ENP.INFORMATION119
17109 ,P_ENP_ATTRIBUTE_CATEGORY => r_ENP.INFORMATION110
17110 --Added two cols reinstate_cd,reinstate_ovrdn_cd
17111 ,P_REINSTATE_CD => r_ENP.INFORMATION26
17112 ,P_REINSTATE_OVRDN_CD => r_ENP.INFORMATION27
17113 --
17114 ,P_ENRT_CVG_END_DT_CD => r_ENP.INFORMATION18
17115 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
17116 ,P_ENRT_CVG_STRT_DT_CD => r_ENP.INFORMATION17
17117 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
17118 ,P_ENRT_PERD_DET_OVRLP_BCKDT_CD => r_ENP.INFORMATION22
17119 ,P_ENRT_PERD_ID => l_enrt_perd_id
17120 ,P_HRCHY_TO_USE_CD => r_ENP.INFORMATION14
17121 ,P_LER_ID => l_LER_ID
17122 ,P_PERF_REVW_STRT_DT => r_ENP.INFORMATION307
17123 ,P_POPL_ENRT_TYP_CYCL_ID => l_POPL_ENRT_TYP_CYCL_ID
17124 ,P_POS_STRUCTURE_VERSION_ID => l_POS_STRUCTURE_VERSION_ID
17125 ,P_PROCG_END_DT => r_ENP.INFORMATION315
17126 ,P_PRSVR_BDGT_CD => r_ENP.INFORMATION15
17127 ,P_RT_END_DT_CD => r_ENP.INFORMATION20
17128 ,P_RT_END_DT_RL => l_RT_END_DT_RL
17129 ,P_RT_STRT_DT_CD => r_ENP.INFORMATION19
17130 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
17131 ,P_STRT_DT => r_ENP.INFORMATION318
17132 ,P_USES_BDGT_FLAG => r_ENP.INFORMATION21
17133 ,P_WS_UPD_END_DT => r_ENP.INFORMATION319
17134 ,P_WS_UPD_STRT_DT => r_ENP.INFORMATION320
17135 ,P_WTHN_YR_PERD_ID => l_WTHN_YR_PERD_ID
17136 ,P_YR_PERD_ID => l_YR_PERD_ID
17137 --cwbglobal
17138 -- cwb tilak
17139 ,p_DATA_FREEZE_DATE => r_ENP.INFORMATION310
17140 ,p_SAL_CHG_REASON_CD => r_ENP.INFORMATION23
17141 ,p_APPROVAL_MODE_CD => r_ENP.INFORMATION24
17142 ,p_HRCHY_AME_TRN_CD => r_ENP.INFORMATION25
17143 ,p_HRCHY_RL => l_HRCHY_RL
17144 ,p_HRCHY_AME_APP_ID => r_ENP.INFORMATION268
17145 --
17146 --
17147 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
17148 );
17149 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
17150 -- Update all relevent cer records with new pk_id
17151 hr_utility.set_location('Before plsql table ',222);
17152 hr_utility.set_location('new_value id '||l_enrt_perd_id,222);
17153 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ENRT_PERD_ID' ;
17154 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ENP.information1 ;
17155 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ENRT_PERD_ID ;
17156 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
17157 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ENP_unique.table_route_id;
17158 hr_utility.set_location('After plsql table ',222);
17159 --
17160 -- 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 ) ;
17161 --
17162 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17163 --
17164 elsif l_update then
17165 BEN_ENROLLMENT_PERIOD_API.UPDATE_ENROLLMENT_PERIOD(
17166 --
17167 P_VALIDATE => false
17168 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
17169 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
17170 --
17171 ,P_ASG_UPDT_EFF_DATE => r_ENP.INFORMATION306
17172 ,P_ASND_LF_EVT_DT => r_ENP.INFORMATION316
17173 ,P_AUTO_DISTR_FLAG => r_ENP.INFORMATION11
17174 ,P_BDGT_UPD_END_DT => r_ENP.INFORMATION308
17175 ,P_BDGT_UPD_STRT_DT => r_ENP.INFORMATION309
17176 ,P_CLS_ENRT_DT_TO_USE_CD => r_ENP.INFORMATION16
17177 ,P_DFLT_ENRT_DT => r_ENP.INFORMATION312
17178 ,P_DFLT_WS_ACC_CD => r_ENP.INFORMATION12
17179 ,P_EMP_INTERVIEW_TYPE_CD => r_ENP.INFORMATION13
17180 ,P_END_DT => r_ENP.INFORMATION317
17181 ,P_ENP_ATTRIBUTE1 => r_ENP.INFORMATION111
17182 ,P_ENP_ATTRIBUTE10 => r_ENP.INFORMATION120
17183 ,P_ENP_ATTRIBUTE11 => r_ENP.INFORMATION121
17184 ,P_ENP_ATTRIBUTE12 => r_ENP.INFORMATION122
17185 ,P_ENP_ATTRIBUTE13 => r_ENP.INFORMATION123
17186 ,P_ENP_ATTRIBUTE14 => r_ENP.INFORMATION124
17187 ,P_ENP_ATTRIBUTE15 => r_ENP.INFORMATION125
17188 ,P_ENP_ATTRIBUTE16 => r_ENP.INFORMATION126
17189 ,P_ENP_ATTRIBUTE17 => r_ENP.INFORMATION127
17190 ,P_ENP_ATTRIBUTE18 => r_ENP.INFORMATION128
17191 ,P_ENP_ATTRIBUTE19 => r_ENP.INFORMATION129
17192 ,P_ENP_ATTRIBUTE2 => r_ENP.INFORMATION112
17193 ,P_ENP_ATTRIBUTE20 => r_ENP.INFORMATION130
17194 ,P_ENP_ATTRIBUTE21 => r_ENP.INFORMATION131
17195 ,P_ENP_ATTRIBUTE22 => r_ENP.INFORMATION132
17196 ,P_ENP_ATTRIBUTE23 => r_ENP.INFORMATION133
17197 ,P_ENP_ATTRIBUTE24 => r_ENP.INFORMATION134
17198 ,P_ENP_ATTRIBUTE25 => r_ENP.INFORMATION135
17199 ,P_ENP_ATTRIBUTE26 => r_ENP.INFORMATION136
17200 ,P_ENP_ATTRIBUTE27 => r_ENP.INFORMATION137
17201 ,P_ENP_ATTRIBUTE28 => r_ENP.INFORMATION138
17202 ,P_ENP_ATTRIBUTE29 => r_ENP.INFORMATION139
17203 ,P_ENP_ATTRIBUTE3 => r_ENP.INFORMATION113
17204 ,P_ENP_ATTRIBUTE30 => r_ENP.INFORMATION140
17205 ,P_ENP_ATTRIBUTE4 => r_ENP.INFORMATION114
17206 ,P_ENP_ATTRIBUTE5 => r_ENP.INFORMATION115
17207 ,P_ENP_ATTRIBUTE6 => r_ENP.INFORMATION116
17208 ,P_ENP_ATTRIBUTE7 => r_ENP.INFORMATION117
17209 ,P_ENP_ATTRIBUTE8 => r_ENP.INFORMATION118
17210 ,P_ENP_ATTRIBUTE9 => r_ENP.INFORMATION119
17211 ,P_ENP_ATTRIBUTE_CATEGORY => r_ENP.INFORMATION110
17212 -- Added two cols reinstate_cd,reinstate_ovrdn_cd
17213 --
17214 -- Bug No 4440058 Updated the information columns from 19
17215 -- and 20 to 26 and 27
17216 ,P_REINSTATE_CD => r_ENP.INFORMATION26
17217 ,P_REINSTATE_OVRDN_CD => r_ENP.INFORMATION27
17218 -- End Bug 4440058
17219 ,P_ENRT_CVG_END_DT_CD => r_ENP.INFORMATION18
17220 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
17221 ,P_ENRT_CVG_STRT_DT_CD => r_ENP.INFORMATION17
17222 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
17223 ,P_ENRT_PERD_DET_OVRLP_BCKDT_CD => r_ENP.INFORMATION22
17224 ,P_ENRT_PERD_ID => l_enrt_perd_id
17225 ,P_HRCHY_TO_USE_CD => r_ENP.INFORMATION14
17226 ,P_LER_ID => l_LER_ID
17227 ,P_PERF_REVW_STRT_DT => r_ENP.INFORMATION307
17228 ,P_POPL_ENRT_TYP_CYCL_ID => l_POPL_ENRT_TYP_CYCL_ID
17229 ,P_POS_STRUCTURE_VERSION_ID => l_POS_STRUCTURE_VERSION_ID
17230 ,P_PROCG_END_DT => r_ENP.INFORMATION315
17231 ,P_PRSVR_BDGT_CD => r_ENP.INFORMATION15
17232 ,P_RT_END_DT_CD => r_ENP.INFORMATION20
17233 ,P_RT_END_DT_RL => l_RT_END_DT_RL
17234 ,P_RT_STRT_DT_CD => r_ENP.INFORMATION19
17235 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
17236 ,P_STRT_DT => r_ENP.INFORMATION318
17237 ,P_USES_BDGT_FLAG => r_ENP.INFORMATION21
17238 ,P_WS_UPD_END_DT => r_ENP.INFORMATION319
17239 ,P_WS_UPD_STRT_DT => r_ENP.INFORMATION320
17240 ,P_WTHN_YR_PERD_ID => l_WTHN_YR_PERD_ID
17241 ,P_YR_PERD_ID => l_YR_PERD_ID
17242 --cwbglobal
17243 -- cwb tilak
17244 ,p_DATA_FREEZE_DATE => r_ENP.INFORMATION310
17245 ,p_SAL_CHG_REASON_CD => r_ENP.INFORMATION23
17246 ,p_APPROVAL_MODE_CD => r_ENP.INFORMATION24
17247 ,p_HRCHY_AME_TRN_CD => r_ENP.INFORMATION25
17248 ,p_HRCHY_RL => l_HRCHY_RL
17249 ,p_HRCHY_AME_APP_ID => r_ENP.INFORMATION268
17250 --
17251 --
17252 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
17253 );
17254 end if;
17255 --
17256 l_prev_pk_id := l_current_pk_id ;
17257 --
17258 end if;
17259 --
17260 end if;
17261 --
17262 end loop;
17263 --
17264 exception when others then
17265 --
17266 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ENP',r_enp.information5 );
17267 --
17268 end create_ENP_rows;
17269
17270 --
17271 ---------------------------------------------------------------
17272 ----------------------< create_LEN_rows >-----------------------
17273 ---------------------------------------------------------------
17274 --
17275 procedure create_LEN_rows
17276 (
17277 p_validate in number default 0
17278 ,p_copy_entity_txn_id in number
17279 ,p_effective_date in date
17280 ,p_prefix_suffix_text in varchar2 default null
17281 ,p_reuse_object_flag in varchar2 default null
17282 ,p_target_business_group_id in varchar2 default null
17283 ,p_prefix_suffix_cd in varchar2 default null
17284 ) is
17285 --
17286 l_ENRT_CVG_END_DT_RL number;
17287 l_ENRT_CVG_STRT_DT_RL number;
17288 l_ENRT_PERD_END_DT_RL number;
17289 l_ENRT_PERD_STRT_DT_RL number;
17290 l_LER_ID number;
17291 l_POPL_ENRT_TYP_CYCL_ID number;
17292 l_RT_END_DT_RL number;
17293 l_RT_STRT_DT_RL number;
17294 cursor c_unique_LEN(l_table_alias varchar2) is
17295 select distinct cpe.information1,
17296 cpe.information2,
17297 cpe.information3,
17298 cpe.table_route_id
17299 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
17300 pqh_table_route tr
17301 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17302 and cpe.table_route_id = tr.table_route_id
17303 -- and tr.where_clause = l_BEN_LEE_RSN_F
17304 and tr.table_alias = l_table_alias
17305 and cpe.number_of_copies = 1 -- ADDITION
17306 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
17307 order by information1, information2; --added for bug: 5151945
17308 --
17309 --
17310 cursor c_LEN_min_max_dates(c_table_route_id number,
17311 c_information1 number) is
17312 select
17313 min(cpe.information2) min_esd,
17314 max(cpe.information3) min_eed
17315 from ben_copy_entity_results cpe
17316 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17317 and cpe.table_route_id = c_table_route_id
17318 and cpe.information1 = c_information1 ;
17319 --
17320 cursor c_LEN(c_table_route_id number,
17321 c_information1 number,
17322 c_information2 date,
17323 c_information3 date) is
17324 select
17325 cpe.*
17326 from ben_copy_entity_results cpe
17327 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17328 and cpe.table_route_id = c_table_route_id
17329 and cpe.information1 = c_information1
17330 and cpe.information2 = c_information2
17331 and cpe.information3 = c_information3
17332 and rownum = 1 ;
17333 -- Date Track target record
17334 cursor c_find_LEN_in_target(
17335 c_effective_start_date date,
17336 c_effective_end_date date,
17337 c_business_group_id number,
17338 c_new_pk_id number) is
17339 select
17340 LEN.lee_rsn_id new_value
17341 from BEN_LEE_RSN_F LEN
17342 where
17343 nvl(LEN.LER_ID,-999) = nvl(l_LER_ID,-999) and
17344 nvl(LEN.POPL_ENRT_TYP_CYCL_ID,-999) = nvl(l_POPL_ENRT_TYP_CYCL_ID,-999) and
17345 LEN.business_group_id = c_business_group_id
17346 and LEN.lee_rsn_id <> c_new_pk_id
17347 --TEMPIK
17348 and c_effective_start_date between effective_start_date
17349 and effective_end_date ;
17350 --END TEMPIK
17351 /*TEMPIK
17352 and exists ( select null
17353 from BEN_LEE_RSN_F LEN1
17354 where
17355 nvl(LEN1.LER_ID,-999) = l_LER_ID and
17356 nvl(LEN1.POPL_ENRT_TYP_CYCL_ID,-999) = nvl(l_POPL_ENRT_TYP_CYCL_ID , -999) and
17357 LEN1.business_group_id = c_business_group_id
17358 and LEN1.effective_start_date <= c_effective_start_date )
17359 and exists ( select null
17360 from BEN_LEE_RSN_F LEN2
17361 where
17362 nvl(LEN2.LER_ID,-999) = l_LER_ID and
17363 nvl(LEN2.POPL_ENRT_TYP_CYCL_ID,-999) = nvl(l_POPL_ENRT_TYP_CYCL_ID , -999) and
17364 LEN2.business_group_id = c_business_group_id
17365 and LEN2.effective_end_date >= c_effective_end_date )
17366 ;
17367 */
17368 --
17369 --UPD START
17370 --
17371 l_update boolean := false ;
17372 l_datetrack_mode varchar2(80) := hr_api.g_update;
17373 l_process_date date;
17374 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
17375 --
17376 --UPD END
17377 l_current_pk_id number := null ;
17378 l_prev_pk_id number := null ;
17379 l_first_rec boolean := true ;
17380 r_LEN c_LEN%rowtype;
17381 l_lee_rsn_id number ;
17382 l_object_version_number number ;
17383 l_effective_start_date date ;
17384 l_effective_end_date date ;
17385 l_prefix pqh_copy_entity_attribs.information1%type := null;
17386 l_suffix pqh_copy_entity_attribs.information1%type := null;
17387 l_new_value number(15);
17388 l_object_found_in_target boolean := false ;
17389 l_min_esd date;
17390 l_max_eed date;
17391 l_effective_date date;
17392 --TEMPIK
17393 l_dt_rec_found boolean ;
17394 --END TEMPIK
17395 --
17396 begin
17397 -- Initialization
17398 l_object_found_in_target := false ;
17399 -- End Initialization
17400 -- Derive the prefix - sufix
17401 if p_prefix_suffix_cd = 'PREFIX' then
17402 l_prefix := p_prefix_suffix_text ;
17403 elsif p_prefix_suffix_cd = 'SUFFIX' then
17404 l_suffix := p_prefix_suffix_text ;
17405 else
17406 l_prefix := null ;
17407 l_suffix := null ;
17408 end if ;
17409 -- End Prefix Sufix derivation
17410 for r_LEN_unique in c_unique_LEN('LEN') loop
17411
17412 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
17413 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17414 r_LEN_unique.information3 >=
17415 ben_pd_copy_to_ben_one.g_copy_effective_date)
17416 ) then
17417 --
17418 hr_utility.set_location(' r_LEN_unique.table_route_id '||r_LEN_unique.table_route_id,10);
17419 hr_utility.set_location(' r_LEN_unique.information1 '||r_LEN_unique.information1,10);
17420 hr_utility.set_location( 'r_LEN_unique.information2 '||r_LEN_unique.information2,10);
17421 hr_utility.set_location( 'r_LEN_unique.information3 '||r_LEN_unique.information3,10);
17422 -- If reuse objects flag is 'Y' then check for the object in the target business group
17423 -- if found insert the record into PLSql table and exit the loop else try create the
17424 -- object in the target business group
17425 --
17426 l_object_found_in_target := false ;
17427 --UPD START
17428 open c_LEN(r_LEN_unique.table_route_id,
17429 r_LEN_unique.information1,
17430 r_LEN_unique.information2,
17431 r_LEN_unique.information3 ) ;
17432 --
17433 fetch c_LEN into r_LEN ;
17434 --
17435 close c_LEN ;
17436 l_dml_operation:= r_LEN_unique.dml_operation ;
17437 l_ENRT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_LEN.INFORMATION266,l_dml_operation);
17438 l_ENRT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_LEN.INFORMATION267,l_dml_operation);
17439 l_ENRT_PERD_END_DT_RL := get_fk('FORMULA_ID', r_LEN.INFORMATION268,l_dml_operation);
17440 l_ENRT_PERD_STRT_DT_RL := get_fk('FORMULA_ID', r_LEN.INFORMATION259,l_dml_operation);
17441 l_LER_ID := get_fk('LER_ID', r_LEN.INFORMATION257,l_dml_operation);
17442 l_POPL_ENRT_TYP_CYCL_ID := get_fk('POPL_ENRT_TYP_CYCL_ID', r_LEN.INFORMATION232,l_dml_operation);
17443 l_RT_END_DT_RL := get_fk('FORMULA_ID', r_LEN.INFORMATION263,l_dml_operation);
17444 l_RT_STRT_DT_RL := get_fk('FORMULA_ID', r_LEN.INFORMATION264,l_dml_operation);
17445 l_update := false;
17446 l_process_date := p_effective_date;
17447 --
17448 if l_dml_operation = 'UPDATE' then
17449 --
17450 l_object_found_in_target := TRUE;
17451 --
17452 if l_process_date between r_LEN_unique.information2 and r_LEN_unique.information3 then
17453 l_update := true;
17454 if r_LEN_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
17455 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LEE_RSN_ID'
17456 then
17457 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LEE_RSN_ID' ;
17458 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LEN_unique.information1 ;
17459 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LEN_unique.information1 ;
17460 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
17461 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LEN_unique.table_route_id;
17462 --
17463 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
17464 --
17465 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17466 --
17467 --DOUBT log_data('LEN',l_new_value,l_prefix || r_LEN_unique.name|| l_suffix,'REUSED');
17468 --
17469 end if ;
17470 hr_utility.set_location( 'found record for update',10);
17471 --
17472 else
17473 --
17474 l_update := false;
17475 --
17476 end if;
17477 else
17478 --
17479 --UPD END
17480 l_min_esd := null ;
17481 l_max_eed := null ;
17482 open c_LEN_min_max_dates(r_LEN_unique.table_route_id, r_LEN_unique.information1 ) ;
17483 fetch c_LEN_min_max_dates into l_min_esd,l_max_eed ;
17484 --
17485
17486 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17487 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
17488 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
17489 end if;
17490 l_min_esd := greatest(l_min_esd,r_LEN_unique.information2);
17491 /* open c_LEN(r_LEN_unique.table_route_id,
17492 r_LEN_unique.information1,
17493 r_LEN_unique.information2,
17494 r_LEN_unique.information3 ) ;
17495 --
17496 fetch c_LEN into r_LEN ;
17497 --
17498 close c_LEN ; */
17499 --
17500
17501 if p_reuse_object_flag = 'Y' then
17502 if c_LEN_min_max_dates%found then
17503 -- cursor to find the object
17504 open c_find_LEN_in_target( l_min_esd,l_max_eed,
17505 p_target_business_group_id, nvl(l_lee_rsn_id, -999) ) ;
17506 fetch c_find_LEN_in_target into l_new_value ;
17507 if c_find_LEN_in_target%found then
17508 --
17509 --TEMPIK
17510 l_dt_rec_found := dt_api.check_min_max_dates
17511 (p_base_table_name => 'BEN_LEE_RSN_F',
17512 p_base_key_column => 'LEE_RSN_ID',
17513 p_base_key_value => l_new_value,
17514 p_from_date => l_min_esd,
17515 p_to_date => l_max_eed );
17516 if l_dt_rec_found THEN
17517 --END TEMPIK
17518 if r_LEN_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
17519 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LEE_RSN_ID' then
17520 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LEE_RSN_ID' ;
17521 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LEN_unique.information1 ;
17522 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
17523 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
17524 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LEN_unique.table_route_id;
17525 --
17526 -- 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) ;
17527 --
17528 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17529 end if ;
17530 --
17531 l_object_found_in_target := true ;
17532 --TEMPIK
17533 end if; -- l_dt_rec_found
17534 --END TEMPIK
17535 end if;
17536 close c_find_LEN_in_target ;
17537 --
17538 end if;
17539 end if ;
17540 --
17541 close c_LEN_min_max_dates ;
17542 end if; --if p_dml_operation
17543 --
17544 if not l_object_found_in_target OR l_update then
17545 --
17546 l_current_pk_id := r_LEN.information1;
17547 --
17548 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
17549 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
17550 --
17551 if l_current_pk_id = l_prev_pk_id then
17552 --
17553 l_first_rec := false ;
17554 --
17555 else
17556 --
17557 l_first_rec := true ;
17558 --
17559 end if ;
17560 --
17561
17562 l_effective_date := r_LEN.information2;
17563 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17564 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
17565 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
17566 end if;
17567
17568 if l_first_rec and not l_update then
17569 -- Call Create routine.
17570 hr_utility.set_location(' BEN_LEE_RSN_F CREATE_LIFE_EVENT_ENROLL_RSN ',20);
17571 BEN_LIFE_EVENT_ENROLL_RSN_API.CREATE_LIFE_EVENT_ENROLL_RSN(
17572 --
17573 P_VALIDATE => false
17574 ,P_EFFECTIVE_DATE => l_effective_date
17575 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
17576 --
17577 ,P_ADDL_PROCG_DYS_NUM => r_LEN.INFORMATION260
17578 ,P_CLS_ENRT_DT_TO_USE_CD => r_LEN.INFORMATION11
17579 ,P_DYS_AFTR_END_TO_DFLT_NUM => r_LEN.INFORMATION258
17580 ,P_DYS_NO_ENRL_CANT_ENRL_NUM => r_LEN.INFORMATION262
17581 ,P_DYS_NO_ENRL_NOT_ELIG_NUM => r_LEN.INFORMATION261
17582 ,P_ENRT_CVG_END_DT_CD => r_LEN.INFORMATION12
17583 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
17584 ,P_ENRT_CVG_STRT_DT_CD => r_LEN.INFORMATION13
17585 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
17586 ,P_ENRT_PERD_DET_OVRLP_BCKDT_CD => r_LEN.INFORMATION18
17587 ,P_ENRT_PERD_END_DT_CD => r_LEN.INFORMATION15
17588 ,P_ENRT_PERD_END_DT_RL => l_ENRT_PERD_END_DT_RL
17589 ,P_ENRT_PERD_STRT_DT_CD => r_LEN.INFORMATION14
17590 ,P_ENRT_PERD_STRT_DT_RL => l_ENRT_PERD_STRT_DT_RL
17591 ,P_LEE_RSN_ID => l_lee_rsn_id
17592 ,P_LEN_ATTRIBUTE1 => r_LEN.INFORMATION111
17593 ,P_LEN_ATTRIBUTE10 => r_LEN.INFORMATION120
17594 ,P_LEN_ATTRIBUTE11 => r_LEN.INFORMATION121
17595 ,P_LEN_ATTRIBUTE12 => r_LEN.INFORMATION122
17596 ,P_LEN_ATTRIBUTE13 => r_LEN.INFORMATION123
17597 ,P_LEN_ATTRIBUTE14 => r_LEN.INFORMATION124
17598 ,P_LEN_ATTRIBUTE15 => r_LEN.INFORMATION125
17599 ,P_LEN_ATTRIBUTE16 => r_LEN.INFORMATION126
17600 ,P_LEN_ATTRIBUTE17 => r_LEN.INFORMATION127
17601 ,P_LEN_ATTRIBUTE18 => r_LEN.INFORMATION128
17602 ,P_LEN_ATTRIBUTE19 => r_LEN.INFORMATION129
17603 ,P_LEN_ATTRIBUTE2 => r_LEN.INFORMATION112
17604 ,P_LEN_ATTRIBUTE20 => r_LEN.INFORMATION130
17605 ,P_LEN_ATTRIBUTE21 => r_LEN.INFORMATION131
17606 ,P_LEN_ATTRIBUTE22 => r_LEN.INFORMATION132
17607 ,P_LEN_ATTRIBUTE23 => r_LEN.INFORMATION133
17608 ,P_LEN_ATTRIBUTE24 => r_LEN.INFORMATION134
17609 ,P_LEN_ATTRIBUTE25 => r_LEN.INFORMATION135
17610 ,P_LEN_ATTRIBUTE26 => r_LEN.INFORMATION136
17611 ,P_LEN_ATTRIBUTE27 => r_LEN.INFORMATION137
17612 ,P_LEN_ATTRIBUTE28 => r_LEN.INFORMATION138
17613 ,P_LEN_ATTRIBUTE29 => r_LEN.INFORMATION139
17614 ,P_LEN_ATTRIBUTE3 => r_LEN.INFORMATION113
17615 ,P_LEN_ATTRIBUTE30 => r_LEN.INFORMATION140
17616 ,P_LEN_ATTRIBUTE4 => r_LEN.INFORMATION114
17617 ,P_LEN_ATTRIBUTE5 => r_LEN.INFORMATION115
17618 ,P_LEN_ATTRIBUTE6 => r_LEN.INFORMATION116
17619 ,P_LEN_ATTRIBUTE7 => r_LEN.INFORMATION117
17620 ,P_LEN_ATTRIBUTE8 => r_LEN.INFORMATION118
17621 ,P_LEN_ATTRIBUTE9 => r_LEN.INFORMATION119
17622 ,P_LEN_ATTRIBUTE_CATEGORY => r_LEN.INFORMATION110
17623 --Added two cols reinstate_cd,reinstate_ovrdn_cd
17624 ,P_REINSTATE_CD => r_LEN.INFORMATION19
17625 ,P_REINSTATE_OVRDN_CD => r_LEN.INFORMATION20
17626 ,P_ENRT_PERD_STRT_DAYS => r_LEN.INFORMATION271
17627 ,P_ENRT_PERD_END_DAYS => r_LEN.INFORMATION272
17628 --
17629 ,P_LER_ID => l_LER_ID
17630 ,P_POPL_ENRT_TYP_CYCL_ID => l_POPL_ENRT_TYP_CYCL_ID
17631 ,P_RT_END_DT_CD => r_LEN.INFORMATION16
17632 ,P_RT_END_DT_RL => l_RT_END_DT_RL
17633 ,P_RT_STRT_DT_CD => r_LEN.INFORMATION17
17634 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
17635 --
17636 ,P_EFFECTIVE_START_DATE => l_effective_start_date
17637 ,P_EFFECTIVE_END_DATE => l_effective_end_date
17638 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
17639 );
17640 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
17641 -- Update all relevent cer records with new pk_id
17642 hr_utility.set_location('Before plsql table ',222);
17643 hr_utility.set_location('new_value id '||l_lee_rsn_id,222);
17644 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LEE_RSN_ID' ;
17645 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LEN.information1 ;
17646 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LEE_RSN_ID ;
17647 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
17648 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LEN_unique.table_route_id;
17649 hr_utility.set_location('After plsql table ',222);
17650 --
17651 -- 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 ) ;
17652 --
17653 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17654 --
17655 else
17656 --
17657 -- Call Update routine for the pk_id created in prev run .
17658 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
17659 hr_utility.set_location(' BEN_LEE_RSN_F UPDATE_LIFE_EVENT_ENROLL_RSN ',30);
17660 --UPD START
17661 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
17662 --
17663 if l_update then
17664 --
17665 l_datetrack_mode := r_LEN.datetrack_mode ;
17666 --
17667 get_dt_modes(
17668 p_effective_date => l_process_date,
17669 p_effective_end_date => r_LEN.information3,
17670 p_effective_start_date => r_LEN.information2,
17671 p_dml_operation => r_LEN.dml_operation,
17672 p_datetrack_mode => l_datetrack_mode );
17673 -- p_update => l_update
17674 --
17675 l_effective_date := l_process_date;
17676 l_LEE_RSN_ID := r_LEN.information1;
17677 l_object_version_number := r_LEN.information265;
17678 --
17679 end if;
17680 --
17681 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
17682 --
17683 IF l_update OR l_dml_operation <> 'UPDATE' THEN
17684 --UPD END
17685 BEN_LIFE_EVENT_ENROLL_RSN_API.UPDATE_LIFE_EVENT_ENROLL_RSN(
17686 --
17687 P_VALIDATE => false
17688 ,P_EFFECTIVE_DATE => l_effective_date
17689 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
17690 --
17691 ,P_ADDL_PROCG_DYS_NUM => r_LEN.INFORMATION260
17692 ,P_CLS_ENRT_DT_TO_USE_CD => r_LEN.INFORMATION11
17693 ,P_DYS_AFTR_END_TO_DFLT_NUM => r_LEN.INFORMATION258
17694 ,P_DYS_NO_ENRL_CANT_ENRL_NUM => r_LEN.INFORMATION262
17695 ,P_DYS_NO_ENRL_NOT_ELIG_NUM => r_LEN.INFORMATION261
17696 ,P_ENRT_CVG_END_DT_CD => r_LEN.INFORMATION12
17697 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
17698 ,P_ENRT_CVG_STRT_DT_CD => r_LEN.INFORMATION13
17699 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
17700 ,P_ENRT_PERD_DET_OVRLP_BCKDT_CD => r_LEN.INFORMATION18
17701 ,P_ENRT_PERD_END_DT_CD => r_LEN.INFORMATION15
17702 ,P_ENRT_PERD_END_DT_RL => l_ENRT_PERD_END_DT_RL
17703 ,P_ENRT_PERD_STRT_DT_CD => r_LEN.INFORMATION14
17704 ,P_ENRT_PERD_STRT_DT_RL => l_ENRT_PERD_STRT_DT_RL
17705 ,P_LEE_RSN_ID => l_lee_rsn_id
17706 ,P_LEN_ATTRIBUTE1 => r_LEN.INFORMATION111
17707 ,P_LEN_ATTRIBUTE10 => r_LEN.INFORMATION120
17708 ,P_LEN_ATTRIBUTE11 => r_LEN.INFORMATION121
17709 ,P_LEN_ATTRIBUTE12 => r_LEN.INFORMATION122
17710 ,P_LEN_ATTRIBUTE13 => r_LEN.INFORMATION123
17711 ,P_LEN_ATTRIBUTE14 => r_LEN.INFORMATION124
17712 ,P_LEN_ATTRIBUTE15 => r_LEN.INFORMATION125
17713 ,P_LEN_ATTRIBUTE16 => r_LEN.INFORMATION126
17714 ,P_LEN_ATTRIBUTE17 => r_LEN.INFORMATION127
17715 ,P_LEN_ATTRIBUTE18 => r_LEN.INFORMATION128
17716 ,P_LEN_ATTRIBUTE19 => r_LEN.INFORMATION129
17717 ,P_LEN_ATTRIBUTE2 => r_LEN.INFORMATION112
17718 ,P_LEN_ATTRIBUTE20 => r_LEN.INFORMATION130
17719 ,P_LEN_ATTRIBUTE21 => r_LEN.INFORMATION131
17720 ,P_LEN_ATTRIBUTE22 => r_LEN.INFORMATION132
17721 ,P_LEN_ATTRIBUTE23 => r_LEN.INFORMATION133
17722 ,P_LEN_ATTRIBUTE24 => r_LEN.INFORMATION134
17723 ,P_LEN_ATTRIBUTE25 => r_LEN.INFORMATION135
17724 ,P_LEN_ATTRIBUTE26 => r_LEN.INFORMATION136
17725 ,P_LEN_ATTRIBUTE27 => r_LEN.INFORMATION137
17726 ,P_LEN_ATTRIBUTE28 => r_LEN.INFORMATION138
17727 ,P_LEN_ATTRIBUTE29 => r_LEN.INFORMATION139
17728 ,P_LEN_ATTRIBUTE3 => r_LEN.INFORMATION113
17729 ,P_LEN_ATTRIBUTE30 => r_LEN.INFORMATION140
17730 ,P_LEN_ATTRIBUTE4 => r_LEN.INFORMATION114
17731 ,P_LEN_ATTRIBUTE5 => r_LEN.INFORMATION115
17732 ,P_LEN_ATTRIBUTE6 => r_LEN.INFORMATION116
17733 ,P_LEN_ATTRIBUTE7 => r_LEN.INFORMATION117
17734 ,P_LEN_ATTRIBUTE8 => r_LEN.INFORMATION118
17735 ,P_LEN_ATTRIBUTE9 => r_LEN.INFORMATION119
17736 ,P_LEN_ATTRIBUTE_CATEGORY => r_LEN.INFORMATION110
17737 --Added two cols reinstate_cd,reinstate_ovrdn_cd
17738 ,P_REINSTATE_CD => r_LEN.INFORMATION19
17739 ,P_REINSTATE_OVRDN_CD => r_LEN.INFORMATION20
17740 --
17741 ,P_LER_ID => l_LER_ID
17742 ,P_POPL_ENRT_TYP_CYCL_ID => l_POPL_ENRT_TYP_CYCL_ID
17743 ,P_RT_END_DT_CD => r_LEN.INFORMATION16
17744 ,P_RT_END_DT_RL => l_RT_END_DT_RL
17745 ,P_RT_STRT_DT_CD => r_LEN.INFORMATION17
17746 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
17747 --
17748 ,P_EFFECTIVE_START_DATE => l_effective_start_date
17749 ,P_EFFECTIVE_END_DATE => l_effective_end_date
17750 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
17751 ,P_DATETRACK_MODE => l_datetrack_mode
17752 );
17753 --
17754 end if; -- l_update
17755 end if;
17756 --
17757 -- Delete the row if it is end dated.
17758 --
17759 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
17760 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
17761 trunc(l_max_eed) = r_LEN.information3) then
17762 --
17763 BEN_LIFE_EVENT_ENROLL_RSN_API.delete_LIFE_EVENT_ENROLL_RSN(
17764 --
17765 p_validate => false
17766 ,p_lee_rsn_id => l_lee_rsn_id
17767 ,p_effective_start_date => l_effective_start_date
17768 ,p_effective_end_date => l_effective_end_date
17769 ,p_object_version_number => l_object_version_number
17770 ,p_effective_date => l_max_eed
17771 ,p_datetrack_mode => hr_api.g_delete
17772 --
17773 );
17774 --
17775 end if;
17776 --
17777 l_prev_pk_id := l_current_pk_id ;
17778 --
17779 end if;
17780 --
17781 end if;
17782 --
17783 end loop;
17784 --
17785 exception when others then
17786 --
17787 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LEN',r_len.information5 );
17788 --
17789 end create_LEN_rows;
17790
17791 --
17792 ---------------------------------------------------------------
17793 ----------------------< create_ERP_rows >-----------------------
17794 ---------------------------------------------------------------
17795 --
17796 procedure create_ERP_rows
17797 (
17798 p_validate in number default 0
17799 ,p_copy_entity_txn_id in number
17800 ,p_effective_date in date
17801 ,p_prefix_suffix_text in varchar2 default null
17802 ,p_reuse_object_flag in varchar2 default null
17803 ,p_target_business_group_id in varchar2 default null
17804 ,p_prefix_suffix_cd in varchar2 default null
17805 ) is
17806 --
17807 l_ENRT_CVG_END_DT_RL number;
17808 l_ENRT_CVG_STRT_DT_RL number;
17809 l_ENRT_PERD_ID number;
17810 l_LEE_RSN_ID number;
17811 l_PL_ID number;
17812 l_RT_END_DT_RL number;
17813 l_RT_STRT_DT_RL number;
17814 cursor c_unique_ERP(l_table_alias varchar2) is
17815 select distinct cpe.information1,
17816 cpe.information2,
17817 cpe.information3,
17818 cpe.table_route_id
17819 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
17820 pqh_table_route tr
17821 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17822 and cpe.table_route_id = tr.table_route_id
17823 -- and tr.where_clause = l_BEN_ENRT_PERD_FOR_PL_F
17824 and tr.table_alias = l_table_alias
17825 and cpe.number_of_copies = 1 -- ADDITION
17826 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
17827 order by information1, information2; --added for bug: 5151945
17828 --
17829 --
17830 cursor c_ERP_min_max_dates(c_table_route_id number,
17831 c_information1 number) is
17832 select
17833 min(cpe.information2) min_esd,
17834 max(cpe.information3) min_eed
17835 from ben_copy_entity_results cpe
17836 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17837 and cpe.table_route_id = c_table_route_id
17838 and cpe.information1 = c_information1 ;
17839 --
17840 cursor c_ERP(c_table_route_id number,
17841 c_information1 number,
17842 c_information2 date,
17843 c_information3 date) is
17844 select
17845 cpe.*
17846 from ben_copy_entity_results cpe
17847 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17848 and cpe.table_route_id = c_table_route_id
17849 and cpe.information1 = c_information1
17850 and cpe.information2 = c_information2
17851 and cpe.information3 = c_information3
17852 and rownum = 1 ;
17853 -- Date Track target record
17854 -- 9999 do we need to check any other data.
17855 cursor c_find_ERP_in_target(
17856 c_effective_start_date date,
17857 c_effective_end_date date,
17858 c_business_group_id number,
17859 c_new_pk_id number) is
17860 select
17861 ERP.enrt_perd_for_pl_id new_value
17862 from BEN_ENRT_PERD_FOR_PL_F ERP
17863 where
17864 nvl(ERP.ENRT_PERD_ID,-999) = nvl(l_ENRT_PERD_ID,-999) and
17865 nvl(ERP.LEE_RSN_ID,-999) = nvl(l_LEE_RSN_ID,-999) and
17866 nvl(ERP.PL_ID,-999) = nvl(l_PL_ID,-999) and
17867 ERP.business_group_id = c_business_group_id
17868 and ERP.enrt_perd_for_pl_id <> c_new_pk_id
17869 --TEMPIK
17870 and c_effective_start_date between effective_start_date
17871 and effective_end_date ;
17872 --END TEMPIK
17873 /*TEMPIK
17874
17875 and exists ( select null
17876 from BEN_ENRT_PERD_FOR_PL_F ERP1
17877 where
17878 nvl(ERP1.ENRT_PERD_ID,-999) = nvl(l_ENRT_PERD_ID, -999) and
17879 nvl(ERP1.LEE_RSN_ID,-999) = nvl(l_LEE_RSN_ID, -999) and
17880 nvl(ERP1.PL_ID,-999) = nvl(l_PL_ID, -999) and
17881 ERP1.business_group_id = c_business_group_id
17882 and ERP1.effective_start_date <= c_effective_start_date )
17883 and exists ( select null
17884 from BEN_ENRT_PERD_FOR_PL_F ERP2
17885 where
17886 nvl(ERP2.ENRT_PERD_ID,-999) = nvl(l_ENRT_PERD_ID, -999) and
17887 nvl(ERP2.LEE_RSN_ID,-999) = nvl(l_LEE_RSN_ID, -999) and
17888 nvl(ERP2.PL_ID,-999) = nvl(l_PL_ID, -999) and
17889 ERP2.business_group_id = c_business_group_id
17890 and ERP2.effective_end_date >= c_effective_end_date )
17891 ;
17892 */
17893 --
17894 --UPD START
17895 --
17896 l_update boolean := false ;
17897 l_datetrack_mode varchar2(80) := hr_api.g_update;
17898 l_process_date date;
17899 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
17900 --
17901 --UPD END
17902 l_current_pk_id number := null ;
17903 l_prev_pk_id number := null ;
17904 l_first_rec boolean := true ;
17905 r_ERP c_ERP%rowtype;
17906 l_enrt_perd_for_pl_id number ;
17907 l_object_version_number number ;
17908 l_effective_start_date date ;
17909 l_effective_end_date date ;
17910 l_prefix pqh_copy_entity_attribs.information1%type := null;
17911 l_suffix pqh_copy_entity_attribs.information1%type := null;
17912 l_new_value number(15);
17913 l_object_found_in_target boolean := false ;
17914 l_min_esd date;
17915 l_max_eed date;
17916 l_effective_date date;
17917 --TEMPIK
17918 l_dt_rec_found boolean ;
17919 --END TEMPIK
17920 --
17921 begin
17922 -- Initialization
17923 l_object_found_in_target := false ;
17924 -- End Initialization
17925 -- Derive the prefix - sufix
17926 if p_prefix_suffix_cd = 'PREFIX' then
17927 l_prefix := p_prefix_suffix_text ;
17928 elsif p_prefix_suffix_cd = 'SUFFIX' then
17929 l_suffix := p_prefix_suffix_text ;
17930 else
17931 l_prefix := null ;
17932 l_suffix := null ;
17933 end if ;
17934 -- End Prefix Sufix derivation
17935 for r_ERP_unique in c_unique_ERP('ERP') loop
17936
17937 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
17938 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17939 r_ERP_unique.information3 >=
17940 ben_pd_copy_to_ben_one.g_copy_effective_date)
17941 ) then
17942 --
17943 hr_utility.set_location(' r_ERP_unique.table_route_id '||r_ERP_unique.table_route_id,10);
17944 hr_utility.set_location(' r_ERP_unique.information1 '||r_ERP_unique.information1,10);
17945 hr_utility.set_location( 'r_ERP_unique.information2 '||r_ERP_unique.information2,10);
17946 hr_utility.set_location( 'r_ERP_unique.information3 '||r_ERP_unique.information3,10);
17947 -- If reuse objects flag is 'Y' then check for the object in the target business group
17948 -- if found insert the record into PLSql table and exit the loop else try create the
17949 -- object in the target business group
17950 --
17951 l_object_found_in_target := false ;
17952 --UPD START
17953 open c_ERP(r_ERP_unique.table_route_id,
17954 r_ERP_unique.information1,
17955 r_ERP_unique.information2,
17956 r_ERP_unique.information3 ) ;
17957 --
17958 fetch c_ERP into r_ERP ;
17959 --
17960 close c_ERP ;
17961 --
17962 l_dml_operation:= r_ERP_unique.dml_operation ;
17963 l_ENRT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_ERP.INFORMATION262,l_dml_operation);
17964 l_ENRT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_ERP.INFORMATION260,l_dml_operation);
17965 l_ENRT_PERD_ID := get_fk('ENRT_PERD_ID', r_ERP.INFORMATION244,l_dml_operation);
17966 l_LEE_RSN_ID := get_fk('LEE_RSN_ID', r_ERP.INFORMATION234,l_dml_operation);
17967 l_PL_ID := get_fk('PL_ID', r_ERP.INFORMATION261,l_dml_operation);
17968 l_RT_END_DT_RL := get_fk('FORMULA_ID', r_ERP.INFORMATION264,l_dml_operation);
17969 l_RT_STRT_DT_RL := get_fk('FORMULA_ID', r_ERP.INFORMATION263,l_dml_operation);
17970 --
17971 l_update := false;
17972 l_process_date := p_effective_date;
17973 --
17974 if l_dml_operation = 'UPDATE' then
17975 --
17976 l_object_found_in_target := TRUE;
17977 --
17978 if l_process_date between r_ERP_unique.information2 and r_ERP_unique.information3 then
17979 l_update := true;
17980 if r_ERP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
17981 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ENRT_PERD_FOR_PL_ID'
17982 then
17983 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ENRT_PERD_FOR_PL_ID' ;
17984 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ERP_unique.information1 ;
17985 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ERP_unique.information1 ;
17986 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
17987 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ERP_unique.table_route_id;
17988 --
17989 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
17990 --
17991 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17992 --
17993 --DOUBT log_data('ERP',l_new_value,l_prefix || r_ERP_unique.name|| l_suffix,'REUSED');
17994 --
17995 end if ;
17996 hr_utility.set_location( 'found record for update',10);
17997 --
17998 else
17999 --
18000 l_update := false;
18001 --
18002 end if;
18003 else
18004 --
18005 --UPD END
18006 l_min_esd := null ;
18007 l_max_eed := null ;
18008 open c_ERP_min_max_dates(r_ERP_unique.table_route_id, r_ERP_unique.information1 ) ;
18009 fetch c_ERP_min_max_dates into l_min_esd,l_max_eed ;
18010 --
18011
18012 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18013 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18014 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
18015 end if;
18016 l_min_esd := greatest(l_min_esd,r_ERP_unique.information2);
18017 /* open c_ERP(r_ERP_unique.table_route_id,
18018 r_ERP_unique.information1,
18019 r_ERP_unique.information2,
18020 r_ERP_unique.information3 ) ;
18021 --
18022 fetch c_ERP into r_ERP ;
18023 --
18024 close c_ERP ; */
18025 -- moved get_fk to top
18026
18027 if p_reuse_object_flag = 'Y' then
18028 if c_ERP_min_max_dates%found then
18029 -- cursor to find the object
18030 open c_find_ERP_in_target( l_min_esd,l_max_eed,
18031 p_target_business_group_id, nvl(l_enrt_perd_for_pl_id, -999) ) ;
18032 fetch c_find_ERP_in_target into l_new_value ;
18033 if c_find_ERP_in_target%found then
18034 --
18035 --TEMPIK
18036 l_dt_rec_found := dt_api.check_min_max_dates
18037 (p_base_table_name => 'BEN_ENRT_PERD_FOR_PL_F',
18038 p_base_key_column => 'ENRT_PERD_FOR_PL_ID',
18039 p_base_key_value => l_new_value,
18040 p_from_date => l_min_esd,
18041 p_to_date => l_max_eed );
18042 if l_dt_rec_found THEN
18043 --END TEMPIK
18044 if r_ERP_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
18045 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ENRT_PERD_FOR_PL_ID' then
18046 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ENRT_PERD_FOR_PL_ID' ;
18047 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ERP_unique.information1 ;
18048 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
18049 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18050 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ERP_unique.table_route_id;
18051 --
18052 -- 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) ;
18053 --
18054 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18055 end if ;
18056 --
18057 l_object_found_in_target := true ;
18058 --TEMPIK
18059 end if; -- l_dt_rec_found
18060 --END TEMPIK
18061 end if;
18062 close c_find_ERP_in_target ;
18063 --
18064 end if;
18065 end if ;
18066 --
18067 close c_ERP_min_max_dates ;
18068 end if; --if p_dml_operation
18069 --
18070 if not l_object_found_in_target OR l_update then
18071 --
18072 l_current_pk_id := r_ERP.information1;
18073 --
18074 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
18075 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
18076 --
18077 if l_current_pk_id = l_prev_pk_id then
18078 --
18079 l_first_rec := false ;
18080 --
18081 else
18082 --
18083 l_first_rec := true ;
18084 --
18085 end if ;
18086 --
18087
18088 l_effective_date := r_ERP.information2;
18089 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18090 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18091 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
18092 end if;
18093
18094 if l_first_rec and not l_update then
18095 -- Call Create routine.
18096 hr_utility.set_location(' BEN_ENRT_PERD_FOR_PL_F CREATE_ENRT_PERD_FOR_PL ',20);
18097 BEN_ENRT_PERD_FOR_PL_API.CREATE_ENRT_PERD_FOR_PL(
18098 --
18099 P_VALIDATE => false
18100 ,P_EFFECTIVE_DATE => l_effective_date
18101 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
18102 --
18103 ,P_ENRT_CVG_END_DT_CD => r_ERP.INFORMATION12
18104 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
18105 ,P_ENRT_CVG_STRT_DT_CD => r_ERP.INFORMATION11
18106 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
18107 ,P_ENRT_PERD_FOR_PL_ID => l_enrt_perd_for_pl_id
18108 ,P_ENRT_PERD_ID => l_ENRT_PERD_ID
18109 ,P_ERP_ATTRIBUTE1 => r_ERP.INFORMATION111
18110 ,P_ERP_ATTRIBUTE10 => r_ERP.INFORMATION120
18111 ,P_ERP_ATTRIBUTE11 => r_ERP.INFORMATION121
18112 ,P_ERP_ATTRIBUTE12 => r_ERP.INFORMATION122
18113 ,P_ERP_ATTRIBUTE13 => r_ERP.INFORMATION123
18114 ,P_ERP_ATTRIBUTE14 => r_ERP.INFORMATION124
18115 ,P_ERP_ATTRIBUTE15 => r_ERP.INFORMATION125
18116 ,P_ERP_ATTRIBUTE16 => r_ERP.INFORMATION126
18117 ,P_ERP_ATTRIBUTE17 => r_ERP.INFORMATION127
18118 ,P_ERP_ATTRIBUTE18 => r_ERP.INFORMATION128
18119 ,P_ERP_ATTRIBUTE19 => r_ERP.INFORMATION129
18120 ,P_ERP_ATTRIBUTE2 => r_ERP.INFORMATION112
18121 ,P_ERP_ATTRIBUTE20 => r_ERP.INFORMATION130
18122 ,P_ERP_ATTRIBUTE21 => r_ERP.INFORMATION131
18123 ,P_ERP_ATTRIBUTE22 => r_ERP.INFORMATION132
18124 ,P_ERP_ATTRIBUTE23 => r_ERP.INFORMATION133
18125 ,P_ERP_ATTRIBUTE24 => r_ERP.INFORMATION134
18126 ,P_ERP_ATTRIBUTE25 => r_ERP.INFORMATION135
18127 ,P_ERP_ATTRIBUTE26 => r_ERP.INFORMATION136
18128 ,P_ERP_ATTRIBUTE27 => r_ERP.INFORMATION137
18129 ,P_ERP_ATTRIBUTE28 => r_ERP.INFORMATION138
18130 ,P_ERP_ATTRIBUTE29 => r_ERP.INFORMATION139
18131 ,P_ERP_ATTRIBUTE3 => r_ERP.INFORMATION113
18132 ,P_ERP_ATTRIBUTE30 => r_ERP.INFORMATION140
18133 ,P_ERP_ATTRIBUTE4 => r_ERP.INFORMATION114
18134 ,P_ERP_ATTRIBUTE5 => r_ERP.INFORMATION115
18135 ,P_ERP_ATTRIBUTE6 => r_ERP.INFORMATION116
18136 ,P_ERP_ATTRIBUTE7 => r_ERP.INFORMATION117
18137 ,P_ERP_ATTRIBUTE8 => r_ERP.INFORMATION118
18138 ,P_ERP_ATTRIBUTE9 => r_ERP.INFORMATION119
18139 ,P_ERP_ATTRIBUTE_CATEGORY => r_ERP.INFORMATION110
18140 ,P_LEE_RSN_ID => l_LEE_RSN_ID
18141 ,P_PL_ID => l_PL_ID
18142 ,P_RT_END_DT_CD => r_ERP.INFORMATION14
18143 ,P_RT_END_DT_RL => l_RT_END_DT_RL
18144 ,P_RT_STRT_DT_CD => r_ERP.INFORMATION13
18145 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
18146 --
18147 ,P_EFFECTIVE_START_DATE => l_effective_start_date
18148 ,P_EFFECTIVE_END_DATE => l_effective_end_date
18149 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
18150 );
18151 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
18152 -- Update all relevent cer records with new pk_id
18153 hr_utility.set_location('Before plsql table ',222);
18154 hr_utility.set_location('new_value id '||l_enrt_perd_for_pl_id,222);
18155 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ENRT_PERD_FOR_PL_ID' ;
18156 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ERP.information1 ;
18157 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ENRT_PERD_FOR_PL_ID ;
18158 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
18159 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ERP_unique.table_route_id;
18160 hr_utility.set_location('After plsql table ',222);
18161 --
18162 -- 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 ) ;
18163 --
18164 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18165 --
18166 else
18167 --
18168 -- Call Update routine for the pk_id created in prev run .
18169 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
18170 hr_utility.set_location(' BEN_ENRT_PERD_FOR_PL_F UPDATE_ENRT_PERD_FOR_PL ',30);
18171 --UPD START
18172 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
18173 --
18174 if l_update then
18175 --
18176 l_datetrack_mode := r_ERP.datetrack_mode ;
18177 --
18178 get_dt_modes(
18179 p_effective_date => l_process_date,
18180 p_effective_end_date => r_ERP.information3,
18181 p_effective_start_date => r_ERP.information2,
18182 p_dml_operation => r_ERP.dml_operation,
18183 p_datetrack_mode => l_datetrack_mode );
18184 -- p_update => l_update
18185 --
18186 l_effective_date := l_process_date;
18187 l_ENRT_PERD_FOR_PL_ID := r_ERP.information1;
18188 l_object_version_number := r_ERP.information265;
18189 --
18190 end if;
18191 --
18192 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
18193 --
18194 IF l_update OR l_dml_operation <> 'UPDATE' THEN
18195 --UPD END
18196 BEN_ENRT_PERD_FOR_PL_API.UPDATE_ENRT_PERD_FOR_PL(
18197 --
18198 P_VALIDATE => false
18199 ,P_EFFECTIVE_DATE => l_effective_date
18200 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
18201 --
18202 ,P_ENRT_CVG_END_DT_CD => r_ERP.INFORMATION12
18203 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
18204 ,P_ENRT_CVG_STRT_DT_CD => r_ERP.INFORMATION11
18205 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
18206 ,P_ENRT_PERD_FOR_PL_ID => l_enrt_perd_for_pl_id
18207 ,P_ENRT_PERD_ID => l_ENRT_PERD_ID
18208 ,P_ERP_ATTRIBUTE1 => r_ERP.INFORMATION111
18209 ,P_ERP_ATTRIBUTE10 => r_ERP.INFORMATION120
18210 ,P_ERP_ATTRIBUTE11 => r_ERP.INFORMATION121
18211 ,P_ERP_ATTRIBUTE12 => r_ERP.INFORMATION122
18212 ,P_ERP_ATTRIBUTE13 => r_ERP.INFORMATION123
18213 ,P_ERP_ATTRIBUTE14 => r_ERP.INFORMATION124
18214 ,P_ERP_ATTRIBUTE15 => r_ERP.INFORMATION125
18215 ,P_ERP_ATTRIBUTE16 => r_ERP.INFORMATION126
18216 ,P_ERP_ATTRIBUTE17 => r_ERP.INFORMATION127
18217 ,P_ERP_ATTRIBUTE18 => r_ERP.INFORMATION128
18218 ,P_ERP_ATTRIBUTE19 => r_ERP.INFORMATION129
18219 ,P_ERP_ATTRIBUTE2 => r_ERP.INFORMATION112
18220 ,P_ERP_ATTRIBUTE20 => r_ERP.INFORMATION130
18221 ,P_ERP_ATTRIBUTE21 => r_ERP.INFORMATION131
18222 ,P_ERP_ATTRIBUTE22 => r_ERP.INFORMATION132
18223 ,P_ERP_ATTRIBUTE23 => r_ERP.INFORMATION133
18224 ,P_ERP_ATTRIBUTE24 => r_ERP.INFORMATION134
18225 ,P_ERP_ATTRIBUTE25 => r_ERP.INFORMATION135
18226 ,P_ERP_ATTRIBUTE26 => r_ERP.INFORMATION136
18227 ,P_ERP_ATTRIBUTE27 => r_ERP.INFORMATION137
18228 ,P_ERP_ATTRIBUTE28 => r_ERP.INFORMATION138
18229 ,P_ERP_ATTRIBUTE29 => r_ERP.INFORMATION139
18230 ,P_ERP_ATTRIBUTE3 => r_ERP.INFORMATION113
18231 ,P_ERP_ATTRIBUTE30 => r_ERP.INFORMATION140
18232 ,P_ERP_ATTRIBUTE4 => r_ERP.INFORMATION114
18233 ,P_ERP_ATTRIBUTE5 => r_ERP.INFORMATION115
18234 ,P_ERP_ATTRIBUTE6 => r_ERP.INFORMATION116
18235 ,P_ERP_ATTRIBUTE7 => r_ERP.INFORMATION117
18236 ,P_ERP_ATTRIBUTE8 => r_ERP.INFORMATION118
18237 ,P_ERP_ATTRIBUTE9 => r_ERP.INFORMATION119
18238 ,P_ERP_ATTRIBUTE_CATEGORY => r_ERP.INFORMATION110
18239 ,P_LEE_RSN_ID => l_LEE_RSN_ID
18240 ,P_PL_ID => l_PL_ID
18241 ,P_RT_END_DT_CD => r_ERP.INFORMATION14
18242 ,P_RT_END_DT_RL => l_RT_END_DT_RL
18243 ,P_RT_STRT_DT_CD => r_ERP.INFORMATION13
18244 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
18245 --
18246 ,P_EFFECTIVE_START_DATE => l_effective_start_date
18247 ,P_EFFECTIVE_END_DATE => l_effective_end_date
18248 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
18249 ,P_DATETRACK_MODE => l_datetrack_mode
18250 );
18251 --
18252 end if; -- l_update
18253 end if;
18254 --
18255 -- Delete the row if it is end dated.
18256 --
18257 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
18258 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
18259 trunc(l_max_eed) = r_ERP.information3) then
18260 --
18261 BEN_ENRT_PERD_FOR_PL_API.delete_ENRT_PERD_FOR_PL(
18262 --
18263 p_validate => false
18264 ,p_enrt_perd_for_pl_id => l_enrt_perd_for_pl_id
18265 ,p_effective_start_date => l_effective_start_date
18266 ,p_effective_end_date => l_effective_end_date
18267 ,p_object_version_number => l_object_version_number
18268 ,p_effective_date => l_max_eed
18269 ,p_datetrack_mode => hr_api.g_delete
18270 --
18271 );
18272 --
18273 end if;
18274 --
18275 l_prev_pk_id := l_current_pk_id ;
18276 --
18277 end if;
18278 --
18279 end if;
18280 --
18281 end loop;
18282 --
18283 exception when others then
18284 --
18285 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ERP',r_erp.information5 );
18286 --
18287 end create_ERP_rows;
18288
18289 --
18290 ---------------------------------------------------------------
18291 ----------------------< create_SER_rows >-----------------------
18292 ---------------------------------------------------------------
18293 --
18294 procedure create_SER_rows
18295 (
18296 p_validate in number default 0
18297 ,p_copy_entity_txn_id in number
18298 ,p_effective_date in date
18299 ,p_prefix_suffix_text in varchar2 default null
18300 ,p_reuse_object_flag in varchar2 default null
18301 ,p_target_business_group_id in varchar2 default null
18302 ,p_prefix_suffix_cd in varchar2 default null
18303 ) is
18304 --
18305 l_ENRT_PERD_ID number;
18306 l_FORMULA_ID number;
18307 cursor c_unique_SER(l_table_alias varchar2) is
18308 select distinct cpe.information1,
18309 cpe.information2,
18310 cpe.information3,
18311 cpe.table_route_id
18312 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
18313 pqh_table_route tr
18314 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18315 and cpe.table_route_id = tr.table_route_id
18316 -- and tr.where_clause = l_BEN_SCHEDD_ENRT_RL_F
18317 and tr.table_alias = l_table_alias
18318 and cpe.number_of_copies = 1 -- ADDITION
18319 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
18320 order by information1, information2; --added for bug: 5151945
18321 --
18322 --
18323 cursor c_SER_min_max_dates(c_table_route_id number,
18324 c_information1 number) is
18325 select
18326 min(cpe.information2) min_esd,
18327 max(cpe.information3) min_eed
18328 from ben_copy_entity_results cpe
18329 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18330 and cpe.table_route_id = c_table_route_id
18331 and cpe.information1 = c_information1 ;
18332 --
18333 cursor c_SER(c_table_route_id number,
18334 c_information1 number,
18335 c_information2 date,
18336 c_information3 date ) is
18337 select
18338 cpe.*
18339 from ben_copy_entity_results cpe
18340 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18341 and cpe.table_route_id = c_table_route_id
18342 and cpe.information1 = c_information1
18343 and cpe.information2 = c_information2
18344 and cpe.information3 = c_information3
18345 and rownum = 1 ;
18346 -- Date Track target record
18347 cursor c_find_SER_in_target(
18348 c_effective_start_date date,
18349 c_effective_end_date date,
18350 c_business_group_id number,
18351 c_new_pk_id number) is
18352 select
18353 SER.schedd_enrt_rl_id new_value
18354 from BEN_SCHEDD_ENRT_RL_F SER
18355 where
18356 nvl(SER.ENRT_PERD_ID,-999) = nvl(l_ENRT_PERD_ID,-999) and
18357 nvl(SER.FORMULA_ID,-999) = nvl(l_FORMULA_ID,-999) and
18358 SER.business_group_id = c_business_group_id
18359 and SER.schedd_enrt_rl_id <> c_new_pk_id
18360 --TEMPIK
18361 and c_effective_start_date between effective_start_date
18362 and effective_end_date ;
18363 --END TEMPIK
18364 /*TEMPIK
18365 and exists ( select null
18366 from BEN_SCHEDD_ENRT_RL_F SER1
18367 where
18368 nvl(SER1.ENRT_PERD_ID,-999) = nvl(l_ENRT_PERD_ID, -999) and
18369 nvl(SER1.FORMULA_ID,-999) = nvl(l_FORMULA_ID , -999) and
18370 SER1.business_group_id = c_business_group_id
18371 and SER1.effective_start_date <= c_effective_start_date )
18372 and exists ( select null
18373 from BEN_SCHEDD_ENRT_RL_F SER2
18374 where
18375 nvl(SER2.ENRT_PERD_ID,-999) = nvl(l_ENRT_PERD_ID , -999) and
18376 nvl(SER2.FORMULA_ID,-999) = nvl(l_FORMULA_ID , -999) and
18377 SER2.business_group_id = c_business_group_id
18378 and SER2.effective_end_date >= c_effective_end_date )
18379 ;
18380 */
18381 --
18382 --UPD START
18383 --
18384 l_update boolean := false ;
18385 l_datetrack_mode varchar2(80) := hr_api.g_update;
18386 l_process_date date;
18387 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
18388 --
18389 --UPD END
18390 l_current_pk_id number := null ;
18391 l_prev_pk_id number := null ;
18392 l_first_rec boolean := true ;
18393 r_SER c_SER%rowtype;
18394 l_schedd_enrt_rl_id number ;
18395 l_object_version_number number ;
18396 l_effective_start_date date ;
18397 l_effective_end_date date ;
18398 l_prefix pqh_copy_entity_attribs.information1%type := null;
18399 l_suffix pqh_copy_entity_attribs.information1%type := null;
18400 l_new_value number(15);
18401 l_object_found_in_target boolean := false ;
18402 l_min_esd date;
18403 l_max_eed date;
18404 l_effective_date date;
18405 --TEMPIK
18406 l_dt_rec_found boolean ;
18407 --END TEMPIK
18408 --
18409 begin
18410 -- Initialization
18411 l_object_found_in_target := false ;
18412 -- End Initialization
18413 -- Derive the prefix - sufix
18414 if p_prefix_suffix_cd = 'PREFIX' then
18415 l_prefix := p_prefix_suffix_text ;
18416 elsif p_prefix_suffix_cd = 'SUFFIX' then
18417 l_suffix := p_prefix_suffix_text ;
18418 else
18419 l_prefix := null ;
18420 l_suffix := null ;
18421 end if ;
18422 -- End Prefix Sufix derivation
18423 for r_SER_unique in c_unique_SER('SER') loop
18424
18425 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
18426 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18427 r_SER_unique.information3 >=
18428 ben_pd_copy_to_ben_one.g_copy_effective_date)
18429 ) then
18430 --
18431 hr_utility.set_location(' r_SER_unique.table_route_id '||r_SER_unique.table_route_id,10);
18432 hr_utility.set_location(' r_SER_unique.information1 '||r_SER_unique.information1,10);
18433 hr_utility.set_location( 'r_SER_unique.information2 '||r_SER_unique.information2,10);
18434 hr_utility.set_location( 'r_SER_unique.information3 '||r_SER_unique.information3,10);
18435 -- If reuse objects flag is 'Y' then check for the object in the target business group
18436 -- if found insert the record into PLSql table and exit the loop else try create the
18437 -- object in the target business group
18438 --
18439 l_object_found_in_target := false ;
18440 --UPD START
18441 open c_SER(r_SER_unique.table_route_id,
18442 r_SER_unique.information1,
18443 r_SER_unique.information2,
18444 r_SER_unique.information3 ) ;
18445 --
18446 fetch c_SER into r_SER ;
18447 --
18448 close c_SER ;
18449 l_dml_operation:= r_SER_unique.dml_operation ;
18450 l_ENRT_PERD_ID := get_fk('ENRT_PERD_ID', r_SER.INFORMATION244,l_dml_operation );
18451 l_FORMULA_ID := get_fk('FORMULA_ID', r_SER.INFORMATION251,l_dml_operation );
18452 l_update := false;
18453 l_process_date := p_effective_date;
18454 --
18455 if l_dml_operation = 'UPDATE' then
18456 --
18457 l_object_found_in_target := TRUE;
18458 --
18459 if l_process_date between r_SER_unique.information2 and r_SER_unique.information3 then
18460 l_update := true;
18461 if r_SER_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
18462 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'SCHEDD_ENRT_RL_ID'
18463 then
18464 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'SCHEDD_ENRT_RL_ID' ;
18465 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_SER_unique.information1 ;
18466 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_SER_unique.information1 ;
18467 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18468 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_SER_unique.table_route_id;
18469 --
18470 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
18471 --
18472 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18473 --
18474 --DOUBT log_data('SER',l_new_value,l_prefix || r_SER_unique.name|| l_suffix,'REUSED');
18475 --
18476 end if ;
18477 hr_utility.set_location( 'found record for update',10);
18478 --
18479 else
18480 --
18481 l_update := false;
18482 --
18483 end if;
18484 else
18485 --
18486 --UPD END
18487 l_min_esd := null ;
18488 l_max_eed := null ;
18489 open c_SER_min_max_dates(r_SER_unique.table_route_id, r_SER_unique.information1 ) ;
18490 fetch c_SER_min_max_dates into l_min_esd,l_max_eed ;
18491 --
18492
18493 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18494 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18495 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
18496 end if;
18497 l_min_esd := greatest(l_min_esd,r_SER_unique.information2);
18498 /* open c_SER(r_SER_unique.table_route_id,
18499 r_SER_unique.information1,
18500 r_SER_unique.information2,
18501 r_SER_unique.information3 ) ;
18502 --
18503 fetch c_SER into r_SER ;
18504 --
18505 close c_SER ; */
18506 --
18507 if p_reuse_object_flag = 'Y' then
18508 if c_SER_min_max_dates%found then
18509 -- cursor to find the object
18510 open c_find_SER_in_target( l_min_esd,l_max_eed,
18511 p_target_business_group_id, nvl(l_schedd_enrt_rl_id, -999) ) ;
18512 fetch c_find_SER_in_target into l_new_value ;
18513 if c_find_SER_in_target%found then
18514 --
18515 --TEMPIK
18516 l_dt_rec_found := dt_api.check_min_max_dates
18517 (p_base_table_name => 'BEN_SCHEDD_ENRT_RL_F',
18518 p_base_key_column => 'SCHEDD_ENRT_RL_ID',
18519 p_base_key_value => l_new_value,
18520 p_from_date => l_min_esd,
18521 p_to_date => l_max_eed );
18522 if l_dt_rec_found THEN
18523 --END TEMPIK
18524 if r_SER_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
18525 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'SCHEDD_ENRT_RL_ID' then
18526 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'SCHEDD_ENRT_RL_ID' ;
18527 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_SER_unique.information1 ;
18528 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
18529 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18530 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_SER_unique.table_route_id;
18531 --
18532 -- 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) ;
18533 --
18534 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18535 end if ;
18536 --
18537 l_object_found_in_target := true ;
18538 --TEMPIK
18539 end if; -- l_dt_rec_found
18540 --END TEMPIK
18541 end if;
18542 close c_find_SER_in_target ;
18543 --
18544 end if;
18545 end if ;
18546 --
18547 close c_SER_min_max_dates ;
18548 end if; --if p_dml_operation
18549 --
18550 if not l_object_found_in_target OR l_update then
18551 --
18552 l_current_pk_id := r_SER.information1;
18553 --
18554 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
18555 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
18556 --
18557 if l_current_pk_id = l_prev_pk_id then
18558 --
18559 l_first_rec := false ;
18560 --
18561 else
18562 --
18563 l_first_rec := true ;
18564 --
18565 end if ;
18566 --
18567
18568 l_effective_date := r_SER.information2;
18569 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18570 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18571 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
18572 end if;
18573
18574 if l_first_rec and not l_update then
18575 -- Call Create routine.
18576 hr_utility.set_location(' BEN_SCHEDD_ENRT_RL_F CREATE_SCHEDD_ENROLLMENT_RL ',20);
18577 BEN_SCHEDD_ENROLLMENT_RL_API.CREATE_SCHEDD_ENROLLMENT_RL(
18578 --
18579 P_VALIDATE => false
18580 ,P_EFFECTIVE_DATE => l_effective_date
18581 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
18582 --
18583 ,P_ENRT_PERD_ID => l_ENRT_PERD_ID
18584 ,P_FORMULA_ID => l_FORMULA_ID
18585 ,P_ORDR_TO_APLY_NUM => r_SER.INFORMATION260
18586 ,P_SCHEDD_ENRT_RL_ID => l_schedd_enrt_rl_id
18587 ,P_SER_ATTRIBUTE1 => r_SER.INFORMATION111
18588 ,P_SER_ATTRIBUTE10 => r_SER.INFORMATION120
18589 ,P_SER_ATTRIBUTE11 => r_SER.INFORMATION121
18590 ,P_SER_ATTRIBUTE12 => r_SER.INFORMATION122
18591 ,P_SER_ATTRIBUTE13 => r_SER.INFORMATION123
18592 ,P_SER_ATTRIBUTE14 => r_SER.INFORMATION124
18593 ,P_SER_ATTRIBUTE15 => r_SER.INFORMATION125
18594 ,P_SER_ATTRIBUTE16 => r_SER.INFORMATION126
18595 ,P_SER_ATTRIBUTE17 => r_SER.INFORMATION127
18596 ,P_SER_ATTRIBUTE18 => r_SER.INFORMATION128
18597 ,P_SER_ATTRIBUTE19 => r_SER.INFORMATION129
18598 ,P_SER_ATTRIBUTE2 => r_SER.INFORMATION112
18599 ,P_SER_ATTRIBUTE20 => r_SER.INFORMATION130
18600 ,P_SER_ATTRIBUTE21 => r_SER.INFORMATION131
18601 ,P_SER_ATTRIBUTE22 => r_SER.INFORMATION132
18602 ,P_SER_ATTRIBUTE23 => r_SER.INFORMATION133
18603 ,P_SER_ATTRIBUTE24 => r_SER.INFORMATION134
18604 ,P_SER_ATTRIBUTE25 => r_SER.INFORMATION135
18605 ,P_SER_ATTRIBUTE26 => r_SER.INFORMATION136
18606 ,P_SER_ATTRIBUTE27 => r_SER.INFORMATION137
18607 ,P_SER_ATTRIBUTE28 => r_SER.INFORMATION138
18608 ,P_SER_ATTRIBUTE29 => r_SER.INFORMATION139
18609 ,P_SER_ATTRIBUTE3 => r_SER.INFORMATION113
18610 ,P_SER_ATTRIBUTE30 => r_SER.INFORMATION140
18611 ,P_SER_ATTRIBUTE4 => r_SER.INFORMATION114
18612 ,P_SER_ATTRIBUTE5 => r_SER.INFORMATION115
18613 ,P_SER_ATTRIBUTE6 => r_SER.INFORMATION116
18614 ,P_SER_ATTRIBUTE7 => r_SER.INFORMATION117
18615 ,P_SER_ATTRIBUTE8 => r_SER.INFORMATION118
18616 ,P_SER_ATTRIBUTE9 => r_SER.INFORMATION119
18617 ,P_SER_ATTRIBUTE_CATEGORY => r_SER.INFORMATION110
18618 --
18619 ,P_EFFECTIVE_START_DATE => l_effective_start_date
18620 ,P_EFFECTIVE_END_DATE => l_effective_end_date
18621 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
18622 );
18623 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
18624 -- Update all relevent cer records with new pk_id
18625 hr_utility.set_location('Before plsql table ',222);
18626 hr_utility.set_location('new_value id '||l_schedd_enrt_rl_id,222);
18627 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'SCHEDD_ENRT_RL_ID' ;
18628 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_SER.information1 ;
18629 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_SCHEDD_ENRT_RL_ID ;
18630 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
18631 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_SER_unique.table_route_id;
18632 hr_utility.set_location('After plsql table ',222);
18633 --
18634 -- 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 ) ;
18635 --
18636 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18637 --
18638 else
18639 --
18640 -- Call Update routine for the pk_id created in prev run .
18641 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
18642 hr_utility.set_location(' BEN_SCHEDD_ENRT_RL_F UPDATE_SCHEDD_ENROLLMENT_RL ',30);
18643 --UPD START
18644 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
18645 --
18646 if l_update then
18647 --
18648 l_datetrack_mode := r_SER.datetrack_mode ;
18649 --
18650 get_dt_modes(
18651 p_effective_date => l_process_date,
18652 p_effective_end_date => r_SER.information3,
18653 p_effective_start_date => r_SER.information2,
18654 p_dml_operation => r_SER.dml_operation,
18655 p_datetrack_mode => l_datetrack_mode );
18656 -- p_update => l_update
18657 --
18658 l_effective_date := l_process_date;
18659 l_SCHEDD_ENRT_RL_ID := r_SER.information1;
18660 l_object_version_number := r_SER.information265;
18661 --
18662 end if;
18663 --
18664 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
18665 --
18666 IF l_update OR l_dml_operation <> 'UPDATE' THEN
18667 --UPD END
18668 BEN_SCHEDD_ENROLLMENT_RL_API.UPDATE_SCHEDD_ENROLLMENT_RL(
18669 --
18670 P_VALIDATE => false
18671 ,P_EFFECTIVE_DATE => l_effective_date
18672 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
18673 --
18674 ,P_ENRT_PERD_ID => l_ENRT_PERD_ID
18675 ,P_FORMULA_ID => l_FORMULA_ID
18676 ,P_ORDR_TO_APLY_NUM => r_SER.INFORMATION260
18677 ,P_SCHEDD_ENRT_RL_ID => l_schedd_enrt_rl_id
18678 ,P_SER_ATTRIBUTE1 => r_SER.INFORMATION111
18679 ,P_SER_ATTRIBUTE10 => r_SER.INFORMATION120
18680 ,P_SER_ATTRIBUTE11 => r_SER.INFORMATION121
18681 ,P_SER_ATTRIBUTE12 => r_SER.INFORMATION122
18682 ,P_SER_ATTRIBUTE13 => r_SER.INFORMATION123
18683 ,P_SER_ATTRIBUTE14 => r_SER.INFORMATION124
18684 ,P_SER_ATTRIBUTE15 => r_SER.INFORMATION125
18685 ,P_SER_ATTRIBUTE16 => r_SER.INFORMATION126
18686 ,P_SER_ATTRIBUTE17 => r_SER.INFORMATION127
18687 ,P_SER_ATTRIBUTE18 => r_SER.INFORMATION128
18688 ,P_SER_ATTRIBUTE19 => r_SER.INFORMATION129
18689 ,P_SER_ATTRIBUTE2 => r_SER.INFORMATION112
18690 ,P_SER_ATTRIBUTE20 => r_SER.INFORMATION130
18691 ,P_SER_ATTRIBUTE21 => r_SER.INFORMATION131
18692 ,P_SER_ATTRIBUTE22 => r_SER.INFORMATION132
18693 ,P_SER_ATTRIBUTE23 => r_SER.INFORMATION133
18694 ,P_SER_ATTRIBUTE24 => r_SER.INFORMATION134
18695 ,P_SER_ATTRIBUTE25 => r_SER.INFORMATION135
18696 ,P_SER_ATTRIBUTE26 => r_SER.INFORMATION136
18697 ,P_SER_ATTRIBUTE27 => r_SER.INFORMATION137
18698 ,P_SER_ATTRIBUTE28 => r_SER.INFORMATION138
18699 ,P_SER_ATTRIBUTE29 => r_SER.INFORMATION139
18700 ,P_SER_ATTRIBUTE3 => r_SER.INFORMATION113
18701 ,P_SER_ATTRIBUTE30 => r_SER.INFORMATION140
18702 ,P_SER_ATTRIBUTE4 => r_SER.INFORMATION114
18703 ,P_SER_ATTRIBUTE5 => r_SER.INFORMATION115
18704 ,P_SER_ATTRIBUTE6 => r_SER.INFORMATION116
18705 ,P_SER_ATTRIBUTE7 => r_SER.INFORMATION117
18706 ,P_SER_ATTRIBUTE8 => r_SER.INFORMATION118
18707 ,P_SER_ATTRIBUTE9 => r_SER.INFORMATION119
18708 ,P_SER_ATTRIBUTE_CATEGORY => r_SER.INFORMATION110
18709 --
18710 ,P_EFFECTIVE_START_DATE => l_effective_start_date
18711 ,P_EFFECTIVE_END_DATE => l_effective_end_date
18712 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
18713 ,P_DATETRACK_MODE => l_datetrack_mode
18714 );
18715 --
18716 end if; -- l_update
18717 end if;
18718 --
18719 -- Delete the row if it is end dated.
18720 --
18721 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
18722 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
18723 trunc(l_max_eed) = r_SER.information3) then
18724 --
18725 BEN_SCHEDD_ENROLLMENT_RL_API.delete_SCHEDD_ENROLLMENT_RL(
18726 --
18727 p_validate => false
18728 ,p_schedd_enrt_rl_id => l_schedd_enrt_rl_id
18729 ,p_effective_start_date => l_effective_start_date
18730 ,p_effective_end_date => l_effective_end_date
18731 ,p_object_version_number => l_object_version_number
18732 ,p_effective_date => l_max_eed
18733 ,p_datetrack_mode => hr_api.g_delete
18734 --
18735 );
18736 --
18737 end if;
18738 --
18739 l_prev_pk_id := l_current_pk_id ;
18740 --
18741 end if;
18742 --
18743 end if;
18744 --
18745 end loop;
18746 --
18747 exception when others then
18748 --
18749 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'SER',r_ser.information5 );
18750 --
18751 end create_SER_rows;
18752 --
18753 ---------------------------------------------------------------
18754 ----------------------< create_LRR_rows >-----------------------
18755 ---------------------------------------------------------------
18756 --
18757 procedure create_LRR_rows
18758 (
18759 p_validate in number default 0
18760 ,p_copy_entity_txn_id in number
18761 ,p_effective_date in date
18762 ,p_prefix_suffix_text in varchar2 default null
18763 ,p_reuse_object_flag in varchar2 default null
18764 ,p_target_business_group_id in varchar2 default null
18765 ,p_prefix_suffix_cd in varchar2 default null
18766 ) is
18767 --
18768 l_FORMULA_ID number;
18769 l_LEE_RSN_ID number;
18770 cursor c_unique_LRR(l_table_alias varchar2) is
18771 select distinct cpe.information1,
18772 cpe.information2,
18773 cpe.information3,
18774 cpe.table_route_id
18775 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
18776 pqh_table_route tr
18777 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18778 and cpe.table_route_id = tr.table_route_id
18779 -- and tr.where_clause = l_BEN_LEE_RSN_RL_F
18780 and tr.table_alias = l_table_alias
18781 and cpe.number_of_copies = 1 -- ADDITION
18782 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
18783 order by information1, information2; --added for bug: 5151945
18784 --
18785 --
18786 cursor c_LRR_min_max_dates(c_table_route_id number,
18787 c_information1 number) is
18788 select
18789 min(cpe.information2) min_esd,
18790 max(cpe.information3) min_eed
18791 from ben_copy_entity_results cpe
18792 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18793 and cpe.table_route_id = c_table_route_id
18794 and cpe.information1 = c_information1 ;
18795 --
18796 cursor c_LRR(c_table_route_id number,
18797 c_information1 number,
18798 c_information2 date,
18799 c_information3 date) is
18800 select
18801 cpe.*
18802 from ben_copy_entity_results cpe
18803 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18804 and cpe.table_route_id = c_table_route_id
18805 and cpe.information1 = c_information1
18806 and cpe.information2 = c_information2
18807 and cpe.information3 = c_information3
18808 and rownum = 1 ;
18809 -- Date Track target record
18810 cursor c_find_LRR_in_target(
18811 c_effective_start_date date,
18812 c_effective_end_date date,
18813 c_business_group_id number,
18814 c_new_pk_id number) is
18815 select
18816 LRR.lee_rsn_rl_id new_value
18817 from BEN_LEE_RSN_RL_F LRR
18818 where
18819 nvl(LRR.FORMULA_ID,-999) = nvl(l_FORMULA_ID,-999) and
18820 nvl(LRR.LEE_RSN_ID,-999) = nvl(l_LEE_RSN_ID,-999) and
18821 LRR.business_group_id = c_business_group_id
18822 and LRR.lee_rsn_rl_id <> c_new_pk_id
18823 --TEMPIK
18824 and c_effective_start_date between effective_start_date
18825 and effective_end_date ;
18826 --END TEMPIK
18827 /*TEMPIK
18828 and exists ( select null
18829 from BEN_LEE_RSN_RL_F LRR1
18830 where
18831 nvl(LRR1.FORMULA_ID,-999) = nvl(l_FORMULA_ID,-999) and
18832 nvl(LRR1.LEE_RSN_ID,-999) = nvl(l_LEE_RSN_ID,-999) and
18833 LRR1.business_group_id = c_business_group_id
18834 and LRR1.effective_start_date <= c_effective_start_date )
18835 and exists ( select null
18836 from BEN_LEE_RSN_RL_F LRR2
18837 where
18838 nvl(LRR2.FORMULA_ID,-999) = nvl(l_FORMULA_ID,-999) and
18839 nvl(LRR2.LEE_RSN_ID,-999) = nvl(l_LEE_RSN_ID,-999) and
18840 LRR2.business_group_id = c_business_group_id
18841 and LRR2.effective_end_date >= c_effective_end_date )
18842 ;
18843 */
18844 --
18845 --UPD START
18846 --
18847 l_update boolean := false ;
18848 l_datetrack_mode varchar2(80) := hr_api.g_update;
18849 l_process_date date;
18850 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
18851 --
18852 --UPD END
18853 l_current_pk_id number := null ;
18854 l_prev_pk_id number := null ;
18855 l_first_rec boolean := true ;
18856 r_LRR c_LRR%rowtype;
18857 l_lee_rsn_rl_id number ;
18858 l_object_version_number number ;
18859 l_effective_start_date date ;
18860 l_effective_end_date date ;
18861 l_prefix pqh_copy_entity_attribs.information1%type := null;
18862 l_suffix pqh_copy_entity_attribs.information1%type := null;
18863 l_new_value number(15);
18864 l_object_found_in_target boolean := false ;
18865 l_min_esd date;
18866 l_max_eed date;
18867 l_effective_date date;
18868 --TEMPIK
18869 l_dt_rec_found boolean ;
18870 --END TEMPIK
18871 --
18872 begin
18873 -- Initialization
18874 l_object_found_in_target := false ;
18875 -- End Initialization
18876 -- Derive the prefix - sufix
18877 if p_prefix_suffix_cd = 'PREFIX' then
18878 l_prefix := p_prefix_suffix_text ;
18879 elsif p_prefix_suffix_cd = 'SUFFIX' then
18880 l_suffix := p_prefix_suffix_text ;
18881 else
18882 l_prefix := null ;
18883 l_suffix := null ;
18884 end if ;
18885 -- End Prefix Sufix derivation
18886 for r_LRR_unique in c_unique_LRR('LRR') loop
18887
18888 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
18889 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18890 r_LRR_unique.information3 >=
18891 ben_pd_copy_to_ben_one.g_copy_effective_date)
18892 ) then
18893 --
18894 hr_utility.set_location(' r_LRR_unique.table_route_id '||r_LRR_unique.table_route_id,10);
18895 hr_utility.set_location(' r_LRR_unique.information1 '||r_LRR_unique.information1,10);
18896 hr_utility.set_location( 'r_LRR_unique.information2 '||r_LRR_unique.information2,10);
18897 hr_utility.set_location( 'r_LRR_unique.information3 '||r_LRR_unique.information3,10);
18898 -- If reuse objects flag is 'Y' then check for the object in the target business group
18899 -- if found insert the record into PLSql table and exit the loop else try create the
18900 -- object in the target business group
18901 --
18902 l_object_found_in_target := false ;
18903 --UPD START
18904 open c_LRR(r_LRR_unique.table_route_id,
18905 r_LRR_unique.information1,
18906 r_LRR_unique.information2,
18907 r_LRR_unique.information3 ) ;
18908 --
18909 fetch c_LRR into r_LRR ;
18910 --
18911 close c_LRR ;
18912 l_dml_operation:= r_LRR_unique.dml_operation ;
18913 l_FORMULA_ID := get_fk('FORMULA_ID', r_LRR.information251,l_dml_operation );
18914 l_LEE_RSN_ID := get_fk('LEE_RSN_ID', r_LRR.information234,l_dml_operation );
18915 l_update := false;
18916 l_process_date := p_effective_date;
18917 --
18918 if l_dml_operation = 'UPDATE' then
18919 --
18920 l_object_found_in_target := TRUE;
18921 --
18922 if l_process_date between r_LRR_unique.information2 and r_LRR_unique.information3 then
18923 l_update := true;
18924 if r_LRR_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
18925 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LEE_RSN_RL_ID'
18926 then
18927 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LEE_RSN_RL_ID' ;
18928 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LRR_unique.information1 ;
18929 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LRR_unique.information1 ;
18930 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18931 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LRR_unique.table_route_id;
18932 --
18933 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
18934 --
18935 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18936 --
18937 --DOUBT log_data('LRR',l_new_value,l_prefix || r_LRR_unique.name|| l_suffix,'REUSED');
18938 --
18939 end if ;
18940 hr_utility.set_location( 'found record for update',10);
18941 --
18942 else
18943 --
18944 l_update := false;
18945 --
18946 end if;
18947 else
18948 --
18949 --UPD END
18950 l_min_esd := null ;
18951 l_max_eed := null ;
18952 open c_LRR_min_max_dates(r_LRR_unique.table_route_id, r_LRR_unique.information1 ) ;
18953 fetch c_LRR_min_max_dates into l_min_esd,l_max_eed ;
18954 --
18955
18956 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18957 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18958 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
18959 end if;
18960 l_min_esd := greatest(l_min_esd,r_LRR_unique.information2);
18961 /* open c_LRR(r_LRR_unique.table_route_id,
18962 r_LRR_unique.information1,
18963 r_LRR_unique.information2,
18964 r_LRR_unique.information3 ) ;
18965 --
18966 fetch c_LRR into r_LRR ;
18967 --
18968 close c_LRR ; */
18969 --
18970 if p_reuse_object_flag = 'Y' then
18971 if c_LRR_min_max_dates%found then
18972 -- cursor to find the object
18973 open c_find_LRR_in_target( l_min_esd,l_max_eed,
18974 p_target_business_group_id, nvl(l_lee_rsn_rl_id, -999) ) ;
18975 fetch c_find_LRR_in_target into l_new_value ;
18976 if c_find_LRR_in_target%found then
18977 --
18978 --TEMPIK
18979 l_dt_rec_found := dt_api.check_min_max_dates
18980 (p_base_table_name => 'BEN_LEE_RSN_RL_F',
18981 p_base_key_column => 'LEE_RSN_RL_ID',
18982 p_base_key_value => l_new_value,
18983 p_from_date => l_min_esd,
18984 p_to_date => l_max_eed );
18985 if l_dt_rec_found THEN
18986 --END TEMPIK
18987 if r_LRR_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
18988 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LEE_RSN_RL_ID' then
18989 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LEE_RSN_RL_ID' ;
18990 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LRR_unique.information1 ;
18991 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
18992 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18993 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LRR_unique.table_route_id;
18994 --
18995 -- 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) ;
18996 --
18997 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18998 end if ;
18999 --
19000 l_object_found_in_target := true ;
19001 --TEMPIK
19002 end if; -- l_dt_rec_found
19003 --END TEMPIK
19004 end if;
19005 close c_find_LRR_in_target ;
19006 --
19007 end if;
19008 end if ;
19009 --
19010 close c_LRR_min_max_dates ;
19011 end if; --if p_dml_operation
19012 --
19013 if not l_object_found_in_target OR l_update then
19014 --
19015 l_current_pk_id := r_LRR.information1;
19016 --
19017 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
19018 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
19019 --
19020 if l_current_pk_id = l_prev_pk_id then
19021 --
19022 l_first_rec := false ;
19023 --
19024 else
19025 --
19026 l_first_rec := true ;
19027 --
19028 end if ;
19029 --
19030
19031 l_effective_date := r_LRR.information2;
19032 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19033 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19034 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
19035 end if;
19036
19037 if l_first_rec and not l_update then
19038 -- Call Create routine.
19039 hr_utility.set_location(' BEN_LEE_RSN_RL_F CREATE_LEE_RSN_RL ',20);
19040 BEN_LEE_RSN_RL_API.CREATE_LEE_RSN_RL(
19041 --
19042 P_VALIDATE => false
19043 ,P_EFFECTIVE_DATE => l_effective_date
19044 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19045 --
19046 ,P_FORMULA_ID => l_FORMULA_ID
19047 ,P_LEE_RSN_ID => l_LEE_RSN_ID
19048 ,P_LEE_RSN_RL_ID => l_lee_rsn_rl_id
19049 ,P_LRR_ATTRIBUTE1 => r_LRR.INFORMATION111
19050 ,P_LRR_ATTRIBUTE10 => r_LRR.INFORMATION120
19051 ,P_LRR_ATTRIBUTE11 => r_LRR.INFORMATION121
19052 ,P_LRR_ATTRIBUTE12 => r_LRR.INFORMATION122
19053 ,P_LRR_ATTRIBUTE13 => r_LRR.INFORMATION123
19054 ,P_LRR_ATTRIBUTE14 => r_LRR.INFORMATION124
19055 ,P_LRR_ATTRIBUTE15 => r_LRR.INFORMATION125
19056 ,P_LRR_ATTRIBUTE16 => r_LRR.INFORMATION126
19057 ,P_LRR_ATTRIBUTE17 => r_LRR.INFORMATION127
19058 ,P_LRR_ATTRIBUTE18 => r_LRR.INFORMATION128
19059 ,P_LRR_ATTRIBUTE19 => r_LRR.INFORMATION129
19060 ,P_LRR_ATTRIBUTE2 => r_LRR.INFORMATION112
19061 ,P_LRR_ATTRIBUTE20 => r_LRR.INFORMATION130
19062 ,P_LRR_ATTRIBUTE21 => r_LRR.INFORMATION131
19063 ,P_LRR_ATTRIBUTE22 => r_LRR.INFORMATION132
19064 ,P_LRR_ATTRIBUTE23 => r_LRR.INFORMATION133
19065 ,P_LRR_ATTRIBUTE24 => r_LRR.INFORMATION134
19066 ,P_LRR_ATTRIBUTE25 => r_LRR.INFORMATION135
19067 ,P_LRR_ATTRIBUTE26 => r_LRR.INFORMATION136
19068 ,P_LRR_ATTRIBUTE27 => r_LRR.INFORMATION137
19069 ,P_LRR_ATTRIBUTE28 => r_LRR.INFORMATION138
19070 ,P_LRR_ATTRIBUTE29 => r_LRR.INFORMATION139
19071 ,P_LRR_ATTRIBUTE3 => r_LRR.INFORMATION113
19072 ,P_LRR_ATTRIBUTE30 => r_LRR.INFORMATION140
19073 ,P_LRR_ATTRIBUTE4 => r_LRR.INFORMATION114
19074 ,P_LRR_ATTRIBUTE5 => r_LRR.INFORMATION115
19075 ,P_LRR_ATTRIBUTE6 => r_LRR.INFORMATION116
19076 ,P_LRR_ATTRIBUTE7 => r_LRR.INFORMATION117
19077 ,P_LRR_ATTRIBUTE8 => r_LRR.INFORMATION118
19078 ,P_LRR_ATTRIBUTE9 => r_LRR.INFORMATION119
19079 ,P_LRR_ATTRIBUTE_CATEGORY => r_LRR.INFORMATION110
19080 ,P_ORDR_TO_APLY_NUM => r_LRR.INFORMATION260
19081 --
19082 ,P_EFFECTIVE_START_DATE => l_effective_start_date
19083 ,P_EFFECTIVE_END_DATE => l_effective_end_date
19084 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
19085 );
19086 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
19087 -- Update all relevent cer records with new pk_id
19088 hr_utility.set_location('Before plsql table ',222);
19089 hr_utility.set_location('new_value id '||l_lee_rsn_rl_id,222);
19090 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LEE_RSN_RL_ID' ;
19091 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LRR.information1 ;
19092 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LEE_RSN_RL_ID ;
19093 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
19094 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LRR_unique.table_route_id;
19095 hr_utility.set_location('After plsql table ',222);
19096 --
19097 -- 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 ) ;
19098 --
19099 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19100 --
19101 else
19102 --
19103 -- Call Update routine for the pk_id created in prev run .
19104 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
19105 hr_utility.set_location(' BEN_LEE_RSN_RL_F UPDATE_LEE_RSN_RL ',30);
19106 --UPD START
19107 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
19108 --
19109 if l_update then
19110 --
19111 l_datetrack_mode := r_LRR.datetrack_mode ;
19112 --
19113 get_dt_modes(
19114 p_effective_date => l_process_date,
19115 p_effective_end_date => r_LRR.information3,
19116 p_effective_start_date => r_LRR.information2,
19117 p_dml_operation => r_LRR.dml_operation,
19118 p_datetrack_mode => l_datetrack_mode );
19119 -- p_update => l_update
19120 --
19121 l_effective_date := l_process_date;
19122 l_LEE_RSN_RL_ID := r_LRR.information1;
19123 l_object_version_number := r_LRR.information265;
19124 --
19125 end if;
19126 --
19127 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
19128 --
19129 IF l_update OR l_dml_operation <> 'UPDATE' THEN
19130 --UPD END
19131 BEN_LEE_RSN_RL_API.UPDATE_LEE_RSN_RL(
19132 --
19133 P_VALIDATE => false
19134 ,P_EFFECTIVE_DATE => l_effective_date
19135 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19136 --
19137 ,P_FORMULA_ID => l_FORMULA_ID
19138 ,P_LEE_RSN_ID => l_LEE_RSN_ID
19139 ,P_LEE_RSN_RL_ID => l_lee_rsn_rl_id
19140 ,P_LRR_ATTRIBUTE1 => r_LRR.INFORMATION111
19141 ,P_LRR_ATTRIBUTE10 => r_LRR.INFORMATION120
19142 ,P_LRR_ATTRIBUTE11 => r_LRR.INFORMATION121
19143 ,P_LRR_ATTRIBUTE12 => r_LRR.INFORMATION122
19144 ,P_LRR_ATTRIBUTE13 => r_LRR.INFORMATION123
19145 ,P_LRR_ATTRIBUTE14 => r_LRR.INFORMATION124
19146 ,P_LRR_ATTRIBUTE15 => r_LRR.INFORMATION125
19147 ,P_LRR_ATTRIBUTE16 => r_LRR.INFORMATION126
19148 ,P_LRR_ATTRIBUTE17 => r_LRR.INFORMATION127
19149 ,P_LRR_ATTRIBUTE18 => r_LRR.INFORMATION128
19150 ,P_LRR_ATTRIBUTE19 => r_LRR.INFORMATION129
19151 ,P_LRR_ATTRIBUTE2 => r_LRR.INFORMATION112
19152 ,P_LRR_ATTRIBUTE20 => r_LRR.INFORMATION130
19153 ,P_LRR_ATTRIBUTE21 => r_LRR.INFORMATION131
19154 ,P_LRR_ATTRIBUTE22 => r_LRR.INFORMATION132
19155 ,P_LRR_ATTRIBUTE23 => r_LRR.INFORMATION133
19156 ,P_LRR_ATTRIBUTE24 => r_LRR.INFORMATION134
19157 ,P_LRR_ATTRIBUTE25 => r_LRR.INFORMATION135
19158 ,P_LRR_ATTRIBUTE26 => r_LRR.INFORMATION136
19159 ,P_LRR_ATTRIBUTE27 => r_LRR.INFORMATION137
19160 ,P_LRR_ATTRIBUTE28 => r_LRR.INFORMATION138
19161 ,P_LRR_ATTRIBUTE29 => r_LRR.INFORMATION139
19162 ,P_LRR_ATTRIBUTE3 => r_LRR.INFORMATION113
19163 ,P_LRR_ATTRIBUTE30 => r_LRR.INFORMATION140
19164 ,P_LRR_ATTRIBUTE4 => r_LRR.INFORMATION114
19165 ,P_LRR_ATTRIBUTE5 => r_LRR.INFORMATION115
19166 ,P_LRR_ATTRIBUTE6 => r_LRR.INFORMATION116
19167 ,P_LRR_ATTRIBUTE7 => r_LRR.INFORMATION117
19168 ,P_LRR_ATTRIBUTE8 => r_LRR.INFORMATION118
19169 ,P_LRR_ATTRIBUTE9 => r_LRR.INFORMATION119
19170 ,P_LRR_ATTRIBUTE_CATEGORY => r_LRR.INFORMATION110
19171 ,P_ORDR_TO_APLY_NUM => r_LRR.INFORMATION260
19172 --
19173 ,P_EFFECTIVE_START_DATE => l_effective_start_date
19174 ,P_EFFECTIVE_END_DATE => l_effective_end_date
19175 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
19176 ,P_DATETRACK_MODE => l_datetrack_mode
19177 );
19178 --
19179 end if; -- l_update
19180 end if;
19181 --
19182 -- Delete the row if it is end dated.
19183 --
19184 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
19185 trunc(l_max_eed) = r_LRR.information3) then
19186 --
19187 BEN_LEE_RSN_RL_API.delete_LEE_RSN_RL(
19188 --
19189 p_validate => false
19190 ,p_lee_rsn_rl_id => l_lee_rsn_rl_id
19191 ,p_effective_start_date => l_effective_start_date
19192 ,p_effective_end_date => l_effective_end_date
19193 ,p_object_version_number => l_object_version_number
19194 ,p_effective_date => l_max_eed
19195 ,p_datetrack_mode => hr_api.g_delete
19196 --
19197 );
19198 --
19199 end if;
19200 --
19201 l_prev_pk_id := l_current_pk_id ;
19202 --
19203 end if;
19204 --
19205 end if;
19206 --
19207 end loop;
19208 --
19209 exception when others then
19210 --
19211 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LRR',r_lrr.information5 );
19212 --
19213 end create_LRR_rows;
19214
19215 ---------------------------------------------------------------
19216 ----------------------< create_ADE_rows >-----------------------
19217 ---------------------------------------------------------------
19218 --
19219 procedure create_ADE_rows
19220 (
19221 p_validate in number default 0
19222 ,p_copy_entity_txn_id in number
19223 ,p_effective_date in date
19224 ,p_prefix_suffix_text in varchar2 default null
19225 ,p_reuse_object_flag in varchar2 default null
19226 ,p_target_business_group_id in varchar2 default null
19227 ,p_prefix_suffix_cd in varchar2 default null
19228 ) is
19229 --
19230 l_APLD_DPNT_CVG_ELIG_RL number;
19231 l_DPNT_CVG_ELIGY_PRFL_ID number;
19232 l_PGM_ID number;
19233 l_PL_ID number;
19234 l_PTIP_ID number;
19235 cursor c_unique_ADE(l_table_alias varchar2) is
19236 select distinct cpe.information1,
19237 cpe.information2,
19238 cpe.information3,
19239 cpe.table_route_id
19240 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
19241 pqh_table_route tr
19242 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19243 and cpe.table_route_id = tr.table_route_id
19244 -- and tr.where_clause = l_APLD_DPNT_CVG_ELIG_PRFL_F
19245 and tr.table_alias = l_table_alias
19246 and cpe.number_of_copies = 1 -- ADDITION
19247 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
19248 order by information1, information2; --added for bug: 5151945
19249 --
19250 --
19251 cursor c_ADE_min_max_dates(c_table_route_id number,
19252 c_information1 number) is
19253 select
19254 min(cpe.information2) min_esd,
19255 max(cpe.information3) min_eed
19256 from ben_copy_entity_results cpe
19257 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19258 and cpe.table_route_id = c_table_route_id
19259 and cpe.information1 = c_information1 ;
19260 --
19261 cursor c_ADE(c_table_route_id number,
19262 c_information1 number,
19263 c_information2 date,
19264 c_information3 date) is
19265 select
19266 cpe.*
19267 from ben_copy_entity_results cpe
19268 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19269 and cpe.table_route_id = c_table_route_id
19270 and cpe.information1 = c_information1
19271 and cpe.information2 = c_information2
19272 and cpe.information3 = c_information3
19273 and rownum = 1 ;
19274 -- Date Track target record
19275 cursor c_find_ADE_in_target(
19276 c_effective_start_date date,
19277 c_effective_end_date date,
19278 c_business_group_id number,
19279 c_new_pk_id number) is
19280 select
19281 ADE.apld_dpnt_cvg_elig_prfl_id new_value
19282 from BEN_APLD_DPNT_CVG_ELIG_PRFL_F ADE
19283 where
19284 ADE.DPNT_CVG_ELIGY_PRFL_ID = l_DPNT_CVG_ELIGY_PRFL_ID and
19285 nvl(ADE.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
19286 nvl(ADE.PL_ID,-999) = nvl(l_PL_ID,-999) and
19287 nvl(ADE.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
19288 ADE.business_group_id = c_business_group_id
19289 and ADE.apld_dpnt_cvg_elig_prfl_id <> c_new_pk_id
19290 --TEMPIK
19291 and c_effective_start_date between effective_start_date
19292 and effective_end_date ;
19293 --END TEMPIK
19294 /*TEMPIK
19295 and exists ( select null
19296 from BEN_APLD_DPNT_CVG_ELIG_PRFL_F ADE1
19297 where
19298 ADE1.DPNT_CVG_ELIGY_PRFL_ID = l_DPNT_CVG_ELIGY_PRFL_ID and
19299 nvl(ADE1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
19300 nvl(ADE1.PL_ID,-999) = nvl(l_PL_ID,-999) and
19301 nvl(ADE1.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
19302 ADE1.business_group_id = c_business_group_id
19303 and ADE1.effective_start_date <= c_effective_start_date )
19304 and exists ( select null
19305 from BEN_APLD_DPNT_CVG_ELIG_PRFL_F ADE2
19306 where
19307 ADE2.DPNT_CVG_ELIGY_PRFL_ID = l_DPNT_CVG_ELIGY_PRFL_ID and
19308 nvl(ADE2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
19309 nvl(ADE2.PL_ID,-999) = nvl(l_PL_ID,-999) and
19310 nvl(ADE2.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
19311 ADE2.business_group_id = c_business_group_id
19312 and ADE2.effective_end_date >= c_effective_end_date )
19313 ;
19314 */
19315 --
19316 --UPD START
19317 --
19318 l_update boolean := false ;
19319 l_datetrack_mode varchar2(80) := hr_api.g_update;
19320 l_process_date date;
19321 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
19322 --
19323 --UPD END
19324 l_current_pk_id number := null ;
19325 l_prev_pk_id number := null ;
19326 l_first_rec boolean := true ;
19327 r_ADE c_ADE%rowtype;
19328 l_apld_dpnt_cvg_elig_prfl_id number ;
19329 l_object_version_number number ;
19330 l_effective_start_date date ;
19331 l_effective_end_date date ;
19332 l_prefix pqh_copy_entity_attribs.information1%type := null;
19333 l_suffix pqh_copy_entity_attribs.information1%type := null;
19334 l_new_value number(15);
19335 l_object_found_in_target boolean := false ;
19336 l_min_esd date;
19337 l_max_eed date;
19338 l_effective_date date;
19339 --TEMPIK
19340 l_dt_rec_found boolean ;
19341 --END TEMPIK
19342 --
19343 begin
19344 -- Initialization
19345 l_object_found_in_target := false ;
19346 -- End Initialization
19347 -- Derive the prefix - sufix
19348 if p_prefix_suffix_cd = 'PREFIX' then
19349 l_prefix := p_prefix_suffix_text ;
19350 elsif p_prefix_suffix_cd = 'SUFFIX' then
19351 l_suffix := p_prefix_suffix_text ;
19352 else
19353 l_prefix := null ;
19354 l_suffix := null ;
19355 end if ;
19356 -- End Prefix Sufix derivation
19357 for r_ADE_unique in c_unique_ADE('ADE') loop
19358
19359 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
19360 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19361 r_ADE_unique.information3 >=
19362 ben_pd_copy_to_ben_one.g_copy_effective_date)
19363 ) then
19364 --
19365 hr_utility.set_location(' r_ADE_unique.table_route_id '||r_ADE_unique.table_route_id,10);
19366 hr_utility.set_location(' r_ADE_unique.information1 '||r_ADE_unique.information1,10);
19367 hr_utility.set_location( 'r_ADE_unique.information2 '||r_ADE_unique.information2,10);
19368 hr_utility.set_location( 'r_ADE_unique.information3 '||r_ADE_unique.information3,10);
19369 -- If reuse objects flag is 'Y' then check for the object in the target business group
19370 -- if found insert the record into PLSql table and exit the loop else try create the
19371 -- object in the target business group
19372 --
19373 l_object_found_in_target := false ;
19374 --UPD START
19375 open c_ADE(r_ADE_unique.table_route_id,
19376 r_ADE_unique.information1,
19377 r_ADE_unique.information2,
19378 r_ADE_unique.information3 ) ;
19379 --
19380 fetch c_ADE into r_ADE ;
19381 --
19382 close c_ADE ;
19383 l_dml_operation:= r_ADE_unique.dml_operation ;
19384 l_APLD_DPNT_CVG_ELIG_RL := get_fk('FORMULA_ID', r_ADE.information263,l_dml_operation );
19385 l_DPNT_CVG_ELIGY_PRFL_ID := get_fk('DPNT_CVG_ELIGY_PRFL_ID', r_ADE.information255,l_dml_operation );
19386 l_PGM_ID := get_fk('PGM_ID', r_ADE.information260,l_dml_operation );
19387 l_PL_ID := get_fk('PL_ID', r_ADE.information261,l_dml_operation );
19388 l_PTIP_ID := get_fk('PTIP_ID', r_ADE.information259,l_dml_operation );
19389 l_update := false;
19390 l_process_date := p_effective_date;
19391 --
19392 if l_dml_operation = 'UPDATE' then
19393 --
19394 l_object_found_in_target := TRUE;
19395 --
19396 if l_process_date between r_ADE_unique.information2 and r_ADE_unique.information3 then
19397 l_update := true;
19398 if r_ADE_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
19399 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'APLD_DPNT_CVG_ELIG_PRFL_ID'
19400 then
19401 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'APLD_DPNT_CVG_ELIG_PRFL_ID' ;
19402 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ADE_unique.information1 ;
19403 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ADE_unique.information1 ;
19404 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19405 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ADE_unique.table_route_id;
19406 --
19407 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
19408 --
19409 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19410 --
19411 --DOUBT log_data('ADE',l_new_value,l_prefix || r_ADE_unique.name|| l_suffix,'REUSED');
19412 --
19413 end if ;
19414 hr_utility.set_location( 'found record for update',10);
19415 --
19416 else
19417 --
19418 l_update := false;
19419 --
19420 end if;
19421 else
19422 --
19423 --UPD END
19424 l_min_esd := null ;
19425 l_max_eed := null ;
19426 open c_ADE_min_max_dates(r_ADE_unique.table_route_id, r_ADE_unique.information1 ) ;
19427 fetch c_ADE_min_max_dates into l_min_esd,l_max_eed ;
19428 --
19429
19430 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19431 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19432 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
19433 end if;
19434 l_min_esd := greatest(l_min_esd,r_ADE_unique.information2);
19435 /* open c_ADE(r_ADE_unique.table_route_id,
19436 r_ADE_unique.information1,
19437 r_ADE_unique.information2,
19438 r_ADE_unique.information3 ) ;
19439 --
19440 fetch c_ADE into r_ADE ;
19441 --
19442 close c_ADE ; */
19443 --
19444 if p_reuse_object_flag = 'Y' then
19445 if c_ADE_min_max_dates%found then
19446 -- cursor to find the object
19447 open c_find_ADE_in_target( l_min_esd,l_max_eed,
19448 p_target_business_group_id, nvl(l_apld_dpnt_cvg_elig_prfl_id, -999) ) ;
19449 fetch c_find_ADE_in_target into l_new_value ;
19450 if c_find_ADE_in_target%found then
19451 --
19452 --TEMPIK
19453 l_dt_rec_found := dt_api.check_min_max_dates
19454 (p_base_table_name => 'BEN_APLD_DPNT_CVG_ELIG_PRFL_F',
19455 p_base_key_column => 'APLD_DPNT_CVG_ELIG_PRFL_ID',
19456 p_base_key_value => l_new_value,
19457 p_from_date => l_min_esd,
19458 p_to_date => l_max_eed );
19459 if l_dt_rec_found THEN
19460 --END TEMPIK
19461 if r_ADE_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
19462 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'APLD_DPNT_CVG_ELIG_PRFL_ID' then
19463 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'APLD_DPNT_CVG_ELIG_PRFL_ID' ;
19464 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ADE_unique.information1 ;
19465 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
19466 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19467 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ADE_unique.table_route_id;
19468 --
19469 -- 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) ;
19470 --
19471 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19472 end if ;
19473 --
19474 l_object_found_in_target := true ;
19475 --TEMPIK
19476 end if; -- l_dt_rec_found
19477 --END TEMPIK
19478 end if;
19479 close c_find_ADE_in_target ;
19480 --
19481 end if;
19482 end if ;
19483 --
19484 close c_ADE_min_max_dates ;
19485 end if; --if p_dml_operation
19486 --
19487 if not l_object_found_in_target OR l_update then
19488 --
19489 l_current_pk_id := r_ADE.information1;
19490 --
19491 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
19492 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
19493 --
19494 if l_current_pk_id = l_prev_pk_id then
19495 --
19496 l_first_rec := false ;
19497 --
19498 else
19499 --
19500 l_first_rec := true ;
19501 --
19502 end if ;
19503 --
19504
19505 l_effective_date := r_ADE.information2;
19506 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19507 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19508 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
19509 end if;
19510
19511 if l_first_rec and not l_update then
19512 -- Call Create routine.
19513 hr_utility.set_location(' BEN_APLD_DPNT_CVG_ELIG_PRFL_F CREATE_APLD_DPNT_CVG_PRFL ',20);
19514 BEN_APLD_DPNT_CVG_PRFL_API.CREATE_APLD_DPNT_CVG_PRFL(
19515 --
19516 P_VALIDATE => false
19517 ,P_EFFECTIVE_DATE => l_effective_date
19518 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19519 --
19520 ,P_ADE_ATTRIBUTE1 => r_ADE.INFORMATION111
19521 ,P_ADE_ATTRIBUTE10 => r_ADE.INFORMATION120
19522 ,P_ADE_ATTRIBUTE11 => r_ADE.INFORMATION121
19523 ,P_ADE_ATTRIBUTE12 => r_ADE.INFORMATION122
19524 ,P_ADE_ATTRIBUTE13 => r_ADE.INFORMATION123
19525 ,P_ADE_ATTRIBUTE14 => r_ADE.INFORMATION124
19526 ,P_ADE_ATTRIBUTE15 => r_ADE.INFORMATION125
19527 ,P_ADE_ATTRIBUTE16 => r_ADE.INFORMATION126
19528 ,P_ADE_ATTRIBUTE17 => r_ADE.INFORMATION127
19529 ,P_ADE_ATTRIBUTE18 => r_ADE.INFORMATION128
19530 ,P_ADE_ATTRIBUTE19 => r_ADE.INFORMATION129
19531 ,P_ADE_ATTRIBUTE2 => r_ADE.INFORMATION112
19532 ,P_ADE_ATTRIBUTE20 => r_ADE.INFORMATION130
19533 ,P_ADE_ATTRIBUTE21 => r_ADE.INFORMATION131
19534 ,P_ADE_ATTRIBUTE22 => r_ADE.INFORMATION132
19535 ,P_ADE_ATTRIBUTE23 => r_ADE.INFORMATION133
19536 ,P_ADE_ATTRIBUTE24 => r_ADE.INFORMATION134
19537 ,P_ADE_ATTRIBUTE25 => r_ADE.INFORMATION135
19538 ,P_ADE_ATTRIBUTE26 => r_ADE.INFORMATION136
19539 ,P_ADE_ATTRIBUTE27 => r_ADE.INFORMATION137
19540 ,P_ADE_ATTRIBUTE28 => r_ADE.INFORMATION138
19541 ,P_ADE_ATTRIBUTE29 => r_ADE.INFORMATION139
19542 ,P_ADE_ATTRIBUTE3 => r_ADE.INFORMATION113
19543 ,P_ADE_ATTRIBUTE30 => r_ADE.INFORMATION140
19544 ,P_ADE_ATTRIBUTE4 => r_ADE.INFORMATION114
19545 ,P_ADE_ATTRIBUTE5 => r_ADE.INFORMATION115
19546 ,P_ADE_ATTRIBUTE6 => r_ADE.INFORMATION116
19547 ,P_ADE_ATTRIBUTE7 => r_ADE.INFORMATION117
19548 ,P_ADE_ATTRIBUTE8 => r_ADE.INFORMATION118
19549 ,P_ADE_ATTRIBUTE9 => r_ADE.INFORMATION119
19550 ,P_ADE_ATTRIBUTE_CATEGORY => r_ADE.INFORMATION110
19551 ,P_APLD_DPNT_CVG_ELIG_PRFL_ID => l_apld_dpnt_cvg_elig_prfl_id
19552 ,P_APLD_DPNT_CVG_ELIG_RL => l_APLD_DPNT_CVG_ELIG_RL
19553 ,P_DPNT_CVG_ELIGY_PRFL_ID => l_DPNT_CVG_ELIGY_PRFL_ID
19554 ,P_MNDTRY_FLAG => r_ADE.INFORMATION11
19555 ,P_PGM_ID => l_PGM_ID
19556 ,P_PL_ID => l_PL_ID
19557 ,P_PTIP_ID => l_PTIP_ID
19558 --
19559 ,P_EFFECTIVE_START_DATE => l_effective_start_date
19560 ,P_EFFECTIVE_END_DATE => l_effective_end_date
19561 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
19562 );
19563 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
19564 -- Update all relevent cer records with new pk_id
19565 hr_utility.set_location('Before plsql table ',222);
19566 hr_utility.set_location('new_value id '||l_apld_dpnt_cvg_elig_prfl_id,222);
19567 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'APLD_DPNT_CVG_ELIG_PRFL_ID' ;
19568 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ADE.information1 ;
19569 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_APLD_DPNT_CVG_ELIG_PRFL_ID ;
19570 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
19571 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ADE_unique.table_route_id;
19572 hr_utility.set_location('After plsql table ',222);
19573 --
19574 -- 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 ) ;
19575 --
19576 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19577 --
19578 else
19579 --
19580 -- Call Update routine for the pk_id created in prev run .
19581 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
19582 hr_utility.set_location(' BEN_APLD_DPNT_CVG_ELIG_PRFL_F UPDATE_APLD_DPNT_CVG_PRFL ',30);
19583 --UPD START
19584 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
19585 --
19586 if l_update then
19587 --
19588 l_datetrack_mode := r_ADE.datetrack_mode ;
19589 --
19590 get_dt_modes(
19591 p_effective_date => l_process_date,
19592 p_effective_end_date => r_ADE.information3,
19593 p_effective_start_date => r_ADE.information2,
19594 p_dml_operation => r_ADE.dml_operation,
19595 p_datetrack_mode => l_datetrack_mode );
19596 -- p_update => l_update
19597 --
19598 l_effective_date := l_process_date;
19599 l_APLD_DPNT_CVG_ELIG_PRFL_ID := r_ADE.information1;
19600 l_object_version_number := r_ADE.information265;
19601 --
19602 end if;
19603 --
19604 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
19605 --
19606 IF l_update OR l_dml_operation <> 'UPDATE' THEN
19607 --UPD END
19608 BEN_APLD_DPNT_CVG_PRFL_API.UPDATE_APLD_DPNT_CVG_PRFL(
19609 --
19610 P_VALIDATE => false
19611 ,P_EFFECTIVE_DATE => l_effective_date
19612 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19613 --
19614 ,P_ADE_ATTRIBUTE1 => r_ADE.INFORMATION111
19615 ,P_ADE_ATTRIBUTE10 => r_ADE.INFORMATION120
19616 ,P_ADE_ATTRIBUTE11 => r_ADE.INFORMATION121
19617 ,P_ADE_ATTRIBUTE12 => r_ADE.INFORMATION122
19618 ,P_ADE_ATTRIBUTE13 => r_ADE.INFORMATION123
19619 ,P_ADE_ATTRIBUTE14 => r_ADE.INFORMATION124
19620 ,P_ADE_ATTRIBUTE15 => r_ADE.INFORMATION125
19621 ,P_ADE_ATTRIBUTE16 => r_ADE.INFORMATION126
19622 ,P_ADE_ATTRIBUTE17 => r_ADE.INFORMATION127
19623 ,P_ADE_ATTRIBUTE18 => r_ADE.INFORMATION128
19624 ,P_ADE_ATTRIBUTE19 => r_ADE.INFORMATION129
19625 ,P_ADE_ATTRIBUTE2 => r_ADE.INFORMATION112
19626 ,P_ADE_ATTRIBUTE20 => r_ADE.INFORMATION130
19627 ,P_ADE_ATTRIBUTE21 => r_ADE.INFORMATION131
19628 ,P_ADE_ATTRIBUTE22 => r_ADE.INFORMATION132
19629 ,P_ADE_ATTRIBUTE23 => r_ADE.INFORMATION133
19630 ,P_ADE_ATTRIBUTE24 => r_ADE.INFORMATION134
19631 ,P_ADE_ATTRIBUTE25 => r_ADE.INFORMATION135
19632 ,P_ADE_ATTRIBUTE26 => r_ADE.INFORMATION136
19633 ,P_ADE_ATTRIBUTE27 => r_ADE.INFORMATION137
19634 ,P_ADE_ATTRIBUTE28 => r_ADE.INFORMATION138
19635 ,P_ADE_ATTRIBUTE29 => r_ADE.INFORMATION139
19636 ,P_ADE_ATTRIBUTE3 => r_ADE.INFORMATION113
19637 ,P_ADE_ATTRIBUTE30 => r_ADE.INFORMATION140
19638 ,P_ADE_ATTRIBUTE4 => r_ADE.INFORMATION114
19639 ,P_ADE_ATTRIBUTE5 => r_ADE.INFORMATION115
19640 ,P_ADE_ATTRIBUTE6 => r_ADE.INFORMATION116
19641 ,P_ADE_ATTRIBUTE7 => r_ADE.INFORMATION117
19642 ,P_ADE_ATTRIBUTE8 => r_ADE.INFORMATION118
19643 ,P_ADE_ATTRIBUTE9 => r_ADE.INFORMATION119
19644 ,P_ADE_ATTRIBUTE_CATEGORY => r_ADE.INFORMATION110
19645 ,P_APLD_DPNT_CVG_ELIG_PRFL_ID => l_apld_dpnt_cvg_elig_prfl_id
19646 ,P_APLD_DPNT_CVG_ELIG_RL => l_APLD_DPNT_CVG_ELIG_RL
19647 ,P_DPNT_CVG_ELIGY_PRFL_ID => l_DPNT_CVG_ELIGY_PRFL_ID
19648 ,P_MNDTRY_FLAG => r_ADE.INFORMATION11
19649 ,P_PGM_ID => l_PGM_ID
19650 ,P_PL_ID => l_PL_ID
19651 ,P_PTIP_ID => l_PTIP_ID
19652 --
19653 ,P_EFFECTIVE_START_DATE => l_effective_start_date
19654 ,P_EFFECTIVE_END_DATE => l_effective_end_date
19655 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
19656 ,P_DATETRACK_MODE => l_datetrack_mode
19657 );
19658 --
19659 end if; -- l_update
19660 end if;
19661 --
19662 -- Delete the row if it is end dated.
19663 --
19664 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
19665 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
19666 trunc(l_max_eed) = r_ADE.information3) then
19667 --
19668 BEN_APLD_DPNT_CVG_PRFL_API.delete_APLD_DPNT_CVG_PRFL(
19669 --
19670 p_validate => false
19671 ,p_apld_dpnt_cvg_elig_prfl_id => l_apld_dpnt_cvg_elig_prfl_id
19672 ,p_effective_start_date => l_effective_start_date
19673 ,p_effective_end_date => l_effective_end_date
19674 ,p_object_version_number => l_object_version_number
19675 ,p_effective_date => l_max_eed
19676 ,p_datetrack_mode => hr_api.g_delete
19677 --
19678 );
19679 --
19680 end if;
19681 --
19682 l_prev_pk_id := l_current_pk_id ;
19683 --
19684 end if;
19685 --
19686 end if;
19687 --
19688 end loop;
19689 --
19690 exception when others then
19691 --
19692 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ADE',r_ade.information5 );
19693 --
19694 end create_ADE_rows;
19695
19696 --
19697 ---------------------------------------------------------------
19698 ----------------------< create_PGC_rows >-----------------------
19699 ---------------------------------------------------------------
19700 --
19701 procedure create_PGC_rows
19702 (
19703 p_validate in number default 0
19704 ,p_copy_entity_txn_id in number
19705 ,p_effective_date in date
19706 ,p_prefix_suffix_text in varchar2 default null
19707 ,p_reuse_object_flag in varchar2 default null
19708 ,p_target_business_group_id in varchar2 default null
19709 ,p_prefix_suffix_cd in varchar2 default null
19710 ) is
19711 --
19712 l_CTFN_RQD_WHEN_RL number;
19713 l_PGM_ID number;
19714 l_DPNT_CVG_CTFN_TYP_CD varchar2(30);
19715 cursor c_unique_PGC(l_table_alias varchar2) is
19716 select distinct cpe.information1,
19717 cpe.information2,
19718 cpe.information3,
19719 cpe.table_route_id
19720 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
19721 pqh_table_route tr
19722 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19723 and cpe.table_route_id = tr.table_route_id
19724 -- and tr.where_clause = l_BEN_PGM_DPNT_CVG_CTFN_F
19725 and tr.table_alias = l_table_alias
19726 and cpe.number_of_copies = 1 -- ADDITION
19727 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
19728 order by information1, information2; --added for bug: 5151945
19729 --
19730 --
19731 cursor c_PGC_min_max_dates(c_table_route_id number,
19732 c_information1 number) is
19733 select
19734 min(cpe.information2) min_esd,
19735 max(cpe.information3) min_eed
19736 from ben_copy_entity_results cpe
19737 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19738 and cpe.table_route_id = c_table_route_id
19739 and cpe.information1 = c_information1 ;
19740 --
19741 cursor c_PGC(c_table_route_id number,
19742 c_information1 number,
19743 c_information2 date,
19744 c_information3 date ) is
19745 select
19746 cpe.*
19747 from ben_copy_entity_results cpe
19748 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19749 and cpe.table_route_id = c_table_route_id
19750 and cpe.information1 = c_information1
19751 and cpe.information2 = c_information2
19752 and cpe.information3 = c_information3
19753 and rownum = 1 ;
19754 -- Date Track target record
19755 cursor c_find_PGC_in_target(
19756 c_effective_start_date date,
19757 c_effective_end_date date,
19758 c_business_group_id number,
19759 c_new_pk_id number) is
19760 select
19761 PGC.pgm_dpnt_cvg_ctfn_id new_value
19762 from BEN_PGM_DPNT_CVG_CTFN_F PGC
19763 where
19764 PGC.PGM_ID = l_PGM_ID and
19765 PGC.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
19766 PGC.business_group_id = c_business_group_id
19767 and PGC.pgm_dpnt_cvg_ctfn_id <> c_new_pk_id
19768 --TEMPIK
19769 and c_effective_start_date between effective_start_date
19770 and effective_end_date ;
19771 --END TEMPIK
19772 /*TEMPIK
19773 and exists ( select null
19774 from BEN_PGM_DPNT_CVG_CTFN_F PGC1
19775 where
19776 PGC1.PGM_ID = l_PGM_ID and
19777 PGC1.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
19778 PGC1.business_group_id = c_business_group_id
19779 and PGC1.effective_start_date <= c_effective_start_date )
19780 and exists ( select null
19781 from BEN_PGM_DPNT_CVG_CTFN_F PGC2
19782 where
19783 PGC2.PGM_ID = l_PGM_ID and
19784 PGC2.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
19785 PGC2.business_group_id = c_business_group_id
19786 and PGC2.effective_end_date >= c_effective_end_date )
19787 ;
19788 */
19789 --
19790 --UPD START
19791 --
19792 l_update boolean := false ;
19793 l_datetrack_mode varchar2(80) := hr_api.g_update;
19794 l_process_date date;
19795 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
19796 --
19797 --UPD END
19798 l_current_pk_id number := null ;
19799 l_prev_pk_id number := null ;
19800 l_first_rec boolean := true ;
19801 r_PGC c_PGC%rowtype;
19802 l_pgm_dpnt_cvg_ctfn_id number ;
19803 l_object_version_number number ;
19804 l_effective_start_date date ;
19805 l_effective_end_date date ;
19806 l_prefix pqh_copy_entity_attribs.information1%type := null;
19807 l_suffix pqh_copy_entity_attribs.information1%type := null;
19808 l_new_value number(15);
19809 l_object_found_in_target boolean := false ;
19810 l_min_esd date;
19811 l_max_eed date;
19812 l_effective_date date;
19813 --TEMPIK
19814 l_dt_rec_found boolean ;
19815 --END TEMPIK
19816 --
19817 begin
19818 -- Initialization
19819 l_object_found_in_target := false ;
19820 -- End Initialization
19821 -- Derive the prefix - sufix
19822 if p_prefix_suffix_cd = 'PREFIX' then
19823 l_prefix := p_prefix_suffix_text ;
19824 elsif p_prefix_suffix_cd = 'SUFFIX' then
19825 l_suffix := p_prefix_suffix_text ;
19826 else
19827 l_prefix := null ;
19828 l_suffix := null ;
19829 end if ;
19830 -- End Prefix Sufix derivation
19831 for r_PGC_unique in c_unique_PGC('PGC') loop
19832
19833 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
19834 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19835 r_PGC_unique.information3 >=
19836 ben_pd_copy_to_ben_one.g_copy_effective_date)
19837 ) then
19838 --
19839 hr_utility.set_location(' r_PGC_unique.table_route_id '||r_PGC_unique.table_route_id,10);
19840 hr_utility.set_location(' r_PGC_unique.information1 '||r_PGC_unique.information1,10);
19841 hr_utility.set_location( 'r_PGC_unique.information2 '||r_PGC_unique.information2,10);
19842 hr_utility.set_location( 'r_PGC_unique.information3 '||r_PGC_unique.information3,10);
19843 -- If reuse objects flag is 'Y' then check for the object in the target business group
19844 -- if found insert the record into PLSql table and exit the loop else try create the
19845 -- object in the target business group
19846 --
19847 l_object_found_in_target := false ;
19848 --UPD START
19849 open c_PGC(r_PGC_unique.table_route_id,
19850 r_PGC_unique.information1,
19851 r_PGC_unique.information2,
19852 r_PGC_unique.information3 ) ;
19853 --
19854 fetch c_PGC into r_PGC ;
19855 --
19856 close c_PGC ;
19857 l_dml_operation:= r_PGC_unique.dml_operation ;
19858 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_PGC.INFORMATION261,l_dml_operation );
19859 l_PGM_ID := get_fk('PGM_ID', r_PGC.INFORMATION260,l_dml_operation );
19860 l_update := false;
19861 l_process_date := p_effective_date;
19862 --
19863 if l_dml_operation = 'UPDATE' then
19864 --
19865 l_object_found_in_target := TRUE;
19866 --
19867 if l_process_date between r_PGC_unique.information2 and r_PGC_unique.information3 then
19868 l_update := true;
19869 if r_PGC_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
19870 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PGM_DPNT_CVG_CTFN_ID'
19871 then
19872 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PGM_DPNT_CVG_CTFN_ID' ;
19873 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PGC_unique.information1 ;
19874 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PGC_unique.information1 ;
19875 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19876 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PGC_unique.table_route_id;
19877 --
19878 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
19879 --
19880 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19881 --
19882 --DOUBT log_data('PGC',l_new_value,l_prefix || r_PGC_unique.name|| l_suffix,'REUSED');
19883 --
19884 end if ;
19885 hr_utility.set_location( 'found record for update',10);
19886 --
19887 else
19888 --
19889 l_update := false;
19890 --
19891 end if;
19892 else
19893 --
19894 --UPD END
19895 l_min_esd := null ;
19896 l_max_eed := null ;
19897 open c_PGC_min_max_dates(r_PGC_unique.table_route_id, r_PGC_unique.information1 ) ;
19898 fetch c_PGC_min_max_dates into l_min_esd,l_max_eed ;
19899 --
19900
19901 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19902 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19903 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
19904 end if;
19905 l_min_esd := greatest(l_min_esd,r_PGC_unique.information2);
19906 /* open c_PGC(r_PGC_unique.table_route_id,
19907 r_PGC_unique.information1,
19908 r_PGC_unique.information2,
19909 r_PGC_unique.information3 ) ;
19910 --
19911 fetch c_PGC into r_PGC ;
19912 --
19913 close c_PGC ; */
19914 --
19915 l_DPNT_CVG_CTFN_TYP_CD := r_PGC.information13 ;
19916 if p_reuse_object_flag = 'Y' then
19917 if c_PGC_min_max_dates%found then
19918 -- cursor to find the object
19919 open c_find_PGC_in_target( l_min_esd,l_max_eed,
19920 p_target_business_group_id, nvl(l_pgm_dpnt_cvg_ctfn_id, -999) ) ;
19921 fetch c_find_PGC_in_target into l_new_value ;
19922 if c_find_PGC_in_target%found then
19923 --
19924 --TEMPIK
19925 l_dt_rec_found := dt_api.check_min_max_dates
19926 (p_base_table_name => 'BEN_PGM_DPNT_CVG_CTFN_F',
19927 p_base_key_column => 'PGM_DPNT_CVG_CTFN_ID',
19928 p_base_key_value => l_new_value,
19929 p_from_date => l_min_esd,
19930 p_to_date => l_max_eed );
19931 if l_dt_rec_found THEN
19932 --END TEMPIK
19933 if r_PGC_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
19934 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PGM_DPNT_CVG_CTFN_ID' then
19935 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PGM_DPNT_CVG_CTFN_ID' ;
19936 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PGC_unique.information1 ;
19937 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
19938 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19939 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PGC_unique.table_route_id;
19940 --
19941 -- 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) ;
19942 --
19943 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19944 end if ;
19945 --
19946 l_object_found_in_target := true ;
19947 --TEMPIK
19948 end if; -- l_dt_rec_found
19949 --END TEMPIK
19950 end if;
19951 close c_find_PGC_in_target ;
19952 --
19953 end if;
19954 end if ;
19955 --
19956 close c_PGC_min_max_dates ;
19957 end if; --if p_dml_operation
19958 --
19959 if not l_object_found_in_target OR l_update then
19960 --
19961 l_current_pk_id := r_PGC.information1;
19962 --
19963 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
19964 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
19965 --
19966 if l_current_pk_id = l_prev_pk_id then
19967 --
19968 l_first_rec := false ;
19969 --
19970 else
19971 --
19972 l_first_rec := true ;
19973 --
19974 end if ;
19975 --
19976
19977 l_effective_date := r_PGC.information2;
19978 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19979 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19980 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
19981 end if;
19982
19983 if l_first_rec and not l_update then
19984 -- Call Create routine.
19985 hr_utility.set_location(' BEN_PGM_DPNT_CVG_CTFN_F CREATE_PROGRAM_DPNT_CVG_CTFN ',20);
19986 BEN_PROGRAM_DPNT_CVG_CTFN_API.CREATE_PROGRAM_DPNT_CVG_CTFN(
19987 --
19988 P_VALIDATE => false
19989 ,P_EFFECTIVE_DATE => l_effective_date
19990 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19991 --
19992 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
19993 ,P_DPNT_CVG_CTFN_TYP_CD => r_PGC.INFORMATION13
19994 ,P_LACK_CTFN_SSPND_ENRT_FLAG => r_PGC.INFORMATION11
19995 ,P_PFD_FLAG => r_PGC.INFORMATION12
19996 ,P_PGC_ATTRIBUTE1 => r_PGC.INFORMATION111
19997 ,P_PGC_ATTRIBUTE10 => r_PGC.INFORMATION120
19998 ,P_PGC_ATTRIBUTE11 => r_PGC.INFORMATION121
19999 ,P_PGC_ATTRIBUTE12 => r_PGC.INFORMATION122
20000 ,P_PGC_ATTRIBUTE13 => r_PGC.INFORMATION123
20001 ,P_PGC_ATTRIBUTE14 => r_PGC.INFORMATION124
20002 ,P_PGC_ATTRIBUTE15 => r_PGC.INFORMATION125
20003 ,P_PGC_ATTRIBUTE16 => r_PGC.INFORMATION126
20004 ,P_PGC_ATTRIBUTE17 => r_PGC.INFORMATION127
20005 ,P_PGC_ATTRIBUTE18 => r_PGC.INFORMATION128
20006 ,P_PGC_ATTRIBUTE19 => r_PGC.INFORMATION129
20007 ,P_PGC_ATTRIBUTE2 => r_PGC.INFORMATION112
20008 ,P_PGC_ATTRIBUTE20 => r_PGC.INFORMATION130
20009 ,P_PGC_ATTRIBUTE21 => r_PGC.INFORMATION131
20010 ,P_PGC_ATTRIBUTE22 => r_PGC.INFORMATION132
20011 ,P_PGC_ATTRIBUTE23 => r_PGC.INFORMATION133
20012 ,P_PGC_ATTRIBUTE24 => r_PGC.INFORMATION134
20013 ,P_PGC_ATTRIBUTE25 => r_PGC.INFORMATION135
20014 ,P_PGC_ATTRIBUTE26 => r_PGC.INFORMATION136
20015 ,P_PGC_ATTRIBUTE27 => r_PGC.INFORMATION137
20016 ,P_PGC_ATTRIBUTE28 => r_PGC.INFORMATION138
20017 ,P_PGC_ATTRIBUTE29 => r_PGC.INFORMATION139
20018 ,P_PGC_ATTRIBUTE3 => r_PGC.INFORMATION113
20019 ,P_PGC_ATTRIBUTE30 => r_PGC.INFORMATION140
20020 ,P_PGC_ATTRIBUTE4 => r_PGC.INFORMATION114
20021 ,P_PGC_ATTRIBUTE5 => r_PGC.INFORMATION115
20022 ,P_PGC_ATTRIBUTE6 => r_PGC.INFORMATION116
20023 ,P_PGC_ATTRIBUTE7 => r_PGC.INFORMATION117
20024 ,P_PGC_ATTRIBUTE8 => r_PGC.INFORMATION118
20025 ,P_PGC_ATTRIBUTE9 => r_PGC.INFORMATION119
20026 ,P_PGC_ATTRIBUTE_CATEGORY => r_PGC.INFORMATION110
20027 ,P_PGM_DPNT_CVG_CTFN_ID => l_pgm_dpnt_cvg_ctfn_id
20028 ,P_PGM_ID => l_PGM_ID
20029 ,P_RLSHP_TYP_CD => r_PGC.INFORMATION15
20030 ,P_RQD_FLAG => r_PGC.INFORMATION14
20031 --
20032 ,P_EFFECTIVE_START_DATE => l_effective_start_date
20033 ,P_EFFECTIVE_END_DATE => l_effective_end_date
20034 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
20035 );
20036 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
20037 -- Update all relevent cer records with new pk_id
20038 hr_utility.set_location('Before plsql table ',222);
20039 hr_utility.set_location('new_value id '||l_pgm_dpnt_cvg_ctfn_id,222);
20040 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PGM_DPNT_CVG_CTFN_ID' ;
20041 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PGC.information1 ;
20042 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PGM_DPNT_CVG_CTFN_ID ;
20043 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
20044 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PGC_unique.table_route_id;
20045 hr_utility.set_location('After plsql table ',222);
20046 --
20047 -- 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 ) ;
20048 --
20049 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20050 --
20051 else
20052 --
20053 -- Call Update routine for the pk_id created in prev run .
20054 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
20055 hr_utility.set_location(' BEN_PGM_DPNT_CVG_CTFN_F UPDATE_PROGRAM_DPNT_CVG_CTFN ',30);
20056 --UPD START
20057 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
20058 --
20059 if l_update then
20060 --
20061 l_datetrack_mode := r_PGC.datetrack_mode ;
20062 --
20063 get_dt_modes(
20064 p_effective_date => l_process_date,
20065 p_effective_end_date => r_PGC.information3,
20066 p_effective_start_date => r_PGC.information2,
20067 p_dml_operation => r_PGC.dml_operation,
20068 p_datetrack_mode => l_datetrack_mode );
20069 -- p_update => l_update
20070 --
20071 l_effective_date := l_process_date;
20072 l_PGM_DPNT_CVG_CTFN_ID := r_PGC.information1;
20073 l_object_version_number := r_PGC.information265;
20074 --
20075 end if;
20076 --
20077 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
20078 --
20079 IF l_update OR l_dml_operation <> 'UPDATE' THEN
20080 --UPD END
20081 BEN_PROGRAM_DPNT_CVG_CTFN_API.UPDATE_PROGRAM_DPNT_CVG_CTFN(
20082 --
20083 P_VALIDATE => false
20084 ,P_EFFECTIVE_DATE => l_effective_date
20085 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
20086 --
20087 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
20088 ,P_DPNT_CVG_CTFN_TYP_CD => r_PGC.INFORMATION13
20089 ,P_LACK_CTFN_SSPND_ENRT_FLAG => r_PGC.INFORMATION11
20090 ,P_PFD_FLAG => r_PGC.INFORMATION12
20091 ,P_PGC_ATTRIBUTE1 => r_PGC.INFORMATION111
20092 ,P_PGC_ATTRIBUTE10 => r_PGC.INFORMATION120
20093 ,P_PGC_ATTRIBUTE11 => r_PGC.INFORMATION121
20094 ,P_PGC_ATTRIBUTE12 => r_PGC.INFORMATION122
20095 ,P_PGC_ATTRIBUTE13 => r_PGC.INFORMATION123
20096 ,P_PGC_ATTRIBUTE14 => r_PGC.INFORMATION124
20097 ,P_PGC_ATTRIBUTE15 => r_PGC.INFORMATION125
20098 ,P_PGC_ATTRIBUTE16 => r_PGC.INFORMATION126
20099 ,P_PGC_ATTRIBUTE17 => r_PGC.INFORMATION127
20100 ,P_PGC_ATTRIBUTE18 => r_PGC.INFORMATION128
20101 ,P_PGC_ATTRIBUTE19 => r_PGC.INFORMATION129
20102 ,P_PGC_ATTRIBUTE2 => r_PGC.INFORMATION112
20103 ,P_PGC_ATTRIBUTE20 => r_PGC.INFORMATION130
20104 ,P_PGC_ATTRIBUTE21 => r_PGC.INFORMATION131
20105 ,P_PGC_ATTRIBUTE22 => r_PGC.INFORMATION132
20106 ,P_PGC_ATTRIBUTE23 => r_PGC.INFORMATION133
20107 ,P_PGC_ATTRIBUTE24 => r_PGC.INFORMATION134
20108 ,P_PGC_ATTRIBUTE25 => r_PGC.INFORMATION135
20109 ,P_PGC_ATTRIBUTE26 => r_PGC.INFORMATION136
20110 ,P_PGC_ATTRIBUTE27 => r_PGC.INFORMATION137
20111 ,P_PGC_ATTRIBUTE28 => r_PGC.INFORMATION138
20112 ,P_PGC_ATTRIBUTE29 => r_PGC.INFORMATION139
20113 ,P_PGC_ATTRIBUTE3 => r_PGC.INFORMATION113
20114 ,P_PGC_ATTRIBUTE30 => r_PGC.INFORMATION140
20115 ,P_PGC_ATTRIBUTE4 => r_PGC.INFORMATION114
20116 ,P_PGC_ATTRIBUTE5 => r_PGC.INFORMATION115
20117 ,P_PGC_ATTRIBUTE6 => r_PGC.INFORMATION116
20118 ,P_PGC_ATTRIBUTE7 => r_PGC.INFORMATION117
20119 ,P_PGC_ATTRIBUTE8 => r_PGC.INFORMATION118
20120 ,P_PGC_ATTRIBUTE9 => r_PGC.INFORMATION119
20121 ,P_PGC_ATTRIBUTE_CATEGORY => r_PGC.INFORMATION110
20122 ,P_PGM_DPNT_CVG_CTFN_ID => l_pgm_dpnt_cvg_ctfn_id
20123 ,P_PGM_ID => l_PGM_ID
20124 ,P_RLSHP_TYP_CD => r_PGC.INFORMATION15
20125 ,P_RQD_FLAG => r_PGC.INFORMATION14
20126 --
20127 ,P_EFFECTIVE_START_DATE => l_effective_start_date
20128 ,P_EFFECTIVE_END_DATE => l_effective_end_date
20129 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
20130 ,P_DATETRACK_MODE => l_datetrack_mode
20131 );
20132 --
20133 end if; -- l_update
20134 end if;
20135 --
20136 -- Delete the row if it is end dated.
20137 --
20138 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
20139 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
20140 trunc(l_max_eed) = r_PGC.information3) then
20141 --
20142 BEN_PROGRAM_DPNT_CVG_CTFN_API.delete_PROGRAM_DPNT_CVG_CTFN(
20143 --
20144 p_validate => false
20145 ,p_pgm_dpnt_cvg_ctfn_id => l_pgm_dpnt_cvg_ctfn_id
20146 ,p_effective_start_date => l_effective_start_date
20147 ,p_effective_end_date => l_effective_end_date
20148 ,p_object_version_number => l_object_version_number
20149 ,p_effective_date => l_max_eed
20150 ,p_datetrack_mode => hr_api.g_delete
20151 --
20152 );
20153 --
20154 end if;
20155 --
20156 l_prev_pk_id := l_current_pk_id ;
20157 --
20158 end if;
20159 --
20160 end if;
20161 --
20162 end loop;
20163 --
20164 exception when others then
20165 --
20166 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PGC',r_pgc.information5 );
20167 --
20168 end create_PGC_rows;
20169
20170 ---------------------------------------------------------------
20171 ----------------------< create_LGE_rows >-----------------------
20172 ---------------------------------------------------------------
20173 --
20174 procedure create_LGE_rows
20175 (
20176 p_validate in number default 0
20177 ,p_copy_entity_txn_id in number
20178 ,p_effective_date in date
20179 ,p_prefix_suffix_text in varchar2 default null
20180 ,p_reuse_object_flag in varchar2 default null
20181 ,p_target_business_group_id in varchar2 default null
20182 ,p_prefix_suffix_cd in varchar2 default null
20183 ) is
20184 --
20185 l_AUTO_ENRT_MTHD_RL number;
20186 l_DFLT_ENRT_RL number;
20187 l_ENRT_RL number;
20188 l_LER_ID number;
20189 l_PGM_ID number;
20190 cursor c_unique_LGE(l_table_alias varchar2) is
20191 select distinct cpe.information1,
20192 cpe.information2,
20193 cpe.information3,
20194 cpe.table_route_id
20195 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
20196 pqh_table_route tr
20197 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20198 and cpe.table_route_id = tr.table_route_id
20199 -- and tr.where_clause = l_BEN_LER_CHG_PGM_ENRT_F
20200 and tr.table_alias = l_table_alias
20201 and cpe.number_of_copies = 1 -- ADDITION
20202 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
20203 order by information1, information2; --added for bug: 5151945
20204 --
20205 --
20206 cursor c_LGE_min_max_dates(c_table_route_id number,
20207 c_information1 number) is
20208 select
20209 min(cpe.information2) min_esd,
20210 max(cpe.information3) min_eed
20211 from ben_copy_entity_results cpe
20212 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20213 and cpe.table_route_id = c_table_route_id
20214 and cpe.information1 = c_information1 ;
20215 --
20216 cursor c_LGE(c_table_route_id number,
20217 c_information1 number,
20218 c_information2 date,
20219 c_information3 date ) is
20220 select
20221 cpe.*
20222 from ben_copy_entity_results cpe
20223 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20224 and cpe.table_route_id = c_table_route_id
20225 and cpe.information1 = c_information1
20226 and cpe.information2 = c_information2
20227 and cpe.information3 = c_information3
20228 and rownum = 1 ;
20229 -- Date Track target record
20230 cursor c_find_LGE_in_target(
20231 c_effective_start_date date,
20232 c_effective_end_date date,
20233 c_business_group_id number,
20234 c_new_pk_id number) is
20235 select
20236 LGE.ler_chg_pgm_enrt_id new_value
20237 from BEN_LER_CHG_PGM_ENRT_F LGE
20238 where
20239 LGE.LER_ID = l_LER_ID and
20240 LGE.PGM_ID = l_PGM_ID and
20241 LGE.business_group_id = c_business_group_id
20242 and LGE.ler_chg_pgm_enrt_id <> c_new_pk_id
20243 --TEMPIK
20244 and c_effective_start_date between effective_start_date
20245 and effective_end_date ;
20246 --END TEMPIK
20247 /*TEMPIK
20248 and exists ( select null
20249 from BEN_LER_CHG_PGM_ENRT_F LGE1
20250 where
20251 LGE1.LER_ID = l_LER_ID and
20252 LGE1.PGM_ID = l_PGM_ID and
20253 LGE1.business_group_id = c_business_group_id
20254 and LGE1.effective_start_date <= c_effective_start_date )
20255 and exists ( select null
20256 from BEN_LER_CHG_PGM_ENRT_F LGE2
20257 where
20258 LGE2.LER_ID = l_LER_ID and
20259 LGE2.PGM_ID = l_PGM_ID and
20260 LGE2.business_group_id = c_business_group_id
20261 and LGE2.effective_end_date >= c_effective_end_date )
20262 ;
20263 */
20264 --
20265 --UPD START
20266 --
20267 l_update boolean := false ;
20268 l_datetrack_mode varchar2(80) := hr_api.g_update;
20269 l_process_date date;
20270 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
20271 --
20272 --UPD END
20273 l_current_pk_id number := null ;
20274 l_prev_pk_id number := null ;
20275 l_first_rec boolean := true ;
20276 r_LGE c_LGE%rowtype;
20277 l_ler_chg_pgm_enrt_id number ;
20278 l_object_version_number number ;
20279 l_effective_start_date date ;
20280 l_effective_end_date date ;
20281 l_prefix pqh_copy_entity_attribs.information1%type := null;
20282 l_suffix pqh_copy_entity_attribs.information1%type := null;
20283 l_new_value number(15);
20284 l_object_found_in_target boolean := false ;
20285 l_min_esd date;
20286 l_max_eed date;
20287 l_effective_date date;
20288 --TEMPIK
20289 l_dt_rec_found boolean ;
20290 --END TEMPIK
20291 --
20292 begin
20293 -- Initialization
20294 l_object_found_in_target := false ;
20295 -- End Initialization
20296 -- Derive the prefix - sufix
20297 if p_prefix_suffix_cd = 'PREFIX' then
20298 l_prefix := p_prefix_suffix_text ;
20299 elsif p_prefix_suffix_cd = 'SUFFIX' then
20300 l_suffix := p_prefix_suffix_text ;
20301 else
20302 l_prefix := null ;
20303 l_suffix := null ;
20304 end if ;
20305 -- End Prefix Sufix derivation
20306 for r_LGE_unique in c_unique_LGE('LGE') loop
20307
20308 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
20309 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20310 r_LGE_unique.information3 >=
20311 ben_pd_copy_to_ben_one.g_copy_effective_date)
20312 ) then
20313 --
20314 hr_utility.set_location(' r_LGE_unique.table_route_id '||r_LGE_unique.table_route_id,10);
20315 hr_utility.set_location(' r_LGE_unique.information1 '||r_LGE_unique.information1,10);
20316 hr_utility.set_location( 'r_LGE_unique.information2 '||r_LGE_unique.information2,10);
20317 hr_utility.set_location( 'r_LGE_unique.information3 '||r_LGE_unique.information3,10);
20318 -- If reuse objects flag is 'Y' then check for the object in the target business group
20319 -- if found insert the record into PLSql table and exit the loop else try create the
20320 -- object in the target business group
20321 --
20322 l_object_found_in_target := false ;
20323 --UPD START
20324 open c_LGE(r_LGE_unique.table_route_id,
20325 r_LGE_unique.information1,
20326 r_LGE_unique.information2,
20327 r_LGE_unique.information3 ) ;
20328 --
20329 fetch c_LGE into r_LGE ;
20330 --
20331 close c_LGE ;
20332 --
20333 l_dml_operation:= r_LGE_unique.dml_operation ;
20334 l_AUTO_ENRT_MTHD_RL := get_fk('FORMULA_ID', r_LGE.INFORMATION262,l_dml_operation );
20335 l_DFLT_ENRT_RL := get_fk('FORMULA_ID', r_LGE.INFORMATION263,l_dml_operation );
20336 l_ENRT_RL := get_fk('FORMULA_ID', r_LGE.INFORMATION264,l_dml_operation );
20337 l_LER_ID := get_fk('LER_ID', r_LGE.INFORMATION257,l_dml_operation );
20338 l_PGM_ID := get_fk('PGM_ID', r_LGE.INFORMATION260,l_dml_operation );
20339 --
20340 l_update := false;
20341 l_process_date := p_effective_date;
20342 --
20343 if l_dml_operation = 'UPDATE' then
20344 --
20345 l_object_found_in_target := TRUE;
20346 --
20347 if l_process_date between r_LGE_unique.information2 and r_LGE_unique.information3 then
20348 l_update := true;
20349 if r_LGE_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
20350 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_PGM_ENRT_ID'
20351 then
20352 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_PGM_ENRT_ID' ;
20353 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LGE_unique.information1 ;
20354 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LGE_unique.information1 ;
20355 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
20356 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LGE_unique.table_route_id;
20357 --
20358 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
20359 --
20360 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20361 --
20362 --DOUBT log_data('LGE',l_new_value,l_prefix || r_LGE_unique.name|| l_suffix,'REUSED');
20363 --
20364 end if ;
20365 hr_utility.set_location( 'found record for update',10);
20366 --
20367 else
20368 --
20369 l_update := false;
20370 --
20371 end if;
20372 else
20373 --
20374 --UPD END
20375 l_min_esd := null ;
20376 l_max_eed := null ;
20377 open c_LGE_min_max_dates(r_LGE_unique.table_route_id, r_LGE_unique.information1 ) ;
20378 fetch c_LGE_min_max_dates into l_min_esd,l_max_eed ;
20379 --
20380
20381 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20382 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
20383 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
20384 end if;
20385 l_min_esd := greatest(l_min_esd,r_LGE_unique.information2);
20386 /* open c_LGE(r_LGE_unique.table_route_id,
20387 r_LGE_unique.information1,
20388 r_LGE_unique.information2,
20389 r_LGE_unique.information3 ) ;
20390 --
20391 fetch c_LGE into r_LGE ;
20392 --
20393 close c_LGE ; */
20394 --
20395 if p_reuse_object_flag = 'Y' then
20396 if c_LGE_min_max_dates%found then
20397 -- cursor to find the object
20398 open c_find_LGE_in_target( l_min_esd,l_max_eed,
20399 p_target_business_group_id, nvl(l_ler_chg_pgm_enrt_id, -999) ) ;
20400 fetch c_find_LGE_in_target into l_new_value ;
20401 if c_find_LGE_in_target%found then
20402 --TEMPIK
20403 l_dt_rec_found := dt_api.check_min_max_dates
20404 (p_base_table_name => 'BEN_LER_CHG_PGM_ENRT_F',
20405 p_base_key_column => 'LER_CHG_PGM_ENRT_ID',
20406 p_base_key_value => l_new_value,
20407 p_from_date => l_min_esd,
20408 p_to_date => l_max_eed );
20409 if l_dt_rec_found THEN
20410 --END TEMPIK
20411 --
20412 if r_LGE_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
20413 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_PGM_ENRT_ID' then
20414 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_PGM_ENRT_ID' ;
20415 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LGE_unique.information1 ;
20416 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
20417 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
20418 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LGE_unique.table_route_id;
20419 --
20420 -- 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) ;
20421 --
20422 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20423 end if ;
20424 --
20425 l_object_found_in_target := true ;
20426 --TEMPIK
20427 end if; -- l_dt_rec_found
20428 --END TEMPIK
20429 end if;
20430 close c_find_LGE_in_target ;
20431 --
20432 end if;
20433 end if ;
20434 --
20435 close c_LGE_min_max_dates ;
20436 end if; --if p_dml_operation
20437 --
20438 if not l_object_found_in_target OR l_update then
20439 --
20440 l_current_pk_id := r_LGE.information1;
20441 --
20442 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
20443 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
20444 --
20445 if l_current_pk_id = l_prev_pk_id then
20446 --
20447 l_first_rec := false ;
20448 --
20449 else
20450 --
20451 l_first_rec := true ;
20452 --
20453 end if ;
20454 --
20455
20456 l_effective_date := r_LGE.information2;
20457 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20458 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
20459 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
20460 end if;
20461
20462 if l_first_rec and not l_update then
20463 -- Call Create routine.
20464 hr_utility.set_location(' BEN_LER_CHG_PGM_ENRT_F CREATE_LER_CHG_PGM_ENRT ',20);
20465 BEN_LER_CHG_PGM_ENRT_API.CREATE_LER_CHG_PGM_ENRT(
20466 --
20467 P_VALIDATE => false
20468 ,P_EFFECTIVE_DATE => l_effective_date
20469 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
20470 --
20471 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
20472 ,P_CRNT_ENRT_PRCLDS_CHG_FLAG => r_LGE.INFORMATION11
20473 ,P_DFLT_ENRT_CD => r_LGE.INFORMATION13
20474 ,P_DFLT_ENRT_RL => l_DFLT_ENRT_RL
20475 ,P_ENRT_CD => r_LGE.INFORMATION14
20476 ,P_ENRT_MTHD_CD => r_LGE.INFORMATION15
20477 ,P_ENRT_RL => l_ENRT_RL
20478 ,P_LER_CHG_PGM_ENRT_ID => l_ler_chg_pgm_enrt_id
20479 ,P_LER_ID => l_LER_ID
20480 ,P_LGE_ATTRIBUTE1 => r_LGE.INFORMATION111
20481 ,P_LGE_ATTRIBUTE10 => r_LGE.INFORMATION120
20482 ,P_LGE_ATTRIBUTE11 => r_LGE.INFORMATION121
20483 ,P_LGE_ATTRIBUTE12 => r_LGE.INFORMATION122
20484 ,P_LGE_ATTRIBUTE13 => r_LGE.INFORMATION123
20485 ,P_LGE_ATTRIBUTE14 => r_LGE.INFORMATION124
20486 ,P_LGE_ATTRIBUTE15 => r_LGE.INFORMATION125
20487 ,P_LGE_ATTRIBUTE16 => r_LGE.INFORMATION126
20488 ,P_LGE_ATTRIBUTE17 => r_LGE.INFORMATION127
20489 ,P_LGE_ATTRIBUTE18 => r_LGE.INFORMATION128
20490 ,P_LGE_ATTRIBUTE19 => r_LGE.INFORMATION129
20491 ,P_LGE_ATTRIBUTE2 => r_LGE.INFORMATION112
20492 ,P_LGE_ATTRIBUTE20 => r_LGE.INFORMATION130
20493 ,P_LGE_ATTRIBUTE21 => r_LGE.INFORMATION131
20494 ,P_LGE_ATTRIBUTE22 => r_LGE.INFORMATION132
20495 ,P_LGE_ATTRIBUTE23 => r_LGE.INFORMATION133
20496 ,P_LGE_ATTRIBUTE24 => r_LGE.INFORMATION134
20497 ,P_LGE_ATTRIBUTE25 => r_LGE.INFORMATION135
20498 ,P_LGE_ATTRIBUTE26 => r_LGE.INFORMATION136
20499 ,P_LGE_ATTRIBUTE27 => r_LGE.INFORMATION137
20500 ,P_LGE_ATTRIBUTE28 => r_LGE.INFORMATION138
20501 ,P_LGE_ATTRIBUTE29 => r_LGE.INFORMATION139
20502 ,P_LGE_ATTRIBUTE3 => r_LGE.INFORMATION113
20503 ,P_LGE_ATTRIBUTE30 => r_LGE.INFORMATION140
20504 ,P_LGE_ATTRIBUTE4 => r_LGE.INFORMATION114
20505 ,P_LGE_ATTRIBUTE5 => r_LGE.INFORMATION115
20506 ,P_LGE_ATTRIBUTE6 => r_LGE.INFORMATION116
20507 ,P_LGE_ATTRIBUTE7 => r_LGE.INFORMATION117
20508 ,P_LGE_ATTRIBUTE8 => r_LGE.INFORMATION118
20509 ,P_LGE_ATTRIBUTE9 => r_LGE.INFORMATION119
20510 ,P_LGE_ATTRIBUTE_CATEGORY => r_LGE.INFORMATION110
20511 ,P_PGM_ID => l_PGM_ID
20512 ,P_STL_ELIG_CANT_CHG_FLAG => r_LGE.INFORMATION12
20513 --
20514 ,P_EFFECTIVE_START_DATE => l_effective_start_date
20515 ,P_EFFECTIVE_END_DATE => l_effective_end_date
20516 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
20517 );
20518 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
20519 -- Update all relevent cer records with new pk_id
20520 hr_utility.set_location('Before plsql table ',222);
20521 hr_utility.set_location('new_value id '||l_ler_chg_pgm_enrt_id,222);
20522 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_PGM_ENRT_ID' ;
20523 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LGE.information1 ;
20524 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LER_CHG_PGM_ENRT_ID ;
20525 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
20526 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LGE_unique.table_route_id;
20527 hr_utility.set_location('After plsql table ',222);
20528 --
20529 -- 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 ) ;
20530 --
20531 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20532 --
20533 else
20534 --
20535 -- Call Update routine for the pk_id created in prev run .
20536 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
20537 hr_utility.set_location(' BEN_LER_CHG_PGM_ENRT_F UPDATE_LER_CHG_PGM_ENRT ',30);
20538 --UPD START
20539 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
20540 --
20541 if l_update then
20542 --
20543 l_datetrack_mode := r_LGE.datetrack_mode ;
20544 --
20545 get_dt_modes(
20546 p_effective_date => l_process_date,
20547 p_effective_end_date => r_LGE.information3,
20548 p_effective_start_date => r_LGE.information2,
20549 p_dml_operation => r_LGE.dml_operation,
20550 p_datetrack_mode => l_datetrack_mode );
20551 -- p_update => l_update
20552 --
20553 l_effective_date := l_process_date;
20554 l_LER_CHG_PGM_ENRT_ID := r_LGE.information1;
20555 l_object_version_number := r_LGE.information265;
20556 --
20557 end if;
20558 --
20559 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
20560 --
20561 IF l_update OR l_dml_operation <> 'UPDATE' THEN
20562 --UPD END
20563 BEN_LER_CHG_PGM_ENRT_API.UPDATE_LER_CHG_PGM_ENRT(
20564 --
20565 P_VALIDATE => false
20566 ,P_EFFECTIVE_DATE => l_effective_date
20567 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
20568 --
20569 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
20570 ,P_CRNT_ENRT_PRCLDS_CHG_FLAG => r_LGE.INFORMATION11
20571 ,P_DFLT_ENRT_CD => r_LGE.INFORMATION13
20572 ,P_DFLT_ENRT_RL => l_DFLT_ENRT_RL
20573 ,P_ENRT_CD => r_LGE.INFORMATION14
20574 ,P_ENRT_MTHD_CD => r_LGE.INFORMATION15
20575 ,P_ENRT_RL => l_ENRT_RL
20576 ,P_LER_CHG_PGM_ENRT_ID => l_ler_chg_pgm_enrt_id
20577 ,P_LER_ID => l_LER_ID
20578 ,P_LGE_ATTRIBUTE1 => r_LGE.INFORMATION111
20579 ,P_LGE_ATTRIBUTE10 => r_LGE.INFORMATION120
20580 ,P_LGE_ATTRIBUTE11 => r_LGE.INFORMATION121
20581 ,P_LGE_ATTRIBUTE12 => r_LGE.INFORMATION122
20582 ,P_LGE_ATTRIBUTE13 => r_LGE.INFORMATION123
20583 ,P_LGE_ATTRIBUTE14 => r_LGE.INFORMATION124
20584 ,P_LGE_ATTRIBUTE15 => r_LGE.INFORMATION125
20585 ,P_LGE_ATTRIBUTE16 => r_LGE.INFORMATION126
20586 ,P_LGE_ATTRIBUTE17 => r_LGE.INFORMATION127
20587 ,P_LGE_ATTRIBUTE18 => r_LGE.INFORMATION128
20588 ,P_LGE_ATTRIBUTE19 => r_LGE.INFORMATION129
20589 ,P_LGE_ATTRIBUTE2 => r_LGE.INFORMATION112
20590 ,P_LGE_ATTRIBUTE20 => r_LGE.INFORMATION130
20591 ,P_LGE_ATTRIBUTE21 => r_LGE.INFORMATION131
20592 ,P_LGE_ATTRIBUTE22 => r_LGE.INFORMATION132
20593 ,P_LGE_ATTRIBUTE23 => r_LGE.INFORMATION133
20594 ,P_LGE_ATTRIBUTE24 => r_LGE.INFORMATION134
20595 ,P_LGE_ATTRIBUTE25 => r_LGE.INFORMATION135
20596 ,P_LGE_ATTRIBUTE26 => r_LGE.INFORMATION136
20597 ,P_LGE_ATTRIBUTE27 => r_LGE.INFORMATION137
20598 ,P_LGE_ATTRIBUTE28 => r_LGE.INFORMATION138
20599 ,P_LGE_ATTRIBUTE29 => r_LGE.INFORMATION139
20600 ,P_LGE_ATTRIBUTE3 => r_LGE.INFORMATION113
20601 ,P_LGE_ATTRIBUTE30 => r_LGE.INFORMATION140
20602 ,P_LGE_ATTRIBUTE4 => r_LGE.INFORMATION114
20603 ,P_LGE_ATTRIBUTE5 => r_LGE.INFORMATION115
20604 ,P_LGE_ATTRIBUTE6 => r_LGE.INFORMATION116
20605 ,P_LGE_ATTRIBUTE7 => r_LGE.INFORMATION117
20606 ,P_LGE_ATTRIBUTE8 => r_LGE.INFORMATION118
20607 ,P_LGE_ATTRIBUTE9 => r_LGE.INFORMATION119
20608 ,P_LGE_ATTRIBUTE_CATEGORY => r_LGE.INFORMATION110
20609 ,P_PGM_ID => l_PGM_ID
20610 ,P_STL_ELIG_CANT_CHG_FLAG => r_LGE.INFORMATION12
20611 --
20612 ,P_EFFECTIVE_START_DATE => l_effective_start_date
20613 ,P_EFFECTIVE_END_DATE => l_effective_end_date
20614 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
20615 ,P_DATETRACK_MODE => l_datetrack_mode
20616 );
20617 --
20618 end if; -- l_update
20619 end if;
20620 --
20621 -- Delete the row if it is end dated.
20622 --
20623 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
20624 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
20625 trunc(l_max_eed) = r_LGE.information3) then
20626 --
20627 BEN_LER_CHG_PGM_ENRT_API.delete_LER_CHG_PGM_ENRT(
20628 --
20629 p_validate => false
20630 ,p_ler_chg_pgm_enrt_id => l_ler_chg_pgm_enrt_id
20631 ,p_effective_start_date => l_effective_start_date
20632 ,p_effective_end_date => l_effective_end_date
20633 ,p_object_version_number => l_object_version_number
20634 ,p_effective_date => l_max_eed
20635 ,p_datetrack_mode => hr_api.g_delete
20636 --
20637 );
20638 --
20639 end if;
20640 --
20641 l_prev_pk_id := l_current_pk_id ;
20642 --
20643 end if;
20644 --
20645 end if;
20646 --
20647 end loop;
20648 --
20649 exception when others then
20650 --
20651 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LGE',r_lge.information5 );
20652 --
20653 end create_LGE_rows;
20654
20655 --
20656 ---------------------------------------------------------------
20657 ----------------------< create_LDC_rows >-----------------------
20658 ---------------------------------------------------------------
20659 --
20660 procedure create_LDC_rows
20661 (
20662 p_validate in number default 0
20663 ,p_copy_entity_txn_id in number
20664 ,p_effective_date in date
20665 ,p_prefix_suffix_text in varchar2 default null
20666 ,p_reuse_object_flag in varchar2 default null
20667 ,p_target_business_group_id in varchar2 default null
20668 ,p_prefix_suffix_cd in varchar2 default null
20669 ) is
20670 --
20671 l_CVG_EFF_END_RL number;
20672 l_CVG_EFF_STRT_RL number;
20673 l_LER_CHG_DPNT_CVG_RL number;
20674 l_LER_ID number;
20675 l_PGM_ID number;
20676 l_PL_ID number;
20677 l_PTIP_ID number;
20678 cursor c_unique_LDC(l_table_alias varchar2) is
20679 select distinct cpe.information1,
20680 cpe.information2,
20681 cpe.information3,
20682 cpe.table_route_id
20683 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
20684 pqh_table_route tr
20685 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20686 and cpe.table_route_id = tr.table_route_id
20687 -- and tr.where_clause = l_BEN_LER_CHG_DPNT_CVG_F
20688 and tr.table_alias = l_table_alias
20689 and cpe.number_of_copies = 1 -- ADDITION
20690 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
20691 order by information1, information2; --added for bug: 5151945
20692 --
20693 --
20694 cursor c_LDC_min_max_dates(c_table_route_id number,
20695 c_information1 number) is
20696 select
20697 min(cpe.information2) min_esd,
20698 max(cpe.information3) min_eed
20699 from ben_copy_entity_results cpe
20700 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20701 and cpe.table_route_id = c_table_route_id
20702 and cpe.information1 = c_information1 ;
20703 --
20704 cursor c_LDC(c_table_route_id number,
20705 c_information1 number,
20706 c_information2 date,
20707 c_information3 date ) is
20708 select
20709 cpe.*
20710 from ben_copy_entity_results cpe
20711 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20712 and cpe.table_route_id = c_table_route_id
20713 and cpe.information1 = c_information1
20714 and cpe.information2 = c_information2
20715 and cpe.information3 = c_information3
20716 and rownum = 1 ;
20717 -- Date Track target record
20718 cursor c_find_LDC_in_target(
20719 c_effective_start_date date,
20720 c_effective_end_date date,
20721 c_business_group_id number,
20722 c_new_pk_id number) is
20723 select
20724 LDC.ler_chg_dpnt_cvg_id new_value
20725 from BEN_LER_CHG_DPNT_CVG_F LDC
20726 where
20727 LDC.LER_ID = l_LER_ID and
20728 nvl(LDC.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
20729 nvl(LDC.PL_ID,-999) = nvl(l_PL_ID,-999) and
20730 nvl(LDC.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
20731 LDC.business_group_id = c_business_group_id
20732 and LDC.ler_chg_dpnt_cvg_id <> c_new_pk_id
20733 --TEMPIK
20734 and c_effective_start_date between effective_start_date
20735 and effective_end_date ;
20736 --END TEMPIK
20737 /*TEMPIK
20738 and exists ( select null
20739 from BEN_LER_CHG_DPNT_CVG_F LDC1
20740 where
20741 LDC1.LER_ID = l_LER_ID and
20742 nvl(LDC1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
20743 nvl(LDC1.PL_ID,-999) = nvl(l_PL_ID,-999) and
20744 nvl(LDC1.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
20745 LDC1.business_group_id = c_business_group_id
20746 and LDC1.effective_start_date <= c_effective_start_date )
20747 and exists ( select null
20748 from BEN_LER_CHG_DPNT_CVG_F LDC2
20749 where
20750 LDC2.LER_ID = l_LER_ID and
20751 nvl(LDC2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
20752 nvl(LDC2.PL_ID,-999) = nvl(l_PL_ID,-999) and
20753 nvl(LDC2.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
20754 LDC2.business_group_id = c_business_group_id
20755 and LDC2.effective_end_date >= c_effective_end_date )
20756 ;
20757 */
20758 --
20759 --UPD START
20760 --
20761 l_update boolean := false ;
20762 l_datetrack_mode varchar2(80) := hr_api.g_update;
20763 l_process_date date;
20764 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
20765 --
20766 --UPD END
20767
20768 l_current_pk_id number := null ;
20769 l_prev_pk_id number := null ;
20770 l_first_rec boolean := true ;
20771 r_LDC c_LDC%rowtype;
20772 l_ler_chg_dpnt_cvg_id number ;
20773 l_object_version_number number ;
20774 l_effective_start_date date ;
20775 l_effective_end_date date ;
20776 l_prefix pqh_copy_entity_attribs.information1%type := null;
20777 l_suffix pqh_copy_entity_attribs.information1%type := null;
20778 l_new_value number(15);
20779 l_object_found_in_target boolean := false ;
20780 l_min_esd date;
20781 l_max_eed date;
20782 l_effective_date date;
20783 --TEMPIK
20784 l_dt_rec_found boolean ;
20785 --END TEMPIK
20786 --
20787 begin
20788 -- Initialization
20789 l_object_found_in_target := false ;
20790 -- End Initialization
20791 -- Derive the prefix - sufix
20792 if p_prefix_suffix_cd = 'PREFIX' then
20793 l_prefix := p_prefix_suffix_text ;
20794 elsif p_prefix_suffix_cd = 'SUFFIX' then
20795 l_suffix := p_prefix_suffix_text ;
20796 else
20797 l_prefix := null ;
20798 l_suffix := null ;
20799 end if ;
20800 -- End Prefix Sufix derivation
20801 for r_LDC_unique in c_unique_LDC('LDC') loop
20802
20803 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
20804 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20805 r_LDC_unique.information3 >=
20806 ben_pd_copy_to_ben_one.g_copy_effective_date)
20807 ) then
20808 --
20809 hr_utility.set_location(' r_LDC_unique.table_route_id '||r_LDC_unique.table_route_id,10);
20810 hr_utility.set_location(' r_LDC_unique.information1 '||r_LDC_unique.information1,10);
20811 hr_utility.set_location( 'r_LDC_unique.information2 '||r_LDC_unique.information2,10);
20812 hr_utility.set_location( 'r_LDC_unique.information3 '||r_LDC_unique.information3,10);
20813 -- If reuse objects flag is 'Y' then check for the object in the target business group
20814 -- if found insert the record into PLSql table and exit the loop else try create the
20815 -- object in the target business group
20816 --
20817 l_object_found_in_target := false ;
20818 --UPD START
20819 open c_LDC(r_LDC_unique.table_route_id,
20820 r_LDC_unique.information1,
20821 r_LDC_unique.information2,
20822 r_LDC_unique.information3 ) ;
20823 --
20824 fetch c_LDC into r_LDC ;
20825 --
20826 close c_LDC ;
20827 --
20828 l_dml_operation:= r_LDC_unique.dml_operation ;
20829 l_CVG_EFF_END_RL := get_fk('FORMULA_ID', r_LDC.INFORMATION263,l_dml_operation );
20830 l_CVG_EFF_STRT_RL := get_fk('FORMULA_ID', r_LDC.INFORMATION262,l_dml_operation );
20831 l_LER_CHG_DPNT_CVG_RL := get_fk('FORMULA_ID', r_LDC.INFORMATION258,l_dml_operation );
20832 l_LER_ID := get_fk('LER_ID', r_LDC.INFORMATION257,l_dml_operation );
20833 l_PGM_ID := get_fk('PGM_ID', r_LDC.INFORMATION260,l_dml_operation );
20834 l_PL_ID := get_fk('PL_ID', r_LDC.INFORMATION261,l_dml_operation );
20835 l_PTIP_ID := get_fk('PTIP_ID', r_LDC.INFORMATION259,l_dml_operation );
20836 --
20837 l_update := false;
20838 l_process_date := p_effective_date;
20839 --
20840 if l_dml_operation = 'UPDATE' then
20841 --
20842 l_object_found_in_target := TRUE;
20843 --
20844 if l_process_date between r_LDC_unique.information2 and r_LDC_unique.information3 then
20845 l_update := true;
20846 if r_LDC_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
20847 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_DPNT_CVG_ID'
20848 then
20849 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_DPNT_CVG_ID' ;
20850 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LDC_unique.information1 ;
20851 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LDC_unique.information1 ;
20852 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
20853 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LDC_unique.table_route_id;
20854 --
20855 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
20856 --
20857 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20858 --
20859 --DOUBT log_data('LDC',l_new_value,l_prefix || r_LDC_unique.name|| l_suffix,'REUSED');
20860 --
20861 end if ;
20862 hr_utility.set_location( 'found record for update',10);
20863 --
20864 else
20865 --
20866 l_update := false;
20867 --
20868 end if;
20869 else
20870 --
20871 --UPD END
20872 l_min_esd := null ;
20873 l_max_eed := null ;
20874 open c_LDC_min_max_dates(r_LDC_unique.table_route_id, r_LDC_unique.information1 ) ;
20875 fetch c_LDC_min_max_dates into l_min_esd,l_max_eed ;
20876 --
20877
20878 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20879 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
20880 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
20881 end if;
20882 l_min_esd := greatest(l_min_esd,r_LDC_unique.information2);
20883 /* open c_LDC(r_LDC_unique.table_route_id,
20884 r_LDC_unique.information1,
20885 r_LDC_unique.information2,
20886 r_LDC_unique.information3 ) ;
20887 --
20888 fetch c_LDC into r_LDC ;
20889 --
20890 close c_LDC ; */
20891 --
20892 if p_reuse_object_flag = 'Y' then
20893 if c_LDC_min_max_dates%found then
20894 -- cursor to find the object
20895 open c_find_LDC_in_target( l_min_esd,l_max_eed,
20896 p_target_business_group_id, nvl(l_ler_chg_dpnt_cvg_id, -999) ) ;
20897 fetch c_find_LDC_in_target into l_new_value ;
20898 if c_find_LDC_in_target%found then
20899 --
20900 --TEMPIK
20901 l_dt_rec_found := dt_api.check_min_max_dates
20902 (p_base_table_name => 'BEN_LER_CHG_DPNT_CVG_F',
20903 p_base_key_column => 'LER_CHG_DPNT_CVG_ID',
20904 p_base_key_value => l_new_value,
20905 p_from_date => l_min_esd,
20906 p_to_date => l_max_eed );
20907 if l_dt_rec_found THEN
20908 --END TEMPIK
20909 if r_LDC_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
20910 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_CHG_DPNT_CVG_ID' then
20911 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_DPNT_CVG_ID' ;
20912 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LDC_unique.information1 ;
20913 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
20914 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
20915 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LDC_unique.table_route_id;
20916 --
20917 -- 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) ;
20918 --
20919 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20920 end if ;
20921 --
20922 l_object_found_in_target := true ;
20923 --TEMPIK
20924 end if; -- l_dt_rec_found
20925 --END TEMPIK
20926 end if;
20927 close c_find_LDC_in_target ;
20928 --
20929 end if;
20930 end if ;
20931 --
20932 close c_LDC_min_max_dates ;
20933 end if; --if p_dml_operation
20934 --
20935 if not l_object_found_in_target OR l_update then
20936 --
20937 l_current_pk_id := r_LDC.information1;
20938 --
20939 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
20940 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
20941 --
20942 if l_current_pk_id = l_prev_pk_id then
20943 --
20944 l_first_rec := false ;
20945 --
20946 else
20947 --
20948 l_first_rec := true ;
20949 --
20950 end if ;
20951 --
20952
20953 l_effective_date := r_LDC.information2;
20954 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20955 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
20956 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
20957 end if;
20958
20959 if l_first_rec and not l_update then
20960 -- Call Create routine.
20961 hr_utility.set_location(' BEN_LER_CHG_DPNT_CVG_F CREATE_LER_CHG_DEPENDENT_CVG ',20);
20962 BEN_LER_CHG_DEPENDENT_CVG_API.CREATE_LER_CHG_DEPENDENT_CVG(
20963 --
20964 P_VALIDATE => false
20965 ,P_EFFECTIVE_DATE => l_effective_date
20966 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
20967 --
20968 ,P_ADD_RMV_CVG_CD => r_LDC.INFORMATION11
20969 ,P_CVG_EFF_END_CD => r_LDC.INFORMATION12
20970 ,P_CVG_EFF_END_RL => l_CVG_EFF_END_RL
20971 ,P_CVG_EFF_STRT_CD => r_LDC.INFORMATION13
20972 ,P_CVG_EFF_STRT_RL => l_CVG_EFF_STRT_RL
20973 ,P_LDC_ATTRIBUTE1 => r_LDC.INFORMATION111
20974 ,P_LDC_ATTRIBUTE10 => r_LDC.INFORMATION120
20975 ,P_LDC_ATTRIBUTE11 => r_LDC.INFORMATION121
20976 ,P_LDC_ATTRIBUTE12 => r_LDC.INFORMATION122
20977 ,P_LDC_ATTRIBUTE13 => r_LDC.INFORMATION123
20978 ,P_LDC_ATTRIBUTE14 => r_LDC.INFORMATION124
20979 ,P_LDC_ATTRIBUTE15 => r_LDC.INFORMATION125
20980 ,P_LDC_ATTRIBUTE16 => r_LDC.INFORMATION126
20981 ,P_LDC_ATTRIBUTE17 => r_LDC.INFORMATION127
20982 ,P_LDC_ATTRIBUTE18 => r_LDC.INFORMATION128
20983 ,P_LDC_ATTRIBUTE19 => r_LDC.INFORMATION129
20984 ,P_LDC_ATTRIBUTE2 => r_LDC.INFORMATION112
20985 ,P_LDC_ATTRIBUTE20 => r_LDC.INFORMATION130
20986 ,P_LDC_ATTRIBUTE21 => r_LDC.INFORMATION131
20987 ,P_LDC_ATTRIBUTE22 => r_LDC.INFORMATION132
20988 ,P_LDC_ATTRIBUTE23 => r_LDC.INFORMATION133
20989 ,P_LDC_ATTRIBUTE24 => r_LDC.INFORMATION134
20990 ,P_LDC_ATTRIBUTE25 => r_LDC.INFORMATION135
20991 ,P_LDC_ATTRIBUTE26 => r_LDC.INFORMATION136
20992 ,P_LDC_ATTRIBUTE27 => r_LDC.INFORMATION137
20993 ,P_LDC_ATTRIBUTE28 => r_LDC.INFORMATION138
20994 ,P_LDC_ATTRIBUTE29 => r_LDC.INFORMATION139
20995 ,P_LDC_ATTRIBUTE3 => r_LDC.INFORMATION113
20996 ,P_LDC_ATTRIBUTE30 => r_LDC.INFORMATION140
20997 ,P_LDC_ATTRIBUTE4 => r_LDC.INFORMATION114
20998 ,P_LDC_ATTRIBUTE5 => r_LDC.INFORMATION115
20999 ,P_LDC_ATTRIBUTE6 => r_LDC.INFORMATION116
21000 ,P_LDC_ATTRIBUTE7 => r_LDC.INFORMATION117
21001 ,P_LDC_ATTRIBUTE8 => r_LDC.INFORMATION118
21002 ,P_LDC_ATTRIBUTE9 => r_LDC.INFORMATION119
21003 ,P_LDC_ATTRIBUTE_CATEGORY => r_LDC.INFORMATION110
21004 ,P_LER_CHG_DPNT_CVG_CD => r_LDC.INFORMATION14
21005 ,P_LER_CHG_DPNT_CVG_ID => l_ler_chg_dpnt_cvg_id
21006 ,P_LER_CHG_DPNT_CVG_RL => l_LER_CHG_DPNT_CVG_RL
21007 ,P_LER_ID => l_LER_ID
21008 ,P_PGM_ID => l_PGM_ID
21009 ,P_PL_ID => l_PL_ID
21010 ,P_PTIP_ID => l_PTIP_ID
21011 --
21012 ,P_SUSP_IF_CTFN_NOT_PRVD_FLAG => nvl(r_LDC.INFORMATION198,'Y')
21013 ,P_CTFN_DETERMINE_CD => r_LDC.INFORMATION197
21014 ,P_EFFECTIVE_START_DATE => l_effective_start_date
21015 ,P_EFFECTIVE_END_DATE => l_effective_end_date
21016 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
21017 );
21018 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
21019 -- Update all relevent cer records with new pk_id
21020 hr_utility.set_location('Before plsql table ',222);
21021 hr_utility.set_location('new_value id '||l_ler_chg_dpnt_cvg_id,222);
21022 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_CHG_DPNT_CVG_ID' ;
21023 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LDC.information1 ;
21024 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LER_CHG_DPNT_CVG_ID ;
21025 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
21026 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LDC_unique.table_route_id;
21027 hr_utility.set_location('After plsql table ',222);
21028 --
21029 -- 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 ) ;
21030 --
21031 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21032 --
21033 else
21034 --
21035 -- Call Update routine for the pk_id created in prev run .
21036 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
21037 hr_utility.set_location(' BEN_LER_CHG_DPNT_CVG_F UPDATE_LER_CHG_DEPENDENT_CVG ',30);
21038 --UPD START
21039 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
21040 --
21041 if l_update then
21042 --
21043 l_datetrack_mode := r_LDC.datetrack_mode ;
21044 --
21045 get_dt_modes(
21046 p_effective_date => l_process_date,
21047 p_effective_end_date => r_LDC.information3,
21048 p_effective_start_date => r_LDC.information2,
21049 p_dml_operation => r_LDC.dml_operation,
21050 p_datetrack_mode => l_datetrack_mode );
21051 -- p_update => l_update
21052 --
21053 l_effective_date := l_process_date;
21054 l_LER_CHG_DPNT_CVG_ID := r_LDC.information1;
21055 l_object_version_number := r_LDC.information265;
21056 --
21057 end if;
21058 --
21059 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
21060 --
21061 IF l_update OR l_dml_operation <> 'UPDATE' THEN
21062 --UPD END
21063 BEN_LER_CHG_DEPENDENT_CVG_API.UPDATE_LER_CHG_DEPENDENT_CVG(
21064 --
21065 P_VALIDATE => false
21066 ,P_EFFECTIVE_DATE => l_effective_date
21067 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
21068 --
21069 ,P_ADD_RMV_CVG_CD => r_LDC.INFORMATION11
21070 ,P_CVG_EFF_END_CD => r_LDC.INFORMATION12
21071 ,P_CVG_EFF_END_RL => l_CVG_EFF_END_RL
21072 ,P_CVG_EFF_STRT_CD => r_LDC.INFORMATION13
21073 ,P_CVG_EFF_STRT_RL => l_CVG_EFF_STRT_RL
21074 ,P_LDC_ATTRIBUTE1 => r_LDC.INFORMATION111
21075 ,P_LDC_ATTRIBUTE10 => r_LDC.INFORMATION120
21076 ,P_LDC_ATTRIBUTE11 => r_LDC.INFORMATION121
21077 ,P_LDC_ATTRIBUTE12 => r_LDC.INFORMATION122
21078 ,P_LDC_ATTRIBUTE13 => r_LDC.INFORMATION123
21079 ,P_LDC_ATTRIBUTE14 => r_LDC.INFORMATION124
21080 ,P_LDC_ATTRIBUTE15 => r_LDC.INFORMATION125
21081 ,P_LDC_ATTRIBUTE16 => r_LDC.INFORMATION126
21082 ,P_LDC_ATTRIBUTE17 => r_LDC.INFORMATION127
21083 ,P_LDC_ATTRIBUTE18 => r_LDC.INFORMATION128
21084 ,P_LDC_ATTRIBUTE19 => r_LDC.INFORMATION129
21085 ,P_LDC_ATTRIBUTE2 => r_LDC.INFORMATION112
21086 ,P_LDC_ATTRIBUTE20 => r_LDC.INFORMATION130
21087 ,P_LDC_ATTRIBUTE21 => r_LDC.INFORMATION131
21088 ,P_LDC_ATTRIBUTE22 => r_LDC.INFORMATION132
21089 ,P_LDC_ATTRIBUTE23 => r_LDC.INFORMATION133
21090 ,P_LDC_ATTRIBUTE24 => r_LDC.INFORMATION134
21091 ,P_LDC_ATTRIBUTE25 => r_LDC.INFORMATION135
21092 ,P_LDC_ATTRIBUTE26 => r_LDC.INFORMATION136
21093 ,P_LDC_ATTRIBUTE27 => r_LDC.INFORMATION137
21094 ,P_LDC_ATTRIBUTE28 => r_LDC.INFORMATION138
21095 ,P_LDC_ATTRIBUTE29 => r_LDC.INFORMATION139
21096 ,P_LDC_ATTRIBUTE3 => r_LDC.INFORMATION113
21097 ,P_LDC_ATTRIBUTE30 => r_LDC.INFORMATION140
21098 ,P_LDC_ATTRIBUTE4 => r_LDC.INFORMATION114
21099 ,P_LDC_ATTRIBUTE5 => r_LDC.INFORMATION115
21100 ,P_LDC_ATTRIBUTE6 => r_LDC.INFORMATION116
21101 ,P_LDC_ATTRIBUTE7 => r_LDC.INFORMATION117
21102 ,P_LDC_ATTRIBUTE8 => r_LDC.INFORMATION118
21103 ,P_LDC_ATTRIBUTE9 => r_LDC.INFORMATION119
21104 ,P_LDC_ATTRIBUTE_CATEGORY => r_LDC.INFORMATION110
21105 ,P_LER_CHG_DPNT_CVG_CD => r_LDC.INFORMATION14
21106 ,P_LER_CHG_DPNT_CVG_ID => l_ler_chg_dpnt_cvg_id
21107 ,P_LER_CHG_DPNT_CVG_RL => l_LER_CHG_DPNT_CVG_RL
21108 ,P_LER_ID => l_LER_ID
21109 ,P_PGM_ID => l_PGM_ID
21110 ,P_PL_ID => l_PL_ID
21111 ,P_PTIP_ID => l_PTIP_ID
21112 --
21113 ,P_SUSP_IF_CTFN_NOT_PRVD_FLAG => nvl(r_LDC.INFORMATION198,'Y')
21114 ,P_CTFN_DETERMINE_CD => r_LDC.INFORMATION197
21115 ,P_EFFECTIVE_START_DATE => l_effective_start_date
21116 ,P_EFFECTIVE_END_DATE => l_effective_end_date
21117 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
21118 ,P_DATETRACK_MODE => l_datetrack_mode
21119 );
21120 --
21121 end if; -- l_update
21122 end if;
21123 --
21124 -- Delete the row if it is end dated.
21125 --
21126 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
21127 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
21128 trunc(l_max_eed) = r_LDC.information3) then
21129 --
21130 BEN_LER_CHG_DEPENDENT_CVG_API.delete_LER_CHG_DEPENDENT_CVG(
21131 --
21132 p_validate => false
21133 ,p_ler_chg_dpnt_cvg_id => l_ler_chg_dpnt_cvg_id
21134 ,p_effective_start_date => l_effective_start_date
21135 ,p_effective_end_date => l_effective_end_date
21136 ,p_object_version_number => l_object_version_number
21137 ,p_effective_date => l_max_eed
21138 ,p_datetrack_mode => hr_api.g_delete
21139 --
21140 );
21141 --
21142 end if;
21143 --
21144 l_prev_pk_id := l_current_pk_id ;
21145 --
21146 end if;
21147 --
21148 end if;
21149 --
21150 end loop;
21151 --
21152 exception when others then
21153 --
21154 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LDC',r_ldc.information5 );
21155 --
21156 end create_LDC_rows;
21157
21158 ---------------------------------------------------------------
21159 ----------------------< create_PAT_rows >-----------------------
21160 ---------------------------------------------------------------
21161 --
21162 procedure create_PAT_rows
21163 (
21164 p_validate in number default 0
21165 ,p_copy_entity_txn_id in number
21166 ,p_effective_date in date
21167 ,p_prefix_suffix_text in varchar2 default null
21168 ,p_reuse_object_flag in varchar2 default null
21169 ,p_target_business_group_id in varchar2 default null
21170 ,p_prefix_suffix_cd in varchar2 default null
21171 ) is
21172 --
21173 l_ACTN_TYP_DUE_DT_RL number;
21174 l_ACTN_TYP_ID number;
21175 l_PGM_ID number;
21176 l_PL_ID number;
21177 cursor c_unique_PAT(l_table_alias varchar2) is
21178 select distinct cpe.information1,
21179 cpe.information2,
21180 cpe.information3,
21181 cpe.table_route_id
21182 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
21183 pqh_table_route tr
21184 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21185 and cpe.table_route_id = tr.table_route_id
21186 -- and tr.where_clause = l_BEN_POPL_ACTN_TYP_F
21187 and tr.table_alias = l_table_alias
21188 and cpe.number_of_copies = 1 -- ADDITION
21189 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
21190 order by information1, information2; --added for bug: 5151945
21191 --
21192 --
21193 cursor c_PAT_min_max_dates(c_table_route_id number,
21194 c_information1 number) is
21195 select
21196 min(cpe.information2) min_esd,
21197 max(cpe.information3) min_eed
21198 from ben_copy_entity_results cpe
21199 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21200 and cpe.table_route_id = c_table_route_id
21201 and cpe.information1 = c_information1 ;
21202 --
21203 cursor c_PAT(c_table_route_id number,
21204 c_information1 number,
21205 c_information2 date,
21206 c_information3 date ) is
21207 select
21208 cpe.*
21209 from ben_copy_entity_results cpe
21210 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21211 and cpe.table_route_id = c_table_route_id
21212 and cpe.information1 = c_information1
21213 and cpe.information2 = c_information2
21214 and cpe.information3 = c_information3
21215 and rownum = 1 ;
21216 -- Date Track target record
21217 cursor c_find_PAT_in_target( c_effective_start_date date,
21218 c_effective_end_date date,
21219 c_business_group_id number,
21220 c_new_pk_id number) is
21221 select
21222 PAT.popl_actn_typ_id new_value
21223 from BEN_POPL_ACTN_TYP_F PAT
21224 where NVL(PAT.PGM_ID,-999) = nvl(l_PGM_ID,-999)
21225 and NVL(PAT.PL_ID,-999) = nvl(l_PL_ID ,-999)
21226 and PAT.ACTN_TYP_ID = l_ACTN_TYP_ID
21227 and PAT.business_group_id = c_business_group_id
21228 and PAT.popl_actn_typ_id <> c_new_pk_id
21229 --TEMPIK
21230 and c_effective_start_date between effective_start_date
21231 and effective_end_date ;
21232 --END TEMPIK
21233 /*
21234 and exists ( select null
21235 from BEN_POPL_ACTN_TYP_F PAT1
21236 where NVL(PAT1.PGM_ID,-999) = nvl(l_PGM_ID,-999)
21237 and NVL(PAT1.PL_ID,-999) = nvl(l_PL_ID ,-999)
21238 and PAT1.ACTN_TYP_ID = l_ACTN_TYP_ID
21239 and PAT1.business_group_id = c_business_group_id
21240 and PAT1.effective_start_date <= c_effective_start_date )
21241 and exists ( select null
21242 from BEN_POPL_ACTN_TYP_F PAT2
21243 where NVL(PAT2.PGM_ID,-999) = nvl(l_PGM_ID,-999)
21244 and NVL(PAT2.PL_ID,-999) = nvl(l_PL_ID ,-999)
21245 and PAT2.ACTN_TYP_ID = l_ACTN_TYP_ID
21246 and PAT2.business_group_id = c_business_group_id
21247 and PAT2.effective_end_date >= c_effective_end_date )
21248 ;
21249 */
21250 --
21251 --UPD START
21252 --
21253 l_update boolean := false ;
21254 l_datetrack_mode varchar2(80) := hr_api.g_update;
21255 l_process_date date;
21256 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
21257 --
21258 --UPD END
21259 l_current_pk_id number := null ;
21260 l_prev_pk_id number := null ;
21261 l_first_rec boolean := true ;
21262 r_PAT c_PAT%rowtype;
21263 l_popl_actn_typ_id number ;
21264 l_object_version_number number ;
21265 l_effective_start_date date ;
21266 l_effective_end_date date ;
21267 l_prefix pqh_copy_entity_attribs.information1%type := null;
21268 l_suffix pqh_copy_entity_attribs.information1%type := null;
21269 l_new_value number(15);
21270 l_object_found_in_target boolean := false ;
21271 l_min_esd date;
21272 l_max_eed date;
21273 l_effective_date date;
21274 --TEMPIK
21275 l_dt_rec_found boolean ;
21276 --END TEMPIK
21277 --
21278 begin
21279 -- Initialization
21280 l_object_found_in_target := false ;
21281 -- End Initialization
21282 -- Derive the prefix - sufix
21283 if p_prefix_suffix_cd = 'PREFIX' then
21284 l_prefix := p_prefix_suffix_text ;
21285 elsif p_prefix_suffix_cd = 'SUFFIX' then
21286 l_suffix := p_prefix_suffix_text ;
21287 else
21288 l_prefix := null ;
21289 l_suffix := null ;
21290 end if ;
21291 -- End Prefix Sufix derivation
21292 for r_PAT_unique in c_unique_PAT('PAT') loop
21293
21294 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
21295 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21296 r_PAT_unique.information3 >=
21297 ben_pd_copy_to_ben_one.g_copy_effective_date)
21298 ) then
21299
21300 --
21301 hr_utility.set_location(' r_PAT_unique.table_route_id '||r_PAT_unique.table_route_id,10);
21302 hr_utility.set_location(' r_PAT_unique.information1 '||r_PAT_unique.information1,10);
21303 hr_utility.set_location( 'r_PAT_unique.information2 '||r_PAT_unique.information2,10);
21304 hr_utility.set_location( 'r_PAT_unique.information3 '||r_PAT_unique.information3,10);
21305 -- If reuse objects flag is 'Y' then check for the object in the target business group
21306 -- if found insert the record into PLSql table and exit the loop else try create the
21307 -- object in the target business group
21308 --
21309 l_object_found_in_target := false ;
21310 --UPD START
21311 open c_PAT(r_PAT_unique.table_route_id,
21312 r_PAT_unique.information1,
21313 r_PAT_unique.information2,
21314 r_PAT_unique.information3 ) ;
21315 --
21316 fetch c_PAT into r_PAT ;
21317 --
21318 close c_PAT ;
21319 --
21320 l_dml_operation:= r_PAT_unique.dml_operation ;
21321 l_ACTN_TYP_DUE_DT_RL := get_fk('FORMULA_ID', r_PAT.INFORMATION262,l_dml_operation );
21322 l_ACTN_TYP_ID := get_fk('ACTN_TYP_ID', r_PAT.INFORMATION221,l_dml_operation );
21323 l_PGM_ID := get_fk('PGM_ID', r_PAT.INFORMATION260,l_dml_operation );
21324 l_PL_ID := get_fk('PL_ID', r_PAT.INFORMATION261,l_dml_operation );
21325 --
21326 l_update := false;
21327 l_process_date := p_effective_date;
21328
21329 --
21330 if l_dml_operation = 'UPDATE' then
21331 --
21332 l_object_found_in_target := TRUE;
21333 --
21334 if l_process_date between r_PAT_unique.information2 and r_PAT_unique.information3 then
21335 l_update := true;
21336 if r_PAT_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
21337 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'POPL_ACTN_TYP_ID'
21338 then
21339 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ACTN_TYP_ID' ;
21340 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PAT_unique.information1 ;
21341 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PAT_unique.information1 ;
21342 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
21343 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PAT_unique.table_route_id;
21344 --
21345 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
21346 --
21347 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21348 --
21349 --DOUBT log_data('PAT',l_new_value,l_prefix || r_PAT_unique.name|| l_suffix,'REUSED');
21350 --
21351 end if ;
21352 hr_utility.set_location( 'found record for update',10);
21353 --
21354 else
21355 --
21356 l_update := false;
21357 --
21358 end if;
21359 else
21360 --
21361 --UPD END
21362 l_min_esd := null ;
21363 l_max_eed := null ;
21364 open c_PAT_min_max_dates(r_PAT_unique.table_route_id, r_PAT_unique.information1 ) ;
21365 fetch c_PAT_min_max_dates into l_min_esd,l_max_eed ;
21366 --
21367
21368 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21369 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
21370 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
21371 end if;
21372 l_min_esd := greatest(l_min_esd,r_PAT_unique.information2);
21373 /* open c_PAT(r_PAT_unique.table_route_id,
21374 r_PAT_unique.information1,
21375 r_PAT_unique.information2,
21376 r_PAT_unique.information3 ) ;
21377 --
21378 fetch c_PAT into r_PAT ;
21379 --
21380 close c_PAT ; */
21381 --
21382 --
21383 if l_ACTN_TYP_ID is null then
21384 close c_PAT_min_max_dates;
21385 else
21386
21387 if p_reuse_object_flag = 'Y' then
21388 if c_PAT_min_max_dates%found then
21389 -- cursor to find the object
21390 open c_find_PAT_in_target( l_min_esd,l_max_eed,
21391 p_target_business_group_id, nvl(l_popl_actn_typ_id, -999) ) ;
21392 fetch c_find_PAT_in_target into l_new_value ;
21393 if c_find_PAT_in_target%found then
21394 --
21395 --TEMPIK
21396 l_dt_rec_found := dt_api.check_min_max_dates
21397 (p_base_table_name => 'BEN_POPL_ACTN_TYP_F',
21398 p_base_key_column => 'POPL_ACTN_TYP_ID',
21399 p_base_key_value => l_new_value,
21400 p_from_date => l_min_esd,
21401 p_to_date => l_max_eed );
21402 if l_dt_rec_found THEN
21403 --END TEMPIK
21404 if r_PAT_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
21405 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'POPL_ACTN_TYP_ID' then
21406 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ACTN_TYP_ID' ;
21407 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PAT_unique.information1 ;
21408 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
21409 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
21410 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PAT_unique.table_route_id;
21411 --
21412 -- 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) ;
21413 --
21414 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21415 end if ;
21416 --
21417 l_object_found_in_target := true ;
21418 --TEMPIK
21419 end if; -- l_dt_rec_found
21420 --END TEMPIK
21421 end if;
21422 close c_find_PAT_in_target ;
21423 --
21424 end if;
21425 end if ;
21426 --
21427 close c_PAT_min_max_dates ;
21428 end if; --if p_dml_operation
21429 --
21430 if (not l_object_found_in_target OR l_update ) and l_ACTN_TYP_ID is not null then
21431 --
21432 l_current_pk_id := r_PAT.information1;
21433 --
21434 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
21435 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
21436 --
21437 if l_current_pk_id = l_prev_pk_id then
21438 --
21439 l_first_rec := false ;
21440 --
21441 else
21442 --
21443 l_first_rec := true ;
21444 --
21445 end if ;
21446 --
21447
21448 l_effective_date := r_PAT.information2;
21449 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21450 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
21451 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
21452 end if;
21453
21454 if l_first_rec and not l_update then
21455 -- Call Create routine.
21456 hr_utility.set_location(' BEN_POPL_ACTN_TYP_F CREATE_POPL_ACTION_TYPE ',20);
21457 BEN_POPL_ACTION_TYPE_API.CREATE_POPL_ACTION_TYPE(
21458 --
21459 P_VALIDATE => false
21460 ,P_EFFECTIVE_DATE => l_effective_date
21461 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
21462 --
21463 ,P_ACTN_TYP_DUE_DT_CD => r_PAT.INFORMATION11
21464 ,P_ACTN_TYP_DUE_DT_RL => l_ACTN_TYP_DUE_DT_RL
21465 ,P_ACTN_TYP_ID => l_ACTN_TYP_ID
21466 ,P_PAT_ATTRIBUTE1 => r_PAT.INFORMATION111
21467 ,P_PAT_ATTRIBUTE10 => r_PAT.INFORMATION120
21468 ,P_PAT_ATTRIBUTE11 => r_PAT.INFORMATION121
21469 ,P_PAT_ATTRIBUTE12 => r_PAT.INFORMATION122
21470 ,P_PAT_ATTRIBUTE13 => r_PAT.INFORMATION123
21471 ,P_PAT_ATTRIBUTE14 => r_PAT.INFORMATION124
21472 ,P_PAT_ATTRIBUTE15 => r_PAT.INFORMATION125
21473 ,P_PAT_ATTRIBUTE16 => r_PAT.INFORMATION126
21474 ,P_PAT_ATTRIBUTE17 => r_PAT.INFORMATION127
21475 ,P_PAT_ATTRIBUTE18 => r_PAT.INFORMATION128
21476 ,P_PAT_ATTRIBUTE19 => r_PAT.INFORMATION129
21477 ,P_PAT_ATTRIBUTE2 => r_PAT.INFORMATION112
21478 ,P_PAT_ATTRIBUTE20 => r_PAT.INFORMATION130
21479 ,P_PAT_ATTRIBUTE21 => r_PAT.INFORMATION131
21480 ,P_PAT_ATTRIBUTE22 => r_PAT.INFORMATION132
21481 ,P_PAT_ATTRIBUTE23 => r_PAT.INFORMATION133
21482 ,P_PAT_ATTRIBUTE24 => r_PAT.INFORMATION134
21483 ,P_PAT_ATTRIBUTE25 => r_PAT.INFORMATION135
21484 ,P_PAT_ATTRIBUTE26 => r_PAT.INFORMATION136
21485 ,P_PAT_ATTRIBUTE27 => r_PAT.INFORMATION137
21486 ,P_PAT_ATTRIBUTE28 => r_PAT.INFORMATION138
21487 ,P_PAT_ATTRIBUTE29 => r_PAT.INFORMATION139
21488 ,P_PAT_ATTRIBUTE3 => r_PAT.INFORMATION113
21489 ,P_PAT_ATTRIBUTE30 => r_PAT.INFORMATION140
21490 ,P_PAT_ATTRIBUTE4 => r_PAT.INFORMATION114
21491 ,P_PAT_ATTRIBUTE5 => r_PAT.INFORMATION115
21492 ,P_PAT_ATTRIBUTE6 => r_PAT.INFORMATION116
21493 ,P_PAT_ATTRIBUTE7 => r_PAT.INFORMATION117
21494 ,P_PAT_ATTRIBUTE8 => r_PAT.INFORMATION118
21495 ,P_PAT_ATTRIBUTE9 => r_PAT.INFORMATION119
21496 ,P_PAT_ATTRIBUTE_CATEGORY => r_PAT.INFORMATION110
21497 ,P_PGM_ID => l_PGM_ID
21498 ,P_PL_ID => l_PL_ID
21499 ,P_POPL_ACTN_TYP_ID => l_popl_actn_typ_id
21500 --
21501 ,P_EFFECTIVE_START_DATE => l_effective_start_date
21502 ,P_EFFECTIVE_END_DATE => l_effective_end_date
21503 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
21504 );
21505 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
21506 -- Update all relevent cer records with new pk_id
21507 hr_utility.set_location('Before plsql table ',222);
21508 hr_utility.set_location('new_value id '||l_popl_actn_typ_id,222);
21509 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ACTN_TYP_ID' ;
21510 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PAT.information1 ;
21511 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_POPL_ACTN_TYP_ID ;
21512 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
21513 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PAT_unique.table_route_id;
21514 hr_utility.set_location('After plsql table ',222);
21515 --
21516 -- 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 ) ;
21517 --
21518 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21519 --
21520 else
21521 --
21522 -- Call Update routine for the pk_id created in prev run .
21523 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
21524 hr_utility.set_location(' BEN_POPL_ACTN_TYP_F UPDATE_POPL_ACTION_TYPE ',30);
21525 --UPD START
21526 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
21527 --
21528 if l_update then
21529 --
21530 l_datetrack_mode := r_PAT.datetrack_mode ;
21531 --
21532 get_dt_modes(
21533 p_effective_date => l_process_date,
21534 p_effective_end_date => r_PAT.information3,
21535 p_effective_start_date => r_PAT.information2,
21536 p_dml_operation => r_PAT.dml_operation,
21537 p_datetrack_mode => l_datetrack_mode );
21538 -- p_update => l_update
21539 --
21540 l_effective_date := l_process_date;
21541 l_POPL_ACTN_TYP_ID := r_PAT.information1;
21542 l_object_version_number := r_PAT.information265;
21543 --
21544 end if;
21545 --
21546 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
21547 --
21548 IF l_update OR l_dml_operation <> 'UPDATE' THEN
21549 --UPD END
21550 BEN_POPL_ACTION_TYPE_API.UPDATE_POPL_ACTION_TYPE(
21551 --
21552 P_VALIDATE => false
21553 ,P_EFFECTIVE_DATE => l_effective_date
21554 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
21555 --
21556 ,P_ACTN_TYP_DUE_DT_CD => r_PAT.INFORMATION11
21557 ,P_ACTN_TYP_DUE_DT_RL => l_ACTN_TYP_DUE_DT_RL
21558 ,P_ACTN_TYP_ID => l_ACTN_TYP_ID
21559 ,P_PAT_ATTRIBUTE1 => r_PAT.INFORMATION111
21560 ,P_PAT_ATTRIBUTE10 => r_PAT.INFORMATION120
21561 ,P_PAT_ATTRIBUTE11 => r_PAT.INFORMATION121
21562 ,P_PAT_ATTRIBUTE12 => r_PAT.INFORMATION122
21563 ,P_PAT_ATTRIBUTE13 => r_PAT.INFORMATION123
21564 ,P_PAT_ATTRIBUTE14 => r_PAT.INFORMATION124
21565 ,P_PAT_ATTRIBUTE15 => r_PAT.INFORMATION125
21566 ,P_PAT_ATTRIBUTE16 => r_PAT.INFORMATION126
21567 ,P_PAT_ATTRIBUTE17 => r_PAT.INFORMATION127
21568 ,P_PAT_ATTRIBUTE18 => r_PAT.INFORMATION128
21569 ,P_PAT_ATTRIBUTE19 => r_PAT.INFORMATION129
21570 ,P_PAT_ATTRIBUTE2 => r_PAT.INFORMATION112
21571 ,P_PAT_ATTRIBUTE20 => r_PAT.INFORMATION130
21572 ,P_PAT_ATTRIBUTE21 => r_PAT.INFORMATION131
21573 ,P_PAT_ATTRIBUTE22 => r_PAT.INFORMATION132
21574 ,P_PAT_ATTRIBUTE23 => r_PAT.INFORMATION133
21575 ,P_PAT_ATTRIBUTE24 => r_PAT.INFORMATION134
21576 ,P_PAT_ATTRIBUTE25 => r_PAT.INFORMATION135
21577 ,P_PAT_ATTRIBUTE26 => r_PAT.INFORMATION136
21578 ,P_PAT_ATTRIBUTE27 => r_PAT.INFORMATION137
21579 ,P_PAT_ATTRIBUTE28 => r_PAT.INFORMATION138
21580 ,P_PAT_ATTRIBUTE29 => r_PAT.INFORMATION139
21581 ,P_PAT_ATTRIBUTE3 => r_PAT.INFORMATION113
21582 ,P_PAT_ATTRIBUTE30 => r_PAT.INFORMATION140
21583 ,P_PAT_ATTRIBUTE4 => r_PAT.INFORMATION114
21584 ,P_PAT_ATTRIBUTE5 => r_PAT.INFORMATION115
21585 ,P_PAT_ATTRIBUTE6 => r_PAT.INFORMATION116
21586 ,P_PAT_ATTRIBUTE7 => r_PAT.INFORMATION117
21587 ,P_PAT_ATTRIBUTE8 => r_PAT.INFORMATION118
21588 ,P_PAT_ATTRIBUTE9 => r_PAT.INFORMATION119
21589 ,P_PAT_ATTRIBUTE_CATEGORY => r_PAT.INFORMATION110
21590 ,P_PGM_ID => l_PGM_ID
21591 ,P_PL_ID => l_PL_ID
21592 ,P_POPL_ACTN_TYP_ID => l_popl_actn_typ_id
21593 --
21594 ,P_EFFECTIVE_START_DATE => l_effective_start_date
21595 ,P_EFFECTIVE_END_DATE => l_effective_end_date
21596 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
21597 ,P_DATETRACK_MODE => l_datetrack_mode
21598 );
21599 --
21600 end if; -- l_update
21601 end if;
21602 --
21603 -- Delete the row if it is end dated.
21604 --
21605 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
21606 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
21607 trunc(l_max_eed) = r_PAT.information3) then
21608 --
21609 BEN_POPL_ACTION_TYPE_API.delete_POPL_ACTION_TYPE(
21610 --
21611 p_validate => false
21612 ,p_popl_actn_typ_id => l_popl_actn_typ_id
21613 ,p_effective_start_date => l_effective_start_date
21614 ,p_effective_end_date => l_effective_end_date
21615 ,p_object_version_number => l_object_version_number
21616 ,p_effective_date => l_max_eed
21617 ,p_datetrack_mode => hr_api.g_delete
21618 --
21619 );
21620 --
21621 end if;
21622 --
21623 l_prev_pk_id := l_current_pk_id ;
21624 --
21625 end if;
21626 --
21627 end if;
21628 --
21629 end if;
21630 --
21631 end loop;
21632 --
21633 exception when others then
21634 --
21635 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PAT',r_pat.information5 );
21636 --
21637 end create_PAT_rows;
21638 --
21639 ---------------------------------------------------------------
21640 ----------------------< create_PEO_rows >-----------------------
21641 ---------------------------------------------------------------
21642 --
21643 procedure create_PEO_rows
21644 (
21645 p_validate in number default 0
21646 ,p_copy_entity_txn_id in number
21647 ,p_effective_date in date
21648 ,p_prefix_suffix_text in varchar2 default null
21649 ,p_reuse_object_flag in varchar2 default null
21650 ,p_target_business_group_id in varchar2 default null
21651 ,p_prefix_suffix_cd in varchar2 default null
21652 ) is
21653 --
21654 l_LER_ID number;
21655 l_MX_POE_DET_DT_RL number;
21656 l_MX_POE_RL number;
21657 l_OIPL_ID number;
21658 l_PGM_ID number;
21659 l_PLIP_ID number;
21660 l_PL_ID number;
21661 l_PRTN_EFF_END_DT_RL number;
21662 l_PRTN_EFF_STRT_DT_RL number;
21663 l_PTIP_ID number;
21664 l_VRFY_FMLY_MMBR_RL number;
21665 l_WAIT_PERD_DT_TO_USE_RL number;
21666 l_WAIT_PERD_RL number;
21667 cursor c_unique_PEO(l_table_alias varchar2) is
21668 select distinct cpe.information1,
21669 cpe.information2,
21670 cpe.information3,
21671 cpe.table_route_id
21672 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
21673 pqh_table_route tr
21674 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21675 and cpe.table_route_id = tr.table_route_id
21676 -- and tr.where_clause = l_BEN_ELIG_TO_PRTE_RSN_F
21677 and tr.table_alias = l_table_alias
21678 and cpe.number_of_copies = 1 -- ADDITION
21679 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
21680 order by information1, information2; --added for bug: 5151945
21681 --
21682 --
21683 cursor c_PEO_min_max_dates(c_table_route_id number,
21684 c_information1 number) is
21685 select
21686 min(cpe.information2) min_esd,
21687 max(cpe.information3) min_eed
21688 from ben_copy_entity_results cpe
21689 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21690 and cpe.table_route_id = c_table_route_id
21691 and cpe.information1 = c_information1 ;
21692 --
21693 cursor c_PEO(c_table_route_id number,
21694 c_information1 number,
21695 c_information2 date,
21696 c_information3 date) is
21697 select
21698 cpe.*
21699 from ben_copy_entity_results cpe
21700 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21701 and cpe.table_route_id = c_table_route_id
21702 and cpe.information1 = c_information1
21703 and cpe.information2 = c_information2
21704 and cpe.information3 = c_information3
21705 and rownum = 1 ;
21706 -- Date Track target record
21707 cursor c_find_PEO_in_target(
21708 c_effective_start_date date,
21709 c_effective_end_date date,
21710 c_business_group_id number,
21711 c_new_pk_id number) is
21712 select
21713 PEO.elig_to_prte_rsn_id new_value
21714 from BEN_ELIG_TO_PRTE_RSN_F PEO
21715 where
21716 PEO.LER_ID = l_LER_ID and
21717 nvl(PEO.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
21718 nvl(PEO.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
21719 nvl(PEO.PLIP_ID,-999) = nvl(l_PLIP_ID,-999) and
21720 nvl(PEO.PL_ID,-999) = nvl(l_PL_ID,-999) and
21721 nvl(PEO.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
21722 PEO.business_group_id = c_business_group_id
21723 and PEO.elig_to_prte_rsn_id <> c_new_pk_id
21724 --TEMPIK
21725 and c_effective_start_date between effective_start_date
21726 and effective_end_date ;
21727 --END TEMPIK
21728 /*
21729 and exists ( select null
21730 from BEN_ELIG_TO_PRTE_RSN_F PEO1
21731 where
21732 PEO1.LER_ID = l_LER_ID and
21733 nvl(PEO1.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
21734 nvl(PEO1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
21735 nvl(PEO1.PLIP_ID,-999) = nvl(l_PLIP_ID,-999) and
21736 nvl(PEO1.PL_ID,-999) = nvl(l_PL_ID,-999) and
21737 nvl(PEO1.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
21738 PEO1.business_group_id = c_business_group_id
21739 and PEO1.effective_start_date <= c_effective_start_date )
21740 and exists ( select null
21741 from BEN_ELIG_TO_PRTE_RSN_F PEO2
21742 where
21743 PEO2.LER_ID = l_LER_ID and
21744 nvl(PEO2.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
21745 nvl(PEO2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
21746 nvl(PEO2.PLIP_ID,-999) = nvl(l_PLIP_ID,-999) and
21747 nvl(PEO2.PL_ID,-999) = nvl(l_PL_ID,-999) and
21748 nvl(PEO2.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
21749 PEO2.business_group_id = c_business_group_id
21750 and PEO2.effective_end_date >= c_effective_end_date )
21751 ;
21752 */
21753 --
21754 --UPD START
21755 --
21756 l_update boolean := false ;
21757 l_datetrack_mode varchar2(80) := hr_api.g_update;
21758 l_process_date date;
21759 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
21760 --
21761 --UPD END
21762 l_current_pk_id number := null ;
21763 l_prev_pk_id number := null ;
21764 l_first_rec boolean := true ;
21765 r_PEO c_PEO%rowtype;
21766 l_elig_to_prte_rsn_id number ;
21767 l_object_version_number number ;
21768 l_effective_start_date date ;
21769 l_effective_end_date date ;
21770 l_prefix pqh_copy_entity_attribs.information1%type := null;
21771 l_suffix pqh_copy_entity_attribs.information1%type := null;
21772 l_new_value number(15);
21773 l_object_found_in_target boolean := false ;
21774 l_min_esd date;
21775 l_max_eed date;
21776 l_effective_date date;
21777 --TEMPIK
21778 l_dt_rec_found boolean ;
21779 --END TEMPIK
21780 --
21781 begin
21782 -- Initialization
21783 l_object_found_in_target := false ;
21784 -- End Initialization
21785 -- Derive the prefix - sufix
21786 if p_prefix_suffix_cd = 'PREFIX' then
21787 l_prefix := p_prefix_suffix_text ;
21788 elsif p_prefix_suffix_cd = 'SUFFIX' then
21789 l_suffix := p_prefix_suffix_text ;
21790 else
21791 l_prefix := null ;
21792 l_suffix := null ;
21793 end if ;
21794 -- End Prefix Sufix derivation
21795 for r_PEO_unique in c_unique_PEO('PEO') loop
21796
21797 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
21798 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21799 r_PEO_unique.information3 >=
21800 ben_pd_copy_to_ben_one.g_copy_effective_date)
21801 ) then
21802
21803 --
21804 hr_utility.set_location(' r_PEO_unique.table_route_id '||r_PEO_unique.table_route_id,10);
21805 hr_utility.set_location(' r_PEO_unique.information1 '||r_PEO_unique.information1,10);
21806 hr_utility.set_location( 'r_PEO_unique.information2 '||r_PEO_unique.information2,10);
21807 hr_utility.set_location( 'r_PEO_unique.information3 '||r_PEO_unique.information3,10);
21808 -- If reuse objects flag is 'Y' then check for the object in the target business group
21809 -- if found insert the record into PLSql table and exit the loop else try create the
21810 -- object in the target business group
21811 --
21812 l_object_found_in_target := false ;
21813 --UPD START
21814 open c_PEO(r_PEO_unique.table_route_id,
21815 r_PEO_unique.information1,
21816 r_PEO_unique.information2,
21817 r_PEO_unique.information3 ) ;
21818 --
21819 fetch c_PEO into r_PEO ;
21820 --
21821 close c_PEO ;
21822 --
21823 l_dml_operation:= r_PEO_unique.dml_operation ;
21824 l_LER_ID := get_fk('LER_ID', r_PEO.information257,l_dml_operation );
21825 hr_utility.set_location(' l_LER_ID '||l_LER_ID ,123);
21826 l_MX_POE_DET_DT_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION272,l_dml_operation );
21827 l_MX_POE_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION270,l_dml_operation );
21828 l_OIPL_ID := get_fk('OIPL_ID', r_PEO.INFORMATION258,l_dml_operation );
21829 l_PGM_ID := get_fk('PGM_ID', r_PEO.INFORMATION260,l_dml_operation );
21830 l_PLIP_ID := get_fk('PLIP_ID', r_PEO.INFORMATION256,l_dml_operation );
21831 l_PL_ID := get_fk('PL_ID', r_PEO.INFORMATION261,l_dml_operation );
21832 l_PRTN_EFF_END_DT_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION266,l_dml_operation );
21833 l_PRTN_EFF_STRT_DT_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION264,l_dml_operation );
21834 l_PTIP_ID := get_fk('PTIP_ID', r_PEO.INFORMATION259,l_dml_operation );
21835 l_VRFY_FMLY_MMBR_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION273,l_dml_operation );
21836 l_WAIT_PERD_DT_TO_USE_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION268,l_dml_operation );
21837 l_WAIT_PERD_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION271,l_dml_operation );
21838 --
21839 l_update := false;
21840 l_process_date := p_effective_date;
21841 --
21842 if l_dml_operation = 'UPDATE' then
21843 --
21844 l_object_found_in_target := TRUE;
21845 --
21846 if l_process_date between r_PEO_unique.information2 and r_PEO_unique.information3 then
21847 l_update := true;
21848 if r_PEO_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
21849 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_TO_PRTE_RSN_ID'
21850 then
21851 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_TO_PRTE_RSN_ID' ;
21852 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PEO_unique.information1 ;
21853 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PEO_unique.information1 ;
21854 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
21855 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PEO_unique.table_route_id;
21856 --
21857 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
21858 --
21859 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21860 --
21861 --DOUBT log_data('PEO',l_new_value,l_prefix || r_PEO_unique.name|| l_suffix,'REUSED');
21862 --
21863 end if ;
21864 hr_utility.set_location( 'found record for update',10);
21865 --
21866 else
21867 --
21868 l_update := false;
21869 --
21870 end if;
21871 else
21872 --
21873 --UPD END
21874 l_min_esd := null ;
21875 l_max_eed := null ;
21876 open c_PEO_min_max_dates(r_PEO_unique.table_route_id, r_PEO_unique.information1 ) ;
21877 fetch c_PEO_min_max_dates into l_min_esd,l_max_eed ;
21878 --
21879
21880 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21881 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
21882 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
21883 end if;
21884 l_min_esd := greatest(l_min_esd,r_PEO_unique.information2);
21885 /* open c_PEO(r_PEO_unique.table_route_id,
21886 r_PEO_unique.information1,
21887 r_PEO_unique.information2,
21888 r_PEO_unique.information3 ) ;
21889 --
21890 fetch c_PEO into r_PEO ;
21891 --
21892 close c_PEO ; */
21893 --
21894 hr_utility.set_location('g_count '||BEN_PD_COPY_TO_BEN_ONE.g_count,123);
21895 hr_utility.set_location('r_PEO.information14 '||r_PEO.information14 ,123);
21896 --
21897
21898 if p_reuse_object_flag = 'Y' then
21899 if c_PEO_min_max_dates%found then
21900 -- cursor to find the object
21901 open c_find_PEO_in_target( l_min_esd,l_max_eed,
21902 p_target_business_group_id, nvl(l_elig_to_prte_rsn_id, -999) ) ;
21903 fetch c_find_PEO_in_target into l_new_value ;
21904 if c_find_PEO_in_target%found then
21905 --
21906 --TEMPIK
21907 l_dt_rec_found := dt_api.check_min_max_dates
21908 (p_base_table_name => 'BEN_ELIG_TO_PRTE_RSN_F',
21909 p_base_key_column => 'ELIG_TO_PRTE_RSN_ID',
21910 p_base_key_value => l_new_value,
21911 p_from_date => l_min_esd,
21912 p_to_date => l_max_eed );
21913 if l_dt_rec_found THEN
21914 --END TEMPIK
21915 if r_PEO_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
21916 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ELIG_TO_PRTE_RSN_ID' then
21917 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_TO_PRTE_RSN_ID' ;
21918 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PEO_unique.information1 ;
21919 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
21920 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
21921 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PEO_unique.table_route_id;
21922 --
21923 -- 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) ;
21924 --
21925 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21926 end if ;
21927 --
21928 l_object_found_in_target := true ;
21929 --TEMPIK
21930 end if; -- l_dt_rec_found
21931 --END TEMPIK
21932 end if;
21933 close c_find_PEO_in_target ;
21934 --
21935 end if;
21936 end if ;
21937 --
21938 close c_PEO_min_max_dates ;
21939 end if; --if p_dml_operation
21940 --
21941 if not l_object_found_in_target OR l_update then
21942 --
21943 l_current_pk_id := r_PEO.information1;
21944 --
21945 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
21946 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
21947 --
21948 if l_current_pk_id = l_prev_pk_id then
21949 --
21950 l_first_rec := false ;
21951 --
21952 else
21953 --
21954 l_first_rec := true ;
21955 --
21956 end if ;
21957 --
21958
21959 l_effective_date := r_PEO.information2;
21960 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21961 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
21962 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
21963 end if;
21964
21965 if l_first_rec and not l_update then
21966 -- Call Create routine.
21967 hr_utility.set_location(' BEN_ELIG_TO_PRTE_RSN_F CREATE_ELIG_TO_PRTE_REASON ',20);
21968 BEN_ELIG_TO_PRTE_REASON_API.CREATE_ELIG_TO_PRTE_REASON(
21969 --
21970 P_VALIDATE => false
21971 ,P_EFFECTIVE_DATE => l_effective_date
21972 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
21973 --
21974 ,P_ELIG_INELIG_CD => r_PEO.INFORMATION21
21975 ,P_ELIG_TO_PRTE_RSN_ID => l_elig_to_prte_rsn_id
21976 ,P_IGNR_PRTN_OVRID_FLAG => r_PEO.INFORMATION20
21977 ,P_LER_ID => l_LER_ID
21978 ,P_MX_POE_APLS_CD => r_PEO.INFORMATION17
21979 ,P_MX_POE_DET_DT_CD => r_PEO.INFORMATION16
21980 ,P_MX_POE_DET_DT_RL => l_MX_POE_DET_DT_RL
21981 ,P_MX_POE_RL => l_MX_POE_RL
21982 ,P_MX_POE_UOM => r_PEO.INFORMATION15
21983 ,P_MX_POE_VAL => r_PEO.INFORMATION269
21984 ,P_OIPL_ID => l_OIPL_ID
21985 ,P_PEO_ATTRIBUTE1 => r_PEO.INFORMATION111
21986 ,P_PEO_ATTRIBUTE10 => r_PEO.INFORMATION120
21987 ,P_PEO_ATTRIBUTE11 => r_PEO.INFORMATION121
21988 ,P_PEO_ATTRIBUTE12 => r_PEO.INFORMATION122
21989 ,P_PEO_ATTRIBUTE13 => r_PEO.INFORMATION123
21990 ,P_PEO_ATTRIBUTE14 => r_PEO.INFORMATION124
21991 ,P_PEO_ATTRIBUTE15 => r_PEO.INFORMATION125
21992 ,P_PEO_ATTRIBUTE16 => r_PEO.INFORMATION126
21993 ,P_PEO_ATTRIBUTE17 => r_PEO.INFORMATION127
21994 ,P_PEO_ATTRIBUTE18 => r_PEO.INFORMATION128
21995 ,P_PEO_ATTRIBUTE19 => r_PEO.INFORMATION129
21996 ,P_PEO_ATTRIBUTE2 => r_PEO.INFORMATION112
21997 ,P_PEO_ATTRIBUTE20 => r_PEO.INFORMATION130
21998 ,P_PEO_ATTRIBUTE21 => r_PEO.INFORMATION131
21999 ,P_PEO_ATTRIBUTE22 => r_PEO.INFORMATION132
22000 ,P_PEO_ATTRIBUTE23 => r_PEO.INFORMATION133
22001 ,P_PEO_ATTRIBUTE24 => r_PEO.INFORMATION134
22002 ,P_PEO_ATTRIBUTE25 => r_PEO.INFORMATION135
22003 ,P_PEO_ATTRIBUTE26 => r_PEO.INFORMATION136
22004 ,P_PEO_ATTRIBUTE27 => r_PEO.INFORMATION137
22005 ,P_PEO_ATTRIBUTE28 => r_PEO.INFORMATION138
22006 ,P_PEO_ATTRIBUTE29 => r_PEO.INFORMATION139
22007 ,P_PEO_ATTRIBUTE3 => r_PEO.INFORMATION113
22008 ,P_PEO_ATTRIBUTE30 => r_PEO.INFORMATION140
22009 ,P_PEO_ATTRIBUTE4 => r_PEO.INFORMATION114
22010 ,P_PEO_ATTRIBUTE5 => r_PEO.INFORMATION115
22011 ,P_PEO_ATTRIBUTE6 => r_PEO.INFORMATION116
22012 ,P_PEO_ATTRIBUTE7 => r_PEO.INFORMATION117
22013 ,P_PEO_ATTRIBUTE8 => r_PEO.INFORMATION118
22014 ,P_PEO_ATTRIBUTE9 => r_PEO.INFORMATION119
22015 ,P_PEO_ATTRIBUTE_CATEGORY => r_PEO.INFORMATION110
22016 ,P_PGM_ID => l_PGM_ID
22017 ,P_PLIP_ID => l_PLIP_ID
22018 ,P_PL_ID => l_PL_ID
22019 ,P_PRTN_EFF_END_DT_CD => r_PEO.INFORMATION12
22020 ,P_PRTN_EFF_END_DT_RL => l_PRTN_EFF_END_DT_RL
22021 ,P_PRTN_EFF_STRT_DT_CD => r_PEO.INFORMATION11
22022 ,P_PRTN_EFF_STRT_DT_RL => l_PRTN_EFF_STRT_DT_RL
22023 ,P_PRTN_OVRIDBL_FLAG => r_PEO.INFORMATION19
22024 ,P_PTIP_ID => l_PTIP_ID
22025 ,P_VRFY_FMLY_MMBR_CD => r_PEO.INFORMATION18
22026 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
22027 ,P_WAIT_PERD_DT_TO_USE_CD => r_PEO.INFORMATION14
22028 ,P_WAIT_PERD_DT_TO_USE_RL => l_WAIT_PERD_DT_TO_USE_RL
22029 ,P_WAIT_PERD_RL => l_WAIT_PERD_RL
22030 ,P_WAIT_PERD_UOM => r_PEO.INFORMATION13
22031 ,P_WAIT_PERD_VAL => r_PEO.INFORMATION267
22032 --
22033 ,P_EFFECTIVE_START_DATE => l_effective_start_date
22034 ,P_EFFECTIVE_END_DATE => l_effective_end_date
22035 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
22036 );
22037 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
22038 -- Update all relevent cer records with new pk_id
22039 hr_utility.set_location('Before plsql table ',222);
22040 hr_utility.set_location('new_value id '||l_elig_to_prte_rsn_id,222);
22041 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ELIG_TO_PRTE_RSN_ID' ;
22042 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PEO.information1 ;
22043 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ELIG_TO_PRTE_RSN_ID ;
22044 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
22045 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PEO_unique.table_route_id;
22046 hr_utility.set_location('After plsql table ',222);
22047 --
22048 -- 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 ) ;
22049 --
22050 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22051 --
22052 else
22053 --
22054 -- Call Update routine for the pk_id created in prev run .
22055 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
22056 hr_utility.set_location(' BEN_ELIG_TO_PRTE_RSN_F UPDATE_ELIG_TO_PRTE_REASON ',30);
22057 --UPD START
22058 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
22059 --
22060 if l_update then
22061 --
22062 l_datetrack_mode := r_PEO.datetrack_mode ;
22063 --
22064 get_dt_modes(
22065 p_effective_date => l_process_date,
22066 p_effective_end_date => r_PEO.information3,
22067 p_effective_start_date => r_PEO.information2,
22068 p_dml_operation => r_PEO.dml_operation,
22069 p_datetrack_mode => l_datetrack_mode );
22070 -- p_update => l_update
22071 --
22072 l_effective_date := l_process_date;
22073 l_ELIG_TO_PRTE_RSN_ID := r_PEO.information1;
22074 l_object_version_number := r_PEO.information265;
22075 --
22076 end if;
22077 --
22078 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
22079 --
22080 IF l_update OR l_dml_operation <> 'UPDATE' THEN
22081 --UPD END
22082 BEN_ELIG_TO_PRTE_REASON_API.UPDATE_ELIG_TO_PRTE_REASON(
22083 --
22084 P_VALIDATE => false
22085 ,P_EFFECTIVE_DATE => l_effective_date
22086 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
22087 --
22088 ,P_ELIG_INELIG_CD => r_PEO.INFORMATION21
22089 ,P_ELIG_TO_PRTE_RSN_ID => l_elig_to_prte_rsn_id
22090 ,P_IGNR_PRTN_OVRID_FLAG => r_PEO.INFORMATION20
22091 ,P_LER_ID => l_LER_ID
22092 ,P_MX_POE_APLS_CD => r_PEO.INFORMATION17
22093 ,P_MX_POE_DET_DT_CD => r_PEO.INFORMATION16
22094 ,P_MX_POE_DET_DT_RL => l_MX_POE_DET_DT_RL
22095 ,P_MX_POE_RL => l_MX_POE_RL
22096 ,P_MX_POE_UOM => r_PEO.INFORMATION15
22097 ,P_MX_POE_VAL => r_PEO.INFORMATION269
22098 ,P_OIPL_ID => l_OIPL_ID
22099 ,P_PEO_ATTRIBUTE1 => r_PEO.INFORMATION111
22100 ,P_PEO_ATTRIBUTE10 => r_PEO.INFORMATION120
22101 ,P_PEO_ATTRIBUTE11 => r_PEO.INFORMATION121
22102 ,P_PEO_ATTRIBUTE12 => r_PEO.INFORMATION122
22103 ,P_PEO_ATTRIBUTE13 => r_PEO.INFORMATION123
22104 ,P_PEO_ATTRIBUTE14 => r_PEO.INFORMATION124
22105 ,P_PEO_ATTRIBUTE15 => r_PEO.INFORMATION125
22106 ,P_PEO_ATTRIBUTE16 => r_PEO.INFORMATION126
22107 ,P_PEO_ATTRIBUTE17 => r_PEO.INFORMATION127
22108 ,P_PEO_ATTRIBUTE18 => r_PEO.INFORMATION128
22109 ,P_PEO_ATTRIBUTE19 => r_PEO.INFORMATION129
22110 ,P_PEO_ATTRIBUTE2 => r_PEO.INFORMATION112
22111 ,P_PEO_ATTRIBUTE20 => r_PEO.INFORMATION130
22112 ,P_PEO_ATTRIBUTE21 => r_PEO.INFORMATION131
22113 ,P_PEO_ATTRIBUTE22 => r_PEO.INFORMATION132
22114 ,P_PEO_ATTRIBUTE23 => r_PEO.INFORMATION133
22115 ,P_PEO_ATTRIBUTE24 => r_PEO.INFORMATION134
22116 ,P_PEO_ATTRIBUTE25 => r_PEO.INFORMATION135
22117 ,P_PEO_ATTRIBUTE26 => r_PEO.INFORMATION136
22118 ,P_PEO_ATTRIBUTE27 => r_PEO.INFORMATION137
22119 ,P_PEO_ATTRIBUTE28 => r_PEO.INFORMATION138
22120 ,P_PEO_ATTRIBUTE29 => r_PEO.INFORMATION139
22121 ,P_PEO_ATTRIBUTE3 => r_PEO.INFORMATION113
22122 ,P_PEO_ATTRIBUTE30 => r_PEO.INFORMATION140
22123 ,P_PEO_ATTRIBUTE4 => r_PEO.INFORMATION114
22124 ,P_PEO_ATTRIBUTE5 => r_PEO.INFORMATION115
22125 ,P_PEO_ATTRIBUTE6 => r_PEO.INFORMATION116
22126 ,P_PEO_ATTRIBUTE7 => r_PEO.INFORMATION117
22127 ,P_PEO_ATTRIBUTE8 => r_PEO.INFORMATION118
22128 ,P_PEO_ATTRIBUTE9 => r_PEO.INFORMATION119
22129 ,P_PEO_ATTRIBUTE_CATEGORY => r_PEO.INFORMATION110
22130 ,P_PGM_ID => l_PGM_ID
22131 ,P_PLIP_ID => l_PLIP_ID
22132 ,P_PL_ID => l_PL_ID
22133 ,P_PRTN_EFF_END_DT_CD => r_PEO.INFORMATION12
22134 ,P_PRTN_EFF_END_DT_RL => l_PRTN_EFF_END_DT_RL
22135 ,P_PRTN_EFF_STRT_DT_CD => r_PEO.INFORMATION11
22136 ,P_PRTN_EFF_STRT_DT_RL => l_PRTN_EFF_STRT_DT_RL
22137 ,P_PRTN_OVRIDBL_FLAG => r_PEO.INFORMATION19
22138 ,P_PTIP_ID => l_PTIP_ID
22139 ,P_VRFY_FMLY_MMBR_CD => r_PEO.INFORMATION18
22140 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
22141 ,P_WAIT_PERD_DT_TO_USE_CD => r_PEO.INFORMATION14
22142 ,P_WAIT_PERD_DT_TO_USE_RL => l_WAIT_PERD_DT_TO_USE_RL
22143 ,P_WAIT_PERD_RL => l_WAIT_PERD_RL
22144 ,P_WAIT_PERD_UOM => r_PEO.INFORMATION13
22145 ,P_WAIT_PERD_VAL => r_PEO.INFORMATION267
22146 --
22147 ,P_EFFECTIVE_START_DATE => l_effective_start_date
22148 ,P_EFFECTIVE_END_DATE => l_effective_end_date
22149 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
22150 ,P_DATETRACK_MODE => l_datetrack_mode
22151 );
22152 --
22153 end if; -- l_update
22154 end if;
22155 --
22156 -- Delete the row if it is end dated.
22157 --
22158 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
22159 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
22160 trunc(l_max_eed) = r_PEO.information3) then
22161 --
22162 BEN_ELIG_TO_PRTE_REASON_API.delete_ELIG_TO_PRTE_REASON(
22163 --
22164 p_validate => false
22165 ,p_elig_to_prte_rsn_id => l_elig_to_prte_rsn_id
22166 ,p_effective_start_date => l_effective_start_date
22167 ,p_effective_end_date => l_effective_end_date
22168 ,p_object_version_number => l_object_version_number
22169 ,p_effective_date => l_max_eed
22170 ,p_datetrack_mode => hr_api.g_delete
22171 --
22172 );
22173 --
22174 end if;
22175 --
22176 l_prev_pk_id := l_current_pk_id ;
22177 --
22178 end if;
22179 --
22180 end if;
22181 --
22182 end loop;
22183 --
22184 exception when others then
22185 --
22186 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PEO',r_peo.information5 );
22187 --
22188 end create_PEO_rows;
22189
22190 --
22191 ---------------------------------------------------------------
22192 ----------------------< create_CWG_rows >-----------------------
22193 ---------------------------------------------------------------
22194 --
22195 procedure create_CWG_rows
22196 (
22197 p_validate in number default 0
22198 ,p_copy_entity_txn_id in number
22199 ,p_effective_date in date
22200 ,p_prefix_suffix_text in varchar2 default null
22201 ,p_reuse_object_flag in varchar2 default null
22202 ,p_target_business_group_id in varchar2 default null
22203 ,p_prefix_suffix_cd in varchar2 default null
22204 ) is
22205 --
22206 l_PL_ID number;
22207 l_WKSHT_GRP_CD ben_cwb_wksht_grp.wksht_grp_cd%type;
22208 cursor c_unique_CWG(l_table_alias varchar2) is
22209 select distinct cpe.information1,
22210 cpe.information2,
22211 cpe.information3,
22212 cpe.table_route_id
22213 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
22214 pqh_table_route tr
22215 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22216 and cpe.table_route_id = tr.table_route_id
22217 -- and tr.where_clause = l_BEN_CWB_WKSHT_GRP
22218 and tr.table_alias = l_table_alias
22219 and cpe.number_of_copies = 1 -- ADDITION
22220 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
22221 order by information1, information2; --added for bug: 5151945
22222 --
22223 --
22224 cursor c_CWG_min_max_dates(c_table_route_id number,
22225 c_information1 number) is
22226 select
22227 min(cpe.information2) min_esd,
22228 max(cpe.information3) min_eed
22229 from ben_copy_entity_results cpe
22230 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22231 and cpe.table_route_id = c_table_route_id
22232 and cpe.information1 = c_information1 ;
22233 --
22234 cursor c_CWG(c_table_route_id number,
22235 c_information1 number,
22236 c_information2 date,
22237 c_information3 date ) is
22238 select
22239 cpe.*
22240 from ben_copy_entity_results cpe
22241 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22242 and cpe.table_route_id = c_table_route_id
22243 and cpe.information1 = c_information1
22244 and rownum = 1 ;
22245 -- Date Track target record
22246 cursor c_find_CWG_in_target(
22247 c_effective_start_date date,
22248 c_effective_end_date date,
22249 c_business_group_id number,
22250 c_new_pk_id number) is
22251 select
22252 CWG.cwb_wksht_grp_id new_value
22253 from BEN_CWB_WKSHT_GRP CWG
22254 where
22255 CWG.PL_ID = l_PL_ID and
22256 CWG.WKSHT_GRP_CD = l_WKSHT_GRP_CD and
22257 CWG.business_group_id = c_business_group_id
22258 and CWG.cwb_wksht_grp_id <> c_new_pk_id
22259 ;
22260 --
22261 --UPD START
22262 --
22263 l_update boolean := false ;
22264 l_datetrack_mode varchar2(80) := hr_api.g_update;
22265 l_process_date date;
22266 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
22267 --
22268 --UPD END
22269 l_current_pk_id number := null ;
22270 l_prev_pk_id number := null ;
22271 l_first_rec boolean := true ;
22272 r_CWG c_CWG%rowtype;
22273 l_cwb_wksht_grp_id number ;
22274 l_object_version_number number ;
22275 l_effective_start_date date ;
22276 l_effective_end_date date ;
22277 l_prefix pqh_copy_entity_attribs.information1%type := null;
22278 l_suffix pqh_copy_entity_attribs.information1%type := null;
22279 l_new_value number(15);
22280 l_object_found_in_target boolean := false ;
22281 l_min_esd date;
22282 l_max_eed date;
22283 --
22284 begin
22285 -- Initialization
22286 l_object_found_in_target := false ;
22287 -- End Initialization
22288 -- Derive the prefix - sufix
22289 if p_prefix_suffix_cd = 'PREFIX' then
22290 l_prefix := p_prefix_suffix_text ;
22291 elsif p_prefix_suffix_cd = 'SUFFIX' then
22292 l_suffix := p_prefix_suffix_text ;
22293 else
22294 l_prefix := null ;
22295 l_suffix := null ;
22296 end if ;
22297 -- End Prefix Sufix derivation
22298 for r_CWG_unique in c_unique_CWG('CWG') loop
22299 --
22300 hr_utility.set_location(' r_CWG_unique.table_route_id '||r_CWG_unique.table_route_id,10);
22301 hr_utility.set_location(' r_CWG_unique.information1 '||r_CWG_unique.information1,10);
22302 hr_utility.set_location( 'r_CWG_unique.information2 '||r_CWG_unique.information2,10);
22303 hr_utility.set_location( 'r_CWG_unique.information3 '||r_CWG_unique.information3,10);
22304 -- If reuse objects flag is 'Y' then check for the object in the target business group
22305 -- if found insert the record into PLSql table and exit the loop else try create the
22306 -- object in the target business group
22307 --
22308 l_object_found_in_target := false ;
22309 l_min_esd := null ;
22310 l_max_eed := null ;
22311 --
22312 open c_CWG(r_CWG_unique.table_route_id,
22313 r_CWG_unique.information1,
22314 r_CWG_unique.information2,
22315 r_CWG_unique.information3 ) ;
22316 --
22317 fetch c_CWG into r_CWG ;
22318 --
22319 close c_CWG ;
22320 --
22321 --UPD START
22322 --
22323 l_update := false;
22324 l_process_date := p_effective_date;
22325 l_dml_operation:= r_CWG_unique.dml_operation ;
22326 --UPD START
22327 --
22328 l_PL_ID := get_fk('PL_ID', r_CWG.INFORMATION261,l_dml_operation);
22329 l_WKSHT_GRP_CD := r_CWG.INFORMATION11;
22330 --UPD START
22331 --
22332 if l_dml_operation = 'UPDATE' then
22333 --
22334 l_update := true;
22335 if r_CWG_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
22336 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'CWB_WKSHT_GRP_ID' then
22337 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'CWB_WKSHT_GRP_ID' ;
22338 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CWG_unique.information1 ;
22339 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_CWG_unique.information1 ;
22340 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
22341 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CWG_unique.table_route_id;
22342 --
22343 -- 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 ) ; -- NEW
22344 --
22345 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22346 --
22347 --DOUBT log_data('CWG',l_new_value,l_prefix || r_CWG_unique.name|| l_suffix,'REUSED');
22348 --
22349 end if ;
22350 l_CWB_WKSHT_GRP_ID := r_CWG_unique.information1 ;
22351 l_object_version_number := r_CWG.information265 ;
22352 hr_utility.set_location( 'found record for update',10);
22353 --
22354 else
22355 --
22356 --UPD END
22357 if p_reuse_object_flag = 'Y' then
22358 -- cursor to find the object
22359 open c_find_CWG_in_target( r_CWG_unique.information2,l_max_eed,
22360 p_target_business_group_id, nvl(l_cwb_wksht_grp_id, -999) ) ;
22361 fetch c_find_CWG_in_target into l_new_value ;
22362 if c_find_CWG_in_target%found then
22363 --
22364 if r_CWG_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
22365 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'CWB_WKSHT_GRP_ID' then
22366 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'CWB_WKSHT_GRP_ID' ;
22367 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CWG_unique.information1 ;
22368 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
22369 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
22370 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CWG_unique.table_route_id;
22371 --
22372 -- 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) ;
22373 --
22374 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22375 --
22376
22377 end if ;
22378 --
22379 l_object_found_in_target := true ;
22380 end if;
22381 close c_find_CWG_in_target ;
22382 --
22383 end if ;
22384 --
22385 end if; --if p_dml_operation
22386 --
22387 if not l_object_found_in_target OR l_update then
22388 --
22389 l_current_pk_id := r_CWG.information1;
22390 --
22391 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
22392 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
22393 --
22394 if l_current_pk_id = l_prev_pk_id then
22395 --
22396 l_first_rec := false ;
22397 --
22398 else
22399 --
22400 l_first_rec := true ;
22401 --
22402 end if ;
22403 --
22404 -- To avoid creating a child with out a parent
22405 --
22406 --
22407 if l_PL_ID is null then
22408 l_first_rec := false ;
22409 end if;
22410 --
22411 if l_first_rec and not l_update then
22412 -- Call Create routine.
22413 hr_utility.set_location(' BEN_CWB_WKSHT_GRP CREATE_CWB_WKSHT_GRP ',20);
22414 BEN_CWB_WKSHT_GRP_API.CREATE_CWB_WKSHT_GRP(
22415 --
22416 P_VALIDATE => false
22417 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
22418 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
22419 ,P_CWB_WKSHT_GRP_ID => l_cwb_wksht_grp_id
22420 ,P_CWG_ATTRIBUTE1 => r_CWG.INFORMATION111
22421 ,P_CWG_ATTRIBUTE10 => r_CWG.INFORMATION120
22422 ,P_CWG_ATTRIBUTE11 => r_CWG.INFORMATION121
22423 ,P_CWG_ATTRIBUTE12 => r_CWG.INFORMATION122
22424 ,P_CWG_ATTRIBUTE13 => r_CWG.INFORMATION123
22425 ,P_CWG_ATTRIBUTE14 => r_CWG.INFORMATION124
22426 ,P_CWG_ATTRIBUTE15 => r_CWG.INFORMATION125
22427 ,P_CWG_ATTRIBUTE16 => r_CWG.INFORMATION126
22428 ,P_CWG_ATTRIBUTE17 => r_CWG.INFORMATION127
22429 ,P_CWG_ATTRIBUTE18 => r_CWG.INFORMATION128
22430 ,P_CWG_ATTRIBUTE19 => r_CWG.INFORMATION129
22431 ,P_CWG_ATTRIBUTE2 => r_CWG.INFORMATION112
22432 ,P_CWG_ATTRIBUTE20 => r_CWG.INFORMATION130
22433 ,P_CWG_ATTRIBUTE21 => r_CWG.INFORMATION131
22434 ,P_CWG_ATTRIBUTE22 => r_CWG.INFORMATION132
22435 ,P_CWG_ATTRIBUTE23 => r_CWG.INFORMATION133
22436 ,P_CWG_ATTRIBUTE24 => r_CWG.INFORMATION134
22437 ,P_CWG_ATTRIBUTE25 => r_CWG.INFORMATION135
22438 ,P_CWG_ATTRIBUTE26 => r_CWG.INFORMATION136
22439 ,P_CWG_ATTRIBUTE27 => r_CWG.INFORMATION137
22440 ,P_CWG_ATTRIBUTE28 => r_CWG.INFORMATION138
22441 ,P_CWG_ATTRIBUTE29 => r_CWG.INFORMATION139
22442 ,P_CWG_ATTRIBUTE3 => r_CWG.INFORMATION113
22443 ,P_CWG_ATTRIBUTE30 => r_CWG.INFORMATION140
22444 ,P_CWG_ATTRIBUTE4 => r_CWG.INFORMATION114
22445 ,P_CWG_ATTRIBUTE5 => r_CWG.INFORMATION115
22446 ,P_CWG_ATTRIBUTE6 => r_CWG.INFORMATION116
22447 ,P_CWG_ATTRIBUTE7 => r_CWG.INFORMATION117
22448 ,P_CWG_ATTRIBUTE8 => r_CWG.INFORMATION118
22449 ,P_CWG_ATTRIBUTE9 => r_CWG.INFORMATION119
22450 ,P_CWG_ATTRIBUTE_CATEGORY => r_CWG.INFORMATION110
22451 ,P_LABEL => r_CWG.INFORMATION141
22452 ,P_ORDR_NUM => r_CWG.INFORMATION260
22453 ,P_PL_ID => l_PL_ID
22454 ,P_WKSHT_GRP_CD => r_CWG.INFORMATION11
22455 ,P_HIDDEN_CD => r_CWG.INFORMATION12
22456 ,P_STATUS_CD => r_CWG.INFORMATION13
22457 --
22458 --
22459 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
22460 );
22461 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
22462 -- Update all relevent cer records with new pk_id
22463 hr_utility.set_location('Before plsql table ',222);
22464 hr_utility.set_location('new_value id '||l_cwb_wksht_grp_id,222);
22465 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'CWB_WKSHT_GRP_ID' ;
22466 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CWG.information1 ;
22467 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_CWB_WKSHT_GRP_ID ;
22468 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
22469 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CWG_unique.table_route_id;
22470 hr_utility.set_location('After plsql table ',222);
22471 --
22472 -- 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 ) ;
22473 --
22474 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22475 --
22476 elsif l_update then
22477 BEN_CWB_WKSHT_GRP_API.UPDATE_CWB_WKSHT_GRP(
22478 --
22479 P_VALIDATE => false
22480 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
22481 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
22482 ,P_CWB_WKSHT_GRP_ID => l_cwb_wksht_grp_id
22483 ,P_CWG_ATTRIBUTE1 => r_CWG.INFORMATION111
22484 ,P_CWG_ATTRIBUTE10 => r_CWG.INFORMATION120
22485 ,P_CWG_ATTRIBUTE11 => r_CWG.INFORMATION121
22486 ,P_CWG_ATTRIBUTE12 => r_CWG.INFORMATION122
22487 ,P_CWG_ATTRIBUTE13 => r_CWG.INFORMATION123
22488 ,P_CWG_ATTRIBUTE14 => r_CWG.INFORMATION124
22489 ,P_CWG_ATTRIBUTE15 => r_CWG.INFORMATION125
22490 ,P_CWG_ATTRIBUTE16 => r_CWG.INFORMATION126
22491 ,P_CWG_ATTRIBUTE17 => r_CWG.INFORMATION127
22492 ,P_CWG_ATTRIBUTE18 => r_CWG.INFORMATION128
22493 ,P_CWG_ATTRIBUTE19 => r_CWG.INFORMATION129
22494 ,P_CWG_ATTRIBUTE2 => r_CWG.INFORMATION112
22495 ,P_CWG_ATTRIBUTE20 => r_CWG.INFORMATION130
22496 ,P_CWG_ATTRIBUTE21 => r_CWG.INFORMATION131
22497 ,P_CWG_ATTRIBUTE22 => r_CWG.INFORMATION132
22498 ,P_CWG_ATTRIBUTE23 => r_CWG.INFORMATION133
22499 ,P_CWG_ATTRIBUTE24 => r_CWG.INFORMATION134
22500 ,P_CWG_ATTRIBUTE25 => r_CWG.INFORMATION135
22501 ,P_CWG_ATTRIBUTE26 => r_CWG.INFORMATION136
22502 ,P_CWG_ATTRIBUTE27 => r_CWG.INFORMATION137
22503 ,P_CWG_ATTRIBUTE28 => r_CWG.INFORMATION138
22504 ,P_CWG_ATTRIBUTE29 => r_CWG.INFORMATION139
22505 ,P_CWG_ATTRIBUTE3 => r_CWG.INFORMATION113
22506 ,P_CWG_ATTRIBUTE30 => r_CWG.INFORMATION140
22507 ,P_CWG_ATTRIBUTE4 => r_CWG.INFORMATION114
22508 ,P_CWG_ATTRIBUTE5 => r_CWG.INFORMATION115
22509 ,P_CWG_ATTRIBUTE6 => r_CWG.INFORMATION116
22510 ,P_CWG_ATTRIBUTE7 => r_CWG.INFORMATION117
22511 ,P_CWG_ATTRIBUTE8 => r_CWG.INFORMATION118
22512 ,P_CWG_ATTRIBUTE9 => r_CWG.INFORMATION119
22513 ,P_CWG_ATTRIBUTE_CATEGORY => r_CWG.INFORMATION110
22514 ,P_LABEL => r_CWG.INFORMATION141
22515 ,P_ORDR_NUM => r_CWG.INFORMATION260
22516 ,P_PL_ID => l_PL_ID
22517 ,P_WKSHT_GRP_CD => r_CWG.INFORMATION11
22518 ,P_HIDDEN_CD => r_CWG.INFORMATION12
22519 ,P_STATUS_CD => r_CWG.INFORMATION13
22520 --
22521 --
22522 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
22523 );
22524 end if;
22525 --
22526 l_prev_pk_id := l_current_pk_id ;
22527 --
22528 end if;
22529 --
22530 end loop;
22531 --
22532 exception when others then
22533 --
22534 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CWG',r_cwg.information5 );
22535 --
22536 end create_CWG_rows;
22537
22538 ---------------------------------------------------------------
22539 ----------------------< create_CRI_rows >-----------------------
22540 ---------------------------------------------------------------
22541 --
22542 procedure create_CRI_rows
22543 (
22544 p_validate in number default 0
22545 ,p_copy_entity_txn_id in number
22546 ,p_effective_date in date
22547 ,p_reuse_object_flag in varchar2 default null
22548 ) is
22549 --
22550 cursor c_unique_CRI(l_table_alias varchar2) is
22551 select distinct cpe.information11,
22552 cpe.information12,
22553 cpe.information13,
22554 cpe.INFORMATION14,
22555 cpe.table_route_id,dml_operation,cpe.datetrack_mode
22556 from ben_copy_entity_results cpe,
22557 pqh_table_route tr
22558 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22559 and cpe.table_route_id = tr.table_route_id
22560 -- and tr.where_clause = l_BEN_AGE_FCTR
22561 and tr.table_alias = l_table_alias
22562 and cpe.number_of_copies = 1 --ADDITION
22563 group by cpe.information11,cpe.information12,cpe.information13, cpe.INFORMATION14, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
22564 order by information11, information12; --added for bug: 5151945 (changed from
22565 --1 to 11 by sshetty)
22566
22567 --
22568 --
22569
22570 cursor c_CRI(c_table_route_id number,
22571 c_information11 varchar2,
22572 c_information12 varchar2,
22573 c_information13 varchar2,
22574 c_information14 varchar2
22575 ) is
22576 select
22577 cpe.*
22578 from ben_copy_entity_results cpe
22579 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22580 and cpe.table_route_id = c_table_route_id
22581 and cpe.information11 = c_information11
22582 and cpe.information12 = c_information12
22583 and cpe.information13 = c_information13
22584 and cpe.information14 = c_information14
22585 and rownum = 1 ;
22586 -- Date Track target record
22587
22588
22589 cursor c_find_CRI_in_target( c_new_information11 varchar2,
22590 c_new_information12 varchar2,
22591 c_new_information13 varchar2,
22592 c_new_information14 varchar2) is
22593 select
22594 CRI.REGION_CODE ,cri.CUSTOM_KEY ,cri.CUSTOM_TYPE ,cri.item_name ,cri.label
22595 from BEN_CUSTOM_REGION_ITEMS CRI
22596 where CRI.region_code = c_new_information11
22597 and CRI.CUSTOM_KEY = c_new_information12
22598 and CRI.CUSTOM_TYPE = c_new_information13
22599 and CRI.item_name = c_new_information14;
22600
22601 --
22602 --
22603 l_update boolean := false ;
22604 l_process_date date;
22605 l_debug_item_name ben_custom_region_items.item_name%type;
22606 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
22607 r_find_CRI_in_target c_find_CRI_in_target%rowtype;
22608 r_CRI c_CRI%rowtype;
22609 --
22610 --UPD END
22611
22612 l_object_version_number number ;
22613 l_object_found_in_target boolean := false ;
22614 l_custom_key ben_custom_region_items.custom_key%type;
22615 l_fk_cwb_wksht_grp_id ben_cwb_wksht_grp.cwb_wksht_grp_id%type;
22616 --
22617 begin
22618
22619 for r_CRI_unique in c_unique_CRI('CRI') loop
22620 --
22621 hr_utility.set_location(' r_CRI_unique.table_route_id '||r_CRI_unique.table_route_id,10);
22622 hr_utility.set_location(' r_CRI_unique.information11 '||r_CRI_unique.information11,10);
22623 hr_utility.set_location( 'r_CRI_unique.information12 '||r_CRI_unique.information12,10);
22624 hr_utility.set_location( 'r_CRI_unique.information13 '||r_CRI_unique.information13,10);
22625 hr_utility.set_location( 'r_CRI_unique.information14 '||r_CRI_unique.information14,10);
22626
22627 -- AS the Only operations that are performed on the table
22628 -- BEN_CUSTOM_REGION_ITEMS are REUSE/INSERT we need not worry about t
22629 -- the l_dml_operation.
22630
22631 -- We first check for the presence of any BEN_CUSTOM_REGION_ITEMS record
22632 -- based on the target cwb_wksht_grp_id and if any records are found
22633 -- we reuse them or we create new records as seen in the CPE table
22634
22635 l_dml_operation := r_CRI_unique.dml_operation ;
22636 l_debug_item_name := r_CRI_unique.information13;
22637
22638 --
22639 l_fk_cwb_wksht_grp_id := get_fk('CWB_WKSHT_GRP_ID', r_CRI_unique.INFORMATION12,l_dml_operation);
22640
22641 -- Fetch the new fk cwb_wksht_grp_id for the target business group.
22642
22643 hr_utility.set_location('source cwb_wksht_grp_id '|| r_CRI_unique.INFORMATION12 || ' target cwb_wksht_grp_id ' || l_fk_cwb_wksht_grp_id , 20);
22644 hr_utility.set_location('l_dml_operation '|| l_dml_operation || ' p_reuse_object_flag ' || p_reuse_object_flag, 20);
22645
22646
22647
22648 open c_find_CRI_in_target(r_CRI_unique.information11,
22649 to_char(l_fk_cwb_wksht_grp_id),
22650 r_CRI_unique.information13,
22651 r_CRI_unique.information14);
22652
22653 fetch c_find_CRI_in_target into r_find_CRI_in_target ;
22654
22655 if c_find_CRI_in_target%found then
22656
22657 hr_utility.set_location(' r_find_CRI_in_target.REGION_CODE ' || r_find_CRI_in_target.REGION_CODE,20 );
22658 hr_utility.set_location(' r_find_CRI_in_target.CUSTOM_KEY ' || r_find_CRI_in_target.CUSTOM_KEY ,20 );
22659 hr_utility.set_location( 'r_find_CRI_in_target.CUSTOM_TYPE ' || r_find_CRI_in_target.CUSTOM_TYPE,20 );
22660 hr_utility.set_location( 'r_find_CRI_in_target.ITEM_NAME ' || r_find_CRI_in_target.ITEM_NAME ,20 );
22661 hr_utility.set_location( 'r_find_CRI_in_target.LABEL ' || r_find_CRI_in_target.LABEL ,20 );
22662 hr_utility.set_location( 'RKG A record of ben_custom_region_items',202);
22663 hr_utility.set_location( 'with the same cwb_wksht_grp_id as custom_key already exists and hence reused. ',202);
22664
22665 -- As the record in found in the target , reuse the record
22666 else
22667 -- or create the new record by querying the full record from CPE
22668
22669 open c_CRI(r_CRI_unique.table_route_id,
22670 r_CRI_unique.information11,
22671 r_CRI_unique.information12,
22672 r_CRI_unique.information13,
22673 r_CRI_unique.information14) ;
22674 --
22675 fetch c_CRI into r_CRI ;
22676 --
22677 close c_CRI ;
22678 --
22679
22680 insert into BEN_CUSTOM_REGION_ITEMS(
22681 REGION_CODE ,
22682 CUSTOM_KEY ,
22683 CUSTOM_TYPE ,
22684 ITEM_NAME ,
22685 DISPLAY_FLAG ,
22686 LABEL ,
22687 ORDR_NUM ,
22688 LAST_UPDATE_DATE ,
22689 CREATION_DATE ,
22690 OBJECT_VERSION_NUMBER ,
22691 UPDATE_ATTR ,
22692 MONETARY )
22693 values
22694 (r_CRI.information11,
22695 to_char(l_fk_cwb_wksht_grp_id),
22696 r_CRI.information13,
22697 r_CRI.information14,
22698 r_CRI.information15,
22699 r_CRI.information141,
22700 r_CRI.information266,
22701 sysdate,
22702 sysdate,
22703 1,
22704 r_CRI.information16,
22705 r_CRI.information17);
22706
22707 end if;
22708
22709 close c_find_CRI_in_target;
22710
22711
22712 end loop;
22713
22714 --
22715 exception when others then
22716 --
22717 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CRI' , l_debug_item_name) ;
22718 --
22719
22720 end create_CRI_rows;
22721
22722 ---------------------------------------------------------------
22723 ----------------------< create_PCP_rows >-----------------------
22724 ---------------------------------------------------------------
22725 --
22726 procedure create_PCP_rows
22727 (
22728 p_validate in number default 0
22729 ,p_copy_entity_txn_id in number
22730 ,p_effective_date in date
22731 ,p_prefix_suffix_text in varchar2 default null
22732 ,p_reuse_object_flag in varchar2 default null
22733 ,p_target_business_group_id in varchar2 default null
22734 ,p_prefix_suffix_cd in varchar2 default null
22735 ) is
22736 --
22737 l_PL_ID number;
22738 cursor c_unique_PCP(l_table_alias varchar2) is
22739 select distinct cpe.information1,
22740 cpe.information2,
22741 cpe.information3,
22742 cpe.table_route_id
22743 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
22744 pqh_table_route tr
22745 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22746 and cpe.table_route_id = tr.table_route_id
22747 -- and tr.where_clause = l_BEN_PL_PCP
22748 and tr.table_alias = l_table_alias
22749 and cpe.number_of_copies = 1 -- ADDITION
22750 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
22751 order by information1, information2; --added for bug: 5151945
22752 --
22753 --
22754 cursor c_PCP_min_max_dates(c_table_route_id number,
22755 c_information1 number) is
22756 select
22757 min(cpe.information2) min_esd,
22758 max(cpe.information3) min_eed
22759 from ben_copy_entity_results cpe
22760 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22761 and cpe.table_route_id = c_table_route_id
22762 and cpe.information1 = c_information1 ;
22763 --
22764 cursor c_PCP(c_table_route_id number,
22765 c_information1 number,
22766 c_information2 date,
22767 c_information3 date ) is
22768 select
22769 cpe.*
22770 from ben_copy_entity_results cpe
22771 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22772 and cpe.table_route_id = c_table_route_id
22773 and cpe.information1 = c_information1
22774 and rownum = 1 ;
22775 -- Date Track target record
22776 cursor c_find_PCP_in_target(
22777 c_effective_start_date date,
22778 c_effective_end_date date,
22779 c_business_group_id number,
22780 c_new_pk_id number) is
22781 select
22782 PCP.pl_pcp_id new_value
22783 from BEN_PL_PCP PCP
22784 where
22785 PCP.PL_ID = l_PL_ID and
22786 PCP.business_group_id = c_business_group_id
22787 and PCP.pl_pcp_id <> c_new_pk_id
22788 ;
22789
22790 --cursor to check the row exist in the ben_popl_org_f table.
22791 cursor c_exists_in_popl_org(c_pl_id in number) is
22792 select 'x'
22793 from ben_popl_org_f
22794 Where pl_id = c_pl_id;
22795 --
22796 l_dummy varchar2(1);
22797 --
22798 --UPD START
22799 --
22800 l_update boolean := false ;
22801 l_datetrack_mode varchar2(80) := hr_api.g_update;
22802 l_process_date date;
22803 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
22804 --
22805 --UPD END
22806 l_current_pk_id number := null ;
22807 l_prev_pk_id number := null ;
22808 l_first_rec boolean := true ;
22809 r_PCP c_PCP%rowtype;
22810 l_pl_pcp_id number ;
22811 l_object_version_number number ;
22812 l_effective_start_date date ;
22813 l_effective_end_date date ;
22814 l_prefix pqh_copy_entity_attribs.information1%type := null;
22815 l_suffix pqh_copy_entity_attribs.information1%type := null;
22816 l_new_value number(15);
22817 l_object_found_in_target boolean := false ;
22818 l_min_esd date;
22819 l_max_eed date;
22820 l_parent_effective_start_date date;
22821 --
22822 begin
22823 -- Initialization
22824 l_object_found_in_target := false ;
22825 -- End Initialization
22826 -- Derive the prefix - sufix
22827 if p_prefix_suffix_cd = 'PREFIX' then
22828 l_prefix := p_prefix_suffix_text ;
22829 elsif p_prefix_suffix_cd = 'SUFFIX' then
22830 l_suffix := p_prefix_suffix_text ;
22831 else
22832 l_prefix := null ;
22833 l_suffix := null ;
22834 end if ;
22835 -- End Prefix Sufix derivation
22836 for r_PCP_unique in c_unique_PCP('PCP') loop
22837 --
22838 hr_utility.set_location(' r_PCP_unique.table_route_id '||r_PCP_unique.table_route_id,10);
22839 hr_utility.set_location(' r_PCP_unique.information1 '||r_PCP_unique.information1,10);
22840 hr_utility.set_location( 'r_PCP_unique.information2 '||r_PCP_unique.information2,10);
22841 hr_utility.set_location( 'r_PCP_unique.information3 '||r_PCP_unique.information3,10);
22842 -- If reuse objects flag is 'Y' then check for the object in the target business group
22843 -- if found insert the record into PLSql table and exit the loop else try create the
22844 -- object in the target business group
22845 --
22846 l_object_found_in_target := false ;
22847 l_min_esd := null ;
22848 l_max_eed := null ;
22849 --
22850 open c_PCP(r_PCP_unique.table_route_id,
22851 r_PCP_unique.information1,
22852 r_PCP_unique.information2,
22853 r_PCP_unique.information3 ) ;
22854 --
22855 fetch c_PCP into r_PCP ;
22856 --
22857 close c_PCP ;
22858 --
22859 --UPD START
22860 --
22861 l_update := false;
22862 l_process_date := p_effective_date;
22863 l_dml_operation:= r_PCP_unique.dml_operation ;
22864 --
22865 --UPD END
22866 l_PL_ID := get_fk('PL_ID', r_PCP.INFORMATION261,l_dml_operation);
22867 --
22868
22869 -- If PCP_RPSTRY_FLAG (From Repository flag ) = 'Y' then
22870 -- Check if a row exists in the ben_popl_org_f table for the Plan
22871 -- If no row found then set PCP_RPSTRY_FLAG to 'N'
22872 -- Also set Radius, Radius Warning and Radius UOM to null as
22873 -- these cannot have a value if the Repository flag is not selected
22874
22875 if r_PCP.information14 = 'Y' then
22876 open c_exists_in_popl_org(l_PL_ID);
22877 fetch c_exists_in_popl_org into l_dummy;
22878 if c_exists_in_popl_org%notfound then
22879 r_PCP.information14 := 'N'; -- Repository flag
22880 r_PCP.information293 := null; -- Radius
22881 r_PCP.information16 := null; -- Radius UOM
22882 r_PCP.information17 := 'N'; -- Radius Warning
22883 end if;
22884 close c_exists_in_popl_org;
22885 end if;
22886
22887 if l_PL_ID is not null then -- Do not create if parent record does not exist
22888
22889 --UPD START
22890 --
22891 if l_dml_operation = 'UPDATE' then
22892 --
22893 l_update := true;
22894 if r_PCP_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
22895 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_PCP_ID' then
22896 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_PCP_ID' ;
22897 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PCP_unique.information1 ;
22898 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PCP_unique.information1 ;
22899 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
22900 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PCP_unique.table_route_id;
22901 --
22902 -- 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 ) ; -- NEW
22903 --
22904 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22905 --
22906 --DOUBT log_data('PCP',l_new_value,l_prefix || r_PCP_unique.name|| l_suffix,'REUSED');
22907 --
22908 end if ;
22909 l_PL_PCP_ID := r_PCP_unique.information1 ;
22910 l_object_version_number := r_PCP.information265 ;
22911 hr_utility.set_location( 'found record for update',10);
22912 --
22913 else
22914 --
22915 --UPD END
22916 if p_reuse_object_flag = 'Y' then
22917 -- cursor to find the object
22918 open c_find_PCP_in_target( r_PCP_unique.information2,l_max_eed,
22919 p_target_business_group_id, nvl(l_pl_pcp_id, -999) ) ;
22920 fetch c_find_PCP_in_target into l_new_value ;
22921 if c_find_PCP_in_target%found then
22922 --
22923 if r_PCP_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
22924 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_PCP_ID' then
22925 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_PCP_ID' ;
22926 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PCP_unique.information1 ;
22927 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
22928 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
22929 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PCP_unique.table_route_id;
22930 --
22931 -- 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) ;
22932 --
22933 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22934 end if ;
22935 --
22936 l_object_found_in_target := true ;
22937 end if;
22938 close c_find_PCP_in_target ;
22939 --
22940 end if ;
22941 --
22942 end if; --if p_dml_operation
22943 --
22944 if not l_object_found_in_target OR l_update then
22945 --
22946 l_current_pk_id := r_PCP.information1;
22947 --
22948 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
22949 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
22950 --
22951 if l_current_pk_id = l_prev_pk_id then
22952 --
22953 l_first_rec := false ;
22954 --
22955 else
22956 --
22957 l_first_rec := true ;
22958 --
22959 end if ;
22960 --
22961
22962 l_parent_effective_start_date := r_PCP.information10;
22963 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null ) then
22964 if l_parent_effective_start_date is null then
22965 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
22966 elsif l_parent_effective_start_date < ben_pd_copy_to_ben_one.g_copy_effective_date then
22967 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
22968 end if;
22969 end if;
22970 --
22971 -- To avoid creating a child with out parent
22972 --
22973 if l_PL_ID is null then
22974 l_first_rec:=false;
22975 end if;
22976 --
22977 if l_first_rec and not l_update then
22978 -- Call Create routine.
22979 hr_utility.set_location(' BEN_PL_PCP CREATE_PL_PRMRY_CARE_PRVDR ',20);
22980 BEN_PL_PRMRY_CARE_PRVDR_API.CREATE_PL_PRMRY_CARE_PRVDR(
22981 --
22982 P_VALIDATE => false
22983 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
22984 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
22985 --
22986 ,P_PCP_ATTRIBUTE1 => r_PCP.INFORMATION111
22987 ,P_PCP_ATTRIBUTE10 => r_PCP.INFORMATION120
22988 ,P_PCP_ATTRIBUTE11 => r_PCP.INFORMATION121
22989 ,P_PCP_ATTRIBUTE12 => r_PCP.INFORMATION122
22990 ,P_PCP_ATTRIBUTE13 => r_PCP.INFORMATION123
22991 ,P_PCP_ATTRIBUTE14 => r_PCP.INFORMATION124
22992 ,P_PCP_ATTRIBUTE15 => r_PCP.INFORMATION125
22993 ,P_PCP_ATTRIBUTE16 => r_PCP.INFORMATION126
22994 ,P_PCP_ATTRIBUTE17 => r_PCP.INFORMATION127
22995 ,P_PCP_ATTRIBUTE18 => r_PCP.INFORMATION128
22996 ,P_PCP_ATTRIBUTE19 => r_PCP.INFORMATION129
22997 ,P_PCP_ATTRIBUTE2 => r_PCP.INFORMATION112
22998 ,P_PCP_ATTRIBUTE20 => r_PCP.INFORMATION130
22999 ,P_PCP_ATTRIBUTE21 => r_PCP.INFORMATION131
23000 ,P_PCP_ATTRIBUTE22 => r_PCP.INFORMATION132
23001 ,P_PCP_ATTRIBUTE23 => r_PCP.INFORMATION133
23002 ,P_PCP_ATTRIBUTE24 => r_PCP.INFORMATION134
23003 ,P_PCP_ATTRIBUTE25 => r_PCP.INFORMATION135
23004 ,P_PCP_ATTRIBUTE26 => r_PCP.INFORMATION136
23005 ,P_PCP_ATTRIBUTE27 => r_PCP.INFORMATION137
23006 ,P_PCP_ATTRIBUTE28 => r_PCP.INFORMATION138
23007 ,P_PCP_ATTRIBUTE29 => r_PCP.INFORMATION139
23008 ,P_PCP_ATTRIBUTE3 => r_PCP.INFORMATION113
23009 ,P_PCP_ATTRIBUTE30 => r_PCP.INFORMATION140
23010 ,P_PCP_ATTRIBUTE4 => r_PCP.INFORMATION114
23011 ,P_PCP_ATTRIBUTE5 => r_PCP.INFORMATION115
23012 ,P_PCP_ATTRIBUTE6 => r_PCP.INFORMATION116
23013 ,P_PCP_ATTRIBUTE7 => r_PCP.INFORMATION117
23014 ,P_PCP_ATTRIBUTE8 => r_PCP.INFORMATION118
23015 ,P_PCP_ATTRIBUTE9 => r_PCP.INFORMATION119
23016 ,P_PCP_ATTRIBUTE_CATEGORY => r_PCP.INFORMATION110
23017 ,P_PCP_CAN_KEEP_FLAG => r_PCP.INFORMATION15
23018 ,P_PCP_DPNT_DSGN_CD => r_PCP.INFORMATION13
23019 ,P_PCP_DSGN_CD => r_PCP.INFORMATION12
23020 ,P_PCP_NUM_CHGS => r_PCP.INFORMATION294
23021 ,P_PCP_NUM_CHGS_UOM => r_PCP.INFORMATION18
23022 ,P_PCP_RADIUS => r_PCP.INFORMATION293
23023 ,P_PCP_RADIUS_UOM => r_PCP.INFORMATION16
23024 ,P_PCP_RADIUS_WARN_FLAG => r_PCP.INFORMATION17
23025 ,P_PCP_RPSTRY_FLAG => r_PCP.INFORMATION14
23026 ,P_PCP_STRT_DT_CD => r_PCP.INFORMATION11
23027 ,P_PL_ID => l_PL_ID
23028 ,P_PL_PCP_ID => l_pl_pcp_id
23029 --
23030 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
23031 );
23032 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
23033 -- Update all relevent cer records with new pk_id
23034 hr_utility.set_location('Before plsql table ',222);
23035 hr_utility.set_location('new_value id '||l_pl_pcp_id,222);
23036 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_PCP_ID' ;
23037 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PCP.information1 ;
23038 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PL_PCP_ID ;
23039 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
23040 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PCP_unique.table_route_id;
23041 hr_utility.set_location('After plsql table ',222);
23042 --
23043 -- 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 ) ;
23044 --
23045 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23046 --
23047 elsif l_update then
23048 BEN_PL_PRMRY_CARE_PRVDR_API.UPDATE_PL_PRMRY_CARE_PRVDR(
23049 --
23050 P_VALIDATE => false
23051 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
23052 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
23053 --
23054 ,P_PCP_ATTRIBUTE1 => r_PCP.INFORMATION111
23055 ,P_PCP_ATTRIBUTE10 => r_PCP.INFORMATION120
23056 ,P_PCP_ATTRIBUTE11 => r_PCP.INFORMATION121
23057 ,P_PCP_ATTRIBUTE12 => r_PCP.INFORMATION122
23058 ,P_PCP_ATTRIBUTE13 => r_PCP.INFORMATION123
23059 ,P_PCP_ATTRIBUTE14 => r_PCP.INFORMATION124
23060 ,P_PCP_ATTRIBUTE15 => r_PCP.INFORMATION125
23061 ,P_PCP_ATTRIBUTE16 => r_PCP.INFORMATION126
23062 ,P_PCP_ATTRIBUTE17 => r_PCP.INFORMATION127
23063 ,P_PCP_ATTRIBUTE18 => r_PCP.INFORMATION128
23064 ,P_PCP_ATTRIBUTE19 => r_PCP.INFORMATION129
23065 ,P_PCP_ATTRIBUTE2 => r_PCP.INFORMATION112
23066 ,P_PCP_ATTRIBUTE20 => r_PCP.INFORMATION130
23067 ,P_PCP_ATTRIBUTE21 => r_PCP.INFORMATION131
23068 ,P_PCP_ATTRIBUTE22 => r_PCP.INFORMATION132
23069 ,P_PCP_ATTRIBUTE23 => r_PCP.INFORMATION133
23070 ,P_PCP_ATTRIBUTE24 => r_PCP.INFORMATION134
23071 ,P_PCP_ATTRIBUTE25 => r_PCP.INFORMATION135
23072 ,P_PCP_ATTRIBUTE26 => r_PCP.INFORMATION136
23073 ,P_PCP_ATTRIBUTE27 => r_PCP.INFORMATION137
23074 ,P_PCP_ATTRIBUTE28 => r_PCP.INFORMATION138
23075 ,P_PCP_ATTRIBUTE29 => r_PCP.INFORMATION139
23076 ,P_PCP_ATTRIBUTE3 => r_PCP.INFORMATION113
23077 ,P_PCP_ATTRIBUTE30 => r_PCP.INFORMATION140
23078 ,P_PCP_ATTRIBUTE4 => r_PCP.INFORMATION114
23079 ,P_PCP_ATTRIBUTE5 => r_PCP.INFORMATION115
23080 ,P_PCP_ATTRIBUTE6 => r_PCP.INFORMATION116
23081 ,P_PCP_ATTRIBUTE7 => r_PCP.INFORMATION117
23082 ,P_PCP_ATTRIBUTE8 => r_PCP.INFORMATION118
23083 ,P_PCP_ATTRIBUTE9 => r_PCP.INFORMATION119
23084 ,P_PCP_ATTRIBUTE_CATEGORY => r_PCP.INFORMATION110
23085 ,P_PCP_CAN_KEEP_FLAG => r_PCP.INFORMATION15
23086 ,P_PCP_DPNT_DSGN_CD => r_PCP.INFORMATION13
23087 ,P_PCP_DSGN_CD => r_PCP.INFORMATION12
23088 ,P_PCP_NUM_CHGS => r_PCP.INFORMATION294
23089 ,P_PCP_NUM_CHGS_UOM => r_PCP.INFORMATION18
23090 ,P_PCP_RADIUS => r_PCP.INFORMATION293
23091 ,P_PCP_RADIUS_UOM => r_PCP.INFORMATION16
23092 ,P_PCP_RADIUS_WARN_FLAG => r_PCP.INFORMATION17
23093 ,P_PCP_RPSTRY_FLAG => r_PCP.INFORMATION14
23094 ,P_PCP_STRT_DT_CD => r_PCP.INFORMATION11
23095 ,P_PL_ID => l_PL_ID
23096 ,P_PL_PCP_ID => l_pl_pcp_id
23097 --
23098 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
23099 );
23100 end if;
23101 --
23102 l_prev_pk_id := l_current_pk_id ;
23103 --
23104 end if;
23105 --
23106 end if;
23107 --
23108 end loop;
23109 --
23110 exception when others then
23111 --
23112 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PCP',r_pcp.information5 );
23113 --
23114 end create_PCP_rows;
23115
23116 --
23117 ---------------------------------------------------------------
23118 ----------------------< create_COP_rows >-----------------------
23119 ---------------------------------------------------------------
23120 --
23121 procedure create_COP_rows
23122 (
23123 p_validate in number default 0
23124 ,p_copy_entity_txn_id in number
23125 ,p_effective_date in date
23126 ,p_prefix_suffix_text in varchar2 default null
23127 ,p_reuse_object_flag in varchar2 default null
23128 ,p_target_business_group_id in varchar2 default null
23129 ,p_prefix_suffix_cd in varchar2 default null
23130 ) is
23131 --
23132 l_ACTL_PREM_ID number;
23133 l_AUTO_ENRT_MTHD_RL number;
23134 l_DFLT_ENRT_DET_RL number;
23135 l_ENRT_RL number;
23136 l_MNDTRY_RL number;
23137 l_OPT_ID number;
23138 l_PL_ID number;
23139 l_POSTELCN_EDIT_RL number;
23140 l_RQD_PERD_ENRT_NENRT_RL number;
23141 l_VRFY_FMLY_MMBR_RL number;
23142 cursor c_unique_COP(l_table_alias varchar2) is
23143 select distinct cpe.information1,
23144 cpe.information2,
23145 cpe.information3,
23146 cpe.table_route_id
23147 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
23148 pqh_table_route tr
23149 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23150 and cpe.table_route_id = tr.table_route_id
23151 -- and tr.where_clause = l_BEN_OIPL_F
23152 and tr.table_alias = l_table_alias
23153 and cpe.number_of_copies = 1 -- ADDITION
23154 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
23155 ORDER BY cpe.information1,cpe.information2; -- 5122908. Records need to be created ordered on effective date.
23156 --
23157 --
23158 cursor c_COP_min_max_dates(c_table_route_id number,
23159 c_information1 number) is
23160 select
23161 min(cpe.information2) min_esd,
23162 max(cpe.information3) min_eed
23163 from ben_copy_entity_results cpe
23164 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23165 and cpe.table_route_id = c_table_route_id
23166 and cpe.information1 = c_information1 ;
23167 --
23168 cursor c_COP(c_table_route_id number,
23169 c_information1 number,
23170 c_information2 date,
23171 c_information3 date ) is
23172 select
23173 cpe.*
23174 from ben_copy_entity_results cpe
23175 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23176 and cpe.table_route_id = c_table_route_id
23177 and cpe.information1 = c_information1
23178 and cpe.information2 = c_information2
23179 and cpe.information3 = c_information3
23180 and rownum = 1 ;
23181 -- Date Track target record
23182 cursor c_find_COP_in_target(
23183 c_effective_start_date date,
23184 c_effective_end_date date,
23185 c_business_group_id number,
23186 c_new_pk_id number) is
23187 select
23188 COP.oipl_id new_value
23189 from BEN_OIPL_F COP
23190 where
23191 COP.OPT_ID = l_OPT_ID and
23192 COP.PL_ID = l_PL_ID and
23193 nvl(COP.ACTL_PREM_ID,-999) = nvl(l_ACTL_PREM_ID,-999) and
23194 COP.business_group_id = c_business_group_id
23195 and COP.oipl_id <> c_new_pk_id
23196 --TEMPIK
23197 and c_effective_start_date between effective_start_date
23198 and effective_end_date ;
23199 --END TEMPIK
23200 /*
23201 and exists ( select null
23202 from BEN_OIPL_F COP1
23203 where
23204 COP1.OPT_ID = l_OPT_ID and
23205 COP1.PL_ID = l_PL_ID and
23206 nvl(COP1.ACTL_PREM_ID,-999) = nvl(l_ACTL_PREM_ID,-999) and
23207 COP1.business_group_id = c_business_group_id
23208 and COP1.effective_start_date <= c_effective_start_date )
23209 and exists ( select null
23210 from BEN_OIPL_F COP2
23211 where
23212 COP2.OPT_ID = l_OPT_ID and
23213 COP2.PL_ID = l_PL_ID and
23214 nvl(COP2.ACTL_PREM_ID,-999) = nvl(l_ACTL_PREM_ID,-999) and
23215 COP2.business_group_id = c_business_group_id
23216 and COP2.effective_end_date >= c_effective_end_date )
23217 ;
23218 */
23219 --
23220 --UPD START
23221 --
23222 l_update boolean := false ;
23223 l_datetrack_mode varchar2(80) := hr_api.g_update;
23224 l_process_date date;
23225 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
23226 --
23227 --UPD END
23228 l_current_pk_id number := null ;
23229 l_prev_pk_id number := null ;
23230 l_first_rec boolean := true ;
23231 r_COP c_COP%rowtype;
23232 l_oipl_id number ;
23233 l_object_version_number number ;
23234 l_effective_start_date date ;
23235 l_effective_end_date date ;
23236 l_prefix pqh_copy_entity_attribs.information1%type := null;
23237 l_suffix pqh_copy_entity_attribs.information1%type := null;
23238 l_new_value number(15);
23239 l_object_found_in_target boolean := false ;
23240 l_min_esd date;
23241 l_max_eed date;
23242 l_effective_date date;
23243 --TEMPIK
23244 l_dt_rec_found boolean ;
23245 --END TEMPIK
23246 --
23247 begin
23248 -- Initialization
23249 l_object_found_in_target := false ;
23250 -- End Initialization
23251 -- Derive the prefix - sufix
23252 if p_prefix_suffix_cd = 'PREFIX' then
23253 l_prefix := p_prefix_suffix_text ;
23254 elsif p_prefix_suffix_cd = 'SUFFIX' then
23255 l_suffix := p_prefix_suffix_text ;
23256 else
23257 l_prefix := null ;
23258 l_suffix := null ;
23259 end if ;
23260 -- End Prefix Sufix derivation
23261 for r_COP_unique in c_unique_COP('COP') loop
23262
23263 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
23264 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23265 r_COP_unique.information3 >=
23266 ben_pd_copy_to_ben_one.g_copy_effective_date)
23267 ) then
23268 --
23269 hr_utility.set_location(' r_COP_unique.table_route_id '||r_COP_unique.table_route_id,10);
23270 hr_utility.set_location(' r_COP_unique.information1 '||r_COP_unique.information1,10);
23271 hr_utility.set_location( 'r_COP_unique.information2 '||r_COP_unique.information2,10);
23272 hr_utility.set_location( 'r_COP_unique.information3 '||r_COP_unique.information3,10);
23273 -- If reuse objects flag is 'Y' then check for the object in the target business group
23274 -- if found insert the record into PLSql table and exit the loop else try create the
23275 -- object in the target business group
23276 --
23277 l_object_found_in_target := false ;
23278 --UPD START
23279 open c_COP(r_COP_unique.table_route_id,
23280 r_COP_unique.information1,
23281 r_COP_unique.information2,
23282 r_COP_unique.information3 ) ;
23283 --
23284 fetch c_COP into r_COP ;
23285 --
23286 close c_COP ;
23287 --
23288 l_dml_operation:= r_COP_unique.dml_operation ;
23289 l_ACTL_PREM_ID := get_fk('ACTL_PREM_ID', r_COP.INFORMATION250,l_dml_operation );
23290 l_AUTO_ENRT_MTHD_RL := get_fk('FORMULA_ID', r_COP.INFORMATION264,l_dml_operation );
23291 l_DFLT_ENRT_DET_RL := get_fk('FORMULA_ID', r_COP.INFORMATION266,l_dml_operation );
23292 l_ENRT_RL := get_fk('FORMULA_ID', r_COP.INFORMATION257,l_dml_operation );
23293 l_MNDTRY_RL := get_fk('FORMULA_ID', r_COP.INFORMATION268,l_dml_operation );
23294 l_OPT_ID := get_fk('OPT_ID', r_COP.INFORMATION247,l_dml_operation );
23295 l_PL_ID := get_fk('PL_ID', r_COP.INFORMATION261,l_dml_operation );
23296 l_POSTELCN_EDIT_RL := get_fk('FORMULA_ID', r_COP.INFORMATION269,l_dml_operation );
23297 l_RQD_PERD_ENRT_NENRT_RL := get_fk('FORMULA_ID', r_COP.INFORMATION267,l_dml_operation );
23298 l_VRFY_FMLY_MMBR_RL := get_fk('FORMULA_ID', r_COP.INFORMATION270,l_dml_operation );
23299 --
23300 l_update := false;
23301 l_process_date := p_effective_date;
23302 --
23303 if l_dml_operation = 'UPDATE' then
23304 --
23305 l_object_found_in_target := TRUE;
23306 --
23307 if l_process_date between r_COP_unique.information2 and r_COP_unique.information3 then
23308 l_update := true;
23309 if r_COP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
23310 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'OIPL_ID'
23311 then
23312 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OIPL_ID' ;
23313 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_COP_unique.information1 ;
23314 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_COP_unique.information1 ;
23315 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23316 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_COP_unique.table_route_id;
23317 --
23318 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
23319 --
23320 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23321 --
23322 --DOUBT log_data('COP',l_new_value,l_prefix || r_COP_unique.name|| l_suffix,'REUSED');
23323 --
23324 end if ;
23325 hr_utility.set_location( 'found record for update',10);
23326 --
23327 else
23328 --
23329 l_update := false;
23330 --
23331 end if;
23332 else
23333 --
23334 --UPD END
23335 l_min_esd := null ;
23336 l_max_eed := null ;
23337 open c_COP_min_max_dates(r_COP_unique.table_route_id, r_COP_unique.information1 ) ;
23338 fetch c_COP_min_max_dates into l_min_esd,l_max_eed ;
23339 --
23340
23341 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23342 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
23343 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
23344 end if;
23345 l_min_esd := greatest(l_min_esd,r_COP_unique.information2);
23346 /* open c_COP(r_COP_unique.table_route_id,
23347 r_COP_unique.information1,
23348 r_COP_unique.information2,
23349 r_COP_unique.information3 ) ;
23350 --
23351 fetch c_COP into r_COP ;
23352 --
23353 close c_COP ; */
23354 --
23355
23356
23357 if p_reuse_object_flag = 'Y' then
23358 if c_COP_min_max_dates%found then
23359 -- cursor to find the object
23360 open c_find_COP_in_target( l_min_esd,l_max_eed,
23361 p_target_business_group_id, nvl(l_oipl_id, -999) ) ;
23362 fetch c_find_COP_in_target into l_new_value ;
23363 if c_find_COP_in_target%found then
23364 --
23365 --TEMPIK
23366 l_dt_rec_found := dt_api.check_min_max_dates
23367 (p_base_table_name => 'BEN_OIPL_F',
23368 p_base_key_column => 'OIPL_ID',
23369 p_base_key_value => l_new_value,
23370 p_from_date => l_min_esd,
23371 p_to_date => l_max_eed );
23372 if l_dt_rec_found THEN
23373 --END TEMPIK
23374 if r_COP_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
23375 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'OIPL_ID' then
23376 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OIPL_ID' ;
23377 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_COP_unique.information1 ;
23378 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
23379 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23380 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_COP_unique.table_route_id;
23381 --
23382 -- 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) ;
23383 --
23384 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23385 end if ;
23386 --
23387 l_object_found_in_target := true ;
23388 --TEMPIK
23389 end if; -- l_dt_rec_found
23390 --END TEMPIK
23391 end if;
23392 close c_find_COP_in_target ;
23393 --
23394 end if;
23395 end if ;
23396 --
23397 close c_COP_min_max_dates ;
23398 end if; --if p_dml_operation
23399 --
23400 if not l_object_found_in_target OR l_update then
23401 --
23402 l_current_pk_id := r_COP.information1;
23403 --
23404 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
23405 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
23406 --
23407 if l_current_pk_id = l_prev_pk_id then
23408 --
23409 l_first_rec := false ;
23410 --
23411 else
23412 --
23413 l_first_rec := true ;
23414 --
23415 end if ;
23416 --
23417
23418 l_effective_date := r_COP.information2;
23419 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23420 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
23421 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
23422 end if;
23423
23424 if l_first_rec and not l_update then
23425 -- Call Create routine.
23426 hr_utility.set_location(' BEN_OIPL_F CREATE_OPTION_IN_PLAN ',20);
23427 BEN_OPTION_IN_PLAN_API.CREATE_OPTION_IN_PLAN(
23428 --
23429 P_VALIDATE => false
23430 ,P_EFFECTIVE_DATE => l_effective_date
23431 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
23432 --
23433 ,P_ACTL_PREM_ID => l_ACTL_PREM_ID
23434 ,P_AUTO_ENRT_FLAG => r_COP.INFORMATION25
23435 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
23436 ,P_COP_ATTRIBUTE1 => r_COP.INFORMATION111
23437 ,P_COP_ATTRIBUTE10 => r_COP.INFORMATION120
23438 ,P_COP_ATTRIBUTE11 => r_COP.INFORMATION121
23439 ,P_COP_ATTRIBUTE12 => r_COP.INFORMATION122
23440 ,P_COP_ATTRIBUTE13 => r_COP.INFORMATION123
23441 ,P_COP_ATTRIBUTE14 => r_COP.INFORMATION124
23442 ,P_COP_ATTRIBUTE15 => r_COP.INFORMATION125
23443 ,P_COP_ATTRIBUTE16 => r_COP.INFORMATION126
23444 ,P_COP_ATTRIBUTE17 => r_COP.INFORMATION127
23445 ,P_COP_ATTRIBUTE18 => r_COP.INFORMATION128
23446 ,P_COP_ATTRIBUTE19 => r_COP.INFORMATION129
23447 ,P_COP_ATTRIBUTE2 => r_COP.INFORMATION112
23448 ,P_COP_ATTRIBUTE20 => r_COP.INFORMATION130
23449 ,P_COP_ATTRIBUTE21 => r_COP.INFORMATION131
23450 ,P_COP_ATTRIBUTE22 => r_COP.INFORMATION132
23451 ,P_COP_ATTRIBUTE23 => r_COP.INFORMATION133
23452 ,P_COP_ATTRIBUTE24 => r_COP.INFORMATION134
23453 ,P_COP_ATTRIBUTE25 => r_COP.INFORMATION135
23454 ,P_COP_ATTRIBUTE26 => r_COP.INFORMATION136
23455 ,P_COP_ATTRIBUTE27 => r_COP.INFORMATION137
23456 ,P_COP_ATTRIBUTE28 => r_COP.INFORMATION138
23457 ,P_COP_ATTRIBUTE29 => r_COP.INFORMATION139
23458 ,P_COP_ATTRIBUTE3 => r_COP.INFORMATION113
23459 ,P_COP_ATTRIBUTE30 => r_COP.INFORMATION140
23460 ,P_COP_ATTRIBUTE4 => r_COP.INFORMATION114
23461 ,P_COP_ATTRIBUTE5 => r_COP.INFORMATION115
23462 ,P_COP_ATTRIBUTE6 => r_COP.INFORMATION116
23463 ,P_COP_ATTRIBUTE7 => r_COP.INFORMATION117
23464 ,P_COP_ATTRIBUTE8 => r_COP.INFORMATION118
23465 ,P_COP_ATTRIBUTE9 => r_COP.INFORMATION119
23466 ,P_COP_ATTRIBUTE_CATEGORY => r_COP.INFORMATION110
23467 ,P_DFLT_ENRT_CD => r_COP.INFORMATION26
23468 ,P_DFLT_ENRT_DET_RL => l_DFLT_ENRT_DET_RL
23469 ,P_DFLT_FLAG => r_COP.INFORMATION18
23470 ,P_DRVBL_FCTR_APLS_RTS_FLAG => r_COP.INFORMATION24
23471 ,P_DRVBL_FCTR_PRTN_ELIG_FLAG => r_COP.INFORMATION22
23472 ,P_ELIG_APLS_FLAG => r_COP.INFORMATION20
23473 ,P_ENRT_CD => r_COP.INFORMATION14
23474 ,P_ENRT_RL => l_ENRT_RL
23475 ,P_HIDDEN_FLAG => r_COP.INFORMATION13
23476 ,P_IVR_IDENT => r_COP.INFORMATION141
23477 ,P_MNDTRY_FLAG => r_COP.INFORMATION17
23478 ,P_MNDTRY_RL => l_MNDTRY_RL
23479 ,P_OIPL_ID => l_oipl_id
23480 ,P_OIPL_STAT_CD => r_COP.INFORMATION19
23481 ,P_OPT_ID => l_OPT_ID
23482 ,P_ORDR_NUM => r_COP.INFORMATION263
23483 ,P_PCP_DPNT_DSGN_CD => r_COP.INFORMATION16
23484 ,P_PCP_DSGN_CD => r_COP.INFORMATION15
23485 ,P_PER_CVRD_CD => r_COP.INFORMATION27
23486 ,P_PL_ID => l_PL_ID
23487 ,P_POSTELCN_EDIT_RL => l_POSTELCN_EDIT_RL
23488 ,P_PRTN_ELIG_OVRID_ALWD_FLAG => r_COP.INFORMATION23
23489 ,P_RQD_PERD_ENRT_NENRT_RL => l_RQD_PERD_ENRT_NENRT_RL
23490 ,P_RQD_PERD_ENRT_NENRT_UOM => r_COP.INFORMATION29
23491 ,P_RQD_PERD_ENRT_NENRT_VAL => r_COP.INFORMATION293
23492 ,P_SHORT_CODE => r_COP.INFORMATION11
23493 ,P_SHORT_NAME => r_COP.INFORMATION12
23494 ,P_TRK_INELIG_PER_FLAG => r_COP.INFORMATION21
23495 ,P_URL_REF_NAME => r_COP.INFORMATION185
23496 ,P_VRFY_FMLY_MMBR_CD => r_COP.INFORMATION28
23497 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
23498 --ML
23499 ,P_SUSP_IF_CTFN_NOT_PRVD_FLAG => nvl(r_COP.INFORMATION198,'Y')
23500 ,P_CTFN_DETERMINE_CD => r_COP.INFORMATION197
23501 --
23502 ,P_EFFECTIVE_START_DATE => l_effective_start_date
23503 ,P_EFFECTIVE_END_DATE => l_effective_end_date
23504 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
23505 );
23506 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
23507 -- Update all relevent cer records with new pk_id
23508 hr_utility.set_location('Before plsql table ',222);
23509 hr_utility.set_location('new_value id '||l_oipl_id,222);
23510 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OIPL_ID' ;
23511 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_COP.information1 ;
23512 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_OIPL_ID ;
23513 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
23514 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_COP_unique.table_route_id;
23515 hr_utility.set_location('After plsql table ',222);
23516 --
23517 -- 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 ) ;
23518 --
23519 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23520 --
23521 else
23522 --
23523 -- Call Update routine for the pk_id created in prev run .
23524 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
23525 hr_utility.set_location(' BEN_OIPL_F UPDATE_OPTION_IN_PLAN ',30);
23526 --UPD START
23527 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
23528 --
23529 if l_update then
23530 --
23531 l_datetrack_mode := r_COP.datetrack_mode ;
23532 --
23533 get_dt_modes(
23534 p_effective_date => l_process_date,
23535 p_effective_end_date => r_COP.information3,
23536 p_effective_start_date => r_COP.information2,
23537 p_dml_operation => r_COP.dml_operation,
23538 p_datetrack_mode => l_datetrack_mode );
23539 -- p_update => l_update
23540 --
23541 l_effective_date := l_process_date;
23542 l_OIPL_ID := r_COP.information1;
23543 l_object_version_number := r_COP.information265;
23544 --
23545 end if;
23546 --
23547 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
23548 --
23549 IF l_update OR l_dml_operation <> 'UPDATE' THEN
23550 --UPD END
23551 BEN_OPTION_IN_PLAN_API.UPDATE_OPTION_IN_PLAN(
23552 --
23553 P_VALIDATE => false
23554 ,P_EFFECTIVE_DATE => l_effective_date
23555 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
23556 --
23557 ,P_ACTL_PREM_ID => l_ACTL_PREM_ID
23558 ,P_AUTO_ENRT_FLAG => r_COP.INFORMATION25
23559 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
23560 ,P_COP_ATTRIBUTE1 => r_COP.INFORMATION111
23561 ,P_COP_ATTRIBUTE10 => r_COP.INFORMATION120
23562 ,P_COP_ATTRIBUTE11 => r_COP.INFORMATION121
23563 ,P_COP_ATTRIBUTE12 => r_COP.INFORMATION122
23564 ,P_COP_ATTRIBUTE13 => r_COP.INFORMATION123
23565 ,P_COP_ATTRIBUTE14 => r_COP.INFORMATION124
23566 ,P_COP_ATTRIBUTE15 => r_COP.INFORMATION125
23567 ,P_COP_ATTRIBUTE16 => r_COP.INFORMATION126
23568 ,P_COP_ATTRIBUTE17 => r_COP.INFORMATION127
23569 ,P_COP_ATTRIBUTE18 => r_COP.INFORMATION128
23570 ,P_COP_ATTRIBUTE19 => r_COP.INFORMATION129
23571 ,P_COP_ATTRIBUTE2 => r_COP.INFORMATION112
23572 ,P_COP_ATTRIBUTE20 => r_COP.INFORMATION130
23573 ,P_COP_ATTRIBUTE21 => r_COP.INFORMATION131
23574 ,P_COP_ATTRIBUTE22 => r_COP.INFORMATION132
23575 ,P_COP_ATTRIBUTE23 => r_COP.INFORMATION133
23576 ,P_COP_ATTRIBUTE24 => r_COP.INFORMATION134
23577 ,P_COP_ATTRIBUTE25 => r_COP.INFORMATION135
23578 ,P_COP_ATTRIBUTE26 => r_COP.INFORMATION136
23579 ,P_COP_ATTRIBUTE27 => r_COP.INFORMATION137
23580 ,P_COP_ATTRIBUTE28 => r_COP.INFORMATION138
23581 ,P_COP_ATTRIBUTE29 => r_COP.INFORMATION139
23582 ,P_COP_ATTRIBUTE3 => r_COP.INFORMATION113
23583 ,P_COP_ATTRIBUTE30 => r_COP.INFORMATION140
23584 ,P_COP_ATTRIBUTE4 => r_COP.INFORMATION114
23585 ,P_COP_ATTRIBUTE5 => r_COP.INFORMATION115
23586 ,P_COP_ATTRIBUTE6 => r_COP.INFORMATION116
23587 ,P_COP_ATTRIBUTE7 => r_COP.INFORMATION117
23588 ,P_COP_ATTRIBUTE8 => r_COP.INFORMATION118
23589 ,P_COP_ATTRIBUTE9 => r_COP.INFORMATION119
23590 ,P_COP_ATTRIBUTE_CATEGORY => r_COP.INFORMATION110
23591 ,P_DFLT_ENRT_CD => r_COP.INFORMATION26
23592 ,P_DFLT_ENRT_DET_RL => l_DFLT_ENRT_DET_RL
23593 ,P_DFLT_FLAG => r_COP.INFORMATION18
23594 ,P_DRVBL_FCTR_APLS_RTS_FLAG => r_COP.INFORMATION24
23595 ,P_DRVBL_FCTR_PRTN_ELIG_FLAG => r_COP.INFORMATION22
23596 ,P_ELIG_APLS_FLAG => r_COP.INFORMATION20
23597 ,P_ENRT_CD => r_COP.INFORMATION14
23598 ,P_ENRT_RL => l_ENRT_RL
23599 ,P_HIDDEN_FLAG => r_COP.INFORMATION13
23600 ,P_IVR_IDENT => r_COP.INFORMATION141
23601 ,P_MNDTRY_FLAG => r_COP.INFORMATION17
23602 ,P_MNDTRY_RL => l_MNDTRY_RL
23603 ,P_OIPL_ID => l_oipl_id
23604 ,P_OIPL_STAT_CD => r_COP.INFORMATION19
23605 ,P_OPT_ID => l_OPT_ID
23606 ,P_ORDR_NUM => r_COP.INFORMATION263
23607 ,P_PCP_DPNT_DSGN_CD => r_COP.INFORMATION16
23608 ,P_PCP_DSGN_CD => r_COP.INFORMATION15
23609 ,P_PER_CVRD_CD => r_COP.INFORMATION27
23610 ,P_PL_ID => l_PL_ID
23611 ,P_POSTELCN_EDIT_RL => l_POSTELCN_EDIT_RL
23612 ,P_PRTN_ELIG_OVRID_ALWD_FLAG => r_COP.INFORMATION23
23613 ,P_RQD_PERD_ENRT_NENRT_RL => l_RQD_PERD_ENRT_NENRT_RL
23614 ,P_RQD_PERD_ENRT_NENRT_UOM => r_COP.INFORMATION29
23615 ,P_RQD_PERD_ENRT_NENRT_VAL => r_COP.INFORMATION293
23616 ,P_SHORT_CODE => r_COP.INFORMATION11
23617 ,P_SHORT_NAME => r_COP.INFORMATION12
23618 ,P_TRK_INELIG_PER_FLAG => r_COP.INFORMATION21
23619 ,P_URL_REF_NAME => r_COP.INFORMATION185
23620 ,P_VRFY_FMLY_MMBR_CD => r_COP.INFORMATION28
23621 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
23622 --ML
23623 ,P_SUSP_IF_CTFN_NOT_PRVD_FLAG => nvl(r_COP.INFORMATION198,'Y')
23624 ,P_CTFN_DETERMINE_CD => r_COP.INFORMATION197
23625 --
23626 ,P_EFFECTIVE_START_DATE => l_effective_start_date
23627 ,P_EFFECTIVE_END_DATE => l_effective_end_date
23628 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
23629 ,P_DATETRACK_MODE => l_datetrack_mode
23630 );
23631 --
23632 end if; -- l_update
23633 end if;
23634 --
23635 -- Delete the row if it is end dated.
23636 --
23637 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
23638 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
23639 trunc(l_max_eed) = r_COP.information3) then
23640 --
23641 BEN_OPTION_IN_PLAN_API.delete_OPTION_IN_PLAN(
23642 --
23643 p_validate => false
23644 ,p_oipl_id => l_oipl_id
23645 ,p_effective_start_date => l_effective_start_date
23646 ,p_effective_end_date => l_effective_end_date
23647 ,p_object_version_number => l_object_version_number
23648 ,p_effective_date => l_max_eed
23649 ,p_datetrack_mode => hr_api.g_delete
23650 --
23651 );
23652 --
23653 end if;
23654 --
23655 l_prev_pk_id := l_current_pk_id ;
23656 --
23657 end if;
23658 --
23659 end if;
23660 --
23661 end loop;
23662 --
23663 exception when others then
23664 --
23665 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'COP',r_cop.information5 );
23666 --
23667 end create_COP_rows;
23668
23669 --
23670 ---------------------------------------------------------------
23671 ----------------------< create_DDR_rows >-----------------------
23672 ---------------------------------------------------------------
23673 --
23674 procedure create_DDR_rows
23675 (
23676 p_validate in number default 0
23677 ,p_copy_entity_txn_id in number
23678 ,p_effective_date in date
23679 ,p_prefix_suffix_text in varchar2 default null
23680 ,p_reuse_object_flag in varchar2 default null
23681 ,p_target_business_group_id in varchar2 default null
23682 ,p_prefix_suffix_cd in varchar2 default null
23683 ) is
23684 --
23685 l_OIPL_ID number;
23686 l_OPT_ID number;
23687 l_PL_ID number;
23688 l_GRP_RLSHP_CD ben_dsgn_rqmt_f.grp_rlshp_cd%type;
23689 l_DSGN_TYP_CD ben_dsgn_rqmt_f.dsgn_typ_cd%type;
23690 cursor c_unique_DDR(l_table_alias varchar2) is
23691 select distinct cpe.information1,
23692 cpe.information2,
23693 cpe.information3,
23694 cpe.table_route_id
23695 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
23696 pqh_table_route tr
23697 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23698 and cpe.table_route_id = tr.table_route_id
23699 -- and tr.where_clause = l_BEN_DSGN_RQMT_F
23700 and tr.table_alias = l_table_alias
23701 and cpe.number_of_copies = 1 -- ADDITION
23702 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
23703 order by information1, information2; --added for bug: 5151945
23704 --
23705 --
23706 cursor c_DDR_min_max_dates(c_table_route_id number,
23707 c_information1 number) is
23708 select
23709 min(cpe.information2) min_esd,
23710 max(cpe.information3) min_eed
23711 from ben_copy_entity_results cpe
23712 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23713 and cpe.table_route_id = c_table_route_id
23714 and cpe.information1 = c_information1 ;
23715 --
23716 cursor c_DDR(c_table_route_id number,
23717 c_information1 number,
23718 c_information2 date,
23719 c_information3 date) is
23720 select
23721 cpe.*
23722 from ben_copy_entity_results cpe
23723 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23724 and cpe.table_route_id = c_table_route_id
23725 and cpe.information1 = c_information1
23726 and cpe.information2 = c_information2
23727 and cpe.information3 = c_information3
23728 and rownum = 1 ;
23729 -- Date Track target record
23730 cursor c_find_DDR_in_target(
23731 c_effective_start_date date,
23732 c_effective_end_date date,
23733 c_business_group_id number,
23734 c_new_pk_id number) is
23735 select
23736 DDR.dsgn_rqmt_id new_value
23737 from BEN_DSGN_RQMT_F DDR
23738 where
23739 nvl(DDR.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
23740 nvl(DDR.OPT_ID,-999) = nvl(l_OPT_ID,-999) and
23741 nvl(DDR.PL_ID,-999) = nvl(l_PL_ID,-999) and
23742 nvl(DDR.GRP_RLSHP_CD,-999) = nvl(l_GRP_RLSHP_CD,-999) and
23743 nvl(DDR.DSGN_TYP_CD,-999) = nvl(l_DSGN_TYP_CD,-999) and
23744 DDR.business_group_id = c_business_group_id
23745 and DDR.dsgn_rqmt_id <> c_new_pk_id
23746 --TEMPIK
23747 and c_effective_start_date between effective_start_date
23748 and effective_end_date ;
23749 --END TEMPIK
23750 /*
23751 and exists ( select null
23752 from BEN_DSGN_RQMT_F DDR1
23753 where
23754 nvl(DDR1.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
23755 nvl(DDR1.OPT_ID,-999) = nvl(l_OPT_ID,-999) and
23756 nvl(DDR1.PL_ID,-999) = nvl(l_PL_ID,-999) and
23757 nvl(DDR1.GRP_RLSHP_CD,-999) = nvl(l_GRP_RLSHP_CD,-999) and
23758 nvl(DDR1.DSGN_TYP_CD,-999) = nvl(l_DSGN_TYP_CD,-999) and
23759 DDR1.business_group_id = c_business_group_id
23760 and DDR1.effective_start_date <= c_effective_start_date )
23761 and exists ( select null
23762 from BEN_DSGN_RQMT_F DDR2
23763 where
23764 nvl(DDR2.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
23765 nvl(DDR2.OPT_ID,-999) = nvl(l_OPT_ID,-999) and
23766 nvl(DDR2.PL_ID,-999) = nvl(l_PL_ID,-999) and
23767 nvl(DDR2.GRP_RLSHP_CD,-999) = nvl(l_GRP_RLSHP_CD,-999) and
23768 nvl(DDR2.DSGN_TYP_CD,-999) = nvl(l_DSGN_TYP_CD,-999) and
23769 DDR2.business_group_id = c_business_group_id
23770 and DDR2.effective_end_date >= c_effective_end_date )
23771 ;
23772 */
23773 --
23774 --UPD START
23775 --
23776 l_update boolean := false ;
23777 l_datetrack_mode varchar2(80) := hr_api.g_update;
23778 l_process_date date;
23779 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
23780 --
23781 --UPD END
23782 l_current_pk_id number := null ;
23783 l_prev_pk_id number := null ;
23784 l_first_rec boolean := true ;
23785 r_DDR c_DDR%rowtype;
23786 l_dsgn_rqmt_id number ;
23787 l_object_version_number number ;
23788 l_effective_start_date date ;
23789 l_effective_end_date date ;
23790 l_prefix pqh_copy_entity_attribs.information1%type := null;
23791 l_suffix pqh_copy_entity_attribs.information1%type := null;
23792 l_new_value number(15);
23793 l_object_found_in_target boolean := false ;
23794 l_min_esd date;
23795 l_max_eed date;
23796 l_effective_date date;
23797 --TEMPIK
23798 l_dt_rec_found boolean ;
23799 --END TEMPIK
23800 --
23801 begin
23802 -- Initialization
23803 l_object_found_in_target := false ;
23804 -- End Initialization
23805 -- Derive the prefix - sufix
23806 if p_prefix_suffix_cd = 'PREFIX' then
23807 l_prefix := p_prefix_suffix_text ;
23808 elsif p_prefix_suffix_cd = 'SUFFIX' then
23809 l_suffix := p_prefix_suffix_text ;
23810 else
23811 l_prefix := null ;
23812 l_suffix := null ;
23813 end if ;
23814 -- End Prefix Sufix derivation
23815 for r_DDR_unique in c_unique_DDR('DDR') loop
23816
23817 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
23818 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23819 r_DDR_unique.information3 >=
23820 ben_pd_copy_to_ben_one.g_copy_effective_date)
23821 ) then
23822 --
23823 hr_utility.set_location(' r_DDR_unique.table_route_id '||r_DDR_unique.table_route_id,10);
23824 hr_utility.set_location(' r_DDR_unique.information1 '||r_DDR_unique.information1,10);
23825 hr_utility.set_location( 'r_DDR_unique.information2 '||r_DDR_unique.information2,10);
23826 hr_utility.set_location( 'r_DDR_unique.information3 '||r_DDR_unique.information3,10);
23827 -- If reuse objects flag is 'Y' then check for the object in the target business group
23828 -- if found insert the record into PLSql table and exit the loop else try create the
23829 -- object in the target business group
23830 --
23831 l_object_found_in_target := false ;
23832 --UPD START
23833 open c_DDR(r_DDR_unique.table_route_id,
23834 r_DDR_unique.information1,
23835 r_DDR_unique.information2,
23836 r_DDR_unique.information3 ) ;
23837 --
23838 fetch c_DDR into r_DDR ;
23839 --
23840 close c_DDR ;
23841 --
23842 l_dml_operation:= r_DDR_unique.dml_operation ;
23843 l_OIPL_ID := get_fk('OIPL_ID', r_DDR.information258,l_dml_operation );
23844 l_OPT_ID := get_fk('OPT_ID', r_DDR.information247,l_dml_operation );
23845 l_PL_ID := get_fk('PL_ID', r_DDR.information261,l_dml_operation );
23846 l_GRP_RLSHP_CD := r_DDR.information14;
23847 l_DSGN_TYP_CD := r_DDR.information15;
23848 --
23849 l_update := false;
23850 l_process_date := p_effective_date;
23851 --
23852 if l_dml_operation = 'UPDATE' then
23853 --
23854 l_object_found_in_target := TRUE;
23855 --
23856 if l_process_date between r_DDR_unique.information2 and r_DDR_unique.information3 then
23857 l_update := true;
23858 if r_DDR_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
23859 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'DSGN_RQMT_ID'
23860 then
23861 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'DSGN_RQMT_ID' ;
23862 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_DDR_unique.information1 ;
23863 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_DDR_unique.information1 ;
23864 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23865 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_DDR_unique.table_route_id;
23866 --
23867 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
23868 --
23869 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23870 --
23871 --DOUBT log_data('DDR',l_new_value,l_prefix || r_DDR_unique.name|| l_suffix,'REUSED');
23872 --
23873 end if ;
23874 hr_utility.set_location( 'found record for update',10);
23875 --
23876 else
23877 --
23878 l_update := false;
23879 --
23880 end if;
23881 else
23882 --
23883 --UPD END
23884 l_min_esd := null ;
23885 l_max_eed := null ;
23886 open c_DDR_min_max_dates(r_DDR_unique.table_route_id, r_DDR_unique.information1 ) ;
23887 fetch c_DDR_min_max_dates into l_min_esd,l_max_eed ;
23888 --
23889
23890 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23891 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
23892 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
23893 end if;
23894 l_min_esd := greatest(l_min_esd,r_DDR_unique.information2);
23895 /* open c_DDR(r_DDR_unique.table_route_id,
23896 r_DDR_unique.information1,
23897 r_DDR_unique.information2,
23898 r_DDR_unique.information3 ) ;
23899 --
23900 fetch c_DDR into r_DDR ;
23901 --
23902 close c_DDR ; */
23903 --
23904 if p_reuse_object_flag = 'Y' then
23905 if c_DDR_min_max_dates%found then
23906 -- cursor to find the object
23907 open c_find_DDR_in_target( l_min_esd,l_max_eed,
23908 p_target_business_group_id, nvl(l_dsgn_rqmt_id, -999) ) ;
23909 fetch c_find_DDR_in_target into l_new_value ;
23910 if c_find_DDR_in_target%found then
23911 --
23912 --TEMPIK
23913 l_dt_rec_found := dt_api.check_min_max_dates
23914 (p_base_table_name => 'BEN_DSGN_RQMT_F',
23915 p_base_key_column => 'DSGN_RQMT_ID',
23916 p_base_key_value => l_new_value,
23917 p_from_date => l_min_esd,
23918 p_to_date => l_max_eed );
23919 if l_dt_rec_found THEN
23920 --END TEMPIK
23921 if r_DDR_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
23922 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'DSGN_RQMT_ID' then
23923 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'DSGN_RQMT_ID' ;
23924 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_DDR_unique.information1 ;
23925 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
23926 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23927 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_DDR_unique.table_route_id;
23928 --
23929 -- 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) ;
23930 --
23931 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23932 end if ;
23933 --
23934 l_object_found_in_target := true ;
23935 --TEMPIK
23936 end if; -- l_dt_rec_found
23937 --END TEMPIK
23938 end if;
23939 close c_find_DDR_in_target ;
23940 --
23941 end if;
23942 end if ;
23943 --
23944 close c_DDR_min_max_dates ;
23945 end if; --if p_dml_operation
23946 --
23947 if not l_object_found_in_target OR l_update then
23948 --
23949 l_current_pk_id := r_DDR.information1;
23950 --
23951 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
23952 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
23953 --
23954 if l_current_pk_id = l_prev_pk_id then
23955 --
23956 l_first_rec := false ;
23957 --
23958 else
23959 --
23960 l_first_rec := true ;
23961 --
23962 end if ;
23963 --
23964
23965 l_effective_date := r_DDR.information2;
23966 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23967 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
23968 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
23969 end if;
23970
23971 if l_first_rec and not l_update then
23972 -- Call Create routine.
23973 hr_utility.set_location(' BEN_DSGN_RQMT_F CREATE_DESIGN_RQMT ',20);
23974 BEN_DESIGN_RQMT_API.CREATE_DESIGN_RQMT(
23975 --
23976 P_VALIDATE => false
23977 ,P_EFFECTIVE_DATE => l_effective_date
23978 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
23979 --
23980 ,P_CVR_ALL_ELIG_FLAG => r_DDR.INFORMATION13
23981 ,P_DDR_ATTRIBUTE1 => r_DDR.INFORMATION111
23982 ,P_DDR_ATTRIBUTE10 => r_DDR.INFORMATION120
23983 ,P_DDR_ATTRIBUTE11 => r_DDR.INFORMATION121
23984 ,P_DDR_ATTRIBUTE12 => r_DDR.INFORMATION122
23985 ,P_DDR_ATTRIBUTE13 => r_DDR.INFORMATION123
23986 ,P_DDR_ATTRIBUTE14 => r_DDR.INFORMATION124
23987 ,P_DDR_ATTRIBUTE15 => r_DDR.INFORMATION125
23988 ,P_DDR_ATTRIBUTE16 => r_DDR.INFORMATION126
23989 ,P_DDR_ATTRIBUTE17 => r_DDR.INFORMATION127
23990 ,P_DDR_ATTRIBUTE18 => r_DDR.INFORMATION128
23991 ,P_DDR_ATTRIBUTE19 => r_DDR.INFORMATION129
23992 ,P_DDR_ATTRIBUTE2 => r_DDR.INFORMATION112
23993 ,P_DDR_ATTRIBUTE20 => r_DDR.INFORMATION130
23994 ,P_DDR_ATTRIBUTE21 => r_DDR.INFORMATION131
23995 ,P_DDR_ATTRIBUTE22 => r_DDR.INFORMATION132
23996 ,P_DDR_ATTRIBUTE23 => r_DDR.INFORMATION133
23997 ,P_DDR_ATTRIBUTE24 => r_DDR.INFORMATION134
23998 ,P_DDR_ATTRIBUTE25 => r_DDR.INFORMATION135
23999 ,P_DDR_ATTRIBUTE26 => r_DDR.INFORMATION136
24000 ,P_DDR_ATTRIBUTE27 => r_DDR.INFORMATION137
24001 ,P_DDR_ATTRIBUTE28 => r_DDR.INFORMATION138
24002 ,P_DDR_ATTRIBUTE29 => r_DDR.INFORMATION139
24003 ,P_DDR_ATTRIBUTE3 => r_DDR.INFORMATION113
24004 ,P_DDR_ATTRIBUTE30 => r_DDR.INFORMATION140
24005 ,P_DDR_ATTRIBUTE4 => r_DDR.INFORMATION114
24006 ,P_DDR_ATTRIBUTE5 => r_DDR.INFORMATION115
24007 ,P_DDR_ATTRIBUTE6 => r_DDR.INFORMATION116
24008 ,P_DDR_ATTRIBUTE7 => r_DDR.INFORMATION117
24009 ,P_DDR_ATTRIBUTE8 => r_DDR.INFORMATION118
24010 ,P_DDR_ATTRIBUTE9 => r_DDR.INFORMATION119
24011 ,P_DDR_ATTRIBUTE_CATEGORY => r_DDR.INFORMATION110
24012 ,P_DSGN_RQMT_ID => l_dsgn_rqmt_id
24013 ,P_DSGN_TYP_CD => r_DDR.INFORMATION15
24014 ,P_GRP_RLSHP_CD => r_DDR.INFORMATION14
24015 ,P_MN_DPNTS_RQD_NUM => r_DDR.INFORMATION262
24016 ,P_MX_DPNTS_ALWD_NUM => r_DDR.INFORMATION263
24017 ,P_NO_MN_NUM_DFND_FLAG => r_DDR.INFORMATION11
24018 ,P_NO_MX_NUM_DFND_FLAG => r_DDR.INFORMATION12
24019 ,P_OIPL_ID => l_OIPL_ID
24020 ,P_OPT_ID => l_OPT_ID
24021 ,P_PL_ID => l_PL_ID
24022 --
24023 ,P_EFFECTIVE_START_DATE => l_effective_start_date
24024 ,P_EFFECTIVE_END_DATE => l_effective_end_date
24025 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24026 );
24027 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24028 -- Update all relevent cer records with new pk_id
24029 hr_utility.set_location('Before plsql table ',222);
24030 hr_utility.set_location('new_value id '||l_dsgn_rqmt_id,222);
24031 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'DSGN_RQMT_ID' ;
24032 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_DDR.information1 ;
24033 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_DSGN_RQMT_ID ;
24034 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
24035 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_DDR_unique.table_route_id;
24036 hr_utility.set_location('After plsql table ',222);
24037 --
24038 -- 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 ) ;
24039 --
24040 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24041 --
24042 else
24043 --
24044 -- Call Update routine for the pk_id created in prev run .
24045 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24046 hr_utility.set_location(' BEN_DSGN_RQMT_F UPDATE_DESIGN_RQMT ',30);
24047 --UPD START
24048 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
24049 --
24050 if l_update then
24051 --
24052 l_datetrack_mode := r_DDR.datetrack_mode ;
24053 --
24054 get_dt_modes(
24055 p_effective_date => l_process_date,
24056 p_effective_end_date => r_DDR.information3,
24057 p_effective_start_date => r_DDR.information2,
24058 p_dml_operation => r_DDR.dml_operation,
24059 p_datetrack_mode => l_datetrack_mode );
24060 -- p_update => l_update
24061 --
24062 l_effective_date := l_process_date;
24063 l_DSGN_RQMT_ID := r_DDR.information1;
24064 l_object_version_number := r_DDR.information265;
24065 --
24066 end if;
24067 --
24068 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
24069 --
24070 IF l_update OR l_dml_operation <> 'UPDATE' THEN
24071 --UPD END
24072 BEN_DESIGN_RQMT_API.UPDATE_DESIGN_RQMT(
24073 --
24074 P_VALIDATE => false
24075 ,P_EFFECTIVE_DATE => l_effective_date
24076 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24077 --
24078 ,P_CVR_ALL_ELIG_FLAG => r_DDR.INFORMATION13
24079 ,P_DDR_ATTRIBUTE1 => r_DDR.INFORMATION111
24080 ,P_DDR_ATTRIBUTE10 => r_DDR.INFORMATION120
24081 ,P_DDR_ATTRIBUTE11 => r_DDR.INFORMATION121
24082 ,P_DDR_ATTRIBUTE12 => r_DDR.INFORMATION122
24083 ,P_DDR_ATTRIBUTE13 => r_DDR.INFORMATION123
24084 ,P_DDR_ATTRIBUTE14 => r_DDR.INFORMATION124
24085 ,P_DDR_ATTRIBUTE15 => r_DDR.INFORMATION125
24086 ,P_DDR_ATTRIBUTE16 => r_DDR.INFORMATION126
24087 ,P_DDR_ATTRIBUTE17 => r_DDR.INFORMATION127
24088 ,P_DDR_ATTRIBUTE18 => r_DDR.INFORMATION128
24089 ,P_DDR_ATTRIBUTE19 => r_DDR.INFORMATION129
24090 ,P_DDR_ATTRIBUTE2 => r_DDR.INFORMATION112
24091 ,P_DDR_ATTRIBUTE20 => r_DDR.INFORMATION130
24092 ,P_DDR_ATTRIBUTE21 => r_DDR.INFORMATION131
24093 ,P_DDR_ATTRIBUTE22 => r_DDR.INFORMATION132
24094 ,P_DDR_ATTRIBUTE23 => r_DDR.INFORMATION133
24095 ,P_DDR_ATTRIBUTE24 => r_DDR.INFORMATION134
24096 ,P_DDR_ATTRIBUTE25 => r_DDR.INFORMATION135
24097 ,P_DDR_ATTRIBUTE26 => r_DDR.INFORMATION136
24098 ,P_DDR_ATTRIBUTE27 => r_DDR.INFORMATION137
24099 ,P_DDR_ATTRIBUTE28 => r_DDR.INFORMATION138
24100 ,P_DDR_ATTRIBUTE29 => r_DDR.INFORMATION139
24101 ,P_DDR_ATTRIBUTE3 => r_DDR.INFORMATION113
24102 ,P_DDR_ATTRIBUTE30 => r_DDR.INFORMATION140
24103 ,P_DDR_ATTRIBUTE4 => r_DDR.INFORMATION114
24104 ,P_DDR_ATTRIBUTE5 => r_DDR.INFORMATION115
24105 ,P_DDR_ATTRIBUTE6 => r_DDR.INFORMATION116
24106 ,P_DDR_ATTRIBUTE7 => r_DDR.INFORMATION117
24107 ,P_DDR_ATTRIBUTE8 => r_DDR.INFORMATION118
24108 ,P_DDR_ATTRIBUTE9 => r_DDR.INFORMATION119
24109 ,P_DDR_ATTRIBUTE_CATEGORY => r_DDR.INFORMATION110
24110 ,P_DSGN_RQMT_ID => l_dsgn_rqmt_id
24111 ,P_DSGN_TYP_CD => r_DDR.INFORMATION15
24112 ,P_GRP_RLSHP_CD => r_DDR.INFORMATION14
24113 ,P_MN_DPNTS_RQD_NUM => r_DDR.INFORMATION262
24114 ,P_MX_DPNTS_ALWD_NUM => r_DDR.INFORMATION263
24115 ,P_NO_MN_NUM_DFND_FLAG => r_DDR.INFORMATION11
24116 ,P_NO_MX_NUM_DFND_FLAG => r_DDR.INFORMATION12
24117 ,P_OIPL_ID => l_OIPL_ID
24118 ,P_OPT_ID => l_OPT_ID
24119 ,P_PL_ID => l_PL_ID
24120 --
24121 ,P_EFFECTIVE_START_DATE => l_effective_start_date
24122 ,P_EFFECTIVE_END_DATE => l_effective_end_date
24123 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24124 ,P_DATETRACK_MODE => l_datetrack_mode
24125 );
24126 --
24127 end if; -- l_update
24128 end if;
24129 --
24130 -- Delete the row if it is end dated.
24131 --
24132 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
24133 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
24134 trunc(l_max_eed) = r_DDR.information3) then
24135 --
24136 BEN_DESIGN_RQMT_API.delete_DESIGN_RQMT(
24137 --
24138 p_validate => false
24139 ,p_dsgn_rqmt_id => l_dsgn_rqmt_id
24140 ,p_effective_start_date => l_effective_start_date
24141 ,p_effective_end_date => l_effective_end_date
24142 ,p_object_version_number => l_object_version_number
24143 ,p_effective_date => l_max_eed
24144 ,p_datetrack_mode => hr_api.g_delete
24145 --
24146 );
24147 --
24148 end if;
24149 --
24150 l_prev_pk_id := l_current_pk_id ;
24151 --
24152 end if;
24153 --
24154 end if;
24155 --
24156 end loop;
24157 --
24158 exception when others then
24159 --
24160 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'DDR',r_ddr.information5 );
24161 --
24162 end create_DDR_rows;
24163
24164 --
24165 ---------------------------------------------------------------
24166 ----------------------< create_DRR_rows >-----------------------
24167 ---------------------------------------------------------------
24168 --
24169 procedure create_DRR_rows
24170 (
24171 p_validate in number default 0
24172 ,p_copy_entity_txn_id in number
24173 ,p_effective_date in date
24174 ,p_prefix_suffix_text in varchar2 default null
24175 ,p_reuse_object_flag in varchar2 default null
24176 ,p_target_business_group_id in varchar2 default null
24177 ,p_prefix_suffix_cd in varchar2 default null
24178 ) is
24179 --
24180 l_DSGN_RQMT_ID number;
24181 l_rlshp_typ_cd varchar2(100);
24182 cursor c_unique_DRR(l_table_alias varchar2) is
24183 select distinct cpe.information1,
24184 cpe.information2,
24185 cpe.information3,
24186 cpe.table_route_id
24187 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
24188 pqh_table_route tr
24189 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24190 and cpe.table_route_id = tr.table_route_id
24191 -- and tr.where_clause = l_BEN_DSGN_RQMT_RLSHP_TYP
24192 and tr.table_alias = l_table_alias
24193 and cpe.number_of_copies = 1 -- ADDITION
24194 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
24195 order by information1, information2; --added for bug: 5151945
24196 --
24197 --
24198 cursor c_DRR_min_max_dates(c_table_route_id number,
24199 c_information1 number) is
24200 select
24201 min(cpe.information2) min_esd,
24202 max(cpe.information3) min_eed
24203 from ben_copy_entity_results cpe
24204 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24205 and cpe.table_route_id = c_table_route_id
24206 and cpe.information1 = c_information1 ;
24207 --
24208 cursor c_DRR(c_table_route_id number,
24209 c_information1 number,
24210 c_information2 date,
24211 c_information3 date) is
24212 select
24213 cpe.*
24214 from ben_copy_entity_results cpe
24215 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24216 and cpe.table_route_id = c_table_route_id
24217 and cpe.information1 = c_information1
24218 and rownum = 1 ;
24219 -- Date Track target record
24220 cursor c_find_DRR_in_target(
24221 c_effective_start_date date,
24222 c_effective_end_date date,
24223 c_business_group_id number,
24224 c_new_pk_id number) is
24225 select
24226 DRR.dsgn_rqmt_rlshp_typ_id new_value
24227 from BEN_DSGN_RQMT_RLSHP_TYP DRR
24228 where
24229 DRR.DSGN_RQMT_ID = l_DSGN_RQMT_ID and
24230 DRR.rlshp_typ_cd = l_rlshp_typ_cd and
24231 DRR.business_group_id = c_business_group_id
24232 and DRR.dsgn_rqmt_rlshp_typ_id <> c_new_pk_id
24233 ;
24234 --
24235 --UPD START
24236 --
24237 l_update boolean := false ;
24238 l_datetrack_mode varchar2(80) := hr_api.g_update;
24239 l_process_date date;
24240 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
24241 --
24242 --UPD END
24243 l_current_pk_id number := null ;
24244 l_prev_pk_id number := null ;
24245 l_first_rec boolean := true ;
24246 r_DRR c_DRR%rowtype;
24247 l_dsgn_rqmt_rlshp_typ_id number ;
24248 l_object_version_number number ;
24249 l_effective_start_date date ;
24250 l_effective_end_date date ;
24251 l_prefix pqh_copy_entity_attribs.information1%type := null;
24252 l_suffix pqh_copy_entity_attribs.information1%type := null;
24253 l_new_value number(15);
24254 l_object_found_in_target boolean := false ;
24255 l_min_esd date;
24256 l_max_eed date;
24257 l_parent_effective_start_date date;
24258 --
24259 begin
24260 -- Initialization
24261 l_object_found_in_target := false ;
24262 -- End Initialization
24263 -- Derive the prefix - sufix
24264 if p_prefix_suffix_cd = 'PREFIX' then
24265 l_prefix := p_prefix_suffix_text ;
24266 elsif p_prefix_suffix_cd = 'SUFFIX' then
24267 l_suffix := p_prefix_suffix_text ;
24268 else
24269 l_prefix := null ;
24270 l_suffix := null ;
24271 end if ;
24272 -- End Prefix Sufix derivation
24273 for r_DRR_unique in c_unique_DRR('DRR') loop
24274 --
24275 hr_utility.set_location(' r_DRR_unique.table_route_id '||r_DRR_unique.table_route_id,10);
24276 hr_utility.set_location(' r_DRR_unique.information1 '||r_DRR_unique.information1,10);
24277 hr_utility.set_location( 'r_DRR_unique.information2 '||r_DRR_unique.information2,10);
24278 hr_utility.set_location( 'r_DRR_unique.information3 '||r_DRR_unique.information3,10);
24279 -- If reuse objects flag is 'Y' then check for the object in the target business group
24280 -- if found insert the record into PLSql table and exit the loop else try create the
24281 -- object in the target business group
24282 --
24283 l_object_found_in_target := false ;
24284 l_min_esd := null ;
24285 l_max_eed := null ;
24286 --
24287 open c_DRR(r_DRR_unique.table_route_id,
24288 r_DRR_unique.information1,
24289 r_DRR_unique.information2,
24290 r_DRR_unique.information3 ) ;
24291 --
24292 fetch c_DRR into r_DRR ;
24293 --
24294 close c_DRR ;
24295 --
24296 --UPD START
24297 --
24298 l_update := false;
24299 l_process_date := p_effective_date;
24300 l_dml_operation:= r_DRR_unique.dml_operation ;
24301 --
24302 --UPD END
24303 l_DSGN_RQMT_ID := get_fk('DSGN_RQMT_ID', r_DRR.information260,l_dml_operation);
24304 l_rlshp_typ_cd := r_DRR.information11;
24305 --UPD START
24306 --
24307 if l_dml_operation = 'UPDATE' then
24308 --
24309 l_update := true;
24310 if r_DRR_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
24311 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'DSGN_RQMT_RLSHP_TYP_ID' then
24312 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'DSGN_RQMT_RLSHP_TYP_ID' ;
24313 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_DRR_unique.information1 ;
24314 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_DRR_unique.information1 ;
24315 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
24316 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_DRR_unique.table_route_id;
24317 --
24318 -- 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 ) ; -- NEW
24319 --
24320 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24321 --
24322 --DOUBT log_data('DRR',l_new_value,l_prefix || r_DRR_unique.name|| l_suffix,'REUSED');
24323 --
24324 end if ;
24325 l_DSGN_RQMT_RLSHP_TYP_ID := r_DRR_unique.information1 ;
24326 l_object_version_number := r_DRR.information265 ;
24327 hr_utility.set_location( 'found record for update',10);
24328 --
24329 else
24330 --
24331 --UPD END
24332 if p_reuse_object_flag = 'Y' then
24333 -- cursor to find the object
24334 open c_find_DRR_in_target( r_DRR_unique.information2,l_max_eed,
24335 p_target_business_group_id, nvl(l_dsgn_rqmt_rlshp_typ_id, -999) ) ;
24336 fetch c_find_DRR_in_target into l_new_value ;
24337 if c_find_DRR_in_target%found then
24338 --
24339 if r_DRR_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
24340 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'DSGN_RQMT_RLSHP_TYP_ID' then
24341 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'DSGN_RQMT_RLSHP_TYP_ID' ;
24342 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_DRR_unique.information1 ;
24343 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
24344 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
24345 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_DRR_unique.table_route_id;
24346 --
24347 -- 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) ;
24348 --
24349 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24350 end if ;
24351 --
24352 l_object_found_in_target := true ;
24353 end if;
24354 close c_find_DRR_in_target ;
24355 --
24356 end if ;
24357 --
24358 end if; --if p_dml_operation
24359 --
24360 if not l_object_found_in_target OR l_update then
24361 --
24362 l_current_pk_id := r_DRR.information1;
24363 --
24364 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
24365 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
24366 --
24367 if l_current_pk_id = l_prev_pk_id then
24368 --
24369 l_first_rec := false ;
24370 --
24371 else
24372 --
24373 l_first_rec := true ;
24374 --
24375 end if ;
24376 --
24377
24378 l_parent_effective_start_date := r_DRR.information10;
24379 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null ) then
24380 if l_parent_effective_start_date is null then
24381 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
24382 elsif l_parent_effective_start_date < ben_pd_copy_to_ben_one.g_copy_effective_date then
24383 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
24384 end if;
24385 end if;
24386 --
24387 -- To avoid creating a child with out a parent
24388 --
24389 --
24390 if l_DSGN_RQMT_ID is null then
24391 l_first_rec := false ;
24392 end if;
24393 --
24394 if l_first_rec and not l_update then
24395 -- Call Create routine.
24396 hr_utility.set_location(' BEN_DSGN_RQMT_RLSHP_TYP CREATE_DSGN_RQMT_RLSHP_TYP ',20);
24397 BEN_DSGN_RQMT_RLSHP_TYP_API.CREATE_DSGN_RQMT_RLSHP_TYP(
24398 --
24399 P_VALIDATE => false
24400 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
24401 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24402 --
24403 ,P_DRR_ATTRIBUTE1 => r_DRR.INFORMATION111
24404 ,P_DRR_ATTRIBUTE10 => r_DRR.INFORMATION120
24405 ,P_DRR_ATTRIBUTE11 => r_DRR.INFORMATION121
24406 ,P_DRR_ATTRIBUTE12 => r_DRR.INFORMATION122
24407 ,P_DRR_ATTRIBUTE13 => r_DRR.INFORMATION123
24408 ,P_DRR_ATTRIBUTE14 => r_DRR.INFORMATION124
24409 ,P_DRR_ATTRIBUTE15 => r_DRR.INFORMATION125
24410 ,P_DRR_ATTRIBUTE16 => r_DRR.INFORMATION126
24411 ,P_DRR_ATTRIBUTE17 => r_DRR.INFORMATION127
24412 ,P_DRR_ATTRIBUTE18 => r_DRR.INFORMATION128
24413 ,P_DRR_ATTRIBUTE19 => r_DRR.INFORMATION129
24414 ,P_DRR_ATTRIBUTE2 => r_DRR.INFORMATION112
24415 ,P_DRR_ATTRIBUTE20 => r_DRR.INFORMATION130
24416 ,P_DRR_ATTRIBUTE21 => r_DRR.INFORMATION131
24417 ,P_DRR_ATTRIBUTE22 => r_DRR.INFORMATION132
24418 ,P_DRR_ATTRIBUTE23 => r_DRR.INFORMATION133
24419 ,P_DRR_ATTRIBUTE24 => r_DRR.INFORMATION134
24420 ,P_DRR_ATTRIBUTE25 => r_DRR.INFORMATION135
24421 ,P_DRR_ATTRIBUTE26 => r_DRR.INFORMATION136
24422 ,P_DRR_ATTRIBUTE27 => r_DRR.INFORMATION137
24423 ,P_DRR_ATTRIBUTE28 => r_DRR.INFORMATION138
24424 ,P_DRR_ATTRIBUTE29 => r_DRR.INFORMATION139
24425 ,P_DRR_ATTRIBUTE3 => r_DRR.INFORMATION113
24426 ,P_DRR_ATTRIBUTE30 => r_DRR.INFORMATION140
24427 ,P_DRR_ATTRIBUTE4 => r_DRR.INFORMATION114
24428 ,P_DRR_ATTRIBUTE5 => r_DRR.INFORMATION115
24429 ,P_DRR_ATTRIBUTE6 => r_DRR.INFORMATION116
24430 ,P_DRR_ATTRIBUTE7 => r_DRR.INFORMATION117
24431 ,P_DRR_ATTRIBUTE8 => r_DRR.INFORMATION118
24432 ,P_DRR_ATTRIBUTE9 => r_DRR.INFORMATION119
24433 ,P_DRR_ATTRIBUTE_CATEGORY => r_DRR.INFORMATION110
24434 ,P_DSGN_RQMT_ID => l_DSGN_RQMT_ID
24435 ,P_DSGN_RQMT_RLSHP_TYP_ID => l_dsgn_rqmt_rlshp_typ_id
24436 ,P_RLSHP_TYP_CD => r_DRR.INFORMATION11
24437 --
24438 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24439 );
24440 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24441 -- Update all relevent cer records with new pk_id
24442 hr_utility.set_location('Before plsql table ',222);
24443 hr_utility.set_location('new_value id '||l_dsgn_rqmt_rlshp_typ_id,222);
24444 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'DSGN_RQMT_RLSHP_TYP_ID' ;
24445 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_DRR.information1 ;
24446 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_DSGN_RQMT_RLSHP_TYP_ID ;
24447 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
24448 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_DRR_unique.table_route_id;
24449 hr_utility.set_location('After plsql table ',222);
24450 --
24451 -- 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 ) ;
24452 --
24453 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24454 --
24455 elsif l_update then
24456 BEN_DSGN_RQMT_RLSHP_TYP_API.UPDATE_DSGN_RQMT_RLSHP_TYP(
24457 --
24458 P_VALIDATE => false
24459 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
24460 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24461 --
24462 ,P_DRR_ATTRIBUTE1 => r_DRR.INFORMATION111
24463 ,P_DRR_ATTRIBUTE10 => r_DRR.INFORMATION120
24464 ,P_DRR_ATTRIBUTE11 => r_DRR.INFORMATION121
24465 ,P_DRR_ATTRIBUTE12 => r_DRR.INFORMATION122
24466 ,P_DRR_ATTRIBUTE13 => r_DRR.INFORMATION123
24467 ,P_DRR_ATTRIBUTE14 => r_DRR.INFORMATION124
24468 ,P_DRR_ATTRIBUTE15 => r_DRR.INFORMATION125
24469 ,P_DRR_ATTRIBUTE16 => r_DRR.INFORMATION126
24470 ,P_DRR_ATTRIBUTE17 => r_DRR.INFORMATION127
24471 ,P_DRR_ATTRIBUTE18 => r_DRR.INFORMATION128
24472 ,P_DRR_ATTRIBUTE19 => r_DRR.INFORMATION129
24473 ,P_DRR_ATTRIBUTE2 => r_DRR.INFORMATION112
24474 ,P_DRR_ATTRIBUTE20 => r_DRR.INFORMATION130
24475 ,P_DRR_ATTRIBUTE21 => r_DRR.INFORMATION131
24476 ,P_DRR_ATTRIBUTE22 => r_DRR.INFORMATION132
24477 ,P_DRR_ATTRIBUTE23 => r_DRR.INFORMATION133
24478 ,P_DRR_ATTRIBUTE24 => r_DRR.INFORMATION134
24479 ,P_DRR_ATTRIBUTE25 => r_DRR.INFORMATION135
24480 ,P_DRR_ATTRIBUTE26 => r_DRR.INFORMATION136
24481 ,P_DRR_ATTRIBUTE27 => r_DRR.INFORMATION137
24482 ,P_DRR_ATTRIBUTE28 => r_DRR.INFORMATION138
24483 ,P_DRR_ATTRIBUTE29 => r_DRR.INFORMATION139
24484 ,P_DRR_ATTRIBUTE3 => r_DRR.INFORMATION113
24485 ,P_DRR_ATTRIBUTE30 => r_DRR.INFORMATION140
24486 ,P_DRR_ATTRIBUTE4 => r_DRR.INFORMATION114
24487 ,P_DRR_ATTRIBUTE5 => r_DRR.INFORMATION115
24488 ,P_DRR_ATTRIBUTE6 => r_DRR.INFORMATION116
24489 ,P_DRR_ATTRIBUTE7 => r_DRR.INFORMATION117
24490 ,P_DRR_ATTRIBUTE8 => r_DRR.INFORMATION118
24491 ,P_DRR_ATTRIBUTE9 => r_DRR.INFORMATION119
24492 ,P_DRR_ATTRIBUTE_CATEGORY => r_DRR.INFORMATION110
24493 ,P_DSGN_RQMT_ID => l_DSGN_RQMT_ID
24494 ,P_DSGN_RQMT_RLSHP_TYP_ID => l_dsgn_rqmt_rlshp_typ_id
24495 ,P_RLSHP_TYP_CD => r_DRR.INFORMATION11
24496 --
24497 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24498 );
24499 end if;
24500 --
24501 l_prev_pk_id := l_current_pk_id ;
24502 --
24503 end if;
24504 --
24505 end loop;
24506 --
24507 exception when others then
24508 --
24509 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'DRR',r_drr.information5 );
24510 --
24511 end create_DRR_rows;
24512
24513 --
24514 ---------------------------------------------------------------
24515 ----------------------< create_OPP_rows >-----------------------
24516 ---------------------------------------------------------------
24517 --
24518 procedure create_OPP_rows
24519 (
24520 p_validate in number default 0
24521 ,p_copy_entity_txn_id in number
24522 ,p_effective_date in date
24523 ,p_prefix_suffix_text in varchar2 default null
24524 ,p_reuse_object_flag in varchar2 default null
24525 ,p_target_business_group_id in varchar2 default null
24526 ,p_prefix_suffix_cd in varchar2 default null
24527 ) is
24528 --
24529 l_OIPL_ID number;
24530 l_PLIP_ID number;
24531 cursor c_unique_OPP(l_table_alias varchar2) is
24532 select distinct cpe.information1,
24533 cpe.information2,
24534 cpe.information3,
24535 cpe.table_route_id
24536 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
24537 pqh_table_route tr
24538 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24539 and cpe.table_route_id = tr.table_route_id
24540 -- and tr.where_clause = l_BEN_OIPLIP_F
24541 and tr.table_alias = l_table_alias
24542 and cpe.number_of_copies = 1 -- ADDITION
24543 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
24544 order by information1, information2; --added for bug: 5151945
24545 --
24546 --
24547 cursor c_OPP_min_max_dates(c_table_route_id number,
24548 c_information1 number) is
24549 select
24550 min(cpe.information2) min_esd,
24551 max(cpe.information3) min_eed
24552 from ben_copy_entity_results cpe
24553 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24554 and cpe.table_route_id = c_table_route_id
24555 and cpe.information1 = c_information1 ;
24556 --
24557 cursor c_OPP(c_table_route_id number,
24558 c_information1 number,
24559 c_information2 date,
24560 c_information3 date ) is
24561 select
24562 cpe.*
24563 from ben_copy_entity_results cpe
24564 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24565 and cpe.table_route_id = c_table_route_id
24566 and cpe.information1 = c_information1
24567 and cpe.information2 = c_information2
24568 and cpe.information3 = c_information3
24569 and rownum = 1 ;
24570 -- Date Track target record
24571 cursor c_find_OPP_in_target(
24572 c_effective_start_date date,
24573 c_effective_end_date date,
24574 c_business_group_id number,
24575 c_new_pk_id number) is
24576 select
24577 OPP.oiplip_id new_value
24578 from BEN_OIPLIP_F OPP
24579 where
24580 OPP.OIPL_ID = l_OIPL_ID and
24581 OPP.PLIP_ID = l_PLIP_ID and
24582 OPP.business_group_id = c_business_group_id
24583 and OPP.oiplip_id <> c_new_pk_id
24584 --TEMPIK
24585 and c_effective_start_date between effective_start_date
24586 and effective_end_date ;
24587 --END TEMPIK
24588 /*
24589 and exists ( select null
24590 from BEN_OIPLIP_F OPP1
24591 where
24592 OPP1.OIPL_ID = l_OIPL_ID and
24593 OPP1.PLIP_ID = l_PLIP_ID and
24594 OPP1.business_group_id = c_business_group_id
24595 and OPP1.effective_start_date <= c_effective_start_date )
24596 and exists ( select null
24597 from BEN_OIPLIP_F OPP2
24598 where
24599 OPP2.OIPL_ID = l_OIPL_ID and
24600 OPP2.PLIP_ID = l_PLIP_ID and
24601 OPP2.business_group_id = c_business_group_id
24602 and OPP2.effective_end_date >= c_effective_end_date )
24603 ;
24604 */
24605 --
24606 l_current_pk_id number := null ;
24607 l_prev_pk_id number := null ;
24608 l_first_rec boolean := true ;
24609 r_OPP c_OPP%rowtype;
24610 l_oiplip_id number ;
24611 l_object_version_number number ;
24612 l_effective_start_date date ;
24613 l_effective_end_date date ;
24614 l_prefix pqh_copy_entity_attribs.information1%type := null;
24615 l_suffix pqh_copy_entity_attribs.information1%type := null;
24616 l_new_value number(15);
24617 l_object_found_in_target boolean := false ;
24618 l_min_esd date;
24619 l_max_eed date;
24620 l_effective_date date;
24621 --TEMPIK
24622 l_dt_rec_found boolean ;
24623 --END TEMPIK
24624 --
24625 begin
24626 -- Initialization
24627 l_object_found_in_target := false ;
24628 -- End Initialization
24629 -- Derive the prefix - sufix
24630 if p_prefix_suffix_cd = 'PREFIX' then
24631 l_prefix := p_prefix_suffix_text ;
24632 elsif p_prefix_suffix_cd = 'SUFFIX' then
24633 l_suffix := p_prefix_suffix_text ;
24634 else
24635 l_prefix := null ;
24636 l_suffix := null ;
24637 end if ;
24638 -- End Prefix Sufix derivation
24639 for r_OPP_unique in c_unique_OPP('OPP') loop
24640
24641 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
24642 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24643 r_OPP_unique.information3 >=
24644 ben_pd_copy_to_ben_one.g_copy_effective_date)
24645 ) then
24646 --
24647 hr_utility.set_location(' r_OPP_unique.table_route_id '||r_OPP_unique.table_route_id,10);
24648 hr_utility.set_location(' r_OPP_unique.information1 '||r_OPP_unique.information1,10);
24649 hr_utility.set_location( 'r_OPP_unique.information2 '||r_OPP_unique.information2,10);
24650 hr_utility.set_location( 'r_OPP_unique.information3 '||r_OPP_unique.information3,10);
24651 -- If reuse objects flag is 'Y' then check for the object in the target business group
24652 -- if found insert the record into PLSql table and exit the loop else try create the
24653 -- object in the target business group
24654 --
24655 l_object_found_in_target := false ;
24656 l_min_esd := null ;
24657 l_max_eed := null ;
24658 open c_OPP_min_max_dates(r_OPP_unique.table_route_id, r_OPP_unique.information1 ) ;
24659 fetch c_OPP_min_max_dates into l_min_esd,l_max_eed ;
24660 --
24661
24662 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24663 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
24664 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
24665 end if;
24666 l_min_esd := greatest(l_min_esd,r_OPP_unique.information2);
24667 open c_OPP(r_OPP_unique.table_route_id,
24668 r_OPP_unique.information1,
24669 r_OPP_unique.information2,
24670 r_OPP_unique.information3 ) ;
24671 --
24672 fetch c_OPP into r_OPP ;
24673 --
24674 close c_OPP ;
24675 --
24676 l_OIPL_ID := get_fk('OIPL_ID', r_OPP.INFORMATION258);
24677 l_PLIP_ID := get_fk('PLIP_ID', r_OPP.INFORMATION256);
24678 -- if p_reuse_object_flag = 'Y' then
24679 if c_OPP_min_max_dates%found then
24680 -- cursor to find the object
24681
24682 -- Bug: 3512195. In the below cursor, pass l_min_esd instead of r_OPP.information2
24683 -- This is because OPP records are not created here, but have already been created
24684 -- while PLIP and OIPL rows are created.
24685
24686 open c_find_OPP_in_target( l_min_esd,l_max_eed,
24687 p_target_business_group_id, nvl(l_oiplip_id, -999) ) ;
24688 fetch c_find_OPP_in_target into l_new_value ;
24689 if c_find_OPP_in_target%found then
24690 --
24691 --TEMPIK
24692 l_dt_rec_found := dt_api.check_min_max_dates
24693 (p_base_table_name => 'BEN_OIPLIP_F',
24694 p_base_key_column => 'OIPLIP_ID',
24695 p_base_key_value => l_new_value,
24696 p_from_date => l_min_esd,
24697 p_to_date => l_max_eed );
24698 if l_dt_rec_found THEN
24699 --END TEMPIK
24700 if r_OPP_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
24701 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'OIPLIP_ID' then
24702 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OIPLIP_ID' ;
24703 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_OPP_unique.information1 ;
24704 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
24705 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED'; -- Always created, never Reused
24706 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_OPP_unique.table_route_id;
24707 --
24708 -- 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) ;
24709 --
24710 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24711 end if ;
24712 --
24713 l_object_found_in_target := true ;
24714 --TEMPIK
24715 end if; -- l_dt_rec_found
24716 --END TEMPIK
24717 end if;
24718 close c_find_OPP_in_target ;
24719 --
24720 end if;
24721 -- end if ;
24722 --
24723 close c_OPP_min_max_dates ;
24724 --
24725 -- NEVER CREATE HERE. THIS IS DONE IN BEN_PLIP_F and BEN_OIPL_F apis.
24726 /*
24727 if not l_object_found_in_target then
24728 --
24729 l_current_pk_id := r_OPP.information1;
24730 --
24731 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
24732 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
24733 --
24734 if l_current_pk_id = l_prev_pk_id then
24735 --
24736 l_first_rec := false ;
24737 --
24738 else
24739 --
24740 l_first_rec := true ;
24741 --
24742 end if ;
24743 --
24744
24745 l_effective_date := r_OPP.information2;
24746 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24747 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
24748 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
24749 end if;
24750
24751 if l_first_rec then
24752 -- Call Create routine.
24753 hr_utility.set_location(' BEN_OIPLIP_F CREATE_OPTION_IN_PLAN_IN_PGM ',20);
24754 BEN_OPTION_IN_PLAN_IN_PGM_API.CREATE_OPTION_IN_PLAN_IN_PGM(
24755 --
24756 P_VALIDATE => false
24757 ,P_EFFECTIVE_DATE => l_effective_date
24758 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24759 --
24760 ,P_OIPLIP_ID => l_oiplip_id
24761 ,P_OIPL_ID => l_OIPL_ID
24762 ,P_OPP_ATTRIBUTE1 => r_OPP.INFORMATION111
24763 ,P_OPP_ATTRIBUTE10 => r_OPP.INFORMATION120
24764 ,P_OPP_ATTRIBUTE11 => r_OPP.INFORMATION121
24765 ,P_OPP_ATTRIBUTE12 => r_OPP.INFORMATION122
24766 ,P_OPP_ATTRIBUTE13 => r_OPP.INFORMATION123
24767 ,P_OPP_ATTRIBUTE14 => r_OPP.INFORMATION124
24768 ,P_OPP_ATTRIBUTE15 => r_OPP.INFORMATION125
24769 ,P_OPP_ATTRIBUTE16 => r_OPP.INFORMATION126
24770 ,P_OPP_ATTRIBUTE17 => r_OPP.INFORMATION127
24771 ,P_OPP_ATTRIBUTE18 => r_OPP.INFORMATION128
24772 ,P_OPP_ATTRIBUTE19 => r_OPP.INFORMATION129
24773 ,P_OPP_ATTRIBUTE2 => r_OPP.INFORMATION112
24774 ,P_OPP_ATTRIBUTE20 => r_OPP.INFORMATION130
24775 ,P_OPP_ATTRIBUTE21 => r_OPP.INFORMATION131
24776 ,P_OPP_ATTRIBUTE22 => r_OPP.INFORMATION132
24777 ,P_OPP_ATTRIBUTE23 => r_OPP.INFORMATION133
24778 ,P_OPP_ATTRIBUTE24 => r_OPP.INFORMATION134
24779 ,P_OPP_ATTRIBUTE25 => r_OPP.INFORMATION135
24780 ,P_OPP_ATTRIBUTE26 => r_OPP.INFORMATION136
24781 ,P_OPP_ATTRIBUTE27 => r_OPP.INFORMATION137
24782 ,P_OPP_ATTRIBUTE28 => r_OPP.INFORMATION138
24783 ,P_OPP_ATTRIBUTE29 => r_OPP.INFORMATION139
24784 ,P_OPP_ATTRIBUTE3 => r_OPP.INFORMATION113
24785 ,P_OPP_ATTRIBUTE30 => r_OPP.INFORMATION140
24786 ,P_OPP_ATTRIBUTE4 => r_OPP.INFORMATION114
24787 ,P_OPP_ATTRIBUTE5 => r_OPP.INFORMATION115
24788 ,P_OPP_ATTRIBUTE6 => r_OPP.INFORMATION116
24789 ,P_OPP_ATTRIBUTE7 => r_OPP.INFORMATION117
24790 ,P_OPP_ATTRIBUTE8 => r_OPP.INFORMATION118
24791 ,P_OPP_ATTRIBUTE9 => r_OPP.INFORMATION119
24792 ,P_OPP_ATTRIBUTE_CATEGORY => r_OPP.INFORMATION110
24793 ,P_PLIP_ID => l_PLIP_ID
24794 --
24795 ,P_EFFECTIVE_START_DATE => l_effective_start_date
24796 ,P_EFFECTIVE_END_DATE => l_effective_end_date
24797 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24798 );
24799 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24800 -- Update all relevent cer records with new pk_id
24801 hr_utility.set_location('Before plsql table ',222);
24802 hr_utility.set_location('new_value id '||l_oiplip_id,222);
24803 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OIPLIP_ID' ;
24804 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_OPP.information1 ;
24805 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_OIPLIP_ID ;
24806 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
24807 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_OPP_unique.table_route_id;
24808 hr_utility.set_location('After plsql table ',222);
24809 --
24810 -- 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 ) ;
24811 --
24812 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24813 --
24814 else
24815 --
24816 -- Call Update routine for the pk_id created in prev run .
24817 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24818 hr_utility.set_location(' BEN_OIPLIP_F UPDATE_OPTION_IN_PLAN_IN_PGM ',30);
24819 BEN_OPTION_IN_PLAN_IN_PGM_API.UPDATE_OPTION_IN_PLAN_IN_PGM(
24820 --
24821 P_VALIDATE => false
24822 ,P_EFFECTIVE_DATE => l_effective_date
24823 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24824 --
24825 ,P_OIPLIP_ID => l_oiplip_id
24826 ,P_OIPL_ID => l_OIPL_ID
24827 ,P_OPP_ATTRIBUTE1 => r_OPP.INFORMATION111
24828 ,P_OPP_ATTRIBUTE10 => r_OPP.INFORMATION120
24829 ,P_OPP_ATTRIBUTE11 => r_OPP.INFORMATION121
24830 ,P_OPP_ATTRIBUTE12 => r_OPP.INFORMATION122
24831 ,P_OPP_ATTRIBUTE13 => r_OPP.INFORMATION123
24832 ,P_OPP_ATTRIBUTE14 => r_OPP.INFORMATION124
24833 ,P_OPP_ATTRIBUTE15 => r_OPP.INFORMATION125
24834 ,P_OPP_ATTRIBUTE16 => r_OPP.INFORMATION126
24835 ,P_OPP_ATTRIBUTE17 => r_OPP.INFORMATION127
24836 ,P_OPP_ATTRIBUTE18 => r_OPP.INFORMATION128
24837 ,P_OPP_ATTRIBUTE19 => r_OPP.INFORMATION129
24838 ,P_OPP_ATTRIBUTE2 => r_OPP.INFORMATION112
24839 ,P_OPP_ATTRIBUTE20 => r_OPP.INFORMATION130
24840 ,P_OPP_ATTRIBUTE21 => r_OPP.INFORMATION131
24841 ,P_OPP_ATTRIBUTE22 => r_OPP.INFORMATION132
24842 ,P_OPP_ATTRIBUTE23 => r_OPP.INFORMATION133
24843 ,P_OPP_ATTRIBUTE24 => r_OPP.INFORMATION134
24844 ,P_OPP_ATTRIBUTE25 => r_OPP.INFORMATION135
24845 ,P_OPP_ATTRIBUTE26 => r_OPP.INFORMATION136
24846 ,P_OPP_ATTRIBUTE27 => r_OPP.INFORMATION137
24847 ,P_OPP_ATTRIBUTE28 => r_OPP.INFORMATION138
24848 ,P_OPP_ATTRIBUTE29 => r_OPP.INFORMATION139
24849 ,P_OPP_ATTRIBUTE3 => r_OPP.INFORMATION113
24850 ,P_OPP_ATTRIBUTE30 => r_OPP.INFORMATION140
24851 ,P_OPP_ATTRIBUTE4 => r_OPP.INFORMATION114
24852 ,P_OPP_ATTRIBUTE5 => r_OPP.INFORMATION115
24853 ,P_OPP_ATTRIBUTE6 => r_OPP.INFORMATION116
24854 ,P_OPP_ATTRIBUTE7 => r_OPP.INFORMATION117
24855 ,P_OPP_ATTRIBUTE8 => r_OPP.INFORMATION118
24856 ,P_OPP_ATTRIBUTE9 => r_OPP.INFORMATION119
24857 ,P_OPP_ATTRIBUTE_CATEGORY => r_OPP.INFORMATION110
24858 ,P_PLIP_ID => l_PLIP_ID
24859 --
24860 ,P_EFFECTIVE_START_DATE => l_effective_start_date
24861 ,P_EFFECTIVE_END_DATE => l_effective_end_date
24862 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24863 ,P_DATETRACK_MODE => hr_api.g_update
24864 );
24865 --
24866 end if;
24867 --
24868 -- Delete the row if it is end dated.
24869 --
24870 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
24871 trunc(l_max_eed) = r_OPP.information3) then
24872 --
24873 BEN_OPTION_IN_PLAN_IN_PGM_API.delete_OPTION_IN_PLAN_IN_PGM(
24874 --
24875 p_validate => false
24876 ,p_oiplip_id => l_oiplip_id
24877 ,p_effective_start_date => l_effective_start_date
24878 ,p_effective_end_date => l_effective_end_date
24879 ,p_object_version_number => l_object_version_number
24880 ,p_effective_date => l_max_eed
24881 ,p_datetrack_mode => hr_api.g_delete
24882 --
24883 );
24884 --
24885 end if;
24886 --
24887 l_prev_pk_id := l_current_pk_id ;
24888 --
24889 end if;
24890 */
24891 --
24892 end if;
24893 --
24894 end loop;
24895 --
24896 exception when others then
24897 --
24898 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'OPP',r_opp.information5 );
24899 --
24900 end create_OPP_rows;
24901
24902 --
24903 ---------------------------------------------------------------
24904 ----------------------< create_OTP_rows >-----------------------
24905 ---------------------------------------------------------------
24906 --
24907 procedure create_OTP_rows
24908 (
24909 p_validate in number default 0
24910 ,p_copy_entity_txn_id in number
24911 ,p_effective_date in date
24912 ,p_prefix_suffix_text in varchar2 default null
24913 ,p_reuse_object_flag in varchar2 default null
24914 ,p_target_business_group_id in varchar2 default null
24915 ,p_prefix_suffix_cd in varchar2 default null
24916 ) is
24917 --
24918 l_CMBN_PTIP_OPT_ID number;
24919 l_OPT_ID number;
24920 l_PGM_ID number;
24921 l_PL_TYP_ID number;
24922 l_PTIP_ID number;
24923 cursor c_unique_OTP(l_table_alias varchar2) is
24924 select distinct cpe.information1,
24925 cpe.information2,
24926 cpe.information3,
24927 cpe.table_route_id
24928 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
24929 pqh_table_route tr
24930 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24931 and cpe.table_route_id = tr.table_route_id
24932 -- and tr.where_clause = l_BEN_OPTIP_F
24933 and tr.table_alias = l_table_alias
24934 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
24935 order by information1, information2; --added for bug: 5151945
24936 --
24937 --
24938 cursor c_OTP_min_max_dates(c_table_route_id number,
24939 c_information1 number) is
24940 select
24941 min(cpe.information2) min_esd,
24942 max(cpe.information3) min_eed
24943 from ben_copy_entity_results cpe
24944 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24945 and cpe.table_route_id = c_table_route_id
24946 and cpe.information1 = c_information1 ;
24947 --
24948 cursor c_OTP(c_table_route_id number,
24949 c_information1 number,
24950 c_information2 date,
24951 c_information3 date ) is
24952 select
24953 cpe.*
24954 from ben_copy_entity_results cpe
24955 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24956 and cpe.table_route_id = c_table_route_id
24957 and cpe.information1 = c_information1
24958 and cpe.information2 = c_information2
24959 and cpe.information3 = c_information3
24960 and rownum = 1 ;
24961 -- Date Track target record
24962 cursor c_find_OTP_in_target(
24963 c_effective_start_date date,
24964 c_effective_end_date date,
24965 c_business_group_id number,
24966 c_new_pk_id number) is
24967 select
24968 OTP.optip_id new_value
24969 from BEN_OPTIP_F OTP
24970 where
24971 -- nvl(OTP.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999) and
24972 OTP.OPT_ID = l_OPT_ID and
24973 OTP.PGM_ID = l_PGM_ID and
24974 OTP.PL_TYP_ID = l_PL_TYP_ID and
24975 -- nvl(OTP.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
24976 OTP.business_group_id = c_business_group_id
24977 and OTP.optip_id <> c_new_pk_id
24978 --TEMPIK
24979 and c_effective_start_date between effective_start_date
24980 and effective_end_date ;
24981 --END TEMPIK
24982 /*
24983 and exists ( select null
24984 from BEN_OPTIP_F OTP1
24985 where
24986 -- nvl(OTP1.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999) and
24987 OTP1.OPT_ID = l_OPT_ID and
24988 OTP1.PGM_ID = l_PGM_ID and
24989 OTP1.PL_TYP_ID = l_PL_TYP_ID and
24990 -- nvl(OTP1.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
24991 OTP1.business_group_id = c_business_group_id
24992 and OTP1.effective_start_date <= c_effective_start_date )
24993 and exists ( select null
24994 from BEN_OPTIP_F OTP2
24995 where
24996 -- nvl(OTP2.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999) and
24997 OTP2.OPT_ID = l_OPT_ID and
24998 OTP2.PGM_ID = l_PGM_ID and
24999 OTP2.PL_TYP_ID = l_PL_TYP_ID and
25000 -- nvl(OTP2.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
25001 OTP2.business_group_id = c_business_group_id
25002 and OTP2.effective_end_date >= c_effective_end_date )
25003 ;
25004 -- */
25005 l_current_pk_id number := null ;
25006 l_prev_pk_id number := null ;
25007 l_first_rec boolean := true ;
25008 r_OTP c_OTP%rowtype;
25009 l_optip_id number ;
25010 l_object_version_number number ;
25011 l_effective_start_date date ;
25012 l_effective_end_date date ;
25013 l_prefix pqh_copy_entity_attribs.information1%type := null;
25014 l_suffix pqh_copy_entity_attribs.information1%type := null;
25015 l_new_value number(15);
25016 l_object_found_in_target boolean := false ;
25017 l_min_esd date;
25018 l_max_eed date;
25019 l_effective_date date;
25020 --TEMPIK
25021 l_dt_rec_found boolean ;
25022 --END TEMPIK
25023 --
25024 begin
25025 -- Initialization
25026 l_object_found_in_target := false ;
25027 -- End Initialization
25028 -- Derive the prefix - sufix
25029 if p_prefix_suffix_cd = 'PREFIX' then
25030 l_prefix := p_prefix_suffix_text ;
25031 elsif p_prefix_suffix_cd = 'SUFFIX' then
25032 l_suffix := p_prefix_suffix_text ;
25033 else
25034 l_prefix := null ;
25035 l_suffix := null ;
25036 end if ;
25037 -- End Prefix Sufix derivation
25038 for r_OTP_unique in c_unique_OTP('OTP') loop
25039
25040 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
25041 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25042 r_OTP_unique.information3 >=
25043 ben_pd_copy_to_ben_one.g_copy_effective_date)
25044 ) then
25045 --
25046 hr_utility.set_location(' r_OTP_unique.table_route_id '||r_OTP_unique.table_route_id,10);
25047 hr_utility.set_location(' r_OTP_unique.information1 '||r_OTP_unique.information1,10);
25048 hr_utility.set_location( 'r_OTP_unique.information2 '||r_OTP_unique.information2,10);
25049 hr_utility.set_location( 'r_OTP_unique.information3 '||r_OTP_unique.information3,10);
25050 -- If reuse objects flag is 'Y' then check for the object in the target business group
25051 -- if found insert the record into PLSql table and exit the loop else try create the
25052 -- object in the target business group
25053 --
25054 l_object_found_in_target := false ;
25055 l_min_esd := null ;
25056 l_max_eed := null ;
25057 open c_OTP_min_max_dates(r_OTP_unique.table_route_id, r_OTP_unique.information1 ) ;
25058 fetch c_OTP_min_max_dates into l_min_esd,l_max_eed ;
25059 --
25060
25061 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25062 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
25063 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
25064 end if;
25065 l_min_esd := greatest(l_min_esd,r_OTP_unique.information2);
25066 open c_OTP(r_OTP_unique.table_route_id,
25067 r_OTP_unique.information1,
25068 r_OTP_unique.information2,
25069 r_OTP_unique.information3 ) ;
25070 --
25071 fetch c_OTP into r_OTP ;
25072 --
25073 close c_OTP ;
25074 --
25075 l_CMBN_PTIP_OPT_ID := get_fk('CMBN_PTIP_OPT_ID', r_OTP.INFORMATION249);
25076 l_OPT_ID := get_fk('OPT_ID', r_OTP.INFORMATION247);
25077 l_PGM_ID := get_fk('PGM_ID', r_OTP.INFORMATION260);
25078 l_PL_TYP_ID := get_fk('PL_TYP_ID', r_OTP.INFORMATION248);
25079 l_PTIP_ID := get_fk('PTIP_ID', r_OTP.INFORMATION259);
25080 -- if p_reuse_object_flag = 'Y' then
25081 if c_OTP_min_max_dates%found then
25082 -- cursor to find the object
25083 open c_find_OTP_in_target( l_min_esd,l_max_eed,
25084 p_target_business_group_id, nvl(l_optip_id, -999) ) ;
25085 fetch c_find_OTP_in_target into l_new_value ;
25086 if c_find_OTP_in_target%found then
25087 --
25088 --TEMPIK
25089 l_dt_rec_found := dt_api.check_min_max_dates
25090 (p_base_table_name => 'BEN_OPTIP_F',
25091 p_base_key_column => 'OPTIP_ID',
25092 p_base_key_value => l_new_value,
25093 p_from_date => l_min_esd,
25094 p_to_date => l_max_eed );
25095 if l_dt_rec_found THEN
25096 --END TEMPIK
25097 if r_OTP_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
25098 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'OPTIP_ID' then
25099 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OPTIP_ID' ;
25100 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_OTP_unique.information1 ;
25101 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
25102 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED'; -- Always created, never Reused
25103 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_OTP_unique.table_route_id;
25104 --
25105 -- 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) ;
25106 --
25107 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25108 end if ;
25109 --
25110 l_object_found_in_target := true ;
25111 --TEMPIK
25112 end if; -- l_dt_rec_found
25113 --END TEMPIK
25114 end if;
25115 close c_find_OTP_in_target ;
25116 --
25117 end if;
25118 -- end if ;
25119 --
25120 close c_OTP_min_max_dates ;
25121 -- NEVER CREATE HERE. THIS IS DONE IN BEN_OIPL_F, BEN_PLIP_F, BEN_OPT_F and BEN_PTIP_F apis.
25122 /*
25123 if not l_object_found_in_target then
25124 --
25125 l_current_pk_id := r_OTP.information1;
25126 --
25127 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
25128 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
25129 --
25130 if l_current_pk_id = l_prev_pk_id then
25131 --
25132 l_first_rec := false ;
25133 --
25134 else
25135 --
25136 l_first_rec := true ;
25137 --
25138 end if ;
25139 --
25140
25141 l_effective_date := r_OTP.information2;
25142 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25143 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
25144 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
25145 end if;
25146
25147 if l_first_rec then
25148 -- Call Create routine.
25149 hr_utility.set_location(' BEN_OPTIP_F CREATE_OPT_PLTYP_IN_PGM ',20);
25150 BEN_OPT_PLTYP_IN_PGM_API.CREATE_OPT_PLTYP_IN_PGM(
25151 --
25152 P_VALIDATE => false
25153 ,P_EFFECTIVE_DATE => l_effective_date
25154 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25155 --
25156 ,P_CMBN_PTIP_OPT_ID => l_CMBN_PTIP_OPT_ID
25157 ,P_OPTIP_ID => l_optip_id
25158 ,P_OPT_ID => l_OPT_ID
25159 ,P_OTP_ATTRIBUTE1 => r_OTP.INFORMATION111
25160 ,P_OTP_ATTRIBUTE10 => r_OTP.INFORMATION120
25161 ,P_OTP_ATTRIBUTE11 => r_OTP.INFORMATION121
25162 ,P_OTP_ATTRIBUTE12 => r_OTP.INFORMATION122
25163 ,P_OTP_ATTRIBUTE13 => r_OTP.INFORMATION123
25164 ,P_OTP_ATTRIBUTE14 => r_OTP.INFORMATION124
25165 ,P_OTP_ATTRIBUTE15 => r_OTP.INFORMATION125
25166 ,P_OTP_ATTRIBUTE16 => r_OTP.INFORMATION126
25167 ,P_OTP_ATTRIBUTE17 => r_OTP.INFORMATION127
25168 ,P_OTP_ATTRIBUTE18 => r_OTP.INFORMATION128
25169 ,P_OTP_ATTRIBUTE19 => r_OTP.INFORMATION129
25170 ,P_OTP_ATTRIBUTE2 => r_OTP.INFORMATION112
25171 ,P_OTP_ATTRIBUTE20 => r_OTP.INFORMATION130
25172 ,P_OTP_ATTRIBUTE21 => r_OTP.INFORMATION131
25173 ,P_OTP_ATTRIBUTE22 => r_OTP.INFORMATION132
25174 ,P_OTP_ATTRIBUTE23 => r_OTP.INFORMATION133
25175 ,P_OTP_ATTRIBUTE24 => r_OTP.INFORMATION134
25176 ,P_OTP_ATTRIBUTE25 => r_OTP.INFORMATION135
25177 ,P_OTP_ATTRIBUTE26 => r_OTP.INFORMATION136
25178 ,P_OTP_ATTRIBUTE27 => r_OTP.INFORMATION137
25179 ,P_OTP_ATTRIBUTE28 => r_OTP.INFORMATION138
25180 ,P_OTP_ATTRIBUTE29 => r_OTP.INFORMATION139
25181 ,P_OTP_ATTRIBUTE3 => r_OTP.INFORMATION113
25182 ,P_OTP_ATTRIBUTE30 => r_OTP.INFORMATION140
25183 ,P_OTP_ATTRIBUTE4 => r_OTP.INFORMATION114
25184 ,P_OTP_ATTRIBUTE5 => r_OTP.INFORMATION115
25185 ,P_OTP_ATTRIBUTE6 => r_OTP.INFORMATION116
25186 ,P_OTP_ATTRIBUTE7 => r_OTP.INFORMATION117
25187 ,P_OTP_ATTRIBUTE8 => r_OTP.INFORMATION118
25188 ,P_OTP_ATTRIBUTE9 => r_OTP.INFORMATION119
25189 ,P_OTP_ATTRIBUTE_CATEGORY => r_OTP.INFORMATION110
25190 ,P_PGM_ID => l_PGM_ID
25191 ,P_PL_TYP_ID => l_PL_TYP_ID
25192 ,P_PTIP_ID => l_PTIP_ID
25193 --
25194 ,P_EFFECTIVE_START_DATE => l_effective_start_date
25195 ,P_EFFECTIVE_END_DATE => l_effective_end_date
25196 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
25197 );
25198 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
25199 -- Update all relevent cer records with new pk_id
25200 hr_utility.set_location('Before plsql table ',222);
25201 hr_utility.set_location('new_value id '||l_optip_id,222);
25202 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OPTIP_ID' ;
25203 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_OTP.information1 ;
25204 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_OPTIP_ID ;
25205 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
25206 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_OTP_unique.table_route_id;
25207 hr_utility.set_location('After plsql table ',222);
25208 --
25209 -- 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 ) ;
25210 --
25211 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25212 --
25213 else
25214 --
25215 -- Call Update routine for the pk_id created in prev run .
25216 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
25217 hr_utility.set_location(' BEN_OPTIP_F UPDATE_OPT_PLTYP_IN_PGM ',30);
25218 BEN_OPT_PLTYP_IN_PGM_API.UPDATE_OPT_PLTYP_IN_PGM(
25219 --
25220 P_VALIDATE => false
25221 ,P_EFFECTIVE_DATE => l_effective_date
25222 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25223 --
25224 ,P_CMBN_PTIP_OPT_ID => l_CMBN_PTIP_OPT_ID
25225 ,P_OPTIP_ID => l_optip_id
25226 ,P_OPT_ID => l_OPT_ID
25227 ,P_OTP_ATTRIBUTE1 => r_OTP.INFORMATION111
25228 ,P_OTP_ATTRIBUTE10 => r_OTP.INFORMATION120
25229 ,P_OTP_ATTRIBUTE11 => r_OTP.INFORMATION121
25230 ,P_OTP_ATTRIBUTE12 => r_OTP.INFORMATION122
25231 ,P_OTP_ATTRIBUTE13 => r_OTP.INFORMATION123
25232 ,P_OTP_ATTRIBUTE14 => r_OTP.INFORMATION124
25233 ,P_OTP_ATTRIBUTE15 => r_OTP.INFORMATION125
25234 ,P_OTP_ATTRIBUTE16 => r_OTP.INFORMATION126
25235 ,P_OTP_ATTRIBUTE17 => r_OTP.INFORMATION127
25236 ,P_OTP_ATTRIBUTE18 => r_OTP.INFORMATION128
25237 ,P_OTP_ATTRIBUTE19 => r_OTP.INFORMATION129
25238 ,P_OTP_ATTRIBUTE2 => r_OTP.INFORMATION112
25239 ,P_OTP_ATTRIBUTE20 => r_OTP.INFORMATION130
25240 ,P_OTP_ATTRIBUTE21 => r_OTP.INFORMATION131
25241 ,P_OTP_ATTRIBUTE22 => r_OTP.INFORMATION132
25242 ,P_OTP_ATTRIBUTE23 => r_OTP.INFORMATION133
25243 ,P_OTP_ATTRIBUTE24 => r_OTP.INFORMATION134
25244 ,P_OTP_ATTRIBUTE25 => r_OTP.INFORMATION135
25245 ,P_OTP_ATTRIBUTE26 => r_OTP.INFORMATION136
25246 ,P_OTP_ATTRIBUTE27 => r_OTP.INFORMATION137
25247 ,P_OTP_ATTRIBUTE28 => r_OTP.INFORMATION138
25248 ,P_OTP_ATTRIBUTE29 => r_OTP.INFORMATION139
25249 ,P_OTP_ATTRIBUTE3 => r_OTP.INFORMATION113
25250 ,P_OTP_ATTRIBUTE30 => r_OTP.INFORMATION140
25251 ,P_OTP_ATTRIBUTE4 => r_OTP.INFORMATION114
25252 ,P_OTP_ATTRIBUTE5 => r_OTP.INFORMATION115
25253 ,P_OTP_ATTRIBUTE6 => r_OTP.INFORMATION116
25254 ,P_OTP_ATTRIBUTE7 => r_OTP.INFORMATION117
25255 ,P_OTP_ATTRIBUTE8 => r_OTP.INFORMATION118
25256 ,P_OTP_ATTRIBUTE9 => r_OTP.INFORMATION119
25257 ,P_OTP_ATTRIBUTE_CATEGORY => r_OTP.INFORMATION110
25258 ,P_PGM_ID => l_PGM_ID
25259 ,P_PL_TYP_ID => l_PL_TYP_ID
25260 ,P_PTIP_ID => l_PTIP_ID
25261 --
25262 ,P_EFFECTIVE_START_DATE => l_effective_start_date
25263 ,P_EFFECTIVE_END_DATE => l_effective_end_date
25264 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
25265 ,P_DATETRACK_MODE => hr_api.g_update
25266 );
25267 --
25268 end if;
25269 --
25270 -- Delete the row if it is end dated.
25271 --
25272 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
25273 trunc(l_max_eed) = r_OTP.information3) then
25274 --
25275 BEN_OPT_PLTYP_IN_PGM_API.delete_OPT_PLTYP_IN_PGM(
25276 --
25277 p_validate => false
25278 ,p_optip_id => l_optip_id
25279 ,p_effective_start_date => l_effective_start_date
25280 ,p_effective_end_date => l_effective_end_date
25281 ,p_object_version_number => l_object_version_number
25282 ,p_effective_date => l_max_eed
25283 ,p_datetrack_mode => hr_api.g_delete
25284 --
25285 );
25286 --
25287 end if;
25288 --
25289 l_prev_pk_id := l_current_pk_id ;
25290 --
25291 end if;
25292 --
25293 */
25294 end if;
25295 --
25296 end loop;
25297 --
25298 exception when others then
25299 --
25300 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'OTP',r_otp.information5 );
25301 --
25302 end create_OTP_rows;
25303 --
25304 ---------------------------------------------------------------
25305 ----------------------< create_PTY_rows >-----------------------
25306 ---------------------------------------------------------------
25307 --
25308 procedure create_PTY_rows
25309 (
25310 p_validate in number default 0
25311 ,p_copy_entity_txn_id in number
25312 ,p_effective_date in date
25313 ,p_prefix_suffix_text in varchar2 default null
25314 ,p_reuse_object_flag in varchar2 default null
25315 ,p_target_business_group_id in varchar2 default null
25316 ,p_prefix_suffix_cd in varchar2 default null
25317 ) is
25318 --
25319 l_PL_PCP_ID number;
25320 l_GNDR_ALWD_CD ben_pl_pcp_typ.gndr_alwd_cd%type;
25321 l_MAX_AGE ben_pl_pcp_typ.max_age%type;
25322 l_MIN_AGE ben_pl_pcp_typ.min_age%type;
25323 l_PCP_TYP_CD ben_pl_pcp_typ.pcp_typ_cd%type;
25324
25325 cursor c_unique_PTY(l_table_alias varchar2) is
25326 select distinct cpe.information1,
25327 cpe.information2,
25328 cpe.information3,
25329 cpe.table_route_id
25330 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
25331 pqh_table_route tr
25332 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25333 and cpe.table_route_id = tr.table_route_id
25334 -- and tr.where_clause = l_BEN_PL_PCP_TYP
25335 and tr.table_alias = l_table_alias
25336 and cpe.number_of_copies = 1 -- ADDITION
25337 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
25338 order by information1, information2; --added for bug: 5151945
25339 --
25340 --
25341 cursor c_PTY_min_max_dates(c_table_route_id number,
25342 c_information1 number) is
25343 select
25344 min(cpe.information2) min_esd,
25345 max(cpe.information3) min_eed
25346 from ben_copy_entity_results cpe
25347 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25348 and cpe.table_route_id = c_table_route_id
25349 and cpe.information1 = c_information1 ;
25350 --
25351 cursor c_PTY(c_table_route_id number,
25352 c_information1 number,
25353 c_information2 date,
25354 c_information3 date ) is
25355 select
25356 cpe.*
25357 from ben_copy_entity_results cpe
25358 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25359 and cpe.table_route_id = c_table_route_id
25360 and cpe.information1 = c_information1
25361 and rownum = 1 ;
25362 -- Date Track target record
25363 cursor c_find_PTY_in_target(
25364 c_effective_start_date date,
25365 c_effective_end_date date,
25366 c_business_group_id number,
25367 c_new_pk_id number) is
25368 select
25369 PTY.pl_pcp_typ_id new_value
25370 from BEN_PL_PCP_TYP PTY
25371 where
25372 PTY.PL_PCP_ID = l_PL_PCP_ID and
25373 NVL(PTY.GNDR_ALWD_CD,-999) = NVL(l_GNDR_ALWD_CD,-999) and
25374 NVL(PTY.MAX_AGE,-999) = NVL(l_MAX_AGE,-999) and
25375 NVL(PTY.MIN_AGE,-999) = NVL(l_MIN_AGE,-999) and
25376 PTY.PCP_TYP_CD = l_PCP_TYP_CD and
25377 PTY.business_group_id = c_business_group_id
25378 and PTY.pl_pcp_typ_id <> c_new_pk_id
25379 ;
25380 --
25381 --cursor to check the pcp_rpstry_flag
25382 cursor c_rpstry_flag(c_pl_pcp_id in number) is
25383 select pcp_rpstry_flag
25384 from ben_pl_pcp
25385 Where pl_pcp_id = c_pl_pcp_id;
25386
25387 l_rpstry_flag ben_pl_pcp.pcp_rpstry_flag%type;
25388 --
25389 --UPD START
25390 --
25391 l_update boolean := false ;
25392 l_datetrack_mode varchar2(80) := hr_api.g_update;
25393 l_process_date date;
25394 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
25395 --
25396 --UPD END
25397 l_current_pk_id number := null ;
25398 l_prev_pk_id number := null ;
25399 l_first_rec boolean := true ;
25400 r_PTY c_PTY%rowtype;
25401 l_pl_pcp_typ_id number ;
25402 l_object_version_number number ;
25403 l_effective_start_date date ;
25404 l_effective_end_date date ;
25405 l_prefix pqh_copy_entity_attribs.information1%type := null;
25406 l_suffix pqh_copy_entity_attribs.information1%type := null;
25407 l_new_value number(15);
25408 l_object_found_in_target boolean := false ;
25409 l_min_esd date;
25410 l_max_eed date;
25411 --
25412 begin
25413 -- Initialization
25414 l_object_found_in_target := false ;
25415 -- End Initialization
25416 -- Derive the prefix - sufix
25417 if p_prefix_suffix_cd = 'PREFIX' then
25418 l_prefix := p_prefix_suffix_text ;
25419 elsif p_prefix_suffix_cd = 'SUFFIX' then
25420 l_suffix := p_prefix_suffix_text ;
25421 else
25422 l_prefix := null ;
25423 l_suffix := null ;
25424 end if ;
25425 -- End Prefix Sufix derivation
25426 for r_PTY_unique in c_unique_PTY('PTY') loop
25427 --
25428 hr_utility.set_location(' r_PTY_unique.table_route_id '||r_PTY_unique.table_route_id,10);
25429 hr_utility.set_location(' r_PTY_unique.information1 '||r_PTY_unique.information1,10);
25430 hr_utility.set_location( 'r_PTY_unique.information2 '||r_PTY_unique.information2,10);
25431 hr_utility.set_location( 'r_PTY_unique.information3 '||r_PTY_unique.information3,10);
25432 -- If reuse objects flag is 'Y' then check for the object in the target business group
25433 -- if found insert the record into PLSql table and exit the loop else try create the
25434 -- object in the target business group
25435 --
25436 l_object_found_in_target := false ;
25437 l_min_esd := null ;
25438 l_max_eed := null ;
25439 --
25440 open c_PTY(r_PTY_unique.table_route_id,
25441 r_PTY_unique.information1,
25442 r_PTY_unique.information2,
25443 r_PTY_unique.information3 ) ;
25444 --
25445 fetch c_PTY into r_PTY ;
25446 --
25447 close c_PTY ;
25448 --
25449 --UPD START
25450 --
25451 l_update := false;
25452 l_process_date := p_effective_date;
25453 l_dml_operation:= r_PTY_unique.dml_operation ;
25454 --
25455 --UPD END
25456 l_PL_PCP_ID := get_fk('PL_PCP_ID', r_PTY.INFORMATION257,l_dml_operation);
25457 l_GNDR_ALWD_CD := r_PTY.INFORMATION12;
25458 l_MAX_AGE := r_PTY.INFORMATION294;
25459 l_MIN_AGE := r_PTY.INFORMATION293;
25460 l_PCP_TYP_CD := r_PTY.INFORMATION11;
25461
25462 open c_rpstry_flag(l_pl_pcp_id);
25463 fetch c_rpstry_flag into l_rpstry_flag;
25464 close c_rpstry_flag;
25465
25466
25467 if l_rpstry_flag = 'Y' then -- create PTY rows only if the Repository flag is selected in ben_pl_pcp
25468 --UPD START
25469 --
25470 if l_dml_operation = 'UPDATE' then
25471 --
25472 l_update := true;
25473 if r_PTY_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
25474 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_PCP_TYP_ID' then
25475 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_PCP_TYP_ID' ;
25476 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PTY_unique.information1 ;
25477 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PTY_unique.information1 ;
25478 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
25479 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PTY_unique.table_route_id;
25480 --
25481 -- 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 ) ; -- NEW
25482 --
25483 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25484 --
25485 --DOUBT log_data('PTY',l_new_value,l_prefix || r_PTY_unique.name|| l_suffix,'REUSED');
25486 --
25487 end if ;
25488 l_PL_PCP_TYP_ID := r_PTY_unique.information1 ;
25489 l_object_version_number := r_PTY.information265 ;
25490 hr_utility.set_location( 'found record for update',10);
25491 --
25492 else
25493 --
25494 --UPD END
25495
25496 if p_reuse_object_flag = 'Y' then
25497 -- cursor to find the object
25498 open c_find_PTY_in_target( r_PTY_unique.information2 ,l_max_eed,
25499 p_target_business_group_id, nvl(l_pl_pcp_typ_id, -999) ) ;
25500 fetch c_find_PTY_in_target into l_new_value ;
25501 if c_find_PTY_in_target%found then
25502 --
25503 if r_PTY_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
25504 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_PCP_TYP_ID' then
25505 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_PCP_TYP_ID' ;
25506 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PTY_unique.information1 ;
25507 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
25508 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
25509 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PTY_unique.table_route_id;
25510 --
25511 -- 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) ;
25512 --
25513 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25514 end if ;
25515 --
25516 l_object_found_in_target := true ;
25517 end if;
25518 close c_find_PTY_in_target ;
25519 --
25520 end if ;
25521 --
25522 end if; --if p_dml_operation
25523 --
25524 if not l_object_found_in_target OR l_update then
25525
25526 --
25527 l_current_pk_id := r_PTY.information1;
25528 --
25529 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
25530 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
25531 --
25532 if l_current_pk_id = l_prev_pk_id then
25533 --
25534 l_first_rec := false ;
25535 --
25536 else
25537 --
25538 l_first_rec := true ;
25539 --
25540 end if ;
25541 --
25542 if l_first_rec and not l_update then
25543 -- Call Create routine.
25544 hr_utility.set_location(' BEN_PL_PCP_TYP CREATE_PL_CARE_PRVDR_TYP ',20);
25545 BEN_PL_CARE_PRVDR_TYP_API.CREATE_PL_CARE_PRVDR_TYP(
25546 --
25547 P_VALIDATE => false
25548 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
25549 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25550 --
25551 ,P_GNDR_ALWD_CD => r_PTY.INFORMATION12
25552 ,P_MAX_AGE => r_PTY.INFORMATION294
25553 ,P_MIN_AGE => r_PTY.INFORMATION293
25554 ,P_PCP_TYP_CD => r_PTY.INFORMATION11
25555 ,P_PL_PCP_ID => l_PL_PCP_ID
25556 ,P_PL_PCP_TYP_ID => l_pl_pcp_typ_id
25557 ,P_PTY_ATTRIBUTE1 => r_PTY.INFORMATION111
25558 ,P_PTY_ATTRIBUTE10 => r_PTY.INFORMATION120
25559 ,P_PTY_ATTRIBUTE11 => r_PTY.INFORMATION121
25560 ,P_PTY_ATTRIBUTE12 => r_PTY.INFORMATION122
25561 ,P_PTY_ATTRIBUTE13 => r_PTY.INFORMATION123
25562 ,P_PTY_ATTRIBUTE14 => r_PTY.INFORMATION124
25563 ,P_PTY_ATTRIBUTE15 => r_PTY.INFORMATION125
25564 ,P_PTY_ATTRIBUTE16 => r_PTY.INFORMATION126
25565 ,P_PTY_ATTRIBUTE17 => r_PTY.INFORMATION127
25566 ,P_PTY_ATTRIBUTE18 => r_PTY.INFORMATION128
25567 ,P_PTY_ATTRIBUTE19 => r_PTY.INFORMATION129
25568 ,P_PTY_ATTRIBUTE2 => r_PTY.INFORMATION112
25569 ,P_PTY_ATTRIBUTE20 => r_PTY.INFORMATION130
25570 ,P_PTY_ATTRIBUTE21 => r_PTY.INFORMATION131
25571 ,P_PTY_ATTRIBUTE22 => r_PTY.INFORMATION132
25572 ,P_PTY_ATTRIBUTE23 => r_PTY.INFORMATION133
25573 ,P_PTY_ATTRIBUTE24 => r_PTY.INFORMATION134
25574 ,P_PTY_ATTRIBUTE25 => r_PTY.INFORMATION135
25575 ,P_PTY_ATTRIBUTE26 => r_PTY.INFORMATION136
25576 ,P_PTY_ATTRIBUTE27 => r_PTY.INFORMATION137
25577 ,P_PTY_ATTRIBUTE28 => r_PTY.INFORMATION138
25578 ,P_PTY_ATTRIBUTE29 => r_PTY.INFORMATION139
25579 ,P_PTY_ATTRIBUTE3 => r_PTY.INFORMATION113
25580 ,P_PTY_ATTRIBUTE30 => r_PTY.INFORMATION140
25581 ,P_PTY_ATTRIBUTE4 => r_PTY.INFORMATION114
25582 ,P_PTY_ATTRIBUTE5 => r_PTY.INFORMATION115
25583 ,P_PTY_ATTRIBUTE6 => r_PTY.INFORMATION116
25584 ,P_PTY_ATTRIBUTE7 => r_PTY.INFORMATION117
25585 ,P_PTY_ATTRIBUTE8 => r_PTY.INFORMATION118
25586 ,P_PTY_ATTRIBUTE9 => r_PTY.INFORMATION119
25587 ,P_PTY_ATTRIBUTE_CATEGORY => r_PTY.INFORMATION110
25588 --
25589 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
25590 );
25591 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
25592 -- Update all relevent cer records with new pk_id
25593 hr_utility.set_location('Before plsql table ',222);
25594 hr_utility.set_location('new_value id '||l_pl_pcp_typ_id,222);
25595 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_PCP_TYP_ID' ;
25596 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PTY.information1 ;
25597 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PL_PCP_TYP_ID ;
25598 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
25599 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PTY_unique.table_route_id;
25600 hr_utility.set_location('After plsql table ',222);
25601 --
25602 -- 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 ) ;
25603 --
25604 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25605 --
25606 elsif l_update then
25607 BEN_PL_CARE_PRVDR_TYP_API.UPDATE_PL_CARE_PRVDR_TYP(
25608 --
25609 P_VALIDATE => false
25610 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
25611 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25612 --
25613 ,P_GNDR_ALWD_CD => r_PTY.INFORMATION12
25614 ,P_MAX_AGE => r_PTY.INFORMATION294
25615 ,P_MIN_AGE => r_PTY.INFORMATION293
25616 ,P_PCP_TYP_CD => r_PTY.INFORMATION11
25617 ,P_PL_PCP_ID => l_PL_PCP_ID
25618 ,P_PL_PCP_TYP_ID => l_pl_pcp_typ_id
25619 ,P_PTY_ATTRIBUTE1 => r_PTY.INFORMATION111
25620 ,P_PTY_ATTRIBUTE10 => r_PTY.INFORMATION120
25621 ,P_PTY_ATTRIBUTE11 => r_PTY.INFORMATION121
25622 ,P_PTY_ATTRIBUTE12 => r_PTY.INFORMATION122
25623 ,P_PTY_ATTRIBUTE13 => r_PTY.INFORMATION123
25624 ,P_PTY_ATTRIBUTE14 => r_PTY.INFORMATION124
25625 ,P_PTY_ATTRIBUTE15 => r_PTY.INFORMATION125
25626 ,P_PTY_ATTRIBUTE16 => r_PTY.INFORMATION126
25627 ,P_PTY_ATTRIBUTE17 => r_PTY.INFORMATION127
25628 ,P_PTY_ATTRIBUTE18 => r_PTY.INFORMATION128
25629 ,P_PTY_ATTRIBUTE19 => r_PTY.INFORMATION129
25630 ,P_PTY_ATTRIBUTE2 => r_PTY.INFORMATION112
25631 ,P_PTY_ATTRIBUTE20 => r_PTY.INFORMATION130
25632 ,P_PTY_ATTRIBUTE21 => r_PTY.INFORMATION131
25633 ,P_PTY_ATTRIBUTE22 => r_PTY.INFORMATION132
25634 ,P_PTY_ATTRIBUTE23 => r_PTY.INFORMATION133
25635 ,P_PTY_ATTRIBUTE24 => r_PTY.INFORMATION134
25636 ,P_PTY_ATTRIBUTE25 => r_PTY.INFORMATION135
25637 ,P_PTY_ATTRIBUTE26 => r_PTY.INFORMATION136
25638 ,P_PTY_ATTRIBUTE27 => r_PTY.INFORMATION137
25639 ,P_PTY_ATTRIBUTE28 => r_PTY.INFORMATION138
25640 ,P_PTY_ATTRIBUTE29 => r_PTY.INFORMATION139
25641 ,P_PTY_ATTRIBUTE3 => r_PTY.INFORMATION113
25642 ,P_PTY_ATTRIBUTE30 => r_PTY.INFORMATION140
25643 ,P_PTY_ATTRIBUTE4 => r_PTY.INFORMATION114
25644 ,P_PTY_ATTRIBUTE5 => r_PTY.INFORMATION115
25645 ,P_PTY_ATTRIBUTE6 => r_PTY.INFORMATION116
25646 ,P_PTY_ATTRIBUTE7 => r_PTY.INFORMATION117
25647 ,P_PTY_ATTRIBUTE8 => r_PTY.INFORMATION118
25648 ,P_PTY_ATTRIBUTE9 => r_PTY.INFORMATION119
25649 ,P_PTY_ATTRIBUTE_CATEGORY => r_PTY.INFORMATION110
25650 --
25651 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
25652 );
25653 end if;
25654 --
25655 l_prev_pk_id := l_current_pk_id ;
25656 --
25657 end if;
25658 --
25659 end if;
25660 --
25661 end loop;
25662 --
25663 exception when others then
25664 --
25665 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PTY',r_pty.information5 );
25666 --
25667 end create_PTY_rows;
25668
25669 --
25670 ---------------------------------------------------------------
25671 ----------------------< create_PRP_rows >-----------------------
25672 ---------------------------------------------------------------
25673 --
25674 procedure create_PRP_rows
25675 (
25676 p_validate in number default 0
25677 ,p_copy_entity_txn_id in number
25678 ,p_effective_date in date
25679 ,p_prefix_suffix_text in varchar2 default null
25680 ,p_reuse_object_flag in varchar2 default null
25681 ,p_target_business_group_id in varchar2 default null
25682 ,p_prefix_suffix_cd in varchar2 default null
25683 ) is
25684 --
25685 l_PL_REGY_BOD_ID number;
25686
25687 l_PL_REGY_PRPS_CD ben_pl_regy_prp_f.pl_regy_prps_cd%type;
25688 cursor c_unique_PRP(l_table_alias varchar2) is
25689 select distinct cpe.information1,
25690 cpe.information2,
25691 cpe.information3,
25692 cpe.table_route_id
25693 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
25694 pqh_table_route tr
25695 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25696 and cpe.table_route_id = tr.table_route_id
25697 -- and tr.where_clause = l_BEN_PL_REGY_PRP_F
25698 and tr.table_alias = l_table_alias
25699 and cpe.number_of_copies = 1 -- ADDITION
25700 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
25701 order by information1, information2; --added for bug: 5151945
25702 --
25703 --
25704 cursor c_PRP_min_max_dates(c_table_route_id number,
25705 c_information1 number) is
25706 select
25707 min(cpe.information2) min_esd,
25708 max(cpe.information3) min_eed
25709 from ben_copy_entity_results cpe
25710 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25711 and cpe.table_route_id = c_table_route_id
25712 and cpe.information1 = c_information1 ;
25713 --
25714 cursor c_PRP(c_table_route_id number,
25715 c_information1 number,
25716 c_information2 date,
25717 c_information3 date ) is
25718 select
25719 cpe.*
25720 from ben_copy_entity_results cpe
25721 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25722 and cpe.table_route_id = c_table_route_id
25723 and cpe.information1 = c_information1
25724 and cpe.information2 = c_information2
25725 and cpe.information3 = c_information3
25726 and rownum = 1 ;
25727 -- Date Track target record
25728 cursor c_find_PRP_in_target(
25729 c_effective_start_date date,
25730 c_effective_end_date date,
25731 c_business_group_id number,
25732 c_new_pk_id number) is
25733 select
25734 PRP.pl_regy_prps_id new_value
25735 from BEN_PL_REGY_PRP_F PRP
25736 where
25737 PRP.PL_REGY_BOD_ID = l_PL_REGY_BOD_ID and
25738 PRP.PL_REGY_PRPS_CD = l_PL_REGY_PRPS_CD and
25739 PRP.business_group_id = c_business_group_id
25740 and PRP.pl_regy_prps_id <> c_new_pk_id
25741 --TEMPIK
25742 and c_effective_start_date between effective_start_date
25743 and effective_end_date ;
25744 --END TEMPIK
25745 /*
25746 and exists ( select null
25747 from BEN_PL_REGY_PRP_F PRP1
25748 where
25749 PRP1.PL_REGY_BOD_ID = l_PL_REGY_BOD_ID and
25750 PRP1.PL_REGY_PRPS_CD = l_PL_REGY_PRPS_CD and
25751 PRP1.business_group_id = c_business_group_id
25752 and PRP1.effective_start_date <= c_effective_start_date )
25753 and exists ( select null
25754 from BEN_PL_REGY_PRP_F PRP2
25755 where
25756 PRP2.PL_REGY_BOD_ID = l_PL_REGY_BOD_ID and
25757 PRP2.PL_REGY_PRPS_CD = l_PL_REGY_PRPS_CD and
25758 PRP2.business_group_id = c_business_group_id
25759 and PRP2.effective_end_date >= c_effective_end_date )
25760 ;
25761 */
25762 --
25763 --UPD START
25764 --
25765 l_update boolean := false ;
25766 l_datetrack_mode varchar2(80) := hr_api.g_update;
25767 l_process_date date;
25768 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
25769 --
25770 --UPD END
25771 l_current_pk_id number := null ;
25772 l_prev_pk_id number := null ;
25773 l_first_rec boolean := true ;
25774 r_PRP c_PRP%rowtype;
25775 l_pl_regy_prps_id number ;
25776 l_object_version_number number ;
25777 l_effective_start_date date ;
25778 l_effective_end_date date ;
25779 l_prefix pqh_copy_entity_attribs.information1%type := null;
25780 l_suffix pqh_copy_entity_attribs.information1%type := null;
25781 l_new_value number(15);
25782 l_object_found_in_target boolean := false ;
25783 l_min_esd date;
25784 l_max_eed date;
25785 l_effective_date date;
25786 --TEMPIK
25787 l_dt_rec_found boolean ;
25788 --END TEMPIK
25789 --
25790 begin
25791 -- Initialization
25792 l_object_found_in_target := false ;
25793 -- End Initialization
25794 -- Derive the prefix - sufix
25795 if p_prefix_suffix_cd = 'PREFIX' then
25796 l_prefix := p_prefix_suffix_text ;
25797 elsif p_prefix_suffix_cd = 'SUFFIX' then
25798 l_suffix := p_prefix_suffix_text ;
25799 else
25800 l_prefix := null ;
25801 l_suffix := null ;
25802 end if ;
25803 -- End Prefix Sufix derivation
25804 for r_PRP_unique in c_unique_PRP('PRP') loop
25805
25806 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
25807 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25808 r_PRP_unique.information3 >=
25809 ben_pd_copy_to_ben_one.g_copy_effective_date)
25810 ) then
25811 --
25812 hr_utility.set_location(' r_PRP_unique.table_route_id '||r_PRP_unique.table_route_id,10);
25813 hr_utility.set_location(' r_PRP_unique.information1 '||r_PRP_unique.information1,10);
25814 hr_utility.set_location( 'r_PRP_unique.information2 '||r_PRP_unique.information2,10);
25815 hr_utility.set_location( 'r_PRP_unique.information3 '||r_PRP_unique.information3,10);
25816 -- If reuse objects flag is 'Y' then check for the object in the target business group
25817 -- if found insert the record into PLSql table and exit the loop else try create the
25818 -- object in the target business group
25819 --
25820 l_object_found_in_target := false ;
25821 --UPD START
25822 open c_PRP(r_PRP_unique.table_route_id,
25823 r_PRP_unique.information1,
25824 r_PRP_unique.information2,
25825 r_PRP_unique.information3 ) ;
25826 --
25827 fetch c_PRP into r_PRP ;
25828 --
25829 close c_PRP ;
25830 --
25831 l_dml_operation:= r_PRP_unique.dml_operation ;
25832 l_PL_REGY_BOD_ID := get_fk('PL_REGY_BOD_ID', r_PRP.INFORMATION258,l_dml_operation );
25833 l_PL_REGY_PRPS_CD := r_PRP.information11;
25834 --
25835 l_update := false;
25836 l_process_date := p_effective_date;
25837 --
25838 if l_dml_operation = 'UPDATE' then
25839 --
25840 l_object_found_in_target := TRUE;
25841 --
25842 if l_process_date between r_PRP_unique.information2 and r_PRP_unique.information3 then
25843 l_update := true;
25844 if r_PRP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
25845 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_REGY_PRPS_ID'
25846 then
25847 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_REGY_PRPS_ID' ;
25848 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PRP_unique.information1 ;
25849 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PRP_unique.information1 ;
25850 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
25851 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PRP_unique.table_route_id;
25852 --
25853 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
25854 --
25855 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25856 --
25857 --DOUBT log_data('PRP',l_new_value,l_prefix || r_PRP_unique.name|| l_suffix,'REUSED');
25858 --
25859 end if ;
25860 hr_utility.set_location( 'found record for update',10);
25861 --
25862 else
25863 --
25864 l_update := false;
25865 --
25866 end if;
25867 else
25868 --
25869 --UPD END
25870 l_min_esd := null ;
25871 l_max_eed := null ;
25872 open c_PRP_min_max_dates(r_PRP_unique.table_route_id, r_PRP_unique.information1 ) ;
25873 fetch c_PRP_min_max_dates into l_min_esd,l_max_eed ;
25874 --
25875
25876 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25877 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
25878 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
25879 end if;
25880 l_min_esd := greatest(l_min_esd,r_PRP_unique.information2);
25881 /* open c_PRP(r_PRP_unique.table_route_id,
25882 r_PRP_unique.information1,
25883 r_PRP_unique.information2,
25884 r_PRP_unique.information3 ) ;
25885 --
25886 fetch c_PRP into r_PRP ;
25887 --
25888 close c_PRP ; */
25889 --
25890
25891 if l_PL_REGY_BOD_ID is null then
25892 close c_PRP_min_max_dates;
25893 else
25894 if p_reuse_object_flag = 'Y' then
25895 if c_PRP_min_max_dates%found then
25896 -- cursor to find the object
25897 open c_find_PRP_in_target( l_min_esd,l_max_eed,
25898 p_target_business_group_id, nvl(l_pl_regy_prps_id, -999) ) ;
25899 fetch c_find_PRP_in_target into l_new_value ;
25900 if c_find_PRP_in_target%found then
25901 --
25902 --TEMPIK
25903 l_dt_rec_found := dt_api.check_min_max_dates
25904 (p_base_table_name => 'BEN_PL_REGY_PRPS_F',
25905 p_base_key_column => 'PL_REGY_PRPS_ID',
25906 p_base_key_value => l_new_value,
25907 p_from_date => l_min_esd,
25908 p_to_date => l_max_eed );
25909 if l_dt_rec_found THEN
25910 --END TEMPIK
25911 if r_PRP_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
25912 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'PL_REGY_PRPS_ID' then
25913 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_REGY_PRPS_ID' ;
25914 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PRP_unique.information1 ;
25915 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
25916 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
25917 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PRP_unique.table_route_id;
25918 --
25919 -- 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) ;
25920 --
25921 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25922 end if ;
25923 --
25924 l_object_found_in_target := true ;
25925 --TEMPIK
25926 end if; -- l_dt_rec_found
25927 --END TEMPIK
25928 end if;
25929 close c_find_PRP_in_target ;
25930 --
25931 end if;
25932 end if ;
25933 --
25934 close c_PRP_min_max_dates ;
25935 end if; --if p_dml_operation
25936 --
25937 if not l_object_found_in_target OR l_update then
25938 --
25939 l_current_pk_id := r_PRP.information1;
25940 --
25941 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
25942 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
25943 --
25944 if l_current_pk_id = l_prev_pk_id then
25945 --
25946 l_first_rec := false ;
25947 --
25948 else
25949 --
25950 l_first_rec := true ;
25951 --
25952 end if ;
25953 --
25954
25955 l_effective_date := r_PRP.information2;
25956 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25957 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
25958 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
25959 end if;
25960
25961 if l_first_rec and not l_update then
25962 -- Call Create routine.
25963 hr_utility.set_location(' BEN_PL_REGY_PRP_F CREATE_REGULATORY_PURPOSE ',20);
25964 BEN_REGULATORY_PURPOSE_API.CREATE_REGULATORY_PURPOSE(
25965 --
25966 P_VALIDATE => false
25967 ,P_EFFECTIVE_DATE => l_effective_date
25968 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25969 --
25970 ,P_PL_REGY_BOD_ID => l_PL_REGY_BOD_ID
25971 ,P_PL_REGY_PRPS_CD => r_PRP.INFORMATION11
25972 ,P_PL_REGY_PRPS_ID => l_PL_REGY_PRPS_ID
25973 ,P_PRP_ATTRIBUTE1 => r_PRP.INFORMATION111
25974 ,P_PRP_ATTRIBUTE10 => r_PRP.INFORMATION120
25975 ,P_PRP_ATTRIBUTE11 => r_PRP.INFORMATION121
25976 ,P_PRP_ATTRIBUTE12 => r_PRP.INFORMATION122
25977 ,P_PRP_ATTRIBUTE13 => r_PRP.INFORMATION123
25978 ,P_PRP_ATTRIBUTE14 => r_PRP.INFORMATION124
25979 ,P_PRP_ATTRIBUTE15 => r_PRP.INFORMATION125
25980 ,P_PRP_ATTRIBUTE16 => r_PRP.INFORMATION126
25981 ,P_PRP_ATTRIBUTE17 => r_PRP.INFORMATION127
25982 ,P_PRP_ATTRIBUTE18 => r_PRP.INFORMATION128
25983 ,P_PRP_ATTRIBUTE19 => r_PRP.INFORMATION129
25984 ,P_PRP_ATTRIBUTE2 => r_PRP.INFORMATION112
25985 ,P_PRP_ATTRIBUTE20 => r_PRP.INFORMATION130
25986 ,P_PRP_ATTRIBUTE21 => r_PRP.INFORMATION131
25987 ,P_PRP_ATTRIBUTE22 => r_PRP.INFORMATION132
25988 ,P_PRP_ATTRIBUTE23 => r_PRP.INFORMATION133
25989 ,P_PRP_ATTRIBUTE24 => r_PRP.INFORMATION134
25990 ,P_PRP_ATTRIBUTE25 => r_PRP.INFORMATION135
25991 ,P_PRP_ATTRIBUTE26 => r_PRP.INFORMATION136
25992 ,P_PRP_ATTRIBUTE27 => r_PRP.INFORMATION137
25993 ,P_PRP_ATTRIBUTE28 => r_PRP.INFORMATION138
25994 ,P_PRP_ATTRIBUTE29 => r_PRP.INFORMATION139
25995 ,P_PRP_ATTRIBUTE3 => r_PRP.INFORMATION113
25996 ,P_PRP_ATTRIBUTE30 => r_PRP.INFORMATION140
25997 ,P_PRP_ATTRIBUTE4 => r_PRP.INFORMATION114
25998 ,P_PRP_ATTRIBUTE5 => r_PRP.INFORMATION115
25999 ,P_PRP_ATTRIBUTE6 => r_PRP.INFORMATION116
26000 ,P_PRP_ATTRIBUTE7 => r_PRP.INFORMATION117
26001 ,P_PRP_ATTRIBUTE8 => r_PRP.INFORMATION118
26002 ,P_PRP_ATTRIBUTE9 => r_PRP.INFORMATION119
26003 ,P_PRP_ATTRIBUTE_CATEGORY => r_PRP.INFORMATION110
26004 --
26005 ,P_EFFECTIVE_START_DATE => l_effective_start_date
26006 ,P_EFFECTIVE_END_DATE => l_effective_end_date
26007 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
26008 );
26009 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
26010 -- Update all relevent cer records with new pk_id
26011 hr_utility.set_location('Before plsql table ',222);
26012 hr_utility.set_location('new_value id '||l_pl_regy_prps_id,222);
26013 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_REGY_PRP_ID' ;
26014 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PRP.information1 ;
26015 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PL_REGY_PRPS_ID ;
26016 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
26017 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_PRP_unique.table_route_id;
26018 hr_utility.set_location('After plsql table ',222);
26019 --
26020 -- 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 ) ;
26021 --
26022 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26023 --
26024 else
26025 --
26026 -- Call Update routine for the pk_id created in prev run .
26027 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
26028 hr_utility.set_location(' BEN_PL_REGY_PRP_F UPDATE_REGULATORY_PURPOSE ',30);
26029 --UPD START
26030 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
26031 --
26032 if l_update then
26033 --
26034 l_datetrack_mode := r_PRP.datetrack_mode ;
26035 --
26036 get_dt_modes(
26037 p_effective_date => l_process_date,
26038 p_effective_end_date => r_PRP.information3,
26039 p_effective_start_date => r_PRP.information2,
26040 p_dml_operation => r_PRP.dml_operation,
26041 p_datetrack_mode => l_datetrack_mode );
26042 -- p_update => l_update
26043 --
26044 l_effective_date := l_process_date;
26045 l_PL_REGY_PRPS_ID := r_PRP.information1;
26046 l_object_version_number := r_PRP.information265;
26047 --
26048 end if;
26049 --
26050 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
26051 --
26052 IF l_update OR l_dml_operation <> 'UPDATE' THEN
26053 --UPD END
26054 BEN_REGULATORY_PURPOSE_API.UPDATE_REGULATORY_PURPOSE(
26055 --
26056 P_VALIDATE => false
26057 ,P_EFFECTIVE_DATE => l_effective_date
26058 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
26059 --
26060 ,P_PL_REGY_BOD_ID => l_PL_REGY_BOD_ID
26061 ,P_PL_REGY_PRPS_CD => r_PRP.INFORMATION11
26062 ,P_PL_REGY_PRPS_ID => l_PL_REGY_PRPS_ID
26063 ,P_PRP_ATTRIBUTE1 => r_PRP.INFORMATION111
26064 ,P_PRP_ATTRIBUTE10 => r_PRP.INFORMATION120
26065 ,P_PRP_ATTRIBUTE11 => r_PRP.INFORMATION121
26066 ,P_PRP_ATTRIBUTE12 => r_PRP.INFORMATION122
26067 ,P_PRP_ATTRIBUTE13 => r_PRP.INFORMATION123
26068 ,P_PRP_ATTRIBUTE14 => r_PRP.INFORMATION124
26069 ,P_PRP_ATTRIBUTE15 => r_PRP.INFORMATION125
26070 ,P_PRP_ATTRIBUTE16 => r_PRP.INFORMATION126
26071 ,P_PRP_ATTRIBUTE17 => r_PRP.INFORMATION127
26072 ,P_PRP_ATTRIBUTE18 => r_PRP.INFORMATION128
26073 ,P_PRP_ATTRIBUTE19 => r_PRP.INFORMATION129
26074 ,P_PRP_ATTRIBUTE2 => r_PRP.INFORMATION112
26075 ,P_PRP_ATTRIBUTE20 => r_PRP.INFORMATION130
26076 ,P_PRP_ATTRIBUTE21 => r_PRP.INFORMATION131
26077 ,P_PRP_ATTRIBUTE22 => r_PRP.INFORMATION132
26078 ,P_PRP_ATTRIBUTE23 => r_PRP.INFORMATION133
26079 ,P_PRP_ATTRIBUTE24 => r_PRP.INFORMATION134
26080 ,P_PRP_ATTRIBUTE25 => r_PRP.INFORMATION135
26081 ,P_PRP_ATTRIBUTE26 => r_PRP.INFORMATION136
26082 ,P_PRP_ATTRIBUTE27 => r_PRP.INFORMATION137
26083 ,P_PRP_ATTRIBUTE28 => r_PRP.INFORMATION138
26084 ,P_PRP_ATTRIBUTE29 => r_PRP.INFORMATION139
26085 ,P_PRP_ATTRIBUTE3 => r_PRP.INFORMATION113
26086 ,P_PRP_ATTRIBUTE30 => r_PRP.INFORMATION140
26087 ,P_PRP_ATTRIBUTE4 => r_PRP.INFORMATION114
26088 ,P_PRP_ATTRIBUTE5 => r_PRP.INFORMATION115
26089 ,P_PRP_ATTRIBUTE6 => r_PRP.INFORMATION116
26090 ,P_PRP_ATTRIBUTE7 => r_PRP.INFORMATION117
26091 ,P_PRP_ATTRIBUTE8 => r_PRP.INFORMATION118
26092 ,P_PRP_ATTRIBUTE9 => r_PRP.INFORMATION119
26093 ,P_PRP_ATTRIBUTE_CATEGORY => r_PRP.INFORMATION110
26094 --
26095 ,P_EFFECTIVE_START_DATE => l_effective_start_date
26096 ,P_EFFECTIVE_END_DATE => l_effective_end_date
26097 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
26098 ,P_DATETRACK_MODE => l_datetrack_mode
26099 );
26100 --
26101 end if; -- l_update
26102 end if;
26103 --
26104 -- Delete the row if it is end dated.
26105 --
26106 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
26107 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
26108 trunc(l_max_eed) = r_PRP.information3) then
26109 --
26110 BEN_REGULATORY_PURPOSE_API.delete_REGULATORY_PURPOSE(
26111 --
26112 p_validate => false
26113 ,p_pl_regy_prps_id => l_pl_regy_prps_id
26114 ,p_effective_start_date => l_effective_start_date
26115 ,p_effective_end_date => l_effective_end_date
26116 ,p_object_version_number => l_object_version_number
26117 ,p_effective_date => l_max_eed
26118 ,p_datetrack_mode => hr_api.g_delete
26119 --
26120 );
26121 --
26122 end if;
26123 --
26124 l_prev_pk_id := l_current_pk_id ;
26125 --
26126 end if;
26127 --
26128 end if;
26129 --
26130 end if;
26131 --
26132 end loop;
26133 --
26134 exception when others then
26135 --
26136 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PRP',r_prp.information5 );
26137 --
26138 end create_PRP_rows;
26139
26140 --
26141 ---------------------------------------------------------------
26142 ----------------------< create_BPP_rows >-----------------------
26143 ---------------------------------------------------------------
26144 --
26145 procedure create_BPP_rows
26146 (
26147 p_validate in number default 0
26148 ,p_copy_entity_txn_id in number
26149 ,p_effective_date in date
26150 ,p_prefix_suffix_text in varchar2 default null
26151 ,p_reuse_object_flag in varchar2 default null
26152 ,p_target_business_group_id in varchar2 default null
26153 ,p_prefix_suffix_cd in varchar2 default null
26154 ) is
26155 --
26156 l_CMBN_PLIP_ID number;
26157 l_CMBN_PTIP_ID number;
26158 l_CMBN_PTIP_OPT_ID number;
26159 l_COMP_LVL_FCTR_ID number;
26160 l_DFLT_EXCS_TRTMT_RL number;
26161 l_OIPLIP_ID number;
26162 l_PCT_RNDG_RL number;
26163 l_PGM_ID number;
26164 l_PLIP_ID number;
26165 l_PTIP_ID number;
26166 l_VAL_RNDG_RL number;
26167 --
26168 cursor c_unique_BPP(l_table_alias varchar2) is
26169 select distinct cpe.information1,
26170 cpe.information2,
26171 cpe.information3,
26172 cpe.INFORMATION170 name ,
26173 cpe.table_route_id
26174 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
26175 pqh_table_route tr
26176 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26177 and cpe.table_route_id = tr.table_route_id
26178 -- and tr.where_clause = l_BEN_BNFT_PRVDR_POOL_F
26179 and tr.table_alias = l_table_alias
26180 and cpe.number_of_copies = 1 --ADDITION
26181 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
26182 order by information1, information2; --added for bug: 5151945
26183 --
26184 --
26185 cursor c_BPP_min_max_dates(c_table_route_id number,
26186 c_information1 number) is
26187 select
26188 min(cpe.information2) min_esd,
26189 max(cpe.information3) min_eed
26190 from ben_copy_entity_results cpe
26191 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26192 and cpe.table_route_id = c_table_route_id
26193 and cpe.information1 = c_information1 ;
26194 --
26195 cursor c_BPP(c_table_route_id number,
26196 c_information1 number,
26197 c_information2 date,
26198 c_information3 date) is
26199 select
26200 cpe.*
26201 from ben_copy_entity_results cpe
26202 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26203 and cpe.table_route_id = c_table_route_id
26204 and cpe.information1 = c_information1
26205 and cpe.information2 = c_information2
26206 and cpe.information3 = c_information3
26207 and rownum = 1 ;
26208 -- Date Track target record
26209 cursor c_find_BPP_in_target( c_BPP_name varchar2,
26210 c_effective_start_date date,
26211 c_effective_end_date date,
26212 c_business_group_id number,
26213 c_new_pk_id number) is
26214 select
26215 BPP.bnft_prvdr_pool_id new_value
26216 from BEN_BNFT_PRVDR_POOL_F BPP
26217 where BPP.name = c_BPP_name
26218 and nvl(BPP.CMBN_PLIP_ID,-999) = nvl(l_CMBN_PLIP_ID,-999)
26219 and nvl(BPP.CMBN_PTIP_ID,-999) = nvl(l_CMBN_PTIP_ID,-999)
26220 and nvl(BPP.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999)
26221 and nvl(BPP.OIPLIP_ID,-999) = nvl(l_OIPLIP_ID,-999)
26222 and nvl(BPP.PGM_ID,-999) = nvl(l_PGM_ID,-999)
26223 and nvl(BPP.PLIP_ID,-999) = nvl(l_PLIP_ID,-999)
26224 and nvl(BPP.PTIP_ID,-999) = nvl(l_PTIP_ID,-999)
26225 and BPP.business_group_id = c_business_group_id
26226 and BPP.bnft_prvdr_pool_id <> c_new_pk_id
26227 --TEMPIK
26228 and c_effective_start_date between effective_start_date
26229 and effective_end_date ;
26230 --END TEMPIK
26231 --
26232 /* TEMPIK
26233 and exists ( select null
26234 from BEN_BNFT_PRVDR_POOL_F BPP1
26235 where BPP1.name = c_BPP_name
26236 and nvl(BPP1.CMBN_PLIP_ID,-999) = nvl(l_CMBN_PLIP_ID,-999)
26237 and nvl(BPP1.CMBN_PTIP_ID,-999) = nvl(l_CMBN_PTIP_ID,-999)
26238 and nvl(BPP1.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999)
26239 and nvl(BPP1.OIPLIP_ID,-999) = nvl(l_OIPLIP_ID,-999)
26240 and nvl(BPP1.PGM_ID,-999) = nvl(l_PGM_ID,-999)
26241 and nvl(BPP1.PLIP_ID,-999) = nvl(l_PLIP_ID,-999)
26242 and nvl(BPP1.PTIP_ID,-999) = nvl(l_PTIP_ID,-999)
26243 and BPP1.business_group_id = c_business_group_id
26244 and BPP1.effective_start_date <= c_effective_start_date )
26245 and exists ( select null
26246 from BEN_BNFT_PRVDR_POOL_F BPP2
26247 where BPP2.name = c_BPP_name
26248 and nvl(BPP2.CMBN_PLIP_ID,-999) = nvl(l_CMBN_PLIP_ID,-999)
26249 and nvl(BPP2.CMBN_PTIP_ID,-999) = nvl(l_CMBN_PTIP_ID,-999)
26250 and nvl(BPP2.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999)
26251 and nvl(BPP2.OIPLIP_ID,-999) = nvl(l_OIPLIP_ID,-999)
26252 and nvl(BPP2.PGM_ID,-999) = nvl(l_PGM_ID,-999)
26253 and nvl(BPP2.PLIP_ID,-999) = nvl(l_PLIP_ID,-999)
26254 and nvl(BPP2.PTIP_ID,-999) = nvl(l_PTIP_ID,-999)
26255 and BPP2.business_group_id = c_business_group_id
26256 and BPP2.effective_end_date >= c_effective_end_date )
26257 ;
26258 END TEMPIK */
26259
26260 cursor c_find_BPP_name_in_target( c_BPP_name varchar2,
26261 c_effective_start_date date,
26262 c_effective_end_date date,
26263 c_business_group_id number,
26264 c_new_pk_id number) is
26265 select
26266 BPP.bnft_prvdr_pool_id new_value
26267 from BEN_BNFT_PRVDR_POOL_F BPP
26268 where BPP.name = c_BPP_name
26269 and BPP.business_group_id = c_business_group_id
26270 and BPP.bnft_prvdr_pool_id <> c_new_pk_id
26271 --TEMPIK
26272 and c_effective_start_date between effective_start_date
26273 and effective_end_date ;
26274 --END TEMPIK
26275 /* TEMPIK
26276 and exists ( select null
26277 from BEN_BNFT_PRVDR_POOL_F BPP1
26278 where BPP1.name = c_BPP_name
26279 and BPP1.business_group_id = c_business_group_id
26280 and BPP1.effective_start_date <= c_effective_start_date )
26281 and exists ( select null
26282 from BEN_BNFT_PRVDR_POOL_F BPP2
26283 where BPP2.name = c_BPP_name
26284 and BPP2.business_group_id = c_business_group_id
26285 and BPP2.effective_end_date >= c_effective_end_date )
26286 ;
26287 END TEMPIK*/
26288 --
26289 --UPD START
26290 --
26291 l_update boolean := false ;
26292 l_datetrack_mode varchar2(80) := hr_api.g_update;
26293 l_process_date date;
26294 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
26295 --
26296 --UPD END
26297 l_current_pk_id number := null ;
26298 l_prev_pk_id number := null ;
26299 l_first_rec boolean := true ;
26300 r_BPP c_BPP%rowtype;
26301 l_bnft_prvdr_pool_id number ;
26302 l_object_version_number number ;
26303 l_effective_start_date date ;
26304 l_effective_end_date date ;
26305 l_prefix pqh_copy_entity_attribs.information1%type := null;
26306 l_suffix pqh_copy_entity_attribs.information1%type := null;
26307 l_new_value number(15);
26308 l_object_found_in_target boolean := false ;
26309 l_min_esd date;
26310 l_max_eed date;
26311 l_effective_date date;
26312 --TEMPIK
26313 l_dt_rec_found boolean ;
26314 --END TEMPIK
26315 --
26316 begin
26317 -- Initialization
26318 l_object_found_in_target := false ;
26319 -- End Initialization
26320 -- Derive the prefix - sufix
26321 -- End Prefix Sufix derivation
26322 for r_BPP_unique in c_unique_BPP('BPP') loop
26323
26324 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
26325 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26326 r_BPP_unique.information3 >=
26327 ben_pd_copy_to_ben_one.g_copy_effective_date)
26328 ) then
26329 --
26330 if p_prefix_suffix_cd = 'PREFIX' then
26331 l_prefix := p_prefix_suffix_text ;
26332 elsif p_prefix_suffix_cd = 'SUFFIX' then
26333 l_suffix := p_prefix_suffix_text ;
26334 else
26335 l_prefix := null ;
26336 l_suffix := null ;
26337 end if ;
26338 hr_utility.set_location(' r_BPP_unique.table_route_id '||r_BPP_unique.table_route_id,10);
26339 hr_utility.set_location(' r_BPP_unique.information1 '||r_BPP_unique.information1,10);
26340 hr_utility.set_location( 'r_BPP_unique.information2 '||r_BPP_unique.information2,10);
26341 hr_utility.set_location( 'r_BPP_unique.information3 '||r_BPP_unique.information3,10);
26342 -- If reuse objects flag is 'Y' then check for the object in the target business group
26343 -- if found insert the record into PLSql table and exit the loop else try create the
26344 -- object in the target business group
26345 --
26346 l_object_found_in_target := false ;
26347 --UPD START
26348 open c_BPP(r_BPP_unique.table_route_id,
26349 r_BPP_unique.information1,
26350 r_BPP_unique.information2,
26351 r_BPP_unique.information3 ) ;
26352 --
26353 fetch c_BPP into r_BPP ;
26354 --
26355 close c_BPP ;
26356 --
26357 l_dml_operation:= r_BPP_unique.dml_operation ;
26358 l_CMBN_PLIP_ID := get_fk('CMBN_PLIP_ID', r_BPP.INFORMATION239,l_dml_operation );
26359 l_CMBN_PTIP_ID := get_fk('CMBN_PTIP_ID', r_BPP.INFORMATION236,l_dml_operation );
26360 l_CMBN_PTIP_OPT_ID := get_fk('CMBN_PTIP_OPT_ID', r_BPP.INFORMATION249,l_dml_operation );
26361 l_COMP_LVL_FCTR_ID := get_fk('COMP_LVL_FCTR_ID', r_BPP.INFORMATION254,l_dml_operation );
26362 l_DFLT_EXCS_TRTMT_RL := get_fk('FORMULA_ID', r_BPP.INFORMATION262,l_dml_operation );
26363 l_OIPLIP_ID := get_fk('OIPLIP_ID', r_BPP.INFORMATION227,l_dml_operation );
26364 l_PCT_RNDG_RL := get_fk('FORMULA_ID', r_BPP.INFORMATION266,l_dml_operation );
26365 l_PGM_ID := get_fk('PGM_ID', r_BPP.INFORMATION260,l_dml_operation );
26366 l_PLIP_ID := get_fk('PLIP_ID', r_BPP.INFORMATION256,l_dml_operation );
26367 l_PTIP_ID := get_fk('PTIP_ID', r_BPP.INFORMATION259,l_dml_operation );
26368 l_VAL_RNDG_RL := get_fk('FORMULA_ID', r_BPP.INFORMATION267,l_dml_operation ); --
26369 --
26370 l_update := false;
26371 l_process_date := p_effective_date;
26372 --
26373 if l_dml_operation = 'UPDATE' then
26374 --
26375 l_object_found_in_target := TRUE;
26376 --
26377 if l_process_date between r_BPP_unique.information2 and r_BPP_unique.information3 then
26378 l_update := true;
26379 if r_BPP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
26380 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'BNFT_PRVDR_POOL_ID'
26381 then
26382 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'BNFT_PRVDR_POOL_ID' ;
26383 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_BPP_unique.information1 ;
26384 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_BPP_unique.information1 ;
26385 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
26386 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_BPP_unique.table_route_id;
26387 --
26388 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
26389 --
26390 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26391 --
26392 --DOUBT log_data('BPP',l_new_value,l_prefix || r_BPP_unique.name|| l_suffix,'REUSED');
26393 --
26394 end if ;
26395 hr_utility.set_location( 'found record for update',10);
26396 --
26397 else
26398 --
26399 l_update := false;
26400 --
26401 end if;
26402 else
26403 --
26404 --UPD END
26405 l_min_esd := null ;
26406 l_max_eed := null ;
26407 open c_BPP_min_max_dates(r_BPP_unique.table_route_id, r_BPP_unique.information1 ) ;
26408 fetch c_BPP_min_max_dates into l_min_esd,l_max_eed ;
26409 --
26410
26411 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26412 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
26413 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
26414 end if;
26415 l_min_esd := greatest(l_min_esd,r_BPP_unique.information2);
26416 /* open c_BPP(r_BPP_unique.table_route_id,
26417 r_BPP_unique.information1,
26418 r_BPP_unique.information2,
26419 r_BPP_unique.information3 ) ;
26420 --
26421 fetch c_BPP into r_BPP ;
26422 --
26423 close c_BPP ; */
26424 --
26425 if p_reuse_object_flag = 'Y' then
26426 if c_BPP_min_max_dates%found then
26427 -- cursor to find the object
26428 open c_find_BPP_in_target( l_prefix || r_BPP_unique.name || l_suffix ,l_min_esd,l_max_eed,
26429 p_target_business_group_id, nvl(l_bnft_prvdr_pool_id, -999) ) ;
26430 fetch c_find_BPP_in_target into l_new_value ;
26431 if c_find_BPP_in_target%found then
26432 --
26433 --TEMPIK
26434 l_dt_rec_found := dt_api.check_min_max_dates
26435 (p_base_table_name => 'BEN_BNFT_PRVDR_POOL_F',
26436 p_base_key_column => 'BNFT_PRVDR_POOL_ID',
26437 p_base_key_value => l_new_value,
26438 p_from_date => l_min_esd,
26439 p_to_date => l_max_eed );
26440 if l_dt_rec_found THEN
26441 --END TEMPIK
26442 --
26443 if r_BPP_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
26444 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'BNFT_PRVDR_POOL_ID' then
26445 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'BNFT_PRVDR_POOL_ID' ;
26446 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_BPP_unique.information1 ;
26447 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
26448 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
26449 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_BPP_unique.table_route_id;
26450 --
26451 -- 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) ;
26452 --
26453 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26454 --
26455 BEN_PD_COPY_TO_BEN_ONE.log_data('BPP',l_new_value,l_prefix || r_BPP_unique.name || l_suffix ,'REUSED');
26456 --
26457 end if ;
26458 --
26459 l_object_found_in_target := true ;
26460 --TEMPIK
26461 end if; -- l_dt_rec_found
26462 --END TEMPIK
26463 else
26464 -- NEW
26465 if p_prefix_suffix_text is null then
26466 --
26467 open c_find_BPP_name_in_target( l_prefix || r_BPP_unique.name|| l_suffix ,
26468 l_min_esd,l_max_eed,
26469 p_target_business_group_id, nvl(l_bnft_prvdr_pool_id, -999) ) ;
26470 fetch c_find_BPP_name_in_target into l_new_value ;
26471 if c_find_BPP_name_in_target%found then
26472 --
26473 --TEMPIK
26474 l_dt_rec_found := dt_api.check_min_max_dates
26475 (p_base_table_name => 'BEN_BNFT_PRVDR_POOL_F',
26476 p_base_key_column => 'BNFT_PRVDR_POOL_ID',
26477 p_base_key_value => l_new_value,
26478 p_from_date => l_min_esd,
26479 p_to_date => l_max_eed );
26480 if l_dt_rec_found THEN
26481 --END TEMPIK
26482
26483 if p_prefix_suffix_cd = 'PREFIX' then
26484 l_prefix := BEN_PLAN_DESIGN_TXNS_API.g_pgm_pl_prefix_suffix_text ;
26485 elsif p_prefix_suffix_cd = 'SUFFIX' then
26486 l_suffix := BEN_PLAN_DESIGN_TXNS_API.g_pgm_pl_prefix_suffix_text ;
26487 else
26488 l_prefix := null ;
26489 l_suffix := null ;
26490 end if ;
26491 --
26492 --TEMPIK
26493 end if ; -- l_dt_rec_found
26494 --END TEMPIK
26495 end if;
26496 close c_find_BPP_name_in_target ;
26497 end if;
26498 --dbms_output.put_line(' Second Cursor ');
26499 end if;
26500 close c_find_BPP_in_target ;
26501 end if;
26502 end if ;
26503 --
26504 close c_BPP_min_max_dates ;
26505 end if; --if p_dml_operation
26506 --
26507 if not l_object_found_in_target OR l_update then
26508 --
26509 l_current_pk_id := r_BPP.information1;
26510 --
26511 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
26512 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
26513 --
26514 if l_current_pk_id = l_prev_pk_id then
26515 --
26516 l_first_rec := false ;
26517 --
26518 else
26519 --
26520 l_first_rec := true ;
26521 --
26522 end if ;
26523 --
26524 --
26525 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_BNFT_PRVDR_POOL_F',l_prefix || r_BPP.information170 || l_suffix);
26526 --
26527
26528 l_effective_date := r_BPP.information2;
26529 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26530 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
26531 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
26532 end if;
26533
26534 if l_first_rec and not l_update then
26535 -- Call Create routine.
26536 hr_utility.set_location(' BEN_BNFT_PRVDR_POOL_F CREATE_BENEFIT_PRVDR_POOL ',20);
26537 BEN_BENEFIT_PRVDR_POOL_API.CREATE_BENEFIT_PRVDR_POOL(
26538 --
26539 P_VALIDATE => false
26540 ,P_EFFECTIVE_DATE => l_effective_date
26541 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
26542 --
26543 ,P_ALWS_NGTV_CRS_FLAG => r_BPP.INFORMATION16
26544 ,P_AUTO_ALCT_EXCS_FLAG => r_BPP.INFORMATION25
26545 ,P_BNFT_PRVDR_POOL_ID => l_bnft_prvdr_pool_id
26546 ,P_BPP_ATTRIBUTE1 => r_BPP.INFORMATION111
26547 ,P_BPP_ATTRIBUTE10 => r_BPP.INFORMATION120
26548 ,P_BPP_ATTRIBUTE11 => r_BPP.INFORMATION121
26549 ,P_BPP_ATTRIBUTE12 => r_BPP.INFORMATION122
26550 ,P_BPP_ATTRIBUTE13 => r_BPP.INFORMATION123
26551 ,P_BPP_ATTRIBUTE14 => r_BPP.INFORMATION124
26552 ,P_BPP_ATTRIBUTE15 => r_BPP.INFORMATION125
26553 ,P_BPP_ATTRIBUTE16 => r_BPP.INFORMATION126
26554 ,P_BPP_ATTRIBUTE17 => r_BPP.INFORMATION127
26555 ,P_BPP_ATTRIBUTE18 => r_BPP.INFORMATION128
26556 ,P_BPP_ATTRIBUTE19 => r_BPP.INFORMATION129
26557 ,P_BPP_ATTRIBUTE2 => r_BPP.INFORMATION112
26558 ,P_BPP_ATTRIBUTE20 => r_BPP.INFORMATION130
26559 ,P_BPP_ATTRIBUTE21 => r_BPP.INFORMATION131
26560 ,P_BPP_ATTRIBUTE22 => r_BPP.INFORMATION132
26561 ,P_BPP_ATTRIBUTE23 => r_BPP.INFORMATION133
26562 ,P_BPP_ATTRIBUTE24 => r_BPP.INFORMATION134
26563 ,P_BPP_ATTRIBUTE25 => r_BPP.INFORMATION135
26564 ,P_BPP_ATTRIBUTE26 => r_BPP.INFORMATION136
26565 ,P_BPP_ATTRIBUTE27 => r_BPP.INFORMATION137
26566 ,P_BPP_ATTRIBUTE28 => r_BPP.INFORMATION138
26567 ,P_BPP_ATTRIBUTE29 => r_BPP.INFORMATION139
26568 ,P_BPP_ATTRIBUTE3 => r_BPP.INFORMATION113
26569 ,P_BPP_ATTRIBUTE30 => r_BPP.INFORMATION140
26570 ,P_BPP_ATTRIBUTE4 => r_BPP.INFORMATION114
26571 ,P_BPP_ATTRIBUTE5 => r_BPP.INFORMATION115
26572 ,P_BPP_ATTRIBUTE6 => r_BPP.INFORMATION116
26573 ,P_BPP_ATTRIBUTE7 => r_BPP.INFORMATION117
26574 ,P_BPP_ATTRIBUTE8 => r_BPP.INFORMATION118
26575 ,P_BPP_ATTRIBUTE9 => r_BPP.INFORMATION119
26576 ,P_BPP_ATTRIBUTE_CATEGORY => r_BPP.INFORMATION110
26577 ,P_CMBN_PLIP_ID => l_CMBN_PLIP_ID
26578 ,P_CMBN_PTIP_ID => l_CMBN_PTIP_ID
26579 ,P_CMBN_PTIP_OPT_ID => l_CMBN_PTIP_OPT_ID
26580 ,P_COMP_LVL_FCTR_ID => l_COMP_LVL_FCTR_ID
26581 ,P_DFLT_EXCS_TRTMT_CD => r_BPP.INFORMATION13
26582 ,P_DFLT_EXCS_TRTMT_RL => l_DFLT_EXCS_TRTMT_RL
26583 ,P_EXCS_ALWYS_FFTD_FLAG => r_BPP.INFORMATION19
26584 ,P_EXCS_TRTMT_CD => r_BPP.INFORMATION15
26585 ,P_MN_DSTRBL_PCT_NUM => r_BPP.INFORMATION263
26586 ,P_MN_DSTRBL_VAL => r_BPP.INFORMATION293
26587 ,P_MX_DFCIT_PCT_COMP_NUM => r_BPP.INFORMATION296
26588 ,P_MX_DFCIT_PCT_POOL_CRS_NUM => r_BPP.INFORMATION295
26589 ,P_MX_DSTRBL_PCT_NUM => r_BPP.INFORMATION264
26590 ,P_MX_DSTRBL_VAL => r_BPP.INFORMATION294
26591 ,P_NAME => l_prefix || r_BPP.INFORMATION170 || l_suffix
26592 ,P_NO_MN_DSTRBL_PCT_FLAG => r_BPP.INFORMATION21
26593 ,P_NO_MN_DSTRBL_VAL_FLAG => r_BPP.INFORMATION22
26594 ,P_NO_MX_DSTRBL_PCT_FLAG => r_BPP.INFORMATION23
26595 ,P_NO_MX_DSTRBL_VAL_FLAG => r_BPP.INFORMATION24
26596 ,P_OIPLIP_ID => l_OIPLIP_ID
26597 ,P_PCT_RNDG_CD => r_BPP.INFORMATION11
26598 ,P_PCT_RNDG_RL => l_PCT_RNDG_RL
26599 ,P_PGM_ID => l_PGM_ID
26600 ,P_PGM_POOL_FLAG => r_BPP.INFORMATION18
26601 ,P_PLIP_ID => l_PLIP_ID
26602 ,P_PTIP_ID => l_PTIP_ID
26603 ,P_RLOVR_RSTRCN_CD => r_BPP.INFORMATION14
26604 ,P_USES_NET_CRS_MTHD_FLAG => r_BPP.INFORMATION17
26605 ,P_USE_FOR_PGM_POOL_FLAG => r_BPP.INFORMATION20
26606 ,P_VAL_RNDG_CD => r_BPP.INFORMATION12
26607 ,P_VAL_RNDG_RL => l_VAL_RNDG_RL
26608 --
26609 ,P_EFFECTIVE_START_DATE => l_effective_start_date
26610 ,P_EFFECTIVE_END_DATE => l_effective_end_date
26611 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
26612 );
26613 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
26614 -- Update all relevent cer records with new pk_id
26615 hr_utility.set_location('Before plsql table ',222);
26616 hr_utility.set_location('new_value id '||l_bnft_prvdr_pool_id,222);
26617 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'BNFT_PRVDR_POOL_ID' ;
26618 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_BPP.information1 ;
26619 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_BNFT_PRVDR_POOL_ID ;
26620 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
26621 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_BPP_unique.table_route_id;
26622 hr_utility.set_location('After plsql table ',222);
26623 --
26624 -- 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 ) ;
26625 --
26626 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26627 --
26628 BEN_PD_COPY_TO_BEN_ONE.log_data('BPP',l_new_value,l_prefix || r_BPP.INFORMATION170 || l_suffix,'COPIED');
26629 --
26630 else
26631 --
26632 -- Call Update routine for the pk_id created in prev run .
26633 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
26634 hr_utility.set_location(' BEN_BNFT_PRVDR_POOL_F UPDATE_BENEFIT_PRVDR_POOL ',30);
26635 --UPD START
26636 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
26637 --
26638 if l_update then
26639 --
26640 l_datetrack_mode := r_BPP.datetrack_mode ;
26641 --
26642 get_dt_modes(
26643 p_effective_date => l_process_date,
26644 p_effective_end_date => r_BPP.information3,
26645 p_effective_start_date => r_BPP.information2,
26646 p_dml_operation => r_BPP.dml_operation,
26647 p_datetrack_mode => l_datetrack_mode );
26648 -- p_update => l_update
26649 --
26650 l_effective_date := l_process_date;
26651 l_BNFT_PRVDR_POOL_ID := r_BPP.information1;
26652 l_object_version_number := r_BPP.information265;
26653 --
26654 end if;
26655 --
26656 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
26657 --
26658 IF l_update OR l_dml_operation <> 'UPDATE' THEN
26659 --UPD END
26660
26661 BEN_BENEFIT_PRVDR_POOL_API.UPDATE_BENEFIT_PRVDR_POOL(
26662 --
26663 P_VALIDATE => false
26664 ,P_EFFECTIVE_DATE => l_effective_date
26665 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
26666 --
26667 ,P_ALWS_NGTV_CRS_FLAG => r_BPP.INFORMATION16
26668 ,P_AUTO_ALCT_EXCS_FLAG => r_BPP.INFORMATION25
26669 ,P_BNFT_PRVDR_POOL_ID => l_bnft_prvdr_pool_id
26670 ,P_BPP_ATTRIBUTE1 => r_BPP.INFORMATION111
26671 ,P_BPP_ATTRIBUTE10 => r_BPP.INFORMATION120
26672 ,P_BPP_ATTRIBUTE11 => r_BPP.INFORMATION121
26673 ,P_BPP_ATTRIBUTE12 => r_BPP.INFORMATION122
26674 ,P_BPP_ATTRIBUTE13 => r_BPP.INFORMATION123
26675 ,P_BPP_ATTRIBUTE14 => r_BPP.INFORMATION124
26676 ,P_BPP_ATTRIBUTE15 => r_BPP.INFORMATION125
26677 ,P_BPP_ATTRIBUTE16 => r_BPP.INFORMATION126
26678 ,P_BPP_ATTRIBUTE17 => r_BPP.INFORMATION127
26679 ,P_BPP_ATTRIBUTE18 => r_BPP.INFORMATION128
26680 ,P_BPP_ATTRIBUTE19 => r_BPP.INFORMATION129
26681 ,P_BPP_ATTRIBUTE2 => r_BPP.INFORMATION112
26682 ,P_BPP_ATTRIBUTE20 => r_BPP.INFORMATION130
26683 ,P_BPP_ATTRIBUTE21 => r_BPP.INFORMATION131
26684 ,P_BPP_ATTRIBUTE22 => r_BPP.INFORMATION132
26685 ,P_BPP_ATTRIBUTE23 => r_BPP.INFORMATION133
26686 ,P_BPP_ATTRIBUTE24 => r_BPP.INFORMATION134
26687 ,P_BPP_ATTRIBUTE25 => r_BPP.INFORMATION135
26688 ,P_BPP_ATTRIBUTE26 => r_BPP.INFORMATION136
26689 ,P_BPP_ATTRIBUTE27 => r_BPP.INFORMATION137
26690 ,P_BPP_ATTRIBUTE28 => r_BPP.INFORMATION138
26691 ,P_BPP_ATTRIBUTE29 => r_BPP.INFORMATION139
26692 ,P_BPP_ATTRIBUTE3 => r_BPP.INFORMATION113
26693 ,P_BPP_ATTRIBUTE30 => r_BPP.INFORMATION140
26694 ,P_BPP_ATTRIBUTE4 => r_BPP.INFORMATION114
26695 ,P_BPP_ATTRIBUTE5 => r_BPP.INFORMATION115
26696 ,P_BPP_ATTRIBUTE6 => r_BPP.INFORMATION116
26697 ,P_BPP_ATTRIBUTE7 => r_BPP.INFORMATION117
26698 ,P_BPP_ATTRIBUTE8 => r_BPP.INFORMATION118
26699 ,P_BPP_ATTRIBUTE9 => r_BPP.INFORMATION119
26700 ,P_BPP_ATTRIBUTE_CATEGORY => r_BPP.INFORMATION110
26701 ,P_CMBN_PLIP_ID => l_CMBN_PLIP_ID
26702 ,P_CMBN_PTIP_ID => l_CMBN_PTIP_ID
26703 ,P_CMBN_PTIP_OPT_ID => l_CMBN_PTIP_OPT_ID
26704 ,P_COMP_LVL_FCTR_ID => l_COMP_LVL_FCTR_ID
26705 ,P_DFLT_EXCS_TRTMT_CD => r_BPP.INFORMATION13
26706 ,P_DFLT_EXCS_TRTMT_RL => l_DFLT_EXCS_TRTMT_RL
26707 ,P_EXCS_ALWYS_FFTD_FLAG => r_BPP.INFORMATION19
26708 ,P_EXCS_TRTMT_CD => r_BPP.INFORMATION15
26709 ,P_MN_DSTRBL_PCT_NUM => r_BPP.INFORMATION263
26710 ,P_MN_DSTRBL_VAL => r_BPP.INFORMATION293
26711 ,P_MX_DFCIT_PCT_COMP_NUM => r_BPP.INFORMATION296
26712 ,P_MX_DFCIT_PCT_POOL_CRS_NUM => r_BPP.INFORMATION295
26713 ,P_MX_DSTRBL_PCT_NUM => r_BPP.INFORMATION264
26714 ,P_MX_DSTRBL_VAL => r_BPP.INFORMATION294
26715 ,P_NAME => l_prefix || r_BPP.INFORMATION170 || l_suffix
26716 ,P_NO_MN_DSTRBL_PCT_FLAG => r_BPP.INFORMATION21
26717 ,P_NO_MN_DSTRBL_VAL_FLAG => r_BPP.INFORMATION22
26718 ,P_NO_MX_DSTRBL_PCT_FLAG => r_BPP.INFORMATION23
26719 ,P_NO_MX_DSTRBL_VAL_FLAG => r_BPP.INFORMATION24
26720 ,P_OIPLIP_ID => l_OIPLIP_ID
26721 ,P_PCT_RNDG_CD => r_BPP.INFORMATION11
26722 ,P_PCT_RNDG_RL => l_PCT_RNDG_RL
26723 ,P_PGM_ID => l_PGM_ID
26724 ,P_PGM_POOL_FLAG => r_BPP.INFORMATION18
26725 ,P_PLIP_ID => l_PLIP_ID
26726 ,P_PTIP_ID => l_PTIP_ID
26727 ,P_RLOVR_RSTRCN_CD => r_BPP.INFORMATION14
26728 ,P_USES_NET_CRS_MTHD_FLAG => r_BPP.INFORMATION17
26729 ,P_USE_FOR_PGM_POOL_FLAG => r_BPP.INFORMATION20
26730 ,P_VAL_RNDG_CD => r_BPP.INFORMATION12
26731 ,P_VAL_RNDG_RL => l_VAL_RNDG_RL
26732 --
26733 ,P_EFFECTIVE_START_DATE => l_effective_start_date
26734 ,P_EFFECTIVE_END_DATE => l_effective_end_date
26735 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
26736 ,P_DATETRACK_MODE => l_datetrack_mode
26737 );
26738 --
26739 end if; -- l_update
26740 end if;
26741 --
26742 -- Delete the row if it is end dated.
26743 --
26744 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
26745 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
26746 trunc(l_max_eed) = r_BPP.information3) then
26747 --
26748 BEN_BENEFIT_PRVDR_POOL_API.delete_BENEFIT_PRVDR_POOL(
26749 --
26750 p_validate => false
26751 ,p_bnft_prvdr_pool_id => l_bnft_prvdr_pool_id
26752 ,p_effective_start_date => l_effective_start_date
26753 ,p_effective_end_date => l_effective_end_date
26754 ,p_object_version_number => l_object_version_number
26755 ,p_effective_date => l_max_eed
26756 ,p_datetrack_mode => hr_api.g_delete
26757 --
26758 );
26759 --
26760 end if;
26761 --
26762 l_prev_pk_id := l_current_pk_id ;
26763 --
26764 end if;
26765 --
26766 end if;
26767 --
26768 end loop;
26769 --
26770 exception when others then
26771 --
26772 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'BPP',l_prefix || r_BPP.information170 || l_suffix) ;
26773 --
26774 end create_BPP_rows;
26775
26776 ---------------------------------------------------------------
26777 ----------------------< create_ACP_rows >-----------------------
26778 ---------------------------------------------------------------
26779 --
26780 procedure create_ACP_rows
26781 (
26782 p_validate in number default 0
26783 ,p_copy_entity_txn_id in number
26784 ,p_effective_date in date
26785 ,p_prefix_suffix_text in varchar2 default null
26786 ,p_reuse_object_flag in varchar2 default null
26787 ,p_target_business_group_id in varchar2 default null
26788 ,p_prefix_suffix_cd in varchar2 default null
26789 ) is
26790 --
26791 l_PGM_ID number;
26792 cursor c_unique_ACP(l_table_alias varchar2) is
26793 select distinct cpe.information1,
26794 cpe.information2,
26795 cpe.information3,
26796 cpe.information170 name,
26797 cpe.table_route_id
26798 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
26799 pqh_table_route tr
26800 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26801 and cpe.table_route_id = tr.table_route_id
26802 -- and tr.where_clause = l_BEN_ACRS_PTIP_CVG_F
26803 and tr.table_alias = l_table_alias
26804 and cpe.number_of_copies = 1 -- ADDITION
26805 group by cpe.information1,cpe.information2,cpe.information3, cpe.information170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
26806 order by information1, information2; --added for bug: 5151945
26807 --
26808 --
26809 cursor c_ACP_min_max_dates(c_table_route_id number,
26810 c_information1 number) is
26811 select
26812 min(cpe.information2) min_esd,
26813 max(cpe.information3) min_eed
26814 from ben_copy_entity_results cpe
26815 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26816 and cpe.table_route_id = c_table_route_id
26817 and cpe.information1 = c_information1 ;
26818 --
26819 cursor c_ACP(c_table_route_id number,
26820 c_information1 number,
26821 c_information2 date,
26822 c_information3 date) is
26823 select
26824 cpe.*
26825 from ben_copy_entity_results cpe
26826 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26827 and cpe.table_route_id = c_table_route_id
26828 and cpe.information1 = c_information1
26829 and cpe.information2 = c_information2
26830 and cpe.information3 = c_information3
26831 and rownum = 1 ;
26832 -- Date Track target record
26833 cursor c_find_ACP_in_target( c_ACP_name varchar2,
26834 c_effective_start_date date,
26835 c_effective_end_date date,
26836 c_business_group_id number,
26837 c_new_pk_id number) is
26838 select
26839 ACP.acrs_ptip_cvg_id new_value
26840 from BEN_ACRS_PTIP_CVG_F ACP
26841 where ACP.name = c_ACP_name and
26842 -- nvl(ACP.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
26843 ACP.business_group_id = c_business_group_id
26844 and ACP.acrs_ptip_cvg_id <> c_new_pk_id
26845 --TEMPIK
26846 and c_effective_start_date between effective_start_date
26847 and effective_end_date ;
26848 --END TEMPIK
26849 /*
26850 and exists ( select null
26851 from BEN_ACRS_PTIP_CVG_F ACP1
26852 where ACP1.name = c_ACP_name and
26853 -- nvl(ACP1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
26854 ACP1.business_group_id = c_business_group_id
26855 and ACP1.effective_start_date <= c_effective_start_date )
26856 and exists ( select null
26857 from BEN_ACRS_PTIP_CVG_F ACP2
26858 where ACP2.name = c_ACP_name and
26859 -- nvl(ACP2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
26860 ACP2.business_group_id = c_business_group_id
26861 and ACP2.effective_end_date >= c_effective_end_date )
26862 ;
26863 --
26864 */
26865 --UPD START
26866 --
26867 l_update boolean := false ;
26868 l_datetrack_mode varchar2(80) := hr_api.g_update;
26869 l_process_date date;
26870 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
26871 --
26872 --UPD END
26873 l_current_pk_id number := null ;
26874 l_prev_pk_id number := null ;
26875 l_first_rec boolean := true ;
26876 r_ACP c_ACP%rowtype;
26877 l_acrs_ptip_cvg_id number ;
26878 l_object_version_number number ;
26879 l_effective_start_date date ;
26880 l_effective_end_date date ;
26881 l_prefix pqh_copy_entity_attribs.information1%type := null;
26882 l_suffix pqh_copy_entity_attribs.information1%type := null;
26883 l_new_value number(15);
26884 l_object_found_in_target boolean := false ;
26885 l_min_esd date;
26886 l_max_eed date;
26887 l_effective_date date;
26888 --TEMPIK
26889 l_dt_rec_found boolean ;
26890 --END TEMPIK
26891 --
26892 begin
26893 -- Initialization
26894 l_object_found_in_target := false ;
26895 -- End Initialization
26896 -- Derive the prefix - sufix
26897 if p_prefix_suffix_cd = 'PREFIX' then
26898 l_prefix := p_prefix_suffix_text ;
26899 elsif p_prefix_suffix_cd = 'SUFFIX' then
26900 l_suffix := p_prefix_suffix_text ;
26901 else
26902 l_prefix := null ;
26903 l_suffix := null ;
26904 end if ;
26905 -- End Prefix Sufix derivation
26906 for r_ACP_unique in c_unique_ACP('ACP') loop
26907
26908 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
26909 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26910 r_ACP_unique.information3 >=
26911 ben_pd_copy_to_ben_one.g_copy_effective_date)
26912 ) then
26913 --
26914 hr_utility.set_location(' r_ACP_unique.table_route_id '||r_ACP_unique.table_route_id,10);
26915 hr_utility.set_location(' r_ACP_unique.information1 '||r_ACP_unique.information1,10);
26916 hr_utility.set_location( 'r_ACP_unique.information2 '||r_ACP_unique.information2,10);
26917 hr_utility.set_location( 'r_ACP_unique.information3 '||r_ACP_unique.information3,10);
26918 -- If reuse objects flag is 'Y' then check for the object in the target business group
26919 -- if found insert the record into PLSql table and exit the loop else try create the
26920 -- object in the target business group
26921 --
26922 l_object_found_in_target := false ;
26923 --UPD START
26924 open c_ACP(r_ACP_unique.table_route_id,
26925 r_ACP_unique.information1,
26926 r_ACP_unique.information2,
26927 r_ACP_unique.information3 ) ;
26928 --
26929 fetch c_ACP into r_ACP ;
26930 --
26931 close c_ACP ;
26932 l_dml_operation:= r_ACP_unique.dml_operation ;
26933 --
26934 -- Only For Use by Create Wizard - Same Business Group
26935 l_PGM_ID := NVL(get_fk('PGM_ID', r_ACP.information260,l_dml_operation ),
26936 r_ACP.information260);
26937 --
26938 l_update := false;
26939 l_process_date := p_effective_date;
26940 --
26941 if l_dml_operation = 'UPDATE' then
26942 --
26943 l_object_found_in_target := TRUE;
26944 --
26945 if l_process_date between r_ACP_unique.information2 and r_ACP_unique.information3 then
26946 l_update := true;
26947 if r_ACP_unique.information1 <> nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).old_value, -999)
26948 or nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'ACRS_PTIP_CVG_ID'
26949 then
26950 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ACRS_PTIP_CVG_ID' ;
26951 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ACP_unique.information1 ;
26952 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ACP_unique.information1 ;
26953 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
26954 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_ACP_unique.table_route_id;
26955 --
26956 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
26957 --
26958 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26959 --
26960 --DOUBT log_data('ACP',l_new_value,l_prefix || r_ACP_unique.name|| l_suffix,'REUSED');
26961 --
26962 end if ;
26963 hr_utility.set_location( 'found record for update',10);
26964 --
26965 else
26966 --
26967 l_update := false;
26968 --
26969 end if;
26970 else
26971 --
26972 --UPD END
26973 l_min_esd := null ;
26974 l_max_eed := null ;
26975 open c_ACP_min_max_dates(r_ACP_unique.table_route_id, r_ACP_unique.information1 ) ;
26976 fetch c_ACP_min_max_dates into l_min_esd,l_max_eed ;
26977 --
26978
26979 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26980 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
26981 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
26982 end if;
26983 l_min_esd := greatest(l_min_esd,r_ACP_unique.information2);
26984 /* open c_ACP(r_ACP_unique.table_route_id,
26985 r_ACP_unique.information1,
26986 r_ACP_unique.information2,
26987 r_ACP_unique.information3 ) ;
26988 --
26989 fetch c_ACP into r_ACP ;
26990 --
26991 close c_ACP ; */
26992
26993 if p_reuse_object_flag = 'Y' then
26994 if c_ACP_min_max_dates%found then
26995 -- cursor to find the object
26996 open c_find_ACP_in_target( l_prefix || r_ACP_unique.name||l_suffix ,l_min_esd,l_max_eed,
26997 p_target_business_group_id, nvl(l_acrs_ptip_cvg_id, -999) ) ;
26998 fetch c_find_ACP_in_target into l_new_value ;
26999 if c_find_ACP_in_target%found then
27000 --
27001 --TEMPIK
27002 l_dt_rec_found := dt_api.check_min_max_dates
27003 (p_base_table_name => 'BEN_ACRS_PTIP_CVG_F',
27004 p_base_key_column => 'ACRS_PTIP_CVG_ID',
27005 p_base_key_value => l_new_value,
27006 p_from_date => l_min_esd,
27007 p_to_date => l_max_eed );
27008 if l_dt_rec_found THEN
27009 --END TEMPIK
27010 if r_ACP_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
27011 nvl(ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count-1).pk_id_column, '999') <> 'ACRS_PTIP_CVG_ID' then
27012 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).pk_id_column := 'ACRS_PTIP_CVG_ID' ;
27013 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).old_value := r_ACP_unique.information1 ;
27014 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).new_value := l_new_value ;
27015 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'REUSED';
27016 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).table_route_id := r_ACP_unique.table_route_id;
27017 --
27018 -- 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) ;
27019 --
27020 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1 ;
27021 ben_pd_copy_to_ben_one.log_data('ACP',l_new_value,l_prefix || r_ACP_unique.name|| l_suffix,'REUSED');
27022 end if ;
27023 --
27024 l_object_found_in_target := true ;
27025 --TEMPIK
27026 end if; -- l_dt_rec_found
27027 --END TEMPIK
27028 end if;
27029 close c_find_ACP_in_target ;
27030 --
27031 end if;
27032 end if ;
27033 --
27034 close c_ACP_min_max_dates ;
27035 end if; --if p_dml_operation
27036 --
27037 if not l_object_found_in_target OR l_update then
27038 --
27039 l_current_pk_id := r_ACP.information1;
27040 --
27041 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
27042 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
27043 --
27044 if l_current_pk_id = l_prev_pk_id then
27045 --
27046 l_first_rec := false ;
27047 --
27048 else
27049 --
27050 l_first_rec := true ;
27051 --
27052 end if ;
27053 --
27054 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_ACRS_PTIP_CVG_F',l_prefix || r_ACP.information170 || l_suffix);
27055 --
27056
27057 l_effective_date := r_ACP.information2;
27058 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
27059 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
27060 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
27061 end if;
27062
27063 if l_first_rec and not l_update then
27064 -- Call Create routine.
27065 hr_utility.set_location(' BEN_ACRS_PTIP_CVG_F CREATE_ACRS_PTIP_CVG ',20);
27066 BEN_ACRS_PTIP_CVG_API.CREATE_ACRS_PTIP_CVG(
27067 --
27068 P_VALIDATE => false
27069 ,P_EFFECTIVE_DATE => l_effective_date
27070 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
27071 --
27072 ,P_ACRS_PTIP_CVG_ID => l_acrs_ptip_cvg_id
27073 ,P_APC_ATTRIBUTE1 => r_ACP.INFORMATION111
27074 ,P_APC_ATTRIBUTE10 => r_ACP.INFORMATION120
27075 ,P_APC_ATTRIBUTE11 => r_ACP.INFORMATION121
27076 ,P_APC_ATTRIBUTE12 => r_ACP.INFORMATION122
27077 ,P_APC_ATTRIBUTE13 => r_ACP.INFORMATION123
27078 ,P_APC_ATTRIBUTE14 => r_ACP.INFORMATION124
27079 ,P_APC_ATTRIBUTE15 => r_ACP.INFORMATION125
27080 ,P_APC_ATTRIBUTE16 => r_ACP.INFORMATION126
27081 ,P_APC_ATTRIBUTE17 => r_ACP.INFORMATION127
27082 ,P_APC_ATTRIBUTE18 => r_ACP.INFORMATION128
27083 ,P_APC_ATTRIBUTE19 => r_ACP.INFORMATION129
27084 ,P_APC_ATTRIBUTE2 => r_ACP.INFORMATION112
27085 ,P_APC_ATTRIBUTE20 => r_ACP.INFORMATION130
27086 ,P_APC_ATTRIBUTE21 => r_ACP.INFORMATION131
27087 ,P_APC_ATTRIBUTE22 => r_ACP.INFORMATION132
27088 ,P_APC_ATTRIBUTE23 => r_ACP.INFORMATION133
27089 ,P_APC_ATTRIBUTE24 => r_ACP.INFORMATION134
27090 ,P_APC_ATTRIBUTE25 => r_ACP.INFORMATION135
27091 ,P_APC_ATTRIBUTE26 => r_ACP.INFORMATION136
27092 ,P_APC_ATTRIBUTE27 => r_ACP.INFORMATION137
27093 ,P_APC_ATTRIBUTE28 => r_ACP.INFORMATION138
27094 ,P_APC_ATTRIBUTE29 => r_ACP.INFORMATION139
27095 ,P_APC_ATTRIBUTE3 => r_ACP.INFORMATION113
27096 ,P_APC_ATTRIBUTE30 => r_ACP.INFORMATION140
27097 ,P_APC_ATTRIBUTE4 => r_ACP.INFORMATION114
27098 ,P_APC_ATTRIBUTE5 => r_ACP.INFORMATION115
27099 ,P_APC_ATTRIBUTE6 => r_ACP.INFORMATION116
27100 ,P_APC_ATTRIBUTE7 => r_ACP.INFORMATION117
27101 ,P_APC_ATTRIBUTE8 => r_ACP.INFORMATION118
27102 ,P_APC_ATTRIBUTE9 => r_ACP.INFORMATION119
27103 ,P_APC_ATTRIBUTE_CATEGORY => r_ACP.INFORMATION110
27104 ,P_MN_CVG_ALWD_AMT => r_ACP.INFORMATION294
27105 ,P_MX_CVG_ALWD_AMT => r_ACP.INFORMATION293
27106 ,P_NAME => l_prefix || r_ACP.INFORMATION170 || l_suffix
27107 ,P_PGM_ID => l_PGM_ID
27108 --
27109 ,P_EFFECTIVE_START_DATE => l_effective_start_date
27110 ,P_EFFECTIVE_END_DATE => l_effective_end_date
27111 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
27112 );
27113 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
27114 -- Update all relevent cer records with new pk_id
27115 hr_utility.set_location('Before plsql table ',222);
27116 hr_utility.set_location('new_value id '||l_acrs_ptip_cvg_id,222);
27117 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).pk_id_column := 'ACRS_PTIP_CVG_ID' ;
27118 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).old_value := r_ACP.information1 ;
27119 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).new_value := l_ACRS_PTIP_CVG_ID ;
27120 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'COPIED';
27121 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).table_route_id := r_ACP_unique.table_route_id;
27122 hr_utility.set_location('After plsql table ',222);
27123 --
27124 -- 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 ) ;
27125 --
27126 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1 ;
27127 ben_pd_copy_to_ben_one.log_data('ACP',l_new_value,l_prefix || r_ACP.information170|| l_suffix,'COPIED');
27128 --
27129 else
27130 --
27131 -- Call Update routine for the pk_id created in prev run .
27132 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
27133 hr_utility.set_location(' BEN_ACRS_PTIP_CVG_F UPDATE_ACRS_PTIP_CVG ',30);
27134 --UPD START
27135 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
27136 --
27137 if l_update then
27138 --
27139 l_datetrack_mode := r_ACP.datetrack_mode ;
27140 --
27141 get_dt_modes(
27142 p_effective_date => l_process_date,
27143 p_effective_end_date => r_ACP.information3,
27144 p_effective_start_date => r_ACP.information2,
27145 p_dml_operation => r_ACP.dml_operation,
27146 p_datetrack_mode => l_datetrack_mode );
27147 -- p_update => l_update
27148 --
27149 l_effective_date := l_process_date;
27150 l_ACRS_PTIP_CVG_ID := r_ACP.information1;
27151 l_object_version_number := r_ACP.information265;
27152 --
27153 end if;
27154 --
27155 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
27156 --
27157 IF l_update OR l_dml_operation <> 'UPDATE' THEN
27158 --UPD END
27159 BEN_ACRS_PTIP_CVG_API.UPDATE_ACRS_PTIP_CVG(
27160 --
27161 P_VALIDATE => false
27162 ,P_EFFECTIVE_DATE => l_effective_date
27163 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
27164 --
27165 ,P_ACRS_PTIP_CVG_ID => l_acrs_ptip_cvg_id
27166 ,P_APC_ATTRIBUTE1 => r_ACP.INFORMATION111
27167 ,P_APC_ATTRIBUTE10 => r_ACP.INFORMATION120
27168 ,P_APC_ATTRIBUTE11 => r_ACP.INFORMATION121
27169 ,P_APC_ATTRIBUTE12 => r_ACP.INFORMATION122
27170 ,P_APC_ATTRIBUTE13 => r_ACP.INFORMATION123
27171 ,P_APC_ATTRIBUTE14 => r_ACP.INFORMATION124
27172 ,P_APC_ATTRIBUTE15 => r_ACP.INFORMATION125
27173 ,P_APC_ATTRIBUTE16 => r_ACP.INFORMATION126
27174 ,P_APC_ATTRIBUTE17 => r_ACP.INFORMATION127
27175 ,P_APC_ATTRIBUTE18 => r_ACP.INFORMATION128
27176 ,P_APC_ATTRIBUTE19 => r_ACP.INFORMATION129
27177 ,P_APC_ATTRIBUTE2 => r_ACP.INFORMATION112
27178 ,P_APC_ATTRIBUTE20 => r_ACP.INFORMATION130
27179 ,P_APC_ATTRIBUTE21 => r_ACP.INFORMATION131
27180 ,P_APC_ATTRIBUTE22 => r_ACP.INFORMATION132
27181 ,P_APC_ATTRIBUTE23 => r_ACP.INFORMATION133
27182 ,P_APC_ATTRIBUTE24 => r_ACP.INFORMATION134
27183 ,P_APC_ATTRIBUTE25 => r_ACP.INFORMATION135
27184 ,P_APC_ATTRIBUTE26 => r_ACP.INFORMATION136
27185 ,P_APC_ATTRIBUTE27 => r_ACP.INFORMATION137
27186 ,P_APC_ATTRIBUTE28 => r_ACP.INFORMATION138
27187 ,P_APC_ATTRIBUTE29 => r_ACP.INFORMATION139
27188 ,P_APC_ATTRIBUTE3 => r_ACP.INFORMATION113
27189 ,P_APC_ATTRIBUTE30 => r_ACP.INFORMATION140
27190 ,P_APC_ATTRIBUTE4 => r_ACP.INFORMATION114
27191 ,P_APC_ATTRIBUTE5 => r_ACP.INFORMATION115
27192 ,P_APC_ATTRIBUTE6 => r_ACP.INFORMATION116
27193 ,P_APC_ATTRIBUTE7 => r_ACP.INFORMATION117
27194 ,P_APC_ATTRIBUTE8 => r_ACP.INFORMATION118
27195 ,P_APC_ATTRIBUTE9 => r_ACP.INFORMATION119
27196 ,P_APC_ATTRIBUTE_CATEGORY => r_ACP.INFORMATION110
27197 ,P_MN_CVG_ALWD_AMT => r_ACP.INFORMATION294
27198 ,P_MX_CVG_ALWD_AMT => r_ACP.INFORMATION293
27199 ,P_NAME => l_prefix || r_ACP.INFORMATION170 || l_suffix
27200 ,P_PGM_ID => l_PGM_ID
27201
27202 --
27203 ,P_EFFECTIVE_START_DATE => l_effective_start_date
27204 ,P_EFFECTIVE_END_DATE => l_effective_end_date
27205 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
27206 ,P_DATETRACK_MODE => l_datetrack_mode
27207 );
27208 end if; -- l_update
27209 end if;
27210 --
27211 --
27212 -- Delete the row if it is end dated.
27213 --
27214 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
27215 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
27216 trunc(l_max_eed) = r_ACP.information3) then
27217 --
27218 BEN_ACRS_PTIP_CVG_API.delete_ACRS_PTIP_CVG(
27219 --
27220 p_validate => false
27221 ,p_acrs_ptip_cvg_id => l_acrs_ptip_cvg_id
27222 ,p_effective_start_date => l_effective_start_date
27223 ,p_effective_end_date => l_effective_end_date
27224 ,p_object_version_number => l_object_version_number
27225 ,p_effective_date => l_max_eed
27226 ,p_datetrack_mode => hr_api.g_delete
27227 --
27228 );
27229 --
27230 end if;
27231 --
27232 l_prev_pk_id := l_current_pk_id ;
27233 --
27234 end if;
27235 --
27236 end if;
27237 --
27238 end loop;
27239 --
27240 exception when others then
27241 --
27242 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ACP',l_prefix || r_ACP.information170 || l_suffix) ;
27243 --
27244 end create_ACP_rows;
27245
27246 procedure create_final_intersect_rows
27247 (
27248 p_validate in number default 0 -- false
27249 ,p_copy_entity_txn_id in number
27250 ,p_effective_date in date
27251 ,p_prefix_suffix_text in varchar2 default null
27252 ,p_reuse_object_flag in varchar2 default null
27253 ,p_target_business_group_id in varchar2 default null
27254 ,p_prefix_suffix_cd in varchar2 default null
27255 ) is
27256 begin
27257
27258 --
27259 -- Create all Service Area Postal Zip Range rows
27260 --
27261 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('SAZ') then
27262 BEN_PD_COPY_TO_BEN_TWO.create_SAZ_rows(
27263 p_validate => p_validate
27264 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27265 ,p_effective_date => p_effective_date
27266 ,p_prefix_suffix_text => p_prefix_suffix_text
27267 ,p_reuse_object_flag => p_reuse_object_flag
27268 ,p_target_business_group_id => p_target_business_group_id
27269 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27270 );
27271 end if;
27272 --
27273 -- Create all oipl rows. Moved these calls to End
27274 --
27275 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('COP') then
27276 BEN_PD_COPY_TO_BEN_TWO.create_COP_rows(
27277 p_validate => p_validate
27278 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27279 ,p_effective_date => p_effective_date
27280 ,p_prefix_suffix_text => p_prefix_suffix_text
27281 ,p_reuse_object_flag => p_reuse_object_flag
27282 ,p_target_business_group_id => p_target_business_group_id
27283 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27284 );
27285 end if;
27286 --
27287 -- Create all DDR rows, which could be attached to opt, oipl, pl levels..
27288 --
27289 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('DDR') then
27290 BEN_PD_COPY_TO_BEN_TWO.create_DDR_rows(
27291 p_validate => p_validate
27292 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27293 ,p_effective_date => p_effective_date
27294 ,p_prefix_suffix_text => p_prefix_suffix_text
27295 ,p_reuse_object_flag => p_reuse_object_flag
27296 ,p_target_business_group_id => p_target_business_group_id
27297 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27298 );
27299 end if;
27300 --
27301 -- Create all DRR rows, which could be attached to DRR rows.
27302 --
27303 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('DRR') then
27304 BEN_PD_COPY_TO_BEN_TWO.create_DRR_rows(
27305 p_validate => p_validate
27306 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27307 ,p_effective_date => p_effective_date
27308 ,p_prefix_suffix_text => p_prefix_suffix_text
27309 ,p_reuse_object_flag => p_reuse_object_flag
27310 ,p_target_business_group_id => p_target_business_group_id
27311 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27312 );
27313 end if;
27314 --
27315 -- These records needs to be created at the end of the process.
27316 -- PEO records are created at PGM,PTIP,PLIP,PL and OIPLIP level
27317 -- This call creates the intersections between all these levels and ler.
27318 --
27319 --XXXOIPL
27320 --
27321 -- CPY records are created at PGM and PL level
27322 -- This call creates the intersections between all these levels and yr_perds.
27323 --
27324 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CPY') then
27325 BEN_PD_COPY_TO_BEN_TWO.create_CPY_rows(
27326 p_validate => p_validate
27327 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27328 ,p_effective_date => p_effective_date
27329 ,p_prefix_suffix_text => p_prefix_suffix_text
27330 ,p_reuse_object_flag => p_reuse_object_flag
27331 ,p_target_business_group_id => p_target_business_group_id
27332 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27333 );
27334 end if;
27335 --
27336 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CWG') then
27337 BEN_PD_COPY_TO_BEN_TWO.create_CWG_rows(
27338 p_validate => p_validate
27339 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27340 ,p_effective_date => p_effective_date
27341 ,p_prefix_suffix_text => p_prefix_suffix_text
27342 ,p_reuse_object_flag => p_reuse_object_flag
27343 ,p_target_business_group_id => p_target_business_group_id
27344 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27345 );
27346
27347 create_CRI_rows(
27348 p_validate => p_validate
27349 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27350 ,p_effective_date => p_effective_date
27351 ,p_reuse_object_flag => p_reuse_object_flag
27352 );
27353 end if;
27354 --
27355 --
27356 -- PAT records are created at PGM and PL level
27357 -- This call creates the intersections between all these levels and Action type.
27358 --
27359 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PAT') then
27360 BEN_PD_COPY_TO_BEN_TWO.create_PAT_rows(
27361 p_validate => p_validate
27362 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27363 ,p_effective_date => p_effective_date
27364 ,p_prefix_suffix_text => p_prefix_suffix_text
27365 ,p_reuse_object_flag => p_reuse_object_flag
27366 ,p_target_business_group_id => p_target_business_group_id
27367 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27368 );
27369 end if;
27370
27371 --
27372 -- PET records are created at PGM and PL level
27373 -- This call creates the intersections between all these levels and enrt type cycl code.
27374 --
27375 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PET') then
27376 BEN_PD_COPY_TO_BEN_TWO.create_PET_rows(
27377 p_validate => p_validate
27378 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27379 ,p_effective_date => p_effective_date
27380 ,p_prefix_suffix_text => p_prefix_suffix_text
27381 ,p_reuse_object_flag => p_reuse_object_flag
27382 ,p_target_business_group_id => p_target_business_group_id
27383 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27384 );
27385 end if;
27386 --
27387 -- ENP records are created at PGM and PL level
27388 -- This call creates the intersections between all these levels and year periods.
27389 --
27390 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ENP') then
27391 BEN_PD_COPY_TO_BEN_TWO.create_ENP_rows(
27392 p_validate => p_validate
27393 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27394 ,p_effective_date => p_effective_date
27395 ,p_prefix_suffix_text => p_prefix_suffix_text
27396 ,p_reuse_object_flag => p_reuse_object_flag
27397 ,p_target_business_group_id => p_target_business_group_id
27398 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27399 );
27400 end if;
27401 --
27402 --
27403 -- LEN records are created at PGM and PL level
27404 -- This call creates the intersections between all these levels and ler.
27405 --
27406 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LEN') then
27407 BEN_PD_COPY_TO_BEN_TWO.create_LEN_rows(
27408 p_validate => p_validate
27409 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27410 ,p_effective_date => p_effective_date
27411 ,p_prefix_suffix_text => p_prefix_suffix_text
27412 ,p_reuse_object_flag => p_reuse_object_flag
27413 ,p_target_business_group_id => p_target_business_group_id
27414 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27415 );
27416 end if;
27417 --
27418 --
27419 -- LOP records are created at OIPL and LER level
27420 --
27421 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LOP') then
27422 BEN_PD_COPY_TO_BEN_TWO.create_LOP_rows(
27423 p_validate => p_validate
27424 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27425 ,p_effective_date => p_effective_date
27426 ,p_prefix_suffix_text => p_prefix_suffix_text
27427 ,p_reuse_object_flag => p_reuse_object_flag
27428 ,p_target_business_group_id => p_target_business_group_id
27429 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27430 );
27431 end if;
27432 --
27433 --
27434 -- ERP records are created at LEN or ENP level
27435 --
27436 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ERP') then
27437 BEN_PD_COPY_TO_BEN_TWO.create_ERP_rows(
27438 p_validate => p_validate
27439 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27440 ,p_effective_date => p_effective_date
27441 ,p_prefix_suffix_text => p_prefix_suffix_text
27442 ,p_reuse_object_flag => p_reuse_object_flag
27443 ,p_target_business_group_id => p_target_business_group_id
27444 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27445 );
27446 end if;
27447 --
27448 --
27449 -- SER records are created at ENP level
27450 --
27451 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('SER') then
27452 BEN_PD_COPY_TO_BEN_TWO.create_SER_rows(
27453 p_validate => p_validate
27454 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27455 ,p_effective_date => p_effective_date
27456 ,p_prefix_suffix_text => p_prefix_suffix_text
27457 ,p_reuse_object_flag => p_reuse_object_flag
27458 ,p_target_business_group_id => p_target_business_group_id
27459 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27460 );
27461 end if;
27462 --
27463 --
27464 -- ECF records are created at PL and OIPL level
27465 -- This call creates the intersections between all these levels and
27466 -- enrt_ctfn_cd
27467 --
27468 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ECF') then
27469 BEN_PD_COPY_TO_BEN_TWO.create_ECF_rows(
27470 p_validate => p_validate
27471 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27472 ,p_effective_date => p_effective_date
27473 ,p_prefix_suffix_text => p_prefix_suffix_text
27474 ,p_reuse_object_flag => p_reuse_object_flag
27475 ,p_target_business_group_id => p_target_business_group_id
27476 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27477 );
27478 end if;
27479 --
27480 -- CPO records are created at PL and GPM level
27481 -- This call creates the intersections between these levels and
27482 -- Organization
27483 --
27484 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CPO') then
27485 BEN_PD_COPY_TO_BEN_TWO.create_CPO_rows(
27486 p_validate => p_validate
27487 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27488 ,p_effective_date => p_effective_date
27489 ,p_prefix_suffix_text => p_prefix_suffix_text
27490 ,p_reuse_object_flag => p_reuse_object_flag
27491 ,p_target_business_group_id => p_target_business_group_id
27492 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27493 );
27494 end if;
27495 -- CPR records are created at CPO level
27496 -- This call creates the child records for the CPO level
27497 --
27498 --
27499 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CPR') then
27500 BEN_PD_COPY_TO_BEN_TWO.create_CPR_rows(
27501 p_validate => p_validate
27502 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27503 ,p_effective_date => p_effective_date
27504 ,p_prefix_suffix_text => p_prefix_suffix_text
27505 ,p_reuse_object_flag => p_reuse_object_flag
27506 ,p_target_business_group_id => p_target_business_group_id
27507 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27508 );
27509 end if;
27510
27511 -- RGR records are created at PL and GPM level
27512 -- This call creates the intersections between these levels and
27513 -- reporting group
27514 --
27515 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('RGR') then
27516 BEN_PD_COPY_TO_BEN_TWO.create_RGR_rows(
27517 p_validate => p_validate
27518 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27519 ,p_effective_date => p_effective_date
27520 ,p_prefix_suffix_text => p_prefix_suffix_text
27521 ,p_reuse_object_flag => p_reuse_object_flag
27522 ,p_target_business_group_id => p_target_business_group_id
27523 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27524 );
27525 end if;
27526 --
27527 -- PRG records are created at PL and RGR level
27528 -- This call creates the intersections between these levels and
27529 -- REGN
27530 --
27531 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PRG') then
27532 BEN_PD_COPY_TO_BEN_TWO.create_PRG_rows(
27533 p_validate => p_validate
27534 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27535 ,p_effective_date => p_effective_date
27536 ,p_prefix_suffix_text => p_prefix_suffix_text
27537 ,p_reuse_object_flag => p_reuse_object_flag
27538 ,p_target_business_group_id => p_target_business_group_id
27539 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27540 );
27541 end if;
27542
27543 --
27544 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ACP') then
27545 BEN_PD_COPY_TO_BEN_two.create_ACP_rows
27546 (p_validate => p_validate
27547 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27548 ,p_effective_date => p_effective_date
27549 ,p_prefix_suffix_text => p_prefix_suffix_text
27550 ,p_reuse_object_flag => p_reuse_object_flag
27551 ,p_target_business_group_id => p_target_business_group_id
27552 ,p_prefix_suffix_cd => p_prefix_suffix_cd);
27553 end if;
27554 --
27555
27556 -- Start of Intersections for the PTIP
27557 -- CTP records are created at Program and Plan Intersection
27558 --
27559 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CTP') then
27560 BEN_PD_COPY_TO_BEN_TWO.create_CTP_rows(
27561 p_validate => p_validate
27562 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27563 ,p_effective_date => p_effective_date
27564 ,p_prefix_suffix_text => p_prefix_suffix_text
27565 ,p_reuse_object_flag => p_reuse_object_flag
27566 ,p_target_business_group_id => p_target_business_group_id
27567 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27568 );
27569 end if;
27570 -- ADE records are created at PGM,PTIP and PL level
27571 -- This call creates the intersections between all these levels and
27572 -- ben_dpnt_cvg_eligy_prfl_f
27573 --
27574 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ADE') then
27575 BEN_PD_COPY_TO_BEN_TWO.create_ADE_rows(
27576 p_validate => p_validate
27577 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27578 ,p_effective_date => p_effective_date
27579 ,p_prefix_suffix_text => p_prefix_suffix_text
27580 ,p_reuse_object_flag => p_reuse_object_flag
27581 ,p_target_business_group_id => p_target_business_group_id
27582 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27583 );
27584 end if;
27585 --
27586 -- LDC records are created at PGM,PTIP and PL level
27587 -- This call creates the intersections between all these levels and
27588 -- ben_ler_f
27589 --
27590 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LDC') then
27591 BEN_PD_COPY_TO_BEN_TWO.create_LDC_rows(
27592 p_validate => p_validate
27593 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27594 ,p_effective_date => p_effective_date
27595 ,p_prefix_suffix_text => p_prefix_suffix_text
27596 ,p_reuse_object_flag => p_reuse_object_flag
27597 ,p_target_business_group_id => p_target_business_group_id
27598 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27599 );
27600 end if;
27601 --
27602 -- LCC records are created at LDC and certification type
27603 --
27604 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LCC') then
27605 BEN_PD_COPY_TO_BEN_TWO.create_LCC_rows(
27606 p_validate => p_validate
27607 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27608 ,p_effective_date => p_effective_date
27609 ,p_prefix_suffix_text => p_prefix_suffix_text
27610 ,p_reuse_object_flag => p_reuse_object_flag
27611 ,p_target_business_group_id => p_target_business_group_id
27612 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27613 );
27614 end if;
27615 -- WPT records are created at PTIP and wv_prtn_rsn_cd intersection
27616 --
27617 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('WPT') then
27618 BEN_PD_COPY_TO_BEN_TWO.create_WPT_rows(
27619 p_validate => p_validate
27620 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27621 ,p_effective_date => p_effective_date
27622 ,p_prefix_suffix_text => p_prefix_suffix_text
27623 ,p_reuse_object_flag => p_reuse_object_flag
27624 ,p_target_business_group_id => p_target_business_group_id
27625 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27626 );
27627 end if;
27628 -- WCT records are created at WPT and wv_prtn_ctfn_typ_cd intersection
27629 --
27630 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('WCT') then
27631 BEN_PD_COPY_TO_BEN_TWO.create_WCT_rows(
27632 p_validate => p_validate
27633 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27634 ,p_effective_date => p_effective_date
27635 ,p_prefix_suffix_text => p_prefix_suffix_text
27636 ,p_reuse_object_flag => p_reuse_object_flag
27637 ,p_target_business_group_id => p_target_business_group_id
27638 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27639 );
27640 end if;
27641 -- LCT records are created at PTIP and LER_ID intersection
27642 --
27643 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LCT') then
27644 BEN_PD_COPY_TO_BEN_TWO.create_LCT_rows(
27645 p_validate => p_validate
27646 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27647 ,p_effective_date => p_effective_date
27648 ,p_prefix_suffix_text => p_prefix_suffix_text
27649 ,p_reuse_object_flag => p_reuse_object_flag
27650 ,p_target_business_group_id => p_target_business_group_id
27651 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27652 );
27653 end if;
27654 -- PYD records are created at PTIP and dependent certification type intersection
27655 --
27656 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PYD') then
27657 BEN_PD_COPY_TO_BEN_TWO.create_PYD_rows(
27658 p_validate => p_validate
27659 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27660 ,p_effective_date => p_effective_date
27661 ,p_prefix_suffix_text => p_prefix_suffix_text
27662 ,p_reuse_object_flag => p_reuse_object_flag
27663 ,p_target_business_group_id => p_target_business_group_id
27664 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27665 );
27666 end if;
27667 -- PLIP Rows start here
27668 -- CPP records are created at PGM and PLN intersection
27669 -- XXXPLIP
27670 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CPP') then
27671 BEN_PD_COPY_TO_BEN_TWO.create_CPP_rows(
27672 p_validate => p_validate
27673 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27674 ,p_effective_date => p_effective_date
27675 ,p_prefix_suffix_text => p_prefix_suffix_text
27676 ,p_reuse_object_flag => p_reuse_object_flag
27677 ,p_target_business_group_id => p_target_business_group_id
27678 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27679 );
27680 end if;
27681
27682 -- OIPLIP Always Reuse, never create
27683 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('OPP') then
27684 BEN_PD_COPY_TO_BEN_TWO.create_OPP_rows(
27685 p_validate => p_validate
27686 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27687 ,p_effective_date => p_effective_date
27688 ,p_prefix_suffix_text => p_prefix_suffix_text
27689 ,p_reuse_object_flag => p_reuse_object_flag
27690 ,p_target_business_group_id => p_target_business_group_id
27691 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27692 );
27693 end if;
27694 --
27695 -- OPTIP Always Reuse, never create
27696 /* Commented out for Now - Not Complete
27697 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('OTP') then
27698 BEN_PD_COPY_TO_BEN_TWO.create_OTP_rows(
27699 p_validate => p_validate
27700 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27701 ,p_effective_date => p_effective_date
27702 ,p_prefix_suffix_text => p_prefix_suffix_text
27703 ,p_reuse_object_flag => p_reuse_object_flag
27704 ,p_target_business_group_id => p_target_business_group_id
27705 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27706 );
27707 end if;
27708 */
27709 --
27710 -- Moved call from bepdccp1.pkb so that Benefit Pools are
27711 -- created after PLIP, PTIP and OIPLIP
27712 --
27713 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('BPP') then
27714 BEN_PD_COPY_TO_BEN_TWO.create_BPP_rows(
27715 p_validate => p_validate
27716 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27717 ,p_effective_date => p_effective_date
27718 ,p_prefix_suffix_text => p_prefix_suffix_text
27719 ,p_reuse_object_flag => p_reuse_object_flag
27720 ,p_target_business_group_id => p_target_business_group_id
27721 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27722 );
27723 end if;
27724 --
27725
27726 -- LBR records are created at PLIP and LER intersection
27727 --
27728 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LBR') then
27729 BEN_PD_COPY_TO_BEN_TWO.create_LBR_rows(
27730 p_validate => p_validate
27731 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27732 ,p_effective_date => p_effective_date
27733 ,p_prefix_suffix_text => p_prefix_suffix_text
27734 ,p_reuse_object_flag => p_reuse_object_flag
27735 ,p_target_business_group_id => p_target_business_group_id
27736 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27737 );
27738 end if;
27739 --
27740 -- LPR1 records are created at PLIP and LER intersection
27741 --
27742 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LPR1') then
27743 BEN_PD_COPY_TO_BEN_TWO.create_LPR1_rows(
27744 p_validate => p_validate
27745 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27746 ,p_effective_date => p_effective_date
27747 ,p_prefix_suffix_text => p_prefix_suffix_text
27748 ,p_reuse_object_flag => p_reuse_object_flag
27749 ,p_target_business_group_id => p_target_business_group_id
27750 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27751 );
27752 end if;
27753 -- Plan Intersections
27754 -- VGS records are created at PL and GOS intersection
27755 --
27756 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('VGS') then
27757 BEN_PD_COPY_TO_BEN_TWO.create_VGS_rows(
27758 p_validate => p_validate
27759 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27760 ,p_effective_date => p_effective_date
27761 ,p_prefix_suffix_text => p_prefix_suffix_text
27762 ,p_reuse_object_flag => p_reuse_object_flag
27763 ,p_target_business_group_id => p_target_business_group_id
27764 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27765 );
27766 end if;
27767 -- PCT records are created at VGS and certification type intersection
27768 --
27769 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PCT') then
27770 BEN_PD_COPY_TO_BEN_TWO.create_PCT_rows(
27771 p_validate => p_validate
27772 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27773 ,p_effective_date => p_effective_date
27774 ,p_prefix_suffix_text => p_prefix_suffix_text
27775 ,p_reuse_object_flag => p_reuse_object_flag
27776 ,p_target_business_group_id => p_target_business_group_id
27777 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27778 );
27779 end if;
27780 -- VRP records as child record of PL
27781 --
27782 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('VRP') then
27783 BEN_PD_COPY_TO_BEN_TWO.create_VRP_rows(
27784 p_validate => p_validate
27785 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27786 ,p_effective_date => p_effective_date
27787 ,p_prefix_suffix_text => p_prefix_suffix_text
27788 ,p_reuse_object_flag => p_reuse_object_flag
27789 ,p_target_business_group_id => p_target_business_group_id
27790 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27791 );
27792 end if;
27793 --
27794 -- WPN records are intersection of PL and wv_prtn_rsn_cd
27795 --
27796 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('WPN') then
27797 BEN_PD_COPY_TO_BEN_TWO.create_WPN_rows(
27798 p_validate => p_validate
27799 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27800 ,p_effective_date => p_effective_date
27801 ,p_prefix_suffix_text => p_prefix_suffix_text
27802 ,p_reuse_object_flag => p_reuse_object_flag
27803 ,p_target_business_group_id => p_target_business_group_id
27804 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27805 );
27806 end if;
27807 -- WCN records are intersection of WPN and wv_prtn_ctfn_typ_cd
27808 --
27809 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('WCN') then
27810 BEN_PD_COPY_TO_BEN_TWO.create_WCN_rows(
27811 p_validate => p_validate
27812 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27813 ,p_effective_date => p_effective_date
27814 ,p_prefix_suffix_text => p_prefix_suffix_text
27815 ,p_reuse_object_flag => p_reuse_object_flag
27816 ,p_target_business_group_id => p_target_business_group_id
27817 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27818 );
27819 end if;
27820 --
27821 -- BRC records are intersection of PL and enrt_ctfn_typ_cd
27822 --
27823 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('BRC') then
27824 BEN_PD_COPY_TO_BEN_TWO.create_BRC_rows(
27825 p_validate => p_validate
27826 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27827 ,p_effective_date => p_effective_date
27828 ,p_prefix_suffix_text => p_prefix_suffix_text
27829 ,p_reuse_object_flag => p_reuse_object_flag
27830 ,p_target_business_group_id => p_target_business_group_id
27831 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27832 );
27833 end if;
27834 -- LBC records are intersection of ler_bnft_rstrn_id and enrt_ctfn_typ_cd
27835 --
27836 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LBC') then
27837 BEN_PD_COPY_TO_BEN_TWO.create_LBC_rows(
27838 p_validate => p_validate
27839 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27840 ,p_effective_date => p_effective_date
27841 ,p_prefix_suffix_text => p_prefix_suffix_text
27842 ,p_reuse_object_flag => p_reuse_object_flag
27843 ,p_target_business_group_id => p_target_business_group_id
27844 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27845 );
27846 end if;
27847 -- LRE records are intersection of PL,OIPL with LER
27848 --
27849 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LRE') then
27850 BEN_PD_COPY_TO_BEN_TWO.create_LRE_rows(
27851 p_validate => p_validate
27852 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27853 ,p_effective_date => p_effective_date
27854 ,p_prefix_suffix_text => p_prefix_suffix_text
27855 ,p_reuse_object_flag => p_reuse_object_flag
27856 ,p_target_business_group_id => p_target_business_group_id
27857 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27858 );
27859 end if;
27860 -- LNC records are intersection of LRE and enrt_ctfn_typ_cd
27861 --
27862 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LNC') then
27863 BEN_PD_COPY_TO_BEN_TWO.create_LNC_rows(
27864 p_validate => p_validate
27865 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27866 ,p_effective_date => p_effective_date
27867 ,p_prefix_suffix_text => p_prefix_suffix_text
27868 ,p_reuse_object_flag => p_reuse_object_flag
27869 ,p_target_business_group_id => p_target_business_group_id
27870 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27871 );
27872 end if;
27873 -- LPE records are intersection of PLN and LER
27874 --
27875 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LPE') then
27876 BEN_PD_COPY_TO_BEN_TWO.create_LPE_rows(
27877 p_validate => p_validate
27878 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27879 ,p_effective_date => p_effective_date
27880 ,p_prefix_suffix_text => p_prefix_suffix_text
27881 ,p_reuse_object_flag => p_reuse_object_flag
27882 ,p_target_business_group_id => p_target_business_group_id
27883 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27884 );
27885 end if;
27886 -- PND records are intersection of PLN and dpnt_cvg_ctfn_typ_cd
27887 --
27888 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PND') then
27889 BEN_PD_COPY_TO_BEN_TWO.create_PND_rows(
27890 p_validate => p_validate
27891 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27892 ,p_effective_date => p_effective_date
27893 ,p_prefix_suffix_text => p_prefix_suffix_text
27894 ,p_reuse_object_flag => p_reuse_object_flag
27895 ,p_target_business_group_id => p_target_business_group_id
27896 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27897 );
27898 end if;
27899 -- PCX records are intersection of PLN and bnf_ctfn_typ_cd
27900 --
27901 --XXXPGM
27902 --
27903 -- These records needs to be created at the end of the process.
27904 -- PEO records are created at PGM,PTIP,PLIP,PL and OIPLIP level
27905 -- This call creates the intersections between all these levels and ler.
27906 --
27907 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PEO') then
27908 BEN_PD_COPY_TO_BEN_TWO.create_PEO_rows(
27909 p_validate => p_validate
27910 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27911 ,p_effective_date => p_effective_date
27912 ,p_prefix_suffix_text => p_prefix_suffix_text
27913 ,p_reuse_object_flag => p_reuse_object_flag
27914 ,p_target_business_group_id => p_target_business_group_id
27915 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27916 );
27917 end if;
27918 --
27919 -- EPA records are created at PGM,PTIP,PLIP,PL and OIPLIP level
27920 --
27921 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EPA') then
27922 BEN_PD_COPY_TO_BEN_TWO.create_EPA_rows(
27923 p_validate => p_validate
27924 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27925 ,p_effective_date => p_effective_date
27926 ,p_prefix_suffix_text => p_prefix_suffix_text
27927 ,p_reuse_object_flag => p_reuse_object_flag
27928 ,p_target_business_group_id => p_target_business_group_id
27929 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27930 );
27931 end if;
27932 --
27933 -- CEP records are created at the intersection of EPA and ELP
27934 --
27935 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CEP') then
27936 BEN_PD_COPY_TO_BEN_TWO.create_CEP_rows(
27937 p_validate => p_validate
27938 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27939 ,p_effective_date => p_effective_date
27940 ,p_prefix_suffix_text => p_prefix_suffix_text
27941 ,p_reuse_object_flag => p_reuse_object_flag
27942 ,p_target_business_group_id => p_target_business_group_id
27943 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27944 );
27945 end if;
27946 -- CER records are created at the intersection of EPA and FORMULA
27947 --
27948 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CER') then
27949 BEN_PD_COPY_TO_BEN_TWO.create_CER_rows(
27950 p_validate => p_validate
27951 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27952 ,p_effective_date => p_effective_date
27953 ,p_prefix_suffix_text => p_prefix_suffix_text
27954 ,p_reuse_object_flag => p_reuse_object_flag
27955 ,p_target_business_group_id => p_target_business_group_id
27956 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27957 );
27958 end if;
27959 --
27960 --
27961 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PCX') then
27962 BEN_PD_COPY_TO_BEN_TWO.create_PCX_rows(
27963 p_validate => p_validate
27964 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27965 ,p_effective_date => p_effective_date
27966 ,p_prefix_suffix_text => p_prefix_suffix_text
27967 ,p_reuse_object_flag => p_reuse_object_flag
27968 ,p_target_business_group_id => p_target_business_group_id
27969 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27970 );
27971 end if;
27972 --
27973 -- PCP records are intersection of PLN and ben_pl_pcp
27974 --
27975 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PCP') then
27976 BEN_PD_COPY_TO_BEN_TWO.create_PCP_rows(
27977 p_validate => p_validate
27978 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27979 ,p_effective_date => p_effective_date
27980 ,p_prefix_suffix_text => p_prefix_suffix_text
27981 ,p_reuse_object_flag => p_reuse_object_flag
27982 ,p_target_business_group_id => p_target_business_group_id
27983 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27984 );
27985 end if;
27986 --
27987 -- PTY records are child records of PCP
27988 --
27989 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PTY') then
27990 BEN_PD_COPY_TO_BEN_TWO.create_PTY_rows(
27991 p_validate => p_validate
27992 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27993 ,p_effective_date => p_effective_date
27994 ,p_prefix_suffix_text => p_prefix_suffix_text
27995 ,p_reuse_object_flag => p_reuse_object_flag
27996 ,p_target_business_group_id => p_target_business_group_id
27997 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27998 );
27999 end if;
28000 --
28001 -- PRB records are child records of PLN OR BNR
28002 --
28003 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PRB') then
28004 BEN_PD_COPY_TO_BEN_TWO.create_PRB_rows(
28005 p_validate => p_validate
28006 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28007 ,p_effective_date => p_effective_date
28008 ,p_prefix_suffix_text => p_prefix_suffix_text
28009 ,p_reuse_object_flag => p_reuse_object_flag
28010 ,p_target_business_group_id => p_target_business_group_id
28011 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28012 );
28013 end if;
28014 --
28015 --
28016 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PRP') then
28017 BEN_PD_COPY_TO_BEN_TWO.create_PRP_rows(
28018 p_validate => p_validate
28019 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28020 ,p_effective_date => p_effective_date
28021 ,p_prefix_suffix_text => p_prefix_suffix_text
28022 ,p_reuse_object_flag => p_reuse_object_flag
28023 ,p_target_business_group_id => p_target_business_group_id
28024 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28025 );
28026 end if;
28027 --
28028
28029 end create_final_intersect_rows ;
28030 --
28031 procedure create_pgm_intersect_rows(
28032 p_validate in number default 0 -- false
28033 ,p_copy_entity_txn_id in number
28034 ,p_effective_date in date
28035 ,p_prefix_suffix_text in varchar2 default null
28036 ,p_reuse_object_flag in varchar2 default null
28037 ,p_target_business_group_id in varchar2 default null
28038 ,p_prefix_suffix_cd in varchar2 default null
28039 ) is
28040 begin
28041 --
28042 -- First try creating all the leaf rows.
28043 --
28044 --TCS PDW Integration ENH
28045 if(BEN_PD_COPY_TO_BEN_TWO.g_copy_entity_txn_id <> p_copy_entity_txn_id) then
28046
28047 BEN_PD_COPY_TO_BEN_TWO.g_copy_entity_txn_id := p_copy_entity_txn_id;
28048
28049 open BEN_PD_COPY_TO_BEN_TWO.g_copy_entity_txn(p_copy_entity_txn_id) ;
28050 fetch BEN_PD_COPY_TO_BEN_TWO.g_copy_entity_txn into BEN_PD_COPY_TO_BEN_TWO.g_row_type_cd;
28051 close BEN_PD_COPY_TO_BEN_TWO.g_copy_entity_txn;
28052
28053 end if;
28054
28055 -- TCS PDW Integration passed the parameter BEN_PD_COPY_TO_BEN_TWO.g_row_type_cd to create_all_leaf_ben_rows
28056 BEN_PD_COPY_TO_BEN_ONE.create_all_leaf_ben_rows(
28057 p_validate => p_validate
28058 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28059 ,p_effective_date => p_effective_date
28060 ,p_prefix_suffix_text => p_prefix_suffix_text
28061 ,p_reuse_object_flag => p_reuse_object_flag
28062 ,p_target_business_group_id => p_target_business_group_id
28063 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28064 ,p_txn_row_type_cd => BEN_PD_COPY_TO_BEN_TWO.g_row_type_cd
28065 );
28066
28067 if (BEN_PD_COPY_TO_BEN_TWO.g_row_type_cd <> 'ELP') then
28068 --TCS PDW Integration ENH
28069 --
28070 -- ben_popl_enrt_typ_cycl_f rows are created as pgm and pl, yrp, wyp rows
28071 -- are created as part of leaf call and above call.
28072 --
28073 BEN_PD_COPY_TO_BEN_TWO.create_final_intersect_rows(
28074 p_validate => p_validate
28075 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28076 ,p_effective_date => p_effective_date
28077 ,p_prefix_suffix_text => p_prefix_suffix_text
28078 ,p_reuse_object_flag => p_reuse_object_flag
28079 ,p_target_business_group_id => p_target_business_group_id
28080 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28081 );
28082 --
28083 -- LGE records are created at Only PGM level
28084 -- This call creates the intersections between the program levels and ler.
28085 --
28086 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LGE') then
28087 BEN_PD_COPY_TO_BEN_TWO.create_LGE_rows(
28088 p_validate => p_validate
28089 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28090 ,p_effective_date => p_effective_date
28091 ,p_prefix_suffix_text => p_prefix_suffix_text
28092 ,p_reuse_object_flag => p_reuse_object_flag
28093 ,p_target_business_group_id => p_target_business_group_id
28094 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28095 );
28096 end if;
28097 --
28098 -- PGC records are created at Only PGM level
28099 -- This call creates the intersections between the program levels and dpnt_cvg_ctfn_typ_cd.
28100 --
28101 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PGC') then
28102 BEN_PD_COPY_TO_BEN_TWO.create_PGC_rows(
28103 p_validate => p_validate
28104 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28105 ,p_effective_date => p_effective_date
28106 ,p_prefix_suffix_text => p_prefix_suffix_text
28107 ,p_reuse_object_flag => p_reuse_object_flag
28108 ,p_target_business_group_id => p_target_business_group_id
28109 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28110 );
28111
28112 end if;
28113 --TCS PDW Integration ENH
28114
28115 end if;
28116 --
28117 --
28118 -- Now call eligibility profile creation.
28119 --
28120
28121 BEN_PD_COPY_TO_BEN_four.create_all_elig_prf_ben_rows
28122 (
28123 p_validate => p_validate
28124 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28125 ,p_effective_date => p_effective_date
28126 ,p_prefix_suffix_text => p_prefix_suffix_text
28127 ,p_reuse_object_flag => p_reuse_object_flag
28128 ,p_target_business_group_id => p_target_business_group_id
28129 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28130 );
28131 --
28132 -- Now make call to rate and all other ows creation
28133 --
28134 --TCS PDW Integration ENH
28135
28136 if (BEN_PD_COPY_TO_BEN_TWO.g_row_type_cd <> 'ELP') then
28137 --TCS PDW Integration ENH
28138
28139 BEN_PD_COPY_TO_BEN_five.create_rate_rows
28140 (
28141 p_validate => p_validate
28142 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28143 ,p_effective_date => p_effective_date
28144 ,p_prefix_suffix_text => p_prefix_suffix_text
28145 ,p_reuse_object_flag => p_reuse_object_flag
28146 ,p_target_business_group_id => p_target_business_group_id
28147 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28148 );
28149 --
28150 -- Now call rate profile creation.
28151 --
28152 BEN_PD_COPY_TO_BEN_three.create_all_rt_prf_ben_rows
28153 (
28154 p_validate => p_validate
28155 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28156 ,p_effective_date => p_effective_date
28157 ,p_prefix_suffix_text => p_prefix_suffix_text
28158 ,p_reuse_object_flag => p_reuse_object_flag
28159 ,p_target_business_group_id => p_target_business_group_id
28160 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28161 );
28162 --TCS PDW Integration ENH
28163 end if;
28164 --TCS PDW Integration ENH
28165 --
28166 end create_pgm_intersect_rows ;
28167 --
28168 procedure create_stg_to_ben_rows
28169 (
28170 p_validate in number default 0 -- false
28171 ,p_copy_entity_txn_id in number
28172 ,p_effective_date in date
28173 ,p_prefix_suffix_text in varchar2 default null
28174 ,p_reuse_object_flag in varchar2 default null
28175 ,p_target_business_group_id in varchar2 default null
28176 ,p_prefix_suffix_cd in varchar2 default null
28177 ,p_effective_date_to_copy in date default null
28178 ) is
28179
28180 cursor c_transaction_category(c_copy_entity_txn_id in number) is
28181 select tcg.short_name
28182 from pqh_copy_entity_txns cet,
28183 pqh_transaction_categories tcg
28184 where cet.copy_entity_txn_id = c_copy_entity_txn_id
28185 and cet.transaction_category_id = tcg.transaction_category_id;
28186
28187 l_transaction_category c_transaction_category%rowtype;
28188
28189 begin
28190 --
28191 --Call Create PGM ROWS
28192 --
28193 -- To set the Global variable for Mapping data.
28194 set_mapping(p_copy_entity_txn_id) ;
28195 --
28196 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl.delete;
28197 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(0) := null ;
28198 BEN_PD_COPY_TO_BEN_ONE.g_count := 1 ;
28199 --
28200 -- Initialize Logging Tables
28201 BEN_PD_COPY_TO_BEN_ONE.init_log_tbl;
28202 --
28203
28204 -- Update information9 to NULL
28205 -- Required for reusing Copy Process
28206
28207 update ben_copy_entity_results
28208 set information9 = null
28209 where copy_entity_txn_id = p_copy_entity_txn_id;
28210
28211
28212 BEN_PD_COPY_TO_BEN_ONE.init_table_data_in_cer(p_copy_entity_txn_id);
28213
28214 -- Initialize global variable for Effective Date to Copy
28215 BEN_PD_COPY_TO_BEN_ONE.g_copy_effective_date := p_effective_date_to_copy;
28216
28217 open c_transaction_category(p_copy_entity_txn_id);
28218 fetch c_transaction_category into l_transaction_category;
28219 close c_transaction_category;
28220
28221 -- Initialize global variable for Transaction Category
28222 BEN_PD_COPY_TO_BEN_ONE.g_transaction_category := l_transaction_category.short_name;
28223
28224 BEN_PD_COPY_TO_BEN_TWO.create_pgm_intersect_rows(
28225 p_validate => p_validate
28226 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28227 ,p_effective_date => p_effective_date
28228 ,p_prefix_suffix_text => p_prefix_suffix_text
28229 ,p_reuse_object_flag => p_reuse_object_flag
28230 ,p_target_business_group_id => p_target_business_group_id
28231 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28232 );
28233
28234 BEN_PD_COPY_TO_BEN_ONE.g_copy_effective_date := null;
28235 BEN_PD_COPY_TO_BEN_ONE.g_transaction_category := null;
28236 --
28237 --
28238 end create_stg_to_ben_rows ;
28239 --
28240 end BEN_PD_COPY_TO_BEN_TWO;