1 PACKAGE BODY PQP_NL_PENSION_EXTRACTS AS
2 /* $Header: pqpnlpext.pkb 120.140.12020000.2 2012/07/05 12:16:28 amnaraya ship $ */
3
4 g_proc_name VARCHAR2(200) :='PQP_NL_Pension_Extracts.';
5 g_debug BOOLEAN := hr_utility.debug_enabled;
6
7 -- =============================================================================
8 -- Cursor to get the extract record id's for extract definition id
9 -- =============================================================================
10 CURSOR csr_ext_rcd_id_with_seq IS
11 SELECT Decode(rin.seq_num,1,'00',
12 2,'01',
13 3,'02',
14 4,'04',
15 5,'05',
16 7,'08',
17 8,'09',
18 10,'12',
19 12,'20',
20 14,'21',
21 16,'22',
22 17,'30',
23 19,'31',
24 21,'40',
25 23,'41',
26 26,'94',
27 27,'95',
28 28,'96',
29 29,'97',
30 30,'99',
31 '~') rec_num,
32 rin.seq_num,
33 rin.hide_flag,
34 rcd.ext_rcd_id,
35 rcd.rcd_type_cd
36 FROM ben_ext_rcd rcd
37 ,ben_ext_rcd_in_file rin
38 ,ben_ext_dfn dfn
39 WHERE dfn.ext_dfn_id = Ben_Ext_Thread.g_ext_dfn_id
40 AND rin.ext_file_id = dfn.ext_file_id
41 AND rin.ext_rcd_id = rcd.ext_rcd_id
42 ORDER BY rin.seq_num;
43
44 -- =============================================================================
45 -- Cursor to get the extract record id's for record sequence number
46 -- =============================================================================
47 CURSOR c_get_rcd_id(c_seq IN Number) IS
48 SELECT rcd.ext_rcd_id
49 FROM ben_ext_rcd rcd
50 ,ben_ext_rcd_in_file rin
51 ,ben_ext_dfn dfn
52 WHERE dfn.ext_dfn_id = Ben_Ext_Thread.g_ext_dfn_id -- The extract executing currently
53 AND rin.ext_file_id = dfn.ext_file_id
54 AND rin.ext_rcd_id = rcd.ext_rcd_id
55 AND rin.seq_num = c_seq;
56
57
58 -- =============================================================================
59 -- Cursor to get assignment details
60 -- =============================================================================
61 CURSOR csr_assig (c_assignment_id IN Number
62 ,c_effective_date IN Date
63 ,c_business_group_id IN Number) IS
64 SELECT paf.person_id
65 ,paf.organization_id
66 ,paf.assignment_type
67 ,paf.effective_start_date
68 ,paf.effective_end_date
69 ,ast.user_status
70 ,Hr_General.decode_lookup
71 ('EMP_CAT',
72 paf.employment_category) employment_category
73 ,pps.date_start
74 ,pps.actual_termination_date
75 ,paf.payroll_id
76 ,'ER'
77 ,per.employee_number
78 ,paf.assignment_sequence
79 ,per.national_identifier
80 ,per.last_name
81 ,per.per_information1
82 ,per.pre_name_adjunct
83 ,per.sex
84 ,per.date_of_birth
85 ,'PLN'
86 ,'PIX'
87 ,per.per_information14
88 ,per.marital_status
89 ,paf.primary_flag
90 FROM per_all_assignments_f paf,
91 per_all_people_f per,
92 per_periods_of_service pps,
93 per_assignment_status_types ast
94 WHERE paf.assignment_id = c_assignment_id
95 AND paf.person_id = per.person_id
96 AND pps.period_of_service_id(+) = paf.period_of_service_id
97 AND ast.assignment_status_type_id = paf.assignment_status_type_id
98 AND c_effective_date BETWEEN paf.effective_start_date
99 AND paf.effective_end_date
100 AND c_effective_date BETWEEN per.effective_start_date
101 AND per.effective_end_date
102 AND paf.business_group_id = c_business_group_id
103 AND per.business_group_id = c_business_group_id;
104
105 -- =============================================================================
106 -- Cursor to get secondary asgs
107 -- =============================================================================
108 CURSOR csr_sec_assig (c_assignment_id IN Number
109 ,c_effective_date IN Date
110 ,c_business_group_id IN Number
111 ,c_person_id IN Number) IS
112 SELECT paf.organization_id
113 ,paf.payroll_id
114 FROM per_all_assignments_f paf,
115 per_all_people_f per
116 WHERE paf.assignment_id <> c_assignment_id
117 AND paf.person_id = c_person_id
118 AND paf.person_id = per.person_id
119 AND c_effective_date BETWEEN paf.effective_start_date
120 AND paf.effective_end_date
121 AND c_effective_date BETWEEN per.effective_start_date
122 AND per.effective_end_date
123 AND paf.business_group_id = c_business_group_id
124 AND per.business_group_id = c_business_group_id;
125
126 -- =============================================================================
127 -- Cursor to get the defined balance id for a given balance and dimension
128 -- =============================================================================
129 CURSOR csr_defined_bal (c_balance_name IN Varchar2
130 ,c_dimension_name IN Varchar2
131 ,c_business_group_id IN Number) IS
132 SELECT db.defined_balance_id
133 FROM pay_balance_types pbt
134 ,pay_defined_balances db
135 ,pay_balance_dimensions bd
136 WHERE pbt.balance_name = c_balance_name
137 AND pbt.balance_type_id = db.balance_type_id
138 AND bd.balance_dimension_id = db.balance_dimension_id
139 AND bd.dimension_name = c_dimension_name
140 AND (pbt.business_group_id = c_business_group_id OR
141 pbt.legislation_code = g_legislation_code)
142 AND (db.business_group_id = pbt.business_group_id OR
143 db.legislation_code = g_legislation_code);
144
145 -- =============================================================================
146 -- Cursor to get the defined balance id for a given balance and dimension
147 -- =============================================================================
148 CURSOR csr_defined_bal1 (c_balance_type_id IN Number
149 ,c_dimension_name IN Varchar2
150 ,c_business_group_id IN Number) IS
151 SELECT db.defined_balance_id
152 FROM pay_defined_balances db
153 ,pay_balance_dimensions bd
154 WHERE db.balance_type_id = c_balance_type_id
155 AND bd.balance_dimension_id = db.balance_dimension_id
156 AND bd.dimension_name = c_dimension_name
157 AND (db.business_group_id = c_business_group_id OR
158 db.legislation_code = g_legislation_code);
159
160 -- =============================================================================
161 -- Cursor to get the ASG_RUN defined balance id for a given balance name
162 -- =============================================================================
163 CURSOR csr_asg_balid (c_balance_type_id IN Number
164 ,c_balance_dimension_id IN Number
165 ,c_business_group_id IN Number) IS
166 SELECT db.defined_balance_id
167 FROM pay_defined_balances db
168 WHERE db.balance_type_id = c_balance_type_id
169 AND db.balance_dimension_id = c_balance_dimension_id
170 AND (db.business_group_id = c_business_group_id OR
171 db.legislation_code = g_legislation_code);
172
173 -- =============================================================================
174 -- Cursor to get all assig.actions for a given assig. within a date range
175 -- =============================================================================
176 CURSOR csr_asg_act (c_assignment_id IN Number
177 ,c_payroll_id IN Number
178 ,c_con_set_id IN Number
179 ,c_start_date IN Date
180 ,c_end_date IN Date
181 ) IS
182 SELECT paa.assignment_action_id
183 ,ppa.effective_date
184 ,ppa.action_type
185 ,ppa.date_earned
186 FROM pay_assignment_actions paa
187 ,pay_payroll_actions ppa
188 WHERE paa.assignment_id = c_assignment_id
189 AND ppa.action_status = 'C'
190 AND paa.action_status = 'C'
191 AND ppa.action_type IN ('Q','R')
192 AND paa.payroll_action_id = ppa.payroll_action_id
193 AND ppa.payroll_id = Nvl(c_payroll_id,ppa.payroll_id)
194 AND ppa.consolidation_set_id = Nvl(c_con_set_id,ppa.consolidation_set_id)
195 AND ppa.effective_date BETWEEN c_start_date
196 AND c_end_date
197 AND source_action_id IS NOT NULL
198 ORDER BY ppa.effective_date;
199
200 l_asg_act csr_asg_act%ROWTYPE;
201
202 -- =============================================================================
203 -- Cursor to get all assig.actions for a given assig. within a data range
204 -- =============================================================================
205 CURSOR csr_asg_act1 (c_assignment_id IN Number
206 ,c_payroll_id IN Number
207 ,c_con_set_id IN Number
208 ,c_start_date IN Date
209 ,c_end_date IN Date
210 ) IS
211 SELECT max(paa.assignment_action_id)
212 FROM pay_assignment_actions paa
213 ,pay_payroll_actions ppa
214 WHERE paa.assignment_id = c_assignment_id
215 AND ppa.action_status = 'C'
216 AND ppa.action_type IN ('Q','R')
217 AND paa.action_status = 'C'
218 AND paa.payroll_action_id = ppa.payroll_action_id
219 AND ppa.payroll_id = Nvl(c_payroll_id,ppa.payroll_id)
220 AND ppa.consolidation_set_id = Nvl(c_con_set_id,ppa.consolidation_set_id)
221 AND source_action_id IS NOT NULL
222 AND ppa.effective_date BETWEEN c_start_date
223 AND c_end_date;
224
225 -- =============================================================================
226 -- Cursor to get all assig.actions for a given assig. within a data range
227 -- =============================================================================
228 CURSOR csr_asg_act_de (c_assignment_id IN Number
229 ,c_start_de IN Date
230 ,c_end_de IN Date
231 ,c_bg_id IN NUMBER
232
233 ) IS
234 SELECT max(paa.assignment_action_id)
235 FROM pay_assignment_actions paa
236 ,pay_payroll_actions ppa
237 WHERE paa.assignment_id = c_assignment_id
238 AND ppa.action_status = 'C'
239 AND ppa.action_type IN ('Q','R')
240 AND paa.action_status = 'C'
241 AND paa.payroll_action_id = ppa.payroll_action_id
242 AND source_action_id IS NOT NULL
243 AND ppa.date_earned BETWEEN c_start_de
244 AND c_end_de
245 AND ppa.effective_date BETWEEN g_extract_params(c_bg_id).extract_start_date
246 AND g_extract_params(c_bg_id).extract_end_date;
247
248 -- =============================================================================
249 -- Cursor to get the extract record id
250 -- =============================================================================
251 CURSOR csr_ext_rcd_id(c_hide_flag IN Varchar2
252 ,c_rcd_type_cd IN Varchar2
253 ) IS
254 SELECT rcd.ext_rcd_id
255 FROM ben_ext_rcd rcd
256 ,ben_ext_rcd_in_file rin
257 ,ben_ext_dfn dfn
258 WHERE dfn.ext_dfn_id = Ben_Ext_Thread.g_ext_dfn_id -- The extract
259 AND rin.ext_file_id = dfn.ext_file_id
260 AND rin.hide_flag = c_hide_flag -- Y=Hidden, N=Not Hidden
261 AND rin.ext_rcd_id = rcd.ext_rcd_id
262 AND rcd.rcd_type_cd = c_rcd_type_cd; -- D=Detail,H=Header,F=Footer
263
264 -- =============================================================================
265 -- Cursor to get the extract record id for hidden and Not hidden records
266 -- =============================================================================
267 CURSOR csr_ext_rcd_id_hidden(c_rcd_type_cd IN Varchar2) IS
268 SELECT rcd.ext_rcd_id
269 FROM ben_ext_rcd rcd
270 ,ben_ext_rcd_in_file rin
271 ,ben_ext_dfn dfn
272 WHERE dfn.ext_dfn_id = Ben_Ext_Thread.g_ext_dfn_id
273 AND rin.ext_file_id = dfn.ext_file_id
274 AND rin.ext_rcd_id = rcd.ext_rcd_id
275 AND rcd.rcd_type_cd = c_rcd_type_cd
276 ORDER BY rin.seq_num;
277
278
279 -- =============================================================================
280 -- Cursor to get the extract result dtl record for a person id
281 -- =============================================================================
282 CURSOR csr_rslt_dtl(c_person_id IN Number
283 ,c_ext_rslt_id IN Number
284 ,c_ext_dtl_rcd_id IN Number ) IS
285 SELECT *
286 FROM ben_ext_rslt_dtl dtl
287 WHERE dtl.ext_rslt_id = c_ext_rslt_id
288 AND dtl.person_id = c_person_id
289 AND dtl.ext_rcd_id = c_ext_dtl_rcd_id;
290
291 -- =============================================================================
292 -- Cursor to get the balance type id for a given name
293 -- =============================================================================
294 CURSOR csr_bal_typid (c_balance_name IN Varchar2
295 ,c_business_group_id IN Number
296 ,c_legislation_code IN Varchar2) IS
297 SELECT pbt.balance_type_id
298 FROM pay_balance_types pbt
299 WHERE pbt.balance_name = c_balance_name
300 AND (pbt.business_group_id = c_business_group_id
301 OR
302 pbt.legislation_code = c_legislation_code);
303
304 -- ============================================================================
305 -- Cursor to get the Organization name
306 -- ============================================================================
307 CURSOR csr_org_name (c_org_id IN Number)IS
308 SELECT NAME
309 FROM hr_all_organization_units
310 WHERE organization_id = c_org_id;
311
312 -- =============================================================================
313 -- Cursor to chk for other primary assig. within the extract date range.
314 -- =============================================================================
315 CURSOR csr_sec_assg
316 (c_primary_assignment_id IN per_all_assignments_f.assignment_id%TYPE
317 ,c_person_id IN per_all_people_f.person_id%TYPE
318 ,c_effective_date IN Date
319 ,c_extract_start_date IN Date
320 ,c_extract_end_date IN Date ) IS
321 SELECT asg.person_id
322 ,asg.organization_id
323 ,asg.assignment_type
324 ,asg.effective_start_date
325 ,asg.effective_end_date
326 ,'NO'
327 ,asg.assignment_id
328 FROM per_all_assignments_f asg
329 WHERE asg.person_id = c_person_id
330 AND asg.assignment_id <> c_primary_assignment_id
331 AND asg.assignment_type ='E'
332 AND (( c_effective_date BETWEEN asg.effective_start_date
333 AND asg.effective_end_date
334 )
335 OR
336 ( asg.effective_end_date =
337 (SELECT Max(asx.effective_end_date)
338 FROM per_all_assignments_f asx
339 WHERE asx.assignment_id = asg.assignment_id
340 AND asx.person_id = c_person_id
341 AND asx.assignment_type = 'E'
342 AND ((asx.effective_end_date BETWEEN c_extract_start_date
343 AND c_extract_end_date)
344 OR
345 (asx.effective_start_date BETWEEN c_extract_start_date
346 AND c_extract_end_date)
347 )
348 )
349 )
350 )
351 ORDER BY asg.effective_start_date ASC;
352
353 -- ============================================================================
354 -- Cursor to get the valid element_type_id for record 09 (at BG Level)
355 -- ============================================================================
356 CURSOR c_rec_09_ele( c_bg_id IN Number
357 ,c_effective_date IN Date) IS
358 SELECT pet.element_type_id
359 ,pei.eei_information9||' Employee Pension Basis' bal_name
360 ,pei.eei_information12 sub_cat
361 ,Decode (pei.eei_information12,'AAOP','AP','IPBW_H','IH','IPBW_L','IL'
362 ,'FPB','FB','FPU_C','FO','OP') code
363 ,-1 defined_bal_id
364 ,pei.eei_information18 cy_retro_element_id
365 ,pei.eei_information19 py_retro_element_id
366 ,(SELECT retro_element_type_id
367 FROM pay_element_span_usages pesu,
368 pay_retro_component_usages prcu
369 WHERE prcu.retro_component_usage_id = pesu.retro_component_usage_id
370 AND retro_component_id = ( SELECT retro_component_id
371 FROM pay_retro_components
372 WHERE legislation_code = 'NL'
373 AND short_name = 'Adjustment'
374 AND component_name = 'Adjustment')
375 AND creator_type = 'ET'
376 AND creator_id = pet.element_type_id) py_cy_adj_retro_element_id
377 FROM pay_element_type_extra_info pei,
378 pay_element_types_f pet
379 WHERE pei.information_type = 'PQP_NL_ABP_DEDUCTION'
380 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
381 -- AND c_effective_date BETWEEN To_Date(pei.eei_information10,'DD/MM/RRRR') AND
382 -- To_Date(pei.eei_information11,'DD/MM/RRRR')
383 AND c_effective_date BETWEEN pet.effective_start_date AND
384 pet.effective_end_date
385 AND pet.element_type_id = pei.element_type_id
386 AND pet.business_group_id = c_bg_id
387 AND pei.EEI_INFORMATION12 IN ('OPNP','IPBW_H','IPBW_L','AAOP');
388
389 -- ============================================================================
390 -- Cursor to get the valid element_type_id for record 31 (at BG Level)
391 -- ============================================================================
392 CURSOR c_rec_31_ele( c_bg_id IN Number
393 ,c_effective_date IN Date) IS
394 SELECT pet.element_type_id
395 ,pei.eei_information9||' Employee Pension Basis' bal_name
396 ,pei.eei_information12 sub_cat
397 ,'02' code
398 ,-1 defined_bal_id
399 ,pei.eei_information18 cy_retro_element_id
400 ,pei.eei_information19 py_retro_element_id
401 FROM pay_element_type_extra_info pei,
402 pay_element_types_f pet
403 WHERE pei.information_type = 'PQP_NL_ABP_DEDUCTION'
404 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
405 AND c_effective_date BETWEEN To_Date(pei.eei_information10,'DD/MM/RRRR') AND
406 To_Date(pei.eei_information11,'DD/MM/RRRR')
407 AND c_effective_date BETWEEN pet.effective_start_date AND
408 pet.effective_end_date
409 AND pet.element_type_id = pei.element_type_id
410 AND pet.business_group_id = c_bg_id
411 AND pei.EEI_INFORMATION12 IN ('IPAP');
412
413 -- ============================================================================
414 -- Cursor to get the valid element_type_id for record 41 (at BG Level)
415 -- ============================================================================
416 CURSOR c_basis_rec_41_ele( c_bg_id IN Number
417 ,c_effective_date IN Date) IS
418 SELECT pet.element_type_id
419 ,pei.eei_information9||' Employee Pension Basis' bal_name
420 ,pei.eei_information12 sub_cat
421 ,'99' code
422 ,-1 defined_bal_id
423 ,pei.eei_information18 cy_retro_element_id
424 ,pei.eei_information19 py_retro_element_id
425 FROM pay_element_type_extra_info pei,
426 pay_element_types_f pet
427 WHERE pei.information_type = 'PQP_NL_ABP_DEDUCTION'
428 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
429 AND c_effective_date BETWEEN To_Date(pei.eei_information10,'DD/MM/RRRR') AND
430 To_Date(pei.eei_information11,'DD/MM/RRRR')
431 AND c_effective_date BETWEEN pet.effective_start_date AND
432 pet.effective_end_date
433 AND pet.element_type_id = pei.element_type_id
434 AND pet.business_group_id = c_bg_id
435 AND pei.EEI_INFORMATION12 IN ('FUR_S');
436
437 --
438 -- Cursor to fetch any termination reversal related change event data
439 -- When a reversal of termination has happened, the period
440 -- of service should be open OR alternatively if the EE is terminated
441 -- in the future, the assignment should be active as of the effective date.
442 --
443 CURSOR c_get_revt_rows (p_business_group_id IN NUMBER
444 ,p_effective_date IN DATE
445 ,p_assignment_id IN NUMBER ) IS
446 SELECT old_val1,new_val1,ext_chg_evt_log_id
447 FROM ben_ext_chg_evt_log bec
448 WHERE chg_evt_cd = 'DAT'
449 AND person_id = g_person_id
450 AND bec.business_group_id = p_business_group_id
451 AND fnd_date.canonical_to_date(prmtr_09) BETWEEN
452 g_extract_params(p_business_group_id).extract_start_date
453 AND g_extract_params(p_business_group_id).extract_end_date
454 AND EXISTS(SELECT 1
455 FROM per_periods_of_service pps
456 ,per_all_assignments_f asg
457 WHERE pps.person_id = g_person_id
458 AND asg.assignment_id = p_assignment_id
459 AND asg.period_of_service_id = pps.period_of_service_id
460 AND (pps.actual_termination_date IS NULL
461 AND assignment_status_type_id IN
462 (SELECT assignment_status_type_id
463 FROM per_assignment_status_types
464 WHERE per_system_status = 'ACTIVE_ASSIGN'
465 AND active_flag = 'Y'))
466 AND p_effective_date BETWEEN effective_start_date
467 AND effective_end_date )
468 ORDER by bec.ext_chg_evt_log_id desc;
469
470 --
471 -- Cursor to fetch the termination date of a terminated or
472 -- ended assignment.
473 --
474 CURSOR c_get_asg_term_date (p_business_group_id IN NUMBER
475 ,p_effective_date IN DATE
476 ,p_assignment_id IN NUMBER
477 ,c_asg_seq_num IN VARCHAR) IS
478 SELECT min(effective_start_date) - 1 term_date
479 ,period_of_service_id
480 FROM per_all_assignments_f asg
481 WHERE assignment_id = p_assignment_id
482 AND effective_start_date <= g_extract_params(p_business_group_id).extract_end_date
483 AND assignment_status_type_id IN (SELECT assignment_status_type_id
484 FROM per_assignment_status_types
485 WHERE per_system_status = 'TERM_ASSIGN'
486 AND active_flag = 'Y')
487 group by period_of_service_id
488 UNION
489 --
490 -- Get the dates for any ended assignments. Note that this is for sec
491 -- assignments only.
492 --
493 SELECT max(effective_end_date)
494 ,period_of_service_id
495 FROM per_all_assignments_f asg
496 WHERE assignment_id = p_assignment_id
497 AND asg.primary_flag = 'N'
498 AND effective_end_date <= g_extract_params(p_business_group_id).extract_end_date
499 AND NOT EXISTS( SELECT 1
500 FROM per_all_assignments_f asg1
501 WHERE asg1.assignment_id = p_assignment_id
502 AND asg1.effective_start_date = asg.effective_end_date + 1
503 AND asg.assignment_id = asg1.assignment_id )
504 AND NOT EXISTS( SELECT 1
505 FROM per_all_assignments_f asg1
506 WHERE asg1.assignment_id = p_assignment_id
507 AND asg1.effective_start_date < asg.effective_start_date
508 AND asg.assignment_id = asg1.assignment_id
509 AND asg1.assignment_status_type_id IN (SELECT assignment_status_type_id
510 FROM per_assignment_status_types
511 WHERE per_system_status = 'TERM_ASSIGN'
512 AND active_flag = 'Y'))
513 group by period_of_service_id
514 ;
515
516 --
517 -- Cursor to fetch any termination related change event data
518 -- from the ben ext log table
519 --
520 CURSOR c_get_term_rows (p_business_group_id IN NUMBER
521 ,p_effective_date IN DATE
522 ,p_assignment_id IN NUMBER
523 ,c_asg_seq_num IN VARCHAR) IS
524 SELECT old_val1
525 ,to_char(pps.actual_termination_date,'DD/MM/YYYY') term_date
526 ,ext_chg_evt_log_id
527 ,fnd_number.canonical_to_number(prmtr_01)
528 FROM ben_ext_chg_evt_log bec
529 ,per_periods_of_service pps
530 ,per_all_assignments_f asg
531 WHERE bec.chg_evt_cd = 'AAT'
532 AND bec.person_id = g_person_id
533 AND bec.business_group_id = p_business_group_id
534 AND fnd_date.canonical_to_date(bec.prmtr_09)
535 BETWEEN g_extract_params(p_business_group_id).extract_start_date
536 AND g_extract_params(p_business_group_id).extract_end_date
537 AND pps.person_id = g_person_id
538 AND asg.assignment_id = p_assignment_id
539 AND asg.period_of_service_id = pps.period_of_service_id
540 AND pps.actual_termination_date IS NOT NULL
541 AND p_effective_date BETWEEN asg.effective_start_date
542 AND asg.effective_end_date
543 UNION
544 SELECT
545 NULL
546 ,term_date
547 ,9999999999 - rownum
548 ,period_of_service_id FROM (
549 SELECT NULL
550 ,to_char(effective_start_date - 1,'DD/MM/YYYY') term_date
551 ,9999999999
552 ,period_of_service_id
553 FROM per_all_assignments_f asg
554 WHERE assignment_id = p_assignment_id
555 AND assignment_status_type_id IN (SELECT assignment_status_type_id
556 FROM per_assignment_status_types
557 WHERE per_system_status = 'TERM_ASSIGN'
558 AND active_flag = 'Y')
559 AND effective_start_date BETWEEN
560 g_extract_params(p_business_group_id).extract_start_date
561 AND g_extract_params(p_business_group_id).extract_end_date
562 AND NOT EXISTS ( SELECT 1
563 FROM ben_ext_chg_evt_log bec
564 WHERE chg_evt_cd = 'AAT'
565 AND person_id = g_person_id
566 AND bec.business_group_id = p_business_group_id
567 AND fnd_date.canonical_to_date(prmtr_09)
568 BETWEEN g_extract_params(p_business_group_id).extract_start_date
569 AND g_extract_params(p_business_group_id).extract_end_date )
570 AND NOT EXISTS( SELECT 1
571 FROM per_all_assignments_f asg1
572 WHERE assignment_id = p_assignment_id
573 AND effective_start_date <
574 g_extract_params(p_business_group_id).extract_start_date
575 AND asg.assignment_id = asg1.assignment_id
576 AND assignment_status_type_id IN (SELECT assignment_status_type_id
577 FROM per_assignment_status_types
578 WHERE per_system_status = 'TERM_ASSIGN'
579 AND active_flag = 'Y'))
580 ORDER BY effective_start_date )
581 UNION
582 SELECT NULL
583 ,to_char(effective_end_date,'DD/MM/YYYY')
584 ,9999999999
585 ,period_of_service_id
586 FROM per_all_assignments_f asg
587 WHERE assignment_id = p_assignment_id
588 AND asg.primary_flag = 'N'
589 AND effective_end_date BETWEEN
590 g_extract_params(p_business_group_id).extract_start_date
591 AND g_extract_params(p_business_group_id).extract_end_date
592 AND NOT EXISTS( SELECT 1
593 FROM per_all_assignments_f asg1
594 WHERE assignment_id = p_assignment_id
595 AND effective_start_date = asg.effective_end_date + 1
596 AND asg.assignment_id = asg1.assignment_id )
597 AND NOT EXISTS( SELECT 1
598 FROM per_all_assignments_f asg1
599 WHERE assignment_id = p_assignment_id
600 AND effective_start_date <
601 g_extract_params(p_business_group_id).extract_start_date
602 AND asg.assignment_id = asg1.assignment_id
603 AND assignment_status_type_id IN (SELECT assignment_status_type_id
604 FROM per_assignment_status_types
605 WHERE per_system_status = 'TERM_ASSIGN'
606 AND active_flag = 'Y'))
607 AND NOT EXISTS ( SELECT 1
608 FROM ben_ext_chg_evt_log bec
609 WHERE chg_evt_cd = 'AAT'
610 AND person_id = g_person_id
611 AND bec.business_group_id = p_business_group_id
612 AND fnd_date.canonical_to_date(prmtr_09)
613 BETWEEN g_extract_params(p_business_group_id).extract_start_date
614 AND g_extract_params(p_business_group_id).extract_end_date )
615 --
616 -- Reporting Retro Termination of sec asg
617 --
618 UNION
619 SELECT NULL
620 ,to_char(min(effective_start_date) - 1,'DD/MM/YYYY')
621 ,9999999999
622 ,period_of_service_id
623 FROM per_all_assignments_f asg
624 WHERE assignment_id = p_assignment_id
625 AND asg.primary_flag = 'N'
626 AND effective_start_date < g_extract_params(p_business_group_id).extract_start_date
627 AND assignment_status_type_id IN (SELECT assignment_status_type_id
628 FROM per_assignment_status_types
629 WHERE per_system_status = 'TERM_ASSIGN'
630 AND active_flag = 'Y')
631 AND NOT EXISTS( SELECT 1
632 FROM ben_ext_rslt_dtl dtl
633 ,ben_ext_rslt res
634 ,ben_ext_rcd rcd
635 ,ben_ext_rcd_in_file rin
636 ,ben_ext_dfn dfn
637 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
638 FROM pqp_extract_attributes
639 WHERE ext_dfn_type = 'NL_FPR')
640 and dtl.person_id = g_person_id
641 and ext_stat_cd = 'A'
642 AND TRUNC(res.eff_dt)< g_extract_params(p_business_group_id).extract_start_date
643 AND rin.ext_file_id = dfn.ext_file_id
644 AND rin.ext_rcd_id = rcd.ext_rcd_id
645 AND dfn.ext_dfn_id = res.ext_dfn_id
646 and dtl.ext_rslt_id = res.ext_rslt_id
647 AND dtl.ext_rcd_id = rcd.ext_rcd_id
648 AND rin.seq_num = 5
649 AND val_04 = c_asg_seq_num
650 AND val_07 <> '00000000')
651 group by period_of_service_id
652
653 ORDER by 3 desc;
654
655 --
656 -- Cursor to get the current ptp.
657 -- this is also used to identify if an EE is a regular EE or
658 -- a declerant (hourly EE)
659 --
660 CURSOR c_cur_ptp (c_eff_dt IN DATE
661 ,c_asg_id IN NUMBER) IS
662 SELECT LEAST(fnd_number.canonical_to_number(NVL(target.SEGMENT29,'100')),125) ptp
663 FROM per_assignments_f asg
664 ,hr_soft_coding_keyflex target
665 WHERE target.soft_coding_keyflex_id = asg.soft_coding_keyflex_id
666 AND asg.assignment_id = c_asg_id
667 AND target.enabled_flag = 'Y'
668 AND trunc(c_eff_dt) BETWEEN asg.effective_start_date AND
669 asg.effective_end_date;
670
671 --7555712
672 --
673 -- Cursor to get the Salaried / Hourly Indicator
674 --
675 l_hourly_salaried_code per_assignments_f.hourly_salaried_code%type;
676
677 CURSOR c_cur_sal_hour (c_eff_dt IN DATE
678 ,c_asg_id IN NUMBER) IS
679 SELECT nvl(hourly_salaried_code,'H') hourly_salaried_code
680 FROM per_assignments_f asg
681 ,hr_soft_coding_keyflex target
682 WHERE target.soft_coding_keyflex_id = asg.soft_coding_keyflex_id
683 AND asg.assignment_id = c_asg_id
684 AND target.enabled_flag = 'Y'
685 AND trunc(c_eff_dt) BETWEEN asg.effective_start_date AND
686 asg.effective_end_date;
687 --7555712
688
689
690 TYPE t_basis_rec IS TABLE OF c_rec_09_ele%ROWTYPE INDEX BY Binary_Integer;
691 TYPE t_basis_rec1 IS TABLE OF c_rec_31_ele%ROWTYPE INDEX BY Binary_Integer;
692
693 l_rec_09 t_basis_rec;
694 l_rec_31 t_basis_rec1;
695 l_basis_rec_41 t_basis_rec1;
696
697 l_09_counter Number := 0;
698 l_31_counter Number := 0;
699 l_41_basis_counter Number := 0;
700
701 TYPE r_basis_rec_values IS RECORD
702 ( basis_amount Number(9,2)
703 ,sign_code Varchar2(1)
704 ,code Varchar2(2)
705 ,processed Varchar2(1)
706 ,pobj_flag Varchar2(1)
707 ,date_earned Varchar2(11) );
708 TYPE t_basis_rec_values IS TABLE OF r_basis_rec_values INDEX BY Binary_Integer;
709 l_rec_09_values t_basis_rec_values;
710 l_rec_31_values t_basis_rec_values;
711 l_rec_41_basis_values t_basis_rec_values;
712
713 TYPE r_retro_ptpn IS RECORD
714 ( start_date DATE
715 ,end_date DATE
716 ,ptid NUMBER );
717 TYPE t_retro_ptpn IS TABLE OF r_retro_ptpn INDEX BY Binary_Integer;
718
719 TYPE r_retro_ptpn_kind IS RECORD
720 ( start_date DATE
721 ,end_date DATE
722 ,ptpn_kind varchar2(3)
723 ,ptpn_val NUMBER);
724 TYPE t_retro_ptpn_kind IS TABLE OF r_retro_ptpn_kind INDEX BY Binary_Integer;
725
726 l_rec_09_disp Varchar2(1) := 'N';
727 l_rec_05_disp Varchar2(1) := 'N';
728 l_rec_31_disp Varchar2(1) := 'N';
729 l_basis_rec_41_disp Varchar2(1) := 'N';
730
731 -- ============================================================================
732 -- Cursor to get the input value id for the pension basis input value
733 -- ============================================================================
734 CURSOR c_get_iv_id(c_element_type_id in number) IS
735 SELECT input_value_id
736 FROM pay_input_values_f
737 WHERE element_type_id = c_element_type_id
738 AND name = 'ABP Employee Pension Basis';
739
740 l_basis_iv_id NUMBER;
741
742 -- ============================================================================
743 -- Cursor to get the valid element_type_id for record 12 (at BG Level)
744 -- ============================================================================
745 CURSOR c_rec_12_ele( c_bg_id IN Number
746 ,c_effective_date IN Date
747 ,c_asg_id IN Number) IS
748 SELECT pei.eei_information12 sub_cat
749 ,pay_paywsmee_pkg.get_original_date_earned(peef.element_entry_id) date_earned
750 ,Decode (pei.eei_information12,'OPNP_65',5,'OPNP_W25',6,'OPNP_W50',7,
751 'VSG',9,'FPU_E',4,'FPU_R',2,'FPU_S',1,'FPU_T',3,'FPU_B',1
752 ,'PPP',11) code
753 ,sum(fnd_number.canonical_to_number(peev.screen_entry_value)) amount
754 ,pty.ee_contribution_bal_type_id
755 ,pty.er_contribution_bal_type_id
756 FROM pay_element_type_extra_info pei,
757 pay_element_types_f pet,
758 pay_element_entries_f peef,
759 pay_element_links_f pelf,
760 pay_element_entry_values_f peev,
761 pay_input_values_f pivf,
762 pqp_pension_types_f pty
763 WHERE pei.information_type = 'PQP_NL_ABP_DEDUCTION'
764 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
765 AND c_effective_date BETWEEN To_Date(pei.eei_information10,'DD/MM/RRRR') AND
766 To_Date(pei.eei_information11,'DD/MM/RRRR')
767 AND c_effective_date BETWEEN pet.effective_start_date AND
768 pet.effective_end_date
769 AND c_effective_date BETWEEN peef.effective_start_date AND
770 peef.effective_end_date
771 AND c_effective_date BETWEEN pelf.effective_start_date AND
772 pelf.effective_end_date
773 AND c_effective_date BETWEEN peev.effective_start_date AND
774 peev.effective_end_date
775 AND c_effective_date BETWEEN pty.effective_start_date AND
776 pty.effective_end_date
777 AND c_effective_date BETWEEN pivf.effective_start_date AND
778 pivf.effective_end_date
779 AND (to_number(pei.eei_information18) = pet.element_type_id
780 OR to_number(pei.eei_information19) = pet.element_type_id
781 OR to_number(pei.eei_information20) = pet.element_type_id
782 OR to_number(pei.eei_information21) = pet.element_type_id
783 OR pet.element_type_id IN (SELECT retro_element_type_id
784 FROM pay_element_span_usages pesu,
785 pay_retro_component_usages prcu
786 WHERE prcu.retro_component_usage_id = pesu.retro_component_usage_id
787 AND retro_component_id = ( SELECT retro_component_id
788 FROM pay_retro_components
789 WHERE legislation_code = 'NL'
790 AND short_name = 'Adjustment'
791 AND component_name = 'Adjustment')
792 AND creator_type = 'ET'
793 AND (creator_id = pei.element_type_id OR
794 creator_id IN (SELECT element_type_id
795 FROM pay_element_types_f pet1
796 WHERE pet1.element_name = pei.eei_information9 || ' ABP Employer Pension Contribution'
797 AND pet1.business_group_id = pet.business_group_id))) )
798 AND pelf.element_type_id = pet.element_type_id
799 AND pivf.element_type_id = pet.element_type_id
800 AND pivf.name = 'Pay Value'
801 AND peef.element_link_id = pelf.element_link_id
802 AND peev.input_value_id = pivf.input_value_id
803 AND peev.element_entry_id = peef.element_entry_id
804 AND pet.business_group_id = c_bg_id
805 AND peef.assignment_id = c_asg_id
806 AND pei.EEI_INFORMATION12 IN ('OPNP_65','OPNP_W25','OPNP_W50','PPP','FPU_B',
807 'VSG','FPU_E','FPU_R','FPU_S','FPU_T')
808 AND pty.pension_type_id = to_number(pei.eei_information2)
809 GROUP BY pei.eei_information12,pay_paywsmee_pkg.get_original_date_earned(peef.element_entry_id)
810 ,pty.ee_contribution_bal_type_id,pty.er_contribution_bal_type_id
811 UNION
812 SELECT pension_sub_category sub_cat
813 ,c_effective_date date_earned
814 ,Decode (pension_sub_category,'OPNP_65',5,'OPNP_W25',6,'OPNP_W50',7,'PPP',11,
815 'VSG',9,'FPU_E',4,'FPU_R',2,'FPU_S',1,'FPU_T',3,'FPU_B',1) code
816 ,-999999 amount
817 ,ee_contribution_bal_type_id
818 ,er_contribution_bal_type_id
819 FROM pqp_pension_types_f pty
820 WHERE pension_sub_category IN ('OPNP_65','OPNP_W25','OPNP_W50','PPP',
821 'VSG','FPU_E','FPU_R','FPU_S','FPU_T','FPU_B')
822 AND business_group_id = c_bg_id
823 AND c_effective_date BETWEEN pty.effective_start_date AND
824 pty.effective_end_date
825 GROUP BY pension_sub_category,c_effective_date
826 ,ee_contribution_bal_type_id
827 ,er_contribution_bal_type_id;
828
829 -- ============================================================================
830 -- Cursor to get the valid element_type_id for record 41 (at BG Level)
831 -- ============================================================================
832 CURSOR c_contrib_rec_41_ele( c_bg_id IN Number
833 ,c_effective_date IN Date
834 ,c_asg_id IN Number) IS
835 SELECT pei.eei_information12 sub_cat
836 ,pay_paywsmee_pkg.get_original_date_earned(peef.element_entry_id) date_earned
837 ,9 code
838 ,sum(fnd_number.canonical_to_number(peev.screen_entry_value)) amount
839 ,pty.ee_contribution_bal_type_id
840 ,pty.er_contribution_bal_type_id
841 FROM pay_element_type_extra_info pei,
842 pay_element_types_f pet,
843 pay_element_entries_f peef,
844 pay_element_links_f pelf,
845 pay_element_entry_values_f peev,
846 pay_input_values_f pivf,
847 pqp_pension_types_f pty
848 WHERE pei.information_type = 'PQP_NL_ABP_DEDUCTION'
849 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
850 AND c_effective_date BETWEEN To_Date(pei.eei_information10,'DD/MM/RRRR') AND
851 To_Date(pei.eei_information11,'DD/MM/RRRR')
852 AND c_effective_date BETWEEN pet.effective_start_date AND
853 pet.effective_end_date
854 AND c_effective_date BETWEEN peef.effective_start_date AND
855 peef.effective_end_date
856 AND c_effective_date BETWEEN pelf.effective_start_date AND
857 pelf.effective_end_date
858 AND c_effective_date BETWEEN peev.effective_start_date AND
859 peev.effective_end_date
860 AND c_effective_date BETWEEN pivf.effective_start_date AND
861 pivf.effective_end_date
862 AND c_effective_date BETWEEN pty.effective_start_date AND
863 pty.effective_end_date
864 AND (to_number(pei.eei_information18) = pet.element_type_id
865 OR to_number(pei.eei_information19) = pet.element_type_id
866 OR to_number(pei.eei_information20) = pet.element_type_id
867 OR to_number(pei.eei_information21) = pet.element_type_id)
868 AND pelf.element_type_id = pet.element_type_id
869 AND pivf.element_type_id = pet.element_type_id
870 AND pivf.name = 'Pay Value'
871 AND peef.element_link_id = pelf.element_link_id
872 AND peev.input_value_id = pivf.input_value_id
873 AND peev.element_entry_id = peef.element_entry_id
874 AND pet.business_group_id = c_bg_id
875 AND peef.assignment_id = c_asg_id
876 AND pei.EEI_INFORMATION12 IN ('FUR_S')
877 AND pty.pension_type_id = to_number(pei.eei_information2)
878 GROUP BY pei.eei_information12,pay_paywsmee_pkg.get_original_date_earned(peef.element_entry_id)
879 ,pty.ee_contribution_bal_type_id,pty.er_contribution_bal_type_id
880 UNION
881 SELECT pension_sub_category sub_cat
882 ,c_effective_date date_earned
883 ,9 code
884 ,-999999 amount
885 ,ee_contribution_bal_type_id
886 ,er_contribution_bal_type_id
887 FROM pqp_pension_types_f pty
888 WHERE pension_sub_category IN ('FUR_S')
889 AND business_group_id = c_bg_id
890 AND c_effective_date BETWEEN pty.effective_start_date AND
891 pty.effective_end_date
892 GROUP BY pension_sub_category,c_effective_date
893 ,ee_contribution_bal_type_id,er_contribution_bal_type_id;
894
895 TYPE t_rec_12 IS TABLE OF c_rec_12_ele%ROWTYPE INDEX BY Binary_Integer;
896 l_rec_12 t_rec_12;
897 l_contrib_rec_41 t_rec_12;
898 l_12_counter Number := 0;
899 l_41_contrib_counter Number := 0;
900 i_12 Number := 0;
901 i_41 Number := 0;
902
903 TYPE r_rec_12_values IS RECORD
904 (contrib_amount Number(9,2)
905 ,date_earned varchar2(11)
906 ,code varchar2(2));
907
908 TYPE t_rec_12_values IS TABLE OF r_rec_12_values INDEX BY Binary_Integer;
909 l_rec_12_values t_rec_12_values;
910 l_rec_41_contrib_values t_rec_12_values;
911
912 l_rec_12_disp Varchar2(1) := 'N';
913 l_contrib_rec_41_disp Varchar2(1) := 'N';
914 l_rec12_amt Number := 0;
915 l_rec41_amt Number := 0;
916
917 -- ============================================================================
918 -- Cursor to get the element entry ids for the Retro Pension Deduction elements
919 -- ============================================================================
920 CURSOR c_get_retro_entry(c_element_type_id in number
921 ,c_assignment_action_id in number) IS
922 SELECT element_entry_id
923 FROM pay_run_results prr
924 WHERE prr.assignment_action_id = c_assignment_action_id
925 AND prr.element_type_id = c_element_type_id
926 ORDER BY element_entry_id;
927
928 -- ============================================================================
929 -- Cursor to get the element entry ids for a given retro element type
930 -- ============================================================================
931 CURSOR c_get_retro_ele_entry(c_start_date in date
932 ,c_end_date in date
933 ,c_assignment_id in number
934 ,c_element_type_id in number) IS
935 SELECT element_entry_id
936 FROM pay_run_results prr,
937 pay_payroll_actions ppa,
938 pay_assignment_actions paa
939 WHERE paa.assignment_action_id = prr.assignment_action_id
940 AND paa.payroll_action_id = ppa.payroll_action_id
941 AND ppa.date_earned BETWEEN c_start_date
942 AND c_end_date
943 AND paa.assignment_id = c_assignment_id
944 AND prr.element_type_id = c_element_type_id
945 ORDER BY element_entry_id;
946
947 l_retro_ptp_entry c_get_retro_ele_entry%ROWTYPE;
948
949 -- ============================================================================
950 -- Cursor to get the input value id and element type id for the
951 -- given retro element and input value names
952 -- ============================================================================
953 CURSOR c_get_retro_ele(c_element_name in varchar2
954 ,c_input_value_name in varchar2) IS
955 SELECT piv.input_value_id
956 ,pet.element_type_id
957 FROM pay_input_values_f piv
958 ,pay_element_types_f pet
959 WHERE piv.name = c_input_value_name
960 AND piv.element_type_id = pet.element_type_id
961 AND pet.element_name = c_element_name;
962
963 -- ============================================================================
964 -- Cursor to get the entry value for the given element entry id and input value
965 -- (for all numeric input values)
966 -- ============================================================================
967 CURSOR c_get_retro_num_value(c_element_entry_id in number
968 ,c_input_value_id in number) IS
969 SELECT fnd_number.canonical_to_number(nvl(screen_entry_value,'0'))
970 FROM pay_element_entry_values_f
971 WHERE element_entry_id = c_element_entry_id
972 AND input_value_id = c_input_value_id;
973
974 -- ============================================================================
975 -- Cursor to get the entry value for the given element entry id and input value
976 -- (for all text input values)
977 -- ============================================================================
978 CURSOR c_get_retro_txt_value(c_element_entry_id in number
979 ,c_input_value_id in number) IS
980 SELECT nvl(screen_entry_value,' ')
981 FROM pay_element_entry_values_f
982 WHERE element_entry_id = c_element_entry_id
983 AND input_value_id = c_input_value_id;
984
985 -- ============================================================================
986 -- Cursor to check if a non-null entry exists for the retro part time percentage
987 -- ============================================================================
988 CURSOR c_retro_ptp_entry_exists(c_start_date in date
989 ,c_end_date in date
990 ,c_assignment_id in number
991 ,c_element_type_id in number
992 ,c_input_value_id in number) IS
993 SELECT 1
994 FROM pay_element_entry_values_f
995 WHERE input_value_id = c_input_value_id
996 AND screen_entry_value IS NOT NULL
997 AND element_entry_id IN
998 (SELECT element_entry_id
999 FROM pay_run_results prr,
1000 pay_payroll_actions ppa,
1001 pay_assignment_actions paa
1002 WHERE paa.assignment_action_id = prr.assignment_action_id
1003 AND paa.payroll_action_id = ppa.payroll_action_id
1004 AND ppa.date_earned BETWEEN c_start_date
1005 AND c_end_date
1006 AND paa.assignment_id = c_assignment_id
1007 AND prr.element_type_id = c_element_type_id
1008 );
1009
1010 l_retro_ptp_entry_exists c_retro_ptp_entry_exists%ROWTYPE;
1011
1012 -- ============================================================================
1013 -- Cursor to get the time period start and end dates for a retro element entry
1014 -- ============================================================================
1015 CURSOR c_get_retro_time_period(c_element_entry_id in number
1016 ,c_assignment_id in number) IS
1017 SELECT ptp.start_date,ptp.end_date
1018 FROM per_time_periods ptp
1019 ,per_all_assignments_f paa
1020 WHERE paa.assignment_id = c_assignment_id
1021 AND ptp.payroll_id = paa.payroll_id
1022 AND pay_paywsmee_pkg.get_original_date_earned(c_element_entry_id)
1023 BETWEEN paa.effective_start_date
1024 AND paa.effective_end_date
1025 AND pay_paywsmee_pkg.get_original_date_earned(c_element_entry_id)
1026 BETWEEN ptp.start_date
1027 AND ptp.end_date;
1028
1029 -- ============================================================================
1030 -- Cursor to check for multiple changes to PTP in a period.
1031 -- Addition of the > 0 check is to report retro PTP for hourly EE's
1032 -- ============================================================================
1033 CURSOR c_get_count_ptp_changes(c_asg_id in number
1034 ,c_period_start in date
1035 ,c_period_end in date) IS
1036 SELECT COUNT(*)
1037 FROM per_assignments_f asg
1038 ,per_assignment_status_types past
1039 ,hr_soft_coding_keyflex target
1040 WHERE asg.assignment_status_type_id = past.assignment_status_type_id
1041 AND past.per_system_status = 'ACTIVE_ASSIGN'
1042 AND asg.effective_start_date BETWEEN c_period_start
1043 AND c_period_end
1044 AND asg.assignment_id = c_asg_id
1045 AND target.soft_coding_keyflex_id = asg.soft_coding_keyflex_id
1046 AND target.enabled_flag = 'Y'
1047 AND fnd_number.canonical_to_number(NVL(target.SEGMENT29,'100')) > 0;
1048
1049 -- ============================================================================
1050 -- Cursor to get the changes to the part time percentage in a retro period
1051 -- ============================================================================
1052 CURSOR c_get_ptp_changes(c_asg_id in number
1053 ,c_period_start in date
1054 ,c_period_end in date) IS
1055 SELECT asg.effective_start_date Start_Date
1056 ,asg.effective_end_date End_Date
1057 ,fnd_number.canonical_to_number(NVL(target.SEGMENT29,'100')) ptp
1058 FROM per_assignments_f asg
1059 ,per_assignment_status_types past
1060 ,hr_soft_coding_keyflex target
1061 WHERE asg.assignment_status_type_id = past.assignment_status_type_id
1062 AND past.per_system_status = 'ACTIVE_ASSIGN'
1063 AND asg.effective_start_date BETWEEN c_period_start
1064 AND c_period_end
1065 AND asg.assignment_id = c_asg_id
1066 AND target.soft_coding_keyflex_id = asg.soft_coding_keyflex_id
1067 AND target.enabled_flag = 'Y';
1068
1069 -- ============================================================================
1070 -- Cursor to get the retro ptp for ABP and SI
1071 -- ============================================================================
1072 CURSOR c_get_retro_ptp(c_asg_id IN NUMBER
1073 ,c_effective_date IN DATE
1074 ,c_ele_type_id IN NUMBER
1075 ,c_input_val_id IN NUMBER ) IS
1076
1077 SELECT to_date('1/'||to_char(pay_paywsmee_pkg.get_original_date_earned(peef.element_entry_id),'MM/YYYY'),'DD/MM/YYYY') start_date
1078 ,add_months(to_date('1/'||to_char(pay_paywsmee_pkg.get_original_date_earned(peef.element_entry_id),'MM/YYYY'),'DD/MM/YYYY'),1) - 1 end_date
1079 ,fnd_number.canonical_to_number(peev.screen_entry_value) ptp
1080 FROM pay_element_entries_f peef,
1081 pay_element_links_f pelf,
1082 pay_element_entry_values_f peev
1083 WHERE c_effective_date BETWEEN peef.effective_start_date AND
1084 peef.effective_end_date
1085 AND c_effective_date BETWEEN pelf.effective_start_date AND
1086 pelf.effective_end_date
1087 AND c_effective_date BETWEEN peev.effective_start_date AND
1088 peev.effective_end_date
1089 AND peef.element_link_id = pelf.element_link_id
1090 AND peev.element_entry_id = peef.element_entry_id
1091 AND pelf.element_type_id = c_ele_type_id
1092 AND peev.input_value_id = c_input_val_id
1093 AND peef.assignment_id = c_asg_id
1094 AND peev.screen_entry_value IS NOT NULL
1095 order by start_date;
1096
1097 -- ============================================================================
1098 -- Cursor to get the retro ptp for ABP and SI
1099 -- ============================================================================
1100 CURSOR c_ptp_chg_exist(c_asg_id IN NUMBER
1101 ,c_effective_date IN DATE
1102 ,c_ele_type_id IN NUMBER
1103 ,c_input_val_id IN NUMBER ) IS
1104
1105 SELECT 1
1106 FROM pay_element_entries_f peef,
1107 pay_element_links_f pelf,
1108 pay_element_entry_values_f peev
1109 WHERE c_effective_date BETWEEN peef.effective_start_date AND
1110 peef.effective_end_date
1111 AND c_effective_date BETWEEN pelf.effective_start_date AND
1112 pelf.effective_end_date
1113 AND c_effective_date BETWEEN peev.effective_start_date AND
1114 peev.effective_end_date
1115 AND peef.element_link_id = pelf.element_link_id
1116 AND peev.element_entry_id = peef.element_entry_id
1117 AND pelf.element_type_id = c_ele_type_id
1118 AND peev.input_value_id = c_input_val_id
1119 AND peef.assignment_id = c_asg_id
1120 AND peev.screen_entry_value IS NOT NULL;
1121
1122 l_ptp_chg_exist NUMBER;
1123
1124 --6501898
1125 -- ============================================================================
1126 -- Cursor to get the non retro ptp for ABP for Hourly Employees
1127 -- ============================================================================
1128 CURSOR c_ptp_chg_hrly_exist(c_asg_id IN NUMBER
1129 ,c_effective_date IN DATE
1130 ,c_ele_type_id IN NUMBER
1131 ,c_input_val_id IN NUMBER ) IS
1132
1133 SELECT to_date('1/'||to_char(ppa.date_earned,'MM/YYYY'),'DD/MM/YYYY') start_date
1134 ,add_months(to_date('1/'||to_char(ppa.date_earned,'MM/YYYY'),'DD/MM/YYYY'),1) - 1 end_date
1135 ,fnd_number.canonical_to_number(prrv.result_value) ptp, 'Y' Yes
1136 FROM pay_element_entries_f peef,
1137 pay_element_links_f pelf,
1138 pay_element_entry_values_f peev,
1139 pay_run_results prr,
1140 pay_run_result_values prrv,
1141 pay_assignment_actions paa,
1142 pay_payroll_actions ppa
1143 WHERE ppa.date_earned BETWEEN peef.effective_start_date AND
1144 peef.effective_end_date
1145 AND ppa.date_earned BETWEEN pelf.effective_start_date AND
1146 pelf.effective_end_date
1147 AND ppa.date_earned BETWEEN peev.effective_start_date AND
1148 peev.effective_end_date
1149 AND c_effective_date BETWEEN to_date('1/'||to_char(ppa.effective_date,'MM/YYYY'),'DD/MM/YYYY') AND
1150 add_months(to_date('1/'||to_char(ppa.effective_date,'MM/YYYY'),'DD/MM/YYYY'),1) - 1
1151 AND peef.element_link_id = pelf.element_link_id
1152 AND peev.element_entry_id = peef.element_entry_id
1153 AND prr.element_entry_id = peef.element_entry_id
1154 AND prr.element_type_id = pelf.element_type_id
1155 AND prrv.run_result_id = prr.run_result_id
1156 AND prrv.input_value_id = peev.input_value_id
1157 AND paa.payroll_action_id = ppa.payroll_action_id
1158 AND paa.assignment_action_id = prr.assignment_action_id
1159 AND pelf.element_type_id = c_ele_type_id
1160 AND peev.input_value_id = c_input_val_id
1161 AND peef.assignment_id = c_asg_id
1162 AND fnd_number.canonical_to_number(prrv.result_value) > 0 ;
1163
1164 l_ptp_chg_hrly_exist c_ptp_chg_hrly_exist%rowtype;
1165 --6501898
1166
1167 -- ============================================================================
1168 -- Cursor to get the original date earned for a retro element entry
1169 -- ============================================================================
1170 CURSOR c_get_retro_date_earned(c_element_entry_id in number) IS
1171 SELECT substr(fnd_date.date_to_canonical(
1172 trunc(pay_paywsmee_pkg.get_original_date_earned(c_element_entry_id))
1173 ),1,10)
1174 FROM dual;
1175
1176 TYPE r_rec_retro_ptp IS RECORD
1177 (start_date Date
1178 ,end_date Date
1179 ,part_time_perc Number(9,2)
1180 ,vop Number(5,2));
1181
1182 TYPE t_rec_retro_ptp IS TABLE of r_rec_retro_ptp INDEX BY Binary_Integer;
1183 l_rec_05_retro_ptp t_rec_retro_ptp;
1184 l_rec_20_retro_ptp t_rec_retro_ptp;
1185
1186 TYPE r_rec_retro_siw IS RECORD
1187 (date_earned varchar2(11)
1188 ,si_wages Number(9,2)
1189 ,si_days Number(5,2)
1190 ,si_type varchar2(4));
1191
1192 TYPE t_rec_retro_siw IS TABLE of r_rec_retro_siw INDEX BY Binary_Integer;
1193 l_rec_21_retro_siw t_rec_retro_siw;
1194 l_rec_22_retro_siw t_rec_retro_siw;
1195
1196 l_si_days_sign Varchar2(1) := ' ';
1197 l_si_wages_sign Varchar2(1) := ' ';
1198 l_curr_si_type Varchar2(5) := 'NONE';
1199 l_curr_si_rec Varchar2(5) := '21';
1200 l_wao_done Varchar2(1) := 'N';
1201 l_si_type_dbal_id Number;
1202 l_si_days_dbal_id Number;
1203 l_si_reg_dbal_id Number;
1204 l_pen_py_con_dbal_id NUMBER;
1205 l_abp_ptp_ele_id Number;
1206 l_abp_ptp_iv_id Number;
1207 l_si_ptp_ele_id Number;
1208 l_si_ptp_iv_id Number;
1209 g_abp_processed_flag NUMBER;
1210 g_new_hire_asg NUMBER;
1211 g_hire_date DATE;
1212
1213
1214 -- =============================================================================
1215 -- IsNumber: return TRUE if number else FALSE
1216 -- =============================================================================
1217 FUNCTION IsNumber (p_data_value IN Varchar2)
1218 RETURN Boolean IS
1219 l_data_value Number;
1220 BEGIN
1221 l_data_value := Fnd_Number.Canonical_To_Number(Nvl(p_data_value,'0'));
1222 RETURN TRUE;
1223 EXCEPTION
1224 WHEN Value_Error THEN
1225 RETURN FALSE;
1226 END IsNumber;
1227
1228 -- =============================================================================
1229 -- to_nl_date: Function to convert the date to the appropriate value
1230 -- since the ben logs contain dates in the NL Language -- 31-MEI-05
1231 -- 1-OKT-05 etc
1232 -- =============================================================================
1233 FUNCTION To_NL_Date (p_date_value IN VARCHAR2,
1234 p_date_format IN VARCHAR2)
1235 RETURN DATE IS
1236
1237 BEGIN
1238
1239 IF LENGTH(p_date_value) = 9 THEN
1240 RETURN TO_DATE(p_date_value,p_date_format,'NLS_DATE_LANGUAGE = ''DUTCH''');
1241 ELSE
1242 RETURN TO_DATE(p_date_value,p_date_format);
1243 END IF;
1244
1245 EXCEPTION
1246 WHEN OTHERS THEN
1247 RETURN To_date(p_date_value,p_date_format,'NLS_DATE_LANGUAGE = ''AMERICAN''');
1248
1249 END to_nl_date;
1250
1251 -- =============================================================================
1252 -- ~ Pension_Extract_Process: This is called by the conc. program as is a
1253 -- ~ wrapper around the benefits conc. program Extract Process.
1254 -- =============================================================================
1255 PROCEDURE Pension_Extract_Process
1256 (errbuf OUT NOCOPY Varchar2
1257 ,retcode OUT NOCOPY Varchar2
1258 ,p_benefit_action_id IN Number
1259 ,p_ext_dfn_id IN Number
1260 ,p_org_id IN Number
1261 ,p_payroll_id IN Number
1262 ,p_start_date IN Varchar2
1263 ,p_end_date IN Varchar2
1264 ,p_extract_rec_01 IN VARCHAR2
1265 ,p_business_group_id IN Number
1266 ,p_sort_position IN NUMBER DEFAULT 1 --9278285
1267 ,p_consolidation_set IN Number
1268 ,p_ext_rslt_id IN Number DEFAULT NULL
1269 ) IS
1270 l_errbuff Varchar2(3000);
1271 l_retcode Number;
1272 l_session_id Number;
1273 l_proc_name Varchar2(150) := g_proc_name ||'Pension_Extract_Process';
1274
1275 BEGIN
1276 IF g_debug THEN
1277 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
1278 END If;
1279
1280 g_conc_request_id := Fnd_Global.conc_request_id;
1281
1282 IF p_end_date < p_start_date THEN
1283 Fnd_Message.set_name('PQP','PQP_230869_END_BEFORE_START');
1284 Fnd_Message.raise_error;
1285 END IF;
1286
1287 SELECT Userenv('SESSIONID') INTO l_session_id FROM dual;
1288
1289 -- Delete values from the temporary table
1290 DELETE FROM pay_us_rpt_totals
1291 WHERE organization_name = 'NL ABP Pension Extracts';
1292
1293 --
1294 -- Insert into pay_us_rpt_totals so that we can refer to these parameters
1295 -- when we call the criteria formula for the pension extract.
1296 --
1297 IF g_debug THEN
1298 hr_utility.set_location('inserting into rpt totals : '||p_business_group_id,20);
1299 END IF;
1300
1301 INSERT INTO pay_us_rpt_totals
1302 (session_id -- Session id
1303 ,organization_name -- Concurrent Program Name
1304 ,business_group_id -- Business Group
1305 ,tax_unit_id -- Concurrent Request Id
1306 ,value1 -- Extract Definition Id
1307 ,value2 -- Payroll Id
1308 ,value3 -- Consolidation Set
1309 ,value4 -- Organization Id
1310 ,value5 -- Sort Order --9278285
1311 ,value6 --
1312 ,attribute1 --
1313 ,attribute2 --
1314 ,attribute3 -- Extract Start Date
1315 ,attribute4 -- Extract End Date
1316 ,attribute5 -- Extract Record 01 Flag
1317 )
1318 VALUES
1319 (l_session_id
1320 ,'NL ABP Pension Extracts'
1321 ,p_business_group_id
1322 ,g_conc_request_id
1323 ,p_ext_dfn_id
1324 ,p_payroll_id
1325 ,p_consolidation_set
1326 ,p_org_id
1327 ,p_sort_position --9278285
1328 ,NULL
1329 ,NULL
1330 ,NULL
1331 ,p_start_date
1332 ,p_end_date
1333 ,p_extract_rec_01
1334 );
1335
1336 COMMIT;
1337
1338 --
1339 -- Call the actual benefit extract process with the effective date as the
1340 -- extract end date along with the ext def. id and business group id.
1341 --
1342 IF g_debug THEN
1343 Hr_Utility.set_location('..Calling Benefit Ext Process'||l_proc_name, 6);
1344 END IF;
1345
1346 Ben_Ext_Thread.process
1347 (errbuf => l_errbuff,
1348 retcode => l_retcode,
1349 p_benefit_action_id => NULL,
1350 p_ext_dfn_id => p_ext_dfn_id,
1351 p_effective_date => p_end_date,
1352 p_business_group_id => p_business_group_id);
1353
1354 IF g_debug THEN
1355 Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
1356 END IF;
1357
1358 EXCEPTION
1359 WHEN Others THEN
1360 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
1361 RAISE;
1362 END Pension_Extract_Process;
1363
1364 -- ============================================================================
1365 -- ~ Update_Record_Values :
1366 -- ============================================================================
1367 PROCEDURE Update_Record_Values
1368 (p_ext_rcd_id IN ben_ext_rcd.ext_rcd_id%TYPE
1369 ,p_ext_data_element_name IN ben_ext_data_elmt.NAME%TYPE
1370 ,p_data_element_value IN ben_ext_rslt_dtl.val_01%TYPE
1371 ,p_data_ele_seqnum IN Number
1372 ,p_ext_dtl_rec IN OUT NOCOPY ben_ext_rslt_dtl%ROWTYPE
1373 ) IS
1374 CURSOR csr_seqnum (c_ext_rcd_id IN ben_ext_rcd.ext_rcd_id%TYPE
1375 ,c_ext_data_element_name IN ben_ext_data_elmt.NAME%TYPE
1376 ) IS
1377 SELECT der.ext_data_elmt_id,
1378 der.seq_num,
1379 ede.NAME
1380 FROM ben_ext_data_elmt_in_rcd der
1381 ,ben_ext_data_elmt ede
1382 WHERE der.ext_rcd_id = c_ext_rcd_id
1383 AND ede.ext_data_elmt_id = der.ext_data_elmt_id
1384 AND ede.NAME LIKE '%'|| c_ext_data_element_name
1385 ORDER BY seq_num;
1386
1387 l_seqnum_rec csr_seqnum%ROWTYPE;
1388 l_proc_name Varchar2(150):= g_proc_name||'Update_Record_Values';
1389 l_ext_dtl_rec_nc ben_ext_rslt_dtl%ROWTYPE;
1390 BEGIN
1391
1392 IF g_debug THEN
1393 Hr_Utility.set_location('Entering :'||l_proc_name, 5);
1394 END IF;
1395 -- nocopy changes
1396 l_ext_dtl_rec_nc := p_ext_dtl_rec;
1397
1398 IF p_data_ele_seqnum IS NULL THEN
1399 OPEN csr_seqnum ( c_ext_rcd_id => p_ext_rcd_id
1400 ,c_ext_data_element_name => p_ext_data_element_name);
1401 FETCH csr_seqnum INTO l_seqnum_rec;
1402 IF csr_seqnum%NOTFOUND THEN
1403 CLOSE csr_seqnum;
1404 ELSE
1405 CLOSE csr_seqnum;
1406 END IF;
1407 ELSE
1408 l_seqnum_rec.seq_num := p_data_ele_seqnum;
1409 END IF;
1410
1411 IF l_seqnum_rec.seq_num = 1 THEN
1412 p_ext_dtl_rec.val_01 := p_data_element_value;
1413 ELSIF l_seqnum_rec.seq_num = 2 THEN
1414 p_ext_dtl_rec.val_02 := p_data_element_value;
1415 ELSIF l_seqnum_rec.seq_num = 3 THEN
1416 p_ext_dtl_rec.val_03 := p_data_element_value;
1417 ELSIF l_seqnum_rec.seq_num = 4 THEN
1418 p_ext_dtl_rec.val_04 := p_data_element_value;
1419 ELSIF l_seqnum_rec.seq_num = 5 THEN
1420 p_ext_dtl_rec.val_05 := p_data_element_value;
1421 ELSIF l_seqnum_rec.seq_num = 6 THEN
1422 p_ext_dtl_rec.val_06 := p_data_element_value;
1423 ELSIF l_seqnum_rec.seq_num = 7 THEN
1424 p_ext_dtl_rec.val_07 := p_data_element_value;
1425 ELSIF l_seqnum_rec.seq_num = 8 THEN
1426 p_ext_dtl_rec.val_08 := p_data_element_value;
1427 ELSIF l_seqnum_rec.seq_num = 9 THEN
1428 p_ext_dtl_rec.val_09 := p_data_element_value;
1429 ELSIF l_seqnum_rec.seq_num = 10 THEN
1430 p_ext_dtl_rec.val_10 := p_data_element_value;
1431 ELSIF l_seqnum_rec.seq_num = 11 THEN
1432 p_ext_dtl_rec.val_11 := p_data_element_value;
1433 ELSIF l_seqnum_rec.seq_num = 12 THEN
1434 p_ext_dtl_rec.val_12 := p_data_element_value;
1435 ELSIF l_seqnum_rec.seq_num = 13 THEN
1436 p_ext_dtl_rec.val_13 := p_data_element_value;
1437 ELSIF l_seqnum_rec.seq_num = 14 THEN
1438 p_ext_dtl_rec.val_14 := p_data_element_value;
1439 ELSIF l_seqnum_rec.seq_num = 15 THEN
1440 p_ext_dtl_rec.val_15 := p_data_element_value;
1441 ELSIF l_seqnum_rec.seq_num = 16 THEN
1442 p_ext_dtl_rec.val_16 := p_data_element_value;
1443 ELSIF l_seqnum_rec.seq_num = 17 THEN
1444 p_ext_dtl_rec.val_17 := p_data_element_value;
1445 ELSIF l_seqnum_rec.seq_num = 18 THEN
1446 p_ext_dtl_rec.val_18 := p_data_element_value;
1447 ELSIF l_seqnum_rec.seq_num = 19 THEN
1448 p_ext_dtl_rec.val_19 := p_data_element_value;
1449 ELSIF l_seqnum_rec.seq_num = 20 THEN
1450 p_ext_dtl_rec.val_20 := p_data_element_value;
1451 ELSIF l_seqnum_rec.seq_num = 21 THEN
1452 p_ext_dtl_rec.val_21 := p_data_element_value;
1453 ELSIF l_seqnum_rec.seq_num = 22 THEN
1454 p_ext_dtl_rec.val_22 := p_data_element_value;
1455 ELSIF l_seqnum_rec.seq_num = 23THEN
1456 p_ext_dtl_rec.val_23 := p_data_element_value;
1457 ELSIF l_seqnum_rec.seq_num = 24 THEN
1458 p_ext_dtl_rec.val_24 := p_data_element_value;
1459 ELSIF l_seqnum_rec.seq_num = 25 THEN
1460 p_ext_dtl_rec.val_25 := p_data_element_value;
1461 ELSIF l_seqnum_rec.seq_num = 26 THEN
1462 p_ext_dtl_rec.val_26 := p_data_element_value;
1463 ELSIF l_seqnum_rec.seq_num = 27 THEN
1464 p_ext_dtl_rec.val_27 := p_data_element_value;
1465 ELSIF l_seqnum_rec.seq_num = 28 THEN
1466 p_ext_dtl_rec.val_28 := p_data_element_value;
1467 ELSIF l_seqnum_rec.seq_num = 29 THEN
1468 p_ext_dtl_rec.val_29 := p_data_element_value;
1469 ELSIF l_seqnum_rec.seq_num = 30 THEN
1470 p_ext_dtl_rec.val_30 := p_data_element_value;
1471 ELSIF l_seqnum_rec.seq_num = 31 THEN
1472 p_ext_dtl_rec.val_31 := p_data_element_value;
1473 ELSIF l_seqnum_rec.seq_num = 32 THEN
1474 p_ext_dtl_rec.val_32 := p_data_element_value;
1475 ELSIF l_seqnum_rec.seq_num = 33 THEN
1476 p_ext_dtl_rec.val_33 := p_data_element_value;
1477 ELSIF l_seqnum_rec.seq_num = 34 THEN
1478 p_ext_dtl_rec.val_34 := p_data_element_value;
1479 ELSIF l_seqnum_rec.seq_num = 35 THEN
1480 p_ext_dtl_rec.val_35 := p_data_element_value;
1481 ELSIF l_seqnum_rec.seq_num = 36 THEN
1482 p_ext_dtl_rec.val_36 := p_data_element_value;
1483 ELSIF l_seqnum_rec.seq_num = 37 THEN
1484 p_ext_dtl_rec.val_37 := p_data_element_value;
1485 ELSIF l_seqnum_rec.seq_num = 38 THEN
1486 p_ext_dtl_rec.val_38 := p_data_element_value;
1487 ELSIF l_seqnum_rec.seq_num = 39 THEN
1488 p_ext_dtl_rec.val_39 := p_data_element_value;
1489 ELSIF l_seqnum_rec.seq_num = 40 THEN
1490 p_ext_dtl_rec.val_40 := p_data_element_value;
1491 ELSIF l_seqnum_rec.seq_num = 41 THEN
1492 p_ext_dtl_rec.val_41 := p_data_element_value;
1493 ELSIF l_seqnum_rec.seq_num = 42 THEN
1494 p_ext_dtl_rec.val_42 := p_data_element_value;
1495 ELSIF l_seqnum_rec.seq_num = 43 THEN
1496 p_ext_dtl_rec.val_43 := p_data_element_value;
1497 ELSIF l_seqnum_rec.seq_num = 44 THEN
1498 p_ext_dtl_rec.val_44 := p_data_element_value;
1499 ELSIF l_seqnum_rec.seq_num = 45 THEN
1500 p_ext_dtl_rec.val_45 := p_data_element_value;
1501 ELSIF l_seqnum_rec.seq_num = 46 THEN
1502 p_ext_dtl_rec.val_46 := p_data_element_value;
1503 ELSIF l_seqnum_rec.seq_num = 47 THEN
1504 p_ext_dtl_rec.val_47 := p_data_element_value;
1505 ELSIF l_seqnum_rec.seq_num = 48 THEN
1506 p_ext_dtl_rec.val_48 := p_data_element_value;
1507 ELSIF l_seqnum_rec.seq_num = 49 THEN
1508 p_ext_dtl_rec.val_49 := p_data_element_value;
1509 ELSIF l_seqnum_rec.seq_num = 50 THEN
1510 p_ext_dtl_rec.val_50 := p_data_element_value;
1511 ELSIF l_seqnum_rec.seq_num = 51 THEN
1512 p_ext_dtl_rec.val_51 := p_data_element_value;
1513 ELSIF l_seqnum_rec.seq_num = 52 THEN
1514 p_ext_dtl_rec.val_52 := p_data_element_value;
1515 ELSIF l_seqnum_rec.seq_num = 53 THEN
1516 p_ext_dtl_rec.val_53 := p_data_element_value;
1517 ELSIF l_seqnum_rec.seq_num = 54 THEN
1518 p_ext_dtl_rec.val_54 := p_data_element_value;
1519 ELSIF l_seqnum_rec.seq_num = 55 THEN
1520 p_ext_dtl_rec.val_55 := p_data_element_value;
1521 ELSIF l_seqnum_rec.seq_num = 56 THEN
1522 p_ext_dtl_rec.val_56 := p_data_element_value;
1523 ELSIF l_seqnum_rec.seq_num = 57 THEN
1524 p_ext_dtl_rec.val_57 := p_data_element_value;
1525 ELSIF l_seqnum_rec.seq_num = 58 THEN
1526 p_ext_dtl_rec.val_58 := p_data_element_value;
1527 ELSIF l_seqnum_rec.seq_num = 58 THEN
1528 p_ext_dtl_rec.val_58 := p_data_element_value;
1529 ELSIF l_seqnum_rec.seq_num = 59 THEN
1530 p_ext_dtl_rec.val_59 := p_data_element_value;
1531 ELSIF l_seqnum_rec.seq_num = 60 THEN
1532 p_ext_dtl_rec.val_60 := p_data_element_value;
1533 ELSIF l_seqnum_rec.seq_num = 61 THEN
1534 p_ext_dtl_rec.val_61 := p_data_element_value;
1535 ELSIF l_seqnum_rec.seq_num = 62 THEN
1536 p_ext_dtl_rec.val_62 := p_data_element_value;
1537 ELSIF l_seqnum_rec.seq_num = 63 THEN
1538 p_ext_dtl_rec.val_63 := p_data_element_value;
1539 ELSIF l_seqnum_rec.seq_num = 64 THEN
1540 p_ext_dtl_rec.val_64 := p_data_element_value;
1541 ELSIF l_seqnum_rec.seq_num = 65 THEN
1542 p_ext_dtl_rec.val_65 := p_data_element_value;
1543 ELSIF l_seqnum_rec.seq_num = 66 THEN
1544 p_ext_dtl_rec.val_66 := p_data_element_value;
1545 ELSIF l_seqnum_rec.seq_num = 67 THEN
1546 p_ext_dtl_rec.val_67 := p_data_element_value;
1547 ELSIF l_seqnum_rec.seq_num = 68 THEN
1548 p_ext_dtl_rec.val_68 := p_data_element_value;
1549 ELSIF l_seqnum_rec.seq_num = 69 THEN
1550 p_ext_dtl_rec.val_69 := p_data_element_value;
1551 ELSIF l_seqnum_rec.seq_num = 70 THEN
1552 p_ext_dtl_rec.val_70 := p_data_element_value;
1553 ELSIF l_seqnum_rec.seq_num = 71 THEN
1554 p_ext_dtl_rec.val_71 := p_data_element_value;
1555 ELSIF l_seqnum_rec.seq_num = 72 THEN
1556 p_ext_dtl_rec.val_72 := p_data_element_value;
1557 ELSIF l_seqnum_rec.seq_num = 73 THEN
1558 p_ext_dtl_rec.val_73 := p_data_element_value;
1559 ELSIF l_seqnum_rec.seq_num = 74 THEN
1560 p_ext_dtl_rec.val_74 := p_data_element_value;
1561 ELSIF l_seqnum_rec.seq_num = 75 THEN
1562 p_ext_dtl_rec.val_75 := p_data_element_value;
1563 END IF;
1564
1565 IF g_debug THEN
1566 Hr_Utility.set_location('Leaving :'||l_proc_name, 25);
1567 END IF;
1568
1569 RETURN;
1570 EXCEPTION
1571 WHEN Others THEN
1572 -- nocopy changes
1573 p_ext_dtl_rec := l_ext_dtl_rec_nc;
1574 RAISE;
1575
1576 END Update_Record_Values;
1577
1578 -- ============================================================================
1579 -- ~ Ins_Rslt_Dtl : Inserts a record into the results detail record.
1580 -- ============================================================================
1581 PROCEDURE Ins_Rslt_Dtl(p_dtl_rec IN OUT NOCOPY ben_ext_rslt_dtl%ROWTYPE) IS
1582
1583 l_proc_name Varchar2(150) := g_proc_name||'Ins_Rslt_Dtl';
1584 l_dtl_rec_nc ben_ext_rslt_dtl%ROWTYPE;
1585
1586 BEGIN -- ins_rslt_dtl
1587
1588 IF g_debug THEN
1589 Hr_Utility.set_location('Entering :'||l_proc_name, 5);
1590 END IF;
1591 -- nocopy changes
1592 l_dtl_rec_nc := p_dtl_rec;
1593 -- Get the next sequence NUMBER to insert a record into the table
1594 SELECT ben_ext_rslt_dtl_s.NEXTVAL INTO p_dtl_rec.ext_rslt_dtl_id FROM dual;
1595
1596 INSERT INTO ben_ext_rslt_dtl
1597 (EXT_RSLT_DTL_ID
1598 ,EXT_RSLT_ID
1599 ,BUSINESS_GROUP_ID
1600 ,EXT_RCD_ID
1601 ,PERSON_ID
1602 ,VAL_01
1603 ,VAL_02
1604 ,VAL_03
1605 ,VAL_04
1606 ,VAL_05
1607 ,VAL_06
1608 ,VAL_07
1609 ,VAL_08
1610 ,VAL_09
1611 ,VAL_10
1612 ,VAL_11
1613 ,VAL_12
1614 ,VAL_13
1615 ,VAL_14
1616 ,VAL_15
1617 ,VAL_16
1618 ,VAL_17
1619 ,VAL_19
1620 ,VAL_18
1621 ,VAL_20
1622 ,VAL_21
1623 ,VAL_22
1624 ,VAL_23
1625 ,VAL_24
1626 ,VAL_25
1627 ,VAL_26
1628 ,VAL_27
1629 ,VAL_28
1630 ,VAL_29
1631 ,VAL_30
1632 ,VAL_31
1633 ,VAL_32
1634 ,VAL_33
1635 ,VAL_34
1636 ,VAL_35
1637 ,VAL_36
1638 ,VAL_37
1639 ,VAL_38
1640 ,VAL_39
1641 ,VAL_40
1642 ,VAL_41
1643 ,VAL_42
1644 ,VAL_43
1645 ,VAL_44
1646 ,VAL_45
1647 ,VAL_46
1648 ,VAL_47
1649 ,VAL_48
1650 ,VAL_49
1651 ,VAL_50
1652 ,VAL_51
1653 ,VAL_52
1654 ,VAL_53
1655 ,VAL_54
1656 ,VAL_55
1657 ,VAL_56
1658 ,VAL_57
1659 ,VAL_58
1660 ,VAL_59
1661 ,VAL_60
1662 ,VAL_61
1663 ,VAL_62
1664 ,VAL_63
1665 ,VAL_64
1666 ,VAL_65
1667 ,VAL_66
1668 ,VAL_67
1669 ,VAL_68
1670 ,VAL_69
1671 ,VAL_70
1672 ,VAL_71
1673 ,VAL_72
1674 ,VAL_73
1675 ,VAL_74
1676 ,VAL_75
1677 ,CREATED_BY
1678 ,CREATION_DATE
1679 ,LAST_UPDATE_DATE
1680 ,LAST_UPDATED_BY
1681 ,LAST_UPDATE_LOGIN
1682 ,PROGRAM_APPLICATION_ID
1683 ,PROGRAM_ID
1684 ,PROGRAM_UPDATE_DATE
1685 ,REQUEST_ID
1686 ,OBJECT_VERSION_NUMBER
1687 ,PRMY_SORT_VAL
1688 ,SCND_SORT_VAL
1689 ,THRD_SORT_VAL
1690 ,TRANS_SEQ_NUM
1691 ,RCRD_SEQ_NUM
1692 )
1693 VALUES
1694 (p_dtl_rec.EXT_RSLT_DTL_ID
1695 ,p_dtl_rec.EXT_RSLT_ID
1696 ,p_dtl_rec.BUSINESS_GROUP_ID
1697 ,p_dtl_rec.EXT_RCD_ID
1698 ,p_dtl_rec.PERSON_ID
1699 ,p_dtl_rec.VAL_01
1700 ,p_dtl_rec.VAL_02
1701 ,p_dtl_rec.VAL_03
1702 ,p_dtl_rec.VAL_04
1703 ,p_dtl_rec.VAL_05
1704 ,p_dtl_rec.VAL_06
1705 ,p_dtl_rec.VAL_07
1706 ,p_dtl_rec.VAL_08
1707 ,p_dtl_rec.VAL_09
1708 ,p_dtl_rec.VAL_10
1709 ,p_dtl_rec.VAL_11
1710 ,p_dtl_rec.VAL_12
1711 ,p_dtl_rec.VAL_13
1712 ,p_dtl_rec.VAL_14
1713 ,p_dtl_rec.VAL_15
1714 ,p_dtl_rec.VAL_16
1715 ,p_dtl_rec.VAL_17
1716 ,p_dtl_rec.VAL_19
1717 ,p_dtl_rec.VAL_18
1718 ,p_dtl_rec.VAL_20
1719 ,p_dtl_rec.VAL_21
1720 ,p_dtl_rec.VAL_22
1721 ,p_dtl_rec.VAL_23
1722 ,p_dtl_rec.VAL_24
1723 ,p_dtl_rec.VAL_25
1724 ,p_dtl_rec.VAL_26
1725 ,p_dtl_rec.VAL_27
1726 ,p_dtl_rec.VAL_28
1727 ,p_dtl_rec.VAL_29
1728 ,p_dtl_rec.VAL_30
1729 ,p_dtl_rec.VAL_31
1730 ,p_dtl_rec.VAL_32
1731 ,p_dtl_rec.VAL_33
1732 ,p_dtl_rec.VAL_34
1733 ,p_dtl_rec.VAL_35
1734 ,p_dtl_rec.VAL_36
1735 ,p_dtl_rec.VAL_37
1736 ,p_dtl_rec.VAL_38
1737 ,p_dtl_rec.VAL_39
1738 ,p_dtl_rec.VAL_40
1739 ,p_dtl_rec.VAL_41
1740 ,p_dtl_rec.VAL_42
1741 ,p_dtl_rec.VAL_43
1742 ,p_dtl_rec.VAL_44
1743 ,p_dtl_rec.VAL_45
1744 ,p_dtl_rec.VAL_46
1745 ,p_dtl_rec.VAL_47
1746 ,p_dtl_rec.VAL_48
1747 ,p_dtl_rec.VAL_49
1748 ,p_dtl_rec.VAL_50
1749 ,p_dtl_rec.VAL_51
1750 ,p_dtl_rec.VAL_52
1751 ,p_dtl_rec.VAL_53
1752 ,p_dtl_rec.VAL_54
1753 ,p_dtl_rec.VAL_55
1754 ,p_dtl_rec.VAL_56
1755 ,p_dtl_rec.VAL_57
1756 ,p_dtl_rec.VAL_58
1757 ,p_dtl_rec.VAL_59
1758 ,p_dtl_rec.VAL_60
1759 ,p_dtl_rec.VAL_61
1760 ,p_dtl_rec.VAL_62
1761 ,p_dtl_rec.VAL_63
1762 ,p_dtl_rec.VAL_64
1763 ,p_dtl_rec.VAL_65
1764 ,p_dtl_rec.VAL_66
1765 ,p_dtl_rec.VAL_67
1766 ,p_dtl_rec.VAL_68
1767 ,p_dtl_rec.VAL_69
1768 ,p_dtl_rec.VAL_70
1769 ,p_dtl_rec.VAL_71
1770 ,p_dtl_rec.VAL_72
1771 ,p_dtl_rec.VAL_73
1772 ,p_dtl_rec.VAL_74
1773 ,p_dtl_rec.VAL_75
1774 ,p_dtl_rec.CREATED_BY
1775 ,p_dtl_rec.CREATION_DATE
1776 ,p_dtl_rec.LAST_UPDATE_DATE
1777 ,p_dtl_rec.LAST_UPDATED_BY
1778 ,p_dtl_rec.LAST_UPDATE_LOGIN
1779 ,p_dtl_rec.PROGRAM_APPLICATION_ID
1780 ,p_dtl_rec.PROGRAM_ID
1781 ,p_dtl_rec.PROGRAM_UPDATE_DATE
1782 ,p_dtl_rec.REQUEST_ID
1783 ,p_dtl_rec.OBJECT_VERSION_NUMBER
1784 ,p_dtl_rec.PRMY_SORT_VAL
1785 ,p_dtl_rec.SCND_SORT_VAL
1786 ,p_dtl_rec.THRD_SORT_VAL
1787 ,p_dtl_rec.TRANS_SEQ_NUM
1788 ,p_dtl_rec.RCRD_SEQ_NUM
1789 );
1790
1791 IF g_debug THEN
1792 Hr_Utility.set_location('Leaving :'||l_proc_name, 25);
1793 END IF;
1794
1795 RETURN;
1796
1797 EXCEPTION
1798 WHEN Others THEN
1799 Hr_Utility.set_location('Leaving :'||l_proc_name, 25);
1800 p_dtl_rec := l_dtl_rec_nc;
1801 RAISE;
1802 END Ins_Rslt_Dtl;
1803
1804 -- ============================================================================
1805 -- ~ Upd_Rslt_Dtl : Updates the primary assignment record in results detail table
1806 -- ============================================================================
1807 PROCEDURE Upd_Rslt_Dtl(p_dtl_rec IN ben_ext_rslt_dtl%ROWTYPE ) IS
1808
1809 l_proc_name Varchar2(150):= g_proc_name||'upd_rslt_dtl';
1810
1811 BEGIN -- Upd_Rslt_Dtl
1812 UPDATE ben_ext_rslt_dtl
1813 SET VAL_01 = p_dtl_rec.VAL_01
1814 ,VAL_02 = p_dtl_rec.VAL_02
1815 ,VAL_03 = p_dtl_rec.VAL_03
1816 ,VAL_04 = p_dtl_rec.VAL_04
1817 ,VAL_05 = p_dtl_rec.VAL_05
1818 ,VAL_06 = p_dtl_rec.VAL_06
1819 ,VAL_07 = p_dtl_rec.VAL_07
1820 ,VAL_08 = p_dtl_rec.VAL_08
1821 ,VAL_09 = p_dtl_rec.VAL_09
1822 ,VAL_10 = p_dtl_rec.VAL_10
1823 ,VAL_11 = p_dtl_rec.VAL_11
1824 ,VAL_12 = p_dtl_rec.VAL_12
1825 ,VAL_13 = p_dtl_rec.VAL_13
1826 ,VAL_14 = p_dtl_rec.VAL_14
1827 ,VAL_15 = p_dtl_rec.VAL_15
1828 ,VAL_16 = p_dtl_rec.VAL_16
1829 ,VAL_17 = p_dtl_rec.VAL_17
1830 ,VAL_19 = p_dtl_rec.VAL_19
1831 ,VAL_18 = p_dtl_rec.VAL_18
1832 ,VAL_20 = p_dtl_rec.VAL_20
1833 ,VAL_21 = p_dtl_rec.VAL_21
1834 ,VAL_22 = p_dtl_rec.VAL_22
1835 ,VAL_23 = p_dtl_rec.VAL_23
1836 ,VAL_24 = p_dtl_rec.VAL_24
1837 ,VAL_25 = p_dtl_rec.VAL_25
1838 ,VAL_26 = p_dtl_rec.VAL_26
1839 ,VAL_27 = p_dtl_rec.VAL_27
1840 ,VAL_28 = p_dtl_rec.VAL_28
1841 ,VAL_29 = p_dtl_rec.VAL_29
1842 ,VAL_30 = p_dtl_rec.VAL_30
1843 ,VAL_31 = p_dtl_rec.VAL_31
1844 ,VAL_32 = p_dtl_rec.VAL_32
1845 ,VAL_33 = p_dtl_rec.VAL_33
1846 ,VAL_34 = p_dtl_rec.VAL_34
1847 ,VAL_35 = p_dtl_rec.VAL_35
1848 ,VAL_36 = p_dtl_rec.VAL_36
1849 ,VAL_37 = p_dtl_rec.VAL_37
1850 ,VAL_38 = p_dtl_rec.VAL_38
1851 ,VAL_39 = p_dtl_rec.VAL_39
1852 ,VAL_40 = p_dtl_rec.VAL_40
1853 ,VAL_41 = p_dtl_rec.VAL_41
1854 ,VAL_42 = p_dtl_rec.VAL_42
1855 ,VAL_43 = p_dtl_rec.VAL_43
1856 ,VAL_44 = p_dtl_rec.VAL_44
1857 ,VAL_45 = p_dtl_rec.VAL_45
1858 ,VAL_46 = p_dtl_rec.VAL_46
1859 ,VAL_47 = p_dtl_rec.VAL_47
1860 ,VAL_48 = p_dtl_rec.VAL_48
1861 ,VAL_49 = p_dtl_rec.VAL_49
1862 ,VAL_50 = p_dtl_rec.VAL_50
1863 ,VAL_51 = p_dtl_rec.VAL_51
1864 ,VAL_52 = p_dtl_rec.VAL_52
1865 ,VAL_53 = p_dtl_rec.VAL_53
1866 ,VAL_54 = p_dtl_rec.VAL_54
1867 ,VAL_55 = p_dtl_rec.VAL_55
1868 ,VAL_56 = p_dtl_rec.VAL_56
1869 ,VAL_57 = p_dtl_rec.VAL_57
1870 ,VAL_58 = p_dtl_rec.VAL_58
1871 ,VAL_59 = p_dtl_rec.VAL_59
1872 ,VAL_60 = p_dtl_rec.VAL_60
1873 ,VAL_61 = p_dtl_rec.VAL_61
1874 ,VAL_62 = p_dtl_rec.VAL_62
1875 ,VAL_63 = p_dtl_rec.VAL_63
1876 ,VAL_64 = p_dtl_rec.VAL_64
1877 ,VAL_65 = p_dtl_rec.VAL_65
1878 ,VAL_66 = p_dtl_rec.VAL_66
1879 ,VAL_67 = p_dtl_rec.VAL_67
1880 ,VAL_68 = p_dtl_rec.VAL_68
1881 ,VAL_69 = p_dtl_rec.VAL_69
1882 ,VAL_70 = p_dtl_rec.VAL_70
1883 ,VAL_71 = p_dtl_rec.VAL_71
1884 ,VAL_72 = p_dtl_rec.VAL_72
1885 ,VAL_73 = p_dtl_rec.VAL_73
1886 ,VAL_74 = p_dtl_rec.VAL_74
1887 ,VAL_75 = p_dtl_rec.VAL_75
1888 ,OBJECT_VERSION_NUMBER = p_dtl_rec.OBJECT_VERSION_NUMBER
1889 ,THRD_SORT_VAL = p_dtl_rec.THRD_SORT_VAL
1890 ,prmy_sort_val =p_dtl_rec.prmy_sort_val
1891 WHERE ext_rslt_dtl_id = p_dtl_rec.ext_rslt_dtl_id;
1892
1893 RETURN;
1894
1895 EXCEPTION
1896 WHEN Others THEN
1897 RAISE;
1898 END Upd_Rslt_Dtl;
1899
1900 -- =============================================================================
1901 -- Process_Ext_Rslt_Dtl_Rec:
1902 -- =============================================================================
1903 PROCEDURE Process_Ext_Rslt_Dtl_Rec
1904 (p_assignment_id IN per_all_assignments.assignment_id%TYPE
1905 ,p_organization_id IN per_all_assignments.organization_id%TYPE DEFAULT NULL
1906 ,p_effective_date IN Date
1907 ,p_ext_dtl_rcd_id IN ben_ext_rcd.ext_rcd_id%TYPE
1908 ,p_rslt_rec IN OUT NOCOPY ben_ext_rslt_dtl%ROWTYPE
1909 ,p_asgaction_no IN Number DEFAULT NULL
1910 ,p_error_message OUT NOCOPY Varchar2) IS
1911
1912 CURSOR csr_rule_ele
1913 (c_ext_rcd_id IN ben_ext_data_elmt_in_rcd.ext_rcd_id%TYPE) IS
1914 SELECT a.ext_data_elmt_in_rcd_id
1915 ,a.seq_num
1916 ,a.sprs_cd
1917 ,a.strt_pos
1918 ,a.dlmtr_val
1919 ,a.rqd_flag
1920 ,b.ext_data_elmt_id
1921 ,b.data_elmt_typ_cd
1922 ,b.data_elmt_rl
1923 ,b.NAME
1924 ,Hr_General.decode_lookup('BEN_EXT_FRMT_MASK', b.frmt_mask_cd) frmt_mask_cd
1925 ,b.frmt_mask_cd frmt_mask_lookup_cd
1926 ,b.string_val
1927 ,b.dflt_val
1928 ,b.max_length_num
1929 ,b.just_cd
1930 FROM ben_ext_data_elmt b,
1931 ben_ext_data_elmt_in_rcd a
1932 WHERE a.ext_data_elmt_id = b.ext_data_elmt_id
1933 AND b.data_elmt_typ_cd = 'R'
1934 AND a.ext_rcd_id = c_ext_rcd_id
1935 -- AND a.hide_flag = 'N'
1936 ORDER BY a.seq_num;
1937
1938 CURSOR csr_ff_type ( c_formula_type_id IN ff_formulas_f.formula_id%TYPE
1939 ,c_effective_date IN Date) IS
1940 SELECT formula_type_id
1941 FROM ff_formulas_f
1942 WHERE formula_id = c_formula_type_id
1943 AND c_effective_date BETWEEN effective_start_date
1944 AND effective_end_date;
1945
1946 CURSOR c_get_org_id IS
1947 SELECT organization_id,business_group_id
1948 FROM per_all_assignments_f
1949 WHERE assignment_id = p_assignment_id
1950 AND business_group_id = g_business_group_id
1951 AND p_effective_date BETWEEN effective_start_date
1952 AND effective_end_date;
1953
1954
1955
1956 l_proc_name Varchar2(150) := g_proc_name ||'Process_Ext_Rslt_Dtl_Rec';
1957 l_foumula_type_id ff_formulas_f.formula_id%TYPE;
1958 l_outputs Ff_Exec.outputs_t;
1959 l_ff_value ben_ext_rslt_dtl.val_01%TYPE;
1960 l_ff_value_fmt ben_ext_rslt_dtl.val_01%TYPE;
1961 l_org_id per_all_assignments_f.organization_id%TYPE;
1962 l_bgid per_all_assignments_f.business_group_id%TYPE;
1963
1964
1965 BEGIN
1966
1967 IF g_debug THEN
1968 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
1969 END IF;
1970
1971 OPEN c_get_org_id;
1972 FETCH c_get_org_id INTO l_org_id,l_bgid;
1973 CLOSE c_get_org_id;
1974
1975
1976 IF g_debug THEN
1977 Hr_Utility.set_location('p_ext_dtl_rcd_id: '||p_ext_dtl_rcd_id, 5);
1978 Hr_Utility.set_location('p_assignment_id: '||p_assignment_id, 5);
1979 END IF;
1980
1981 FOR i IN csr_rule_ele( c_ext_rcd_id => p_ext_dtl_rcd_id)
1982 LOOP
1983 OPEN csr_ff_type(c_formula_type_id => i.data_elmt_rl
1984 ,c_effective_date => p_effective_date);
1985 FETCH csr_ff_type INTO l_foumula_type_id;
1986 CLOSE csr_ff_type;
1987
1988 IF g_debug THEN
1989 Hr_Utility.set_location('l_foumula_type_id: '||l_foumula_type_id, 5);
1990 END IF;
1991
1992 IF l_foumula_type_id = -413 THEN -- person level rule
1993 l_outputs := Benutils.formula
1994 (p_formula_id => i.data_elmt_rl
1995 ,p_effective_date => p_effective_date
1996 ,p_assignment_id => p_assignment_id
1997 ,p_organization_id => l_org_id
1998 ,p_business_group_id => l_bgid
1999 ,p_jurisdiction_code => NULL
2000 ,p_param1 => 'EXT_DFN_ID'
2001 ,p_param1_value => To_Char(Nvl(Ben_Ext_Thread.g_ext_dfn_id, -1))
2002 ,p_param2 => 'EXT_RSLT_ID'
2003 ,p_param2_value => To_Char(Nvl(Ben_Ext_Thread.g_ext_rslt_id, -1))
2004 );
2005 l_ff_value := l_outputs(l_outputs.FIRST).VALUE;
2006 BEGIN
2007 IF i.frmt_mask_lookup_cd IS NOT NULL AND
2008 l_ff_value IS NOT NULL THEN
2009 IF Substr(i.frmt_mask_lookup_cd,1,1) = 'N' THEN
2010 IF g_debug THEN
2011 Hr_Utility.set_location('..Applying NUMBER format mask
2012 :ben_ext_fmt.apply_format_mask',50);
2013 END IF;
2014 l_ff_value_fmt := Ben_Ext_Fmt.apply_format_mask(To_Number(l_ff_value), i.frmt_mask_cd);
2015 l_ff_value := l_ff_value_fmt;
2016 ELSIF Substr(i.frmt_mask_lookup_cd,1,1) = 'D' THEN
2017 IF g_debug THEN
2018 Hr_Utility.set_location('..Applying Date format mask
2019 :ben_ext_fmt.apply_format_mask',55);
2020 END IF;
2021 l_ff_value_fmt := Ben_Ext_Fmt.apply_format_mask(Fnd_Date.canonical_to_date(l_ff_value),
2022 i.frmt_mask_cd);
2023 l_ff_value := l_ff_value_fmt;
2024 END IF;
2025 END IF;
2026 EXCEPTION -- incase l_ff_value is not valid for formatting, just don't format it.
2027 WHEN Others THEN
2028 NULL;
2029 END;
2030 Update_Record_Values (p_ext_rcd_id => p_ext_dtl_rcd_id
2031 ,p_ext_data_element_name => NULL
2032 ,p_data_element_value => l_ff_value
2033 ,p_data_ele_seqnum => i.seq_num
2034 ,p_ext_dtl_rec => p_rslt_rec);
2035 END IF;
2036 END LOOP; --For i in csr_rule_ele
2037
2038 p_rslt_rec.prmy_sort_val := p_assignment_id;
2039
2040 Ins_Rslt_Dtl(p_dtl_rec => p_rslt_rec);
2041
2042 IF g_debug THEN
2043 Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
2044 END IF;
2045
2046 EXCEPTION
2047 WHEN Others THEN
2048 Hr_Utility.set_location('..error',85);
2049 Hr_Utility.set_location('SQL-ERRM :'||SQLERRM,87);
2050 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
2051 END Process_Ext_Rslt_Dtl_Rec;
2052
2053 -- ===============================================================================
2054 -- ~ Get_ConcProg_Information : Common function to get the concurrent program parameters
2055 -- ===============================================================================
2056 FUNCTION Get_ConcProg_Information
2057 (p_header_type IN Varchar2
2058 ,p_error_message OUT NOCOPY Varchar2) RETURN Varchar2 IS
2059
2060 l_proc_name Varchar2(150) := g_proc_name ||'.Get_ConcProg_Information';
2061 l_return_value Varchar2(1000);
2062
2063 BEGIN
2064
2065 IF g_debug THEN
2066 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
2067 END IF;
2068
2069 IF p_header_type = 'EXTRACT_NAME' THEN
2070 l_return_value := g_conc_prog_details(0).extract_name;
2071 ELSIF p_header_type = 'REPORT_OPTION' THEN
2072 l_return_value := g_conc_prog_details(0).reporting_options;
2073 ELSIF p_header_type = 'SELECTION_CRITERIA' THEN
2074 l_return_value := g_conc_prog_details(0).selection_criteria;
2075 ELSIF p_header_type = 'ELE_SET' THEN
2076 l_return_value := g_conc_prog_details(0).elementset;
2077 ELSIF p_header_type = 'ELE_NAME' THEN
2078 l_return_value := g_conc_prog_details(0).elementname;
2079 ELSIF p_header_type = 'BGN_DT_PAID' THEN
2080 l_return_value := g_conc_prog_details(0).beginningdt;
2081 ELSIF p_header_type = 'END_DT_PAID' THEN
2082 l_return_value := g_conc_prog_details(0).endingdt;
2083 ELSIF p_header_type = 'GRE' THEN
2084 l_return_value := g_conc_prog_details(0).grename;
2085 ELSIF p_header_type = 'PAYROLL_NAME' THEN
2086 IF g_debug THEN
2087 Hr_Utility.set_location('PAYROLL_NAME: '||g_conc_prog_details(0).payrollname, 5);
2088 END IF;
2089 l_return_value := g_conc_prog_details(0).payrollname;
2090 ELSIF p_header_type = 'CON_SET' THEN
2091 l_return_value := g_conc_prog_details(0).consolset;
2092 IF g_debug THEN
2093 Hr_Utility.set_location('CON_SET: '||l_return_value, 5);
2094 END IF;
2095 END IF;
2096 IF g_debug THEN
2097 Hr_Utility.set_location('Leaving: '||l_proc_name, 45);
2098 END IF;
2099
2100 RETURN l_return_value;
2101 EXCEPTION
2102 WHEN Others THEN
2103 p_error_message :='SQL-ERRM :'||SQLERRM;
2104 Hr_Utility.set_location('..Exception Others Raised at Get_ConcProg_Information'||p_error_message,40);
2105 Hr_Utility.set_location('Leaving: '||l_proc_name, 45);
2106 RETURN l_return_value;
2107 END Get_ConcProg_Information;
2108
2109 -- =============================================================================
2110 -- ~ Get_Balance_Value: Gets the balance value for a given balance name for that
2111 -- ~ Assign.Id as of an effective date
2112 -- =============================================================================
2113 FUNCTION Get_Balance_Value_Eff_Dt
2114 (p_assignment_id IN NUMBER
2115 ,p_business_group_id IN NUMBER
2116 ,p_balance_name IN VARCHAR2
2117 ,p_error_message OUT NOCOPY VARCHAR2
2118 ,p_start_date IN DATE
2119 ,p_end_date IN DATE)
2120 RETURN NUMBER IS
2121
2122 l_defined_balance_id pay_defined_balances.defined_balance_id%TYPE;
2123 l_balance_amount NUMBER :=0;
2124 l_bal_total_amt NUMBER :=0;
2125 l_dimension_name VARCHAR2(100);
2126 i per_all_assignments_f.business_group_id%TYPE;
2127 l_legislation_code per_business_groups.legislation_code%TYPE;
2128 l_balance_type_id pay_balance_types.balance_type_id%TYPE;
2129 l_index NUMBER;
2130
2131 BEGIN
2132
2133 i := p_business_group_id;
2134 IF g_debug THEN
2135 Hr_Utility.set_location('Entering Get_Balance_Value function:', 5);
2136 END IF;
2137 -- Check this balance already exists in record
2138 -- If it exists then get the balance type id
2139 FOR num IN 1..g_balance_detls.Count LOOP
2140 IF g_balance_detls(num).balance_name = p_balance_name THEN
2141 l_balance_type_id := g_balance_detls(num).balance_type_id;
2142 l_defined_balance_id := g_balance_detls(num).defined_balance_id;
2143 EXIT;
2144 END IF;
2145 END LOOP;
2146 -- Get the balance type id for a balance name ,if it does not exist in record
2147 IF l_balance_type_id IS NULL THEN
2148 OPEN csr_bal_typid (c_balance_name => p_balance_name
2149 ,c_business_group_id => p_business_group_id
2150 ,c_legislation_code => g_legislation_code);
2151 FETCH csr_bal_typid INTO l_balance_type_id;
2152 CLOSE csr_bal_typid;
2153 -- Get the def. balance id for a given balance type id
2154 IF l_balance_type_id IS NOT NULL THEN
2155 OPEN csr_asg_balid
2156 (c_balance_type_id => l_balance_type_id
2157 ,c_balance_dimension_id => g_asgrun_dim_id
2158 ,c_business_group_id => p_business_group_id);
2159 FETCH csr_asg_balid INTO l_defined_balance_id;
2160 CLOSE csr_asg_balid;
2161 END IF;
2162 l_index := g_balance_detls.Count + 1;
2163 g_balance_detls(l_index).balance_name := p_balance_name;
2164 g_balance_detls(l_index).balance_type_id := l_balance_type_id;
2165 g_balance_detls(l_index).defined_balance_id := l_defined_balance_id;
2166 END IF;
2167
2168 IF l_defined_balance_id IS NOT NULL THEN
2169 --Get the Assignment action ids for assignment Id
2170 FOR asgact_rec IN csr_asg_act
2171 (c_assignment_id => p_assignment_id
2172 ,c_payroll_id => g_extract_params(i).payroll_id
2173 ,c_con_set_id => g_extract_params(i).con_set_id
2174 ,c_start_date => p_start_date
2175 ,c_end_date => p_end_date
2176 )
2177 LOOP
2178 l_balance_amount := Pay_Balance_Pkg.get_value
2179 (p_defined_balance_id => l_defined_balance_id,
2180 p_assignment_action_id => asgact_rec.assignment_action_id );
2181 l_bal_total_amt := l_bal_total_amt + Nvl(l_balance_amount,0);
2182 END LOOP; -- For Loop
2183 END IF; -- If l_defined_balance_id
2184 RETURN l_bal_total_amt;
2185
2186 EXCEPTION
2187 WHEN Others THEN
2188 p_error_message :='SQL-ERRM :'||SQLERRM;
2189 Hr_Utility.set_location('..'||p_error_message,85);
2190 Hr_Utility.set_location('Leaving Get_Balance_Value function:', 80);
2191 RETURN l_bal_total_amt;
2192 END Get_Balance_Value_Eff_Dt;
2193
2194 -- =============================================================================
2195 -- ~ Get_Balance_Value: Gets the balance value for a given balance name for that
2196 -- ~ Assign.Id.
2197 -- =============================================================================
2198 FUNCTION Get_Balance_Value
2199 (p_assignment_id IN NUMBER
2200 ,p_business_group_id IN NUMBER
2201 ,p_balance_name IN VARCHAR2
2202 ,p_error_message OUT NOCOPY VARCHAR2 )
2203 RETURN NUMBER IS
2204
2205 l_bal_total_amt NUMBER :=0;
2206 i per_all_assignments_f.business_group_id%TYPE;
2207
2208 BEGIN
2209
2210 i := p_business_group_id;
2211
2212 IF g_debug THEN
2213 Hr_Utility.set_location('Entering Get_Balance_Value function:', 5);
2214 END IF;
2215
2216 l_bal_total_amt := Get_Balance_Value_Eff_Dt
2217 (p_assignment_id => p_assignment_id
2218 ,p_business_group_id => p_business_group_id
2219 ,p_balance_name => p_balance_name
2220 ,p_error_message => p_error_message
2221 ,p_start_date => g_extract_params(i).extract_start_date
2222 ,p_end_date => g_extract_params(i).extract_end_date
2223 );
2224
2225 RETURN l_bal_total_amt;
2226
2227 EXCEPTION
2228 WHEN Others THEN
2229 p_error_message :='SQL-ERRM :'||SQLERRM;
2230 Hr_Utility.set_location('..'||p_error_message,85);
2231 Hr_Utility.set_location('Leaving Get_Balance_Value function:', 80);
2232 RETURN l_bal_total_amt;
2233 END Get_Balance_Value;
2234
2235 -- ====================================================================
2236 -- ~ Set_ConcProg_Parameter_Values : Used to get the conc program parameters
2237 -- values for passed ids and also setting the values into the global records
2238 -- ====================================================================
2239 PROCEDURE Set_ConcProg_Parameter_Values
2240 (p_ext_dfn_id IN Number
2241 ,p_start_date IN Varchar2
2242 ,p_end_date IN Varchar2
2243 ,p_payroll_id IN Number
2244 ,p_con_set IN Number
2245 ,p_org_id IN Number
2246 ) IS
2247
2248 CURSOR csr_ext_name(c_ext_dfn_id IN Number
2249 )IS
2250 SELECT Substr(ed.NAME,1,240)
2251 FROM ben_ext_dfn ed
2252 WHERE ed.ext_dfn_id = p_ext_dfn_id;
2253
2254 CURSOR csr_pay_name(c_payroll_id IN Number
2255 ,c_end_date IN Date
2256 )IS
2257 SELECT pay.payroll_name
2258 FROM pay_payrolls_f pay
2259 WHERE pay.payroll_id = c_payroll_id
2260 AND c_end_date BETWEEN pay.effective_start_date
2261 AND pay.effective_end_date;
2262
2263 CURSOR csr_con_set (c_con_set IN Number
2264 )IS
2265 SELECT con.consolidation_set_name
2266 FROM pay_consolidation_sets con
2267 WHERE con.consolidation_set_id = c_con_set;
2268
2269
2270 l_proc_name Varchar2(150) := g_proc_name ||'Set_ConcProg_Parameter_Values';
2271 l_extract_name ben_ext_dfn.NAME%TYPE;
2272 l_payroll_name PAY_PAYROLLS_F.PAYROLL_NAME%TYPE ;
2273 l_con_set_name PAY_CONSOLIDATION_SETS.CONSOLIDATION_SET_NAME%TYPE;
2274 l_org_name hr_all_organization_units.NAME%TYPE;
2275
2276
2277 BEGIN
2278 IF g_debug THEN
2279 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
2280 END IF;
2281
2282 OPEN csr_ext_name( c_ext_dfn_id => p_ext_dfn_id);
2283 FETCH csr_ext_name INTO l_extract_name;
2284 CLOSE csr_ext_name;
2285
2286 IF p_payroll_id IS NOT NULL THEN
2287 OPEN csr_pay_name( c_payroll_id => p_payroll_id
2288 ,c_end_date =>p_end_date
2289 );
2290 FETCH csr_pay_name INTO l_payroll_name;
2291 CLOSE csr_pay_name;
2292 END IF;
2293 IF p_con_set IS NOT NULL THEN
2294 OPEN csr_con_set( c_con_set => p_con_set);
2295 FETCH csr_con_set INTO l_con_set_name;
2296 CLOSE csr_con_set;
2297 END IF;
2298
2299 IF p_org_id IS NOT NULL THEN
2300 OPEN csr_org_name( c_org_id => p_org_id);
2301 FETCH csr_org_name INTO l_org_name;
2302 CLOSE csr_org_name;
2303 END IF;
2304
2305
2306 --Setting the values
2307 g_conc_prog_details(0).extract_name := l_extract_name;
2308 g_conc_prog_details(0).beginningdt := p_start_date;
2309 g_conc_prog_details(0).endingdt := p_end_date;
2310 g_conc_prog_details(0).payrollname := l_payroll_name;
2311 g_conc_prog_details(0).consolset := l_con_set_name;
2312 g_conc_prog_details(0).orgname := l_org_name;
2313 g_conc_prog_details(0).orgid := p_org_id;
2314
2315 IF g_debug THEN
2316 Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
2317 END IF;
2318
2319 EXCEPTION
2320 WHEN Others THEN
2321 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
2322 END Set_ConcProg_Parameter_Values;
2323
2324 -- ====================================================================
2325 -- Function to check if RR exist for an ass act/element combination
2326 -- ====================================================================
2327 FUNCTION Chk_Rr_Exist (p_ass_act_id IN NUMBER
2328 ,p_element_type_id IN NUMBER ) RETURN BOOLEAN IS
2329
2330 CURSOR c_ass_act IS
2331 SELECT 1
2332 FROM pay_run_results
2333 WHERE assignment_action_id = p_ass_act_id
2334 AND element_type_id = p_element_type_id;
2335
2336 l_dummy NUMBER;
2337 l_proc_name VARCHAR2(150) := g_proc_name ||'chk_rr_exist';
2338
2339 BEGIN
2340
2341 IF g_debug THEN
2342 hr_utility.set_location('Entering: '||l_proc_name,5);
2343 hr_utility.set_location('...Ass Act is : '||p_ass_act_id,10);
2344 hr_utility.set_location('...Element Type is : '||p_element_type_id,15);
2345 END IF;
2346
2347 OPEN c_ass_act;
2348 FETCH c_ass_act INTO l_dummy;
2349
2350 IF c_ass_act%FOUND THEN
2351 IF g_debug THEN
2352 hr_utility.set_location('...Run Results found : ',20);
2353 hr_utility.set_location('Leaving : '||l_proc_name,30);
2354 END IF;
2355 CLOSE c_ass_act;
2356 RETURN TRUE;
2357 ELSE
2358 IF g_debug THEN
2359 hr_utility.set_location('...Run Results not found : ',20);
2360 hr_utility.set_location('Leaving : '||l_proc_name,30);
2361 END IF;
2362 CLOSE c_ass_act;
2363 RETURN FALSE;
2364 END IF;
2365
2366 END chk_rr_exist;
2367
2368 --
2369 -- Function to check if there is a change in hire date
2370 --
2371 FUNCTION Chk_Chg_Hire_Dt (p_person_id IN NUMBER
2372 ,p_business_group_id IN NUMBER
2373 ,p_old_hire_date OUT NOCOPY DATE
2374 ,p_new_hire_date OUT NOCOPY DATE )
2375 RETURN NUMBER IS
2376
2377 CURSOR c_hire_dt_chg(c_person_id IN NUMBER) IS
2378 SELECT old_val1 old_date,
2379 new_val1 new_date
2380 FROM ben_ext_chg_evt_log
2381 WHERE person_id = p_person_id
2382 AND chg_evt_cd = 'COPOS'
2383 AND fnd_date.canonical_to_date(prmtr_09)
2384 BETWEEN g_extract_params(p_business_group_id).extract_start_date AND
2385 g_extract_params(p_business_group_id).extract_end_date
2386 ORDER BY ext_chg_evt_log_id DESC;
2387
2388 l_old_hire_can ben_ext_chg_evt_log.old_val1%TYPE;
2389 l_new_hire_can ben_ext_chg_evt_log.new_val1%TYPE;
2390 l_ret_val NUMBER := 0;
2391
2392 BEGIN
2393
2394 OPEN c_hire_dt_chg(c_person_id => p_person_id);
2395 FETCH c_hire_dt_chg INTO l_old_hire_can,l_new_hire_can;
2396 IF c_hire_dt_chg%NOTFOUND THEN
2397 p_new_hire_date := NULL;
2398 p_old_hire_date := NULL;
2399 l_ret_val := 0;
2400 ELSIF c_hire_dt_chg%FOUND THEN
2401 p_new_hire_date := to_nl_date(l_new_hire_can,'DD-MM-RRRR');
2402 p_old_hire_date := to_nl_date(l_old_hire_can,'DD-MM-RRRR');
2403 l_ret_val := 1;
2404 END IF;
2405 CLOSE c_hire_dt_chg;
2406
2407 RETURN l_ret_val;
2408
2409 END chk_chg_hire_dt;
2410
2411 -- =============================================================================
2412 -- Get_Asg_Seq_Num:
2413 -- =============================================================================
2414 FUNCTION Get_Asg_Seq_Num
2415 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
2416 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
2417 ,p_effective_date IN Date
2418 ,p_error_message OUT NOCOPY Varchar2
2419 ,p_data_element_value OUT NOCOPY Varchar2
2420 ) RETURN Number IS
2421
2422 l_proc_name Varchar2(150) := g_proc_name ||'Get_Asg_Seq_Num';
2423 l_asg_seq_num Varchar2(2);
2424 BEGIN
2425 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
2426 IF g_primary_assig.EXISTS(p_assignment_id) THEN
2427 l_asg_seq_num := g_primary_assig(p_assignment_id).asg_seq_num;
2428 IF To_Number(Nvl(l_asg_seq_num,'1')) < 10 THEN
2429 l_asg_seq_num := '0' ||Nvl(l_asg_seq_num,'1');
2430 END IF;
2431 END IF;
2432 p_data_element_value := Nvl(l_asg_seq_num,'01');
2433 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
2434 RETURN 0;
2435
2436 EXCEPTION
2437 WHEN Others THEN
2438 p_error_message :='SQL-ERRM :'||SQLERRM;
2439 Hr_Utility.set_location('..'||p_error_message,85);
2440 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
2441 RETURN -1;
2442 END Get_Asg_Seq_Num;
2443
2444 --============================================================================
2445 -- Function to check if the assignment being processed has to be reported to
2446 -- ABP as a new hire assignment
2447 --============================================================================
2448 FUNCTION Chk_New_Hire_Asg
2449 (p_person_id IN per_all_people_f.person_id%TYPE
2450 ,p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
2451 ,p_business_group_id IN NUMBER
2452 ,p_start_date IN DATE
2453 ,p_end_date IN DATE
2454 ,p_hire_date OUT NOCOPY DATE
2455 ,p_error_message OUT NOCOPY VARCHAR2)
2456 RETURN NUMBER IS
2457 --
2458 -- Cursor to derive the hire date of the EE assignment
2459 --
2460 CURSOR csr_hire_dt IS
2461 SELECT MIN(effective_start_date)
2462 FROM per_all_assignments_f
2463 WHERE assignment_id = p_assignment_id
2464 AND assignment_type = 'E';
2465
2466 --
2467 -- Cursor to check if New hire Record 05 is sent to ABP
2468 -- in an earlier run. If record 05 is sent, there is no need
2469 -- to send it again. This check is necessary for late hire
2470 -- EE assignments
2471 --
2472 CURSOR c_rec05_sent (c_asg_seq IN VARCHAR2) IS
2473 SELECT 1
2474 FROM ben_ext_rslt_dtl dtl
2475 ,ben_ext_rslt res
2476 ,ben_ext_rcd rcd
2477 ,ben_ext_rcd_in_file rin
2478 ,ben_ext_dfn dfn
2479 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
2480 FROM pqp_extract_attributes
2481 WHERE ext_dfn_type = 'NL_FPR')
2482 AND val_05 <> '00000000' -- Ptpn St Date
2483 AND val_11 IS NOT NULL -- Kind of Ptpn
2484 AND val_12 IS NOT NULL -- Value of Ptpn
2485 AND val_16 IS NOT NULL -- PTP
2486 AND val_04 = c_asg_seq
2487 AND dtl.person_id = g_person_id
2488 AND ext_stat_cd = 'A'
2489 AND TRUNC(res.eff_dt) < TRUNC(g_extract_params(p_business_group_id).extract_start_date)
2490 AND rin.ext_file_id = dfn.ext_file_id
2491 AND rin.ext_rcd_id = rcd.ext_rcd_id
2492 AND dfn.ext_dfn_id = res.ext_dfn_id
2493 AND dtl.ext_rslt_id = res.ext_rslt_id
2494 AND dtl.ext_rcd_id = rcd.ext_rcd_id
2495 AND rin.seq_num = 5;
2496
2497 l_proc_name VARCHAR2(150) := g_proc_name ||'.chk_new_hire_asg';
2498 l_dummy NUMBER;
2499 l_asg_seq VARCHAR2(2);
2500
2501 BEGIN
2502
2503 hr_utility.set_location('Entering : '||l_proc_name, 90);
2504 hr_utility.set_location('Assignment Id : '||p_assignment_id, 90);
2505 hr_utility.set_location('p_start_date is : '||p_start_date, 90);
2506 hr_utility.set_location('p_end_date is : '||p_end_date, 90);
2507
2508 --
2509 -- Check if the EE assignment was hired in the current extract
2510 -- start and end dates
2511 --
2512 OPEN csr_hire_dt;
2513 FETCH csr_hire_dt INTO p_hire_date;
2514 CLOSE csr_hire_dt;
2515
2516 l_dummy := Get_Asg_Seq_Num(p_assignment_id
2517 ,p_business_group_id
2518 ,p_hire_date
2519 ,p_error_message
2520 ,l_asg_seq);
2521
2522 hr_utility.set_location('p_hire_date is : '||p_hire_date, 90);
2523
2524 IF p_hire_date BETWEEN p_start_date AND p_end_date THEN
2525 RETURN 1;
2526 END IF;
2527
2528 --
2529 -- If the EE assignment was not hired between the extract
2530 -- start and end dates, check if New Hire Record 05 was reported
2531 -- to ABP earlier. If it was then do not report it again.
2532 -- If not report the EE as a new hire.
2533 -- This logic works for late hire EE assignments as well.
2534 --
2535 OPEN c_rec05_sent(l_asg_seq);
2536 FETCH c_rec05_sent INTO l_dummy;
2537 IF c_rec05_sent%NOTFOUND AND
2538 TRUNC(p_hire_date) > TO_DATE('31/12/2005','DD/MM/YYYY') THEN
2539 CLOSE c_rec05_sent;
2540 hr_utility.set_location('Rec 05 Not Sent : '||p_start_date, 90);
2541 RETURN 1;
2542 ELSE
2543 CLOSE c_rec05_sent;
2544 hr_utility.set_location('Rec 05 Sent : '||p_start_date, 90);
2545 RETURN 0;
2546 END IF;
2547
2548 hr_utility.set_location('Leaving : '||l_proc_name, 90);
2549
2550 RETURN 0 ;
2551
2552 EXCEPTION
2553
2554 WHEN OTHERS THEN
2555 p_error_message :='SQL-ERRM :'||SQLERRM;
2556 Hr_Utility.set_location('..'||p_error_message,85);
2557 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
2558 RETURN 0;
2559
2560 END chk_new_hire_asg;
2561
2562 --=============================================================================
2563 -- Function to get the age of a person given the effective date
2564 --=============================================================================
2565 FUNCTION Get_Age
2566 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
2567 ,p_effective_date IN DATE)
2568 RETURN NUMBER IS
2569
2570 CURSOR get_dob IS
2571 SELECT trunc(date_of_birth)
2572 FROM per_all_people_f per
2573 ,per_all_assignments_f paf
2574 WHERE per.person_id = paf.person_id
2575 AND paf.assignment_id = p_assignment_id
2576 AND p_effective_date BETWEEN per.effective_start_date
2577 AND per.effective_end_date
2578 AND p_effective_date BETWEEN paf.effective_start_date
2579 AND paf.effective_end_date;
2580
2581 l_age NUMBER;
2582 l_dob DATE;
2583
2584 BEGIN
2585
2586 --
2587 --Fetch the date of birth
2588 --
2589 OPEN get_dob;
2590 FETCH get_dob INTO l_dob;
2591 CLOSE get_dob;
2592
2593 l_dob := NVL(l_dob,p_effective_date);
2594
2595 RETURN (TRUNC(MONTHS_BETWEEN(p_effective_date,l_dob)/12,2));
2596
2597 END Get_Age;
2598
2599 -- =============================================================================
2600 -- Get_Pen_Prin_Obj_Cd
2601 -- =============================================================================
2602 FUNCTION Get_Pri_Obj_Cd_Cur
2603 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
2604 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
2605 ,p_effective_date IN Date
2606 ,p_error_message OUT NOCOPY Varchar2
2607 ,p_data_element_value OUT NOCOPY Varchar2
2608 ) RETURN Number IS
2609
2610 CURSOR c_obj_cd IS
2611 SELECT Decode(aei_information5,'Y','J',' ') obj_cd
2612 FROM per_assignment_extra_info
2613 WHERE assignment_id = p_assignment_id
2614 AND information_type = 'NL_USZO_INFO'
2615 AND Trunc(p_effective_date) BETWEEN
2616 Fnd_Date.canonical_to_date(aei_information1)AND
2617 Nvl(Fnd_Date.canonical_to_date(aei_information2),
2618 To_Date('31/12/4712','DD/MM/YYYY'))
2619 AND ROWNUM = 1;
2620 -- Rownum clause has been added on purpose as it is possible that there
2621 -- are two valid rows in the system ( There are no checks in the ASG EIT)
2622 -- this is in case the user makes an error and has two valid rows
2623 -- at the same time.
2624
2625
2626 l_return_value Number := 0;
2627 l_obj_cd Varchar2(150);
2628 l_error_code Varchar2(10);
2629 l_proc_name Varchar2(150) := g_proc_name ||'Get_Pen_Prin_Obj_Cd_Cur';
2630
2631 BEGIN
2632
2633 Hr_Utility.set_location(' Entering ' || l_proc_name , 5);
2634 OPEN c_obj_cd;
2635 FETCH c_obj_cd INTO l_obj_cd;
2636 IF c_obj_cd%FOUND THEN
2637 CLOSE c_obj_cd;
2638 p_data_element_value := l_obj_cd;
2639 ELSE
2640 CLOSE c_obj_cd;
2641 p_data_element_value := ' ';
2642 END IF;
2643 l_return_value := 0;
2644
2645 Hr_Utility.set_location(' Leaving ' || l_proc_name , 30);
2646
2647 RETURN l_return_value;
2648
2649 EXCEPTION
2650 WHEN Others THEN
2651 p_error_message :='SQL-ERRM :'||SQLERRM;
2652 Hr_Utility.set_location('..'||p_error_message,85);
2653 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
2654 RETURN -1 ;
2655 END Get_Pri_Obj_Cd_Cur;
2656
2657 -- =============================================================================
2658 -- Get_Pen_Prin_Obj_Cd
2659 -- =============================================================================
2660 FUNCTION Get_Pri_Obj_Cd
2661 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
2662 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
2663 ,p_effective_date IN Date
2664 ,p_error_message OUT NOCOPY Varchar2
2665 ,p_data_element_value OUT NOCOPY Varchar2
2666 ) RETURN Number IS
2667
2668
2669 l_return_value Number := 0;
2670 l_obj_cd Varchar2(150);
2671 l_error_code Varchar2(10);
2672 l_proc_name Varchar2(150) := g_proc_name ||'Get_Pen_Prin_Obj_Cd';
2673 j NUMBER;
2674 l_fetch_flag VARCHAR2(1);
2675 l_ret_val NUMBER;
2676
2677 BEGIN
2678
2679 Hr_Utility.set_location(' Entering ' || l_proc_name , 30);
2680
2681 IF l_rec_09_values.count > 0 THEN
2682 j := l_rec_09_values.FIRST;
2683 IF l_rec_09_values.EXISTS(j) THEN
2684 l_fetch_flag := NVL(l_rec_09_values(j).pobj_flag,'Y');
2685 l_rec_09_values.DELETE(j);
2686 END IF;
2687 END IF;
2688
2689 l_ret_val := Get_Pri_Obj_Cd_Cur(p_assignment_id
2690 ,p_business_group_id
2691 ,p_effective_date
2692 ,p_error_message
2693 ,l_obj_cd);
2694
2695 IF l_fetch_flag = 'N' THEN
2696
2697 IF NVL(l_obj_cd,' ') = 'J' THEN
2698 p_data_element_value := ' ';
2699 ELSIF NVL(l_obj_cd,' ') = ' ' THEN
2700 p_data_element_value := 'J';
2701 END IF;
2702
2703 l_return_value := 0;
2704
2705 ELSE
2706
2707 p_data_element_value := l_obj_cd;
2708 l_return_value := 0;
2709
2710 END IF;
2711
2712 Hr_Utility.set_location(' Leaving ' || l_proc_name , 30);
2713
2714
2715 RETURN l_return_value;
2716
2717 EXCEPTION
2718 WHEN Others THEN
2719 p_error_message :='SQL-ERRM :'||SQLERRM;
2720 Hr_Utility.set_location('..'||p_error_message,85);
2721 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
2722 RETURN -1 ;
2723 END Get_Pri_Obj_Cd;
2724
2725 -- =============================================================================
2726 --This Procedure stores the child orgs and sub orgs which are employer themselves of
2727 --the organization passed as parameter(employers) in table employer_child_list
2728 -- =============================================================================
2729 PROCEDURE Set_Er_Children ( p_org_id IN hr_all_organization_units.organization_id%TYPE
2730 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
2731 ,p_effective_date IN Date
2732 )
2733 IS
2734 -- Cursor to Check if a org hierarchy is attached to the BG.
2735 -- If it is attached get the valid version as of the effective date.
2736 -- If a valid version is not found then do nothing.
2737 CURSOR c_get_org_hierarchy IS
2738 SELECT pos.org_structure_version_id
2739 FROM per_org_structure_versions_v pos,
2740 hr_organization_information hoi
2741 WHERE hoi.organization_id = p_business_group_id
2742 AND To_Number(hoi.org_information1) = pos.organization_structure_id
2743 AND Trunc(p_effective_date) BETWEEN date_from
2744 AND Nvl(date_to,Hr_Api.g_eot)
2745 AND hoi.org_information_context = 'NL_BG_INFO';
2746
2747 --Cursor to fetch immediate children of org
2748 CURSOR csr_get_children(c_org_id hr_all_organization_units.organization_id%TYPE,
2749 c_org_struct_ver_id per_org_structure_versions_v.org_structure_version_id%TYPE
2750 ) IS
2751 SELECT os.organization_id_child
2752 FROM (SELECT *
2753 FROM per_org_structure_elements a
2754 WHERE a.org_structure_version_id = c_org_struct_ver_id ) os
2755 WHERE os.organization_id_parent = c_org_id;
2756
2757
2758 --Cursor to check whether oganization is tax organization or not
2759 CURSOR csr_tax_org(c_org_id NUMBER) IS
2760 SELECT 'x'
2761 FROM hr_organization_information
2762 WHERE organization_id = c_org_id
2763 AND org_information_context = 'NL_ORG_INFORMATION'
2764 AND org_information3 IS NOT NULL
2765 AND org_information4 IS NOT NULL;
2766
2767 CURSOR csr_any_child_exists(c_org_id hr_all_organization_units.organization_id%TYPE,
2768 c_org_struct_ver_id per_org_structure_versions_v.org_structure_version_id%TYPE
2769 ) IS
2770 SELECT 'x'
2771 FROM (SELECT *
2772 FROM per_org_structure_elements a
2773 WHERE a.org_structure_version_id = c_org_struct_ver_id ) os
2774 WHERE os.organization_id_parent = c_org_id;
2775
2776 l_error_message Varchar2(10);
2777 l_proc_name Varchar2(150) := g_proc_name ||'Set_Er_Children';
2778 l_org_struct_ver_id per_org_structure_versions_v.org_structure_version_id%TYPE;
2779 l_tax_org_flag varchar2(1);
2780 l_child_org_flag varchar2(1);
2781 BEGIN
2782 Hr_Utility.set_location(' Entering ' || l_proc_name , 30);
2783
2784 --Get the org_structure_version_id from the hierarchy atttached to BG
2785 OPEN c_get_org_hierarchy;
2786 FETCH c_get_org_hierarchy INTO l_org_struct_ver_id;
2787 CLOSE c_get_org_hierarchy;
2788
2789 --Loop for all the immediate children orgs
2790 FOR temp_rec IN csr_get_children(p_org_id,l_org_struct_ver_id)
2791 LOOP
2792 --CASE 1: IF org is employer do nothing
2793 OPEN csr_tax_org(temp_rec.organization_id_child );
2794 FETCH csr_tax_org INTO l_tax_org_flag;
2795 IF csr_tax_org%FOUND THEN
2796 CLOSE csr_tax_org;
2797
2798 ELSE
2799 CLOSE csr_tax_org;
2800
2801
2802 OPEN csr_any_child_exists(temp_rec.organization_id_child,l_org_struct_ver_id);
2803 FETCH csr_any_child_exists INTO l_child_org_flag;
2804
2805 --CASE 2: If org is non employer but has no child
2806 IF csr_any_child_exists%NOTFOUND THEN
2807 CLOSE csr_any_child_exists;
2808 --Increase the group count
2809 g_org_grp_list_cnt(g_er_index).org_grp_count:=g_org_grp_list_cnt(g_er_index).org_grp_count+1;
2810
2811 --Increase index
2812 g_er_child_index:=g_er_child_index+1;
2813
2814 --add current org to the employer child table
2815 g_employer_child_list(g_er_child_index).gre_org_id:=temp_rec.organization_id_child;
2816
2817
2818 ELSE
2819 --CASE 3:If org is a non employer and has child/children orgs
2820 CLOSE csr_any_child_exists;
2821 --Increase the group count
2822 g_org_grp_list_cnt(g_er_index).org_grp_count:=g_org_grp_list_cnt(g_er_index).org_grp_count+1;
2823
2824 --Increase index
2825 g_er_child_index:=g_er_child_index+1;
2826
2827 --add current org to the employer child table
2828 g_employer_child_list(g_er_child_index).gre_org_id:=temp_rec.organization_id_child;
2829
2830 --Make a recursive call
2831 Set_Er_Children(temp_rec.organization_id_child,p_business_group_id,p_effective_date);
2832 END IF;
2833 END IF;
2834
2835 END LOOP;
2836
2837
2838 Hr_Utility.set_location(' Leaving ' || l_proc_name , 100);
2839 EXCEPTION
2840 WHEN Others THEN
2841 l_error_message :='SQL-ERRM :'||SQLERRM;
2842 Hr_Utility.set_location('..'||l_error_message,85);
2843 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
2844 END Set_Er_Children;
2845
2846 --
2847 -- Function to check if ABP Pensions element is processed for the
2848 -- EE assignment. This also takes care of the EE assignment
2849 -- not attached to the payroll.
2850 --
2851 FUNCTION Chk_ABP_Processed
2852 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
2853 ,p_effective_date IN DATE
2854 ,p_business_group_id IN NUMBER)
2855 RETURN NUMBER IS
2856
2857 l_payroll_id NUMBER;
2858 l_abp_ee_xst NUMBER;
2859 l_proc_name VARCHAR2(150) := g_proc_name ||'Chk_ABP_Processed';
2860
2861 --
2862 -- Cursor to check if an Element Entry for ABP Pensions
2863 -- exists for the EE assignment
2864 --
2865 CURSOR c_abp_entry IS
2866 SELECT 1
2867 FROM pay_element_entries_f peef,
2868 pay_element_links_f pelf
2869 WHERE p_effective_date BETWEEN peef.effective_start_date AND
2870 peef.effective_end_date
2871 AND p_effective_date BETWEEN pelf.effective_start_date AND
2872 pelf.effective_end_date
2873 AND peef.element_link_id = pelf.element_link_id
2874 AND peef.assignment_id = p_assignment_id
2875 AND pelf.element_type_id =
2876 (SELECT element_type_id
2877 FROM pay_element_types_f
2878 WHERE element_name = 'ABP Pensions'
2879 AND TRUNC(g_extract_params(p_business_group_id).extract_start_date)
2880 BETWEEN effective_start_date AND effective_end_date);
2881
2882 --
2883 -- Cursor to check if the EE assignment is attached
2884 -- to a payroll
2885 --
2886 CURSOR c_pay_id IS
2887 SELECT payroll_id
2888 FROM per_all_assignments_f
2889 WHERE p_effective_date between effective_start_date AND
2890 effective_end_date
2891 AND assignment_id = p_assignment_id
2892 AND payroll_id IS NOT NULL;
2893
2894 BEGIN
2895
2896 IF g_debug THEN
2897 Hr_Utility.set_location('Entering: '||l_proc_name,10);
2898 Hr_Utility.set_location('...Assignment Id is : '||p_assignment_id,11);
2899 Hr_Utility.set_location('...Eff Dt is : '||p_effective_date,12);
2900 END IF;
2901
2902 l_payroll_id := NULL;
2903 l_abp_ee_xst := 0;
2904
2905 FOR temp_rec in c_pay_id LOOP
2906 l_payroll_id := temp_rec.payroll_id;
2907 END LOOP;
2908
2909 IF g_debug THEN
2910 Hr_Utility.set_location('...Checking if EE is part of payroll ',20);
2911 Hr_Utility.set_location('...Payroll id is '||NVL(l_payroll_id,-1),25);
2912 END IF;
2913
2914 IF l_payroll_id IS NULL THEN
2915
2916 IF g_debug THEN
2917 Hr_Utility.set_location('...EE is not part of payroll ',30);
2918 Hr_Utility.set_location('Leaving: '||l_proc_name,90);
2919 END IF;
2920
2921 RETURN 0;
2922 ELSE
2923
2924 IF g_debug THEN
2925 Hr_Utility.set_location('...EE is part of payroll ',40);
2926 END IF;
2927
2928 OPEN c_abp_entry;
2929 FETCH c_abp_entry INTO l_abp_ee_xst;
2930
2931 IF c_abp_entry%FOUND THEN
2932
2933 IF g_debug THEN
2934 Hr_Utility.set_location('...ABP is processed ',50);
2935 Hr_Utility.set_location('Leaving: '||l_proc_name,90);
2936 END IF;
2937
2938 CLOSE c_abp_entry;
2939 RETURN 1;
2940
2941 ELSE
2942
2943 IF g_debug THEN
2944 Hr_Utility.set_location('...ABP is not processed ',50);
2945 Hr_Utility.set_location('Leaving: '||l_proc_name,90);
2946 END IF;
2947
2948 CLOSE c_abp_entry;
2949 RETURN 0;
2950
2951 END IF;
2952
2953 END IF;
2954
2955 END Chk_ABP_Processed;
2956
2957 FUNCTION Get_Min_Date (p_hire_term_dt IN DATE ,
2958 p_derived_date IN DATE)
2959 RETURN DATE IS
2960
2961 BEGIN
2962
2963 IF TO_CHAR(p_hire_term_dt,'MM/YYYY') = TO_CHAR(p_derived_date,'MM/YYYY') THEN
2964 --
2965 -- EE was hired or terminated in the same month as we are trying to report.
2966 --
2967 RETURN p_hire_term_dt;
2968 ELSE
2969 --
2970 -- EE was hired or terminatred in a different month
2971 --
2972 RETURN p_derived_date;
2973 END IF;
2974
2975 END Get_Min_Date;
2976
2977 --
2978 -- Function to check if a given assignment is terminated in the prev year (
2979 -- with reference to the extract start date).This function is necessary to
2980 -- supress Record 08 and 09 for EE assignments that are terminated in the
2981 -- previous years. Can be an issue for Secondary assignments where the primary
2982 -- assignment is still valid for reporting.
2983 -- Returns TRUE if asg is terminated in the prev year.
2984 -- P1 Bug Reference -- 5852097
2985 -- P1 SR/TAR Reference -- 6120992.992
2986 --
2987 FUNCTION Chk_Asg_Term_Py (p_assignment_id IN NUMBER,
2988 p_ext_st IN DATE)
2989 RETURN BOOLEAN IS
2990
2991 l_asg_term_dt DATE;
2992 l_proc_name VARCHAR2(150) := g_proc_name ||'Chk_Asg_Term_Py';
2993 --
2994 -- Cursor to fetch the termination date of a terminated or
2995 -- ended assignment.
2996 --
2997 CURSOR c_get_term_date IS
2998 SELECT MIN(effective_start_date) - 1 term_date
2999 FROM per_all_assignments_f asg
3000 WHERE assignment_id = p_assignment_id
3001 AND assignment_status_type_id IN (SELECT assignment_status_type_id
3002 FROM per_assignment_status_types
3003 WHERE per_system_status = 'TERM_ASSIGN'
3004 AND active_flag = 'Y')
3005 UNION
3006 --
3007 -- Get the dates for any ended assignments. Note that this is for sec
3008 -- assignments only.
3009 --
3010 SELECT MAX(effective_end_date)
3011 FROM per_all_assignments_f asg
3012 WHERE assignment_id = p_assignment_id
3013 AND asg.primary_flag = 'N'
3014 AND NOT EXISTS( SELECT 1
3015 FROM per_all_assignments_f asg1
3016 WHERE asg1.assignment_id = p_assignment_id
3017 AND asg1.effective_start_date = asg.effective_end_date + 1
3018 AND asg.assignment_id = asg1.assignment_id )
3019 AND NOT EXISTS( SELECT 1
3020 FROM per_all_assignments_f asg1
3021 WHERE asg1.assignment_id = p_assignment_id
3022 AND asg1.effective_start_date < asg.effective_start_date
3023 AND asg.assignment_id = asg1.assignment_id
3024 AND asg1.assignment_status_type_id IN (SELECT assignment_status_type_id
3025 FROM per_assignment_status_types
3026 WHERE per_system_status = 'TERM_ASSIGN'
3027 AND active_flag = 'Y'))
3028 ;
3029
3030
3031 BEGIN
3032
3033 IF g_debug THEN
3034 Hr_Utility.set_location('Entering : '||l_proc_name,10);
3035 Hr_Utility.set_location('...Assignment Id is : '||p_assignment_id,11);
3036 Hr_Utility.set_location('...Value of p_ext_st is : '||p_ext_st,12);
3037 END IF;
3038
3039 OPEN c_get_term_date;
3040 FETCH c_get_term_date INTO l_asg_term_dt;
3041
3042 IF c_get_term_date%NOTFOUND THEN
3043
3044 IF g_debug THEN
3045 Hr_Utility.set_location('...Termination Date Not found : ',13);
3046 Hr_Utility.set_location('Leaving: '||l_proc_name,17);
3047 END IF;
3048
3049 CLOSE c_get_term_date;
3050 RETURN FALSE;
3051
3052 ELSE
3053
3054 CLOSE c_get_term_date;
3055
3056 IF g_debug THEN
3057 Hr_Utility.set_location('...Termination Date found : ',14);
3058 END IF;
3059
3060 IF TO_NUMBER(TO_CHAR(NVL(l_asg_term_dt,p_ext_st),'YYYY')) <
3061 TO_NUMBER(TO_CHAR(p_ext_st,'YYYY')) THEN
3062 IF g_debug THEN
3063 Hr_Utility.set_location('...Condition met return TRUE : ',15);
3064 Hr_Utility.set_location('Leaving: '||l_proc_name,18);
3065 END IF;
3066 RETURN TRUE;
3067 ELSE
3068 IF g_debug THEN
3069 Hr_Utility.set_location('...Condition not met return FALSE : ',16);
3070 Hr_Utility.set_location('Leaving: '||l_proc_name,19);
3071 END IF;
3072 RETURN FALSE;
3073 END IF;
3074
3075 END IF;
3076
3077 END chk_asg_term_py;
3078
3079
3080 FUNCTION Chk_Subcat_Disp (p_code IN VARCHAR2
3081 ,p_dt_earned IN DATE )
3082 --
3083 -- Function to check if IPH and IPL are to be displayed.
3084 -- From 2007 onwards only retro amounts for 2006 OR contributions
3085 -- for late hires are to be displayed for IPH and L
3086 --
3087 RETURN BOOLEAN IS
3088
3089 BEGIN
3090
3091 IF p_code IN ('IH','IL') AND p_dt_earned > TO_DATE('12/31/2006','MM/DD/YYYY') THEN
3092 RETURN FALSE;
3093 ELSE
3094 RETURN TRUE;
3095 END IF;
3096
3097 END chk_subcat_disp;
3098
3099 -- =============================================================================
3100 -- Function Chk_Asg_late_hire to check if an EE assignment is a late hire.
3101 -- For ABP Pensions, an EE assignment is considered as late hire if the
3102 -- EE crosses tax years. For e.g. hired in 2006 but the first payroll is run
3103 -- in 2007. During payroll processing, late hire indicator is stored in a
3104 -- balance -- ABP Late Hire. If the YTD value of this balance is <> 0 then the
3105 -- EE assignment is considered as a late hire.
3106 -- RETURNS TRUE if EE asg is late hire.
3107 -- =============================================================================
3108 FUNCTION Chk_Asg_Late_Hire (p_assignment_id IN NUMBER
3109 ,p_business_group_id IN NUMBER)
3110
3111 RETURN BOOLEAN IS
3112
3113 l_late_hire_ind NUMBER;
3114 l_def_bal_id NUMBER;
3115 l_proc_name VARCHAR2(150) := g_proc_name ||'Chk_Asg_Late_Hire';
3116
3117 BEGIN
3118
3119 IF g_debug THEN
3120 Hr_Utility.set_location('Entering: '||l_proc_name,10);
3121 Hr_Utility.set_location('...Assignment Id is : '||p_assignment_id,11);
3122 END IF;
3123
3124 l_late_hire_ind := 0;
3125 l_def_bal_id := -1;
3126
3127 OPEN csr_defined_bal (c_balance_name => 'ABP Late Hire'
3128 ,c_dimension_name => 'Assignment Year To Date'
3129 ,c_business_group_id => p_business_group_id);
3130 FETCH csr_defined_bal INTO l_def_bal_id;
3131
3132 IF csr_defined_bal%NOTFOUND THEN
3133 l_def_bal_id := -1;
3134 END IF;
3135
3136 CLOSE csr_defined_bal;
3137
3138 IF g_debug THEN
3139 Hr_Utility.set_location('...l_def_bal_id is : '||l_def_bal_id,12);
3140 END IF;
3141
3142 IF l_def_bal_id <> -1 THEN
3143 --
3144 -- Derive the late hire indicator value from the balance
3145 --
3146 l_late_hire_ind := pay_balance_pkg.get_value( p_assignment_id => p_assignment_id
3147 ,p_defined_balance_id => l_def_bal_id
3148 ,p_virtual_date => g_extract_params(p_business_group_id).extract_end_date);
3149 END IF;
3150
3151 IF g_debug THEN
3152 Hr_Utility.set_location('...l_late_hire_ind is : '||l_late_hire_ind,13);
3153 END IF;
3154
3155 IF l_late_hire_ind <> 0 THEN
3156 RETURN TRUE;
3157 ELSE
3158 RETURN FALSE;
3159 END IF;
3160
3161 IF g_debug THEN
3162 Hr_Utility.set_location('Leaving: '||l_proc_name,10);
3163 END IF;
3164
3165 EXCEPTION
3166 WHEN OTHERS THEN
3167 IF g_debug THEN
3168 Hr_Utility.set_location(' Exception occured: '||l_proc_name,10);
3169 END IF;
3170 RETURN FALSE;
3171 END Chk_Asg_Late_Hire;
3172
3173 --
3174 -- Procedure to populate all the PL/SQL tables for records
3175 -- with multiple rows
3176 --
3177 PROCEDURE Populate_Record_Structures
3178 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
3179 ,p_effective_date IN DATE
3180 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
3181 ,p_error_message OUT NOCOPY VARCHAR2 ) IS
3182
3183 --
3184 -- Cursor to get the Assignment Run level dimension id
3185 --
3186 CURSOR csr_asg_dimId IS
3187 SELECT balance_dimension_id
3188 FROM pay_balance_dimensions
3189 WHERE legislation_code = 'NL'
3190 AND database_item_suffix = '_ASG_RUN';
3191
3192 -- Cursor to check if there is a change in hire date
3193 -- the change may be in the future or in the past
3194 -- with or without payroll runs
3195 CURSOR c_hire_dt_chg(c_person_id IN NUMBER
3196 ,c_start_date IN DATE
3197 ,c_end_date IN DATE) IS
3198 SELECT old_val1 old_date,
3199 new_val1 new_date
3200 FROM ben_ext_chg_evt_log
3201 WHERE person_id = c_person_id
3202 AND chg_evt_cd = 'COPOS'
3203 AND fnd_date.canonical_to_date(prmtr_09) BETWEEN c_start_date AND c_end_date
3204 ORDER BY ext_chg_evt_log_id desc;
3205
3206 CURSOR c_ptp_log_rows (c_start_date IN DATE
3207 ,c_end_date IN DATE
3208 ,c_asg_st_dt IN DATE
3209 ,c_asg_ed_dt IN DATE )IS
3210 SELECT assignment_id
3211 ,effective_start_date start_date
3212 ,effective_end_date end_date
3213 ,fnd_number.canonical_to_number(new_val1) ptp
3214 FROM per_all_assignments_f asg,
3215 ben_ext_chg_evt_log log
3216 ,per_assignment_status_types past
3217 ,hr_soft_coding_keyflex sck
3218 WHERE asg.assignment_id = p_assignment_id
3219 AND asg.assignment_status_type_id = past.assignment_status_type_id
3220 AND sck.soft_coding_keyflex_id = asg.soft_coding_keyflex_id
3221 AND past.per_system_status = 'ACTIVE_ASSIGN'
3222 AND log.person_id = g_person_id
3223 AND log.chg_evt_cd = 'COPTP'
3224 AND fnd_date.canonical_to_date(log.prmtr_09)
3225 BETWEEN c_start_date AND c_end_date
3226 AND asg.effective_start_date between c_asg_st_dt AND c_asg_ed_dt
3227 AND asg.soft_coding_keyflex_id = log.prmtr_02
3228 AND asg.assignment_id = log.prmtr_01
3229 AND fnd_number.canonical_to_number(new_val1) =
3230 fnd_number.canonical_to_number(sck.segment29)
3231 order by effective_start_date;
3232
3233 l_ptp_log_rows c_ptp_log_rows%ROWTYPE;
3234
3235 CURSOR c_prior_hourly_ee_ptp
3236 (c_asg_id IN NUMBER
3237 ,c_effective_date IN DATE
3238 ,c_orig_st_date IN DATE
3239 ,c_orig_ed_date IN DATE
3240 ,c_ele_type_id IN NUMBER
3241 ,c_input_val_id IN NUMBER ) IS
3242 SELECT NVL(sum(round(fnd_number.canonical_to_number(peev.screen_entry_value),2)),0) prior_ptp
3243 FROM pay_element_entries_f peef,
3244 pay_element_links_f pelf,
3245 pay_element_entry_values_f peev
3246 WHERE peef.effective_start_date < c_effective_date
3247 AND c_effective_date BETWEEN pelf.effective_start_date AND
3248 pelf.effective_end_date
3249 AND peev.effective_start_date < c_effective_date
3250 AND peef.element_link_id = pelf.element_link_id
3251 AND peev.element_entry_id = peef.element_entry_id
3252 AND pelf.element_type_id = c_ele_type_id
3253 AND peev.input_value_id = c_input_val_id
3254 AND peef.assignment_id = c_asg_id
3255 AND peev.screen_entry_value IS NOT NULL
3256 AND pay_paywsmee_pkg.get_original_date_earned(peef.element_entry_id)
3257 BETWEEN c_orig_st_date AND c_orig_ed_date;
3258
3259 CURSOR c_sent_to_abp (c_eff_dt IN DATE) IS
3260 SELECT 1
3261 FROM ben_ext_rslt res
3262 WHERE ext_dfn_id IN (SELECT ext_dfn_id
3263 FROM pqp_extract_attributes
3264 WHERE ext_dfn_type = 'NL_FPR')
3265 AND ext_stat_cd = 'A'
3266 AND EXISTS ( SELECT 1 FROM ben_ext_rslt_dtl dtl
3267 WHERE dtl.ext_rslt_id = res.ext_rslt_id
3268 AND dtl.person_id = g_person_id)
3269 AND trunc(res.eff_dt) = trunc(c_eff_dt)
3270 ORDER BY ext_rslt_id DESC;
3271
3272 CURSOR c_09_abp_data (c_eff_dt IN DATE
3273 ,c_pt_code IN VARCHAR2) IS
3274 SELECT fnd_number.canonical_to_number(val_06)/100 basis
3275 FROM ben_ext_rslt_dtl dtl
3276 ,ben_ext_rslt res
3277 ,ben_ext_rcd rcd
3278 ,ben_ext_rcd_in_file rin
3279 ,ben_ext_dfn dfn
3280 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
3281 FROM pqp_extract_attributes
3282 WHERE ext_dfn_type = 'NL_FPR')
3283 and dtl.person_id = g_person_id
3284 and ext_stat_cd = 'A'
3285 AND TRUNC(res.eff_dt)= trunc(c_eff_dt)
3286 AND rin.ext_file_id = dfn.ext_file_id
3287 AND rin.ext_rcd_id = rcd.ext_rcd_id
3288 AND dfn.ext_dfn_id = res.ext_dfn_id
3289 and dtl.ext_rslt_id = res.ext_rslt_id
3290 AND dtl.ext_rcd_id = rcd.ext_rcd_id
3291 AND rin.seq_num = 8
3292 AND val_05 = c_pt_code
3293 ORDER BY res.ext_rslt_id desc;
3294
3295 CURSOR c_09_poj_abp_data (c_eff_dt IN DATE
3296 ,c_poj_cd IN VARCHAR2) IS
3297 SELECT fnd_number.canonical_to_number(val_06)/100 basis
3298 ,TRUNC(res.eff_dt) eff_dt
3299 , val_05 code
3300 FROM ben_ext_rslt_dtl dtl
3301 ,ben_ext_rslt res
3302 ,ben_ext_rcd rcd
3303 ,ben_ext_rcd_in_file rin
3304 ,ben_ext_dfn dfn
3305 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
3306 FROM pqp_extract_attributes
3307 WHERE ext_dfn_type = 'NL_FPR')
3308 and dtl.person_id = g_person_id
3309 and ext_stat_cd = 'A'
3310 AND TRUNC(res.eff_dt)< trunc(c_eff_dt)
3311 AND rin.ext_file_id = dfn.ext_file_id
3312 AND rin.ext_rcd_id = rcd.ext_rcd_id
3313 AND dfn.ext_dfn_id = res.ext_dfn_id
3314 and dtl.ext_rslt_id = res.ext_rslt_id
3315 AND dtl.ext_rcd_id = rcd.ext_rcd_id
3316 AND rin.seq_num = 8
3317 AND val_08 = '0000'
3318 AND val_09 = '00'
3319 AND val_10 <> c_poj_cd
3320 ORDER BY res.ext_rslt_id desc;
3321
3322 CURSOR c_09_poj_cor_abp_data (c_eff_dt IN DATE
3323 ,c_poj_cd IN VARCHAR2) IS
3324 SELECT 1
3325 FROM ben_ext_rslt_dtl dtl
3326 ,ben_ext_rslt res
3327 ,ben_ext_rcd rcd
3328 ,ben_ext_rcd_in_file rin
3329 ,ben_ext_dfn dfn
3330 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
3331 FROM pqp_extract_attributes
3332 WHERE ext_dfn_type = 'NL_FPR')
3333 and dtl.person_id = g_person_id
3334 and ext_stat_cd = 'A'
3335 AND TRUNC(res.eff_dt)> TRUNC(c_eff_dt)
3336 AND rin.ext_file_id = dfn.ext_file_id
3337 AND rin.ext_rcd_id = rcd.ext_rcd_id
3338 AND dfn.ext_dfn_id = res.ext_dfn_id
3339 and dtl.ext_rslt_id = res.ext_rslt_id
3340 AND dtl.ext_rcd_id = rcd.ext_rcd_id
3341 AND rin.seq_num = 8
3342 AND val_08 = to_char(TRUNC(c_eff_dt),'YYYY')
3343 AND val_09 = to_char(TRUNC(c_eff_dt),'MM')
3344 AND val_10 = c_poj_cd -- current_code
3345 ORDER BY res.ext_rslt_id desc;
3346
3347 CURSOR c_12_abp_data (c_eff_dt IN DATE
3348 ,c_code IN VARCHAR2) IS
3349 SELECT fnd_number.canonical_to_number(val_06)/100 amount
3350 FROM ben_ext_rslt_dtl dtl
3351 ,ben_ext_rslt res
3352 ,ben_ext_rcd rcd
3353 ,ben_ext_rcd_in_file rin
3354 ,ben_ext_dfn dfn
3355 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
3356 FROM pqp_extract_attributes
3357 WHERE ext_dfn_type = 'NL_FPR')
3358 and dtl.person_id = g_person_id
3359 and ext_stat_cd = 'A'
3360 AND TRUNC(res.eff_dt)= trunc(c_eff_dt)
3361 AND rin.ext_file_id = dfn.ext_file_id
3362 AND rin.ext_rcd_id = rcd.ext_rcd_id
3363 AND dfn.ext_dfn_id = res.ext_dfn_id
3364 AND dtl.ext_rslt_id = res.ext_rslt_id
3365 AND dtl.ext_rcd_id = rcd.ext_rcd_id
3366 AND rin.seq_num = 10
3367 AND val_05 = c_code
3368 AND val_08 = '0000'
3369 AND val_09 = '00'
3370 ORDER BY res.ext_rslt_id desc;
3371
3372 CURSOR c_12_retro_abp_data (c_year IN VARCHAR2
3373 ,c_mon IN VARCHAR2
3374 ,c_eff_dt IN DATE
3375 ,c_code IN VARCHAR2) IS
3376 SELECT fnd_number.canonical_to_number(val_06)/100 amount
3377 FROM ben_ext_rslt_dtl dtl
3378 ,ben_ext_rslt res
3379 ,ben_ext_rcd rcd
3380 ,ben_ext_rcd_in_file rin
3381 ,ben_ext_dfn dfn
3382 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
3383 FROM pqp_extract_attributes
3384 WHERE ext_dfn_type = 'NL_FPR')
3385 and dtl.person_id = g_person_id
3386 and ext_stat_cd = 'A'
3387 AND TRUNC(res.eff_dt)>= trunc(c_eff_dt)
3388 AND rin.ext_file_id = dfn.ext_file_id
3389 AND rin.ext_rcd_id = rcd.ext_rcd_id
3390 AND dfn.ext_dfn_id = res.ext_dfn_id
3391 AND dtl.ext_rslt_id = res.ext_rslt_id
3392 AND dtl.ext_rcd_id = rcd.ext_rcd_id
3393 AND rin.seq_num = 10
3394 AND val_05 = c_code
3395 AND val_08 = c_year
3396 AND val_09 = c_mon
3397 ORDER BY res.ext_rslt_id desc;
3398
3399 CURSOR c_current_ptp_chgs (c_min_st_dt IN DATE ) IS
3400 SELECT asg.assignment_id
3401 ,effective_start_date start_date
3402 ,effective_end_date end_date
3403 ,least(fnd_number.canonical_to_number(nvl(sck.segment29,100)),125) ptp
3404 FROM per_all_assignments_f asg
3405 ,per_assignment_status_types past
3406 ,hr_soft_coding_keyflex sck
3407 WHERE asg.assignment_id = p_assignment_id
3408 AND asg.assignment_status_type_id = past.assignment_status_type_id
3409 AND sck.soft_coding_keyflex_id = asg.soft_coding_keyflex_id
3410 AND past.per_system_status = 'ACTIVE_ASSIGN'
3411 AND asg.effective_start_date BETWEEN
3412 g_extract_params(p_business_group_id).extract_start_date
3413 AND g_extract_params(p_business_group_id).extract_end_date
3414 AND asg.effective_start_date >= c_min_st_dt
3415 ORDER BY effective_start_date;
3416
3417
3418 CURSOR c_get_min_st_dt IS
3419 SELECT effective_start_date
3420 FROM per_all_assignments_f asg
3421 ,per_assignment_status_types past
3422 ,hr_soft_coding_keyflex sck
3423 WHERE asg.assignment_id = p_assignment_id
3424 AND asg.assignment_status_type_id = past.assignment_status_type_id
3425 AND sck.soft_coding_keyflex_id = asg.soft_coding_keyflex_id
3426 AND past.per_system_status = 'ACTIVE_ASSIGN'
3427 AND asg.effective_start_date BETWEEN
3428 g_extract_params(p_business_group_id).extract_start_date
3429 AND g_extract_params(p_business_group_id).extract_end_date
3430 AND EXISTS (SELECT 1
3431 FROM per_all_assignments_f asg1
3432 ,per_assignment_status_types past1
3433 ,hr_soft_coding_keyflex sck1
3434 WHERE asg1.assignment_id = p_assignment_id
3435 AND asg1.effective_end_date = asg.effective_start_date - 1
3436 AND asg1.assignment_status_type_id = past1.assignment_status_type_id
3437 AND sck1.soft_coding_keyflex_id = asg1.soft_coding_keyflex_id
3438 AND past1.per_system_status = 'ACTIVE_ASSIGN'
3439 AND fnd_number.canonical_to_number(nvl(sck.segment29,'100'))
3440 <> fnd_number.canonical_to_number(nvl(sck1.segment29,'100'))
3441 )
3442 ORDER BY effective_start_date;
3443
3444 CURSOR c_get_hire_dt IS
3445 SELECT MIN(effective_start_date) hire_date
3446 FROM per_all_assignments_f asg
3447 WHERE assignment_id = p_assignment_id
3448 AND assignment_status_type_id IN (SELECT assignment_status_type_id
3449 FROM per_assignment_status_types
3450 WHERE per_system_status = 'ACTIVE_ASSIGN'
3451 AND active_flag = 'Y')
3452 AND assignment_type = 'E';
3453
3454 CURSOR c_get_term_dt IS
3455 SELECT MIN(effective_start_date) - 1 term_date
3456 FROM per_all_assignments_f asg
3457 WHERE assignment_id = p_assignment_id
3458 AND assignment_status_type_id IN (SELECT assignment_status_type_id
3459 FROM per_assignment_status_types
3460 WHERE per_system_status = 'TERM_ASSIGN'
3461 AND active_flag = 'Y')
3462 AND assignment_type = 'E';
3463
3464 -- =========================================
3465 -- ~ Local variables
3466 -- =========================================
3467 l_cur_ptp_min_st_dt DATE;
3468 l_get_fp_nh NUMBER;
3469 l_rec_12_amt_sent_prev_r NUMBER;
3470 l_sent_to_abp NUMBER;
3471 l_rej_hf_ee NUMBER;
3472 i per_all_assignments_f.business_group_id%TYPE;
3473 l_ele_type_id pay_element_types_f.element_type_id%TYPE;
3474 l_prev_ele_type_id pay_element_types_f.element_type_id%TYPE;
3475 l_proc_name VARCHAR2(150) := g_proc_name ||'Populate_Record_Structures';
3476 l_assig_rec csr_assig%ROWTYPE;
3477 l_Chg_Evt_Exists Varchar2(2);
3478 l_effective_date Date;
3479 l_org_hierarchy NUMBER;
3480 j NUMBER := 0;
3481 k NUMBER := 0;
3482 l_rr_exists NUMBER := 0;
3483 l_retro_ptp_value NUMBER(9,2);
3484 l_basis_amount NUMBER(9,2);
3485 l_retro_vop_value NUMBER(5,2);
3486 l_retro_siw_value NUMBER(9,2);
3487 l_retro_sid_value NUMBER(9,2);
3488 l_retro_sit_value varchar2(4);
3489 l_retro_period_start date;
3490 l_retro_period_end date;
3491 l_retro_date_earned varchar2(11);
3492 l_asg_act_id NUMBER;
3493 l_def_bal_id NUMBER;
3494 l_amount NUMBER;
3495 l_context_id NUMBER;
3496 l_si_type varchar2(4);
3497 l_code NUMBER;
3498 l_date date := hr_api.g_eot;
3499 l_new_start date;
3500 l_old_start date;
3501 l_new_start_can ben_ext_chg_evt_log.new_val1%TYPE;
3502 l_old_start_can ben_ext_chg_evt_log.old_val1%TYPE;
3503 l_beg_new_st date;
3504 l_end_new_st date;
3505
3506 l_get_count_ptp_changes NUMBER := 0;
3507 l_ee_age_at_retro NUMBER;
3508 l_retro_age_cal_dt DATE;
3509 l_reg_09_age NUMBER;
3510 l_reg_09_age_cal_dt DATE;
3511 l_retro_ptp_term_asg NUMBER;
3512 l_retro_ptp_row NUMBER;
3513 l_loop_end_date DATE;
3514 l_09_basis_amt_sent_prev NUMBER;
3515 l_rec_12_amt_sent_prev NUMBER;
3516 l_gzz_asg_act_xst NUMBER;
3517 l_gxx_code VARCHAR2(2);
3518 l_poj_ret_val NUMBER;
3519 l_poj_cd VARCHAR2(1);
3520 l_09_poj_cor_abp_data NUMBER;
3521 l_er_index NUMBER:=0;
3522 l_grp_index NUMBER:=0;
3523 l_tax_org_flag VARCHAR2(1);
3524 l_reversal_term NUMBER := 0;
3525 l_normal_term NUMBER := 0;
3526 l_old_date1_xx ben_ext_chg_evt_log.old_val1%TYPE;
3527 l_new_date1_xx ben_ext_chg_evt_log.new_val1%TYPE;
3528 l_old_date2_xx ben_ext_chg_evt_log.old_val1%TYPE;
3529 l_new_date2_xx ben_ext_chg_evt_log.new_val1%TYPE;
3530 l_term_log_id_xx ben_ext_chg_evt_log.ext_chg_evt_log_id%TYPE;
3531 l_revt_log_id_xx ben_ext_chg_evt_log.ext_chg_evt_log_id%TYPE;
3532 l_term_pos_id_XX NUMBER;
3533 l_org_index NUMBER;
3534 l_fp_hire_dt DATE;
3535 l_fp_new_hire NUMBER := 0 ;
3536 l_cur_ptp NUMBER;
3537 l_hourly_ee_avg_ptp NUMBER;
3538 l_hourly_ee_avg_ptp_prev NUMBER;
3539 l_prior_hourly_ee_ptp NUMBER;
3540 l_ret_val_asg NUMBER;
3541 l_seq_num VARCHAR2(2);
3542 l_asg_hire_dt DATE;
3543 l_asg_term_dt DATE;
3544 l_sent_ptp NUMBER;
3545 l_sent_end_dt DATE;
3546 l_sent_st_dt DATE;
3547
3548 --7361922
3549 -- User Defined Element used to report the Record 05 with force.
3550 l_ude_ele_type_id NUMBER;
3551 l_sd_input_val_id NUMBER;
3552 l_ed_input_val_id NUMBER;
3553
3554 CURSOR c_ude_ele_iv_id(p_bg_id NUMBER, p_effective_date DATE) IS
3555 SELECT piv.input_value_id start_dt_id, piv1.input_value_id end_dt_id
3556 ,pet.element_type_id
3557 FROM pay_input_values_f piv
3558 ,pay_input_values_f piv1
3559 ,pay_element_types_f pet
3560 WHERE piv.name = 'Start Date'
3561 AND piv.element_type_id = pet.element_type_id
3562 AND piv1.name = 'End Date'
3563 AND piv1.element_type_id = pet.element_type_id
3564 AND pet.element_name = 'ABP Record 05 Reporting'
3565 AND pet.legislation_code IS NULL
3566 AND pet.business_group_id = p_bg_id
3567 AND p_effective_date between pet.effective_start_date AND pet.effective_end_date
3568 AND p_effective_date between piv.effective_start_date AND piv.effective_end_date
3569 AND p_effective_date between piv1.effective_start_date AND piv1.effective_end_date;
3570
3571 CURSOR c_ude_rec05(p_effective_date date, p_ele_type_id number, p_start_dt_id number, p_end_dt_id number, p_asg_id number) IS
3572 SELECT fnd_date.canonical_to_date(peev.screen_entry_value) start_date, fnd_date.canonical_to_date(peev1.screen_entry_value) end_date
3573 FROM pay_element_entries_f peef,
3574 pay_element_links_f pelf,
3575 pay_element_entry_values_f peev,
3576 pay_element_entry_values_f peev1
3577 WHERE p_effective_date BETWEEN peef.effective_start_date AND
3578 peef.effective_end_date
3579 AND p_effective_date BETWEEN pelf.effective_start_date AND
3580 pelf.effective_end_date
3581 AND p_effective_date BETWEEN peev.effective_start_date AND
3582 peev.effective_end_date
3583 AND peef.element_link_id = pelf.element_link_id
3584 AND peev.element_entry_id = peef.element_entry_id
3585 AND pelf.element_type_id = p_ele_type_id
3586 AND peev.input_value_id = p_start_dt_id
3587 AND peef.assignment_id = p_asg_id
3588 AND p_effective_date BETWEEN peev1.effective_start_date AND
3589 peev1.effective_end_date
3590 AND peev1.element_entry_id = peef.element_entry_id
3591 AND peev1.input_value_id = p_end_dt_id;
3592
3593 l_ude_rec05 c_ude_rec05%rowtype;
3594
3595 CURSOR c_ude_rec05_ptp(p_asg_id number, p_start_date date, p_end_date date) IS
3596 SELECT DISTINCT asg.effective_start_date Start_Date
3597 ,asg.effective_end_date End_Date
3598 ,fnd_number.canonical_to_number(NVL(target.SEGMENT29,'100'))*100 ptp
3599 FROM per_assignments_f asg
3600 ,hr_soft_coding_keyflex target
3601 WHERE asg.assignment_id = p_asg_id
3602 AND asg.effective_start_date BETWEEN p_start_date AND nvl(p_end_date,to_date('31-12-4712','dd-mm-rrrr'))
3603 AND target.soft_coding_keyflex_id = asg.soft_coding_keyflex_id
3604 AND target.enabled_flag = 'Y'
3605 order by Start_Date;
3606
3607 l_prev_ptp_05 Number:= -999;
3608 --7361922
3609
3610 --9503781
3611 CURSOR c_get_retro_pd(c_asg_id IN NUMBER
3612 ,c_effective_date IN DATE
3613 ,c_ele_type_id IN NUMBER
3614 ,c_input_val_id IN NUMBER ) IS
3615
3616 SELECT
3617 MIN(to_date('1/'||to_char(pay_paywsmee_pkg.get_original_date_earned(peef.element_entry_id),'MM/YYYY'),'DD/MM/YYYY')) start_date,
3618 MAX(add_months(to_date('1/'||to_char(pay_paywsmee_pkg.get_original_date_earned(peef.element_entry_id),'MM/YYYY'),'DD/MM/YYYY'),1) - 1) end_date
3619 FROM pay_element_entries_f peef,
3620 pay_element_links_f pelf,
3621 pay_element_entry_values_f peev
3622 WHERE c_effective_date BETWEEN peef.effective_start_date AND
3623 peef.effective_end_date
3624 AND c_effective_date BETWEEN pelf.effective_start_date AND
3625 pelf.effective_end_date
3626 AND c_effective_date BETWEEN peev.effective_start_date AND
3627 peev.effective_end_date
3628 AND peef.element_link_id = pelf.element_link_id
3629 AND peev.element_entry_id = peef.element_entry_id
3630 AND pelf.element_type_id = c_ele_type_id
3631 AND peev.input_value_id = c_input_val_id
3632 AND peef.assignment_id = c_asg_id
3633 AND peev.screen_entry_value IS NOT NULL;
3634
3635 l_ret_rec05_pd c_get_retro_pd%rowtype;
3636
3637 CURSOR c_ret_rec05_ptp(p_asg_id number, p_start_date date, p_end_date date) IS
3638 SELECT DISTINCT asg.effective_start_date Start_Date
3639 ,asg.effective_end_date End_Date
3640 ,fnd_number.canonical_to_number(NVL(target.SEGMENT29,'100'))*100 ptp
3641 FROM per_assignments_f asg
3642 ,hr_soft_coding_keyflex target
3643 WHERE asg.assignment_id = p_asg_id
3644 AND asg.effective_start_date BETWEEN p_start_date AND nvl(p_end_date,to_date('31-12-4712','dd-mm-rrrr'))
3645 AND target.soft_coding_keyflex_id = asg.soft_coding_keyflex_id
3646 AND target.enabled_flag = 'Y'
3647 order by Start_Date;
3648
3649 l_ret_rec05 c_ret_rec05_ptp%rowtype;
3650 l_prev_ptp_rec_05 Number:= -999;
3651 --9503781
3652
3653
3654
3655 BEGIN
3656
3657 --
3658 -- Initialise the count variables to 0
3659 --
3660 g_index_05 := 0;
3661 g_count_05 := 0;
3662 g_si_index := 0;
3663 g_si_count := 0;
3664 g_retro_ptp_count := 0;
3665 g_retro_si_ptp_count := 0;
3666 g_retro_21_count := 0;
3667 g_retro_21_index := 0;
3668 g_retro_22_count := 0;
3669 g_retro_22_index := 0;
3670 l_rec_05_disp := 'N';
3671 g_retro_ptp_count := 0;
3672 i := p_business_group_id;
3673 l_cur_ptp := -1;
3674 l_hourly_ee_avg_ptp := 0;
3675 l_hourly_ee_avg_ptp_prev := 0;
3676 l_prior_hourly_ee_ptp := 0;
3677 g_abp_processed_flag := 0;
3678 g_new_hire_asg := 0;
3679 g_hire_date := NULL;
3680
3681 --
3682 -- Check if ABP Pensions is processed for the EE assignment.
3683 -- Set global flag
3684 --
3685 g_abp_processed_flag := Chk_ABP_Processed
3686 (p_assignment_id => p_assignment_id
3687 ,p_effective_date => p_effective_date
3688 ,p_business_group_id => p_business_group_id);
3689
3690 --
3691 -- Check if the EE asg is a new hire
3692 --
3693 g_new_hire_asg := chk_new_hire_asg
3694 (p_person_id => g_person_id
3695 ,p_assignment_id => p_assignment_id
3696 ,p_business_group_id => p_business_group_id
3697 ,p_start_date => g_extract_params(p_business_group_id).extract_start_date
3698 ,p_end_date => g_extract_params(p_business_group_id).extract_end_date
3699 ,p_hire_date => g_hire_date
3700 ,p_error_message => p_error_message);
3701
3702
3703 -- Get Assignment Run dimension Id as we will be using for
3704 -- calculating the amount
3705 OPEN csr_asg_dimId;
3706 FETCH csr_asg_dimId INTO g_asgrun_dim_id;
3707 CLOSE csr_asg_dimId;
3708
3709
3710 --
3711 -- Get the defined balance id for the ABP contribution
3712 -- of the previous year. This is necessary to reduce the
3713 -- SI Income reported in Rec 21 and 22
3714 FOR temp_rec IN csr_defined_bal
3715 (c_balance_name => 'Retro ABP EE Contribution Previous Year'
3716 ,c_dimension_name => 'Assignment Period To Date'
3717 ,c_business_group_id => p_business_group_id)
3718 LOOP
3719 l_pen_py_con_dbal_id := temp_rec.defined_balance_id;
3720 END LOOP;
3721 ---
3722 ---
3723 ---
3724 --fetch the element type id and the input value id
3725 --for the ABP part time percentage element
3726 OPEN c_get_retro_ele('ABP Pensions Part Time Percentage'
3727 ,'Part Time Percentage');
3728 --6501898
3729 --FETCH c_get_retro_ele INTO l_abp_ptp_iv_id,l_abp_ptp_ele_id;
3730 FETCH c_get_retro_ele INTO g_abp_ptp_iv_id,g_abp_ptp_ele_id;
3731 CLOSE c_get_retro_ele;
3732
3733 --fetch the element type id and the input value id
3734 --for the ABP retro part time percentage element
3735 OPEN c_get_retro_ele('Retro ABP Pensions Part Time Percentage'
3736 ,'Part Time Percentage');
3737 FETCH c_get_retro_ele INTO g_retro_ptp_iv_id,g_retro_ptp_element_id;
3738 CLOSE c_get_retro_ele;
3739
3740 OPEN c_get_retro_ele('Retro ABP Pensions Part Time Percentage'
3741 ,'Value Of Participation');
3742 FETCH c_get_retro_ele INTO g_retro_vop_iv_id,g_retro_ptp_element_id;
3743 CLOSE c_get_retro_ele;
3744
3745 OPEN c_get_retro_ele('Retro ABP Pensions Part Time Percentage'
3746 ,'Part Time Percentage');
3747 FETCH c_get_retro_ele INTO g_retro_pv_iv_id,g_retro_ptp_element_id;
3748 CLOSE c_get_retro_ele;
3749
3750 -- Populate the PLSQL table with the elment type ids for record 09
3751 -- this is required only once . These are the valid schemes for
3752 -- IP IH AP and OP
3753
3754 l_rec_09.DELETE;
3755
3756 FOR temp_rec IN c_rec_09_ele
3757 ( c_bg_id => p_business_group_id
3758 ,c_effective_date => g_extract_params(i).extract_end_date ) LOOP
3759 -- Increment the counter
3760 l_09_counter := l_09_counter + 1;
3761 -- Get the defined balance id
3762 l_rec_09(l_09_counter) := temp_rec;
3763 FOR temp_rec1 IN csr_defined_bal
3764 (c_balance_name => l_rec_09(l_09_counter).bal_name
3765 ,c_dimension_name => 'Assignment Run'
3766 ,c_business_group_id => p_business_group_id)
3767 LOOP
3768 l_rec_09(l_09_counter).defined_bal_id :=
3769 temp_rec1.defined_balance_id;
3770 END LOOP;
3771 END LOOP;
3772
3773 -- Populate the PLSQL table with the elment type ids for record 31
3774 -- this is required only once . These are the valid schemes for
3775 -- IPAP
3776
3777 l_rec_31.DELETE;
3778
3779 FOR temp_rec IN c_rec_31_ele
3780 ( c_bg_id => p_business_group_id
3781 ,c_effective_date => g_extract_params(i).extract_end_date ) LOOP
3782 -- Increment the counter
3783 l_31_counter := l_31_counter + 1;
3784 -- Get the defined balance id
3785 l_rec_31(l_31_counter) := temp_rec;
3786 FOR temp_rec1 IN csr_defined_bal
3787 (c_balance_name => l_rec_31(l_31_counter).bal_name
3788 ,c_dimension_name => 'Assignment Run'
3789 ,c_business_group_id => p_business_group_id)
3790 LOOP
3791 l_rec_31(l_31_counter).defined_bal_id :=
3792 temp_rec1.defined_balance_id;
3793 END LOOP;
3794 END LOOP;
3795
3796 -- Populate the PLSQL table with the elment type ids for record 41
3797 -- this is required only once . These are the valid schemes for
3798 -- FUR_S
3799
3800 l_basis_rec_41.DELETE;
3801
3802 FOR temp_rec IN c_basis_rec_41_ele
3803 ( c_bg_id => p_business_group_id
3804 ,c_effective_date => g_extract_params(i).extract_end_date ) LOOP
3805 -- Increment the counter
3806 l_41_basis_counter := l_41_basis_counter + 1;
3807 -- Get the defined balance id
3808 l_basis_rec_41(l_41_basis_counter) := temp_rec;
3809 FOR temp_rec1 IN csr_defined_bal
3810 (c_balance_name => l_basis_rec_41(l_41_basis_counter).bal_name
3811 ,c_dimension_name => 'Assignment Run'
3812 ,c_business_group_id => p_business_group_id)
3813 LOOP
3814 l_basis_rec_41(l_41_basis_counter).defined_bal_id :=
3815 temp_rec1.defined_balance_id;
3816 END LOOP;
3817 END LOOP;
3818
3819
3820 -- check to see if there is a change in the hire date for the
3821 -- person being processed. These have to be reported to ABP
3822 -- these are persons whose hire date has been updated to a date earlier
3823 -- than the current hire date or to a date in the future
3824 l_new_start := NULL;
3825 l_old_start := NULL;
3826
3827 OPEN c_hire_dt_chg(c_person_id => g_person_id
3828 ,c_start_date => g_extract_params(i).extract_start_date
3829 ,c_end_date => g_extract_params(i).extract_end_date);
3830 FETCH c_hire_dt_chg INTO l_old_start_can,l_new_start_can;
3831 IF c_hire_dt_chg%NOTFOUND THEN
3832 l_new_start := NULL;
3833 l_old_start := NULL;
3834 ELSIF c_hire_dt_chg%FOUND THEN
3835 l_new_start := to_nl_date(l_new_start_can,'DD-MM-RRRR');
3836 l_old_start := to_nl_date(l_old_start_can,'DD-MM-RRRR');
3837 END IF;
3838 CLOSE c_hire_dt_chg;
3839
3840 --If person is not retro hired then g_retro_hires record is null
3841 Hr_Utility.set_location('c_start_date'||g_extract_params(i).extract_start_date, 15);
3842 Hr_Utility.set_location('c_end_date'||g_extract_params(i).extract_end_date, 15);
3843 Hr_Utility.set_location('l_new_start'||l_new_start, 15);
3844 Hr_Utility.set_location('l_old_date'||l_old_start, 15);
3845
3846 -- ============================================================================
3847 -- BEGIN Populate Record 05 Retro PTP change information
3848 -- ============================================================================
3849 -- Derive the current ptp to check if the EE is
3850 -- Hourly or a regular EE
3851 --
3852 FOR cur_ptp_rec IN c_cur_ptp(p_effective_date,p_assignment_id) LOOP
3853 l_cur_ptp := cur_ptp_rec.ptp;
3854 END LOOP;
3855
3856 --7555712
3857 -- Fetching the hourly / salaried indicator.
3858 OPEN c_cur_sal_hour(p_effective_date,p_assignment_id);
3859 FETCH c_cur_sal_hour INTO l_hourly_salaried_code;
3860 CLOSE c_cur_sal_hour;
3861 --7555712
3862
3863 --
3864 -- Derive the hire and termination dates
3865 --
3866 OPEN c_get_hire_dt;
3867 FETCH c_get_hire_dt INTO l_asg_hire_dt;
3868 CLOSE c_get_hire_dt;
3869
3870 OPEN c_get_term_dt;
3871 FETCH c_get_term_dt INTO l_asg_term_dt;
3872 IF c_get_term_dt%NOTFOUND THEN
3873 l_asg_term_dt := NULL;
3874 END IF;
3875 CLOSE c_get_term_dt;
3876
3877 OPEN c_ptp_chg_exist (c_asg_id => p_assignment_id
3878 ,c_effective_date => g_extract_params(i).extract_start_date
3879 ,c_ele_type_id => g_retro_ptp_element_id
3880 ,c_input_val_id => g_retro_pv_iv_id);
3881 FETCH c_ptp_chg_exist INTO l_ptp_chg_exist;
3882
3883 IF c_ptp_chg_exist%FOUND THEN
3884
3885
3886 IF l_cur_ptp <> 0 THEN -- Regular EE
3887
3888 --9503781 COPTP changes commented
3889 /*
3890 FOR retro_rec_05_period IN c_get_retro_ptp(c_asg_id => p_assignment_id
3891 ,c_effective_date => g_extract_params(i).extract_start_date
3892 ,c_ele_type_id => g_retro_ptp_element_id
3893 ,c_input_val_id => g_retro_pv_iv_id)
3894 LOOP
3895 --
3896 -- Part time percentage changes exist as retro entries have been created
3897 --
3898
3899 OPEN c_ptp_log_rows(g_extract_params(i).extract_start_date,
3900 g_extract_params(i).extract_end_date
3901 ,retro_rec_05_period.start_date
3902 ,retro_rec_05_period.end_date);
3903 --
3904 -- For regular EE get the data from the log rows
3905 --
3906 LOOP
3907 FETCH c_ptp_log_rows INTO l_ptp_log_rows;
3908
3909 EXIT WHEN c_ptp_log_rows%NOTFOUND;
3910 hr_utility.set_location('....Inside the loop',20);
3911 IF g_retro_ptp_count > 0 THEN
3912 --
3913 -- Check if the ptp is the same and the dates are continuous
3914 --
3915 IF ( trunc(l_rec_05_retro_ptp(g_retro_ptp_count).end_date) + 1 =
3916 trunc(l_ptp_log_rows.start_date) AND
3917 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc =
3918 l_ptp_log_rows.ptp * 100 ) THEN
3919 l_rec_05_retro_ptp(g_retro_ptp_count).end_date := l_ptp_log_rows.end_date;
3920 hr_utility.set_location('...Updated the date',20);
3921 ELSE
3922 g_retro_ptp_count := g_retro_ptp_count + 1;
3923 l_rec_05_retro_ptp(g_retro_ptp_count).start_date := l_ptp_log_rows.start_date;
3924 l_rec_05_retro_ptp(g_retro_ptp_count).end_date := l_ptp_log_rows.end_date;
3925 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc := l_ptp_log_rows.ptp * 100;
3926 END IF;
3927 ELSIF g_retro_ptp_count = 0 THEN
3928 g_retro_ptp_count := g_retro_ptp_count + 1;
3929 l_rec_05_retro_ptp(g_retro_ptp_count).start_date := l_ptp_log_rows.start_date;
3930 l_rec_05_retro_ptp(g_retro_ptp_count).end_date := l_ptp_log_rows.end_date;
3931 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc := l_ptp_log_rows.ptp * 100;
3932 END IF;
3933 hr_utility.set_location('...start_date'||l_rec_05_retro_ptp(g_retro_ptp_count).start_date,20);
3934 hr_utility.set_location('...end_date'||l_rec_05_retro_ptp(g_retro_ptp_count).end_date,20);
3935
3936 END LOOP;
3937 CLOSE c_ptp_log_rows;
3938
3939 END LOOP;
3940 */
3941 --9503781 COPTP changes commented
3942
3943 --9503781
3944 OPEN c_get_retro_pd(p_assignment_id, g_extract_params(i).extract_start_date, g_retro_ptp_element_id, g_retro_pv_iv_id);
3945 FETCH c_get_retro_pd INTO l_ret_rec05_pd;
3946 CLOSE c_get_retro_pd;
3947
3948 FOR rec_05 in c_ret_rec05_ptp(p_assignment_id, l_ret_rec05_pd.start_date, l_ret_rec05_pd.end_date)
3949 LOOP
3950 IF l_prev_ptp_rec_05 <> rec_05.ptp THEN
3951 g_retro_ptp_count := g_retro_ptp_count + 1;
3952 l_rec_05_retro_ptp(g_retro_ptp_count).start_date := rec_05.Start_Date;
3953 l_rec_05_retro_ptp(g_retro_ptp_count).end_date := rec_05.End_Date;
3954 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc := rec_05.ptp;
3955 ELSE
3956 l_rec_05_retro_ptp(g_retro_ptp_count).end_date := rec_05.End_Date;
3957 END IF;
3958 l_prev_ptp_rec_05 := rec_05.ptp;
3959 END LOOP;
3960 --9503781
3961
3962 ELSIF l_cur_ptp = 0 AND l_hourly_salaried_code <> 'S' THEN -- Hourly EE --7555712
3963
3964 FOR retro_rec_05 IN c_get_retro_ptp(c_asg_id => p_assignment_id
3965 ,c_effective_date => g_extract_params(i).extract_start_date
3966 ,c_ele_type_id => g_retro_ptp_element_id
3967 ,c_input_val_id => g_retro_pv_iv_id)
3968 LOOP
3969 hr_utility.set_location(' -- Inside the loop to fetch retro elements',-999);
3970 l_hourly_ee_avg_ptp_prev := 0;
3971 g_retro_ptp_count := g_retro_ptp_count + 1;
3972 l_rec_05_retro_ptp(g_retro_ptp_count).start_date
3973 := get_min_date(l_asg_hire_dt,retro_rec_05.start_date);
3974 IF l_asg_term_dt IS NOT NULL THEN
3975 l_rec_05_retro_ptp(g_retro_ptp_count).end_date
3976 := get_min_date(l_asg_term_dt - 1,(retro_rec_05.end_date - 1));
3977 ELSE
3978 l_rec_05_retro_ptp(g_retro_ptp_count).end_date
3979 := retro_rec_05.end_date - 1;
3980 END IF;
3981
3982 /*l_hourly_ee_avg_ptp_prev := Get_Balance_Value_Eff_Dt
3983 (p_assignment_id => p_assignment_id
3984 ,p_business_group_id => p_business_group_id
3985 ,p_balance_name => 'ABP Average Part Time Percentage'
3986 ,p_error_message => p_error_message
3987 ,p_start_date => retro_rec_05.start_date
3988 ,p_end_date => retro_rec_05.end_date);
3989
3990 l_hourly_ee_avg_ptp_prev := round(NVL(l_hourly_ee_avg_ptp_prev,0),2); */
3991
3992
3993 --
3994 -- Derive the retro hourly ptp reported earlier to ABP
3995 --
3996 l_prior_hourly_ee_ptp := 0;
3997
3998 OPEN c_prior_hourly_ee_ptp
3999 (c_asg_id => p_assignment_id
4000 ,c_effective_date => g_extract_params(i).extract_start_date
4001 ,c_orig_st_date => retro_rec_05.start_date
4002 ,c_orig_ed_date => retro_rec_05.end_date
4003 ,c_ele_type_id => g_retro_ptp_element_id
4004 ,c_input_val_id => g_retro_pv_iv_id);
4005 FETCH c_prior_hourly_ee_ptp INTO l_prior_hourly_ee_ptp;
4006 CLOSE c_prior_hourly_ee_ptp;
4007
4008 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc :=
4009 (retro_rec_05.ptp +
4010 l_hourly_ee_avg_ptp_prev +
4011 l_prior_hourly_ee_ptp) * 100;
4012
4013 --7361997 If condition Added
4014 IF (LEAST(retro_rec_05.end_date,nvl(l_asg_term_dt,retro_rec_05.end_date)) - GREATEST(l_asg_hire_dt,retro_rec_05.start_date)+1) > 0
4015 THEN
4016 --Bug# 5973446
4017 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc :=
4018 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc *
4019 (
4020 ((retro_rec_05.end_date - retro_rec_05.start_date)+1)
4021 /
4022 (LEAST(retro_rec_05.end_date,nvl(l_asg_term_dt,retro_rec_05.end_date)) -
4023 GREATEST(l_asg_hire_dt,retro_rec_05.start_date)+1)
4024 );
4025 --Bug# 5973446
4026 END IF; --7361997
4027
4028 --7361970
4029 l_rec_05_retro_ptp(g_retro_ptp_count).end_date := l_rec_05_retro_ptp(g_retro_ptp_count).end_date + 1;
4030 --7361970
4031 hr_utility.set_location(' -- Done populating PLSQL tbl',-999);
4032 END LOOP;
4033
4034 END IF; -- Check for regular or hourly EE's
4035
4036 END IF;
4037
4038 CLOSE c_ptp_chg_exist;
4039
4040 --6501898
4041 IF l_cur_ptp = 0 AND l_hourly_salaried_code <> 'S' THEN --7555712
4042 hr_utility.set_location(' -- Inside the l_cur_ptp = 0',-999);
4043
4044 OPEN c_ptp_chg_hrly_exist (c_asg_id => p_assignment_id
4045 ,c_effective_date => g_extract_params(i).extract_start_date
4046 ,c_ele_type_id => g_abp_ptp_ele_id
4047 ,c_input_val_id => g_abp_ptp_iv_id);
4048
4049 FETCH c_ptp_chg_hrly_exist INTO l_ptp_chg_hrly_exist;
4050 CLOSE c_ptp_chg_hrly_exist;
4051
4052 IF l_ptp_chg_hrly_exist.Yes = 'Y' THEN
4053 hr_utility.set_location(' -- Inside the if condition c_ptp_chg_hrly_exist FOUND ',-999);
4054
4055 FOR non_retro_rec_05 IN c_ptp_chg_hrly_exist(c_asg_id => p_assignment_id
4056 ,c_effective_date => g_extract_params(i).extract_start_date
4057 ,c_ele_type_id => g_abp_ptp_ele_id
4058 ,c_input_val_id => g_abp_ptp_iv_id)
4059 LOOP
4060 hr_utility.set_location(' -- Inside the loop to fetch non retro elements',-999);
4061 hr_utility.set_location(' -- g_retro_ptp_count Before'||g_retro_ptp_count,-999);
4062 hr_utility.set_location(' -- p_assignment_id'||p_assignment_id,-999);
4063 hr_utility.set_location(' -- g_extract_params(i).extract_start_date'||g_extract_params(i).extract_start_date,-999);
4064 hr_utility.set_location(' -- g_abp_ptp_ele_id:'||g_abp_ptp_ele_id||' g_abp_ptp_iv_id:'||g_abp_ptp_iv_id,-999);
4065
4066 g_retro_ptp_count := g_retro_ptp_count + 1;
4067 l_rec_05_retro_ptp(g_retro_ptp_count).start_date
4068 := get_min_date(l_asg_hire_dt,non_retro_rec_05.start_date);
4069 IF l_asg_term_dt IS NOT NULL THEN
4070 l_rec_05_retro_ptp(g_retro_ptp_count).end_date
4071 := get_min_date(l_asg_term_dt - 1,(non_retro_rec_05.end_date - 1));
4072 ELSE
4073 l_rec_05_retro_ptp(g_retro_ptp_count).end_date
4074 := non_retro_rec_05.end_date - 1;
4075 END IF;
4076
4077 hr_utility.set_location(' -- g_retro_ptp_count After'||g_retro_ptp_count,-999);
4078
4079
4080 /*
4081 --
4082 -- Derive the retro hourly ptp reported earlier to ABP
4083 --
4084 l_prior_hourly_ee_ptp := 0;
4085
4086 OPEN c_prior_hourly_ee_ptp
4087 (c_asg_id => p_assignment_id
4088 ,c_effective_date => g_extract_params(i).extract_start_date
4089 ,c_orig_st_date => retro_rec_05.start_date
4090 ,c_orig_ed_date => retro_rec_05.end_date
4091 ,c_ele_type_id => g_retro_ptp_element_id
4092 ,c_input_val_id => g_retro_pv_iv_id);
4093 FETCH c_prior_hourly_ee_ptp INTO l_prior_hourly_ee_ptp;
4094 CLOSE c_prior_hourly_ee_ptp;
4095
4096 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc :=
4097 (retro_rec_05.ptp +
4098 l_hourly_ee_avg_ptp_prev +
4099 l_prior_hourly_ee_ptp) * 100;
4100 */
4101 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc :=
4102 non_retro_rec_05.ptp * 100;
4103
4104 --7361997 If condition Added
4105 IF (LEAST(non_retro_rec_05.end_date,nvl(l_asg_term_dt,non_retro_rec_05.end_date)) - GREATEST(l_asg_hire_dt,non_retro_rec_05.start_date)+1) > 0
4106 THEN
4107 --Bug# 5973446
4108 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc :=
4109 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc *
4110 (
4111 ((non_retro_rec_05.end_date - non_retro_rec_05.start_date)+1)
4112 /
4113 (LEAST(non_retro_rec_05.end_date,nvl(l_asg_term_dt,non_retro_rec_05.end_date)) -
4114 GREATEST(l_asg_hire_dt,non_retro_rec_05.start_date)+1)
4115 );
4116 --Bug# 5973446
4117 END IF; --7361997
4118
4119 --7361970
4120 l_rec_05_retro_ptp(g_retro_ptp_count).end_date := l_rec_05_retro_ptp(g_retro_ptp_count).end_date + 1;
4121 --7361970
4122 hr_utility.set_location(' -- Done populating PLSQL tbl for non retro late hire',-999);
4123 END LOOP;
4124
4125 END IF;
4126 --
4127
4128 END IF;
4129
4130 --6501898
4131
4132 l_fp_new_hire := g_new_hire_asg;
4133 l_fp_hire_dt := g_hire_date;
4134
4135
4136 IF l_fp_new_hire = 0 AND l_cur_ptp <> 0 THEN
4137
4138 --
4139 -- Report part time percentage changes of the current period
4140 -- from the change event logs. Note that this is not the same
4141 -- period as the new hire. Not applicable for hourly EEs
4142 --
4143
4144 OPEN c_get_min_st_dt;
4145
4146 FETCH c_get_min_st_dt INTO l_cur_ptp_min_st_dt;
4147
4148 IF c_get_min_st_dt%FOUND THEN
4149
4150
4151 OPEN c_current_ptp_chgs (l_cur_ptp_min_st_dt);
4152 --
4153 -- Get the data from the log rows
4154 --
4155 LOOP
4156 FETCH c_current_ptp_chgs INTO l_ptp_log_rows;
4157
4158 EXIT WHEN c_current_ptp_chgs%NOTFOUND;
4159 hr_utility.set_location('....Inside the loop',20);
4160 IF g_retro_ptp_count > 0 THEN
4161 --
4162 -- Check if the ptp is the same and the dates are continuous
4163 --
4164 IF ( trunc(l_rec_05_retro_ptp(g_retro_ptp_count).end_date) + 1 =
4165 trunc(l_ptp_log_rows.start_date) AND
4166 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc =
4167 l_ptp_log_rows.ptp * 100 ) THEN
4168 l_rec_05_retro_ptp(g_retro_ptp_count).end_date
4169 := l_ptp_log_rows.end_date;
4170 hr_utility.set_location('...Updated the date',20);
4171 ELSE
4172 g_retro_ptp_count := g_retro_ptp_count + 1;
4173 l_rec_05_retro_ptp(g_retro_ptp_count).start_date
4174 := l_ptp_log_rows.start_date;
4175 l_rec_05_retro_ptp(g_retro_ptp_count).end_date
4176 := l_ptp_log_rows.end_date;
4177 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc
4178 := l_ptp_log_rows.ptp * 100;
4179 END IF;
4180 ELSIF g_retro_ptp_count = 0 THEN
4181 g_retro_ptp_count := g_retro_ptp_count + 1;
4182 l_rec_05_retro_ptp(g_retro_ptp_count).start_date
4183 := l_ptp_log_rows.start_date;
4184 l_rec_05_retro_ptp(g_retro_ptp_count).end_date
4185 := l_ptp_log_rows.end_date;
4186 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc
4187 := l_ptp_log_rows.ptp * 100;
4188 END IF;
4189 hr_utility.set_location('...start_date'
4190 ||l_rec_05_retro_ptp(g_retro_ptp_count).start_date,20);
4191 hr_utility.set_location('...end_date'
4192 ||l_rec_05_retro_ptp(g_retro_ptp_count).end_date,20);
4193
4194 END LOOP;
4195 CLOSE c_current_ptp_chgs;
4196 END IF;
4197 CLOSE c_get_min_st_dt;
4198
4199 END IF;
4200
4201 --7361922
4202 OPEN c_ude_ele_iv_id(p_business_group_id, g_extract_params(i).extract_start_date) ;
4203 FETCH c_ude_ele_iv_id INTO l_sd_input_val_id, l_ed_input_val_id, l_ude_ele_type_id;
4204 CLOSE c_ude_ele_iv_id;
4205
4206 OPEN c_ude_rec05(g_extract_params(i).extract_start_date,
4207 l_ude_ele_type_id,
4208 l_sd_input_val_id,
4209 l_ed_input_val_id,
4210 p_assignment_id);
4211 FETCH c_ude_rec05 INTO l_ude_rec05;
4212 IF c_ude_rec05%FOUND THEN
4213 FOR r05 in c_ude_rec05_ptp(p_assignment_id, l_ude_rec05.start_date, l_ude_rec05.end_date)
4214 LOOP
4215 IF l_prev_ptp_05 <> r05.ptp THEN
4216 g_retro_ptp_count := g_retro_ptp_count + 1;
4217 l_rec_05_retro_ptp(g_retro_ptp_count).start_date := r05.Start_Date;
4218 l_rec_05_retro_ptp(g_retro_ptp_count).end_date := r05.End_Date;
4219 l_rec_05_retro_ptp(g_retro_ptp_count).part_time_perc := r05.ptp;
4220 ELSE
4221 l_rec_05_retro_ptp(g_retro_ptp_count).end_date := r05.End_Date;
4222 END IF;
4223 l_prev_ptp_05 := r05.ptp;
4224 END LOOP;
4225 CLOSE c_ude_rec05;
4226 ELSE
4227 CLOSE c_ude_rec05;
4228 END IF;
4229 --7361922
4230
4231 -- ============================================================================
4232 -- END Populate Record 05 Retro PTP change information
4233 -- ============================================================================
4234
4235 -- ============================================================================
4236 -- BEGIN Populate Record 09 details for Cur period,retro prev yr and cur yr
4237 -- ============================================================================
4238 IF l_rec_09.count > 0 THEN
4239 k := 1;
4240 FOR i IN l_rec_09.FIRST..l_rec_09.LAST
4241 LOOP
4242 l_rr_exists := 0;
4243 hr_utility.set_location('...Current element : '
4244 ||l_rec_09(i).element_type_id,10);
4245 hr_utility.set_location('..Assignment Id : '||p_assignment_id,12);
4246 hr_utility.set_location('..Payroll id : '
4247 ||g_extract_params(p_business_group_id).payroll_id,13);
4248 hr_utility.set_location('..Start date : '
4249 ||g_extract_params(p_business_group_id).extract_start_date,14);
4250 hr_utility.set_location('..End date : '
4251 ||g_extract_params(p_business_group_id).extract_end_date,15);
4252
4253 FOR act_rec IN csr_asg_act (
4254 c_assignment_id => p_assignment_id
4255 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
4256 ,c_con_set_id => NULL
4257 ,c_start_date => g_extract_params(p_business_group_id).extract_start_date
4258 ,c_end_date => g_extract_params(p_business_group_id).extract_end_date)
4259 LOOP
4260 hr_utility.set_location('..Asg act id : '||act_rec.assignment_action_id,20);
4261 --
4262 -- populate the PLSQL table with the retro basis entries
4263 -- and the start and end date of the corresponding retro paid period
4264 -- for ABP (record 09)
4265 --
4266 -- Previous Year Retro
4267 --
4268 FOR temp_rec IN c_get_retro_entry
4269 (c_element_type_id =>
4270 fnd_number.canonical_to_number(l_rec_09(i).py_retro_element_id)
4271 ,c_assignment_action_id => act_rec.assignment_action_id)
4272 LOOP
4273 hr_utility.set_location('..Found previous year retro entries',30);
4274 --
4275 -- Fetch the input value id for ABP Employee Pension Basis input value
4276 --
4277 OPEN c_get_iv_id(c_element_type_id =>
4278 fnd_number.canonical_to_number(l_rec_09(i).py_retro_element_id));
4279 FETCH c_get_iv_id INTO l_basis_iv_id;
4280 CLOSE c_get_iv_id;
4281
4282 --
4283 --fetch the pension basis retro value for this current
4284 --element entry id
4285 --
4286 OPEN c_get_retro_num_value(c_element_entry_id => temp_rec.element_entry_id
4287 ,c_input_value_id => l_basis_iv_id);
4288 FETCH c_get_retro_num_value INTO l_retro_ptp_value;
4289 CLOSE c_get_retro_num_value;
4290
4291 l_retro_age_cal_dt :=
4292 fnd_date.canonical_to_date(substr(substr(
4293 fnd_date.date_to_canonical(
4294 pay_paywsmee_pkg.get_original_date_earned(
4295 temp_rec.element_entry_id)),1,10),1,8)||'01');
4296
4297
4298 IF l_retro_ptp_value <> 0 AND chk_subcat_disp (l_rec_09(i).code
4299 ,l_retro_age_cal_dt) THEN
4300 l_rec_09_values(k).basis_amount := l_retro_ptp_value;
4301 l_rec_09_disp := 'Y';
4302 l_rec_09_values(k).processed := 'N';
4303 l_rec_09_values(k).code := l_rec_09(i).code;
4304 l_rec_09_values(k).date_earned := ' ';
4305
4306 IF l_rec_09_values(k).basis_amount < 0 THEN
4307 l_rec_09_values(k).sign_code := 'C';
4308 END IF;
4309
4310 k := k + 1;
4311
4312 END IF;
4313
4314 END LOOP;
4315
4316 --
4317 -- Current Year Retro
4318 --
4319 FOR temp_rec IN c_get_retro_entry
4320 (c_element_type_id => fnd_number.canonical_to_number(
4321 l_rec_09(i).cy_retro_element_id)
4322 ,c_assignment_action_id => act_rec.assignment_action_id)
4323 LOOP
4324 hr_utility.set_location('...Found current year retro entries',30);
4325 --
4326 -- Fetch the input value id for ABP Employee Pension Basis input value
4327 --
4328 OPEN c_get_iv_id(c_element_type_id =>
4329 fnd_number.canonical_to_number(l_rec_09(i).cy_retro_element_id));
4330 FETCH c_get_iv_id INTO l_basis_iv_id;
4331 CLOSE c_get_iv_id;
4332
4333 --
4334 -- Fetch the pension basis retro value for this current
4335 -- element entry id
4336 --
4337 OPEN c_get_retro_num_value(c_element_entry_id => temp_rec.element_entry_id
4338 ,c_input_value_id => l_basis_iv_id);
4339 FETCH c_get_retro_num_value INTO l_retro_ptp_value;
4340 CLOSE c_get_retro_num_value;
4341
4342
4343 l_retro_age_cal_dt :=
4344 fnd_date.canonical_to_date(substr(substr(
4345 fnd_date.date_to_canonical(
4346 pay_paywsmee_pkg.get_original_date_earned(
4347 temp_rec.element_entry_id)),1,10),1,8)||'01');
4348
4349 l_ee_age_at_retro := Get_Age(
4350 p_assignment_id
4351 ,trunc(l_retro_age_cal_dt)) ;
4352
4353 hr_utility.set_location('...l_retro_age_cal_dt :'||l_retro_age_cal_dt,50);
4354 hr_utility.set_location('...l_ee_age_at_retro :'||l_ee_age_at_retro,50);
4355
4356 IF l_ee_age_at_retro < 65 AND chk_subcat_disp (l_rec_09(i).code
4357 ,l_retro_age_cal_dt) THEN
4358 IF l_retro_ptp_value <> 0 THEN
4359 l_rec_09_values(k).basis_amount := l_retro_ptp_value;
4360 l_rec_09_disp := 'Y';
4361 l_rec_09_values(k).processed := 'N';
4362 l_rec_09_values(k).code := l_rec_09(i).code;
4363 l_rec_09_values(k).date_earned := ' ';
4364
4365 hr_utility.set_location('GAA-- Date Earned used :'
4366 ||l_rec_09_values(k).date_earned,50);
4367
4368 IF l_rec_09_values(k).basis_amount < 0 THEN
4369 l_rec_09_values(k).sign_code := 'C';
4370 END IF;
4371
4372 k := k + 1;
4373
4374 END IF;
4375
4376 END IF; -- AGe
4377
4378 END LOOP;
4379
4380 --
4381 -- Adjustment Retro Entries
4382 --
4383 FOR temp_rec IN c_get_retro_entry
4384 (c_element_type_id => l_rec_09(i).py_cy_adj_retro_element_id
4385 ,c_assignment_action_id => act_rec.assignment_action_id)
4386 LOOP
4387 hr_utility.set_location('...Found Adjustment retro entries',30);
4388 --
4389 -- Fetch the input value id for ABP Employee Pension Basis input value
4390 --
4391 OPEN c_get_iv_id(c_element_type_id => l_rec_09(i).py_cy_adj_retro_element_id);
4392 FETCH c_get_iv_id INTO l_basis_iv_id;
4393 CLOSE c_get_iv_id;
4394
4395 --
4396 -- Fetch the pension basis retro value for this current
4397 -- element entry id
4398 --
4399 OPEN c_get_retro_num_value(c_element_entry_id => temp_rec.element_entry_id
4400 ,c_input_value_id => l_basis_iv_id);
4401 FETCH c_get_retro_num_value INTO l_retro_ptp_value;
4402 CLOSE c_get_retro_num_value;
4403
4404
4405 l_retro_age_cal_dt :=
4406 fnd_date.canonical_to_date(substr(substr(
4407 fnd_date.date_to_canonical(
4408 pay_paywsmee_pkg.get_original_date_earned(
4409 temp_rec.element_entry_id)),1,10),1,8)||'01');
4410
4411 l_ee_age_at_retro := Get_Age(
4412 p_assignment_id
4413 ,trunc(l_retro_age_cal_dt)) ;
4414
4415 hr_utility.set_location('...l_retro_age_cal_dt :'||l_retro_age_cal_dt,50);
4416 hr_utility.set_location('...l_ee_age_at_retro :'||l_ee_age_at_retro,50);
4417
4418 IF l_ee_age_at_retro < 65 AND chk_subcat_disp (l_rec_09(i).code
4419 ,l_retro_age_cal_dt) THEN
4420 IF l_retro_ptp_value <> 0 THEN
4421 l_rec_09_values(k).basis_amount := l_retro_ptp_value;
4422 l_rec_09_disp := 'Y';
4423 l_rec_09_values(k).processed := 'N';
4424 l_rec_09_values(k).code := l_rec_09(i).code;
4425 l_rec_09_values(k).date_earned := ' ';
4426
4427 hr_utility.set_location('GAA-- Date Earned used :'
4428 ||l_rec_09_values(k).date_earned,50);
4429
4430 IF l_rec_09_values(k).basis_amount < 0 THEN
4431 l_rec_09_values(k).sign_code := 'C';
4432 END IF;
4433
4434 k := k + 1;
4435
4436 END IF;
4437
4438 END IF; -- AGe
4439
4440 END LOOP;
4441
4442 l_reg_09_age_cal_dt := fnd_date.canonical_to_date(
4443 substr(substr(fnd_date.date_to_canonical(
4444 act_rec.date_earned),1,10),1,8)||'01');
4445
4446 l_reg_09_age := Get_Age(p_assignment_id
4447 ,trunc(l_reg_09_age_cal_dt)) ;
4448
4449 IF l_reg_09_age < 65 AND chk_subcat_disp (l_rec_09(i).code
4450 ,l_reg_09_age_cal_dt) THEN
4451
4452 IF NOT chk_asg_term_py (p_assignment_id => p_assignment_id
4453 ,p_ext_st => g_extract_params(p_business_group_id).extract_start_date) THEN
4454
4455 --
4456 -- Check if Run Results exist for this element/ass act
4457 --
4458 IF chk_rr_exist (p_ass_act_id => act_rec.assignment_action_id
4459 ,p_element_type_id => l_rec_09(i).element_type_id ) THEN
4460 -- Call pay_balance_pkg
4461 hr_utility.set_location('Run results exist for current period',40);
4462
4463 IF l_rec_09(i).defined_bal_id <> -1 THEN
4464
4465 l_rec_09_values(k).basis_amount :=
4466 Pay_Balance_Pkg.get_value
4467 (p_defined_balance_id => l_rec_09(i).defined_bal_id
4468 ,p_assignment_action_id => act_rec.assignment_action_id);
4469 hr_utility.set_location('Defined bal id used :'
4470 ||l_rec_09(i).defined_bal_id,50);
4471 l_rec_09_disp := 'Y';
4472 l_rec_09_values(k).processed := 'N';
4473 l_rec_09_values(k).code := l_rec_09(i).code;
4474 l_rec_09_values(k).date_earned := ' ';
4475
4476 IF l_rec_09_values(k).basis_amount < 0 THEN
4477 l_rec_09_values(k).sign_code := 'C';
4478 END IF;
4479 k := k + 1;
4480 END IF;--end of defined bal check
4481
4482 END IF;-- End of rr check
4483 END IF; -- Check asg term in prev year
4484 END IF; -- Age check
4485
4486 END LOOP; -- Asg Acts
4487 END LOOP; -- Elements
4488 END IF;
4489
4490 -- ============================================================================
4491 -- END Populate Record 09 details for Cur period,retro prev yr and cur yr
4492 -- ============================================================================
4493
4494 --
4495 -- Populate the Record 09 PL SQL table with values from the
4496 -- previous runs if there has been a change in hire date
4497 -- Marker GXX
4498 --
4499 IF l_old_start IS NOT NULL AND l_new_start IS NOT NULL THEN
4500 --
4501 -- Hire Date is changed to the past
4502 --
4503 IF trunc(l_new_start) < trunc(l_old_start) THEN
4504 --
4505 -- Derive the beginning date
4506 --
4507 l_beg_new_st := fnd_date.canonical_to_date(to_char(l_new_start,'YYYY/MM')||'/01');
4508 --
4509 -- If the beginnind date is less then the current extract start
4510 -- Loop through the assignment actions to derive contrib amounts
4511 -- of that period
4512 --
4513 WHILE trunc(l_beg_new_st) < trunc(g_extract_params(p_business_group_id).extract_start_date)
4514 LOOP
4515 l_end_new_st := add_months(trunc(l_beg_new_st),1) -1;
4516 --
4517 -- If Data has been sent to ABP , so not send it again
4518 --
4519 OPEN c_sent_to_abp(l_end_new_st);
4520 FETCH c_sent_to_abp INTO l_sent_to_abp;
4521 IF c_sent_to_abp%NOTFOUND THEN
4522 IF l_rec_09.count > 0 THEN
4523 FOR i IN l_rec_09.FIRST..l_rec_09.LAST
4524 LOOP
4525 l_rr_exists := 0;
4526 hr_utility.set_location('current element : '||l_rec_09(i).element_type_id,10);
4527 hr_utility.set_location('asg id : '||p_assignment_id,12);
4528 hr_utility.set_location('start date : ',14);
4529 hr_utility.set_location('end date : ',15);
4530 FOR act_rec IN csr_asg_act (
4531 c_assignment_id => p_assignment_id
4532 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
4533 ,c_con_set_id => NULL
4534 ,c_start_date => l_beg_new_st
4535 ,c_end_date => l_end_new_st)
4536 LOOP
4537
4538 l_reg_09_age_cal_dt := l_beg_new_st;
4539 l_reg_09_age := Get_Age(p_assignment_id,trunc(l_reg_09_age_cal_dt)) ;
4540
4541 IF l_reg_09_age < 65 THEN
4542 -- Check if Run Results exist for this element/ass act
4543 IF chk_rr_exist (p_ass_act_id => act_rec.assignment_action_id
4544 ,p_element_type_id => l_rec_09(i).element_type_id ) THEN
4545 -- Call pay_balance_pkg
4546 hr_utility.set_location('run results exist for current period',40);
4547 IF l_rec_09(i).defined_bal_id <> -1 THEN
4548 l_rec_09_values(k).basis_amount :=
4549 Pay_Balance_Pkg.get_value
4550 (p_defined_balance_id => l_rec_09(i).defined_bal_id
4551 ,p_assignment_action_id => act_rec.assignment_action_id);
4552 hr_utility.set_location('defined bal id used :'||l_rec_09(i).defined_bal_id,50);
4553 l_rec_09_disp := 'Y';
4554 l_rec_09_values(k).processed := 'N';
4555 l_rec_09_values(k).code := l_rec_09(i).code;
4556 l_rec_09_values(k).date_earned := ' ';
4557
4558 IF l_rec_09_values(k).basis_amount < 0 THEN
4559 l_rec_09_values(k).sign_code := 'C';
4560 END IF;
4561 k := k + 1;
4562 END IF;-- Defined bal check
4563 END IF;-- RR exist check
4564 END IF; -- Age check
4565 END LOOP; -- Ass acts
4566 END LOOP; -- All elements for Rec 09
4567 END IF; -- Record 09 elements exist
4568 END IF; -- Data not sent to ABP
4569 CLOSE c_sent_to_abp;
4570 l_beg_new_st := ADD_MONTHS(l_beg_new_st,1);
4571 END LOOP; -- Loop through the months
4572
4573 ELSIF trunc(l_new_start) > trunc(l_old_start) THEN
4574
4575 --
4576 -- Derive the beginning date
4577 --
4578 l_beg_new_st := fnd_date.canonical_to_date(to_char(l_old_start,'YYYY/MM')||'/01');
4579 l_loop_end_date := add_months(fnd_date.canonical_to_date(to_char(l_new_start,'YYYY/MM')||'/01'),1) - 1;
4580 l_loop_end_date := LEAST ( g_extract_params(p_business_group_id).extract_start_date -1
4581 ,l_loop_end_date);
4582 -- GZZ
4583 --
4584 --
4585 -- Loop through the dates to derive data to be reported to ABP
4586 -- this might include ony the differences of that period or the entire amount
4587 -- for the month
4588 --
4589 WHILE trunc(l_beg_new_st) < l_loop_end_date
4590 LOOP
4591 l_end_new_st := add_months(trunc(l_beg_new_st),1) -1;
4592 l_gzz_asg_act_xst := 0;
4593
4594 IF l_rec_09.count > 0 THEN
4595 FOR i IN l_rec_09.FIRST..l_rec_09.LAST
4596 LOOP
4597 l_rr_exists := 0;
4598 hr_utility.set_location('current element : '||l_rec_09(i).element_type_id,10);
4599 hr_utility.set_location('asg id : '||p_assignment_id,12);
4600 hr_utility.set_location('start date : ',14);
4601 hr_utility.set_location('end date : ',15);
4602 FOR act_rec IN csr_asg_act (
4603 c_assignment_id => p_assignment_id
4604 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
4605 ,c_con_set_id => NULL
4606 ,c_start_date => l_beg_new_st
4607 ,c_end_date => l_end_new_st)
4608 LOOP
4609
4610 l_reg_09_age_cal_dt := l_beg_new_st;
4611 l_reg_09_age := Get_Age(p_assignment_id,trunc(l_reg_09_age_cal_dt)) ;
4612
4613 IF l_reg_09_age < 65 THEN
4614 -- Check if Run Results exist for this element/ass act
4615 IF chk_rr_exist (p_ass_act_id => act_rec.assignment_action_id
4616 ,p_element_type_id => l_rec_09(i).element_type_id ) THEN
4617 -- Call pay_balance_pkg
4618 hr_utility.set_location('run results exist for current period',40);
4619 IF l_rec_09(i).defined_bal_id <> -1 THEN
4620 l_rec_09_values(k).basis_amount :=
4621 Pay_Balance_Pkg.get_value
4622 (p_defined_balance_id => l_rec_09(i).defined_bal_id
4623 ,p_assignment_action_id => act_rec.assignment_action_id);
4624 hr_utility.set_location('defined bal id used :'||l_rec_09(i).defined_bal_id,50);
4625 l_rec_09_disp := 'Y';
4626 l_rec_09_values(k).processed := 'N';
4627 l_rec_09_values(k).code := l_rec_09(i).code;
4628 l_rec_09_values(k).date_earned :=
4629 substr(fnd_date.date_to_canonical(l_end_new_st),1,10);
4630
4631 OPEN c_09_abp_data (l_end_new_st,l_rec_09(i).code);
4632 FETCH c_09_abp_data INTO l_09_basis_amt_sent_prev;
4633 IF c_09_abp_data%FOUND THEN
4634 l_rec_09_values(k).basis_amount := l_rec_09_values(k).basis_amount
4635 - l_09_basis_amt_sent_prev;
4636 END IF;
4637 CLOSE c_09_abp_data;
4638
4639 IF l_rec_09_values(k).basis_amount < 0 THEN
4640 l_rec_09_values(k).sign_code := 'C';
4641 END IF;
4642 l_gzz_asg_act_xst := 1;
4643 k := k + 1;
4644 END IF;-- Defined bal check
4645 END IF;-- RR exist check
4646
4647 END IF; -- Age check
4648 END LOOP; -- Ass acts
4649 END LOOP; -- All elements for Rec 09
4650 END IF; -- Record 09 elements exist
4651
4652
4653 IF l_rec_09.count > 0 AND l_gzz_asg_act_xst = 0 THEN
4654 FOR i IN l_rec_09.FIRST..l_rec_09.LAST
4655 LOOP
4656 OPEN c_09_abp_data (l_end_new_st,l_rec_09(i).code);
4657 FETCH c_09_abp_data INTO l_09_basis_amt_sent_prev;
4658 IF c_09_abp_data%FOUND THEN
4659 l_rec_09_values(k).basis_amount := -1 * l_09_basis_amt_sent_prev;
4660 l_rec_09_disp := 'Y';
4661 l_rec_09_values(k).processed := 'N';
4662 l_rec_09_values(k).code := l_rec_09(i).code;
4663 l_rec_09_values(k).date_earned :=
4664 substr(fnd_date.date_to_canonical(l_end_new_st),1,10);
4665 IF l_rec_09_values(k).basis_amount < 0 THEN
4666 l_rec_09_values(k).sign_code := 'C';
4667 END IF;
4668 k := k+ 1;
4669 END IF;
4670 CLOSE c_09_abp_data;
4671 END LOOP;
4672 END IF;
4673
4674 l_beg_new_st := ADD_MONTHS(l_beg_new_st,1);
4675
4676 END LOOP; -- Loop through the months
4677
4678 END IF; -- new start date < old start dt
4679
4680 END IF; -- dates are not null
4681
4682 -- ======================================================================
4683 -- Begin Principle Objection Code Changes
4684 -- ======================================================================
4685
4686 --
4687 -- get the current Princ Obj Code
4688 --
4689 l_poj_ret_val := Get_Pri_Obj_Cd_Cur(p_assignment_id
4690 ,p_business_group_id
4691 ,p_effective_date
4692 ,p_error_message
4693 ,l_poj_cd);
4694
4695 -- Populate record 09 values for the
4696 -- months in which the princlple obj code is
4697 -- different from the current value
4698
4699 FOR l_09_poj_rec IN c_09_poj_abp_data ( g_extract_params(p_business_group_id).extract_end_date
4700 ,l_poj_cd)
4701 LOOP
4702
4703 --
4704 -- Check to see if the corrected data has been sent to ABP.
4705 --
4706 l_09_poj_cor_abp_data := -1;
4707
4708 OPEN c_09_poj_cor_abp_data ( l_09_poj_rec.eff_dt
4709 ,l_poj_cd);
4710 FETCH c_09_poj_cor_abp_data INTO l_09_poj_cor_abp_data;
4711 CLOSE c_09_poj_cor_abp_data;
4712
4713 IF l_09_poj_cor_abp_data = -1 THEN
4714 --
4715 -- Debit entries
4716 --
4717 l_rec_09_values(k).basis_amount := l_09_poj_rec.basis;
4718 l_rec_09_disp := 'Y';
4719 l_rec_09_values(k).processed := 'N';
4720 l_rec_09_values(k).code := l_09_poj_rec.code;
4721 l_rec_09_values(k).date_earned :=
4722 substr(fnd_date.date_to_canonical(l_09_poj_rec.eff_dt),1,10);
4723
4724 IF l_rec_09_values(k).basis_amount < 0 THEN
4725 l_rec_09_values(k).sign_code := 'C';
4726 END IF;
4727 k := k+ 1;
4728
4729 --
4730 -- Credit entries
4731 --
4732 l_rec_09_values(k).basis_amount := -1 * l_09_poj_rec.basis;
4733 l_rec_09_disp := 'Y';
4734 l_rec_09_values(k).processed := 'N';
4735 l_rec_09_values(k).code := l_09_poj_rec.code;
4736 l_rec_09_values(k).date_earned :=
4737 substr(fnd_date.date_to_canonical(l_09_poj_rec.eff_dt),1,10);
4738
4739 IF l_rec_09_values(k).basis_amount < 0 THEN
4740 l_rec_09_values(k).sign_code := 'C';
4741 END IF;
4742 l_rec_09_values(k).pobj_flag := 'N';
4743 k := k+ 1;
4744
4745 END IF;
4746
4747 END LOOP;
4748
4749 -- ======================================================================
4750 -- End Principle Objection Code Changes
4751 -- ======================================================================
4752
4753
4754 /* code commented out by vjhanak. The value of k is getting reset.
4755 need to use a different variable for the index.
4756 -- Get the pension basis balance for record 31
4757 IF l_rec_31.count > 0 THEN
4758 k := 1;
4759 FOR i IN l_rec_31.FIRST..l_rec_31.LAST
4760 LOOP
4761 l_rr_exists := 0;
4762 FOR act_rec IN csr_asg_act (
4763 c_assignment_id => p_assignment_id
4764 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
4765 ,c_con_set_id => NULL
4766 ,c_start_date => g_extract_params(p_business_group_id).extract_start_date
4767 ,c_end_date => g_extract_params(p_business_group_id).extract_end_date)
4768 LOOP
4769 --populate the PLSQL table with the retro basis entries
4770 -- and the start and end date of the corresponding retro paid period
4771 --for ABP (record 31)
4772 FOR temp_rec IN c_get_retro_entry
4773 (c_element_type_id => fnd_number.canonical_to_number(
4774 l_rec_31(i).py_retro_element_id)
4775 ,c_assignment_action_id => act_rec.assignment_action_id
4776 )
4777 LOOP
4778 --fetch the input value id for ABP Employee Pension Basis input value
4779 OPEN c_get_iv_id(c_element_type_id => fnd_number.canonical_to_number(
4780 l_rec_31(i).py_retro_element_id));
4781 FETCH c_get_iv_id INTO l_basis_iv_id;
4782 CLOSE c_get_iv_id;
4783
4784 --fetch the pension basis retro value for this current
4785 --element entry id
4786 OPEN c_get_retro_num_value(c_element_entry_id => temp_rec.element_entry_id
4787 ,c_input_value_id => l_basis_iv_id);
4788 FETCH c_get_retro_num_value INTO l_retro_ptp_value;
4789 CLOSE c_get_retro_num_value;
4790
4791 IF l_retro_ptp_value <> 0 THEN
4792 l_rec_31_values(k).basis_amount := l_retro_ptp_value;
4793 l_rec_31_disp := 'Y';
4794 l_rec_31_values(k).processed := 'N';
4795 l_rec_31_values(k).code := l_rec_31(i).code;
4796 l_rec_31_values(k).date_earned := substr(fnd_date.date_to_canonical(
4797 pay_paywsmee_pkg.get_original_date_earned(
4798 temp_rec.element_entry_id)
4799 ),1,10);
4800
4801 IF l_rec_31_values(k).basis_amount < 0 THEN
4802 l_rec_31_values(k).sign_code := 'C';
4803 END IF;
4804 k := k + 1;
4805 END IF;
4806
4807 END LOOP;
4808
4809 FOR temp_rec IN c_get_retro_entry
4810 (c_element_type_id => fnd_number.canonical_to_number(
4811 l_rec_31(i).cy_retro_element_id)
4812 ,c_assignment_action_id => act_rec.assignment_action_id
4813 )
4814 LOOP
4815 --fetch the input value id for ABP Employee Pension Basis input value
4816 OPEN c_get_iv_id(c_element_type_id => fnd_number.canonical_to_number(
4817 l_rec_31(i).cy_retro_element_id));
4818 FETCH c_get_iv_id INTO l_basis_iv_id;
4819 CLOSE c_get_iv_id;
4820
4821 --fetch the pension basis retro value for this current
4822 --element entry id
4823 OPEN c_get_retro_num_value(c_element_entry_id => temp_rec.element_entry_id
4824 ,c_input_value_id => l_basis_iv_id);
4825 FETCH c_get_retro_num_value INTO l_retro_ptp_value;
4826 CLOSE c_get_retro_num_value;
4827
4828 IF l_retro_ptp_value <> 0 THEN
4829 l_rec_31_values(k).basis_amount := l_retro_ptp_value;
4830 l_rec_31_disp := 'Y';
4831 l_rec_31_values(k).processed := 'N';
4832 l_rec_31_values(k).code := l_rec_31(i).code;
4833 l_rec_31_values(k).date_earned := ' ';
4834 l_rec_31_values(k).date_earned := substr(fnd_date.date_to_canonical(
4835 pay_paywsmee_pkg.get_original_date_earned(
4836 temp_rec.element_entry_id)
4837 ),1,10);
4838
4839 IF l_rec_31_values(k).basis_amount < 0 THEN
4840 l_rec_31_values(k).sign_code := 'C';
4841 END IF;
4842 k := k + 1;
4843 END IF;
4844
4845 END LOOP;
4846
4847 -- Check if Run Results exist for this element/ass act
4848 IF chk_rr_exist (p_ass_act_id => act_rec.assignment_action_id
4849 ,p_element_type_id => l_rec_31(i).element_type_id ) THEN
4850 -- Call pay_balance_pkg
4851 IF l_rec_31(i).defined_bal_id <> -1 THEN
4852 l_rec_31_values(k).basis_amount :=
4853 Pay_Balance_Pkg.get_value
4854 (p_defined_balance_id => l_rec_31(i).defined_bal_id
4855 ,p_assignment_action_id => act_rec.assignment_action_id);
4856 l_rec_31_disp := 'Y';
4857 l_rec_31_values(k).processed := 'N';
4858 l_rec_31_values(k).code := l_rec_31(i).code;
4859 l_rec_31_values(k).date_earned := ' ';
4860
4861 IF l_rec_31_values(k).basis_amount < 0 THEN
4862 l_rec_31_values(k).sign_code := 'C';
4863 END IF;
4864 k := k + 1;
4865 END IF;
4866 END IF;
4867 END LOOP; -- Asg Acts
4868 END LOOP; -- Elements
4869 END IF;
4870
4871 -- Get the pension basis balance for record 41
4872 IF l_basis_rec_41.count > 0 THEN
4873 k := 1;
4874 FOR i IN l_basis_rec_41.FIRST..l_basis_rec_41.LAST
4875 LOOP
4876 l_rr_exists := 0;
4877 FOR act_rec IN csr_asg_act (
4878 c_assignment_id => p_assignment_id
4879 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
4880 ,c_con_set_id => NULL
4881 ,c_start_date => g_extract_params(p_business_group_id).extract_start_date
4882 ,c_end_date => g_extract_params(p_business_group_id).extract_end_date)
4883 LOOP
4884 --populate the PLSQL table with the retro basis entries
4885 -- and the start and end date of the corresponding retro paid period
4886 --for ABP (record 41)
4887 FOR temp_rec IN c_get_retro_entry
4888 (c_element_type_id => fnd_number.canonical_to_number(
4889 l_basis_rec_41(i).py_retro_element_id)
4890 ,c_assignment_action_id => act_rec.assignment_action_id
4891 )
4892 LOOP
4893 --fetch the input value id for ABP Employee Pension Basis input value
4894 OPEN c_get_iv_id(c_element_type_id => fnd_number.canonical_to_number(
4895 l_basis_rec_41(i).py_retro_element_id));
4896 FETCH c_get_iv_id INTO l_basis_iv_id;
4897 CLOSE c_get_iv_id;
4898
4899 --fetch the pension basis retro value for this current
4900 --element entry id
4901 OPEN c_get_retro_num_value(c_element_entry_id => temp_rec.element_entry_id
4902 ,c_input_value_id => l_basis_iv_id);
4903 FETCH c_get_retro_num_value INTO l_retro_ptp_value;
4904 CLOSE c_get_retro_num_value;
4905
4906 IF l_retro_ptp_value <> 0 THEN
4907 l_rec_41_basis_values(k).basis_amount := l_retro_ptp_value;
4908 l_basis_rec_41_disp := 'Y';
4909 l_rec_41_basis_values(k).processed := 'N';
4910 l_rec_41_basis_values(k).code := l_basis_rec_41(i).code;
4911 l_rec_41_basis_values(k).date_earned := substr(fnd_date.date_to_canonical(
4912 pay_paywsmee_pkg.get_original_date_earned(
4913 temp_rec.element_entry_id)
4914 ),1,10);
4915
4916 IF l_rec_41_basis_values(k).basis_amount < 0 THEN
4917 l_rec_41_basis_values(k).sign_code := 'C';
4918 END IF;
4919 k := k + 1;
4920 END IF;
4921
4922 END LOOP;
4923
4924 FOR temp_rec IN c_get_retro_entry
4925 (c_element_type_id => fnd_number.canonical_to_number(
4926 l_basis_rec_41(i).cy_retro_element_id)
4927 ,c_assignment_action_id => act_rec.assignment_action_id
4928 )
4929 LOOP
4930 --fetch the input value id for ABP Employee Pension Basis input value
4931 OPEN c_get_iv_id(c_element_type_id => fnd_number.canonical_to_number(
4932 l_basis_rec_41(i).cy_retro_element_id));
4933 FETCH c_get_iv_id INTO l_basis_iv_id;
4934 CLOSE c_get_iv_id;
4935
4936 --fetch the pension basis retro value for this current
4937 --element entry id
4938 OPEN c_get_retro_num_value(c_element_entry_id => temp_rec.element_entry_id
4939 ,c_input_value_id => l_basis_iv_id);
4940 FETCH c_get_retro_num_value INTO l_retro_ptp_value;
4941 CLOSE c_get_retro_num_value;
4942
4943 IF l_retro_ptp_value <> 0 THEN
4944 l_rec_41_basis_values(k).basis_amount := l_retro_ptp_value;
4945 l_basis_rec_41_disp := 'Y';
4946 l_rec_41_basis_values(k).processed := 'N';
4947 l_rec_41_basis_values(k).code := l_basis_rec_41(i).code;
4948 l_rec_41_basis_values(k).date_earned := ' ';
4949 l_rec_41_basis_values(k).date_earned := substr(fnd_date.date_to_canonical(
4950 pay_paywsmee_pkg.get_original_date_earned(
4951 temp_rec.element_entry_id)
4952 ),1,10);
4953
4954 IF l_rec_41_basis_values(k).basis_amount < 0 THEN
4955 l_rec_41_basis_values(k).sign_code := 'C';
4956 END IF;
4957 k := k + 1;
4958 END IF;
4959
4960 END LOOP;
4961
4962 -- Check if Run Results exist for this element/ass act
4963 IF chk_rr_exist (p_ass_act_id => act_rec.assignment_action_id
4964 ,p_element_type_id => l_basis_rec_41(i).element_type_id ) THEN
4965 -- Call pay_balance_pkg
4966 IF l_basis_rec_41(i).defined_bal_id <> -1 THEN
4967 l_rec_41_basis_values(k).basis_amount :=
4968 Pay_Balance_Pkg.get_value
4969 (p_defined_balance_id => l_basis_rec_41(i).defined_bal_id
4970 ,p_assignment_action_id => act_rec.assignment_action_id);
4971 l_basis_rec_41_disp := 'Y';
4972 l_rec_41_basis_values(k).processed := 'N';
4973 l_rec_41_basis_values(k).code := l_basis_rec_41(i).code;
4974 l_rec_41_basis_values(k).date_earned := ' ';
4975
4976 IF l_rec_41_basis_values(k).basis_amount < 0 THEN
4977 l_rec_41_basis_values(k).sign_code := 'C';
4978 END IF;
4979 k := k + 1;
4980 END IF;
4981 END IF;
4982 END LOOP; -- Asg Acts
4983 END LOOP; -- Elements
4984 END IF;
4985
4986 code commented out by vjhanak. The value of k is getting reset.
4987 need to use a different variable for the index. */
4988
4989 --first fetch the maximum assignment action id
4990 OPEN csr_asg_act1 (
4991 c_assignment_id => p_assignment_id
4992 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
4993 ,c_con_set_id => NULL
4994 ,c_start_date => g_extract_params(p_business_group_id).extract_start_date
4995 ,c_end_date => g_extract_params(p_business_group_id).extract_end_date);
4996 FETCH csr_asg_act1 INTO l_asg_act_id;
4997 IF csr_asg_act1%FOUND THEN
4998 CLOSE csr_asg_act1;
4999 i_12 := 1;
5000
5001 FOR rec12_act_rec IN csr_asg_act (
5002 c_assignment_id => p_assignment_id
5003 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
5004 ,c_con_set_id => NULL
5005 ,c_start_date => g_extract_params(p_business_group_id).extract_start_date
5006 ,c_end_date => g_extract_params(p_business_group_id).extract_end_date)
5007 LOOP
5008
5009 --loop through the retro and normal deduction amount rows
5010 FOR temp_rec IN c_rec_12_ele(c_bg_id => p_business_group_id
5011 ,c_effective_date =>
5012 --g_extract_params(p_business_group_id).extract_end_date --9902953
5013 rec12_act_rec.date_earned --9902953
5014 ,c_asg_id => p_assignment_id
5015 )
5016 LOOP
5017 hr_utility.set_location('chking asg : '||p_assignment_id,10);
5018 hr_utility.set_location('chking code : '||temp_rec.code,10);
5019 --if the amount is -999999 then fetch the balance value
5020 IF temp_rec.amount = -999999 THEN
5021 l_rec12_amt := 0;
5022 OPEN csr_defined_bal1(c_balance_type_id => temp_rec.ee_contribution_bal_type_id
5023 ,c_dimension_name => 'Assignment Run'
5024 ,c_business_group_id => p_business_group_id
5025 );
5026 FETCH csr_defined_bal1 INTO l_def_bal_id;
5027 IF csr_defined_bal1%FOUND THEN
5028 CLOSE csr_defined_bal1;
5029 l_rec12_amt := pay_balance_pkg.get_value(p_defined_balance_id => l_def_bal_id
5030 ,p_assignment_action_id => rec12_act_rec.assignment_action_id
5031 );
5032 ELSE
5033 CLOSE csr_defined_bal1;
5034 END IF;
5035
5036 OPEN csr_defined_bal1(c_balance_type_id => temp_rec.er_contribution_bal_type_id
5037 ,c_dimension_name => 'Assignment Run'
5038 ,c_business_group_id => p_business_group_id
5039 );
5040 FETCH csr_defined_bal1 INTO l_def_bal_id;
5041 IF csr_defined_bal1%FOUND THEN
5042 CLOSE csr_defined_bal1;
5043 l_rec12_amt := l_rec12_amt +
5044 pay_balance_pkg.get_value(p_defined_balance_id => l_def_bal_id
5045 ,p_assignment_action_id => rec12_act_rec.assignment_action_id
5046 );
5047 ELSE
5048 CLOSE csr_defined_bal1;
5049 END IF;
5050
5051 hr_utility.set_location('chking amt : '||l_rec12_amt,10);
5052
5053 IF l_rec12_amt <> 0 THEN
5054 l_rec_12_values(i_12).contrib_amount := l_rec12_amt;
5055 l_rec_12_values(i_12).date_earned := ' ';
5056 l_rec_12_values(i_12).code := temp_rec.code;
5057 i_12 := i_12 + 1;
5058 l_rec_12_disp := 'Y';
5059 END IF;
5060 ELSE
5061 IF temp_rec.amount <> 0 THEN
5062 l_rec_12_values(i_12).contrib_amount := temp_rec.amount;
5063 l_rec_12_values(i_12).date_earned := ' ';
5064 l_rec_12_values(i_12).code := temp_rec.code;
5065 i_12 := i_12 + 1;
5066 l_rec_12_disp := 'Y';
5067 END IF;
5068 END IF;
5069 hr_utility.set_location('asg : '||p_assignment_id,10);
5070 hr_utility.set_location('amt : '||temp_rec.amount,11);
5071 hr_utility.set_location('date : '||temp_rec.date_earned,11);
5072 hr_utility.set_location('cdoe : '||temp_rec.code,11);
5073 END LOOP;
5074 END LOOP;
5075
5076 i_41 := 1;
5077 --loop through the retro and normal deduction amount rows
5078 FOR temp_rec IN c_contrib_rec_41_ele(c_bg_id => p_business_group_id
5079 ,c_effective_date =>
5080 g_extract_params(p_business_group_id).extract_end_date
5081 ,c_asg_id => p_assignment_id
5082 )
5083 LOOP
5084 --if the amount is -999999 then fetch the balance value
5085 IF temp_rec.amount = -999999 THEN
5086 l_rec41_amt := 0;
5087 OPEN csr_defined_bal1(c_balance_type_id => temp_rec.ee_contribution_bal_type_id
5088 ,c_dimension_name => 'Assignment Run'
5089 ,c_business_group_id => p_business_group_id
5090 );
5091 FETCH csr_defined_bal1 INTO l_def_bal_id;
5092 IF csr_defined_bal1%FOUND THEN
5093 CLOSE csr_defined_bal1;
5094 l_rec41_amt := pay_balance_pkg.get_value(p_defined_balance_id => l_def_bal_id
5095 ,p_assignment_action_id => l_asg_act_id
5096 );
5097 ELSE
5098 CLOSE csr_defined_bal1;
5099 END IF;
5100
5101 OPEN csr_defined_bal1(c_balance_type_id => temp_rec.er_contribution_bal_type_id
5102 ,c_dimension_name => 'Assignment Run'
5103 ,c_business_group_id => p_business_group_id
5104 );
5105 FETCH csr_defined_bal1 INTO l_def_bal_id;
5106 IF csr_defined_bal1%FOUND THEN
5107 CLOSE csr_defined_bal1;
5108 l_rec41_amt := l_rec41_amt +
5109 pay_balance_pkg.get_value(p_defined_balance_id => l_def_bal_id
5110 ,p_assignment_action_id => l_asg_act_id
5111 );
5112 ELSE
5113 CLOSE csr_defined_bal1;
5114 END IF;
5115 IF l_rec41_amt <> 0 THEN
5116 l_rec_41_contrib_values(i_41).contrib_amount := l_rec41_amt;
5117 l_rec_41_contrib_values(i_41).date_earned := ' ';
5118 l_rec_41_contrib_values(i_41).code := temp_rec.code;
5119 i_41 := i_41 + 1;
5120 l_contrib_rec_41_disp := 'Y';
5121 END IF;
5122 ELSE
5123 IF temp_rec.amount <> 0 THEN
5124 l_rec_41_contrib_values(i_41).contrib_amount := temp_rec.amount;
5125 l_rec_41_contrib_values(i_41).date_earned := substr(fnd_date.date_to_canonical(
5126 temp_rec.date_earned),1,10);
5127 l_rec_41_contrib_values(i_41).code := temp_rec.code;
5128 i_41 := i_41 + 1;
5129 l_contrib_rec_41_disp := 'Y';
5130 END IF;
5131 END IF;
5132 hr_utility.set_location('amt : '||temp_rec.amount,11);
5133 hr_utility.set_location('date : '||temp_rec.date_earned,11);
5134 hr_utility.set_location('cdoe : '||temp_rec.code,11);
5135 END LOOP;
5136
5137 ELSE
5138 CLOSE csr_asg_act1;
5139 END IF;
5140 -- ============================================================================
5141 -- BEGIN Populating Rec 12 for change in hire dates
5142 -- ============================================================================
5143 -- Populate the Record 12 PL SQL table with values from the
5144 -- previous runs if there has been a change in hire date
5145 --
5146
5147 IF l_old_start IS NOT NULL AND l_new_start IS NOT NULL THEN
5148 --
5149 -- Hire Date is changed to the past
5150 --
5151 IF trunc(l_new_start) < trunc(l_old_start) THEN
5152 --
5153 -- Derive the beginning date
5154 --
5155 l_beg_new_st := fnd_date.canonical_to_date(to_char(l_new_start,'YYYY/MM')||'/01');
5156 --
5157 -- If the beginning date is less then the current extract start
5158 -- Loop through the assignment actions to derive contrib amounts
5159 -- of that period
5160 --
5161 WHILE trunc(l_beg_new_st) < trunc(g_extract_params(p_business_group_id).extract_start_date)
5162 LOOP
5163 l_end_new_st := add_months(trunc(l_beg_new_st),1) -1;
5164 --
5165 -- If Data has been sent to ABP , so not send it again
5166 --
5167 OPEN c_sent_to_abp(l_end_new_st);
5168 FETCH c_sent_to_abp INTO l_sent_to_abp;
5169 IF c_sent_to_abp%NOTFOUND THEN
5170 --
5171 -- First fetch the maximum assignment action id
5172 --
5173 OPEN csr_asg_act1 (
5174 c_assignment_id => p_assignment_id
5175 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
5176 ,c_con_set_id => NULL
5177 ,c_start_date => l_beg_new_st
5178 ,c_end_date => l_end_new_st );
5179 FETCH csr_asg_act1 INTO l_asg_act_id;
5180 IF csr_asg_act1%FOUND THEN
5181 --
5182 -- Loop through the retro and normal deduction amount rows
5183 --
5184 FOR temp_rec IN c_rec_12_ele(c_bg_id => p_business_group_id
5185 ,c_effective_date => l_end_new_st
5186 ,c_asg_id => p_assignment_id)
5187 LOOP
5188 hr_utility.set_location('chking asg : '||p_assignment_id,10);
5189 hr_utility.set_location('chking code : '||temp_rec.code,10);
5190 --if the amount is -999999 then fetch the balance value
5191 IF temp_rec.amount = -999999 THEN
5192 l_rec12_amt := 0;
5193 OPEN csr_defined_bal1(c_balance_type_id => temp_rec.ee_contribution_bal_type_id
5194 ,c_dimension_name => 'Assignment Run'
5195 ,c_business_group_id => p_business_group_id);
5196 FETCH csr_defined_bal1 INTO l_def_bal_id;
5197 IF csr_defined_bal1%FOUND THEN
5198 CLOSE csr_defined_bal1;
5199 l_rec12_amt := pay_balance_pkg.get_value(p_defined_balance_id => l_def_bal_id
5200 ,p_assignment_action_id => l_asg_act_id);
5201 ELSE
5202 CLOSE csr_defined_bal1;
5203 END IF;
5204
5205 OPEN csr_defined_bal1(c_balance_type_id => temp_rec.er_contribution_bal_type_id
5206 ,c_dimension_name => 'Assignment Run'
5207 ,c_business_group_id => p_business_group_id
5208 );
5209 FETCH csr_defined_bal1 INTO l_def_bal_id;
5210 IF csr_defined_bal1%FOUND THEN
5211 CLOSE csr_defined_bal1;
5212 l_rec12_amt := l_rec12_amt +
5213 pay_balance_pkg.get_value(p_defined_balance_id => l_def_bal_id
5214 ,p_assignment_action_id => l_asg_act_id);
5215 ELSE
5216 CLOSE csr_defined_bal1;
5217 END IF;
5218
5219 hr_utility.set_location('chking amt : '||l_rec12_amt,10);
5220
5221 IF l_rec12_amt <> 0 THEN
5222 l_rec_12_values(i_12).contrib_amount := l_rec12_amt;
5223 l_rec_12_values(i_12).date_earned := ' ';
5224 l_rec_12_values(i_12).code := temp_rec.code;
5225 i_12 := i_12 + 1;
5226 l_rec_12_disp := 'Y';
5227 END IF;
5228 END IF; -- amount is -9999
5229 END LOOP;
5230
5231 END IF; -- Ass acts are found
5232 CLOSE csr_asg_act1;
5233
5234 END IF; -- Data not sent to ABP
5235
5236 CLOSE c_sent_to_abp;
5237 l_beg_new_st := ADD_MONTHS(l_beg_new_st,1);
5238
5239 END LOOP; -- Loop through the months
5240
5241 ELSIF trunc(l_new_start) > trunc(l_old_start) THEN
5242 --
5243 -- Derive the beginning date
5244 --
5245 l_beg_new_st := fnd_date.canonical_to_date(to_char(l_old_start,'YYYY/MM')||'/01');
5246 l_loop_end_date := add_months(fnd_date.canonical_to_date(to_char(l_new_start,'YYYY/MM')||'/01'),1) - 1;
5247 l_loop_end_date := LEAST ( g_extract_params(p_business_group_id).extract_start_date -1
5248 ,l_loop_end_date);
5249 -- GZZ
5250 --
5251 --
5252 -- Loop through the dates to derive data to be reported to ABP
5253 -- this might include ony the differences of that period or the entire amount
5254 -- for the month
5255 --
5256 WHILE trunc(l_beg_new_st) < l_loop_end_date
5257 LOOP
5258 l_end_new_st := add_months(trunc(l_beg_new_st),1) -1;
5259 hr_utility.set_location('l_beg_new_st is '||l_beg_new_st,10);
5260 hr_utility.set_location('l_end_new_st is '||l_end_new_st,10);
5261 --
5262 -- First fetch the maximum assignment action id
5263 --
5264 OPEN csr_asg_act1 (
5265 c_assignment_id => p_assignment_id
5266 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
5267 ,c_con_set_id => NULL
5268 ,c_start_date => l_beg_new_st
5269 ,c_end_date => l_end_new_st );
5270 FETCH csr_asg_act1 INTO l_asg_act_id;
5271 CLOSE csr_asg_act1;
5272
5273 IF l_asg_act_id IS NOT NULL THEN
5274 --
5275 -- Loop through the normal deduction amount rows
5276 --
5277 FOR temp_rec IN c_rec_12_ele(c_bg_id => p_business_group_id
5278 ,c_effective_date => l_end_new_st
5279 ,c_asg_id => p_assignment_id)
5280 LOOP
5281 hr_utility.set_location('chking asg : '||p_assignment_id,10);
5282 hr_utility.set_location('chking code : '||temp_rec.code,10);
5283 --if the amount is -999999 then fetch the balance value
5284 IF temp_rec.amount = -999999 THEN
5285 l_rec12_amt := 0;
5286 OPEN csr_defined_bal1(c_balance_type_id => temp_rec.ee_contribution_bal_type_id
5287 ,c_dimension_name => 'Assignment Run'
5288 ,c_business_group_id => p_business_group_id);
5289 FETCH csr_defined_bal1 INTO l_def_bal_id;
5290 IF csr_defined_bal1%FOUND THEN
5291 CLOSE csr_defined_bal1;
5292 l_rec12_amt := pay_balance_pkg.get_value(p_defined_balance_id => l_def_bal_id
5293 ,p_assignment_action_id => l_asg_act_id);
5294 ELSE
5295 CLOSE csr_defined_bal1;
5296 END IF;
5297
5298 OPEN csr_defined_bal1(c_balance_type_id => temp_rec.er_contribution_bal_type_id
5299 ,c_dimension_name => 'Assignment Run'
5300 ,c_business_group_id => p_business_group_id
5301 );
5302 FETCH csr_defined_bal1 INTO l_def_bal_id;
5303 IF csr_defined_bal1%FOUND THEN
5304 CLOSE csr_defined_bal1;
5305 l_rec12_amt := l_rec12_amt +
5306 pay_balance_pkg.get_value(p_defined_balance_id => l_def_bal_id
5307 ,p_assignment_action_id => l_asg_act_id);
5308 ELSE
5309 CLOSE csr_defined_bal1;
5310 END IF;
5311
5312 hr_utility.set_location('chking amt : '||l_rec12_amt,10);
5313
5314 IF l_rec12_amt <> 0 THEN
5315 l_rec_12_values(i_12).contrib_amount := l_rec12_amt;
5316 l_rec_12_values(i_12).date_earned := substr(fnd_date.date_to_canonical(l_end_new_st),1,10);
5317 l_rec_12_values(i_12).code := temp_rec.code;
5318 IF length(temp_rec.code) = 1 THEN
5319 l_gxx_code := '0'||temp_rec.code;
5320 ELSE
5321 l_gxx_code := temp_rec.code;
5322 END IF;
5323
5324 OPEN c_12_abp_data (l_end_new_st,l_gxx_code);
5325 FETCH c_12_abp_data INTO l_rec_12_amt_sent_prev;
5326 IF c_12_abp_data%FOUND THEN
5327 l_rec_12_values(i_12).contrib_amount := l_rec_12_values(i_12).contrib_amount
5328 - l_rec_12_amt_sent_prev;
5329 hr_utility.set_location('l_rec_12_amt_sent_prev : '||l_rec_12_amt_sent_prev,10);
5330 END IF;
5331 CLOSE c_12_abp_data;
5332 i_12 := i_12 + 1;
5333 l_rec_12_disp := 'Y';
5334
5335 END IF;
5336 END IF;
5337 END LOOP;
5338
5339 ELSIF l_asg_act_id IS NULL THEN
5340
5341 hr_utility.set_location('ass act is null fetching data freom sent is '||l_end_new_st,10);
5342 FOR temp_rec IN c_rec_12_ele(c_bg_id => p_business_group_id
5343 ,c_effective_date => l_end_new_st
5344 ,c_asg_id => p_assignment_id)
5345 LOOP
5346 hr_utility.set_location('chking asg : '||p_assignment_id,10);
5347 hr_utility.set_location('chking code : '||temp_rec.code,10);
5348 --if the amount is -999999 then fetch the balance value
5349 IF temp_rec.amount = -999999 THEN
5350 hr_utility.set_location('GXXXXX entrred the if condition for -9999: '||l_rec_12_amt_sent_prev,10);
5351 hr_utility.set_location('GXXXXX l_end_new_st : '||l_end_new_st,10);
5352 hr_utility.set_location('GXXXXX temp_rec.code : '||temp_rec.code,10);
5353 IF length(temp_rec.code) = 1 THEN
5354 l_gxx_code := '0'||temp_rec.code;
5355 ELSE
5356 l_gxx_code := temp_rec.code;
5357 END IF;
5358 OPEN c_12_abp_data (l_end_new_st,l_gxx_code);
5359 FETCH c_12_abp_data INTO l_rec_12_amt_sent_prev;
5360 IF c_12_abp_data%FOUND THEN
5361 hr_utility.set_location('GXXXXX the amount is asg : '||l_rec_12_amt_sent_prev,10);
5362 l_rec_12_values(i_12).contrib_amount := -1 * l_rec_12_amt_sent_prev;
5363 l_rec_12_values(i_12).date_earned := substr(fnd_date.date_to_canonical(l_end_new_st),1,10);
5364 l_rec_12_values(i_12).code := temp_rec.code;
5365 i_12 := i_12 + 1;
5366 l_rec_12_disp := 'Y';
5367 ELSE
5368 OPEN c_12_retro_abp_data (to_char(l_end_new_st,'YYYY'),
5369 to_char(l_end_new_st,'MM'),
5370 l_end_new_st,l_gxx_code);
5371 FETCH c_12_retro_abp_data INTO l_rec_12_amt_sent_prev_r;
5372 IF c_12_retro_abp_data%FOUND THEN
5373 l_rec_12_values(i_12).contrib_amount := -1 * l_rec_12_amt_sent_prev_r;
5374 l_rec_12_values(i_12).date_earned := substr(fnd_date.date_to_canonical(l_end_new_st),1,10);
5375 l_rec_12_values(i_12).code := temp_rec.code;
5376 i_12 := i_12 + 1;
5377 l_rec_12_disp := 'Y';
5378 END IF;
5379 CLOSE c_12_retro_abp_data;
5380
5381 END IF;
5382 CLOSE c_12_abp_data;
5383 END IF;
5384 END LOOP;
5385
5386 END IF;
5387
5388
5389 l_beg_new_st := ADD_MONTHS(l_beg_new_st,1);
5390
5391 END LOOP; -- Loop through the months
5392
5393 END IF; -- new start date < old start dt
5394 END IF; -- dates are not null
5395 -- ============================================================================
5396 -- END Populating Rec 12 for change in hire dates
5397 -- ============================================================================
5398
5399 -- ============================================================================
5400 -- BEGIN Populate Rec 09 and 12 for Termination Reversal
5401 -- ============================================================================
5402
5403 l_reversal_term := 0;
5404 l_normal_term := 0;
5405
5406 l_ret_val_asg := Get_Asg_Seq_Num(p_assignment_id
5407 ,p_business_group_id
5408 ,p_effective_date
5409 ,p_error_message
5410 ,l_seq_num);
5411
5412
5413 OPEN c_get_term_rows(p_business_group_id
5414 ,p_effective_date
5415 ,p_assignment_id
5416 ,l_seq_num);
5417 FETCH c_get_term_rows INTO
5418 l_old_date1_XX,
5419 l_new_date1_XX
5420 ,l_term_log_id_XX
5421 ,l_term_pos_id_XX;
5422
5423 IF c_get_term_rows%FOUND THEN
5424 hr_utility.set_location('....c_get_term_rows Found : ',30);
5425 CLOSE c_get_term_rows;
5426
5427 OPEN c_get_revt_rows (p_business_group_id
5428 ,p_effective_date
5429 ,p_assignment_id);
5430 FETCH c_get_revt_rows INTO l_old_date2_XX,l_new_date2_XX,l_revt_log_id_XX;
5431 IF c_get_revt_rows%FOUND THEN
5432 hr_utility.set_location('....c_get_revt_rows found : ',34);
5433 CLOSE c_get_revt_rows;
5434 IF l_term_log_id_XX > l_revt_log_id_XX THEN
5435 l_normal_term := 1;
5436 END IF;
5437 ELSE
5438 CLOSE c_get_revt_rows;
5439 hr_utility.set_location('....Regular values being fetched : ',38);
5440 l_normal_term := 1;
5441 END IF;
5442 ELSE
5443 CLOSE c_get_term_rows;
5444 OPEN c_get_revt_rows (p_business_group_id
5445 ,p_effective_date
5446 ,p_assignment_id);
5447 FETCH c_get_revt_rows INTO l_old_date2_XX,l_new_date2_XX,l_revt_log_id_XX;
5448 IF c_get_revt_rows%FOUND THEN
5449 hr_utility.set_location('....c_get_revt_rows Found: ',40);
5450 CLOSE c_get_revt_rows;
5451 l_reversal_term := 1;
5452 ELSE
5453 CLOSE c_get_revt_rows;
5454 END IF;
5455 END IF;
5456
5457 IF l_reversal_term = 1 AND l_old_date2_XX IS NOT NULL THEN
5458
5459 -------------------------------REcord 09 ----------------
5460
5461 l_beg_new_st := ADD_MONTHS(to_date(to_char(to_nl_date(l_old_date2_XX,'DD-MM-RR'),'YYYY/MM')||'01','YYYY/MM/DD'),1);
5462 l_loop_end_date := g_extract_params(p_business_group_id).extract_start_date ;
5463 -- GZZ
5464 --
5465 --
5466 -- Loop through the dates to derive data to be reported to ABP
5467 -- this might include ony the differences of that period or the entire amount
5468 -- for the month
5469 --
5470 WHILE trunc(l_beg_new_st) < l_loop_end_date
5471 LOOP
5472 l_end_new_st := add_months(trunc(l_beg_new_st),1) -1;
5473 l_gzz_asg_act_xst := 0;
5474
5475 OPEN c_sent_to_abp(l_end_new_st);
5476 FETCH c_sent_to_abp INTO l_sent_to_abp;
5477 IF c_sent_to_abp%NOTFOUND THEN
5478
5479 IF l_rec_09.count > 0 THEN
5480 FOR i IN l_rec_09.FIRST..l_rec_09.LAST
5481 LOOP
5482 l_rr_exists := 0;
5483 hr_utility.set_location('current element : '||l_rec_09(i).element_type_id,10);
5484 hr_utility.set_location('asg id : '||p_assignment_id,12);
5485 hr_utility.set_location('start date : ',14);
5486 hr_utility.set_location('end date : ',15);
5487 FOR act_rec IN csr_asg_act (
5488 c_assignment_id => p_assignment_id
5489 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
5490 ,c_con_set_id => NULL
5491 ,c_start_date => l_beg_new_st
5492 ,c_end_date => l_end_new_st)
5493 LOOP
5494
5495 l_reg_09_age_cal_dt := l_beg_new_st;
5496 l_reg_09_age := Get_Age(p_assignment_id,trunc(l_reg_09_age_cal_dt)) ;
5497
5498 IF l_reg_09_age < 65 THEN
5499 -- Check if Run Results exist for this element/ass act
5500 IF chk_rr_exist (p_ass_act_id => act_rec.assignment_action_id
5501 ,p_element_type_id => l_rec_09(i).element_type_id ) THEN
5502 -- Call pay_balance_pkg
5503 hr_utility.set_location('run results exist for current period',40);
5504 IF l_rec_09(i).defined_bal_id <> -1 THEN
5505 l_rec_09_values(k).basis_amount :=
5506 Pay_Balance_Pkg.get_value
5507 (p_defined_balance_id => l_rec_09(i).defined_bal_id
5508 ,p_assignment_action_id => act_rec.assignment_action_id);
5509 hr_utility.set_location('defined bal id used :'||l_rec_09(i).defined_bal_id,50);
5510 l_rec_09_disp := 'Y';
5511 l_rec_09_values(k).processed := 'N';
5512 l_rec_09_values(k).code := l_rec_09(i).code;
5513 l_rec_09_values(k).date_earned :=
5514 substr(fnd_date.date_to_canonical(l_end_new_st),1,10);
5515
5516 OPEN c_09_abp_data (l_end_new_st,l_rec_09(i).code);
5517 FETCH c_09_abp_data INTO l_09_basis_amt_sent_prev;
5518 IF c_09_abp_data%FOUND THEN
5519 l_rec_09_values(k).basis_amount := l_rec_09_values(k).basis_amount
5520 - l_09_basis_amt_sent_prev;
5521 END IF;
5522 CLOSE c_09_abp_data;
5523
5524 IF l_rec_09_values(k).basis_amount < 0 THEN
5525 l_rec_09_values(k).sign_code := 'C';
5526 END IF;
5527 l_gzz_asg_act_xst := 1;
5528 k := k + 1;
5529 END IF;-- Defined bal check
5530 END IF;-- RR exist check
5531
5532 END IF; -- Age check
5533 END LOOP; -- Ass acts
5534 END LOOP; -- All elements for Rec 09
5535 END IF; -- Record 09 elements exist
5536 END IF;
5537 CLOSE c_sent_to_abp;
5538
5539 l_beg_new_st := ADD_MONTHS(l_beg_new_st,1);
5540
5541 END LOOP; -- Loop through the months
5542
5543
5544 ---------------------- REcord 09 -----------------------
5545
5546 -- Record 12
5547
5548 l_beg_new_st := ADD_MONTHS(to_date(to_char(to_nl_date(l_old_date2_XX,'DD-MM-RR'),'YYYY/MM')||'01','YYYY/MM/DD'),1);
5549 l_loop_end_date := g_extract_params(p_business_group_id).extract_start_date -1;
5550
5551
5552 WHILE trunc(l_beg_new_st) < l_loop_end_date
5553 LOOP
5554 l_end_new_st := add_months(trunc(l_beg_new_st),1) -1;
5555 hr_utility.set_location('l_beg_new_st is '||l_beg_new_st,10);
5556 hr_utility.set_location('l_end_new_st is '||l_end_new_st,10);
5557 OPEN c_sent_to_abp(l_end_new_st);
5558 FETCH c_sent_to_abp INTO l_sent_to_abp;
5559 IF c_sent_to_abp%NOTFOUND THEN
5560 --
5561 -- First fetch the maximum assignment action id
5562 --
5563 OPEN csr_asg_act1 (
5564 c_assignment_id => p_assignment_id
5565 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
5566 ,c_con_set_id => NULL
5567 ,c_start_date => l_beg_new_st
5568 ,c_end_date => l_end_new_st );
5569 FETCH csr_asg_act1 INTO l_asg_act_id;
5570 CLOSE csr_asg_act1;
5571
5572 IF l_asg_act_id IS NOT NULL THEN
5573 --
5574 -- Loop through the normal deduction amount rows
5575 --
5576 FOR temp_rec IN c_rec_12_ele(c_bg_id => p_business_group_id
5577 ,c_effective_date => l_end_new_st
5578 ,c_asg_id => p_assignment_id)
5579 LOOP
5580 hr_utility.set_location('chking asg : '||p_assignment_id,10);
5581 hr_utility.set_location('chking code : '||temp_rec.code,10);
5582 --if the amount is -999999 then fetch the balance value
5583 IF temp_rec.amount = -999999 THEN
5584 l_rec12_amt := 0;
5585 OPEN csr_defined_bal1(c_balance_type_id => temp_rec.ee_contribution_bal_type_id
5586 ,c_dimension_name => 'Assignment Run'
5587 ,c_business_group_id => p_business_group_id);
5588 FETCH csr_defined_bal1 INTO l_def_bal_id;
5589 IF csr_defined_bal1%FOUND THEN
5590 CLOSE csr_defined_bal1;
5591 l_rec12_amt := pay_balance_pkg.get_value(p_defined_balance_id => l_def_bal_id
5592 ,p_assignment_action_id => l_asg_act_id);
5593 ELSE
5594 CLOSE csr_defined_bal1;
5595 END IF;
5596
5597 OPEN csr_defined_bal1(c_balance_type_id => temp_rec.er_contribution_bal_type_id
5598 ,c_dimension_name => 'Assignment Run'
5599 ,c_business_group_id => p_business_group_id
5600 );
5601 FETCH csr_defined_bal1 INTO l_def_bal_id;
5602 IF csr_defined_bal1%FOUND THEN
5603 CLOSE csr_defined_bal1;
5604 l_rec12_amt := l_rec12_amt +
5605 pay_balance_pkg.get_value(p_defined_balance_id => l_def_bal_id
5606 ,p_assignment_action_id => l_asg_act_id);
5607 ELSE
5608 CLOSE csr_defined_bal1;
5609 END IF;
5610
5611 hr_utility.set_location('chking amt : '||l_rec12_amt,10);
5612
5613 IF l_rec12_amt <> 0 THEN
5614 l_rec_12_values(i_12).contrib_amount := l_rec12_amt;
5615 l_rec_12_values(i_12).date_earned := substr(fnd_date.date_to_canonical(l_end_new_st),1,10);
5616 l_rec_12_values(i_12).code := temp_rec.code;
5617 i_12 := i_12 + 1;
5618 l_rec_12_disp := 'Y';
5619
5620 END IF;
5621 END IF;
5622 END LOOP;
5623
5624 ELSIF l_asg_act_id IS NULL THEN
5625
5626 NULL;
5627
5628 END IF;
5629
5630 END IF;
5631 CLOSE c_sent_to_abp;
5632
5633 l_beg_new_st := ADD_MONTHS(l_beg_new_st,1);
5634
5635 END LOOP; -- Loop through the months
5636
5637
5638 -- Record 12
5639
5640
5641 END IF; -- check for reversal
5642
5643 -- ============================================================================
5644 -- END Populate Rec 09 and 12 for Termination Reversal
5645 -- ============================================================================
5646
5647 END Populate_Record_Structures;
5648
5649
5650 -- =============================================================================
5651 -- Pension_Criteria_Full_Profile: The Main extract criteria that would be used
5652 -- for the pension extract. This function decides the assignments that need
5653 -- to be processed. The assignments that need not be processed are rejected
5654 -- here. The criteria is to filter the assignments based on the org hierarchy .
5655 -- =============================================================================
5656 FUNCTION Pension_Criteria_Full_Profile
5657 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
5658 ,p_effective_date IN DATE
5659 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
5660 ,p_warning_message OUT NOCOPY VARCHAR2
5661 ,p_error_message OUT NOCOPY VARCHAR2
5662 ) RETURN VARCHAR2 IS
5663 --
5664 -- Cursor to get the extract definition type
5665 --
5666 CURSOR csr_ext_attr (c_ext_dfn_id IN ben_ext_rslt.ext_dfn_id%TYPE) IS
5667 SELECT ext_dfn_type
5668 FROM pqp_extract_attributes
5669 WHERE ext_dfn_id = c_ext_dfn_id;
5670 --
5671 -- Based on result id and Ext. Dfn Id, get the con. request id
5672 --
5673 CURSOR csr_req_id (c_ext_rslt_id IN ben_ext_rslt.ext_rslt_id%TYPE
5674 ,c_ext_dfn_id IN ben_ext_rslt.ext_dfn_id%TYPE
5675 ,c_business_group_id IN ben_ext_rslt.business_group_id%TYPE) IS
5676 SELECT request_id
5677 FROM ben_ext_rslt
5678 WHERE ext_rslt_id = c_ext_rslt_id
5679 AND ext_dfn_id = c_ext_dfn_id
5680 AND business_group_id = c_business_group_id;
5681 --
5682 -- Get the Conc. requests params based on the request id fetched
5683 --
5684 CURSOR csr_ext_params (c_request_id IN Number
5685 ,c_ext_dfn_id IN Number
5686 ,c_business_group_id IN Number) IS
5687 SELECT session_id -- Session id
5688 ,organization_name -- Concurrent Program Name
5689 ,business_group_id -- Business Group
5690 ,tax_unit_id -- Concurrent Request Id
5691 ,value1 -- Extract Definition Id
5692 ,value2 -- Payroll Id
5693 ,value3 -- Consolidation Set
5694 ,value4 -- Organization Id
5695 ,value5 -- Sort Position -- 9278285
5696 ,value6 --
5697 ,attribute1 --
5698 ,attribute2 --
5699 ,attribute3 -- Extract Start Date
5700 ,attribute4 -- Extract End Date
5701 ,attribute5 -- Extract Record 01 Flag
5702 FROM pay_us_rpt_totals
5703 WHERE tax_unit_id = c_request_id
5704 AND value1 = c_ext_dfn_id
5705 AND business_group_id = c_business_group_id;
5706 --
5707 -- Get the Legislation Code and Curreny Code
5708 --
5709 CURSOR csr_leg_code (c_business_group_id IN Number) IS
5710 SELECT pbg.legislation_code
5711 ,pbg.currency_code
5712 FROM per_business_groups_perf pbg
5713 WHERE pbg.business_group_id = c_business_group_id;
5714 --
5715 -- Cursor to Check if a org hierarchy is attached to the BG.
5716 -- If it is attached get the valid version as of the effective date.
5717 -- If a valid version is not found then do nothing.
5718 CURSOR c_get_org_hierarchy IS
5719 SELECT pos.org_structure_version_id
5720 FROM per_org_structure_versions_v pos,
5721 hr_organization_information hoi
5722 WHERE hoi.organization_id = p_business_group_id
5723 AND To_Number(hoi.org_information1) = pos.organization_structure_id
5724 AND Trunc(p_effective_date) BETWEEN date_from
5725 AND Nvl(date_to,Hr_Api.g_eot)
5726 AND hoi.org_information_context = 'NL_BG_INFO';
5727 --
5728 -- Cursor to get the list of orgs from the hierarchy if one exists.
5729 --
5730 CURSOR c_get_children ( c_org_str_ver_id IN Number
5731 ,c_org_id IN Number) IS
5732 SELECT os.organization_id_child
5733 FROM (SELECT *
5734 FROM per_org_structure_elements a
5735 WHERE a.org_structure_version_id = c_org_str_ver_id ) os
5736 START WITH os.organization_id_parent = c_org_id
5737 CONNECT BY os.organization_id_parent = PRIOR os.organization_id_child;
5738 --
5739 -- Cursor to check whether oganization is tax organization or not
5740 --
5741 CURSOR csr_tax_org(c_org_id NUMBER) IS
5742 SELECT 'x'
5743 FROM hr_organization_information
5744 WHERE organization_id = c_org_id
5745 AND org_information_context = 'NL_ORG_INFORMATION'
5746 AND org_information3 IS NOT NULL
5747 AND org_information4 IS NOT NULL;
5748 --
5749 -- Cursor to store the record ids in a PL/SQL table to be used while
5750 -- processing the sec. and terminated assignments
5751 --
5752 CURSOR csr_rcd_ids IS
5753 SELECT Decode(rin.seq_num,1,'00',
5754 2,'01',
5755 3,'02',
5756 4,'04',
5757 5,'05',
5758 7,'08',
5759 8,'09',
5760 10,'12',
5761 12,'20',
5762 14,'21',
5763 16,'22',
5764 17,'30',
5765 19,'31',
5766 21,'40',
5767 23,'41',
5768 24,'41h',
5769 26,'94',
5770 27,'95',
5771 28,'96',
5772 29,'97',
5773 30,'99',
5774 '~') rec_num,
5775 rin.seq_num,
5776 rin.hide_flag,
5777 rcd.ext_rcd_id,
5778 rcd.rcd_type_cd
5779 FROM ben_ext_rcd rcd
5780 ,ben_ext_rcd_in_file rin
5781 ,ben_ext_dfn dfn
5782 WHERE dfn.ext_dfn_id = Ben_Ext_Thread.g_ext_dfn_id
5783 AND rin.ext_file_id = dfn.ext_file_id
5784 AND rin.ext_rcd_id = rcd.ext_rcd_id
5785 ORDER BY rin.seq_num;
5786
5787 CURSOR c_rej_hf_ee (c_per_id IN NUMBER)IS
5788 --9433900
5789 /*
5790 SELECT 1
5791 FROM per_periods_of_service
5792 WHERE PERSON_ID = c_per_id
5793 AND TRUNC(actual_termination_date) =
5794 TRUNC(date_start)
5795 AND NOT EXISTS(SELECT 1
5796 FROM PER_PERIODS_OF_SERVICE
5797 WHERE person_id = c_per_id
5798 AND TRUNC(date_start) >
5799 TRUNC(g_extract_params(p_business_group_id).extract_start_date));
5800 */
5801 SELECT 1
5802 FROM per_periods_of_service ppos1
5803 WHERE ppos1.PERSON_ID = c_per_id
5804 AND TRUNC(ppos1.actual_termination_date) =
5805 TRUNC(ppos1.date_start)
5806 AND TRUNC(ppos1.date_start) <= TRUNC(g_extract_params(p_business_group_id).extract_end_date)
5807 AND NOT EXISTS(SELECT 1
5808 FROM PER_PERIODS_OF_SERVICE ppos2
5809 WHERE ppos2.person_id = c_per_id
5810 AND ppos1.period_of_service_id <> ppos2.period_of_service_id
5811 AND TRUNC(ppos2.date_start) > TRUNC(ppos1.date_start)
5812 AND TRUNC(g_extract_params(p_business_group_id).extract_end_date) >= TRUNC(ppos2.date_start)
5813 AND ppos2.actual_termination_date IS NULL
5814 AND ppos2.final_process_date IS NULL
5815 AND ppos2.last_standard_process_date IS NULL);
5816 --9433900
5817
5818 CURSOR c_rej_old_ee (c_ass_id IN NUMBER
5819 ,c_eff_dt IN DATE ) IS
5820 SELECT 1
5821 FROM per_periods_of_service pps
5822 ,per_all_assignments_f asg
5823 WHERE asg.assignment_id = c_ass_id
5824 AND c_eff_dt BETWEEN asg.effective_start_date AND asg.effective_end_date
5825 AND asg.period_of_service_id = pps.period_of_service_id
5826 AND pps.actual_termination_date IS NOT NULL
5827 AND pps.final_process_date IS NOT NULL
5828 AND pps.final_process_date <
5829 TRUNC(g_extract_params(p_business_group_id).extract_start_date);
5830
5831 -- 9917330
5832 CURSOR c_is_payroll_run(p_asg_id NUMBER, p_bg_id NUMBER, p_payroll_id number, p_cons_id number)
5833 IS
5834 SELECT 1
5835 FROM pay_assignment_actions paa
5836 ,pay_payroll_actions ppa
5837 WHERE paa.assignment_id = p_asg_id
5838 AND ppa.BUSINESS_GROUP_ID = p_bg_id
5839 AND ppa.action_status = 'C'
5840 AND ppa.action_type IN ('Q','R')
5841 AND paa.action_status = 'C'
5842 AND ppa.payroll_id = Nvl(p_payroll_id,ppa.payroll_id)
5843 AND ppa.consolidation_set_id = Nvl(p_cons_id,ppa.consolidation_set_id)
5844 AND paa.payroll_action_id = ppa.payroll_action_id
5845 AND ppa.effective_date BETWEEN g_extract_params(p_business_group_id).extract_start_date
5846 AND g_extract_params(p_business_group_id).extract_end_date;
5847
5848 CURSOR c_ele_entries(p_asg_id NUMBER)
5849 IS
5850 SELECT 1
5851 FROM pay_element_entries_f peef
5852 where
5853 peef.Assignment_id = p_asg_id
5854 AND (g_extract_params(p_business_group_id).extract_start_date BETWEEN peef.EFFECTIVE_START_DATE AND peef.EFFECTIVE_END_DATE
5855 OR
5856 g_extract_params(p_business_group_id).extract_end_date BETWEEN peef.EFFECTIVE_START_DATE AND peef.EFFECTIVE_END_DATE
5857 )
5858 AND EXISTS
5859 (SELECT 1
5860 FROM pay_element_types_f petf
5861 WHERE
5862 peef.element_type_id = petf.element_type_id
5863 AND UPPER(element_name) like '%RETRO%ABP%'
5864 AND (g_extract_params(p_business_group_id).extract_start_date BETWEEN petf.EFFECTIVE_START_DATE AND petf.EFFECTIVE_END_DATE
5865 OR
5866 g_extract_params(p_business_group_id).extract_end_date BETWEEN petf.EFFECTIVE_START_DATE AND petf.EFFECTIVE_END_DATE
5867 )
5868 );
5869
5870 l_is_payroll_run NUMBER;
5871 l_ele_entries NUMBER;
5872
5873 -- 9917330
5874
5875 -- =========================================
5876 -- ~ Local variables
5877 -- =========================================
5878 l_rej_hf_ee NUMBER;
5879 l_rej_old_ee NUMBER;
5880 l_ext_params csr_ext_params%ROWTYPE;
5881 l_conc_reqest_id ben_ext_rslt.request_id%TYPE;
5882 l_ext_dfn_type pqp_extract_attributes.ext_dfn_type%TYPE;
5883 i per_all_assignments_f.business_group_id%TYPE;
5884 l_ext_rslt_id ben_ext_rslt.ext_rslt_id%TYPE;
5885 l_ext_dfn_id ben_ext_dfn.ext_dfn_id%TYPE;
5886 l_return_value Varchar2(2) :='N';
5887 l_proc_name Varchar2(150) := g_proc_name ||'Pension_Criteria_Full_Profile';
5888 l_assig_rec csr_assig%ROWTYPE;
5889 l_effective_date Date;
5890 l_org_hierarchy Number;
5891 l_tax_org_flag VARCHAR2(1);
5892 l_grp_index NUMBER:=0;
5893 l_org_index NUMBER;
5894
5895 BEGIN
5896
5897 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
5898 i := p_business_group_id;
5899 l_ext_rslt_id := Ben_Ext_Thread.g_ext_rslt_id;
5900 l_ext_dfn_id := Ben_Ext_Thread.g_ext_dfn_id;
5901
5902 IF NOT g_extract_params.EXISTS(i) THEN
5903 Hr_Utility.set_location('..Exract Params PL/SQL not populated ', 7);
5904 -- Get the extract type, Changes extract or Full Profile
5905 OPEN csr_ext_attr(c_ext_dfn_id=> l_ext_dfn_id);
5906 FETCH csr_ext_attr INTO l_ext_dfn_type;
5907 CLOSE csr_ext_attr;
5908 Hr_Utility.set_location('..After cursor csr_ext_attr',9);
5909 -- Get the Conc. request id to get the params
5910 OPEN csr_req_id(c_ext_rslt_id => l_ext_rslt_id
5911 ,c_ext_dfn_id => l_ext_dfn_id
5912 ,c_business_group_id => p_business_group_id);
5913 FETCH csr_req_id INTO l_conc_reqest_id;
5914 CLOSE csr_req_id;
5915 Hr_Utility.set_location('..After Conc.Request id cursor csr_req_id',11);
5916 -- Get the params. based on the conc. request id.
5917 OPEN csr_ext_params (c_request_id => l_conc_reqest_id
5918 ,c_ext_dfn_id => l_ext_dfn_id
5919 ,c_business_group_id => p_business_group_id);
5920 FETCH csr_ext_params INTO l_ext_params;
5921 CLOSE csr_ext_params;
5922 -- Store the params. in a PL/SQL table record
5923 g_extract_params(i).session_id := l_ext_params.session_id;
5924 g_extract_params(i).ext_dfn_type := l_ext_dfn_type;
5925 g_extract_params(i).business_group_id := l_ext_params.business_group_id;
5926 g_extract_params(i).concurrent_req_id := l_ext_params.tax_unit_id;
5927 g_extract_params(i).ext_dfn_id := l_ext_params.value1;
5928 g_extract_params(i).payroll_id := l_ext_params.value2;
5929 g_extract_params(i).con_set_id := l_ext_params.value3;
5930 g_extract_params(i).org_id := l_ext_params.value4;
5931 g_extract_params(i).extract_start_date :=
5932 Fnd_Date.canonical_to_date(l_ext_params.attribute3);
5933 g_extract_params(i).extract_end_date :=
5934 Fnd_Date.canonical_to_date(l_ext_params.attribute4);
5935 g_extract_params(i).extract_rec_01 := l_ext_params.attribute5;
5936 g_sort_position := nvl(l_ext_params.value5,1); --9278285
5937
5938 OPEN csr_leg_code (c_business_group_id => p_business_group_id);
5939 FETCH csr_leg_code INTO g_extract_params(i).legislation_code,
5940 g_extract_params(i).currency_code;
5941 CLOSE csr_leg_code;
5942 g_legislation_code := g_extract_params(i).legislation_code;
5943 g_business_group_id := p_business_group_id;
5944 Hr_Utility.set_location('..Stored the extract parameters in PL/SQL table', 15);
5945
5946 -- Set the meaning for concurrent program parameters
5947 Set_ConcProg_Parameter_Values
5948 (p_ext_dfn_id => g_extract_params(i).ext_dfn_id
5949 ,p_start_date => g_extract_params(i).extract_start_date
5950 ,p_end_date => g_extract_params(i).extract_end_date
5951 ,p_payroll_id => g_extract_params(i).payroll_id
5952 ,p_con_set => g_extract_params(i).con_set_id
5953 ,p_org_id => g_extract_params(i).org_id
5954 );
5955 Hr_Utility.set_location('..Stored the Conc. Program parameters', 17);
5956 -- Store all record ids in a PL/SQL tbl
5957 FOR rcd_rec IN csr_rcd_ids
5958 LOOP
5959 g_ext_rcds(rcd_rec.ext_rcd_id) := rcd_rec;
5960 END LOOP;
5961 -- Add the current org to the org table.
5962 g_org_list(g_extract_params(i).org_id).org_id
5963 := g_extract_params(i).org_id;
5964 -- Check if a hierarchy is attached.
5965 OPEN c_get_org_hierarchy ;
5966 FETCH c_get_org_hierarchy INTO l_org_hierarchy;
5967 IF c_get_org_hierarchy%FOUND THEN
5968 CLOSE c_get_org_hierarchy;
5969 -- Get the children of the Org for which extract is being run
5970 -- based on the hierarchy obtained above.
5971 FOR temp_rec IN c_get_children
5972 (c_org_str_ver_id => l_org_hierarchy
5973 ,c_org_id => g_extract_params(i).org_id)
5974 LOOP
5975 g_org_list(temp_rec.organization_id_child).org_id
5976 := temp_rec.organization_id_child;
5977 END LOOP;
5978 ELSE
5979 CLOSE c_get_org_hierarchy;
5980 END IF;
5981
5982 --------------------------------------------------------------------
5983 --From the org list select the employers
5984 l_org_index:=g_org_list.FIRST;
5985 WHILE l_org_index IS NOT NULL
5986 LOOP
5987 --Check if org is employer or not
5988 OPEN csr_tax_org(g_org_list(l_org_index).org_id);
5989 FETCH csr_tax_org INTO l_tax_org_flag;
5990 --If employer then add org in employer list
5991 IF csr_tax_org%FOUND THEN
5992 g_employer_list(g_org_list(l_org_index).org_id).gre_org_id:=g_org_list(l_org_index).org_id;
5993 Hr_Utility.set_location('Employer '||l_org_index||g_employer_list(g_org_list(l_org_index).org_id).gre_org_id, 10);
5994 END IF;
5995 CLOSE csr_tax_org;
5996 l_org_index:=g_org_list.NEXT(l_org_index);
5997 END LOOP;
5998
5999 ---------------------------------------------------------------------
6000 g_er_index:=g_employer_list.FIRST;
6001 l_grp_index:=0;
6002 --For each employer store all the child orgs which are not employers
6003 --This include sub orgs also
6004 WHILE g_er_index IS NOT NULL
6005 LOOP
6006 --Initialize the index values
6007 g_er_child_index := l_grp_index * 1000;
6008 g_org_grp_list_cnt(g_er_index).org_grp_count:=0;
6009
6010 --Add employer first before adding its child orgs
6011 --First increase the org group count
6012 g_org_grp_list_cnt(g_er_index).org_grp_count:=
6013 g_org_grp_list_cnt(g_er_index).org_grp_count+1;
6014
6015 --add current org/employer to the employer child table
6016 g_employer_child_list(g_er_child_index).gre_org_id:=
6017 g_employer_list(g_er_index).gre_org_id;
6018
6019 --Create Group for this employer
6020 Set_Er_Children(g_employer_list(g_er_index).gre_org_id
6021 ,p_business_group_id
6022 ,p_effective_date);
6023
6024 --Next Employer
6025 g_er_index:=g_employer_list.NEXT(g_er_index);
6026 l_grp_index:=l_grp_index+1;
6027 END LOOP;
6028
6029 END IF;
6030
6031 -- Get the person id for the assignment and store it in a global
6032 -- variable
6033 g_person_id:= Nvl(get_current_extract_person(p_assignment_id),
6034 Ben_Ext_Person.g_person_id);
6035
6036 -- Derive the effective date
6037 l_effective_date := Least(g_extract_params(i).extract_end_date,
6038 p_effective_date);
6039
6040 Hr_Utility.set_location('..Processing Assig Id : '||p_assignment_id, 17);
6041 Hr_Utility.set_location('..Processing Person Id : '||g_person_id, 17);
6042 Hr_Utility.set_location('..Processing Eff.Date : '||p_effective_date, 17);
6043 -- Get the list of employers (HR Orgs) in the current hierarchy.
6044 -- Store this value in a PL/SQL Table.
6045 -- Check if the assignments need to be processed. Assignments are
6046 -- processed if
6047 -- 1. The organization of the person assignment exists in the
6048 -- org list derived above.
6049 -- 2. If the primary assignment does not satisfy point 1 then check if
6050 -- the secondary assignments satisfy point 1
6051 -- 3. If the assignment passed is a Benefits assignment
6052
6053 --
6054 -- Full Profile Extracts fetches all EE's . Reject EE's that need
6055 -- not be processed at all. For E.g. if an EE's Final Close Date is
6056 -- in Jan 2004 and the extract start date is Jan 2006, there is no
6057 -- need to process this EE as no reporting needs to be done
6058 -- Also payroll cannot be processed so there are no retro changes
6059 --
6060 OPEN c_rej_old_ee (p_assignment_id
6061 ,l_effective_date);
6062 FETCH c_rej_old_ee INTO l_rej_old_ee;
6063 IF c_rej_old_ee%FOUND THEN
6064 l_return_value := 'N';
6065 CLOSE c_rej_old_ee;
6066 RETURN l_return_value;
6067 ELSE
6068 CLOSE c_rej_old_ee;
6069 END IF;
6070
6071 -- Check if the assignements passed by BEN are in the org list
6072 OPEN csr_assig (c_assignment_id => p_assignment_id
6073 ,c_effective_date => l_effective_date
6074 ,c_business_group_id => p_business_group_id);
6075 FETCH csr_assig INTO l_assig_rec;
6076 CLOSE csr_assig;
6077 -- Check for Benefits assignment first.
6078 IF l_assig_rec.assignment_type = 'B' THEN
6079 --
6080 -- Added to reject EE's that are hired and fired on the same day
6081 --
6082 /* --9917330
6083 OPEN c_rej_hf_ee(g_person_id);
6084 FETCH c_rej_hf_ee INTO l_rej_hf_ee;
6085 IF c_rej_hf_ee%FOUND THEN
6086 l_return_value := 'N';
6087 ELSE
6088 l_return_value := 'Y';
6089 END IF;
6090 CLOSE c_rej_hf_ee;
6091 */ --9917330
6092
6093 --9917330
6094
6095 OPEN c_rej_hf_ee(g_person_id);
6096 FETCH c_rej_hf_ee INTO l_rej_hf_ee;
6097 IF c_rej_hf_ee%FOUND THEN
6098 l_return_value := 'N';
6099
6100 OPEN c_is_payroll_run(p_assignment_id, p_business_group_id, g_extract_params(i).payroll_id, g_extract_params(i).con_set_id );
6101 FETCH c_is_payroll_run INTO l_is_payroll_run;
6102 IF c_is_payroll_run%FOUND THEN
6103 OPEN c_ele_entries(p_assignment_id);
6104 FETCH c_ele_entries INTO l_ele_entries;
6105 IF c_ele_entries%FOUND THEN
6106 l_return_value := 'Y';
6107 END IF;
6108 CLOSE c_ele_entries;
6109 END IF;
6110 CLOSE c_is_payroll_run;
6111
6112 ELSE
6113 l_return_value := 'Y';
6114 END IF;
6115 CLOSE c_rej_hf_ee;
6116 --9917330
6117
6118 -- Check for EE Assignment
6119 ELSIF l_assig_rec.assignment_type = 'E' THEN
6120 l_return_value := 'N';
6121
6122 -- Check if the asg org_id is in the list of orgs, Also Check if the
6123 -- value of payroll_id on the ASG is the same as the param Payroll id.
6124
6125 IF g_org_list.EXISTS(l_assig_rec.organization_id) AND
6126 ( g_extract_params(i).payroll_id IS NULL OR
6127 l_assig_rec.payroll_id =
6128 g_extract_params(i).payroll_id ) THEN
6129 --
6130 -- Added to reject EE's that are hired and fired on the same day
6131 --
6132 /* --9917330
6133 OPEN c_rej_hf_ee(g_person_id);
6134 FETCH c_rej_hf_ee INTO l_rej_hf_ee;
6135 IF c_rej_hf_ee%FOUND THEN
6136 l_return_value := 'N';
6137 ELSE
6138 l_return_value := 'Y';
6139 END IF;
6140 CLOSE c_rej_hf_ee;
6141 */ --9917330
6142
6143 --9917330
6144
6145 OPEN c_rej_hf_ee(g_person_id);
6146 FETCH c_rej_hf_ee INTO l_rej_hf_ee;
6147 IF c_rej_hf_ee%FOUND THEN
6148 l_return_value := 'N';
6149
6150 OPEN c_is_payroll_run(p_assignment_id, p_business_group_id, g_extract_params(i).payroll_id, g_extract_params(i).con_set_id );
6151 FETCH c_is_payroll_run INTO l_is_payroll_run;
6152 IF c_is_payroll_run%FOUND THEN
6153 OPEN c_ele_entries(p_assignment_id);
6154 FETCH c_ele_entries INTO l_ele_entries;
6155 IF c_ele_entries%FOUND THEN
6156 l_return_value := 'Y';
6157 END IF;
6158 CLOSE c_ele_entries;
6159 END IF;
6160 CLOSE c_is_payroll_run;
6161
6162 ELSE
6163 l_return_value := 'Y';
6164 END IF;
6165 CLOSE c_rej_hf_ee;
6166 --9917330
6167
6168
6169 END IF;
6170 END IF;
6171
6172 -- Check if any secondary assignments exist and need to be picked up
6173 IF l_return_value = 'N' AND l_assig_rec.primary_flag = 'Y' THEN
6174
6175 FOR temp_rec IN csr_sec_assig (c_assignment_id => p_assignment_id
6176 ,c_effective_date => l_effective_date
6177 ,c_business_group_id => p_business_group_id
6178 ,c_person_id => g_person_id)
6179 -- For all sec asg's
6180 LOOP
6181 IF g_org_list.EXISTS(temp_rec.organization_id) AND
6182 ( g_extract_params(i).payroll_id IS NULL OR
6183 temp_rec.payroll_id = g_extract_params(i).payroll_id) THEN
6184 --
6185 -- Added to reject EE's that are hired and fired on the same day
6186 --
6187 /* --9917330
6188 OPEN c_rej_hf_ee(g_person_id);
6189 FETCH c_rej_hf_ee INTO l_rej_hf_ee;
6190 IF c_rej_hf_ee%FOUND THEN
6191 l_return_value := 'N';
6192 ELSE
6193 l_return_value := 'Y';
6194 END IF;
6195 CLOSE c_rej_hf_ee;
6196 */ --9917330
6197
6198 --9917330
6199
6200 OPEN c_rej_hf_ee(g_person_id);
6201 FETCH c_rej_hf_ee INTO l_rej_hf_ee;
6202 IF c_rej_hf_ee%FOUND THEN
6203 l_return_value := 'N';
6204
6205 OPEN c_is_payroll_run(p_assignment_id, p_business_group_id, g_extract_params(i).payroll_id, g_extract_params(i).con_set_id );
6206 FETCH c_is_payroll_run INTO l_is_payroll_run;
6207 IF c_is_payroll_run%FOUND THEN
6208 OPEN c_ele_entries(p_assignment_id);
6209 FETCH c_ele_entries INTO l_ele_entries;
6210 IF c_ele_entries%FOUND THEN
6211 l_return_value := 'Y';
6212 END IF;
6213 CLOSE c_ele_entries;
6214 END IF;
6215 CLOSE c_is_payroll_run;
6216
6217 ELSE
6218 l_return_value := 'Y';
6219 END IF;
6220 CLOSE c_rej_hf_ee;
6221 --9917330
6222
6223 EXIT;
6224 END IF;
6225 END LOOP;
6226
6227 END IF;
6228
6229
6230 -- Added to maintain global asg data
6231 IF l_return_value = 'Y' THEN
6232 g_primary_assig(p_assignment_id) := l_assig_rec;
6233
6234 OPEN csr_asg_act(p_assignment_id
6235 ,null
6236 ,null
6237 ,g_extract_params(p_business_group_id).extract_start_date
6238 ,g_extract_params(p_business_group_id).extract_end_date
6239 );
6240 FETCH csr_asg_act INTO l_asg_act;
6241 IF csr_asg_act%FOUND THEN
6242 CLOSE csr_asg_act;
6243 ELSE
6244 CLOSE csr_asg_act;
6245 p_error_message := 'Payroll or QuickPay is not processed for this assignment.';
6246 END IF;
6247 Hr_Utility.set_location('..Valid Assig Id : '||p_assignment_id, 79);
6248
6249 IF l_assig_rec.primary_flag = 'Y' THEN
6250 --
6251 -- Populate the PL/SQL structures with data like contribution
6252 -- basis , ptp changes etc
6253 --
6254 Populate_Record_Structures
6255 (p_assignment_id => p_assignment_id
6256 ,p_effective_date => p_effective_date
6257 ,p_business_group_id => p_business_group_id
6258 ,p_error_message => p_error_message );
6259
6260 END IF;
6261
6262
6263 END IF; -- if l_return_value = 'Y'
6264
6265 Hr_Utility.set_location('l_return_value : '||l_return_value, 79);
6266 Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
6267 RETURN l_return_value;
6268
6269 END Pension_Criteria_Full_Profile;
6270
6271 -- =============================================================================
6272 -- Check_Addl_Assigs: Check if the person has any secondary active assigs within
6273 -- the extract date range, then check the criteria and store it in PL/SQL table.
6274 -- =============================================================================
6275 FUNCTION Check_Addl_Assigs
6276 (p_assignment_id IN Number
6277 ,p_business_group_id IN Number
6278 ,p_effective_date IN Date
6279 ,p_error_message OUT NOCOPY Varchar2
6280 ) RETURN Varchar2 IS
6281
6282 l_return_value Varchar2(50);
6283 i per_all_assignments_f.business_group_id%TYPE;
6284 l_proc_name Varchar2(150) := g_proc_name ||'Check_Addl_Assigs';
6285 l_sec_assg_rec csr_sec_assg%ROWTYPE;
6286 l_effective_date Date;
6287 l_criteria_value Varchar2(2);
6288 l_warning_message Varchar2(2000);
6289 l_error_message Varchar2(2000);
6290 l_asg_type per_all_assignments_f.assignment_type%TYPE;
6291 l_person_id per_all_people_f.person_id%TYPE;
6292 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
6293 BEGIN
6294 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
6295 i := p_business_group_id;
6296
6297 IF NOT g_primary_assig.EXISTS(p_assignment_id) THEN
6298 l_return_value := 'NOTFOUND';
6299 Hr_Utility.set_location('..Not a Valid assignment: '||p_assignment_id, 6);
6300 RETURN l_return_value;
6301 ELSIF g_primary_assig(p_assignment_id).assignment_type IN ('B','E') THEN
6302 Hr_Utility.set_location('..Valid Assignment Type B : '||p_assignment_id, 6);
6303 l_person_id := g_primary_assig(p_assignment_id).person_id;
6304 l_asg_type := g_primary_assig(p_assignment_id).assignment_type;
6305 -- Check if there are any other assignments which might be active within the
6306 -- specified extract date range
6307 FOR sec_asg_rec IN csr_sec_assg
6308 (c_primary_assignment_id => p_assignment_id
6309 ,c_person_id => g_primary_assig(p_assignment_id).person_id
6310 ,c_effective_date => g_extract_params(i).extract_end_date
6311 ,c_extract_start_date => g_extract_params(i).extract_start_date
6312 ,c_extract_end_date => g_extract_params(i).extract_end_date)
6313 LOOP
6314 l_sec_assg_rec := sec_asg_rec;
6315 l_criteria_value := 'N';
6316 l_effective_date := Least(g_extract_params(i).extract_end_date,
6317 l_sec_assg_rec.effective_end_date);
6318 Hr_Utility.set_location('..Checking for assignment id: '||
6319 l_sec_assg_rec.assignment_id, 7);
6320 Hr_Utility.set_location('..p_effective_date : '||l_effective_date, 7);
6321 -- Call the main criteria function for this assignment to check if its a
6322 -- valid assignment that can be reported based on the criteria specified.
6323 l_criteria_value := Pension_Criteria_Full_Profile
6324 (p_assignment_id => l_sec_assg_rec.assignment_id
6325 ,p_effective_date => l_effective_date
6326 ,p_business_group_id => p_business_group_id
6327 ,p_warning_message => l_warning_message
6328 ,p_error_message => l_error_message
6329 );
6330 IF l_criteria_value ='Y' THEN
6331 l_return_value := 'FOUND';
6332 END IF;
6333 END LOOP; -- FOR sec_asg_rec
6334 END IF;
6335 Hr_Utility.set_location('..Assignment Count : '||g_primary_assig.Count, 7);
6336 Hr_Utility.set_location('..l_person_id : '||l_person_id, 7);
6337 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
6338 RETURN l_return_value;
6339 EXCEPTION
6340 WHEN Others THEN
6341 p_error_message :='SQL-ERRM :'||SQLERRM;
6342 Hr_Utility.set_location('..'||p_error_message,85);
6343 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
6344 RETURN l_return_value;
6345 END Check_Addl_Assigs;
6346
6347 -- ====================================================================
6348 -- Raise_Extract_Warning:
6349 -- When called from the Rule of a extract detail data element
6350 -- it logs a warning in the ben_ext_rslt_err table against
6351 -- the person being processed (or as specified by context of
6352 -- assignment id ). It prefixes all warning messages with a
6353 -- string "Warning raised in data element "||element_name
6354 -- This allows the same Rule to be called from different data
6355 -- elements. Usage example.
6356 -- RAISE_EXTRACT_WARNING("No initials were found.")
6357 -- RRTURNCODE MEANING
6358 -- -1 Cannot raise warning against a header/trailer
6359 -- record. System Extract does not allow it.
6360 -- -2 No current extract process was found.
6361 -- -3 No person was found.A Warning in System Extract
6362 -- is always raised against a person.
6363 -- ====================================================================
6364 FUNCTION Raise_Extract_Warning
6365 (p_assignment_id IN Number -- context
6366 ,p_error_text IN Varchar2
6367 ,p_error_NUMBER IN Number DEFAULT NULL
6368 ) RETURN Number IS
6369 l_ext_rslt_id Number;
6370 l_person_id Number;
6371 l_error_text Varchar2(2000);
6372 l_return_value Number:= 0;
6373 BEGIN
6374 --
6375 IF p_assignment_id <> -1 THEN
6376 l_ext_rslt_id:= get_current_extract_result;
6377 IF l_ext_rslt_id <> -1 THEN
6378 IF p_error_NUMBER IS NULL THEN
6379 l_error_text:= 'Warning raised in data element '||
6380 Nvl(Ben_Ext_Person.g_elmt_name
6381 ,Ben_Ext_Fmt.g_elmt_name)||'. '||
6382 p_error_text;
6383 ELSE
6384 Ben_Ext_Thread.g_err_num := p_error_NUMBER;
6385 Ben_Ext_Thread.g_err_name := p_error_text;
6386 l_error_text :=
6387 Ben_Ext_Fmt.get_error_msg(To_Number(Substr(p_error_text, 5, 5)),
6388 p_error_text,Nvl(Ben_Ext_Person.g_elmt_name,Ben_Ext_Fmt.g_elmt_name) );
6389
6390 END IF;
6391 l_person_id:= Nvl(get_current_extract_person(p_assignment_id)
6392 ,Ben_Ext_Person.g_person_id);
6393
6394 IF l_person_id IS NOT NULL THEN
6395 --
6396 Ben_Ext_Util.write_err
6397 (p_err_num => p_error_NUMBER
6398 ,p_err_name => l_error_text
6399 ,p_typ_cd => 'W'
6400 ,p_person_id => l_person_id
6401 ,p_request_id => Fnd_Global.conc_request_id
6402 ,p_business_group_id => Fnd_Global.per_business_group_id
6403 ,p_ext_rslt_id => get_current_extract_result
6404 );
6405 l_return_value:= 0;
6406 ELSE
6407 l_return_value:= -3;
6408 END IF;
6409 ELSE
6410 --
6411 l_return_value:= -2; /* No current extract process was found */
6412 --
6413 END IF;
6414 --
6415 ELSE
6416 --
6417 l_return_value := -1; /* Cannot raise warnings against header/trailers */
6418 --
6419 END IF;
6420 --
6421 RETURN l_return_value;
6422 END Raise_Extract_Warning;
6423
6424 -- ====================================================================
6425 -- Get_Current_Extract_Result:
6426 -- Returns the person id associated with the given assignment.
6427 -- If none is found,it returns NULL. This may arise if the
6428 -- user calls this from a header/trailer record, where
6429 -- a dummy context of assignment_id = -1 is passed.
6430 -- ====================================================================
6431 FUNCTION Get_Current_Extract_Result
6432 RETURN Number IS
6433
6434 e_extract_process_not_running EXCEPTION;
6435 PRAGMA EXCEPTION_INIT(e_extract_process_not_running,-8002);
6436 l_ext_rslt_id Number;
6437
6438 BEGIN
6439
6440 l_ext_rslt_id := Ben_Ext_Thread.g_ext_rslt_id;
6441 RETURN l_ext_rslt_id;
6442
6443 EXCEPTION
6444 WHEN e_extract_process_not_running THEN
6445 RETURN -1;
6446
6447 END Get_Current_Extract_Result;
6448
6449 -- ====================================================================
6450 -- Get_Current_Extract_Person:
6451 -- Returns the ext_rslt_id for the current extract process
6452 -- if one is running, else returns -1
6453 -- ====================================================================
6454 FUNCTION Get_Current_Extract_Person
6455 (p_assignment_id IN NUMBER )
6456 RETURN NUMBER IS
6457
6458 l_person_id NUMBER;
6459
6460 BEGIN
6461
6462 SELECT person_id
6463 INTO l_person_id
6464 FROM per_all_assignments_f
6465 WHERE assignment_id = p_assignment_id
6466 AND ROWNUM < 2;
6467
6468 RETURN l_person_id;
6469
6470 EXCEPTION
6471 WHEN NO_DATA_FOUND THEN
6472 RETURN NULL;
6473
6474 END Get_Current_Extract_Person;
6475
6476 --============================================================================
6477 --Function to derive the code for person detail changes
6478 --============================================================================
6479 FUNCTION Get_Change_CD_PER
6480 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
6481 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
6482 ,p_effective_date IN DATE
6483 ,p_error_message OUT NOCOPY VARCHAR2
6484 ,p_data_element_value OUT NOCOPY VARCHAR2)
6485 RETURN NUMBER IS
6486
6487 l_proc_name VARCHAR2(150) := g_proc_name ||'Get_Change_CD_PER';
6488 l_new_hire NUMBER;
6489 l_hire_dt DATE;
6490
6491 BEGIN
6492
6493 hr_utility.set_location('Entering: '||l_proc_name, 5);
6494
6495 p_data_element_value := ' ';
6496 --
6497 -- Check if the EE assignment is a new hire
6498 --
6499 l_new_hire := g_new_hire_asg;
6500 l_hire_dt := g_hire_date;
6501
6502
6503 IF l_new_hire = 1 THEN
6504 p_data_element_value := ' ';
6505 ELSE
6506 p_data_element_value := 'W';
6507 END IF;
6508
6509 hr_utility.set_location('p_data_element_value: '||p_data_element_value, 5);
6510 hr_utility.set_location('Leaving: '||l_proc_name, 5);
6511
6512 RETURN 0 ;
6513
6514 EXCEPTION
6515
6516 WHEN OTHERS THEN
6517 p_error_message :='SQL-ERRM :'||SQLERRM;
6518 Hr_Utility.set_location('..'||p_error_message,85);
6519 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
6520 RETURN -1;
6521
6522 END GET_CHANGE_CD_PER;
6523
6524 --============================================================================
6525 --GET_PERSON_INITIALS
6526 --============================================================================
6527 FUNCTION Get_Person_Initials
6528 ( p_assignment_id IN Number
6529 ,p_business_group_id IN Number
6530 ,p_date_earned IN Date
6531 ,p_error_message OUT NOCOPY Varchar2
6532 ,p_data_element_value OUT NOCOPY Varchar2
6533 ) RETURN Number IS
6534
6535 CURSOR cur_get_initials(c_person_id IN Number,
6536 c_date_earned IN Date) IS
6537 SELECT Substr(replace(per_information1,'.',NULL),0,5)
6538 FROM per_all_people_f
6539 WHERE person_id = c_person_id
6540 AND business_group_id = p_business_group_id
6541 AND c_date_earned BETWEEN effective_start_date
6542 AND effective_end_date;
6543
6544 l_initials Varchar2(5);
6545 l_proc_name Varchar2(150) := g_proc_name ||'Get_Person_Initials';
6546 l_return_value Number :=0;
6547
6548 BEGIN
6549
6550 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
6551
6552 OPEN cur_get_initials(g_person_id,p_date_earned);
6553 FETCH cur_get_initials INTO l_initials;
6554 CLOSE cur_get_initials;
6555
6556 p_data_element_value := l_initials;
6557 Hr_Utility.set_location('Leaving: '||l_proc_name, 10);
6558 RETURN l_return_value;
6559
6560 EXCEPTION
6561 WHEN Others THEN
6562 p_error_message :='SQL-ERRM :'||SQLERRM;
6563 Hr_Utility.set_location('..'||p_error_message,7);
6564 Hr_Utility.set_location('Leaving: '||l_proc_name, 9);
6565 l_return_value := -1;
6566 RETURN l_return_value;
6567 END Get_Person_Initials;
6568
6569 -- =============================================================================
6570 -- Get_Partner_Last_Name:
6571 -- =============================================================================
6572 FUNCTION Get_Partner_Last_Name
6573 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
6574 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
6575 ,p_effective_date IN Date
6576 ,p_error_message OUT NOCOPY Varchar2
6577 ,p_data_element_value OUT NOCOPY Varchar2
6578 ) RETURN Number IS
6579
6580 CURSOR cur_last_partner_name
6581 (c_person_id IN Number
6582 ,c_date_earned IN Date) IS
6583 SELECT last_name
6584 FROM per_all_people_f
6585 WHERE person_id IN
6586 ( SELECT contact_person_id
6587 FROM per_contact_relationships
6588 WHERE person_id = c_person_id
6589 AND business_group_id = p_business_group_id
6590 AND contact_type IN ('S','D')
6591 AND c_date_earned
6592 BETWEEN Nvl(date_start,
6593 g_extract_params(p_business_group_id).extract_start_date )
6594 AND Nvl(date_end,
6595 g_extract_params(p_business_group_id).extract_end_date)
6596 )
6597 AND business_group_id = p_business_group_id
6598 AND c_date_earned BETWEEN effective_start_date
6599 AND effective_end_date;
6600
6601 l_last_partner_name per_all_people_f.last_name%TYPE;
6602 l_proc_name Varchar2(150) := g_proc_name ||'Get_Partner_Last_Name';
6603 l_return_value Number :=-1;
6604
6605 BEGIN
6606 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
6607
6608 OPEN cur_last_partner_name(g_person_id,p_effective_date);
6609 FETCH cur_last_partner_name INTO l_last_partner_name;
6610 CLOSE cur_last_partner_name;
6611
6612 p_data_element_value := Upper(l_last_partner_name);
6613
6614 Hr_Utility.set_location('Leaving: '||l_proc_name, 10);
6615 l_return_value :=0;
6616
6617 RETURN l_return_value;
6618
6619 EXCEPTION
6620 WHEN Others THEN
6621 p_error_message :='SQL-ERRM :'||SQLERRM;
6622 Hr_Utility.set_location('..'||p_error_message,7);
6623 Hr_Utility.set_location('Leaving: '||l_proc_name, 9);
6624 RETURN l_return_value;
6625 END Get_Partner_Last_Name;
6626
6627 -- =============================================================================
6628 -- Get_Gender:
6629 -- =============================================================================
6630 FUNCTION Get_Gender
6631 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
6632 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
6633 ,p_effective_date IN Date
6634 ,p_error_message OUT NOCOPY Varchar2
6635 ,p_data_element_value OUT NOCOPY Varchar2
6636 ) RETURN Number IS
6637 CURSOR cur_get_gender(c_date_earned IN Date
6638 ,c_business_group_id IN Number) IS
6639 SELECT Decode(sex,'F','V','M') gender
6640 FROM per_all_people_f
6641 WHERE person_id = g_person_id
6642 AND business_group_id = c_business_group_id
6643 AND c_date_earned BETWEEN effective_start_date
6644 AND effective_end_date;
6645
6646 l_proc_name Varchar2(150) := g_proc_name ||'Get_Gender';
6647 l_gender Varchar2(2);
6648 l_return_value Number;
6649
6650 BEGIN
6651 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
6652 OPEN cur_get_gender(p_effective_date,p_business_group_id);
6653 FETCH cur_get_gender INTO l_gender;
6654 CLOSE cur_get_gender;
6655 p_data_element_value := l_gender;
6656
6657 Hr_Utility.set_location('p_data_element_value:'||p_data_element_value, 5);
6658 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
6659
6660 l_return_value := 0;
6661 RETURN l_return_value;
6662
6663 EXCEPTION
6664 WHEN Others THEN
6665 p_error_message :='SQL-ERRM :'||SQLERRM;
6666 Hr_Utility.set_location('..'||p_error_message,85);
6667 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
6668 l_return_value := -1;
6669 RETURN l_return_value;
6670 END Get_Gender;
6671
6672 -- =============================================================================
6673 -- Get_Partner_Prefix:
6674 -- =============================================================================
6675 FUNCTION Get_Partner_Prefix
6676 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
6677 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
6678 ,p_effective_date IN Date
6679 ,p_error_message OUT NOCOPY Varchar2
6680 ,p_data_element_value OUT NOCOPY Varchar2
6681 ) RETURN Number IS
6682
6683 CURSOR cur_partner_prefix
6684 (c_date_earned IN Date) IS
6685 SELECT pre_name_adjunct
6686 FROM per_all_people_f
6687 WHERE person_id IN
6688 (SELECT contact_person_id
6689 FROM per_contact_relationships
6690 WHERE person_id = g_person_id
6691 AND business_group_id = p_business_group_id
6692 AND contact_type IN('S','D')
6693 AND c_date_earned
6694 BETWEEN Nvl(date_start,
6695 g_extract_params(p_business_group_id).extract_start_date )
6696 AND Nvl(date_end,
6697 g_extract_params(p_business_group_id).extract_end_date)
6698
6699 )
6700 AND business_group_id = p_business_group_id
6701 AND c_date_earned BETWEEN effective_start_date
6702 AND effective_end_date;
6703
6704 l_proc_name Varchar2(150) := g_proc_name ||'Get_Partner_Prefix';
6705 l_partner_prefix Varchar2(30);
6706 l_return_value Number;
6707
6708
6709 BEGIN
6710 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
6711 OPEN cur_partner_prefix(p_effective_date);
6712 FETCH cur_partner_prefix INTO l_partner_prefix;
6713 CLOSE cur_partner_prefix;
6714
6715 p_data_element_value := Upper(l_partner_prefix);
6716 Hr_Utility.set_location('p_data_element_value:'||p_data_element_value, 5);
6717 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
6718 l_return_value := 0;
6719 RETURN l_return_value;
6720 EXCEPTION
6721 WHEN Others THEN
6722 p_error_message :='SQL-ERRM :'||SQLERRM;
6723 Hr_Utility.set_location('..'||p_error_message,85);
6724 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
6725 l_return_value := -1;
6726 RETURN l_return_value;
6727 END Get_Partner_Prefix;
6728
6729 -- =============================================================================
6730 -- Get_Add_Fem_EE:
6731 -- =============================================================================
6732 FUNCTION Get_Add_Fem_EE
6733 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
6734 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
6735 ,p_effective_date IN Date
6736 ,p_error_message OUT NOCOPY Varchar2
6737 ,p_data_element_value OUT NOCOPY Varchar2) RETURN Number IS
6738
6739 CURSOR cur_add_fem IS
6740 SELECT per_information13
6741 FROM per_all_people_f
6742 WHERE person_id = g_person_id
6743 AND p_effective_date BETWEEN
6744 effective_start_date AND effective_end_date
6745 AND business_group_id = p_business_group_id
6746 AND per_information_category = 'NL';
6747
6748
6749 l_proc_name Varchar2(150) := g_proc_name ||'Get_Add_Fem_EE';
6750
6751 BEGIN
6752 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
6753 p_data_element_value := ' ';
6754 FOR temp_rec IN cur_add_fem
6755 LOOP
6756 p_data_element_value := temp_rec.per_information13;
6757 END LOOP;
6758 Hr_Utility.set_location('p_data_element_value:'||p_data_element_value, 5);
6759 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
6760
6761 RETURN 0;
6762
6763 EXCEPTION
6764 WHEN Others THEN
6765 p_error_message :='SQL-ERRM :'||SQLERRM;
6766 Hr_Utility.set_location('..'||p_error_message,85);
6767 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
6768 RETURN -1 ;
6769 END Get_Add_Fem_EE;
6770
6771 -- =============================================================================
6772 -- Get_EE_Num:
6773 -- =============================================================================
6774 FUNCTION Get_EE_Num
6775 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
6776 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
6777 ,p_effective_date IN Date
6778 ,p_error_message OUT NOCOPY Varchar2
6779 ,p_data_element_value OUT NOCOPY Varchar2
6780 ) RETURN Number IS
6781
6782 l_proc_name Varchar2(150) := g_proc_name ||'Get_EE_Num';
6783 l_per_ee_num per_all_people_f.employee_number%TYPE;
6784 BEGIN
6785 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
6786 IF g_primary_assig.EXISTS(p_assignment_id) THEN
6787 l_per_ee_num := g_primary_assig(p_assignment_id).ee_num;
6788 END IF;
6789 p_data_element_value := Nvl(l_per_ee_num,'000000000000000');
6790 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
6791 RETURN 0;
6792
6793 EXCEPTION
6794 WHEN Others THEN
6795 p_error_message :='SQL-ERRM :'||SQLERRM;
6796 Hr_Utility.set_location('..'||p_error_message,85);
6797 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
6798 RETURN -1;
6799 END Get_EE_Num;
6800
6801 -- =============================================================================
6802 -- Get_Old_Asg_Seq_Num:
6803 -- =============================================================================
6804 FUNCTION Get_Old_Asg_Seq_Num
6805 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
6806 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
6807 ,p_effective_date IN DATE
6808 ,p_error_message OUT NOCOPY VARCHAR2
6809 ,p_data_element_value OUT NOCOPY VARCHAR2
6810 ) RETURN NUMBER IS
6811
6812 CURSOR c_get_old_num IS
6813 SELECT NVL(lpad(aei_information2,2,'0'),'00') old_num
6814 FROM per_assignment_extra_info
6815 WHERE assignment_id = p_assignment_id
6816 AND information_type = 'PQP_NL_ABP_OLD_EE_INFO';
6817
6818 l_proc_name VARCHAR2(150) := g_proc_name ||'Get_Old_Asg_Seq_Num';
6819 l_old_asg_seq_num VARCHAR2(2);
6820
6821 BEGIN
6822
6823 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
6824
6825 OPEN c_get_old_num;
6826 FETCH c_get_old_num INTO l_old_asg_seq_num;
6827 CLOSE c_get_old_num;
6828
6829 p_data_element_value := UPPER(Nvl(l_old_asg_seq_num,'00'));
6830
6831 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
6832
6833 RETURN 0;
6834
6835 EXCEPTION
6836 WHEN Others THEN
6837 p_error_message :='SQL-ERRM :'||SQLERRM;
6838 Hr_Utility.set_location('..'||p_error_message,85);
6839 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
6840 RETURN -1;
6841 END Get_Old_Asg_Seq_Num;
6842
6843 -- =============================================================================
6844 -- Get_ABP_ER_Num
6845 -- =============================================================================
6846 FUNCTION Get_ABP_ER_Num
6847 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
6848 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
6849 ,p_effective_date IN Date
6850 ,p_fetch_code IN Varchar2
6851 ,p_error_message OUT NOCOPY Varchar2
6852 ,p_data_element_value OUT NOCOPY Varchar2
6853 ) RETURN NUMBER IS
6854
6855 --
6856 -- Cursor to find the named hierarchy associated with the BG
6857 --
6858 CURSOR c_find_named_hierarchy IS
6859 SELECT org_information1
6860 FROM hr_organization_information
6861 WHERE organization_id = p_business_group_id
6862 AND org_information_context = 'NL_BG_INFO';
6863
6864 --
6865 -- Cursor to find the valid version id for the particular named hierarchy
6866 --
6867 CURSOR c_find_ver_frm_hierarchy(c_hierarchy_id IN NUMBER) IS
6868 SELECT org_structure_version_id
6869 FROM per_org_structure_versions_v
6870 WHERE organization_structure_id = c_hierarchy_id
6871 AND g_extract_params(p_business_group_id).extract_end_date BETWEEN date_from
6872 AND nvl(date_to,hr_api.g_eot);
6873
6874 --
6875 -- Cursor to find the valid version id for a particular business group
6876 --
6877 CURSOR c_find_ver_frm_bg IS
6878 SELECT org_structure_version_id
6879 FROM per_org_structure_versions_v
6880 WHERE business_group_id = p_business_group_id
6881 AND g_extract_params(p_business_group_id).extract_end_date BETWEEN date_from
6882 AND nvl( date_to,hr_api.g_eot);
6883 --
6884 -- Cursor to find the parent id from the org id
6885 --
6886 CURSOR c_find_parent_id(c_org_id in number
6887 ,c_version_id in number) IS
6888 SELECT organization_id_parent
6889 FROM per_org_structure_elements
6890 WHERE organization_id_child = c_org_id
6891 AND org_structure_version_id = c_version_id
6892 AND business_group_id = p_business_group_id;
6893
6894 --
6895 -- Cursor to fetch ABP employer number
6896 --
6897 CURSOR csr_get_er_num(c_org_id IN Number) IS
6898 SELECT UPPER(nvl(lpad(org_information4,7,'0'),'0000000')) old_num
6899 ,SUBSTR(NVL(org_information2,'-1'),0,7) new_num
6900 FROM hr_organization_information
6901 WHERE org_information_context = 'PQP_ABP_PROVIDER'
6902 AND organization_id = c_org_id;
6903
6904 --
6905 -- Cursor to fetch the organization of the EE Asg.
6906 --
6907 CURSOR csr_get_org_id IS
6908 SELECT organization_id
6909 FROM per_all_assignments_f
6910 WHERE assignment_id = p_assignment_id
6911 AND business_group_id = p_business_group_id
6912 AND p_effective_date BETWEEN effective_start_date and effective_end_date --9583106
6913 ORDER BY effective_end_date DESC;
6914
6915 l_old_er_num ben_ext_chg_evt_log.old_val1%TYPE := '-1';
6916 l_new_er_num hr_organization_information.org_information2%TYPE := '-1';
6917 l_org_info_id hr_organization_information.org_information_id%TYPE;
6918 l_version_id per_org_structure_versions_v.org_structure_version_id%TYPE DEFAULT NULL;
6919 l_proc_name VARCHAR2(150) := g_proc_name ||'Get_ABP_ER_Num';
6920 l_ret_val NUMBER := -1;
6921 l_org_id NUMBER;
6922 l_named_hierarchy NUMBER;
6923 l_loop_again NUMBER;
6924
6925
6926 BEGIN
6927
6928 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
6929
6930 OPEN csr_get_org_id;
6931 FETCH csr_get_org_id INTO l_org_id;
6932 CLOSE csr_get_org_id ;
6933
6934 Hr_Utility.set_location('l_org_id: '||l_org_id, 5);
6935
6936 --
6937 -- Fetch the values for old and new ER nums
6938 --
6939 OPEN csr_get_er_num(l_org_id);
6940 FETCH csr_get_er_num INTO l_old_er_num,l_new_er_num;
6941 --
6942 --
6943 --
6944 IF csr_get_er_num%FOUND THEN
6945 --
6946 -- Depending on the fetch code,return the correct value
6947 --
6948 IF p_fetch_code = 'OLD' THEN
6949 p_data_element_value := l_old_er_num;
6950 l_ret_val := 0;
6951 ELSIF p_fetch_code = 'NEW' THEN
6952 p_data_element_value := l_new_er_num;
6953 l_ret_val := 0;
6954 END IF;
6955
6956 CLOSE csr_get_er_num;
6957 RETURN l_ret_val;
6958 --
6959 ELSE
6960 --
6961 CLOSE csr_get_er_num;
6962 --
6963 -- Value not found at this org level,traverse up the
6964 -- org hierarchy to find a value at the parent level
6965 --
6966 hr_utility.set_location('....No value found at HR org level,searching up the tree',40);
6967 --
6968 -- Check to see if a named hierarchy exists for the BG
6969 --
6970 OPEN c_find_named_hierarchy;
6971 FETCH c_find_named_hierarchy INTO l_named_hierarchy;
6972 --
6973 -- If a named hiearchy is found, find the valid version on that date
6974 --
6975 IF c_find_named_hierarchy%FOUND THEN
6976 CLOSE c_find_named_hierarchy;
6977 --
6978 -- Find the valid version on that date
6979 --
6980 OPEN c_find_ver_frm_hierarchy(l_named_hierarchy);
6981 FETCH c_find_ver_frm_hierarchy INTO l_version_id;
6982 --
6983 -- If no valid version is found, try to get it from the BG
6984 --
6985 IF c_find_ver_frm_hierarchy%NOTFOUND THEN
6986 CLOSE c_find_ver_frm_hierarchy;
6987 --
6988 -- Find the valid version id from the BG
6989 --
6990 OPEN c_find_ver_frm_bg;
6991 FETCH c_find_ver_frm_bg INTO l_version_id;
6992 CLOSE c_find_ver_frm_bg;
6993 --
6994 -- Else a valid version has been found for the named hierarchy
6995 --
6996 ELSE
6997 CLOSE c_find_ver_frm_hierarchy;
6998 END IF; -- end of if no valid version found
6999 --
7000 -- Else find the valid version from BG
7001 --
7002 ELSE
7003 CLOSE c_find_named_hierarchy;
7004 --
7005 -- Find the version number from the BG
7006 --
7007 OPEN c_find_ver_frm_bg;
7008 FETCH c_find_ver_frm_bg INTO l_version_id;
7009 CLOSE c_find_ver_frm_bg;
7010 END IF; -- end of if named hierarchy found
7011
7012 hr_utility.set_location(' l_version_id '||l_version_id,50);
7013
7014 IF l_version_id IS NULL THEN
7015 --
7016 -- No hierarchy has been defined, so return 00000
7017 --
7018 hr_utility.set_location('No hierarchy found,hence returning 0',60);
7019 hr_utility.set_location('Leaving get_abp_er_num',65);
7020 p_data_element_value := '';
7021 RETURN 0;
7022 END IF;
7023 --
7024 -- Loop through the org hierarchy to find the values
7025 -- at this org level or its parents
7026 --
7027 l_loop_again := 1;
7028 WHILE (l_loop_again = 1)
7029 LOOP
7030 --
7031 -- Find the parent of this org
7032 --
7033 OPEN c_find_parent_id(l_org_id,l_version_id);
7034 FETCH c_find_parent_id INTO l_org_id;
7035 IF c_find_parent_id%FOUND THEN
7036 hr_utility.set_location('searching at parent : '||l_org_id,70);
7037 CLOSE c_find_parent_id;
7038 OPEN csr_get_er_num(l_org_id);
7039 FETCH csr_get_er_num INTO l_old_er_num,l_new_er_num;
7040 IF csr_get_er_num%FOUND THEN
7041 CLOSE csr_get_er_num;
7042 l_loop_again := 0;
7043 --
7044 -- Depending on the fetch code,return the correct value
7045 --
7046 IF p_fetch_code = 'OLD' THEN
7047 p_data_element_value := l_old_er_num;
7048 l_ret_val := 0;
7049 ELSIF p_fetch_code = 'NEW' THEN
7050 p_data_element_value := l_new_er_num;
7051 l_ret_val := 0;
7052 END IF;
7053
7054 RETURN l_ret_val;
7055
7056 ELSE
7057 CLOSE csr_get_er_num;
7058 END IF;
7059
7060 ELSE
7061 --
7062 -- No parent found, so return 0
7063 --
7064 CLOSE c_find_parent_id;
7065 hr_utility.set_location('no parents found,returning 0',90);
7066 p_data_element_value := '';
7067 l_loop_again := 0;
7068 l_ret_val := 0;
7069 END IF;
7070 END LOOP;
7071 END IF;
7072
7073 Hr_Utility.set_location('....Old ER Num : '||l_old_er_num,10);
7074 Hr_Utility.set_location('....New ER Num : '||l_new_er_num,15);
7075 Hr_Utility.set_location('...p_data_element_value '||p_data_element_value,20);
7076 Hr_Utility.set_location('...p_error_message '||p_error_message,25);
7077 Hr_Utility.set_location('...l_ret_val '||l_ret_val ,30);
7078 Hr_Utility.set_location(' Leaving: '||l_proc_name,50);
7079
7080 RETURN l_ret_val;
7081
7082 EXCEPTION
7083 WHEN OTHERS THEN
7084 p_error_message :='SQL-ERRM :'||SQLERRM;
7085 Hr_Utility.set_location('..'||p_error_message,85);
7086 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7087 RETURN l_ret_val;
7088 END GET_ABP_ER_NUM;
7089
7090 -- =============================================================================
7091 -- Get_Old_Ee_Num
7092 -- =============================================================================
7093 FUNCTION Get_Old_Ee_Num
7094 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7095 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7096 ,p_effective_date IN DATE
7097 ,p_error_message OUT NOCOPY VARCHAR2
7098 ,p_data_element_value OUT NOCOPY VARCHAR2
7099 ) RETURN NUMBER IS
7100
7101 --
7102 -- Cursor to fetch the old employee number
7103 --
7104 CURSOR csr_get_old_ee_num IS
7105 SELECT NVL(lpad(aei_information1,15,'0'),'000000000000000') old_num
7106 FROM per_assignment_extra_info
7107 WHERE assignment_id = p_assignment_id
7108 AND information_type = 'PQP_NL_ABP_OLD_EE_INFO';
7109
7110 l_old_ee_num VARCHAR2(30) ;
7111 l_proc_name VARCHAR2(150) := g_proc_name ||'Get_Old_Ee_Num';
7112 l_ret_val NUMBER := 0;
7113
7114
7115 BEGIN
7116 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
7117
7118 --
7119 -- get the values for old EE num
7120 --
7121 OPEN csr_get_old_ee_num;
7122 FETCH csr_get_old_ee_num INTO l_old_ee_num;
7123 CLOSE csr_get_old_ee_num;
7124
7125 p_data_element_value := UPPER(NVL(l_old_ee_num,'000000000000000'));
7126
7127 l_ret_val := 0;
7128
7129 Hr_Utility.set_location(' p_data_element_value ' || p_data_element_value , 20);
7130 Hr_Utility.set_location('Leaving: '||l_proc_name, 50);
7131
7132 RETURN l_ret_val;
7133
7134 EXCEPTION
7135
7136 WHEN Others THEN
7137 p_error_message :='SQL-ERRM :'||SQLERRM;
7138 Hr_Utility.set_location('..'||p_error_message,85);
7139 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7140 RETURN -1;
7141
7142 END GET_OLD_EE_NUM;
7143
7144 --============================================================================
7145 -- Get the code for change in address for the EE
7146 --============================================================================
7147 FUNCTION Get_Change_CD_Addr
7148 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7149 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7150 ,p_effective_date IN DATE
7151 ,p_error_message OUT NOCOPY VARCHAR2
7152 ,p_data_element_value OUT NOCOPY VARCHAR2)
7153 RETURN Number IS
7154
7155 l_proc_name VARCHAR2(150) := g_proc_name ||'Get_Change_CD_Addr';
7156 l_new_hire NUMBER;
7157 l_hire_dt DATE;
7158
7159 BEGIN
7160
7161 hr_utility.set_location('Entering: '||l_proc_name, 5);
7162
7163 p_data_element_value := ' ';
7164
7165 --
7166 -- Check if the EE assignment is a new hire
7167 --
7168 l_new_hire := g_new_hire_asg;
7169 l_hire_dt := g_hire_date;
7170
7171 IF l_new_hire = 1 THEN
7172 p_data_element_value := ' ';
7173 ELSE
7174 p_data_element_value := 'W';
7175 END IF;
7176
7177 hr_utility.set_location('p_data_element_value: '||p_data_element_value, 5);
7178 hr_utility.set_location('Leaving: '||l_proc_name, 5);
7179
7180 RETURN 0 ;
7181
7182 EXCEPTION
7183 WHEN OTHERS THEN
7184 p_error_message :='SQL-ERRM :'||SQLERRM;
7185 hr_utility.set_location('..'||p_error_message,85);
7186 hr_utility.set_location('Leaving: '||l_proc_name, 90);
7187 RETURN -1 ;
7188 END Get_Change_CD_Addr;
7189
7190 -- =============================================================================
7191 -- Get_Street
7192 -- =============================================================================
7193 FUNCTION Get_Street
7194 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7195 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7196 ,p_effective_date IN Date
7197 ,p_error_message OUT NOCOPY Varchar2
7198 ,p_data_element_value OUT NOCOPY Varchar2
7199 ) RETURN Number IS
7200
7201
7202 CURSOR cur_get_street(c_person_id IN Number) IS
7203 SELECT region_1
7204 FROM per_addresses_v
7205 WHERE person_id = c_person_id
7206 AND p_effective_date BETWEEN date_from
7207 AND Nvl(date_to,Hr_Api.g_eot)
7208 AND primary_flag = 'Y'
7209 AND style = 'NL'
7210 UNION
7211 SELECT address_line1
7212 FROM per_addresses_v
7213 WHERE person_id = c_person_id
7214 AND p_effective_date BETWEEN date_from
7215 AND Nvl(date_to,Hr_Api.g_eot)
7216 AND primary_flag = 'Y'
7217 AND style = 'NL_GLB';
7218
7219 l_street per_addresses_v.region_1%TYPE;
7220 l_proc_name Varchar2(150) := g_proc_name ||'Get_Street';
7221
7222 BEGIN
7223 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
7224
7225 OPEN cur_get_street(g_person_id);
7226 FETCH cur_get_street INTO l_street;
7227 CLOSE cur_get_street;
7228
7229 p_data_element_value := Upper(l_street);
7230 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
7231 RETURN 0;
7232
7233 EXCEPTION
7234 WHEN Others THEN
7235 p_error_message :='SQL-ERRM :'||SQLERRM;
7236 Hr_Utility.set_location('..'||p_error_message,85);
7237 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7238 RETURN -1;
7239 END Get_Street;
7240
7241 -- =============================================================================
7242 -- Get_House_Num
7243 -- =============================================================================
7244 FUNCTION Get_House_Num
7245 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7246 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7247 ,p_effective_date IN Date
7248 ,p_error_message OUT NOCOPY Varchar2
7249 ,p_data_element_value OUT NOCOPY Varchar2
7250 ) RETURN Number IS
7251
7252 CURSOR cur_get_house_num(c_person_id IN Number) IS
7253 SELECT add_information13
7254 FROM per_addresses_v
7255 WHERE person_id = c_person_id
7256 AND p_effective_date BETWEEN date_from
7257 AND Nvl(date_to,Hr_Api.g_eot)
7258 AND style = 'NL'
7259 AND primary_flag = 'Y'
7260 UNION
7261 SELECT address_line2
7262 FROM per_addresses_v
7263 WHERE person_id = c_person_id
7264 AND p_effective_date BETWEEN date_from
7265 AND Nvl(date_to,Hr_Api.g_eot)
7266 AND style = 'NL_GLB'
7267 AND primary_flag = 'Y';
7268
7269 l_house_num per_addresses_v.address_line1%TYPE;
7270 l_proc_name Varchar2(150) := g_proc_name ||'Get_House_Num';
7271 l_ret_val Number := -1;
7272
7273 BEGIN
7274
7275 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
7276
7277 OPEN cur_get_house_num(g_person_id);
7278 FETCH cur_get_house_num INTO l_house_num;
7279 CLOSE cur_get_house_num;
7280
7281 p_data_element_value := Upper(l_house_num);
7282 l_ret_val :=0;
7283
7284 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
7285 RETURN l_ret_val;
7286
7287 EXCEPTION
7288 WHEN Others THEN
7289 p_error_message :='SQL-ERRM :'||SQLERRM;
7290 Hr_Utility.set_location('..'||p_error_message,85);
7291 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7292 RETURN l_ret_val;
7293 END Get_House_Num;
7294
7295 -- =============================================================================
7296 -- Get_Addnl_House_Num
7297 -- =============================================================================
7298 FUNCTION Get_Addnl_House_Num
7299 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7300 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7301 ,p_effective_date IN Date
7302 ,p_error_message OUT NOCOPY Varchar2
7303 ,p_data_element_value OUT NOCOPY Varchar2
7304 ) RETURN Number IS
7305
7306
7307 CURSOR cur_get_addl_house_num(c_person_id IN Number) IS
7308 SELECT add_information14
7309 FROM per_addresses_v
7310 WHERE person_id = c_person_id
7311 AND p_effective_date BETWEEN date_from
7312 AND Nvl(date_to,Hr_Api.g_eot)
7313 AND primary_flag = 'Y'
7314 AND style = 'NL'
7315 UNION
7316 SELECT address_line3
7317 FROM per_addresses_v
7318 WHERE person_id = c_person_id
7319 AND p_effective_date BETWEEN date_from
7320 AND Nvl(date_to,Hr_Api.g_eot)
7321 AND primary_flag = 'Y'
7322 AND style = 'NL_GLB';
7323
7324 l_addl_house_num per_addresses_v.address_line1%TYPE;
7325 l_proc_name Varchar2(150) := g_proc_name ||'Get_Addnl_House_Num';
7326 l_ret_val Number := -1;
7327
7328 BEGIN
7329
7330 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
7331
7332 OPEN cur_get_addl_house_num(g_person_id);
7333 FETCH cur_get_addl_house_num INTO l_addl_house_num;
7334 CLOSE cur_get_addl_house_num;
7335
7336 p_data_element_value := Upper(l_addl_house_num);
7337 l_ret_val :=0;
7338
7339 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
7340 RETURN l_ret_val;
7341
7342 EXCEPTION
7343 WHEN Others THEN
7344 p_error_message :='SQL-ERRM :'||SQLERRM;
7345 Hr_Utility.set_location('..'||p_error_message,85);
7346 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7347 RETURN l_ret_val;
7348 END Get_Addnl_House_Num;
7349
7350 -- =============================================================================
7351 -- Get_Postal_Code
7352 -- =============================================================================
7353 FUNCTION Get_Postal_Code
7354 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7355 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7356 ,p_effective_date IN Date
7357 ,p_error_message OUT NOCOPY Varchar2
7358 ,p_data_element_value OUT NOCOPY Varchar2
7359 ) RETURN Number IS
7360
7361
7362 CURSOR cur_get_postal_code(c_person_id IN Number) IS
7363 SELECT postal_code
7364 FROM per_addresses_v
7365 WHERE person_id = c_person_id
7366 AND p_effective_date BETWEEN date_from
7367 AND Nvl(date_to,Hr_Api.g_eot)
7368 AND style IN ('NL','NL_GLB')
7369 AND primary_flag = 'Y';
7370
7371 l_postal_code per_addresses_v.postal_code%TYPE;
7372 l_postal_code1 per_addresses_v.postal_code%TYPE;
7373 temp_str varchar2(1);
7374 i Number := 0;
7375 l_proc_name Varchar2(150) := g_proc_name ||'Get_Postal_Code';
7376 l_ret_val Number := -1;
7377
7378 BEGIN
7379 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
7380 OPEN cur_get_postal_code(g_person_id);
7381 FETCH cur_get_postal_code INTO l_postal_code;
7382 IF cur_get_postal_code%FOUND THEN
7383 CLOSE cur_get_postal_code;
7384 IF l_postal_code IS NOT NULL THEN
7385 FOR i in 1..length(l_postal_code)
7386 LOOP
7387 SELECT substr(l_postal_code,i,1) INTO temp_str from dual;
7388 IF temp_str <> ' ' THEN
7389 l_postal_code1 := l_postal_code1||temp_str;
7390 END IF;
7391 END LOOP;
7392 END IF;
7393 p_data_element_value := Upper(substr(l_postal_code1,0,6));
7394 ELSE
7395 CLOSE cur_get_postal_code;
7396 p_data_element_value := '';
7397 END IF;
7398 l_ret_val :=0;
7399 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
7400 RETURN l_ret_val;
7401
7402 EXCEPTION
7403 WHEN Others THEN
7404 p_error_message :='SQL-ERRM :'||SQLERRM;
7405 Hr_Utility.set_location('..'||p_error_message,85);
7406 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7407 RETURN l_ret_val;
7408 END Get_Postal_Code;
7409
7410 -- =============================================================================
7411 -- Get_City
7412 -- =============================================================================
7413 FUNCTION Get_City
7414 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7415 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7416 ,p_effective_date IN Date
7417 ,p_error_message OUT NOCOPY Varchar2
7418 ,p_data_element_value OUT NOCOPY Varchar2
7419 ) RETURN Number IS
7420
7421
7422 CURSOR cur_get_city(c_person_id IN Number) IS
7423 SELECT town_or_city
7424 FROM per_addresses_v
7425 WHERE person_id = c_person_id
7426 AND p_effective_date BETWEEN date_from
7427 AND Nvl(date_to,Hr_Api.g_eot)
7428 AND style IN ('NL','NL_GLB')
7429 AND primary_flag = 'Y';
7430
7431 CURSOR cur_get_foreign_coun(c_person_id IN Number) IS
7432 SELECT Decode(country,'NL','N',country) code
7433 ,d_country
7434 FROM per_addresses_v
7435 WHERE person_id = c_person_id
7436 AND p_effective_date BETWEEN date_from
7437 AND Nvl(date_to,Hr_Api.g_eot)
7438 AND style IN ('NL','NL_GLB')
7439 AND primary_flag = 'Y';
7440
7441
7442 CURSOR c_city (p_lookup_code IN VARCHAR2) IS
7443 SELECT meaning
7444 FROM hr_lookups
7445 WHERE lookup_type = 'HR_NL_CITY'
7446 AND lookup_code = p_lookup_code;
7447
7448
7449 l_city per_addresses_v.town_or_city%TYPE;
7450 l_city_name hr_lookups.meaning%TYPE;
7451 l_country per_addresses_v.d_country%TYPE;
7452 l_code per_addresses_v.country%TYPE;
7453 l_proc_name Varchar2(150) := g_proc_name ||'Get_Postal_Code';
7454 l_ret_val Number := -1;
7455
7456 BEGIN
7457 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
7458
7459 OPEN cur_get_city(g_person_id);
7460 FETCH cur_get_city INTO l_city;
7461 CLOSE cur_get_city;
7462
7463 OPEN cur_get_foreign_coun(g_person_id);
7464 FETCH cur_get_foreign_coun INTO l_code,l_country;
7465 CLOSE cur_get_foreign_coun;
7466
7467 IF l_city IS NOT NULL THEN
7468 FOR c_city_rec IN c_city (l_city) LOOP
7469 l_city_name := c_city_rec.meaning;
7470 END LOOP;
7471 END IF;
7472
7473 l_city_name := nvl(l_city_name,l_city);
7474
7475 IF l_code <> 'N' THEN
7476 p_data_element_value := Upper(l_city_name)||' '||Upper(l_country);
7477 ELSE
7478 p_data_element_value := Upper(l_city_name);
7479 END IF;
7480
7481 l_ret_val :=0;
7482
7483 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
7484 RETURN l_ret_val;
7485
7486 EXCEPTION
7487 WHEN Others THEN
7488 p_error_message :='SQL-ERRM :'||SQLERRM;
7489 Hr_Utility.set_location('..'||p_error_message,85);
7490 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7491 RETURN l_ret_val;
7492 END Get_City;
7493
7494 -- =============================================================================
7495 -- Get_Foreign_Country
7496 -- =============================================================================
7497 FUNCTION Get_Foreign_Country
7498 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7499 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7500 ,p_effective_date IN Date
7501 ,p_error_message OUT NOCOPY Varchar2
7502 ,p_data_element_value OUT NOCOPY Varchar2
7503 ) RETURN Number IS
7504
7505 CURSOR cur_get_foreign_coun(c_person_id IN Number) IS
7506 SELECT Decode(country,'NL',' ','J')
7507 FROM per_addresses_v
7508 WHERE person_id = c_person_id
7509 AND p_effective_date BETWEEN date_from
7510 AND Nvl(date_to,Hr_Api.g_eot)
7511 AND style IN ('NL','NL_GLB')
7512 AND primary_flag = 'Y';
7513
7514 l_country per_addresses_v.d_country%TYPE;
7515 l_proc_name Varchar2(150) := g_proc_name ||'Get_Foreign_Country';
7516 l_ret_val Number := 0;
7517
7518 BEGIN
7519 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
7520 OPEN cur_get_foreign_coun(g_person_id);
7521 FETCH cur_get_foreign_coun INTO l_country;
7522 CLOSE cur_get_foreign_coun;
7523
7524 p_data_element_value := l_country;
7525 l_ret_val :=0;
7526 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
7527 RETURN l_ret_val;
7528
7529 EXCEPTION
7530 WHEN Others THEN
7531 p_error_message :='SQL-ERRM :'||SQLERRM;
7532 Hr_Utility.set_location('..'||p_error_message,85);
7533 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7534 RETURN -1 ;
7535 END Get_Foreign_Country;
7536
7537 -- =============================================================================
7538 -- Get_Marital_Status
7539 -- =============================================================================
7540 FUNCTION Get_Marital_Status
7541 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7542 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7543 ,p_effective_date IN Date
7544 ,p_error_message OUT NOCOPY Varchar2
7545 ,p_data_element_value OUT NOCOPY Varchar2
7546 ) RETURN Number IS
7547
7548 CURSOR cur_get_marital_status(c_person_id IN Number) IS
7549 SELECT DECODE(marital_status, 'S',1,
7550 'M',2,
7551 'D',3,
7552 'W',4,
7553 'DP',0,
7554 'L',3,
7555 'BE_LIV_TOG',1,
7556 'REG_PART',1,
7557 'BE_WID_PENS',4,
7558 NULL) ms_code
7559 FROM per_all_people_f
7560 WHERE person_id = c_person_id
7561 AND business_group_id = p_business_group_id
7562 AND p_effective_date BETWEEN effective_start_date
7563 AND effective_end_date;
7564
7565 CURSOR cur_get_foreign_coun(c_person_id IN Number) IS
7566 SELECT DECODE(country,'NL','N','J')
7567 FROM per_addresses_v
7568 WHERE person_id = c_person_id
7569 AND p_effective_date BETWEEN date_from
7570 AND NVL(date_to,hr_api.g_eot)
7571 AND style IN('NL','NL_GLB')
7572 AND primary_flag = 'Y';
7573
7574 l_marital_status per_all_people_f.marital_status%TYPE;
7575 l_native VARCHAR2(1) := 'N';
7576 l_proc_name VARCHAR2(150) := g_proc_name ||'Get_Marital_Status';
7577 l_ret_val NUMBER := -1;
7578
7579 BEGIN
7580 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
7581
7582 OPEN cur_get_foreign_coun(g_person_id);
7583 FETCH cur_get_foreign_coun INTO l_native;
7584 CLOSE cur_get_foreign_coun;
7585
7586 IF l_native = 'J' THEN
7587 OPEN cur_get_marital_status(g_person_id);
7588 FETCH cur_get_marital_status INTO l_marital_status;
7589 CLOSE cur_get_marital_status;
7590 p_data_element_value := l_marital_status;
7591 ELSE
7592 p_data_element_value := ' ';
7593 END IF;
7594
7595 l_ret_val :=0;
7596 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
7597
7598 RETURN l_ret_val;
7599
7600 EXCEPTION
7601 WHEN Others THEN
7602 p_error_message :='SQL-ERRM :'||SQLERRM;
7603 Hr_Utility.set_location('..'||p_error_message,85);
7604 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7605 RETURN l_ret_val;
7606 END Get_Marital_Status;
7607
7608 -- =============================================================================
7609 -- Get_Pension_Salary -- Function to derive pension salary value for Record 08
7610 -- =============================================================================
7611 FUNCTION Get_Pension_Salary
7612 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7613 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7614 ,p_effective_date IN DATE
7615 ,p_balance_name IN pay_balance_types.balance_name%TYPE
7616 ,p_asg_act IN NUMBER
7617 ,p_error_message OUT NOCOPY VARCHAR2
7618 ,p_data_element_value OUT NOCOPY VARCHAR2)
7619 RETURN NUMBER IS
7620 --
7621 -- Cursor to get the override ABP Pension Salary
7622 --
7623 CURSOR c_get_override_salary IS
7624 SELECT NVL(aei_information6,'0') ,
7625 TRUNC(fnd_date.canonical_to_date(aei_information1))
7626 FROM per_assignment_extra_info
7627 WHERE assignment_id = p_assignment_id
7628 AND information_type = 'NL_ABP_PAR_INFO'
7629 AND aei_information_category = 'NL_ABP_PAR_INFO'
7630 AND p_effective_date BETWEEN
7631 TRUNC(fnd_date.canonical_to_date(aei_information1))
7632 AND TRUNC(NVL(fnd_date.canonical_to_date(aei_information2),hr_api.g_eot))
7633 AND aei_information6 IS NOT NULL;
7634
7635 l_ret_val NUMBER := 0;
7636 l_asg_action_id pay_assignment_actions.assignment_action_id%TYPE;
7637 l_bal_exists NUMBER;
7638 l_balance_id pay_balance_types.balance_type_id%TYPE;
7639 l_balance_amount NUMBER := 0;
7640 l_override_value ben_ext_chg_evt_log.new_val1%TYPE;
7641 l_proc_name VARCHAR2(150) := g_proc_name ||'Get_Pension_Salary';
7642 l_eff_dt DATE;
7643 l_dim_name VARCHAR2(100);
7644
7645 BEGIN
7646
7647 Hr_Utility.set_location(' Entering ' || l_proc_name,5);
7648 Hr_Utility.set_location(' p_assignment_id ' || p_assignment_id,6);
7649 Hr_Utility.set_location(' p_balance_name ' || p_balance_name,7);
7650 Hr_Utility.set_location(' p_effective_date ' || p_effective_date,7);
7651 Hr_Utility.set_location(' p_asg_act ' || p_asg_act,7);
7652
7653 --
7654 -- Fetch the overridden value if there is any override at the ASG EIT
7655 --
7656 OPEN c_get_override_salary;
7657 FETCH c_get_override_salary INTO l_override_value,l_eff_dt;
7658 IF c_get_override_salary%FOUND THEN
7659 CLOSE c_get_override_salary;
7660 hr_utility.set_location(' Found Override at ASG Level ', 25);
7661 p_data_element_value := l_override_value;
7662 RETURN 0;
7663 ELSE
7664 CLOSE c_get_override_salary;
7665 END IF;
7666 --
7667 -- Check if the EE assignment is a late hire. Use appropriate dimension
7668 -- if the EE is a late hire. Normal ASG_YTD otherwise.
7669 --
7670 IF Chk_Asg_Late_Hire (p_assignment_id => p_assignment_id
7671 ,p_business_group_id => p_business_group_id) THEN
7672 l_dim_name := 'NL Assignment ABP Year To Date Dimension';
7673 hr_utility.set_location(' Asg is late hire ', 25);
7674 ELSE
7675 l_dim_name := 'Assignment Year To Date';
7676 hr_utility.set_location(' Asg is not a late hire ', 25);
7677 END IF;
7678
7679 OPEN csr_defined_bal(p_balance_name
7680 ,l_dim_name
7681 ,p_business_group_id);
7682 FETCH csr_defined_bal INTO l_balance_id;
7683 CLOSE csr_defined_bal;
7684
7685 Hr_Utility.set_location(' l_balance_id ' || l_balance_id , 15);
7686
7687 IF l_balance_id IS NOT NULL THEN
7688
7689 IF p_asg_act <> - 1 THEN
7690 l_balance_amount := Pay_Balance_Pkg.get_value
7691 (p_defined_balance_id => l_balance_id
7692 ,p_assignment_action_id => p_asg_act);
7693 Hr_Utility.set_location(' l_balance_amount ' || l_balance_amount , 25);
7694 l_balance_amount := NVL(l_balance_amount,0);
7695 p_data_element_value :=
7696 Fnd_Number.number_to_canonical(l_balance_amount);
7697 l_ret_val := 0;
7698 ELSIF p_asg_act = - 1 THEN
7699
7700 Hr_Utility.set_location(' l_asg_action_id ' || l_asg_action_id , 20);
7701 Hr_Utility.set_location(' l_eff_dt ' || l_eff_dt , 22);
7702 OPEN csr_asg_act1 (
7703 c_assignment_id => p_assignment_id
7704 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
7705 ,c_con_set_id => NULL
7706 ,c_start_date => g_extract_params(p_business_group_id).extract_start_date
7707 ,c_end_date => g_extract_params(p_business_group_id).extract_end_date);
7708 FETCH csr_asg_act1 INTO l_asg_action_id;
7709 CLOSE csr_asg_act1;
7710
7711 IF l_asg_action_id IS NOT NULL THEN
7712 l_balance_amount := Pay_Balance_Pkg.get_value
7713 (p_defined_balance_id => l_balance_id
7714 ,p_assignment_action_id => l_asg_action_id);
7715 Hr_Utility.set_location(' l_balance_amount ' || l_balance_amount , 25);
7716 l_balance_amount := NVL(l_balance_amount,0);
7717 p_data_element_value :=
7718 Fnd_Number.number_to_canonical(l_balance_amount);
7719 l_ret_val := 0;
7720 END IF;
7721
7722 END IF;
7723 END IF;
7724
7725 Hr_Utility.set_location(' p_data_element_value ' || p_data_element_value , 30);
7726 Hr_Utility.set_location(' l_ret_val ' || l_ret_val , 40);
7727 Hr_Utility.set_location(' Leaving ' || l_proc_name , 50);
7728
7729 RETURN l_ret_val;
7730
7731 EXCEPTION WHEN Others THEN
7732 p_error_message :='SQL-ERRM :'||SQLERRM;
7733 Hr_Utility.set_location('..'||p_error_message,85);
7734 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7735 RETURN l_ret_val;
7736
7737 END Get_Pension_Salary;
7738
7739 -- =============================================================================
7740 -- Get_Contribution_Amount for Record 12/41
7741 -- =============================================================================
7742 FUNCTION Get_Contribution_Amount(
7743 p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7744 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7745 ,p_effective_date IN Date
7746 ,p_record_number IN Number
7747 ,p_error_message OUT NOCOPY Varchar2
7748 ,p_data_element_value OUT NOCOPY Varchar2) RETURN Number IS
7749
7750 l_proc_name Varchar2(150) := g_proc_name ||'Get_Contribution_Amount';
7751 j Number;
7752
7753 BEGIN
7754
7755 Hr_Utility.set_location(' Entering ' || l_proc_name , 10);
7756 IF p_record_number = 12 THEN
7757 IF l_rec_12_values.count > 0 THEN
7758 j := l_rec_12_values.FIRST;
7759 IF l_rec_12_values.EXISTS(j) THEN
7760 p_data_element_value
7761 := Fnd_Number.number_to_canonical(l_rec_12_values(j).contrib_amount);
7762 END IF;
7763 END IF;
7764 ELSIF p_record_number = 41 THEN
7765 IF l_rec_41_contrib_values.count > 0 THEN
7766 j := l_rec_41_contrib_values.FIRST;
7767 IF l_rec_41_contrib_values.EXISTS(j) THEN
7768 p_data_element_value
7769 := Fnd_Number.number_to_canonical(l_rec_41_contrib_values(j).contrib_amount);
7770 END IF;
7771 END IF;
7772 END IF;
7773 RETURN 0;
7774
7775 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7776 EXCEPTION
7777 WHEN Others THEN
7778 p_error_message :='SQL-ERRM :'||SQLERRM;
7779 Hr_Utility.set_location('..'||p_error_message,85);
7780 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7781 RETURN -1 ;
7782 END Get_Contribution_Amount;
7783
7784 -- =============================================================================
7785 -- Get_Sub_Cat_12 for Record 12
7786 -- This Function gets the sub categories
7787 -- =============================================================================
7788
7789 FUNCTION Get_Sub_Cat_12
7790 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7791 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7792 ,p_effective_date IN Date
7793 ,p_error_message OUT NOCOPY Varchar2
7794 ,p_data_element_value OUT NOCOPY Varchar2
7795 ) RETURN Number IS
7796
7797 l_proc_name Varchar2(150) := g_proc_name ||'Get_Sub_Cat_12';
7798 j Number;
7799
7800 BEGIN
7801 Hr_Utility.set_location(' Entering ' || l_proc_name , 10);
7802 IF l_rec_12_values.count > 0 THEN
7803 j := l_rec_12_values.FIRST;
7804 p_data_element_value := lpad(l_rec_12_values(j).code,2,'0');
7805 END IF;
7806
7807 RETURN 0;
7808
7809 Hr_Utility.set_location(' Leaving ' || l_proc_name , 80);
7810
7811 EXCEPTION
7812 WHEN Others THEN
7813 p_error_message :='SQL-ERRM :'||SQLERRM;
7814 Hr_Utility.set_location('..'||p_error_message,85);
7815 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7816 RETURN -1;
7817 END Get_Sub_Cat_12;
7818
7819 -- =============================================================================
7820 -- Get_Pension_Start_Year
7821 -- =============================================================================
7822 FUNCTION Get_Pension_Start_Year
7823 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7824 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7825 ,p_effective_date IN DATE
7826 ,p_start_date IN DATE
7827 ,p_end_date IN DATE
7828 ,p_error_message OUT NOCOPY VARCHAR2
7829 ,p_data_element_value OUT NOCOPY VARCHAR2
7830 ) RETURN NUMBER IS
7831
7832 CURSOR cur_get_asg_start_date(c_assign_id IN NUMBER) IS
7833 SELECT MIN(asg.effective_start_date)
7834 FROM per_assignments_f asg,per_assignment_status_types past
7835 WHERE asg.assignment_status_type_id = past.assignment_status_type_id
7836 AND past.per_system_status = 'ACTIVE_ASSIGN'
7837 AND asg.assignment_id = c_assign_id;
7838
7839 CURSOR cur_get_yr(c_effective_dt IN Date) IS
7840 SELECT fnd_date.canonical_to_date(TO_CHAR(c_effective_dt,'YYYY')||'/01/01')
7841 FROM dual ;
7842 --
7843 -- Cursor to check if there are any changes in the pension salary
7844 --
7845 CURSOR c_get_override_start_date IS
7846 SELECT fnd_date.canonical_to_date(prmtr_02)
7847 FROM ben_ext_chg_evt_log
7848 WHERE person_id = g_person_id
7849 AND Fnd_Number.canonical_to_number(prmtr_01) = p_assignment_id
7850 AND chg_eff_dt BETWEEN p_start_date AND p_end_date
7851 AND chg_evt_cd = 'COAPS'
7852 AND ext_chg_evt_log_id =
7853 (SELECT Max(ext_chg_evt_log_id)
7854 FROM ben_ext_chg_evt_log
7855 WHERE person_id = g_person_id
7856 AND Fnd_Number.canonical_to_number(prmtr_01) = p_assignment_id
7857 AND chg_eff_dt BETWEEN p_start_date AND p_end_date
7858 AND chg_evt_cd = 'COAPS');
7859
7860 l_ret_val NUMBER := -1;
7861 l_start_date_yr DATE;
7862 l_assign_start_dt DATE;
7863 l_proc_name VARCHAR2(150) := g_proc_name ||'Get_Pension_Start_Year';
7864 l_return NUMBER(1);
7865 l_pension_type_id NUMBER(10);
7866 l_pen_part_start_dt DATE;
7867
7868 BEGIN
7869
7870 Hr_Utility.set_location(' Entering ' || l_proc_name , 5);
7871 Hr_Utility.set_location(' p_assignment_id ' || p_assignment_id , 6);
7872
7873 OPEN cur_get_yr(p_effective_date);
7874 FETCH cur_get_yr INTO l_start_date_yr;
7875 CLOSE cur_get_yr;
7876
7877 OPEN cur_get_asg_start_date(p_assignment_id);
7878 FETCH cur_get_asg_start_date INTO l_assign_start_dt;
7879 CLOSE cur_get_asg_start_date;
7880
7881 OPEN c_get_override_start_date;
7882 FETCH c_get_override_start_date INTO l_pen_part_start_dt;
7883
7884 IF c_get_override_start_date%FOUND THEN
7885 CLOSE c_get_override_start_date;
7886 Hr_Utility.set_location(' l_pen_part_start_dt ' || l_pen_part_start_dt , 10);
7887 Hr_Utility.set_location('l_start_date_yr'||l_start_date_yr , 40);
7888
7889 IF (l_pen_part_start_dt IS NOT NULL AND l_start_date_yr IS NOT NULL) THEN
7890
7891 IF ( l_pen_part_start_dt > l_start_date_yr ) THEN
7892 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
7893 (l_pen_part_start_dt,'YYYYMMDD');
7894 ELSE
7895 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
7896 (l_start_date_yr,'YYYYMMDD');
7897 END IF;
7898 Hr_Utility.set_location('p_data_element_value'||p_data_element_value,50);
7899 l_ret_val := 0;
7900 END IF;
7901
7902 ELSE
7903 CLOSE c_get_override_start_date;
7904 IF (l_assign_start_dt IS NOT NULL AND l_start_date_yr IS NOT NULL) THEN
7905
7906 IF ( l_assign_start_dt > l_start_date_yr ) THEN
7907 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
7908 (l_assign_start_dt,'YYYYMMDD');
7909 ELSE
7910 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
7911 (l_start_date_yr,'YYYYMMDD');
7912 END IF;
7913 l_ret_val := 0;
7914
7915 END IF;
7916 END IF;
7917
7918 Hr_Utility.set_location(' l_ret_val ' || l_ret_val , 60);
7919 Hr_Utility.set_location(' p_data_element_value'||p_data_element_value , 70);
7920 Hr_Utility.set_location(' Leaving: '||l_proc_name, 80);
7921
7922 RETURN l_ret_val ;
7923
7924 EXCEPTION
7925 WHEN OTHERS THEN
7926 p_error_message :='SQL-ERRM :'||SQLERRM;
7927 Hr_Utility.set_location('..'||p_error_message,85);
7928 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7929 RETURN l_ret_val;
7930 END Get_Pension_Start_Year;
7931
7932
7933 FUNCTION Get_Pension_Basis_Year
7934 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7935 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7936 ,p_effective_date IN Date
7937 ,p_record_number IN Number
7938 ,p_error_message OUT NOCOPY Varchar2
7939 ,p_data_element_value OUT NOCOPY Varchar2
7940 ) RETURN Number IS
7941
7942 l_proc_name Varchar2(150) := g_proc_name ||'Get_Pension_Basis_Year';
7943 j number;
7944
7945 BEGIN
7946
7947 Hr_Utility.set_location(' Entering ' || l_proc_name , 05);
7948 IF p_record_number = 9 THEN
7949 IF l_rec_09_values.count > 0 THEN
7950 j := l_rec_09_values.FIRST;
7951 IF l_rec_09_values.EXISTS(j) THEN
7952 p_data_element_value := l_rec_09_values(j).date_earned;
7953 END IF;
7954 END IF;
7955 ELSIF p_record_number = 31 THEN
7956 IF l_rec_31_values.count > 0 THEN
7957 j := l_rec_31_values.FIRST;
7958 IF l_rec_31_values.EXISTS(j) THEN
7959 p_data_element_value := l_rec_31_values(j).date_earned;
7960 END IF;
7961 END IF;
7962 ELSIF p_record_number = 41 THEN
7963 IF l_rec_41_basis_values.count > 0 THEN
7964 j := l_rec_41_basis_values.FIRST;
7965 IF l_rec_41_basis_values.EXISTS(j) THEN
7966 p_data_element_value := l_rec_41_basis_values(j).date_earned;
7967 END IF;
7968 END IF;
7969 END IF;
7970
7971 IF p_data_element_value <> ' ' THEN
7972 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
7973 (Fnd_Date.canonical_to_date(p_data_element_value),
7974 'YYYY');
7975 ELSE
7976 p_data_element_value := '0000';
7977 END IF;
7978 Hr_Utility.set_location(' Leaving ' || l_proc_name , 25);
7979
7980 RETURN 0;
7981
7982 EXCEPTION
7983 WHEN Others THEN
7984 p_error_message :='SQL-ERRM :'||SQLERRM;
7985 Hr_Utility.set_location('..'||p_error_message,85);
7986 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
7987 RETURN -1;
7988 END Get_Pension_Basis_Year;
7989
7990 FUNCTION Get_Month_Contribution_Base
7991 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
7992 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
7993 ,p_effective_date IN Date
7994 ,p_record_number IN Number
7995 ,p_error_message OUT NOCOPY Varchar2
7996 ,p_data_element_value OUT NOCOPY Varchar2
7997 ) RETURN Number IS
7998
7999 l_proc_name Varchar2(150) := g_proc_name ||'Get_Month_Contribution_Base';
8000 j number;
8001
8002 BEGIN
8003
8004 Hr_Utility.set_location(' Entering ' || l_proc_name , 05);
8005 IF p_record_number = 9 THEN
8006 IF l_rec_09_values.count > 0 THEN
8007 j := l_rec_09_values.FIRST;
8008 IF l_rec_09_values.EXISTS(j) THEN
8009 p_data_element_value := l_rec_09_values(j).date_earned;
8010 END IF;
8011 END IF;
8012 ELSIF p_record_number = 31 THEN
8013 IF l_rec_31_values.count > 0 THEN
8014 j := l_rec_31_values.FIRST;
8015 IF l_rec_31_values.EXISTS(j) THEN
8016 p_data_element_value := l_rec_31_values(j).date_earned;
8017 l_rec_31_values.DELETE(j);
8018 END IF;
8019 END IF;
8020 ELSIF p_record_number = 41 THEN
8021 IF l_rec_41_basis_values.count > 0 THEN
8022 j := l_rec_41_basis_values.FIRST;
8023 IF l_rec_41_basis_values.EXISTS(j) THEN
8024 p_data_element_value := l_rec_41_basis_values(j).date_earned;
8025 l_rec_41_basis_values.DELETE(j);
8026 END IF;
8027 END IF;
8028 END IF;
8029
8030 IF p_data_element_value <> ' ' THEN
8031 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
8032 (Fnd_Date.canonical_to_date(p_data_element_value),
8033 'MM');
8034 ELSE
8035 p_data_element_value := '00';
8036 END IF;
8037 Hr_Utility.set_location(' Leaving ' || l_proc_name , 25);
8038
8039 RETURN 0;
8040
8041 EXCEPTION
8042 WHEN Others THEN
8043 p_error_message :='SQL-ERRM :'||SQLERRM;
8044 Hr_Utility.set_location('..'||p_error_message,85);
8045 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
8046 RETURN -1;
8047
8048 END Get_Month_Contribution_Base;
8049
8050 FUNCTION Get_Year_Contribution_Amt
8051 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
8052 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
8053 ,p_effective_date IN Date
8054 ,p_record_number IN Number
8055 ,p_error_message OUT NOCOPY Varchar2
8056 ,p_data_element_value OUT NOCOPY Varchar2
8057 ) RETURN Number IS
8058
8059 l_proc_name Varchar2(150) := g_proc_name ||'Get_Year_Contribution_Amt';
8060 j number;
8061
8062 BEGIN
8063
8064 Hr_Utility.set_location(' Entering ' || l_proc_name , 05);
8065 IF p_record_number = 12 THEN
8066 IF l_rec_12_values.count > 0 THEN
8067 j := l_rec_12_values.FIRST;
8068 IF l_rec_12_values.EXISTS(j) THEN
8069 p_data_element_value := l_rec_12_values(j).date_earned;
8070 IF p_data_element_value <> ' ' THEN
8071 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
8072 (Fnd_Date.canonical_to_date(p_data_element_value),
8073 'YYYY');
8074 ELSE
8075 p_data_element_value := '0000';
8076 END IF;
8077 END IF;
8078 END IF;
8079 ELSIF p_record_number = 41 THEN
8080 IF l_rec_41_contrib_values.count > 0 THEN
8081 j := l_rec_41_contrib_values.FIRST;
8082 IF l_rec_41_contrib_values.EXISTS(j) THEN
8083 p_data_element_value := l_rec_41_contrib_values(j).date_earned;
8084 IF p_data_element_value <> ' ' THEN
8085 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
8086 (Fnd_Date.canonical_to_date(p_data_element_value),
8087 'YYYY');
8088 ELSE
8089 p_data_element_value := '0000';
8090 END IF;
8091 END IF;
8092 END IF;
8093 END IF;
8094 Hr_Utility.set_location(' Leaving ' || l_proc_name , 25);
8095
8096 RETURN 0;
8097
8098 EXCEPTION
8099 WHEN Others THEN
8100 p_error_message :='SQL-ERRM :'||SQLERRM;
8101 Hr_Utility.set_location('..'||p_error_message,85);
8102 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
8103 RETURN -1;
8104 END Get_Year_Contribution_Amt;
8105
8106 FUNCTION Get_Month_Contribution_Amt
8107 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
8108 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
8109 ,p_effective_date IN Date
8110 ,p_record_number IN Number
8111 ,p_error_message OUT NOCOPY Varchar2
8112 ,p_data_element_value OUT NOCOPY Varchar2
8113 ) RETURN Number IS
8114
8115 l_proc_name Varchar2(150) := g_proc_name ||'Get_Month_Contribution_Amt';
8116 j number;
8117
8118 BEGIN
8119
8120 Hr_Utility.set_location(' Entering ' || l_proc_name , 05);
8121 IF p_record_number = 12 THEN
8122 IF l_rec_12_values.count > 0 THEN
8123 j := l_rec_12_values.FIRST;
8124 IF l_rec_12_values.EXISTS(j) THEN
8125 p_data_element_value := l_rec_12_values(j).date_earned;
8126 IF p_data_element_value <> ' ' THEN
8127 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
8128 (Fnd_Date.canonical_to_date(p_data_element_value),
8129 'MM');
8130 ELSE
8131 p_data_element_value := '00';
8132 END IF;
8133 l_rec_12_values.DELETE(j);
8134 END IF;
8135 END IF;
8136 ELSIF p_record_number = 41 THEN
8137 IF l_rec_41_contrib_values.count > 0 THEN
8138 j := l_rec_41_contrib_values.FIRST;
8139 IF l_rec_41_contrib_values.EXISTS(j) THEN
8140 p_data_element_value := l_rec_41_contrib_values(j).date_earned;
8141 IF p_data_element_value <> ' ' THEN
8142 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
8143 (Fnd_Date.canonical_to_date(p_data_element_value),
8144 'MM');
8145 ELSE
8146 p_data_element_value := '00';
8147 END IF;
8148 l_rec_41_contrib_values.DELETE(j);
8149 END IF;
8150 END IF;
8151 END IF;
8152 Hr_Utility.set_location(' Leaving ' || l_proc_name , 25);
8153
8154 RETURN 0;
8155
8156 EXCEPTION
8157 WHEN Others THEN
8158 p_error_message :='SQL-ERRM :'||SQLERRM;
8159 Hr_Utility.set_location('..'||p_error_message,85);
8160 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
8161 RETURN -1;
8162
8163 END Get_Month_Contribution_Amt;
8164
8165 --============================================================================
8166 -- Function to derive the display criteria for Record 01
8167 --============================================================================
8168 FUNCTION Record01_Display_Criteria
8169 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
8170 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
8171 ,p_effective_date IN DATE
8172 ,p_error_message OUT NOCOPY VARCHAR2
8173 ,p_data_element_value OUT NOCOPY VARCHAR2)
8174 RETURN NUMBER IS
8175
8176 CURSOR c_data_entered IS
8177 SELECT 1
8178 FROM per_assignment_extra_info
8179 WHERE assignment_id = p_assignment_id
8180 AND information_type = 'PQP_NL_ABP_OLD_EE_INFO';
8181
8182 l_proc_name VARCHAR2(150) := g_proc_name ||'Record01_Display_Criteria';
8183 l_return_value NUMBER := -1;
8184 l_data_ent NUMBER := 0;
8185
8186 BEGIN
8187
8188 hr_utility.set_location('Entering...'||l_proc_name,10);
8189 --
8190 -- Check if the assignment is attached to a payroll
8191 -- Check if ABP Pensions is processed
8192 --
8193 IF g_abp_processed_flag = 0 THEN
8194 p_data_element_value := 'N';
8195 RETURN 0;
8196 END IF;
8197
8198 --
8199 -- Check if the user has entered the old EE details
8200 -- for this assignment. If the details are not
8201 -- entered, this is a new hire employee and the
8202 -- record does not have to be displayed
8203 --
8204 hr_utility.set_location('....Checking old EE info entry',50);
8205
8206 OPEN c_data_entered;
8207 FETCH c_data_entered INTO l_data_ent;
8208 IF c_data_entered%FOUND THEN
8209 l_data_ent := 1;
8210 hr_utility.set_location('....c_data_entered %FOUND',60);
8211 ELSIF c_data_entered%NOTFOUND THEN
8212 hr_utility.set_location('....c_data_entered %NOTFOUND',70);
8213 l_data_ent := 0;
8214 END IF;
8215 CLOSE c_data_entered;
8216
8217 hr_utility.set_location('....After Checking old EE entry',80);
8218 hr_utility.set_location('....Value of l_data_ent is -- '||l_data_ent,90);
8219
8220 IF NVL(g_extract_params(p_business_group_id).extract_rec_01,'N') = 'Y'
8221 AND l_data_ent = 1 THEN
8222 p_data_element_value := 'Y';
8223 ELSE
8224 p_data_element_value := 'N';
8225 END IF;
8226
8227 hr_utility.set_location('....Value of p_data_element_value is '
8228 ||p_data_element_value,100);
8229 hr_utility.set_location('Leaving: '||l_proc_name,110);
8230
8231 l_return_value := 0;
8232
8233 RETURN l_return_value;
8234
8235 EXCEPTION
8236 WHEN OTHERS THEN
8237 p_error_message :='SQL-ERRM :'||SQLERRM;
8238 p_data_element_value := 'N';
8239 hr_utility.set_location('..WHEN OTHERS EXCEPTION ',120);
8240 hr_utility.set_location('..'||p_error_message,130);
8241 hr_utility.set_location('Leaving: '||l_proc_name,140);
8242 RETURN l_return_value;
8243
8244 END Record01_Display_Criteria;
8245
8246 --============================================================================
8247 -- Record02_Display_Criteria
8248 --============================================================================
8249 FUNCTION Record02_Display_Criteria
8250 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
8251 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
8252 ,p_effective_date IN Date
8253 ,p_error_message OUT NOCOPY Varchar2
8254 ,p_data_element_value OUT NOCOPY Varchar2
8255 ) RETURN Number IS
8256 --
8257 -- Cursor to check if other changes are done like Last Name, Gender etc
8258 --
8259 CURSOR csr_chk_log(c_person_id IN Number
8260 ,c_business_group_id IN Number
8261 ,c_ext_start_date IN Date
8262 ,c_ext_end_date IN Date ) IS
8263 SELECT 'x'
8264 FROM ben_ext_chg_evt_log
8265 WHERE person_id = c_person_id
8266 AND business_group_id = c_business_group_id
8267 AND chg_evt_cd IN ('COLN','COSS','COUN','COG','CODB')
8268 AND fnd_date.canonical_to_date(prmtr_09)
8269 BETWEEN c_ext_start_date AND c_ext_end_date;
8270 --
8271 -- Cursor to fetch the partner's person id
8272 --
8273 CURSOR c_get_partner IS
8274 SELECT contact_person_id
8275 FROM per_contact_relationships
8276 WHERE person_id = g_person_id
8277 AND p_effective_date BETWEEN date_start
8278 AND Nvl(date_end,Hr_Api.g_eot)
8279 AND contact_type IN ('S','D')
8280 AND business_group_id = p_business_group_id;
8281
8282 --
8283 -- Cursor to check if partner last name or prefix has changed
8284 --
8285 CURSOR c_chk_partner_log (c_person_id IN Number) IS
8286 SELECT 'X'
8287 FROM ben_ext_chg_evt_log
8288 WHERE person_id = c_person_id
8289 AND business_group_id = p_business_group_id
8290 AND chg_evt_cd IN ('COUN','COLN','CCFN')
8291 AND fnd_date.canonical_to_date(prmtr_09) BETWEEN g_extract_params(p_business_group_id).extract_start_date
8292 AND g_extract_params(p_business_group_id).extract_end_date;
8293
8294 --
8295 -- Cursor to check if Rec 02 was sent to ABP previously
8296 -- for this assignment. If not sent then trigger a send
8297 --
8298 CURSOR c_rec_02_sent(c_asg_seq_no IN VARCHAR2 ) IS
8299 SELECT 1
8300 FROM ben_ext_rslt_dtl dtl
8301 ,ben_ext_rslt res
8302 ,ben_ext_rcd rcd
8303 ,ben_ext_rcd_in_file rin
8304 ,ben_ext_dfn dfn
8305 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
8306 FROM pqp_extract_attributes
8307 WHERE ext_dfn_type = 'NL_FPR')
8308 AND dtl.person_id = g_person_id
8309 AND ext_stat_cd = 'A'
8310 AND TRUNC(res.eff_dt) <
8311 TRUNC(g_extract_params(p_business_group_id).extract_start_date)
8312 AND rin.ext_file_id = dfn.ext_file_id
8313 AND rin.ext_rcd_id = rcd.ext_rcd_id
8314 AND dfn.ext_dfn_id = res.ext_dfn_id
8315 and dtl.ext_rslt_id = res.ext_rslt_id
8316 AND dtl.ext_rcd_id = rcd.ext_rcd_id
8317 AND dtl.val_04 = c_asg_seq_no
8318 AND rin.seq_num = 3;
8319
8320 l_chg_evt_exists VARCHAR2(2);
8321 l_rows_exist NUMBER := 0;
8322 l_return_value NUMBER := -1;
8323 l_new_hire NUMBER := 0;
8324 l_partner_id per_contact_relationships.contact_person_id%TYPE;
8325 l_proc_name VARCHAR2(150) := g_proc_name ||'Record02_Display_Criteria';
8326 l_hire_dt DATE;
8327 l_chk_hire_dt_chg NUMBER := 0;
8328 l_old_hire_date DATE;
8329 l_new_hire_date DATE;
8330 l_ret_val_asg NUMBER;
8331 l_seq_num VARCHAR2(2);
8332 l_rec_02_sent NUMBER;
8333
8334 BEGIN
8335
8336 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
8337 --
8338 -- Check if the assignment is attached to a payroll
8339 -- Check if ABP Pensions is processed for the asg
8340 --
8341 IF g_abp_processed_flag = 0 THEN
8342 p_data_element_value := 'N';
8343 RETURN 0;
8344 END IF;
8345
8346 --
8347 -- Check if the EE assignment is a new hire and to be reported.
8348 --
8349 l_new_hire := g_new_hire_asg;
8350 l_hire_dt := g_hire_date;
8351
8352 IF l_new_hire = 1 THEN
8353 p_data_element_value := 'Y';
8354 RETURN 0;
8355 ELSE
8356 p_data_element_value := 'N';
8357 END IF;
8358
8359 --
8360 -- Check for other changes to personal data when it is not a new hire
8361 --
8362 OPEN csr_chk_log
8363 (c_person_id => g_person_id
8364 ,c_business_group_id => p_business_group_id
8365 ,c_ext_start_date => g_extract_params(p_business_group_id).extract_start_date
8366 ,c_ext_end_date => g_extract_params(p_business_group_id).extract_end_date);
8367
8368 FETCH csr_chk_log INTO l_Chg_Evt_Exists;
8369
8370 IF csr_chk_log%FOUND THEN
8371 p_data_element_value := 'Y';
8372 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
8373 CLOSE csr_chk_log;
8374 RETURN 0;
8375 ELSE
8376 p_data_element_value := 'N';
8377 CLOSE csr_chk_log;
8378 END IF;
8379
8380 --
8381 -- Check for changes to spouses name
8382 --
8383 OPEN c_get_partner;
8384 FETCH c_get_partner INTO l_partner_id;
8385 IF c_get_partner%FOUND THEN
8386 CLOSE c_get_partner;
8387 OPEN c_chk_partner_log(l_partner_id);
8388 FETCH c_chk_partner_log INTO l_Chg_Evt_Exists;
8389 IF c_chk_partner_log%FOUND THEN
8390 p_data_element_value := 'Y';
8391 CLOSE c_chk_partner_log;
8392 RETURN 0;
8393 ELSE
8394 p_data_element_value := 'N';
8395 CLOSE c_chk_partner_log;
8396 END IF;
8397 ELSE
8398 CLOSE c_get_partner;
8399 p_data_element_value := 'N';
8400 END IF;
8401
8402 l_chk_hire_dt_chg := chk_chg_hire_dt
8403 (p_person_id => g_person_id
8404 ,p_business_group_id => p_business_group_id
8405 ,p_old_hire_date => l_old_hire_date
8406 ,p_new_hire_date => l_new_hire_date );
8407
8408 IF l_chk_hire_dt_chg = 1 THEN
8409
8410 l_ret_val_asg := Get_Asg_Seq_Num(p_assignment_id
8411 ,p_business_group_id
8412 ,p_effective_date
8413 ,p_error_message
8414 ,l_seq_num);
8415 OPEN c_rec_02_sent(l_seq_num);
8416 FETCH c_rec_02_sent INTO l_rec_02_sent;
8417 IF c_rec_02_sent%NOTFOUND THEN
8418 CLOSE c_rec_02_sent ;
8419 p_data_element_value := 'Y';
8420 RETURN 0;
8421 ELSIF c_rec_02_sent%FOUND THEN
8422 CLOSE c_rec_02_sent ;
8423 p_data_element_value := 'N';
8424 END IF;
8425
8426 ELSE
8427 p_data_element_value := 'N';
8428 END IF;
8429
8430 hr_Utility.set_location('Leaving: '||l_proc_name, 5);
8431
8432 l_return_value := 0;
8433 RETURN l_return_value;
8434
8435 EXCEPTION
8436
8437 WHEN OTHERS THEN
8438 p_error_message :='SQL-ERRM :'||SQLERRM;
8439 p_data_element_value := 'N';
8440 Hr_Utility.set_location('..'||p_error_message,85);
8441 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
8442 RETURN l_return_value;
8443
8444 END Record02_Display_Criteria;
8445
8446 --============================================================================
8447 -- Function to derive the display criteria for Record 04
8448 --============================================================================
8449 FUNCTION Record04_Display_Criteria
8450 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
8451 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
8452 ,p_effective_date IN DATE
8453 ,p_error_message OUT NOCOPY VARCHAR2
8454 ,p_data_element_value OUT NOCOPY VARCHAR2)
8455
8456 RETURN NUMBER IS
8457 --
8458 -- Cursor to check if rows exists for change of Marital Status
8459 --
8460 CURSOR csr_chk_log_com (c_person_id IN NUMBER
8461 ,c_business_group_id IN NUMBER
8462 ,c_ext_start_date IN DATE
8463 ,c_ext_end_date IN DATE ) IS
8464 SELECT 'x'
8465 FROM ben_ext_chg_evt_log
8466 WHERE person_id = c_person_id
8467 AND business_group_id = c_business_group_id
8468 AND chg_evt_cd = 'COM'
8469 AND fnd_date.canonical_to_date(prmtr_09)
8470 BETWEEN c_ext_start_date AND c_ext_end_date;
8471 --
8472 -- Cursor to check if the country of residence is a foreign ( non NL ) country
8473 --
8474 CURSOR cur_get_foreign_coun(c_person_id IN Number) IS
8475 SELECT DECODE(country,'NL','N','J')
8476 FROM per_addresses_v
8477 WHERE person_id = c_person_id
8478 AND p_effective_date BETWEEN date_from
8479 AND NVL(date_to,hr_api.g_eot)
8480 AND style IN('NL','NL_GLB')
8481 AND primary_flag = 'Y';
8482
8483 --
8484 -- Cursor to check if Rec 04 was sent to ABP previously
8485 -- for this assignment. If not sent then trigger a send
8486 --
8487 CURSOR c_rec_04_sent(c_asg_seq_no IN VARCHAR2 ) IS
8488 SELECT 1
8489 FROM ben_ext_rslt_dtl dtl
8490 ,ben_ext_rslt res
8491 ,ben_ext_rcd rcd
8492 ,ben_ext_rcd_in_file rin
8493 ,ben_ext_dfn dfn
8494 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
8495 FROM pqp_extract_attributes
8496 WHERE ext_dfn_type = 'NL_FPR')
8497 AND dtl.person_id = g_person_id
8498 AND ext_stat_cd = 'A'
8499 AND TRUNC(res.eff_dt) <
8500 TRUNC(g_extract_params(p_business_group_id).extract_start_date)
8501 AND rin.ext_file_id = dfn.ext_file_id
8502 AND rin.ext_rcd_id = rcd.ext_rcd_id
8503 AND dfn.ext_dfn_id = res.ext_dfn_id
8504 and dtl.ext_rslt_id = res.ext_rslt_id
8505 AND dtl.ext_rcd_id = rcd.ext_rcd_id
8506 AND dtl.val_04 = c_asg_seq_no
8507 AND rin.seq_num = 4;
8508
8509 --
8510 -- Cursor to check of there are address changes to the
8511 -- curent EE address in an Non NL country. If this is
8512 -- true return Y
8513 --
8514 CURSOR c_non_nl_chg (c_person_id IN NUMBER
8515 ,c_business_group_id IN NUMBER
8516 ,c_ext_start_date IN DATE
8517 ,c_ext_end_date IN DATE ) IS
8518 SELECT 1
8519 FROM per_addresses_v padr
8520 WHERE person_id = c_person_id
8521 -- if the current primary address is not in NL
8522 AND p_effective_date BETWEEN date_from AND NVL(date_to,hr_api.g_eot)
8523 AND primary_flag = 'Y'
8524 AND country <> 'NL'
8525 AND EXISTS (SELECT 1
8526 -- exists change in address event logs
8527 -- for the primary address
8528 FROM ben_ext_chg_evt_log log
8529 WHERE padr.person_id = log.person_id
8530 AND chg_evt_cd = 'COPR'
8531 AND padr.address_id = log.prmtr_01
8532 AND fnd_date.canonical_to_date(prmtr_09)
8533 BETWEEN c_ext_start_date AND c_ext_end_date);
8534
8535 --
8536 -- Cursor to check if the address changed from Non NL Country to NL
8537 -- If True return Y
8538 --
8539 CURSOR c_to_nl_chg (c_person_id IN NUMBER
8540 ,c_business_group_id IN NUMBER
8541 ,c_ext_start_date IN DATE
8542 ,c_ext_end_date IN DATE ) IS
8543 SELECT 1
8544 FROM per_addresses_v padr
8545 WHERE person_id = c_person_id
8546 -- if the current primary address is in NL
8547 AND p_effective_date BETWEEN date_from AND NVL(date_to,hr_api.g_eot)
8548 AND primary_flag = 'Y'
8549 AND country = 'NL'
8550 AND EXISTS (SELECT 1
8551 -- exists change in address event logs
8552 -- for the primary address
8553 FROM ben_ext_chg_evt_log log
8554 WHERE padr.person_id = log.person_id
8555 AND chg_evt_cd = 'COPR'
8556 AND padr.address_id = log.prmtr_01
8557 -- there is a change in primary address
8558 AND log.prmtr_02 IS NOT NULL
8559 AND fnd_date.canonical_to_date(prmtr_09)
8560 BETWEEN c_ext_start_date AND c_ext_end_date
8561 AND EXISTS (SELECT 1
8562 FROM per_addresses_v adr
8563 WHERE adr.person_id = log.person_id
8564 AND adr.address_id = to_number(log.prmtr_02)
8565 -- old address was not in NL
8566 AND country <> 'NL'));
8567 --
8568 -- Cursor to check if there is a change in country
8569 -- for the current address. Changes from NL to Non NL and Vice
8570 -- versa must be reported to ABP. If true return Y
8571 --
8572 CURSOR c_cntry_chg (c_person_id IN NUMBER
8573 ,c_business_group_id IN NUMBER
8574 ,c_ext_start_date IN DATE
8575 ,c_ext_end_date IN DATE ) IS
8576 SELECT TO_NUMBER(prmtr_01) addr_id,new_val1 country
8577 FROM ben_ext_chg_evt_log log
8578 WHERE person_id = c_person_id
8579 AND chg_evt_cd = 'COCN'
8580 AND fnd_date.canonical_to_date(prmtr_09)
8581 BETWEEN c_ext_start_date AND c_ext_end_date
8582 ORDER BY ext_chg_evt_log_id DESC;
8583
8584 --
8585 -- Cursor to check if the change of country code is for the current address
8586 --
8587 CURSOR c_get_cc (c_code IN VARCHAR2
8588 ,c_addr_id IN NUMBER) IS
8589 SELECT 1
8590 FROM per_addresses_v padr
8591 WHERE person_id = g_person_id
8592 AND p_effective_date BETWEEN date_from AND NVL(date_to,hr_api.g_eot)
8593 AND address_id = c_addr_id
8594 AND primary_flag = 'Y'
8595 AND country = c_code;
8596
8597 l_cc_code VARCHAR2(2);
8598 l_chg_addr_id NUMBER;
8599 l_cc_changed NUMBER;
8600 l_chg_evt_exists VARCHAR2(2);
8601 l_foreign_country VARCHAR2(1);
8602 l_new_hire NUMBER := 0;
8603 l_rows_exist NUMBER := 0;
8604 l_return_value NUMBER := -1;
8605 l_proc_name VARCHAR2(150) := g_proc_name ||'Record04_Display_Criteria';
8606 l_hire_dt DATE;
8607 l_chk_hire_dt_chg NUMBER := 0;
8608 l_old_hire_date DATE;
8609 l_new_hire_date DATE;
8610 l_ret_val_asg NUMBER;
8611 l_seq_num VARCHAR2(2);
8612 l_rec_04_sent NUMBER;
8613
8614 BEGIN
8615
8616 IF g_debug THEN
8617 Hr_Utility.set_location('Entering: '||l_proc_name,10);
8618 Hr_Utility.set_location('... Checking if EE is a New Hire ',20);
8619 END IF;
8620 --
8621 -- Check if the assignment is attached to a payroll
8622 -- Check if ABP Pensions is processed
8623 --
8624 IF g_abp_processed_flag = 0 THEN
8625 p_data_element_value := 'N';
8626 RETURN 0;
8627 END IF;
8628
8629 --
8630 -- Check if the EE assignment is a new hire and needs to be reported.
8631 --
8632 l_new_hire := g_new_hire_asg;
8633 l_hire_dt := g_hire_date;
8634
8635 IF l_new_hire = 1 THEN
8636 p_data_element_value := 'Y';
8637 IF g_debug THEN
8638 Hr_Utility.set_location('... EE is a New Hire ',30);
8639 END IF;
8640 RETURN 0;
8641 ELSE
8642 p_data_element_value := 'N';
8643 IF g_debug THEN
8644 Hr_Utility.set_location('... EE is not a New Hire ',40);
8645 END IF;
8646 END IF;
8647
8648 --
8649 --Checking the ben event log for any foreign address changes
8650 --
8651 IF g_debug THEN
8652 Hr_Utility.set_location('... Checking for Foreign Address Changes ',50);
8653 END IF;
8654
8655 OPEN c_non_nl_chg
8656 (c_person_id => g_person_id
8657 ,c_business_group_id => p_business_group_id
8658 ,c_ext_start_date => g_extract_params(p_business_group_id).extract_start_date
8659 ,c_ext_end_date => g_extract_params(p_business_group_id).extract_end_date);
8660
8661 FETCH c_non_nl_chg INTO l_chg_evt_exists;
8662
8663 IF c_non_nl_chg%FOUND THEN
8664 p_data_element_value := 'Y';
8665 IF g_debug THEN
8666 Hr_Utility.set_location('...Foreign Address Changes Found',60);
8667 END IF;
8668 CLOSE c_non_nl_chg;
8669 RETURN 0;
8670 ELSE
8671 p_data_element_value := 'N';
8672 IF g_debug THEN
8673 Hr_Utility.set_location('...Foreign Address Changes Not Found',70);
8674 END IF;
8675 CLOSE c_non_nl_chg;
8676 END IF;
8677
8678
8679 --
8680 --Checking the ben event log for any changes from Foreign Country to NL
8681 --
8682 IF g_debug THEN
8683 Hr_Utility.set_location('... Checking for Changes from a foreign Country to NL ',50);
8684 END IF;
8685
8686 OPEN c_to_nl_chg
8687 (c_person_id => g_person_id
8688 ,c_business_group_id => p_business_group_id
8689 ,c_ext_start_date => g_extract_params(p_business_group_id).extract_start_date
8690 ,c_ext_end_date => g_extract_params(p_business_group_id).extract_end_date);
8691
8692 FETCH c_to_nl_chg INTO l_chg_evt_exists;
8693
8694 IF c_to_nl_chg%FOUND THEN
8695 p_data_element_value := 'Y';
8696 IF g_debug THEN
8697 Hr_Utility.set_location('...EE Moved to NL',60);
8698 END IF;
8699 CLOSE c_to_nl_chg;
8700 RETURN 0;
8701 ELSE
8702 p_data_element_value := 'N';
8703 IF g_debug THEN
8704 Hr_Utility.set_location('...EE Did not move to NL',70);
8705 END IF;
8706 CLOSE c_to_nl_chg;
8707 END IF;
8708
8709 IF g_debug THEN
8710 Hr_Utility.set_location('... Checking for Country Code Changes ',50);
8711 END IF;
8712
8713 OPEN c_cntry_chg
8714 (c_person_id => g_person_id
8715 ,c_business_group_id => p_business_group_id
8716 ,c_ext_start_date => g_extract_params(p_business_group_id).extract_start_date
8717 ,c_ext_end_date => g_extract_params(p_business_group_id).extract_end_date);
8718
8719 FETCH c_cntry_chg INTO l_chg_addr_id,l_cc_code;
8720
8721 IF c_cntry_chg%FOUND THEN
8722 IF g_debug THEN
8723 Hr_Utility.set_location('...Country Code Changes Found',60);
8724 END IF;
8725 CLOSE c_cntry_chg;
8726 --
8727 -- Check if the change was made for the current address
8728 --
8729 OPEN c_get_cc (l_cc_code,l_chg_addr_id);
8730 FETCH c_get_cc INTO l_cc_changed;
8731 IF c_get_cc%FOUND THEN
8732 p_data_element_value := 'Y';
8733 CLOSE c_get_cc;
8734 RETURN 0;
8735 ELSE
8736 p_data_element_value := 'N';
8737 CLOSE c_get_cc;
8738 END IF;
8739 ELSE
8740 p_data_element_value := 'N';
8741 IF g_debug THEN
8742 Hr_Utility.set_location('...Country Code Changes Not Found',70);
8743 END IF;
8744 CLOSE c_cntry_chg;
8745 END IF;
8746
8747 --
8748 -- Checking the ben event log for marital status changes
8749 -- Marital status changes are to be reported only if the EE resides
8750 -- in a foreign country
8751 --
8752 IF g_debug THEN
8753 Hr_Utility.set_location('... Checking for Marital Status Changes ',90);
8754 END IF;
8755
8756 OPEN cur_get_foreign_coun(g_person_id);
8757 FETCH cur_get_foreign_coun INTO l_foreign_country;
8758 CLOSE cur_get_foreign_coun;
8759
8760 IF g_debug THEN
8761 Hr_Utility.set_location('...Value of l_foreign_country is ',80);
8762 END IF;
8763
8764 OPEN csr_chk_log_com
8765 (c_person_id => g_person_id
8766 ,c_business_group_id => p_business_group_id
8767 ,c_ext_start_date => g_extract_params(p_business_group_id).extract_start_date
8768 ,c_ext_end_date => g_extract_params(p_business_group_id).extract_end_date);
8769
8770 FETCH csr_chk_log_com INTO l_Chg_Evt_Exists;
8771
8772 IF csr_chk_log_com%FOUND AND l_foreign_country = 'J' THEN
8773 p_data_element_value := 'Y';
8774 IF g_debug THEN
8775 Hr_Utility.set_location('...Marital Status Changes Found',100);
8776 Hr_Utility.set_location('...EE Resides in a Foreign Country',100);
8777 END IF;
8778 CLOSE csr_chk_log_com;
8779 RETURN 0;
8780 ELSE
8781 p_data_element_value := 'N';
8782 IF g_debug THEN
8783 Hr_Utility.set_location('...Marital Status Changes Not Found',110);
8784 Hr_Utility.set_location('...Alternatively EE Resides in NL',110);
8785 END IF;
8786 CLOSE csr_chk_log_com;
8787 END IF;
8788
8789 --
8790 -- Check to see if the EE is a late hire and if Record 04
8791 -- has never been reported to ABP earlier.
8792 -- in such cases the Record has to be sent to ABP as this is the
8793 -- first time the EE is picked up for reporting.
8794 --
8795 l_chk_hire_dt_chg := chk_chg_hire_dt
8796 (p_person_id => g_person_id
8797 ,p_business_group_id => p_business_group_id
8798 ,p_old_hire_date => l_old_hire_date
8799 ,p_new_hire_date => l_new_hire_date );
8800
8801 IF l_chk_hire_dt_chg = 1 THEN
8802
8803 IF g_debug THEN
8804 Hr_Utility.set_location('...EE is a late Hire ',120);
8805 END IF;
8806
8807 l_ret_val_asg := Get_Asg_Seq_Num(p_assignment_id
8808 ,p_business_group_id
8809 ,p_effective_date
8810 ,p_error_message
8811 ,l_seq_num);
8812 OPEN c_rec_04_sent(l_seq_num);
8813 FETCH c_rec_04_sent INTO l_rec_04_sent;
8814 IF c_rec_04_sent%NOTFOUND THEN
8815 CLOSE c_rec_04_sent ;
8816 p_data_element_value := 'Y';
8817 IF g_debug THEN
8818 Hr_Utility.set_location('...EE Record 04 never sent to ABP ',130);
8819 END IF;
8820 RETURN 0;
8821 ELSIF c_rec_04_sent%FOUND THEN
8822 CLOSE c_rec_04_sent ;
8823 IF g_debug THEN
8824 Hr_Utility.set_location('...EE Record 04 sent to ABP earlier',140);
8825 END IF;
8826 p_data_element_value := 'N';
8827 END IF;
8828
8829 ELSE
8830 IF g_debug THEN
8831 Hr_Utility.set_location('...EE is a not a late Hire ',150);
8832 END IF;
8833 p_data_element_value := 'N';
8834 END IF;
8835
8836 IF g_debug THEN
8837 Hr_Utility.set_location('... Value of p_data_element_value is '
8838 ||p_data_element_value,160);
8839 Hr_Utility.set_location('Leaving: '||l_proc_name, 170);
8840 END IF;
8841
8842 l_return_value := 0;
8843
8844 RETURN l_return_value;
8845
8846 EXCEPTION
8847 WHEN OTHERS THEN
8848 p_error_message :='SQL-ERRM :'||SQLERRM;
8849 p_data_element_value := 'N';
8850 Hr_Utility.set_location('... WHEN OTHERS EXCEPTION',180);
8851 Hr_Utility.set_location('..'||p_error_message,190);
8852 Hr_Utility.set_location('Leaving: '||l_proc_name,200);
8853 RETURN l_return_value;
8854 END Record04_Display_Criteria;
8855
8856 --============================================================================
8857 -- Function to derive the display criteria for Record 08
8858 --============================================================================
8859 FUNCTION Record08_Display_Criteria
8860 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
8861 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
8862 ,p_effective_date IN DATE
8863 ,p_error_message OUT NOCOPY VARCHAR2
8864 ,p_data_element_value OUT NOCOPY VARCHAR2)
8865 RETURN NUMBER IS
8866
8867 --
8868 -- Cursor to check if there are any changes in the ABP Pension Salary
8869 --
8870 CURSOR c_get_override_salary IS
8871 SELECT fnd_number.canonical_to_number(nvl(new_val1,'0'))
8872 FROM ben_ext_chg_evt_log
8873 WHERE person_id = g_person_id
8874 AND fnd_number.canonical_to_number(prmtr_01) = p_assignment_id
8875 AND chg_eff_dt BETWEEN g_extract_params(p_business_group_id).extract_start_date
8876 AND g_extract_params(p_business_group_id).extract_end_date
8877 AND chg_evt_cd = 'COAPS'
8878 AND ext_chg_evt_log_id =
8879 (SELECT MAX(ext_chg_evt_log_id)
8880 FROM ben_ext_chg_evt_log
8881 WHERE person_id = g_person_id
8882 AND fnd_number.canonical_to_number(prmtr_01) = p_assignment_id
8883 AND chg_eff_dt BETWEEN g_extract_params(p_business_group_id).extract_start_date
8884 AND g_extract_params(p_business_group_id).extract_end_date
8885 AND chg_evt_cd = 'COAPS');
8886
8887 --
8888 -- Cursor to fetch the month for the effective date
8889 --
8890 CURSOR c_get_month IS
8891 SELECT TO_CHAR(p_effective_date,'MM')
8892 FROM dual;
8893 --
8894 -- Cursor to check if Rec 08 was sent to ABP in the current year.
8895 -- fot this assignment . If not sent then trigger a send
8896 --
8897 CURSOR c_rec_08_sent(c_start_of_yr IN DATE
8898 ,c_asg_seq_no IN VARCHAR2 ) IS
8899 SELECT 1
8900 FROM ben_ext_rslt_dtl dtl
8901 ,ben_ext_rslt res
8902 ,ben_ext_rcd rcd
8903 ,ben_ext_rcd_in_file rin
8904 ,ben_ext_dfn dfn
8905 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
8906 FROM pqp_extract_attributes
8907 WHERE ext_dfn_type = 'NL_FPR')
8908 and dtl.person_id = g_person_id
8909 and ext_stat_cd = 'A'
8910 AND TRUNC(res.eff_dt) BETWEEN c_start_of_yr
8911 AND TRUNC(g_extract_params(p_business_group_id).extract_start_date) - 1
8912 AND rin.ext_file_id = dfn.ext_file_id
8913 AND rin.ext_rcd_id = rcd.ext_rcd_id
8914 AND dfn.ext_dfn_id = res.ext_dfn_id
8915 and dtl.ext_rslt_id = res.ext_rslt_id
8916 AND dtl.ext_rcd_id = rcd.ext_rcd_id
8917 AND dtl.val_04 = c_asg_seq_no
8918 AND rin.seq_num = 7;
8919
8920 l_override_exists NUMBER;
8921 l_month VARCHAR2(2);
8922 l_chg_evt_exists VARCHAR2(2);
8923 l_return_value NUMBER := -1;
8924 l_new_hire NUMBER := 0;
8925 l_balance_amount NUMBER := 0;
8926 l_override_value NUMBER := 0;
8927 l_person_id per_all_people_f.person_id%TYPE;
8928 l_asg_action_id pay_assignment_actions.assignment_action_id%TYPE;
8929 l_balance_id pay_balance_types.balance_type_id%TYPE;
8930 l_proc_name VARCHAR2(150) := g_proc_name ||'Record08_Display_Criteria';
8931 l_hire_dt DATE;
8932 l_08_sent NUMBER;
8933 l_ret_val_asg NUMBER;
8934 l_seq_num VARCHAR2(2);
8935
8936 BEGIN
8937
8938 Hr_Utility.set_location('Entering: '||l_proc_name,10);
8939
8940 --
8941 -- Check if the assignment is attached to a payroll
8942 -- Check if ABP Pensions is processed
8943 --
8944 IF g_abp_processed_flag = 0 THEN
8945 p_data_element_value := 'N';
8946 RETURN 0;
8947 END IF;
8948
8949 --
8950 -- Check if the EE assignment is terminated in the prev year.
8951 -- do not display Record 08 in that case.
8952 --
8953 IF chk_asg_term_py (p_assignment_id => p_assignment_id
8954 ,p_ext_st => g_extract_params(p_business_group_id).extract_start_date) THEN
8955 p_data_element_value := 'N';
8956 RETURN 0;
8957 END IF;
8958
8959 Hr_Utility.set_location('...Deriving def bal id ',20);
8960
8961 OPEN csr_defined_bal('ABP Pension Salary'
8962 ,'Assignment Year To Date'
8963 ,p_business_group_id);
8964 FETCH csr_defined_bal INTO l_balance_id;
8965 CLOSE csr_defined_bal;
8966
8967 Hr_Utility.set_location('... Value of def bal id is'||l_balance_id,30);
8968 Hr_Utility.set_location('...Deriving ass act id ',40);
8969
8970 IF l_balance_id IS NOT NULL THEN
8971
8972 OPEN csr_asg_act1 (
8973 c_assignment_id => p_assignment_id
8974 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
8975 ,c_con_set_id => NULL
8976 ,c_start_date => g_extract_params(p_business_group_id).extract_start_date
8977 ,c_end_date => g_extract_params(p_business_group_id).extract_end_date);
8978 FETCH csr_asg_act1 INTO l_asg_action_id;
8979 Hr_Utility.set_location('... Value of ass act id is'||l_asg_action_id,45);
8980 CLOSE csr_asg_act1;
8981
8982 IF l_asg_action_id IS NOT NULL THEN
8983 Hr_Utility.set_location('...Deriving balance value ',50);
8984 l_balance_amount := pay_balance_pkg.get_value
8985 (p_defined_balance_id => l_balance_id
8986 ,p_assignment_action_id => l_asg_action_id);
8987 Hr_Utility.set_location('...Value of l_balance_amount is:'
8988 ||l_balance_amount, 25);
8989 l_balance_amount := NVL(l_balance_amount,0);
8990 END IF;
8991
8992 END IF;
8993
8994 Hr_Utility.set_location('...Checking of Ext is running for Jan ',60);
8995 --
8996 -- Check to see if the extract is being run for JAN,
8997 -- If it is JAN, we need to report the pension salary
8998 --
8999 OPEN c_get_month;
9000 FETCH c_get_month INTO l_month;
9001 CLOSE c_get_month;
9002
9003 IF l_month = '01' AND NVL(l_balance_amount,0) <> 0 THEN
9004 Hr_Utility.set_location('...Ext is running for Jan ',70);
9005 p_data_element_value := 'Y';
9006 RETURN 0;
9007 ELSE
9008 Hr_Utility.set_location('...Ext is not running for Jan ',80);
9009 p_data_element_value := 'N';
9010 END IF;
9011
9012 --
9013 -- Fetch the overridden value if there is any override changes in
9014 -- the ASG EIT
9015 --
9016 Hr_Utility.set_location('...Checking for ABP Pension Salary Override ',90);
9017
9018 OPEN c_get_override_salary;
9019 FETCH c_get_override_salary INTO l_override_value;
9020 IF c_get_override_salary%FOUND THEN
9021 CLOSE c_get_override_salary;
9022 IF nvl(l_override_value,0) <> 0 THEN
9023 p_data_element_value := 'Y';
9024 Hr_Utility.set_location('...ABP Pension Salary Override Found ',100);
9025 RETURN 0;
9026 ELSE
9027 Hr_Utility.set_location('...ABP Pension Salary Override Not Found ',110);
9028 p_data_element_value := 'N';
9029 END IF;
9030 ELSE
9031 CLOSE c_get_override_salary;
9032 END IF;
9033
9034 --
9035 -- Check if the EE assignment is a new hire and needs to be reported.
9036 --
9037 Hr_Utility.set_location('... Checking if EE is a New Hire ',20);
9038
9039 l_new_hire := g_new_hire_asg;
9040 l_hire_dt := g_hire_date;
9041
9042 IF l_new_hire = 1 AND NVL(l_balance_amount,0) <> 0 THEN
9043 p_data_element_value := 'Y';
9044 Hr_Utility.set_location('... EE is a New Hire ',120);
9045 RETURN 0;
9046 ELSE
9047 p_data_element_value := 'N';
9048 Hr_Utility.set_location('... EE is not a New Hire ',130);
9049 END IF;
9050
9051 l_ret_val_asg := Get_Asg_Seq_Num(p_assignment_id
9052 ,p_business_group_id
9053 ,p_effective_date
9054 ,p_error_message
9055 ,l_seq_num);
9056
9057
9058 OPEN c_rec_08_sent( to_date('01/01/'||to_char(p_effective_date,'YYYY'),'DD/MM/YYYY')
9059 ,l_seq_num);
9060 FETCH c_rec_08_sent INTO l_08_sent;
9061 IF c_rec_08_sent%NOTFOUND AND NVL(l_balance_amount,0) <> 0 THEN
9062 p_data_element_value := 'Y';
9063 Hr_Utility.set_location('... Data never sent ',120);
9064 CLOSE c_rec_08_sent;
9065 RETURN 0;
9066 ELSE
9067 CLOSE c_rec_08_sent;
9068 p_data_element_value := 'N';
9069 Hr_Utility.set_location('... Data Was sent ',130);
9070 END IF;
9071
9072 hr_utility.set_location('Leaving: '||l_proc_name,140);
9073 l_return_value := 0;
9074
9075 RETURN l_return_value;
9076
9077 EXCEPTION
9078 WHEN OTHERS THEN
9079 p_error_message :='SQL-ERRM :'||SQLERRM;
9080 p_data_element_value := 'N';
9081 Hr_Utility.set_location('...WHEN OTHERS EXCEPTION',150);
9082 Hr_Utility.set_location('..'||p_error_message,160);
9083 Hr_Utility.set_location('Leaving: '||l_proc_name,170);
9084 RETURN l_return_value;
9085 END Record08_Display_Criteria;
9086
9087 --=============================================================================
9088 -- Function to derive the display criteria for Record 09
9089 --=============================================================================
9090 FUNCTION Record09_Display_Criteria
9091 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
9092 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
9093 ,p_effective_date IN DATE
9094 ,p_error_message OUT NOCOPY VARCHAR2
9095 ,p_data_element_value OUT NOCOPY VARCHAR2)
9096 RETURN NUMBER IS
9097
9098 l_proc_name VARCHAR2(150) := g_proc_name ||'Record09_Display_Criteria';
9099
9100 BEGIN
9101
9102 Hr_Utility.set_location('Entering: '||l_proc_name,10);
9103 --
9104 -- Derive the value of Record 09 display criteria based on the
9105 -- value set to the global variable in full profile criteria
9106 --
9107 IF l_rec_09_disp = 'Y' THEN
9108 p_data_element_value := 'Y';
9109 ELSE
9110 p_data_element_value := 'N';
9111 END IF;
9112
9113 Hr_Utility.set_location('Value of p_data_element_value is : '
9114 ||p_data_element_value,20);
9115 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
9116
9117 RETURN 0;
9118
9119 END Record09_Display_Criteria;
9120
9121 --=============================================================================
9122 -- Function to check if Record12 needs to be displayed
9123 --=============================================================================
9124 FUNCTION Record12_Display_Criteria
9125 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
9126 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
9127 ,p_effective_date IN DATE
9128 ,p_error_message OUT NOCOPY VARCHAR2
9129 ,p_data_element_value OUT NOCOPY VARCHAR2)
9130 RETURN NUMBER IS
9131
9132 l_proc_name VARCHAR2(150) := g_proc_name ||'Record12_Display_Criteria';
9133
9134 BEGIN
9135 Hr_Utility.set_location('Entering : '||l_proc_name,10);
9136 --
9137 -- Derive the value of Record 12 display criteria based on the
9138 -- value set to the global variable in full profile criteria
9139 --
9140 IF l_rec_12_disp = 'Y' THEN
9141 p_data_element_value := 'Y';
9142 ELSE
9143 p_data_element_value := 'N';
9144 END IF;
9145
9146 Hr_Utility.set_location('Value of p_data_element_value is: '
9147 ||p_data_element_value,20);
9148 Hr_Utility.set_location('Leaving: '||l_proc_name,30);
9149
9150 RETURN 0;
9151
9152 END Record12_Display_Criteria;
9153
9154 --=============================================================================
9155 -- Function to derive the display criteria for Record 20
9156 --=============================================================================
9157 FUNCTION Record20_Display_Criteria
9158 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
9159 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
9160 ,p_effective_date IN DATE
9161 ,p_error_message OUT NOCOPY VARCHAR2
9162 ,p_data_element_value OUT NOCOPY VARCHAR2)
9163 RETURN NUMBER IS
9164
9165 BEGIN
9166
9167 --
9168 -- All SI records are obselete and are not reported to ABP
9169 -- so there is no need to display them
9170 --
9171 p_data_element_value := 'N';
9172
9173 RETURN 0;
9174
9175 END Record20_Display_Criteria;
9176
9177 --============================================================================
9178 -- Function to derive the display criteria for Record 21
9179 --============================================================================
9180 FUNCTION Record21_Display_Criteria
9181 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
9182 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
9183 ,p_effective_date IN DATE
9184 ,p_error_message OUT NOCOPY VARCHAR2
9185 ,p_data_element_value OUT NOCOPY VARCHAR2)
9186 RETURN NUMBER IS
9187
9188 BEGIN
9189 --
9190 -- All SI records are obselete and are not reported to ABP
9191 -- so there is no need to display them
9192 --
9193
9194 p_data_element_value := 'N';
9195
9196 RETURN 0;
9197
9198 END Record21_Display_Criteria;
9199
9200 --============================================================================
9201 -- Function to derive the display criteria for Record 22
9202 --============================================================================
9203 FUNCTION Record22_Display_Criteria
9204 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
9205 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
9206 ,p_effective_date IN DATE
9207 ,p_error_message OUT NOCOPY VARCHAR2
9208 ,p_data_element_value OUT NOCOPY VARCHAR2)
9209 RETURN NUMBER IS
9210
9211 BEGIN
9212 --
9213 -- The SI records are obselete and are not reported to ABP
9214 -- so there is no need to display them
9215 --
9216
9217 p_data_element_value := 'N';
9218
9219 RETURN 0;
9220
9221 END Record22_Display_Criteria;
9222
9223 --============================================================================
9224 -- Function to derive the display criteria for Record 05
9225 --============================================================================
9226 FUNCTION Record05_Display_Criteria
9227 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
9228 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
9229 ,p_effective_date IN DATE
9230 ,p_error_message OUT NOCOPY VARCHAR2
9231 ,p_data_element_value OUT NOCOPY VARCHAR2)
9232 RETURN NUMBER IS
9233
9234 l_return_value NUMBER := 0;
9235 l_proc_name VARCHAR2(150) := 'Record05_Display_Criteria';
9236
9237 BEGIN
9238
9239 Hr_Utility.set_location('Entering: '||l_proc_name, 10);
9240
9241 --
9242 -- Always display record 05 as this causes issues with the
9243 -- secondary assignments. Unnecessary records are later deleted as part of
9244 -- the extract post process
9245 --
9246
9247 p_data_element_value := 'Y';
9248
9249 Hr_Utility.set_location('... The data element value is : '
9250 ||p_data_element_value,20);
9251
9252 Hr_Utility.set_location('Leaving: '||l_proc_name, 30);
9253
9254 l_return_value := 0;
9255
9256 RETURN l_return_value;
9257
9258 EXCEPTION
9259 WHEN OTHERS THEN
9260 p_error_message :='SQL-ERRM :'||SQLERRM;
9261 Hr_Utility.set_location('...WHEN OTHERS EXCEPTION',40);
9262 p_data_element_value := 'N';
9263 Hr_Utility.set_location('...'||p_error_message,50);
9264 Hr_Utility.set_location('Leaving: '||l_proc_name,60);
9265 l_return_value := 1;
9266 RETURN l_return_value;
9267
9268 END Record05_Display_Criteria;
9269
9270 --============================================================================
9271 --This is used to decide the Record40_30 hide or show
9272 --============================================================================
9273 FUNCTION Record30_40_Display_Criteria
9274 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
9275 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
9276 ,p_effective_date IN Date
9277 ,p_sub_cat IN Varchar2
9278 ,p_error_message OUT NOCOPY Varchar2
9279 ,p_data_element_value OUT NOCOPY Varchar2
9280 ) RETURN Number IS
9281
9282 --cursor to check if ASG EIT rows exist
9283 CURSOR c_asg_rows_exist IS
9284 SELECT 1
9285 FROM ben_ext_chg_evt_log bec,pqp_pension_types_f pty
9286 WHERE chg_evt_cd = 'COAPPD'
9287 AND prmtr_01 = 'ASG'
9288 AND Fnd_Number.canonical_to_number(prmtr_02) = pty.pension_type_id
9289 AND pty.pension_sub_category = p_sub_cat
9290 AND prmtr_03 = 'Y'
9291 AND Fnd_Number.canonical_to_number(prmtr_10) = p_assignment_id
9292 AND person_id = (SELECT person_id
9293 FROM per_all_assignments_f
9294 WHERE assignment_id = p_assignment_id
9295 AND p_effective_date BETWEEN effective_start_date
9296 AND effective_end_date
9297 )
9298 AND bec.business_group_id = p_business_group_id;
9299
9300 --cursor to check if ORG EIT rows exist
9301 CURSOR c_org_rows_exist(c_org_id IN Number) IS
9302 SELECT 1
9303 FROM ben_ext_chg_evt_log bec,pqp_pension_types_f pty
9304 WHERE chg_evt_cd = 'COAPPD'
9305 AND prmtr_01 = 'ORG'
9306 AND Fnd_Number.canonical_to_number(prmtr_02) = pty.pension_type_id
9307 AND pty.pension_sub_category = p_sub_cat
9308 AND prmtr_03 = 'Y'
9309 AND Fnd_Number.canonical_to_number(prmtr_04) = c_org_id
9310 AND bec.business_group_id = p_business_group_id;
9311
9312 --cursor to get the ASG EIT log rows
9313 CURSOR c_get_asg_rows IS
9314 SELECT 1
9315 FROM ben_ext_chg_evt_log bec,pqp_pension_types_f pty
9316 WHERE chg_evt_cd = 'COAPPD'
9317 AND prmtr_01 = 'ASG'
9318 AND Fnd_Number.canonical_to_number(prmtr_02) = pty.pension_type_id
9319 AND prmtr_03 = 'Y'
9320 AND Fnd_Number.canonical_to_number(prmtr_10) = p_assignment_id
9321 AND pty.pension_sub_category = p_sub_cat
9322 AND person_id = (SELECT person_id
9323 FROM per_all_assignments_f
9324 WHERE assignment_id = p_assignment_id
9325 AND p_effective_date BETWEEN effective_start_date
9326 AND effective_end_date
9327 )
9328 AND bec.business_group_id = p_business_group_id
9329 AND chg_eff_dt BETWEEN g_extract_params(p_business_group_id).extract_start_date
9330 AND g_extract_params(p_business_group_id).extract_end_date
9331 ORDER BY ext_chg_evt_log_id;
9332
9333 --cursor to get the ORG EIT log rows
9334 CURSOR c_get_org_rows(c_org_id IN Number,c_hire_date IN Date) IS
9335 SELECT 1
9336 FROM ben_ext_chg_evt_log bec,pqp_pension_types_f pty
9337 WHERE chg_evt_cd = 'COAPPD'
9338 AND prmtr_01 = 'ORG'
9339 AND Fnd_Number.canonical_to_number(prmtr_02) = pty.pension_type_id
9340 AND prmtr_03 = 'Y'
9341 AND pty.pension_sub_category = p_sub_cat
9342 AND Fnd_Number.canonical_to_number(prmtr_04) = c_org_id
9343 AND bec.business_group_id = p_business_group_id
9344 AND chg_eff_dt BETWEEN g_extract_params(p_business_group_id).extract_start_date
9345 AND g_extract_params(p_business_group_id).extract_end_date
9346 AND chg_eff_dt >= c_hire_date
9347 ORDER BY ext_chg_evt_log_id;
9348
9349 --Cursor to find the named hierarchy associated with the BG
9350 CURSOR c_find_named_hierarchy IS
9351 SELECT org_information1
9352 FROM hr_organization_information
9353 WHERE organization_id = p_business_group_id
9354 AND org_information_context = 'NL_BG_INFO';
9355
9356 --Cursor to find the valid version id for the particular named hierarchy
9357 CURSOR c_find_ver_frm_hierarchy(c_hierarchy_id IN Number) IS
9358 SELECT ORG_STRUCTURE_VERSION_ID
9359 FROM per_org_structure_versions_v
9360 WHERE organization_structure_id = c_hierarchy_id
9361 AND p_effective_date BETWEEN date_from
9362 AND Nvl(date_to,Hr_Api.g_eot);
9363
9364 --Cursor to find the valid version id for a particular business group
9365 CURSOR c_find_ver_frm_bg IS
9366 SELECT ORG_STRUCTURE_VERSION_ID
9367 FROM per_org_structure_versions_v
9368 WHERE business_group_id = p_business_group_id
9369 AND p_effective_date BETWEEN date_from
9370 AND Nvl( date_to,Hr_Api.g_eot);
9371
9372 --Cursor to find the parent id from the org id
9373 CURSOR c_find_parent_id(c_org_id IN Number
9374 ,c_version_id IN Number) IS
9375 SELECT organization_id_parent
9376 FROM per_org_structure_elements
9377 WHERE organization_id_child = c_org_id
9378 AND org_structure_version_id = c_version_id
9379 AND business_group_id = p_business_group_id;
9380
9381 --cursor to find the org id for the current asg
9382 CURSOR c_find_org_id IS
9383 SELECT organization_id
9384 FROM per_all_assignments_f
9385 WHERE assignment_id = p_assignment_id
9386 AND p_effective_date BETWEEN effective_start_date
9387 AND effective_end_date;
9388
9389 -- Cursor to get the hire date of the person
9390 CURSOR c_hire_dt IS
9391 SELECT max(date_start)
9392 FROM per_all_assignments_f asg
9393 ,per_periods_of_service pps
9394 WHERE pps.person_id = asg.person_id
9395 AND asg.assignment_id = p_assignment_id
9396 AND pps.business_group_id = p_business_group_id
9397 AND date_start <= p_effective_date;
9398
9399 --cursor to check if run results exist for any FUR/IPAP Pension Types for this assignment
9400 CURSOR c_run_results_exist IS
9401 SELECT pty.pension_type_id
9402 FROM pay_run_results prr,
9403 pay_payroll_actions ppa,
9404 pay_assignment_actions paa,
9405 pay_element_type_extra_info pei,
9406 pqp_pension_types_f pty
9407 WHERE paa.assignment_action_id = prr.assignment_action_id
9408 AND paa.payroll_action_id = ppa.payroll_action_id
9409 AND ppa.date_earned BETWEEN g_extract_params(p_business_group_id).extract_start_date
9410 AND g_extract_params(p_business_group_id).extract_end_date
9411 AND paa.assignment_id = p_assignment_id
9412 AND pei.element_type_id = prr.element_type_id
9413 AND pei.information_type = 'PQP_NL_ABP_DEDUCTION'
9414 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
9415 AND pei.eei_information2 = Fnd_Number.number_to_canonical(pty.pension_type_id)
9416 AND pty.pension_sub_category = p_sub_cat;
9417
9418
9419 l_proc_name Varchar2(150) := 'Record40_30_Disp_Criteria';
9420 l_return_value Number := -1;
9421 l_named_hierarchy Number;
9422 l_version_id per_org_structure_versions_v.org_structure_version_id%TYPE DEFAULT NULL;
9423 l_rows_exist Number := 0;
9424 l_asg_rows_exist Number;
9425 l_org_rows_exist Number;
9426 l_org_id Number;
9427 l_loop_again Number;
9428 l_age Number;
9429 l_hire_date Date;
9430 l_pt Number;
9431 l_hired Number := 0;
9432
9433 BEGIN
9434 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
9435 Hr_Utility.set_location('sub category : '||p_sub_cat,10);
9436
9437 OPEN c_hire_dt;
9438 FETCH c_hire_dt INTO l_hire_date;
9439 CLOSE c_hire_dt;
9440 IF l_hire_date BETWEEN g_extract_params(p_business_group_id).extract_start_date
9441 AND g_extract_params(p_business_group_id).extract_end_date THEN
9442 l_hired := 1;
9443 END IF;
9444
9445 OPEN c_asg_rows_exist;
9446 FETCH c_asg_rows_exist INTO l_asg_rows_exist;
9447 IF c_asg_rows_exist%FOUND THEN
9448 CLOSE c_asg_rows_exist;
9449 Hr_Utility.set_location('found rows at the assignment eit level',15);
9450 OPEN c_get_asg_rows;
9451 FETCH c_get_asg_rows INTO l_rows_exist;
9452 CLOSE c_get_asg_rows;
9453 ELSE
9454 CLOSE c_asg_rows_exist;
9455 --go up the org hierarchy to find the rows at some org eit level
9456 -- find the org the assignment is attached to
9457 OPEN c_find_org_id;
9458 FETCH c_find_org_id INTO l_org_id;
9459 CLOSE c_find_org_id;
9460
9461 --first chk to see if a named hierarchy exists for the BG
9462 OPEN c_find_named_hierarchy;
9463 FETCH c_find_named_hierarchy INTO l_named_hierarchy;
9464 -- if a named hiearchy is found , find the valid version on that date
9465 IF c_find_named_hierarchy%FOUND THEN
9466 CLOSE c_find_named_hierarchy;
9467 -- now find the valid version on that date
9468 OPEN c_find_ver_frm_hierarchy(l_named_hierarchy);
9469 FETCH c_find_ver_frm_hierarchy INTO l_version_id;
9470 --if no valid version is found, try to get it frm the BG
9471 IF c_find_ver_frm_hierarchy%NOTFOUND THEN
9472 CLOSE c_find_ver_frm_hierarchy;
9473 -- find the valid version id from the BG
9474 OPEN c_find_ver_frm_bg;
9475 FETCH c_find_ver_frm_bg INTO l_version_id;
9476 CLOSE c_find_ver_frm_bg;
9477 -- else a valid version has been found for the named hierarchy
9478 ELSE
9479 CLOSE c_find_ver_frm_hierarchy;
9480 END IF; --end of if no valid version found
9481 -- else find the valid version from BG
9482 ELSE
9483 CLOSE c_find_named_hierarchy;
9484 --now find the version number from the BG
9485 OPEN c_find_ver_frm_bg;
9486 FETCH c_find_ver_frm_bg INTO l_version_id;
9487 CLOSE c_find_ver_frm_bg;
9488 END IF; -- end of if named hierarchy found
9489
9490 -- loop through the org hierarchy to find the participation start date at
9491 -- this org level or its parents
9492 l_loop_again := 1;
9493 WHILE (l_loop_again = 1)
9494
9495 LOOP
9496 Hr_Utility.set_location('searching at org level : '||l_org_id,25);
9497 OPEN c_org_rows_exist(l_org_id);
9498 FETCH c_org_rows_exist INTO l_org_rows_exist;
9499 IF c_org_rows_exist%FOUND THEN
9500 CLOSE c_org_rows_exist;
9501 OPEN c_get_org_rows(l_org_id,l_hire_date);
9502 FETCH c_get_org_rows INTO l_rows_exist;
9503 CLOSE c_get_org_rows;
9504 l_loop_again := 0;
9505 ELSE
9506 --search at the parent level next
9507 CLOSE c_org_rows_exist;
9508 OPEN c_find_parent_id(l_org_id,l_version_id);
9509 FETCH c_find_parent_id INTO l_org_id;
9510 IF c_find_parent_id%NOTFOUND THEN
9511 l_loop_again := 0;
9512 CLOSE c_find_parent_id;
9513 ELSE
9514 CLOSE c_find_parent_id;
9515 END IF;
9516 END IF;
9517 END LOOP;
9518 END IF;
9519 IF l_rows_exist <> 1 THEN
9520 IF l_hired = 1 THEN
9521 --chk if there is any run result
9522 OPEN c_run_results_exist;
9523 FETCH c_run_results_exist INTO l_pt;
9524 IF c_run_results_exist%FOUND THEN
9525 l_rows_exist := 1;
9526 CLOSE c_run_results_exist;
9527 ELSE
9528 CLOSE c_run_results_exist;
9529 END IF;
9530 END IF;
9531 END IF;
9532 Hr_Utility.set_location('rows exist : '||l_rows_exist,30);
9533 IF l_rows_exist = 1 THEN
9534 IF p_sub_cat = 'IPAP' THEN
9535 p_data_element_value := 'Y';
9536 l_return_value := 0;
9537 ELSIF p_sub_cat = 'FUR_S' THEN
9538 --for fur now check to see if the person needs to be reported, this is if he is
9539 --<= 65 years old
9540 l_age := Get_Age(p_assignment_id
9541 ,p_effective_date);
9542 IF l_age <= 65 THEN
9543 p_data_element_value := 'Y';
9544 l_return_value := 0;
9545 ELSE
9546 p_data_element_value := 'N';
9547 l_return_value := 0;
9548 END IF;
9549 END IF;
9550 ELSE
9551 p_data_element_value := 'N';
9552 l_return_value := 0;
9553 END IF;
9554 Hr_Utility.set_location('data element value : '||p_data_element_value,35);
9555 Hr_Utility.set_location('Leaving: '||l_proc_name, 40);
9556 RETURN l_return_value;
9557 EXCEPTION
9558 WHEN Others THEN
9559 p_error_message :='SQL-ERRM :'||SQLERRM;
9560 p_data_element_value := 'N';
9561 Hr_Utility.set_location('..'||p_error_message,85);
9562 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
9563 l_return_value := 1;
9564 RETURN l_return_value;
9565 END Record30_40_Display_Criteria;
9566
9567 --============================================================================
9568 --This is used to decide the Record41_31 hide or show
9569 --============================================================================
9570 FUNCTION Record31_41_Display_Criteria
9571 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
9572 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
9573 ,p_effective_date IN Date
9574 ,p_record_number IN Number
9575 ,p_error_message OUT NOCOPY Varchar2
9576 ,p_data_element_value OUT NOCOPY Varchar2
9577 ) RETURN Number IS
9578
9579 l_proc_name Varchar2(130) := 'Record31_41_Display_Criteria';
9580 l_return_value Number := 1;
9581 l_age Number;
9582
9583 BEGIN
9584 Hr_Utility.set_location('Entering -------- : '||l_proc_name,10);
9585 IF p_record_number = 31 THEN
9586 IF l_rec_31_disp = 'Y' THEN
9587 p_data_element_value := 'Y';
9588 l_return_value := 0;
9589 ELSE
9590 p_data_element_value := 'N';
9591 l_return_value := 0;
9592 END IF;
9593 ELSIF p_record_number = 41 THEN
9594 --now check to see if the person needs to be reported, this is if he is
9595 --<= 65 years old
9596 l_age := Get_Age(p_assignment_id
9597 ,p_effective_date);
9598 IF l_age <= 65 THEN
9599 IF g_fur_contrib_kind = 'A' THEN
9600 IF l_basis_rec_41_disp = 'Y' THEN
9601 p_data_element_value := 'Y';
9602 ELSE
9603 p_data_element_value := 'N';
9604 END IF;
9605 l_return_value := 0;
9606 ELSE
9607 IF l_contrib_rec_41_disp = 'Y' THEN
9608 p_data_element_value := 'Y';
9609 ELSE
9610 p_data_element_value := 'N';
9611 END IF;
9612 l_return_value := 0;
9613 END IF;
9614 ELSE
9615 p_data_element_value := 'N';
9616 l_return_value := 0;
9617 END IF;
9618 END IF;
9619
9620 RETURN l_return_value ;
9621
9622 EXCEPTION
9623 WHEN Others THEN
9624 p_error_message :='SQL-ERRM :'||SQLERRM;
9625 p_data_element_value := 'N';
9626 Hr_Utility.set_location('..'||p_error_message,85);
9627 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
9628 l_return_value := 1;
9629 RETURN l_return_value;
9630 END Record31_41_Display_Criteria;
9631
9632 --============================================================================
9633 --This is used to derive the participation end date in the case , when enrollment has
9634 --come from the ORG EIT on a start of employment
9635 --============================================================================
9636 FUNCTION Get_Participation_End
9637 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
9638 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
9639 ,p_pension_type_id IN pqp_pension_types_f.pension_type_id%TYPE
9640 ,p_date_earned IN Date
9641 ,p_end_date OUT NOCOPY Date
9642 ) RETURN Number IS
9643
9644 l_org_id hr_all_organization_units.organization_id%TYPE;
9645 l_ret_value Number := 0; --return
9646 l_org_info_id hr_organization_information.org_information_id%TYPE;
9647 l_named_hierarchy Number;
9648 l_version_id per_org_structure_versions_v.org_structure_version_id%TYPE DEFAULT NULL;
9649 l_loop_again Number;
9650 l_is_org_info_valid Varchar2(1);
9651
9652 --Cursor to find the org id from the assignment id
9653 CURSOR c_find_org_id IS
9654 SELECT organization_id
9655 FROM per_all_assignments_f
9656 WHERE assignment_id = p_assignment_id
9657 AND Trunc(p_date_earned) BETWEEN effective_start_date AND effective_end_date
9658 AND business_group_id = p_business_group_id;
9659
9660 --Cursor to find the named hierarchy associated with the BG
9661 CURSOR c_find_named_hierarchy IS
9662 SELECT org_information1
9663 FROM hr_organization_information
9664 WHERE organization_id = p_business_group_id
9665 AND org_information_context = 'NL_BG_INFO';
9666
9667 --Cursor to find the valid version id for the particular named hierarchy
9668 CURSOR c_find_ver_frm_hierarchy(c_hierarchy_id IN Number) IS
9669 SELECT ORG_STRUCTURE_VERSION_ID
9670 FROM per_org_structure_versions_v
9671 WHERE organization_structure_id = c_hierarchy_id
9672 AND p_date_earned BETWEEN date_from
9673 AND Nvl(date_to,Hr_Api.g_eot);
9674
9675 --Cursor to find the valid version id for a particular business group
9676 CURSOR c_find_ver_frm_bg IS
9677 SELECT ORG_STRUCTURE_VERSION_ID
9678 FROM per_org_structure_versions_v
9679 WHERE business_group_id = p_business_group_id
9680 AND p_date_earned BETWEEN date_from
9681 AND Nvl( date_to,Hr_Api.g_eot);
9682
9683 --Cursor to find the parent id from the org id
9684 CURSOR c_find_parent_id(c_org_id IN Number
9685 ,c_version_id IN Number) IS
9686 SELECT organization_id_parent
9687 FROM per_org_structure_elements
9688 WHERE organization_id_child = c_org_id
9689 AND org_structure_version_id = c_version_id
9690 AND business_group_id = p_business_group_id;
9691
9692 --Cursor to find if there is any information record at the org level
9693 --if so return the org info id
9694 CURSOR c_get_valid_org_info(c_org_id IN hr_all_organization_units.organization_id%TYPE) IS
9695 SELECT hoi.org_information_id
9696 FROM hr_organization_information hoi
9697 WHERE hoi.org_information_context = 'PQP_NL_ABP_PT'
9698 AND hoi.org_information3 = To_Char(p_pension_type_id)
9699 AND NVL(hoi.org_information7,'Y') = 'Y'
9700 AND hoi.organization_id = c_org_id;
9701
9702 --Cursor to find the participation end date from org level information
9703 CURSOR c_get_org_info(c_org_id IN hr_organization_information.organization_id%TYPE) IS
9704 SELECT Fnd_Date.canonical_to_date(Nvl(hoi.org_information2,Fnd_Date.date_to_canonical(Hr_Api.g_eot)))
9705 FROM hr_organization_information hoi
9706 WHERE hoi.org_information_context = 'PQP_NL_ABP_PT'
9707 AND hoi.org_information3 = To_Char(p_pension_type_id)
9708 AND hoi.org_information6 = 'Y'
9709 AND NVL(hoi.org_information7,'Y') = 'Y'
9710 AND hoi.organization_id = c_org_id
9711 AND p_date_earned BETWEEN Fnd_Date.canonical_to_date(hoi.org_information1)
9712 AND Fnd_Date.canonical_to_date(Nvl(hoi.org_information2,Fnd_Date.date_to_canonical(Hr_Api.g_eot)));
9713
9714 BEGIN
9715 -- find the org the assignment is attached to
9716 OPEN c_find_org_id;
9717 FETCH c_find_org_id INTO l_org_id;
9718 CLOSE c_find_org_id;
9719
9720 --first chk to see if a named hierarchy exists for the BG
9721 OPEN c_find_named_hierarchy;
9722 FETCH c_find_named_hierarchy INTO l_named_hierarchy;
9723 -- if a named hiearchy is found , find the valid version on that date
9724 IF c_find_named_hierarchy%FOUND THEN
9725 CLOSE c_find_named_hierarchy;
9726 -- now find the valid version on that date
9727 OPEN c_find_ver_frm_hierarchy(l_named_hierarchy);
9728 FETCH c_find_ver_frm_hierarchy INTO l_version_id;
9729 --if no valid version is found, try to get it frm the BG
9730 IF c_find_ver_frm_hierarchy%NOTFOUND THEN
9731 CLOSE c_find_ver_frm_hierarchy;
9732 -- find the valid version id from the BG
9733 OPEN c_find_ver_frm_bg;
9734 FETCH c_find_ver_frm_bg INTO l_version_id;
9735 CLOSE c_find_ver_frm_bg;
9736 -- else a valid version has been found for the named hierarchy
9737 ELSE
9738 CLOSE c_find_ver_frm_hierarchy;
9739 END IF; --end of if no valid version found
9740 -- else find the valid version from BG
9741 ELSE
9742 CLOSE c_find_named_hierarchy;
9743 --now find the version number from the BG
9744 OPEN c_find_ver_frm_bg;
9745 FETCH c_find_ver_frm_bg INTO l_version_id;
9746 CLOSE c_find_ver_frm_bg;
9747 END IF; -- end of if named hierarchy found
9748
9749 -- loop through the org hierarchy to find the participation end date at
9750 -- this org level or its parents
9751 l_loop_again := 1;
9752 WHILE (l_loop_again = 1)
9753
9754 LOOP
9755 -- if any org info row is found for this particular org id
9756 -- for a pension type with the given pension type id
9757 -- then return that org info id
9758 OPEN c_get_valid_org_info(l_org_id);
9759 FETCH c_get_valid_org_info INTO l_org_info_id;
9760 IF c_get_valid_org_info%FOUND THEN
9761 Hr_Utility.set_location('found row @ org info level'||l_org_id,20);
9762 l_loop_again := 0;
9763 CLOSE c_get_valid_org_info;
9764 -- fetch the participation end date from the org info row
9765 OPEN c_get_org_info(l_org_id);
9766 FETCH c_get_org_info INTO p_end_date;
9767 IF c_get_org_info%FOUND THEN
9768 l_ret_value := 0;
9769 l_loop_again := 0;
9770 CLOSE c_get_org_info;
9771 ELSE
9772 l_ret_value := 1;
9773 l_loop_again := 0;
9774 CLOSE c_get_org_info;
9775 END IF;
9776
9777 ELSE -- search at the parent level of the current org
9778 CLOSE c_get_valid_org_info;
9779 -- fetch the parent of this org and loop again
9780 OPEN c_find_parent_id(l_org_id,l_version_id);
9781 FETCH c_find_parent_id INTO l_org_id;
9782 IF c_find_parent_id%NOTFOUND THEN -- the topmost org has been reached
9783 CLOSE c_find_parent_id;
9784 l_ret_value := 1;
9785 l_loop_again := 0;
9786 ELSE
9787 CLOSE c_find_parent_id;
9788 END IF;
9789 END IF;
9790 END LOOP;
9791 RETURN l_ret_value;
9792
9793 END Get_Participation_End;
9794
9795 --============================================================================
9796 --This is used to derive the participation start and end dates and the old start and
9797 --end dates in case of an update for FUR Pensions
9798 --============================================================================
9799 FUNCTION Get_Fur_Participation_Dates
9800 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
9801 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
9802 ,p_fetch_code IN Varchar2
9803 ,p_effective_date IN Date
9804 ,p_error_message OUT NOCOPY Varchar2
9805 ,p_data_element_value OUT NOCOPY Varchar2
9806 ) RETURN Number IS
9807
9808 --cursor to check if ASG EIT rows exist
9809 CURSOR c_asg_rows_exist IS
9810 SELECT 1
9811 FROM ben_ext_chg_evt_log bec,pqp_pension_types_f pty
9812 WHERE chg_evt_cd = 'COAPPD'
9813 AND prmtr_01 = 'ASG'
9814 AND Fnd_Number.canonical_to_number(prmtr_02) = pty.pension_type_id
9815 AND pty.pension_sub_category = 'FUR_S'
9816 AND prmtr_03 = 'Y'
9817 AND Fnd_Number.canonical_to_number(prmtr_10) = p_assignment_id
9818 AND person_id = (SELECT person_id
9819 FROM per_all_assignments_f
9820 WHERE assignment_id = p_assignment_id
9821 AND p_effective_date BETWEEN effective_start_date
9822 AND effective_end_date
9823 )
9824 AND bec.business_group_id = p_business_group_id;
9825
9826 --cursor to check if ORG EIT rows exist
9827 CURSOR c_org_rows_exist(c_org_id IN Number) IS
9828 SELECT 1
9829 FROM ben_ext_chg_evt_log bec,pqp_pension_types_f pty
9830 WHERE chg_evt_cd = 'COAPPD'
9831 AND prmtr_01 = 'ORG'
9832 AND Fnd_Number.canonical_to_number(prmtr_02) = pty.pension_type_id
9833 AND pty.pension_sub_category = 'FUR_S'
9834 AND prmtr_03 = 'Y'
9835 AND Fnd_Number.canonical_to_number(prmtr_04) = c_org_id
9836 AND bec.business_group_id = p_business_group_id;
9837
9838 --cursor to get the old and new start and end dates from the ASG EIT
9839 CURSOR c_get_asg_rows IS
9840 SELECT old_val1,new_val1,old_val2,new_val2
9841 FROM ben_ext_chg_evt_log bec,pqp_pension_types_f pty
9842 WHERE chg_evt_cd = 'COAPPD'
9843 AND prmtr_01 = 'ASG'
9844 AND Fnd_Number.canonical_to_number(prmtr_02) = pty.pension_type_id
9845 AND prmtr_03 = 'Y'
9846 AND Fnd_Number.canonical_to_number(prmtr_10) = p_assignment_id
9847 AND pty.pension_sub_category = 'FUR_S'
9848 AND person_id = (SELECT person_id
9849 FROM per_all_assignments_f
9850 WHERE assignment_id = p_assignment_id
9851 AND p_effective_date BETWEEN effective_start_date
9852 AND effective_end_date
9853 )
9854 AND bec.business_group_id = p_business_group_id
9855 AND chg_eff_dt BETWEEN g_extract_params(p_business_group_id).extract_start_date
9856 AND g_extract_params(p_business_group_id).extract_end_date
9857 ORDER BY ext_chg_evt_log_id;
9858
9859 --cursor to get the old and new start and end dates from the ORG EIT
9860 CURSOR c_get_org_rows(c_org_id IN Number,c_hire_date IN Date) IS
9861 SELECT old_val1,new_val1,old_val2,new_val2
9862 FROM ben_ext_chg_evt_log bec,pqp_pension_types_f pty
9863 WHERE chg_evt_cd = 'COAPPD'
9864 AND prmtr_01 = 'ORG'
9865 AND Fnd_Number.canonical_to_number(prmtr_02) = pty.pension_type_id
9866 AND prmtr_03 = 'Y'
9867 AND pty.pension_sub_category = 'FUR_S'
9868 AND Fnd_Number.canonical_to_number(prmtr_04) = c_org_id
9869 AND bec.business_group_id = p_business_group_id
9870 AND chg_eff_dt BETWEEN g_extract_params(p_business_group_id).extract_start_date
9871 AND g_extract_params(p_business_group_id).extract_end_date
9872 AND chg_eff_dt >= c_hire_date
9873 ORDER BY ext_chg_evt_log_id;
9874
9875 --Cursor to find the named hierarchy associated with the BG
9876 CURSOR c_find_named_hierarchy IS
9877 SELECT org_information1
9878 FROM hr_organization_information
9879 WHERE organization_id = p_business_group_id
9880 AND org_information_context = 'NL_BG_INFO';
9881
9882 --Cursor to find the valid version id for the particular named hierarchy
9883 CURSOR c_find_ver_frm_hierarchy(c_hierarchy_id IN Number) IS
9884 SELECT ORG_STRUCTURE_VERSION_ID
9885 FROM per_org_structure_versions_v
9886 WHERE organization_structure_id = c_hierarchy_id
9887 AND p_effective_date BETWEEN date_from
9888 AND Nvl(date_to,Hr_Api.g_eot);
9889
9890 --Cursor to find the valid version id for a particular business group
9891 CURSOR c_find_ver_frm_bg IS
9892 SELECT ORG_STRUCTURE_VERSION_ID
9893 FROM per_org_structure_versions_v
9894 WHERE business_group_id = p_business_group_id
9895 AND p_effective_date BETWEEN date_from
9896 AND Nvl( date_to,Hr_Api.g_eot);
9897
9898 --Cursor to find the parent id from the org id
9899 CURSOR c_find_parent_id(c_org_id IN Number
9900 ,c_version_id IN Number) IS
9901 SELECT organization_id_parent
9902 FROM per_org_structure_elements
9903 WHERE organization_id_child = c_org_id
9904 AND org_structure_version_id = c_version_id
9905 AND business_group_id = p_business_group_id;
9906
9907 --cursor to find the org id for the current asg
9908 CURSOR c_find_org_id IS
9909 SELECT organization_id
9910 FROM per_all_assignments_f
9911 WHERE assignment_id = p_assignment_id
9912 AND p_effective_date BETWEEN effective_start_date
9913 AND effective_end_date;
9914
9915 -- Cursor to get the hire date of the person
9916 CURSOR c_hire_dt IS
9917 SELECT max(date_start)
9918 FROM per_all_assignments_f asg
9919 ,per_periods_of_service pps
9920 WHERE pps.person_id = asg.person_id
9921 AND asg.assignment_id = p_assignment_id
9922 AND pps.business_group_id = p_business_group_id
9923 AND date_start <= p_effective_date;
9924
9925 --cursor to check if run results exist for any FUR Pension Types for this assignment
9926 CURSOR c_run_results_exist IS
9927 SELECT pty.pension_type_id
9928 FROM pay_run_results prr,
9929 pay_payroll_actions ppa,
9930 pay_assignment_actions paa,
9931 pay_element_type_extra_info pei,
9932 pqp_pension_types_f pty
9933 WHERE paa.assignment_action_id = prr.assignment_action_id
9934 AND paa.payroll_action_id = ppa.payroll_action_id
9935 AND ppa.date_earned BETWEEN g_extract_params(p_business_group_id).extract_start_date
9936 AND g_extract_params(p_business_group_id).extract_end_date
9937 AND paa.assignment_id = p_assignment_id
9938 AND pei.element_type_id = prr.element_type_id
9939 AND pei.information_type = 'PQP_NL_ABP_DEDUCTION'
9940 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
9941 AND pei.eei_information2 = Fnd_Number.number_to_canonical(pty.pension_type_id)
9942 AND pty.pension_sub_category = 'FUR_S';
9943
9944 l_proc_name Varchar2(150) := g_proc_name ||'get_fur_participation_dates';
9945 l_return_value Number := -1;
9946 l_named_hierarchy Number;
9947 l_version_id per_org_structure_versions_v.org_structure_version_id%TYPE DEFAULT NULL;
9948 l_asg_rows_exist Number;
9949 l_org_rows_exist Number;
9950 l_org_id Number;
9951 i Number := 0;
9952 l_loop_again Number;
9953 l_hire_date Date;
9954 l_hired Number := 0;
9955 l_ret_val Number;
9956 l_end_date Date;
9957
9958
9959 BEGIN
9960 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
9961 --check the index and the code and calculate the value accordingly
9962 Hr_Utility.set_location('value of g_index : '||g_index_fur,7);
9963 Hr_Utility.set_location('value of fetch code : '||p_fetch_code ,10);
9964 IF g_index_fur = 0 AND p_fetch_code = 'NEW_ST' THEN
9965 g_count_fur := 0;
9966
9967 OPEN c_hire_dt;
9968 FETCH c_hire_dt INTO l_hire_date;
9969 CLOSE c_hire_dt;
9970 IF l_hire_date BETWEEN g_extract_params(p_business_group_id).extract_start_date
9971 AND g_extract_params(p_business_group_id).extract_end_date THEN
9972 l_hired := 1;
9973 END IF;
9974
9975 OPEN c_asg_rows_exist;
9976 FETCH c_asg_rows_exist INTO l_asg_rows_exist;
9977 IF c_asg_rows_exist%FOUND THEN
9978 CLOSE c_asg_rows_exist;
9979 Hr_Utility.set_location('found rows at the assignment eit level',15);
9980 --now fetch the rows from the log table
9981 FOR asg_rec IN c_get_asg_rows
9982 LOOP
9983
9984 IF asg_rec.old_val1 IS NOT NULL THEN
9985 IF asg_rec.old_val1 <> asg_rec.new_val1 THEN
9986 g_fur_dates(i).old_start := asg_rec.old_val1;
9987 g_fur_dates(i).new_start := asg_rec.new_val1;
9988 ELSE
9989 g_fur_dates(i).old_start := '';
9990 g_fur_dates(i).new_start := asg_rec.new_val1;
9991 END IF;
9992 ELSIF asg_rec.new_val1 IS NOT NULL THEN
9993 g_fur_dates(i).old_start := '';
9994 g_fur_dates(i).new_start := asg_rec.new_val1;
9995 ELSE
9996 g_fur_dates(i).old_start := '';
9997 g_fur_dates(i).new_start := '';
9998 END IF;
9999
10000 IF asg_rec.old_val2 IS NOT NULL THEN
10001 IF asg_rec.old_val2 <> asg_rec.new_val2 THEN
10002 g_fur_dates(i).old_end := asg_rec.old_val2;
10003 g_fur_dates(i).new_end := asg_rec.new_val2;
10004 ELSE
10005 g_fur_dates(i).old_end := '';
10006 g_fur_dates(i).new_end := asg_rec.new_val2;
10007 END IF;
10008 ELSIF asg_rec.new_val2 IS NOT NULL THEN
10009 g_fur_dates(i).old_end := '';
10010 g_fur_dates(i).new_end := asg_rec.new_val2;
10011 ELSE
10012 g_fur_dates(i).old_end := '';
10013 g_fur_dates(i).new_end := '';
10014 END IF;
10015
10016 i := i + 1;
10017 END LOOP; -- FOR asg_rec IN c_get_asg_rows
10018 g_count_fur := i;
10019 Hr_Utility.set_location('count of rows : '||g_count_fur,20);
10020 ELSE
10021 CLOSE c_asg_rows_exist;
10022 --go up the org hierarchy to find the rows at some org eit level
10023 -- find the org the assignment is attached to
10024 OPEN c_find_org_id;
10025 FETCH c_find_org_id INTO l_org_id;
10026 CLOSE c_find_org_id;
10027
10028 --first chk to see if a named hierarchy exists for the BG
10029 OPEN c_find_named_hierarchy;
10030 FETCH c_find_named_hierarchy INTO l_named_hierarchy;
10031 -- if a named hiearchy is found , find the valid version on that date
10032 IF c_find_named_hierarchy%FOUND THEN
10033 CLOSE c_find_named_hierarchy;
10034 -- now find the valid version on that date
10035 OPEN c_find_ver_frm_hierarchy(l_named_hierarchy);
10036 FETCH c_find_ver_frm_hierarchy INTO l_version_id;
10037 --if no valid version is found, try to get it frm the BG
10038 IF c_find_ver_frm_hierarchy%NOTFOUND THEN
10039 CLOSE c_find_ver_frm_hierarchy;
10040 -- find the valid version id from the BG
10041 OPEN c_find_ver_frm_bg;
10042 FETCH c_find_ver_frm_bg INTO l_version_id;
10043 CLOSE c_find_ver_frm_bg;
10044 -- else a valid version has been found for the named hierarchy
10045 ELSE
10046 CLOSE c_find_ver_frm_hierarchy;
10047 END IF; --end of if no valid version found
10048 -- else find the valid version from BG
10049 ELSE
10050 CLOSE c_find_named_hierarchy;
10051 --now find the version number from the BG
10052 OPEN c_find_ver_frm_bg;
10053 FETCH c_find_ver_frm_bg INTO l_version_id;
10054 CLOSE c_find_ver_frm_bg;
10055 END IF; -- end of if named hierarchy found
10056
10057 -- loop through the org hierarchy to find the participation start date at
10058 -- this org level or its parents
10059 l_loop_again := 1;
10060 WHILE (l_loop_again = 1)
10061
10062 LOOP
10063 Hr_Utility.set_location('searching at org level : '||l_org_id,25);
10064 OPEN c_org_rows_exist(l_org_id);
10065 FETCH c_org_rows_exist INTO l_org_rows_exist;
10066 IF c_org_rows_exist%FOUND THEN
10067 CLOSE c_org_rows_exist;
10068 FOR org_rec IN c_get_org_rows(l_org_id,l_hire_date)
10069 LOOP
10070 IF org_rec.old_val1 IS NOT NULL THEN
10071 IF org_rec.old_val1 <> org_rec.new_val1 THEN
10072 g_fur_dates(i).old_start := org_rec.old_val1;
10073 g_fur_dates(i).new_start := org_rec.new_val1;
10074 ELSE
10075 g_fur_dates(i).old_start := '';
10076 g_fur_dates(i).new_start := org_rec.new_val1;
10077 END IF;
10078 ELSIF org_rec.new_val1 IS NOT NULL THEN
10079 g_fur_dates(i).old_start := '';
10080 g_fur_dates(i).new_start := org_rec.new_val1;
10081 ELSE
10082 g_fur_dates(i).old_start := '';
10083 g_fur_dates(i).new_start := '';
10084 END IF;
10085 IF org_rec.old_val2 IS NOT NULL THEN
10086 IF org_rec.old_val2 <> org_rec.new_val2 THEN
10087 g_fur_dates(i).old_end := org_rec.old_val2;
10088 g_fur_dates(i).new_end := org_rec.new_val2;
10089 ELSE
10090 g_fur_dates(i).old_end := '';
10091 g_fur_dates(i).new_end := org_rec.new_val2;
10092 END IF;
10093 ELSIF org_rec.new_val2 IS NOT NULL THEN
10094 g_fur_dates(i).old_end := '';
10095 g_fur_dates(i).new_end := org_rec.new_val2;
10096 ELSE
10097 g_fur_dates(i).old_end := '';
10098 g_fur_dates(i).new_end := '';
10099 END IF;
10100 IF l_hired = 1 THEN
10101 Hr_Utility.set_location('hire date : '||l_hire_date,99);
10102 Hr_Utility.set_location('new date : '||g_fur_dates(i).new_start,100);
10103 Hr_Utility.set_location('greater date : '||Fnd_Date.date_to_canonical(Greatest(
10104 l_hire_date,Fnd_Date.canonical_to_date(g_fur_dates(i).new_start))),101);
10105 IF g_fur_dates(i).new_start IS NOT NULL THEN
10106 Hr_Utility.set_location('chking the new start date',102);
10107 g_fur_dates(i).new_start := Fnd_Date.date_to_canonical(Greatest(
10108 l_hire_date,Fnd_Date.canonical_to_date(g_fur_dates(i).new_start)));
10109 Hr_Utility.set_location('new start date is : '||g_fur_dates(i).new_start,103);
10110 END IF;
10111 IF g_fur_dates(i).old_start IS NOT NULL THEN
10112 g_fur_dates(i).old_start := Fnd_Date.date_to_canonical(Greatest(
10113 l_hire_date,Fnd_Date.canonical_to_date(g_fur_dates(i).old_start)));
10114 END IF;
10115 END IF;
10116 IF g_fur_dates(i).new_start = g_fur_dates(i).old_start THEN
10117 g_fur_dates(i).old_start := '';
10118 END IF;
10119 i := i + 1;
10120 END LOOP;
10121 g_count_fur := i;
10122 Hr_Utility.set_location('value for g count : '||g_count_fur,30);
10123 l_loop_again := 0;
10124 ELSE
10125 --search at the parent level next
10126 CLOSE c_org_rows_exist;
10127 OPEN c_find_parent_id(l_org_id,l_version_id);
10128 FETCH c_find_parent_id INTO l_org_id;
10129 IF c_find_parent_id%NOTFOUND THEN
10130 l_loop_again := 0;
10131 CLOSE c_find_parent_id;
10132 ELSE
10133 CLOSE c_find_parent_id;
10134 END IF;
10135 END IF;
10136 END LOOP;
10137 END IF;
10138 --if no changes have occured,check if participation has occured due to employement start
10139 --if so , fire a row for record 40
10140 IF g_count_fur = 0 THEN
10141 i := 0;
10142 IF l_hired = 1 THEN
10143 --chk if there is any run result
10144 FOR c_rec IN c_run_results_exist
10145 LOOP
10146 g_fur_dates(i).new_start := Fnd_Date.date_to_canonical(l_hire_date);
10147 g_fur_dates(i).old_start := '';
10148 --get the end date corresponding to this enrollment
10149 l_ret_val := Get_Participation_End
10150 (p_assignment_id => p_assignment_id
10151 ,p_business_group_id => p_business_group_id
10152 ,p_pension_type_id => c_rec.pension_type_id
10153 ,p_date_earned => p_effective_date
10154 ,p_end_date => l_end_date
10155 );
10156 IF l_ret_val = 0 THEN
10157 IF l_end_date = hr_api.g_eot THEN
10158 g_fur_dates(i).new_end := '';
10159 ELSE
10160 g_fur_dates(i).new_end := Fnd_Date.date_to_canonical(l_end_date) ;
10161 END IF;
10162 ELSE
10163 g_fur_dates(i).new_end := '';
10164 END IF;
10165 g_fur_dates(i).old_end := '';
10166 i := i+1;
10167 END LOOP;
10168 g_count_fur := i;
10169 END IF;
10170 END IF;
10171 END IF;
10172
10173 IF g_count_fur > 0 THEN
10174 Hr_Utility.set_location('old st date : '||g_fur_dates(g_index_fur).old_start,40);
10175 Hr_Utility.set_location('new st date : '||g_fur_dates(g_index_fur).new_start,45);
10176 Hr_Utility.set_location('old ed date : '||g_fur_dates(g_index_fur).old_end,50);
10177 Hr_Utility.set_location('new ed date : '||g_fur_dates(g_index_fur).new_end,55);
10178 l_return_value := 0;
10179 --depending on the fetch code ,set the data element value
10180 IF p_fetch_code = 'NEW_ST' THEN
10181 p_data_element_value := g_fur_dates(g_index_fur).new_start;
10182 ELSIF p_fetch_code = 'OLD_ST' THEN
10183 p_data_element_value := g_fur_dates(g_index_fur).old_start;
10184 ELSIF p_fetch_code = 'NEW_ED' THEN
10185 p_data_element_value := g_fur_dates(g_index_fur).new_end;
10186 ELSIF p_fetch_code = 'OLD_ED' THEN
10187 p_data_element_value := g_fur_dates(g_index_fur).old_end;
10188 END IF;
10189
10190 -- p_data_element_value := substr(p_data_element_value,1,10);
10191 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
10192 (Fnd_Date.canonical_to_date(p_data_element_value),
10193 'YYYYMMDD');
10194
10195 ELSE
10196 p_data_element_value := '';
10197 l_return_value := 0;
10198 END IF;
10199
10200 Hr_Utility.set_location('p_data_element_value: '||p_data_element_value, 70);
10201 Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
10202
10203 l_return_value :=0;
10204 RETURN l_return_value;
10205 EXCEPTION
10206 WHEN Others THEN
10207 p_error_message :='SQL-ERRM :'||SQLERRM;
10208 Hr_Utility.set_location('..'||p_error_message,85);
10209 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
10210 RETURN l_return_value;
10211 END get_fur_participation_dates;
10212
10213 --============================================================================
10214 -- This function returns the kind of contribution for PPP Pensions
10215 -- for a particular effective date.
10216 --============================================================================
10217 FUNCTION Get_PPP_Kind
10218 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
10219 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
10220 ,p_effective_date IN DATE
10221 ,p_current IN VARCHAR2
10222 ,p_error_message OUT NOCOPY VARCHAR2
10223 ,p_data_element_value OUT NOCOPY VARCHAR2
10224 ) RETURN NUMBER IS
10225
10226 l_proc_name VARCHAR2(30) := 'Get_PPP_Kind';
10227 l_ppp_flag VARCHAR2(1) := ' ';
10228 l_org_id NUMBER;
10229 l_rr_exist NUMBER;
10230 l_asg_exist NUMBER;
10231
10232 CURSOR c_ppp_org IS
10233 SELECT organization_id
10234 FROM per_all_assignments_f
10235 WHERE assignment_id = p_assignment_id
10236 AND TRUNC(p_effective_date) BETWEEN effective_start_date
10237 AND effective_end_date;
10238
10239 --
10240 -- Cursor for ASG participation in PPP
10241 --
10242 CURSOR c_ppp_asg IS
10243 SELECT 1
10244 FROM ben_ext_chg_evt_log bec
10245 WHERE chg_evt_cd = 'COAPPD'
10246 AND prmtr_01 = 'ASG'
10247 AND prmtr_04 = 'PPP'
10248 AND prmtr_03 = 'Y'
10249 AND fnd_number.canonical_to_number(prmtr_10) = p_assignment_id
10250 -- AND chg_eff_dt BETWEEN g_extract_params(p_business_group_id).extract_start_date
10251 -- AND g_extract_params(p_business_group_id).extract_end_date
10252 AND bec.business_group_id = p_business_group_id;
10253
10254 CURSOR c_ppp_asg1 IS
10255 SELECT 1
10256 FROM per_assignment_extra_info paei,
10257 pqp_pension_types_f pty
10258 WHERE paei.information_type = 'NL_ABP_PI'
10259 AND paei.aei_information_category = 'NL_ABP_PI'
10260 AND paei.assignment_id = p_assignment_id
10261 AND fnd_number.canonical_to_number(NVL(aei_information3,-1)) = pty.pension_type_id
10262 AND p_effective_date BETWEEN pty.effective_start_date and pty.effective_end_date
10263 AND pty.pension_sub_category IN ('PPP')
10264 AND p_effective_date between fnd_date.canonical_to_date(paei.aei_information1)
10265 AND fnd_date.canonical_to_date(NVL(paei.aei_information2,
10266 fnd_date.date_to_canonical(hr_api.g_eot)));
10267
10268 /* Cursor changed for 6670714
10269 CURSOR c_rr_cur IS
10270 SELECT 1
10271 FROM pay_run_results prr,
10272 pay_payroll_actions ppa,
10273 pay_assignment_actions paa,
10274 pay_element_type_extra_info pei,
10275 pqp_pension_types_f pty
10276 WHERE paa.assignment_action_id = prr.assignment_action_id
10277 AND paa.payroll_action_id = ppa.payroll_action_id
10278 AND ppa.date_earned BETWEEN g_extract_params(p_business_group_id).extract_start_date
10279 AND g_extract_params(p_business_group_id).extract_end_date
10280 AND paa.assignment_id = p_assignment_id
10281 AND pei.element_type_id = prr.element_type_id
10282 AND pei.information_type = 'PQP_NL_ABP_DEDUCTION'
10283 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
10284 AND pei.eei_information2 = Fnd_Number.number_to_canonical(pty.pension_type_id)
10285 AND pty.pension_sub_category = 'PPP';*/
10286
10287 CURSOR c_rr_cur IS
10288 SELECT 1
10289 FROM per_all_assignments_f paf,
10290 hr_organization_information hoi,
10291 pqp_pension_types_f pty,
10292 pay_all_payrolls_f ppf
10293 WHERE paf.assignment_id = p_assignment_id
10294 AND p_effective_date BETWEEN paf.effective_start_date AND paf.effective_end_date
10295 AND paf.payroll_id = ppf.payroll_id
10296 AND ppf.prl_information_category = 'NL'
10297 AND p_effective_date BETWEEN ppf.effective_start_date AND ppf.effective_end_date
10298 AND (paf.organization_id = hoi.organization_id
10299 OR
10300 (fnd_number.canonical_to_number(ppf.prl_information1) = hoi.organization_id
10301 AND NOT EXISTS (SELECT 1
10302 FROM hr_organization_information hoi1
10303 WHERE hoi1.org_information_context = 'PQP_NL_ABP_PT'
10304 AND hoi1.org_information3 = TO_CHAR(pty.pension_type_id)
10305 AND hoi1.organization_id = paf.organization_id
10306 AND ( NVL(hoi1.org_information6,'N')= 'N'
10307 OR NVL(hoi1.org_information7,'N')= 'N')
10308 AND p_effective_date BETWEEN fnd_date.canonical_to_date(hoi1.org_information1)
10309 AND fnd_date.canonical_to_date(NVL(hoi1.org_information2,
10310 fnd_date.date_to_canonical(hr_api.g_eot))))
10311 ))
10312 AND hoi.org_information_context = 'PQP_NL_ABP_PT'
10313 AND hoi.org_information3 = TO_CHAR(pty.pension_type_id)
10314 AND p_effective_date BETWEEN pty.effective_start_date AND pty.effective_end_date
10315 AND pty.pension_sub_category IN ('PPP')
10316 AND NVL(hoi.org_information6,'N') = 'Y'
10317 AND NVL(hoi.org_information7,'N') = 'Y'
10318 AND p_effective_date BETWEEN fnd_date.canonical_to_date(hoi.org_information1)
10319 AND fnd_date.canonical_to_date(NVL(hoi.org_information2,
10320 fnd_date.date_to_canonical(hr_api.g_eot)));
10321
10322
10323 BEGIN
10324 Hr_Utility.set_location('Entering ------ : '||l_proc_name,10);
10325 --
10326 -- Check if the value being fetched is the current one(for the extract date range).
10327 --
10328 IF p_current = 'Y' THEN
10329 Hr_Utility.set_location('... Current PPP Flag derived',15);
10330 OPEN c_ppp_asg1;
10331 FETCH c_ppp_asg1 INTO l_asg_exist;
10332 IF c_ppp_asg1%FOUND THEN
10333 Hr_Utility.set_location('... Current PPP Flag derived',16);
10334 l_ppp_flag := '1';
10335 ELSE
10336 OPEN c_rr_cur;
10337 FETCH c_rr_cur INTO l_rr_exist;
10338 IF c_rr_cur%FOUND THEN
10339 l_ppp_flag := '1';
10340 Hr_Utility.set_location('... RR exist value is 1',20);
10341 ELSE
10342 l_ppp_flag := '0';
10343 Hr_Utility.set_location('... RR do not exist value is 0',30);
10344 END IF;
10345 CLOSE c_rr_cur;
10346 END IF;
10347 CLOSE c_ppp_asg1;
10348 END IF;
10349
10350 FOR ppp_org_rec IN c_ppp_org
10351 LOOP
10352 l_org_id := ppp_org_rec.organization_id;
10353 END LOOP;
10354 Hr_Utility.set_location('...Org Id for the Asg: '||l_org_id,20);
10355
10356 p_data_element_value := l_ppp_flag;
10357 Hr_Utility.set_location('Leaving:-------- '||l_proc_name, 20);
10358 RETURN 0;
10359
10360 EXCEPTION
10361 WHEN Others THEN
10362 p_error_message :='SQL-ERRM :'||SQLERRM;
10363 p_data_element_value := ' ';
10364 Hr_Utility.set_location('..'||p_error_message,10);
10365 Hr_Utility.set_location('Leaving:-------- '||l_proc_name,20);
10366 RETURN -1;
10367
10368 END Get_PPP_Kind;
10369
10370 --============================================================================
10371 --This function returns the kind of contribution for FPU Pensions
10372 --
10373 -- Logic behind the code
10374 --
10375 /*
10376 Individual Schemes Code
10377 ============================= ======
10378 No Participation G
10379 FPU Standard (End 31-DEC-03) S
10380 FPU Extra C
10381 FPU Raise A
10382 FPU Total B
10383 FPU Base S
10384 FPU Composition S
10385
10386 Multiple FPU Code
10387 =========================== ======
10388 FPU Base + Composition S
10389 FPU Base or Composition + Extra C
10390 FPU Base or Composition + Raise A
10391 FPU Base or Composition + Total B */
10392
10393 -- Please Note : Legislative rules do not allow any other combination
10394 --============================================================================
10395 FUNCTION Get_Fpu_Kind
10396 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
10397 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
10398 ,p_effective_date IN Date
10399 ,p_error_message OUT NOCOPY Varchar2
10400 ,p_data_element_value OUT NOCOPY Varchar2
10401 ) RETURN NUMBER IS
10402
10403 l_proc_name VARCHAR2(30) := 'Get_Fpu_Kind';
10404 l_kind_of_contrib VARCHAR2(1) := 'G';
10405
10406 /* Cursor changed for 6670714
10407 CURSOR c_fpu_rr_cur IS
10408 SELECT decode (pty.pension_sub_category,'FPU_B','S'
10409 ,'FPU_C','S'
10410 ,'FPU_E','C'
10411 ,'FPU_R','A'
10412 ,'FPU_S','S'
10413 ,'FPU_T' ,'B') fpu_code
10414 FROM pay_run_results prr,
10415 pay_payroll_actions ppa,
10416 pay_assignment_actions paa,
10417 pay_element_type_extra_info pei,
10418 pqp_pension_types_f pty
10419 WHERE paa.assignment_action_id = prr.assignment_action_id
10420 AND paa.payroll_action_id = ppa.payroll_action_id
10421 AND ppa.date_earned BETWEEN g_extract_params(p_business_group_id).extract_start_date
10422 AND g_extract_params(p_business_group_id).extract_end_date
10423 AND paa.assignment_id = p_assignment_id
10424 AND pei.element_type_id = prr.element_type_id
10425 AND pei.information_type = 'PQP_NL_ABP_DEDUCTION'
10426 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
10427 AND pei.eei_information2 = Fnd_Number.number_to_canonical(pty.pension_type_id)
10428 AND pty.pension_sub_category IN ('FPU_B',
10429 'FPU_E',
10430 'FPU_R',
10431 'FPU_S',
10432 'FPU_T');*/
10433
10434 CURSOR c_fpu_rr_cur IS
10435 SELECT DISTINCT DECODE (pty.pension_sub_category,'FPU_B','S'
10436 ,'FPU_C','S'
10437 ,'FPU_E','C'
10438 ,'FPU_R','A'
10439 ,'FPU_S','S'
10440 ,'FPU_T' ,'B') fpu_code
10441 FROM per_all_assignments_f paf,
10442 hr_organization_information hoi,
10443 pqp_pension_types_f pty,
10444 pay_all_payrolls_f ppf
10445 WHERE paf.assignment_id = p_assignment_id
10446 AND p_effective_date BETWEEN paf.effective_start_date AND paf.effective_end_date
10447 AND paf.payroll_id = ppf.payroll_id
10448 AND ppf.prl_information_category = 'NL'
10449 AND p_effective_date BETWEEN ppf.effective_start_date AND ppf.effective_end_date
10450 AND (paf.organization_id = hoi.organization_id
10451 OR
10452 (fnd_number.canonical_to_number(ppf.prl_information1) = hoi.organization_id
10453 AND NOT EXISTS (SELECT 1
10454 FROM hr_organization_information hoi1
10455 WHERE hoi1.org_information_context = 'PQP_NL_ABP_PT'
10456 AND hoi1.org_information3 = TO_CHAR(pty.pension_type_id)
10457 AND hoi1.organization_id = paf.organization_id
10458 AND ( NVL(hoi1.org_information6,'N')= 'N'
10459 OR NVL(hoi1.org_information7,'N')= 'N')
10460 AND p_effective_date BETWEEN fnd_date.canonical_to_date(hoi1.org_information1)
10461 AND fnd_date.canonical_to_date(NVL(hoi1.org_information2,
10462 fnd_date.date_to_canonical(hr_api.g_eot))))
10463 ))
10464 AND hoi.org_information_context = 'PQP_NL_ABP_PT'
10465 AND hoi.org_information3 = TO_CHAR(pty.pension_type_id)
10466 AND p_effective_date BETWEEN pty.effective_start_date AND pty.effective_end_date
10467 AND pty.pension_sub_category IN ('FPU_B',
10468 'FPU_E',
10469 'FPU_R',
10470 'FPU_S',
10471 'FPU_T')
10472 AND NVL(hoi.org_information6,'N') = 'Y'
10473 AND NVL(hoi.org_information7,'N') = 'Y'
10474 AND p_effective_date BETWEEN fnd_date.canonical_to_date(hoi.org_information1)
10475 AND fnd_date.canonical_to_date(NVL(hoi.org_information2,
10476 fnd_date.date_to_canonical(hr_api.g_eot)))
10477 AND NOT EXISTS (SELECT 1
10478 FROM per_assignment_extra_info paei1
10479 WHERE paei1.information_type='NL_ABP_RI'
10480 AND paei1.aei_information_category='NL_ABP_RI'
10481 AND paei1.assignment_id = p_assignment_id
10482 AND paei1.aei_information3 = 'G'
10483 AND p_effective_date BETWEEN fnd_date.canonical_to_date(paei1.aei_information1)
10484 AND fnd_date.canonical_to_date(NVL(paei1.aei_information2,
10485 fnd_date.date_to_canonical(hr_api.g_eot))));
10486
10487 CURSOR c_fpu_asg IS
10488 SELECT DISTINCT DECODE (pty.pension_sub_category,'FPU_B','S'
10489 ,'FPU_C','S'
10490 ,'FPU_E','C'
10491 ,'FPU_R','A'
10492 ,'FPU_S','S'
10493 ,'FPU_T' ,'B') fpu_code
10494 FROM per_assignment_extra_info paei,
10495 pqp_pension_types_f pty
10496 WHERE paei.information_type = 'NL_ABP_PI'
10497 AND paei.aei_information_category = 'NL_ABP_PI'
10498 AND paei.assignment_id = p_assignment_id
10499 AND fnd_number.canonical_to_number(NVL(aei_information3,-1)) = pty.pension_type_id
10500 AND p_effective_date BETWEEN pty.effective_start_date and pty.effective_end_date
10501 AND pty.pension_sub_category IN ('FPU_B',
10502 'FPU_E',
10503 'FPU_R',
10504 'FPU_S',
10505 'FPU_T')
10506 AND p_effective_date between fnd_date.canonical_to_date(paei.aei_information1)
10507 AND fnd_date.canonical_to_date(NVL(paei.aei_information2,
10508 fnd_date.date_to_canonical(hr_api.g_eot)))
10509 AND NOT EXISTS (SELECT 1
10510 FROM per_assignment_extra_info paei1
10511 WHERE paei1.information_type='NL_ABP_RI'
10512 AND paei1.aei_information_category='NL_ABP_RI'
10513 AND paei1.assignment_id = p_assignment_id
10514 AND paei1.aei_information3 = 'G'
10515 AND p_effective_date BETWEEN fnd_date.canonical_to_date(paei1.aei_information1)
10516 AND fnd_date.canonical_to_date(NVL(paei1.aei_information2,
10517 fnd_date.date_to_canonical(hr_api.g_eot))));
10518
10519 BEGIN
10520
10521 Hr_Utility.set_location('Entering ------ : '||l_proc_name,5);
10522
10523 FOR fpu_rec IN c_fpu_asg
10524 LOOP
10525 IF l_kind_of_contrib = 'G' THEN
10526 l_kind_of_contrib := fpu_rec.fpu_code;
10527 ELSIF l_kind_of_contrib NOT IN ('A','B','C') THEN
10528 l_kind_of_contrib := fpu_rec.fpu_code;
10529 END IF;
10530 END LOOP;
10531 IF l_kind_of_contrib = 'G' THEN
10532 FOR fpu_rec IN c_fpu_rr_cur
10533 LOOP
10534 IF l_kind_of_contrib = 'G' THEN
10535 l_kind_of_contrib := fpu_rec.fpu_code;
10536 ELSIF l_kind_of_contrib NOT IN ('A','B','C') THEN
10537 l_kind_of_contrib := fpu_rec.fpu_code;
10538 END IF;
10539 END LOOP;
10540 END IF;
10541
10542 Hr_Utility.set_location('...Kind of FPU : '||l_kind_of_contrib,10);
10543
10544 p_data_element_value := l_kind_of_contrib;
10545
10546 Hr_Utility.set_location('Leaving:-------- '||l_proc_name, 20);
10547
10548 RETURN 0;
10549
10550 EXCEPTION
10551 WHEN OTHERS THEN
10552 p_error_message :='SQL-ERRM :'||SQLERRM;
10553 Hr_Utility.set_location('..'||p_error_message,15);
10554 Hr_Utility.set_location('Leaving:-------- '||l_proc_name, 20);
10555 RETURN -1;
10556
10557 END Get_Fpu_Kind;
10558
10559 --============================================================================
10560 --This function returns the kind of contribution for OPNP Pensions, from the ASG EIT
10561 --============================================================================
10562 FUNCTION Get_Opnp_Kind
10563 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
10564 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
10565 ,p_effective_date IN Date
10566 ,p_error_message OUT NOCOPY Varchar2
10567 ,p_data_element_value OUT NOCOPY Varchar2
10568 ) RETURN Number IS
10569
10570 l_proc_name Varchar2(30) := 'Get_Opnp_Kind';
10571 l_kind_of_contrib Varchar2(1) := 'G';
10572
10573 --cursor to fetch the contribution kind from the ASG EIT
10574 CURSOR c_get_contrib_kind IS
10575 SELECT Substr(Nvl(aei_information4,'G'),0,1)
10576 FROM per_assignment_extra_info
10577 WHERE assignment_id = p_assignment_id
10578 AND p_effective_date BETWEEN Fnd_Date.canonical_to_date(aei_information1)
10579 AND Fnd_Date.canonical_to_date(Nvl(aei_information2,Fnd_Date.date_to_canonical(Hr_Api.g_eot)))
10580 AND aei_information_category = 'NL_ABP_RI'
10581 AND information_type = 'NL_ABP_RI';
10582
10583 BEGIN
10584
10585 Hr_Utility.set_location('Entering ------ : '||l_proc_name,5);
10586 OPEN c_get_contrib_kind;
10587 FETCH c_get_contrib_kind INTO l_kind_of_contrib;
10588 CLOSE c_get_contrib_kind;
10589 Hr_Utility.set_location('value of kind of opnp : '||l_kind_of_contrib,10);
10590 p_data_element_value := l_kind_of_contrib;
10591 RETURN 0;
10592
10593 EXCEPTION
10594 WHEN Others THEN
10595 p_error_message :='SQL-ERRM :'||SQLERRM;
10596 Hr_Utility.set_location('..'||p_error_message,15);
10597 Hr_Utility.set_location('Leaving:-------- '||l_proc_name, 20);
10598 RETURN -1;
10599
10600 END Get_Opnp_Kind;
10601
10602 -- ============================================================================
10603 -- Function to get the retro participation of a particular sub category
10604 -- this function currently returns the start and end date of retro
10605 -- participation.
10606 -- ============================================================================
10607 FUNCTION Get_Retro_Kind_Of_Ptpn
10608 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
10609 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
10610 ,p_effective_date IN DATE
10611 ,p_retro_kind_ptpn OUT NOCOPY t_retro_ptpn_kind
10612 ,p_error_message OUT NOCOPY VARCHAR2
10613 ) RETURN NUMBER IS
10614
10615 CURSOR c_asg_kind_info IS
10616 SELECT fnd_date.canonical_to_date(aei_information1) start_dt
10617 ,fnd_date.canonical_to_date(NVL(aei_information2,'4712/12/31 00:00:00')) end_dt
10618 ,aei_information4 kind
10619 ,LEAST(fnd_number.canonical_to_number(aei_information5),1) * 100 value
10620 FROM per_assignment_extra_info paei
10621 WHERE paei.assignment_id = p_assignment_id
10622 AND aei_information4 IS NOT NULL
10623 AND paei.information_type = 'NL_ABP_PAR_INFO'
10624 AND fnd_date.canonical_to_date(aei_information1)
10625 BETWEEN g_extract_params(p_business_group_id).extract_start_date
10626 AND g_extract_params(p_business_group_id).extract_end_date
10627 AND NOT EXISTS ( SELECT 1
10628 FROM per_assignment_extra_info paei1
10629 WHERE paei1.assignment_id = p_assignment_id
10630 AND paei1.information_type = 'NL_ABP_PAR_INFO'
10631 AND fnd_date.canonical_to_date(paei1.aei_information1) <
10632 g_extract_params(p_business_group_id).extract_start_date
10633 AND paei1.aei_information4 IS NOT NULL
10634 and paei1.aei_information4 = paei.aei_information4
10635 AND fnd_date.canonical_to_date(NVL(paei1.aei_information2,'4712/12/31 00:00:00')) =
10636 fnd_date.canonical_to_date(NVL(paei.aei_information1,'4712/12/31 00:00:00')) - 1
10637 )
10638 UNION
10639 SELECT fnd_date.canonical_to_date(aei_information1) start_dt
10640 ,fnd_date.canonical_to_date(NVL(aei_information2,'4712/12/31 00:00:00')) end_dt
10641 ,aei_information4 kind
10642 ,LEAST(fnd_number.canonical_to_number(aei_information5),1) * 100 value
10643 FROM per_assignment_extra_info paei
10644 WHERE paei.assignment_id = p_assignment_id
10645 AND aei_information4 IS NOT NULL
10646 AND paei.information_type = 'NL_ABP_PAR_INFO'
10647 AND fnd_date.canonical_to_date(aei_information1)
10648 < g_extract_params(p_business_group_id).extract_start_date
10649 AND EXISTS ( SELECT 1 FROM
10650 ben_ext_chg_evt_log blog
10651 WHERE blog.person_id = g_person_id
10652 AND blog.chg_evt_cd = 'COAPKOP'
10653 AND blog.prmtr_10 = paei.assignment_id
10654 AND fnd_number.canonical_to_number(blog.prmtr_03) = paei.assignment_extra_info_id
10655 AND fnd_date.canonical_to_date(blog.prmtr_09) BETWEEN
10656 g_extract_params(p_business_group_id).extract_start_date
10657 AND g_extract_params(p_business_group_id).extract_end_date)
10658 ORDER BY start_dt;
10659
10660 CURSOR c_chk_ptpn_continues (c_end_date IN DATE
10661 ,c_ptpn_kind IN VARCHAR2) IS
10662 SELECT 1
10663 FROM per_assignment_extra_info paei
10664 WHERE paei.assignment_id = p_assignment_id
10665 AND aei_information4 = c_ptpn_kind
10666 AND aei_information4 is not null
10667 AND paei.information_type = 'NL_ABP_PAR_INFO'
10668 AND fnd_date.canonical_to_date(aei_information1) = c_end_date + 1;
10669
10670 l_subcat VARCHAR2(100);
10671 i NUMBER := 0;
10672 x NUMBER := 0;
10673 l_dummy NUMBER;
10674
10675 BEGIN
10676
10677 --
10678 -- Derive all the start and end dates of participation for
10679 -- the retro period and current period
10680 --
10681 FOR l_asg_info_rec IN c_asg_kind_info
10682 LOOP
10683 IF i = 0 THEN
10684 --
10685 -- Create the row for the first time
10686 --
10687 i:= i + 1;
10688 p_retro_kind_ptpn(i).start_date := l_asg_info_rec.start_dt;
10689 p_retro_kind_ptpn(i).end_date := l_asg_info_rec.end_dt;
10690 p_retro_kind_ptpn(i).ptpn_kind := l_asg_info_rec.kind;
10691 p_retro_kind_ptpn(i).ptpn_val := l_asg_info_rec.value;
10692 ELSE
10693 --
10694 -- Create the row only if the dates are not continuous
10695 --
10696 IF l_asg_info_rec.start_dt <> p_retro_kind_ptpn(i).end_date + 1 AND
10697 l_asg_info_rec.kind <> p_retro_kind_ptpn(i).ptpn_kind THEN
10698 i:= i + 1;
10699 p_retro_kind_ptpn(i).start_date := l_asg_info_rec.start_dt;
10700 p_retro_kind_ptpn(i).end_date := l_asg_info_rec.end_dt;
10701 p_retro_kind_ptpn(i).ptpn_kind := l_asg_info_rec.kind;
10702 p_retro_kind_ptpn(i).ptpn_val := l_asg_info_rec.value;
10703 ELSE
10704 p_retro_kind_ptpn(i).end_date := l_asg_info_rec.end_dt;
10705 END IF;
10706 END IF;
10707 END LOOP; -- For the changes to dates in the assignment
10708
10709 IF p_retro_kind_ptpn.COUNT > 0 THEN
10710 x := p_retro_kind_ptpn.LAST;
10711 OPEN c_chk_ptpn_continues (p_retro_kind_ptpn(x).end_date,p_retro_kind_ptpn(x).ptpn_kind);
10712 FETCH c_chk_ptpn_continues INTO l_dummy;
10713 IF c_chk_ptpn_continues%FOUND THEN
10714 p_retro_kind_ptpn(x).end_date := NULL;
10715 END IF;
10716 CLOSE c_chk_ptpn_continues;
10717 END IF;
10718
10719 RETURN 0;
10720
10721 END Get_Retro_Kind_Of_Ptpn;
10722
10723 -- ============================================================================
10724 -- Function to get the retro participation of a particular sub category
10725 -- this function currently returns the start and end date of retro
10726 -- participation.
10727 -- ============================================================================
10728 FUNCTION Get_Retro_Participation
10729 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
10730 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
10731 ,p_sub_cat IN VARCHAR2
10732 ,p_effective_date IN DATE
10733 ,p_retro_ptpn OUT NOCOPY t_retro_ptpn
10734 ,p_error_message OUT NOCOPY VARCHAR2
10735 ) RETURN NUMBER IS
10736
10737 CURSOR c_ele_cur IS
10738 SELECT pet.element_type_id base_ele
10739 ,pei.eei_information12 sub_cat
10740 ,pei.eei_information18 cy_retro_ele
10741 ,pei.eei_information19 py_retro_ele
10742 ,pei.eei_information2 pt_id
10743 FROM pay_element_type_extra_info pei,
10744 pay_element_types_f pet
10745 WHERE pei.information_type = 'PQP_NL_ABP_DEDUCTION'
10746 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
10747 AND p_effective_date BETWEEN To_Date(pei.eei_information10,'DD/MM/RRRR') AND
10748 To_Date(pei.eei_information11,'DD/MM/RRRR')
10749 AND p_effective_date BETWEEN pet.effective_start_date AND
10750 pet.effective_end_date
10751 AND pet.element_type_id = pei.element_type_id
10752 AND pet.business_group_id = p_business_group_id
10753 AND pei.EEI_INFORMATION12 = p_sub_cat;
10754
10755 CURSOR c_asg_info ( c_pt_id IN NUMBER) IS
10756 SELECT fnd_date.canonical_to_date(aei_information1) start_dt
10757 ,fnd_date.canonical_to_date(NVL(aei_information2,'4712/12/31 00:00:00')) end_dt
10758 FROM per_assignment_extra_info paei
10759 WHERE paei.assignment_id = p_assignment_id
10760 AND fnd_number.canonical_to_number(aei_information3) = c_pt_id
10761 AND paei.information_type = 'NL_ABP_PI'
10762 AND fnd_date.canonical_to_date(aei_information1)
10763 BETWEEN g_extract_params(p_business_group_id).extract_start_date
10764 AND g_extract_params(p_business_group_id).extract_end_date
10765 AND NOT EXISTS ( SELECT 1
10766 FROM per_assignment_extra_info paei1
10767 WHERE paei1.assignment_id = p_assignment_id
10768 AND paei1.information_type = 'NL_ABP_PI'
10769 AND fnd_date.canonical_to_date(paei1.aei_information1) <
10770 g_extract_params(p_business_group_id).extract_start_date
10771 AND fnd_number.canonical_to_number(paei1.aei_information3) = c_pt_id
10772 AND fnd_date.canonical_to_date(NVL(paei1.aei_information2,'4712/12/31 00:00:00')) =
10773 fnd_date.canonical_to_date(NVL(paei.aei_information1,'4712/12/31 00:00:00')) -1
10774 )
10775 UNION
10776 SELECT fnd_date.canonical_to_date(aei_information1) start_dt
10777 ,fnd_date.canonical_to_date(NVL(aei_information2,'4712/12/31 00:00:00')) end_dt
10778 FROM per_assignment_extra_info paei
10779 WHERE paei.assignment_id = p_assignment_id
10780 AND fnd_number.canonical_to_number(aei_information3) = c_pt_id
10781 AND paei.information_type = 'NL_ABP_PI'
10782 AND fnd_date.canonical_to_date(aei_information1)
10783 < g_extract_params(p_business_group_id).extract_start_date
10784 AND EXISTS ( SELECT 1 FROM
10785 ben_ext_chg_evt_log blog
10786 WHERE blog.person_id = g_person_id
10787 AND blog.chg_evt_cd = 'COAPP'
10788 AND blog.prmtr_10 = paei.assignment_id
10789 AND fnd_number.canonical_to_number(blog.prmtr_03) = paei.assignment_extra_info_id
10790 AND fnd_date.canonical_to_date(blog.prmtr_09) BETWEEN
10791 g_extract_params(p_business_group_id).extract_start_date
10792 AND g_extract_params(p_business_group_id).extract_end_date)
10793 ORDER BY start_dt ;
10794
10795 CURSOR c_chk_ptpn_continues (c_end_date IN DATE,
10796 c_pt_id IN NUMBER) IS
10797 SELECT 1
10798 FROM per_assignment_extra_info paei
10799 WHERE paei.assignment_id = p_assignment_id
10800 AND fnd_number.canonical_to_number(aei_information3) = c_pt_id
10801 AND paei.information_type = 'NL_ABP_PI'
10802 AND fnd_date.canonical_to_date(aei_information1) = c_end_date + 1;
10803
10804 l_subcat VARCHAR2(100);
10805 i NUMBER := 0;
10806 x NUMBER := 0;
10807 l_ass_act_absent NUMBER;
10808 l_pt_id NUMBER;
10809 l_dummy NUMBER;
10810
10811 BEGIN
10812
10813 --
10814 -- For the elements created for the Sub Category
10815 --
10816 FOR l_ele_rec IN c_ele_cur
10817 LOOP
10818 --
10819 -- Derive all the start and end dates of participation for
10820 -- the retro period and current period it is possible that there is no end of
10821 -- participation. It is possible that the user has entered retro
10822 -- participation for two separate dates
10823 --
10824 FOR l_asg_info_rec IN c_asg_info (l_ele_rec.pt_id )
10825 LOOP
10826 l_pt_id := l_ele_rec.pt_id;
10827 IF i = 0 THEN
10828 --
10829 -- Create the row for the first time
10830 --
10831 i:= i + 1;
10832 p_retro_ptpn(i).start_date := l_asg_info_rec.start_dt;
10833 p_retro_ptpn(i).end_date := l_asg_info_rec.end_dt;
10834 p_retro_ptpn(i).ptid := l_ele_rec.pt_id;
10835 ELSE
10836 --
10837 -- Create the row only if the dates are not continuous
10838 --
10839 IF l_asg_info_rec.start_dt <> p_retro_ptpn(i).end_date + 1 THEN
10840 i:= i + 1;
10841 p_retro_ptpn(i).start_date := l_asg_info_rec.start_dt;
10842 p_retro_ptpn(i).end_date := l_asg_info_rec.end_dt;
10843 p_retro_ptpn(i).ptid := l_ele_rec.pt_id;
10844 ELSE
10845 p_retro_ptpn(i).end_date := l_asg_info_rec.end_dt;
10846 END IF;
10847 END IF;
10848 END LOOP; -- For the changes to dates in the assignment
10849 END LOOP; -- For each of the elements in the sub category
10850
10851 IF p_retro_ptpn.COUNT > 0 THEN
10852 x := p_retro_ptpn.LAST;
10853 OPEN c_chk_ptpn_continues (p_retro_ptpn(x).end_date,l_pt_id);
10854 FETCH c_chk_ptpn_continues INTO l_dummy;
10855 IF c_chk_ptpn_continues%FOUND THEN
10856 p_retro_ptpn(x).end_date := NULL;
10857 END IF;
10858 CLOSE c_chk_ptpn_continues;
10859 END IF;
10860
10861 RETURN 0;
10862
10863 END Get_Retro_Participation;
10864
10865
10866 /*PROCEDURE Populate_Term_Rev_Data
10867 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
10868 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
10869 ,p_end_date IN DATE
10870 ,p_start_date IN DATE
10871 ,p_error_message OUT NOCOPY VARCHAR2
10872 ) IS
10873 BEGIN
10874
10875
10876 --
10877 -- Derive the beginning date
10878 --
10879 l_beg_new_st := p_start_date;
10880 l_loop_end_date := p_end_date;
10881 l_loop_end_date := LEAST ( g_extract_params(p_business_group_id).extract_start_date -1
10882 ,l_loop_end_date);
10883 -- GZZ
10884 --
10885 --
10886 -- Loop through the dates to derive data to be reported to ABP
10887 -- this might include ony the differences of that period or the entire amount
10888 -- for the month
10889 --
10890 WHILE trunc(l_beg_new_st) < l_loop_end_date
10891 LOOP
10892 l_end_new_st := add_months(trunc(l_beg_new_st),1) -1;
10893 l_gzz_asg_act_xst := 0;
10894
10895 IF l_rec_09.count > 0 THEN
10896 FOR i IN l_rec_09.FIRST..l_rec_09.LAST
10897 LOOP
10898 l_rr_exists := 0;
10899 hr_utility.set_location('current element : '||l_rec_09(i).element_type_id,10);
10900 hr_utility.set_location('asg id : '||p_assignment_id,12);
10901 hr_utility.set_location('start date : ',14);
10902 hr_utility.set_location('end date : ',15);
10903 FOR act_rec IN csr_asg_act (
10904 c_assignment_id => p_assignment_id
10905 ,c_payroll_id => g_extract_params(p_business_group_id).payroll_id
10906 ,c_con_set_id => NULL
10907 ,c_start_date => l_beg_new_st
10908 ,c_end_date => l_end_new_st)
10909 LOOP
10910
10911 l_reg_09_age_cal_dt := l_beg_new_st;
10912 l_reg_09_age := Get_Age(p_assignment_id,trunc(l_reg_09_age_cal_dt)) ;
10913
10914 IF l_reg_09_age < 65 THEN
10915 -- Check if Run Results exist for this element/ass act
10916 IF chk_rr_exist (p_ass_act_id => act_rec.assignment_action_id
10917 ,p_element_type_id => l_rec_09(i).element_type_id ) THEN
10918 -- Call pay_balance_pkg
10919 hr_utility.set_location('run results exist for current period',40);
10920 IF l_rec_09(i).defined_bal_id <> -1 THEN
10921 l_rec_09_values(k).basis_amount :=
10922 Pay_Balance_Pkg.get_value
10923 (p_defined_balance_id => l_rec_09(i).defined_bal_id
10924 ,p_assignment_action_id => act_rec.assignment_action_id);
10925 hr_utility.set_location('defined bal id used :'||l_rec_09(i).defined_bal_id,50);
10926 l_rec_09_disp := 'Y';
10927 l_rec_09_values(k).processed := 'N';
10928 l_rec_09_values(k).code := l_rec_09(i).code;
10929 l_rec_09_values(k).date_earned :=
10930 substr(fnd_date.date_to_canonical(l_end_new_st),1,10);
10931
10932 OPEN c_09_abp_data (l_end_new_st,l_rec_09(i).code);
10933 FETCH c_09_abp_data INTO l_09_basis_amt_sent_prev;
10934 IF c_09_abp_data%FOUND THEN
10935 l_rec_09_values(k).basis_amount := l_rec_09_values(k).basis_amount
10936 - l_09_basis_amt_sent_prev;
10937 END IF;
10938 CLOSE c_09_abp_data;
10939
10940 IF l_rec_09_values(k).basis_amount < 0 THEN
10941 l_rec_09_values(k).sign_code := 'C';
10942 END IF;
10943 l_gzz_asg_act_xst := 1;
10944 k := k + 1;
10945 END IF;-- Defined bal check
10946 END IF;-- RR exist check
10947
10948 END IF; -- Age check
10949 END LOOP; -- Ass acts
10950 END LOOP; -- All elements for Rec 09
10951 END IF; -- Record 09 elements exist
10952
10953 l_beg_new_st := ADD_MONTHS(l_beg_new_st,1);
10954
10955 END LOOP; -- Loop through the months
10956
10957 END Populate_Term_Rev_Data;
10958 */
10959
10960 --============================================================================
10961 -- Record 05 Reporting
10962 -- This record is used to report the following incidents for FPU OPNP and PPP
10963 -- New Hire/Participation Start
10964 -- Participation End
10965 -- Retro changes
10966 -- Termination/ participation end
10967 -- Political leave
10968 --============================================================================
10969 FUNCTION Get_Rec05_Participation
10970 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
10971 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
10972 ,p_fetch_code IN VARCHAR2
10973 ,p_effective_date IN DATE
10974 ,p_error_message OUT NOCOPY VARCHAR2
10975 ,p_data_element_value OUT NOCOPY VARCHAR2)
10976 RETURN NUMBER IS
10977 --
10978 -- Cursor to find the org id for the current asg
10979 --
10980 CURSOR c_find_org_id IS
10981 SELECT organization_id
10982 FROM per_all_assignments_f
10983 WHERE assignment_id = p_assignment_id
10984 AND p_effective_date BETWEEN effective_start_date
10985 AND effective_end_date;
10986 --
10987 -- Cursor to fetch the kind and value of participation from the ASG EIT
10988 --
10989 CURSOR c_get_participation_detl IS
10990 SELECT Nvl(aei_information4,'WNE') kind,
10991 LEAST(Nvl(fnd_number.canonical_to_number(aei_information5),1),1) VALUE
10992 FROM per_assignment_extra_info
10993 WHERE information_type = 'NL_ABP_PAR_INFO'
10994 AND aei_information_category = 'NL_ABP_PAR_INFO'
10995 AND assignment_id = p_assignment_id
10996 AND p_effective_date BETWEEN Fnd_Date.canonical_to_date(aei_information1)
10997 AND Fnd_Date.canonical_to_date(Nvl(aei_information2,Fnd_Date.date_to_canonical(Hr_Api.g_eot)));
10998 --
10999 -- Cursor to get the hire date of the person
11000 --
11001 CURSOR c_hire_dt IS
11002 SELECT max(date_start)
11003 FROM per_all_assignments_f asg
11004 ,per_periods_of_service pps
11005 WHERE pps.person_id = asg.person_id
11006 AND asg.assignment_id = p_assignment_id
11007 AND pps.business_group_id = p_business_group_id
11008 AND date_start <= p_effective_date;
11009
11010 --
11011 -- Cursor to check if run results exist for any FPU/OPNP Pension Types
11012 -- for this assignment
11013 --
11014 CURSOR c_run_results_exist IS
11015 SELECT pty.pension_type_id
11016 ,pty.pension_sub_category sub_cat
11017 FROM pay_run_results prr,
11018 pay_payroll_actions ppa,
11019 pay_assignment_actions paa,
11020 pay_element_type_extra_info pei,
11021 pqp_pension_types_f pty
11022 WHERE paa.assignment_action_id = prr.assignment_action_id
11023 AND paa.payroll_action_id = ppa.payroll_action_id
11024 AND ppa.date_earned BETWEEN g_extract_params(p_business_group_id).extract_start_date
11025 AND g_extract_params(p_business_group_id).extract_end_date
11026 AND paa.assignment_id = p_assignment_id
11027 AND pei.element_type_id = prr.element_type_id
11028 AND pei.information_type = 'PQP_NL_ABP_DEDUCTION'
11029 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
11030 AND pei.eei_information2 = Fnd_Number.number_to_canonical(pty.pension_type_id)
11031 AND (pty.pension_sub_category LIKE 'FPU%'
11032 OR pty.pension_sub_category LIKE 'OPNP%'
11033 OR pty.pension_sub_category = 'PPP');
11034
11035 --
11036 -- Cursor to fetch the termination reason
11037 -- from the ben ext log table
11038 --
11039
11040 -- Bug# 6506736
11041 CURSOR c_get_end_reason IS
11042 SELECT /*decode(nvl(leaving_reason ,'A'),'D','I','A') term_reas*/
11043 decode(nvl(leaving_reason ,'A'),'D','I','B','B','A') term_reas
11044 FROM per_periods_of_service pps,
11045 per_all_assignments_f asg
11046 WHERE asg.period_of_service_id = pps.period_of_service_id
11047 AND assignment_id = p_assignment_id
11048 AND p_effective_date between effective_start_date and
11049 effective_end_date ;
11050
11051
11052 CURSOR c_hire_ptp_chg (c_asg_id IN NUMBER) IS
11053 SELECT asg.effective_start_date Start_Date
11054 ,asg.effective_end_date End_Date
11055 ,fnd_number.canonical_to_number(NVL(target.SEGMENT29,'100')) ptp
11056 FROM per_assignments_f asg
11057 ,hr_soft_coding_keyflex target
11058 ,per_assignment_status_types past
11059 WHERE target.soft_coding_keyflex_id = asg.soft_coding_keyflex_id
11060 AND asg.assignment_id = c_asg_id
11061 AND target.enabled_flag = 'Y'
11062 AND asg.assignment_status_type_id = past.assignment_status_type_id
11063 AND past.per_system_status = 'ACTIVE_ASSIGN'
11064 AND asg.effective_start_date BETWEEN
11065 trunc(g_extract_params(p_business_group_id).extract_start_date)
11066 AND trunc(g_extract_params(p_business_group_id).extract_end_date)
11067 ORDER BY START_DATE;
11068
11069 l_hire_ptp_chg c_hire_ptp_chg%ROWTYPE;
11070
11071 CURSOR c_hf_pos_cur (c_pos_id IN NUMBER)IS
11072 SELECT TRUNC(date_start)
11073 FROM per_periods_of_service
11074 WHERE period_of_service_id = c_pos_id
11075 AND TRUNC(date_start) = trunc(actual_termination_date);
11076
11077 CURSOR c_prev_term_dt (c_asg_seq_no IN VARCHAR2 ) IS
11078 SELECT dtl.val_07,
11079 DECODE(dtl.val_09,' ','A')
11080 FROM ben_ext_rslt_dtl dtl
11081 ,ben_ext_rslt res
11082 ,ben_ext_rcd rcd
11083 ,ben_ext_rcd_in_file rin
11084 ,ben_ext_dfn dfn
11085 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
11086 FROM pqp_extract_attributes
11087 WHERE ext_dfn_type = 'NL_FPR')
11088 and dtl.person_id = g_person_id
11089 and ext_stat_cd = 'A'
11090 AND TRUNC(res.eff_dt) < TRUNC(g_extract_params(p_business_group_id).extract_start_date)
11091 AND rin.ext_file_id = dfn.ext_file_id
11092 AND rin.ext_rcd_id = rcd.ext_rcd_id
11093 AND dfn.ext_dfn_id = res.ext_dfn_id
11094 and dtl.ext_rslt_id = res.ext_rslt_id
11095 AND dtl.ext_rcd_id = rcd.ext_rcd_id
11096 AND rin.seq_num = 5
11097 AND NVL(dtl.val_07,'X') <> '00000000'
11098 AND dtl.val_04 = c_asg_seq_no
11099 order by ext_rslt_dtl_id desc;
11100
11101 CURSOR c_prev_term_rev (c_asg_seq_no IN VARCHAR2
11102 ,c_in_term_date IN VARCHAR2) IS
11103 SELECT 1
11104 FROM ben_ext_rslt_dtl dtl
11105 ,ben_ext_rslt res
11106 ,ben_ext_rcd rcd
11107 ,ben_ext_rcd_in_file rin
11108 ,ben_ext_dfn dfn
11109 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
11110 FROM pqp_extract_attributes
11111 WHERE ext_dfn_type = 'NL_FPR')
11112 and dtl.person_id = g_person_id
11113 and ext_stat_cd = 'A'
11114 AND TRUNC(res.eff_dt) < TRUNC(g_extract_params(p_business_group_id).extract_start_date)
11115 AND rin.ext_file_id = dfn.ext_file_id
11116 AND rin.ext_rcd_id = rcd.ext_rcd_id
11117 AND dfn.ext_dfn_id = res.ext_dfn_id
11118 and dtl.ext_rslt_id = res.ext_rslt_id
11119 AND dtl.ext_rcd_id = rcd.ext_rcd_id
11120 AND rin.seq_num = 5
11121 AND NVL(dtl.val_05,'X') = '00000000'
11122 AND NVL(dtl.val_06,'X') = '00000000'
11123 AND NVL(dtl.val_07,'X') = '00000000'
11124 AND NVL(dtl.val_08,'X') = c_in_term_date
11125 AND dtl.val_04 = c_asg_seq_no
11126 order by ext_rslt_dtl_id desc;
11127
11128 -- Cursor to check if there is a change in hire date
11129 -- the change may be in the future or in the past
11130 -- with or without payroll runs
11131 CURSOR c_hire_dt_chg(c_person_id IN NUMBER
11132 ,c_start_date IN DATE
11133 ,c_end_date IN DATE) IS
11134 SELECT old_val1 old_date,
11135 new_val1 new_date
11136 FROM ben_ext_chg_evt_log
11137 WHERE person_id = c_person_id
11138 AND chg_evt_cd = 'COPOS'
11139 AND fnd_date.canonical_to_date(prmtr_09) BETWEEN c_start_date AND c_end_date
11140 ORDER BY ext_chg_evt_log_id desc;
11141
11142 CURSOR c_chk_ptpn_continues (c_end_date IN DATE,
11143 c_pt_id IN NUMBER) IS
11144 SELECT 1
11145 FROM per_assignment_extra_info paei
11146 WHERE paei.assignment_id = p_assignment_id
11147 AND fnd_number.canonical_to_number(aei_information3) = c_pt_id
11148 AND paei.information_type = 'NL_ABP_PI'
11149 AND fnd_date.canonical_to_date(aei_information1) = c_end_date + 1;
11150
11151 CURSOR c_chk_ptpn_continues_kind (c_end_date IN DATE
11152 ,c_ptpn_kind IN VARCHAR2) IS
11153 SELECT 1
11154 FROM per_assignment_extra_info paei
11155 WHERE paei.assignment_id = p_assignment_id
11156 AND aei_information4 = c_ptpn_kind
11157 AND aei_information4 is not null
11158 AND paei.information_type = 'NL_ABP_PAR_INFO'
11159 AND fnd_date.canonical_to_date(aei_information1) = c_end_date + 1;
11160
11161 CURSOR c_rec05_sub_cat IS
11162 SELECT lookup_code sub_cat, DECODE(lookup_code,'PPP','1'
11163 ,'OPNP','G'
11164 ,'OPNP_65','A'
11165 ,'OPNP_AOW','G'
11166 ,'OPNP_W25','B'
11167 ,'OPNP_W50','C'
11168 ,'FPU_B','S'
11169 ,'FPU_E','C'
11170 ,'FPU_R','A'
11171 ,'FPU_S','S'
11172 ,'FPU_T','B'
11173 ,' ') code
11174 FROM fnd_lookup_values
11175 WHERE lookup_type = 'PQP_PENSION_SUB_CATEGORY'
11176 AND lookup_code IN ('PPP','OPNP','OPNP_65','OPNP_AOW'
11177 ,'OPNP_W25','OPNP_W50','FPU_B','FPU_E'
11178 ,'FPU_R','FPU_S','FPU_T')
11179 AND NVL(enabled_flag,'N') = 'Y'
11180 AND language = 'US';
11181
11182 CURSOR c_rec05_sent IS
11183 SELECT 1
11184 FROM ben_ext_rslt_dtl dtl
11185 ,ben_ext_rslt res
11186 ,ben_ext_rcd rcd
11187 ,ben_ext_rcd_in_file rin
11188 ,ben_ext_dfn dfn
11189 WHERE dfn.ext_dfn_id IN (SELECT ext_dfn_id
11190 FROM pqp_extract_attributes
11191 WHERE ext_dfn_type = 'NL_FPR')
11192 and dtl.person_id = g_person_id
11193 and ext_stat_cd = 'A'
11194 AND TRUNC(res.eff_dt) < TRUNC(g_extract_params(p_business_group_id).extract_start_date)
11195 AND rin.ext_file_id = dfn.ext_file_id
11196 AND rin.ext_rcd_id = rcd.ext_rcd_id
11197 AND dfn.ext_dfn_id = res.ext_dfn_id
11198 and dtl.ext_rslt_id = res.ext_rslt_id
11199 AND dtl.ext_rcd_id = rcd.ext_rcd_id
11200 AND rin.seq_num = 5;
11201
11202 CURSOR c_copos_ptp_chg (c_asg_id IN NUMBER
11203 ,c_eff_date IN DATE ) IS
11204 SELECT fnd_number.canonical_to_number(NVL(target.SEGMENT29,'100')) ptp
11205 FROM per_assignments_f asg
11206 ,hr_soft_coding_keyflex target
11207 ,per_assignment_status_types past
11208 WHERE target.soft_coding_keyflex_id = asg.soft_coding_keyflex_id
11209 AND asg.assignment_id = c_asg_id
11210 AND target.enabled_flag = 'Y'
11211 AND asg.assignment_status_type_id = past.assignment_status_type_id
11212 AND past.per_system_status = 'ACTIVE_ASSIGN'
11213 AND trunc(c_eff_date) BETWEEN asg.effective_start_date AND
11214 asg.effective_end_date
11215 order by asg.effective_start_date;
11216
11217 CURSOR c_pay_id IS
11218 SELECT payroll_id
11219 FROM per_all_assignments_f
11220 WHERE assignment_id = p_assignment_id
11221 AND p_effective_date BETWEEN effective_start_date AND
11222 effective_end_date;
11223
11224 --6501898
11225 --Commented for 6959318
11226 /*CURSOR c_get_term_dt IS
11227 SELECT MIN(effective_start_date) - 1 term_date
11228 FROM per_all_assignments_f asg
11229 WHERE assignment_id = p_assignment_id
11230 AND assignment_status_type_id IN (SELECT assignment_status_type_id
11231 FROM per_assignment_status_types
11232 WHERE per_system_status = 'TERM_ASSIGN'
11233 AND active_flag = 'Y')
11234 AND assignment_type = 'E';*/
11235
11236 --13571541
11237 CURSOR c_rec05_curr_ptp_end_date IS
11238 SELECT 'Y'
11239 FROM pay_element_types_f petf
11240 ,pay_element_entries_f peef
11241 WHERE petf.element_name = 'ABP flex workers PTP End Date'
11242 AND petf.element_type_id = peef.element_type_id
11243 AND peef.assignment_id = p_assignment_id
11244 AND p_effective_date BETWEEN peef.effective_start_date
11245 AND peef.effective_end_date;
11246 --13571541
11247
11248 l_chg_eff_dt ben_ext_chg_evt_log.chg_eff_dt%TYPE;
11249 l_chg_evt_cd ben_ext_chg_evt_log.chg_evt_cd%TYPE;
11250 l_active_assg NUMBER;
11251 l_rec05_sent NUMBER;
11252 l_prior_ptp NUMBER;
11253 l_dummy NUMBER;
11254 l_hf_pos_dt DATE;
11255 l_proc_name VARCHAR2(150) := g_proc_name ||'get_rec05_participation';
11256 l_return_value NUMBER := -1;
11257 l_named_hierarchy NUMBER;
11258 l_version_id
11259 per_org_structure_versions_v.org_structure_version_id%TYPE DEFAULT NULL;
11260 l_asg_rows_exist NUMBER;
11261 l_org_rows_exist NUMBER;
11262 l_kind VARCHAR2(30) := 'WNE';
11263 l_value VARCHAR2(30) := '100';
11264 l_value_num NUMBER;
11265 l_old_date1 ben_ext_chg_evt_log.old_val1%TYPE;
11266 l_new_date1 ben_ext_chg_evt_log.new_val1%TYPE;
11267 l_old_date2 ben_ext_chg_evt_log.old_val1%TYPE;
11268 l_new_date2 ben_ext_chg_evt_log.new_val1%TYPE;
11269 l_term_log_id ben_ext_chg_evt_log.ext_chg_evt_log_id%TYPE;
11270 l_revt_log_id ben_ext_chg_evt_log.ext_chg_evt_log_id%TYPE;
11271 l_reason VARCHAR2(1);
11272 l_old_term_reason VARCHAR2(1);
11273 l_org_id NUMBER;
11274 l_ppp_start ben_ext_chg_evt_log.new_val1%TYPE;
11275 l_ppp_end ben_ext_chg_evt_log.new_val2%TYPE;
11276 l_ppp_found NUMBER := 0;
11277 l_ppp_kind VARCHAR2(1) := ' ';
11278 l_ppp_ret NUMBER;
11279 l_ppp_err VARCHAR2(1000);
11280 i NUMBER := 0;
11281 l_loop_again NUMBER;
11282 l_flag NUMBER := 0;
11283 l_hire_date DATE;
11284 l_pt_id NUMBER;
11285 l_end_date DATE;
11286 l_hired NUMBER := 0;
11287 l_ret_val NUMBER;
11288 l_ret_val1 NUMBER;
11289 l_hire_date1 DATE;
11290 l_retro_ptp_index NUMBER;
11291 l_ptp NUMBER(9,2);
11292 l_partn_rows_exist NUMBER := 0;
11293 l_term_rows_exist NUMBER := 0;
11294 l_age NUMBER;
11295 l_old_hire DATE;
11296 l_new_hire DATE;
11297 l_retro_hired NUMBER := 0;
11298 l_fpu_ret_val NUMBER;
11299 l_ptp_row_ins NUMBER := 0;
11300 l_abp_pen_rr NUMBER;
11301 l_payroll_id NUMBER;
11302 l_new_hire_row NUMBER;
11303 l_terminated_row NUMBER;
11304 l_term_pos_id NUMBER;
11305 l_opnp_ret_val NUMBER;
11306 l_prev_term_dt VARCHAR2(8);
11307 l_old_hire_dt DATE;
11308 l_new_hire_dt DATE;
11309 l_old_hire_dt_can ben_ext_chg_evt_log.old_val1%TYPE;
11310 l_new_hire_dt_can ben_ext_chg_evt_log.new_val1%TYPE;
11311 l_out_retro_ptpn t_retro_ptpn;
11312 l_out_retro_ptpn_kind t_retro_ptpn_kind;
11313 l_ge_retro_ptpn NUMBER;
11314 l_ge_retro_ptpn_kind NUMBER;
11315 l_ret_index_05 NUMBER;
11316 l_ret_index_05_kind NUMBER;
11317 w NUMBER;
11318 l_kind_change_exists NUMBER;
11319 l_copos_xst NUMBER;
11320 l_copos_ptp NUMBER;
11321 l_new_hire_ee_chk NUMBER := 0;
11322 l_ret_val_asg NUMBER;
11323 l_seq_num VARCHAR2(2);
11324 l_asg_termination_dt DATE;
11325 l_prev_term_rev NUMBER;
11326 --6501898
11327 l_hrly_ptp_rec c_ptp_chg_hrly_exist%ROWTYPE;
11328 l_asg_term_dt DATE;
11329
11330 l_ele_exists VARCHAR2(1); --13571541
11331
11332 BEGIN
11333
11334 Hr_Utility.set_location('Entering:------'||l_proc_name, 2);
11335 Hr_Utility.set_location('....Value of assignment id : '||p_assignment_id,4);
11336 Hr_Utility.set_location('....Value of g_index : '||g_index_05,6);
11337 Hr_Utility.set_location('....Value of g_count : '||g_count_05,8);
11338 Hr_Utility.set_location('....Value of fetch code : '||p_fetch_code ,10);
11339
11340 --
11341 -- Derive the age of the employee
11342 --
11343 l_age := Get_Age(p_assignment_id,p_effective_date);
11344
11345 Hr_Utility.set_location('....Value of l_age : '||l_age ,12);
11346
11347 IF g_index_05 = 0
11348 AND p_fetch_code = 'NEW_ST'
11349 AND g_abp_processed_flag = 1 THEN
11350
11351 Hr_Utility.set_location('....Populating the PLSQL Table for the first time : ',12);
11352
11353 g_count_05 := 0;
11354 l_rec_05_disp := 'N';
11355
11356 OPEN c_get_participation_detl;
11357 FETCH c_get_participation_detl INTO l_kind,l_value;
11358 IF c_get_participation_detl%FOUND THEN
11359 CLOSE c_get_participation_detl;
11360 ELSE
11361 CLOSE c_get_participation_detl;
11362 l_kind := 'WNE';
11363 l_value := '1';
11364 END IF;
11365
11366 l_value_num := fnd_number.canonical_to_number(l_value);
11367 l_value_num := l_value_num * 100;
11368 l_value := fnd_number.number_to_canonical(l_value_num);
11369
11370 Hr_Utility.set_location('....Value of l_value : '||l_value ,14);
11371 Hr_Utility.set_location('....Value of l_kind : '||l_kind ,16);
11372
11373 --
11374 -- Check if the EE assignment is a new hire and to be reported.
11375 --
11376 IF g_new_hire_asg = 1 THEN
11377 l_hired := 1;
11378 ELSE
11379 l_hired := 0;
11380 END IF;
11381
11382 l_hire_date := g_hire_date;
11383
11384 IF l_hired = 1 THEN
11385 --
11386 -- Derive the part time percentage to be reported for a new hire
11387 --
11388 OPEN c_cur_ptp (l_hire_date,p_assignment_id);
11389
11390 FETCH c_cur_ptp INTO l_ptp;
11391 IF c_cur_ptp%FOUND THEN
11392 l_ptp := l_ptp * 100;
11393 hr_utility.set_location('....Found PTP : '||l_ptp,28);
11394 ELSE
11395 l_ptp := 0;
11396 hr_utility.set_location('....Did not find PTP : '||l_ptp,28);
11397 END IF;
11398 CLOSE c_cur_ptp;
11399
11400 -- 6501898 : For declarant new hires, check if PTP is entered in the current period
11401 -- through an Hours element
11402 /* Commented for Bug 6959318
11403 IF l_ptp = 0 THEN
11404 --
11405 OPEN c_get_retro_ele('ABP Pensions Part Time Percentage'
11406 ,'Part Time Percentage');
11407 FETCH c_get_retro_ele INTO g_abp_ptp_iv_id,g_abp_ptp_ele_id;
11408 CLOSE c_get_retro_ele;
11409 --
11410 OPEN c_ptp_chg_hrly_exist (c_asg_id => p_assignment_id
11411 ,c_effective_date => l_hire_date
11412 ,c_ele_type_id => g_abp_ptp_ele_id
11413 ,c_input_val_id => g_abp_ptp_iv_id);
11414
11415 FETCH c_ptp_chg_hrly_exist INTO l_hrly_ptp_rec;
11416 --
11417 IF c_ptp_chg_hrly_exist%FOUND THEN
11418 OPEN c_get_term_dt;
11419 FETCH c_get_term_dt INTO l_asg_term_dt;
11420 IF c_get_term_dt%NOTFOUND THEN
11421 l_asg_term_dt := NULL;
11422 END IF;
11423 CLOSE c_get_term_dt;
11424 l_ptp := l_hrly_ptp_rec.ptp * 100;
11425 --Bug# 5973446
11426 l_ptp :=
11427 l_ptp *
11428 (
11429 ((l_hrly_ptp_rec.end_date - l_hrly_ptp_rec.start_date)+1)
11430 /
11431 (LEAST(l_hrly_ptp_rec.end_date,nvl(l_asg_term_dt,l_hrly_ptp_rec.end_date)) -
11432 GREATEST(l_hire_date,l_hrly_ptp_rec.start_date)+1)
11433 );
11434 --Bug# 5973446
11435 ELSE
11436 l_ptp := 0;
11437 END IF;
11438 --
11439 CLOSE c_ptp_chg_hrly_exist;
11440 --
11441 END IF;*/
11442 -- End of 6501898
11443
11444 hr_utility.set_location('....Value of PTP is : '||l_ptp,28);
11445
11446 END IF;
11447
11448 Hr_Utility.set_location('....New hire flag is l_hired : '||l_hired ,18);
11449
11450 -- ==========================================================================
11451 -- BEGIN NEW HIRE PARTICIPATION REPORTING SECTION
11452 -- ==========================================================================
11453 IF l_hired = 1 THEN
11454
11455 OPEN c_pay_id;
11456 FETCH c_pay_id INTO l_payroll_id;
11457 CLOSE c_pay_id;
11458
11459 IF g_abp_processed_flag = 1 THEN
11460 --
11461 -- ABP Pensions has been processed on new hire. Create a new hire row
11462 --
11463 g_rec05_rows(i).new_start := Fnd_Date.date_to_canonical(l_hire_date);
11464 g_rec05_rows(i).dt_chg := NULL;
11465 g_rec05_rows(i).old_start := NULL;
11466 g_rec05_rows(i).end_reason := NULL;
11467 g_rec05_rows(i).eddt_chg := NULL;
11468 g_rec05_rows(i).end_reason := ' ';
11469 g_rec05_rows(i).old_end := NULL;
11470 g_rec05_rows(i).new_end := NULL;
11471 g_rec05_rows(i).partn_kind := l_kind;
11472 g_rec05_rows(i).partn_value := l_value;
11473 g_rec05_rows(i).part_time_perc := l_ptp;
11474
11475 l_ppp_ret := Get_PPP_Kind
11476 (p_assignment_id => p_assignment_id
11477 ,p_business_group_id => p_business_group_id
11478 ,p_effective_date => p_effective_date
11479 ,p_current => 'Y'
11480 ,p_error_message => l_ppp_err
11481 ,p_data_element_value => g_rec05_rows(i).ppp_kind );
11482
11483 IF l_ppp_ret <> 0 THEN
11484 g_rec05_rows(i).ppp_kind := '0';
11485 END IF;
11486
11487 l_fpu_ret_val := Get_FPU_Kind
11488 (p_assignment_id
11489 ,p_business_group_id
11490 ,p_effective_date
11491 ,p_error_message
11492 ,g_rec05_rows(i).fpu_kind);
11493
11494 l_opnp_ret_val := Get_OPNP_Kind
11495 ( p_assignment_id
11496 ,p_business_group_id
11497 ,p_effective_date
11498 ,p_error_message
11499 ,g_rec05_rows(i).opnp_kind);
11500
11501 l_new_hire_row := i;
11502 i := i + 1;
11503 g_count_05 := i;
11504
11505 END IF; -- Check if ABP is processed
11506
11507 END IF; -- Check for New hire
11508
11509 -- ==========================================================================
11510 -- END NEW HIRE PARTICIPATION REPORTING SECTION
11511 -- ==========================================================================
11512
11513 -- ==========================================================================
11514 -- BEGIN RETRO HIRE CHECK SECTION
11515 -- ==========================================================================
11516 l_copos_xst := 0;
11517
11518 OPEN c_hire_dt_chg(c_person_id => g_person_id
11519 ,c_start_date => g_extract_params(p_business_group_id).extract_start_date
11520 ,c_end_date => g_extract_params(p_business_group_id).extract_end_date);
11521 FETCH c_hire_dt_chg INTO l_old_hire_dt_can,l_new_hire_dt_can;
11522
11523 IF c_hire_dt_chg%FOUND THEN
11524 l_old_hire_dt := to_nl_date(l_old_hire_dt_can,'DD-MM-RRRR');
11525 l_new_hire_dt := to_nl_date(l_new_hire_dt_can,'DD-MM-RRRR');
11526
11527 l_copos_xst := 1;
11528
11529 IF l_hired = 1 THEN
11530 --
11531 -- Update the existing row for reporting the change
11532 --
11533 g_rec05_rows(l_new_hire_row).old_start := Fnd_Date.date_to_canonical(l_hire_date);
11534 g_rec05_rows(l_new_hire_row).new_start := fnd_date.date_to_canonical(l_new_hire_dt);
11535
11536 OPEN c_copos_ptp_chg (c_asg_id => p_assignment_id
11537 ,c_eff_date => trunc(l_new_hire_dt));
11538 FETCH c_copos_ptp_chg INTO l_copos_ptp;
11539 CLOSE c_copos_ptp_chg;
11540 IF l_copos_ptp IS NOT NULL THEN
11541 g_rec05_rows(l_new_hire_row).part_time_perc := l_copos_ptp * 100 ;
11542 END IF;
11543
11544 ELSIF l_hired = 0 THEN
11545 --
11546 -- Create a new Record 05 for reporting the change in hire dt
11547 --
11548 g_rec05_rows(i).new_end := NULL;
11549 g_rec05_rows(i).old_end := NULL;
11550 g_rec05_rows(i).new_start := Fnd_Date.date_to_canonical(l_new_hire_dt);
11551 g_rec05_rows(i).old_start := Fnd_Date.date_to_canonical(l_old_hire_dt);
11552 g_rec05_rows(i).partn_kind := NULL;
11553 g_rec05_rows(i).partn_value := ' ';
11554 g_rec05_rows(i).part_time_perc := NULL;
11555 g_rec05_rows(i).dt_chg := NULL;
11556 g_rec05_rows(i).eddt_chg := NULL;
11557 g_rec05_rows(i).end_reason := ' ';
11558 g_rec05_rows(i).ppp_kind := ' ';
11559 g_rec05_rows(i).fpu_kind := ' ';
11560 g_rec05_rows(i).opnp_kind := ' ';
11561 g_rec05_rows(i).pos_id := NULL;
11562 i := i + 1;
11563 g_count_05 := i;
11564 --
11565 END IF;
11566
11567 OPEN c_rec05_sent;
11568 FETCH c_rec05_sent INTO l_rec05_sent;
11569 IF c_rec05_sent%NOTFOUND THEN
11570 -- record 05 was not sent earlier
11571 g_rec05_rows(i-1).old_start := NULL;
11572 END IF;
11573 CLOSE c_rec05_sent;
11574
11575 END IF;
11576 CLOSE c_hire_dt_chg;
11577
11578 -- ==========================================================================
11579 -- END RETRO HIRE CHECK SECTION
11580 -- ==========================================================================
11581
11582 -- ==========================================================================
11583 -- BEGIN RETRO CHANGE IN PART TIME PERCENTAGE SECTION
11584 -- ==========================================================================
11585 -- Reporting Retro changes to part time percentage
11586 -- This section contains Record 05 Rows that appear due to change
11587 -- in part time percentage in the prior periods
11588 -- Sections 1,2,3,4 Should be filled with appropriate values
11589 -- Sections 5,6,7 and 8 should contain 00000000
11590 -- Sections 9,11,12,13,14,15 should contain white spaces
11591 -- Section 10 should contain the part time percentage change effective st dt
11592 -- Section 17 should contain the part time percentage change effective ed dt
11593 -- Section 16 should contain the part time percentage.
11594 --
11595 IF g_retro_ptp_count > 0 THEN
11596
11597 hr_utility.set_location('....Found retro entries for PTP elements: ',24);
11598 hr_utility.set_location('....Value of g_retro_ptp_count is : '||g_retro_ptp_count,22);
11599
11600 --13571541
11601 OPEN c_rec05_curr_ptp_end_date;
11602 FETCH c_rec05_curr_ptp_end_date into l_ele_exists;
11603 CLOSE c_rec05_curr_ptp_end_date;
11604 --13571541
11605
11606 hr_utility.set_location('....Value of l_ele_exists is : '||l_ele_exists,20);
11607
11608 FOR l_retro_ptp_index IN 1..g_retro_ptp_count
11609 LOOP
11610 hr_utility.set_location('....Looping through retro PTP entries : '||i,24);
11611 g_rec05_rows(i).partn_kind := ' ';
11612 g_rec05_rows(i).partn_value := ' ';
11613 g_rec05_rows(i).end_reason := ' ';
11614 g_rec05_rows(i).ppp_kind := ' ';
11615 g_rec05_rows(i).fpu_kind := ' ';
11616 g_rec05_rows(i).opnp_kind := ' ';
11617 g_rec05_rows(i).old_start := NULL;
11618 g_rec05_rows(i).old_end := NULL;
11619 g_rec05_rows(i).new_start := NULL;
11620 g_rec05_rows(i).new_end := NULL;
11621 g_rec05_rows(i).dt_chg := fnd_date.date_to_canonical
11622 (l_rec_05_retro_ptp(l_retro_ptp_index).start_date);
11623 hr_utility.set_location('....Change date st : '||g_rec05_rows(i).dt_chg,24);
11624 IF l_rec_05_retro_ptp(l_retro_ptp_index).end_date >=
11625 trunc(g_extract_params(p_business_group_id).extract_end_date) THEN
11626 g_rec05_rows(i).eddt_chg := NULL;
11627
11628 --13571541
11629 IF nvl(l_ele_exists,'N') = 'Y' THEN
11630 g_rec05_rows(i).eddt_chg := fnd_date.date_to_canonical(l_rec_05_retro_ptp(l_retro_ptp_index).end_date);
11631 END IF;
11632 --13571541
11633
11634 ELSE
11635 g_rec05_rows(i).eddt_chg := fnd_date.date_to_canonical(l_rec_05_retro_ptp(l_retro_ptp_index).end_date);
11636 END IF;
11637
11638 hr_utility.set_location('....Change date End : '||g_rec05_rows(i).eddt_chg,24);
11639 g_rec05_rows(i).part_time_perc := l_rec_05_retro_ptp(l_retro_ptp_index).part_time_perc;
11640 hr_utility.set_location('....Changed PTP : '||g_rec05_rows(i).part_time_perc,24);
11641
11642 i := i + 1;
11643
11644 END LOOP;
11645 g_count_05 := i;
11646 l_partn_rows_exist := 1;
11647 l_rec_05_retro_ptp.DELETE;
11648
11649 END IF; -- Check if there are retro ptp chanegs to be reported
11650
11651 hr_utility.set_location('....Completed Rec 05 Retro PTP Changes : ',24);
11652 -- ==========================================================================
11653 -- END RETRO CHANGE IN PART TIME PERCENTAGE SECTION
11654 -- ==========================================================================
11655
11656 -- ==========================================================================
11657 -- BEGIN TERMINATION AND REVERSAL OF TERMINATION SECTION
11658 -- ==========================================================================
11659 l_terminated_row := -1;
11660
11661 l_ret_val_asg := Get_Asg_Seq_Num(p_assignment_id
11662 ,p_business_group_id
11663 ,p_effective_date
11664 ,p_error_message
11665 ,l_seq_num);
11666
11667
11668 OPEN c_get_asg_term_date (p_business_group_id
11669 ,p_effective_date
11670 ,p_assignment_id
11671 ,l_seq_num);
11672 FETCH c_get_asg_term_date INTO l_asg_termination_dt,l_term_pos_id;
11673
11674 IF c_get_asg_term_date%FOUND THEN
11675 --
11676 -- Termination Date was found for the assignment
11677 --
11678 --
11679 -- Derive the termination reason
11680 --
11681
11682 OPEN c_get_end_reason;
11683 FETCH c_get_end_reason INTO l_reason;
11684 IF c_get_end_reason%NOTFOUND THEN
11685 l_reason := 'A';
11686 END IF;
11687 CLOSE c_get_end_reason;
11688
11689 OPEN c_prev_term_dt(l_seq_num) ;
11690 FETCH c_prev_term_dt INTO l_prev_term_dt,l_old_term_reason;
11691 IF c_prev_term_dt%NOTFOUND THEN
11692 --
11693 -- Termination was never reported to ABP Report it now.
11694 --
11695 g_rec05_rows(i).new_end := NVL(fnd_date.date_to_canonical(
11696 l_asg_termination_dt),'');
11697 g_rec05_rows(i).old_end := NULL;
11698 g_rec05_rows(i).new_start := '';
11699 g_rec05_rows(i).old_start := '';
11700 g_rec05_rows(i).partn_kind := NULL;
11701 g_rec05_rows(i).partn_value := ' ';
11702 g_rec05_rows(i).part_time_perc := NULL;
11703 g_rec05_rows(i).ppp_kind := ' ';
11704 g_rec05_rows(i).fpu_kind := ' ';
11705 g_rec05_rows(i).opnp_kind := ' ';
11706 g_rec05_rows(i).dt_chg := '';
11707 g_rec05_rows(i).eddt_chg := '';
11708 g_rec05_rows(i).end_reason := l_reason;
11709 g_rec05_rows(i).pos_id := l_term_pos_id;
11710 l_terminated_row := i;
11711 i := i + 1;
11712 g_count_05 := i;
11713 l_term_rows_exist := 1;
11714 ELSIF c_prev_term_dt%FOUND AND TRUNC(fnd_date.canonical_to_date(l_prev_term_dt))
11715 <> TRUNC(l_asg_termination_dt) + 1
11716 THEN
11717 --
11718 -- Termination date has changed from the prev reported value.
11719 -- Report the old and new dates
11720 --
11721 g_rec05_rows(i).new_end := nvl(fnd_date.date_to_canonical(
11722 l_asg_termination_dt),'');
11723 OPEN c_prev_term_rev(l_seq_num,l_prev_term_dt);
11724 FETCH c_prev_term_rev INTO l_prev_term_rev;
11725 IF c_prev_term_rev%NOTFOUND THEN
11726 g_rec05_rows(i).old_end := fnd_date.date_to_canonical(
11727 fnd_date.canonical_to_date(l_prev_term_dt) - 1);
11728 ELSE
11729 g_rec05_rows(i).old_end := NULL;
11730 END IF;
11731 g_rec05_rows(i).new_start := '';
11732 g_rec05_rows(i).old_start := '';
11733 g_rec05_rows(i).partn_kind := NULL;
11734 g_rec05_rows(i).partn_value := ' ';
11735 g_rec05_rows(i).part_time_perc := NULL;
11736 g_rec05_rows(i).ppp_kind := ' ';
11737 g_rec05_rows(i).fpu_kind := ' ';
11738 g_rec05_rows(i).opnp_kind := ' ';
11739 g_rec05_rows(i).dt_chg := '';
11740 g_rec05_rows(i).eddt_chg := '';
11741 IF l_reason <> NVL(l_old_term_reason,'A') THEN
11742 g_rec05_rows(i).end_reason := l_reason;
11743 ELSE
11744 g_rec05_rows(i).end_reason := ' ';
11745 END IF;
11746 g_rec05_rows(i).pos_id := l_term_pos_id;
11747 l_terminated_row := i;
11748 i := i + 1;
11749 g_count_05 := i;
11750 l_term_rows_exist := 1;
11751
11752 END IF;
11753
11754 CLOSE c_prev_term_dt;
11755
11756 ELSIF c_get_asg_term_date%NOTFOUND THEN
11757
11758 OPEN c_prev_term_dt(l_seq_num) ;
11759 FETCH c_prev_term_dt INTO l_prev_term_dt,l_old_term_reason;
11760 IF c_prev_term_dt%FOUND THEN
11761 --
11762 -- Ensure that term reversal was not reported earlier
11763 --
11764 OPEN c_prev_term_rev(l_seq_num,l_prev_term_dt);
11765 FETCH c_prev_term_rev INTO l_prev_term_rev;
11766 IF c_prev_term_rev%NOTFOUND THEN
11767 --
11768 -- Termination reversal was never reported to ABP Report it now.
11769 --
11770 g_rec05_rows(i).new_end := NULL;
11771 g_rec05_rows(i).old_end := fnd_date.date_to_canonical(
11772 fnd_date.canonical_to_date(l_prev_term_dt) - 1);
11773 g_rec05_rows(i).new_start := '';
11774 g_rec05_rows(i).old_start := '';
11775 g_rec05_rows(i).partn_kind := NULL;
11776 g_rec05_rows(i).partn_value := ' ';
11777 g_rec05_rows(i).part_time_perc := NULL;
11778 g_rec05_rows(i).ppp_kind := ' ';
11779 g_rec05_rows(i).fpu_kind := ' ';
11780 g_rec05_rows(i).opnp_kind := ' ';
11781 g_rec05_rows(i).dt_chg := '';
11782 g_rec05_rows(i).eddt_chg := '';
11783 g_rec05_rows(i).end_reason := ' ';
11784 g_rec05_rows(i).pos_id := NULL;
11785 i := i + 1;
11786 g_count_05 := i;
11787 END IF;
11788 CLOSE c_prev_term_rev;
11789 END IF;
11790 CLOSE c_prev_term_dt;
11791
11792 END IF;
11793
11794 CLOSE c_get_asg_term_date;
11795
11796
11797 IF l_hired = 1 AND l_terminated_row <> -1 THEN
11798 --
11799 -- Termination has happened in the same month as the hire.
11800 -- Record 05 should not be reported twice. It should be reported only once
11801 -- Update the new hire row and delete the termination row.
11802 --
11803 g_rec05_rows(l_new_hire_row).new_end :=
11804 g_rec05_rows(l_terminated_row).new_end;
11805 g_rec05_rows(l_new_hire_row).end_reason :=
11806 g_rec05_rows(l_terminated_row).end_reason;
11807 g_rec05_rows.DELETE(l_terminated_row);
11808 g_count_05 := g_count_05 - 1 ;
11809
11810 END IF;
11811
11812 IF l_hired = 0 AND l_terminated_row <> -1 THEN
11813 IF g_rec05_rows(l_terminated_row).pos_id IS NOT NULL THEN
11814 OPEN c_hf_pos_cur(g_rec05_rows(l_terminated_row).pos_id);
11815 FETCH c_hf_pos_cur INTO l_hf_pos_dt;
11816 IF c_hf_pos_cur%FOUND THEN
11817 g_rec05_rows(l_terminated_row).new_start := NULL;
11818 g_rec05_rows(l_terminated_row).dt_chg := NULL;
11819 g_rec05_rows(l_terminated_row).old_start := fnd_date.date_to_canonical(l_hf_pos_dt);
11820 g_rec05_rows(l_terminated_row).end_reason := NULL;
11821 g_rec05_rows(l_terminated_row).eddt_chg := NULL;
11822 g_rec05_rows(l_terminated_row).end_reason := NULL;
11823 g_rec05_rows(l_terminated_row).old_end := NULL;
11824 g_rec05_rows(l_terminated_row).new_end := NULL;
11825 g_rec05_rows(l_terminated_row).partn_kind := NULL;
11826 g_rec05_rows(l_terminated_row).partn_value := ' ';
11827 g_rec05_rows(l_terminated_row).part_time_perc := NULL;
11828 g_rec05_rows(l_terminated_row).ppp_kind := ' ';
11829 g_rec05_rows(l_terminated_row).fpu_kind := ' ';
11830 g_rec05_rows(l_terminated_row).opnp_kind := ' ';
11831 g_rec05_rows(l_terminated_row).end_reason := ' ';
11832 END IF;
11833 END IF;
11834 END IF;
11835
11836 -- ==========================================================================
11837 -- END TERMINATION AND REVERSAL OF TERMINATION SECTION
11838 -- ==========================================================================
11839 l_kind_change_exists := 0;
11840
11841 IF l_hired = 0 THEN
11842
11843 l_ge_retro_ptpn_kind := Get_Retro_Kind_Of_Ptpn
11844 (p_assignment_id => p_assignment_id
11845 ,p_business_group_id => p_business_group_id
11846 ,p_effective_date => p_effective_date
11847 ,p_retro_kind_ptpn => l_out_retro_ptpn_kind
11848 ,p_error_message => p_error_message);
11849 IF l_out_retro_ptpn_kind.COUNT > 0 THEN
11850
11851 l_ret_index_05_kind := l_out_retro_ptpn_kind.LAST;
11852 FOR w IN 1..l_ret_index_05_kind LOOP
11853 IF l_out_retro_ptpn_kind.EXISTS(w) THEN
11854 g_rec05_rows(i).new_end := NULL;
11855 g_rec05_rows(i).old_end := NULL;
11856 g_rec05_rows(i).new_start := NULL;
11857 g_rec05_rows(i).old_start := NULL;
11858 g_rec05_rows(i).partn_kind := l_out_retro_ptpn_kind(w).ptpn_kind;
11859 g_rec05_rows(i).partn_value := l_out_retro_ptpn_kind(w).ptpn_val;
11860 g_rec05_rows(i).part_time_perc := NULL;
11861 g_rec05_rows(i).fpu_kind := ' ';
11862 g_rec05_rows(i).opnp_kind := ' ';
11863 g_rec05_rows(i).ppp_kind := ' ';
11864 g_rec05_rows(i).dt_chg := fnd_date.date_to_canonical(l_out_retro_ptpn_kind(w).start_date);
11865 IF fnd_date.date_to_canonical(TRUNC(l_out_retro_ptpn_kind(w).end_date)) =
11866 '4712/12/31 00:00:00' THEN
11867 g_rec05_rows(i).eddt_chg := NULL;
11868
11869 ELSE
11870
11871 OPEN c_chk_ptpn_continues_kind ( l_out_retro_ptpn_kind(w).end_date
11872 ,l_out_retro_ptpn_kind(w).ptpn_kind);
11873 FETCH c_chk_ptpn_continues_kind INTO l_dummy;
11874 IF c_chk_ptpn_continues_kind%NOTFOUND THEN
11875 g_rec05_rows(i).eddt_chg := fnd_date.date_to_canonical(l_out_retro_ptpn_kind(w).end_date);
11876 ELSE
11877 g_rec05_rows(i).eddt_chg := NULL;
11878 END IF;
11879 CLOSE c_chk_ptpn_continues_kind;
11880 END IF;
11881
11882 g_rec05_rows(i).end_reason := '';
11883 l_kind_change_exists := 1;
11884
11885 i := i + 1;
11886 g_count_05 := i;
11887 END IF;
11888 END LOOP;
11889
11890 l_out_retro_ptpn_kind.DELETE;
11891
11892 END IF;
11893
11894 END IF; -- New Hire check
11895
11896 -- ==========================================================================
11897 -- BEGIN RETRO ORG AND ASG PARTICIPATION SECTION
11898 -- ==========================================================================
11899 IF l_copos_xst = 0 THEN
11900
11901 IF l_hired = 0 AND l_kind_change_exists = 0 THEN
11902
11903 FOR l_rec05_sub_cat IN c_rec05_sub_cat LOOP
11904
11905 l_ge_retro_ptpn := Get_Retro_Participation
11906 (p_assignment_id => p_assignment_id
11907 ,p_business_group_id => p_business_group_id
11908 ,p_sub_cat => l_rec05_sub_cat.sub_cat
11909 ,p_effective_date => p_effective_date
11910 ,p_retro_ptpn => l_out_retro_ptpn
11911 ,p_error_message => p_error_message);
11912 IF l_out_retro_ptpn.COUNT > 0 THEN
11913
11914 l_ret_index_05 := l_out_retro_ptpn.LAST;
11915 FOR w IN 1..l_ret_index_05 LOOP
11916 IF l_out_retro_ptpn.EXISTS(w) THEN
11917 g_rec05_rows(i).new_end := NULL;
11918 g_rec05_rows(i).old_end := NULL;
11919 g_rec05_rows(i).new_start := NULL;
11920 g_rec05_rows(i).old_start := NULL;
11921 g_rec05_rows(i).partn_kind := NULL;
11922 g_rec05_rows(i).partn_value := ' ';
11923 g_rec05_rows(i).part_time_perc := NULL;
11924
11925 IF l_rec05_sub_cat.sub_cat LIKE 'PPP%' THEN
11926 g_rec05_rows(i).ppp_kind := l_rec05_sub_cat.code;
11927 g_rec05_rows(i).fpu_kind := ' ';
11928 g_rec05_rows(i).opnp_kind := ' ';
11929 ELSIF l_rec05_sub_cat.sub_cat LIKE 'FPU%' THEN
11930 g_rec05_rows(i).ppp_kind := ' ';
11931 g_rec05_rows(i).fpu_kind := l_rec05_sub_cat.code;
11932 g_rec05_rows(i).opnp_kind := ' ';
11933 ELSIF l_rec05_sub_cat.sub_cat LIKE 'OPNP%' THEN
11934 g_rec05_rows(i).ppp_kind := ' ';
11935 g_rec05_rows(i).fpu_kind := ' ';
11936 g_rec05_rows(i).opnp_kind := l_rec05_sub_cat.code;
11937 END IF;
11938
11939 g_rec05_rows(i).dt_chg := fnd_date.date_to_canonical(l_out_retro_ptpn(w).start_date);
11940 IF fnd_date.date_to_canonical(TRUNC(l_out_retro_ptpn(w).end_date)) =
11941 '4712/12/31 00:00:00' THEN
11942 g_rec05_rows(i).eddt_chg := NULL;
11943
11944 ELSE
11945
11946 OPEN c_chk_ptpn_continues ( l_out_retro_ptpn(w).end_date
11947 ,l_out_retro_ptpn(w).ptid);
11948 FETCH c_chk_ptpn_continues INTO l_dummy;
11949 IF c_chk_ptpn_continues%NOTFOUND THEN
11950 g_rec05_rows(i).eddt_chg := fnd_date.date_to_canonical(l_out_retro_ptpn(w).end_date);
11951 ELSE
11952 g_rec05_rows(i).eddt_chg := NULL;
11953 END IF;
11954 CLOSE c_chk_ptpn_continues;
11955 END IF;
11956
11957 g_rec05_rows(i).end_reason := '';
11958
11959 i := i + 1;
11960 g_count_05 := i;
11961 END IF;
11962 END LOOP;
11963
11964 l_out_retro_ptpn.DELETE;
11965
11966 END IF;
11967
11968 END LOOP;
11969
11970 END IF; -- New Hire check
11971
11972 END IF;
11973
11974 -- ==========================================================================
11975 -- END RETRO ORG AND ASG PARTICIPATION SECTION
11976 -- ==========================================================================
11977
11978 -- ============================================================================
11979 -- BEGIN Section to add part time percentage change rows if there are changes
11980 -- in the month of hire
11981 -- ============================================================================
11982 IF l_copos_xst = 1 THEN
11983 l_hire_date := l_new_hire_dt;
11984 END IF;
11985
11986 IF l_hired = 1 THEN
11987
11988 l_prior_ptp := g_rec05_rows(l_new_hire_row).part_time_perc/100;
11989
11990 FOR hire_ptp_rec IN c_hire_ptp_chg (p_assignment_id) LOOP
11991
11992 IF hire_ptp_rec.start_date > l_hire_date THEN
11993 hr_utility.set_location('....Start Date > Hire Date : ',24);
11994
11995 IF hire_ptp_rec.ptp <> l_prior_ptp THEN
11996 hr_utility.set_location('....Inserting Rec 05 as PTP has changed : ',24);
11997 g_rec05_rows(i).partn_kind := ' ';
11998 g_rec05_rows(i).partn_value := ' ';
11999 g_rec05_rows(i).end_reason := ' ';
12000 g_rec05_rows(i).ppp_kind := ' ';
12001 g_rec05_rows(i).opnp_kind := ' ';
12002 g_rec05_rows(i).fpu_kind := ' ';
12003 g_rec05_rows(i).old_start := NULL;
12004 g_rec05_rows(i).old_end := NULL;
12005 g_rec05_rows(i).new_start := NULL;
12006 g_rec05_rows(i).new_end := NULL;
12007 g_rec05_rows(i).dt_chg := fnd_date.date_to_canonical
12008 (hire_ptp_rec.start_date);
12009 hr_utility.set_location('....Start Date is : '||hire_ptp_rec.start_date,24);
12010 hr_utility.set_location('....End Date is : '||hire_ptp_rec.end_date,24);
12011
12012 IF hire_ptp_rec.end_date >=
12013 trunc(g_extract_params(p_business_group_id).extract_end_date) THEN
12014 g_rec05_rows(i).eddt_chg := NULL;
12015 ELSE
12016 g_rec05_rows(i).eddt_chg := fnd_date.date_to_canonical
12017 (hire_ptp_rec.end_date);
12018 END IF;
12019
12020 hr_utility.set_location('....PTP is : '||hire_ptp_rec.ptp,24);
12021 g_rec05_rows(i).part_time_perc := hire_ptp_rec.ptp * 100;
12022 i := i + 1;
12023 g_count_05 := i;
12024 l_ptp_row_ins := 1;
12025 hr_utility.set_location('....Value of i is : '||i,24);
12026 hr_utility.set_location('....Value of g_count_05 is : '||g_count_05,24);
12027
12028 ELSIF hire_ptp_rec.ptp = l_prior_ptp AND l_ptp_row_ins = 1 THEN
12029 -- Assign the new end date to the prior row
12030 hr_utility.set_location('....Inside the IF condition to update the end date: ',24);
12031 hr_utility.set_location('....Ed Dt is : '||hire_ptp_rec.end_date,24);
12032
12033 IF hire_ptp_rec.end_date >=
12034 trunc(g_extract_params(p_business_group_id).extract_end_date) THEN
12035 g_rec05_rows(i-1).eddt_chg := NULL;
12036 ELSE
12037 g_rec05_rows(i-1).eddt_chg := fnd_date.date_to_canonical
12038 (hire_ptp_rec.end_date);
12039 END IF;
12040
12041 END IF;
12042
12043 END IF;
12044 l_prior_ptp := hire_ptp_rec.ptp;
12045 hr_utility.set_location('....Value of l_prior_ptp is : '||l_prior_ptp,24);
12046
12047 END LOOP;
12048
12049 END IF; -- Check if the EE is a new hire
12050 -- ============================================================================
12051 -- END Section to add part time percentage change rows if there are changes
12052 -- in the month of hire
12053 -- ============================================================================
12054
12055 END IF;
12056
12057 IF g_count_05 > 0 THEN
12058
12059 l_rec_05_disp := 'Y';
12060 Hr_Utility.set_location('----Old start date is : '||g_rec05_rows(g_index_05).old_start,88);
12061 Hr_Utility.set_location('----New start date is : '||g_rec05_rows(g_index_05).new_start,90);
12062 Hr_Utility.set_location('----Old end date is : '||g_rec05_rows(g_index_05).old_end,92);
12063 Hr_Utility.set_location('----New end date is : '||g_rec05_rows(g_index_05).new_end,94);
12064 Hr_Utility.set_location('----Kind of participation is : '||g_rec05_rows(g_index_05).partn_kind,96);
12065 Hr_Utility.set_location('----Value of participation is : '||g_rec05_rows(g_index_05).partn_value,98);
12066 Hr_Utility.set_location('----Change start date is : '||g_rec05_rows(g_index_05).dt_chg,100);
12067 Hr_Utility.set_location('----Change end date is : '||g_rec05_rows(g_index_05).eddt_chg,102);
12068 Hr_Utility.set_location('----End reason is : '||g_rec05_rows(g_index_05).end_reason,104);
12069 Hr_Utility.set_location('----Part Time Percent is : '||g_rec05_rows(g_index_05).part_time_perc,106);
12070
12071 l_return_value := 0;
12072
12073 --
12074 -- Depending on the fetch code, set the data element value
12075 --
12076 IF p_fetch_code = 'NEW_ST' THEN
12077 p_data_element_value := g_rec05_rows(g_index_05).new_start;
12078 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
12079 (Fnd_Date.canonical_to_date(p_data_element_value),
12080 'YYYYMMDD');
12081 ELSIF p_fetch_code = 'OLD_ST' THEN
12082 p_data_element_value := g_rec05_rows(g_index_05).old_start;
12083 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
12084 (Fnd_Date.canonical_to_date(p_data_element_value),
12085 'YYYYMMDD');
12086 ELSIF p_fetch_code = 'NEW_ED' THEN
12087 IF g_rec05_rows(g_index_05).new_end IS NOT NULL THEN
12088 g_rec05_rows(g_index_05).new_end :=
12089 fnd_date.date_to_canonical(fnd_date.canonical_to_date(g_rec05_rows(g_index_05).new_end) + 1);
12090 END IF;
12091 p_data_element_value := g_rec05_rows(g_index_05).new_end;
12092 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
12093 (Fnd_Date.canonical_to_date(p_data_element_value),
12094 'YYYYMMDD');
12095 ELSIF p_fetch_code = 'OLD_ED' THEN
12096 IF g_rec05_rows(g_index_05).old_end IS NOT NULL THEN
12097 g_rec05_rows(g_index_05).old_end :=
12098 fnd_date.date_to_canonical(fnd_date.canonical_to_date(g_rec05_rows(g_index_05).old_end) + 1);
12099 END IF;
12100 p_data_element_value := g_rec05_rows(g_index_05).old_end;
12101 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
12102 (Fnd_Date.canonical_to_date(p_data_element_value),
12103 'YYYYMMDD');
12104 ELSIF p_fetch_code = 'P_KIND' THEN
12105 p_data_element_value := g_rec05_rows(g_index_05).partn_kind;
12106 ELSIF p_fetch_code = 'P_VALUE' THEN
12107 IF g_rec05_rows(g_index_05).partn_kind = 'WVP' THEN
12108 hr_utility.set_location('.... political leave',110);
12109 p_data_element_value := '0';
12110 ELSIF l_age >= 65 THEN
12111 hr_utility.set_location('....age => 65 ',110);
12112 IF g_rec05_rows(g_index_05).partn_value <> ' ' THEN
12113 p_data_element_value := '0';
12114 ELSE
12115 p_data_element_value := ' ';
12116 END IF;
12117 ELSE
12118 p_data_element_value := g_rec05_rows(g_index_05).partn_value;
12119 hr_utility.set_location('....age < 65 and not on political leave',112);
12120 END IF;
12121 ELSIF p_fetch_code = 'DT_CHG' THEN
12122 p_data_element_value := g_rec05_rows(g_index_05).dt_chg;
12123 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
12124 (Fnd_Date.canonical_to_date(p_data_element_value),
12125 'YYYYMMDD');
12126 ELSIF p_fetch_code = 'EDDT_CHG' THEN
12127
12128 IF g_rec05_rows(g_index_05).eddt_chg IS NOT NULL THEN
12129 IF fnd_date.canonical_to_date(g_rec05_rows(g_index_05).eddt_chg) >
12130 trunc(g_extract_params(p_business_group_id).extract_end_date) THEN
12131 g_rec05_rows(g_index_05).eddt_chg := NULL;
12132 END IF;
12133 END IF;
12134
12135 IF g_rec05_rows(g_index_05).eddt_chg IS NOT NULL THEN
12136 g_rec05_rows(g_index_05).eddt_chg :=
12137 fnd_date.date_to_canonical(fnd_date.canonical_to_date(g_rec05_rows(g_index_05).eddt_chg) + 1);
12138 END IF;
12139 p_data_element_value := g_rec05_rows(g_index_05).eddt_chg;
12140 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
12141 (Fnd_Date.canonical_to_date(p_data_element_value),
12142 'YYYYMMDD');
12143 ELSIF p_fetch_code = 'END_REASON' THEN
12144 p_data_element_value := g_rec05_rows(g_index_05).end_reason;
12145 ELSIF p_fetch_code = 'PPP_KIND' THEN
12146 IF (g_rec05_rows(g_index_05).new_start IS NOT NULL AND
12147 NVL(g_rec05_rows(g_index_05).ppp_kind,0) = 0) THEN
12148 p_data_element_value := ' ';
12149 ELSE
12150 p_data_element_value := g_rec05_rows(g_index_05).ppp_kind;
12151 END IF;
12152 ELSIF p_fetch_code = 'FPU_KIND' THEN
12153 p_data_element_value := g_rec05_rows(g_index_05).fpu_kind;
12154 ELSIF p_fetch_code = 'OPNP_KIND' THEN
12155 p_data_element_value := g_rec05_rows(g_index_05).opnp_kind;
12156 ELSIF p_fetch_code = 'PART_TIME_PERC' THEN
12157 IF g_rec05_rows(g_index_05).part_time_perc IS NULL THEN
12158 p_data_element_value := ' ';
12159 ELSE
12160 p_data_element_value := fnd_number.number_to_canonical
12161 (g_rec05_rows(g_index_05).part_time_perc);
12162 END IF;
12163 END IF;
12164
12165 ELSE
12166 p_data_element_value := '';
12167 l_rec_05_disp := 'N';
12168 l_return_value := 0;
12169 END IF;
12170
12171 Hr_Utility.set_location('....Final value of p_data_element_value is : '||p_data_element_value, 114);
12172 Hr_Utility.set_location('Leaving: '||l_proc_name, 116);
12173 Hr_Utility.set_location(' ', 118);
12174 l_return_value :=0;
12175
12176 RETURN l_return_value;
12177 EXCEPTION
12178 WHEN Others THEN
12179 p_error_message :='SQL-ERRM :'||SQLERRM;
12180 Hr_Utility.set_location('..'||p_error_message,85);
12181 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
12182 RETURN l_return_value;
12183 END Get_Rec05_Participation;
12184
12185 --============================================================================
12186 --This is used to derive the participation start and end dates and the old start and
12187 --end dates in case of an update for IPAP Pensions
12188 --============================================================================
12189 FUNCTION Get_Ipap_Participation_Dates
12190 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
12191 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
12192 ,p_fetch_code IN Varchar2
12193 ,p_effective_date IN Date
12194 ,p_error_message OUT NOCOPY Varchar2
12195 ,p_data_element_value OUT NOCOPY Varchar2
12196 ) RETURN Number IS
12197
12198 --cursor to check if ASG EIT rows exist
12199 CURSOR c_asg_rows_exist IS
12200 SELECT 1
12201 FROM ben_ext_chg_evt_log bec,pqp_pension_types_f pty
12202 WHERE chg_evt_cd = 'COAPPD'
12203 AND prmtr_01 = 'ASG'
12204 AND Fnd_Number.canonical_to_number(prmtr_02) = pty.pension_type_id
12205 AND pty.pension_sub_category = 'IPAP'
12206 AND prmtr_03 = 'Y'
12207 AND Fnd_Number.canonical_to_number(prmtr_10) = p_assignment_id
12208 AND person_id = (SELECT person_id
12209 FROM per_all_assignments_f
12210 WHERE assignment_id = p_assignment_id
12211 AND p_effective_date BETWEEN effective_start_date
12212 AND effective_end_date
12213 )
12214 AND bec.business_group_id = p_business_group_id;
12215
12216 --cursor to check if ORG EIT rows exist
12217 CURSOR c_org_rows_exist(c_org_id IN Number) IS
12218 SELECT 1
12219 FROM ben_ext_chg_evt_log bec,pqp_pension_types_f pty
12220 WHERE chg_evt_cd = 'COAPPD'
12221 AND prmtr_01 = 'ORG'
12222 AND Fnd_Number.canonical_to_number(prmtr_02) = pty.pension_type_id
12223 AND pty.pension_sub_category = 'IPAP'
12224 AND prmtr_03 = 'Y'
12225 AND Fnd_Number.canonical_to_number(prmtr_04) = c_org_id
12226 AND bec.business_group_id = p_business_group_id;
12227
12228 --cursor to get the old and new start and end dates from the ASG EIT
12229 CURSOR c_get_asg_rows IS
12230 SELECT old_val1,new_val1,old_val2,new_val2
12231 FROM ben_ext_chg_evt_log bec,pqp_pension_types_f pty
12232 WHERE chg_evt_cd = 'COAPPD'
12233 AND prmtr_01 = 'ASG'
12234 AND Fnd_Number.canonical_to_number(prmtr_02) = pty.pension_type_id
12235 AND prmtr_03 = 'Y'
12236 AND Fnd_Number.canonical_to_number(prmtr_10) = p_assignment_id
12237 AND pty.pension_sub_category = 'IPAP'
12238 AND person_id = (SELECT person_id
12239 FROM per_all_assignments_f
12240 WHERE assignment_id = p_assignment_id
12241 AND p_effective_date BETWEEN effective_start_date
12242 AND effective_end_date
12243 )
12244 AND bec.business_group_id = p_business_group_id
12245 AND chg_eff_dt BETWEEN g_extract_params(p_business_group_id).extract_start_date
12246 AND g_extract_params(p_business_group_id).extract_end_date
12247 ORDER BY ext_chg_evt_log_id;
12248
12249 --cursor to get the old and new start and end dates from the ORG EIT
12250 CURSOR c_get_org_rows(c_org_id IN Number,c_hire_date IN Date) IS
12251 SELECT old_val1,new_val1,old_val2,new_val2
12252 FROM ben_ext_chg_evt_log bec,pqp_pension_types_f pty
12253 WHERE chg_evt_cd = 'COAPPD'
12254 AND prmtr_01 = 'ORG'
12255 AND Fnd_Number.canonical_to_number(prmtr_02) = pty.pension_type_id
12256 AND prmtr_03 = 'Y'
12257 AND pty.pension_sub_category = 'IPAP'
12258 AND Fnd_Number.canonical_to_number(prmtr_04) = c_org_id
12259 AND bec.business_group_id = p_business_group_id
12260 AND chg_eff_dt BETWEEN g_extract_params(p_business_group_id).extract_start_date
12261 AND g_extract_params(p_business_group_id).extract_end_date
12262 AND chg_eff_dt >= c_hire_date
12263 ORDER BY ext_chg_evt_log_id;
12264
12265 --Cursor to find the named hierarchy associated with the BG
12266 CURSOR c_find_named_hierarchy IS
12267 SELECT org_information1
12268 FROM hr_organization_information
12269 WHERE organization_id = p_business_group_id
12270 AND org_information_context = 'NL_BG_INFO';
12271
12272 --Cursor to find the valid version id for the particular named hierarchy
12273 CURSOR c_find_ver_frm_hierarchy(c_hierarchy_id IN Number) IS
12274 SELECT ORG_STRUCTURE_VERSION_ID
12275 FROM per_org_structure_versions_v
12276 WHERE organization_structure_id = c_hierarchy_id
12277 AND p_effective_date BETWEEN date_from
12278 AND Nvl(date_to,Hr_Api.g_eot);
12279
12280 --Cursor to find the valid version id for a particular business group
12281 CURSOR c_find_ver_frm_bg IS
12282 SELECT ORG_STRUCTURE_VERSION_ID
12283 FROM per_org_structure_versions_v
12284 WHERE business_group_id = p_business_group_id
12285 AND p_effective_date BETWEEN date_from
12286 AND Nvl( date_to,Hr_Api.g_eot);
12287
12288 --Cursor to find the parent id from the org id
12289 CURSOR c_find_parent_id(c_org_id IN Number
12290 ,c_version_id IN Number) IS
12291 SELECT organization_id_parent
12292 FROM per_org_structure_elements
12293 WHERE organization_id_child = c_org_id
12294 AND org_structure_version_id = c_version_id
12295 AND business_group_id = p_business_group_id;
12296
12297 --cursor to find the org id for the current asg
12298 CURSOR c_find_org_id IS
12299 SELECT organization_id
12300 FROM per_all_assignments_f
12301 WHERE assignment_id = p_assignment_id
12302 AND p_effective_date BETWEEN effective_start_date
12303 AND effective_end_date;
12304
12305 -- Cursor to get the hire date of the person
12306 CURSOR c_hire_dt IS
12307 SELECT max(date_start)
12308 FROM per_all_assignments_f asg
12309 ,per_periods_of_service pps
12310 WHERE pps.person_id = asg.person_id
12311 AND asg.assignment_id = p_assignment_id
12312 AND pps.business_group_id = p_business_group_id
12313 AND date_start <= p_effective_date;
12314
12315 --cursor to check if run results exist for any IPAP Pension Types for this assignment
12316 CURSOR c_run_results_exist IS
12317 SELECT pty.pension_type_id
12318 FROM pay_run_results prr,
12319 pay_payroll_actions ppa,
12320 pay_assignment_actions paa,
12321 pay_element_type_extra_info pei,
12322 pqp_pension_types_f pty
12323 WHERE paa.assignment_action_id = prr.assignment_action_id
12324 AND paa.payroll_action_id = ppa.payroll_action_id
12325 AND ppa.date_earned BETWEEN g_extract_params(p_business_group_id).extract_start_date
12326 AND g_extract_params(p_business_group_id).extract_end_date
12327 AND paa.assignment_id = p_assignment_id
12328 AND pei.element_type_id = prr.element_type_id
12329 AND pei.information_type = 'PQP_NL_ABP_DEDUCTION'
12330 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
12331 AND pei.eei_information2 = Fnd_Number.number_to_canonical(pty.pension_type_id)
12332 AND pty.pension_sub_category = 'IPAP';
12333
12334 l_proc_name Varchar2(150) := g_proc_name ||'get_ipap_participation_dates';
12335 l_return_value Number := -1;
12336 l_named_hierarchy Number;
12337 l_version_id per_org_structure_versions_v.org_structure_version_id%TYPE DEFAULT NULL;
12338 l_asg_rows_exist Number;
12339 l_org_rows_exist Number;
12340 l_org_id Number;
12341 i Number := 0;
12342 l_loop_again Number;
12343 l_hire_date Date;
12344 l_hired Number := 0;
12345 l_ret_val Number;
12346 l_end_date Date;
12347
12348
12349 BEGIN
12350 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
12351 --check the index and the code and calculate the value accordingly
12352 Hr_Utility.set_location('value of g_index : '||g_index_ipap,7);
12353 Hr_Utility.set_location('value of fetch code : '||p_fetch_code ,10);
12354 IF g_index_ipap = 0 AND p_fetch_code = 'NEW_ST' THEN
12355 g_count_ipap := 0;
12356
12357 OPEN c_hire_dt;
12358 FETCH c_hire_dt INTO l_hire_date;
12359 CLOSE c_hire_dt;
12360 IF l_hire_date BETWEEN g_extract_params(p_business_group_id).extract_start_date
12361 AND g_extract_params(p_business_group_id).extract_end_date THEN
12362 l_hired := 1;
12363 END IF;
12364
12365 OPEN c_asg_rows_exist;
12366 FETCH c_asg_rows_exist INTO l_asg_rows_exist;
12367 IF c_asg_rows_exist%FOUND THEN
12368 CLOSE c_asg_rows_exist;
12369 Hr_Utility.set_location('found rows at the assignment eit level',15);
12370 --now fetch the rows from the log table
12371 FOR asg_rec IN c_get_asg_rows
12372 LOOP
12373 IF asg_rec.old_val1 IS NOT NULL THEN
12374 IF asg_rec.old_val1 <> asg_rec.new_val1 THEN
12375 g_ipap_dates(i).old_start := asg_rec.old_val1;
12376 g_ipap_dates(i).new_start := asg_rec.new_val1;
12377 ELSE
12378 g_ipap_dates(i).old_start := '';
12379 g_ipap_dates(i).new_start := asg_rec.new_val1;
12380 END IF;
12381 ELSIF asg_rec.new_val1 IS NOT NULL THEN
12382 g_ipap_dates(i).old_start := '';
12383 g_ipap_dates(i).new_start := asg_rec.new_val1;
12384 ELSE
12385 g_ipap_dates(i).old_start := '';
12386 g_ipap_dates(i).new_start := '';
12387 END IF;
12388 IF asg_rec.old_val2 IS NOT NULL THEN
12389 IF asg_rec.old_val2 <> asg_rec.new_val2 THEN
12390 g_ipap_dates(i).old_end := asg_rec.old_val2;
12391 g_ipap_dates(i).new_end := asg_rec.new_val2;
12392 ELSE
12393 g_ipap_dates(i).old_end := '';
12394 g_ipap_dates(i).new_end := asg_rec.new_val2;
12395 END IF;
12396 ELSIF asg_rec.new_val2 IS NOT NULL THEN
12397 g_ipap_dates(i).old_end := '';
12398 g_ipap_dates(i).new_end := asg_rec.new_val2;
12399 ELSE
12400 g_ipap_dates(i).old_end := '';
12401 g_ipap_dates(i).new_end := '';
12402 END IF;
12403 i := i + 1;
12404 END LOOP;
12405 g_count_ipap := i;
12406 Hr_Utility.set_location('count of rows : '||g_count_ipap,20);
12407 ELSE
12408 CLOSE c_asg_rows_exist;
12409 --go up the org hierarchy to find the rows at some org eit level
12410 -- find the org the assignment is attached to
12411 OPEN c_find_org_id;
12412 FETCH c_find_org_id INTO l_org_id;
12413 CLOSE c_find_org_id;
12414
12415 --first chk to see if a named hierarchy exists for the BG
12416 OPEN c_find_named_hierarchy;
12417 FETCH c_find_named_hierarchy INTO l_named_hierarchy;
12418 -- if a named hiearchy is found , find the valid version on that date
12419 IF c_find_named_hierarchy%FOUND THEN
12420 CLOSE c_find_named_hierarchy;
12421 -- now find the valid version on that date
12422 OPEN c_find_ver_frm_hierarchy(l_named_hierarchy);
12423 FETCH c_find_ver_frm_hierarchy INTO l_version_id;
12424 --if no valid version is found, try to get it frm the BG
12425 IF c_find_ver_frm_hierarchy%NOTFOUND THEN
12426 CLOSE c_find_ver_frm_hierarchy;
12427 -- find the valid version id from the BG
12428 OPEN c_find_ver_frm_bg;
12429 FETCH c_find_ver_frm_bg INTO l_version_id;
12430 CLOSE c_find_ver_frm_bg;
12431 -- else a valid version has been found for the named hierarchy
12432 ELSE
12433 CLOSE c_find_ver_frm_hierarchy;
12434 END IF; --end of if no valid version found
12435 -- else find the valid version from BG
12436 ELSE
12437 CLOSE c_find_named_hierarchy;
12438 --now find the version number from the BG
12439 OPEN c_find_ver_frm_bg;
12440 FETCH c_find_ver_frm_bg INTO l_version_id;
12441 CLOSE c_find_ver_frm_bg;
12442 END IF; -- end of if named hierarchy found
12443
12444 -- loop through the org hierarchy to find the participation start date at
12445 -- this org level or its parents
12446 l_loop_again := 1;
12447 WHILE (l_loop_again = 1)
12448
12449 LOOP
12450 Hr_Utility.set_location('searching at org level : '||l_org_id,25);
12451 OPEN c_org_rows_exist(l_org_id);
12452 FETCH c_org_rows_exist INTO l_org_rows_exist;
12453 IF c_org_rows_exist%FOUND THEN
12454 CLOSE c_org_rows_exist;
12455 FOR org_rec IN c_get_org_rows(l_org_id,l_hire_date)
12456 LOOP
12457 IF org_rec.old_val1 IS NOT NULL THEN
12458 IF org_rec.old_val1 <> org_rec.new_val1 THEN
12459 g_ipap_dates(i).old_start := org_rec.old_val1;
12460 g_ipap_dates(i).new_start := org_rec.new_val1;
12461 ELSE
12462 g_ipap_dates(i).old_start := '';
12463 g_ipap_dates(i).new_start := org_rec.new_val1;
12464 END IF;
12465 ELSIF org_rec.new_val1 IS NOT NULL THEN
12466 g_ipap_dates(i).old_start := '';
12467 g_ipap_dates(i).new_start := org_rec.new_val1;
12468 ELSE
12469 g_ipap_dates(i).old_start := '';
12470 g_ipap_dates(i).new_start := '';
12471 END IF;
12472 IF org_rec.old_val2 IS NOT NULL THEN
12473 IF org_rec.old_val2 <> org_rec.new_val2 THEN
12474 g_ipap_dates(i).old_end := org_rec.old_val2;
12475 g_ipap_dates(i).new_end := org_rec.new_val2;
12476 ELSE
12477 g_ipap_dates(i).old_end := '';
12478 g_ipap_dates(i).new_end := org_rec.new_val2;
12479 END IF;
12480 ELSIF org_rec.new_val2 IS NOT NULL THEN
12481 g_ipap_dates(i).old_end := '';
12482 g_ipap_dates(i).new_end := org_rec.new_val2;
12483 ELSE
12484 g_ipap_dates(i).old_end := '';
12485 g_ipap_dates(i).new_end := '';
12486 END IF;
12487 IF l_hired = 1 THEN
12488 Hr_Utility.set_location('hire date : '||l_hire_date,99);
12489 Hr_Utility.set_location('new date : '||g_ipap_dates(i).new_start,100);
12490 Hr_Utility.set_location('greater date : '||Fnd_Date.date_to_canonical(Greatest(
12491 l_hire_date,Fnd_Date.canonical_to_date(g_ipap_dates(i).new_start))),101);
12492 IF g_ipap_dates(i).new_start IS NOT NULL THEN
12493 Hr_Utility.set_location('chking the new start date',102);
12494 g_ipap_dates(i).new_start := Fnd_Date.date_to_canonical(Greatest(
12495 l_hire_date,Fnd_Date.canonical_to_date(g_ipap_dates(i).new_start)));
12496 Hr_Utility.set_location('new start date is : '||g_ipap_dates(i).new_start,103);
12497 END IF;
12498 IF g_ipap_dates(i).old_start IS NOT NULL THEN
12499 g_ipap_dates(i).old_start := Fnd_Date.date_to_canonical(Greatest(
12500 l_hire_date,Fnd_Date.canonical_to_date(g_ipap_dates(i).old_start)));
12501 END IF;
12502 END IF;
12503 IF g_ipap_dates(i).new_start = g_ipap_dates(i).old_start THEN
12504 g_ipap_dates(i).old_start := '';
12505 END IF;
12506
12507 i := i + 1;
12508 END LOOP;
12509 g_count_ipap := i;
12510 Hr_Utility.set_location('value for g count : '||g_count_ipap,30);
12511 l_loop_again := 0;
12512 ELSE
12513 --search at the parent level next
12514 CLOSE c_org_rows_exist;
12515 OPEN c_find_parent_id(l_org_id,l_version_id);
12516 FETCH c_find_parent_id INTO l_org_id;
12517 IF c_find_parent_id%NOTFOUND THEN
12518 l_loop_again := 0;
12519 CLOSE c_find_parent_id;
12520 ELSE
12521 CLOSE c_find_parent_id;
12522 END IF;
12523 END IF;
12524 END LOOP;
12525 END IF;
12526 --if no changes have occured,check if participation has occured due to employement start
12527 --if so , fire a row for record 30
12528 IF g_count_ipap = 0 THEN
12529 i := 0;
12530 IF l_hired = 1 THEN
12531 --chk if there is any run result
12532 FOR c_rec IN c_run_results_exist
12533 LOOP
12534 g_ipap_dates(i).new_start := Fnd_Date.date_to_canonical(l_hire_date);
12535 g_ipap_dates(i).old_start := '';
12536 --get the end date corresponding to this enrollment
12537 l_ret_val := Get_Participation_End
12538 (p_assignment_id => p_assignment_id
12539 ,p_business_group_id => p_business_group_id
12540 ,p_pension_type_id => c_rec.pension_type_id
12541 ,p_date_earned => p_effective_date
12542 ,p_end_date => l_end_date
12543 );
12544 IF l_ret_val = 0 THEN
12545 IF l_end_date = hr_api.g_eot THEN
12546 g_ipap_dates(i).new_end := '';
12547 ELSE
12548 g_ipap_dates(i).new_end := Fnd_Date.date_to_canonical(l_end_date) ;
12549 END IF;
12550 ELSE
12551 g_ipap_dates(i).new_end := '';
12552 END IF;
12553 g_ipap_dates(i).old_end := '';
12554 i := i+1;
12555 END LOOP;
12556 g_count_ipap := i;
12557 END IF;
12558 END IF;
12559 END IF;
12560
12561 IF g_count_ipap > 0 THEN
12562 Hr_Utility.set_location('old st date : '||g_ipap_dates(g_index_ipap).old_start,40);
12563 Hr_Utility.set_location('new st date : '||g_ipap_dates(g_index_ipap).new_start,45);
12564 Hr_Utility.set_location('old ed date : '||g_ipap_dates(g_index_ipap).old_end,50);
12565 Hr_Utility.set_location('new ed date : '||g_ipap_dates(g_index_ipap).new_end,55);
12566 l_return_value := 0;
12567 --depending on the fetch code ,set the data element value
12568 IF p_fetch_code = 'NEW_ST' THEN
12569 p_data_element_value := g_ipap_dates(g_index_ipap).new_start;
12570 ELSIF p_fetch_code = 'OLD_ST' THEN
12571 p_data_element_value := g_ipap_dates(g_index_ipap).old_start;
12572 ELSIF p_fetch_code = 'NEW_ED' THEN
12573 p_data_element_value := g_ipap_dates(g_index_ipap).new_end;
12574 ELSIF p_fetch_code = 'OLD_ED' THEN
12575 p_data_element_value := g_ipap_dates(g_index_ipap).old_end;
12576 END IF;
12577
12578 -- p_data_element_value := substr(p_data_element_value,1,10);
12579 p_data_element_value := Ben_Ext_Fmt.apply_format_mask
12580 (Fnd_Date.canonical_to_date(p_data_element_value),
12581 'YYYYMMDD');
12582
12583 ELSE
12584 p_data_element_value := '';
12585 l_return_value := 1;
12586 END IF;
12587
12588 Hr_Utility.set_location('p_data_element_value: '||p_data_element_value, 70);
12589 Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
12590
12591 l_return_value :=0;
12592 RETURN l_return_value;
12593 EXCEPTION
12594 WHEN Others THEN
12595 p_error_message :='SQL-ERRM :'||SQLERRM;
12596 Hr_Utility.set_location('..'||p_error_message,85);
12597 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
12598 RETURN l_return_value;
12599 END get_ipap_participation_dates;
12600
12601 -- =============================================================================
12602 -- Chk_If_Req_ToExtract: For a given assignment check to see the record needs to
12603 -- be extracted or not.
12604 -- =============================================================================
12605 FUNCTION Chk_If_Req_ToExtract
12606 (p_assignment_id IN Number
12607 ,p_business_group_id IN Number
12608 ,p_person_id IN Number
12609 ,p_effective_date IN Date
12610 ,p_record_num IN Varchar2
12611 ,p_error_message OUT NOCOPY Varchar2) RETURN Varchar2 IS
12612
12613 l_proc_name Varchar2(150) := g_proc_name ||'Chk_If_Req_ToExtract';
12614 l_return_value Number :=0;
12615 l_data_element_value Varchar2(2);
12616
12617 BEGIN
12618 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
12619 Hr_Utility.set_location('..p_record_num : '||p_record_num , 6);
12620 IF p_record_num = '01' THEN
12621 l_return_value := Record01_Display_Criteria
12622 (p_assignment_id => p_assignment_id
12623 ,p_business_group_id => p_business_group_id
12624 ,p_effective_date => p_effective_date
12625 ,p_error_message => p_error_message
12626 ,p_data_element_value => l_data_element_value
12627 );
12628 ELSIF p_record_num = '02' THEN
12629 l_return_value := Record02_Display_Criteria
12630 (p_assignment_id => p_assignment_id
12631 ,p_business_group_id => p_business_group_id
12632 ,p_effective_date => p_effective_date
12633 ,p_error_message => p_error_message
12634 ,p_data_element_value => l_data_element_value
12635 );
12636 ELSIF p_record_num = '04' THEN
12637 l_return_value := Record04_Display_Criteria
12638 (p_assignment_id => p_assignment_id
12639 ,p_business_group_id => p_business_group_id
12640 ,p_effective_date => p_effective_date
12641 ,p_error_message => p_error_message
12642 ,p_data_element_value => l_data_element_value
12643 );
12644 ELSIF p_record_num = '05' THEN
12645 l_return_value := Record05_Display_Criteria
12646 (p_assignment_id => p_assignment_id
12647 ,p_business_group_id => p_business_group_id
12648 ,p_effective_date => p_effective_date
12649 ,p_error_message => p_error_message
12650 ,p_data_element_value => l_data_element_value
12651 );
12652
12653 ELSIF p_record_num = '08' THEN
12654 l_return_value := Record08_Display_Criteria
12655 (p_assignment_id => p_assignment_id
12656 ,p_business_group_id => p_business_group_id
12657 ,p_effective_date => p_effective_date
12658 ,p_error_message => p_error_message
12659 ,p_data_element_value => l_data_element_value
12660 );
12661
12662 ELSIF p_record_num = '30' THEN
12663 l_return_value := Record30_40_Display_Criteria(p_assignment_id
12664 ,p_business_group_id
12665 ,p_effective_date
12666 ,'IPAP'
12667 ,p_error_message
12668 ,l_data_element_value);
12669
12670 ELSIF p_record_num = '31' THEN
12671 l_return_value := Record31_41_Display_Criteria(p_assignment_id
12672 ,p_business_group_id
12673 ,p_effective_date
12674 ,31
12675 ,p_error_message
12676 ,l_data_element_value);
12677
12678 ELSIF p_record_num = '40' THEN
12679 l_return_value := Record30_40_Display_Criteria
12680 (p_assignment_id
12681 ,p_business_group_id
12682 ,p_effective_date
12683 ,'FUR_S'
12684 ,p_error_message
12685 ,l_data_element_value);
12686
12687 ELSIF p_record_num = '41' THEN
12688 l_return_value := Record31_41_Display_Criteria(p_assignment_id
12689 ,p_business_group_id
12690 ,p_effective_date
12691 ,41
12692 ,p_error_message
12693 ,l_data_element_value);
12694 ELSIF p_record_num = '21' THEN
12695 l_return_value := Record21_Display_Criteria
12696 (p_assignment_id => p_assignment_id
12697 ,p_business_group_id => p_business_group_id
12698 ,p_effective_date => p_effective_date
12699 ,p_error_message => p_error_message
12700 ,p_data_element_value => l_data_element_value
12701 );
12702 ELSIF p_record_num = '09' THEN
12703 l_return_value := Record09_Display_Criteria
12704 (p_assignment_id => p_assignment_id
12705 ,p_business_group_id => p_business_group_id
12706 ,p_effective_date => p_effective_date
12707 ,p_error_message => p_error_message
12708 ,p_data_element_value => l_data_element_value
12709 );
12710 ELSIF p_record_num = '12' THEN
12711 l_return_value := Record12_Display_Criteria
12712 (p_assignment_id => p_assignment_id
12713 ,p_business_group_id => p_business_group_id
12714 ,p_effective_date => p_effective_date
12715 ,p_error_message => p_error_message
12716 ,p_data_element_value => l_data_element_value
12717 );
12718 ELSIF p_record_num = '20' THEN
12719 l_return_value := Record20_Display_Criteria
12720 (p_assignment_id => p_assignment_id
12721 ,p_business_group_id => p_business_group_id
12722 ,p_effective_date => p_effective_date
12723 ,p_error_message => p_error_message
12724 ,p_data_element_value => l_data_element_value
12725 );
12726 ELSIF p_record_num = '22' THEN
12727 l_return_value := Record22_Display_Criteria
12728 (p_assignment_id => p_assignment_id
12729 ,p_business_group_id => p_business_group_id
12730 ,p_effective_date => p_effective_date
12731 ,p_error_message => p_error_message
12732 ,p_data_element_value => l_data_element_value
12733 );
12734 ELSIF p_record_num = '41h' THEN
12735 l_data_element_value := 'Y';
12736
12737 ELSE
12738 l_data_element_value := 'N';
12739 END IF;
12740 Hr_Utility.set_location('..l_data_element_value: '||l_data_element_value,45);
12741 Hr_Utility.set_location('Leaving: '||l_proc_name, 50);
12742 RETURN l_data_element_value;
12743 EXCEPTION
12744 WHEN Others THEN
12745 p_error_message :='SQL-ERRM :'||SQLERRM;
12746 Hr_Utility.set_location('..'||p_error_message,85);
12747 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
12748 RETURN l_return_value;
12749
12750 END Chk_If_Req_ToExtract;
12751
12752 --============================================================================
12753 --This is used to check if there are any more rows for Record 05 and insert
12754 --those records forcibly
12755 --============================================================================
12756 FUNCTION Process_Mult_Rec05
12757 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
12758 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
12759 ,p_effective_date IN Date
12760 ,p_error_message OUT NOCOPY Varchar2
12761 ,p_data_element_value OUT NOCOPY Varchar2
12762 ) RETURN Number IS
12763
12764 l_main_rec csr_rslt_dtl%ROWTYPE;
12765 l_new_rec csr_rslt_dtl%ROWTYPE;
12766 l_return_value Number := 1;
12767 l_rcd_id Number;
12768 l_mutli_assig Varchar2(50);
12769 l_asg_type per_all_assignments_f.assignment_type%TYPE;
12770 l_person_id per_all_people_f.person_id%TYPE;
12771 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
12772 l_effective_date Date;
12773
12774 BEGIN
12775 --fetch the record id from the sequence number
12776 OPEN c_get_rcd_id(5);
12777 FETCH c_get_rcd_id INTO l_rcd_id;
12778 CLOSE c_get_rcd_id;
12779
12780 --first fetch the data from the result detail record
12781 OPEN csr_rslt_dtl(c_person_id => g_person_id
12782 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
12783 ,c_ext_dtl_rcd_id => l_rcd_id
12784 );
12785
12786 FETCH csr_rslt_dtl INTO l_main_rec;
12787 CLOSE csr_rslt_dtl;
12788
12789 l_main_rec.object_version_NUMBER := Nvl(l_main_rec.object_version_NUMBER,0) + 1;
12790 l_new_rec := l_main_rec;
12791
12792 --This is multiple categories process for first Assignment
12793 WHILE(g_index_05 < g_count_05)
12794 LOOP
12795 IF g_index_05 <> 0 THEN
12796 Process_Ext_Rslt_Dtl_Rec
12797 (p_assignment_id => p_assignment_id
12798 ,p_organization_id => NULL
12799 ,p_effective_date => p_effective_date
12800 ,p_ext_dtl_rcd_id => l_rcd_id
12801 ,p_rslt_rec => l_main_rec
12802 ,p_asgaction_no => NULL
12803 ,p_error_message => p_error_message
12804 );
12805 END IF;
12806 g_index_05 := g_index_05 + 1;
12807 END LOOP;
12808 g_index_05 := 0;
12809 g_count_05 := 0;
12810 p_data_element_value := '';
12811 l_rec_05_disp := 'N';
12812 l_return_value := 0;
12813
12814 RETURN l_return_value;
12815
12816 EXCEPTION
12817 WHEN Others THEN
12818 p_error_message :='SQL-ERRM :'||SQLERRM;
12819 Hr_Utility.set_location('..'||p_error_message,85);
12820 RETURN l_return_value;
12821 END Process_Mult_Rec05;
12822
12823 --=============================================================================
12824 -- Process Multiple Record 08. This is necessary for late hires
12825 -- and for change in hire date to the past (ABP Certification only test case).
12826 --=============================================================================
12827 FUNCTION Process_Mult_Rec08
12828 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
12829 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
12830 ,p_effective_date IN DATE
12831 ,p_error_message OUT NOCOPY VARCHAR2
12832 ,p_data_element_value OUT NOCOPY VARCHAR2
12833 ) RETURN NUMBER IS
12834
12835 CURSOR c_hire_dt_chg(c_person_id IN NUMBER
12836 ,c_start_date IN DATE
12837 ,c_end_date IN DATE) IS
12838 SELECT old_val1 old_date,
12839 new_val1 new_date
12840 FROM ben_ext_chg_evt_log
12841 WHERE person_id = c_person_id
12842 AND chg_evt_cd = 'COPOS'
12843 AND fnd_date.canonical_to_date(prmtr_09) BETWEEN c_start_date AND c_end_date
12844 ORDER BY ext_chg_evt_log_id desc;
12845
12846 CURSOR or_pen_sal ( c_nh_date IN DATE) IS
12847 SELECT 1
12848 FROM per_assignment_extra_info
12849 WHERE assignment_id = p_assignment_id
12850 AND aei_information_category = 'NL_ABP_PAR_INFO'
12851 AND information_type = 'NL_ABP_PAR_INFO'
12852 AND trunc(c_nh_date) BETWEEN fnd_date.canonical_to_date(aei_information1)
12853 AND fnd_date.canonical_to_date(nvl(aei_information2,
12854 fnd_date.date_to_canonical(hr_api.g_eot)))
12855 AND aei_information6 IS NOT NULL;
12856
12857 CURSOR c_get_override_salary (c_start IN DATE, c_end IN DATE) IS
12858 SELECT fnd_number.canonical_to_number(nvl(new_val1,'0'))
12859 ,fnd_date.canonical_to_date(prmtr_02)
12860 FROM ben_ext_chg_evt_log
12861 WHERE person_id = g_person_id
12862 AND fnd_number.canonical_to_number(prmtr_01) = p_assignment_id
12863 AND chg_eff_dt BETWEEN g_extract_params(p_business_group_id).extract_start_date
12864 AND g_extract_params(p_business_group_id).extract_end_date
12865 AND chg_evt_cd = 'COAPS'
12866 AND fnd_number.canonical_to_number(nvl(new_val1,'0')) <> 0
12867 AND fnd_date.canonical_to_date(prmtr_02) BETWEEN c_start and c_end;
12868
12869 l_ret_val NUMBER := 0;
12870 l_proc_name VARCHAR2(150) := g_proc_name ||'Process_Mult_Rec08';
12871 l_rcd_id NUMBER;
12872 l_index NUMBER;
12873 l_old_hire_dt DATE;
12874 l_new_hire_dt DATE;
12875 l_or_pen_sal NUMBER;
12876 l_ext_rslt_dtl_id NUMBER;
12877 l_main_rec csr_rslt_dtl%ROWTYPE;
12878 l_new_rec csr_rslt_dtl%ROWTYPE;
12879 l_old_date_can ben_ext_chg_evt_log.old_val1%TYPE;
12880 l_new_date_can ben_ext_chg_evt_log.new_val1%TYPE;
12881 l_asg_action_id pay_assignment_actions.assignment_action_id%TYPE;
12882 l_pension_sal_char VARCHAR2(15);
12883 l_pension_yr_char VARCHAR2(15);
12884 l_get_ps_val NUMBER;
12885 l_get_yr_val NUMBER;
12886 l_max_de DATE;
12887 l_de_asg_act NUMBER;
12888 l_start_de DATE;
12889 l_end_de DATE;
12890 l_lh_or_pen_sal NUMBER;
12891 l_lh_or_date DATE;
12892 l_override_lh BOOLEAN;
12893 l_ret_val_asg NUMBER;
12894 l_seq_num VARCHAR2(2);
12895
12896 BEGIN
12897
12898 Hr_Utility.set_location(' Entering ' || l_proc_name , 10);
12899 --
12900 -- Create Record 08 for an EE assignment if the assignment
12901 -- is a late hire across years. For e.g. hired in 2006 but
12902 -- the first payroll is processed in 2007
12903 --
12904
12905 IF Chk_Asg_Late_Hire (p_assignment_id => p_assignment_id
12906 ,p_business_group_id => p_business_group_id) THEN
12907 --
12908 -- EE assignment is a late hire. Insert a record 08 for the prev year.
12909 --
12910
12911 OPEN c_get_rcd_id(7);
12912 FETCH c_get_rcd_id INTO l_rcd_id;
12913 CLOSE c_get_rcd_id;
12914
12915 OPEN csr_rslt_dtl(c_person_id => g_person_id
12916 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
12917 ,c_ext_dtl_rcd_id => l_rcd_id);
12918 FETCH csr_rslt_dtl INTO l_main_rec;
12919 CLOSE csr_rslt_dtl;
12920
12921 l_start_de := TO_DATE('01/01/'||TO_CHAR(TO_NUMBER(TO_CHAR(g_extract_params(p_business_group_id).extract_start_date,'YYYY')) - 1),'DD/MM/YYYY');
12922 l_end_de := TO_DATE('31/12/'||TO_CHAR(TO_NUMBER(TO_CHAR(g_extract_params(p_business_group_id).extract_start_date,'YYYY')) - 1),'DD/MM/YYYY');
12923 l_de_asg_act := -1;
12924
12925 OPEN csr_asg_act_de (c_assignment_id => p_assignment_id
12926 ,c_start_de => l_start_de
12927 ,c_end_de => l_end_de
12928 ,c_bg_id => p_business_group_id);
12929 FETCH csr_asg_act_de INTO l_de_asg_act;
12930 CLOSE csr_asg_act_de;
12931
12932 --
12933 -- Check if any override pension salary is entered
12934 --
12935 l_override_lh := FALSE;
12936
12937 OPEN c_get_override_salary(l_start_de,l_end_de);
12938 FETCH c_get_override_salary INTO l_lh_or_pen_sal,l_lh_or_date;
12939 IF c_get_override_salary%FOUND THEN
12940 l_override_lh := TRUE;
12941 ELSE
12942 l_override_lh := FALSE;
12943 END IF;
12944 CLOSE c_get_override_salary;
12945
12946 IF l_de_asg_act <> - 1 OR l_override_lh THEN
12947 --
12948 -- Derive the date for which we are attempting to get pension salary.
12949 --
12950
12951 IF l_de_asg_act <> - 1 THEN
12952
12953 SELECT date_earned
12954 INTO l_max_de
12955 FROM pay_payroll_actions ppa,
12956 pay_assignment_actions paa
12957 WHERE ppa.payroll_action_id = paa.payroll_action_id
12958 AND paa.assignment_action_id =l_de_asg_act;
12959 --
12960 -- Derive the pension salary
12961 --
12962
12963 l_get_ps_val := Get_Pension_Salary(p_assignment_id
12964 ,p_business_group_id
12965 ,LAST_DAY(l_max_de)
12966 ,'ABP Pension Salary'
12967 ,l_de_asg_act
12968 ,p_error_message
12969 ,l_pension_sal_char);
12970
12971 IF IsNumber(l_pension_sal_char) THEN
12972 l_pension_sal_char := Trim(To_Char(ABS(Fnd_Number.Canonical_To_Number
12973 (Nvl(l_pension_sal_char,'0')))
12974 ,'0999999V99'));
12975 END IF;
12976
12977 l_get_yr_val := Get_Pension_Start_Year(p_assignment_id
12978 ,p_business_group_id
12979 ,LAST_DAY(l_max_de)
12980 ,l_start_de
12981 ,l_end_de
12982 ,p_error_message
12983 ,l_pension_yr_char);
12984
12985 ELSE
12986
12987 IF IsNumber(l_lh_or_pen_sal) THEN
12988 l_pension_sal_char := Trim(To_Char(ABS(Nvl(l_lh_or_pen_sal,0))
12989 ,'0999999V99'));
12990 END IF;
12991
12992 l_pension_yr_char := Ben_Ext_Fmt.apply_format_mask
12993 (l_lh_or_date,'YYYYMMDD');
12994
12995 END IF;
12996
12997 l_ret_val_asg := Get_Asg_Seq_Num(p_assignment_id
12998 ,p_business_group_id
12999 ,p_effective_date
13000 ,p_error_message
13001 ,l_seq_num);
13002
13003 SELECT ben_ext_rslt_dtl_s.NEXTVAL INTO l_ext_rslt_dtl_id FROM dual;
13004
13005 INSERT INTO ben_ext_rslt_dtl
13006 ( EXT_RSLT_DTL_ID
13007 ,EXT_RSLT_ID
13008 ,BUSINESS_GROUP_ID
13009 ,EXT_RCD_ID
13010 ,PERSON_ID
13011 ,VAL_01
13012 ,VAL_02
13013 ,VAL_03
13014 ,VAL_04
13015 ,VAL_05
13016 ,VAL_06
13017 ,VAL_07
13018 ,VAL_08
13019 ,VAL_09
13020 ,VAL_10
13021 ,VAL_25
13022 ,VAL_26
13023 ,VAL_70
13024 ,CREATED_BY
13025 ,CREATION_DATE
13026 ,LAST_UPDATE_DATE
13027 ,LAST_UPDATED_BY
13028 ,LAST_UPDATE_LOGIN
13029 ,PROGRAM_APPLICATION_ID
13030 ,PROGRAM_ID
13031 ,PROGRAM_UPDATE_DATE
13032 ,REQUEST_ID
13033 ,OBJECT_VERSION_NUMBER
13034 ,PRMY_SORT_VAL
13035 ,SCND_SORT_VAL
13036 ,THRD_SORT_VAL
13037 ,TRANS_SEQ_NUM
13038 ,RCRD_SEQ_NUM)
13039 VALUES( l_ext_rslt_dtl_id
13040 ,l_main_rec.EXT_RSLT_ID
13041 ,l_main_rec.BUSINESS_GROUP_ID
13042 ,l_main_rec.EXT_RCD_ID
13043 ,l_main_rec.PERSON_ID
13044 ,l_main_rec.VAL_01
13045 ,l_main_rec.VAL_02
13046 ,l_main_rec.VAL_03
13047 ,l_seq_num
13048 ,l_pension_sal_char
13049 ,l_main_rec.VAL_06
13050 ,l_pension_yr_char
13051 ,l_main_rec.VAL_08
13052 ,l_main_rec.VAL_09
13053 ,l_main_rec.VAL_10
13054 ,l_main_rec.VAL_25
13055 ,l_main_rec.VAL_26
13056 ,l_main_rec.VAL_70
13057 ,l_main_rec.CREATED_BY
13058 ,l_main_rec.CREATION_DATE
13059 ,l_main_rec.LAST_UPDATE_DATE
13060 ,l_main_rec.LAST_UPDATED_BY
13061 ,l_main_rec.LAST_UPDATE_LOGIN
13062 ,l_main_rec.PROGRAM_APPLICATION_ID
13063 ,l_main_rec.PROGRAM_ID
13064 ,l_main_rec.PROGRAM_UPDATE_DATE
13065 ,l_main_rec.REQUEST_ID
13066 ,l_main_rec.OBJECT_VERSION_NUMBER
13067 ,l_main_rec.PRMY_SORT_VAL
13068 ,l_main_rec.SCND_SORT_VAL
13069 ,l_main_rec.THRD_SORT_VAL
13070 ,l_main_rec.TRANS_SEQ_NUM
13071 ,l_main_rec.RCRD_SEQ_NUM);
13072 END IF; -- Check l_de_asg_act <> -1
13073
13074 END IF;
13075
13076 --
13077 -- Insert a Record 08 if the change of hire date is in the past
13078 --
13079 OPEN c_hire_dt_chg(c_person_id => g_person_id
13080 ,c_start_date => g_extract_params(p_business_group_id).extract_start_date
13081 ,c_end_date => g_extract_params(p_business_group_id).extract_end_date);
13082 FETCH c_hire_dt_chg INTO l_old_date_can,l_new_date_can;
13083 IF c_hire_dt_chg%FOUND THEN
13084 l_old_hire_dt := to_nl_date(l_old_date_can,'DD-MM-RRRR');
13085 l_new_hire_dt := to_nl_date(l_new_date_can,'DD-MM-RRRR');
13086 Hr_Utility.set_location(' Change in hire date found ' || l_proc_name , 10);
13087
13088 IF to_number(to_char(l_new_hire_dt,'YYYY'))
13089 < to_number(to_char(l_old_hire_dt,'YYYY')) THEN
13090 Hr_Utility.set_location(' Years are different ' || l_proc_name , 10);
13091
13092 OPEN or_pen_sal (l_new_hire_dt);
13093 FETCH or_pen_sal INTO l_or_pen_sal;
13094 IF or_pen_sal%FOUND THEN
13095 Hr_Utility.set_location(' Pension sal found are diff ' || l_proc_name , 10);
13096 OPEN c_get_rcd_id(7);
13097 FETCH c_get_rcd_id INTO l_rcd_id;
13098 CLOSE c_get_rcd_id;
13099
13100 OPEN csr_rslt_dtl(c_person_id => g_person_id
13101 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
13102 ,c_ext_dtl_rcd_id => l_rcd_id);
13103 FETCH csr_rslt_dtl INTO l_main_rec;
13104 CLOSE csr_rslt_dtl;
13105
13106 SELECT ben_ext_rslt_dtl_s.NEXTVAL INTO l_ext_rslt_dtl_id FROM dual;
13107
13108 INSERT INTO ben_ext_rslt_dtl
13109 ( EXT_RSLT_DTL_ID
13110 ,EXT_RSLT_ID
13111 ,BUSINESS_GROUP_ID
13112 ,EXT_RCD_ID
13113 ,PERSON_ID
13114 ,VAL_01
13115 ,VAL_02
13116 ,VAL_03
13117 ,VAL_04
13118 ,VAL_05
13119 ,VAL_06
13120 ,VAL_07
13121 ,VAL_08
13122 ,VAL_09
13123 ,VAL_10
13124 ,VAL_25
13125 ,VAL_26
13126 ,VAL_70
13127 ,CREATED_BY
13128 ,CREATION_DATE
13129 ,LAST_UPDATE_DATE
13130 ,LAST_UPDATED_BY
13131 ,LAST_UPDATE_LOGIN
13132 ,PROGRAM_APPLICATION_ID
13133 ,PROGRAM_ID
13134 ,PROGRAM_UPDATE_DATE
13135 ,REQUEST_ID
13136 ,OBJECT_VERSION_NUMBER
13137 ,PRMY_SORT_VAL
13138 ,SCND_SORT_VAL
13139 ,THRD_SORT_VAL
13140 ,TRANS_SEQ_NUM
13141 ,RCRD_SEQ_NUM)
13142 VALUES( l_ext_rslt_dtl_id
13143 ,l_main_rec.EXT_RSLT_ID
13144 ,l_main_rec.BUSINESS_GROUP_ID
13145 ,l_main_rec.EXT_RCD_ID
13146 ,l_main_rec.PERSON_ID
13147 ,l_main_rec.VAL_01
13148 ,l_main_rec.VAL_02
13149 ,l_main_rec.VAL_03
13150 ,l_main_rec.VAL_04
13151 ,l_main_rec.VAL_05
13152 ,l_main_rec.VAL_06
13153 ,to_char(l_new_hire_dt,'YYYYMMDD')
13154 ,l_main_rec.VAL_08
13155 ,l_main_rec.VAL_09
13156 ,l_main_rec.VAL_10
13157 ,l_main_rec.VAL_25
13158 ,l_main_rec.VAL_26
13159 ,l_main_rec.VAL_70
13160 ,l_main_rec.CREATED_BY
13161 ,l_main_rec.CREATION_DATE
13162 ,l_main_rec.LAST_UPDATE_DATE
13163 ,l_main_rec.LAST_UPDATED_BY
13164 ,l_main_rec.LAST_UPDATE_LOGIN
13165 ,l_main_rec.PROGRAM_APPLICATION_ID
13166 ,l_main_rec.PROGRAM_ID
13167 ,l_main_rec.PROGRAM_UPDATE_DATE
13168 ,l_main_rec.REQUEST_ID
13169 ,l_main_rec.OBJECT_VERSION_NUMBER
13170 ,l_main_rec.PRMY_SORT_VAL
13171 ,l_main_rec.SCND_SORT_VAL
13172 ,l_main_rec.THRD_SORT_VAL
13173 ,l_main_rec.TRANS_SEQ_NUM
13174 ,l_main_rec.RCRD_SEQ_NUM);
13175 END IF;
13176 CLOSE or_pen_sal;
13177 END IF;
13178 END IF;
13179
13180 CLOSE c_hire_dt_chg;
13181
13182 Hr_Utility.set_location(' Leaving '||l_proc_name , 15);
13183
13184 RETURN l_ret_val;
13185
13186 EXCEPTION
13187 WHEN Others THEN
13188 p_error_message :='SQL-ERRM :'||SQLERRM;
13189 Hr_Utility.set_location('..'||p_error_message,85);
13190 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
13191 RETURN -1;
13192 END Process_Mult_Rec08;
13193
13194 -- =============================================================================
13195 -- Process Multiple SubCategories for record 09
13196 -- =============================================================================
13197 FUNCTION Process_Mult_Rec09
13198 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13199 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
13200 ,p_effective_date IN Date
13201 ,p_error_message OUT NOCOPY Varchar2
13202 ,p_data_element_value OUT NOCOPY Varchar2
13203 ) RETURN Number IS
13204
13205 l_ret_val Number := 0;
13206 l_asg_action_id pay_assignment_actions.assignment_action_id%TYPE;
13207 l_proc_name Varchar2(150) := g_proc_name ||'Process_Mult_Rec09';
13208 l_rcd_id Number;
13209 l_index Number;
13210 l_main_rec csr_rslt_dtl%ROWTYPE;
13211 l_new_rec csr_rslt_dtl%ROWTYPE;
13212
13213 BEGIN
13214 Hr_Utility.set_location(' Entering ' || l_proc_name , 10);
13215
13216 IF l_rec_09_values.Count > 0 THEN
13217
13218 --Fetch the record id from the sequence number
13219 OPEN c_get_rcd_id(8);
13220 FETCH c_get_rcd_id INTO l_rcd_id;
13221 CLOSE c_get_rcd_id;
13222
13223 OPEN csr_rslt_dtl(c_person_id => g_person_id
13224 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
13225 ,c_ext_dtl_rcd_id => l_rcd_id
13226 );
13227 FETCH csr_rslt_dtl INTO l_main_rec;
13228 CLOSE csr_rslt_dtl;
13229
13230 l_main_rec.object_version_NUMBER := Nvl(l_main_rec.object_version_NUMBER,0) + 1;
13231 l_new_rec := l_main_rec;
13232
13233 l_index := l_rec_09_values.LAST;
13234
13235 FOR i IN 1..l_index
13236 LOOP
13237 IF l_rec_09_values.EXISTS(i) THEN
13238 Process_Ext_Rslt_Dtl_Rec
13239 (p_assignment_id => p_assignment_id
13240 ,p_effective_date => p_effective_date
13241 ,p_ext_dtl_rcd_id => l_rcd_id
13242 ,p_rslt_rec => l_main_rec
13243 ,p_error_message => p_error_message
13244 );
13245 END IF;
13246 END LOOP;
13247
13248 END IF;
13249 l_rec_09_disp := 'N';
13250 l_ret_val := 0;
13251
13252 Hr_Utility.set_location(' Leaving '||l_proc_name , 15);
13253
13254 RETURN l_ret_val;
13255 EXCEPTION
13256 WHEN Others THEN
13257 p_error_message :='SQL-ERRM :'||SQLERRM;
13258 Hr_Utility.set_location('..'||p_error_message,85);
13259 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
13260 RETURN -1;
13261 END Process_Mult_Rec09;
13262
13263 -- =============================================================================
13264 -- Process Multiple SubCategories for Record 12
13265 -- =============================================================================
13266 FUNCTION Process_Mult_Rec12
13267 (
13268 p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13269 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
13270 ,p_effective_date IN Date
13271 ,p_error_message OUT NOCOPY Varchar2
13272 ,p_data_element_value OUT NOCOPY Varchar2
13273 ) RETURN Number IS
13274
13275 l_ret_val Number := 0;
13276 l_asg_action_id pay_assignment_actions.assignment_action_id%TYPE;
13277 l_proc_name Varchar2(150) := g_proc_name ||'Process_Mult_Rec12';
13278 l_rcd_id Number;
13279 l_index Number;
13280 i Number;
13281 l_main_rec csr_rslt_dtl%ROWTYPE;
13282 l_new_rec csr_rslt_dtl%ROWTYPE;
13283
13284 BEGIN
13285
13286 Hr_Utility.set_location(' Entering ' || l_proc_name , 10);
13287 hr_utility.set_location('asg : '||p_assignment_id||'count : '||l_rec_12_values.Count,12);
13288
13289 IF l_rec_12_values.Count > 0 THEN
13290 --fetch the record id from the sequence number
13291 OPEN c_get_rcd_id(10);
13292 FETCH c_get_rcd_id INTO l_rcd_id;
13293 CLOSE c_get_rcd_id;
13294
13295 OPEN csr_rslt_dtl(c_person_id => g_person_id
13296 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
13297 ,c_ext_dtl_rcd_id => l_rcd_id
13298 );
13299
13300 FETCH csr_rslt_dtl INTO l_main_rec;
13301
13302 CLOSE csr_rslt_dtl;
13303
13304 l_main_rec.object_version_NUMBER := Nvl(l_main_rec.object_version_NUMBER,0) + 1;
13305 l_new_rec := l_main_rec;
13306 l_index := l_rec_12_values.LAST;
13307 FOR i IN 1..l_index
13308 LOOP
13309 hr_utility.set_location('counts : '||i||'----'||l_index,15);
13310 IF l_rec_12_values.EXISTS(i) THEN
13311 Process_Ext_Rslt_Dtl_Rec
13312 (p_assignment_id => p_assignment_id
13313 ,p_effective_date => p_effective_date
13314 ,p_ext_dtl_rcd_id => l_rcd_id
13315 ,p_rslt_rec => l_main_rec
13316 ,p_error_message => p_error_message
13317 );
13318 END IF;
13319 END LOOP;
13320
13321 END IF;
13322 l_rec_12_disp := 'N';
13323 l_ret_val := 0;
13324
13325 Hr_Utility.set_location(' Leaving '||l_proc_name , 15);
13326
13327 RETURN l_ret_val;
13328
13329 EXCEPTION
13330 WHEN Others THEN
13331 p_error_message :='SQL-ERRM :'||SQLERRM;
13332 Hr_Utility.set_location('..'||p_error_message,85);
13333 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
13334 RETURN l_ret_val;
13335 END Process_Mult_Rec12;
13336
13337 --============================================================================
13338 --This is used to check if there are any more rows for SI participation and insert
13339 --those records forcibly
13340 --============================================================================
13341 FUNCTION Process_Mult_Rec20
13342 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13343 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
13344 ,p_effective_date IN Date
13345 ,p_error_message OUT NOCOPY Varchar2
13346 ,p_data_element_value OUT NOCOPY Varchar2
13347 ) RETURN Number IS
13348
13349 l_return_value Number := 0;
13350
13351 BEGIN
13352 p_data_element_value := '';
13353 l_return_value := 0;
13354 RETURN l_return_value;
13355 EXCEPTION
13356 WHEN Others THEN
13357 p_error_message :='SQL-ERRM :'||SQLERRM;
13358 Hr_Utility.set_location('..'||p_error_message,85);
13359 RETURN l_return_value;
13360 END Process_Mult_Rec20;
13361
13362 ---------------------------------------------------------------------------
13363 FUNCTION Process_Mult_Rec21
13364 (p_assignment_id IN Number
13365 ,p_business_group_id IN Number
13366 ,p_effective_date IN Date
13367 ,p_error_message IN OUT NOCOPY Varchar2 )
13368 RETURN Number IS
13369
13370 l_return_value Number := 0;
13371 l_proc_name Varchar2(80) := 'Process_Mult_Rec21';
13372
13373 BEGIN
13374
13375 RETURN 0;
13376
13377 EXCEPTION
13378 WHEN Others THEN
13379 p_error_message :='SQL-ERRM :'||SQLERRM;
13380 Hr_Utility.set_location('..'||p_error_message,85);
13381 Hr_Utility.set_location('Leaving:-------- '||l_proc_name, 15);
13382 RETURN -1;
13383 END Process_Mult_Rec21;
13384
13385 ---------------------------------------------------------------------------
13386 FUNCTION Process_Mult_Rec22
13387 (p_assignment_id IN Number
13388 ,p_business_group_id IN Number
13389 ,p_effective_date IN Date
13390 ,p_error_message IN OUT NOCOPY Varchar2 )
13391 RETURN Number IS
13392
13393 l_return_value Number := 0;
13394 l_proc_name Varchar2(80) := 'Process_Mult_Rec22';
13395
13396 BEGIN
13397 Hr_Utility.set_location('Entering: '||l_proc_name, 15);
13398 RETURN 0;
13399 Hr_Utility.set_location('Leaving: '||l_proc_name, 15);
13400
13401 EXCEPTION
13402 WHEN Others THEN
13403 p_error_message :='SQL-ERRM :'||SQLERRM;
13404 Hr_Utility.set_location('..'||p_error_message,85);
13405 Hr_Utility.set_location('Leaving:-------- '||l_proc_name, 15);
13406 RETURN -1;
13407 END Process_Mult_Rec22;
13408
13409 --============================================================================
13410 --This is used to check if there are any more rows for IPAP participation and insert
13411 --those records forcibly
13412 --============================================================================
13413 FUNCTION Process_Mult_Rec30
13414 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13415 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
13416 ,p_effective_date IN Date
13417 ,p_error_message OUT NOCOPY Varchar2
13418 ,p_data_element_value OUT NOCOPY Varchar2
13419 ) RETURN Number IS
13420
13421 l_main_rec csr_rslt_dtl%ROWTYPE;
13422 l_new_rec csr_rslt_dtl%ROWTYPE;
13423 l_return_value Number := 1;
13424 l_rcd_id Number;
13425
13426 BEGIN
13427 --fetch the record id from the sequence number
13428 OPEN c_get_rcd_id(17);
13429 FETCH c_get_rcd_id INTO l_rcd_id;
13430 CLOSE c_get_rcd_id;
13431
13432 --first fetch the data from the result detail record
13433 OPEN csr_rslt_dtl(c_person_id => g_person_id
13434 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
13435 ,c_ext_dtl_rcd_id => l_rcd_id
13436 );
13437
13438 FETCH csr_rslt_dtl INTO l_main_rec;
13439 CLOSE csr_rslt_dtl;
13440
13441 l_new_rec := l_main_rec;
13442
13443 WHILE(g_index_ipap < g_count_ipap)
13444 LOOP
13445 IF g_index_ipap <> 0 THEN
13446 Process_Ext_Rslt_Dtl_Rec
13447 (p_assignment_id => p_assignment_id
13448 ,p_organization_id => NULL
13449 ,p_effective_date => p_effective_date
13450 ,p_ext_dtl_rcd_id => l_rcd_id
13451 ,p_rslt_rec => l_main_rec
13452 ,p_asgaction_no => NULL
13453 ,p_error_message => p_error_message
13454 );
13455 END IF;
13456 g_index_ipap := g_index_ipap + 1;
13457 END LOOP;
13458 g_index_ipap := 0;
13459 p_data_element_value := '';
13460 l_return_value := 0;
13461 RETURN l_return_value;
13462 EXCEPTION
13463 WHEN Others THEN
13464 p_error_message :='SQL-ERRM :'||SQLERRM;
13465 Hr_Utility.set_location('..'||p_error_message,85);
13466 -- hr_utility.set_location('Leaving: '||l_proc_name, 90);
13467 RETURN l_return_value;
13468 END Process_Mult_Rec30;
13469
13470 --=============================================================================
13471 -- This is used to check if there are any additional rows for rec 31
13472 -- This is for future use.
13473 --=============================================================================
13474 FUNCTION Process_Mult_Rec31
13475 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13476 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
13477 ,p_effective_date IN Date
13478 ,p_error_message OUT NOCOPY Varchar2
13479 ,p_data_element_value OUT NOCOPY Varchar2
13480 ) RETURN Number IS
13481
13482 l_ret_val Number := 0;
13483 l_asg_action_id pay_assignment_actions.assignment_action_id%TYPE;
13484 l_proc_name Varchar2(150) := g_proc_name ||'Process_Mult_Rec31';
13485 l_rcd_id Number;
13486 l_index Number;
13487 l_main_rec csr_rslt_dtl%ROWTYPE;
13488 l_new_rec csr_rslt_dtl%ROWTYPE;
13489
13490 BEGIN
13491
13492 IF l_rec_31_values.Count > 0 THEN
13493
13494 --Fetch the record id from the sequence number
13495 OPEN c_get_rcd_id(19);
13496 FETCH c_get_rcd_id INTO l_rcd_id;
13497 CLOSE c_get_rcd_id;
13498
13499 OPEN csr_rslt_dtl(c_person_id => g_person_id
13500 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
13501 ,c_ext_dtl_rcd_id => l_rcd_id
13502 );
13503 FETCH csr_rslt_dtl INTO l_main_rec;
13504 CLOSE csr_rslt_dtl;
13505
13506 l_main_rec.object_version_NUMBER := Nvl(l_main_rec.object_version_NUMBER,0) + 1;
13507 l_new_rec := l_main_rec;
13508
13509 l_index := l_rec_31_values.LAST;
13510
13511 FOR i IN 1..l_index
13512 LOOP
13513 IF l_rec_31_values.EXISTS(i) THEN
13514 Process_Ext_Rslt_Dtl_Rec
13515 (p_assignment_id => p_assignment_id
13516 ,p_effective_date => p_effective_date
13517 ,p_ext_dtl_rcd_id => l_rcd_id
13518 ,p_rslt_rec => l_main_rec
13519 ,p_error_message => p_error_message
13520 );
13521 END IF;
13522 END LOOP;
13523
13524 END IF;
13525 l_rec_31_disp := 'N';
13526 l_ret_val := 0;
13527
13528 Hr_Utility.set_location(' Leaving '||l_proc_name , 15);
13529
13530 RETURN l_ret_val;
13531
13532 END Process_Mult_Rec31;
13533
13534 --============================================================================
13535 -- This is used to check if there are any more rows for FUR participation and
13536 -- insert those records forcibly
13537 --=============================================================================
13538 FUNCTION Process_Mult_Rec40
13539 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13540 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
13541 ,p_effective_date IN Date
13542 ,p_error_message OUT NOCOPY Varchar2
13543 ,p_data_element_value OUT NOCOPY Varchar2
13544 ) RETURN Number IS
13545
13546 l_main_rec csr_rslt_dtl%ROWTYPE;
13547 l_new_rec csr_rslt_dtl%ROWTYPE;
13548 l_return_value Number := 1;
13549 l_rcd_id Number;
13550
13551 BEGIN
13552
13553
13554 --fetch the record id from the sequence number
13555 OPEN c_get_rcd_id(21);
13556 FETCH c_get_rcd_id INTO l_rcd_id;
13557 CLOSE c_get_rcd_id;
13558
13559 --first fetch the data from the result detail record
13560 OPEN csr_rslt_dtl(c_person_id => g_person_id
13561 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
13562 ,c_ext_dtl_rcd_id => l_rcd_id
13563 );
13564
13565 FETCH csr_rslt_dtl INTO l_main_rec;
13566 CLOSE csr_rslt_dtl;
13567
13568 l_new_rec := l_main_rec;
13569
13570 WHILE(g_index_fur < g_count_fur)
13571 LOOP
13572 IF g_index_fur <> 0 THEN
13573 Process_Ext_Rslt_Dtl_Rec
13574 (p_assignment_id => p_assignment_id
13575 ,p_organization_id => NULL
13576 ,p_effective_date => p_effective_date
13577 ,p_ext_dtl_rcd_id => l_rcd_id
13578 ,p_rslt_rec => l_main_rec
13579 ,p_asgaction_no => NULL
13580 ,p_error_message => p_error_message
13581 );
13582 END IF;
13583 g_index_fur := g_index_fur + 1;
13584 END LOOP;
13585 g_index_fur := 0;
13586 p_data_element_value := '';
13587
13588 /* l_return_value := Process_Mult_Rec21
13589 (p_assignment_id => p_assignment_id
13590 ,p_business_group_id => p_business_group_id
13591 ,p_effective_date => p_effective_date
13592 ,p_error_message => p_error_message
13593 );*/
13594 l_return_value := 0;
13595 RETURN l_return_value;
13596 EXCEPTION
13597 WHEN Others THEN
13598 p_error_message :='SQL-ERRM :'||SQLERRM;
13599 Hr_Utility.set_location('..'||p_error_message,85);
13600 -- hr_utility.set_location('Leaving: '||l_proc_name, 90);
13601 RETURN l_return_value;
13602 END Process_Mult_Rec40;
13603
13604 --=============================================================================
13605 -- This is used to check if there are any additional rows for rec 41
13606 -- This is for future use.
13607 --=============================================================================
13608 FUNCTION Process_Mult_Rec41
13609 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13610 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
13611 ,p_effective_date IN Date
13612 ,p_error_message OUT NOCOPY Varchar2
13613 ,p_data_element_value OUT NOCOPY Varchar2
13614 ) RETURN Number IS
13615
13616 l_ret_val Number := 0;
13617 l_asg_action_id pay_assignment_actions.assignment_action_id%TYPE;
13618 l_proc_name Varchar2(150) := g_proc_name ||'Process_Mult_Rec41';
13619 l_rcd_id Number;
13620 l_index Number;
13621 l_main_rec csr_rslt_dtl%ROWTYPE;
13622 l_new_rec csr_rslt_dtl%ROWTYPE;
13623
13624 BEGIN
13625
13626 IF g_fur_contrib_kind = 'A' THEN
13627
13628 IF l_rec_41_basis_values.Count > 0 THEN
13629
13630 --Fetch the record id from the sequence number
13631 OPEN c_get_rcd_id(23);
13632 FETCH c_get_rcd_id INTO l_rcd_id;
13633 CLOSE c_get_rcd_id;
13634
13635 OPEN csr_rslt_dtl(c_person_id => g_person_id
13636 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
13637 ,c_ext_dtl_rcd_id => l_rcd_id
13638 );
13639 FETCH csr_rslt_dtl INTO l_main_rec;
13640 CLOSE csr_rslt_dtl;
13641
13642 l_main_rec.object_version_NUMBER := Nvl(l_main_rec.object_version_NUMBER,0) + 1;
13643 l_new_rec := l_main_rec;
13644
13645 l_index := l_rec_41_basis_values.LAST;
13646
13647 FOR i IN 1..l_index
13648 LOOP
13649 IF l_rec_41_basis_values.EXISTS(i) THEN
13650 Process_Ext_Rslt_Dtl_Rec
13651 (p_assignment_id => p_assignment_id
13652 ,p_effective_date => p_effective_date
13653 ,p_ext_dtl_rcd_id => l_rcd_id
13654 ,p_rslt_rec => l_main_rec
13655 ,p_error_message => p_error_message
13656 );
13657 END IF;
13658 END LOOP;
13659
13660 END IF;
13661 l_basis_rec_41_disp := 'N';
13662 l_ret_val := 0;
13663
13664 ELSIF g_fur_contrib_kind = 'D' THEN
13665
13666 IF l_rec_41_contrib_values.Count > 0 THEN
13667
13668 --Fetch the record id from the sequence number
13669 OPEN c_get_rcd_id(23);
13670 FETCH c_get_rcd_id INTO l_rcd_id;
13671 CLOSE c_get_rcd_id;
13672
13673 OPEN csr_rslt_dtl(c_person_id => g_person_id
13674 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
13675 ,c_ext_dtl_rcd_id => l_rcd_id
13676 );
13677 FETCH csr_rslt_dtl INTO l_main_rec;
13678 CLOSE csr_rslt_dtl;
13679
13680 l_main_rec.object_version_NUMBER := Nvl(l_main_rec.object_version_NUMBER,0) + 1;
13681 l_new_rec := l_main_rec;
13682
13683 l_index := l_rec_41_contrib_values.LAST;
13684
13685 FOR i IN 1..l_index
13686 LOOP
13687 IF l_rec_41_contrib_values.EXISTS(i) THEN
13688 Process_Ext_Rslt_Dtl_Rec
13689 (p_assignment_id => p_assignment_id
13690 ,p_effective_date => p_effective_date
13691 ,p_ext_dtl_rcd_id => l_rcd_id
13692 ,p_rslt_rec => l_main_rec
13693 ,p_error_message => p_error_message
13694 );
13695 END IF;
13696 END LOOP;
13697
13698 END IF;
13699 l_contrib_rec_41_disp := 'N';
13700 l_ret_val := 0;
13701
13702 END IF;
13703
13704 Hr_Utility.set_location(' Leaving '||l_proc_name , 15);
13705
13706 RETURN l_ret_val;
13707
13708 END Process_Mult_Rec41;
13709
13710 --============================================================================
13711 --Function to return the contribution amount towards FUR Pensions
13712 --============================================================================
13713 FUNCTION Get_FUR_Contribution_Amt
13714 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13715 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
13716 ,p_effective_date IN Date
13717 ,p_error_message OUT NOCOPY Varchar2
13718 ,p_data_element_value OUT NOCOPY Varchar2
13719 ) RETURN Number IS
13720
13721 --cursor to check if run results exist for any FUR Pension Types for this assignment
13722 --in this period
13723 CURSOR c_run_results_exist IS
13724 SELECT paa.assignment_action_id
13725 FROM pay_payroll_actions ppa,pay_assignment_actions paa
13726 WHERE paa.payroll_action_id = ppa.payroll_action_id
13727 AND ppa.date_earned BETWEEN g_extract_params(p_business_group_id).extract_start_date
13728 AND g_extract_params(p_business_group_id).extract_end_date
13729 AND paa.assignment_id = p_assignment_id
13730 AND paa.assignment_action_id IN
13731 (SELECT assignment_action_id
13732 FROM pay_run_results
13733 WHERE element_type_id IN
13734 (SELECT element_type_id
13735 FROM pay_element_type_extra_info,pqp_pension_types_f pty
13736 WHERE information_type = 'PQP_NL_ABP_DEDUCTION'
13737 AND eei_information_category = 'PQP_NL_ABP_DEDUCTION'
13738 AND eei_information2 = Fnd_Number.number_to_canonical(pty.pension_type_id)
13739 AND pty.pension_sub_category = 'FUR_S'
13740 )
13741 );
13742
13743 l_asg_act_id Number;
13744 l_defined_balance_id Number;
13745 l_proc Varchar2(30) := 'get_fur_contribution_amt';
13746
13747
13748 BEGIN
13749
13750 --find the defined balance id for the FUR Standard EE Contribution for the _ASG_PTD dimension
13751 Hr_Utility.set_location('Entering : '||l_proc,10);
13752 OPEN csr_defined_bal(c_balance_name => 'FUR Standard EE Contribution'
13753 ,c_dimension_name => 'Assignment Period To Date'
13754 ,c_business_group_id => p_business_group_id
13755 );
13756 FETCH csr_defined_bal INTO l_defined_balance_id;
13757 IF csr_defined_bal%FOUND THEN
13758 CLOSE csr_defined_bal;
13759 Hr_Utility.set_location('found defined balance id : '||l_defined_balance_id,20);
13760 --Find the assignment action of the payroll run if any FUR Pensions has been processed and
13761 --if the date earned for that payroll run , is between the extract start and end dates
13762 OPEN c_run_results_exist;
13763 FETCH c_run_results_exist INTO l_asg_act_id;
13764 IF c_run_results_exist%FOUND THEN
13765 --assignment action id has been found, now find the value for the EE contribution
13766 --from the dimension _ASG_PTD
13767 CLOSE c_run_results_exist;
13768 Hr_Utility.set_location('found asg action id : '||l_asg_act_id,30);
13769 --from the assignment action id,and defined balance id fetched above , find the balance value
13770 p_data_element_value := Fnd_Number.number_to_canonical(
13771 Pay_Balance_Pkg.get_value(p_defined_balance_id => l_defined_balance_id
13772 ,p_assignment_action_id => l_asg_act_id
13773 ));
13774 Hr_Utility.set_location('found value for the contribution as : '||p_data_element_value,40);
13775 g_fur_contribution := Fnd_Number.canonical_to_number(p_data_element_value);
13776 RETURN 0;
13777 ELSE
13778 CLOSE c_run_results_exist;
13779 Hr_Utility.set_location('could not find the asg action id',50);
13780 p_data_element_value := '';
13781 p_error_message := 'Could not find a value for the Contribution amount towards FUR Pensions.';
13782 RETURN 1;
13783 END IF;
13784 ELSE
13785 CLOSE csr_defined_bal;
13786 Hr_Utility.set_location('could not find the defined balance id',60);
13787 p_data_element_value := '';
13788 p_error_message := 'Could not find the defined balance id for the contribution balance.';
13789 RETURN 1;
13790 END IF;
13791
13792 EXCEPTION
13793 WHEN Others THEN
13794 p_error_message :='SQL-ERRM :'||SQLERRM;
13795 Hr_Utility.set_location('..'||p_error_message,70);
13796 RETURN 1;
13797 END get_fur_contribution_amt;
13798
13799 --============================================================================
13800 --Function to return the contribution basis towards FUR/IPAP Pensions
13801 --============================================================================
13802 FUNCTION Get_Contribution_Basis
13803 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13804 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
13805 ,p_effective_date IN Date
13806 ,p_sub_cat IN Varchar2
13807 ,p_error_message OUT NOCOPY Varchar2
13808 ,p_data_element_value OUT NOCOPY Varchar2
13809 ) RETURN Number IS
13810
13811 --cursor to check if run results exist for any FUR/IPAP Pension Types for this assignment
13812 --in this period,and if so fetch the Scheme Prefix so that the basis balance name can be constructed
13813 CURSOR c_run_results_exist IS
13814 SELECT prr.assignment_action_id,
13815 pei.eei_information9
13816 FROM pay_run_results prr,
13817 pay_payroll_actions ppa,
13818 pay_assignment_actions paa,
13819 pay_element_type_extra_info pei,
13820 pqp_pension_types_f pty
13821 WHERE paa.assignment_action_id = prr.assignment_action_id
13822 AND paa.payroll_action_id = ppa.payroll_action_id
13823 AND ppa.date_earned BETWEEN g_extract_params(p_business_group_id).extract_start_date
13824 AND g_extract_params(p_business_group_id).extract_end_date
13825 AND paa.assignment_id = p_assignment_id
13826 AND pei.element_type_id = prr.element_type_id
13827 AND pei.information_type = 'PQP_NL_ABP_DEDUCTION'
13828 AND pei.eei_information_category = 'PQP_NL_ABP_DEDUCTION'
13829 AND pei.eei_information2 = Fnd_Number.number_to_canonical(pty.pension_type_id)
13830 AND pty.pension_sub_category = p_sub_cat;
13831
13832 l_asg_act_id Number;
13833 l_scheme_prefix Varchar2(150);
13834 l_defined_balance_id Number;
13835 l_proc Varchar2(30) := 'get_contribution_basis';
13836
13837
13838 BEGIN
13839
13840 Hr_Utility.set_location('sub category is : '||p_sub_cat,10);
13841 OPEN c_run_results_exist;
13842 FETCH c_run_results_exist INTO l_asg_act_id,l_scheme_prefix;
13843 IF c_run_results_exist%FOUND THEN
13844 CLOSE c_run_results_exist;
13845 --find the defined balance id for the Pension Basis balance for the _ASG_RUN dimension
13846 Hr_Utility.set_location('Entering : '||l_proc,10);
13847 Hr_Utility.set_location('asg act id : '||l_asg_act_id,15);
13848 Hr_Utility.set_location('scheme prefix : '||l_scheme_prefix,20);
13849 OPEN csr_defined_bal(c_balance_name => l_scheme_prefix||' Employee Pension Basis'
13850 ,c_dimension_name => 'Assignment Run'
13851 ,c_business_group_id => p_business_group_id
13852 );
13853 FETCH csr_defined_bal INTO l_defined_balance_id;
13854 IF csr_defined_bal%FOUND THEN
13855 CLOSE csr_defined_bal;
13856 Hr_Utility.set_location('found defined balance id : '||l_defined_balance_id,20);
13857 --from the assignment action id,and defined balance id fetched above , find the balance value
13858 p_data_element_value := Fnd_Number.number_to_canonical(
13859 Pay_Balance_Pkg.get_value(p_defined_balance_id => l_defined_balance_id
13860 ,p_assignment_action_id => l_asg_act_id
13861 ));
13862 Hr_Utility.set_location('found value for the contribution as : '||p_data_element_value,40);
13863 IF p_sub_cat = 'FUR_S' THEN
13864 g_fur_contribution := Fnd_Number.canonical_to_number(p_data_element_value);
13865 RETURN 0;
13866 ELSIF p_sub_cat = 'IPAP' THEN
13867 g_ipap_contribution := Fnd_Number.canonical_to_number(p_data_element_value);
13868 RETURN 0;
13869 END IF;
13870 ELSE
13871 CLOSE csr_defined_bal;
13872 Hr_Utility.set_location('could not find the defined balance id',60);
13873 p_data_element_value := '';
13874 p_error_message := 'Could not find the defined balance id for the contribution balance.';
13875 RETURN 1;
13876 END IF;
13877 ELSE
13878 CLOSE c_run_results_exist;
13879 Hr_Utility.set_location('Employee does not contribute towards pensions ',65);
13880 p_data_element_value := '';
13881 p_error_message := 'Could not find run results.';
13882 RETURN 1;
13883 END IF;
13884
13885 EXCEPTION
13886 WHEN Others THEN
13887 p_error_message :='SQL-ERRM :'||SQLERRM;
13888 Hr_Utility.set_location('..'||p_error_message,70);
13889 RETURN 1;
13890 END get_contribution_basis;
13891
13892 -- =============================================================================
13893 -- Get_Basis_Amt for Record 09/31/41
13894 -- This Function returns the Basis Contribution amount for any sub cats in
13895 -- rec 09/31/41 that the ee might have paid for .
13896 -- =============================================================================
13897 FUNCTION Get_Basis_Amt
13898 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13899 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
13900 ,p_effective_date IN Date
13901 ,p_record_number IN Number
13902 ,p_error_message OUT NOCOPY Varchar2
13903 ,p_data_element_value OUT NOCOPY Varchar2)
13904 RETURN Number IS
13905
13906 l_proc_name Varchar2(150) := g_proc_name ||'Get_Basis_Amt';
13907 j Number ;
13908
13909 BEGIN
13910
13911 Hr_Utility.set_location(' Entering : ' || l_proc_name , 10);
13912 IF p_record_number = 9 THEN
13913 IF l_rec_09_values.count > 0 THEN
13914 j := l_rec_09_values.FIRST;
13915 IF l_rec_09_values.EXISTS(j) THEN
13916 p_data_element_value :=
13917 Fnd_Number.number_to_canonical(l_rec_09_values(j).basis_amount);
13918 END IF;
13919 END IF;
13920 ELSIF p_record_number = 31 THEN
13921 IF l_rec_31_values.count > 0 THEN
13922 j := l_rec_31_values.FIRST;
13923 IF l_rec_31_values.EXISTS(j) THEN
13924 p_data_element_value :=
13925 Fnd_Number.number_to_canonical(l_rec_31_values(j).basis_amount);
13926 END IF;
13927 END IF;
13928 ELSIF p_record_number = 41 THEN
13929 IF l_rec_41_basis_values.count > 0 THEN
13930 j := l_rec_41_basis_values.FIRST;
13931 IF l_rec_41_basis_values.EXISTS(j) THEN
13932 p_data_element_value :=
13933 Fnd_Number.number_to_canonical(l_rec_41_basis_values(j).basis_amount);
13934 END IF;
13935 END IF;
13936 END IF;
13937
13938 Hr_Utility.set_location(' Leaving : ' || l_proc_name , 80);
13939
13940 RETURN 0 ;
13941
13942 EXCEPTION
13943 WHEN Others THEN
13944 p_error_message :='SQL-ERRM :'||SQLERRM;
13945 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
13946 RETURN -1 ;
13947 END Get_Basis_Amt;
13948
13949 -- =============================================================================
13950 -- Get_Sub_Cat_09 for Record 09
13951 -- This Function gets the sub categories for rec 09
13952 -- =============================================================================
13953 FUNCTION Get_Sub_Cat_09
13954 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13955 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
13956 ,p_effective_date IN Date
13957 ,p_error_message OUT NOCOPY Varchar2
13958 ,p_data_element_value OUT NOCOPY Varchar2)
13959 RETURN Number IS
13960
13961 l_proc_name Varchar2(150) := g_proc_name ||'Get_Sub_Cat_09';
13962 j Number ;
13963
13964 BEGIN
13965
13966 Hr_Utility.set_location(' Entering : ' || l_proc_name , 10);
13967 IF l_rec_09_values.count > 0 THEN
13968 j := l_rec_09_values.FIRST;
13969 IF l_rec_09_values.EXISTS(j) THEN
13970 p_data_element_value := l_rec_09_values(j).code;
13971 END IF;
13972 END IF;
13973
13974 Hr_Utility.set_location(' Leaving : ' || l_proc_name , 80);
13975
13976 RETURN 0 ;
13977
13978 EXCEPTION
13979 WHEN Others THEN
13980 p_error_message :='SQL-ERRM :'||SQLERRM;
13981 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
13982 RETURN -1 ;
13983 END Get_Sub_Cat_09;
13984
13985 -- =============================================================================
13986 -- Get_Basis_Amt_Code for Record 09/31/41
13987 -- This Function gets sign for basis amount in rec 09/31/41
13988 -- =============================================================================
13989 FUNCTION Get_Basis_Amt_Code
13990 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13991 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
13992 ,p_effective_date IN Date
13993 ,p_record_number IN Number
13994 ,p_error_message OUT NOCOPY Varchar2
13995 ,p_data_element_value OUT NOCOPY Varchar2)
13996 RETURN Number IS
13997
13998 l_proc_name Varchar2(150) := g_proc_name ||'Get_Basis_Amt_Code';
13999 j Number ;
14000
14001 BEGIN
14002
14003 Hr_Utility.set_location(' Entering : ' || l_proc_name , 10);
14004 IF p_record_number = 9 THEN
14005 IF l_rec_09_values.count > 0 THEN
14006 j := l_rec_09_values.FIRST;
14007 IF l_rec_09_values.EXISTS(j) THEN
14008 p_data_element_value := l_rec_09_values(j).sign_code;
14009 END IF;
14010 END IF;
14011 ELSIF p_record_number = 31 THEN
14012 IF l_rec_31_values.count > 0 THEN
14013 j := l_rec_31_values.FIRST;
14014 IF l_rec_31_values.EXISTS(j) THEN
14015 p_data_element_value := l_rec_31_values(j).sign_code;
14016 END IF;
14017 END IF;
14018 ELSIF p_record_number = 41 THEN
14019 IF l_rec_41_basis_values.count > 0 THEN
14020 j := l_rec_41_basis_values.FIRST;
14021 IF l_rec_41_basis_values.EXISTS(j) THEN
14022 p_data_element_value := l_rec_41_basis_values(j).sign_code;
14023 END IF;
14024 END IF;
14025 END IF;
14026
14027 Hr_Utility.set_location(' Leaving : ' || l_proc_name , 80);
14028
14029 RETURN 0 ;
14030
14031 EXCEPTION
14032 WHEN Others THEN
14033 p_error_message :='SQL-ERRM :'||SQLERRM;
14034 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
14035 RETURN -1 ;
14036 END Get_Basis_Amt_Code;
14037
14038 -- =============================================================================
14039 -- Get_Contrib_Amt_Code for Record 12/41
14040 -- This Function gets sign for contrib amount in rec 12/41
14041 -- =============================================================================
14042 FUNCTION Get_Contrib_Amt_Code
14043 ( p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
14044 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
14045 ,p_effective_date IN Date
14046 ,p_record_number IN Number
14047 ,p_error_message OUT NOCOPY Varchar2
14048 ,p_data_element_value OUT NOCOPY Varchar2)
14049 RETURN Number IS
14050
14051 l_proc_name Varchar2(150) := g_proc_name ||'Get_Contrib_Amt_Code';
14052 j Number ;
14053
14054 BEGIN
14055
14056 Hr_Utility.set_location(' Entering : ' || l_proc_name , 10);
14057 IF p_record_number = 12 THEN
14058 IF l_rec_12_values.count > 0 THEN
14059 j := l_rec_12_values.FIRST;
14060 IF l_rec_12_values.EXISTS(j) THEN
14061 IF l_rec_12_values(j).contrib_amount < 0 THEN
14062 p_data_element_value := 'C';
14063 ELSE
14064 p_data_element_value := ' ';
14065 END IF;
14066 END IF;
14067 END IF;
14068 ELSIF p_record_number = 41 THEN
14069 IF l_rec_41_contrib_values.count > 0 THEN
14070 j := l_rec_41_contrib_values.FIRST;
14071 IF l_rec_41_contrib_values.EXISTS(j) THEN
14072 IF l_rec_41_contrib_values(j).contrib_amount < 0 THEN
14073 p_data_element_value := 'C';
14074 ELSE
14075 p_data_element_value := ' ';
14076 END IF;
14077 END IF;
14078 END IF;
14079 END IF;
14080
14081 Hr_Utility.set_location(' Leaving : ' || l_proc_name , 80);
14082
14083 RETURN 0 ;
14084
14085 EXCEPTION
14086 WHEN Others THEN
14087 p_error_message :='SQL-ERRM :'||SQLERRM;
14088 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
14089 RETURN -1 ;
14090 END Get_Contrib_Amt_Code;
14091
14092
14093 --============================================================================
14094 --Function to return the contribution amount towards IPAP Pensions
14095 --============================================================================
14096 FUNCTION Get_IPAP_Contribution_Amt
14097 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
14098 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
14099 ,p_effective_date IN Date
14100 ,p_error_message OUT NOCOPY Varchar2
14101 ,p_data_element_value OUT NOCOPY Varchar2
14102 ) RETURN Number IS
14103
14104 --cursor to check if run results exist for any IPAP Pension Types for this assignment
14105 --in this period
14106 CURSOR c_run_results_exist IS
14107 SELECT paa.assignment_action_id
14108 FROM pay_payroll_actions ppa,pay_assignment_actions paa
14109 WHERE paa.payroll_action_id = ppa.payroll_action_id
14110 AND ppa.date_earned BETWEEN g_extract_params(p_business_group_id).extract_start_date
14111 AND g_extract_params(p_business_group_id).extract_end_date
14112 AND paa.assignment_id = p_assignment_id
14113 AND paa.assignment_action_id IN
14114 (SELECT assignment_action_id
14115 FROM pay_run_results
14116 WHERE element_type_id IN
14117 (SELECT element_type_id
14118 FROM pay_element_type_extra_info,pqp_pension_types_f pty
14119 WHERE information_type = 'PQP_NL_ABP_DEDUCTION'
14120 AND eei_information_category = 'PQP_NL_ABP_DEDUCTION'
14121 AND eei_information2 = Fnd_Number.number_to_canonical(pty.pension_type_id)
14122 AND pty.pension_sub_category = 'IPAP'
14123 )
14124 );
14125
14126 l_asg_act_id Number;
14127 l_defined_balance_id Number;
14128 l_proc Varchar2(30) := 'get_ipap_contribution_amt';
14129
14130 BEGIN
14131
14132 --find the defined balance id for the IPAP Standard EE Contribution for the _ASG_PTD dimension
14133 Hr_Utility.set_location('Entering : '||l_proc,10);
14134 OPEN csr_defined_bal(c_balance_name => 'IPAP EE Contribution'
14135 ,c_dimension_name => 'Assignment Period To Date'
14136 ,c_business_group_id => p_business_group_id
14137 );
14138 FETCH csr_defined_bal INTO l_defined_balance_id;
14139 IF csr_defined_bal%FOUND THEN
14140 CLOSE csr_defined_bal;
14141 Hr_Utility.set_location('found defined balance id : '||l_defined_balance_id,20);
14142 --Find the assignment action of the payroll run if any IPAP Pensions has been processed and
14143 --if the date earned for that payroll run , is between the extract start and end dates
14144 OPEN c_run_results_exist;
14145 FETCH c_run_results_exist INTO l_asg_act_id;
14146 IF c_run_results_exist%FOUND THEN
14147 --assignment action id has been found, now find the value for the EE contribution
14148 --from the dimension _ASG_PTD
14149 CLOSE c_run_results_exist;
14150 Hr_Utility.set_location('found asg action id : '||l_asg_act_id,30);
14151 --from the assignment action id,and defined balance id fetched above , find the balance value
14152 p_data_element_value := Fnd_Number.number_to_canonical(
14153 Pay_Balance_Pkg.get_value(p_defined_balance_id => l_defined_balance_id
14154 ,p_assignment_action_id => l_asg_act_id
14155 ));
14156 Hr_Utility.set_location('found value for the contribution as : '||p_data_element_value,40);
14157 g_ipap_contribution := Fnd_Number.canonical_to_number(p_data_element_value);
14158 RETURN 0;
14159 ELSE
14160 CLOSE c_run_results_exist;
14161 Hr_Utility.set_location('could not find the asg action id',50);
14162 p_data_element_value := '';
14163 p_error_message := 'Could not find a value for the Contribution amount towards IPAP Pensions.';
14164 RETURN 1;
14165 END IF;
14166 ELSE
14167 CLOSE csr_defined_bal;
14168 Hr_Utility.set_location('could not find the defined balance id',60);
14169 p_data_element_value := '';
14170 p_error_message := 'Could not find the defined balance id for the contribution balance.';
14171 RETURN 1;
14172 END IF;
14173
14174 EXCEPTION
14175 WHEN Others THEN
14176 p_error_message :='SQL-ERRM :'||SQLERRM;
14177 Hr_Utility.set_location('..'||p_error_message,70);
14178 RETURN 1;
14179 END get_ipap_contribution_amt;
14180
14181 --============================================================================
14182 --This function returns the code to indicate whether the basis/contribution is positive
14183 --or negative
14184 --============================================================================
14185 FUNCTION Get_Amt_Code
14186 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
14187 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
14188 ,p_effective_date IN Date
14189 ,p_sub_cat IN Varchar2
14190 ,p_error_message OUT NOCOPY Varchar2
14191 ,p_data_element_value OUT NOCOPY Varchar2
14192 ) RETURN Number IS
14193
14194 l_proc_name Varchar2(30) := 'Get_Amt_Code';
14195
14196 BEGIN
14197
14198 Hr_Utility.set_location('Entering : -----------'||l_proc_name,5);
14199 IF p_sub_cat = 'FUR_S' THEN
14200 IF g_fur_contribution >= 0 THEN
14201 p_data_element_value := ' ';
14202 RETURN 0;
14203 ELSE
14204 p_data_element_value := 'C';
14205 RETURN 0;
14206 END IF;
14207 ELSIF p_sub_cat = 'IPAP' THEN
14208 IF g_ipap_contribution >= 0 THEN
14209 p_data_element_value := ' ';
14210 RETURN 0;
14211 ELSE
14212 p_data_element_value := 'C';
14213 RETURN 0;
14214 END IF;
14215 END IF;
14216
14217 EXCEPTION
14218 WHEN Others THEN
14219 p_error_message :='SQL-ERRM :'||SQLERRM;
14220 Hr_Utility.set_location('..'||p_error_message,10);
14221 Hr_Utility.set_location('Leaving:-------- '||l_proc_name, 15);
14222 RETURN -1;
14223
14224 END Get_Amt_Code;
14225
14226 --============================================================================
14227 --This function returns the month of contribution
14228 --============================================================================
14229 FUNCTION Get_Amt_Month
14230 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
14231 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
14232 ,p_effective_date IN Date
14233 ,p_error_message OUT NOCOPY Varchar2
14234 ,p_data_element_value OUT NOCOPY Varchar2
14235 ) RETURN Number IS
14236
14237 l_proc_name Varchar2(30) := 'Get_Amt_Month';
14238 l_month Varchar2(4);
14239
14240 --cursor to fetch the month from the effective date
14241 CURSOR c_get_amt_month IS
14242 SELECT To_Char(p_effective_date,'MM')
14243 FROM dual;
14244
14245 BEGIN
14246 Hr_Utility.set_location('Entering:-------- '||l_proc_name, 5);
14247 OPEN c_get_amt_month;
14248 FETCH c_get_amt_month INTO l_month;
14249 CLOSE c_get_amt_month;
14250 Hr_Utility.set_location('month of amt is : '||l_month,7);
14251 p_data_element_value := l_month;
14252 RETURN 0;
14253
14254 EXCEPTION
14255 WHEN Others THEN
14256 p_error_message :='SQL-ERRM :'||SQLERRM;
14257 Hr_Utility.set_location('..'||p_error_message,10);
14258 Hr_Utility.set_location('Leaving:-------- '||l_proc_name, 15);
14259 RETURN -1;
14260
14261 END Get_Amt_Month;
14262
14263 --============================================================================
14264 --This function returns the year of contribution
14265 --============================================================================
14266 FUNCTION Get_Amt_Year
14267 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
14268 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
14269 ,p_effective_date IN DATE
14270 ,p_error_message OUT NOCOPY VARCHAR2
14271 ,p_data_element_value OUT NOCOPY VARCHAR2)
14272 RETURN NUMBER IS
14273
14274 l_proc_name VARCHAR2(30) := 'Get_Amt_Year';
14275 l_year VARCHAR2(8);
14276
14277 --
14278 --Cursor to fetch the year from the effective date
14279 --
14280 CURSOR c_get_amt_year IS
14281 SELECT TO_CHAR(p_effective_date,'YYYY')
14282 FROM dual;
14283
14284 BEGIN
14285
14286 hr_utility.set_location('Entering :------- '||l_proc_name,5);
14287
14288 OPEN c_get_amt_year;
14289 FETCH c_get_amt_year INTO l_year;
14290 CLOSE c_get_amt_year;
14291
14292 p_data_element_value := l_year;
14293
14294 hr_utility.set_location('Year is :------- '||l_year,10);
14295 hr_utility.set_location('Leaving :------- '||l_proc_name,15);
14296
14297 RETURN 0;
14298
14299 EXCEPTION
14300 WHEN OTHERS THEN
14301 p_error_message :='SQL-ERRM :'||SQLERRM;
14302 hr_utility.set_location('..ERROR'||p_error_message,10);
14303 hr_utility.set_location('Leaving:-------- '||l_proc_name, 15);
14304 RETURN -1;
14305
14306 END Get_Amt_Year;
14307
14308 --============================================================================
14309 --This function returns the kind of contribution for FUR Pensions, from the ASG EIT
14310 --============================================================================
14311 FUNCTION Get_Fur_Contribution_Kind
14312 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
14313 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
14314 ,p_effective_date IN Date
14315 ,p_error_message OUT NOCOPY Varchar2
14316 ,p_data_element_value OUT NOCOPY Varchar2
14317 ) RETURN Number IS
14318
14319 l_proc_name Varchar2(30) := 'Get_Fur_Contribution_Kind';
14320 l_kind_of_contrib Varchar2(1) := 'D';
14321
14322 --cursor to fetch the contribution kind from the ASG EIT
14323 CURSOR c_get_contrib_kind IS
14324 SELECT Substr(Nvl(aei_information7,'D'),0,1)
14325 FROM per_assignment_extra_info
14326 WHERE assignment_id = p_assignment_id
14327 AND p_effective_date BETWEEN Fnd_Date.canonical_to_date(aei_information1)
14328 AND Fnd_Date.canonical_to_date(Nvl(aei_information2,Fnd_Date.date_to_canonical(Hr_Api.g_eot)))
14329 AND aei_information_category = 'NL_ABP_RI'
14330 AND information_type = 'NL_ABP_RI';
14331
14332 BEGIN
14333
14334 Hr_Utility.set_location('Entering ------ : '||l_proc_name,5);
14335 OPEN c_get_contrib_kind;
14336 FETCH c_get_contrib_kind INTO l_kind_of_contrib;
14337 IF c_get_contrib_kind%FOUND THEN
14338 CLOSE c_get_contrib_kind;
14339 ELSE
14340 CLOSE c_get_contrib_kind;
14341 l_kind_of_contrib := 'D';
14342 END IF;
14343
14344 Hr_Utility.set_location('value of kind of contribution : '||l_kind_of_contrib,10);
14345 p_data_element_value := l_kind_of_contrib;
14346 g_fur_contrib_kind := l_kind_of_contrib;
14347 RETURN 0;
14348
14349 EXCEPTION
14350 WHEN Others THEN
14351 p_error_message :='SQL-ERRM :'||SQLERRM;
14352 Hr_Utility.set_location('..'||p_error_message,15);
14353 Hr_Utility.set_location('Leaving:-------- '||l_proc_name, 20);
14354 RETURN -1;
14355
14356 END Get_Fur_Contribution_Kind;
14357
14358 --=============================================================================
14359 --Function to return the kind of insurance between IPAP and ANW
14360 --=============================================================================
14361 FUNCTION Get_Ins_Cd_Anw_Ipap
14362 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
14363 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
14364 ,p_effective_date IN Date
14365 ,p_error_message OUT NOCOPY Varchar2
14366 ,p_data_element_value OUT NOCOPY Varchar2
14367 ) RETURN Number IS
14368
14369 l_proc_name Varchar2(30) := 'Get_Ins_Cd_Anw_Ipap';
14370 j number;
14371
14372 BEGIN
14373 Hr_Utility.set_location('Entering : '||l_proc_name,10);
14374
14375 j := l_rec_31_values.FIRST;
14376 IF l_rec_31_values.EXISTS(j) THEN
14377 p_data_element_value := l_rec_31_values(j).code;
14378 g_ins_cd_anw_ipap := l_rec_31_values(j).code;
14379 END IF;
14380 Hr_Utility.set_location('Leaving : '||l_proc_name,20);
14381 RETURN 0;
14382
14383 EXCEPTION
14384 WHEN Others THEN
14385 p_error_message :='SQL-ERRM :'||SQLERRM;
14386 Hr_Utility.set_location('..'||p_error_message,15);
14387 Hr_Utility.set_location('Leaving:-------- '||l_proc_name, 20);
14388 RETURN -1;
14389 END Get_Ins_Cd_Anw_Ipap;
14390
14391 --============================================================================
14392 --Function to return the type of insurance between IPAP and ANW
14393 --depending on the kind of insurance
14394 --============================================================================
14395 FUNCTION Get_Ins_Typ_Anw_Ipap
14396 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
14397 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
14398 ,p_effective_date IN Date
14399 ,p_error_message OUT NOCOPY Varchar2
14400 ,p_data_element_value OUT NOCOPY Varchar2
14401 ) RETURN Number IS
14402
14403 --cursor to fetch the insurance type data from the assignment EIT
14404 CURSOR c_get_ins_type IS
14405 SELECT Substr(Nvl(aei_information5,'01'),0,2),Substr(Nvl(aei_information6,'01'),0,2)
14406 FROM per_assignment_extra_info
14407 WHERE assignment_id = p_assignment_id
14408 AND aei_information_category = 'NL_ABP_RI'
14409 AND information_type = 'NL_ABP_RI'
14410 AND p_effective_date BETWEEN Fnd_Date.canonical_to_date(aei_information1)
14411 AND Fnd_Date.canonical_to_date(Nvl(aei_information2,Fnd_Date.date_to_canonical(Hr_Api.g_eot)));
14412
14413 l_proc_name Varchar2(30) := 'Get_Ins_Typ_Anw_Ipap';
14414 l_anw_type Varchar2(2) := '01';
14415 l_ipap_type Varchar2(2) := '01';
14416
14417 BEGIN
14418
14419 Hr_Utility.set_location('Entering : '||l_proc_name,10);
14420 OPEN c_get_ins_type;
14421 FETCH c_get_ins_type INTO l_anw_type,l_ipap_type;
14422 CLOSE c_get_ins_type;
14423 Hr_Utility.set_location('anw ins type : '||l_anw_type,15);
14424 Hr_Utility.set_location('ipap ins type : '||l_ipap_type,17);
14425 Hr_Utility.set_location('ins cd : '||g_ins_cd_anw_ipap,19);
14426
14427 IF g_ins_cd_anw_ipap = '01' THEN
14428 p_data_element_value := l_anw_type;
14429 ELSIF g_ins_cd_anw_ipap = '02' THEN
14430 p_data_element_value := l_ipap_type;
14431 END IF;
14432 RETURN 0;
14433
14434 Hr_Utility.set_location('leaving --------------: '||l_proc_name,20);
14435
14436 EXCEPTION
14437 WHEN Others THEN
14438 p_error_message :='SQL-ERRM :'||SQLERRM;
14439 Hr_Utility.set_location('..'||p_error_message,15);
14440 Hr_Utility.set_location('Leaving:-------- '||l_proc_name, 20);
14441 RETURN -1;
14442
14443 END Get_Ins_Typ_Anw_Ipap;
14444
14445 --function to return the incidental worker status
14446 FUNCTION Get_Incidental_Worker
14447 (p_assignment_id IN Number
14448 ,p_business_group_id IN Number
14449 ,p_effective_date IN Date
14450 ,p_error_message OUT NOCOPY Varchar2
14451 ,p_data_element_value OUT NOCOPY Varchar2
14452 ) RETURN Number IS
14453
14454 --cursor to fetch the incidental worker status from the ASG EIT
14455 CURSOR c_get_incidental_wrkr IS
14456 SELECT Nvl(aei_information3,'0')
14457 FROM per_assignment_extra_info
14458 WHERE information_type = 'NL_USZO_INFO'
14459 AND aei_information_category = 'NL_USZO_INFO'
14460 AND assignment_id = p_assignment_id
14461 AND p_effective_date BETWEEN Fnd_Date.canonical_to_date(aei_information1)
14462 AND Fnd_Date.canonical_to_date(Nvl(aei_information2,Fnd_Date.date_to_canonical(Hr_Api.g_eot)))
14463 AND ROWNUM = 1;
14464
14465 l_incidental_worker Varchar2(1) := '0';
14466
14467 BEGIN
14468 OPEN c_get_incidental_wrkr;
14469 FETCH c_get_incidental_wrkr INTO l_incidental_worker;
14470 IF c_get_incidental_wrkr%FOUND THEN
14471 p_data_element_value := l_incidental_worker;
14472 CLOSE c_get_incidental_wrkr;
14473 ELSE
14474 CLOSE c_get_incidental_wrkr;
14475 p_data_element_value := '0';
14476 END IF;
14477 RETURN 0;
14478
14479 EXCEPTION
14480 WHEN Others THEN
14481 p_error_message :='SQL-ERRM :'||SQLERRM;
14482 p_data_element_value := '';
14483 RETURN -1;
14484
14485 END Get_Incidental_Worker;
14486
14487 --function to get the kind of employment from the UDT
14488 FUNCTION Get_Employment_Kind
14489 (p_assignment_id IN Number
14490 ,p_business_group_id IN Number
14491 ,p_effective_date IN Date
14492 ,p_error_message OUT NOCOPY Varchar2
14493 ,p_data_element_value OUT NOCOPY Varchar2
14494 ) RETURN Number IS
14495
14496 --cursor to fetch the kind of employment code
14497 --from the soft coding key flex
14498 CURSOR c_get_emp_code IS
14499 SELECT scl.SEGMENT2||scl.SEGMENT3
14500 FROM per_all_assignments_f asg
14501 ,hr_soft_coding_keyflex scl
14502 WHERE asg.assignment_id = p_assignment_id
14503 AND p_effective_date BETWEEN asg.effective_start_date
14504 AND asg.effective_end_date
14505 AND asg.soft_coding_keyflex_id = scl.soft_coding_keyflex_id;
14506
14507 l_emp_code Varchar2(120);
14508 l_emp_kind Varchar2(1);
14509 l_proc_name Varchar2(150) := 'Get_Employment_Kind';
14510
14511 BEGIN
14512
14513 Hr_Utility.set_location('Entering : '||l_proc_name,10);
14514 --first fetch the employment code from the soft coding keyflex
14515 OPEN c_get_emp_code;
14516 FETCH c_get_emp_code INTO l_emp_code;
14517 IF c_get_emp_code%FOUND THEN
14518 CLOSE c_get_emp_code;
14519 Hr_Utility.set_location('found the code as : '||l_emp_code,20);
14520 --now from the employment code,fetch the udt data for the value (as 1,2,3 etc)
14521 l_emp_kind := Hruserdt.get_table_value
14522 (p_bus_group_id => p_business_group_id
14523 ,p_table_name => 'NL_EMP_SUB_TYPE_CIB_KOA'
14524 ,p_col_name => 'USZO_KOA'
14525 ,p_row_value => l_emp_code
14526 ,p_effective_date => p_effective_date
14527 );
14528
14529 IF l_emp_kind IS NOT NULL THEN
14530 Hr_Utility.set_location('employment kind is : '||l_emp_kind,30);
14531 p_data_element_value := l_emp_kind;
14532 ELSE
14533 p_data_element_value := '';
14534 END IF;
14535 ELSE
14536 CLOSE c_get_emp_code;
14537 p_data_element_value := '';
14538 END IF;
14539 Hr_Utility.set_location('data element value is : '||p_data_element_value,40);
14540 Hr_Utility.set_location('Leaving : '||l_proc_name,50);
14541 RETURN 0;
14542
14543 EXCEPTION
14544
14545 WHEN NO_DATA_FOUND THEN
14546 p_data_element_value := '';
14547 RETURN 0;
14548
14549 WHEN Others THEN
14550 p_error_message := SQLERRM;
14551 Hr_Utility.set_location('error message : '||SQLERRM,10);
14552 Hr_Utility.set_location('Leaving : '||l_proc_name,50);
14553 p_data_element_value := '';
14554 RETURN 1;
14555
14556 END Get_Employment_Kind;
14557
14558 -- ================================================================================
14559 -- Change_Date : The effective date for EE and ER Number changes
14560 -- ================================================================================
14561
14562 FUNCTION Get_Change_Date
14563 (p_assignment_id IN NUMBER
14564 ,p_business_group_id IN NUMBER
14565 ,p_effective_date IN DATE
14566 ,p_error_message OUT NOCOPY VARCHAR2
14567 ,p_data_element_value OUT NOCOPY VARCHAR2
14568 ) RETURN NUMBER IS
14569
14570 CURSOR csr_get_dt (c_assignment_id IN NUMBER) IS
14571 SELECT fnd_date.canonical_to_date(aei_information3)
14572 FROM per_assignment_extra_info
14573 WHERE assignment_id = p_assignment_id
14574 AND information_type = 'PQP_NL_ABP_OLD_EE_INFO';
14575
14576 l_return_value NUMBER := -1;
14577 l_proc_name VARCHAR2(150) := 'Get_Change_Date';
14578 l_eff_dt DATE;
14579
14580
14581 BEGIN
14582
14583 Hr_Utility.set_location('Entering : '||l_proc_name,10);
14584
14585 OPEN csr_get_dt(p_assignment_id);
14586 FETCH csr_get_dt INTO l_eff_dt;
14587 CLOSE csr_get_dt;
14588
14589 p_data_element_value := Upper(nvl(TO_CHAR(l_eff_dt,'YYYYMMDD'),'00000000'));
14590
14591 l_return_value := 0 ;
14592
14593 Hr_Utility.set_location('l_return_value : '||l_return_value,30);
14594 Hr_Utility.set_location('p_data_element_value : '||p_data_element_value,40);
14595 Hr_Utility.set_location('Leaving : '||l_proc_name,50);
14596
14597 RETURN l_return_value;
14598
14599 END Get_Change_Date;
14600
14601 -- ================================================================================
14602 -- ~ Sort_Id_Generator : It is concatenated with ernum+empNumber+record.
14603 -- ================================================================================
14604 FUNCTION Sort_Id_Generator
14605 (p_assignment_id IN Number
14606 ,p_business_group_id IN Number
14607 ,p_effective_date IN Date
14608 ,p_generator_record IN Varchar2
14609 ,p_error_message OUT NOCOPY Varchar2
14610 ,p_data_element_value OUT NOCOPY Varchar2
14611 ) RETURN Number IS
14612
14613 l_temp_sort_id Varchar2(50);
14614 l_proc_name Varchar2(150) := g_proc_name ||'Sort_Id_Generator';
14615 l_employee_number per_all_people_f.Employee_number%TYPE;
14616 l_temp_person_id per_all_people_f.Employee_number%TYPE;
14617 l_return_value Number := -1;
14618 l_employer_number Number;
14619 l_asg_seq_num Varchar2(2);
14620
14621 BEGIN
14622 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
14623 -- Get the orgId for assigntment ID
14624 l_return_value := Get_ABP_ER_Num(p_assignment_id
14625 ,p_business_group_id
14626 ,p_effective_date
14627 ,'NEW'
14628 ,p_error_message
14629 ,p_data_element_value);
14630 l_employer_number := Nvl(p_data_element_value,9999999);
14631 l_employer_number := p_data_element_value;
14632 p_data_element_value :='';
14633
14634 IF g_primary_assig.EXISTS(p_assignment_id) THEN
14635 --l_employee_number := substr(g_primary_assig(p_assignment_id).ee_num,2); --9278285
14636 l_employee_number := NVL(substr(g_primary_assig(p_assignment_id).ee_num, g_sort_position), g_primary_assig(p_assignment_id).ee_num) ; --9278285
14637 END IF;
14638
14639 Hr_Utility.set_location('l_employee_number: '||l_employee_number, 5);
14640 l_employer_number := Lpad(l_employer_number,9,0);
14641 l_employee_number := Lpad(l_employee_number,10,0);
14642 l_asg_seq_num := g_primary_assig(p_assignment_id).asg_seq_num;
14643 IF To_Number(Nvl(l_asg_seq_num,'1')) < 10 THEN
14644 l_asg_seq_num := '0' ||Nvl(l_asg_seq_num,'1');
14645 END IF;
14646
14647 /* --9278285 Commented
14648 p_data_element_value := l_employer_number ||
14649 l_employee_number ||
14650 l_asg_seq_num ||
14651 p_generator_record;
14652 */
14653 --9278285
14654 p_data_element_value := l_employee_number ||
14655 l_asg_seq_num ||
14656 p_generator_record;
14657 --9278285
14658
14659 Hr_Utility.set_location('p_data_element_value: '||p_data_element_value, 5);
14660 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
14661 l_return_value := 0;
14662
14663 RETURN l_return_value;
14664 EXCEPTION
14665 WHEN Others THEN
14666 p_error_message :='SQL-ERRM :'||SQLERRM;
14667 Hr_Utility.set_location('..'||p_error_message,85);
14668 RETURN l_return_value;
14669 END Sort_Id_Generator;
14670
14671 -- =============================================================================
14672 -- Org_Id_DataElement
14673 -- =============================================================================
14674
14675 FUNCTION Org_Id_DataElement
14676 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
14677 ,p_business_group_id IN per_all_assignments_f.business_group_id%TYPE
14678 ,p_effective_date IN Date
14679 ,p_error_message OUT NOCOPY Varchar2
14680 ,p_data_element_value OUT NOCOPY Varchar2
14681 ) RETURN Number IS
14682
14683 l_temp_sort_org Varchar2(50);
14684 l_proc_name Varchar2(150) := g_proc_name ||'Sort_Id_Generator';
14685 l_return_value Number := -1;
14686
14687
14688 BEGIN
14689 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
14690
14691 -- rpinjala
14692 IF g_primary_assig.EXISTS(p_assignment_id) THEN
14693 p_data_element_value := g_primary_assig(p_assignment_id).organization_id;
14694 END IF;
14695
14696 l_return_value := 0;
14697 Hr_Utility.set_location('Leaving: '||l_proc_name, 5);
14698 RETURN l_return_value;
14699 EXCEPTION
14700 WHEN Others THEN
14701 p_error_message :='SQL-ERRM :'||SQLERRM;
14702 Hr_Utility.set_location('..'||p_error_message,85);
14703 RETURN l_return_value;
14704 END Org_Id_DataElement;
14705
14706 -- =============================================================================
14707 -- Create_Addl_Assignments:
14708 -- =============================================================================
14709 PROCEDURE Create_Addl_Assignments
14710 (p_assignment_id IN Number
14711 ,p_business_group_id IN Number
14712 ,p_person_id IN Number
14713 ,p_no_asg_action IN OUT NOCOPY Number
14714 ,p_error_message OUT NOCOPY Varchar2)IS
14715
14716 l_ele_type_id pay_element_types_f.element_type_id%TYPE;
14717 l_prev_ele_type_id pay_element_types_f.element_type_id%TYPE;
14718 l_valid_action Varchar2(2);
14719 i per_all_assignments_f.business_group_id%TYPE;
14720 l_ext_dfn_type pqp_extract_attributes.ext_dfn_type%TYPE;
14721 l_proc_name Varchar2(150) := g_proc_name ||'Create_Addl_Assignments';
14722 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
14723 l_organization_id per_all_assignments_f.organization_id%TYPE;
14724 l_business_group_id per_all_assignments_f.business_group_id%TYPE;
14725 l_main_rec csr_rslt_dtl%ROWTYPE;
14726 l_new_rec csr_rslt_dtl%ROWTYPE;
14727 l_effective_date Date;
14728 l_ext_rcd_id ben_ext_rcd.ext_rcd_id%TYPE;
14729 l_record_num Varchar2(20);
14730 l_return_value Varchar2(2);
14731 l_last_name per_all_people_f.last_name%TYPE;
14732 l_dob VARCHAR2(8);
14733 l_prefix per_all_people_f.pre_name_adjunct%TYPE;
14734 l_national_ident per_all_people_f.national_identifier%TYPE;
14735
14736 CURSOR cur_per_info IS
14737 SELECT national_identifier
14738 ,UPPER(last_name)
14739 ,UPPER(pre_name_adjunct)
14740 ,TO_CHAR(date_of_birth,'YYYYMMDD')
14741 FROM per_all_people_f
14742 WHERE person_id = p_person_id
14743 AND g_extract_params(p_business_group_id).extract_end_date
14744 BETWEEN effective_start_date AND effective_end_date ;
14745
14746 BEGIN
14747 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
14748 i := p_business_group_id;
14749
14750 FOR csr_rcd_rec IN csr_ext_rcd_id_hidden
14751 (c_rcd_type_cd => 'D')-- D=Detail, T=Total, H-Header
14752 LOOP
14753 l_ext_rcd_id := csr_rcd_rec.ext_rcd_id;
14754
14755 Hr_Utility.set_location('l_ext_rcd_id: '||l_ext_rcd_id, 5);
14756
14757 --These are single processing reoords
14758 IF g_ext_rcds(l_ext_rcd_id).record_number IN
14759 ('01','02','04','05','08','09','12','20',
14760 '21','22','30','31','40','41','41h') THEN
14761 l_record_num := g_ext_rcds(l_ext_rcd_id).record_number;
14762 OPEN csr_rslt_dtl
14763 (c_person_id => p_person_id
14764 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
14765 ,c_ext_dtl_rcd_id => l_ext_rcd_id
14766 );
14767 FETCH csr_rslt_dtl INTO l_main_rec;
14768
14769 IF csr_rslt_dtl%NOTFOUND THEN
14770 -- The primary assignment does not have a valid record
14771 -- force the creation of the record based on the person information
14772 OPEN cur_per_info;
14773 FETCH cur_per_info INTO l_national_ident,l_last_name,l_prefix,l_dob;
14774 CLOSE cur_per_info;
14775
14776 l_main_rec := NULL;
14777 l_main_rec.ext_rslt_id := ben_ext_thread.g_ext_rslt_id;
14778 l_main_rec.business_group_id := p_business_group_id;
14779 l_main_rec.ext_rcd_id := l_ext_rcd_id;
14780 l_main_rec.person_id := p_person_id;
14781 l_main_rec.val_01 := l_record_num;
14782
14783 IF l_record_num = '04' THEN
14784 l_main_rec.val_05 := l_national_ident;
14785 END IF;
14786
14787 IF l_record_num = '02' THEN
14788 l_main_rec.val_05 := l_national_ident;
14789 l_main_rec.val_07 := l_last_name;
14790 l_main_rec.val_09 := l_prefix;
14791 l_main_rec.val_11 := l_dob;
14792 END IF;
14793
14794 l_main_rec.ext_per_bg_id := p_business_group_id;
14795 l_main_rec.request_id := fnd_global.conc_request_id;
14796 l_main_rec.program_id := fnd_global.conc_program_id;
14797 l_main_rec.program_update_date := SYSDATE;
14798 l_main_rec.scnd_sort_val := 0;
14799 l_main_rec.thrd_sort_val := 0;
14800 l_main_rec.trans_seq_num := 1;
14801 l_main_rec.rcrd_seq_num := 1;
14802
14803 END IF;
14804
14805 CLOSE csr_rslt_dtl;
14806
14807 l_main_rec.object_version_NUMBER
14808 := Nvl(l_main_rec.object_version_NUMBER,0) + 1;
14809 l_new_rec := l_main_rec;
14810 l_assignment_id := p_assignment_id;
14811 l_organization_id := g_primary_assig(p_assignment_id).organization_id;
14812 l_business_group_id := p_business_group_id;
14813 l_effective_date := Least(g_extract_params(i).extract_end_date,
14814 g_primary_assig(p_assignment_id).effective_end_date);
14815 l_return_value := Chk_If_Req_ToExtract
14816 (p_assignment_id => l_assignment_id
14817 ,p_business_group_id => l_business_group_id
14818 ,p_person_id => p_person_id
14819 ,p_effective_date => l_effective_date
14820 ,p_record_num => l_record_num
14821 ,p_error_message => p_error_message);
14822 IF l_return_value = 'Y' THEN
14823 -- Re-Process the person level rule based data-element for the record
14824 -- along with appropiate effective date and assignment id
14825 Process_Ext_Rslt_Dtl_Rec
14826 (p_assignment_id => l_assignment_id
14827 ,p_organization_id => l_organization_id
14828 ,p_effective_date => l_effective_date
14829 ,p_ext_dtl_rcd_id => l_ext_rcd_id
14830 ,p_rslt_rec => l_main_rec
14831 ,p_asgaction_no => p_no_asg_action
14832 ,p_error_message => p_error_message);
14833 END IF; -- IF l_return_value = 'Y'
14834 END IF;
14835 END LOOP;
14836
14837 Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
14838 END Create_Addl_Assignments;
14839
14840 -- =============================================================================
14841 -- Process_Addl_Assigs: Process all the assigs in the PL/SQL table for the
14842 -- person and create the records accordingly.
14843 -- =============================================================================
14844 FUNCTION Process_Addl_Assigs
14845 (p_assignment_id IN Number
14846 ,p_business_group_id IN Number
14847 ,p_effective_date IN Date
14848 ,p_error_message OUT NOCOPY Varchar2
14849 ) RETURN Number IS
14850
14851 l_return_value Number;
14852 i per_all_assignments_f.business_group_id%TYPE;
14853 l_ele_type_id pay_element_types_f.element_type_id%TYPE;
14854 l_prev_ele_type_id pay_element_types_f.element_type_id%TYPE;
14855 l_valid_action Varchar2(2);
14856 l_no_asg_action Number(5) := 0;
14857 l_proc_name Varchar2(150) := g_proc_name ||'Process_Addl_Assigs';
14858 l_sec_assg_rec csr_sec_assg%ROWTYPE;
14859 l_effective_date Date;
14860 l_criteria_value Varchar2(2);
14861 l_warning_message Varchar2(2000);
14862 l_error_message Varchar2(2000);
14863 l_asg_type per_all_assignments_f.assignment_type%TYPE;
14864 l_main_rec csr_rslt_dtl%ROWTYPE;
14865 l_person_id per_all_people_f.person_id%TYPE;
14866 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
14867 l_mutli_assig Varchar2(150);
14868 BEGIN
14869
14870 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
14871
14872 l_mutli_assig := Check_Addl_Assigs
14873 (p_assignment_id => p_assignment_id
14874 ,p_business_group_id => p_business_group_id
14875 ,p_effective_date => p_effective_date
14876 ,p_error_message => p_error_message
14877 );
14878
14879 i := p_business_group_id;
14880 IF g_primary_assig.EXISTS(p_assignment_id) THEN
14881 l_person_id := g_primary_assig(p_assignment_id).person_id;
14882 l_asg_type := g_primary_assig(p_assignment_id).assignment_type;
14883 END IF;
14884 -- For each assignment for this person id check if additional rows need to be
14885 -- created and re-calculate the person level based fast-formulas.
14886 l_assignment_id := g_primary_assig.FIRST;
14887 WHILE l_assignment_id IS NOT NULL
14888 LOOP
14889 Hr_Utility.set_location('..Checking for assignment : '||l_assignment_id, 7);
14890 IF g_primary_assig(l_assignment_id).person_id = l_person_id AND
14891 l_assignment_id <> p_assignment_id AND
14892 g_primary_assig(l_assignment_id).Assignment_Type = 'E' THEN
14893
14894 Hr_Utility.set_location('..Valid Assignment : '||l_assignment_id, 8);
14895 Hr_Utility.set_location('..l_no_asg_action : '||l_no_asg_action, 8);
14896
14897 l_rec_09_values.delete;
14898
14899 Populate_Record_Structures
14900 (p_assignment_id => l_assignment_id
14901 ,p_effective_date => LEAST(g_extract_params(i).extract_end_date,
14902 g_primary_assig(l_assignment_id).effective_end_date)
14903 ,p_business_group_id => p_business_group_id
14904 ,p_error_message => p_error_message );
14905
14906 Create_Addl_Assignments
14907 (p_assignment_id => l_assignment_id
14908 ,p_business_group_id => p_business_group_id
14909 ,p_person_id => l_person_id
14910 ,p_no_asg_action => l_no_asg_action
14911 ,p_error_message => l_error_message
14912 );
14913 l_no_asg_action := l_no_asg_action + 1;
14914 END IF;
14915 l_assignment_id := g_primary_assig.NEXT(l_assignment_id);
14916
14917 END LOOP;
14918 IF l_asg_type = 'B' AND l_no_asg_action = 0 THEN
14919 -- =================================================================
14920 -- This mean that the extract created a row for the benefit's assig.
14921 -- record and that person does not have any employee assig. record
14922 -- within the extract date range specified.
14923 -- =================================================================
14924 FOR csr_rcd_rec IN csr_ext_rcd_id
14925 (c_hide_flag => 'N' -- N=No Y=Yes
14926 ,c_rcd_type_cd => 'D')-- D=Detail, T=Total, H-Header
14927 -- Loop through each detail record for the extract
14928 LOOP
14929 OPEN csr_rslt_dtl
14930 (c_person_id => l_person_id
14931 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
14932 ,c_ext_dtl_rcd_id => csr_rcd_rec.ext_rcd_id
14933 );
14934 FETCH csr_rslt_dtl INTO l_main_rec;
14935 WHILE csr_rslt_dtl%FOUND
14936 LOOP
14937 -- Delete for each detail record for the person
14938 DELETE ben_ext_rslt_dtl
14939 WHERE ext_rslt_dtl_id = l_main_rec.ext_rslt_dtl_id
14940 AND person_id = l_person_id;
14941 FETCH csr_rslt_dtl INTO l_main_rec;
14942
14943 END LOOP; -- While csr_rslt_dtl%FOUND
14944 CLOSE csr_rslt_dtl;
14945 END LOOP; -- FOR csr_rcd_rec
14946 END IF;
14947 -- Delete all the hidden Records for the person
14948 FOR csr_rcd_rec IN csr_ext_rcd_id
14949 (c_hide_flag => 'Y' -- N=No Y=Yes
14950 ,c_rcd_type_cd => 'D')-- D=Detail, T=Total, H-Header
14951 -- Loop through each detail record for the extract
14952 LOOP
14953 OPEN csr_rslt_dtl
14954 (c_person_id => l_person_id
14955 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
14956 ,c_ext_dtl_rcd_id => csr_rcd_rec.ext_rcd_id
14957 );
14958 FETCH csr_rslt_dtl INTO l_main_rec;
14959 WHILE csr_rslt_dtl%FOUND
14960 LOOP
14961 -- Delete for each detail record for the person
14962 DELETE ben_ext_rslt_dtl
14963 WHERE ext_rslt_dtl_id = l_main_rec.ext_rslt_dtl_id
14964 AND person_id = l_person_id;
14965 FETCH csr_rslt_dtl INTO l_main_rec;
14966 END LOOP; -- While csr_rslt_dtl%FOUND
14967 CLOSE csr_rslt_dtl;
14968 END LOOP; -- FOR csr_rcd_rec
14969
14970 -- Once the sec. record has been taken care of all the asg actions
14971 -- remove it from the PL/SQL table.
14972 l_assignment_id := g_primary_assig.FIRST;
14973 WHILE l_assignment_id IS NOT NULL
14974 LOOP
14975 IF g_primary_assig(l_assignment_id).person_id = l_person_id THEN
14976 g_primary_assig.DELETE(l_assignment_id);
14977 END IF;
14978 l_assignment_id := g_primary_assig.NEXT(l_assignment_id);
14979 END LOOP;
14980
14981 Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
14982 RETURN 0;
14983
14984 EXCEPTION
14985 WHEN Others THEN
14986 p_error_message :='SQL-ERRM :'||SQLERRM;
14987 Hr_Utility.set_location('..'||p_error_message,85);
14988 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
14989 RETURN -1;
14990 END Process_Addl_Assigs;
14991
14992 FUNCTION Process_Retro_Hire
14993 (p_assignment_id IN Number
14994 ,p_business_group_id IN Number
14995 ,p_effective_date IN Date
14996 ,p_error_message OUT NOCOPY Varchar2
14997 ) RETURN Number IS
14998
14999 BEGIN
15000
15001 IF g_retro_hires.count > 0 THEN
15002 g_retro_hires.DELETE;
15003 END IF;
15004
15005 RETURN 0;
15006
15007 EXCEPTION
15008 WHEN Others THEN
15009 p_error_message :='SQL-ERRM :'||SQLERRM;
15010 Hr_Utility.set_location('..'||p_error_message,85);
15011 RETURN -1;
15012 END Process_Retro_Hire;
15013
15014 -- =============================================================================
15015 -- Process_Mult_Records: For a given assignment multiple records are created for
15016 -- Records 05, 09, 12, 20, 21, 30, 31, 40 and 41. Addl. rows for the record are
15017 -- provided it satisfies the functional requirements for each record i.e. the
15018 -- record display criteria.
15019 -- =============================================================================
15020 FUNCTION Process_Mult_Records
15021 (p_assignment_id IN Number
15022 ,p_business_group_id IN Number
15023 ,p_effective_date IN Date
15024 ,p_error_message OUT NOCOPY Varchar2
15025 )
15026 RETURN Number IS
15027 l_proc_name Varchar2(150) := g_proc_name ||'Process_Mult_Records';
15028 l_data_element_value Varchar2(150);
15029 l_error_message Varchar2(2000);
15030 l_error_flag Boolean;
15031 l_ret_val Number := 0;
15032
15033 BEGIN
15034 Hr_Utility.set_location('Entering: '||l_proc_name, 4);
15035
15036 -- Process Multiple Records for Record 05
15037 BEGIN
15038 l_ret_val := Process_Mult_Rec05
15039 (p_assignment_id => p_assignment_id
15040 ,p_business_group_id => p_business_group_id
15041 ,p_effective_date => p_effective_date
15042 ,p_error_message => p_error_message
15043 ,p_data_element_value => l_data_element_value);
15044 g_rec05_rows.delete;
15045 Hr_Utility.set_location('..Processed Multi Recds for 05 : '||l_proc_name, 5);
15046 EXCEPTION
15047 WHEN Others THEN
15048 Hr_Utility.set_location('..Error in Multi Recds for 05 : '||l_proc_name, 5);
15049 l_error_message := Substr('SQL-ERRM :'||SQLERRM,1,2000);
15050 l_error_flag := TRUE;
15051 END;
15052 IF l_ret_val <> 0 THEN
15053 l_error_message := 'Error in Process Multi Record 05 for '||
15054 'Assignment Id :'||p_assignment_id;
15055 l_error_flag := TRUE;
15056 END IF;
15057
15058 BEGIN
15059
15060 l_ret_val := Process_Mult_Rec08
15061 (p_assignment_id => p_assignment_id
15062 ,p_business_group_id => p_business_group_id
15063 ,p_effective_date => p_effective_date
15064 ,p_error_message => p_error_message
15065 ,p_data_element_value => l_data_element_value);
15066 Hr_Utility.set_location('..Processed Multi Recds for 08 : '||l_proc_name, 9);
15067 EXCEPTION
15068 WHEN Others THEN
15069 Hr_Utility.set_location('..Error in Multi Recds for 08 : '||l_proc_name, 9);
15070 l_error_message := Substr('SQL-ERRM :'||SQLERRM,1,2000);
15071 l_error_flag := TRUE;
15072 END;
15073 IF l_ret_val <> 0 THEN
15074 l_error_message := 'Error in Process Multi Record 08 for '||
15075 'Assignment Id :'||p_assignment_id;
15076 l_error_flag := TRUE;
15077 END IF;
15078
15079 -- Process Multiple Records for Record 09
15080 BEGIN
15081 l_ret_val := Process_Mult_Rec09
15082 (p_assignment_id => p_assignment_id
15083 ,p_business_group_id => p_business_group_id
15084 ,p_effective_date => p_effective_date
15085 ,p_error_message => p_error_message
15086 ,p_data_element_value => l_data_element_value);
15087 l_rec_09_values.delete;
15088
15089 Hr_Utility.set_location('..Processed Multi Recds for 09 : '||l_proc_name, 9);
15090 EXCEPTION
15091 WHEN Others THEN
15092 Hr_Utility.set_location('..Error in Multi Recds for 09 : '||l_proc_name, 9);
15093 l_error_message := Substr('SQL-ERRM :'||SQLERRM,1,2000);
15094 l_error_flag := TRUE;
15095 END;
15096 IF l_ret_val <> 0 THEN
15097 l_error_message := l_error_message ||
15098 'Error in Processing Multi Record 09 for '||
15099 'Assignment Id :'||p_assignment_id ;
15100 l_error_flag := TRUE;
15101 END IF;
15102
15103 -- Process Multiple Records for Record 12
15104 BEGIN
15105 l_ret_val := Process_Mult_Rec12
15106 (p_assignment_id => p_assignment_id
15107 ,p_business_group_id => p_business_group_id
15108 ,p_effective_date => p_effective_date
15109 ,p_error_message => p_error_message
15110 ,p_data_element_value => l_data_element_value);
15111 l_rec_12_values.delete;
15112 Hr_Utility.set_location('..Processed Multi Recds for 12 : '||l_proc_name, 12);
15113 EXCEPTION
15114 WHEN Others THEN
15115 Hr_Utility.set_location('..Error in Multi Recds for 12 : '||l_proc_name, 12);
15116 l_error_message := Substr('SQL-ERRM :'||SQLERRM,1,2000);
15117 l_error_flag := TRUE;
15118 END;
15119 IF l_ret_val <> 0 THEN
15120 l_error_message := l_error_message ||
15121 'Error in Processing Multi Record 12 for '||
15122 'Assignment Id :'||p_assignment_id ;
15123 l_error_flag := TRUE;
15124 END IF;
15125
15126 -- Process Multiple Records for Record 30
15127 BEGIN
15128 l_ret_val := Process_Mult_Rec30
15129 (p_assignment_id => p_assignment_id
15130 ,p_business_group_id => p_business_group_id
15131 ,p_effective_date => p_effective_date
15132 ,p_error_message => p_error_message
15133 ,p_data_element_value => l_data_element_value);
15134 Hr_Utility.set_location('..Processed Multi Recds for 30 : '||l_proc_name, 30);
15135 EXCEPTION
15136 WHEN Others THEN
15137 Hr_Utility.set_location('..Error in Multi Recds for 30 : '||l_proc_name, 30);
15138 l_error_message := Substr('SQL-ERRM :'||SQLERRM,1,2000);
15139 l_error_flag := TRUE;
15140 END;
15141 IF l_ret_val <> 0 THEN
15142 l_error_message := l_error_message ||
15143 'Error in Processing Multi Record 30 for '||
15144 'Assignment Id :'||p_assignment_id ;
15145 l_error_flag := TRUE;
15146 END IF;
15147
15148 -- Process Multiple Records for Record 31
15149 BEGIN
15150 l_ret_val := Process_Mult_Rec31
15151 (p_assignment_id => p_assignment_id
15152 ,p_business_group_id => p_business_group_id
15153 ,p_effective_date => p_effective_date
15154 ,p_error_message => p_error_message
15155 ,p_data_element_value => l_data_element_value);
15156 Hr_Utility.set_location('..Processed Multi Recds for 31 : '||l_proc_name, 31);
15157 EXCEPTION
15158 WHEN Others THEN
15159 Hr_Utility.set_location('..Error in Multi Recds for 31 : '||l_proc_name, 31);
15160 l_error_message := Substr('SQL-ERRM :'||SQLERRM,1,2000);
15161 l_error_flag := TRUE;
15162 END;
15163 IF l_ret_val <> 0 THEN
15164 l_error_message := l_error_message ||
15165 'Error in Processing Multi Record 31 for '||
15166 'Assignment Id :'||p_assignment_id ;
15167 l_error_flag := TRUE;
15168 END IF;
15169
15170 -- Process Multiple Records for Record 40
15171 BEGIN
15172 l_ret_val := Process_Mult_Rec40
15173 (p_assignment_id => p_assignment_id
15174 ,p_business_group_id => p_business_group_id
15175 ,p_effective_date => p_effective_date
15176 ,p_error_message => p_error_message
15177 ,p_data_element_value => l_data_element_value);
15178 Hr_Utility.set_location('..Processed Multi Recds for 40 : '||l_proc_name, 40);
15179 EXCEPTION
15180 WHEN Others THEN
15181 Hr_Utility.set_location('..Error in Multi Recds for 40 : '||l_proc_name, 40);
15182 l_error_message := Substr('SQL-ERRM :'||SQLERRM,1,2000);
15183 l_error_flag := TRUE;
15184 END;
15185 IF l_ret_val <> 0 THEN
15186 l_error_message := l_error_message ||
15187 'Error in Processing Multi Record 40 for '||
15188 'Assignment Id :'||p_assignment_id ;
15189 l_error_flag := TRUE;
15190 END IF;
15191
15192 -- Process Multiple Records for Record 41
15193 BEGIN
15194 l_ret_val := Process_Mult_Rec41
15195 (p_assignment_id => p_assignment_id
15196 ,p_business_group_id => p_business_group_id
15197 ,p_effective_date => p_effective_date
15198 ,p_error_message => p_error_message
15199 ,p_data_element_value => l_data_element_value);
15200 Hr_Utility.set_location('..Processed Multi Recds for 41 : '||l_proc_name, 41);
15201 EXCEPTION
15202 WHEN Others THEN
15203 Hr_Utility.set_location('..Error in Multi Recds for 41 : '||l_proc_name, 41);
15204 l_error_message := Substr('SQL-ERRM :'||SQLERRM,1,2000);
15205 l_error_flag := TRUE;
15206 END;
15207 IF l_ret_val <> 0 THEN
15208 l_error_message := l_error_message ||
15209 'Error in Processing Multi Record 41 for '||
15210 'Assignment Id :'||p_assignment_id ;
15211 l_error_flag := TRUE;
15212 END IF;
15213
15214 Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
15215 IF l_error_flag THEN
15216 p_error_message := l_error_message;
15217 RETURN -1;
15218 ELSE
15219 RETURN 0;
15220 END IF;
15221
15222 EXCEPTION
15223 WHEN Others THEN
15224 p_error_message :='SQL-ERRM :'||SQLERRM;
15225 Hr_Utility.set_location('..'||p_error_message,85);
15226 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
15227 RETURN -1;
15228
15229 END Process_Mult_Records;
15230
15231 -- =============================================================================
15232 -- PQP_NL_GET_DATA_ELEMENT_VALUE
15233 -- This function is used for all rule based data elements
15234 -- =============================================================================
15235
15236 FUNCTION PQP_NL_Get_Data_Element_Value
15237 ( p_assignment_id IN Number
15238 ,p_business_group_id IN Number
15239 ,p_date_earned IN Date
15240 ,p_data_element_cd IN Varchar2
15241 ,p_error_message OUT NOCOPY Varchar2
15242 ,p_data_element_value OUT NOCOPY Varchar2
15243 ) RETURN Number IS
15244
15245 l_ret_val Number;
15246 l_debug Boolean;
15247 l_proc_name Varchar2(150) := g_proc_name ||'PQP_NL_Get_Data_Element_Value';
15248
15249 BEGIN
15250
15251 l_ret_val := 0;
15252
15253 Hr_Utility.set_location(' Entering : ' || l_proc_name , 5);
15254 Hr_Utility.set_location(' p_assignment_id ' || p_assignment_id , 10);
15255 Hr_Utility.set_location(' p_bg_id is ' || p_business_group_id ,15);
15256 Hr_Utility.set_location(' p_date_earned ' || p_date_earned,20 );
15257 Hr_Utility.set_location(' p_data_ele_cd ' || p_data_element_cd ,25);
15258 Hr_Utility.set_location(' g_person_id ' || g_person_id , 30);
15259
15260 IF (p_data_element_cd = 'ABP_ER_NUM') THEN
15261
15262 l_ret_val := Get_ABP_ER_Num(p_assignment_id
15263 ,p_business_group_id
15264 ,p_date_earned
15265 ,'NEW'
15266 ,p_error_message
15267 ,p_data_element_value);
15268 IF IsNumber(p_data_element_value) THEN
15269 p_data_element_value := Trim(To_Char(Fnd_Number.Canonical_To_Number
15270 (Nvl(p_data_element_value,'0'))
15271 ,'0999999'));
15272 END IF;
15273
15274 ELSIF (p_data_element_cd = 'PROCESS_MULTIPLE_REC41') THEN
15275 l_ret_val := Process_Mult_Records
15276 (p_assignment_id => p_assignment_id
15277 ,p_business_group_id => p_business_group_id
15278 ,p_effective_date => p_date_earned
15279 ,p_error_message => p_error_message
15280 );
15281 p_data_element_value := 'PROCESSED';
15282
15283 ELSIF (p_data_element_cd = 'EE_NUM') THEN
15284
15285 l_ret_val := Get_EE_Num(p_assignment_id => p_assignment_id
15286 ,p_business_group_id => p_business_group_id
15287 ,p_effective_date => p_date_earned
15288 ,p_error_message => p_error_message
15289 ,p_data_element_value => p_data_element_value);
15290
15291 ELSIF (p_data_element_cd = 'OLD_ABP_ER_NUM') THEN
15292
15293 l_ret_val := Get_ABP_ER_Num(p_assignment_id
15294 ,p_business_group_id
15295 ,p_date_earned
15296 ,'OLD'
15297 ,p_error_message
15298 ,p_data_element_value);
15299
15300 IF p_data_element_value IS NOT NULL THEN
15301 IF IsNumber(p_data_element_value) THEN
15302 p_data_element_value := Trim(To_Char(Fnd_Number.Canonical_To_Number
15303 (p_data_element_value)
15304 ,'0999999'));
15305 END IF;
15306 ELSE
15307 p_data_element_value := '0000000';
15308 END IF;
15309
15310 ELSIF (p_data_element_cd = 'ASG_SEQ_NUM') THEN
15311
15312 l_ret_val := Get_Asg_Seq_Num(p_assignment_id
15313 ,p_business_group_id
15314 ,p_date_earned
15315 ,p_error_message
15316 ,p_data_element_value);
15317
15318 ELSIF (p_data_element_cd = 'OLD_ASG_SEQ_NUM') THEN
15319
15320 l_ret_val := Get_Old_Asg_Seq_Num(p_assignment_id
15321 ,p_business_group_id
15322 ,p_date_earned
15323 ,p_error_message
15324 ,p_data_element_value);
15325
15326 ELSIF (p_data_element_cd = 'OLD_EE_NUM') THEN
15327
15328 l_ret_val := Get_Old_Ee_Num(p_assignment_id
15329 ,p_business_group_id
15330 ,p_date_earned
15331 ,p_error_message
15332 ,p_data_element_value);
15333
15334 ELSIF (p_data_element_cd = 'PERSON_INITIALS') THEN
15335
15336 l_ret_val := Get_Person_Initials(p_assignment_id
15337 ,p_business_group_id
15338 ,p_date_earned
15339 ,p_error_message
15340 ,p_data_element_value);
15341
15342 ELSIF (p_data_element_cd = 'PARTNER_LAST_NAME') THEN
15343
15344 l_ret_val := Get_Partner_Last_Name(p_assignment_id
15345 ,p_business_group_id
15346 ,p_date_earned
15347 ,p_error_message
15348 ,p_data_element_value);
15349
15350 ELSIF (p_data_element_cd = 'GENDER') THEN
15351
15352 l_ret_val := Get_Gender(p_assignment_id
15353 ,p_business_group_id
15354 ,p_date_earned
15355 ,p_error_message
15356 ,p_data_element_value);
15357
15358 ELSIF (p_data_element_cd = 'CHANGE_CD_PER') THEN
15359
15360 l_ret_val := GET_CHANGE_CD_PER(p_assignment_id
15361 ,p_business_group_id
15362 ,p_date_earned
15363 ,p_error_message
15364 ,p_data_element_value);
15365
15366 ELSIF (p_data_element_cd = 'PARTNER_PREFIX') THEN
15367
15368 l_ret_val := Get_Partner_Prefix(p_assignment_id
15369 ,p_business_group_id
15370 ,p_date_earned
15371 ,p_error_message
15372 ,p_data_element_value);
15373
15374 ELSIF (p_data_element_cd = 'CHANGE_CD_ADDR') THEN
15375
15376 l_ret_val := Get_Change_CD_Addr(p_assignment_id
15377 ,p_business_group_id
15378 ,p_date_earned
15379 ,p_error_message
15380 ,p_data_element_value);
15381
15382 ELSIF (p_data_element_cd = 'STREET') THEN
15383
15384 l_ret_val := Get_Street(p_assignment_id
15385 ,p_business_group_id
15386 ,p_date_earned
15387 ,p_error_message
15388 ,p_data_element_value);
15389
15390 ELSIF (p_data_element_cd = 'HOUSE_NUM') THEN
15391
15392 l_ret_val := Get_House_Num(p_assignment_id
15393 ,p_business_group_id
15394 ,p_date_earned
15395 ,p_error_message
15396 ,p_data_element_value);
15397
15398 ELSIF (p_data_element_cd = 'ADDNL_HOUSE_NUM') THEN
15399
15400 l_ret_val := Get_Addnl_House_Num(p_assignment_id
15401 ,p_business_group_id
15402 ,p_date_earned
15403 ,p_error_message
15404 ,p_data_element_value);
15405
15406 ELSIF (p_data_element_cd = 'POSTAL_CODE') THEN
15407
15408 l_ret_val := Get_Postal_Code(p_assignment_id
15409 ,p_business_group_id
15410 ,p_date_earned
15411 ,p_error_message
15412 ,p_data_element_value);
15413
15414 ELSIF (p_data_element_cd = 'CITY') THEN
15415
15416 l_ret_val := Get_City(p_assignment_id
15417 ,p_business_group_id
15418 ,p_date_earned
15419 ,p_error_message
15420 ,p_data_element_value);
15421
15422
15423 ELSIF (p_data_element_cd = 'FOREIGN_COUNTRY') THEN
15424
15425 l_ret_val := Get_Foreign_Country(p_assignment_id
15426 ,p_business_group_id
15427 ,p_date_earned
15428 ,p_error_message
15429 ,p_data_element_value);
15430
15431 ELSIF (p_data_element_cd = 'MARITAL_STATUS') THEN
15432
15433 l_ret_val := Get_Marital_Status(p_assignment_id
15434 ,p_business_group_id
15435 ,p_date_earned
15436 ,p_error_message
15437 ,p_data_element_value);
15438
15439 ELSIF (p_data_element_cd = 'PROCESS_MULTIPLE_ASSIGS') THEN
15440
15441 l_ret_val := Process_Addl_Assigs
15442 (p_assignment_id => p_assignment_id
15443 ,p_business_group_id => p_business_group_id
15444 ,p_effective_date => p_date_earned
15445 ,p_error_message => p_error_message
15446 );
15447 p_data_element_value := 'PROCESSED';
15448
15449 ELSIF (p_data_element_cd = 'PROCESS_RETRO_HIRE') THEN
15450
15451 l_ret_val := Process_Retro_Hire
15452 (p_assignment_id => p_assignment_id
15453 ,p_business_group_id => p_business_group_id
15454 ,p_effective_date => p_date_earned
15455 ,p_error_message => p_error_message
15456 );
15457 p_data_element_value := 'PROCESSED';
15458
15459 ELSIF (p_data_element_cd = 'CUMULATIVE_REP') THEN
15460 p_data_element_value := ' ';
15461
15462 ELSIF (p_data_element_cd = 'R01_DISPLAY_CRITERIA') THEN
15463
15464 l_ret_val := Record01_Display_Criteria(p_assignment_id
15465 ,p_business_group_id
15466 ,p_date_earned
15467 ,p_error_message
15468 ,p_data_element_value);
15469
15470 ELSIF (p_data_element_cd = 'R02_DISPLAY_CRITERIA') THEN
15471
15472 l_ret_val := Record02_Display_Criteria(p_assignment_id
15473 ,p_business_group_id
15474 ,p_date_earned
15475 ,p_error_message
15476 ,p_data_element_value);
15477
15478 ELSIF (p_data_element_cd = 'R04_DISPLAY_CRITERIA') THEN
15479
15480 l_ret_val := Record04_Display_Criteria(p_assignment_id
15481 ,p_business_group_id
15482 ,p_date_earned
15483 ,p_error_message
15484 ,p_data_element_value);
15485
15486 ELSIF (p_data_element_cd = 'R05_DISPLAY_CRITERIA') THEN
15487
15488 l_ret_val := Record05_Display_Criteria(p_assignment_id
15489 ,p_business_group_id
15490 ,p_date_earned
15491 ,p_error_message
15492 ,p_data_element_value);
15493
15494 ELSIF (p_data_element_cd = 'R21_DISPLAY_CRITERIA') THEN
15495
15496 l_ret_val := Record21_Display_Criteria(p_assignment_id
15497 ,p_business_group_id
15498 ,p_date_earned
15499 ,p_error_message
15500 ,p_data_element_value);
15501
15502 ELSIF (p_data_element_cd = 'R22_DISPLAY_CRITERIA') THEN
15503
15504 l_ret_val := Record22_Display_Criteria(p_assignment_id
15505 ,p_business_group_id
15506 ,p_date_earned
15507 ,p_error_message
15508 ,p_data_element_value);
15509
15510 ELSIF (p_data_element_cd = 'R09_DISPLAY_CRITERIA') THEN
15511 l_ret_val := Record09_Display_Criteria(p_assignment_id
15512 ,p_business_group_id
15513 ,p_date_earned
15514 ,p_error_message
15515 ,p_data_element_value);
15516
15517 ELSIF (p_data_element_cd = 'R12_DISPLAY_CRITERIA') THEN
15518 l_ret_val := Record12_Display_Criteria(p_assignment_id
15519 ,p_business_group_id
15520 ,p_date_earned
15521 ,p_error_message
15522 ,p_data_element_value);
15523
15524 ELSIF (p_data_element_cd = 'R20_DISPLAY_CRITERIA') THEN
15525 l_ret_val := Record20_Display_Criteria(p_assignment_id
15526 ,p_business_group_id
15527 ,p_date_earned
15528 ,p_error_message
15529 ,p_data_element_value);
15530
15531 ELSIF (p_data_element_cd = 'R40_DISPLAY_CRITERIA') THEN
15532
15533 l_ret_val := Record30_40_Display_Criteria(p_assignment_id
15534 ,p_business_group_id
15535 ,p_date_earned
15536 ,'FUR_S'
15537 ,p_error_message
15538 ,p_data_element_value);
15539
15540 ELSIF (p_data_element_cd = 'R41_DISPLAY_CRITERIA') THEN
15541
15542 l_ret_val := Record31_41_Display_Criteria(p_assignment_id
15543 ,p_business_group_id
15544 ,p_date_earned
15545 ,41
15546 ,p_error_message
15547 ,p_data_element_value);
15548
15549 ELSIF (p_data_element_cd = 'R30_DISPLAY_CRITERIA') THEN
15550
15551 l_ret_val := Record30_40_Display_Criteria(p_assignment_id
15552 ,p_business_group_id
15553 ,p_date_earned
15554 ,'IPAP'
15555 ,p_error_message
15556 ,p_data_element_value);
15557
15558 ELSIF (p_data_element_cd = 'R31_DISPLAY_CRITERIA') THEN
15559 l_ret_val := Record31_41_Display_Criteria(p_assignment_id
15560 ,p_business_group_id
15561 ,p_date_earned
15562 ,31
15563 ,p_error_message
15564 ,p_data_element_value);
15565
15566 ELSIF (p_data_element_cd = 'PENSION_SALARY') THEN
15567
15568 l_ret_val := Get_Pension_Salary(p_assignment_id
15569 ,p_business_group_id
15570 ,p_date_earned
15571 ,'ABP Pension Salary'
15572 , -1
15573 ,p_error_message
15574 ,p_data_element_value);
15575
15576 IF IsNumber(p_data_element_value) THEN
15577 p_data_element_value := Trim(To_Char(ABS(Fnd_Number.Canonical_To_Number
15578 (Nvl(p_data_element_value,'0')))
15579 ,'0999999V99'));
15580 END IF;
15581
15582 ELSIF (p_data_element_cd = 'SI_WAGES_TYPE') THEN
15583 -- Obselete SI data element
15584 p_data_element_value := NULL;
15585
15586 ELSIF (p_data_element_cd = 'PEN_START_YEAR') THEN
15587
15588 l_ret_val := Get_Pension_Start_Year(p_assignment_id
15589 ,p_business_group_id
15590 ,p_date_earned
15591 ,g_extract_params(p_business_group_id).extract_start_date
15592 ,g_extract_params(p_business_group_id).extract_end_date
15593 ,p_error_message
15594 ,p_data_element_value);
15595
15596 ELSIF (p_data_element_cd = 'PEN_CONTRIBUTION_AMT_CD') THEN
15597
15598 l_ret_val := Get_Contrib_Amt_Code(p_assignment_id
15599 ,p_business_group_id
15600 ,p_date_earned
15601 ,12
15602 ,p_error_message
15603 ,p_data_element_value);
15604
15605
15606 ELSIF (p_data_element_cd = 'R08_DISPLAY_CRITERIA') THEN
15607
15608 l_ret_val := Record08_Display_Criteria(p_assignment_id
15609 ,p_business_group_id
15610 ,p_date_earned
15611 ,p_error_message
15612 ,p_data_element_value);
15613
15614
15615 ELSIF (p_data_element_cd = 'PEXT_BASIS_CONTRIBUTION') THEN
15616
15617 l_ret_val := Get_Sub_Cat_09(p_assignment_id
15618 ,p_business_group_id
15619 ,p_date_earned
15620 ,p_error_message
15621 ,p_data_element_value);
15622
15623 ELSIF (p_data_element_cd = 'PEN_BASIS_AMT_CD') THEN
15624
15625 l_ret_val := Get_Basis_Amt_Code(p_assignment_id
15626 ,p_business_group_id
15627 ,p_date_earned
15628 ,9
15629 ,p_error_message
15630 ,p_data_element_value);
15631
15632 ELSIF (p_data_element_cd = 'AMT_CD') THEN
15633
15634 l_ret_val := Get_Basis_Amt_Code(p_assignment_id
15635 ,p_business_group_id
15636 ,p_date_earned
15637 ,31
15638 ,p_error_message
15639 ,p_data_element_value);
15640
15641 ELSIF (p_data_element_cd = 'PRINCIPAL_OBJN_CD') THEN
15642
15643 l_ret_val := Get_Pri_Obj_Cd(p_assignment_id
15644 ,p_business_group_id
15645 ,p_date_earned
15646 ,p_error_message
15647 ,p_data_element_value);
15648
15649
15650 ELSIF (p_data_element_cd = 'ABP_PENSION_BASIS') THEN
15651
15652 l_ret_val := Get_Basis_Amt(p_assignment_id
15653 ,p_business_group_id
15654 ,p_date_earned
15655 ,9
15656 ,p_error_message
15657 ,p_data_element_value);
15658
15659 IF IsNumber(p_data_element_value) THEN
15660 p_data_element_value := Trim(To_Char(ABS(Fnd_Number.Canonical_To_Number
15661 (Nvl(p_data_element_value,'0')))
15662 ,'0999999V99'));
15663 END IF;
15664
15665
15666 ELSIF (p_data_element_cd = 'PENSION_BASIS_YEAR') THEN
15667
15668 l_ret_val := Get_Pension_Basis_Year(p_assignment_id
15669 ,p_business_group_id
15670 ,p_date_earned
15671 ,9
15672 ,p_error_message
15673 ,p_data_element_value);
15674
15675 IF p_data_element_value IS NULL THEN
15676 p_data_element_value := '0000';
15677 END IF;
15678
15679 ELSIF (p_data_element_cd = 'MONTH_CONTRIBUTION_BASE') THEN
15680
15681 l_ret_val := Get_Month_Contribution_Base(p_assignment_id
15682 ,p_business_group_id
15683 ,p_date_earned
15684 ,9
15685 ,p_error_message
15686 ,p_data_element_value);
15687
15688 IF p_data_element_value IS NULL THEN
15689 p_data_element_value := '00';
15690 END IF;
15691
15692 ELSIF (p_data_element_cd = 'IPAP_CONTRIBUTION_AMT_YEAR') THEN
15693
15694 l_ret_val := Get_Pension_Basis_Year(p_assignment_id
15695 ,p_business_group_id
15696 ,p_date_earned
15697 ,31
15698 ,p_error_message
15699 ,p_data_element_value);
15700
15701 ELSIF (p_data_element_cd = 'IPAP_CONTRIBUTION_AMT_MONTH') THEN
15702
15703 l_ret_val := Get_Month_Contribution_Base(p_assignment_id
15704 ,p_business_group_id
15705 ,p_date_earned
15706 ,31
15707 ,p_error_message
15708 ,p_data_element_value);
15709
15710 ELSIF (p_data_element_cd = 'PRINCIPAL_SI_OBJ_CD') THEN
15711
15712 p_data_element_value := ' ';
15713
15714 ELSIF (p_data_element_cd = 'PROCESS_MUL_SUB_CAT_09') THEN
15715
15716 l_ret_val := Process_Mult_Rec09
15717 (p_assignment_id
15718 ,p_business_group_id
15719 ,p_date_earned
15720 ,p_error_message
15721 ,p_data_element_value);
15722
15723
15724 ELSIF (p_data_element_cd = 'CONTRIBUTION_AMOUNT') THEN
15725
15726 l_ret_val := Get_Sub_Cat_12(p_assignment_id
15727 ,p_business_group_id
15728 ,p_date_earned
15729 ,p_error_message
15730 ,p_data_element_value);
15731
15732
15733 ELSIF (p_data_element_cd = 'ABP_DEDN_AMT') THEN
15734
15735 l_ret_val := Get_Contribution_Amount(p_assignment_id
15736 ,p_business_group_id
15737 ,p_date_earned
15738 ,12
15739 ,p_error_message
15740 ,p_data_element_value);
15741
15742 IF IsNumber(p_data_element_value) THEN
15743 p_data_element_value :=Trim( To_Char(ABS(Fnd_Number.Canonical_To_Number
15744 (Nvl(p_data_element_value,'0')))
15745 ,'0999999V99'));
15746 END IF;
15747
15748 ELSIF (p_data_element_cd = 'SORT_ID_R01') THEN
15749
15750 l_ret_val := Sort_Id_Generator(p_assignment_id
15751 ,p_business_group_id
15752 ,p_date_earned
15753 ,'01'
15754 ,p_error_message
15755 ,p_data_element_value);
15756
15757 ELSIF (p_data_element_cd = 'SORT_ID_R02') THEN
15758
15759 l_ret_val := Sort_Id_Generator(p_assignment_id
15760 ,p_business_group_id
15761 ,p_date_earned
15762 ,'02'
15763 ,p_error_message
15764 ,p_data_element_value);
15765
15766 ELSIF (p_data_element_cd = 'SORT_ID_R04') THEN
15767
15768 l_ret_val := Sort_Id_Generator(p_assignment_id
15769 ,p_business_group_id
15770 ,p_date_earned
15771 ,'04'
15772 ,p_error_message
15773 ,p_data_element_value);
15774
15775 ELSIF (p_data_element_cd = 'SORT_ID_R05') THEN
15776
15777 l_ret_val := Sort_Id_Generator(p_assignment_id
15778 ,p_business_group_id
15779 ,p_date_earned
15780 ,'05'
15781 ,p_error_message
15782 ,p_data_element_value);
15783
15784 ELSIF (p_data_element_cd = 'SORT_ID_R08') THEN
15785
15786 l_ret_val := Sort_Id_Generator(p_assignment_id
15787 ,p_business_group_id
15788 ,p_date_earned
15789 ,'08'
15790 ,p_error_message
15791 ,p_data_element_value);
15792
15793 ELSIF (p_data_element_cd = 'SORT_ID_R09') THEN
15794
15795 l_ret_val := Sort_Id_Generator(p_assignment_id
15796 ,p_business_group_id
15797 ,p_date_earned
15798 ,'09'
15799 ,p_error_message
15800 ,p_data_element_value);
15801
15802 ELSIF (p_data_element_cd = 'SORT_ID_R12') THEN
15803
15804 l_ret_val := Sort_Id_Generator(p_assignment_id
15805 ,p_business_group_id
15806 ,p_date_earned
15807 ,'12'
15808 ,p_error_message
15809 ,p_data_element_value);
15810
15811 ELSIF (p_data_element_cd = 'SORT_ID_R20') THEN
15812
15813 l_ret_val := Sort_Id_Generator(p_assignment_id
15814 ,p_business_group_id
15815 ,p_date_earned
15816 ,'20'
15817 ,p_error_message
15818 ,p_data_element_value);
15819
15820
15821 ELSIF (p_data_element_cd = 'SORT_ID_R21') THEN
15822
15823 l_ret_val := Sort_Id_Generator(p_assignment_id
15824 ,p_business_group_id
15825 ,p_date_earned
15826 ,'21'
15827 ,p_error_message
15828 ,p_data_element_value);
15829
15830 ELSIF (p_data_element_cd = 'SORT_ID_R22') THEN
15831
15832 l_ret_val := Sort_Id_Generator(p_assignment_id
15833 ,p_business_group_id
15834 ,p_date_earned
15835 ,'22'
15836 ,p_error_message
15837 ,p_data_element_value);
15838
15839 ELSIF (p_data_element_cd = 'SORT_ID_R22') THEN
15840
15841 l_ret_val := Sort_Id_Generator(p_assignment_id
15842 ,p_business_group_id
15843 ,p_date_earned
15844 ,'22'
15845 ,p_error_message
15846 ,p_data_element_value);
15847
15848 ELSIF (p_data_element_cd = 'SORT_ID_R30') THEN
15849
15850 l_ret_val := Sort_Id_Generator(p_assignment_id
15851 ,p_business_group_id
15852 ,p_date_earned
15853 ,'30'
15854 ,p_error_message
15855 ,p_data_element_value);
15856
15857 ELSIF (p_data_element_cd = 'SORT_ID_R31') THEN
15858
15859 l_ret_val := Sort_Id_Generator(p_assignment_id
15860 ,p_business_group_id
15861 ,p_date_earned
15862 ,'31'
15863 ,p_error_message
15864 ,p_data_element_value);
15865
15866 ELSIF (p_data_element_cd = 'SORT_ID_R40') THEN
15867
15868 l_ret_val := Sort_Id_Generator(p_assignment_id
15869 ,p_business_group_id
15870 ,p_date_earned
15871 ,'40'
15872 ,p_error_message
15873 ,p_data_element_value);
15874
15875 ELSIF (p_data_element_cd = 'SORT_ID_R41') THEN
15876
15877 l_ret_val := Sort_Id_Generator(p_assignment_id
15878 ,p_business_group_id
15879 ,p_date_earned
15880 ,'41'
15881 ,p_error_message
15882 ,p_data_element_value);
15883
15884 ELSIF (p_data_element_cd = 'HIDE_ORG_ID') THEN
15885
15886 l_ret_val := Org_Id_DataElement(p_assignment_id
15887 ,p_business_group_id
15888 ,p_date_earned
15889 ,p_error_message
15890 ,p_data_element_value);
15891
15892 ELSIF (p_data_element_cd = 'PENSION_BASIS') THEN
15893
15894 l_ret_val := Get_Fur_Contribution_Kind(p_assignment_id
15895 ,p_business_group_id
15896 ,p_date_earned
15897 ,p_error_message
15898 ,p_data_element_value);
15899
15900 ELSIF (p_data_element_cd = 'ADD_FEM_EMP') THEN
15901
15902 l_ret_val := Get_Add_Fem_EE(p_assignment_id
15903 ,p_business_group_id
15904 ,p_date_earned
15905 ,p_error_message
15906 ,p_data_element_value);
15907
15908
15909 ELSIF (p_data_element_cd = 'ANW_IPAP_AMT') THEN
15910
15911 l_ret_val := Get_Basis_Amt(p_assignment_id
15912 ,p_business_group_id
15913 ,p_date_earned
15914 ,31
15915 ,p_error_message
15916 ,p_data_element_value);
15917
15918 IF IsNumber(p_data_element_value) THEN
15919 p_data_element_value := Trim(To_Char(ABS(Fnd_Number.Canonical_To_Number
15920 (Nvl(p_data_element_value,'0')))
15921 ,'0999999V99'));
15922 END IF;
15923
15924 ELSIF (p_data_element_cd = 'FUR_AMT') THEN
15925
15926 IF g_fur_contrib_kind = 'A' THEN
15927
15928 l_ret_val := Get_Basis_Amt(p_assignment_id
15929 ,p_business_group_id
15930 ,p_date_earned
15931 ,41
15932 ,p_error_message
15933 ,p_data_element_value);
15934
15935 IF IsNumber(p_data_element_value) THEN
15936 p_data_element_value := Trim(To_Char(ABS(Fnd_Number.Canonical_To_Number
15937 (Nvl(p_data_element_value,'0')))
15938 ,'0999999V99'));
15939 END IF;
15940
15941 ELSIF g_fur_contrib_kind = 'D' THEN
15942
15943 l_ret_val := Get_Contribution_Amount(p_assignment_id
15944 ,p_business_group_id
15945 ,p_date_earned
15946 ,41
15947 ,p_error_message
15948 ,p_data_element_value);
15949
15950 IF IsNumber(p_data_element_value) THEN
15951 p_data_element_value :=Trim( To_Char(ABS(Fnd_Number.Canonical_To_Number
15952 (Nvl(p_data_element_value,'0')))
15953 ,'0999999V99'));
15954 END IF;
15955
15956 END IF;
15957
15958 ELSIF (p_data_element_cd = 'FUR_SI_WAGES_AMT_CD') THEN
15959
15960 IF g_fur_contrib_kind = 'A' THEN
15961
15962 l_ret_val := Get_Basis_Amt_Code(p_assignment_id
15963 ,p_business_group_id
15964 ,p_date_earned
15965 ,41
15966 ,p_error_message
15967 ,p_data_element_value);
15968 ELSIF g_fur_contrib_kind = 'D' THEN
15969
15970 l_ret_val := Get_Contrib_Amt_Code(p_assignment_id
15971 ,p_business_group_id
15972 ,p_date_earned
15973 ,41
15974 ,p_error_message
15975 ,p_data_element_value);
15976
15977 END IF;
15978
15979 ELSIF (p_data_element_cd = 'FUR_CONTRIBUTION_AMT_MONTH') THEN
15980
15981 IF g_fur_contrib_kind = 'A' THEN
15982
15983 l_ret_val := Get_Month_Contribution_Base(p_assignment_id
15984 ,p_business_group_id
15985 ,p_date_earned
15986 ,41
15987 ,p_error_message
15988 ,p_data_element_value);
15989 ELSIF g_fur_contrib_kind = 'D' THEN
15990
15991 l_ret_val := Get_Month_Contribution_Amt(p_assignment_id
15992 ,p_business_group_id
15993 ,p_date_earned
15994 ,41
15995 ,p_error_message
15996 ,p_data_element_value);
15997
15998 END IF;
15999
16000 ELSIF (p_data_element_cd = 'FUR_CONTRIBUTION_AMT_YEAR') THEN
16001
16002 IF g_fur_contrib_kind = 'A' THEN
16003
16004 l_ret_val := Get_Pension_Basis_Year(p_assignment_id
16005 ,p_business_group_id
16006 ,p_date_earned
16007 ,41
16008 ,p_error_message
16009 ,p_data_element_value);
16010 ELSIF g_fur_contrib_kind = 'D' THEN
16011
16012 l_ret_val := Get_Year_Contribution_Amt(p_assignment_id
16013 ,p_business_group_id
16014 ,p_date_earned
16015 ,41
16016 ,p_error_message
16017 ,p_data_element_value);
16018
16019 END IF;
16020
16021 ELSIF (p_data_element_cd = 'CHANGE_DATE') THEN
16022
16023 l_ret_val := Get_Change_Date
16024 (p_assignment_id
16025 ,p_business_group_id
16026 ,p_date_earned
16027 ,p_error_message
16028 ,p_data_element_value);
16029
16030 ELSIF (p_data_element_cd = 'WAO_CONTRIBUTION_CD') THEN
16031 --
16032 -- Obselete SI Data Element
16033 --
16034 p_data_element_value := ' ';
16035
16036 ELSIF (p_data_element_cd = 'DISCOUNT_AGH') THEN
16037 --
16038 -- Obselete SI Data Element
16039 --
16040 p_data_element_value := ' ';
16041
16042 ELSIF (p_data_element_cd = 'SI_WAGES') THEN
16043
16044 l_curr_si_rec := '21';
16045 -- Obselete SI data element
16046 p_data_element_value := NULL;
16047
16048 ELSIF (p_data_element_cd = 'SI_WAGES_PMT_CD') THEN
16049 p_data_element_value := ' ';
16050
16051 ELSIF (p_data_element_cd = 'CHANGE_DATE_PARTICIPATION_VALUE') THEN
16052
16053 l_ret_val := Get_rec05_Participation
16054 (p_assignment_id
16055 ,p_business_group_id
16056 ,'DT_CHG'
16057 ,p_date_earned
16058 ,p_error_message
16059 ,p_data_element_value);
16060
16061 IF p_data_element_value IS NULL THEN
16062 p_data_element_value := '00000000';
16063 END IF;
16064
16065 ELSIF (p_data_element_cd = 'PARTICIPATION_END_DT') THEN
16066
16067 l_ret_val := Get_rec05_Participation
16068 (p_assignment_id
16069 ,p_business_group_id
16070 ,'EDDT_CHG'
16071 ,p_date_earned
16072 ,p_error_message
16073 ,p_data_element_value);
16074
16075 IF p_data_element_value IS NULL THEN
16076 p_data_element_value := '00000000';
16077 END IF;
16078
16079 ELSIF (p_data_element_cd = 'NEW_INSURANCE_END_DT') THEN
16080
16081 l_ret_val := Get_Ipap_Participation_Dates
16082 (p_assignment_id
16083 ,p_business_group_id
16084 ,'NEW_ED'
16085 ,p_date_earned
16086 ,p_error_message
16087 ,p_data_element_value);
16088
16089 ELSIF (p_data_element_cd = 'OLD_INSURANCE_END_DT') THEN
16090
16091 l_ret_val := Get_Ipap_Participation_Dates
16092 (p_assignment_id
16093 ,p_business_group_id
16094 ,'OLD_ED'
16095 ,p_date_earned
16096 ,p_error_message
16097 ,p_data_element_value);
16098
16099 ELSIF (p_data_element_cd = 'OLD_INSURANCE_FUR_END_DT') THEN
16100
16101 l_ret_val := Get_Fur_Participation_Dates
16102 (p_assignment_id
16103 ,p_business_group_id
16104 ,'OLD_ED'
16105 ,p_date_earned
16106 ,p_error_message
16107 ,p_data_element_value);
16108
16109 ELSIF (p_data_element_cd = 'NEW_FUR_INS_END_DT') THEN
16110
16111 l_ret_val := Get_Fur_Participation_Dates
16112 (p_assignment_id
16113 ,p_business_group_id
16114 ,'NEW_ED'
16115 ,p_date_earned
16116 ,p_error_message
16117 ,p_data_element_value);
16118
16119 ELSIF (p_data_element_cd = 'NEW_PARTICIPATION_END_DT') THEN
16120
16121 l_ret_val := Get_rec05_Participation
16122 (p_assignment_id
16123 ,p_business_group_id
16124 ,'NEW_ED'
16125 ,p_date_earned
16126 ,p_error_message
16127 ,p_data_element_value);
16128
16129 IF p_data_element_value IS NULL THEN
16130 p_data_element_value := '00000000';
16131 END IF;
16132
16133 ELSIF (p_data_element_cd = 'OLD_PARTICIPATION_END_DT') THEN
16134
16135 l_ret_val := Get_rec05_Participation
16136 (p_assignment_id
16137 ,p_business_group_id
16138 ,'OLD_ED'
16139 ,p_date_earned
16140 ,p_error_message
16141 ,p_data_element_value);
16142
16143 IF p_data_element_value IS NULL THEN
16144 p_data_element_value := '00000000';
16145 END IF;
16146
16147 ELSIF (p_data_element_cd = 'ASG_ST_DT_NEW') THEN
16148 -- Obselete SI Data Element
16149 p_data_element_value := '00000000';
16150
16151 ELSIF (p_data_element_cd = 'ASG_START_DATE_OLD') THEN
16152 -- Obselete SI Data Element
16153 p_data_element_value := '00000000';
16154
16155 ELSIF (p_data_element_cd = 'ASG_END_DATE_OLD') THEN
16156 -- Obselete SI Data Element
16157 p_data_element_value := '00000000';
16158
16159 ELSIF (p_data_element_cd = 'ASG_END_DT_NEW') THEN
16160 -- Obselete SI Data Element
16161 p_data_element_value := '00000000';
16162
16163 ELSIF (p_data_element_cd = 'SI_END_DT') THEN
16164 -- Obselete SI Data Element
16165 p_data_element_value := '00000000';
16166
16167 ELSIF (p_data_element_cd = 'ASG_TYPE_CODE') THEN
16168 l_ret_val := Get_Employment_Kind
16169 (p_assignment_id
16170 ,p_business_group_id
16171 ,p_date_earned
16172 ,p_error_message
16173 ,p_data_element_value);
16174
16175 ELSIF (p_data_element_cd = 'INCIDENTAL_WORKER') THEN
16176 l_ret_val := Get_Incidental_Worker
16177 (p_assignment_id
16178 ,p_business_group_id
16179 ,p_date_earned
16180 ,p_error_message
16181 ,p_data_element_value);
16182
16183 ELSIF (p_data_element_cd = 'WAO_INSURED_CD') THEN
16184 -- Obselete SI data element
16185 p_data_element_value := NULL;
16186
16187 ELSIF (p_data_element_cd = 'WW_INSURED_CD') THEN
16188 -- Obselete SI data element
16189 p_data_element_value := NULL;
16190
16191 ELSIF (p_data_element_cd = 'ZFW_INSURED_CD') THEN
16192 -- Obselete SI data element
16193 p_data_element_value := NULL;
16194
16195 ELSIF (p_data_element_cd = 'ZW_INSURED_CD') THEN
16196 -- Obselete SI data element
16197 p_data_element_value := NULL;
16198
16199 ELSIF (p_data_element_cd = 'INSURANCE_TYPE') THEN
16200 l_ret_val := Get_Ins_Typ_Anw_Ipap
16201 (p_assignment_id
16202 ,p_business_group_id
16203 ,p_date_earned
16204 ,p_error_message
16205 ,p_data_element_value);
16206
16207 ELSIF (p_data_element_cd = 'FPU_CONTRIBUTION') THEN
16208
16209 l_ret_val := Get_rec05_Participation
16210 (p_assignment_id
16211 ,p_business_group_id
16212 ,'FPU_KIND'
16213 ,p_date_earned
16214 ,p_error_message
16215 ,p_data_element_value);
16216
16217 ELSIF (p_data_element_cd = 'PPP_PARTICIPATION') THEN
16218
16219 l_ret_val := Get_rec05_Participation
16220 (p_assignment_id
16221 ,p_business_group_id
16222 ,'PPP_KIND'
16223 ,p_date_earned
16224 ,p_error_message
16225 ,p_data_element_value);
16226
16227 ELSIF (p_data_element_cd = 'INSURANCE_CD_ANW_IPAP') THEN
16228
16229 l_ret_val := Get_Ins_Cd_Anw_Ipap
16230 (p_assignment_id
16231 ,p_business_group_id
16232 ,p_date_earned
16233 ,p_error_message
16234 ,p_data_element_value);
16235
16236 ELSIF (p_data_element_cd = 'OPNP_INDIVIDUAL_CD') THEN
16237
16238 l_ret_val := Get_rec05_Participation
16239 (p_assignment_id
16240 ,p_business_group_id
16241 ,'OPNP_KIND'
16242 ,p_date_earned
16243 ,p_error_message
16244 ,p_data_element_value);
16245
16246
16247 ELSIF (p_data_element_cd = 'PARTICIPATION_CD') THEN
16248
16249 l_ret_val := Get_rec05_Participation
16250 (p_assignment_id
16251 ,p_business_group_id
16252 ,'P_KIND'
16253 ,p_date_earned
16254 ,p_error_message
16255 ,p_data_element_value);
16256
16257 ELSIF (p_data_element_cd = 'MONTH_CONTRIBUTION_AMT') THEN
16258 l_ret_val := Get_Month_Contribution_Amt(p_assignment_id
16259 ,p_business_group_id
16260 ,p_date_earned
16261 ,12
16262 ,p_error_message
16263 ,p_data_element_value);
16264
16265 IF p_data_element_value IS NULL THEN
16266 p_data_element_value := '00';
16267 END IF;
16268
16269 ELSIF (p_data_element_cd = 'MONTH_SI_WAGES') THEN
16270 -- Obselete SI data element
16271 p_data_element_value := NULL;
16272
16273 ELSIF (p_data_element_cd = 'SI_WAGES_AMT_CD') THEN
16274 -- Obselete SI data element
16275 p_data_element_value := NULL;
16276
16277 ELSIF (p_data_element_cd = 'SI_DAYS_CD') THEN
16278
16279 -- Obselete SI Data element
16280 p_data_element_value := NULL;
16281
16282
16283 ELSIF (p_data_element_cd = 'PART_TIME_FACTOR_4') THEN
16284
16285 l_ret_val := Get_rec05_Participation
16286 (p_assignment_id
16287 ,p_business_group_id
16288 ,'PART_TIME_PERC'
16289 ,p_date_earned
16290 ,p_error_message
16291 ,p_data_element_value);
16292
16293 IF IsNumber(p_data_element_value) THEN
16294 p_data_element_value := Trim(To_Char(ABS(Fnd_Number.Canonical_To_Number
16295 (p_data_element_value))
16296 ,'09999'));
16297 END IF;
16298
16299 ELSIF (p_data_element_cd = 'PART_TIME_FACTOR_5') THEN
16300
16301 p_data_element_value := '0';
16302
16303 ELSIF (p_data_element_cd = 'SI_WAGE_PAYMENT_PERIOD') THEN
16304 -- Obselete data element
16305 p_data_element_value := '00';
16306
16307 ELSIF (p_data_element_cd = 'PARTICIPATION_END_REASON') THEN
16308 l_ret_val := Get_rec05_Participation
16309 (p_assignment_id
16310 ,p_business_group_id
16311 ,'END_REASON'
16312 ,p_date_earned
16313 ,p_error_message
16314 ,p_data_element_value);
16315
16316 ELSIF (p_data_element_cd = 'DISCOUNT_BASE_WAO') THEN
16317 -- Obselete data element
16318 p_data_element_value := NULL;
16319
16320 ELSIF (p_data_element_cd = 'PARTICIP_ST_DT_ANW_IPAP') THEN
16321
16322 l_ret_val := Get_Ipap_Participation_Dates
16323 (p_assignment_id
16324 ,p_business_group_id
16325 ,'NEW_ST'
16326 ,p_date_earned
16327 ,p_error_message
16328 ,p_data_element_value);
16329
16330 ELSIF (p_data_element_cd = 'PARTICIP_ST_DT_FUR') THEN
16331
16332 l_ret_val := Get_Fur_Participation_Dates
16333 (p_assignment_id
16334 ,p_business_group_id
16335 ,'NEW_ST'
16336 ,p_date_earned
16337 ,p_error_message
16338 ,p_data_element_value);
16339
16340 ELSIF (p_data_element_cd = 'PARTICIP_ST_DT_OLD_FUR') THEN
16341 l_ret_val := Get_Fur_Participation_Dates
16342 (p_assignment_id
16343 ,p_business_group_id
16344 ,'OLD_ST'
16345 ,p_date_earned
16346 ,p_error_message
16347 ,p_data_element_value);
16348
16349 ELSIF (p_data_element_cd = 'WAGES_SOCIAL_INS') THEN
16350
16351 l_curr_si_rec := '22';
16352 -- Obselete SI data element
16353 p_data_element_value := NULL;
16354
16355 ELSIF (p_data_element_cd = 'SI_DAYS') THEN
16356 -- Obselete SI data element
16357 p_data_element_value := NULL ;
16358
16359 ELSIF (p_data_element_cd = 'PARTICIP_ST_DT_OLD_ANW_IPAP') THEN
16360
16361 l_ret_val := Get_Ipap_Participation_Dates
16362 (p_assignment_id
16363 ,p_business_group_id
16364 ,'OLD_ST'
16365 ,p_date_earned
16366 ,p_error_message
16367 ,p_data_element_value);
16368
16369 ELSIF (p_data_element_cd = 'NEW_PARTICIPATION_ST_DT') THEN
16370
16371 l_ret_val := Get_rec05_Participation
16372 (p_assignment_id
16373 ,p_business_group_id
16374 ,'NEW_ST'
16375 ,p_date_earned
16376 ,p_error_message
16377 ,p_data_element_value);
16378
16379 IF p_data_element_value IS NULL THEN
16380 p_data_element_value := '00000000';
16381 END IF;
16382
16383 ELSIF (p_data_element_cd = 'OLD_PARTICIPATION_ST_DT') THEN
16384
16385 l_ret_val := Get_rec05_Participation
16386 (p_assignment_id
16387 ,p_business_group_id
16388 ,'OLD_ST'
16389 ,p_date_earned
16390 ,p_error_message
16391 ,p_data_element_value);
16392
16393 IF p_data_element_value IS NULL THEN
16394 p_data_element_value := '00000000';
16395 END IF;
16396
16397
16398
16399 ELSIF (p_data_element_cd = 'SI_START_DATE') THEN
16400 -- Obselete SI Data Element
16401 p_data_element_value := '00000000';
16402
16403 ELSIF (p_data_element_cd = 'PARTICIPATION_VALUE') THEN
16404
16405 l_ret_val := Get_rec05_Participation
16406 (p_assignment_id
16407 ,p_business_group_id
16408 ,'P_VALUE'
16409 ,p_date_earned
16410 ,p_error_message
16411 ,p_data_element_value);
16412
16413 IF IsNumber(p_data_element_value) THEN
16414 p_data_element_value := Trim(To_Char(ABS(Fnd_Number.Canonical_To_Number
16415 (Nvl(p_data_element_value,'0')))
16416 ,'099'));
16417 END IF;
16418
16419 ELSIF (p_data_element_cd = 'SI_WAGES_PAYMENT_YEAR') THEN
16420 -- Obselete SI data element
16421 p_data_element_value := '0000';
16422
16423 ELSIF (p_data_element_cd = 'CONTRIBUTION_AMT_YEAR') THEN
16424
16425 l_ret_val := Get_Year_Contribution_Amt(p_assignment_id
16426 ,p_business_group_id
16427 ,p_date_earned
16428 ,12
16429 ,p_error_message
16430 ,p_data_element_value);
16431
16432 IF p_data_element_value IS NULL THEN
16433 p_data_element_value := '0000';
16434 END IF;
16435
16436 ELSIF (p_data_element_cd = 'SI_WAGES_YEAR') THEN
16437 -- Obselete data element
16438 p_data_element_value := '0000';
16439
16440 ELSIF (p_data_element_cd = 'TERM_REASON') THEN
16441 -- Obselete SI Data Element
16442 p_data_element_value := '';
16443
16444 END IF;
16445
16446 p_data_element_value := Upper(p_data_element_value);
16447
16448 RETURN l_ret_val;
16449
16450 EXCEPTION
16451 WHEN Others THEN
16452 p_error_message :='SQL-ERRM :'||SQLERRM;
16453 Hr_Utility.set_location('..'||p_error_message,85);
16454 Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
16455 RETURN l_ret_val;
16456 END PQP_NL_GET_DATA_ELEMENT_VALUE;
16457
16458 -- ===============================================================================
16459 -- ~ Get_Header_EMR_Number : Common function to get the Header Information
16460 -- ===============================================================================
16461 FUNCTION Get_Header_EMR_Number
16462 (p_org_id IN NUMBER
16463 ,p_effective_date IN DATE
16464 ) RETURN VARCHAR2 IS
16465
16466 --
16467 -- Cursor to get the ER number from the org level.
16468 --
16469 CURSOR csr_get_new_er_num(c_org_id IN NUMBER
16470 ,c_effective_date IN DATE) IS
16471 SELECT SUBSTR(NVL(org_information2,'-1'),0,7)
16472 FROM hr_organization_information
16473 WHERE org_information_context = 'PQP_ABP_PROVIDER'
16474 AND organization_id = c_org_id;
16475
16476 l_proc_name VARCHAR2(150) := g_proc_name ||'.Get_Header_EMR_Number';
16477 l_new_er_num VARCHAR(7) := '0';
16478
16479 BEGIN
16480
16481 hr_utility.set_location('Entering: '||l_proc_name, 5);
16482
16483 OPEN csr_get_new_er_num(p_org_id,p_effective_date);
16484 FETCH csr_get_new_er_num INTO l_new_er_num;
16485 CLOSE csr_get_new_er_num;
16486
16487 hr_utility.set_location('Leaving: '||l_proc_name, 45);
16488
16489 RETURN l_new_er_num;
16490
16491 EXCEPTION
16492 WHEN Others THEN
16493 hr_utility.set_location('Exception Others Raised at Get_Header_Information',40);
16494 hr_utility.set_location('Leaving: '||l_proc_name, 45);
16495 RETURN -1;
16496 END Get_Header_EMR_Number;
16497
16498 -- ===============================================================================
16499 -- ~ Get_Header_Submit_Code : Function to get the submitter identification code
16500 -- ===============================================================================
16501 FUNCTION Get_Header_Submit_Code
16502 (p_org_id IN Number
16503 ) RETURN Varchar2 IS
16504
16505
16506 CURSOR csr_get_submit_code IS
16507 SELECT Substr(org_information3,0,4)
16508 FROM hr_organization_information
16509 WHERE org_information_context = 'PQP_ABP_PROVIDER'
16510 AND organization_id = p_org_id;
16511
16512 l_proc_name Varchar2(150) := g_proc_name ||'.Get_Header_Submit_Code';
16513 l_submit_code Varchar(4) := '';
16514 BEGIN
16515 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
16516
16517 OPEN csr_get_submit_code;
16518 FETCH csr_get_submit_code INTO l_submit_code;
16519 CLOSE csr_get_submit_code;
16520
16521 Hr_Utility.set_location('Leaving: '||l_proc_name, 45);
16522 RETURN l_submit_code;
16523 EXCEPTION
16524 WHEN Others THEN
16525 Hr_Utility.set_location('Exception Others Raised at Get_Submitter_code',40);
16526 Hr_Utility.set_location('Leaving: '||l_proc_name, 45);
16527 RETURN -1;
16528 END Get_Header_Submit_Code;
16529
16530 -- ===============================================================================
16531 -- ~ Get_Header_Information : Common function to get the Header Information
16532 -- ===============================================================================
16533 FUNCTION Get_Header_Information
16534 (p_header_type IN Varchar2
16535 ,p_error_message OUT NOCOPY Varchar2) RETURN Varchar2 IS
16536
16537 l_proc_name Varchar2(150) := g_proc_name ||'.Get_Header_Information';
16538 l_return_value Varchar2(1000);
16539 l_new_er_num Varchar(4);
16540
16541
16542 BEGIN
16543
16544 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
16545 IF p_header_type = 'HEADER_FILE_SUB_PERIOD' THEN
16546 l_return_value := To_Char(Fnd_Date.canonical_to_date(Fnd_Date.date_to_canonical(g_conc_prog_details(0).beginningdt)),'YYYYMM');
16547 ELSIF p_header_type = 'HEADER_SUB_IDEN' THEN
16548 l_return_value := g_conc_prog_details(0).orgname;
16549 ELSIF p_header_type = 'HEADER_EMR_REG_NUM' THEN
16550 l_new_er_num :=Get_Header_Submit_Code(g_conc_prog_details(0).orgid);
16551 l_return_value := l_new_er_num;
16552 IF IsNumber(l_return_value) THEN
16553 l_return_value := Trim(To_Char(Fnd_Number.Canonical_To_Number
16554 (Nvl(l_return_value,'0'))
16555 ,'0999'));
16556 END IF;
16557
16558 END IF;
16559
16560 Hr_Utility.set_location('Leaving: '||l_proc_name, 45);
16561
16562 RETURN l_return_value;
16563 EXCEPTION
16564 WHEN Others THEN
16565 p_error_message :='SQL-ERRM :'||SQLERRM;
16566 Hr_Utility.set_location('..Exception Others Raised at Get_Header_Information'||p_error_message,40);
16567 Hr_Utility.set_location('Leaving: '||l_proc_name, 45);
16568 RETURN l_return_value;
16569 END Get_Header_Information;
16570
16571
16572 -- ===============================================================================
16573 -- ~ Get_Trailer_Amount_Sign : This is used to decide the sgn
16574 -- ===============================================================================
16575 FUNCTION Get_Trailer_Amount_Sign
16576 (p_amount IN Number
16577 ) RETURN Varchar2 IS
16578
16579 CURSOR csr_get_sign(c_amount IN Number) IS
16580 SELECT Sign(c_amount)
16581 FROM dual;
16582
16583 l_proc_name Varchar2(150) := g_proc_name ||'.Get_Trailer_Amount_Sign';
16584 l_sing_number Number := 0;
16585 l_temp Number;
16586
16587 BEGIN
16588 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
16589 IF p_amount IS NOT NULL THEN
16590 OPEN csr_get_sign(p_amount);
16591 FETCH csr_get_sign INTO l_temp;
16592 CLOSE csr_get_sign;
16593 IF l_temp = -1 THEN
16594 RETURN 'C';
16595 ELSE
16596 RETURN ' ';
16597 END IF;
16598 END IF;
16599 Hr_Utility.set_location('Leaving: '||l_proc_name, 45);
16600 RETURN ' ';
16601 EXCEPTION
16602 WHEN Others THEN
16603 Hr_Utility.set_location('Exception Others Raised at Get_Header_Information',40);
16604 Hr_Utility.set_location('Leaving: '||l_proc_name, 45);
16605 RETURN ' ';
16606 END Get_Trailer_Amount_Sign;
16607
16608 -- ===============================================================================
16609 -- ~ Get_All_Records_Count : This is used to calculate the record count
16610 -- ===============================================================================
16611 FUNCTION Get_All_Records_Count
16612 (p_rcd_1 IN NUMBER
16613 ,p_rcd_2 IN NUMBER
16614 ,p_emr_id IN NUMBER) RETURN NUMBER IS
16615
16616 CURSOR csr_get_a_record_count(c_recordid_1 IN NUMBER
16617 ,c_recordid_2 IN NUMBER
16618 ,c_emr_id IN NUMBER ) IS
16619 SELECT Count(dtl.ext_rslt_dtl_id)
16620 FROM ben_ext_rslt_dtl dtl
16621 WHERE dtl.ext_rslt_id = ben_ext_thread.g_ext_rslt_id
16622 AND ext_rcd_id NOT IN(c_recordid_1,c_recordid_2)
16623 AND val_25 = c_emr_id;
16624
16625 l_proc_name VARCHAR2(150) := g_proc_name ||'.Get_All_Records_Count';
16626 l_record_count NUMBER := 0;
16627
16628 BEGIN
16629
16630 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
16631
16632 OPEN csr_get_a_record_count(p_rcd_1,p_rcd_2,p_emr_id);
16633 FETCH csr_get_a_record_count INTO l_record_count;
16634 CLOSE csr_get_a_record_count;
16635
16636 Hr_Utility.set_location('Leaving: '||l_proc_name, 45);
16637
16638 RETURN l_record_count;
16639
16640 EXCEPTION
16641 WHEN OTHERS THEN
16642 Hr_Utility.set_location('Exception Others Raised at Get_Header_Information',40);
16643 Hr_Utility.set_location('Leaving: '||l_proc_name, 45);
16644 RETURN -1;
16645 END Get_All_Records_Count;
16646
16647 -- ===============================================================================
16648 -- ~ Get_Trailer_Record_Count : This is used to calculate the record count
16649 -- ===============================================================================
16650 FUNCTION Get_Trailer_Record_Count
16651 (p_rcd_1 IN Number
16652 ,p_rcd_2 IN Number
16653 ,p_rcd_3 IN Number
16654 ,p_emr_id IN Number
16655 ) RETURN Number IS
16656
16657 CURSOR csr_get_record_count(c_recordid_1 IN Number
16658 ,c_recordid_2 IN Number
16659 ,c_recordid_3 IN Number
16660 ,c_emr_id IN Number ) IS
16661 SELECT Count(dtl.ext_rslt_dtl_id)
16662 FROM ben_ext_rslt_dtl dtl
16663 WHERE dtl.ext_rslt_id = Ben_Ext_Thread.g_ext_rslt_id
16664 AND ext_rcd_id IN(c_recordid_1,c_recordid_2,c_recordid_3)
16665 AND val_25=c_emr_id;
16666
16667 l_proc_name Varchar2(150) := g_proc_name ||'.Get_Trailer_Record_Count';
16668 l_record_count Number := 0;
16669 BEGIN
16670 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
16671 OPEN csr_get_record_count(p_rcd_1,p_rcd_2,p_rcd_3,p_emr_id);
16672 FETCH csr_get_record_count INTO l_record_count;
16673 CLOSE csr_get_record_count;
16674 Hr_Utility.set_location('Leaving: '||l_proc_name, 45);
16675 RETURN l_record_count;
16676 EXCEPTION
16677 WHEN Others THEN
16678 Hr_Utility.set_location('Exception Others Raised at Get_Trailer_Record_Count',40);
16679 Hr_Utility.set_location('Leaving: '||l_proc_name, 45);
16680 RETURN -1;
16681 END Get_Trailer_Record_Count;
16682
16683 -- ================================================================================
16684 -- ~ Sort_Post_Process : Post process logic
16685 -- ================================================================================
16686 FUNCTION Sort_Post_Process
16687 (p_business_group_id ben_ext_rslt_dtl.business_group_id%TYPE
16688 )RETURN Number IS
16689
16690 /* --9278285 cursor modified
16691 CURSOR csr_get_rslt(c_org_id IN Varchar2
16692 ,c_ext_rslt_id IN Number ) IS
16693 SELECT DISTINCT(val_26) val_26
16694 FROM ben_ext_rslt_dtl dtl
16695 WHERE dtl.ext_rslt_id = c_ext_rslt_id
16696 AND val_25= c_org_id
16697 ORDER BY val_26 ASC ;
16698 */
16699
16700 --9278285 ordering on employee number only.
16701 --Do not pick org wise record, instead pick all records in one go.
16702 CURSOR csr_get_rslt(c_ext_rslt_id IN Number ) IS
16703 SELECT DISTINCT(val_26) val_26
16704 FROM ben_ext_rslt_dtl dtl
16705 WHERE dtl.ext_rslt_id = c_ext_rslt_id
16706 AND val_25 IS NOT NULL
16707 AND val_26 IS NOT NULL
16708 ORDER BY val_26 ASC ;
16709
16710
16711 CURSOR csr_get_rslt1(c_ext_rslt_id IN Number ) IS
16712 SELECT val_25,val_26
16713 FROM ben_ext_rslt_dtl dtl
16714 WHERE dtl.ext_rslt_id = c_ext_rslt_id
16715 ORDER BY val_26 ASC ;
16716
16717 CURSOR csr_rslt_dtl_sort(c_val_26 IN Varchar2
16718 ,c_ext_rslt_id IN Number ) IS
16719 SELECT *
16720 FROM ben_ext_rslt_dtl dtl
16721 WHERE dtl.ext_rslt_id = c_ext_rslt_id
16722 -- AND dtl.person_id = c_person_id
16723 AND dtl.val_26 =c_val_26;
16724
16725
16726
16727 CURSOR csr_get_header_rslt(c_ext_rslt_id IN Number
16728 ,c_ext_dtl_rcd_id IN Number ) IS
16729 SELECT *
16730 FROM ben_ext_rslt_dtl dtl
16731 WHERE dtl.ext_rslt_id = c_ext_rslt_id
16732 AND ext_rcd_id= c_ext_dtl_rcd_id;
16733
16734
16735 CURSOR csr_get_trailer_rslt(c_ext_rslt_id IN Number
16736 ,c_ext_dtl_rcd_id IN Number ) IS
16737 SELECT *
16738 FROM ben_ext_rslt_dtl dtl
16739 WHERE dtl.ext_rslt_id = c_ext_rslt_id
16740 AND ext_rcd_id= c_ext_dtl_rcd_id;
16741
16742 -- Cursor to get the person existence flag
16743 CURSOR csr_get_person_exist(c_org_id IN Number) IS
16744 SELECT 'x'
16745 FROM ben_ext_rslt_dtl
16746 WHERE ext_rslt_id=Ben_Ext_Thread.g_ext_rslt_id
16747 AND val_25=c_org_id;
16748
16749 --
16750 -- Cursor to get the record id for Rec 05
16751 --
16752 CURSOR csr_rcd_05_id IS
16753 SELECT rcd.ext_rcd_id,rin.seq_num
16754 FROM ben_ext_rcd rcd
16755 ,ben_ext_rcd_in_file rin
16756 ,ben_ext_dfn dfn
16757 WHERE dfn.ext_dfn_id = Ben_Ext_Thread.g_ext_dfn_id
16758 AND rin.ext_file_id = dfn.ext_file_id
16759 AND rin.ext_rcd_id = rcd.ext_rcd_id
16760 AND rin.seq_num = 5;
16761
16762 --
16763 -- Cursor to get the records 05 rows that need to be deleted.
16764 --
16765 CURSOR csr_rec05_del (p_ext_rcd_id IN NUMBER) IS
16766 SELECT ext_rslt_dtl_id
16767 FROM ben_ext_rslt_dtl
16768 WHERE ext_rslt_id = Ben_Ext_Thread.g_ext_rslt_id
16769 AND ext_rcd_id = p_ext_rcd_id
16770 AND val_05 = '00000000'
16771 AND val_06 = '00000000'
16772 AND val_07 = '00000000'
16773 AND val_08 = '00000000'
16774 AND val_10 = '00000000'
16775 AND val_17 = '00000000'
16776 AND business_group_id = p_business_group_id;
16777
16778 l_ext_dtl_rcd_id ben_ext_rcd.ext_rcd_id%TYPE;
16779 l_ext_main_rcd_id ben_ext_rcd.ext_rcd_id%TYPE;
16780 l_proc_name Varchar2(150):= g_proc_name||'Sort_Post_Process';
16781 l_return_value Number := 0; --0= Sucess, -1=Error ;
16782 l_tmp_person_id Number;
16783 l_tmp_org_id Number;
16784 l_first_flag Number :=0;
16785 l_org_pram_id hr_all_organization_units.organization_id%TYPE;
16786 l_temp_org_pram_id hr_all_organization_units.organization_id%TYPE;
16787 l_org_detl g_org_list%TYPE;
16788 l_org_index Number :=1;
16789 l_global_contribution Number :=0;
16790 l_first_person_id Number;
16791 l_main_rec csr_rslt_dtl_sort%ROWTYPE;
16792 l_new_rec csr_rslt_dtl_sort%ROWTYPE;
16793 l_header_main_rec csr_get_header_rslt%ROWTYPE;
16794 l_header_new_rec csr_get_header_rslt%ROWTYPE;
16795 l_trailer_main_rec csr_get_trailer_rslt%ROWTYPE;
16796 l_trailer_new_rec csr_get_trailer_rslt%ROWTYPE;
16797 sort_val Number :=1;
16798 l_sort_val Varchar2(15);
16799 l_org_count Number :=0;
16800 l_header_er_num Varchar2(4);
16801 l_trailer_er_num Varchar2(7);
16802 l_org_name hr_all_organization_units.NAME%TYPE;
16803 l_CodeA_R96_Contri Number :=0;
16804 l_CodeD_R96_Contri Number :=0;
16805 l_record96_count Number :=0;
16806 l_record96_rcd_id Number;
16807 l_R95_Contri Number := 0;
16808 l_record95_count Number := 0;
16809 l_R97_Contri Number := 0;
16810 l_record97_count Number := 0;
16811 l_R94_WA_Contri Number := 0;
16812 l_R94_UF_Contri Number := 0;
16813 l_R94_ZF_Contri Number := 0;
16814 l_R94_SI_Contri Number := 0;
16815 l_record94_count Number := 0;
16816 l_R99_Yearly_Amount Number := 0;
16817 l_R99_OPNP_Contri Number := 0;
16818 l_R99_IPbw_H_Contri Number := 0;
16819 l_R99_IPbw_L_Contri Number := 0;
16820 l_R99_Fpu_B_Contri Number := 0;
16821 l_R99_Fpu_C_Contri Number := 0;
16822 l_record99_count Number := 0;
16823 l_00_inserted Number := 0;
16824 l_insert_trailer Number := 1;
16825 l_first_trailer_flag Number :=0;
16826 l_Person_Exists Varchar2(2);
16827 i Number := 0;
16828 l_R00_rslt_dtl_id Number;
16829 l_R94_rslt_dtl_id Number;
16830 l_R95_rslt_dtl_id Number;
16831 l_R96_rslt_dtl_id Number;
16832 l_R97_rslt_dtl_id Number;
16833 l_R99_rslt_dtl_id Number;
16834 l_ext_rslt_dtl_id Number;
16835 l_count Number := 0;
16836 l_employer_count Number := 0;
16837 l_er_index Number := 0;
16838 l_org_grp_index Number := 0;
16839 l_group_org_index Number := 0;
16840 l_employer_index Number := 0;
16841
16842 --10136155
16843 CURSOR C_USR_TAB_COL
16844 IS
16845 SELECT put.USER_TABLE_ID, puc.USER_COLUMN_ID
16846 FROM PAY_USER_TABLES put,
16847 PAY_USER_COLUMNS puc
16848 WHERE
16849 put.USER_TABLE_ID = puc.USER_TABLE_ID
16850 AND put.LEGISLATION_CODE = puc.LEGISLATION_CODE
16851 AND put.USER_TABLE_NAME = 'NL_DIACRITICAL_MARKS'
16852 AND put.LEGISLATION_CODE = 'NL';
16853
16854 l_user_table_id NUMBER;
16855 l_user_column_id NUMBER;
16856
16857 CURSOR C_SRC_DEST_STR(p_USER_COLUMN_ID NUMBER, p_USER_TABLE_ID IN NUMBER)
16858 IS
16859 select UPPER(purf.ROW_LOW_RANGE_OR_NAME) ROW_LOW_RANGE_OR_NAME, UPPER(pucif.VALUE) VALUE
16860 from
16861 PAY_USER_COLUMN_INSTANCES_F pucif,
16862 PAY_USER_ROWS_F purf
16863 where
16864 pucif.USER_COLUMN_ID = p_USER_COLUMN_ID
16865 AND purf.USER_TABLE_ID = p_USER_TABLE_ID
16866 AND pucif.USER_ROW_ID = purf.USER_ROW_ID
16867 AND pucif.business_group_id = purf.business_group_id
16868 AND pucif.business_group_id = p_business_group_id
16869 AND g_extract_params(p_business_group_id).extract_start_date BETWEEN pucif.EFFECTIVE_START_DATE AND pucif.EFFECTIVE_END_DATE
16870 AND g_extract_params(p_business_group_id).extract_start_date BETWEEN purf.EFFECTIVE_START_DATE AND purf.EFFECTIVE_END_DATE;
16871
16872 l_SOURCE VARCHAR2(4000);
16873 l_DEST VARCHAR2(4000);
16874 --10136155
16875
16876 BEGIN
16877 Hr_Utility.set_location('Entering :---------'||l_proc_name, 5);
16878 -- Delete all the hidden Records
16879 FOR csr_rcd_rec IN csr_ext_rcd_id
16880 (c_hide_flag => 'Y' -- N=No Y=Yes
16881 ,c_rcd_type_cd => 'D')-- D=Detail, T=Total, H-Header
16882 -- Loop through each detail record for the extract
16883 LOOP
16884 -- Delete all detail records for the record
16885 DELETE ben_ext_rslt_dtl
16886 WHERE ext_rcd_id = csr_rcd_rec.ext_rcd_id
16887 AND ext_rslt_id = Ben_Ext_Thread.g_ext_rslt_id
16888 AND business_group_id = p_business_group_id;
16889 END LOOP; -- FOR csr_rcd_rec
16890
16891 --
16892 -- Delete all the Record 05's that are not necessary.
16893 --
16894 FOR csr_rcd_05_id_rec IN csr_rcd_05_id
16895 LOOP
16896 FOR csr_rec05_del_rec IN csr_rec05_del (csr_rcd_05_id_rec.ext_rcd_id)
16897 LOOP
16898 DELETE ben_ext_rslt_dtl
16899 WHERE ext_rslt_dtl_id = csr_rec05_del_rec.ext_rslt_dtl_id;
16900 END LOOP; -- FOR csr_rcd_05_id
16901 END LOOP; -- For csr_rec05_del
16902
16903 -- All orgs,fill up the temp. table with the org ids in order of
16904 --the sort value
16905 FOR val IN csr_get_rslt1
16906 (c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id )
16907 LOOP
16908 hr_utility.set_location('val 26 : '||val.val_26,10);
16909 IF g_org_list.EXISTS(val.val_25) THEN
16910 IF NOT g_ord_details1.EXISTS(val.val_25) THEN
16911 hr_utility.set_location('l_org_index : '||l_org_index,20);
16912 hr_utility.set_location('org : '||val.val_25,30);
16913 g_ord_details(l_org_index).gre_org_id := val.val_25;
16914 g_ord_details1(to_number(val.val_25)).gre_org_id := val.val_25;
16915 l_org_index := l_org_index + 1;
16916 END IF;
16917 END IF;
16918 END LOOP;
16919 -- Maintaining recordIds with record numbers in plsql table
16920 FOR rcd_dtls IN csr_ext_rcd_id_with_seq()
16921 LOOP
16922 IF rcd_dtls.hide_flag = 'N' THEN
16923 g_rcd_dtls(To_Number(rcd_dtls.rec_num)).ext_rcd_id := rcd_dtls.ext_rcd_id;
16924 END IF;
16925 END LOOP;
16926
16927 l_org_count := g_ord_details.Count;
16928
16929 --fetch the extract result id for the trailer records
16930 --these are ids for the records created automatically by
16931 --benefits, and they will be deleted in the end after we
16932 --create our own trailer records for each org based on these
16933 FOR csr_rcd_rec IN csr_ext_rcd_id(c_hide_flag => 'N'
16934 ,c_rcd_type_cd => 'T')-- T-Trailer
16935 LOOP
16936 OPEN csr_get_trailer_rslt(c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
16937 ,c_ext_dtl_rcd_id => csr_rcd_rec.ext_rcd_id);
16938 FETCH csr_get_trailer_rslt INTO l_trailer_main_rec;
16939 CLOSE csr_get_trailer_rslt;
16940 IF g_rcd_dtls(94).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
16941 l_R94_rslt_dtl_id := l_trailer_main_rec.ext_rslt_dtl_id;
16942 ELSIF g_rcd_dtls(95).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
16943 l_R95_rslt_dtl_id := l_trailer_main_rec.ext_rslt_dtl_id;
16944 ELSIF g_rcd_dtls(96).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
16945 l_R96_rslt_dtl_id := l_trailer_main_rec.ext_rslt_dtl_id;
16946 ELSIF g_rcd_dtls(97).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
16947 l_R97_rslt_dtl_id := l_trailer_main_rec.ext_rslt_dtl_id;
16948 ELSIF g_rcd_dtls(99).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
16949 l_R99_rslt_dtl_id := l_trailer_main_rec.ext_rslt_dtl_id;
16950 END IF;
16951 END LOOP;
16952
16953 --find the dtl record id for the header record
16954 --since records need to be sorted by employer number, the default
16955 --header record created by benefits needs to be deleted later
16956 FOR csr_rcd_rec IN csr_ext_rcd_id(c_hide_flag => 'N'
16957 ,c_rcd_type_cd => 'H')-- H-Header
16958 LOOP
16959 OPEN csr_get_header_rslt(c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
16960 ,c_ext_dtl_rcd_id => csr_rcd_rec.ext_rcd_id);
16961 FETCH csr_get_header_rslt INTO l_header_main_rec;
16962 CLOSE csr_get_header_rslt;
16963 IF g_rcd_dtls(00).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
16964 l_R00_rslt_dtl_id := l_header_main_rec.ext_rslt_dtl_id;
16965 END IF;
16966 END LOOP;
16967
16968 -- If there are no emps for next org in list of org
16969 -- then no need to create the header
16970 /*OPEN csr_get_person_exist(g_conc_prog_details(0).orgid);
16971 FETCH csr_get_person_exist INTO l_Person_Exists;
16972 CLOSE csr_get_person_exist;
16973 IF l_Person_Exists = 'x' THEN*/
16974
16975 --Loop through Header records
16976 FOR csr_rcd_rec IN csr_ext_rcd_id(c_hide_flag => 'N'
16977 ,c_rcd_type_cd => 'H')-- H-Header
16978 LOOP
16979 OPEN csr_get_header_rslt(c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
16980 ,c_ext_dtl_rcd_id => csr_rcd_rec.ext_rcd_id);
16981 FETCH csr_get_header_rslt INTO l_header_main_rec;
16982 CLOSE csr_get_header_rslt;
16983 l_header_new_rec := l_header_main_rec;
16984 l_sort_val := Lpad(sort_val,15,0);
16985 l_header_new_rec.prmy_sort_val := l_sort_val;
16986 --Updating the employer name and employer number
16987 l_header_er_num :=Get_Header_Submit_Code(g_conc_prog_details(0).orgid);
16988
16989 IF IsNumber(l_header_er_num) THEN
16990 l_header_er_num := Trim(To_Char(Fnd_Number.Canonical_To_Number
16991 (Nvl(l_header_er_num,'0'))
16992 ,'0999'));
16993
16994 END IF;
16995
16996 OPEN csr_org_name( c_org_id => g_conc_prog_details(0).orgid);
16997 FETCH csr_org_name INTO l_org_name;
16998 CLOSE csr_org_name;
16999 l_header_new_rec.val_07 := l_org_name;
17000 l_header_new_rec.val_08 := l_header_er_num;
17001 l_header_new_rec.object_version_NUMBER := Nvl(l_header_new_rec.object_version_NUMBER,0) + 1;
17002 sort_val :=sort_val+1;
17003
17004 -- Insert the header record only once for each extract
17005 IF l_00_inserted=0 THEN
17006 Ins_Rslt_Dtl(p_dtl_rec => l_header_new_rec);
17007 l_00_inserted:=1;
17008 END IF;
17009 -- l_Person_Exists := 'y';
17010 END LOOP;
17011 -- END IF;
17012
17013
17014 -- loop through all employers
17015 l_employer_count:=g_employer_list.COUNT;
17016 l_employer_index:=g_employer_list.FIRST;
17017 l_er_index:=0;
17018 Hr_Utility.set_location('l_employer_count --'||l_employer_count,20);
17019
17020 /* --9278285 Commented Do Not Create trailer record per group
17021 WHILE l_employer_index IS NOT NULL
17022 LOOP
17023 --l_count Keeps track of total number of trailor records added per group
17024 l_count:=0;
17025
17026 l_org_grp_index:=0;
17027 */
17028 -- for all orgs in the groups
17029 /* --9278285 Commented Do Not divide records into groups
17030 Hr_Utility.set_location('Grp count '||g_org_grp_list_cnt(l_employer_index).org_grp_count ,23);
17031 FOR l_org_count IN 1..g_org_grp_list_cnt(l_employer_index).org_grp_count
17032 LOOP
17033 l_group_org_index:=l_er_index * 1000 + l_org_grp_index;
17034 Hr_Utility.set_location('Current Org Id:---------'||g_employer_child_list(l_group_org_index).gre_org_id, 25);
17035 -- Get all rows/persons for this orgid
17036 */
17037
17038 /* --9278285 Cursor Modified, picking all employee records in correct order and storing.
17039 FOR val IN csr_get_rslt
17040 (c_org_id => g_employer_child_list(l_group_org_index).gre_org_id
17041 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id )
17042 */
17043 --9278285
17044 FOR val IN csr_get_rslt
17045 (c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id )
17046 --9278285
17047 LOOP
17048 --Hr_Utility.set_location('val'||val.EXT_RSLT_DTL_ID ,26);
17049 -- Get the individual row using sortid key
17050 -- So we will get only one record related data per person
17051 FOR ind_dtl IN csr_rslt_dtl_sort
17052 (c_val_26 => val.val_26
17053 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
17054 )
17055 LOOP
17056 l_main_rec := ind_dtl;
17057 l_main_rec.object_version_NUMBER := Nvl(l_main_rec.object_version_NUMBER,0) + 1;
17058 l_new_rec := l_main_rec;
17059 l_sort_val:= Lpad(sort_val,15,0);
17060 l_new_rec.prmy_sort_val := l_sort_val;
17061 sort_val :=sort_val+1;
17062 Upd_Rslt_Dtl(p_dtl_rec => l_new_rec);
17063
17064 -- Totaling Record 94 Processing
17065 -- Rrecord 21
17066 IF l_new_rec.ext_rcd_id = g_rcd_dtls(21).ext_rcd_id AND
17067 l_new_rec.val_01 = '21'
17068 THEN
17069 -- Checking SI Wages Type is WA,UF or ZF (Seq 06)
17070 --Then getting the value of SI Wages ABP USZO(Seq 08)
17071 IF l_new_rec.val_06 ='WA'THEN
17072 IF nvl(l_new_rec.val_09,' ') = 'C' THEN
17073 l_R94_WA_Contri:=l_R94_WA_Contri-Nvl(To_Number(l_new_rec.val_08),0);
17074 ELSE
17075 l_R94_WA_Contri:=l_R94_WA_Contri+Nvl(To_Number(l_new_rec.val_08),0);
17076 END IF;
17077 ELSIF l_new_rec.val_06 ='UF'THEN
17078 IF nvl(l_new_rec.val_09,' ') = 'C' THEN
17079 l_R94_UF_Contri:=l_R94_UF_Contri-Nvl(To_Number(l_new_rec.val_08),0);
17080 ELSE
17081 l_R94_UF_Contri:=l_R94_UF_Contri+Nvl(To_Number(l_new_rec.val_08),0);
17082 END IF;
17083 ELSIF l_new_rec.val_06 ='ZF'THEN
17084 IF nvl(l_new_rec.val_09,' ') = 'C' THEN
17085 l_R94_ZF_Contri:=l_R94_ZF_Contri-Nvl(To_Number(l_new_rec.val_08),0);
17086 ELSE
17087 l_R94_ZF_Contri:=l_R94_ZF_Contri+Nvl(To_Number(l_new_rec.val_08),0);
17088 END IF;
17089 END IF;
17090 END IF;
17091 -- Record 22
17092 IF l_new_rec.ext_rcd_id = g_rcd_dtls(22).ext_rcd_id AND
17093 l_new_rec.val_01 = '22'
17094 THEN
17095 --Getting the value of Social Insurance Wages ABP USZO(Seq 07)
17096 IF nvl(l_new_rec.val_08,' ') = 'C' THEN
17097 l_R94_SI_Contri:=l_R94_SI_Contri-Nvl(To_Number(l_new_rec.val_07),0);
17098 ELSE
17099 l_R94_SI_Contri:=l_R94_SI_Contri+Nvl(To_Number(l_new_rec.val_07),0);
17100 END IF;
17101 END IF;
17102 -- End of Record 94
17103
17104 -- Totaling Record 95 Processing
17105 -- Record 31
17106 IF l_new_rec.ext_rcd_id = g_rcd_dtls(31).ext_rcd_id AND
17107 l_new_rec.val_01 = '31'
17108 THEN
17109 IF nvl(l_new_rec.val_08,' ') = 'C' THEN
17110 l_R95_Contri:=l_R95_Contri-Nvl(To_Number(l_new_rec.val_07),0);
17111 ELSE
17112 l_R95_Contri:=l_R95_Contri+Nvl(To_Number(l_new_rec.val_07),0);
17113 END IF;
17114 END IF;
17115 -- End of Record 95
17116
17117 -- Totaling Record 96 Processing
17118 -- Record 41
17119 IF l_new_rec.ext_rcd_id = g_rcd_dtls(41).ext_rcd_id AND
17120 l_new_rec.val_01 = '41'
17121 THEN
17122 IF l_new_rec.val_06 ='D' THEN
17123 IF nvl(l_new_rec.val_08,' ') = 'C' THEN
17124 l_CodeD_R96_Contri:=l_CodeD_R96_Contri-Nvl(To_Number(l_new_rec.val_07),0);
17125 ELSE
17126 l_CodeD_R96_Contri:=l_CodeD_R96_Contri+Nvl(To_Number(l_new_rec.val_07),0);
17127 END IF;
17128 ELSIF l_new_rec.val_06 ='A' THEN
17129 IF nvl(l_new_rec.val_08,' ') = 'C' THEN
17130 l_CodeA_R96_Contri :=l_CodeA_R96_Contri-Nvl(To_Number(l_new_rec.val_07),0);
17131 ELSE
17132 l_CodeA_R96_Contri :=l_CodeA_R96_Contri+Nvl(To_Number(l_new_rec.val_07),0);
17133 END IF;
17134 END IF;
17135 END IF;
17136 --End of Record 96
17137
17138 -- Totaling Record 97 Processing
17139 -- Record 12
17140 IF l_new_rec.ext_rcd_id = g_rcd_dtls(12).ext_rcd_id AND
17141 l_new_rec.val_01 = '12'
17142 THEN
17143 IF nvl(l_new_rec.val_07,' ') = 'C' THEN
17144 l_R97_Contri:=l_R97_Contri-Nvl(To_Number(l_new_rec.val_06),0);
17145 ELSE
17146 l_R97_Contri:=l_R97_Contri+Nvl(To_Number(l_new_rec.val_06),0);
17147 END IF;
17148 END IF;
17149 -- End of Record 97
17150
17151 -- Totaling Record 99 Processing
17152 -- Record8
17153 IF l_new_rec.ext_rcd_id = g_rcd_dtls(8).ext_rcd_id AND
17154 l_new_rec.val_01 = '08'
17155 THEN
17156 -- Calculating Pension Salary ABP USZO(seq05)
17157 Hr_Utility.set_location('inside 99 prcesssing' ,26);
17158 --Hr_Utility.set_location('val'||val.EXT_RSLT_DTL_ID,26);
17159 Hr_Utility.set_location('l_R99_Yearly_Amount :'||To_Number(l_new_rec.val_05),12);
17160 l_R99_Yearly_Amount := l_R99_Yearly_Amount+Nvl(To_Number(l_new_rec.val_05),0);
17161 END IF;
17162 -- Record9
17163 IF l_new_rec.ext_rcd_id = g_rcd_dtls(9).ext_rcd_id AND
17164 l_new_rec.val_01 = '09'
17165 THEN
17166 --Check the record9 Basis Contribution (seq 05)
17167 --then calculate seq 6 value (ABP Pension Basis Contribution ABP USZO)
17168 IF l_new_rec.val_05 = 'OP' THEN
17169 IF nvl(l_new_rec.val_07,' ') = 'C' THEN
17170 l_R99_OPNP_Contri := l_R99_OPNP_Contri-Nvl(To_Number(l_new_rec.val_06),0);
17171 ELSE
17172 l_R99_OPNP_Contri := l_R99_OPNP_Contri+Nvl(To_Number(l_new_rec.val_06),0);
17173 END IF;
17174 -- IPBW_H code is 06
17175 ELSIF l_new_rec.val_05 IN('IH','AP') THEN
17176 IF nvl(l_new_rec.val_07,' ') = 'C' THEN
17177 l_R99_IPbw_H_Contri := l_R99_IPbw_H_Contri-Nvl(To_Number(l_new_rec.val_06),0);
17178 ELSE
17179 l_R99_IPbw_H_Contri := l_R99_IPbw_H_Contri+Nvl(To_Number(l_new_rec.val_06),0);
17180 END IF;
17181 -- IPBW_L code is 07
17182 ELSIF l_new_rec.val_05 = 'IL' THEN
17183 IF nvl(l_new_rec.val_07,' ') = 'C' THEN
17184 l_R99_IPbw_L_Contri := l_R99_IPbw_L_Contri-Nvl(To_Number(l_new_rec.val_06),0);
17185 ELSE
17186 l_R99_IPbw_L_Contri := l_R99_IPbw_L_Contri+Nvl(To_Number(l_new_rec.val_06),0);
17187 END IF;
17188 ELSIF l_new_rec.val_05 = 'FB' THEN
17189 IF nvl(l_new_rec.val_07,' ') = 'C' THEN
17190 l_R99_Fpu_B_Contri := l_R99_Fpu_B_Contri-Nvl(To_Number(l_new_rec.val_06),0);
17191 ELSE
17192 l_R99_Fpu_B_Contri := l_R99_Fpu_B_Contri+Nvl(To_Number(l_new_rec.val_06),0);
17193 END IF;
17194 ELSIF l_new_rec.val_05 = 'FO' THEN
17195 IF nvl(l_new_rec.val_07,' ') = 'C' THEN
17196 l_R99_Fpu_C_Contri := l_R99_Fpu_C_Contri-Nvl(To_Number(l_new_rec.val_06),0);
17197 ELSE
17198 l_R99_Fpu_C_Contri := l_R99_Fpu_C_Contri+Nvl(To_Number(l_new_rec.val_06),0);
17199 END IF;
17200 END IF;
17201 END IF;
17202 --End of 99 Processing
17203 END LOOP ; --individual close
17204 END LOOP;--End of val result loop
17205
17206
17207 /*9278285*/ --Loops commented above are opend here so that totals will not affect.
17208 WHILE l_employer_index IS NOT NULL
17209 LOOP
17210 --l_count Keeps track of total number of trailor records added per group
17211 l_count:=0;
17212
17213 l_org_grp_index:=0;
17214
17215 Hr_Utility.set_location('Grp count '||g_org_grp_list_cnt(l_employer_index).org_grp_count ,23);
17216 FOR l_org_count IN 1..g_org_grp_list_cnt(l_employer_index).org_grp_count
17217 LOOP
17218
17219 l_group_org_index:=l_er_index * 1000 + l_org_grp_index;
17220 Hr_Utility.set_location('Current Org Id:---------'||g_employer_child_list(l_group_org_index).gre_org_id, 25);
17221 /*9278285*/
17222
17223 --Get the record count for 20,21 and 22
17224 l_record94_count:=l_record94_count + Get_Trailer_Record_Count(g_rcd_dtls(20).ext_rcd_id
17225 ,g_rcd_dtls(21).ext_rcd_id
17226 ,g_rcd_dtls(22).ext_rcd_id
17227 ,g_employer_child_list(l_group_org_index).gre_org_id);
17228
17229
17230 --Get the record count for 30 and 31
17231 l_record95_count:=l_record95_count + Get_Trailer_Record_Count(g_rcd_dtls(30).ext_rcd_id
17232 ,g_rcd_dtls(31).ext_rcd_id
17233 ,NULL
17234 ,g_employer_child_list(l_group_org_index).gre_org_id);
17235
17236 --Get the record count for 40 and 41
17237 l_record96_count:=l_record96_count + Get_Trailer_Record_Count(g_rcd_dtls(40).ext_rcd_id
17238 ,g_rcd_dtls(41).ext_rcd_id
17239 ,NULL
17240 ,g_employer_child_list(l_group_org_index).gre_org_id);
17241
17242 --Get the record count for 12
17243 l_record97_count:=l_record97_count + Get_Trailer_Record_Count(g_rcd_dtls(12).ext_rcd_id
17244 ,NULL
17245 ,NULL
17246 ,g_employer_child_list(l_group_org_index).gre_org_id);
17247 Hr_Utility.set_location('l_record99_count --'||l_record99_count,20);
17248 Hr_Utility.set_location('g_employer_child_list(l_group_org_index).gre_org_id --'||g_employer_child_list(l_group_org_index).gre_org_id,20);
17249 l_record99_count:=l_record99_count + Get_All_Records_Count(g_rcd_dtls(0).ext_rcd_id
17250 ,g_rcd_dtls(99).ext_rcd_id
17251 ,g_employer_child_list(l_group_org_index).gre_org_id);
17252
17253
17254 l_org_grp_index:=l_org_grp_index+1;
17255 END LOOP; --End of Org Sub grouping
17256
17257 --9278285 Outer Loop Ended here
17258 --next employer index
17259 l_er_index:=l_er_index+1;
17260 l_employer_index:= g_employer_list.NEXT(l_employer_index);
17261 END LOOP; --End of Employers loop
17262 --9278285
17263
17264 --Loop through trailer records
17265 FOR csr_rcd_rec IN csr_ext_rcd_id(c_hide_flag => 'N'
17266 ,c_rcd_type_cd => 'T')-- T-Trailer
17267 LOOP
17268 l_insert_trailer := 1;
17269 OPEN csr_get_trailer_rslt(c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
17270 ,c_ext_dtl_rcd_id => csr_rcd_rec.ext_rcd_id);
17271 FETCH csr_get_trailer_rslt INTO l_trailer_main_rec;
17272 CLOSE csr_get_trailer_rslt;
17273 l_trailer_new_rec := l_trailer_main_rec;
17274
17275 -- Start of trailer record94
17276 IF g_rcd_dtls(94).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
17277
17278
17279 l_trailer_new_rec.val_04 := Trim(To_Char(l_record94_count,'0999999'));--records count
17280 l_trailer_new_rec.val_05 := Trim(To_Char(ABS(l_R94_WA_Contri),'09999999999'));
17281 l_trailer_new_rec.val_06 := Get_Trailer_Amount_Sign(l_R94_WA_Contri); --Amount Code
17282 l_trailer_new_rec.val_07 := Trim(To_Char(ABS(l_R94_UF_Contri),'09999999999'));
17283 l_trailer_new_rec.val_08 := Get_Trailer_Amount_Sign(l_R94_UF_Contri); --Amount Code
17284 l_trailer_new_rec.val_09 :=Trim(To_Char(ABS(l_R94_ZF_Contri),'09999999999'));
17285 l_trailer_new_rec.val_10 := Get_Trailer_Amount_Sign(l_R94_ZF_Contri); --Amount Code
17286 l_trailer_new_rec.val_11 :=Trim(To_Char(ABS(l_R94_SI_Contri),'0999999999999'));
17287 l_trailer_new_rec.val_12 := Get_Trailer_Amount_Sign(l_R94_SI_Contri); --Amount Code
17288
17289 --force an insert of this trailer record only if the count is > 0
17290 IF l_record94_count > 0 THEN
17291 l_insert_trailer := 1;
17292 l_count := l_count + 1;
17293 ELSE
17294 l_insert_trailer := 0;
17295 END IF;
17296
17297 END IF;
17298 -- End of record 94
17299
17300 -- Start of trailer record95
17301 IF g_rcd_dtls(95).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
17302
17303 l_trailer_new_rec.val_04 := Trim(To_Char(l_record95_count,'0999999'));
17304 --l_trailer_new_rec.val_05 := Lpad(Ben_Ext_Fmt.apply_format_mask(To_Number(l_R95_Contri),'9999999999999V99'),10,0);
17305 l_trailer_new_rec.val_05 := Trim(To_Char(ABS(l_R95_Contri),'09999999999'));
17306 l_trailer_new_rec.val_06 := Get_Trailer_Amount_Sign(l_R95_Contri);
17307
17308 --force an insert of this trailer record only if the count is > 0
17309 IF l_record95_count > 0 THEN
17310 l_insert_trailer := 1;
17311 l_count := l_count + 1;
17312 ELSE
17313 l_insert_trailer := 0;
17314 END IF;
17315
17316 END IF;
17317
17318 -- Start of trailer record96
17319 l_record96_rcd_id := g_rcd_dtls(96).ext_rcd_id;
17320 IF l_record96_rcd_id = csr_rcd_rec.ext_rcd_id THEN
17321
17322 l_trailer_new_rec.val_04 := Trim(To_Char(l_record96_count,'0999999'));
17323 l_trailer_new_rec.val_05 := Trim(To_Char(ABS(l_CodeA_R96_Contri),'09999999999'));
17324 l_trailer_new_rec.val_06 := Get_Trailer_Amount_Sign(l_CodeA_R96_Contri);
17325 l_trailer_new_rec.val_07 := Trim(To_Char(ABS(l_CodeD_R96_Contri),'09999999999'));
17326 l_trailer_new_rec.val_08 := Get_Trailer_Amount_Sign(l_CodeD_R96_Contri);
17327
17328 --force an insert of this trailer record only if the count is > 0
17329 IF l_record96_count > 0 THEN
17330 l_insert_trailer := 1;
17331 l_count := l_count + 1;
17332 ELSE
17333 l_insert_trailer := 0;
17334 END IF;
17335
17336 END IF;
17337
17338 -- Start of trailer record97
17339 IF g_rcd_dtls(97).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
17340
17341 l_trailer_new_rec.val_04 := Trim(To_Char(l_record97_count,'0999999'));
17342 l_trailer_new_rec.val_05 := Trim(To_Char(ABS(l_R97_Contri),'09999999999'));
17343 l_trailer_new_rec.val_06 := Get_Trailer_Amount_Sign(l_R97_Contri);
17344
17345 --force an insert of this trailer record only if the count is > 0
17346 IF l_record97_count > 0 THEN
17347 l_insert_trailer := 1;
17348 l_count := l_count + 1;
17349 ELSE
17350 l_insert_trailer := 0;
17351 END IF;
17352
17353 END IF;
17354
17355 -- Start of trailer record99
17356 IF g_rcd_dtls(99).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
17357 --All Records count exclusive record 00 and record 99
17358 l_count := l_count +l_record99_count;
17359
17360 l_trailer_new_rec.val_04 := Trim(To_Char(l_count,'0999999'));
17361 l_trailer_new_rec.val_05 := Trim(To_Char(ABS(l_R99_Yearly_Amount),'09999999999'));
17362 l_trailer_new_rec.val_06 := Get_Trailer_Amount_Sign(l_R99_Yearly_Amount);
17363 l_trailer_new_rec.val_07 := Trim(To_Char(ABS(l_R99_OPNP_Contri),'09999999999'));
17364 l_trailer_new_rec.val_08 := Get_Trailer_Amount_Sign(l_R99_OPNP_Contri);
17365 l_trailer_new_rec.val_09 := Trim(To_Char(ABS(l_R99_IPbw_H_Contri),'09999999999'));
17366 l_trailer_new_rec.val_10 := Get_Trailer_Amount_Sign(l_R99_IPbw_H_Contri);
17367 l_trailer_new_rec.val_11 := Trim(To_Char(ABS(l_R99_IPbw_L_Contri),'09999999999'));
17368 l_trailer_new_rec.val_12 := Get_Trailer_Amount_Sign(l_R99_IPbw_L_Contri);
17369 l_trailer_new_rec.val_17 := Trim(To_Char(ABS(l_R99_Fpu_B_Contri),'09999999999'));
17370 l_trailer_new_rec.val_18 := Get_Trailer_Amount_Sign(l_R99_Fpu_B_Contri);
17371 l_trailer_new_rec.val_19 := Trim(To_Char(ABS(l_R99_Fpu_C_Contri),'09999999999'));
17372 l_trailer_new_rec.val_20 := Get_Trailer_Amount_Sign(l_R99_Fpu_C_Contri);
17373 l_trailer_new_rec.val_13 := Trim(To_Char(0,'09999999999'));
17374 l_trailer_new_rec.val_15 := Trim(To_Char(0,'09999999999'));
17375 l_trailer_new_rec.val_23 := Trim(To_Char(0,'09999999999'));
17376
17377 END IF;
17378 --Updating the current ER Num
17379 l_employer_index:=g_employer_list.FIRST; --9278285
17380
17381 l_trailer_er_num :=Get_Header_EMR_Number(g_employer_list(l_employer_index).gre_org_id,g_conc_prog_details(0).endingdt);
17382
17383 IF IsNumber(l_trailer_er_num) THEN
17384 l_trailer_er_num := Trim(To_Char(Fnd_Number.Canonical_To_Number
17385 (Nvl(l_trailer_er_num,'0'))
17386 ,'0999999'));
17387 END IF;
17388
17389 l_trailer_new_rec.val_02 := l_trailer_er_num;
17390 l_sort_val := Lpad(sort_val,15,0);
17391 l_trailer_new_rec.prmy_sort_val := l_sort_val;
17392 l_trailer_new_rec.object_version_NUMBER := Nvl(l_trailer_new_rec.object_version_NUMBER,0) + 1;
17393 sort_val :=sort_val+1;
17394
17395 --Inserting new ones
17396 IF l_insert_trailer = 1 THEN
17397 Ins_Rslt_Dtl(p_dtl_rec => l_trailer_new_rec);
17398 END IF;
17399 END LOOP;
17400
17401 --9278285 Commented as only one trailer record per file
17402 /* --Intialize to zero
17403 l_R94_WA_Contri := 0;
17404 l_R94_UF_Contri := 0;
17405 l_R94_ZF_Contri := 0;
17406 l_R94_SI_Contri := 0;
17407 l_R95_Contri := 0;
17408 l_CodeD_R96_Contri := 0;
17409 l_CodeA_R96_Contri := 0;
17410 l_R97_Contri := 0;
17411 l_R99_Yearly_Amount:= 0;
17412 l_R99_OPNP_Contri := 0;
17413 l_R99_IPbw_H_Contri:= 0;
17414 l_R99_IPbw_L_Contri:= 0;
17415 l_R99_Fpu_B_Contri := 0;
17416 l_R99_Fpu_C_Contri := 0;
17417 l_record94_count := 0;
17418 l_record95_count := 0;
17419 l_record96_count := 0;
17420 l_record97_count := 0;
17421 l_record99_count := 0;
17422
17423 --next employer index
17424 l_er_index:=l_er_index+1;
17425 l_employer_index:=g_employer_list.NEXT(l_employer_index);
17426 END LOOP; --End of Employers loop
17427 */
17428 --9278285
17429
17430 --fetch the result id to delete the extract result
17431 --trailer records created by benefits
17432 FOR csr_rcd_rec IN csr_ext_rcd_id(c_hide_flag => 'N'
17433 ,c_rcd_type_cd => 'T')-- T-Trailer
17434 LOOP
17435 IF g_rcd_dtls(94).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
17436 l_ext_rslt_dtl_id := l_R94_rslt_dtl_id;
17437 ELSIF g_rcd_dtls(95).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
17438 l_ext_rslt_dtl_id := l_R95_rslt_dtl_id;
17439 ELSIF g_rcd_dtls(96).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
17440 l_ext_rslt_dtl_id := l_R96_rslt_dtl_id;
17441 ELSIF g_rcd_dtls(97).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
17442 l_ext_rslt_dtl_id := l_R97_rslt_dtl_id;
17443 ELSIF g_rcd_dtls(99).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
17444 l_ext_rslt_dtl_id := l_R99_rslt_dtl_id;
17445 END IF;
17446
17447 DELETE
17448 FROM ben_ext_rslt_dtl dtl
17449 WHERE dtl.ext_rslt_id = Ben_Ext_Thread.g_ext_rslt_id
17450 AND dtl.ext_rcd_id = csr_rcd_rec.ext_rcd_id
17451 AND dtl.ext_rslt_dtl_id = l_ext_rslt_dtl_id
17452 AND business_group_id = p_business_group_id;
17453
17454 END LOOP;
17455
17456 FOR csr_rcd_rec IN csr_ext_rcd_id(c_hide_flag => 'N'
17457 ,c_rcd_type_cd => 'H')-- H-Header
17458 LOOP
17459 IF g_rcd_dtls(00).ext_rcd_id = csr_rcd_rec.ext_rcd_id THEN
17460 l_ext_rslt_dtl_id := l_R00_rslt_dtl_id;
17461 END IF;
17462
17463 DELETE
17464 FROM ben_ext_rslt_dtl dtl
17465 WHERE dtl.ext_rslt_id = Ben_Ext_Thread.g_ext_rslt_id
17466 AND dtl.ext_rcd_id = csr_rcd_rec.ext_rcd_id
17467 AND dtl.ext_rslt_dtl_id = l_ext_rslt_dtl_id
17468 AND business_group_id = p_business_group_id;
17469
17470 END LOOP;
17471
17472 --10136155
17473 IF Instr ('a', COMPOSE('a'|| UNISTR('\0301')) ) = 0 THEN
17474
17475 OPEN C_USR_TAB_COL;
17476 FETCH C_USR_TAB_COL INTO l_user_table_id, l_user_column_id;
17477 CLOSE C_USR_TAB_COL;
17478
17479 FOR I in C_SRC_DEST_STR(l_user_column_id, l_user_table_id)
17480 LOOP
17481 l_SOURCE := l_SOURCE||I.ROW_LOW_RANGE_OR_NAME;
17482 l_DEST := l_DEST||I.VALUE;
17483 END LOOP;
17484
17485 IF l_DEST IS NOT NULL THEN
17486
17487 UPDATE ben_ext_rslt_dtl
17488 SET VAL_07 = translate(VAL_07,l_SOURCE,l_DEST),
17489 VAL_08 = translate(VAL_08,l_SOURCE,l_DEST),
17490 VAL_09 = translate(VAL_09,l_SOURCE,l_DEST),
17491 VAL_12 = translate(VAL_12,l_SOURCE,l_DEST),
17492 VAL_13 = translate(VAL_13,l_SOURCE,l_DEST)
17493 WHERE EXT_RSLT_ID = Ben_Ext_Thread.g_ext_rslt_id
17494 AND VAL_01 = '02'
17495 AND BUSINESS_GROUP_ID = p_business_group_id;
17496
17497 UPDATE ben_ext_rslt_dtl
17498 SET VAL_07 = translate(VAL_07,l_SOURCE,l_DEST),
17499 VAL_11 = translate(VAL_11,l_SOURCE,l_DEST),
17500 VAL_13 = translate(VAL_13,l_SOURCE,l_DEST),
17501 VAL_14 = translate(VAL_14,l_SOURCE,l_DEST)
17502 WHERE EXT_RSLT_ID = Ben_Ext_Thread.g_ext_rslt_id
17503 AND VAL_01 = '04'
17504 AND BUSINESS_GROUP_ID = p_business_group_id;
17505
17506 END IF;
17507
17508 --10136155
17509 END IF;
17510
17511 Hr_Utility.set_location('Leaving :'||l_proc_name, 25);
17512 RETURN l_return_value;
17513
17514 EXCEPTION
17515 WHEN Others THEN
17516 Hr_Utility.set_location('..Exception when others raised..', 20);
17517 Hr_Utility.set_location('Leaving :'||l_proc_name, 25);
17518 RETURN -1;
17519 END Sort_Post_Process;
17520
17521 END Pqp_Nl_Pension_Extracts;