[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.15.12020000.2 2012/09/10 06:45:25 amnaraya ship $ */
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.information13 ; --13109026
9140 l_RLSHP_TYP_CD := r_PYD.information15 ; --13109026
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 --Start 129
16063 cursor c_pl_yrp(p_yr_perd_id number,
16064 p_pl_id number) is
16065 SELECT yrp1.start_date
16066 , yrp1.end_date
16067 , yrp2.start_date
16068 , yrp2.end_date
16069 FROM ben_yr_perd yrp1
16070 , ben_yr_perd yrp2
16071 , ben_popl_yr_perd byrp
16072 WHERE yrp1.yr_perd_id = p_yr_perd_id
16073 AND byrp.pl_id = p_pl_id
16074 AND byrp.business_group_id + 0 = p_target_business_group_id
16075 AND yrp1.business_group_id + 0 = p_target_business_group_id
16076 AND yrp2.business_group_id + 0 = p_target_business_group_id
16077 AND byrp.yr_perd_id = yrp2.yr_perd_id
16078 AND (
16079 yrp1.start_date
16080 BETWEEN yrp2.start_date
16081 AND yrp2.end_date
16082 OR yrp1.end_date
16083 BETWEEN yrp2.start_date
16084 AND yrp2.end_date
16085 )
16086 ORDER BY yrp2.start_date;
16087
16088 l_c_start_date date;
16089 l_n_start_date date;
16090 l_c_end_date date;
16091 l_n_end_date date;
16092
16093 cursor c_dup_pl_yrp(p_yr_perd_id number,
16094 p_pl_id number) is
16095 SELECT NULL
16096 FROM ben_popl_yr_perd cpy
16097 WHERE cpy.pl_id = p_pl_id
16098 AND cpy.yr_perd_id = p_yr_perd_id
16099 AND cpy.business_group_id + 0 = p_target_business_group_id;
16100
16101 l_dup_pl_yrp c_dup_pl_yrp%rowtype;
16102
16103 cursor c_pl_name(p_pl_id number) is
16104 SELECT name
16105 FROM ben_pl_f
16106 WHERE business_group_id = p_target_business_group_id
16107 AND pl_id = p_pl_id
16108 AND p_effective_date
16109 BETWEEN effective_start_date
16110 AND effective_end_date;
16111 l_pl_name c_pl_name%rowtype;
16112 l_skip_pl_yrp boolean := false;
16113 --End 129
16114 --
16115 --UPD START
16116 --
16117 l_update boolean := false ;
16118 l_datetrack_mode varchar2(80) := hr_api.g_update;
16119 l_process_date date;
16120 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
16121 --
16122 --UPD END
16123 l_current_pk_id number := null ;
16124 l_prev_pk_id number := null ;
16125 l_first_rec boolean := true ;
16126 r_CPY c_CPY%rowtype;
16127 l_popl_yr_perd_id number ;
16128 l_object_version_number number ;
16129 l_effective_start_date date ;
16130 l_effective_end_date date ;
16131 l_prefix pqh_copy_entity_attribs.information1%type := null;
16132 l_suffix pqh_copy_entity_attribs.information1%type := null;
16133 l_new_value number(15);
16134 l_object_found_in_target boolean := false ;
16135 l_min_esd date;
16136 l_max_eed date;
16137 --
16138 begin
16139 -- Initialization
16140 l_object_found_in_target := false ;
16141 -- End Initialization
16142 -- Derive the prefix - sufix
16143 if p_prefix_suffix_cd = 'PREFIX' then
16144 l_prefix := p_prefix_suffix_text ;
16145 elsif p_prefix_suffix_cd = 'SUFFIX' then
16146 l_suffix := p_prefix_suffix_text ;
16147 else
16148 l_prefix := null ;
16149 l_suffix := null ;
16150 end if ;
16151 -- End Prefix Sufix derivation
16152 for r_CPY_unique in c_unique_CPY('CPY') loop
16153 --
16154 hr_utility.set_location(' r_CPY_unique.table_route_id '||r_CPY_unique.table_route_id,10);
16155 hr_utility.set_location(' r_CPY_unique.information1 '||r_CPY_unique.information1,10);
16156 hr_utility.set_location( 'r_CPY_unique.information2 '||r_CPY_unique.information2,10);
16157 hr_utility.set_location( 'r_CPY_unique.information3 '||r_CPY_unique.information3,10);
16158 -- If reuse objects flag is 'Y' then check for the object in the target business group
16159 -- if found insert the record into PLSql table and exit the loop else try create the
16160 -- object in the target business group
16161 --
16162 l_object_found_in_target := false ;
16163 l_min_esd := null ;
16164 l_max_eed := null ;
16165 --
16166 open c_CPY(r_CPY_unique.table_route_id,
16167 r_CPY_unique.information1,
16168 r_CPY_unique.information2,
16169 r_CPY_unique.information3 ) ;
16170 --
16171 fetch c_CPY into r_CPY ;
16172 --
16173 close c_CPY ;
16174 --
16175 l_update := false;
16176 l_process_date := p_effective_date;
16177 l_dml_operation:= r_CPY_unique.dml_operation ;
16178 l_PGM_ID := get_fk('PGM_ID', r_CPY.INFORMATION260,l_dml_operation);
16179 l_PL_ID := get_fk('PL_ID', r_CPY.INFORMATION261,l_dml_operation);
16180 l_YR_PERD_ID := get_fk('YR_PERD_ID', r_CPY.INFORMATION240,l_dml_operation);
16181 --UPD START
16182 --
16183 if l_dml_operation = 'UPDATE' then
16184 --
16185 l_update := true;
16186 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
16187 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
16188 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_YR_PERD_ID' ;
16189 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPY_unique.information1 ;
16190 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_CPY_unique.information1 ;
16191 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16192 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;
16193 --
16194 -- update_cer_with_target( g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ; -- NEW
16195 --
16196 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16197 --
16198 --DOUBT log_data('CPY',l_new_value,l_prefix || r_CPY_unique.name|| l_suffix,'REUSED');
16199 --
16200 end if ;
16201 l_POPL_YR_PERD_ID := r_CPY_unique.information1 ;
16202 l_object_version_number := r_CPY.information265 ;
16203 hr_utility.set_location( 'found record for update',10);
16204 --
16205 else
16206 --
16207 --UPD END
16208 if p_reuse_object_flag = 'Y' then
16209 -- cursor to find the object
16210 open c_find_CPY_in_target( r_CPY_unique.information2,l_max_eed,
16211 p_target_business_group_id, nvl(l_popl_yr_perd_id, -999) ) ;
16212 fetch c_find_CPY_in_target into l_new_value ;
16213 if c_find_CPY_in_target%found then
16214 --
16215 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
16216 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
16217 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_YR_PERD_ID' ;
16218 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPY_unique.information1 ;
16219 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
16220 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16221 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;
16222 --
16223 -- 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) ;
16224 --
16225 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16226 end if ;
16227 --
16228 l_object_found_in_target := true ;
16229 end if;
16230 close c_find_CPY_in_target ;
16231 --
16232 end if ;
16233 --
16234 end if; --if p_dml_operation
16235 --
16236 if not l_object_found_in_target OR l_update then
16237 --
16238 l_current_pk_id := r_CPY.information1;
16239 --
16240 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
16241 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
16242 --
16243 if l_current_pk_id = l_prev_pk_id then
16244 --
16245 l_first_rec := false ;
16246 --
16247 else
16248 --
16249 l_first_rec := true ;
16250 --
16251 end if ;
16252 --
16253 -- To avoid creating a child with out a parent
16254 --
16255 --
16256 if l_PGM_ID is null and l_PL_ID is null then
16257 l_first_rec := false ;
16258 end if;
16259 --
16260 if l_first_rec and not l_update then
16261 /*Start Bug 14490456
16262 If the plan year period overlaps with any of the current plan year
16263 periods, then log the skipping of plan year period creation in the
16264 log file.
16265 */
16266 --FND_FILE.PUT_LINE(FND_FILE.LOG, 'l_dml_operation: '||l_dml_operation);
16267 --FND_FILE.PUT_LINE(FND_FILE.LOG, 'l_PGM_ID: '||l_PGM_ID||' l_PL_ID: '||l_PL_ID||' l_YR_PERD_ID: '||l_YR_PERD_ID);
16268 if l_dml_operation = 'INSERT' and l_PGM_ID is null and l_PL_ID is not null then
16269 open c_pl_yrp(l_YR_PERD_ID,l_PL_ID);
16270 loop
16271 fetch c_pl_yrp into l_c_start_date,l_c_end_date,l_n_start_date,l_n_end_date;
16272 if c_pl_yrp%notfound then
16273 exit;
16274 end if;
16275 l_skip_pl_yrp := true;
16276 open c_pl_name(l_PL_ID);
16277 fetch c_pl_name into l_pl_name;
16278 close c_pl_name;
16279 FND_FILE.PUT_LINE(FND_FILE.LOG,'Skipping plan year period creation for plan "'||l_pl_name.name||'"');
16280 FND_FILE.PUT_LINE(FND_FILE.LOG, 'This plan year period "'||l_c_start_date||' - '||l_c_end_date||'" overlaps with another plan year period "'||l_n_start_date||' - '||l_n_end_date||'" for the plan "'||l_pl_name.name||'"' );
16281 end loop;
16282 close c_pl_yrp;
16283 if not l_skip_pl_yrp then
16284 open c_dup_pl_yrp(l_YR_PERD_ID,l_PL_ID);
16285 fetch c_dup_pl_yrp into l_dup_pl_yrp;
16286 if c_dup_pl_yrp%found then
16287 l_skip_pl_yrp := true;
16288 end if;
16289 close c_dup_pl_yrp;
16290 end if;
16291 end if;
16292
16293 if not l_skip_pl_yrp then
16294 --End Bug 14490456
16295 -- Call Create routine.
16296 hr_utility.set_location(' BEN_POPL_YR_PERD CREATE_POPL_YR_PERD ',20);
16297 BEN_POPL_YR_PERD_API.CREATE_POPL_YR_PERD(
16298 --
16299 P_VALIDATE => false
16300 --,P_EFFECTIVE_DATE => p_effective_date
16301 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16302 --
16303 ,P_ACPT_CLM_RQSTS_THRU_DT => r_CPY.INFORMATION308
16304 ,P_CPY_ATTRIBUTE1 => r_CPY.INFORMATION111
16305 ,P_CPY_ATTRIBUTE10 => r_CPY.INFORMATION120
16306 ,P_CPY_ATTRIBUTE11 => r_CPY.INFORMATION121
16307 ,P_CPY_ATTRIBUTE12 => r_CPY.INFORMATION122
16308 ,P_CPY_ATTRIBUTE13 => r_CPY.INFORMATION123
16309 ,P_CPY_ATTRIBUTE14 => r_CPY.INFORMATION124
16310 ,P_CPY_ATTRIBUTE15 => r_CPY.INFORMATION125
16311 ,P_CPY_ATTRIBUTE16 => r_CPY.INFORMATION126
16312 ,P_CPY_ATTRIBUTE17 => r_CPY.INFORMATION127
16313 ,P_CPY_ATTRIBUTE18 => r_CPY.INFORMATION128
16314 ,P_CPY_ATTRIBUTE19 => r_CPY.INFORMATION129
16315 ,P_CPY_ATTRIBUTE2 => r_CPY.INFORMATION112
16316 ,P_CPY_ATTRIBUTE20 => r_CPY.INFORMATION130
16317 ,P_CPY_ATTRIBUTE21 => r_CPY.INFORMATION131
16318 ,P_CPY_ATTRIBUTE22 => r_CPY.INFORMATION132
16319 ,P_CPY_ATTRIBUTE23 => r_CPY.INFORMATION133
16320 ,P_CPY_ATTRIBUTE24 => r_CPY.INFORMATION134
16321 ,P_CPY_ATTRIBUTE25 => r_CPY.INFORMATION135
16322 ,P_CPY_ATTRIBUTE26 => r_CPY.INFORMATION136
16323 ,P_CPY_ATTRIBUTE27 => r_CPY.INFORMATION137
16324 ,P_CPY_ATTRIBUTE28 => r_CPY.INFORMATION138
16325 ,P_CPY_ATTRIBUTE29 => r_CPY.INFORMATION139
16326 ,P_CPY_ATTRIBUTE3 => r_CPY.INFORMATION113
16327 ,P_CPY_ATTRIBUTE30 => r_CPY.INFORMATION140
16328 ,P_CPY_ATTRIBUTE4 => r_CPY.INFORMATION114
16329 ,P_CPY_ATTRIBUTE5 => r_CPY.INFORMATION115
16330 ,P_CPY_ATTRIBUTE6 => r_CPY.INFORMATION116
16331 ,P_CPY_ATTRIBUTE7 => r_CPY.INFORMATION117
16332 ,P_CPY_ATTRIBUTE8 => r_CPY.INFORMATION118
16333 ,P_CPY_ATTRIBUTE9 => r_CPY.INFORMATION119
16334 ,P_CPY_ATTRIBUTE_CATEGORY => r_CPY.INFORMATION110
16335 ,P_ORDR_NUM => r_CPY.INFORMATION262
16336 ,P_PGM_ID => l_PGM_ID
16337 ,P_PL_ID => l_PL_ID
16338 ,P_POPL_YR_PERD_ID => l_popl_yr_perd_id
16339 ,P_PY_CLMS_THRU_DT => r_CPY.INFORMATION309
16340 ,P_YR_PERD_ID => l_YR_PERD_ID
16341 --
16342 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16343 );
16344 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16345 -- Update all relevent cer records with new pk_id
16346 hr_utility.set_location('Before plsql table ',222);
16347 hr_utility.set_location('new_value id '||l_popl_yr_perd_id,222);
16348 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_YR_PERD_ID' ;
16349 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CPY.information1 ;
16350 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_POPL_YR_PERD_ID ;
16351 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
16352 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;
16353 hr_utility.set_location('After plsql table ',222);
16354 --
16355 -- 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 ) ;
16356 --
16357 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16358 end if;--Bug 14490456
16359 elsif l_update then
16360 BEN_POPL_YR_PERD_API.UPDATE_POPL_YR_PERD(
16361 --
16362 P_VALIDATE => false
16363 --,P_EFFECTIVE_DATE => p_effective_date
16364 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16365 --
16366 ,P_ACPT_CLM_RQSTS_THRU_DT => r_CPY.INFORMATION308
16367 ,P_CPY_ATTRIBUTE1 => r_CPY.INFORMATION111
16368 ,P_CPY_ATTRIBUTE10 => r_CPY.INFORMATION120
16369 ,P_CPY_ATTRIBUTE11 => r_CPY.INFORMATION121
16370 ,P_CPY_ATTRIBUTE12 => r_CPY.INFORMATION122
16371 ,P_CPY_ATTRIBUTE13 => r_CPY.INFORMATION123
16372 ,P_CPY_ATTRIBUTE14 => r_CPY.INFORMATION124
16373 ,P_CPY_ATTRIBUTE15 => r_CPY.INFORMATION125
16374 ,P_CPY_ATTRIBUTE16 => r_CPY.INFORMATION126
16375 ,P_CPY_ATTRIBUTE17 => r_CPY.INFORMATION127
16376 ,P_CPY_ATTRIBUTE18 => r_CPY.INFORMATION128
16377 ,P_CPY_ATTRIBUTE19 => r_CPY.INFORMATION129
16378 ,P_CPY_ATTRIBUTE2 => r_CPY.INFORMATION112
16379 ,P_CPY_ATTRIBUTE20 => r_CPY.INFORMATION130
16380 ,P_CPY_ATTRIBUTE21 => r_CPY.INFORMATION131
16381 ,P_CPY_ATTRIBUTE22 => r_CPY.INFORMATION132
16382 ,P_CPY_ATTRIBUTE23 => r_CPY.INFORMATION133
16383 ,P_CPY_ATTRIBUTE24 => r_CPY.INFORMATION134
16384 ,P_CPY_ATTRIBUTE25 => r_CPY.INFORMATION135
16385 ,P_CPY_ATTRIBUTE26 => r_CPY.INFORMATION136
16386 ,P_CPY_ATTRIBUTE27 => r_CPY.INFORMATION137
16387 ,P_CPY_ATTRIBUTE28 => r_CPY.INFORMATION138
16388 ,P_CPY_ATTRIBUTE29 => r_CPY.INFORMATION139
16389 ,P_CPY_ATTRIBUTE3 => r_CPY.INFORMATION113
16390 ,P_CPY_ATTRIBUTE30 => r_CPY.INFORMATION140
16391 ,P_CPY_ATTRIBUTE4 => r_CPY.INFORMATION114
16392 ,P_CPY_ATTRIBUTE5 => r_CPY.INFORMATION115
16393 ,P_CPY_ATTRIBUTE6 => r_CPY.INFORMATION116
16394 ,P_CPY_ATTRIBUTE7 => r_CPY.INFORMATION117
16395 ,P_CPY_ATTRIBUTE8 => r_CPY.INFORMATION118
16396 ,P_CPY_ATTRIBUTE9 => r_CPY.INFORMATION119
16397 ,P_CPY_ATTRIBUTE_CATEGORY => r_CPY.INFORMATION110
16398 ,P_ORDR_NUM => r_CPY.INFORMATION262
16399 ,P_PGM_ID => l_PGM_ID
16400 ,P_PL_ID => l_PL_ID
16401 ,P_POPL_YR_PERD_ID => l_popl_yr_perd_id
16402 ,P_PY_CLMS_THRU_DT => r_CPY.INFORMATION309
16403 ,P_YR_PERD_ID => l_YR_PERD_ID
16404 --
16405 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16406 );
16407 --
16408 end if;
16409 --
16410 l_prev_pk_id := l_current_pk_id ;
16411 --
16412 end if;
16413 --
16414 end loop;
16415 --
16416 exception when others then
16417 --
16418 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CPY',r_cpy.information5 );
16419 --
16420 end create_CPY_rows;
16421
16422 --
16423 ---------------------------------------------------------------
16424 ----------------------< create_PET_rows >-----------------------
16425 ---------------------------------------------------------------
16426 --
16427 procedure create_PET_rows
16428 (
16429 p_validate in number default 0
16430 ,p_copy_entity_txn_id in number
16431 ,p_effective_date in date
16432 ,p_prefix_suffix_text in varchar2 default null
16433 ,p_reuse_object_flag in varchar2 default null
16434 ,p_target_business_group_id in varchar2 default null
16435 ,p_prefix_suffix_cd in varchar2 default null
16436 ) is
16437 --
16438 l_PGM_ID number;
16439 l_PL_ID number;
16440 l_ENRT_TYP_CYCL_CD varchar2(30);
16441 --
16442 cursor c_unique_PET(l_table_alias varchar2) is
16443 select distinct cpe.information1,
16444 cpe.information2,
16445 cpe.information3,
16446 cpe.table_route_id
16447 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
16448 pqh_table_route tr
16449 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16450 and cpe.table_route_id = tr.table_route_id
16451 -- and tr.where_clause = l_BEN_POPL_ENRT_TYP_CYCL_F
16452 and tr.table_alias = l_table_alias
16453 and cpe.number_of_copies = 1 -- ADDITION
16454 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
16455 order by information1, information2; --added for bug: 5151945
16456 --
16457 --
16458 cursor c_PET_min_max_dates(c_table_route_id number,
16459 c_information1 number) is
16460 select
16461 min(cpe.information2) min_esd,
16462 max(cpe.information3) min_eed
16463 from ben_copy_entity_results cpe
16464 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16465 and cpe.table_route_id = c_table_route_id
16466 and cpe.information1 = c_information1 ;
16467 --
16468 cursor c_PET(c_table_route_id number,
16469 c_information1 number,
16470 c_information2 date,
16471 c_information3 date ) is
16472 select
16473 cpe.*
16474 from ben_copy_entity_results cpe
16475 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16476 and cpe.table_route_id = c_table_route_id
16477 and cpe.information1 = c_information1
16478 and cpe.information2 = c_information2
16479 and cpe.information3 = c_information3
16480 and rownum = 1 ;
16481 -- Date Track target record
16482 cursor c_find_PET_in_target(
16483 c_effective_start_date date,
16484 c_effective_end_date date,
16485 c_business_group_id number,
16486 c_new_pk_id number) is
16487 select
16488 PET.popl_enrt_typ_cycl_id new_value
16489 from BEN_POPL_ENRT_TYP_CYCL_F PET
16490 where
16491 nvl(PET.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
16492 nvl(PET.PL_ID,-999) = nvl(l_PL_ID,-999) and
16493 PET.ENRT_TYP_CYCL_CD = l_ENRT_TYP_CYCL_CD and
16494 PET.business_group_id = c_business_group_id
16495 and PET.popl_enrt_typ_cycl_id <> c_new_pk_id
16496 --TEMPIK
16497 and c_effective_start_date between effective_start_date
16498 and effective_end_date ;
16499 --END TEMPIK
16500 /*TEMPIK
16501 and exists ( select null
16502 from BEN_POPL_ENRT_TYP_CYCL_F PET1
16503 where
16504 nvl(PET1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
16505 nvl(PET1.PL_ID,-999) = nvl(l_PL_ID,-999) and
16506 PET1.ENRT_TYP_CYCL_CD = l_ENRT_TYP_CYCL_CD and
16507 PET1.business_group_id = c_business_group_id
16508 and PET1.effective_start_date <= c_effective_start_date )
16509 and exists ( select null
16510 from BEN_POPL_ENRT_TYP_CYCL_F PET2
16511 where
16512 nvl(PET2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
16513 nvl(PET2.PL_ID,-999) = nvl(l_PL_ID,-999) and
16514 PET2.ENRT_TYP_CYCL_CD = l_ENRT_TYP_CYCL_CD and
16515 PET2.business_group_id = c_business_group_id
16516 and PET2.effective_end_date >= c_effective_end_date )
16517 ;
16518 TEMPIK */
16519 --TEMPIK
16520 l_dt_rec_found boolean ;
16521 --END TEMPIK
16522 --
16523 --UPD START
16524 --
16525 l_update boolean := false ;
16526 l_datetrack_mode varchar2(80) := hr_api.g_update;
16527 l_process_date date;
16528 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
16529 --
16530 --UPD END
16531 l_current_pk_id number := null ;
16532 l_prev_pk_id number := null ;
16533 l_first_rec boolean := true ;
16534 r_PET c_PET%rowtype;
16535 l_popl_enrt_typ_cycl_id number ;
16536 l_object_version_number number ;
16537 l_effective_start_date date ;
16538 l_effective_end_date date ;
16539 l_prefix pqh_copy_entity_attribs.information1%type := null;
16540 l_suffix pqh_copy_entity_attribs.information1%type := null;
16541 l_new_value number(15);
16542 l_object_found_in_target boolean := false ;
16543 l_min_esd date;
16544 l_max_eed date;
16545 l_effective_date date;
16546 --
16547 begin
16548 -- Initialization
16549 l_object_found_in_target := false ;
16550 -- End Initialization
16551 -- Derive the prefix - sufix
16552 if p_prefix_suffix_cd = 'PREFIX' then
16553 l_prefix := p_prefix_suffix_text ;
16554 elsif p_prefix_suffix_cd = 'SUFFIX' then
16555 l_suffix := p_prefix_suffix_text ;
16556 else
16557 l_prefix := null ;
16558 l_suffix := null ;
16559 end if ;
16560 -- End Prefix Sufix derivation
16561 for r_PET_unique in c_unique_PET('PET') loop
16562
16563 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
16564 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16565 r_PET_unique.information3 >=
16566 ben_pd_copy_to_ben_one.g_copy_effective_date)
16567 ) then
16568 --
16569 hr_utility.set_location(' r_PET_unique.table_route_id '||r_PET_unique.table_route_id,10);
16570 hr_utility.set_location(' r_PET_unique.information1 '||r_PET_unique.information1,10);
16571 hr_utility.set_location( 'r_PET_unique.information2 '||r_PET_unique.information2,10);
16572 hr_utility.set_location( 'r_PET_unique.information3 '||r_PET_unique.information3,10);
16573 -- If reuse objects flag is 'Y' then check for the object in the target business group
16574 -- if found insert the record into PLSql table and exit the loop else try create the
16575 -- object in the target business group
16576 --
16577 l_object_found_in_target := false ;
16578 --UPD START
16579 open c_PET(r_PET_unique.table_route_id,
16580 r_PET_unique.information1,
16581 r_PET_unique.information2,
16582 r_PET_unique.information3 ) ;
16583 --
16584 fetch c_PET into r_PET ;
16585 --
16586 close c_PET ;
16587 l_dml_operation:= r_PET_unique.dml_operation ;
16588 l_PGM_ID := get_fk('PGM_ID', r_PET.INFORMATION260,l_dml_operation );
16589 l_PL_ID := get_fk('PL_ID', r_PET.INFORMATION261,l_dml_operation );
16590 l_ENRT_TYP_CYCL_CD := r_PET.information11 ;
16591 l_update := false;
16592 l_process_date := p_effective_date;
16593 --
16594 if l_dml_operation = 'UPDATE' then
16595 --
16596 l_object_found_in_target := TRUE;
16597 --
16598 if l_process_date between r_PET_unique.information2 and r_PET_unique.information3 then
16599 l_update := true;
16600 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)
16601 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'
16602 then
16603 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' ;
16604 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PET_unique.information1 ;
16605 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PET_unique.information1 ;
16606 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16607 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;
16608 --
16609 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
16610 --
16611 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16612 --
16613 --DOUBT log_data('PET',l_new_value,l_prefix || r_PET_unique.name|| l_suffix,'REUSED');
16614 --
16615 end if ;
16616 hr_utility.set_location( 'found record for update',10);
16617 --
16618 else
16619 --
16620 l_update := false;
16621 --
16622 end if;
16623 else
16624 --
16625 --UPD END
16626 l_min_esd := null ;
16627 l_max_eed := null ;
16628 open c_PET_min_max_dates(r_PET_unique.table_route_id, r_PET_unique.information1 ) ;
16629 fetch c_PET_min_max_dates into l_min_esd,l_max_eed ;
16630 --
16631
16632 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16633 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
16634 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
16635 end if;
16636 l_min_esd := greatest(l_min_esd,r_PET_unique.information2);
16637 /* open c_PET(r_PET_unique.table_route_id,
16638 r_PET_unique.information1,
16639 r_PET_unique.information2,
16640 r_PET_unique.information3 ) ;
16641 --
16642 fetch c_PET into r_PET ;
16643 --
16644 close c_PET ; */
16645 --
16646 if p_reuse_object_flag = 'Y' then
16647 if c_PET_min_max_dates%found then
16648 -- cursor to find the object
16649 open c_find_PET_in_target( l_min_esd,l_max_eed,
16650 p_target_business_group_id, nvl(l_popl_enrt_typ_cycl_id, -999) ) ;
16651 fetch c_find_PET_in_target into l_new_value ;
16652 if c_find_PET_in_target%found then
16653 --
16654 --TEMPIK
16655 l_dt_rec_found := dt_api.check_min_max_dates
16656 (p_base_table_name => 'BEN_POPL_ENRT_TYP_CYCL_F',
16657 p_base_key_column => 'POPL_ENRT_TYP_CYCL_ID',
16658 p_base_key_value => l_new_value,
16659 p_from_date => l_min_esd,
16660 p_to_date => l_max_eed );
16661 if l_dt_rec_found THEN
16662 --END TEMPIK
16663 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
16664 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
16665 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' ;
16666 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PET_unique.information1 ;
16667 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
16668 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
16669 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;
16670 --
16671 -- 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) ;
16672 --
16673 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16674 end if ;
16675 --
16676 l_object_found_in_target := true ;
16677 --TEMPIK
16678 end if; -- l_dt_rec_found
16679 --END TEMPIK
16680 end if;
16681 close c_find_PET_in_target ;
16682 --
16683 end if;
16684 end if ;
16685 --
16686 close c_PET_min_max_dates ;
16687 end if; --if p_dml_operation
16688 --
16689 if not l_object_found_in_target OR l_update then
16690 --
16691 l_current_pk_id := r_PET.information1;
16692 --
16693 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
16694 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
16695 --
16696 if l_current_pk_id = l_prev_pk_id then
16697 --
16698 l_first_rec := false ;
16699 --
16700 else
16701 --
16702 l_first_rec := true ;
16703 --
16704 end if ;
16705 --
16706
16707 l_effective_date := r_PET.information2;
16708 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16709 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
16710 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
16711 end if;
16712
16713 if l_first_rec and not l_update then
16714 -- Call Create routine.
16715 hr_utility.set_location(' BEN_POPL_ENRT_TYP_CYCL_F CREATE_POPL_ENRT_TYP_CYCL ',20);
16716 BEN_POPL_ENRT_TYP_CYCL_API.CREATE_POPL_ENRT_TYP_CYCL(
16717 --
16718 P_VALIDATE => false
16719 ,P_EFFECTIVE_DATE => l_effective_date
16720 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16721 --
16722 ,P_ENRT_TYP_CYCL_CD => r_PET.INFORMATION11
16723 ,P_PET_ATTRIBUTE1 => r_PET.INFORMATION111
16724 ,P_PET_ATTRIBUTE10 => r_PET.INFORMATION120
16725 ,P_PET_ATTRIBUTE11 => r_PET.INFORMATION121
16726 ,P_PET_ATTRIBUTE12 => r_PET.INFORMATION122
16727 ,P_PET_ATTRIBUTE13 => r_PET.INFORMATION123
16728 ,P_PET_ATTRIBUTE14 => r_PET.INFORMATION124
16729 ,P_PET_ATTRIBUTE15 => r_PET.INFORMATION125
16730 ,P_PET_ATTRIBUTE16 => r_PET.INFORMATION126
16731 ,P_PET_ATTRIBUTE17 => r_PET.INFORMATION127
16732 ,P_PET_ATTRIBUTE18 => r_PET.INFORMATION128
16733 ,P_PET_ATTRIBUTE19 => r_PET.INFORMATION129
16734 ,P_PET_ATTRIBUTE2 => r_PET.INFORMATION112
16735 ,P_PET_ATTRIBUTE20 => r_PET.INFORMATION130
16736 ,P_PET_ATTRIBUTE21 => r_PET.INFORMATION131
16737 ,P_PET_ATTRIBUTE22 => r_PET.INFORMATION132
16738 ,P_PET_ATTRIBUTE23 => r_PET.INFORMATION133
16739 ,P_PET_ATTRIBUTE24 => r_PET.INFORMATION134
16740 ,P_PET_ATTRIBUTE25 => r_PET.INFORMATION135
16741 ,P_PET_ATTRIBUTE26 => r_PET.INFORMATION136
16742 ,P_PET_ATTRIBUTE27 => r_PET.INFORMATION137
16743 ,P_PET_ATTRIBUTE28 => r_PET.INFORMATION138
16744 ,P_PET_ATTRIBUTE29 => r_PET.INFORMATION139
16745 ,P_PET_ATTRIBUTE3 => r_PET.INFORMATION113
16746 ,P_PET_ATTRIBUTE30 => r_PET.INFORMATION140
16747 ,P_PET_ATTRIBUTE4 => r_PET.INFORMATION114
16748 ,P_PET_ATTRIBUTE5 => r_PET.INFORMATION115
16749 ,P_PET_ATTRIBUTE6 => r_PET.INFORMATION116
16750 ,P_PET_ATTRIBUTE7 => r_PET.INFORMATION117
16751 ,P_PET_ATTRIBUTE8 => r_PET.INFORMATION118
16752 ,P_PET_ATTRIBUTE9 => r_PET.INFORMATION119
16753 ,P_PET_ATTRIBUTE_CATEGORY => r_PET.INFORMATION110
16754 ,P_PGM_ID => l_PGM_ID
16755 ,P_PL_ID => l_PL_ID
16756 ,P_POPL_ENRT_TYP_CYCL_ID => l_popl_enrt_typ_cycl_id
16757 --
16758 ,P_EFFECTIVE_START_DATE => l_effective_start_date
16759 ,P_EFFECTIVE_END_DATE => l_effective_end_date
16760 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16761 );
16762 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16763 -- Update all relevent cer records with new pk_id
16764 hr_utility.set_location('Before plsql table ',222);
16765 hr_utility.set_location('new_value id '||l_popl_enrt_typ_cycl_id,222);
16766 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' ;
16767 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PET.information1 ;
16768 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 ;
16769 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
16770 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;
16771 hr_utility.set_location('After plsql table ',222);
16772 --
16773 -- 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 ) ;
16774 --
16775 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
16776 --
16777 else
16778 --
16779 -- Call Update routine for the pk_id created in prev run .
16780 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16781 hr_utility.set_location(' BEN_POPL_ENRT_TYP_CYCL_F UPDATE_POPL_ENRT_TYP_CYCL ',30);
16782 --UPD START
16783 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
16784 --
16785 if l_update then
16786 --
16787 l_datetrack_mode := r_PET.datetrack_mode ;
16788 --
16789 get_dt_modes(
16790 p_effective_date => l_process_date,
16791 p_effective_end_date => r_PET.information3,
16792 p_effective_start_date => r_PET.information2,
16793 p_dml_operation => r_PET.dml_operation,
16794 p_datetrack_mode => l_datetrack_mode );
16795 -- p_update => l_update
16796 --
16797 l_effective_date := l_process_date;
16798 l_POPL_ENRT_TYP_CYCL_ID := r_PET.information1;
16799 l_object_version_number := r_PET.information265;
16800 --
16801 end if;
16802 --
16803 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
16804 --
16805 IF l_update OR l_dml_operation <> 'UPDATE' THEN
16806 --UPD END
16807 BEN_POPL_ENRT_TYP_CYCL_API.UPDATE_POPL_ENRT_TYP_CYCL(
16808 --
16809 P_VALIDATE => false
16810 ,P_EFFECTIVE_DATE => l_effective_date
16811 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16812 --
16813 ,P_ENRT_TYP_CYCL_CD => r_PET.INFORMATION11
16814 ,P_PET_ATTRIBUTE1 => r_PET.INFORMATION111
16815 ,P_PET_ATTRIBUTE10 => r_PET.INFORMATION120
16816 ,P_PET_ATTRIBUTE11 => r_PET.INFORMATION121
16817 ,P_PET_ATTRIBUTE12 => r_PET.INFORMATION122
16818 ,P_PET_ATTRIBUTE13 => r_PET.INFORMATION123
16819 ,P_PET_ATTRIBUTE14 => r_PET.INFORMATION124
16820 ,P_PET_ATTRIBUTE15 => r_PET.INFORMATION125
16821 ,P_PET_ATTRIBUTE16 => r_PET.INFORMATION126
16822 ,P_PET_ATTRIBUTE17 => r_PET.INFORMATION127
16823 ,P_PET_ATTRIBUTE18 => r_PET.INFORMATION128
16824 ,P_PET_ATTRIBUTE19 => r_PET.INFORMATION129
16825 ,P_PET_ATTRIBUTE2 => r_PET.INFORMATION112
16826 ,P_PET_ATTRIBUTE20 => r_PET.INFORMATION130
16827 ,P_PET_ATTRIBUTE21 => r_PET.INFORMATION131
16828 ,P_PET_ATTRIBUTE22 => r_PET.INFORMATION132
16829 ,P_PET_ATTRIBUTE23 => r_PET.INFORMATION133
16830 ,P_PET_ATTRIBUTE24 => r_PET.INFORMATION134
16831 ,P_PET_ATTRIBUTE25 => r_PET.INFORMATION135
16832 ,P_PET_ATTRIBUTE26 => r_PET.INFORMATION136
16833 ,P_PET_ATTRIBUTE27 => r_PET.INFORMATION137
16834 ,P_PET_ATTRIBUTE28 => r_PET.INFORMATION138
16835 ,P_PET_ATTRIBUTE29 => r_PET.INFORMATION139
16836 ,P_PET_ATTRIBUTE3 => r_PET.INFORMATION113
16837 ,P_PET_ATTRIBUTE30 => r_PET.INFORMATION140
16838 ,P_PET_ATTRIBUTE4 => r_PET.INFORMATION114
16839 ,P_PET_ATTRIBUTE5 => r_PET.INFORMATION115
16840 ,P_PET_ATTRIBUTE6 => r_PET.INFORMATION116
16841 ,P_PET_ATTRIBUTE7 => r_PET.INFORMATION117
16842 ,P_PET_ATTRIBUTE8 => r_PET.INFORMATION118
16843 ,P_PET_ATTRIBUTE9 => r_PET.INFORMATION119
16844 ,P_PET_ATTRIBUTE_CATEGORY => r_PET.INFORMATION110
16845 ,P_PGM_ID => l_PGM_ID
16846 ,P_PL_ID => l_PL_ID
16847 ,P_POPL_ENRT_TYP_CYCL_ID => l_popl_enrt_typ_cycl_id
16848 --
16849 ,P_EFFECTIVE_START_DATE => l_effective_start_date
16850 ,P_EFFECTIVE_END_DATE => l_effective_end_date
16851 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16852 ,P_DATETRACK_MODE => l_datetrack_mode
16853 );
16854 --
16855 end if; -- l_update
16856 end if;
16857 --
16858 -- Delete the row if it is end dated.
16859 --
16860 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
16861 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
16862 trunc(l_max_eed) = r_PET.information3) then
16863 --
16864 BEN_POPL_ENRT_TYP_CYCL_API.delete_POPL_ENRT_TYP_CYCL(
16865 --
16866 p_validate => false
16867 ,p_popl_enrt_typ_cycl_id => l_popl_enrt_typ_cycl_id
16868 ,p_effective_start_date => l_effective_start_date
16869 ,p_effective_end_date => l_effective_end_date
16870 ,p_object_version_number => l_object_version_number
16871 ,p_effective_date => l_max_eed
16872 ,p_datetrack_mode => hr_api.g_delete
16873 --
16874 );
16875 --
16876 end if;
16877 --
16878 l_prev_pk_id := l_current_pk_id ;
16879 --
16880 end if;
16881 --
16882 end if;
16883 --
16884 end loop;
16885 --
16886 exception when others then
16887 --
16888 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PET',r_pet.information5 );
16889 --
16890 end create_PET_rows;
16891
16892 --
16893 ---------------------------------------------------------------
16894 ----------------------< create_ENP_rows >-----------------------
16895 ---------------------------------------------------------------
16896 --
16897 procedure create_ENP_rows
16898 (
16899 p_validate in number default 0
16900 ,p_copy_entity_txn_id in number
16901 ,p_effective_date in date
16902 ,p_prefix_suffix_text in varchar2 default null
16903 ,p_reuse_object_flag in varchar2 default null
16904 ,p_target_business_group_id in varchar2 default null
16905 ,p_prefix_suffix_cd in varchar2 default null
16906 ) is
16907 --
16908 l_ENRT_CVG_END_DT_RL number;
16909 l_ENRT_CVG_STRT_DT_RL number;
16910 l_LER_ID number;
16911 l_POPL_ENRT_TYP_CYCL_ID number;
16912 l_POS_STRUCTURE_VERSION_ID number;
16913 l_RT_END_DT_RL number;
16914 l_RT_STRT_DT_RL number;
16915 l_HRCHY_RL number;
16916 l_WTHN_YR_PERD_ID number;
16917 l_YR_PERD_ID number;
16918 cursor c_unique_ENP(l_table_alias varchar2) is
16919 select distinct cpe.information1,
16920 cpe.information2,
16921 cpe.information3,
16922 cpe.table_route_id
16923 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
16924 pqh_table_route tr
16925 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16926 and cpe.table_route_id = tr.table_route_id
16927 -- and tr.where_clause = l_BEN_ENRT_PERD
16928 and tr.table_alias = l_table_alias
16929 and cpe.number_of_copies = 1 -- ADDITION
16930 group by cpe.information1,cpe.information2,
16931 cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
16932 order by information1, information2; --added for bug: 5151945
16933 --
16934 --
16935 cursor c_ENP_min_max_dates(c_table_route_id number,
16936 c_information1 number) is
16937 select
16938 min(cpe.information2) min_esd,
16939 max(cpe.information3) min_eed
16940 from ben_copy_entity_results cpe
16941 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16942 and cpe.table_route_id = c_table_route_id
16943 and cpe.information1 = c_information1 ;
16944 --
16945 cursor c_ENP(c_table_route_id number,
16946 c_information1 number,
16947 c_information2 date,
16948 c_information3 date) is
16949 select
16950 cpe.*
16951 from ben_copy_entity_results cpe
16952 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
16953 and cpe.table_route_id = c_table_route_id
16954 and cpe.information1 = c_information1
16955 and rownum = 1 ;
16956 -- Date Track target record
16957 cursor c_find_ENP_in_target(
16958 c_effective_start_date date,
16959 c_effective_end_date date,
16960 c_business_group_id number,
16961 c_new_pk_id number) is
16962 select
16963 ENP.enrt_perd_id new_value
16964 from BEN_ENRT_PERD ENP
16965 where
16966 ENP.POPL_ENRT_TYP_CYCL_ID = l_POPL_ENRT_TYP_CYCL_ID and
16967 nvl(ENP.LER_ID,-999) = nvl(l_LER_ID,-999) and
16968 nvl(ENP.YR_PERD_ID,-999) = nvl(l_YR_PERD_ID,-999) and
16969 ENP.business_group_id = c_business_group_id
16970 and ENP.enrt_perd_id <> c_new_pk_id
16971 ;
16972 --
16973 --UPD START
16974 --
16975 l_update boolean := false ;
16976 l_datetrack_mode varchar2(80) := hr_api.g_update;
16977 l_process_date date;
16978 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
16979 --
16980 --UPD END
16981 l_current_pk_id number := null ;
16982 l_prev_pk_id number := null ;
16983 l_first_rec boolean := true ;
16984 r_ENP c_ENP%rowtype;
16985 l_enrt_perd_id number ;
16986 l_object_version_number number ;
16987 l_effective_start_date date ;
16988 l_effective_end_date date ;
16989 l_prefix pqh_copy_entity_attribs.information1%type := null;
16990 l_suffix pqh_copy_entity_attribs.information1%type := null;
16991 l_new_value number(15);
16992 l_object_found_in_target boolean := false ;
16993 l_min_esd date;
16994 l_max_eed date;
16995 l_parent_effective_start_date date;
16996 --
16997 begin
16998 -- Initialization
16999 l_object_found_in_target := false ;
17000 -- End Initialization
17001 -- Derive the prefix - sufix
17002 if p_prefix_suffix_cd = 'PREFIX' then
17003 l_prefix := p_prefix_suffix_text ;
17004 elsif p_prefix_suffix_cd = 'SUFFIX' then
17005 l_suffix := p_prefix_suffix_text ;
17006 else
17007 l_prefix := null ;
17008 l_suffix := null ;
17009 end if ;
17010 -- End Prefix Sufix derivation
17011 for r_ENP_unique in c_unique_ENP('ENP') loop
17012 --
17013 hr_utility.set_location(' r_ENP_unique.table_route_id '||r_ENP_unique.table_route_id,10);
17014 hr_utility.set_location(' r_ENP_unique.information1 '||r_ENP_unique.information1,10);
17015 hr_utility.set_location( 'r_ENP_unique.information2 '||r_ENP_unique.information2,10);
17016 hr_utility.set_location( 'r_ENP_unique.information3 '||r_ENP_unique.information3,10);
17017 -- If reuse objects flag is 'Y' then check for the object in the target business group
17018 -- if found insert the record into PLSql table and exit the loop else try create the
17019 -- object in the target business group
17020 --
17021 l_object_found_in_target := false ;
17022 l_min_esd := null ;
17023 l_max_eed := null ;
17024 --
17025 open c_ENP(r_ENP_unique.table_route_id,
17026 r_ENP_unique.information1,
17027 r_ENP_unique.information2,
17028 r_ENP_unique.information3 ) ;
17029 --
17030 fetch c_ENP into r_ENP ;
17031 --
17032 close c_ENP ;
17033 --
17034 l_update := false;
17035 l_process_date := p_effective_date;
17036 l_dml_operation:= r_ENP_unique.dml_operation ;
17037 l_ENRT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_ENP.INFORMATION263,l_dml_operation);
17038 l_ENRT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_ENP.INFORMATION262,l_dml_operation);
17039 l_LER_ID := get_fk('LER_ID', r_ENP.INFORMATION257,l_dml_operation);
17040 l_POPL_ENRT_TYP_CYCL_ID := get_fk('POPL_ENRT_TYP_CYCL_ID', r_ENP.INFORMATION232,l_dml_operation);
17041 l_RT_END_DT_RL := get_fk('FORMULA_ID', r_ENP.INFORMATION264,l_dml_operation);
17042 l_RT_STRT_DT_RL := get_fk('FORMULA_ID', r_ENP.INFORMATION261,l_dml_operation);
17043 l_HRCHY_RL := get_fk('FORMULA_ID', r_ENP.INFORMATION267,l_dml_operation);
17044 l_WTHN_YR_PERD_ID := get_fk('WTHN_YR_PERD_ID', r_ENP.INFORMATION266,l_dml_operation);
17045 l_YR_PERD_ID := get_fk('YR_PERD_ID', r_ENP.INFORMATION240,l_dml_operation);
17046
17047
17048
17049 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
17050 l_POS_STRUCTURE_VERSION_ID := r_ENP.information176 ;
17051 else
17052 l_POS_STRUCTURE_VERSION_ID := r_ENP.information174 ;
17053 end if;
17054
17055
17056 if l_POPL_ENRT_TYP_CYCL_ID is not null then -- Do not create if parent record does not exist
17057
17058 --UPD START
17059 --
17060 if l_dml_operation = 'UPDATE' then
17061 --
17062 l_update := true;
17063 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
17064 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
17065 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ENRT_PERD_ID' ;
17066 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ENP_unique.information1 ;
17067 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ENP_unique.information1 ;
17068 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
17069 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;
17070 --
17071 -- 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
17072 --
17073 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17074 --
17075 --DOUBT log_data('ENP',l_new_value,l_prefix || r_ENP_unique.name|| l_suffix,'REUSED');
17076 --
17077 end if ;
17078 l_ENRT_PERD_ID := r_ENP_unique.information1 ;
17079 l_object_version_number := r_ENP.information265 ;
17080 hr_utility.set_location( 'found record for update',10);
17081 --
17082 else
17083 --
17084 --UPD END
17085 if p_reuse_object_flag = 'Y' then
17086 -- cursor to find the object
17087 open c_find_ENP_in_target( r_ENP_unique.information2,l_max_eed,
17088 p_target_business_group_id, nvl(l_enrt_perd_id, -999) ) ;
17089 fetch c_find_ENP_in_target into l_new_value ;
17090 if c_find_ENP_in_target%found then
17091 --
17092 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
17093 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
17094 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ENRT_PERD_ID' ;
17095 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ENP_unique.information1 ;
17096 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
17097 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
17098 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;
17099 --
17100 -- 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) ;
17101 --
17102 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17103 end if ;
17104 --
17105 l_object_found_in_target := true ;
17106 end if;
17107 close c_find_ENP_in_target ;
17108 --
17109 end if ;
17110 --
17111 end if; --if p_dml_operation
17112 --
17113 if not l_object_found_in_target OR l_update then
17114 --
17115 l_current_pk_id := r_ENP.information1;
17116 --
17117 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
17118 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
17119 --
17120 if l_current_pk_id = l_prev_pk_id then
17121 --
17122 l_first_rec := false ;
17123 --
17124 else
17125 --
17126 l_first_rec := true ;
17127 --
17128 end if ;
17129 --
17130
17131 l_parent_effective_start_date := r_ENP.information10;
17132 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null ) then
17133 if l_parent_effective_start_date is null then
17134 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
17135 elsif l_parent_effective_start_date < ben_pd_copy_to_ben_one.g_copy_effective_date then
17136 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
17137 end if;
17138 end if;
17139 --
17140 -- To avoid creating a child with out a parent
17141 --
17142 --
17143 if l_LER_ID is null and l_POPL_ENRT_TYP_CYCL_ID is null then
17144 l_first_rec := false ;
17145 end if;
17146 --
17147 if l_first_rec and not l_update then
17148 -- Call Create routine.
17149 hr_utility.set_location(' BEN_ENRT_PERD CREATE_ENROLLMENT_PERIOD ',20);
17150 BEN_ENROLLMENT_PERIOD_API.CREATE_ENROLLMENT_PERIOD(
17151 --
17152 P_VALIDATE => false
17153 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
17154 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
17155 --
17156 ,P_ASG_UPDT_EFF_DATE => r_ENP.INFORMATION306
17157 ,P_ASND_LF_EVT_DT => r_ENP.INFORMATION316
17158 ,P_AUTO_DISTR_FLAG => r_ENP.INFORMATION11
17159 ,P_BDGT_UPD_END_DT => r_ENP.INFORMATION308
17160 ,P_BDGT_UPD_STRT_DT => r_ENP.INFORMATION309
17161 ,P_CLS_ENRT_DT_TO_USE_CD => r_ENP.INFORMATION16
17162 ,P_DFLT_ENRT_DT => r_ENP.INFORMATION312
17163 ,P_DFLT_WS_ACC_CD => r_ENP.INFORMATION12
17164 ,P_EMP_INTERVIEW_TYPE_CD => r_ENP.INFORMATION13
17165 ,P_END_DT => r_ENP.INFORMATION317
17166 ,P_ENP_ATTRIBUTE1 => r_ENP.INFORMATION111
17167 ,P_ENP_ATTRIBUTE10 => r_ENP.INFORMATION120
17168 ,P_ENP_ATTRIBUTE11 => r_ENP.INFORMATION121
17169 ,P_ENP_ATTRIBUTE12 => r_ENP.INFORMATION122
17170 ,P_ENP_ATTRIBUTE13 => r_ENP.INFORMATION123
17171 ,P_ENP_ATTRIBUTE14 => r_ENP.INFORMATION124
17172 ,P_ENP_ATTRIBUTE15 => r_ENP.INFORMATION125
17173 ,P_ENP_ATTRIBUTE16 => r_ENP.INFORMATION126
17174 ,P_ENP_ATTRIBUTE17 => r_ENP.INFORMATION127
17175 ,P_ENP_ATTRIBUTE18 => r_ENP.INFORMATION128
17176 ,P_ENP_ATTRIBUTE19 => r_ENP.INFORMATION129
17177 ,P_ENP_ATTRIBUTE2 => r_ENP.INFORMATION112
17178 ,P_ENP_ATTRIBUTE20 => r_ENP.INFORMATION130
17179 ,P_ENP_ATTRIBUTE21 => r_ENP.INFORMATION131
17180 ,P_ENP_ATTRIBUTE22 => r_ENP.INFORMATION132
17181 ,P_ENP_ATTRIBUTE23 => r_ENP.INFORMATION133
17182 ,P_ENP_ATTRIBUTE24 => r_ENP.INFORMATION134
17183 ,P_ENP_ATTRIBUTE25 => r_ENP.INFORMATION135
17184 ,P_ENP_ATTRIBUTE26 => r_ENP.INFORMATION136
17185 ,P_ENP_ATTRIBUTE27 => r_ENP.INFORMATION137
17186 ,P_ENP_ATTRIBUTE28 => r_ENP.INFORMATION138
17187 ,P_ENP_ATTRIBUTE29 => r_ENP.INFORMATION139
17188 ,P_ENP_ATTRIBUTE3 => r_ENP.INFORMATION113
17189 ,P_ENP_ATTRIBUTE30 => r_ENP.INFORMATION140
17190 ,P_ENP_ATTRIBUTE4 => r_ENP.INFORMATION114
17191 ,P_ENP_ATTRIBUTE5 => r_ENP.INFORMATION115
17192 ,P_ENP_ATTRIBUTE6 => r_ENP.INFORMATION116
17193 ,P_ENP_ATTRIBUTE7 => r_ENP.INFORMATION117
17194 ,P_ENP_ATTRIBUTE8 => r_ENP.INFORMATION118
17195 ,P_ENP_ATTRIBUTE9 => r_ENP.INFORMATION119
17196 ,P_ENP_ATTRIBUTE_CATEGORY => r_ENP.INFORMATION110
17197 --Added two cols reinstate_cd,reinstate_ovrdn_cd
17198 ,P_REINSTATE_CD => r_ENP.INFORMATION26
17199 ,P_REINSTATE_OVRDN_CD => r_ENP.INFORMATION27
17200 --
17201 ,P_ENRT_CVG_END_DT_CD => r_ENP.INFORMATION18
17202 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
17203 ,P_ENRT_CVG_STRT_DT_CD => r_ENP.INFORMATION17
17204 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
17205 ,P_ENRT_PERD_DET_OVRLP_BCKDT_CD => r_ENP.INFORMATION22
17206 ,P_ENRT_PERD_ID => l_enrt_perd_id
17207 ,P_HRCHY_TO_USE_CD => r_ENP.INFORMATION14
17208 ,P_LER_ID => l_LER_ID
17209 ,P_PERF_REVW_STRT_DT => r_ENP.INFORMATION307
17210 ,P_POPL_ENRT_TYP_CYCL_ID => l_POPL_ENRT_TYP_CYCL_ID
17211 ,P_POS_STRUCTURE_VERSION_ID => l_POS_STRUCTURE_VERSION_ID
17212 ,P_PROCG_END_DT => r_ENP.INFORMATION315
17213 ,P_PRSVR_BDGT_CD => r_ENP.INFORMATION15
17214 ,P_RT_END_DT_CD => r_ENP.INFORMATION20
17215 ,P_RT_END_DT_RL => l_RT_END_DT_RL
17216 ,P_RT_STRT_DT_CD => r_ENP.INFORMATION19
17217 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
17218 ,P_STRT_DT => r_ENP.INFORMATION318
17219 ,P_USES_BDGT_FLAG => r_ENP.INFORMATION21
17220 ,P_WS_UPD_END_DT => r_ENP.INFORMATION319
17221 ,P_WS_UPD_STRT_DT => r_ENP.INFORMATION320
17222 ,P_WTHN_YR_PERD_ID => l_WTHN_YR_PERD_ID
17223 ,P_YR_PERD_ID => l_YR_PERD_ID
17224 --cwbglobal
17225 -- cwb tilak
17226 ,p_DATA_FREEZE_DATE => r_ENP.INFORMATION310
17227 ,p_SAL_CHG_REASON_CD => r_ENP.INFORMATION23
17228 ,p_APPROVAL_MODE_CD => r_ENP.INFORMATION24
17229 ,p_HRCHY_AME_TRN_CD => r_ENP.INFORMATION25
17230 ,p_HRCHY_RL => l_HRCHY_RL
17231 ,p_HRCHY_AME_APP_ID => r_ENP.INFORMATION268
17232 --
17233 --
17234 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
17235 );
17236 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
17237 -- Update all relevent cer records with new pk_id
17238 hr_utility.set_location('Before plsql table ',222);
17239 hr_utility.set_location('new_value id '||l_enrt_perd_id,222);
17240 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ENRT_PERD_ID' ;
17241 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ENP.information1 ;
17242 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_ENRT_PERD_ID ;
17243 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
17244 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;
17245 hr_utility.set_location('After plsql table ',222);
17246 --
17247 -- 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 ) ;
17248 --
17249 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17250 --
17251 elsif l_update then
17252 BEN_ENROLLMENT_PERIOD_API.UPDATE_ENROLLMENT_PERIOD(
17253 --
17254 P_VALIDATE => false
17255 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
17256 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
17257 --
17258 ,P_ASG_UPDT_EFF_DATE => r_ENP.INFORMATION306
17259 ,P_ASND_LF_EVT_DT => r_ENP.INFORMATION316
17260 ,P_AUTO_DISTR_FLAG => r_ENP.INFORMATION11
17261 ,P_BDGT_UPD_END_DT => r_ENP.INFORMATION308
17262 ,P_BDGT_UPD_STRT_DT => r_ENP.INFORMATION309
17263 ,P_CLS_ENRT_DT_TO_USE_CD => r_ENP.INFORMATION16
17264 ,P_DFLT_ENRT_DT => r_ENP.INFORMATION312
17265 ,P_DFLT_WS_ACC_CD => r_ENP.INFORMATION12
17266 ,P_EMP_INTERVIEW_TYPE_CD => r_ENP.INFORMATION13
17267 ,P_END_DT => r_ENP.INFORMATION317
17268 ,P_ENP_ATTRIBUTE1 => r_ENP.INFORMATION111
17269 ,P_ENP_ATTRIBUTE10 => r_ENP.INFORMATION120
17270 ,P_ENP_ATTRIBUTE11 => r_ENP.INFORMATION121
17271 ,P_ENP_ATTRIBUTE12 => r_ENP.INFORMATION122
17272 ,P_ENP_ATTRIBUTE13 => r_ENP.INFORMATION123
17273 ,P_ENP_ATTRIBUTE14 => r_ENP.INFORMATION124
17274 ,P_ENP_ATTRIBUTE15 => r_ENP.INFORMATION125
17275 ,P_ENP_ATTRIBUTE16 => r_ENP.INFORMATION126
17276 ,P_ENP_ATTRIBUTE17 => r_ENP.INFORMATION127
17277 ,P_ENP_ATTRIBUTE18 => r_ENP.INFORMATION128
17278 ,P_ENP_ATTRIBUTE19 => r_ENP.INFORMATION129
17279 ,P_ENP_ATTRIBUTE2 => r_ENP.INFORMATION112
17280 ,P_ENP_ATTRIBUTE20 => r_ENP.INFORMATION130
17281 ,P_ENP_ATTRIBUTE21 => r_ENP.INFORMATION131
17282 ,P_ENP_ATTRIBUTE22 => r_ENP.INFORMATION132
17283 ,P_ENP_ATTRIBUTE23 => r_ENP.INFORMATION133
17284 ,P_ENP_ATTRIBUTE24 => r_ENP.INFORMATION134
17285 ,P_ENP_ATTRIBUTE25 => r_ENP.INFORMATION135
17286 ,P_ENP_ATTRIBUTE26 => r_ENP.INFORMATION136
17287 ,P_ENP_ATTRIBUTE27 => r_ENP.INFORMATION137
17288 ,P_ENP_ATTRIBUTE28 => r_ENP.INFORMATION138
17289 ,P_ENP_ATTRIBUTE29 => r_ENP.INFORMATION139
17290 ,P_ENP_ATTRIBUTE3 => r_ENP.INFORMATION113
17291 ,P_ENP_ATTRIBUTE30 => r_ENP.INFORMATION140
17292 ,P_ENP_ATTRIBUTE4 => r_ENP.INFORMATION114
17293 ,P_ENP_ATTRIBUTE5 => r_ENP.INFORMATION115
17294 ,P_ENP_ATTRIBUTE6 => r_ENP.INFORMATION116
17295 ,P_ENP_ATTRIBUTE7 => r_ENP.INFORMATION117
17296 ,P_ENP_ATTRIBUTE8 => r_ENP.INFORMATION118
17297 ,P_ENP_ATTRIBUTE9 => r_ENP.INFORMATION119
17298 ,P_ENP_ATTRIBUTE_CATEGORY => r_ENP.INFORMATION110
17299 -- Added two cols reinstate_cd,reinstate_ovrdn_cd
17300 --
17301 -- Bug No 4440058 Updated the information columns from 19
17302 -- and 20 to 26 and 27
17303 ,P_REINSTATE_CD => r_ENP.INFORMATION26
17304 ,P_REINSTATE_OVRDN_CD => r_ENP.INFORMATION27
17305 -- End Bug 4440058
17306 ,P_ENRT_CVG_END_DT_CD => r_ENP.INFORMATION18
17307 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
17308 ,P_ENRT_CVG_STRT_DT_CD => r_ENP.INFORMATION17
17309 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
17310 ,P_ENRT_PERD_DET_OVRLP_BCKDT_CD => r_ENP.INFORMATION22
17311 ,P_ENRT_PERD_ID => l_enrt_perd_id
17312 ,P_HRCHY_TO_USE_CD => r_ENP.INFORMATION14
17313 ,P_LER_ID => l_LER_ID
17314 ,P_PERF_REVW_STRT_DT => r_ENP.INFORMATION307
17315 ,P_POPL_ENRT_TYP_CYCL_ID => l_POPL_ENRT_TYP_CYCL_ID
17316 ,P_POS_STRUCTURE_VERSION_ID => l_POS_STRUCTURE_VERSION_ID
17317 ,P_PROCG_END_DT => r_ENP.INFORMATION315
17318 ,P_PRSVR_BDGT_CD => r_ENP.INFORMATION15
17319 ,P_RT_END_DT_CD => r_ENP.INFORMATION20
17320 ,P_RT_END_DT_RL => l_RT_END_DT_RL
17321 ,P_RT_STRT_DT_CD => r_ENP.INFORMATION19
17322 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
17323 ,P_STRT_DT => r_ENP.INFORMATION318
17324 ,P_USES_BDGT_FLAG => r_ENP.INFORMATION21
17325 ,P_WS_UPD_END_DT => r_ENP.INFORMATION319
17326 ,P_WS_UPD_STRT_DT => r_ENP.INFORMATION320
17327 ,P_WTHN_YR_PERD_ID => l_WTHN_YR_PERD_ID
17328 ,P_YR_PERD_ID => l_YR_PERD_ID
17329 --cwbglobal
17330 -- cwb tilak
17331 ,p_DATA_FREEZE_DATE => r_ENP.INFORMATION310
17332 ,p_SAL_CHG_REASON_CD => r_ENP.INFORMATION23
17333 ,p_APPROVAL_MODE_CD => r_ENP.INFORMATION24
17334 ,p_HRCHY_AME_TRN_CD => r_ENP.INFORMATION25
17335 ,p_HRCHY_RL => l_HRCHY_RL
17336 ,p_HRCHY_AME_APP_ID => r_ENP.INFORMATION268
17337 --
17338 --
17339 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
17340 );
17341 end if;
17342 --
17343 l_prev_pk_id := l_current_pk_id ;
17344 --
17345 end if;
17346 --
17347 end if;
17348 --
17349 end loop;
17350 --
17351 exception when others then
17352 --
17353 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ENP',r_enp.information5 );
17354 --
17355 end create_ENP_rows;
17356
17357 --
17358 ---------------------------------------------------------------
17359 ----------------------< create_LEN_rows >-----------------------
17360 ---------------------------------------------------------------
17361 --
17362 procedure create_LEN_rows
17363 (
17364 p_validate in number default 0
17365 ,p_copy_entity_txn_id in number
17366 ,p_effective_date in date
17367 ,p_prefix_suffix_text in varchar2 default null
17368 ,p_reuse_object_flag in varchar2 default null
17369 ,p_target_business_group_id in varchar2 default null
17370 ,p_prefix_suffix_cd in varchar2 default null
17371 ) is
17372 --
17373 l_ENRT_CVG_END_DT_RL number;
17374 l_ENRT_CVG_STRT_DT_RL number;
17375 l_ENRT_PERD_END_DT_RL number;
17376 l_ENRT_PERD_STRT_DT_RL number;
17377 l_LER_ID number;
17378 l_POPL_ENRT_TYP_CYCL_ID number;
17379 l_RT_END_DT_RL number;
17380 l_RT_STRT_DT_RL number;
17381 cursor c_unique_LEN(l_table_alias varchar2) is
17382 select distinct cpe.information1,
17383 cpe.information2,
17384 cpe.information3,
17385 cpe.table_route_id
17386 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
17387 pqh_table_route tr
17388 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17389 and cpe.table_route_id = tr.table_route_id
17390 -- and tr.where_clause = l_BEN_LEE_RSN_F
17391 and tr.table_alias = l_table_alias
17392 and cpe.number_of_copies = 1 -- ADDITION
17393 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
17394 order by information1, information2; --added for bug: 5151945
17395 --
17396 --
17397 cursor c_LEN_min_max_dates(c_table_route_id number,
17398 c_information1 number) is
17399 select
17400 min(cpe.information2) min_esd,
17401 max(cpe.information3) min_eed
17402 from ben_copy_entity_results cpe
17403 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17404 and cpe.table_route_id = c_table_route_id
17405 and cpe.information1 = c_information1 ;
17406 --
17407 cursor c_LEN(c_table_route_id number,
17408 c_information1 number,
17409 c_information2 date,
17410 c_information3 date) is
17411 select
17412 cpe.*
17413 from ben_copy_entity_results cpe
17414 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17415 and cpe.table_route_id = c_table_route_id
17416 and cpe.information1 = c_information1
17417 and cpe.information2 = c_information2
17418 and cpe.information3 = c_information3
17419 and rownum = 1 ;
17420 -- Date Track target record
17421 cursor c_find_LEN_in_target(
17422 c_effective_start_date date,
17423 c_effective_end_date date,
17424 c_business_group_id number,
17425 c_new_pk_id number) is
17426 select
17427 LEN.lee_rsn_id new_value
17428 from BEN_LEE_RSN_F LEN
17429 where
17430 nvl(LEN.LER_ID,-999) = nvl(l_LER_ID,-999) and
17431 nvl(LEN.POPL_ENRT_TYP_CYCL_ID,-999) = nvl(l_POPL_ENRT_TYP_CYCL_ID,-999) and
17432 LEN.business_group_id = c_business_group_id
17433 and LEN.lee_rsn_id <> c_new_pk_id
17434 --TEMPIK
17435 and c_effective_start_date between effective_start_date
17436 and effective_end_date ;
17437 --END TEMPIK
17438 /*TEMPIK
17439 and exists ( select null
17440 from BEN_LEE_RSN_F LEN1
17441 where
17442 nvl(LEN1.LER_ID,-999) = l_LER_ID and
17443 nvl(LEN1.POPL_ENRT_TYP_CYCL_ID,-999) = nvl(l_POPL_ENRT_TYP_CYCL_ID , -999) and
17444 LEN1.business_group_id = c_business_group_id
17445 and LEN1.effective_start_date <= c_effective_start_date )
17446 and exists ( select null
17447 from BEN_LEE_RSN_F LEN2
17448 where
17449 nvl(LEN2.LER_ID,-999) = l_LER_ID and
17450 nvl(LEN2.POPL_ENRT_TYP_CYCL_ID,-999) = nvl(l_POPL_ENRT_TYP_CYCL_ID , -999) and
17451 LEN2.business_group_id = c_business_group_id
17452 and LEN2.effective_end_date >= c_effective_end_date )
17453 ;
17454 */
17455 --
17456 --UPD START
17457 --
17458 l_update boolean := false ;
17459 l_datetrack_mode varchar2(80) := hr_api.g_update;
17460 l_process_date date;
17461 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
17462 --
17463 --UPD END
17464 l_current_pk_id number := null ;
17465 l_prev_pk_id number := null ;
17466 l_first_rec boolean := true ;
17467 r_LEN c_LEN%rowtype;
17468 l_lee_rsn_id number ;
17469 l_object_version_number number ;
17470 l_effective_start_date date ;
17471 l_effective_end_date date ;
17472 l_prefix pqh_copy_entity_attribs.information1%type := null;
17473 l_suffix pqh_copy_entity_attribs.information1%type := null;
17474 l_new_value number(15);
17475 l_object_found_in_target boolean := false ;
17476 l_min_esd date;
17477 l_max_eed date;
17478 l_effective_date date;
17479 --TEMPIK
17480 l_dt_rec_found boolean ;
17481 --END TEMPIK
17482 --
17483 begin
17484 -- Initialization
17485 l_object_found_in_target := false ;
17486 -- End Initialization
17487 -- Derive the prefix - sufix
17488 if p_prefix_suffix_cd = 'PREFIX' then
17489 l_prefix := p_prefix_suffix_text ;
17490 elsif p_prefix_suffix_cd = 'SUFFIX' then
17491 l_suffix := p_prefix_suffix_text ;
17492 else
17493 l_prefix := null ;
17494 l_suffix := null ;
17495 end if ;
17496 -- End Prefix Sufix derivation
17497 for r_LEN_unique in c_unique_LEN('LEN') loop
17498
17499 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
17500 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17501 r_LEN_unique.information3 >=
17502 ben_pd_copy_to_ben_one.g_copy_effective_date)
17503 ) then
17504 --
17505 hr_utility.set_location(' r_LEN_unique.table_route_id '||r_LEN_unique.table_route_id,10);
17506 hr_utility.set_location(' r_LEN_unique.information1 '||r_LEN_unique.information1,10);
17507 hr_utility.set_location( 'r_LEN_unique.information2 '||r_LEN_unique.information2,10);
17508 hr_utility.set_location( 'r_LEN_unique.information3 '||r_LEN_unique.information3,10);
17509 -- If reuse objects flag is 'Y' then check for the object in the target business group
17510 -- if found insert the record into PLSql table and exit the loop else try create the
17511 -- object in the target business group
17512 --
17513 l_object_found_in_target := false ;
17514 --UPD START
17515 open c_LEN(r_LEN_unique.table_route_id,
17516 r_LEN_unique.information1,
17517 r_LEN_unique.information2,
17518 r_LEN_unique.information3 ) ;
17519 --
17520 fetch c_LEN into r_LEN ;
17521 --
17522 close c_LEN ;
17523 l_dml_operation:= r_LEN_unique.dml_operation ;
17524 l_ENRT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_LEN.INFORMATION266,l_dml_operation);
17525 l_ENRT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_LEN.INFORMATION267,l_dml_operation);
17526 l_ENRT_PERD_END_DT_RL := get_fk('FORMULA_ID', r_LEN.INFORMATION268,l_dml_operation);
17527 l_ENRT_PERD_STRT_DT_RL := get_fk('FORMULA_ID', r_LEN.INFORMATION259,l_dml_operation);
17528 l_LER_ID := get_fk('LER_ID', r_LEN.INFORMATION257,l_dml_operation);
17529 l_POPL_ENRT_TYP_CYCL_ID := get_fk('POPL_ENRT_TYP_CYCL_ID', r_LEN.INFORMATION232,l_dml_operation);
17530 l_RT_END_DT_RL := get_fk('FORMULA_ID', r_LEN.INFORMATION263,l_dml_operation);
17531 l_RT_STRT_DT_RL := get_fk('FORMULA_ID', r_LEN.INFORMATION264,l_dml_operation);
17532 l_update := false;
17533 l_process_date := p_effective_date;
17534 --
17535 if l_dml_operation = 'UPDATE' then
17536 --
17537 l_object_found_in_target := TRUE;
17538 --
17539 if l_process_date between r_LEN_unique.information2 and r_LEN_unique.information3 then
17540 l_update := true;
17541 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)
17542 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'
17543 then
17544 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LEE_RSN_ID' ;
17545 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LEN_unique.information1 ;
17546 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LEN_unique.information1 ;
17547 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
17548 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;
17549 --
17550 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
17551 --
17552 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17553 --
17554 --DOUBT log_data('LEN',l_new_value,l_prefix || r_LEN_unique.name|| l_suffix,'REUSED');
17555 --
17556 end if ;
17557 hr_utility.set_location( 'found record for update',10);
17558 --
17559 else
17560 --
17561 l_update := false;
17562 --
17563 end if;
17564 else
17565 --
17566 --UPD END
17567 l_min_esd := null ;
17568 l_max_eed := null ;
17569 open c_LEN_min_max_dates(r_LEN_unique.table_route_id, r_LEN_unique.information1 ) ;
17570 fetch c_LEN_min_max_dates into l_min_esd,l_max_eed ;
17571 --
17572
17573 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17574 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
17575 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
17576 end if;
17577 l_min_esd := greatest(l_min_esd,r_LEN_unique.information2);
17578 /* open c_LEN(r_LEN_unique.table_route_id,
17579 r_LEN_unique.information1,
17580 r_LEN_unique.information2,
17581 r_LEN_unique.information3 ) ;
17582 --
17583 fetch c_LEN into r_LEN ;
17584 --
17585 close c_LEN ; */
17586 --
17587
17588 if p_reuse_object_flag = 'Y' then
17589 if c_LEN_min_max_dates%found then
17590 -- cursor to find the object
17591 open c_find_LEN_in_target( l_min_esd,l_max_eed,
17592 p_target_business_group_id, nvl(l_lee_rsn_id, -999) ) ;
17593 fetch c_find_LEN_in_target into l_new_value ;
17594 if c_find_LEN_in_target%found then
17595 --
17596 --TEMPIK
17597 l_dt_rec_found := dt_api.check_min_max_dates
17598 (p_base_table_name => 'BEN_LEE_RSN_F',
17599 p_base_key_column => 'LEE_RSN_ID',
17600 p_base_key_value => l_new_value,
17601 p_from_date => l_min_esd,
17602 p_to_date => l_max_eed );
17603 if l_dt_rec_found THEN
17604 --END TEMPIK
17605 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
17606 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
17607 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LEE_RSN_ID' ;
17608 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LEN_unique.information1 ;
17609 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
17610 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
17611 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;
17612 --
17613 -- 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) ;
17614 --
17615 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17616 end if ;
17617 --
17618 l_object_found_in_target := true ;
17619 --TEMPIK
17620 end if; -- l_dt_rec_found
17621 --END TEMPIK
17622 end if;
17623 close c_find_LEN_in_target ;
17624 --
17625 end if;
17626 end if ;
17627 --
17628 close c_LEN_min_max_dates ;
17629 end if; --if p_dml_operation
17630 --
17631 if not l_object_found_in_target OR l_update then
17632 --
17633 l_current_pk_id := r_LEN.information1;
17634 --
17635 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
17636 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
17637 --
17638 if l_current_pk_id = l_prev_pk_id then
17639 --
17640 l_first_rec := false ;
17641 --
17642 else
17643 --
17644 l_first_rec := true ;
17645 --
17646 end if ;
17647 --
17648
17649 l_effective_date := r_LEN.information2;
17650 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
17651 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
17652 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
17653 end if;
17654
17655 if l_first_rec and not l_update then
17656 -- Call Create routine.
17657 hr_utility.set_location(' BEN_LEE_RSN_F CREATE_LIFE_EVENT_ENROLL_RSN ',20);
17658 BEN_LIFE_EVENT_ENROLL_RSN_API.CREATE_LIFE_EVENT_ENROLL_RSN(
17659 --
17660 P_VALIDATE => false
17661 ,P_EFFECTIVE_DATE => l_effective_date
17662 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
17663 --
17664 ,P_ADDL_PROCG_DYS_NUM => r_LEN.INFORMATION260
17665 ,P_CLS_ENRT_DT_TO_USE_CD => r_LEN.INFORMATION11
17666 ,P_DYS_AFTR_END_TO_DFLT_NUM => r_LEN.INFORMATION258
17667 ,P_DYS_NO_ENRL_CANT_ENRL_NUM => r_LEN.INFORMATION262
17668 ,P_DYS_NO_ENRL_NOT_ELIG_NUM => r_LEN.INFORMATION261
17669 ,P_ENRT_CVG_END_DT_CD => r_LEN.INFORMATION12
17670 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
17671 ,P_ENRT_CVG_STRT_DT_CD => r_LEN.INFORMATION13
17672 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
17673 ,P_ENRT_PERD_DET_OVRLP_BCKDT_CD => r_LEN.INFORMATION18
17674 ,P_ENRT_PERD_END_DT_CD => r_LEN.INFORMATION15
17675 ,P_ENRT_PERD_END_DT_RL => l_ENRT_PERD_END_DT_RL
17676 ,P_ENRT_PERD_STRT_DT_CD => r_LEN.INFORMATION14
17677 ,P_ENRT_PERD_STRT_DT_RL => l_ENRT_PERD_STRT_DT_RL
17678 ,P_LEE_RSN_ID => l_lee_rsn_id
17679 ,P_LEN_ATTRIBUTE1 => r_LEN.INFORMATION111
17680 ,P_LEN_ATTRIBUTE10 => r_LEN.INFORMATION120
17681 ,P_LEN_ATTRIBUTE11 => r_LEN.INFORMATION121
17682 ,P_LEN_ATTRIBUTE12 => r_LEN.INFORMATION122
17683 ,P_LEN_ATTRIBUTE13 => r_LEN.INFORMATION123
17684 ,P_LEN_ATTRIBUTE14 => r_LEN.INFORMATION124
17685 ,P_LEN_ATTRIBUTE15 => r_LEN.INFORMATION125
17686 ,P_LEN_ATTRIBUTE16 => r_LEN.INFORMATION126
17687 ,P_LEN_ATTRIBUTE17 => r_LEN.INFORMATION127
17688 ,P_LEN_ATTRIBUTE18 => r_LEN.INFORMATION128
17689 ,P_LEN_ATTRIBUTE19 => r_LEN.INFORMATION129
17690 ,P_LEN_ATTRIBUTE2 => r_LEN.INFORMATION112
17691 ,P_LEN_ATTRIBUTE20 => r_LEN.INFORMATION130
17692 ,P_LEN_ATTRIBUTE21 => r_LEN.INFORMATION131
17693 ,P_LEN_ATTRIBUTE22 => r_LEN.INFORMATION132
17694 ,P_LEN_ATTRIBUTE23 => r_LEN.INFORMATION133
17695 ,P_LEN_ATTRIBUTE24 => r_LEN.INFORMATION134
17696 ,P_LEN_ATTRIBUTE25 => r_LEN.INFORMATION135
17697 ,P_LEN_ATTRIBUTE26 => r_LEN.INFORMATION136
17698 ,P_LEN_ATTRIBUTE27 => r_LEN.INFORMATION137
17699 ,P_LEN_ATTRIBUTE28 => r_LEN.INFORMATION138
17700 ,P_LEN_ATTRIBUTE29 => r_LEN.INFORMATION139
17701 ,P_LEN_ATTRIBUTE3 => r_LEN.INFORMATION113
17702 ,P_LEN_ATTRIBUTE30 => r_LEN.INFORMATION140
17703 ,P_LEN_ATTRIBUTE4 => r_LEN.INFORMATION114
17704 ,P_LEN_ATTRIBUTE5 => r_LEN.INFORMATION115
17705 ,P_LEN_ATTRIBUTE6 => r_LEN.INFORMATION116
17706 ,P_LEN_ATTRIBUTE7 => r_LEN.INFORMATION117
17707 ,P_LEN_ATTRIBUTE8 => r_LEN.INFORMATION118
17708 ,P_LEN_ATTRIBUTE9 => r_LEN.INFORMATION119
17709 ,P_LEN_ATTRIBUTE_CATEGORY => r_LEN.INFORMATION110
17710 --Added two cols reinstate_cd,reinstate_ovrdn_cd
17711 ,P_REINSTATE_CD => r_LEN.INFORMATION19
17712 ,P_REINSTATE_OVRDN_CD => r_LEN.INFORMATION20
17713 ,P_ENRT_PERD_STRT_DAYS => r_LEN.INFORMATION271
17714 ,P_ENRT_PERD_END_DAYS => r_LEN.INFORMATION272
17715 --
17716 ,P_LER_ID => l_LER_ID
17717 ,P_POPL_ENRT_TYP_CYCL_ID => l_POPL_ENRT_TYP_CYCL_ID
17718 ,P_RT_END_DT_CD => r_LEN.INFORMATION16
17719 ,P_RT_END_DT_RL => l_RT_END_DT_RL
17720 ,P_RT_STRT_DT_CD => r_LEN.INFORMATION17
17721 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
17722 --
17723 ,P_EFFECTIVE_START_DATE => l_effective_start_date
17724 ,P_EFFECTIVE_END_DATE => l_effective_end_date
17725 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
17726 );
17727 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
17728 -- Update all relevent cer records with new pk_id
17729 hr_utility.set_location('Before plsql table ',222);
17730 hr_utility.set_location('new_value id '||l_lee_rsn_id,222);
17731 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LEE_RSN_ID' ;
17732 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LEN.information1 ;
17733 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LEE_RSN_ID ;
17734 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
17735 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;
17736 hr_utility.set_location('After plsql table ',222);
17737 --
17738 -- 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 ) ;
17739 --
17740 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
17741 --
17742 else
17743 --
17744 -- Call Update routine for the pk_id created in prev run .
17745 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
17746 hr_utility.set_location(' BEN_LEE_RSN_F UPDATE_LIFE_EVENT_ENROLL_RSN ',30);
17747 --UPD START
17748 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
17749 --
17750 if l_update then
17751 --
17752 l_datetrack_mode := r_LEN.datetrack_mode ;
17753 --
17754 get_dt_modes(
17755 p_effective_date => l_process_date,
17756 p_effective_end_date => r_LEN.information3,
17757 p_effective_start_date => r_LEN.information2,
17758 p_dml_operation => r_LEN.dml_operation,
17759 p_datetrack_mode => l_datetrack_mode );
17760 -- p_update => l_update
17761 --
17762 l_effective_date := l_process_date;
17763 l_LEE_RSN_ID := r_LEN.information1;
17764 l_object_version_number := r_LEN.information265;
17765 --
17766 end if;
17767 --
17768 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
17769 --
17770 IF l_update OR l_dml_operation <> 'UPDATE' THEN
17771 --UPD END
17772 BEN_LIFE_EVENT_ENROLL_RSN_API.UPDATE_LIFE_EVENT_ENROLL_RSN(
17773 --
17774 P_VALIDATE => false
17775 ,P_EFFECTIVE_DATE => l_effective_date
17776 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
17777 --
17778 ,P_ADDL_PROCG_DYS_NUM => r_LEN.INFORMATION260
17779 ,P_CLS_ENRT_DT_TO_USE_CD => r_LEN.INFORMATION11
17780 ,P_DYS_AFTR_END_TO_DFLT_NUM => r_LEN.INFORMATION258
17781 ,P_DYS_NO_ENRL_CANT_ENRL_NUM => r_LEN.INFORMATION262
17782 ,P_DYS_NO_ENRL_NOT_ELIG_NUM => r_LEN.INFORMATION261
17783 ,P_ENRT_CVG_END_DT_CD => r_LEN.INFORMATION12
17784 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
17785 ,P_ENRT_CVG_STRT_DT_CD => r_LEN.INFORMATION13
17786 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
17787 ,P_ENRT_PERD_DET_OVRLP_BCKDT_CD => r_LEN.INFORMATION18
17788 ,P_ENRT_PERD_END_DT_CD => r_LEN.INFORMATION15
17789 ,P_ENRT_PERD_END_DT_RL => l_ENRT_PERD_END_DT_RL
17790 ,P_ENRT_PERD_STRT_DT_CD => r_LEN.INFORMATION14
17791 ,P_ENRT_PERD_STRT_DT_RL => l_ENRT_PERD_STRT_DT_RL
17792 ,P_LEE_RSN_ID => l_lee_rsn_id
17793 ,P_LEN_ATTRIBUTE1 => r_LEN.INFORMATION111
17794 ,P_LEN_ATTRIBUTE10 => r_LEN.INFORMATION120
17795 ,P_LEN_ATTRIBUTE11 => r_LEN.INFORMATION121
17796 ,P_LEN_ATTRIBUTE12 => r_LEN.INFORMATION122
17797 ,P_LEN_ATTRIBUTE13 => r_LEN.INFORMATION123
17798 ,P_LEN_ATTRIBUTE14 => r_LEN.INFORMATION124
17799 ,P_LEN_ATTRIBUTE15 => r_LEN.INFORMATION125
17800 ,P_LEN_ATTRIBUTE16 => r_LEN.INFORMATION126
17801 ,P_LEN_ATTRIBUTE17 => r_LEN.INFORMATION127
17802 ,P_LEN_ATTRIBUTE18 => r_LEN.INFORMATION128
17803 ,P_LEN_ATTRIBUTE19 => r_LEN.INFORMATION129
17804 ,P_LEN_ATTRIBUTE2 => r_LEN.INFORMATION112
17805 ,P_LEN_ATTRIBUTE20 => r_LEN.INFORMATION130
17806 ,P_LEN_ATTRIBUTE21 => r_LEN.INFORMATION131
17807 ,P_LEN_ATTRIBUTE22 => r_LEN.INFORMATION132
17808 ,P_LEN_ATTRIBUTE23 => r_LEN.INFORMATION133
17809 ,P_LEN_ATTRIBUTE24 => r_LEN.INFORMATION134
17810 ,P_LEN_ATTRIBUTE25 => r_LEN.INFORMATION135
17811 ,P_LEN_ATTRIBUTE26 => r_LEN.INFORMATION136
17812 ,P_LEN_ATTRIBUTE27 => r_LEN.INFORMATION137
17813 ,P_LEN_ATTRIBUTE28 => r_LEN.INFORMATION138
17814 ,P_LEN_ATTRIBUTE29 => r_LEN.INFORMATION139
17815 ,P_LEN_ATTRIBUTE3 => r_LEN.INFORMATION113
17816 ,P_LEN_ATTRIBUTE30 => r_LEN.INFORMATION140
17817 ,P_LEN_ATTRIBUTE4 => r_LEN.INFORMATION114
17818 ,P_LEN_ATTRIBUTE5 => r_LEN.INFORMATION115
17819 ,P_LEN_ATTRIBUTE6 => r_LEN.INFORMATION116
17820 ,P_LEN_ATTRIBUTE7 => r_LEN.INFORMATION117
17821 ,P_LEN_ATTRIBUTE8 => r_LEN.INFORMATION118
17822 ,P_LEN_ATTRIBUTE9 => r_LEN.INFORMATION119
17823 ,P_LEN_ATTRIBUTE_CATEGORY => r_LEN.INFORMATION110
17824 --Added two cols reinstate_cd,reinstate_ovrdn_cd
17825 ,P_REINSTATE_CD => r_LEN.INFORMATION19
17826 ,P_REINSTATE_OVRDN_CD => r_LEN.INFORMATION20
17827 --
17828 ,P_LER_ID => l_LER_ID
17829 ,P_POPL_ENRT_TYP_CYCL_ID => l_POPL_ENRT_TYP_CYCL_ID
17830 ,P_RT_END_DT_CD => r_LEN.INFORMATION16
17831 ,P_RT_END_DT_RL => l_RT_END_DT_RL
17832 ,P_RT_STRT_DT_CD => r_LEN.INFORMATION17
17833 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
17834 --
17835 ,P_EFFECTIVE_START_DATE => l_effective_start_date
17836 ,P_EFFECTIVE_END_DATE => l_effective_end_date
17837 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
17838 ,P_DATETRACK_MODE => l_datetrack_mode
17839 );
17840 --
17841 end if; -- l_update
17842 end if;
17843 --
17844 -- Delete the row if it is end dated.
17845 --
17846 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
17847 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
17848 trunc(l_max_eed) = r_LEN.information3) then
17849 --
17850 BEN_LIFE_EVENT_ENROLL_RSN_API.delete_LIFE_EVENT_ENROLL_RSN(
17851 --
17852 p_validate => false
17853 ,p_lee_rsn_id => l_lee_rsn_id
17854 ,p_effective_start_date => l_effective_start_date
17855 ,p_effective_end_date => l_effective_end_date
17856 ,p_object_version_number => l_object_version_number
17857 ,p_effective_date => l_max_eed
17858 ,p_datetrack_mode => hr_api.g_delete
17859 --
17860 );
17861 --
17862 end if;
17863 --
17864 l_prev_pk_id := l_current_pk_id ;
17865 --
17866 end if;
17867 --
17868 end if;
17869 --
17870 end loop;
17871 --
17872 exception when others then
17873 --
17874 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LEN',r_len.information5 );
17875 --
17876 end create_LEN_rows;
17877
17878 --
17879 ---------------------------------------------------------------
17880 ----------------------< create_ERP_rows >-----------------------
17881 ---------------------------------------------------------------
17882 --
17883 procedure create_ERP_rows
17884 (
17885 p_validate in number default 0
17886 ,p_copy_entity_txn_id in number
17887 ,p_effective_date in date
17888 ,p_prefix_suffix_text in varchar2 default null
17889 ,p_reuse_object_flag in varchar2 default null
17890 ,p_target_business_group_id in varchar2 default null
17891 ,p_prefix_suffix_cd in varchar2 default null
17892 ) is
17893 --
17894 l_ENRT_CVG_END_DT_RL number;
17895 l_ENRT_CVG_STRT_DT_RL number;
17896 l_ENRT_PERD_ID number;
17897 l_LEE_RSN_ID number;
17898 l_PL_ID number;
17899 l_RT_END_DT_RL number;
17900 l_RT_STRT_DT_RL number;
17901 cursor c_unique_ERP(l_table_alias varchar2) is
17902 select distinct cpe.information1,
17903 cpe.information2,
17904 cpe.information3,
17905 cpe.table_route_id
17906 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
17907 pqh_table_route tr
17908 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17909 and cpe.table_route_id = tr.table_route_id
17910 -- and tr.where_clause = l_BEN_ENRT_PERD_FOR_PL_F
17911 and tr.table_alias = l_table_alias
17912 and cpe.number_of_copies = 1 -- ADDITION
17913 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
17914 order by information1, information2; --added for bug: 5151945
17915 --
17916 --
17917 cursor c_ERP_min_max_dates(c_table_route_id number,
17918 c_information1 number) is
17919 select
17920 min(cpe.information2) min_esd,
17921 max(cpe.information3) min_eed
17922 from ben_copy_entity_results cpe
17923 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17924 and cpe.table_route_id = c_table_route_id
17925 and cpe.information1 = c_information1 ;
17926 --
17927 cursor c_ERP(c_table_route_id number,
17928 c_information1 number,
17929 c_information2 date,
17930 c_information3 date) is
17931 select
17932 cpe.*
17933 from ben_copy_entity_results cpe
17934 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
17935 and cpe.table_route_id = c_table_route_id
17936 and cpe.information1 = c_information1
17937 and cpe.information2 = c_information2
17938 and cpe.information3 = c_information3
17939 and rownum = 1 ;
17940 -- Date Track target record
17941 -- 9999 do we need to check any other data.
17942 cursor c_find_ERP_in_target(
17943 c_effective_start_date date,
17944 c_effective_end_date date,
17945 c_business_group_id number,
17946 c_new_pk_id number) is
17947 select
17948 ERP.enrt_perd_for_pl_id new_value
17949 from BEN_ENRT_PERD_FOR_PL_F ERP
17950 where
17951 nvl(ERP.ENRT_PERD_ID,-999) = nvl(l_ENRT_PERD_ID,-999) and
17952 nvl(ERP.LEE_RSN_ID,-999) = nvl(l_LEE_RSN_ID,-999) and
17953 nvl(ERP.PL_ID,-999) = nvl(l_PL_ID,-999) and
17954 ERP.business_group_id = c_business_group_id
17955 and ERP.enrt_perd_for_pl_id <> c_new_pk_id
17956 --TEMPIK
17957 and c_effective_start_date between effective_start_date
17958 and effective_end_date ;
17959 --END TEMPIK
17960 /*TEMPIK
17961
17962 and exists ( select null
17963 from BEN_ENRT_PERD_FOR_PL_F ERP1
17964 where
17965 nvl(ERP1.ENRT_PERD_ID,-999) = nvl(l_ENRT_PERD_ID, -999) and
17966 nvl(ERP1.LEE_RSN_ID,-999) = nvl(l_LEE_RSN_ID, -999) and
17967 nvl(ERP1.PL_ID,-999) = nvl(l_PL_ID, -999) and
17968 ERP1.business_group_id = c_business_group_id
17969 and ERP1.effective_start_date <= c_effective_start_date )
17970 and exists ( select null
17971 from BEN_ENRT_PERD_FOR_PL_F ERP2
17972 where
17973 nvl(ERP2.ENRT_PERD_ID,-999) = nvl(l_ENRT_PERD_ID, -999) and
17974 nvl(ERP2.LEE_RSN_ID,-999) = nvl(l_LEE_RSN_ID, -999) and
17975 nvl(ERP2.PL_ID,-999) = nvl(l_PL_ID, -999) and
17976 ERP2.business_group_id = c_business_group_id
17977 and ERP2.effective_end_date >= c_effective_end_date )
17978 ;
17979 */
17980 --
17981 --UPD START
17982 --
17983 l_update boolean := false ;
17984 l_datetrack_mode varchar2(80) := hr_api.g_update;
17985 l_process_date date;
17986 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
17987 --
17988 --UPD END
17989 l_current_pk_id number := null ;
17990 l_prev_pk_id number := null ;
17991 l_first_rec boolean := true ;
17992 r_ERP c_ERP%rowtype;
17993 l_enrt_perd_for_pl_id number ;
17994 l_object_version_number number ;
17995 l_effective_start_date date ;
17996 l_effective_end_date date ;
17997 l_prefix pqh_copy_entity_attribs.information1%type := null;
17998 l_suffix pqh_copy_entity_attribs.information1%type := null;
17999 l_new_value number(15);
18000 l_object_found_in_target boolean := false ;
18001 l_min_esd date;
18002 l_max_eed date;
18003 l_effective_date date;
18004 --TEMPIK
18005 l_dt_rec_found boolean ;
18006 --END TEMPIK
18007 --
18008 begin
18009 -- Initialization
18010 l_object_found_in_target := false ;
18011 -- End Initialization
18012 -- Derive the prefix - sufix
18013 if p_prefix_suffix_cd = 'PREFIX' then
18014 l_prefix := p_prefix_suffix_text ;
18015 elsif p_prefix_suffix_cd = 'SUFFIX' then
18016 l_suffix := p_prefix_suffix_text ;
18017 else
18018 l_prefix := null ;
18019 l_suffix := null ;
18020 end if ;
18021 -- End Prefix Sufix derivation
18022 for r_ERP_unique in c_unique_ERP('ERP') loop
18023
18024 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
18025 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18026 r_ERP_unique.information3 >=
18027 ben_pd_copy_to_ben_one.g_copy_effective_date)
18028 ) then
18029 --
18030 hr_utility.set_location(' r_ERP_unique.table_route_id '||r_ERP_unique.table_route_id,10);
18031 hr_utility.set_location(' r_ERP_unique.information1 '||r_ERP_unique.information1,10);
18032 hr_utility.set_location( 'r_ERP_unique.information2 '||r_ERP_unique.information2,10);
18033 hr_utility.set_location( 'r_ERP_unique.information3 '||r_ERP_unique.information3,10);
18034 -- If reuse objects flag is 'Y' then check for the object in the target business group
18035 -- if found insert the record into PLSql table and exit the loop else try create the
18036 -- object in the target business group
18037 --
18038 l_object_found_in_target := false ;
18039 --UPD START
18040 open c_ERP(r_ERP_unique.table_route_id,
18041 r_ERP_unique.information1,
18042 r_ERP_unique.information2,
18043 r_ERP_unique.information3 ) ;
18044 --
18045 fetch c_ERP into r_ERP ;
18046 --
18047 close c_ERP ;
18048 --
18049 l_dml_operation:= r_ERP_unique.dml_operation ;
18050 l_ENRT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_ERP.INFORMATION262,l_dml_operation);
18051 l_ENRT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_ERP.INFORMATION260,l_dml_operation);
18052 l_ENRT_PERD_ID := get_fk('ENRT_PERD_ID', r_ERP.INFORMATION244,l_dml_operation);
18053 l_LEE_RSN_ID := get_fk('LEE_RSN_ID', r_ERP.INFORMATION234,l_dml_operation);
18054 l_PL_ID := get_fk('PL_ID', r_ERP.INFORMATION261,l_dml_operation);
18055 l_RT_END_DT_RL := get_fk('FORMULA_ID', r_ERP.INFORMATION264,l_dml_operation);
18056 l_RT_STRT_DT_RL := get_fk('FORMULA_ID', r_ERP.INFORMATION263,l_dml_operation);
18057 --
18058 l_update := false;
18059 l_process_date := p_effective_date;
18060 --
18061 if l_dml_operation = 'UPDATE' then
18062 --
18063 l_object_found_in_target := TRUE;
18064 --
18065 if l_process_date between r_ERP_unique.information2 and r_ERP_unique.information3 then
18066 l_update := true;
18067 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)
18068 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'
18069 then
18070 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' ;
18071 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ERP_unique.information1 ;
18072 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ERP_unique.information1 ;
18073 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18074 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;
18075 --
18076 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
18077 --
18078 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18079 --
18080 --DOUBT log_data('ERP',l_new_value,l_prefix || r_ERP_unique.name|| l_suffix,'REUSED');
18081 --
18082 end if ;
18083 hr_utility.set_location( 'found record for update',10);
18084 --
18085 else
18086 --
18087 l_update := false;
18088 --
18089 end if;
18090 else
18091 --
18092 --UPD END
18093 l_min_esd := null ;
18094 l_max_eed := null ;
18095 open c_ERP_min_max_dates(r_ERP_unique.table_route_id, r_ERP_unique.information1 ) ;
18096 fetch c_ERP_min_max_dates into l_min_esd,l_max_eed ;
18097 --
18098
18099 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18100 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18101 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
18102 end if;
18103 l_min_esd := greatest(l_min_esd,r_ERP_unique.information2);
18104 /* open c_ERP(r_ERP_unique.table_route_id,
18105 r_ERP_unique.information1,
18106 r_ERP_unique.information2,
18107 r_ERP_unique.information3 ) ;
18108 --
18109 fetch c_ERP into r_ERP ;
18110 --
18111 close c_ERP ; */
18112 -- moved get_fk to top
18113
18114 if p_reuse_object_flag = 'Y' then
18115 if c_ERP_min_max_dates%found then
18116 -- cursor to find the object
18117 open c_find_ERP_in_target( l_min_esd,l_max_eed,
18118 p_target_business_group_id, nvl(l_enrt_perd_for_pl_id, -999) ) ;
18119 fetch c_find_ERP_in_target into l_new_value ;
18120 if c_find_ERP_in_target%found then
18121 --
18122 --TEMPIK
18123 l_dt_rec_found := dt_api.check_min_max_dates
18124 (p_base_table_name => 'BEN_ENRT_PERD_FOR_PL_F',
18125 p_base_key_column => 'ENRT_PERD_FOR_PL_ID',
18126 p_base_key_value => l_new_value,
18127 p_from_date => l_min_esd,
18128 p_to_date => l_max_eed );
18129 if l_dt_rec_found THEN
18130 --END TEMPIK
18131 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
18132 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
18133 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' ;
18134 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ERP_unique.information1 ;
18135 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
18136 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18137 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;
18138 --
18139 -- 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) ;
18140 --
18141 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18142 end if ;
18143 --
18144 l_object_found_in_target := true ;
18145 --TEMPIK
18146 end if; -- l_dt_rec_found
18147 --END TEMPIK
18148 end if;
18149 close c_find_ERP_in_target ;
18150 --
18151 end if;
18152 end if ;
18153 --
18154 close c_ERP_min_max_dates ;
18155 end if; --if p_dml_operation
18156 --
18157 if not l_object_found_in_target OR l_update then
18158 --
18159 l_current_pk_id := r_ERP.information1;
18160 --
18161 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
18162 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
18163 --
18164 if l_current_pk_id = l_prev_pk_id then
18165 --
18166 l_first_rec := false ;
18167 --
18168 else
18169 --
18170 l_first_rec := true ;
18171 --
18172 end if ;
18173 --
18174
18175 l_effective_date := r_ERP.information2;
18176 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18177 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18178 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
18179 end if;
18180
18181 if l_first_rec and not l_update then
18182 -- Call Create routine.
18183 hr_utility.set_location(' BEN_ENRT_PERD_FOR_PL_F CREATE_ENRT_PERD_FOR_PL ',20);
18184 BEN_ENRT_PERD_FOR_PL_API.CREATE_ENRT_PERD_FOR_PL(
18185 --
18186 P_VALIDATE => false
18187 ,P_EFFECTIVE_DATE => l_effective_date
18188 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
18189 --
18190 ,P_ENRT_CVG_END_DT_CD => r_ERP.INFORMATION12
18191 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
18192 ,P_ENRT_CVG_STRT_DT_CD => r_ERP.INFORMATION11
18193 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
18194 ,P_ENRT_PERD_FOR_PL_ID => l_enrt_perd_for_pl_id
18195 ,P_ENRT_PERD_ID => l_ENRT_PERD_ID
18196 ,P_ERP_ATTRIBUTE1 => r_ERP.INFORMATION111
18197 ,P_ERP_ATTRIBUTE10 => r_ERP.INFORMATION120
18198 ,P_ERP_ATTRIBUTE11 => r_ERP.INFORMATION121
18199 ,P_ERP_ATTRIBUTE12 => r_ERP.INFORMATION122
18200 ,P_ERP_ATTRIBUTE13 => r_ERP.INFORMATION123
18201 ,P_ERP_ATTRIBUTE14 => r_ERP.INFORMATION124
18202 ,P_ERP_ATTRIBUTE15 => r_ERP.INFORMATION125
18203 ,P_ERP_ATTRIBUTE16 => r_ERP.INFORMATION126
18204 ,P_ERP_ATTRIBUTE17 => r_ERP.INFORMATION127
18205 ,P_ERP_ATTRIBUTE18 => r_ERP.INFORMATION128
18206 ,P_ERP_ATTRIBUTE19 => r_ERP.INFORMATION129
18207 ,P_ERP_ATTRIBUTE2 => r_ERP.INFORMATION112
18208 ,P_ERP_ATTRIBUTE20 => r_ERP.INFORMATION130
18209 ,P_ERP_ATTRIBUTE21 => r_ERP.INFORMATION131
18210 ,P_ERP_ATTRIBUTE22 => r_ERP.INFORMATION132
18211 ,P_ERP_ATTRIBUTE23 => r_ERP.INFORMATION133
18212 ,P_ERP_ATTRIBUTE24 => r_ERP.INFORMATION134
18213 ,P_ERP_ATTRIBUTE25 => r_ERP.INFORMATION135
18214 ,P_ERP_ATTRIBUTE26 => r_ERP.INFORMATION136
18215 ,P_ERP_ATTRIBUTE27 => r_ERP.INFORMATION137
18216 ,P_ERP_ATTRIBUTE28 => r_ERP.INFORMATION138
18217 ,P_ERP_ATTRIBUTE29 => r_ERP.INFORMATION139
18218 ,P_ERP_ATTRIBUTE3 => r_ERP.INFORMATION113
18219 ,P_ERP_ATTRIBUTE30 => r_ERP.INFORMATION140
18220 ,P_ERP_ATTRIBUTE4 => r_ERP.INFORMATION114
18221 ,P_ERP_ATTRIBUTE5 => r_ERP.INFORMATION115
18222 ,P_ERP_ATTRIBUTE6 => r_ERP.INFORMATION116
18223 ,P_ERP_ATTRIBUTE7 => r_ERP.INFORMATION117
18224 ,P_ERP_ATTRIBUTE8 => r_ERP.INFORMATION118
18225 ,P_ERP_ATTRIBUTE9 => r_ERP.INFORMATION119
18226 ,P_ERP_ATTRIBUTE_CATEGORY => r_ERP.INFORMATION110
18227 ,P_LEE_RSN_ID => l_LEE_RSN_ID
18228 ,P_PL_ID => l_PL_ID
18229 ,P_RT_END_DT_CD => r_ERP.INFORMATION14
18230 ,P_RT_END_DT_RL => l_RT_END_DT_RL
18231 ,P_RT_STRT_DT_CD => r_ERP.INFORMATION13
18232 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
18233 --
18234 ,P_EFFECTIVE_START_DATE => l_effective_start_date
18235 ,P_EFFECTIVE_END_DATE => l_effective_end_date
18236 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
18237 );
18238 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
18239 -- Update all relevent cer records with new pk_id
18240 hr_utility.set_location('Before plsql table ',222);
18241 hr_utility.set_location('new_value id '||l_enrt_perd_for_pl_id,222);
18242 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' ;
18243 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ERP.information1 ;
18244 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 ;
18245 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
18246 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;
18247 hr_utility.set_location('After plsql table ',222);
18248 --
18249 -- 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 ) ;
18250 --
18251 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18252 --
18253 else
18254 --
18255 -- Call Update routine for the pk_id created in prev run .
18256 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
18257 hr_utility.set_location(' BEN_ENRT_PERD_FOR_PL_F UPDATE_ENRT_PERD_FOR_PL ',30);
18258 --UPD START
18259 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
18260 --
18261 if l_update then
18262 --
18263 l_datetrack_mode := r_ERP.datetrack_mode ;
18264 --
18265 get_dt_modes(
18266 p_effective_date => l_process_date,
18267 p_effective_end_date => r_ERP.information3,
18268 p_effective_start_date => r_ERP.information2,
18269 p_dml_operation => r_ERP.dml_operation,
18270 p_datetrack_mode => l_datetrack_mode );
18271 -- p_update => l_update
18272 --
18273 l_effective_date := l_process_date;
18274 l_ENRT_PERD_FOR_PL_ID := r_ERP.information1;
18275 l_object_version_number := r_ERP.information265;
18276 --
18277 end if;
18278 --
18279 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
18280 --
18281 IF l_update OR l_dml_operation <> 'UPDATE' THEN
18282 --UPD END
18283 BEN_ENRT_PERD_FOR_PL_API.UPDATE_ENRT_PERD_FOR_PL(
18284 --
18285 P_VALIDATE => false
18286 ,P_EFFECTIVE_DATE => l_effective_date
18287 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
18288 --
18289 ,P_ENRT_CVG_END_DT_CD => r_ERP.INFORMATION12
18290 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
18291 ,P_ENRT_CVG_STRT_DT_CD => r_ERP.INFORMATION11
18292 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
18293 ,P_ENRT_PERD_FOR_PL_ID => l_enrt_perd_for_pl_id
18294 ,P_ENRT_PERD_ID => l_ENRT_PERD_ID
18295 ,P_ERP_ATTRIBUTE1 => r_ERP.INFORMATION111
18296 ,P_ERP_ATTRIBUTE10 => r_ERP.INFORMATION120
18297 ,P_ERP_ATTRIBUTE11 => r_ERP.INFORMATION121
18298 ,P_ERP_ATTRIBUTE12 => r_ERP.INFORMATION122
18299 ,P_ERP_ATTRIBUTE13 => r_ERP.INFORMATION123
18300 ,P_ERP_ATTRIBUTE14 => r_ERP.INFORMATION124
18301 ,P_ERP_ATTRIBUTE15 => r_ERP.INFORMATION125
18302 ,P_ERP_ATTRIBUTE16 => r_ERP.INFORMATION126
18303 ,P_ERP_ATTRIBUTE17 => r_ERP.INFORMATION127
18304 ,P_ERP_ATTRIBUTE18 => r_ERP.INFORMATION128
18305 ,P_ERP_ATTRIBUTE19 => r_ERP.INFORMATION129
18306 ,P_ERP_ATTRIBUTE2 => r_ERP.INFORMATION112
18307 ,P_ERP_ATTRIBUTE20 => r_ERP.INFORMATION130
18308 ,P_ERP_ATTRIBUTE21 => r_ERP.INFORMATION131
18309 ,P_ERP_ATTRIBUTE22 => r_ERP.INFORMATION132
18310 ,P_ERP_ATTRIBUTE23 => r_ERP.INFORMATION133
18311 ,P_ERP_ATTRIBUTE24 => r_ERP.INFORMATION134
18312 ,P_ERP_ATTRIBUTE25 => r_ERP.INFORMATION135
18313 ,P_ERP_ATTRIBUTE26 => r_ERP.INFORMATION136
18314 ,P_ERP_ATTRIBUTE27 => r_ERP.INFORMATION137
18315 ,P_ERP_ATTRIBUTE28 => r_ERP.INFORMATION138
18316 ,P_ERP_ATTRIBUTE29 => r_ERP.INFORMATION139
18317 ,P_ERP_ATTRIBUTE3 => r_ERP.INFORMATION113
18318 ,P_ERP_ATTRIBUTE30 => r_ERP.INFORMATION140
18319 ,P_ERP_ATTRIBUTE4 => r_ERP.INFORMATION114
18320 ,P_ERP_ATTRIBUTE5 => r_ERP.INFORMATION115
18321 ,P_ERP_ATTRIBUTE6 => r_ERP.INFORMATION116
18322 ,P_ERP_ATTRIBUTE7 => r_ERP.INFORMATION117
18323 ,P_ERP_ATTRIBUTE8 => r_ERP.INFORMATION118
18324 ,P_ERP_ATTRIBUTE9 => r_ERP.INFORMATION119
18325 ,P_ERP_ATTRIBUTE_CATEGORY => r_ERP.INFORMATION110
18326 ,P_LEE_RSN_ID => l_LEE_RSN_ID
18327 ,P_PL_ID => l_PL_ID
18328 ,P_RT_END_DT_CD => r_ERP.INFORMATION14
18329 ,P_RT_END_DT_RL => l_RT_END_DT_RL
18330 ,P_RT_STRT_DT_CD => r_ERP.INFORMATION13
18331 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
18332 --
18333 ,P_EFFECTIVE_START_DATE => l_effective_start_date
18334 ,P_EFFECTIVE_END_DATE => l_effective_end_date
18335 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
18336 ,P_DATETRACK_MODE => l_datetrack_mode
18337 );
18338 --
18339 end if; -- l_update
18340 end if;
18341 --
18342 -- Delete the row if it is end dated.
18343 --
18344 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
18345 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
18346 trunc(l_max_eed) = r_ERP.information3) then
18347 --
18348 BEN_ENRT_PERD_FOR_PL_API.delete_ENRT_PERD_FOR_PL(
18349 --
18350 p_validate => false
18351 ,p_enrt_perd_for_pl_id => l_enrt_perd_for_pl_id
18352 ,p_effective_start_date => l_effective_start_date
18353 ,p_effective_end_date => l_effective_end_date
18354 ,p_object_version_number => l_object_version_number
18355 ,p_effective_date => l_max_eed
18356 ,p_datetrack_mode => hr_api.g_delete
18357 --
18358 );
18359 --
18360 end if;
18361 --
18362 l_prev_pk_id := l_current_pk_id ;
18363 --
18364 end if;
18365 --
18366 end if;
18367 --
18368 end loop;
18369 --
18370 exception when others then
18371 --
18372 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ERP',r_erp.information5 );
18373 --
18374 end create_ERP_rows;
18375
18376 --
18377 ---------------------------------------------------------------
18378 ----------------------< create_SER_rows >-----------------------
18379 ---------------------------------------------------------------
18380 --
18381 procedure create_SER_rows
18382 (
18383 p_validate in number default 0
18384 ,p_copy_entity_txn_id in number
18385 ,p_effective_date in date
18386 ,p_prefix_suffix_text in varchar2 default null
18387 ,p_reuse_object_flag in varchar2 default null
18388 ,p_target_business_group_id in varchar2 default null
18389 ,p_prefix_suffix_cd in varchar2 default null
18390 ) is
18391 --
18392 l_ENRT_PERD_ID number;
18393 l_FORMULA_ID number;
18394 cursor c_unique_SER(l_table_alias varchar2) is
18395 select distinct cpe.information1,
18396 cpe.information2,
18397 cpe.information3,
18398 cpe.table_route_id
18399 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
18400 pqh_table_route tr
18401 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18402 and cpe.table_route_id = tr.table_route_id
18403 -- and tr.where_clause = l_BEN_SCHEDD_ENRT_RL_F
18404 and tr.table_alias = l_table_alias
18405 and cpe.number_of_copies = 1 -- ADDITION
18406 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
18407 order by information1, information2; --added for bug: 5151945
18408 --
18409 --
18410 cursor c_SER_min_max_dates(c_table_route_id number,
18411 c_information1 number) is
18412 select
18413 min(cpe.information2) min_esd,
18414 max(cpe.information3) min_eed
18415 from ben_copy_entity_results cpe
18416 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18417 and cpe.table_route_id = c_table_route_id
18418 and cpe.information1 = c_information1 ;
18419 --
18420 cursor c_SER(c_table_route_id number,
18421 c_information1 number,
18422 c_information2 date,
18423 c_information3 date ) is
18424 select
18425 cpe.*
18426 from ben_copy_entity_results cpe
18427 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18428 and cpe.table_route_id = c_table_route_id
18429 and cpe.information1 = c_information1
18430 and cpe.information2 = c_information2
18431 and cpe.information3 = c_information3
18432 and rownum = 1 ;
18433 -- Date Track target record
18434 cursor c_find_SER_in_target(
18435 c_effective_start_date date,
18436 c_effective_end_date date,
18437 c_business_group_id number,
18438 c_new_pk_id number) is
18439 select
18440 SER.schedd_enrt_rl_id new_value
18441 from BEN_SCHEDD_ENRT_RL_F SER
18442 where
18443 nvl(SER.ENRT_PERD_ID,-999) = nvl(l_ENRT_PERD_ID,-999) and
18444 nvl(SER.FORMULA_ID,-999) = nvl(l_FORMULA_ID,-999) and
18445 SER.business_group_id = c_business_group_id
18446 and SER.schedd_enrt_rl_id <> c_new_pk_id
18447 --TEMPIK
18448 and c_effective_start_date between effective_start_date
18449 and effective_end_date ;
18450 --END TEMPIK
18451 /*TEMPIK
18452 and exists ( select null
18453 from BEN_SCHEDD_ENRT_RL_F SER1
18454 where
18455 nvl(SER1.ENRT_PERD_ID,-999) = nvl(l_ENRT_PERD_ID, -999) and
18456 nvl(SER1.FORMULA_ID,-999) = nvl(l_FORMULA_ID , -999) and
18457 SER1.business_group_id = c_business_group_id
18458 and SER1.effective_start_date <= c_effective_start_date )
18459 and exists ( select null
18460 from BEN_SCHEDD_ENRT_RL_F SER2
18461 where
18462 nvl(SER2.ENRT_PERD_ID,-999) = nvl(l_ENRT_PERD_ID , -999) and
18463 nvl(SER2.FORMULA_ID,-999) = nvl(l_FORMULA_ID , -999) and
18464 SER2.business_group_id = c_business_group_id
18465 and SER2.effective_end_date >= c_effective_end_date )
18466 ;
18467 */
18468 --
18469 --UPD START
18470 --
18471 l_update boolean := false ;
18472 l_datetrack_mode varchar2(80) := hr_api.g_update;
18473 l_process_date date;
18474 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
18475 --
18476 --UPD END
18477 l_current_pk_id number := null ;
18478 l_prev_pk_id number := null ;
18479 l_first_rec boolean := true ;
18480 r_SER c_SER%rowtype;
18481 l_schedd_enrt_rl_id number ;
18482 l_object_version_number number ;
18483 l_effective_start_date date ;
18484 l_effective_end_date date ;
18485 l_prefix pqh_copy_entity_attribs.information1%type := null;
18486 l_suffix pqh_copy_entity_attribs.information1%type := null;
18487 l_new_value number(15);
18488 l_object_found_in_target boolean := false ;
18489 l_min_esd date;
18490 l_max_eed date;
18491 l_effective_date date;
18492 --TEMPIK
18493 l_dt_rec_found boolean ;
18494 --END TEMPIK
18495 --
18496 begin
18497 -- Initialization
18498 l_object_found_in_target := false ;
18499 -- End Initialization
18500 -- Derive the prefix - sufix
18501 if p_prefix_suffix_cd = 'PREFIX' then
18502 l_prefix := p_prefix_suffix_text ;
18503 elsif p_prefix_suffix_cd = 'SUFFIX' then
18504 l_suffix := p_prefix_suffix_text ;
18505 else
18506 l_prefix := null ;
18507 l_suffix := null ;
18508 end if ;
18509 -- End Prefix Sufix derivation
18510 for r_SER_unique in c_unique_SER('SER') loop
18511
18512 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
18513 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18514 r_SER_unique.information3 >=
18515 ben_pd_copy_to_ben_one.g_copy_effective_date)
18516 ) then
18517 --
18518 hr_utility.set_location(' r_SER_unique.table_route_id '||r_SER_unique.table_route_id,10);
18519 hr_utility.set_location(' r_SER_unique.information1 '||r_SER_unique.information1,10);
18520 hr_utility.set_location( 'r_SER_unique.information2 '||r_SER_unique.information2,10);
18521 hr_utility.set_location( 'r_SER_unique.information3 '||r_SER_unique.information3,10);
18522 -- If reuse objects flag is 'Y' then check for the object in the target business group
18523 -- if found insert the record into PLSql table and exit the loop else try create the
18524 -- object in the target business group
18525 --
18526 l_object_found_in_target := false ;
18527 --UPD START
18528 open c_SER(r_SER_unique.table_route_id,
18529 r_SER_unique.information1,
18530 r_SER_unique.information2,
18531 r_SER_unique.information3 ) ;
18532 --
18533 fetch c_SER into r_SER ;
18534 --
18535 close c_SER ;
18536 l_dml_operation:= r_SER_unique.dml_operation ;
18537 l_ENRT_PERD_ID := get_fk('ENRT_PERD_ID', r_SER.INFORMATION244,l_dml_operation );
18538 l_FORMULA_ID := get_fk('FORMULA_ID', r_SER.INFORMATION251,l_dml_operation );
18539 l_update := false;
18540 l_process_date := p_effective_date;
18541 --
18542 if l_dml_operation = 'UPDATE' then
18543 --
18544 l_object_found_in_target := TRUE;
18545 --
18546 if l_process_date between r_SER_unique.information2 and r_SER_unique.information3 then
18547 l_update := true;
18548 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)
18549 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'
18550 then
18551 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'SCHEDD_ENRT_RL_ID' ;
18552 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_SER_unique.information1 ;
18553 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_SER_unique.information1 ;
18554 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18555 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;
18556 --
18557 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
18558 --
18559 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18560 --
18561 --DOUBT log_data('SER',l_new_value,l_prefix || r_SER_unique.name|| l_suffix,'REUSED');
18562 --
18563 end if ;
18564 hr_utility.set_location( 'found record for update',10);
18565 --
18566 else
18567 --
18568 l_update := false;
18569 --
18570 end if;
18571 else
18572 --
18573 --UPD END
18574 l_min_esd := null ;
18575 l_max_eed := null ;
18576 open c_SER_min_max_dates(r_SER_unique.table_route_id, r_SER_unique.information1 ) ;
18577 fetch c_SER_min_max_dates into l_min_esd,l_max_eed ;
18578 --
18579
18580 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18581 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18582 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
18583 end if;
18584 l_min_esd := greatest(l_min_esd,r_SER_unique.information2);
18585 /* open c_SER(r_SER_unique.table_route_id,
18586 r_SER_unique.information1,
18587 r_SER_unique.information2,
18588 r_SER_unique.information3 ) ;
18589 --
18590 fetch c_SER into r_SER ;
18591 --
18592 close c_SER ; */
18593 --
18594 if p_reuse_object_flag = 'Y' then
18595 if c_SER_min_max_dates%found then
18596 -- cursor to find the object
18597 open c_find_SER_in_target( l_min_esd,l_max_eed,
18598 p_target_business_group_id, nvl(l_schedd_enrt_rl_id, -999) ) ;
18599 fetch c_find_SER_in_target into l_new_value ;
18600 if c_find_SER_in_target%found then
18601 --
18602 --TEMPIK
18603 l_dt_rec_found := dt_api.check_min_max_dates
18604 (p_base_table_name => 'BEN_SCHEDD_ENRT_RL_F',
18605 p_base_key_column => 'SCHEDD_ENRT_RL_ID',
18606 p_base_key_value => l_new_value,
18607 p_from_date => l_min_esd,
18608 p_to_date => l_max_eed );
18609 if l_dt_rec_found THEN
18610 --END TEMPIK
18611 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
18612 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
18613 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'SCHEDD_ENRT_RL_ID' ;
18614 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_SER_unique.information1 ;
18615 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
18616 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
18617 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;
18618 --
18619 -- 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) ;
18620 --
18621 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18622 end if ;
18623 --
18624 l_object_found_in_target := true ;
18625 --TEMPIK
18626 end if; -- l_dt_rec_found
18627 --END TEMPIK
18628 end if;
18629 close c_find_SER_in_target ;
18630 --
18631 end if;
18632 end if ;
18633 --
18634 close c_SER_min_max_dates ;
18635 end if; --if p_dml_operation
18636 --
18637 if not l_object_found_in_target OR l_update then
18638 --
18639 l_current_pk_id := r_SER.information1;
18640 --
18641 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
18642 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
18643 --
18644 if l_current_pk_id = l_prev_pk_id then
18645 --
18646 l_first_rec := false ;
18647 --
18648 else
18649 --
18650 l_first_rec := true ;
18651 --
18652 end if ;
18653 --
18654
18655 l_effective_date := r_SER.information2;
18656 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18657 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
18658 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
18659 end if;
18660
18661 if l_first_rec and not l_update then
18662 -- Call Create routine.
18663 hr_utility.set_location(' BEN_SCHEDD_ENRT_RL_F CREATE_SCHEDD_ENROLLMENT_RL ',20);
18664 BEN_SCHEDD_ENROLLMENT_RL_API.CREATE_SCHEDD_ENROLLMENT_RL(
18665 --
18666 P_VALIDATE => false
18667 ,P_EFFECTIVE_DATE => l_effective_date
18668 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
18669 --
18670 ,P_ENRT_PERD_ID => l_ENRT_PERD_ID
18671 ,P_FORMULA_ID => l_FORMULA_ID
18672 ,P_ORDR_TO_APLY_NUM => r_SER.INFORMATION260
18673 ,P_SCHEDD_ENRT_RL_ID => l_schedd_enrt_rl_id
18674 ,P_SER_ATTRIBUTE1 => r_SER.INFORMATION111
18675 ,P_SER_ATTRIBUTE10 => r_SER.INFORMATION120
18676 ,P_SER_ATTRIBUTE11 => r_SER.INFORMATION121
18677 ,P_SER_ATTRIBUTE12 => r_SER.INFORMATION122
18678 ,P_SER_ATTRIBUTE13 => r_SER.INFORMATION123
18679 ,P_SER_ATTRIBUTE14 => r_SER.INFORMATION124
18680 ,P_SER_ATTRIBUTE15 => r_SER.INFORMATION125
18681 ,P_SER_ATTRIBUTE16 => r_SER.INFORMATION126
18682 ,P_SER_ATTRIBUTE17 => r_SER.INFORMATION127
18683 ,P_SER_ATTRIBUTE18 => r_SER.INFORMATION128
18684 ,P_SER_ATTRIBUTE19 => r_SER.INFORMATION129
18685 ,P_SER_ATTRIBUTE2 => r_SER.INFORMATION112
18686 ,P_SER_ATTRIBUTE20 => r_SER.INFORMATION130
18687 ,P_SER_ATTRIBUTE21 => r_SER.INFORMATION131
18688 ,P_SER_ATTRIBUTE22 => r_SER.INFORMATION132
18689 ,P_SER_ATTRIBUTE23 => r_SER.INFORMATION133
18690 ,P_SER_ATTRIBUTE24 => r_SER.INFORMATION134
18691 ,P_SER_ATTRIBUTE25 => r_SER.INFORMATION135
18692 ,P_SER_ATTRIBUTE26 => r_SER.INFORMATION136
18693 ,P_SER_ATTRIBUTE27 => r_SER.INFORMATION137
18694 ,P_SER_ATTRIBUTE28 => r_SER.INFORMATION138
18695 ,P_SER_ATTRIBUTE29 => r_SER.INFORMATION139
18696 ,P_SER_ATTRIBUTE3 => r_SER.INFORMATION113
18697 ,P_SER_ATTRIBUTE30 => r_SER.INFORMATION140
18698 ,P_SER_ATTRIBUTE4 => r_SER.INFORMATION114
18699 ,P_SER_ATTRIBUTE5 => r_SER.INFORMATION115
18700 ,P_SER_ATTRIBUTE6 => r_SER.INFORMATION116
18701 ,P_SER_ATTRIBUTE7 => r_SER.INFORMATION117
18702 ,P_SER_ATTRIBUTE8 => r_SER.INFORMATION118
18703 ,P_SER_ATTRIBUTE9 => r_SER.INFORMATION119
18704 ,P_SER_ATTRIBUTE_CATEGORY => r_SER.INFORMATION110
18705 --
18706 ,P_EFFECTIVE_START_DATE => l_effective_start_date
18707 ,P_EFFECTIVE_END_DATE => l_effective_end_date
18708 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
18709 );
18710 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
18711 -- Update all relevent cer records with new pk_id
18712 hr_utility.set_location('Before plsql table ',222);
18713 hr_utility.set_location('new_value id '||l_schedd_enrt_rl_id,222);
18714 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'SCHEDD_ENRT_RL_ID' ;
18715 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_SER.information1 ;
18716 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_SCHEDD_ENRT_RL_ID ;
18717 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
18718 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;
18719 hr_utility.set_location('After plsql table ',222);
18720 --
18721 -- 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 ) ;
18722 --
18723 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
18724 --
18725 else
18726 --
18727 -- Call Update routine for the pk_id created in prev run .
18728 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
18729 hr_utility.set_location(' BEN_SCHEDD_ENRT_RL_F UPDATE_SCHEDD_ENROLLMENT_RL ',30);
18730 --UPD START
18731 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
18732 --
18733 if l_update then
18734 --
18735 l_datetrack_mode := r_SER.datetrack_mode ;
18736 --
18737 get_dt_modes(
18738 p_effective_date => l_process_date,
18739 p_effective_end_date => r_SER.information3,
18740 p_effective_start_date => r_SER.information2,
18741 p_dml_operation => r_SER.dml_operation,
18742 p_datetrack_mode => l_datetrack_mode );
18743 -- p_update => l_update
18744 --
18745 l_effective_date := l_process_date;
18746 l_SCHEDD_ENRT_RL_ID := r_SER.information1;
18747 l_object_version_number := r_SER.information265;
18748 --
18749 end if;
18750 --
18751 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
18752 --
18753 IF l_update OR l_dml_operation <> 'UPDATE' THEN
18754 --UPD END
18755 BEN_SCHEDD_ENROLLMENT_RL_API.UPDATE_SCHEDD_ENROLLMENT_RL(
18756 --
18757 P_VALIDATE => false
18758 ,P_EFFECTIVE_DATE => l_effective_date
18759 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
18760 --
18761 ,P_ENRT_PERD_ID => l_ENRT_PERD_ID
18762 ,P_FORMULA_ID => l_FORMULA_ID
18763 ,P_ORDR_TO_APLY_NUM => r_SER.INFORMATION260
18764 ,P_SCHEDD_ENRT_RL_ID => l_schedd_enrt_rl_id
18765 ,P_SER_ATTRIBUTE1 => r_SER.INFORMATION111
18766 ,P_SER_ATTRIBUTE10 => r_SER.INFORMATION120
18767 ,P_SER_ATTRIBUTE11 => r_SER.INFORMATION121
18768 ,P_SER_ATTRIBUTE12 => r_SER.INFORMATION122
18769 ,P_SER_ATTRIBUTE13 => r_SER.INFORMATION123
18770 ,P_SER_ATTRIBUTE14 => r_SER.INFORMATION124
18771 ,P_SER_ATTRIBUTE15 => r_SER.INFORMATION125
18772 ,P_SER_ATTRIBUTE16 => r_SER.INFORMATION126
18773 ,P_SER_ATTRIBUTE17 => r_SER.INFORMATION127
18774 ,P_SER_ATTRIBUTE18 => r_SER.INFORMATION128
18775 ,P_SER_ATTRIBUTE19 => r_SER.INFORMATION129
18776 ,P_SER_ATTRIBUTE2 => r_SER.INFORMATION112
18777 ,P_SER_ATTRIBUTE20 => r_SER.INFORMATION130
18778 ,P_SER_ATTRIBUTE21 => r_SER.INFORMATION131
18779 ,P_SER_ATTRIBUTE22 => r_SER.INFORMATION132
18780 ,P_SER_ATTRIBUTE23 => r_SER.INFORMATION133
18781 ,P_SER_ATTRIBUTE24 => r_SER.INFORMATION134
18782 ,P_SER_ATTRIBUTE25 => r_SER.INFORMATION135
18783 ,P_SER_ATTRIBUTE26 => r_SER.INFORMATION136
18784 ,P_SER_ATTRIBUTE27 => r_SER.INFORMATION137
18785 ,P_SER_ATTRIBUTE28 => r_SER.INFORMATION138
18786 ,P_SER_ATTRIBUTE29 => r_SER.INFORMATION139
18787 ,P_SER_ATTRIBUTE3 => r_SER.INFORMATION113
18788 ,P_SER_ATTRIBUTE30 => r_SER.INFORMATION140
18789 ,P_SER_ATTRIBUTE4 => r_SER.INFORMATION114
18790 ,P_SER_ATTRIBUTE5 => r_SER.INFORMATION115
18791 ,P_SER_ATTRIBUTE6 => r_SER.INFORMATION116
18792 ,P_SER_ATTRIBUTE7 => r_SER.INFORMATION117
18793 ,P_SER_ATTRIBUTE8 => r_SER.INFORMATION118
18794 ,P_SER_ATTRIBUTE9 => r_SER.INFORMATION119
18795 ,P_SER_ATTRIBUTE_CATEGORY => r_SER.INFORMATION110
18796 --
18797 ,P_EFFECTIVE_START_DATE => l_effective_start_date
18798 ,P_EFFECTIVE_END_DATE => l_effective_end_date
18799 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
18800 ,P_DATETRACK_MODE => l_datetrack_mode
18801 );
18802 --
18803 end if; -- l_update
18804 end if;
18805 --
18806 -- Delete the row if it is end dated.
18807 --
18808 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
18809 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
18810 trunc(l_max_eed) = r_SER.information3) then
18811 --
18812 BEN_SCHEDD_ENROLLMENT_RL_API.delete_SCHEDD_ENROLLMENT_RL(
18813 --
18814 p_validate => false
18815 ,p_schedd_enrt_rl_id => l_schedd_enrt_rl_id
18816 ,p_effective_start_date => l_effective_start_date
18817 ,p_effective_end_date => l_effective_end_date
18818 ,p_object_version_number => l_object_version_number
18819 ,p_effective_date => l_max_eed
18820 ,p_datetrack_mode => hr_api.g_delete
18821 --
18822 );
18823 --
18824 end if;
18825 --
18826 l_prev_pk_id := l_current_pk_id ;
18827 --
18828 end if;
18829 --
18830 end if;
18831 --
18832 end loop;
18833 --
18834 exception when others then
18835 --
18836 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'SER',r_ser.information5 );
18837 --
18838 end create_SER_rows;
18839 --
18840 ---------------------------------------------------------------
18841 ----------------------< create_LRR_rows >-----------------------
18842 ---------------------------------------------------------------
18843 --
18844 procedure create_LRR_rows
18845 (
18846 p_validate in number default 0
18847 ,p_copy_entity_txn_id in number
18848 ,p_effective_date in date
18849 ,p_prefix_suffix_text in varchar2 default null
18850 ,p_reuse_object_flag in varchar2 default null
18851 ,p_target_business_group_id in varchar2 default null
18852 ,p_prefix_suffix_cd in varchar2 default null
18853 ) is
18854 --
18855 l_FORMULA_ID number;
18856 l_LEE_RSN_ID number;
18857 cursor c_unique_LRR(l_table_alias varchar2) is
18858 select distinct cpe.information1,
18859 cpe.information2,
18860 cpe.information3,
18861 cpe.table_route_id
18862 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
18863 pqh_table_route tr
18864 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18865 and cpe.table_route_id = tr.table_route_id
18866 -- and tr.where_clause = l_BEN_LEE_RSN_RL_F
18867 and tr.table_alias = l_table_alias
18868 and cpe.number_of_copies = 1 -- ADDITION
18869 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
18870 order by information1, information2; --added for bug: 5151945
18871 --
18872 --
18873 cursor c_LRR_min_max_dates(c_table_route_id number,
18874 c_information1 number) is
18875 select
18876 min(cpe.information2) min_esd,
18877 max(cpe.information3) min_eed
18878 from ben_copy_entity_results cpe
18879 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18880 and cpe.table_route_id = c_table_route_id
18881 and cpe.information1 = c_information1 ;
18882 --
18883 cursor c_LRR(c_table_route_id number,
18884 c_information1 number,
18885 c_information2 date,
18886 c_information3 date) is
18887 select
18888 cpe.*
18889 from ben_copy_entity_results cpe
18890 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
18891 and cpe.table_route_id = c_table_route_id
18892 and cpe.information1 = c_information1
18893 and cpe.information2 = c_information2
18894 and cpe.information3 = c_information3
18895 and rownum = 1 ;
18896 -- Date Track target record
18897 cursor c_find_LRR_in_target(
18898 c_effective_start_date date,
18899 c_effective_end_date date,
18900 c_business_group_id number,
18901 c_new_pk_id number) is
18902 select
18903 LRR.lee_rsn_rl_id new_value
18904 from BEN_LEE_RSN_RL_F LRR
18905 where
18906 nvl(LRR.FORMULA_ID,-999) = nvl(l_FORMULA_ID,-999) and
18907 nvl(LRR.LEE_RSN_ID,-999) = nvl(l_LEE_RSN_ID,-999) and
18908 LRR.business_group_id = c_business_group_id
18909 and LRR.lee_rsn_rl_id <> c_new_pk_id
18910 --TEMPIK
18911 and c_effective_start_date between effective_start_date
18912 and effective_end_date ;
18913 --END TEMPIK
18914 /*TEMPIK
18915 and exists ( select null
18916 from BEN_LEE_RSN_RL_F LRR1
18917 where
18918 nvl(LRR1.FORMULA_ID,-999) = nvl(l_FORMULA_ID,-999) and
18919 nvl(LRR1.LEE_RSN_ID,-999) = nvl(l_LEE_RSN_ID,-999) and
18920 LRR1.business_group_id = c_business_group_id
18921 and LRR1.effective_start_date <= c_effective_start_date )
18922 and exists ( select null
18923 from BEN_LEE_RSN_RL_F LRR2
18924 where
18925 nvl(LRR2.FORMULA_ID,-999) = nvl(l_FORMULA_ID,-999) and
18926 nvl(LRR2.LEE_RSN_ID,-999) = nvl(l_LEE_RSN_ID,-999) and
18927 LRR2.business_group_id = c_business_group_id
18928 and LRR2.effective_end_date >= c_effective_end_date )
18929 ;
18930 */
18931 --
18932 --UPD START
18933 --
18934 l_update boolean := false ;
18935 l_datetrack_mode varchar2(80) := hr_api.g_update;
18936 l_process_date date;
18937 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
18938 --
18939 --UPD END
18940 l_current_pk_id number := null ;
18941 l_prev_pk_id number := null ;
18942 l_first_rec boolean := true ;
18943 r_LRR c_LRR%rowtype;
18944 l_lee_rsn_rl_id number ;
18945 l_object_version_number number ;
18946 l_effective_start_date date ;
18947 l_effective_end_date date ;
18948 l_prefix pqh_copy_entity_attribs.information1%type := null;
18949 l_suffix pqh_copy_entity_attribs.information1%type := null;
18950 l_new_value number(15);
18951 l_object_found_in_target boolean := false ;
18952 l_min_esd date;
18953 l_max_eed date;
18954 l_effective_date date;
18955 --TEMPIK
18956 l_dt_rec_found boolean ;
18957 --END TEMPIK
18958 --
18959 begin
18960 -- Initialization
18961 l_object_found_in_target := false ;
18962 -- End Initialization
18963 -- Derive the prefix - sufix
18964 if p_prefix_suffix_cd = 'PREFIX' then
18965 l_prefix := p_prefix_suffix_text ;
18966 elsif p_prefix_suffix_cd = 'SUFFIX' then
18967 l_suffix := p_prefix_suffix_text ;
18968 else
18969 l_prefix := null ;
18970 l_suffix := null ;
18971 end if ;
18972 -- End Prefix Sufix derivation
18973 for r_LRR_unique in c_unique_LRR('LRR') loop
18974
18975 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
18976 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
18977 r_LRR_unique.information3 >=
18978 ben_pd_copy_to_ben_one.g_copy_effective_date)
18979 ) then
18980 --
18981 hr_utility.set_location(' r_LRR_unique.table_route_id '||r_LRR_unique.table_route_id,10);
18982 hr_utility.set_location(' r_LRR_unique.information1 '||r_LRR_unique.information1,10);
18983 hr_utility.set_location( 'r_LRR_unique.information2 '||r_LRR_unique.information2,10);
18984 hr_utility.set_location( 'r_LRR_unique.information3 '||r_LRR_unique.information3,10);
18985 -- If reuse objects flag is 'Y' then check for the object in the target business group
18986 -- if found insert the record into PLSql table and exit the loop else try create the
18987 -- object in the target business group
18988 --
18989 l_object_found_in_target := false ;
18990 --UPD START
18991 open c_LRR(r_LRR_unique.table_route_id,
18992 r_LRR_unique.information1,
18993 r_LRR_unique.information2,
18994 r_LRR_unique.information3 ) ;
18995 --
18996 fetch c_LRR into r_LRR ;
18997 --
18998 close c_LRR ;
18999 l_dml_operation:= r_LRR_unique.dml_operation ;
19000 l_FORMULA_ID := get_fk('FORMULA_ID', r_LRR.information251,l_dml_operation );
19001 l_LEE_RSN_ID := get_fk('LEE_RSN_ID', r_LRR.information234,l_dml_operation );
19002 l_update := false;
19003 l_process_date := p_effective_date;
19004 --
19005 if l_dml_operation = 'UPDATE' then
19006 --
19007 l_object_found_in_target := TRUE;
19008 --
19009 if l_process_date between r_LRR_unique.information2 and r_LRR_unique.information3 then
19010 l_update := true;
19011 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)
19012 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'
19013 then
19014 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LEE_RSN_RL_ID' ;
19015 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LRR_unique.information1 ;
19016 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LRR_unique.information1 ;
19017 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19018 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;
19019 --
19020 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
19021 --
19022 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19023 --
19024 --DOUBT log_data('LRR',l_new_value,l_prefix || r_LRR_unique.name|| l_suffix,'REUSED');
19025 --
19026 end if ;
19027 hr_utility.set_location( 'found record for update',10);
19028 --
19029 else
19030 --
19031 l_update := false;
19032 --
19033 end if;
19034 else
19035 --
19036 --UPD END
19037 l_min_esd := null ;
19038 l_max_eed := null ;
19039 open c_LRR_min_max_dates(r_LRR_unique.table_route_id, r_LRR_unique.information1 ) ;
19040 fetch c_LRR_min_max_dates into l_min_esd,l_max_eed ;
19041 --
19042
19043 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19044 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19045 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
19046 end if;
19047 l_min_esd := greatest(l_min_esd,r_LRR_unique.information2);
19048 /* open c_LRR(r_LRR_unique.table_route_id,
19049 r_LRR_unique.information1,
19050 r_LRR_unique.information2,
19051 r_LRR_unique.information3 ) ;
19052 --
19053 fetch c_LRR into r_LRR ;
19054 --
19055 close c_LRR ; */
19056 --
19057 if p_reuse_object_flag = 'Y' then
19058 if c_LRR_min_max_dates%found then
19059 -- cursor to find the object
19060 open c_find_LRR_in_target( l_min_esd,l_max_eed,
19061 p_target_business_group_id, nvl(l_lee_rsn_rl_id, -999) ) ;
19062 fetch c_find_LRR_in_target into l_new_value ;
19063 if c_find_LRR_in_target%found then
19064 --
19065 --TEMPIK
19066 l_dt_rec_found := dt_api.check_min_max_dates
19067 (p_base_table_name => 'BEN_LEE_RSN_RL_F',
19068 p_base_key_column => 'LEE_RSN_RL_ID',
19069 p_base_key_value => l_new_value,
19070 p_from_date => l_min_esd,
19071 p_to_date => l_max_eed );
19072 if l_dt_rec_found THEN
19073 --END TEMPIK
19074 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
19075 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
19076 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LEE_RSN_RL_ID' ;
19077 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LRR_unique.information1 ;
19078 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
19079 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19080 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;
19081 --
19082 -- 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) ;
19083 --
19084 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19085 end if ;
19086 --
19087 l_object_found_in_target := true ;
19088 --TEMPIK
19089 end if; -- l_dt_rec_found
19090 --END TEMPIK
19091 end if;
19092 close c_find_LRR_in_target ;
19093 --
19094 end if;
19095 end if ;
19096 --
19097 close c_LRR_min_max_dates ;
19098 end if; --if p_dml_operation
19099 --
19100 if not l_object_found_in_target OR l_update then
19101 --
19102 l_current_pk_id := r_LRR.information1;
19103 --
19104 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
19105 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
19106 --
19107 if l_current_pk_id = l_prev_pk_id then
19108 --
19109 l_first_rec := false ;
19110 --
19111 else
19112 --
19113 l_first_rec := true ;
19114 --
19115 end if ;
19116 --
19117
19118 l_effective_date := r_LRR.information2;
19119 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19120 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19121 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
19122 end if;
19123
19124 if l_first_rec and not l_update then
19125 -- Call Create routine.
19126 hr_utility.set_location(' BEN_LEE_RSN_RL_F CREATE_LEE_RSN_RL ',20);
19127 BEN_LEE_RSN_RL_API.CREATE_LEE_RSN_RL(
19128 --
19129 P_VALIDATE => false
19130 ,P_EFFECTIVE_DATE => l_effective_date
19131 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19132 --
19133 ,P_FORMULA_ID => l_FORMULA_ID
19134 ,P_LEE_RSN_ID => l_LEE_RSN_ID
19135 ,P_LEE_RSN_RL_ID => l_lee_rsn_rl_id
19136 ,P_LRR_ATTRIBUTE1 => r_LRR.INFORMATION111
19137 ,P_LRR_ATTRIBUTE10 => r_LRR.INFORMATION120
19138 ,P_LRR_ATTRIBUTE11 => r_LRR.INFORMATION121
19139 ,P_LRR_ATTRIBUTE12 => r_LRR.INFORMATION122
19140 ,P_LRR_ATTRIBUTE13 => r_LRR.INFORMATION123
19141 ,P_LRR_ATTRIBUTE14 => r_LRR.INFORMATION124
19142 ,P_LRR_ATTRIBUTE15 => r_LRR.INFORMATION125
19143 ,P_LRR_ATTRIBUTE16 => r_LRR.INFORMATION126
19144 ,P_LRR_ATTRIBUTE17 => r_LRR.INFORMATION127
19145 ,P_LRR_ATTRIBUTE18 => r_LRR.INFORMATION128
19146 ,P_LRR_ATTRIBUTE19 => r_LRR.INFORMATION129
19147 ,P_LRR_ATTRIBUTE2 => r_LRR.INFORMATION112
19148 ,P_LRR_ATTRIBUTE20 => r_LRR.INFORMATION130
19149 ,P_LRR_ATTRIBUTE21 => r_LRR.INFORMATION131
19150 ,P_LRR_ATTRIBUTE22 => r_LRR.INFORMATION132
19151 ,P_LRR_ATTRIBUTE23 => r_LRR.INFORMATION133
19152 ,P_LRR_ATTRIBUTE24 => r_LRR.INFORMATION134
19153 ,P_LRR_ATTRIBUTE25 => r_LRR.INFORMATION135
19154 ,P_LRR_ATTRIBUTE26 => r_LRR.INFORMATION136
19155 ,P_LRR_ATTRIBUTE27 => r_LRR.INFORMATION137
19156 ,P_LRR_ATTRIBUTE28 => r_LRR.INFORMATION138
19157 ,P_LRR_ATTRIBUTE29 => r_LRR.INFORMATION139
19158 ,P_LRR_ATTRIBUTE3 => r_LRR.INFORMATION113
19159 ,P_LRR_ATTRIBUTE30 => r_LRR.INFORMATION140
19160 ,P_LRR_ATTRIBUTE4 => r_LRR.INFORMATION114
19161 ,P_LRR_ATTRIBUTE5 => r_LRR.INFORMATION115
19162 ,P_LRR_ATTRIBUTE6 => r_LRR.INFORMATION116
19163 ,P_LRR_ATTRIBUTE7 => r_LRR.INFORMATION117
19164 ,P_LRR_ATTRIBUTE8 => r_LRR.INFORMATION118
19165 ,P_LRR_ATTRIBUTE9 => r_LRR.INFORMATION119
19166 ,P_LRR_ATTRIBUTE_CATEGORY => r_LRR.INFORMATION110
19167 ,P_ORDR_TO_APLY_NUM => r_LRR.INFORMATION260
19168 --
19169 ,P_EFFECTIVE_START_DATE => l_effective_start_date
19170 ,P_EFFECTIVE_END_DATE => l_effective_end_date
19171 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
19172 );
19173 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
19174 -- Update all relevent cer records with new pk_id
19175 hr_utility.set_location('Before plsql table ',222);
19176 hr_utility.set_location('new_value id '||l_lee_rsn_rl_id,222);
19177 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LEE_RSN_RL_ID' ;
19178 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LRR.information1 ;
19179 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LEE_RSN_RL_ID ;
19180 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
19181 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;
19182 hr_utility.set_location('After plsql table ',222);
19183 --
19184 -- 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 ) ;
19185 --
19186 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19187 --
19188 else
19189 --
19190 -- Call Update routine for the pk_id created in prev run .
19191 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
19192 hr_utility.set_location(' BEN_LEE_RSN_RL_F UPDATE_LEE_RSN_RL ',30);
19193 --UPD START
19194 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
19195 --
19196 if l_update then
19197 --
19198 l_datetrack_mode := r_LRR.datetrack_mode ;
19199 --
19200 get_dt_modes(
19201 p_effective_date => l_process_date,
19202 p_effective_end_date => r_LRR.information3,
19203 p_effective_start_date => r_LRR.information2,
19204 p_dml_operation => r_LRR.dml_operation,
19205 p_datetrack_mode => l_datetrack_mode );
19206 -- p_update => l_update
19207 --
19208 l_effective_date := l_process_date;
19209 l_LEE_RSN_RL_ID := r_LRR.information1;
19210 l_object_version_number := r_LRR.information265;
19211 --
19212 end if;
19213 --
19214 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
19215 --
19216 IF l_update OR l_dml_operation <> 'UPDATE' THEN
19217 --UPD END
19218 BEN_LEE_RSN_RL_API.UPDATE_LEE_RSN_RL(
19219 --
19220 P_VALIDATE => false
19221 ,P_EFFECTIVE_DATE => l_effective_date
19222 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19223 --
19224 ,P_FORMULA_ID => l_FORMULA_ID
19225 ,P_LEE_RSN_ID => l_LEE_RSN_ID
19226 ,P_LEE_RSN_RL_ID => l_lee_rsn_rl_id
19227 ,P_LRR_ATTRIBUTE1 => r_LRR.INFORMATION111
19228 ,P_LRR_ATTRIBUTE10 => r_LRR.INFORMATION120
19229 ,P_LRR_ATTRIBUTE11 => r_LRR.INFORMATION121
19230 ,P_LRR_ATTRIBUTE12 => r_LRR.INFORMATION122
19231 ,P_LRR_ATTRIBUTE13 => r_LRR.INFORMATION123
19232 ,P_LRR_ATTRIBUTE14 => r_LRR.INFORMATION124
19233 ,P_LRR_ATTRIBUTE15 => r_LRR.INFORMATION125
19234 ,P_LRR_ATTRIBUTE16 => r_LRR.INFORMATION126
19235 ,P_LRR_ATTRIBUTE17 => r_LRR.INFORMATION127
19236 ,P_LRR_ATTRIBUTE18 => r_LRR.INFORMATION128
19237 ,P_LRR_ATTRIBUTE19 => r_LRR.INFORMATION129
19238 ,P_LRR_ATTRIBUTE2 => r_LRR.INFORMATION112
19239 ,P_LRR_ATTRIBUTE20 => r_LRR.INFORMATION130
19240 ,P_LRR_ATTRIBUTE21 => r_LRR.INFORMATION131
19241 ,P_LRR_ATTRIBUTE22 => r_LRR.INFORMATION132
19242 ,P_LRR_ATTRIBUTE23 => r_LRR.INFORMATION133
19243 ,P_LRR_ATTRIBUTE24 => r_LRR.INFORMATION134
19244 ,P_LRR_ATTRIBUTE25 => r_LRR.INFORMATION135
19245 ,P_LRR_ATTRIBUTE26 => r_LRR.INFORMATION136
19246 ,P_LRR_ATTRIBUTE27 => r_LRR.INFORMATION137
19247 ,P_LRR_ATTRIBUTE28 => r_LRR.INFORMATION138
19248 ,P_LRR_ATTRIBUTE29 => r_LRR.INFORMATION139
19249 ,P_LRR_ATTRIBUTE3 => r_LRR.INFORMATION113
19250 ,P_LRR_ATTRIBUTE30 => r_LRR.INFORMATION140
19251 ,P_LRR_ATTRIBUTE4 => r_LRR.INFORMATION114
19252 ,P_LRR_ATTRIBUTE5 => r_LRR.INFORMATION115
19253 ,P_LRR_ATTRIBUTE6 => r_LRR.INFORMATION116
19254 ,P_LRR_ATTRIBUTE7 => r_LRR.INFORMATION117
19255 ,P_LRR_ATTRIBUTE8 => r_LRR.INFORMATION118
19256 ,P_LRR_ATTRIBUTE9 => r_LRR.INFORMATION119
19257 ,P_LRR_ATTRIBUTE_CATEGORY => r_LRR.INFORMATION110
19258 ,P_ORDR_TO_APLY_NUM => r_LRR.INFORMATION260
19259 --
19260 ,P_EFFECTIVE_START_DATE => l_effective_start_date
19261 ,P_EFFECTIVE_END_DATE => l_effective_end_date
19262 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
19263 ,P_DATETRACK_MODE => l_datetrack_mode
19264 );
19265 --
19266 end if; -- l_update
19267 end if;
19268 --
19269 -- Delete the row if it is end dated.
19270 --
19271 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
19272 trunc(l_max_eed) = r_LRR.information3) then
19273 --
19274 BEN_LEE_RSN_RL_API.delete_LEE_RSN_RL(
19275 --
19276 p_validate => false
19277 ,p_lee_rsn_rl_id => l_lee_rsn_rl_id
19278 ,p_effective_start_date => l_effective_start_date
19279 ,p_effective_end_date => l_effective_end_date
19280 ,p_object_version_number => l_object_version_number
19281 ,p_effective_date => l_max_eed
19282 ,p_datetrack_mode => hr_api.g_delete
19283 --
19284 );
19285 --
19286 end if;
19287 --
19288 l_prev_pk_id := l_current_pk_id ;
19289 --
19290 end if;
19291 --
19292 end if;
19293 --
19294 end loop;
19295 --
19296 exception when others then
19297 --
19298 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LRR',r_lrr.information5 );
19299 --
19300 end create_LRR_rows;
19301
19302 ---------------------------------------------------------------
19303 ----------------------< create_ADE_rows >-----------------------
19304 ---------------------------------------------------------------
19305 --
19306 procedure create_ADE_rows
19307 (
19308 p_validate in number default 0
19309 ,p_copy_entity_txn_id in number
19310 ,p_effective_date in date
19311 ,p_prefix_suffix_text in varchar2 default null
19312 ,p_reuse_object_flag in varchar2 default null
19313 ,p_target_business_group_id in varchar2 default null
19314 ,p_prefix_suffix_cd in varchar2 default null
19315 ) is
19316 --
19317 l_APLD_DPNT_CVG_ELIG_RL number;
19318 l_DPNT_CVG_ELIGY_PRFL_ID number;
19319 l_PGM_ID number;
19320 l_PL_ID number;
19321 l_PTIP_ID number;
19322 cursor c_unique_ADE(l_table_alias varchar2) is
19323 select distinct cpe.information1,
19324 cpe.information2,
19325 cpe.information3,
19326 cpe.table_route_id
19327 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
19328 pqh_table_route tr
19329 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19330 and cpe.table_route_id = tr.table_route_id
19331 -- and tr.where_clause = l_APLD_DPNT_CVG_ELIG_PRFL_F
19332 and tr.table_alias = l_table_alias
19333 and cpe.number_of_copies = 1 -- ADDITION
19334 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
19335 order by information1, information2; --added for bug: 5151945
19336 --
19337 --
19338 cursor c_ADE_min_max_dates(c_table_route_id number,
19339 c_information1 number) is
19340 select
19341 min(cpe.information2) min_esd,
19342 max(cpe.information3) min_eed
19343 from ben_copy_entity_results cpe
19344 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19345 and cpe.table_route_id = c_table_route_id
19346 and cpe.information1 = c_information1 ;
19347 --
19348 cursor c_ADE(c_table_route_id number,
19349 c_information1 number,
19350 c_information2 date,
19351 c_information3 date) is
19352 select
19353 cpe.*
19354 from ben_copy_entity_results cpe
19355 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19356 and cpe.table_route_id = c_table_route_id
19357 and cpe.information1 = c_information1
19358 and cpe.information2 = c_information2
19359 and cpe.information3 = c_information3
19360 and rownum = 1 ;
19361 -- Date Track target record
19362 cursor c_find_ADE_in_target(
19363 c_effective_start_date date,
19364 c_effective_end_date date,
19365 c_business_group_id number,
19366 c_new_pk_id number) is
19367 select
19368 ADE.apld_dpnt_cvg_elig_prfl_id new_value
19369 from BEN_APLD_DPNT_CVG_ELIG_PRFL_F ADE
19370 where
19371 ADE.DPNT_CVG_ELIGY_PRFL_ID = l_DPNT_CVG_ELIGY_PRFL_ID and
19372 nvl(ADE.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
19373 nvl(ADE.PL_ID,-999) = nvl(l_PL_ID,-999) and
19374 nvl(ADE.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
19375 ADE.business_group_id = c_business_group_id
19376 and ADE.apld_dpnt_cvg_elig_prfl_id <> c_new_pk_id
19377 --TEMPIK
19378 and c_effective_start_date between effective_start_date
19379 and effective_end_date ;
19380 --END TEMPIK
19381 /*TEMPIK
19382 and exists ( select null
19383 from BEN_APLD_DPNT_CVG_ELIG_PRFL_F ADE1
19384 where
19385 ADE1.DPNT_CVG_ELIGY_PRFL_ID = l_DPNT_CVG_ELIGY_PRFL_ID and
19386 nvl(ADE1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
19387 nvl(ADE1.PL_ID,-999) = nvl(l_PL_ID,-999) and
19388 nvl(ADE1.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
19389 ADE1.business_group_id = c_business_group_id
19390 and ADE1.effective_start_date <= c_effective_start_date )
19391 and exists ( select null
19392 from BEN_APLD_DPNT_CVG_ELIG_PRFL_F ADE2
19393 where
19394 ADE2.DPNT_CVG_ELIGY_PRFL_ID = l_DPNT_CVG_ELIGY_PRFL_ID and
19395 nvl(ADE2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
19396 nvl(ADE2.PL_ID,-999) = nvl(l_PL_ID,-999) and
19397 nvl(ADE2.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
19398 ADE2.business_group_id = c_business_group_id
19399 and ADE2.effective_end_date >= c_effective_end_date )
19400 ;
19401 */
19402 --
19403 --UPD START
19404 --
19405 l_update boolean := false ;
19406 l_datetrack_mode varchar2(80) := hr_api.g_update;
19407 l_process_date date;
19408 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
19409 --
19410 --UPD END
19411 l_current_pk_id number := null ;
19412 l_prev_pk_id number := null ;
19413 l_first_rec boolean := true ;
19414 r_ADE c_ADE%rowtype;
19415 l_apld_dpnt_cvg_elig_prfl_id number ;
19416 l_object_version_number number ;
19417 l_effective_start_date date ;
19418 l_effective_end_date date ;
19419 l_prefix pqh_copy_entity_attribs.information1%type := null;
19420 l_suffix pqh_copy_entity_attribs.information1%type := null;
19421 l_new_value number(15);
19422 l_object_found_in_target boolean := false ;
19423 l_min_esd date;
19424 l_max_eed date;
19425 l_effective_date date;
19426 --TEMPIK
19427 l_dt_rec_found boolean ;
19428 --END TEMPIK
19429 --
19430 begin
19431 -- Initialization
19432 l_object_found_in_target := false ;
19433 -- End Initialization
19434 -- Derive the prefix - sufix
19435 if p_prefix_suffix_cd = 'PREFIX' then
19436 l_prefix := p_prefix_suffix_text ;
19437 elsif p_prefix_suffix_cd = 'SUFFIX' then
19438 l_suffix := p_prefix_suffix_text ;
19439 else
19440 l_prefix := null ;
19441 l_suffix := null ;
19442 end if ;
19443 -- End Prefix Sufix derivation
19444 for r_ADE_unique in c_unique_ADE('ADE') loop
19445
19446 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
19447 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19448 r_ADE_unique.information3 >=
19449 ben_pd_copy_to_ben_one.g_copy_effective_date)
19450 ) then
19451 --
19452 hr_utility.set_location(' r_ADE_unique.table_route_id '||r_ADE_unique.table_route_id,10);
19453 hr_utility.set_location(' r_ADE_unique.information1 '||r_ADE_unique.information1,10);
19454 hr_utility.set_location( 'r_ADE_unique.information2 '||r_ADE_unique.information2,10);
19455 hr_utility.set_location( 'r_ADE_unique.information3 '||r_ADE_unique.information3,10);
19456 -- If reuse objects flag is 'Y' then check for the object in the target business group
19457 -- if found insert the record into PLSql table and exit the loop else try create the
19458 -- object in the target business group
19459 --
19460 l_object_found_in_target := false ;
19461 --UPD START
19462 open c_ADE(r_ADE_unique.table_route_id,
19463 r_ADE_unique.information1,
19464 r_ADE_unique.information2,
19465 r_ADE_unique.information3 ) ;
19466 --
19467 fetch c_ADE into r_ADE ;
19468 --
19469 close c_ADE ;
19470 l_dml_operation:= r_ADE_unique.dml_operation ;
19471 l_APLD_DPNT_CVG_ELIG_RL := get_fk('FORMULA_ID', r_ADE.information263,l_dml_operation );
19472 l_DPNT_CVG_ELIGY_PRFL_ID := get_fk('DPNT_CVG_ELIGY_PRFL_ID', r_ADE.information255,l_dml_operation );
19473 l_PGM_ID := get_fk('PGM_ID', r_ADE.information260,l_dml_operation );
19474 l_PL_ID := get_fk('PL_ID', r_ADE.information261,l_dml_operation );
19475 l_PTIP_ID := get_fk('PTIP_ID', r_ADE.information259,l_dml_operation );
19476 l_update := false;
19477 l_process_date := p_effective_date;
19478 --
19479 if l_dml_operation = 'UPDATE' then
19480 --
19481 l_object_found_in_target := TRUE;
19482 --
19483 if l_process_date between r_ADE_unique.information2 and r_ADE_unique.information3 then
19484 l_update := true;
19485 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)
19486 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'
19487 then
19488 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' ;
19489 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ADE_unique.information1 ;
19490 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ADE_unique.information1 ;
19491 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19492 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;
19493 --
19494 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
19495 --
19496 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19497 --
19498 --DOUBT log_data('ADE',l_new_value,l_prefix || r_ADE_unique.name|| l_suffix,'REUSED');
19499 --
19500 end if ;
19501 hr_utility.set_location( 'found record for update',10);
19502 --
19503 else
19504 --
19505 l_update := false;
19506 --
19507 end if;
19508 else
19509 --
19510 --UPD END
19511 l_min_esd := null ;
19512 l_max_eed := null ;
19513 open c_ADE_min_max_dates(r_ADE_unique.table_route_id, r_ADE_unique.information1 ) ;
19514 fetch c_ADE_min_max_dates into l_min_esd,l_max_eed ;
19515 --
19516
19517 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19518 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19519 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
19520 end if;
19521 l_min_esd := greatest(l_min_esd,r_ADE_unique.information2);
19522 /* open c_ADE(r_ADE_unique.table_route_id,
19523 r_ADE_unique.information1,
19524 r_ADE_unique.information2,
19525 r_ADE_unique.information3 ) ;
19526 --
19527 fetch c_ADE into r_ADE ;
19528 --
19529 close c_ADE ; */
19530 --
19531 if p_reuse_object_flag = 'Y' then
19532 if c_ADE_min_max_dates%found then
19533 -- cursor to find the object
19534 open c_find_ADE_in_target( l_min_esd,l_max_eed,
19535 p_target_business_group_id, nvl(l_apld_dpnt_cvg_elig_prfl_id, -999) ) ;
19536 fetch c_find_ADE_in_target into l_new_value ;
19537 if c_find_ADE_in_target%found then
19538 --
19539 --TEMPIK
19540 l_dt_rec_found := dt_api.check_min_max_dates
19541 (p_base_table_name => 'BEN_APLD_DPNT_CVG_ELIG_PRFL_F',
19542 p_base_key_column => 'APLD_DPNT_CVG_ELIG_PRFL_ID',
19543 p_base_key_value => l_new_value,
19544 p_from_date => l_min_esd,
19545 p_to_date => l_max_eed );
19546 if l_dt_rec_found THEN
19547 --END TEMPIK
19548 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
19549 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
19550 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' ;
19551 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ADE_unique.information1 ;
19552 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
19553 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19554 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;
19555 --
19556 -- 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) ;
19557 --
19558 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19559 end if ;
19560 --
19561 l_object_found_in_target := true ;
19562 --TEMPIK
19563 end if; -- l_dt_rec_found
19564 --END TEMPIK
19565 end if;
19566 close c_find_ADE_in_target ;
19567 --
19568 end if;
19569 end if ;
19570 --
19571 close c_ADE_min_max_dates ;
19572 end if; --if p_dml_operation
19573 --
19574 if not l_object_found_in_target OR l_update then
19575 --
19576 l_current_pk_id := r_ADE.information1;
19577 --
19578 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
19579 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
19580 --
19581 if l_current_pk_id = l_prev_pk_id then
19582 --
19583 l_first_rec := false ;
19584 --
19585 else
19586 --
19587 l_first_rec := true ;
19588 --
19589 end if ;
19590 --
19591
19592 l_effective_date := r_ADE.information2;
19593 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19594 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19595 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
19596 end if;
19597
19598 if l_first_rec and not l_update then
19599 -- Call Create routine.
19600 hr_utility.set_location(' BEN_APLD_DPNT_CVG_ELIG_PRFL_F CREATE_APLD_DPNT_CVG_PRFL ',20);
19601 BEN_APLD_DPNT_CVG_PRFL_API.CREATE_APLD_DPNT_CVG_PRFL(
19602 --
19603 P_VALIDATE => false
19604 ,P_EFFECTIVE_DATE => l_effective_date
19605 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19606 --
19607 ,P_ADE_ATTRIBUTE1 => r_ADE.INFORMATION111
19608 ,P_ADE_ATTRIBUTE10 => r_ADE.INFORMATION120
19609 ,P_ADE_ATTRIBUTE11 => r_ADE.INFORMATION121
19610 ,P_ADE_ATTRIBUTE12 => r_ADE.INFORMATION122
19611 ,P_ADE_ATTRIBUTE13 => r_ADE.INFORMATION123
19612 ,P_ADE_ATTRIBUTE14 => r_ADE.INFORMATION124
19613 ,P_ADE_ATTRIBUTE15 => r_ADE.INFORMATION125
19614 ,P_ADE_ATTRIBUTE16 => r_ADE.INFORMATION126
19615 ,P_ADE_ATTRIBUTE17 => r_ADE.INFORMATION127
19616 ,P_ADE_ATTRIBUTE18 => r_ADE.INFORMATION128
19617 ,P_ADE_ATTRIBUTE19 => r_ADE.INFORMATION129
19618 ,P_ADE_ATTRIBUTE2 => r_ADE.INFORMATION112
19619 ,P_ADE_ATTRIBUTE20 => r_ADE.INFORMATION130
19620 ,P_ADE_ATTRIBUTE21 => r_ADE.INFORMATION131
19621 ,P_ADE_ATTRIBUTE22 => r_ADE.INFORMATION132
19622 ,P_ADE_ATTRIBUTE23 => r_ADE.INFORMATION133
19623 ,P_ADE_ATTRIBUTE24 => r_ADE.INFORMATION134
19624 ,P_ADE_ATTRIBUTE25 => r_ADE.INFORMATION135
19625 ,P_ADE_ATTRIBUTE26 => r_ADE.INFORMATION136
19626 ,P_ADE_ATTRIBUTE27 => r_ADE.INFORMATION137
19627 ,P_ADE_ATTRIBUTE28 => r_ADE.INFORMATION138
19628 ,P_ADE_ATTRIBUTE29 => r_ADE.INFORMATION139
19629 ,P_ADE_ATTRIBUTE3 => r_ADE.INFORMATION113
19630 ,P_ADE_ATTRIBUTE30 => r_ADE.INFORMATION140
19631 ,P_ADE_ATTRIBUTE4 => r_ADE.INFORMATION114
19632 ,P_ADE_ATTRIBUTE5 => r_ADE.INFORMATION115
19633 ,P_ADE_ATTRIBUTE6 => r_ADE.INFORMATION116
19634 ,P_ADE_ATTRIBUTE7 => r_ADE.INFORMATION117
19635 ,P_ADE_ATTRIBUTE8 => r_ADE.INFORMATION118
19636 ,P_ADE_ATTRIBUTE9 => r_ADE.INFORMATION119
19637 ,P_ADE_ATTRIBUTE_CATEGORY => r_ADE.INFORMATION110
19638 ,P_APLD_DPNT_CVG_ELIG_PRFL_ID => l_apld_dpnt_cvg_elig_prfl_id
19639 ,P_APLD_DPNT_CVG_ELIG_RL => l_APLD_DPNT_CVG_ELIG_RL
19640 ,P_DPNT_CVG_ELIGY_PRFL_ID => l_DPNT_CVG_ELIGY_PRFL_ID
19641 ,P_MNDTRY_FLAG => r_ADE.INFORMATION11
19642 ,P_PGM_ID => l_PGM_ID
19643 ,P_PL_ID => l_PL_ID
19644 ,P_PTIP_ID => l_PTIP_ID
19645 --
19646 ,P_EFFECTIVE_START_DATE => l_effective_start_date
19647 ,P_EFFECTIVE_END_DATE => l_effective_end_date
19648 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
19649 );
19650 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
19651 -- Update all relevent cer records with new pk_id
19652 hr_utility.set_location('Before plsql table ',222);
19653 hr_utility.set_location('new_value id '||l_apld_dpnt_cvg_elig_prfl_id,222);
19654 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' ;
19655 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ADE.information1 ;
19656 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 ;
19657 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
19658 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;
19659 hr_utility.set_location('After plsql table ',222);
19660 --
19661 -- 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 ) ;
19662 --
19663 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19664 --
19665 else
19666 --
19667 -- Call Update routine for the pk_id created in prev run .
19668 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
19669 hr_utility.set_location(' BEN_APLD_DPNT_CVG_ELIG_PRFL_F UPDATE_APLD_DPNT_CVG_PRFL ',30);
19670 --UPD START
19671 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
19672 --
19673 if l_update then
19674 --
19675 l_datetrack_mode := r_ADE.datetrack_mode ;
19676 --
19677 get_dt_modes(
19678 p_effective_date => l_process_date,
19679 p_effective_end_date => r_ADE.information3,
19680 p_effective_start_date => r_ADE.information2,
19681 p_dml_operation => r_ADE.dml_operation,
19682 p_datetrack_mode => l_datetrack_mode );
19683 -- p_update => l_update
19684 --
19685 l_effective_date := l_process_date;
19686 l_APLD_DPNT_CVG_ELIG_PRFL_ID := r_ADE.information1;
19687 l_object_version_number := r_ADE.information265;
19688 --
19689 end if;
19690 --
19691 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
19692 --
19693 IF l_update OR l_dml_operation <> 'UPDATE' THEN
19694 --UPD END
19695 BEN_APLD_DPNT_CVG_PRFL_API.UPDATE_APLD_DPNT_CVG_PRFL(
19696 --
19697 P_VALIDATE => false
19698 ,P_EFFECTIVE_DATE => l_effective_date
19699 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
19700 --
19701 ,P_ADE_ATTRIBUTE1 => r_ADE.INFORMATION111
19702 ,P_ADE_ATTRIBUTE10 => r_ADE.INFORMATION120
19703 ,P_ADE_ATTRIBUTE11 => r_ADE.INFORMATION121
19704 ,P_ADE_ATTRIBUTE12 => r_ADE.INFORMATION122
19705 ,P_ADE_ATTRIBUTE13 => r_ADE.INFORMATION123
19706 ,P_ADE_ATTRIBUTE14 => r_ADE.INFORMATION124
19707 ,P_ADE_ATTRIBUTE15 => r_ADE.INFORMATION125
19708 ,P_ADE_ATTRIBUTE16 => r_ADE.INFORMATION126
19709 ,P_ADE_ATTRIBUTE17 => r_ADE.INFORMATION127
19710 ,P_ADE_ATTRIBUTE18 => r_ADE.INFORMATION128
19711 ,P_ADE_ATTRIBUTE19 => r_ADE.INFORMATION129
19712 ,P_ADE_ATTRIBUTE2 => r_ADE.INFORMATION112
19713 ,P_ADE_ATTRIBUTE20 => r_ADE.INFORMATION130
19714 ,P_ADE_ATTRIBUTE21 => r_ADE.INFORMATION131
19715 ,P_ADE_ATTRIBUTE22 => r_ADE.INFORMATION132
19716 ,P_ADE_ATTRIBUTE23 => r_ADE.INFORMATION133
19717 ,P_ADE_ATTRIBUTE24 => r_ADE.INFORMATION134
19718 ,P_ADE_ATTRIBUTE25 => r_ADE.INFORMATION135
19719 ,P_ADE_ATTRIBUTE26 => r_ADE.INFORMATION136
19720 ,P_ADE_ATTRIBUTE27 => r_ADE.INFORMATION137
19721 ,P_ADE_ATTRIBUTE28 => r_ADE.INFORMATION138
19722 ,P_ADE_ATTRIBUTE29 => r_ADE.INFORMATION139
19723 ,P_ADE_ATTRIBUTE3 => r_ADE.INFORMATION113
19724 ,P_ADE_ATTRIBUTE30 => r_ADE.INFORMATION140
19725 ,P_ADE_ATTRIBUTE4 => r_ADE.INFORMATION114
19726 ,P_ADE_ATTRIBUTE5 => r_ADE.INFORMATION115
19727 ,P_ADE_ATTRIBUTE6 => r_ADE.INFORMATION116
19728 ,P_ADE_ATTRIBUTE7 => r_ADE.INFORMATION117
19729 ,P_ADE_ATTRIBUTE8 => r_ADE.INFORMATION118
19730 ,P_ADE_ATTRIBUTE9 => r_ADE.INFORMATION119
19731 ,P_ADE_ATTRIBUTE_CATEGORY => r_ADE.INFORMATION110
19732 ,P_APLD_DPNT_CVG_ELIG_PRFL_ID => l_apld_dpnt_cvg_elig_prfl_id
19733 ,P_APLD_DPNT_CVG_ELIG_RL => l_APLD_DPNT_CVG_ELIG_RL
19734 ,P_DPNT_CVG_ELIGY_PRFL_ID => l_DPNT_CVG_ELIGY_PRFL_ID
19735 ,P_MNDTRY_FLAG => r_ADE.INFORMATION11
19736 ,P_PGM_ID => l_PGM_ID
19737 ,P_PL_ID => l_PL_ID
19738 ,P_PTIP_ID => l_PTIP_ID
19739 --
19740 ,P_EFFECTIVE_START_DATE => l_effective_start_date
19741 ,P_EFFECTIVE_END_DATE => l_effective_end_date
19742 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
19743 ,P_DATETRACK_MODE => l_datetrack_mode
19744 );
19745 --
19746 end if; -- l_update
19747 end if;
19748 --
19749 -- Delete the row if it is end dated.
19750 --
19751 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
19752 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
19753 trunc(l_max_eed) = r_ADE.information3) then
19754 --
19755 BEN_APLD_DPNT_CVG_PRFL_API.delete_APLD_DPNT_CVG_PRFL(
19756 --
19757 p_validate => false
19758 ,p_apld_dpnt_cvg_elig_prfl_id => l_apld_dpnt_cvg_elig_prfl_id
19759 ,p_effective_start_date => l_effective_start_date
19760 ,p_effective_end_date => l_effective_end_date
19761 ,p_object_version_number => l_object_version_number
19762 ,p_effective_date => l_max_eed
19763 ,p_datetrack_mode => hr_api.g_delete
19764 --
19765 );
19766 --
19767 end if;
19768 --
19769 l_prev_pk_id := l_current_pk_id ;
19770 --
19771 end if;
19772 --
19773 end if;
19774 --
19775 end loop;
19776 --
19777 exception when others then
19778 --
19779 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ADE',r_ade.information5 );
19780 --
19781 end create_ADE_rows;
19782
19783 --
19784 ---------------------------------------------------------------
19785 ----------------------< create_PGC_rows >-----------------------
19786 ---------------------------------------------------------------
19787 --
19788 procedure create_PGC_rows
19789 (
19790 p_validate in number default 0
19791 ,p_copy_entity_txn_id in number
19792 ,p_effective_date in date
19793 ,p_prefix_suffix_text in varchar2 default null
19794 ,p_reuse_object_flag in varchar2 default null
19795 ,p_target_business_group_id in varchar2 default null
19796 ,p_prefix_suffix_cd in varchar2 default null
19797 ) is
19798 --
19799 l_CTFN_RQD_WHEN_RL number;
19800 l_PGM_ID number;
19801 l_DPNT_CVG_CTFN_TYP_CD varchar2(30);
19802 cursor c_unique_PGC(l_table_alias varchar2) is
19803 select distinct cpe.information1,
19804 cpe.information2,
19805 cpe.information3,
19806 cpe.table_route_id
19807 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
19808 pqh_table_route tr
19809 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19810 and cpe.table_route_id = tr.table_route_id
19811 -- and tr.where_clause = l_BEN_PGM_DPNT_CVG_CTFN_F
19812 and tr.table_alias = l_table_alias
19813 and cpe.number_of_copies = 1 -- ADDITION
19814 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
19815 order by information1, information2; --added for bug: 5151945
19816 --
19817 --
19818 cursor c_PGC_min_max_dates(c_table_route_id number,
19819 c_information1 number) is
19820 select
19821 min(cpe.information2) min_esd,
19822 max(cpe.information3) min_eed
19823 from ben_copy_entity_results cpe
19824 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19825 and cpe.table_route_id = c_table_route_id
19826 and cpe.information1 = c_information1 ;
19827 --
19828 cursor c_PGC(c_table_route_id number,
19829 c_information1 number,
19830 c_information2 date,
19831 c_information3 date ) is
19832 select
19833 cpe.*
19834 from ben_copy_entity_results cpe
19835 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
19836 and cpe.table_route_id = c_table_route_id
19837 and cpe.information1 = c_information1
19838 and cpe.information2 = c_information2
19839 and cpe.information3 = c_information3
19840 and rownum = 1 ;
19841 -- Date Track target record
19842 cursor c_find_PGC_in_target(
19843 c_effective_start_date date,
19844 c_effective_end_date date,
19845 c_business_group_id number,
19846 c_new_pk_id number) is
19847 select
19848 PGC.pgm_dpnt_cvg_ctfn_id new_value
19849 from BEN_PGM_DPNT_CVG_CTFN_F PGC
19850 where
19851 PGC.PGM_ID = l_PGM_ID and
19852 PGC.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
19853 PGC.business_group_id = c_business_group_id
19854 and PGC.pgm_dpnt_cvg_ctfn_id <> c_new_pk_id
19855 --TEMPIK
19856 and c_effective_start_date between effective_start_date
19857 and effective_end_date ;
19858 --END TEMPIK
19859 /*TEMPIK
19860 and exists ( select null
19861 from BEN_PGM_DPNT_CVG_CTFN_F PGC1
19862 where
19863 PGC1.PGM_ID = l_PGM_ID and
19864 PGC1.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
19865 PGC1.business_group_id = c_business_group_id
19866 and PGC1.effective_start_date <= c_effective_start_date )
19867 and exists ( select null
19868 from BEN_PGM_DPNT_CVG_CTFN_F PGC2
19869 where
19870 PGC2.PGM_ID = l_PGM_ID and
19871 PGC2.DPNT_CVG_CTFN_TYP_CD = l_DPNT_CVG_CTFN_TYP_CD and
19872 PGC2.business_group_id = c_business_group_id
19873 and PGC2.effective_end_date >= c_effective_end_date )
19874 ;
19875 */
19876 --
19877 --UPD START
19878 --
19879 l_update boolean := false ;
19880 l_datetrack_mode varchar2(80) := hr_api.g_update;
19881 l_process_date date;
19882 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
19883 --
19884 --UPD END
19885 l_current_pk_id number := null ;
19886 l_prev_pk_id number := null ;
19887 l_first_rec boolean := true ;
19888 r_PGC c_PGC%rowtype;
19889 l_pgm_dpnt_cvg_ctfn_id number ;
19890 l_object_version_number number ;
19891 l_effective_start_date date ;
19892 l_effective_end_date date ;
19893 l_prefix pqh_copy_entity_attribs.information1%type := null;
19894 l_suffix pqh_copy_entity_attribs.information1%type := null;
19895 l_new_value number(15);
19896 l_object_found_in_target boolean := false ;
19897 l_min_esd date;
19898 l_max_eed date;
19899 l_effective_date date;
19900 --TEMPIK
19901 l_dt_rec_found boolean ;
19902 --END TEMPIK
19903 --
19904 begin
19905 -- Initialization
19906 l_object_found_in_target := false ;
19907 -- End Initialization
19908 -- Derive the prefix - sufix
19909 if p_prefix_suffix_cd = 'PREFIX' then
19910 l_prefix := p_prefix_suffix_text ;
19911 elsif p_prefix_suffix_cd = 'SUFFIX' then
19912 l_suffix := p_prefix_suffix_text ;
19913 else
19914 l_prefix := null ;
19915 l_suffix := null ;
19916 end if ;
19917 -- End Prefix Sufix derivation
19918 for r_PGC_unique in c_unique_PGC('PGC') loop
19919
19920 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
19921 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19922 r_PGC_unique.information3 >=
19923 ben_pd_copy_to_ben_one.g_copy_effective_date)
19924 ) then
19925 --
19926 hr_utility.set_location(' r_PGC_unique.table_route_id '||r_PGC_unique.table_route_id,10);
19927 hr_utility.set_location(' r_PGC_unique.information1 '||r_PGC_unique.information1,10);
19928 hr_utility.set_location( 'r_PGC_unique.information2 '||r_PGC_unique.information2,10);
19929 hr_utility.set_location( 'r_PGC_unique.information3 '||r_PGC_unique.information3,10);
19930 -- If reuse objects flag is 'Y' then check for the object in the target business group
19931 -- if found insert the record into PLSql table and exit the loop else try create the
19932 -- object in the target business group
19933 --
19934 l_object_found_in_target := false ;
19935 --UPD START
19936 open c_PGC(r_PGC_unique.table_route_id,
19937 r_PGC_unique.information1,
19938 r_PGC_unique.information2,
19939 r_PGC_unique.information3 ) ;
19940 --
19941 fetch c_PGC into r_PGC ;
19942 --
19943 close c_PGC ;
19944 l_dml_operation:= r_PGC_unique.dml_operation ;
19945 l_CTFN_RQD_WHEN_RL := get_fk('FORMULA_ID', r_PGC.INFORMATION261,l_dml_operation );
19946 l_PGM_ID := get_fk('PGM_ID', r_PGC.INFORMATION260,l_dml_operation );
19947 l_update := false;
19948 l_process_date := p_effective_date;
19949 --
19950 if l_dml_operation = 'UPDATE' then
19951 --
19952 l_object_found_in_target := TRUE;
19953 --
19954 if l_process_date between r_PGC_unique.information2 and r_PGC_unique.information3 then
19955 l_update := true;
19956 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)
19957 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'
19958 then
19959 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' ;
19960 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PGC_unique.information1 ;
19961 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PGC_unique.information1 ;
19962 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
19963 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;
19964 --
19965 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
19966 --
19967 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
19968 --
19969 --DOUBT log_data('PGC',l_new_value,l_prefix || r_PGC_unique.name|| l_suffix,'REUSED');
19970 --
19971 end if ;
19972 hr_utility.set_location( 'found record for update',10);
19973 --
19974 else
19975 --
19976 l_update := false;
19977 --
19978 end if;
19979 else
19980 --
19981 --UPD END
19982 l_min_esd := null ;
19983 l_max_eed := null ;
19984 open c_PGC_min_max_dates(r_PGC_unique.table_route_id, r_PGC_unique.information1 ) ;
19985 fetch c_PGC_min_max_dates into l_min_esd,l_max_eed ;
19986 --
19987
19988 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
19989 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
19990 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
19991 end if;
19992 l_min_esd := greatest(l_min_esd,r_PGC_unique.information2);
19993 /* open c_PGC(r_PGC_unique.table_route_id,
19994 r_PGC_unique.information1,
19995 r_PGC_unique.information2,
19996 r_PGC_unique.information3 ) ;
19997 --
19998 fetch c_PGC into r_PGC ;
19999 --
20000 close c_PGC ; */
20001 --
20002 l_DPNT_CVG_CTFN_TYP_CD := r_PGC.information13 ;
20003 if p_reuse_object_flag = 'Y' then
20004 if c_PGC_min_max_dates%found then
20005 -- cursor to find the object
20006 open c_find_PGC_in_target( l_min_esd,l_max_eed,
20007 p_target_business_group_id, nvl(l_pgm_dpnt_cvg_ctfn_id, -999) ) ;
20008 fetch c_find_PGC_in_target into l_new_value ;
20009 if c_find_PGC_in_target%found then
20010 --
20011 --TEMPIK
20012 l_dt_rec_found := dt_api.check_min_max_dates
20013 (p_base_table_name => 'BEN_PGM_DPNT_CVG_CTFN_F',
20014 p_base_key_column => 'PGM_DPNT_CVG_CTFN_ID',
20015 p_base_key_value => l_new_value,
20016 p_from_date => l_min_esd,
20017 p_to_date => l_max_eed );
20018 if l_dt_rec_found THEN
20019 --END TEMPIK
20020 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
20021 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
20022 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' ;
20023 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PGC_unique.information1 ;
20024 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
20025 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
20026 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;
20027 --
20028 -- 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) ;
20029 --
20030 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20031 end if ;
20032 --
20033 l_object_found_in_target := true ;
20034 --TEMPIK
20035 end if; -- l_dt_rec_found
20036 --END TEMPIK
20037 end if;
20038 close c_find_PGC_in_target ;
20039 --
20040 end if;
20041 end if ;
20042 --
20043 close c_PGC_min_max_dates ;
20044 end if; --if p_dml_operation
20045 --
20046 if not l_object_found_in_target OR l_update then
20047 --
20048 l_current_pk_id := r_PGC.information1;
20049 --
20050 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
20051 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
20052 --
20053 if l_current_pk_id = l_prev_pk_id then
20054 --
20055 l_first_rec := false ;
20056 --
20057 else
20058 --
20059 l_first_rec := true ;
20060 --
20061 end if ;
20062 --
20063
20064 l_effective_date := r_PGC.information2;
20065 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20066 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
20067 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
20068 end if;
20069
20070 if l_first_rec and not l_update then
20071 -- Call Create routine.
20072 hr_utility.set_location(' BEN_PGM_DPNT_CVG_CTFN_F CREATE_PROGRAM_DPNT_CVG_CTFN ',20);
20073 BEN_PROGRAM_DPNT_CVG_CTFN_API.CREATE_PROGRAM_DPNT_CVG_CTFN(
20074 --
20075 P_VALIDATE => false
20076 ,P_EFFECTIVE_DATE => l_effective_date
20077 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
20078 --
20079 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
20080 ,P_DPNT_CVG_CTFN_TYP_CD => r_PGC.INFORMATION13
20081 ,P_LACK_CTFN_SSPND_ENRT_FLAG => r_PGC.INFORMATION11
20082 ,P_PFD_FLAG => r_PGC.INFORMATION12
20083 ,P_PGC_ATTRIBUTE1 => r_PGC.INFORMATION111
20084 ,P_PGC_ATTRIBUTE10 => r_PGC.INFORMATION120
20085 ,P_PGC_ATTRIBUTE11 => r_PGC.INFORMATION121
20086 ,P_PGC_ATTRIBUTE12 => r_PGC.INFORMATION122
20087 ,P_PGC_ATTRIBUTE13 => r_PGC.INFORMATION123
20088 ,P_PGC_ATTRIBUTE14 => r_PGC.INFORMATION124
20089 ,P_PGC_ATTRIBUTE15 => r_PGC.INFORMATION125
20090 ,P_PGC_ATTRIBUTE16 => r_PGC.INFORMATION126
20091 ,P_PGC_ATTRIBUTE17 => r_PGC.INFORMATION127
20092 ,P_PGC_ATTRIBUTE18 => r_PGC.INFORMATION128
20093 ,P_PGC_ATTRIBUTE19 => r_PGC.INFORMATION129
20094 ,P_PGC_ATTRIBUTE2 => r_PGC.INFORMATION112
20095 ,P_PGC_ATTRIBUTE20 => r_PGC.INFORMATION130
20096 ,P_PGC_ATTRIBUTE21 => r_PGC.INFORMATION131
20097 ,P_PGC_ATTRIBUTE22 => r_PGC.INFORMATION132
20098 ,P_PGC_ATTRIBUTE23 => r_PGC.INFORMATION133
20099 ,P_PGC_ATTRIBUTE24 => r_PGC.INFORMATION134
20100 ,P_PGC_ATTRIBUTE25 => r_PGC.INFORMATION135
20101 ,P_PGC_ATTRIBUTE26 => r_PGC.INFORMATION136
20102 ,P_PGC_ATTRIBUTE27 => r_PGC.INFORMATION137
20103 ,P_PGC_ATTRIBUTE28 => r_PGC.INFORMATION138
20104 ,P_PGC_ATTRIBUTE29 => r_PGC.INFORMATION139
20105 ,P_PGC_ATTRIBUTE3 => r_PGC.INFORMATION113
20106 ,P_PGC_ATTRIBUTE30 => r_PGC.INFORMATION140
20107 ,P_PGC_ATTRIBUTE4 => r_PGC.INFORMATION114
20108 ,P_PGC_ATTRIBUTE5 => r_PGC.INFORMATION115
20109 ,P_PGC_ATTRIBUTE6 => r_PGC.INFORMATION116
20110 ,P_PGC_ATTRIBUTE7 => r_PGC.INFORMATION117
20111 ,P_PGC_ATTRIBUTE8 => r_PGC.INFORMATION118
20112 ,P_PGC_ATTRIBUTE9 => r_PGC.INFORMATION119
20113 ,P_PGC_ATTRIBUTE_CATEGORY => r_PGC.INFORMATION110
20114 ,P_PGM_DPNT_CVG_CTFN_ID => l_pgm_dpnt_cvg_ctfn_id
20115 ,P_PGM_ID => l_PGM_ID
20116 ,P_RLSHP_TYP_CD => r_PGC.INFORMATION15
20117 ,P_RQD_FLAG => r_PGC.INFORMATION14
20118 --
20119 ,P_EFFECTIVE_START_DATE => l_effective_start_date
20120 ,P_EFFECTIVE_END_DATE => l_effective_end_date
20121 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
20122 );
20123 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
20124 -- Update all relevent cer records with new pk_id
20125 hr_utility.set_location('Before plsql table ',222);
20126 hr_utility.set_location('new_value id '||l_pgm_dpnt_cvg_ctfn_id,222);
20127 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' ;
20128 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PGC.information1 ;
20129 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 ;
20130 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
20131 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;
20132 hr_utility.set_location('After plsql table ',222);
20133 --
20134 -- 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 ) ;
20135 --
20136 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20137 --
20138 else
20139 --
20140 -- Call Update routine for the pk_id created in prev run .
20141 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
20142 hr_utility.set_location(' BEN_PGM_DPNT_CVG_CTFN_F UPDATE_PROGRAM_DPNT_CVG_CTFN ',30);
20143 --UPD START
20144 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
20145 --
20146 if l_update then
20147 --
20148 l_datetrack_mode := r_PGC.datetrack_mode ;
20149 --
20150 get_dt_modes(
20151 p_effective_date => l_process_date,
20152 p_effective_end_date => r_PGC.information3,
20153 p_effective_start_date => r_PGC.information2,
20154 p_dml_operation => r_PGC.dml_operation,
20155 p_datetrack_mode => l_datetrack_mode );
20156 -- p_update => l_update
20157 --
20158 l_effective_date := l_process_date;
20159 l_PGM_DPNT_CVG_CTFN_ID := r_PGC.information1;
20160 l_object_version_number := r_PGC.information265;
20161 --
20162 end if;
20163 --
20164 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
20165 --
20166 IF l_update OR l_dml_operation <> 'UPDATE' THEN
20167 --UPD END
20168 BEN_PROGRAM_DPNT_CVG_CTFN_API.UPDATE_PROGRAM_DPNT_CVG_CTFN(
20169 --
20170 P_VALIDATE => false
20171 ,P_EFFECTIVE_DATE => l_effective_date
20172 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
20173 --
20174 ,P_CTFN_RQD_WHEN_RL => l_CTFN_RQD_WHEN_RL
20175 ,P_DPNT_CVG_CTFN_TYP_CD => r_PGC.INFORMATION13
20176 ,P_LACK_CTFN_SSPND_ENRT_FLAG => r_PGC.INFORMATION11
20177 ,P_PFD_FLAG => r_PGC.INFORMATION12
20178 ,P_PGC_ATTRIBUTE1 => r_PGC.INFORMATION111
20179 ,P_PGC_ATTRIBUTE10 => r_PGC.INFORMATION120
20180 ,P_PGC_ATTRIBUTE11 => r_PGC.INFORMATION121
20181 ,P_PGC_ATTRIBUTE12 => r_PGC.INFORMATION122
20182 ,P_PGC_ATTRIBUTE13 => r_PGC.INFORMATION123
20183 ,P_PGC_ATTRIBUTE14 => r_PGC.INFORMATION124
20184 ,P_PGC_ATTRIBUTE15 => r_PGC.INFORMATION125
20185 ,P_PGC_ATTRIBUTE16 => r_PGC.INFORMATION126
20186 ,P_PGC_ATTRIBUTE17 => r_PGC.INFORMATION127
20187 ,P_PGC_ATTRIBUTE18 => r_PGC.INFORMATION128
20188 ,P_PGC_ATTRIBUTE19 => r_PGC.INFORMATION129
20189 ,P_PGC_ATTRIBUTE2 => r_PGC.INFORMATION112
20190 ,P_PGC_ATTRIBUTE20 => r_PGC.INFORMATION130
20191 ,P_PGC_ATTRIBUTE21 => r_PGC.INFORMATION131
20192 ,P_PGC_ATTRIBUTE22 => r_PGC.INFORMATION132
20193 ,P_PGC_ATTRIBUTE23 => r_PGC.INFORMATION133
20194 ,P_PGC_ATTRIBUTE24 => r_PGC.INFORMATION134
20195 ,P_PGC_ATTRIBUTE25 => r_PGC.INFORMATION135
20196 ,P_PGC_ATTRIBUTE26 => r_PGC.INFORMATION136
20197 ,P_PGC_ATTRIBUTE27 => r_PGC.INFORMATION137
20198 ,P_PGC_ATTRIBUTE28 => r_PGC.INFORMATION138
20199 ,P_PGC_ATTRIBUTE29 => r_PGC.INFORMATION139
20200 ,P_PGC_ATTRIBUTE3 => r_PGC.INFORMATION113
20201 ,P_PGC_ATTRIBUTE30 => r_PGC.INFORMATION140
20202 ,P_PGC_ATTRIBUTE4 => r_PGC.INFORMATION114
20203 ,P_PGC_ATTRIBUTE5 => r_PGC.INFORMATION115
20204 ,P_PGC_ATTRIBUTE6 => r_PGC.INFORMATION116
20205 ,P_PGC_ATTRIBUTE7 => r_PGC.INFORMATION117
20206 ,P_PGC_ATTRIBUTE8 => r_PGC.INFORMATION118
20207 ,P_PGC_ATTRIBUTE9 => r_PGC.INFORMATION119
20208 ,P_PGC_ATTRIBUTE_CATEGORY => r_PGC.INFORMATION110
20209 ,P_PGM_DPNT_CVG_CTFN_ID => l_pgm_dpnt_cvg_ctfn_id
20210 ,P_PGM_ID => l_PGM_ID
20211 ,P_RLSHP_TYP_CD => r_PGC.INFORMATION15
20212 ,P_RQD_FLAG => r_PGC.INFORMATION14
20213 --
20214 ,P_EFFECTIVE_START_DATE => l_effective_start_date
20215 ,P_EFFECTIVE_END_DATE => l_effective_end_date
20216 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
20217 ,P_DATETRACK_MODE => l_datetrack_mode
20218 );
20219 --
20220 end if; -- l_update
20221 end if;
20222 --
20223 -- Delete the row if it is end dated.
20224 --
20225 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
20226 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
20227 trunc(l_max_eed) = r_PGC.information3) then
20228 --
20229 BEN_PROGRAM_DPNT_CVG_CTFN_API.delete_PROGRAM_DPNT_CVG_CTFN(
20230 --
20231 p_validate => false
20232 ,p_pgm_dpnt_cvg_ctfn_id => l_pgm_dpnt_cvg_ctfn_id
20233 ,p_effective_start_date => l_effective_start_date
20234 ,p_effective_end_date => l_effective_end_date
20235 ,p_object_version_number => l_object_version_number
20236 ,p_effective_date => l_max_eed
20237 ,p_datetrack_mode => hr_api.g_delete
20238 --
20239 );
20240 --
20241 end if;
20242 --
20243 l_prev_pk_id := l_current_pk_id ;
20244 --
20245 end if;
20246 --
20247 end if;
20248 --
20249 end loop;
20250 --
20251 exception when others then
20252 --
20253 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PGC',r_pgc.information5 );
20254 --
20255 end create_PGC_rows;
20256
20257 ---------------------------------------------------------------
20258 ----------------------< create_LGE_rows >-----------------------
20259 ---------------------------------------------------------------
20260 --
20261 procedure create_LGE_rows
20262 (
20263 p_validate in number default 0
20264 ,p_copy_entity_txn_id in number
20265 ,p_effective_date in date
20266 ,p_prefix_suffix_text in varchar2 default null
20267 ,p_reuse_object_flag in varchar2 default null
20268 ,p_target_business_group_id in varchar2 default null
20269 ,p_prefix_suffix_cd in varchar2 default null
20270 ) is
20271 --
20272 l_AUTO_ENRT_MTHD_RL number;
20273 l_DFLT_ENRT_RL number;
20274 l_ENRT_RL number;
20275 l_LER_ID number;
20276 l_PGM_ID number;
20277 cursor c_unique_LGE(l_table_alias varchar2) is
20278 select distinct cpe.information1,
20279 cpe.information2,
20280 cpe.information3,
20281 cpe.table_route_id
20282 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
20283 pqh_table_route tr
20284 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20285 and cpe.table_route_id = tr.table_route_id
20286 -- and tr.where_clause = l_BEN_LER_CHG_PGM_ENRT_F
20287 and tr.table_alias = l_table_alias
20288 and cpe.number_of_copies = 1 -- ADDITION
20289 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
20290 order by information1, information2; --added for bug: 5151945
20291 --
20292 --
20293 cursor c_LGE_min_max_dates(c_table_route_id number,
20294 c_information1 number) is
20295 select
20296 min(cpe.information2) min_esd,
20297 max(cpe.information3) min_eed
20298 from ben_copy_entity_results cpe
20299 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20300 and cpe.table_route_id = c_table_route_id
20301 and cpe.information1 = c_information1 ;
20302 --
20303 cursor c_LGE(c_table_route_id number,
20304 c_information1 number,
20305 c_information2 date,
20306 c_information3 date ) is
20307 select
20308 cpe.*
20309 from ben_copy_entity_results cpe
20310 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20311 and cpe.table_route_id = c_table_route_id
20312 and cpe.information1 = c_information1
20313 and cpe.information2 = c_information2
20314 and cpe.information3 = c_information3
20315 and rownum = 1 ;
20316 -- Date Track target record
20317 cursor c_find_LGE_in_target(
20318 c_effective_start_date date,
20319 c_effective_end_date date,
20320 c_business_group_id number,
20321 c_new_pk_id number) is
20322 select
20323 LGE.ler_chg_pgm_enrt_id new_value
20324 from BEN_LER_CHG_PGM_ENRT_F LGE
20325 where
20326 LGE.LER_ID = l_LER_ID and
20327 LGE.PGM_ID = l_PGM_ID and
20328 LGE.business_group_id = c_business_group_id
20329 and LGE.ler_chg_pgm_enrt_id <> c_new_pk_id
20330 --TEMPIK
20331 and c_effective_start_date between effective_start_date
20332 and effective_end_date ;
20333 --END TEMPIK
20334 /*TEMPIK
20335 and exists ( select null
20336 from BEN_LER_CHG_PGM_ENRT_F LGE1
20337 where
20338 LGE1.LER_ID = l_LER_ID and
20339 LGE1.PGM_ID = l_PGM_ID and
20340 LGE1.business_group_id = c_business_group_id
20341 and LGE1.effective_start_date <= c_effective_start_date )
20342 and exists ( select null
20343 from BEN_LER_CHG_PGM_ENRT_F LGE2
20344 where
20345 LGE2.LER_ID = l_LER_ID and
20346 LGE2.PGM_ID = l_PGM_ID and
20347 LGE2.business_group_id = c_business_group_id
20348 and LGE2.effective_end_date >= c_effective_end_date )
20349 ;
20350 */
20351 --
20352 --UPD START
20353 --
20354 l_update boolean := false ;
20355 l_datetrack_mode varchar2(80) := hr_api.g_update;
20356 l_process_date date;
20357 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
20358 --
20359 --UPD END
20360 l_current_pk_id number := null ;
20361 l_prev_pk_id number := null ;
20362 l_first_rec boolean := true ;
20363 r_LGE c_LGE%rowtype;
20364 l_ler_chg_pgm_enrt_id number ;
20365 l_object_version_number number ;
20366 l_effective_start_date date ;
20367 l_effective_end_date date ;
20368 l_prefix pqh_copy_entity_attribs.information1%type := null;
20369 l_suffix pqh_copy_entity_attribs.information1%type := null;
20370 l_new_value number(15);
20371 l_object_found_in_target boolean := false ;
20372 l_min_esd date;
20373 l_max_eed date;
20374 l_effective_date date;
20375 --TEMPIK
20376 l_dt_rec_found boolean ;
20377 --END TEMPIK
20378 --
20379 begin
20380 -- Initialization
20381 l_object_found_in_target := false ;
20382 -- End Initialization
20383 -- Derive the prefix - sufix
20384 if p_prefix_suffix_cd = 'PREFIX' then
20385 l_prefix := p_prefix_suffix_text ;
20386 elsif p_prefix_suffix_cd = 'SUFFIX' then
20387 l_suffix := p_prefix_suffix_text ;
20388 else
20389 l_prefix := null ;
20390 l_suffix := null ;
20391 end if ;
20392 -- End Prefix Sufix derivation
20393 for r_LGE_unique in c_unique_LGE('LGE') loop
20394
20395 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
20396 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20397 r_LGE_unique.information3 >=
20398 ben_pd_copy_to_ben_one.g_copy_effective_date)
20399 ) then
20400 --
20401 hr_utility.set_location(' r_LGE_unique.table_route_id '||r_LGE_unique.table_route_id,10);
20402 hr_utility.set_location(' r_LGE_unique.information1 '||r_LGE_unique.information1,10);
20403 hr_utility.set_location( 'r_LGE_unique.information2 '||r_LGE_unique.information2,10);
20404 hr_utility.set_location( 'r_LGE_unique.information3 '||r_LGE_unique.information3,10);
20405 -- If reuse objects flag is 'Y' then check for the object in the target business group
20406 -- if found insert the record into PLSql table and exit the loop else try create the
20407 -- object in the target business group
20408 --
20409 l_object_found_in_target := false ;
20410 --UPD START
20411 open c_LGE(r_LGE_unique.table_route_id,
20412 r_LGE_unique.information1,
20413 r_LGE_unique.information2,
20414 r_LGE_unique.information3 ) ;
20415 --
20416 fetch c_LGE into r_LGE ;
20417 --
20418 close c_LGE ;
20419 --
20420 l_dml_operation:= r_LGE_unique.dml_operation ;
20421 l_AUTO_ENRT_MTHD_RL := get_fk('FORMULA_ID', r_LGE.INFORMATION262,l_dml_operation );
20422 l_DFLT_ENRT_RL := get_fk('FORMULA_ID', r_LGE.INFORMATION263,l_dml_operation );
20423 l_ENRT_RL := get_fk('FORMULA_ID', r_LGE.INFORMATION264,l_dml_operation );
20424 l_LER_ID := get_fk('LER_ID', r_LGE.INFORMATION257,l_dml_operation );
20425 l_PGM_ID := get_fk('PGM_ID', r_LGE.INFORMATION260,l_dml_operation );
20426 --
20427 l_update := false;
20428 l_process_date := p_effective_date;
20429 --
20430 if l_dml_operation = 'UPDATE' then
20431 --
20432 l_object_found_in_target := TRUE;
20433 --
20434 if l_process_date between r_LGE_unique.information2 and r_LGE_unique.information3 then
20435 l_update := true;
20436 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)
20437 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'
20438 then
20439 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' ;
20440 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LGE_unique.information1 ;
20441 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LGE_unique.information1 ;
20442 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
20443 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;
20444 --
20445 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
20446 --
20447 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20448 --
20449 --DOUBT log_data('LGE',l_new_value,l_prefix || r_LGE_unique.name|| l_suffix,'REUSED');
20450 --
20451 end if ;
20452 hr_utility.set_location( 'found record for update',10);
20453 --
20454 else
20455 --
20456 l_update := false;
20457 --
20458 end if;
20459 else
20460 --
20461 --UPD END
20462 l_min_esd := null ;
20463 l_max_eed := null ;
20464 open c_LGE_min_max_dates(r_LGE_unique.table_route_id, r_LGE_unique.information1 ) ;
20465 fetch c_LGE_min_max_dates into l_min_esd,l_max_eed ;
20466 --
20467
20468 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20469 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
20470 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
20471 end if;
20472 l_min_esd := greatest(l_min_esd,r_LGE_unique.information2);
20473 /* open c_LGE(r_LGE_unique.table_route_id,
20474 r_LGE_unique.information1,
20475 r_LGE_unique.information2,
20476 r_LGE_unique.information3 ) ;
20477 --
20478 fetch c_LGE into r_LGE ;
20479 --
20480 close c_LGE ; */
20481 --
20482 if p_reuse_object_flag = 'Y' then
20483 if c_LGE_min_max_dates%found then
20484 -- cursor to find the object
20485 open c_find_LGE_in_target( l_min_esd,l_max_eed,
20486 p_target_business_group_id, nvl(l_ler_chg_pgm_enrt_id, -999) ) ;
20487 fetch c_find_LGE_in_target into l_new_value ;
20488 if c_find_LGE_in_target%found then
20489 --TEMPIK
20490 l_dt_rec_found := dt_api.check_min_max_dates
20491 (p_base_table_name => 'BEN_LER_CHG_PGM_ENRT_F',
20492 p_base_key_column => 'LER_CHG_PGM_ENRT_ID',
20493 p_base_key_value => l_new_value,
20494 p_from_date => l_min_esd,
20495 p_to_date => l_max_eed );
20496 if l_dt_rec_found THEN
20497 --END TEMPIK
20498 --
20499 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
20500 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
20501 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' ;
20502 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LGE_unique.information1 ;
20503 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
20504 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
20505 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;
20506 --
20507 -- 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) ;
20508 --
20509 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20510 end if ;
20511 --
20512 l_object_found_in_target := true ;
20513 --TEMPIK
20514 end if; -- l_dt_rec_found
20515 --END TEMPIK
20516 end if;
20517 close c_find_LGE_in_target ;
20518 --
20519 end if;
20520 end if ;
20521 --
20522 close c_LGE_min_max_dates ;
20523 end if; --if p_dml_operation
20524 --
20525 if not l_object_found_in_target OR l_update then
20526 --
20527 l_current_pk_id := r_LGE.information1;
20528 --
20529 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
20530 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
20531 --
20532 if l_current_pk_id = l_prev_pk_id then
20533 --
20534 l_first_rec := false ;
20535 --
20536 else
20537 --
20538 l_first_rec := true ;
20539 --
20540 end if ;
20541 --
20542
20543 l_effective_date := r_LGE.information2;
20544 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20545 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
20546 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
20547 end if;
20548
20549 if l_first_rec and not l_update then
20550 -- Call Create routine.
20551 hr_utility.set_location(' BEN_LER_CHG_PGM_ENRT_F CREATE_LER_CHG_PGM_ENRT ',20);
20552 BEN_LER_CHG_PGM_ENRT_API.CREATE_LER_CHG_PGM_ENRT(
20553 --
20554 P_VALIDATE => false
20555 ,P_EFFECTIVE_DATE => l_effective_date
20556 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
20557 --
20558 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
20559 ,P_CRNT_ENRT_PRCLDS_CHG_FLAG => r_LGE.INFORMATION11
20560 ,P_DFLT_ENRT_CD => r_LGE.INFORMATION13
20561 ,P_DFLT_ENRT_RL => l_DFLT_ENRT_RL
20562 ,P_ENRT_CD => r_LGE.INFORMATION14
20563 ,P_ENRT_MTHD_CD => r_LGE.INFORMATION15
20564 ,P_ENRT_RL => l_ENRT_RL
20565 ,P_LER_CHG_PGM_ENRT_ID => l_ler_chg_pgm_enrt_id
20566 ,P_LER_ID => l_LER_ID
20567 ,P_LGE_ATTRIBUTE1 => r_LGE.INFORMATION111
20568 ,P_LGE_ATTRIBUTE10 => r_LGE.INFORMATION120
20569 ,P_LGE_ATTRIBUTE11 => r_LGE.INFORMATION121
20570 ,P_LGE_ATTRIBUTE12 => r_LGE.INFORMATION122
20571 ,P_LGE_ATTRIBUTE13 => r_LGE.INFORMATION123
20572 ,P_LGE_ATTRIBUTE14 => r_LGE.INFORMATION124
20573 ,P_LGE_ATTRIBUTE15 => r_LGE.INFORMATION125
20574 ,P_LGE_ATTRIBUTE16 => r_LGE.INFORMATION126
20575 ,P_LGE_ATTRIBUTE17 => r_LGE.INFORMATION127
20576 ,P_LGE_ATTRIBUTE18 => r_LGE.INFORMATION128
20577 ,P_LGE_ATTRIBUTE19 => r_LGE.INFORMATION129
20578 ,P_LGE_ATTRIBUTE2 => r_LGE.INFORMATION112
20579 ,P_LGE_ATTRIBUTE20 => r_LGE.INFORMATION130
20580 ,P_LGE_ATTRIBUTE21 => r_LGE.INFORMATION131
20581 ,P_LGE_ATTRIBUTE22 => r_LGE.INFORMATION132
20582 ,P_LGE_ATTRIBUTE23 => r_LGE.INFORMATION133
20583 ,P_LGE_ATTRIBUTE24 => r_LGE.INFORMATION134
20584 ,P_LGE_ATTRIBUTE25 => r_LGE.INFORMATION135
20585 ,P_LGE_ATTRIBUTE26 => r_LGE.INFORMATION136
20586 ,P_LGE_ATTRIBUTE27 => r_LGE.INFORMATION137
20587 ,P_LGE_ATTRIBUTE28 => r_LGE.INFORMATION138
20588 ,P_LGE_ATTRIBUTE29 => r_LGE.INFORMATION139
20589 ,P_LGE_ATTRIBUTE3 => r_LGE.INFORMATION113
20590 ,P_LGE_ATTRIBUTE30 => r_LGE.INFORMATION140
20591 ,P_LGE_ATTRIBUTE4 => r_LGE.INFORMATION114
20592 ,P_LGE_ATTRIBUTE5 => r_LGE.INFORMATION115
20593 ,P_LGE_ATTRIBUTE6 => r_LGE.INFORMATION116
20594 ,P_LGE_ATTRIBUTE7 => r_LGE.INFORMATION117
20595 ,P_LGE_ATTRIBUTE8 => r_LGE.INFORMATION118
20596 ,P_LGE_ATTRIBUTE9 => r_LGE.INFORMATION119
20597 ,P_LGE_ATTRIBUTE_CATEGORY => r_LGE.INFORMATION110
20598 ,P_PGM_ID => l_PGM_ID
20599 ,P_STL_ELIG_CANT_CHG_FLAG => r_LGE.INFORMATION12
20600 --
20601 ,P_EFFECTIVE_START_DATE => l_effective_start_date
20602 ,P_EFFECTIVE_END_DATE => l_effective_end_date
20603 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
20604 );
20605 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
20606 -- Update all relevent cer records with new pk_id
20607 hr_utility.set_location('Before plsql table ',222);
20608 hr_utility.set_location('new_value id '||l_ler_chg_pgm_enrt_id,222);
20609 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' ;
20610 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LGE.information1 ;
20611 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 ;
20612 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
20613 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;
20614 hr_utility.set_location('After plsql table ',222);
20615 --
20616 -- 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 ) ;
20617 --
20618 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20619 --
20620 else
20621 --
20622 -- Call Update routine for the pk_id created in prev run .
20623 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
20624 hr_utility.set_location(' BEN_LER_CHG_PGM_ENRT_F UPDATE_LER_CHG_PGM_ENRT ',30);
20625 --UPD START
20626 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
20627 --
20628 if l_update then
20629 --
20630 l_datetrack_mode := r_LGE.datetrack_mode ;
20631 --
20632 get_dt_modes(
20633 p_effective_date => l_process_date,
20634 p_effective_end_date => r_LGE.information3,
20635 p_effective_start_date => r_LGE.information2,
20636 p_dml_operation => r_LGE.dml_operation,
20637 p_datetrack_mode => l_datetrack_mode );
20638 -- p_update => l_update
20639 --
20640 l_effective_date := l_process_date;
20641 l_LER_CHG_PGM_ENRT_ID := r_LGE.information1;
20642 l_object_version_number := r_LGE.information265;
20643 --
20644 end if;
20645 --
20646 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
20647 --
20648 IF l_update OR l_dml_operation <> 'UPDATE' THEN
20649 --UPD END
20650 BEN_LER_CHG_PGM_ENRT_API.UPDATE_LER_CHG_PGM_ENRT(
20651 --
20652 P_VALIDATE => false
20653 ,P_EFFECTIVE_DATE => l_effective_date
20654 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
20655 --
20656 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
20657 ,P_CRNT_ENRT_PRCLDS_CHG_FLAG => r_LGE.INFORMATION11
20658 ,P_DFLT_ENRT_CD => r_LGE.INFORMATION13
20659 ,P_DFLT_ENRT_RL => l_DFLT_ENRT_RL
20660 ,P_ENRT_CD => r_LGE.INFORMATION14
20661 ,P_ENRT_MTHD_CD => r_LGE.INFORMATION15
20662 ,P_ENRT_RL => l_ENRT_RL
20663 ,P_LER_CHG_PGM_ENRT_ID => l_ler_chg_pgm_enrt_id
20664 ,P_LER_ID => l_LER_ID
20665 ,P_LGE_ATTRIBUTE1 => r_LGE.INFORMATION111
20666 ,P_LGE_ATTRIBUTE10 => r_LGE.INFORMATION120
20667 ,P_LGE_ATTRIBUTE11 => r_LGE.INFORMATION121
20668 ,P_LGE_ATTRIBUTE12 => r_LGE.INFORMATION122
20669 ,P_LGE_ATTRIBUTE13 => r_LGE.INFORMATION123
20670 ,P_LGE_ATTRIBUTE14 => r_LGE.INFORMATION124
20671 ,P_LGE_ATTRIBUTE15 => r_LGE.INFORMATION125
20672 ,P_LGE_ATTRIBUTE16 => r_LGE.INFORMATION126
20673 ,P_LGE_ATTRIBUTE17 => r_LGE.INFORMATION127
20674 ,P_LGE_ATTRIBUTE18 => r_LGE.INFORMATION128
20675 ,P_LGE_ATTRIBUTE19 => r_LGE.INFORMATION129
20676 ,P_LGE_ATTRIBUTE2 => r_LGE.INFORMATION112
20677 ,P_LGE_ATTRIBUTE20 => r_LGE.INFORMATION130
20678 ,P_LGE_ATTRIBUTE21 => r_LGE.INFORMATION131
20679 ,P_LGE_ATTRIBUTE22 => r_LGE.INFORMATION132
20680 ,P_LGE_ATTRIBUTE23 => r_LGE.INFORMATION133
20681 ,P_LGE_ATTRIBUTE24 => r_LGE.INFORMATION134
20682 ,P_LGE_ATTRIBUTE25 => r_LGE.INFORMATION135
20683 ,P_LGE_ATTRIBUTE26 => r_LGE.INFORMATION136
20684 ,P_LGE_ATTRIBUTE27 => r_LGE.INFORMATION137
20685 ,P_LGE_ATTRIBUTE28 => r_LGE.INFORMATION138
20686 ,P_LGE_ATTRIBUTE29 => r_LGE.INFORMATION139
20687 ,P_LGE_ATTRIBUTE3 => r_LGE.INFORMATION113
20688 ,P_LGE_ATTRIBUTE30 => r_LGE.INFORMATION140
20689 ,P_LGE_ATTRIBUTE4 => r_LGE.INFORMATION114
20690 ,P_LGE_ATTRIBUTE5 => r_LGE.INFORMATION115
20691 ,P_LGE_ATTRIBUTE6 => r_LGE.INFORMATION116
20692 ,P_LGE_ATTRIBUTE7 => r_LGE.INFORMATION117
20693 ,P_LGE_ATTRIBUTE8 => r_LGE.INFORMATION118
20694 ,P_LGE_ATTRIBUTE9 => r_LGE.INFORMATION119
20695 ,P_LGE_ATTRIBUTE_CATEGORY => r_LGE.INFORMATION110
20696 ,P_PGM_ID => l_PGM_ID
20697 ,P_STL_ELIG_CANT_CHG_FLAG => r_LGE.INFORMATION12
20698 --
20699 ,P_EFFECTIVE_START_DATE => l_effective_start_date
20700 ,P_EFFECTIVE_END_DATE => l_effective_end_date
20701 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
20702 ,P_DATETRACK_MODE => l_datetrack_mode
20703 );
20704 --
20705 end if; -- l_update
20706 end if;
20707 --
20708 -- Delete the row if it is end dated.
20709 --
20710 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
20711 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
20712 trunc(l_max_eed) = r_LGE.information3) then
20713 --
20714 BEN_LER_CHG_PGM_ENRT_API.delete_LER_CHG_PGM_ENRT(
20715 --
20716 p_validate => false
20717 ,p_ler_chg_pgm_enrt_id => l_ler_chg_pgm_enrt_id
20718 ,p_effective_start_date => l_effective_start_date
20719 ,p_effective_end_date => l_effective_end_date
20720 ,p_object_version_number => l_object_version_number
20721 ,p_effective_date => l_max_eed
20722 ,p_datetrack_mode => hr_api.g_delete
20723 --
20724 );
20725 --
20726 end if;
20727 --
20728 l_prev_pk_id := l_current_pk_id ;
20729 --
20730 end if;
20731 --
20732 end if;
20733 --
20734 end loop;
20735 --
20736 exception when others then
20737 --
20738 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LGE',r_lge.information5 );
20739 --
20740 end create_LGE_rows;
20741
20742 --
20743 ---------------------------------------------------------------
20744 ----------------------< create_LDC_rows >-----------------------
20745 ---------------------------------------------------------------
20746 --
20747 procedure create_LDC_rows
20748 (
20749 p_validate in number default 0
20750 ,p_copy_entity_txn_id in number
20751 ,p_effective_date in date
20752 ,p_prefix_suffix_text in varchar2 default null
20753 ,p_reuse_object_flag in varchar2 default null
20754 ,p_target_business_group_id in varchar2 default null
20755 ,p_prefix_suffix_cd in varchar2 default null
20756 ) is
20757 --
20758 l_CVG_EFF_END_RL number;
20759 l_CVG_EFF_STRT_RL number;
20760 l_LER_CHG_DPNT_CVG_RL number;
20761 l_LER_ID number;
20762 l_PGM_ID number;
20763 l_PL_ID number;
20764 l_PTIP_ID number;
20765 cursor c_unique_LDC(l_table_alias varchar2) is
20766 select distinct cpe.information1,
20767 cpe.information2,
20768 cpe.information3,
20769 cpe.table_route_id
20770 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
20771 pqh_table_route tr
20772 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20773 and cpe.table_route_id = tr.table_route_id
20774 -- and tr.where_clause = l_BEN_LER_CHG_DPNT_CVG_F
20775 and tr.table_alias = l_table_alias
20776 and cpe.number_of_copies = 1 -- ADDITION
20777 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
20778 order by information1, information2; --added for bug: 5151945
20779 --
20780 --
20781 cursor c_LDC_min_max_dates(c_table_route_id number,
20782 c_information1 number) is
20783 select
20784 min(cpe.information2) min_esd,
20785 max(cpe.information3) min_eed
20786 from ben_copy_entity_results cpe
20787 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20788 and cpe.table_route_id = c_table_route_id
20789 and cpe.information1 = c_information1 ;
20790 --
20791 cursor c_LDC(c_table_route_id number,
20792 c_information1 number,
20793 c_information2 date,
20794 c_information3 date ) is
20795 select
20796 cpe.*
20797 from ben_copy_entity_results cpe
20798 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
20799 and cpe.table_route_id = c_table_route_id
20800 and cpe.information1 = c_information1
20801 and cpe.information2 = c_information2
20802 and cpe.information3 = c_information3
20803 and rownum = 1 ;
20804 -- Date Track target record
20805 cursor c_find_LDC_in_target(
20806 c_effective_start_date date,
20807 c_effective_end_date date,
20808 c_business_group_id number,
20809 c_new_pk_id number) is
20810 select
20811 LDC.ler_chg_dpnt_cvg_id new_value
20812 from BEN_LER_CHG_DPNT_CVG_F LDC
20813 where
20814 LDC.LER_ID = l_LER_ID and
20815 nvl(LDC.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
20816 nvl(LDC.PL_ID,-999) = nvl(l_PL_ID,-999) and
20817 nvl(LDC.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
20818 LDC.business_group_id = c_business_group_id
20819 and LDC.ler_chg_dpnt_cvg_id <> c_new_pk_id
20820 --TEMPIK
20821 and c_effective_start_date between effective_start_date
20822 and effective_end_date ;
20823 --END TEMPIK
20824 /*TEMPIK
20825 and exists ( select null
20826 from BEN_LER_CHG_DPNT_CVG_F LDC1
20827 where
20828 LDC1.LER_ID = l_LER_ID and
20829 nvl(LDC1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
20830 nvl(LDC1.PL_ID,-999) = nvl(l_PL_ID,-999) and
20831 nvl(LDC1.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
20832 LDC1.business_group_id = c_business_group_id
20833 and LDC1.effective_start_date <= c_effective_start_date )
20834 and exists ( select null
20835 from BEN_LER_CHG_DPNT_CVG_F LDC2
20836 where
20837 LDC2.LER_ID = l_LER_ID and
20838 nvl(LDC2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
20839 nvl(LDC2.PL_ID,-999) = nvl(l_PL_ID,-999) and
20840 nvl(LDC2.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
20841 LDC2.business_group_id = c_business_group_id
20842 and LDC2.effective_end_date >= c_effective_end_date )
20843 ;
20844 */
20845 --
20846 --UPD START
20847 --
20848 l_update boolean := false ;
20849 l_datetrack_mode varchar2(80) := hr_api.g_update;
20850 l_process_date date;
20851 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
20852 --
20853 --UPD END
20854
20855 l_current_pk_id number := null ;
20856 l_prev_pk_id number := null ;
20857 l_first_rec boolean := true ;
20858 r_LDC c_LDC%rowtype;
20859 l_ler_chg_dpnt_cvg_id number ;
20860 l_object_version_number number ;
20861 l_effective_start_date date ;
20862 l_effective_end_date date ;
20863 l_prefix pqh_copy_entity_attribs.information1%type := null;
20864 l_suffix pqh_copy_entity_attribs.information1%type := null;
20865 l_new_value number(15);
20866 l_object_found_in_target boolean := false ;
20867 l_min_esd date;
20868 l_max_eed date;
20869 l_effective_date date;
20870 --TEMPIK
20871 l_dt_rec_found boolean ;
20872 --END TEMPIK
20873 --
20874 begin
20875 -- Initialization
20876 l_object_found_in_target := false ;
20877 -- End Initialization
20878 -- Derive the prefix - sufix
20879 if p_prefix_suffix_cd = 'PREFIX' then
20880 l_prefix := p_prefix_suffix_text ;
20881 elsif p_prefix_suffix_cd = 'SUFFIX' then
20882 l_suffix := p_prefix_suffix_text ;
20883 else
20884 l_prefix := null ;
20885 l_suffix := null ;
20886 end if ;
20887 -- End Prefix Sufix derivation
20888 for r_LDC_unique in c_unique_LDC('LDC') loop
20889
20890 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
20891 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20892 r_LDC_unique.information3 >=
20893 ben_pd_copy_to_ben_one.g_copy_effective_date)
20894 ) then
20895 --
20896 hr_utility.set_location(' r_LDC_unique.table_route_id '||r_LDC_unique.table_route_id,10);
20897 hr_utility.set_location(' r_LDC_unique.information1 '||r_LDC_unique.information1,10);
20898 hr_utility.set_location( 'r_LDC_unique.information2 '||r_LDC_unique.information2,10);
20899 hr_utility.set_location( 'r_LDC_unique.information3 '||r_LDC_unique.information3,10);
20900 -- If reuse objects flag is 'Y' then check for the object in the target business group
20901 -- if found insert the record into PLSql table and exit the loop else try create the
20902 -- object in the target business group
20903 --
20904 l_object_found_in_target := false ;
20905 --UPD START
20906 open c_LDC(r_LDC_unique.table_route_id,
20907 r_LDC_unique.information1,
20908 r_LDC_unique.information2,
20909 r_LDC_unique.information3 ) ;
20910 --
20911 fetch c_LDC into r_LDC ;
20912 --
20913 close c_LDC ;
20914 --
20915 l_dml_operation:= r_LDC_unique.dml_operation ;
20916 l_CVG_EFF_END_RL := get_fk('FORMULA_ID', r_LDC.INFORMATION263,l_dml_operation );
20917 l_CVG_EFF_STRT_RL := get_fk('FORMULA_ID', r_LDC.INFORMATION262,l_dml_operation );
20918 l_LER_CHG_DPNT_CVG_RL := get_fk('FORMULA_ID', r_LDC.INFORMATION258,l_dml_operation );
20919 l_LER_ID := get_fk('LER_ID', r_LDC.INFORMATION257,l_dml_operation );
20920 l_PGM_ID := get_fk('PGM_ID', r_LDC.INFORMATION260,l_dml_operation );
20921 l_PL_ID := get_fk('PL_ID', r_LDC.INFORMATION261,l_dml_operation );
20922 l_PTIP_ID := get_fk('PTIP_ID', r_LDC.INFORMATION259,l_dml_operation );
20923 --
20924 l_update := false;
20925 l_process_date := p_effective_date;
20926 --
20927 if l_dml_operation = 'UPDATE' then
20928 --
20929 l_object_found_in_target := TRUE;
20930 --
20931 if l_process_date between r_LDC_unique.information2 and r_LDC_unique.information3 then
20932 l_update := true;
20933 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)
20934 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'
20935 then
20936 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' ;
20937 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LDC_unique.information1 ;
20938 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_LDC_unique.information1 ;
20939 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
20940 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;
20941 --
20942 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
20943 --
20944 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
20945 --
20946 --DOUBT log_data('LDC',l_new_value,l_prefix || r_LDC_unique.name|| l_suffix,'REUSED');
20947 --
20948 end if ;
20949 hr_utility.set_location( 'found record for update',10);
20950 --
20951 else
20952 --
20953 l_update := false;
20954 --
20955 end if;
20956 else
20957 --
20958 --UPD END
20959 l_min_esd := null ;
20960 l_max_eed := null ;
20961 open c_LDC_min_max_dates(r_LDC_unique.table_route_id, r_LDC_unique.information1 ) ;
20962 fetch c_LDC_min_max_dates into l_min_esd,l_max_eed ;
20963 --
20964
20965 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
20966 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
20967 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
20968 end if;
20969 l_min_esd := greatest(l_min_esd,r_LDC_unique.information2);
20970 /* open c_LDC(r_LDC_unique.table_route_id,
20971 r_LDC_unique.information1,
20972 r_LDC_unique.information2,
20973 r_LDC_unique.information3 ) ;
20974 --
20975 fetch c_LDC into r_LDC ;
20976 --
20977 close c_LDC ; */
20978 --
20979 if p_reuse_object_flag = 'Y' then
20980 if c_LDC_min_max_dates%found then
20981 -- cursor to find the object
20982 open c_find_LDC_in_target( l_min_esd,l_max_eed,
20983 p_target_business_group_id, nvl(l_ler_chg_dpnt_cvg_id, -999) ) ;
20984 fetch c_find_LDC_in_target into l_new_value ;
20985 if c_find_LDC_in_target%found then
20986 --
20987 --TEMPIK
20988 l_dt_rec_found := dt_api.check_min_max_dates
20989 (p_base_table_name => 'BEN_LER_CHG_DPNT_CVG_F',
20990 p_base_key_column => 'LER_CHG_DPNT_CVG_ID',
20991 p_base_key_value => l_new_value,
20992 p_from_date => l_min_esd,
20993 p_to_date => l_max_eed );
20994 if l_dt_rec_found THEN
20995 --END TEMPIK
20996 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
20997 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
20998 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' ;
20999 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LDC_unique.information1 ;
21000 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
21001 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
21002 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;
21003 --
21004 -- 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) ;
21005 --
21006 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21007 end if ;
21008 --
21009 l_object_found_in_target := true ;
21010 --TEMPIK
21011 end if; -- l_dt_rec_found
21012 --END TEMPIK
21013 end if;
21014 close c_find_LDC_in_target ;
21015 --
21016 end if;
21017 end if ;
21018 --
21019 close c_LDC_min_max_dates ;
21020 end if; --if p_dml_operation
21021 --
21022 if not l_object_found_in_target OR l_update then
21023 --
21024 l_current_pk_id := r_LDC.information1;
21025 --
21026 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
21027 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
21028 --
21029 if l_current_pk_id = l_prev_pk_id then
21030 --
21031 l_first_rec := false ;
21032 --
21033 else
21034 --
21035 l_first_rec := true ;
21036 --
21037 end if ;
21038 --
21039
21040 l_effective_date := r_LDC.information2;
21041 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21042 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
21043 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
21044 end if;
21045
21046 if l_first_rec and not l_update then
21047 -- Call Create routine.
21048 hr_utility.set_location(' BEN_LER_CHG_DPNT_CVG_F CREATE_LER_CHG_DEPENDENT_CVG ',20);
21049 BEN_LER_CHG_DEPENDENT_CVG_API.CREATE_LER_CHG_DEPENDENT_CVG(
21050 --
21051 P_VALIDATE => false
21052 ,P_EFFECTIVE_DATE => l_effective_date
21053 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
21054 --
21055 ,P_ADD_RMV_CVG_CD => r_LDC.INFORMATION11
21056 ,P_CVG_EFF_END_CD => r_LDC.INFORMATION12
21057 ,P_CVG_EFF_END_RL => l_CVG_EFF_END_RL
21058 ,P_CVG_EFF_STRT_CD => r_LDC.INFORMATION13
21059 ,P_CVG_EFF_STRT_RL => l_CVG_EFF_STRT_RL
21060 ,P_LDC_ATTRIBUTE1 => r_LDC.INFORMATION111
21061 ,P_LDC_ATTRIBUTE10 => r_LDC.INFORMATION120
21062 ,P_LDC_ATTRIBUTE11 => r_LDC.INFORMATION121
21063 ,P_LDC_ATTRIBUTE12 => r_LDC.INFORMATION122
21064 ,P_LDC_ATTRIBUTE13 => r_LDC.INFORMATION123
21065 ,P_LDC_ATTRIBUTE14 => r_LDC.INFORMATION124
21066 ,P_LDC_ATTRIBUTE15 => r_LDC.INFORMATION125
21067 ,P_LDC_ATTRIBUTE16 => r_LDC.INFORMATION126
21068 ,P_LDC_ATTRIBUTE17 => r_LDC.INFORMATION127
21069 ,P_LDC_ATTRIBUTE18 => r_LDC.INFORMATION128
21070 ,P_LDC_ATTRIBUTE19 => r_LDC.INFORMATION129
21071 ,P_LDC_ATTRIBUTE2 => r_LDC.INFORMATION112
21072 ,P_LDC_ATTRIBUTE20 => r_LDC.INFORMATION130
21073 ,P_LDC_ATTRIBUTE21 => r_LDC.INFORMATION131
21074 ,P_LDC_ATTRIBUTE22 => r_LDC.INFORMATION132
21075 ,P_LDC_ATTRIBUTE23 => r_LDC.INFORMATION133
21076 ,P_LDC_ATTRIBUTE24 => r_LDC.INFORMATION134
21077 ,P_LDC_ATTRIBUTE25 => r_LDC.INFORMATION135
21078 ,P_LDC_ATTRIBUTE26 => r_LDC.INFORMATION136
21079 ,P_LDC_ATTRIBUTE27 => r_LDC.INFORMATION137
21080 ,P_LDC_ATTRIBUTE28 => r_LDC.INFORMATION138
21081 ,P_LDC_ATTRIBUTE29 => r_LDC.INFORMATION139
21082 ,P_LDC_ATTRIBUTE3 => r_LDC.INFORMATION113
21083 ,P_LDC_ATTRIBUTE30 => r_LDC.INFORMATION140
21084 ,P_LDC_ATTRIBUTE4 => r_LDC.INFORMATION114
21085 ,P_LDC_ATTRIBUTE5 => r_LDC.INFORMATION115
21086 ,P_LDC_ATTRIBUTE6 => r_LDC.INFORMATION116
21087 ,P_LDC_ATTRIBUTE7 => r_LDC.INFORMATION117
21088 ,P_LDC_ATTRIBUTE8 => r_LDC.INFORMATION118
21089 ,P_LDC_ATTRIBUTE9 => r_LDC.INFORMATION119
21090 ,P_LDC_ATTRIBUTE_CATEGORY => r_LDC.INFORMATION110
21091 ,P_LER_CHG_DPNT_CVG_CD => r_LDC.INFORMATION14
21092 ,P_LER_CHG_DPNT_CVG_ID => l_ler_chg_dpnt_cvg_id
21093 ,P_LER_CHG_DPNT_CVG_RL => l_LER_CHG_DPNT_CVG_RL
21094 ,P_LER_ID => l_LER_ID
21095 ,P_PGM_ID => l_PGM_ID
21096 ,P_PL_ID => l_PL_ID
21097 ,P_PTIP_ID => l_PTIP_ID
21098 --
21099 ,P_SUSP_IF_CTFN_NOT_PRVD_FLAG => nvl(r_LDC.INFORMATION198,'Y')
21100 ,P_CTFN_DETERMINE_CD => r_LDC.INFORMATION197
21101 ,P_EFFECTIVE_START_DATE => l_effective_start_date
21102 ,P_EFFECTIVE_END_DATE => l_effective_end_date
21103 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
21104 );
21105 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
21106 -- Update all relevent cer records with new pk_id
21107 hr_utility.set_location('Before plsql table ',222);
21108 hr_utility.set_location('new_value id '||l_ler_chg_dpnt_cvg_id,222);
21109 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' ;
21110 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LDC.information1 ;
21111 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 ;
21112 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
21113 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;
21114 hr_utility.set_location('After plsql table ',222);
21115 --
21116 -- 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 ) ;
21117 --
21118 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21119 --
21120 else
21121 --
21122 -- Call Update routine for the pk_id created in prev run .
21123 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
21124 hr_utility.set_location(' BEN_LER_CHG_DPNT_CVG_F UPDATE_LER_CHG_DEPENDENT_CVG ',30);
21125 --UPD START
21126 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
21127 --
21128 if l_update then
21129 --
21130 l_datetrack_mode := r_LDC.datetrack_mode ;
21131 --
21132 get_dt_modes(
21133 p_effective_date => l_process_date,
21134 p_effective_end_date => r_LDC.information3,
21135 p_effective_start_date => r_LDC.information2,
21136 p_dml_operation => r_LDC.dml_operation,
21137 p_datetrack_mode => l_datetrack_mode );
21138 -- p_update => l_update
21139 --
21140 l_effective_date := l_process_date;
21141 l_LER_CHG_DPNT_CVG_ID := r_LDC.information1;
21142 l_object_version_number := r_LDC.information265;
21143 --
21144 end if;
21145 --
21146 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
21147 --
21148 IF l_update OR l_dml_operation <> 'UPDATE' THEN
21149 --UPD END
21150 BEN_LER_CHG_DEPENDENT_CVG_API.UPDATE_LER_CHG_DEPENDENT_CVG(
21151 --
21152 P_VALIDATE => false
21153 ,P_EFFECTIVE_DATE => l_effective_date
21154 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
21155 --
21156 ,P_ADD_RMV_CVG_CD => r_LDC.INFORMATION11
21157 ,P_CVG_EFF_END_CD => r_LDC.INFORMATION12
21158 ,P_CVG_EFF_END_RL => l_CVG_EFF_END_RL
21159 ,P_CVG_EFF_STRT_CD => r_LDC.INFORMATION13
21160 ,P_CVG_EFF_STRT_RL => l_CVG_EFF_STRT_RL
21161 ,P_LDC_ATTRIBUTE1 => r_LDC.INFORMATION111
21162 ,P_LDC_ATTRIBUTE10 => r_LDC.INFORMATION120
21163 ,P_LDC_ATTRIBUTE11 => r_LDC.INFORMATION121
21164 ,P_LDC_ATTRIBUTE12 => r_LDC.INFORMATION122
21165 ,P_LDC_ATTRIBUTE13 => r_LDC.INFORMATION123
21166 ,P_LDC_ATTRIBUTE14 => r_LDC.INFORMATION124
21167 ,P_LDC_ATTRIBUTE15 => r_LDC.INFORMATION125
21168 ,P_LDC_ATTRIBUTE16 => r_LDC.INFORMATION126
21169 ,P_LDC_ATTRIBUTE17 => r_LDC.INFORMATION127
21170 ,P_LDC_ATTRIBUTE18 => r_LDC.INFORMATION128
21171 ,P_LDC_ATTRIBUTE19 => r_LDC.INFORMATION129
21172 ,P_LDC_ATTRIBUTE2 => r_LDC.INFORMATION112
21173 ,P_LDC_ATTRIBUTE20 => r_LDC.INFORMATION130
21174 ,P_LDC_ATTRIBUTE21 => r_LDC.INFORMATION131
21175 ,P_LDC_ATTRIBUTE22 => r_LDC.INFORMATION132
21176 ,P_LDC_ATTRIBUTE23 => r_LDC.INFORMATION133
21177 ,P_LDC_ATTRIBUTE24 => r_LDC.INFORMATION134
21178 ,P_LDC_ATTRIBUTE25 => r_LDC.INFORMATION135
21179 ,P_LDC_ATTRIBUTE26 => r_LDC.INFORMATION136
21180 ,P_LDC_ATTRIBUTE27 => r_LDC.INFORMATION137
21181 ,P_LDC_ATTRIBUTE28 => r_LDC.INFORMATION138
21182 ,P_LDC_ATTRIBUTE29 => r_LDC.INFORMATION139
21183 ,P_LDC_ATTRIBUTE3 => r_LDC.INFORMATION113
21184 ,P_LDC_ATTRIBUTE30 => r_LDC.INFORMATION140
21185 ,P_LDC_ATTRIBUTE4 => r_LDC.INFORMATION114
21186 ,P_LDC_ATTRIBUTE5 => r_LDC.INFORMATION115
21187 ,P_LDC_ATTRIBUTE6 => r_LDC.INFORMATION116
21188 ,P_LDC_ATTRIBUTE7 => r_LDC.INFORMATION117
21189 ,P_LDC_ATTRIBUTE8 => r_LDC.INFORMATION118
21190 ,P_LDC_ATTRIBUTE9 => r_LDC.INFORMATION119
21191 ,P_LDC_ATTRIBUTE_CATEGORY => r_LDC.INFORMATION110
21192 ,P_LER_CHG_DPNT_CVG_CD => r_LDC.INFORMATION14
21193 ,P_LER_CHG_DPNT_CVG_ID => l_ler_chg_dpnt_cvg_id
21194 ,P_LER_CHG_DPNT_CVG_RL => l_LER_CHG_DPNT_CVG_RL
21195 ,P_LER_ID => l_LER_ID
21196 ,P_PGM_ID => l_PGM_ID
21197 ,P_PL_ID => l_PL_ID
21198 ,P_PTIP_ID => l_PTIP_ID
21199 --
21200 ,P_SUSP_IF_CTFN_NOT_PRVD_FLAG => nvl(r_LDC.INFORMATION198,'Y')
21201 ,P_CTFN_DETERMINE_CD => r_LDC.INFORMATION197
21202 ,P_EFFECTIVE_START_DATE => l_effective_start_date
21203 ,P_EFFECTIVE_END_DATE => l_effective_end_date
21204 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
21205 ,P_DATETRACK_MODE => l_datetrack_mode
21206 );
21207 --
21208 end if; -- l_update
21209 end if;
21210 --
21211 -- Delete the row if it is end dated.
21212 --
21213 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
21214 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
21215 trunc(l_max_eed) = r_LDC.information3) then
21216 --
21217 BEN_LER_CHG_DEPENDENT_CVG_API.delete_LER_CHG_DEPENDENT_CVG(
21218 --
21219 p_validate => false
21220 ,p_ler_chg_dpnt_cvg_id => l_ler_chg_dpnt_cvg_id
21221 ,p_effective_start_date => l_effective_start_date
21222 ,p_effective_end_date => l_effective_end_date
21223 ,p_object_version_number => l_object_version_number
21224 ,p_effective_date => l_max_eed
21225 ,p_datetrack_mode => hr_api.g_delete
21226 --
21227 );
21228 --
21229 end if;
21230 --
21231 l_prev_pk_id := l_current_pk_id ;
21232 --
21233 end if;
21234 --
21235 end if;
21236 --
21237 end loop;
21238 --
21239 exception when others then
21240 --
21241 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LDC',r_ldc.information5 );
21242 --
21243 end create_LDC_rows;
21244
21245 ---------------------------------------------------------------
21246 ----------------------< create_PAT_rows >-----------------------
21247 ---------------------------------------------------------------
21248 --
21249 procedure create_PAT_rows
21250 (
21251 p_validate in number default 0
21252 ,p_copy_entity_txn_id in number
21253 ,p_effective_date in date
21254 ,p_prefix_suffix_text in varchar2 default null
21255 ,p_reuse_object_flag in varchar2 default null
21256 ,p_target_business_group_id in varchar2 default null
21257 ,p_prefix_suffix_cd in varchar2 default null
21258 ) is
21259 --
21260 l_ACTN_TYP_DUE_DT_RL number;
21261 l_ACTN_TYP_ID number;
21262 l_PGM_ID number;
21263 l_PL_ID number;
21264 cursor c_unique_PAT(l_table_alias varchar2) is
21265 select distinct cpe.information1,
21266 cpe.information2,
21267 cpe.information3,
21268 cpe.table_route_id
21269 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
21270 pqh_table_route tr
21271 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21272 and cpe.table_route_id = tr.table_route_id
21273 -- and tr.where_clause = l_BEN_POPL_ACTN_TYP_F
21274 and tr.table_alias = l_table_alias
21275 and cpe.number_of_copies = 1 -- ADDITION
21276 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
21277 order by information1, information2; --added for bug: 5151945
21278 --
21279 --
21280 cursor c_PAT_min_max_dates(c_table_route_id number,
21281 c_information1 number) is
21282 select
21283 min(cpe.information2) min_esd,
21284 max(cpe.information3) min_eed
21285 from ben_copy_entity_results cpe
21286 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21287 and cpe.table_route_id = c_table_route_id
21288 and cpe.information1 = c_information1 ;
21289 --
21290 cursor c_PAT(c_table_route_id number,
21291 c_information1 number,
21292 c_information2 date,
21293 c_information3 date ) is
21294 select
21295 cpe.*
21296 from ben_copy_entity_results cpe
21297 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21298 and cpe.table_route_id = c_table_route_id
21299 and cpe.information1 = c_information1
21300 and cpe.information2 = c_information2
21301 and cpe.information3 = c_information3
21302 and rownum = 1 ;
21303 -- Date Track target record
21304 cursor c_find_PAT_in_target( c_effective_start_date date,
21305 c_effective_end_date date,
21306 c_business_group_id number,
21307 c_new_pk_id number) is
21308 select
21309 PAT.popl_actn_typ_id new_value
21310 from BEN_POPL_ACTN_TYP_F PAT
21311 where NVL(PAT.PGM_ID,-999) = nvl(l_PGM_ID,-999)
21312 and NVL(PAT.PL_ID,-999) = nvl(l_PL_ID ,-999)
21313 and PAT.ACTN_TYP_ID = l_ACTN_TYP_ID
21314 and PAT.business_group_id = c_business_group_id
21315 and PAT.popl_actn_typ_id <> c_new_pk_id
21316 --TEMPIK
21317 and c_effective_start_date between effective_start_date
21318 and effective_end_date ;
21319 --END TEMPIK
21320 /*
21321 and exists ( select null
21322 from BEN_POPL_ACTN_TYP_F PAT1
21323 where NVL(PAT1.PGM_ID,-999) = nvl(l_PGM_ID,-999)
21324 and NVL(PAT1.PL_ID,-999) = nvl(l_PL_ID ,-999)
21325 and PAT1.ACTN_TYP_ID = l_ACTN_TYP_ID
21326 and PAT1.business_group_id = c_business_group_id
21327 and PAT1.effective_start_date <= c_effective_start_date )
21328 and exists ( select null
21329 from BEN_POPL_ACTN_TYP_F PAT2
21330 where NVL(PAT2.PGM_ID,-999) = nvl(l_PGM_ID,-999)
21331 and NVL(PAT2.PL_ID,-999) = nvl(l_PL_ID ,-999)
21332 and PAT2.ACTN_TYP_ID = l_ACTN_TYP_ID
21333 and PAT2.business_group_id = c_business_group_id
21334 and PAT2.effective_end_date >= c_effective_end_date )
21335 ;
21336 */
21337 --
21338 --UPD START
21339 --
21340 l_update boolean := false ;
21341 l_datetrack_mode varchar2(80) := hr_api.g_update;
21342 l_process_date date;
21343 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
21344 --
21345 --UPD END
21346 l_current_pk_id number := null ;
21347 l_prev_pk_id number := null ;
21348 l_first_rec boolean := true ;
21349 r_PAT c_PAT%rowtype;
21350 l_popl_actn_typ_id number ;
21351 l_object_version_number number ;
21352 l_effective_start_date date ;
21353 l_effective_end_date date ;
21354 l_prefix pqh_copy_entity_attribs.information1%type := null;
21355 l_suffix pqh_copy_entity_attribs.information1%type := null;
21356 l_new_value number(15);
21357 l_object_found_in_target boolean := false ;
21358 l_min_esd date;
21359 l_max_eed date;
21360 l_effective_date date;
21361 --TEMPIK
21362 l_dt_rec_found boolean ;
21363 --END TEMPIK
21364 --
21365 begin
21366 -- Initialization
21367 l_object_found_in_target := false ;
21368 -- End Initialization
21369 -- Derive the prefix - sufix
21370 if p_prefix_suffix_cd = 'PREFIX' then
21371 l_prefix := p_prefix_suffix_text ;
21372 elsif p_prefix_suffix_cd = 'SUFFIX' then
21373 l_suffix := p_prefix_suffix_text ;
21374 else
21375 l_prefix := null ;
21376 l_suffix := null ;
21377 end if ;
21378 -- End Prefix Sufix derivation
21379 for r_PAT_unique in c_unique_PAT('PAT') loop
21380
21381 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
21382 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21383 r_PAT_unique.information3 >=
21384 ben_pd_copy_to_ben_one.g_copy_effective_date)
21385 ) then
21386
21387 --
21388 hr_utility.set_location(' r_PAT_unique.table_route_id '||r_PAT_unique.table_route_id,10);
21389 hr_utility.set_location(' r_PAT_unique.information1 '||r_PAT_unique.information1,10);
21390 hr_utility.set_location( 'r_PAT_unique.information2 '||r_PAT_unique.information2,10);
21391 hr_utility.set_location( 'r_PAT_unique.information3 '||r_PAT_unique.information3,10);
21392 -- If reuse objects flag is 'Y' then check for the object in the target business group
21393 -- if found insert the record into PLSql table and exit the loop else try create the
21394 -- object in the target business group
21395 --
21396 l_object_found_in_target := false ;
21397 --UPD START
21398 open c_PAT(r_PAT_unique.table_route_id,
21399 r_PAT_unique.information1,
21400 r_PAT_unique.information2,
21401 r_PAT_unique.information3 ) ;
21402 --
21403 fetch c_PAT into r_PAT ;
21404 --
21405 close c_PAT ;
21406 --
21407 l_dml_operation:= r_PAT_unique.dml_operation ;
21408 l_ACTN_TYP_DUE_DT_RL := get_fk('FORMULA_ID', r_PAT.INFORMATION262,l_dml_operation );
21409 l_ACTN_TYP_ID := get_fk('ACTN_TYP_ID', r_PAT.INFORMATION221,l_dml_operation );
21410 l_PGM_ID := get_fk('PGM_ID', r_PAT.INFORMATION260,l_dml_operation );
21411 l_PL_ID := get_fk('PL_ID', r_PAT.INFORMATION261,l_dml_operation );
21412 --
21413 l_update := false;
21414 l_process_date := p_effective_date;
21415
21416 --
21417 if l_dml_operation = 'UPDATE' then
21418 --
21419 l_object_found_in_target := TRUE;
21420 --
21421 if l_process_date between r_PAT_unique.information2 and r_PAT_unique.information3 then
21422 l_update := true;
21423 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)
21424 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'
21425 then
21426 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ACTN_TYP_ID' ;
21427 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PAT_unique.information1 ;
21428 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PAT_unique.information1 ;
21429 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
21430 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;
21431 --
21432 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
21433 --
21434 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21435 --
21436 --DOUBT log_data('PAT',l_new_value,l_prefix || r_PAT_unique.name|| l_suffix,'REUSED');
21437 --
21438 end if ;
21439 hr_utility.set_location( 'found record for update',10);
21440 --
21441 else
21442 --
21443 l_update := false;
21444 --
21445 end if;
21446 else
21447 --
21448 --UPD END
21449 l_min_esd := null ;
21450 l_max_eed := null ;
21451 open c_PAT_min_max_dates(r_PAT_unique.table_route_id, r_PAT_unique.information1 ) ;
21452 fetch c_PAT_min_max_dates into l_min_esd,l_max_eed ;
21453 --
21454
21455 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21456 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
21457 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
21458 end if;
21459 l_min_esd := greatest(l_min_esd,r_PAT_unique.information2);
21460 /* open c_PAT(r_PAT_unique.table_route_id,
21461 r_PAT_unique.information1,
21462 r_PAT_unique.information2,
21463 r_PAT_unique.information3 ) ;
21464 --
21465 fetch c_PAT into r_PAT ;
21466 --
21467 close c_PAT ; */
21468 --
21469 --
21470 if l_ACTN_TYP_ID is null then
21471 close c_PAT_min_max_dates;
21472 else
21473
21474 if p_reuse_object_flag = 'Y' then
21475 if c_PAT_min_max_dates%found then
21476 -- cursor to find the object
21477 open c_find_PAT_in_target( l_min_esd,l_max_eed,
21478 p_target_business_group_id, nvl(l_popl_actn_typ_id, -999) ) ;
21479 fetch c_find_PAT_in_target into l_new_value ;
21480 if c_find_PAT_in_target%found then
21481 --
21482 --TEMPIK
21483 l_dt_rec_found := dt_api.check_min_max_dates
21484 (p_base_table_name => 'BEN_POPL_ACTN_TYP_F',
21485 p_base_key_column => 'POPL_ACTN_TYP_ID',
21486 p_base_key_value => l_new_value,
21487 p_from_date => l_min_esd,
21488 p_to_date => l_max_eed );
21489 if l_dt_rec_found THEN
21490 --END TEMPIK
21491 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
21492 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
21493 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ACTN_TYP_ID' ;
21494 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PAT_unique.information1 ;
21495 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
21496 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
21497 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;
21498 --
21499 -- 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) ;
21500 --
21501 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21502 end if ;
21503 --
21504 l_object_found_in_target := true ;
21505 --TEMPIK
21506 end if; -- l_dt_rec_found
21507 --END TEMPIK
21508 end if;
21509 close c_find_PAT_in_target ;
21510 --
21511 end if;
21512 end if ;
21513 --
21514 close c_PAT_min_max_dates ;
21515 end if; --if p_dml_operation
21516 --
21517 if (not l_object_found_in_target OR l_update ) and l_ACTN_TYP_ID is not null then
21518 --
21519 l_current_pk_id := r_PAT.information1;
21520 --
21521 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
21522 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
21523 --
21524 if l_current_pk_id = l_prev_pk_id then
21525 --
21526 l_first_rec := false ;
21527 --
21528 else
21529 --
21530 l_first_rec := true ;
21531 --
21532 end if ;
21533 --
21534
21535 l_effective_date := r_PAT.information2;
21536 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21537 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
21538 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
21539 end if;
21540
21541 if l_first_rec and not l_update then
21542 -- Call Create routine.
21543 hr_utility.set_location(' BEN_POPL_ACTN_TYP_F CREATE_POPL_ACTION_TYPE ',20);
21544 BEN_POPL_ACTION_TYPE_API.CREATE_POPL_ACTION_TYPE(
21545 --
21546 P_VALIDATE => false
21547 ,P_EFFECTIVE_DATE => l_effective_date
21548 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
21549 --
21550 ,P_ACTN_TYP_DUE_DT_CD => r_PAT.INFORMATION11
21551 ,P_ACTN_TYP_DUE_DT_RL => l_ACTN_TYP_DUE_DT_RL
21552 ,P_ACTN_TYP_ID => l_ACTN_TYP_ID
21553 ,P_PAT_ATTRIBUTE1 => r_PAT.INFORMATION111
21554 ,P_PAT_ATTRIBUTE10 => r_PAT.INFORMATION120
21555 ,P_PAT_ATTRIBUTE11 => r_PAT.INFORMATION121
21556 ,P_PAT_ATTRIBUTE12 => r_PAT.INFORMATION122
21557 ,P_PAT_ATTRIBUTE13 => r_PAT.INFORMATION123
21558 ,P_PAT_ATTRIBUTE14 => r_PAT.INFORMATION124
21559 ,P_PAT_ATTRIBUTE15 => r_PAT.INFORMATION125
21560 ,P_PAT_ATTRIBUTE16 => r_PAT.INFORMATION126
21561 ,P_PAT_ATTRIBUTE17 => r_PAT.INFORMATION127
21562 ,P_PAT_ATTRIBUTE18 => r_PAT.INFORMATION128
21563 ,P_PAT_ATTRIBUTE19 => r_PAT.INFORMATION129
21564 ,P_PAT_ATTRIBUTE2 => r_PAT.INFORMATION112
21565 ,P_PAT_ATTRIBUTE20 => r_PAT.INFORMATION130
21566 ,P_PAT_ATTRIBUTE21 => r_PAT.INFORMATION131
21567 ,P_PAT_ATTRIBUTE22 => r_PAT.INFORMATION132
21568 ,P_PAT_ATTRIBUTE23 => r_PAT.INFORMATION133
21569 ,P_PAT_ATTRIBUTE24 => r_PAT.INFORMATION134
21570 ,P_PAT_ATTRIBUTE25 => r_PAT.INFORMATION135
21571 ,P_PAT_ATTRIBUTE26 => r_PAT.INFORMATION136
21572 ,P_PAT_ATTRIBUTE27 => r_PAT.INFORMATION137
21573 ,P_PAT_ATTRIBUTE28 => r_PAT.INFORMATION138
21574 ,P_PAT_ATTRIBUTE29 => r_PAT.INFORMATION139
21575 ,P_PAT_ATTRIBUTE3 => r_PAT.INFORMATION113
21576 ,P_PAT_ATTRIBUTE30 => r_PAT.INFORMATION140
21577 ,P_PAT_ATTRIBUTE4 => r_PAT.INFORMATION114
21578 ,P_PAT_ATTRIBUTE5 => r_PAT.INFORMATION115
21579 ,P_PAT_ATTRIBUTE6 => r_PAT.INFORMATION116
21580 ,P_PAT_ATTRIBUTE7 => r_PAT.INFORMATION117
21581 ,P_PAT_ATTRIBUTE8 => r_PAT.INFORMATION118
21582 ,P_PAT_ATTRIBUTE9 => r_PAT.INFORMATION119
21583 ,P_PAT_ATTRIBUTE_CATEGORY => r_PAT.INFORMATION110
21584 ,P_PGM_ID => l_PGM_ID
21585 ,P_PL_ID => l_PL_ID
21586 ,P_POPL_ACTN_TYP_ID => l_popl_actn_typ_id
21587 --
21588 ,P_EFFECTIVE_START_DATE => l_effective_start_date
21589 ,P_EFFECTIVE_END_DATE => l_effective_end_date
21590 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
21591 );
21592 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
21593 -- Update all relevent cer records with new pk_id
21594 hr_utility.set_location('Before plsql table ',222);
21595 hr_utility.set_location('new_value id '||l_popl_actn_typ_id,222);
21596 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'POPL_ACTN_TYP_ID' ;
21597 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PAT.information1 ;
21598 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_POPL_ACTN_TYP_ID ;
21599 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
21600 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;
21601 hr_utility.set_location('After plsql table ',222);
21602 --
21603 -- 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 ) ;
21604 --
21605 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21606 --
21607 else
21608 --
21609 -- Call Update routine for the pk_id created in prev run .
21610 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
21611 hr_utility.set_location(' BEN_POPL_ACTN_TYP_F UPDATE_POPL_ACTION_TYPE ',30);
21612 --UPD START
21613 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
21614 --
21615 if l_update then
21616 --
21617 l_datetrack_mode := r_PAT.datetrack_mode ;
21618 --
21619 get_dt_modes(
21620 p_effective_date => l_process_date,
21621 p_effective_end_date => r_PAT.information3,
21622 p_effective_start_date => r_PAT.information2,
21623 p_dml_operation => r_PAT.dml_operation,
21624 p_datetrack_mode => l_datetrack_mode );
21625 -- p_update => l_update
21626 --
21627 l_effective_date := l_process_date;
21628 l_POPL_ACTN_TYP_ID := r_PAT.information1;
21629 l_object_version_number := r_PAT.information265;
21630 --
21631 end if;
21632 --
21633 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
21634 --
21635 IF l_update OR l_dml_operation <> 'UPDATE' THEN
21636 --UPD END
21637 BEN_POPL_ACTION_TYPE_API.UPDATE_POPL_ACTION_TYPE(
21638 --
21639 P_VALIDATE => false
21640 ,P_EFFECTIVE_DATE => l_effective_date
21641 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
21642 --
21643 ,P_ACTN_TYP_DUE_DT_CD => r_PAT.INFORMATION11
21644 ,P_ACTN_TYP_DUE_DT_RL => l_ACTN_TYP_DUE_DT_RL
21645 ,P_ACTN_TYP_ID => l_ACTN_TYP_ID
21646 ,P_PAT_ATTRIBUTE1 => r_PAT.INFORMATION111
21647 ,P_PAT_ATTRIBUTE10 => r_PAT.INFORMATION120
21648 ,P_PAT_ATTRIBUTE11 => r_PAT.INFORMATION121
21649 ,P_PAT_ATTRIBUTE12 => r_PAT.INFORMATION122
21650 ,P_PAT_ATTRIBUTE13 => r_PAT.INFORMATION123
21651 ,P_PAT_ATTRIBUTE14 => r_PAT.INFORMATION124
21652 ,P_PAT_ATTRIBUTE15 => r_PAT.INFORMATION125
21653 ,P_PAT_ATTRIBUTE16 => r_PAT.INFORMATION126
21654 ,P_PAT_ATTRIBUTE17 => r_PAT.INFORMATION127
21655 ,P_PAT_ATTRIBUTE18 => r_PAT.INFORMATION128
21656 ,P_PAT_ATTRIBUTE19 => r_PAT.INFORMATION129
21657 ,P_PAT_ATTRIBUTE2 => r_PAT.INFORMATION112
21658 ,P_PAT_ATTRIBUTE20 => r_PAT.INFORMATION130
21659 ,P_PAT_ATTRIBUTE21 => r_PAT.INFORMATION131
21660 ,P_PAT_ATTRIBUTE22 => r_PAT.INFORMATION132
21661 ,P_PAT_ATTRIBUTE23 => r_PAT.INFORMATION133
21662 ,P_PAT_ATTRIBUTE24 => r_PAT.INFORMATION134
21663 ,P_PAT_ATTRIBUTE25 => r_PAT.INFORMATION135
21664 ,P_PAT_ATTRIBUTE26 => r_PAT.INFORMATION136
21665 ,P_PAT_ATTRIBUTE27 => r_PAT.INFORMATION137
21666 ,P_PAT_ATTRIBUTE28 => r_PAT.INFORMATION138
21667 ,P_PAT_ATTRIBUTE29 => r_PAT.INFORMATION139
21668 ,P_PAT_ATTRIBUTE3 => r_PAT.INFORMATION113
21669 ,P_PAT_ATTRIBUTE30 => r_PAT.INFORMATION140
21670 ,P_PAT_ATTRIBUTE4 => r_PAT.INFORMATION114
21671 ,P_PAT_ATTRIBUTE5 => r_PAT.INFORMATION115
21672 ,P_PAT_ATTRIBUTE6 => r_PAT.INFORMATION116
21673 ,P_PAT_ATTRIBUTE7 => r_PAT.INFORMATION117
21674 ,P_PAT_ATTRIBUTE8 => r_PAT.INFORMATION118
21675 ,P_PAT_ATTRIBUTE9 => r_PAT.INFORMATION119
21676 ,P_PAT_ATTRIBUTE_CATEGORY => r_PAT.INFORMATION110
21677 ,P_PGM_ID => l_PGM_ID
21678 ,P_PL_ID => l_PL_ID
21679 ,P_POPL_ACTN_TYP_ID => l_popl_actn_typ_id
21680 --
21681 ,P_EFFECTIVE_START_DATE => l_effective_start_date
21682 ,P_EFFECTIVE_END_DATE => l_effective_end_date
21683 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
21684 ,P_DATETRACK_MODE => l_datetrack_mode
21685 );
21686 --
21687 end if; -- l_update
21688 end if;
21689 --
21690 -- Delete the row if it is end dated.
21691 --
21692 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
21693 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
21694 trunc(l_max_eed) = r_PAT.information3) then
21695 --
21696 BEN_POPL_ACTION_TYPE_API.delete_POPL_ACTION_TYPE(
21697 --
21698 p_validate => false
21699 ,p_popl_actn_typ_id => l_popl_actn_typ_id
21700 ,p_effective_start_date => l_effective_start_date
21701 ,p_effective_end_date => l_effective_end_date
21702 ,p_object_version_number => l_object_version_number
21703 ,p_effective_date => l_max_eed
21704 ,p_datetrack_mode => hr_api.g_delete
21705 --
21706 );
21707 --
21708 end if;
21709 --
21710 l_prev_pk_id := l_current_pk_id ;
21711 --
21712 end if;
21713 --
21714 end if;
21715 --
21716 end if;
21717 --
21718 end loop;
21719 --
21720 exception when others then
21721 --
21722 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PAT',r_pat.information5 );
21723 --
21724 end create_PAT_rows;
21725 --
21726 ---------------------------------------------------------------
21727 ----------------------< create_PEO_rows >-----------------------
21728 ---------------------------------------------------------------
21729 --
21730 procedure create_PEO_rows
21731 (
21732 p_validate in number default 0
21733 ,p_copy_entity_txn_id in number
21734 ,p_effective_date in date
21735 ,p_prefix_suffix_text in varchar2 default null
21736 ,p_reuse_object_flag in varchar2 default null
21737 ,p_target_business_group_id in varchar2 default null
21738 ,p_prefix_suffix_cd in varchar2 default null
21739 ) is
21740 --
21741 l_LER_ID number;
21742 l_MX_POE_DET_DT_RL number;
21743 l_MX_POE_RL number;
21744 l_OIPL_ID number;
21745 l_PGM_ID number;
21746 l_PLIP_ID number;
21747 l_PL_ID number;
21748 l_PRTN_EFF_END_DT_RL number;
21749 l_PRTN_EFF_STRT_DT_RL number;
21750 l_PTIP_ID number;
21751 l_VRFY_FMLY_MMBR_RL number;
21752 l_WAIT_PERD_DT_TO_USE_RL number;
21753 l_WAIT_PERD_RL number;
21754 cursor c_unique_PEO(l_table_alias varchar2) is
21755 select distinct cpe.information1,
21756 cpe.information2,
21757 cpe.information3,
21758 cpe.table_route_id
21759 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
21760 pqh_table_route tr
21761 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21762 and cpe.table_route_id = tr.table_route_id
21763 -- and tr.where_clause = l_BEN_ELIG_TO_PRTE_RSN_F
21764 and tr.table_alias = l_table_alias
21765 and cpe.number_of_copies = 1 -- ADDITION
21766 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
21767 order by information1, information2; --added for bug: 5151945
21768 --
21769 --
21770 cursor c_PEO_min_max_dates(c_table_route_id number,
21771 c_information1 number) is
21772 select
21773 min(cpe.information2) min_esd,
21774 max(cpe.information3) min_eed
21775 from ben_copy_entity_results cpe
21776 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21777 and cpe.table_route_id = c_table_route_id
21778 and cpe.information1 = c_information1 ;
21779 --
21780 cursor c_PEO(c_table_route_id number,
21781 c_information1 number,
21782 c_information2 date,
21783 c_information3 date) is
21784 select
21785 cpe.*
21786 from ben_copy_entity_results cpe
21787 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
21788 and cpe.table_route_id = c_table_route_id
21789 and cpe.information1 = c_information1
21790 and cpe.information2 = c_information2
21791 and cpe.information3 = c_information3
21792 and rownum = 1 ;
21793 -- Date Track target record
21794 cursor c_find_PEO_in_target(
21795 c_effective_start_date date,
21796 c_effective_end_date date,
21797 c_business_group_id number,
21798 c_new_pk_id number) is
21799 select
21800 PEO.elig_to_prte_rsn_id new_value
21801 from BEN_ELIG_TO_PRTE_RSN_F PEO
21802 where
21803 PEO.LER_ID = l_LER_ID and
21804 nvl(PEO.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
21805 nvl(PEO.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
21806 nvl(PEO.PLIP_ID,-999) = nvl(l_PLIP_ID,-999) and
21807 nvl(PEO.PL_ID,-999) = nvl(l_PL_ID,-999) and
21808 nvl(PEO.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
21809 PEO.business_group_id = c_business_group_id
21810 and PEO.elig_to_prte_rsn_id <> c_new_pk_id
21811 --TEMPIK
21812 and c_effective_start_date between effective_start_date
21813 and effective_end_date ;
21814 --END TEMPIK
21815 /*
21816 and exists ( select null
21817 from BEN_ELIG_TO_PRTE_RSN_F PEO1
21818 where
21819 PEO1.LER_ID = l_LER_ID and
21820 nvl(PEO1.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
21821 nvl(PEO1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
21822 nvl(PEO1.PLIP_ID,-999) = nvl(l_PLIP_ID,-999) and
21823 nvl(PEO1.PL_ID,-999) = nvl(l_PL_ID,-999) and
21824 nvl(PEO1.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
21825 PEO1.business_group_id = c_business_group_id
21826 and PEO1.effective_start_date <= c_effective_start_date )
21827 and exists ( select null
21828 from BEN_ELIG_TO_PRTE_RSN_F PEO2
21829 where
21830 PEO2.LER_ID = l_LER_ID and
21831 nvl(PEO2.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
21832 nvl(PEO2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
21833 nvl(PEO2.PLIP_ID,-999) = nvl(l_PLIP_ID,-999) and
21834 nvl(PEO2.PL_ID,-999) = nvl(l_PL_ID,-999) and
21835 nvl(PEO2.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
21836 PEO2.business_group_id = c_business_group_id
21837 and PEO2.effective_end_date >= c_effective_end_date )
21838 ;
21839 */
21840 --
21841 --UPD START
21842 --
21843 l_update boolean := false ;
21844 l_datetrack_mode varchar2(80) := hr_api.g_update;
21845 l_process_date date;
21846 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
21847 --
21848 --UPD END
21849 l_current_pk_id number := null ;
21850 l_prev_pk_id number := null ;
21851 l_first_rec boolean := true ;
21852 r_PEO c_PEO%rowtype;
21853 l_elig_to_prte_rsn_id number ;
21854 l_object_version_number number ;
21855 l_effective_start_date date ;
21856 l_effective_end_date date ;
21857 l_prefix pqh_copy_entity_attribs.information1%type := null;
21858 l_suffix pqh_copy_entity_attribs.information1%type := null;
21859 l_new_value number(15);
21860 l_object_found_in_target boolean := false ;
21861 l_min_esd date;
21862 l_max_eed date;
21863 l_effective_date date;
21864 --TEMPIK
21865 l_dt_rec_found boolean ;
21866 --END TEMPIK
21867 --
21868 begin
21869 -- Initialization
21870 l_object_found_in_target := false ;
21871 -- End Initialization
21872 -- Derive the prefix - sufix
21873 if p_prefix_suffix_cd = 'PREFIX' then
21874 l_prefix := p_prefix_suffix_text ;
21875 elsif p_prefix_suffix_cd = 'SUFFIX' then
21876 l_suffix := p_prefix_suffix_text ;
21877 else
21878 l_prefix := null ;
21879 l_suffix := null ;
21880 end if ;
21881 -- End Prefix Sufix derivation
21882 for r_PEO_unique in c_unique_PEO('PEO') loop
21883
21884 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
21885 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21886 r_PEO_unique.information3 >=
21887 ben_pd_copy_to_ben_one.g_copy_effective_date)
21888 ) then
21889
21890 --
21891 hr_utility.set_location(' r_PEO_unique.table_route_id '||r_PEO_unique.table_route_id,10);
21892 hr_utility.set_location(' r_PEO_unique.information1 '||r_PEO_unique.information1,10);
21893 hr_utility.set_location( 'r_PEO_unique.information2 '||r_PEO_unique.information2,10);
21894 hr_utility.set_location( 'r_PEO_unique.information3 '||r_PEO_unique.information3,10);
21895 -- If reuse objects flag is 'Y' then check for the object in the target business group
21896 -- if found insert the record into PLSql table and exit the loop else try create the
21897 -- object in the target business group
21898 --
21899 l_object_found_in_target := false ;
21900 --UPD START
21901 open c_PEO(r_PEO_unique.table_route_id,
21902 r_PEO_unique.information1,
21903 r_PEO_unique.information2,
21904 r_PEO_unique.information3 ) ;
21905 --
21906 fetch c_PEO into r_PEO ;
21907 --
21908 close c_PEO ;
21909 --
21910 l_dml_operation:= r_PEO_unique.dml_operation ;
21911 l_LER_ID := get_fk('LER_ID', r_PEO.information257,l_dml_operation );
21912 hr_utility.set_location(' l_LER_ID '||l_LER_ID ,123);
21913 l_MX_POE_DET_DT_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION272,l_dml_operation );
21914 l_MX_POE_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION270,l_dml_operation );
21915 l_OIPL_ID := get_fk('OIPL_ID', r_PEO.INFORMATION258,l_dml_operation );
21916 l_PGM_ID := get_fk('PGM_ID', r_PEO.INFORMATION260,l_dml_operation );
21917 l_PLIP_ID := get_fk('PLIP_ID', r_PEO.INFORMATION256,l_dml_operation );
21918 l_PL_ID := get_fk('PL_ID', r_PEO.INFORMATION261,l_dml_operation );
21919 l_PRTN_EFF_END_DT_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION266,l_dml_operation );
21920 l_PRTN_EFF_STRT_DT_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION264,l_dml_operation );
21921 l_PTIP_ID := get_fk('PTIP_ID', r_PEO.INFORMATION259,l_dml_operation );
21922 l_VRFY_FMLY_MMBR_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION273,l_dml_operation );
21923 l_WAIT_PERD_DT_TO_USE_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION268,l_dml_operation );
21924 l_WAIT_PERD_RL := get_fk('FORMULA_ID', r_PEO.INFORMATION271,l_dml_operation );
21925 --
21926 l_update := false;
21927 l_process_date := p_effective_date;
21928 --
21929 if l_dml_operation = 'UPDATE' then
21930 --
21931 l_object_found_in_target := TRUE;
21932 --
21933 if l_process_date between r_PEO_unique.information2 and r_PEO_unique.information3 then
21934 l_update := true;
21935 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)
21936 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'
21937 then
21938 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' ;
21939 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PEO_unique.information1 ;
21940 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PEO_unique.information1 ;
21941 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
21942 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;
21943 --
21944 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
21945 --
21946 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
21947 --
21948 --DOUBT log_data('PEO',l_new_value,l_prefix || r_PEO_unique.name|| l_suffix,'REUSED');
21949 --
21950 end if ;
21951 hr_utility.set_location( 'found record for update',10);
21952 --
21953 else
21954 --
21955 l_update := false;
21956 --
21957 end if;
21958 else
21959 --
21960 --UPD END
21961 l_min_esd := null ;
21962 l_max_eed := null ;
21963 open c_PEO_min_max_dates(r_PEO_unique.table_route_id, r_PEO_unique.information1 ) ;
21964 fetch c_PEO_min_max_dates into l_min_esd,l_max_eed ;
21965 --
21966
21967 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
21968 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
21969 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
21970 end if;
21971 l_min_esd := greatest(l_min_esd,r_PEO_unique.information2);
21972 /* open c_PEO(r_PEO_unique.table_route_id,
21973 r_PEO_unique.information1,
21974 r_PEO_unique.information2,
21975 r_PEO_unique.information3 ) ;
21976 --
21977 fetch c_PEO into r_PEO ;
21978 --
21979 close c_PEO ; */
21980 --
21981 hr_utility.set_location('g_count '||BEN_PD_COPY_TO_BEN_ONE.g_count,123);
21982 hr_utility.set_location('r_PEO.information14 '||r_PEO.information14 ,123);
21983 --
21984
21985 if p_reuse_object_flag = 'Y' then
21986 if c_PEO_min_max_dates%found then
21987 -- cursor to find the object
21988 open c_find_PEO_in_target( l_min_esd,l_max_eed,
21989 p_target_business_group_id, nvl(l_elig_to_prte_rsn_id, -999) ) ;
21990 fetch c_find_PEO_in_target into l_new_value ;
21991 if c_find_PEO_in_target%found then
21992 --
21993 --TEMPIK
21994 l_dt_rec_found := dt_api.check_min_max_dates
21995 (p_base_table_name => 'BEN_ELIG_TO_PRTE_RSN_F',
21996 p_base_key_column => 'ELIG_TO_PRTE_RSN_ID',
21997 p_base_key_value => l_new_value,
21998 p_from_date => l_min_esd,
21999 p_to_date => l_max_eed );
22000 if l_dt_rec_found THEN
22001 --END TEMPIK
22002 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
22003 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
22004 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' ;
22005 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PEO_unique.information1 ;
22006 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
22007 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
22008 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;
22009 --
22010 -- 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) ;
22011 --
22012 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22013 end if ;
22014 --
22015 l_object_found_in_target := true ;
22016 --TEMPIK
22017 end if; -- l_dt_rec_found
22018 --END TEMPIK
22019 end if;
22020 close c_find_PEO_in_target ;
22021 --
22022 end if;
22023 end if ;
22024 --
22025 close c_PEO_min_max_dates ;
22026 end if; --if p_dml_operation
22027 --
22028 if not l_object_found_in_target OR l_update then
22029 --
22030 l_current_pk_id := r_PEO.information1;
22031 --
22032 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
22033 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
22034 --
22035 if l_current_pk_id = l_prev_pk_id then
22036 --
22037 l_first_rec := false ;
22038 --
22039 else
22040 --
22041 l_first_rec := true ;
22042 --
22043 end if ;
22044 --
22045
22046 l_effective_date := r_PEO.information2;
22047 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
22048 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
22049 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
22050 end if;
22051
22052 if l_first_rec and not l_update then
22053 -- Call Create routine.
22054 hr_utility.set_location(' BEN_ELIG_TO_PRTE_RSN_F CREATE_ELIG_TO_PRTE_REASON ',20);
22055 BEN_ELIG_TO_PRTE_REASON_API.CREATE_ELIG_TO_PRTE_REASON(
22056 --
22057 P_VALIDATE => false
22058 ,P_EFFECTIVE_DATE => l_effective_date
22059 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
22060 --
22061 ,P_ELIG_INELIG_CD => r_PEO.INFORMATION21
22062 ,P_ELIG_TO_PRTE_RSN_ID => l_elig_to_prte_rsn_id
22063 ,P_IGNR_PRTN_OVRID_FLAG => r_PEO.INFORMATION20
22064 ,P_LER_ID => l_LER_ID
22065 ,P_MX_POE_APLS_CD => r_PEO.INFORMATION17
22066 ,P_MX_POE_DET_DT_CD => r_PEO.INFORMATION16
22067 ,P_MX_POE_DET_DT_RL => l_MX_POE_DET_DT_RL
22068 ,P_MX_POE_RL => l_MX_POE_RL
22069 ,P_MX_POE_UOM => r_PEO.INFORMATION15
22070 ,P_MX_POE_VAL => r_PEO.INFORMATION269
22071 ,P_OIPL_ID => l_OIPL_ID
22072 ,P_PEO_ATTRIBUTE1 => r_PEO.INFORMATION111
22073 ,P_PEO_ATTRIBUTE10 => r_PEO.INFORMATION120
22074 ,P_PEO_ATTRIBUTE11 => r_PEO.INFORMATION121
22075 ,P_PEO_ATTRIBUTE12 => r_PEO.INFORMATION122
22076 ,P_PEO_ATTRIBUTE13 => r_PEO.INFORMATION123
22077 ,P_PEO_ATTRIBUTE14 => r_PEO.INFORMATION124
22078 ,P_PEO_ATTRIBUTE15 => r_PEO.INFORMATION125
22079 ,P_PEO_ATTRIBUTE16 => r_PEO.INFORMATION126
22080 ,P_PEO_ATTRIBUTE17 => r_PEO.INFORMATION127
22081 ,P_PEO_ATTRIBUTE18 => r_PEO.INFORMATION128
22082 ,P_PEO_ATTRIBUTE19 => r_PEO.INFORMATION129
22083 ,P_PEO_ATTRIBUTE2 => r_PEO.INFORMATION112
22084 ,P_PEO_ATTRIBUTE20 => r_PEO.INFORMATION130
22085 ,P_PEO_ATTRIBUTE21 => r_PEO.INFORMATION131
22086 ,P_PEO_ATTRIBUTE22 => r_PEO.INFORMATION132
22087 ,P_PEO_ATTRIBUTE23 => r_PEO.INFORMATION133
22088 ,P_PEO_ATTRIBUTE24 => r_PEO.INFORMATION134
22089 ,P_PEO_ATTRIBUTE25 => r_PEO.INFORMATION135
22090 ,P_PEO_ATTRIBUTE26 => r_PEO.INFORMATION136
22091 ,P_PEO_ATTRIBUTE27 => r_PEO.INFORMATION137
22092 ,P_PEO_ATTRIBUTE28 => r_PEO.INFORMATION138
22093 ,P_PEO_ATTRIBUTE29 => r_PEO.INFORMATION139
22094 ,P_PEO_ATTRIBUTE3 => r_PEO.INFORMATION113
22095 ,P_PEO_ATTRIBUTE30 => r_PEO.INFORMATION140
22096 ,P_PEO_ATTRIBUTE4 => r_PEO.INFORMATION114
22097 ,P_PEO_ATTRIBUTE5 => r_PEO.INFORMATION115
22098 ,P_PEO_ATTRIBUTE6 => r_PEO.INFORMATION116
22099 ,P_PEO_ATTRIBUTE7 => r_PEO.INFORMATION117
22100 ,P_PEO_ATTRIBUTE8 => r_PEO.INFORMATION118
22101 ,P_PEO_ATTRIBUTE9 => r_PEO.INFORMATION119
22102 ,P_PEO_ATTRIBUTE_CATEGORY => r_PEO.INFORMATION110
22103 ,P_PGM_ID => l_PGM_ID
22104 ,P_PLIP_ID => l_PLIP_ID
22105 ,P_PL_ID => l_PL_ID
22106 ,P_PRTN_EFF_END_DT_CD => r_PEO.INFORMATION12
22107 ,P_PRTN_EFF_END_DT_RL => l_PRTN_EFF_END_DT_RL
22108 ,P_PRTN_EFF_STRT_DT_CD => r_PEO.INFORMATION11
22109 ,P_PRTN_EFF_STRT_DT_RL => l_PRTN_EFF_STRT_DT_RL
22110 ,P_PRTN_OVRIDBL_FLAG => r_PEO.INFORMATION19
22111 ,P_PTIP_ID => l_PTIP_ID
22112 ,P_VRFY_FMLY_MMBR_CD => r_PEO.INFORMATION18
22113 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
22114 ,P_WAIT_PERD_DT_TO_USE_CD => r_PEO.INFORMATION14
22115 ,P_WAIT_PERD_DT_TO_USE_RL => l_WAIT_PERD_DT_TO_USE_RL
22116 ,P_WAIT_PERD_RL => l_WAIT_PERD_RL
22117 ,P_WAIT_PERD_UOM => r_PEO.INFORMATION13
22118 ,P_WAIT_PERD_VAL => r_PEO.INFORMATION267
22119 --
22120 ,P_EFFECTIVE_START_DATE => l_effective_start_date
22121 ,P_EFFECTIVE_END_DATE => l_effective_end_date
22122 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
22123 );
22124 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
22125 -- Update all relevent cer records with new pk_id
22126 hr_utility.set_location('Before plsql table ',222);
22127 hr_utility.set_location('new_value id '||l_elig_to_prte_rsn_id,222);
22128 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' ;
22129 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PEO.information1 ;
22130 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 ;
22131 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
22132 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;
22133 hr_utility.set_location('After plsql table ',222);
22134 --
22135 -- 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 ) ;
22136 --
22137 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22138 --
22139 else
22140 --
22141 -- Call Update routine for the pk_id created in prev run .
22142 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
22143 hr_utility.set_location(' BEN_ELIG_TO_PRTE_RSN_F UPDATE_ELIG_TO_PRTE_REASON ',30);
22144 --UPD START
22145 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
22146 --
22147 if l_update then
22148 --
22149 l_datetrack_mode := r_PEO.datetrack_mode ;
22150 --
22151 get_dt_modes(
22152 p_effective_date => l_process_date,
22153 p_effective_end_date => r_PEO.information3,
22154 p_effective_start_date => r_PEO.information2,
22155 p_dml_operation => r_PEO.dml_operation,
22156 p_datetrack_mode => l_datetrack_mode );
22157 -- p_update => l_update
22158 --
22159 l_effective_date := l_process_date;
22160 l_ELIG_TO_PRTE_RSN_ID := r_PEO.information1;
22161 l_object_version_number := r_PEO.information265;
22162 --
22163 end if;
22164 --
22165 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
22166 --
22167 IF l_update OR l_dml_operation <> 'UPDATE' THEN
22168 --UPD END
22169 BEN_ELIG_TO_PRTE_REASON_API.UPDATE_ELIG_TO_PRTE_REASON(
22170 --
22171 P_VALIDATE => false
22172 ,P_EFFECTIVE_DATE => l_effective_date
22173 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
22174 --
22175 ,P_ELIG_INELIG_CD => r_PEO.INFORMATION21
22176 ,P_ELIG_TO_PRTE_RSN_ID => l_elig_to_prte_rsn_id
22177 ,P_IGNR_PRTN_OVRID_FLAG => r_PEO.INFORMATION20
22178 ,P_LER_ID => l_LER_ID
22179 ,P_MX_POE_APLS_CD => r_PEO.INFORMATION17
22180 ,P_MX_POE_DET_DT_CD => r_PEO.INFORMATION16
22181 ,P_MX_POE_DET_DT_RL => l_MX_POE_DET_DT_RL
22182 ,P_MX_POE_RL => l_MX_POE_RL
22183 ,P_MX_POE_UOM => r_PEO.INFORMATION15
22184 ,P_MX_POE_VAL => r_PEO.INFORMATION269
22185 ,P_OIPL_ID => l_OIPL_ID
22186 ,P_PEO_ATTRIBUTE1 => r_PEO.INFORMATION111
22187 ,P_PEO_ATTRIBUTE10 => r_PEO.INFORMATION120
22188 ,P_PEO_ATTRIBUTE11 => r_PEO.INFORMATION121
22189 ,P_PEO_ATTRIBUTE12 => r_PEO.INFORMATION122
22190 ,P_PEO_ATTRIBUTE13 => r_PEO.INFORMATION123
22191 ,P_PEO_ATTRIBUTE14 => r_PEO.INFORMATION124
22192 ,P_PEO_ATTRIBUTE15 => r_PEO.INFORMATION125
22193 ,P_PEO_ATTRIBUTE16 => r_PEO.INFORMATION126
22194 ,P_PEO_ATTRIBUTE17 => r_PEO.INFORMATION127
22195 ,P_PEO_ATTRIBUTE18 => r_PEO.INFORMATION128
22196 ,P_PEO_ATTRIBUTE19 => r_PEO.INFORMATION129
22197 ,P_PEO_ATTRIBUTE2 => r_PEO.INFORMATION112
22198 ,P_PEO_ATTRIBUTE20 => r_PEO.INFORMATION130
22199 ,P_PEO_ATTRIBUTE21 => r_PEO.INFORMATION131
22200 ,P_PEO_ATTRIBUTE22 => r_PEO.INFORMATION132
22201 ,P_PEO_ATTRIBUTE23 => r_PEO.INFORMATION133
22202 ,P_PEO_ATTRIBUTE24 => r_PEO.INFORMATION134
22203 ,P_PEO_ATTRIBUTE25 => r_PEO.INFORMATION135
22204 ,P_PEO_ATTRIBUTE26 => r_PEO.INFORMATION136
22205 ,P_PEO_ATTRIBUTE27 => r_PEO.INFORMATION137
22206 ,P_PEO_ATTRIBUTE28 => r_PEO.INFORMATION138
22207 ,P_PEO_ATTRIBUTE29 => r_PEO.INFORMATION139
22208 ,P_PEO_ATTRIBUTE3 => r_PEO.INFORMATION113
22209 ,P_PEO_ATTRIBUTE30 => r_PEO.INFORMATION140
22210 ,P_PEO_ATTRIBUTE4 => r_PEO.INFORMATION114
22211 ,P_PEO_ATTRIBUTE5 => r_PEO.INFORMATION115
22212 ,P_PEO_ATTRIBUTE6 => r_PEO.INFORMATION116
22213 ,P_PEO_ATTRIBUTE7 => r_PEO.INFORMATION117
22214 ,P_PEO_ATTRIBUTE8 => r_PEO.INFORMATION118
22215 ,P_PEO_ATTRIBUTE9 => r_PEO.INFORMATION119
22216 ,P_PEO_ATTRIBUTE_CATEGORY => r_PEO.INFORMATION110
22217 ,P_PGM_ID => l_PGM_ID
22218 ,P_PLIP_ID => l_PLIP_ID
22219 ,P_PL_ID => l_PL_ID
22220 ,P_PRTN_EFF_END_DT_CD => r_PEO.INFORMATION12
22221 ,P_PRTN_EFF_END_DT_RL => l_PRTN_EFF_END_DT_RL
22222 ,P_PRTN_EFF_STRT_DT_CD => r_PEO.INFORMATION11
22223 ,P_PRTN_EFF_STRT_DT_RL => l_PRTN_EFF_STRT_DT_RL
22224 ,P_PRTN_OVRIDBL_FLAG => r_PEO.INFORMATION19
22225 ,P_PTIP_ID => l_PTIP_ID
22226 ,P_VRFY_FMLY_MMBR_CD => r_PEO.INFORMATION18
22227 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
22228 ,P_WAIT_PERD_DT_TO_USE_CD => r_PEO.INFORMATION14
22229 ,P_WAIT_PERD_DT_TO_USE_RL => l_WAIT_PERD_DT_TO_USE_RL
22230 ,P_WAIT_PERD_RL => l_WAIT_PERD_RL
22231 ,P_WAIT_PERD_UOM => r_PEO.INFORMATION13
22232 ,P_WAIT_PERD_VAL => r_PEO.INFORMATION267
22233 --
22234 ,P_EFFECTIVE_START_DATE => l_effective_start_date
22235 ,P_EFFECTIVE_END_DATE => l_effective_end_date
22236 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
22237 ,P_DATETRACK_MODE => l_datetrack_mode
22238 );
22239 --
22240 end if; -- l_update
22241 end if;
22242 --
22243 -- Delete the row if it is end dated.
22244 --
22245 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
22246 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
22247 trunc(l_max_eed) = r_PEO.information3) then
22248 --
22249 BEN_ELIG_TO_PRTE_REASON_API.delete_ELIG_TO_PRTE_REASON(
22250 --
22251 p_validate => false
22252 ,p_elig_to_prte_rsn_id => l_elig_to_prte_rsn_id
22253 ,p_effective_start_date => l_effective_start_date
22254 ,p_effective_end_date => l_effective_end_date
22255 ,p_object_version_number => l_object_version_number
22256 ,p_effective_date => l_max_eed
22257 ,p_datetrack_mode => hr_api.g_delete
22258 --
22259 );
22260 --
22261 end if;
22262 --
22263 l_prev_pk_id := l_current_pk_id ;
22264 --
22265 end if;
22266 --
22267 end if;
22268 --
22269 end loop;
22270 --
22271 exception when others then
22272 --
22273 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PEO',r_peo.information5 );
22274 --
22275 end create_PEO_rows;
22276
22277 --
22278 ---------------------------------------------------------------
22279 ----------------------< create_CWG_rows >-----------------------
22280 ---------------------------------------------------------------
22281 --
22282 procedure create_CWG_rows
22283 (
22284 p_validate in number default 0
22285 ,p_copy_entity_txn_id in number
22286 ,p_effective_date in date
22287 ,p_prefix_suffix_text in varchar2 default null
22288 ,p_reuse_object_flag in varchar2 default null
22289 ,p_target_business_group_id in varchar2 default null
22290 ,p_prefix_suffix_cd in varchar2 default null
22291 ) is
22292 --
22293 l_PL_ID number;
22294 l_WKSHT_GRP_CD ben_cwb_wksht_grp.wksht_grp_cd%type;
22295 cursor c_unique_CWG(l_table_alias varchar2) is
22296 select distinct cpe.information1,
22297 cpe.information2,
22298 cpe.information3,
22299 cpe.table_route_id
22300 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
22301 pqh_table_route tr
22302 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22303 and cpe.table_route_id = tr.table_route_id
22304 -- and tr.where_clause = l_BEN_CWB_WKSHT_GRP
22305 and tr.table_alias = l_table_alias
22306 and cpe.number_of_copies = 1 -- ADDITION
22307 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
22308 order by information1, information2; --added for bug: 5151945
22309 --
22310 --
22311 cursor c_CWG_min_max_dates(c_table_route_id number,
22312 c_information1 number) is
22313 select
22314 min(cpe.information2) min_esd,
22315 max(cpe.information3) min_eed
22316 from ben_copy_entity_results cpe
22317 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22318 and cpe.table_route_id = c_table_route_id
22319 and cpe.information1 = c_information1 ;
22320 --
22321 cursor c_CWG(c_table_route_id number,
22322 c_information1 number,
22323 c_information2 date,
22324 c_information3 date ) is
22325 select
22326 cpe.*
22327 from ben_copy_entity_results cpe
22328 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22329 and cpe.table_route_id = c_table_route_id
22330 and cpe.information1 = c_information1
22331 and rownum = 1 ;
22332 -- Date Track target record
22333 cursor c_find_CWG_in_target(
22334 c_effective_start_date date,
22335 c_effective_end_date date,
22336 c_business_group_id number,
22337 c_new_pk_id number) is
22338 select
22339 CWG.cwb_wksht_grp_id new_value
22340 from BEN_CWB_WKSHT_GRP CWG
22341 where
22342 CWG.PL_ID = l_PL_ID and
22343 CWG.WKSHT_GRP_CD = l_WKSHT_GRP_CD and
22344 CWG.business_group_id = c_business_group_id
22345 and CWG.cwb_wksht_grp_id <> c_new_pk_id
22346 ;
22347 --
22348 --UPD START
22349 --
22350 l_update boolean := false ;
22351 l_datetrack_mode varchar2(80) := hr_api.g_update;
22352 l_process_date date;
22353 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
22354 --
22355 --UPD END
22356 l_current_pk_id number := null ;
22357 l_prev_pk_id number := null ;
22358 l_first_rec boolean := true ;
22359 r_CWG c_CWG%rowtype;
22360 l_cwb_wksht_grp_id number ;
22361 l_object_version_number number ;
22362 l_effective_start_date date ;
22363 l_effective_end_date date ;
22364 l_prefix pqh_copy_entity_attribs.information1%type := null;
22365 l_suffix pqh_copy_entity_attribs.information1%type := null;
22366 l_new_value number(15);
22367 l_object_found_in_target boolean := false ;
22368 l_min_esd date;
22369 l_max_eed date;
22370 --
22371 begin
22372 -- Initialization
22373 l_object_found_in_target := false ;
22374 -- End Initialization
22375 -- Derive the prefix - sufix
22376 if p_prefix_suffix_cd = 'PREFIX' then
22377 l_prefix := p_prefix_suffix_text ;
22378 elsif p_prefix_suffix_cd = 'SUFFIX' then
22379 l_suffix := p_prefix_suffix_text ;
22380 else
22381 l_prefix := null ;
22382 l_suffix := null ;
22383 end if ;
22384 -- End Prefix Sufix derivation
22385 for r_CWG_unique in c_unique_CWG('CWG') loop
22386 --
22387 hr_utility.set_location(' r_CWG_unique.table_route_id '||r_CWG_unique.table_route_id,10);
22388 hr_utility.set_location(' r_CWG_unique.information1 '||r_CWG_unique.information1,10);
22389 hr_utility.set_location( 'r_CWG_unique.information2 '||r_CWG_unique.information2,10);
22390 hr_utility.set_location( 'r_CWG_unique.information3 '||r_CWG_unique.information3,10);
22391 -- If reuse objects flag is 'Y' then check for the object in the target business group
22392 -- if found insert the record into PLSql table and exit the loop else try create the
22393 -- object in the target business group
22394 --
22395 l_object_found_in_target := false ;
22396 l_min_esd := null ;
22397 l_max_eed := null ;
22398 --
22399 open c_CWG(r_CWG_unique.table_route_id,
22400 r_CWG_unique.information1,
22401 r_CWG_unique.information2,
22402 r_CWG_unique.information3 ) ;
22403 --
22404 fetch c_CWG into r_CWG ;
22405 --
22406 close c_CWG ;
22407 --
22408 --UPD START
22409 --
22410 l_update := false;
22411 l_process_date := p_effective_date;
22412 l_dml_operation:= r_CWG_unique.dml_operation ;
22413 --UPD START
22414 --
22415 l_PL_ID := get_fk('PL_ID', r_CWG.INFORMATION261,l_dml_operation);
22416 l_WKSHT_GRP_CD := r_CWG.INFORMATION11;
22417 --UPD START
22418 --
22419 if l_dml_operation = 'UPDATE' then
22420 --
22421 l_update := true;
22422 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
22423 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
22424 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'CWB_WKSHT_GRP_ID' ;
22425 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CWG_unique.information1 ;
22426 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_CWG_unique.information1 ;
22427 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
22428 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;
22429 --
22430 -- 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
22431 --
22432 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22433 --
22434 --DOUBT log_data('CWG',l_new_value,l_prefix || r_CWG_unique.name|| l_suffix,'REUSED');
22435 --
22436 end if ;
22437 l_CWB_WKSHT_GRP_ID := r_CWG_unique.information1 ;
22438 l_object_version_number := r_CWG.information265 ;
22439 hr_utility.set_location( 'found record for update',10);
22440 --
22441 else
22442 --
22443 --UPD END
22444 if p_reuse_object_flag = 'Y' then
22445 -- cursor to find the object
22446 open c_find_CWG_in_target( r_CWG_unique.information2,l_max_eed,
22447 p_target_business_group_id, nvl(l_cwb_wksht_grp_id, -999) ) ;
22448 fetch c_find_CWG_in_target into l_new_value ;
22449 if c_find_CWG_in_target%found then
22450 --
22451 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
22452 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
22453 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'CWB_WKSHT_GRP_ID' ;
22454 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CWG_unique.information1 ;
22455 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
22456 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
22457 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;
22458 --
22459 -- 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) ;
22460 --
22461 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22462 --
22463
22464 end if ;
22465 --
22466 l_object_found_in_target := true ;
22467 end if;
22468 close c_find_CWG_in_target ;
22469 --
22470 end if ;
22471 --
22472 end if; --if p_dml_operation
22473 --
22474 if not l_object_found_in_target OR l_update then
22475 --
22476 l_current_pk_id := r_CWG.information1;
22477 --
22478 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
22479 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
22480 --
22481 if l_current_pk_id = l_prev_pk_id then
22482 --
22483 l_first_rec := false ;
22484 --
22485 else
22486 --
22487 l_first_rec := true ;
22488 --
22489 end if ;
22490 --
22491 -- To avoid creating a child with out a parent
22492 --
22493 --
22494 if l_PL_ID is null then
22495 l_first_rec := false ;
22496 end if;
22497 --
22498 if l_first_rec and not l_update then
22499 -- Call Create routine.
22500 hr_utility.set_location(' BEN_CWB_WKSHT_GRP CREATE_CWB_WKSHT_GRP ',20);
22501 BEN_CWB_WKSHT_GRP_API.CREATE_CWB_WKSHT_GRP(
22502 --
22503 P_VALIDATE => false
22504 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
22505 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
22506 ,P_CWB_WKSHT_GRP_ID => l_cwb_wksht_grp_id
22507 ,P_CWG_ATTRIBUTE1 => r_CWG.INFORMATION111
22508 ,P_CWG_ATTRIBUTE10 => r_CWG.INFORMATION120
22509 ,P_CWG_ATTRIBUTE11 => r_CWG.INFORMATION121
22510 ,P_CWG_ATTRIBUTE12 => r_CWG.INFORMATION122
22511 ,P_CWG_ATTRIBUTE13 => r_CWG.INFORMATION123
22512 ,P_CWG_ATTRIBUTE14 => r_CWG.INFORMATION124
22513 ,P_CWG_ATTRIBUTE15 => r_CWG.INFORMATION125
22514 ,P_CWG_ATTRIBUTE16 => r_CWG.INFORMATION126
22515 ,P_CWG_ATTRIBUTE17 => r_CWG.INFORMATION127
22516 ,P_CWG_ATTRIBUTE18 => r_CWG.INFORMATION128
22517 ,P_CWG_ATTRIBUTE19 => r_CWG.INFORMATION129
22518 ,P_CWG_ATTRIBUTE2 => r_CWG.INFORMATION112
22519 ,P_CWG_ATTRIBUTE20 => r_CWG.INFORMATION130
22520 ,P_CWG_ATTRIBUTE21 => r_CWG.INFORMATION131
22521 ,P_CWG_ATTRIBUTE22 => r_CWG.INFORMATION132
22522 ,P_CWG_ATTRIBUTE23 => r_CWG.INFORMATION133
22523 ,P_CWG_ATTRIBUTE24 => r_CWG.INFORMATION134
22524 ,P_CWG_ATTRIBUTE25 => r_CWG.INFORMATION135
22525 ,P_CWG_ATTRIBUTE26 => r_CWG.INFORMATION136
22526 ,P_CWG_ATTRIBUTE27 => r_CWG.INFORMATION137
22527 ,P_CWG_ATTRIBUTE28 => r_CWG.INFORMATION138
22528 ,P_CWG_ATTRIBUTE29 => r_CWG.INFORMATION139
22529 ,P_CWG_ATTRIBUTE3 => r_CWG.INFORMATION113
22530 ,P_CWG_ATTRIBUTE30 => r_CWG.INFORMATION140
22531 ,P_CWG_ATTRIBUTE4 => r_CWG.INFORMATION114
22532 ,P_CWG_ATTRIBUTE5 => r_CWG.INFORMATION115
22533 ,P_CWG_ATTRIBUTE6 => r_CWG.INFORMATION116
22534 ,P_CWG_ATTRIBUTE7 => r_CWG.INFORMATION117
22535 ,P_CWG_ATTRIBUTE8 => r_CWG.INFORMATION118
22536 ,P_CWG_ATTRIBUTE9 => r_CWG.INFORMATION119
22537 ,P_CWG_ATTRIBUTE_CATEGORY => r_CWG.INFORMATION110
22538 ,P_LABEL => r_CWG.INFORMATION141
22539 ,P_ORDR_NUM => r_CWG.INFORMATION260
22540 ,P_PL_ID => l_PL_ID
22541 ,P_WKSHT_GRP_CD => r_CWG.INFORMATION11
22542 ,P_HIDDEN_CD => r_CWG.INFORMATION12
22543 ,P_STATUS_CD => r_CWG.INFORMATION13
22544 --
22545 --
22546 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
22547 );
22548 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
22549 -- Update all relevent cer records with new pk_id
22550 hr_utility.set_location('Before plsql table ',222);
22551 hr_utility.set_location('new_value id '||l_cwb_wksht_grp_id,222);
22552 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'CWB_WKSHT_GRP_ID' ;
22553 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_CWG.information1 ;
22554 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_CWB_WKSHT_GRP_ID ;
22555 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
22556 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;
22557 hr_utility.set_location('After plsql table ',222);
22558 --
22559 -- 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 ) ;
22560 --
22561 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22562 --
22563 elsif l_update then
22564 BEN_CWB_WKSHT_GRP_API.UPDATE_CWB_WKSHT_GRP(
22565 --
22566 P_VALIDATE => false
22567 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
22568 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
22569 ,P_CWB_WKSHT_GRP_ID => l_cwb_wksht_grp_id
22570 ,P_CWG_ATTRIBUTE1 => r_CWG.INFORMATION111
22571 ,P_CWG_ATTRIBUTE10 => r_CWG.INFORMATION120
22572 ,P_CWG_ATTRIBUTE11 => r_CWG.INFORMATION121
22573 ,P_CWG_ATTRIBUTE12 => r_CWG.INFORMATION122
22574 ,P_CWG_ATTRIBUTE13 => r_CWG.INFORMATION123
22575 ,P_CWG_ATTRIBUTE14 => r_CWG.INFORMATION124
22576 ,P_CWG_ATTRIBUTE15 => r_CWG.INFORMATION125
22577 ,P_CWG_ATTRIBUTE16 => r_CWG.INFORMATION126
22578 ,P_CWG_ATTRIBUTE17 => r_CWG.INFORMATION127
22579 ,P_CWG_ATTRIBUTE18 => r_CWG.INFORMATION128
22580 ,P_CWG_ATTRIBUTE19 => r_CWG.INFORMATION129
22581 ,P_CWG_ATTRIBUTE2 => r_CWG.INFORMATION112
22582 ,P_CWG_ATTRIBUTE20 => r_CWG.INFORMATION130
22583 ,P_CWG_ATTRIBUTE21 => r_CWG.INFORMATION131
22584 ,P_CWG_ATTRIBUTE22 => r_CWG.INFORMATION132
22585 ,P_CWG_ATTRIBUTE23 => r_CWG.INFORMATION133
22586 ,P_CWG_ATTRIBUTE24 => r_CWG.INFORMATION134
22587 ,P_CWG_ATTRIBUTE25 => r_CWG.INFORMATION135
22588 ,P_CWG_ATTRIBUTE26 => r_CWG.INFORMATION136
22589 ,P_CWG_ATTRIBUTE27 => r_CWG.INFORMATION137
22590 ,P_CWG_ATTRIBUTE28 => r_CWG.INFORMATION138
22591 ,P_CWG_ATTRIBUTE29 => r_CWG.INFORMATION139
22592 ,P_CWG_ATTRIBUTE3 => r_CWG.INFORMATION113
22593 ,P_CWG_ATTRIBUTE30 => r_CWG.INFORMATION140
22594 ,P_CWG_ATTRIBUTE4 => r_CWG.INFORMATION114
22595 ,P_CWG_ATTRIBUTE5 => r_CWG.INFORMATION115
22596 ,P_CWG_ATTRIBUTE6 => r_CWG.INFORMATION116
22597 ,P_CWG_ATTRIBUTE7 => r_CWG.INFORMATION117
22598 ,P_CWG_ATTRIBUTE8 => r_CWG.INFORMATION118
22599 ,P_CWG_ATTRIBUTE9 => r_CWG.INFORMATION119
22600 ,P_CWG_ATTRIBUTE_CATEGORY => r_CWG.INFORMATION110
22601 ,P_LABEL => r_CWG.INFORMATION141
22602 ,P_ORDR_NUM => r_CWG.INFORMATION260
22603 ,P_PL_ID => l_PL_ID
22604 ,P_WKSHT_GRP_CD => r_CWG.INFORMATION11
22605 ,P_HIDDEN_CD => r_CWG.INFORMATION12
22606 ,P_STATUS_CD => r_CWG.INFORMATION13
22607 --
22608 --
22609 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
22610 );
22611 end if;
22612 --
22613 l_prev_pk_id := l_current_pk_id ;
22614 --
22615 end if;
22616 --
22617 end loop;
22618 --
22619 exception when others then
22620 --
22621 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CWG',r_cwg.information5 );
22622 --
22623 end create_CWG_rows;
22624
22625 ---------------------------------------------------------------
22626 ----------------------< create_CRI_rows >-----------------------
22627 ---------------------------------------------------------------
22628 --
22629 procedure create_CRI_rows
22630 (
22631 p_validate in number default 0
22632 ,p_copy_entity_txn_id in number
22633 ,p_effective_date in date
22634 ,p_reuse_object_flag in varchar2 default null
22635 ) is
22636 --
22637 cursor c_unique_CRI(l_table_alias varchar2) is
22638 select distinct cpe.information11,
22639 cpe.information12,
22640 cpe.information13,
22641 cpe.INFORMATION14,
22642 cpe.table_route_id,dml_operation,cpe.datetrack_mode
22643 from ben_copy_entity_results cpe,
22644 pqh_table_route tr
22645 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22646 and cpe.table_route_id = tr.table_route_id
22647 -- and tr.where_clause = l_BEN_AGE_FCTR
22648 and tr.table_alias = l_table_alias
22649 and cpe.number_of_copies = 1 --ADDITION
22650 group by cpe.information11,cpe.information12,cpe.information13, cpe.INFORMATION14, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
22651 order by information11, information12; --added for bug: 5151945 (changed from
22652 --1 to 11 by sshetty)
22653
22654 --
22655 --
22656
22657 cursor c_CRI(c_table_route_id number,
22658 c_information11 varchar2,
22659 c_information12 varchar2,
22660 c_information13 varchar2,
22661 c_information14 varchar2
22662 ) is
22663 select
22664 cpe.*
22665 from ben_copy_entity_results cpe
22666 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22667 and cpe.table_route_id = c_table_route_id
22668 and cpe.information11 = c_information11
22669 and cpe.information12 = c_information12
22670 and cpe.information13 = c_information13
22671 and cpe.information14 = c_information14
22672 and rownum = 1 ;
22673 -- Date Track target record
22674
22675
22676 cursor c_find_CRI_in_target( c_new_information11 varchar2,
22677 c_new_information12 varchar2,
22678 c_new_information13 varchar2,
22679 c_new_information14 varchar2) is
22680 select
22681 CRI.REGION_CODE ,cri.CUSTOM_KEY ,cri.CUSTOM_TYPE ,cri.item_name ,cri.label
22682 from BEN_CUSTOM_REGION_ITEMS CRI
22683 where CRI.region_code = c_new_information11
22684 and CRI.CUSTOM_KEY = c_new_information12
22685 and CRI.CUSTOM_TYPE = c_new_information13
22686 and CRI.item_name = c_new_information14;
22687
22688 --
22689 --
22690 l_update boolean := false ;
22691 l_process_date date;
22692 l_debug_item_name ben_custom_region_items.item_name%type;
22693 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
22694 r_find_CRI_in_target c_find_CRI_in_target%rowtype;
22695 r_CRI c_CRI%rowtype;
22696 --
22697 --UPD END
22698
22699 l_object_version_number number ;
22700 l_object_found_in_target boolean := false ;
22701 l_custom_key ben_custom_region_items.custom_key%type;
22702 l_fk_cwb_wksht_grp_id ben_cwb_wksht_grp.cwb_wksht_grp_id%type;
22703 --
22704 begin
22705
22706 for r_CRI_unique in c_unique_CRI('CRI') loop
22707 --
22708 hr_utility.set_location(' r_CRI_unique.table_route_id '||r_CRI_unique.table_route_id,10);
22709 hr_utility.set_location(' r_CRI_unique.information11 '||r_CRI_unique.information11,10);
22710 hr_utility.set_location( 'r_CRI_unique.information12 '||r_CRI_unique.information12,10);
22711 hr_utility.set_location( 'r_CRI_unique.information13 '||r_CRI_unique.information13,10);
22712 hr_utility.set_location( 'r_CRI_unique.information14 '||r_CRI_unique.information14,10);
22713
22714 -- AS the Only operations that are performed on the table
22715 -- BEN_CUSTOM_REGION_ITEMS are REUSE/INSERT we need not worry about t
22716 -- the l_dml_operation.
22717
22718 -- We first check for the presence of any BEN_CUSTOM_REGION_ITEMS record
22719 -- based on the target cwb_wksht_grp_id and if any records are found
22720 -- we reuse them or we create new records as seen in the CPE table
22721
22722 l_dml_operation := r_CRI_unique.dml_operation ;
22723 l_debug_item_name := r_CRI_unique.information13;
22724
22725 --
22726 l_fk_cwb_wksht_grp_id := get_fk('CWB_WKSHT_GRP_ID', r_CRI_unique.INFORMATION12,l_dml_operation);
22727
22728 -- Fetch the new fk cwb_wksht_grp_id for the target business group.
22729
22730 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);
22731 hr_utility.set_location('l_dml_operation '|| l_dml_operation || ' p_reuse_object_flag ' || p_reuse_object_flag, 20);
22732
22733
22734
22735 open c_find_CRI_in_target(r_CRI_unique.information11,
22736 to_char(l_fk_cwb_wksht_grp_id),
22737 r_CRI_unique.information13,
22738 r_CRI_unique.information14);
22739
22740 fetch c_find_CRI_in_target into r_find_CRI_in_target ;
22741
22742 if c_find_CRI_in_target%found then
22743
22744 hr_utility.set_location(' r_find_CRI_in_target.REGION_CODE ' || r_find_CRI_in_target.REGION_CODE,20 );
22745 hr_utility.set_location(' r_find_CRI_in_target.CUSTOM_KEY ' || r_find_CRI_in_target.CUSTOM_KEY ,20 );
22746 hr_utility.set_location( 'r_find_CRI_in_target.CUSTOM_TYPE ' || r_find_CRI_in_target.CUSTOM_TYPE,20 );
22747 hr_utility.set_location( 'r_find_CRI_in_target.ITEM_NAME ' || r_find_CRI_in_target.ITEM_NAME ,20 );
22748 hr_utility.set_location( 'r_find_CRI_in_target.LABEL ' || r_find_CRI_in_target.LABEL ,20 );
22749 hr_utility.set_location( 'RKG A record of ben_custom_region_items',202);
22750 hr_utility.set_location( 'with the same cwb_wksht_grp_id as custom_key already exists and hence reused. ',202);
22751
22752 --8985766
22753 hr_utility.set_location('Before plsql table ',111);
22754 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
22755 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CRI_unique.table_route_id;
22756 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22757 hr_utility.set_location('After plsql table ',111);
22758 --8985766
22759
22760 -- As the record in found in the target , reuse the record
22761 else
22762 -- or create the new record by querying the full record from CPE
22763
22764 open c_CRI(r_CRI_unique.table_route_id,
22765 r_CRI_unique.information11,
22766 r_CRI_unique.information12,
22767 r_CRI_unique.information13,
22768 r_CRI_unique.information14) ;
22769 --
22770 fetch c_CRI into r_CRI ;
22771 --
22772 close c_CRI ;
22773 --
22774
22775 insert into BEN_CUSTOM_REGION_ITEMS(
22776 REGION_CODE ,
22777 CUSTOM_KEY ,
22778 CUSTOM_TYPE ,
22779 ITEM_NAME ,
22780 DISPLAY_FLAG ,
22781 LABEL ,
22782 ORDR_NUM ,
22783 LAST_UPDATE_DATE ,
22784 CREATION_DATE ,
22785 OBJECT_VERSION_NUMBER ,
22786 UPDATE_ATTR ,
22787 MONETARY )
22788 values
22789 (r_CRI.information11,
22790 to_char(l_fk_cwb_wksht_grp_id),
22791 r_CRI.information13,
22792 r_CRI.information14,
22793 r_CRI.information15,
22794 r_CRI.information141,
22795 r_CRI.information266,
22796 sysdate,
22797 sysdate,
22798 1,
22799 r_CRI.information16,
22800 r_CRI.information17);
22801 --8985766
22802 hr_utility.set_location('Before plsql table ',222);
22803 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
22804 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_CRI_unique.table_route_id;
22805 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
22806 hr_utility.set_location('After plsql table ',222);
22807 --8985766
22808
22809 end if;
22810
22811 close c_find_CRI_in_target;
22812
22813
22814 end loop;
22815
22816 --
22817 exception when others then
22818 --
22819 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'CRI' , l_debug_item_name) ;
22820 --
22821
22822 end create_CRI_rows;
22823
22824 ---------------------------------------------------------------
22825 ----------------------< create_PCP_rows >-----------------------
22826 ---------------------------------------------------------------
22827 --
22828 procedure create_PCP_rows
22829 (
22830 p_validate in number default 0
22831 ,p_copy_entity_txn_id in number
22832 ,p_effective_date in date
22833 ,p_prefix_suffix_text in varchar2 default null
22834 ,p_reuse_object_flag in varchar2 default null
22835 ,p_target_business_group_id in varchar2 default null
22836 ,p_prefix_suffix_cd in varchar2 default null
22837 ) is
22838 --
22839 l_PL_ID number;
22840 cursor c_unique_PCP(l_table_alias varchar2) is
22841 select distinct cpe.information1,
22842 cpe.information2,
22843 cpe.information3,
22844 cpe.table_route_id
22845 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
22846 pqh_table_route tr
22847 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22848 and cpe.table_route_id = tr.table_route_id
22849 -- and tr.where_clause = l_BEN_PL_PCP
22850 and tr.table_alias = l_table_alias
22851 and cpe.number_of_copies = 1 -- ADDITION
22852 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
22853 order by information1, information2; --added for bug: 5151945
22854 --
22855 --
22856 cursor c_PCP_min_max_dates(c_table_route_id number,
22857 c_information1 number) is
22858 select
22859 min(cpe.information2) min_esd,
22860 max(cpe.information3) min_eed
22861 from ben_copy_entity_results cpe
22862 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22863 and cpe.table_route_id = c_table_route_id
22864 and cpe.information1 = c_information1 ;
22865 --
22866 cursor c_PCP(c_table_route_id number,
22867 c_information1 number,
22868 c_information2 date,
22869 c_information3 date ) is
22870 select
22871 cpe.*
22872 from ben_copy_entity_results cpe
22873 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
22874 and cpe.table_route_id = c_table_route_id
22875 and cpe.information1 = c_information1
22876 and rownum = 1 ;
22877 -- Date Track target record
22878 cursor c_find_PCP_in_target(
22879 c_effective_start_date date,
22880 c_effective_end_date date,
22881 c_business_group_id number,
22882 c_new_pk_id number) is
22883 select
22884 PCP.pl_pcp_id new_value
22885 from BEN_PL_PCP PCP
22886 where
22887 PCP.PL_ID = l_PL_ID and
22888 PCP.business_group_id = c_business_group_id
22889 and PCP.pl_pcp_id <> c_new_pk_id
22890 ;
22891
22892 --cursor to check the row exist in the ben_popl_org_f table.
22893 cursor c_exists_in_popl_org(c_pl_id in number) is
22894 select 'x'
22895 from ben_popl_org_f
22896 Where pl_id = c_pl_id;
22897 --
22898 l_dummy varchar2(1);
22899 --
22900 --UPD START
22901 --
22902 l_update boolean := false ;
22903 l_datetrack_mode varchar2(80) := hr_api.g_update;
22904 l_process_date date;
22905 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
22906 --
22907 --UPD END
22908 l_current_pk_id number := null ;
22909 l_prev_pk_id number := null ;
22910 l_first_rec boolean := true ;
22911 r_PCP c_PCP%rowtype;
22912 l_pl_pcp_id number ;
22913 l_object_version_number number ;
22914 l_effective_start_date date ;
22915 l_effective_end_date date ;
22916 l_prefix pqh_copy_entity_attribs.information1%type := null;
22917 l_suffix pqh_copy_entity_attribs.information1%type := null;
22918 l_new_value number(15);
22919 l_object_found_in_target boolean := false ;
22920 l_min_esd date;
22921 l_max_eed date;
22922 l_parent_effective_start_date date;
22923 --
22924 begin
22925 -- Initialization
22926 l_object_found_in_target := false ;
22927 -- End Initialization
22928 -- Derive the prefix - sufix
22929 if p_prefix_suffix_cd = 'PREFIX' then
22930 l_prefix := p_prefix_suffix_text ;
22931 elsif p_prefix_suffix_cd = 'SUFFIX' then
22932 l_suffix := p_prefix_suffix_text ;
22933 else
22934 l_prefix := null ;
22935 l_suffix := null ;
22936 end if ;
22937 -- End Prefix Sufix derivation
22938 for r_PCP_unique in c_unique_PCP('PCP') loop
22939 --
22940 hr_utility.set_location(' r_PCP_unique.table_route_id '||r_PCP_unique.table_route_id,10);
22941 hr_utility.set_location(' r_PCP_unique.information1 '||r_PCP_unique.information1,10);
22942 hr_utility.set_location( 'r_PCP_unique.information2 '||r_PCP_unique.information2,10);
22943 hr_utility.set_location( 'r_PCP_unique.information3 '||r_PCP_unique.information3,10);
22944 -- If reuse objects flag is 'Y' then check for the object in the target business group
22945 -- if found insert the record into PLSql table and exit the loop else try create the
22946 -- object in the target business group
22947 --
22948 l_object_found_in_target := false ;
22949 l_min_esd := null ;
22950 l_max_eed := null ;
22951 --
22952 open c_PCP(r_PCP_unique.table_route_id,
22953 r_PCP_unique.information1,
22954 r_PCP_unique.information2,
22955 r_PCP_unique.information3 ) ;
22956 --
22957 fetch c_PCP into r_PCP ;
22958 --
22959 close c_PCP ;
22960 --
22961 --UPD START
22962 --
22963 l_update := false;
22964 l_process_date := p_effective_date;
22965 l_dml_operation:= r_PCP_unique.dml_operation ;
22966 --
22967 --UPD END
22968 l_PL_ID := get_fk('PL_ID', r_PCP.INFORMATION261,l_dml_operation);
22969 --
22970
22971 -- If PCP_RPSTRY_FLAG (From Repository flag ) = 'Y' then
22972 -- Check if a row exists in the ben_popl_org_f table for the Plan
22973 -- If no row found then set PCP_RPSTRY_FLAG to 'N'
22974 -- Also set Radius, Radius Warning and Radius UOM to null as
22975 -- these cannot have a value if the Repository flag is not selected
22976
22977 if r_PCP.information14 = 'Y' then
22978 open c_exists_in_popl_org(l_PL_ID);
22979 fetch c_exists_in_popl_org into l_dummy;
22980 if c_exists_in_popl_org%notfound then
22981 r_PCP.information14 := 'N'; -- Repository flag
22982 r_PCP.information293 := null; -- Radius
22983 r_PCP.information16 := null; -- Radius UOM
22984 r_PCP.information17 := 'N'; -- Radius Warning
22985 end if;
22986 close c_exists_in_popl_org;
22987 end if;
22988
22989 if l_PL_ID is not null then -- Do not create if parent record does not exist
22990
22991 --UPD START
22992 --
22993 if l_dml_operation = 'UPDATE' then
22994 --
22995 l_update := true;
22996 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
22997 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
22998 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_PCP_ID' ;
22999 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PCP_unique.information1 ;
23000 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PCP_unique.information1 ;
23001 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23002 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;
23003 --
23004 -- 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
23005 --
23006 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23007 --
23008 --DOUBT log_data('PCP',l_new_value,l_prefix || r_PCP_unique.name|| l_suffix,'REUSED');
23009 --
23010 end if ;
23011 l_PL_PCP_ID := r_PCP_unique.information1 ;
23012 l_object_version_number := r_PCP.information265 ;
23013 hr_utility.set_location( 'found record for update',10);
23014 --
23015 else
23016 --
23017 --UPD END
23018 if p_reuse_object_flag = 'Y' then
23019 -- cursor to find the object
23020 open c_find_PCP_in_target( r_PCP_unique.information2,l_max_eed,
23021 p_target_business_group_id, nvl(l_pl_pcp_id, -999) ) ;
23022 fetch c_find_PCP_in_target into l_new_value ;
23023 if c_find_PCP_in_target%found then
23024 --
23025 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
23026 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
23027 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_PCP_ID' ;
23028 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PCP_unique.information1 ;
23029 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
23030 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23031 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;
23032 --
23033 -- 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) ;
23034 --
23035 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23036 end if ;
23037 --
23038 l_object_found_in_target := true ;
23039 end if;
23040 close c_find_PCP_in_target ;
23041 --
23042 end if ;
23043 --
23044 end if; --if p_dml_operation
23045 --
23046 if not l_object_found_in_target OR l_update then
23047 --
23048 l_current_pk_id := r_PCP.information1;
23049 --
23050 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
23051 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
23052 --
23053 if l_current_pk_id = l_prev_pk_id then
23054 --
23055 l_first_rec := false ;
23056 --
23057 else
23058 --
23059 l_first_rec := true ;
23060 --
23061 end if ;
23062 --
23063
23064 l_parent_effective_start_date := r_PCP.information10;
23065 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null ) then
23066 if l_parent_effective_start_date is null then
23067 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
23068 elsif l_parent_effective_start_date < ben_pd_copy_to_ben_one.g_copy_effective_date then
23069 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
23070 end if;
23071 end if;
23072 --
23073 -- To avoid creating a child with out parent
23074 --
23075 if l_PL_ID is null then
23076 l_first_rec:=false;
23077 end if;
23078 --
23079 if l_first_rec and not l_update then
23080 -- Call Create routine.
23081 hr_utility.set_location(' BEN_PL_PCP CREATE_PL_PRMRY_CARE_PRVDR ',20);
23082 BEN_PL_PRMRY_CARE_PRVDR_API.CREATE_PL_PRMRY_CARE_PRVDR(
23083 --
23084 P_VALIDATE => false
23085 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
23086 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
23087 --
23088 ,P_PCP_ATTRIBUTE1 => r_PCP.INFORMATION111
23089 ,P_PCP_ATTRIBUTE10 => r_PCP.INFORMATION120
23090 ,P_PCP_ATTRIBUTE11 => r_PCP.INFORMATION121
23091 ,P_PCP_ATTRIBUTE12 => r_PCP.INFORMATION122
23092 ,P_PCP_ATTRIBUTE13 => r_PCP.INFORMATION123
23093 ,P_PCP_ATTRIBUTE14 => r_PCP.INFORMATION124
23094 ,P_PCP_ATTRIBUTE15 => r_PCP.INFORMATION125
23095 ,P_PCP_ATTRIBUTE16 => r_PCP.INFORMATION126
23096 ,P_PCP_ATTRIBUTE17 => r_PCP.INFORMATION127
23097 ,P_PCP_ATTRIBUTE18 => r_PCP.INFORMATION128
23098 ,P_PCP_ATTRIBUTE19 => r_PCP.INFORMATION129
23099 ,P_PCP_ATTRIBUTE2 => r_PCP.INFORMATION112
23100 ,P_PCP_ATTRIBUTE20 => r_PCP.INFORMATION130
23101 ,P_PCP_ATTRIBUTE21 => r_PCP.INFORMATION131
23102 ,P_PCP_ATTRIBUTE22 => r_PCP.INFORMATION132
23103 ,P_PCP_ATTRIBUTE23 => r_PCP.INFORMATION133
23104 ,P_PCP_ATTRIBUTE24 => r_PCP.INFORMATION134
23105 ,P_PCP_ATTRIBUTE25 => r_PCP.INFORMATION135
23106 ,P_PCP_ATTRIBUTE26 => r_PCP.INFORMATION136
23107 ,P_PCP_ATTRIBUTE27 => r_PCP.INFORMATION137
23108 ,P_PCP_ATTRIBUTE28 => r_PCP.INFORMATION138
23109 ,P_PCP_ATTRIBUTE29 => r_PCP.INFORMATION139
23110 ,P_PCP_ATTRIBUTE3 => r_PCP.INFORMATION113
23111 ,P_PCP_ATTRIBUTE30 => r_PCP.INFORMATION140
23112 ,P_PCP_ATTRIBUTE4 => r_PCP.INFORMATION114
23113 ,P_PCP_ATTRIBUTE5 => r_PCP.INFORMATION115
23114 ,P_PCP_ATTRIBUTE6 => r_PCP.INFORMATION116
23115 ,P_PCP_ATTRIBUTE7 => r_PCP.INFORMATION117
23116 ,P_PCP_ATTRIBUTE8 => r_PCP.INFORMATION118
23117 ,P_PCP_ATTRIBUTE9 => r_PCP.INFORMATION119
23118 ,P_PCP_ATTRIBUTE_CATEGORY => r_PCP.INFORMATION110
23119 ,P_PCP_CAN_KEEP_FLAG => r_PCP.INFORMATION15
23120 ,P_PCP_DPNT_DSGN_CD => r_PCP.INFORMATION13
23121 ,P_PCP_DSGN_CD => r_PCP.INFORMATION12
23122 ,P_PCP_NUM_CHGS => r_PCP.INFORMATION294
23123 ,P_PCP_NUM_CHGS_UOM => r_PCP.INFORMATION18
23124 ,P_PCP_RADIUS => r_PCP.INFORMATION293
23125 ,P_PCP_RADIUS_UOM => r_PCP.INFORMATION16
23126 ,P_PCP_RADIUS_WARN_FLAG => r_PCP.INFORMATION17
23127 ,P_PCP_RPSTRY_FLAG => r_PCP.INFORMATION14
23128 ,P_PCP_STRT_DT_CD => r_PCP.INFORMATION11
23129 ,P_PL_ID => l_PL_ID
23130 ,P_PL_PCP_ID => l_pl_pcp_id
23131 --
23132 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
23133 );
23134 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
23135 -- Update all relevent cer records with new pk_id
23136 hr_utility.set_location('Before plsql table ',222);
23137 hr_utility.set_location('new_value id '||l_pl_pcp_id,222);
23138 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_PCP_ID' ;
23139 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PCP.information1 ;
23140 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PL_PCP_ID ;
23141 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
23142 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;
23143 hr_utility.set_location('After plsql table ',222);
23144 --
23145 -- 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 ) ;
23146 --
23147 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23148 --
23149 elsif l_update then
23150 BEN_PL_PRMRY_CARE_PRVDR_API.UPDATE_PL_PRMRY_CARE_PRVDR(
23151 --
23152 P_VALIDATE => false
23153 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
23154 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
23155 --
23156 ,P_PCP_ATTRIBUTE1 => r_PCP.INFORMATION111
23157 ,P_PCP_ATTRIBUTE10 => r_PCP.INFORMATION120
23158 ,P_PCP_ATTRIBUTE11 => r_PCP.INFORMATION121
23159 ,P_PCP_ATTRIBUTE12 => r_PCP.INFORMATION122
23160 ,P_PCP_ATTRIBUTE13 => r_PCP.INFORMATION123
23161 ,P_PCP_ATTRIBUTE14 => r_PCP.INFORMATION124
23162 ,P_PCP_ATTRIBUTE15 => r_PCP.INFORMATION125
23163 ,P_PCP_ATTRIBUTE16 => r_PCP.INFORMATION126
23164 ,P_PCP_ATTRIBUTE17 => r_PCP.INFORMATION127
23165 ,P_PCP_ATTRIBUTE18 => r_PCP.INFORMATION128
23166 ,P_PCP_ATTRIBUTE19 => r_PCP.INFORMATION129
23167 ,P_PCP_ATTRIBUTE2 => r_PCP.INFORMATION112
23168 ,P_PCP_ATTRIBUTE20 => r_PCP.INFORMATION130
23169 ,P_PCP_ATTRIBUTE21 => r_PCP.INFORMATION131
23170 ,P_PCP_ATTRIBUTE22 => r_PCP.INFORMATION132
23171 ,P_PCP_ATTRIBUTE23 => r_PCP.INFORMATION133
23172 ,P_PCP_ATTRIBUTE24 => r_PCP.INFORMATION134
23173 ,P_PCP_ATTRIBUTE25 => r_PCP.INFORMATION135
23174 ,P_PCP_ATTRIBUTE26 => r_PCP.INFORMATION136
23175 ,P_PCP_ATTRIBUTE27 => r_PCP.INFORMATION137
23176 ,P_PCP_ATTRIBUTE28 => r_PCP.INFORMATION138
23177 ,P_PCP_ATTRIBUTE29 => r_PCP.INFORMATION139
23178 ,P_PCP_ATTRIBUTE3 => r_PCP.INFORMATION113
23179 ,P_PCP_ATTRIBUTE30 => r_PCP.INFORMATION140
23180 ,P_PCP_ATTRIBUTE4 => r_PCP.INFORMATION114
23181 ,P_PCP_ATTRIBUTE5 => r_PCP.INFORMATION115
23182 ,P_PCP_ATTRIBUTE6 => r_PCP.INFORMATION116
23183 ,P_PCP_ATTRIBUTE7 => r_PCP.INFORMATION117
23184 ,P_PCP_ATTRIBUTE8 => r_PCP.INFORMATION118
23185 ,P_PCP_ATTRIBUTE9 => r_PCP.INFORMATION119
23186 ,P_PCP_ATTRIBUTE_CATEGORY => r_PCP.INFORMATION110
23187 ,P_PCP_CAN_KEEP_FLAG => r_PCP.INFORMATION15
23188 ,P_PCP_DPNT_DSGN_CD => r_PCP.INFORMATION13
23189 ,P_PCP_DSGN_CD => r_PCP.INFORMATION12
23190 ,P_PCP_NUM_CHGS => r_PCP.INFORMATION294
23191 ,P_PCP_NUM_CHGS_UOM => r_PCP.INFORMATION18
23192 ,P_PCP_RADIUS => r_PCP.INFORMATION293
23193 ,P_PCP_RADIUS_UOM => r_PCP.INFORMATION16
23194 ,P_PCP_RADIUS_WARN_FLAG => r_PCP.INFORMATION17
23195 ,P_PCP_RPSTRY_FLAG => r_PCP.INFORMATION14
23196 ,P_PCP_STRT_DT_CD => r_PCP.INFORMATION11
23197 ,P_PL_ID => l_PL_ID
23198 ,P_PL_PCP_ID => l_pl_pcp_id
23199 --
23200 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
23201 );
23202 end if;
23203 --
23204 l_prev_pk_id := l_current_pk_id ;
23205 --
23206 end if;
23207 --
23208 end if;
23209 --
23210 end loop;
23211 --
23212 exception when others then
23213 --
23214 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PCP',r_pcp.information5 );
23215 --
23216 end create_PCP_rows;
23217
23218 --
23219 ---------------------------------------------------------------
23220 ----------------------< create_COP_rows >-----------------------
23221 ---------------------------------------------------------------
23222 --
23223 procedure create_COP_rows
23224 (
23225 p_validate in number default 0
23226 ,p_copy_entity_txn_id in number
23227 ,p_effective_date in date
23228 ,p_prefix_suffix_text in varchar2 default null
23229 ,p_reuse_object_flag in varchar2 default null
23230 ,p_target_business_group_id in varchar2 default null
23231 ,p_prefix_suffix_cd in varchar2 default null
23232 ) is
23233 --
23234 l_ACTL_PREM_ID number;
23235 l_AUTO_ENRT_MTHD_RL number;
23236 l_DFLT_ENRT_DET_RL number;
23237 l_ENRT_RL number;
23238 l_MNDTRY_RL number;
23239 l_OPT_ID number;
23240 l_PL_ID number;
23241 l_POSTELCN_EDIT_RL number;
23242 l_RQD_PERD_ENRT_NENRT_RL number;
23243 l_VRFY_FMLY_MMBR_RL number;
23244 cursor c_unique_COP(l_table_alias varchar2) is
23245 select distinct cpe.information1,
23246 cpe.information2,
23247 cpe.information3,
23248 cpe.table_route_id
23249 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
23250 pqh_table_route tr
23251 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23252 and cpe.table_route_id = tr.table_route_id
23253 -- and tr.where_clause = l_BEN_OIPL_F
23254 and tr.table_alias = l_table_alias
23255 and cpe.number_of_copies = 1 -- ADDITION
23256 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
23257 ORDER BY cpe.information1,cpe.information2; -- 5122908. Records need to be created ordered on effective date.
23258 --
23259 --
23260 cursor c_COP_min_max_dates(c_table_route_id number,
23261 c_information1 number) is
23262 select
23263 min(cpe.information2) min_esd,
23264 max(cpe.information3) min_eed
23265 from ben_copy_entity_results cpe
23266 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23267 and cpe.table_route_id = c_table_route_id
23268 and cpe.information1 = c_information1 ;
23269 --
23270 cursor c_COP(c_table_route_id number,
23271 c_information1 number,
23272 c_information2 date,
23273 c_information3 date ) is
23274 select
23275 cpe.*
23276 from ben_copy_entity_results cpe
23277 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23278 and cpe.table_route_id = c_table_route_id
23279 and cpe.information1 = c_information1
23280 and cpe.information2 = c_information2
23281 and cpe.information3 = c_information3
23282 and rownum = 1 ;
23283 -- Date Track target record
23284 cursor c_find_COP_in_target(
23285 c_effective_start_date date,
23286 c_effective_end_date date,
23287 c_business_group_id number,
23288 c_new_pk_id number) is
23289 select
23290 COP.oipl_id new_value
23291 from BEN_OIPL_F COP
23292 where
23293 COP.OPT_ID = l_OPT_ID and
23294 COP.PL_ID = l_PL_ID and
23295 nvl(COP.ACTL_PREM_ID,-999) = nvl(l_ACTL_PREM_ID,-999) and
23296 COP.business_group_id = c_business_group_id
23297 and COP.oipl_id <> c_new_pk_id
23298 --TEMPIK
23299 and c_effective_start_date between effective_start_date
23300 and effective_end_date ;
23301 --END TEMPIK
23302 /*
23303 and exists ( select null
23304 from BEN_OIPL_F COP1
23305 where
23306 COP1.OPT_ID = l_OPT_ID and
23307 COP1.PL_ID = l_PL_ID and
23308 nvl(COP1.ACTL_PREM_ID,-999) = nvl(l_ACTL_PREM_ID,-999) and
23309 COP1.business_group_id = c_business_group_id
23310 and COP1.effective_start_date <= c_effective_start_date )
23311 and exists ( select null
23312 from BEN_OIPL_F COP2
23313 where
23314 COP2.OPT_ID = l_OPT_ID and
23315 COP2.PL_ID = l_PL_ID and
23316 nvl(COP2.ACTL_PREM_ID,-999) = nvl(l_ACTL_PREM_ID,-999) and
23317 COP2.business_group_id = c_business_group_id
23318 and COP2.effective_end_date >= c_effective_end_date )
23319 ;
23320 */
23321 --
23322 --UPD START
23323 --
23324 l_update boolean := false ;
23325 l_datetrack_mode varchar2(80) := hr_api.g_update;
23326 l_process_date date;
23327 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
23328 --
23329 --UPD END
23330 l_current_pk_id number := null ;
23331 l_prev_pk_id number := null ;
23332 l_first_rec boolean := true ;
23333 r_COP c_COP%rowtype;
23334 l_oipl_id number ;
23335 l_object_version_number number ;
23336 l_effective_start_date date ;
23337 l_effective_end_date date ;
23338 l_prefix pqh_copy_entity_attribs.information1%type := null;
23339 l_suffix pqh_copy_entity_attribs.information1%type := null;
23340 l_new_value number(15);
23341 l_object_found_in_target boolean := false ;
23342 l_min_esd date;
23343 l_max_eed date;
23344 l_effective_date date;
23345 --TEMPIK
23346 l_dt_rec_found boolean ;
23347 --END TEMPIK
23348 --
23349 begin
23350 -- Initialization
23351 l_object_found_in_target := false ;
23352 -- End Initialization
23353 -- Derive the prefix - sufix
23354 if p_prefix_suffix_cd = 'PREFIX' then
23355 l_prefix := p_prefix_suffix_text ;
23356 elsif p_prefix_suffix_cd = 'SUFFIX' then
23357 l_suffix := p_prefix_suffix_text ;
23358 else
23359 l_prefix := null ;
23360 l_suffix := null ;
23361 end if ;
23362 -- End Prefix Sufix derivation
23363 for r_COP_unique in c_unique_COP('COP') loop
23364
23365 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
23366 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23367 r_COP_unique.information3 >=
23368 ben_pd_copy_to_ben_one.g_copy_effective_date)
23369 ) then
23370 --
23371 hr_utility.set_location(' r_COP_unique.table_route_id '||r_COP_unique.table_route_id,10);
23372 hr_utility.set_location(' r_COP_unique.information1 '||r_COP_unique.information1,10);
23373 hr_utility.set_location( 'r_COP_unique.information2 '||r_COP_unique.information2,10);
23374 hr_utility.set_location( 'r_COP_unique.information3 '||r_COP_unique.information3,10);
23375 -- If reuse objects flag is 'Y' then check for the object in the target business group
23376 -- if found insert the record into PLSql table and exit the loop else try create the
23377 -- object in the target business group
23378 --
23379 l_object_found_in_target := false ;
23380 --UPD START
23381 open c_COP(r_COP_unique.table_route_id,
23382 r_COP_unique.information1,
23383 r_COP_unique.information2,
23384 r_COP_unique.information3 ) ;
23385 --
23386 fetch c_COP into r_COP ;
23387 --
23388 close c_COP ;
23389 --
23390 l_dml_operation:= r_COP_unique.dml_operation ;
23391 l_ACTL_PREM_ID := get_fk('ACTL_PREM_ID', r_COP.INFORMATION250,l_dml_operation );
23392 l_AUTO_ENRT_MTHD_RL := get_fk('FORMULA_ID', r_COP.INFORMATION264,l_dml_operation );
23393 l_DFLT_ENRT_DET_RL := get_fk('FORMULA_ID', r_COP.INFORMATION266,l_dml_operation );
23394 l_ENRT_RL := get_fk('FORMULA_ID', r_COP.INFORMATION257,l_dml_operation );
23395 l_MNDTRY_RL := get_fk('FORMULA_ID', r_COP.INFORMATION268,l_dml_operation );
23396 l_OPT_ID := get_fk('OPT_ID', r_COP.INFORMATION247,l_dml_operation );
23397 l_PL_ID := get_fk('PL_ID', r_COP.INFORMATION261,l_dml_operation );
23398 l_POSTELCN_EDIT_RL := get_fk('FORMULA_ID', r_COP.INFORMATION269,l_dml_operation );
23399 l_RQD_PERD_ENRT_NENRT_RL := get_fk('FORMULA_ID', r_COP.INFORMATION267,l_dml_operation );
23400 l_VRFY_FMLY_MMBR_RL := get_fk('FORMULA_ID', r_COP.INFORMATION270,l_dml_operation );
23401 --
23402 l_update := false;
23403 l_process_date := p_effective_date;
23404 --
23405 if l_dml_operation = 'UPDATE' then
23406 --
23407 l_object_found_in_target := TRUE;
23408 --
23409 if l_process_date between r_COP_unique.information2 and r_COP_unique.information3 then
23410 l_update := true;
23411 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)
23412 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'
23413 then
23414 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OIPL_ID' ;
23415 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_COP_unique.information1 ;
23416 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_COP_unique.information1 ;
23417 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23418 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;
23419 --
23420 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
23421 --
23422 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23423 --
23424 --DOUBT log_data('COP',l_new_value,l_prefix || r_COP_unique.name|| l_suffix,'REUSED');
23425 --
23426 end if ;
23427 hr_utility.set_location( 'found record for update',10);
23428 --
23429 else
23430 --
23431 l_update := false;
23432 --
23433 end if;
23434 else
23435 --
23436 --UPD END
23437 l_min_esd := null ;
23438 l_max_eed := null ;
23439 open c_COP_min_max_dates(r_COP_unique.table_route_id, r_COP_unique.information1 ) ;
23440 fetch c_COP_min_max_dates into l_min_esd,l_max_eed ;
23441 --
23442
23443 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23444 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
23445 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
23446 end if;
23447 l_min_esd := greatest(l_min_esd,r_COP_unique.information2);
23448 /* open c_COP(r_COP_unique.table_route_id,
23449 r_COP_unique.information1,
23450 r_COP_unique.information2,
23451 r_COP_unique.information3 ) ;
23452 --
23453 fetch c_COP into r_COP ;
23454 --
23455 close c_COP ; */
23456 --
23457
23458
23459 if p_reuse_object_flag = 'Y' then
23460 if c_COP_min_max_dates%found then
23461 -- cursor to find the object
23462 open c_find_COP_in_target( l_min_esd,l_max_eed,
23463 p_target_business_group_id, nvl(l_oipl_id, -999) ) ;
23464 fetch c_find_COP_in_target into l_new_value ;
23465 if c_find_COP_in_target%found then
23466 --
23467 --TEMPIK
23468 l_dt_rec_found := dt_api.check_min_max_dates
23469 (p_base_table_name => 'BEN_OIPL_F',
23470 p_base_key_column => 'OIPL_ID',
23471 p_base_key_value => l_new_value,
23472 p_from_date => l_min_esd,
23473 p_to_date => l_max_eed );
23474 if l_dt_rec_found THEN
23475 --END TEMPIK
23476 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
23477 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
23478 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OIPL_ID' ;
23479 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_COP_unique.information1 ;
23480 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
23481 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23482 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;
23483 --
23484 -- 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) ;
23485 --
23486 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23487 end if ;
23488 --
23489 l_object_found_in_target := true ;
23490 --TEMPIK
23491 end if; -- l_dt_rec_found
23492 --END TEMPIK
23493 end if;
23494 close c_find_COP_in_target ;
23495 --
23496 end if;
23497 end if ;
23498 --
23499 close c_COP_min_max_dates ;
23500 end if; --if p_dml_operation
23501 --
23502 if not l_object_found_in_target OR l_update then
23503 --
23504 l_current_pk_id := r_COP.information1;
23505 --
23506 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
23507 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
23508 --
23509 if l_current_pk_id = l_prev_pk_id then
23510 --
23511 l_first_rec := false ;
23512 --
23513 else
23514 --
23515 l_first_rec := true ;
23516 --
23517 end if ;
23518 --
23519
23520 l_effective_date := r_COP.information2;
23521 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23522 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
23523 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
23524 end if;
23525
23526 if l_first_rec and not l_update then
23527 -- Call Create routine.
23528 hr_utility.set_location(' BEN_OIPL_F CREATE_OPTION_IN_PLAN ',20);
23529 BEN_OPTION_IN_PLAN_API.CREATE_OPTION_IN_PLAN(
23530 --
23531 P_VALIDATE => false
23532 ,P_EFFECTIVE_DATE => l_effective_date
23533 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
23534 --
23535 ,P_ACTL_PREM_ID => l_ACTL_PREM_ID
23536 ,P_AUTO_ENRT_FLAG => r_COP.INFORMATION25
23537 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
23538 ,P_COP_ATTRIBUTE1 => r_COP.INFORMATION111
23539 ,P_COP_ATTRIBUTE10 => r_COP.INFORMATION120
23540 ,P_COP_ATTRIBUTE11 => r_COP.INFORMATION121
23541 ,P_COP_ATTRIBUTE12 => r_COP.INFORMATION122
23542 ,P_COP_ATTRIBUTE13 => r_COP.INFORMATION123
23543 ,P_COP_ATTRIBUTE14 => r_COP.INFORMATION124
23544 ,P_COP_ATTRIBUTE15 => r_COP.INFORMATION125
23545 ,P_COP_ATTRIBUTE16 => r_COP.INFORMATION126
23546 ,P_COP_ATTRIBUTE17 => r_COP.INFORMATION127
23547 ,P_COP_ATTRIBUTE18 => r_COP.INFORMATION128
23548 ,P_COP_ATTRIBUTE19 => r_COP.INFORMATION129
23549 ,P_COP_ATTRIBUTE2 => r_COP.INFORMATION112
23550 ,P_COP_ATTRIBUTE20 => r_COP.INFORMATION130
23551 ,P_COP_ATTRIBUTE21 => r_COP.INFORMATION131
23552 ,P_COP_ATTRIBUTE22 => r_COP.INFORMATION132
23553 ,P_COP_ATTRIBUTE23 => r_COP.INFORMATION133
23554 ,P_COP_ATTRIBUTE24 => r_COP.INFORMATION134
23555 ,P_COP_ATTRIBUTE25 => r_COP.INFORMATION135
23556 ,P_COP_ATTRIBUTE26 => r_COP.INFORMATION136
23557 ,P_COP_ATTRIBUTE27 => r_COP.INFORMATION137
23558 ,P_COP_ATTRIBUTE28 => r_COP.INFORMATION138
23559 ,P_COP_ATTRIBUTE29 => r_COP.INFORMATION139
23560 ,P_COP_ATTRIBUTE3 => r_COP.INFORMATION113
23561 ,P_COP_ATTRIBUTE30 => r_COP.INFORMATION140
23562 ,P_COP_ATTRIBUTE4 => r_COP.INFORMATION114
23563 ,P_COP_ATTRIBUTE5 => r_COP.INFORMATION115
23564 ,P_COP_ATTRIBUTE6 => r_COP.INFORMATION116
23565 ,P_COP_ATTRIBUTE7 => r_COP.INFORMATION117
23566 ,P_COP_ATTRIBUTE8 => r_COP.INFORMATION118
23567 ,P_COP_ATTRIBUTE9 => r_COP.INFORMATION119
23568 ,P_COP_ATTRIBUTE_CATEGORY => r_COP.INFORMATION110
23569 ,P_DFLT_ENRT_CD => r_COP.INFORMATION26
23570 ,P_DFLT_ENRT_DET_RL => l_DFLT_ENRT_DET_RL
23571 ,P_DFLT_FLAG => r_COP.INFORMATION18
23572 ,P_DRVBL_FCTR_APLS_RTS_FLAG => r_COP.INFORMATION24
23573 ,P_DRVBL_FCTR_PRTN_ELIG_FLAG => r_COP.INFORMATION22
23574 ,P_ELIG_APLS_FLAG => r_COP.INFORMATION20
23575 ,P_ENRT_CD => r_COP.INFORMATION14
23576 ,P_ENRT_RL => l_ENRT_RL
23577 ,P_HIDDEN_FLAG => r_COP.INFORMATION13
23578 ,P_IVR_IDENT => r_COP.INFORMATION141
23579 ,P_MNDTRY_FLAG => r_COP.INFORMATION17
23580 ,P_MNDTRY_RL => l_MNDTRY_RL
23581 ,P_OIPL_ID => l_oipl_id
23582 ,P_OIPL_STAT_CD => r_COP.INFORMATION19
23583 ,P_OPT_ID => l_OPT_ID
23584 ,P_ORDR_NUM => r_COP.INFORMATION263
23585 ,P_PCP_DPNT_DSGN_CD => r_COP.INFORMATION16
23586 ,P_PCP_DSGN_CD => r_COP.INFORMATION15
23587 ,P_PER_CVRD_CD => r_COP.INFORMATION27
23588 ,P_PL_ID => l_PL_ID
23589 ,P_POSTELCN_EDIT_RL => l_POSTELCN_EDIT_RL
23590 ,P_PRTN_ELIG_OVRID_ALWD_FLAG => r_COP.INFORMATION23
23591 ,P_RQD_PERD_ENRT_NENRT_RL => l_RQD_PERD_ENRT_NENRT_RL
23592 ,P_RQD_PERD_ENRT_NENRT_UOM => r_COP.INFORMATION29
23593 ,P_RQD_PERD_ENRT_NENRT_VAL => r_COP.INFORMATION293
23594 ,P_SHORT_CODE => r_COP.INFORMATION11
23595 ,P_SHORT_NAME => r_COP.INFORMATION12
23596 ,P_TRK_INELIG_PER_FLAG => r_COP.INFORMATION21
23597 ,P_URL_REF_NAME => r_COP.INFORMATION185
23598 ,P_VRFY_FMLY_MMBR_CD => r_COP.INFORMATION28
23599 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
23600 --ML
23601 ,P_SUSP_IF_CTFN_NOT_PRVD_FLAG => nvl(r_COP.INFORMATION198,'Y')
23602 ,P_CTFN_DETERMINE_CD => r_COP.INFORMATION197
23603 --
23604 ,P_EFFECTIVE_START_DATE => l_effective_start_date
23605 ,P_EFFECTIVE_END_DATE => l_effective_end_date
23606 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
23607 );
23608 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
23609 -- Update all relevent cer records with new pk_id
23610 hr_utility.set_location('Before plsql table ',222);
23611 hr_utility.set_location('new_value id '||l_oipl_id,222);
23612 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OIPL_ID' ;
23613 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_COP.information1 ;
23614 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_OIPL_ID ;
23615 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
23616 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;
23617 hr_utility.set_location('After plsql table ',222);
23618 --
23619 -- 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 ) ;
23620 --
23621 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23622 --
23623 else
23624 --
23625 -- Call Update routine for the pk_id created in prev run .
23626 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
23627 hr_utility.set_location(' BEN_OIPL_F UPDATE_OPTION_IN_PLAN ',30);
23628 --UPD START
23629 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
23630 --
23631 if l_update then
23632 --
23633 l_datetrack_mode := r_COP.datetrack_mode ;
23634 --
23635 get_dt_modes(
23636 p_effective_date => l_process_date,
23637 p_effective_end_date => r_COP.information3,
23638 p_effective_start_date => r_COP.information2,
23639 p_dml_operation => r_COP.dml_operation,
23640 p_datetrack_mode => l_datetrack_mode );
23641 -- p_update => l_update
23642 --
23643 l_effective_date := l_process_date;
23644 l_OIPL_ID := r_COP.information1;
23645 l_object_version_number := r_COP.information265;
23646 --
23647 end if;
23648 --
23649 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
23650 --
23651 IF l_update OR l_dml_operation <> 'UPDATE' THEN
23652 --UPD END
23653 BEN_OPTION_IN_PLAN_API.UPDATE_OPTION_IN_PLAN(
23654 --
23655 P_VALIDATE => false
23656 ,P_EFFECTIVE_DATE => l_effective_date
23657 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
23658 --
23659 ,P_ACTL_PREM_ID => l_ACTL_PREM_ID
23660 ,P_AUTO_ENRT_FLAG => r_COP.INFORMATION25
23661 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
23662 ,P_COP_ATTRIBUTE1 => r_COP.INFORMATION111
23663 ,P_COP_ATTRIBUTE10 => r_COP.INFORMATION120
23664 ,P_COP_ATTRIBUTE11 => r_COP.INFORMATION121
23665 ,P_COP_ATTRIBUTE12 => r_COP.INFORMATION122
23666 ,P_COP_ATTRIBUTE13 => r_COP.INFORMATION123
23667 ,P_COP_ATTRIBUTE14 => r_COP.INFORMATION124
23668 ,P_COP_ATTRIBUTE15 => r_COP.INFORMATION125
23669 ,P_COP_ATTRIBUTE16 => r_COP.INFORMATION126
23670 ,P_COP_ATTRIBUTE17 => r_COP.INFORMATION127
23671 ,P_COP_ATTRIBUTE18 => r_COP.INFORMATION128
23672 ,P_COP_ATTRIBUTE19 => r_COP.INFORMATION129
23673 ,P_COP_ATTRIBUTE2 => r_COP.INFORMATION112
23674 ,P_COP_ATTRIBUTE20 => r_COP.INFORMATION130
23675 ,P_COP_ATTRIBUTE21 => r_COP.INFORMATION131
23676 ,P_COP_ATTRIBUTE22 => r_COP.INFORMATION132
23677 ,P_COP_ATTRIBUTE23 => r_COP.INFORMATION133
23678 ,P_COP_ATTRIBUTE24 => r_COP.INFORMATION134
23679 ,P_COP_ATTRIBUTE25 => r_COP.INFORMATION135
23680 ,P_COP_ATTRIBUTE26 => r_COP.INFORMATION136
23681 ,P_COP_ATTRIBUTE27 => r_COP.INFORMATION137
23682 ,P_COP_ATTRIBUTE28 => r_COP.INFORMATION138
23683 ,P_COP_ATTRIBUTE29 => r_COP.INFORMATION139
23684 ,P_COP_ATTRIBUTE3 => r_COP.INFORMATION113
23685 ,P_COP_ATTRIBUTE30 => r_COP.INFORMATION140
23686 ,P_COP_ATTRIBUTE4 => r_COP.INFORMATION114
23687 ,P_COP_ATTRIBUTE5 => r_COP.INFORMATION115
23688 ,P_COP_ATTRIBUTE6 => r_COP.INFORMATION116
23689 ,P_COP_ATTRIBUTE7 => r_COP.INFORMATION117
23690 ,P_COP_ATTRIBUTE8 => r_COP.INFORMATION118
23691 ,P_COP_ATTRIBUTE9 => r_COP.INFORMATION119
23692 ,P_COP_ATTRIBUTE_CATEGORY => r_COP.INFORMATION110
23693 ,P_DFLT_ENRT_CD => r_COP.INFORMATION26
23694 ,P_DFLT_ENRT_DET_RL => l_DFLT_ENRT_DET_RL
23695 ,P_DFLT_FLAG => r_COP.INFORMATION18
23696 ,P_DRVBL_FCTR_APLS_RTS_FLAG => r_COP.INFORMATION24
23697 ,P_DRVBL_FCTR_PRTN_ELIG_FLAG => r_COP.INFORMATION22
23698 ,P_ELIG_APLS_FLAG => r_COP.INFORMATION20
23699 ,P_ENRT_CD => r_COP.INFORMATION14
23700 ,P_ENRT_RL => l_ENRT_RL
23701 ,P_HIDDEN_FLAG => r_COP.INFORMATION13
23702 ,P_IVR_IDENT => r_COP.INFORMATION141
23703 ,P_MNDTRY_FLAG => r_COP.INFORMATION17
23704 ,P_MNDTRY_RL => l_MNDTRY_RL
23705 ,P_OIPL_ID => l_oipl_id
23706 ,P_OIPL_STAT_CD => r_COP.INFORMATION19
23707 ,P_OPT_ID => l_OPT_ID
23708 ,P_ORDR_NUM => r_COP.INFORMATION263
23709 ,P_PCP_DPNT_DSGN_CD => r_COP.INFORMATION16
23710 ,P_PCP_DSGN_CD => r_COP.INFORMATION15
23711 ,P_PER_CVRD_CD => r_COP.INFORMATION27
23712 ,P_PL_ID => l_PL_ID
23713 ,P_POSTELCN_EDIT_RL => l_POSTELCN_EDIT_RL
23714 ,P_PRTN_ELIG_OVRID_ALWD_FLAG => r_COP.INFORMATION23
23715 ,P_RQD_PERD_ENRT_NENRT_RL => l_RQD_PERD_ENRT_NENRT_RL
23716 ,P_RQD_PERD_ENRT_NENRT_UOM => r_COP.INFORMATION29
23717 ,P_RQD_PERD_ENRT_NENRT_VAL => r_COP.INFORMATION293
23718 ,P_SHORT_CODE => r_COP.INFORMATION11
23719 ,P_SHORT_NAME => r_COP.INFORMATION12
23720 ,P_TRK_INELIG_PER_FLAG => r_COP.INFORMATION21
23721 ,P_URL_REF_NAME => r_COP.INFORMATION185
23722 ,P_VRFY_FMLY_MMBR_CD => r_COP.INFORMATION28
23723 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
23724 --ML
23725 ,P_SUSP_IF_CTFN_NOT_PRVD_FLAG => nvl(r_COP.INFORMATION198,'Y')
23726 ,P_CTFN_DETERMINE_CD => r_COP.INFORMATION197
23727 --
23728 ,P_EFFECTIVE_START_DATE => l_effective_start_date
23729 ,P_EFFECTIVE_END_DATE => l_effective_end_date
23730 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
23731 ,P_DATETRACK_MODE => l_datetrack_mode
23732 );
23733 --
23734 end if; -- l_update
23735 end if;
23736 --
23737 -- Delete the row if it is end dated.
23738 --
23739 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
23740 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
23741 trunc(l_max_eed) = r_COP.information3) then
23742 --
23743 BEN_OPTION_IN_PLAN_API.delete_OPTION_IN_PLAN(
23744 --
23745 p_validate => false
23746 ,p_oipl_id => l_oipl_id
23747 ,p_effective_start_date => l_effective_start_date
23748 ,p_effective_end_date => l_effective_end_date
23749 ,p_object_version_number => l_object_version_number
23750 ,p_effective_date => l_max_eed
23751 ,p_datetrack_mode => hr_api.g_delete
23752 --
23753 );
23754 --
23755 end if;
23756 --
23757 l_prev_pk_id := l_current_pk_id ;
23758 --
23759 end if;
23760 --
23761 end if;
23762 --
23763 end loop;
23764 --
23765 exception when others then
23766 --
23767 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'COP',r_cop.information5 );
23768 --
23769 end create_COP_rows;
23770
23771 --
23772 ---------------------------------------------------------------
23773 ----------------------< create_DDR_rows >-----------------------
23774 ---------------------------------------------------------------
23775 --
23776 procedure create_DDR_rows
23777 (
23778 p_validate in number default 0
23779 ,p_copy_entity_txn_id in number
23780 ,p_effective_date in date
23781 ,p_prefix_suffix_text in varchar2 default null
23782 ,p_reuse_object_flag in varchar2 default null
23783 ,p_target_business_group_id in varchar2 default null
23784 ,p_prefix_suffix_cd in varchar2 default null
23785 ) is
23786 --
23787 l_OIPL_ID number;
23788 l_OPT_ID number;
23789 l_PL_ID number;
23790 l_GRP_RLSHP_CD ben_dsgn_rqmt_f.grp_rlshp_cd%type;
23791 l_DSGN_TYP_CD ben_dsgn_rqmt_f.dsgn_typ_cd%type;
23792 cursor c_unique_DDR(l_table_alias varchar2) is
23793 select distinct cpe.information1,
23794 cpe.information2,
23795 cpe.information3,
23796 cpe.table_route_id
23797 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
23798 pqh_table_route tr
23799 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23800 and cpe.table_route_id = tr.table_route_id
23801 -- and tr.where_clause = l_BEN_DSGN_RQMT_F
23802 and tr.table_alias = l_table_alias
23803 and cpe.number_of_copies = 1 -- ADDITION
23804 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
23805 order by information1, information2; --added for bug: 5151945
23806 --
23807 --
23808 cursor c_DDR_min_max_dates(c_table_route_id number,
23809 c_information1 number) is
23810 select
23811 min(cpe.information2) min_esd,
23812 max(cpe.information3) min_eed
23813 from ben_copy_entity_results cpe
23814 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23815 and cpe.table_route_id = c_table_route_id
23816 and cpe.information1 = c_information1 ;
23817 --
23818 cursor c_DDR(c_table_route_id number,
23819 c_information1 number,
23820 c_information2 date,
23821 c_information3 date) is
23822 select
23823 cpe.*
23824 from ben_copy_entity_results cpe
23825 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
23826 and cpe.table_route_id = c_table_route_id
23827 and cpe.information1 = c_information1
23828 and cpe.information2 = c_information2
23829 and cpe.information3 = c_information3
23830 and rownum = 1 ;
23831 -- Date Track target record
23832 cursor c_find_DDR_in_target(
23833 c_effective_start_date date,
23834 c_effective_end_date date,
23835 c_business_group_id number,
23836 c_new_pk_id number) is
23837 select
23838 DDR.dsgn_rqmt_id new_value
23839 from BEN_DSGN_RQMT_F DDR
23840 where
23841 nvl(DDR.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
23842 nvl(DDR.OPT_ID,-999) = nvl(l_OPT_ID,-999) and
23843 nvl(DDR.PL_ID,-999) = nvl(l_PL_ID,-999) and
23844 nvl(DDR.GRP_RLSHP_CD,-999) = nvl(l_GRP_RLSHP_CD,-999) and
23845 nvl(DDR.DSGN_TYP_CD,-999) = nvl(l_DSGN_TYP_CD,-999) and
23846 DDR.business_group_id = c_business_group_id
23847 and DDR.dsgn_rqmt_id <> c_new_pk_id
23848 --TEMPIK
23849 and c_effective_start_date between effective_start_date
23850 and effective_end_date ;
23851 --END TEMPIK
23852 /*
23853 and exists ( select null
23854 from BEN_DSGN_RQMT_F DDR1
23855 where
23856 nvl(DDR1.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
23857 nvl(DDR1.OPT_ID,-999) = nvl(l_OPT_ID,-999) and
23858 nvl(DDR1.PL_ID,-999) = nvl(l_PL_ID,-999) and
23859 nvl(DDR1.GRP_RLSHP_CD,-999) = nvl(l_GRP_RLSHP_CD,-999) and
23860 nvl(DDR1.DSGN_TYP_CD,-999) = nvl(l_DSGN_TYP_CD,-999) and
23861 DDR1.business_group_id = c_business_group_id
23862 and DDR1.effective_start_date <= c_effective_start_date )
23863 and exists ( select null
23864 from BEN_DSGN_RQMT_F DDR2
23865 where
23866 nvl(DDR2.OIPL_ID,-999) = nvl(l_OIPL_ID,-999) and
23867 nvl(DDR2.OPT_ID,-999) = nvl(l_OPT_ID,-999) and
23868 nvl(DDR2.PL_ID,-999) = nvl(l_PL_ID,-999) and
23869 nvl(DDR2.GRP_RLSHP_CD,-999) = nvl(l_GRP_RLSHP_CD,-999) and
23870 nvl(DDR2.DSGN_TYP_CD,-999) = nvl(l_DSGN_TYP_CD,-999) and
23871 DDR2.business_group_id = c_business_group_id
23872 and DDR2.effective_end_date >= c_effective_end_date )
23873 ;
23874 */
23875 --
23876 --UPD START
23877 --
23878 l_update boolean := false ;
23879 l_datetrack_mode varchar2(80) := hr_api.g_update;
23880 l_process_date date;
23881 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
23882 --
23883 --UPD END
23884 l_current_pk_id number := null ;
23885 l_prev_pk_id number := null ;
23886 l_first_rec boolean := true ;
23887 r_DDR c_DDR%rowtype;
23888 l_dsgn_rqmt_id number ;
23889 l_object_version_number number ;
23890 l_effective_start_date date ;
23891 l_effective_end_date date ;
23892 l_prefix pqh_copy_entity_attribs.information1%type := null;
23893 l_suffix pqh_copy_entity_attribs.information1%type := null;
23894 l_new_value number(15);
23895 l_object_found_in_target boolean := false ;
23896 l_min_esd date;
23897 l_max_eed date;
23898 l_effective_date date;
23899 --TEMPIK
23900 l_dt_rec_found boolean ;
23901 --END TEMPIK
23902 --
23903 begin
23904 -- Initialization
23905 l_object_found_in_target := false ;
23906 -- End Initialization
23907 -- Derive the prefix - sufix
23908 if p_prefix_suffix_cd = 'PREFIX' then
23909 l_prefix := p_prefix_suffix_text ;
23910 elsif p_prefix_suffix_cd = 'SUFFIX' then
23911 l_suffix := p_prefix_suffix_text ;
23912 else
23913 l_prefix := null ;
23914 l_suffix := null ;
23915 end if ;
23916 -- End Prefix Sufix derivation
23917 for r_DDR_unique in c_unique_DDR('DDR') loop
23918
23919 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
23920 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23921 r_DDR_unique.information3 >=
23922 ben_pd_copy_to_ben_one.g_copy_effective_date)
23923 ) then
23924 --
23925 hr_utility.set_location(' r_DDR_unique.table_route_id '||r_DDR_unique.table_route_id,10);
23926 hr_utility.set_location(' r_DDR_unique.information1 '||r_DDR_unique.information1,10);
23927 hr_utility.set_location( 'r_DDR_unique.information2 '||r_DDR_unique.information2,10);
23928 hr_utility.set_location( 'r_DDR_unique.information3 '||r_DDR_unique.information3,10);
23929 -- If reuse objects flag is 'Y' then check for the object in the target business group
23930 -- if found insert the record into PLSql table and exit the loop else try create the
23931 -- object in the target business group
23932 --
23933 l_object_found_in_target := false ;
23934 --UPD START
23935 open c_DDR(r_DDR_unique.table_route_id,
23936 r_DDR_unique.information1,
23937 r_DDR_unique.information2,
23938 r_DDR_unique.information3 ) ;
23939 --
23940 fetch c_DDR into r_DDR ;
23941 --
23942 close c_DDR ;
23943 --
23944 l_dml_operation:= r_DDR_unique.dml_operation ;
23945 l_OIPL_ID := get_fk('OIPL_ID', r_DDR.information258,l_dml_operation );
23946 l_OPT_ID := get_fk('OPT_ID', r_DDR.information247,l_dml_operation );
23947 l_PL_ID := get_fk('PL_ID', r_DDR.information261,l_dml_operation );
23948 l_GRP_RLSHP_CD := r_DDR.information14;
23949 l_DSGN_TYP_CD := r_DDR.information15;
23950 --
23951 l_update := false;
23952 l_process_date := p_effective_date;
23953 --
23954 if l_dml_operation = 'UPDATE' then
23955 --
23956 l_object_found_in_target := TRUE;
23957 --
23958 if l_process_date between r_DDR_unique.information2 and r_DDR_unique.information3 then
23959 l_update := true;
23960 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)
23961 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'
23962 then
23963 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'DSGN_RQMT_ID' ;
23964 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_DDR_unique.information1 ;
23965 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_DDR_unique.information1 ;
23966 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
23967 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;
23968 --
23969 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
23970 --
23971 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
23972 --
23973 --DOUBT log_data('DDR',l_new_value,l_prefix || r_DDR_unique.name|| l_suffix,'REUSED');
23974 --
23975 end if ;
23976 hr_utility.set_location( 'found record for update',10);
23977 --
23978 else
23979 --
23980 l_update := false;
23981 --
23982 end if;
23983 else
23984 --
23985 --UPD END
23986 l_min_esd := null ;
23987 l_max_eed := null ;
23988 open c_DDR_min_max_dates(r_DDR_unique.table_route_id, r_DDR_unique.information1 ) ;
23989 fetch c_DDR_min_max_dates into l_min_esd,l_max_eed ;
23990 --
23991
23992 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
23993 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
23994 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
23995 end if;
23996 l_min_esd := greatest(l_min_esd,r_DDR_unique.information2);
23997 /* open c_DDR(r_DDR_unique.table_route_id,
23998 r_DDR_unique.information1,
23999 r_DDR_unique.information2,
24000 r_DDR_unique.information3 ) ;
24001 --
24002 fetch c_DDR into r_DDR ;
24003 --
24004 close c_DDR ; */
24005 --
24006 if p_reuse_object_flag = 'Y' then
24007 if c_DDR_min_max_dates%found then
24008 -- cursor to find the object
24009 open c_find_DDR_in_target( l_min_esd,l_max_eed,
24010 p_target_business_group_id, nvl(l_dsgn_rqmt_id, -999) ) ;
24011 fetch c_find_DDR_in_target into l_new_value ;
24012 if c_find_DDR_in_target%found then
24013 --
24014 --TEMPIK
24015 l_dt_rec_found := dt_api.check_min_max_dates
24016 (p_base_table_name => 'BEN_DSGN_RQMT_F',
24017 p_base_key_column => 'DSGN_RQMT_ID',
24018 p_base_key_value => l_new_value,
24019 p_from_date => l_min_esd,
24020 p_to_date => l_max_eed );
24021 if l_dt_rec_found THEN
24022 --END TEMPIK
24023 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
24024 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
24025 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'DSGN_RQMT_ID' ;
24026 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_DDR_unique.information1 ;
24027 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
24028 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
24029 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;
24030 --
24031 -- 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) ;
24032 --
24033 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24034 end if ;
24035 --
24036 l_object_found_in_target := true ;
24037 --TEMPIK
24038 end if; -- l_dt_rec_found
24039 --END TEMPIK
24040 end if;
24041 close c_find_DDR_in_target ;
24042 --
24043 end if;
24044 end if ;
24045 --
24046 close c_DDR_min_max_dates ;
24047 end if; --if p_dml_operation
24048 --
24049 if not l_object_found_in_target OR l_update then
24050 --
24051 l_current_pk_id := r_DDR.information1;
24052 --
24053 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
24054 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
24055 --
24056 if l_current_pk_id = l_prev_pk_id then
24057 --
24058 l_first_rec := false ;
24059 --
24060 else
24061 --
24062 l_first_rec := true ;
24063 --
24064 end if ;
24065 --
24066
24067 l_effective_date := r_DDR.information2;
24068 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24069 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
24070 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
24071 end if;
24072
24073 if l_first_rec and not l_update then
24074 -- Call Create routine.
24075 hr_utility.set_location(' BEN_DSGN_RQMT_F CREATE_DESIGN_RQMT ',20);
24076 BEN_DESIGN_RQMT_API.CREATE_DESIGN_RQMT(
24077 --
24078 P_VALIDATE => false
24079 ,P_EFFECTIVE_DATE => l_effective_date
24080 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24081 --
24082 ,P_CVR_ALL_ELIG_FLAG => r_DDR.INFORMATION13
24083 ,P_DDR_ATTRIBUTE1 => r_DDR.INFORMATION111
24084 ,P_DDR_ATTRIBUTE10 => r_DDR.INFORMATION120
24085 ,P_DDR_ATTRIBUTE11 => r_DDR.INFORMATION121
24086 ,P_DDR_ATTRIBUTE12 => r_DDR.INFORMATION122
24087 ,P_DDR_ATTRIBUTE13 => r_DDR.INFORMATION123
24088 ,P_DDR_ATTRIBUTE14 => r_DDR.INFORMATION124
24089 ,P_DDR_ATTRIBUTE15 => r_DDR.INFORMATION125
24090 ,P_DDR_ATTRIBUTE16 => r_DDR.INFORMATION126
24091 ,P_DDR_ATTRIBUTE17 => r_DDR.INFORMATION127
24092 ,P_DDR_ATTRIBUTE18 => r_DDR.INFORMATION128
24093 ,P_DDR_ATTRIBUTE19 => r_DDR.INFORMATION129
24094 ,P_DDR_ATTRIBUTE2 => r_DDR.INFORMATION112
24095 ,P_DDR_ATTRIBUTE20 => r_DDR.INFORMATION130
24096 ,P_DDR_ATTRIBUTE21 => r_DDR.INFORMATION131
24097 ,P_DDR_ATTRIBUTE22 => r_DDR.INFORMATION132
24098 ,P_DDR_ATTRIBUTE23 => r_DDR.INFORMATION133
24099 ,P_DDR_ATTRIBUTE24 => r_DDR.INFORMATION134
24100 ,P_DDR_ATTRIBUTE25 => r_DDR.INFORMATION135
24101 ,P_DDR_ATTRIBUTE26 => r_DDR.INFORMATION136
24102 ,P_DDR_ATTRIBUTE27 => r_DDR.INFORMATION137
24103 ,P_DDR_ATTRIBUTE28 => r_DDR.INFORMATION138
24104 ,P_DDR_ATTRIBUTE29 => r_DDR.INFORMATION139
24105 ,P_DDR_ATTRIBUTE3 => r_DDR.INFORMATION113
24106 ,P_DDR_ATTRIBUTE30 => r_DDR.INFORMATION140
24107 ,P_DDR_ATTRIBUTE4 => r_DDR.INFORMATION114
24108 ,P_DDR_ATTRIBUTE5 => r_DDR.INFORMATION115
24109 ,P_DDR_ATTRIBUTE6 => r_DDR.INFORMATION116
24110 ,P_DDR_ATTRIBUTE7 => r_DDR.INFORMATION117
24111 ,P_DDR_ATTRIBUTE8 => r_DDR.INFORMATION118
24112 ,P_DDR_ATTRIBUTE9 => r_DDR.INFORMATION119
24113 ,P_DDR_ATTRIBUTE_CATEGORY => r_DDR.INFORMATION110
24114 ,P_DSGN_RQMT_ID => l_dsgn_rqmt_id
24115 ,P_DSGN_TYP_CD => r_DDR.INFORMATION15
24116 ,P_GRP_RLSHP_CD => r_DDR.INFORMATION14
24117 ,P_MN_DPNTS_RQD_NUM => r_DDR.INFORMATION262
24118 ,P_MX_DPNTS_ALWD_NUM => r_DDR.INFORMATION263
24119 ,P_NO_MN_NUM_DFND_FLAG => r_DDR.INFORMATION11
24120 ,P_NO_MX_NUM_DFND_FLAG => r_DDR.INFORMATION12
24121 ,P_OIPL_ID => l_OIPL_ID
24122 ,P_OPT_ID => l_OPT_ID
24123 ,P_PL_ID => l_PL_ID
24124 --
24125 ,P_EFFECTIVE_START_DATE => l_effective_start_date
24126 ,P_EFFECTIVE_END_DATE => l_effective_end_date
24127 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24128 );
24129 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24130 -- Update all relevent cer records with new pk_id
24131 hr_utility.set_location('Before plsql table ',222);
24132 hr_utility.set_location('new_value id '||l_dsgn_rqmt_id,222);
24133 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'DSGN_RQMT_ID' ;
24134 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_DDR.information1 ;
24135 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_DSGN_RQMT_ID ;
24136 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
24137 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;
24138 hr_utility.set_location('After plsql table ',222);
24139 --
24140 -- 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 ) ;
24141 --
24142 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24143 --
24144 else
24145 --
24146 -- Call Update routine for the pk_id created in prev run .
24147 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24148 hr_utility.set_location(' BEN_DSGN_RQMT_F UPDATE_DESIGN_RQMT ',30);
24149 --UPD START
24150 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
24151 --
24152 if l_update then
24153 --
24154 l_datetrack_mode := r_DDR.datetrack_mode ;
24155 --
24156 get_dt_modes(
24157 p_effective_date => l_process_date,
24158 p_effective_end_date => r_DDR.information3,
24159 p_effective_start_date => r_DDR.information2,
24160 p_dml_operation => r_DDR.dml_operation,
24161 p_datetrack_mode => l_datetrack_mode );
24162 -- p_update => l_update
24163 --
24164 l_effective_date := l_process_date;
24165 l_DSGN_RQMT_ID := r_DDR.information1;
24166 l_object_version_number := r_DDR.information265;
24167 --
24168 end if;
24169 --
24170 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
24171 --
24172 IF l_update OR l_dml_operation <> 'UPDATE' THEN
24173 --UPD END
24174 BEN_DESIGN_RQMT_API.UPDATE_DESIGN_RQMT(
24175 --
24176 P_VALIDATE => false
24177 ,P_EFFECTIVE_DATE => l_effective_date
24178 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24179 --
24180 ,P_CVR_ALL_ELIG_FLAG => r_DDR.INFORMATION13
24181 ,P_DDR_ATTRIBUTE1 => r_DDR.INFORMATION111
24182 ,P_DDR_ATTRIBUTE10 => r_DDR.INFORMATION120
24183 ,P_DDR_ATTRIBUTE11 => r_DDR.INFORMATION121
24184 ,P_DDR_ATTRIBUTE12 => r_DDR.INFORMATION122
24185 ,P_DDR_ATTRIBUTE13 => r_DDR.INFORMATION123
24186 ,P_DDR_ATTRIBUTE14 => r_DDR.INFORMATION124
24187 ,P_DDR_ATTRIBUTE15 => r_DDR.INFORMATION125
24188 ,P_DDR_ATTRIBUTE16 => r_DDR.INFORMATION126
24189 ,P_DDR_ATTRIBUTE17 => r_DDR.INFORMATION127
24190 ,P_DDR_ATTRIBUTE18 => r_DDR.INFORMATION128
24191 ,P_DDR_ATTRIBUTE19 => r_DDR.INFORMATION129
24192 ,P_DDR_ATTRIBUTE2 => r_DDR.INFORMATION112
24193 ,P_DDR_ATTRIBUTE20 => r_DDR.INFORMATION130
24194 ,P_DDR_ATTRIBUTE21 => r_DDR.INFORMATION131
24195 ,P_DDR_ATTRIBUTE22 => r_DDR.INFORMATION132
24196 ,P_DDR_ATTRIBUTE23 => r_DDR.INFORMATION133
24197 ,P_DDR_ATTRIBUTE24 => r_DDR.INFORMATION134
24198 ,P_DDR_ATTRIBUTE25 => r_DDR.INFORMATION135
24199 ,P_DDR_ATTRIBUTE26 => r_DDR.INFORMATION136
24200 ,P_DDR_ATTRIBUTE27 => r_DDR.INFORMATION137
24201 ,P_DDR_ATTRIBUTE28 => r_DDR.INFORMATION138
24202 ,P_DDR_ATTRIBUTE29 => r_DDR.INFORMATION139
24203 ,P_DDR_ATTRIBUTE3 => r_DDR.INFORMATION113
24204 ,P_DDR_ATTRIBUTE30 => r_DDR.INFORMATION140
24205 ,P_DDR_ATTRIBUTE4 => r_DDR.INFORMATION114
24206 ,P_DDR_ATTRIBUTE5 => r_DDR.INFORMATION115
24207 ,P_DDR_ATTRIBUTE6 => r_DDR.INFORMATION116
24208 ,P_DDR_ATTRIBUTE7 => r_DDR.INFORMATION117
24209 ,P_DDR_ATTRIBUTE8 => r_DDR.INFORMATION118
24210 ,P_DDR_ATTRIBUTE9 => r_DDR.INFORMATION119
24211 ,P_DDR_ATTRIBUTE_CATEGORY => r_DDR.INFORMATION110
24212 ,P_DSGN_RQMT_ID => l_dsgn_rqmt_id
24213 ,P_DSGN_TYP_CD => r_DDR.INFORMATION15
24214 ,P_GRP_RLSHP_CD => r_DDR.INFORMATION14
24215 ,P_MN_DPNTS_RQD_NUM => r_DDR.INFORMATION262
24216 ,P_MX_DPNTS_ALWD_NUM => r_DDR.INFORMATION263
24217 ,P_NO_MN_NUM_DFND_FLAG => r_DDR.INFORMATION11
24218 ,P_NO_MX_NUM_DFND_FLAG => r_DDR.INFORMATION12
24219 ,P_OIPL_ID => l_OIPL_ID
24220 ,P_OPT_ID => l_OPT_ID
24221 ,P_PL_ID => l_PL_ID
24222 --
24223 ,P_EFFECTIVE_START_DATE => l_effective_start_date
24224 ,P_EFFECTIVE_END_DATE => l_effective_end_date
24225 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24226 ,P_DATETRACK_MODE => l_datetrack_mode
24227 );
24228 --
24229 end if; -- l_update
24230 end if;
24231 --
24232 -- Delete the row if it is end dated.
24233 --
24234 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
24235 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
24236 trunc(l_max_eed) = r_DDR.information3) then
24237 --
24238 BEN_DESIGN_RQMT_API.delete_DESIGN_RQMT(
24239 --
24240 p_validate => false
24241 ,p_dsgn_rqmt_id => l_dsgn_rqmt_id
24242 ,p_effective_start_date => l_effective_start_date
24243 ,p_effective_end_date => l_effective_end_date
24244 ,p_object_version_number => l_object_version_number
24245 ,p_effective_date => l_max_eed
24246 ,p_datetrack_mode => hr_api.g_delete
24247 --
24248 );
24249 --
24250 end if;
24251 --
24252 l_prev_pk_id := l_current_pk_id ;
24253 --
24254 end if;
24255 --
24256 end if;
24257 --
24258 end loop;
24259 --
24260 exception when others then
24261 --
24262 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'DDR',r_ddr.information5 );
24263 --
24264 end create_DDR_rows;
24265
24266 --
24267 ---------------------------------------------------------------
24268 ----------------------< create_DRR_rows >-----------------------
24269 ---------------------------------------------------------------
24270 --
24271 procedure create_DRR_rows
24272 (
24273 p_validate in number default 0
24274 ,p_copy_entity_txn_id in number
24275 ,p_effective_date in date
24276 ,p_prefix_suffix_text in varchar2 default null
24277 ,p_reuse_object_flag in varchar2 default null
24278 ,p_target_business_group_id in varchar2 default null
24279 ,p_prefix_suffix_cd in varchar2 default null
24280 ) is
24281 --
24282 l_DSGN_RQMT_ID number;
24283 l_rlshp_typ_cd varchar2(100);
24284 cursor c_unique_DRR(l_table_alias varchar2) is
24285 select distinct cpe.information1,
24286 cpe.information2,
24287 cpe.information3,
24288 cpe.table_route_id
24289 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
24290 pqh_table_route tr
24291 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24292 and cpe.table_route_id = tr.table_route_id
24293 -- and tr.where_clause = l_BEN_DSGN_RQMT_RLSHP_TYP
24294 and tr.table_alias = l_table_alias
24295 and cpe.number_of_copies = 1 -- ADDITION
24296 group by cpe.information1,cpe.information2,cpe.information3,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
24297 order by information1, information2; --added for bug: 5151945
24298 --
24299 --
24300 cursor c_DRR_min_max_dates(c_table_route_id number,
24301 c_information1 number) is
24302 select
24303 min(cpe.information2) min_esd,
24304 max(cpe.information3) min_eed
24305 from ben_copy_entity_results cpe
24306 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24307 and cpe.table_route_id = c_table_route_id
24308 and cpe.information1 = c_information1 ;
24309 --
24310 cursor c_DRR(c_table_route_id number,
24311 c_information1 number,
24312 c_information2 date,
24313 c_information3 date) is
24314 select
24315 cpe.*
24316 from ben_copy_entity_results cpe
24317 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24318 and cpe.table_route_id = c_table_route_id
24319 and cpe.information1 = c_information1
24320 and rownum = 1 ;
24321 -- Date Track target record
24322 cursor c_find_DRR_in_target(
24323 c_effective_start_date date,
24324 c_effective_end_date date,
24325 c_business_group_id number,
24326 c_new_pk_id number) is
24327 select
24328 DRR.dsgn_rqmt_rlshp_typ_id new_value
24329 from BEN_DSGN_RQMT_RLSHP_TYP DRR
24330 where
24331 DRR.DSGN_RQMT_ID = l_DSGN_RQMT_ID and
24332 DRR.rlshp_typ_cd = l_rlshp_typ_cd and
24333 DRR.business_group_id = c_business_group_id
24334 and DRR.dsgn_rqmt_rlshp_typ_id <> c_new_pk_id
24335 ;
24336 --
24337 --UPD START
24338 --
24339 l_update boolean := false ;
24340 l_datetrack_mode varchar2(80) := hr_api.g_update;
24341 l_process_date date;
24342 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
24343 --
24344 --UPD END
24345 l_current_pk_id number := null ;
24346 l_prev_pk_id number := null ;
24347 l_first_rec boolean := true ;
24348 r_DRR c_DRR%rowtype;
24349 l_dsgn_rqmt_rlshp_typ_id number ;
24350 l_object_version_number number ;
24351 l_effective_start_date date ;
24352 l_effective_end_date date ;
24353 l_prefix pqh_copy_entity_attribs.information1%type := null;
24354 l_suffix pqh_copy_entity_attribs.information1%type := null;
24355 l_new_value number(15);
24356 l_object_found_in_target boolean := false ;
24357 l_min_esd date;
24358 l_max_eed date;
24359 l_parent_effective_start_date date;
24360 --
24361 begin
24362 -- Initialization
24363 l_object_found_in_target := false ;
24364 -- End Initialization
24365 -- Derive the prefix - sufix
24366 if p_prefix_suffix_cd = 'PREFIX' then
24367 l_prefix := p_prefix_suffix_text ;
24368 elsif p_prefix_suffix_cd = 'SUFFIX' then
24369 l_suffix := p_prefix_suffix_text ;
24370 else
24371 l_prefix := null ;
24372 l_suffix := null ;
24373 end if ;
24374 -- End Prefix Sufix derivation
24375 for r_DRR_unique in c_unique_DRR('DRR') loop
24376 --
24377 hr_utility.set_location(' r_DRR_unique.table_route_id '||r_DRR_unique.table_route_id,10);
24378 hr_utility.set_location(' r_DRR_unique.information1 '||r_DRR_unique.information1,10);
24379 hr_utility.set_location( 'r_DRR_unique.information2 '||r_DRR_unique.information2,10);
24380 hr_utility.set_location( 'r_DRR_unique.information3 '||r_DRR_unique.information3,10);
24381 -- If reuse objects flag is 'Y' then check for the object in the target business group
24382 -- if found insert the record into PLSql table and exit the loop else try create the
24383 -- object in the target business group
24384 --
24385 l_object_found_in_target := false ;
24386 l_min_esd := null ;
24387 l_max_eed := null ;
24388 --
24389 open c_DRR(r_DRR_unique.table_route_id,
24390 r_DRR_unique.information1,
24391 r_DRR_unique.information2,
24392 r_DRR_unique.information3 ) ;
24393 --
24394 fetch c_DRR into r_DRR ;
24395 --
24396 close c_DRR ;
24397 --
24398 --UPD START
24399 --
24400 l_update := false;
24401 l_process_date := p_effective_date;
24402 l_dml_operation:= r_DRR_unique.dml_operation ;
24403 --
24404 --UPD END
24405 l_DSGN_RQMT_ID := get_fk('DSGN_RQMT_ID', r_DRR.information260,l_dml_operation);
24406 l_rlshp_typ_cd := r_DRR.information11;
24407 --UPD START
24408 --
24409 if l_dml_operation = 'UPDATE' then
24410 --
24411 l_update := true;
24412 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
24413 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
24414 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' ;
24415 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_DRR_unique.information1 ;
24416 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_DRR_unique.information1 ;
24417 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
24418 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;
24419 --
24420 -- 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
24421 --
24422 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24423 --
24424 --DOUBT log_data('DRR',l_new_value,l_prefix || r_DRR_unique.name|| l_suffix,'REUSED');
24425 --
24426 end if ;
24427 l_DSGN_RQMT_RLSHP_TYP_ID := r_DRR_unique.information1 ;
24428 l_object_version_number := r_DRR.information265 ;
24429 hr_utility.set_location( 'found record for update',10);
24430 --
24431 else
24432 --
24433 --UPD END
24434 if p_reuse_object_flag = 'Y' then
24435 -- cursor to find the object
24436 open c_find_DRR_in_target( r_DRR_unique.information2,l_max_eed,
24437 p_target_business_group_id, nvl(l_dsgn_rqmt_rlshp_typ_id, -999) ) ;
24438 fetch c_find_DRR_in_target into l_new_value ;
24439 if c_find_DRR_in_target%found then
24440 --
24441 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
24442 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
24443 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' ;
24444 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_DRR_unique.information1 ;
24445 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
24446 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
24447 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;
24448 --
24449 -- 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) ;
24450 --
24451 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24452 end if ;
24453 --
24454 l_object_found_in_target := true ;
24455 end if;
24456 close c_find_DRR_in_target ;
24457 --
24458 end if ;
24459 --
24460 end if; --if p_dml_operation
24461 --
24462 if not l_object_found_in_target OR l_update then
24463 --
24464 l_current_pk_id := r_DRR.information1;
24465 --
24466 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
24467 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
24468 --
24469 if l_current_pk_id = l_prev_pk_id then
24470 --
24471 l_first_rec := false ;
24472 --
24473 else
24474 --
24475 l_first_rec := true ;
24476 --
24477 end if ;
24478 --
24479
24480 l_parent_effective_start_date := r_DRR.information10;
24481 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null ) then
24482 if l_parent_effective_start_date is null then
24483 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
24484 elsif l_parent_effective_start_date < ben_pd_copy_to_ben_one.g_copy_effective_date then
24485 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
24486 end if;
24487 end if;
24488 --
24489 -- To avoid creating a child with out a parent
24490 --
24491 --
24492 if l_DSGN_RQMT_ID is null then
24493 l_first_rec := false ;
24494 end if;
24495 --
24496 if l_first_rec and not l_update then
24497 -- Call Create routine.
24498 hr_utility.set_location(' BEN_DSGN_RQMT_RLSHP_TYP CREATE_DSGN_RQMT_RLSHP_TYP ',20);
24499 BEN_DSGN_RQMT_RLSHP_TYP_API.CREATE_DSGN_RQMT_RLSHP_TYP(
24500 --
24501 P_VALIDATE => false
24502 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
24503 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24504 --
24505 ,P_DRR_ATTRIBUTE1 => r_DRR.INFORMATION111
24506 ,P_DRR_ATTRIBUTE10 => r_DRR.INFORMATION120
24507 ,P_DRR_ATTRIBUTE11 => r_DRR.INFORMATION121
24508 ,P_DRR_ATTRIBUTE12 => r_DRR.INFORMATION122
24509 ,P_DRR_ATTRIBUTE13 => r_DRR.INFORMATION123
24510 ,P_DRR_ATTRIBUTE14 => r_DRR.INFORMATION124
24511 ,P_DRR_ATTRIBUTE15 => r_DRR.INFORMATION125
24512 ,P_DRR_ATTRIBUTE16 => r_DRR.INFORMATION126
24513 ,P_DRR_ATTRIBUTE17 => r_DRR.INFORMATION127
24514 ,P_DRR_ATTRIBUTE18 => r_DRR.INFORMATION128
24515 ,P_DRR_ATTRIBUTE19 => r_DRR.INFORMATION129
24516 ,P_DRR_ATTRIBUTE2 => r_DRR.INFORMATION112
24517 ,P_DRR_ATTRIBUTE20 => r_DRR.INFORMATION130
24518 ,P_DRR_ATTRIBUTE21 => r_DRR.INFORMATION131
24519 ,P_DRR_ATTRIBUTE22 => r_DRR.INFORMATION132
24520 ,P_DRR_ATTRIBUTE23 => r_DRR.INFORMATION133
24521 ,P_DRR_ATTRIBUTE24 => r_DRR.INFORMATION134
24522 ,P_DRR_ATTRIBUTE25 => r_DRR.INFORMATION135
24523 ,P_DRR_ATTRIBUTE26 => r_DRR.INFORMATION136
24524 ,P_DRR_ATTRIBUTE27 => r_DRR.INFORMATION137
24525 ,P_DRR_ATTRIBUTE28 => r_DRR.INFORMATION138
24526 ,P_DRR_ATTRIBUTE29 => r_DRR.INFORMATION139
24527 ,P_DRR_ATTRIBUTE3 => r_DRR.INFORMATION113
24528 ,P_DRR_ATTRIBUTE30 => r_DRR.INFORMATION140
24529 ,P_DRR_ATTRIBUTE4 => r_DRR.INFORMATION114
24530 ,P_DRR_ATTRIBUTE5 => r_DRR.INFORMATION115
24531 ,P_DRR_ATTRIBUTE6 => r_DRR.INFORMATION116
24532 ,P_DRR_ATTRIBUTE7 => r_DRR.INFORMATION117
24533 ,P_DRR_ATTRIBUTE8 => r_DRR.INFORMATION118
24534 ,P_DRR_ATTRIBUTE9 => r_DRR.INFORMATION119
24535 ,P_DRR_ATTRIBUTE_CATEGORY => r_DRR.INFORMATION110
24536 ,P_DSGN_RQMT_ID => l_DSGN_RQMT_ID
24537 ,P_DSGN_RQMT_RLSHP_TYP_ID => l_dsgn_rqmt_rlshp_typ_id
24538 ,P_RLSHP_TYP_CD => r_DRR.INFORMATION11
24539 --
24540 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24541 );
24542 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24543 -- Update all relevent cer records with new pk_id
24544 hr_utility.set_location('Before plsql table ',222);
24545 hr_utility.set_location('new_value id '||l_dsgn_rqmt_rlshp_typ_id,222);
24546 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' ;
24547 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_DRR.information1 ;
24548 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 ;
24549 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
24550 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;
24551 hr_utility.set_location('After plsql table ',222);
24552 --
24553 -- 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 ) ;
24554 --
24555 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24556 --
24557 elsif l_update then
24558 BEN_DSGN_RQMT_RLSHP_TYP_API.UPDATE_DSGN_RQMT_RLSHP_TYP(
24559 --
24560 P_VALIDATE => false
24561 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
24562 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24563 --
24564 ,P_DRR_ATTRIBUTE1 => r_DRR.INFORMATION111
24565 ,P_DRR_ATTRIBUTE10 => r_DRR.INFORMATION120
24566 ,P_DRR_ATTRIBUTE11 => r_DRR.INFORMATION121
24567 ,P_DRR_ATTRIBUTE12 => r_DRR.INFORMATION122
24568 ,P_DRR_ATTRIBUTE13 => r_DRR.INFORMATION123
24569 ,P_DRR_ATTRIBUTE14 => r_DRR.INFORMATION124
24570 ,P_DRR_ATTRIBUTE15 => r_DRR.INFORMATION125
24571 ,P_DRR_ATTRIBUTE16 => r_DRR.INFORMATION126
24572 ,P_DRR_ATTRIBUTE17 => r_DRR.INFORMATION127
24573 ,P_DRR_ATTRIBUTE18 => r_DRR.INFORMATION128
24574 ,P_DRR_ATTRIBUTE19 => r_DRR.INFORMATION129
24575 ,P_DRR_ATTRIBUTE2 => r_DRR.INFORMATION112
24576 ,P_DRR_ATTRIBUTE20 => r_DRR.INFORMATION130
24577 ,P_DRR_ATTRIBUTE21 => r_DRR.INFORMATION131
24578 ,P_DRR_ATTRIBUTE22 => r_DRR.INFORMATION132
24579 ,P_DRR_ATTRIBUTE23 => r_DRR.INFORMATION133
24580 ,P_DRR_ATTRIBUTE24 => r_DRR.INFORMATION134
24581 ,P_DRR_ATTRIBUTE25 => r_DRR.INFORMATION135
24582 ,P_DRR_ATTRIBUTE26 => r_DRR.INFORMATION136
24583 ,P_DRR_ATTRIBUTE27 => r_DRR.INFORMATION137
24584 ,P_DRR_ATTRIBUTE28 => r_DRR.INFORMATION138
24585 ,P_DRR_ATTRIBUTE29 => r_DRR.INFORMATION139
24586 ,P_DRR_ATTRIBUTE3 => r_DRR.INFORMATION113
24587 ,P_DRR_ATTRIBUTE30 => r_DRR.INFORMATION140
24588 ,P_DRR_ATTRIBUTE4 => r_DRR.INFORMATION114
24589 ,P_DRR_ATTRIBUTE5 => r_DRR.INFORMATION115
24590 ,P_DRR_ATTRIBUTE6 => r_DRR.INFORMATION116
24591 ,P_DRR_ATTRIBUTE7 => r_DRR.INFORMATION117
24592 ,P_DRR_ATTRIBUTE8 => r_DRR.INFORMATION118
24593 ,P_DRR_ATTRIBUTE9 => r_DRR.INFORMATION119
24594 ,P_DRR_ATTRIBUTE_CATEGORY => r_DRR.INFORMATION110
24595 ,P_DSGN_RQMT_ID => l_DSGN_RQMT_ID
24596 ,P_DSGN_RQMT_RLSHP_TYP_ID => l_dsgn_rqmt_rlshp_typ_id
24597 ,P_RLSHP_TYP_CD => r_DRR.INFORMATION11
24598 --
24599 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24600 );
24601 end if;
24602 --
24603 l_prev_pk_id := l_current_pk_id ;
24604 --
24605 end if;
24606 --
24607 end loop;
24608 --
24609 exception when others then
24610 --
24611 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'DRR',r_drr.information5 );
24612 --
24613 end create_DRR_rows;
24614
24615 --
24616 ---------------------------------------------------------------
24617 ----------------------< create_OPP_rows >-----------------------
24618 ---------------------------------------------------------------
24619 --
24620 procedure create_OPP_rows
24621 (
24622 p_validate in number default 0
24623 ,p_copy_entity_txn_id in number
24624 ,p_effective_date in date
24625 ,p_prefix_suffix_text in varchar2 default null
24626 ,p_reuse_object_flag in varchar2 default null
24627 ,p_target_business_group_id in varchar2 default null
24628 ,p_prefix_suffix_cd in varchar2 default null
24629 ) is
24630 --
24631 l_OIPL_ID number;
24632 l_PLIP_ID number;
24633 cursor c_unique_OPP(l_table_alias varchar2) is
24634 select distinct cpe.information1,
24635 cpe.information2,
24636 cpe.information3,
24637 cpe.table_route_id
24638 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
24639 pqh_table_route tr
24640 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24641 and cpe.table_route_id = tr.table_route_id
24642 -- and tr.where_clause = l_BEN_OIPLIP_F
24643 and tr.table_alias = l_table_alias
24644 and cpe.number_of_copies = 1 -- ADDITION
24645 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
24646 order by information1, information2; --added for bug: 5151945
24647 --
24648 --
24649 cursor c_OPP_min_max_dates(c_table_route_id number,
24650 c_information1 number) is
24651 select
24652 min(cpe.information2) min_esd,
24653 max(cpe.information3) min_eed
24654 from ben_copy_entity_results cpe
24655 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24656 and cpe.table_route_id = c_table_route_id
24657 and cpe.information1 = c_information1 ;
24658 --
24659 cursor c_OPP(c_table_route_id number,
24660 c_information1 number,
24661 c_information2 date,
24662 c_information3 date ) is
24663 select
24664 cpe.*
24665 from ben_copy_entity_results cpe
24666 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
24667 and cpe.table_route_id = c_table_route_id
24668 and cpe.information1 = c_information1
24669 and cpe.information2 = c_information2
24670 and cpe.information3 = c_information3
24671 and rownum = 1 ;
24672 -- Date Track target record
24673 cursor c_find_OPP_in_target(
24674 c_effective_start_date date,
24675 c_effective_end_date date,
24676 c_business_group_id number,
24677 c_new_pk_id number) is
24678 select
24679 OPP.oiplip_id new_value
24680 from BEN_OIPLIP_F OPP
24681 where
24682 OPP.OIPL_ID = l_OIPL_ID and
24683 OPP.PLIP_ID = l_PLIP_ID and
24684 OPP.business_group_id = c_business_group_id
24685 and OPP.oiplip_id <> c_new_pk_id
24686 --TEMPIK
24687 and c_effective_start_date between effective_start_date
24688 and effective_end_date ;
24689 --END TEMPIK
24690 /*
24691 and exists ( select null
24692 from BEN_OIPLIP_F OPP1
24693 where
24694 OPP1.OIPL_ID = l_OIPL_ID and
24695 OPP1.PLIP_ID = l_PLIP_ID and
24696 OPP1.business_group_id = c_business_group_id
24697 and OPP1.effective_start_date <= c_effective_start_date )
24698 and exists ( select null
24699 from BEN_OIPLIP_F OPP2
24700 where
24701 OPP2.OIPL_ID = l_OIPL_ID and
24702 OPP2.PLIP_ID = l_PLIP_ID and
24703 OPP2.business_group_id = c_business_group_id
24704 and OPP2.effective_end_date >= c_effective_end_date )
24705 ;
24706 */
24707 --
24708 l_current_pk_id number := null ;
24709 l_prev_pk_id number := null ;
24710 l_first_rec boolean := true ;
24711 r_OPP c_OPP%rowtype;
24712 l_oiplip_id number ;
24713 l_object_version_number number ;
24714 l_effective_start_date date ;
24715 l_effective_end_date date ;
24716 l_prefix pqh_copy_entity_attribs.information1%type := null;
24717 l_suffix pqh_copy_entity_attribs.information1%type := null;
24718 l_new_value number(15);
24719 l_object_found_in_target boolean := false ;
24720 l_min_esd date;
24721 l_max_eed date;
24722 l_effective_date date;
24723 --TEMPIK
24724 l_dt_rec_found boolean ;
24725 --END TEMPIK
24726 --
24727 begin
24728 -- Initialization
24729 l_object_found_in_target := false ;
24730 -- End Initialization
24731 -- Derive the prefix - sufix
24732 if p_prefix_suffix_cd = 'PREFIX' then
24733 l_prefix := p_prefix_suffix_text ;
24734 elsif p_prefix_suffix_cd = 'SUFFIX' then
24735 l_suffix := p_prefix_suffix_text ;
24736 else
24737 l_prefix := null ;
24738 l_suffix := null ;
24739 end if ;
24740 -- End Prefix Sufix derivation
24741 for r_OPP_unique in c_unique_OPP('OPP') loop
24742
24743 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
24744 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24745 r_OPP_unique.information3 >=
24746 ben_pd_copy_to_ben_one.g_copy_effective_date)
24747 ) then
24748 --
24749 hr_utility.set_location(' r_OPP_unique.table_route_id '||r_OPP_unique.table_route_id,10);
24750 hr_utility.set_location(' r_OPP_unique.information1 '||r_OPP_unique.information1,10);
24751 hr_utility.set_location( 'r_OPP_unique.information2 '||r_OPP_unique.information2,10);
24752 hr_utility.set_location( 'r_OPP_unique.information3 '||r_OPP_unique.information3,10);
24753 -- If reuse objects flag is 'Y' then check for the object in the target business group
24754 -- if found insert the record into PLSql table and exit the loop else try create the
24755 -- object in the target business group
24756 --
24757 l_object_found_in_target := false ;
24758 l_min_esd := null ;
24759 l_max_eed := null ;
24760 open c_OPP_min_max_dates(r_OPP_unique.table_route_id, r_OPP_unique.information1 ) ;
24761 fetch c_OPP_min_max_dates into l_min_esd,l_max_eed ;
24762 --
24763
24764 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24765 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
24766 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
24767 end if;
24768 l_min_esd := greatest(l_min_esd,r_OPP_unique.information2);
24769 open c_OPP(r_OPP_unique.table_route_id,
24770 r_OPP_unique.information1,
24771 r_OPP_unique.information2,
24772 r_OPP_unique.information3 ) ;
24773 --
24774 fetch c_OPP into r_OPP ;
24775 --
24776 close c_OPP ;
24777 --
24778 l_OIPL_ID := get_fk('OIPL_ID', r_OPP.INFORMATION258);
24779 l_PLIP_ID := get_fk('PLIP_ID', r_OPP.INFORMATION256);
24780 -- if p_reuse_object_flag = 'Y' then
24781 if c_OPP_min_max_dates%found then
24782 -- cursor to find the object
24783
24784 -- Bug: 3512195. In the below cursor, pass l_min_esd instead of r_OPP.information2
24785 -- This is because OPP records are not created here, but have already been created
24786 -- while PLIP and OIPL rows are created.
24787
24788 open c_find_OPP_in_target( l_min_esd,l_max_eed,
24789 p_target_business_group_id, nvl(l_oiplip_id, -999) ) ;
24790 fetch c_find_OPP_in_target into l_new_value ;
24791 if c_find_OPP_in_target%found then
24792 --
24793 --TEMPIK
24794 l_dt_rec_found := dt_api.check_min_max_dates
24795 (p_base_table_name => 'BEN_OIPLIP_F',
24796 p_base_key_column => 'OIPLIP_ID',
24797 p_base_key_value => l_new_value,
24798 p_from_date => l_min_esd,
24799 p_to_date => l_max_eed );
24800 if l_dt_rec_found THEN
24801 --END TEMPIK
24802 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
24803 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
24804 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OIPLIP_ID' ;
24805 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_OPP_unique.information1 ;
24806 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
24807 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
24808 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;
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 end if ;
24814 --
24815 l_object_found_in_target := true ;
24816 --TEMPIK
24817 end if; -- l_dt_rec_found
24818 --END TEMPIK
24819 end if;
24820 close c_find_OPP_in_target ;
24821 --
24822 end if;
24823 -- end if ;
24824 --
24825 close c_OPP_min_max_dates ;
24826 --
24827 -- NEVER CREATE HERE. THIS IS DONE IN BEN_PLIP_F and BEN_OIPL_F apis.
24828 /*
24829 if not l_object_found_in_target then
24830 --
24831 l_current_pk_id := r_OPP.information1;
24832 --
24833 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
24834 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
24835 --
24836 if l_current_pk_id = l_prev_pk_id then
24837 --
24838 l_first_rec := false ;
24839 --
24840 else
24841 --
24842 l_first_rec := true ;
24843 --
24844 end if ;
24845 --
24846
24847 l_effective_date := r_OPP.information2;
24848 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
24849 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
24850 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
24851 end if;
24852
24853 if l_first_rec then
24854 -- Call Create routine.
24855 hr_utility.set_location(' BEN_OIPLIP_F CREATE_OPTION_IN_PLAN_IN_PGM ',20);
24856 BEN_OPTION_IN_PLAN_IN_PGM_API.CREATE_OPTION_IN_PLAN_IN_PGM(
24857 --
24858 P_VALIDATE => false
24859 ,P_EFFECTIVE_DATE => l_effective_date
24860 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24861 --
24862 ,P_OIPLIP_ID => l_oiplip_id
24863 ,P_OIPL_ID => l_OIPL_ID
24864 ,P_OPP_ATTRIBUTE1 => r_OPP.INFORMATION111
24865 ,P_OPP_ATTRIBUTE10 => r_OPP.INFORMATION120
24866 ,P_OPP_ATTRIBUTE11 => r_OPP.INFORMATION121
24867 ,P_OPP_ATTRIBUTE12 => r_OPP.INFORMATION122
24868 ,P_OPP_ATTRIBUTE13 => r_OPP.INFORMATION123
24869 ,P_OPP_ATTRIBUTE14 => r_OPP.INFORMATION124
24870 ,P_OPP_ATTRIBUTE15 => r_OPP.INFORMATION125
24871 ,P_OPP_ATTRIBUTE16 => r_OPP.INFORMATION126
24872 ,P_OPP_ATTRIBUTE17 => r_OPP.INFORMATION127
24873 ,P_OPP_ATTRIBUTE18 => r_OPP.INFORMATION128
24874 ,P_OPP_ATTRIBUTE19 => r_OPP.INFORMATION129
24875 ,P_OPP_ATTRIBUTE2 => r_OPP.INFORMATION112
24876 ,P_OPP_ATTRIBUTE20 => r_OPP.INFORMATION130
24877 ,P_OPP_ATTRIBUTE21 => r_OPP.INFORMATION131
24878 ,P_OPP_ATTRIBUTE22 => r_OPP.INFORMATION132
24879 ,P_OPP_ATTRIBUTE23 => r_OPP.INFORMATION133
24880 ,P_OPP_ATTRIBUTE24 => r_OPP.INFORMATION134
24881 ,P_OPP_ATTRIBUTE25 => r_OPP.INFORMATION135
24882 ,P_OPP_ATTRIBUTE26 => r_OPP.INFORMATION136
24883 ,P_OPP_ATTRIBUTE27 => r_OPP.INFORMATION137
24884 ,P_OPP_ATTRIBUTE28 => r_OPP.INFORMATION138
24885 ,P_OPP_ATTRIBUTE29 => r_OPP.INFORMATION139
24886 ,P_OPP_ATTRIBUTE3 => r_OPP.INFORMATION113
24887 ,P_OPP_ATTRIBUTE30 => r_OPP.INFORMATION140
24888 ,P_OPP_ATTRIBUTE4 => r_OPP.INFORMATION114
24889 ,P_OPP_ATTRIBUTE5 => r_OPP.INFORMATION115
24890 ,P_OPP_ATTRIBUTE6 => r_OPP.INFORMATION116
24891 ,P_OPP_ATTRIBUTE7 => r_OPP.INFORMATION117
24892 ,P_OPP_ATTRIBUTE8 => r_OPP.INFORMATION118
24893 ,P_OPP_ATTRIBUTE9 => r_OPP.INFORMATION119
24894 ,P_OPP_ATTRIBUTE_CATEGORY => r_OPP.INFORMATION110
24895 ,P_PLIP_ID => l_PLIP_ID
24896 --
24897 ,P_EFFECTIVE_START_DATE => l_effective_start_date
24898 ,P_EFFECTIVE_END_DATE => l_effective_end_date
24899 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24900 );
24901 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24902 -- Update all relevent cer records with new pk_id
24903 hr_utility.set_location('Before plsql table ',222);
24904 hr_utility.set_location('new_value id '||l_oiplip_id,222);
24905 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OIPLIP_ID' ;
24906 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_OPP.information1 ;
24907 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_OIPLIP_ID ;
24908 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
24909 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;
24910 hr_utility.set_location('After plsql table ',222);
24911 --
24912 -- 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 ) ;
24913 --
24914 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
24915 --
24916 else
24917 --
24918 -- Call Update routine for the pk_id created in prev run .
24919 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
24920 hr_utility.set_location(' BEN_OIPLIP_F UPDATE_OPTION_IN_PLAN_IN_PGM ',30);
24921 BEN_OPTION_IN_PLAN_IN_PGM_API.UPDATE_OPTION_IN_PLAN_IN_PGM(
24922 --
24923 P_VALIDATE => false
24924 ,P_EFFECTIVE_DATE => l_effective_date
24925 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
24926 --
24927 ,P_OIPLIP_ID => l_oiplip_id
24928 ,P_OIPL_ID => l_OIPL_ID
24929 ,P_OPP_ATTRIBUTE1 => r_OPP.INFORMATION111
24930 ,P_OPP_ATTRIBUTE10 => r_OPP.INFORMATION120
24931 ,P_OPP_ATTRIBUTE11 => r_OPP.INFORMATION121
24932 ,P_OPP_ATTRIBUTE12 => r_OPP.INFORMATION122
24933 ,P_OPP_ATTRIBUTE13 => r_OPP.INFORMATION123
24934 ,P_OPP_ATTRIBUTE14 => r_OPP.INFORMATION124
24935 ,P_OPP_ATTRIBUTE15 => r_OPP.INFORMATION125
24936 ,P_OPP_ATTRIBUTE16 => r_OPP.INFORMATION126
24937 ,P_OPP_ATTRIBUTE17 => r_OPP.INFORMATION127
24938 ,P_OPP_ATTRIBUTE18 => r_OPP.INFORMATION128
24939 ,P_OPP_ATTRIBUTE19 => r_OPP.INFORMATION129
24940 ,P_OPP_ATTRIBUTE2 => r_OPP.INFORMATION112
24941 ,P_OPP_ATTRIBUTE20 => r_OPP.INFORMATION130
24942 ,P_OPP_ATTRIBUTE21 => r_OPP.INFORMATION131
24943 ,P_OPP_ATTRIBUTE22 => r_OPP.INFORMATION132
24944 ,P_OPP_ATTRIBUTE23 => r_OPP.INFORMATION133
24945 ,P_OPP_ATTRIBUTE24 => r_OPP.INFORMATION134
24946 ,P_OPP_ATTRIBUTE25 => r_OPP.INFORMATION135
24947 ,P_OPP_ATTRIBUTE26 => r_OPP.INFORMATION136
24948 ,P_OPP_ATTRIBUTE27 => r_OPP.INFORMATION137
24949 ,P_OPP_ATTRIBUTE28 => r_OPP.INFORMATION138
24950 ,P_OPP_ATTRIBUTE29 => r_OPP.INFORMATION139
24951 ,P_OPP_ATTRIBUTE3 => r_OPP.INFORMATION113
24952 ,P_OPP_ATTRIBUTE30 => r_OPP.INFORMATION140
24953 ,P_OPP_ATTRIBUTE4 => r_OPP.INFORMATION114
24954 ,P_OPP_ATTRIBUTE5 => r_OPP.INFORMATION115
24955 ,P_OPP_ATTRIBUTE6 => r_OPP.INFORMATION116
24956 ,P_OPP_ATTRIBUTE7 => r_OPP.INFORMATION117
24957 ,P_OPP_ATTRIBUTE8 => r_OPP.INFORMATION118
24958 ,P_OPP_ATTRIBUTE9 => r_OPP.INFORMATION119
24959 ,P_OPP_ATTRIBUTE_CATEGORY => r_OPP.INFORMATION110
24960 ,P_PLIP_ID => l_PLIP_ID
24961 --
24962 ,P_EFFECTIVE_START_DATE => l_effective_start_date
24963 ,P_EFFECTIVE_END_DATE => l_effective_end_date
24964 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
24965 ,P_DATETRACK_MODE => hr_api.g_update
24966 );
24967 --
24968 end if;
24969 --
24970 -- Delete the row if it is end dated.
24971 --
24972 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
24973 trunc(l_max_eed) = r_OPP.information3) then
24974 --
24975 BEN_OPTION_IN_PLAN_IN_PGM_API.delete_OPTION_IN_PLAN_IN_PGM(
24976 --
24977 p_validate => false
24978 ,p_oiplip_id => l_oiplip_id
24979 ,p_effective_start_date => l_effective_start_date
24980 ,p_effective_end_date => l_effective_end_date
24981 ,p_object_version_number => l_object_version_number
24982 ,p_effective_date => l_max_eed
24983 ,p_datetrack_mode => hr_api.g_delete
24984 --
24985 );
24986 --
24987 end if;
24988 --
24989 l_prev_pk_id := l_current_pk_id ;
24990 --
24991 end if;
24992 */
24993 --
24994 end if;
24995 --
24996 end loop;
24997 --
24998 exception when others then
24999 --
25000 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'OPP',r_opp.information5 );
25001 --
25002 end create_OPP_rows;
25003
25004 --
25005 ---------------------------------------------------------------
25006 ----------------------< create_OTP_rows >-----------------------
25007 ---------------------------------------------------------------
25008 --
25009 procedure create_OTP_rows
25010 (
25011 p_validate in number default 0
25012 ,p_copy_entity_txn_id in number
25013 ,p_effective_date in date
25014 ,p_prefix_suffix_text in varchar2 default null
25015 ,p_reuse_object_flag in varchar2 default null
25016 ,p_target_business_group_id in varchar2 default null
25017 ,p_prefix_suffix_cd in varchar2 default null
25018 ) is
25019 --
25020 l_CMBN_PTIP_OPT_ID number;
25021 l_OPT_ID number;
25022 l_PGM_ID number;
25023 l_PL_TYP_ID number;
25024 l_PTIP_ID number;
25025 cursor c_unique_OTP(l_table_alias varchar2) is
25026 select distinct cpe.information1,
25027 cpe.information2,
25028 cpe.information3,
25029 cpe.table_route_id
25030 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
25031 pqh_table_route tr
25032 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25033 and cpe.table_route_id = tr.table_route_id
25034 -- and tr.where_clause = l_BEN_OPTIP_F
25035 and tr.table_alias = l_table_alias
25036 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
25037 order by information1, information2; --added for bug: 5151945
25038 --
25039 --
25040 cursor c_OTP_min_max_dates(c_table_route_id number,
25041 c_information1 number) is
25042 select
25043 min(cpe.information2) min_esd,
25044 max(cpe.information3) min_eed
25045 from ben_copy_entity_results cpe
25046 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25047 and cpe.table_route_id = c_table_route_id
25048 and cpe.information1 = c_information1 ;
25049 --
25050 cursor c_OTP(c_table_route_id number,
25051 c_information1 number,
25052 c_information2 date,
25053 c_information3 date ) is
25054 select
25055 cpe.*
25056 from ben_copy_entity_results cpe
25057 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25058 and cpe.table_route_id = c_table_route_id
25059 and cpe.information1 = c_information1
25060 and cpe.information2 = c_information2
25061 and cpe.information3 = c_information3
25062 and rownum = 1 ;
25063 -- Date Track target record
25064 cursor c_find_OTP_in_target(
25065 c_effective_start_date date,
25066 c_effective_end_date date,
25067 c_business_group_id number,
25068 c_new_pk_id number) is
25069 select
25070 OTP.optip_id new_value
25071 from BEN_OPTIP_F OTP
25072 where
25073 -- nvl(OTP.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999) and
25074 OTP.OPT_ID = l_OPT_ID and
25075 OTP.PGM_ID = l_PGM_ID and
25076 OTP.PL_TYP_ID = l_PL_TYP_ID and
25077 -- nvl(OTP.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
25078 OTP.business_group_id = c_business_group_id
25079 and OTP.optip_id <> c_new_pk_id
25080 --TEMPIK
25081 and c_effective_start_date between effective_start_date
25082 and effective_end_date ;
25083 --END TEMPIK
25084 /*
25085 and exists ( select null
25086 from BEN_OPTIP_F OTP1
25087 where
25088 -- nvl(OTP1.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999) and
25089 OTP1.OPT_ID = l_OPT_ID and
25090 OTP1.PGM_ID = l_PGM_ID and
25091 OTP1.PL_TYP_ID = l_PL_TYP_ID and
25092 -- nvl(OTP1.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
25093 OTP1.business_group_id = c_business_group_id
25094 and OTP1.effective_start_date <= c_effective_start_date )
25095 and exists ( select null
25096 from BEN_OPTIP_F OTP2
25097 where
25098 -- nvl(OTP2.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999) and
25099 OTP2.OPT_ID = l_OPT_ID and
25100 OTP2.PGM_ID = l_PGM_ID and
25101 OTP2.PL_TYP_ID = l_PL_TYP_ID and
25102 -- nvl(OTP2.PTIP_ID,-999) = nvl(l_PTIP_ID,-999) and
25103 OTP2.business_group_id = c_business_group_id
25104 and OTP2.effective_end_date >= c_effective_end_date )
25105 ;
25106 -- */
25107 l_current_pk_id number := null ;
25108 l_prev_pk_id number := null ;
25109 l_first_rec boolean := true ;
25110 r_OTP c_OTP%rowtype;
25111 l_optip_id number ;
25112 l_object_version_number number ;
25113 l_effective_start_date date ;
25114 l_effective_end_date date ;
25115 l_prefix pqh_copy_entity_attribs.information1%type := null;
25116 l_suffix pqh_copy_entity_attribs.information1%type := null;
25117 l_new_value number(15);
25118 l_object_found_in_target boolean := false ;
25119 l_min_esd date;
25120 l_max_eed date;
25121 l_effective_date date;
25122 --TEMPIK
25123 l_dt_rec_found boolean ;
25124 --END TEMPIK
25125 --
25126 begin
25127 -- Initialization
25128 l_object_found_in_target := false ;
25129 -- End Initialization
25130 -- Derive the prefix - sufix
25131 if p_prefix_suffix_cd = 'PREFIX' then
25132 l_prefix := p_prefix_suffix_text ;
25133 elsif p_prefix_suffix_cd = 'SUFFIX' then
25134 l_suffix := p_prefix_suffix_text ;
25135 else
25136 l_prefix := null ;
25137 l_suffix := null ;
25138 end if ;
25139 -- End Prefix Sufix derivation
25140 for r_OTP_unique in c_unique_OTP('OTP') loop
25141
25142 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
25143 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25144 r_OTP_unique.information3 >=
25145 ben_pd_copy_to_ben_one.g_copy_effective_date)
25146 ) then
25147 --
25148 hr_utility.set_location(' r_OTP_unique.table_route_id '||r_OTP_unique.table_route_id,10);
25149 hr_utility.set_location(' r_OTP_unique.information1 '||r_OTP_unique.information1,10);
25150 hr_utility.set_location( 'r_OTP_unique.information2 '||r_OTP_unique.information2,10);
25151 hr_utility.set_location( 'r_OTP_unique.information3 '||r_OTP_unique.information3,10);
25152 -- If reuse objects flag is 'Y' then check for the object in the target business group
25153 -- if found insert the record into PLSql table and exit the loop else try create the
25154 -- object in the target business group
25155 --
25156 l_object_found_in_target := false ;
25157 l_min_esd := null ;
25158 l_max_eed := null ;
25159 open c_OTP_min_max_dates(r_OTP_unique.table_route_id, r_OTP_unique.information1 ) ;
25160 fetch c_OTP_min_max_dates into l_min_esd,l_max_eed ;
25161 --
25162
25163 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25164 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
25165 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
25166 end if;
25167 l_min_esd := greatest(l_min_esd,r_OTP_unique.information2);
25168 open c_OTP(r_OTP_unique.table_route_id,
25169 r_OTP_unique.information1,
25170 r_OTP_unique.information2,
25171 r_OTP_unique.information3 ) ;
25172 --
25173 fetch c_OTP into r_OTP ;
25174 --
25175 close c_OTP ;
25176 --
25177 l_CMBN_PTIP_OPT_ID := get_fk('CMBN_PTIP_OPT_ID', r_OTP.INFORMATION249);
25178 l_OPT_ID := get_fk('OPT_ID', r_OTP.INFORMATION247);
25179 l_PGM_ID := get_fk('PGM_ID', r_OTP.INFORMATION260);
25180 l_PL_TYP_ID := get_fk('PL_TYP_ID', r_OTP.INFORMATION248);
25181 l_PTIP_ID := get_fk('PTIP_ID', r_OTP.INFORMATION259);
25182 -- if p_reuse_object_flag = 'Y' then
25183 if c_OTP_min_max_dates%found then
25184 -- cursor to find the object
25185 open c_find_OTP_in_target( l_min_esd,l_max_eed,
25186 p_target_business_group_id, nvl(l_optip_id, -999) ) ;
25187 fetch c_find_OTP_in_target into l_new_value ;
25188 if c_find_OTP_in_target%found then
25189 --
25190 --TEMPIK
25191 l_dt_rec_found := dt_api.check_min_max_dates
25192 (p_base_table_name => 'BEN_OPTIP_F',
25193 p_base_key_column => 'OPTIP_ID',
25194 p_base_key_value => l_new_value,
25195 p_from_date => l_min_esd,
25196 p_to_date => l_max_eed );
25197 if l_dt_rec_found THEN
25198 --END TEMPIK
25199 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
25200 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
25201 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OPTIP_ID' ;
25202 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_OTP_unique.information1 ;
25203 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
25204 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
25205 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;
25206 --
25207 -- 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) ;
25208 --
25209 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25210 end if ;
25211 --
25212 l_object_found_in_target := true ;
25213 --TEMPIK
25214 end if; -- l_dt_rec_found
25215 --END TEMPIK
25216 end if;
25217 close c_find_OTP_in_target ;
25218 --
25219 end if;
25220 -- end if ;
25221 --
25222 close c_OTP_min_max_dates ;
25223 -- NEVER CREATE HERE. THIS IS DONE IN BEN_OIPL_F, BEN_PLIP_F, BEN_OPT_F and BEN_PTIP_F apis.
25224 /*
25225 if not l_object_found_in_target then
25226 --
25227 l_current_pk_id := r_OTP.information1;
25228 --
25229 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
25230 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
25231 --
25232 if l_current_pk_id = l_prev_pk_id then
25233 --
25234 l_first_rec := false ;
25235 --
25236 else
25237 --
25238 l_first_rec := true ;
25239 --
25240 end if ;
25241 --
25242
25243 l_effective_date := r_OTP.information2;
25244 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25245 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
25246 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
25247 end if;
25248
25249 if l_first_rec then
25250 -- Call Create routine.
25251 hr_utility.set_location(' BEN_OPTIP_F CREATE_OPT_PLTYP_IN_PGM ',20);
25252 BEN_OPT_PLTYP_IN_PGM_API.CREATE_OPT_PLTYP_IN_PGM(
25253 --
25254 P_VALIDATE => false
25255 ,P_EFFECTIVE_DATE => l_effective_date
25256 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25257 --
25258 ,P_CMBN_PTIP_OPT_ID => l_CMBN_PTIP_OPT_ID
25259 ,P_OPTIP_ID => l_optip_id
25260 ,P_OPT_ID => l_OPT_ID
25261 ,P_OTP_ATTRIBUTE1 => r_OTP.INFORMATION111
25262 ,P_OTP_ATTRIBUTE10 => r_OTP.INFORMATION120
25263 ,P_OTP_ATTRIBUTE11 => r_OTP.INFORMATION121
25264 ,P_OTP_ATTRIBUTE12 => r_OTP.INFORMATION122
25265 ,P_OTP_ATTRIBUTE13 => r_OTP.INFORMATION123
25266 ,P_OTP_ATTRIBUTE14 => r_OTP.INFORMATION124
25267 ,P_OTP_ATTRIBUTE15 => r_OTP.INFORMATION125
25268 ,P_OTP_ATTRIBUTE16 => r_OTP.INFORMATION126
25269 ,P_OTP_ATTRIBUTE17 => r_OTP.INFORMATION127
25270 ,P_OTP_ATTRIBUTE18 => r_OTP.INFORMATION128
25271 ,P_OTP_ATTRIBUTE19 => r_OTP.INFORMATION129
25272 ,P_OTP_ATTRIBUTE2 => r_OTP.INFORMATION112
25273 ,P_OTP_ATTRIBUTE20 => r_OTP.INFORMATION130
25274 ,P_OTP_ATTRIBUTE21 => r_OTP.INFORMATION131
25275 ,P_OTP_ATTRIBUTE22 => r_OTP.INFORMATION132
25276 ,P_OTP_ATTRIBUTE23 => r_OTP.INFORMATION133
25277 ,P_OTP_ATTRIBUTE24 => r_OTP.INFORMATION134
25278 ,P_OTP_ATTRIBUTE25 => r_OTP.INFORMATION135
25279 ,P_OTP_ATTRIBUTE26 => r_OTP.INFORMATION136
25280 ,P_OTP_ATTRIBUTE27 => r_OTP.INFORMATION137
25281 ,P_OTP_ATTRIBUTE28 => r_OTP.INFORMATION138
25282 ,P_OTP_ATTRIBUTE29 => r_OTP.INFORMATION139
25283 ,P_OTP_ATTRIBUTE3 => r_OTP.INFORMATION113
25284 ,P_OTP_ATTRIBUTE30 => r_OTP.INFORMATION140
25285 ,P_OTP_ATTRIBUTE4 => r_OTP.INFORMATION114
25286 ,P_OTP_ATTRIBUTE5 => r_OTP.INFORMATION115
25287 ,P_OTP_ATTRIBUTE6 => r_OTP.INFORMATION116
25288 ,P_OTP_ATTRIBUTE7 => r_OTP.INFORMATION117
25289 ,P_OTP_ATTRIBUTE8 => r_OTP.INFORMATION118
25290 ,P_OTP_ATTRIBUTE9 => r_OTP.INFORMATION119
25291 ,P_OTP_ATTRIBUTE_CATEGORY => r_OTP.INFORMATION110
25292 ,P_PGM_ID => l_PGM_ID
25293 ,P_PL_TYP_ID => l_PL_TYP_ID
25294 ,P_PTIP_ID => l_PTIP_ID
25295 --
25296 ,P_EFFECTIVE_START_DATE => l_effective_start_date
25297 ,P_EFFECTIVE_END_DATE => l_effective_end_date
25298 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
25299 );
25300 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
25301 -- Update all relevent cer records with new pk_id
25302 hr_utility.set_location('Before plsql table ',222);
25303 hr_utility.set_location('new_value id '||l_optip_id,222);
25304 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'OPTIP_ID' ;
25305 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_OTP.information1 ;
25306 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_OPTIP_ID ;
25307 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
25308 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;
25309 hr_utility.set_location('After plsql table ',222);
25310 --
25311 -- 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 ) ;
25312 --
25313 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25314 --
25315 else
25316 --
25317 -- Call Update routine for the pk_id created in prev run .
25318 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
25319 hr_utility.set_location(' BEN_OPTIP_F UPDATE_OPT_PLTYP_IN_PGM ',30);
25320 BEN_OPT_PLTYP_IN_PGM_API.UPDATE_OPT_PLTYP_IN_PGM(
25321 --
25322 P_VALIDATE => false
25323 ,P_EFFECTIVE_DATE => l_effective_date
25324 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25325 --
25326 ,P_CMBN_PTIP_OPT_ID => l_CMBN_PTIP_OPT_ID
25327 ,P_OPTIP_ID => l_optip_id
25328 ,P_OPT_ID => l_OPT_ID
25329 ,P_OTP_ATTRIBUTE1 => r_OTP.INFORMATION111
25330 ,P_OTP_ATTRIBUTE10 => r_OTP.INFORMATION120
25331 ,P_OTP_ATTRIBUTE11 => r_OTP.INFORMATION121
25332 ,P_OTP_ATTRIBUTE12 => r_OTP.INFORMATION122
25333 ,P_OTP_ATTRIBUTE13 => r_OTP.INFORMATION123
25334 ,P_OTP_ATTRIBUTE14 => r_OTP.INFORMATION124
25335 ,P_OTP_ATTRIBUTE15 => r_OTP.INFORMATION125
25336 ,P_OTP_ATTRIBUTE16 => r_OTP.INFORMATION126
25337 ,P_OTP_ATTRIBUTE17 => r_OTP.INFORMATION127
25338 ,P_OTP_ATTRIBUTE18 => r_OTP.INFORMATION128
25339 ,P_OTP_ATTRIBUTE19 => r_OTP.INFORMATION129
25340 ,P_OTP_ATTRIBUTE2 => r_OTP.INFORMATION112
25341 ,P_OTP_ATTRIBUTE20 => r_OTP.INFORMATION130
25342 ,P_OTP_ATTRIBUTE21 => r_OTP.INFORMATION131
25343 ,P_OTP_ATTRIBUTE22 => r_OTP.INFORMATION132
25344 ,P_OTP_ATTRIBUTE23 => r_OTP.INFORMATION133
25345 ,P_OTP_ATTRIBUTE24 => r_OTP.INFORMATION134
25346 ,P_OTP_ATTRIBUTE25 => r_OTP.INFORMATION135
25347 ,P_OTP_ATTRIBUTE26 => r_OTP.INFORMATION136
25348 ,P_OTP_ATTRIBUTE27 => r_OTP.INFORMATION137
25349 ,P_OTP_ATTRIBUTE28 => r_OTP.INFORMATION138
25350 ,P_OTP_ATTRIBUTE29 => r_OTP.INFORMATION139
25351 ,P_OTP_ATTRIBUTE3 => r_OTP.INFORMATION113
25352 ,P_OTP_ATTRIBUTE30 => r_OTP.INFORMATION140
25353 ,P_OTP_ATTRIBUTE4 => r_OTP.INFORMATION114
25354 ,P_OTP_ATTRIBUTE5 => r_OTP.INFORMATION115
25355 ,P_OTP_ATTRIBUTE6 => r_OTP.INFORMATION116
25356 ,P_OTP_ATTRIBUTE7 => r_OTP.INFORMATION117
25357 ,P_OTP_ATTRIBUTE8 => r_OTP.INFORMATION118
25358 ,P_OTP_ATTRIBUTE9 => r_OTP.INFORMATION119
25359 ,P_OTP_ATTRIBUTE_CATEGORY => r_OTP.INFORMATION110
25360 ,P_PGM_ID => l_PGM_ID
25361 ,P_PL_TYP_ID => l_PL_TYP_ID
25362 ,P_PTIP_ID => l_PTIP_ID
25363 --
25364 ,P_EFFECTIVE_START_DATE => l_effective_start_date
25365 ,P_EFFECTIVE_END_DATE => l_effective_end_date
25366 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
25367 ,P_DATETRACK_MODE => hr_api.g_update
25368 );
25369 --
25370 end if;
25371 --
25372 -- Delete the row if it is end dated.
25373 --
25374 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
25375 trunc(l_max_eed) = r_OTP.information3) then
25376 --
25377 BEN_OPT_PLTYP_IN_PGM_API.delete_OPT_PLTYP_IN_PGM(
25378 --
25379 p_validate => false
25380 ,p_optip_id => l_optip_id
25381 ,p_effective_start_date => l_effective_start_date
25382 ,p_effective_end_date => l_effective_end_date
25383 ,p_object_version_number => l_object_version_number
25384 ,p_effective_date => l_max_eed
25385 ,p_datetrack_mode => hr_api.g_delete
25386 --
25387 );
25388 --
25389 end if;
25390 --
25391 l_prev_pk_id := l_current_pk_id ;
25392 --
25393 end if;
25394 --
25395 */
25396 end if;
25397 --
25398 end loop;
25399 --
25400 exception when others then
25401 --
25402 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'OTP',r_otp.information5 );
25403 --
25404 end create_OTP_rows;
25405 --
25406 ---------------------------------------------------------------
25407 ----------------------< create_PTY_rows >-----------------------
25408 ---------------------------------------------------------------
25409 --
25410 procedure create_PTY_rows
25411 (
25412 p_validate in number default 0
25413 ,p_copy_entity_txn_id in number
25414 ,p_effective_date in date
25415 ,p_prefix_suffix_text in varchar2 default null
25416 ,p_reuse_object_flag in varchar2 default null
25417 ,p_target_business_group_id in varchar2 default null
25418 ,p_prefix_suffix_cd in varchar2 default null
25419 ) is
25420 --
25421 l_PL_PCP_ID number;
25422 l_GNDR_ALWD_CD ben_pl_pcp_typ.gndr_alwd_cd%type;
25423 l_MAX_AGE ben_pl_pcp_typ.max_age%type;
25424 l_MIN_AGE ben_pl_pcp_typ.min_age%type;
25425 l_PCP_TYP_CD ben_pl_pcp_typ.pcp_typ_cd%type;
25426
25427 cursor c_unique_PTY(l_table_alias varchar2) is
25428 select distinct cpe.information1,
25429 cpe.information2,
25430 cpe.information3,
25431 cpe.table_route_id
25432 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
25433 pqh_table_route tr
25434 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25435 and cpe.table_route_id = tr.table_route_id
25436 -- and tr.where_clause = l_BEN_PL_PCP_TYP
25437 and tr.table_alias = l_table_alias
25438 and cpe.number_of_copies = 1 -- ADDITION
25439 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
25440 order by information1, information2; --added for bug: 5151945
25441 --
25442 --
25443 cursor c_PTY_min_max_dates(c_table_route_id number,
25444 c_information1 number) is
25445 select
25446 min(cpe.information2) min_esd,
25447 max(cpe.information3) min_eed
25448 from ben_copy_entity_results cpe
25449 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25450 and cpe.table_route_id = c_table_route_id
25451 and cpe.information1 = c_information1 ;
25452 --
25453 cursor c_PTY(c_table_route_id number,
25454 c_information1 number,
25455 c_information2 date,
25456 c_information3 date ) is
25457 select
25458 cpe.*
25459 from ben_copy_entity_results cpe
25460 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25461 and cpe.table_route_id = c_table_route_id
25462 and cpe.information1 = c_information1
25463 and rownum = 1 ;
25464 -- Date Track target record
25465 cursor c_find_PTY_in_target(
25466 c_effective_start_date date,
25467 c_effective_end_date date,
25468 c_business_group_id number,
25469 c_new_pk_id number) is
25470 select
25471 PTY.pl_pcp_typ_id new_value
25472 from BEN_PL_PCP_TYP PTY
25473 where
25474 PTY.PL_PCP_ID = l_PL_PCP_ID and
25475 NVL(PTY.GNDR_ALWD_CD,-999) = NVL(l_GNDR_ALWD_CD,-999) and
25476 NVL(PTY.MAX_AGE,-999) = NVL(l_MAX_AGE,-999) and
25477 NVL(PTY.MIN_AGE,-999) = NVL(l_MIN_AGE,-999) and
25478 PTY.PCP_TYP_CD = l_PCP_TYP_CD and
25479 PTY.business_group_id = c_business_group_id
25480 and PTY.pl_pcp_typ_id <> c_new_pk_id
25481 ;
25482 --
25483 --cursor to check the pcp_rpstry_flag
25484 cursor c_rpstry_flag(c_pl_pcp_id in number) is
25485 select pcp_rpstry_flag
25486 from ben_pl_pcp
25487 Where pl_pcp_id = c_pl_pcp_id;
25488
25489 l_rpstry_flag ben_pl_pcp.pcp_rpstry_flag%type;
25490 --
25491 --UPD START
25492 --
25493 l_update boolean := false ;
25494 l_datetrack_mode varchar2(80) := hr_api.g_update;
25495 l_process_date date;
25496 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
25497 --
25498 --UPD END
25499 l_current_pk_id number := null ;
25500 l_prev_pk_id number := null ;
25501 l_first_rec boolean := true ;
25502 r_PTY c_PTY%rowtype;
25503 l_pl_pcp_typ_id number ;
25504 l_object_version_number number ;
25505 l_effective_start_date date ;
25506 l_effective_end_date date ;
25507 l_prefix pqh_copy_entity_attribs.information1%type := null;
25508 l_suffix pqh_copy_entity_attribs.information1%type := null;
25509 l_new_value number(15);
25510 l_object_found_in_target boolean := false ;
25511 l_min_esd date;
25512 l_max_eed date;
25513 --
25514 begin
25515 -- Initialization
25516 l_object_found_in_target := false ;
25517 -- End Initialization
25518 -- Derive the prefix - sufix
25519 if p_prefix_suffix_cd = 'PREFIX' then
25520 l_prefix := p_prefix_suffix_text ;
25521 elsif p_prefix_suffix_cd = 'SUFFIX' then
25522 l_suffix := p_prefix_suffix_text ;
25523 else
25524 l_prefix := null ;
25525 l_suffix := null ;
25526 end if ;
25527 -- End Prefix Sufix derivation
25528 for r_PTY_unique in c_unique_PTY('PTY') loop
25529 --
25530 hr_utility.set_location(' r_PTY_unique.table_route_id '||r_PTY_unique.table_route_id,10);
25531 hr_utility.set_location(' r_PTY_unique.information1 '||r_PTY_unique.information1,10);
25532 hr_utility.set_location( 'r_PTY_unique.information2 '||r_PTY_unique.information2,10);
25533 hr_utility.set_location( 'r_PTY_unique.information3 '||r_PTY_unique.information3,10);
25534 -- If reuse objects flag is 'Y' then check for the object in the target business group
25535 -- if found insert the record into PLSql table and exit the loop else try create the
25536 -- object in the target business group
25537 --
25538 l_object_found_in_target := false ;
25539 l_min_esd := null ;
25540 l_max_eed := null ;
25541 --
25542 open c_PTY(r_PTY_unique.table_route_id,
25543 r_PTY_unique.information1,
25544 r_PTY_unique.information2,
25545 r_PTY_unique.information3 ) ;
25546 --
25547 fetch c_PTY into r_PTY ;
25548 --
25549 close c_PTY ;
25550 --
25551 --UPD START
25552 --
25553 l_update := false;
25554 l_process_date := p_effective_date;
25555 l_dml_operation:= r_PTY_unique.dml_operation ;
25556 --
25557 --UPD END
25558 l_PL_PCP_ID := get_fk('PL_PCP_ID', r_PTY.INFORMATION257,l_dml_operation);
25559 l_GNDR_ALWD_CD := r_PTY.INFORMATION12;
25560 l_MAX_AGE := r_PTY.INFORMATION294;
25561 l_MIN_AGE := r_PTY.INFORMATION293;
25562 l_PCP_TYP_CD := r_PTY.INFORMATION11;
25563
25564 open c_rpstry_flag(l_pl_pcp_id);
25565 fetch c_rpstry_flag into l_rpstry_flag;
25566 close c_rpstry_flag;
25567
25568
25569 if l_rpstry_flag = 'Y' then -- create PTY rows only if the Repository flag is selected in ben_pl_pcp
25570 --UPD START
25571 --
25572 if l_dml_operation = 'UPDATE' then
25573 --
25574 l_update := true;
25575 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
25576 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
25577 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_PCP_TYP_ID' ;
25578 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PTY_unique.information1 ;
25579 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PTY_unique.information1 ;
25580 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
25581 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;
25582 --
25583 -- 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
25584 --
25585 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25586 --
25587 --DOUBT log_data('PTY',l_new_value,l_prefix || r_PTY_unique.name|| l_suffix,'REUSED');
25588 --
25589 end if ;
25590 l_PL_PCP_TYP_ID := r_PTY_unique.information1 ;
25591 l_object_version_number := r_PTY.information265 ;
25592 hr_utility.set_location( 'found record for update',10);
25593 --
25594 else
25595 --
25596 --UPD END
25597
25598 if p_reuse_object_flag = 'Y' then
25599 -- cursor to find the object
25600 open c_find_PTY_in_target( r_PTY_unique.information2 ,l_max_eed,
25601 p_target_business_group_id, nvl(l_pl_pcp_typ_id, -999) ) ;
25602 fetch c_find_PTY_in_target into l_new_value ;
25603 if c_find_PTY_in_target%found then
25604 --
25605 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
25606 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
25607 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_PCP_TYP_ID' ;
25608 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PTY_unique.information1 ;
25609 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
25610 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
25611 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;
25612 --
25613 -- 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) ;
25614 --
25615 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25616 end if ;
25617 --
25618 l_object_found_in_target := true ;
25619 end if;
25620 close c_find_PTY_in_target ;
25621 --
25622 end if ;
25623 --
25624 end if; --if p_dml_operation
25625 --
25626 if not l_object_found_in_target OR l_update then
25627
25628 --
25629 l_current_pk_id := r_PTY.information1;
25630 --
25631 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
25632 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
25633 --
25634 if l_current_pk_id = l_prev_pk_id then
25635 --
25636 l_first_rec := false ;
25637 --
25638 else
25639 --
25640 l_first_rec := true ;
25641 --
25642 end if ;
25643 --
25644 if l_first_rec and not l_update then
25645 -- Call Create routine.
25646 hr_utility.set_location(' BEN_PL_PCP_TYP CREATE_PL_CARE_PRVDR_TYP ',20);
25647 BEN_PL_CARE_PRVDR_TYP_API.CREATE_PL_CARE_PRVDR_TYP(
25648 --
25649 P_VALIDATE => false
25650 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
25651 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25652 --
25653 ,P_GNDR_ALWD_CD => r_PTY.INFORMATION12
25654 ,P_MAX_AGE => r_PTY.INFORMATION294
25655 ,P_MIN_AGE => r_PTY.INFORMATION293
25656 ,P_PCP_TYP_CD => r_PTY.INFORMATION11
25657 ,P_PL_PCP_ID => l_PL_PCP_ID
25658 ,P_PL_PCP_TYP_ID => l_pl_pcp_typ_id
25659 ,P_PTY_ATTRIBUTE1 => r_PTY.INFORMATION111
25660 ,P_PTY_ATTRIBUTE10 => r_PTY.INFORMATION120
25661 ,P_PTY_ATTRIBUTE11 => r_PTY.INFORMATION121
25662 ,P_PTY_ATTRIBUTE12 => r_PTY.INFORMATION122
25663 ,P_PTY_ATTRIBUTE13 => r_PTY.INFORMATION123
25664 ,P_PTY_ATTRIBUTE14 => r_PTY.INFORMATION124
25665 ,P_PTY_ATTRIBUTE15 => r_PTY.INFORMATION125
25666 ,P_PTY_ATTRIBUTE16 => r_PTY.INFORMATION126
25667 ,P_PTY_ATTRIBUTE17 => r_PTY.INFORMATION127
25668 ,P_PTY_ATTRIBUTE18 => r_PTY.INFORMATION128
25669 ,P_PTY_ATTRIBUTE19 => r_PTY.INFORMATION129
25670 ,P_PTY_ATTRIBUTE2 => r_PTY.INFORMATION112
25671 ,P_PTY_ATTRIBUTE20 => r_PTY.INFORMATION130
25672 ,P_PTY_ATTRIBUTE21 => r_PTY.INFORMATION131
25673 ,P_PTY_ATTRIBUTE22 => r_PTY.INFORMATION132
25674 ,P_PTY_ATTRIBUTE23 => r_PTY.INFORMATION133
25675 ,P_PTY_ATTRIBUTE24 => r_PTY.INFORMATION134
25676 ,P_PTY_ATTRIBUTE25 => r_PTY.INFORMATION135
25677 ,P_PTY_ATTRIBUTE26 => r_PTY.INFORMATION136
25678 ,P_PTY_ATTRIBUTE27 => r_PTY.INFORMATION137
25679 ,P_PTY_ATTRIBUTE28 => r_PTY.INFORMATION138
25680 ,P_PTY_ATTRIBUTE29 => r_PTY.INFORMATION139
25681 ,P_PTY_ATTRIBUTE3 => r_PTY.INFORMATION113
25682 ,P_PTY_ATTRIBUTE30 => r_PTY.INFORMATION140
25683 ,P_PTY_ATTRIBUTE4 => r_PTY.INFORMATION114
25684 ,P_PTY_ATTRIBUTE5 => r_PTY.INFORMATION115
25685 ,P_PTY_ATTRIBUTE6 => r_PTY.INFORMATION116
25686 ,P_PTY_ATTRIBUTE7 => r_PTY.INFORMATION117
25687 ,P_PTY_ATTRIBUTE8 => r_PTY.INFORMATION118
25688 ,P_PTY_ATTRIBUTE9 => r_PTY.INFORMATION119
25689 ,P_PTY_ATTRIBUTE_CATEGORY => r_PTY.INFORMATION110
25690 --
25691 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
25692 );
25693 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
25694 -- Update all relevent cer records with new pk_id
25695 hr_utility.set_location('Before plsql table ',222);
25696 hr_utility.set_location('new_value id '||l_pl_pcp_typ_id,222);
25697 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_PCP_TYP_ID' ;
25698 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PTY.information1 ;
25699 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PL_PCP_TYP_ID ;
25700 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
25701 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;
25702 hr_utility.set_location('After plsql table ',222);
25703 --
25704 -- 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 ) ;
25705 --
25706 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25707 --
25708 elsif l_update then
25709 BEN_PL_CARE_PRVDR_TYP_API.UPDATE_PL_CARE_PRVDR_TYP(
25710 --
25711 P_VALIDATE => false
25712 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
25713 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
25714 --
25715 ,P_GNDR_ALWD_CD => r_PTY.INFORMATION12
25716 ,P_MAX_AGE => r_PTY.INFORMATION294
25717 ,P_MIN_AGE => r_PTY.INFORMATION293
25718 ,P_PCP_TYP_CD => r_PTY.INFORMATION11
25719 ,P_PL_PCP_ID => l_PL_PCP_ID
25720 ,P_PL_PCP_TYP_ID => l_pl_pcp_typ_id
25721 ,P_PTY_ATTRIBUTE1 => r_PTY.INFORMATION111
25722 ,P_PTY_ATTRIBUTE10 => r_PTY.INFORMATION120
25723 ,P_PTY_ATTRIBUTE11 => r_PTY.INFORMATION121
25724 ,P_PTY_ATTRIBUTE12 => r_PTY.INFORMATION122
25725 ,P_PTY_ATTRIBUTE13 => r_PTY.INFORMATION123
25726 ,P_PTY_ATTRIBUTE14 => r_PTY.INFORMATION124
25727 ,P_PTY_ATTRIBUTE15 => r_PTY.INFORMATION125
25728 ,P_PTY_ATTRIBUTE16 => r_PTY.INFORMATION126
25729 ,P_PTY_ATTRIBUTE17 => r_PTY.INFORMATION127
25730 ,P_PTY_ATTRIBUTE18 => r_PTY.INFORMATION128
25731 ,P_PTY_ATTRIBUTE19 => r_PTY.INFORMATION129
25732 ,P_PTY_ATTRIBUTE2 => r_PTY.INFORMATION112
25733 ,P_PTY_ATTRIBUTE20 => r_PTY.INFORMATION130
25734 ,P_PTY_ATTRIBUTE21 => r_PTY.INFORMATION131
25735 ,P_PTY_ATTRIBUTE22 => r_PTY.INFORMATION132
25736 ,P_PTY_ATTRIBUTE23 => r_PTY.INFORMATION133
25737 ,P_PTY_ATTRIBUTE24 => r_PTY.INFORMATION134
25738 ,P_PTY_ATTRIBUTE25 => r_PTY.INFORMATION135
25739 ,P_PTY_ATTRIBUTE26 => r_PTY.INFORMATION136
25740 ,P_PTY_ATTRIBUTE27 => r_PTY.INFORMATION137
25741 ,P_PTY_ATTRIBUTE28 => r_PTY.INFORMATION138
25742 ,P_PTY_ATTRIBUTE29 => r_PTY.INFORMATION139
25743 ,P_PTY_ATTRIBUTE3 => r_PTY.INFORMATION113
25744 ,P_PTY_ATTRIBUTE30 => r_PTY.INFORMATION140
25745 ,P_PTY_ATTRIBUTE4 => r_PTY.INFORMATION114
25746 ,P_PTY_ATTRIBUTE5 => r_PTY.INFORMATION115
25747 ,P_PTY_ATTRIBUTE6 => r_PTY.INFORMATION116
25748 ,P_PTY_ATTRIBUTE7 => r_PTY.INFORMATION117
25749 ,P_PTY_ATTRIBUTE8 => r_PTY.INFORMATION118
25750 ,P_PTY_ATTRIBUTE9 => r_PTY.INFORMATION119
25751 ,P_PTY_ATTRIBUTE_CATEGORY => r_PTY.INFORMATION110
25752 --
25753 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
25754 );
25755 end if;
25756 --
25757 l_prev_pk_id := l_current_pk_id ;
25758 --
25759 end if;
25760 --
25761 end if;
25762 --
25763 end loop;
25764 --
25765 exception when others then
25766 --
25767 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PTY',r_pty.information5 );
25768 --
25769 end create_PTY_rows;
25770
25771 --
25772 ---------------------------------------------------------------
25773 ----------------------< create_PRP_rows >-----------------------
25774 ---------------------------------------------------------------
25775 --
25776 procedure create_PRP_rows
25777 (
25778 p_validate in number default 0
25779 ,p_copy_entity_txn_id in number
25780 ,p_effective_date in date
25781 ,p_prefix_suffix_text in varchar2 default null
25782 ,p_reuse_object_flag in varchar2 default null
25783 ,p_target_business_group_id in varchar2 default null
25784 ,p_prefix_suffix_cd in varchar2 default null
25785 ) is
25786 --
25787 l_PL_REGY_BOD_ID number;
25788
25789 l_PL_REGY_PRPS_CD ben_pl_regy_prp_f.pl_regy_prps_cd%type;
25790 cursor c_unique_PRP(l_table_alias varchar2) is
25791 select distinct cpe.information1,
25792 cpe.information2,
25793 cpe.information3,
25794 cpe.table_route_id
25795 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
25796 pqh_table_route tr
25797 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25798 and cpe.table_route_id = tr.table_route_id
25799 -- and tr.where_clause = l_BEN_PL_REGY_PRP_F
25800 and tr.table_alias = l_table_alias
25801 and cpe.number_of_copies = 1 -- ADDITION
25802 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
25803 order by information1, information2; --added for bug: 5151945
25804 --
25805 --
25806 cursor c_PRP_min_max_dates(c_table_route_id number,
25807 c_information1 number) is
25808 select
25809 min(cpe.information2) min_esd,
25810 max(cpe.information3) min_eed
25811 from ben_copy_entity_results cpe
25812 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25813 and cpe.table_route_id = c_table_route_id
25814 and cpe.information1 = c_information1 ;
25815 --
25816 cursor c_PRP(c_table_route_id number,
25817 c_information1 number,
25818 c_information2 date,
25819 c_information3 date ) is
25820 select
25821 cpe.*
25822 from ben_copy_entity_results cpe
25823 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
25824 and cpe.table_route_id = c_table_route_id
25825 and cpe.information1 = c_information1
25826 and cpe.information2 = c_information2
25827 and cpe.information3 = c_information3
25828 and rownum = 1 ;
25829 -- Date Track target record
25830 cursor c_find_PRP_in_target(
25831 c_effective_start_date date,
25832 c_effective_end_date date,
25833 c_business_group_id number,
25834 c_new_pk_id number) is
25835 select
25836 PRP.pl_regy_prps_id new_value
25837 from BEN_PL_REGY_PRP_F PRP
25838 where
25839 PRP.PL_REGY_BOD_ID = l_PL_REGY_BOD_ID and
25840 PRP.PL_REGY_PRPS_CD = l_PL_REGY_PRPS_CD and
25841 PRP.business_group_id = c_business_group_id
25842 and PRP.pl_regy_prps_id <> c_new_pk_id
25843 --TEMPIK
25844 and c_effective_start_date between effective_start_date
25845 and effective_end_date ;
25846 --END TEMPIK
25847 /*
25848 and exists ( select null
25849 from BEN_PL_REGY_PRP_F PRP1
25850 where
25851 PRP1.PL_REGY_BOD_ID = l_PL_REGY_BOD_ID and
25852 PRP1.PL_REGY_PRPS_CD = l_PL_REGY_PRPS_CD and
25853 PRP1.business_group_id = c_business_group_id
25854 and PRP1.effective_start_date <= c_effective_start_date )
25855 and exists ( select null
25856 from BEN_PL_REGY_PRP_F PRP2
25857 where
25858 PRP2.PL_REGY_BOD_ID = l_PL_REGY_BOD_ID and
25859 PRP2.PL_REGY_PRPS_CD = l_PL_REGY_PRPS_CD and
25860 PRP2.business_group_id = c_business_group_id
25861 and PRP2.effective_end_date >= c_effective_end_date )
25862 ;
25863 */
25864 --
25865 --UPD START
25866 --
25867 l_update boolean := false ;
25868 l_datetrack_mode varchar2(80) := hr_api.g_update;
25869 l_process_date date;
25870 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
25871 --
25872 --UPD END
25873 l_current_pk_id number := null ;
25874 l_prev_pk_id number := null ;
25875 l_first_rec boolean := true ;
25876 r_PRP c_PRP%rowtype;
25877 l_pl_regy_prps_id number ;
25878 l_object_version_number number ;
25879 l_effective_start_date date ;
25880 l_effective_end_date date ;
25881 l_prefix pqh_copy_entity_attribs.information1%type := null;
25882 l_suffix pqh_copy_entity_attribs.information1%type := null;
25883 l_new_value number(15);
25884 l_object_found_in_target boolean := false ;
25885 l_min_esd date;
25886 l_max_eed date;
25887 l_effective_date date;
25888 --TEMPIK
25889 l_dt_rec_found boolean ;
25890 --END TEMPIK
25891 --
25892 begin
25893 -- Initialization
25894 l_object_found_in_target := false ;
25895 -- End Initialization
25896 -- Derive the prefix - sufix
25897 if p_prefix_suffix_cd = 'PREFIX' then
25898 l_prefix := p_prefix_suffix_text ;
25899 elsif p_prefix_suffix_cd = 'SUFFIX' then
25900 l_suffix := p_prefix_suffix_text ;
25901 else
25902 l_prefix := null ;
25903 l_suffix := null ;
25904 end if ;
25905 -- End Prefix Sufix derivation
25906 for r_PRP_unique in c_unique_PRP('PRP') loop
25907
25908 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
25909 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25910 r_PRP_unique.information3 >=
25911 ben_pd_copy_to_ben_one.g_copy_effective_date)
25912 ) then
25913 --
25914 hr_utility.set_location(' r_PRP_unique.table_route_id '||r_PRP_unique.table_route_id,10);
25915 hr_utility.set_location(' r_PRP_unique.information1 '||r_PRP_unique.information1,10);
25916 hr_utility.set_location( 'r_PRP_unique.information2 '||r_PRP_unique.information2,10);
25917 hr_utility.set_location( 'r_PRP_unique.information3 '||r_PRP_unique.information3,10);
25918 -- If reuse objects flag is 'Y' then check for the object in the target business group
25919 -- if found insert the record into PLSql table and exit the loop else try create the
25920 -- object in the target business group
25921 --
25922 l_object_found_in_target := false ;
25923 --UPD START
25924 open c_PRP(r_PRP_unique.table_route_id,
25925 r_PRP_unique.information1,
25926 r_PRP_unique.information2,
25927 r_PRP_unique.information3 ) ;
25928 --
25929 fetch c_PRP into r_PRP ;
25930 --
25931 close c_PRP ;
25932 --
25933 l_dml_operation:= r_PRP_unique.dml_operation ;
25934 l_PL_REGY_BOD_ID := get_fk('PL_REGY_BOD_ID', r_PRP.INFORMATION258,l_dml_operation );
25935 l_PL_REGY_PRPS_CD := r_PRP.information11;
25936 --
25937 l_update := false;
25938 l_process_date := p_effective_date;
25939 --
25940 if l_dml_operation = 'UPDATE' then
25941 --
25942 l_object_found_in_target := TRUE;
25943 --
25944 if l_process_date between r_PRP_unique.information2 and r_PRP_unique.information3 then
25945 l_update := true;
25946 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)
25947 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'
25948 then
25949 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_REGY_PRPS_ID' ;
25950 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PRP_unique.information1 ;
25951 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_PRP_unique.information1 ;
25952 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
25953 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;
25954 --
25955 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
25956 --
25957 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
25958 --
25959 --DOUBT log_data('PRP',l_new_value,l_prefix || r_PRP_unique.name|| l_suffix,'REUSED');
25960 --
25961 end if ;
25962 hr_utility.set_location( 'found record for update',10);
25963 --
25964 else
25965 --
25966 l_update := false;
25967 --
25968 end if;
25969 else
25970 --
25971 --UPD END
25972 l_min_esd := null ;
25973 l_max_eed := null ;
25974 open c_PRP_min_max_dates(r_PRP_unique.table_route_id, r_PRP_unique.information1 ) ;
25975 fetch c_PRP_min_max_dates into l_min_esd,l_max_eed ;
25976 --
25977
25978 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
25979 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
25980 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
25981 end if;
25982 l_min_esd := greatest(l_min_esd,r_PRP_unique.information2);
25983 /* open c_PRP(r_PRP_unique.table_route_id,
25984 r_PRP_unique.information1,
25985 r_PRP_unique.information2,
25986 r_PRP_unique.information3 ) ;
25987 --
25988 fetch c_PRP into r_PRP ;
25989 --
25990 close c_PRP ; */
25991 --
25992
25993 if l_PL_REGY_BOD_ID is null then
25994 close c_PRP_min_max_dates;
25995 else
25996 if p_reuse_object_flag = 'Y' then
25997 if c_PRP_min_max_dates%found then
25998 -- cursor to find the object
25999 open c_find_PRP_in_target( l_min_esd,l_max_eed,
26000 p_target_business_group_id, nvl(l_pl_regy_prps_id, -999) ) ;
26001 fetch c_find_PRP_in_target into l_new_value ;
26002 if c_find_PRP_in_target%found then
26003 --
26004 --TEMPIK
26005 l_dt_rec_found := dt_api.check_min_max_dates
26006 (p_base_table_name => 'BEN_PL_REGY_PRP_F', --bug 12558413
26007 p_base_key_column => 'PL_REGY_PRPS_ID',
26008 p_base_key_value => l_new_value,
26009 p_from_date => l_min_esd,
26010 p_to_date => l_max_eed );
26011 if l_dt_rec_found THEN
26012 --END TEMPIK
26013 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
26014 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
26015 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_REGY_PRPS_ID' ;
26016 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PRP_unique.information1 ;
26017 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
26018 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
26019 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;
26020 --
26021 -- 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) ;
26022 --
26023 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26024 end if ;
26025 --
26026 l_object_found_in_target := true ;
26027 --TEMPIK
26028 end if; -- l_dt_rec_found
26029 --END TEMPIK
26030 end if;
26031 close c_find_PRP_in_target ;
26032 --
26033 end if;
26034 end if ;
26035 --
26036 close c_PRP_min_max_dates ;
26037 end if; --if p_dml_operation
26038 --
26039 if not l_object_found_in_target OR l_update then
26040 --
26041 l_current_pk_id := r_PRP.information1;
26042 --
26043 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
26044 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
26045 --
26046 if l_current_pk_id = l_prev_pk_id then
26047 --
26048 l_first_rec := false ;
26049 --
26050 else
26051 --
26052 l_first_rec := true ;
26053 --
26054 end if ;
26055 --
26056
26057 l_effective_date := r_PRP.information2;
26058 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26059 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
26060 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
26061 end if;
26062
26063 if l_first_rec and not l_update then
26064 -- Call Create routine.
26065 hr_utility.set_location(' BEN_PL_REGY_PRP_F CREATE_REGULATORY_PURPOSE ',20);
26066 BEN_REGULATORY_PURPOSE_API.CREATE_REGULATORY_PURPOSE(
26067 --
26068 P_VALIDATE => false
26069 ,P_EFFECTIVE_DATE => l_effective_date
26070 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
26071 --
26072 ,P_PL_REGY_BOD_ID => l_PL_REGY_BOD_ID
26073 ,P_PL_REGY_PRPS_CD => r_PRP.INFORMATION11
26074 ,P_PL_REGY_PRPS_ID => l_PL_REGY_PRPS_ID
26075 ,P_PRP_ATTRIBUTE1 => r_PRP.INFORMATION111
26076 ,P_PRP_ATTRIBUTE10 => r_PRP.INFORMATION120
26077 ,P_PRP_ATTRIBUTE11 => r_PRP.INFORMATION121
26078 ,P_PRP_ATTRIBUTE12 => r_PRP.INFORMATION122
26079 ,P_PRP_ATTRIBUTE13 => r_PRP.INFORMATION123
26080 ,P_PRP_ATTRIBUTE14 => r_PRP.INFORMATION124
26081 ,P_PRP_ATTRIBUTE15 => r_PRP.INFORMATION125
26082 ,P_PRP_ATTRIBUTE16 => r_PRP.INFORMATION126
26083 ,P_PRP_ATTRIBUTE17 => r_PRP.INFORMATION127
26084 ,P_PRP_ATTRIBUTE18 => r_PRP.INFORMATION128
26085 ,P_PRP_ATTRIBUTE19 => r_PRP.INFORMATION129
26086 ,P_PRP_ATTRIBUTE2 => r_PRP.INFORMATION112
26087 ,P_PRP_ATTRIBUTE20 => r_PRP.INFORMATION130
26088 ,P_PRP_ATTRIBUTE21 => r_PRP.INFORMATION131
26089 ,P_PRP_ATTRIBUTE22 => r_PRP.INFORMATION132
26090 ,P_PRP_ATTRIBUTE23 => r_PRP.INFORMATION133
26091 ,P_PRP_ATTRIBUTE24 => r_PRP.INFORMATION134
26092 ,P_PRP_ATTRIBUTE25 => r_PRP.INFORMATION135
26093 ,P_PRP_ATTRIBUTE26 => r_PRP.INFORMATION136
26094 ,P_PRP_ATTRIBUTE27 => r_PRP.INFORMATION137
26095 ,P_PRP_ATTRIBUTE28 => r_PRP.INFORMATION138
26096 ,P_PRP_ATTRIBUTE29 => r_PRP.INFORMATION139
26097 ,P_PRP_ATTRIBUTE3 => r_PRP.INFORMATION113
26098 ,P_PRP_ATTRIBUTE30 => r_PRP.INFORMATION140
26099 ,P_PRP_ATTRIBUTE4 => r_PRP.INFORMATION114
26100 ,P_PRP_ATTRIBUTE5 => r_PRP.INFORMATION115
26101 ,P_PRP_ATTRIBUTE6 => r_PRP.INFORMATION116
26102 ,P_PRP_ATTRIBUTE7 => r_PRP.INFORMATION117
26103 ,P_PRP_ATTRIBUTE8 => r_PRP.INFORMATION118
26104 ,P_PRP_ATTRIBUTE9 => r_PRP.INFORMATION119
26105 ,P_PRP_ATTRIBUTE_CATEGORY => r_PRP.INFORMATION110
26106 --
26107 ,P_EFFECTIVE_START_DATE => l_effective_start_date
26108 ,P_EFFECTIVE_END_DATE => l_effective_end_date
26109 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
26110 );
26111 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
26112 -- Update all relevent cer records with new pk_id
26113 hr_utility.set_location('Before plsql table ',222);
26114 hr_utility.set_location('new_value id '||l_pl_regy_prps_id,222);
26115 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'PL_REGY_PRP_ID' ;
26116 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_PRP.information1 ;
26117 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_PL_REGY_PRPS_ID ;
26118 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
26119 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;
26120 hr_utility.set_location('After plsql table ',222);
26121 --
26122 -- 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 ) ;
26123 --
26124 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26125 --
26126 else
26127 --
26128 -- Call Update routine for the pk_id created in prev run .
26129 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
26130 hr_utility.set_location(' BEN_PL_REGY_PRP_F UPDATE_REGULATORY_PURPOSE ',30);
26131 --UPD START
26132 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
26133 --
26134 if l_update then
26135 --
26136 l_datetrack_mode := r_PRP.datetrack_mode ;
26137 --
26138 get_dt_modes(
26139 p_effective_date => l_process_date,
26140 p_effective_end_date => r_PRP.information3,
26141 p_effective_start_date => r_PRP.information2,
26142 p_dml_operation => r_PRP.dml_operation,
26143 p_datetrack_mode => l_datetrack_mode );
26144 -- p_update => l_update
26145 --
26146 l_effective_date := l_process_date;
26147 l_PL_REGY_PRPS_ID := r_PRP.information1;
26148 l_object_version_number := r_PRP.information265;
26149 --
26150 end if;
26151 --
26152 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
26153 --
26154 IF l_update OR l_dml_operation <> 'UPDATE' THEN
26155 --UPD END
26156 BEN_REGULATORY_PURPOSE_API.UPDATE_REGULATORY_PURPOSE(
26157 --
26158 P_VALIDATE => false
26159 ,P_EFFECTIVE_DATE => l_effective_date
26160 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
26161 --
26162 ,P_PL_REGY_BOD_ID => l_PL_REGY_BOD_ID
26163 ,P_PL_REGY_PRPS_CD => r_PRP.INFORMATION11
26164 ,P_PL_REGY_PRPS_ID => l_PL_REGY_PRPS_ID
26165 ,P_PRP_ATTRIBUTE1 => r_PRP.INFORMATION111
26166 ,P_PRP_ATTRIBUTE10 => r_PRP.INFORMATION120
26167 ,P_PRP_ATTRIBUTE11 => r_PRP.INFORMATION121
26168 ,P_PRP_ATTRIBUTE12 => r_PRP.INFORMATION122
26169 ,P_PRP_ATTRIBUTE13 => r_PRP.INFORMATION123
26170 ,P_PRP_ATTRIBUTE14 => r_PRP.INFORMATION124
26171 ,P_PRP_ATTRIBUTE15 => r_PRP.INFORMATION125
26172 ,P_PRP_ATTRIBUTE16 => r_PRP.INFORMATION126
26173 ,P_PRP_ATTRIBUTE17 => r_PRP.INFORMATION127
26174 ,P_PRP_ATTRIBUTE18 => r_PRP.INFORMATION128
26175 ,P_PRP_ATTRIBUTE19 => r_PRP.INFORMATION129
26176 ,P_PRP_ATTRIBUTE2 => r_PRP.INFORMATION112
26177 ,P_PRP_ATTRIBUTE20 => r_PRP.INFORMATION130
26178 ,P_PRP_ATTRIBUTE21 => r_PRP.INFORMATION131
26179 ,P_PRP_ATTRIBUTE22 => r_PRP.INFORMATION132
26180 ,P_PRP_ATTRIBUTE23 => r_PRP.INFORMATION133
26181 ,P_PRP_ATTRIBUTE24 => r_PRP.INFORMATION134
26182 ,P_PRP_ATTRIBUTE25 => r_PRP.INFORMATION135
26183 ,P_PRP_ATTRIBUTE26 => r_PRP.INFORMATION136
26184 ,P_PRP_ATTRIBUTE27 => r_PRP.INFORMATION137
26185 ,P_PRP_ATTRIBUTE28 => r_PRP.INFORMATION138
26186 ,P_PRP_ATTRIBUTE29 => r_PRP.INFORMATION139
26187 ,P_PRP_ATTRIBUTE3 => r_PRP.INFORMATION113
26188 ,P_PRP_ATTRIBUTE30 => r_PRP.INFORMATION140
26189 ,P_PRP_ATTRIBUTE4 => r_PRP.INFORMATION114
26190 ,P_PRP_ATTRIBUTE5 => r_PRP.INFORMATION115
26191 ,P_PRP_ATTRIBUTE6 => r_PRP.INFORMATION116
26192 ,P_PRP_ATTRIBUTE7 => r_PRP.INFORMATION117
26193 ,P_PRP_ATTRIBUTE8 => r_PRP.INFORMATION118
26194 ,P_PRP_ATTRIBUTE9 => r_PRP.INFORMATION119
26195 ,P_PRP_ATTRIBUTE_CATEGORY => r_PRP.INFORMATION110
26196 --
26197 ,P_EFFECTIVE_START_DATE => l_effective_start_date
26198 ,P_EFFECTIVE_END_DATE => l_effective_end_date
26199 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
26200 ,P_DATETRACK_MODE => l_datetrack_mode
26201 );
26202 --
26203 end if; -- l_update
26204 end if;
26205 --
26206 -- Delete the row if it is end dated.
26207 --
26208 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
26209 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
26210 trunc(l_max_eed) = r_PRP.information3) then
26211 --
26212 BEN_REGULATORY_PURPOSE_API.delete_REGULATORY_PURPOSE(
26213 --
26214 p_validate => false
26215 ,p_pl_regy_prps_id => l_pl_regy_prps_id
26216 ,p_effective_start_date => l_effective_start_date
26217 ,p_effective_end_date => l_effective_end_date
26218 ,p_object_version_number => l_object_version_number
26219 ,p_effective_date => l_max_eed
26220 ,p_datetrack_mode => hr_api.g_delete
26221 --
26222 );
26223 --
26224 end if;
26225 --
26226 l_prev_pk_id := l_current_pk_id ;
26227 --
26228 end if;
26229 --
26230 end if;
26231 --
26232 end if;
26233 --
26234 end loop;
26235 --
26236 exception when others then
26237 --
26238 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'PRP',r_prp.information5 );
26239 --
26240 end create_PRP_rows;
26241
26242 --
26243 ---------------------------------------------------------------
26244 ----------------------< create_BPP_rows >-----------------------
26245 ---------------------------------------------------------------
26246 --
26247 procedure create_BPP_rows
26248 (
26249 p_validate in number default 0
26250 ,p_copy_entity_txn_id in number
26251 ,p_effective_date in date
26252 ,p_prefix_suffix_text in varchar2 default null
26253 ,p_reuse_object_flag in varchar2 default null
26254 ,p_target_business_group_id in varchar2 default null
26255 ,p_prefix_suffix_cd in varchar2 default null
26256 ) is
26257 --
26258 l_CMBN_PLIP_ID number;
26259 l_CMBN_PTIP_ID number;
26260 l_CMBN_PTIP_OPT_ID number;
26261 l_COMP_LVL_FCTR_ID number;
26262 l_DFLT_EXCS_TRTMT_RL number;
26263 l_OIPLIP_ID number;
26264 l_PCT_RNDG_RL number;
26265 l_PGM_ID number;
26266 l_PLIP_ID number;
26267 l_PTIP_ID number;
26268 l_VAL_RNDG_RL number;
26269 --
26270 cursor c_unique_BPP(l_table_alias varchar2) is
26271 select distinct cpe.information1,
26272 cpe.information2,
26273 cpe.information3,
26274 cpe.INFORMATION170 name ,
26275 cpe.table_route_id
26276 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
26277 pqh_table_route tr
26278 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26279 and cpe.table_route_id = tr.table_route_id
26280 -- and tr.where_clause = l_BEN_BNFT_PRVDR_POOL_F
26281 and tr.table_alias = l_table_alias
26282 and cpe.number_of_copies = 1 --ADDITION
26283 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
26284 order by information1, information2; --added for bug: 5151945
26285 --
26286 --
26287 cursor c_BPP_min_max_dates(c_table_route_id number,
26288 c_information1 number) is
26289 select
26290 min(cpe.information2) min_esd,
26291 max(cpe.information3) min_eed
26292 from ben_copy_entity_results cpe
26293 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26294 and cpe.table_route_id = c_table_route_id
26295 and cpe.information1 = c_information1 ;
26296 --
26297 cursor c_BPP(c_table_route_id number,
26298 c_information1 number,
26299 c_information2 date,
26300 c_information3 date) is
26301 select
26302 cpe.*
26303 from ben_copy_entity_results cpe
26304 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26305 and cpe.table_route_id = c_table_route_id
26306 and cpe.information1 = c_information1
26307 and cpe.information2 = c_information2
26308 and cpe.information3 = c_information3
26309 and rownum = 1 ;
26310 -- Date Track target record
26311 cursor c_find_BPP_in_target( c_BPP_name varchar2,
26312 c_effective_start_date date,
26313 c_effective_end_date date,
26314 c_business_group_id number,
26315 c_new_pk_id number) is
26316 select
26317 BPP.bnft_prvdr_pool_id new_value
26318 from BEN_BNFT_PRVDR_POOL_F BPP
26319 where BPP.name = c_BPP_name
26320 and nvl(BPP.CMBN_PLIP_ID,-999) = nvl(l_CMBN_PLIP_ID,-999)
26321 and nvl(BPP.CMBN_PTIP_ID,-999) = nvl(l_CMBN_PTIP_ID,-999)
26322 and nvl(BPP.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999)
26323 and nvl(BPP.OIPLIP_ID,-999) = nvl(l_OIPLIP_ID,-999)
26324 and nvl(BPP.PGM_ID,-999) = nvl(l_PGM_ID,-999)
26325 and nvl(BPP.PLIP_ID,-999) = nvl(l_PLIP_ID,-999)
26326 and nvl(BPP.PTIP_ID,-999) = nvl(l_PTIP_ID,-999)
26327 and BPP.business_group_id = c_business_group_id
26328 and BPP.bnft_prvdr_pool_id <> c_new_pk_id
26329 --TEMPIK
26330 and c_effective_start_date between effective_start_date
26331 and effective_end_date ;
26332 --END TEMPIK
26333 --
26334 /* TEMPIK
26335 and exists ( select null
26336 from BEN_BNFT_PRVDR_POOL_F BPP1
26337 where BPP1.name = c_BPP_name
26338 and nvl(BPP1.CMBN_PLIP_ID,-999) = nvl(l_CMBN_PLIP_ID,-999)
26339 and nvl(BPP1.CMBN_PTIP_ID,-999) = nvl(l_CMBN_PTIP_ID,-999)
26340 and nvl(BPP1.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999)
26341 and nvl(BPP1.OIPLIP_ID,-999) = nvl(l_OIPLIP_ID,-999)
26342 and nvl(BPP1.PGM_ID,-999) = nvl(l_PGM_ID,-999)
26343 and nvl(BPP1.PLIP_ID,-999) = nvl(l_PLIP_ID,-999)
26344 and nvl(BPP1.PTIP_ID,-999) = nvl(l_PTIP_ID,-999)
26345 and BPP1.business_group_id = c_business_group_id
26346 and BPP1.effective_start_date <= c_effective_start_date )
26347 and exists ( select null
26348 from BEN_BNFT_PRVDR_POOL_F BPP2
26349 where BPP2.name = c_BPP_name
26350 and nvl(BPP2.CMBN_PLIP_ID,-999) = nvl(l_CMBN_PLIP_ID,-999)
26351 and nvl(BPP2.CMBN_PTIP_ID,-999) = nvl(l_CMBN_PTIP_ID,-999)
26352 and nvl(BPP2.CMBN_PTIP_OPT_ID,-999) = nvl(l_CMBN_PTIP_OPT_ID,-999)
26353 and nvl(BPP2.OIPLIP_ID,-999) = nvl(l_OIPLIP_ID,-999)
26354 and nvl(BPP2.PGM_ID,-999) = nvl(l_PGM_ID,-999)
26355 and nvl(BPP2.PLIP_ID,-999) = nvl(l_PLIP_ID,-999)
26356 and nvl(BPP2.PTIP_ID,-999) = nvl(l_PTIP_ID,-999)
26357 and BPP2.business_group_id = c_business_group_id
26358 and BPP2.effective_end_date >= c_effective_end_date )
26359 ;
26360 END TEMPIK */
26361
26362 cursor c_find_BPP_name_in_target( c_BPP_name varchar2,
26363 c_effective_start_date date,
26364 c_effective_end_date date,
26365 c_business_group_id number,
26366 c_new_pk_id number) is
26367 select
26368 BPP.bnft_prvdr_pool_id new_value
26369 from BEN_BNFT_PRVDR_POOL_F BPP
26370 where BPP.name = c_BPP_name
26371 and BPP.business_group_id = c_business_group_id
26372 and BPP.bnft_prvdr_pool_id <> c_new_pk_id
26373 --TEMPIK
26374 and c_effective_start_date between effective_start_date
26375 and effective_end_date ;
26376 --END TEMPIK
26377 /* TEMPIK
26378 and exists ( select null
26379 from BEN_BNFT_PRVDR_POOL_F BPP1
26380 where BPP1.name = c_BPP_name
26381 and BPP1.business_group_id = c_business_group_id
26382 and BPP1.effective_start_date <= c_effective_start_date )
26383 and exists ( select null
26384 from BEN_BNFT_PRVDR_POOL_F BPP2
26385 where BPP2.name = c_BPP_name
26386 and BPP2.business_group_id = c_business_group_id
26387 and BPP2.effective_end_date >= c_effective_end_date )
26388 ;
26389 END TEMPIK*/
26390 --
26391 --UPD START
26392 --
26393 l_update boolean := false ;
26394 l_datetrack_mode varchar2(80) := hr_api.g_update;
26395 l_process_date date;
26396 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
26397 --
26398 --UPD END
26399 l_current_pk_id number := null ;
26400 l_prev_pk_id number := null ;
26401 l_first_rec boolean := true ;
26402 r_BPP c_BPP%rowtype;
26403 l_bnft_prvdr_pool_id number ;
26404 l_object_version_number number ;
26405 l_effective_start_date date ;
26406 l_effective_end_date date ;
26407 l_prefix pqh_copy_entity_attribs.information1%type := null;
26408 l_suffix pqh_copy_entity_attribs.information1%type := null;
26409 l_new_value number(15);
26410 l_object_found_in_target boolean := false ;
26411 l_min_esd date;
26412 l_max_eed date;
26413 l_effective_date date;
26414 --TEMPIK
26415 l_dt_rec_found boolean ;
26416 --END TEMPIK
26417 --
26418 begin
26419 -- Initialization
26420 l_object_found_in_target := false ;
26421 -- End Initialization
26422 -- Derive the prefix - sufix
26423 -- End Prefix Sufix derivation
26424 for r_BPP_unique in c_unique_BPP('BPP') loop
26425
26426 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
26427 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26428 r_BPP_unique.information3 >=
26429 ben_pd_copy_to_ben_one.g_copy_effective_date)
26430 ) then
26431 --
26432 if p_prefix_suffix_cd = 'PREFIX' then
26433 l_prefix := p_prefix_suffix_text ;
26434 elsif p_prefix_suffix_cd = 'SUFFIX' then
26435 l_suffix := p_prefix_suffix_text ;
26436 else
26437 l_prefix := null ;
26438 l_suffix := null ;
26439 end if ;
26440 hr_utility.set_location(' r_BPP_unique.table_route_id '||r_BPP_unique.table_route_id,10);
26441 hr_utility.set_location(' r_BPP_unique.information1 '||r_BPP_unique.information1,10);
26442 hr_utility.set_location( 'r_BPP_unique.information2 '||r_BPP_unique.information2,10);
26443 hr_utility.set_location( 'r_BPP_unique.information3 '||r_BPP_unique.information3,10);
26444 -- If reuse objects flag is 'Y' then check for the object in the target business group
26445 -- if found insert the record into PLSql table and exit the loop else try create the
26446 -- object in the target business group
26447 --
26448 l_object_found_in_target := false ;
26449 --UPD START
26450 open c_BPP(r_BPP_unique.table_route_id,
26451 r_BPP_unique.information1,
26452 r_BPP_unique.information2,
26453 r_BPP_unique.information3 ) ;
26454 --
26455 fetch c_BPP into r_BPP ;
26456 --
26457 close c_BPP ;
26458 --
26459 l_dml_operation:= r_BPP_unique.dml_operation ;
26460 l_CMBN_PLIP_ID := get_fk('CMBN_PLIP_ID', r_BPP.INFORMATION239,l_dml_operation );
26461 l_CMBN_PTIP_ID := get_fk('CMBN_PTIP_ID', r_BPP.INFORMATION236,l_dml_operation );
26462 l_CMBN_PTIP_OPT_ID := get_fk('CMBN_PTIP_OPT_ID', r_BPP.INFORMATION249,l_dml_operation );
26463 l_COMP_LVL_FCTR_ID := get_fk('COMP_LVL_FCTR_ID', r_BPP.INFORMATION254,l_dml_operation );
26464 l_DFLT_EXCS_TRTMT_RL := get_fk('FORMULA_ID', r_BPP.INFORMATION262,l_dml_operation );
26465 l_OIPLIP_ID := get_fk('OIPLIP_ID', r_BPP.INFORMATION227,l_dml_operation );
26466 l_PCT_RNDG_RL := get_fk('FORMULA_ID', r_BPP.INFORMATION266,l_dml_operation );
26467 l_PGM_ID := get_fk('PGM_ID', r_BPP.INFORMATION260,l_dml_operation );
26468 l_PLIP_ID := get_fk('PLIP_ID', r_BPP.INFORMATION256,l_dml_operation );
26469 l_PTIP_ID := get_fk('PTIP_ID', r_BPP.INFORMATION259,l_dml_operation );
26470 l_VAL_RNDG_RL := get_fk('FORMULA_ID', r_BPP.INFORMATION267,l_dml_operation ); --
26471 --
26472 l_update := false;
26473 l_process_date := p_effective_date;
26474 --
26475 if l_dml_operation = 'UPDATE' then
26476 --
26477 l_object_found_in_target := TRUE;
26478 --
26479 if l_process_date between r_BPP_unique.information2 and r_BPP_unique.information3 then
26480 l_update := true;
26481 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)
26482 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'
26483 then
26484 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'BNFT_PRVDR_POOL_ID' ;
26485 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_BPP_unique.information1 ;
26486 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_BPP_unique.information1 ;
26487 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
26488 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;
26489 --
26490 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
26491 --
26492 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26493 --
26494 --DOUBT log_data('BPP',l_new_value,l_prefix || r_BPP_unique.name|| l_suffix,'REUSED');
26495 --
26496 end if ;
26497 hr_utility.set_location( 'found record for update',10);
26498 --
26499 else
26500 --
26501 l_update := false;
26502 --
26503 end if;
26504 else
26505 --
26506 --UPD END
26507 l_min_esd := null ;
26508 l_max_eed := null ;
26509 open c_BPP_min_max_dates(r_BPP_unique.table_route_id, r_BPP_unique.information1 ) ;
26510 fetch c_BPP_min_max_dates into l_min_esd,l_max_eed ;
26511 --
26512
26513 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26514 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
26515 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
26516 end if;
26517 l_min_esd := greatest(l_min_esd,r_BPP_unique.information2);
26518 /* open c_BPP(r_BPP_unique.table_route_id,
26519 r_BPP_unique.information1,
26520 r_BPP_unique.information2,
26521 r_BPP_unique.information3 ) ;
26522 --
26523 fetch c_BPP into r_BPP ;
26524 --
26525 close c_BPP ; */
26526 --
26527 if p_reuse_object_flag = 'Y' then
26528 if c_BPP_min_max_dates%found then
26529 -- cursor to find the object
26530 open c_find_BPP_in_target( l_prefix || r_BPP_unique.name || l_suffix ,l_min_esd,l_max_eed,
26531 p_target_business_group_id, nvl(l_bnft_prvdr_pool_id, -999) ) ;
26532 fetch c_find_BPP_in_target into l_new_value ;
26533 if c_find_BPP_in_target%found then
26534 --
26535 --TEMPIK
26536 l_dt_rec_found := dt_api.check_min_max_dates
26537 (p_base_table_name => 'BEN_BNFT_PRVDR_POOL_F',
26538 p_base_key_column => 'BNFT_PRVDR_POOL_ID',
26539 p_base_key_value => l_new_value,
26540 p_from_date => l_min_esd,
26541 p_to_date => l_max_eed );
26542 if l_dt_rec_found THEN
26543 --END TEMPIK
26544 --
26545 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
26546 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
26547 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'BNFT_PRVDR_POOL_ID' ;
26548 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_BPP_unique.information1 ;
26549 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
26550 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
26551 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;
26552 --
26553 -- 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) ;
26554 --
26555 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26556 --
26557 BEN_PD_COPY_TO_BEN_ONE.log_data('BPP',l_new_value,l_prefix || r_BPP_unique.name || l_suffix ,'REUSED');
26558 --
26559 end if ;
26560 --
26561 l_object_found_in_target := true ;
26562 --TEMPIK
26563 end if; -- l_dt_rec_found
26564 --END TEMPIK
26565 else
26566 -- NEW
26567 if p_prefix_suffix_text is null then
26568 --
26569 open c_find_BPP_name_in_target( l_prefix || r_BPP_unique.name|| l_suffix ,
26570 l_min_esd,l_max_eed,
26571 p_target_business_group_id, nvl(l_bnft_prvdr_pool_id, -999) ) ;
26572 fetch c_find_BPP_name_in_target into l_new_value ;
26573 if c_find_BPP_name_in_target%found then
26574 --
26575 --TEMPIK
26576 l_dt_rec_found := dt_api.check_min_max_dates
26577 (p_base_table_name => 'BEN_BNFT_PRVDR_POOL_F',
26578 p_base_key_column => 'BNFT_PRVDR_POOL_ID',
26579 p_base_key_value => l_new_value,
26580 p_from_date => l_min_esd,
26581 p_to_date => l_max_eed );
26582 if l_dt_rec_found THEN
26583 --END TEMPIK
26584
26585 if p_prefix_suffix_cd = 'PREFIX' then
26586 l_prefix := BEN_PLAN_DESIGN_TXNS_API.g_pgm_pl_prefix_suffix_text ;
26587 elsif p_prefix_suffix_cd = 'SUFFIX' then
26588 l_suffix := BEN_PLAN_DESIGN_TXNS_API.g_pgm_pl_prefix_suffix_text ;
26589 else
26590 l_prefix := null ;
26591 l_suffix := null ;
26592 end if ;
26593 --
26594 --TEMPIK
26595 end if ; -- l_dt_rec_found
26596 --END TEMPIK
26597 end if;
26598 close c_find_BPP_name_in_target ;
26599 end if;
26600 --dbms_output.put_line(' Second Cursor ');
26601 end if;
26602 close c_find_BPP_in_target ;
26603 end if;
26604 end if ;
26605 --
26606 close c_BPP_min_max_dates ;
26607 end if; --if p_dml_operation
26608 --
26609 if not l_object_found_in_target OR l_update then
26610 --
26611 l_current_pk_id := r_BPP.information1;
26612 --
26613 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
26614 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
26615 --
26616 if l_current_pk_id = l_prev_pk_id then
26617 --
26618 l_first_rec := false ;
26619 --
26620 else
26621 --
26622 l_first_rec := true ;
26623 --
26624 end if ;
26625 --
26626 --
26627 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_BNFT_PRVDR_POOL_F',l_prefix || r_BPP.information170 || l_suffix);
26628 --
26629
26630 l_effective_date := r_BPP.information2;
26631 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
26632 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
26633 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
26634 end if;
26635
26636 if l_first_rec and not l_update then
26637 -- Call Create routine.
26638 hr_utility.set_location(' BEN_BNFT_PRVDR_POOL_F CREATE_BENEFIT_PRVDR_POOL ',20);
26639 BEN_BENEFIT_PRVDR_POOL_API.CREATE_BENEFIT_PRVDR_POOL(
26640 --
26641 P_VALIDATE => false
26642 ,P_EFFECTIVE_DATE => l_effective_date
26643 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
26644 --
26645 ,P_ALWS_NGTV_CRS_FLAG => r_BPP.INFORMATION16
26646 ,P_AUTO_ALCT_EXCS_FLAG => r_BPP.INFORMATION25
26647 ,P_BNFT_PRVDR_POOL_ID => l_bnft_prvdr_pool_id
26648 ,P_BPP_ATTRIBUTE1 => r_BPP.INFORMATION111
26649 ,P_BPP_ATTRIBUTE10 => r_BPP.INFORMATION120
26650 ,P_BPP_ATTRIBUTE11 => r_BPP.INFORMATION121
26651 ,P_BPP_ATTRIBUTE12 => r_BPP.INFORMATION122
26652 ,P_BPP_ATTRIBUTE13 => r_BPP.INFORMATION123
26653 ,P_BPP_ATTRIBUTE14 => r_BPP.INFORMATION124
26654 ,P_BPP_ATTRIBUTE15 => r_BPP.INFORMATION125
26655 ,P_BPP_ATTRIBUTE16 => r_BPP.INFORMATION126
26656 ,P_BPP_ATTRIBUTE17 => r_BPP.INFORMATION127
26657 ,P_BPP_ATTRIBUTE18 => r_BPP.INFORMATION128
26658 ,P_BPP_ATTRIBUTE19 => r_BPP.INFORMATION129
26659 ,P_BPP_ATTRIBUTE2 => r_BPP.INFORMATION112
26660 ,P_BPP_ATTRIBUTE20 => r_BPP.INFORMATION130
26661 ,P_BPP_ATTRIBUTE21 => r_BPP.INFORMATION131
26662 ,P_BPP_ATTRIBUTE22 => r_BPP.INFORMATION132
26663 ,P_BPP_ATTRIBUTE23 => r_BPP.INFORMATION133
26664 ,P_BPP_ATTRIBUTE24 => r_BPP.INFORMATION134
26665 ,P_BPP_ATTRIBUTE25 => r_BPP.INFORMATION135
26666 ,P_BPP_ATTRIBUTE26 => r_BPP.INFORMATION136
26667 ,P_BPP_ATTRIBUTE27 => r_BPP.INFORMATION137
26668 ,P_BPP_ATTRIBUTE28 => r_BPP.INFORMATION138
26669 ,P_BPP_ATTRIBUTE29 => r_BPP.INFORMATION139
26670 ,P_BPP_ATTRIBUTE3 => r_BPP.INFORMATION113
26671 ,P_BPP_ATTRIBUTE30 => r_BPP.INFORMATION140
26672 ,P_BPP_ATTRIBUTE4 => r_BPP.INFORMATION114
26673 ,P_BPP_ATTRIBUTE5 => r_BPP.INFORMATION115
26674 ,P_BPP_ATTRIBUTE6 => r_BPP.INFORMATION116
26675 ,P_BPP_ATTRIBUTE7 => r_BPP.INFORMATION117
26676 ,P_BPP_ATTRIBUTE8 => r_BPP.INFORMATION118
26677 ,P_BPP_ATTRIBUTE9 => r_BPP.INFORMATION119
26678 ,P_BPP_ATTRIBUTE_CATEGORY => r_BPP.INFORMATION110
26679 ,P_CMBN_PLIP_ID => l_CMBN_PLIP_ID
26680 ,P_CMBN_PTIP_ID => l_CMBN_PTIP_ID
26681 ,P_CMBN_PTIP_OPT_ID => l_CMBN_PTIP_OPT_ID
26682 ,P_COMP_LVL_FCTR_ID => l_COMP_LVL_FCTR_ID
26683 ,P_DFLT_EXCS_TRTMT_CD => r_BPP.INFORMATION13
26684 ,P_DFLT_EXCS_TRTMT_RL => l_DFLT_EXCS_TRTMT_RL
26685 ,P_EXCS_ALWYS_FFTD_FLAG => r_BPP.INFORMATION19
26686 ,P_EXCS_TRTMT_CD => r_BPP.INFORMATION15
26687 ,P_MN_DSTRBL_PCT_NUM => r_BPP.INFORMATION263
26688 ,P_MN_DSTRBL_VAL => r_BPP.INFORMATION293
26689 ,P_MX_DFCIT_PCT_COMP_NUM => r_BPP.INFORMATION296
26690 ,P_MX_DFCIT_PCT_POOL_CRS_NUM => r_BPP.INFORMATION295
26691 ,P_MX_DSTRBL_PCT_NUM => r_BPP.INFORMATION264
26692 ,P_MX_DSTRBL_VAL => r_BPP.INFORMATION294
26693 ,P_NAME => l_prefix || r_BPP.INFORMATION170 || l_suffix
26694 ,P_NO_MN_DSTRBL_PCT_FLAG => r_BPP.INFORMATION21
26695 ,P_NO_MN_DSTRBL_VAL_FLAG => r_BPP.INFORMATION22
26696 ,P_NO_MX_DSTRBL_PCT_FLAG => r_BPP.INFORMATION23
26697 ,P_NO_MX_DSTRBL_VAL_FLAG => r_BPP.INFORMATION24
26698 ,P_OIPLIP_ID => l_OIPLIP_ID
26699 ,P_PCT_RNDG_CD => r_BPP.INFORMATION11
26700 ,P_PCT_RNDG_RL => l_PCT_RNDG_RL
26701 ,P_PGM_ID => l_PGM_ID
26702 ,P_PGM_POOL_FLAG => r_BPP.INFORMATION18
26703 ,P_PLIP_ID => l_PLIP_ID
26704 ,P_PTIP_ID => l_PTIP_ID
26705 ,P_RLOVR_RSTRCN_CD => r_BPP.INFORMATION14
26706 ,P_USES_NET_CRS_MTHD_FLAG => r_BPP.INFORMATION17
26707 ,P_USE_FOR_PGM_POOL_FLAG => r_BPP.INFORMATION20
26708 ,P_VAL_RNDG_CD => r_BPP.INFORMATION12
26709 ,P_VAL_RNDG_RL => l_VAL_RNDG_RL
26710 --
26711 ,P_EFFECTIVE_START_DATE => l_effective_start_date
26712 ,P_EFFECTIVE_END_DATE => l_effective_end_date
26713 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
26714 );
26715 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
26716 -- Update all relevent cer records with new pk_id
26717 hr_utility.set_location('Before plsql table ',222);
26718 hr_utility.set_location('new_value id '||l_bnft_prvdr_pool_id,222);
26719 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'BNFT_PRVDR_POOL_ID' ;
26720 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_BPP.information1 ;
26721 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_BNFT_PRVDR_POOL_ID ;
26722 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
26723 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;
26724 hr_utility.set_location('After plsql table ',222);
26725 --
26726 -- 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 ) ;
26727 --
26728 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
26729 --
26730 BEN_PD_COPY_TO_BEN_ONE.log_data('BPP',l_new_value,l_prefix || r_BPP.INFORMATION170 || l_suffix,'COPIED');
26731 --
26732 else
26733 --
26734 -- Call Update routine for the pk_id created in prev run .
26735 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
26736 hr_utility.set_location(' BEN_BNFT_PRVDR_POOL_F UPDATE_BENEFIT_PRVDR_POOL ',30);
26737 --UPD START
26738 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
26739 --
26740 if l_update then
26741 --
26742 l_datetrack_mode := r_BPP.datetrack_mode ;
26743 --
26744 get_dt_modes(
26745 p_effective_date => l_process_date,
26746 p_effective_end_date => r_BPP.information3,
26747 p_effective_start_date => r_BPP.information2,
26748 p_dml_operation => r_BPP.dml_operation,
26749 p_datetrack_mode => l_datetrack_mode );
26750 -- p_update => l_update
26751 --
26752 l_effective_date := l_process_date;
26753 l_BNFT_PRVDR_POOL_ID := r_BPP.information1;
26754 l_object_version_number := r_BPP.information265;
26755 --
26756 end if;
26757 --
26758 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
26759 --
26760 IF l_update OR l_dml_operation <> 'UPDATE' THEN
26761 --UPD END
26762
26763 BEN_BENEFIT_PRVDR_POOL_API.UPDATE_BENEFIT_PRVDR_POOL(
26764 --
26765 P_VALIDATE => false
26766 ,P_EFFECTIVE_DATE => l_effective_date
26767 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
26768 --
26769 ,P_ALWS_NGTV_CRS_FLAG => r_BPP.INFORMATION16
26770 ,P_AUTO_ALCT_EXCS_FLAG => r_BPP.INFORMATION25
26771 ,P_BNFT_PRVDR_POOL_ID => l_bnft_prvdr_pool_id
26772 ,P_BPP_ATTRIBUTE1 => r_BPP.INFORMATION111
26773 ,P_BPP_ATTRIBUTE10 => r_BPP.INFORMATION120
26774 ,P_BPP_ATTRIBUTE11 => r_BPP.INFORMATION121
26775 ,P_BPP_ATTRIBUTE12 => r_BPP.INFORMATION122
26776 ,P_BPP_ATTRIBUTE13 => r_BPP.INFORMATION123
26777 ,P_BPP_ATTRIBUTE14 => r_BPP.INFORMATION124
26778 ,P_BPP_ATTRIBUTE15 => r_BPP.INFORMATION125
26779 ,P_BPP_ATTRIBUTE16 => r_BPP.INFORMATION126
26780 ,P_BPP_ATTRIBUTE17 => r_BPP.INFORMATION127
26781 ,P_BPP_ATTRIBUTE18 => r_BPP.INFORMATION128
26782 ,P_BPP_ATTRIBUTE19 => r_BPP.INFORMATION129
26783 ,P_BPP_ATTRIBUTE2 => r_BPP.INFORMATION112
26784 ,P_BPP_ATTRIBUTE20 => r_BPP.INFORMATION130
26785 ,P_BPP_ATTRIBUTE21 => r_BPP.INFORMATION131
26786 ,P_BPP_ATTRIBUTE22 => r_BPP.INFORMATION132
26787 ,P_BPP_ATTRIBUTE23 => r_BPP.INFORMATION133
26788 ,P_BPP_ATTRIBUTE24 => r_BPP.INFORMATION134
26789 ,P_BPP_ATTRIBUTE25 => r_BPP.INFORMATION135
26790 ,P_BPP_ATTRIBUTE26 => r_BPP.INFORMATION136
26791 ,P_BPP_ATTRIBUTE27 => r_BPP.INFORMATION137
26792 ,P_BPP_ATTRIBUTE28 => r_BPP.INFORMATION138
26793 ,P_BPP_ATTRIBUTE29 => r_BPP.INFORMATION139
26794 ,P_BPP_ATTRIBUTE3 => r_BPP.INFORMATION113
26795 ,P_BPP_ATTRIBUTE30 => r_BPP.INFORMATION140
26796 ,P_BPP_ATTRIBUTE4 => r_BPP.INFORMATION114
26797 ,P_BPP_ATTRIBUTE5 => r_BPP.INFORMATION115
26798 ,P_BPP_ATTRIBUTE6 => r_BPP.INFORMATION116
26799 ,P_BPP_ATTRIBUTE7 => r_BPP.INFORMATION117
26800 ,P_BPP_ATTRIBUTE8 => r_BPP.INFORMATION118
26801 ,P_BPP_ATTRIBUTE9 => r_BPP.INFORMATION119
26802 ,P_BPP_ATTRIBUTE_CATEGORY => r_BPP.INFORMATION110
26803 ,P_CMBN_PLIP_ID => l_CMBN_PLIP_ID
26804 ,P_CMBN_PTIP_ID => l_CMBN_PTIP_ID
26805 ,P_CMBN_PTIP_OPT_ID => l_CMBN_PTIP_OPT_ID
26806 ,P_COMP_LVL_FCTR_ID => l_COMP_LVL_FCTR_ID
26807 ,P_DFLT_EXCS_TRTMT_CD => r_BPP.INFORMATION13
26808 ,P_DFLT_EXCS_TRTMT_RL => l_DFLT_EXCS_TRTMT_RL
26809 ,P_EXCS_ALWYS_FFTD_FLAG => r_BPP.INFORMATION19
26810 ,P_EXCS_TRTMT_CD => r_BPP.INFORMATION15
26811 ,P_MN_DSTRBL_PCT_NUM => r_BPP.INFORMATION263
26812 ,P_MN_DSTRBL_VAL => r_BPP.INFORMATION293
26813 ,P_MX_DFCIT_PCT_COMP_NUM => r_BPP.INFORMATION296
26814 ,P_MX_DFCIT_PCT_POOL_CRS_NUM => r_BPP.INFORMATION295
26815 ,P_MX_DSTRBL_PCT_NUM => r_BPP.INFORMATION264
26816 ,P_MX_DSTRBL_VAL => r_BPP.INFORMATION294
26817 ,P_NAME => l_prefix || r_BPP.INFORMATION170 || l_suffix
26818 ,P_NO_MN_DSTRBL_PCT_FLAG => r_BPP.INFORMATION21
26819 ,P_NO_MN_DSTRBL_VAL_FLAG => r_BPP.INFORMATION22
26820 ,P_NO_MX_DSTRBL_PCT_FLAG => r_BPP.INFORMATION23
26821 ,P_NO_MX_DSTRBL_VAL_FLAG => r_BPP.INFORMATION24
26822 ,P_OIPLIP_ID => l_OIPLIP_ID
26823 ,P_PCT_RNDG_CD => r_BPP.INFORMATION11
26824 ,P_PCT_RNDG_RL => l_PCT_RNDG_RL
26825 ,P_PGM_ID => l_PGM_ID
26826 ,P_PGM_POOL_FLAG => r_BPP.INFORMATION18
26827 ,P_PLIP_ID => l_PLIP_ID
26828 ,P_PTIP_ID => l_PTIP_ID
26829 ,P_RLOVR_RSTRCN_CD => r_BPP.INFORMATION14
26830 ,P_USES_NET_CRS_MTHD_FLAG => r_BPP.INFORMATION17
26831 ,P_USE_FOR_PGM_POOL_FLAG => r_BPP.INFORMATION20
26832 ,P_VAL_RNDG_CD => r_BPP.INFORMATION12
26833 ,P_VAL_RNDG_RL => l_VAL_RNDG_RL
26834 --
26835 ,P_EFFECTIVE_START_DATE => l_effective_start_date
26836 ,P_EFFECTIVE_END_DATE => l_effective_end_date
26837 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
26838 ,P_DATETRACK_MODE => l_datetrack_mode
26839 );
26840 --
26841 end if; -- l_update
26842 end if;
26843 --
26844 -- Delete the row if it is end dated.
26845 --
26846 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
26847 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
26848 trunc(l_max_eed) = r_BPP.information3) then
26849 --
26850 BEN_BENEFIT_PRVDR_POOL_API.delete_BENEFIT_PRVDR_POOL(
26851 --
26852 p_validate => false
26853 ,p_bnft_prvdr_pool_id => l_bnft_prvdr_pool_id
26854 ,p_effective_start_date => l_effective_start_date
26855 ,p_effective_end_date => l_effective_end_date
26856 ,p_object_version_number => l_object_version_number
26857 ,p_effective_date => l_max_eed
26858 ,p_datetrack_mode => hr_api.g_delete
26859 --
26860 );
26861 --
26862 end if;
26863 --
26864 l_prev_pk_id := l_current_pk_id ;
26865 --
26866 end if;
26867 --
26868 end if;
26869 --
26870 end loop;
26871 --
26872 exception when others then
26873 --
26874 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'BPP',l_prefix || r_BPP.information170 || l_suffix) ;
26875 --
26876 end create_BPP_rows;
26877
26878 ---------------------------------------------------------------
26879 ----------------------< create_ACP_rows >-----------------------
26880 ---------------------------------------------------------------
26881 --
26882 procedure create_ACP_rows
26883 (
26884 p_validate in number default 0
26885 ,p_copy_entity_txn_id in number
26886 ,p_effective_date in date
26887 ,p_prefix_suffix_text in varchar2 default null
26888 ,p_reuse_object_flag in varchar2 default null
26889 ,p_target_business_group_id in varchar2 default null
26890 ,p_prefix_suffix_cd in varchar2 default null
26891 ) is
26892 --
26893 l_PGM_ID number;
26894 cursor c_unique_ACP(l_table_alias varchar2) is
26895 select distinct cpe.information1,
26896 cpe.information2,
26897 cpe.information3,
26898 cpe.information170 name,
26899 cpe.table_route_id
26900 ,cpe.dml_operation,cpe.datetrack_mode from ben_copy_entity_results cpe,
26901 pqh_table_route tr
26902 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26903 and cpe.table_route_id = tr.table_route_id
26904 -- and tr.where_clause = l_BEN_ACRS_PTIP_CVG_F
26905 and tr.table_alias = l_table_alias
26906 and cpe.number_of_copies = 1 -- ADDITION
26907 group by cpe.information1,cpe.information2,cpe.information3, cpe.information170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
26908 order by information1, information2; --added for bug: 5151945
26909 --
26910 --
26911 cursor c_ACP_min_max_dates(c_table_route_id number,
26912 c_information1 number) is
26913 select
26914 min(cpe.information2) min_esd,
26915 max(cpe.information3) min_eed
26916 from ben_copy_entity_results cpe
26917 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26918 and cpe.table_route_id = c_table_route_id
26919 and cpe.information1 = c_information1 ;
26920 --
26921 cursor c_ACP(c_table_route_id number,
26922 c_information1 number,
26923 c_information2 date,
26924 c_information3 date) is
26925 select
26926 cpe.*
26927 from ben_copy_entity_results cpe
26928 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
26929 and cpe.table_route_id = c_table_route_id
26930 and cpe.information1 = c_information1
26931 and cpe.information2 = c_information2
26932 and cpe.information3 = c_information3
26933 and rownum = 1 ;
26934 -- Date Track target record
26935 cursor c_find_ACP_in_target( c_ACP_name varchar2,
26936 c_effective_start_date date,
26937 c_effective_end_date date,
26938 c_business_group_id number,
26939 c_new_pk_id number) is
26940 select
26941 ACP.acrs_ptip_cvg_id new_value
26942 from BEN_ACRS_PTIP_CVG_F ACP
26943 where ACP.name = c_ACP_name and
26944 -- nvl(ACP.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
26945 ACP.business_group_id = c_business_group_id
26946 and ACP.acrs_ptip_cvg_id <> c_new_pk_id
26947 --TEMPIK
26948 and c_effective_start_date between effective_start_date
26949 and effective_end_date ;
26950 --END TEMPIK
26951 /*
26952 and exists ( select null
26953 from BEN_ACRS_PTIP_CVG_F ACP1
26954 where ACP1.name = c_ACP_name and
26955 -- nvl(ACP1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
26956 ACP1.business_group_id = c_business_group_id
26957 and ACP1.effective_start_date <= c_effective_start_date )
26958 and exists ( select null
26959 from BEN_ACRS_PTIP_CVG_F ACP2
26960 where ACP2.name = c_ACP_name and
26961 -- nvl(ACP2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
26962 ACP2.business_group_id = c_business_group_id
26963 and ACP2.effective_end_date >= c_effective_end_date )
26964 ;
26965 --
26966 */
26967 --UPD START
26968 --
26969 l_update boolean := false ;
26970 l_datetrack_mode varchar2(80) := hr_api.g_update;
26971 l_process_date date;
26972 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
26973 --
26974 --UPD END
26975 l_current_pk_id number := null ;
26976 l_prev_pk_id number := null ;
26977 l_first_rec boolean := true ;
26978 r_ACP c_ACP%rowtype;
26979 l_acrs_ptip_cvg_id number ;
26980 l_object_version_number number ;
26981 l_effective_start_date date ;
26982 l_effective_end_date date ;
26983 l_prefix pqh_copy_entity_attribs.information1%type := null;
26984 l_suffix pqh_copy_entity_attribs.information1%type := null;
26985 l_new_value number(15);
26986 l_object_found_in_target boolean := false ;
26987 l_min_esd date;
26988 l_max_eed date;
26989 l_effective_date date;
26990 --TEMPIK
26991 l_dt_rec_found boolean ;
26992 --END TEMPIK
26993 --
26994 begin
26995 -- Initialization
26996 l_object_found_in_target := false ;
26997 -- End Initialization
26998 -- Derive the prefix - sufix
26999 if p_prefix_suffix_cd = 'PREFIX' then
27000 l_prefix := p_prefix_suffix_text ;
27001 elsif p_prefix_suffix_cd = 'SUFFIX' then
27002 l_suffix := p_prefix_suffix_text ;
27003 else
27004 l_prefix := null ;
27005 l_suffix := null ;
27006 end if ;
27007 -- End Prefix Sufix derivation
27008 for r_ACP_unique in c_unique_ACP('ACP') loop
27009
27010 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
27011 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
27012 r_ACP_unique.information3 >=
27013 ben_pd_copy_to_ben_one.g_copy_effective_date)
27014 ) then
27015 --
27016 hr_utility.set_location(' r_ACP_unique.table_route_id '||r_ACP_unique.table_route_id,10);
27017 hr_utility.set_location(' r_ACP_unique.information1 '||r_ACP_unique.information1,10);
27018 hr_utility.set_location( 'r_ACP_unique.information2 '||r_ACP_unique.information2,10);
27019 hr_utility.set_location( 'r_ACP_unique.information3 '||r_ACP_unique.information3,10);
27020 -- If reuse objects flag is 'Y' then check for the object in the target business group
27021 -- if found insert the record into PLSql table and exit the loop else try create the
27022 -- object in the target business group
27023 --
27024 l_object_found_in_target := false ;
27025 --UPD START
27026 open c_ACP(r_ACP_unique.table_route_id,
27027 r_ACP_unique.information1,
27028 r_ACP_unique.information2,
27029 r_ACP_unique.information3 ) ;
27030 --
27031 fetch c_ACP into r_ACP ;
27032 --
27033 close c_ACP ;
27034 l_dml_operation:= r_ACP_unique.dml_operation ;
27035 --
27036 -- Only For Use by Create Wizard - Same Business Group
27037 l_PGM_ID := NVL(get_fk('PGM_ID', r_ACP.information260,l_dml_operation ),
27038 r_ACP.information260);
27039 --
27040 l_update := false;
27041 l_process_date := p_effective_date;
27042 --
27043 if l_dml_operation = 'UPDATE' then
27044 --
27045 l_object_found_in_target := TRUE;
27046 --
27047 if l_process_date between r_ACP_unique.information2 and r_ACP_unique.information3 then
27048 l_update := true;
27049 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)
27050 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'
27051 then
27052 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'ACRS_PTIP_CVG_ID' ;
27053 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_ACP_unique.information1 ;
27054 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := r_ACP_unique.information1 ;
27055 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
27056 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;
27057 --
27058 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
27059 --
27060 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
27061 --
27062 --DOUBT log_data('ACP',l_new_value,l_prefix || r_ACP_unique.name|| l_suffix,'REUSED');
27063 --
27064 end if ;
27065 hr_utility.set_location( 'found record for update',10);
27066 --
27067 else
27068 --
27069 l_update := false;
27070 --
27071 end if;
27072 else
27073 --
27074 --UPD END
27075 l_min_esd := null ;
27076 l_max_eed := null ;
27077 open c_ACP_min_max_dates(r_ACP_unique.table_route_id, r_ACP_unique.information1 ) ;
27078 fetch c_ACP_min_max_dates into l_min_esd,l_max_eed ;
27079 --
27080
27081 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
27082 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
27083 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
27084 end if;
27085 l_min_esd := greatest(l_min_esd,r_ACP_unique.information2);
27086 /* open c_ACP(r_ACP_unique.table_route_id,
27087 r_ACP_unique.information1,
27088 r_ACP_unique.information2,
27089 r_ACP_unique.information3 ) ;
27090 --
27091 fetch c_ACP into r_ACP ;
27092 --
27093 close c_ACP ; */
27094
27095 if p_reuse_object_flag = 'Y' then
27096 if c_ACP_min_max_dates%found then
27097 -- cursor to find the object
27098 open c_find_ACP_in_target( l_prefix || r_ACP_unique.name||l_suffix ,l_min_esd,l_max_eed,
27099 p_target_business_group_id, nvl(l_acrs_ptip_cvg_id, -999) ) ;
27100 fetch c_find_ACP_in_target into l_new_value ;
27101 if c_find_ACP_in_target%found then
27102 --
27103 --TEMPIK
27104 l_dt_rec_found := dt_api.check_min_max_dates
27105 (p_base_table_name => 'BEN_ACRS_PTIP_CVG_F',
27106 p_base_key_column => 'ACRS_PTIP_CVG_ID',
27107 p_base_key_value => l_new_value,
27108 p_from_date => l_min_esd,
27109 p_to_date => l_max_eed );
27110 if l_dt_rec_found THEN
27111 --END TEMPIK
27112 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
27113 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
27114 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).pk_id_column := 'ACRS_PTIP_CVG_ID' ;
27115 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).old_value := r_ACP_unique.information1 ;
27116 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).new_value := l_new_value ;
27117 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'REUSED';
27118 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;
27119 --
27120 -- 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) ;
27121 --
27122 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1 ;
27123 ben_pd_copy_to_ben_one.log_data('ACP',l_new_value,l_prefix || r_ACP_unique.name|| l_suffix,'REUSED');
27124 end if ;
27125 --
27126 l_object_found_in_target := true ;
27127 --TEMPIK
27128 end if; -- l_dt_rec_found
27129 --END TEMPIK
27130 end if;
27131 close c_find_ACP_in_target ;
27132 --
27133 end if;
27134 end if ;
27135 --
27136 close c_ACP_min_max_dates ;
27137 end if; --if p_dml_operation
27138 --
27139 if not l_object_found_in_target OR l_update then
27140 --
27141 l_current_pk_id := r_ACP.information1;
27142 --
27143 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
27144 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
27145 --
27146 if l_current_pk_id = l_prev_pk_id then
27147 --
27148 l_first_rec := false ;
27149 --
27150 else
27151 --
27152 l_first_rec := true ;
27153 --
27154 end if ;
27155 --
27156 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_ACRS_PTIP_CVG_F',l_prefix || r_ACP.information170 || l_suffix);
27157 --
27158
27159 l_effective_date := r_ACP.information2;
27160 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
27161 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
27162 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
27163 end if;
27164
27165 if l_first_rec and not l_update then
27166 -- Call Create routine.
27167 hr_utility.set_location(' BEN_ACRS_PTIP_CVG_F CREATE_ACRS_PTIP_CVG ',20);
27168 BEN_ACRS_PTIP_CVG_API.CREATE_ACRS_PTIP_CVG(
27169 --
27170 P_VALIDATE => false
27171 ,P_EFFECTIVE_DATE => l_effective_date
27172 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
27173 --
27174 ,P_ACRS_PTIP_CVG_ID => l_acrs_ptip_cvg_id
27175 ,P_APC_ATTRIBUTE1 => r_ACP.INFORMATION111
27176 ,P_APC_ATTRIBUTE10 => r_ACP.INFORMATION120
27177 ,P_APC_ATTRIBUTE11 => r_ACP.INFORMATION121
27178 ,P_APC_ATTRIBUTE12 => r_ACP.INFORMATION122
27179 ,P_APC_ATTRIBUTE13 => r_ACP.INFORMATION123
27180 ,P_APC_ATTRIBUTE14 => r_ACP.INFORMATION124
27181 ,P_APC_ATTRIBUTE15 => r_ACP.INFORMATION125
27182 ,P_APC_ATTRIBUTE16 => r_ACP.INFORMATION126
27183 ,P_APC_ATTRIBUTE17 => r_ACP.INFORMATION127
27184 ,P_APC_ATTRIBUTE18 => r_ACP.INFORMATION128
27185 ,P_APC_ATTRIBUTE19 => r_ACP.INFORMATION129
27186 ,P_APC_ATTRIBUTE2 => r_ACP.INFORMATION112
27187 ,P_APC_ATTRIBUTE20 => r_ACP.INFORMATION130
27188 ,P_APC_ATTRIBUTE21 => r_ACP.INFORMATION131
27189 ,P_APC_ATTRIBUTE22 => r_ACP.INFORMATION132
27190 ,P_APC_ATTRIBUTE23 => r_ACP.INFORMATION133
27191 ,P_APC_ATTRIBUTE24 => r_ACP.INFORMATION134
27192 ,P_APC_ATTRIBUTE25 => r_ACP.INFORMATION135
27193 ,P_APC_ATTRIBUTE26 => r_ACP.INFORMATION136
27194 ,P_APC_ATTRIBUTE27 => r_ACP.INFORMATION137
27195 ,P_APC_ATTRIBUTE28 => r_ACP.INFORMATION138
27196 ,P_APC_ATTRIBUTE29 => r_ACP.INFORMATION139
27197 ,P_APC_ATTRIBUTE3 => r_ACP.INFORMATION113
27198 ,P_APC_ATTRIBUTE30 => r_ACP.INFORMATION140
27199 ,P_APC_ATTRIBUTE4 => r_ACP.INFORMATION114
27200 ,P_APC_ATTRIBUTE5 => r_ACP.INFORMATION115
27201 ,P_APC_ATTRIBUTE6 => r_ACP.INFORMATION116
27202 ,P_APC_ATTRIBUTE7 => r_ACP.INFORMATION117
27203 ,P_APC_ATTRIBUTE8 => r_ACP.INFORMATION118
27204 ,P_APC_ATTRIBUTE9 => r_ACP.INFORMATION119
27205 ,P_APC_ATTRIBUTE_CATEGORY => r_ACP.INFORMATION110
27206 ,P_MN_CVG_ALWD_AMT => r_ACP.INFORMATION294
27207 ,P_MX_CVG_ALWD_AMT => r_ACP.INFORMATION293
27208 ,P_NAME => l_prefix || r_ACP.INFORMATION170 || l_suffix
27209 ,P_PGM_ID => l_PGM_ID
27210 --
27211 ,P_EFFECTIVE_START_DATE => l_effective_start_date
27212 ,P_EFFECTIVE_END_DATE => l_effective_end_date
27213 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
27214 );
27215 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
27216 -- Update all relevent cer records with new pk_id
27217 hr_utility.set_location('Before plsql table ',222);
27218 hr_utility.set_location('new_value id '||l_acrs_ptip_cvg_id,222);
27219 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).pk_id_column := 'ACRS_PTIP_CVG_ID' ;
27220 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).old_value := r_ACP.information1 ;
27221 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).new_value := l_ACRS_PTIP_CVG_ID ;
27222 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'COPIED';
27223 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;
27224 hr_utility.set_location('After plsql table ',222);
27225 --
27226 -- 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 ) ;
27227 --
27228 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1 ;
27229 ben_pd_copy_to_ben_one.log_data('ACP',l_new_value,l_prefix || r_ACP.information170|| l_suffix,'COPIED');
27230 --
27231 else
27232 --
27233 -- Call Update routine for the pk_id created in prev run .
27234 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
27235 hr_utility.set_location(' BEN_ACRS_PTIP_CVG_F UPDATE_ACRS_PTIP_CVG ',30);
27236 --UPD START
27237 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
27238 --
27239 if l_update then
27240 --
27241 l_datetrack_mode := r_ACP.datetrack_mode ;
27242 --
27243 get_dt_modes(
27244 p_effective_date => l_process_date,
27245 p_effective_end_date => r_ACP.information3,
27246 p_effective_start_date => r_ACP.information2,
27247 p_dml_operation => r_ACP.dml_operation,
27248 p_datetrack_mode => l_datetrack_mode );
27249 -- p_update => l_update
27250 --
27251 l_effective_date := l_process_date;
27252 l_ACRS_PTIP_CVG_ID := r_ACP.information1;
27253 l_object_version_number := r_ACP.information265;
27254 --
27255 end if;
27256 --
27257 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
27258 --
27259 IF l_update OR l_dml_operation <> 'UPDATE' THEN
27260 --UPD END
27261 BEN_ACRS_PTIP_CVG_API.UPDATE_ACRS_PTIP_CVG(
27262 --
27263 P_VALIDATE => false
27264 ,P_EFFECTIVE_DATE => l_effective_date
27265 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
27266 --
27267 ,P_ACRS_PTIP_CVG_ID => l_acrs_ptip_cvg_id
27268 ,P_APC_ATTRIBUTE1 => r_ACP.INFORMATION111
27269 ,P_APC_ATTRIBUTE10 => r_ACP.INFORMATION120
27270 ,P_APC_ATTRIBUTE11 => r_ACP.INFORMATION121
27271 ,P_APC_ATTRIBUTE12 => r_ACP.INFORMATION122
27272 ,P_APC_ATTRIBUTE13 => r_ACP.INFORMATION123
27273 ,P_APC_ATTRIBUTE14 => r_ACP.INFORMATION124
27274 ,P_APC_ATTRIBUTE15 => r_ACP.INFORMATION125
27275 ,P_APC_ATTRIBUTE16 => r_ACP.INFORMATION126
27276 ,P_APC_ATTRIBUTE17 => r_ACP.INFORMATION127
27277 ,P_APC_ATTRIBUTE18 => r_ACP.INFORMATION128
27278 ,P_APC_ATTRIBUTE19 => r_ACP.INFORMATION129
27279 ,P_APC_ATTRIBUTE2 => r_ACP.INFORMATION112
27280 ,P_APC_ATTRIBUTE20 => r_ACP.INFORMATION130
27281 ,P_APC_ATTRIBUTE21 => r_ACP.INFORMATION131
27282 ,P_APC_ATTRIBUTE22 => r_ACP.INFORMATION132
27283 ,P_APC_ATTRIBUTE23 => r_ACP.INFORMATION133
27284 ,P_APC_ATTRIBUTE24 => r_ACP.INFORMATION134
27285 ,P_APC_ATTRIBUTE25 => r_ACP.INFORMATION135
27286 ,P_APC_ATTRIBUTE26 => r_ACP.INFORMATION136
27287 ,P_APC_ATTRIBUTE27 => r_ACP.INFORMATION137
27288 ,P_APC_ATTRIBUTE28 => r_ACP.INFORMATION138
27289 ,P_APC_ATTRIBUTE29 => r_ACP.INFORMATION139
27290 ,P_APC_ATTRIBUTE3 => r_ACP.INFORMATION113
27291 ,P_APC_ATTRIBUTE30 => r_ACP.INFORMATION140
27292 ,P_APC_ATTRIBUTE4 => r_ACP.INFORMATION114
27293 ,P_APC_ATTRIBUTE5 => r_ACP.INFORMATION115
27294 ,P_APC_ATTRIBUTE6 => r_ACP.INFORMATION116
27295 ,P_APC_ATTRIBUTE7 => r_ACP.INFORMATION117
27296 ,P_APC_ATTRIBUTE8 => r_ACP.INFORMATION118
27297 ,P_APC_ATTRIBUTE9 => r_ACP.INFORMATION119
27298 ,P_APC_ATTRIBUTE_CATEGORY => r_ACP.INFORMATION110
27299 ,P_MN_CVG_ALWD_AMT => r_ACP.INFORMATION294
27300 ,P_MX_CVG_ALWD_AMT => r_ACP.INFORMATION293
27301 ,P_NAME => l_prefix || r_ACP.INFORMATION170 || l_suffix
27302 ,P_PGM_ID => l_PGM_ID
27303
27304 --
27305 ,P_EFFECTIVE_START_DATE => l_effective_start_date
27306 ,P_EFFECTIVE_END_DATE => l_effective_end_date
27307 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
27308 ,P_DATETRACK_MODE => l_datetrack_mode
27309 );
27310 end if; -- l_update
27311 end if;
27312 --
27313 --
27314 -- Delete the row if it is end dated.
27315 --
27316 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
27317 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
27318 trunc(l_max_eed) = r_ACP.information3) then
27319 --
27320 BEN_ACRS_PTIP_CVG_API.delete_ACRS_PTIP_CVG(
27321 --
27322 p_validate => false
27323 ,p_acrs_ptip_cvg_id => l_acrs_ptip_cvg_id
27324 ,p_effective_start_date => l_effective_start_date
27325 ,p_effective_end_date => l_effective_end_date
27326 ,p_object_version_number => l_object_version_number
27327 ,p_effective_date => l_max_eed
27328 ,p_datetrack_mode => hr_api.g_delete
27329 --
27330 );
27331 --
27332 end if;
27333 --
27334 l_prev_pk_id := l_current_pk_id ;
27335 --
27336 end if;
27337 --
27338 end if;
27339 --
27340 end loop;
27341 --
27342 exception when others then
27343 --
27344 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'ACP',l_prefix || r_ACP.information170 || l_suffix) ;
27345 --
27346 end create_ACP_rows;
27347
27348 procedure create_final_intersect_rows
27349 (
27350 p_validate in number default 0 -- false
27351 ,p_copy_entity_txn_id in number
27352 ,p_effective_date in date
27353 ,p_prefix_suffix_text in varchar2 default null
27354 ,p_reuse_object_flag in varchar2 default null
27355 ,p_target_business_group_id in varchar2 default null
27356 ,p_prefix_suffix_cd in varchar2 default null
27357 ) is
27358 begin
27359
27360 --
27361 -- Create all Service Area Postal Zip Range rows
27362 --
27363 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('SAZ') then
27364 BEN_PD_COPY_TO_BEN_TWO.create_SAZ_rows(
27365 p_validate => p_validate
27366 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27367 ,p_effective_date => p_effective_date
27368 ,p_prefix_suffix_text => p_prefix_suffix_text
27369 ,p_reuse_object_flag => p_reuse_object_flag
27370 ,p_target_business_group_id => p_target_business_group_id
27371 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27372 );
27373 end if;
27374 --
27375 -- Create all oipl rows. Moved these calls to End
27376 --
27377 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('COP') then
27378 BEN_PD_COPY_TO_BEN_TWO.create_COP_rows(
27379 p_validate => p_validate
27380 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27381 ,p_effective_date => p_effective_date
27382 ,p_prefix_suffix_text => p_prefix_suffix_text
27383 ,p_reuse_object_flag => p_reuse_object_flag
27384 ,p_target_business_group_id => p_target_business_group_id
27385 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27386 );
27387 end if;
27388 --
27389 -- Create all DDR rows, which could be attached to opt, oipl, pl levels..
27390 --
27391 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('DDR') then
27392 BEN_PD_COPY_TO_BEN_TWO.create_DDR_rows(
27393 p_validate => p_validate
27394 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27395 ,p_effective_date => p_effective_date
27396 ,p_prefix_suffix_text => p_prefix_suffix_text
27397 ,p_reuse_object_flag => p_reuse_object_flag
27398 ,p_target_business_group_id => p_target_business_group_id
27399 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27400 );
27401 end if;
27402 --
27403 -- Create all DRR rows, which could be attached to DRR rows.
27404 --
27405 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('DRR') then
27406 BEN_PD_COPY_TO_BEN_TWO.create_DRR_rows(
27407 p_validate => p_validate
27408 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27409 ,p_effective_date => p_effective_date
27410 ,p_prefix_suffix_text => p_prefix_suffix_text
27411 ,p_reuse_object_flag => p_reuse_object_flag
27412 ,p_target_business_group_id => p_target_business_group_id
27413 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27414 );
27415 end if;
27416 --
27417 -- These records needs to be created at the end of the process.
27418 -- PEO records are created at PGM,PTIP,PLIP,PL and OIPLIP level
27419 -- This call creates the intersections between all these levels and ler.
27420 --
27421 --XXXOIPL
27422 --
27423 -- CPY records are created at PGM and PL level
27424 -- This call creates the intersections between all these levels and yr_perds.
27425 --
27426 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CPY') then
27427 BEN_PD_COPY_TO_BEN_TWO.create_CPY_rows(
27428 p_validate => p_validate
27429 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27430 ,p_effective_date => p_effective_date
27431 ,p_prefix_suffix_text => p_prefix_suffix_text
27432 ,p_reuse_object_flag => p_reuse_object_flag
27433 ,p_target_business_group_id => p_target_business_group_id
27434 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27435 );
27436 end if;
27437 --
27438 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CWG') then
27439 BEN_PD_COPY_TO_BEN_TWO.create_CWG_rows(
27440 p_validate => p_validate
27441 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27442 ,p_effective_date => p_effective_date
27443 ,p_prefix_suffix_text => p_prefix_suffix_text
27444 ,p_reuse_object_flag => p_reuse_object_flag
27445 ,p_target_business_group_id => p_target_business_group_id
27446 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27447 );
27448
27449 create_CRI_rows(
27450 p_validate => p_validate
27451 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27452 ,p_effective_date => p_effective_date
27453 ,p_reuse_object_flag => p_reuse_object_flag
27454 );
27455 end if;
27456 --
27457 --
27458 -- PAT records are created at PGM and PL level
27459 -- This call creates the intersections between all these levels and Action type.
27460 --
27461 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PAT') then
27462 BEN_PD_COPY_TO_BEN_TWO.create_PAT_rows(
27463 p_validate => p_validate
27464 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27465 ,p_effective_date => p_effective_date
27466 ,p_prefix_suffix_text => p_prefix_suffix_text
27467 ,p_reuse_object_flag => p_reuse_object_flag
27468 ,p_target_business_group_id => p_target_business_group_id
27469 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27470 );
27471 end if;
27472
27473 --
27474 -- PET records are created at PGM and PL level
27475 -- This call creates the intersections between all these levels and enrt type cycl code.
27476 --
27477 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PET') then
27478 BEN_PD_COPY_TO_BEN_TWO.create_PET_rows(
27479 p_validate => p_validate
27480 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27481 ,p_effective_date => p_effective_date
27482 ,p_prefix_suffix_text => p_prefix_suffix_text
27483 ,p_reuse_object_flag => p_reuse_object_flag
27484 ,p_target_business_group_id => p_target_business_group_id
27485 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27486 );
27487 end if;
27488 --
27489 -- ENP records are created at PGM and PL level
27490 -- This call creates the intersections between all these levels and year periods.
27491 --
27492 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ENP') then
27493 BEN_PD_COPY_TO_BEN_TWO.create_ENP_rows(
27494 p_validate => p_validate
27495 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27496 ,p_effective_date => p_effective_date
27497 ,p_prefix_suffix_text => p_prefix_suffix_text
27498 ,p_reuse_object_flag => p_reuse_object_flag
27499 ,p_target_business_group_id => p_target_business_group_id
27500 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27501 );
27502 end if;
27503 --
27504 --
27505 -- LEN records are created at PGM and PL level
27506 -- This call creates the intersections between all these levels and ler.
27507 --
27508 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LEN') then
27509 BEN_PD_COPY_TO_BEN_TWO.create_LEN_rows(
27510 p_validate => p_validate
27511 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27512 ,p_effective_date => p_effective_date
27513 ,p_prefix_suffix_text => p_prefix_suffix_text
27514 ,p_reuse_object_flag => p_reuse_object_flag
27515 ,p_target_business_group_id => p_target_business_group_id
27516 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27517 );
27518 end if;
27519 --
27520 --
27521 -- LOP records are created at OIPL and LER level
27522 --
27523 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LOP') then
27524 BEN_PD_COPY_TO_BEN_TWO.create_LOP_rows(
27525 p_validate => p_validate
27526 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27527 ,p_effective_date => p_effective_date
27528 ,p_prefix_suffix_text => p_prefix_suffix_text
27529 ,p_reuse_object_flag => p_reuse_object_flag
27530 ,p_target_business_group_id => p_target_business_group_id
27531 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27532 );
27533 end if;
27534 --
27535 --
27536 -- ERP records are created at LEN or ENP level
27537 --
27538 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ERP') then
27539 BEN_PD_COPY_TO_BEN_TWO.create_ERP_rows(
27540 p_validate => p_validate
27541 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27542 ,p_effective_date => p_effective_date
27543 ,p_prefix_suffix_text => p_prefix_suffix_text
27544 ,p_reuse_object_flag => p_reuse_object_flag
27545 ,p_target_business_group_id => p_target_business_group_id
27546 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27547 );
27548 end if;
27549 --
27550 --
27551 -- SER records are created at ENP level
27552 --
27553 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('SER') then
27554 BEN_PD_COPY_TO_BEN_TWO.create_SER_rows(
27555 p_validate => p_validate
27556 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27557 ,p_effective_date => p_effective_date
27558 ,p_prefix_suffix_text => p_prefix_suffix_text
27559 ,p_reuse_object_flag => p_reuse_object_flag
27560 ,p_target_business_group_id => p_target_business_group_id
27561 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27562 );
27563 end if;
27564 --
27565 --
27566 -- ECF records are created at PL and OIPL level
27567 -- This call creates the intersections between all these levels and
27568 -- enrt_ctfn_cd
27569 --
27570 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ECF') then
27571 BEN_PD_COPY_TO_BEN_TWO.create_ECF_rows(
27572 p_validate => p_validate
27573 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27574 ,p_effective_date => p_effective_date
27575 ,p_prefix_suffix_text => p_prefix_suffix_text
27576 ,p_reuse_object_flag => p_reuse_object_flag
27577 ,p_target_business_group_id => p_target_business_group_id
27578 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27579 );
27580 end if;
27581 --
27582 -- CPO records are created at PL and GPM level
27583 -- This call creates the intersections between these levels and
27584 -- Organization
27585 --
27586 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CPO') then
27587 BEN_PD_COPY_TO_BEN_TWO.create_CPO_rows(
27588 p_validate => p_validate
27589 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27590 ,p_effective_date => p_effective_date
27591 ,p_prefix_suffix_text => p_prefix_suffix_text
27592 ,p_reuse_object_flag => p_reuse_object_flag
27593 ,p_target_business_group_id => p_target_business_group_id
27594 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27595 );
27596 end if;
27597 -- CPR records are created at CPO level
27598 -- This call creates the child records for the CPO level
27599 --
27600 --
27601 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CPR') then
27602 BEN_PD_COPY_TO_BEN_TWO.create_CPR_rows(
27603 p_validate => p_validate
27604 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27605 ,p_effective_date => p_effective_date
27606 ,p_prefix_suffix_text => p_prefix_suffix_text
27607 ,p_reuse_object_flag => p_reuse_object_flag
27608 ,p_target_business_group_id => p_target_business_group_id
27609 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27610 );
27611 end if;
27612
27613 -- RGR records are created at PL and GPM level
27614 -- This call creates the intersections between these levels and
27615 -- reporting group
27616 --
27617 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('RGR') then
27618 BEN_PD_COPY_TO_BEN_TWO.create_RGR_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 --
27629 -- PRG records are created at PL and RGR level
27630 -- This call creates the intersections between these levels and
27631 -- REGN
27632 --
27633 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PRG') then
27634 BEN_PD_COPY_TO_BEN_TWO.create_PRG_rows(
27635 p_validate => p_validate
27636 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27637 ,p_effective_date => p_effective_date
27638 ,p_prefix_suffix_text => p_prefix_suffix_text
27639 ,p_reuse_object_flag => p_reuse_object_flag
27640 ,p_target_business_group_id => p_target_business_group_id
27641 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27642 );
27643 end if;
27644
27645 --
27646 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ACP') then
27647 BEN_PD_COPY_TO_BEN_two.create_ACP_rows
27648 (p_validate => p_validate
27649 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27650 ,p_effective_date => p_effective_date
27651 ,p_prefix_suffix_text => p_prefix_suffix_text
27652 ,p_reuse_object_flag => p_reuse_object_flag
27653 ,p_target_business_group_id => p_target_business_group_id
27654 ,p_prefix_suffix_cd => p_prefix_suffix_cd);
27655 end if;
27656 --
27657
27658 -- Start of Intersections for the PTIP
27659 -- CTP records are created at Program and Plan Intersection
27660 --
27661 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CTP') then
27662 BEN_PD_COPY_TO_BEN_TWO.create_CTP_rows(
27663 p_validate => p_validate
27664 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27665 ,p_effective_date => p_effective_date
27666 ,p_prefix_suffix_text => p_prefix_suffix_text
27667 ,p_reuse_object_flag => p_reuse_object_flag
27668 ,p_target_business_group_id => p_target_business_group_id
27669 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27670 );
27671 end if;
27672 -- ADE records are created at PGM,PTIP and PL level
27673 -- This call creates the intersections between all these levels and
27674 -- ben_dpnt_cvg_eligy_prfl_f
27675 --
27676 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ADE') then
27677 BEN_PD_COPY_TO_BEN_TWO.create_ADE_rows(
27678 p_validate => p_validate
27679 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27680 ,p_effective_date => p_effective_date
27681 ,p_prefix_suffix_text => p_prefix_suffix_text
27682 ,p_reuse_object_flag => p_reuse_object_flag
27683 ,p_target_business_group_id => p_target_business_group_id
27684 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27685 );
27686 end if;
27687 --
27688 -- LDC records are created at PGM,PTIP and PL level
27689 -- This call creates the intersections between all these levels and
27690 -- ben_ler_f
27691 --
27692 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LDC') then
27693 BEN_PD_COPY_TO_BEN_TWO.create_LDC_rows(
27694 p_validate => p_validate
27695 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27696 ,p_effective_date => p_effective_date
27697 ,p_prefix_suffix_text => p_prefix_suffix_text
27698 ,p_reuse_object_flag => p_reuse_object_flag
27699 ,p_target_business_group_id => p_target_business_group_id
27700 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27701 );
27702 end if;
27703 --
27704 -- LCC records are created at LDC and certification type
27705 --
27706 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LCC') then
27707 BEN_PD_COPY_TO_BEN_TWO.create_LCC_rows(
27708 p_validate => p_validate
27709 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27710 ,p_effective_date => p_effective_date
27711 ,p_prefix_suffix_text => p_prefix_suffix_text
27712 ,p_reuse_object_flag => p_reuse_object_flag
27713 ,p_target_business_group_id => p_target_business_group_id
27714 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27715 );
27716 end if;
27717 -- WPT records are created at PTIP and wv_prtn_rsn_cd intersection
27718 --
27719 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('WPT') then
27720 BEN_PD_COPY_TO_BEN_TWO.create_WPT_rows(
27721 p_validate => p_validate
27722 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27723 ,p_effective_date => p_effective_date
27724 ,p_prefix_suffix_text => p_prefix_suffix_text
27725 ,p_reuse_object_flag => p_reuse_object_flag
27726 ,p_target_business_group_id => p_target_business_group_id
27727 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27728 );
27729 end if;
27730 -- WCT records are created at WPT and wv_prtn_ctfn_typ_cd intersection
27731 --
27732 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('WCT') then
27733 BEN_PD_COPY_TO_BEN_TWO.create_WCT_rows(
27734 p_validate => p_validate
27735 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27736 ,p_effective_date => p_effective_date
27737 ,p_prefix_suffix_text => p_prefix_suffix_text
27738 ,p_reuse_object_flag => p_reuse_object_flag
27739 ,p_target_business_group_id => p_target_business_group_id
27740 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27741 );
27742 end if;
27743 -- LCT records are created at PTIP and LER_ID intersection
27744 --
27745 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LCT') then
27746 BEN_PD_COPY_TO_BEN_TWO.create_LCT_rows(
27747 p_validate => p_validate
27748 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27749 ,p_effective_date => p_effective_date
27750 ,p_prefix_suffix_text => p_prefix_suffix_text
27751 ,p_reuse_object_flag => p_reuse_object_flag
27752 ,p_target_business_group_id => p_target_business_group_id
27753 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27754 );
27755 end if;
27756 -- PYD records are created at PTIP and dependent certification type intersection
27757 --
27758 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PYD') then
27759 BEN_PD_COPY_TO_BEN_TWO.create_PYD_rows(
27760 p_validate => p_validate
27761 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27762 ,p_effective_date => p_effective_date
27763 ,p_prefix_suffix_text => p_prefix_suffix_text
27764 ,p_reuse_object_flag => p_reuse_object_flag
27765 ,p_target_business_group_id => p_target_business_group_id
27766 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27767 );
27768 end if;
27769 -- PLIP Rows start here
27770 -- CPP records are created at PGM and PLN intersection
27771 -- XXXPLIP
27772 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CPP') then
27773 BEN_PD_COPY_TO_BEN_TWO.create_CPP_rows(
27774 p_validate => p_validate
27775 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27776 ,p_effective_date => p_effective_date
27777 ,p_prefix_suffix_text => p_prefix_suffix_text
27778 ,p_reuse_object_flag => p_reuse_object_flag
27779 ,p_target_business_group_id => p_target_business_group_id
27780 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27781 );
27782 end if;
27783
27784 -- OIPLIP Always Reuse, never create
27785 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('OPP') then
27786 BEN_PD_COPY_TO_BEN_TWO.create_OPP_rows(
27787 p_validate => p_validate
27788 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27789 ,p_effective_date => p_effective_date
27790 ,p_prefix_suffix_text => p_prefix_suffix_text
27791 ,p_reuse_object_flag => p_reuse_object_flag
27792 ,p_target_business_group_id => p_target_business_group_id
27793 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27794 );
27795 end if;
27796 --
27797 -- OPTIP Always Reuse, never create
27798 /* Commented out for Now - Not Complete
27799 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('OTP') then
27800 BEN_PD_COPY_TO_BEN_TWO.create_OTP_rows(
27801 p_validate => p_validate
27802 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27803 ,p_effective_date => p_effective_date
27804 ,p_prefix_suffix_text => p_prefix_suffix_text
27805 ,p_reuse_object_flag => p_reuse_object_flag
27806 ,p_target_business_group_id => p_target_business_group_id
27807 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27808 );
27809 end if;
27810 */
27811 --
27812 -- Moved call from bepdccp1.pkb so that Benefit Pools are
27813 -- created after PLIP, PTIP and OIPLIP
27814 --
27815 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('BPP') then
27816 BEN_PD_COPY_TO_BEN_TWO.create_BPP_rows(
27817 p_validate => p_validate
27818 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27819 ,p_effective_date => p_effective_date
27820 ,p_prefix_suffix_text => p_prefix_suffix_text
27821 ,p_reuse_object_flag => p_reuse_object_flag
27822 ,p_target_business_group_id => p_target_business_group_id
27823 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27824 );
27825 end if;
27826 --
27827
27828 -- LBR records are created at PLIP and LER intersection
27829 --
27830 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LBR') then
27831 BEN_PD_COPY_TO_BEN_TWO.create_LBR_rows(
27832 p_validate => p_validate
27833 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27834 ,p_effective_date => p_effective_date
27835 ,p_prefix_suffix_text => p_prefix_suffix_text
27836 ,p_reuse_object_flag => p_reuse_object_flag
27837 ,p_target_business_group_id => p_target_business_group_id
27838 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27839 );
27840 end if;
27841 --
27842 -- LPR1 records are created at PLIP and LER intersection
27843 --
27844 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LPR1') then
27845 BEN_PD_COPY_TO_BEN_TWO.create_LPR1_rows(
27846 p_validate => p_validate
27847 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27848 ,p_effective_date => p_effective_date
27849 ,p_prefix_suffix_text => p_prefix_suffix_text
27850 ,p_reuse_object_flag => p_reuse_object_flag
27851 ,p_target_business_group_id => p_target_business_group_id
27852 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27853 );
27854 end if;
27855 -- Plan Intersections
27856 -- VGS records are created at PL and GOS intersection
27857 --
27858 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('VGS') then
27859 BEN_PD_COPY_TO_BEN_TWO.create_VGS_rows(
27860 p_validate => p_validate
27861 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27862 ,p_effective_date => p_effective_date
27863 ,p_prefix_suffix_text => p_prefix_suffix_text
27864 ,p_reuse_object_flag => p_reuse_object_flag
27865 ,p_target_business_group_id => p_target_business_group_id
27866 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27867 );
27868 end if;
27869 -- PCT records are created at VGS and certification type intersection
27870 --
27871 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PCT') then
27872 BEN_PD_COPY_TO_BEN_TWO.create_PCT_rows(
27873 p_validate => p_validate
27874 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27875 ,p_effective_date => p_effective_date
27876 ,p_prefix_suffix_text => p_prefix_suffix_text
27877 ,p_reuse_object_flag => p_reuse_object_flag
27878 ,p_target_business_group_id => p_target_business_group_id
27879 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27880 );
27881 end if;
27882 -- VRP records as child record of PL
27883 --
27884 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('VRP') then
27885 BEN_PD_COPY_TO_BEN_TWO.create_VRP_rows(
27886 p_validate => p_validate
27887 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27888 ,p_effective_date => p_effective_date
27889 ,p_prefix_suffix_text => p_prefix_suffix_text
27890 ,p_reuse_object_flag => p_reuse_object_flag
27891 ,p_target_business_group_id => p_target_business_group_id
27892 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27893 );
27894 end if;
27895 --
27896 -- WPN records are intersection of PL and wv_prtn_rsn_cd
27897 --
27898 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('WPN') then
27899 BEN_PD_COPY_TO_BEN_TWO.create_WPN_rows(
27900 p_validate => p_validate
27901 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27902 ,p_effective_date => p_effective_date
27903 ,p_prefix_suffix_text => p_prefix_suffix_text
27904 ,p_reuse_object_flag => p_reuse_object_flag
27905 ,p_target_business_group_id => p_target_business_group_id
27906 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27907 );
27908 end if;
27909 -- WCN records are intersection of WPN and wv_prtn_ctfn_typ_cd
27910 --
27911 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('WCN') then
27912 BEN_PD_COPY_TO_BEN_TWO.create_WCN_rows(
27913 p_validate => p_validate
27914 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27915 ,p_effective_date => p_effective_date
27916 ,p_prefix_suffix_text => p_prefix_suffix_text
27917 ,p_reuse_object_flag => p_reuse_object_flag
27918 ,p_target_business_group_id => p_target_business_group_id
27919 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27920 );
27921 end if;
27922 --
27923 -- BRC records are intersection of PL and enrt_ctfn_typ_cd
27924 --
27925 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('BRC') then
27926 BEN_PD_COPY_TO_BEN_TWO.create_BRC_rows(
27927 p_validate => p_validate
27928 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27929 ,p_effective_date => p_effective_date
27930 ,p_prefix_suffix_text => p_prefix_suffix_text
27931 ,p_reuse_object_flag => p_reuse_object_flag
27932 ,p_target_business_group_id => p_target_business_group_id
27933 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27934 );
27935 end if;
27936 -- LBC records are intersection of ler_bnft_rstrn_id and enrt_ctfn_typ_cd
27937 --
27938 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LBC') then
27939 BEN_PD_COPY_TO_BEN_TWO.create_LBC_rows(
27940 p_validate => p_validate
27941 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27942 ,p_effective_date => p_effective_date
27943 ,p_prefix_suffix_text => p_prefix_suffix_text
27944 ,p_reuse_object_flag => p_reuse_object_flag
27945 ,p_target_business_group_id => p_target_business_group_id
27946 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27947 );
27948 end if;
27949 -- LRE records are intersection of PL,OIPL with LER
27950 --
27951 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LRE') then
27952 BEN_PD_COPY_TO_BEN_TWO.create_LRE_rows(
27953 p_validate => p_validate
27954 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27955 ,p_effective_date => p_effective_date
27956 ,p_prefix_suffix_text => p_prefix_suffix_text
27957 ,p_reuse_object_flag => p_reuse_object_flag
27958 ,p_target_business_group_id => p_target_business_group_id
27959 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27960 );
27961 end if;
27962 -- LNC records are intersection of LRE and enrt_ctfn_typ_cd
27963 --
27964 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LNC') then
27965 BEN_PD_COPY_TO_BEN_TWO.create_LNC_rows(
27966 p_validate => p_validate
27967 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27968 ,p_effective_date => p_effective_date
27969 ,p_prefix_suffix_text => p_prefix_suffix_text
27970 ,p_reuse_object_flag => p_reuse_object_flag
27971 ,p_target_business_group_id => p_target_business_group_id
27972 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27973 );
27974 end if;
27975 -- LPE records are intersection of PLN and LER
27976 --
27977 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LPE') then
27978 BEN_PD_COPY_TO_BEN_TWO.create_LPE_rows(
27979 p_validate => p_validate
27980 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27981 ,p_effective_date => p_effective_date
27982 ,p_prefix_suffix_text => p_prefix_suffix_text
27983 ,p_reuse_object_flag => p_reuse_object_flag
27984 ,p_target_business_group_id => p_target_business_group_id
27985 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27986 );
27987 end if;
27988 -- PND records are intersection of PLN and dpnt_cvg_ctfn_typ_cd
27989 --
27990 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PND') then
27991 BEN_PD_COPY_TO_BEN_TWO.create_PND_rows(
27992 p_validate => p_validate
27993 ,p_copy_entity_txn_id => p_copy_entity_txn_id
27994 ,p_effective_date => p_effective_date
27995 ,p_prefix_suffix_text => p_prefix_suffix_text
27996 ,p_reuse_object_flag => p_reuse_object_flag
27997 ,p_target_business_group_id => p_target_business_group_id
27998 ,p_prefix_suffix_cd => p_prefix_suffix_cd
27999 );
28000 end if;
28001 -- PCX records are intersection of PLN and bnf_ctfn_typ_cd
28002 --
28003 --XXXPGM
28004 --
28005 -- These records needs to be created at the end of the process.
28006 -- PEO records are created at PGM,PTIP,PLIP,PL and OIPLIP level
28007 -- This call creates the intersections between all these levels and ler.
28008 --
28009 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PEO') then
28010 BEN_PD_COPY_TO_BEN_TWO.create_PEO_rows(
28011 p_validate => p_validate
28012 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28013 ,p_effective_date => p_effective_date
28014 ,p_prefix_suffix_text => p_prefix_suffix_text
28015 ,p_reuse_object_flag => p_reuse_object_flag
28016 ,p_target_business_group_id => p_target_business_group_id
28017 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28018 );
28019 end if;
28020 --
28021 -- EPA records are created at PGM,PTIP,PLIP,PL and OIPLIP level
28022 --
28023 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EPA') then
28024 BEN_PD_COPY_TO_BEN_TWO.create_EPA_rows(
28025 p_validate => p_validate
28026 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28027 ,p_effective_date => p_effective_date
28028 ,p_prefix_suffix_text => p_prefix_suffix_text
28029 ,p_reuse_object_flag => p_reuse_object_flag
28030 ,p_target_business_group_id => p_target_business_group_id
28031 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28032 );
28033 end if;
28034 --
28035 -- CEP records are created at the intersection of EPA and ELP
28036 --
28037 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CEP') then
28038 BEN_PD_COPY_TO_BEN_TWO.create_CEP_rows(
28039 p_validate => p_validate
28040 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28041 ,p_effective_date => p_effective_date
28042 ,p_prefix_suffix_text => p_prefix_suffix_text
28043 ,p_reuse_object_flag => p_reuse_object_flag
28044 ,p_target_business_group_id => p_target_business_group_id
28045 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28046 );
28047 end if;
28048 -- CER records are created at the intersection of EPA and FORMULA
28049 --
28050 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CER') then
28051 BEN_PD_COPY_TO_BEN_TWO.create_CER_rows(
28052 p_validate => p_validate
28053 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28054 ,p_effective_date => p_effective_date
28055 ,p_prefix_suffix_text => p_prefix_suffix_text
28056 ,p_reuse_object_flag => p_reuse_object_flag
28057 ,p_target_business_group_id => p_target_business_group_id
28058 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28059 );
28060 end if;
28061 --
28062 --
28063 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PCX') then
28064 BEN_PD_COPY_TO_BEN_TWO.create_PCX_rows(
28065 p_validate => p_validate
28066 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28067 ,p_effective_date => p_effective_date
28068 ,p_prefix_suffix_text => p_prefix_suffix_text
28069 ,p_reuse_object_flag => p_reuse_object_flag
28070 ,p_target_business_group_id => p_target_business_group_id
28071 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28072 );
28073 end if;
28074 --
28075 -- PCP records are intersection of PLN and ben_pl_pcp
28076 --
28077 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PCP') then
28078 BEN_PD_COPY_TO_BEN_TWO.create_PCP_rows(
28079 p_validate => p_validate
28080 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28081 ,p_effective_date => p_effective_date
28082 ,p_prefix_suffix_text => p_prefix_suffix_text
28083 ,p_reuse_object_flag => p_reuse_object_flag
28084 ,p_target_business_group_id => p_target_business_group_id
28085 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28086 );
28087 end if;
28088 --
28089 -- PTY records are child records of PCP
28090 --
28091 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PTY') then
28092 BEN_PD_COPY_TO_BEN_TWO.create_PTY_rows(
28093 p_validate => p_validate
28094 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28095 ,p_effective_date => p_effective_date
28096 ,p_prefix_suffix_text => p_prefix_suffix_text
28097 ,p_reuse_object_flag => p_reuse_object_flag
28098 ,p_target_business_group_id => p_target_business_group_id
28099 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28100 );
28101 end if;
28102 --
28103 -- PRB records are child records of PLN OR BNR
28104 --
28105 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PRB') then
28106 BEN_PD_COPY_TO_BEN_TWO.create_PRB_rows(
28107 p_validate => p_validate
28108 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28109 ,p_effective_date => p_effective_date
28110 ,p_prefix_suffix_text => p_prefix_suffix_text
28111 ,p_reuse_object_flag => p_reuse_object_flag
28112 ,p_target_business_group_id => p_target_business_group_id
28113 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28114 );
28115 end if;
28116 --
28117 --
28118 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PRP') then
28119 BEN_PD_COPY_TO_BEN_TWO.create_PRP_rows(
28120 p_validate => p_validate
28121 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28122 ,p_effective_date => p_effective_date
28123 ,p_prefix_suffix_text => p_prefix_suffix_text
28124 ,p_reuse_object_flag => p_reuse_object_flag
28125 ,p_target_business_group_id => p_target_business_group_id
28126 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28127 );
28128 end if;
28129 --
28130
28131 end create_final_intersect_rows ;
28132 --
28133 procedure create_pgm_intersect_rows(
28134 p_validate in number default 0 -- false
28135 ,p_copy_entity_txn_id in number
28136 ,p_effective_date in date
28137 ,p_prefix_suffix_text in varchar2 default null
28138 ,p_reuse_object_flag in varchar2 default null
28139 ,p_target_business_group_id in varchar2 default null
28140 ,p_prefix_suffix_cd in varchar2 default null
28141 ) is
28142 begin
28143 --
28144 -- First try creating all the leaf rows.
28145 --
28146 --TCS PDW Integration ENH
28147 if(BEN_PD_COPY_TO_BEN_TWO.g_copy_entity_txn_id <> p_copy_entity_txn_id) then
28148
28149 BEN_PD_COPY_TO_BEN_TWO.g_copy_entity_txn_id := p_copy_entity_txn_id;
28150
28151 open BEN_PD_COPY_TO_BEN_TWO.g_copy_entity_txn(p_copy_entity_txn_id) ;
28152 fetch BEN_PD_COPY_TO_BEN_TWO.g_copy_entity_txn into BEN_PD_COPY_TO_BEN_TWO.g_row_type_cd;
28153 close BEN_PD_COPY_TO_BEN_TWO.g_copy_entity_txn;
28154
28155 end if;
28156
28157 -- TCS PDW Integration passed the parameter BEN_PD_COPY_TO_BEN_TWO.g_row_type_cd to create_all_leaf_ben_rows
28158 BEN_PD_COPY_TO_BEN_ONE.create_all_leaf_ben_rows(
28159 p_validate => p_validate
28160 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28161 ,p_effective_date => p_effective_date
28162 ,p_prefix_suffix_text => p_prefix_suffix_text
28163 ,p_reuse_object_flag => p_reuse_object_flag
28164 ,p_target_business_group_id => p_target_business_group_id
28165 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28166 ,p_txn_row_type_cd => BEN_PD_COPY_TO_BEN_TWO.g_row_type_cd
28167 );
28168
28169 if (BEN_PD_COPY_TO_BEN_TWO.g_row_type_cd <> 'ELP') then
28170 --TCS PDW Integration ENH
28171 --
28172 -- ben_popl_enrt_typ_cycl_f rows are created as pgm and pl, yrp, wyp rows
28173 -- are created as part of leaf call and above call.
28174 --
28175 BEN_PD_COPY_TO_BEN_TWO.create_final_intersect_rows(
28176 p_validate => p_validate
28177 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28178 ,p_effective_date => p_effective_date
28179 ,p_prefix_suffix_text => p_prefix_suffix_text
28180 ,p_reuse_object_flag => p_reuse_object_flag
28181 ,p_target_business_group_id => p_target_business_group_id
28182 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28183 );
28184 --
28185 -- LGE records are created at Only PGM level
28186 -- This call creates the intersections between the program levels and ler.
28187 --
28188 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LGE') then
28189 BEN_PD_COPY_TO_BEN_TWO.create_LGE_rows(
28190 p_validate => p_validate
28191 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28192 ,p_effective_date => p_effective_date
28193 ,p_prefix_suffix_text => p_prefix_suffix_text
28194 ,p_reuse_object_flag => p_reuse_object_flag
28195 ,p_target_business_group_id => p_target_business_group_id
28196 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28197 );
28198 end if;
28199 --
28200 -- PGC records are created at Only PGM level
28201 -- This call creates the intersections between the program levels and dpnt_cvg_ctfn_typ_cd.
28202 --
28203 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PGC') then
28204 BEN_PD_COPY_TO_BEN_TWO.create_PGC_rows(
28205 p_validate => p_validate
28206 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28207 ,p_effective_date => p_effective_date
28208 ,p_prefix_suffix_text => p_prefix_suffix_text
28209 ,p_reuse_object_flag => p_reuse_object_flag
28210 ,p_target_business_group_id => p_target_business_group_id
28211 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28212 );
28213
28214 end if;
28215 --TCS PDW Integration ENH
28216
28217 end if;
28218 --
28219 --
28220 -- Now call eligibility profile creation.
28221 --
28222
28223 BEN_PD_COPY_TO_BEN_four.create_all_elig_prf_ben_rows
28224 (
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 -- Now make call to rate and all other ows creation
28235 --
28236 --TCS PDW Integration ENH
28237
28238 if (BEN_PD_COPY_TO_BEN_TWO.g_row_type_cd <> 'ELP') then
28239 --TCS PDW Integration ENH
28240
28241 BEN_PD_COPY_TO_BEN_five.create_rate_rows
28242 (
28243 p_validate => p_validate
28244 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28245 ,p_effective_date => p_effective_date
28246 ,p_prefix_suffix_text => p_prefix_suffix_text
28247 ,p_reuse_object_flag => p_reuse_object_flag
28248 ,p_target_business_group_id => p_target_business_group_id
28249 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28250 );
28251 --
28252 -- Now call rate profile creation.
28253 --
28254 BEN_PD_COPY_TO_BEN_three.create_all_rt_prf_ben_rows
28255 (
28256 p_validate => p_validate
28257 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28258 ,p_effective_date => p_effective_date
28259 ,p_prefix_suffix_text => p_prefix_suffix_text
28260 ,p_reuse_object_flag => p_reuse_object_flag
28261 ,p_target_business_group_id => p_target_business_group_id
28262 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28263 );
28264 --TCS PDW Integration ENH
28265 end if;
28266 --TCS PDW Integration ENH
28267 --
28268 end create_pgm_intersect_rows ;
28269 --
28270 procedure create_stg_to_ben_rows
28271 (
28272 p_validate in number default 0 -- false
28273 ,p_copy_entity_txn_id in number
28274 ,p_effective_date in date
28275 ,p_prefix_suffix_text in varchar2 default null
28276 ,p_reuse_object_flag in varchar2 default null
28277 ,p_target_business_group_id in varchar2 default null
28278 ,p_prefix_suffix_cd in varchar2 default null
28279 ,p_effective_date_to_copy in date default null
28280 ) is
28281
28282 cursor c_transaction_category(c_copy_entity_txn_id in number) is
28283 select tcg.short_name
28284 from pqh_copy_entity_txns cet,
28285 pqh_transaction_categories tcg
28286 where cet.copy_entity_txn_id = c_copy_entity_txn_id
28287 and cet.transaction_category_id = tcg.transaction_category_id;
28288
28289 l_transaction_category c_transaction_category%rowtype;
28290
28291 begin
28292 --
28293 --Call Create PGM ROWS
28294 --
28295 -- To set the Global variable for Mapping data.
28296 set_mapping(p_copy_entity_txn_id) ;
28297 --
28298 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl.delete;
28299 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(0) := null ;
28300 BEN_PD_COPY_TO_BEN_ONE.g_count := 1 ;
28301 --
28302 -- Initialize Logging Tables
28303 BEN_PD_COPY_TO_BEN_ONE.init_log_tbl;
28304 --
28305
28306 -- Update information9 to NULL
28307 -- Required for reusing Copy Process
28308
28309 update ben_copy_entity_results
28310 set information9 = null
28311 where copy_entity_txn_id = p_copy_entity_txn_id;
28312
28313
28314 BEN_PD_COPY_TO_BEN_ONE.init_table_data_in_cer(p_copy_entity_txn_id);
28315
28316 -- Initialize global variable for Effective Date to Copy
28317 BEN_PD_COPY_TO_BEN_ONE.g_copy_effective_date := p_effective_date_to_copy;
28318
28319 open c_transaction_category(p_copy_entity_txn_id);
28320 fetch c_transaction_category into l_transaction_category;
28321 close c_transaction_category;
28322
28323 -- Initialize global variable for Transaction Category
28324 BEN_PD_COPY_TO_BEN_ONE.g_transaction_category := l_transaction_category.short_name;
28325
28326 BEN_PD_COPY_TO_BEN_TWO.create_pgm_intersect_rows(
28327 p_validate => p_validate
28328 ,p_copy_entity_txn_id => p_copy_entity_txn_id
28329 ,p_effective_date => p_effective_date
28330 ,p_prefix_suffix_text => p_prefix_suffix_text
28331 ,p_reuse_object_flag => p_reuse_object_flag
28332 ,p_target_business_group_id => p_target_business_group_id
28333 ,p_prefix_suffix_cd => p_prefix_suffix_cd
28334 );
28335
28336 BEN_PD_COPY_TO_BEN_ONE.g_copy_effective_date := null;
28337 BEN_PD_COPY_TO_BEN_ONE.g_transaction_category := null;
28338 --
28339 --
28340 end create_stg_to_ben_rows ;
28341 --
28342 end BEN_PD_COPY_TO_BEN_TWO;