[Home] [Help]
PACKAGE BODY: APPS.BEN_PD_COPY_TO_BEN_ONE
Source
1 Package BODY BEN_PD_COPY_TO_BEN_ONE as
2 /* $Header: bepdccp1.pkb 120.24 2006/12/04 09:44:53 vborkar noship $ */
3 --
4 -- {Start Of Comments}
5 --
6 -- {End Of Comments}
7 --
8 --
9 --UPD Changes New procedure for getting the dtmodes
10 --
11 procedure get_dt_modes(p_effective_date in date,
12 p_effective_end_date in date,
13 p_effective_start_date in date,
14 p_dml_operation in varchar2,
15 p_datetrack_mode in out nocopy varchar2
16 -- p_update out nocopy boolean
17 ) is
18 l_update boolean := true ;
19 l_datetrack_mode varchar2(80) := p_datetrack_mode ;
20 begin
21 --
22 hr_utility.set_location('Intering get_dt_modes p_dt_mode '||l_datetrack_mode,10);
23 hr_utility.set_location('p_effective_start_date '||p_effective_start_date,10);
24 hr_utility.set_location('p_effective_end_date '||p_effective_end_date,10);
25 hr_utility.set_location('p_effective_date '||p_effective_date,10);
26 --
27 if p_effective_end_date <> hr_api.g_eot then
28 --
29 if p_dml_operation = 'INSERT' then
30 --
31 l_datetrack_mode := hr_api.g_update;
32 l_update := true;
33 --
34 elsif l_datetrack_mode in ('CORRECTION') then
35 --
36 l_datetrack_mode := hr_api.g_correction ;
37 l_update := true;
38 --
39 elsif l_datetrack_mode in ('UPDATE_OVERRIDE','UPDATE' ) then
40 --
41 if p_effective_date = p_effective_start_date then
42 l_datetrack_mode := hr_api.g_correction ;
43 l_update := true;
44 else
45 --
46 if l_datetrack_mode in ('UPDATE_OVERRIDE') then
47 --
48 l_datetrack_mode := hr_api.g_update_override ;
49 l_update := false ;
50 --
51 elsif l_datetrack_mode in ('UPDATE') then
52 --
53 l_datetrack_mode := hr_api.g_update;
54 --
55 end if;
56 --
57 end if;
58 --
59 elsif l_datetrack_mode in ('UPDATE_CHANGE_INSERT') then
60 --
61 if p_effective_date = p_effective_start_date then
62 l_datetrack_mode := hr_api.g_correction ;
63 l_update := true;
64 else
65 l_datetrack_mode := hr_api.g_update_change_insert ;
66 l_update := true;
67 end if;
68 --
69 else
70 --
71 l_datetrack_mode := hr_api.g_update;
72 l_update := false;
73 --
74 end if;
75 --
76 else
77 --
78 if p_dml_operation = 'INSERT' then
79 --
80 l_datetrack_mode := hr_api.g_update;
81 l_update := false;
82 --
83 elsif l_datetrack_mode in ('CORRECTION') then
84 --
85 l_datetrack_mode := hr_api.g_correction ;
86 l_update := false;
87 --
88 elsif l_datetrack_mode in ('UPDATE_OVERRIDE','UPDATE' ) then
89 --
90 if p_effective_date = p_effective_start_date then
91 l_datetrack_mode := hr_api.g_correction ;
92 l_update := true;
93 else
94 l_datetrack_mode := hr_api.g_update ;
95 l_update := false ;
96 end if;
97 --
98 elsif l_datetrack_mode in ('UPDATE_CHANGE_INSERT') then
99 --
100 if p_effective_date = p_effective_start_date then
101 l_datetrack_mode := hr_api.g_correction ;
102 l_update := false;
103 else
104 l_datetrack_mode := hr_api.g_update ;
105 l_update := false;
106 end if;
107 --
108 else
109 --
110 l_datetrack_mode := hr_api.g_update;
111 l_update := false;
112 --
113 end if;
114 --
115 end if ;
116 --
117 p_datetrack_mode := l_datetrack_mode ;
118 -- p_update := l_update ;
119 --
120 hr_utility.set_location('Leaving get_dt_modes p_dt_mode '||p_datetrack_mode,10);
121 --
122 end get_dt_modes ;
123 --
124 -- Start of Performance additions
125 --
126 -- ----------------------------------------------------------------------------
127 -- |------------------------< init_copy_tbl >---------------------------------|
128 -- ----------------------------------------------------------------------------
129 --
130 procedure init_table_data_in_cer(p_copy_entity_txn_id in number) is
131 --
132 cursor c_table_data_in_cer is
133 select tr.table_alias, tr.table_route_id
134 from pqh_table_route tr
135 where tr.table_route_id in(
136 select table_route_id from ben_copy_entity_results cpe
137 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
138 and cpe.number_of_copies = 1);
139 --
140 begin
141 --
142 g_table_data_in_cer.delete;
143 g_table_data_in_cer(0) := null ;
144 g_table_data_in_cer_count := 0 ;
145 --
146 for l_table_data_in_cer in c_table_data_in_cer loop
147 --
148 g_table_data_in_cer(g_table_data_in_cer_count).table_alias
149 := l_table_data_in_cer.table_alias;
150 g_table_data_in_cer(g_table_data_in_cer_count).table_route_id
151 := l_table_data_in_cer.table_route_id;
152 g_table_data_in_cer_count := g_table_data_in_cer_count + 1;
153 --
154 end loop;
155 --
156 end init_table_data_in_cer;
157 --
158 --
159 -- ----------------------------------------------------------------------------
160 -- |------------------------< data_exists_for_table >----------------------|
161 -- ----------------------------------------------------------------------------
162 --
163 function data_exists_for_table(p_table_alias in varchar2) return boolean is
164 --
165 l_ret_val boolean := false;
166 begin
167 --
168
169 for i in g_table_data_in_cer.FIRST..g_table_data_in_cer.LAST loop
170 if g_table_data_in_cer(i).table_alias = p_table_alias then
171 l_ret_val := true;
172 exit;
173 end if;
174 end loop;
175 --
176 return l_ret_val;
177 --
178 end data_exists_for_table;
179
180 --
181 -- End Performance additions
182 --
183 function get_fk(p_col_name varchar2, p_old_val number,p_dml_operation varchar2 default null) return number is
184 l_counter number;
185 l_ret_id number := null;
186 begin
187 --
188 /*
189 if p_dml_operation = 'UPDATE' then
190 --
191 l_ret_id := p_old_val ;
192 --
193 else
194 */
195 --
196 l_counter := nvl(g_pk_tbl.LAST, 0);
197 if l_counter > 0 and p_old_val is not null then
198 for i in 1..l_counter loop
199 if g_pk_tbl(i).pk_id_column = p_col_name and
200 g_pk_tbl(i).old_value = p_old_val
201 then
202 l_ret_id := g_pk_tbl(i).new_value;
203 exit;
204 end if;
205 end loop;
206 --
207 end if;
208 --
209 /*
210 end if;
211 */
212 return l_ret_id;
213 --
214 end;
215 --
216 --
217 -- Private procedure to update the cer with target details
218 --
219 procedure update_cer_with_target(c_pk_rec g_pk_rec_type, p_copy_entity_txn_id in number) is
220 begin
221 hr_utility.set_location('Inside update_cer_with_target ',233);
222 update ben_copy_entity_results
223 set information9 = c_pk_rec.copy_reuse_type||'-'||c_pk_rec.new_value
224 where copy_entity_txn_id = p_copy_entity_txn_id
225 and table_route_id = c_pk_rec.table_route_id
226 and information1 = c_pk_rec.old_value ;
227 end update_cer_with_target ;
228
229 --
230 --
231 -- ----------------------------------------------------------------------------
232 -- |------------------------< ben_chk_col_len >------------------------|
233 -- ----------------------------------------------------------------------------
234 -- {Start Of Comments}
235 --
236 -- Public procedure to check if Name + Prefix/Suffix exceed max length of Name
237 -- column, if so raise error appropriately.
238 --
239 -- {End Of Comments}
240 --
241 procedure ben_chk_col_len (column_type varchar2
242 ,table_name varchar2
243 ,column_value varchar2) is
244 l_length number := length(column_value) ;
245 l_var varchar2(4000):= '*' ;
246
247 BEGIN
248 hr_utility.set_location('Inside ben_chk_col_len ',234);
249 --- pls dont change -- tilak
250 l_var := rpad(l_var,l_length,'*');
251 EXECUTE IMMEDIATE
252 'declare
253 l_column '||table_name||'.'||column_type||'%type ;
254 begin
255 l_column := :1;
256 exception when others then
257 fnd_message.set_name(''BEN'',''BEN_93353_PDC_MAX_LENGTH'');
258 fnd_message.raise_error ;
259 end;'
260 USING l_var;
261 END ben_chk_col_len;
262
263 --
264 procedure raise_error_message( p_table_alias in varchar2,
265 p_object_name in varchar2 ) is
266 l_message varchar2(2000);
267 l_display_name pqh_table_route_tl.display_name%TYPE := null ;
268 --
269 cursor c_display_name is
270 select display_name
271 from pqh_table_route_vl tr
272 where tr.table_alias = p_table_alias
273 and tr.from_clause = 'OAB' ;
274 --
275 begin
276 --
277 l_message := substr(nvl(fnd_message.get,sqlerrm),1,1999) ;
278 --
279 fnd_message.clear;
280 --
281 open c_display_name;
282 fetch c_display_name into l_display_name ;
283 close c_display_name;
284 --
285 fnd_message.set_name('BEN','BEN_93256_PDC_ERROR_STACK');
286 fnd_message.set_token('DISPLAY_NAME',l_display_name||' - '||p_object_name );
287 fnd_message.set_token('DETAILS',l_message);
288 fnd_message.raise_error ;
289 end raise_error_message ;
290 --
291
292 --
293 -- Start Log additions
294 --
295
296 --
297 -- Procedure to store Log details
298 --
299 procedure log_data(p_table_alias in varchar2
300 ,p_pk_id in number
301 ,p_new_name in varchar2
302 ,p_copied_reused_cd in varchar2) is
303 begin
304 hr_utility.set_location('Entering log_data ',5);
305
306 if p_table_alias = 'PGM' then
307 if p_copied_reused_cd = 'COPIED' then
308 g_pgm_tbl_copied(g_pgm_tbl_copied_count).pk_id := p_pk_id;
309 g_pgm_tbl_copied(g_pgm_tbl_copied_count).new_name := p_new_name;
310 g_pgm_tbl_copied_count := g_pgm_tbl_copied_count + 1;
311 else
312 g_pgm_tbl_reused(g_pgm_tbl_reused_count).pk_id := p_pk_id;
313 g_pgm_tbl_reused(g_pgm_tbl_reused_count).new_name := p_new_name;
314 g_pgm_tbl_reused_count := g_pgm_tbl_reused_count + 1;
315 end if;
316
317 elsif p_table_alias = 'PLN' then
318 if p_copied_reused_cd = 'COPIED' then
319 g_pln_tbl_copied(g_pln_tbl_copied_count).pk_id := p_pk_id;
320 g_pln_tbl_copied(g_pln_tbl_copied_count).new_name := p_new_name;
321 g_pln_tbl_copied_count := g_pln_tbl_copied_count + 1;
322 else
323 g_pln_tbl_reused(g_pln_tbl_reused_count).pk_id := p_pk_id;
324 g_pln_tbl_reused(g_pln_tbl_reused_count).new_name := p_new_name;
325 g_pln_tbl_reused_count := g_pln_tbl_reused_count + 1;
326 end if;
327
328 elsif p_table_alias = 'OPT' then
329 if p_copied_reused_cd = 'COPIED' then
330 g_opt_tbl_copied(g_opt_tbl_copied_count).pk_id := p_pk_id;
331 g_opt_tbl_copied(g_opt_tbl_copied_count).new_name := p_new_name;
332 g_opt_tbl_copied_count := g_opt_tbl_copied_count + 1;
333 else
334 g_opt_tbl_reused(g_opt_tbl_reused_count).pk_id := p_pk_id;
335 g_opt_tbl_reused(g_opt_tbl_reused_count).new_name := p_new_name;
336 g_opt_tbl_reused_count := g_opt_tbl_reused_count + 1;
337 end if;
338
339 elsif p_table_alias = 'PTP' then
340 if p_copied_reused_cd = 'COPIED' then
341 g_ptp_tbl_copied(g_ptp_tbl_copied_count).pk_id := p_pk_id;
342 g_ptp_tbl_copied(g_ptp_tbl_copied_count).new_name := p_new_name;
343 g_ptp_tbl_copied_count := g_ptp_tbl_copied_count + 1;
344 else
345 g_ptp_tbl_reused(g_ptp_tbl_reused_count).pk_id := p_pk_id;
346 g_ptp_tbl_reused(g_ptp_tbl_reused_count).new_name := p_new_name;
347 g_ptp_tbl_reused_count := g_ptp_tbl_reused_count + 1;
348 end if;
349
350 elsif p_table_alias = 'EAT' then
351 if p_copied_reused_cd = 'COPIED' then
352 g_eat_tbl_copied(g_eat_tbl_copied_count).pk_id := p_pk_id;
353 g_eat_tbl_copied(g_eat_tbl_copied_count).new_name := p_new_name;
354 g_eat_tbl_copied_count := g_eat_tbl_copied_count + 1;
355 else
356 g_eat_tbl_reused(g_eat_tbl_reused_count).pk_id := p_pk_id;
357 g_eat_tbl_reused(g_eat_tbl_reused_count).new_name := p_new_name;
358 g_eat_tbl_reused_count := g_eat_tbl_reused_count + 1;
359 end if;
360
361 elsif p_table_alias = 'BNB' then
362 if p_copied_reused_cd = 'COPIED' then
363 g_bnb_tbl_copied(g_bnb_tbl_copied_count).pk_id := p_pk_id;
364 g_bnb_tbl_copied(g_bnb_tbl_copied_count).new_name := p_new_name;
365 g_bnb_tbl_copied_count := g_bnb_tbl_copied_count + 1;
366 else
367 g_bnb_tbl_reused(g_bnb_tbl_reused_count).pk_id := p_pk_id;
368 g_bnb_tbl_reused(g_bnb_tbl_reused_count).new_name := p_new_name;
369 g_bnb_tbl_reused_count := g_bnb_tbl_reused_count + 1;
370 end if;
371
372 elsif p_table_alias = 'CLF' then
373 if p_copied_reused_cd = 'COPIED' then
374 g_clf_tbl_copied(g_clf_tbl_copied_count).pk_id := p_pk_id;
375 g_clf_tbl_copied(g_clf_tbl_copied_count).new_name := p_new_name;
376 g_clf_tbl_copied_count := g_clf_tbl_copied_count + 1;
377 else
378 g_clf_tbl_reused(g_clf_tbl_reused_count).pk_id := p_pk_id;
379 g_clf_tbl_reused(g_clf_tbl_reused_count).new_name := p_new_name;
380 g_clf_tbl_reused_count := g_clf_tbl_reused_count + 1;
381 end if;
382
383 elsif p_table_alias = 'HWF' then
384 if p_copied_reused_cd = 'COPIED' then
385 g_hwf_tbl_copied(g_hwf_tbl_copied_count).pk_id := p_pk_id;
386 g_hwf_tbl_copied(g_hwf_tbl_copied_count).new_name := p_new_name;
387 g_hwf_tbl_copied_count := g_hwf_tbl_copied_count + 1;
388 else
389 g_hwf_tbl_reused(g_hwf_tbl_reused_count).pk_id := p_pk_id;
390 g_hwf_tbl_reused(g_hwf_tbl_reused_count).new_name := p_new_name;
391 g_hwf_tbl_reused_count := g_hwf_tbl_reused_count + 1;
392 end if;
393
394 elsif p_table_alias = 'AGF' then
395 if p_copied_reused_cd = 'COPIED' then
396 g_agf_tbl_copied(g_agf_tbl_copied_count).pk_id := p_pk_id;
397 g_agf_tbl_copied(g_agf_tbl_copied_count).new_name := p_new_name;
398 g_agf_tbl_copied_count := g_agf_tbl_copied_count + 1;
399 else
400 g_agf_tbl_reused(g_agf_tbl_reused_count).pk_id := p_pk_id;
401 g_agf_tbl_reused(g_agf_tbl_reused_count).new_name := p_new_name;
402 g_agf_tbl_reused_count := g_agf_tbl_reused_count + 1;
403 end if;
404
405 elsif p_table_alias = 'LSF' then
406 if p_copied_reused_cd = 'COPIED' then
407 g_lsf_tbl_copied(g_lsf_tbl_copied_count).pk_id := p_pk_id;
408 g_lsf_tbl_copied(g_lsf_tbl_copied_count).new_name := p_new_name;
409 g_lsf_tbl_copied_count := g_lsf_tbl_copied_count + 1;
410 else
411 g_lsf_tbl_reused(g_lsf_tbl_reused_count).pk_id := p_pk_id;
412 g_lsf_tbl_reused(g_lsf_tbl_reused_count).new_name := p_new_name;
413 g_lsf_tbl_reused_count := g_lsf_tbl_reused_count + 1;
414 end if;
415
416 elsif p_table_alias = 'PFF' then
417 if p_copied_reused_cd = 'COPIED' then
418 g_pff_tbl_copied(g_pff_tbl_copied_count).pk_id := p_pk_id;
419 g_pff_tbl_copied(g_pff_tbl_copied_count).new_name := p_new_name;
420 g_pff_tbl_copied_count := g_pff_tbl_copied_count + 1;
421 else
422 g_pff_tbl_reused(g_pff_tbl_reused_count).pk_id := p_pk_id;
423 g_pff_tbl_reused(g_pff_tbl_reused_count).new_name := p_new_name;
424 g_pff_tbl_reused_count := g_pff_tbl_reused_count + 1;
425 end if;
426
427 elsif p_table_alias = 'CLA' then
428 if p_copied_reused_cd = 'COPIED' then
429 g_cla_tbl_copied(g_cla_tbl_copied_count).pk_id := p_pk_id;
430 g_cla_tbl_copied(g_cla_tbl_copied_count).new_name := p_new_name;
431 g_cla_tbl_copied_count := g_cla_tbl_copied_count + 1;
432 else
433 g_cla_tbl_reused(g_cla_tbl_reused_count).pk_id := p_pk_id;
434 g_cla_tbl_reused(g_cla_tbl_reused_count).new_name := p_new_name;
435 g_cla_tbl_reused_count := g_cla_tbl_reused_count + 1;
436 end if;
437
438 elsif p_table_alias = 'REG' then
439 if p_copied_reused_cd = 'COPIED' then
440 g_reg_tbl_copied(g_reg_tbl_copied_count).pk_id := p_pk_id;
441 g_reg_tbl_copied(g_reg_tbl_copied_count).new_name := p_new_name;
442 g_reg_tbl_copied_count := g_reg_tbl_copied_count + 1;
443 else
444 g_reg_tbl_reused(g_reg_tbl_reused_count).pk_id := p_pk_id;
445 g_reg_tbl_reused(g_reg_tbl_reused_count).new_name := p_new_name;
446 g_reg_tbl_reused_count := g_reg_tbl_reused_count + 1;
447 end if;
448
449 elsif p_table_alias = 'BNR' then
450 if p_copied_reused_cd = 'COPIED' then
451 g_bnr_tbl_copied(g_bnr_tbl_copied_count).pk_id := p_pk_id;
452 g_bnr_tbl_copied(g_bnr_tbl_copied_count).new_name := p_new_name;
453 g_bnr_tbl_copied_count := g_bnr_tbl_copied_count + 1;
454 else
455 g_bnr_tbl_reused(g_bnr_tbl_reused_count).pk_id := p_pk_id;
456 g_bnr_tbl_reused(g_bnr_tbl_reused_count).new_name := p_new_name;
457 g_bnr_tbl_reused_count := g_bnr_tbl_reused_count + 1;
458 end if;
459
460 elsif p_table_alias = 'BPP' then
461 if p_copied_reused_cd = 'COPIED' then
462 g_bpp_tbl_copied(g_bpp_tbl_copied_count).pk_id := p_pk_id;
463 g_bpp_tbl_copied(g_bpp_tbl_copied_count).new_name := p_new_name;
464 g_bpp_tbl_copied_count := g_bpp_tbl_copied_count + 1;
465 else
466 g_bpp_tbl_reused(g_bpp_tbl_reused_count).pk_id := p_pk_id;
467 g_bpp_tbl_reused(g_bpp_tbl_reused_count).new_name := p_new_name;
468 g_bpp_tbl_reused_count := g_bpp_tbl_reused_count + 1;
469 end if;
470
471 elsif p_table_alias = 'LER' then
472 if p_copied_reused_cd = 'COPIED' then
473 g_ler_tbl_copied(g_ler_tbl_copied_count).pk_id := p_pk_id;
474 g_ler_tbl_copied(g_ler_tbl_copied_count).new_name := p_new_name;
475 g_ler_tbl_copied_count := g_ler_tbl_copied_count + 1;
476 else
477 g_ler_tbl_reused(g_ler_tbl_reused_count).pk_id := p_pk_id;
478 g_ler_tbl_reused(g_ler_tbl_reused_count).new_name := p_new_name;
479 g_ler_tbl_reused_count := g_ler_tbl_reused_count + 1;
480 end if;
481
482 elsif p_table_alias = 'PSL' then
483 if p_copied_reused_cd = 'COPIED' then
484 g_psl_tbl_copied(g_psl_tbl_copied_count).pk_id := p_pk_id;
485 g_psl_tbl_copied(g_psl_tbl_copied_count).new_name := p_new_name;
486 g_psl_tbl_copied_count := g_psl_tbl_copied_count + 1;
487 else
488 g_psl_tbl_reused(g_psl_tbl_reused_count).pk_id := p_pk_id;
489 g_psl_tbl_reused(g_psl_tbl_reused_count).new_name := p_new_name;
490 g_psl_tbl_reused_count := g_psl_tbl_reused_count + 1;
491 end if;
492
493 elsif p_table_alias = 'ELP' then
494 if p_copied_reused_cd = 'COPIED' then
495 g_elp_tbl_copied(g_elp_tbl_copied_count).pk_id := p_pk_id;
496 g_elp_tbl_copied(g_elp_tbl_copied_count).new_name := p_new_name;
497 g_elp_tbl_copied_count := g_elp_tbl_copied_count + 1;
498 else
499 g_elp_tbl_reused(g_elp_tbl_reused_count).pk_id := p_pk_id;
500 g_elp_tbl_reused(g_elp_tbl_reused_count).new_name := p_new_name;
501 g_elp_tbl_reused_count := g_elp_tbl_reused_count + 1;
502 end if;
503
504 elsif p_table_alias = 'DCE' then
505 if p_copied_reused_cd = 'COPIED' then
506 g_dce_tbl_copied(g_dce_tbl_copied_count).pk_id := p_pk_id;
507 g_dce_tbl_copied(g_dce_tbl_copied_count).new_name := p_new_name;
508 g_dce_tbl_copied_count := g_dce_tbl_copied_count + 1;
509 else
510 g_dce_tbl_reused(g_dce_tbl_reused_count).pk_id := p_pk_id;
511 g_dce_tbl_reused(g_dce_tbl_reused_count).new_name := p_new_name;
512 g_dce_tbl_reused_count := g_dce_tbl_reused_count + 1;
513 end if;
514
515 elsif p_table_alias = 'GOS' then
516 if p_copied_reused_cd = 'COPIED' then
517 g_gos_tbl_copied(g_gos_tbl_copied_count).pk_id := p_pk_id;
518 g_gos_tbl_copied(g_gos_tbl_copied_count).new_name := p_new_name;
519 g_gos_tbl_copied_count := g_gos_tbl_copied_count + 1;
520 else
521 g_gos_tbl_reused(g_gos_tbl_reused_count).pk_id := p_pk_id;
522 g_gos_tbl_reused(g_gos_tbl_reused_count).new_name := p_new_name;
523 g_gos_tbl_reused_count := g_gos_tbl_reused_count + 1;
524 end if;
525
526 elsif p_table_alias = 'BNG' then
527 if p_copied_reused_cd = 'COPIED' then
528 g_bng_tbl_copied(g_bng_tbl_copied_count).pk_id := p_pk_id;
529 g_bng_tbl_copied(g_bng_tbl_copied_count).new_name := p_new_name;
530 g_bng_tbl_copied_count := g_bng_tbl_copied_count + 1;
531 else
532 g_bng_tbl_reused(g_bng_tbl_reused_count).pk_id := p_pk_id;
533 g_bng_tbl_reused(g_bng_tbl_reused_count).new_name := p_new_name;
534 g_bng_tbl_reused_count := g_bng_tbl_reused_count + 1;
535 end if;
536
537 elsif p_table_alias = 'PDL' then
538 if p_copied_reused_cd = 'COPIED' then
539 g_pdl_tbl_copied(g_pdl_tbl_copied_count).pk_id := p_pk_id;
540 g_pdl_tbl_copied(g_pdl_tbl_copied_count).new_name := p_new_name;
541 g_pdl_tbl_copied_count := g_pdl_tbl_copied_count + 1;
542 else
543 g_pdl_tbl_reused(g_pdl_tbl_reused_count).pk_id := p_pk_id;
544 g_pdl_tbl_reused(g_pdl_tbl_reused_count).new_name := p_new_name;
545 g_pdl_tbl_reused_count := g_pdl_tbl_reused_count + 1;
546 end if;
547
548 elsif p_table_alias = 'SVA' then
549 if p_copied_reused_cd = 'COPIED' then
550 g_sva_tbl_copied(g_sva_tbl_copied_count).pk_id := p_pk_id;
551 g_sva_tbl_copied(g_sva_tbl_copied_count).new_name := p_new_name;
552 g_sva_tbl_copied_count := g_sva_tbl_copied_count + 1;
553 else
554 g_sva_tbl_reused(g_sva_tbl_reused_count).pk_id := p_pk_id;
555 g_sva_tbl_reused(g_sva_tbl_reused_count).new_name := p_new_name;
556 g_sva_tbl_reused_count := g_sva_tbl_reused_count + 1;
557 end if;
558
559 elsif p_table_alias = 'CPL' then
560 if p_copied_reused_cd = 'COPIED' then
561 g_cpl_tbl_copied(g_cpl_tbl_copied_count).pk_id := p_pk_id;
562 g_cpl_tbl_copied(g_cpl_tbl_copied_count).new_name := p_new_name;
563 g_cpl_tbl_copied_count := g_cpl_tbl_copied_count + 1;
564 else
565 g_cpl_tbl_reused(g_cpl_tbl_reused_count).pk_id := p_pk_id;
566 g_cpl_tbl_reused(g_cpl_tbl_reused_count).new_name := p_new_name;
567 g_cpl_tbl_reused_count := g_cpl_tbl_reused_count + 1;
568 end if;
569
570 elsif p_table_alias = 'CBP' then
571 if p_copied_reused_cd = 'COPIED' then
572 g_cbp_tbl_copied(g_cbp_tbl_copied_count).pk_id := p_pk_id;
573 g_cbp_tbl_copied(g_cbp_tbl_copied_count).new_name := p_new_name;
574 g_cbp_tbl_copied_count := g_cbp_tbl_copied_count + 1;
575 else
576 g_cbp_tbl_reused(g_cbp_tbl_reused_count).pk_id := p_pk_id;
577 g_cbp_tbl_reused(g_cbp_tbl_reused_count).new_name := p_new_name;
578 g_cbp_tbl_reused_count := g_cbp_tbl_reused_count + 1;
579 end if;
580
581 elsif p_table_alias = 'CPT' then
582 if p_copied_reused_cd = 'COPIED' then
583 g_cpt_tbl_copied(g_cpt_tbl_copied_count).pk_id := p_pk_id;
584 g_cpt_tbl_copied(g_cpt_tbl_copied_count).new_name := p_new_name;
585 g_cpt_tbl_copied_count := g_cpt_tbl_copied_count + 1;
586 else
587 g_cpt_tbl_reused(g_cpt_tbl_reused_count).pk_id := p_pk_id;
588 g_cpt_tbl_reused(g_cpt_tbl_reused_count).new_name := p_new_name;
589 g_cpt_tbl_reused_count := g_cpt_tbl_reused_count + 1;
590 end if;
591
592 elsif p_table_alias = 'FFF' then
593 if p_copied_reused_cd = 'COPIED' then
594 g_fff_tbl_copied(g_fff_tbl_copied_count).pk_id := p_pk_id;
595 g_fff_tbl_copied(g_fff_tbl_copied_count).new_name := p_new_name;
596 g_fff_tbl_copied_count := g_fff_tbl_copied_count + 1;
597 else
598 g_fff_tbl_reused(g_fff_tbl_reused_count).pk_id := p_pk_id;
599 g_fff_tbl_reused(g_fff_tbl_reused_count).new_name := p_new_name;
600 g_fff_tbl_reused_count := g_fff_tbl_reused_count + 1;
601 end if;
602
603 elsif p_table_alias = 'ABR' then
604 if p_copied_reused_cd = 'COPIED' then
605 g_abr_tbl_copied(g_abr_tbl_copied_count).pk_id := p_pk_id;
606 g_abr_tbl_copied(g_abr_tbl_copied_count).new_name := p_new_name;
607 g_abr_tbl_copied_count := g_abr_tbl_copied_count + 1;
608 else
609 g_abr_tbl_reused(g_abr_tbl_reused_count).pk_id := p_pk_id;
610 g_abr_tbl_reused(g_abr_tbl_reused_count).new_name := p_new_name;
611 g_abr_tbl_reused_count := g_abr_tbl_reused_count + 1;
612 end if;
613
614 elsif p_table_alias = 'APR' then
615 if p_copied_reused_cd = 'COPIED' then
616 g_apr_tbl_copied(g_apr_tbl_copied_count).pk_id := p_pk_id;
617 g_apr_tbl_copied(g_apr_tbl_copied_count).new_name := p_new_name;
618 g_apr_tbl_copied_count := g_apr_tbl_copied_count + 1;
619 else
620 g_apr_tbl_reused(g_apr_tbl_reused_count).pk_id := p_pk_id;
621 g_apr_tbl_reused(g_apr_tbl_reused_count).new_name := p_new_name;
622 g_apr_tbl_reused_count := g_apr_tbl_reused_count + 1;
623 end if;
624
625 elsif p_table_alias = 'VPF' then
626 if p_copied_reused_cd = 'COPIED' then
627 g_vpf_tbl_copied(g_vpf_tbl_copied_count).pk_id := p_pk_id;
628 g_vpf_tbl_copied(g_vpf_tbl_copied_count).new_name := p_new_name;
629 g_vpf_tbl_copied_count := g_vpf_tbl_copied_count + 1;
630 else
631 g_vpf_tbl_reused(g_vpf_tbl_reused_count).pk_id := p_pk_id;
632 g_vpf_tbl_reused(g_vpf_tbl_reused_count).new_name := p_new_name;
633 g_vpf_tbl_reused_count := g_vpf_tbl_reused_count + 1;
634 end if;
635
636 elsif p_table_alias = 'CCM' then
637 if p_copied_reused_cd = 'COPIED' then
638 g_ccm_tbl_copied(g_ccm_tbl_copied_count).pk_id := p_pk_id;
639 g_ccm_tbl_copied(g_ccm_tbl_copied_count).new_name := p_new_name;
640 g_ccm_tbl_copied_count := g_ccm_tbl_copied_count + 1;
641 else
642 g_ccm_tbl_reused(g_ccm_tbl_reused_count).pk_id := p_pk_id;
643 g_ccm_tbl_reused(g_ccm_tbl_reused_count).new_name := p_new_name;
644 g_ccm_tbl_reused_count := g_ccm_tbl_reused_count + 1;
645 end if;
646
647 elsif p_table_alias = 'ACP' then
648 if p_copied_reused_cd = 'COPIED' then
649 g_acp_tbl_copied(g_acp_tbl_copied_count).pk_id := p_pk_id;
650 g_acp_tbl_copied(g_acp_tbl_copied_count).new_name := p_new_name;
651 g_acp_tbl_copied_count := g_acp_tbl_copied_count + 1;
652 else
653 g_acp_tbl_reused(g_acp_tbl_reused_count).pk_id := p_pk_id;
654 g_acp_tbl_reused(g_acp_tbl_reused_count).new_name := p_new_name;
655 g_acp_tbl_reused_count := g_acp_tbl_reused_count + 1;
656 end if;
657 elsif p_table_alias = 'EGL' then
658 --
659 -- Bug 4169120 - Rate By Criteria
660 --
661 if p_copied_reused_cd = 'COPIED' then
662 g_egl_tbl_copied(g_egl_tbl_copied_count).pk_id := p_pk_id;
663 g_egl_tbl_copied(g_egl_tbl_copied_count).new_name := p_new_name;
664 g_egl_tbl_copied_count := g_egl_tbl_copied_count + 1;
665 else
666 g_egl_tbl_reused(g_egl_tbl_reused_count).pk_id := p_pk_id;
667 g_egl_tbl_reused(g_egl_tbl_reused_count).new_name := p_new_name;
668 g_egl_tbl_reused_count := g_egl_tbl_reused_count + 1;
669 end if;
670 end if;
671
672 hr_utility.set_location('Leaving log_data ',100);
673 end log_data;
674 --
675 --
676 -- Procedure to store Log details
677 --
678 procedure init_log_tbl is
679 begin
680 hr_utility.set_location('Entering init_log_tbl ',5);
681
682 g_pgm_tbl_copied.delete;
683 g_pgm_tbl_copied(0) := null ;
684 g_pgm_tbl_copied_count := 0 ;
685 g_pgm_tbl_reused.delete;
686 g_pgm_tbl_reused(0) := null ;
687 g_pgm_tbl_reused_count := 0 ;
688
689 g_pln_tbl_copied.delete;
690 g_pln_tbl_copied(0) := null ;
691 g_pln_tbl_copied_count := 0 ;
692 g_pln_tbl_reused.delete;
693 g_pln_tbl_reused(0) := null ;
694 g_pln_tbl_reused_count := 0 ;
695
696 g_opt_tbl_copied.delete;
697 g_opt_tbl_copied(0) := null ;
698 g_opt_tbl_copied_count := 0 ;
699 g_opt_tbl_reused.delete;
700 g_opt_tbl_reused(0) := null ;
701 g_opt_tbl_reused_count := 0 ;
702
703 g_ptp_tbl_copied.delete;
704 g_ptp_tbl_copied(0) := null ;
705 g_ptp_tbl_copied_count := 0 ;
706 g_ptp_tbl_reused.delete;
707 g_ptp_tbl_reused(0) := null ;
708 g_ptp_tbl_reused_count := 0 ;
709
710 g_eat_tbl_copied.delete;
711 g_eat_tbl_copied(0) := null ;
712 g_eat_tbl_copied_count := 0 ;
713 g_eat_tbl_reused.delete;
714 g_eat_tbl_reused(0) := null ;
715 g_eat_tbl_reused_count := 0 ;
716
717 g_bnb_tbl_copied.delete;
718 g_bnb_tbl_copied(0) := null ;
719 g_bnb_tbl_copied_count := 0 ;
720 g_bnb_tbl_reused.delete;
721 g_bnb_tbl_reused(0) := null ;
722 g_bnb_tbl_reused_count := 0 ;
723
724 g_clf_tbl_copied.delete;
725 g_clf_tbl_copied(0) := null ;
726 g_clf_tbl_copied_count := 0 ;
727 g_clf_tbl_reused.delete;
728 g_clf_tbl_reused(0) := null ;
729 g_clf_tbl_reused_count := 0 ;
730
731 g_hwf_tbl_copied.delete;
732 g_hwf_tbl_copied(0) := null ;
733 g_hwf_tbl_copied_count := 0 ;
734 g_hwf_tbl_reused.delete;
735 g_hwf_tbl_reused(0) := null ;
736 g_hwf_tbl_reused_count := 0 ;
737
738 g_agf_tbl_copied.delete;
739 g_agf_tbl_copied(0) := null ;
740 g_agf_tbl_copied_count := 0 ;
741 g_agf_tbl_reused.delete;
742 g_agf_tbl_reused(0) := null ;
743 g_agf_tbl_reused_count := 0 ;
744
745 g_lsf_tbl_copied.delete;
746 g_lsf_tbl_copied(0) := null ;
747 g_lsf_tbl_copied_count := 0 ;
748 g_lsf_tbl_reused.delete;
749 g_lsf_tbl_reused(0) := null ;
750 g_lsf_tbl_reused_count := 0 ;
751
752 g_pff_tbl_copied.delete;
753 g_pff_tbl_copied(0) := null ;
754 g_pff_tbl_copied_count := 0 ;
755 g_pff_tbl_reused.delete;
756 g_pff_tbl_reused(0) := null ;
757 g_pff_tbl_reused_count := 0 ;
758
759 g_cla_tbl_copied.delete;
760 g_cla_tbl_copied(0) := null ;
761 g_cla_tbl_copied_count := 0 ;
762 g_cla_tbl_reused.delete;
763 g_cla_tbl_reused(0) := null ;
764 g_cla_tbl_reused_count := 0 ;
765
766 g_reg_tbl_copied.delete;
767 g_reg_tbl_copied(0) := null ;
768 g_reg_tbl_copied_count := 0 ;
769 g_reg_tbl_reused.delete;
770 g_reg_tbl_reused(0) := null ;
771 g_reg_tbl_reused_count := 0 ;
772
773 g_bnr_tbl_copied.delete;
774 g_bnr_tbl_copied(0) := null ;
775 g_bnr_tbl_copied_count := 0 ;
776 g_bnr_tbl_reused.delete;
777 g_bnr_tbl_reused(0) := null ;
778 g_bnr_tbl_reused_count := 0 ;
779
780 g_bpp_tbl_copied.delete;
781 g_bpp_tbl_copied(0) := null ;
782 g_bpp_tbl_copied_count := 0 ;
783 g_bpp_tbl_reused.delete;
784 g_bpp_tbl_reused(0) := null ;
785 g_bpp_tbl_reused_count := 0 ;
786
787 g_ler_tbl_copied.delete;
788 g_ler_tbl_copied(0) := null ;
789 g_ler_tbl_copied_count := 0 ;
790 g_ler_tbl_reused.delete;
791 g_ler_tbl_reused(0) := null ;
792 g_ler_tbl_reused_count := 0 ;
793
794 g_elp_tbl_copied.delete;
795 g_elp_tbl_copied(0) := null ;
796 g_elp_tbl_copied_count := 0 ;
797 g_elp_tbl_reused.delete;
798 g_elp_tbl_reused(0) := null ;
799 g_elp_tbl_reused_count := 0 ;
800
801 g_dce_tbl_copied.delete;
802 g_dce_tbl_copied(0) := null ;
803 g_dce_tbl_copied_count := 0 ;
804 g_dce_tbl_reused.delete;
805 g_dce_tbl_reused(0) := null ;
806 g_dce_tbl_reused_count := 0 ;
807
808 g_gos_tbl_copied.delete;
809 g_gos_tbl_copied(0) := null ;
810 g_gos_tbl_copied_count := 0 ;
811 g_gos_tbl_reused.delete;
812 g_gos_tbl_reused(0) := null ;
813 g_gos_tbl_reused_count := 0 ;
814
815 g_bng_tbl_copied.delete;
816 g_bng_tbl_copied(0) := null ;
817 g_bng_tbl_copied_count := 0 ;
818 g_bng_tbl_reused.delete;
819 g_bng_tbl_reused(0) := null ;
820 g_bng_tbl_reused_count := 0 ;
821
822 g_pdl_tbl_copied.delete;
823 g_pdl_tbl_copied(0) := null ;
824 g_pdl_tbl_copied_count := 0 ;
825 g_pdl_tbl_reused.delete;
826 g_pdl_tbl_reused(0) := null ;
827 g_pdl_tbl_reused_count := 0 ;
828
829 g_sva_tbl_copied.delete;
830 g_sva_tbl_copied(0) := null ;
831 g_sva_tbl_copied_count := 0 ;
832 g_sva_tbl_reused.delete;
833 g_sva_tbl_reused(0) := null ;
834 g_sva_tbl_reused_count := 0 ;
835
836 g_cpl_tbl_copied.delete;
837 g_cpl_tbl_copied(0) := null ;
838 g_cpl_tbl_copied_count := 0 ;
839 g_cpl_tbl_reused.delete;
840 g_cpl_tbl_reused(0) := null ;
841 g_cpl_tbl_reused_count := 0 ;
842
843 g_cbp_tbl_copied.delete;
844 g_cbp_tbl_copied(0) := null ;
845 g_cbp_tbl_copied_count := 0 ;
846 g_cbp_tbl_reused.delete;
847 g_cbp_tbl_reused(0) := null ;
848 g_cbp_tbl_reused_count := 0 ;
849
850 g_cpt_tbl_copied.delete;
851 g_cpt_tbl_copied(0) := null ;
852 g_cpt_tbl_copied_count := 0 ;
853 g_cpt_tbl_reused.delete;
854 g_cpt_tbl_reused(0) := null ;
855 g_cpt_tbl_reused_count := 0 ;
856
857 g_fff_tbl_copied.delete;
858 g_fff_tbl_copied(0) := null ;
859 g_fff_tbl_copied_count := 0 ;
860 g_fff_tbl_reused.delete;
861 g_fff_tbl_reused(0) := null ;
862 g_fff_tbl_reused_count := 0 ;
863
864 g_abr_tbl_copied.delete;
865 g_abr_tbl_copied(0) := null ;
866 g_abr_tbl_copied_count := 0 ;
867 g_abr_tbl_reused.delete;
868 g_abr_tbl_reused(0) := null ;
869 g_abr_tbl_reused_count := 0 ;
870
871 g_apr_tbl_copied.delete;
872 g_apr_tbl_copied(0) := null ;
873 g_apr_tbl_copied_count := 0 ;
874 g_apr_tbl_reused.delete;
875 g_apr_tbl_reused(0) := null ;
876 g_apr_tbl_reused_count := 0 ;
877
878 g_vpf_tbl_copied.delete;
879 g_vpf_tbl_copied(0) := null ;
880 g_vpf_tbl_copied_count := 0 ;
881 g_vpf_tbl_reused.delete;
882 g_vpf_tbl_reused(0) := null ;
883 g_vpf_tbl_reused_count := 0 ;
884
885 g_ccm_tbl_copied.delete;
886 g_ccm_tbl_copied(0) := null ;
887 g_ccm_tbl_copied_count := 0 ;
888 g_ccm_tbl_reused.delete;
889 g_ccm_tbl_reused(0) := null ;
890 g_ccm_tbl_reused_count := 0 ;
891
892 g_acp_tbl_copied.delete;
893 g_acp_tbl_copied(0) := null ;
894 g_acp_tbl_copied_count := 0 ;
895 g_acp_tbl_reused.delete;
896 g_acp_tbl_reused(0) := null ;
897 g_acp_tbl_reused_count := 0 ;
898
899 -- Bug 4081161
900 g_psl_tbl_copied.delete;
901 g_psl_tbl_copied(0) := null ;
902 g_psl_tbl_copied_count := 0 ;
903 g_psl_tbl_reused.delete;
904 g_psl_tbl_reused(0) := null ;
905 g_psl_tbl_reused_count := 0 ;
906 -- Bug 4081161
907
908 --
909 -- Bug 4169120 - Rate By Criteria
910 --
911 g_egl_tbl_copied.delete;
912 g_egl_tbl_copied(0) := null ;
913 g_egl_tbl_copied_count := 0 ;
914 g_egl_tbl_reused.delete;
915 g_egl_tbl_reused(0) := null ;
916 g_egl_tbl_reused_count := 0 ;
917
918 -- NO MAPPING LOG
919 BEN_PD_COPY_TO_BEN_three.g_not_copied_tbl.delete;
920 BEN_PD_COPY_TO_BEN_three.g_not_copied_tbl(0) := null ;
921 BEN_PD_COPY_TO_BEN_three.g_not_copied_tbl_count := 0 ;
922
923 hr_utility.set_location('Leaving init_log_tbl ',100);
924 end init_log_tbl;
925 --
926 -- End Log additions
927 --
928 procedure compile_FFF_rows(
929 p_copy_entity_txn_id in number
930 ,p_effective_date in date
931 ,p_formula_name in varchar2 default null
932 ,p_formula_type_name in varchar2 default null
933 ,p_request_id out nocopy number
934 ) is
935 begin
936 --
937 -- Compile the formula
938 --
939 p_request_id := fnd_request.submit_request
940 (application => 'FF'
941 ,program => 'SINGLECOMPILE'
942 ,argument1 => p_formula_type_name --'Oracle Payroll' formula type
943 ,argument2 => p_formula_name); -- formula name
944
945 --
946 Exception
947 When Others Then
948 p_request_id := Null;
949 end compile_fff_rows;
950 --
951
952 PROCEDURE create_or_update_ff (
953 p_formula_id IN NUMBER,
954 p_effective_start_date IN DATE,
955 p_effective_end_date IN DATE,
956 p_business_group_id IN NUMBER,
957 p_legislation_code IN VARCHAR,
958 p_formula_type_id IN NUMBER,
959 p_formula_name IN VARCHAR,
960 p_description IN VARCHAR,
961 p_formula_text IN LONG,
962 p_sticky_flag IN VARCHAR,
963 p_compile_flag IN VARCHAR,
964 p_last_update_date IN DATE,
965 p_last_updated_by IN NUMBER,
966 p_last_update_login IN NUMBER,
967 p_created_by IN NUMBER,
968 p_creation_date IN DATE,
969 p_process_date IN DATE,
970 p_dml_operation IN VARCHAR,
971 p_datetrack_mode IN VARCHAR
972 )
973 IS
974 BEGIN
975 hr_utility.set_location ('Entering procedure create_or_update_ff creation ',10);
976
977 IF p_dml_operation = hr_api.g_insert
978 THEN
979 hr_utility.set_location (' p_dml_operation' || p_dml_operation, 10);
980 hr_utility.set_location (' p_datetrack_mode' || p_datetrack_mode, 10);
981 hr_utility.set_location (' p_formula_id' || p_formula_id, 10);
982 hr_utility.set_location (' p_process_date' || p_process_date, 10);
983 hr_utility.set_location (' p_effective_start_date'|| p_effective_start_date,10);
984 hr_utility.set_location (' p_effective_end_date' || p_effective_end_date,10);
985
986 --Perform an insert if the dml operation is insert
987
988 INSERT INTO ff_formulas_f
989 (formula_id, effective_start_date, effective_end_date,
990 legislation_code, formula_type_id, formula_name,
991 description, formula_text, sticky_flag,
992 compile_flag, business_group_id, last_update_date,
993 last_updated_by, last_update_login, created_by,
994 creation_date
995 )
996 VALUES (p_formula_id, p_process_date, p_effective_end_date,
997 p_legislation_code, p_formula_type_id, p_formula_name,
998 p_description, p_formula_text, p_sticky_flag,
999 p_compile_flag, p_business_group_id, p_last_update_date,
1000 p_last_updated_by, p_last_update_login, p_created_by,
1001 p_creation_date
1002 );
1003 -- Record created successfully
1004 END IF;
1005
1006 IF p_dml_operation = hr_api.g_update
1007 THEN
1008 hr_utility.set_location (' p_dml_operation' || p_dml_operation, 10);
1009 hr_utility.set_location (' p_datetrack_mode' || p_datetrack_mode, 10);
1010 hr_utility.set_location (' p_formula_id' || p_formula_id, 10);
1011 hr_utility.set_location (' p_process_date' || p_process_date, 10);
1012 hr_utility.set_location (' p_effective_start_date' || p_effective_start_date,10);
1013 hr_utility.set_location (' p_effective_end_date' || p_effective_end_date,10);
1014
1015 IF p_datetrack_mode = hr_api.g_update
1016 THEN
1017 UPDATE ff_formulas_f
1018 SET effective_end_date = (p_process_date - 1),
1019 last_update_date = p_last_update_date,
1020 last_updated_by = p_last_updated_by,
1021 last_update_login = p_last_update_login,
1022 created_by = p_created_by,
1023 creation_date = p_creation_date
1024 WHERE formula_id = p_formula_id
1025 AND effective_start_date = p_effective_start_date
1026 AND effective_end_date = p_effective_end_date
1027 AND business_group_id = p_business_group_id;
1028
1029 INSERT INTO ff_formulas_f
1030 (formula_id, effective_start_date, effective_end_date,
1031 legislation_code, formula_type_id, formula_name,
1032 description, formula_text, sticky_flag,
1033 compile_flag, business_group_id,
1034 last_update_date, last_updated_by,
1035 last_update_login, created_by, creation_date
1036 )
1037 VALUES (p_formula_id, p_process_date, p_effective_end_date,
1038 p_legislation_code, p_formula_type_id, p_formula_name,
1039 p_description, p_formula_text, p_sticky_flag,
1040 p_compile_flag, p_business_group_id,
1041 p_last_update_date, p_last_updated_by,
1042 p_last_update_login, p_created_by, p_creation_date
1043 );
1044 END IF;
1045
1046 IF p_datetrack_mode = hr_api.g_correction
1047 THEN
1048 UPDATE ff_formulas_f
1049 SET legislation_code = p_legislation_code,
1050 formula_type_id = p_formula_type_id,
1051 formula_name = p_formula_name,
1052 description = p_description,
1053 formula_text = p_formula_text,
1054 sticky_flag = p_sticky_flag,
1055 compile_flag = p_compile_flag,
1056 last_update_date = p_last_update_date,
1057 last_updated_by = p_last_updated_by,
1058 last_update_login = p_last_update_login,
1059 created_by = p_created_by,
1060 creation_date = p_creation_date
1061 WHERE formula_id = p_formula_id
1062 AND effective_start_date = p_effective_start_date
1063 AND effective_end_date = p_effective_end_date
1064 AND business_group_id = p_business_group_id;
1065 END IF;
1066
1067 IF p_datetrack_mode = hr_api.g_update_override
1068 THEN
1069 UPDATE ff_formulas_f
1070 SET effective_end_date = (p_process_date - 1),
1071 last_update_date = p_last_update_date,
1072 last_updated_by = p_last_updated_by,
1073 last_update_login = p_last_update_login,
1074 created_by = p_created_by,
1075 creation_date = p_creation_date
1076 WHERE formula_id = p_formula_id
1077 AND effective_start_date = p_effective_start_date
1078 AND effective_end_date = p_effective_end_date
1079 AND business_group_id = p_business_group_id;
1080
1081 DELETE FROM ff_formulas_f
1082 WHERE formula_id = p_formula_id
1083 AND business_group_id = p_business_group_id
1084 AND effective_start_date >= p_process_date;
1085
1086 INSERT INTO ff_formulas_f
1087 (formula_id, effective_start_date, effective_end_date,
1088 legislation_code, formula_type_id, formula_name,
1089 description, formula_text, sticky_flag,
1090 compile_flag, business_group_id,
1091 last_update_date, last_updated_by,
1092 last_update_login, created_by, creation_date
1093 )
1094 VALUES (p_formula_id, p_process_date, -- l_min_esd,
1095 hr_api.g_eot, -- CHANGED FROM HARD-CODED DATE TO HR_API VARIABLE..
1096 p_legislation_code, p_formula_type_id, p_formula_name,
1097 p_description, p_formula_text, p_sticky_flag,
1098 p_compile_flag, p_business_group_id,
1099 p_last_update_date, p_last_updated_by,
1100 p_last_update_login, p_created_by, p_creation_date
1101 );
1102 END IF;
1103
1104 IF p_datetrack_mode = hr_api.g_update_change_insert
1105 THEN
1106 UPDATE ff_formulas_f
1107 SET effective_end_date = (p_process_date - 1),
1108 last_update_date = p_last_update_date,
1109 last_updated_by = p_last_updated_by,
1110 last_update_login = p_last_update_login,
1111 created_by = p_created_by,
1112 creation_date = p_creation_date
1113 WHERE formula_id = p_formula_id
1114 AND business_group_id = p_business_group_id
1115 AND effective_start_date = p_effective_start_date
1116 AND effective_start_date = p_effective_end_date;
1117
1118 INSERT INTO ff_formulas_f
1119 (formula_id, effective_start_date, effective_end_date,
1120 legislation_code, formula_type_id, formula_name,
1121 description, formula_text, sticky_flag,
1122 compile_flag, business_group_id,
1123 last_update_date, last_updated_by,
1124 last_update_login, created_by, creation_date
1125 )
1126 VALUES (p_formula_id, p_process_date, -- l_min_esd,
1127 p_effective_end_date,
1128 p_legislation_code, p_formula_type_id, p_formula_name,
1129 p_description, p_formula_text, p_sticky_flag,
1130 p_compile_flag, p_business_group_id,
1131 p_last_update_date, p_last_updated_by,
1132 p_last_update_login, p_created_by, p_creation_date
1133 );
1134 END IF;
1135 END IF;
1136
1137 hr_utility.set_location ('Leaving procedure create_or_update_ff creation ',10);
1138 --
1139 END create_or_update_ff;
1140 --
1141
1142 PROCEDURE create_fff_rows (
1143 p_validate IN NUMBER DEFAULT 0,
1144 p_copy_entity_txn_id IN NUMBER,
1145 p_effective_date IN DATE,
1146 p_prefix_suffix_text IN VARCHAR2 DEFAULT NULL,
1147 p_reuse_object_flag IN VARCHAR2 DEFAULT NULL,
1148 p_target_business_group_id IN VARCHAR2 DEFAULT NULL,
1149 p_prefix_suffix_cd IN VARCHAR2 DEFAULT NULL
1150 )
1151 IS
1152 --
1153 CURSOR c_unique_fff (l_table_alias VARCHAR2)
1154 IS
1155 SELECT DISTINCT cpe.information1, cpe.information2, cpe.information3,
1156 cpe.information112 NAME, -- 5250824, 5253679 (FF Case Sensitive)
1157 cpe.table_route_id,
1158 cpe.dml_operation, cpe.datetrack_mode
1159 --RKG Modfied for PDW FF Enhancements
1160 FROM ben_copy_entity_results cpe, pqh_table_route tr
1161 WHERE cpe.copy_entity_txn_id = p_copy_entity_txn_id
1162 AND cpe.table_route_id = tr.table_route_id
1163 AND tr.table_alias = l_table_alias
1164 AND cpe.number_of_copies = 1 --ADDITION
1165 GROUP BY cpe.information1,
1166 cpe.information2,
1167 cpe.information3,
1168 cpe.information112,
1169 cpe.table_route_id,
1170 cpe.dml_operation,
1171 cpe.datetrack_mode
1172 order by information1, information2; --added for bug: 5151945
1173
1174 --
1175 CURSOR c_fff_min_max_dates (c_table_route_id NUMBER, c_information1 NUMBER)
1176 IS
1177 SELECT MIN (cpe.information2) min_esd, MAX (cpe.information3) min_eed
1178 FROM ben_copy_entity_results cpe
1179 WHERE cpe.copy_entity_txn_id = p_copy_entity_txn_id
1180 AND cpe.table_route_id = c_table_route_id
1181 AND cpe.information1 = c_information1;
1182
1183 --
1184 CURSOR c_fff (
1185 c_table_route_id NUMBER,
1186 c_information1 NUMBER,
1187 c_information2 DATE,
1188 c_information3 DATE
1189 )
1190 IS
1191 SELECT cpe.*
1192 FROM ben_copy_entity_results cpe
1193 WHERE cpe.copy_entity_txn_id = p_copy_entity_txn_id
1194 AND cpe.table_route_id = c_table_route_id
1195 AND cpe.information1 = c_information1
1196 AND cpe.information2 = c_information2
1197 AND cpe.information3 = c_information3
1198 AND ROWNUM = 1;
1199
1200 -- Date Track target record
1201 CURSOR c_find_fff_in_target (
1202 c_fff_name VARCHAR2,
1203 c_effective_start_date DATE,
1204 c_effective_end_date DATE,
1205 c_business_group_id NUMBER,
1206 c_new_pk_id NUMBER
1207 )
1208 IS
1209 SELECT fff.formula_id new_value
1210 FROM ff_formulas_f fff
1211 WHERE fff.formula_name = c_fff_name -- 5250824, 5253679 (FF Case Sensitive)
1212 AND fff.business_group_id = c_business_group_id
1213 AND fff.formula_id <> c_new_pk_id
1214 AND EXISTS (
1215 SELECT NULL
1216 FROM ff_formulas_f fff1
1217 WHERE fff1.formula_name = c_fff_name -- 5250824 , 5253679 (FF Case Sensitive)
1218 AND fff1.business_group_id = c_business_group_id
1219 AND fff1.effective_start_date <= c_effective_start_date)
1220 AND EXISTS (
1221 SELECT NULL
1222 FROM ff_formulas_f fff2
1223 WHERE fff2.formula_name = c_fff_name -- 5250824, 5253679 (FF Case Sensitive)
1224 AND fff2.business_group_id = c_business_group_id
1225 AND fff2.effective_end_date >= c_effective_end_date);
1226
1227 --
1228 l_current_pk_id NUMBER := NULL;
1229 --UPD START
1230 --
1231 l_update BOOLEAN := FALSE;
1232 l_datetrack_mode VARCHAR2 (80) := hr_api.g_update;
1233 l_process_date DATE;
1234 l_dml_operation ben_copy_entity_results.dml_operation%TYPE;
1235 --
1236 --UPD END
1237 --TEMPIK
1238 l_dt_rec_found BOOLEAN;
1239 --END TEMPIK
1240 l_prev_pk_id NUMBER := NULL;
1241 l_request_id NUMBER := NULL;
1242 l_first_rec BOOLEAN := TRUE;
1243 r_fff c_fff%ROWTYPE;
1244 l_formula_id NUMBER;
1245 l_object_version_number NUMBER;
1246 l_effective_start_date DATE;
1247 l_effective_end_date DATE;
1248 l_prefix pqh_copy_entity_attribs.information1%TYPE
1249 := NULL;
1250 l_suffix pqh_copy_entity_attribs.information1%TYPE
1251 := NULL;
1252 l_new_value NUMBER (15);
1253 l_object_found_in_target BOOLEAN := FALSE;
1254 l_min_esd DATE;
1255 l_max_eed DATE;
1256 l_formula_type_id NUMBER;
1257 l_effective_date DATE;
1258 l_formula_name ff_formulas_f.formula_name%TYPE; -- 5253679 (FF Case Sensitive)
1259 BEGIN
1260 --
1261 hr_utility.set_location ('Entering Formula creation ', 10);
1262
1263 -- Initialization
1264 l_object_found_in_target := FALSE;
1265
1266 -- End Initialization
1267 -- Derive the prefix - sufix
1268 IF p_prefix_suffix_cd = 'PREFIX'
1269 THEN
1270 l_prefix := p_prefix_suffix_text;
1271 ELSIF p_prefix_suffix_cd = 'SUFFIX'
1272 THEN
1273 l_suffix := p_prefix_suffix_text;
1274 ELSE
1275 l_prefix := NULL;
1276 l_suffix := NULL;
1277 END IF;
1278
1279 -- End Prefix Sufix derivation
1280 FOR r_fff_unique IN c_unique_fff ('FFF')
1281 LOOP
1282 IF ( ben_pd_copy_to_ben_one.g_copy_effective_date IS NULL
1283 OR (ben_pd_copy_to_ben_one.g_copy_effective_date IS NOT NULL
1284 AND r_fff_unique.information3 >= ben_pd_copy_to_ben_one.g_copy_effective_date
1285 )
1286 )
1287 THEN
1288 --
1289 hr_utility.set_location ('Formula r_FFF_unique '|| r_fff_unique.information1,10);
1290 hr_utility.set_location ('l_dml_operation ' || l_dml_operation, 10);
1291 -- If reuse objects flag is 'Y' then check for the object in the target business group
1292 -- if found insert the record into PLSql table and exit the loop else try create the
1293 -- object in the target business group
1294 --
1295 l_object_found_in_target := FALSE;
1296 --UPD START
1297 l_update := FALSE;
1298 l_process_date := p_effective_date;
1299 l_dml_operation := r_fff_unique.dml_operation;
1300
1301 --
1302 IF l_dml_operation = 'UPDATE'
1303 THEN
1304 --
1305 l_object_found_in_target := TRUE;
1306
1307 --
1308
1309 IF l_process_date BETWEEN r_fff_unique.information2
1310 AND r_fff_unique.information3
1311 THEN
1312 l_update := TRUE;
1313
1314 IF r_fff_unique.information1 <> NVL (g_pk_tbl (g_count - 1).old_value,-999)
1315 OR NVL (g_pk_tbl (g_count - 1).pk_id_column, '999') <> 'FORMULA_ID'
1316 THEN
1317 g_pk_tbl (g_count).pk_id_column := 'FORMULA_ID';
1318 g_pk_tbl (g_count).old_value := r_fff_unique.information1;
1319 g_pk_tbl (g_count).new_value := r_fff_unique.information1;
1320 g_pk_tbl (g_count).copy_reuse_type := 'REUSED';
1321 g_pk_tbl (g_count).table_route_id := r_fff_unique.table_route_id;
1322 --
1323 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
1324 --
1325 g_count := g_count + 1;
1326 --
1327 log_data ('FFF',l_new_value,l_prefix || r_fff_unique.NAME || l_suffix,'REUSED');
1328 --
1329 END IF;
1330
1331 hr_utility.set_location ('found record for update', 10);
1332 --
1333 ELSE
1334 --
1335 l_update := FALSE;
1336 --
1337 END IF;
1338 ELSE
1339 --
1340 --UPD END
1341 l_min_esd := NULL;
1342 l_max_eed := NULL;
1343 OPEN c_fff_min_max_dates (r_fff_unique.table_route_id,r_fff_unique.information1);
1344 FETCH c_fff_min_max_dates INTO l_min_esd, l_max_eed;
1345
1346 IF ( ben_pd_copy_to_ben_one.g_copy_effective_date IS NOT NULL
1347 AND l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date
1348 )
1349 THEN
1350 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
1351 END IF;
1352
1353 -- l_min_esd := greatest(l_min_esd,r_XXX_unique.information2);
1354 hr_utility.set_location ('Formula l_min_esd,l_max_eed '|| l_min_esd,30);
1355
1356 -- Whether reuse or not always check whether object exists or not.
1357 IF p_reuse_object_flag = 'Y'
1358 THEN
1359 IF c_fff_min_max_dates%FOUND
1360 THEN
1361 -- cursor to find the object
1362 OPEN c_find_fff_in_target (l_prefix|| r_fff_unique.NAME|| l_suffix,
1363 l_min_esd,
1364 l_max_eed,
1365 p_target_business_group_id,
1366 NVL (l_formula_id, -999)
1367 );
1368 FETCH c_find_fff_in_target INTO l_new_value;
1369
1370 IF c_find_fff_in_target%FOUND
1371 THEN
1372 --
1373 --TEMPIK
1374 l_dt_rec_found :=
1375 dt_api.check_min_max_dates (p_base_table_name => 'FF_FORMULAS_F',
1376 p_base_key_column => 'FORMULA_ID',
1377 p_base_key_value => l_new_value,
1378 p_from_date => l_min_esd,
1379 p_to_date => l_max_eed
1380 );
1381
1382 IF l_dt_rec_found
1383 THEN
1384 --END TEMPIK
1385 hr_utility.set_location ('Formula c_find_FFF_in_target found ',40);
1386 --
1387
1388 IF r_fff_unique.information1 <> NVL (g_pk_tbl (g_count - 1).old_value,-999)
1389 OR NVL (g_pk_tbl (g_count - 1).pk_id_column, '999') <>'FORMULA_ID'
1390 THEN
1391 g_pk_tbl (g_count).pk_id_column := 'FORMULA_ID';
1392 g_pk_tbl (g_count).old_value := r_fff_unique.information1;
1393 g_pk_tbl (g_count).new_value := l_new_value;
1394 g_pk_tbl (g_count).copy_reuse_type := 'REUSED';
1395 g_pk_tbl (g_count).table_route_id := r_fff_unique.table_route_id;
1396 --
1397 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
1398 --
1399 g_count := g_count + 1;
1400 --
1401 log_data ('FFF', l_new_value, l_prefix || r_fff_unique.NAME || l_suffix,'REUSED' );
1402 --
1403 END IF;
1404
1405 --
1406 l_object_found_in_target := TRUE;
1407 --TEMPIK
1408 END IF; -- l_dt_rec_found
1409 --END TEMPIK
1410 END IF;
1411
1412 CLOSE c_find_fff_in_target;
1413 --
1414 END IF;
1415 END IF;
1416
1417 --
1418 hr_utility.set_location (' Before l_object_found_in_target ', 50);
1419 hr_utility.set_location (' Before r_FFF_unique.information1 = '|| r_fff_unique.information1,50);
1420 hr_utility.set_location (' Before r_FFF_unique.information2 = '|| r_fff_unique.information2,50);
1421 hr_utility.set_location (' Before r_FFF_unique.information3 = '|| r_fff_unique.information3,50);
1422 CLOSE c_fff_min_max_dates;
1423 END IF;
1424
1425 IF NOT l_object_found_in_target OR l_update
1426 THEN
1427 --
1428 hr_utility.set_location (' l_object_found_in_target ', 60);
1429 OPEN c_fff (r_fff_unique.table_route_id,
1430 r_fff_unique.information1,
1431 r_fff_unique.information2,
1432 r_fff_unique.information3
1433 );
1434 --
1435 FETCH c_fff INTO r_fff;
1436 --
1437 CLOSE c_fff;
1438 --
1439 l_current_pk_id := r_fff.information1;
1440 --
1441 hr_utility.set_location (' l_current_pk_id ' || l_current_pk_id,20);
1442 hr_utility.set_location (' l_prev_pk_id ' || l_prev_pk_id, 20);
1443
1444 --
1445 IF l_current_pk_id = l_prev_pk_id
1446 THEN
1447 --
1448 l_first_rec := FALSE;
1449 --
1450 ELSE
1451 --
1452 l_first_rec := TRUE;
1453 --
1454 END IF;
1455
1456 --
1457 ben_pd_copy_to_ben_one.ben_chk_col_len ('FORMULA_NAME', 'FF_FORMULAS_F',l_prefix|| r_fff.information112|| l_suffix);
1458 l_effective_date := r_fff.information2;
1459
1460 IF ( ben_pd_copy_to_ben_one.g_copy_effective_date IS NOT NULL
1461 AND l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date
1462 )
1463 THEN
1464 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
1465 END IF;
1466
1467 IF l_first_rec AND NOT l_update
1468 THEN
1469 -- Call Create routine.
1470 --
1471 hr_utility.set_location (' In the Insert FF_FORMULAS_F ', 70);
1472
1473 --
1474 --
1475 --
1476 SELECT ff_formulas_s.NEXTVAL
1477 INTO l_formula_id
1478 FROM SYS.DUAL;
1479 --
1480 hr_utility.set_location (' l_formula_id ' || l_formula_id, 80);
1481 hr_utility.set_location (' l_formula_type_id ' || l_formula_type_id,80);
1482 hr_utility.set_location (' name ' || l_prefix || r_fff.information112 || l_suffix,80);
1483 hr_utility.set_location (' esd ' || r_fff.information2, 80);
1484 hr_utility.set_location (' eed ' || r_fff.information3, 80);
1485
1486 l_formula_name := l_prefix || r_fff.information112 || l_suffix ; --5253679 (FF Case Sensitive)
1487 --
1488 create_or_update_ff (p_formula_id => l_formula_id,
1489 p_effective_start_date => r_fff.information2,
1490 p_effective_end_date => r_fff.information3,
1491 p_business_group_id => p_target_business_group_id,
1492 p_legislation_code => r_fff.information13,
1493 p_formula_type_id => r_fff.information160,
1494 p_formula_name => l_formula_name, -- :FORMULA_NAME, 5253679 (FF Case Sensitive)
1495 p_description => r_fff.information151,
1496 p_formula_text => r_fff.information323,
1497 p_sticky_flag => r_fff.information11,
1498 p_compile_flag => r_fff.information12,
1499 p_last_update_date => SYSDATE,
1500 p_last_updated_by => 1,
1501 p_last_update_login => 0,
1502 p_created_by => 1,
1503 p_creation_date => SYSDATE,
1504 p_process_date => l_effective_date,
1505 p_dml_operation => 'INSERT',
1506 p_datetrack_mode => NULL
1507 );
1508 -- p_datetrack_mode is not necessary for dml_operation as INSERT
1509
1510
1511 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1512 -- Update all relevent cer records with new pk_id
1513 hr_utility.set_location ('Before plsql table ', 222);
1514 hr_utility.set_location ('new_value id ' || l_formula_id, 222);
1515 --
1516 g_pk_tbl (g_count).pk_id_column := 'FORMULA_ID';
1517 g_pk_tbl (g_count).old_value := r_fff.information1;
1518 g_pk_tbl (g_count).new_value := l_formula_id;
1519 g_pk_tbl (g_count).copy_reuse_type := 'COPIED';
1520 g_pk_tbl (g_count).table_route_id := r_fff_unique.table_route_id;
1521 --
1522 hr_utility.set_location ('After plsql table ', 222);
1523 --
1524 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
1525 --
1526 g_count := g_count + 1;
1527 --
1528 -- Now call formula compilation.
1529 /*
1530 compile_FFF_rows(
1531 p_copy_entity_txn_id => p_copy_entity_txn_id
1532 ,p_effective_date => p_effective_date
1533 ,p_formula_name =>
1534 replace(upper(l_prefix||r_FFF.information112||l_suffix),' ', '_'),
1535 ,p_formula_type_name => r_FFF.information113
1536 ,p_request_id => l_request_id
1537 );
1538 */
1539 --
1540 log_data ('FFF', l_new_value,l_prefix || r_fff.information112 || l_suffix,'COPIED');
1541 --
1542 ELSE
1543 --
1544 --UPD START
1545 hr_utility.set_location ('Before call to get_dt_modes l_dt_mode'|| l_datetrack_mode,5);
1546
1547 --
1548 IF l_update
1549 THEN
1550 --
1551 l_datetrack_mode := r_fff.datetrack_mode;
1552 --
1553 get_dt_modes (p_effective_date => l_process_date,
1554 p_effective_end_date => r_fff.information3,
1555 p_effective_start_date => r_fff.information2,
1556 p_dml_operation => r_fff.dml_operation,
1557 p_datetrack_mode => l_datetrack_mode
1558 );
1559 -- p_update => l_update
1560 --
1561 l_effective_date := l_process_date;
1562 l_formula_id := r_fff.information1;
1563 l_object_version_number := r_fff.information265;
1564 --
1565
1566 --
1567 hr_utility.set_location ('After call to get_dt_modes l_dt_mode' || l_datetrack_mode,5);
1568 --
1569
1570 l_formula_name := l_prefix || r_fff.information112 || l_suffix ; -- 5253679 (FF Case Sensitive)
1571 --UPD END
1572 -- Call Update routine for the pk_id created in prev run .
1573 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1574 create_or_update_ff (p_formula_id => l_formula_id,
1575 p_effective_start_date => r_fff.information2,
1576 p_effective_end_date => r_fff.information3,
1577 p_business_group_id => p_target_business_group_id,
1578 p_legislation_code => r_fff.information13,
1579 p_formula_type_id => r_fff.information160,
1580 p_formula_name => l_formula_name, -- :FORMULA_NAME, 5253679 (FF Case Sensitive)
1581 p_description => r_fff.information151,
1582 p_formula_text => r_fff.information323,
1583 p_sticky_flag => r_fff.information11,
1584 p_compile_flag => r_fff.information12,
1585 p_last_update_date => SYSDATE,
1586 p_last_updated_by => 1,
1587 p_last_update_login => 0,
1588 p_created_by => 1,
1589 p_creation_date => SYSDATE,
1590 p_process_date => l_effective_date,
1591 p_dml_operation => 'UPDATE',
1592 p_datetrack_mode => l_datetrack_mode
1593 );
1594 ELSE
1595 IF l_dml_operation <> 'UPDATE'
1596 THEN
1597 --
1598 hr_utility.set_location (' l_formula_id ' || l_formula_id,90);
1599 hr_utility.set_location (' l_formula_type_id '|| l_formula_type_id,90);
1600 hr_utility.set_location (' name '|| l_prefix|| r_fff.information112|| l_suffix,90);
1601 hr_utility.set_location (' esd ' || r_fff.information2,90);
1602 hr_utility.set_location (' eed ' || r_fff.information3,90);
1603
1604 l_formula_name := l_prefix || r_fff.information112 || l_suffix ; -- 5253679 (FF Case Sensitive)
1605 --
1606 create_or_update_ff (p_formula_id => l_formula_id,
1607 p_effective_start_date => r_fff.information2,
1608 p_effective_end_date => r_fff.information3,
1609 p_business_group_id => p_target_business_group_id,
1610 p_legislation_code => r_fff.information13,
1611 p_formula_type_id => r_fff.information160,
1612 p_formula_name => l_formula_name, -- :FORMULA_NAME, 5253679 (FF Case Sensitive)
1613 p_description => r_fff.information151,
1614 p_formula_text => r_fff.information323,
1615 p_sticky_flag => r_fff.information11,
1616 p_compile_flag => r_fff.information12,
1617 p_last_update_date => SYSDATE,
1618 p_last_updated_by => 1,
1619 p_last_update_login => 0,
1620 p_created_by => 1,
1621 p_creation_date => SYSDATE,
1622 p_process_date => l_effective_date,
1623 p_dml_operation => 'INSERT',
1624 p_datetrack_mode => NULL
1625 );
1626 -- p_datetrack_mode is not necessary for dml_operation as INSERT
1627 --
1628 -- Do we need to call it twice ?
1629 -- Now call formula compilation.
1630 --
1631 /*
1632 compile_FFF_rows(
1633 p_copy_entity_txn_id => p_copy_entity_txn_id
1634 ,p_effective_date => p_effective_date
1635 ,p_formula_name =>
1636 replace(upper(l_prefix||r_FFF.information112||l_suffix),' ', '_'),
1637 ,p_formula_type_name => r_FFF.information113
1638 ,p_request_id => l_request_id
1639 );
1640 */
1641 --
1642 END IF;
1643 END IF;
1644 END IF;
1645
1646 l_prev_pk_id := l_current_pk_id;
1647 --
1648 END IF;
1649 --
1650 END IF;
1651 --
1652 END LOOP;
1653
1654 hr_utility.set_location ('Leaving Formula creation ', 10);
1655
1656 EXCEPTION
1657 WHEN OTHERS
1658 THEN
1659 --
1660 raise_error_message ('FFF',l_prefix || r_fff.information112 || l_suffix);
1661 --
1662 END create_fff_rows;
1663 --
1664 --
1665 ---------------------------------------------------------------
1666 ----------------------< create_EAT_rows >-----------------------
1667 ---------------------------------------------------------------
1668 --
1669 procedure create_EAT_rows
1670 (
1671 p_validate in number default 0
1672 ,p_copy_entity_txn_id in number
1673 ,p_effective_date in date
1674 ,p_prefix_suffix_text in varchar2 default null
1675 ,p_reuse_object_flag in varchar2 default null
1676 ,p_target_business_group_id in varchar2 default null
1677 ,p_prefix_suffix_cd in varchar2 default null
1678 ) is
1679 --
1680 cursor c_unique_EAT(l_table_alias varchar2) is
1681 select distinct cpe.information1,
1682 cpe.information2,
1683 cpe.information3,
1684 cpe.information170 name,
1685 cpe.table_route_id
1686 from ben_copy_entity_results cpe,
1687 pqh_table_route tr
1688 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1689 and cpe.table_route_id = tr.table_route_id
1690 -- and tr.where_clause = l_BEN_ACTN_TYP
1691 and tr.table_alias = l_table_alias
1692 group by cpe.information1,cpe.information2,cpe.information3,
1693 cpe.information170, cpe.table_route_id
1694 order by information1, information2; --added for bug: 5151945
1695 --
1696 --
1697 cursor c_EAT_min_max_dates(c_table_route_id number,
1698 c_information1 number) is
1699 select
1700 min(cpe.information2) min_esd,
1701 max(cpe.information3) min_eed
1702 from ben_copy_entity_results cpe
1703 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1704 and cpe.table_route_id = c_table_route_id
1705 and cpe.information1 = c_information1 ;
1706 --
1707 cursor c_EAT(c_table_route_id number,
1708 c_information1 number,
1709 c_information2 date,
1710 c_information3 date ) is
1711 select
1712 cpe.*
1713 from ben_copy_entity_results cpe
1714 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1715 and cpe.table_route_id = c_table_route_id
1716 and cpe.information1 = c_information1
1717 and rownum = 1 ;
1718 -- Date Track target record
1719 cursor c_find_EAT_in_target( c_EAT_name varchar2,
1720 c_effective_start_date date,
1721 c_effective_end_date date,
1722 c_business_group_id number,
1723 c_new_pk_id number) is
1724 select
1725 EAT.actn_typ_id new_value
1726 from BEN_ACTN_TYP EAT
1727 where
1728 EAT.name = c_EAT_name and
1729 EAT.business_group_id = c_business_group_id
1730 and EAT.actn_typ_id <> c_new_pk_id
1731 ;
1732 --
1733 l_current_pk_id number := null ;
1734 --UPD START
1735 --
1736 l_update boolean := false ;
1737 l_datetrack_mode varchar2(80) := hr_api.g_update;
1738 l_process_date date;
1739 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
1740 --
1741 --UPD END
1742 l_prev_pk_id number := null ;
1743 l_first_rec boolean := true ;
1744 r_EAT c_EAT%rowtype;
1745 l_actn_typ_id number ;
1746 l_object_version_number number ;
1747 l_effective_start_date date ;
1748 l_effective_end_date date ;
1749 l_prefix pqh_copy_entity_attribs.information1%type := null;
1750 l_suffix pqh_copy_entity_attribs.information1%type := null;
1751 l_new_value number(15);
1752 l_object_found_in_target boolean := false ;
1753 l_min_esd date;
1754 l_max_eed date;
1755 --
1756 begin
1757 -- Initialization
1758 l_object_found_in_target := false ;
1759 -- End Initialization
1760 -- Derive the prefix - sufix
1761 if p_prefix_suffix_cd = 'PREFIX' then
1762 l_prefix := p_prefix_suffix_text ;
1763 elsif p_prefix_suffix_cd = 'SUFFIX' then
1764 l_suffix := p_prefix_suffix_text ;
1765 else
1766 l_prefix := null ;
1767 l_suffix := null ;
1768 end if ;
1769 -- End Prefix Sufix derivation
1770 for r_EAT_unique in c_unique_EAT('EAT') loop
1771 --
1772 hr_utility.set_location(' r_EAT_unique.table_route_id '||r_EAT_unique.table_route_id,10);
1773 hr_utility.set_location(' r_EAT_unique.information1 '||r_EAT_unique.information1,10);
1774 hr_utility.set_location( 'r_EAT_unique.information2 '||r_EAT_unique.information2,10);
1775 hr_utility.set_location( 'r_EAT_unique.information3 '||r_EAT_unique.information3,10);
1776 -- If reuse objects flag is 'Y' then check for the object in the target business group
1777 -- if found insert the record into PLSql table and exit the loop else try create the
1778 -- object in the target business group
1779 --
1780 l_object_found_in_target := false ;
1781 l_min_esd := null ;
1782 l_max_eed := null ;
1783 --
1784 open c_EAT(r_EAT_unique.table_route_id,
1785 r_EAT_unique.information1,
1786 r_EAT_unique.information2,
1787 r_EAT_unique.information3 ) ;
1788 --
1789 fetch c_EAT into r_EAT ;
1790 --
1791 close c_EAT ;
1792 --
1793 -- if p_reuse_object_flag = 'Y' then /* Always Reuse Action Types, Never create */
1794 -- cursor to find the object
1795 open c_find_EAT_in_target(r_EAT_unique.name, r_EAT_unique.information2,l_max_eed,
1796 p_target_business_group_id, nvl(l_actn_typ_id, -999) ) ;
1797 fetch c_find_EAT_in_target into l_new_value ;
1798 if c_find_EAT_in_target%found then
1799 --
1800 if r_EAT_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
1801 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'ACTN_TYP_ID' then
1802 g_pk_tbl(g_count).pk_id_column := 'ACTN_TYP_ID' ;
1803 g_pk_tbl(g_count).old_value := r_EAT_unique.information1 ;
1804 g_pk_tbl(g_count).new_value := l_new_value ;
1805 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
1806 g_pk_tbl(g_count).table_route_id := r_EAT_unique.table_route_id;
1807 --
1808 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
1809 --
1810 g_count := g_count + 1 ;
1811 end if ;
1812 --
1813 l_object_found_in_target := true ;
1814 end if;
1815 close c_find_EAT_in_target ;
1816 --
1817 -- end if ;
1818 --
1819 -- NEVER CREATE ACTION TYPES. ALWAYS NEED TO BE REUSED
1820 /*
1821 if not l_object_found_in_target then
1822 --
1823 l_current_pk_id := r_EAT.information1;
1824 --
1825 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
1826 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
1827 --
1828 if l_current_pk_id = l_prev_pk_id then
1829 --
1830 l_first_rec := false ;
1831 --
1832 else
1833 --
1834 l_first_rec := true ;
1835 --
1836 end if ;
1837 --
1838 if l_first_rec then
1839 -- Call Create routine.
1840 hr_utility.set_location(' BEN_ACTN_TYP CREATE_ACTION_TYPE ',20);
1841 BEN_ACTION_TYPE_API.CREATE_ACTION_TYPE(
1842 --
1843 P_VALIDATE => false
1844 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
1845 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
1846 --
1847
1848 ,P_ACTN_TYP_ID => l_actn_typ_id
1849 ,P_DESCRIPTION => r_EAT.INFORMATION185
1850 ,P_EAT_ATTRIBUTE1 => r_EAT.INFORMATION111
1851 ,P_EAT_ATTRIBUTE10 => r_EAT.INFORMATION120
1852 ,P_EAT_ATTRIBUTE11 => r_EAT.INFORMATION121
1853 ,P_EAT_ATTRIBUTE12 => r_EAT.INFORMATION122
1854 ,P_EAT_ATTRIBUTE13 => r_EAT.INFORMATION123
1855 ,P_EAT_ATTRIBUTE14 => r_EAT.INFORMATION124
1856 ,P_EAT_ATTRIBUTE15 => r_EAT.INFORMATION125
1857 ,P_EAT_ATTRIBUTE16 => r_EAT.INFORMATION126
1858 ,P_EAT_ATTRIBUTE17 => r_EAT.INFORMATION127
1859 ,P_EAT_ATTRIBUTE18 => r_EAT.INFORMATION128
1860 ,P_EAT_ATTRIBUTE19 => r_EAT.INFORMATION129
1861 ,P_EAT_ATTRIBUTE2 => r_EAT.INFORMATION112
1862 ,P_EAT_ATTRIBUTE20 => r_EAT.INFORMATION130
1863 ,P_EAT_ATTRIBUTE21 => r_EAT.INFORMATION131
1864 ,P_EAT_ATTRIBUTE22 => r_EAT.INFORMATION132
1865 ,P_EAT_ATTRIBUTE23 => r_EAT.INFORMATION133
1866 ,P_EAT_ATTRIBUTE24 => r_EAT.INFORMATION134
1867 ,P_EAT_ATTRIBUTE25 => r_EAT.INFORMATION135
1868 ,P_EAT_ATTRIBUTE26 => r_EAT.INFORMATION136
1869 ,P_EAT_ATTRIBUTE27 => r_EAT.INFORMATION137
1870 ,P_EAT_ATTRIBUTE28 => r_EAT.INFORMATION138
1871 ,P_EAT_ATTRIBUTE29 => r_EAT.INFORMATION139
1872 ,P_EAT_ATTRIBUTE3 => r_EAT.INFORMATION113
1873 ,P_EAT_ATTRIBUTE30 => r_EAT.INFORMATION140
1874 ,P_EAT_ATTRIBUTE4 => r_EAT.INFORMATION114
1875 ,P_EAT_ATTRIBUTE5 => r_EAT.INFORMATION115
1876 ,P_EAT_ATTRIBUTE6 => r_EAT.INFORMATION116
1877 ,P_EAT_ATTRIBUTE7 => r_EAT.INFORMATION117
1878 ,P_EAT_ATTRIBUTE8 => r_EAT.INFORMATION118
1879 ,P_EAT_ATTRIBUTE9 => r_EAT.INFORMATION119
1880 ,P_EAT_ATTRIBUTE_CATEGORY => r_EAT.INFORMATION110
1881 ,P_NAME => l_prefix || r_EAT.INFORMATION170 || l_suffix
1882 ,P_TYPE_CD => r_EAT.INFORMATION11
1883 --
1884 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
1885 );
1886 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
1887 -- Update all relevent cer records with new pk_id
1888 hr_utility.set_location('Before plsql table ',222);
1889 hr_utility.set_location('new_value id '||l_actn_typ_id,222);
1890 g_pk_tbl(g_count).pk_id_column := 'ACTN_TYP_ID' ;
1891 g_pk_tbl(g_count).old_value := r_EAT.information1 ;
1892 g_pk_tbl(g_count).new_value := l_ACTN_TYP_ID ;
1893 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
1894 g_pk_tbl(g_count).table_route_id := r_EAT_unique.table_route_id;
1895 hr_utility.set_location('After plsql table ',222);
1896 --
1897 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
1898 --
1899 g_count := g_count + 1 ;
1900 end if;
1901 --
1902 l_prev_pk_id := l_current_pk_id ;
1903 --
1904 end if;
1905 --
1906 */
1907 end loop;
1908 --
1909 exception when others then
1910 --
1911 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'EAT',r_eat.information5 );
1912 --
1913 end create_EAT_rows;
1914
1915 -- ----------------------------------------------------------------------------
1916 --
1917 ---------------------------------------------------------------
1918 ----------------------< create_CPL_rows >-----------------------
1919 ---------------------------------------------------------------
1920 --
1921 procedure create_CPL_rows
1922 (
1923 p_validate in number default 0
1924 ,p_copy_entity_txn_id in number
1925 ,p_effective_date in date
1926 ,p_prefix_suffix_text in varchar2 default null
1927 ,p_reuse_object_flag in varchar2 default null
1928 ,p_target_business_group_id in varchar2 default null
1929 ,p_prefix_suffix_cd in varchar2 default null
1930 ) is
1931 --
1932 l_PGM_ID number;
1933 cursor c_unique_CPL(l_table_alias varchar2) is
1934 select distinct cpe.information1,
1935 cpe.information2,
1936 cpe.information3,
1937 cpe.INFORMATION170 name,
1938 cpe.table_route_id,
1939 cpe.dml_operation,
1940 cpe.datetrack_mode
1941 from ben_copy_entity_results cpe,
1942 pqh_table_route tr
1943 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1944 and cpe.table_route_id = tr.table_route_id
1945 -- and tr.where_clause = l_BEN_CMBN_PLIP_F
1946 and tr.table_alias = l_table_alias
1947 and cpe.number_of_copies = 1 -- ADDITION
1948 group by cpe.information1,cpe.information2,cpe.information3, cpe.information170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
1949 order by information1, information2; --added for bug: 5151945
1950 --
1951 --
1952 cursor c_CPL_min_max_dates(c_table_route_id number,
1953 c_information1 number) is
1954 select
1955 min(cpe.information2) min_esd,
1956 max(cpe.information3) min_eed
1957 from ben_copy_entity_results cpe
1958 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1959 and cpe.table_route_id = c_table_route_id
1960 and cpe.information1 = c_information1 ;
1961 --
1962 cursor c_CPL(c_table_route_id number,
1963 c_information1 number,
1964 c_information2 date,
1965 c_information3 date ) is
1966 select
1967 cpe.*
1968 from ben_copy_entity_results cpe
1969 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
1970 and cpe.table_route_id = c_table_route_id
1971 and cpe.information1 = c_information1
1972 and cpe.information2 = c_information2
1973 and cpe.information3 = c_information3
1974 and rownum = 1 ;
1975 -- Date Track target record
1976 cursor c_find_CPL_in_target( c_CPL_name varchar2,
1977 c_effective_start_date date,
1978 c_effective_end_date date,
1979 c_business_group_id number,
1980 c_new_pk_id number) is
1981 select
1982 CPL.cmbn_plip_id new_value
1983 from BEN_CMBN_PLIP_F CPL
1984 where CPL.name = c_CPL_name and
1985 nvl(CPL.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
1986 CPL.business_group_id = c_business_group_id
1987 and CPL.cmbn_plip_id <> c_new_pk_id
1988 --TEMPIK
1989 and c_effective_start_date between effective_start_date
1990 and effective_end_date ;
1991 --END TEMPIK
1992 /*TEMPIK
1993 and exists ( select null
1994 from BEN_CMBN_PLIP_F CPL1
1995 where CPL1.name = c_CPL_name and
1996 nvl(CPL1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
1997 CPL1.business_group_id = c_business_group_id
1998 and CPL1.effective_start_date <= c_effective_start_date )
1999 and exists ( select null
2000 from BEN_CMBN_PLIP_F CPL2
2001 where CPL2.name = c_CPL_name and
2002 nvl(CPL2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
2003 CPL2.business_group_id = c_business_group_id
2004 and CPL2.effective_end_date >= c_effective_end_date )
2005 ;
2006 TEMPIK */
2007 --TEMPIK
2008 l_dt_rec_found boolean ;
2009 --END TEMPIK
2010 --
2011 -- Date Track target record
2012 --
2013 cursor c_find_CPL_name_in_target( c_CPL_name varchar2,
2014 c_effective_start_date date,
2015 c_effective_end_date date,
2016 c_business_group_id number,
2017 c_new_pk_id number) is
2018 select
2019 CPL.cmbn_plip_id new_value
2020 from BEN_CMBN_PLIP_F CPL
2021 where CPL.name = c_CPL_name and
2022 CPL.business_group_id = c_business_group_id
2023 and CPL.cmbn_plip_id <> c_new_pk_id
2024 and exists ( select null
2025 from BEN_CMBN_PLIP_F CPL1
2026 where CPL1.name = c_CPL_name and
2027 CPL1.business_group_id = c_business_group_id
2028 and CPL1.effective_start_date <= c_effective_start_date )
2029 and exists ( select null
2030 from BEN_CMBN_PLIP_F CPL2
2031 where CPL2.name = c_CPL_name and
2032 CPL2.business_group_id = c_business_group_id
2033 and CPL2.effective_end_date >= c_effective_end_date )
2034 ;
2035 --
2036 l_current_pk_id number := null ;
2037 --UPD START
2038 --
2039 l_update boolean := false ;
2040 l_datetrack_mode varchar2(80) := hr_api.g_update;
2041 l_process_date date;
2042 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
2043 --
2044 --UPD END
2045 l_prev_pk_id number := null ;
2046 l_first_rec boolean := true ;
2047 r_CPL c_CPL%rowtype;
2048 l_cmbn_plip_id number ;
2049 l_object_version_number number ;
2050 l_effective_start_date date ;
2051 l_effective_end_date date ;
2052 l_prefix pqh_copy_entity_attribs.information1%type := null;
2053 l_suffix pqh_copy_entity_attribs.information1%type := null;
2054 l_new_value number(15);
2055 l_object_found_in_target boolean := false ;
2056 l_min_esd date;
2057 l_max_eed date;
2058 l_effective_date date;
2059 --
2060 begin
2061 -- Initialization
2062 l_object_found_in_target := false ;
2063 -- End Initialization
2064
2065 for r_CPL_unique in c_unique_CPL('CPL') loop
2066
2067 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
2068 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2069 r_CPL_unique.information3 >=
2070 ben_pd_copy_to_ben_one.g_copy_effective_date)
2071 ) then
2072 --
2073 if p_prefix_suffix_cd = 'PREFIX' then
2074 l_prefix := p_prefix_suffix_text ;
2075 elsif p_prefix_suffix_cd = 'SUFFIX' then
2076 l_suffix := p_prefix_suffix_text ;
2077 else
2078 l_prefix := null ;
2079 l_suffix := null ;
2080 end if ;
2081 --
2082 hr_utility.set_location(' r_CPL_unique.table_route_id '||r_CPL_unique.table_route_id,10);
2083 hr_utility.set_location(' r_CPL_unique.information1 '||r_CPL_unique.information1,10);
2084 hr_utility.set_location( 'r_CPL_unique.information2 '||r_CPL_unique.information2,10);
2085 hr_utility.set_location( 'r_CPL_unique.information3 '||r_CPL_unique.information3,10);
2086 -- If reuse objects flag is 'Y' then check for the object in the target business group
2087 -- if found insert the record into PLSql table and exit the loop else try create the
2088 -- object in the target business group
2089 --
2090 open c_CPL(r_CPL_unique.table_route_id,
2091 r_CPL_unique.information1,
2092 r_CPL_unique.information2,
2093 r_CPL_unique.information3 ) ;
2094 --
2095 fetch c_CPL into r_CPL ;
2096 --
2097 close c_CPL ;
2098 l_PGM_ID := get_fk('PGM_ID', r_CPL.INFORMATION260,r_CPL_unique.dml_operation);
2099
2100 l_object_found_in_target := false ;
2101 --UPD START
2102 l_update := false;
2103 l_process_date := p_effective_date;
2104 l_dml_operation:= r_CPL_unique.dml_operation ;
2105 --
2106 if l_dml_operation = 'UPDATE' then
2107 --
2108 l_object_found_in_target := TRUE;
2109 --
2110 if l_process_date between r_CPL_unique.information2 and r_CPL_unique.information3 then
2111 l_update := true;
2112 if r_CPL_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
2113 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'CMBN_PLIP_ID' then
2114 g_pk_tbl(g_count).pk_id_column := 'CMBN_PLIP_ID' ;
2115 g_pk_tbl(g_count).old_value := r_CPL_unique.information1 ;
2116 g_pk_tbl(g_count).new_value := r_CPL_unique.information1 ;
2117 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
2118 g_pk_tbl(g_count).table_route_id := r_CPL_unique.table_route_id;
2119 --
2120 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
2121 --
2122 g_count := g_count + 1 ;
2123 --
2124 log_data('CPL',l_new_value,l_prefix || r_CPL_unique.name|| l_suffix,'REUSED');
2125 --
2126 end if ;
2127 hr_utility.set_location( 'found record for update',10);
2128 --
2129 else
2130 --
2131 l_update := false;
2132 --
2133 end if;
2134 else
2135 --
2136 --UPD END
2137 l_min_esd := null ;
2138 l_max_eed := null ;
2139 open c_CPL_min_max_dates(r_CPL_unique.table_route_id, r_CPL_unique.information1 ) ;
2140 fetch c_CPL_min_max_dates into l_min_esd,l_max_eed ;
2141
2142 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2143 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
2144 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
2145 end if;
2146 l_min_esd := greatest(l_min_esd,r_CPL_unique.information2);
2147 --
2148 /*
2149 open c_CPL(r_CPL_unique.table_route_id,
2150 r_CPL_unique.information1,
2151 r_CPL_unique.information2,
2152 r_CPL_unique.information3 ) ;
2153 --
2154 fetch c_CPL into r_CPL ;
2155 --
2156 close c_CPL ;
2157 --
2158 l_PGM_ID := get_fk('PGM_ID', r_CPL.INFORMATION260);
2159 */
2160 if p_reuse_object_flag = 'Y' then
2161 if c_CPL_min_max_dates%found then
2162 -- cursor to find the object
2163 open c_find_CPL_in_target( l_prefix || r_CPL_unique.name|| l_suffix ,l_min_esd,l_max_eed,
2164 p_target_business_group_id, nvl(l_cmbn_plip_id, -999) ) ;
2165 fetch c_find_CPL_in_target into l_new_value ;
2166 if c_find_CPL_in_target%found then
2167 --
2168 --TEMPIK
2169 l_dt_rec_found := dt_api.check_min_max_dates
2170 (p_base_table_name => 'BEN_CMBN_PLIP_F',
2171 p_base_key_column => 'CMBN_PLIP_ID',
2172 p_base_key_value => l_new_value,
2173 p_from_date => l_min_esd,
2174 p_to_date => l_max_eed );
2175 if l_dt_rec_found THEN
2176 --END TEMPIK
2177 if r_CPL_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
2178 nvl(ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count-1).pk_id_column, '999') <> 'CMBN_PLIP_ID' then
2179 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).pk_id_column := 'CMBN_PLIP_ID' ;
2180 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).old_value := r_CPL_unique.information1 ;
2181 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).new_value := l_new_value ;
2182 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'REUSED';
2183 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).table_route_id := r_CPL_unique.table_route_id;
2184 --
2185 -- -- update_cer_with_target( ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count) , p_copy_entity_txn_id) ;
2186 --
2187 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1 ;
2188 --
2189 log_data('CPL',l_new_value,l_prefix || r_CPL_unique.name|| l_suffix,'REUSED');
2190 --
2191 end if ;
2192 --
2193 l_object_found_in_target := true ;
2194 --TEMPIK
2195 end if; -- l_dt_rec_found
2196 --END TEMPIK
2197 --
2198 else
2199 -- NEW
2200 if p_prefix_suffix_text is null then
2201 --
2202 open c_find_CPL_name_in_target( l_prefix || r_CPL_unique.name|| l_suffix ,
2203 l_min_esd,l_max_eed,
2204 p_target_business_group_id, nvl(l_cmbn_plip_id, -999) ) ;
2205 fetch c_find_CPL_name_in_target into l_new_value ;
2206 if c_find_CPL_name_in_target%found then
2207 --
2208 if p_prefix_suffix_cd = 'PREFIX' then
2209 l_prefix := BEN_PLAN_DESIGN_TXNS_API.g_pgm_pl_prefix_suffix_text ;
2210 elsif p_prefix_suffix_cd = 'SUFFIX' then
2211 l_suffix := BEN_PLAN_DESIGN_TXNS_API.g_pgm_pl_prefix_suffix_text ;
2212 else
2213 l_prefix := null ;
2214 l_suffix := null ;
2215 end if ;
2216 --
2217 end if;
2218 close c_find_CPL_name_in_target ;
2219 end if;
2220 --dbms_output.put_line(' Second Cursor ');
2221 end if;
2222 close c_find_CPL_in_target ;
2223 -- NEW
2224 end if;
2225 end if ;
2226 --
2227 close c_CPL_min_max_dates ;
2228 --UPD START
2229 end if; --if p_dml_operation
2230 --
2231 -- if not l_object_found_in_target then
2232 if not l_object_found_in_target OR l_update then
2233 --
2234 --UPD END
2235 --
2236 l_current_pk_id := r_CPL.information1;
2237 --
2238 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
2239 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
2240 --
2241 if l_current_pk_id = l_prev_pk_id then
2242 --
2243 l_first_rec := false ;
2244 --
2245 else
2246 --
2247 l_first_rec := true ;
2248 --
2249 end if ;
2250 --
2251 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_CMBN_PLIP_F' ,l_prefix || r_CPL.information170 || l_suffix);
2252 --
2253
2254 l_effective_date := r_CPL.information2;
2255 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2256 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
2257 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
2258 end if;
2259
2260 if l_first_rec and not l_update then
2261 -- Call Create routine.
2262 hr_utility.set_location(' BEN_CMBN_PLIP_F CREATE_CMBN_PLIP ',20);
2263 BEN_CMBN_PLIP_API.CREATE_CMBN_PLIP(
2264 --
2265 P_VALIDATE => false
2266 ,P_EFFECTIVE_DATE => l_effective_date
2267 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2268 --
2269 ,P_CMBN_PLIP_ID => l_cmbn_plip_id
2270 ,P_CPL_ATTRIBUTE1 => r_CPL.INFORMATION111
2271 ,P_CPL_ATTRIBUTE10 => r_CPL.INFORMATION120
2272 ,P_CPL_ATTRIBUTE11 => r_CPL.INFORMATION121
2273 ,P_CPL_ATTRIBUTE12 => r_CPL.INFORMATION122
2274 ,P_CPL_ATTRIBUTE13 => r_CPL.INFORMATION123
2275 ,P_CPL_ATTRIBUTE14 => r_CPL.INFORMATION124
2276 ,P_CPL_ATTRIBUTE15 => r_CPL.INFORMATION125
2277 ,P_CPL_ATTRIBUTE16 => r_CPL.INFORMATION126
2278 ,P_CPL_ATTRIBUTE17 => r_CPL.INFORMATION127
2279 ,P_CPL_ATTRIBUTE18 => r_CPL.INFORMATION128
2280 ,P_CPL_ATTRIBUTE19 => r_CPL.INFORMATION129
2281 ,P_CPL_ATTRIBUTE2 => r_CPL.INFORMATION112
2282 ,P_CPL_ATTRIBUTE20 => r_CPL.INFORMATION130
2283 ,P_CPL_ATTRIBUTE21 => r_CPL.INFORMATION131
2284 ,P_CPL_ATTRIBUTE22 => r_CPL.INFORMATION132
2285 ,P_CPL_ATTRIBUTE23 => r_CPL.INFORMATION133
2286 ,P_CPL_ATTRIBUTE24 => r_CPL.INFORMATION134
2287 ,P_CPL_ATTRIBUTE25 => r_CPL.INFORMATION135
2288 ,P_CPL_ATTRIBUTE26 => r_CPL.INFORMATION136
2289 ,P_CPL_ATTRIBUTE27 => r_CPL.INFORMATION137
2290 ,P_CPL_ATTRIBUTE28 => r_CPL.INFORMATION138
2291 ,P_CPL_ATTRIBUTE29 => r_CPL.INFORMATION139
2292 ,P_CPL_ATTRIBUTE3 => r_CPL.INFORMATION113
2293 ,P_CPL_ATTRIBUTE30 => r_CPL.INFORMATION140
2294 ,P_CPL_ATTRIBUTE4 => r_CPL.INFORMATION114
2295 ,P_CPL_ATTRIBUTE5 => r_CPL.INFORMATION115
2296 ,P_CPL_ATTRIBUTE6 => r_CPL.INFORMATION116
2297 ,P_CPL_ATTRIBUTE7 => r_CPL.INFORMATION117
2298 ,P_CPL_ATTRIBUTE8 => r_CPL.INFORMATION118
2299 ,P_CPL_ATTRIBUTE9 => r_CPL.INFORMATION119
2300 ,P_CPL_ATTRIBUTE_CATEGORY => r_CPL.INFORMATION110
2301 ,P_NAME => l_prefix || r_CPL.INFORMATION170 || l_suffix
2302 ,P_PGM_ID => l_PGM_ID
2303 --
2304 ,P_EFFECTIVE_START_DATE => l_effective_start_date
2305 ,P_EFFECTIVE_END_DATE => l_effective_end_date
2306 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
2307 );
2308 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
2309 -- Update all relevent cer records with new pk_id
2310 hr_utility.set_location('Before plsql table ',222);
2311 hr_utility.set_location('new_value id '||l_cmbn_plip_id,222);
2312 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).pk_id_column := 'CMBN_PLIP_ID' ;
2313 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).old_value := r_CPL.information1 ;
2314 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).new_value := l_CMBN_PLIP_ID ;
2315 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'COPIED';
2316 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).table_route_id := r_CPL_unique.table_route_id;
2317 hr_utility.set_location('After plsql table ',222);
2318 --
2319 -- update_cer_with_target( ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count),p_copy_entity_txn_id ) ;
2320 --
2321 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1 ;
2322 --
2323 log_data('CPL',l_new_value,l_prefix || r_CPL.information170 || l_suffix,'COPIED');
2324 --
2325 else
2326 --
2327 -- Call Update routine for the pk_id created in prev run .
2328 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
2329 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
2330 --
2331 if l_update then
2332 --
2333 l_datetrack_mode := r_CPL.datetrack_mode ;
2334 --
2335 get_dt_modes(
2336 p_effective_date => l_process_date,
2337 p_effective_end_date => r_CPL.information3,
2338 p_effective_start_date => r_CPL.information2,
2339 p_dml_operation => r_CPL.dml_operation,
2340 p_datetrack_mode => l_datetrack_mode );
2341 -- p_update => l_update
2342 --
2343 l_effective_date := l_process_date;
2344 l_cmbn_plip_id := r_CPL.information1;
2345 l_object_version_number := r_CPL.information265;
2346 --
2347 end if;
2348 --
2349 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
2350 --
2351 IF l_update OR l_dml_operation <> 'UPDATE' THEN
2352 --UPD END
2353 hr_utility.set_location(' BEN_CMBN_PLIP_F UPDATE_CMBN_PLIP ',30);
2354 BEN_CMBN_PLIP_API.UPDATE_CMBN_PLIP(
2355 --
2356 P_VALIDATE => false
2357 ,P_EFFECTIVE_DATE => l_effective_date
2358 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2359 --
2360 ,P_CMBN_PLIP_ID => l_cmbn_plip_id
2361 ,P_CPL_ATTRIBUTE1 => r_CPL.INFORMATION111
2362 ,P_CPL_ATTRIBUTE10 => r_CPL.INFORMATION120
2363 ,P_CPL_ATTRIBUTE11 => r_CPL.INFORMATION121
2364 ,P_CPL_ATTRIBUTE12 => r_CPL.INFORMATION122
2365 ,P_CPL_ATTRIBUTE13 => r_CPL.INFORMATION123
2366 ,P_CPL_ATTRIBUTE14 => r_CPL.INFORMATION124
2367 ,P_CPL_ATTRIBUTE15 => r_CPL.INFORMATION125
2368 ,P_CPL_ATTRIBUTE16 => r_CPL.INFORMATION126
2369 ,P_CPL_ATTRIBUTE17 => r_CPL.INFORMATION127
2370 ,P_CPL_ATTRIBUTE18 => r_CPL.INFORMATION128
2371 ,P_CPL_ATTRIBUTE19 => r_CPL.INFORMATION129
2372 ,P_CPL_ATTRIBUTE2 => r_CPL.INFORMATION112
2373 ,P_CPL_ATTRIBUTE20 => r_CPL.INFORMATION130
2374 ,P_CPL_ATTRIBUTE21 => r_CPL.INFORMATION131
2375 ,P_CPL_ATTRIBUTE22 => r_CPL.INFORMATION132
2376 ,P_CPL_ATTRIBUTE23 => r_CPL.INFORMATION133
2377 ,P_CPL_ATTRIBUTE24 => r_CPL.INFORMATION134
2378 ,P_CPL_ATTRIBUTE25 => r_CPL.INFORMATION135
2379 ,P_CPL_ATTRIBUTE26 => r_CPL.INFORMATION136
2380 ,P_CPL_ATTRIBUTE27 => r_CPL.INFORMATION137
2381 ,P_CPL_ATTRIBUTE28 => r_CPL.INFORMATION138
2382 ,P_CPL_ATTRIBUTE29 => r_CPL.INFORMATION139
2383 ,P_CPL_ATTRIBUTE3 => r_CPL.INFORMATION113
2384 ,P_CPL_ATTRIBUTE30 => r_CPL.INFORMATION140
2385 ,P_CPL_ATTRIBUTE4 => r_CPL.INFORMATION114
2386 ,P_CPL_ATTRIBUTE5 => r_CPL.INFORMATION115
2387 ,P_CPL_ATTRIBUTE6 => r_CPL.INFORMATION116
2388 ,P_CPL_ATTRIBUTE7 => r_CPL.INFORMATION117
2389 ,P_CPL_ATTRIBUTE8 => r_CPL.INFORMATION118
2390 ,P_CPL_ATTRIBUTE9 => r_CPL.INFORMATION119
2391 ,P_CPL_ATTRIBUTE_CATEGORY => r_CPL.INFORMATION110
2392 ,P_NAME => l_prefix || r_CPL.INFORMATION170 || l_suffix
2393 ,P_PGM_ID => l_PGM_ID
2394 --
2395 ,P_EFFECTIVE_START_DATE => l_effective_start_date
2396 ,P_EFFECTIVE_END_DATE => l_effective_end_date
2397 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
2398 ,P_DATETRACK_MODE => l_datetrack_mode
2399 );
2400 end if;
2401 --
2402 end if;
2403 --
2404 -- Delete the row if it is end dated.
2405 --
2406 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
2407 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
2408 trunc(l_max_eed) = r_CPL.information3) then
2409 --
2410 BEN_CMBN_PLIP_API.delete_CMBN_PLIP(
2411 --
2412 p_validate => false
2413 ,p_cmbn_plip_id => l_cmbn_plip_id
2414 ,p_effective_start_date => l_effective_start_date
2415 ,p_effective_end_date => l_effective_end_date
2416 ,p_object_version_number => l_object_version_number
2417 ,p_effective_date => l_max_eed
2418 ,p_datetrack_mode => hr_api.g_delete
2419 --
2420 );
2421 --
2422 end if;
2423 --
2424 l_prev_pk_id := l_current_pk_id ;
2425 --
2426 end if;
2427 --
2428 end if;
2429 --
2430 end loop;
2431 --
2432 exception when others then
2433 --
2434 raise_error_message( 'CPL',l_prefix || r_CPL.information170 || l_suffix) ;
2435 --
2436 end create_CPL_rows;
2437
2438 --
2439 ---------------------------------------------------------------
2440 ----------------------< create_CBP_rows >-----------------------
2441 ---------------------------------------------------------------
2442 --
2443 procedure create_CBP_rows
2444 (
2445 p_validate in number default 0
2446 ,p_copy_entity_txn_id in number
2447 ,p_effective_date in date
2448 ,p_prefix_suffix_text in varchar2 default null
2449 ,p_reuse_object_flag in varchar2 default null
2450 ,p_target_business_group_id in varchar2 default null
2451 ,p_prefix_suffix_cd in varchar2 default null
2452 ) is
2453 --
2454 l_PGM_ID number;
2455 cursor c_unique_CBP(l_table_alias varchar2) is
2456 select distinct cpe.information1,
2457 cpe.information2,
2458 cpe.information3,
2459 cpe.INFORMATION170 name,
2460 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
2461 from ben_copy_entity_results cpe,
2462 pqh_table_route tr
2463 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2464 and cpe.table_route_id = tr.table_route_id
2465 -- and tr.where_clause = l_BEN_CMBN_PTIP_F
2466 and tr.table_alias = l_table_alias
2467 and cpe.number_of_copies = 1 -- ADDITION
2468 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
2469 order by information1, information2; --added for bug: 5151945
2470 --
2471 --
2472 cursor c_CBP_min_max_dates(c_table_route_id number,
2473 c_information1 number) is
2474 select
2475 min(cpe.information2) min_esd,
2476 max(cpe.information3) min_eed
2477 from ben_copy_entity_results cpe
2478 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2479 and cpe.table_route_id = c_table_route_id
2480 and cpe.information1 = c_information1 ;
2481 --
2482 cursor c_CBP(c_table_route_id number,
2483 c_information1 number,
2484 c_information2 date,
2485 c_information3 date ) is
2486 select
2487 cpe.*
2488 from ben_copy_entity_results cpe
2489 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2490 and cpe.table_route_id = c_table_route_id
2491 and cpe.information1 = c_information1
2492 and cpe.information2 = c_information2
2493 and cpe.information3 = c_information3
2494 and rownum = 1 ;
2495 -- Date Track target record
2496 cursor c_find_CBP_in_target( c_CBP_name varchar2,
2497 c_effective_start_date date,
2498 c_effective_end_date date,
2499 c_business_group_id number,
2500 c_new_pk_id number) is
2501 select
2502 CBP.cmbn_ptip_id new_value
2503 from BEN_CMBN_PTIP_F CBP
2504 where CBP.name = c_CBP_name and
2505 nvl(CBP.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
2506 CBP.business_group_id = c_business_group_id
2507 and CBP.cmbn_ptip_id <> c_new_pk_id
2508 --TEMPIK
2509 and c_effective_start_date between effective_start_date
2510 and effective_end_date ;
2511 --END TEMPIK
2512 /*TEMPIK
2513 and exists ( select null
2514 from BEN_CMBN_PTIP_F CBP1
2515 where CBP1.name = c_CBP_name and
2516 nvl(CBP1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
2517 CBP1.business_group_id = c_business_group_id
2518 and CBP1.effective_start_date <= c_effective_start_date )
2519 and exists ( select null
2520 from BEN_CMBN_PTIP_F CBP2
2521 where CBP2.name = c_CBP_name and
2522 nvl(CBP2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
2523 CBP2.business_group_id = c_business_group_id
2524 and CBP2.effective_end_date >= c_effective_end_date )
2525 ;
2526 TEMPIK */
2527 --TEMPIK
2528 l_dt_rec_found boolean ;
2529 --END TEMPIK
2530 --
2531 cursor c_find_CBP_name_in_target( c_CBP_name varchar2,
2532 c_effective_start_date date,
2533 c_effective_end_date date,
2534 c_business_group_id number,
2535 c_new_pk_id number) is
2536 select
2537 CBP.cmbn_ptip_id new_value
2538 from BEN_CMBN_PTIP_F CBP
2539 where CBP.name = c_CBP_name and
2540 CBP.business_group_id = c_business_group_id
2541 and CBP.cmbn_ptip_id <> c_new_pk_id
2542 and exists ( select null
2543 from BEN_CMBN_PTIP_F CBP1
2544 where CBP1.name = c_CBP_name and
2545 CBP1.business_group_id = c_business_group_id
2546 and CBP1.effective_start_date <= c_effective_start_date )
2547 and exists ( select null
2548 from BEN_CMBN_PTIP_F CBP2
2549 where CBP2.name = c_CBP_name and
2550 CBP2.business_group_id = c_business_group_id
2551 and CBP2.effective_end_date >= c_effective_end_date )
2552 ;
2553 l_current_pk_id number := null ;
2554 --UPD START
2555 --
2556 l_update boolean := false ;
2557 l_datetrack_mode varchar2(80) := hr_api.g_update;
2558 l_process_date date;
2559 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
2560 --
2561 --UPD END
2562 l_prev_pk_id number := null ;
2563 l_first_rec boolean := true ;
2564 r_CBP c_CBP%rowtype;
2565 l_cmbn_ptip_id number ;
2566 l_object_version_number number ;
2567 l_effective_start_date date ;
2568 l_effective_end_date date ;
2569 l_prefix pqh_copy_entity_attribs.information1%type := null;
2570 l_suffix pqh_copy_entity_attribs.information1%type := null;
2571 l_new_value number(15);
2572 l_object_found_in_target boolean := false ;
2573 l_min_esd date;
2574 l_max_eed date;
2575 l_effective_date date;
2576 --
2577 begin
2578 -- Initialization
2579 l_object_found_in_target := false ;
2580 -- End Initialization
2581
2582 for r_CBP_unique in c_unique_CBP('CBP') loop
2583
2584 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
2585 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2586 r_CBP_unique.information3 >=
2587 ben_pd_copy_to_ben_one.g_copy_effective_date)
2588 ) then
2589 --
2590 if p_prefix_suffix_cd = 'PREFIX' then
2591 l_prefix := p_prefix_suffix_text ;
2592 elsif p_prefix_suffix_cd = 'SUFFIX' then
2593 l_suffix := p_prefix_suffix_text ;
2594 else
2595 l_prefix := null ;
2596 l_suffix := null ;
2597 end if ;
2598 --
2599 hr_utility.set_location(' r_CBP_unique.table_route_id '||r_CBP_unique.table_route_id,10);
2600 hr_utility.set_location(' r_CBP_unique.information1 '||r_CBP_unique.information1,10);
2601 hr_utility.set_location( 'r_CBP_unique.information2 '||r_CBP_unique.information2,10);
2602 hr_utility.set_location( 'r_CBP_unique.information3 '||r_CBP_unique.information3,10);
2603 -- If reuse objects flag is 'Y' then check for the object in the target business group
2604 -- if found insert the record into PLSql table and exit the loop else try create the
2605 -- object in the target business group
2606 --
2607 l_object_found_in_target := false ;
2608 l_min_esd := null ;
2609 l_max_eed := null ;
2610 open c_CBP_min_max_dates(r_CBP_unique.table_route_id, r_CBP_unique.information1 ) ;
2611 fetch c_CBP_min_max_dates into l_min_esd,l_max_eed ;
2612 --
2613
2614 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2615 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
2616 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
2617 end if;
2618 l_min_esd := greatest(l_min_esd,r_CBP_unique.information2);
2619 open c_CBP(r_CBP_unique.table_route_id,
2620 r_CBP_unique.information1,
2621 r_CBP_unique.information2,
2622 r_CBP_unique.information3 ) ;
2623 --
2624 fetch c_CBP into r_CBP ;
2625 --
2626 close c_CBP ;
2627 --
2628 l_update := false;
2629 l_process_date := p_effective_date;
2630 l_dml_operation:= r_CBP_unique.dml_operation ;
2631 --
2632 l_PGM_ID := get_fk('PGM_ID', r_CBP.information260,l_dml_operation );
2633 if l_dml_operation = 'UPDATE' then
2634 --
2635 l_object_found_in_target := TRUE;
2636 --
2637 if l_process_date between r_CBP_unique.information2 and r_CBP_unique.information3 then
2638 l_update := true;
2639 if r_CBP_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
2640 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'CMBN_PTIP_ID' then
2641 g_pk_tbl(g_count).pk_id_column := 'CMBN_PTIP_ID' ;
2642 g_pk_tbl(g_count).old_value := r_CBP_unique.information1 ;
2643 g_pk_tbl(g_count).new_value := r_CBP_unique.information1 ;
2644 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
2645 g_pk_tbl(g_count).table_route_id := r_CBP_unique.table_route_id;
2646 --
2647 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
2648 --
2649 g_count := g_count + 1 ;
2650 --
2651 log_data('CBP',l_new_value,l_prefix || r_CBP_unique.name|| l_suffix,'REUSED');
2652 --
2653 end if ;
2654 hr_utility.set_location( 'found record for update',10);
2655 --
2656 else
2657 --
2658 l_update := false;
2659 --
2660 end if;
2661 else
2662 --
2663 --UPD END
2664 if p_reuse_object_flag = 'Y' then
2665 if c_CBP_min_max_dates%found then
2666 -- cursor to find the object
2667 open c_find_CBP_in_target( l_prefix || r_CBP_unique.name|| l_suffix ,r_CBP_unique.information2,l_max_eed,
2668 p_target_business_group_id, nvl(l_cmbn_ptip_id, -999) ) ;
2669
2670 fetch c_find_CBP_in_target into l_new_value ;
2671 if c_find_CBP_in_target%found then
2672 --TEMPIK
2673 l_dt_rec_found := dt_api.check_min_max_dates
2674 (p_base_table_name => 'BEN_CMBN_PTIP_F',
2675 p_base_key_column => 'CMBN_PTIP_ID',
2676 p_base_key_value => l_new_value,
2677 p_from_date => l_min_esd,
2678 p_to_date => l_max_eed );
2679 if l_dt_rec_found THEN
2680 --END TEMPIK
2681 --
2682 if r_CBP_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
2683 nvl(ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count-1).pk_id_column, '999') <> 'CMBN_PTIP_ID' then
2684 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).pk_id_column := 'CMBN_PTIP_ID' ;
2685 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).old_value := r_CBP_unique.information1 ;
2686 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).new_value := l_new_value ;
2687 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'REUSED';
2688 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).table_route_id := r_CBP_unique.table_route_id;
2689 --
2690 -- update_cer_with_target( ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count) , p_copy_entity_txn_id) ;
2691 --
2692 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1 ;
2693 --
2694 log_data('CBP',l_new_value,l_prefix || r_CBP_unique.name|| l_suffix,'REUSED');
2695 --
2696 end if ;
2697 --
2698 l_object_found_in_target := true ;
2699 --TEMPIK
2700 end if; -- l_dt_rec_found
2701 --END TEMPIK
2702 else
2703 if p_prefix_suffix_text is null then
2704 --
2705 open c_find_CBP_name_in_target( l_prefix || r_CBP_unique.name|| l_suffix ,
2706 l_min_esd,l_max_eed,
2707 p_target_business_group_id, nvl(l_cmbn_ptip_id, -999) ) ;
2708 fetch c_find_CBP_name_in_target into l_new_value ;
2709 if c_find_CBP_name_in_target%found then
2710 --
2711 if p_prefix_suffix_cd = 'PREFIX' then
2712 l_prefix := BEN_PLAN_DESIGN_TXNS_API.g_pgm_pl_prefix_suffix_text ;
2713 elsif p_prefix_suffix_cd = 'SUFFIX' then
2714 l_suffix := BEN_PLAN_DESIGN_TXNS_API.g_pgm_pl_prefix_suffix_text ;
2715 else
2716 l_prefix := null ;
2717 l_suffix := null ;
2718 end if ;
2719 --
2720 end if;
2721 close c_find_CBP_name_in_target ;
2722 end if;
2723 --dbms_output.put_line(' Second Cursor ');
2724 end if;
2725 close c_find_CBP_in_target ;
2726 -- NEW
2727 --
2728 end if;
2729 end if ;
2730 --
2731 end if ; --UPDATE
2732 --
2733 close c_CBP_min_max_dates ;
2734 if not l_object_found_in_target then
2735 --
2736 l_current_pk_id := r_CBP.information1;
2737 --
2738 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
2739 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
2740 --
2741 if l_current_pk_id = l_prev_pk_id then
2742 --
2743 l_first_rec := false ;
2744 --
2745 else
2746 --
2747 l_first_rec := true ;
2748 --
2749 end if ;
2750 --
2751 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_CMBN_PTIP_F' ,l_prefix || r_CBP.INFORMATION170 || l_suffix);
2752 --
2753
2754 l_effective_date := r_CBP.information2;
2755 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
2756 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
2757 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
2758 end if;
2759
2760 if l_first_rec and not l_update then
2761 -- Call Create routine.
2762 hr_utility.set_location(' BEN_CMBN_PTIP_F CREATE_CMBN_PTIP ',20);
2763 BEN_CMBN_PTIP_API.CREATE_CMBN_PTIP(
2764 --
2765 P_VALIDATE => false
2766 ,P_EFFECTIVE_DATE => l_effective_date
2767 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2768 --
2769 ,P_CBP_ATTRIBUTE1 => r_CBP.INFORMATION111
2770 ,P_CBP_ATTRIBUTE10 => r_CBP.INFORMATION120
2771 ,P_CBP_ATTRIBUTE11 => r_CBP.INFORMATION121
2772 ,P_CBP_ATTRIBUTE12 => r_CBP.INFORMATION122
2773 ,P_CBP_ATTRIBUTE13 => r_CBP.INFORMATION123
2774 ,P_CBP_ATTRIBUTE14 => r_CBP.INFORMATION124
2775 ,P_CBP_ATTRIBUTE15 => r_CBP.INFORMATION125
2776 ,P_CBP_ATTRIBUTE16 => r_CBP.INFORMATION126
2777 ,P_CBP_ATTRIBUTE17 => r_CBP.INFORMATION127
2778 ,P_CBP_ATTRIBUTE18 => r_CBP.INFORMATION128
2779 ,P_CBP_ATTRIBUTE19 => r_CBP.INFORMATION129
2780 ,P_CBP_ATTRIBUTE2 => r_CBP.INFORMATION112
2781 ,P_CBP_ATTRIBUTE20 => r_CBP.INFORMATION130
2782 ,P_CBP_ATTRIBUTE21 => r_CBP.INFORMATION131
2783 ,P_CBP_ATTRIBUTE22 => r_CBP.INFORMATION132
2784 ,P_CBP_ATTRIBUTE23 => r_CBP.INFORMATION133
2785 ,P_CBP_ATTRIBUTE24 => r_CBP.INFORMATION134
2786 ,P_CBP_ATTRIBUTE25 => r_CBP.INFORMATION135
2787 ,P_CBP_ATTRIBUTE26 => r_CBP.INFORMATION136
2788 ,P_CBP_ATTRIBUTE27 => r_CBP.INFORMATION137
2789 ,P_CBP_ATTRIBUTE28 => r_CBP.INFORMATION138
2790 ,P_CBP_ATTRIBUTE29 => r_CBP.INFORMATION139
2791 ,P_CBP_ATTRIBUTE3 => r_CBP.INFORMATION113
2792 ,P_CBP_ATTRIBUTE30 => r_CBP.INFORMATION140
2793 ,P_CBP_ATTRIBUTE4 => r_CBP.INFORMATION114
2794 ,P_CBP_ATTRIBUTE5 => r_CBP.INFORMATION115
2795 ,P_CBP_ATTRIBUTE6 => r_CBP.INFORMATION116
2796 ,P_CBP_ATTRIBUTE7 => r_CBP.INFORMATION117
2797 ,P_CBP_ATTRIBUTE8 => r_CBP.INFORMATION118
2798 ,P_CBP_ATTRIBUTE9 => r_CBP.INFORMATION119
2799 ,P_CBP_ATTRIBUTE_CATEGORY => r_CBP.INFORMATION110
2800 ,P_CMBN_PTIP_ID => l_cmbn_ptip_id
2801 ,P_NAME => l_prefix || r_CBP.INFORMATION170 || l_suffix
2802 ,P_PGM_ID => l_PGM_ID
2803 --
2804 ,P_EFFECTIVE_START_DATE => l_effective_start_date
2805 ,P_EFFECTIVE_END_DATE => l_effective_end_date
2806 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
2807 );
2808 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
2809 -- Update all relevent cer records with new pk_id
2810 hr_utility.set_location('Before plsql table ',222);
2811 hr_utility.set_location('new_value id '||l_cmbn_ptip_id,222);
2812 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).pk_id_column := 'CMBN_PTIP_ID' ;
2813 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).old_value := r_CBP.information1 ;
2814 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).new_value := l_CMBN_PTIP_ID ;
2815 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'COPIED';
2816 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).table_route_id := r_CBP_unique.table_route_id;
2817 hr_utility.set_location('After plsql table ',222);
2818 --
2819 -- update_cer_with_target( ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count),p_copy_entity_txn_id ) ;
2820 --
2821 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1 ;
2822 --
2823 log_data('CBP',l_new_value,l_prefix || r_CBP.INFORMATION170 || l_suffix,'COPIED');
2824 --
2825 else
2826 --
2827 -- Call Update routine for the pk_id created in prev run .
2828 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
2829 hr_utility.set_location(' BEN_CMBN_PTIP_F UPDATE_CMBN_PTIP ',30);
2830 BEN_CMBN_PTIP_API.UPDATE_CMBN_PTIP(
2831 --
2832 P_VALIDATE => false
2833 ,P_EFFECTIVE_DATE => l_effective_date
2834 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
2835 --
2836 ,P_CBP_ATTRIBUTE1 => r_CBP.INFORMATION111
2837 ,P_CBP_ATTRIBUTE10 => r_CBP.INFORMATION120
2838 ,P_CBP_ATTRIBUTE11 => r_CBP.INFORMATION121
2839 ,P_CBP_ATTRIBUTE12 => r_CBP.INFORMATION122
2840 ,P_CBP_ATTRIBUTE13 => r_CBP.INFORMATION123
2841 ,P_CBP_ATTRIBUTE14 => r_CBP.INFORMATION124
2842 ,P_CBP_ATTRIBUTE15 => r_CBP.INFORMATION125
2843 ,P_CBP_ATTRIBUTE16 => r_CBP.INFORMATION126
2844 ,P_CBP_ATTRIBUTE17 => r_CBP.INFORMATION127
2845 ,P_CBP_ATTRIBUTE18 => r_CBP.INFORMATION128
2846 ,P_CBP_ATTRIBUTE19 => r_CBP.INFORMATION129
2847 ,P_CBP_ATTRIBUTE2 => r_CBP.INFORMATION112
2848 ,P_CBP_ATTRIBUTE20 => r_CBP.INFORMATION130
2849 ,P_CBP_ATTRIBUTE21 => r_CBP.INFORMATION131
2850 ,P_CBP_ATTRIBUTE22 => r_CBP.INFORMATION132
2851 ,P_CBP_ATTRIBUTE23 => r_CBP.INFORMATION133
2852 ,P_CBP_ATTRIBUTE24 => r_CBP.INFORMATION134
2853 ,P_CBP_ATTRIBUTE25 => r_CBP.INFORMATION135
2854 ,P_CBP_ATTRIBUTE26 => r_CBP.INFORMATION136
2855 ,P_CBP_ATTRIBUTE27 => r_CBP.INFORMATION137
2856 ,P_CBP_ATTRIBUTE28 => r_CBP.INFORMATION138
2857 ,P_CBP_ATTRIBUTE29 => r_CBP.INFORMATION139
2858 ,P_CBP_ATTRIBUTE3 => r_CBP.INFORMATION113
2859 ,P_CBP_ATTRIBUTE30 => r_CBP.INFORMATION140
2860 ,P_CBP_ATTRIBUTE4 => r_CBP.INFORMATION114
2861 ,P_CBP_ATTRIBUTE5 => r_CBP.INFORMATION115
2862 ,P_CBP_ATTRIBUTE6 => r_CBP.INFORMATION116
2863 ,P_CBP_ATTRIBUTE7 => r_CBP.INFORMATION117
2864 ,P_CBP_ATTRIBUTE8 => r_CBP.INFORMATION118
2865 ,P_CBP_ATTRIBUTE9 => r_CBP.INFORMATION119
2866 ,P_CBP_ATTRIBUTE_CATEGORY => r_CBP.INFORMATION110
2867 ,P_CMBN_PTIP_ID => l_cmbn_ptip_id
2868 ,P_NAME => l_prefix || r_CBP.INFORMATION170 || l_suffix
2869 ,P_PGM_ID => l_PGM_ID
2870 --
2871 ,P_EFFECTIVE_START_DATE => l_effective_start_date
2872 ,P_EFFECTIVE_END_DATE => l_effective_end_date
2873 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
2874 ,P_DATETRACK_MODE => l_datetrack_mode
2875 );
2876 --
2877 end if;
2878 --
2879 -- Delete the row if it is end dated.
2880 --
2881 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
2882 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
2883 trunc(l_max_eed) = r_CBP.information3) then
2884 --
2885 BEN_CMBN_PTIP_API.delete_CMBN_PTIP(
2886 --
2887 p_validate => false
2888 ,p_cmbn_ptip_id => l_cmbn_ptip_id
2889 ,p_effective_start_date => l_effective_start_date
2890 ,p_effective_end_date => l_effective_end_date
2891 ,p_object_version_number => l_object_version_number
2892 ,p_effective_date => l_max_eed
2893 ,p_datetrack_mode => hr_api.g_delete
2894 --
2895 );
2896 --
2897 end if;
2898 --
2899 l_prev_pk_id := l_current_pk_id ;
2900 --
2901 end if;
2902 --
2903 end if;
2904 --
2905 end loop;
2906 --
2907 exception when others then
2908 --
2909 raise_error_message( 'CBP',l_prefix || r_CBP.INFORMATION170 || l_suffix) ;
2910 --
2911 end create_CBP_rows;
2912
2913 --
2914 ---------------------------------------------------------------
2915 ----------------------< create_CPT_rows >-----------------------
2916 ---------------------------------------------------------------
2917 --
2918 procedure create_CPT_rows
2919 (
2920 p_validate in number default 0
2921 ,p_copy_entity_txn_id in number
2922 ,p_effective_date in date
2923 ,p_prefix_suffix_text in varchar2 default null
2924 ,p_reuse_object_flag in varchar2 default null
2925 ,p_target_business_group_id in varchar2 default null
2926 ,p_prefix_suffix_cd in varchar2 default null
2927 ) is
2928 --
2929 l_OPT_ID number;
2930 l_PGM_ID number;
2931 l_PTIP_ID number;
2932 cursor c_unique_CPT(l_table_alias varchar2) is
2933 select distinct cpe.information1,
2934 cpe.information2,
2935 cpe.information3,
2936 cpe.INFORMATION170 name,
2937 cpe.table_route_id,
2938 cpe.dml_operation,cpe.datetrack_mode
2939 from ben_copy_entity_results cpe,
2940 pqh_table_route tr
2941 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2942 and cpe.table_route_id = tr.table_route_id
2943 -- and tr.where_clause = l_BEN_CMBN_PTIP_OPT_F
2944 and tr.table_alias = l_table_alias
2945 and cpe.number_of_copies = 1 -- ADDITION
2946 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
2947 order by information1, information2; --added for bug: 5151945
2948 --
2949 --
2950 cursor c_CPT_min_max_dates(c_table_route_id number,
2951 c_information1 number) is
2952 select
2953 min(cpe.information2) min_esd,
2954 max(cpe.information3) min_eed
2955 from ben_copy_entity_results cpe
2956 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2957 and cpe.table_route_id = c_table_route_id
2958 and cpe.information1 = c_information1 ;
2959 --
2960 cursor c_CPT(c_table_route_id number,
2961 c_information1 number,
2962 c_information2 date,
2963 c_information3 date ) is
2964 select
2965 cpe.*
2966 from ben_copy_entity_results cpe
2967 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
2968 and cpe.table_route_id = c_table_route_id
2969 and cpe.information1 = c_information1
2970 and cpe.information2 = c_information2
2971 and cpe.information3 = c_information3
2972 and rownum = 1 ;
2973 -- Date Track target record
2974 cursor c_find_CPT_in_target( c_CPT_name varchar2,
2975 c_effective_start_date date,
2976 c_effective_end_date date,
2977 c_business_group_id number,
2978 c_new_pk_id number) is
2979 select
2980 CPT.cmbn_ptip_opt_id new_value
2981 from BEN_CMBN_PTIP_OPT_F CPT
2982 where CPT.name = c_CPT_name and
2983 nvl(CPT.OPT_ID,-999) = nvl(l_OPT_ID,-999) and
2984 nvl(CPT.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
2985 CPT.business_group_id = c_business_group_id
2986 and CPT.cmbn_ptip_opt_id <> c_new_pk_id
2987 --TEMPIK
2988 and c_effective_start_date between effective_start_date
2989 and effective_end_date ;
2990 --END TEMPIK
2991 /*TEMPIK
2992 and exists ( select null
2993 from BEN_CMBN_PTIP_OPT_F CPT1
2994 where CPT1.name = c_CPT_name and
2995 nvl(CPT1.OPT_ID,-999) = nvl(l_OPT_ID,-999) and
2996 nvl(CPT1.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
2997 CPT1.business_group_id = c_business_group_id
2998 and CPT1.effective_start_date <= c_effective_start_date )
2999 and exists ( select null
3000 from BEN_CMBN_PTIP_OPT_F CPT2
3001 where CPT2.name = c_CPT_name and
3002 nvl(CPT2.OPT_ID,-999) = nvl(l_OPT_ID,-999) and
3003 nvl(CPT2.PGM_ID,-999) = nvl(l_PGM_ID,-999) and
3004 CPT2.business_group_id = c_business_group_id
3005 and CPT2.effective_end_date >= c_effective_end_date )
3006 ;
3007 TEMPIK */
3008 --TEMPIK
3009 l_dt_rec_found boolean ;
3010 --END TEMPIK
3011 --
3012 cursor c_find_CPT_name_in_target( c_CPT_name varchar2,
3013 c_effective_start_date date,
3014 c_effective_end_date date,
3015 c_business_group_id number,
3016 c_new_pk_id number) is
3017 select
3018 CPT.cmbn_ptip_opt_id new_value
3019 from BEN_CMBN_PTIP_OPT_F CPT
3020 where CPT.name = c_CPT_name and
3021 CPT.business_group_id = c_business_group_id
3022 and CPT.cmbn_ptip_opt_id <> c_new_pk_id
3023 and exists ( select null
3024 from BEN_CMBN_PTIP_OPT_F CPT1
3025 where CPT1.name = c_CPT_name and
3026 CPT1.business_group_id = c_business_group_id
3027 and CPT1.effective_start_date <= c_effective_start_date )
3028 and exists ( select null
3029 from BEN_CMBN_PTIP_OPT_F CPT2
3030 where CPT2.name = c_CPT_name and
3031 CPT2.business_group_id = c_business_group_id
3032 and CPT2.effective_end_date >= c_effective_end_date )
3033 ;
3034 l_current_pk_id number := null ;
3035 --UPD START
3036 --
3037 l_update boolean := false ;
3038 l_datetrack_mode varchar2(80) := hr_api.g_update;
3039 l_process_date date;
3040 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
3041 --
3042 --UPD END
3043 l_prev_pk_id number := null ;
3044 l_first_rec boolean := true ;
3045 r_CPT c_CPT%rowtype;
3046 l_cmbn_ptip_opt_id number ;
3047 l_object_version_number number ;
3048 l_effective_start_date date ;
3049 l_effective_end_date date ;
3050 l_prefix pqh_copy_entity_attribs.information1%type := null;
3051 l_suffix pqh_copy_entity_attribs.information1%type := null;
3052 l_new_value number(15);
3053 l_object_found_in_target boolean := false ;
3054 l_min_esd date;
3055 l_max_eed date;
3056 l_effective_date date;
3057 --
3058 begin
3059 -- Initialization
3060 l_object_found_in_target := false ;
3061 -- End Initialization
3062
3063 for r_CPT_unique in c_unique_CPT('CPT') loop
3064
3065 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
3066 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3067 r_CPT_unique.information3 >=
3068 ben_pd_copy_to_ben_one.g_copy_effective_date)
3069 ) then
3070 --
3071 if p_prefix_suffix_cd = 'PREFIX' then
3072 l_prefix := p_prefix_suffix_text ;
3073 elsif p_prefix_suffix_cd = 'SUFFIX' then
3074 l_suffix := p_prefix_suffix_text ;
3075 else
3076 l_prefix := null ;
3077 l_suffix := null ;
3078 end if ;
3079 --
3080 hr_utility.set_location(' r_CPT_unique.table_route_id '||r_CPT_unique.table_route_id,10);
3081 hr_utility.set_location(' r_CPT_unique.information1 '||r_CPT_unique.information1,10);
3082 hr_utility.set_location( 'r_CPT_unique.information2 '||r_CPT_unique.information2,10);
3083 hr_utility.set_location( 'r_CPT_unique.information3 '||r_CPT_unique.information3,10);
3084 -- If reuse objects flag is 'Y' then check for the object in the target business group
3085 -- if found insert the record into PLSql table and exit the loop else try create the
3086 -- object in the target business group
3087 --
3088 l_object_found_in_target := false ;
3089 l_min_esd := null ;
3090 l_max_eed := null ;
3091 open c_CPT_min_max_dates(r_CPT_unique.table_route_id, r_CPT_unique.information1 ) ;
3092 fetch c_CPT_min_max_dates into l_min_esd,l_max_eed ;
3093 --
3094
3095 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3096 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
3097 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
3098 end if;
3099 l_min_esd := greatest(l_min_esd,r_CPT_unique.information2);
3100 open c_CPT(r_CPT_unique.table_route_id,
3101 r_CPT_unique.information1,
3102 r_CPT_unique.information2,
3103 r_CPT_unique.information3 ) ;
3104 --
3105 fetch c_CPT into r_CPT ;
3106 --
3107 close c_CPT ;
3108 --
3109 --UPD START
3110 l_update := false;
3111 l_process_date := p_effective_date;
3112 l_dml_operation:= r_CPT_unique.dml_operation ;
3113 --
3114 l_OPT_ID := get_fk('OPT_ID', r_CPT.INFORMATION247,l_dml_operation);
3115 l_PGM_ID := get_fk('PGM_ID', r_CPT.INFORMATION260,l_dml_operation);
3116 l_PTIP_ID := get_fk('PTIP_ID', r_CPT.INFORMATION259,l_dml_operation);
3117 if l_dml_operation = 'UPDATE' then
3118 --
3119 l_object_found_in_target := TRUE;
3120 --
3121 if l_process_date between r_CPT_unique.information2 and r_CPT_unique.information3 then
3122 l_update := true;
3123 if r_CPT_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
3124 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'CMBN_PTIP_OPT_ID' then
3125 g_pk_tbl(g_count).pk_id_column := 'CMBN_PTIP_OPT_ID' ;
3126 g_pk_tbl(g_count).old_value := r_CPT_unique.information1 ;
3127 g_pk_tbl(g_count).new_value := r_CPT_unique.information1 ;
3128 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
3129 g_pk_tbl(g_count).table_route_id := r_CPT_unique.table_route_id;
3130 --
3131 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
3132 --
3133 g_count := g_count + 1 ;
3134 --
3135 log_data('CPT',l_new_value,l_prefix || r_CPT_unique.name|| l_suffix,'REUSED');
3136 --
3137 end if ;
3138 hr_utility.set_location( 'found record for update',10);
3139 --
3140 else
3141 --
3142 l_update := false;
3143 --
3144 end if;
3145 else
3146 --
3147 --UPD END
3148 if p_reuse_object_flag = 'Y' then
3149 if c_CPT_min_max_dates%found then
3150 -- cursor to find the object
3151 open c_find_CPT_in_target( l_prefix || r_CPT_unique.name|| l_suffix ,l_min_esd,l_max_eed,
3152 p_target_business_group_id, nvl(l_cmbn_ptip_opt_id, -999) ) ;
3153 fetch c_find_CPT_in_target into l_new_value ;
3154 if c_find_CPT_in_target%found then
3155 --
3156 --TEMPIK
3157 l_dt_rec_found := dt_api.check_min_max_dates
3158 (p_base_table_name => 'BEN_CMBN_PTIP_OPT_F',
3159 p_base_key_column => 'CMBN_PTIP_OPT_ID',
3160 p_base_key_value => l_new_value,
3161 p_from_date => l_min_esd,
3162 p_to_date => l_max_eed );
3163 if l_dt_rec_found THEN
3164 --END TEMPIK
3165 if r_CPT_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
3166 nvl(ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count-1).pk_id_column, '999') <> 'CMBN_PTIP_OPT_ID' then
3167 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).pk_id_column := 'CMBN_PTIP_OPT_ID' ;
3168 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).old_value := r_CPT_unique.information1 ;
3169 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).new_value := l_new_value ;
3170 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'REUSED';
3171 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).table_route_id := r_CPT_unique.table_route_id;
3172 --
3173 -- update_cer_with_target( ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count) , p_copy_entity_txn_id) ;
3174 --
3175 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1 ;
3176 --
3177 log_data('CPT',l_new_value,l_prefix || r_CPT_unique.name|| l_suffix,'REUSED');
3178 --
3179 end if ;
3180 --
3181 l_object_found_in_target := true ;
3182 --TEMPIK
3183 end if; -- l_dt_rec_found
3184 --END TEMPIK
3185 else
3186 -- NEW
3187 if p_prefix_suffix_text is null then
3188 --
3189 open c_find_CPT_name_in_target( l_prefix || r_CPT_unique.name|| l_suffix ,
3190 l_min_esd,l_max_eed,
3191 p_target_business_group_id, nvl(l_cmbn_ptip_opt_id, -999) ) ;
3192 fetch c_find_CPT_name_in_target into l_new_value ;
3193 if c_find_CPT_name_in_target%found then
3194 --
3195 if p_prefix_suffix_cd = 'PREFIX' then
3196 l_prefix := BEN_PLAN_DESIGN_TXNS_API.g_pgm_pl_prefix_suffix_text ;
3197 elsif p_prefix_suffix_cd = 'SUFFIX' then
3198 l_suffix := BEN_PLAN_DESIGN_TXNS_API.g_pgm_pl_prefix_suffix_text ;
3199 else
3200 l_prefix := null ;
3201 l_suffix := null ;
3202 end if ;
3203 --
3204 end if;
3205 close c_find_CPT_name_in_target ;
3206 end if;
3207 --dbms_output.put_line(' Second Cursor ');
3208 end if;
3209 close c_find_CPT_in_target ;
3210 -- NEW
3211 --
3212 end if;
3213 end if ;
3214 --
3215 end if; --UPDATE
3216 close c_CPT_min_max_dates ;
3217 -- if not l_object_found_in_target then
3218 if not l_object_found_in_target OR l_update then
3219 --
3220 l_current_pk_id := r_CPT.information1;
3221 --
3222 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
3223 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
3224 --
3225 if l_current_pk_id = l_prev_pk_id then
3226 --
3227 l_first_rec := false ;
3228 --
3229 else
3230 --
3231 l_first_rec := true ;
3232 --
3233 end if ;
3234 --
3235 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_CMBN_PTIP_OPT_F' ,l_prefix || r_CPT.INFORMATION170 || l_suffix);
3236 --
3237
3238 l_effective_date := r_CPT.information2;
3239 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3240 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
3241 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
3242 end if;
3243
3244 if l_first_rec and not l_update then
3245 -- Call Create routine.
3246 hr_utility.set_location(' BEN_CMBN_PTIP_OPT_F CREATE_CMBN_PTIP_OPT ',20);
3247 BEN_CMBN_PTIP_OPT_API.CREATE_CMBN_PTIP_OPT(
3248 --
3249 P_VALIDATE => false
3250 ,P_EFFECTIVE_DATE => l_effective_date
3251 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
3252 --
3253 ,P_CMBN_PTIP_OPT_ID => l_cmbn_ptip_opt_id
3254 ,P_CPT_ATTRIBUTE1 => r_CPT.INFORMATION111
3255 ,P_CPT_ATTRIBUTE10 => r_CPT.INFORMATION120
3256 ,P_CPT_ATTRIBUTE11 => r_CPT.INFORMATION121
3257 ,P_CPT_ATTRIBUTE12 => r_CPT.INFORMATION122
3258 ,P_CPT_ATTRIBUTE13 => r_CPT.INFORMATION123
3259 ,P_CPT_ATTRIBUTE14 => r_CPT.INFORMATION124
3260 ,P_CPT_ATTRIBUTE15 => r_CPT.INFORMATION125
3261 ,P_CPT_ATTRIBUTE16 => r_CPT.INFORMATION126
3262 ,P_CPT_ATTRIBUTE17 => r_CPT.INFORMATION127
3263 ,P_CPT_ATTRIBUTE18 => r_CPT.INFORMATION128
3264 ,P_CPT_ATTRIBUTE19 => r_CPT.INFORMATION129
3265 ,P_CPT_ATTRIBUTE2 => r_CPT.INFORMATION112
3266 ,P_CPT_ATTRIBUTE20 => r_CPT.INFORMATION130
3267 ,P_CPT_ATTRIBUTE21 => r_CPT.INFORMATION131
3268 ,P_CPT_ATTRIBUTE22 => r_CPT.INFORMATION132
3269 ,P_CPT_ATTRIBUTE23 => r_CPT.INFORMATION133
3270 ,P_CPT_ATTRIBUTE24 => r_CPT.INFORMATION134
3271 ,P_CPT_ATTRIBUTE25 => r_CPT.INFORMATION135
3272 ,P_CPT_ATTRIBUTE26 => r_CPT.INFORMATION136
3273 ,P_CPT_ATTRIBUTE27 => r_CPT.INFORMATION137
3274 ,P_CPT_ATTRIBUTE28 => r_CPT.INFORMATION138
3275 ,P_CPT_ATTRIBUTE29 => r_CPT.INFORMATION139
3276 ,P_CPT_ATTRIBUTE3 => r_CPT.INFORMATION113
3277 ,P_CPT_ATTRIBUTE30 => r_CPT.INFORMATION140
3278 ,P_CPT_ATTRIBUTE4 => r_CPT.INFORMATION114
3279 ,P_CPT_ATTRIBUTE5 => r_CPT.INFORMATION115
3280 ,P_CPT_ATTRIBUTE6 => r_CPT.INFORMATION116
3281 ,P_CPT_ATTRIBUTE7 => r_CPT.INFORMATION117
3282 ,P_CPT_ATTRIBUTE8 => r_CPT.INFORMATION118
3283 ,P_CPT_ATTRIBUTE9 => r_CPT.INFORMATION119
3284 ,P_CPT_ATTRIBUTE_CATEGORY => r_CPT.INFORMATION110
3285 ,P_NAME => l_prefix || r_CPT.INFORMATION170 || l_suffix
3286 ,P_OPT_ID => l_OPT_ID
3287 ,P_PGM_ID => l_PGM_ID
3288 ,P_PTIP_ID => l_PTIP_ID
3289 --
3290 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3291 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3292 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3293 );
3294 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
3295 -- Update all relevent cer records with new pk_id
3296 hr_utility.set_location('Before plsql table ',222);
3297 hr_utility.set_location('new_value id '||l_cmbn_ptip_opt_id,222);
3298 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).pk_id_column := 'CMBN_PTIP_OPT_ID' ;
3299 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).old_value := r_CPT.information1 ;
3300 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).new_value := l_CMBN_PTIP_OPT_ID ;
3301 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).copy_reuse_type := 'COPIED';
3302 ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count).table_route_id := r_CPT_unique.table_route_id;
3303 hr_utility.set_location('After plsql table ',222);
3304 --
3305 -- update_cer_with_target( ben_pd_copy_to_ben_one.g_pk_tbl(ben_pd_copy_to_ben_one.g_count),p_copy_entity_txn_id ) ;
3306 --
3307 ben_pd_copy_to_ben_one.g_count := ben_pd_copy_to_ben_one.g_count + 1 ;
3308 --
3309 log_data('CPT',l_new_value,l_prefix || r_CPT.INFORMATION170 || l_suffix,'COPIED');
3310 --
3311 else
3312 --
3313 if l_update then
3314 --
3315 l_datetrack_mode := r_CPT.datetrack_mode ;
3316 --
3317 get_dt_modes(
3318 p_effective_date => l_process_date,
3319 p_effective_end_date => r_CPT.information3,
3320 p_effective_start_date => r_CPT.information2,
3321 p_dml_operation => r_CPT.dml_operation,
3322 p_datetrack_mode => l_datetrack_mode );
3323 -- p_update => l_update
3324 --
3325 l_effective_date := l_process_date;
3326 l_cmbn_ptip_opt_id := r_CPT.information1;
3327 l_object_version_number := r_CPT.information265;
3328 --
3329 end if;
3330 --
3331 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
3332 --
3333 IF l_update OR l_dml_operation <> 'UPDATE' THEN
3334 -- Call Update routine for the pk_id created in prev run .
3335 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
3336 hr_utility.set_location(' BEN_CMBN_PTIP_OPT_F UPDATE_CMBN_PTIP_OPT ',30);
3337 BEN_CMBN_PTIP_OPT_API.UPDATE_CMBN_PTIP_OPT(
3338 --
3339 P_VALIDATE => false
3340 ,P_EFFECTIVE_DATE => l_effective_date
3341 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
3342 --
3343 ,P_CMBN_PTIP_OPT_ID => l_cmbn_ptip_opt_id
3344 ,P_CPT_ATTRIBUTE1 => r_CPT.INFORMATION111
3345 ,P_CPT_ATTRIBUTE10 => r_CPT.INFORMATION120
3346 ,P_CPT_ATTRIBUTE11 => r_CPT.INFORMATION121
3347 ,P_CPT_ATTRIBUTE12 => r_CPT.INFORMATION122
3348 ,P_CPT_ATTRIBUTE13 => r_CPT.INFORMATION123
3349 ,P_CPT_ATTRIBUTE14 => r_CPT.INFORMATION124
3350 ,P_CPT_ATTRIBUTE15 => r_CPT.INFORMATION125
3351 ,P_CPT_ATTRIBUTE16 => r_CPT.INFORMATION126
3352 ,P_CPT_ATTRIBUTE17 => r_CPT.INFORMATION127
3353 ,P_CPT_ATTRIBUTE18 => r_CPT.INFORMATION128
3354 ,P_CPT_ATTRIBUTE19 => r_CPT.INFORMATION129
3355 ,P_CPT_ATTRIBUTE2 => r_CPT.INFORMATION112
3356 ,P_CPT_ATTRIBUTE20 => r_CPT.INFORMATION130
3357 ,P_CPT_ATTRIBUTE21 => r_CPT.INFORMATION131
3358 ,P_CPT_ATTRIBUTE22 => r_CPT.INFORMATION132
3359 ,P_CPT_ATTRIBUTE23 => r_CPT.INFORMATION133
3360 ,P_CPT_ATTRIBUTE24 => r_CPT.INFORMATION134
3361 ,P_CPT_ATTRIBUTE25 => r_CPT.INFORMATION135
3362 ,P_CPT_ATTRIBUTE26 => r_CPT.INFORMATION136
3363 ,P_CPT_ATTRIBUTE27 => r_CPT.INFORMATION137
3364 ,P_CPT_ATTRIBUTE28 => r_CPT.INFORMATION138
3365 ,P_CPT_ATTRIBUTE29 => r_CPT.INFORMATION139
3366 ,P_CPT_ATTRIBUTE3 => r_CPT.INFORMATION113
3367 ,P_CPT_ATTRIBUTE30 => r_CPT.INFORMATION140
3368 ,P_CPT_ATTRIBUTE4 => r_CPT.INFORMATION114
3369 ,P_CPT_ATTRIBUTE5 => r_CPT.INFORMATION115
3370 ,P_CPT_ATTRIBUTE6 => r_CPT.INFORMATION116
3371 ,P_CPT_ATTRIBUTE7 => r_CPT.INFORMATION117
3372 ,P_CPT_ATTRIBUTE8 => r_CPT.INFORMATION118
3373 ,P_CPT_ATTRIBUTE9 => r_CPT.INFORMATION119
3374 ,P_CPT_ATTRIBUTE_CATEGORY => r_CPT.INFORMATION110
3375 ,P_NAME => l_prefix || r_CPT.INFORMATION170 || l_suffix
3376 ,P_OPT_ID => l_OPT_ID
3377 ,P_PGM_ID => l_PGM_ID
3378 ,P_PTIP_ID => l_PTIP_ID
3379 --
3380 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3381 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3382 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3383 ,P_DATETRACK_MODE => l_datetrack_mode
3384 );
3385 --
3386 end if; --l_update
3387 end if;
3388 --
3389 -- Delete the row if it is end dated.
3390 --
3391 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
3392 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
3393 trunc(l_max_eed) = r_CPT.information3) then
3394 --
3395 BEN_CMBN_PTIP_OPT_API.delete_CMBN_PTIP_OPT(
3396 --
3397 p_validate => false
3398 ,p_cmbn_ptip_opt_id => l_cmbn_ptip_opt_id
3399 ,p_effective_start_date => l_effective_start_date
3400 ,p_effective_end_date => l_effective_end_date
3401 ,p_object_version_number => l_object_version_number
3402 ,p_effective_date => l_max_eed
3403 ,p_datetrack_mode => hr_api.g_delete
3404 --
3405 );
3406 --
3407 end if;
3408 --
3409 l_prev_pk_id := l_current_pk_id ;
3410 --
3411 end if;
3412 --
3413 end if;
3414 --
3415 end loop;
3416 --
3417 exception when others then
3418 --
3419 raise_error_message( 'CPT',l_prefix || r_CPT.INFORMATION170 || l_suffix) ;
3420 --
3421 end create_CPT_rows;
3422
3423 --
3424 ---------------------------------------------------------------
3425 ----------------------< create_BNB_rows >-----------------------
3426 ---------------------------------------------------------------
3427 --
3428 procedure create_BNB_rows
3429 (
3430 p_validate in number default 0
3431 ,p_copy_entity_txn_id in number
3432 ,p_effective_date in date
3433 ,p_prefix_suffix_text in varchar2 default null
3434 ,p_reuse_object_flag in varchar2 default null
3435 ,p_target_business_group_id in varchar2 default null
3436 ,p_prefix_suffix_cd in varchar2 default null
3437 ) is
3438 --
3439 --UPD START
3440 /*
3441 cursor c_unique_BNB(l_table_alias varchar2) is
3442 select distinct cpe.information1,
3443 cpe.information2,
3444 cpe.information3,
3445 cpe.INFORMATION170 name,
3446 cpe.table_route_id,
3447 cpe.dml_operation,cpe.datetrack_mode
3448 from ben_copy_entity_results cpe,
3449 pqh_table_route tr
3450 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3451 and cpe.table_route_id = tr.table_route_id
3452 -- and tr.where_clause = l_BEN_BNFTS_BAL_F
3453 and tr.table_alias = l_table_alias
3454 and cpe.number_of_copies = 1 --ADDITION
3455 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode ;
3456
3457 */
3458 cursor c_unique_BNB(l_table_alias varchar2) is
3459 select distinct cpe.information1,
3460 cpe.information2,
3461 cpe.information3,
3462 cpe.INFORMATION170 name,
3463 cpe.table_route_id,
3464 cpe.dml_operation,
3465 cpe.datetrack_mode
3466 from ben_copy_entity_results cpe
3467 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3468 and cpe.table_alias = l_table_alias
3469 and cpe.number_of_copies = 1 --ADDITION
3470 group by cpe.information1,
3471 cpe.information2,
3472 cpe.information3,
3473 cpe.INFORMATION170,
3474 cpe.table_route_id,
3475 cpe.dml_operation,
3476 cpe.datetrack_mode
3477 order by information1, information2; --added for bug: 5151945
3478 --UPD END
3479 --
3480 cursor c_BNB_min_max_dates(c_table_route_id number,
3481 c_information1 number) is
3482 select
3483 min(cpe.information2) min_esd,
3484 max(cpe.information3) min_eed
3485 from ben_copy_entity_results cpe
3486 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3487 and cpe.table_route_id = c_table_route_id
3488 and cpe.information1 = c_information1 ;
3489 --
3490 cursor c_BNB(c_table_route_id number,
3491 c_information1 number,
3492 c_information2 date,
3493 c_information3 date ) is
3494 select
3495 cpe.*
3496 from ben_copy_entity_results cpe
3497 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3498 and cpe.table_route_id = c_table_route_id
3499 and cpe.information1 = c_information1
3500 and cpe.information2 = c_information2
3501 and cpe.information3 = c_information3
3502 and rownum = 1 ;
3503 -- Date Track target record
3504 cursor c_find_BNB_in_target( c_BNB_name varchar2,
3505 c_effective_start_date date,
3506 c_effective_end_date date,
3507 c_business_group_id number,
3508 c_new_pk_id number) is
3509 select
3510 BNB.bnfts_bal_id new_value
3511 from BEN_BNFTS_BAL_F BNB
3512 where BNB.name = c_BNB_name
3513 and BNB.business_group_id = c_business_group_id
3514 and BNB.bnfts_bal_id <> c_new_pk_id
3515 --TEMPIK
3516 and c_effective_start_date between effective_start_date
3517 and effective_end_date ;
3518 --END TEMPIK
3519 /*TEMPIK
3520 and exists ( select null
3521 from BEN_BNFTS_BAL_F BNB1
3522 where BNB1.name = c_BNB_name
3523 and BNB1.business_group_id = c_business_group_id
3524 and BNB1.effective_start_date <= c_effective_start_date )
3525 and exists ( select null
3526 from BEN_BNFTS_BAL_F BNB2
3527 where BNB2.name = c_BNB_name
3528 and BNB2.business_group_id = c_business_group_id
3529 and BNB2.effective_end_date >= c_effective_end_date ) ;
3530 TEMPIK */
3531 --TEMPIK
3532 l_dt_rec_found boolean ;
3533 --END TEMPIK
3534 --
3535 --UPD START
3536 --
3537 l_update boolean := false ;
3538 l_datetrack_mode varchar2(80) := hr_api.g_update;
3539 l_process_date date;
3540 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
3541 --
3542 --UPD END
3543 --
3544 l_current_pk_id number := null ;
3545 l_prev_pk_id number := null ;
3546 l_first_rec boolean := true ;
3547 r_BNB c_BNB%rowtype;
3548 l_bnfts_bal_id number ;
3549 l_object_version_number number ;
3550 l_effective_start_date date ;
3551 l_effective_end_date date ;
3552 l_prefix pqh_copy_entity_attribs.information1%type := null;
3553 l_suffix pqh_copy_entity_attribs.information1%type := null;
3554 l_new_value number(15);
3555 l_object_found_in_target boolean := false ;
3556 l_min_esd date;
3557 l_max_eed date;
3558 l_effective_date date;
3559 --
3560 begin
3561 l_object_found_in_target := false ;
3562 -- End Initialization
3563 -- Derive the prefix - sufix
3564 if p_prefix_suffix_cd = 'PREFIX' then
3565 l_prefix := p_prefix_suffix_text ;
3566 elsif p_prefix_suffix_cd = 'SUFFIX' then
3567 l_suffix := p_prefix_suffix_text ;
3568 else
3569 l_prefix := null ;
3570 l_suffix := null ;
3571 end if ;
3572 -- End Prefix Sufix derivation
3573 for r_BNB_unique in c_unique_BNB('BNB') loop
3574
3575 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
3576 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3577 r_BNB_unique.information3 >=
3578 ben_pd_copy_to_ben_one.g_copy_effective_date)
3579 ) then
3580 --
3581 hr_utility.set_location(' r_BNB_unique.table_route_id '||r_BNB_unique.table_route_id,10);
3582 hr_utility.set_location(' r_BNB_unique.information1 '||r_BNB_unique.information1,10);
3583 hr_utility.set_location( 'r_BNB_unique.information2 '||r_BNB_unique.information2,10);
3584 hr_utility.set_location( 'r_BNB_unique.information3 '||r_BNB_unique.information3,10);
3585 hr_utility.set_location( 'p_effective_date'||p_effective_date,10);
3586 --
3587 -- If reuse objects flag is 'Y' then check for the object in the target business group
3588 -- if found insert the record into PLSql table and exit the loop else try create the
3589 -- object in the target business group
3590 --
3591 l_object_found_in_target := false ;
3592 --UPD START
3593 l_update := false;
3594 l_process_date := p_effective_date;
3595 l_dml_operation:= r_BNB_unique.dml_operation ;
3596 --
3597 if l_dml_operation = 'UPDATE' then
3598 --
3599 l_object_found_in_target := TRUE;
3600 --
3601 if l_process_date between r_BNB_unique.information2 and r_BNB_unique.information3 then
3602 l_update := true;
3603 if r_BNB_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
3604 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'BNFTS_BAL_ID' then
3605 g_pk_tbl(g_count).pk_id_column := 'BNFTS_BAL_ID' ;
3606 g_pk_tbl(g_count).old_value := r_BNB_unique.information1 ;
3607 g_pk_tbl(g_count).new_value := r_BNB_unique.information1 ;
3608 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
3609 g_pk_tbl(g_count).table_route_id := r_BNB_unique.table_route_id;
3610 --
3611 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
3612 --
3613 g_count := g_count + 1 ;
3614 --
3615 log_data('BNB',l_new_value,l_prefix || r_BNB_unique.name|| l_suffix,'REUSED');
3616 --
3617 end if ;
3618 hr_utility.set_location( 'found record for update',10);
3619 --
3620 else
3621 --
3622 l_update := false;
3623 --
3624 end if;
3625 else
3626 --
3627 --UPD END
3628 l_min_esd := null ;
3629 l_max_eed := null ;
3630 open c_BNB_min_max_dates(r_BNB_unique.table_route_id, r_BNB_unique.information1 ) ;
3631 fetch c_BNB_min_max_dates into l_min_esd,l_max_eed ;
3632 --
3633 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3634 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
3635 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
3636 end if;
3637 l_min_esd := greatest(l_min_esd,r_BNB_unique.information2);
3638 if p_reuse_object_flag = 'Y' then
3639 if c_BNB_min_max_dates%found then
3640 -- cursor to find the object
3641 open c_find_BNB_in_target( l_prefix ||r_BNB_unique.name || l_suffix,l_min_esd,l_max_eed,
3642 p_target_business_group_id, nvl(l_bnfts_bal_id, -999) ) ;
3643 fetch c_find_BNB_in_target into l_new_value ;
3644 if c_find_BNB_in_target%found then
3645 --
3646 --TEMPIK
3647 l_dt_rec_found := dt_api.check_min_max_dates
3648 (p_base_table_name => 'BEN_BNFTS_BAL_F',
3649 p_base_key_column => 'BNFTS_BAL_ID',
3650 p_base_key_value => l_new_value,
3651 p_from_date => l_min_esd,
3652 p_to_date => l_max_eed );
3653 --
3654 if l_dt_rec_found THEN
3655 --END TEMPIK
3656 if r_BNB_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
3657 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'BNFTS_BAL_ID' then
3658 g_pk_tbl(g_count).pk_id_column := 'BNFTS_BAL_ID' ;
3659 g_pk_tbl(g_count).old_value := r_BNB_unique.information1 ;
3660 g_pk_tbl(g_count).new_value := l_new_value ;
3661 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
3662 g_pk_tbl(g_count).table_route_id := r_BNB_unique.table_route_id;
3663 --
3664 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
3665 --
3666 g_count := g_count + 1 ;
3667 --
3668 log_data('BNB',l_new_value,l_prefix || r_BNB_unique.name|| l_suffix,'REUSED');
3669 --
3670 end if ;
3671 --
3672 l_object_found_in_target := true ;
3673 --TEMPIK
3674 end if; -- l_dt_rec_found
3675 --END TEMPIK
3676 end if;
3677 close c_find_BNB_in_target ;
3678 --
3679 end if;
3680 end if ;
3681 --
3682 close c_BNB_min_max_dates ;
3683 --
3684 --UPD START
3685 end if; --if p_dml_operation
3686 --
3687 -- if not l_object_found_in_target then
3688 if not l_object_found_in_target OR l_update then
3689 --
3690 --UPD END
3691 open c_BNB(r_BNB_unique.table_route_id,
3692 r_BNB_unique.information1,
3693 r_BNB_unique.information2,
3694 r_BNB_unique.information3 ) ;
3695 --
3696 fetch c_BNB into r_BNB ;
3697 --
3698 close c_BNB ;
3699 --
3700 l_current_pk_id := r_BNB.information1;
3701 --
3702 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
3703 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
3704 --
3705 if l_current_pk_id = l_prev_pk_id then
3706 --
3707 l_first_rec := false ;
3708 --
3709 else
3710 --
3711 l_first_rec := true ;
3712 --
3713 end if ;
3714 --
3715 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_BNFTS_BAL_F' ,l_prefix || r_BNB.INFORMATION170 || l_suffix);
3716 --
3717
3718 l_effective_date := r_BNB.information2;
3719 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
3720 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
3721 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
3722 end if;
3723 --UPD START
3724 --if l_first_rec and not l_update then
3725 if l_first_rec and not l_update then
3726 --UPD END
3727 -- Call Create routine.
3728 hr_utility.set_location(' BEN_BNFTS_BAL_F CREATE_BENEFITS_BALANCE ',20);
3729 BEN_BENEFITS_BALANCE_API.CREATE_BENEFITS_BALANCE(
3730 --
3731 P_VALIDATE => false
3732 ,P_EFFECTIVE_DATE => l_effective_date
3733 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
3734 --
3735 ,P_BNB_ATTRIBUTE1 => r_BNB.INFORMATION111
3736 ,P_BNB_ATTRIBUTE10 => r_BNB.INFORMATION120
3737 ,P_BNB_ATTRIBUTE11 => r_BNB.INFORMATION121
3738 ,P_BNB_ATTRIBUTE12 => r_BNB.INFORMATION122
3739 ,P_BNB_ATTRIBUTE13 => r_BNB.INFORMATION123
3740 ,P_BNB_ATTRIBUTE14 => r_BNB.INFORMATION124
3741 ,P_BNB_ATTRIBUTE15 => r_BNB.INFORMATION125
3742 ,P_BNB_ATTRIBUTE16 => r_BNB.INFORMATION126
3743 ,P_BNB_ATTRIBUTE17 => r_BNB.INFORMATION127
3744 ,P_BNB_ATTRIBUTE18 => r_BNB.INFORMATION128
3745 ,P_BNB_ATTRIBUTE19 => r_BNB.INFORMATION129
3746 ,P_BNB_ATTRIBUTE2 => r_BNB.INFORMATION112
3747 ,P_BNB_ATTRIBUTE20 => r_BNB.INFORMATION130
3748 ,P_BNB_ATTRIBUTE21 => r_BNB.INFORMATION131
3749 ,P_BNB_ATTRIBUTE22 => r_BNB.INFORMATION132
3750 ,P_BNB_ATTRIBUTE23 => r_BNB.INFORMATION133
3751 ,P_BNB_ATTRIBUTE24 => r_BNB.INFORMATION134
3752 ,P_BNB_ATTRIBUTE25 => r_BNB.INFORMATION135
3753 ,P_BNB_ATTRIBUTE26 => r_BNB.INFORMATION136
3754 ,P_BNB_ATTRIBUTE27 => r_BNB.INFORMATION137
3755 ,P_BNB_ATTRIBUTE28 => r_BNB.INFORMATION138
3756 ,P_BNB_ATTRIBUTE29 => r_BNB.INFORMATION139
3757 ,P_BNB_ATTRIBUTE3 => r_BNB.INFORMATION113
3758 ,P_BNB_ATTRIBUTE30 => r_BNB.INFORMATION140
3759 ,P_BNB_ATTRIBUTE4 => r_BNB.INFORMATION114
3760 ,P_BNB_ATTRIBUTE5 => r_BNB.INFORMATION115
3761 ,P_BNB_ATTRIBUTE6 => r_BNB.INFORMATION116
3762 ,P_BNB_ATTRIBUTE7 => r_BNB.INFORMATION117
3763 ,P_BNB_ATTRIBUTE8 => r_BNB.INFORMATION118
3764 ,P_BNB_ATTRIBUTE9 => r_BNB.INFORMATION119
3765 ,P_BNB_ATTRIBUTE_CATEGORY => r_BNB.INFORMATION110
3766 ,P_BNFTS_BAL_DESC => r_BNB.INFORMATION185
3767 ,P_BNFTS_BAL_ID => l_bnfts_bal_id
3768 ,P_BNFTS_BAL_USG_CD => r_BNB.INFORMATION11
3769 ,P_NAME => l_prefix || r_BNB.INFORMATION170 || l_suffix
3770 ,P_NNMNTRY_UOM => r_BNB.INFORMATION13
3771 ,P_UOM => r_BNB.INFORMATION12
3772 --
3773 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3774 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3775 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3776 );
3777 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
3778 -- Update all relevent cer records with new pk_id
3779 hr_utility.set_location('Before plsql table ',222);
3780 hr_utility.set_location('new_value id '||l_bnfts_bal_id,222);
3781 g_pk_tbl(g_count).pk_id_column := 'BNFTS_BAL_ID' ;
3782 g_pk_tbl(g_count).old_value := r_BNB.information1 ;
3783 g_pk_tbl(g_count).new_value := l_BNFTS_BAL_ID ;
3784 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
3785 g_pk_tbl(g_count).table_route_id := r_BNB_unique.table_route_id;
3786 hr_utility.set_location('After plsql table ',222);
3787 --
3788 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
3789 --
3790 g_count := g_count + 1 ;
3791 --
3792 log_data('BNB',l_new_value,l_prefix || r_BNB.INFORMATION170 || l_suffix,'COPIED');
3793 --
3794 else
3795 --
3796 -- Call Update routine for the pk_id created in prev run .
3797 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
3798 --
3799 --UPD START
3800 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
3801 --
3802 if l_update then
3803 --
3804 l_datetrack_mode := r_BNB.datetrack_mode ;
3805 --
3806 get_dt_modes(
3807 p_effective_date => l_process_date,
3808 p_effective_end_date => r_BNB.information3,
3809 p_effective_start_date => r_BNB.information2,
3810 p_dml_operation => r_BNB.dml_operation,
3811 p_datetrack_mode => l_datetrack_mode );
3812 -- p_update => l_update
3813 --
3814 l_effective_date := l_process_date;
3815 l_bnfts_bal_id := r_BNB.information1;
3816 l_object_version_number := r_BNB.information265;
3817 --
3818 end if;
3819 --
3820 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
3821 --
3822 IF l_update OR l_dml_operation <> 'UPDATE' THEN
3823 --UPD END
3824 --
3825 hr_utility.set_location(' BEN_BNFTS_BAL_F UPDATE_BENEFITS_BALANCE ',30);
3826 BEN_BENEFITS_BALANCE_API.UPDATE_BENEFITS_BALANCE(
3827 --
3828 P_VALIDATE => false
3829 ,P_EFFECTIVE_DATE => l_effective_date
3830 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
3831 --
3832 ,P_BNB_ATTRIBUTE1 => r_BNB.INFORMATION111
3833 ,P_BNB_ATTRIBUTE10 => r_BNB.INFORMATION120
3834 ,P_BNB_ATTRIBUTE11 => r_BNB.INFORMATION121
3835 ,P_BNB_ATTRIBUTE12 => r_BNB.INFORMATION122
3836 ,P_BNB_ATTRIBUTE13 => r_BNB.INFORMATION123
3837 ,P_BNB_ATTRIBUTE14 => r_BNB.INFORMATION124
3838 ,P_BNB_ATTRIBUTE15 => r_BNB.INFORMATION125
3839 ,P_BNB_ATTRIBUTE16 => r_BNB.INFORMATION126
3840 ,P_BNB_ATTRIBUTE17 => r_BNB.INFORMATION127
3841 ,P_BNB_ATTRIBUTE18 => r_BNB.INFORMATION128
3842 ,P_BNB_ATTRIBUTE19 => r_BNB.INFORMATION129
3843 ,P_BNB_ATTRIBUTE2 => r_BNB.INFORMATION112
3844 ,P_BNB_ATTRIBUTE20 => r_BNB.INFORMATION130
3845 ,P_BNB_ATTRIBUTE21 => r_BNB.INFORMATION131
3846 ,P_BNB_ATTRIBUTE22 => r_BNB.INFORMATION132
3847 ,P_BNB_ATTRIBUTE23 => r_BNB.INFORMATION133
3848 ,P_BNB_ATTRIBUTE24 => r_BNB.INFORMATION134
3849 ,P_BNB_ATTRIBUTE25 => r_BNB.INFORMATION135
3850 ,P_BNB_ATTRIBUTE26 => r_BNB.INFORMATION136
3851 ,P_BNB_ATTRIBUTE27 => r_BNB.INFORMATION137
3852 ,P_BNB_ATTRIBUTE28 => r_BNB.INFORMATION138
3853 ,P_BNB_ATTRIBUTE29 => r_BNB.INFORMATION139
3854 ,P_BNB_ATTRIBUTE3 => r_BNB.INFORMATION113
3855 ,P_BNB_ATTRIBUTE30 => r_BNB.INFORMATION140
3856 ,P_BNB_ATTRIBUTE4 => r_BNB.INFORMATION114
3857 ,P_BNB_ATTRIBUTE5 => r_BNB.INFORMATION115
3858 ,P_BNB_ATTRIBUTE6 => r_BNB.INFORMATION116
3859 ,P_BNB_ATTRIBUTE7 => r_BNB.INFORMATION117
3860 ,P_BNB_ATTRIBUTE8 => r_BNB.INFORMATION118
3861 ,P_BNB_ATTRIBUTE9 => r_BNB.INFORMATION119
3862 ,P_BNB_ATTRIBUTE_CATEGORY => r_BNB.INFORMATION110
3863 ,P_BNFTS_BAL_DESC => r_BNB.INFORMATION185
3864 ,P_BNFTS_BAL_ID => l_bnfts_bal_id
3865 ,P_BNFTS_BAL_USG_CD => r_BNB.INFORMATION11
3866 ,P_NAME => l_prefix || r_BNB.INFORMATION170 || l_suffix
3867 ,P_NNMNTRY_UOM => r_BNB.INFORMATION13
3868 ,P_UOM => r_BNB.INFORMATION12
3869 --
3870 ,P_EFFECTIVE_START_DATE => l_effective_start_date
3871 ,P_EFFECTIVE_END_DATE => l_effective_end_date
3872 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
3873 --UPD START
3874 -- ,P_DATETRACK_MODE => l_datetrack_mode
3875 ,P_DATETRACK_MODE => l_datetrack_mode
3876 --UPD END
3877 );
3878 --
3879 --UPD START
3880 end if; -- l_update
3881 --UPD END
3882 end if;
3883 --
3884 -- Delete the row if it is end dated.
3885 --
3886 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
3887 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
3888 trunc(l_max_eed) = r_BNB.information3) then
3889 --
3890 BEN_BENEFITS_BALANCE_API.delete_BENEFITS_BALANCE(
3891 --
3892 p_validate => false
3893 ,p_bnfts_bal_id => l_bnfts_bal_id
3894 ,p_effective_start_date => l_effective_start_date
3895 ,p_effective_end_date => l_effective_end_date
3896 ,p_object_version_number => l_object_version_number
3897 ,p_effective_date => l_max_eed
3898 ,p_datetrack_mode => hr_api.g_delete
3899 --
3900 );
3901 --
3902 end if;
3903 --
3904 l_prev_pk_id := l_current_pk_id ;
3905 --
3906 end if;
3907 --
3908 end if;
3909 --
3910 end loop;
3911 exception when others then
3912 --
3913 raise_error_message( 'BNB',l_prefix || r_BNB.INFORMATION170 || l_suffix) ;
3914 --
3915 end create_BNB_rows;
3916 --
3917 --
3918 ---------------------------------------------------------------
3919 ----------------------< create_CLF_rows >-----------------------
3920 ---------------------------------------------------------------
3921 --
3922 procedure create_CLF_rows
3923 (
3924 p_validate in number default 0
3925 ,p_copy_entity_txn_id in number
3926 ,p_effective_date in date
3927 ,p_prefix_suffix_text in varchar2 default null
3928 ,p_reuse_object_flag in varchar2 default null
3929 ,p_target_business_group_id in varchar2 default null
3930 ,p_prefix_suffix_cd in varchar2 default null
3931 ) is
3932 --
3933 cursor c_unique_CLF(l_table_alias varchar2) is
3934 select distinct cpe.information1,
3935 cpe.information2,
3936 cpe.information3,
3937 cpe.INFORMATION170 name,
3938 cpe.table_route_id,
3939 cpe.dml_operation --UPD
3940 from ben_copy_entity_results cpe
3941 -- pqh_table_route tr UPD
3942 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3943 -- and cpe.table_route_id = tr.table_route_id UPD
3944 -- and tr.where_clause = l_BEN_COMP_LVL_FCTR
3945 and cpe.table_alias = l_table_alias --UPD
3946 and cpe.number_of_copies = 1 --ADDITION
3947 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,
3948 cpe.dml_operation
3949 order by information1, information2; --added for bug: 5151945
3950 --
3951 --
3952 cursor c_CLF_min_max_dates(c_table_route_id number,
3953 c_information1 number) is
3954 select
3955 min(cpe.information2) min_esd,
3956 max(cpe.information3) min_eed
3957 from ben_copy_entity_results cpe
3958 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3959 and cpe.table_route_id = c_table_route_id
3960 and cpe.information1 = c_information1 ;
3961 --
3962 cursor c_CLF(c_table_route_id number,
3963 c_information1 number,
3964 c_information2 date,
3965 c_information3 date ) is
3966 select
3967 cpe.*
3968 from ben_copy_entity_results cpe
3969 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
3970 and cpe.table_route_id = c_table_route_id
3971 and cpe.information1 = c_information1
3972 and rownum = 1 ;
3973 -- Date Track target record
3974 cursor c_find_CLF_in_target( c_CLF_name varchar2,
3975 c_effective_start_date date,
3976 c_effective_end_date date,
3977 c_business_group_id number,
3978 c_new_pk_id number) is
3979 select
3980 CLF.comp_lvl_fctr_id new_value
3981 from BEN_COMP_LVL_FCTR CLF
3982 where CLF.name = c_CLF_name
3983 and CLF.business_group_id = c_business_group_id
3984 and CLF.comp_lvl_fctr_id <> c_new_pk_id;
3985 --
3986 l_current_pk_id number := null ;
3987 --UPD START
3988 --
3989 l_update boolean := false ;
3990 l_datetrack_mode varchar2(80) := hr_api.g_update;
3991 l_process_date date;
3992 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
3993 --
3994 --UPD END
3995 l_prev_pk_id number := null ;
3996 l_first_rec boolean := true ;
3997 r_CLF c_CLF%rowtype;
3998 l_comp_lvl_fctr_id number ;
3999 l_object_version_number number ;
4000 l_effective_start_date date ;
4001 l_effective_end_date date ;
4002 l_prefix pqh_copy_entity_attribs.information1%type := null;
4003 l_suffix pqh_copy_entity_attribs.information1%type := null;
4004 l_new_value number(15);
4005 l_object_found_in_target boolean := false ;
4006 l_min_esd date;
4007 l_max_eed date;
4008 -- NEW
4009 l_bnfts_bal_id number;
4010 l_defined_balance_id number ;
4011 --
4012 l_parent_effective_start_date date;
4013 --
4014 l_COMP_CALC_RL number(15);
4015 l_COMP_LVL_DET_RL number(15);
4016 l_RNDG_RL number(15);
4017 --
4018 begin
4019 l_object_found_in_target := false ;
4020 -- End Initialization
4021 -- Derive the prefix - sufix
4022 if p_prefix_suffix_cd = 'PREFIX' then
4023 l_prefix := p_prefix_suffix_text ;
4024 elsif p_prefix_suffix_cd = 'SUFFIX' then
4025 l_suffix := p_prefix_suffix_text ;
4026 else
4027 l_prefix := null ;
4028 l_suffix := null ;
4029 end if ;
4030 -- End Prefix Sufix derivation
4031 for r_CLF_unique in c_unique_CLF('CLF') loop
4032 --
4033 hr_utility.set_location(' r_CLF_unique.table_route_id '||r_CLF_unique.table_route_id,10);
4034 hr_utility.set_location(' r_CLF_unique.information1 '||r_CLF_unique.information1,10);
4035 hr_utility.set_location( 'r_CLF_unique.information2 '||r_CLF_unique.information2,10);
4036 hr_utility.set_location( 'r_CLF_unique.information3 '||r_CLF_unique.information3,10);
4037 -- If reuse objects flag is 'Y' then check for the object in the target business group
4038 -- if found insert the record into PLSql table and exit the loop else try create the
4039 -- object in the target business group
4040 --
4041 l_object_found_in_target := false ;
4042 l_min_esd := null ;
4043 l_max_eed := null ;
4044
4045 --
4046 open c_CLF(r_CLF_unique.table_route_id,
4047 r_CLF_unique.information1,
4048 r_CLF_unique.information2,
4049 r_CLF_unique.information3 ) ;
4050 --
4051 fetch c_CLF into r_CLF ;
4052 --
4053 close c_CLF ;
4054
4055 --
4056 l_dml_operation := r_CLF_unique.dml_operation;
4057 --
4058 l_BNFTS_BAL_ID := get_fk('BNFTS_BAL_ID', r_CLF.INFORMATION225,l_dml_operation);
4059 l_COMP_CALC_RL := get_fk('FORMULA_ID', r_CLF.INFORMATION262,l_dml_operation);
4060 l_COMP_LVL_DET_RL := get_fk('FORMULA_ID', r_CLF.INFORMATION257,l_dml_operation);
4061 l_RNDG_RL := get_fk('FORMULA_ID', r_CLF.INFORMATION258,l_dml_operation);
4062 --
4063 -- Do not copy CLF if Comp_Src_Cd = 'Benefit Balance Type' and Benefit Balance is not copied over
4064 --
4065 hr_utility.set_location( 'r_CLF.information16'||r_CLF.information16,1);
4066 hr_utility.set_location( 'l_bnfts_bal_id '||l_bnfts_bal_id,1);
4067 hr_utility.set_location( 'l_dml_operation'||l_dml_operation,1);
4068 --
4069 if r_CLF.information16 = 'BNFTBALTYP' and l_bnfts_bal_id is null then
4070 -- Need to populate the FK's for RHI to go thru fine.
4071 g_pk_tbl(g_count).pk_id_column := 'COMP_LVL_FCTR_ID' ;
4072 g_pk_tbl(g_count).old_value := r_CLF_unique.information1 ;
4073 g_pk_tbl(g_count).new_value := r_CLF_unique.information1 ;
4074 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
4075 g_pk_tbl(g_count).table_route_id := r_CLF_unique.table_route_id;
4076 --
4077 g_count := g_count + 1 ;
4078 else
4079 --UPD START
4080 --
4081 l_update := false;
4082 --
4083 if l_dml_operation = 'UPDATE' then
4084 --
4085 l_update := true;
4086 if r_CLF_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
4087 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'COMP_LVL_FCTR_ID' then
4088 g_pk_tbl(g_count).pk_id_column := 'COMP_LVL_FCTR_ID' ;
4089 g_pk_tbl(g_count).old_value := r_CLF_unique.information1 ;
4090 g_pk_tbl(g_count).new_value := r_CLF_unique.information1 ;
4091 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
4092 g_pk_tbl(g_count).table_route_id := r_CLF_unique.table_route_id;
4093 --
4094 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ; -- NEW
4095 --
4096 g_count := g_count + 1 ;
4097 --
4098 log_data('CLF',l_new_value,l_prefix || r_CLF_unique.name|| l_suffix,'REUSED');
4099 --
4100 end if ;
4101 l_comp_lvl_fctr_id := r_CLF_unique.information1 ;
4102 l_object_version_number := r_CLF.information265 ;
4103 hr_utility.set_location( 'found record for update',10);
4104 --
4105 else
4106 --UPD END
4107 --
4108 if p_reuse_object_flag = 'Y' then
4109 -- cursor to find the object
4110 open c_find_CLF_in_target( l_prefix || r_CLF_unique.name|| l_suffix ,r_CLF_unique.information2,l_max_eed,
4111 p_target_business_group_id, nvl(l_comp_lvl_fctr_id, -999) ) ;
4112 fetch c_find_CLF_in_target into l_new_value ;
4113 if c_find_CLF_in_target%found then
4114 --
4115 if r_CLF_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
4116 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'COMP_LVL_FCTR_ID' then
4117 g_pk_tbl(g_count).pk_id_column := 'COMP_LVL_FCTR_ID' ;
4118 g_pk_tbl(g_count).old_value := r_CLF_unique.information1 ;
4119 g_pk_tbl(g_count).new_value := l_new_value ;
4120 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
4121 g_pk_tbl(g_count).table_route_id := r_CLF_unique.table_route_id;
4122 --
4123 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ; -- NEW
4124 --
4125 g_count := g_count + 1 ;
4126 --
4127 log_data('CLF',l_new_value,l_prefix || r_CLF_unique.name|| l_suffix,'REUSED');
4128 --
4129 end if ;
4130 --
4131 l_object_found_in_target := true ;
4132 end if;
4133 close c_find_CLF_in_target ;
4134 end if ;
4135 --
4136 --UPD START
4137 end if ;
4138 -- if not l_object_found_in_target then
4139 if not l_object_found_in_target OR l_update then
4140 --
4141 --UPD END
4142 --
4143 l_current_pk_id := r_CLF.information1;
4144 --
4145 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
4146 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
4147 --
4148 if l_current_pk_id = l_prev_pk_id then
4149 --
4150 l_first_rec := false ;
4151 --
4152 else
4153 --
4154 l_first_rec := true ;
4155 --
4156 end if ;
4157 --
4158 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_COMP_LVL_FCTR' ,l_prefix || r_CLF.INFORMATION170 || l_suffix);
4159 --
4160
4161 l_parent_effective_start_date := r_CLF.information10;
4162 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null ) then
4163 if l_parent_effective_start_date is null then
4164 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
4165 elsif l_parent_effective_start_date < ben_pd_copy_to_ben_one.g_copy_effective_date then
4166 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
4167 end if;
4168 end if;
4169
4170 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
4171 l_defined_balance_id := r_CLF.information176 ;
4172 else
4173 l_defined_balance_id := r_CLF.information174 ;
4174 end if ;
4175 --
4176 --UPD START
4177 --To avoid creating a child with out a parent
4178 --
4179 --
4180 if r_CLF.information16 = 'BNFTBALTYP' and l_BNFTS_BAL_ID is null then
4181 l_first_rec := false ;
4182 end if;
4183 --
4184 if l_first_rec and not l_update then
4185 --UPD END
4186 -- Call Create routine.
4187 hr_utility.set_location(' BEN_COMP_LVL_FCTR CREATE_COMP_LEVEL_FACTORS ',20);
4188
4189 BEN_COMP_LEVEL_FACTORS_API.CREATE_COMP_LEVEL_FACTORS(
4190 --
4191 P_VALIDATE => false
4192 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
4193 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
4194 --
4195 ,P_BNFTS_BAL_ID => l_BNFTS_BAL_ID
4196 ,P_CLF_ATTRIBUTE1 => r_CLF.INFORMATION111
4197 ,P_CLF_ATTRIBUTE10 => r_CLF.INFORMATION120
4198 ,P_CLF_ATTRIBUTE11 => r_CLF.INFORMATION121
4199 ,P_CLF_ATTRIBUTE12 => r_CLF.INFORMATION122
4200 ,P_CLF_ATTRIBUTE13 => r_CLF.INFORMATION123
4201 ,P_CLF_ATTRIBUTE14 => r_CLF.INFORMATION124
4202 ,P_CLF_ATTRIBUTE15 => r_CLF.INFORMATION125
4203 ,P_CLF_ATTRIBUTE16 => r_CLF.INFORMATION126
4204 ,P_CLF_ATTRIBUTE17 => r_CLF.INFORMATION127
4205 ,P_CLF_ATTRIBUTE18 => r_CLF.INFORMATION128
4206 ,P_CLF_ATTRIBUTE19 => r_CLF.INFORMATION129
4207 ,P_CLF_ATTRIBUTE2 => r_CLF.INFORMATION112
4208 ,P_CLF_ATTRIBUTE20 => r_CLF.INFORMATION130
4209 ,P_CLF_ATTRIBUTE21 => r_CLF.INFORMATION131
4210 ,P_CLF_ATTRIBUTE22 => r_CLF.INFORMATION132
4211 ,P_CLF_ATTRIBUTE23 => r_CLF.INFORMATION133
4212 ,P_CLF_ATTRIBUTE24 => r_CLF.INFORMATION134
4213 ,P_CLF_ATTRIBUTE25 => r_CLF.INFORMATION135
4214 ,P_CLF_ATTRIBUTE26 => r_CLF.INFORMATION136
4215 ,P_CLF_ATTRIBUTE27 => r_CLF.INFORMATION137
4216 ,P_CLF_ATTRIBUTE28 => r_CLF.INFORMATION138
4217 ,P_CLF_ATTRIBUTE29 => r_CLF.INFORMATION139
4218 ,P_CLF_ATTRIBUTE3 => r_CLF.INFORMATION113
4219 ,P_CLF_ATTRIBUTE30 => r_CLF.INFORMATION140
4220 ,P_CLF_ATTRIBUTE4 => r_CLF.INFORMATION114
4221 ,P_CLF_ATTRIBUTE5 => r_CLF.INFORMATION115
4222 ,P_CLF_ATTRIBUTE6 => r_CLF.INFORMATION116
4223 ,P_CLF_ATTRIBUTE7 => r_CLF.INFORMATION117
4224 ,P_CLF_ATTRIBUTE8 => r_CLF.INFORMATION118
4225 ,P_CLF_ATTRIBUTE9 => r_CLF.INFORMATION119
4226 ,P_CLF_ATTRIBUTE_CATEGORY => r_CLF.INFORMATION110
4227 ,P_COMP_ALT_VAL_TO_USE_CD => r_CLF.INFORMATION11
4228 ,P_COMP_CALC_RL => l_COMP_CALC_RL
4229 ,P_COMP_LVL_DET_CD => r_CLF.INFORMATION18
4230 ,P_COMP_LVL_DET_RL => l_COMP_LVL_DET_RL
4231 ,P_COMP_LVL_FCTR_ID => l_comp_lvl_fctr_id
4232 ,P_COMP_LVL_UOM => r_CLF.INFORMATION15
4233 ,P_COMP_SRC_CD => r_CLF.INFORMATION16
4234 ,P_DEFINED_BALANCE_ID => l_DEFINED_BALANCE_ID
4235 ,P_MN_COMP_VAL => r_CLF.INFORMATION294
4236 ,P_MX_COMP_VAL => r_CLF.INFORMATION293
4237 ,P_NAME => l_prefix || r_CLF.INFORMATION170 || l_suffix
4238 ,P_NO_MN_COMP_FLAG => r_CLF.INFORMATION13
4239 ,P_NO_MX_COMP_FLAG => r_CLF.INFORMATION12
4240 ,P_RNDG_CD => r_CLF.INFORMATION14
4241 ,P_RNDG_RL => l_RNDG_RL
4242 ,P_STTD_SAL_PRDCTY_CD => r_CLF.INFORMATION17
4243 ,p_proration_flag => r_CLF.INFORMATION20
4244 ,p_start_day_mo => r_CLF.INFORMATION21
4245 ,p_end_day_mo => r_CLF.INFORMATION22
4246 ,p_start_year => r_CLF.INFORMATION23
4247 ,p_end_year => r_CLF.INFORMATION24
4248 --
4249 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
4250 );
4251 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
4252 -- Update all relevent cer records with new pk_id
4253 hr_utility.set_location('Before plsql table ',222);
4254 hr_utility.set_location('new_value id '||l_comp_lvl_fctr_id,222);
4255 g_pk_tbl(g_count).pk_id_column := 'COMP_LVL_FCTR_ID' ;
4256 g_pk_tbl(g_count).old_value := r_CLF.information1 ;
4257 g_pk_tbl(g_count).new_value := l_COMP_LVL_FCTR_ID ;
4258 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
4259 g_pk_tbl(g_count).table_route_id := r_CLF_unique.table_route_id;
4260 hr_utility.set_location('After plsql table ',222);
4261 --
4262 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ; -- NEW
4263 --
4264 g_count := g_count + 1 ;
4265 --
4266 log_data('CLF',l_new_value,l_prefix || r_CLF.INFORMATION170 || l_suffix,'COPIED');
4267 --
4268 --UPD START
4269 elsif l_update THEN
4270 --
4271 hr_utility.set_location(' BEN_COMP_LVL_FCTR UPDATE_COMP_LEVEL_FACTORS ',20);
4272 --
4273 BEN_COMP_LEVEL_FACTORS_API.UPDATE_COMP_LEVEL_FACTORS(
4274 --
4275 P_VALIDATE => false
4276 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
4277 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
4278 --
4279 ,P_BNFTS_BAL_ID => l_BNFTS_BAL_ID
4280 ,P_CLF_ATTRIBUTE1 => r_CLF.INFORMATION111
4281 ,P_CLF_ATTRIBUTE10 => r_CLF.INFORMATION120
4282 ,P_CLF_ATTRIBUTE11 => r_CLF.INFORMATION121
4283 ,P_CLF_ATTRIBUTE12 => r_CLF.INFORMATION122
4284 ,P_CLF_ATTRIBUTE13 => r_CLF.INFORMATION123
4285 ,P_CLF_ATTRIBUTE14 => r_CLF.INFORMATION124
4286 ,P_CLF_ATTRIBUTE15 => r_CLF.INFORMATION125
4287 ,P_CLF_ATTRIBUTE16 => r_CLF.INFORMATION126
4288 ,P_CLF_ATTRIBUTE17 => r_CLF.INFORMATION127
4289 ,P_CLF_ATTRIBUTE18 => r_CLF.INFORMATION128
4290 ,P_CLF_ATTRIBUTE19 => r_CLF.INFORMATION129
4291 ,P_CLF_ATTRIBUTE2 => r_CLF.INFORMATION112
4292 ,P_CLF_ATTRIBUTE20 => r_CLF.INFORMATION130
4293 ,P_CLF_ATTRIBUTE21 => r_CLF.INFORMATION131
4294 ,P_CLF_ATTRIBUTE22 => r_CLF.INFORMATION132
4295 ,P_CLF_ATTRIBUTE23 => r_CLF.INFORMATION133
4296 ,P_CLF_ATTRIBUTE24 => r_CLF.INFORMATION134
4297 ,P_CLF_ATTRIBUTE25 => r_CLF.INFORMATION135
4298 ,P_CLF_ATTRIBUTE26 => r_CLF.INFORMATION136
4299 ,P_CLF_ATTRIBUTE27 => r_CLF.INFORMATION137
4300 ,P_CLF_ATTRIBUTE28 => r_CLF.INFORMATION138
4301 ,P_CLF_ATTRIBUTE29 => r_CLF.INFORMATION139
4302 ,P_CLF_ATTRIBUTE3 => r_CLF.INFORMATION113
4303 ,P_CLF_ATTRIBUTE30 => r_CLF.INFORMATION140
4304 ,P_CLF_ATTRIBUTE4 => r_CLF.INFORMATION114
4305 ,P_CLF_ATTRIBUTE5 => r_CLF.INFORMATION115
4306 ,P_CLF_ATTRIBUTE6 => r_CLF.INFORMATION116
4307 ,P_CLF_ATTRIBUTE7 => r_CLF.INFORMATION117
4308 ,P_CLF_ATTRIBUTE8 => r_CLF.INFORMATION118
4309 ,P_CLF_ATTRIBUTE9 => r_CLF.INFORMATION119
4310 ,P_CLF_ATTRIBUTE_CATEGORY => r_CLF.INFORMATION110
4311 ,P_COMP_ALT_VAL_TO_USE_CD => r_CLF.INFORMATION11
4312 ,P_COMP_CALC_RL => l_COMP_CALC_RL
4313 ,P_COMP_LVL_DET_CD => r_CLF.INFORMATION18
4314 ,P_COMP_LVL_DET_RL => l_COMP_LVL_DET_RL
4315 ,P_COMP_LVL_FCTR_ID => l_comp_lvl_fctr_id
4316 ,P_COMP_LVL_UOM => r_CLF.INFORMATION15
4317 ,P_COMP_SRC_CD => r_CLF.INFORMATION16
4318 ,P_DEFINED_BALANCE_ID => l_DEFINED_BALANCE_ID
4319 ,P_MN_COMP_VAL => r_CLF.INFORMATION294
4320 ,P_MX_COMP_VAL => r_CLF.INFORMATION293
4321 ,P_NAME => l_prefix || r_CLF.INFORMATION170 || l_suffix
4322 ,P_NO_MN_COMP_FLAG => r_CLF.INFORMATION13
4323 ,P_NO_MX_COMP_FLAG => r_CLF.INFORMATION12
4324 ,P_RNDG_CD => r_CLF.INFORMATION14
4325 ,P_RNDG_RL => l_RNDG_RL
4326 ,P_STTD_SAL_PRDCTY_CD => r_CLF.INFORMATION17
4327 ,p_proration_flag => r_CLF.INFORMATION20
4328 ,p_start_day_mo => r_CLF.INFORMATION21
4329 ,p_end_day_mo => r_CLF.INFORMATION22
4330 ,p_start_year => r_CLF.INFORMATION23
4331 ,p_end_year => r_CLF.INFORMATION24
4332 --
4333 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
4334 );
4335 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
4336 --UPD END
4337 end if;
4338 --
4339 l_prev_pk_id := l_current_pk_id ;
4340 --
4341 end if;
4342 --
4343 end if;
4344 --
4345 end loop;
4346
4347 exception when others then
4348 --
4349 raise_error_message( 'CLF',l_prefix || r_CLF.INFORMATION170 || l_suffix) ;
4350 --
4351 end create_CLF_rows;
4352
4353
4354 --
4355 ---------------------------------------------------------------
4356 ----------------------< create_HWF_rows >-----------------------
4357 ---------------------------------------------------------------
4358 --
4359 procedure create_HWF_rows
4360 (
4361 p_validate in number default 0
4362 ,p_copy_entity_txn_id in number
4363 ,p_effective_date in date
4364 ,p_prefix_suffix_text in varchar2 default null
4365 ,p_reuse_object_flag in varchar2 default null
4366 ,p_target_business_group_id in varchar2 default null
4367 ,p_prefix_suffix_cd in varchar2 default null
4368 ) is
4369 --
4370 cursor c_unique_HWF(l_table_alias varchar2) is
4371 select distinct cpe.information1,
4372 cpe.information2,
4373 cpe.information3,
4374 cpe.INFORMATION170 name,
4375 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
4376 from ben_copy_entity_results cpe,
4377 pqh_table_route tr
4378 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4379 and cpe.table_route_id = tr.table_route_id
4380 -- and tr.where_clause = l_BEN_HRS_WKD_IN_PERD_FCTR
4381 and tr.table_alias = l_table_alias
4382 and cpe.number_of_copies = 1 --ADDITION
4383 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
4384 order by information1, information2; --added for bug: 5151945
4385 --
4386 --
4387 cursor c_HWF_min_max_dates(c_table_route_id number,
4388 c_information1 number) is
4389 select
4390 min(cpe.information2) min_esd,
4391 max(cpe.information3) min_eed
4392 from ben_copy_entity_results cpe
4393 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4394 and cpe.table_route_id = c_table_route_id
4395 and cpe.information1 = c_information1 ;
4396 --
4397 cursor c_HWF(c_table_route_id number,
4398 c_information1 number,
4399 c_information2 date,
4400 c_information3 date ) is
4401 select
4402 cpe.*
4403 from ben_copy_entity_results cpe
4404 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4405 and cpe.table_route_id = c_table_route_id
4406 and cpe.information1 = c_information1
4407 and rownum = 1 ;
4408 -- Date Track target record
4409 cursor c_find_HWF_in_target( c_HWF_name varchar2,
4410 c_effective_start_date date,
4411 c_effective_end_date date,
4412 c_business_group_id number,
4413 c_new_pk_id number) is
4414 select
4415 HWF.hrs_wkd_in_perd_fctr_id new_value
4416 from BEN_HRS_WKD_IN_PERD_FCTR HWF
4417 where HWF.name = c_HWF_name
4418 and HWF.business_group_id = c_business_group_id
4419 and HWF.hrs_wkd_in_perd_fctr_id <> c_new_pk_id
4420 ;
4421 --
4422 l_current_pk_id number := null ;
4423 --UPD START
4424 --
4425 l_update boolean := false ;
4426 l_datetrack_mode varchar2(80) := hr_api.g_update;
4427 l_process_date date;
4428 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
4429 --
4430 --UPD END
4431 l_prev_pk_id number := null ;
4432 l_first_rec boolean := true ;
4433 r_HWF c_HWF%rowtype;
4434 l_hrs_wkd_in_perd_fctr_id number ;
4435 l_object_version_number number ;
4436 l_effective_start_date date ;
4437 l_effective_end_date date ;
4438 l_prefix pqh_copy_entity_attribs.information1%type := null;
4439 l_suffix pqh_copy_entity_attribs.information1%type := null;
4440 l_new_value number(15);
4441 l_object_found_in_target boolean := false ;
4442 l_min_esd date;
4443 l_max_eed date;
4444 l_BNFTS_BAL_ID number;
4445 l_DEFINED_BALANCE_ID number;
4446 l_HRS_WKD_CALC_RL number;
4447 l_HRS_WKD_DET_RL number;
4448 l_RNDG_RL number;
4449 l_parent_effective_start_date date;
4450 --
4451 begin
4452 -- Initialization
4453 l_object_found_in_target := false ;
4454 -- End Initialization
4455 -- Derive the prefix - sufix
4456 if p_prefix_suffix_cd = 'PREFIX' then
4457 l_prefix := p_prefix_suffix_text ;
4458 elsif p_prefix_suffix_cd = 'SUFFIX' then
4459 l_suffix := p_prefix_suffix_text ;
4460 else
4461 l_prefix := null ;
4462 l_suffix := null ;
4463 end if ;
4464 -- End Prefix Sufix derivation
4465 for r_HWF_unique in c_unique_HWF('HWF') loop
4466 --
4467 hr_utility.set_location(' r_HWF_unique.table_route_id '||r_HWF_unique.table_route_id,10);
4468 hr_utility.set_location(' r_HWF_unique.information1 '||r_HWF_unique.information1,10);
4469 hr_utility.set_location( 'r_HWF_unique.information2 '||r_HWF_unique.information2,10);
4470 hr_utility.set_location( 'r_HWF_unique.information3 '||r_HWF_unique.information3,10);
4471 -- If reuse objects flag is 'Y' then check for the object in the target business group
4472 -- if found insert the record into PLSql table and exit the loop else try create the
4473 -- object in the target business group
4474 --
4475 l_object_found_in_target := false ;
4476 l_min_esd := null ;
4477 l_max_eed := null ;
4478
4479
4480 open c_HWF(r_HWF_unique.table_route_id,
4481 r_HWF_unique.information1,
4482 r_HWF_unique.information2,
4483 r_HWF_unique.information3 ) ;
4484 --
4485 fetch c_HWF into r_HWF ;
4486 --
4487 close c_HWF ;
4488 --
4489 l_update := false;
4490 l_process_date := p_effective_date;
4491 l_dml_operation:= r_HWF_unique.dml_operation ;
4492 --
4493 l_BNFTS_BAL_ID := get_fk('BNFTS_BAL_ID', r_HWF.INFORMATION225,l_dml_operation);
4494 l_HRS_WKD_CALC_RL := get_fk('FORMULA_ID', r_HWF.INFORMATION257,l_dml_operation);
4495 l_HRS_WKD_DET_RL := get_fk('FORMULA_ID', r_HWF.INFORMATION258,l_dml_operation);
4496 l_RNDG_RL := get_fk('FORMULA_ID', r_HWF.INFORMATION259,l_dml_operation);
4497 --
4498 --
4499 -- Do not copy HWF if Hrs_Src_Cd = 'Benefit Balance Type' and Benefit Balance is not copied over
4500 --
4501 if r_HWF.information13 = 'BNFTBALTYP' and l_bnfts_bal_id is null then
4502 -- bug 4112422
4503 g_pk_tbl(g_count).pk_id_column := 'HRS_WKD_IN_PERD_FCTR_ID' ;
4504 g_pk_tbl(g_count).old_value := r_HWF_unique.information1 ;
4505 g_pk_tbl(g_count).new_value := r_HWF_unique.information1 ;
4506 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
4507 g_pk_tbl(g_count).table_route_id := r_HWF_unique.table_route_id;
4508 g_count := g_count + 1 ;
4509 else
4510 if l_dml_operation = 'UPDATE' then
4511 --
4512 l_object_found_in_target := TRUE;
4513 -- commented for bug 4112422
4514 -- if l_process_date between r_HWF_unique.information2 and r_HWF_unique.information3 then
4515 l_update := true;
4516 if r_HWF_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
4517 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'HRS_WKD_IN_PERD_FCTR_ID' then
4518 g_pk_tbl(g_count).pk_id_column := 'HRS_WKD_IN_PERD_FCTR_ID' ;
4519 g_pk_tbl(g_count).old_value := r_HWF_unique.information1 ;
4520 g_pk_tbl(g_count).new_value := r_HWF_unique.information1 ;
4521 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
4522 g_pk_tbl(g_count).table_route_id := r_HWF_unique.table_route_id;
4523 --
4524 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
4525 --
4526 g_count := g_count + 1 ;
4527 --
4528 log_data('HWF',l_new_value,l_prefix || r_HWF_unique.name|| l_suffix,'REUSED');
4529 --
4530 end if ;
4531 l_HRS_WKD_IN_PERD_FCTR_ID := r_HWF_unique.information1 ;
4532 l_object_version_number := r_HWF.information265 ;
4533 hr_utility.set_location( 'found record for update',10);
4534 --
4535 -- else
4536 --
4537 -- l_update := false;
4538 --
4539 -- end if;
4540 else
4541 --
4542 if p_reuse_object_flag = 'Y' then
4543 -- cursor to find the object
4544 open c_find_HWF_in_target( l_prefix || r_HWF_unique.name || l_suffix ,r_HWF_unique.information2,l_max_eed,
4545 p_target_business_group_id, nvl(l_hrs_wkd_in_perd_fctr_id, -999) ) ;
4546 hr_utility.set_location('name = ' || l_prefix || r_HWF_unique.name || l_suffix, 999);
4547 hr_utility.set_location('tr bg = ' || p_target_business_group_id, 999);
4548 hr_utility.set_location('tr id = ' || l_hrs_wkd_in_perd_fctr_id, 999);
4549 fetch c_find_HWF_in_target into l_new_value ;
4550 if c_find_HWF_in_target%found then
4551 --
4552 if r_HWF_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
4553 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'HRS_WKD_IN_PERD_FCTR_ID' then
4554 g_pk_tbl(g_count).pk_id_column := 'HRS_WKD_IN_PERD_FCTR_ID' ;
4555 g_pk_tbl(g_count).old_value := r_HWF_unique.information1 ;
4556 g_pk_tbl(g_count).new_value := l_new_value ;
4557 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
4558 g_pk_tbl(g_count).table_route_id := r_HWF_unique.table_route_id;
4559 --
4560 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
4561 --
4562 g_count := g_count + 1 ;
4563 --
4564 log_data('HWF',l_new_value,l_prefix || r_HWF_unique.name|| l_suffix,'REUSED');
4565 --
4566 end if ;
4567 --
4568 l_object_found_in_target := true ;
4569 end if;
4570 close c_find_HWF_in_target ;
4571 --
4572 end if ;
4573 --
4574 end if;
4575 --
4576 if not l_object_found_in_target or l_update then
4577 --
4578 l_current_pk_id := r_HWF.information1;
4579 --
4580 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
4581 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
4582 --
4583 if l_current_pk_id = l_prev_pk_id then
4584 --
4585 l_first_rec := false ;
4586 --
4587 hr_utility.set_location(' false',20);
4588 else
4589 --
4590 l_first_rec := true ;
4591 hr_utility.set_location(' true',20);
4592 --
4593 end if ;
4594 --
4595 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
4596 l_DEFINED_BALANCE_ID := r_HWF.information176; -- Mapping
4597 else
4598 l_DEFINED_BALANCE_ID := r_HWF.information174;
4599 end if;
4600 --
4601 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_HRS_WKD_IN_PERD_FCTR' ,l_prefix || r_HWF.INFORMATION170 || l_suffix);
4602 --
4603
4604 l_parent_effective_start_date := r_HWF.information10;
4605 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null ) then
4606 if l_parent_effective_start_date is null then
4607 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
4608 elsif l_parent_effective_start_date < ben_pd_copy_to_ben_one.g_copy_effective_date then
4609 l_parent_effective_start_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
4610 end if;
4611 end if;
4612 --
4613 -- To avoid creating a child with out parent
4614 --
4615 if r_HWF.information13 = 'BNFTBALTYP' and l_BNFTS_BAL_ID is null then
4616 l_first_rec:=false;
4617 end if;
4618 --
4619 if l_first_rec and not l_update then
4620 -- Call Create routine.
4621 hr_utility.set_location(' BEN_HRS_WKD_IN_PERD_FCTR CREATE_HRS_WKD_IN_PERD_FCTR ',20);
4622 BEN_HRS_WKD_IN_PERD_FCTR_API.CREATE_HRS_WKD_IN_PERD_FCTR(
4623 --
4624 P_VALIDATE => false
4625 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
4626 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
4627 --
4628 ,P_BNFTS_BAL_ID => l_BNFTS_BAL_ID
4629 ,P_DEFINED_BALANCE_ID => l_DEFINED_BALANCE_ID
4630 ,P_HRS_ALT_VAL_TO_USE_CD => r_HWF.INFORMATION18
4631 ,P_HRS_SRC_CD => r_HWF.INFORMATION13
4632 ,P_HRS_WKD_CALC_RL => l_HRS_WKD_CALC_RL
4633 ,P_HRS_WKD_DET_CD => r_HWF.INFORMATION15
4634 ,P_HRS_WKD_DET_RL => l_HRS_WKD_DET_RL
4635 ,P_HRS_WKD_IN_PERD_FCTR_ID => l_hrs_wkd_in_perd_fctr_id
4636 ,P_HWF_ATTRIBUTE1 => r_HWF.INFORMATION111
4637 ,P_HWF_ATTRIBUTE10 => r_HWF.INFORMATION120
4638 ,P_HWF_ATTRIBUTE11 => r_HWF.INFORMATION121
4639 ,P_HWF_ATTRIBUTE12 => r_HWF.INFORMATION122
4640 ,P_HWF_ATTRIBUTE13 => r_HWF.INFORMATION123
4641 ,P_HWF_ATTRIBUTE14 => r_HWF.INFORMATION124
4642 ,P_HWF_ATTRIBUTE15 => r_HWF.INFORMATION125
4643 ,P_HWF_ATTRIBUTE16 => r_HWF.INFORMATION126
4644 ,P_HWF_ATTRIBUTE17 => r_HWF.INFORMATION127
4645 ,P_HWF_ATTRIBUTE18 => r_HWF.INFORMATION128
4646 ,P_HWF_ATTRIBUTE19 => r_HWF.INFORMATION129
4647 ,P_HWF_ATTRIBUTE2 => r_HWF.INFORMATION112
4648 ,P_HWF_ATTRIBUTE20 => r_HWF.INFORMATION130
4649 ,P_HWF_ATTRIBUTE21 => r_HWF.INFORMATION131
4650 ,P_HWF_ATTRIBUTE22 => r_HWF.INFORMATION132
4651 ,P_HWF_ATTRIBUTE23 => r_HWF.INFORMATION133
4652 ,P_HWF_ATTRIBUTE24 => r_HWF.INFORMATION134
4653 ,P_HWF_ATTRIBUTE25 => r_HWF.INFORMATION135
4654 ,P_HWF_ATTRIBUTE26 => r_HWF.INFORMATION136
4655 ,P_HWF_ATTRIBUTE27 => r_HWF.INFORMATION137
4656 ,P_HWF_ATTRIBUTE28 => r_HWF.INFORMATION138
4657 ,P_HWF_ATTRIBUTE29 => r_HWF.INFORMATION139
4658 ,P_HWF_ATTRIBUTE3 => r_HWF.INFORMATION113
4659 ,P_HWF_ATTRIBUTE30 => r_HWF.INFORMATION140
4660 ,P_HWF_ATTRIBUTE4 => r_HWF.INFORMATION114
4661 ,P_HWF_ATTRIBUTE5 => r_HWF.INFORMATION115
4662 ,P_HWF_ATTRIBUTE6 => r_HWF.INFORMATION116
4663 ,P_HWF_ATTRIBUTE7 => r_HWF.INFORMATION117
4664 ,P_HWF_ATTRIBUTE8 => r_HWF.INFORMATION118
4665 ,P_HWF_ATTRIBUTE9 => r_HWF.INFORMATION119
4666 ,P_HWF_ATTRIBUTE_CATEGORY => r_HWF.INFORMATION110
4667 ,P_MN_HRS_NUM => r_HWF.INFORMATION293
4668 ,P_MX_HRS_NUM => r_HWF.INFORMATION294
4669 ,P_NAME => l_prefix || r_HWF.INFORMATION170 || l_suffix
4670 ,P_NO_MN_HRS_WKD_FLAG => r_HWF.INFORMATION11
4671 ,P_NO_MX_HRS_WKD_FLAG => r_HWF.INFORMATION19
4672 ,P_ONCE_R_CNTUG_CD => r_HWF.INFORMATION16
4673 ,P_PYRL_FREQ_CD => r_HWF.INFORMATION12
4674 ,P_RNDG_CD => r_HWF.INFORMATION14
4675 ,P_RNDG_RL => l_RNDG_RL
4676 --
4677 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
4678 );
4679 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
4680 -- Update all relevent cer records with new pk_id
4681 hr_utility.set_location('Before plsql table ',222);
4682 hr_utility.set_location('new_value id '||l_hrs_wkd_in_perd_fctr_id,222);
4683 g_pk_tbl(g_count).pk_id_column := 'HRS_WKD_IN_PERD_FCTR_ID' ;
4684 g_pk_tbl(g_count).old_value := r_HWF.information1 ;
4685 g_pk_tbl(g_count).new_value := l_HRS_WKD_IN_PERD_FCTR_ID ;
4686 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
4687 g_pk_tbl(g_count).table_route_id := r_HWF_unique.table_route_id;
4688 hr_utility.set_location('After plsql table ',222);
4689 --
4690 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
4691 --
4692 g_count := g_count + 1 ;
4693 --
4694 log_data('HWF',l_new_value,l_prefix || r_HWF.INFORMATION170 || l_suffix,'COPIED');
4695 --
4696 ELSIF l_update THEN
4697 --
4698 BEN_HRS_WKD_IN_PERD_FCTR_API.UPDATE_HRS_WKD_IN_PERD_FCTR(
4699 --
4700 P_VALIDATE => false
4701 ,P_EFFECTIVE_DATE => NVL(l_parent_effective_start_date,p_effective_date)
4702 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
4703 --
4704 ,P_BNFTS_BAL_ID => l_BNFTS_BAL_ID
4705 ,P_DEFINED_BALANCE_ID => l_DEFINED_BALANCE_ID
4706 ,P_HRS_ALT_VAL_TO_USE_CD => r_HWF.INFORMATION18
4707 ,P_HRS_SRC_CD => r_HWF.INFORMATION13
4708 ,P_HRS_WKD_CALC_RL => l_HRS_WKD_CALC_RL
4709 ,P_HRS_WKD_DET_CD => r_HWF.INFORMATION15
4710 ,P_HRS_WKD_DET_RL => l_HRS_WKD_DET_RL
4711 ,P_HRS_WKD_IN_PERD_FCTR_ID => l_hrs_wkd_in_perd_fctr_id
4712 ,P_HWF_ATTRIBUTE1 => r_HWF.INFORMATION111
4713 ,P_HWF_ATTRIBUTE10 => r_HWF.INFORMATION120
4714 ,P_HWF_ATTRIBUTE11 => r_HWF.INFORMATION121
4715 ,P_HWF_ATTRIBUTE12 => r_HWF.INFORMATION122
4716 ,P_HWF_ATTRIBUTE13 => r_HWF.INFORMATION123
4717 ,P_HWF_ATTRIBUTE14 => r_HWF.INFORMATION124
4718 ,P_HWF_ATTRIBUTE15 => r_HWF.INFORMATION125
4719 ,P_HWF_ATTRIBUTE16 => r_HWF.INFORMATION126
4720 ,P_HWF_ATTRIBUTE17 => r_HWF.INFORMATION127
4721 ,P_HWF_ATTRIBUTE18 => r_HWF.INFORMATION128
4722 ,P_HWF_ATTRIBUTE19 => r_HWF.INFORMATION129
4723 ,P_HWF_ATTRIBUTE2 => r_HWF.INFORMATION112
4724 ,P_HWF_ATTRIBUTE20 => r_HWF.INFORMATION130
4725 ,P_HWF_ATTRIBUTE21 => r_HWF.INFORMATION131
4726 ,P_HWF_ATTRIBUTE22 => r_HWF.INFORMATION132
4727 ,P_HWF_ATTRIBUTE23 => r_HWF.INFORMATION133
4728 ,P_HWF_ATTRIBUTE24 => r_HWF.INFORMATION134
4729 ,P_HWF_ATTRIBUTE25 => r_HWF.INFORMATION135
4730 ,P_HWF_ATTRIBUTE26 => r_HWF.INFORMATION136
4731 ,P_HWF_ATTRIBUTE27 => r_HWF.INFORMATION137
4732 ,P_HWF_ATTRIBUTE28 => r_HWF.INFORMATION138
4733 ,P_HWF_ATTRIBUTE29 => r_HWF.INFORMATION139
4734 ,P_HWF_ATTRIBUTE3 => r_HWF.INFORMATION113
4735 ,P_HWF_ATTRIBUTE30 => r_HWF.INFORMATION140
4736 ,P_HWF_ATTRIBUTE4 => r_HWF.INFORMATION114
4737 ,P_HWF_ATTRIBUTE5 => r_HWF.INFORMATION115
4738 ,P_HWF_ATTRIBUTE6 => r_HWF.INFORMATION116
4739 ,P_HWF_ATTRIBUTE7 => r_HWF.INFORMATION117
4740 ,P_HWF_ATTRIBUTE8 => r_HWF.INFORMATION118
4741 ,P_HWF_ATTRIBUTE9 => r_HWF.INFORMATION119
4742 ,P_HWF_ATTRIBUTE_CATEGORY => r_HWF.INFORMATION110
4743 ,P_MN_HRS_NUM => r_HWF.INFORMATION293
4744 ,P_MX_HRS_NUM => r_HWF.INFORMATION294
4745 ,P_NAME => l_prefix || r_HWF.INFORMATION170 || l_suffix
4746 ,P_NO_MN_HRS_WKD_FLAG => r_HWF.INFORMATION11
4747 ,P_NO_MX_HRS_WKD_FLAG => r_HWF.INFORMATION19
4748 ,P_ONCE_R_CNTUG_CD => r_HWF.INFORMATION16
4749 ,P_PYRL_FREQ_CD => r_HWF.INFORMATION12
4750 ,P_RNDG_CD => r_HWF.INFORMATION14
4751 ,P_RNDG_RL => l_RNDG_RL
4752 --
4753 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
4754 );
4755 end if;
4756 --
4757 l_prev_pk_id := l_current_pk_id ;
4758 --
4759 end if;
4760 --
4761 end if;
4762 --
4763 end loop;
4764 --
4765 exception when others then
4766 --
4767 raise_error_message( 'HWF',l_prefix || r_HWF.INFORMATION170 || l_suffix) ;
4768 --
4769 end create_HWF_rows;
4770
4771 --
4772 ---------------------------------------------------------------
4773 ----------------------< create_AGF_rows >-----------------------
4774 ---------------------------------------------------------------
4775 --
4776 procedure create_AGF_rows
4777 (
4778 p_validate in number default 0
4779 ,p_copy_entity_txn_id in number
4780 ,p_effective_date in date
4781 ,p_prefix_suffix_text in varchar2 default null
4782 ,p_reuse_object_flag in varchar2 default null
4783 ,p_target_business_group_id in varchar2 default null
4784 ,p_prefix_suffix_cd in varchar2 default null
4785 ) is
4786 --
4787 cursor c_unique_AGF(l_table_alias varchar2) is
4788 select distinct cpe.information1,
4789 cpe.information2,
4790 cpe.information3,
4791 cpe.INFORMATION170 name,
4792 cpe.table_route_id,dml_operation,cpe.datetrack_mode
4793 from ben_copy_entity_results cpe,
4794 pqh_table_route tr
4795 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4796 and cpe.table_route_id = tr.table_route_id
4797 -- and tr.where_clause = l_BEN_AGE_FCTR
4798 and tr.table_alias = l_table_alias
4799 and cpe.number_of_copies = 1 --ADDITION
4800 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
4801 order by information1, information2; --added for bug: 5151945
4802 --
4803 --
4804 cursor c_AGF_min_max_dates(c_table_route_id number,
4805 c_information1 number) is
4806 select
4807 min(cpe.information2) min_esd,
4808 max(cpe.information3) min_eed
4809 from ben_copy_entity_results cpe
4810 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4811 and cpe.table_route_id = c_table_route_id
4812 and cpe.information1 = c_information1 ;
4813 --
4814 cursor c_AGF(c_table_route_id number,
4815 c_information1 number,
4816 c_information2 date,
4817 c_information3 date ) is
4818 select
4819 cpe.*
4820 from ben_copy_entity_results cpe
4821 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
4822 and cpe.table_route_id = c_table_route_id
4823 and cpe.information1 = c_information1
4824 and rownum = 1 ;
4825 -- Date Track target record
4826 cursor c_find_AGF_in_target( c_AGF_name varchar2,
4827 c_effective_start_date date,
4828 c_effective_end_date date,
4829 c_business_group_id number,
4830 c_new_pk_id number) is
4831 select
4832 AGF.age_fctr_id new_value
4833 from BEN_AGE_FCTR AGF
4834 where AGF.name = c_AGF_name
4835 and AGF.business_group_id = c_business_group_id
4836 and AGF.age_fctr_id <> c_new_pk_id
4837 ;
4838 --
4839 l_current_pk_id number := null ;
4840 --UPD START
4841 --
4842 l_update boolean := false ;
4843 l_datetrack_mode varchar2(80) := hr_api.g_update;
4844 l_process_date date;
4845 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
4846 --
4847 --UPD END
4848 l_prev_pk_id number := null ;
4849 l_first_rec boolean := true ;
4850 r_AGF c_AGF%rowtype;
4851 l_age_fctr_id number ;
4852 l_object_version_number number ;
4853 l_effective_start_date date ;
4854 l_effective_end_date date ;
4855 l_prefix pqh_copy_entity_attribs.information1%type := null;
4856 l_suffix pqh_copy_entity_attribs.information1%type := null;
4857 l_new_value number(15);
4858 l_object_found_in_target boolean := false ;
4859 l_min_esd date;
4860 l_max_eed date;
4861 l_AGE_CALC_RL number;
4862 l_AGE_DET_RL number;
4863 l_RNDG_RL number;
4864 --
4865 begin
4866 -- Initialization
4867 l_object_found_in_target := false ;
4868 -- End Initialization
4869 -- Derive the prefix - sufix
4870 if p_prefix_suffix_cd = 'PREFIX' then
4871 l_prefix := p_prefix_suffix_text ;
4872 elsif p_prefix_suffix_cd = 'SUFFIX' then
4873 l_suffix := p_prefix_suffix_text ;
4874 else
4875 l_prefix := null ;
4876 l_suffix := null ;
4877 end if ;
4878 -- End Prefix Sufix derivation
4879 for r_AGF_unique in c_unique_AGF('AGF') loop
4880 --
4881 hr_utility.set_location(' r_AGF_unique.table_route_id '||r_AGF_unique.table_route_id,10);
4882 hr_utility.set_location(' r_AGF_unique.information1 '||r_AGF_unique.information1,10);
4883 hr_utility.set_location( 'r_AGF_unique.information2 '||r_AGF_unique.information2,10);
4884 hr_utility.set_location( 'r_AGF_unique.information3 '||r_AGF_unique.information3,10);
4885 -- If reuse objects flag is 'Y' then check for the object in the target business group
4886 -- if found insert the record into PLSql table and exit the loop else try create the
4887 -- object in the target business group
4888 --
4889 l_object_found_in_target := false ;
4890 l_min_esd := null ;
4891 l_max_eed := null ;
4892 --UPD START
4893 l_update := false;
4894 l_process_date := p_effective_date;
4895 l_dml_operation:= r_AGF_unique.dml_operation ;
4896 --
4897 if l_dml_operation = 'UPDATE' then
4898 --
4899 l_object_found_in_target := TRUE;
4900 -- 4193391 - commented the if else clause
4901 -- if l_process_date between r_AGF_unique.information2 and r_AGF_unique.information3 then
4902 l_update := true;
4903 if r_AGF_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
4904 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'AGE_FCTR_ID' then
4905 g_pk_tbl(g_count).pk_id_column := 'AGE_FCTR_ID' ;
4906 g_pk_tbl(g_count).old_value := r_AGF_unique.information1 ;
4907 g_pk_tbl(g_count).new_value := r_AGF_unique.information1 ;
4908 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
4909 g_pk_tbl(g_count).table_route_id := r_AGF_unique.table_route_id;
4910 --
4911 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
4912 --
4913 g_count := g_count + 1 ;
4914 --
4915 log_data('AGF',l_new_value,l_prefix || r_AGF_unique.name|| l_suffix,'REUSED');
4916 --
4917 end if ;
4918 l_age_fctr_id := r_AGF_unique.information1 ;
4919 l_object_version_number := r_AGF.information265 ;
4920 hr_utility.set_location( 'found record for update',10);
4921 --
4922 -- else
4923 --
4924 -- l_update := false;
4925 --
4926 -- end if;
4927 else
4928 --
4929 --UPD END
4930
4931 if p_reuse_object_flag = 'Y' then
4932 -- cursor to find the object
4933 open c_find_AGF_in_target( l_prefix || r_AGF_unique.name|| l_suffix ,r_AGF_unique.information2,l_max_eed,
4934 p_target_business_group_id, nvl(l_age_fctr_id, -999) ) ;
4935 fetch c_find_AGF_in_target into l_new_value ;
4936 if c_find_AGF_in_target%found then
4937 --
4938 if r_AGF_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
4939 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'AGE_FCTR_ID' then
4940 g_pk_tbl(g_count).pk_id_column := 'AGE_FCTR_ID' ;
4941 g_pk_tbl(g_count).old_value := r_AGF_unique.information1 ;
4942 g_pk_tbl(g_count).new_value := l_new_value ;
4943 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
4944 g_pk_tbl(g_count).table_route_id := r_AGF_unique.table_route_id;
4945 --
4946 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
4947 --
4948 g_count := g_count + 1 ;
4949 --
4950 log_data('AGF',l_new_value,l_prefix || r_AGF_unique.name|| l_suffix,'REUSED');
4951 --
4952 end if ;
4953 --
4954 l_object_found_in_target := true ;
4955 end if;
4956 close c_find_AGF_in_target ;
4957 --
4958 end if ;
4959 --
4960 end if;
4961 --
4962 if not l_object_found_in_target OR l_update then
4963 --
4964 open c_AGF(r_AGF_unique.table_route_id,
4965 r_AGF_unique.information1,
4966 r_AGF_unique.information2,
4967 r_AGF_unique.information3 ) ;
4968 --
4969 fetch c_AGF into r_AGF ;
4970 --
4971 close c_AGF ;
4972 --
4973 l_current_pk_id := r_AGF.information1;
4974 --
4975 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
4976 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
4977 --
4978 if l_current_pk_id = l_prev_pk_id then
4979 --
4980 l_first_rec := false ;
4981 --
4982 else
4983 --
4984 l_first_rec := true ;
4985 --
4986 end if ;
4987 --
4988 l_AGE_CALC_RL := get_fk('FORMULA_ID', r_AGF.INFORMATION262,l_dml_operation);
4989 l_AGE_DET_RL := get_fk('FORMULA_ID', r_AGF.INFORMATION261,l_dml_operation);
4990 l_RNDG_RL := get_fk('FORMULA_ID', r_AGF.INFORMATION257,l_dml_operation);
4991 --
4992 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_AGE_FCTR' ,l_prefix || r_AGF.INFORMATION170 || l_suffix);
4993 --
4994 if l_first_rec and not l_update then
4995 -- Call Create routine.
4996 hr_utility.set_location(' BEN_AGE_FCTR CREATE_AGE_FACTOR ',20);
4997 BEN_AGE_FACTOR_API.CREATE_AGE_FACTOR(
4998 --
4999 P_VALIDATE => false
5000 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
5001 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5002 --
5003 ,P_AGE_CALC_RL => l_AGE_CALC_RL
5004 ,P_AGE_DET_CD => r_AGF.INFORMATION16
5005 ,P_AGE_DET_RL => l_AGE_DET_RL
5006 ,P_AGE_FCTR_ID => l_age_fctr_id
5007 ,P_AGE_TO_USE_CD => r_AGF.INFORMATION14
5008 ,P_AGE_UOM => r_AGF.INFORMATION15
5009 ,P_AGF_ATTRIBUTE1 => r_AGF.INFORMATION111
5010 ,P_AGF_ATTRIBUTE10 => r_AGF.INFORMATION120
5011 ,P_AGF_ATTRIBUTE11 => r_AGF.INFORMATION121
5012 ,P_AGF_ATTRIBUTE12 => r_AGF.INFORMATION122
5013 ,P_AGF_ATTRIBUTE13 => r_AGF.INFORMATION123
5014 ,P_AGF_ATTRIBUTE14 => r_AGF.INFORMATION124
5015 ,P_AGF_ATTRIBUTE15 => r_AGF.INFORMATION125
5016 ,P_AGF_ATTRIBUTE16 => r_AGF.INFORMATION126
5017 ,P_AGF_ATTRIBUTE17 => r_AGF.INFORMATION127
5018 ,P_AGF_ATTRIBUTE18 => r_AGF.INFORMATION128
5019 ,P_AGF_ATTRIBUTE19 => r_AGF.INFORMATION129
5020 ,P_AGF_ATTRIBUTE2 => r_AGF.INFORMATION112
5021 ,P_AGF_ATTRIBUTE20 => r_AGF.INFORMATION130
5022 ,P_AGF_ATTRIBUTE21 => r_AGF.INFORMATION131
5023 ,P_AGF_ATTRIBUTE22 => r_AGF.INFORMATION132
5024 ,P_AGF_ATTRIBUTE23 => r_AGF.INFORMATION133
5025 ,P_AGF_ATTRIBUTE24 => r_AGF.INFORMATION134
5026 ,P_AGF_ATTRIBUTE25 => r_AGF.INFORMATION135
5027 ,P_AGF_ATTRIBUTE26 => r_AGF.INFORMATION136
5028 ,P_AGF_ATTRIBUTE27 => r_AGF.INFORMATION137
5029 ,P_AGF_ATTRIBUTE28 => r_AGF.INFORMATION138
5030 ,P_AGF_ATTRIBUTE29 => r_AGF.INFORMATION139
5031 ,P_AGF_ATTRIBUTE3 => r_AGF.INFORMATION113
5032 ,P_AGF_ATTRIBUTE30 => r_AGF.INFORMATION140
5033 ,P_AGF_ATTRIBUTE4 => r_AGF.INFORMATION114
5034 ,P_AGF_ATTRIBUTE5 => r_AGF.INFORMATION115
5035 ,P_AGF_ATTRIBUTE6 => r_AGF.INFORMATION116
5036 ,P_AGF_ATTRIBUTE7 => r_AGF.INFORMATION117
5037 ,P_AGF_ATTRIBUTE8 => r_AGF.INFORMATION118
5038 ,P_AGF_ATTRIBUTE9 => r_AGF.INFORMATION119
5039 ,P_AGF_ATTRIBUTE_CATEGORY => r_AGF.INFORMATION110
5040 ,P_MN_AGE_NUM => r_AGF.INFORMATION294
5041 ,P_MX_AGE_NUM => r_AGF.INFORMATION293
5042 ,P_NAME => l_prefix || r_AGF.INFORMATION170 || l_suffix
5043 ,P_NO_MN_AGE_FLAG => r_AGF.INFORMATION11
5044 ,P_NO_MX_AGE_FLAG => r_AGF.INFORMATION12
5045 ,P_RNDG_CD => r_AGF.INFORMATION13
5046 ,P_RNDG_RL => l_RNDG_RL
5047 --
5048 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5049 );
5050 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
5051 -- Update all relevent cer records with new pk_id
5052 hr_utility.set_location('Before plsql table ',222);
5053 hr_utility.set_location('new_value id '||l_age_fctr_id,222);
5054 g_pk_tbl(g_count).pk_id_column := 'AGE_FCTR_ID' ;
5055 g_pk_tbl(g_count).old_value := r_AGF.information1 ;
5056 g_pk_tbl(g_count).new_value := l_AGE_FCTR_ID ;
5057 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
5058 g_pk_tbl(g_count).table_route_id := r_AGF_unique.table_route_id;
5059 hr_utility.set_location('After plsql table ',222);
5060 --
5061 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
5062 --
5063 g_count := g_count + 1 ;
5064 --
5065 log_data('AGF',l_new_value,l_prefix || r_AGF.INFORMATION170 || l_suffix,'COPIED');
5066 --
5067 elsif l_update then
5068
5069 hr_utility.set_location(' BEN_AGE_FCTR UPDATE_AGE_FACTOR ',20);
5070 BEN_AGE_FACTOR_API.UPDATE_AGE_FACTOR(
5071 --
5072 P_VALIDATE => false
5073 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
5074 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5075 --
5076 ,P_AGE_CALC_RL => l_AGE_CALC_RL
5077 ,P_AGE_DET_CD => r_AGF.INFORMATION16
5078 ,P_AGE_DET_RL => l_AGE_DET_RL
5079 ,P_AGE_FCTR_ID => l_age_fctr_id
5080 ,P_AGE_TO_USE_CD => r_AGF.INFORMATION14
5081 ,P_AGE_UOM => r_AGF.INFORMATION15
5082 ,P_AGF_ATTRIBUTE1 => r_AGF.INFORMATION111
5083 ,P_AGF_ATTRIBUTE10 => r_AGF.INFORMATION120
5084 ,P_AGF_ATTRIBUTE11 => r_AGF.INFORMATION121
5085 ,P_AGF_ATTRIBUTE12 => r_AGF.INFORMATION122
5086 ,P_AGF_ATTRIBUTE13 => r_AGF.INFORMATION123
5087 ,P_AGF_ATTRIBUTE14 => r_AGF.INFORMATION124
5088 ,P_AGF_ATTRIBUTE15 => r_AGF.INFORMATION125
5089 ,P_AGF_ATTRIBUTE16 => r_AGF.INFORMATION126
5090 ,P_AGF_ATTRIBUTE17 => r_AGF.INFORMATION127
5091 ,P_AGF_ATTRIBUTE18 => r_AGF.INFORMATION128
5092 ,P_AGF_ATTRIBUTE19 => r_AGF.INFORMATION129
5093 ,P_AGF_ATTRIBUTE2 => r_AGF.INFORMATION112
5094 ,P_AGF_ATTRIBUTE20 => r_AGF.INFORMATION130
5095 ,P_AGF_ATTRIBUTE21 => r_AGF.INFORMATION131
5096 ,P_AGF_ATTRIBUTE22 => r_AGF.INFORMATION132
5097 ,P_AGF_ATTRIBUTE23 => r_AGF.INFORMATION133
5098 ,P_AGF_ATTRIBUTE24 => r_AGF.INFORMATION134
5099 ,P_AGF_ATTRIBUTE25 => r_AGF.INFORMATION135
5100 ,P_AGF_ATTRIBUTE26 => r_AGF.INFORMATION136
5101 ,P_AGF_ATTRIBUTE27 => r_AGF.INFORMATION137
5102 ,P_AGF_ATTRIBUTE28 => r_AGF.INFORMATION138
5103 ,P_AGF_ATTRIBUTE29 => r_AGF.INFORMATION139
5104 ,P_AGF_ATTRIBUTE3 => r_AGF.INFORMATION113
5105 ,P_AGF_ATTRIBUTE30 => r_AGF.INFORMATION140
5106 ,P_AGF_ATTRIBUTE4 => r_AGF.INFORMATION114
5107 ,P_AGF_ATTRIBUTE5 => r_AGF.INFORMATION115
5108 ,P_AGF_ATTRIBUTE6 => r_AGF.INFORMATION116
5109 ,P_AGF_ATTRIBUTE7 => r_AGF.INFORMATION117
5110 ,P_AGF_ATTRIBUTE8 => r_AGF.INFORMATION118
5111 ,P_AGF_ATTRIBUTE9 => r_AGF.INFORMATION119
5112 ,P_AGF_ATTRIBUTE_CATEGORY => r_AGF.INFORMATION110
5113 ,P_MN_AGE_NUM => r_AGF.INFORMATION294
5114 ,P_MX_AGE_NUM => r_AGF.INFORMATION293
5115 ,P_NAME => l_prefix || r_AGF.INFORMATION170 || l_suffix
5116 ,P_NO_MN_AGE_FLAG => r_AGF.INFORMATION11
5117 ,P_NO_MX_AGE_FLAG => r_AGF.INFORMATION12
5118 ,P_RNDG_CD => r_AGF.INFORMATION13
5119 ,P_RNDG_RL => l_RNDG_RL
5120 --
5121 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5122 );
5123 end if;
5124 --
5125 l_prev_pk_id := l_current_pk_id ;
5126 --
5127 end if;
5128 --
5129 end loop;
5130 --
5131 exception when others then
5132 --
5133 raise_error_message( 'AGF',l_prefix || r_AGF.INFORMATION170 || l_suffix) ;
5134 --
5135 end create_AGF_rows;
5136
5137 --
5138 ---------------------------------------------------------------
5139 ----------------------< create_LSF_rows >-----------------------
5140 ---------------------------------------------------------------
5141 --
5142 procedure create_LSF_rows
5143 (
5144 p_validate in number default 0
5145 ,p_copy_entity_txn_id in number
5146 ,p_effective_date in date
5147 ,p_prefix_suffix_text in varchar2 default null
5148 ,p_reuse_object_flag in varchar2 default null
5149 ,p_target_business_group_id in varchar2 default null
5150 ,p_prefix_suffix_cd in varchar2 default null
5151 ) is
5152 --
5153 cursor c_unique_LSF(l_table_alias varchar2) is
5154 select distinct cpe.information1,
5155 cpe.information2,
5156 cpe.information3,
5157 cpe.INFORMATION170 name,
5158 cpe.table_route_id,dml_operation,cpe.datetrack_mode
5159 from ben_copy_entity_results cpe,
5160 pqh_table_route tr
5161 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5162 and cpe.table_route_id = tr.table_route_id
5163 -- and tr.where_clause = l_BEN_LOS_FCTR
5164 and tr.table_alias = l_table_alias
5165 and cpe.number_of_copies = 1 --ADDITION
5166 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
5167 order by information1, information2; --added for bug: 5151945
5168 --
5169 --
5170 cursor c_LSF_min_max_dates(c_table_route_id number,
5171 c_information1 number) is
5172 select
5173 min(cpe.information2) min_esd,
5174 max(cpe.information3) min_eed
5175 from ben_copy_entity_results cpe
5176 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5177 and cpe.table_route_id = c_table_route_id
5178 and cpe.information1 = c_information1 ;
5179 --
5180 cursor c_LSF(c_table_route_id number,
5181 c_information1 number,
5182 c_information2 date,
5183 c_information3 date ) is
5184 select
5185 cpe.*
5186 from ben_copy_entity_results cpe
5187 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5188 and cpe.table_route_id = c_table_route_id
5189 and cpe.information1 = c_information1
5190 and rownum = 1 ;
5191 -- Date Track target record
5192 cursor c_find_LSF_in_target( c_LSF_name varchar2,
5193 c_effective_start_date date,
5194 c_effective_end_date date,
5195 c_business_group_id number,
5196 c_new_pk_id number) is
5197 select
5198 LSF.los_fctr_id new_value
5199 from BEN_LOS_FCTR LSF
5200 where LSF.name = c_LSF_name
5201 and LSF.business_group_id = c_business_group_id
5202 and LSF.los_fctr_id <> c_new_pk_id
5203 ;
5204 --
5205 l_current_pk_id number := null ;
5206 --UPD START
5207 --
5208 l_update boolean := false ;
5209 l_datetrack_mode varchar2(80) := hr_api.g_update;
5210 l_process_date date;
5211 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
5212 --
5213 --UPD END
5214 l_prev_pk_id number := null ;
5215 l_first_rec boolean := true ;
5216 r_LSF c_LSF%rowtype;
5217 l_los_fctr_id number ;
5218 l_object_version_number number ;
5219 l_effective_start_date date ;
5220 l_effective_end_date date ;
5221 l_prefix pqh_copy_entity_attribs.information1%type := null;
5222 l_suffix pqh_copy_entity_attribs.information1%type := null;
5223 l_new_value number(15);
5224 l_object_found_in_target boolean := false ;
5225 l_min_esd date;
5226 l_max_eed date;
5227 l_LOS_CALC_RL number;
5228 l_LOS_DET_RL number;
5229 l_LOS_DT_TO_USE_RL number;
5230 l_RNDG_RL number;
5231 --
5232 begin
5233 -- Initialization
5234 l_object_found_in_target := false ;
5235 -- End Initialization
5236 -- Derive the prefix - sufix
5237 if p_prefix_suffix_cd = 'PREFIX' then
5238 l_prefix := p_prefix_suffix_text ;
5239 elsif p_prefix_suffix_cd = 'SUFFIX' then
5240 l_suffix := p_prefix_suffix_text ;
5241 else
5242 l_prefix := null ;
5243 l_suffix := null ;
5244 end if ;
5245 -- End Prefix Sufix derivation
5246 for r_LSF_unique in c_unique_LSF('LSF') loop
5247 --
5248 hr_utility.set_location(' r_LSF_unique.table_route_id '||r_LSF_unique.table_route_id,10);
5249 hr_utility.set_location(' r_LSF_unique.information1 '||r_LSF_unique.information1,10);
5250 hr_utility.set_location( 'r_LSF_unique.information2 '||r_LSF_unique.information2,10);
5251 hr_utility.set_location( 'r_LSF_unique.information3 '||r_LSF_unique.information3,10);
5252 -- If reuse objects flag is 'Y' then check for the object in the target business group
5253 -- if found insert the record into PLSql table and exit the loop else try create the
5254 -- object in the target business group
5255 --
5256 l_object_found_in_target := false ;
5257 l_min_esd := null ;
5258 l_max_eed := null ;
5259 --UPD START
5260 l_dml_operation := r_LSF_unique.dml_operation;
5261 --
5262 l_update := false;
5263 --
5264 if l_dml_operation = 'UPDATE' then
5265 --
5266 l_update := true;
5267 if r_LSF_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
5268 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'LOS_FCTR_ID' then
5269 g_pk_tbl(g_count).pk_id_column := 'LOS_FCTR_ID' ;
5270 g_pk_tbl(g_count).old_value := r_LSF_unique.information1 ;
5271 g_pk_tbl(g_count).new_value := r_LSF_unique.information1 ;
5272 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
5273 g_pk_tbl(g_count).table_route_id := r_LSF_unique.table_route_id;
5274 --
5275 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ; -- NEW
5276 --
5277 g_count := g_count + 1 ;
5278 --
5279 log_data('LSF',l_new_value,l_prefix || r_LSF_unique.name|| l_suffix,'REUSED');
5280 --
5281 end if ;
5282 l_LOS_FCTR_ID := r_LSF_unique.information1 ;
5283 l_object_version_number := r_LSF.information265 ;
5284 hr_utility.set_location( 'found record for update',10);
5285 --
5286 else
5287 --
5288 if p_reuse_object_flag = 'Y' then
5289 -- cursor to find the object
5290 open c_find_LSF_in_target( l_prefix || r_LSF_unique.name|| l_suffix ,r_LSF_unique.information2,l_max_eed,
5291 p_target_business_group_id, nvl(l_los_fctr_id, -999) ) ;
5292 fetch c_find_LSF_in_target into l_new_value ;
5293 if c_find_LSF_in_target%found then
5294 --
5295 if r_LSF_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
5296 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'LOS_FCTR_ID' then
5297 g_pk_tbl(g_count).pk_id_column := 'LOS_FCTR_ID' ;
5298 g_pk_tbl(g_count).old_value := r_LSF_unique.information1 ;
5299 g_pk_tbl(g_count).new_value := l_new_value ;
5300 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
5301 g_pk_tbl(g_count).table_route_id := r_LSF_unique.table_route_id;
5302 --
5303 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
5304 --
5305 g_count := g_count + 1 ;
5306 --
5307 log_data('LSF',l_new_value,l_prefix || r_LSF_unique.name|| l_suffix,'REUSED');
5308 --
5309 end if ;
5310 --
5311 l_object_found_in_target := true ;
5312 end if;
5313 close c_find_LSF_in_target ;
5314 --
5315 end if ;
5316 --
5317 end if;
5318 if not l_object_found_in_target or l_update then
5319 --
5320 open c_LSF(r_LSF_unique.table_route_id,
5321 r_LSF_unique.information1,
5322 r_LSF_unique.information2,
5323 r_LSF_unique.information3 ) ;
5324 --
5325 fetch c_LSF into r_LSF ;
5326 --
5327 close c_LSF ;
5328 --
5329 l_current_pk_id := r_LSF.information1;
5330 --
5331 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
5332 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
5333 --
5334 if l_current_pk_id = l_prev_pk_id then
5335 --
5336 l_first_rec := false ;
5337 --
5338 else
5339 --
5340 l_first_rec := true ;
5341 --
5342 end if ;
5343 --
5344 l_LOS_CALC_RL := get_fk('FORMULA_ID', r_LSF.INFORMATION263,l_dml_operation);
5345 l_LOS_DET_RL := get_fk('FORMULA_ID', r_LSF.INFORMATION257,l_dml_operation);
5346 l_LOS_DT_TO_USE_RL := get_fk('FORMULA_ID', r_LSF.INFORMATION258,l_dml_operation);
5347 l_RNDG_RL := get_fk('FORMULA_ID', r_LSF.INFORMATION259,l_dml_operation);
5348 --
5349 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_LOS_FCTR',l_prefix || r_LSF.INFORMATION170 || l_suffix);
5350 --
5351 if l_first_rec and not l_update then
5352 -- Call Create routine.
5353 hr_utility.set_location(' BEN_LOS_FCTR CREATE_LOS_FACTORS ',20);
5354 BEN_LOS_FACTORS_API.CREATE_LOS_FACTORS(
5355 --
5356 P_VALIDATE => false
5357 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date,p_effective_date)
5358 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5359 --
5360 -- ,P_hrs_ALT_VAL_TO_USE_CD => r_LSF.information11
5361 -- ,P_LOS_ALT_VAL_TO_USE_CD => r_LSF.INFORMATION19
5362 ,P_LOS_CALC_RL => l_LOS_CALC_RL
5363 ,P_LOS_DET_CD => r_LSF.INFORMATION15
5364 ,P_LOS_DET_RL => l_LOS_DET_RL
5365 ,P_LOS_DT_TO_USE_CD => r_LSF.INFORMATION14
5366 ,P_LOS_DT_TO_USE_RL => l_LOS_DT_TO_USE_RL
5367 ,P_LOS_FCTR_ID => l_los_fctr_id
5368 ,P_LOS_UOM => r_LSF.INFORMATION17
5369 ,P_LSF_ATTRIBUTE1 => r_LSF.INFORMATION111
5370 ,P_LSF_ATTRIBUTE10 => r_LSF.INFORMATION120
5371 ,P_LSF_ATTRIBUTE11 => r_LSF.INFORMATION121
5372 ,P_LSF_ATTRIBUTE12 => r_LSF.INFORMATION122
5373 ,P_LSF_ATTRIBUTE13 => r_LSF.INFORMATION123
5374 ,P_LSF_ATTRIBUTE14 => r_LSF.INFORMATION124
5375 ,P_LSF_ATTRIBUTE15 => r_LSF.INFORMATION125
5376 ,P_LSF_ATTRIBUTE16 => r_LSF.INFORMATION126
5377 ,P_LSF_ATTRIBUTE17 => r_LSF.INFORMATION127
5378 ,P_LSF_ATTRIBUTE18 => r_LSF.INFORMATION128
5379 ,P_LSF_ATTRIBUTE19 => r_LSF.INFORMATION129
5380 ,P_LSF_ATTRIBUTE2 => r_LSF.INFORMATION112
5381 ,P_LSF_ATTRIBUTE20 => r_LSF.INFORMATION130
5382 ,P_LSF_ATTRIBUTE21 => r_LSF.INFORMATION131
5383 ,P_LSF_ATTRIBUTE22 => r_LSF.INFORMATION132
5384 ,P_LSF_ATTRIBUTE23 => r_LSF.INFORMATION133
5385 ,P_LSF_ATTRIBUTE24 => r_LSF.INFORMATION134
5386 ,P_LSF_ATTRIBUTE25 => r_LSF.INFORMATION135
5387 ,P_LSF_ATTRIBUTE26 => r_LSF.INFORMATION136
5388 ,P_LSF_ATTRIBUTE27 => r_LSF.INFORMATION137
5389 ,P_LSF_ATTRIBUTE28 => r_LSF.INFORMATION138
5390 ,P_LSF_ATTRIBUTE29 => r_LSF.INFORMATION139
5391 ,P_LSF_ATTRIBUTE3 => r_LSF.INFORMATION113
5392 ,P_LSF_ATTRIBUTE30 => r_LSF.INFORMATION140
5393 ,P_LSF_ATTRIBUTE4 => r_LSF.INFORMATION114
5394 ,P_LSF_ATTRIBUTE5 => r_LSF.INFORMATION115
5395 ,P_LSF_ATTRIBUTE6 => r_LSF.INFORMATION116
5396 ,P_LSF_ATTRIBUTE7 => r_LSF.INFORMATION117
5397 ,P_LSF_ATTRIBUTE8 => r_LSF.INFORMATION118
5398 ,P_LSF_ATTRIBUTE9 => r_LSF.INFORMATION119
5399 ,P_LSF_ATTRIBUTE_CATEGORY => r_LSF.INFORMATION110
5400 ,P_MN_LOS_NUM => r_LSF.INFORMATION293
5401 ,P_MX_LOS_NUM => r_LSF.INFORMATION294
5402 ,P_NAME => l_prefix || r_LSF.INFORMATION170 || l_suffix
5403 ,P_NO_MN_LOS_NUM_APLS_FLAG => r_LSF.INFORMATION13
5404 ,P_NO_MX_LOS_NUM_APLS_FLAG => r_LSF.INFORMATION12
5405 ,P_RNDG_CD => r_LSF.INFORMATION16
5406 ,P_RNDG_RL => l_RNDG_RL
5407 ,P_USE_OVERID_SVC_DT_FLAG => r_LSF.INFORMATION11
5408 --
5409 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5410 );
5411 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
5412 -- Update all relevent cer records with new pk_id
5413 hr_utility.set_location('Before plsql table ',222);
5414 hr_utility.set_location('new_value id '||l_los_fctr_id,222);
5415 g_pk_tbl(g_count).pk_id_column := 'LOS_FCTR_ID' ;
5416 g_pk_tbl(g_count).old_value := r_LSF.information1 ;
5417 g_pk_tbl(g_count).new_value := l_LOS_FCTR_ID ;
5418 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
5419 g_pk_tbl(g_count).table_route_id := r_LSF_unique.table_route_id;
5420 hr_utility.set_location('After plsql table ',222);
5421 --
5422 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
5423 --
5424 g_count := g_count + 1 ;
5425 --
5426 log_data('LSF',l_new_value,l_prefix || r_LSF.INFORMATION170 || l_suffix,'COPIED');
5427 --
5428 elsif l_update then
5429 --
5430 BEN_LOS_FACTORS_API.UPDATE_LOS_FACTORS(
5431 --
5432 P_VALIDATE => false
5433 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date,p_effective_date)
5434 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5435 --
5436 -- ,P_hrs_ALT_VAL_TO_USE_CD => r_LSF.information11
5437 -- ,P_LOS_ALT_VAL_TO_USE_CD => r_LSF.INFORMATION19
5438 ,P_LOS_CALC_RL => l_LOS_CALC_RL
5439 ,P_LOS_DET_CD => r_LSF.INFORMATION15
5440 ,P_LOS_DET_RL => l_LOS_DET_RL
5441 ,P_LOS_DT_TO_USE_CD => r_LSF.INFORMATION14
5442 ,P_LOS_DT_TO_USE_RL => l_LOS_DT_TO_USE_RL
5443 ,P_LOS_FCTR_ID => l_los_fctr_id
5444 ,P_LOS_UOM => r_LSF.INFORMATION17
5445 ,P_LSF_ATTRIBUTE1 => r_LSF.INFORMATION111
5446 ,P_LSF_ATTRIBUTE10 => r_LSF.INFORMATION120
5447 ,P_LSF_ATTRIBUTE11 => r_LSF.INFORMATION121
5448 ,P_LSF_ATTRIBUTE12 => r_LSF.INFORMATION122
5449 ,P_LSF_ATTRIBUTE13 => r_LSF.INFORMATION123
5450 ,P_LSF_ATTRIBUTE14 => r_LSF.INFORMATION124
5451 ,P_LSF_ATTRIBUTE15 => r_LSF.INFORMATION125
5452 ,P_LSF_ATTRIBUTE16 => r_LSF.INFORMATION126
5453 ,P_LSF_ATTRIBUTE17 => r_LSF.INFORMATION127
5454 ,P_LSF_ATTRIBUTE18 => r_LSF.INFORMATION128
5455 ,P_LSF_ATTRIBUTE19 => r_LSF.INFORMATION129
5456 ,P_LSF_ATTRIBUTE2 => r_LSF.INFORMATION112
5457 ,P_LSF_ATTRIBUTE20 => r_LSF.INFORMATION130
5458 ,P_LSF_ATTRIBUTE21 => r_LSF.INFORMATION131
5459 ,P_LSF_ATTRIBUTE22 => r_LSF.INFORMATION132
5460 ,P_LSF_ATTRIBUTE23 => r_LSF.INFORMATION133
5461 ,P_LSF_ATTRIBUTE24 => r_LSF.INFORMATION134
5462 ,P_LSF_ATTRIBUTE25 => r_LSF.INFORMATION135
5463 ,P_LSF_ATTRIBUTE26 => r_LSF.INFORMATION136
5464 ,P_LSF_ATTRIBUTE27 => r_LSF.INFORMATION137
5465 ,P_LSF_ATTRIBUTE28 => r_LSF.INFORMATION138
5466 ,P_LSF_ATTRIBUTE29 => r_LSF.INFORMATION139
5467 ,P_LSF_ATTRIBUTE3 => r_LSF.INFORMATION113
5468 ,P_LSF_ATTRIBUTE30 => r_LSF.INFORMATION140
5469 ,P_LSF_ATTRIBUTE4 => r_LSF.INFORMATION114
5470 ,P_LSF_ATTRIBUTE5 => r_LSF.INFORMATION115
5471 ,P_LSF_ATTRIBUTE6 => r_LSF.INFORMATION116
5472 ,P_LSF_ATTRIBUTE7 => r_LSF.INFORMATION117
5473 ,P_LSF_ATTRIBUTE8 => r_LSF.INFORMATION118
5474 ,P_LSF_ATTRIBUTE9 => r_LSF.INFORMATION119
5475 ,P_LSF_ATTRIBUTE_CATEGORY => r_LSF.INFORMATION110
5476 ,P_MN_LOS_NUM => r_LSF.INFORMATION293
5477 ,P_MX_LOS_NUM => r_LSF.INFORMATION294
5478 ,P_NAME => l_prefix || r_LSF.INFORMATION170 || l_suffix
5479 ,P_NO_MN_LOS_NUM_APLS_FLAG => r_LSF.INFORMATION13
5480 ,P_NO_MX_LOS_NUM_APLS_FLAG => r_LSF.INFORMATION12
5481 ,P_RNDG_CD => r_LSF.INFORMATION16
5482 ,P_RNDG_RL => l_RNDG_RL
5483 ,P_USE_OVERID_SVC_DT_FLAG => r_LSF.INFORMATION11
5484 --
5485 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5486 );
5487 end if;
5488 --
5489 l_prev_pk_id := l_current_pk_id ;
5490 --
5491 end if;
5492 --
5493 end loop;
5494 --
5495 exception when others then
5496 --
5497 raise_error_message( 'LSF',l_prefix || r_LSF.INFORMATION170 || l_suffix) ;
5498 --
5499 end create_LSF_rows;
5500
5501 --
5502 ---------------------------------------------------------------
5503 ----------------------< create_PFF_rows >-----------------------
5504 ---------------------------------------------------------------
5505 --
5506 procedure create_PFF_rows
5507 (
5508 p_validate in number default 0
5509 ,p_copy_entity_txn_id in number
5510 ,p_effective_date in date
5511 ,p_prefix_suffix_text in varchar2 default null
5512 ,p_reuse_object_flag in varchar2 default null
5513 ,p_target_business_group_id in varchar2 default null
5514 ,p_prefix_suffix_cd in varchar2 default null
5515 ) is
5516 --
5517 cursor c_unique_PFF(l_table_alias varchar2) is
5518 select distinct cpe.information1,
5519 cpe.information2,
5520 cpe.information3,
5521 cpe.INFORMATION218 name,
5522 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
5523 from ben_copy_entity_results cpe,
5524 pqh_table_route tr
5525 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5526 and cpe.table_route_id = tr.table_route_id
5527 -- and tr.where_clause = l_BEN_PCT_FL_TM_FCTR
5528 and tr.table_alias = l_table_alias
5529 and cpe.number_of_copies = 1 --ADDITION
5530 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION218, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
5531 order by information1, information2; --added for bug: 5151945
5532 --
5533 --
5534 cursor c_PFF_min_max_dates(c_table_route_id number,
5535 c_information1 number) is
5536 select
5537 min(cpe.information2) min_esd,
5538 max(cpe.information3) min_eed
5539 from ben_copy_entity_results cpe
5540 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5541 and cpe.table_route_id = c_table_route_id
5542 and cpe.information1 = c_information1 ;
5543 --
5544 cursor c_PFF(c_table_route_id number,
5545 c_information1 number,
5546 c_information2 date,
5547 c_information3 date ) is
5548 select
5549 cpe.*
5550 from ben_copy_entity_results cpe
5551 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5552 and cpe.table_route_id = c_table_route_id
5553 and cpe.information1 = c_information1
5554 and rownum = 1 ;
5555 -- Date Track target record
5556 cursor c_find_PFF_in_target( c_PFF_name varchar2,
5557 c_effective_start_date date,
5558 c_effective_end_date date,
5559 c_business_group_id number,
5560 c_new_pk_id number) is
5561 select
5562 PFF.pct_fl_tm_fctr_id new_value
5563 from BEN_PCT_FL_TM_FCTR PFF
5564 where PFF.name = c_PFF_name
5565 and PFF.business_group_id = c_business_group_id
5566 and PFF.pct_fl_tm_fctr_id <> c_new_pk_id
5567 ;
5568 --
5569 l_current_pk_id number := null ;
5570 --UPD START
5571 --
5572 l_update boolean := false ;
5573 l_datetrack_mode varchar2(80) := hr_api.g_update;
5574 l_process_date date;
5575 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
5576 --
5577 --UPD END
5578 l_prev_pk_id number := null ;
5579 l_first_rec boolean := true ;
5580 r_PFF c_PFF%rowtype;
5581 l_pct_fl_tm_fctr_id number ;
5582 l_object_version_number number ;
5583 l_effective_start_date date ;
5584 l_effective_end_date date ;
5585 l_prefix pqh_copy_entity_attribs.information1%type := null;
5586 l_suffix pqh_copy_entity_attribs.information1%type := null;
5587 l_new_value number(15);
5588 l_object_found_in_target boolean := false ;
5589 l_min_esd date;
5590 l_max_eed date;
5591 l_RNDG_RL number;
5592 --
5593 begin
5594 -- Initialization
5595 l_object_found_in_target := false ;
5596 -- End Initialization
5597 -- Derive the prefix - sufix
5598 if p_prefix_suffix_cd = 'PREFIX' then
5599 l_prefix := p_prefix_suffix_text ;
5600 elsif p_prefix_suffix_cd = 'SUFFIX' then
5601 l_suffix := p_prefix_suffix_text ;
5602 else
5603 l_prefix := null ;
5604 l_suffix := null ;
5605 end if ;
5606 -- End Prefix Sufix derivation
5607 for r_PFF_unique in c_unique_PFF('PFF') loop
5608 --
5609 hr_utility.set_location(' r_PFF_unique.table_route_id '||r_PFF_unique.table_route_id,10);
5610 hr_utility.set_location(' r_PFF_unique.information1 '||r_PFF_unique.information1,10);
5611 hr_utility.set_location( 'r_PFF_unique.information2 '||r_PFF_unique.information2,10);
5612 hr_utility.set_location( 'r_PFF_unique.information3 '||r_PFF_unique.information3,10);
5613 -- If reuse objects flag is 'Y' then check for the object in the target business group
5614 -- if found insert the record into PLSql table and exit the loop else try create the
5615 -- object in the target business group
5616 --
5617 l_object_found_in_target := false ;
5618 l_min_esd := null ;
5619 l_max_eed := null ;
5620 --UPD START
5621 l_dml_operation := r_PFF_unique.dml_operation;
5622 l_update := false;
5623 --
5624 if l_dml_operation = 'UPDATE' then
5625 --
5626 l_update := true;
5627 if r_PFF_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
5628 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PCT_FL_TM_FCTR_ID' then
5629 g_pk_tbl(g_count).pk_id_column := 'PCT_FL_TM_FCTR_ID' ;
5630 g_pk_tbl(g_count).old_value := r_PFF_unique.information1 ;
5631 g_pk_tbl(g_count).new_value := r_PFF_unique.information1 ;
5632 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
5633 g_pk_tbl(g_count).table_route_id := r_PFF_unique.table_route_id;
5634 --
5635 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ; -- NEW
5636 --
5637 g_count := g_count + 1 ;
5638 --
5639 log_data('PFF',l_new_value,l_prefix || r_PFF_unique.name|| l_suffix,'REUSED');
5640 --
5641 end if ;
5642 l_pct_fl_tm_fctr_id := r_PFF_unique.information1 ;
5643 l_object_version_number := r_PFF.information265 ;
5644 hr_utility.set_location( 'found record for update',10);
5645 --
5646 else
5647 --UPD END
5648 if p_reuse_object_flag = 'Y' then
5649 -- cursor to find the object
5650 open c_find_PFF_in_target( l_prefix || r_PFF_unique.name|| l_suffix ,r_PFF_unique.information2,l_max_eed,
5651 p_target_business_group_id, nvl(l_pct_fl_tm_fctr_id, -999) ) ;
5652 fetch c_find_PFF_in_target into l_new_value ;
5653 if c_find_PFF_in_target%found then
5654 --
5655 if r_PFF_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
5656 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PCT_FL_TM_FCTR_ID' then
5657 g_pk_tbl(g_count).pk_id_column := 'PCT_FL_TM_FCTR_ID' ;
5658 g_pk_tbl(g_count).old_value := r_PFF_unique.information1 ;
5659 g_pk_tbl(g_count).new_value := l_new_value ;
5660 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
5661 g_pk_tbl(g_count).table_route_id := r_PFF_unique.table_route_id;
5662 --
5663 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
5664 --
5665 g_count := g_count + 1 ;
5666 --
5667 log_data('PFF',l_new_value,l_prefix || r_PFF_unique.name|| l_suffix,'REUSED');
5668 --
5669 end if ;
5670 --
5671 l_object_found_in_target := true ;
5672 end if;
5673 close c_find_PFF_in_target ;
5674 --
5675 end if ;
5676 --
5677 end if; --l_update
5678 if not l_object_found_in_target or l_update then
5679 --
5680 open c_PFF(r_PFF_unique.table_route_id,
5681 r_PFF_unique.information1,
5682 r_PFF_unique.information2,
5683 r_PFF_unique.information3 ) ;
5684 --
5685 fetch c_PFF into r_PFF ;
5686 --
5687 close c_PFF ;
5688 --
5689 l_current_pk_id := r_PFF.information1;
5690 --
5691 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
5692 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
5693 --
5694 if l_current_pk_id = l_prev_pk_id then
5695 --
5696 l_first_rec := false ;
5697 --
5698 else
5699 --
5700 l_first_rec := true ;
5701 --
5702 end if ;
5703 --
5704 l_RNDG_RL := get_fk('FORMULA_ID', r_PFF.INFORMATION257,l_dml_operation);
5705 --
5706 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_PCT_FL_TM_FCTR',l_prefix || r_PFF.INFORMATION218 || l_suffix);
5707 --
5708 if l_first_rec and not l_update then
5709 -- Call Create routine.
5710 hr_utility.set_location(' BEN_PCT_FL_TM_FCTR CREATE_PERCENT_FT_FACTORS ',20);
5711 BEN_PERCENT_FT_FACTORS_API.CREATE_PERCENT_FT_FACTORS(
5712 --
5713 P_VALIDATE => false
5714 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
5715 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5716 --
5717 ,P_MN_PCT_VAL => r_PFF.INFORMATION294
5718 ,P_MX_PCT_VAL => r_PFF.INFORMATION293
5719 ,P_NAME => l_prefix || r_PFF.INFORMATION218 || l_suffix
5720 ,P_NO_MN_PCT_VAL_FLAG => r_PFF.INFORMATION11
5721 ,P_NO_MX_PCT_VAL_FLAG => r_PFF.INFORMATION12
5722 ,P_PCT_FL_TM_FCTR_ID => l_pct_fl_tm_fctr_id
5723 ,P_PFF_ATTRIBUTE1 => r_PFF.INFORMATION111
5724 ,P_PFF_ATTRIBUTE10 => r_PFF.INFORMATION120
5725 ,P_PFF_ATTRIBUTE11 => r_PFF.INFORMATION121
5726 ,P_PFF_ATTRIBUTE12 => r_PFF.INFORMATION122
5727 ,P_PFF_ATTRIBUTE13 => r_PFF.INFORMATION123
5728 ,P_PFF_ATTRIBUTE14 => r_PFF.INFORMATION124
5729 ,P_PFF_ATTRIBUTE15 => r_PFF.INFORMATION125
5730 ,P_PFF_ATTRIBUTE16 => r_PFF.INFORMATION126
5731 ,P_PFF_ATTRIBUTE17 => r_PFF.INFORMATION127
5732 ,P_PFF_ATTRIBUTE18 => r_PFF.INFORMATION128
5733 ,P_PFF_ATTRIBUTE19 => r_PFF.INFORMATION129
5734 ,P_PFF_ATTRIBUTE2 => r_PFF.INFORMATION112
5735 ,P_PFF_ATTRIBUTE20 => r_PFF.INFORMATION130
5736 ,P_PFF_ATTRIBUTE21 => r_PFF.INFORMATION131
5737 ,P_PFF_ATTRIBUTE22 => r_PFF.INFORMATION132
5738 ,P_PFF_ATTRIBUTE23 => r_PFF.INFORMATION133
5739 ,P_PFF_ATTRIBUTE24 => r_PFF.INFORMATION134
5740 ,P_PFF_ATTRIBUTE25 => r_PFF.INFORMATION135
5741 ,P_PFF_ATTRIBUTE26 => r_PFF.INFORMATION136
5742 ,P_PFF_ATTRIBUTE27 => r_PFF.INFORMATION137
5743 ,P_PFF_ATTRIBUTE28 => r_PFF.INFORMATION138
5744 ,P_PFF_ATTRIBUTE29 => r_PFF.INFORMATION139
5745 ,P_PFF_ATTRIBUTE3 => r_PFF.INFORMATION113
5746 ,P_PFF_ATTRIBUTE30 => r_PFF.INFORMATION140
5747 ,P_PFF_ATTRIBUTE4 => r_PFF.INFORMATION114
5748 ,P_PFF_ATTRIBUTE5 => r_PFF.INFORMATION115
5749 ,P_PFF_ATTRIBUTE6 => r_PFF.INFORMATION116
5750 ,P_PFF_ATTRIBUTE7 => r_PFF.INFORMATION117
5751 ,P_PFF_ATTRIBUTE8 => r_PFF.INFORMATION118
5752 ,P_PFF_ATTRIBUTE9 => r_PFF.INFORMATION119
5753 ,P_PFF_ATTRIBUTE_CATEGORY => r_PFF.INFORMATION110
5754 ,P_RNDG_CD => r_PFF.INFORMATION15
5755 ,P_RNDG_RL => l_RNDG_RL
5756 ,P_USE_PRMRY_ASNT_ONLY_FLAG => r_PFF.INFORMATION13
5757 ,P_USE_SUM_OF_ALL_ASNTS_FLAG => r_PFF.INFORMATION14
5758 --
5759 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5760 );
5761 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
5762 -- Update all relevent cer records with new pk_id
5763 hr_utility.set_location('Before plsql table ',222);
5764 hr_utility.set_location('new_value id '||l_pct_fl_tm_fctr_id,222);
5765 g_pk_tbl(g_count).pk_id_column := 'PCT_FL_TM_FCTR_ID' ;
5766 g_pk_tbl(g_count).old_value := r_PFF.information1 ;
5767 g_pk_tbl(g_count).new_value := l_PCT_FL_TM_FCTR_ID ;
5768 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
5769 g_pk_tbl(g_count).table_route_id := r_PFF_unique.table_route_id;
5770 hr_utility.set_location('After plsql table ',222);
5771 --
5772 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
5773 --
5774 g_count := g_count + 1 ;
5775 --
5776 log_data('PFF',l_new_value,l_prefix || r_PFF.INFORMATION218 || l_suffix,'COPIED');
5777 --
5778 elsif l_update then
5779 --
5780 hr_utility.set_location(' BEN_PCT_FL_TM_FCTR UPDATE_PERCENT_FT_FACTORS ',20);
5781 BEN_PERCENT_FT_FACTORS_API.UPDATE_PERCENT_FT_FACTORS(
5782 --
5783 P_VALIDATE => false
5784 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
5785 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
5786 --
5787 ,P_MN_PCT_VAL => r_PFF.INFORMATION294
5788 ,P_MX_PCT_VAL => r_PFF.INFORMATION293
5789 ,P_NAME => l_prefix || r_PFF.INFORMATION218 || l_suffix
5790 ,P_NO_MN_PCT_VAL_FLAG => r_PFF.INFORMATION11
5791 ,P_NO_MX_PCT_VAL_FLAG => r_PFF.INFORMATION12
5792 ,P_PCT_FL_TM_FCTR_ID => l_pct_fl_tm_fctr_id
5793 ,P_PFF_ATTRIBUTE1 => r_PFF.INFORMATION111
5794 ,P_PFF_ATTRIBUTE10 => r_PFF.INFORMATION120
5795 ,P_PFF_ATTRIBUTE11 => r_PFF.INFORMATION121
5796 ,P_PFF_ATTRIBUTE12 => r_PFF.INFORMATION122
5797 ,P_PFF_ATTRIBUTE13 => r_PFF.INFORMATION123
5798 ,P_PFF_ATTRIBUTE14 => r_PFF.INFORMATION124
5799 ,P_PFF_ATTRIBUTE15 => r_PFF.INFORMATION125
5800 ,P_PFF_ATTRIBUTE16 => r_PFF.INFORMATION126
5801 ,P_PFF_ATTRIBUTE17 => r_PFF.INFORMATION127
5802 ,P_PFF_ATTRIBUTE18 => r_PFF.INFORMATION128
5803 ,P_PFF_ATTRIBUTE19 => r_PFF.INFORMATION129
5804 ,P_PFF_ATTRIBUTE2 => r_PFF.INFORMATION112
5805 ,P_PFF_ATTRIBUTE20 => r_PFF.INFORMATION130
5806 ,P_PFF_ATTRIBUTE21 => r_PFF.INFORMATION131
5807 ,P_PFF_ATTRIBUTE22 => r_PFF.INFORMATION132
5808 ,P_PFF_ATTRIBUTE23 => r_PFF.INFORMATION133
5809 ,P_PFF_ATTRIBUTE24 => r_PFF.INFORMATION134
5810 ,P_PFF_ATTRIBUTE25 => r_PFF.INFORMATION135
5811 ,P_PFF_ATTRIBUTE26 => r_PFF.INFORMATION136
5812 ,P_PFF_ATTRIBUTE27 => r_PFF.INFORMATION137
5813 ,P_PFF_ATTRIBUTE28 => r_PFF.INFORMATION138
5814 ,P_PFF_ATTRIBUTE29 => r_PFF.INFORMATION139
5815 ,P_PFF_ATTRIBUTE3 => r_PFF.INFORMATION113
5816 ,P_PFF_ATTRIBUTE30 => r_PFF.INFORMATION140
5817 ,P_PFF_ATTRIBUTE4 => r_PFF.INFORMATION114
5818 ,P_PFF_ATTRIBUTE5 => r_PFF.INFORMATION115
5819 ,P_PFF_ATTRIBUTE6 => r_PFF.INFORMATION116
5820 ,P_PFF_ATTRIBUTE7 => r_PFF.INFORMATION117
5821 ,P_PFF_ATTRIBUTE8 => r_PFF.INFORMATION118
5822 ,P_PFF_ATTRIBUTE9 => r_PFF.INFORMATION119
5823 ,P_PFF_ATTRIBUTE_CATEGORY => r_PFF.INFORMATION110
5824 ,P_RNDG_CD => r_PFF.INFORMATION15
5825 ,P_RNDG_RL => l_RNDG_RL
5826 ,P_USE_PRMRY_ASNT_ONLY_FLAG => r_PFF.INFORMATION13
5827 ,P_USE_SUM_OF_ALL_ASNTS_FLAG => r_PFF.INFORMATION14
5828 --
5829 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
5830 );
5831 end if;
5832 --
5833 l_prev_pk_id := l_current_pk_id ;
5834 --
5835 end if;
5836 --
5837 end loop;
5838 --
5839 exception when others then
5840 --
5841 raise_error_message( 'PFF',l_prefix || r_PFF.INFORMATION218 || l_suffix) ;
5842 --
5843 end create_PFF_rows;
5844
5845 --
5846 ---------------------------------------------------------------
5847 ----------------------< create_CLA_rows >-----------------------
5848 ---------------------------------------------------------------
5849 --
5850 procedure create_CLA_rows
5851 (
5852 p_validate in number default 0
5853 ,p_copy_entity_txn_id in number
5854 ,p_effective_date in date
5855 ,p_prefix_suffix_text in varchar2 default null
5856 ,p_reuse_object_flag in varchar2 default null
5857 ,p_target_business_group_id in varchar2 default null
5858 ,p_prefix_suffix_cd in varchar2 default null
5859 ) is
5860 --
5861 cursor c_unique_CLA(l_table_alias varchar2) is
5862 select distinct cpe.information1,
5863 cpe.information2,
5864 cpe.information3,
5865 cpe.INFORMATION170 name,
5866 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
5867 from ben_copy_entity_results cpe,
5868 pqh_table_route tr
5869 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5870 and cpe.table_route_id = tr.table_route_id
5871 -- and tr.where_clause = l_BEN_CMBN_AGE_LOS_FCTR
5872 and tr.table_alias = l_table_alias
5873 and cpe.number_of_copies = 1 --ADDITION
5874 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
5875 order by information1, information2; --added for bug: 5151945
5876 --
5877 --
5878 cursor c_CLA_min_max_dates(c_table_route_id number,
5879 c_information1 number) is
5880 select
5881 min(cpe.information2) min_esd,
5882 max(cpe.information3) min_eed
5883 from ben_copy_entity_results cpe
5884 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5885 and cpe.table_route_id = c_table_route_id
5886 and cpe.information1 = c_information1 ;
5887 --
5888 cursor c_CLA(c_table_route_id number,
5889 c_information1 number,
5890 c_information2 date,
5891 c_information3 date ) is
5892 select
5893 cpe.*
5894 from ben_copy_entity_results cpe
5895 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
5896 and cpe.table_route_id = c_table_route_id
5897 and cpe.information1 = c_information1
5898 and rownum = 1 ;
5899 -- Date Track target record
5900 cursor c_find_CLA_in_target( c_CLA_name varchar2,
5901 c_effective_start_date date,
5902 c_effective_end_date date,
5903 c_business_group_id number,
5904 c_new_pk_id number) is
5905 select
5906 CLA.cmbn_age_los_fctr_id new_value
5907 from BEN_CMBN_AGE_LOS_FCTR CLA
5908 where CLA.name = c_CLA_name
5909 and CLA.business_group_id = c_business_group_id
5910 and CLA.cmbn_age_los_fctr_id <> c_new_pk_id
5911 ;
5912 --
5913 l_current_pk_id number := null ;
5914 --UPD START
5915 --
5916 l_update boolean := false ;
5917 l_datetrack_mode varchar2(80) := hr_api.g_update;
5918 l_process_date date;
5919 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
5920 --
5921 --UPD END
5922 l_prev_pk_id number := null ;
5923 l_first_rec boolean := true ;
5924 r_CLA c_CLA%rowtype;
5925 l_cmbn_age_los_fctr_id number ;
5926 l_object_version_number number ;
5927 l_effective_start_date date ;
5928 l_effective_end_date date ;
5929 l_prefix pqh_copy_entity_attribs.information1%type := null;
5930 l_suffix pqh_copy_entity_attribs.information1%type := null;
5931 l_new_value number(15);
5932 l_object_found_in_target boolean := false ;
5933 l_min_esd date;
5934 l_max_eed date;
5935 l_AGE_FCTR_ID number;
5936 l_LOS_FCTR_ID number;
5937 --
5938 begin
5939 -- Initialization
5940 l_object_found_in_target := false ;
5941 -- End Initialization
5942 -- Derive the prefix - sufix
5943 if p_prefix_suffix_cd = 'PREFIX' then
5944 l_prefix := p_prefix_suffix_text ;
5945 elsif p_prefix_suffix_cd = 'SUFFIX' then
5946 l_suffix := p_prefix_suffix_text ;
5947 else
5948 l_prefix := null ;
5949 l_suffix := null ;
5950 end if ;
5951 -- End Prefix Sufix derivation
5952 for r_CLA_unique in c_unique_CLA('CLA') loop
5953 --
5954 hr_utility.set_location(' r_CLA_unique.table_route_id '||r_CLA_unique.table_route_id,10);
5955 hr_utility.set_location(' r_CLA_unique.information1 '||r_CLA_unique.information1,10);
5956 hr_utility.set_location( 'r_CLA_unique.information2 '||r_CLA_unique.information2,10);
5957 hr_utility.set_location( 'r_CLA_unique.information3 '||r_CLA_unique.information3,10);
5958 -- If reuse objects flag is 'Y' then check for the object in the target business group
5959 -- if found insert the record into PLSql table and exit the loop else try create the
5960 -- object in the target business group
5961 --
5962 l_object_found_in_target := false ;
5963 l_min_esd := null ;
5964 l_max_eed := null ;
5965 --UPD START
5966 l_dml_operation := r_CLA_unique.dml_operation;
5967 l_update := false;
5968 --
5969 if l_dml_operation = 'UPDATE' then
5970 --
5971 l_update := true;
5972 if r_CLA_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
5973 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'CMBN_AGE_LOS_FCTR_ID' then
5974 g_pk_tbl(g_count).pk_id_column := 'CMBN_AGE_LOS_FCTR_ID';
5975 g_pk_tbl(g_count).old_value := r_CLA_unique.information1 ;
5976 g_pk_tbl(g_count).new_value := r_CLA_unique.information1 ;
5977 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
5978 g_pk_tbl(g_count).table_route_id := r_CLA_unique.table_route_id;
5979 --
5980 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ; -- NEW
5981 --
5982 g_count := g_count + 1 ;
5983 --
5984 log_data('CLA',l_new_value,l_prefix || r_CLA_unique.name|| l_suffix,'REUSED');
5985 --
5986 end if ;
5987 l_cmbn_age_los_fctr_id := r_CLA_unique.information1 ;
5988 l_object_version_number := r_CLA.information265 ;
5989 hr_utility.set_location( 'found record for update',10);
5990 --
5991 else
5992 --UPD END
5993 if p_reuse_object_flag = 'Y' then
5994 -- cursor to find the object
5995 open c_find_CLA_in_target( l_prefix || r_CLA_unique.name|| l_suffix ,r_CLA_unique.information2,l_max_eed,
5996 p_target_business_group_id, nvl(l_cmbn_age_los_fctr_id, -999) ) ;
5997 fetch c_find_CLA_in_target into l_new_value ;
5998 if c_find_CLA_in_target%found then
5999 --
6000 if r_CLA_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
6001 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'CMBN_AGE_LOS_FCTR_ID' then
6002 g_pk_tbl(g_count).pk_id_column := 'CMBN_AGE_LOS_FCTR_ID' ;
6003 g_pk_tbl(g_count).old_value := r_CLA_unique.information1 ;
6004 g_pk_tbl(g_count).new_value := l_new_value ;
6005 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
6006 g_pk_tbl(g_count).table_route_id := r_CLA_unique.table_route_id;
6007 --
6008 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
6009 --
6010 g_count := g_count + 1 ;
6011 --
6012 log_data('CLA',l_new_value,l_prefix || r_CLA_unique.name|| l_suffix,'REUSED');
6013 --
6014 end if ;
6015 --
6016 l_object_found_in_target := true ;
6017 end if;
6018 close c_find_CLA_in_target ;
6019 --
6020 end if ;
6021 end if ;
6022 --
6023 if not l_object_found_in_target or l_update then
6024 --
6025 open c_CLA(r_CLA_unique.table_route_id,
6026 r_CLA_unique.information1,
6027 r_CLA_unique.information2,
6028 r_CLA_unique.information3 ) ;
6029 --
6030 fetch c_CLA into r_CLA ;
6031 --
6032 close c_CLA ;
6033 --
6034 l_current_pk_id := r_CLA.information1;
6035 --
6036 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
6037 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
6038 --
6039 if l_current_pk_id = l_prev_pk_id then
6040 --
6041 l_first_rec := false ;
6042 --
6043 else
6044 --
6045 l_first_rec := true ;
6046 --
6047 end if ;
6048 --
6049 l_AGE_FCTR_ID := get_fk('AGE_FCTR_ID', r_CLA.INFORMATION246,l_dml_operation );
6050 l_LOS_FCTR_ID := get_fk('LOS_FCTR_ID', r_CLA.INFORMATION243,l_dml_operation );
6051 --
6052 -- To avoid creating a child with out a parent
6053 --
6054 if l_AGE_FCTR_ID is null and l_LOS_FCTR_ID is null then
6055 l_first_rec:=false;
6056 end if;
6057 --
6058 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_CMBN_AGE_LOS_FCTR',l_prefix || r_CLA.INFORMATION170 || l_suffix);
6059 --
6060 if l_first_rec and not l_update then
6061 -- Call Create routine.
6062 hr_utility.set_location(' BEN_CMBN_AGE_LOS_FCTR CREATE_CMBN_AGE_LOS_FCTR ',20);
6063 BEN_CMBN_AGE_LOS_FCTR_API.CREATE_CMBN_AGE_LOS_FCTR(
6064 --
6065 P_VALIDATE => false
6066 -- ,P_EFFECTIVE_DATE => p_effective_date
6067 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
6068 --
6069 ,P_AGE_FCTR_ID => l_AGE_FCTR_ID
6070 ,P_CLA_ATTRIBUTE1 => r_CLA.INFORMATION111
6071 ,P_CLA_ATTRIBUTE10 => r_CLA.INFORMATION120
6072 ,P_CLA_ATTRIBUTE11 => r_CLA.INFORMATION121
6073 ,P_CLA_ATTRIBUTE12 => r_CLA.INFORMATION122
6074 ,P_CLA_ATTRIBUTE13 => r_CLA.INFORMATION123
6075 ,P_CLA_ATTRIBUTE14 => r_CLA.INFORMATION124
6076 ,P_CLA_ATTRIBUTE15 => r_CLA.INFORMATION125
6077 ,P_CLA_ATTRIBUTE16 => r_CLA.INFORMATION126
6078 ,P_CLA_ATTRIBUTE17 => r_CLA.INFORMATION127
6079 ,P_CLA_ATTRIBUTE18 => r_CLA.INFORMATION128
6080 ,P_CLA_ATTRIBUTE19 => r_CLA.INFORMATION129
6081 ,P_CLA_ATTRIBUTE2 => r_CLA.INFORMATION112
6082 ,P_CLA_ATTRIBUTE20 => r_CLA.INFORMATION130
6083 ,P_CLA_ATTRIBUTE21 => r_CLA.INFORMATION131
6084 ,P_CLA_ATTRIBUTE22 => r_CLA.INFORMATION132
6085 ,P_CLA_ATTRIBUTE23 => r_CLA.INFORMATION133
6086 ,P_CLA_ATTRIBUTE24 => r_CLA.INFORMATION134
6087 ,P_CLA_ATTRIBUTE25 => r_CLA.INFORMATION135
6088 ,P_CLA_ATTRIBUTE26 => r_CLA.INFORMATION136
6089 ,P_CLA_ATTRIBUTE27 => r_CLA.INFORMATION137
6090 ,P_CLA_ATTRIBUTE28 => r_CLA.INFORMATION138
6091 ,P_CLA_ATTRIBUTE29 => r_CLA.INFORMATION139
6092 ,P_CLA_ATTRIBUTE3 => r_CLA.INFORMATION113
6093 ,P_CLA_ATTRIBUTE30 => r_CLA.INFORMATION140
6094 ,P_CLA_ATTRIBUTE4 => r_CLA.INFORMATION114
6095 ,P_CLA_ATTRIBUTE5 => r_CLA.INFORMATION115
6096 ,P_CLA_ATTRIBUTE6 => r_CLA.INFORMATION116
6097 ,P_CLA_ATTRIBUTE7 => r_CLA.INFORMATION117
6098 ,P_CLA_ATTRIBUTE8 => r_CLA.INFORMATION118
6099 ,P_CLA_ATTRIBUTE9 => r_CLA.INFORMATION119
6100 ,P_CLA_ATTRIBUTE_CATEGORY => r_CLA.INFORMATION110
6101 ,P_CMBND_MAX_VAL => r_CLA.INFORMATION294
6102 ,P_CMBND_MIN_VAL => r_CLA.INFORMATION293
6103 ,P_CMBN_AGE_LOS_FCTR_ID => l_cmbn_age_los_fctr_id
6104 ,P_LOS_FCTR_ID => l_LOS_FCTR_ID
6105 ,P_NAME => l_prefix || r_CLA.INFORMATION170 || l_suffix
6106 ,P_ORDR_NUM => r_CLA.INFORMATION260
6107 --
6108 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
6109 );
6110 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
6111 -- Update all relevent cer records with new pk_id
6112 hr_utility.set_location('Before plsql table ',222);
6113 hr_utility.set_location('new_value id '||l_cmbn_age_los_fctr_id,222);
6114 g_pk_tbl(g_count).pk_id_column := 'CMBN_AGE_LOS_FCTR_ID' ;
6115 g_pk_tbl(g_count).old_value := r_CLA.information1 ;
6116 g_pk_tbl(g_count).new_value := l_CMBN_AGE_LOS_FCTR_ID ;
6117 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
6118 g_pk_tbl(g_count).table_route_id := r_CLA_unique.table_route_id;
6119 hr_utility.set_location('After plsql table ',222);
6120 --
6121 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
6122 --
6123 g_count := g_count + 1 ;
6124 --
6125 log_data('CLA',l_new_value,l_prefix || r_CLA.INFORMATION170 || l_suffix,'COPIED');
6126 --
6127 elsif l_update then
6128
6129 hr_utility.set_location(' BEN_CMBN_AGE_LOS_FCTR UPDATE_CMBN_AGE_LOS_FCTR ',20);
6130 BEN_CMBN_AGE_LOS_FCTR_API.UPDATE_CMBN_AGE_LOS_FCTR(
6131 --
6132 P_VALIDATE => false
6133 -- ,P_EFFECTIVE_DATE => p_effective_date
6134 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
6135 --
6136 ,P_AGE_FCTR_ID => l_AGE_FCTR_ID
6137 ,P_CLA_ATTRIBUTE1 => r_CLA.INFORMATION111
6138 ,P_CLA_ATTRIBUTE10 => r_CLA.INFORMATION120
6139 ,P_CLA_ATTRIBUTE11 => r_CLA.INFORMATION121
6140 ,P_CLA_ATTRIBUTE12 => r_CLA.INFORMATION122
6141 ,P_CLA_ATTRIBUTE13 => r_CLA.INFORMATION123
6142 ,P_CLA_ATTRIBUTE14 => r_CLA.INFORMATION124
6143 ,P_CLA_ATTRIBUTE15 => r_CLA.INFORMATION125
6144 ,P_CLA_ATTRIBUTE16 => r_CLA.INFORMATION126
6145 ,P_CLA_ATTRIBUTE17 => r_CLA.INFORMATION127
6146 ,P_CLA_ATTRIBUTE18 => r_CLA.INFORMATION128
6147 ,P_CLA_ATTRIBUTE19 => r_CLA.INFORMATION129
6148 ,P_CLA_ATTRIBUTE2 => r_CLA.INFORMATION112
6149 ,P_CLA_ATTRIBUTE20 => r_CLA.INFORMATION130
6150 ,P_CLA_ATTRIBUTE21 => r_CLA.INFORMATION131
6151 ,P_CLA_ATTRIBUTE22 => r_CLA.INFORMATION132
6152 ,P_CLA_ATTRIBUTE23 => r_CLA.INFORMATION133
6153 ,P_CLA_ATTRIBUTE24 => r_CLA.INFORMATION134
6154 ,P_CLA_ATTRIBUTE25 => r_CLA.INFORMATION135
6155 ,P_CLA_ATTRIBUTE26 => r_CLA.INFORMATION136
6156 ,P_CLA_ATTRIBUTE27 => r_CLA.INFORMATION137
6157 ,P_CLA_ATTRIBUTE28 => r_CLA.INFORMATION138
6158 ,P_CLA_ATTRIBUTE29 => r_CLA.INFORMATION139
6159 ,P_CLA_ATTRIBUTE3 => r_CLA.INFORMATION113
6160 ,P_CLA_ATTRIBUTE30 => r_CLA.INFORMATION140
6161 ,P_CLA_ATTRIBUTE4 => r_CLA.INFORMATION114
6162 ,P_CLA_ATTRIBUTE5 => r_CLA.INFORMATION115
6163 ,P_CLA_ATTRIBUTE6 => r_CLA.INFORMATION116
6164 ,P_CLA_ATTRIBUTE7 => r_CLA.INFORMATION117
6165 ,P_CLA_ATTRIBUTE8 => r_CLA.INFORMATION118
6166 ,P_CLA_ATTRIBUTE9 => r_CLA.INFORMATION119
6167 ,P_CLA_ATTRIBUTE_CATEGORY => r_CLA.INFORMATION110
6168 ,P_CMBND_MAX_VAL => r_CLA.INFORMATION294
6169 ,P_CMBND_MIN_VAL => r_CLA.INFORMATION293
6170 ,P_CMBN_AGE_LOS_FCTR_ID => l_cmbn_age_los_fctr_id
6171 ,P_LOS_FCTR_ID => l_LOS_FCTR_ID
6172 ,P_NAME => l_prefix || r_CLA.INFORMATION170 || l_suffix
6173 ,P_ORDR_NUM => r_CLA.INFORMATION260
6174 --
6175 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
6176 );
6177 end if;
6178 --
6179 l_prev_pk_id := l_current_pk_id ;
6180 --
6181 end if;
6182 --
6183 end loop;
6184 --
6185 exception when others then
6186 --
6187 raise_error_message( 'CLA',l_prefix || r_CLA.INFORMATION170 || l_suffix) ;
6188 --
6189 end create_CLA_rows;
6190
6191 --
6192 ---------------------------------------------------------------
6193 ----------------------< create_PTP_rows >-----------------------
6194 ---------------------------------------------------------------
6195 --
6196 procedure create_PTP_rows
6197 (
6198 p_validate in number default 0
6199 ,p_copy_entity_txn_id in number
6200 ,p_effective_date in date
6201 ,p_prefix_suffix_text in varchar2 default null
6202 ,p_reuse_object_flag in varchar2 default null
6203 ,p_target_business_group_id in varchar2 default null
6204 ,p_prefix_suffix_cd in varchar2 default null
6205 ) is
6206 --
6207 cursor c_unique_PTP(l_table_alias varchar2) is
6208 select distinct cpe.information1,
6209 cpe.information2,
6210 cpe.information3,
6211 cpe.INFORMATION170 name,
6212 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
6213 from ben_copy_entity_results cpe,
6214 pqh_table_route tr
6215 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6216 and cpe.table_route_id = tr.table_route_id
6217 -- and tr.where_clause = l_BEN_PL_TYP_F
6218 and tr.table_alias = l_table_alias
6219 and cpe.number_of_copies = 1 --ADDITION
6220 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
6221 order by information1, information2; --added for bug: 5151945
6222 --
6223 --
6224 cursor c_PTP_min_max_dates(c_table_route_id number,
6225 c_information1 number) is
6226 select
6227 min(cpe.information2) min_esd,
6228 max(cpe.information3) min_eed
6229 from ben_copy_entity_results cpe
6230 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6231 and cpe.table_route_id = c_table_route_id
6232 and cpe.information1 = c_information1 ;
6233 --
6234 cursor c_PTP(c_table_route_id number,
6235 c_information1 number,
6236 c_information2 date,
6237 c_information3 date ) is
6238 select
6239 cpe.*
6240 from ben_copy_entity_results cpe
6241 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6242 and cpe.table_route_id = c_table_route_id
6243 and cpe.information1 = c_information1
6244 and cpe.information2 = c_information2
6245 and cpe.information3 = c_information3
6246 and rownum = 1 ;
6247 -- Date Track target record
6248 cursor c_find_PTP_in_target( c_PTP_name varchar2,
6249 c_effective_start_date date,
6250 c_effective_end_date date,
6251 c_business_group_id number,
6252 c_new_pk_id number) is
6253 select
6254 PTP.pl_typ_id new_value
6255 from BEN_PL_TYP_F PTP
6256 where PTP.name = c_PTP_name
6257 and PTP.business_group_id = c_business_group_id
6258 and PTP.pl_typ_id <> c_new_pk_id
6259 --TEMPIK
6260 and c_effective_start_date between effective_start_date
6261 and effective_end_date ;
6262 --END TEMPIK
6263 /*TEMPIK
6264 and exists ( select null
6265 from BEN_PL_TYP_F PTP1
6266 where PTP1.name = c_PTP_name
6267 and PTP1.business_group_id = c_business_group_id
6268 and PTP1.effective_start_date <= c_effective_start_date )
6269 and exists ( select null
6270 from BEN_PL_TYP_F PTP2
6271 where PTP2.name = c_PTP_name
6272 and PTP2.business_group_id = c_business_group_id
6273 and PTP2.effective_end_date >= c_effective_end_date )
6274 ;
6275 TEMPIK */
6276 --TEMPIK
6277 l_dt_rec_found boolean ;
6278 --END TEMPIK
6279 --
6280 l_current_pk_id number := null ;
6281 --UPD START
6282 --
6283 l_update boolean := false ;
6284 l_datetrack_mode varchar2(80) := hr_api.g_update;
6285 l_process_date date;
6286 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
6287 --
6288 --UPD END
6289 l_prev_pk_id number := null ;
6290 l_first_rec boolean := true ;
6291 r_PTP c_PTP%rowtype;
6292 l_pl_typ_id number ;
6293 l_object_version_number number ;
6294 l_effective_start_date date ;
6295 l_effective_end_date date ;
6296 l_prefix pqh_copy_entity_attribs.information1%type := null;
6297 l_suffix pqh_copy_entity_attribs.information1%type := null;
6298 l_new_value number(15);
6299 l_object_found_in_target boolean := false ;
6300 l_min_esd date;
6301 l_max_eed date;
6302 l_effective_date date;
6303 --
6304 begin
6305 -- Initialization
6306 l_object_found_in_target := false ;
6307 -- End Initialization
6308 -- Derive the prefix - sufix
6309 if p_prefix_suffix_cd = 'PREFIX' then
6310 l_prefix := p_prefix_suffix_text ;
6311 elsif p_prefix_suffix_cd = 'SUFFIX' then
6312 l_suffix := p_prefix_suffix_text ;
6313 else
6314 l_prefix := null ;
6315 l_suffix := null ;
6316 end if ;
6317 -- End Prefix Sufix derivation
6318 for r_PTP_unique in c_unique_PTP('PTP') loop
6319
6320 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
6321 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6322 r_PTP_unique.information3 >=
6323 ben_pd_copy_to_ben_one.g_copy_effective_date)
6324 ) then
6325 --
6326 hr_utility.set_location(' r_PTP_unique.table_route_id '||r_PTP_unique.table_route_id,10);
6327 hr_utility.set_location(' r_PTP_unique.information1 '||r_PTP_unique.information1,10);
6328 hr_utility.set_location( 'r_PTP_unique.information2 '||r_PTP_unique.information2,10);
6329 hr_utility.set_location( 'r_PTP_unique.information3 '||r_PTP_unique.information3,10);
6330 -- If reuse objects flag is 'Y' then check for the object in the target business group
6331 -- if found insert the record into PLSql table and exit the loop else try create the
6332 -- object in the target business group
6333 --
6334 l_object_found_in_target := false ;
6335 --UPD START
6336 l_update := false;
6337 l_process_date := p_effective_date;
6338 l_dml_operation:= r_PTP_unique.dml_operation ;
6339 --
6340 if l_dml_operation = 'UPDATE' then
6341 --
6342 l_object_found_in_target := TRUE;
6343 --
6344 if l_process_date between r_PTP_unique.information2 and r_PTP_unique.information3 then
6345 l_update := true;
6346 if r_PTP_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
6347 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PL_TYP_ID' then
6348 g_pk_tbl(g_count).pk_id_column := 'PL_TYP_ID' ;
6349 g_pk_tbl(g_count).old_value := r_PTP_unique.information1 ;
6350 g_pk_tbl(g_count).new_value := r_PTP_unique.information1 ;
6351 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
6352 g_pk_tbl(g_count).table_route_id := r_PTP_unique.table_route_id;
6353 --
6354 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
6355 --
6356 g_count := g_count + 1 ;
6357 --
6358 log_data('PTP',l_new_value,l_prefix || r_PTP_unique.name|| l_suffix,'REUSED');
6359 --
6360 end if ;
6361 hr_utility.set_location( 'found record for update',10);
6362 --
6363 else
6364 --
6365 l_update := false;
6366 --
6367 end if;
6368 else
6369 --
6370 --UPD END
6371 l_min_esd := null ;
6372 l_max_eed := null ;
6373 open c_PTP_min_max_dates(r_PTP_unique.table_route_id, r_PTP_unique.information1 ) ;
6374 fetch c_PTP_min_max_dates into l_min_esd,l_max_eed ;
6375
6376 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6377 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
6378 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
6379 end if;
6380 --
6381 -- if there are update rows
6382 --
6383 l_min_esd := greatest(l_min_esd,r_PTP_unique.information2);
6384
6385
6386 hr_utility.set_location( 'p_reuse_object_flag = ' || p_reuse_object_flag, 10);
6387 if p_reuse_object_flag = 'Y' then
6388 if c_PTP_min_max_dates%found then
6389 -- cursor to find the object
6390 hr_utility.set_location( 'l_prefix || r_PTP_unique.name|| l_suffix = ' || l_prefix || r_PTP_unique.name|| l_suffix,10);
6391 hr_utility.set_location( 'l_min_esd = ' || l_min_esd ,10);
6392 hr_utility.set_location( 'l_max_eed = ' || l_max_eed ,10);
6393 open c_find_PTP_in_target( l_prefix || r_PTP_unique.name|| l_suffix ,l_min_esd,l_max_eed,
6394 p_target_business_group_id, nvl(l_pl_typ_id, -999) ) ;
6395 fetch c_find_PTP_in_target into l_new_value ;
6396 if c_find_PTP_in_target%found then
6397 --
6398 --TEMPIK
6399 l_dt_rec_found := dt_api.check_min_max_dates
6400 (p_base_table_name => 'BEN_PL_TYP_F',
6401 p_base_key_column => 'PL_TYP_ID',
6402 p_base_key_value => l_new_value,
6403 p_from_date => l_min_esd,
6404 p_to_date => l_max_eed );
6405 if l_dt_rec_found THEN
6406 --END TEMPIK
6407 hr_utility.set_location( 'r_PTP_unique.information3 found ',10);
6408 if r_PTP_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
6409 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PL_TYP_ID' then
6410 g_pk_tbl(g_count).pk_id_column := 'PL_TYP_ID' ;
6411 g_pk_tbl(g_count).old_value := r_PTP_unique.information1 ;
6412 g_pk_tbl(g_count).new_value := l_new_value ;
6413 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
6414 g_pk_tbl(g_count).table_route_id := r_PTP_unique.table_route_id;
6415 --
6416 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
6417 --
6418 g_count := g_count + 1 ;
6419 --
6420 log_data('PTP',l_new_value,l_prefix || r_PTP_unique.name|| l_suffix,'REUSED');
6421 --
6422 end if ;
6423 --
6424 l_object_found_in_target := true ;
6425 --TEMPIK
6426 end if; -- l_dt_rec_found
6427 --END TEMPIK
6428 end if;
6429 close c_find_PTP_in_target ;
6430 --
6431 end if;
6432 end if ;
6433 --
6434 close c_PTP_min_max_dates ;
6435 end if ; --l_update
6436 if not l_object_found_in_target or l_update then
6437 --
6438 open c_PTP(r_PTP_unique.table_route_id,
6439 r_PTP_unique.information1,
6440 r_PTP_unique.information2,
6441 r_PTP_unique.information3 ) ;
6442 --
6443 fetch c_PTP into r_PTP ;
6444 --
6445 close c_PTP ;
6446 --
6447 l_current_pk_id := r_PTP.information1;
6448 --
6449 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
6450 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
6451 --
6452 if l_current_pk_id = l_prev_pk_id then
6453 --
6454 l_first_rec := false ;
6455 --
6456 else
6457 --
6458 l_first_rec := true ;
6459 --
6460 end if ;
6461 --
6462 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_PL_TYP_F',l_prefix || r_PTP.INFORMATION170 || l_suffix);
6463 --
6464
6465 l_effective_date := r_PTP.information2;
6466 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6467 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
6468 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
6469 end if;
6470
6471 if l_first_rec and not l_update then
6472 -- Call Create routine.
6473 hr_utility.set_location(' BEN_PL_TYP_F CREATE_PLAN_TYPE ',20);
6474 BEN_PLAN_TYPE_API.CREATE_PLAN_TYPE(
6475 --
6476 P_VALIDATE => false
6477 ,P_EFFECTIVE_DATE => l_effective_date
6478 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
6479 --
6480 ,P_COMP_TYP_CD => r_PTP.INFORMATION16
6481 ,P_IVR_IDENT => r_PTP.INFORMATION141
6482 ,P_MN_ENRL_RQD_NUM => r_PTP.INFORMATION261
6483 ,P_MX_ENRL_ALWD_NUM => r_PTP.INFORMATION260
6484 ,P_NAME => l_prefix || r_PTP.INFORMATION170 || l_suffix
6485 ,P_NO_MN_ENRL_NUM_DFND_FLAG => r_PTP.INFORMATION14
6486 ,P_NO_MX_ENRL_NUM_DFND_FLAG => r_PTP.INFORMATION13
6487 ,P_OPT_DSPLY_FMT_CD => r_PTP.INFORMATION15
6488 ,P_OPT_TYP_CD => r_PTP.INFORMATION18
6489 ,P_PL_TYP_ID => l_pl_typ_id
6490 ,P_PL_TYP_STAT_CD => r_PTP.INFORMATION17
6491 ,P_PTP_ATTRIBUTE1 => r_PTP.INFORMATION111
6492 ,P_PTP_ATTRIBUTE10 => r_PTP.INFORMATION120
6493 ,P_PTP_ATTRIBUTE11 => r_PTP.INFORMATION121
6494 ,P_PTP_ATTRIBUTE12 => r_PTP.INFORMATION122
6495 ,P_PTP_ATTRIBUTE13 => r_PTP.INFORMATION123
6496 ,P_PTP_ATTRIBUTE14 => r_PTP.INFORMATION124
6497 ,P_PTP_ATTRIBUTE15 => r_PTP.INFORMATION125
6498 ,P_PTP_ATTRIBUTE16 => r_PTP.INFORMATION126
6499 ,P_PTP_ATTRIBUTE17 => r_PTP.INFORMATION127
6500 ,P_PTP_ATTRIBUTE18 => r_PTP.INFORMATION128
6501 ,P_PTP_ATTRIBUTE19 => r_PTP.INFORMATION129
6502 ,P_PTP_ATTRIBUTE2 => r_PTP.INFORMATION112
6503 ,P_PTP_ATTRIBUTE20 => r_PTP.INFORMATION130
6504 ,P_PTP_ATTRIBUTE21 => r_PTP.INFORMATION131
6505 ,P_PTP_ATTRIBUTE22 => r_PTP.INFORMATION132
6506 ,P_PTP_ATTRIBUTE23 => r_PTP.INFORMATION133
6507 ,P_PTP_ATTRIBUTE24 => r_PTP.INFORMATION134
6508 ,P_PTP_ATTRIBUTE25 => r_PTP.INFORMATION135
6509 ,P_PTP_ATTRIBUTE26 => r_PTP.INFORMATION136
6510 ,P_PTP_ATTRIBUTE27 => r_PTP.INFORMATION137
6511 ,P_PTP_ATTRIBUTE28 => r_PTP.INFORMATION138
6512 ,P_PTP_ATTRIBUTE29 => r_PTP.INFORMATION139
6513 ,P_PTP_ATTRIBUTE3 => r_PTP.INFORMATION113
6514 ,P_PTP_ATTRIBUTE30 => r_PTP.INFORMATION140
6515 ,P_PTP_ATTRIBUTE4 => r_PTP.INFORMATION114
6516 ,P_PTP_ATTRIBUTE5 => r_PTP.INFORMATION115
6517 ,P_PTP_ATTRIBUTE6 => r_PTP.INFORMATION116
6518 ,P_PTP_ATTRIBUTE7 => r_PTP.INFORMATION117
6519 ,P_PTP_ATTRIBUTE8 => r_PTP.INFORMATION118
6520 ,P_PTP_ATTRIBUTE9 => r_PTP.INFORMATION119
6521 ,P_PTP_ATTRIBUTE_CATEGORY => r_PTP.INFORMATION110
6522 ,P_SHORT_CODE => r_PTP.INFORMATION11
6523 ,P_SHORT_NAME => r_PTP.INFORMATION12
6524 --
6525 ,P_EFFECTIVE_START_DATE => l_effective_start_date
6526 ,P_EFFECTIVE_END_DATE => l_effective_end_date
6527 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
6528 );
6529 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
6530 -- Update all relevent cer records with new pk_id
6531 hr_utility.set_location('Before plsql table ',222);
6532 hr_utility.set_location('new_value id '||l_pl_typ_id,222);
6533 g_pk_tbl(g_count).pk_id_column := 'PL_TYP_ID' ;
6534 g_pk_tbl(g_count).old_value := r_PTP.information1 ;
6535 g_pk_tbl(g_count).new_value := l_PL_TYP_ID ;
6536 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
6537 g_pk_tbl(g_count).table_route_id := r_PTP_unique.table_route_id;
6538 hr_utility.set_location('After plsql table ',222);
6539 --
6540 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
6541 --
6542 g_count := g_count + 1 ;
6543 --
6544 log_data('PTP',l_new_value,l_prefix || r_PTP.INFORMATION170 || l_suffix,'COPIED');
6545 --
6546 else
6547 --
6548 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
6549 --
6550 if l_update then
6551 --
6552 l_datetrack_mode := r_PTP.datetrack_mode ;
6553 --
6554 get_dt_modes(
6555 p_effective_date => l_process_date,
6556 p_effective_end_date => r_PTP.information3,
6557 p_effective_start_date => r_PTP.information2,
6558 p_dml_operation => r_PTP.dml_operation,
6559 p_datetrack_mode => l_datetrack_mode );
6560 -- p_update => l_update
6561 --
6562 l_effective_date := l_process_date;
6563 l_pl_typ_id := r_PTP.information1;
6564 l_object_version_number := r_PTP.information265;
6565 --
6566 end if;
6567 --
6568 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
6569 -- Call Update routine for the pk_id created in prev run .
6570 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
6571 IF l_update OR l_dml_operation <> 'UPDATE' THEN
6572 hr_utility.set_location(' BEN_PL_TYP_F UPDATE_PLAN_TYPE ',30);
6573 BEN_PLAN_TYPE_API.UPDATE_PLAN_TYPE(
6574 --
6575 P_VALIDATE => false
6576 ,P_EFFECTIVE_DATE => l_effective_date
6577 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
6578 --
6579 ,P_COMP_TYP_CD => r_PTP.INFORMATION16
6580 ,P_IVR_IDENT => r_PTP.INFORMATION141
6581 ,P_MN_ENRL_RQD_NUM => r_PTP.INFORMATION261
6582 ,P_MX_ENRL_ALWD_NUM => r_PTP.INFORMATION260
6583 ,P_NAME => l_prefix || r_PTP.INFORMATION170 || l_suffix
6584 ,P_NO_MN_ENRL_NUM_DFND_FLAG => r_PTP.INFORMATION14
6585 ,P_NO_MX_ENRL_NUM_DFND_FLAG => r_PTP.INFORMATION13
6586 ,P_OPT_DSPLY_FMT_CD => r_PTP.INFORMATION15
6587 ,P_OPT_TYP_CD => r_PTP.INFORMATION18
6588 ,P_PL_TYP_ID => l_pl_typ_id
6589 ,P_PL_TYP_STAT_CD => r_PTP.INFORMATION17
6590 ,P_PTP_ATTRIBUTE1 => r_PTP.INFORMATION111
6591 ,P_PTP_ATTRIBUTE10 => r_PTP.INFORMATION120
6592 ,P_PTP_ATTRIBUTE11 => r_PTP.INFORMATION121
6593 ,P_PTP_ATTRIBUTE12 => r_PTP.INFORMATION122
6594 ,P_PTP_ATTRIBUTE13 => r_PTP.INFORMATION123
6595 ,P_PTP_ATTRIBUTE14 => r_PTP.INFORMATION124
6596 ,P_PTP_ATTRIBUTE15 => r_PTP.INFORMATION125
6597 ,P_PTP_ATTRIBUTE16 => r_PTP.INFORMATION126
6598 ,P_PTP_ATTRIBUTE17 => r_PTP.INFORMATION127
6599 ,P_PTP_ATTRIBUTE18 => r_PTP.INFORMATION128
6600 ,P_PTP_ATTRIBUTE19 => r_PTP.INFORMATION129
6601 ,P_PTP_ATTRIBUTE2 => r_PTP.INFORMATION112
6602 ,P_PTP_ATTRIBUTE20 => r_PTP.INFORMATION130
6603 ,P_PTP_ATTRIBUTE21 => r_PTP.INFORMATION131
6604 ,P_PTP_ATTRIBUTE22 => r_PTP.INFORMATION132
6605 ,P_PTP_ATTRIBUTE23 => r_PTP.INFORMATION133
6606 ,P_PTP_ATTRIBUTE24 => r_PTP.INFORMATION134
6607 ,P_PTP_ATTRIBUTE25 => r_PTP.INFORMATION135
6608 ,P_PTP_ATTRIBUTE26 => r_PTP.INFORMATION136
6609 ,P_PTP_ATTRIBUTE27 => r_PTP.INFORMATION137
6610 ,P_PTP_ATTRIBUTE28 => r_PTP.INFORMATION138
6611 ,P_PTP_ATTRIBUTE29 => r_PTP.INFORMATION139
6612 ,P_PTP_ATTRIBUTE3 => r_PTP.INFORMATION113
6613 ,P_PTP_ATTRIBUTE30 => r_PTP.INFORMATION140
6614 ,P_PTP_ATTRIBUTE4 => r_PTP.INFORMATION114
6615 ,P_PTP_ATTRIBUTE5 => r_PTP.INFORMATION115
6616 ,P_PTP_ATTRIBUTE6 => r_PTP.INFORMATION116
6617 ,P_PTP_ATTRIBUTE7 => r_PTP.INFORMATION117
6618 ,P_PTP_ATTRIBUTE8 => r_PTP.INFORMATION118
6619 ,P_PTP_ATTRIBUTE9 => r_PTP.INFORMATION119
6620 ,P_PTP_ATTRIBUTE_CATEGORY => r_PTP.INFORMATION110
6621 ,P_SHORT_CODE => r_PTP.INFORMATION11
6622 ,P_SHORT_NAME => r_PTP.INFORMATION12
6623 --
6624 ,P_EFFECTIVE_START_DATE => l_effective_start_date
6625 ,P_EFFECTIVE_END_DATE => l_effective_end_date
6626 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
6627 ,P_DATETRACK_MODE => l_datetrack_mode
6628 );
6629 end if;
6630 end if;
6631 --
6632 --
6633 -- Delete the row if it is end dated.
6634 --
6635 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
6636 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
6637 trunc(l_max_eed) = r_PTP.information3) then
6638 --
6639 BEN_PLAN_TYPE_API.delete_PLAN_TYPE(
6640 --
6641 p_validate => false
6642 ,p_pl_typ_id => l_pl_typ_id
6643 ,p_effective_start_date => l_effective_start_date
6644 ,p_effective_end_date => l_effective_end_date
6645 ,p_object_version_number => l_object_version_number
6646 ,p_effective_date => l_max_eed
6647 ,p_datetrack_mode => hr_api.g_delete
6648 --
6649 );
6650 --
6651 end if;
6652 --
6653 l_prev_pk_id := l_current_pk_id ;
6654 --
6655 end if;
6656 --
6657 end if;
6658 --
6659 end loop;
6660 --
6661 exception when others then
6662 --
6663 raise_error_message( 'PTP',l_prefix || r_PTP.INFORMATION170 || l_suffix) ;
6664 --
6665 end create_PTP_rows;
6666
6667 --
6668 ---------------------------------------------------------------
6669 ----------------------< create_PGM_rows >-----------------------
6670 ---------------------------------------------------------------
6671 --
6672 procedure create_PGM_rows
6673 (
6674 p_validate in number default 0
6675 ,p_copy_entity_txn_id in number
6676 ,p_effective_date in date
6677 ,p_prefix_suffix_text in varchar2 default null
6678 ,p_reuse_object_flag in varchar2 default null
6679 ,p_target_business_group_id in varchar2 default null
6680 ,p_prefix_suffix_cd in varchar2 default null
6681 ) is
6682 --
6683 cursor c_unique_PGM(l_table_alias varchar2) is
6684 select distinct cpe.information1,
6685 cpe.information2,
6686 cpe.information3,
6687 cpe.INFORMATION170 name,
6688 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
6689 from ben_copy_entity_results cpe,
6690 pqh_table_route tr
6691 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6692 and cpe.table_route_id = tr.table_route_id
6693 -- and tr.where_clause = l_BEN_PGM_F
6694 and tr.table_alias = l_table_alias
6695 and cpe.number_of_copies = 1 --ADDITION
6696 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
6697 order by cpe.information1, cpe.information2 /* Bug 5076363 */;
6698 --
6699 --
6700 cursor c_PGM_min_max_dates(c_table_route_id number,
6701 c_information1 number) is
6702 select
6703 min(cpe.information2) min_esd,
6704 max(cpe.information3) min_eed
6705 from ben_copy_entity_results cpe
6706 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6707 and cpe.table_route_id = c_table_route_id
6708 and cpe.information1 = c_information1 ;
6709 --
6710 cursor c_PGM(c_table_route_id number,
6711 c_information1 number,
6712 c_information2 date,
6713 c_information3 date ) is
6714 select
6715 cpe.*
6716 from ben_copy_entity_results cpe
6717 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
6718 and cpe.table_route_id = c_table_route_id
6719 and cpe.information1 = c_information1
6720 and cpe.information2 = c_information2
6721 and cpe.information3 = c_information3
6722 and rownum = 1 ;
6723 -- Date Track target record
6724 cursor c_find_PGM_in_target( c_PGM_name varchar2,
6725 c_effective_start_date date,
6726 c_effective_end_date date,
6727 c_business_group_id number,
6728 c_new_pk_id number) is
6729 select
6730 PGM.pgm_id new_value
6731 from BEN_PGM_F PGM
6732 where PGM.name = c_PGM_name
6733 and PGM.business_group_id = c_business_group_id
6734 and PGM.pgm_id <> c_new_pk_id
6735 --TEMPIK
6736 and c_effective_start_date between effective_start_date
6737 and effective_end_date ;
6738 --END TEMPIK
6739 /*TEMPIK
6740 and exists ( select null
6741 from BEN_PGM_F PGM1
6742 where PGM1.name = c_PGM_name
6743 and PGM1.business_group_id = c_business_group_id
6744 and PGM1.effective_start_date <= c_effective_start_date )
6745 and exists ( select null
6746 from BEN_PGM_F PGM2
6747 where PGM2.name = c_PGM_name
6748 and PGM2.business_group_id = c_business_group_id
6749 and PGM2.effective_end_date >= c_effective_end_date )
6750 ;
6751 TEMPIK */
6752 --TEMPIK
6753 l_dt_rec_found boolean ;
6754 --END TEMPIK
6755 --
6756 l_current_pk_id number := null ;
6757 --UPD START
6758 --
6759 l_update boolean := false ;
6760 l_datetrack_mode varchar2(80) := hr_api.g_update;
6761 l_process_date date;
6762 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
6763 --
6764 --UPD END
6765 l_prev_pk_id number := null ;
6766 l_first_rec boolean := true ;
6767 r_PGM c_PGM%rowtype;
6768 l_pgm_id number ;
6769 l_object_version_number number ;
6770 l_effective_start_date date ;
6771 l_effective_end_date date ;
6772 l_prefix pqh_copy_entity_attribs.information1%type := null;
6773 l_suffix pqh_copy_entity_attribs.information1%type := null;
6774 l_new_value number(15);
6775 l_object_found_in_target boolean := false ;
6776 l_min_esd date;
6777 l_max_eed date;
6778 l_AUTO_ENRT_MTHD_RL number;
6779 l_DFLT_STEP_RL number;
6780 l_SCORES_CALC_RL number;
6781 l_DPNT_CVG_END_DT_RL number;
6782 l_DPNT_CVG_STRT_DT_RL number;
6783 l_ENRT_CVG_END_DT_RL number;
6784 l_ENRT_CVG_STRT_DT_RL number;
6785 l_ENRT_RL number;
6786 l_RT_END_DT_RL number;
6787 l_RT_STRT_DT_RL number;
6788 l_VRFY_FMLY_MMBR_RL number;
6789 l_SALARY_CALC_MTHD_RL number;
6790 l_status_cd varchar2(30);
6791 l_effective_date date;
6792 --
6793 l_DFLT_ELEMENT_TYPE_ID number(15);
6794 l_DFLT_INPUT_VALUE_ID number(15);
6795 --
6796 --
6797 --ML
6798 l_susp_if_dpnt_ssn_nt_prv_cd ben_pgm_f.susp_if_dpnt_ssn_nt_prv_cd%type;
6799 l_susp_if_dpnt_dob_nt_prv_cd ben_pgm_f.susp_if_dpnt_dob_nt_prv_cd%type;
6800 l_susp_if_dpnt_adr_nt_prv_cd ben_pgm_f.susp_if_dpnt_adr_nt_prv_cd%type;
6801 --
6802 begin
6803 -- Initialization
6804 l_object_found_in_target := false ;
6805 -- End Initialization
6806 -- Derive the prefix - sufix
6807 if p_prefix_suffix_cd = 'PREFIX' then
6808 l_prefix := p_prefix_suffix_text ;
6809 elsif p_prefix_suffix_cd = 'SUFFIX' then
6810 l_suffix := p_prefix_suffix_text ;
6811 else
6812 l_prefix := null ;
6813 l_suffix := null ;
6814 end if ;
6815 -- End Prefix Sufix derivation
6816 for r_PGM_unique in c_unique_PGM('PGM') loop
6817
6818 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
6819 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6820 r_PGM_unique.information3 >=
6821 ben_pd_copy_to_ben_one.g_copy_effective_date)
6822 ) then
6823 --
6824 hr_utility.set_location(' r_PGM_unique.table_route_id '||r_PGM_unique.table_route_id,10);
6825 hr_utility.set_location(' r_PGM_unique.information1 '||r_PGM_unique.information1,10);
6826 hr_utility.set_location( 'r_PGM_unique.information2 '||r_PGM_unique.information2,10);
6827 hr_utility.set_location( 'r_PGM_unique.information3 '||r_PGM_unique.information3,10);
6828 -- If reuse objects flag is 'Y' then check for the object in the target business group
6829 -- if found insert the record into PLSql table and exit the loop else try create the
6830 -- object in the target business group
6831 --
6832 l_object_found_in_target := false ;
6833 l_min_esd := null ;
6834 l_max_eed := null ;
6835 --UPD START
6836 l_update := false;
6837 l_process_date := p_effective_date;
6838 l_dml_operation:= r_PGM_unique.dml_operation ;
6839 --
6840 if l_dml_operation = 'UPDATE' then
6841 --
6842 l_object_found_in_target := TRUE;
6843 --
6844 if l_process_date between r_PGM_unique.information2 and r_PGM_unique.information3 then
6845 l_update := true;
6846 if r_PGM_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
6847 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PGM_ID' then
6848 g_pk_tbl(g_count).pk_id_column := 'PGM_ID' ;
6849 g_pk_tbl(g_count).old_value := r_PGM_unique.information1 ;
6850 g_pk_tbl(g_count).new_value := r_PGM_unique.information1 ;
6851 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
6852 g_pk_tbl(g_count).table_route_id := r_PGM_unique.table_route_id;
6853 --
6854 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
6855 --
6856 g_count := g_count + 1 ;
6857 --
6858 log_data('PGM',l_new_value,l_prefix || r_PGM_unique.name|| l_suffix,'REUSED');
6859 --
6860 end if ;
6861 hr_utility.set_location( 'found record for update',10);
6862 --
6863 else
6864 --
6865 l_update := false;
6866 --
6867 end if;
6868 else
6869 --end if; --dml_operation
6870 open c_PGM_min_max_dates(r_PGM_unique.table_route_id, r_PGM_unique.information1 ) ;
6871 fetch c_PGM_min_max_dates into l_min_esd,l_max_eed ;
6872
6873 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6874 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
6875 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
6876 end if;
6877 --
6878 -- if there are update rows
6879 --
6880 l_min_esd := greatest(l_min_esd,r_PGM_unique.information2);
6881
6882 if p_reuse_object_flag = 'Y' then
6883 if c_PGM_min_max_dates%found then
6884 -- cursor to find the object
6885 open c_find_PGM_in_target( l_prefix || r_PGM_unique.name|| l_suffix ,l_min_esd,l_max_eed,
6886 p_target_business_group_id, nvl(l_pgm_id, -999) ) ;
6887 fetch c_find_PGM_in_target into l_new_value ;
6888 if c_find_PGM_in_target%found then
6889 --
6890 --TEMPIK
6891 l_dt_rec_found := dt_api.check_min_max_dates
6892 (p_base_table_name => 'BEN_PGM_F',
6893 p_base_key_column => 'PGM_ID',
6894 p_base_key_value => l_new_value,
6895 p_from_date => l_min_esd,
6896 p_to_date => l_max_eed );
6897 if l_dt_rec_found THEN
6898 --END TEMPIK
6899 if r_PGM_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
6900 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PGM_ID' then
6901 g_pk_tbl(g_count).pk_id_column := 'PGM_ID' ;
6902 g_pk_tbl(g_count).old_value := r_PGM_unique.information1 ;
6903 g_pk_tbl(g_count).new_value := l_new_value ;
6904 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
6905 g_pk_tbl(g_count).table_route_id := r_PGM_unique.table_route_id;
6906 --
6907 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
6908 --
6909 g_count := g_count + 1 ;
6910 --
6911 log_data('PGM',l_new_value,l_prefix || r_PGM_unique.name|| l_suffix,'REUSED');
6912 --
6913 end if ;
6914 --
6915 l_object_found_in_target := true ;
6916 --TEMPIK
6917 end if; -- l_dt_rec_found
6918 --END TEMPIK
6919 end if;
6920 close c_find_PGM_in_target ;
6921 --
6922 end if;
6923 end if ;
6924 --
6925 --
6926 close c_PGM_min_max_dates ;
6927 end if; --dml_operation
6928 --
6929 if not l_object_found_in_target or l_update then
6930 --
6931 open c_PGM(r_PGM_unique.table_route_id,
6932 r_PGM_unique.information1,
6933 r_PGM_unique.information2,
6934 r_PGM_unique.information3 ) ;
6935 --
6936 fetch c_PGM into r_PGM ;
6937 --
6938 close c_PGM ;
6939 --
6940 l_current_pk_id := r_PGM.information1;
6941 --
6942 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
6943 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
6944 --
6945 if l_current_pk_id = l_prev_pk_id then
6946 --
6947 l_first_rec := false ;
6948 --
6949 else
6950 --
6951 l_first_rec := true ;
6952 --
6953 end if ;
6954 --
6955 l_AUTO_ENRT_MTHD_RL := get_fk('FORMULA_ID', r_PGM.INFORMATION272,l_dml_operation );
6956 l_DFLT_ELEMENT_TYPE_ID := get_fk('DFLT_ELEMENT_TYPE_ID', r_PGM.INFORMATION257,l_dml_operation );
6957 l_DFLT_INPUT_VALUE_ID := get_fk('DFLT_INPUT_VALUE_ID', r_PGM.INFORMATION258,l_dml_operation );
6958 l_DFLT_STEP_RL := get_fk('FORMULA_ID', r_PGM.INFORMATION259,l_dml_operation );
6959 l_DPNT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_PGM.INFORMATION269,l_dml_operation );
6960 l_DPNT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_PGM.INFORMATION268,l_dml_operation );
6961 l_ENRT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_PGM.INFORMATION266,l_dml_operation );
6962 l_ENRT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_PGM.INFORMATION267,l_dml_operation );
6963 l_ENRT_RL := get_fk('FORMULA_ID', r_PGM.INFORMATION273,l_dml_operation );
6964 l_RT_END_DT_RL := get_fk('FORMULA_ID', r_PGM.INFORMATION271,l_dml_operation );
6965 l_RT_STRT_DT_RL := get_fk('FORMULA_ID', r_PGM.INFORMATION270,l_dml_operation );
6966 l_SCORES_CALC_RL := get_fk('FORMULA_ID', r_PGM.INFORMATION261,l_dml_operation );
6967 l_VRFY_FMLY_MMBR_RL := get_fk('FORMULA_ID', r_PGM.INFORMATION274,l_dml_operation );
6968 l_SALARY_CALC_MTHD_RL := get_fk('FORMULA_ID', r_PGM.INFORMATION293,l_dml_operation );
6969 --
6970 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_PGM_F',l_prefix || r_PGM.INFORMATION170|| l_suffix);
6971 --
6972
6973 l_effective_date := r_PGM.information2;
6974 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
6975 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
6976 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
6977 end if;
6978
6979 --
6980 -- Bug : If called from plan design wizard copy the value selected by
6981 -- by the user.
6982 --
6983 if BEN_PD_COPY_TO_BEN_ONE.g_transaction_category = 'BEN_PDCRWZ' then
6984 l_status_cd := r_pgm.information38;
6985 else
6986 l_status_cd := 'P';
6987 end if;
6988
6989 --ML
6990 --
6991 if r_PGM.INFORMATION25 = 'Y' and r_pgm.INFORMATION196 is null then
6992 l_susp_if_dpnt_ssn_nt_prv_cd := 'RQDS';
6993 else
6994 l_susp_if_dpnt_ssn_nt_prv_cd := r_pgm.INFORMATION196;
6995 end if;
6996 --
6997 if r_PGM.INFORMATION23 = 'Y' and r_pgm.INFORMATION190 is null then
6998 l_susp_if_dpnt_dob_nt_prv_cd := 'RQDS';
6999 else
7000 l_susp_if_dpnt_dob_nt_prv_cd := r_pgm.INFORMATION190;
7001 end if;
7002 --
7003 if r_PGM.INFORMATION21 = 'Y' and r_pgm.INFORMATION191 is null then
7004 l_susp_if_dpnt_adr_nt_prv_cd := 'RQDS';
7005 else
7006 l_susp_if_dpnt_adr_nt_prv_cd := r_pgm.INFORMATION191;
7007 end if;
7008 --
7009
7010 if l_first_rec and not l_update then
7011 -- Call Create routine.
7012 hr_utility.set_location(' BEN_PGM_F CREATE_PROGRAM ',20);
7013 BEN_PROGRAM_API.CREATE_PROGRAM(
7014 --
7015 P_VALIDATE => false
7016 ,P_EFFECTIVE_DATE => l_effective_date
7017 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
7018 --
7019 ,P_ACTY_REF_PERD_CD => r_PGM.INFORMATION41
7020 ,P_ALWS_UNRSTRCTD_ENRT_FLAG => r_PGM.INFORMATION36
7021 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
7022 ,P_COORD_CVG_FOR_ALL_PLS_FLG => r_PGM.INFORMATION30
7023 ,P_DFLT_ELEMENT_TYPE_ID => l_DFLT_ELEMENT_TYPE_ID
7024 ,P_DFLT_INPUT_VALUE_ID => l_DFLT_INPUT_VALUE_ID
7025 ,P_DFLT_PGM_FLAG => NVL(r_PGM.INFORMATION13, 'N')
7026 ,P_DFLT_STEP_CD => r_PGM.INFORMATION14
7027 ,P_DFLT_STEP_RL => l_DFLT_STEP_RL
7028 ,P_DPNT_ADRS_RQD_FLAG => r_PGM.INFORMATION21
7029 ,P_DPNT_CVG_END_DT_CD => r_PGM.INFORMATION43
7030 ,P_DPNT_CVG_END_DT_RL => l_DPNT_CVG_END_DT_RL
7031 ,P_DPNT_CVG_STRT_DT_CD => r_PGM.INFORMATION44
7032 ,P_DPNT_CVG_STRT_DT_RL => l_DPNT_CVG_STRT_DT_RL
7033 ,P_DPNT_DOB_RQD_FLAG => r_PGM.INFORMATION23
7034 ,P_DPNT_DSGN_CD => r_PGM.INFORMATION40
7035 ,P_DPNT_DSGN_LVL_CD => r_PGM.INFORMATION37
7036 ,P_DPNT_DSGN_NO_CTFN_RQD_FLAG => r_PGM.INFORMATION31
7037 ,P_DPNT_LEGV_ID_RQD_FLAG => r_PGM.INFORMATION25
7038 ,P_DRVBL_FCTR_APLS_RTS_FLAG => r_PGM.INFORMATION34
7039 ,P_DRVBL_FCTR_DPNT_ELIG_FLAG => r_PGM.INFORMATION32
7040 ,P_DRVBL_FCTR_PRTN_ELIG_FLAG => r_PGM.INFORMATION33
7041 ,P_ELIG_APLS_FLAG => r_PGM.INFORMATION26
7042 ,P_ENRT_CD => r_PGM.INFORMATION51
7043 ,P_ENRT_CVG_END_DT_CD => r_PGM.INFORMATION42
7044 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
7045 ,P_ENRT_CVG_STRT_DT_CD => r_PGM.INFORMATION45
7046 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
7047 ,P_ENRT_INFO_RT_FREQ_CD => r_PGM.INFORMATION46
7048 ,P_ENRT_MTHD_CD => r_PGM.INFORMATION52
7049 ,P_ENRT_RL => l_ENRT_RL
7050 ,P_IVR_IDENT => r_PGM.INFORMATION141
7051 ,P_MX_DPNT_PCT_PRTT_LF_AMT => r_PGM.INFORMATION287
7052 ,P_MX_SPS_PCT_PRTT_LF_AMT => r_PGM.INFORMATION288
7053 ,P_NAME => l_prefix || r_PGM.INFORMATION170 || l_suffix
7054 ,P_PER_CVRD_CD => r_PGM.INFORMATION20
7055 ,P_PGM_ATTRIBUTE1 => r_PGM.INFORMATION111
7056 ,P_PGM_ATTRIBUTE10 => r_PGM.INFORMATION120
7057 ,P_PGM_ATTRIBUTE11 => r_PGM.INFORMATION121
7058 ,P_PGM_ATTRIBUTE12 => r_PGM.INFORMATION122
7059 ,P_PGM_ATTRIBUTE13 => r_PGM.INFORMATION123
7060 ,P_PGM_ATTRIBUTE14 => r_PGM.INFORMATION124
7061 ,P_PGM_ATTRIBUTE15 => r_PGM.INFORMATION125
7062 ,P_PGM_ATTRIBUTE16 => r_PGM.INFORMATION126
7063 ,P_PGM_ATTRIBUTE17 => r_PGM.INFORMATION127
7064 ,P_PGM_ATTRIBUTE18 => r_PGM.INFORMATION128
7065 ,P_PGM_ATTRIBUTE19 => r_PGM.INFORMATION129
7066 ,P_PGM_ATTRIBUTE2 => r_PGM.INFORMATION112
7067 ,P_PGM_ATTRIBUTE20 => r_PGM.INFORMATION130
7068 ,P_PGM_ATTRIBUTE21 => r_PGM.INFORMATION131
7069 ,P_PGM_ATTRIBUTE22 => r_PGM.INFORMATION132
7070 ,P_PGM_ATTRIBUTE23 => r_PGM.INFORMATION133
7071 ,P_PGM_ATTRIBUTE24 => r_PGM.INFORMATION134
7072 ,P_PGM_ATTRIBUTE25 => r_PGM.INFORMATION135
7073 ,P_PGM_ATTRIBUTE26 => r_PGM.INFORMATION136
7074 ,P_PGM_ATTRIBUTE27 => r_PGM.INFORMATION137
7075 ,P_PGM_ATTRIBUTE28 => r_PGM.INFORMATION138
7076 ,P_PGM_ATTRIBUTE29 => r_PGM.INFORMATION139
7077 ,P_PGM_ATTRIBUTE3 => r_PGM.INFORMATION113
7078 ,P_PGM_ATTRIBUTE30 => r_PGM.INFORMATION140
7079 ,P_PGM_ATTRIBUTE4 => r_PGM.INFORMATION114
7080 ,P_PGM_ATTRIBUTE5 => r_PGM.INFORMATION115
7081 ,P_PGM_ATTRIBUTE6 => r_PGM.INFORMATION116
7082 ,P_PGM_ATTRIBUTE7 => r_PGM.INFORMATION117
7083 ,P_PGM_ATTRIBUTE8 => r_PGM.INFORMATION118
7084 ,P_PGM_ATTRIBUTE9 => r_PGM.INFORMATION119
7085 ,P_PGM_ATTRIBUTE_CATEGORY => r_PGM.INFORMATION110
7086 ,P_PGM_DESC => r_PGM.INFORMATION219
7087 ,P_PGM_GRP_CD => r_PGM.INFORMATION49
7088 ,P_PGM_ID => l_pgm_id
7089 ,P_PGM_PRVDS_NO_AUTO_ENRT_FLAG => r_PGM.INFORMATION22
7090 ,P_PGM_PRVDS_NO_DFLT_ENRT_FLAG => r_PGM.INFORMATION24
7091 ,P_PGM_STAT_CD => l_status_cd
7092 ,P_PGM_TYP_CD => r_PGM.INFORMATION39
7093 ,P_PGM_UOM => r_PGM.INFORMATION50
7094 ,P_PGM_USE_ALL_ASNTS_ELIG_FLAG => r_PGM.INFORMATION29
7095 ,P_POE_LVL_CD => r_PGM.INFORMATION53
7096 ,P_PRTN_ELIG_OVRID_ALWD_FLAG => r_PGM.INFORMATION28
7097 ,P_RT_END_DT_CD => r_PGM.INFORMATION48
7098 ,P_RT_END_DT_RL => l_RT_END_DT_RL
7099 ,P_RT_STRT_DT_CD => r_PGM.INFORMATION47
7100 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
7101 ,P_SCORES_CALC_MTHD_CD => r_PGM.INFORMATION15
7102 ,P_SCORES_CALC_RL => l_SCORES_CALC_RL
7103 ,P_SHORT_CODE => r_PGM.INFORMATION11
7104 ,P_SHORT_NAME => r_PGM.INFORMATION12
7105 ,P_TRK_INELIG_PER_FLAG => r_PGM.INFORMATION35
7106 ,P_UPDATE_SALARY_CD => r_PGM.INFORMATION16
7107 ,P_URL_REF_NAME => r_PGM.INFORMATION185
7108 ,P_USES_ALL_ASMTS_FOR_RTS_FLAG => r_PGM.INFORMATION27
7109 ,P_USE_MULTI_PAY_RATES_FLAG => NVL(r_PGM.INFORMATION17, 'N')
7110 ,P_USE_PROG_POINTS_FLAG => NVL(r_PGM.INFORMATION18, 'N')
7111 ,P_USE_SCORES_CD => r_PGM.INFORMATION19
7112 ,P_VRFY_FMLY_MMBR_CD => r_PGM.INFORMATION54
7113 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
7114 ,P_USE_VARIABLE_RATES_FLAG => NVL(r_PGM.INFORMATION69,'N')
7115 ,P_SALARY_CALC_MTHD_CD => r_PGM.INFORMATION70
7116 ,P_GSP_ALLOW_OVERRIDE_FLAG => NVL(r_PGM.INFORMATION72,'N')
7117 ,P_SALARY_CALC_MTHD_RL => l_SALARY_CALC_MTHD_RL
7118 --
7119 --ML
7120 ,p_SUSP_IF_DPNT_SSN_NT_PRV_CD =>l_susp_if_dpnt_ssn_nt_prv_cd
7121 ,p_SUSP_IF_DPNT_DOB_NT_PRV_CD =>l_susp_if_dpnt_dob_nt_prv_cd
7122 ,p_SUSP_IF_DPNT_ADR_NT_PRV_CD =>l_susp_if_dpnt_adr_nt_prv_cd
7123 ,p_SUSP_IF_CTFN_NOT_DPNT_FLAG =>nvl(r_pgm.INFORMATION192,'Y')
7124 ,p_DPNT_CTFN_DETERMINE_CD =>r_pgm.INFORMATION193
7125 --
7126 ,P_EFFECTIVE_START_DATE => l_effective_start_date
7127 ,P_EFFECTIVE_END_DATE => l_effective_end_date
7128 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
7129 );
7130 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
7131 -- Update all relevent cer records with new pk_id
7132 hr_utility.set_location('Before plsql table ',222);
7133 hr_utility.set_location('new_value id '||l_pgm_id,222);
7134 g_pk_tbl(g_count).pk_id_column := 'PGM_ID' ;
7135 g_pk_tbl(g_count).old_value := r_PGM.information1 ;
7136 g_pk_tbl(g_count).new_value := l_PGM_ID ;
7137 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
7138 g_pk_tbl(g_count).table_route_id := r_PGM_unique.table_route_id;
7139 hr_utility.set_location('After plsql table ',222);
7140 --
7141 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
7142 --
7143 g_count := g_count + 1 ;
7144 --
7145 log_data('PGM',l_new_value,l_prefix || r_PGM.INFORMATION170 || l_suffix,'COPIED');
7146 --
7147 else
7148 --
7149 -- Call Update routine for the pk_id created in prev run .
7150 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
7151 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
7152 --
7153 if l_update then
7154 --
7155 l_datetrack_mode := r_PGM.datetrack_mode ;
7156 --
7157 get_dt_modes(
7158 p_effective_date => l_process_date,
7159 p_effective_end_date => r_PGM.information3,
7160 p_effective_start_date => r_PGM.information2,
7161 p_dml_operation => r_PGM.dml_operation,
7162 p_datetrack_mode => l_datetrack_mode );
7163 -- p_update => l_update
7164 --
7165 l_effective_date := l_process_date;
7166 l_pgm_id := r_PGM.information1;
7167 l_object_version_number := r_PGM.information265;
7168 --
7169 end if;
7170 --
7171 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
7172 --
7173 IF l_update OR l_dml_operation <> 'UPDATE' THEN
7174 hr_utility.set_location(' BEN_PGM_F UPDATE_PROGRAM ',30);
7175
7176 BEN_PROGRAM_API.UPDATE_PROGRAM(
7177 --
7178 P_VALIDATE => false
7179 ,P_EFFECTIVE_DATE => l_effective_date
7180 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
7181 --
7182 ,P_ACTY_REF_PERD_CD => r_PGM.INFORMATION41
7183 ,P_ALWS_UNRSTRCTD_ENRT_FLAG => r_PGM.INFORMATION36
7184 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
7185 ,P_COORD_CVG_FOR_ALL_PLS_FLG => r_PGM.INFORMATION30
7186 ,P_DFLT_ELEMENT_TYPE_ID => l_DFLT_ELEMENT_TYPE_ID
7187 ,P_DFLT_INPUT_VALUE_ID => l_DFLT_INPUT_VALUE_ID
7188 ,P_DFLT_PGM_FLAG => NVL(r_PGM.INFORMATION13, 'N')
7189 ,P_DFLT_STEP_CD => r_PGM.INFORMATION14
7190 ,P_DFLT_STEP_RL => l_DFLT_STEP_RL
7191 ,P_DPNT_ADRS_RQD_FLAG => r_PGM.INFORMATION21
7192 ,P_DPNT_CVG_END_DT_CD => r_PGM.INFORMATION43
7193 ,P_DPNT_CVG_END_DT_RL => l_DPNT_CVG_END_DT_RL
7194 ,P_DPNT_CVG_STRT_DT_CD => r_PGM.INFORMATION44
7195 ,P_DPNT_CVG_STRT_DT_RL => l_DPNT_CVG_STRT_DT_RL
7196 ,P_DPNT_DOB_RQD_FLAG => r_PGM.INFORMATION23
7197 ,P_DPNT_DSGN_CD => r_PGM.INFORMATION40
7198 ,P_DPNT_DSGN_LVL_CD => r_PGM.INFORMATION37
7199 ,P_DPNT_DSGN_NO_CTFN_RQD_FLAG => r_PGM.INFORMATION31
7200 ,P_DPNT_LEGV_ID_RQD_FLAG => r_PGM.INFORMATION25
7201 ,P_DRVBL_FCTR_APLS_RTS_FLAG => r_PGM.INFORMATION34
7202 ,P_DRVBL_FCTR_DPNT_ELIG_FLAG => r_PGM.INFORMATION32
7203 ,P_DRVBL_FCTR_PRTN_ELIG_FLAG => r_PGM.INFORMATION33
7204 ,P_ELIG_APLS_FLAG => r_PGM.INFORMATION26
7205 ,P_ENRT_CD => r_PGM.INFORMATION51
7206 ,P_ENRT_CVG_END_DT_CD => r_PGM.INFORMATION42
7207 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
7208 ,P_ENRT_CVG_STRT_DT_CD => r_PGM.INFORMATION45
7209 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
7210 ,P_ENRT_INFO_RT_FREQ_CD => r_PGM.INFORMATION46
7211 ,P_ENRT_MTHD_CD => r_PGM.INFORMATION52
7212 ,P_ENRT_RL => l_ENRT_RL
7213 ,P_IVR_IDENT => r_PGM.INFORMATION141
7214 ,P_MX_DPNT_PCT_PRTT_LF_AMT => r_PGM.INFORMATION287
7215 ,P_MX_SPS_PCT_PRTT_LF_AMT => r_PGM.INFORMATION288
7216 ,P_NAME => l_prefix || r_PGM.INFORMATION170 || l_suffix
7217 ,P_PER_CVRD_CD => r_PGM.INFORMATION20
7218 ,P_PGM_ATTRIBUTE1 => r_PGM.INFORMATION111
7219 ,P_PGM_ATTRIBUTE10 => r_PGM.INFORMATION120
7220 ,P_PGM_ATTRIBUTE11 => r_PGM.INFORMATION121
7221 ,P_PGM_ATTRIBUTE12 => r_PGM.INFORMATION122
7222 ,P_PGM_ATTRIBUTE13 => r_PGM.INFORMATION123
7223 ,P_PGM_ATTRIBUTE14 => r_PGM.INFORMATION124
7224 ,P_PGM_ATTRIBUTE15 => r_PGM.INFORMATION125
7225 ,P_PGM_ATTRIBUTE16 => r_PGM.INFORMATION126
7226 ,P_PGM_ATTRIBUTE17 => r_PGM.INFORMATION127
7227 ,P_PGM_ATTRIBUTE18 => r_PGM.INFORMATION128
7228 ,P_PGM_ATTRIBUTE19 => r_PGM.INFORMATION129
7229 ,P_PGM_ATTRIBUTE2 => r_PGM.INFORMATION112
7230 ,P_PGM_ATTRIBUTE20 => r_PGM.INFORMATION130
7231 ,P_PGM_ATTRIBUTE21 => r_PGM.INFORMATION131
7232 ,P_PGM_ATTRIBUTE22 => r_PGM.INFORMATION132
7233 ,P_PGM_ATTRIBUTE23 => r_PGM.INFORMATION133
7234 ,P_PGM_ATTRIBUTE24 => r_PGM.INFORMATION134
7235 ,P_PGM_ATTRIBUTE25 => r_PGM.INFORMATION135
7236 ,P_PGM_ATTRIBUTE26 => r_PGM.INFORMATION136
7237 ,P_PGM_ATTRIBUTE27 => r_PGM.INFORMATION137
7238 ,P_PGM_ATTRIBUTE28 => r_PGM.INFORMATION138
7239 ,P_PGM_ATTRIBUTE29 => r_PGM.INFORMATION139
7240 ,P_PGM_ATTRIBUTE3 => r_PGM.INFORMATION113
7241 ,P_PGM_ATTRIBUTE30 => r_PGM.INFORMATION140
7242 ,P_PGM_ATTRIBUTE4 => r_PGM.INFORMATION114
7243 ,P_PGM_ATTRIBUTE5 => r_PGM.INFORMATION115
7244 ,P_PGM_ATTRIBUTE6 => r_PGM.INFORMATION116
7245 ,P_PGM_ATTRIBUTE7 => r_PGM.INFORMATION117
7246 ,P_PGM_ATTRIBUTE8 => r_PGM.INFORMATION118
7247 ,P_PGM_ATTRIBUTE9 => r_PGM.INFORMATION119
7248 ,P_PGM_ATTRIBUTE_CATEGORY => r_PGM.INFORMATION110
7249 ,P_PGM_DESC => r_PGM.INFORMATION219
7250 ,P_PGM_GRP_CD => r_PGM.INFORMATION49
7251 ,P_PGM_ID => l_pgm_id
7252 ,P_PGM_PRVDS_NO_AUTO_ENRT_FLAG => r_PGM.INFORMATION22
7253 ,P_PGM_PRVDS_NO_DFLT_ENRT_FLAG => r_PGM.INFORMATION24
7254 ,P_PGM_STAT_CD => l_status_cd
7255 ,P_PGM_TYP_CD => r_PGM.INFORMATION39
7256 ,P_PGM_UOM => r_PGM.INFORMATION50
7257 ,P_PGM_USE_ALL_ASNTS_ELIG_FLAG => r_PGM.INFORMATION29
7258 ,P_POE_LVL_CD => r_PGM.INFORMATION53
7259 ,P_PRTN_ELIG_OVRID_ALWD_FLAG => r_PGM.INFORMATION28
7260 ,P_RT_END_DT_CD => r_PGM.INFORMATION48
7261 ,P_RT_END_DT_RL => l_RT_END_DT_RL
7262 ,P_RT_STRT_DT_CD => r_PGM.INFORMATION47
7263 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
7264 ,P_SCORES_CALC_MTHD_CD => r_PGM.INFORMATION15
7265 ,P_SCORES_CALC_RL => l_SCORES_CALC_RL
7266 ,P_SHORT_CODE => r_PGM.INFORMATION11
7267 ,P_SHORT_NAME => r_PGM.INFORMATION12
7268 ,P_TRK_INELIG_PER_FLAG => r_PGM.INFORMATION35
7269 ,P_UPDATE_SALARY_CD => r_PGM.INFORMATION16
7270 ,P_URL_REF_NAME => r_PGM.INFORMATION185
7271 ,P_USES_ALL_ASMTS_FOR_RTS_FLAG => r_PGM.INFORMATION27
7272 ,P_USE_MULTI_PAY_RATES_FLAG => NVL(r_PGM.INFORMATION17,'N')
7273 ,P_USE_PROG_POINTS_FLAG => NVL(r_PGM.INFORMATION18,'N')
7274 ,P_USE_SCORES_CD => r_PGM.INFORMATION19
7275 ,P_VRFY_FMLY_MMBR_CD => r_PGM.INFORMATION54
7276 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
7277 ,P_USE_VARIABLE_RATES_FLAG => NVL(r_PGM.INFORMATION69,'N')
7278 ,P_SALARY_CALC_MTHD_CD => r_PGM.INFORMATION70
7279 ,P_GSP_ALLOW_OVERRIDE_FLAG => NVL(r_PGM.INFORMATION72,'N')
7280 ,P_SALARY_CALC_MTHD_RL => l_SALARY_CALC_MTHD_RL
7281 --ML
7282 ,p_SUSP_IF_DPNT_SSN_NT_PRV_CD =>l_susp_if_dpnt_ssn_nt_prv_cd
7283 ,p_SUSP_IF_DPNT_DOB_NT_PRV_CD =>l_susp_if_dpnt_dob_nt_prv_cd
7284 ,p_SUSP_IF_DPNT_ADR_NT_PRV_CD =>l_susp_if_dpnt_adr_nt_prv_cd
7285 ,p_SUSP_IF_CTFN_NOT_DPNT_FLAG =>nvl(r_pgm.INFORMATION192,'Y')
7286 ,p_DPNT_CTFN_DETERMINE_CD =>r_pgm.INFORMATION193
7287 --
7288 ,P_EFFECTIVE_START_DATE => l_effective_start_date
7289 ,P_EFFECTIVE_END_DATE => l_effective_end_date
7290 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
7291 ,P_DATETRACK_MODE => l_datetrack_mode
7292 );
7293 --
7294 end if;
7295 end if;
7296 --
7297 -- Delete the row if it is end dated.
7298 --
7299 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
7300 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
7301 trunc(l_max_eed) = r_PGM.information3) then
7302 --
7303 BEN_PROGRAM_API.delete_PROGRAM(
7304 --
7305 p_validate => false
7306 ,p_pgm_id => l_pgm_id
7307 ,p_effective_start_date => l_effective_start_date
7308 ,p_effective_end_date => l_effective_end_date
7309 ,p_object_version_number => l_object_version_number
7310 ,p_effective_date => l_max_eed
7311 ,p_datetrack_mode => hr_api.g_delete
7312 --
7313 );
7314 --
7315 end if;
7316 --
7317 l_prev_pk_id := l_current_pk_id ;
7318 --
7319 end if;
7320 --
7321 end if;
7322 --
7323 end loop;
7324 --
7325 exception when others then
7326 --
7327 raise_error_message( 'PGM',l_prefix || r_PGM.INFORMATION170 || l_suffix) ;
7328 --
7329 end create_PGM_rows;
7330 --
7331 ---------------------------------------------------------------
7332 ----------------------< create_REG_rows >-----------------------
7333 ---------------------------------------------------------------
7334 --
7335 procedure create_REG_rows
7336 (
7337 p_validate in number default 0
7338 ,p_copy_entity_txn_id in number
7339 ,p_effective_date in date
7340 ,p_prefix_suffix_text in varchar2 default null
7341 ,p_reuse_object_flag in varchar2 default null
7342 ,p_target_business_group_id in varchar2 default null
7343 ,p_prefix_suffix_cd in varchar2 default null
7344 ) is
7345 --
7346 cursor c_unique_REG(l_table_alias varchar2) is
7347 select distinct cpe.information1,
7348 cpe.information2,
7349 cpe.information3,
7350 cpe.INFORMATION170 name,
7351 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
7352 from ben_copy_entity_results cpe,
7353 pqh_table_route tr
7354 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7355 and cpe.table_route_id = tr.table_route_id
7356 -- and tr.where_clause = l_BEN_REGN_F
7357 and tr.table_alias = l_table_alias
7358 and cpe.number_of_copies = 1 --ADDITION
7359 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
7360 order by information1, information2; --added for bug: 5151945
7361 --
7362 --
7363 cursor c_REG_min_max_dates(c_table_route_id number,
7364 c_information1 number) is
7365 select
7366 min(cpe.information2) min_esd,
7367 max(cpe.information3) min_eed
7368 from ben_copy_entity_results cpe
7369 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7370 and cpe.table_route_id = c_table_route_id
7371 and cpe.information1 = c_information1 ;
7372 --
7373 cursor c_REG(c_table_route_id number,
7374 c_information1 number,
7375 c_information2 date,
7376 c_information3 date ) is
7377 select
7378 cpe.*
7379 from ben_copy_entity_results cpe
7380 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7381 and cpe.table_route_id = c_table_route_id
7382 and cpe.information1 = c_information1
7383 and cpe.information2 = c_information2
7384 and cpe.information3 = c_information3
7385 and rownum = 1 ;
7386 -- Date Track target record
7387 cursor c_find_REG_in_target( c_REG_name varchar2,
7388 c_effective_start_date date,
7389 c_effective_end_date date,
7390 c_business_group_id number,
7391 c_new_pk_id number) is
7392 select
7393 REG.regn_id new_value
7394 from BEN_REGN_F REG
7395 where REG.name = c_REG_name
7396 and REG.business_group_id = c_business_group_id
7397 and REG.regn_id <> c_new_pk_id
7398 --TEMPIK
7399 and c_effective_start_date between effective_start_date
7400 and effective_end_date ;
7401 --END TEMPIK
7402 /*TEMPIK
7403 and exists ( select null
7404 from BEN_REGN_F REG1
7405 where REG1.name = c_REG_name
7406 and REG1.business_group_id = c_business_group_id
7407 and REG1.effective_start_date <= c_effective_start_date )
7408 and exists ( select null
7409 from BEN_REGN_F REG2
7410 where REG2.name = c_REG_name
7411 and REG2.business_group_id = c_business_group_id
7412 and REG2.effective_end_date >= c_effective_end_date )
7413 ;
7414 TEMPIK */
7415 --TEMPIK
7416 l_dt_rec_found boolean ;
7417 --END TEMPIK
7418 --
7419 l_current_pk_id number := null ;
7420 --UPD START
7421 --
7422 l_update boolean := false ;
7423 l_datetrack_mode varchar2(80) := hr_api.g_update;
7424 l_process_date date;
7425 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
7426 --
7427 --UPD END
7428 l_prev_pk_id number := null ;
7429 l_first_rec boolean := true ;
7430 r_REG c_REG%rowtype;
7431 l_regn_id number ;
7432 l_object_version_number number ;
7433 l_effective_start_date date ;
7434 l_effective_end_date date ;
7435 l_prefix pqh_copy_entity_attribs.information1%type := null;
7436 l_suffix pqh_copy_entity_attribs.information1%type := null;
7437 l_new_value number(15);
7438 l_object_found_in_target boolean := false ;
7439 l_min_esd date;
7440 l_max_eed date;
7441 l_ORGANIZATION_ID number;
7442 l_effective_date date;
7443 --
7444 begin
7445 -- Initialization
7446 l_object_found_in_target := false ;
7447 -- End Initialization
7448 -- Derive the prefix - sufix
7449 if p_prefix_suffix_cd = 'PREFIX' then
7450 l_prefix := p_prefix_suffix_text ;
7451 elsif p_prefix_suffix_cd = 'SUFFIX' then
7452 l_suffix := p_prefix_suffix_text ;
7453 else
7454 l_prefix := null ;
7455 l_suffix := null ;
7456 end if ;
7457 -- End Prefix Sufix derivation
7458 for r_REG_unique in c_unique_REG('REG') loop
7459
7460 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
7461 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7462 r_REG_unique.information3 >=
7463 ben_pd_copy_to_ben_one.g_copy_effective_date)
7464 ) then
7465 --
7466 hr_utility.set_location(' r_REG_unique.table_route_id '||r_REG_unique.table_route_id,10);
7467 hr_utility.set_location(' r_REG_unique.information1 '||r_REG_unique.information1,10);
7468 hr_utility.set_location( 'r_REG_unique.information2 '||r_REG_unique.information2,10);
7469 hr_utility.set_location( 'r_REG_unique.information3 '||r_REG_unique.information3,10);
7470 -- If reuse objects flag is 'Y' then check for the object in the target business group
7471 -- if found insert the record into PLSql table and exit the loop else try create the
7472 -- object in the target business group
7473 --
7474 l_object_found_in_target := false ;
7475 l_min_esd := null ;
7476 l_max_eed := null ;
7477 open c_REG_min_max_dates(r_REG_unique.table_route_id, r_REG_unique.information1 ) ;
7478 fetch c_REG_min_max_dates into l_min_esd,l_max_eed ;
7479
7480 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7481 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
7482 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
7483 end if;
7484 l_min_esd := greatest(l_min_esd,r_REG_unique.information2);
7485
7486 -- if p_reuse_object_flag = 'Y' then /* Always Reuse Regulations, Never create */
7487 if c_REG_min_max_dates%found then
7488 -- cursor to find the object
7489 open c_find_REG_in_target( r_REG_unique.name ,l_min_esd,l_max_eed,
7490 p_target_business_group_id, nvl(l_regn_id, -999) ) ;
7491 fetch c_find_REG_in_target into l_new_value ;
7492 if c_find_REG_in_target%found then
7493 --
7494 --TEMPIK
7495 l_dt_rec_found := dt_api.check_min_max_dates
7496 (p_base_table_name => 'BEN_REGN_F',
7497 p_base_key_column => 'REGN_ID',
7498 p_base_key_value => l_new_value,
7499 p_from_date => l_min_esd,
7500 p_to_date => l_max_eed );
7501 if l_dt_rec_found THEN
7502 --END TEMPIK
7503 if r_REG_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
7504 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'REGN_ID' then
7505 g_pk_tbl(g_count).pk_id_column := 'REGN_ID' ;
7506 g_pk_tbl(g_count).old_value := r_REG_unique.information1 ;
7507 g_pk_tbl(g_count).new_value := l_new_value ;
7508 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
7509 g_pk_tbl(g_count).table_route_id := r_REG_unique.table_route_id;
7510 --
7511 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
7512 --
7513 g_count := g_count + 1 ;
7514 --
7515 log_data('REG',l_new_value,r_REG_unique.name,'REUSED');
7516 --
7517 end if ;
7518 --
7519 l_object_found_in_target := true ;
7520 --TEMPIK
7521 end if; -- l_dt_rec_found
7522 --END TEMPIK
7523 end if;
7524 close c_find_REG_in_target ;
7525 --
7526 end if;
7527 -- end if ;
7528 --
7529 close c_REG_min_max_dates ;
7530 -- NEVER CREATE REGULATIONS. ALWAYS NEED TO BE REUSED
7531 /*
7532 if not l_object_found_in_target then
7533 --
7534 open c_REG(r_REG_unique.table_route_id,
7535 r_REG_unique.information1,
7536 r_REG_unique.information2,
7537 r_REG_unique.information3 ) ;
7538 --
7539 fetch c_REG into r_REG ;
7540 --
7541 close c_REG ;
7542 --
7543 l_current_pk_id := r_REG.information1;
7544 --
7545 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
7546 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
7547 --
7548 if l_current_pk_id = l_prev_pk_id then
7549 --
7550 l_first_rec := false ;
7551 --
7552 else
7553 --
7554 l_first_rec := true ;
7555 --
7556 end if ;
7557 --
7558 l_ORGANIZATION_ID := get_fk('ORGANIZATION_ID', r_REG.INFORMATION252);
7559 --
7560 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_REGN_F',l_prefix || r_REG.INFORMATION170 || l_suffix);
7561 --
7562
7563 l_effective_date := r_REG.information2;
7564 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7565 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
7566 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
7567 end if;
7568
7569 if l_first_rec and not l_update then
7570 -- Call Create routine.
7571 hr_utility.set_location(' BEN_REGN_F CREATE_REGULATIONS ',20);
7572 BEN_REGULATIONS_API.CREATE_REGULATIONS(
7573 --
7574 P_VALIDATE => false
7575 ,P_EFFECTIVE_DATE => l_effective_date
7576 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
7577 --
7578 ,P_NAME => l_prefix || r_REG.INFORMATION170 || l_suffix
7579 ,P_ORGANIZATION_ID => l_ORGANIZATION_ID
7580 ,P_REGN_ID => l_regn_id
7581 ,P_REG_ATTRIBUTE1 => r_REG.INFORMATION111
7582 ,P_REG_ATTRIBUTE10 => r_REG.INFORMATION120
7583 ,P_REG_ATTRIBUTE11 => r_REG.INFORMATION121
7584 ,P_REG_ATTRIBUTE12 => r_REG.INFORMATION122
7585 ,P_REG_ATTRIBUTE13 => r_REG.INFORMATION123
7586 ,P_REG_ATTRIBUTE14 => r_REG.INFORMATION124
7587 ,P_REG_ATTRIBUTE15 => r_REG.INFORMATION125
7588 ,P_REG_ATTRIBUTE16 => r_REG.INFORMATION126
7589 ,P_REG_ATTRIBUTE17 => r_REG.INFORMATION127
7590 ,P_REG_ATTRIBUTE18 => r_REG.INFORMATION128
7591 ,P_REG_ATTRIBUTE19 => r_REG.INFORMATION129
7592 ,P_REG_ATTRIBUTE2 => r_REG.INFORMATION112
7593 ,P_REG_ATTRIBUTE20 => r_REG.INFORMATION130
7594 ,P_REG_ATTRIBUTE21 => r_REG.INFORMATION131
7595 ,P_REG_ATTRIBUTE22 => r_REG.INFORMATION132
7596 ,P_REG_ATTRIBUTE23 => r_REG.INFORMATION133
7597 ,P_REG_ATTRIBUTE24 => r_REG.INFORMATION134
7598 ,P_REG_ATTRIBUTE25 => r_REG.INFORMATION135
7599 ,P_REG_ATTRIBUTE26 => r_REG.INFORMATION136
7600 ,P_REG_ATTRIBUTE27 => r_REG.INFORMATION137
7601 ,P_REG_ATTRIBUTE28 => r_REG.INFORMATION138
7602 ,P_REG_ATTRIBUTE29 => r_REG.INFORMATION139
7603 ,P_REG_ATTRIBUTE3 => r_REG.INFORMATION113
7604 ,P_REG_ATTRIBUTE30 => r_REG.INFORMATION140
7605 ,P_REG_ATTRIBUTE4 => r_REG.INFORMATION114
7606 ,P_REG_ATTRIBUTE5 => r_REG.INFORMATION115
7607 ,P_REG_ATTRIBUTE6 => r_REG.INFORMATION116
7608 ,P_REG_ATTRIBUTE7 => r_REG.INFORMATION117
7609 ,P_REG_ATTRIBUTE8 => r_REG.INFORMATION118
7610 ,P_REG_ATTRIBUTE9 => r_REG.INFORMATION119
7611 ,P_REG_ATTRIBUTE_CATEGORY => r_REG.INFORMATION110
7612 ,P_STTRY_CITN_NAME => r_REG.INFORMATION185
7613 --
7614 ,P_EFFECTIVE_START_DATE => l_effective_start_date
7615 ,P_EFFECTIVE_END_DATE => l_effective_end_date
7616 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
7617 );
7618 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
7619 -- Update all relevent cer records with new pk_id
7620 hr_utility.set_location('Before plsql table ',222);
7621 hr_utility.set_location('new_value id '||l_regn_id,222);
7622 g_pk_tbl(g_count).pk_id_column := 'REGN_ID' ;
7623 g_pk_tbl(g_count).old_value := r_REG.information1 ;
7624 g_pk_tbl(g_count).new_value := l_REGN_ID ;
7625 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
7626 g_pk_tbl(g_count).table_route_id := r_REG_unique.table_route_id;
7627 hr_utility.set_location('After plsql table ',222);
7628 --
7629 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
7630 --
7631 g_count := g_count + 1 ;
7632 --
7633 --
7634 log_data('REG',l_new_value,l_prefix || r_REG.INFORMATION170 || l_suffix ,'COPIED');
7635 --
7636 else
7637 --
7638 -- Call Update routine for the pk_id created in prev run .
7639 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
7640 hr_utility.set_location(' BEN_REGN_F UPDATE_REGULATIONS ',30);
7641 BEN_REGULATIONS_API.UPDATE_REGULATIONS(
7642 --
7643 P_VALIDATE => false
7644 ,P_EFFECTIVE_DATE => l_effective_date
7645 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
7646 --
7647 ,P_NAME => l_prefix || r_REG.INFORMATION170 || l_suffix
7648 ,P_ORGANIZATION_ID => l_ORGANIZATION_ID
7649 ,P_REGN_ID => l_regn_id
7650 ,P_REG_ATTRIBUTE1 => r_REG.INFORMATION111
7651 ,P_REG_ATTRIBUTE10 => r_REG.INFORMATION120
7652 ,P_REG_ATTRIBUTE11 => r_REG.INFORMATION121
7653 ,P_REG_ATTRIBUTE12 => r_REG.INFORMATION122
7654 ,P_REG_ATTRIBUTE13 => r_REG.INFORMATION123
7655 ,P_REG_ATTRIBUTE14 => r_REG.INFORMATION124
7656 ,P_REG_ATTRIBUTE15 => r_REG.INFORMATION125
7657 ,P_REG_ATTRIBUTE16 => r_REG.INFORMATION126
7658 ,P_REG_ATTRIBUTE17 => r_REG.INFORMATION127
7659 ,P_REG_ATTRIBUTE18 => r_REG.INFORMATION128
7660 ,P_REG_ATTRIBUTE19 => r_REG.INFORMATION129
7661 ,P_REG_ATTRIBUTE2 => r_REG.INFORMATION112
7662 ,P_REG_ATTRIBUTE20 => r_REG.INFORMATION130
7663 ,P_REG_ATTRIBUTE21 => r_REG.INFORMATION131
7664 ,P_REG_ATTRIBUTE22 => r_REG.INFORMATION132
7665 ,P_REG_ATTRIBUTE23 => r_REG.INFORMATION133
7666 ,P_REG_ATTRIBUTE24 => r_REG.INFORMATION134
7667 ,P_REG_ATTRIBUTE25 => r_REG.INFORMATION135
7668 ,P_REG_ATTRIBUTE26 => r_REG.INFORMATION136
7669 ,P_REG_ATTRIBUTE27 => r_REG.INFORMATION137
7670 ,P_REG_ATTRIBUTE28 => r_REG.INFORMATION138
7671 ,P_REG_ATTRIBUTE29 => r_REG.INFORMATION139
7672 ,P_REG_ATTRIBUTE3 => r_REG.INFORMATION113
7673 ,P_REG_ATTRIBUTE30 => r_REG.INFORMATION140
7674 ,P_REG_ATTRIBUTE4 => r_REG.INFORMATION114
7675 ,P_REG_ATTRIBUTE5 => r_REG.INFORMATION115
7676 ,P_REG_ATTRIBUTE6 => r_REG.INFORMATION116
7677 ,P_REG_ATTRIBUTE7 => r_REG.INFORMATION117
7678 ,P_REG_ATTRIBUTE8 => r_REG.INFORMATION118
7679 ,P_REG_ATTRIBUTE9 => r_REG.INFORMATION119
7680 ,P_REG_ATTRIBUTE_CATEGORY => r_REG.INFORMATION110
7681 ,P_STTRY_CITN_NAME => r_REG.INFORMATION185
7682 --
7683 ,P_EFFECTIVE_START_DATE => l_effective_start_date
7684 ,P_EFFECTIVE_END_DATE => l_effective_end_date
7685 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
7686 ,P_DATETRACK_MODE => l_datetrack_mode
7687 );
7688 --
7689 end if;
7690 --
7691 -- Delete the row if it is end dated.
7692 --
7693 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
7694 trunc(l_max_eed) = r_REG.information3) then
7695 --
7696 BEN_REGULATIONS_API.delete_REGULATIONS(
7697 --
7698 p_validate => false
7699 ,p_regn_id => l_regn_id
7700 ,p_effective_start_date => l_effective_start_date
7701 ,p_effective_end_date => l_effective_end_date
7702 ,p_object_version_number => l_object_version_number
7703 ,p_effective_date => l_max_eed
7704 ,p_datetrack_mode => hr_api.g_delete
7705 --
7706 );
7707 --
7708 end if;
7709 --
7710 l_prev_pk_id := l_current_pk_id ;
7711 --
7712 end if;
7713 --
7714 */
7715 end if;
7716 --
7717 end loop;
7718 --
7719 exception when others then
7720 --
7721 raise_error_message( 'REG',l_prefix || r_REG.INFORMATION170 || l_suffix) ;
7722 --
7723 end create_REG_rows;
7724
7725 --
7726 ---------------------------------------------------------------
7727 ----------------------< create_RZR_rows >-----------------------
7728 ---------------------------------------------------------------
7729 --
7730 procedure create_RZR_rows
7731 (
7732 p_validate in number default 0
7733 ,p_copy_entity_txn_id in number
7734 ,p_effective_date in date
7735 ,p_prefix_suffix_text in varchar2 default null
7736 ,p_reuse_object_flag in varchar2 default null
7737 ,p_target_business_group_id in varchar2 default null
7738 ,p_prefix_suffix_cd in varchar2 default null
7739 ) is
7740 --
7741 cursor c_unique_RZR(l_table_alias varchar2) is
7742 select distinct cpe.information1,
7743 cpe.information2,
7744 cpe.information3,
7745 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
7746 from ben_copy_entity_results cpe,
7747 pqh_table_route tr
7748 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7749 and cpe.table_route_id = tr.table_route_id
7750 -- and tr.where_clause = l_BEN_PSTL_ZIP_RNG_F
7751 and tr.table_alias = l_table_alias
7752 and cpe.number_of_copies = 1 --ADDITION
7753 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
7754 order by information1, information2; --added for bug: 5151945 --
7755 --
7756 --
7757 cursor c_RZR_min_max_dates(c_table_route_id number,
7758 c_information1 number) is
7759 select
7760 min(cpe.information2) min_esd,
7761 max(cpe.information3) min_eed
7762 from ben_copy_entity_results cpe
7763 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7764 and cpe.table_route_id = c_table_route_id
7765 and cpe.information1 = c_information1 ;
7766 --
7767 cursor c_RZR(c_table_route_id number,
7768 c_information1 number,
7769 c_information2 date,
7770 c_information3 date ) is
7771 select
7772 cpe.*
7773 from ben_copy_entity_results cpe
7774 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
7775 and cpe.table_route_id = c_table_route_id
7776 and cpe.information1 = c_information1
7777 and cpe.information2 = c_information2
7778 and cpe.information3 = c_information3
7779 and rownum = 1 ;
7780 r_RZR c_RZR%rowtype;
7781 -- Date Track target record
7782 cursor c_find_RZR_in_target(
7783 c_effective_start_date date,
7784 c_effective_end_date date,
7785 c_business_group_id number,
7786 c_new_pk_id number) is
7787 select
7788 RZR.pstl_zip_rng_id new_value
7789 from BEN_PSTL_ZIP_RNG_F RZR
7790 where
7791 RZR.business_group_id = c_business_group_id
7792 and RZR.from_value = r_RZR.information142 --r_RZR.from_value
7793 and nvl(RZR.to_value,-999) = nvl(r_RZR.information141,-999) --r_RZR.to_value
7794 and RZR.pstl_zip_rng_id <> c_new_pk_id
7795 --TEMPIK
7796 and c_effective_start_date between effective_start_date
7797 and effective_end_date ;
7798 --END TEMPIK
7799 /*TEMPIK
7800 and exists ( select null
7801 from BEN_PSTL_ZIP_RNG_F RZR1
7802 where RZR1.business_group_id = c_business_group_id
7803 and RZR1.from_value = r_RZR.information142
7804 and nvl(RZR1.to_value,-999) = nvl(r_RZR.information141,-999)
7805 and RZR1.effective_start_date <= c_effective_start_date )
7806 and exists ( select null
7807 from BEN_PSTL_ZIP_RNG_F RZR2
7808 where RZR2.business_group_id = c_business_group_id
7809 and RZR2.from_value = r_RZR.information142
7810 and nvl(RZR2.to_value,-999) = nvl(r_RZR.information141,-999)
7811 and RZR2.effective_end_date >= c_effective_end_date ) ;
7812 TEMPIK */
7813 --TEMPIK
7814 l_dt_rec_found boolean ;
7815 --END TEMPIK
7816 --
7817 l_current_pk_id number := null ;
7818 --UPD START
7819 --
7820 l_update boolean := false ;
7821 l_datetrack_mode varchar2(80) := hr_api.g_update;
7822 l_process_date date;
7823 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
7824 --
7825 --UPD END
7826 l_prev_pk_id number := null ;
7827 l_first_rec boolean := true ;
7828 l_pstl_zip_rng_id number ;
7829 l_object_version_number number ;
7830 l_effective_start_date date ;
7831 l_effective_end_date date ;
7832 l_prefix pqh_copy_entity_attribs.information1%type := null;
7833 l_suffix pqh_copy_entity_attribs.information1%type := null;
7834 l_new_value number(15);
7835 l_object_found_in_target boolean := false ;
7836 l_min_esd date;
7837 l_max_eed date;
7838 l_effective_date date;
7839 --
7840 begin
7841 -- Initialization
7842 l_object_found_in_target := false ;
7843 -- End Initialization
7844 -- Derive the prefix - sufix
7845 if p_prefix_suffix_cd = 'PREFIX' then
7846 l_prefix := p_prefix_suffix_text ;
7847 elsif p_prefix_suffix_cd = 'SUFFIX' then
7848 l_suffix := p_prefix_suffix_text ;
7849 else
7850 l_prefix := null ;
7851 l_suffix := null ;
7852 end if ;
7853 -- End Prefix Sufix derivation
7854 for r_RZR_unique in c_unique_RZR('RZR') loop
7855
7856 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
7857 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7858 r_RZR_unique.information3 >=
7859 ben_pd_copy_to_ben_one.g_copy_effective_date)
7860 ) then
7861 --
7862 hr_utility.set_location(' r_RZR_unique.table_route_id '||r_RZR_unique.table_route_id,10);
7863 hr_utility.set_location(' r_RZR_unique.information1 '||r_RZR_unique.information1,10);
7864 hr_utility.set_location( 'r_RZR_unique.information2 '||r_RZR_unique.information2,10);
7865 hr_utility.set_location( 'r_RZR_unique.information3 '||r_RZR_unique.information3,10);
7866 -- If reuse objects flag is 'Y' then check for the object in the target business group
7867 -- if found insert the record into PLSql table and exit the loop else try create the
7868 -- object in the target business group
7869 --
7870 l_object_found_in_target := false ;
7871 l_min_esd := null ;
7872 l_max_eed := null ;
7873 open c_RZR_min_max_dates(r_RZR_unique.table_route_id, r_RZR_unique.information1 ) ;
7874 fetch c_RZR_min_max_dates into l_min_esd,l_max_eed ;
7875 --
7876
7877 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
7878 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
7879 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
7880 end if;
7881 l_min_esd := greatest(l_min_esd,r_RZR_unique.information2);
7882
7883 open c_RZR(r_RZR_unique.table_route_id,
7884 r_RZR_unique.information1,
7885 r_RZR_unique.information2,
7886 r_RZR_unique.information3 ) ;
7887 --
7888 fetch c_RZR into r_RZR ;
7889 --
7890 close c_RZR ;
7891 --UPD START
7892 l_update := false;
7893 l_process_date := p_effective_date;
7894 l_dml_operation:= r_RZR_unique.dml_operation ;
7895 --
7896 if l_dml_operation = 'UPDATE' then
7897 --
7898 l_object_found_in_target := TRUE;
7899 --
7900 if l_process_date between r_RZR_unique.information2 and r_RZR_unique.information3 then
7901 l_update := true;
7902 if r_RZR_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
7903 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PSTL_ZIP_RNG_ID' then
7904 g_pk_tbl(g_count).pk_id_column := 'PSTL_ZIP_RNG_ID' ;
7905 g_pk_tbl(g_count).old_value := r_RZR_unique.information1 ;
7906 g_pk_tbl(g_count).new_value := r_RZR_unique.information1 ;
7907 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
7908 g_pk_tbl(g_count).table_route_id := r_RZR_unique.table_route_id;
7909 --
7910 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
7911 --
7912 g_count := g_count + 1 ;
7913 --
7914 log_data('RZR',l_new_value,l_prefix || r_RZR_unique.information1|| l_suffix,'REUSED');
7915 --
7916 end if ;
7917 hr_utility.set_location( 'found record for update',10);
7918 --
7919 else
7920 --
7921 l_update := false;
7922 --
7923 end if;
7924 else
7925 --
7926 --UPD END
7927 --
7928 --if p_reuse_object_flag = 'Y' then
7929 if c_RZR_min_max_dates%found then
7930 -- cursor to find the object
7931 open c_find_RZR_in_target( l_min_esd,l_max_eed,
7932 p_target_business_group_id, nvl(l_pstl_zip_rng_id, -999) ) ;
7933 fetch c_find_RZR_in_target into l_new_value ;
7934 if c_find_RZR_in_target%found then
7935 --
7936 --TEMPIK
7937 l_dt_rec_found := dt_api.check_min_max_dates
7938 (p_base_table_name => 'BEN_PSTL_ZIP_RNG_F',
7939 p_base_key_column => 'PSTL_ZIP_RNG_ID',
7940 p_base_key_value => l_new_value,
7941 p_from_date => l_min_esd,
7942 p_to_date => l_max_eed );
7943 if l_dt_rec_found THEN
7944 --END TEMPIK
7945 if r_RZR_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
7946 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PSTL_ZIP_RNG_ID' then
7947 g_pk_tbl(g_count).pk_id_column := 'PSTL_ZIP_RNG_ID' ;
7948 g_pk_tbl(g_count).old_value := r_RZR_unique.information1 ;
7949 g_pk_tbl(g_count).new_value := l_new_value ;
7950 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
7951 g_pk_tbl(g_count).table_route_id := r_RZR_unique.table_route_id;
7952 --
7953 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
7954 --
7955 g_count := g_count + 1 ;
7956 end if ;
7957 --
7958 l_object_found_in_target := true ;
7959 --TEMPIK
7960 end if; -- l_dt_rec_found
7961 --END TEMPIK
7962 end if;
7963 close c_find_RZR_in_target ;
7964 --
7965 end if;
7966 --end if ;
7967 --
7968 end if;
7969 close c_RZR_min_max_dates ;
7970 if not l_object_found_in_target or l_update then
7971 --
7972 /*
7973 open c_RZR(r_RZR_unique.table_route_id,
7974 r_RZR_unique.information1,
7975 r_RZR_unique.information2,
7976 r_RZR_unique.information3 ) ;
7977 --
7978 fetch c_RZR into r_RZR ;
7979 --
7980 close c_RZR ;
7981 --
7982 */
7983 l_current_pk_id := r_RZR.information1;
7984 --
7985 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
7986 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
7987 --
7988 if l_current_pk_id = l_prev_pk_id then
7989 --
7990 l_first_rec := false ;
7991 --
7992 else
7993 --
7994 l_first_rec := true ;
7995 --
7996 end if ;
7997 --
7998
7999 l_effective_date := r_RZR.information2;
8000 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8001 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
8002 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
8003 end if;
8004
8005 if l_first_rec and not l_update then
8006 -- Call Create routine.
8007 hr_utility.set_location(' BEN_PSTL_ZIP_RNG_F CREATE_POSTAL_ZIP_RANGE ',20);
8008 BEN_POSTAL_ZIP_RANGE_API.CREATE_POSTAL_ZIP_RANGE(
8009 --
8010 P_VALIDATE => false
8011 ,P_EFFECTIVE_DATE => l_effective_date
8012 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
8013 --
8014 ,P_FROM_VALUE => r_RZR.INFORMATION142
8015 ,P_PSTL_ZIP_RNG_ID => l_pstl_zip_rng_id
8016 ,P_RZR_ATTRIBUTE1 => r_RZR.INFORMATION111
8017 ,P_RZR_ATTRIBUTE10 => r_RZR.INFORMATION120
8018 ,P_RZR_ATTRIBUTE11 => r_RZR.INFORMATION121
8019 ,P_RZR_ATTRIBUTE12 => r_RZR.INFORMATION122
8020 ,P_RZR_ATTRIBUTE13 => r_RZR.INFORMATION123
8021 ,P_RZR_ATTRIBUTE14 => r_RZR.INFORMATION124
8022 ,P_RZR_ATTRIBUTE15 => r_RZR.INFORMATION125
8023 ,P_RZR_ATTRIBUTE16 => r_RZR.INFORMATION126
8024 ,P_RZR_ATTRIBUTE17 => r_RZR.INFORMATION127
8025 ,P_RZR_ATTRIBUTE18 => r_RZR.INFORMATION128
8026 ,P_RZR_ATTRIBUTE19 => r_RZR.INFORMATION129
8027 ,P_RZR_ATTRIBUTE2 => r_RZR.INFORMATION112
8028 ,P_RZR_ATTRIBUTE20 => r_RZR.INFORMATION130
8029 ,P_RZR_ATTRIBUTE21 => r_RZR.INFORMATION131
8030 ,P_RZR_ATTRIBUTE22 => r_RZR.INFORMATION132
8031 ,P_RZR_ATTRIBUTE23 => r_RZR.INFORMATION133
8032 ,P_RZR_ATTRIBUTE24 => r_RZR.INFORMATION134
8033 ,P_RZR_ATTRIBUTE25 => r_RZR.INFORMATION135
8034 ,P_RZR_ATTRIBUTE26 => r_RZR.INFORMATION136
8035 ,P_RZR_ATTRIBUTE27 => r_RZR.INFORMATION137
8036 ,P_RZR_ATTRIBUTE28 => r_RZR.INFORMATION138
8037 ,P_RZR_ATTRIBUTE29 => r_RZR.INFORMATION139
8038 ,P_RZR_ATTRIBUTE3 => r_RZR.INFORMATION113
8039 ,P_RZR_ATTRIBUTE30 => r_RZR.INFORMATION140
8040 ,P_RZR_ATTRIBUTE4 => r_RZR.INFORMATION114
8041 ,P_RZR_ATTRIBUTE5 => r_RZR.INFORMATION115
8042 ,P_RZR_ATTRIBUTE6 => r_RZR.INFORMATION116
8043 ,P_RZR_ATTRIBUTE7 => r_RZR.INFORMATION117
8044 ,P_RZR_ATTRIBUTE8 => r_RZR.INFORMATION118
8045 ,P_RZR_ATTRIBUTE9 => r_RZR.INFORMATION119
8046 ,P_RZR_ATTRIBUTE_CATEGORY => r_RZR.INFORMATION110
8047 ,P_TO_VALUE => r_RZR.INFORMATION141
8048 --
8049 ,P_EFFECTIVE_START_DATE => l_effective_start_date
8050 ,P_EFFECTIVE_END_DATE => l_effective_end_date
8051 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8052 );
8053 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8054 -- Update all relevent cer records with new pk_id
8055 hr_utility.set_location('Before plsql table ',222);
8056 hr_utility.set_location('new_value id '||l_pstl_zip_rng_id,222);
8057 g_pk_tbl(g_count).pk_id_column := 'PSTL_ZIP_RNG_ID' ;
8058 g_pk_tbl(g_count).old_value := r_RZR.information1 ;
8059 g_pk_tbl(g_count).new_value := l_PSTL_ZIP_RNG_ID ;
8060 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
8061 g_pk_tbl(g_count).table_route_id := r_RZR_unique.table_route_id;
8062 hr_utility.set_location('After plsql table ',222);
8063 --
8064 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
8065 --
8066 g_count := g_count + 1 ;
8067 --
8068 else
8069 --
8070 --UPD START
8071 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
8072 --
8073 if l_update then
8074 --
8075 l_datetrack_mode := r_RZR.datetrack_mode ;
8076 --
8077 get_dt_modes(
8078 p_effective_date => l_process_date,
8079 p_effective_end_date => r_RZR.information3,
8080 p_effective_start_date => r_RZR.information2,
8081 p_dml_operation => r_RZR.dml_operation,
8082 p_datetrack_mode => l_datetrack_mode );
8083 -- p_update => l_update
8084 --
8085 l_effective_date := l_process_date;
8086 l_pstl_zip_rng_id := r_RZR.information1;
8087 l_object_version_number := r_RZR.information265;
8088 --
8089 end if;
8090 --
8091 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
8092 --
8093 IF l_update OR l_dml_operation <> 'UPDATE' THEN
8094 --UPD END
8095 -- Call Update routine for the pk_id created in prev run .
8096 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8097 hr_utility.set_location(' BEN_PSTL_ZIP_RNG_F UPDATE_POSTAL_ZIP_RANGE ',30);
8098 BEN_POSTAL_ZIP_RANGE_API.UPDATE_POSTAL_ZIP_RANGE(
8099 --
8100 P_VALIDATE => false
8101 ,P_EFFECTIVE_DATE => l_effective_date
8102 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
8103 --
8104 ,P_FROM_VALUE => r_RZR.INFORMATION142
8105 ,P_PSTL_ZIP_RNG_ID => l_pstl_zip_rng_id
8106 ,P_RZR_ATTRIBUTE1 => r_RZR.INFORMATION111
8107 ,P_RZR_ATTRIBUTE10 => r_RZR.INFORMATION120
8108 ,P_RZR_ATTRIBUTE11 => r_RZR.INFORMATION121
8109 ,P_RZR_ATTRIBUTE12 => r_RZR.INFORMATION122
8110 ,P_RZR_ATTRIBUTE13 => r_RZR.INFORMATION123
8111 ,P_RZR_ATTRIBUTE14 => r_RZR.INFORMATION124
8112 ,P_RZR_ATTRIBUTE15 => r_RZR.INFORMATION125
8113 ,P_RZR_ATTRIBUTE16 => r_RZR.INFORMATION126
8114 ,P_RZR_ATTRIBUTE17 => r_RZR.INFORMATION127
8115 ,P_RZR_ATTRIBUTE18 => r_RZR.INFORMATION128
8116 ,P_RZR_ATTRIBUTE19 => r_RZR.INFORMATION129
8117 ,P_RZR_ATTRIBUTE2 => r_RZR.INFORMATION112
8118 ,P_RZR_ATTRIBUTE20 => r_RZR.INFORMATION130
8119 ,P_RZR_ATTRIBUTE21 => r_RZR.INFORMATION131
8120 ,P_RZR_ATTRIBUTE22 => r_RZR.INFORMATION132
8121 ,P_RZR_ATTRIBUTE23 => r_RZR.INFORMATION133
8122 ,P_RZR_ATTRIBUTE24 => r_RZR.INFORMATION134
8123 ,P_RZR_ATTRIBUTE25 => r_RZR.INFORMATION135
8124 ,P_RZR_ATTRIBUTE26 => r_RZR.INFORMATION136
8125 ,P_RZR_ATTRIBUTE27 => r_RZR.INFORMATION137
8126 ,P_RZR_ATTRIBUTE28 => r_RZR.INFORMATION138
8127 ,P_RZR_ATTRIBUTE29 => r_RZR.INFORMATION139
8128 ,P_RZR_ATTRIBUTE3 => r_RZR.INFORMATION113
8129 ,P_RZR_ATTRIBUTE30 => r_RZR.INFORMATION140
8130 ,P_RZR_ATTRIBUTE4 => r_RZR.INFORMATION114
8131 ,P_RZR_ATTRIBUTE5 => r_RZR.INFORMATION115
8132 ,P_RZR_ATTRIBUTE6 => r_RZR.INFORMATION116
8133 ,P_RZR_ATTRIBUTE7 => r_RZR.INFORMATION117
8134 ,P_RZR_ATTRIBUTE8 => r_RZR.INFORMATION118
8135 ,P_RZR_ATTRIBUTE9 => r_RZR.INFORMATION119
8136 ,P_RZR_ATTRIBUTE_CATEGORY => r_RZR.INFORMATION110
8137 ,P_TO_VALUE => r_RZR.INFORMATION141
8138 --
8139 ,P_EFFECTIVE_START_DATE => l_effective_start_date
8140 ,P_EFFECTIVE_END_DATE => l_effective_end_date
8141 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8142 ,P_DATETRACK_MODE => l_datetrack_mode
8143 );
8144 --
8145 end if;
8146 end if;
8147 --
8148 -- Delete the row if it is end dated.
8149 --
8150 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
8151 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
8152 trunc(l_max_eed) = r_RZR.information3) then
8153 --
8154 BEN_POSTAL_ZIP_RANGE_API.delete_POSTAL_ZIP_RANGE(
8155 --
8156 p_validate => false
8157 ,p_pstl_zip_rng_id => l_pstl_zip_rng_id
8158 ,p_effective_start_date => l_effective_start_date
8159 ,p_effective_end_date => l_effective_end_date
8160 ,p_object_version_number => l_object_version_number
8161 ,p_effective_date => l_max_eed
8162 ,p_datetrack_mode => hr_api.g_delete
8163 --
8164 );
8165 --
8166 end if;
8167 --
8168 l_prev_pk_id := l_current_pk_id ;
8169 --
8170 end if;
8171 --
8172 end if;
8173 --
8174 end loop;
8175 --
8176 exception when others then
8177 --
8178 raise_error_message( 'RZR',r_RZR.information5 ) ;
8179 --
8180 end create_RZR_rows;
8181
8182 --
8183 ---------------------------------------------------------------
8184 ----------------------< create_BNR_rows >-----------------------
8185 ---------------------------------------------------------------
8186 --
8187 procedure create_BNR_rows
8188 (
8189 p_validate in number default 0
8190 ,p_copy_entity_txn_id in number
8191 ,p_effective_date in date
8192 ,p_prefix_suffix_text in varchar2 default null
8193 ,p_reuse_object_flag in varchar2 default null
8194 ,p_target_business_group_id in varchar2 default null
8195 ,p_prefix_suffix_cd in varchar2 default null
8196 ) is
8197 --
8198 cursor c_unique_BNR(l_table_alias varchar2) is
8199 select distinct cpe.information1,
8200 cpe.information2,
8201 cpe.information3,
8202 cpe.INFORMATION170 name,
8203 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
8204 from ben_copy_entity_results cpe,
8205 pqh_table_route tr
8206 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8207 and cpe.table_route_id = tr.table_route_id
8208 -- and tr.where_clause = l_BEN_RPTG_GRP
8209 and tr.table_alias = l_table_alias
8210 and cpe.number_of_copies = 1 --ADDITION
8211 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
8212 order by information1, information2; --added for bug: 5151945
8213 --
8214 --
8215 cursor c_BNR_min_max_dates(c_table_route_id number,
8216 c_information1 number) is
8217 select
8218 min(cpe.information2) min_esd,
8219 max(cpe.information3) min_eed
8220 from ben_copy_entity_results cpe
8221 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8222 and cpe.table_route_id = c_table_route_id
8223 and cpe.information1 = c_information1 ;
8224 --
8225 cursor c_BNR(c_table_route_id number,
8226 c_information1 number,
8227 c_information2 date,
8228 c_information3 date ) is
8229 select
8230 cpe.*
8231 from ben_copy_entity_results cpe
8232 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8233 and cpe.table_route_id = c_table_route_id
8234 and cpe.information1 = c_information1
8235 and rownum = 1 ;
8236 -- Date Track target record
8237 cursor c_find_BNR_in_target( c_BNR_name varchar2,
8238 c_effective_start_date date,
8239 c_effective_end_date date,
8240 c_business_group_id number,
8241 c_new_pk_id number) is
8242 select
8243 BNR.rptg_grp_id new_value
8244 from BEN_RPTG_GRP BNR
8245 where BNR.name = c_BNR_name
8246 and (BNR.business_group_id = c_business_group_id
8247 or BNR.business_group_id is null) -- Bug 2907912
8248 and BNR.rptg_grp_id <> c_new_pk_id
8249 ;
8250 --
8251 l_current_pk_id number := null ;
8252 --UPD START
8253 --
8254 l_update boolean := false ;
8255 l_datetrack_mode varchar2(80) := hr_api.g_update;
8256 l_process_date date;
8257 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
8258 --
8259 --UPD END
8260 l_prev_pk_id number := null ;
8261 l_first_rec boolean := true ;
8262 r_BNR c_BNR%rowtype;
8263 l_rptg_grp_id number ;
8264 l_object_version_number number ;
8265 l_business_group_id number ;
8266 l_effective_start_date date ;
8267 l_effective_end_date date ;
8268 l_prefix pqh_copy_entity_attribs.information1%type := null;
8269 l_suffix pqh_copy_entity_attribs.information1%type := null;
8270 l_new_value number(15);
8271 l_object_found_in_target boolean := false ;
8272 l_min_esd date;
8273 l_max_eed date;
8274 --
8275 begin
8276 -- Initialization
8277 l_object_found_in_target := false ;
8278 -- End Initialization
8279 -- Derive the prefix - sufix
8280 if p_prefix_suffix_cd = 'PREFIX' then
8281 l_prefix := p_prefix_suffix_text ;
8282 elsif p_prefix_suffix_cd = 'SUFFIX' then
8283 l_suffix := p_prefix_suffix_text ;
8284 else
8285 l_prefix := null ;
8286 l_suffix := null ;
8287 end if ;
8288 -- End Prefix Sufix derivation
8289 for r_BNR_unique in c_unique_BNR('BNR') loop
8290 --
8291 hr_utility.set_location(' r_BNR_unique.table_route_id '||r_BNR_unique.table_route_id,10);
8292 hr_utility.set_location(' r_BNR_unique.information1 '||r_BNR_unique.information1,10);
8293 hr_utility.set_location( 'r_BNR_unique.information2 '||r_BNR_unique.information2,10);
8294 hr_utility.set_location( 'r_BNR_unique.information3 '||r_BNR_unique.information3,10);
8295 -- If reuse objects flag is 'Y' then check for the object in the target business group
8296 -- if found insert the record into PLSql table and exit the loop else try create the
8297 -- object in the target business group
8298 --
8299 l_object_found_in_target := false ;
8300 l_min_esd := null ;
8301 l_max_eed := null ;
8302 --UPD START
8303 l_dml_operation := r_BNR_unique.dml_operation;
8304 --
8305 l_update := false;
8306 --
8307 if l_dml_operation = 'UPDATE' then
8308 --
8309 l_update := true;
8310 if r_BNR_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
8311 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'RPTG_GRP_ID' then
8312 g_pk_tbl(g_count).pk_id_column := 'RPTG_GRP_ID' ;
8313 g_pk_tbl(g_count).old_value := r_BNR_unique.information1 ;
8314 g_pk_tbl(g_count).new_value := r_BNR_unique.information1 ;
8315 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
8316 g_pk_tbl(g_count).table_route_id := r_BNR_unique.table_route_id;
8317 --
8318 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ; -- NEW
8319 --
8320 g_count := g_count + 1 ;
8321 --
8322 log_data('BNR',l_new_value,l_prefix || r_BNR_unique.name|| l_suffix,'REUSED');
8323 --
8324 end if ;
8325 l_RPTG_GRP_ID := r_BNR_unique.information1 ;
8326 l_object_version_number := r_BNR.information265 ;
8327 hr_utility.set_location( 'found record for update',10);
8328 --
8329 else
8330 if p_reuse_object_flag = 'Y' then
8331 -- cursor to find the object
8332 open c_find_BNR_in_target( l_prefix || r_BNR_unique.name || l_suffix ,r_BNR_unique.information2,l_max_eed,
8333 p_target_business_group_id, nvl(l_rptg_grp_id, -999) ) ;
8334 fetch c_find_BNR_in_target into l_new_value ;
8335 if c_find_BNR_in_target%found then
8336 --
8337 if r_BNR_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
8338 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'RPTG_GRP_ID' then
8339 g_pk_tbl(g_count).pk_id_column := 'RPTG_GRP_ID' ;
8340 g_pk_tbl(g_count).old_value := r_BNR_unique.information1 ;
8341 g_pk_tbl(g_count).new_value := l_new_value ;
8342 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
8343 g_pk_tbl(g_count).table_route_id := r_BNR_unique.table_route_id;
8344 --
8345 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
8346 --
8347 g_count := g_count + 1 ;
8348 --
8349 log_data('BNR',l_new_value,l_prefix || r_BNR_unique.name || l_suffix ,'REUSED');
8350 --
8351 end if ;
8352 --
8353 l_object_found_in_target := true ;
8354 end if;
8355 close c_find_BNR_in_target ;
8356 --
8357 end if ;
8358 end if ;
8359 --
8360 if not l_object_found_in_target or l_update then
8361 --
8362 open c_BNR(r_BNR_unique.table_route_id,
8363 r_BNR_unique.information1,
8364 r_BNR_unique.information2,
8365 r_BNR_unique.information3 ) ;
8366 --
8367 fetch c_BNR into r_BNR ;
8368 --
8369 close c_BNR ;
8370 --
8371 l_current_pk_id := r_BNR.information1;
8372 --
8373 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
8374 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
8375 --
8376 if l_current_pk_id = l_prev_pk_id then
8377 --
8378 l_first_rec := false ;
8379 --
8380 else
8381 --
8382 l_first_rec := true ;
8383 --
8384 end if ;
8385 --
8386 if(r_BNR.information4 is null) then
8387 l_BUSINESS_GROUP_ID := null;
8388 else
8389 l_business_group_id := p_target_business_group_id;
8390 end if;
8391 --
8392 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_RPTG_GRP',l_prefix || r_BNR.INFORMATION170 || l_suffix);
8393 --
8394 if l_first_rec and not l_update then
8395 -- Call Create routine.
8396 hr_utility.set_location(' BEN_RPTG_GRP CREATE_REPORTING_GROUP ',20);
8397 BEN_REPORTING_GROUP_API.CREATE_REPORTING_GROUP(
8398 --
8399 P_VALIDATE => false
8400 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
8401 ,P_BUSINESS_GROUP_ID => l_business_group_id
8402 --
8403 ,P_BNR_ATTRIBUTE1 => r_BNR.INFORMATION111
8404 ,P_BNR_ATTRIBUTE10 => r_BNR.INFORMATION120
8405 ,P_BNR_ATTRIBUTE11 => r_BNR.INFORMATION121
8406 ,P_BNR_ATTRIBUTE12 => r_BNR.INFORMATION122
8407 ,P_BNR_ATTRIBUTE13 => r_BNR.INFORMATION123
8408 ,P_BNR_ATTRIBUTE14 => r_BNR.INFORMATION124
8409 ,P_BNR_ATTRIBUTE15 => r_BNR.INFORMATION125
8410 ,P_BNR_ATTRIBUTE16 => r_BNR.INFORMATION126
8411 ,P_BNR_ATTRIBUTE17 => r_BNR.INFORMATION127
8412 ,P_BNR_ATTRIBUTE18 => r_BNR.INFORMATION128
8413 ,P_BNR_ATTRIBUTE19 => r_BNR.INFORMATION129
8414 ,P_BNR_ATTRIBUTE2 => r_BNR.INFORMATION112
8415 ,P_BNR_ATTRIBUTE20 => r_BNR.INFORMATION130
8416 ,P_BNR_ATTRIBUTE21 => r_BNR.INFORMATION131
8417 ,P_BNR_ATTRIBUTE22 => r_BNR.INFORMATION132
8418 ,P_BNR_ATTRIBUTE23 => r_BNR.INFORMATION133
8419 ,P_BNR_ATTRIBUTE24 => r_BNR.INFORMATION134
8420 ,P_BNR_ATTRIBUTE25 => r_BNR.INFORMATION135
8421 ,P_BNR_ATTRIBUTE26 => r_BNR.INFORMATION136
8422 ,P_BNR_ATTRIBUTE27 => r_BNR.INFORMATION137
8423 ,P_BNR_ATTRIBUTE28 => r_BNR.INFORMATION138
8424 ,P_BNR_ATTRIBUTE29 => r_BNR.INFORMATION139
8425 ,P_BNR_ATTRIBUTE3 => r_BNR.INFORMATION113
8426 ,P_BNR_ATTRIBUTE30 => r_BNR.INFORMATION140
8427 ,P_BNR_ATTRIBUTE4 => r_BNR.INFORMATION114
8428 ,P_BNR_ATTRIBUTE5 => r_BNR.INFORMATION115
8429 ,P_BNR_ATTRIBUTE6 => r_BNR.INFORMATION116
8430 ,P_BNR_ATTRIBUTE7 => r_BNR.INFORMATION117
8431 ,P_BNR_ATTRIBUTE8 => r_BNR.INFORMATION118
8432 ,P_BNR_ATTRIBUTE9 => r_BNR.INFORMATION119
8433 ,P_BNR_ATTRIBUTE_CATEGORY => r_BNR.INFORMATION110
8434 ,P_FUNCTION_CODE => r_BNR.INFORMATION11
8435 ,P_LEGISLATION_CODE => r_BNR.INFORMATION12
8436 ,P_NAME => l_prefix || r_BNR.INFORMATION170 || l_suffix
8437 ,P_RPG_DESC => r_BNR.INFORMATION185
8438 ,P_RPTG_GRP_ID => l_rptg_grp_id
8439 ,P_RPTG_PRPS_CD => r_BNR.INFORMATION13
8440 --
8441 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8442 );
8443 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8444 -- Update all relevent cer records with new pk_id
8445 hr_utility.set_location('Before plsql table ',222);
8446 hr_utility.set_location('new_value id '||l_rptg_grp_id,222);
8447 g_pk_tbl(g_count).pk_id_column := 'RPTG_GRP_ID' ;
8448 g_pk_tbl(g_count).old_value := r_BNR.information1 ;
8449 g_pk_tbl(g_count).new_value := l_RPTG_GRP_ID ;
8450 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
8451 g_pk_tbl(g_count).table_route_id := r_BNR_unique.table_route_id;
8452 hr_utility.set_location('After plsql table ',222);
8453 --
8454 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
8455 --
8456 g_count := g_count + 1 ;
8457 --
8458 log_data('BNR',l_new_value,l_prefix || r_BNR.INFORMATION170 || l_suffix ,'COPIED');
8459 --
8460 elsif l_update then
8461 hr_utility.set_location(' BEN_RPTG_GRP UPDATE_REPORTING_GROUP ',20);
8462 BEN_REPORTING_GROUP_API.UPDATE_REPORTING_GROUP(
8463 --
8464 P_VALIDATE => false
8465 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
8466 ,P_BUSINESS_GROUP_ID => l_business_group_id
8467 --
8468 ,P_BNR_ATTRIBUTE1 => r_BNR.INFORMATION111
8469 ,P_BNR_ATTRIBUTE10 => r_BNR.INFORMATION120
8470 ,P_BNR_ATTRIBUTE11 => r_BNR.INFORMATION121
8471 ,P_BNR_ATTRIBUTE12 => r_BNR.INFORMATION122
8472 ,P_BNR_ATTRIBUTE13 => r_BNR.INFORMATION123
8473 ,P_BNR_ATTRIBUTE14 => r_BNR.INFORMATION124
8474 ,P_BNR_ATTRIBUTE15 => r_BNR.INFORMATION125
8475 ,P_BNR_ATTRIBUTE16 => r_BNR.INFORMATION126
8476 ,P_BNR_ATTRIBUTE17 => r_BNR.INFORMATION127
8477 ,P_BNR_ATTRIBUTE18 => r_BNR.INFORMATION128
8478 ,P_BNR_ATTRIBUTE19 => r_BNR.INFORMATION129
8479 ,P_BNR_ATTRIBUTE2 => r_BNR.INFORMATION112
8480 ,P_BNR_ATTRIBUTE20 => r_BNR.INFORMATION130
8481 ,P_BNR_ATTRIBUTE21 => r_BNR.INFORMATION131
8482 ,P_BNR_ATTRIBUTE22 => r_BNR.INFORMATION132
8483 ,P_BNR_ATTRIBUTE23 => r_BNR.INFORMATION133
8484 ,P_BNR_ATTRIBUTE24 => r_BNR.INFORMATION134
8485 ,P_BNR_ATTRIBUTE25 => r_BNR.INFORMATION135
8486 ,P_BNR_ATTRIBUTE26 => r_BNR.INFORMATION136
8487 ,P_BNR_ATTRIBUTE27 => r_BNR.INFORMATION137
8488 ,P_BNR_ATTRIBUTE28 => r_BNR.INFORMATION138
8489 ,P_BNR_ATTRIBUTE29 => r_BNR.INFORMATION139
8490 ,P_BNR_ATTRIBUTE3 => r_BNR.INFORMATION113
8491 ,P_BNR_ATTRIBUTE30 => r_BNR.INFORMATION140
8492 ,P_BNR_ATTRIBUTE4 => r_BNR.INFORMATION114
8493 ,P_BNR_ATTRIBUTE5 => r_BNR.INFORMATION115
8494 ,P_BNR_ATTRIBUTE6 => r_BNR.INFORMATION116
8495 ,P_BNR_ATTRIBUTE7 => r_BNR.INFORMATION117
8496 ,P_BNR_ATTRIBUTE8 => r_BNR.INFORMATION118
8497 ,P_BNR_ATTRIBUTE9 => r_BNR.INFORMATION119
8498 ,P_BNR_ATTRIBUTE_CATEGORY => r_BNR.INFORMATION110
8499 ,P_FUNCTION_CODE => r_BNR.INFORMATION11
8500 ,P_LEGISLATION_CODE => r_BNR.INFORMATION12
8501 ,P_NAME => l_prefix || r_BNR.INFORMATION170 || l_suffix
8502 ,P_RPG_DESC => r_BNR.INFORMATION185
8503 ,P_RPTG_GRP_ID => l_rptg_grp_id
8504 ,P_RPTG_PRPS_CD => r_BNR.INFORMATION13
8505 --
8506 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8507 );
8508 end if;
8509 --
8510 l_prev_pk_id := l_current_pk_id ;
8511 --
8512 end if;
8513 --
8514 end loop;
8515 --
8516 exception when others then
8517 --
8518 raise_error_message( 'BNR',l_prefix || r_BNR.INFORMATION170 || l_suffix) ;
8519 --
8520 end create_BNR_rows;
8521
8522
8523 --
8524 ---------------------------------------------------------------
8525 ----------------------< create_RCL_rows >-----------------------
8526 ---------------------------------------------------------------
8527 --
8528 procedure create_RCL_rows
8529 (
8530 p_validate in number default 0
8531 ,p_copy_entity_txn_id in number
8532 ,p_effective_date in date
8533 ,p_prefix_suffix_text in varchar2 default null
8534 ,p_reuse_object_flag in varchar2 default null
8535 ,p_target_business_group_id in varchar2 default null
8536 ,p_prefix_suffix_cd in varchar2 default null
8537 ) is
8538 --
8539 cursor c_unique_RCL(l_table_alias varchar2) is
8540 select distinct cpe.information1,
8541 cpe.information2,
8542 cpe.information3,
8543 cpe.INFORMATION218 name,
8544 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
8545 from ben_copy_entity_results cpe,
8546 pqh_table_route tr
8547 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8548 and cpe.table_route_id = tr.table_route_id
8549 -- and tr.where_clause = l_BEN_RLTD_PER_CHG_CS_LER_F
8550 and tr.table_alias = l_table_alias
8551 and cpe.number_of_copies = 1 --ADDITION
8552 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION218, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
8553 order by information1, information2; --added for bug: 5151945
8554 --
8555 --
8556 cursor c_RCL_min_max_dates(c_table_route_id number,
8557 c_information1 number) is
8558 select
8559 min(cpe.information2) min_esd,
8560 max(cpe.information3) min_eed
8561 from ben_copy_entity_results cpe
8562 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8563 and cpe.table_route_id = c_table_route_id
8564 and cpe.information1 = c_information1 ;
8565 --
8566 cursor c_RCL(c_table_route_id number,
8567 c_information1 number,
8568 c_information2 date,
8569 c_information3 date ) is
8570 select
8571 cpe.*
8572 from ben_copy_entity_results cpe
8573 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
8574 and cpe.table_route_id = c_table_route_id
8575 and cpe.information1 = c_information1
8576 and cpe.information2 = c_information2
8577 and cpe.information3 = c_information3
8578 and rownum = 1 ;
8579 -- Date Track target record
8580 cursor c_find_RCL_in_target( c_RCL_name varchar2,
8581 c_effective_start_date date,
8582 c_effective_end_date date,
8583 c_business_group_id number,
8584 c_new_pk_id number) is
8585 select
8586 RCL.rltd_per_chg_cs_ler_id new_value
8587 from BEN_RLTD_PER_CHG_CS_LER_F RCL
8588 where RCL.name = c_RCL_name
8589 and RCL.business_group_id = c_business_group_id
8590 and RCL.rltd_per_chg_cs_ler_id <> c_new_pk_id
8591 --TEMPIK
8592 and c_effective_start_date between effective_start_date
8593 and effective_end_date ;
8594 --END TEMPIK
8595 /*TEMPIK
8596 and exists ( select null
8597 from BEN_RLTD_PER_CHG_CS_LER_F RCL1
8598 where RCL1.name = c_RCL_name
8599 and RCL1.business_group_id = c_business_group_id
8600 and RCL1.effective_start_date <= c_effective_start_date )
8601 and exists ( select null
8602 from BEN_RLTD_PER_CHG_CS_LER_F RCL2
8603 where RCL2.name = c_RCL_name
8604 and RCL2.business_group_id = c_business_group_id
8605 and RCL2.effective_end_date >= c_effective_end_date )
8606 ;
8607 TEMPIK */
8608 --TEMPIK
8609 l_dt_rec_found boolean ;
8610 --END TEMPIK
8611 --
8612 l_current_pk_id number := null ;
8613 --UPD START
8614 --
8615 l_update boolean := false ;
8616 l_datetrack_mode varchar2(80) := hr_api.g_update;
8617 l_process_date date;
8618 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
8619 --
8620 --UPD END
8621 l_prev_pk_id number := null ;
8622 l_first_rec boolean := true ;
8623 r_RCL c_RCL%rowtype;
8624 l_rltd_per_chg_cs_ler_id number ;
8625 l_object_version_number number ;
8626 l_effective_start_date date ;
8627 l_effective_end_date date ;
8628 l_prefix pqh_copy_entity_attribs.information1%type := null;
8629 l_suffix pqh_copy_entity_attribs.information1%type := null;
8630 l_new_value number(15);
8631 l_object_found_in_target boolean := false ;
8632 l_min_esd date;
8633 l_max_eed date;
8634 l_RLTD_PER_CHG_CS_LER_RL number;
8635 l_effective_date date;
8636 --
8637 begin
8638 -- Initialization
8639 l_object_found_in_target := false ;
8640 -- End Initialization
8641 -- Derive the prefix - sufix
8642 if p_prefix_suffix_cd = 'PREFIX' then
8643 l_prefix := p_prefix_suffix_text ;
8644 elsif p_prefix_suffix_cd = 'SUFFIX' then
8645 l_suffix := p_prefix_suffix_text ;
8646 else
8647 l_prefix := null ;
8648 l_suffix := null ;
8649 end if ;
8650 -- End Prefix Sufix derivation
8651 for r_RCL_unique in c_unique_RCL('RCL') loop
8652
8653 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
8654 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8655 r_RCL_unique.information3 >=
8656 ben_pd_copy_to_ben_one.g_copy_effective_date)
8657 ) then
8658 --
8659 hr_utility.set_location(' r_RCL_unique.table_route_id '||r_RCL_unique.table_route_id,10);
8660 hr_utility.set_location(' r_RCL_unique.information1 '||r_RCL_unique.information1,10);
8661 hr_utility.set_location( 'r_RCL_unique.information2 '||r_RCL_unique.information2,10);
8662 hr_utility.set_location( 'r_RCL_unique.information3 '||r_RCL_unique.information3,10);
8663 -- If reuse objects flag is 'Y' then check for the object in the target business group
8664 -- if found insert the record into PLSql table and exit the loop else try create the
8665 -- object in the target business group
8666 --
8667 l_object_found_in_target := false ;
8668 --UPD START
8669 l_update := false;
8670 l_process_date := p_effective_date;
8671 l_dml_operation:= r_RCL_unique.dml_operation ;
8672 --
8673 if l_dml_operation = 'UPDATE' then
8674 --
8675 l_object_found_in_target := TRUE;
8676 --
8677 if l_process_date between r_RCL_unique.information2 and r_RCL_unique.information3 then
8678 l_update := true;
8679 if r_RCL_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
8680 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'RLTD_PER_CHG_CS_LER_ID' then
8681 g_pk_tbl(g_count).pk_id_column := 'RLTD_PER_CHG_CS_LER_ID' ;
8682 g_pk_tbl(g_count).old_value := r_RCL_unique.information1 ;
8683 g_pk_tbl(g_count).new_value := r_RCL_unique.information1 ;
8684 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
8685 g_pk_tbl(g_count).table_route_id := r_RCL_unique.table_route_id;
8686 --
8687 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
8688 --
8689 g_count := g_count + 1 ;
8690 --
8691 log_data('RCL',l_new_value,l_prefix || r_RCL_unique.name|| l_suffix,'REUSED');
8692 --
8693 end if ;
8694 hr_utility.set_location( 'found record for update',10);
8695 --
8696 else
8697 --
8698 l_update := false;
8699 --
8700 end if;
8701 else
8702 --
8703 --UPD END
8704 l_min_esd := null ;
8705 l_max_eed := null ;
8706 open c_RCL_min_max_dates(r_RCL_unique.table_route_id, r_RCL_unique.information1 ) ;
8707 fetch c_RCL_min_max_dates into l_min_esd,l_max_eed ;
8708
8709 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8710 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
8711 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
8712 end if;
8713 l_min_esd := greatest(l_min_esd,r_RCL_unique.information2);
8714
8715 if p_reuse_object_flag = 'Y' then
8716 if c_RCL_min_max_dates%found then
8717 -- cursor to find the object
8718 open c_find_RCL_in_target( l_prefix || r_RCL_unique.name || l_suffix ,l_min_esd,l_max_eed,
8719 p_target_business_group_id, nvl(l_rltd_per_chg_cs_ler_id, -999) ) ;
8720 fetch c_find_RCL_in_target into l_new_value ;
8721 if c_find_RCL_in_target%found then
8722 --
8723 --TEMPIK
8724 l_dt_rec_found := dt_api.check_min_max_dates
8725 (p_base_table_name => 'BEN_RLTD_PER_CHG_CS_LER_F',
8726 p_base_key_column => 'RLTD_PER_CHG_CS_LER_ID',
8727 p_base_key_value => l_new_value,
8728 p_from_date => l_min_esd,
8729 p_to_date => l_max_eed );
8730 if l_dt_rec_found THEN
8731 --END TEMPIK
8732 if r_RCL_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
8733 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'RLTD_PER_CHG_CS_LER_ID' then
8734 g_pk_tbl(g_count).pk_id_column := 'RLTD_PER_CHG_CS_LER_ID' ;
8735 g_pk_tbl(g_count).old_value := r_RCL_unique.information1 ;
8736 g_pk_tbl(g_count).new_value := l_new_value ;
8737 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
8738 g_pk_tbl(g_count).table_route_id := r_RCL_unique.table_route_id;
8739 --
8740 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
8741 --
8742 g_count := g_count + 1 ;
8743 end if ;
8744 --
8745 l_object_found_in_target := true ;
8746 --TEMPIK
8747 end if; -- l_dt_rec_found
8748 --END TEMPIK
8749 end if;
8750 close c_find_RCL_in_target ;
8751 --
8752 end if;
8753 end if ;
8754 --
8755 close c_RCL_min_max_dates ;
8756 end if;
8757 if not l_object_found_in_target or l_update then
8758 --
8759 open c_RCL(r_RCL_unique.table_route_id,
8760 r_RCL_unique.information1,
8761 r_RCL_unique.information2,
8762 r_RCL_unique.information3 ) ;
8763 --
8764 fetch c_RCL into r_RCL ;
8765 --
8766 close c_RCL ;
8767 --
8768 l_current_pk_id := r_RCL.information1;
8769 --
8770 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
8771 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
8772 --
8773 if l_current_pk_id = l_prev_pk_id then
8774 --
8775 l_first_rec := false ;
8776 --
8777 else
8778 --
8779 l_first_rec := true ;
8780 --
8781 end if ;
8782 --
8783 l_RLTD_PER_CHG_CS_LER_RL := get_fk('FORMULA_ID', r_RCL.INFORMATION260, l_dml_operation);
8784 --
8785 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_RLTD_PER_CHG_CS_LER_F',l_prefix || r_RCL.INFORMATION218 || l_suffix);
8786 --
8787
8788 l_effective_date := r_RCL.information2;
8789 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
8790 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
8791 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
8792 end if;
8793
8794 if l_first_rec and not l_update then
8795 -- Call Create routine.
8796 hr_utility.set_location(' BEN_RLTD_PER_CHG_CS_LER_F CREATE_RLTD_PER_CHG_CS_LER ',20);
8797 BEN_RLTD_PER_CHG_CS_LER_API.CREATE_RLTD_PER_CHG_CS_LER(
8798 --
8799 P_VALIDATE => false
8800 ,P_EFFECTIVE_DATE => l_effective_date
8801 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
8802 --
8803 ,P_NAME => l_prefix || r_RCL.INFORMATION218 || l_suffix
8804 ,P_NEW_VAL => r_RCL.INFORMATION186
8805 ,P_OLD_VAL => r_RCL.INFORMATION185
8806 ,P_RCL_ATTRIBUTE1 => r_RCL.INFORMATION111
8807 ,P_RCL_ATTRIBUTE10 => r_RCL.INFORMATION120
8808 ,P_RCL_ATTRIBUTE11 => r_RCL.INFORMATION121
8809 ,P_RCL_ATTRIBUTE12 => r_RCL.INFORMATION122
8810 ,P_RCL_ATTRIBUTE13 => r_RCL.INFORMATION123
8811 ,P_RCL_ATTRIBUTE14 => r_RCL.INFORMATION124
8812 ,P_RCL_ATTRIBUTE15 => r_RCL.INFORMATION125
8813 ,P_RCL_ATTRIBUTE16 => r_RCL.INFORMATION126
8814 ,P_RCL_ATTRIBUTE17 => r_RCL.INFORMATION127
8815 ,P_RCL_ATTRIBUTE18 => r_RCL.INFORMATION128
8816 ,P_RCL_ATTRIBUTE19 => r_RCL.INFORMATION129
8817 ,P_RCL_ATTRIBUTE2 => r_RCL.INFORMATION112
8818 ,P_RCL_ATTRIBUTE20 => r_RCL.INFORMATION130
8819 ,P_RCL_ATTRIBUTE21 => r_RCL.INFORMATION131
8820 ,P_RCL_ATTRIBUTE22 => r_RCL.INFORMATION132
8821 ,P_RCL_ATTRIBUTE23 => r_RCL.INFORMATION133
8822 ,P_RCL_ATTRIBUTE24 => r_RCL.INFORMATION134
8823 ,P_RCL_ATTRIBUTE25 => r_RCL.INFORMATION135
8824 ,P_RCL_ATTRIBUTE26 => r_RCL.INFORMATION136
8825 ,P_RCL_ATTRIBUTE27 => r_RCL.INFORMATION137
8826 ,P_RCL_ATTRIBUTE28 => r_RCL.INFORMATION138
8827 ,P_RCL_ATTRIBUTE29 => r_RCL.INFORMATION139
8828 ,P_RCL_ATTRIBUTE3 => r_RCL.INFORMATION113
8829 ,P_RCL_ATTRIBUTE30 => r_RCL.INFORMATION140
8830 ,P_RCL_ATTRIBUTE4 => r_RCL.INFORMATION114
8831 ,P_RCL_ATTRIBUTE5 => r_RCL.INFORMATION115
8832 ,P_RCL_ATTRIBUTE6 => r_RCL.INFORMATION116
8833 ,P_RCL_ATTRIBUTE7 => r_RCL.INFORMATION117
8834 ,P_RCL_ATTRIBUTE8 => r_RCL.INFORMATION118
8835 ,P_RCL_ATTRIBUTE9 => r_RCL.INFORMATION119
8836 ,P_RCL_ATTRIBUTE_CATEGORY => r_RCL.INFORMATION110
8837 ,P_RLTD_PER_CHG_CS_LER_ID => l_rltd_per_chg_cs_ler_id
8838 ,P_RLTD_PER_CHG_CS_LER_RL => l_RLTD_PER_CHG_CS_LER_RL
8839 ,P_SOURCE_COLUMN => r_RCL.INFORMATION141
8840 ,P_SOURCE_TABLE => r_RCL.INFORMATION142
8841 ,P_WHATIF_LBL_TXT => r_RCL.INFORMATION219
8842 --
8843 ,P_EFFECTIVE_START_DATE => l_effective_start_date
8844 ,P_EFFECTIVE_END_DATE => l_effective_end_date
8845 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8846 );
8847 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8848 -- Update all relevent cer records with new pk_id
8849 hr_utility.set_location('Before plsql table ',222);
8850 hr_utility.set_location('new_value id '||l_rltd_per_chg_cs_ler_id,222);
8851 g_pk_tbl(g_count).pk_id_column := 'RLTD_PER_CHG_CS_LER_ID' ;
8852 g_pk_tbl(g_count).old_value := r_RCL.information1 ;
8853 g_pk_tbl(g_count).new_value := l_RLTD_PER_CHG_CS_LER_ID ;
8854 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
8855 g_pk_tbl(g_count).table_route_id := r_RCL_unique.table_route_id;
8856 hr_utility.set_location('After plsql table ',222);
8857 --
8858 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
8859 --
8860 g_count := g_count + 1 ;
8861 --
8862 else
8863 --
8864 --UPD START
8865 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
8866 --
8867 if l_update then
8868 --
8869 l_datetrack_mode := r_RCL.datetrack_mode ;
8870 --
8871 get_dt_modes(
8872 p_effective_date => l_process_date,
8873 p_effective_end_date => r_RCL.information3,
8874 p_effective_start_date => r_RCL.information2,
8875 p_dml_operation => r_RCL.dml_operation,
8876 p_datetrack_mode => l_datetrack_mode );
8877 -- p_update => l_update
8878 --
8879 l_effective_date := l_process_date;
8880 l_rltd_per_chg_cs_ler_id := r_RCL.information1;
8881 l_object_version_number := r_RCL.information265;
8882 --
8883 end if;
8884 --
8885 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
8886 --
8887 IF l_update OR l_dml_operation <> 'UPDATE' THEN
8888 --UPD END
8889 -- Call Update routine for the pk_id created in prev run .
8890 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
8891 hr_utility.set_location(' BEN_RLTD_PER_CHG_CS_LER_F UPDATE_RLTD_PER_CHG_CS_LER ',30);
8892 BEN_RLTD_PER_CHG_CS_LER_API.UPDATE_RLTD_PER_CHG_CS_LER(
8893 --
8894 P_VALIDATE => false
8895 ,P_EFFECTIVE_DATE => l_effective_date
8896 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
8897 --
8898 ,P_NAME => l_prefix || r_RCL.INFORMATION218 || l_suffix
8899 ,P_NEW_VAL => r_RCL.INFORMATION186
8900 ,P_OLD_VAL => r_RCL.INFORMATION185
8901 ,P_RCL_ATTRIBUTE1 => r_RCL.INFORMATION111
8902 ,P_RCL_ATTRIBUTE10 => r_RCL.INFORMATION120
8903 ,P_RCL_ATTRIBUTE11 => r_RCL.INFORMATION121
8904 ,P_RCL_ATTRIBUTE12 => r_RCL.INFORMATION122
8905 ,P_RCL_ATTRIBUTE13 => r_RCL.INFORMATION123
8906 ,P_RCL_ATTRIBUTE14 => r_RCL.INFORMATION124
8907 ,P_RCL_ATTRIBUTE15 => r_RCL.INFORMATION125
8908 ,P_RCL_ATTRIBUTE16 => r_RCL.INFORMATION126
8909 ,P_RCL_ATTRIBUTE17 => r_RCL.INFORMATION127
8910 ,P_RCL_ATTRIBUTE18 => r_RCL.INFORMATION128
8911 ,P_RCL_ATTRIBUTE19 => r_RCL.INFORMATION129
8912 ,P_RCL_ATTRIBUTE2 => r_RCL.INFORMATION112
8913 ,P_RCL_ATTRIBUTE20 => r_RCL.INFORMATION130
8914 ,P_RCL_ATTRIBUTE21 => r_RCL.INFORMATION131
8915 ,P_RCL_ATTRIBUTE22 => r_RCL.INFORMATION132
8916 ,P_RCL_ATTRIBUTE23 => r_RCL.INFORMATION133
8917 ,P_RCL_ATTRIBUTE24 => r_RCL.INFORMATION134
8918 ,P_RCL_ATTRIBUTE25 => r_RCL.INFORMATION135
8919 ,P_RCL_ATTRIBUTE26 => r_RCL.INFORMATION136
8920 ,P_RCL_ATTRIBUTE27 => r_RCL.INFORMATION137
8921 ,P_RCL_ATTRIBUTE28 => r_RCL.INFORMATION138
8922 ,P_RCL_ATTRIBUTE29 => r_RCL.INFORMATION139
8923 ,P_RCL_ATTRIBUTE3 => r_RCL.INFORMATION113
8924 ,P_RCL_ATTRIBUTE30 => r_RCL.INFORMATION140
8925 ,P_RCL_ATTRIBUTE4 => r_RCL.INFORMATION114
8926 ,P_RCL_ATTRIBUTE5 => r_RCL.INFORMATION115
8927 ,P_RCL_ATTRIBUTE6 => r_RCL.INFORMATION116
8928 ,P_RCL_ATTRIBUTE7 => r_RCL.INFORMATION117
8929 ,P_RCL_ATTRIBUTE8 => r_RCL.INFORMATION118
8930 ,P_RCL_ATTRIBUTE9 => r_RCL.INFORMATION119
8931 ,P_RCL_ATTRIBUTE_CATEGORY => r_RCL.INFORMATION110
8932 ,P_RLTD_PER_CHG_CS_LER_ID => l_rltd_per_chg_cs_ler_id
8933 ,P_RLTD_PER_CHG_CS_LER_RL => l_RLTD_PER_CHG_CS_LER_RL
8934 ,P_SOURCE_COLUMN => r_RCL.INFORMATION141
8935 ,P_SOURCE_TABLE => r_RCL.INFORMATION142
8936 ,P_WHATIF_LBL_TXT => r_RCL.INFORMATION219
8937 --
8938 ,P_EFFECTIVE_START_DATE => l_effective_start_date
8939 ,P_EFFECTIVE_END_DATE => l_effective_end_date
8940 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
8941 ,P_DATETRACK_MODE => l_datetrack_mode
8942 );
8943 --
8944 end if;
8945 end if;
8946 --
8947 -- Delete the row if it is end dated.
8948 --
8949 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
8950 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
8951 trunc(l_max_eed) = r_RCL.information3) then
8952 --
8953 BEN_RLTD_PER_CHG_CS_LER_API.delete_RLTD_PER_CHG_CS_LER(
8954 --
8955 p_validate => false
8956 ,p_rltd_per_chg_cs_ler_id => l_rltd_per_chg_cs_ler_id
8957 ,p_effective_start_date => l_effective_start_date
8958 ,p_effective_end_date => l_effective_end_date
8959 ,p_object_version_number => l_object_version_number
8960 ,p_effective_date => l_max_eed
8961 ,p_datetrack_mode => hr_api.g_delete
8962 --
8963 );
8964 --
8965 end if;
8966 --
8967 l_prev_pk_id := l_current_pk_id ;
8968 --
8969 end if;
8970 --
8971 end if;
8972 --
8973 end loop;
8974 --
8975 exception when others then
8976 --
8977 raise_error_message( 'RCL',l_prefix || r_RCL.INFORMATION218 || l_suffix) ;
8978 --
8979 end create_RCL_rows;
8980
8981 --
8982 ---------------------------------------------------------------
8983 ----------------------< create_OPT_rows >-----------------------
8984 ---------------------------------------------------------------
8985 --
8986 procedure create_OPT_rows
8987 (
8988 p_validate in number default 0
8989 ,p_copy_entity_txn_id in number
8990 ,p_effective_date in date
8991 ,p_prefix_suffix_text in varchar2 default null
8992 ,p_reuse_object_flag in varchar2 default null
8993 ,p_target_business_group_id in varchar2 default null
8994 ,p_prefix_suffix_cd in varchar2 default null
8995 ) is
8996 --
8997 cursor c_unique_OPT(l_table_alias varchar2) is
8998 select distinct decode(cpe.information264,cpe.information1,1,2), cpe.information1,
8999 cpe.information2,
9000 cpe.information3,
9001 cpe.INFORMATION170 name,
9002 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
9003 from ben_copy_entity_results cpe,
9004 pqh_table_route tr
9005 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9006 and cpe.table_route_id = tr.table_route_id
9007 -- and tr.where_clause = l_BEN_OPT_F
9008 and tr.table_alias = l_table_alias
9009 and cpe.number_of_copies = 1 --ADDITION
9010 group by decode(cpe.information264,cpe.information1,1,2),
9011 cpe.information1,
9012 cpe.information2,
9013 cpe.information3,
9014 cpe.INFORMATION170,
9015 cpe.table_route_id,
9016 cpe.dml_operation,
9017 cpe.datetrack_mode
9018 ORDER BY 1,2,3;
9019 --
9020 --
9021 cursor c_OPT_min_max_dates(c_table_route_id number,
9022 c_information1 number) is
9023 select
9024 min(cpe.information2) min_esd,
9025 max(cpe.information3) min_eed
9026 from ben_copy_entity_results cpe
9027 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9028 and cpe.table_route_id = c_table_route_id
9029 and cpe.information1 = c_information1 ;
9030 --
9031 cursor c_OPT(c_table_route_id number,
9032 c_information1 number,
9033 c_information2 date,
9034 c_information3 date ) is
9035 select
9036 cpe.*
9037 from ben_copy_entity_results cpe
9038 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9039 and cpe.table_route_id = c_table_route_id
9040 and cpe.information1 = c_information1
9041 and cpe.information2 = c_information2
9042 and cpe.information3 = c_information3
9043 and rownum = 1 ;
9044 -- Date Track target record
9045 cursor c_find_OPT_in_target( c_OPT_name varchar2,
9046 c_effective_start_date date,
9047 c_effective_end_date date,
9048 c_business_group_id number,
9049 c_new_pk_id number) is
9050 select
9051 OPT.opt_id new_value
9052 from BEN_OPT_F OPT
9053 where OPT.name = c_OPT_name
9054 and OPT.business_group_id = c_business_group_id
9055 and OPT.opt_id <> c_new_pk_id
9056 --TEMPIK
9057 and c_effective_start_date between effective_start_date
9058 and effective_end_date ;
9059 --END TEMPIK
9060 /*TEMPIK
9061 and exists ( select null
9062 from BEN_OPT_F OPT1
9063 where OPT1.name = c_OPT_name
9064 and OPT1.business_group_id = c_business_group_id
9065 and OPT1.effective_start_date <= c_effective_start_date )
9066 and exists ( select null
9067 from BEN_OPT_F OPT2
9068 where OPT2.name = c_OPT_name
9069 and OPT2.business_group_id = c_business_group_id
9070 and OPT2.effective_end_date >= c_effective_end_date )
9071 ;
9072 TEMPIK */
9073 --TEMPIK
9074 l_dt_rec_found boolean ;
9075 --END TEMPIK
9076 --
9077 --Mapping for CWB group Option
9078 --
9079 cursor c_get_grp_opt(p_grp_opt_name in varchar2,
9080 p_effective_date in date) is
9081 select name, opt_id
9082 from ben_opt_f
9083 where name = p_grp_opt_name
9084 and p_effective_date between effective_start_date and effective_end_date;
9085
9086 l_get_grp_opt c_get_grp_opt%rowtype;
9087 l_group_opt_id number := null ;
9088 --End Mapping for CWB group Option
9089
9090 l_current_pk_id number := null ;
9091 --UPD START
9092 --
9093 l_update boolean := false ;
9094 l_datetrack_mode varchar2(80) := hr_api.g_update;
9095 l_process_date date;
9096 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
9097 --
9098 --UPD END
9099 l_prev_pk_id number := null ;
9100 l_first_rec boolean := true ;
9101 r_OPT c_OPT%rowtype;
9102 l_opt_id number ;
9103 l_object_version_number number ;
9104 l_effective_start_date date ;
9105 l_effective_end_date date ;
9106 l_prefix pqh_copy_entity_attribs.information1%type := null;
9107 l_suffix pqh_copy_entity_attribs.information1%type := null;
9108 l_new_value number(15);
9109 l_object_found_in_target boolean := false ;
9110 l_min_esd date;
9111 l_max_eed date;
9112 l_CMBN_PTIP_OPT_ID number;
9113 l_RQD_PERD_ENRT_NENRT_RL number;
9114 l_effective_date date;
9115 -- Added during PDC change
9116 l_MAPPING_TABLE_PK_ID number;
9117
9118 --
9119 begin
9120 -- Initialization
9121 l_object_found_in_target := false ;
9122 -- End Initialization
9123 -- Derive the prefix - sufix
9124 if p_prefix_suffix_cd = 'PREFIX' then
9125 l_prefix := p_prefix_suffix_text ;
9126 elsif p_prefix_suffix_cd = 'SUFFIX' then
9127 l_suffix := p_prefix_suffix_text ;
9128 else
9129 l_prefix := null ;
9130 l_suffix := null ;
9131 end if ;
9132 -- End Prefix Sufix derivation
9133 for r_OPT_unique in c_unique_OPT('OPT') loop
9134
9135 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
9136 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9137 r_OPT_unique.information3 >=
9138 ben_pd_copy_to_ben_one.g_copy_effective_date)
9139 ) then
9140 --
9141 hr_utility.set_location(' r_OPT_unique.table_route_id '||r_OPT_unique.table_route_id,10);
9142 hr_utility.set_location(' r_OPT_unique.information1 '||r_OPT_unique.information1,10);
9143 hr_utility.set_location( 'r_OPT_unique.information2 '||r_OPT_unique.information2,10);
9144 hr_utility.set_location( 'r_OPT_unique.information3 '||r_OPT_unique.information3,10);
9145 -- If reuse objects flag is 'Y' then check for the object in the target business group
9146 -- if found insert the record into PLSql table and exit the loop else try create the
9147 -- object in the target business group
9148 --
9149 l_object_found_in_target := false ;
9150 --UPD START
9151 l_update := false;
9152 l_process_date := p_effective_date;
9153 l_dml_operation:= r_OPT_unique.dml_operation ;
9154 --
9155 if l_dml_operation = 'UPDATE' then
9156 --
9157 l_object_found_in_target := TRUE;
9158 --
9159 if l_process_date between r_OPT_unique.information2 and r_OPT_unique.information3 then
9160 l_update := true;
9161 if r_OPT_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
9162 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'OPT_ID' then
9163 g_pk_tbl(g_count).pk_id_column := 'OPT_ID' ;
9164 g_pk_tbl(g_count).old_value := r_OPT_unique.information1 ;
9165 g_pk_tbl(g_count).new_value := r_OPT_unique.information1 ;
9166 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
9167 g_pk_tbl(g_count).table_route_id := r_OPT_unique.table_route_id;
9168 --
9169 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
9170 --
9171 g_count := g_count + 1 ;
9172 --
9173 log_data('OPT',l_new_value,l_prefix || r_OPT_unique.name|| l_suffix,'REUSED');
9174 --
9175 end if ;
9176 hr_utility.set_location( 'found record for update',10);
9177 --
9178 else
9179 --
9180 l_update := false;
9181 --
9182 end if;
9183 else
9184 --
9185 --UPD END
9186 l_min_esd := null ;
9187 l_max_eed := null ;
9188 open c_OPT_min_max_dates(r_OPT_unique.table_route_id, r_OPT_unique.information1 ) ;
9189 fetch c_OPT_min_max_dates into l_min_esd,l_max_eed ;
9190
9191 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9192 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
9193 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
9194 end if;
9195 l_min_esd := greatest(l_min_esd,r_OPT_unique.information2);
9196
9197 if p_reuse_object_flag = 'Y' then
9198 if c_OPT_min_max_dates%found then
9199 -- cursor to find the object
9200 open c_find_OPT_in_target( l_prefix || r_OPT_unique.name || l_suffix ,l_min_esd,l_max_eed,
9201 p_target_business_group_id, nvl(l_opt_id, -999) ) ;
9202 fetch c_find_OPT_in_target into l_new_value ;
9203 if c_find_OPT_in_target%found then
9204 --
9205 --TEMPIK
9206 l_dt_rec_found := dt_api.check_min_max_dates
9207 (p_base_table_name => 'BEN_OPT_F',
9208 p_base_key_column => 'OPT_ID',
9209 p_base_key_value => l_new_value,
9210 p_from_date => l_min_esd,
9211 p_to_date => l_max_eed );
9212 if l_dt_rec_found THEN
9213 --END TEMPIK
9214 if r_OPT_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
9215 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'OPT_ID' then
9216 g_pk_tbl(g_count).pk_id_column := 'OPT_ID' ;
9217 g_pk_tbl(g_count).old_value := r_OPT_unique.information1 ;
9218 g_pk_tbl(g_count).new_value := l_new_value ;
9219 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
9220 g_pk_tbl(g_count).table_route_id := r_OPT_unique.table_route_id;
9221 --
9222 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
9223 --
9224 g_count := g_count + 1 ;
9225 --
9226 log_data('OPT',l_new_value,l_prefix || r_OPT_unique.name|| l_suffix,'REUSED');
9227 --
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_OPT_in_target ;
9236 --
9237 end if;
9238 end if ;
9239 --
9240 close c_OPT_min_max_dates ;
9241 end if;
9242 if not l_object_found_in_target or l_update then
9243 --
9244 open c_OPT(r_OPT_unique.table_route_id,
9245 r_OPT_unique.information1,
9246 r_OPT_unique.information2,
9247 r_OPT_unique.information3 ) ;
9248 --
9249 fetch c_OPT into r_OPT ;
9250 --
9251 close c_OPT ;
9252 --
9253 l_current_pk_id := r_OPT.information1;
9254 --
9255 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
9256 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
9257 --
9258 if l_current_pk_id = l_prev_pk_id then
9259 --
9260 l_first_rec := false ;
9261 --
9262 else
9263 --
9264 l_first_rec := true ;
9265 --
9266 end if ;
9267 --Mapping for CWB group Plan
9268 -- 4665663 - Group Plans/Options neednot be mapped.
9269 if (r_OPT.INFORMATION264 IS NOT NULL and
9270 r_OPT.INFORMATION264 <> r_OPT.INFORMATION1) then
9271 --
9272 l_group_opt_id := NULL;
9273 --
9274 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
9275 l_group_opt_id := r_OPT.information176 ;
9276 end if;
9277 --
9278 if (l_group_opt_id IS NULL) then
9279 l_group_opt_id := get_fk('OPT_ID', r_OPT.INFORMATION264,l_dml_operation);
9280 end if ;
9281 end if;
9282 --
9283 /*
9284 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
9285 l_group_opt_id := r_OPT.information176 ;
9286 --
9287 else
9288 l_group_opt_id := r_OPT.information174 ;
9289 end if ;
9290
9291 if l_group_opt_id is null then
9292 --
9293 l_group_opt_id := get_fk('OPT_ID', r_OPT.INFORMATION264,l_dml_operation);
9294 --
9295 end if;
9296 */
9297 -- End Mapping for CWB group Option
9298 --
9299 l_CMBN_PTIP_OPT_ID := get_fk('CMBN_PTIP_OPT_ID', r_OPT.INFORMATION249,l_dml_operation);
9300 l_MAPPING_TABLE_PK_ID := get_fk('MAPPING_TABLE_PK_ID', r_OPT.INFORMATION257,l_dml_operation);
9301 l_RQD_PERD_ENRT_NENRT_RL := get_fk('FORMULA_ID', r_OPT.INFORMATION258,l_dml_operation);
9302 --
9303 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_OPT_F',l_prefix || r_OPT.INFORMATION170 || l_suffix);
9304 --
9305
9306 l_effective_date := r_OPT.information2;
9307 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9308 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
9309 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
9310 end if;
9311 --
9312 if l_first_rec and not l_update then
9313 -- Call Create routine.
9314 hr_utility.set_location(' BEN_OPT_F CREATE_OPTION_DEFINITION ',20);
9315 BEN_OPTION_DEFINITION_API.CREATE_OPTION_DEFINITION(
9316 --
9317 P_VALIDATE => false
9318 ,P_EFFECTIVE_DATE => l_effective_date
9319 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
9320 --
9321 ,P_CMBN_PTIP_OPT_ID => l_CMBN_PTIP_OPT_ID
9322 ,P_COMPONENT_REASON => r_OPT.INFORMATION13
9323 ,P_INVK_WV_OPT_FLAG => r_OPT.INFORMATION14
9324 ,P_MAPPING_TABLE_NAME => r_OPT.INFORMATION141
9325 ,P_MAPPING_TABLE_PK_ID => l_MAPPING_TABLE_PK_ID
9326 ,P_NAME => l_prefix || r_OPT.INFORMATION170 || l_suffix
9327 ,P_OPT_ATTRIBUTE1 => r_OPT.INFORMATION111
9328 ,P_OPT_ATTRIBUTE10 => r_OPT.INFORMATION120
9329 ,P_OPT_ATTRIBUTE11 => r_OPT.INFORMATION121
9330 ,P_OPT_ATTRIBUTE12 => r_OPT.INFORMATION122
9331 ,P_OPT_ATTRIBUTE13 => r_OPT.INFORMATION123
9332 ,P_OPT_ATTRIBUTE14 => r_OPT.INFORMATION124
9333 ,P_OPT_ATTRIBUTE15 => r_OPT.INFORMATION125
9334 ,P_OPT_ATTRIBUTE16 => r_OPT.INFORMATION126
9335 ,P_OPT_ATTRIBUTE17 => r_OPT.INFORMATION127
9336 ,P_OPT_ATTRIBUTE18 => r_OPT.INFORMATION128
9337 ,P_OPT_ATTRIBUTE19 => r_OPT.INFORMATION129
9338 ,P_OPT_ATTRIBUTE2 => r_OPT.INFORMATION112
9339 ,P_OPT_ATTRIBUTE20 => r_OPT.INFORMATION130
9340 ,P_OPT_ATTRIBUTE21 => r_OPT.INFORMATION131
9341 ,P_OPT_ATTRIBUTE22 => r_OPT.INFORMATION132
9342 ,P_OPT_ATTRIBUTE23 => r_OPT.INFORMATION133
9343 ,P_OPT_ATTRIBUTE24 => r_OPT.INFORMATION134
9344 ,P_OPT_ATTRIBUTE25 => r_OPT.INFORMATION135
9345 ,P_OPT_ATTRIBUTE26 => r_OPT.INFORMATION136
9346 ,P_OPT_ATTRIBUTE27 => r_OPT.INFORMATION137
9347 ,P_OPT_ATTRIBUTE28 => r_OPT.INFORMATION138
9348 ,P_OPT_ATTRIBUTE29 => r_OPT.INFORMATION139
9349 ,P_OPT_ATTRIBUTE3 => r_OPT.INFORMATION113
9350 ,P_OPT_ATTRIBUTE30 => r_OPT.INFORMATION140
9351 ,P_OPT_ATTRIBUTE4 => r_OPT.INFORMATION114
9352 ,P_OPT_ATTRIBUTE5 => r_OPT.INFORMATION115
9353 ,P_OPT_ATTRIBUTE6 => r_OPT.INFORMATION116
9354 ,P_OPT_ATTRIBUTE7 => r_OPT.INFORMATION117
9355 ,P_OPT_ATTRIBUTE8 => r_OPT.INFORMATION118
9356 ,P_OPT_ATTRIBUTE9 => r_OPT.INFORMATION119
9357 ,P_OPT_ATTRIBUTE_CATEGORY => r_OPT.INFORMATION110
9358 ,P_OPT_ID => l_opt_id
9359 ,P_RQD_PERD_ENRT_NENRT_RL => l_RQD_PERD_ENRT_NENRT_RL
9360 ,P_RQD_PERD_ENRT_NENRT_UOM => r_OPT.INFORMATION15
9361 ,P_RQD_PERD_ENRT_NENRT_VAL => r_OPT.INFORMATION259
9362 -- Bug 3939490
9363 ,p_legislation_code => r_opt.information16
9364 ,p_legislation_subgroup => r_opt.information17
9365 -- Bug 3939490
9366 ,P_SHORT_CODE => r_OPT.INFORMATION11
9367 ,P_SHORT_NAME => r_OPT.INFORMATION12
9368 --
9369 ,P_EFFECTIVE_START_DATE => l_effective_start_date
9370 ,P_EFFECTIVE_END_DATE => l_effective_end_date
9371 --cwbglobal cwb tilak
9372 ,P_GROUP_OPT_ID => l_group_opt_id --r_OPT.INFORMATION176
9373 --
9374 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
9375 );
9376 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
9377 -- Update all relevent cer records with new pk_id
9378 hr_utility.set_location('Before plsql table ',222);
9379 hr_utility.set_location('new_value id '||l_opt_id,222);
9380 g_pk_tbl(g_count).pk_id_column := 'OPT_ID' ;
9381 g_pk_tbl(g_count).old_value := r_OPT.information1 ;
9382 g_pk_tbl(g_count).new_value := l_OPT_ID ;
9383 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
9384 g_pk_tbl(g_count).table_route_id := r_OPT_unique.table_route_id;
9385 hr_utility.set_location('After plsql table ',222);
9386 --
9387 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
9388 --
9389 g_count := g_count + 1 ;
9390 --
9391 log_data('OPT',l_new_value,l_prefix || r_OPT.INFORMATION170 || l_suffix,'COPIED');
9392 --
9393 else
9394 --
9395 --UPD START
9396 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
9397 --
9398 if l_update then
9399 --
9400 l_datetrack_mode := r_OPT.datetrack_mode ;
9401 --
9402 get_dt_modes(
9403 p_effective_date => l_process_date,
9404 p_effective_end_date => r_OPT.information3,
9405 p_effective_start_date => r_OPT.information2,
9406 p_dml_operation => r_OPT.dml_operation,
9407 p_datetrack_mode => l_datetrack_mode );
9408 -- p_update => l_update
9409 --
9410 l_effective_date := l_process_date;
9411 l_opt_id := r_OPT.information1;
9412 l_object_version_number := r_OPT.information265;
9413 --
9414 end if;
9415 --
9416 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
9417 --
9418 IF l_update OR l_dml_operation <> 'UPDATE' THEN
9419 --UPD END
9420 -- Call Update routine for the pk_id created in prev run .
9421 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
9422 hr_utility.set_location(' BEN_OPT_F UPDATE_OPTION_DEFINITION ',30);
9423 BEN_OPTION_DEFINITION_API.UPDATE_OPTION_DEFINITION(
9424 --
9425 P_VALIDATE => false
9426 ,P_EFFECTIVE_DATE => l_effective_date
9427 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
9428 --
9429 ,P_CMBN_PTIP_OPT_ID => l_CMBN_PTIP_OPT_ID
9430 ,P_COMPONENT_REASON => r_OPT.INFORMATION13
9431 ,P_INVK_WV_OPT_FLAG => r_OPT.INFORMATION14
9432 ,P_MAPPING_TABLE_NAME => r_OPT.INFORMATION141
9433 ,P_MAPPING_TABLE_PK_ID => l_MAPPING_TABLE_PK_ID
9434 ,P_NAME => l_prefix || r_OPT.INFORMATION170 || l_suffix
9435 ,P_OPT_ATTRIBUTE1 => r_OPT.INFORMATION111
9436 ,P_OPT_ATTRIBUTE10 => r_OPT.INFORMATION120
9437 ,P_OPT_ATTRIBUTE11 => r_OPT.INFORMATION121
9438 ,P_OPT_ATTRIBUTE12 => r_OPT.INFORMATION122
9439 ,P_OPT_ATTRIBUTE13 => r_OPT.INFORMATION123
9440 ,P_OPT_ATTRIBUTE14 => r_OPT.INFORMATION124
9441 ,P_OPT_ATTRIBUTE15 => r_OPT.INFORMATION125
9442 ,P_OPT_ATTRIBUTE16 => r_OPT.INFORMATION126
9443 ,P_OPT_ATTRIBUTE17 => r_OPT.INFORMATION127
9444 ,P_OPT_ATTRIBUTE18 => r_OPT.INFORMATION128
9445 ,P_OPT_ATTRIBUTE19 => r_OPT.INFORMATION129
9446 ,P_OPT_ATTRIBUTE2 => r_OPT.INFORMATION112
9447 ,P_OPT_ATTRIBUTE20 => r_OPT.INFORMATION130
9448 ,P_OPT_ATTRIBUTE21 => r_OPT.INFORMATION131
9449 ,P_OPT_ATTRIBUTE22 => r_OPT.INFORMATION132
9450 ,P_OPT_ATTRIBUTE23 => r_OPT.INFORMATION133
9451 ,P_OPT_ATTRIBUTE24 => r_OPT.INFORMATION134
9452 ,P_OPT_ATTRIBUTE25 => r_OPT.INFORMATION135
9453 ,P_OPT_ATTRIBUTE26 => r_OPT.INFORMATION136
9454 ,P_OPT_ATTRIBUTE27 => r_OPT.INFORMATION137
9455 ,P_OPT_ATTRIBUTE28 => r_OPT.INFORMATION138
9456 ,P_OPT_ATTRIBUTE29 => r_OPT.INFORMATION139
9457 ,P_OPT_ATTRIBUTE3 => r_OPT.INFORMATION113
9458 ,P_OPT_ATTRIBUTE30 => r_OPT.INFORMATION140
9459 ,P_OPT_ATTRIBUTE4 => r_OPT.INFORMATION114
9460 ,P_OPT_ATTRIBUTE5 => r_OPT.INFORMATION115
9461 ,P_OPT_ATTRIBUTE6 => r_OPT.INFORMATION116
9462 ,P_OPT_ATTRIBUTE7 => r_OPT.INFORMATION117
9463 ,P_OPT_ATTRIBUTE8 => r_OPT.INFORMATION118
9464 ,P_OPT_ATTRIBUTE9 => r_OPT.INFORMATION119
9465 ,P_OPT_ATTRIBUTE_CATEGORY => r_OPT.INFORMATION110
9466 ,P_OPT_ID => l_opt_id
9467 ,P_RQD_PERD_ENRT_NENRT_RL => l_RQD_PERD_ENRT_NENRT_RL
9468 ,P_RQD_PERD_ENRT_NENRT_UOM => r_OPT.INFORMATION15
9469 ,P_RQD_PERD_ENRT_NENRT_VAL => r_OPT.INFORMATION259
9470 -- Bug 3939490
9471 ,p_legislation_code => r_opt.information16
9472 ,p_legislation_subgroup => r_opt.information17
9473 -- Bug 3939490
9474 ,P_SHORT_CODE => r_OPT.INFORMATION11
9475 ,P_SHORT_NAME => r_OPT.INFORMATION12
9476 --
9477 ,P_EFFECTIVE_START_DATE => l_effective_start_date
9478 ,P_EFFECTIVE_END_DATE => l_effective_end_date
9479 --cwbglobal -- cwb tilak
9480 ,P_GROUP_OPT_ID => r_OPT.INFORMATION264
9481 --
9482 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
9483 ,P_DATETRACK_MODE => l_datetrack_mode
9484 );
9485 --
9486 end if;
9487 end if;
9488 --
9489 -- Delete the row if it is end dated.
9490 --
9491 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
9492 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
9493 trunc(l_max_eed) = r_OPT.information3) then
9494 --
9495 BEN_OPTION_DEFINITION_API.delete_OPTION_DEFINITION(
9496 --
9497 p_validate => false
9498 ,p_opt_id => l_opt_id
9499 ,p_effective_start_date => l_effective_start_date
9500 ,p_effective_end_date => l_effective_end_date
9501 ,p_object_version_number => l_object_version_number
9502 ,p_effective_date => l_max_eed
9503 ,p_datetrack_mode => hr_api.g_delete
9504 --
9505 );
9506 --
9507 end if;
9508 --
9509 l_prev_pk_id := l_current_pk_id ;
9510 --
9511 end if;
9512 --
9513 end if;
9514 --
9515 end loop;
9516 --
9517 exception when others then
9518 --
9519 raise_error_message( 'OPT',l_prefix || r_OPT.INFORMATION170 || l_suffix) ;
9520 --
9521 end create_OPT_rows;
9522
9523 --
9524 ---------------------------------------------------------------
9525 ----------------------< create_LER_rows >-----------------------
9526 ---------------------------------------------------------------
9527 --
9528 procedure create_LER_rows
9529 (
9530 p_validate in number default 0
9531 ,p_copy_entity_txn_id in number
9532 ,p_effective_date in date
9533 ,p_prefix_suffix_text in varchar2 default null
9534 ,p_reuse_object_flag in varchar2 default null
9535 ,p_target_business_group_id in varchar2 default null
9536 ,p_prefix_suffix_cd in varchar2 default null
9537 ) is
9538 --
9539 cursor c_unique_LER(l_table_alias varchar2) is
9540 select distinct cpe.information1,
9541 cpe.information2,
9542 cpe.information3,
9543 cpe.INFORMATION170 name,
9544 cpe.information16 typ_cd, -- Required for Absences
9545 cpe.information13 lf_evt_oper_cd, -- Required for Absences
9546 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
9547 from ben_copy_entity_results cpe,
9548 pqh_table_route tr
9549 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9550 and cpe.table_route_id = tr.table_route_id
9551 -- and tr.where_clause = l_BEN_LER_F
9552 and tr.table_alias = l_table_alias
9553 and cpe.number_of_copies = 1 --ADDITION
9554 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170,
9555 cpe.information16, cpe.information13,cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
9556 order by information1, information2; --added for bug: 5151945
9557 --
9558 --
9559 cursor c_LER_min_max_dates(c_table_route_id number,
9560 c_information1 number) is
9561 select
9562 min(cpe.information2) min_esd,
9563 max(cpe.information3) min_eed
9564 from ben_copy_entity_results cpe
9565 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9566 and cpe.table_route_id = c_table_route_id
9567 and cpe.information1 = c_information1 ;
9568 --
9569 cursor c_LER(c_table_route_id number,
9570 c_information1 number,
9571 c_information2 date,
9572 c_information3 date ) is
9573 select
9574 cpe.*
9575 from ben_copy_entity_results cpe
9576 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
9577 and cpe.table_route_id = c_table_route_id
9578 and cpe.information1 = c_information1
9579 and cpe.information2 = c_information2
9580 and cpe.information3 = c_information3
9581 and rownum = 1 ;
9582 -- Date Track target record
9583 cursor c_find_LER_in_target( c_LER_name varchar2,
9584 c_effective_start_date date,
9585 c_effective_end_date date,
9586 c_business_group_id number,
9587 c_new_pk_id number) is
9588 select
9589 LER.ler_id new_value
9590 from BEN_LER_F LER
9591 where LER.name = c_LER_name
9592 and LER.business_group_id = c_business_group_id
9593 and LER.ler_id <> c_new_pk_id
9594 --TEMPIK
9595 and c_effective_start_date between effective_start_date
9596 and effective_end_date ;
9597 --END TEMPIK
9598 /*TEMPIK
9599 and exists ( select null
9600 from BEN_LER_F LER1
9601 where LER1.name = c_LER_name
9602 and LER1.business_group_id = c_business_group_id
9603 and LER1.effective_start_date <= c_effective_start_date )
9604 and exists ( select null
9605 from BEN_LER_F LER2
9606 where LER2.name = c_LER_name
9607 and LER2.business_group_id = c_business_group_id
9608 and LER2.effective_end_date >= c_effective_end_date )
9609 ;
9610 TEMPIK */
9611 --TEMPIK
9612 l_dt_rec_found boolean := false ;
9613 --END TEMPIK
9614
9615 cursor c_find_LER_TYP_in_target( c_LER_TYP_cd varchar2,
9616 c_LF_EVT_OPER_cd varchar2,
9617 c_effective_start_date date,
9618 c_effective_end_date date,
9619 c_business_group_id number,
9620 c_new_pk_id number) is
9621 select
9622 LER.ler_id new_value
9623 from BEN_LER_F LER
9624 where LER.typ_cd = c_LER_TYP_cd
9625 -- 3508427: Including LE's of type Derived and Scheduled along with Abscences.
9626 -- and LER.lf_evt_oper_cd = c_LF_EVT_OPER_cd
9627 and ((LER.typ_cd = 'ABS' and LER.lf_evt_oper_cd = c_LF_EVT_OPER_cd )
9628 or ( LER.typ_cd in ('DRVDAGE', 'DRVDLOS', 'DRVDCAL',
9629 'DRVDHRW', 'DRVDCMP', 'DRVDTPF', 'SCHEDDO','SCHEDDA','SCHEDDU',
9630 'QMSCOCO', 'QDROCOU', 'QUAINGR', 'GSP','IREC') )
9631 )
9632 -- 3508427 Ends ---------
9633 and LER.business_group_id = c_business_group_id
9634 and LER.ler_id <> c_new_pk_id
9635 --TEMPIK
9636 and c_effective_start_date between effective_start_date
9637 and effective_end_date ;
9638 --END TEMPIK
9639 /*TEMPIK
9640 and exists ( select null
9641 from BEN_LER_F LER1
9642 where LER1.typ_cd = c_LER_TYP_cd
9643 and LER1.lf_evt_oper_cd = c_LF_EVT_OPER_cd
9644 and LER1.ler_id = LER.ler_id
9645 and LER1.business_group_id = c_business_group_id
9646 and LER1.effective_start_date <= c_effective_start_date )
9647 and exists ( select null
9648 from BEN_LER_F LER2
9649 where LER2.typ_cd = c_LER_TYP_cd
9650 and LER2.lf_evt_oper_cd = c_LF_EVT_OPER_cd
9651 and LER2.ler_id = LER.ler_id
9652 and LER2.business_group_id = c_business_group_id
9653 and LER2.effective_end_date >= c_effective_end_date )
9654 ;
9655 TEMPIK */
9656
9657 cursor c_lf_evt_oper_cd_exists( c_LER_TYP_cd varchar2,
9658 c_LF_EVT_OPER_cd varchar2,
9659 c_effective_start_date date,
9660 c_effective_end_date date,
9661 c_business_group_id number,
9662 c_new_pk_id number) is
9663 select
9664 LER.name
9665 from BEN_LER_F LER
9666 where LER.typ_cd = c_LER_TYP_cd
9667 and LER.lf_evt_oper_cd = c_LF_EVT_OPER_cd
9668 and LER.business_group_id = c_business_group_id
9669 and LER.ler_id <> c_new_pk_id
9670 and ((LER.effective_start_date between c_effective_start_date
9671 and c_effective_end_date)
9672 or
9673 (LER.effective_end_date between c_effective_start_date
9674 and c_effective_end_date))
9675 ;
9676 --
9677 l_current_pk_id number := null ;
9678 --UPD START
9679 --
9680 l_update boolean := false ;
9681 l_datetrack_mode varchar2(80) := hr_api.g_update;
9682 l_process_date date;
9683 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
9684 --
9685 --UPD END
9686 l_prev_pk_id number := null ;
9687 l_first_rec boolean := true ;
9688 r_LER c_LER%rowtype;
9689 l_ler_id number ;
9690 l_object_version_number number ;
9691 l_effective_start_date date ;
9692 l_effective_end_date date ;
9693 l_prefix pqh_copy_entity_attribs.information1%type := null;
9694 l_suffix pqh_copy_entity_attribs.information1%type := null;
9695 l_new_value number(15);
9696 l_object_found_in_target boolean := false ;
9697 l_min_esd date;
9698 l_max_eed date;
9699 l_LER_EVAL_RL number;
9700 l_TMLNS_PERD_RL number;
9701 l_target_ler_name ben_ler_f.name%type;
9702 l_source_ler_name ben_ler_f.name%type;
9703 l_effective_date date;
9704 --
9705 begin
9706 -- Initialization
9707 l_object_found_in_target := false ;
9708 l_source_ler_name := null;
9709 -- End Initialization
9710 -- Derive the prefix - sufix
9711 if p_prefix_suffix_cd = 'PREFIX' then
9712 l_prefix := p_prefix_suffix_text ;
9713 elsif p_prefix_suffix_cd = 'SUFFIX' then
9714 l_suffix := p_prefix_suffix_text ;
9715 else
9716 l_prefix := null ;
9717 l_suffix := null ;
9718 end if ;
9719 hr_utility.set_location('prefix '||l_prefix,100);
9720 hr_utility.set_location('suffix '||l_suffix,101);
9721 -- End Prefix Sufix derivation
9722 for r_LER_unique in c_unique_LER('LER') loop
9723
9724 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
9725 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9726 r_LER_unique.information3 >=
9727 ben_pd_copy_to_ben_one.g_copy_effective_date)
9728 ) then
9729
9730 l_source_ler_name := l_prefix || r_LER_unique.name || l_suffix; -- For display in error messages
9731 --
9732 hr_utility.set_location(' r_LER_unique.table_route_id '||r_LER_unique.table_route_id,10);
9733 hr_utility.set_location(' r_LER_unique.information1 '||r_LER_unique.information1,10);
9734 hr_utility.set_location( 'r_LER_unique.information2 '||r_LER_unique.information2,10);
9735 hr_utility.set_location( 'r_LER_unique.information3 '||r_LER_unique.information3,10);
9736 -- If reuse objects flag is 'Y' then check for the object in the target business group
9737 -- if found insert the record into PLSql table and exit the loop else try create the
9738 -- object in the target business group
9739 --
9740 l_object_found_in_target := false ;
9741 --UPD START
9742 l_update := false;
9743 l_process_date := p_effective_date;
9744 l_dml_operation:= r_LER_unique.dml_operation ;
9745 --
9746 if l_dml_operation = 'UPDATE' then
9747 --
9748 l_object_found_in_target := TRUE;
9749 --
9750 if l_process_date between r_LER_unique.information2 and r_LER_unique.information3 then
9751 l_update := true;
9752 if r_LER_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
9753 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'LER_ID' then
9754 g_pk_tbl(g_count).pk_id_column := 'LER_ID' ;
9755 g_pk_tbl(g_count).old_value := r_LER_unique.information1 ;
9756 g_pk_tbl(g_count).new_value := r_LER_unique.information1 ;
9757 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
9758 g_pk_tbl(g_count).table_route_id := r_LER_unique.table_route_id;
9759 --
9760 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
9761 --
9762 g_count := g_count + 1 ;
9763 --
9764 log_data('LER',l_new_value,l_prefix || r_LER_unique.name|| l_suffix,'REUSED');
9765 --
9766 end if ;
9767 hr_utility.set_location( 'found record for update',10);
9768 --
9769 else
9770 --
9771 l_update := false;
9772 --
9773 end if;
9774 else
9775 --
9776 --UPD END
9777 l_min_esd := null ;
9778 l_max_eed := null ;
9779 open c_LER_min_max_dates(r_LER_unique.table_route_id, r_LER_unique.information1 ) ;
9780 fetch c_LER_min_max_dates into l_min_esd,l_max_eed ;
9781
9782 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9783 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
9784 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
9785 end if;
9786 l_min_esd := greatest(l_min_esd,r_LER_unique.information2);
9787
9788 --
9789 -- Ler's shopuld always be checked whether they exists or not.
9790 --
9791 -- if p_reuse_object_flag = 'Y' then
9792 if c_LER_min_max_dates%found then
9793 -- cursor to find the object
9794 -- Always check with original name.
9795 --
9796 l_new_value := null;
9797 open c_find_LER_in_target( l_prefix || r_LER_unique.name || l_suffix ,l_min_esd,l_max_eed,
9798 p_target_business_group_id, nvl(l_ler_id, -999) ) ;
9799 fetch c_find_LER_in_target into l_new_value ;
9800 --TEMPIK
9801 hr_utility.set_location('New value '||l_new_value,102);
9802 if l_new_value is not null then
9803 l_dt_rec_found := dt_api.check_min_max_dates
9804 (p_base_table_name => 'BEN_LER_F',
9805 p_base_key_column => 'LER_ID',
9806 p_base_key_value => l_new_value,
9807 p_from_date => l_min_esd,
9808 p_to_date => l_max_eed );
9809 end if;
9810 --END TEMPIK
9811 close c_find_LER_in_target ;
9812 --bug#3120115 - for compensation always new life event is created
9813 --with suffix/prefix
9814 if not l_dt_rec_found and r_LER_unique.typ_cd <> 'COMP'
9815 then -- c_find_LER_in_target%found then
9816 --
9817 open c_find_LER_in_target( r_LER_unique.name ,l_min_esd,l_max_eed,
9818 p_target_business_group_id, nvl(l_ler_id, -999) ) ;
9819 fetch c_find_LER_in_target into l_new_value ;
9820 --TEMPIK
9821 if l_new_value is not null then
9822 l_dt_rec_found := dt_api.check_min_max_dates
9823 (p_base_table_name => 'BEN_LER_F',
9824 p_base_key_column => 'LER_ID',
9825 p_base_key_value => l_new_value,
9826 p_from_date => l_min_esd,
9827 p_to_date => l_max_eed );
9828 end if;
9829 --END TEMPIK
9830 close c_find_LER_in_target ;
9831 end if;
9832
9833 -- For Absence Type Lers, check if any Ler with the same Life Event Operation Code exists
9834 -- If any Ler with the same Life Event Operation Code found, reuse that, else create
9835 -- If the LER_TYPE_CD is DERIVED OR SCHEDULED, always reuse if LER exists.
9836 if ( l_new_value is null or (not l_dt_rec_found ))
9837 and r_LER_unique.typ_cd in -- 3508427. Included Derived and Scheduled LE's along with Absences.
9838 ('ABS', 'DRVDAGE', 'DRVDLOS', 'DRVDCAL',
9839 'DRVDHRW', 'DRVDCMP', 'DRVDTPF', 'SCHEDDO','SCHEDDA',
9840 'SCHEDDU', 'QMSCOCO', 'QDROCOU', 'QUAINGR', 'GSP','IREC') -- 3508427 Ends --
9841 then
9842 --
9843 open c_find_LER_TYP_in_target( r_LER_unique.typ_cd,r_LER_unique.lf_evt_oper_cd,l_min_esd,l_max_eed,
9844 p_target_business_group_id, nvl(l_ler_id, -999)) ;
9845 fetch c_find_LER_TYP_in_target into l_new_value ;
9846 --TEMPIK
9847 if l_new_value is not null then
9848 l_dt_rec_found := dt_api.check_min_max_dates
9849 (p_base_table_name => 'BEN_LER_F',
9850 p_base_key_column => 'LER_ID',
9851 p_base_key_value => l_new_value,
9852 p_from_date => l_min_esd,
9853 p_to_date => l_max_eed );
9854 end if;
9855 --END TEMPIK
9856 close c_find_LER_TYP_in_target ;
9857
9858 -- Bug 2851090 If any Ler with the same Life Event Operation Code exists, but cannot be reused
9859 -- because of the effective start and end dates being different, then throw error
9860 -- 3508427: Added 'type_cd = ABS' in the below if-condition to restrict Derived and Scheduled LE's.
9861
9862 if ((l_new_value is null or (not l_dt_rec_found )) AND r_LER_unique.typ_cd = 'ABS') then
9863 open c_lf_evt_oper_cd_exists( r_LER_unique.typ_cd,r_LER_unique.lf_evt_oper_cd,l_min_esd,l_max_eed,
9864 p_target_business_group_id, nvl(l_ler_id, -999)) ;
9865 fetch c_lf_evt_oper_cd_exists into l_target_ler_name;
9866 if c_lf_evt_oper_cd_exists%found then
9867 close c_lf_evt_oper_cd_exists;
9868 fnd_message.set_name('BEN','BEN_93364_PDC_DUP_LE_OPER_CD');
9869 fnd_message.set_token('NAME',l_target_ler_name);
9870 fnd_message.set_token('OPER_CD',hr_general.decode_lookup('BEN_LF_EVT_OPER',r_LER_unique.lf_evt_oper_cd));
9871 fnd_message.raise_error;
9872 end if;
9873 close c_lf_evt_oper_cd_exists ;
9874 end if;
9875 end if;
9876
9877 if l_new_value is not null then -- c_find_LER_in_target%found then
9878 if l_dt_rec_found THEN
9879 if r_LER_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
9880 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'LER_ID' then
9881 --
9882 g_pk_tbl(g_count).pk_id_column := 'LER_ID' ;
9883 g_pk_tbl(g_count).old_value := r_LER_unique.information1 ;
9884 g_pk_tbl(g_count).new_value := l_new_value ;
9885 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
9886 g_pk_tbl(g_count).table_route_id := r_LER_unique.table_route_id;
9887 --
9888 hr_utility.set_location(' g_count '||g_count,12);
9889 hr_utility.set_location(' pk_id_column '||g_pk_tbl(g_count).pk_id_column,12);
9890 hr_utility.set_location(' old_value '||g_pk_tbl(g_count).old_value,12);
9891 hr_utility.set_location(' new_value '||g_pk_tbl(g_count).new_value,12);
9892 hr_utility.set_location(' copy_reuse_type '||g_pk_tbl(g_count).copy_reuse_type,12);
9893 hr_utility.set_location(' table_route_id '||g_pk_tbl(g_count).table_route_id,12);
9894 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
9895 --
9896 g_count := g_count + 1 ;
9897 --
9898 log_data('LER',l_new_value,r_LER_unique.name,'REUSED');
9899 --
9900 end if ;
9901 --
9902 l_object_found_in_target := true ;
9903 end if;
9904 --
9905 end if;
9906 --
9907 end if;
9908 -- end if ;
9909 --
9910 close c_LER_min_max_dates ;
9911 end if;
9912 if not l_object_found_in_target or l_update then
9913 --
9914 open c_LER(r_LER_unique.table_route_id,
9915 r_LER_unique.information1,
9916 r_LER_unique.information2,
9917 r_LER_unique.information3 ) ;
9918 --
9919 fetch c_LER into r_LER ;
9920 --
9921 close c_LER ;
9922 --
9923 l_current_pk_id := r_LER.information1;
9924 --
9925 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
9926 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
9927 --
9928 if l_current_pk_id = l_prev_pk_id then
9929 --
9930 l_first_rec := false ;
9931 --
9932 else
9933 --
9934 l_first_rec := true ;
9935 --
9936 end if ;
9937 --
9938
9939 l_LER_EVAL_RL := get_fk('FORMULA_ID', r_LER.INFORMATION261,l_dml_operation );
9940 l_TMLNS_PERD_RL := get_fk('FORMULA_ID', r_LER.INFORMATION262,l_dml_operation );
9941 --
9942 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_LER_F',l_prefix || r_LER.information170 || l_suffix);
9943 --
9944
9945 l_effective_date := r_LER.information2;
9946 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
9947 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
9948 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
9949 end if;
9950
9951 if l_first_rec and not l_update then
9952 -- Call Create routine.
9953 hr_utility.set_location(' BEN_LER_F CREATE_LIFE_EVENT_REASON ',20);
9954 BEN_LIFE_EVENT_REASON_API.CREATE_LIFE_EVENT_REASON(
9955 --
9956 P_VALIDATE => false
9957 ,P_EFFECTIVE_DATE => l_effective_date
9958 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
9959 --
9960 ,P_CK_RLTD_PER_ELIG_FLAG => r_LER.INFORMATION22
9961 ,P_CM_APLY_FLAG => r_LER.INFORMATION23
9962 ,P_DESC_TXT => r_LER.INFORMATION219
9963 ,P_LER_ATTRIBUTE1 => r_LER.INFORMATION111
9964 ,P_LER_ATTRIBUTE10 => r_LER.INFORMATION120
9965 ,P_LER_ATTRIBUTE11 => r_LER.INFORMATION121
9966 ,P_LER_ATTRIBUTE12 => r_LER.INFORMATION122
9967 ,P_LER_ATTRIBUTE13 => r_LER.INFORMATION123
9968 ,P_LER_ATTRIBUTE14 => r_LER.INFORMATION124
9969 ,P_LER_ATTRIBUTE15 => r_LER.INFORMATION125
9970 ,P_LER_ATTRIBUTE16 => r_LER.INFORMATION126
9971 ,P_LER_ATTRIBUTE17 => r_LER.INFORMATION127
9972 ,P_LER_ATTRIBUTE18 => r_LER.INFORMATION128
9973 ,P_LER_ATTRIBUTE19 => r_LER.INFORMATION129
9974 ,P_LER_ATTRIBUTE2 => r_LER.INFORMATION112
9975 ,P_LER_ATTRIBUTE20 => r_LER.INFORMATION130
9976 ,P_LER_ATTRIBUTE21 => r_LER.INFORMATION131
9977 ,P_LER_ATTRIBUTE22 => r_LER.INFORMATION132
9978 ,P_LER_ATTRIBUTE23 => r_LER.INFORMATION133
9979 ,P_LER_ATTRIBUTE24 => r_LER.INFORMATION134
9980 ,P_LER_ATTRIBUTE25 => r_LER.INFORMATION135
9981 ,P_LER_ATTRIBUTE26 => r_LER.INFORMATION136
9982 ,P_LER_ATTRIBUTE27 => r_LER.INFORMATION137
9983 ,P_LER_ATTRIBUTE28 => r_LER.INFORMATION138
9984 ,P_LER_ATTRIBUTE29 => r_LER.INFORMATION139
9985 ,P_LER_ATTRIBUTE3 => r_LER.INFORMATION113
9986 ,P_LER_ATTRIBUTE30 => r_LER.INFORMATION140
9987 ,P_LER_ATTRIBUTE4 => r_LER.INFORMATION114
9988 ,P_LER_ATTRIBUTE5 => r_LER.INFORMATION115
9989 ,P_LER_ATTRIBUTE6 => r_LER.INFORMATION116
9990 ,P_LER_ATTRIBUTE7 => r_LER.INFORMATION117
9991 ,P_LER_ATTRIBUTE8 => r_LER.INFORMATION118
9992 ,P_LER_ATTRIBUTE9 => r_LER.INFORMATION119
9993 ,P_LER_ATTRIBUTE_CATEGORY => r_LER.INFORMATION110
9994 ,P_LER_EVAL_RL => l_LER_EVAL_RL
9995 ,P_LER_ID => l_ler_id
9996 ,P_LER_STAT_CD => r_LER.INFORMATION15
9997 ,P_LF_EVT_OPER_CD => r_LER.INFORMATION13
9998 ,P_NAME => l_prefix || r_LER.INFORMATION170 || l_suffix
9999 ,P_OCRD_DT_DET_CD => r_LER.INFORMATION21
10000 ,P_OVRIDG_LE_FLAG => r_LER.INFORMATION24
10001 ,P_PTNL_LER_TRTMT_CD => r_LER.INFORMATION17
10002 ,P_QUALG_EVT_FLAG => r_LER.INFORMATION25
10003 ,P_SS_PCP_DISP_CD => r_LER.INFORMATION26 --4301332
10004 ,P_SHORT_CODE => r_LER.INFORMATION11
10005 ,P_SHORT_NAME => r_LER.INFORMATION12
10006 ,P_SLCTBL_SLF_SVC_CD => r_LER.INFORMATION14
10007 ,P_TMLNS_DYS_NUM => r_LER.INFORMATION263
10008 ,P_TMLNS_EVAL_CD => r_LER.INFORMATION20
10009 ,P_TMLNS_PERD_CD => r_LER.INFORMATION19
10010 ,P_TMLNS_PERD_RL => l_TMLNS_PERD_RL
10011 ,P_TYP_CD => r_LER.INFORMATION16
10012 ,P_WHN_TO_PRCS_CD => r_LER.INFORMATION18
10013 --
10014 ,P_EFFECTIVE_START_DATE => l_effective_start_date
10015 ,P_EFFECTIVE_END_DATE => l_effective_end_date
10016 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
10017 );
10018 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
10019 -- Update all relevent cer records with new pk_id
10020 hr_utility.set_location('Before plsql table ',222);
10021 hr_utility.set_location('new_value id '||l_ler_id,222);
10022 g_pk_tbl(g_count).pk_id_column := 'LER_ID' ;
10023 g_pk_tbl(g_count).old_value := r_LER.information1 ;
10024 g_pk_tbl(g_count).new_value := l_LER_ID ;
10025 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
10026 g_pk_tbl(g_count).table_route_id := r_LER_unique.table_route_id;
10027 hr_utility.set_location('After plsql table ',222);
10028 --
10029 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
10030 --
10031 g_count := g_count + 1 ;
10032 --
10033 log_data('LER',l_new_value,l_prefix || r_LER.INFORMATION170 || l_suffix,'COPIED');
10034 --
10035 else
10036 --
10037 --UPD START
10038 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
10039 --
10040 if l_update then
10041 --
10042 l_datetrack_mode := r_LER.datetrack_mode ;
10043 --
10044 get_dt_modes(
10045 p_effective_date => l_process_date,
10046 p_effective_end_date => r_LER.information3,
10047 p_effective_start_date => r_LER.information2,
10048 p_dml_operation => r_LER.dml_operation,
10049 p_datetrack_mode => l_datetrack_mode );
10050 -- p_update => l_update
10051 --
10052 l_effective_date := l_process_date;
10053 l_ler_id := r_LER.information1;
10054 l_object_version_number := r_LER.information265;
10055 --
10056 end if;
10057 --
10058 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
10059 --
10060 IF l_update OR l_dml_operation <> 'UPDATE' THEN
10061 -- Call Update routine for the pk_id created in prev run .
10062 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
10063 hr_utility.set_location(' BEN_LER_F UPDATE_LIFE_EVENT_REASON ',30);
10064 BEN_LIFE_EVENT_REASON_API.UPDATE_LIFE_EVENT_REASON(
10065 --
10066 P_VALIDATE => false
10067 ,P_EFFECTIVE_DATE => l_effective_date
10068 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
10069 --
10070 ,P_CK_RLTD_PER_ELIG_FLAG => r_LER.INFORMATION22
10071 ,P_CM_APLY_FLAG => r_LER.INFORMATION23
10072 ,P_DESC_TXT => r_LER.INFORMATION219
10073 ,P_LER_ATTRIBUTE1 => r_LER.INFORMATION111
10074 ,P_LER_ATTRIBUTE10 => r_LER.INFORMATION120
10075 ,P_LER_ATTRIBUTE11 => r_LER.INFORMATION121
10076 ,P_LER_ATTRIBUTE12 => r_LER.INFORMATION122
10077 ,P_LER_ATTRIBUTE13 => r_LER.INFORMATION123
10078 ,P_LER_ATTRIBUTE14 => r_LER.INFORMATION124
10079 ,P_LER_ATTRIBUTE15 => r_LER.INFORMATION125
10080 ,P_LER_ATTRIBUTE16 => r_LER.INFORMATION126
10081 ,P_LER_ATTRIBUTE17 => r_LER.INFORMATION127
10082 ,P_LER_ATTRIBUTE18 => r_LER.INFORMATION128
10083 ,P_LER_ATTRIBUTE19 => r_LER.INFORMATION129
10084 ,P_LER_ATTRIBUTE2 => r_LER.INFORMATION112
10085 ,P_LER_ATTRIBUTE20 => r_LER.INFORMATION130
10086 ,P_LER_ATTRIBUTE21 => r_LER.INFORMATION131
10087 ,P_LER_ATTRIBUTE22 => r_LER.INFORMATION132
10088 ,P_LER_ATTRIBUTE23 => r_LER.INFORMATION133
10089 ,P_LER_ATTRIBUTE24 => r_LER.INFORMATION134
10090 ,P_LER_ATTRIBUTE25 => r_LER.INFORMATION135
10091 ,P_LER_ATTRIBUTE26 => r_LER.INFORMATION136
10092 ,P_LER_ATTRIBUTE27 => r_LER.INFORMATION137
10093 ,P_LER_ATTRIBUTE28 => r_LER.INFORMATION138
10094 ,P_LER_ATTRIBUTE29 => r_LER.INFORMATION139
10095 ,P_LER_ATTRIBUTE3 => r_LER.INFORMATION113
10096 ,P_LER_ATTRIBUTE30 => r_LER.INFORMATION140
10097 ,P_LER_ATTRIBUTE4 => r_LER.INFORMATION114
10098 ,P_LER_ATTRIBUTE5 => r_LER.INFORMATION115
10099 ,P_LER_ATTRIBUTE6 => r_LER.INFORMATION116
10100 ,P_LER_ATTRIBUTE7 => r_LER.INFORMATION117
10101 ,P_LER_ATTRIBUTE8 => r_LER.INFORMATION118
10102 ,P_LER_ATTRIBUTE9 => r_LER.INFORMATION119
10103 ,P_LER_ATTRIBUTE_CATEGORY => r_LER.INFORMATION110
10104 ,P_LER_EVAL_RL => l_LER_EVAL_RL
10105 ,P_LER_ID => l_ler_id
10106 ,P_LER_STAT_CD => r_LER.INFORMATION15
10107 ,P_LF_EVT_OPER_CD => r_LER.INFORMATION13
10108 ,P_NAME => l_prefix || r_LER.INFORMATION170 || l_suffix
10109 ,P_OCRD_DT_DET_CD => r_LER.INFORMATION21
10110 ,P_OVRIDG_LE_FLAG => r_LER.INFORMATION24
10111 ,P_PTNL_LER_TRTMT_CD => r_LER.INFORMATION17
10112 ,P_QUALG_EVT_FLAG => r_LER.INFORMATION25
10113 ,P_SS_PCP_DISP_CD => r_LER.INFORMATION26 --4301332
10114 ,P_SHORT_CODE => r_LER.INFORMATION11
10115 ,P_SHORT_NAME => r_LER.INFORMATION12
10116 ,P_SLCTBL_SLF_SVC_CD => r_LER.INFORMATION14
10117 ,P_TMLNS_DYS_NUM => r_LER.INFORMATION263
10118 ,P_TMLNS_EVAL_CD => r_LER.INFORMATION20
10119 ,P_TMLNS_PERD_CD => r_LER.INFORMATION19
10120 ,P_TMLNS_PERD_RL => l_TMLNS_PERD_RL
10121 ,P_TYP_CD => r_LER.INFORMATION16
10122 ,P_WHN_TO_PRCS_CD => r_LER.INFORMATION18
10123 --
10124 ,P_EFFECTIVE_START_DATE => l_effective_start_date
10125 ,P_EFFECTIVE_END_DATE => l_effective_end_date
10126 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
10127 ,P_DATETRACK_MODE => l_datetrack_mode
10128 );
10129 --
10130 end if;
10131 end if;
10132 --
10133 -- Delete the row if it is end dated.
10134 --
10135 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
10136 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
10137 trunc(l_max_eed) = r_LER.information3) then
10138 --
10139 BEN_LIFE_EVENT_REASON_API.delete_LIFE_EVENT_REASON(
10140 --
10141 p_validate => false
10142 ,p_ler_id => l_ler_id
10143 ,p_effective_start_date => l_effective_start_date
10144 ,p_effective_end_date => l_effective_end_date
10145 ,p_object_version_number => l_object_version_number
10146 ,p_effective_date => l_max_eed
10147 ,p_datetrack_mode => hr_api.g_delete
10148 --
10149 );
10150 --
10151 end if;
10152 --
10153 l_prev_pk_id := l_current_pk_id ;
10154 --
10155 end if;
10156 --
10157 end if;
10158 --
10159 end loop;
10160 --
10161 exception when others then
10162 --
10163 raise_error_message( 'LER',l_source_ler_name) ;
10164 --
10165 end create_LER_rows;
10166
10167 --
10168 ---------------------------------------------------------------
10169 ----------------------< create_LPL_rows >----------------------
10170 ---------------------------------------------------------------
10171 --
10172 procedure create_LPL_rows
10173 (
10174 p_validate in number default 0
10175 ,p_copy_entity_txn_id in number
10176 ,p_effective_date in date
10177 ,p_prefix_suffix_text in varchar2 default null
10178 ,p_reuse_object_flag in varchar2 default null
10179 ,p_target_business_group_id in varchar2 default null
10180 ,p_prefix_suffix_cd in varchar2 default null
10181 ) is
10182 --
10183 l_LER_ID number;
10184 l_LER_PER_INFO_CS_LER_RL number;
10185 l_PER_INFO_CHG_CS_LER_ID number;
10186 cursor c_unique_LPL(l_table_alias varchar2) is
10187 select distinct cer.information1,
10188 cer.information2,
10189 cer.information3,
10190 cer.table_route_id,cer.dml_operation,cer.datetrack_mode
10191 from ben_copy_entity_results cer,
10192 pqh_table_route tr
10193 where cer.copy_entity_txn_id = p_copy_entity_txn_id
10194 and cer.table_route_id = tr.table_route_id
10195 and tr.table_alias = l_table_alias
10196 and cer.number_of_copies = 1
10197 group by cer.information1,cer.information2,cer.information3, cer.table_route_id,cer.dml_operation,cer.datetrack_mode
10198 order by information1, information2; --added for bug: 5151945
10199 --
10200 --
10201 cursor c_LPL_min_max_dates(c_table_route_id number,
10202 c_information1 number) is
10203 select
10204 min(cer.information2) min_esd,
10205 max(cer.information3) min_eed
10206 from ben_copy_entity_results cer
10207 where cer.copy_entity_txn_id = p_copy_entity_txn_id
10208 and cer.table_route_id = c_table_route_id
10209 and cer.information1 = c_information1 ;
10210 --
10211 cursor c_LPL(c_table_route_id number,
10212 c_information1 number,
10213 c_information2 date,
10214 c_information3 date ) is
10215 select
10216 cer.*
10217 from ben_copy_entity_results cer
10218 where cer.copy_entity_txn_id = p_copy_entity_txn_id
10219 and cer.table_route_id = c_table_route_id
10220 and cer.information1 = c_information1
10221 and cer.information2 = c_information2
10222 and cer.information3 = c_information3
10223 and rownum = 1 ;
10224 -- Date Track target record
10225 cursor c_find_LPL_in_target(
10226 c_effective_start_date date,
10227 c_effective_end_date date,
10228 c_business_group_id number,
10229 c_new_pk_id number) is
10230 select
10231 LPL.ler_per_info_cs_ler_id new_value
10232 from BEN_LER_PER_INFO_CS_LER_F LPL
10233 where
10234 LPL.LER_ID = l_LER_ID and
10235 LPL.PER_INFO_CHG_CS_LER_ID = l_PER_INFO_CHG_CS_LER_ID and
10236 LPL.business_group_id = c_business_group_id
10237 and LPL.ler_per_info_cs_ler_id <> c_new_pk_id
10238 --TEMPIK
10239 and c_effective_start_date between effective_start_date
10240 and effective_end_date ;
10241 --END TEMPIK
10242 /*TEMPIK
10243 and exists ( select null
10244 from BEN_LER_PER_INFO_CS_LER_F LPL1
10245 where
10246 LPL1.LER_ID = l_LER_ID and
10247 LPL1.PER_INFO_CHG_CS_LER_ID = l_PER_INFO_CHG_CS_LER_ID and
10248 LPL1.business_group_id = c_business_group_id
10249 and LPL1.effective_start_date <= c_effective_start_date )
10250 and exists ( select null
10251 from BEN_LER_PER_INFO_CS_LER_F LPL2
10252 where
10253 LPL2.LER_ID = l_LER_ID and
10254 LPL2.PER_INFO_CHG_CS_LER_ID = l_PER_INFO_CHG_CS_LER_ID and
10255 LPL2.business_group_id = c_business_group_id
10256 and LPL2.effective_end_date >= c_effective_end_date )
10257 ;
10258 TEMPIK */
10259 --TEMPIK
10260 l_dt_rec_found boolean ;
10261 --END TEMPIK
10262 --
10263 l_current_pk_id number := null ;
10264 --UPD START
10265 --
10266 l_update boolean := false ;
10267 l_datetrack_mode varchar2(80) := hr_api.g_update;
10268 l_process_date date;
10269 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
10270 --
10271 --UPD END
10272 l_prev_pk_id number := null ;
10273 l_first_rec boolean := true ;
10274 r_LPL c_LPL%rowtype;
10275 l_ler_per_info_cs_ler_id number ;
10276 l_object_version_number number ;
10277 l_effective_start_date date ;
10278 l_effective_end_date date ;
10279 l_prefix pqh_copy_entity_attribs.information1%type := null;
10280 l_suffix pqh_copy_entity_attribs.information1%type := null;
10281 l_new_value number(15);
10282 l_object_found_in_target boolean := false ;
10283 l_min_esd date;
10284 l_max_eed date;
10285 l_effective_date date;
10286 --
10287 begin
10288 -- Initialization
10289 l_object_found_in_target := false ;
10290 -- End Initialization
10291 -- Derive the prefix - sufix
10292 if p_prefix_suffix_cd = 'PREFIX' then
10293 l_prefix := p_prefix_suffix_text ;
10294 elsif p_prefix_suffix_cd = 'SUFFIX' then
10295 l_suffix := p_prefix_suffix_text ;
10296 else
10297 l_prefix := null ;
10298 l_suffix := null ;
10299 end if ;
10300 -- End Prefix Sufix derivation
10301 for r_LPL_unique in c_unique_LPL('LPL') loop
10302 --
10303 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
10304 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10305 r_LPL_unique.information3 >=
10306 ben_pd_copy_to_ben_one.g_copy_effective_date)
10307 ) then
10308 --
10309 hr_utility.set_location(' r_LPL_unique.table_route_id '||r_LPL_unique.table_route_id,10);
10310 hr_utility.set_location(' r_LPL_unique.information1 '||r_LPL_unique.information1,10);
10311 hr_utility.set_location( 'r_LPL_unique.information2 '||r_LPL_unique.information2,10);
10312 hr_utility.set_location( 'r_LPL_unique.information3 '||r_LPL_unique.information3,10);
10313 -- If reuse objects flag is 'Y' then check for the object in the target business group
10314 -- if found insert the record into PLSql table and exit the loop else try create the
10315 -- object in the target business group
10316 --
10317 l_object_found_in_target := false ;
10318 open c_LPL(r_LPL_unique.table_route_id,
10319 r_LPL_unique.information1,
10320 r_LPL_unique.information2,
10321 r_LPL_unique.information3 ) ;
10322 --
10323 fetch c_LPL into r_LPL ;
10324 --
10325 close c_LPL ;
10326 --
10327 l_dml_operation:= r_LPL_unique.dml_operation ;
10328 l_LER_ID := get_fk('LER_ID', r_LPL.information257,l_dml_operation);
10329 l_LER_PER_INFO_CS_LER_RL := get_fk('FORMULA_ID', r_LPL.information13,l_dml_operation);
10330 l_PER_INFO_CHG_CS_LER_ID := get_fk('PER_INFO_CHG_CS_LER_ID', r_LPL.information258,l_dml_operation);
10331 --UPD START
10332 l_update := false;
10333 l_process_date := p_effective_date;
10334 --
10335 if l_dml_operation = 'UPDATE' then
10336 --
10337 l_object_found_in_target := TRUE;
10338 --
10339 if l_process_date between r_LPL_unique.information2 and r_LPL_unique.information3 then
10340 l_update := true;
10341 if r_LPL_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
10342 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'LER_PER_INFO_CS_LER_ID' then
10343 g_pk_tbl(g_count).pk_id_column := 'LER_PER_INFO_CS_LER_ID' ;
10344 g_pk_tbl(g_count).old_value := r_LPL_unique.information1 ;
10345 g_pk_tbl(g_count).new_value := r_LPL_unique.information1 ;
10346 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
10347 g_pk_tbl(g_count).table_route_id := r_LPL_unique.table_route_id;
10348 --
10349 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
10350 --
10351 g_count := g_count + 1 ;
10352 --
10353 log_data('LPL',l_new_value,l_prefix || r_LPL_unique.information1|| l_suffix,'REUSED');
10354 --
10355 end if ;
10356 hr_utility.set_location( 'found record for update',10);
10357 --
10358 else
10359 --
10360 l_update := false;
10361 --
10362 end if;
10363 else
10364 --
10365 --UPD END
10366 l_min_esd := null ;
10367 l_max_eed := null ;
10368 open c_LPL_min_max_dates(r_LPL_unique.table_route_id, r_LPL_unique.information1 ) ;
10369 fetch c_LPL_min_max_dates into l_min_esd,l_max_eed ;
10370 --
10371 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10372 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
10373 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
10374 end if;
10375 l_min_esd := greatest(l_min_esd,r_LPL_unique.information2);
10376 --
10377 /*
10378 open c_LPL(r_LPL_unique.table_route_id,
10379 r_LPL_unique.information1,
10380 r_LPL_unique.information2,
10381 r_LPL_unique.information3 ) ;
10382 --
10383 fetch c_LPL into r_LPL ;
10384 --
10385 close c_LPL ;
10386 --
10387 l_LER_ID := get_fk('LER_ID', r_LPL.information257);
10388 l_LER_PER_INFO_CS_LER_RL := get_fk('FORMULA_ID', r_LPL.information13);
10389 l_PER_INFO_CHG_CS_LER_ID := get_fk('PER_INFO_CHG_CS_LER_ID', r_LPL.information258);
10390 */
10391 if p_reuse_object_flag = 'Y' then
10392 if c_LPL_min_max_dates%found then
10393 -- cursor to find the object
10394 open c_find_LPL_in_target( l_min_esd,l_max_eed,
10395 p_target_business_group_id, nvl(l_ler_per_info_cs_ler_id, -999) ) ;
10396 fetch c_find_LPL_in_target into l_new_value ;
10397 if c_find_LPL_in_target%found then
10398 --
10399 --TEMPIK
10400 l_dt_rec_found := dt_api.check_min_max_dates
10401 (p_base_table_name => 'BEN_LER_PER_INFO_CS_LER_F',
10402 p_base_key_column => 'LER_PER_INFO_CS_LER_ID',
10403 p_base_key_value => l_new_value,
10404 p_from_date => l_min_esd,
10405 p_to_date => l_max_eed );
10406 if l_dt_rec_found THEN
10407 --END TEMPIK
10408 if r_LPL_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
10409 nvl(BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count-1).pk_id_column, '999') <> 'LER_PER_INFO_CS_LER_ID' then
10410 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_PER_INFO_CS_LER_ID' ;
10411 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LPL_unique.information1 ;
10412 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_new_value ;
10413 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'REUSED';
10414 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LPL_unique.table_route_id;
10415 --
10416 update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count) , p_copy_entity_txn_id) ;
10417 --
10418 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10419 end if ;
10420 --
10421 l_object_found_in_target := true ;
10422 --TEMPIK
10423 end if; -- l_dt_rec_found
10424 --END TEMPIK
10425 end if;
10426 close c_find_LPL_in_target ;
10427 --
10428 end if;
10429 end if ;
10430 --
10431 close c_LPL_min_max_dates ;
10432 end if;
10433 if not l_object_found_in_target or l_update then
10434 --
10435 l_current_pk_id := r_LPL.information1;
10436 --
10437 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
10438 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
10439 --
10440 if l_current_pk_id = l_prev_pk_id then
10441 --
10442 l_first_rec := false ;
10443 --
10444 else
10445 --
10446 l_first_rec := true ;
10447 --
10448 end if ;
10449 --
10450 l_effective_date := r_LPL.information2;
10451 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10452 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date )
10453 then
10454 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
10455 end if;
10456 --
10457 if l_first_rec and not l_update then
10458 -- Call Create routine.
10459 hr_utility.set_location(' BEN_LER_PER_INFO_CS_LER_F CREATE_LER_PER_INFO_CS_LER ',20);
10460 BEN_LER_PER_INFO_CS_LER_API.CREATE_LER_PER_INFO_CS_LER(
10461 --
10462 P_VALIDATE => false
10463 ,P_EFFECTIVE_DATE => l_effective_date
10464 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
10465 --
10466 ,P_LER_ID => l_LER_ID
10467 ,P_LER_PER_INFO_CS_LER_ID => l_ler_per_info_cs_ler_id
10468 ,P_LER_PER_INFO_CS_LER_RL => l_LER_PER_INFO_CS_LER_RL
10469 ,P_LPL_ATTRIBUTE1 => r_LPL.information14
10470 ,P_LPL_ATTRIBUTE10 => r_LPL.information15
10471 ,P_LPL_ATTRIBUTE11 => r_LPL.information16
10472 ,P_LPL_ATTRIBUTE12 => r_LPL.information17
10473 ,P_LPL_ATTRIBUTE13 => r_LPL.information18
10474 ,P_LPL_ATTRIBUTE14 => r_LPL.information19
10475 ,P_LPL_ATTRIBUTE15 => r_LPL.information20
10476 ,P_LPL_ATTRIBUTE16 => r_LPL.information21
10477 ,P_LPL_ATTRIBUTE17 => r_LPL.information22
10478 ,P_LPL_ATTRIBUTE18 => r_LPL.information23
10479 ,P_LPL_ATTRIBUTE19 => r_LPL.information24
10480 ,P_LPL_ATTRIBUTE2 => r_LPL.information25
10481 ,P_LPL_ATTRIBUTE20 => r_LPL.information26
10482 ,P_LPL_ATTRIBUTE21 => r_LPL.information27
10483 ,P_LPL_ATTRIBUTE22 => r_LPL.information28
10484 ,P_LPL_ATTRIBUTE23 => r_LPL.information29
10485 ,P_LPL_ATTRIBUTE24 => r_LPL.information30
10486 ,P_LPL_ATTRIBUTE25 => r_LPL.information31
10487 ,P_LPL_ATTRIBUTE26 => r_LPL.information32
10488 ,P_LPL_ATTRIBUTE27 => r_LPL.information33
10489 ,P_LPL_ATTRIBUTE28 => r_LPL.information34
10490 ,P_LPL_ATTRIBUTE29 => r_LPL.information35
10491 ,P_LPL_ATTRIBUTE3 => r_LPL.information36
10492 ,P_LPL_ATTRIBUTE30 => r_LPL.information37
10493 ,P_LPL_ATTRIBUTE4 => r_LPL.information38
10494 ,P_LPL_ATTRIBUTE5 => r_LPL.information39
10495 ,P_LPL_ATTRIBUTE6 => r_LPL.information40
10496 ,P_LPL_ATTRIBUTE7 => r_LPL.information41
10497 ,P_LPL_ATTRIBUTE8 => r_LPL.information42
10498 ,P_LPL_ATTRIBUTE9 => r_LPL.information43
10499 ,P_LPL_ATTRIBUTE_CATEGORY => r_LPL.information44
10500 ,P_PER_INFO_CHG_CS_LER_ID => l_PER_INFO_CHG_CS_LER_ID
10501 --
10502 ,P_EFFECTIVE_START_DATE => l_effective_start_date
10503 ,P_EFFECTIVE_END_DATE => l_effective_end_date
10504 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
10505 );
10506 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
10507 -- Update all relevent cer records with new pk_id
10508 hr_utility.set_location('Before plsql table ',222);
10509 hr_utility.set_location('new_value id '||l_ler_per_info_cs_ler_id,222);
10510 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).pk_id_column := 'LER_PER_INFO_CS_LER_ID' ;
10511 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).old_value := r_LPL.information1 ;
10512 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).new_value := l_LER_PER_INFO_CS_LER_ID ;
10513 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).copy_reuse_type := 'COPIED';
10514 BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count).table_route_id := r_LPL_unique.table_route_id;
10515 hr_utility.set_location('After plsql table ',222);
10516 --
10517 -- 9999 why commented update_cer_with_target( BEN_PD_COPY_TO_BEN_ONE.g_pk_tbl(BEN_PD_COPY_TO_BEN_ONE.g_count),p_copy_entity_txn_id ) ;
10518 --
10519 BEN_PD_COPY_TO_BEN_ONE.g_count := BEN_PD_COPY_TO_BEN_ONE.g_count + 1 ;
10520 --
10521 else
10522 --
10523 --UPD START
10524 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
10525 --
10526 if l_update then
10527 --
10528 l_datetrack_mode := r_LPL.datetrack_mode ;
10529 --
10530 get_dt_modes(
10531 p_effective_date => l_process_date,
10532 p_effective_end_date => r_LPL.information3,
10533 p_effective_start_date => r_LPL.information2,
10534 p_dml_operation => r_LPL.dml_operation,
10535 p_datetrack_mode => l_datetrack_mode );
10536 -- p_update => l_update
10537 --
10538 l_effective_date := l_process_date;
10539 l_ler_per_info_cs_ler_id := r_LPL.information1;
10540 l_object_version_number := r_LPL.information265;
10541 --
10542 end if;
10543 --
10544 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
10545 --
10546 IF l_update OR l_dml_operation <> 'UPDATE' THEN
10547 --UPD END
10548 -- Call Update routine for the pk_id created in prev run .
10549 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
10550 hr_utility.set_location(' BEN_LER_PER_INFO_CS_LER_F UPDATE_LER_PER_INFO_CS_LER ',30);
10551 BEN_LER_PER_INFO_CS_LER_API.UPDATE_LER_PER_INFO_CS_LER(
10552 --
10553 P_VALIDATE => false
10554 ,P_EFFECTIVE_DATE => l_effective_date
10555 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
10556 --
10557 ,P_LER_ID => l_LER_ID
10558 ,P_LER_PER_INFO_CS_LER_ID => l_ler_per_info_cs_ler_id
10559 ,P_LER_PER_INFO_CS_LER_RL => l_LER_PER_INFO_CS_LER_RL
10560 ,P_LPL_ATTRIBUTE1 => r_LPL.information14
10561 ,P_LPL_ATTRIBUTE10 => r_LPL.information15
10562 ,P_LPL_ATTRIBUTE11 => r_LPL.information16
10563 ,P_LPL_ATTRIBUTE12 => r_LPL.information17
10564 ,P_LPL_ATTRIBUTE13 => r_LPL.information18
10565 ,P_LPL_ATTRIBUTE14 => r_LPL.information19
10566 ,P_LPL_ATTRIBUTE15 => r_LPL.information20
10567 ,P_LPL_ATTRIBUTE16 => r_LPL.information21
10568 ,P_LPL_ATTRIBUTE17 => r_LPL.information22
10569 ,P_LPL_ATTRIBUTE18 => r_LPL.information23
10570 ,P_LPL_ATTRIBUTE19 => r_LPL.information24
10571 ,P_LPL_ATTRIBUTE2 => r_LPL.information25
10572 ,P_LPL_ATTRIBUTE20 => r_LPL.information26
10573 ,P_LPL_ATTRIBUTE21 => r_LPL.information27
10574 ,P_LPL_ATTRIBUTE22 => r_LPL.information28
10575 ,P_LPL_ATTRIBUTE23 => r_LPL.information29
10576 ,P_LPL_ATTRIBUTE24 => r_LPL.information30
10577 ,P_LPL_ATTRIBUTE25 => r_LPL.information31
10578 ,P_LPL_ATTRIBUTE26 => r_LPL.information32
10579 ,P_LPL_ATTRIBUTE27 => r_LPL.information33
10580 ,P_LPL_ATTRIBUTE28 => r_LPL.information34
10581 ,P_LPL_ATTRIBUTE29 => r_LPL.information35
10582 ,P_LPL_ATTRIBUTE3 => r_LPL.information36
10583 ,P_LPL_ATTRIBUTE30 => r_LPL.information37
10584 ,P_LPL_ATTRIBUTE4 => r_LPL.information38
10585 ,P_LPL_ATTRIBUTE5 => r_LPL.information39
10586 ,P_LPL_ATTRIBUTE6 => r_LPL.information40
10587 ,P_LPL_ATTRIBUTE7 => r_LPL.information41
10588 ,P_LPL_ATTRIBUTE8 => r_LPL.information42
10589 ,P_LPL_ATTRIBUTE9 => r_LPL.information43
10590 ,P_LPL_ATTRIBUTE_CATEGORY => r_LPL.information44
10591 ,P_PER_INFO_CHG_CS_LER_ID => l_PER_INFO_CHG_CS_LER_ID
10592 --
10593 ,P_EFFECTIVE_START_DATE => l_effective_start_date
10594 ,P_EFFECTIVE_END_DATE => l_effective_end_date
10595 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
10596 ,P_DATETRACK_MODE => l_datetrack_mode
10597 );
10598 end if;
10599 --
10600 end if;
10601 --
10602 -- Delete the row if it is end dated.
10603 --
10604 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
10605 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
10606 trunc(l_max_eed) = r_LPL.information3) then
10607 --
10608 BEN_LER_PER_INFO_CS_LER_API.delete_LER_PER_INFO_CS_LER(
10609 --
10610 p_validate => false
10611 ,p_ler_per_info_cs_ler_id => l_ler_per_info_cs_ler_id
10612 ,p_effective_start_date => l_effective_start_date
10613 ,p_effective_end_date => l_effective_end_date
10614 ,p_object_version_number => l_object_version_number
10615 ,p_effective_date => l_max_eed
10616 ,p_datetrack_mode => hr_api.g_delete
10617 --
10618 );
10619 --
10620 end if;
10621 --
10622 l_prev_pk_id := l_current_pk_id ;
10623 --
10624 end if;
10625 --
10626 end if;
10627 --
10628 end loop;
10629 --
10630 exception when others then
10631 --
10632 BEN_PD_COPY_TO_BEN_ONE.raise_error_message( 'LPL',r_LPL.information5 );
10633 --
10634 end create_LPL_rows;
10635
10636 ---------------------------------------------------------------
10637 ----------------------< create_ELP_rows >-----------------------
10638 ---------------------------------------------------------------
10639 --
10640 procedure create_ELP_rows
10641 (
10642 p_validate in number default 0
10643 ,p_copy_entity_txn_id in number
10644 ,p_effective_date in date
10645 ,p_prefix_suffix_text in varchar2 default null
10646 ,p_reuse_object_flag in varchar2 default null
10647 ,p_target_business_group_id in varchar2 default null
10648 ,p_prefix_suffix_cd in varchar2 default null
10649 ) is
10650 --
10651 cursor c_unique_ELP(l_table_alias varchar2) is
10652 select distinct cpe.information1,
10653 cpe.information2,
10654 cpe.information3,
10655 cpe.INFORMATION170 name,
10656 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
10657 from ben_copy_entity_results cpe,
10658 pqh_table_route tr
10659 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10660 and cpe.table_route_id = tr.table_route_id
10661 -- and tr.where_clause = l_BEN_ELIGY_PRFL_F
10662 and tr.table_alias = l_table_alias
10663 and cpe.number_of_copies = 1 --ADDITION
10664 group by cpe.information1,cpe.information2,cpe.information3,
10665 cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
10666 order by information1, information2; --added for bug: 5151945
10667 --
10668 --
10669 cursor c_ELP_min_max_dates(c_table_route_id number,
10670 c_information1 number) is
10671 select
10672 min(cpe.information2) min_esd,
10673 max(cpe.information3) min_eed
10674 from ben_copy_entity_results cpe
10675 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10676 and cpe.table_route_id = c_table_route_id
10677 and cpe.information1 = c_information1 ;
10678 --
10679 cursor c_ELP(c_table_route_id number,
10680 c_information1 number,
10681 c_information2 date,
10682 c_information3 date ) is
10683 select
10684 cpe.*
10685 from ben_copy_entity_results cpe
10686 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
10687 and cpe.table_route_id = c_table_route_id
10688 and cpe.information1 = c_information1
10689 and cpe.information2 = c_information2
10690 and cpe.information3 = c_information3
10691 and rownum = 1 ;
10692 -- Date Track target record
10693 cursor c_find_ELP_in_target( c_ELP_name varchar2,
10694 c_effective_start_date date,
10695 c_effective_end_date date,
10696 c_business_group_id number,
10697 c_new_pk_id number) is
10698 select
10699 ELP.eligy_prfl_id new_value
10700 from BEN_ELIGY_PRFL_F ELP
10701 where ELP.name = c_ELP_name
10702 and ELP.business_group_id = c_business_group_id
10703 and ELP.eligy_prfl_id <> c_new_pk_id
10704 --TEMPIK
10705 and c_effective_start_date between effective_start_date
10706 and effective_end_date ;
10707 --END TEMPIK
10708 /*TEMPIK
10709 and exists ( select null
10710 from BEN_ELIGY_PRFL_F ELP1
10711 where ELP1.name = c_ELP_name
10712 and ELP1.business_group_id = c_business_group_id
10713 and ELP1.effective_start_date <= c_effective_start_date )
10714 and exists ( select null
10715 from BEN_ELIGY_PRFL_F ELP2
10716 where ELP2.name = c_ELP_name
10717 and ELP2.business_group_id = c_business_group_id
10718 and ELP2.effective_end_date >= c_effective_end_date )
10719 ;
10720 TEMPIK */
10721 --TEMPIK
10722 l_dt_rec_found boolean ;
10723 --END TEMPIK
10724 --
10725 l_current_pk_id number := null ;
10726 --UPD START
10727 --
10728 l_update boolean := false ;
10729 l_datetrack_mode varchar2(80) := hr_api.g_update;
10730 l_process_date date;
10731 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
10732 --
10733 --UPD END
10734 l_prev_pk_id number := null ;
10735 l_first_rec boolean := true ;
10736 r_ELP c_ELP%rowtype;
10737 l_eligy_prfl_id number ;
10738 l_object_version_number number ;
10739 l_effective_start_date date ;
10740 l_effective_end_date date ;
10741 l_prefix pqh_copy_entity_attribs.information1%type := null;
10742 l_suffix pqh_copy_entity_attribs.information1%type := null;
10743 l_new_value number(15);
10744 l_object_found_in_target boolean := false ;
10745 l_min_esd date;
10746 l_max_eed date;
10747 l_effective_date date;
10748 --
10749 begin
10750 -- Initialization
10751 l_object_found_in_target := false ;
10752 -- End Initialization
10753 -- Derive the prefix - sufix
10754 if p_prefix_suffix_cd = 'PREFIX' then
10755 l_prefix := p_prefix_suffix_text ;
10756 elsif p_prefix_suffix_cd = 'SUFFIX' then
10757 l_suffix := p_prefix_suffix_text ;
10758 else
10759 l_prefix := null ;
10760 l_suffix := null ;
10761 end if ;
10762 -- End Prefix Sufix derivation
10763 for r_ELP_unique in c_unique_ELP('ELP') loop
10764
10765 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
10766 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10767 r_ELP_unique.information3 >=
10768 ben_pd_copy_to_ben_one.g_copy_effective_date)
10769 ) then
10770 --
10771 hr_utility.set_location(' r_ELP_unique.table_route_id '||r_ELP_unique.table_route_id,10);
10772 hr_utility.set_location(' r_ELP_unique.information1 '||r_ELP_unique.information1,10);
10773 hr_utility.set_location( 'r_ELP_unique.information2 '||r_ELP_unique.information2,10);
10774 hr_utility.set_location( 'r_ELP_unique.information3 '||r_ELP_unique.information3,10);
10775 -- If reuse objects flag is 'Y' then check for the object in the target business group
10776 -- if found insert the record into PLSql table and exit the loop else try create the
10777 -- object in the target business group
10778 --
10779 l_object_found_in_target := false ;
10780 --UPD START
10781 l_update := false;
10782 l_process_date := p_effective_date;
10783 l_dml_operation:= r_ELP_unique.dml_operation ;
10784 --
10785 if l_dml_operation = 'UPDATE' then
10786 --
10787 l_object_found_in_target := TRUE;
10788 --
10789 if l_process_date between r_ELP_unique.information2 and r_ELP_unique.information3 then
10790 l_update := true;
10791 if r_ELP_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
10792 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'ELIGY_PRFL_ID' then
10793 g_pk_tbl(g_count).pk_id_column := 'ELIGY_PRFL_ID' ;
10794 g_pk_tbl(g_count).old_value := r_ELP_unique.information1 ;
10795 g_pk_tbl(g_count).new_value := r_ELP_unique.information1 ;
10796 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
10797 g_pk_tbl(g_count).table_route_id := r_ELP_unique.table_route_id;
10798 --
10799 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
10800 --
10801 g_count := g_count + 1 ;
10802 --
10803 log_data('ELP',l_new_value,l_prefix || r_ELP_unique.name|| l_suffix,'REUSED');
10804 --
10805 end if ;
10806 hr_utility.set_location( 'found record for update',10);
10807 --
10808 else
10809 --
10810 l_update := false;
10811 --
10812 end if;
10813 else
10814 --
10815 --UPD END
10816 l_min_esd := null ;
10817 l_max_eed := null ;
10818 open c_ELP_min_max_dates(r_ELP_unique.table_route_id, r_ELP_unique.information1 ) ;
10819 fetch c_ELP_min_max_dates into l_min_esd,l_max_eed ;
10820
10821 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10822 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
10823 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
10824 end if;
10825 l_min_esd := greatest(l_min_esd,r_ELP_unique.information2);
10826
10827 if p_reuse_object_flag = 'Y' then
10828 if c_ELP_min_max_dates%found then
10829 -- cursor to find the object
10830 open c_find_ELP_in_target( l_prefix || r_ELP_unique.name || l_suffix ,l_min_esd,l_max_eed,
10831 p_target_business_group_id, nvl(l_eligy_prfl_id, -999) ) ;
10832 fetch c_find_ELP_in_target into l_new_value ;
10833 if c_find_ELP_in_target%found then
10834 --
10835 --TEMPIK
10836 l_dt_rec_found := dt_api.check_min_max_dates
10837 (p_base_table_name => 'BEN_ELIGY_PRFL_F',
10838 p_base_key_column => 'ELIGY_PRFL_ID',
10839 p_base_key_value => l_new_value,
10840 p_from_date => l_min_esd,
10841 p_to_date => l_max_eed );
10842 if l_dt_rec_found THEN
10843 --END TEMPIK
10844 if r_ELP_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
10845 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'ELIGY_PRFL_ID' then
10846 g_pk_tbl(g_count).pk_id_column := 'ELIGY_PRFL_ID' ;
10847 g_pk_tbl(g_count).old_value := r_ELP_unique.information1 ;
10848 g_pk_tbl(g_count).new_value := l_new_value ;
10849 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
10850 g_pk_tbl(g_count).table_route_id := r_ELP_unique.table_route_id;
10851 --
10852 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
10853 --
10854 g_count := g_count + 1 ;
10855 --
10856 log_data('ELP',l_new_value,l_prefix || r_ELP_unique.name || l_suffix ,'REUSED');
10857 --
10858 end if ;
10859 --
10860 l_object_found_in_target := true ;
10861 --TEMPIK
10862 end if; -- l_dt_rec_found
10863 --END TEMPIK
10864 end if;
10865 close c_find_ELP_in_target ;
10866 --
10867 end if;
10868 end if ;
10869 --
10870 close c_ELP_min_max_dates ;
10871 end if;
10872 if not l_object_found_in_target or l_update then
10873 --
10874 open c_ELP(r_ELP_unique.table_route_id,
10875 r_ELP_unique.information1,
10876 r_ELP_unique.information2,
10877 r_ELP_unique.information3 ) ;
10878 --
10879 fetch c_ELP into r_ELP ;
10880 --
10881 close c_ELP ;
10882 --
10883 l_current_pk_id := r_ELP.information1;
10884 --
10885 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
10886 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
10887 --
10888 if l_current_pk_id = l_prev_pk_id then
10889 --
10890 l_first_rec := false ;
10891 --
10892 else
10893 --
10894 l_first_rec := true ;
10895 --
10896 end if ;
10897 --
10898 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_ELIGY_PRFL_F',l_prefix || r_elp.INFORMATION170 || l_suffix);
10899 --
10900
10901 l_effective_date := r_ELP.information2;
10902 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
10903 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
10904 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
10905 end if;
10906
10907 if l_first_rec and not l_update then
10908 -- Call Create routine.
10909 hr_utility.set_location(' BEN_ELIGY_PRFL_F CREATE_ELIGY_PROFILE ',20);
10910 BEN_ELIGY_PROFILE_API.CREATE_ELIGY_PROFILE(
10911 --
10912 P_VALIDATE => false
10913 ,P_EFFECTIVE_DATE => l_effective_date
10914 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
10915 --
10916 -- ,p_asg_typ_cd => r_elp.information11
10917 ,P_ASMT_TO_USE_CD => r_ELP.INFORMATION76
10918 ,P_BNFT_CAGR_PRTN_CD => r_ELP.INFORMATION20
10919 ,P_CNTNG_PRTN_ELIG_PRFL_FLAG => r_ELP.INFORMATION62
10920 ,P_DESCRIPTION => r_ELP.INFORMATION219
10921 ,P_ELIGY_PRFL_ID => l_eligy_prfl_id
10922 ,P_ELIGY_PRFL_RL_FLAG => r_ELP.INFORMATION60
10923 ,P_ELIG_AGE_FLAG => r_ELP.INFORMATION45
10924 ,P_ELIG_ANTHR_PL_FLAG => r_ELP.INFORMATION16
10925 ,P_ELIG_ASNT_SET_FLAG => r_ELP.INFORMATION52
10926 ,P_ELIG_BENFTS_GRP_FLAG => r_ELP.INFORMATION42
10927 ,P_ELIG_BRGNG_UNIT_FLAG => r_ELP.INFORMATION44
10928 ,P_ELIG_CBR_QUALD_BNF_FLAG => r_ELP.INFORMATION32
10929 ,P_ELIG_CMBN_AGE_LOS_FLAG => r_ELP.INFORMATION61
10930 ,P_ELIG_COMPTNCY_FLAG => r_ELP.INFORMATION14
10931 ,P_ELIG_COMP_LVL_FLAG => r_ELP.INFORMATION54
10932 ,P_ELIG_DPNT_CVRD_PGM_FLAG => r_ELP.INFORMATION36
10933 ,P_ELIG_DPNT_CVRD_PLIP_FLAG => r_ELP.INFORMATION34
10934 ,P_ELIG_DPNT_CVRD_PL_FLAG => r_ELP.INFORMATION71
10935 ,P_ELIG_DPNT_CVRD_PTIP_FLAG => r_ELP.INFORMATION35
10936 ,P_ELIG_DPNT_OTHR_PTIP_FLAG => r_ELP.INFORMATION77
10937 ,P_ELIG_DSBLD_FLAG => r_ELP.INFORMATION11
10938 ,P_ELIG_DSBLTY_CTG_FLAG => r_ELP.INFORMATION25
10939 ,P_ELIG_DSBLTY_DGR_FLAG => r_ELP.INFORMATION26
10940 ,P_ELIG_DSBLTY_RSN_FLAG => r_ELP.INFORMATION27
10941 ,P_ELIG_EE_STAT_FLAG => r_ELP.INFORMATION49
10942 ,P_ELIG_ENRLD_OIPL_FLAG => r_ELP.INFORMATION69
10943 ,P_ELIG_ENRLD_PGM_FLAG => r_ELP.INFORMATION70
10944 ,P_ELIG_ENRLD_PLIP_FLAG => r_ELP.INFORMATION31
10945 ,P_ELIG_ENRLD_PL_FLAG => r_ELP.INFORMATION68
10946 ,P_ELIG_ENRLD_PTIP_FLAG => r_ELP.INFORMATION33
10947 ,P_ELIG_FL_TM_PT_TM_FLAG => r_ELP.INFORMATION48
10948 ,P_ELIG_GNDR_FLAG => r_ELP.INFORMATION24
10949 ,P_ELIG_GRD_FLAG => r_ELP.INFORMATION50
10950 ,P_ELIG_HLTH_CVG_FLAG => r_ELP.INFORMATION15
10951 ,P_ELIG_HRLY_SLRD_FLAG => r_ELP.INFORMATION38
10952 ,P_ELIG_HRS_WKD_FLAG => r_ELP.INFORMATION53
10953 ,P_ELIG_JOB_FLAG => r_ELP.INFORMATION37
10954 ,P_ELIG_LBR_MMBR_FLAG => r_ELP.INFORMATION40
10955 ,P_ELIG_LGL_ENTY_FLAG => r_ELP.INFORMATION41
10956 ,P_ELIG_LOA_RSN_FLAG => r_ELP.INFORMATION56
10957 ,P_ELIG_LOS_FLAG => r_ELP.INFORMATION46
10958 ,P_ELIG_LVG_RSN_FLAG => r_ELP.INFORMATION72
10959 ,P_ELIG_MRTL_STS_FLAG => r_ELP.INFORMATION28
10960 ,P_ELIG_NO_OTHR_CVG_FLAG => r_ELP.INFORMATION67
10961 ,P_ELIG_OPTD_MDCR_FLAG => r_ELP.INFORMATION73
10962 ,P_ELIG_ORG_UNIT_FLAG => r_ELP.INFORMATION55
10963 ,P_ELIG_PCT_FL_TM_FLAG => r_ELP.INFORMATION51
10964 ,P_ELIG_PERF_RTNG_FLAG => r_ELP.INFORMATION17
10965 ,P_ELIG_PER_TYP_FLAG => r_ELP.INFORMATION47
10966 ,P_ELIG_PPL_GRP_FLAG => r_ELP.INFORMATION64
10967 ,P_ELIG_PRBTN_PERD_FLAG => r_ELP.INFORMATION29
10968 ,P_ELIG_PRTT_PL_FLAG => r_ELP.INFORMATION63
10969 ,P_ELIG_PSTL_CD_FLAG => r_ELP.INFORMATION39
10970 ,P_ELIG_PSTN_FLAG => r_ELP.INFORMATION19
10971 ,P_ELIG_PTIP_PRTE_FLAG => r_ELP.INFORMATION66
10972 ,P_ELIG_PYRL_FLAG => r_ELP.INFORMATION57
10973 ,P_ELIG_PY_BSS_FLAG => r_ELP.INFORMATION59
10974 ,P_ELIG_QUAL_TITL_FLAG => r_ELP.INFORMATION21
10975 ,P_ELIG_QUA_IN_GR_FLAG => r_ELP.INFORMATION18
10976 ,P_ELIG_SCHEDD_HRS_FLAG => r_ELP.INFORMATION58
10977 ,P_ELIG_SP_CLNG_PRG_PT_FLAG => r_ELP.INFORMATION22
10978 ,P_ELIG_SUPPL_ROLE_FLAG => r_ELP.INFORMATION23
10979 ,P_ELIG_SVC_AREA_FLAG => r_ELP.INFORMATION65
10980 ,P_ELIG_TBCO_USE_FLAG => r_ELP.INFORMATION74
10981 ,P_ELIG_TTL_CVG_VOL_FLAG => r_ELP.INFORMATION12
10982 ,P_ELIG_TTL_PRTT_FLAG => r_ELP.INFORMATION13
10983 ,P_ELIG_WK_LOC_FLAG => r_ELP.INFORMATION43
10984 ,p_ELIG_CRIT_VALUES_FLAG => nvl(r_ELP.INFORMATION78, 'N') /* Bug 4169120 : Rate By Criteria */
10985 ,P_ELP_ATTRIBUTE1 => r_ELP.INFORMATION111
10986 ,P_ELP_ATTRIBUTE10 => r_ELP.INFORMATION120
10987 ,P_ELP_ATTRIBUTE11 => r_ELP.INFORMATION121
10988 ,P_ELP_ATTRIBUTE12 => r_ELP.INFORMATION122
10989 ,P_ELP_ATTRIBUTE13 => r_ELP.INFORMATION123
10990 ,P_ELP_ATTRIBUTE14 => r_ELP.INFORMATION124
10991 ,P_ELP_ATTRIBUTE15 => r_ELP.INFORMATION125
10992 ,P_ELP_ATTRIBUTE16 => r_ELP.INFORMATION126
10993 ,P_ELP_ATTRIBUTE17 => r_ELP.INFORMATION127
10994 ,P_ELP_ATTRIBUTE18 => r_ELP.INFORMATION128
10995 ,P_ELP_ATTRIBUTE19 => r_ELP.INFORMATION129
10996 ,P_ELP_ATTRIBUTE2 => r_ELP.INFORMATION112
10997 ,P_ELP_ATTRIBUTE20 => r_ELP.INFORMATION130
10998 ,P_ELP_ATTRIBUTE21 => r_ELP.INFORMATION131
10999 ,P_ELP_ATTRIBUTE22 => r_ELP.INFORMATION132
11000 ,P_ELP_ATTRIBUTE23 => r_ELP.INFORMATION133
11001 ,P_ELP_ATTRIBUTE24 => r_ELP.INFORMATION134
11002 ,P_ELP_ATTRIBUTE25 => r_ELP.INFORMATION135
11003 ,P_ELP_ATTRIBUTE26 => r_ELP.INFORMATION136
11004 ,P_ELP_ATTRIBUTE27 => r_ELP.INFORMATION137
11005 ,P_ELP_ATTRIBUTE28 => r_ELP.INFORMATION138
11006 ,P_ELP_ATTRIBUTE29 => r_ELP.INFORMATION139
11007 ,P_ELP_ATTRIBUTE3 => r_ELP.INFORMATION113
11008 ,P_ELP_ATTRIBUTE30 => r_ELP.INFORMATION140
11009 ,P_ELP_ATTRIBUTE4 => r_ELP.INFORMATION114
11010 ,P_ELP_ATTRIBUTE5 => r_ELP.INFORMATION115
11011 ,P_ELP_ATTRIBUTE6 => r_ELP.INFORMATION116
11012 ,P_ELP_ATTRIBUTE7 => r_ELP.INFORMATION117
11013 ,P_ELP_ATTRIBUTE8 => r_ELP.INFORMATION118
11014 ,P_ELP_ATTRIBUTE9 => r_ELP.INFORMATION119
11015 ,P_ELP_ATTRIBUTE_CATEGORY => r_ELP.INFORMATION110
11016 ,P_NAME => l_prefix || r_ELP.INFORMATION170 || l_suffix
11017 ,P_STAT_CD => r_ELP.INFORMATION30
11018 --
11019 ,P_EFFECTIVE_START_DATE => l_effective_start_date
11020 ,P_EFFECTIVE_END_DATE => l_effective_end_date
11021 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11022 );
11023 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11024 -- Update all relevent cer records with new pk_id
11025 hr_utility.set_location('Before plsql table ',222);
11026 hr_utility.set_location('new_value id '||l_eligy_prfl_id,222);
11027 g_pk_tbl(g_count).pk_id_column := 'ELIGY_PRFL_ID' ;
11028 g_pk_tbl(g_count).old_value := r_ELP.information1 ;
11029 g_pk_tbl(g_count).new_value := l_ELIGY_PRFL_ID ;
11030 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
11031 g_pk_tbl(g_count).table_route_id := r_ELP_unique.table_route_id;
11032 hr_utility.set_location('After plsql table ',222);
11033 --
11034 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
11035 --
11036 g_count := g_count + 1 ;
11037 --
11038 --
11039 log_data('ELP',l_new_value,l_prefix || r_elp.INFORMATION170 || l_suffix,'COPIED');
11040 --
11041 else
11042 --
11043 --UPD START
11044 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
11045 --
11046 if l_update then
11047 --
11048 l_datetrack_mode := r_ELP.datetrack_mode ;
11049 --
11050 get_dt_modes(
11051 p_effective_date => l_process_date,
11052 p_effective_end_date => r_ELP.information3,
11053 p_effective_start_date => r_ELP.information2,
11054 p_dml_operation => r_ELP.dml_operation,
11055 p_datetrack_mode => l_datetrack_mode );
11056 -- p_update => l_update
11057 --
11058 l_effective_date := l_process_date;
11059 l_eligy_prfl_id := r_ELP.information1;
11060 l_object_version_number := r_ELP.information265;
11061 --
11062 end if;
11063 --
11064 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
11065 --
11066 IF l_update OR l_dml_operation <> 'UPDATE' THEN
11067 --UPD END
11068 -- Call Update routine for the pk_id created in prev run .
11069 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11070 hr_utility.set_location(' BEN_ELIGY_PRFL_F UPDATE_ELIGY_PROFILE ',30);
11071 BEN_ELIGY_PROFILE_API.UPDATE_ELIGY_PROFILE(
11072 --
11073 P_VALIDATE => false
11074 ,P_EFFECTIVE_DATE => l_effective_date
11075 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11076 --
11077 -- ,p_asg_typ_cd => r_elp.information11
11078 ,P_ASMT_TO_USE_CD => r_ELP.INFORMATION76
11079 ,P_BNFT_CAGR_PRTN_CD => r_ELP.INFORMATION20
11080 ,P_CNTNG_PRTN_ELIG_PRFL_FLAG => r_ELP.INFORMATION62
11081 ,P_DESCRIPTION => r_ELP.INFORMATION219
11082 ,P_ELIGY_PRFL_ID => l_eligy_prfl_id
11083 ,P_ELIGY_PRFL_RL_FLAG => r_ELP.INFORMATION60
11084 ,P_ELIG_AGE_FLAG => r_ELP.INFORMATION45
11085 ,P_ELIG_ANTHR_PL_FLAG => r_ELP.INFORMATION16
11086 ,P_ELIG_ASNT_SET_FLAG => r_ELP.INFORMATION52
11087 ,P_ELIG_BENFTS_GRP_FLAG => r_ELP.INFORMATION42
11088 ,P_ELIG_BRGNG_UNIT_FLAG => r_ELP.INFORMATION44
11089 ,P_ELIG_CBR_QUALD_BNF_FLAG => r_ELP.INFORMATION32
11090 ,P_ELIG_CMBN_AGE_LOS_FLAG => r_ELP.INFORMATION61
11091 ,P_ELIG_COMPTNCY_FLAG => r_ELP.INFORMATION14
11092 ,P_ELIG_COMP_LVL_FLAG => r_ELP.INFORMATION54
11093 ,P_ELIG_DPNT_CVRD_PGM_FLAG => r_ELP.INFORMATION36
11094 ,P_ELIG_DPNT_CVRD_PLIP_FLAG => r_ELP.INFORMATION34
11095 ,P_ELIG_DPNT_CVRD_PL_FLAG => r_ELP.INFORMATION71
11096 ,P_ELIG_DPNT_CVRD_PTIP_FLAG => r_ELP.INFORMATION35
11097 ,P_ELIG_DPNT_OTHR_PTIP_FLAG => r_ELP.INFORMATION77
11098 ,P_ELIG_DSBLD_FLAG => r_ELP.INFORMATION11
11099 ,P_ELIG_DSBLTY_CTG_FLAG => r_ELP.INFORMATION25
11100 ,P_ELIG_DSBLTY_DGR_FLAG => r_ELP.INFORMATION26
11101 ,P_ELIG_DSBLTY_RSN_FLAG => r_ELP.INFORMATION27
11102 ,P_ELIG_EE_STAT_FLAG => r_ELP.INFORMATION49
11103 ,P_ELIG_ENRLD_OIPL_FLAG => r_ELP.INFORMATION69
11104 ,P_ELIG_ENRLD_PGM_FLAG => r_ELP.INFORMATION70
11105 ,P_ELIG_ENRLD_PLIP_FLAG => r_ELP.INFORMATION31
11106 ,P_ELIG_ENRLD_PL_FLAG => r_ELP.INFORMATION68
11107 ,P_ELIG_ENRLD_PTIP_FLAG => r_ELP.INFORMATION33
11108 ,P_ELIG_FL_TM_PT_TM_FLAG => r_ELP.INFORMATION48
11109 ,P_ELIG_GNDR_FLAG => r_ELP.INFORMATION24
11110 ,P_ELIG_GRD_FLAG => r_ELP.INFORMATION50
11111 ,P_ELIG_HLTH_CVG_FLAG => r_ELP.INFORMATION15
11112 ,P_ELIG_HRLY_SLRD_FLAG => r_ELP.INFORMATION38
11113 ,P_ELIG_HRS_WKD_FLAG => r_ELP.INFORMATION53
11114 ,P_ELIG_JOB_FLAG => r_ELP.INFORMATION37
11115 ,P_ELIG_LBR_MMBR_FLAG => r_ELP.INFORMATION40
11116 ,P_ELIG_LGL_ENTY_FLAG => r_ELP.INFORMATION41
11117 ,P_ELIG_LOA_RSN_FLAG => r_ELP.INFORMATION56
11118 ,P_ELIG_LOS_FLAG => r_ELP.INFORMATION46
11119 ,P_ELIG_LVG_RSN_FLAG => r_ELP.INFORMATION72
11120 ,P_ELIG_MRTL_STS_FLAG => r_ELP.INFORMATION28
11121 ,P_ELIG_NO_OTHR_CVG_FLAG => r_ELP.INFORMATION67
11122 ,P_ELIG_OPTD_MDCR_FLAG => r_ELP.INFORMATION73
11123 ,P_ELIG_ORG_UNIT_FLAG => r_ELP.INFORMATION55
11124 ,P_ELIG_PCT_FL_TM_FLAG => r_ELP.INFORMATION51
11125 ,P_ELIG_PERF_RTNG_FLAG => r_ELP.INFORMATION17
11126 ,P_ELIG_PER_TYP_FLAG => r_ELP.INFORMATION47
11127 ,P_ELIG_PPL_GRP_FLAG => r_ELP.INFORMATION64
11128 ,P_ELIG_PRBTN_PERD_FLAG => r_ELP.INFORMATION29
11129 ,P_ELIG_PRTT_PL_FLAG => r_ELP.INFORMATION63
11130 ,P_ELIG_PSTL_CD_FLAG => r_ELP.INFORMATION39
11131 ,P_ELIG_PSTN_FLAG => r_ELP.INFORMATION19
11132 ,P_ELIG_PTIP_PRTE_FLAG => r_ELP.INFORMATION66
11133 ,P_ELIG_PYRL_FLAG => r_ELP.INFORMATION57
11134 ,P_ELIG_PY_BSS_FLAG => r_ELP.INFORMATION59
11135 ,P_ELIG_QUAL_TITL_FLAG => r_ELP.INFORMATION21
11136 ,P_ELIG_QUA_IN_GR_FLAG => r_ELP.INFORMATION18
11137 ,P_ELIG_SCHEDD_HRS_FLAG => r_ELP.INFORMATION58
11138 ,P_ELIG_SP_CLNG_PRG_PT_FLAG => r_ELP.INFORMATION22
11139 ,P_ELIG_SUPPL_ROLE_FLAG => r_ELP.INFORMATION23
11140 ,P_ELIG_SVC_AREA_FLAG => r_ELP.INFORMATION65
11141 ,P_ELIG_TBCO_USE_FLAG => r_ELP.INFORMATION74
11142 ,P_ELIG_TTL_CVG_VOL_FLAG => r_ELP.INFORMATION12
11143 ,P_ELIG_TTL_PRTT_FLAG => r_ELP.INFORMATION13
11144 ,P_ELIG_WK_LOC_FLAG => r_ELP.INFORMATION43
11145 ,p_ELIG_CRIT_VALUES_FLAG => nvl(r_ELP.INFORMATION78, 'N') /* Bug 4169120 : Rate By Criteria */
11146 ,P_ELP_ATTRIBUTE1 => r_ELP.INFORMATION111
11147 ,P_ELP_ATTRIBUTE10 => r_ELP.INFORMATION120
11148 ,P_ELP_ATTRIBUTE11 => r_ELP.INFORMATION121
11149 ,P_ELP_ATTRIBUTE12 => r_ELP.INFORMATION122
11150 ,P_ELP_ATTRIBUTE13 => r_ELP.INFORMATION123
11151 ,P_ELP_ATTRIBUTE14 => r_ELP.INFORMATION124
11152 ,P_ELP_ATTRIBUTE15 => r_ELP.INFORMATION125
11153 ,P_ELP_ATTRIBUTE16 => r_ELP.INFORMATION126
11154 ,P_ELP_ATTRIBUTE17 => r_ELP.INFORMATION127
11155 ,P_ELP_ATTRIBUTE18 => r_ELP.INFORMATION128
11156 ,P_ELP_ATTRIBUTE19 => r_ELP.INFORMATION129
11157 ,P_ELP_ATTRIBUTE2 => r_ELP.INFORMATION112
11158 ,P_ELP_ATTRIBUTE20 => r_ELP.INFORMATION130
11159 ,P_ELP_ATTRIBUTE21 => r_ELP.INFORMATION131
11160 ,P_ELP_ATTRIBUTE22 => r_ELP.INFORMATION132
11161 ,P_ELP_ATTRIBUTE23 => r_ELP.INFORMATION133
11162 ,P_ELP_ATTRIBUTE24 => r_ELP.INFORMATION134
11163 ,P_ELP_ATTRIBUTE25 => r_ELP.INFORMATION135
11164 ,P_ELP_ATTRIBUTE26 => r_ELP.INFORMATION136
11165 ,P_ELP_ATTRIBUTE27 => r_ELP.INFORMATION137
11166 ,P_ELP_ATTRIBUTE28 => r_ELP.INFORMATION138
11167 ,P_ELP_ATTRIBUTE29 => r_ELP.INFORMATION139
11168 ,P_ELP_ATTRIBUTE3 => r_ELP.INFORMATION113
11169 ,P_ELP_ATTRIBUTE30 => r_ELP.INFORMATION140
11170 ,P_ELP_ATTRIBUTE4 => r_ELP.INFORMATION114
11171 ,P_ELP_ATTRIBUTE5 => r_ELP.INFORMATION115
11172 ,P_ELP_ATTRIBUTE6 => r_ELP.INFORMATION116
11173 ,P_ELP_ATTRIBUTE7 => r_ELP.INFORMATION117
11174 ,P_ELP_ATTRIBUTE8 => r_ELP.INFORMATION118
11175 ,P_ELP_ATTRIBUTE9 => r_ELP.INFORMATION119
11176 ,P_ELP_ATTRIBUTE_CATEGORY => r_ELP.INFORMATION110
11177 ,P_NAME => l_prefix || r_ELP.INFORMATION170 || l_suffix
11178 ,P_STAT_CD => r_ELP.INFORMATION30
11179 --
11180 ,P_EFFECTIVE_START_DATE => l_effective_start_date
11181 ,P_EFFECTIVE_END_DATE => l_effective_end_date
11182 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11183 ,P_DATETRACK_MODE => l_datetrack_mode
11184 );
11185 --
11186 end if;
11187 end if;
11188 --
11189 -- Delete the row if it is end dated.
11190 --
11191 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
11192 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
11193 trunc(l_max_eed) = r_ELP.information3) then
11194 --
11195 BEN_ELIGY_PROFILE_API.delete_ELIGY_PROFILE(
11196 --
11197 p_validate => false
11198 ,p_eligy_prfl_id => l_eligy_prfl_id
11199 ,p_effective_start_date => l_effective_start_date
11200 ,p_effective_end_date => l_effective_end_date
11201 ,p_object_version_number => l_object_version_number
11202 ,p_effective_date => l_max_eed
11203 ,p_datetrack_mode => hr_api.g_delete
11204 --
11205 );
11206 --
11207 end if;
11208 --
11209 l_prev_pk_id := l_current_pk_id ;
11210 --
11211 end if;
11212 --
11213 end if;
11214 --
11215 end loop;
11216 --
11217 exception when others then
11218 --
11219 raise_error_message( 'ELP',l_prefix || r_elp.INFORMATION170 || l_suffix) ;
11220 --
11221 end create_ELP_rows;
11222 --
11223 ---------------------------------------------------------------
11224 ----------------------< create_DCE_rows >-----------------------
11225 ---------------------------------------------------------------
11226 --
11227 procedure create_DCE_rows
11228 (
11229 p_validate in number default 0
11230 ,p_copy_entity_txn_id in number
11231 ,p_effective_date in date
11232 ,p_prefix_suffix_text in varchar2 default null
11233 ,p_reuse_object_flag in varchar2 default null
11234 ,p_target_business_group_id in varchar2 default null
11235 ,p_prefix_suffix_cd in varchar2 default null
11236 ) is
11237 --
11238 cursor c_unique_DCE(l_table_alias varchar2) is
11239 select distinct cpe.information1,
11240 cpe.information2,
11241 cpe.information3,
11242 cpe.INFORMATION170 name,
11243 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
11244 from ben_copy_entity_results cpe,
11245 pqh_table_route tr
11246 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11247 and cpe.table_route_id = tr.table_route_id
11248 -- and tr.where_clause = l_BEN_DPNT_CVG_ELIGY_PRFL_F
11249 and tr.table_alias = l_table_alias
11250 and cpe.number_of_copies = 1 --ADDITION
11251 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
11252 order by information1, information2; --added for bug: 5151945
11253 --
11254 --
11255 cursor c_DCE_min_max_dates(c_table_route_id number,
11256 c_information1 number) is
11257 select
11258 min(cpe.information2) min_esd,
11259 max(cpe.information3) min_eed
11260 from ben_copy_entity_results cpe
11261 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11262 and cpe.table_route_id = c_table_route_id
11263 and cpe.information1 = c_information1 ;
11264 --
11265 cursor c_DCE(c_table_route_id number,
11266 c_information1 number,
11267 c_information2 date,
11268 c_information3 date ) is
11269 select
11270 cpe.*
11271 from ben_copy_entity_results cpe
11272 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11273 and cpe.table_route_id = c_table_route_id
11274 and cpe.information1 = c_information1
11275 and cpe.information2 = c_information2
11276 and cpe.information3 = c_information3
11277 and rownum = 1 ;
11278 -- Date Track target record
11279 cursor c_find_DCE_in_target( c_DCE_name varchar2,
11280 c_effective_start_date date,
11281 c_effective_end_date date,
11282 c_business_group_id number,
11283 c_new_pk_id number) is
11284 select
11285 DCE.dpnt_cvg_eligy_prfl_id new_value
11286 from BEN_DPNT_CVG_ELIGY_PRFL_F DCE
11287 where DCE.name = c_DCE_name
11288 and DCE.business_group_id = c_business_group_id
11289 and DCE.dpnt_cvg_eligy_prfl_id <> c_new_pk_id
11290 --TEMPIK
11291 and c_effective_start_date between effective_start_date
11292 and effective_end_date ;
11293 --END TEMPIK
11294 /*TEMPIK
11295 and exists ( select null
11296 from BEN_DPNT_CVG_ELIGY_PRFL_F DCE1
11297 where DCE1.name = c_DCE_name
11298 and DCE1.business_group_id = c_business_group_id
11299 and DCE1.effective_start_date <= c_effective_start_date )
11300 and exists ( select null
11301 from BEN_DPNT_CVG_ELIGY_PRFL_F DCE2
11302 where DCE2.name = c_DCE_name
11303 and DCE2.business_group_id = c_business_group_id
11304 and DCE2.effective_end_date >= c_effective_end_date )
11305 ;
11306 TEMPIK */
11307 --TEMPIK
11308 l_dt_rec_found boolean ;
11309 --END TEMPIK
11310 --
11311 l_current_pk_id number := null ;
11312 --UPD START
11313 --
11314 l_update boolean := false ;
11315 l_datetrack_mode varchar2(80) := hr_api.g_update;
11316 l_process_date date;
11317 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
11318 --
11319 --UPD END
11320 l_prev_pk_id number := null ;
11321 l_first_rec boolean := true ;
11322 r_DCE c_DCE%rowtype;
11323 l_dpnt_cvg_eligy_prfl_id number ;
11324 l_object_version_number number ;
11325 l_effective_start_date date ;
11326 l_effective_end_date date ;
11327 l_prefix pqh_copy_entity_attribs.information1%type := null;
11328 l_suffix pqh_copy_entity_attribs.information1%type := null;
11329 l_new_value number(15);
11330 l_object_found_in_target boolean := false ;
11331 l_min_esd date;
11332 l_max_eed date;
11333 l_DPNT_CVG_ELIG_DET_RL number;
11334 l_REGN_ID number;
11335 l_effective_date date;
11336 --
11337 begin
11338 -- Initialization
11339 l_object_found_in_target := false ;
11340 -- End Initialization
11341 -- Derive the prefix - sufix
11342 if p_prefix_suffix_cd = 'PREFIX' then
11343 l_prefix := p_prefix_suffix_text ;
11344 elsif p_prefix_suffix_cd = 'SUFFIX' then
11345 l_suffix := p_prefix_suffix_text ;
11346 else
11347 l_prefix := null ;
11348 l_suffix := null ;
11349 end if ;
11350 -- End Prefix Sufix derivation
11351 for r_DCE_unique in c_unique_DCE('DCE') loop
11352
11353 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
11354 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11355 r_DCE_unique.information3 >=
11356 ben_pd_copy_to_ben_one.g_copy_effective_date)
11357 ) then
11358 --
11359 hr_utility.set_location(' r_DCE_unique.table_route_id '||r_DCE_unique.table_route_id,10);
11360 hr_utility.set_location(' r_DCE_unique.information1 '||r_DCE_unique.information1,10);
11361 hr_utility.set_location( 'r_DCE_unique.information2 '||r_DCE_unique.information2,10);
11362 hr_utility.set_location( 'r_DCE_unique.information3 '||r_DCE_unique.information3,10);
11363 -- If reuse objects flag is 'Y' then check for the object in the target business group
11364 -- if found insert the record into PLSql table and exit the loop else try create the
11365 -- object in the target business group
11366 --
11367 l_object_found_in_target := false ;
11368 --UPD START
11369 l_update := false;
11370 l_process_date := p_effective_date;
11371 l_dml_operation:= r_DCE_unique.dml_operation ;
11372 --
11373 if l_dml_operation = 'UPDATE' then
11374 --
11375 l_object_found_in_target := TRUE;
11376 --
11377 if l_process_date between r_DCE_unique.information2 and r_DCE_unique.information3 then
11378 l_update := true;
11379 if r_DCE_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
11380 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'DPNT_CVG_ELIGY_PRFL_ID' then
11381 g_pk_tbl(g_count).pk_id_column := 'DPNT_CVG_ELIGY_PRFL_ID' ;
11382 g_pk_tbl(g_count).old_value := r_DCE_unique.information1 ;
11383 g_pk_tbl(g_count).new_value := r_DCE_unique.information1 ;
11384 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
11385 g_pk_tbl(g_count).table_route_id := r_DCE_unique.table_route_id;
11386 --
11387 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
11388 --
11389 g_count := g_count + 1 ;
11390 --
11391 log_data('DCE',l_new_value,l_prefix || r_DCE_unique.name|| l_suffix,'REUSED');
11392 --
11393 end if ;
11394 hr_utility.set_location( 'found record for update',10);
11395 --
11396 else
11397 --
11398 l_update := false;
11399 --
11400 end if;
11401 else
11402 --
11403 --UPD END
11404 l_min_esd := null ;
11405 l_max_eed := null ;
11406 open c_DCE_min_max_dates(r_DCE_unique.table_route_id, r_DCE_unique.information1 ) ;
11407 fetch c_DCE_min_max_dates into l_min_esd,l_max_eed ;
11408
11409 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11410 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
11411 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
11412 end if;
11413 l_min_esd := greatest(l_min_esd,r_DCE_unique.information2);
11414
11415 if p_reuse_object_flag = 'Y' then
11416 if c_DCE_min_max_dates%found then
11417 -- cursor to find the object
11418 open c_find_DCE_in_target( l_prefix || r_DCE_unique.name || l_suffix ,l_min_esd,l_max_eed,
11419 p_target_business_group_id, nvl(l_dpnt_cvg_eligy_prfl_id, -999) ) ;
11420 fetch c_find_DCE_in_target into l_new_value ;
11421 if c_find_DCE_in_target%found then
11422 --
11423 --TEMPIK
11424 l_dt_rec_found := dt_api.check_min_max_dates
11425 (p_base_table_name => 'BEN_DPNT_CVG_ELIGY_PRFL_F',
11426 p_base_key_column => 'DPNT_CVG_ELIGY_PRFL_ID',
11427 p_base_key_value => l_new_value,
11428 p_from_date => l_min_esd,
11429 p_to_date => l_max_eed );
11430 if l_dt_rec_found THEN
11431 --END TEMPIK
11432 if r_DCE_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
11433 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'DPNT_CVG_ELIGY_PRFL_ID' then
11434 g_pk_tbl(g_count).pk_id_column := 'DPNT_CVG_ELIGY_PRFL_ID' ;
11435 g_pk_tbl(g_count).old_value := r_DCE_unique.information1 ;
11436 g_pk_tbl(g_count).new_value := l_new_value ;
11437 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
11438 g_pk_tbl(g_count).table_route_id := r_DCE_unique.table_route_id;
11439 --
11440 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
11441 --
11442 g_count := g_count + 1 ;
11443 --
11444 log_data('DCE',l_new_value,l_prefix || r_DCE_unique.name || l_suffix,'REUSED');
11445 --
11446 end if ;
11447 --
11448 l_object_found_in_target := true ;
11449 --TEMPIK
11450 end if; -- l_dt_rec_found
11451 --END TEMPIK
11452 end if;
11453 close c_find_DCE_in_target ;
11454 --
11455 end if;
11456 end if ;
11457 --
11458 close c_DCE_min_max_dates ;
11459 end if;
11460 if not l_object_found_in_target or l_update then
11461 --
11462 open c_DCE(r_DCE_unique.table_route_id,
11463 r_DCE_unique.information1,
11464 r_DCE_unique.information2,
11465 r_DCE_unique.information3 ) ;
11466 --
11467 fetch c_DCE into r_DCE ;
11468 --
11469 close c_DCE ;
11470 --
11471 l_current_pk_id := r_DCE.information1;
11472 --
11473 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
11474 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
11475 --
11476 if l_current_pk_id = l_prev_pk_id then
11477 --
11478 l_first_rec := false ;
11479 --
11480 else
11481 --
11482 l_first_rec := true ;
11483 --
11484 end if ;
11485 --
11486 l_DPNT_CVG_ELIG_DET_RL := get_fk('FORMULA_ID', r_DCE.INFORMATION257,l_dml_operation);
11487 l_REGN_ID := get_fk('REGN_ID', r_DCE.INFORMATION231,l_dml_operation);
11488 --
11489 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_DPNT_CVG_ELIGY_PRFL_F',l_prefix || r_DCE.INFORMATION170 || l_suffix);
11490 --
11491
11492 l_effective_date := r_DCE.information2;
11493 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
11494 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
11495 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
11496 end if;
11497
11498 if l_first_rec and not l_update then
11499 -- Call Create routine.
11500 hr_utility.set_location(' BEN_DPNT_CVG_ELIGY_PRFL_F CREATE_DPNT_CVG_ELIG_PRFL ',20);
11501 BEN_DPNT_CVG_ELIG_PRFL_API.CREATE_DPNT_CVG_ELIG_PRFL(
11502 --
11503 P_VALIDATE => false
11504 ,P_EFFECTIVE_DATE => l_effective_date
11505 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11506 --
11507 ,P_DCE_ATTRIBUTE1 => r_DCE.INFORMATION111
11508 ,P_DCE_ATTRIBUTE10 => r_DCE.INFORMATION120
11509 ,P_DCE_ATTRIBUTE11 => r_DCE.INFORMATION121
11510 ,P_DCE_ATTRIBUTE12 => r_DCE.INFORMATION122
11511 ,P_DCE_ATTRIBUTE13 => r_DCE.INFORMATION123
11512 ,P_DCE_ATTRIBUTE14 => r_DCE.INFORMATION124
11513 ,P_DCE_ATTRIBUTE15 => r_DCE.INFORMATION125
11514 ,P_DCE_ATTRIBUTE16 => r_DCE.INFORMATION126
11515 ,P_DCE_ATTRIBUTE17 => r_DCE.INFORMATION127
11516 ,P_DCE_ATTRIBUTE18 => r_DCE.INFORMATION128
11517 ,P_DCE_ATTRIBUTE19 => r_DCE.INFORMATION129
11518 ,P_DCE_ATTRIBUTE2 => r_DCE.INFORMATION112
11519 ,P_DCE_ATTRIBUTE20 => r_DCE.INFORMATION130
11520 ,P_DCE_ATTRIBUTE21 => r_DCE.INFORMATION131
11521 ,P_DCE_ATTRIBUTE22 => r_DCE.INFORMATION132
11522 ,P_DCE_ATTRIBUTE23 => r_DCE.INFORMATION133
11523 ,P_DCE_ATTRIBUTE24 => r_DCE.INFORMATION134
11524 ,P_DCE_ATTRIBUTE25 => r_DCE.INFORMATION135
11525 ,P_DCE_ATTRIBUTE26 => r_DCE.INFORMATION136
11526 ,P_DCE_ATTRIBUTE27 => r_DCE.INFORMATION137
11527 ,P_DCE_ATTRIBUTE28 => r_DCE.INFORMATION138
11528 ,P_DCE_ATTRIBUTE29 => r_DCE.INFORMATION139
11529 ,P_DCE_ATTRIBUTE3 => r_DCE.INFORMATION113
11530 ,P_DCE_ATTRIBUTE30 => r_DCE.INFORMATION140
11531 ,P_DCE_ATTRIBUTE4 => r_DCE.INFORMATION114
11532 ,P_DCE_ATTRIBUTE5 => r_DCE.INFORMATION115
11533 ,P_DCE_ATTRIBUTE6 => r_DCE.INFORMATION116
11534 ,P_DCE_ATTRIBUTE7 => r_DCE.INFORMATION117
11535 ,P_DCE_ATTRIBUTE8 => r_DCE.INFORMATION118
11536 ,P_DCE_ATTRIBUTE9 => r_DCE.INFORMATION119
11537 ,P_DCE_ATTRIBUTE_CATEGORY => r_DCE.INFORMATION110
11538 ,P_DCE_DESC => r_DCE.INFORMATION185
11539 ,P_DPNT_AGE_FLAG => r_DCE.INFORMATION13
11540 ,P_DPNT_CVG_ELIGY_PRFL_ID => l_dpnt_cvg_eligy_prfl_id
11541 ,P_DPNT_CVG_ELIGY_PRFL_STAT_CD => r_DCE.INFORMATION11
11542 ,P_DPNT_CVG_ELIG_DET_RL => l_DPNT_CVG_ELIG_DET_RL
11543 ,P_DPNT_CVRD_IN_ANTHR_PL_FLAG => r_DCE.INFORMATION19
11544 ,P_DPNT_DSBLD_FLAG => r_DCE.INFORMATION15
11545 ,P_DPNT_DSGNT_CRNTLY_ENRLD_FLAG => r_DCE.INFORMATION20
11546 ,P_DPNT_MLTRY_FLAG => r_DCE.INFORMATION17
11547 ,P_DPNT_MRTL_FLAG => r_DCE.INFORMATION16
11548 ,P_DPNT_PSTL_FLAG => r_DCE.INFORMATION18
11549 ,P_DPNT_RLSHP_FLAG => r_DCE.INFORMATION12
11550 ,P_DPNT_STUD_FLAG => r_DCE.INFORMATION14
11551 ,P_NAME => l_prefix || r_DCE.INFORMATION170 || l_suffix
11552 ,P_REGN_ID => l_REGN_ID
11553 --
11554 ,P_EFFECTIVE_START_DATE => l_effective_start_date
11555 ,P_EFFECTIVE_END_DATE => l_effective_end_date
11556 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11557 );
11558 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11559 -- Update all relevent cer records with new pk_id
11560 hr_utility.set_location('Before plsql table ',222);
11561 hr_utility.set_location('new_value id '||l_dpnt_cvg_eligy_prfl_id,222);
11562 g_pk_tbl(g_count).pk_id_column := 'DPNT_CVG_ELIGY_PRFL_ID' ;
11563 g_pk_tbl(g_count).old_value := r_DCE.information1 ;
11564 g_pk_tbl(g_count).new_value := l_DPNT_CVG_ELIGY_PRFL_ID ;
11565 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
11566 g_pk_tbl(g_count).table_route_id := r_DCE_unique.table_route_id;
11567 hr_utility.set_location('After plsql table ',222);
11568 --
11569 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
11570 --
11571 g_count := g_count + 1 ;
11572 --
11573 --
11574 log_data('DCE',l_new_value,l_prefix || r_DCE.INFORMATION170 || l_suffix,'COPIED');
11575 --
11576 else
11577 --
11578 --UPD START
11579 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
11580 --
11581 if l_update then
11582 --
11583 l_datetrack_mode := r_DCE.datetrack_mode ;
11584 --
11585 get_dt_modes(
11586 p_effective_date => l_process_date,
11587 p_effective_end_date => r_DCE.information3,
11588 p_effective_start_date => r_DCE.information2,
11589 p_dml_operation => r_DCE.dml_operation,
11590 p_datetrack_mode => l_datetrack_mode );
11591 -- p_update => l_update
11592 --
11593 l_effective_date := l_process_date;
11594 l_DPNT_CVG_ELIGY_PRFL_ID := r_DCE.information1;
11595 l_object_version_number := r_DCE.information265;
11596 --
11597 end if;
11598 --
11599 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
11600 --
11601 IF l_update OR l_dml_operation <> 'UPDATE' THEN
11602 --UPD END
11603 -- Call Update routine for the pk_id created in prev run .
11604 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11605 hr_utility.set_location(' BEN_DPNT_CVG_ELIGY_PRFL_F UPDATE_DPNT_CVG_ELIG_PRFL ',30);
11606 BEN_DPNT_CVG_ELIG_PRFL_API.UPDATE_DPNT_CVG_ELIG_PRFL(
11607 --
11608 P_VALIDATE => false
11609 ,P_EFFECTIVE_DATE => l_effective_date
11610 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11611 --
11612 ,P_DCE_ATTRIBUTE1 => r_DCE.INFORMATION111
11613 ,P_DCE_ATTRIBUTE10 => r_DCE.INFORMATION120
11614 ,P_DCE_ATTRIBUTE11 => r_DCE.INFORMATION121
11615 ,P_DCE_ATTRIBUTE12 => r_DCE.INFORMATION122
11616 ,P_DCE_ATTRIBUTE13 => r_DCE.INFORMATION123
11617 ,P_DCE_ATTRIBUTE14 => r_DCE.INFORMATION124
11618 ,P_DCE_ATTRIBUTE15 => r_DCE.INFORMATION125
11619 ,P_DCE_ATTRIBUTE16 => r_DCE.INFORMATION126
11620 ,P_DCE_ATTRIBUTE17 => r_DCE.INFORMATION127
11621 ,P_DCE_ATTRIBUTE18 => r_DCE.INFORMATION128
11622 ,P_DCE_ATTRIBUTE19 => r_DCE.INFORMATION129
11623 ,P_DCE_ATTRIBUTE2 => r_DCE.INFORMATION112
11624 ,P_DCE_ATTRIBUTE20 => r_DCE.INFORMATION130
11625 ,P_DCE_ATTRIBUTE21 => r_DCE.INFORMATION131
11626 ,P_DCE_ATTRIBUTE22 => r_DCE.INFORMATION132
11627 ,P_DCE_ATTRIBUTE23 => r_DCE.INFORMATION133
11628 ,P_DCE_ATTRIBUTE24 => r_DCE.INFORMATION134
11629 ,P_DCE_ATTRIBUTE25 => r_DCE.INFORMATION135
11630 ,P_DCE_ATTRIBUTE26 => r_DCE.INFORMATION136
11631 ,P_DCE_ATTRIBUTE27 => r_DCE.INFORMATION137
11632 ,P_DCE_ATTRIBUTE28 => r_DCE.INFORMATION138
11633 ,P_DCE_ATTRIBUTE29 => r_DCE.INFORMATION139
11634 ,P_DCE_ATTRIBUTE3 => r_DCE.INFORMATION113
11635 ,P_DCE_ATTRIBUTE30 => r_DCE.INFORMATION140
11636 ,P_DCE_ATTRIBUTE4 => r_DCE.INFORMATION114
11637 ,P_DCE_ATTRIBUTE5 => r_DCE.INFORMATION115
11638 ,P_DCE_ATTRIBUTE6 => r_DCE.INFORMATION116
11639 ,P_DCE_ATTRIBUTE7 => r_DCE.INFORMATION117
11640 ,P_DCE_ATTRIBUTE8 => r_DCE.INFORMATION118
11641 ,P_DCE_ATTRIBUTE9 => r_DCE.INFORMATION119
11642 ,P_DCE_ATTRIBUTE_CATEGORY => r_DCE.INFORMATION110
11643 ,P_DCE_DESC => r_DCE.INFORMATION185
11644 ,P_DPNT_AGE_FLAG => r_DCE.INFORMATION13
11645 ,P_DPNT_CVG_ELIGY_PRFL_ID => l_dpnt_cvg_eligy_prfl_id
11646 ,P_DPNT_CVG_ELIGY_PRFL_STAT_CD => r_DCE.INFORMATION11
11647 ,P_DPNT_CVG_ELIG_DET_RL => l_DPNT_CVG_ELIG_DET_RL
11648 ,P_DPNT_CVRD_IN_ANTHR_PL_FLAG => r_DCE.INFORMATION19
11649 ,P_DPNT_DSBLD_FLAG => r_DCE.INFORMATION15
11650 ,P_DPNT_DSGNT_CRNTLY_ENRLD_FLAG => r_DCE.INFORMATION20
11651 ,P_DPNT_MLTRY_FLAG => r_DCE.INFORMATION17
11652 ,P_DPNT_MRTL_FLAG => r_DCE.INFORMATION16
11653 ,P_DPNT_PSTL_FLAG => r_DCE.INFORMATION18
11654 ,P_DPNT_RLSHP_FLAG => r_DCE.INFORMATION12
11655 ,P_DPNT_STUD_FLAG => r_DCE.INFORMATION14
11656 ,P_NAME => l_prefix || r_DCE.INFORMATION170 || l_suffix
11657 ,P_REGN_ID => l_REGN_ID
11658 --
11659 ,P_EFFECTIVE_START_DATE => l_effective_start_date
11660 ,P_EFFECTIVE_END_DATE => l_effective_end_date
11661 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11662 ,P_DATETRACK_MODE => l_datetrack_mode
11663 );
11664 --
11665 end if;
11666 end if;
11667 --
11668 -- Delete the row if it is end dated.
11669 --
11670 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
11671 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
11672 trunc(l_max_eed) = r_DCE.information3) then
11673 --
11674 BEN_DPNT_CVG_ELIG_PRFL_API.delete_DPNT_CVG_ELIG_PRFL(
11675 --
11676 p_validate => false
11677 ,p_dpnt_cvg_eligy_prfl_id => l_dpnt_cvg_eligy_prfl_id
11678 ,p_effective_start_date => l_effective_start_date
11679 ,p_effective_end_date => l_effective_end_date
11680 ,p_object_version_number => l_object_version_number
11681 ,p_effective_date => l_max_eed
11682 ,p_datetrack_mode => hr_api.g_delete
11683 --
11684 );
11685 --
11686 end if;
11687 --
11688 l_prev_pk_id := l_current_pk_id ;
11689 --
11690 end if;
11691 --
11692 end if;
11693 --
11694 end loop;
11695 --
11696 exception when others then
11697 --
11698 raise_error_message( 'DCE',l_prefix || r_DCE.INFORMATION170 || l_suffix) ;
11699 --
11700 end create_DCE_rows;
11701 --
11702 ---------------------------------------------------------------
11703 ----------------------< create_GOS_rows >-----------------------
11704 ---------------------------------------------------------------
11705 --
11706 procedure create_GOS_rows
11707 (
11708 p_validate in number default 0
11709 ,p_copy_entity_txn_id in number
11710 ,p_effective_date in date
11711 ,p_prefix_suffix_text in varchar2 default null
11712 ,p_reuse_object_flag in varchar2 default null
11713 ,p_target_business_group_id in varchar2 default null
11714 ,p_prefix_suffix_cd in varchar2 default null
11715 ) is
11716 --
11717 cursor c_unique_GOS(l_table_alias varchar2) is
11718 select distinct cpe.information1,
11719 cpe.information2,
11720 cpe.information3,
11721 cpe.INFORMATION170 name,
11722 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
11723 from ben_copy_entity_results cpe,
11724 pqh_table_route tr
11725 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11726 and cpe.table_route_id = tr.table_route_id
11727 -- and tr.where_clause = l_BEN_GD_OR_SVC_TYP
11728 and tr.table_alias = l_table_alias
11729 and cpe.number_of_copies = 1 --ADDITION
11730 group by cpe.information1,cpe.information2,cpe.information3,
11731 cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
11732 order by information1, information2; --added for bug: 5151945
11733 --
11734 --
11735 cursor c_GOS_min_max_dates(c_table_route_id number,
11736 c_information1 number) is
11737 select
11738 min(cpe.information2) min_esd,
11739 max(cpe.information3) min_eed
11740 from ben_copy_entity_results cpe
11741 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11742 and cpe.table_route_id = c_table_route_id
11743 and cpe.information1 = c_information1 ;
11744 --
11745 cursor c_GOS(c_table_route_id number,
11746 c_information1 number,
11747 c_information2 date,
11748 c_information3 date ) is
11749 select
11750 cpe.*
11751 from ben_copy_entity_results cpe
11752 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
11753 and cpe.table_route_id = c_table_route_id
11754 and cpe.information1 = c_information1
11755 and rownum = 1 ;
11756 -- Date Track target record
11757 cursor c_find_GOS_in_target( c_GOS_name varchar2,
11758 c_effective_start_date date,
11759 c_effective_end_date date,
11760 c_business_group_id number,
11761 c_new_pk_id number) is
11762 select
11763 GOS.gd_or_svc_typ_id new_value
11764 from BEN_GD_OR_SVC_TYP GOS
11765 where GOS.name = c_GOS_name
11766 and GOS.business_group_id = c_business_group_id
11767 and GOS.gd_or_svc_typ_id <> c_new_pk_id
11768 ;
11769 --
11770 l_current_pk_id number := null ;
11771 --UPD START
11772 --
11773 l_update boolean := false ;
11774 l_datetrack_mode varchar2(80) := hr_api.g_update;
11775 l_process_date date;
11776 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
11777 --
11778 --UPD END
11779 l_prev_pk_id number := null ;
11780 l_first_rec boolean := true ;
11781 r_GOS c_GOS%rowtype;
11782 l_gd_or_svc_typ_id number ;
11783 l_object_version_number number ;
11784 l_effective_start_date date ;
11785 l_effective_end_date date ;
11786 l_prefix pqh_copy_entity_attribs.information1%type := null;
11787 l_suffix pqh_copy_entity_attribs.information1%type := null;
11788 l_new_value number(15);
11789 l_object_found_in_target boolean := false ;
11790 l_min_esd date;
11791 l_max_eed date;
11792 --
11793 begin
11794 -- Initialization
11795 l_object_found_in_target := false ;
11796 -- End Initialization
11797 -- Derive the prefix - sufix
11798 if p_prefix_suffix_cd = 'PREFIX' then
11799 l_prefix := p_prefix_suffix_text ;
11800 elsif p_prefix_suffix_cd = 'SUFFIX' then
11801 l_suffix := p_prefix_suffix_text ;
11802 else
11803 l_prefix := null ;
11804 l_suffix := null ;
11805 end if ;
11806 -- End Prefix Sufix derivation
11807 for r_GOS_unique in c_unique_GOS('GOS') loop
11808 --
11809 hr_utility.set_location(' r_GOS_unique.table_route_id '||r_GOS_unique.table_route_id,10);
11810 hr_utility.set_location(' r_GOS_unique.information1 '||r_GOS_unique.information1,10);
11811 hr_utility.set_location( 'r_GOS_unique.information2 '||r_GOS_unique.information2,10);
11812 hr_utility.set_location( 'r_GOS_unique.information3 '||r_GOS_unique.information3,10);
11813 -- If reuse objects flag is 'Y' then check for the object in the target business group
11814 -- if found insert the record into PLSql table and exit the loop else try create the
11815 -- object in the target business group
11816 --
11817 l_object_found_in_target := false ;
11818 --UPD START
11819 l_dml_operation := r_GOS_unique.dml_operation;
11820 --
11821 l_update := false;
11822 --
11823 if l_dml_operation = 'UPDATE' then
11824 --
11825 l_update := true;
11826 if r_GOS_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
11827 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'GD_OR_SVC_TYP_ID' then
11828 g_pk_tbl(g_count).pk_id_column := 'GD_OR_SVC_TYP_ID' ;
11829 g_pk_tbl(g_count).old_value := r_GOS_unique.information1 ;
11830 g_pk_tbl(g_count).new_value := r_GOS_unique.information1 ;
11831 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
11832 g_pk_tbl(g_count).table_route_id := r_GOS_unique.table_route_id;
11833 --
11834 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ; -- NEW
11835 --
11836 g_count := g_count + 1 ;
11837 --
11838 log_data('GOS',l_new_value,l_prefix || r_GOS_unique.name|| l_suffix,'REUSED');
11839 --
11840 end if ;
11841 l_GD_OR_SVC_TYP_ID := r_GOS_unique.information1 ;
11842 l_object_version_number := r_GOS.information265 ;
11843 hr_utility.set_location( 'found record for update',10);
11844 --
11845 else
11846 l_min_esd := null ;
11847 l_max_eed := null ;
11848 if p_reuse_object_flag = 'Y' then
11849 -- cursor to find the object
11850 open c_find_GOS_in_target( l_prefix || r_GOS_unique.name || l_suffix ,r_GOS_unique.information2,l_max_eed,
11851 p_target_business_group_id, nvl(l_gd_or_svc_typ_id, -999) ) ;
11852 fetch c_find_GOS_in_target into l_new_value ;
11853 if c_find_GOS_in_target%found then
11854 --
11855 if r_GOS_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
11856 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'GD_OR_SVC_TYP_ID' then
11857 g_pk_tbl(g_count).pk_id_column := 'GD_OR_SVC_TYP_ID' ;
11858 g_pk_tbl(g_count).old_value := r_GOS_unique.information1 ;
11859 g_pk_tbl(g_count).new_value := l_new_value ;
11860 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
11861 g_pk_tbl(g_count).table_route_id := r_GOS_unique.table_route_id;
11862 --
11863 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
11864 --
11865 g_count := g_count + 1 ;
11866 --
11867 log_data('GOS',l_new_value,l_prefix || r_GOS_unique.name || l_suffix ,'REUSED');
11868 --
11869 end if ;
11870 --
11871 l_object_found_in_target := true ;
11872 end if;
11873 close c_find_GOS_in_target ;
11874 --
11875 end if ;
11876 --
11877 end if;
11878 if not l_object_found_in_target or l_update then
11879 --
11880 open c_GOS(r_GOS_unique.table_route_id,
11881 r_GOS_unique.information1,
11882 r_GOS_unique.information2,
11883 r_GOS_unique.information3 ) ;
11884 --
11885 fetch c_GOS into r_GOS ;
11886 --
11887 close c_GOS ;
11888 --
11889 l_current_pk_id := r_GOS.information1;
11890 --
11891 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
11892 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
11893 --
11894 if l_current_pk_id = l_prev_pk_id then
11895 --
11896 l_first_rec := false ;
11897 --
11898 else
11899 --
11900 l_first_rec := true ;
11901 --
11902 end if ;
11903 --
11904 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_GD_OR_SVC_TYP',l_prefix || r_GOS.INFORMATION170 || l_suffix);
11905 --
11906 if l_first_rec and not l_update then
11907 -- Call Create routine.
11908 hr_utility.set_location(' BEN_GD_OR_SVC_TYP CREATE_GOOD_SVC_TYPE ',20);
11909 BEN_GOOD_SVC_TYPE_API.CREATE_GOOD_SVC_TYPE(
11910 --
11911 P_VALIDATE => false
11912 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
11913 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11914 --
11915 ,P_DESCRIPTION => r_GOS.INFORMATION185
11916 ,P_GD_OR_SVC_TYP_ID => l_gd_or_svc_typ_id
11917 ,P_GOS_ATTRIBUTE1 => r_GOS.INFORMATION111
11918 ,P_GOS_ATTRIBUTE10 => r_GOS.INFORMATION120
11919 ,P_GOS_ATTRIBUTE11 => r_GOS.INFORMATION121
11920 ,P_GOS_ATTRIBUTE12 => r_GOS.INFORMATION122
11921 ,P_GOS_ATTRIBUTE13 => r_GOS.INFORMATION123
11922 ,P_GOS_ATTRIBUTE14 => r_GOS.INFORMATION124
11923 ,P_GOS_ATTRIBUTE15 => r_GOS.INFORMATION125
11924 ,P_GOS_ATTRIBUTE16 => r_GOS.INFORMATION126
11925 ,P_GOS_ATTRIBUTE17 => r_GOS.INFORMATION127
11926 ,P_GOS_ATTRIBUTE18 => r_GOS.INFORMATION128
11927 ,P_GOS_ATTRIBUTE19 => r_GOS.INFORMATION129
11928 ,P_GOS_ATTRIBUTE2 => r_GOS.INFORMATION112
11929 ,P_GOS_ATTRIBUTE20 => r_GOS.INFORMATION130
11930 ,P_GOS_ATTRIBUTE21 => r_GOS.INFORMATION131
11931 ,P_GOS_ATTRIBUTE22 => r_GOS.INFORMATION132
11932 ,P_GOS_ATTRIBUTE23 => r_GOS.INFORMATION133
11933 ,P_GOS_ATTRIBUTE24 => r_GOS.INFORMATION134
11934 ,P_GOS_ATTRIBUTE25 => r_GOS.INFORMATION135
11935 ,P_GOS_ATTRIBUTE26 => r_GOS.INFORMATION136
11936 ,P_GOS_ATTRIBUTE27 => r_GOS.INFORMATION137
11937 ,P_GOS_ATTRIBUTE28 => r_GOS.INFORMATION138
11938 ,P_GOS_ATTRIBUTE29 => r_GOS.INFORMATION139
11939 ,P_GOS_ATTRIBUTE3 => r_GOS.INFORMATION113
11940 ,P_GOS_ATTRIBUTE30 => r_GOS.INFORMATION140
11941 ,P_GOS_ATTRIBUTE4 => r_GOS.INFORMATION114
11942 ,P_GOS_ATTRIBUTE5 => r_GOS.INFORMATION115
11943 ,P_GOS_ATTRIBUTE6 => r_GOS.INFORMATION116
11944 ,P_GOS_ATTRIBUTE7 => r_GOS.INFORMATION117
11945 ,P_GOS_ATTRIBUTE8 => r_GOS.INFORMATION118
11946 ,P_GOS_ATTRIBUTE9 => r_GOS.INFORMATION119
11947 ,P_GOS_ATTRIBUTE_CATEGORY => r_GOS.INFORMATION110
11948 ,P_NAME => l_prefix || r_GOS.INFORMATION170 || l_suffix
11949 ,P_TYP_CD => r_GOS.INFORMATION11
11950 --
11951 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
11952 );
11953 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
11954 -- Update all relevent cer records with new pk_id
11955 hr_utility.set_location('Before plsql table ',222);
11956 hr_utility.set_location('new_value id '||l_gd_or_svc_typ_id,222);
11957 g_pk_tbl(g_count).pk_id_column := 'GD_OR_SVC_TYP_ID' ;
11958 g_pk_tbl(g_count).old_value := r_GOS.information1 ;
11959 g_pk_tbl(g_count).new_value := l_GD_OR_SVC_TYP_ID ;
11960 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
11961 g_pk_tbl(g_count).table_route_id := r_GOS_unique.table_route_id;
11962 hr_utility.set_location('After plsql table ',222);
11963 --
11964 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
11965 --
11966 g_count := g_count + 1 ;
11967 --
11968 log_data('GOS',l_new_value,l_prefix || r_GOS.INFORMATION170 || l_suffix,'COPIED');
11969 --
11970 elsif l_update then
11971 --
11972 hr_utility.set_location(' BEN_GD_OR_SVC_TYP UPDATE_GOOD_SVC_TYPE ',20);
11973 BEN_GOOD_SVC_TYPE_API.UPDATE_GOOD_SVC_TYPE(
11974 --
11975 P_VALIDATE => false
11976 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
11977 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
11978 --
11979 ,P_DESCRIPTION => r_GOS.INFORMATION185
11980 ,P_GD_OR_SVC_TYP_ID => l_gd_or_svc_typ_id
11981 ,P_GOS_ATTRIBUTE1 => r_GOS.INFORMATION111
11982 ,P_GOS_ATTRIBUTE10 => r_GOS.INFORMATION120
11983 ,P_GOS_ATTRIBUTE11 => r_GOS.INFORMATION121
11984 ,P_GOS_ATTRIBUTE12 => r_GOS.INFORMATION122
11985 ,P_GOS_ATTRIBUTE13 => r_GOS.INFORMATION123
11986 ,P_GOS_ATTRIBUTE14 => r_GOS.INFORMATION124
11987 ,P_GOS_ATTRIBUTE15 => r_GOS.INFORMATION125
11988 ,P_GOS_ATTRIBUTE16 => r_GOS.INFORMATION126
11989 ,P_GOS_ATTRIBUTE17 => r_GOS.INFORMATION127
11990 ,P_GOS_ATTRIBUTE18 => r_GOS.INFORMATION128
11991 ,P_GOS_ATTRIBUTE19 => r_GOS.INFORMATION129
11992 ,P_GOS_ATTRIBUTE2 => r_GOS.INFORMATION112
11993 ,P_GOS_ATTRIBUTE20 => r_GOS.INFORMATION130
11994 ,P_GOS_ATTRIBUTE21 => r_GOS.INFORMATION131
11995 ,P_GOS_ATTRIBUTE22 => r_GOS.INFORMATION132
11996 ,P_GOS_ATTRIBUTE23 => r_GOS.INFORMATION133
11997 ,P_GOS_ATTRIBUTE24 => r_GOS.INFORMATION134
11998 ,P_GOS_ATTRIBUTE25 => r_GOS.INFORMATION135
11999 ,P_GOS_ATTRIBUTE26 => r_GOS.INFORMATION136
12000 ,P_GOS_ATTRIBUTE27 => r_GOS.INFORMATION137
12001 ,P_GOS_ATTRIBUTE28 => r_GOS.INFORMATION138
12002 ,P_GOS_ATTRIBUTE29 => r_GOS.INFORMATION139
12003 ,P_GOS_ATTRIBUTE3 => r_GOS.INFORMATION113
12004 ,P_GOS_ATTRIBUTE30 => r_GOS.INFORMATION140
12005 ,P_GOS_ATTRIBUTE4 => r_GOS.INFORMATION114
12006 ,P_GOS_ATTRIBUTE5 => r_GOS.INFORMATION115
12007 ,P_GOS_ATTRIBUTE6 => r_GOS.INFORMATION116
12008 ,P_GOS_ATTRIBUTE7 => r_GOS.INFORMATION117
12009 ,P_GOS_ATTRIBUTE8 => r_GOS.INFORMATION118
12010 ,P_GOS_ATTRIBUTE9 => r_GOS.INFORMATION119
12011 ,P_GOS_ATTRIBUTE_CATEGORY => r_GOS.INFORMATION110
12012 ,P_NAME => l_prefix || r_GOS.INFORMATION170 || l_suffix
12013 ,P_TYP_CD => r_GOS.INFORMATION11
12014 --
12015 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12016 );
12017 end if;
12018 --
12019 l_prev_pk_id := l_current_pk_id ;
12020 --
12021 end if;
12022 --
12023 end loop;
12024 --
12025 exception when others then
12026 --
12027 raise_error_message( 'GOS',l_prefix || r_GOS.INFORMATION170 || l_suffix) ;
12028 --
12029 end create_GOS_rows;
12030 --
12031 ---------------------------------------------------------------
12032 ----------------------< create_BNG_rows >-----------------------
12033 ---------------------------------------------------------------
12034 --
12035 procedure create_BNG_rows
12036 (
12037 p_validate in number default 0
12038 ,p_copy_entity_txn_id in number
12039 ,p_effective_date in date
12040 ,p_prefix_suffix_text in varchar2 default null
12041 ,p_reuse_object_flag in varchar2 default null
12042 ,p_target_business_group_id in varchar2 default null
12043 ,p_prefix_suffix_cd in varchar2 default null
12044 ) is
12045 --
12046 cursor c_unique_BNG(l_table_alias varchar2) is
12047 select distinct cpe.information1,
12048 cpe.information2,
12049 cpe.information3,
12050 cpe.INFORMATION170 name,
12051 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
12052 from ben_copy_entity_results cpe,
12053 pqh_table_route tr
12054 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12055 and cpe.table_route_id = tr.table_route_id
12056 -- and tr.where_clause = l_BEN_BENFTS_GRP
12057 and tr.table_alias = l_table_alias
12058 and cpe.number_of_copies = 1 --ADDITION
12059 group by cpe.information1,cpe.information2,cpe.information3,
12060 cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
12061 order by information1, information2; --added for bug: 5151945
12062 --
12063 --
12064 cursor c_BNG_min_max_dates(c_table_route_id number,
12065 c_information1 number) is
12066 select
12067 min(cpe.information2) min_esd,
12068 max(cpe.information3) min_eed
12069 from ben_copy_entity_results cpe
12070 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12071 and cpe.table_route_id = c_table_route_id
12072 and cpe.information1 = c_information1 ;
12073 --
12074 cursor c_BNG(c_table_route_id number,
12075 c_information1 number,
12076 c_information2 date,
12077 c_information3 date ) is
12078 select
12079 cpe.*
12080 from ben_copy_entity_results cpe
12081 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12082 and cpe.table_route_id = c_table_route_id
12083 and cpe.information1 = c_information1
12084 and rownum = 1 ;
12085 -- Date Track target record
12086 cursor c_find_BNG_in_target( c_BNG_name varchar2,
12087 c_effective_start_date date,
12088 c_effective_end_date date,
12089 c_business_group_id number,
12090 c_new_pk_id number) is
12091 select
12092 BNG.benfts_grp_id new_value
12093 from BEN_BENFTS_GRP BNG
12094 where BNG.name = c_BNG_name
12095 and BNG.business_group_id = c_business_group_id
12096 and BNG.benfts_grp_id <> c_new_pk_id
12097 ;
12098 --
12099 l_current_pk_id number := null ;
12100 --UPD START
12101 --
12102 l_update boolean := false ;
12103 l_datetrack_mode varchar2(80) := hr_api.g_update;
12104 l_process_date date;
12105 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
12106 --
12107 --UPD END
12108 l_prev_pk_id number := null ;
12109 l_first_rec boolean := true ;
12110 r_BNG c_BNG%rowtype;
12111 l_benfts_grp_id number ;
12112 l_object_version_number number ;
12113 l_effective_start_date date ;
12114 l_effective_end_date date ;
12115 l_prefix pqh_copy_entity_attribs.information1%type := null;
12116 l_suffix pqh_copy_entity_attribs.information1%type := null;
12117 l_new_value number(15);
12118 l_object_found_in_target boolean := false ;
12119 l_min_esd date;
12120 l_max_eed date;
12121 --
12122 begin
12123 -- Initialization
12124 l_object_found_in_target := false ;
12125 -- End Initialization
12126 -- Derive the prefix - sufix
12127 if p_prefix_suffix_cd = 'PREFIX' then
12128 l_prefix := p_prefix_suffix_text ;
12129 elsif p_prefix_suffix_cd = 'SUFFIX' then
12130 l_suffix := p_prefix_suffix_text ;
12131 else
12132 l_prefix := null ;
12133 l_suffix := null ;
12134 end if ;
12135 -- End Prefix Sufix derivation
12136 for r_BNG_unique in c_unique_BNG('BNG') loop
12137 --
12138 hr_utility.set_location(' r_BNG_unique.table_route_id '||r_BNG_unique.table_route_id,10);
12139 hr_utility.set_location(' r_BNG_unique.information1 '||r_BNG_unique.information1,10);
12140 hr_utility.set_location( 'r_BNG_unique.information2 '||r_BNG_unique.information2,10);
12141 hr_utility.set_location( 'r_BNG_unique.information3 '||r_BNG_unique.information3,10);
12142 -- If reuse objects flag is 'Y' then check for the object in the target business group
12143 -- if found insert the record into PLSql table and exit the loop else try create the
12144 -- object in the target business group
12145 --
12146 l_object_found_in_target := false ;
12147 l_dml_operation := r_BNG_unique.dml_operation;
12148 --
12149 l_update := false;
12150 --
12151 if l_dml_operation = 'UPDATE' then
12152 --
12153 l_update := true;
12154 if r_BNG_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
12155 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'BENFTS_GRP_ID' then
12156 g_pk_tbl(g_count).pk_id_column := 'BENFTS_GRP_ID' ;
12157 g_pk_tbl(g_count).old_value := r_BNG_unique.information1 ;
12158 g_pk_tbl(g_count).new_value := r_BNG_unique.information1 ;
12159 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
12160 g_pk_tbl(g_count).table_route_id := r_BNG_unique.table_route_id;
12161 --
12162 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ; -- NEW
12163 --
12164 g_count := g_count + 1 ;
12165 --
12166 log_data('BNG',l_new_value,l_prefix || r_BNG_unique.name|| l_suffix,'REUSED');
12167 --
12168 end if ;
12169 l_BENFTS_GRP_ID := r_BNG_unique.information1 ;
12170 l_object_version_number := r_BNG.information265 ;
12171 hr_utility.set_location( 'found record for update',10);
12172 --
12173 else
12174 l_min_esd := null ;
12175 l_max_eed := null ;
12176 if p_reuse_object_flag = 'Y' then
12177 -- cursor to find the object
12178 open c_find_BNG_in_target( l_prefix || r_BNG_unique.name || l_suffix ,r_BNG_unique.information2,l_max_eed,
12179 p_target_business_group_id, nvl(l_benfts_grp_id, -999) ) ;
12180 fetch c_find_BNG_in_target into l_new_value ;
12181 if c_find_BNG_in_target%found then
12182 --
12183 if r_BNG_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
12184 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'BENFTS_GRP_ID' then
12185 g_pk_tbl(g_count).pk_id_column := 'BENFTS_GRP_ID' ;
12186 g_pk_tbl(g_count).old_value := r_BNG_unique.information1 ;
12187 g_pk_tbl(g_count).new_value := l_new_value ;
12188 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
12189 g_pk_tbl(g_count).table_route_id := r_BNG_unique.table_route_id;
12190 --
12191 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
12192 --
12193 g_count := g_count + 1 ;
12194 end if ;
12195 --
12196 l_object_found_in_target := true ;
12197 end if;
12198 close c_find_BNG_in_target ;
12199 --
12200 end if ;
12201 --
12202 end if;
12203 if not l_object_found_in_target or l_update then
12204 --
12205 open c_BNG(r_BNG_unique.table_route_id,
12206 r_BNG_unique.information1,
12207 r_BNG_unique.information2,
12208 r_BNG_unique.information3 ) ;
12209 --
12210 fetch c_BNG into r_BNG ;
12211 --
12212 close c_BNG ;
12213 --
12214 l_current_pk_id := r_BNG.information1;
12215 --
12216 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
12217 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
12218 --
12219 if l_current_pk_id = l_prev_pk_id then
12220 --
12221 l_first_rec := false ;
12222 --
12223 else
12224 --
12225 l_first_rec := true ;
12226 --
12227 end if ;
12228 --
12229 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_BENFTS_GRP',l_prefix || r_BNG.INFORMATION170 || l_suffix);
12230 --
12231 if l_first_rec and not l_update then
12232 -- Call Create routine.
12233 hr_utility.set_location(' BEN_BENFTS_GRP CREATE_BENEFITS_GROUP ',20);
12234 BEN_BENEFITS_GROUP_API.CREATE_BENEFITS_GROUP(
12235 --
12236 P_VALIDATE => false
12237 -- ,P_EFFECTIVE_DATE => p_effective_date
12238 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
12239 --
12240 ,P_BENFTS_GRP_ID => l_benfts_grp_id
12241 ,P_BNG_ATTRIBUTE1 => r_BNG.INFORMATION111
12242 ,P_BNG_ATTRIBUTE10 => r_BNG.INFORMATION120
12243 ,P_BNG_ATTRIBUTE11 => r_BNG.INFORMATION121
12244 ,P_BNG_ATTRIBUTE12 => r_BNG.INFORMATION122
12245 ,P_BNG_ATTRIBUTE13 => r_BNG.INFORMATION123
12246 ,P_BNG_ATTRIBUTE14 => r_BNG.INFORMATION124
12247 ,P_BNG_ATTRIBUTE15 => r_BNG.INFORMATION125
12248 ,P_BNG_ATTRIBUTE16 => r_BNG.INFORMATION126
12249 ,P_BNG_ATTRIBUTE17 => r_BNG.INFORMATION127
12250 ,P_BNG_ATTRIBUTE18 => r_BNG.INFORMATION128
12251 ,P_BNG_ATTRIBUTE19 => r_BNG.INFORMATION129
12252 ,P_BNG_ATTRIBUTE2 => r_BNG.INFORMATION112
12253 ,P_BNG_ATTRIBUTE20 => r_BNG.INFORMATION130
12254 ,P_BNG_ATTRIBUTE21 => r_BNG.INFORMATION131
12255 ,P_BNG_ATTRIBUTE22 => r_BNG.INFORMATION132
12256 ,P_BNG_ATTRIBUTE23 => r_BNG.INFORMATION133
12257 ,P_BNG_ATTRIBUTE24 => r_BNG.INFORMATION134
12258 ,P_BNG_ATTRIBUTE25 => r_BNG.INFORMATION135
12259 ,P_BNG_ATTRIBUTE26 => r_BNG.INFORMATION136
12260 ,P_BNG_ATTRIBUTE27 => r_BNG.INFORMATION137
12261 ,P_BNG_ATTRIBUTE28 => r_BNG.INFORMATION138
12262 ,P_BNG_ATTRIBUTE29 => r_BNG.INFORMATION139
12263 ,P_BNG_ATTRIBUTE3 => r_BNG.INFORMATION113
12264 ,P_BNG_ATTRIBUTE30 => r_BNG.INFORMATION140
12265 ,P_BNG_ATTRIBUTE4 => r_BNG.INFORMATION114
12266 ,P_BNG_ATTRIBUTE5 => r_BNG.INFORMATION115
12267 ,P_BNG_ATTRIBUTE6 => r_BNG.INFORMATION116
12268 ,P_BNG_ATTRIBUTE7 => r_BNG.INFORMATION117
12269 ,P_BNG_ATTRIBUTE8 => r_BNG.INFORMATION118
12270 ,P_BNG_ATTRIBUTE9 => r_BNG.INFORMATION119
12271 ,P_BNG_ATTRIBUTE_CATEGORY => r_BNG.INFORMATION110
12272 ,P_BNG_DESC => r_BNG.INFORMATION185
12273 ,P_NAME => l_prefix || r_BNG.INFORMATION170 || l_suffix
12274 --
12275 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12276 );
12277 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
12278 -- Update all relevent cer records with new pk_id
12279 hr_utility.set_location('Before plsql table ',222);
12280 hr_utility.set_location('new_value id '||l_benfts_grp_id,222);
12281 g_pk_tbl(g_count).pk_id_column := 'BENFTS_GRP_ID' ;
12282 g_pk_tbl(g_count).old_value := r_BNG.information1 ;
12283 g_pk_tbl(g_count).new_value := l_BENFTS_GRP_ID ;
12284 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
12285 g_pk_tbl(g_count).table_route_id := r_BNG_unique.table_route_id;
12286 hr_utility.set_location('After plsql table ',222);
12287 --
12288 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
12289 --
12290 g_count := g_count + 1 ;
12291 --
12292 log_data('BNG',l_new_value,l_prefix || r_BNG.INFORMATION170 || l_suffix,'COPIED');
12293 --
12294 elsif l_update then
12295
12296 hr_utility.set_location(' BEN_BENFTS_GRP UPDATE_BENEFITS_GROUP ',20);
12297 BEN_BENEFITS_GROUP_API.UPDATE_BENEFITS_GROUP(
12298 --
12299 P_VALIDATE => false
12300 -- ,P_EFFECTIVE_DATE => p_effective_date
12301 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
12302 --
12303 ,P_BENFTS_GRP_ID => l_benfts_grp_id
12304 ,P_BNG_ATTRIBUTE1 => r_BNG.INFORMATION111
12305 ,P_BNG_ATTRIBUTE10 => r_BNG.INFORMATION120
12306 ,P_BNG_ATTRIBUTE11 => r_BNG.INFORMATION121
12307 ,P_BNG_ATTRIBUTE12 => r_BNG.INFORMATION122
12308 ,P_BNG_ATTRIBUTE13 => r_BNG.INFORMATION123
12309 ,P_BNG_ATTRIBUTE14 => r_BNG.INFORMATION124
12310 ,P_BNG_ATTRIBUTE15 => r_BNG.INFORMATION125
12311 ,P_BNG_ATTRIBUTE16 => r_BNG.INFORMATION126
12312 ,P_BNG_ATTRIBUTE17 => r_BNG.INFORMATION127
12313 ,P_BNG_ATTRIBUTE18 => r_BNG.INFORMATION128
12314 ,P_BNG_ATTRIBUTE19 => r_BNG.INFORMATION129
12315 ,P_BNG_ATTRIBUTE2 => r_BNG.INFORMATION112
12316 ,P_BNG_ATTRIBUTE20 => r_BNG.INFORMATION130
12317 ,P_BNG_ATTRIBUTE21 => r_BNG.INFORMATION131
12318 ,P_BNG_ATTRIBUTE22 => r_BNG.INFORMATION132
12319 ,P_BNG_ATTRIBUTE23 => r_BNG.INFORMATION133
12320 ,P_BNG_ATTRIBUTE24 => r_BNG.INFORMATION134
12321 ,P_BNG_ATTRIBUTE25 => r_BNG.INFORMATION135
12322 ,P_BNG_ATTRIBUTE26 => r_BNG.INFORMATION136
12323 ,P_BNG_ATTRIBUTE27 => r_BNG.INFORMATION137
12324 ,P_BNG_ATTRIBUTE28 => r_BNG.INFORMATION138
12325 ,P_BNG_ATTRIBUTE29 => r_BNG.INFORMATION139
12326 ,P_BNG_ATTRIBUTE3 => r_BNG.INFORMATION113
12327 ,P_BNG_ATTRIBUTE30 => r_BNG.INFORMATION140
12328 ,P_BNG_ATTRIBUTE4 => r_BNG.INFORMATION114
12329 ,P_BNG_ATTRIBUTE5 => r_BNG.INFORMATION115
12330 ,P_BNG_ATTRIBUTE6 => r_BNG.INFORMATION116
12331 ,P_BNG_ATTRIBUTE7 => r_BNG.INFORMATION117
12332 ,P_BNG_ATTRIBUTE8 => r_BNG.INFORMATION118
12333 ,P_BNG_ATTRIBUTE9 => r_BNG.INFORMATION119
12334 ,P_BNG_ATTRIBUTE_CATEGORY => r_BNG.INFORMATION110
12335 ,P_BNG_DESC => r_BNG.INFORMATION185
12336 ,P_NAME => l_prefix || r_BNG.INFORMATION170 || l_suffix
12337 --
12338 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12339 );
12340 end if;
12341 --
12342 l_prev_pk_id := l_current_pk_id ;
12343 --
12344 end if;
12345 --
12346 end loop;
12347 --
12348 exception when others then
12349 --
12350 raise_error_message( 'BNG',l_prefix || r_BNG.INFORMATION170 || l_suffix) ;
12351 --
12352 end create_BNG_rows;
12353
12354
12355 --
12356 ---------------------------------------------------------------
12357 ----------------------< create_PSL_rows >-----------------------
12358 ---------------------------------------------------------------
12359 --
12360 procedure create_PSL_rows
12361 (
12362 p_validate in number default 0
12363 ,p_copy_entity_txn_id in number
12364 ,p_effective_date in date
12365 ,p_prefix_suffix_text in varchar2 default null
12366 ,p_reuse_object_flag in varchar2 default null
12367 ,p_target_business_group_id in varchar2 default null
12368 ,p_prefix_suffix_cd in varchar2 default null
12369 ) is
12370 --
12371 l_source_table varchar2(240);
12372 l_source_column varchar2(240);
12373 l_new_val varchar2(240);
12374 l_old_val varchar2(240);
12375 --
12376 cursor c_unique_PSL(l_table_alias varchar2) is
12377 select distinct cpe.information1,
12378 cpe.information2,
12379 cpe.information3,
12380 cpe.INFORMATION218 name,
12381 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
12382 from ben_copy_entity_results cpe,
12383 pqh_table_route tr
12384 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12385 and cpe.table_route_id = tr.table_route_id
12386 -- and tr.where_clause = l_BEN_PER_INFO_CHG_CS_LER_F
12387 and tr.table_alias = l_table_alias
12388 and cpe.number_of_copies = 1 --ADDITION
12389 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION218, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
12390 order by information1, information2; --added for bug: 5151945
12391 --
12392 --
12393 cursor c_PSL_min_max_dates(c_table_route_id number,
12394 c_information1 number) is
12395 select
12396 min(cpe.information2) min_esd,
12397 max(cpe.information3) min_eed
12398 from ben_copy_entity_results cpe
12399 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12400 and cpe.table_route_id = c_table_route_id
12401 and cpe.information1 = c_information1 ;
12402 --
12403 cursor c_PSL(c_table_route_id number,
12404 c_information1 number,
12405 c_information2 date,
12406 c_information3 date ) is
12407 select
12408 cpe.*
12409 from ben_copy_entity_results cpe
12410 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12411 and cpe.table_route_id = c_table_route_id
12412 and cpe.information1 = c_information1
12413 and cpe.information2 = c_information2
12414 and cpe.information3 = c_information3
12415 and rownum = 1 ;
12416 -- Date Track target record
12417 cursor c_find_PSL_in_target( c_PSL_name varchar2,
12418 c_effective_start_date date,
12419 c_effective_end_date date,
12420 c_business_group_id number,
12421 c_new_pk_id number) is
12422 select
12423 PSL.per_info_chg_cs_ler_id new_value
12424 from BEN_PER_INFO_CHG_CS_LER_F PSL
12425 where ( PSL.name = c_PSL_name OR
12426 ( PSL.source_table = l_source_table
12427 and PSL.source_column = l_source_column
12428 and PSL.new_val = nvl(l_new_val,hr_api.g_varchar2)
12429 and PSL.old_val = nvl(l_old_val,hr_api.g_varchar2) ))
12430 and PSL.business_group_id = c_business_group_id
12431 and PSL.per_info_chg_cs_ler_id <> c_new_pk_id
12432 --TEMPIK
12433 and c_effective_start_date between effective_start_date
12434 and effective_end_date ;
12435 --END TEMPIK
12436 /*TEMPIK
12437 and exists ( select null
12438 from BEN_PER_INFO_CHG_CS_LER_F PSL1
12439 where (PSL1.name = c_PSL_name OR
12440 ( PSL1.source_table = l_source_table
12441 and PSL1.source_column = l_source_column
12442 --and PSL1.new_val = nvl(l_new_val,hr_api.g_varchar2)
12443 --and PSL1.old_val = nvl(l_old_val,hr_api.g_varchar2)
12444 ))
12445 and PSL1.business_group_id = c_business_group_id
12446 and PSL1.effective_start_date <= c_effective_start_date )
12447 and exists ( select null
12448 from BEN_PER_INFO_CHG_CS_LER_F PSL2
12449 where ( PSL2.name = c_PSL_name OR
12450 ( PSL2.source_table = l_source_table
12451 and PSL2.source_column = l_source_column
12452 --and PSL2.new_val = nvl(l_new_val,hr_api.g_varchar2)
12453 --and PSL2.old_val = nvl(l_old_val,hr_api.g_varchar2)
12454 ))
12455 and PSL2.business_group_id = c_business_group_id
12456 and PSL2.effective_end_date >= c_effective_end_date )
12457 ;
12458 TEMPIK */
12459 --TEMPIK
12460 l_dt_rec_found boolean ;
12461 --END TEMPIK
12462 --
12463 cursor c_abs_reason(cv_lookup_code in varchar2, cv_effective_date in date) is
12464 SELECT hl.lookup_code
12465 FROM hr_lookups hl,
12466 per_abs_attendance_reasons abs
12467 WHERE hl.lookup_type = 'ABSENCE_REASON'
12468 AND hl.lookup_code = abs.name
12469 AND hl.lookup_code = cv_lookup_code
12470 AND hl.enabled_flag = 'Y'
12471 AND abs.business_group_id = p_target_business_group_id
12472 AND cv_effective_date between nvl(start_date_active,cv_effective_date)
12473 and nvl(end_date_active,cv_effective_date);
12474 --
12475 cursor c_abs_type(cv_val in varchar2) is
12476 SELECT absence_attendance_type_id
12477 from PER_ABSENCE_ATTENDANCE_TYPES
12478 WHERE business_group_id = p_target_business_group_id
12479 and name = cv_val;
12480 --
12481 l_abs_old_name varchar2(600);
12482 l_abs_new_name varchar2(600);
12483 --
12484 l_current_pk_id number := null ;
12485 --UPD START
12486 --
12487 l_update boolean := false ;
12488 l_datetrack_mode varchar2(80) := hr_api.g_update;
12489 l_process_date date;
12490 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
12491 --
12492 --UPD END
12493 l_prev_pk_id number := null ;
12494 l_first_rec boolean := true ;
12495 r_PSL c_PSL%rowtype;
12496 l_per_info_chg_cs_ler_id number ;
12497 l_object_version_number number ;
12498 l_effective_start_date date ;
12499 l_effective_end_date date ;
12500 l_prefix pqh_copy_entity_attribs.information1%type := null;
12501 l_suffix pqh_copy_entity_attribs.information1%type := null;
12502 l_new_value number(15);
12503 l_object_found_in_target boolean := false ;
12504 l_min_esd date;
12505 l_max_eed date;
12506 l_PER_INFO_CHG_CS_LER_RL number;
12507 l_effective_date date;
12508 --
12509 begin
12510 -- Initialization
12511 l_object_found_in_target := false ;
12512 -- End Initialization
12513 -- Derive the prefix - sufix
12514 if p_prefix_suffix_cd = 'PREFIX' then
12515 l_prefix := p_prefix_suffix_text ;
12516 elsif p_prefix_suffix_cd = 'SUFFIX' then
12517 l_suffix := p_prefix_suffix_text ;
12518 else
12519 l_prefix := null ;
12520 l_suffix := null ;
12521 end if ;
12522 -- End Prefix Sufix derivation
12523 for r_PSL_unique in c_unique_PSL('PSL') loop
12524
12525 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
12526 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12527 r_PSL_unique.information3 >=
12528 ben_pd_copy_to_ben_one.g_copy_effective_date)
12529 ) then
12530
12531 --
12532 hr_utility.set_location(' r_PSL_unique.table_route_id '||r_PSL_unique.table_route_id,10);
12533 hr_utility.set_location(' r_PSL_unique.information1 '||r_PSL_unique.information1,10);
12534 hr_utility.set_location( 'r_PSL_unique.information2 '||r_PSL_unique.information2,10);
12535 hr_utility.set_location( 'r_PSL_unique.information3 '||r_PSL_unique.information3,10);
12536 -- If reuse objects flag is 'Y' then check for the object in the target business group
12537 -- if found insert the record into PLSql table and exit the loop else try create the
12538 -- object in the target business group
12539 --
12540 l_object_found_in_target := false ;
12541 l_min_esd := null ;
12542 l_max_eed := null ;
12543 open c_PSL_min_max_dates(r_PSL_unique.table_route_id, r_PSL_unique.information1 ) ;
12544 fetch c_PSL_min_max_dates into l_min_esd,l_max_eed ;
12545 --
12546
12547 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12548 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
12549 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
12550 end if;
12551 l_min_esd := greatest(l_min_esd,r_PSL_unique.information2);
12552
12553 open c_PSL(r_PSL_unique.table_route_id,
12554 r_PSL_unique.information1,
12555 r_PSL_unique.information2,
12556 r_PSL_unique.information3 ) ;
12557 --
12558 fetch c_PSL into r_PSL ;
12559 --
12560 --
12561 -- For absences seeded plan design
12562 --
12563 l_abs_old_name := r_PSL.information185;
12564 l_abs_new_name := r_PSL.information186;
12565 if r_PSL.information142 = 'PER_ABSENCE_ATTENDANCES' then
12566 --
12567 if r_PSL.information141 = 'ABSENCE_ATTENDANCE_TYPE_ID' then
12568 --
12569 if r_PSL.information185 not in ('OABANY', 'NULL') then
12570 open c_abs_type(r_PSL.information188);
12571 fetch c_abs_type into l_abs_old_name;
12572 close c_abs_type;
12573 end if;
12574 --
12575 if r_PSL.information186 not in ('OABANY', 'NULL') then
12576 open c_abs_type(r_PSL.information187);
12577 fetch c_abs_type into l_abs_new_name;
12578 close c_abs_type;
12579 end if;
12580 --
12581 elsif r_PSL.information141 = 'ABS_ATTENDANCE_REASON_ID' then
12582 --
12583 if r_PSL.information185 not in ('OABANY', 'NULL') then
12584 open c_abs_reason(r_PSL.information188, p_effective_date);
12585 fetch c_abs_reason into l_abs_old_name;
12586 close c_abs_reason;
12587 end if;
12588 --
12589 if r_PSL.information186 not in ('OABANY', 'NULL') then
12590 open c_abs_reason(r_PSL.information187,p_effective_date );
12591 fetch c_abs_reason into l_abs_new_name;
12592 close c_abs_reason;
12593 end if;
12594 --
12595 end if;
12596 --
12597 end if;
12598 l_source_table := r_PSL.information142 ;
12599 l_source_column := r_PSL.information141 ;
12600 --
12601 l_new_val := l_abs_new_name ;
12602 l_old_val := l_abs_old_name ;
12603 --
12604 close c_PSL ;
12605 l_update := false;
12606 l_process_date := p_effective_date;
12607 l_dml_operation:= r_PSL_unique.dml_operation;
12608 if l_dml_operation = 'UPDATE' then
12609 --
12610 l_object_found_in_target := TRUE;
12611 --
12612 if l_process_date between r_PSL_unique.information2 and r_PSL_unique.information3 then
12613 l_update := true;
12614 if r_PSL_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
12615 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PER_INFO_CHG_CS_LER_ID' then
12616 g_pk_tbl(g_count).pk_id_column := 'PER_INFO_CHG_CS_LER_ID' ;
12617 g_pk_tbl(g_count).old_value := r_PSL_unique.information1 ;
12618 g_pk_tbl(g_count).new_value := r_PSL_unique.information1 ;
12619 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
12620 g_pk_tbl(g_count).table_route_id := r_PSL_unique.table_route_id;
12621 --
12622 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
12623 --
12624 g_count := g_count + 1 ;
12625 --
12626 log_data('PSL',l_new_value,l_prefix || r_PSL_unique.name|| l_suffix,'REUSED');
12627 --
12628 end if ;
12629 hr_utility.set_location( 'found record for update',10);
12630 --
12631 else
12632 --
12633 l_update := false;
12634 --
12635 end if;
12636 else
12637 --
12638 --UPD END
12639 --if p_reuse_object_flag = 'Y' then
12640 if c_PSL_min_max_dates%found then
12641 -- cursor to find the object
12642 open c_find_PSL_in_target( l_prefix || r_PSL_unique.name || l_suffix ,l_min_esd,l_max_eed,
12643 p_target_business_group_id, nvl(l_per_info_chg_cs_ler_id, -999) ) ;
12644 fetch c_find_PSL_in_target into l_new_value ;
12645 --
12646 if c_find_PSL_in_target%found then
12647 --
12648 --TEMPIK
12649 l_dt_rec_found := dt_api.check_min_max_dates
12650 (p_base_table_name => 'BEN_PER_INFO_CHG_CS_LER_F',
12651 p_base_key_column => 'PER_INFO_CHG_CS_LER_ID',
12652 p_base_key_value => l_new_value,
12653 p_from_date => l_min_esd,
12654 p_to_date => l_max_eed );
12655 if l_dt_rec_found THEN
12656 --END TEMPIK
12657 if r_PSL_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
12658 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PER_INFO_CHG_CS_LER_ID' then
12659 g_pk_tbl(g_count).pk_id_column := 'PER_INFO_CHG_CS_LER_ID' ;
12660 g_pk_tbl(g_count).old_value := r_PSL_unique.information1 ;
12661 g_pk_tbl(g_count).new_value := l_new_value ;
12662 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
12663 g_pk_tbl(g_count).table_route_id := r_PSL_unique.table_route_id;
12664 --
12665 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
12666 --
12667 g_count := g_count + 1 ;
12668 --
12669 log_data('PSL',l_new_value, r_PSL_unique.name,'REUSED');
12670 --
12671 end if ;
12672 --
12673 l_object_found_in_target := true ;
12674 --TEMPIK
12675 end if; -- l_dt_rec_found
12676 --END TEMPIK
12677 end if;
12678 close c_find_PSL_in_target ;
12679 --
12680 end if;
12681 --end if ;
12682 --
12683 end if;
12684 close c_PSL_min_max_dates ;
12685 --
12686 if not l_object_found_in_target or l_update then
12687 --
12688 l_current_pk_id := r_PSL.information1;
12689 --
12690 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
12691 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
12692 --
12693 if l_current_pk_id = l_prev_pk_id then
12694 --
12695 l_first_rec := false ;
12696 --
12697 else
12698 --
12699 l_first_rec := true ;
12700 --
12701 end if ;
12702 --
12703 l_PER_INFO_CHG_CS_LER_RL := get_fk('FORMULA_ID', r_PSL.INFORMATION260,l_dml_operation);
12704 --
12705 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_PER_INFO_CHG_CS_LER_F',l_prefix || r_PSL.INFORMATION218 || l_suffix);
12706 --
12707
12708 l_effective_date := r_PSL.information2;
12709 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
12710 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
12711 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
12712 end if;
12713
12714 if l_first_rec and not l_update then
12715 -- Call Create routine.
12716 hr_utility.set_location(' BEN_PER_INFO_CHG_CS_LER_F CREATE_PERSON_CHANGE_CS_LER ',20);
12717 BEN_PERSON_CHANGE_CS_LER_API.CREATE_PERSON_CHANGE_CS_LER(
12718 --
12719 P_VALIDATE => false
12720 ,P_EFFECTIVE_DATE => l_effective_date
12721 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
12722 --
12723 ,P_NAME => l_prefix || r_PSL.INFORMATION218 || l_suffix
12724 --
12725 -- Bug No: 3907710
12726 --
12727 ,P_RULE_OVERRIDES_FLAG => r_PSL.INFORMATION11
12728 --
12729 ,P_NEW_VAL => l_abs_new_name
12730 ,P_OLD_VAL => l_abs_old_name
12731 ,P_PER_INFO_CHG_CS_LER_ID => l_per_info_chg_cs_ler_id
12732 ,P_PER_INFO_CHG_CS_LER_RL => l_PER_INFO_CHG_CS_LER_RL
12733 ,P_PSL_ATTRIBUTE1 => r_PSL.INFORMATION111
12734 ,P_PSL_ATTRIBUTE10 => r_PSL.INFORMATION120
12735 ,P_PSL_ATTRIBUTE11 => r_PSL.INFORMATION121
12736 ,P_PSL_ATTRIBUTE12 => r_PSL.INFORMATION122
12737 ,P_PSL_ATTRIBUTE13 => r_PSL.INFORMATION123
12738 ,P_PSL_ATTRIBUTE14 => r_PSL.INFORMATION124
12739 ,P_PSL_ATTRIBUTE15 => r_PSL.INFORMATION125
12740 ,P_PSL_ATTRIBUTE16 => r_PSL.INFORMATION126
12741 ,P_PSL_ATTRIBUTE17 => r_PSL.INFORMATION127
12742 ,P_PSL_ATTRIBUTE18 => r_PSL.INFORMATION128
12743 ,P_PSL_ATTRIBUTE19 => r_PSL.INFORMATION129
12744 ,P_PSL_ATTRIBUTE2 => r_PSL.INFORMATION112
12745 ,P_PSL_ATTRIBUTE20 => r_PSL.INFORMATION130
12746 ,P_PSL_ATTRIBUTE21 => r_PSL.INFORMATION131
12747 ,P_PSL_ATTRIBUTE22 => r_PSL.INFORMATION132
12748 ,P_PSL_ATTRIBUTE23 => r_PSL.INFORMATION133
12749 ,P_PSL_ATTRIBUTE24 => r_PSL.INFORMATION134
12750 ,P_PSL_ATTRIBUTE25 => r_PSL.INFORMATION135
12751 ,P_PSL_ATTRIBUTE26 => r_PSL.INFORMATION136
12752 ,P_PSL_ATTRIBUTE27 => r_PSL.INFORMATION137
12753 ,P_PSL_ATTRIBUTE28 => r_PSL.INFORMATION138
12754 ,P_PSL_ATTRIBUTE29 => r_PSL.INFORMATION139
12755 ,P_PSL_ATTRIBUTE3 => r_PSL.INFORMATION113
12756 ,P_PSL_ATTRIBUTE30 => r_PSL.INFORMATION140
12757 ,P_PSL_ATTRIBUTE4 => r_PSL.INFORMATION114
12758 ,P_PSL_ATTRIBUTE5 => r_PSL.INFORMATION115
12759 ,P_PSL_ATTRIBUTE6 => r_PSL.INFORMATION116
12760 ,P_PSL_ATTRIBUTE7 => r_PSL.INFORMATION117
12761 ,P_PSL_ATTRIBUTE8 => r_PSL.INFORMATION118
12762 ,P_PSL_ATTRIBUTE9 => r_PSL.INFORMATION119
12763 ,P_PSL_ATTRIBUTE_CATEGORY => r_PSL.INFORMATION110
12764 ,P_SOURCE_COLUMN => r_PSL.INFORMATION141
12765 ,P_SOURCE_TABLE => r_PSL.INFORMATION142
12766 ,P_WHATIF_LBL_TXT => r_PSL.INFORMATION219
12767 --
12768 ,P_EFFECTIVE_START_DATE => l_effective_start_date
12769 ,P_EFFECTIVE_END_DATE => l_effective_end_date
12770 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12771 );
12772 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
12773 -- Update all relevent cer records with new pk_id
12774 hr_utility.set_location('Before plsql table ',222);
12775 hr_utility.set_location('new_value id '||l_per_info_chg_cs_ler_id,222);
12776 g_pk_tbl(g_count).pk_id_column := 'PER_INFO_CHG_CS_LER_ID' ;
12777 g_pk_tbl(g_count).old_value := r_PSL.information1 ;
12778 g_pk_tbl(g_count).new_value := l_PER_INFO_CHG_CS_LER_ID ;
12779 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
12780 g_pk_tbl(g_count).table_route_id := r_PSL_unique.table_route_id;
12781 hr_utility.set_location('After plsql table ',222);
12782 --
12783 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
12784 --
12785 g_count := g_count + 1 ;
12786 --
12787 log_data('PSL',l_new_value,l_prefix || r_PSL.INFORMATION218 || l_suffix,'COPIED');
12788 else
12789 --
12790 --UPD START
12791 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
12792 --
12793 if l_update then
12794 --
12795 l_datetrack_mode := r_PSL.datetrack_mode ;
12796 --
12797 get_dt_modes(
12798 p_effective_date => l_process_date,
12799 p_effective_end_date => r_PSL.information3,
12800 p_effective_start_date => r_PSL.information2,
12801 p_dml_operation => r_PSL.dml_operation,
12802 p_datetrack_mode => l_datetrack_mode );
12803 -- p_update => l_update
12804 --
12805 l_effective_date := l_process_date;
12806 l_PER_INFO_CHG_CS_LER_ID := r_PSL.information1;
12807 l_object_version_number := r_PSL.information265;
12808 --
12809 end if;
12810 --
12811 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
12812 --
12813 IF l_update OR l_dml_operation <> 'UPDATE' THEN
12814 --UPD END
12815 -- Call Update routine for the pk_id created in prev run .
12816 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
12817 hr_utility.set_location(' BEN_PER_INFO_CHG_CS_LER_F UPDATE_PERSON_CHANGE_CS_LER ',30);
12818 BEN_PERSON_CHANGE_CS_LER_API.UPDATE_PERSON_CHANGE_CS_LER(
12819 --
12820 P_VALIDATE => false
12821 ,P_EFFECTIVE_DATE => l_effective_date
12822 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
12823 --
12824 ,P_NAME => l_prefix || r_PSL.INFORMATION218 || l_suffix
12825 --
12826 -- Bug No: 3907710
12827 --
12828 ,P_RULE_OVERRIDES_FLAG => r_PSL.INFORMATION11
12829 --
12830 ,P_NEW_VAL => l_abs_new_name
12831 ,P_OLD_VAL => l_abs_old_name
12832 ,P_PER_INFO_CHG_CS_LER_ID => l_per_info_chg_cs_ler_id
12833 ,P_PER_INFO_CHG_CS_LER_RL => l_PER_INFO_CHG_CS_LER_RL
12834 ,P_PSL_ATTRIBUTE1 => r_PSL.INFORMATION111
12835 ,P_PSL_ATTRIBUTE10 => r_PSL.INFORMATION120
12836 ,P_PSL_ATTRIBUTE11 => r_PSL.INFORMATION121
12837 ,P_PSL_ATTRIBUTE12 => r_PSL.INFORMATION122
12838 ,P_PSL_ATTRIBUTE13 => r_PSL.INFORMATION123
12839 ,P_PSL_ATTRIBUTE14 => r_PSL.INFORMATION124
12840 ,P_PSL_ATTRIBUTE15 => r_PSL.INFORMATION125
12841 ,P_PSL_ATTRIBUTE16 => r_PSL.INFORMATION126
12842 ,P_PSL_ATTRIBUTE17 => r_PSL.INFORMATION127
12843 ,P_PSL_ATTRIBUTE18 => r_PSL.INFORMATION128
12844 ,P_PSL_ATTRIBUTE19 => r_PSL.INFORMATION129
12845 ,P_PSL_ATTRIBUTE2 => r_PSL.INFORMATION112
12846 ,P_PSL_ATTRIBUTE20 => r_PSL.INFORMATION130
12847 ,P_PSL_ATTRIBUTE21 => r_PSL.INFORMATION131
12848 ,P_PSL_ATTRIBUTE22 => r_PSL.INFORMATION132
12849 ,P_PSL_ATTRIBUTE23 => r_PSL.INFORMATION133
12850 ,P_PSL_ATTRIBUTE24 => r_PSL.INFORMATION134
12851 ,P_PSL_ATTRIBUTE25 => r_PSL.INFORMATION135
12852 ,P_PSL_ATTRIBUTE26 => r_PSL.INFORMATION136
12853 ,P_PSL_ATTRIBUTE27 => r_PSL.INFORMATION137
12854 ,P_PSL_ATTRIBUTE28 => r_PSL.INFORMATION138
12855 ,P_PSL_ATTRIBUTE29 => r_PSL.INFORMATION139
12856 ,P_PSL_ATTRIBUTE3 => r_PSL.INFORMATION113
12857 ,P_PSL_ATTRIBUTE30 => r_PSL.INFORMATION140
12858 ,P_PSL_ATTRIBUTE4 => r_PSL.INFORMATION114
12859 ,P_PSL_ATTRIBUTE5 => r_PSL.INFORMATION115
12860 ,P_PSL_ATTRIBUTE6 => r_PSL.INFORMATION116
12861 ,P_PSL_ATTRIBUTE7 => r_PSL.INFORMATION117
12862 ,P_PSL_ATTRIBUTE8 => r_PSL.INFORMATION118
12863 ,P_PSL_ATTRIBUTE9 => r_PSL.INFORMATION119
12864 ,P_PSL_ATTRIBUTE_CATEGORY => r_PSL.INFORMATION110
12865 ,P_SOURCE_COLUMN => r_PSL.INFORMATION141
12866 ,P_SOURCE_TABLE => r_PSL.INFORMATION142
12867 ,P_WHATIF_LBL_TXT => r_PSL.INFORMATION219
12868 --
12869 ,P_EFFECTIVE_START_DATE => l_effective_start_date
12870 ,P_EFFECTIVE_END_DATE => l_effective_end_date
12871 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
12872 ,P_DATETRACK_MODE => l_datetrack_mode
12873 );
12874 --
12875 end if;
12876 end if;
12877 --
12878 -- Delete the row if it is end dated.
12879 --
12880 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
12881 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
12882 trunc(l_max_eed) = r_PSL.information3) then
12883 --
12884 BEN_PERSON_CHANGE_CS_LER_API.delete_PERSON_CHANGE_CS_LER(
12885 --
12886 p_validate => false
12887 ,p_per_info_chg_cs_ler_id => l_per_info_chg_cs_ler_id
12888 ,p_effective_start_date => l_effective_start_date
12889 ,p_effective_end_date => l_effective_end_date
12890 ,p_object_version_number => l_object_version_number
12891 ,p_effective_date => l_max_eed
12892 ,p_datetrack_mode => hr_api.g_delete
12893 --
12894 );
12895 --
12896 end if;
12897 --
12898 l_prev_pk_id := l_current_pk_id ;
12899 --
12900 end if;
12901 --
12902 end if;
12903 --
12904 end loop;
12905 --
12906 exception when others then
12907 --
12908 raise_error_message( 'PSL',l_prefix || r_PSL.INFORMATION218 || l_suffix) ;
12909 --
12910 end create_PSL_rows;
12911
12912 --
12913 ---------------------------------------------------------------
12914 ----------------------< create_CCT_rows >-----------------------
12915 ---------------------------------------------------------------
12916 --
12917 procedure create_CCT_rows
12918 (
12919 p_validate in number default 0
12920 ,p_copy_entity_txn_id in number
12921 ,p_effective_date in date
12922 ,p_prefix_suffix_text in varchar2 default null
12923 ,p_reuse_object_flag in varchar2 default null
12924 ,p_target_business_group_id in varchar2 default null
12925 ,p_prefix_suffix_cd in varchar2 default null
12926 ) is
12927 --
12928 cursor c_unique_CCT(l_table_alias varchar2) is
12929 select distinct cpe.information1,
12930 cpe.information2,
12931 cpe.information3,
12932 cpe.INFORMATION170 name,
12933 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
12934 from ben_copy_entity_results cpe,
12935 pqh_table_route tr
12936 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12937 and cpe.table_route_id = tr.table_route_id
12938 -- and tr.where_clause = l_BEN_CM_TYP_F
12939 and tr.table_alias = l_table_alias
12940 and cpe.number_of_copies = 1 --ADDITION
12941 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
12942 order by information1, information2; --added for bug: 5151945
12943 --
12944 --
12945 cursor c_CCT_min_max_dates(c_table_route_id number,
12946 c_information1 number) is
12947 select
12948 min(cpe.information2) min_esd,
12949 max(cpe.information3) min_eed
12950 from ben_copy_entity_results cpe
12951 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12952 and cpe.table_route_id = c_table_route_id
12953 and cpe.information1 = c_information1 ;
12954 --
12955 cursor c_CCT(c_table_route_id number,
12956 c_information1 number,
12957 c_information2 date,
12958 c_information3 date ) is
12959 select
12960 cpe.*
12961 from ben_copy_entity_results cpe
12962 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
12963 and cpe.table_route_id = c_table_route_id
12964 and cpe.information1 = c_information1
12965 and cpe.information2 = c_information2
12966 and cpe.information3 = c_information3
12967 and rownum = 1 ;
12968 -- Date Track target record
12969 cursor c_find_CCT_in_target( c_CCT_name varchar2,
12970 c_effective_start_date date,
12971 c_effective_end_date date,
12972 c_business_group_id number,
12973 c_new_pk_id number) is
12974 select
12975 CCT.cm_typ_id new_value
12976 from BEN_CM_TYP_F CCT
12977 where CCT.name = c_CCT_name
12978 and CCT.business_group_id = c_business_group_id
12979 and CCT.cm_typ_id <> c_new_pk_id
12980 --TEMPIK
12981 and c_effective_start_date between effective_start_date
12982 and effective_end_date ;
12983 --END TEMPIK
12984 /*TEMPIK
12985 and exists ( select null
12986 from BEN_CM_TYP_F CCT1
12987 where CCT1.name = c_CCT_name
12988 and CCT1.business_group_id = c_business_group_id
12989 and CCT1.effective_start_date <= c_effective_start_date )
12990 and exists ( select null
12991 from BEN_CM_TYP_F CCT2
12992 where CCT2.name = c_CCT_name
12993 and CCT2.business_group_id = c_business_group_id
12994 and CCT2.effective_end_date >= c_effective_end_date )
12995 ;
12996 TEMPIK */
12997 --TEMPIK
12998 l_dt_rec_found boolean ;
12999 --END TEMPIK
13000 --
13001 l_current_pk_id number := null ;
13002 --UPD START
13003 --
13004 l_update boolean := false ;
13005 l_datetrack_mode varchar2(80) := hr_api.g_update;
13006 l_process_date date;
13007 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
13008 --
13009 --UPD END
13010 l_prev_pk_id number := null ;
13011 l_first_rec boolean := true ;
13012 r_CCT c_CCT%rowtype;
13013 l_cm_typ_id number ;
13014 l_object_version_number number ;
13015 l_effective_start_date date ;
13016 l_effective_end_date date ;
13017 l_prefix pqh_copy_entity_attribs.information1%type := null;
13018 l_suffix pqh_copy_entity_attribs.information1%type := null;
13019 l_new_value number(15);
13020 l_object_found_in_target boolean := false ;
13021 l_min_esd date;
13022 l_max_eed date;
13023 l_CM_TYP_RL number;
13024 l_INSPN_RQD_RL number;
13025 l_PARNT_CM_TYP_ID number;
13026 l_TO_BE_SENT_DT_RL number;
13027 l_effective_date date;
13028 --
13029 begin
13030 -- Initialization
13031 l_object_found_in_target := false ;
13032 -- End Initialization
13033 -- Derive the prefix - sufix
13034 if p_prefix_suffix_cd = 'PREFIX' then
13035 l_prefix := p_prefix_suffix_text ;
13036 elsif p_prefix_suffix_cd = 'SUFFIX' then
13037 l_suffix := p_prefix_suffix_text ;
13038 else
13039 l_prefix := null ;
13040 l_suffix := null ;
13041 end if ;
13042 -- End Prefix Sufix derivation
13043 for r_CCT_unique in c_unique_CCT('CCT') loop
13044
13045 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
13046 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13047 r_CCT_unique.information3 >=
13048 ben_pd_copy_to_ben_one.g_copy_effective_date)
13049 ) then
13050 --
13051 hr_utility.set_location(' r_CCT_unique.table_route_id '||r_CCT_unique.table_route_id,10);
13052 hr_utility.set_location(' r_CCT_unique.information1 '||r_CCT_unique.information1,10);
13053 hr_utility.set_location( 'r_CCT_unique.information2 '||r_CCT_unique.information2,10);
13054 hr_utility.set_location( 'r_CCT_unique.information3 '||r_CCT_unique.information3,10);
13055 -- If reuse objects flag is 'Y' then check for the object in the target business group
13056 -- if found insert the record into PLSql table and exit the loop else try create the
13057 -- object in the target business group
13058 --
13059 l_object_found_in_target := false ;
13060 --UPD START
13061 l_update := false;
13062 l_process_date := p_effective_date;
13063 l_dml_operation:= r_CCT_unique.dml_operation ;
13064 --
13065 if l_dml_operation = 'UPDATE' then
13066 --
13067 l_object_found_in_target := TRUE;
13068 --
13069 if l_process_date between r_CCT_unique.information2 and r_CCT_unique.information3 then
13070 l_update := true;
13071 if r_CCT_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
13072 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'CM_TYP_ID' then
13073 g_pk_tbl(g_count).pk_id_column := 'CM_TYP_ID' ;
13074 g_pk_tbl(g_count).old_value := r_CCT_unique.information1 ;
13075 g_pk_tbl(g_count).new_value := r_CCT_unique.information1 ;
13076 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
13077 g_pk_tbl(g_count).table_route_id := r_CCT_unique.table_route_id;
13078 --
13079 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
13080 --
13081 g_count := g_count + 1 ;
13082 --
13083 log_data('CCT',l_new_value,l_prefix || r_CCT_unique.name|| l_suffix,'REUSED');
13084 --
13085 end if ;
13086 hr_utility.set_location( 'found record for update',10);
13087 --
13088 else
13089 --
13090 l_update := false;
13091 --
13092 end if;
13093 else
13094 --
13095 l_min_esd := null ;
13096 l_max_eed := null ;
13097 open c_CCT_min_max_dates(r_CCT_unique.table_route_id, r_CCT_unique.information1 ) ;
13098 fetch c_CCT_min_max_dates into l_min_esd,l_max_eed ;
13099
13100 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13101 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
13102 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
13103 end if;
13104 l_min_esd := greatest(l_min_esd,r_CCT_unique.information2);
13105
13106 if p_reuse_object_flag = 'Y' then
13107 if c_CCT_min_max_dates%found then
13108 -- cursor to find the object
13109 open c_find_CCT_in_target( l_prefix || r_CCT_unique.name || l_suffix ,l_min_esd,l_max_eed,
13110 p_target_business_group_id, nvl(l_cm_typ_id, -999) ) ;
13111 fetch c_find_CCT_in_target into l_new_value ;
13112 if c_find_CCT_in_target%found then
13113 --
13114 --TEMPIK
13115 l_dt_rec_found := dt_api.check_min_max_dates
13116 (p_base_table_name => 'BEN_CM_TYP_F',
13117 p_base_key_column => 'CM_TYP_ID',
13118 p_base_key_value => l_new_value,
13119 p_from_date => l_min_esd,
13120 p_to_date => l_max_eed );
13121 if l_dt_rec_found THEN
13122 --END TEMPIK
13123 if r_CCT_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
13124 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'CM_TYP_ID' then
13125 g_pk_tbl(g_count).pk_id_column := 'CM_TYP_ID' ;
13126 g_pk_tbl(g_count).old_value := r_CCT_unique.information1 ;
13127 g_pk_tbl(g_count).new_value := l_new_value ;
13128 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
13129 g_pk_tbl(g_count).table_route_id := r_CCT_unique.table_route_id;
13130 --
13131 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
13132 --
13133 g_count := g_count + 1 ;
13134 end if ;
13135 --
13136 l_object_found_in_target := true ;
13137 --TEMPIK
13138 end if; -- l_dt_rec_found
13139 --END TEMPIK
13140 end if;
13141 close c_find_CCT_in_target ;
13142 --
13143 end if;
13144 end if ;
13145 --
13146 close c_CCT_min_max_dates ;
13147 end if;
13148 if not l_object_found_in_target or l_update then
13149 --
13150 open c_CCT(r_CCT_unique.table_route_id,
13151 r_CCT_unique.information1,
13152 r_CCT_unique.information2,
13153 r_CCT_unique.information3 ) ;
13154 --
13155 fetch c_CCT into r_CCT ;
13156 --
13157 close c_CCT ;
13158 --
13159 l_current_pk_id := r_CCT.information1;
13160 --
13161 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
13162 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
13163 --
13164 if l_current_pk_id = l_prev_pk_id then
13165 --
13166 l_first_rec := false ;
13167 --
13168 else
13169 --
13170 l_first_rec := true ;
13171 --
13172 end if ;
13173 --
13174 l_CM_TYP_RL := get_fk('FORMULA_ID', r_CCT.INFORMATION261,l_dml_operation);
13175 l_INSPN_RQD_RL := get_fk('FORMULA_ID', r_CCT.INFORMATION263,l_dml_operation);
13176 l_PARNT_CM_TYP_ID := get_fk('PARNT_CM_TYP_ID', r_CCT.INFORMATION260,l_dml_operation);
13177 l_TO_BE_SENT_DT_RL := get_fk('FORMULA_ID', r_CCT.INFORMATION264,l_dml_operation);
13178 --
13179 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_CM_TYP_F',l_prefix || r_CCT.INFORMATION170 || l_suffix);
13180 --
13181
13182 l_effective_date := r_CCT.information2;
13183 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13184 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
13185 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
13186 end if;
13187
13188 if l_first_rec and not l_update then
13189 -- Call Create routine.
13190 hr_utility.set_location(' BEN_CM_TYP_F CREATE_COMP_COMM_TYPES ',20);
13191 BEN_COMP_COMM_TYPES_API.CREATE_COMP_COMM_TYPES(
13192 --
13193 P_VALIDATE => false
13194 ,P_EFFECTIVE_DATE => l_effective_date
13195 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
13196 --
13197 ,P_CCT_ATTRIBUTE1 => r_CCT.INFORMATION111
13198 ,P_CCT_ATTRIBUTE10 => r_CCT.INFORMATION120
13199 ,P_CCT_ATTRIBUTE11 => r_CCT.INFORMATION121
13200 ,P_CCT_ATTRIBUTE12 => r_CCT.INFORMATION122
13201 ,P_CCT_ATTRIBUTE13 => r_CCT.INFORMATION123
13202 ,P_CCT_ATTRIBUTE14 => r_CCT.INFORMATION124
13203 ,P_CCT_ATTRIBUTE15 => r_CCT.INFORMATION125
13204 ,P_CCT_ATTRIBUTE16 => r_CCT.INFORMATION126
13205 ,P_CCT_ATTRIBUTE17 => r_CCT.INFORMATION127
13206 ,P_CCT_ATTRIBUTE18 => r_CCT.INFORMATION128
13207 ,P_CCT_ATTRIBUTE19 => r_CCT.INFORMATION129
13208 ,P_CCT_ATTRIBUTE2 => r_CCT.INFORMATION112
13209 ,P_CCT_ATTRIBUTE20 => r_CCT.INFORMATION130
13210 ,P_CCT_ATTRIBUTE21 => r_CCT.INFORMATION131
13211 ,P_CCT_ATTRIBUTE22 => r_CCT.INFORMATION132
13212 ,P_CCT_ATTRIBUTE23 => r_CCT.INFORMATION133
13213 ,P_CCT_ATTRIBUTE24 => r_CCT.INFORMATION134
13214 ,P_CCT_ATTRIBUTE25 => r_CCT.INFORMATION135
13215 ,P_CCT_ATTRIBUTE26 => r_CCT.INFORMATION136
13216 ,P_CCT_ATTRIBUTE27 => r_CCT.INFORMATION137
13217 ,P_CCT_ATTRIBUTE28 => r_CCT.INFORMATION138
13218 ,P_CCT_ATTRIBUTE29 => r_CCT.INFORMATION139
13219 ,P_CCT_ATTRIBUTE3 => r_CCT.INFORMATION113
13220 ,P_CCT_ATTRIBUTE30 => r_CCT.INFORMATION140
13221 ,P_CCT_ATTRIBUTE4 => r_CCT.INFORMATION114
13222 ,P_CCT_ATTRIBUTE5 => r_CCT.INFORMATION115
13223 ,P_CCT_ATTRIBUTE6 => r_CCT.INFORMATION116
13224 ,P_CCT_ATTRIBUTE7 => r_CCT.INFORMATION117
13225 ,P_CCT_ATTRIBUTE8 => r_CCT.INFORMATION118
13226 ,P_CCT_ATTRIBUTE9 => r_CCT.INFORMATION119
13227 ,P_CCT_ATTRIBUTE_CATEGORY => r_CCT.INFORMATION110
13228 ,P_CM_TYP_ID => l_cm_typ_id
13229 ,P_CM_TYP_RL => l_CM_TYP_RL
13230 ,P_CM_USG_CD => r_CCT.INFORMATION16
13231 ,P_DESC_TXT => r_CCT.INFORMATION185
13232 ,P_INSPN_RQD_FLAG => r_CCT.INFORMATION14
13233 ,P_INSPN_RQD_RL => l_INSPN_RQD_RL
13234 ,P_MX_NUM_AVLBL_VAL => r_CCT.INFORMATION262
13235 ,P_NAME => l_prefix || r_CCT.INFORMATION170 || l_suffix
13236 ,P_PARNT_CM_TYP_ID => l_PARNT_CM_TYP_ID
13237 ,P_PC_KIT_CD => r_CCT.INFORMATION17
13238 ,P_RCPENT_CD => r_CCT.INFORMATION15
13239 ,P_SHRT_NAME => r_CCT.INFORMATION141
13240 ,P_TO_BE_SENT_DT_CD => r_CCT.INFORMATION13
13241 ,P_TO_BE_SENT_DT_RL => l_TO_BE_SENT_DT_RL
13242 ,P_TRK_MLG_FLAG => r_CCT.INFORMATION12
13243 ,P_WHNVR_TRGRD_FLAG => r_CCT.INFORMATION11
13244 --
13245 ,P_EFFECTIVE_START_DATE => l_effective_start_date
13246 ,P_EFFECTIVE_END_DATE => l_effective_end_date
13247 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
13248 );
13249 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
13250 -- Update all relevent cer records with new pk_id
13251 hr_utility.set_location('Before plsql table ',222);
13252 hr_utility.set_location('new_value id '||l_cm_typ_id,222);
13253 g_pk_tbl(g_count).pk_id_column := 'CM_TYP_ID' ;
13254 g_pk_tbl(g_count).old_value := r_CCT.information1 ;
13255 g_pk_tbl(g_count).new_value := l_CM_TYP_ID ;
13256 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
13257 g_pk_tbl(g_count).table_route_id := r_CCT_unique.table_route_id;
13258 hr_utility.set_location('After plsql table ',222);
13259 --
13260 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
13261 --
13262 g_count := g_count + 1 ;
13263 --
13264 else
13265 --
13266 --UPD START
13267 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
13268 --
13269 if l_update then
13270 --
13271 l_datetrack_mode := r_CCT.datetrack_mode ;
13272 --
13273 get_dt_modes(
13274 p_effective_date => l_process_date,
13275 p_effective_end_date => r_CCT.information3,
13276 p_effective_start_date => r_CCT.information2,
13277 p_dml_operation => r_CCT.dml_operation,
13278 p_datetrack_mode => l_datetrack_mode );
13279 -- p_update => l_update
13280 --
13281 l_effective_date := l_process_date;
13282 l_CM_TYP_ID := r_CCT.information1;
13283 l_object_version_number := r_CCT.information265;
13284 --
13285 end if;
13286 --
13287 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
13288 --
13289 IF l_update OR l_dml_operation <> 'UPDATE' THEN
13290 --UPD END
13291 -- Call Update routine for the pk_id created in prev run .
13292 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
13293 hr_utility.set_location(' BEN_CM_TYP_F UPDATE_COMP_COMM_TYPES ',30);
13294 BEN_COMP_COMM_TYPES_API.UPDATE_COMP_COMM_TYPES(
13295 --
13296 P_VALIDATE => false
13297 ,P_EFFECTIVE_DATE => l_effective_date
13298 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
13299 --
13300 ,P_CCT_ATTRIBUTE1 => r_CCT.INFORMATION111
13301 ,P_CCT_ATTRIBUTE10 => r_CCT.INFORMATION120
13302 ,P_CCT_ATTRIBUTE11 => r_CCT.INFORMATION121
13303 ,P_CCT_ATTRIBUTE12 => r_CCT.INFORMATION122
13304 ,P_CCT_ATTRIBUTE13 => r_CCT.INFORMATION123
13305 ,P_CCT_ATTRIBUTE14 => r_CCT.INFORMATION124
13306 ,P_CCT_ATTRIBUTE15 => r_CCT.INFORMATION125
13307 ,P_CCT_ATTRIBUTE16 => r_CCT.INFORMATION126
13308 ,P_CCT_ATTRIBUTE17 => r_CCT.INFORMATION127
13309 ,P_CCT_ATTRIBUTE18 => r_CCT.INFORMATION128
13310 ,P_CCT_ATTRIBUTE19 => r_CCT.INFORMATION129
13311 ,P_CCT_ATTRIBUTE2 => r_CCT.INFORMATION112
13312 ,P_CCT_ATTRIBUTE20 => r_CCT.INFORMATION130
13313 ,P_CCT_ATTRIBUTE21 => r_CCT.INFORMATION131
13314 ,P_CCT_ATTRIBUTE22 => r_CCT.INFORMATION132
13315 ,P_CCT_ATTRIBUTE23 => r_CCT.INFORMATION133
13316 ,P_CCT_ATTRIBUTE24 => r_CCT.INFORMATION134
13317 ,P_CCT_ATTRIBUTE25 => r_CCT.INFORMATION135
13318 ,P_CCT_ATTRIBUTE26 => r_CCT.INFORMATION136
13319 ,P_CCT_ATTRIBUTE27 => r_CCT.INFORMATION137
13320 ,P_CCT_ATTRIBUTE28 => r_CCT.INFORMATION138
13321 ,P_CCT_ATTRIBUTE29 => r_CCT.INFORMATION139
13322 ,P_CCT_ATTRIBUTE3 => r_CCT.INFORMATION113
13323 ,P_CCT_ATTRIBUTE30 => r_CCT.INFORMATION140
13324 ,P_CCT_ATTRIBUTE4 => r_CCT.INFORMATION114
13325 ,P_CCT_ATTRIBUTE5 => r_CCT.INFORMATION115
13326 ,P_CCT_ATTRIBUTE6 => r_CCT.INFORMATION116
13327 ,P_CCT_ATTRIBUTE7 => r_CCT.INFORMATION117
13328 ,P_CCT_ATTRIBUTE8 => r_CCT.INFORMATION118
13329 ,P_CCT_ATTRIBUTE9 => r_CCT.INFORMATION119
13330 ,P_CCT_ATTRIBUTE_CATEGORY => r_CCT.INFORMATION110
13331 ,P_CM_TYP_ID => l_cm_typ_id
13332 ,P_CM_TYP_RL => l_CM_TYP_RL
13333 ,P_CM_USG_CD => r_CCT.INFORMATION16
13334 ,P_DESC_TXT => r_CCT.INFORMATION185
13335 ,P_INSPN_RQD_FLAG => r_CCT.INFORMATION14
13336 ,P_INSPN_RQD_RL => l_INSPN_RQD_RL
13337 ,P_MX_NUM_AVLBL_VAL => r_CCT.INFORMATION262
13338 ,P_NAME => l_prefix || r_CCT.INFORMATION170 || l_suffix
13339 ,P_PARNT_CM_TYP_ID => l_PARNT_CM_TYP_ID
13340 ,P_PC_KIT_CD => r_CCT.INFORMATION17
13341 ,P_RCPENT_CD => r_CCT.INFORMATION15
13342 ,P_SHRT_NAME => r_CCT.INFORMATION141
13343 ,P_TO_BE_SENT_DT_CD => r_CCT.INFORMATION13
13344 ,P_TO_BE_SENT_DT_RL => l_TO_BE_SENT_DT_RL
13345 ,P_TRK_MLG_FLAG => r_CCT.INFORMATION12
13346 ,P_WHNVR_TRGRD_FLAG => r_CCT.INFORMATION11
13347 --
13348 ,P_EFFECTIVE_START_DATE => l_effective_start_date
13349 ,P_EFFECTIVE_END_DATE => l_effective_end_date
13350 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
13351 ,P_DATETRACK_MODE => l_datetrack_mode
13352 );
13353 --
13354 end if;
13355 end if;
13356 --
13357 -- Delete the row if it is end dated.
13358 --
13359 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
13360 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
13361 trunc(l_max_eed) = r_CCT.information3) then
13362 --
13363 BEN_COMP_COMM_TYPES_API.delete_COMP_COMM_TYPES(
13364 --
13365 p_validate => false
13366 ,p_cm_typ_id => l_cm_typ_id
13367 ,p_effective_start_date => l_effective_start_date
13368 ,p_effective_end_date => l_effective_end_date
13369 ,p_object_version_number => l_object_version_number
13370 ,p_effective_date => l_max_eed
13371 ,p_datetrack_mode => hr_api.g_delete
13372 --
13373 );
13374 --
13375 end if;
13376 --
13377 l_prev_pk_id := l_current_pk_id ;
13378 --
13379 end if;
13380 --
13381 end if;
13382 --
13383 end loop;
13384 --
13385 exception when others then
13386 --
13387 raise_error_message( 'CCT',l_prefix || r_CCT.INFORMATION170 || l_suffix) ;
13388 --
13389 end create_CCT_rows;
13390
13391 --
13392 ---------------------------------------------------------------
13393 ----------------------< create_PDL_rows >-----------------------
13394 ---------------------------------------------------------------
13395 --
13396 procedure create_PDL_rows
13397 (
13398 p_validate in number default 0
13399 ,p_copy_entity_txn_id in number
13400 ,p_effective_date in date
13401 ,p_prefix_suffix_text in varchar2 default null
13402 ,p_reuse_object_flag in varchar2 default null
13403 ,p_target_business_group_id in varchar2 default null
13404 ,p_prefix_suffix_cd in varchar2 default null
13405 ) is
13406 --
13407 cursor c_unique_PDL(l_table_alias varchar2) is
13408 select distinct cpe.information1,
13409 cpe.information2,
13410 cpe.information3,
13411 cpe.INFORMATION170 name,
13412 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
13413 from ben_copy_entity_results cpe,
13414 pqh_table_route tr
13415 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13416 and cpe.table_route_id = tr.table_route_id
13417 -- and tr.where_clause = l_BEN_PTD_LMT_F
13418 and tr.table_alias = l_table_alias
13419 and cpe.number_of_copies = 1 --ADDITION
13420 group by cpe.information1,cpe.information2,cpe.information3, cpe.INFORMATION170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
13421 order by information1, information2; --added for bug: 5151945
13422 --
13423 --
13424 cursor c_PDL_min_max_dates(c_table_route_id number,
13425 c_information1 number) is
13426 select
13427 min(cpe.information2) min_esd,
13428 max(cpe.information3) min_eed
13429 from ben_copy_entity_results cpe
13430 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13431 and cpe.table_route_id = c_table_route_id
13432 and cpe.information1 = c_information1 ;
13433 --
13434 cursor c_PDL(c_table_route_id number,
13435 c_information1 number,
13436 c_information2 date,
13437 c_information3 date ) is
13438 select
13439 cpe.*
13440 from ben_copy_entity_results cpe
13441 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13442 and cpe.table_route_id = c_table_route_id
13443 and cpe.information1 = c_information1
13444 and cpe.information2 = c_information2
13445 and cpe.information3 = c_information3
13446 and rownum = 1 ;
13447 -- Date Track target record
13448 cursor c_find_PDL_in_target( c_PDL_name varchar2,
13449 c_effective_start_date date,
13450 c_effective_end_date date,
13451 c_business_group_id number,
13452 c_new_pk_id number) is
13453 select
13454 PDL.ptd_lmt_id new_value
13455 from BEN_PTD_LMT_F PDL
13456 where PDL.name = c_PDL_name
13457 and PDL.business_group_id = c_business_group_id
13458 and PDL.ptd_lmt_id <> c_new_pk_id
13459 --TEMPIK
13460 and c_effective_start_date between effective_start_date
13461 and effective_end_date ;
13462 --END TEMPIK
13463 /*TEMPIK
13464 and exists ( select null
13465 from BEN_PTD_LMT_F PDL1
13466 where PDL1.name = c_PDL_name
13467 and PDL1.business_group_id = c_business_group_id
13468 and PDL1.effective_start_date <= c_effective_start_date )
13469 and exists ( select null
13470 from BEN_PTD_LMT_F PDL2
13471 where PDL2.name = c_PDL_name
13472 and PDL2.business_group_id = c_business_group_id
13473 and PDL2.effective_end_date >= c_effective_end_date )
13474 ;
13475 TEMPIK */
13476 --TEMPIK
13477 l_dt_rec_found boolean ;
13478 --END TEMPIK
13479 --
13480 l_current_pk_id number := null ;
13481 --UPD START
13482 --
13483 l_update boolean := false ;
13484 l_datetrack_mode varchar2(80) := hr_api.g_update;
13485 l_process_date date;
13486 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
13487 --
13488 --UPD END
13489 l_prev_pk_id number := null ;
13490 l_first_rec boolean := true ;
13491 r_PDL c_PDL%rowtype;
13492 l_ptd_lmt_id number ;
13493 l_object_version_number number ;
13494 l_effective_start_date date ;
13495 l_effective_end_date date ;
13496 l_prefix pqh_copy_entity_attribs.information1%type := null;
13497 l_suffix pqh_copy_entity_attribs.information1%type := null;
13498 l_new_value number(15);
13499 l_object_found_in_target boolean := false ;
13500 l_min_esd date;
13501 l_max_eed date;
13502 l_BALANCE_TYPE_ID number;
13503 l_COMP_LVL_FCTR_ID number;
13504 l_PTD_LMT_CALC_RL number;
13505 l_effective_date date;
13506 --
13507 begin
13508 -- Initialization
13509 l_object_found_in_target := false ;
13510 -- End Initialization
13511 -- Derive the prefix - sufix
13512 if p_prefix_suffix_cd = 'PREFIX' then
13513 l_prefix := p_prefix_suffix_text ;
13514 elsif p_prefix_suffix_cd = 'SUFFIX' then
13515 l_suffix := p_prefix_suffix_text ;
13516 else
13517 l_prefix := null ;
13518 l_suffix := null ;
13519 end if ;
13520 -- End Prefix Sufix derivation
13521 for r_PDL_unique in c_unique_PDL('PDL') loop
13522
13523 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
13524 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13525 r_PDL_unique.information3 >=
13526 ben_pd_copy_to_ben_one.g_copy_effective_date)
13527 ) then
13528 --
13529 hr_utility.set_location(' r_PDL_unique.table_route_id '||r_PDL_unique.table_route_id,10);
13530 hr_utility.set_location(' r_PDL_unique.information1 '||r_PDL_unique.information1,10);
13531 hr_utility.set_location( 'r_PDL_unique.information2 '||r_PDL_unique.information2,10);
13532 hr_utility.set_location( 'r_PDL_unique.information3 '||r_PDL_unique.information3,10);
13533 -- If reuse objects flag is 'Y' then check for the object in the target business group
13534 -- if found insert the record into PLSql table and exit the loop else try create the
13535 -- object in the target business group
13536 --
13537 l_object_found_in_target := false ;
13538 --UPD START
13539 l_update := false;
13540 l_process_date := p_effective_date;
13541 l_dml_operation:= r_PDL_unique.dml_operation ;
13542 --
13543 if l_dml_operation = 'UPDATE' then
13544 --
13545 l_object_found_in_target := TRUE;
13546 --
13547 if l_process_date between r_PDL_unique.information2 and r_PDL_unique.information3 then
13548 l_update := true;
13549 if r_PDL_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
13550 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PTD_LMT_ID' then
13551 g_pk_tbl(g_count).pk_id_column := 'PTD_LMT_ID' ;
13552 g_pk_tbl(g_count).old_value := r_PDL_unique.information1 ;
13553 g_pk_tbl(g_count).new_value := r_PDL_unique.information1 ;
13554 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
13555 g_pk_tbl(g_count).table_route_id := r_PDL_unique.table_route_id;
13556 --
13557 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
13558 --
13559 g_count := g_count + 1 ;
13560 --
13561 log_data('PDL',l_new_value,l_prefix || r_PDL_unique.name|| l_suffix,'REUSED');
13562 --
13563 end if ;
13564 hr_utility.set_location( 'found record for update',10);
13565 --
13566 else
13567 --
13568 l_update := false;
13569 --
13570 end if;
13571 else
13572 --
13573 --UPD END
13574 l_min_esd := null ;
13575 l_max_eed := null ;
13576 open c_PDL_min_max_dates(r_PDL_unique.table_route_id, r_PDL_unique.information1 ) ;
13577 fetch c_PDL_min_max_dates into l_min_esd,l_max_eed ;
13578
13579 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13580 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
13581 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
13582 end if;
13583 l_min_esd := greatest(l_min_esd,r_PDL_unique.information2);
13584
13585 if p_reuse_object_flag = 'Y' then
13586 if c_PDL_min_max_dates%found then
13587 -- cursor to find the object
13588 open c_find_PDL_in_target( l_prefix || r_PDL_unique.name || l_suffix ,l_min_esd,l_max_eed,
13589 p_target_business_group_id, nvl(l_ptd_lmt_id, -999) ) ;
13590 fetch c_find_PDL_in_target into l_new_value ;
13591 if c_find_PDL_in_target%found then
13592 --
13593 --TEMPIK
13594 l_dt_rec_found := dt_api.check_min_max_dates
13595 (p_base_table_name => 'BEN_PTD_LMT_F',
13596 p_base_key_column => 'PTD_LMT_ID',
13597 p_base_key_value => l_new_value,
13598 p_from_date => l_min_esd,
13599 p_to_date => l_max_eed );
13600 if l_dt_rec_found THEN
13601 --END TEMPIK
13602 if r_PDL_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
13603 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PTD_LMT_ID' then
13604 g_pk_tbl(g_count).pk_id_column := 'PTD_LMT_ID' ;
13605 g_pk_tbl(g_count).old_value := r_PDL_unique.information1 ;
13606 g_pk_tbl(g_count).new_value := l_new_value ;
13607 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
13608 g_pk_tbl(g_count).table_route_id := r_PDL_unique.table_route_id;
13609 --
13610 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
13611 --
13612 g_count := g_count + 1 ;
13613 --
13614 log_data('PDL',l_new_value,l_prefix || r_PDL_unique.name || l_suffix ,'REUSED');
13615 --
13616 end if ;
13617 --
13618 l_object_found_in_target := true ;
13619 --TEMPIK
13620 end if; -- l_dt_rec_found
13621 --END TEMPIK
13622 end if;
13623 close c_find_PDL_in_target ;
13624 --
13625 end if;
13626 end if ;
13627 --
13628 close c_PDL_min_max_dates ;
13629 end if;
13630 if not l_object_found_in_target or l_update then
13631 --
13632 open c_PDL(r_PDL_unique.table_route_id,
13633 r_PDL_unique.information1,
13634 r_PDL_unique.information2,
13635 r_PDL_unique.information3 ) ;
13636 --
13637 fetch c_PDL into r_PDL ;
13638 --
13639 close c_PDL ;
13640 --
13641 l_current_pk_id := r_PDL.information1;
13642 --
13643 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
13644 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
13645 --
13646 if l_current_pk_id = l_prev_pk_id then
13647 --
13648 l_first_rec := false ;
13649 --
13650 else
13651 --
13652 l_first_rec := true ;
13653 --
13654 end if ;
13655 --
13656 l_BALANCE_TYPE_ID := get_fk('BALANCE_TYPE_ID', r_PDL.INFORMATION260,l_dml_operation);
13657 l_COMP_LVL_FCTR_ID := get_fk('COMP_LVL_FCTR_ID', r_PDL.INFORMATION254,l_dml_operation);
13658 l_PTD_LMT_CALC_RL := get_fk('FORMULA_ID', r_PDL.INFORMATION261,l_dml_operation);
13659 --
13660 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_PTD_LMT_F',l_prefix || r_PDL.INFORMATION170 || l_suffix);
13661 --
13662
13663 l_effective_date := r_PDL.information2;
13664 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
13665 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
13666 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
13667 end if;
13668
13669 if l_first_rec and not l_update then
13670 -- Call Create routine.
13671 hr_utility.set_location(' BEN_PTD_LMT_F CREATE_PERIOD_LIMIT ',20);
13672 BEN_PERIOD_LIMIT_API.CREATE_PERIOD_LIMIT(
13673 --
13674 P_VALIDATE => false
13675 ,P_EFFECTIVE_DATE => l_effective_date
13676 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
13677 --
13678 ,P_BALANCE_TYPE_ID => l_BALANCE_TYPE_ID
13679 ,P_COMP_LVL_FCTR_ID => l_COMP_LVL_FCTR_ID
13680 ,P_LMT_DET_CD => r_PDL.INFORMATION11
13681 ,P_MX_COMP_TO_CNSDR => r_PDL.INFORMATION293
13682 ,P_MX_PCT_VAL => r_PDL.INFORMATION295
13683 ,P_MX_VAL => r_PDL.INFORMATION294
13684 ,P_NAME => l_prefix || r_PDL.INFORMATION170 || l_suffix
13685 ,P_PDL_ATTRIBUTE1 => r_PDL.INFORMATION111
13686 ,P_PDL_ATTRIBUTE10 => r_PDL.INFORMATION120
13687 ,P_PDL_ATTRIBUTE11 => r_PDL.INFORMATION121
13688 ,P_PDL_ATTRIBUTE12 => r_PDL.INFORMATION122
13689 ,P_PDL_ATTRIBUTE13 => r_PDL.INFORMATION123
13690 ,P_PDL_ATTRIBUTE14 => r_PDL.INFORMATION124
13691 ,P_PDL_ATTRIBUTE15 => r_PDL.INFORMATION125
13692 ,P_PDL_ATTRIBUTE16 => r_PDL.INFORMATION126
13693 ,P_PDL_ATTRIBUTE17 => r_PDL.INFORMATION127
13694 ,P_PDL_ATTRIBUTE18 => r_PDL.INFORMATION128
13695 ,P_PDL_ATTRIBUTE19 => r_PDL.INFORMATION129
13696 ,P_PDL_ATTRIBUTE2 => r_PDL.INFORMATION112
13697 ,P_PDL_ATTRIBUTE20 => r_PDL.INFORMATION130
13698 ,P_PDL_ATTRIBUTE21 => r_PDL.INFORMATION131
13699 ,P_PDL_ATTRIBUTE22 => r_PDL.INFORMATION132
13700 ,P_PDL_ATTRIBUTE23 => r_PDL.INFORMATION133
13701 ,P_PDL_ATTRIBUTE24 => r_PDL.INFORMATION134
13702 ,P_PDL_ATTRIBUTE25 => r_PDL.INFORMATION135
13703 ,P_PDL_ATTRIBUTE26 => r_PDL.INFORMATION136
13704 ,P_PDL_ATTRIBUTE27 => r_PDL.INFORMATION137
13705 ,P_PDL_ATTRIBUTE28 => r_PDL.INFORMATION138
13706 ,P_PDL_ATTRIBUTE29 => r_PDL.INFORMATION139
13707 ,P_PDL_ATTRIBUTE3 => r_PDL.INFORMATION113
13708 ,P_PDL_ATTRIBUTE30 => r_PDL.INFORMATION140
13709 ,P_PDL_ATTRIBUTE4 => r_PDL.INFORMATION114
13710 ,P_PDL_ATTRIBUTE5 => r_PDL.INFORMATION115
13711 ,P_PDL_ATTRIBUTE6 => r_PDL.INFORMATION116
13712 ,P_PDL_ATTRIBUTE7 => r_PDL.INFORMATION117
13713 ,P_PDL_ATTRIBUTE8 => r_PDL.INFORMATION118
13714 ,P_PDL_ATTRIBUTE9 => r_PDL.INFORMATION119
13715 ,P_PDL_ATTRIBUTE_CATEGORY => r_PDL.INFORMATION110
13716 ,P_PTD_LMT_CALC_RL => l_PTD_LMT_CALC_RL
13717 ,P_PTD_LMT_ID => l_ptd_lmt_id
13718 --
13719 ,P_EFFECTIVE_START_DATE => l_effective_start_date
13720 ,P_EFFECTIVE_END_DATE => l_effective_end_date
13721 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
13722 );
13723 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
13724 -- Update all relevent cer records with new pk_id
13725 hr_utility.set_location('Before plsql table ',222);
13726 hr_utility.set_location('new_value id '||l_ptd_lmt_id,222);
13727 g_pk_tbl(g_count).pk_id_column := 'PTD_LMT_ID' ;
13728 g_pk_tbl(g_count).old_value := r_PDL.information1 ;
13729 g_pk_tbl(g_count).new_value := l_PTD_LMT_ID ;
13730 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
13731 g_pk_tbl(g_count).table_route_id := r_PDL_unique.table_route_id;
13732 hr_utility.set_location('After plsql table ',222);
13733 --
13734 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
13735 --
13736 g_count := g_count + 1 ;
13737 --
13738 log_data('PDL',l_new_value,l_prefix || r_PDL.INFORMATION170 || l_suffix,'COPIED');
13739 --
13740 else
13741 --
13742 --UPD START
13743 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
13744 --
13745 if l_update then
13746 --
13747 l_datetrack_mode := r_PDL.datetrack_mode ;
13748 --
13749 get_dt_modes(
13750 p_effective_date => l_process_date,
13751 p_effective_end_date => r_PDL.information3,
13752 p_effective_start_date => r_PDL.information2,
13753 p_dml_operation => r_PDL.dml_operation,
13754 p_datetrack_mode => l_datetrack_mode );
13755 -- p_update => l_update
13756 --
13757 l_effective_date := l_process_date;
13758 l_PTD_LMT_ID := r_PDL.information1;
13759 l_object_version_number := r_PDL.information265;
13760 --
13761 end if;
13762 --
13763 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
13764 --
13765 IF l_update OR l_dml_operation <> 'UPDATE' THEN
13766 --UPD END
13767 -- Call Update routine for the pk_id created in prev run .
13768 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
13769 hr_utility.set_location(' BEN_PTD_LMT_F UPDATE_PERIOD_LIMIT ',30);
13770 BEN_PERIOD_LIMIT_API.UPDATE_PERIOD_LIMIT(
13771 --
13772 P_VALIDATE => false
13773 ,P_EFFECTIVE_DATE => l_effective_date
13774 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
13775 --
13776 ,P_BALANCE_TYPE_ID => l_BALANCE_TYPE_ID
13777 ,P_COMP_LVL_FCTR_ID => l_COMP_LVL_FCTR_ID
13778 ,P_LMT_DET_CD => r_PDL.INFORMATION11
13779 ,P_MX_COMP_TO_CNSDR => r_PDL.INFORMATION293
13780 ,P_MX_PCT_VAL => r_PDL.INFORMATION295
13781 ,P_MX_VAL => r_PDL.INFORMATION294
13782 ,P_NAME => l_prefix || r_PDL.INFORMATION170 || l_suffix
13783 ,P_PDL_ATTRIBUTE1 => r_PDL.INFORMATION111
13784 ,P_PDL_ATTRIBUTE10 => r_PDL.INFORMATION120
13785 ,P_PDL_ATTRIBUTE11 => r_PDL.INFORMATION121
13786 ,P_PDL_ATTRIBUTE12 => r_PDL.INFORMATION122
13787 ,P_PDL_ATTRIBUTE13 => r_PDL.INFORMATION123
13788 ,P_PDL_ATTRIBUTE14 => r_PDL.INFORMATION124
13789 ,P_PDL_ATTRIBUTE15 => r_PDL.INFORMATION125
13790 ,P_PDL_ATTRIBUTE16 => r_PDL.INFORMATION126
13791 ,P_PDL_ATTRIBUTE17 => r_PDL.INFORMATION127
13792 ,P_PDL_ATTRIBUTE18 => r_PDL.INFORMATION128
13793 ,P_PDL_ATTRIBUTE19 => r_PDL.INFORMATION129
13794 ,P_PDL_ATTRIBUTE2 => r_PDL.INFORMATION112
13795 ,P_PDL_ATTRIBUTE20 => r_PDL.INFORMATION130
13796 ,P_PDL_ATTRIBUTE21 => r_PDL.INFORMATION131
13797 ,P_PDL_ATTRIBUTE22 => r_PDL.INFORMATION132
13798 ,P_PDL_ATTRIBUTE23 => r_PDL.INFORMATION133
13799 ,P_PDL_ATTRIBUTE24 => r_PDL.INFORMATION134
13800 ,P_PDL_ATTRIBUTE25 => r_PDL.INFORMATION135
13801 ,P_PDL_ATTRIBUTE26 => r_PDL.INFORMATION136
13802 ,P_PDL_ATTRIBUTE27 => r_PDL.INFORMATION137
13803 ,P_PDL_ATTRIBUTE28 => r_PDL.INFORMATION138
13804 ,P_PDL_ATTRIBUTE29 => r_PDL.INFORMATION139
13805 ,P_PDL_ATTRIBUTE3 => r_PDL.INFORMATION113
13806 ,P_PDL_ATTRIBUTE30 => r_PDL.INFORMATION140
13807 ,P_PDL_ATTRIBUTE4 => r_PDL.INFORMATION114
13808 ,P_PDL_ATTRIBUTE5 => r_PDL.INFORMATION115
13809 ,P_PDL_ATTRIBUTE6 => r_PDL.INFORMATION116
13810 ,P_PDL_ATTRIBUTE7 => r_PDL.INFORMATION117
13811 ,P_PDL_ATTRIBUTE8 => r_PDL.INFORMATION118
13812 ,P_PDL_ATTRIBUTE9 => r_PDL.INFORMATION119
13813 ,P_PDL_ATTRIBUTE_CATEGORY => r_PDL.INFORMATION110
13814 ,P_PTD_LMT_CALC_RL => l_PTD_LMT_CALC_RL
13815 ,P_PTD_LMT_ID => l_ptd_lmt_id
13816 --
13817 ,P_EFFECTIVE_START_DATE => l_effective_start_date
13818 ,P_EFFECTIVE_END_DATE => l_effective_end_date
13819 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
13820 ,P_DATETRACK_MODE => l_datetrack_mode
13821 );
13822 --
13823 end if;
13824 end if;
13825 --
13826 -- Delete the row if it is end dated.
13827 --
13828 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
13829 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
13830 trunc(l_max_eed) = r_PDL.information3) then
13831 --
13832 BEN_PERIOD_LIMIT_API.delete_PERIOD_LIMIT(
13833 --
13834 p_validate => false
13835 ,p_ptd_lmt_id => l_ptd_lmt_id
13836 ,p_effective_start_date => l_effective_start_date
13837 ,p_effective_end_date => l_effective_end_date
13838 ,p_object_version_number => l_object_version_number
13839 ,p_effective_date => l_max_eed
13840 ,p_datetrack_mode => hr_api.g_delete
13841 --
13842 );
13843 --
13844 end if;
13845 --
13846 l_prev_pk_id := l_current_pk_id ;
13847 --
13848 end if;
13849 --
13850 end if;
13851 --
13852 end loop;
13853 --
13854 exception when others then
13855 --
13856 raise_error_message( 'PDL',l_prefix || r_PDL.INFORMATION170 || l_suffix) ;
13857 --
13858 end create_PDL_rows;
13859
13860 --
13861 ---------------------------------------------------------------
13862 ----------------------< create_YRP_rows >-----------------------
13863 ---------------------------------------------------------------
13864 --
13865 procedure create_YRP_rows
13866 (
13867 p_validate in number default 0
13868 ,p_copy_entity_txn_id in number
13869 ,p_effective_date in date
13870 ,p_prefix_suffix_text in varchar2 default null
13871 ,p_reuse_object_flag in varchar2 default null
13872 ,p_target_business_group_id in varchar2 default null
13873 ,p_prefix_suffix_cd in varchar2 default null
13874 ) is
13875 --
13876 cursor c_unique_YRP(l_table_alias varchar2) is
13877 select distinct cpe.information1,
13878 cpe.information2,
13879 cpe.information3,
13880 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
13881 from ben_copy_entity_results cpe,
13882 pqh_table_route tr
13883 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13884 and cpe.table_route_id = tr.table_route_id
13885 -- and tr.where_clause = l_BEN_YR_PERD
13886 and tr.table_alias = l_table_alias
13887 and cpe.number_of_copies = 1 --ADDITION
13888 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
13889 order by information1, information2; --added for bug: 5151945
13890 --
13891 --
13892 cursor c_YRP_min_max_dates(c_table_route_id number,
13893 c_information1 number) is
13894 select
13895 min(cpe.information2) min_esd,
13896 max(cpe.information3) min_eed
13897 from ben_copy_entity_results cpe
13898 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13899 and cpe.table_route_id = c_table_route_id
13900 and cpe.information1 = c_information1 ;
13901 --
13902 cursor c_YRP(c_table_route_id number,
13903 c_information1 number,
13904 c_information2 date,
13905 c_information3 date ) is
13906 select
13907 cpe.*
13908 from ben_copy_entity_results cpe
13909 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
13910 and cpe.table_route_id = c_table_route_id
13911 and cpe.information1 = c_information1
13912 and rownum = 1 ;
13913 -- Date Track target record
13914 cursor c_find_YRP_in_target( c_start_date date,
13915 c_end_date date,
13916 c_business_group_id number,
13917 c_new_pk_id number) is
13918 select
13919 YRP.yr_perd_id new_value
13920 from BEN_YR_PERD YRP
13921 where
13922 YRP.business_group_id = c_business_group_id
13923 and YRP.start_date = c_start_date
13924 and YRP.end_date = c_end_date
13925 and YRP.yr_perd_id <> c_new_pk_id
13926 ;
13927 --
13928 l_current_pk_id number := null ;
13929 --UPD START
13930 --
13931 l_update boolean := false ;
13932 l_datetrack_mode varchar2(80) := hr_api.g_update;
13933 l_process_date date;
13934 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
13935 --
13936 --UPD END
13937 l_prev_pk_id number := null ;
13938 l_first_rec boolean := true ;
13939 r_YRP c_YRP%rowtype;
13940 l_yr_perd_id number ;
13941 l_object_version_number number ;
13942 l_effective_start_date date ;
13943 l_effective_end_date date ;
13944 l_prefix pqh_copy_entity_attribs.information1%type := null;
13945 l_suffix pqh_copy_entity_attribs.information1%type := null;
13946 l_new_value number(15);
13947 l_object_found_in_target boolean := false ;
13948 l_min_esd date;
13949 l_max_eed date;
13950 --
13951 begin
13952 -- Initialization
13953 l_object_found_in_target := false ;
13954 -- End Initialization
13955 -- Derive the prefix - sufix
13956 if p_prefix_suffix_cd = 'PREFIX' then
13957 l_prefix := p_prefix_suffix_text ;
13958 elsif p_prefix_suffix_cd = 'SUFFIX' then
13959 l_suffix := p_prefix_suffix_text ;
13960 else
13961 l_prefix := null ;
13962 l_suffix := null ;
13963 end if ;
13964 -- End Prefix Sufix derivation
13965 for r_YRP_unique in c_unique_YRP('YRP') loop
13966 --
13967 hr_utility.set_location(' r_YRP_unique.table_route_id '||r_YRP_unique.table_route_id,10);
13968 hr_utility.set_location(' r_YRP_unique.information1 '||r_YRP_unique.information1,10);
13969 hr_utility.set_location( 'r_YRP_unique.information2 '||r_YRP_unique.information2,10);
13970 hr_utility.set_location( 'r_YRP_unique.information3 '||r_YRP_unique.information3,10);
13971 -- If reuse objects flag is 'Y' then check for the object in the target business group
13972 -- if found insert the record into PLSql table and exit the loop else try create the
13973 -- object in the target business group
13974 --
13975 l_object_found_in_target := false ;
13976 open c_YRP(r_YRP_unique.table_route_id,
13977 r_YRP_unique.information1,
13978 r_YRP_unique.information2,
13979 r_YRP_unique.information3 ) ;
13980 --
13981 fetch c_YRP into r_YRP ;
13982 --
13983 close c_YRP ;
13984 --UPD START
13985 l_dml_operation := r_YRP_unique.dml_operation;
13986 --
13987 l_update := false;
13988 --
13989 if l_dml_operation = 'UPDATE' then
13990 --
13991 l_update := true;
13992 if r_YRP_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
13993 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'YR_PERD_ID' then
13994 g_pk_tbl(g_count).pk_id_column := 'YR_PERD_ID' ;
13995 g_pk_tbl(g_count).old_value := r_YRP_unique.information1 ;
13996 g_pk_tbl(g_count).new_value := r_YRP_unique.information1 ;
13997 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
13998 g_pk_tbl(g_count).table_route_id := r_YRP_unique.table_route_id;
13999 --
14000 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ; -- NEW
14001 --
14002 g_count := g_count + 1 ;
14003 --
14004 log_data('YRP',l_new_value,l_prefix || r_YRP_unique.information1|| l_suffix,'REUSED');
14005 --
14006 end if ;
14007 l_YR_PERD_ID := r_YRP_unique.information1 ;
14008 l_object_version_number := r_YRP.information265 ;
14009 hr_utility.set_location( 'found record for update',10);
14010 --
14011 else
14012 l_min_esd := null ;
14013 l_max_eed := null ;
14014 /*
14015 open c_YRP(r_YRP_unique.table_route_id,
14016 r_YRP_unique.information1,
14017 r_YRP_unique.information2,
14018 r_YRP_unique.information3 ) ;
14019 --
14020 fetch c_YRP into r_YRP ;
14021 --
14022 close c_YRP ;
14023 */
14024 --
14025 -- Year periods should always be reused.
14026 -- if p_reuse_object_flag = 'Y' then
14027 -- cursor to find the object
14028 open c_find_YRP_in_target( r_YRP.INFORMATION309, r_YRP.INFORMATION308,
14029 p_target_business_group_id, nvl(l_yr_perd_id, -999) ) ;
14030 fetch c_find_YRP_in_target into l_new_value ;
14031 if c_find_YRP_in_target%found then
14032 --
14033 if r_YRP_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
14034 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'YR_PERD_ID' then
14035 g_pk_tbl(g_count).pk_id_column := 'YR_PERD_ID' ;
14036 g_pk_tbl(g_count).old_value := r_YRP_unique.information1 ;
14037 g_pk_tbl(g_count).new_value := l_new_value ;
14038 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
14039 g_pk_tbl(g_count).table_route_id := r_YRP_unique.table_route_id;
14040 --
14041 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
14042 --
14043 g_count := g_count + 1 ;
14044 end if ;
14045 --
14046 l_object_found_in_target := true ;
14047 end if;
14048 close c_find_YRP_in_target ;
14049 --
14050 -- end if ;
14051 --
14052 end if;
14053 if not l_object_found_in_target or l_update then
14054 --
14055 l_current_pk_id := r_YRP.information1;
14056 --
14057 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
14058 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
14059 --
14060 if l_current_pk_id = l_prev_pk_id then
14061 --
14062 l_first_rec := false ;
14063 --
14064 else
14065 --
14066 l_first_rec := true ;
14067 --
14068 end if ;
14069 --
14070 if l_first_rec and not l_update then
14071 -- Call Create routine.
14072 hr_utility.set_location(' BEN_YR_PERD CREATE_PGM_OR_PL_YR_PERD ',20);
14073 BEN_PGM_OR_PL_YR_PERD_API.CREATE_PGM_OR_PL_YR_PERD(
14074 --
14075 P_VALIDATE => false
14076 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
14077 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
14078 --
14079 ,P_END_DATE => r_YRP.INFORMATION308
14080 ,P_LMTN_YR_END_DT => r_YRP.INFORMATION311
14081 ,P_LMTN_YR_STRT_DT => r_YRP.INFORMATION310
14082 ,P_PERDS_IN_YR_NUM => r_YRP.INFORMATION260
14083 ,P_PERD_TM_UOM_CD => r_YRP.INFORMATION11
14084 ,P_PERD_TYP_CD => r_YRP.INFORMATION12
14085 ,P_START_DATE => r_YRP.INFORMATION309
14086 ,P_YRP_ATTRIBUTE1 => r_YRP.INFORMATION111
14087 ,P_YRP_ATTRIBUTE10 => r_YRP.INFORMATION120
14088 ,P_YRP_ATTRIBUTE11 => r_YRP.INFORMATION121
14089 ,P_YRP_ATTRIBUTE12 => r_YRP.INFORMATION122
14090 ,P_YRP_ATTRIBUTE13 => r_YRP.INFORMATION123
14091 ,P_YRP_ATTRIBUTE14 => r_YRP.INFORMATION124
14092 ,P_YRP_ATTRIBUTE15 => r_YRP.INFORMATION125
14093 ,P_YRP_ATTRIBUTE16 => r_YRP.INFORMATION126
14094 ,P_YRP_ATTRIBUTE17 => r_YRP.INFORMATION127
14095 ,P_YRP_ATTRIBUTE18 => r_YRP.INFORMATION128
14096 ,P_YRP_ATTRIBUTE19 => r_YRP.INFORMATION129
14097 ,P_YRP_ATTRIBUTE2 => r_YRP.INFORMATION112
14098 ,P_YRP_ATTRIBUTE20 => r_YRP.INFORMATION130
14099 ,P_YRP_ATTRIBUTE21 => r_YRP.INFORMATION131
14100 ,P_YRP_ATTRIBUTE22 => r_YRP.INFORMATION132
14101 ,P_YRP_ATTRIBUTE23 => r_YRP.INFORMATION133
14102 ,P_YRP_ATTRIBUTE24 => r_YRP.INFORMATION134
14103 ,P_YRP_ATTRIBUTE25 => r_YRP.INFORMATION135
14104 ,P_YRP_ATTRIBUTE26 => r_YRP.INFORMATION136
14105 ,P_YRP_ATTRIBUTE27 => r_YRP.INFORMATION137
14106 ,P_YRP_ATTRIBUTE28 => r_YRP.INFORMATION138
14107 ,P_YRP_ATTRIBUTE29 => r_YRP.INFORMATION139
14108 ,P_YRP_ATTRIBUTE3 => r_YRP.INFORMATION113
14109 ,P_YRP_ATTRIBUTE30 => r_YRP.INFORMATION140
14110 ,P_YRP_ATTRIBUTE4 => r_YRP.INFORMATION114
14111 ,P_YRP_ATTRIBUTE5 => r_YRP.INFORMATION115
14112 ,P_YRP_ATTRIBUTE6 => r_YRP.INFORMATION116
14113 ,P_YRP_ATTRIBUTE7 => r_YRP.INFORMATION117
14114 ,P_YRP_ATTRIBUTE8 => r_YRP.INFORMATION118
14115 ,P_YRP_ATTRIBUTE9 => r_YRP.INFORMATION119
14116 ,P_YRP_ATTRIBUTE_CATEGORY => r_YRP.INFORMATION110
14117 ,P_YR_PERD_ID => l_yr_perd_id
14118 --
14119 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
14120 );
14121 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
14122 -- Update all relevent cer records with new pk_id
14123 hr_utility.set_location('Before plsql table ',222);
14124 hr_utility.set_location('new_value id '||l_yr_perd_id,222);
14125 g_pk_tbl(g_count).pk_id_column := 'YR_PERD_ID' ;
14126 g_pk_tbl(g_count).old_value := r_YRP.information1 ;
14127 g_pk_tbl(g_count).new_value := l_YR_PERD_ID ;
14128 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
14129 g_pk_tbl(g_count).table_route_id := r_YRP_unique.table_route_id;
14130 hr_utility.set_location('After plsql table ',222);
14131 --
14132 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
14133 --
14134 g_count := g_count + 1 ;
14135 --
14136 elsif l_update then
14137
14138 hr_utility.set_location(' BEN_YR_PERD UPDATE_PGM_OR_PL_YR_PERD ',20);
14139 BEN_PGM_OR_PL_YR_PERD_API.UPDATE_PGM_OR_PL_YR_PERD(
14140 --
14141 P_VALIDATE => false
14142 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
14143 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
14144 --
14145 ,P_END_DATE => r_YRP.INFORMATION308
14146 ,P_LMTN_YR_END_DT => r_YRP.INFORMATION311
14147 ,P_LMTN_YR_STRT_DT => r_YRP.INFORMATION310
14148 ,P_PERDS_IN_YR_NUM => r_YRP.INFORMATION260
14149 ,P_PERD_TM_UOM_CD => r_YRP.INFORMATION11
14150 ,P_PERD_TYP_CD => r_YRP.INFORMATION12
14151 ,P_START_DATE => r_YRP.INFORMATION309
14152 ,P_YRP_ATTRIBUTE1 => r_YRP.INFORMATION111
14153 ,P_YRP_ATTRIBUTE10 => r_YRP.INFORMATION120
14154 ,P_YRP_ATTRIBUTE11 => r_YRP.INFORMATION121
14155 ,P_YRP_ATTRIBUTE12 => r_YRP.INFORMATION122
14156 ,P_YRP_ATTRIBUTE13 => r_YRP.INFORMATION123
14157 ,P_YRP_ATTRIBUTE14 => r_YRP.INFORMATION124
14158 ,P_YRP_ATTRIBUTE15 => r_YRP.INFORMATION125
14159 ,P_YRP_ATTRIBUTE16 => r_YRP.INFORMATION126
14160 ,P_YRP_ATTRIBUTE17 => r_YRP.INFORMATION127
14161 ,P_YRP_ATTRIBUTE18 => r_YRP.INFORMATION128
14162 ,P_YRP_ATTRIBUTE19 => r_YRP.INFORMATION129
14163 ,P_YRP_ATTRIBUTE2 => r_YRP.INFORMATION112
14164 ,P_YRP_ATTRIBUTE20 => r_YRP.INFORMATION130
14165 ,P_YRP_ATTRIBUTE21 => r_YRP.INFORMATION131
14166 ,P_YRP_ATTRIBUTE22 => r_YRP.INFORMATION132
14167 ,P_YRP_ATTRIBUTE23 => r_YRP.INFORMATION133
14168 ,P_YRP_ATTRIBUTE24 => r_YRP.INFORMATION134
14169 ,P_YRP_ATTRIBUTE25 => r_YRP.INFORMATION135
14170 ,P_YRP_ATTRIBUTE26 => r_YRP.INFORMATION136
14171 ,P_YRP_ATTRIBUTE27 => r_YRP.INFORMATION137
14172 ,P_YRP_ATTRIBUTE28 => r_YRP.INFORMATION138
14173 ,P_YRP_ATTRIBUTE29 => r_YRP.INFORMATION139
14174 ,P_YRP_ATTRIBUTE3 => r_YRP.INFORMATION113
14175 ,P_YRP_ATTRIBUTE30 => r_YRP.INFORMATION140
14176 ,P_YRP_ATTRIBUTE4 => r_YRP.INFORMATION114
14177 ,P_YRP_ATTRIBUTE5 => r_YRP.INFORMATION115
14178 ,P_YRP_ATTRIBUTE6 => r_YRP.INFORMATION116
14179 ,P_YRP_ATTRIBUTE7 => r_YRP.INFORMATION117
14180 ,P_YRP_ATTRIBUTE8 => r_YRP.INFORMATION118
14181 ,P_YRP_ATTRIBUTE9 => r_YRP.INFORMATION119
14182 ,P_YRP_ATTRIBUTE_CATEGORY => r_YRP.INFORMATION110
14183 ,P_YR_PERD_ID => l_yr_perd_id
14184 --
14185 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
14186 );
14187 end if;
14188 --
14189 l_prev_pk_id := l_current_pk_id ;
14190 --
14191 end if;
14192 --
14193 end loop;
14194 --
14195 exception when others then
14196 --
14197 raise_error_message( 'YRP',r_YRP.information5 ) ;
14198 --
14199 end create_YRP_rows;
14200 --
14201 ---------------------------------------------------------------
14202 ----------------------< create_WYP_rows >-----------------------
14203 ---------------------------------------------------------------
14204 --
14205 procedure create_WYP_rows
14206 (
14207 p_validate in number default 0
14208 ,p_copy_entity_txn_id in number
14209 ,p_effective_date in date
14210 ,p_prefix_suffix_text in varchar2 default null
14211 ,p_reuse_object_flag in varchar2 default null
14212 ,p_target_business_group_id in varchar2 default null
14213 ,p_prefix_suffix_cd in varchar2 default null
14214 ) is
14215 --
14216 cursor c_unique_WYP(l_table_alias varchar2) is
14217 select distinct cpe.information1,
14218 cpe.information2,
14219 cpe.information3,
14220 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
14221 from ben_copy_entity_results cpe,
14222 pqh_table_route tr
14223 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14224 and cpe.table_route_id = tr.table_route_id
14225 -- and tr.where_clause = l_BEN_WTHN_YR_PERD
14226 and tr.table_alias = l_table_alias
14227 and cpe.number_of_copies = 1 --ADDITION
14228 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
14229 order by information1, information2; --added for bug: 5151945
14230 --
14231 --
14232 cursor c_WYP_min_max_dates(c_table_route_id number,
14233 c_information1 number) is
14234 select
14235 min(cpe.information2) min_esd,
14236 max(cpe.information3) min_eed
14237 from ben_copy_entity_results cpe
14238 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14239 and cpe.table_route_id = c_table_route_id
14240 and cpe.information1 = c_information1 ;
14241 --
14242 cursor c_WYP(c_table_route_id number,
14243 c_information1 number,
14244 c_information2 date,
14245 c_information3 date ) is
14246 select
14247 cpe.*
14248 from ben_copy_entity_results cpe
14249 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14250 and cpe.table_route_id = c_table_route_id
14251 and cpe.information1 = c_information1
14252 and rownum = 1 ;
14253 -- Date Track target record
14254 r_WYP c_WYP%rowtype;
14255 l_YR_PERD_ID number;
14256 --
14257 cursor c_find_WYP_in_target(
14258 c_effective_start_date date,
14259 c_effective_end_date date,
14260 c_business_group_id number,
14261 c_new_pk_id number) is
14262 select WYP.wthn_yr_perd_id new_value
14263 from BEN_WTHN_YR_PERD WYP
14264 where WYP.business_group_id = c_business_group_id
14265 and WYP.strt_day = r_WYP.information293
14266 and WYP.strt_mo = r_WYP.information295
14267 and WYP.end_day = r_WYP.information294
14268 and WYP.end_mo = r_WYP.information296
14269 and WYP.tm_uom = r_WYP.information11
14270 and WYP.yr_perd_id = l_yr_perd_id
14271 and WYP.wthn_yr_perd_id <> c_new_pk_id ;
14272 --
14273 l_current_pk_id number := null ;
14274 --UPD START
14275 --
14276 l_update boolean := false ;
14277 l_datetrack_mode varchar2(80) := hr_api.g_update;
14278 l_process_date date;
14279 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
14280 --
14281 --UPD END
14282 l_prev_pk_id number := null ;
14283 l_first_rec boolean := true ;
14284 l_wthn_yr_perd_id number ;
14285 l_object_version_number number ;
14286 l_effective_start_date date ;
14287 l_effective_end_date date ;
14288 l_prefix pqh_copy_entity_attribs.information1%type := null;
14289 l_suffix pqh_copy_entity_attribs.information1%type := null;
14290 l_new_value number(15);
14291 l_object_found_in_target boolean := false ;
14292 l_min_esd date;
14293 l_max_eed date;
14294 --
14295 begin
14296 -- Initialization
14297 l_object_found_in_target := false ;
14298 -- End Initialization
14299 -- Derive the prefix - sufix
14300 if p_prefix_suffix_cd = 'PREFIX' then
14301 l_prefix := p_prefix_suffix_text ;
14302 elsif p_prefix_suffix_cd = 'SUFFIX' then
14303 l_suffix := p_prefix_suffix_text ;
14304 else
14305 l_prefix := null ;
14306 l_suffix := null ;
14307 end if ;
14308 -- End Prefix Sufix derivation
14309 for r_WYP_unique in c_unique_WYP('WYP') loop
14310 --
14311 hr_utility.set_location(' r_WYP_unique.table_route_id '||r_WYP_unique.table_route_id,10);
14312 hr_utility.set_location(' r_WYP_unique.information1 '||r_WYP_unique.information1,10);
14313 hr_utility.set_location( 'r_WYP_unique.information2 '||r_WYP_unique.information2,10);
14314 hr_utility.set_location( 'r_WYP_unique.information3 '||r_WYP_unique.information3,10);
14315 -- If reuse objects flag is 'Y' then check for the object in the target business group
14316 -- if found insert the record into PLSql table and exit the loop else try create the
14317 -- object in the target business group
14318 --
14319 l_object_found_in_target := false ;
14320 l_min_esd := null ;
14321 l_max_eed := null ;
14322 --
14323 open c_WYP(r_WYP_unique.table_route_id,
14324 r_WYP_unique.information1,
14325 r_WYP_unique.information2,
14326 r_WYP_unique.information3 ) ;
14327 --
14328 fetch c_WYP into r_WYP ;
14329 --
14330 close c_WYP ;
14331 --
14332 l_dml_operation := r_WYP_unique.dml_operation;
14333 l_YR_PERD_ID := get_fk('YR_PERD_ID', r_WYP.information240,l_dml_operation);
14334 l_update := false;
14335 --
14336 if l_dml_operation = 'UPDATE' then
14337 --
14338 l_update := true;
14339 if r_WYP_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
14340 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'WTHN_YR_PERD_ID' then
14341 g_pk_tbl(g_count).pk_id_column := 'WTHN_YR_PERD_ID' ;
14342 g_pk_tbl(g_count).old_value := r_WYP_unique.information1 ;
14343 g_pk_tbl(g_count).new_value := r_WYP_unique.information1 ;
14344 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
14345 g_pk_tbl(g_count).table_route_id := r_WYP_unique.table_route_id;
14346 --
14347 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ; -- NEW
14348 --
14349 g_count := g_count + 1 ;
14350 --
14351 log_data('WYP',l_new_value,l_prefix || r_WYP_unique.information1|| l_suffix,'REUSED');
14352 --
14353 end if ;
14354 l_WTHN_YR_PERD_ID := r_WYP_unique.information1 ;
14355 l_object_version_number := r_WYP.information265 ;
14356 hr_utility.set_location( 'found record for update',10);
14357 --
14358 else
14359
14360 -- IK This needs to be uncommented if the YRP is changed.
14361 -- if p_reuse_object_flag = 'Y' then
14362 -- cursor to find the object
14363 open c_find_WYP_in_target( r_WYP_unique.information2,l_max_eed,
14364 p_target_business_group_id, nvl(l_wthn_yr_perd_id, -999) ) ;
14365 fetch c_find_WYP_in_target into l_new_value ;
14366 if c_find_WYP_in_target%found then
14367 --
14368 if r_WYP_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
14369 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'WTHN_YR_PERD_ID' then
14370 g_pk_tbl(g_count).pk_id_column := 'WTHN_YR_PERD_ID' ;
14371 g_pk_tbl(g_count).old_value := r_WYP_unique.information1 ;
14372 g_pk_tbl(g_count).new_value := l_new_value ;
14373 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
14374 g_pk_tbl(g_count).table_route_id := r_WYP_unique.table_route_id;
14375 --
14376 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
14377 --
14378 g_count := g_count + 1 ;
14379 end if ;
14380 --
14381 l_object_found_in_target := true ;
14382 end if;
14383 close c_find_WYP_in_target ;
14384 --
14385 -- end if ;
14386 --
14387 end if;
14388 if not l_object_found_in_target or l_update then
14389 l_current_pk_id := r_WYP.information1;
14390 --
14391 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
14392 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
14393 --
14394 if l_current_pk_id = l_prev_pk_id then
14395 --
14396 l_first_rec := false ;
14397 --
14398 else
14399 --
14400 l_first_rec := true ;
14401 --
14402 end if ;
14403 --
14404 if l_first_rec and not l_update then
14405 -- Call Create routine.
14406 hr_utility.set_location(' BEN_WTHN_YR_PERD CREATE_WITHIN_YEAR_PERD ',20);
14407 BEN_WITHIN_YEAR_PERD_API.CREATE_WITHIN_YEAR_PERD(
14408 --
14409 P_VALIDATE => false
14410 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
14411 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
14412 --
14413 ,P_END_DAY => r_WYP.INFORMATION294
14414 ,P_END_MO => r_WYP.INFORMATION296
14415 ,P_STRT_DAY => r_WYP.INFORMATION293
14416 ,P_STRT_MO => r_WYP.INFORMATION295
14417 ,P_TM_UOM => r_WYP.INFORMATION11
14418 ,P_WTHN_YR_PERD_ID => l_wthn_yr_perd_id
14419 ,P_WYP_ATTRIBUTE1 => r_WYP.INFORMATION111
14420 ,P_WYP_ATTRIBUTE10 => r_WYP.INFORMATION120
14421 ,P_WYP_ATTRIBUTE11 => r_WYP.INFORMATION121
14422 ,P_WYP_ATTRIBUTE12 => r_WYP.INFORMATION122
14423 ,P_WYP_ATTRIBUTE13 => r_WYP.INFORMATION123
14424 ,P_WYP_ATTRIBUTE14 => r_WYP.INFORMATION124
14425 ,P_WYP_ATTRIBUTE15 => r_WYP.INFORMATION125
14426 ,P_WYP_ATTRIBUTE16 => r_WYP.INFORMATION126
14427 ,P_WYP_ATTRIBUTE17 => r_WYP.INFORMATION127
14428 ,P_WYP_ATTRIBUTE18 => r_WYP.INFORMATION128
14429 ,P_WYP_ATTRIBUTE19 => r_WYP.INFORMATION129
14430 ,P_WYP_ATTRIBUTE2 => r_WYP.INFORMATION112
14431 ,P_WYP_ATTRIBUTE20 => r_WYP.INFORMATION130
14432 ,P_WYP_ATTRIBUTE21 => r_WYP.INFORMATION131
14433 ,P_WYP_ATTRIBUTE22 => r_WYP.INFORMATION132
14434 ,P_WYP_ATTRIBUTE23 => r_WYP.INFORMATION133
14435 ,P_WYP_ATTRIBUTE24 => r_WYP.INFORMATION134
14436 ,P_WYP_ATTRIBUTE25 => r_WYP.INFORMATION135
14437 ,P_WYP_ATTRIBUTE26 => r_WYP.INFORMATION136
14438 ,P_WYP_ATTRIBUTE27 => r_WYP.INFORMATION137
14439 ,P_WYP_ATTRIBUTE28 => r_WYP.INFORMATION138
14440 ,P_WYP_ATTRIBUTE29 => r_WYP.INFORMATION139
14441 ,P_WYP_ATTRIBUTE3 => r_WYP.INFORMATION113
14442 ,P_WYP_ATTRIBUTE30 => r_WYP.INFORMATION140
14443 ,P_WYP_ATTRIBUTE4 => r_WYP.INFORMATION114
14444 ,P_WYP_ATTRIBUTE5 => r_WYP.INFORMATION115
14445 ,P_WYP_ATTRIBUTE6 => r_WYP.INFORMATION116
14446 ,P_WYP_ATTRIBUTE7 => r_WYP.INFORMATION117
14447 ,P_WYP_ATTRIBUTE8 => r_WYP.INFORMATION118
14448 ,P_WYP_ATTRIBUTE9 => r_WYP.INFORMATION119
14449 ,P_WYP_ATTRIBUTE_CATEGORY => r_WYP.INFORMATION110
14450 ,P_YR_PERD_ID => l_YR_PERD_ID
14451 --
14452 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
14453 );
14454 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
14455 -- Update all relevent cer records with new pk_id
14456 hr_utility.set_location('Before plsql table ',222);
14457 hr_utility.set_location('new_value id '||l_wthn_yr_perd_id,222);
14458 g_pk_tbl(g_count).pk_id_column := 'WTHN_YR_PERD_ID' ;
14459 g_pk_tbl(g_count).old_value := r_WYP.information1 ;
14460 g_pk_tbl(g_count).new_value := l_WTHN_YR_PERD_ID ;
14461 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
14462 g_pk_tbl(g_count).table_route_id := r_WYP_unique.table_route_id;
14463 hr_utility.set_location('After plsql table ',222);
14464 --
14465 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
14466 --
14467 g_count := g_count + 1 ;
14468 --
14469 elsif l_update then
14470
14471 hr_utility.set_location(' BEN_WTHN_YR_PERD UPDATE_WITHIN_YEAR_PERD ',20);
14472 BEN_WITHIN_YEAR_PERD_API.UPDATE_WITHIN_YEAR_PERD(
14473 --
14474 P_VALIDATE => false
14475 ,P_EFFECTIVE_DATE => NVL(ben_pd_copy_to_ben_one.g_copy_effective_date ,p_effective_date)
14476 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
14477 --
14478 ,P_END_DAY => r_WYP.INFORMATION294
14479 ,P_END_MO => r_WYP.INFORMATION296
14480 ,P_STRT_DAY => r_WYP.INFORMATION293
14481 ,P_STRT_MO => r_WYP.INFORMATION295
14482 ,P_TM_UOM => r_WYP.INFORMATION11
14483 ,P_WTHN_YR_PERD_ID => l_wthn_yr_perd_id
14484 ,P_WYP_ATTRIBUTE1 => r_WYP.INFORMATION111
14485 ,P_WYP_ATTRIBUTE10 => r_WYP.INFORMATION120
14486 ,P_WYP_ATTRIBUTE11 => r_WYP.INFORMATION121
14487 ,P_WYP_ATTRIBUTE12 => r_WYP.INFORMATION122
14488 ,P_WYP_ATTRIBUTE13 => r_WYP.INFORMATION123
14489 ,P_WYP_ATTRIBUTE14 => r_WYP.INFORMATION124
14490 ,P_WYP_ATTRIBUTE15 => r_WYP.INFORMATION125
14491 ,P_WYP_ATTRIBUTE16 => r_WYP.INFORMATION126
14492 ,P_WYP_ATTRIBUTE17 => r_WYP.INFORMATION127
14493 ,P_WYP_ATTRIBUTE18 => r_WYP.INFORMATION128
14494 ,P_WYP_ATTRIBUTE19 => r_WYP.INFORMATION129
14495 ,P_WYP_ATTRIBUTE2 => r_WYP.INFORMATION112
14496 ,P_WYP_ATTRIBUTE20 => r_WYP.INFORMATION130
14497 ,P_WYP_ATTRIBUTE21 => r_WYP.INFORMATION131
14498 ,P_WYP_ATTRIBUTE22 => r_WYP.INFORMATION132
14499 ,P_WYP_ATTRIBUTE23 => r_WYP.INFORMATION133
14500 ,P_WYP_ATTRIBUTE24 => r_WYP.INFORMATION134
14501 ,P_WYP_ATTRIBUTE25 => r_WYP.INFORMATION135
14502 ,P_WYP_ATTRIBUTE26 => r_WYP.INFORMATION136
14503 ,P_WYP_ATTRIBUTE27 => r_WYP.INFORMATION137
14504 ,P_WYP_ATTRIBUTE28 => r_WYP.INFORMATION138
14505 ,P_WYP_ATTRIBUTE29 => r_WYP.INFORMATION139
14506 ,P_WYP_ATTRIBUTE3 => r_WYP.INFORMATION113
14507 ,P_WYP_ATTRIBUTE30 => r_WYP.INFORMATION140
14508 ,P_WYP_ATTRIBUTE4 => r_WYP.INFORMATION114
14509 ,P_WYP_ATTRIBUTE5 => r_WYP.INFORMATION115
14510 ,P_WYP_ATTRIBUTE6 => r_WYP.INFORMATION116
14511 ,P_WYP_ATTRIBUTE7 => r_WYP.INFORMATION117
14512 ,P_WYP_ATTRIBUTE8 => r_WYP.INFORMATION118
14513 ,P_WYP_ATTRIBUTE9 => r_WYP.INFORMATION119
14514 ,P_WYP_ATTRIBUTE_CATEGORY => r_WYP.INFORMATION110
14515 ,P_YR_PERD_ID => l_YR_PERD_ID
14516 --
14517 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
14518 );
14519 end if;
14520 --
14521 l_prev_pk_id := l_current_pk_id ;
14522 --
14523 end if;
14524 --
14525 end loop;
14526 --
14527 exception when others then
14528 --
14529 raise_error_message( 'WYP',r_WYP.information5 ) ;
14530 --
14531 end create_WYP_rows;
14532 --
14533
14534 --
14535 ---------------------------------------------------------------
14536 ----------------------< create_PLN_rows >-----------------------
14537 ---------------------------------------------------------------
14538 --
14539 procedure create_PLN_rows
14540 (
14541 p_validate in number default 0
14542 ,p_copy_entity_txn_id in number
14543 ,p_effective_date in date
14544 ,p_prefix_suffix_text in varchar2 default null
14545 ,p_reuse_object_flag in varchar2 default null
14546 ,p_target_business_group_id in varchar2 default null
14547 ,p_prefix_suffix_cd in varchar2 default null
14548 ) is
14549 --
14550 -- REUSE ENHANCEMENT
14551 -- Added decode to copy CWB group Plans first
14552 --
14553 cursor c_unique_PLN(l_table_alias varchar2) is
14554 select distinct decode(cpe.information160,cpe.information1,1,2), cpe.information1,
14555 cpe.information2,
14556 cpe.information3,
14557 cpe.INFORMATION170 name,
14558 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode,
14559 cpe.information8
14560 from ben_copy_entity_results cpe,
14561 pqh_table_route tr
14562 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14563 and cpe.table_route_id = tr.table_route_id
14564 -- and tr.where_clause = l_BEN_PL_F
14565 and tr.table_alias = l_table_alias
14566 and cpe.number_of_copies = 1 --ADDITION
14567 group by decode(cpe.information160,cpe.information1,1,2), cpe.information1,cpe.information2,cpe.information3,
14568 cpe.information170, cpe.table_route_id ,cpe.dml_operation,cpe.datetrack_mode, cpe.information8
14569 order by 1,2,3;
14570 --
14571 --
14572 cursor c_PLN_min_max_dates(c_table_route_id number,
14573 c_information1 number) is
14574 select
14575 min(cpe.information2) min_esd,
14576 max(cpe.information3) min_eed
14577 from ben_copy_entity_results cpe
14578 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14579 and cpe.table_route_id = c_table_route_id
14580 and cpe.information1 = c_information1 ;
14581 --
14582 cursor c_PLN(c_table_route_id number,
14583 c_information1 number,
14584 c_information2 date,
14585 c_information3 date ) is
14586 select
14587 cpe.*
14588 from ben_copy_entity_results cpe
14589 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
14590 and cpe.table_route_id = c_table_route_id
14591 and cpe.information1 = c_information1
14592 and cpe.information2 = c_information2
14593 and cpe.information3 = c_information3
14594 and rownum = 1 ;
14595 -- Date Track target record
14596 cursor c_find_PLN_in_target( c_PLN_name varchar2,
14597 c_effective_start_date date,
14598 c_effective_end_date date,
14599 c_business_group_id number,
14600 c_new_pk_id number) is
14601 select
14602 PLN.pl_id new_value
14603 from BEN_PL_F PLN
14604 where PLN.name = c_PLN_name
14605 and PLN.business_group_id = c_business_group_id
14606 and PLN.pl_id <> c_new_pk_id
14607 --TEMPIK
14608 and c_effective_start_date between effective_start_date
14609 and effective_end_date ;
14610 --END TEMPIK
14611 /*TEMPIK
14612 and exists ( select null
14613 from BEN_PL_F PLN1
14614 where PLN1.name = c_PLN_name
14615 and PLN1.business_group_id = c_business_group_id
14616 and PLN1.effective_start_date <= c_effective_start_date )
14617 and exists ( select null
14618 from BEN_PL_F PLN2
14619 where PLN2.name = c_PLN_name
14620 and PLN2.business_group_id = c_business_group_id
14621 and PLN2.effective_end_date >= c_effective_end_date )
14622 ;
14623 TEMPIK */
14624
14625 --
14626 --Mapping for CWB group Plan
14627 --
14628 cursor c_get_grp_pl(p_grp_pl_name in varchar2,
14629 p_effective_date in date) is
14630 select name, pl_id
14631 from ben_pl_f
14632 where name = p_grp_pl_name
14633 and p_effective_date between effective_start_date and effective_end_date;
14634
14635 l_get_grp_pl c_get_grp_pl%rowtype;
14636 --
14637
14638 --TEMPIK
14639 l_dt_rec_found boolean ;
14640 --END TEMPIK
14641 --
14642 -- REUSE
14643 --
14644 l_prefix_suffix_text varchar2(300) := p_prefix_suffix_text;
14645 --
14646 l_current_pk_id number := null ;
14647 --UPD START
14648 --
14649 l_update boolean := false ;
14650 l_datetrack_mode varchar2(80) := hr_api.g_update;
14651 l_process_date date;
14652 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
14653 --
14654 --UPD END
14655 l_prev_pk_id number := null ;
14656 l_first_rec boolean := true ;
14657 r_PLN c_PLN%rowtype;
14658 l_pl_id number ;
14659 l_group_pl_id number ;
14660 l_object_version_number number ;
14661 l_effective_start_date date ;
14662 l_effective_end_date date ;
14663 l_prefix pqh_copy_entity_attribs.information1%type := null;
14664 l_suffix pqh_copy_entity_attribs.information1%type := null;
14665 l_new_value number(15);
14666 l_object_found_in_target boolean := false ;
14667 l_min_esd date;
14668 l_max_eed date;
14669 l_ACTL_PREM_ID number;
14670 l_AUTO_ENRT_MTHD_RL number;
14671 l_BNFT_PRVDR_POOL_ID number;
14672 l_COST_ALLOC_KEYFLEX_1_ID number;
14673 l_COST_ALLOC_KEYFLEX_2_ID number;
14674 l_DFLT_TO_ASN_PNDG_CTFN_RL number;
14675 l_DPNT_CVG_END_DT_RL number;
14676 l_DPNT_CVG_STRT_DT_RL number;
14677 l_ENRT_CVG_END_DT_RL number;
14678 l_ENRT_CVG_STRT_DT_RL number;
14679 l_ENRT_RL number;
14680 l_FRFS_DISTR_MTHD_RL number;
14681 l_MN_CVG_RL number;
14682 l_MX_CVG_RL number;
14683 l_MX_WTG_DT_TO_USE_RL number;
14684 l_MX_WTG_PERD_RL number;
14685 l_NIP_DFLT_ENRT_DET_RL number;
14686 l_PL_TYP_ID number;
14687 l_POSTELCN_EDIT_RL number;
14688 l_PRORT_PRTL_YR_CVG_RSTRN_RL number;
14689 l_RQD_PERD_ENRT_NENRT_RL number;
14690 l_RT_END_DT_RL number;
14691 l_RT_STRT_DT_RL number;
14692 l_VRFY_FMLY_MMBR_RL number;
14693 l_status_cd varchar2(30);
14694 l_effective_date date;
14695 -- Added during PDC change
14696 l_MAPPING_TABLE_PK_ID number;
14697 --
14698 --ML
14699 l_SUSP_IF_DPNT_DOB_NT_PRV_CD ben_pl_f.SUSP_IF_DPNT_DOB_NT_PRV_CD%type;
14700 l_SUSP_IF_DPNT_ADR_NT_PRV_CD ben_pl_f.SUSP_IF_DPNT_ADR_NT_PRV_CD%type;
14701 l_SUSP_IF_BNF_SSN_NT_PRV_CD ben_pl_f.SUSP_IF_BNF_SSN_NT_PRV_CD%type;
14702 l_SUSP_IF_BNF_DOB_NT_PRV_CD ben_pl_f.SUSP_IF_BNF_DOB_NT_PRV_CD%type;
14703 l_SUSP_IF_BNF_ADR_NT_PRV_CD ben_pl_f.SUSP_IF_BNF_ADR_NT_PRV_CD%type;
14704 l_SUSP_IF_DPNT_SSN_NT_PRV_CD ben_pl_f.SUSP_IF_DPNT_SSN_NT_PRV_CD%type;
14705 --
14706 begin
14707 -- Initialization
14708 l_object_found_in_target := false ;
14709 -- End Initialization
14710 --
14711
14712 for r_PLN_unique in c_unique_PLN('PLN') loop
14713
14714 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
14715 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14716 r_PLN_unique.information3 >=
14717 ben_pd_copy_to_ben_one.g_copy_effective_date)
14718 ) then
14719 --
14720 -- Derive the prefix - sufix
14721 -- REUSE ENHANCEMENT
14722 --
14723 l_prefix_suffix_text := p_prefix_suffix_text;
14724 if ben_PLAN_DESIGN_TXNS_api.g_pgm_pl_prefix_suffix_text is not null and
14725 r_PLN_unique.information8 = 'PLNIP' then
14726 --
14727 l_prefix_suffix_text := ben_PLAN_DESIGN_TXNS_api.g_pgm_pl_prefix_suffix_text;
14728 --
14729 end if;
14730 if p_prefix_suffix_cd = 'PREFIX' then
14731 l_prefix := l_prefix_suffix_text ;
14732 elsif p_prefix_suffix_cd = 'SUFFIX' then
14733 l_suffix := l_prefix_suffix_text ;
14734 else
14735 l_prefix := null ;
14736 l_suffix := null ;
14737 end if ;
14738 --
14739 hr_utility.set_location(' r_PLN_unique.table_route_id '||r_PLN_unique.table_route_id,10);
14740 hr_utility.set_location(' r_PLN_unique.information1 '||r_PLN_unique.information1,10);
14741 hr_utility.set_location( 'r_PLN_unique.information2 '||r_PLN_unique.information2,10);
14742 hr_utility.set_location( 'r_PLN_unique.information3 '||r_PLN_unique.information3,10);
14743 -- If reuse objects flag is 'Y' then check for the object in the target business group
14744 -- if found insert the record into PLSql table and exit the loop else try create the
14745 -- object in the target business group
14746 --
14747 l_object_found_in_target := false ;
14748 l_update := false;
14749 l_process_date := p_effective_date;
14750 l_dml_operation:= r_PLN_unique.dml_operation ;
14751 --
14752 if l_dml_operation = 'UPDATE' then
14753 --
14754 l_object_found_in_target := TRUE;
14755 --
14756 if l_process_date between r_PLN_unique.information2 and r_PLN_unique.information3 then
14757 l_update := true;
14758 if r_PLN_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
14759 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PL_ID' then
14760 g_pk_tbl(g_count).pk_id_column := 'PL_ID' ;
14761 g_pk_tbl(g_count).old_value := r_PLN_unique.information1 ;
14762 g_pk_tbl(g_count).new_value := r_PLN_unique.information1 ;
14763 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
14764 g_pk_tbl(g_count).table_route_id := r_PLN_unique.table_route_id;
14765 --
14766 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
14767 --
14768 g_count := g_count + 1 ;
14769 --
14770 log_data('PLN',l_new_value,l_prefix || r_PLN_unique.name|| l_suffix,'REUSED');
14771 --
14772 end if ;
14773 hr_utility.set_location( 'found record for update',10);
14774 --
14775 else
14776 --
14777 l_update := false;
14778 --
14779 end if;
14780 else
14781 --
14782 l_min_esd := null ;
14783 l_max_eed := null ;
14784 open c_PLN_min_max_dates(r_PLN_unique.table_route_id, r_PLN_unique.information1 ) ;
14785 fetch c_PLN_min_max_dates into l_min_esd,l_max_eed ;
14786
14787 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14788 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
14789 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
14790 end if;
14791 l_min_esd := greatest(l_min_esd,r_PLN_unique.information2);
14792
14793 hr_utility.set_location( 'l_min_esd,l_max_eed '||l_min_esd|| ' : ' || l_max_eed,10);
14794 hr_utility.set_location( 'r_PLN_unique.information8 = ' || r_PLN_unique.information8, 10);
14795 ---
14796 --Bug 4367899 fix -- reverting fix 4367899 not to get into fp.
14797 -- fix for 4367899 will be delivered later
14798 -- if p_reuse_object_flag = 'Y' and nvl(r_PLN_unique.information8, 'XYZ') <> 'PLNIP' then
14799 if p_reuse_object_flag = 'Y' then
14800 if c_PLN_min_max_dates%found then
14801 hr_utility.set_location( '-- cursor to find the object', 10);
14802 hr_utility.set_location( l_prefix || r_PLN_unique.name || l_suffix, 10);
14803 open c_find_PLN_in_target( l_prefix || r_PLN_unique.name || l_suffix ,l_min_esd,l_max_eed,
14804 p_target_business_group_id, nvl(l_pl_id, -999) ) ;
14805 fetch c_find_PLN_in_target into l_new_value ;
14806 if c_find_PLN_in_target%found then
14807 --
14808 --TEMPIK
14809 l_dt_rec_found := dt_api.check_min_max_dates
14810 (p_base_table_name => 'BEN_PL_F',
14811 p_base_key_column => 'PL_ID',
14812 p_base_key_value => l_new_value,
14813 p_from_date => l_min_esd,
14814 p_to_date => l_max_eed );
14815 if l_dt_rec_found THEN
14816 --END TEMPIK
14817 hr_utility.set_location( '-- found the object', 10);
14818 if r_PLN_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
14819 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PL_ID' then
14820 g_pk_tbl(g_count).pk_id_column := 'PL_ID' ;
14821 g_pk_tbl(g_count).old_value := r_PLN_unique.information1 ;
14822 g_pk_tbl(g_count).new_value := l_new_value ;
14823 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
14824 g_pk_tbl(g_count).table_route_id := r_PLN_unique.table_route_id;
14825 --
14826 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
14827 --
14828 g_count := g_count + 1 ;
14829 --
14830 log_data('PLN',l_new_value,l_prefix || r_PLN_unique.name|| l_suffix,'REUSED');
14831 --
14832 end if ;
14833 --
14834 l_object_found_in_target := true ;
14835 --TEMPIK
14836 end if; -- l_dt_rec_found
14837 --END TEMPIK
14838 end if;
14839 close c_find_PLN_in_target ;
14840 --
14841 end if;
14842 end if ;
14843 --
14844 close c_PLN_min_max_dates ;
14845 end if; --if p_dml_operation
14846 --
14847 if not l_object_found_in_target OR l_update then
14848 --
14849 open c_PLN(r_PLN_unique.table_route_id,
14850 r_PLN_unique.information1,
14851 r_PLN_unique.information2,
14852 r_PLN_unique.information3 ) ;
14853 --
14854 fetch c_PLN into r_PLN ;
14855 --
14856 close c_PLN ;
14857 --
14858 l_status_cd := r_PLN.information19;
14859 if r_PLN_unique.information8 = 'PLNIP' then
14860 l_status_cd := 'P';
14861 end if;
14862 --
14863 l_current_pk_id := r_PLN.information1;
14864 --
14865 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
14866 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
14867 --
14868 if l_current_pk_id = l_prev_pk_id then
14869 --
14870 l_first_rec := false ;
14871 --
14872 else
14873 --
14874 l_first_rec := true ;
14875 --
14876 end if ;
14877 --
14878 --
14879 --Mapping for CWB group Plan
14880 --
14881 -- Bug 4665663 - Map only if it is not a Group Plan
14882 if (r_PLN.INFORMATION160 IS NOT NULL and
14883 r_PLN.INFORMATION160 <> r_PLN.INFORMATION1) then
14884 --
14885 l_group_pl_id := NULL;
14886 --
14887 if BEN_PD_COPY_TO_BEN_ONE.g_mapping_done then
14888 l_group_pl_id := r_PLN.information176 ;
14889 end if;
14890 --
14891 if (l_group_pl_id IS NULL) then
14892 l_group_pl_id := get_fk('PL_ID', r_PLN.INFORMATION160,l_dml_operation);
14893 end if ;
14894 end if;
14895 --
14896 /*
14897 hr_utility.set_location(' l_group_pl_id '||l_group_pl_id,20);
14898 --
14899 -- If group plan and actual plans are created in one flow then resolve the
14900 -- group plan.
14901 --
14902 if l_group_pl_id is null then
14903 l_group_pl_id := get_fk('PL_ID', r_PLN.INFORMATION160,l_dml_operation);
14904 end if;
14905 */
14906 hr_utility.set_location(' l_group_pl_id '||l_group_pl_id,30);
14907 --
14908 --
14909 -- End Mapping for CWB group Plan
14910 --
14911 l_ACTL_PREM_ID := get_fk('ACTL_PREM_ID', r_PLN.INFORMATION250,l_dml_operation);
14912 l_AUTO_ENRT_MTHD_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION281,l_dml_operation);
14913 l_BNFT_PRVDR_POOL_ID := get_fk('BNFT_PRVDR_POOL_ID', r_PLN.INFORMATION235,l_dml_operation);
14914 l_COST_ALLOC_KEYFLEX_1_ID := get_fk('COST_ALLOC_KEYFLEX_1_ID', r_PLN.INFORMATION287,l_dml_operation);
14915 l_COST_ALLOC_KEYFLEX_2_ID := get_fk('COST_ALLOC_KEYFLEX_2_ID', r_PLN.INFORMATION288,l_dml_operation);
14916 l_DFLT_TO_ASN_PNDG_CTFN_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION272,l_dml_operation);
14917 l_DPNT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION258,l_dml_operation);
14918 l_DPNT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION259,l_dml_operation);
14919 l_ENRT_CVG_END_DT_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION260,l_dml_operation);
14920 l_ENRT_CVG_STRT_DT_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION262,l_dml_operation);
14921 l_ENRT_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION274,l_dml_operation);
14922 l_FRFS_DISTR_MTHD_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION257,l_dml_operation);
14923 l_MAPPING_TABLE_PK_ID := get_fk('MAPPING_TABLE_PK_ID', r_PLN.INFORMATION294,l_dml_operation);
14924 l_MN_CVG_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION283,l_dml_operation);
14925 l_MX_CVG_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION284,l_dml_operation);
14926 l_MX_WTG_DT_TO_USE_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION275,l_dml_operation);
14927 l_MX_WTG_PERD_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION282,l_dml_operation);
14928 l_NIP_DFLT_ENRT_DET_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION286,l_dml_operation);
14929 l_PL_TYP_ID := get_fk('PL_TYP_ID', r_PLN.INFORMATION248,l_dml_operation);
14930 l_POSTELCN_EDIT_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION279,l_dml_operation);
14931 l_PRORT_PRTL_YR_CVG_RSTRN_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION268,l_dml_operation);
14932 l_RQD_PERD_ENRT_NENRT_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION276,l_dml_operation);
14933 l_RT_END_DT_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION277,l_dml_operation);
14934 l_RT_STRT_DT_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION278,l_dml_operation);
14935 l_VRFY_FMLY_MMBR_RL := get_fk('FORMULA_ID', r_PLN.INFORMATION264,l_dml_operation);
14936
14937 --
14938 -- PDW modification
14939 --
14940 if(BEN_PD_COPY_TO_BEN_ONE.g_transaction_category = 'BEN_PDCRWZ') then
14941 --
14942 if(r_PLN.INFORMATION299 = 0) then
14943 r_PLN.INFORMATION299 := null;
14944 end if;
14945
14946 if(r_PLN.INFORMATION300 = 0) then
14947 r_PLN.INFORMATION300 := null;
14948 end if;
14949
14950 --
14951 end if;
14952 --
14953
14954 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_PL_F',l_prefix || r_PLN.INFORMATION170 || l_suffix);
14955 --
14956
14957 l_effective_date := r_PLN.information2;
14958 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
14959 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
14960 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
14961 end if;
14962
14963 --
14964 --ML
14965 --
14966 if r_PLN.INFORMATION31 = 'Y' and r_PLN.INFORMATION196 is null then
14967 l_SUSP_IF_DPNT_SSN_NT_PRV_CD := 'RQDS';
14968 else
14969 l_SUSP_IF_DPNT_SSN_NT_PRV_CD := r_PLN.INFORMATION196;
14970 end if;
14971 --
14972 if r_PLN.INFORMATION32 = 'Y' and r_PLN.INFORMATION190 is null then
14973 l_SUSP_IF_DPNT_DOB_NT_PRV_CD := 'RQDS';
14974 else
14975 l_SUSP_IF_DPNT_DOB_NT_PRV_CD := r_PLN.INFORMATION190;
14976 end if;
14977 --
14978 if r_PLN.INFORMATION30 = 'Y' and r_PLN.INFORMATION191 is null then
14979 l_SUSP_IF_DPNT_ADR_NT_PRV_CD := 'RQDS';
14980 else
14981 l_SUSP_IF_DPNT_ADR_NT_PRV_CD := r_PLN.INFORMATION191;
14982 end if;
14983 --
14984 if r_PLN.INFORMATION57 = 'Y' and r_PLN.INFORMATION194 is null then
14985 l_SUSP_IF_BNF_SSN_NT_PRV_CD := 'RQDS';
14986 else
14987 l_SUSP_IF_BNF_SSN_NT_PRV_CD := r_PLN.INFORMATION194;
14988 end if;
14989 --
14990 if r_PLN.INFORMATION66 = 'Y' and r_PLN.INFORMATION195 is null then
14991 l_SUSP_IF_BNF_DOB_NT_PRV_CD := 'RQDS';
14992 else
14993 l_SUSP_IF_BNF_DOB_NT_PRV_CD := r_PLN.INFORMATION195;
14994 end if;
14995 --
14996 if r_PLN.INFORMATION54 = 'Y' and r_PLN.INFORMATION106 is null then
14997 l_SUSP_IF_BNF_ADR_NT_PRV_CD := 'RQDS';
14998 else
14999 l_SUSP_IF_BNF_ADR_NT_PRV_CD := r_PLN.INFORMATION106;
15000 end if;
15001 if l_first_rec and not l_update then
15002 -- Call Create routine.
15003 hr_utility.set_location(' BEN_PL_F CREATE_PLAN ',20);
15004 BEN_PLAN_API.CREATE_PLAN(
15005 --
15006 P_VALIDATE => false
15007 ,P_EFFECTIVE_DATE => l_effective_date
15008 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
15009 --
15010 ,P_ACTL_PREM_ID => l_ACTL_PREM_ID
15011 ,P_ALWS_QDRO_FLAG => r_PLN.INFORMATION36
15012 ,P_ALWS_QMCSO_FLAG => r_PLN.INFORMATION37
15013 ,P_ALWS_REIMBMTS_FLAG => r_PLN.INFORMATION51
15014 ,P_ALWS_TMPRY_ID_CRD_FLAG => r_PLN.INFORMATION24
15015 ,P_ALWS_UNRSTRCTD_ENRT_FLAG => r_PLN.INFORMATION52
15016 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
15017 ,P_BNDRY_PERD_CD => r_PLN.INFORMATION101
15018 ,P_BNFT_OR_OPTION_RSTRCTN_CD => r_PLN.INFORMATION77
15019 ,P_BNFT_PRVDR_POOL_ID => l_BNFT_PRVDR_POOL_ID
15020 ,P_BNF_ADDL_INSTN_TXT_ALWD_FLAG => r_PLN.INFORMATION53
15021 ,P_BNF_ADRS_RQD_FLAG => r_PLN.INFORMATION54
15022 ,P_BNF_CNTNGT_BNFS_ALWD_FLAG => r_PLN.INFORMATION56
15023 ,P_BNF_CTFN_RQD_FLAG => r_PLN.INFORMATION55
15024 ,P_BNF_DFLT_BNF_CD => r_PLN.INFORMATION82
15025 ,P_BNF_DOB_RQD_FLAG => r_PLN.INFORMATION66
15026 ,P_BNF_DSGE_MNR_TTEE_RQD_FLAG => r_PLN.INFORMATION60
15027 ,P_BNF_DSGN_CD => r_PLN.INFORMATION89
15028 ,P_BNF_INCRMT_AMT => r_PLN.INFORMATION302
15029 ,P_BNF_LEGV_ID_RQD_FLAG => r_PLN.INFORMATION57
15030 ,P_BNF_MAY_DSGT_ORG_FLAG => r_PLN.INFORMATION58
15031 ,P_BNF_MN_DSGNTBL_AMT => r_PLN.INFORMATION303
15032 ,P_BNF_MN_DSGNTBL_PCT_VAL => r_PLN.INFORMATION290
15033 ,P_BNF_PCT_AMT_ALWD_CD => r_PLN.INFORMATION83
15034 ,P_BNF_PCT_INCRMT_VAL => r_PLN.INFORMATION293
15035 ,P_BNF_QDRO_RL_APLS_FLAG => r_PLN.INFORMATION59
15036 ,P_CMPR_CLMS_TO_CVG_OR_BAL_CD => r_PLN.INFORMATION84
15037 ,P_COBRA_PYMT_DUE_DY_NUM => r_PLN.INFORMATION285
15038 ,P_COST_ALLOC_KEYFLEX_1_ID => l_COST_ALLOC_KEYFLEX_1_ID
15039 ,P_COST_ALLOC_KEYFLEX_2_ID => l_COST_ALLOC_KEYFLEX_2_ID
15040 ,P_CVG_INCR_R_DECR_ONLY_CD => r_PLN.INFORMATION68
15041 ,P_DFLT_TO_ASN_PNDG_CTFN_CD => r_PLN.INFORMATION91
15042 ,P_DFLT_TO_ASN_PNDG_CTFN_RL => l_DFLT_TO_ASN_PNDG_CTFN_RL
15043 ,P_DPNT_ADRS_RQD_FLAG => r_PLN.INFORMATION30
15044 ,P_DPNT_CVD_BY_OTHR_APLS_FLAG => r_PLN.INFORMATION29
15045 ,P_DPNT_CVG_END_DT_CD => r_PLN.INFORMATION85
15046 ,P_DPNT_CVG_END_DT_RL => l_DPNT_CVG_END_DT_RL
15047 ,P_DPNT_CVG_STRT_DT_CD => r_PLN.INFORMATION86
15048 ,P_DPNT_CVG_STRT_DT_RL => l_DPNT_CVG_STRT_DT_RL
15049 ,P_DPNT_DOB_RQD_FLAG => r_PLN.INFORMATION32
15050 ,P_DPNT_DSGN_CD => r_PLN.INFORMATION87
15051 ,P_DPNT_LEG_ID_RQD_FLAG => r_PLN.INFORMATION31
15052 ,P_DPNT_NO_CTFN_RQD_FLAG => r_PLN.INFORMATION27
15053 ,P_DRVBL_DPNT_ELIG_FLAG => r_PLN.INFORMATION25
15054 ,P_DRVBL_FCTR_APLS_RTS_FLAG => r_PLN.INFORMATION33
15055 ,P_DRVBL_FCTR_PRTN_ELIG_FLAG => r_PLN.INFORMATION26
15056 ,P_ELIG_APLS_FLAG => r_PLN.INFORMATION34
15057 ,P_ENRT_CD => r_PLN.INFORMATION17
15058 ,P_ENRT_CVG_END_DT_CD => r_PLN.INFORMATION21
15059 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
15060 ,P_ENRT_CVG_STRT_DT_CD => r_PLN.INFORMATION20
15061 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
15062 ,P_ENRT_MTHD_CD => r_PLN.INFORMATION92
15063 ,P_ENRT_PL_OPT_FLAG => r_PLN.INFORMATION39
15064 ,P_ENRT_RL => l_ENRT_RL
15065 ,P_FRFS_APLY_FLAG => r_PLN.INFORMATION40
15066 ,P_FRFS_CNTR_DET_CD => r_PLN.INFORMATION96
15067 ,P_FRFS_DISTR_DET_CD => r_PLN.INFORMATION97
15068 ,P_FRFS_DISTR_MTHD_CD => r_PLN.INFORMATION13
15069 ,P_FRFS_DISTR_MTHD_RL => l_FRFS_DISTR_MTHD_RL
15070 ,P_FRFS_MX_CRYFWD_VAL => r_PLN.INFORMATION304
15071 ,P_FRFS_PORTION_DET_CD => r_PLN.INFORMATION100
15072 ,P_FRFS_VAL_DET_CD => r_PLN.INFORMATION99
15073 ,P_FUNCTION_CODE => r_PLN.INFORMATION95
15074 ,P_HC_PL_SUBJ_HCFA_APRVL_FLAG => r_PLN.INFORMATION47
15075 ,P_HC_SVC_TYP_CD => r_PLN.INFORMATION15
15076 ,P_HGHLY_CMPD_RL_APLS_FLAG => r_PLN.INFORMATION38
15077 ,P_IMPTD_INCM_CALC_CD => r_PLN.INFORMATION73
15078 ,P_INCPTN_DT => r_PLN.INFORMATION306
15079 ,P_INVK_DCLN_PRTN_PL_FLAG => r_PLN.INFORMATION50
15080 ,P_INVK_FLX_CR_PL_FLAG => r_PLN.INFORMATION49
15081 ,P_IVR_IDENT => r_PLN.INFORMATION142
15082 ,P_MAPPING_TABLE_NAME => r_PLN.INFORMATION141
15083 ,P_MAPPING_TABLE_PK_ID => l_MAPPING_TABLE_PK_ID
15084 ,P_MAY_ENRL_PL_N_OIPL_FLAG => r_PLN.INFORMATION28
15085 ,P_MN_CVG_RL => l_MN_CVG_RL
15086 ,P_MN_CVG_RQD_AMT => r_PLN.INFORMATION300
15087 ,P_MN_OPTS_RQD_NUM => r_PLN.INFORMATION269
15088 ,P_MX_CVG_ALWD_AMT => r_PLN.INFORMATION299
15089 ,P_MX_CVG_INCR_ALWD_AMT => r_PLN.INFORMATION297
15090 ,P_MX_CVG_INCR_WCF_ALWD_AMT => r_PLN.INFORMATION298
15091 ,P_MX_CVG_MLT_INCR_NUM => r_PLN.INFORMATION271
15092 ,P_MX_CVG_MLT_INCR_WCF_NUM => r_PLN.INFORMATION273
15093 ,P_MX_CVG_RL => l_MX_CVG_RL
15094 ,P_MX_CVG_WCFN_AMT => r_PLN.INFORMATION295
15095 ,P_MX_CVG_WCFN_MLT_NUM => r_PLN.INFORMATION267
15096 ,P_MX_OPTS_ALWD_NUM => r_PLN.INFORMATION270
15097 ,P_MX_WTG_DT_TO_USE_CD => r_PLN.INFORMATION80
15098 ,P_MX_WTG_DT_TO_USE_RL => l_MX_WTG_DT_TO_USE_RL
15099 ,P_MX_WTG_PERD_PRTE_UOM => r_PLN.INFORMATION79
15100 ,P_MX_WTG_PERD_PRTE_VAL => r_PLN.INFORMATION289
15101 ,P_MX_WTG_PERD_RL => l_MX_WTG_PERD_RL
15102 ,P_NAME => l_prefix || r_PLN.INFORMATION170 || l_suffix
15103 ,P_NIP_ACTY_REF_PERD_CD => r_PLN.INFORMATION16
15104 ,P_NIP_DFLT_ENRT_CD => r_PLN.INFORMATION88
15105 ,P_NIP_DFLT_ENRT_DET_RL => l_NIP_DFLT_ENRT_DET_RL
15106 ,P_NIP_DFLT_FLAG => r_PLN.INFORMATION12
15107 ,P_NIP_ENRT_INFO_RT_FREQ_CD => r_PLN.INFORMATION22
15108 ,P_NIP_PL_UOM => r_PLN.INFORMATION81
15109 ,P_NO_MN_CVG_AMT_APLS_FLAG => r_PLN.INFORMATION61
15110 ,P_NO_MN_CVG_INCR_APLS_FLAG => r_PLN.INFORMATION63
15111 ,P_NO_MN_OPTS_NUM_APLS_FLAG => r_PLN.INFORMATION65
15112 ,P_NO_MX_CVG_AMT_APLS_FLAG => r_PLN.INFORMATION62
15113 ,P_NO_MX_CVG_INCR_APLS_FLAG => r_PLN.INFORMATION64
15114 ,P_NO_MX_OPTS_NUM_APLS_FLAG => r_PLN.INFORMATION35
15115 ,P_ORDR_NUM => r_PLN.INFORMATION266
15116 ,P_PER_CVRD_CD => r_PLN.INFORMATION76
15117 ,P_PLN_ATTRIBUTE1 => r_PLN.INFORMATION111
15118 ,P_PLN_ATTRIBUTE10 => r_PLN.INFORMATION120
15119 ,P_PLN_ATTRIBUTE11 => r_PLN.INFORMATION121
15120 ,P_PLN_ATTRIBUTE12 => r_PLN.INFORMATION122
15121 ,P_PLN_ATTRIBUTE13 => r_PLN.INFORMATION123
15122 ,P_PLN_ATTRIBUTE14 => r_PLN.INFORMATION124
15123 ,P_PLN_ATTRIBUTE15 => r_PLN.INFORMATION125
15124 ,P_PLN_ATTRIBUTE16 => r_PLN.INFORMATION126
15125 ,P_PLN_ATTRIBUTE17 => r_PLN.INFORMATION127
15126 ,P_PLN_ATTRIBUTE18 => r_PLN.INFORMATION128
15127 ,P_PLN_ATTRIBUTE19 => r_PLN.INFORMATION129
15128 ,P_PLN_ATTRIBUTE2 => r_PLN.INFORMATION112
15129 ,P_PLN_ATTRIBUTE20 => r_PLN.INFORMATION130
15130 ,P_PLN_ATTRIBUTE21 => r_PLN.INFORMATION131
15131 ,P_PLN_ATTRIBUTE22 => r_PLN.INFORMATION132
15132 ,P_PLN_ATTRIBUTE23 => r_PLN.INFORMATION133
15133 ,P_PLN_ATTRIBUTE24 => r_PLN.INFORMATION134
15134 ,P_PLN_ATTRIBUTE25 => r_PLN.INFORMATION135
15135 ,P_PLN_ATTRIBUTE26 => r_PLN.INFORMATION136
15136 ,P_PLN_ATTRIBUTE27 => r_PLN.INFORMATION137
15137 ,P_PLN_ATTRIBUTE28 => r_PLN.INFORMATION138
15138 ,P_PLN_ATTRIBUTE29 => r_PLN.INFORMATION139
15139 ,P_PLN_ATTRIBUTE3 => r_PLN.INFORMATION113
15140 ,P_PLN_ATTRIBUTE30 => r_PLN.INFORMATION140
15141 ,P_PLN_ATTRIBUTE4 => r_PLN.INFORMATION114
15142 ,P_PLN_ATTRIBUTE5 => r_PLN.INFORMATION115
15143 ,P_PLN_ATTRIBUTE6 => r_PLN.INFORMATION116
15144 ,P_PLN_ATTRIBUTE7 => r_PLN.INFORMATION117
15145 ,P_PLN_ATTRIBUTE8 => r_PLN.INFORMATION118
15146 ,P_PLN_ATTRIBUTE9 => r_PLN.INFORMATION119
15147 ,P_PLN_ATTRIBUTE_CATEGORY => r_PLN.INFORMATION110
15148 ,P_PL_CD => r_PLN.INFORMATION67
15149 ,P_PL_ID => l_pl_id
15150 ,P_PL_STAT_CD => l_status_cd
15151 ,P_PL_TYP_ID => l_PL_TYP_ID
15152 ,P_PL_YR_NOT_APPLCBL_FLAG => NVL(r_PLN.INFORMATION14,'N') -- BUG: 3502032
15153 ,P_POSTELCN_EDIT_RL => l_POSTELCN_EDIT_RL
15154 ,P_POST_TO_GL_FLAG => r_PLN.INFORMATION98
15155 ,P_PRMRY_FNDG_MTHD_CD => r_PLN.INFORMATION90
15156 ,P_PRORT_PRTL_YR_CVG_RSTRN_CD => r_PLN.INFORMATION18
15157 ,P_PRORT_PRTL_YR_CVG_RSTRN_RL => l_PRORT_PRTL_YR_CVG_RSTRN_RL
15158 ,P_PRTN_ELIG_OVRID_ALWD_FLAG => r_PLN.INFORMATION46
15159 ,P_RQD_PERD_ENRT_NENRT_RL => l_RQD_PERD_ENRT_NENRT_RL
15160 ,P_RQD_PERD_ENRT_NENRT_UOM => r_PLN.INFORMATION69
15161 ,P_RQD_PERD_ENRT_NENRT_VAL => r_PLN.INFORMATION301
15162 ,P_RT_END_DT_CD => r_PLN.INFORMATION74
15163 ,P_RT_END_DT_RL => l_RT_END_DT_RL
15164 ,P_RT_STRT_DT_CD => r_PLN.INFORMATION75
15165 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
15166 ,P_SHORT_CODE => r_PLN.INFORMATION93
15167 ,P_SHORT_NAME => r_PLN.INFORMATION94
15168 -- cwb tilak
15169 ,P_GROUP_PL_ID => l_group_pl_id -- r_PLN.INFORMATION176
15170 ,P_SUBJ_TO_IMPTD_INCM_TYP_CD => r_PLN.INFORMATION71
15171 ,P_SVGS_PL_FLAG => r_PLN.INFORMATION41
15172 ,P_TRK_INELIG_PER_FLAG => r_PLN.INFORMATION42
15173 ,P_UNSSPND_ENRT_CD => r_PLN.INFORMATION72
15174 ,P_URL_REF_NAME => r_PLN.INFORMATION185
15175 ,P_USE_ALL_ASNTS_ELIG_FLAG => r_PLN.INFORMATION43
15176 ,P_USE_ALL_ASNTS_FOR_RT_FLAG => r_PLN.INFORMATION44
15177 ,P_VRFY_FMLY_MMBR_CD => r_PLN.INFORMATION23
15178 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
15179 ,P_VSTG_APLS_FLAG => r_PLN.INFORMATION45
15180 ,P_WVBL_FLAG => r_PLN.INFORMATION48
15181 --ML
15182 ,p_SUSP_IF_CTFN_NOT_PRVD_FLAG => nvl(r_PLN.INFORMATION198,'Y')
15183 ,p_CTFN_DETERMINE_CD => r_PLN.INFORMATION197
15184 ,p_SUSP_IF_DPNT_SSN_NT_PRV_CD => l_SUSP_IF_DPNT_SSN_NT_PRV_CD
15185 ,p_SUSP_IF_DPNT_DOB_NT_PRV_CD => l_SUSP_IF_DPNT_DOB_NT_PRV_CD
15186 ,p_SUSP_IF_DPNT_ADR_NT_PRV_CD => l_SUSP_IF_DPNT_ADR_NT_PRV_CD
15187 ,p_SUSP_IF_CTFN_NOT_DPNT_FLAG => nvl(r_PLN.INFORMATION192,'Y')
15188 ,p_DPNT_CTFN_DETERMINE_CD => r_PLN.INFORMATION193
15189 ,p_SUSP_IF_BNF_SSN_NT_PRV_CD => l_SUSP_IF_BNF_SSN_NT_PRV_CD
15190 ,p_SUSP_IF_BNF_DOB_NT_PRV_CD => l_SUSP_IF_BNF_DOB_NT_PRV_CD
15191 ,p_BNF_CTFN_DETERMINE_CD => r_PLN.INFORMATION104
15192 -- Bug 3939490
15193 ,p_legislation_code => r_pln.information107
15194 ,p_legislation_subgroup => r_pln.information108
15195 ,p_use_csd_rsd_prccng_cd => r_pln.information109
15196 -- Bug 3939490
15197 ,p_SUSP_IF_CTFN_NOT_BNF_FLAG => nvl(r_PLN.INFORMATION105,'N')
15198 ,p_SUSP_IF_BNF_ADR_NT_PRV_CD => l_SUSP_IF_BNF_ADR_NT_PRV_CD
15199 --
15200 ,P_EFFECTIVE_START_DATE => l_effective_start_date
15201 ,P_EFFECTIVE_END_DATE => l_effective_end_date
15202 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
15203 );
15204 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
15205 -- Update all relevent cer records with new pk_id
15206 hr_utility.set_location('Before plsql table ',222);
15207 hr_utility.set_location('new_value id '||l_pl_id,222);
15208 g_pk_tbl(g_count).pk_id_column := 'PL_ID' ;
15209 g_pk_tbl(g_count).old_value := r_PLN.information1 ;
15210 g_pk_tbl(g_count).new_value := l_PL_ID ;
15211 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
15212 g_pk_tbl(g_count).table_route_id := r_PLN_unique.table_route_id;
15213 hr_utility.set_location('After plsql table ',222);
15214 --
15215 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
15216 --
15217 g_count := g_count + 1 ;
15218 --
15219 log_data('PLN',l_new_value,l_prefix || r_PLN.INFORMATION170 || l_suffix,'COPIED');
15220 --
15221 else
15222 --
15223 -- Call Update routine for the pk_id created in prev run .
15224 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
15225 --UPD START
15226 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
15227 --
15228 if l_update then
15229 --
15230 l_datetrack_mode := r_PLN.datetrack_mode ;
15231 --
15232 get_dt_modes(
15233 p_effective_date => l_process_date,
15234 p_effective_end_date => r_PLN.information3,
15235 p_effective_start_date => r_PLN.information2,
15236 p_dml_operation => r_PLN.dml_operation,
15237 p_datetrack_mode => l_datetrack_mode );
15238 -- p_update => l_update
15239 --
15240 l_effective_date := l_process_date;
15241 l_pl_id := r_PLN.information1;
15242 l_object_version_number := r_PLN.information265;
15243 --
15244 end if;
15245 --
15246 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
15247 --
15248 IF l_update OR l_dml_operation <> 'UPDATE' THEN
15249 --UPD END
15250 hr_utility.set_location(' BEN_PL_F UPDATE_PLAN ',30);
15251 BEN_PLAN_API.UPDATE_PLAN(
15252 --
15253 P_VALIDATE => false
15254 ,P_EFFECTIVE_DATE => l_effective_date
15255 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
15256 --
15257 ,P_ACTL_PREM_ID => l_ACTL_PREM_ID
15258 ,P_ALWS_QDRO_FLAG => r_PLN.INFORMATION36
15259 ,P_ALWS_QMCSO_FLAG => r_PLN.INFORMATION37
15260 ,P_ALWS_REIMBMTS_FLAG => r_PLN.INFORMATION51
15261 ,P_ALWS_TMPRY_ID_CRD_FLAG => r_PLN.INFORMATION24
15262 ,P_ALWS_UNRSTRCTD_ENRT_FLAG => r_PLN.INFORMATION52
15263 ,P_AUTO_ENRT_MTHD_RL => l_AUTO_ENRT_MTHD_RL
15264 ,P_BNDRY_PERD_CD => r_PLN.INFORMATION101
15265 ,P_BNFT_OR_OPTION_RSTRCTN_CD => r_PLN.INFORMATION77
15266 ,P_BNFT_PRVDR_POOL_ID => l_BNFT_PRVDR_POOL_ID
15267 ,P_BNF_ADDL_INSTN_TXT_ALWD_FLAG => r_PLN.INFORMATION53
15268 ,P_BNF_ADRS_RQD_FLAG => r_PLN.INFORMATION54
15269 ,P_BNF_CNTNGT_BNFS_ALWD_FLAG => r_PLN.INFORMATION56
15270 ,P_BNF_CTFN_RQD_FLAG => r_PLN.INFORMATION55
15271 ,P_BNF_DFLT_BNF_CD => r_PLN.INFORMATION82
15272 ,P_BNF_DOB_RQD_FLAG => r_PLN.INFORMATION66
15273 ,P_BNF_DSGE_MNR_TTEE_RQD_FLAG => r_PLN.INFORMATION60
15274 ,P_BNF_DSGN_CD => r_PLN.INFORMATION89
15275 ,P_BNF_INCRMT_AMT => r_PLN.INFORMATION302
15276 ,P_BNF_LEGV_ID_RQD_FLAG => r_PLN.INFORMATION57
15277 ,P_BNF_MAY_DSGT_ORG_FLAG => r_PLN.INFORMATION58
15278 ,P_BNF_MN_DSGNTBL_AMT => r_PLN.INFORMATION303
15279 ,P_BNF_MN_DSGNTBL_PCT_VAL => r_PLN.INFORMATION290
15280 ,P_BNF_PCT_AMT_ALWD_CD => r_PLN.INFORMATION83
15281 ,P_BNF_PCT_INCRMT_VAL => r_PLN.INFORMATION293
15282 ,P_BNF_QDRO_RL_APLS_FLAG => r_PLN.INFORMATION59
15283 ,P_CMPR_CLMS_TO_CVG_OR_BAL_CD => r_PLN.INFORMATION84
15284 ,P_COBRA_PYMT_DUE_DY_NUM => r_PLN.INFORMATION285
15285 ,P_COST_ALLOC_KEYFLEX_1_ID => l_COST_ALLOC_KEYFLEX_1_ID
15286 ,P_COST_ALLOC_KEYFLEX_2_ID => l_COST_ALLOC_KEYFLEX_2_ID
15287 ,P_CVG_INCR_R_DECR_ONLY_CD => r_PLN.INFORMATION68
15288 ,P_DFLT_TO_ASN_PNDG_CTFN_CD => r_PLN.INFORMATION91
15289 ,P_DFLT_TO_ASN_PNDG_CTFN_RL => l_DFLT_TO_ASN_PNDG_CTFN_RL
15290 ,P_DPNT_ADRS_RQD_FLAG => r_PLN.INFORMATION30
15291 ,P_DPNT_CVD_BY_OTHR_APLS_FLAG => r_PLN.INFORMATION29
15292 ,P_DPNT_CVG_END_DT_CD => r_PLN.INFORMATION85
15293 ,P_DPNT_CVG_END_DT_RL => l_DPNT_CVG_END_DT_RL
15294 ,P_DPNT_CVG_STRT_DT_CD => r_PLN.INFORMATION86
15295 ,P_DPNT_CVG_STRT_DT_RL => l_DPNT_CVG_STRT_DT_RL
15296 ,P_DPNT_DOB_RQD_FLAG => r_PLN.INFORMATION32
15297 ,P_DPNT_DSGN_CD => r_PLN.INFORMATION87
15298 ,P_DPNT_LEG_ID_RQD_FLAG => r_PLN.INFORMATION31
15299 ,P_DPNT_NO_CTFN_RQD_FLAG => r_PLN.INFORMATION27
15300 ,P_DRVBL_DPNT_ELIG_FLAG => r_PLN.INFORMATION25
15301 ,P_DRVBL_FCTR_APLS_RTS_FLAG => r_PLN.INFORMATION33
15302 ,P_DRVBL_FCTR_PRTN_ELIG_FLAG => r_PLN.INFORMATION26
15303 ,P_ELIG_APLS_FLAG => r_PLN.INFORMATION34
15304 ,P_ENRT_CD => r_PLN.INFORMATION17
15305 ,P_ENRT_CVG_END_DT_CD => r_PLN.INFORMATION21
15306 ,P_ENRT_CVG_END_DT_RL => l_ENRT_CVG_END_DT_RL
15307 ,P_ENRT_CVG_STRT_DT_CD => r_PLN.INFORMATION20
15308 ,P_ENRT_CVG_STRT_DT_RL => l_ENRT_CVG_STRT_DT_RL
15309 ,P_ENRT_MTHD_CD => r_PLN.INFORMATION92
15310 ,P_ENRT_PL_OPT_FLAG => r_PLN.INFORMATION39
15311 ,P_ENRT_RL => l_ENRT_RL
15312 ,P_FRFS_APLY_FLAG => r_PLN.INFORMATION40
15313 ,P_FRFS_CNTR_DET_CD => r_PLN.INFORMATION96
15314 ,P_FRFS_DISTR_DET_CD => r_PLN.INFORMATION97
15315 ,P_FRFS_DISTR_MTHD_CD => r_PLN.INFORMATION13
15316 ,P_FRFS_DISTR_MTHD_RL => l_FRFS_DISTR_MTHD_RL
15317 ,P_FRFS_MX_CRYFWD_VAL => r_PLN.INFORMATION304
15318 ,P_FRFS_PORTION_DET_CD => r_PLN.INFORMATION100
15319 ,P_FRFS_VAL_DET_CD => r_PLN.INFORMATION99
15320 ,P_FUNCTION_CODE => r_PLN.INFORMATION95
15321 ,P_HC_PL_SUBJ_HCFA_APRVL_FLAG => r_PLN.INFORMATION47
15322 ,P_HC_SVC_TYP_CD => r_PLN.INFORMATION15
15323 ,P_HGHLY_CMPD_RL_APLS_FLAG => r_PLN.INFORMATION38
15324 ,P_IMPTD_INCM_CALC_CD => r_PLN.INFORMATION73
15325 ,P_INCPTN_DT => r_PLN.INFORMATION306
15326 ,P_INVK_DCLN_PRTN_PL_FLAG => r_PLN.INFORMATION50
15327 ,P_INVK_FLX_CR_PL_FLAG => r_PLN.INFORMATION49
15328 ,P_IVR_IDENT => r_PLN.INFORMATION142
15329 ,P_MAPPING_TABLE_NAME => r_PLN.INFORMATION141
15330 ,P_MAPPING_TABLE_PK_ID => l_MAPPING_TABLE_PK_ID
15331 ,P_MAY_ENRL_PL_N_OIPL_FLAG => r_PLN.INFORMATION28
15332 ,P_MN_CVG_RL => l_MN_CVG_RL
15333 ,P_MN_CVG_RQD_AMT => r_PLN.INFORMATION300
15334 ,P_MN_OPTS_RQD_NUM => r_PLN.INFORMATION269
15335 ,P_MX_CVG_ALWD_AMT => r_PLN.INFORMATION299
15336 ,P_MX_CVG_INCR_ALWD_AMT => r_PLN.INFORMATION297
15337 ,P_MX_CVG_INCR_WCF_ALWD_AMT => r_PLN.INFORMATION298
15338 ,P_MX_CVG_MLT_INCR_NUM => r_PLN.INFORMATION271
15339 ,P_MX_CVG_MLT_INCR_WCF_NUM => r_PLN.INFORMATION273
15340 ,P_MX_CVG_RL => l_MX_CVG_RL
15341 ,P_MX_CVG_WCFN_AMT => r_PLN.INFORMATION295
15342 ,P_MX_CVG_WCFN_MLT_NUM => r_PLN.INFORMATION267
15343 ,P_MX_OPTS_ALWD_NUM => r_PLN.INFORMATION270
15344 ,P_MX_WTG_DT_TO_USE_CD => r_PLN.INFORMATION80
15345 ,P_MX_WTG_DT_TO_USE_RL => l_MX_WTG_DT_TO_USE_RL
15346 ,P_MX_WTG_PERD_PRTE_UOM => r_PLN.INFORMATION79
15347 ,P_MX_WTG_PERD_PRTE_VAL => r_PLN.INFORMATION289
15348 ,P_MX_WTG_PERD_RL => l_MX_WTG_PERD_RL
15349 ,P_NAME => l_prefix || r_PLN.INFORMATION170 || l_suffix
15350 ,P_NIP_ACTY_REF_PERD_CD => r_PLN.INFORMATION16
15351 ,P_NIP_DFLT_ENRT_CD => r_PLN.INFORMATION88
15352 ,P_NIP_DFLT_ENRT_DET_RL => l_NIP_DFLT_ENRT_DET_RL
15353 ,P_NIP_DFLT_FLAG => r_PLN.INFORMATION12
15354 ,P_NIP_ENRT_INFO_RT_FREQ_CD => r_PLN.INFORMATION22
15355 ,P_NIP_PL_UOM => r_PLN.INFORMATION81
15356 ,P_NO_MN_CVG_AMT_APLS_FLAG => r_PLN.INFORMATION61
15357 ,P_NO_MN_CVG_INCR_APLS_FLAG => r_PLN.INFORMATION63
15358 ,P_NO_MN_OPTS_NUM_APLS_FLAG => r_PLN.INFORMATION65
15359 ,P_NO_MX_CVG_AMT_APLS_FLAG => r_PLN.INFORMATION62
15360 ,P_NO_MX_CVG_INCR_APLS_FLAG => r_PLN.INFORMATION64
15361 ,P_NO_MX_OPTS_NUM_APLS_FLAG => r_PLN.INFORMATION35
15362 ,P_ORDR_NUM => r_PLN.INFORMATION266
15363 ,P_PER_CVRD_CD => r_PLN.INFORMATION76
15364 ,P_PLN_ATTRIBUTE1 => r_PLN.INFORMATION111
15365 ,P_PLN_ATTRIBUTE10 => r_PLN.INFORMATION120
15366 ,P_PLN_ATTRIBUTE11 => r_PLN.INFORMATION121
15367 ,P_PLN_ATTRIBUTE12 => r_PLN.INFORMATION122
15368 ,P_PLN_ATTRIBUTE13 => r_PLN.INFORMATION123
15369 ,P_PLN_ATTRIBUTE14 => r_PLN.INFORMATION124
15370 ,P_PLN_ATTRIBUTE15 => r_PLN.INFORMATION125
15371 ,P_PLN_ATTRIBUTE16 => r_PLN.INFORMATION126
15372 ,P_PLN_ATTRIBUTE17 => r_PLN.INFORMATION127
15373 ,P_PLN_ATTRIBUTE18 => r_PLN.INFORMATION128
15374 ,P_PLN_ATTRIBUTE19 => r_PLN.INFORMATION129
15375 ,P_PLN_ATTRIBUTE2 => r_PLN.INFORMATION112
15376 ,P_PLN_ATTRIBUTE20 => r_PLN.INFORMATION130
15377 ,P_PLN_ATTRIBUTE21 => r_PLN.INFORMATION131
15378 ,P_PLN_ATTRIBUTE22 => r_PLN.INFORMATION132
15379 ,P_PLN_ATTRIBUTE23 => r_PLN.INFORMATION133
15380 ,P_PLN_ATTRIBUTE24 => r_PLN.INFORMATION134
15381 ,P_PLN_ATTRIBUTE25 => r_PLN.INFORMATION135
15382 ,P_PLN_ATTRIBUTE26 => r_PLN.INFORMATION136
15383 ,P_PLN_ATTRIBUTE27 => r_PLN.INFORMATION137
15384 ,P_PLN_ATTRIBUTE28 => r_PLN.INFORMATION138
15385 ,P_PLN_ATTRIBUTE29 => r_PLN.INFORMATION139
15386 ,P_PLN_ATTRIBUTE3 => r_PLN.INFORMATION113
15387 ,P_PLN_ATTRIBUTE30 => r_PLN.INFORMATION140
15388 ,P_PLN_ATTRIBUTE4 => r_PLN.INFORMATION114
15389 ,P_PLN_ATTRIBUTE5 => r_PLN.INFORMATION115
15390 ,P_PLN_ATTRIBUTE6 => r_PLN.INFORMATION116
15391 ,P_PLN_ATTRIBUTE7 => r_PLN.INFORMATION117
15392 ,P_PLN_ATTRIBUTE8 => r_PLN.INFORMATION118
15393 ,P_PLN_ATTRIBUTE9 => r_PLN.INFORMATION119
15394 ,P_PLN_ATTRIBUTE_CATEGORY => r_PLN.INFORMATION110
15395 ,P_PL_CD => r_PLN.INFORMATION67
15396 ,P_PL_ID => l_pl_id
15397 ,P_PL_STAT_CD => l_status_cd
15398 ,P_PL_TYP_ID => l_PL_TYP_ID
15399 ,P_PL_YR_NOT_APPLCBL_FLAG => NVL(r_PLN.INFORMATION14, 'N') -- BUG: 3502032
15400 ,P_POSTELCN_EDIT_RL => l_POSTELCN_EDIT_RL
15401 ,P_POST_TO_GL_FLAG => r_PLN.INFORMATION98
15402 ,P_PRMRY_FNDG_MTHD_CD => r_PLN.INFORMATION90
15403 ,P_PRORT_PRTL_YR_CVG_RSTRN_CD => r_PLN.INFORMATION18
15404 ,P_PRORT_PRTL_YR_CVG_RSTRN_RL => l_PRORT_PRTL_YR_CVG_RSTRN_RL
15405 ,P_PRTN_ELIG_OVRID_ALWD_FLAG => r_PLN.INFORMATION46
15406 ,P_RQD_PERD_ENRT_NENRT_RL => l_RQD_PERD_ENRT_NENRT_RL
15407 ,P_RQD_PERD_ENRT_NENRT_UOM => r_PLN.INFORMATION69
15408 ,P_RQD_PERD_ENRT_NENRT_VAL => r_PLN.INFORMATION301
15409 ,P_RT_END_DT_CD => r_PLN.INFORMATION74
15410 ,P_RT_END_DT_RL => l_RT_END_DT_RL
15411 ,P_RT_STRT_DT_CD => r_PLN.INFORMATION75
15412 ,P_RT_STRT_DT_RL => l_RT_STRT_DT_RL
15413 ,P_SHORT_CODE => r_PLN.INFORMATION93
15414 ,P_SHORT_NAME => r_PLN.INFORMATION94
15415 -- cwb tilakn
15416 ,P_GROUP_PL_ID => r_PLN.INFORMATION160
15417 ,P_SUBJ_TO_IMPTD_INCM_TYP_CD => r_PLN.INFORMATION71
15418 ,P_SVGS_PL_FLAG => r_PLN.INFORMATION41
15419 ,P_TRK_INELIG_PER_FLAG => r_PLN.INFORMATION42
15420 ,P_UNSSPND_ENRT_CD => r_PLN.INFORMATION72
15421 ,P_URL_REF_NAME => r_PLN.INFORMATION185
15422 ,P_USE_ALL_ASNTS_ELIG_FLAG => r_PLN.INFORMATION43
15423 ,P_USE_ALL_ASNTS_FOR_RT_FLAG => r_PLN.INFORMATION44
15424 ,P_VRFY_FMLY_MMBR_CD => r_PLN.INFORMATION23
15425 ,P_VRFY_FMLY_MMBR_RL => l_VRFY_FMLY_MMBR_RL
15426 ,P_VSTG_APLS_FLAG => r_PLN.INFORMATION45
15427 ,P_WVBL_FLAG => r_PLN.INFORMATION48
15428 --ML
15429 ,p_SUSP_IF_CTFN_NOT_PRVD_FLAG => nvl(r_PLN.INFORMATION198,'Y')
15430 ,p_CTFN_DETERMINE_CD => r_PLN.INFORMATION197
15431 ,p_SUSP_IF_DPNT_SSN_NT_PRV_CD => l_SUSP_IF_DPNT_SSN_NT_PRV_CD
15432 ,p_SUSP_IF_DPNT_DOB_NT_PRV_CD => l_SUSP_IF_DPNT_DOB_NT_PRV_CD
15433 ,p_SUSP_IF_DPNT_ADR_NT_PRV_CD => l_SUSP_IF_DPNT_ADR_NT_PRV_CD
15434 ,p_SUSP_IF_CTFN_NOT_DPNT_FLAG => nvl(r_PLN.INFORMATION192,'Y')
15435 ,p_DPNT_CTFN_DETERMINE_CD => r_PLN.INFORMATION193
15436 ,p_SUSP_IF_BNF_SSN_NT_PRV_CD => l_SUSP_IF_BNF_SSN_NT_PRV_CD
15437 ,p_SUSP_IF_BNF_DOB_NT_PRV_CD => l_SUSP_IF_BNF_DOB_NT_PRV_CD
15438 ,p_BNF_CTFN_DETERMINE_CD => r_PLN.INFORMATION104
15439 -- Bug 3939490
15440 ,p_legislation_code => r_pln.information107
15441 ,p_legislation_subgroup => r_pln.information108
15442 ,p_use_csd_rsd_prccng_cd => r_pln.information109
15443 -- Bug 3939490
15444 ,p_SUSP_IF_CTFN_NOT_BNF_FLAG => nvl(r_PLN.INFORMATION105,'N')
15445 ,p_SUSP_IF_BNF_ADR_NT_PRV_CD => l_SUSP_IF_BNF_ADR_NT_PRV_CD
15446 --
15447 ,P_EFFECTIVE_START_DATE => l_effective_start_date
15448 ,P_EFFECTIVE_END_DATE => l_effective_end_date
15449 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
15450 ,P_DATETRACK_MODE => l_datetrack_mode
15451 );
15452 --
15453 end if;
15454 end if;
15455 --
15456 -- Delete the row if it is end dated.
15457 --
15458 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
15459 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
15460 trunc(l_max_eed) = r_PLN.information3) then
15461 --
15462 BEN_PLAN_API.delete_PLAN(
15463 --
15464 p_validate => false
15465 ,p_pl_id => l_pl_id
15466 ,p_effective_start_date => l_effective_start_date
15467 ,p_effective_end_date => l_effective_end_date
15468 ,p_object_version_number => l_object_version_number
15469 ,p_effective_date => l_max_eed
15470 ,p_datetrack_mode => hr_api.g_delete
15471 --
15472 );
15473 --
15474 end if;
15475 --
15476 l_prev_pk_id := l_current_pk_id ;
15477 --
15478 end if;
15479 --
15480 end if;
15481 --
15482 end loop;
15483 --
15484 exception when others then
15485 --
15486 raise_error_message( 'PLN',l_prefix || r_PLN.INFORMATION170 || l_suffix) ;
15487 --
15488 end create_PLN_rows;
15489
15490 --
15491 ---------------------------------------------------------------
15492 ----------------------< create_SVA_rows >-----------------------
15493 ---------------------------------------------------------------
15494 --
15495 procedure create_SVA_rows
15496 (
15497 p_validate in number default 0
15498 ,p_copy_entity_txn_id in number
15499 ,p_effective_date in date
15500 ,p_prefix_suffix_text in varchar2 default null
15501 ,p_reuse_object_flag in varchar2 default null
15502 ,p_target_business_group_id in varchar2 default null
15503 ,p_prefix_suffix_cd in varchar2 default null
15504 ) is
15505 --
15506 cursor c_unique_SVA(l_table_alias varchar2) is
15507 select distinct cpe.information1,
15508 cpe.information2,
15509 cpe.information3,
15510 cpe.information170 name,
15511 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
15512 from ben_copy_entity_results cpe,
15513 pqh_table_route tr
15514 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15515 and cpe.table_route_id = tr.table_route_id
15516 -- and tr.where_clause = l_BEN_SVC_AREA_F
15517 and tr.table_alias = l_table_alias
15518 and cpe.number_of_copies = 1 --ADDITION
15519 group by cpe.information1,cpe.information2,cpe.information3, cpe.information170, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
15520 order by information1, information2; --added for bug: 5151945
15521 --
15522 --
15523 cursor c_SVA_min_max_dates(c_table_route_id number,
15524 c_information1 number) is
15525 select
15526 min(cpe.information2) min_esd,
15527 max(cpe.information3) min_eed
15528 from ben_copy_entity_results cpe
15529 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15530 and cpe.table_route_id = c_table_route_id
15531 and cpe.information1 = c_information1 ;
15532 --
15533 cursor c_SVA(c_table_route_id number,
15534 c_information1 number,
15535 c_information2 date,
15536 c_information3 date ) is
15537 select
15538 cpe.*
15539 from ben_copy_entity_results cpe
15540 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15541 and cpe.table_route_id = c_table_route_id
15542 and cpe.information1 = c_information1
15543 and cpe.information2 = c_information2
15544 and cpe.information3 = c_information3
15545 and rownum = 1 ;
15546 -- Date Track target record
15547 cursor c_find_SVA_in_target( c_SVA_name varchar2,
15548 c_effective_start_date date,
15549 c_effective_end_date date,
15550 c_business_group_id number,
15551 c_new_pk_id number) is
15552 select
15553 SVA.svc_area_id new_value
15554 from BEN_SVC_AREA_F SVA
15555 where SVA.name = c_SVA_name
15556 and SVA.business_group_id = c_business_group_id
15557 and SVA.svc_area_id <> c_new_pk_id
15558 --TEMPIK
15559 and c_effective_start_date between effective_start_date
15560 and effective_end_date ;
15561 --END TEMPIK
15562 /*TEMPIK
15563 and exists ( select null
15564 from BEN_SVC_AREA_F SVA1
15565 where SVA1.name = c_SVA_name
15566 and SVA1.business_group_id = c_business_group_id
15567 and SVA1.effective_start_date <= c_effective_start_date )
15568 and exists ( select null
15569 from BEN_SVC_AREA_F SVA2
15570 where SVA2.name = c_SVA_name
15571 and SVA2.business_group_id = c_business_group_id
15572 and SVA2.effective_end_date >= c_effective_end_date )
15573 ;
15574 TEMPIK */
15575 --TEMPIK
15576 l_dt_rec_found boolean ;
15577 --END TEMPIK
15578 --
15579 l_current_pk_id number := null ;
15580 --UPD START
15581 --
15582 l_update boolean := false ;
15583 l_datetrack_mode varchar2(80) := hr_api.g_update;
15584 l_process_date date;
15585 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
15586 --
15587 --UPD END
15588 l_prev_pk_id number := null ;
15589 l_first_rec boolean := true ;
15590 r_SVA c_SVA%rowtype;
15591 l_svc_area_id number ;
15592 l_object_version_number number ;
15593 l_effective_start_date date ;
15594 l_effective_end_date date ;
15595 l_prefix pqh_copy_entity_attribs.information1%type := null;
15596 l_suffix pqh_copy_entity_attribs.information1%type := null;
15597 l_new_value number(15);
15598 l_object_found_in_target boolean := false ;
15599 l_min_esd date;
15600 l_max_eed date;
15601 l_effective_date date;
15602 --
15603 begin
15604 -- Initialization
15605 l_object_found_in_target := false ;
15606 -- End Initialization
15607 -- Derive the prefix - sufix
15608 if p_prefix_suffix_cd = 'PREFIX' then
15609 l_prefix := p_prefix_suffix_text ;
15610 elsif p_prefix_suffix_cd = 'SUFFIX' then
15611 l_suffix := p_prefix_suffix_text ;
15612 else
15613 l_prefix := null ;
15614 l_suffix := null ;
15615 end if ;
15616 -- End Prefix Sufix derivation
15617 for r_SVA_unique in c_unique_SVA('SVA') loop
15618
15619 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
15620 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15621 r_SVA_unique.information3 >=
15622 ben_pd_copy_to_ben_one.g_copy_effective_date)
15623 ) then
15624 --
15625 hr_utility.set_location(' r_SVA_unique.table_route_id '||r_SVA_unique.table_route_id,10);
15626 hr_utility.set_location(' r_SVA_unique.information1 '||r_SVA_unique.information1,10);
15627 hr_utility.set_location( 'r_SVA_unique.information2 '||r_SVA_unique.information2,10);
15628 hr_utility.set_location( 'r_SVA_unique.information3 '||r_SVA_unique.information3,10);
15629 -- If reuse objects flag is 'Y' then check for the object in the target business group
15630 -- if found insert the record into PLSql table and exit the loop else try create the
15631 -- object in the target business group
15632 --
15633 l_object_found_in_target := false ;
15634 --UPD START
15635 l_update := false;
15636 l_process_date := p_effective_date;
15637 l_dml_operation:= r_SVA_unique.dml_operation ;
15638 --
15639 if l_dml_operation = 'UPDATE' then
15640 --
15641 l_object_found_in_target := TRUE;
15642 --
15643 if l_process_date between r_SVA_unique.information2 and r_SVA_unique.information3 then
15644 l_update := true;
15645 if r_SVA_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
15646 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'SVC_AREA_ID' then
15647 g_pk_tbl(g_count).pk_id_column := 'SVC_AREA_ID' ;
15648 g_pk_tbl(g_count).old_value := r_SVA_unique.information1 ;
15649 g_pk_tbl(g_count).new_value := r_SVA_unique.information1 ;
15650 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
15651 g_pk_tbl(g_count).table_route_id := r_SVA_unique.table_route_id;
15652 --
15653 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
15654 --
15655 g_count := g_count + 1 ;
15656 --
15657 log_data('SVA',l_new_value,l_prefix || r_SVA_unique.name|| l_suffix,'REUSED');
15658 --
15659 end if ;
15660 hr_utility.set_location( 'found record for update',10);
15661 --
15662 else
15663 --
15664 l_update := false;
15665 --
15666 end if;
15667 else
15668 --
15669 --UPD END
15670 l_min_esd := null ;
15671 l_max_eed := null ;
15672 open c_SVA_min_max_dates(r_SVA_unique.table_route_id, r_SVA_unique.information1 ) ;
15673 fetch c_SVA_min_max_dates into l_min_esd,l_max_eed ;
15674
15675 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15676 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
15677 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
15678 end if;
15679 l_min_esd := greatest(l_min_esd,r_SVA_unique.information2);
15680
15681 if p_reuse_object_flag = 'Y' then
15682 if c_SVA_min_max_dates%found then
15683 -- cursor to find the object
15684 open c_find_SVA_in_target( l_prefix || r_SVA_unique.name || l_suffix ,l_min_esd,l_max_eed,
15685 p_target_business_group_id, nvl(l_svc_area_id, -999) ) ;
15686 fetch c_find_SVA_in_target into l_new_value ;
15687 if c_find_SVA_in_target%found then
15688 --
15689 --TEMPIK
15690 l_dt_rec_found := dt_api.check_min_max_dates
15691 (p_base_table_name => 'BEN_SVC_AREA_F',
15692 p_base_key_column => 'SVC_AREA_ID',
15693 p_base_key_value => l_new_value,
15694 p_from_date => l_min_esd,
15695 p_to_date => l_max_eed );
15696 if l_dt_rec_found THEN
15697 --END TEMPIK
15698 if r_SVA_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
15699 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'SVC_AREA_ID' then
15700 g_pk_tbl(g_count).pk_id_column := 'SVC_AREA_ID' ;
15701 g_pk_tbl(g_count).old_value := r_SVA_unique.information1 ;
15702 g_pk_tbl(g_count).new_value := l_new_value ;
15703 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
15704 g_pk_tbl(g_count).table_route_id := r_SVA_unique.table_route_id;
15705 --
15706 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
15707 --
15708 g_count := g_count + 1 ;
15709 --
15710 log_data('SVA',l_new_value,l_prefix || r_SVA_unique.name || l_suffix ,'REUSED');
15711 --
15712 end if ;
15713 --
15714 l_object_found_in_target := true ;
15715 --TEMPIK
15716 end if; -- l_dt_rec_found
15717 --END TEMPIK
15718 end if;
15719 close c_find_SVA_in_target ;
15720 --
15721 end if;
15722 end if ;
15723 --
15724 close c_SVA_min_max_dates ;
15725 end if; --if p_dml_operation
15726 --
15727 if not l_object_found_in_target OR l_update then
15728 --
15729 open c_SVA(r_SVA_unique.table_route_id,
15730 r_SVA_unique.information1,
15731 r_SVA_unique.information2,
15732 r_SVA_unique.information3 ) ;
15733 --
15734 fetch c_SVA into r_SVA ;
15735 --
15736 close c_SVA ;
15737 --
15738 l_current_pk_id := r_SVA.information1;
15739 --
15740 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
15741 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
15742 --
15743 if l_current_pk_id = l_prev_pk_id then
15744 --
15745 l_first_rec := false ;
15746 --
15747 else
15748 --
15749 l_first_rec := true ;
15750 --
15751 end if ;
15752 --
15753 ben_pd_copy_to_ben_one.ben_chk_col_len('NAME' ,'BEN_SVC_AREA_F',l_prefix || r_SVA.information170 || l_suffix);
15754 --
15755
15756 l_effective_date := r_SVA.information2;
15757 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
15758 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
15759 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
15760 end if;
15761
15762 if l_first_rec and not l_update then
15763 -- Call Create routine.
15764 hr_utility.set_location(' BEN_SVC_AREA_F CREATE_SERVICE_AREA ',20);
15765 BEN_SERVICE_AREA_API.CREATE_SERVICE_AREA(
15766 --
15767 P_VALIDATE => false
15768 ,P_EFFECTIVE_DATE => l_effective_date
15769 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
15770 --
15771 ,P_NAME => l_prefix || r_SVA.INFORMATION170 || l_suffix
15772 ,P_ORG_UNIT_PRDCT => r_SVA.INFORMATION141
15773 ,P_SVA_ATTRIBUTE1 => r_SVA.INFORMATION111
15774 ,P_SVA_ATTRIBUTE10 => r_SVA.INFORMATION120
15775 ,P_SVA_ATTRIBUTE11 => r_SVA.INFORMATION121
15776 ,P_SVA_ATTRIBUTE12 => r_SVA.INFORMATION122
15777 ,P_SVA_ATTRIBUTE13 => r_SVA.INFORMATION123
15778 ,P_SVA_ATTRIBUTE14 => r_SVA.INFORMATION124
15779 ,P_SVA_ATTRIBUTE15 => r_SVA.INFORMATION125
15780 ,P_SVA_ATTRIBUTE16 => r_SVA.INFORMATION126
15781 ,P_SVA_ATTRIBUTE17 => r_SVA.INFORMATION127
15782 ,P_SVA_ATTRIBUTE18 => r_SVA.INFORMATION128
15783 ,P_SVA_ATTRIBUTE19 => r_SVA.INFORMATION129
15784 ,P_SVA_ATTRIBUTE2 => r_SVA.INFORMATION112
15785 ,P_SVA_ATTRIBUTE20 => r_SVA.INFORMATION130
15786 ,P_SVA_ATTRIBUTE21 => r_SVA.INFORMATION131
15787 ,P_SVA_ATTRIBUTE22 => r_SVA.INFORMATION132
15788 ,P_SVA_ATTRIBUTE23 => r_SVA.INFORMATION133
15789 ,P_SVA_ATTRIBUTE24 => r_SVA.INFORMATION134
15790 ,P_SVA_ATTRIBUTE25 => r_SVA.INFORMATION135
15791 ,P_SVA_ATTRIBUTE26 => r_SVA.INFORMATION136
15792 ,P_SVA_ATTRIBUTE27 => r_SVA.INFORMATION137
15793 ,P_SVA_ATTRIBUTE28 => r_SVA.INFORMATION138
15794 ,P_SVA_ATTRIBUTE29 => r_SVA.INFORMATION139
15795 ,P_SVA_ATTRIBUTE3 => r_SVA.INFORMATION113
15796 ,P_SVA_ATTRIBUTE30 => r_SVA.INFORMATION140
15797 ,P_SVA_ATTRIBUTE4 => r_SVA.INFORMATION114
15798 ,P_SVA_ATTRIBUTE5 => r_SVA.INFORMATION115
15799 ,P_SVA_ATTRIBUTE6 => r_SVA.INFORMATION116
15800 ,P_SVA_ATTRIBUTE7 => r_SVA.INFORMATION117
15801 ,P_SVA_ATTRIBUTE8 => r_SVA.INFORMATION118
15802 ,P_SVA_ATTRIBUTE9 => r_SVA.INFORMATION119
15803 ,P_SVA_ATTRIBUTE_CATEGORY => r_SVA.INFORMATION110
15804 ,P_SVC_AREA_ID => l_svc_area_id
15805 --
15806 ,P_EFFECTIVE_START_DATE => l_effective_start_date
15807 ,P_EFFECTIVE_END_DATE => l_effective_end_date
15808 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
15809 );
15810 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
15811 -- Update all relevent cer records with new pk_id
15812 hr_utility.set_location('Before plsql table ',222);
15813 hr_utility.set_location('new_value id '||l_svc_area_id,222);
15814 g_pk_tbl(g_count).pk_id_column := 'SVC_AREA_ID' ;
15815 g_pk_tbl(g_count).old_value := r_SVA.information1 ;
15816 g_pk_tbl(g_count).new_value := l_SVC_AREA_ID ;
15817 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
15818 g_pk_tbl(g_count).table_route_id := r_SVA_unique.table_route_id;
15819 hr_utility.set_location('After plsql table ',222);
15820 --
15821 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
15822 --
15823 g_count := g_count + 1 ;
15824 --
15825 log_data('SVA',l_new_value,l_prefix || r_SVA.information170 || l_suffix,'COPIED');
15826 --
15827 else
15828 --
15829 -- Call Update routine for the pk_id created in prev run .
15830 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
15831 --UPD START
15832 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
15833 --
15834 if l_update then
15835 --
15836 l_datetrack_mode := r_SVA.datetrack_mode ;
15837 --
15838 get_dt_modes(
15839 p_effective_date => l_process_date,
15840 p_effective_end_date => r_SVA.information3,
15841 p_effective_start_date => r_SVA.information2,
15842 p_dml_operation => r_SVA.dml_operation,
15843 p_datetrack_mode => l_datetrack_mode );
15844 -- p_update => l_update
15845 --
15846 l_effective_date := l_process_date;
15847 l_SVC_AREA_ID := r_SVA.information1;
15848 l_object_version_number := r_SVA.information265;
15849 --
15850 end if;
15851 --
15852 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
15853 --
15854 IF l_update OR l_dml_operation <> 'UPDATE' THEN
15855 --UPD END
15856 hr_utility.set_location(' BEN_SVC_AREA_F UPDATE_SERVICE_AREA ',30);
15857 BEN_SERVICE_AREA_API.UPDATE_SERVICE_AREA(
15858 --
15859 P_VALIDATE => false
15860 ,P_EFFECTIVE_DATE => l_effective_date
15861 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
15862 --
15863 ,P_NAME => l_prefix || r_SVA.INFORMATION170 || l_suffix
15864 ,P_ORG_UNIT_PRDCT => r_SVA.INFORMATION141
15865 ,P_SVA_ATTRIBUTE1 => r_SVA.INFORMATION111
15866 ,P_SVA_ATTRIBUTE10 => r_SVA.INFORMATION120
15867 ,P_SVA_ATTRIBUTE11 => r_SVA.INFORMATION121
15868 ,P_SVA_ATTRIBUTE12 => r_SVA.INFORMATION122
15869 ,P_SVA_ATTRIBUTE13 => r_SVA.INFORMATION123
15870 ,P_SVA_ATTRIBUTE14 => r_SVA.INFORMATION124
15871 ,P_SVA_ATTRIBUTE15 => r_SVA.INFORMATION125
15872 ,P_SVA_ATTRIBUTE16 => r_SVA.INFORMATION126
15873 ,P_SVA_ATTRIBUTE17 => r_SVA.INFORMATION127
15874 ,P_SVA_ATTRIBUTE18 => r_SVA.INFORMATION128
15875 ,P_SVA_ATTRIBUTE19 => r_SVA.INFORMATION129
15876 ,P_SVA_ATTRIBUTE2 => r_SVA.INFORMATION112
15877 ,P_SVA_ATTRIBUTE20 => r_SVA.INFORMATION130
15878 ,P_SVA_ATTRIBUTE21 => r_SVA.INFORMATION131
15879 ,P_SVA_ATTRIBUTE22 => r_SVA.INFORMATION132
15880 ,P_SVA_ATTRIBUTE23 => r_SVA.INFORMATION133
15881 ,P_SVA_ATTRIBUTE24 => r_SVA.INFORMATION134
15882 ,P_SVA_ATTRIBUTE25 => r_SVA.INFORMATION135
15883 ,P_SVA_ATTRIBUTE26 => r_SVA.INFORMATION136
15884 ,P_SVA_ATTRIBUTE27 => r_SVA.INFORMATION137
15885 ,P_SVA_ATTRIBUTE28 => r_SVA.INFORMATION138
15886 ,P_SVA_ATTRIBUTE29 => r_SVA.INFORMATION139
15887 ,P_SVA_ATTRIBUTE3 => r_SVA.INFORMATION113
15888 ,P_SVA_ATTRIBUTE30 => r_SVA.INFORMATION140
15889 ,P_SVA_ATTRIBUTE4 => r_SVA.INFORMATION114
15890 ,P_SVA_ATTRIBUTE5 => r_SVA.INFORMATION115
15891 ,P_SVA_ATTRIBUTE6 => r_SVA.INFORMATION116
15892 ,P_SVA_ATTRIBUTE7 => r_SVA.INFORMATION117
15893 ,P_SVA_ATTRIBUTE8 => r_SVA.INFORMATION118
15894 ,P_SVA_ATTRIBUTE9 => r_SVA.INFORMATION119
15895 ,P_SVA_ATTRIBUTE_CATEGORY => r_SVA.INFORMATION110
15896 ,P_SVC_AREA_ID => l_svc_area_id
15897 --
15898 ,P_EFFECTIVE_START_DATE => l_effective_start_date
15899 ,P_EFFECTIVE_END_DATE => l_effective_end_date
15900 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
15901 ,P_DATETRACK_MODE => l_datetrack_mode
15902 );
15903 --
15904 end if;
15905 end if;
15906 --
15907 -- Delete the row if it is end dated.
15908 --
15909 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
15910 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
15911 trunc(l_max_eed) = r_SVA.information3) then
15912 --
15913 BEN_SERVICE_AREA_API.delete_SERVICE_AREA(
15914 --
15915 p_validate => false
15916 ,p_svc_area_id => l_svc_area_id
15917 ,p_effective_start_date => l_effective_start_date
15918 ,p_effective_end_date => l_effective_end_date
15919 ,p_object_version_number => l_object_version_number
15920 ,p_effective_date => l_max_eed
15921 ,p_datetrack_mode => hr_api.g_delete
15922 --
15923 );
15924 --
15925 end if;
15926 --
15927 l_prev_pk_id := l_current_pk_id ;
15928 --
15929 end if;
15930 --
15931 end if;
15932 --
15933 end loop;
15934 --
15935 exception when others then
15936 --
15937 raise_error_message( 'SVA',l_prefix || r_SVA.information170 || l_suffix) ;
15938 --
15939 end create_SVA_rows;
15940
15941 --
15942 ---------------------------------------------------------------
15943 ----------------------< create_PON_rows >-----------------------
15944 ---------------------------------------------------------------
15945 --
15946 procedure create_PON_rows
15947 (
15948 p_validate in number default 0
15949 ,p_copy_entity_txn_id in number
15950 ,p_effective_date in date
15951 ,p_prefix_suffix_text in varchar2 default null
15952 ,p_reuse_object_flag in varchar2 default null
15953 ,p_target_business_group_id in varchar2 default null
15954 ,p_prefix_suffix_cd in varchar2 default null
15955 ) is
15956 --
15957 l_OPT_ID number;
15958 l_PL_TYP_ID number;
15959 cursor c_unique_PON(l_table_alias varchar2) is
15960 select distinct cpe.information1,
15961 cpe.information2,
15962 cpe.information3,
15963 cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
15964 from ben_copy_entity_results cpe,
15965 pqh_table_route tr
15966 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15967 and cpe.table_route_id = tr.table_route_id
15968 -- and tr.where_clause = l_BEN_PL_TYP_OPT_TYP_F
15969 and tr.table_alias = l_table_alias
15970 and cpe.number_of_copies = 1 --ADDITION
15971 group by cpe.information1,cpe.information2,cpe.information3, cpe.table_route_id,cpe.dml_operation,cpe.datetrack_mode
15972 order by information1, information2; --added for bug: 5151945
15973 --
15974 --
15975 cursor c_PON_min_max_dates(c_table_route_id number,
15976 c_information1 number) is
15977 select
15978 min(cpe.information2) min_esd,
15979 max(cpe.information3) min_eed
15980 from ben_copy_entity_results cpe
15981 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15982 and cpe.table_route_id = c_table_route_id
15983 and cpe.information1 = c_information1 ;
15984 --
15985 cursor c_PON(c_table_route_id number,
15986 c_information1 number,
15987 c_information2 date,
15988 c_information3 date ) is
15989 select
15990 cpe.*
15991 from ben_copy_entity_results cpe
15992 where cpe.copy_entity_txn_id = p_copy_entity_txn_id
15993 and cpe.table_route_id = c_table_route_id
15994 and cpe.information1 = c_information1
15995 and cpe.information2 = c_information2
15996 and cpe.information3 = c_information3
15997 and rownum = 1 ;
15998 -- Date Track target record
15999 cursor c_find_PON_in_target(
16000 c_effective_start_date date,
16001 c_effective_end_date date,
16002 c_business_group_id number,
16003 c_new_pk_id number) is
16004 select
16005 PON.pl_typ_opt_typ_id new_value
16006 from BEN_PL_TYP_OPT_TYP_F PON
16007 where
16008 PON.OPT_ID = l_OPT_ID and
16009 PON.PL_TYP_ID = l_PL_TYP_ID and
16010 PON.business_group_id = c_business_group_id
16011 and PON.pl_typ_opt_typ_id <> c_new_pk_id
16012 --TEMPIK
16013 and c_effective_start_date between effective_start_date
16014 and effective_end_date ;
16015 --END TEMPIK
16016 /*TEMPIK
16017 and exists ( select null
16018 from BEN_PL_TYP_OPT_TYP_F PON1
16019 where
16020 PON1.OPT_ID = l_OPT_ID and
16021 PON1.PL_TYP_ID = l_PL_TYP_ID and
16022 PON1.business_group_id = c_business_group_id
16023 and PON1.effective_start_date <= c_effective_start_date )
16024 and exists ( select null
16025 from BEN_PL_TYP_OPT_TYP_F PON2
16026 where
16027 PON2.OPT_ID = l_OPT_ID and
16028 PON2.PL_TYP_ID = l_PL_TYP_ID and
16029 PON2.business_group_id = c_business_group_id
16030 and PON2.effective_end_date >= c_effective_end_date )
16031 ;
16032 TEMPIK */
16033 --TEMPIK
16034 l_dt_rec_found boolean ;
16035 --END TEMPIK
16036 --
16037 l_current_pk_id number := null ;
16038 --UPD START
16039 --
16040 l_update boolean := false ;
16041 l_datetrack_mode varchar2(80) := hr_api.g_update;
16042 l_process_date date;
16043 l_dml_operation ben_copy_entity_results.dml_operation%TYPE ;
16044 --
16045 --UPD END
16046 l_prev_pk_id number := null ;
16047 l_first_rec boolean := true ;
16048 r_PON c_PON%rowtype;
16049 l_pl_typ_opt_typ_id number ;
16050 l_object_version_number number ;
16051 l_effective_start_date date ;
16052 l_effective_end_date date ;
16053 l_prefix pqh_copy_entity_attribs.information1%type := null;
16054 l_suffix pqh_copy_entity_attribs.information1%type := null;
16055 l_new_value number(15);
16056 l_object_found_in_target boolean := false ;
16057 l_min_esd date;
16058 l_max_eed date;
16059 l_effective_date date;
16060 --
16061 begin
16062 -- Initialization
16063 l_object_found_in_target := false ;
16064 -- End Initialization
16065 -- Derive the prefix - sufix
16066 if p_prefix_suffix_cd = 'PREFIX' then
16067 l_prefix := p_prefix_suffix_text ;
16068 elsif p_prefix_suffix_cd = 'SUFFIX' then
16069 l_suffix := p_prefix_suffix_text ;
16070 else
16071 l_prefix := null ;
16072 l_suffix := null ;
16073 end if ;
16074 -- End Prefix Sufix derivation
16075 for r_PON_unique in c_unique_PON('PON') loop
16076
16077 if (ben_pd_copy_to_ben_one.g_copy_effective_date is null or
16078 (ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16079 r_PON_unique.information3 >=
16080 ben_pd_copy_to_ben_one.g_copy_effective_date)
16081 ) then
16082 --
16083 hr_utility.set_location(' r_PON_unique.table_route_id '||r_PON_unique.table_route_id,10);
16084 hr_utility.set_location(' r_PON_unique.information1 '||r_PON_unique.information1,10);
16085 hr_utility.set_location( 'r_PON_unique.information2 '||r_PON_unique.information2,10);
16086 hr_utility.set_location( 'r_PON_unique.information3 '||r_PON_unique.information3,10);
16087 -- If reuse objects flag is 'Y' then check for the object in the target business group
16088 -- if found insert the record into PLSql table and exit the loop else try create the
16089 -- object in the target business group
16090 --
16091 l_object_found_in_target := false ;
16092 l_min_esd := null ;
16093 l_max_eed := null ;
16094 --UPD START
16095 l_update := false;
16096 l_process_date := p_effective_date;
16097 l_dml_operation:= r_PON_unique.dml_operation ;
16098 --
16099 open c_PON(r_PON_unique.table_route_id,
16100 r_PON_unique.information1,
16101 r_PON_unique.information2,
16102 r_PON_unique.information3 ) ;
16103 --
16104 fetch c_PON into r_PON ;
16105 --
16106 close c_PON ;
16107 --
16108 l_OPT_ID := get_fk('OPT_ID', r_PON.INFORMATION247,l_dml_operation);
16109 l_PL_TYP_ID := get_fk('PL_TYP_ID', r_PON.INFORMATION248,l_dml_operation);
16110 --
16111 --
16112 if l_dml_operation = 'UPDATE' then
16113 --
16114 l_object_found_in_target := TRUE;
16115 --
16116 if l_process_date between r_PON_unique.information2 and r_PON_unique.information3 then
16117 l_update := true;
16118 if r_PON_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
16119 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PL_TYP_OPT_TYP_ID' then
16120 g_pk_tbl(g_count).pk_id_column := 'PL_TYP_OPT_TYP_ID' ;
16121 g_pk_tbl(g_count).old_value := r_PON_unique.information1 ;
16122 g_pk_tbl(g_count).new_value := r_PON_unique.information1 ;
16123 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
16124 g_pk_tbl(g_count).table_route_id := r_PON_unique.table_route_id;
16125 --
16126 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
16127 --
16128 g_count := g_count + 1 ;
16129 --
16130 -- log_data('PON',l_new_value,l_prefix || r_PON_unique.information1|| l_suffix,'REUSED');
16131 --
16132 end if ;
16133 hr_utility.set_location( 'found record for update',10);
16134 --
16135 else
16136 --
16137 l_update := false;
16138 --
16139 end if;
16140 else
16141 --
16142 --UPD END
16143 open c_PON_min_max_dates(r_PON_unique.table_route_id, r_PON_unique.information1 ) ;
16144 fetch c_PON_min_max_dates into l_min_esd,l_max_eed ;
16145 --
16146
16147 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16148 l_min_esd < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
16149 l_min_esd := ben_pd_copy_to_ben_one.g_copy_effective_date;
16150 end if;
16151 l_min_esd := greatest(l_min_esd,r_PON_unique.information2);
16152 /*
16153 open c_PON(r_PON_unique.table_route_id,
16154 r_PON_unique.information1,
16155 r_PON_unique.information2,
16156 r_PON_unique.information3 ) ;
16157 --
16158 fetch c_PON into r_PON ;
16159 --
16160 close c_PON ;
16161 --
16162 l_OPT_ID := get_fk('OPT_ID', r_PON.INFORMATION247);
16163 l_PL_TYP_ID := get_fk('PL_TYP_ID', r_PON.INFORMATION248);
16164 */
16165 if p_reuse_object_flag = 'Y' then
16166 if c_PON_min_max_dates%found then
16167 -- cursor to find the object
16168 open c_find_PON_in_target( l_min_esd,l_max_eed,
16169 p_target_business_group_id, nvl(l_pl_typ_opt_typ_id, -999) ) ;
16170 fetch c_find_PON_in_target into l_new_value ;
16171 if c_find_PON_in_target%found then
16172 --
16173 --TEMPIK
16174 l_dt_rec_found := dt_api.check_min_max_dates
16175 (p_base_table_name => 'BEN_PL_TYP_OPT_TYP_F',
16176 p_base_key_column => 'PL_TYP_OPT_TYP_ID',
16177 p_base_key_value => l_new_value,
16178 p_from_date => l_min_esd,
16179 p_to_date => l_max_eed );
16180 if l_dt_rec_found THEN
16181 --END TEMPIK
16182 if r_PON_unique.information1 <> nvl(g_pk_tbl(g_count-1).old_value, -999) or
16183 nvl(g_pk_tbl(g_count-1).pk_id_column, '999') <> 'PL_TYP_OPT_TYP_ID' then
16184 g_pk_tbl(g_count).pk_id_column := 'PL_TYP_OPT_TYP_ID' ;
16185 g_pk_tbl(g_count).old_value := r_PON_unique.information1 ;
16186 g_pk_tbl(g_count).new_value := l_new_value ;
16187 g_pk_tbl(g_count).copy_reuse_type := 'REUSED';
16188 g_pk_tbl(g_count).table_route_id := r_PON_unique.table_route_id;
16189 --
16190 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
16191 --
16192 g_count := g_count + 1 ;
16193 end if ;
16194 --
16195 l_object_found_in_target := true ;
16196 --TEMPIK
16197 end if; -- l_dt_rec_found
16198 --END TEMPIK
16199 end if;
16200 close c_find_PON_in_target ;
16201 --
16202 end if;
16203 end if ;
16204 --
16205 close c_PON_min_max_dates ;
16206 end if; --if p_dml_operation
16207 --
16208 -- 4395957 - Avoid calling API's if PL_TYP_ID is not found.
16209 if (l_PL_TYP_ID is NOT NULL) THEN
16210 if not l_object_found_in_target OR l_update then
16211 --
16212 l_current_pk_id := r_PON.information1;
16213 --
16214 hr_utility.set_location(' l_current_pk_id '||l_current_pk_id,20);
16215 hr_utility.set_location(' l_prev_pk_id '||l_prev_pk_id,20);
16216 --
16217 if l_current_pk_id = l_prev_pk_id then
16218 --
16219 l_first_rec := false ;
16220 --
16221 else
16222 --
16223 l_first_rec := true ;
16224 --
16225 end if ;
16226 --
16227
16228 l_effective_date := r_PON.information2;
16229 if ( ben_pd_copy_to_ben_one.g_copy_effective_date is not null and
16230 l_effective_date < ben_pd_copy_to_ben_one.g_copy_effective_date ) then
16231 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
16232 end if;
16233
16234 if l_first_rec and not l_update then
16235 -- Call Create routine.
16236 hr_utility.set_location(' BEN_PL_TYP_OPT_TYP_F CREATE_PLAN_TYPE_OPTION_TYPE ',20);
16237 BEN_PLAN_TYPE_OPTION_TYPE_API.CREATE_PLAN_TYPE_OPTION_TYPE(
16238 --
16239 P_VALIDATE => false
16240 ,P_EFFECTIVE_DATE => l_effective_date
16241 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16242 --
16243 ,P_OPT_ID => l_OPT_ID
16244 ,P_PL_TYP_ID => l_PL_TYP_ID
16245 ,P_PL_TYP_OPT_TYP_CD => r_PON.INFORMATION11
16246 ,P_PL_TYP_OPT_TYP_ID => l_pl_typ_opt_typ_id
16247 ,P_PON_ATTRIBUTE1 => r_PON.INFORMATION111
16248 ,P_PON_ATTRIBUTE10 => r_PON.INFORMATION120
16249 ,P_PON_ATTRIBUTE11 => r_PON.INFORMATION121
16250 ,P_PON_ATTRIBUTE12 => r_PON.INFORMATION122
16251 ,P_PON_ATTRIBUTE13 => r_PON.INFORMATION123
16252 ,P_PON_ATTRIBUTE14 => r_PON.INFORMATION124
16253 ,P_PON_ATTRIBUTE15 => r_PON.INFORMATION125
16254 ,P_PON_ATTRIBUTE16 => r_PON.INFORMATION126
16255 ,P_PON_ATTRIBUTE17 => r_PON.INFORMATION127
16256 ,P_PON_ATTRIBUTE18 => r_PON.INFORMATION128
16257 ,P_PON_ATTRIBUTE19 => r_PON.INFORMATION129
16258 ,P_PON_ATTRIBUTE2 => r_PON.INFORMATION112
16259 ,P_PON_ATTRIBUTE20 => r_PON.INFORMATION130
16260 ,P_PON_ATTRIBUTE21 => r_PON.INFORMATION131
16261 ,P_PON_ATTRIBUTE22 => r_PON.INFORMATION132
16262 ,P_PON_ATTRIBUTE23 => r_PON.INFORMATION133
16263 ,P_PON_ATTRIBUTE24 => r_PON.INFORMATION134
16264 ,P_PON_ATTRIBUTE25 => r_PON.INFORMATION135
16265 ,P_PON_ATTRIBUTE26 => r_PON.INFORMATION136
16266 ,P_PON_ATTRIBUTE27 => r_PON.INFORMATION137
16267 ,P_PON_ATTRIBUTE28 => r_PON.INFORMATION138
16268 ,P_PON_ATTRIBUTE29 => r_PON.INFORMATION139
16269 ,P_PON_ATTRIBUTE3 => r_PON.INFORMATION113
16270 ,P_PON_ATTRIBUTE30 => r_PON.INFORMATION140
16271 ,P_PON_ATTRIBUTE4 => r_PON.INFORMATION114
16272 ,P_PON_ATTRIBUTE5 => r_PON.INFORMATION115
16273 ,P_PON_ATTRIBUTE6 => r_PON.INFORMATION116
16274 ,P_PON_ATTRIBUTE7 => r_PON.INFORMATION117
16275 ,P_PON_ATTRIBUTE8 => r_PON.INFORMATION118
16276 ,P_PON_ATTRIBUTE9 => r_PON.INFORMATION119
16277 ,P_PON_ATTRIBUTE_CATEGORY => r_PON.INFORMATION110
16278 --
16279 ,P_EFFECTIVE_START_DATE => l_effective_start_date
16280 ,P_EFFECTIVE_END_DATE => l_effective_end_date
16281 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16282 );
16283 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16284 -- Update all relevent cer records with new pk_id
16285 hr_utility.set_location('Before plsql table ',222);
16286 hr_utility.set_location('new_value id '||l_pl_typ_opt_typ_id,222);
16287 g_pk_tbl(g_count).pk_id_column := 'PL_TYP_OPT_TYP_ID' ;
16288 g_pk_tbl(g_count).old_value := r_PON.information1 ;
16289 g_pk_tbl(g_count).new_value := l_PL_TYP_OPT_TYP_ID ;
16290 g_pk_tbl(g_count).copy_reuse_type := 'COPIED';
16291 g_pk_tbl(g_count).table_route_id := r_PON_unique.table_route_id;
16292 hr_utility.set_location('After plsql table ',222);
16293 --
16294 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
16295 --
16296 g_count := g_count + 1 ;
16297 --
16298 else
16299 --
16300 -- Call Update routine for the pk_id created in prev run .
16301 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16302 --UPD START
16303 hr_utility.set_location('Before call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
16304 --
16305 if l_update then
16306 --
16307 l_datetrack_mode := r_PON.datetrack_mode ;
16308 --
16309 get_dt_modes(
16310 p_effective_date => l_process_date,
16311 p_effective_end_date => r_PON.information3,
16312 p_effective_start_date => r_PON.information2,
16313 p_dml_operation => r_PON.dml_operation,
16314 p_datetrack_mode => l_datetrack_mode );
16315 -- p_update => l_update
16316 --
16317 l_effective_date := l_process_date;
16318 l_PL_TYP_OPT_TYP_ID := r_PON.information1;
16319 l_object_version_number := r_PON.information265;
16320 --
16321 end if;
16322 --
16323 hr_utility.set_location('After call to get_dt_modes l_dt_mode'||l_datetrack_mode,5);
16324 --
16325 IF l_update OR l_dml_operation <> 'UPDATE' THEN
16326 --UPD END
16327 hr_utility.set_location(' BEN_PL_TYP_OPT_TYP_F UPDATE_PLAN_TYPE_OPTION_TYPE ',30);
16328 BEN_PLAN_TYPE_OPTION_TYPE_API.UPDATE_PLAN_TYPE_OPTION_TYPE(
16329 --
16330 P_VALIDATE => false
16331 ,P_EFFECTIVE_DATE => l_effective_date
16332 ,P_BUSINESS_GROUP_ID => p_target_business_group_id
16333 --
16334 ,P_OPT_ID => l_OPT_ID
16335 ,P_PL_TYP_ID => l_PL_TYP_ID
16336 ,P_PL_TYP_OPT_TYP_CD => r_PON.INFORMATION11
16337 ,P_PL_TYP_OPT_TYP_ID => l_pl_typ_opt_typ_id
16338 ,P_PON_ATTRIBUTE1 => r_PON.INFORMATION111
16339 ,P_PON_ATTRIBUTE10 => r_PON.INFORMATION120
16340 ,P_PON_ATTRIBUTE11 => r_PON.INFORMATION121
16341 ,P_PON_ATTRIBUTE12 => r_PON.INFORMATION122
16342 ,P_PON_ATTRIBUTE13 => r_PON.INFORMATION123
16343 ,P_PON_ATTRIBUTE14 => r_PON.INFORMATION124
16344 ,P_PON_ATTRIBUTE15 => r_PON.INFORMATION125
16345 ,P_PON_ATTRIBUTE16 => r_PON.INFORMATION126
16346 ,P_PON_ATTRIBUTE17 => r_PON.INFORMATION127
16347 ,P_PON_ATTRIBUTE18 => r_PON.INFORMATION128
16348 ,P_PON_ATTRIBUTE19 => r_PON.INFORMATION129
16349 ,P_PON_ATTRIBUTE2 => r_PON.INFORMATION112
16350 ,P_PON_ATTRIBUTE20 => r_PON.INFORMATION130
16351 ,P_PON_ATTRIBUTE21 => r_PON.INFORMATION131
16352 ,P_PON_ATTRIBUTE22 => r_PON.INFORMATION132
16353 ,P_PON_ATTRIBUTE23 => r_PON.INFORMATION133
16354 ,P_PON_ATTRIBUTE24 => r_PON.INFORMATION134
16355 ,P_PON_ATTRIBUTE25 => r_PON.INFORMATION135
16356 ,P_PON_ATTRIBUTE26 => r_PON.INFORMATION136
16357 ,P_PON_ATTRIBUTE27 => r_PON.INFORMATION137
16358 ,P_PON_ATTRIBUTE28 => r_PON.INFORMATION138
16359 ,P_PON_ATTRIBUTE29 => r_PON.INFORMATION139
16360 ,P_PON_ATTRIBUTE3 => r_PON.INFORMATION113
16361 ,P_PON_ATTRIBUTE30 => r_PON.INFORMATION140
16362 ,P_PON_ATTRIBUTE4 => r_PON.INFORMATION114
16363 ,P_PON_ATTRIBUTE5 => r_PON.INFORMATION115
16364 ,P_PON_ATTRIBUTE6 => r_PON.INFORMATION116
16365 ,P_PON_ATTRIBUTE7 => r_PON.INFORMATION117
16366 ,P_PON_ATTRIBUTE8 => r_PON.INFORMATION118
16367 ,P_PON_ATTRIBUTE9 => r_PON.INFORMATION119
16368 ,P_PON_ATTRIBUTE_CATEGORY => r_PON.INFORMATION110
16369 --
16370 ,P_EFFECTIVE_START_DATE => l_effective_start_date
16371 ,P_EFFECTIVE_END_DATE => l_effective_end_date
16372 ,P_OBJECT_VERSION_NUMBER => l_object_version_number
16373 ,P_DATETRACK_MODE => l_datetrack_mode
16374 );
16375 --
16376 end if;
16377 end if;
16378 --
16379 -- Delete the row if it is end dated.
16380 --
16381 if (trunc(l_max_eed) <> trunc(hr_api.g_eot) and
16382 trunc(l_max_eed) <> l_effective_end_date and /* Bug 4302963 */
16383 trunc(l_max_eed) = r_PON.information3) then
16384 --
16385 BEN_PLAN_TYPE_OPTION_TYPE_API.delete_PLAN_TYPE_OPTION_TYPE(
16386 --
16387 p_validate => false
16388 ,p_pl_typ_opt_typ_id => l_pl_typ_opt_typ_id
16389 ,p_effective_start_date => l_effective_start_date
16390 ,p_effective_end_date => l_effective_end_date
16391 ,p_object_version_number => l_object_version_number
16392 ,p_effective_date => l_max_eed
16393 ,p_datetrack_mode => hr_api.g_delete
16394 --
16395 );
16396 --
16397 end if;
16398 --
16399 l_prev_pk_id := l_current_pk_id ;
16400 --
16401 end if; -- 4395957 END;
16402 end if;
16403 --
16404 end if;
16405 --
16406 end loop;
16407 --
16408 exception when others then
16409 --
16410 raise_error_message( 'PON',r_PON.information5 ) ;
16411 --
16412 end create_PON_rows;
16413
16414 --
16415 -- Bug 4169120 : Rate By Criteria
16416 --
16417 ---------------------------------------------------------------
16418 -----------------< map_valueset_in_target >--------------------
16419 ---------------------------------------------------------------
16420 --
16421 FUNCTION map_valueset_in_target (
16422 p_valueset_name IN VARCHAR2,
16423 p_target_business_group_id IN NUMBER,
16424 p_value_set_id OUT NOCOPY NUMBER
16425 ) RETURN BOOLEAN
16426 IS
16427 --
16428 l_map_succeed BOOLEAN;
16429 l_dummy VARCHAR2(1);
16430 --
16431 CURSOR c_value_set
16432 IS
16433 SELECT flex_value_set_id
16434 FROM fnd_flex_value_sets
16435 WHERE flex_value_set_name = p_valueset_name
16436 /* AND ( NVL (security_group_id, 0) = 0 -- Bug 4351143 Commented as
16437 OR security_group_id IN ( -- security_group_id is not in
16438 SELECT security_group_id -- table fnd_flex_value_sets
16439 FROM fnd_security_groups
16440 WHERE security_group_key = TO_CHAR (p_target_business_group_id)
16441 )
16442 )*/
16443 ;
16444 --
16445 BEGIN
16446 --
16447 hr_utility.set_location('Entering map_valueset_in_target', 5);
16448 --
16449 open c_value_set ;
16450 --
16451 fetch c_value_set into p_value_set_id;
16452 --
16453 if c_value_set%found
16454 then
16455 --
16456 l_map_succeed := true;
16457 --
16458 else
16459 --
16460 l_map_succeed := false;
16461 --
16462 end if;
16463 --
16464 close c_value_set;
16465 --
16466 hr_utility.set_location('Leaving map_valueset_in_target', 10);
16467 --
16468 return l_map_succeed;
16469 --
16470 END map_valueset_in_target;
16471 --
16472 ---------------------------------------------------------------
16473 ------------------< map_lookup_in_target >---------------------
16474 ---------------------------------------------------------------
16475 --
16476 FUNCTION map_lookup_in_target (
16477 p_lookup_name IN VARCHAR2,
16478 p_target_business_group_id IN NUMBER
16479 ) RETURN BOOLEAN
16480 IS
16481 --
16482 l_map_succeed BOOLEAN;
16483 l_dummy VARCHAR2(1);
16484 --
16485 CURSOR c_hr_lookup_type (
16486 cv_lookup_type VARCHAR2,
16487 cv_target_business_group_id NUMBER
16488 )
16489 IS
16490 SELECT NULL
16491 FROM fnd_lookup_types_vl flv
16492 WHERE lookup_type = cv_lookup_type
16493 AND ( customization_level IN ('E', 'S')
16494 OR ( customization_level = 'U'
16495 AND ( security_group_id = 0
16496 OR security_group_id IN (
16497 SELECT security_group_id
16498 FROM fnd_security_groups
16499 WHERE security_group_key =
16500 TO_CHAR (cv_target_business_group_id))
16501 )
16502 )
16503 );
16504 --
16505 BEGIN
16506 --
16507 hr_utility.set_location('Entering map_lookup_in_target', 5);
16508 --
16509 open c_hr_lookup_type ( cv_lookup_type => p_lookup_name,
16510 cv_target_business_group_id => p_target_business_group_id );
16511 --
16512 fetch c_hr_lookup_type into l_dummy;
16513 --
16514 if c_hr_lookup_type%notfound
16515 then
16516 --
16517 l_map_succeed := false;
16518 --
16519 else
16520 --
16521 l_map_succeed := true;
16522 --
16523 end if;
16524 --
16525 close c_hr_lookup_type;
16526 --
16527 hr_utility.set_location('Leaving map_lookup_in_target', 10);
16528 --
16529 return l_map_succeed;
16530 --
16531 END map_lookup_in_target;
16532 --
16533 ---------------------------------------------------------------
16534 ----------------------< create_EGL_rows >-----------------------
16535 ---------------------------------------------------------------
16536 --
16537
16538 PROCEDURE create_EGL_rows (
16539 p_validate IN NUMBER DEFAULT 0,
16540 p_copy_entity_txn_id IN NUMBER,
16541 p_effective_date IN DATE,
16542 p_prefix_suffix_text IN VARCHAR2 DEFAULT NULL,
16543 p_reuse_object_flag IN VARCHAR2 DEFAULT NULL,
16544 p_target_business_group_id IN VARCHAR2 DEFAULT NULL,
16545 p_prefix_suffix_cd IN VARCHAR2 DEFAULT NULL
16546 )
16547 IS
16548 --
16549 CURSOR c_unique_egl (l_table_alias VARCHAR2)
16550 IS
16551 SELECT DISTINCT cpe.information1, cpe.information2, cpe.information3,
16552 cpe.information170 NAME, cpe.table_route_id,
16553 cpe.dml_operation, cpe.datetrack_mode
16554 FROM ben_copy_entity_results cpe, pqh_table_route tr
16555 WHERE cpe.copy_entity_txn_id = p_copy_entity_txn_id
16556 AND cpe.table_route_id = tr.table_route_id
16557 AND tr.table_alias = l_table_alias
16558 AND cpe.number_of_copies = 1
16559 GROUP BY cpe.information1,
16560 cpe.information2,
16561 cpe.information3,
16562 cpe.information170,
16563 cpe.table_route_id,
16564 cpe.dml_operation,
16565 cpe.datetrack_mode
16566 order by information1, information2; --added for bug: 5151945
16567
16568 --
16569 CURSOR c_egl_min_max_dates (c_table_route_id NUMBER, c_information1 NUMBER)
16570 IS
16571 SELECT MIN (cpe.information2) min_esd, MAX (cpe.information3) min_eed
16572 FROM ben_copy_entity_results cpe
16573 WHERE cpe.copy_entity_txn_id = p_copy_entity_txn_id
16574 AND cpe.table_route_id = c_table_route_id
16575 AND cpe.information1 = c_information1;
16576 --
16577 CURSOR c_egl (
16578 c_table_route_id NUMBER,
16579 c_information1 NUMBER
16580 )
16581 IS
16582 SELECT cpe.*
16583 FROM ben_copy_entity_results cpe
16584 WHERE cpe.copy_entity_txn_id = p_copy_entity_txn_id
16585 AND cpe.table_route_id = c_table_route_id
16586 AND cpe.information1 = c_information1
16587 AND ROWNUM = 1;
16588
16589 -- Date Track target record
16590 CURSOR c_find_egl_in_target (
16591 c_egl_name VARCHAR2,
16592 c_business_group_id NUMBER,
16593 c_new_pk_id NUMBER
16594 )
16595 IS
16596 SELECT egl.eligy_criteria_id new_value
16597 FROM ben_eligy_criteria egl
16598 WHERE egl.NAME = c_egl_name
16599 AND egl.business_group_id = c_business_group_id
16600 AND egl.eligy_criteria_id <> c_new_pk_id;
16601 --
16602 CURSOR c_target_type
16603 IS
16604 SELECT information3
16605 FROM pqh_copy_entity_attribs
16606 WHERE copy_entity_Txn_id = p_copy_entity_txn_id;
16607 --
16608 l_current_pk_id NUMBER := NULL;
16609 l_update BOOLEAN := FALSE;
16610 l_datetrack_mode VARCHAR2 (80) := hr_api.g_update;
16611 l_process_date DATE;
16612 l_dml_operation ben_copy_entity_results.dml_operation%TYPE;
16613 l_prev_pk_id NUMBER := NULL;
16614 l_first_rec BOOLEAN := TRUE;
16615 r_egl c_egl%ROWTYPE;
16616 l_eligy_criteria_id NUMBER;
16617 l_object_version_number NUMBER;
16618 l_effective_start_date DATE;
16619 l_effective_end_date DATE;
16620 l_prefix pqh_copy_entity_attribs.information1%TYPE
16621 := NULL;
16622 l_suffix pqh_copy_entity_attribs.information1%TYPE
16623 := NULL;
16624 l_new_value NUMBER (15);
16625 l_object_found_in_target BOOLEAN := FALSE;
16626 l_min_esd DATE;
16627 l_max_eed DATE;
16628 l_effective_date DATE;
16629 l_access_calc_rule NUMBER (15);
16630 l_target_type VARCHAR2(30);
16631 l_map_succeed BOOLEAN;
16632 l_dummy VARCHAR2(1);
16633 l_col1_value_set_id NUMBER(15);
16634 --
16635 BEGIN
16636 -- Initialization
16637 l_object_found_in_target := FALSE;
16638 -- End Initialization
16639
16640 -- Derive the prefix - sufix
16641 --
16642 IF p_prefix_suffix_cd = 'PREFIX'
16643 THEN
16644 --
16645 l_prefix := p_prefix_suffix_text;
16646 --
16647 ELSIF p_prefix_suffix_cd = 'SUFFIX'
16648 THEN
16649 --
16650 l_suffix := p_prefix_suffix_text;
16651 --
16652 ELSE
16653 --
16654 l_prefix := NULL;
16655 l_suffix := NULL;
16656 --
16657 END IF;
16658 --
16659 -- End Prefix Sufix derivation
16660 --
16661 open c_target_type;
16662 --
16663 fetch c_target_type into l_target_type;
16664 --
16665 close c_target_type;
16666 --
16667 --
16668 --
16669 FOR r_egl_unique IN c_unique_egl ('EGL')
16670 LOOP
16671 --
16672 -- IF l_target_type = 'BEN_PDSMBG'
16673 -- THEN
16674 --
16675 hr_utility.set_location(' r_egl_unique.table_route_id ' || r_egl_unique.table_route_id,10);
16676 hr_utility.set_location(' r_egl_unique.information1 ' || r_egl_unique.information1,10);
16677 hr_utility.set_location( 'r_egl_unique.information2 ' || r_egl_unique.information2,10);
16678 hr_utility.set_location( 'r_egl_unique.information3 ' || r_egl_unique.information3,10);
16679 --
16680 -- If reuse objects flag is 'Y' then check for the object in the target business group
16681 -- if found insert the record into PLSql table and exit the loop else try create the
16682 -- object in the target business group
16683 --
16684 l_object_found_in_target := FALSE;
16685 l_dml_operation := r_egl_unique.dml_operation;
16686 --
16687 l_update := FALSE;
16688 --
16689 IF l_dml_operation = 'UPDATE'
16690 THEN
16691 --
16692 l_update := TRUE;
16693
16694 IF r_egl_unique.information1 <> NVL (g_pk_tbl (g_count - 1).old_value, -999)
16695 OR NVL (g_pk_tbl (g_count - 1).pk_id_column, '999') <> 'ELIGY_CRITERIA_ID'
16696 THEN
16697 --
16698 g_pk_tbl (g_count).pk_id_column := 'ELIGY_CRITERIA_ID';
16699 g_pk_tbl (g_count).old_value := r_egl_unique.information1;
16700 g_pk_tbl (g_count).new_value := r_egl_unique.information1;
16701 g_pk_tbl (g_count).copy_reuse_type := 'REUSED';
16702 g_pk_tbl (g_count).table_route_id := r_egl_unique.table_route_id;
16703 --
16704 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ; -- NEW
16705 --
16706 g_count := g_count + 1;
16707 --
16708 log_data ('EGL', l_new_value, l_prefix || r_egl_unique.NAME || l_suffix, 'REUSED');
16709 --
16710 END IF;
16711 --
16712 l_eligy_criteria_id := r_egl_unique.information1;
16713 l_object_version_number := r_egl.information265;
16714 hr_utility.set_location ('found record for update', 10);
16715 --
16716 ELSE
16717 --
16718 l_min_esd := NULL;
16719 l_max_eed := NULL;
16720 --
16721 IF p_reuse_object_flag = 'Y'
16722 THEN
16723 -- cursor to find the object
16724 OPEN c_find_egl_in_target (l_prefix || r_egl_unique.NAME || l_suffix,
16725 p_target_business_group_id,
16726 NVL (l_eligy_criteria_id, -999)
16727 );
16728 FETCH c_find_egl_in_target INTO l_new_value;
16729
16730 IF c_find_egl_in_target%FOUND
16731 THEN
16732 --
16733 IF r_egl_unique.information1 <> NVL (g_pk_tbl (g_count - 1).old_value, -999)
16734 OR NVL (g_pk_tbl (g_count - 1).pk_id_column, '999') <> 'ELIGY_CRITERIA_ID'
16735 THEN
16736 g_pk_tbl (g_count).pk_id_column := 'ELIGY_CRITERIA_ID';
16737 g_pk_tbl (g_count).old_value := r_egl_unique.information1;
16738 g_pk_tbl (g_count).new_value := l_new_value;
16739 g_pk_tbl (g_count).copy_reuse_type := 'REUSED';
16740 g_pk_tbl (g_count).table_route_id := r_egl_unique.table_route_id;
16741 --
16742 -- update_cer_with_target( g_pk_tbl(g_count) , p_copy_entity_txn_id) ;
16743 --
16744 g_count := g_count + 1;
16745 --
16746 log_data ('EGL', l_new_value, l_prefix || r_egl_unique.NAME || l_suffix, 'REUSED');
16747 --
16748 END IF;
16749
16750 --
16751 l_object_found_in_target := TRUE;
16752 END IF;
16753
16754 CLOSE c_find_egl_in_target;
16755 --
16756 END IF;
16757 --
16758 END IF;
16759
16760 IF NOT l_object_found_in_target OR l_update
16761 THEN
16762 --
16763 OPEN c_egl (r_egl_unique.table_route_id,
16764 r_egl_unique.information1
16765 );
16766 --
16767 FETCH c_egl INTO r_egl;
16768 --
16769 CLOSE c_egl;
16770 --
16771 l_current_pk_id := r_egl.information1;
16772 --
16773 l_access_calc_rule := get_fk ('FORMULA_ID', r_egl.information268, l_dml_operation);
16774 --
16775 -- For 1. Lookup Value (COL1_LOOKUP_TYPE - INFORMATION15 ) and
16776 -- 2. Value Set (COL1_VALUE_SET_ID - INFORMATION266 / FLEX_VALUE_SET_NAME - INFORMATION185)
16777 -- we will try to auto map in the target business group
16778 -- If we are unable to auto map, then we will not copy corresponding EGL record
16779 -- and hence the ECV record will also not get copied (as it wont find parent EGL record)
16780 --
16781 l_map_succeed := true;
16782 l_col1_value_set_id := r_egl.information266;
16783 --
16784 if r_egl.information15 is not null
16785 then
16786 --
16787 l_map_succeed := map_lookup_in_target ( p_lookup_name => r_egl.information15,
16788 p_target_business_group_id => p_target_business_group_id );
16789 --
16790 end if;
16791 --
16792 if r_egl.information185 is not null
16793 then
16794 --
16795 l_map_succeed := map_valueset_in_target ( p_valueset_name => r_egl.information185,
16796 p_target_business_group_id => p_target_business_group_id,
16797 p_value_set_id => l_col1_value_set_id);
16798 --
16799 end if;
16800 --
16801 hr_utility.set_location (' l_current_pk_id ' || l_current_pk_id, 20);
16802 hr_utility.set_location (' l_prev_pk_id ' || l_prev_pk_id, 20);
16803 --
16804 IF l_current_pk_id = l_prev_pk_id
16805 THEN
16806 --
16807 l_first_rec := FALSE;
16808 --
16809 ELSE
16810 --
16811 l_first_rec := TRUE;
16812 --
16813 END IF;
16814 --
16815 l_effective_date := ben_pd_copy_to_ben_one.g_copy_effective_date;
16816 --
16817 ben_pd_copy_to_ben_one.ben_chk_col_len ('NAME', 'BEN_ELIGY_CRITERIA', l_prefix || r_egl.information170 || l_suffix );
16818 --
16819 IF l_map_succeed = true
16820 THEN
16821 --
16822 IF l_first_rec AND NOT l_update
16823 THEN
16824 -- Call Create routine.
16825 hr_utility.set_location ('BEN_ELIGY_CRITERIA_API.CREATE_ELIGY_CRITERIA ', 20 );
16826 --
16827 ben_eligy_criteria_api.create_eligy_criteria
16828 (
16829 p_validate => FALSE,
16830 p_eligy_criteria_id => l_eligy_criteria_id,
16831 p_name => l_prefix || r_egl.information170 || l_suffix,
16832 p_short_code => r_egl.information11,
16833 p_description => r_egl.information219,
16834 p_criteria_type => r_egl.information12,
16835 p_crit_col1_val_type_cd => r_egl.information13,
16836 p_crit_col1_datatype => r_egl.information14,
16837 p_col1_lookup_type => r_egl.information15,
16838 p_col1_value_set_id => l_col1_value_set_id,
16839 p_access_table_name1 => r_egl.information16,
16840 p_access_column_name1 => r_egl.information17,
16841 p_time_entry_access_tab_nam1 => r_egl.information18,
16842 p_time_entry_access_col_nam1 => r_egl.information19,
16843 p_crit_col2_val_type_cd => r_egl.information20,
16844 p_crit_col2_datatype => r_egl.information21,
16845 p_col2_lookup_type => r_egl.information22,
16846 p_col2_value_set_id => r_egl.information267,
16847 p_access_table_name2 => r_egl.information23,
16848 p_access_column_name2 => r_egl.information24,
16849 p_time_entry_access_tab_nam2 => r_egl.information25,
16850 p_time_entry_access_col_nam2 => r_egl.information26,
16851 p_access_calc_rule => l_access_calc_rule,
16852 p_allow_range_validation_flg => r_egl.information27,
16853 p_user_defined_flag => r_egl.information28,
16854 p_business_group_id => p_target_business_group_id,
16855 p_legislation_code => r_egl.information29,
16856 --Bug 4592554
16857 p_allow_range_validation_flag2 => r_egl.information30,
16858 p_access_calc_rule2 => r_egl.information269,
16859 p_time_access_calc_rule1 => r_egl.information270,
16860 p_time_access_calc_rule2 => r_egl.information271,
16861 --End Bug 4592554
16862 p_egl_attribute_category => r_egl.information110,
16863 p_egl_attribute1 => r_egl.information111,
16864 p_egl_attribute2 => r_egl.information112,
16865 p_egl_attribute3 => r_egl.information113,
16866 p_egl_attribute4 => r_egl.information114,
16867 p_egl_attribute5 => r_egl.information115,
16868 p_egl_attribute6 => r_egl.information116,
16869 p_egl_attribute7 => r_egl.information117,
16870 p_egl_attribute8 => r_egl.information118,
16871 p_egl_attribute9 => r_egl.information119,
16872 p_egl_attribute10 => r_egl.information120,
16873 p_egl_attribute11 => r_egl.information121,
16874 p_egl_attribute12 => r_egl.information122,
16875 p_egl_attribute13 => r_egl.information123,
16876 p_egl_attribute14 => r_egl.information124,
16877 p_egl_attribute15 => r_egl.information125,
16878 p_egl_attribute16 => r_egl.information126,
16879 p_egl_attribute17 => r_egl.information127,
16880 p_egl_attribute18 => r_egl.information128,
16881 p_egl_attribute19 => r_egl.information129,
16882 p_egl_attribute20 => r_egl.information130,
16883 p_egl_attribute21 => r_egl.information131,
16884 p_egl_attribute22 => r_egl.information132,
16885 p_egl_attribute23 => r_egl.information133,
16886 p_egl_attribute24 => r_egl.information134,
16887 p_egl_attribute25 => r_egl.information135,
16888 p_egl_attribute26 => r_egl.information136,
16889 p_egl_attribute27 => r_egl.information137,
16890 p_egl_attribute28 => r_egl.information138,
16891 p_egl_attribute29 => r_egl.information139,
16892 p_egl_attribute30 => r_egl.information140,
16893 p_object_version_number => l_object_version_number,
16894 p_effective_date => nvl(l_effective_date,p_effective_date)
16895 );
16896 --
16897 -- insert the table_name,old_pk_id,new_pk_id into a plsql record
16898 -- Update all relevent cer records with new pk_id
16899 hr_utility.set_location ('Before plsql table ', 222);
16900 hr_utility.set_location ('new_value id ' || l_eligy_criteria_id, 222);
16901 --
16902 g_pk_tbl (g_count).pk_id_column := 'ELIGY_CRITERIA_ID';
16903 g_pk_tbl (g_count).old_value := r_egl.information1;
16904 g_pk_tbl (g_count).new_value := l_eligy_criteria_id;
16905 g_pk_tbl (g_count).copy_reuse_type := 'COPIED';
16906 g_pk_tbl (g_count).table_route_id := r_egl_unique.table_route_id;
16907 --
16908 hr_utility.set_location ('After plsql table ', 222);
16909 --
16910 -- update_cer_with_target( g_pk_tbl(g_count),p_copy_entity_txn_id ) ;
16911 --
16912 g_count := g_count + 1;
16913 --
16914 log_data ('EGL', l_new_value, l_prefix || r_egl.information170 || l_suffix, 'COPIED');
16915 --
16916 ELSIF l_update
16917 THEN
16918 --
16919 -- Bug: 4372345 Fetch OVN. EGL being non-date-tracked,
16920 -- create-api will not be called before update in PDW/PDC flow.
16921 l_object_version_number := r_egl.information265;
16922 --
16923 hr_utility.set_location ('BEN_ELIGY_CRITERIA_API.UPDATE_ELIGY_CRITERIA ', 20 );
16924 --
16925 ben_eligy_criteria_api.update_eligy_criteria
16926 (
16927 p_validate => FALSE,
16928 p_eligy_criteria_id => l_eligy_criteria_id,
16929 p_name => l_prefix || r_egl.information170 || l_suffix,
16930 p_short_code => r_egl.information11,
16931 p_description => r_egl.information219,
16932 p_criteria_type => r_egl.information12,
16933 p_crit_col1_val_type_cd => r_egl.information13,
16934 p_crit_col1_datatype => r_egl.information14,
16935 p_col1_lookup_type => r_egl.information15,
16936 p_col1_value_set_id => l_col1_value_set_id,
16937 p_access_table_name1 => r_egl.information16,
16938 p_access_column_name1 => r_egl.information17,
16939 p_time_entry_access_tab_nam1 => r_egl.information18,
16940 p_time_entry_access_col_nam1 => r_egl.information19,
16941 p_crit_col2_val_type_cd => r_egl.information20,
16942 p_crit_col2_datatype => r_egl.information21,
16943 p_col2_lookup_type => r_egl.information22,
16944 p_col2_value_set_id => r_egl.information267,
16945 p_access_table_name2 => r_egl.information23,
16946 p_access_column_name2 => r_egl.information24,
16947 p_time_entry_access_tab_nam2 => r_egl.information25,
16948 p_time_entry_access_col_nam2 => r_egl.information26,
16949 p_access_calc_rule => l_access_calc_rule,
16950 p_allow_range_validation_flg => r_egl.information27,
16951 p_user_defined_flag => r_egl.information28,
16952 p_business_group_id => p_target_business_group_id,
16953 p_legislation_code => r_egl.information29,
16954 --Bug 4592554
16955 p_allow_range_validation_flag2 => r_egl.information30,
16956 p_access_calc_rule2 => r_egl.information269,
16957 p_time_access_calc_rule1 => r_egl.information270,
16958 p_time_access_calc_rule2 => r_egl.information271,
16959 --End Bug 4592554
16960 p_egl_attribute_category => r_egl.information110,
16961 p_egl_attribute1 => r_egl.information111,
16962 p_egl_attribute2 => r_egl.information112,
16963 p_egl_attribute3 => r_egl.information113,
16964 p_egl_attribute4 => r_egl.information114,
16965 p_egl_attribute5 => r_egl.information115,
16966 p_egl_attribute6 => r_egl.information116,
16967 p_egl_attribute7 => r_egl.information117,
16968 p_egl_attribute8 => r_egl.information118,
16969 p_egl_attribute9 => r_egl.information119,
16970 p_egl_attribute10 => r_egl.information120,
16971 p_egl_attribute11 => r_egl.information121,
16972 p_egl_attribute12 => r_egl.information122,
16973 p_egl_attribute13 => r_egl.information123,
16974 p_egl_attribute14 => r_egl.information124,
16975 p_egl_attribute15 => r_egl.information125,
16976 p_egl_attribute16 => r_egl.information126,
16977 p_egl_attribute17 => r_egl.information127,
16978 p_egl_attribute18 => r_egl.information128,
16979 p_egl_attribute19 => r_egl.information129,
16980 p_egl_attribute20 => r_egl.information130,
16981 p_egl_attribute21 => r_egl.information131,
16982 p_egl_attribute22 => r_egl.information132,
16983 p_egl_attribute23 => r_egl.information133,
16984 p_egl_attribute24 => r_egl.information134,
16985 p_egl_attribute25 => r_egl.information135,
16986 p_egl_attribute26 => r_egl.information136,
16987 p_egl_attribute27 => r_egl.information137,
16988 p_egl_attribute28 => r_egl.information138,
16989 p_egl_attribute29 => r_egl.information139,
16990 p_egl_attribute30 => r_egl.information140,
16991 p_object_version_number => l_object_version_number,
16992 p_effective_date => nvl(l_effective_date,p_effective_date)
16993 );
16994 --
16995 END IF;
16996 --
16997 END IF; /* l_map_succeed = true */
16998 --
16999 l_prev_pk_id := l_current_pk_id;
17000 --
17001 END IF;
17002 --
17003 -- END IF; /* l_target_type = 'BEN_PDSMBG' */
17004 --
17005 END LOOP;
17006 --
17007 EXCEPTION
17008 WHEN OTHERS
17009 THEN
17010 --
17011 raise_error_message ('EGL', l_prefix || r_egl.information170 || l_suffix );
17012 --
17013 --
17014 END create_egl_rows;
17015 --
17016
17017 procedure create_all_leaf_ben_rows
17018 (
17019 p_validate in number default 0 -- false
17020 ,p_copy_entity_txn_id in number
17021 ,p_effective_date in date
17022 ,p_prefix_suffix_text in varchar2 default null
17023 ,p_reuse_object_flag in varchar2 default null
17024 ,p_target_business_group_id in varchar2 default null
17025 ,p_prefix_suffix_cd in varchar2 default null
17026 ,p_txn_row_type_cd in varchar2 default null
17027 ) is
17028 -- REUSE
17029 cursor c_source_business_group is
17030 select information30, context_business_group_id
17031 from ben_copy_entity_txns_vw
17032 where copy_entity_txn_id = p_copy_entity_txn_id;
17033 --
17034 l_prefix_suffix_text varchar2(300) := p_prefix_suffix_text;
17035 l_source_business_group per_business_groups.name%type;
17036 l_source_business_group_id number (15);
17037
17038 --TCS PDW Integration Enhancement
17039 l_txn_row_type_cd varchar2(15);
17040 --TCS PDW Integration Enhancement
17041 --
17042 begin
17043
17044 --TCS PDW Integration Enhancement
17045 l_txn_row_type_cd := nvl(p_txn_row_type_cd,'~');
17046 --TCS PDW Integration Enhancement
17047
17048
17049 --TCS PDW Integration Enhancement
17050 --By passed calls to certains procedures in the below flow
17051 --if the l_txn_row_type_cd is ELP
17052 --
17053 open c_source_business_group;
17054 fetch c_source_business_group into l_source_business_group, l_source_business_group_id;
17055 close c_source_business_group;
17056 --
17057
17058 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('FFF') then
17059 BEN_PD_COPY_TO_BEN_ONE.create_fff_rows(
17060 p_validate => p_validate
17061 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17062 ,p_effective_date => p_effective_date
17063 ,p_prefix_suffix_text => p_prefix_suffix_text
17064 ,p_reuse_object_flag => p_reuse_object_flag
17065 ,p_target_business_group_id => p_target_business_group_id
17066 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17067 );
17068 end if;
17069 --
17070 -- Action Types always to be Reused
17071 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EAT'))then
17072 BEN_PD_COPY_TO_BEN_ONE.create_EAT_rows(
17073 p_validate => p_validate
17074 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17075 ,p_effective_date => p_effective_date
17076 ,p_prefix_suffix_text => p_prefix_suffix_text
17077 ,p_reuse_object_flag => p_reuse_object_flag
17078 ,p_target_business_group_id => p_target_business_group_id
17079 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17080 );
17081 end if;
17082 --
17083 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('SVA') then
17084 BEN_PD_COPY_TO_BEN_ONE.create_SVA_rows(
17085 p_validate => p_validate
17086 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17087 ,p_effective_date => p_effective_date
17088 ,p_prefix_suffix_text => p_prefix_suffix_text
17089 ,p_reuse_object_flag => p_reuse_object_flag
17090 ,p_target_business_group_id => p_target_business_group_id
17091 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17092 );
17093 end if;
17094 --
17095 --TCS PDW Enhancement , creation of Benefits Balances is supported
17096 if (BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('BNB'))then
17097 BEN_PD_COPY_TO_BEN_ONE.create_bnb_rows(
17098 p_validate => p_validate
17099 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17100 ,p_effective_date => p_effective_date
17101 ,p_prefix_suffix_text => p_prefix_suffix_text
17102 ,p_reuse_object_flag => p_reuse_object_flag
17103 ,p_target_business_group_id => p_target_business_group_id
17104 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17105 );
17106 end if;
17107 --
17108 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CLF') then
17109 BEN_PD_COPY_TO_BEN_ONE.create_CLF_rows(
17110 p_validate => p_validate
17111 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17112 ,p_effective_date => p_effective_date
17113 ,p_prefix_suffix_text => p_prefix_suffix_text
17114 ,p_reuse_object_flag => p_reuse_object_flag
17115 ,p_target_business_group_id => p_target_business_group_id
17116 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17117 );
17118 end if;
17119 --
17120 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('HWF') then
17121 BEN_PD_COPY_TO_BEN_ONE.create_HWF_rows(
17122 p_validate => p_validate
17123 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17124 ,p_effective_date => p_effective_date
17125 ,p_prefix_suffix_text => p_prefix_suffix_text
17126 ,p_reuse_object_flag => p_reuse_object_flag
17127 ,p_target_business_group_id => p_target_business_group_id
17128 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17129 );
17130 end if;
17131 --
17132 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('AGF') then
17133 BEN_PD_COPY_TO_BEN_ONE.create_AGF_rows(
17134 p_validate => p_validate
17135 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17136 ,p_effective_date => p_effective_date
17137 ,p_prefix_suffix_text => p_prefix_suffix_text
17138 ,p_reuse_object_flag => p_reuse_object_flag
17139 ,p_target_business_group_id => p_target_business_group_id
17140 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17141 );
17142 end if;
17143 --
17144 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LSF') then
17145 BEN_PD_COPY_TO_BEN_ONE.create_LSF_rows(
17146 p_validate => p_validate
17147 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17148 ,p_effective_date => p_effective_date
17149 ,p_prefix_suffix_text => p_prefix_suffix_text
17150 ,p_reuse_object_flag => p_reuse_object_flag
17151 ,p_target_business_group_id => p_target_business_group_id
17152 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17153 );
17154 end if;
17155 --
17156 --
17157 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PFF') then
17158 BEN_PD_COPY_TO_BEN_ONE.create_PFF_rows(
17159 p_validate => p_validate
17160 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17161 ,p_effective_date => p_effective_date
17162 ,p_prefix_suffix_text => p_prefix_suffix_text
17163 ,p_reuse_object_flag => p_reuse_object_flag
17164 ,p_target_business_group_id => p_target_business_group_id
17165 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17166 );
17167 end if;
17168 --
17169 --
17170 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CLA') then
17171 BEN_PD_COPY_TO_BEN_ONE.create_CLA_rows(
17172 p_validate => p_validate
17173 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17174 ,p_effective_date => p_effective_date
17175 ,p_prefix_suffix_text => p_prefix_suffix_text
17176 ,p_reuse_object_flag => p_reuse_object_flag
17177 ,p_target_business_group_id => p_target_business_group_id
17178 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17179 );
17180 end if;
17181 --
17182 --
17183 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PTP') )then
17184 BEN_PD_COPY_TO_BEN_ONE.create_PTP_rows(
17185 p_validate => p_validate
17186 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17187 ,p_effective_date => p_effective_date
17188 ,p_prefix_suffix_text => p_prefix_suffix_text
17189 ,p_reuse_object_flag => p_reuse_object_flag
17190 ,p_target_business_group_id => p_target_business_group_id
17191 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17192 );
17193 end if;
17194 --
17195 --
17196 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PLN'))then
17197 BEN_PD_COPY_TO_BEN_ONE.create_PLN_rows(
17198 p_validate => p_validate
17199 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17200 ,p_effective_date => p_effective_date
17201 ,p_prefix_suffix_text => p_prefix_suffix_text
17202 ,p_reuse_object_flag => p_reuse_object_flag
17203 ,p_target_business_group_id => p_target_business_group_id
17204 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17205 );
17206 end if;
17207 --
17208 --
17209 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('BNR'))then
17210 BEN_PD_COPY_TO_BEN_ONE.create_BNR_rows(
17211 p_validate => p_validate
17212 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17213 ,p_effective_date => p_effective_date
17214 ,p_prefix_suffix_text => p_prefix_suffix_text
17215 ,p_reuse_object_flag => p_reuse_object_flag
17216 ,p_target_business_group_id => p_target_business_group_id
17217 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17218 );
17219 end if;
17220 --
17221
17222 -- Regulations always to be Reused
17223 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('REG'))then
17224 BEN_PD_COPY_TO_BEN_ONE.create_REG_rows(
17225 p_validate => p_validate
17226 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17227 ,p_effective_date => p_effective_date
17228 ,p_prefix_suffix_text => p_prefix_suffix_text
17229 ,p_reuse_object_flag => p_reuse_object_flag
17230 ,p_target_business_group_id => p_target_business_group_id
17231 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17232 );
17233 end if;
17234 --
17235 --
17236 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('OPT'))then
17237 BEN_PD_COPY_TO_BEN_ONE.create_OPT_rows(
17238 p_validate => p_validate
17239 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17240 ,p_effective_date => p_effective_date
17241 ,p_prefix_suffix_text => p_prefix_suffix_text
17242 ,p_reuse_object_flag => p_reuse_object_flag
17243 ,p_target_business_group_id => p_target_business_group_id
17244 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17245 );
17246 end if;
17247 --
17248 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PON'))then
17249 BEN_PD_COPY_TO_BEN_ONE.create_PON_rows(
17250 p_validate => p_validate
17251 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17252 ,p_effective_date => p_effective_date
17253 ,p_prefix_suffix_text => p_prefix_suffix_text
17254 ,p_reuse_object_flag => p_reuse_object_flag
17255 ,p_target_business_group_id => p_target_business_group_id
17256 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17257 );
17258 end if;
17259 --
17260 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('RZR') then
17261 BEN_PD_COPY_TO_BEN_ONE.create_RZR_rows(
17262 p_validate => p_validate
17263 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17264 ,p_effective_date => p_effective_date
17265 ,p_prefix_suffix_text => p_prefix_suffix_text
17266 ,p_reuse_object_flag => p_reuse_object_flag
17267 ,p_target_business_group_id => p_target_business_group_id
17268 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17269 );
17270 end if;
17271 --
17272 /* NOTIMPLEMENTED
17273 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('RCL') then
17274 BEN_PD_COPY_TO_BEN_ONE.create_RCL_rows(
17275 p_validate => p_validate
17276 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17277 ,p_effective_date => p_effective_date
17278 ,p_prefix_suffix_text => p_prefix_suffix_text
17279 ,p_reuse_object_flag => p_reuse_object_flag
17280 ,p_target_business_group_id => p_target_business_group_id
17281 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17282 );
17283 end if;
17284 */
17285 --
17286 -- REUSE ENHANCEMENT
17287 --
17288 l_prefix_suffix_text := p_prefix_suffix_text;
17289 -- REUSE
17290 if ben_PLAN_DESIGN_TXNS_api.g_pgm_pl_prefix_suffix_text is not null then
17291 --
17292 l_prefix_suffix_text := ben_PLAN_DESIGN_TXNS_api.g_pgm_pl_prefix_suffix_text;
17293 --
17294 end if;
17295 --
17296 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PGM'))then
17297 BEN_PD_COPY_TO_BEN_ONE.create_PGM_rows(
17298 p_validate => p_validate
17299 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17300 ,p_effective_date => p_effective_date
17301 ,p_prefix_suffix_text => l_prefix_suffix_text
17302 ,p_reuse_object_flag => p_reuse_object_flag
17303 ,p_target_business_group_id => p_target_business_group_id
17304 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17305 );
17306 end if;
17307 --
17308 -- Moved these three calls from benpdccp5.pkb
17309 --
17310 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CPL'))then
17311 BEN_PD_COPY_TO_BEN_ONE.create_CPL_rows
17312 (p_validate => p_validate
17313 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17314 ,p_effective_date => p_effective_date
17315 ,p_prefix_suffix_text => p_prefix_suffix_text
17316 ,p_reuse_object_flag => p_reuse_object_flag
17317 ,p_target_business_group_id => p_target_business_group_id
17318 ,p_prefix_suffix_cd => p_prefix_suffix_cd);
17319 end if;
17320 --
17321 --
17322 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CBP'))then
17323 BEN_PD_COPY_TO_BEN_ONE.create_CBP_rows
17324 (p_validate => p_validate
17325 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17326 ,p_effective_date => p_effective_date
17327 ,p_prefix_suffix_text => p_prefix_suffix_text
17328 ,p_reuse_object_flag => p_reuse_object_flag
17329 ,p_target_business_group_id => p_target_business_group_id
17330 ,p_prefix_suffix_cd => p_prefix_suffix_cd);
17331 end if;
17332 --
17333 --
17334 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CPT'))then
17335 BEN_PD_COPY_TO_BEN_ONE.create_CPT_rows
17336 (p_validate => p_validate
17337 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17338 ,p_effective_date => p_effective_date
17339 ,p_prefix_suffix_text => p_prefix_suffix_text
17340 ,p_reuse_object_flag => p_reuse_object_flag
17341 ,p_target_business_group_id => p_target_business_group_id
17342 ,p_prefix_suffix_cd => p_prefix_suffix_cd);
17343 end if;
17344 --
17345 --
17346 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LER'))then
17347 BEN_PD_COPY_TO_BEN_ONE.create_LER_rows(
17348 p_validate => p_validate
17349 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17350 ,p_effective_date => p_effective_date
17351 ,p_prefix_suffix_text => p_prefix_suffix_text
17352 ,p_reuse_object_flag => p_reuse_object_flag
17353 ,p_target_business_group_id => p_target_business_group_id
17354 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17355 );
17356 end if;
17357 --
17358 -- TCS PDW Enhancement Opened the call to create_ELP_rows
17359 if (BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('ELP'))then
17360 BEN_PD_COPY_TO_BEN_ONE.create_ELP_rows(
17361 p_validate => p_validate
17362 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17363 ,p_effective_date => p_effective_date
17364 ,p_prefix_suffix_text => p_prefix_suffix_text
17365 ,p_reuse_object_flag => p_reuse_object_flag
17366 ,p_target_business_group_id => p_target_business_group_id
17367 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17368 );
17369 end if;
17370 -- TCS PDW Enhancement Opened the call to create_ELP_rows
17371 --
17372 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('DCE'))then
17373 BEN_PD_COPY_TO_BEN_ONE.create_DCE_rows(
17374 p_validate => p_validate
17375 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17376 ,p_effective_date => p_effective_date
17377 ,p_prefix_suffix_text => p_prefix_suffix_text
17378 ,p_reuse_object_flag => p_reuse_object_flag
17379 ,p_target_business_group_id => p_target_business_group_id
17380 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17381 );
17382 end if;
17383 --
17384 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('GOS'))then
17385 BEN_PD_COPY_TO_BEN_ONE.create_GOS_rows(
17386 p_validate => p_validate
17387 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17388 ,p_effective_date => p_effective_date
17389 ,p_prefix_suffix_text => p_prefix_suffix_text
17390 ,p_reuse_object_flag => p_reuse_object_flag
17391 ,p_target_business_group_id => p_target_business_group_id
17392 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17393 );
17394 end if;
17395 --
17396 --Bug 5127683 Call the below procedure irrespective of the l_txn_row_type_cd
17397 if (BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('BNG'))then
17398 BEN_PD_COPY_TO_BEN_ONE.create_BNG_rows(
17399 p_validate => p_validate
17400 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17401 ,p_effective_date => p_effective_date
17402 ,p_prefix_suffix_text => p_prefix_suffix_text
17403 ,p_reuse_object_flag => p_reuse_object_flag
17404 ,p_target_business_group_id => p_target_business_group_id
17405 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17406 );
17407 end if;
17408 --
17409
17410 --Uncommented to copy the seeded plan design for Absences, plan design wizard
17411 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PSL')
17412 and (l_source_business_group is null or
17413 BEN_PD_COPY_TO_BEN_ONE.g_transaction_category = 'BEN_PDCRWZ')
17414 ) then
17415 --hr_utility.set_location(' BEN_PD_COPY_TO_BEN_ONE.create_PSL_rows !!!!!!!!! ',10);
17416
17417 BEN_PD_COPY_TO_BEN_ONE.create_PSL_rows(
17418 p_validate => p_validate
17419 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17420 ,p_effective_date => p_effective_date
17421 ,p_prefix_suffix_text => p_prefix_suffix_text
17422 ,p_reuse_object_flag => p_reuse_object_flag
17423 ,p_target_business_group_id => p_target_business_group_id
17424 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17425 );
17426 end if;
17427
17428 --Uncommented to copy the seeded plan design for Absences, plan design wizard
17429 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('LPL')
17430 and (BEN_PD_COPY_TO_BEN_ONE.g_transaction_category = 'BEN_PDCRWZ'))
17431 then
17432 --hr_utility.set_location(' BEN_PD_COPY_TO_BEN_ONE.create_LPL_rows!!!!!!!!!!!! ',10);
17433
17434 BEN_PD_COPY_TO_BEN_ONE.create_LPL_rows(
17435 p_validate => p_validate
17436 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17437 ,p_effective_date => p_effective_date
17438 ,p_prefix_suffix_text => p_prefix_suffix_text
17439 ,p_reuse_object_flag => p_reuse_object_flag
17440 ,p_target_business_group_id => p_target_business_group_id
17441 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17442 );
17443 end if;
17444
17445 --
17446 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('CCT'))then
17447 BEN_PD_COPY_TO_BEN_ONE.create_CCT_rows(
17448 p_validate => p_validate
17449 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17450 ,p_effective_date => p_effective_date
17451 ,p_prefix_suffix_text => p_prefix_suffix_text
17452 ,p_reuse_object_flag => p_reuse_object_flag
17453 ,p_target_business_group_id => p_target_business_group_id
17454 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17455 );
17456 end if;
17457 --
17458 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('PDL'))then
17459 BEN_PD_COPY_TO_BEN_ONE.create_PDL_rows(
17460 p_validate => p_validate
17461 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17462 ,p_effective_date => p_effective_date
17463 ,p_prefix_suffix_text => p_prefix_suffix_text
17464 ,p_reuse_object_flag => p_reuse_object_flag
17465 ,p_target_business_group_id => p_target_business_group_id
17466 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17467 );
17468 end if;
17469 --
17470 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('YRP'))then
17471 BEN_PD_COPY_TO_BEN_ONE.create_YRP_rows(
17472 p_validate => p_validate
17473 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17474 ,p_effective_date => p_effective_date
17475 ,p_prefix_suffix_text => p_prefix_suffix_text
17476 ,p_reuse_object_flag => p_reuse_object_flag
17477 ,p_target_business_group_id => p_target_business_group_id
17478 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17479 );
17480 end if;
17481 --
17482 if ((l_txn_row_type_cd <> 'ELP') and BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('WYP'))then
17483 BEN_PD_COPY_TO_BEN_ONE.create_WYP_rows(
17484 p_validate => p_validate
17485 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17486 ,p_effective_date => p_effective_date
17487 ,p_prefix_suffix_text => p_prefix_suffix_text
17488 ,p_reuse_object_flag => p_reuse_object_flag
17489 ,p_target_business_group_id => p_target_business_group_id
17490 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17491 );
17492 end if;
17493 --
17494 --
17495 -- Bug 4169120 : Rate By Criteria
17496 --
17497 if BEN_PD_COPY_TO_BEN_ONE.data_exists_for_table('EGL')
17498 then
17499 --
17500 BEN_PD_COPY_TO_BEN_ONE.create_EGL_rows
17501 (
17502 p_validate => p_validate
17503 ,p_copy_entity_txn_id => p_copy_entity_txn_id
17504 ,p_effective_date => p_effective_date
17505 ,p_prefix_suffix_text => p_prefix_suffix_text
17506 ,p_reuse_object_flag => p_reuse_object_flag
17507 ,p_target_business_group_id => p_target_business_group_id
17508 ,p_prefix_suffix_cd => p_prefix_suffix_cd
17509 );
17510 --
17511 end if;
17512 --
17513 end create_all_leaf_ben_rows;
17514 --
17515 end BEN_PD_COPY_TO_BEN_ONE;
17516