[Home] [Help]
PACKAGE BODY: APPS.PQP_GB_PSI_FUNCTIONS
Source
1 PACKAGE BODY PQP_GB_PSI_FUNCTIONS AS
2 -- /* $Header: pqpgbpsifunc.pkb 120.45.12020000.2 2012/07/05 12:12:03 amnaraya ship $ */
3
4 --
5 --
6 -- Exceptions
7 hr_application_error exception;
8 pragma exception_init (hr_application_error, -20001);
9
10
11 g_sth_single VARCHAR2(10); -- For Bug 7010282
12
13
14 FUNCTION get_time
15 RETURN NUMBER
16 IS
17
18 t NUMBER;
19
20 BEGIN
21
22 SELECT TO_CHAR(SYSDATE,'SSSSS') INTO t FROM dual;
23
24 return t;
25
26 END get_time;
27
28
29 -- ----------------------------------------------------------------------------
30 -- |--------------------------------< check_debug >---------------------------------|
31 -- ----------------------------------------------------------------------------
32
33 FUNCTION check_debug
34 (p_business_group_id IN VARCHAR2 -- context
35 )
36 RETURN boolean
37 IS
38
39 l_proc_name VARCHAR2(61):=
40 g_proc_name||'check_debug';
41
42 l_config_value pqp_utilities.t_config_values;
43 l_return VARCHAR2(20);
44 l_debug_enable_mode fnd_concurrent_requests.argument3%type;
45 l_process_parameters csr_debug_enable_mode%rowtype;
46 l_parent_process_parameters csr_debug_enable_mode%rowtype;
47
48 --
49 BEGIN
50
51 --
52
53 IF g_debug_flag IS NULL
54 THEN
55 --
56 OPEN csr_debug_enable_mode;
57 FETCH csr_debug_enable_mode INTO l_process_parameters;
58
59 IF csr_debug_enable_mode%NOTFOUND
60 THEN
61
62 OPEN csr_debug_enable_mode_parent;
63 FETCH csr_debug_enable_mode_parent INTO l_parent_process_parameters;
64 IF csr_debug_enable_mode_parent%NOTFOUND
65 THEN
66
67 g_debug := FALSE;
68 ELSE
69 IF l_parent_process_parameters.argument3 = '3DBG'
70 THEN
71
72 g_debug := TRUE;
73 g_debug_flag := 'Y';
74
75 ELSE
76
77 g_debug := FALSE;
78 g_debug_flag := 'N';
79 END IF;
80 END IF;
81 CLOSE csr_debug_enable_mode_parent;
82
83 ELSE -- IF csr_debug_enable_mode%NOTFOUND
84 IF l_process_parameters.argument3 = '3DBG'
85 THEN
86 g_debug := TRUE;
87 g_debug_flag := 'Y';
88
89 ELSE
90 g_debug := FALSE;
91 g_debug_flag := 'N';
92
93 END IF;
94 -- also, save the params for future use
95 g_extract_type := l_process_parameters.argument5;
96 g_dfn_name := l_process_parameters.argument6;
97
98 END IF;
99 CLOSE csr_debug_enable_mode;
100
101 IF g_debug = TRUE THEN
102 -- fetch configuration value for paypoint
103 -- debug('Fetching configuration value for debug flag ...', 20);
104 pqp_utilities.get_config_type_values
105 ( p_configuration_type => 'PQP_GB_PENSERVER_DEFINITION'
106 ,p_business_group_id => p_business_group_id
107 ,p_legislation_code => NULL
108 ,p_tab_config_values => l_config_value
109 );
110
111 IF l_config_value.COUNT > 0 -- config value found
112 THEN
113 g_debug_flag := l_config_value(l_config_value.FIRST).pcv_information1;
114 --
115 IF g_debug_flag = 'Y' THEN
116 g_debug := TRUE;
117 ELSE
118 g_debug := FALSE;
119 END IF;
120 --
121 ELSE
122 g_debug_flag := 'N';
123 g_debug := FALSE;
124 END IF;
125 END IF;
126 --
127 END IF;
128
129 return g_debug;
130
131 END check_debug;
132
133
134 -- ----------------------------------------------------------------------------
135 -- |--------------------------------< debug >---------------------------------|
136 -- ----------------------------------------------------------------------------
137
138 PROCEDURE DEBUG (p_trace_message IN VARCHAR2, p_trace_location IN NUMBER)
139 IS
140
141 --
142 BEGIN
143 --
144
145 pqp_utilities.DEBUG (
146 p_trace_message => p_trace_message
147 ,p_trace_location => p_trace_location
148 );
149 --
150 END DEBUG;
151
152
153 -- This procedure is used for debug purposes
154 -- debug_enter checks the debug flag and sets the trace on/off
155 --
156 -- ----------------------------------------------------------------------------
157 -- |----------------------------< debug_enter >-------------------------------|
158 -- ----------------------------------------------------------------------------
159
160 PROCEDURE debug_enter (p_proc_name IN VARCHAR2, p_trace_on IN VARCHAR2)
161 IS
162 BEGIN
163 --
164 IF g_debug THEN
165 IF pqp_utilities.g_nested_level = 0 THEN
166 hr_utility.trace_on(NULL, 'REQID'); -- Pipe name REQIDnnnnn
167 END IF;
168 pqp_utilities.debug_enter (
169 p_proc_name => p_proc_name
170 ,p_trace_on => p_trace_on
171 );
172 END IF;
173 --
174
175 END debug_enter;
176
177
178 -- This procedure is used for debug purposes
179 --
180 -- ----------------------------------------------------------------------------
181 -- |----------------------------< debug_exit >--------------------------------|
182 -- ----------------------------------------------------------------------------
183
184 PROCEDURE debug_exit (p_proc_name IN VARCHAR2, p_trace_off IN VARCHAR2)
185 IS
186 BEGIN
187 --
188 IF g_debug THEN
189 pqp_utilities.debug_exit (
190 p_proc_name => p_proc_name
191 ,p_trace_off => p_trace_off
192 );
193
194 IF pqp_utilities.g_nested_level = 0 THEN
195 hr_utility.trace_off;
196 END IF;
197 END IF;
198 --
199 END debug_exit;
200
201
202 -- This procedure is used for debug purposes
203 --
204 -- ----------------------------------------------------------------------------
205 -- |----------------------------< debug_others >------------------------------|
206 -- ----------------------------------------------------------------------------
207
208 PROCEDURE debug_others (p_proc_name IN VARCHAR2, p_proc_step IN NUMBER)
209 IS
210 BEGIN
211 --
212 pqp_utilities.debug_others (
213 p_proc_name => p_proc_name
214 ,p_proc_step => p_proc_step
215 );
216 --
217 END debug_others;
218
219 /* For bug 8359083
220 -- ----------------------------------------------------------------------------
221 -- |----------------------------< get_penserver_date >-------------------------|
222 -- Description : For each assignment fetch the least effective date
223 -- ----------------------------------------------------------------------------
224
225 FUNCTION get_penserver_date
226 (p_assignment_id IN NUMBER
227 ,p_business_group_id IN NUMBER
228 ,p_lapp_date IN DATE
229 ,p_end_date IN DATE
230 ) RETURN date
231 IS
232
233 l_penserver_date date;
234
235 -- This cursor will fetch the minimum efective on which a penserver event has
236 -- occured for the employee having the creation_date in the current period.
237 cursor csr_pen_eff_date
238 is select min(ppe.effective_date)
239 from pay_process_events ppe
240 where trunc(ppe.creation_date) between p_lapp_date and p_end_date
241 and ppe.assignment_id = p_assignment_id
242 and ppe.business_group_id = p_business_group_id
243 and ppe.effective_date >= ben_ext_thread.g_effective_start_date
244 and exists (select pde.event_group_id
245 from pay_datetracked_events pde,
246 pay_event_updates peu
247 where pde.event_group_id in (select becv.val_1
248 from ben_ext_crit_val becv,
249 ben_ext_crit_typ bect,
250 ben_ext_dfn bed
251 where becv.ext_crit_typ_id = bect.ext_crit_typ_id
252 and bect.ext_crit_prfl_id = bed.ext_crit_prfl_id
253 and bed.ext_dfn_id = ben_ext_thread.g_ext_dfn_id
254 and bect.crit_typ_cd = 'CPE')
255 and ppe.event_update_id = peu.event_update_id
256 and peu.dated_table_id = pde.dated_table_id);
257
258
259 BEGIN
260
261 open csr_pen_eff_date;
262 fetch csr_pen_eff_date into l_penserver_date;
263 if l_penserver_date is null
264 then
265 l_penserver_date := p_lapp_date;
266 end if;
267 close csr_pen_eff_date;
268
269
270 if l_penserver_date > p_lapp_date
271 then
272 l_penserver_date := p_lapp_date;
273 end if;
274
275 l_penserver_date := l_penserver_date - 1;
276
277 debug( 'p_lapp_date :' ||p_lapp_date,20);
278 debug( 'l_penserver_date :' ||l_penserver_date,20);
279
280 RETURN l_penserver_date;
281
282 END; */
283
284 -- ----------------------------------------------------------------------------
285 -- |------------------------< GET_CURRENT_EXTRACT_PERSON >---------------------|
286 -- ----------------------------------------------------------------------------
287
288 -- GET_CURRENT_EXTRACT_PERSON
289 --
290 -- Returns the ext_rslt_id for the current extract process
291 -- if one is running, else returns -1
292 --
293 FUNCTION get_current_extract_person
294 (p_assignment_id NUMBER -- context
295 )
296 RETURN NUMBER
297 IS
298 l_person_id NUMBER;
299 BEGIN
300 SELECT person_id
301 INTO l_person_id
302 FROM per_all_assignments_f
303 WHERE assignment_id = p_assignment_id
304 AND ROWNUM < 2;
305 RETURN l_person_id;
306 EXCEPTION
307 WHEN NO_DATA_FOUND THEN
308 RETURN NULL;
309 END;
310 --
311
312 -- ----------------------------------------------------------------------------
313 -- |------------------------< GET_CURRENT_EXTRACT_RESULT >-----------------------|
314 -- ----------------------------------------------------------------------------
315
316 --
317 -- GET_CURRENT_EXTRACT_RESULT
318 --
319 -- Returns the person id associated with the given assignment.
320 -- If none is found,it returns NULL. This may arise if the
321 -- user calls this from a header/trailer record, where
322 -- a dummy context of assignment_id = -1 is passed.
323 --
324 --
325 FUNCTION get_current_extract_result
326 RETURN NUMBER
327 IS
328 e_extract_process_not_running EXCEPTION;
329 PRAGMA EXCEPTION_INIT(e_extract_process_not_running,-8002);
330 l_ext_rslt_id NUMBER;
331 --
332 BEGIN
333 --
334 -- SELECT ben_ext_rslt_s.CURRVAL
335 -- INTO l_ext_rslt_id
336 -- FROM DUAL;
337
338 l_ext_rslt_id := ben_ext_thread.g_ext_rslt_id;
339
340 RETURN l_ext_rslt_id;
341 --
342 EXCEPTION
343 WHEN e_extract_process_not_running THEN
344 RETURN -1;
345 END;
346
347
348
349 -- ----------------------------------------------------------------------------
350 -- |---------------------------< is_alphanumeric >--------------------|
351 -- ----------------------------------------------------------------------------
352 function is_alphanumeric
353 (p_string in varchar2
354 ) Return Boolean is
355 --
356 l_proc_name varchar2(72) := g_proc_name||'is_alphanumeric';
357
358 begin
359 --
360 debug_enter(l_proc_name);
361
362 IF
363 TRIM(TRANSLATE(p_string,'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz '
364 ,' _'))
365 IS NULL
366
367 THEN
368 debug('true');
369 debug_exit(l_proc_name);
370 return true;
371 ELSE
372 debug('false');
373 debug_exit(l_proc_name);
374 return false;
375 END IF;
376 EXCEPTION
377 WHEN others THEN
378 IF SQLCODE <> hr_utility.hr_error_number
379 THEN
380 debug_others (l_proc_name, 10);
381 IF g_debug
382 THEN
383 DEBUG ( 'Leaving: '
384 || l_proc_name, -999);
385 END IF;
386 fnd_message.raise_error;
387 ELSE
388 RAISE;
389 END IF;
390
391 --
392 end is_alphanumeric;
393
394 -- ----------------------------------------------------------------------------
395 -- |---------------------------< is_alphanumeric_space_allowed >--------------------|
396 -- ----------------------------------------------------------------------------
397 function is_alphanumeric_space_allowed
398 (p_string in varchar2
399 ) Return Boolean is
400 --
401 l_proc_name varchar2(72) := g_proc_name||'is_alphanumeric';
402
403 begin
404 --
405 debug_enter(l_proc_name);
406
407 IF
408 TRIM(TRANSLATE(p_string,'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz '
409 ,' '))
410 IS NULL
411
412 THEN
413 debug('true');
414 debug_exit(l_proc_name);
415 return true;
416 ELSE
417 debug('false');
418 debug_exit(l_proc_name);
419 return false;
420 END IF;
421 EXCEPTION
422 WHEN others THEN
423 IF SQLCODE <> hr_utility.hr_error_number
424 THEN
425 debug_others (l_proc_name, 10);
426 IF g_debug
427 THEN
428 DEBUG ( 'Leaving: '
429 || l_proc_name, -999);
430 END IF;
431 fnd_message.raise_error;
432 ELSE
433 RAISE;
434 END IF;
435
436 --
437 end is_alphanumeric_space_allowed;
438 -- ----------------------------------------------------------------------------
439 -- |---------------------------< is_numeric >--------------------|
440 -- ----------------------------------------------------------------------------
441 function is_numeric
442 (p_string in varchar2
443 ) Return Boolean is
444 --
445 l_proc_name varchar2(72) := g_proc_name||'is_numeric';
446
447 begin
448 --
449 debug_enter(l_proc_name);
450
451 IF
452 TRIM(TRANSLATE(p_string,'0123456789'
453 ,' '))
454 IS NULL
455
456 THEN
457 debug('true');
458 debug_exit(l_proc_name);
459 return true;
460 ELSE
461 debug('false');
462 debug_exit(l_proc_name);
463 return false;
464 END IF;
465 EXCEPTION
466 WHEN others THEN
467 IF SQLCODE <> hr_utility.hr_error_number
468 THEN
469 debug_others (l_proc_name, 10);
470 IF g_debug
471 THEN
472 DEBUG ( 'Leaving: '
473 || l_proc_name, -999);
474 END IF;
475 fnd_message.raise_error;
476 ELSE
477 RAISE;
478 END IF;
479
480 --
481 end is_numeric;
482
483
484
485 -- =============================================================================
486 -- This procedure gets the bonus codes information from pay_element_type_extra_info
487 -- if bonus code is alphanumeric then information is passed to the output file
488 -- else to the log file
489 -- =============================================================================
490 PROCEDURE get_bonus_codes
491 (p_business_group_id IN VARCHAR2
492 ,p_from_date IN DATE
493 ,p_to_date IN DATE) IS
494
495 l_column_separator VARCHAR2(10) := ' , ';
496 l_pay_point VARCHAR2(10);
497 l_filler1 CHAR(16):=' ';
498 l_filler2 CHAR(86):=' ';
499 l_bonus_codes t_bonus_codes;
500 l_bonus_index NUMBER:=0;
501 l_alphanum_code VARCHAR2(200);
502 l_proc_name VARCHAR2(200):= g_proc_name || 'get_bonus_codes';
503
504 BEGIN
505
506 debug_enter(l_proc_name);
507
508 -- get paypoint value for business group id passed
509 l_pay_point := paypoint(p_business_group_id);
510
511 debug ('l_pay_point:'||l_pay_point);
512
513
514 IF l_pay_point = ''
515 or
516 NOT PQP_GB_PSI_FUNCTIONS.is_alphanumeric(p_string=> l_pay_point)
517 THEN
518 -- Raise error as Paypoint is unknown(E)
519 hr_utility.set_message(805, 'BEN_94453_INV_PAYPOINT');
520 fnd_file.put_line(fnd_file.LOG
521 , RPAD('Error', 30) || ': ' || hr_utility.get_message);
522 fnd_file.put_line(fnd_file.LOG, ' ');
523 END IF;
524
525
526 -- Pass context as PQP_GB_PENSERV_BONUS_INFO to get the bonus codes information
527 FOR l_bonus_rec IN csr_get_extra_bonus_info
528 (p_from_date => p_from_date
529 ,p_to_date => p_to_date)
530 LOOP
531
532 debug ('l_bonus_rec.code:'||l_bonus_rec.code);
533 -- set error code to null
534 l_alphanum_code := NULL;
535
536 IF l_bonus_rec.code IS NULL THEN
537 l_alphanum_code := 'NULL';
538 ELSIF NOT PQP_GB_PSI_FUNCTIONS.is_alphanumeric(p_string=> l_bonus_rec.code) THEN
539 -- raise error against this element/code
540 l_alphanum_code := l_bonus_rec.code;
541 END IF;
542
543 IF l_alphanum_code IS NOT NULL THEN
544 --
545 fnd_file.put_line(fnd_file.LOG,
546 RPAD(nvl(l_pay_point,' '),6,' ') ||
547 RPAD(nvl(l_bonus_rec.code,' '),4,' ') ||
548 RPAD(nvl(l_bonus_rec.description,' '),34,' ') ||
549 RPAD(nvl(l_bonus_rec.pension_flag,' '),1,' ') ||
550 RPAD(nvl(l_bonus_rec.industrial_flag,' '),1,' ') ||
551 RPAD(l_filler1,16,' ') ||
552 RPAD(nvl(l_bonus_rec.basic_pay_reckonable,' '),1,' ') ||
553 RPAD(nvl(l_bonus_rec.pre_75_reckonable,' '),1,' ') ||
554 RPAD(l_filler2,86,' '));
555 --
556 -- Raise error as Special characters are not permitted in the allowance code(E)
557 hr_utility.set_message(805, 'BEN_94458_PEN_SPCL_CHAR_CHK');
558 fnd_file.put_line(fnd_file.LOG
559 , RPAD('Error', 30) || ': ' || hr_utility.get_message);
560
561 fnd_file.put_line(fnd_file.log, 'INTERFACE : Bonus');
562
563 fnd_file.put_line(fnd_file.log, 'ELEMENT : '|| l_bonus_rec.element_name);
564
565 fnd_file.put_line(fnd_file.log, 'BONUS CODE : '|| l_alphanum_code);
566 fnd_file.put_line(fnd_file.log, ' ');
567 fnd_file.put_line(fnd_file.log, ' ');
568 --
569
570 --
571 ELSE
572 --
573 -- increase the counter
574 l_bonus_index := l_bonus_index +1;
575 l_bonus_codes(l_bonus_index).pay_point :=RPAD(nvl(l_pay_point,' '),6,' ');
576 l_bonus_codes(l_bonus_index).bonus_code :=RPAD(nvl(l_bonus_rec.code,' '),4,' ');
577 l_bonus_codes(l_bonus_index).bonus_descr :=RPAD(nvl(l_bonus_rec.description,' '),34,' ');
578 l_bonus_codes(l_bonus_index).pension_flag :=RPAD(nvl(l_bonus_rec.pension_flag,' '),1,' ');
579 l_bonus_codes(l_bonus_index).industrial_flag :=RPAD(nvl(l_bonus_rec.industrial_flag,' '),1,' ');
580 l_bonus_codes(l_bonus_index).filler1 :=RPAD(l_filler1,16,' ');
581 l_bonus_codes(l_bonus_index).basic_pay_reckonable :=RPAD(nvl(l_bonus_rec.basic_pay_reckonable,' '),1,' ');
582 l_bonus_codes(l_bonus_index).pre_75_reckonable :=RPAD(nvl(l_bonus_rec.pre_75_reckonable,' '),1,' ');
583 l_bonus_codes(l_bonus_index).filler2 :=RPAD(l_filler2,86,' ');
584 --
585 END IF;
586
587 END LOOP;
588
589 IF l_bonus_codes.COUNT > 0
590 THEN
591 -- insert correct bonus information into output file
592 FOR l_bonus_index IN l_bonus_codes.FIRST..l_bonus_codes.LAST
593 LOOP
594
595 fnd_file.put_line(fnd_file.output,
596 l_bonus_codes(l_bonus_index).pay_point ||
597 l_bonus_codes(l_bonus_index).bonus_code ||
598 l_bonus_codes(l_bonus_index).bonus_descr ||
599 l_bonus_codes(l_bonus_index).pension_flag ||
600 l_bonus_codes(l_bonus_index).industrial_flag ||
601 l_bonus_codes(l_bonus_index).filler1 ||
602 l_bonus_codes(l_bonus_index).basic_pay_reckonable ||
603 l_bonus_codes(l_bonus_index).pre_75_reckonable ||
604 l_bonus_codes(l_bonus_index).filler2 );
605
606 END LOOP;
607 END IF;
608
609 debug_exit(l_proc_name);
610
611 EXCEPTION
612 WHEN OTHERS THEN
613 debug_exit(' Error in '||l_proc_name);
614 RAISE;
615
616 END get_bonus_codes;
617
618 -- =============================================================================
619 -- This procedure gets allowance code information from pay_element_type_extra_info
620 -- if allowance code is alphanumeric then information is passed to the output file
621 -- else to the log file.
622 -- =============================================================================
623 PROCEDURE get_allowance_codes
624 (p_business_group_id IN VARCHAR2
625 ,p_from_date IN DATE
626 ,p_to_date IN DATE) IS
627
628 l_column_separator VARCHAR2(10) := ' , ';
629 l_pay_point VARCHAR2(10);
630 l_filler1 CHAR(16) :=' ';
631 l_filler2 CHAR(79) :=' ';
632 l_allowance_codes t_allowance_codes;
633 l_allowance_index NUMBER :=0;
634 l_alphanum_code VARCHAR2(200);
635 l_proc_name VARCHAR2(200):= g_proc_name || 'get_allowance_codes';
636
637 BEGIN
638
639 debug_enter(l_proc_name);
640 debug('Entering get_allowance_codes');
641
642 -- get paypoint value for business group id passed
643 l_pay_point := paypoint(p_business_group_id);
644 debug ('l_pay_point:'||l_pay_point);
645
646 IF l_pay_point = ''
647 or
648 NOT PQP_GB_PSI_FUNCTIONS.is_alphanumeric(p_string=> l_pay_point)
649 THEN
650 -- Raise error as Paypoint is unknown(E)
651 hr_utility.set_message(805, 'BEN_94453_INV_PAYPOINT');
652 fnd_file.put_line(fnd_file.LOG
653 , RPAD('Error', 30) || ': ' || hr_utility.get_message);
654 fnd_file.put_line(fnd_file.LOG, ' ');
655 END IF;
656 --Pass context as PQP_GB_PENSERV_ALLOWANCE_INFO to get the allowance codes information
657 FOR l_allowance_rec IN csr_get_extra_allow_info
658 (p_from_date => p_from_date
659 ,p_to_date => p_to_date)
660 LOOP
661
662 debug ('l_allowance_rec.code:'||l_allowance_rec.code);
663 -- set error code to null
664 l_alphanum_code := NULL;
665
666 IF l_allowance_rec.code IS NULL THEN
667 l_alphanum_code := 'NULL';
668 ELSIF NOT PQP_GB_PSI_FUNCTIONS.is_alphanumeric(p_string=> l_allowance_rec.code) THEN
669 -- raise error against this element/code
670 l_alphanum_code := l_allowance_rec.code;
671 END IF;
672
673 IF l_alphanum_code IS NOT NULL THEN
674 --
675 fnd_file.put_line(fnd_file.LOG,
676 RPAD(nvl(l_pay_point,' '),6,' ') ||
677 RPAD(nvl(l_allowance_rec.code,' '),10,' ') ||
678 RPAD(nvl(l_allowance_rec.description,' '),34,' ') ||
679 RPAD(nvl(l_allowance_rec.pension_flag,' '),1,' ') ||
680 RPAD(nvl(l_allowance_rec.industrial_flag,' '),1,' ') ||
681 RPAD(nvl(l_allowance_rec.spread_bonus_flag,' '),1,' ') ||
682 RPAD(l_filler1,16,' ') ||
683 RPAD(nvl(l_allowance_rec.basic_pay_reckonable,' '),1,' ') ||
684 RPAD(nvl(l_allowance_rec.pre_75_reckonable,' '),1,' ') ||
685 RPAD(l_filler2,79,' '));
686 --
687 -- Raise error as Special characters are not permitted in the allowance code(E)
688 hr_utility.set_message(805, 'BEN_94458_PEN_SPCL_CHAR_CHK');
689 fnd_file.put_line(fnd_file.LOG
690 , RPAD('Error', 30) || ': ' || hr_utility.get_message);
691
692 fnd_file.put_line(fnd_file.log, 'INTERFACE : Allowance');
693
694 fnd_file.put_line(fnd_file.log, 'ELEMENT : '|| l_allowance_rec.element_name);
695
696 fnd_file.put_line(fnd_file.log, 'ALLOWANCE CODE : '|| l_alphanum_code);
697 fnd_file.put_line(fnd_file.log, ' ');
698 fnd_file.put_line(fnd_file.log, ' ');
699 --
700 ELSE
701 --
702 -- increase the counter
703 l_allowance_index := l_allowance_index + 1;
704 l_allowance_codes(l_allowance_index).pay_point :=RPAD(nvl(l_pay_point,' '),6,' ');
705 l_allowance_codes(l_allowance_index).allowance_code :=RPAD(nvl(l_allowance_rec.code,' '),10,' ');
706 l_allowance_codes(l_allowance_index).allowance_descr :=RPAD(nvl(l_allowance_rec.description,' '),34,' ');
707 l_allowance_codes(l_allowance_index).pension_flag :=RPAD(nvl(l_allowance_rec.pension_flag,' '),1,' ');
708 l_allowance_codes(l_allowance_index).industrial_flag :=RPAD(nvl(l_allowance_rec.industrial_flag,' '),1,' ');
709 l_allowance_codes(l_allowance_index).spread_bonus_flag :=RPAD(nvl(l_allowance_rec.spread_bonus_flag,' '),1,' ');
710 l_allowance_codes(l_allowance_index).filler1 :=RPAD(l_filler1,16,' ');
711 l_allowance_codes(l_allowance_index).basic_pay_reckonable:=RPAD(nvl(l_allowance_rec.basic_pay_reckonable,' '),1,' ');
712 l_allowance_codes(l_allowance_index).pre_75_reckonable :=RPAD(nvl(l_allowance_rec.pre_75_reckonable,' '),1,' ');
713 l_allowance_codes(l_allowance_index).filler2 :=RPAD(l_filler2,79,' ');
714 --
715 END IF;
716
717 END LOOP;
718 debug ('Before writing into file');
719
720 IF l_allowance_codes.COUNT > 0
721 THEN
722 -- insert correct allowance information into output file
723 FOR l_allowance_index IN l_allowance_codes.FIRST..l_allowance_codes.LAST
724 LOOP
725
726 fnd_file.put_line(fnd_file.output,
727 l_allowance_codes(l_allowance_index).pay_point ||
728 l_allowance_codes(l_allowance_index).allowance_code ||
729 l_allowance_codes(l_allowance_index).allowance_descr ||
730 l_allowance_codes(l_allowance_index).pension_flag ||
731 l_allowance_codes(l_allowance_index).industrial_flag ||
732 l_allowance_codes(l_allowance_index).spread_bonus_flag ||
733 l_allowance_codes(l_allowance_index).filler1 ||
734 l_allowance_codes(l_allowance_index).basic_pay_reckonable ||
735 l_allowance_codes(l_allowance_index).pre_75_reckonable ||
736 l_allowance_codes(l_allowance_index).filler2 );
737
738 END LOOP;
739 END IF;
740 debug_exit(l_proc_name);
741
742 EXCEPTION
743 WHEN OTHERS THEN
744 debug_exit(' Error in '||l_proc_name);
745 RAISE;
746 END get_allowance_codes;
747
748
749
750 -- Function returns extract result id for a given request id
751 --
752 -- ----------------------------------------------------------------------------
753 -- |----------------------------< get_ext_rslt_frm_req >----------------------|
754 -- ----------------------------------------------------------------------------
755
756 FUNCTION get_ext_rslt_frm_req (p_request_id IN NUMBER
757 ,p_business_group_id IN NUMBER
758 )
759 RETURN NUMBER IS
760 --
761 CURSOR csr_get_ext_rslt_id
762 IS
763 SELECT ext_rslt_id
764 FROM ben_ext_rslt
765 WHERE request_id = p_request_id
766 AND business_group_id = p_business_group_id;
767
768 l_ext_rslt_id NUMBER;
769 l_proc_name VARCHAR2 (80) := g_proc_name
770 || 'get_ext_rslt_frm_req';
771 l_proc_step NUMBER;
772
773 --
774 BEGIN
775 --
776 IF g_debug
777 THEN
778 l_proc_step := 10;
779 DEBUG ( 'Entering: '
780 || l_proc_name, l_proc_step);
781 END IF;
782
783 OPEN csr_get_ext_rslt_id;
784 FETCH csr_get_ext_rslt_id INTO l_ext_rslt_id;
785
786 IF csr_get_ext_rslt_id%NOTFOUND THEN
787 fnd_message.set_name ('BEN', 'BEN_91873_EXT_NOT_FOUND');
788 fnd_file.put_line(fnd_file.log, 'Error: '
789 || fnd_message.get);
790 fnd_file.put_line(fnd_file.log, ' ');
791 CLOSE csr_get_ext_rslt_id;
792 fnd_message.raise_error;
793 END IF; -- End if of row not found check ...
794 CLOSE csr_get_ext_rslt_id;
795
796 IF g_debug
797 THEN
798 DEBUG ( 'Extract Result ID: '
799 || TO_CHAR(l_ext_rslt_id));
800 l_proc_step := 20;
801 DEBUG ( 'Leaving: '
802 || l_proc_name, l_proc_step);
803 END IF;
804
805 RETURN l_ext_rslt_id;
806
807 END get_ext_rslt_frm_req;
808 --
809
810
811
812 -- =============================================================================
813 -- Build_Metadata_Ext_Names
814 -- =============================================================================
815
816 PROCEDURE Build_Metadata_Ext_Names IS
817 l_proc_name VARCHAR2(120):= g_proc_name||'Build_Metadata_Ext_Names';
818 BEGIN
819 debug_enter(l_proc_name);
820
821 /*
822 1 BASIC DATA -- DONE
823 2 ADDRESS -- DONE
824 3 SERVICE HISTORY -- DONE
825 4 PART-TIME HOURS HISTORY
826 5 SHORT-TIME HOURS HISTORY - Single Records
827 6 SHORT-TIME HOURS HISTORY - Accumulated Records
828 7 SALARY HISTORY -- DONE
829 8 ALLOWANCE HISTORY
830 9 BONUS HISTORY
831 10 EARNINGS HISTORY -- DONE
832 11 WPS CONTRIBUTION RATE HISTORY
833 */
834
835 ---define Penserver Cutover extract names and codes
836 g_cutover_ext_names(1).extract_name :='PQP GB PenServer Cutover Interface - Basic Data';
837 g_cutover_ext_names(1).extract_code :='BDI';
838 g_cutover_ext_names(2).extract_name :='PQP GB PenServer Cutover Interface - Address';
839 g_cutover_ext_names(2).extract_code :='ADI';
840 g_cutover_ext_names(3).extract_name :='PQP GB PenServer Cutover Interface - Service History';
841 g_cutover_ext_names(3).extract_code :='SVI';
842 g_cutover_ext_names(4).extract_name :='PQP GB PenServer Cutover Interface - Part Time Hours History';
843 g_cutover_ext_names(4).extract_code :='PTH';
844 g_cutover_ext_names(5).extract_name :=' ';
845 g_cutover_ext_names(5).extract_code :=' ';
846 g_cutover_ext_names(6).extract_name :=' ';
847 g_cutover_ext_names(6).extract_code :=' ';
848 g_cutover_ext_names(7).extract_name :='PQP GB PenServer Cutover Interface - Salary History';
849 g_cutover_ext_names(7).extract_code :='SDI';
850 g_cutover_ext_names(8).extract_name :='PQP GB PenServer Cutover Interface - Allowance History';
851 g_cutover_ext_names(8).extract_code :='AHI';
852 g_cutover_ext_names(9).extract_name :='PQP GB PenServer Cutover Interface - Bonus History';
853 g_cutover_ext_names(9).extract_code :='BHI';
854 g_cutover_ext_names(10).extract_name :='PQP GB PenServer Standard Interface - Earnings History';
855 g_cutover_ext_names(10).extract_code :='EDI';
856 g_cutover_ext_names(11).extract_name :='PQP GB PenServer Cutover Interface - WPS History';
857 g_cutover_ext_names(11).extract_code :='WPS';
858
859
860 ---define Penserver Periodic extract names and codes
861 g_periodic_ext_names(1).extract_name :='PQP GB PenServer Periodic Changes Interface - Basic Data';
862 g_periodic_ext_names(1).extract_code :='BDI';
863 g_periodic_ext_names(2).extract_name :='PQP GB PenServer Periodic Changes Interface - Address';
864 g_periodic_ext_names(2).extract_code :='ADI';
865 g_periodic_ext_names(3).extract_name :='PQP GB PenServer Periodic Changes Interface - Service History';
866 g_periodic_ext_names(3).extract_code :='SVI';
867 g_periodic_ext_names(4).extract_name :='PQP GB PenServer Periodic Changes Interface - Part Time Hours History';
868 g_periodic_ext_names(4).extract_code :='PTH';
869 -- For Bug 7010282
870 IF g_sth_single = 'EXCLUDE'
871 THEN
872 g_periodic_ext_names(5).extract_name :=' ';
873 g_periodic_ext_names(5).extract_code :=' ';
874 ELSE
875 g_periodic_ext_names(5).extract_name :='PQP GB PenServer Periodic Changes Interface - Short Time Hours History (Single Records)';
876 g_periodic_ext_names(5).extract_code :='STS';
877 END IF;
878 g_periodic_ext_names(6).extract_name :='PQP GB PenServer Periodic Changes Interface - Short Time Hours History (Accumulated Records)';
879 g_periodic_ext_names(6).extract_code :='STA';
880 g_periodic_ext_names(7).extract_name :='PQP GB PenServer Periodic Changes Interface - Salary History';
881 g_periodic_ext_names(7).extract_code :='SDI';
882 g_periodic_ext_names(8).extract_name :='PQP GB PenServer Periodic Changes Interface - Allowance History';
883 g_periodic_ext_names(8).extract_code :='AHI';
884 g_periodic_ext_names(9).extract_name :='PQP GB PenServer Periodic Changes Interface - Bonus History';
885 g_periodic_ext_names(9).extract_code :='BHI';
886 g_periodic_ext_names(10).extract_name :='PQP GB PenServer Standard Interface - Earnings History';
887 g_periodic_ext_names(10).extract_code :='EDI';
888 g_periodic_ext_names(11).extract_name :='PQP GB PenServer Periodic Interface - WPS History';
889 g_periodic_ext_names(11).extract_code :='WPS';
890
891
892 ---define Penserver Codes extract names
893 g_code_ext_names(1).extract_name :='PQP GB PenServer Standard Interface - Grade Codes';
894 g_code_ext_names(1).extract_code :='GCI';
895 g_code_ext_names(2).extract_name :='PQP GB PenServer Standard Interface - Location Codes';
896 g_code_ext_names(2).extract_code :='LCI';
897 g_code_ext_names(3).extract_name :='PQP GB PenServer Standard Interface- Allowance Codes';
898 g_code_ext_names(3).extract_code :='ACI';
899 g_code_ext_names(4).extract_name :='PQP GB PenServer Standard Interface- Bonus Codes';
900 g_code_ext_names(4).extract_code :='BCI';
901
902
903 debug_exit(l_proc_name);
904
905 END Build_Metadata_Ext_Names;
906
907
908 -- =============================================================================
909 -- ~ PQP_Penserver_Extract: This is called by the conc. program
910 -- ~ to run cutover Penserver extracts and is basically a
911 -- ~ wrapper around the benefits conc. program Extract Process.
912 -- =============================================================================
913
914 PROCEDURE PQP_Penserver_Extract
915 (errbuf OUT NOCOPY VARCHAR2
916 ,retcode OUT NOCOPY VARCHAR2
917 ,p_benefit_action_id IN NUMBER
918 ,p_business_group_id IN NUMBER
919 ,p_execution_mode IN VARCHAR2 -- 1GEN/3DBG/2SET/1REP
920 ,p_execution_mode_type IN VARCHAR2
921 ,p_extract_type IN VARCHAR2 -- 3CUT/1PED/2CODE
922 ,p_dfn_name IN VARCHAR2 -- 1ALL/BDI/ADI/SDI/EDI/ACI/BCI/GCI/LCI
923 ,p_start_date IN VARCHAR2
924 ,p_eff_date IN VARCHAR2
925 ,p_submit_request_y_n IN VARCHAR2 default 'N'
926 ,p_concurrent_request_id IN NUMBER DEFAULT NULL
927 ,p_year_end_close IN VARCHAR2 default 'N' -- /* Nuvos Changes */
928 ,p_short_time_hours_single IN VARCHAR2 default 'INCLUDE' -- For Bug 7010282
929 ) IS
930
931 l_ext_dfn_id ben_ext_dfn.ext_dfn_id%TYPE;
932 l_proc_name VARCHAR2(61):= g_proc_name||'PQP_Penserver_Extract';
933 l_errbuff VARCHAR2(3000);
934 l_retcode NUMBER;
935 l_extract_name ben_ext_dfn.name%TYPE;
936 l_extract_shortname VARCHAR2(80);
937 l_extract_count NUMBER;
938
939 l_request_id fnd_concurrent_requests.request_id%TYPE;
940 l_index fnd_concurrent_requests.request_id%TYPE;
941
942 l_wait_success BOOLEAN := FALSE;
943 l_effective_date DATE;
944 l_cutover_date DATE;
945 l_rolling_window_length NUMBER;
946
947 l_config_value pqp_utilities.t_config_values;
948
949 -- Concurrent program
950 l_phase VARCHAR2(80);
951 l_status VARCHAR2(80);
952 l_dev_phase VARCHAR2(80);
953 l_dev_status VARCHAR2(80);
954 l_message VARCHAR2(80);
955 l_err_msg fnd_new_messages.message_text%TYPE;
956 PROGRAM_FAILURE CONSTANT NUMBER := 2 ;
957 PROGRAM_SUCCESS CONSTANT NUMBER := 0 ;
958
959 -- to store extract names and codes
960 l_ext_names t_ext_dfn_names;
961 l_eff_date VARCHAR2(40);
962 l_eff_start_date VARCHAR2(40);
963 l_threads NUMBER;
964 l_chunk_size NUMBER;
965 l_max_errors_allowed NUMBER;
966
967 -- For 115.81
968
969 l_penserv_mode VARCHAR2(1);
970
971
972 BEGIN
973
974 --***************************************
975 -- IMP!! -- remove this later
976 -- g_debug := TRUE;
977 --***************************************
978
979 -- fnd_file.put_line(fnd_file.log, l_proc_name || to_char(SYSDATE,'dd-Mon-yyyy hh:mm:ss am'));
980 fnd_file.put_line(fnd_file.log, l_proc_name || ' : ' || get_time);
981
982 IF (p_submit_request_y_n = 'N') THEN
983 fnd_file.put_line(fnd_file.log, 'First call to ' || l_proc_name );
984 ELSE
985 fnd_file.put_line(fnd_file.log, 'Second call to ' || l_proc_name );
986 END IF;
987
988
989 -- 115.60
990 -- there are cases when some common functions dont get business_group_id
991 -- as a paramater. In such cases, this variable shall be referenced
992 g_business_group_id_backup := p_business_group_id;
993
994 -- store extract type and name in global
995 g_extract_type := p_extract_type;
996 g_dfn_name := p_dfn_name;
997 g_sth_single := p_short_time_hours_single; -- Bug 7010282
998
999
1000 --115.87: Bug 7291713
1001 /*
1002 --115.85
1003 g_bas_eff_date := p_eff_date;
1004 */
1005
1006 -- check for enabling trace
1007 IF p_execution_mode = '3DBG'
1008 THEN
1009 g_debug := pqp_gb_psi_functions.check_debug(p_business_group_id);
1010 END IF;
1011
1012 debug_enter(l_proc_name);
1013 --Maintaining all Penserver extracts in record,so that
1014 --if at all there will be any name change ,we can modify only this
1015 Build_Metadata_Ext_Names;
1016 -- Checking the p_extract_type to decide which extract type to process
1017
1018 debug('p_business_group_id :' || p_business_group_id);
1019 debug('p_execution_mode :' || p_execution_mode);
1020 debug('p_extract_type :' || p_extract_type);
1021 debug('p_dfn_name :' || p_dfn_name);
1022 debug('p_start_date :' || p_start_date);
1023 debug('p_eff_date :' || p_eff_date);
1024 debug('p_submit_request_y_n :' || p_submit_request_y_n);
1025
1026 --Now set interface name
1027 -- BDI/ADI/SDI/EDI
1028 -- GCI/LCI/ACI/BCI
1029
1030 -- check for 3CUT/1PED/2CODE
1031 -- and store in l_ext_names for later use
1032 IF p_extract_type = '3CUT' THEN
1033 l_ext_names := g_cutover_ext_names;
1034 ELSIF p_extract_type = '1PED' THEN
1035 l_ext_names := g_periodic_ext_names;
1036 ELSE
1037 l_ext_names := g_code_ext_names;
1038 END IF;
1039
1040 -- Added for serial mode run
1041 -- in ALL mode and multi-thread
1042 benutils.get_parameter
1043 (p_business_group_id => p_business_group_id
1044 ,p_batch_exe_cd => 'BENXTRCT'
1045 ,p_threads => l_threads
1046 ,p_chunk_size => l_chunk_size
1047 ,p_max_errors => l_max_errors_allowed);
1048
1049 -- Check if this is the parent thread call
1050 -- if = N => this is parent -> launch child threads for the extracts
1051 -- if = Y => this is not parent
1052 IF p_submit_request_y_n = 'N' and p_execution_mode <> '2SET' THEN
1053
1054 debug('p_submit_request_y_n is N !',20);
1055
1056 IF p_dfn_name <> '1ALL' THEN -- single extract submission case
1057 -- find the short name of the dfn_code
1058 -- this is the meaning of the lookup code
1059 l_extract_shortname := HR_GENERAL.DECODE_LOOKUP
1060 (p_lookup_type => 'PQP_GB_PENSERVER_INTERFACES'
1061 ,p_lookup_code => p_dfn_name
1062 );
1063
1064 debug('l_extract_shortname :' || l_extract_shortname,30);
1065 -- append cutover/periodic to names
1066 -- codes already have 'code' attached to their name
1067 IF p_extract_type = '3CUT' THEN
1068 l_extract_shortname := l_extract_shortname||' - '||'Cutover';
1069 ELSIF p_extract_type = '1PED' THEN
1070 l_extract_shortname := l_extract_shortname||' - '||'Periodic';
1071 END IF;
1072
1073 IF p_execution_mode = '1REP' THEN
1074 l_extract_shortname := 'Reprocess'||' - '||l_extract_shortname;
1075 END IF;
1076
1077 debug('l_extract_shortname (appended) :' || l_extract_shortname,30);
1078
1079 debug('p_dfn_name != 1ALL !',20);
1080 -- Submit the process again, this time with 'Y'
1081 debug('now launching : '|| l_extract_shortname, 25);
1082
1083 l_request_id :=
1084 fnd_request.submit_request
1085 (application => 'PQP'
1086 ,program => 'PQPGBPENSERVER'
1087 ,description => l_extract_shortname
1088 ,sub_request => FALSE -- TRUE, still not decide on this one
1089 ,argument1 => NULL -- benefit_action_id
1090 ,argument2 => p_business_group_id
1091 ,argument3 => p_execution_mode
1092 ,argument4 => p_execution_mode_type
1093 ,argument5 => p_extract_type
1094 ,argument6 => p_dfn_name
1095 ,argument7 => p_start_date
1096 ,argument8 => p_eff_date
1097 ,argument9 => 'Y'
1098 ,argument10 => p_concurrent_request_id
1099 ,argument11 => p_year_end_close -- For Nuvos changes
1100 ,argument12 => p_short_time_hours_single -- -- For Bug 7010282
1101 );
1102
1103 -- check for process submit error
1104 IF l_request_id = 0 THEN
1105
1106 fnd_message.set_name('PQP', 'PQP_230228_PSI_EXT_SUBMIT_ERR');
1107 fnd_message.set_token('EXTNAME',g_ext_dtls(1).extract_name);
1108 l_err_msg := fnd_message.get;
1109 errbuf := l_err_msg;
1110 fnd_file.put_line(fnd_file.log, l_err_msg);
1111 l_err_msg := NULL;
1112 END IF;
1113
1114 COMMIT;
1115 -- now search for extract name in this collection
1116 -- and store in global collection
1117 -- we are basically storing extract_name, request_id
1118 FOR j in 1..l_ext_names.count
1119 LOOP
1120 IF l_ext_names(j).extract_code = p_dfn_name
1121 THEN
1122 -- store the details in a global collection
1123 g_ext_dtls(j).extract_name := l_ext_names(j).extract_name;
1124 g_ext_dtls(j).extract_code := l_ext_names(j).extract_code;
1125 g_ext_dtls(j).short_name := l_extract_shortname;
1126 g_ext_dtls(j).request_id := l_request_id;
1127 /*
1128 g_ext_dtls(j).extract_rslt_id := get_ext_rslt_frm_req
1129 (p_request_id => l_request_id
1130 ,p_business_group_id => p_business_group_id
1131 );
1132 */
1133 ELSE
1134 g_ext_dtls(j).extract_name := NULL;
1135 END IF;
1136 END LOOP;
1137
1138 debug('Launched : '|| l_extract_shortname, 30);
1139 --
1140
1141
1142 ELSE -- submit all extract threads
1143
1144 debug('p_dfn_name = 1ALL !',20);
1145
1146 -- = ALL => submit all processes
1147 FOR i in 1..l_ext_names.count
1148 LOOP
1149
1150 -- check for presence in lookup
1151 -- find the short name of the dfn_code
1152 l_extract_shortname := HR_GENERAL.DECODE_LOOKUP
1153 (p_lookup_type => 'PQP_GB_PENSERVER_INTERFACES'
1154 ,p_lookup_code => l_ext_names(i).extract_code
1155 );
1156
1157 debug('l_extract_shortname :' || l_extract_shortname,30);
1158
1159 -- submit the new process only if present in lookup
1160 IF l_extract_shortname IS NOT NULL -- if present in lookup, then submit
1161 THEN
1162 -- append cutover/periodic to names
1163 IF p_extract_type = '3CUT' THEN
1164 l_extract_shortname := l_extract_shortname||' - '||'Cutover';
1165 ELSIF p_extract_type = '1PED' THEN
1166 l_extract_shortname := l_extract_shortname||' - '||'Periodic';
1167 END IF;
1168
1169 debug('l_extract_shortname (appended) :' || l_extract_shortname,40);
1170 debug('now launching : '|| l_extract_shortname, 45);
1171
1172 l_request_id :=
1173 fnd_request.submit_request
1174 (application => 'PQP'
1175 ,program => 'PQPGBPENSERVER'
1176 ,description => l_extract_shortname
1177 ,sub_request => FALSE -- TRUE, still not decide on this one
1178 ,argument1 => NULL -- benefit_action_id
1179 ,argument2 => p_business_group_id
1180 ,argument3 => p_execution_mode -- is already canonical
1181 ,argument4 => p_execution_mode_type
1182 ,argument5 => p_extract_type
1183 ,argument6 => l_ext_names(i).extract_code
1184 ,argument7 => p_start_date
1185 ,argument8 => p_eff_date
1186 ,argument9 => 'Y'
1187 ,argument10 => p_concurrent_request_id
1188 ,argument11 => p_year_end_close -- Nuvos Changes
1189 ,argument12 => p_short_time_hours_single -- -- For Bug 7010282
1190 );
1191
1192 -- check for process submit error
1193 IF l_request_id = 0 THEN
1194
1195 fnd_message.set_name('PQP', 'PQP_230228_PSI_EXT_SUBMIT_ERR');
1196 fnd_message.set_token('EXTNAME',l_ext_names(i).extract_name);
1197 l_err_msg := fnd_message.get;
1198 errbuf := l_err_msg;
1199 fnd_file.put_line(fnd_file.log, l_err_msg);
1200 l_err_msg := NULL;
1201 EXIT;
1202 END IF;
1203
1204 COMMIT;
1205 -- store extract details in the collection
1206 g_ext_dtls(i).extract_name := l_ext_names(i).extract_name;
1207 g_ext_dtls(i).extract_code := l_ext_names(i).extract_code;
1208 g_ext_dtls(i).short_name := l_extract_shortname;
1209 g_ext_dtls(i).request_id := l_request_id;
1210
1211 -- fnd_file.put_line(fnd_file.log, 'Request ID: ' ||l_request_id || ' Extract Name: '|| l_ext_names(i).extract_name);
1212
1213 /*
1214 g_ext_dtls(i).extract_rslt_id := get_ext_rslt_frm_req
1215 (p_request_id => l_request_id
1216 ,p_business_group_id => p_business_group_id
1217 );
1218 */
1219 debug('Launched : '|| l_extract_shortname, 50);
1220
1221
1222
1223 IF l_threads <> 1 THEN
1224 l_wait_success := fnd_concurrent.wait_for_request
1225 (request_id => l_request_id
1226 ,interval => (g_wait_interval - 30)
1227 ,max_wait => g_max_wait
1228 ,phase => l_phase -- OUT
1229 ,status => l_status -- OUT
1230 ,dev_phase => l_dev_phase -- OUT
1231 ,dev_status => l_dev_status -- OUT
1232 ,message => l_message -- OUT
1233 );
1234
1235 -- Do some error checking here
1236 IF (NOT l_wait_success
1237 )
1238 OR
1239 (l_dev_phase = 'COMPLETE' AND l_dev_status <> 'NORMAL'
1240 ) THEN
1241
1242 fnd_file.put_line(fnd_file.log, l_message);
1243
1244 fnd_message.set_name('PQP', 'PQP_230229_PSI_EXT_EXEC_ERR');
1245 fnd_message.set_token('EXTNAME',l_ext_names(i).extract_name);
1246 l_err_msg := fnd_message.get;
1247 errbuf := l_err_msg;
1248 fnd_file.put_line(fnd_file.log, l_err_msg);
1249 l_retcode := PROGRAM_FAILURE ;
1250 l_err_msg:= NULL;
1251 -- EXIT;
1252
1253 END IF; -- (l_dev_phase = 'COMPLETE'
1254
1255 END IF; -- l_threads <> 1 check ...
1256
1257 ELSE -- l_extract_shortname IS NOT NULL
1258 g_ext_dtls(i).extract_name := NULL;
1259 END IF; -- l_extract short name is NULL check ...
1260 END LOOP; -- FOR i in 1..g_cutover_ext_names.count
1261
1262 END IF; -- IF p_dfn_name <> '1ALL' THEN
1263
1264 -------------- wait for child processes to end
1265 -- parent to wait till all child process end
1266 -- parent to error if any child fails
1267
1268 -- dump data for debugging
1269 FOR i in 1..g_ext_dtls.count
1270 LOOP
1271 debug('g_ext_dtls('||i||').extract_name :' || g_ext_dtls(i).extract_name);
1272 debug('g_ext_dtls('||i||').extract_code : ' || g_ext_dtls(i).extract_code);
1273 debug('g_ext_dtls('||i||').short_name : ' || g_ext_dtls(i).short_name);
1274 debug('g_ext_dtls('||i||').request_id : ' || g_ext_dtls(i).request_id);
1275 END LOOP;
1276
1277
1278 l_index := g_ext_dtls.FIRST;
1279
1280 -- start browsing thru collection of child thread details
1281 debug('start browsing thru collection of child thread details',60);
1282
1283 WHILE l_index IS NOT NULL AND (p_dfn_name <> '1ALL' OR
1284 (p_dfn_name = '1ALL' AND l_threads = 1))
1285 LOOP
1286 IF g_ext_dtls(l_index).extract_name IS NOT NULL
1287 THEN
1288
1289 l_wait_success := fnd_concurrent.wait_for_request
1290 (request_id => g_ext_dtls(l_index).request_id
1291 ,interval => (g_wait_interval - 30)
1292 ,max_wait => g_max_wait
1293 ,phase => l_phase -- OUT
1294 ,status => l_status -- OUT
1295 ,dev_phase => l_dev_phase -- OUT
1296 ,dev_status => l_dev_status -- OUT
1297 ,message => l_message -- OUT
1298 );
1299
1300 -- Do some error checking here
1301 IF (NOT l_wait_success
1302 )
1303 OR
1304 (l_dev_phase = 'COMPLETE' AND l_dev_status <> 'NORMAL'
1305 ) THEN
1306
1307 fnd_file.put_line(fnd_file.log, l_message);
1308
1309 fnd_message.set_name('PQP', 'PQP_230229_PSI_EXT_EXEC_ERR');
1310 fnd_message.set_token('EXTNAME',g_ext_dtls(l_index).extract_name);
1311 l_err_msg := fnd_message.get;
1312 errbuf := l_err_msg;
1313 fnd_file.put_line(fnd_file.log, l_err_msg);
1314 l_retcode := PROGRAM_FAILURE ;
1315 l_err_msg:= NULL;
1316 -- EXIT;
1317 END IF; -- (l_dev_phase = 'COMPLETE'
1318
1319 -- fnd_file.put_line(fnd_file.log, 'Completed the extract' || to_char(SYSDATE,'dd-Mon-yyyy hh:mm:ss am'));
1320 fnd_file.put_line(fnd_file.log, 'Completed the extract' || ' : ' || get_time);
1321
1322 debug('Completed Request ID :'||
1323 to_char(g_ext_dtls(l_index).request_id), 160);
1324 END IF;
1325
1326 l_index := g_ext_dtls.NEXT(l_index);
1327
1328 END LOOP; -- WHILE l_index IS NOT NULL
1329
1330 ---------------------------------------
1331 -- All extracts have been launched --
1332 -- now launch control totals
1333 ---------------------------------------
1334
1335 debug('p_extract_type : ' || p_extract_type);
1336 -- now launch control total thread and then wait for it to finish
1337 IF p_extract_type <> '2CODE' THEN -- IF code files, then dont need to
1338 debug('now launch control total thread and then wait for it to finish ',70);
1339 -- fetch rslt_ids from request_ids
1340 FOR i in 1..g_ext_dtls.count
1341 LOOP
1342 IF g_ext_dtls(i).request_id IS NOT NULL
1343 THEN
1344 g_ext_dtls(i).extract_rslt_id := get_ext_rslt_frm_req
1345 (p_request_id => g_ext_dtls(i).request_id
1346 ,p_business_group_id => p_business_group_id
1347 );
1348 END IF;
1349 END LOOP;
1350
1351 /* The Claybrook order
1352 1 BASIC DATA -- DONE
1353 2 ADDRESS -- DONE
1354 3 SERVICE HISTORY -- DONE
1355 4 PART-TIME HOURS HISTORY
1356 5 SHORT-TIME HOURS HISTORY - Single Records
1357 6 SHORT-TIME HOURS HISTORY - Accumulated Records
1358 7 SALARY HISTORY -- DONE
1359 8 ALLOWANCE HISTORY
1360 9 BONUS HISTORY
1361 10 EARNINGS HISTORY -- DONE
1362 11 WPS CONTRIBUTION RATE HISTORY
1363 */
1364
1365 /* In control totals
1366 1 Basic Data -- 1
1367 2 Address -- 2
1368 3 Service -- 3
1369 4 Salary -- 7
1370 5 Earnings -- 10
1371 6 Allowance -- 8
1372 7 Bonus -- 9
1373 8 WPS -- 11
1374 9 Part-time hours -- 4
1375 10 Short-time hours Single records -- 5
1376 11 Short-time hours Accumulated records -- 6
1377 */
1378
1379 --**************
1380 --
1381 -- We need to match the order for correct processing, as the order in code is different
1382 -- from that in control totals.
1383 --
1384 --**************
1385 debug('Submitting control totals ... ',80);
1386 l_request_id :=
1387 fnd_request.submit_request
1388 (application => 'PQP'
1389 ,program => 'PQPPENTTL'
1390 ,description => ''
1391 ,sub_request => FALSE -- TRUE, still not decide on this one
1392 ,argument1 => p_extract_type -- NULL
1393 ,argument2 => NULL
1394 ,argument3 => NULL
1395 ,argument4 => g_ext_dtls(1).extract_rslt_id
1396 ,argument5 => g_ext_dtls(2).extract_rslt_id
1397 ,argument6 => g_ext_dtls(3).extract_rslt_id
1398 ,argument7 => g_ext_dtls(7).extract_rslt_id
1399 ,argument8 => g_ext_dtls(10).extract_rslt_id
1400 ,argument9 => g_ext_dtls(8).extract_rslt_id
1401 ,argument10 => g_ext_dtls(9).extract_rslt_id
1402 ,argument11 => g_ext_dtls(11).extract_rslt_id
1403 ,argument12 => g_ext_dtls(4).extract_rslt_id
1404 ,argument13 => g_ext_dtls(5).extract_rslt_id
1405 ,argument14 => g_ext_dtls(6).extract_rslt_id
1406 ,argument15 => p_business_group_id
1407 ,argument16 => p_year_end_close -- Nuvos Changes
1408 );
1409
1410 -- check for process submit error
1411 IF l_request_id = 0 THEN
1412
1413 fnd_message.set_name('PQP', 'PQP_230228_PSI_EXT_SUBMIT_ERR');
1414 fnd_message.set_token('EXTNAME','PenServer Control Totals Process');
1415 l_err_msg := fnd_message.get;
1416 errbuf := l_err_msg;
1417 fnd_file.put_line(fnd_file.log, l_err_msg);
1418 l_err_msg := NULL;
1419 END IF;
1420
1421 COMMIT;
1422
1423 -- now wait for control totals to finish
1424 l_wait_success := fnd_concurrent.wait_for_request
1425 (request_id => l_request_id
1426 ,interval => (g_wait_interval - 30)
1427 ,max_wait => g_max_wait
1428 ,phase => l_phase -- OUT
1429 ,status => l_status -- OUT
1430 ,dev_phase => l_dev_phase -- OUT
1431 ,dev_status => l_dev_status -- OUT
1432 ,message => l_message -- OUT
1433 );
1434
1435 -- Do some error checking here
1436 IF (NOT l_wait_success
1437 )
1438 OR
1439 (l_dev_phase = 'COMPLETE' AND l_dev_status <> 'NORMAL'
1440 ) THEN
1441
1442 fnd_file.put_line(fnd_file.log, l_message);
1443
1444 fnd_message.set_name('PQP', 'PQP_230229_PSI_EXT_EXEC_ERR');
1445 fnd_message.set_token('EXTNAME','PenServer Control Totals');
1446 l_err_msg := fnd_message.get;
1447 errbuf := l_err_msg;
1448 fnd_file.put_line(fnd_file.log, l_err_msg);
1449 l_retcode := PROGRAM_FAILURE ;
1450 l_err_msg:= NULL;
1451
1452 END IF; -- (l_dev_phase = 'COMPLETE'
1453 END IF;
1454 debug('Completed Request ID :'|| to_char(l_request_id), 160);
1455
1456 -------------------------
1457
1458 -- Check the return code for any failure
1459 IF l_retcode = PROGRAM_FAILURE THEN
1460
1461 debug('Program Failure, erroring.', 170);
1462
1463 retcode := l_retcode;
1464 fnd_message.raise_error;
1465 RETURN;
1466 END IF;
1467
1468 -- Write a summary in the log file
1469 fnd_file.put_line(fnd_file.log, '---------------------------------------------------------------------- ');
1470 fnd_file.put_line(fnd_file.log, '********************************************************************** ');
1471 fnd_file.put_line(fnd_file.log, ' ');
1472 fnd_file.put_line(fnd_file.log, 'PenServer Interface Process completed successfully.');
1473 fnd_file.put_line(fnd_file.log, ' ');
1474 fnd_file.put_line(fnd_file.log, ' Extract Name Request Id ');
1475 fnd_file.put_line(fnd_file.log, '--------------------------------------------------------------------------------------------- ------------ ');
1476
1477
1478 l_extract_count := 0;
1479 l_index := g_ext_dtls.FIRST;
1480
1481 WHILE l_index IS NOT NULL
1482 LOOP
1483
1484 IF g_ext_dtls(l_index).extract_name IS NOT NULL
1485 THEN
1486 fnd_file.put(fnd_file.log, rpad(g_ext_dtls(l_index).extract_name, 100));
1487 fnd_file.put_line(fnd_file.log, rpad(g_ext_dtls(l_index).request_id, 15));
1488
1489 l_extract_count := l_extract_count + 1;
1490 END IF;
1491
1492 l_index := g_ext_dtls.NEXT(l_index);
1493
1494 END LOOP; -- WHILE l_index IS NOT NULL
1495
1496 fnd_file.put_line(fnd_file.log, 'Total Extracts processed :' ||to_char(l_extract_count));
1497 fnd_file.put_line(fnd_file.log, ' ');
1498
1499 fnd_file.put_line(fnd_file.log, ' ');
1500 fnd_file.put_line(fnd_file.log, '********************************************************************** ');
1501 fnd_file.put_line(fnd_file.log, '---------------------------------------------------------------------- ');
1502
1503
1504 -- the follwoing ELSE is for the case when this process is NOT a parent
1505 -- it is in fact one of the threads launched by Penserver Interface Process
1506 -- to launch individual extract processes
1507 ELSE -- IF p_submit_request_y_n = 'N' THEN
1508
1509 -- This is a child thread, prepare to submit extract processes
1510 l_eff_date := p_eff_date;
1511
1512 debug('substr(p_eff_date,1,10) : '|| substr(p_eff_date,1,10));
1513 debug('l_eff_date :' || l_eff_date);
1514
1515 --***************************
1516 -- fetch configuration value for cutover date
1517 debug('Fetching configuration value for cutover date ...', 40);
1518 pqp_utilities.get_config_type_values
1519 ( p_configuration_type => 'PQP_GB_PENSERVER_PAYPOINT_INFO' --'PQP_GB_PENSERVER_CUTOVER_DATE'
1520 ,p_business_group_id => p_business_group_id
1521 ,p_legislation_code => NULL
1522 ,p_tab_config_values => l_config_value
1523 );
1524
1525 IF l_config_value.COUNT > 0 -- config value found
1526 THEN
1527 l_cutover_date := to_date(substr(l_config_value(l_config_value.FIRST).pcv_information2,1,10),'YYYY/MM/DD HH24:MI:SS');
1528 ELSE
1529 l_cutover_date := NULL;
1530 END IF;
1531
1532 -- fetch Effective rolling date window length
1533 debug('Fetching Effective rolling date window length ...', 40);
1534 pqp_utilities.get_config_type_values
1535 ( p_configuration_type => 'PQP_GB_PENSERVER_DEFINITION'
1536 ,p_business_group_id => p_business_group_id
1537 ,p_legislation_code => NULL
1538 ,p_tab_config_values => l_config_value
1539 );
1540
1541 IF l_config_value.COUNT > 0 -- config value found
1542 THEN
1543 IF l_rolling_window_length < 1
1544 THEN
1545 l_rolling_window_length := 6;
1546 ELSE
1547 l_rolling_window_length :=
1548 fnd_number.canonical_to_number(l_config_value(l_config_value.FIRST).pcv_information2);
1549 END IF;
1550
1551 -- performance fix : 1
1552 g_reference_extract := l_config_value(l_config_value.FIRST).pcv_information3;
1553
1554 ELSE
1555 l_rolling_window_length := 6;
1556
1557 -- performance fix : 1
1558 g_reference_extract := 'BASIC';
1559 END IF;
1560
1561
1562 debug('l_rolling_window_length : '|| l_rolling_window_length);
1563 -- effective date window restrictions
1564 -- if effective start date < cutover date, pick cutover date for window start
1565 IF l_cutover_date IS NOT NULL and
1566 (add_months(to_date(p_eff_date,'YYYY/MM/DD HH24:MI:SS'),(-1 * l_rolling_window_length))) < l_cutover_date
1567 THEN
1568 l_eff_start_date := to_char(l_cutover_date,'YYYY/MM/DD HH24:MI:SS');
1569 ELSE
1570 l_eff_start_date :=
1571 to_char(add_months(to_date(p_eff_date,'YYYY/MM/DD HH24:MI:SS'),(-1 * l_rolling_window_length)),'YYYY/MM/DD HH24:MI:SS');
1572 END IF;
1573
1574 IF p_dfn_name not in ('STA','STS') THEN
1575 l_eff_start_date :=
1576 to_char(to_date(l_eff_start_date,'YYYY/MM/DD HH24:MI:SS')+1,'YYYY/MM/DD HH24:MI:SS');
1577 END IF;
1578
1579 debug('After add_months/cutover date check : l_eff_start_date :' || l_eff_start_date);
1580
1581 -- set the start date of the range to '00:00:00'
1582 -- and set the end date of the range to '23:59:59'
1583 --l_eff_start_date := TO_CHAR(l_eff_start_date,'YYYY/MM/DD');
1584 --l_eff_date := TO_CHAR(l_eff_date,'YYYY/MM/DD')||' 23:59:59';
1585 debug('setting start date to 00:00:00 and end date to 23:59:59');
1586 l_eff_start_date := substr(l_eff_start_date,1,10)|| ' 00:00:00';
1587 l_eff_date := substr(l_eff_date,1,10)|| ' 23:59:59';
1588
1589 debug('l_eff_start_date :' || l_eff_start_date);
1590 debug('l_eff_date :' || l_eff_date);
1591 --
1592
1593 --***************************
1594
1595 -- Call the actual benefit extract process with the effective date as
1596 -- the extract end date along with the ext def. id and business group id.
1597
1598 IF p_dfn_name = 'ACI' THEN --Allowance Codes Interface
1599 debug('p_dfn_name = ACI !',30);
1600 get_allowance_codes
1601 (p_business_group_id => p_business_group_id
1602 ,p_from_date => to_date(l_eff_start_date,'YYYY/MM/DD HH24:MI:SS')
1603 ,p_to_date => to_date(l_eff_date,'YYYY/MM/DD HH24:MI:SS'));
1604 ELSIF p_dfn_name ='BCI' THEN --Bonus Codes Interface
1605 debug('p_dfn_name = BCI !',30);
1606 get_bonus_codes
1607 (p_business_group_id => p_business_group_id
1608 ,p_from_date => to_date(l_eff_start_date,'YYYY/MM/DD HH24:MI:SS')
1609 ,p_to_date => to_date(l_eff_date,'YYYY/MM/DD HH24:MI:SS'));
1610 ELSE
1611 -- submit the extract
1612
1613 -- now search for extract name in this collection
1614 FOR i in 1..l_ext_names.count
1615 LOOP
1616 IF l_ext_names(i).extract_code = p_dfn_name
1617 THEN
1618 l_extract_name := l_ext_names(i).extract_name;
1619 EXIT;
1620 END IF;
1621 END LOOP;
1622
1623 debug('will now find ext_dfn_id and submit extract');
1624 debug('p_extract_type : ' || p_extract_type );
1625 debug('p_dfn_name : ' || p_dfn_name );
1626
1627 --
1628 --p_benefit_action_id
1629 --p_business_group_id
1630 --p_execution_mode
1631 --p_execution_mode_type
1632 --p_extract_type
1633 --p_dfn_name
1634 --p_start_date
1635 --p_eff_date
1636 --p_submit_request_y_n
1637 --p_concurrent_request_id
1638 --
1639
1640 -- find ext_dfn_id
1641 OPEN csr_ext_dfn_id(c_extract_name => l_extract_name);
1642 FETCH csr_ext_dfn_id INTO l_ext_dfn_id;
1643 CLOSE csr_ext_dfn_id;
1644
1645
1646 -- Start 115.77.11511.3
1647 OPEN csr_get_run_date(c_ext_dfn_id => l_ext_dfn_id
1648 ,c_business_group_id => g_business_group_id_backup);
1649 FETCH csr_get_run_date INTO g_last_app_date,g_output_name;
1650 CLOSE csr_get_run_date;
1651
1652 debug('g_last_approved_date : ' || g_last_app_date );
1653 debug('g_output_name : ' || g_output_name );
1654 -- End 115.77.11511.3
1655
1656
1657 IF l_ext_dfn_id IS NOT NULL THEN
1658
1659 IF p_execution_mode = '1REP'
1660 THEN
1661 ben_ext_thread.restart
1662 (errbuf => l_errbuff
1663 ,retcode => l_retcode
1664 ,p_ext_dfn_id => l_ext_dfn_id
1665 ,p_concurrent_request_id => p_concurrent_request_id
1666 );
1667 ELSE
1668
1669
1670 -- fnd_file.put_line(fnd_file.log, 'calling ben_process' || to_char(SYSDATE,'dd-Mon-yyyy hh:mm:ss am'));
1671 fnd_file.put_line(fnd_file.log, 'calling ben_process' || ' : ' || get_time);
1672
1673 IF p_extract_type <> '1PED' -- cutover/code extract (full profile)
1674 THEN
1675 ben_ext_thread.process
1676 (errbuf => l_errbuff
1677 ,retcode => l_retcode
1678 ,p_benefit_action_id => NULL
1679 ,p_ext_dfn_id => l_ext_dfn_id
1680 ,p_effective_date => l_eff_date
1681 ,p_business_group_id => p_business_group_id
1682 ,p_penserv_date => g_last_app_date --for Bug 7358374
1683 );
1684 ELSE -- (is = '1PED') -- periodic type
1685
1686 -- Start 115.81
1687 -- start 115.84 7165575
1688 -- Modifed for 115.85
1689 IF p_dfn_name = 'ADI'
1690 THEN
1691 l_penserv_mode := 'A' ;
1692 ELSE
1693 l_penserv_mode := 'Y';
1694 END IF;
1695 -- End 115.84
1696 -- End 115.81
1697
1698 debug('p_dfn_name : ' || p_dfn_name );
1699 debug('l_penserv_mode : ' || l_penserv_mode );
1700
1701 ben_ext_thread.process
1702 (errbuf => l_errbuff
1703 ,retcode => l_retcode
1704 ,p_benefit_action_id => NULL
1705 ,p_ext_dfn_id => l_ext_dfn_id
1706 ,p_effective_date => l_eff_date
1707 ,p_business_group_id => p_business_group_id
1708 ,p_eff_start_date => l_eff_start_date
1709 ,p_eff_end_date => l_eff_date
1710 ,p_penserv_date => g_last_app_date
1711 ,p_penserv_mode => l_penserv_mode
1712 --,p_act_start_date => hr_api.g_sot
1713 --,p_act_end_date => l_eff_date
1714 );
1715 END IF; -- p_extract_type <> '1PED'
1716 END IF; -- p_execution_mode = '1REP'
1717 END IF; -- l_ext_dfn_id IS NOT NULL
1718 END IF; -- IF p_dfn_name = 'ACI' THEN
1719
1720 END IF; -- IF p_submit_request_y_n = 'N'
1721
1722 debug_exit(l_proc_name);
1723 EXCEPTION
1724 WHEN OTHERS THEN
1725 debug_exit(' Error in '||l_proc_name);
1726 RAISE;
1727 END PQP_Penserver_Extract;
1728
1729
1730
1731 -- =============================================================================
1732 -- This procedure gets control totals information
1733 -- =============================================================================
1734 PROCEDURE Get_Penserver_CntrlTtl_Process
1735 (errbuf OUT NOCOPY VARCHAR2
1736 ,retcode OUT NOCOPY VARCHAR2
1737 ,p_extract_type IN VARCHAR2 DEFAULT NULL
1738 ,p_parent_request_id IN NUMBER DEFAULT NULL
1739 ,p_parent_selected IN VARCHAR2 DEFAULT NULL
1740 ,p_ext_bdi_rslt_id IN NUMBER DEFAULT NULL
1741 ,p_ext_adi_rslt_id IN NUMBER DEFAULT NULL
1742 ,p_ext_sehi_rslt_id IN NUMBER DEFAULT NULL
1743 ,p_ext_sahi_rslt_id IN NUMBER DEFAULT NULL
1744 ,p_ext_ehi_rslt_id IN NUMBER DEFAULT NULL
1745 ,p_ext_ahi_rslt_id IN NUMBER DEFAULT NULL
1746 ,p_ext_bhi_rslt_id IN NUMBER DEFAULT NULL
1747 ,p_ext_wps_rslt_id IN NUMBER DEFAULT NULL
1748 ,p_ext_pthi_rslt_id IN NUMBER DEFAULT NULL
1749 ,p_ext_sthi_rslt_id IN NUMBER DEFAULT NULL
1750 ,p_ext_sthai_rslt_id IN NUMBER DEFAULT NULL
1751 ,p_business_group_id IN NUMBER
1752 ,p_year_end_close IN VARCHAR2 DEFAULT 'N' -- For Nuvos Changes
1753 ) IS
1754
1755
1756 CURSOR csr_get_ttl_rslt(c_ext_rslt_id IN Number) IS
1757 SELECT val_01,val_02,val_03,val_04,val_05
1758 FROM ben_ext_rslt_dtl dtl
1759 ,ben_ext_rcd rcd
1760 WHERE dtl.ext_rslt_id = c_ext_rslt_id
1761 AND dtl.ext_rcd_id = rcd.ext_rcd_id
1762 AND rcd.rcd_type_cd = 'T';
1763
1764 CURSOR csr_get_rsltid (c_get_rsltid IN number) IS
1765 SELECT req.request_id req_id
1766 ,bba.pl_id rslt_id
1767 ,bba.pgm_id ext_dfn_id
1768 ,argument3 Execution_Mode
1769 ,argument5 Extract_Type
1770 ,argument6 Interface_File
1771 ,argument8 Extract_eff_date --- For Nuvos
1772 ,request_date req_date
1773 FROM fnd_concurrent_requests req, ben_benefit_actions bba
1774 WHERE parent_request_id = c_get_rsltid
1775 AND bba.request_id = req.request_id
1776 AND bba.business_group_id = p_business_group_id;
1777
1778
1779 -- For Nuvos
1780
1781 CURSOR csr_get_eff_date (c_ext_rslt_id IN number) IS
1782 SELECT argument8 Extract_eff_date --- For Nuvos
1783 FROM fnd_concurrent_requests req ,ben_ext_rslt ben
1784 where req.request_id = ben.request_id
1785 and ben.ext_rslt_id = c_ext_rslt_id
1786 and ben.business_group_id = p_business_group_id;
1787
1788 -- For Nuvos Earnings
1789
1790 CURSOR csr_get_ern_ttl_rslt(c_ext_rslt_id IN Number) IS
1791 SELECT val_01 payhcnt,
1792 nvl(val_03,0) + nvl(val_04,0) pearntot,
1793 nvl(val_02,0) + nvl(val_05,0) + nvl(val_06,0) + nvl(val_07,0) + nvl(val_08,0) + nvl(val_09,0) + nvl(val_10,0) + nvl(val_11,0) + nvl(val_12,0) pdedstot
1794 FROM ben_ext_rslt_dtl dtl
1795 ,ben_ext_rcd rcd
1796 WHERE dtl.ext_rslt_id = c_ext_rslt_id
1797 AND dtl.ext_rcd_id = rcd.ext_rcd_id
1798 AND rcd.rcd_type_cd = 'T';
1799
1800
1801
1802 l_ext_bdi_rslt_id NUMBER;
1803 l_ext_adi_rslt_id NUMBER;
1804 l_ext_sehi_rslt_id NUMBER;
1805 l_ext_sahi_rslt_id NUMBER;
1806 l_ext_ehi_rslt_id NUMBER;
1807 l_ext_ahi_rslt_id NUMBER;
1808 l_ext_bhi_rslt_id NUMBER;
1809 l_ext_wps_rslt_id NUMBER;
1810 l_ext_pthi_rslt_id NUMBER;
1811 l_ext_sthi_rslt_id NUMBER;
1812 l_ext_sthai_rslt_id NUMBER;
1813 l_ext_date DATE;
1814
1815 l_total_amount NUMBER;
1816
1817
1818 l_pay_point VARCHAR2(15);
1819 l_column_separator VARCHAR2(10):= ' , ';
1820 l_cntrl_tot t_cntrl_tot;
1821 l_Basic_Data_Cnt VARCHAR2(10);
1822 l_Service_Hist_Cnt VARCHAR2(10);
1823 l_Salary_Hist_Cnt VARCHAR2(10);
1824 l_Sal_hist_Nat_Pay_Cnt VARCHAR2(16);
1825 l_Address_Data_Cnt VARCHAR2(10);
1826 l_Earning_Hist_Cnt VARCHAR2(10);
1827 l_Earning_Tot_Cnt VARCHAR2(16);
1828 l_Bonus_Hist_Cnt VARCHAR2(10);
1829 l_Bonus_Tot_Cnt VARCHAR2(16);
1830 l_STA_Hist_Cnt VARCHAR2(10);
1831 l_STA_Tot_AdjHrs_Cnt VARCHAR2(16);
1832 l_STS_Hist_Cnt VARCHAR2(10);
1833 l_STS_Tot_AdjHrs_Cnt VARCHAR2(16);
1834 l_WPS_Hist_Cnt VARCHAR2(10);
1835 l_WPS_Tot_Cnt VARCHAR2(16);
1836 l_Allowance_Hist_Cnt VARCHAR2(10);
1837 l_Allowance_Tot_Cnt VARCHAR2(16);
1838 l_PTH_Hist_Cnt VARCHAR2(10);
1839 l_Tot_Part_Time_Hours_Cnt VARCHAR2(16);
1840
1841 -- For Nuvos
1842 l_Pay_Hist_Cnt VARCHAR2(10);
1843 l_Pay_Tot_EARN_Cnt VARCHAR2(16);
1844 l_Pay_Tot_DEDS_Cnt VARCHAR2(16);
1845
1846
1847
1848 l_proc_name VARCHAR2(200):= g_proc_name || 'Get_Penserver_CntrlTtl_Process';
1849
1850 l_get_ttl_rslt csr_get_ttl_rslt%ROWTYPE; -- to fetch from the cursor.
1851 l_get_rsltid csr_get_rsltid%ROWTYPE;
1852 l_ext_dfn_id NUMBER;
1853 l_run_date DATE;
1854 l_year_close VARCHAR2(4); -- For Nuvos
1855 l_per_end_date DATE; -- For Nuvos
1856 l_eff_date_arg8 VARCHAR2(30); -- For Nuvos
1857 l_get_ern_ttl_rslt csr_get_ern_ttl_rslt%ROWTYPE; -- For Nuvos
1858
1859
1860 BEGIN
1861
1862
1863 hr_utility.set_location('p_ext_ehi_rslt_id: ' || p_ext_ehi_rslt_id, 10);
1864 -- check for enabling trace
1865 g_debug := pqp_gb_psi_functions.check_debug(p_business_group_id);
1866
1867 l_ext_bdi_rslt_id := p_ext_bdi_rslt_id;
1868 l_ext_adi_rslt_id := p_ext_adi_rslt_id;
1869 l_ext_sehi_rslt_id := p_ext_sehi_rslt_id;
1870 l_ext_sahi_rslt_id := p_ext_sahi_rslt_id;
1871 l_ext_ehi_rslt_id := p_ext_ehi_rslt_id;
1872 l_ext_ahi_rslt_id := p_ext_ahi_rslt_id;
1873 l_ext_bhi_rslt_id := p_ext_bhi_rslt_id;
1874 l_ext_wps_rslt_id := p_ext_wps_rslt_id;
1875 l_ext_pthi_rslt_id := p_ext_pthi_rslt_id;
1876 l_ext_sthi_rslt_id := p_ext_sthi_rslt_id;
1877 l_ext_sthai_rslt_id := p_ext_sthai_rslt_id;
1878 l_ext_date := sysdate;
1879
1880 debug_enter(l_proc_name);
1881
1882 Build_Metadata_Ext_Names;
1883
1884 -- get paypoint value for business group id passed
1885 l_pay_point := paypoint(p_business_group_id);
1886 debug ('l_pay_point:'||l_pay_point);
1887
1888 IF l_pay_point = ''
1889 or
1890 NOT PQP_GB_PSI_FUNCTIONS.is_alphanumeric(p_string=> l_pay_point)
1891 THEN
1892 -- Raise error as Paypoint is unknown(E)
1893 hr_utility.set_message(805, 'BEN_94453_INV_PAYPOINT');
1894 fnd_file.put_line(fnd_file.LOG
1895 , RPAD('Error', 30) || ': ' || hr_utility.get_message);
1896 fnd_file.put_line(fnd_file.LOG, ' ');
1897 END IF;
1898
1899
1900 debug('p_parent_request_id ' || p_parent_request_id, 20);
1901 -- If parent request id is supplied instead of individual result ids.
1902
1903 IF p_parent_request_id IS NOT NULL THEN
1904 OPEN csr_get_rsltid(c_get_rsltid=>p_parent_request_id);
1905 LOOP
1906 FETCH csr_get_rsltid INTO l_get_rsltid;
1907 EXIT WHEN csr_get_rsltid%NOTFOUND;
1908 l_ext_date := l_get_rsltid.req_date;
1909 l_per_end_date := fnd_date.canonical_to_date(l_get_rsltid.Extract_eff_date); -- For Nuvos change
1910 hr_utility.set_location('l_per_end_date: ' || l_per_end_date, 10);
1911 IF l_get_rsltid.Interface_File = g_periodic_ext_names(1).extract_code THEN
1912 l_ext_bdi_rslt_id := l_get_rsltid.rslt_id; -- dbms_output.put_line(l_ext_bdi_rslt_id);
1913 debug('l_get_rsltid.rslt_id '|| l_get_rsltid.rslt_id, 20);
1914 ELSIF l_get_rsltid.Interface_File = g_periodic_ext_names(2).extract_code THEN
1915 l_ext_adi_rslt_id := l_get_rsltid.rslt_id; -- dbms_output.put_line(l_ext_adi_rslt_id);
1916 debug('l_get_rsltid.rslt_id '|| l_get_rsltid.rslt_id, 30);
1917 ELSIF l_get_rsltid.Interface_File = g_periodic_ext_names(3).extract_code THEN
1918 l_ext_sehi_rslt_id := l_get_rsltid.rslt_id; -- dbms_output.put_line(l_ext_sehi_rslt_id);
1919 debug('l_get_rsltid.rslt_id '|| l_get_rsltid.rslt_id, 40);
1920 ELSIF l_get_rsltid.Interface_File = g_periodic_ext_names(4).extract_code THEN
1921 l_ext_pthi_rslt_id := l_get_rsltid.rslt_id;
1922 debug('l_get_rsltid.rslt_id '|| l_get_rsltid.rslt_id, 50);
1923 ELSIF l_get_rsltid.Interface_File = g_periodic_ext_names(5).extract_code THEN
1924 l_ext_sthi_rslt_id := l_get_rsltid.rslt_id;
1925 debug('l_get_rsltid.rslt_id '|| l_get_rsltid.rslt_id, 60);
1926 ELSIF l_get_rsltid.Interface_File = g_periodic_ext_names(6).extract_code THEN
1927 l_ext_sthai_rslt_id := l_get_rsltid.rslt_id;
1928 debug('l_get_rsltid.rslt_id '|| l_get_rsltid.rslt_id, 70);
1929 ELSIF l_get_rsltid.Interface_File = g_periodic_ext_names(7).extract_code THEN
1930 l_ext_sahi_rslt_id := l_get_rsltid.rslt_id; -- dbms_output.put_line(l_ext_sahi_rslt_id);
1931 debug('l_get_rsltid.rslt_id '|| l_get_rsltid.rslt_id, 80);
1932 ELSIF l_get_rsltid.Interface_File = g_periodic_ext_names(8).extract_code THEN
1933 l_ext_ahi_rslt_id := l_get_rsltid.rslt_id;
1934 debug('l_get_rsltid.rslt_id '|| l_get_rsltid.rslt_id, 90);
1935 ELSIF l_get_rsltid.Interface_File = g_periodic_ext_names(9).extract_code THEN
1936 l_ext_bhi_rslt_id := l_get_rsltid.rslt_id;
1937 debug('l_get_rsltid.rslt_id '|| l_get_rsltid.rslt_id, 100);
1938 ELSIF l_get_rsltid.Interface_File = g_periodic_ext_names(10).extract_code THEN
1939 l_ext_ehi_rslt_id := l_get_rsltid.rslt_id; -- dbms_output.put_line(l_ext_ehi_rslt_id);
1940 debug('l_get_rsltid.rslt_id '|| l_get_rsltid.rslt_id, 110);
1941 ELSIF l_get_rsltid.Interface_File = g_periodic_ext_names(11).extract_code THEN
1942 l_ext_wps_rslt_id := l_get_rsltid.rslt_id;
1943 debug('l_get_rsltid.rslt_id '|| l_get_rsltid.rslt_id, 120);
1944 END IF;
1945 END LOOP;
1946
1947
1948 CLOSE csr_get_rsltid;
1949
1950 debug('l_get_rsltid.rslt_id '|| l_get_rsltid.rslt_id, 125);
1951 END IF;
1952
1953 hr_utility.set_location('l_ext_ehi_rslt_id: ' || l_ext_ehi_rslt_id, 30);
1954 --Basic Data interface Count
1955 IF l_ext_bdi_rslt_id IS NOT NULL THEN
1956 OPEN csr_get_ttl_rslt(c_ext_rslt_id => l_ext_bdi_rslt_id);
1957 FETCH csr_get_ttl_rslt INTO l_get_ttl_rslt;
1958 IF csr_get_ttl_rslt%NOTFOUND
1959 THEN
1960 l_Basic_Data_Cnt := RPAD(' ',10,' ');
1961 ELSE
1962 l_Basic_Data_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_01),'0999999999')));
1963 END IF;
1964 CLOSE csr_get_ttl_rslt;
1965
1966 -- For Nuvos
1967 OPEN csr_get_eff_date(c_ext_rslt_id => l_ext_bdi_rslt_id);
1968 FETCH csr_get_eff_date into l_eff_date_arg8;
1969 IF csr_get_eff_date%NOTFOUND
1970 THEN
1971 l_per_end_date := sysdate;
1972 ELSE
1973 l_per_end_date := fnd_date.canonical_to_date(l_eff_date_arg8);
1974 END IF;
1975 CLOSE csr_get_eff_date;
1976 ELSE
1977 l_Basic_Data_Cnt := RPAD(' ',10,' ');
1978 END IF;
1979
1980
1981 --Address data interface Count
1982
1983 IF l_ext_adi_rslt_id IS NOT NULL THEN
1984 OPEN csr_get_ttl_rslt(c_ext_rslt_id => l_ext_adi_rslt_id);
1985 FETCH csr_get_ttl_rslt INTO l_get_ttl_rslt;
1986 IF csr_get_ttl_rslt%NOTFOUND
1987 THEN
1988 l_Address_Data_Cnt := RPAD(' ',10,' ');
1989 ELSE
1990 l_Address_Data_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_03),'0999999999')));
1991 END IF;
1992 CLOSE csr_get_ttl_rslt;
1993 -- For Nuvos
1994 OPEN csr_get_eff_date(c_ext_rslt_id => l_ext_adi_rslt_id);
1995 FETCH csr_get_eff_date into l_eff_date_arg8;
1996 IF csr_get_eff_date%NOTFOUND
1997 THEN
1998 l_per_end_date := sysdate;
1999 ELSE
2000 l_per_end_date := fnd_date.canonical_to_date(l_eff_date_arg8);
2001 END IF;
2002 CLOSE csr_get_eff_date;
2003 ELSE
2004 l_Address_Data_Cnt := RPAD(' ',10,' ');
2005 END IF;
2006
2007
2008 --Salary History interface Count
2009
2010 IF l_ext_sahi_rslt_id IS NOT NULL THEN
2011 OPEN csr_get_ttl_rslt(c_ext_rslt_id => l_ext_sahi_rslt_id);
2012 FETCH csr_get_ttl_rslt INTO l_get_ttl_rslt;
2013 IF csr_get_ttl_rslt%NOTFOUND
2014 THEN
2015 l_Salary_Hist_Cnt := RPAD(' ',10,' ');
2016 l_Sal_hist_Nat_Pay_Cnt := RPAD(' ',16,' ');
2017 ELSE
2018 --
2019 IF l_get_ttl_rslt.val_01 IS NOT NULL THEN
2020 l_Salary_Hist_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_01),'0999999999')));
2021 ELSE
2022 l_Salary_Hist_Cnt := RPAD(' ',10,' ');
2023 END IF;
2024 IF l_get_ttl_rslt.val_02 IS NOT NULL THEN
2025
2026 l_total_amount := fnd_number.canonical_to_number(l_get_ttl_rslt.val_02);
2027 IF l_total_amount < 0 THEN
2028 l_Sal_hist_Nat_Pay_Cnt:=rtrim(ltrim(to_char(l_total_amount,'S099999999999.99')));
2029 ELSE
2030 l_Sal_hist_Nat_Pay_Cnt:=rtrim(ltrim(to_char(l_total_amount,'0999999999999.99')));
2031 END IF;
2032
2033 ELSE
2034 l_Sal_hist_Nat_Pay_Cnt := RPAD(' ',16,' ');
2035 END IF;
2036 --
2037 END IF;
2038 CLOSE csr_get_ttl_rslt;
2039 -- For Nuvos
2040 OPEN csr_get_eff_date(c_ext_rslt_id => l_ext_sahi_rslt_id);
2041 FETCH csr_get_eff_date into l_eff_date_arg8;
2042 IF csr_get_eff_date%NOTFOUND
2043 THEN
2044 l_per_end_date := sysdate;
2045 ELSE
2046 l_per_end_date := fnd_date.canonical_to_date(l_eff_date_arg8);
2047 END IF;
2048 CLOSE csr_get_eff_date;
2049
2050 ELSE
2051 l_Salary_Hist_Cnt := RPAD(' ',10,' ');
2052 l_Sal_hist_Nat_Pay_Cnt := RPAD(' ',16,' ');
2053 END IF;
2054
2055 debug(l_Salary_Hist_Cnt);
2056 debug(l_Sal_hist_Nat_Pay_Cnt);
2057 debug(l_ext_sahi_rslt_id);
2058
2059
2060 --Service History interface Count
2061 IF l_ext_sehi_rslt_id IS NOT NULL THEN
2062 OPEN csr_get_ttl_rslt(c_ext_rslt_id => l_ext_sehi_rslt_id);
2063 FETCH csr_get_ttl_rslt INTO l_get_ttl_rslt;
2064 IF csr_get_ttl_rslt%NOTFOUND
2065 THEN
2066 l_Service_Hist_Cnt := RPAD(' ',10,' ');
2067 ELSE
2068 l_Service_Hist_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_01),'0999999999')));
2069 END IF;
2070 CLOSE csr_get_ttl_rslt;
2071 -- For Nuvos
2072 OPEN csr_get_eff_date(c_ext_rslt_id => l_ext_sehi_rslt_id);
2073 FETCH csr_get_eff_date into l_eff_date_arg8;
2074 IF csr_get_eff_date%NOTFOUND
2075 THEN
2076 l_per_end_date := sysdate;
2077 ELSE
2078 l_per_end_date := fnd_date.canonical_to_date(l_eff_date_arg8);
2079 END IF;
2080 CLOSE csr_get_eff_date;
2081 ELSE
2082 l_Service_Hist_Cnt := RPAD(' ',10,' ');
2083 END IF;
2084 debug(l_Service_Hist_Cnt);
2085 debug(l_ext_sehi_rslt_id);
2086
2087 /*--Earning History interface Count
2088 -- commented for nuvos changes
2089 IF l_ext_ehi_rslt_id IS NOT NULL THEN
2090 OPEN csr_get_ttl_rslt(c_ext_rslt_id => l_ext_ehi_rslt_id);
2091 FETCH csr_get_ttl_rslt INTO l_get_ttl_rslt;
2092 IF csr_get_ttl_rslt%NOTFOUND
2093 THEN
2094 l_Earning_Hist_Cnt := RPAD(' ',10,' ');
2095 l_Earning_Tot_Cnt := RPAD(' ',16,' ');
2096 ELSE
2097 --
2098 IF l_get_ttl_rslt.val_01 IS NOT NULL THEN
2099 l_Earning_Hist_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_01),'0999999999')));
2100 ELSE
2101 l_Earning_Hist_Cnt := RPAD(' ',10,' ');
2102 END IF;
2103 IF l_get_ttl_rslt.val_02 IS NOT NULL THEN
2104
2105 l_total_amount := fnd_number.canonical_to_number(l_get_ttl_rslt.val_02);
2106 IF l_total_amount < 0 THEN
2107 l_Earning_Tot_Cnt:=rtrim(ltrim(to_char(l_total_amount,'S099999999999.99')));
2108 ELSE
2109 l_Earning_Tot_Cnt:=rtrim(ltrim(to_char(l_total_amount,'0999999999999.99')));
2110 END IF;
2111
2112 -- l_Earning_Tot_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_02),'0999999999999.99')));
2113 ELSE
2114 l_Earning_Tot_Cnt := RPAD(' ',16,' ');
2115 END IF;
2116 --
2117 END IF;
2118 CLOSE csr_get_ttl_rslt;
2119
2120 -- For Nuvos
2121 OPEN csr_get_eff_date(c_ext_rslt_id => l_ext_ehi_rslt_id);
2122 FETCH csr_get_eff_date into l_eff_date_arg8;
2123 IF csr_get_eff_date%NOTFOUND
2124 THEN
2125 l_per_end_date := sysdate;
2126 ELSE
2127 l_per_end_date := fnd_date.canonical_to_date(l_eff_date_arg8);
2128 END IF;
2129 CLOSE csr_get_eff_date;
2130 hr_utility.set_location('l_per_end_date: '||l_per_end_date,64);
2131 ELSE
2132 l_Earning_Hist_Cnt := RPAD(' ',10,' ');
2133 l_Earning_Tot_Cnt := RPAD(' ',16,' ');
2134 END IF;
2135
2136 debug(l_Earning_Hist_Cnt);
2137 debug(l_Earning_Tot_Cnt);
2138 debug(l_ext_ehi_rslt_id); */
2139
2140 --Earning History interface Count
2141 IF l_ext_ehi_rslt_id IS NOT NULL THEN
2142 OPEN csr_get_ern_ttl_rslt(c_ext_rslt_id => l_ext_ehi_rslt_id);
2143 FETCH csr_get_ern_ttl_rslt INTO l_get_ern_ttl_rslt;
2144 IF csr_get_ern_ttl_rslt%NOTFOUND
2145 THEN
2146 l_Pay_Hist_Cnt := RPAD(' ',10,' ');
2147 l_Pay_Tot_EARN_Cnt := RPAD(' ',16,' ');
2148 l_Pay_Tot_DEDS_Cnt := RPAD(' ',16,' ');
2149 ELSE
2150 --
2151 IF l_get_ern_ttl_rslt.payhcnt IS NOT NULL THEN
2152 l_Pay_Hist_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ern_ttl_rslt.payhcnt),'0999999999')));
2153 ELSE
2154 l_Pay_Hist_Cnt := RPAD(' ',10,' ');
2155 END IF;
2156 IF l_get_ern_ttl_rslt.pearntot IS NOT NULL THEN
2157
2158 l_total_amount := fnd_number.canonical_to_number(l_get_ern_ttl_rslt.pearntot);
2159 IF l_total_amount < 0 THEN
2160 l_Pay_Tot_EARN_Cnt:=rtrim(ltrim(to_char(l_total_amount,'S099999999999.99')));
2161 ELSE
2162 l_Pay_Tot_EARN_Cnt:=rtrim(ltrim(to_char(l_total_amount,'0999999999999.99')));
2163 END IF;
2164
2165 -- l_Earning_Tot_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_02),'0999999999999.99')));
2166 ELSE
2167 l_Pay_Tot_EARN_Cnt := RPAD(' ',16,' ');
2168 END IF;
2169 IF l_get_ern_ttl_rslt.pdedstot IS NOT NULL THEN
2170
2171 l_total_amount := fnd_number.canonical_to_number(l_get_ern_ttl_rslt.pdedstot);
2172 IF l_total_amount < 0 THEN
2173 l_Pay_Tot_DEDS_Cnt:=rtrim(ltrim(to_char(l_total_amount,'S099999999999.99')));
2174 ELSE
2175 l_Pay_Tot_DEDS_Cnt:=rtrim(ltrim(to_char(l_total_amount,'0999999999999.99')));
2176 END IF;
2177
2178 -- l_Earning_Tot_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_02),'0999999999999.99')));
2179 ELSE
2180 l_Pay_Tot_DEDS_Cnt := RPAD(' ',16,' ');
2181 END IF;
2182 --
2183 END IF;
2184 CLOSE csr_get_ern_ttl_rslt;
2185
2186 -- For Nuvos
2187 OPEN csr_get_eff_date(c_ext_rslt_id => l_ext_ehi_rslt_id);
2188 FETCH csr_get_eff_date into l_eff_date_arg8;
2189 IF csr_get_eff_date%NOTFOUND
2190 THEN
2191 l_per_end_date := sysdate;
2192 ELSE
2193 hr_utility.set_location('l_eff_date_arg8'|| l_eff_date_arg8,31);
2194 l_per_end_date := fnd_date.canonical_to_date(l_eff_date_arg8);
2195 END IF;
2196 CLOSE csr_get_eff_date;
2197 hr_utility.set_location('l_per_end_date: '||l_per_end_date,64);
2198 ELSE
2199 l_Pay_Hist_Cnt := RPAD(' ',10,' ');
2200 l_Pay_Tot_EARN_Cnt := RPAD(' ',16,' ');
2201 l_Pay_Tot_DEDS_Cnt := RPAD(' ',16,' ');
2202 END IF;
2203
2204 debug(l_Pay_Hist_Cnt);
2205 debug(l_Pay_Tot_EARN_Cnt);
2206 debug(l_Pay_Tot_DEDS_Cnt);
2207 debug(l_ext_ehi_rslt_id);
2208
2209
2210 --Bonus History interface Count
2211
2212 IF l_ext_bhi_rslt_id IS NOT NULL THEN
2213 OPEN csr_get_ttl_rslt(c_ext_rslt_id => l_ext_bhi_rslt_id);
2214 FETCH csr_get_ttl_rslt INTO l_get_ttl_rslt;
2215 IF csr_get_ttl_rslt%NOTFOUND
2216 THEN
2217 l_Bonus_Hist_Cnt := RPAD(' ',10,' ');
2218 l_Bonus_Tot_Cnt := RPAD(' ',16,' ');
2219 ELSE
2220 --
2221 IF l_get_ttl_rslt.val_01 IS NOT NULL THEN
2222 l_Bonus_Hist_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_01),'0999999999')));
2223 ELSE
2224 l_Bonus_Hist_Cnt := RPAD(' ',10,' ');
2225 END IF;
2226 IF l_get_ttl_rslt.val_02 IS NOT NULL THEN
2227
2228 l_total_amount := fnd_number.canonical_to_number(l_get_ttl_rslt.val_02);
2229 IF l_total_amount < 0 THEN
2230 l_Bonus_Tot_Cnt:=rtrim(ltrim(to_char(l_total_amount,'S099999999999.99')));
2231 ELSE
2232 l_Bonus_Tot_Cnt:=rtrim(ltrim(to_char(l_total_amount,'0999999999999.99')));
2233 END IF;
2234
2235 -- l_Bonus_Tot_Cnt:=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_02),'0999999999999.99')));
2236 ELSE
2237 l_Bonus_Tot_Cnt := RPAD(' ',16,' ');
2238 END IF;
2239 --
2240 END IF;
2241 CLOSE csr_get_ttl_rslt;
2242 -- For Nuvos
2243 OPEN csr_get_eff_date(c_ext_rslt_id => l_ext_bhi_rslt_id);
2244 FETCH csr_get_eff_date into l_eff_date_arg8;
2245 IF csr_get_eff_date%NOTFOUND
2246 THEN
2247 l_per_end_date := sysdate;
2248 ELSE
2249 l_per_end_date := fnd_date.canonical_to_date(l_eff_date_arg8);
2250 END IF;
2251 CLOSE csr_get_eff_date;
2252
2253 ELSE
2254 l_Bonus_Hist_Cnt := RPAD(' ',10,' ');
2255 l_Bonus_Tot_Cnt := RPAD(' ',16,' ');
2256 END IF;
2257
2258 debug(l_Bonus_Hist_Cnt);
2259 debug(l_Bonus_Tot_Cnt);
2260 debug(l_ext_bhi_rslt_id);
2261
2262 --WPS History interface Count
2263
2264 IF l_ext_wps_rslt_id IS NOT NULL THEN
2265 OPEN csr_get_ttl_rslt(c_ext_rslt_id => l_ext_wps_rslt_id);
2266 FETCH csr_get_ttl_rslt INTO l_get_ttl_rslt;
2267 IF csr_get_ttl_rslt%NOTFOUND
2268 THEN
2269 l_WPS_Hist_Cnt := RPAD(' ',10,' ');
2270 l_WPS_Tot_Cnt := RPAD(' ',16,' ');
2271 ELSE
2272 --
2273 IF l_get_ttl_rslt.val_01 IS NOT NULL THEN
2274 l_WPS_Hist_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_01),'0999999999')));
2275 ELSE
2276 l_WPS_Hist_Cnt := RPAD(' ',10,' ');
2277 END IF;
2278 IF l_get_ttl_rslt.val_02 IS NOT NULL THEN
2279
2280 l_total_amount := fnd_number.canonical_to_number(l_get_ttl_rslt.val_02);
2281 IF l_total_amount < 0 THEN
2282 l_WPS_Tot_Cnt:=rtrim(ltrim(to_char(l_total_amount,'S099999999999.99')));
2283 ELSE
2284 l_WPS_Tot_Cnt:=rtrim(ltrim(to_char(l_total_amount,'0999999999999.99')));
2285 END IF;
2286
2287 -- l_WPS_Tot_Cnt:=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_02),'0999999999999.99')));
2288 ELSE
2289 l_WPS_Tot_Cnt := RPAD(' ',16,' ');
2290 END IF;
2291 --
2292 END IF;
2293 CLOSE csr_get_ttl_rslt;
2294 -- For Nuvos
2295 OPEN csr_get_eff_date(c_ext_rslt_id => l_ext_wps_rslt_id);
2296 FETCH csr_get_eff_date into l_eff_date_arg8;
2297 IF csr_get_eff_date%NOTFOUND
2298 THEN
2299 l_per_end_date := sysdate;
2300 ELSE
2301 l_per_end_date := fnd_date.canonical_to_date(l_eff_date_arg8);
2302 END IF;
2303 CLOSE csr_get_eff_date;
2304
2305 ELSE
2306 l_WPS_Hist_Cnt := RPAD(' ',10,' ');
2307 l_WPS_Tot_Cnt := RPAD(' ',16,' ');
2308 END IF;
2309
2310 debug(l_WPS_Hist_Cnt);
2311 debug(l_WPS_Tot_Cnt);
2312 debug(l_ext_wps_rslt_id);
2313
2314 --Short-Time Hours ( Accumulated ) History interface Count
2315
2316 IF l_ext_sthai_rslt_id IS NOT NULL THEN
2317 OPEN csr_get_ttl_rslt(c_ext_rslt_id => l_ext_sthai_rslt_id);
2318 FETCH csr_get_ttl_rslt INTO l_get_ttl_rslt;
2319 IF csr_get_ttl_rslt%NOTFOUND
2320 THEN
2321 l_STA_Hist_Cnt := RPAD(' ',10,' ');
2322 l_STA_Tot_AdjHrs_Cnt := RPAD(' ',16,' ');
2323 ELSE
2324 --
2325 IF l_get_ttl_rslt.val_01 IS NOT NULL THEN
2326 l_STA_Hist_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_01),'0999999999')));
2327 ELSE
2328 l_STA_Hist_Cnt := RPAD(' ',10,' ');
2329 END IF;
2330 IF l_get_ttl_rslt.val_02 IS NOT NULL THEN
2331 l_STA_Tot_AdjHrs_Cnt:=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_02),'S099999999999D99')));
2332 ELSE
2333 l_STA_Tot_AdjHrs_Cnt := RPAD(' ',16,' ');
2334 END IF;
2335 --
2336 END IF;
2337 CLOSE csr_get_ttl_rslt;
2338 -- For Nuvos
2339 OPEN csr_get_eff_date(c_ext_rslt_id => l_ext_sthai_rslt_id);
2340 FETCH csr_get_eff_date into l_eff_date_arg8;
2341 IF csr_get_eff_date%NOTFOUND
2342 THEN
2343 l_per_end_date := sysdate;
2344 ELSE
2345 l_per_end_date := fnd_date.canonical_to_date(l_eff_date_arg8);
2346 END IF;
2347 CLOSE csr_get_eff_date;
2348
2349 ELSE
2350 l_STA_Hist_Cnt := RPAD(' ',10,' ');
2351 l_STA_Tot_AdjHrs_Cnt := RPAD(' ',16,' ');
2352 END IF;
2353
2354 debug(l_STA_Hist_Cnt);
2355 debug(l_STA_Tot_AdjHrs_Cnt);
2356 debug(l_ext_sthai_rslt_id);
2357
2358 --Short-Time Hours ( Single ) History interface Count
2359
2360 IF l_ext_sthi_rslt_id IS NOT NULL THEN
2361 OPEN csr_get_ttl_rslt(c_ext_rslt_id => l_ext_sthi_rslt_id);
2362 FETCH csr_get_ttl_rslt INTO l_get_ttl_rslt;
2363 IF csr_get_ttl_rslt%NOTFOUND
2364 THEN
2365 l_STS_Hist_Cnt := RPAD(' ',10,' ');
2366 l_STS_Tot_AdjHrs_Cnt := RPAD(' ',16,' ');
2367 ELSE
2368 --
2369 IF l_get_ttl_rslt.val_01 IS NOT NULL THEN
2370 l_STS_Hist_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_01),'0999999999')));
2371 ELSE
2372 l_STS_Hist_Cnt := RPAD(' ',10,' ');
2373 END IF;
2374 IF l_get_ttl_rslt.val_02 IS NOT NULL THEN
2375 l_STS_Tot_AdjHrs_Cnt:=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_02),'S099999999999D99')));
2376 ELSE
2377 l_STS_Tot_AdjHrs_Cnt := RPAD(' ',16,' ');
2378 END IF;
2379 --
2380 END IF;
2381 CLOSE csr_get_ttl_rslt;
2382 -- For Nuvos
2383 OPEN csr_get_eff_date(c_ext_rslt_id => l_ext_sthi_rslt_id);
2384 FETCH csr_get_eff_date into l_eff_date_arg8;
2385 IF csr_get_eff_date%NOTFOUND
2386 THEN
2387 l_per_end_date := sysdate;
2388 ELSE
2389 l_per_end_date := fnd_date.canonical_to_date(l_eff_date_arg8);
2390 END IF;
2391 CLOSE csr_get_eff_date;
2392
2393 ELSE
2394 l_STS_Hist_Cnt := RPAD(' ',10,' ');
2395 l_STS_Tot_AdjHrs_Cnt := RPAD(' ',16,' ');
2396 END IF;
2397
2398 debug(l_STS_Hist_Cnt);
2399 debug(l_STS_Tot_AdjHrs_Cnt);
2400 debug(l_ext_sthi_rslt_id);
2401
2402 --Allowance History interface Count
2403
2404 IF l_ext_ahi_rslt_id IS NOT NULL THEN
2405 OPEN csr_get_ttl_rslt(c_ext_rslt_id => l_ext_ahi_rslt_id);
2406 FETCH csr_get_ttl_rslt INTO l_get_ttl_rslt;
2407 IF csr_get_ttl_rslt%NOTFOUND
2408 THEN
2409 l_Allowance_Hist_Cnt := RPAD(' ',10,' ');
2410 l_Allowance_Tot_Cnt := RPAD(' ',16,' ');
2411 ELSE
2412 --
2413 IF l_get_ttl_rslt.val_01 IS NOT NULL THEN
2414 l_Allowance_Hist_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_01),'0999999999')));
2415 ELSE
2416 l_Allowance_Hist_Cnt := RPAD(' ',10,' ');
2417 END IF;
2418 IF l_get_ttl_rslt.val_02 IS NOT NULL THEN
2419
2420 l_total_amount := fnd_number.canonical_to_number(l_get_ttl_rslt.val_02);
2421 IF l_total_amount < 0 THEN
2422 l_Allowance_Tot_Cnt:=rtrim(ltrim(to_char(l_total_amount,'S099999999999.99')));
2423 ELSE
2424 l_Allowance_Tot_Cnt:=rtrim(ltrim(to_char(l_total_amount,'0999999999999.99')));
2425 END IF;
2426
2427 -- l_Allowance_Tot_Cnt:=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_02),'0999999999999.99')));
2428 ELSE
2429 l_Allowance_Tot_Cnt := RPAD(' ',16,' ');
2430 END IF;
2431 --
2432 END IF;
2433 CLOSE csr_get_ttl_rslt;
2434 -- For Nuvos
2435 OPEN csr_get_eff_date(c_ext_rslt_id => l_ext_ahi_rslt_id);
2436 FETCH csr_get_eff_date into l_eff_date_arg8;
2437 IF csr_get_eff_date%NOTFOUND
2438 THEN
2439 l_per_end_date := sysdate;
2440 ELSE
2441 l_per_end_date := fnd_date.canonical_to_date(l_eff_date_arg8);
2442 END IF;
2443 CLOSE csr_get_eff_date;
2444
2445 ELSE
2446 l_Allowance_Hist_Cnt := RPAD(' ',10,' ');
2447 l_Allowance_Tot_Cnt := RPAD(' ',16,' ');
2448 END IF;
2449
2450 debug(l_Allowance_Hist_Cnt);
2451 debug(l_Allowance_Tot_Cnt);
2452 debug(l_ext_ahi_rslt_id);
2453
2454
2455 --Part-Time Hours ( Single ) History interface Count
2456
2457 IF l_ext_pthi_rslt_id IS NOT NULL THEN
2458 OPEN csr_get_ttl_rslt(c_ext_rslt_id => l_ext_pthi_rslt_id);
2459 FETCH csr_get_ttl_rslt INTO l_get_ttl_rslt;
2460 IF csr_get_ttl_rslt%NOTFOUND
2461 THEN
2462 l_PTH_Hist_Cnt := RPAD(' ',10,' ');
2463 l_Tot_Part_Time_Hours_Cnt := RPAD(' ',16,' ');
2464 ELSE
2465 --
2466 IF l_get_ttl_rslt.val_01 IS NOT NULL THEN
2467 l_PTH_Hist_Cnt :=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_01),'0999999999')));
2468 ELSE
2469 l_PTH_Hist_Cnt := RPAD(' ',10,' ');
2470 END IF;
2471 IF l_get_ttl_rslt.val_02 IS NOT NULL THEN
2472 l_Tot_Part_Time_Hours_Cnt:=rtrim(ltrim(to_char(fnd_number.canonical_to_number(l_get_ttl_rslt.val_02),'S099999999999D99')));
2473 ELSE
2474 l_Tot_Part_Time_Hours_Cnt := RPAD(' ',16,' ');
2475 END IF;
2476 --
2477 END IF;
2478 CLOSE csr_get_ttl_rslt;
2479 -- For Nuvos
2480 OPEN csr_get_eff_date(c_ext_rslt_id => l_ext_pthi_rslt_id);
2481 FETCH csr_get_eff_date into l_eff_date_arg8;
2482 IF csr_get_eff_date%NOTFOUND
2483 THEN
2484 l_per_end_date := sysdate;
2485 ELSE
2486 l_per_end_date := fnd_date.canonical_to_date(l_eff_date_arg8);
2487 END IF;
2488 CLOSE csr_get_eff_date;
2489
2490 ELSE
2491 l_PTH_Hist_Cnt := RPAD(' ',10,' ');
2492 l_Tot_Part_Time_Hours_Cnt := RPAD(' ',16,' ');
2493 END IF;
2494
2495 debug(l_PTH_Hist_Cnt);
2496 debug(l_Tot_Part_Time_Hours_Cnt);
2497 debug(l_ext_pthi_rslt_id);
2498
2499
2500 -----------
2501
2502 OPEN csr_ext_dfn_id(c_extract_name => 'PQP GB PenServer Periodic Changes Interface - Basic Data');
2503 FETCH csr_ext_dfn_id INTO l_ext_dfn_id;
2504 CLOSE csr_ext_dfn_id;
2505
2506 -- Get the run date
2507 OPEN csr_get_run_date(c_ext_dfn_id => l_ext_dfn_id
2508 ,c_business_group_id => p_business_group_id);
2509 FETCH csr_get_run_date INTO l_run_date,g_output_name;
2510 CLOSE csr_get_run_date;
2511
2512
2513 IF p_extract_type = '3CUT' THEN
2514 l_cntrl_tot(1).seq_num := '001';
2515 ELSE
2516 IF g_output_name IS NULL THEN
2517 l_cntrl_tot(1).seq_num := '002';
2518 ELSE
2519 IF p_parent_request_id IS NULL THEN
2520 l_cntrl_tot(1).seq_num := rtrim(ltrim(to_char(fnd_number.canonical_to_number(substr(g_output_name,INSTR(g_output_name,'.')+1))+1,'099')));
2521 ELSE
2522 l_cntrl_tot(1).seq_num := rtrim(ltrim(to_char(fnd_number.canonical_to_number(substr(g_output_name,INSTR(g_output_name,'.')+1)),'099')));
2523 END IF;
2524 END IF;
2525 END IF;
2526
2527 ------------
2528 hr_utility.set_location('l_year_close1: ' || l_year_close , 11);
2529 hr_utility.set_location('p_year_end_close: ' || p_year_end_close , 11);
2530
2531 /* For Nuvps */
2532 IF p_year_end_close = 'Yes'
2533 THEN
2534
2535 IF l_per_end_date between to_date('01-04-'||to_char(l_per_end_date,'YYYY'),'DD-MM-YYYY') and to_date('31-12-'||to_char(l_per_end_date,'YYYY'),'DD-MM-YYYY')
2536 THEN
2537 l_year_close := to_number(to_char(l_per_end_date,'yyyy'));
2538
2539 ELSE
2540
2541 l_year_close := to_number(to_char(l_per_end_date,'yyyy')) -1;
2542
2543 END IF;
2544 ELSE
2545 l_year_close := RPAD(' ' ,4,' ');
2546
2547 END IF;
2548
2549 l_per_end_date := last_day(l_per_end_date);
2550 hr_utility.set_location('l_per_end_date: ' || l_per_end_date, 20);
2551 hr_utility.set_location('l_year_close6: ' || l_year_close , 11);
2552
2553 l_Earning_Hist_Cnt := RPAD(' ',10,' ');
2554 l_Earning_Tot_Cnt := RPAD(' ',16,' ');
2555
2556
2557
2558 l_cntrl_tot(1).pay_point :=RPAD(nvl(l_pay_point,' ') ,6,' ');
2559 l_cntrl_tot(1).file_extract_date :=to_char(l_ext_date, 'DD/MM/YYYY HH24:MI');
2560 --Not done
2561 -- l_cntrl_tot(1).seq_num :=RPAD(' ',3,' ');
2562 --This one is related to Basic Data interface
2563 l_cntrl_tot(1).basic_cnt :=l_Basic_Data_Cnt;
2564 --This one is related to Service History interface
2565 l_cntrl_tot(1).serv_hist_cnt :=l_Service_Hist_Cnt;
2566 --These two are related to Salary History interface
2567 l_cntrl_tot(1).sal_hist_cnt :=l_Salary_Hist_Cnt;
2568 l_cntrl_tot(1).sal_hist_tot_national_pay :=l_Sal_hist_Nat_Pay_Cnt;
2569 --This one is related to Address data interface
2570 l_cntrl_tot(1).addr_data_tot_rec :=l_Address_Data_Cnt;
2571 --These two are related to Earnings History interface,Which is not done for this QA drop
2572 l_cntrl_tot(1).earn_hist_cnt :=l_Earning_Hist_Cnt;
2573 l_cntrl_tot(1).earn_hist_tot_WPS :=l_Earning_Tot_Cnt;
2574
2575 --All below fields are not either supported or building for this drop,so hardcoded the values
2576
2577 --These two are related to Allowance History interface
2578 l_cntrl_tot(1).allw_hist_rec_cnt :=l_Allowance_Hist_Cnt;
2579 l_cntrl_tot(1).allw_hist_tot_allw_rate :=l_Allowance_Tot_Cnt;
2580 --These two are related to Bonus History interface
2581 l_cntrl_tot(1).bonus_hist_rec_cnt := l_Bonus_Hist_Cnt;
2582 l_cntrl_tot(1).bonus_hist_tot_bonus_amt := l_Bonus_Tot_Cnt;
2583 --These two are related to WPS Contributions History interface
2584 l_cntrl_tot(1).WPS_contrbt_hist_rec_cnt := l_WPS_Hist_Cnt;
2585 l_cntrl_tot(1).WPS_contrbt_hist_tot_perc := l_WPS_Tot_Cnt;
2586 --This left blank ,because we are not building AVC History interface
2587 l_cntrl_tot(1).AVC_hist_rec_cnt :=RPAD(' ' ,10,' ');
2588 l_cntrl_tot(1).EECONT_tot :=RPAD(' ' ,16,' ');
2589 --This left blank ,because we are not building Transfer in and other benefits interface.
2590 l_cntrl_tot(1).other_benef_rec_cnt :=RPAD(' ' ,10,' ');
2591 l_cntrl_tot(1).PUP_tot :=RPAD(' ' ,16,' ');
2592 --These two are related to Part-time Hours History interface,Which is not done for this QA drop
2593 l_cntrl_tot(1).prt_tm_hr_hist_rec_cnt :=l_PTH_Hist_Cnt;
2594 l_cntrl_tot(1).prt_tm_hr_hist_tot_pthrs :=l_Tot_Part_Time_Hours_Cnt;
2595 --These two are related to Short-time Hours History (Single record)
2596 l_cntrl_tot(1).srt_tm_hr_hist_sing_rec_cnt := l_STS_Hist_Cnt;
2597 l_cntrl_tot(1).srt_tm_hr_hist_sing_tot_hr_var := l_STS_Tot_AdjHrs_Cnt;
2598 --These two are related to Short-time Hours History (Accumulated record)
2599 l_cntrl_tot(1).srt_tm_hr_hist_accu_rec_cnt := l_STA_Hist_Cnt;
2600 l_cntrl_tot(1).srt_tm_hr_hist_accu_tot_hr_var := l_STA_Tot_AdjHrs_Cnt;
2601 --This left blank ,because we are not building Dated Event Details interface
2602 l_cntrl_tot(1).event_det_tot_rec :=RPAD(' ' ,10,' ');
2603 l_cntrl_tot(1).event_det_tot_amt :=RPAD(' ' ,16,' ');
2604 --This left blank ,because we are not building Remarks interface interface
2605 l_cntrl_tot(1).remarks_interface_tot_rec :=RPAD(' ' ,10,' ');
2606 --This left blank ,because we are not building Beneficiary Details interface
2607 l_cntrl_tot(1).benef_det_tot_rec :=RPAD(' ' ,10,' ');
2608 -- Nuvos Pay file
2609 l_cntrl_tot(1).pay_hist_cnt :=l_Pay_Hist_Cnt;
2610 l_cntrl_tot(1).pay_hist_tot_EARN :=l_Pay_Tot_EARN_Cnt;
2611 l_cntrl_tot(1).pay_hist_tot_DEDS :=l_Pay_Tot_DEDS_Cnt;
2612 -- For Nuvos
2613 l_cntrl_tot(1).year_end_close :=l_year_close;
2614 l_cntrl_tot(1).pay_per_end_date :=substr(to_char(l_per_end_date, 'DD/MM/YYYY HH24:MI'),1,10);
2615
2616
2617 /* --These two are related to Earnings History interface,Which is not done for this QA drop
2618 l_cntrl_tot(1).earn_hist_cnt :=rtrim(ltrim(to_char(0, '0999999999')));
2619 l_cntrl_tot(1).earn_hist_tot_WPS :=rtrim(ltrim(to_char(0, '0999999999999999V99')));
2620 --These two are related to Allowance History interface,Which is not done for this QA drop
2621 l_cntrl_tot(1).allw_hist_rec_cnt :=rtrim(ltrim(to_char(0, '0999999999')));
2622 l_cntrl_tot(1).allw_hist_tot_allw_rate :=rtrim(ltrim(to_char(0, '0999999999999999V99')));
2623 --These two are related to Allowance History interface,Which is not done for this QA drop
2624 l_cntrl_tot(1).bonus_hist_rec_cnt :=rtrim(ltrim(to_char(0, '0999999999')));
2625 l_cntrl_tot(1).bonus_hist_tot_bonus_amt :=rtrim(ltrim(to_char(0, '0999999999999999V99')));
2626 --These two are related to WPS Contributions History interface,Which is not done for this QA drop
2627 l_cntrl_tot(1).WPS_contrbt_hist_rec_cnt :=rtrim(ltrim(to_char(0, '0999999999')));
2628 l_cntrl_tot(1).WPS_contrbt_hist_tot_perc :=rtrim(ltrim(to_char(0, '0999999999999999V99')));
2629 --This left blank ,because we are not building AVC History interface
2630 l_cntrl_tot(1).AVC_hist_rec_cnt :=rtrim(ltrim(to_char(0, '0999999999')));
2631 l_cntrl_tot(1).EECONT_tot :=rtrim(ltrim(to_char(0, '0999999999999999V99')));
2632 --This left blank ,because we are not building Transfer in and other benefits interface.
2633 l_cntrl_tot(1).other_benef_rec_cnt :=rtrim(ltrim(to_char(0, '0999999999')));
2634 l_cntrl_tot(1).PUP_tot :=rtrim(ltrim(to_char(0, '0999999999999999V99')));
2635 --These two are related to Part-time Hours History interface,Which is not done for this QA drop
2636 l_cntrl_tot(1).prt_tm_hr_hist_rec_cnt :=rtrim(ltrim(to_char(0, '0999999999')));
2637 l_cntrl_tot(1).prt_tm_hr_hist_tot_pthrs :=rtrim(ltrim(to_char(0, '0999999999999999')));
2638 --These two are related to Short-time Hours History (Single record),Which is not done for this QA drop
2639 l_cntrl_tot(1).srt_tm_hr_hist_sing_rec_cnt :=rtrim(ltrim(to_char(0, '0999999999')));
2640 l_cntrl_tot(1).srt_tm_hr_hist_sing_tot_hr_var :=rtrim(ltrim(to_char(0, '0999999999999999V99')));
2641 --These two are related to Short-time Hours History (Accumulated record),Which is not done for this QA drop
2642 l_cntrl_tot(1).srt_tm_hr_hist_accu_rec_cnt :=rtrim(ltrim(to_char(0, '0999999999')));
2643 l_cntrl_tot(1).srt_tm_hr_hist_accu_tot_hr_var :=rtrim(ltrim(to_char(0, '0999999999999999V99')));
2644 --This left blank ,because we are not building Dated Event Details interface
2645 l_cntrl_tot(1).event_det_tot_rec :=rtrim(ltrim(to_char(0, '0999999999')));
2646 l_cntrl_tot(1).event_det_tot_amt :=rtrim(ltrim(to_char(0, '0999999999999999V99')));
2647 --This left blank ,because we are not building Remarks interface interface
2648 l_cntrl_tot(1).remarks_interface_tot_rec :=rtrim(ltrim(to_char(0, '0999999999')));
2649 --This left blank ,because we are not building Beneficiary Details interface
2650 l_cntrl_tot(1).benef_det_tot_rec :=rtrim(ltrim(to_char(0, '0999999999'))); */
2651
2652 debug ('Before writing into file');
2653 -- insert control totals information into output file
2654 fnd_file.put_line(fnd_file.output,
2655 l_cntrl_tot(1).pay_point ||
2656 l_cntrl_tot(1).file_extract_date ||
2657 l_cntrl_tot(1).seq_num ||
2658 l_cntrl_tot(1).basic_cnt ||
2659 l_cntrl_tot(1).serv_hist_cnt ||
2660 l_cntrl_tot(1).earn_hist_cnt ||
2661 l_cntrl_tot(1).earn_hist_tot_WPS ||
2662 l_cntrl_tot(1).sal_hist_cnt ||
2663 l_cntrl_tot(1).sal_hist_tot_national_pay ||
2664 l_cntrl_tot(1).allw_hist_rec_cnt ||
2665 l_cntrl_tot(1).allw_hist_tot_allw_rate ||
2666 l_cntrl_tot(1).bonus_hist_rec_cnt ||
2667 l_cntrl_tot(1).bonus_hist_tot_bonus_amt ||
2668 l_cntrl_tot(1).WPS_contrbt_hist_rec_cnt ||
2669 l_cntrl_tot(1).WPS_contrbt_hist_tot_perc ||
2670 l_cntrl_tot(1).AVC_hist_rec_cnt ||
2671 l_cntrl_tot(1).EECONT_tot ||
2672 l_cntrl_tot(1).other_benef_rec_cnt ||
2673 l_cntrl_tot(1).PUP_tot ||
2674 l_cntrl_tot(1).prt_tm_hr_hist_rec_cnt ||
2675 l_cntrl_tot(1).prt_tm_hr_hist_tot_pthrs ||
2676 l_cntrl_tot(1).srt_tm_hr_hist_sing_rec_cnt ||
2677 l_cntrl_tot(1).srt_tm_hr_hist_sing_tot_hr_var ||
2678 l_cntrl_tot(1).srt_tm_hr_hist_accu_rec_cnt ||
2679 l_cntrl_tot(1).srt_tm_hr_hist_accu_tot_hr_var ||
2680 l_cntrl_tot(1).event_det_tot_rec ||
2681 l_cntrl_tot(1).event_det_tot_amt ||
2682 l_cntrl_tot(1).remarks_interface_tot_rec ||
2683 l_cntrl_tot(1).addr_data_tot_rec ||
2684 l_cntrl_tot(1).benef_det_tot_rec ||
2685 l_cntrl_tot(1).pay_hist_cnt ||
2686 l_cntrl_tot(1).pay_hist_tot_EARN ||
2687 l_cntrl_tot(1).pay_hist_tot_DEDS ||
2688 l_cntrl_tot(1).year_end_close || -- for nuvos
2689 l_cntrl_tot(1).pay_per_end_date);
2690
2691
2692 debug(' file content : ' || l_cntrl_tot(1).pay_point ||
2693 l_cntrl_tot(1).file_extract_date ||
2694 l_cntrl_tot(1).seq_num ||
2695 l_cntrl_tot(1).basic_cnt ||
2696 l_cntrl_tot(1).serv_hist_cnt ||
2697 l_cntrl_tot(1).earn_hist_cnt ||
2698 l_cntrl_tot(1).earn_hist_tot_WPS ||
2699 l_cntrl_tot(1).sal_hist_cnt ||
2700 l_cntrl_tot(1).sal_hist_tot_national_pay ||
2701 l_cntrl_tot(1).allw_hist_rec_cnt ||
2702 l_cntrl_tot(1).allw_hist_tot_allw_rate ||
2703 l_cntrl_tot(1).bonus_hist_rec_cnt ||
2704 l_cntrl_tot(1).bonus_hist_tot_bonus_amt ||
2705 l_cntrl_tot(1).WPS_contrbt_hist_rec_cnt ||
2706 l_cntrl_tot(1).WPS_contrbt_hist_tot_perc ||
2707 l_cntrl_tot(1).AVC_hist_rec_cnt ||
2708 l_cntrl_tot(1).EECONT_tot ||
2709 l_cntrl_tot(1).other_benef_rec_cnt ||
2710 l_cntrl_tot(1).PUP_tot ||
2711 l_cntrl_tot(1).prt_tm_hr_hist_rec_cnt ||
2712 l_cntrl_tot(1).prt_tm_hr_hist_tot_pthrs ||
2713 l_cntrl_tot(1).srt_tm_hr_hist_sing_rec_cnt ||
2714 l_cntrl_tot(1).srt_tm_hr_hist_sing_tot_hr_var ||
2715 l_cntrl_tot(1).srt_tm_hr_hist_accu_rec_cnt ||
2716 l_cntrl_tot(1).srt_tm_hr_hist_accu_tot_hr_var ||
2717 l_cntrl_tot(1).event_det_tot_rec ||
2718 l_cntrl_tot(1).event_det_tot_amt ||
2719 l_cntrl_tot(1).remarks_interface_tot_rec ||
2720 l_cntrl_tot(1).addr_data_tot_rec ||
2721 l_cntrl_tot(1).benef_det_tot_rec ||
2722 l_cntrl_tot(1).pay_hist_cnt ||
2723 l_cntrl_tot(1).pay_hist_tot_EARN ||
2724 l_cntrl_tot(1).pay_hist_tot_DEDS ||
2725 l_cntrl_tot(1).year_end_close || -- for nuvos
2726 l_cntrl_tot(1).pay_per_end_date);
2727
2728
2729 debug_exit(l_proc_name);
2730 EXCEPTION
2731 WHEN OTHERS THEN
2732 debug_exit(' Error in '||l_proc_name);
2733 RAISE;
2734 END Get_Penserver_CntrlTtl_Process;
2735
2736 -- ----------------------------------------------------------------------------
2737 -- |--------------------------------< employer_code >-------------------------|
2738 -- ----------------------------------------------------------------------------
2739
2740 FUNCTION employer_code
2741 (p_business_group_id NUMBER
2742 ,p_effective_date DATE
2743 ,p_assignment_id NUMBER
2744 ) RETURN VARCHAR2
2745 IS
2746 -- Cursor to get assignment details
2747 CURSOR csr_get_org_id(c_basic_date DATE)
2748 IS
2749 SELECT organization_id
2750 FROM per_all_assignments_f
2751 WHERE assignment_id = p_assignment_id
2752 AND c_basic_date BETWEEN effective_start_date
2753 AND effective_end_date;
2754
2755 -- Cursor to get employer code
2756 CURSOR csr_get_emp_code (c_organization_id NUMBER)
2757 IS
2758 SELECT org_information1
2759 FROM hr_organization_information
2760 WHERE organization_id = c_organization_id
2761 AND org_information_context = 'PQP_GB_PENSERV_REPORTING_INFO';
2762
2763 l_proc_name VARCHAR2(61):=
2764 g_proc_name||'employer_code';
2765
2766 l_org_id NUMBER;
2767 l_employer_code hr_organization_information.org_information1%TYPE;
2768 l_value NUMBER;
2769 --115.85
2770 l_basic_date DATE;
2771
2772 --115.87/115.88:Bug 7291713: Start
2773 CURSOR csr_get_bas_ext_dfn_id
2774 IS
2775 SELECT ext_dfn_id
2776 FROM BEN_EXT_DFN
2777 WHERE name = 'PQP GB PenServer Periodic Changes Interface - Basic Data'
2778 AND legislation_code ='GB';
2779
2780 CURSOR csr_get_max_asg_end_date
2781 IS
2782 SELECT max(effective_end_date)
2783 FROM per_all_assignments_f
2784 WHERE assignment_id = p_assignment_id;
2785
2786 l_max_asg_end_date DATE;
2787 l_bas_ext_dfn_id NUMBER;
2788 --115.87/115.88:Bug 7291713: Stop
2789
2790 BEGIN
2791 --
2792 debug_enter(l_proc_name);
2793 -- 115.85
2794
2795 --115.88:Bug 7291713: Start
2796 OPEN csr_get_bas_ext_dfn_id;
2797 FETCH csr_get_bas_ext_dfn_id INTO l_bas_ext_dfn_id;
2798 CLOSE csr_get_bas_ext_dfn_id;
2799
2800 debug('l_bas_ext_dfn_id: '|| l_bas_ext_dfn_id);
2801 debug('ben_ext_thread.g_ext_dfn_id: '|| ben_ext_thread.g_ext_dfn_id);
2802
2803 IF l_bas_ext_dfn_id = ben_ext_thread.g_ext_dfn_id
2804 --115.88:Bug 7291713: Stop
2805 THEN
2806
2807 --115.87:Bug 7291713: Start
2808 OPEN csr_get_max_asg_end_date;
2809 FETCH csr_get_max_asg_end_date INTO l_max_asg_end_date;
2810 CLOSE csr_get_max_asg_end_date;
2811
2812 debug('ben_ext_person.g_effective_date: '|| ben_ext_person.g_effective_date);
2813
2814 IF l_max_asg_end_date < ben_ext_person.g_effective_date
2815 THEN
2816 l_basic_date := l_max_asg_end_date;
2817 ELSE
2818 l_basic_date := ben_ext_person.g_effective_date;
2819 END IF;
2820 --115.87:Bug 7291713: Stop
2821
2822 ELSE --g_dfn_name <> 'BDI'
2823 l_basic_date := p_effective_date;
2824 END IF;
2825
2826 debug('g_dfn_name : '|| g_dfn_name);
2827 debug('l_basic_date : '|| l_basic_date);
2828
2829 OPEN csr_get_org_id(l_basic_date);
2830 FETCH csr_get_org_id INTO l_org_id;
2831 CLOSE csr_get_org_id;
2832
2833 -- If employer code exists for this organization
2834 -- return it from collection otherwise fetch and
2835 -- store in the collection
2836 IF g_employer_code.EXISTS(l_org_id) THEN
2837 l_employer_code := g_employer_code(l_org_id);
2838 ELSE
2839 l_employer_code := NULL;
2840 OPEN csr_get_emp_code(l_org_id);
2841 FETCH csr_get_emp_code INTO l_employer_code;
2842 IF csr_get_emp_code%NOTFOUND OR
2843 l_employer_code IS NULL
2844 THEN
2845 -- store error
2846 l_value := raise_extract_error
2847 (p_error_number => 92369
2848 ,p_error_text => 'BEN_92369_EXT_PSI_NO_EMP_CODE'
2849 );
2850 ELSE -- employer code information found
2851 g_employer_code(l_org_id) := l_employer_code;
2852 END IF;
2853 CLOSE csr_get_emp_code;
2854 END IF; -- End if of code exists in collection check ...
2855
2856 debug('Employer Code: '|| l_employer_code);
2857 debug_exit(l_proc_name);
2858
2859 RETURN l_employer_code;
2860
2861 EXCEPTION
2862 WHEN others THEN
2863 IF SQLCODE <> hr_utility.hr_error_number
2864 THEN
2865 debug_others (l_proc_name, 10);
2866 IF g_debug
2867 THEN
2868 DEBUG ( 'Leaving: '
2869 || l_proc_name, -999);
2870 END IF;
2871 fnd_message.raise_error;
2872 ELSE
2873 RAISE;
2874 END IF;
2875
2876 END employer_code;
2877
2878
2879
2880 -- ----------------------------------------------------------------------------
2881 -- |--------------------------------< altkey >--------------------------------|
2882 -- ----------------------------------------------------------------------------
2883
2884 FUNCTION altkey
2885 --(p_assignment_number IN VARCHAR2 -- context
2886 --,p_paypoint IN VARCHAR2 -- context
2887 --)
2888 RETURN VARCHAR2
2889 IS
2890 l_proc_name VARCHAR2(61):=
2891 g_proc_name||'altkey';
2892
2893 l_return VARCHAR2(20);
2894 CURSOR csr_get_assignment_number
2895 IS
2896 SELECT assignment_number
2897 FROM per_all_assignments_f
2898 WHERE assignment_id = g_assignment_id
2899 AND g_effective_date BETWEEN effective_start_date
2900 AND effective_end_date;
2901
2902 BEGIN
2903 --
2904 debug_enter(l_proc_name);
2905 debug('g_paypoint : '||g_paypoint,10);
2906 debug('g_assignment_number : '||g_assignment_number,20);
2907
2908 -- added by kkarri
2909 -- g_assignment_number will be set in basic criteria
2910 -- but for bonus history the basic criteria will be called
2911 -- for claim date. When a claim date is invalid, assignment_number
2912 -- will remain null.
2913 IF g_assignment_number IS NULL THEN
2914 DEBUG('assignment_number NOT FOUND',30);
2915 DEBUG('g_effective_date'||g_effective_date,30);
2916 OPEN csr_get_assignment_number;
2917 FETCH csr_get_assignment_number INTO g_assignment_number;
2918 CLOSE csr_get_assignment_number;
2919
2920 g_assignment_number := TRIM(REPLACE(g_assignment_number,'-',''));
2921
2922 debug('g_assignment_number : '||g_assignment_number,30);
2923 END IF;
2924
2925 l_return := g_paypoint || g_assignment_number;
2926 debug('l_return : '||l_return,30);
2927 debug_exit(l_proc_name);
2928
2929 RETURN l_return;
2930
2931 EXCEPTION
2932 WHEN others THEN
2933 IF SQLCODE <> hr_utility.hr_error_number
2934 THEN
2935 debug_others (l_proc_name, 10);
2936 IF g_debug
2937 THEN
2938 DEBUG ( 'Leaving: '
2939 || l_proc_name, -999);
2940 END IF;
2941 fnd_message.raise_error;
2942 ELSE
2943 RAISE;
2944 END IF;
2945
2946 END altkey;
2947
2948
2949
2950 -- ----------------------------------------------------------------------------
2951 -- |--------------------------------< paypoint >--------------------------------|
2952 -- ----------------------------------------------------------------------------
2953
2954 FUNCTION paypoint
2955 (p_business_group_id IN VARCHAR2 -- context
2956 )
2957 RETURN VARCHAR2
2958 IS
2959 l_proc_name VARCHAR2(61):=
2960 g_proc_name||'paypoint';
2961
2962 l_config_value pqp_utilities.t_config_values;
2963 l_return VARCHAR2(20);
2964
2965 BEGIN
2966 --
2967 debug_enter(l_proc_name);
2968
2969
2970 IF g_paypoint IS NULL -- 115.58 (4)
2971 THEN
2972 -- fetch configuration value for paypoint
2973 debug('Fetching configuration value for paypoint ...', 20);
2974 pqp_utilities.get_config_type_values
2975 ( p_configuration_type => 'PQP_GB_PENSERVER_PAYPOINT_INFO'
2976 ,p_business_group_id => p_business_group_id
2977 ,p_legislation_code => NULL
2978 ,p_tab_config_values => l_config_value
2979 );
2980
2981 IF l_config_value.COUNT > 0 -- config value found
2982 THEN
2983 g_paypoint := l_config_value(l_config_value.FIRST).pcv_information1;
2984
2985 ELSE
2986 -- ERR store error
2987
2988 g_paypoint := '';
2989 END IF;
2990
2991 END IF;
2992
2993 debug_exit(l_proc_name);
2994
2995 RETURN g_paypoint;
2996
2997 EXCEPTION
2998 WHEN others THEN
2999 IF SQLCODE <> hr_utility.hr_error_number
3000 THEN
3001 debug_others (l_proc_name, 10);
3002 IF g_debug
3003 THEN
3004 DEBUG ( 'Leaving: '
3005 || l_proc_name, -999);
3006 END IF;
3007 fnd_message.raise_error;
3008 ELSE
3009 RAISE;
3010 END IF;
3011
3012 END paypoint;
3013
3014
3015
3016
3017 /*
3018
3019 -- ----------------------------------------------------------------------------
3020 -- |------------------------< exclude_errored_people >-------------------------------|
3021 -- ----------------------------------------------------------------------------
3022 -- procedure to mark errored persons as 'U' (unprocessed)
3023
3024
3025 Procedure exclude_errored_people
3026 (p_business_group_id in number
3027 ) Is
3028
3029 l_conc_reqest_id Number(20);
3030 l_exists Varchar2(2);
3031
3032 l_proc_name VARCHAR2(61):=
3033 g_proc_name||'exclude_errored_people';
3034
3035 l_ben_params csr_ben%ROWTYPE;
3036
3037
3038 cursor csr_err_per_action_id
3039 (c_benefit_action_id IN NUMBER
3040 ,c_ext_rslt_id IN NUMBER)
3041
3042 IS
3043 select person_action_id
3044 from ben_person_actions bpa
3045 Where bpa.benefit_action_id = c_benefit_action_id
3046 and EXISTS
3047 ( SELECT ers.PERSON_ID
3048 FROM BEN_EXT_RSLT_ERR ers
3049 WHERE ers.person_id = bpa.person_id
3050 AND ers.EXT_RSLT_ID= c_ext_rslt_id
3051 AND typ_cd = 'E');
3052
3053
3054 Begin
3055
3056 debug_enter(l_proc_name);
3057
3058
3059 OPEN csr_ben (c_ext_dfn_id => Ben_Ext_Thread.g_ext_dfn_id
3060 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
3061 ,c_business_group_id => p_business_group_id);
3062 Fetch csr_ben Into l_ben_params;
3063 CLOSE csr_ben;
3064
3065 debug('l_ben_params.benefit_action_id :' || l_ben_params.benefit_action_id);
3066
3067
3068 Update ben_person_actions bpa
3069 Set bpa.action_status_cd = 'U'
3070 Where bpa.benefit_action_id = l_ben_params.benefit_action_id -- 3629 -- p_benefit_action_id
3071 and bpa.person_id -- = p_person_id;
3072 IN ( SELECT PERSON_ID
3073 FROM BEN_EXT_RSLT_ERR
3074 WHERE EXT_RSLT_ID= Ben_Ext_Thread.g_ext_rslt_id -- 2891 -- c_ext_rslt_id
3075 AND typ_cd = 'E');
3076
3077 Update ben_batch_ranges bbr
3078 set bbr.range_status_cd = 'E'
3079 Where bbr.benefit_action_id = l_ben_params.benefit_action_id
3080 AND EXISTS(
3081 Select 1 -- distinct(bere.person_id)
3082 From ben_person_actions bpa, BEN_EXT_RSLT_ERR bere
3083 Where bpa.benefit_action_id = l_ben_params.benefit_action_id
3084 AND bbr.benefit_action_id = bpa.benefit_action_id
3085 AND (bpa.person_action_id Between
3086 bbr.starting_person_action_id And bbr.ending_person_action_id)
3087 And bpa.person_id = bere.person_id
3088 AND bere.EXT_RSLT_ID= Ben_Ext_Thread.g_ext_rslt_id
3089 AND bere.typ_cd = 'E');
3090
3091 debug_exit(l_proc_name);
3092
3093 EXCEPTION
3094 WHEN others THEN
3095 IF SQLCODE <> hr_utility.hr_error_number
3096 THEN
3097 debug_others (l_proc_name, 10);
3098 IF g_debug
3099 THEN
3100 DEBUG ( 'Leaving: '
3101 || l_proc_name, -999);
3102 END IF;
3103 fnd_message.raise_error;
3104 ELSE
3105 RAISE;
3106 END IF;
3107 End exclude_errored_people;
3108
3109 */
3110
3111 --
3112 -- modified as part of 115.58 (1)
3113 --
3114 -- ----------------------------------------------------------------------------
3115 -- |------------------------< exclude_errored_people >-------------------------------|
3116 -- ----------------------------------------------------------------------------
3117 -- procedure to mark errored persons as 'U' (unprocessed)
3118
3119
3120 Procedure exclude_errored_people
3121 (p_business_group_id in number
3122 ) Is
3123
3124 l_conc_reqest_id Number(20);
3125 l_exists Varchar2(2);
3126
3127 l_proc_name VARCHAR2(61):=
3128 g_proc_name||'exclude_errored_people';
3129
3130 CURSOR csr_err_person_id
3131 (p_ext_rslt_id IN NUMBER)
3132 IS
3133 SELECT distinct(ers.PERSON_ID)
3134 FROM BEN_EXT_RSLT_ERR ers
3135 WHERE ers.EXT_RSLT_ID = p_ext_rslt_id
3136 AND typ_cd = 'E';
3137
3138 CURSOR csr_range_id
3139 (p_person_action_id IN NUMBER
3140 ,p_benefit_action_id IN NUMBER
3141 )
3142 IS
3143 SELECT bbr.range_id
3144 FROM ben_batch_ranges bbr
3145 WHERE bbr.benefit_action_id = p_benefit_action_id
3146 AND p_person_action_id Between
3147 bbr.starting_person_action_id And bbr.ending_person_action_id;
3148
3149 TYPE t_number IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
3150 l_person_collection t_number;
3151 l_RangeId_collection t_number;
3152 l_per_action_id_collection t_number;
3153
3154 l_range_id NUMBER;
3155 l_itr NUMBER;
3156 i NUMBER;
3157
3158 l_ben_params csr_ben%ROWTYPE;
3159
3160 Begin
3161
3162 debug_enter(l_proc_name);
3163
3164
3165 OPEN csr_ben (c_ext_dfn_id => Ben_Ext_Thread.g_ext_dfn_id
3166 ,c_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id
3167 ,c_business_group_id => p_business_group_id);
3168 Fetch csr_ben Into l_ben_params;
3169 CLOSE csr_ben;
3170
3171 debug('l_ben_params.benefit_action_id :' || l_ben_params.benefit_action_id);
3172
3173
3174 -- (1) fetch all person_ids which have errored
3175 OPEN csr_err_person_id(p_ext_rslt_id => Ben_Ext_Thread.g_ext_rslt_id);
3176 FETCH csr_err_person_id BULK COLLECT INTO l_person_collection;
3177 CLOSE csr_err_person_id;
3178
3179 debug('Step 1 Completed');
3180
3181
3182 -- (2) update using FORALL and bulk collect all person_action_id
3183 FORALL i in 1..l_person_collection.COUNT
3184 Update ben_person_actions bpa
3185 Set bpa.action_status_cd = 'U'
3186 Where bpa.benefit_action_id = l_ben_params.benefit_action_id
3187 and bpa.person_id = l_person_collection(i)
3188 RETURNING person_action_id BULK COLLECT INTO l_per_action_id_collection;
3189
3190 debug('Step 2 Completed');
3191 debug('l_per_action_id_collection.COUNT : ' || l_per_action_id_collection.COUNT);
3192
3193
3194 -- (3) run thru the PL/SQL collection and populate a range_id collection
3195 IF l_per_action_id_collection.COUNT > 0
3196 THEN
3197
3198 FOR l_index IN l_per_action_id_collection.FIRST..l_per_action_id_collection.LAST
3199 LOOP
3200
3201 OPEN csr_range_id
3202 (p_person_action_id => l_per_action_id_collection(l_index)
3203 ,p_benefit_action_id => l_ben_params.benefit_action_id
3204 );
3205 FETCH csr_range_id INTO l_range_id;
3206 CLOSE csr_range_id;
3207
3208 IF NOT l_RangeId_collection.EXISTS(l_range_id) THEN
3209 l_RangeID_collection(l_range_id) := l_range_id;
3210 END IF;
3211 END LOOP;
3212 END IF; -- l_per_action_id_collection.COUNT > 0
3213
3214 debug('Step 3 Completed');
3215 debug('l_RangeID_collection.COUNT : ' || l_RangeID_collection.COUNT);
3216
3217
3218 -- (4) now use the range Id collection to update the batch ranges
3219 FOR i IN 1..l_RangeID_collection.COUNT
3220 LOOP
3221
3222 IF i=1 THEN
3223 l_itr :=l_RangeID_collection.FIRST;
3224 ELSE
3225 l_itr :=l_RangeID_collection.NEXT(l_itr);
3226 END IF;
3227
3228 Update ben_batch_ranges bbr
3229 set bbr.range_status_cd = 'E'
3230 Where bbr.range_id = l_RangeID_collection(l_itr);
3231
3232 END LOOP;
3233
3234 debug('Step 4 Completed');
3235
3236
3237 debug_exit(l_proc_name);
3238
3239 EXCEPTION
3240 WHEN others THEN
3241 IF SQLCODE <> hr_utility.hr_error_number
3242 THEN
3243 debug_others (l_proc_name, 10);
3244 IF g_debug
3245 THEN
3246 DEBUG ( 'Leaving: '
3247 || l_proc_name, -999);
3248 END IF;
3249 fnd_message.raise_error;
3250 ELSE
3251 RAISE;
3252 END IF;
3253 End exclude_errored_people;
3254
3255
3256
3257
3258 -- ----------------------------------------------------------------------------
3259 -- |------------------------< common_post_process >-------------------------------|
3260 -- ----------------------------------------------------------------------------
3261 -- procedure to mark errored persons as 'U' (unprocessed)
3262
3263
3264 Procedure common_post_process
3265 (p_business_group_id in number
3266 ) Is
3267
3268
3269 l_proc_name VARCHAR2(61):=
3270 g_proc_name||'common_post_process';
3271
3272 CURSOR csr_dfn_code
3273 IS
3274 Select output_name
3275 from ben_ext_dfn
3276 where ext_dfn_id = ben_ext_thread.g_ext_dfn_id;
3277
3278 l_extract_code csr_dfn_code%rowtype;
3279 l_file_name VARCHAR2(100);
3280 l_run_date DATE;
3281 l_business_group_id NUMBER := NULL;
3282
3283 Begin
3284
3285 debug_enter(l_proc_name);
3286
3287 -- fnd_file.put_line(fnd_file.log, l_proc_name || to_char(SYSDATE,'dd-Mon-yyyy hh:mm:ss am'));
3288 fnd_file.put_line(fnd_file.log, l_proc_name || ' : ' || get_time);
3289
3290 -- 115.60
3291 -- this happens when persons are rejected at the system extract level
3292 -- in such cases, set_shared_globals doesnt get called, and the globals
3293 -- need to be set here
3294 IF p_business_group_id IS NULL
3295 THEN
3296 l_business_group_id := g_business_group_id_backup;
3297 ELSE
3298 l_business_group_id := p_business_group_id;
3299 END IF;
3300
3301 -- set paypoint if not found
3302 debug('g_paypoint :' || g_paypoint);
3303 IF g_paypoint IS NULL
3304 THEN
3305 g_paypoint := paypoint(l_business_group_id);
3306 debug('g_paypoint :' || g_paypoint);
3307 END IF;
3308
3309 -- function call to exclude errored people
3310 exclude_errored_people(l_business_group_id);
3311
3312 debug('g_extract_type : ' || g_extract_type);
3313 debug('g_output_name : ' || g_output_name);
3314 debug('g_sequence_number : ' || g_sequence_number);
3315
3316
3317 -- Get the output file name
3318 OPEN csr_get_run_date(c_ext_dfn_id => ben_ext_thread.g_ext_dfn_id
3319 ,c_business_group_id => l_business_group_id);
3320 FETCH csr_get_run_date INTO l_run_date,g_output_name;
3321 CLOSE csr_get_run_date;
3322
3323
3324 IF g_extract_type = '3CUT' THEN
3325 g_sequence_number := '001';
3326 ELSE
3327 IF g_output_name IS NULL THEN
3328 g_sequence_number := '002';
3329 ELSE
3330 g_sequence_number := rtrim(ltrim(to_char(fnd_number.canonical_to_number(substr(g_output_name,INSTR(g_output_name,'.')+1))+1,'099')));
3331 END IF;
3332 END IF;
3333
3334 debug('g_extract_type : ' || g_extract_type);
3335 debug('g_output_name : ' || g_output_name);
3336 debug('g_sequence_number : ' || g_sequence_number);
3337
3338 OPEN csr_dfn_code;
3339 FETCH csr_dfn_code INTO l_extract_code;
3340 CLOSE csr_dfn_code;
3341
3342 debug('l_extract_code.output_name :' || l_extract_code.output_name);
3343
3344
3345 l_file_name := l_extract_code.output_name || g_paypoint || '.' || g_sequence_number;
3346
3347 debug('l_file_name :' || l_file_name );
3348
3349 update ben_ext_rslt
3350 SET output_name = l_file_name
3351 WHERE business_group_id = l_business_group_id
3352 AND ext_rslt_id = ben_ext_thread.g_ext_rslt_id;
3353
3354 debug_exit(l_proc_name);
3355
3356 -- fnd_file.put_line(fnd_file.log, 'Done : ' || l_proc_name || to_char(SYSDATE,'dd-Mon-yyyy hh:mm:ss am'));
3357 fnd_file.put_line(fnd_file.log, 'Done : ' || l_proc_name || ' : ' || get_time);
3358
3359 EXCEPTION
3360 WHEN others THEN
3361 IF SQLCODE <> hr_utility.hr_error_number
3362 THEN
3363 debug_others (l_proc_name, 10);
3364 IF g_debug
3365 THEN
3366 DEBUG ( 'Leaving: '
3367 || l_proc_name, -999);
3368 END IF;
3369 fnd_message.raise_error;
3370 ELSE
3371 RAISE;
3372 END IF;
3373 End common_post_process;
3374
3375 --
3376 --
3377 -- ----------------------------------------------------------------------------
3378 -- |------------------------< raise_extract_warning >-----------------------|
3379 -- ----------------------------------------------------------------------------
3380
3381
3382 --
3383 -- RAISE_EXTRACT_WARNING
3384 --
3385 -- "Smart" warning function.
3386 -- When called from the Rule of a extract detail data element
3387 -- it logs a warning in the ben_ext_rslt_err table against
3388 -- the person being processed (or as specified by context of
3389 -- assignment id ). It prefixes all warning messages with a
3390 -- string "Warning raised in data element "||element_name
3391 -- This allows the same Rule to be called from different data
3392 -- elements.
3393 --
3394 -- usage example.
3395 --
3396 -- RAISE_EXTRACT_WARNING("No initials were found.")
3397 --
3398 -- RRTURNCODE MEANING
3399 -- -1 Cannot raise warning against a header/trailer
3400 -- record. System Extract does not allow it.
3401 --
3402 -- -2 No current extract process was found.
3403 --
3404 -- -3 No person was found.A Warning in System Extract
3405 -- is always raised against a person.
3406 --
3407
3408 FUNCTION raise_extract_warning
3409 (p_assignment_id IN NUMBER DEFAULT g_assignment_id -- context
3410 ,p_error_text IN VARCHAR2
3411 ,p_error_number IN NUMBER DEFAULT NULL
3412 ,p_token1 IN VARCHAR2 DEFAULT NULL --added to pass tokens to messages.
3413 ,p_token2 IN VARCHAR2 DEFAULT NULL --added to pass tokens to messages.
3414 ,p_token3 IN VARCHAR2 DEFAULT NULL --added to pass tokens to messages.
3415 ,p_token4 IN VARCHAR2 DEFAULT NULL --added to pass tokens to messages.
3416 ) RETURN NUMBER
3417 IS
3418
3419 l_proc_name VARCHAR2(61):=
3420 g_proc_name||'raise_extract_warning';
3421
3422 l_ext_rslt_id NUMBER;
3423 l_person_id NUMBER;
3424 l_error_text VARCHAR2(2000);
3425 l_return_value NUMBER:= 0;
3426 BEGIN
3427 --
3428
3429 debug_enter(l_proc_name);
3430
3431 l_ext_rslt_id:= get_current_extract_result;
3432
3433 IF l_ext_rslt_id <> -1 THEN
3434 --
3435
3436
3437 If p_error_number is null Then
3438
3439 l_error_text:= 'Warning raised in data element '||
3440 ben_ext_fmt.g_elmt_name||'. '||
3441 p_error_text;
3442 --if no message token is defined then egt the message from
3443 --ben_ext_fmt.
3444 Elsif p_token1 is null Then
3445
3446 ben_ext_thread.g_err_num := p_error_number;
3447 ben_ext_thread.g_err_name := p_error_text;
3448 l_error_text :=
3449 ben_ext_fmt.get_error_msg(fnd_number.canonical_to_number(substr(p_error_text, 5, 5)),
3450 p_error_text,ben_ext_fmt.g_elmt_name);
3451
3452 -- if any token is defined than replace the tokens in the message.
3453 -- and get the message text from fnd_messages.
3454 Elsif p_token1 is not null Then
3455
3456 -- set the Tokens in the warning message and then
3457 -- get the warning message from fnd_messages.
3458
3459 ben_ext_thread.g_err_num := p_error_number;
3460 ben_ext_thread.g_err_name := p_error_text;
3461
3462 fnd_message.set_name('BEN',p_error_text);
3463 fnd_message.set_token('TOKEN1',p_token1);
3464 debug('token1 : '||p_token1);
3465 -- this is based on the logic that tokens are passed in order
3466 -- i.e. when 3 tokens are to be used, it will be passed as token1,
3467 -- token2 and token3. Hence, if we find token2 as NULL, we conclude
3468 -- that token3 and token4 are not present.
3469 if p_token2 is not null Then
3470 debug('token2 : '||p_token2);
3471 fnd_message.set_token('TOKEN2',p_token2);
3472 if p_token3 is not null Then
3473 debug('token3 : '||p_token3);
3474 fnd_message.set_token('TOKEN3',p_token3);
3475 if p_token4 is not null Then
3476 debug('token4 : '||p_token4);
3477 fnd_message.set_token('TOKEN4',p_token4);
3478 end if;
3479 end if;
3480 end if;
3481
3482 l_error_text := fnd_message.get ;
3483
3484 End If;
3485
3486
3487 -- for setup related warnings, assignment_id is NULL
3488 -- so raise these warnings independent of person
3489 IF p_assignment_id < 0 -- IS NULL
3490 THEN
3491 --l_person_id := -1; --p_assignment_id ; -- independent of person
3492 l_person_id := p_assignment_id ; -- independent of person
3493 ELSE -- DE related warning
3494 l_person_id:= NVL(get_current_extract_person(p_assignment_id)
3495 ,ben_ext_person.g_person_id);
3496 END IF;
3497 debug('l_person_id : '||l_person_id, 99);
3498
3499 IF l_person_id IS NOT NULL THEN
3500 --
3501 ben_ext_util.write_err
3502 (p_err_num => p_error_number
3503 ,p_err_name => l_error_text
3504 ,p_typ_cd => 'W'
3505 ,p_person_id => l_person_id
3506 ,p_request_id => fnd_global.conc_request_id
3507 ,p_business_group_id => fnd_global.per_business_group_id
3508 ,p_ext_rslt_id => get_current_extract_result
3509 );
3510 l_return_value:= 0; /* All Well ! */
3511 --
3512 ELSE
3513 --
3514 l_return_value:= -3; /* Person not found */
3515 --
3516 END IF;
3517 --
3518 ELSE
3519 --
3520 l_return_value:= -2; /* No current extract process was found */
3521 --
3522 END IF;
3523
3524 debug_exit(l_proc_name);
3525 --
3526 RETURN l_return_value;
3527 EXCEPTION
3528 WHEN others THEN
3529 IF SQLCODE <> hr_utility.hr_error_number
3530 THEN
3531 debug_others (l_proc_name, 10);
3532 IF g_debug
3533 THEN
3534 DEBUG ( 'Leaving: '
3535 || l_proc_name, -999);
3536 END IF;
3537 fnd_message.raise_error;
3538 ELSE
3539 RAISE;
3540 END IF;
3541
3542 END raise_extract_warning;
3543
3544
3545 -- ----------------------------------------------------------------------------
3546 -- |------------------------< raise_extract_error >-----------------------|
3547 -- ----------------------------------------------------------------------------
3548
3549 FUNCTION raise_extract_error
3550 (p_business_group_id IN NUMBER DEFAULT g_business_group_id -- context
3551 ,p_assignment_id IN NUMBER DEFAULT g_assignment_id -- context
3552 ,p_error_text IN VARCHAR2
3553 ,p_error_number IN NUMBER DEFAULT NULL
3554 ,p_token1 IN VARCHAR2 DEFAULT NULL --added to pass tokens to messages.
3555 ,p_token2 IN VARCHAR2 DEFAULT NULL --added to pass tokens to messages.
3556 ,p_token3 IN VARCHAR2 DEFAULT NULL --added to pass tokens to messages.
3557 ,p_token4 IN VARCHAR2 DEFAULT NULL --added to pass tokens to messages.
3558 ) RETURN NUMBER
3559 IS
3560
3561 l_proc_name VARCHAR2(61):=
3562 g_proc_name||'raise_extract_error';
3563
3564 l_ext_rslt_id NUMBER;
3565 l_person_id NUMBER;
3566 l_error_text VARCHAR2(2000);
3567 l_error_message VARCHAR2(2000);
3568 l_return_value NUMBER:= 0;
3569 l_err_typ_cd VARCHAR2(1) := NULL;
3570
3571 BEGIN
3572
3573 debug_enter(l_proc_name);
3574 --
3575 IF p_business_group_id is not null THEN
3576 --
3577 debug('p_business_group_id is not null');
3578 l_ext_rslt_id:= get_current_extract_result;
3579 IF l_ext_rslt_id <> -1 THEN
3580 --
3581
3582 If p_error_number is null Then
3583
3584 l_error_text:= 'Error raised in data element '||
3585 NVL(ben_ext_person.g_elmt_name,ben_ext_fmt.g_elmt_name)||'. '||
3586 p_error_text;
3587
3588
3589 Elsif p_token1 is null Then
3590
3591 debug('p_token1 is null');
3592 ben_ext_thread.g_err_num := p_error_number;
3593 ben_ext_thread.g_err_name := p_error_text;
3594 l_error_text :=
3595 ben_ext_fmt.get_error_msg(fnd_number.canonical_to_number(substr(p_error_text, 5, 5)),
3596 p_error_text,ben_ext_fmt.g_elmt_name);
3597
3598 -- if any token is defined than replace the tokens in the message.
3599 -- and get the message text from fnd_messages.
3600 Elsif p_token1 is not null Then
3601
3602 -- set the Tokens in the warning message and then
3603 -- get the warning message from fnd_messages.
3604
3605 ben_ext_thread.g_err_num := p_error_number;
3606 ben_ext_thread.g_err_name := p_error_text;
3607
3608 fnd_message.set_name('BEN',p_error_text);
3609 fnd_message.set_token('TOKEN1',p_token1);
3610
3611 if p_token2 is not null Then
3612 debug('token2 : '||p_token2);
3613 fnd_message.set_token('TOKEN2',p_token2);
3614 if p_token3 is not null Then
3615 debug('token3 : '||p_token3);
3616 fnd_message.set_token('TOKEN3',p_token3);
3617 if p_token4 is not null Then
3618 debug('token4 : '||p_token4);
3619 fnd_message.set_token('TOKEN4',p_token4);
3620 end if;
3621 end if;
3622 end if;
3623
3624 l_error_text := fnd_message.get ;
3625
3626 End If; -- End if of error number is null check ...
3627
3628 -- for setup related errors, assignment_id is NULL
3629 -- so raise these errors independent of person
3630 IF p_assignment_id < 0 -- IS NULL (setup error)
3631 THEN
3632 --l_person_id := -1; --p_assignment_id ; -- independent of person
3633 l_person_id := p_assignment_id ; -- independent of person
3634 -- 115.10
3635 l_err_typ_cd := 'F'; -- all setup errors are fatal
3636 ELSE -- DE related error
3637 l_person_id := NVL(get_current_extract_person(p_assignment_id)
3638 ,ben_ext_person.g_person_id);
3639 -- 115.10
3640 l_err_typ_cd := 'E'; -- all data element related errors are 'E'
3641 END IF;
3642 debug('l_person_id : '||l_person_id, 99);
3643
3644 ben_ext_util.write_err
3645 (p_err_num => p_error_number
3646 ,p_err_name => l_error_text
3647 ,p_typ_cd => l_err_typ_cd -- 'F'
3648 ,p_person_id => l_person_id
3649 ,p_request_id => fnd_global.conc_request_id
3650 ,p_business_group_id => p_business_group_id
3651 ,p_ext_rslt_id => get_current_extract_result
3652 );
3653
3654 --commit;
3655
3656 --raise ben_ext_thread.g_job_failure_error;
3657 l_return_value:= 0; /* All Well ! */
3658 --
3659 ELSE
3660 --
3661 l_return_value:= -2; /* No current extract process was found */
3662 --
3663 END IF;
3664 --
3665 ELSE
3666 --
3667 l_return_value := -1; /* Cannot raise warnings against header/trailers */
3668 --
3669 END IF;
3670 --
3671
3672 debug_exit(l_proc_name);
3673
3674 RETURN l_return_value;
3675 EXCEPTION
3676 WHEN others THEN
3677 IF SQLCODE <> hr_utility.hr_error_number
3678 THEN
3679 debug_others (l_proc_name, 10);
3680 IF g_debug
3681 THEN
3682 DEBUG ( 'Leaving: '
3683 || l_proc_name, -999);
3684 END IF;
3685 fnd_message.raise_error;
3686 ELSE
3687 RAISE;
3688 END IF;
3689
3690 END raise_extract_error;
3691
3692
3693 -- ----------------------------------------------------------------------------
3694 -- |------------------------< store_extract_exceptions >-----------------------|
3695 -- ----------------------------------------------------------------------------
3696
3697 PROCEDURE store_extract_exceptions
3698 (-- pass <interface_name> / 'DE' to indicate
3699 -- the level at which error/warning has been raised
3700 -- (1) <interface_name> (eg BASIC_DATA) = interface setup exceptions
3701 -- (2) DE = person/data element level
3702 p_extract_type IN VARCHAR2 -- <interface_name>/'DE'
3703 ,p_error_number IN NUMBER
3704 ,p_error_text IN VARCHAR2
3705 ,p_token1 IN VARCHAR2 DEFAULT NULL
3706 ,p_token2 IN VARCHAR2 DEFAULT NULL
3707 ,p_token3 IN VARCHAR2 DEFAULT NULL
3708 ,p_token4 IN VARCHAR2 DEFAULT NULL
3709 ,p_error_warning_flag IN VARCHAR2 -- E (error) / W (warning)
3710 )
3711 IS
3712 --
3713 l_proc_name VARCHAR2(61):=
3714 g_proc_name||'store_extract_exceptions';
3715
3716 l_error_index NUMBER;
3717 l_warning_index NUMBER;
3718
3719 --
3720 BEGIN
3721
3722 debug_enter(l_proc_name);
3723
3724 l_error_index := 0;
3725 l_warning_index := 0;
3726
3727 debug('g_errors.COUNT : '|| g_errors.COUNT);
3728 debug('g_warnings.COUNT : '|| g_warnings.COUNT);
3729
3730
3731 IF p_error_warning_flag = 'e'
3732 OR p_error_warning_flag = 'E'
3733 THEN -- enter a new record in errors table
3734 l_error_index := g_errors.COUNT;
3735
3736 g_errors(l_error_index + 1).extract_type := p_extract_type;
3737 g_errors(l_error_index + 1).error_number := p_error_number;
3738 g_errors(l_error_index + 1).error_text := p_error_text;
3739 g_errors(l_error_index + 1).token1 := p_token1;
3740 g_errors(l_error_index + 1).token2 := p_token2;
3741 g_errors(l_error_index + 1).token3 := p_token3;
3742 g_errors(l_error_index + 1).token4 := p_token4;
3743
3744 -- assignment_id need to be set for DE level errors
3745 IF p_extract_type = 'DE' THEN
3746 g_errors(l_error_index + 1).assignment_id := g_assignment_id;
3747 ELSE
3748 --g_errors(l_error_index + 1).assignment_id := NULL;
3749 g_errors(l_error_index + 1).assignment_id := -(l_error_index+1);
3750 END IF;
3751
3752 -- store extract result ID for cases of multiple parallel extracts run
3753 g_errors(l_error_index + 1).ext_rslt_id := ben_ext_thread.g_ext_rslt_id;
3754
3755 -- debug
3756 --=================================
3757 debug('g_errors('||(l_error_index + 1)||').extract_type : '|| g_errors(l_error_index + 1).extract_type);
3758 debug('g_errors('||(l_error_index + 1)||').error_number : '|| g_errors(l_error_index + 1).error_number);
3759 debug('g_errors('||(l_error_index + 1)||').error_text : '|| g_errors(l_error_index + 1).error_text);
3760 debug('g_errors('||(l_error_index + 1)||').token1 : '|| g_errors(l_error_index + 1).token1);
3761 debug('g_errors('||(l_error_index + 1)||').token2 : '|| g_errors(l_error_index + 1).token2);
3762 debug('g_errors('||(l_error_index + 1)||').token3 : '|| g_errors(l_error_index + 1).token3);
3763 debug('g_errors('||(l_error_index + 1)||').token4 : '|| g_errors(l_error_index + 1).token4);
3764 debug('g_errors('||(l_error_index + 1)||').assignment_id : '|| g_errors(l_error_index + 1).assignment_id);
3765 debug('g_errors('||(l_error_index + 1)||').ext_rslt_id : '|| g_errors(l_error_index + 1).ext_rslt_id);
3766 --=================================
3767
3768 ELSE -- enter a new record in the warnings table
3769
3770 l_warning_index := g_warnings.COUNT;
3771
3772 g_warnings(l_warning_index + 1).extract_type := p_extract_type;
3773 g_warnings(l_warning_index + 1).error_number := p_error_number;
3774 g_warnings(l_warning_index + 1).error_text := p_error_text;
3775 g_warnings(l_warning_index + 1).token1 := p_token1;
3776 g_warnings(l_warning_index + 1).token2 := p_token2;
3777 g_warnings(l_warning_index + 1).token3 := p_token3;
3778 g_warnings(l_warning_index + 1).token4 := p_token4;
3779
3780 -- assignment_id need to be set for DE level errors
3781 IF p_extract_type = 'DE' THEN
3782 g_warnings(l_warning_index + 1).assignment_id := g_assignment_id;
3783 ELSE
3784 --g_warnings(l_warning_index + 1).assignment_id := NULL;
3785 g_warnings(l_warning_index + 1).assignment_id := -(l_warning_index+1);
3786 END IF;
3787
3788 -- store extract result ID for cases of multiple parallel extracts run
3789 g_warnings(l_warning_index + 1).ext_rslt_id := ben_ext_thread.g_ext_rslt_id;
3790
3791
3792 -- debug
3793 --=================================
3794 debug('g_warnings('||(l_warning_index + 1)||').extract_type : '|| g_warnings(l_warning_index + 1).extract_type);
3795 debug('g_warnings('||(l_warning_index + 1)||').error_number : '|| g_warnings(l_warning_index + 1).error_number);
3796 debug('g_warnings('||(l_warning_index + 1)||').error_text : '|| g_warnings(l_warning_index + 1).error_text);
3797 debug('g_warnings('||(l_warning_index + 1)||').token1 : '|| g_warnings(l_warning_index + 1).token1);
3798 debug('g_warnings('||(l_warning_index + 1)||').token2 : '|| g_warnings(l_warning_index + 1).token2);
3799 debug('g_warnings('||(l_warning_index + 1)||').token3 : '|| g_warnings(l_warning_index + 1).token3);
3800 debug('g_warnings('||(l_warning_index + 1)||').token4 : '|| g_warnings(l_warning_index + 1).token4);
3801 debug('g_warnings('||(l_warning_index + 1)||').assignment_id : '|| g_warnings(l_warning_index + 1).assignment_id);
3802 debug('g_warnings('||(l_warning_index + 1)||').ext_rslt_id : '|| g_warnings(l_warning_index + 1).ext_rslt_id);
3803 --=================================
3804
3805 END IF;
3806
3807 --
3808
3809 debug_exit(l_proc_name);
3810
3811 EXCEPTION
3812 WHEN others THEN
3813 IF SQLCODE <> hr_utility.hr_error_number
3814 THEN
3815 debug_others (l_proc_name, 10);
3816 IF g_debug
3817 THEN
3818 DEBUG ( 'Leaving: '
3819 || l_proc_name, -999);
3820 END IF;
3821 fnd_message.raise_error;
3822 ELSE
3823 RAISE;
3824 END IF;
3825
3826 END store_extract_exceptions;
3827
3828
3829
3830 -- ----------------------------------------------------------------------------
3831 -- |------------------------< raise_extract_exceptions >-----------------------|
3832 -- ----------------------------------------------------------------------------
3833
3834 -- (1) pass <interface_name> as parameter to raise setup related errors/warnings that were
3835 -- stored during set_shared_globals and set_extract_globals
3836 -- (2) Dont pass any parameter,data element level errors/warnings will be raised
3837 PROCEDURE raise_extract_exceptions
3838 (p_extract_type IN VARCHAR2 DEFAULT 'DE'
3839 )
3840 IS
3841 --
3842 l_proc_name VARCHAR2(61):=
3843 g_proc_name||'raise_extract_exceptions';
3844
3845 l_index NUMBER;
3846 l_value NUMBER;
3847 l_fatal_error_flag VARCHAR2(1) := 'N';
3848 --
3849 BEGIN
3850
3851 debug_enter(l_proc_name);
3852
3853 l_index := 0;
3854
3855 -- this flag is to track whether one of the errors raised were a fatal error
3856 l_fatal_error_flag := 'N';
3857
3858 FOR i IN 1..g_errors.COUNT
3859 LOOP
3860
3861 -- IF error_type = DE and g_errors has assignment_id, raise
3862 -- OR
3863 -- IF error_type = SETUP and g_errors doesnt have assignment_id, raise
3864 -- all DE errors will have g_error.assignment_id,
3865 -- all setup errors will have g_error.assignment_id = NULL
3866 debug('This is the loop for raising errors - ',20);
3867
3868
3869 -- setting the index
3870 IF i=1 THEN
3871 l_index:=g_errors.FIRST;
3872 ELSE
3873 l_index:=g_errors.NEXT(l_index);
3874 END IF;
3875
3876 debug('l_index : ' || l_index,25);
3877 -- debug
3878 --=================================
3879 debug('g_errors('||(l_index)||').extract_type : '|| g_errors(l_index).extract_type);
3880 debug('g_errors('||(l_index)||').error_number : '|| g_errors(l_index).error_number);
3881 debug('g_errors('||(l_index)||').error_text : '|| g_errors(l_index).error_text);
3882 debug('g_errors('||(l_index)||').token1 : '|| g_errors(l_index).token1);
3883 debug('g_errors('||(l_index)||').token2 : '|| g_errors(l_index).token2);
3884 debug('g_errors('||(l_index)||').token3 : '|| g_errors(l_index).token3);
3885 debug('g_errors('||(l_index)||').token4 : '|| g_errors(l_index).token4);
3886 debug('g_errors('||(l_index)||').assignment_id : '|| g_errors(l_index).assignment_id);
3887 debug('g_errors('||(l_index)||').ext_rslt_id : '|| g_errors(l_index).ext_rslt_id);
3888 --=================================
3889
3890 -- check error type
3891 IF (
3892 (p_extract_type = 'DE'
3893 and
3894 g_errors(l_index).assignment_id > 0 -- IS NOT NULL
3895 )
3896 or
3897 (p_extract_type <> 'DE'
3898 and
3899 g_errors(l_index).assignment_id < 0 -- IS NULL
3900 )
3901 )
3902 and
3903 g_errors(l_index).ext_rslt_id = ben_ext_thread.g_ext_rslt_id
3904
3905
3906 THEN
3907 debug('This error qualified to be raised - ',30);
3908
3909 l_value:=
3910 raise_extract_error
3911 (p_business_group_id => g_business_group_id
3912 ,p_assignment_id => g_errors(l_index).assignment_id
3913 ,p_error_text => g_errors(l_index).error_text
3914 ,p_error_number => g_errors(l_index).error_number
3915 ,p_token1 => g_errors(l_index).token1
3916 ,p_token2 => g_errors(l_index).token2
3917 ,p_token3 => g_errors(l_index).token3
3918 ,p_token4 => g_errors(l_index).token4
3919 );
3920
3921 -- delete this record as this error has already been reported above
3922 g_errors.DELETE(l_index);
3923
3924 -- setting flag to error out extract in case the error
3925 -- raised was of setup type
3926 IF p_extract_type <> 'DE' and l_fatal_error_flag = 'N'
3927 THEN
3928 l_fatal_error_flag := 'Y';
3929 END IF;
3930
3931 ELSE
3932 debug('This error was NOT raised - ',30);
3933 debug('p_extract_type : ' || p_extract_type);
3934 debug('g_errors('||l_index||').assignment_id : ' || g_errors(l_index).assignment_id);
3935
3936 END IF;
3937 END LOOP;
3938
3939
3940 FOR i IN 1..g_warnings.COUNT
3941 LOOP
3942 -- IF error_type = DE and g_errors has assignment_id, raise
3943 -- OR
3944 -- IF error_type = SETUP and g_errors doesnt have assignment_id, raise
3945 -- all DE errors will have g_error.assignment_id,
3946 -- all setup errors will have g_error.assignment_id = NULL
3947
3948 debug('This is the loop for raising warnings - ',20);
3949
3950
3951 -- setting the index
3952 IF i=1 THEN
3953 l_index:=g_warnings.FIRST;
3954 ELSE
3955 l_index:=g_warnings.NEXT(l_index);
3956 END IF;
3957
3958 -- debug
3959 --=================================
3960 debug('g_warnings('||(l_index)||').extract_type : '|| g_warnings(l_index).extract_type);
3961 debug('g_warnings('||(l_index)||').error_number : '|| g_warnings(l_index).error_number);
3962 debug('g_warnings('||(l_index)||').error_text : '|| g_warnings(l_index).error_text);
3963 debug('g_warnings('||(l_index)||').token1 : '|| g_warnings(l_index).token1);
3964 debug('g_warnings('||(l_index)||').token2 : '|| g_warnings(l_index).token2);
3965 debug('g_warnings('||(l_index)||').token3 : '|| g_warnings(l_index).token3);
3966 debug('g_warnings('||(l_index)||').token4 : '|| g_warnings(l_index).token4);
3967 debug('g_warnings('||(l_index)||').assignment_id : '|| g_warnings(l_index).assignment_id);
3968 debug('g_warnings('||(l_index)||').ext_rslt_id : '|| g_warnings(l_index).ext_rslt_id);
3969 --=================================
3970
3971 -- check warning type
3972 IF (
3973 (p_extract_type = 'DE'
3974 and
3975 g_warnings(l_index).assignment_id > 0 -- IS NOT NULL
3976 )
3977 or
3978 (p_extract_type <> 'DE'
3979 and
3980 g_warnings(l_index).assignment_id < 0 -- IS NULL
3981 )
3982 )
3983 and
3984 g_warnings(l_index).ext_rslt_id = ben_ext_thread.g_ext_rslt_id
3985
3986 THEN
3987 debug('This warning qualified to be raised - ',30);
3988
3989 l_value:=
3990 raise_extract_warning
3991 (p_assignment_id => g_warnings(l_index).assignment_id
3992 ,p_error_text => g_warnings(l_index).error_text
3993 ,p_error_number => g_warnings(l_index).error_number
3994 ,p_token1 => g_warnings(l_index).token1
3995 ,p_token2 => g_warnings(l_index).token2
3996 ,p_token3 => g_warnings(l_index).token3
3997 ,p_token4 => g_warnings(l_index).token4
3998 );
3999
4000 -- delete this record as this warning has already been reported above
4001 g_warnings.DELETE(l_index);
4002
4003 ELSE
4004 debug('This warning was NOT raised - ',30);
4005 END IF;
4006
4007 END LOOP;
4008
4009
4010 -- fail extract if fatal errors were there
4011 IF l_fatal_error_flag = 'Y'
4012 THEN
4013 commit;
4014
4015 raise ben_ext_thread.g_job_failure_error;
4016 END IF;
4017
4018 debug_exit(l_proc_name);
4019
4020 EXCEPTION
4021 WHEN others THEN
4022 IF SQLCODE <> hr_utility.hr_error_number
4023 THEN
4024 debug_others (l_proc_name, 10);
4025 IF g_debug
4026 THEN
4027 DEBUG ( 'Leaving: '
4028 || l_proc_name, -999);
4029 END IF;
4030 fnd_message.raise_error;
4031 ELSE
4032 RAISE;
4033 END IF;
4034
4035 END raise_extract_exceptions;
4036
4037
4038 -- ----------------------------------------------------------------------------
4039 -- |------------------------< set_shared_globals >-----------------------------------|
4040 -- ----------------------------------------------------------------------------
4041 PROCEDURE set_shared_globals
4042 (p_business_group_id IN NUMBER
4043 ,p_paypoint OUT NOCOPY VARCHAR2
4044 ,p_cutover_date OUT NOCOPY VARCHAR2
4045 ,p_ext_dfn_id OUT NOCOPY NUMBER
4046 )
4047 IS
4048 --
4049 l_proc_name VARCHAR2(61):=
4050 g_proc_name||'set_shared_globals';
4051
4052
4053 l_paypoint VARCHAR2(5) := NULL;
4054 l_cutover_date DATE;
4055 l_ext_dfn_id NUMBER;
4056 l_config_value pqp_utilities.t_config_values;
4057 --
4058 BEGIN
4059
4060
4061 g_debug := pqp_gb_psi_functions.check_debug(p_business_group_id);
4062
4063 debug_enter(l_proc_name);
4064
4065 -- fnd_file.put_line(fnd_file.log, l_proc_name || to_char(SYSDATE,'dd-Mon-yyyy hh:mm:ss am'));
4066 fnd_file.put_line(fnd_file.log, l_proc_name || ' : ' || get_time);
4067
4068
4069 debug('Entering set_shared_globals ...',10);
4070 debug ('p_business_group_id:'||p_business_group_id);
4071
4072 g_business_group_id := p_business_group_id;
4073
4074 -- For bug 12896006
4075 -- In Multi node RAC instances, when multithreaded legislation_context has to be set.
4076 -- As this function is Penserver specific and is applicable to GB only, hard coding
4077 -- the legislation context to GB. This will allow query on hr_lookups table to
4078 -- provide correct data.
4079 hr_api.set_legislation_context('GB');
4080 debug('After setting Legislation Context to GB', 20);
4081 -- End Bug 12896006
4082
4083 -- paypoint
4084 p_paypoint := paypoint(p_business_group_id);
4085 debug('p_paypoint : ' || p_paypoint, 30);
4086 -- check if paypoint is present or valid
4087 IF p_paypoint = ''
4088 or
4089 p_paypoint IS NULL
4090 or
4091 NOT PQP_GB_PSI_FUNCTIONS.is_alphanumeric(p_string=> p_paypoint)
4092 THEN
4093 -- error
4094 PQP_GB_PSI_FUNCTIONS.store_extract_exceptions
4095 (p_extract_type => 'Pay Point'
4096 ,p_error_number => 94453
4097 ,p_error_text => 'BEN_94453_INV_PAYPOINT'
4098 ,p_error_warning_flag => 'E'
4099 );
4100 END IF;
4101
4102 -- fetch configuration value for cutover date
4103 debug('Fetching configuration value for cutover date ...', 40);
4104 pqp_utilities.get_config_type_values
4105 ( p_configuration_type => 'PQP_GB_PENSERVER_PAYPOINT_INFO' --'PQP_GB_PENSERVER_CUTOVER_DATE'
4106 ,p_business_group_id => p_business_group_id
4107 ,p_legislation_code => NULL
4108 ,p_tab_config_values => l_config_value
4109 );
4110 --ERR : no configuration value found ???
4111 --debug('ERROR!!! : no configuration value found for cutover date', 50);
4112 IF l_config_value.COUNT > 0 -- config value found
4113 THEN
4114 p_cutover_date := to_date(substr(l_config_value(l_config_value.FIRST).pcv_information2,1,10),'YYYY/MM/DD');
4115 debug('p_cutover_date : ' || p_cutover_date, 50);
4116 ELSE
4117 p_cutover_date := NULL;
4118 END IF;
4119
4120 -- store in a global
4121 g_cutover_date := p_cutover_date;
4122
4123 -- extract definition ID
4124 p_ext_dfn_id := ben_ext_thread.g_ext_dfn_id;
4125 debug('p_ext_dfn_id : ' || p_ext_dfn_id, 60);
4126
4127
4128 -- fetch configuration value for employment type mapping
4129 debug('Fetching configuration value for employment type mapping ...', 65);
4130
4131 pqp_utilities.get_config_type_values
4132 ( p_configuration_type => 'PQP_GB_PENSERVER_EMPLYMT_TYPE'
4133 ,p_business_group_id => p_business_group_id
4134 ,p_legislation_code => NULL
4135 ,p_tab_config_values => g_assign_category_mapping --caching in global
4136 -- for future use
4137 );
4138 debug('g_assign_category_mapping has been populated !',66);
4139
4140
4141 -- fetch configuration value for pension scheme mapping
4142 debug('Fetching configuration value for pension scheme mapping ...', 65);
4143
4144 pqp_utilities.get_config_type_values
4145 ( p_configuration_type => 'PQP_GB_PENSERV_SCHEME_MAP_INFO'
4146 ,p_business_group_id => p_business_group_id
4147 ,p_legislation_code => NULL
4148 ,p_tab_config_values => g_pension_scheme_mapping --caching in global
4149 -- for future use
4150 );
4151 debug('g_pension_scheme_mapping has been populated !',66);
4152
4153
4154 debug('Exiting set_shared_globals ...',70);
4155 debug_exit(l_proc_name);
4156
4157 EXCEPTION
4158 WHEN others THEN
4159 IF SQLCODE <> hr_utility.hr_error_number
4160 THEN
4161 debug_others (l_proc_name, 10);
4162 IF g_debug
4163 THEN
4164 DEBUG ( 'Leaving: '
4165 || l_proc_name, -999);
4166 END IF;
4167 fnd_message.raise_error;
4168 ELSE
4169 RAISE;
4170 END IF;
4171
4172 END set_shared_globals;
4173
4174
4175 --
4176 -- modified as part of 115.58 (5)
4177 --
4178 -- ----------------------------------------------------------------------------
4179 -- |------------------------< check_employee_pension_scheme >-------------------|
4180 -- ----------------------------------------------------------------------------
4181 FUNCTION check_employee_pension_scheme
4182 (p_business_group_id IN NUMBER
4183 ,p_effective_date IN DATE
4184 ,p_assignment_id IN NUMBER
4185 ,p_psi_pension_scheme IN VARCHAR2
4186 ,p_pension_element_type_id OUT NOCOPY NUMBER
4187 ) RETURN VARCHAR2 -- Y or N
4188 IS
4189 --
4190
4191 l_proc_name VARCHAR2(61):=
4192 g_proc_name||'check_employee_pension_scheme';
4193
4194 l_return VARCHAR2(1) := 'N';
4195 l_config_value pqp_utilities.t_config_values;
4196 l_index NUMBER;
4197 l_element_type_id NUMBER := NULL;
4198
4199 BEGIN
4200 debug_enter(l_proc_name);
4201 debug ('p_business_group_id:'||p_business_group_id);
4202 debug ('p_effective_date:'||p_effective_date);
4203 debug ('p_assignment_id:'||p_assignment_id);
4204
4205 -- search thru the mapping for this assignment category
4206 FOR i IN 1..g_pension_scheme_mapping.COUNT
4207 LOOP
4208
4209 IF i=1 THEN -- finding next index
4210 l_index:=g_pension_scheme_mapping.FIRST;
4211 ELSE
4212 l_index:=g_pension_scheme_mapping.NEXT(l_index);
4213 END IF;
4214
4215 debug('g_pension_scheme_mapping('||l_index||').pcv_information1 : '
4216 || g_pension_scheme_mapping(l_index).pcv_information1);
4217 debug('g_pension_scheme_mapping('||l_index||').pcv_information2 : '
4218 || g_pension_scheme_mapping(l_index).pcv_information2);
4219
4220 -- start comparing
4221 --IF g_pension_scheme_mapping(l_index).pcv_information2 = 'PARTNER' -- match found!!
4222 IF g_pension_scheme_mapping(l_index).pcv_information2 = p_psi_pension_scheme -- match found!!
4223 THEN
4224 l_element_type_id := g_pension_scheme_mapping(l_index).pcv_information1;
4225
4226 debug('l_element_type_id : '|| l_element_type_id,65);
4227 debug('g_pension_scheme_mapping('||l_index||').pcv_information1 : '
4228 || g_pension_scheme_mapping(l_index).pcv_information1,66);
4229 debug('g_pension_scheme_mapping('||l_index||').pcv_information2 : '
4230 || g_pension_scheme_mapping(l_index).pcv_information2,66);
4231
4232 debug('match found! Need to check presence on assignment ',67);
4233
4234 -- now check for presence of this element_type_id on assignment
4235 debug('now checking for scheme membership for '||p_psi_pension_scheme||'...',70);
4236 -- open cursor
4237 OPEN csr_partnership_scheme_flag
4238 (p_business_group_id => p_business_group_id
4239 ,p_effective_date => p_effective_date
4240 ,p_assignment_id => p_assignment_id
4241 ,p_element_type_id => l_element_type_id
4242 );
4243 FETCH csr_partnership_scheme_flag into l_return;
4244 IF csr_partnership_scheme_flag%FOUND THEN
4245 l_return := 'Y';
4246 debug('l_return : ' || l_return,75);
4247 CLOSE csr_partnership_scheme_flag;
4248 EXIT; -- match found, exit the FOR loop
4249 ELSE
4250 l_return := 'N';
4251 debug('l_return : ' || l_return,76);
4252 END IF;
4253 CLOSE csr_partnership_scheme_flag;
4254 --
4255
4256 ELSE
4257 -- ERR - no matching employment category
4258 debug('Not a match !!',70);
4259 END IF;
4260
4261 END LOOP; -- end of FOR loop
4262
4263
4264 -- out parameter of this pension scheme
4265 p_pension_element_type_id := l_element_type_id;
4266
4267 debug_exit(l_proc_name);
4268 return l_return;
4269
4270 EXCEPTION
4271 WHEN others THEN
4272 IF SQLCODE <> hr_utility.hr_error_number
4273 THEN
4274 debug_others (l_proc_name, 10);
4275 IF g_debug
4276 THEN
4277 DEBUG ( 'Leaving: '
4278 || l_proc_name, -999);
4279 END IF;
4280 fnd_message.raise_error;
4281 ELSE
4282 RAISE;
4283 END IF;
4284
4285 END check_employee_pension_scheme;
4286
4287
4288 -- ----------------------------------------------------------------------------
4289 -- |------------------------< check_employee_eligibility >-------------------|
4290 -- ----------------------------------------------------------------------------
4291 FUNCTION check_employee_eligibility
4292 (p_business_group_id IN NUMBER
4293 ,p_assignment_id IN NUMBER
4294 ,p_effective_date IN DATE
4295 ,p_chg_value OUT NOCOPY VARCHAR2 -- the scheme name entered.
4296 ) RETURN VARCHAR2 -- Y or N
4297 IS
4298 --
4299 l_proc_name VARCHAR2(61):= g_proc_name||'check_employee_eligibility';
4300 l_return VARCHAR2(1) := 'Y';
4301 l_config_values PQP_UTILITIES.t_config_values;
4302
4303 l_query VARCHAR2(1000);
4304 TYPE base_table_ref_csr_typ IS REF CURSOR;
4305 c_base_table base_table_ref_csr_typ;
4306
4307 BEGIN
4308 debug_enter(l_proc_name);
4309 debug('p_business_group_id: '||p_business_group_id,10);
4310 debug('p_effective_date: '||p_effective_date,10);
4311 debug('p_assignment_id: '||p_assignment_id,10);
4312
4313 IF g_asg_membership_col IS NULL THEN
4314 -- fetch the value if g_asg_membership_col is null
4315 debug('Fetch the column name for the first time.',30);
4316 PQP_UTILITIES.get_config_type_values(
4317 p_configuration_type => 'PQP_GB_PENSERVER_ELIGBLTY_CONF'
4318 ,p_business_group_id => g_business_group_id
4319 ,p_legislation_code => g_legislation_code
4320 ,p_tab_config_values => l_config_values
4321 );
4322 IF l_config_values.COUNT > 0 THEN
4323 g_asg_membership_context := l_config_values(l_config_values.FIRST).pcv_information1;
4324 g_asg_membership_col := l_config_values(l_config_values.FIRST).pcv_information2;
4325 ELSE
4326 -- no configuration value
4327 -- riase errorr
4328 debug('ERROR: No configuration for the eligibility column',20);
4329 store_extract_exceptions
4330 (p_extract_type => 'Employee Eligibility'
4331 ,p_error_number => 93917
4332 ,p_error_text => 'BEN_93917_NO_PEN_ELIGBLTY_CONF'
4333 ,p_error_warning_flag => 'E'
4334 );
4335 END IF;
4336 END IF;
4337
4338 IF g_asg_membership_col IS NOT NULL THEN
4339 debug('g_asg_membership_col: '||g_asg_membership_col,40);
4340 /*l_query := 'select '||g_asg_membership_col||'
4341 from per_all_assignments_f '||
4342 'where business_group_id = '||p_business_group_id||' '||
4343 'and assignment_id = '||p_assignment_id||' '||
4344 'and ASS_ATTRIBUTE_CATEGORY = '||''''||g_asg_membership_context||''''||
4345 'and to_date('||''''||TO_CHAR(p_effective_date,'dd/mm/yyyy')||''''||
4346 ',''dd/mm/yyyy'')'||' between effective_start_date '||
4347 'and effective_end_date';*/
4348 /* commented to use bind variable instead of parameter */
4349 /* l_query := 'select '||g_asg_membership_col||' '||
4350 'from per_all_assignments_f '||' '||
4351 'where business_group_id = '||p_business_group_id||' '||
4352 'and assignment_id = '||p_assignment_id||' ';
4353 IF g_asg_membership_context <> 'Global Data Elements' THEN
4354 l_query := l_query||
4355 'and ASS_ATTRIBUTE_CATEGORY = '''||g_asg_membership_context||''' ';
4356 END IF;
4357
4358 l_query := l_query||
4359 'and to_date('||''''||TO_CHAR(p_effective_date,'dd/mm/yyyy')||''''||
4360 ',''dd/mm/yyyy'')'||' between effective_start_date '||
4361 'and effective_end_date';
4362 debug('l_query: '||l_query,30);
4363 -- fetch the value of from the column name
4364 OPEN c_base_table FOR l_query; */
4365
4366 l_query := 'select '||g_asg_membership_col||' '||'from per_all_assignments_f '||' '||
4367 'where business_group_id = :p_business_group_id '||
4368 'and assignment_id = :p_assignment_id '||
4369 'and :p_effective_date between effective_start_date and effective_end_date ';
4370
4371 IF g_asg_membership_context <> 'Global Data Elements'
4372 THEN
4373 l_query := l_query || ' and ASS_ATTRIBUTE_CATEGORY = :g_asg_membership_context';
4374 END IF;
4375
4376 IF g_asg_membership_context <> 'Global Data Elements'
4377 THEN
4378
4379 OPEN c_base_table FOR l_query using p_business_group_id,p_assignment_id,p_effective_date,g_asg_membership_context;
4380
4381 ELSE
4382
4383 OPEN c_base_table FOR l_query using p_business_group_id,p_assignment_id,p_effective_date;
4384
4385 END IF;
4386
4387 FETCH c_base_table INTO p_chg_value;
4388 CLOSE c_base_table;
4389 debug('l_assg_membership_value: '||p_chg_value,30);
4390
4391 IF p_chg_value IS NULL THEN
4392 l_return := 'N';
4393 debug('l_return: '||l_return,40);
4394 END IF;
4395 END IF;
4396
4397
4398
4399 debug('l_return: '||l_return,10);
4400 debug_exit(l_proc_name);
4401 return l_return;
4402
4403 EXCEPTION
4404 WHEN others THEN
4405 IF SQLCODE <> hr_utility.hr_error_number
4406 THEN
4407 debug_others (l_proc_name, 10);
4408 IF g_debug
4409 THEN
4410 DEBUG ( 'Leaving: '
4411 || l_proc_name, -999);
4412 END IF;
4413 fnd_message.raise_error;
4414 ELSE
4415 RAISE;
4416 END IF;
4417
4418 END check_employee_eligibility;
4419
4420 -- ----------------------------------------------------------------------------
4421 -- |------------------------< chk_penserver_basic_criteria >-------------------|
4422 -- ----------------------------------------------------------------------------
4423 FUNCTION chk_penserver_basic_criteria
4424 (p_business_group_id IN NUMBER
4425 ,p_effective_date IN DATE
4426 ,p_assignment_id IN NUMBER
4427 ,p_person_dtl OUT NOCOPY per_all_people_f%rowtype
4428 ,p_assignment_dtl OUT NOCOPY per_all_assignments_f%rowtype
4429 ) RETURN VARCHAR2 -- Y or N
4430 IS
4431
4432 --
4433
4434 l_proc_name VARCHAR2(61):=
4435 g_proc_name||'chk_penserver_basic_criteria';
4436
4437 l_inclusion_flag VARCHAR2(1) := 'Y';
4438 l_assignment_category VARCHAR2(30):= NULL;
4439 l_last_hire_date_indicator VARCHAR2(1) := NULL;
4440 l_person_id NUMBER;
4441
4442 l_person_dtl per_all_people_f%rowtype;
4443 l_assignment_dtl per_all_assignments_f%rowtype;
4444 i NUMBER;
4445 l_index NUMBER;
4446 l_value NUMBER;
4447 l_pension_element_type_id NUMBER;
4448
4449
4450 --
4451
4452 BEGIN
4453
4454 debug_enter(l_proc_name);
4455
4456 IF (g_count = 0) THEN
4457 -- fnd_file.put_line(fnd_file.log, l_proc_name || to_char(SYSDATE,'dd-Mon-yyyy hh:mm:ss am'));
4458 fnd_file.put_line(fnd_file.log, l_proc_name || ' : ' || get_time);
4459 g_count := 1;
4460 END IF;
4461
4462
4463
4464 debug ('p_business_group_id:'||p_business_group_id);
4465 debug ('p_effective_date:'||p_effective_date);
4466 debug ('p_assignment_id:'||p_assignment_id);
4467
4468 debug ('g_extract_type:'||g_extract_type);
4469 debug ('g_dfn_name:'||g_dfn_name);
4470
4471 --for PF
4472 IF (g_prev_assignment_id = p_assignment_id
4473 AND
4474 g_prev_effective_date = p_effective_date)
4475 THEN
4476 l_inclusion_flag := g_prev_inclusion_flag;
4477 p_assignment_dtl := g_assignment_dtl;
4478 p_person_dtl := g_person_dtl;
4479
4480 return l_inclusion_flag;
4481 END IF;
4482 --for PF
4483
4484
4485 -- 115.60
4486 -- for cutover extracts and basic data
4487 -- pick person only till actual termination date
4488 IF g_extract_type = '3CUT'
4489 OR
4490 g_dfn_name = 'BDI'
4491 THEN
4492 -- open cursor to store assignment details
4493 open csr_get_assignment_dtl_cut
4494 (
4495 p_business_group_id => p_business_group_id -- IN
4496 ,p_effective_date => p_effective_date -- IN
4497 ,p_assignment_id => p_assignment_id -- IN
4498 );
4499 fetch csr_get_assignment_dtl_cut into l_assignment_dtl;
4500 IF csr_get_assignment_dtl_cut%FOUND THEN
4501 debug('storing assignment details ...', 15);
4502 p_assignment_dtl := l_assignment_dtl;
4503
4504 ---- Bugfix 6196433
4505 IF g_dfn_name = 'BDI' THEN
4506 g_assignment_dtl := l_assignment_dtl; --location fix
4507 END IF;
4508
4509 ELSE
4510 --ERR : no assignment details found
4511 debug('Assignment did not qualify !!', 20);
4512 p_assignment_dtl := NULL;
4513 l_inclusion_flag := 'N';
4514 END IF;
4515 close csr_get_assignment_dtl_cut;
4516
4517 ELSE -- ='1PED' : periodic interfaces
4518 -- pick person till final close date
4519
4520 -- open cursor to store assignment details
4521 open csr_get_assignment_dtl_per
4522 (
4523 p_business_group_id => p_business_group_id -- IN
4524 ,p_effective_date => p_effective_date -- IN
4525 ,p_assignment_id => p_assignment_id -- IN
4526 );
4527 fetch csr_get_assignment_dtl_per into l_assignment_dtl;
4528 IF csr_get_assignment_dtl_per%FOUND THEN
4529 debug('storing assignment details ...', 21);
4530 p_assignment_dtl := l_assignment_dtl;
4531
4532 g_assignment_dtl := l_assignment_dtl; -- for PF
4533
4534
4535 ELSE
4536 --ERR : no assignment details found
4537 debug('Assignment did not qualify !!', 22);
4538 p_assignment_dtl := NULL;
4539 l_inclusion_flag := 'N';
4540 END IF;
4541 close csr_get_assignment_dtl_per;
4542 END IF;
4543
4544
4545 IF g_assignment_id IS NULL
4546 OR p_assignment_id <> nvl(g_assignment_id,0) THEN
4547 -- set assignment globals
4548 g_retro_event_date_reported := FALSE;
4549 END IF;
4550 -- store globals
4551 g_assignment_id := p_assignment_id;
4552
4553 -- remove all occurences of '-'
4554 g_assignment_number := TRIM(REPLACE(l_assignment_dtl.assignment_number,'-',''));
4555 debug('g_assignment_number : ' || g_assignment_number , 25);
4556 -- check altkey size <= 12 and alphanumeric check
4557 -- anshghos : 115.9
4558 IF ( length(g_assignment_number) + length(g_paypoint)) > 12
4559 THEN
4560 -- store error
4561 l_value := raise_extract_error
4562 (p_error_number => 94454
4563 ,p_error_text => 'BEN_94454_INV_ASSIGNMENT_NUM'
4564 -- 115.11 : invalid assignment_number passed as token
4565 ,p_token1 => g_assignment_number
4566 );
4567 END IF;
4568
4569 IF NOT PQP_GB_PSI_FUNCTIONS.is_alphanumeric(p_string=> g_assignment_number)
4570 THEN
4571 -- store error
4572 l_value := raise_extract_error
4573 (p_error_number => 94467
4574 ,p_error_text => 'BEN_94467_INV_ASSIGNMENT_NUM'
4575 -- 115.11 : invalid assignment_number passed as token
4576 ,p_token1 => g_assignment_number
4577 );
4578 END IF;
4579
4580 -- 115.11 (anshghos) : person no longer excluded for invalid altkey
4581 -- truncating assignment number so that altkey is 12 characters
4582 g_assignment_number := substr(g_assignment_number,1,(12-length(g_paypoint)));
4583
4584 debug('l_inclusion_flag : '|| l_inclusion_flag,25);
4585
4586
4587 IF l_inclusion_flag <> 'N' -- not yet ruled out
4588 THEN
4589 -- open cursor to store person details
4590 open csr_get_person_dtl
4591 (
4592 p_business_group_id => p_business_group_id -- IN
4593 ,p_effective_date => p_effective_date -- IN
4594 ,p_person_id => l_assignment_dtl.person_id -- IN
4595 );
4596 fetch csr_get_person_dtl into l_person_dtl;
4597 IF csr_get_person_dtl%FOUND THEN
4598 debug('storing person details ...', 20);
4599 p_person_dtl := l_person_dtl;
4600
4601 g_person_dtl := l_person_dtl; -- for PF
4602
4603 ELSE
4604 --ERR : no assignment details found
4605 debug('ERROR!!! : no person details fetched for the person id', 30);
4606 p_person_dtl := NULL;
4607 l_inclusion_flag := 'N';
4608
4609
4610 -- ERR raised for this person
4611 -- store error
4612 l_value := raise_extract_error
4613 (p_error_number => 94455
4614 ,p_error_text => 'BEN_94455_PERSON_DTLS_MISSING'
4615 );
4616
4617 END IF;
4618 close csr_get_person_dtl;
4619 END IF;
4620
4621 debug('l_inclusion_flag : '|| l_inclusion_flag,35);
4622
4623
4624 -- assignment and person details are available
4625 -- employee_type = 'E', category IS NOT NULL
4626
4627 IF l_inclusion_flag <> 'N' -- => assignment/person details were found
4628 THEN
4629 debug('l_inclusion_flag : '|| l_inclusion_flag,60);
4630
4631 -- search thru the mapping for this assignment category
4632 FOR i IN 1..g_assign_category_mapping.COUNT
4633 LOOP
4634
4635 IF i=1 THEN -- finding next index
4636 l_index:=g_assign_category_mapping.FIRST;
4637 ELSE
4638 l_index:=g_assign_category_mapping.NEXT(l_index);
4639 END IF;
4640
4641 debug('g_assign_category_mapping('||l_index||').pcv_information1 : '
4642 || g_assign_category_mapping(l_index).pcv_information1);
4643 debug('g_assign_category_mapping('||l_index||').pcv_information2 : '
4644 || g_assign_category_mapping(l_index).pcv_information2);
4645
4646 -- start comparing
4647 IF l_assignment_dtl.employment_category =
4648 g_assign_category_mapping(l_index).pcv_information1 -- match found!!
4649 THEN
4650 l_assignment_category := g_assign_category_mapping(l_index).pcv_information2;
4651
4652 debug('l_assignment_category : '|| l_assignment_category,65);
4653 debug('g_assign_category_mapping('||l_index||').pcv_information2 : '
4654 || g_assign_category_mapping(l_index).pcv_information2,66);
4655 debug('match found, exiting FOR loop!',67);
4656
4657 EXIT; -- match found, exit the FOR loop
4658 ELSE
4659 -- ERR - no matching employment category
4660 debug('Not a match !!',70);
4661 END IF;
4662
4663 END LOOP; -- end of FOR loop
4664
4665 -- match not found after looping thru
4666 IF l_assignment_category IS NULL
4667 THEN
4668 debug('No match was found, this category type doesnt exist in config value mapping!!',75);
4669
4670 l_inclusion_flag := 'N';
4671 ELSE -- assignment category match found - casual or regular
4672
4673 debug('employment category mapping has been found :'||l_assignment_category,90);
4674
4675 -- 1) if permanent (regular) or fixed term employee, report
4676 --115.70 5897563
4677 IF l_assignment_category in ('REGULAR','FIXED','CASUAL') THEN -- 9855764 added CASUAL as it can have any pension scheme (earlier only NUVOS, Partnership)
4678 debug('employee is '||l_assignment_category||' , inclusion = Y',110);
4679 l_inclusion_flag := 'Y';
4680 ELSE -- not regular, is casual
4681 -- 2) check if person employed for more than 3 months
4682
4683 debug('employee is CASUAL, further checks ...',120);
4684
4685 --
4686 /*
4687 debug('Fetching last_hire_date_indicator ...', 130);
4688 OPEN csr_last_hire_date_indicator
4689 (
4690 p_business_group_id => p_business_group_id -- IN
4691 ,p_effective_date => p_effective_date -- IN
4692 ,p_person_id => l_person_dtl.person_id -- IN
4693 );
4694 FETCH csr_last_hire_date_indicator into l_last_hire_date_indicator;
4695 IF csr_last_hire_date_indicator%NOTFOUND THEN
4696 debug('last hire date < 3 months old',140);
4697 l_inclusion_flag := 'N'; -- cursor empty as last hire date = within 3 months
4698 ELSE
4699 -- further check pension scheme, in case its partner, 'Y' else 'N'
4700 l_inclusion_flag := check_employee_pension_scheme -- Y/N last hire date > 3 months older
4701 (p_business_group_id => p_business_group_id
4702 ,p_effective_date => p_effective_date
4703 ,p_assignment_id => p_assignment_id
4704 ,p_psi_pension_scheme => 'PARTNER'
4705 ,p_pension_element_type_id => l_pension_element_type_id
4706 );
4707 --
4708 END IF;
4709 CLOSE csr_last_hire_date_indicator;
4710 */
4711
4712 -- 115.60
4713 -- the check for 3 months of service for part timers has been removed
4714 -- direct check for partnership scheme for part timers
4715
4716 debug('Check if employee is in PARTNERship scheme...', 130);
4717 l_inclusion_flag := check_employee_pension_scheme -- Y/N last hire date > 3 months older
4718 (p_business_group_id => p_business_group_id
4719 ,p_effective_date => p_effective_date
4720 ,p_assignment_id => p_assignment_id
4721 ,p_psi_pension_scheme => 'PARTNER'
4722 ,p_pension_element_type_id => l_pension_element_type_id
4723 );
4724 --Bug 6770167 begin
4725 IF l_inclusion_flag = 'N'
4726 THEN
4727 l_inclusion_flag := check_employee_pension_scheme -- Y/N last hire date > 3 months older
4728 (p_business_group_id => p_business_group_id
4729 ,p_effective_date => p_effective_date
4730 ,p_assignment_id => p_assignment_id
4731 ,p_psi_pension_scheme => 'NUVOS'
4732 ,p_pension_element_type_id => l_pension_element_type_id
4733 );
4734 END IF;
4735 --Bug 6770167 End
4736
4737 END IF; -- IF l_assignment_category = 'REGULAR' THEN
4738
4739 END IF; -- IF l_assignment_category IS NULL
4740 END IF; -- IF l_inclusion_flag <> 'N' -- => assignment/person details were found
4741
4742 IF l_inclusion_flag <> 'N' THEN
4743 l_inclusion_flag := check_employee_eligibility
4744 (p_business_group_id => p_business_group_id
4745 ,p_assignment_id => p_assignment_id
4746 ,p_effective_date => p_effective_date
4747 ,p_chg_value => g_pension_scheme
4748 );
4749 END IF;
4750
4751 debug('l_inclusion_flag (final) : ' || l_inclusion_flag,150);
4752 debug_exit(l_proc_name);
4753 -- for PF
4754
4755 g_prev_assignment_id := p_assignment_id;
4756
4757 g_prev_effective_date := p_effective_date;
4758 g_prev_inclusion_flag := l_inclusion_flag;
4759
4760
4761 return l_inclusion_flag;
4762
4763 EXCEPTION
4764 WHEN others THEN
4765 IF SQLCODE <> hr_utility.hr_error_number
4766 THEN
4767 debug_others (l_proc_name, 10);
4768 IF g_debug
4769 THEN
4770 DEBUG ( 'Leaving: '
4771 || l_proc_name, -999);
4772 END IF;
4773 fnd_message.raise_error;
4774 ELSE
4775 RAISE;
4776 END IF;
4777
4778 END chk_penserver_basic_criteria;
4779
4780 ----
4781 FUNCTION is_curr_last_event RETURN BOOLEAN
4782 IS
4783 l_proc varchar2(72) := g_proc_name||'.is_curr_last_event';
4784 l_prev_event_dtl_rec ben_ext_person.t_detailed_output_tab_rec;
4785 l_flag VARCHAR2(1);
4786 l_curr_idx NUMBER;
4787 l_next_event_dtl_rec ben_ext_person.t_detailed_output_tab_rec;
4788 l_curr_event_dtl_rec ben_ext_person.t_detailed_output_tab_rec;
4789 l_return BOOLEAN;
4790 BEGIN
4791 debug_enter(l_proc);
4792 l_curr_idx := ben_ext_person.g_chg_pay_evt_index;
4793
4794 IF l_curr_idx = ben_ext_person.g_pay_proc_evt_tab.COUNT
4795 OR l_curr_idx = ben_ext_person.g_pay_proc_evt_tab.COUNT - 1 THEN
4796 IF l_curr_idx = ben_ext_person.g_pay_proc_evt_tab.COUNT - 1 THEN
4797 -- if the current is last-1 event. check for duplicate row.
4798 debug('the current is last-1 event.',30);
4799 l_curr_event_dtl_rec := ben_ext_person.g_pay_proc_evt_tab(l_curr_idx);
4800 l_next_event_dtl_rec := ben_ext_person.g_pay_proc_evt_tab(l_curr_idx+1);
4801 l_next_event_dtl_rec.change_mode := l_curr_event_dtl_rec.change_mode;
4802 l_flag := 'Y';
4803 IF l_curr_event_dtl_rec.dated_table_id <> l_next_event_dtl_rec.dated_table_id THEN
4804 l_flag := 'N';
4805 ELSIF l_curr_event_dtl_rec.datetracked_event <> l_next_event_dtl_rec.datetracked_event THEN
4806 l_flag := 'N';
4807 ELSIF l_curr_event_dtl_rec.update_type <> l_next_event_dtl_rec.update_type THEN
4808 l_flag := 'N';
4809 ELSIF l_curr_event_dtl_rec.surrogate_key <> l_next_event_dtl_rec.surrogate_key THEN
4810 l_flag := 'N';
4811 ELSIF l_curr_event_dtl_rec.column_name <> l_next_event_dtl_rec.column_name THEN
4812 l_flag := 'N';
4813 ELSIF l_curr_event_dtl_rec.effective_date <> l_next_event_dtl_rec.effective_date THEN
4814 l_flag := 'N';
4815 ELSIF l_curr_event_dtl_rec.old_value <> l_next_event_dtl_rec.old_value THEN
4816 l_flag := 'N';
4817 ELSIF l_curr_event_dtl_rec.new_value <> l_next_event_dtl_rec.new_value THEN
4818 l_flag := 'N';
4819 ELSIF l_curr_event_dtl_rec.change_values <> l_next_event_dtl_rec.change_values THEN
4820 l_flag := 'N';
4821 ELSIF l_curr_event_dtl_rec.proration_type <> l_next_event_dtl_rec.proration_type THEN
4822 l_flag := 'N';
4823 ELSIF l_curr_event_dtl_rec.event_group_id <> l_next_event_dtl_rec.event_group_id THEN
4824 l_flag := 'N';
4825 ELSIF l_curr_event_dtl_rec.actual_date <> l_next_event_dtl_rec.actual_date THEN
4826 l_flag := 'N';
4827 END IF;
4828 IF l_flag = 'N' THEN
4829 debug('the next event is not the same as the curr one.');
4830 l_return := FALSE;
4831 ELSE
4832 debug('the next event is the same as the curr one.');
4833 l_return := TRUE;
4834 END IF;
4835 ELSE
4836 debug('Current event is the last one',30);
4837 l_return := TRUE;
4838 END IF;
4839 ELSE
4840 debug('Current event is NOT the last one',30);
4841 l_return := FALSE;
4842 END IF;
4843
4844
4845 debug_exit(l_proc);
4846 RETURN l_return;
4847 END is_curr_last_event;
4848 ----
4849 -- This function returns the last approved run date for
4850 -- periodic changes
4851 -- ----------------------------------------------------------------------------
4852 -- |----------------------------< get_last_run_date >-------------------------|
4853 -- ----------------------------------------------------------------------------
4854 FUNCTION get_last_run_date
4855 (p_run_from_cutover_date IN VARCHAR2 -- Bugfix 4969368
4856 )
4857 RETURN DATE
4858 IS
4859 --
4860
4861 /*
4862 -- Cursor to fetch the last successful approved run date
4863 CURSOR csr_get_run_date
4864 IS
4865 SELECT MAX(eff_dt)
4866 FROM ben_ext_rslt
4867 WHERE ext_dfn_id = ben_ext_thread.g_ext_dfn_id
4868 AND business_group_id = g_business_group_id
4869 AND ext_stat_cd = 'A';
4870 */
4871
4872 l_proc_name VARCHAR2(80) := g_proc_name || 'get_last_run_date';
4873 l_proc_step PLS_INTEGER;
4874 l_run_date DATE;
4875 l_config_value PQP_UTILITIES.t_config_values;
4876
4877 l_reference_extract VARCHAr2(30);
4878 l_ext_dfn_id NUMBER;
4879 --
4880 BEGIN
4881 --
4882 IF g_debug
4883 THEN
4884 l_proc_step := 10;
4885 debug_enter(l_proc_name, l_proc_step);
4886 END IF;
4887
4888 /*
4889 -- fetch reference extract name
4890 debug('Fetching Effective rolling date window length ...', 40);
4891 pqp_utilities.get_config_type_values
4892 ( p_configuration_type => 'PQP_GB_PENSERVER_DEFINITION'
4893 ,p_business_group_id => g_business_group_id
4894 ,p_legislation_code => NULL
4895 ,p_tab_config_values => l_config_value
4896 );
4897
4898 IF l_config_value.COUNT > 0 -- config value found
4899 THEN
4900 l_reference_extract := l_config_value(l_config_value.FIRST).pcv_information3;
4901 ELSE
4902 l_reference_extract := 'BASIC';
4903 END IF;
4904
4905 */
4906
4907 -- performance fix : 1
4908 IF g_reference_extract = 'BASIC' THEN
4909 OPEN csr_ext_dfn_id(c_extract_name => 'PQP GB PenServer Periodic Changes Interface - Basic Data');
4910 FETCH csr_ext_dfn_id INTO l_ext_dfn_id;
4911 CLOSE csr_ext_dfn_id;
4912 ELSE
4913 l_ext_dfn_id := ben_ext_thread.g_ext_dfn_id;
4914 END IF;
4915
4916
4917 -- Get the run date
4918 OPEN csr_get_run_date(c_ext_dfn_id => l_ext_dfn_id
4919 ,c_business_group_id => g_business_group_id);
4920 FETCH csr_get_run_date INTO l_run_date,g_output_name;
4921 CLOSE csr_get_run_date;
4922
4923 IF g_debug
4924 THEN
4925 debug('l_run_date: '||TO_CHAR(l_run_date, 'DD/MON/YYYY'));
4926 END IF;
4927
4928 -- Set the run date to cutover date only if this is a
4929 -- first run
4930 -- Bugfix 4969368: Setting run date to cutover date if
4931 -- current interfaces needs to run from cutover date
4932 -- rather than cutover date +1
4933 -- Currently only short time hours needs to do this
4934 IF l_run_date IS NULL THEN
4935 -- This is the first run, using cutover date
4936 IF p_run_from_cutover_date = 'Y' THEN
4937 -- Set the run date to be cutover date
4938 l_run_date := g_cutover_date;
4939 ELSE
4940 l_run_date := g_cutover_date + 1;
4941 END IF;
4942 --
4943 ELSE
4944 -- Bugfix 4969368: Moved +1 logic up here for bugfix
4945 -- This is not the first run
4946 -- l_run_date := l_run_date + 1;
4947 -- For Bug 7615709, commented the above + 1 logic.
4948 -- This might lead to re-reporting of data that got reported in the last period but
4949 -- re-reporting is fine as far as we dont miss the data that got created on the last approved date.
4950
4951 l_run_date := l_run_date;
4952
4953 END IF; -- End if of l_run_date is null check ...
4954
4955 -- When this is the first run and the cutover date is not
4956 -- present default the dates to pension year start date
4957 IF l_run_date IS NULL
4958 THEN
4959 l_run_date :=
4960 TO_DATE(
4961 '01-04-' || TO_CHAR(ben_ext_person.g_effective_date, 'YYYY')
4962 ,'DD-MM-YYYY'
4963 );
4964 IF l_run_date > ben_ext_person.g_effective_date
4965 THEN
4966 l_run_date := ADD_MONTHS(l_run_date, -12);
4967 END IF;
4968 -- Bugfix 4969368: Moving this logic of run_date +1 above
4969 -- to cater for short time hours which should run from
4970 -- cutover date always
4971 --ELSE -- run date is not null
4972 -- l_run_date := l_run_date + 1;
4973 END IF; -- End if of run date is null check ..
4974
4975 IF g_debug
4976 THEN
4977 l_proc_step := 20;
4978 debug('l_run_date: '||TO_CHAR(l_run_date, 'DD/MON/YYYY'));
4979 debug_exit(l_proc_name);
4980 END IF;
4981
4982 RETURN l_run_date;
4983 EXCEPTION
4984 WHEN others THEN
4985 IF SQLCODE <> hr_utility.hr_error_number
4986 THEN
4987 debug_others (l_proc_name, l_proc_step);
4988 IF g_debug
4989 THEN
4990 DEBUG ( 'Leaving: '
4991 || l_proc_name, -999);
4992 END IF;
4993 fnd_message.raise_error;
4994 ELSE
4995 RAISE;
4996 END IF;
4997 END get_last_run_date;
4998
4999 -- ----------------------------------------------------------------------------
5000 -- |---------------------< is_curr_evt_processed >---------------------|
5001 -- ----------------------------------------------------------------------------
5002 FUNCTION is_curr_evt_processed RETURN BOOLEAN
5003 IS
5004 l_proc varchar2(72) := g_proc_name||'is_curr_evt_processed';
5005 l_prev_event_dtl_rec ben_ext_person.t_detailed_output_tab_rec;
5006 l_flag VARCHAR2(1);
5007 BEGIN
5008 debug_enter(l_proc);
5009
5010 IF g_prev_event_dtl_rec.dated_table_id IS NOT NULL THEN
5011 l_prev_event_dtl_rec := ben_ext_person.g_pay_proc_evt_tab(ben_ext_person.g_chg_pay_evt_index);
5012 l_prev_event_dtl_rec.change_mode := g_prev_event_dtl_rec.change_mode;
5013 l_flag := 'Y';
5014 IF l_prev_event_dtl_rec.dated_table_id <> g_prev_event_dtl_rec.dated_table_id THEN
5015 l_flag := 'N';
5016 ELSIF l_prev_event_dtl_rec.datetracked_event <> g_prev_event_dtl_rec.datetracked_event THEN
5017 l_flag := 'N';
5018 ELSIF l_prev_event_dtl_rec.update_type <> g_prev_event_dtl_rec.update_type THEN
5019 l_flag := 'N';
5020 ELSIF l_prev_event_dtl_rec.surrogate_key <> g_prev_event_dtl_rec.surrogate_key THEN
5021 l_flag := 'N';
5022 ELSIF l_prev_event_dtl_rec.column_name <> g_prev_event_dtl_rec.column_name THEN
5023 l_flag := 'N';
5024 ELSIF l_prev_event_dtl_rec.effective_date <> g_prev_event_dtl_rec.effective_date THEN
5025 l_flag := 'N';
5026 ELSIF l_prev_event_dtl_rec.old_value <> g_prev_event_dtl_rec.old_value THEN
5027 l_flag := 'N';
5028 ELSIF l_prev_event_dtl_rec.new_value <> g_prev_event_dtl_rec.new_value THEN
5029 l_flag := 'N';
5030 ELSIF l_prev_event_dtl_rec.change_values <> g_prev_event_dtl_rec.change_values THEN
5031 l_flag := 'N';
5032 ELSIF l_prev_event_dtl_rec.proration_type <> g_prev_event_dtl_rec.proration_type THEN
5033 l_flag := 'N';
5034 ELSIF l_prev_event_dtl_rec.event_group_id <> g_prev_event_dtl_rec.event_group_id THEN
5035 l_flag := 'N';
5036 ELSIF l_prev_event_dtl_rec.actual_date <> g_prev_event_dtl_rec.actual_date THEN
5037 l_flag := 'N';
5038 END IF;
5039
5040 IF l_flag = 'Y' THEN
5041 debug('Event already processed',30);
5042 debug_exit(l_proc);
5043 RETURN TRUE;
5044 ELSE
5045 g_prev_event_dtl_rec := ben_ext_person.g_pay_proc_evt_tab(ben_ext_person.g_chg_pay_evt_index);
5046 END IF;
5047 ELSE
5048 debug('First event');
5049 g_prev_event_dtl_rec := ben_ext_person.g_pay_proc_evt_tab(ben_ext_person.g_chg_pay_evt_index);
5050 END IF;
5051
5052 debug_exit(l_proc);
5053 RETURN FALSE;
5054 END is_curr_evt_processed;
5055 ----
5056 -- This function evaluates whether an event should be included in the current
5057 -- report or not based on the effectiveness and application date logic
5058 -- ----------------------------------------------------------------------------
5059 -- |----------------------------< include_event >-----------------------------|
5060 -- ----------------------------------------------------------------------------
5061 FUNCTION include_event (
5062 p_actual_date IN DATE
5063 ,p_effective_date IN DATE
5064 ,p_run_from_cutover_date IN VARCHAR2 -- Bugfix 4969368
5065 )
5066 RETURN VARCHAR2
5067 IS
5068 --
5069 l_proc_name VARCHAR2(80) := g_proc_name || 'include_event';
5070 l_proc_step PLS_INTEGER;
5071 l_return VARCHAR2(10);
5072 l_chg_date DATE;
5073 l_chg_table VARCHAR2(80);
5074 l_chg_type VARCHAR2(10);
5075
5076 event_effec_date date; -- Bug Fix 9370749
5077 event_act_date date; -- Bug Fix 9370749
5078 --
5079 BEGIN
5080 --
5081 IF g_debug
5082 THEN
5083 l_proc_step := 10;
5084 debug_enter(l_proc_name);
5085 debug('p_actual_date: '||TO_CHAR(p_actual_date, 'DD/MON/YYYY'));
5086 debug('p_effective_date: '||TO_CHAR(p_effective_date, 'DD/MON/YYYY'));
5087 END IF;
5088
5089 IF g_effective_start_date IS NULL
5090 THEN
5091 -- populate the effective dates
5092 g_effective_start_date :=
5093 get_last_run_date(p_run_from_cutover_date => p_run_from_cutover_date -- Bugfix 4969368
5094 );
5095 g_effective_end_date := ben_ext_person.g_effective_date;
5096 END IF;
5097
5098 IF g_debug
5099 THEN
5100 l_proc_step := 20;
5101 debug(l_proc_name, l_proc_step);
5102 debug('g_effective_start_date: '||TO_CHAR(g_effective_start_date, 'DD/MON/YYYY'));
5103 debug('g_effective_end_date: '||TO_CHAR(g_effective_end_date, 'DD/MON/YYYY'));
5104 END IF;
5105
5106 IF NVL(g_person_id, hr_api.g_number) <> ben_ext_person.g_person_id
5107 THEN
5108 g_person_id := ben_ext_person.g_person_id;
5109 g_min_eff_date_exists := 'N';
5110 debug('NVL(g_person_id, hr_api.g_number) <> ben_ext_person.g_person_id',20);
5111 END IF;
5112
5113 -- set the start date of the range to '00:00:00'
5114 -- and set the end date of the range to '23:59:59'
5115 g_effective_start_date :=
5116 fnd_date.canonical_to_date(TO_CHAR(g_effective_start_date,'YYYY/MM/DD'));
5117 g_effective_end_date :=
5118 fnd_date.canonical_to_date((TO_CHAR(g_effective_end_date,'YYYY/MM/DD')||'23:59:59'));
5119
5120 IF g_debug
5121 THEN
5122 debug('g_effective_start_date: '||g_effective_start_date,25);
5123 debug('g_effective_end_date: '||g_effective_end_date,25);
5124 END IF;
5125
5126 --
5127 l_return := 'Y';
5128
5129 -- Check whether the actual date is between last run date and extract effective
5130 -- date or we have already found the earliest effective date or
5131 -- the effective date is within the run date range and the actual date
5132 -- is not in the future
5133
5134 IF l_return <> 'N' AND NOT is_curr_evt_processed THEN
5135 --
5136 l_return := 'N';
5137 /* Bug Fix 9370749 Start */
5138 debug('Min Eff Date exists check',28);
5139 if (ben_ext_person.g_pay_proc_evt_tab.COUNT > 0 AND
5140 g_min_eff_date_exists = 'N' AND
5141 nvl(g_dfn_name,'~') = 'SVI') then
5142 for i in 1..ben_ext_person.g_pay_proc_evt_tab.COUNT
5143 loop
5144 debug('eff_date('||i||'):'||ben_ext_person.g_pay_proc_evt_tab(i).effective_date,28);
5145 debug('act_date('||i||'):'||ben_ext_person.g_pay_proc_evt_tab(i).actual_date,28);
5146 event_effec_date := ben_ext_person.g_pay_proc_evt_tab(i).effective_date;
5147 event_act_date := ben_ext_person.g_pay_proc_evt_tab(i).actual_date;
5148 if( g_min_eff_date_exists = 'N' AND
5149 (( (event_effec_date between g_effective_start_date AND g_effective_end_date) AND
5150 event_act_date <= g_effective_end_date
5151 ) OR
5152 ( (event_act_date between g_effective_start_date AND g_effective_end_date) AND
5153 event_effec_date <= g_effective_end_date
5154 ))
5155 )
5156 then
5157 g_min_effective_date(g_assignment_id) := least(event_effec_date, p_effective_date);
5158 g_min_eff_date_exists := 'Y';
5159 debug ('L Min Effective Date Found',28);
5160 exit;
5161 end if;
5162 end loop;
5163 end if;
5164 /* Bug Fix 9370749 End */
5165
5166
5167 IF (p_actual_date BETWEEN g_effective_start_date AND g_effective_end_date
5168 AND
5169 p_effective_date <= g_effective_end_date -- bug fix 4944134
5170 )
5171 OR (
5172 (
5173 g_min_eff_date_exists = 'Y'
5174 OR p_effective_date BETWEEN g_effective_start_date
5175 AND g_effective_end_date
5176 )
5177 AND p_actual_date <= g_effective_end_date
5178 )
5179 THEN
5180 debug('Inside the Then ... ',30);
5181 IF g_min_eff_date_exists = 'N' AND
5182 NOT p_effective_date BETWEEN g_effective_start_date
5183 AND g_effective_end_date
5184 THEN
5185 debug('g_min_eff_date_exists = N and p_effective_date is not between '||
5186 'g_eff start and end dates',40);
5187 debug('g_assignment_id : '||g_assignment_id,50);
5188
5189 g_min_effective_date(g_assignment_id) := p_effective_date;
5190 g_min_eff_date_exists := 'Y';
5191
5192
5193 IF g_debug
5194 THEN
5195
5196 l_proc_step := 30;
5197 debug(l_proc_name, l_proc_step);
5198 IF g_min_effective_date.EXISTS(g_assignment_id) THEN
5199
5200 debug(
5201 'g_min_effective_date('
5202 || g_assignment_id
5203 || '): '
5204 || TO_CHAR(g_min_effective_date(g_assignment_id), 'DD/MON/YYYY')
5205 );
5206 ELSE
5207 debug('g_min_effective_date.(g_assignment_id) doesnt Exist!',60);
5208 debug('g_assignment_id : '|| g_assignment_id,70);
5209 END IF;
5210 debug('g_min_eff_date_exists: '||g_min_eff_date_exists);
5211
5212 END IF;
5213 END IF;
5214
5215 l_return := 'Y';
5216 END IF; -- End if of actual date check ...
5217 ELSE
5218 debug('the current event is already processed');
5219 l_return := 'N';
5220 END IF;
5221
5222 -- reject all purge events on element entries
5223 l_chg_type := ben_ext_person.g_chg_update_type;
5224 l_chg_table := ben_ext_person.g_chg_pay_table;
5225 l_chg_date := ben_ext_person.g_chg_eff_dt;
5226
5227 IF l_chg_table = 'PAY_ELEMENT_ENTRIES_F'
5228 AND l_chg_type = 'P'
5229 THEN
5230 debug('Current event is a Purge on element entries',20);
5231 debug('This event will be rejected.',20);
5232 l_return := 'N';
5233 END IF;
5234 ----------
5235
5236 IF g_debug
5237 THEN
5238 l_proc_step := 40;
5239 debug('l_return: '||l_return);
5240 debug_exit(l_proc_name);
5241 END IF;
5242
5243 RETURN l_return;
5244 EXCEPTION
5245 WHEN others THEN
5246 IF SQLCODE <> hr_utility.hr_error_number
5247 THEN
5248 debug_others (l_proc_name, l_proc_step);
5249 IF g_debug
5250 THEN
5251 DEBUG ( 'Leaving: '
5252 || l_proc_name, -999);
5253 END IF;
5254 fnd_message.raise_error;
5255 ELSE
5256 RAISE;
5257 END IF;
5258 END include_event;
5259
5260
5261 -- This procedure will be used in the future to add any new logic for
5262 -- retro event processing
5263 -- ----------------------------------------------------------------------------
5264 -- |----------------------------< process_retro_event >-----------------------|
5265 -- ----------------------------------------------------------------------------
5266 PROCEDURE process_retro_event
5267 (
5268 p_include VARCHAR2 DEFAULT 'Y'
5269 )
5270 IS
5271 --
5272 l_proc_name VARCHAR2(80) := g_proc_name || 'process_retro_event';
5273 l_proc_step PLS_INTEGER;
5274 l_value NUMBER;
5275 --
5276 BEGIN
5277 --
5278 IF g_debug
5279 THEN
5280 l_proc_step := 10;
5281 debug_enter(l_proc_name);
5282 END IF;
5283
5284 -- At the moment check for presence of any retro events and raise a
5285 -- suitable warning message
5286 IF g_min_effective_date.EXISTS(g_assignment_id)
5287 THEN
5288 IF g_debug
5289 THEN
5290 DEBUG('Raise Warning Message: Retro Event Exists');
5291 DEBUG(
5292 'g_min_effective_date('
5293 || g_assignment_id
5294 || '): '
5295 || g_min_effective_date(g_assignment_id)
5296 );
5297 END IF;
5298
5299 -- retro event exists
5300 l_value :=
5301 raise_extract_warning(
5302 p_error_text => 'BEN_94482_EXT_PSI_OVR_EVNT_WRN'
5303 ,p_error_number => 94482
5304 ,p_token1 => fnd_date.date_to_displaydt(g_min_effective_date(g_assignment_id))
5305 );
5306
5307
5308 IF NOT g_retro_event_date_reported THEN
5309 -- if the retro event date is not reported in the DE
5310 -- if p_include is 'N' check if this is the last event.
5311 debug('Retro event date is not reported',20);
5312 IF p_include = 'N' THEN
5313 IF is_curr_last_event() THEN
5314 -- raise data error
5315 debug('Raise an error as the delete event could not be reported',30);
5316 debug('Current event is the last event, g_retro_event_date_reported is rest to true.',30);
5317 l_value :=
5318 raise_extract_error(
5319 p_error_text => 'BEN_94540_FIRST_RETRO_DATE'
5320 ,p_error_number => 94540
5321 ,p_token1 => fnd_date.date_to_displaydt(g_min_effective_date(g_assignment_id))
5322 );
5323 g_retro_event_date_reported := TRUE;
5324 END IF;
5325 ELSE
5326 debug('Delete date should be reported in the current row: '||g_min_effective_date(g_assignment_id),20);
5327 END IF;
5328 ELSE
5329 -- clear the retro_event_date global value, so that the DE reports a null value.
5330 debug('retro event date is already reported.',20);
5331
5332 END IF; --IF NOT g_retro_event_date_reported
5333
5334 END IF; -- End if of min effective date exists check ...
5335 IF g_debug
5336 THEN
5337 l_proc_step := 20;
5338 debug_exit(l_proc_name);
5339 END IF;
5340 EXCEPTION
5341 WHEN OTHERS
5342 THEN
5343 IF SQLCODE <> hr_utility.hr_error_number
5344 THEN
5345 debug_others(l_proc_name, l_proc_step);
5346
5347 IF g_debug
5348 THEN
5349 DEBUG('Leaving: ' || l_proc_name, -999);
5350 END IF;
5351
5352 fnd_message.raise_error;
5353 ELSE
5354 RAISE;
5355 END IF;
5356 END process_retro_event;
5357 -- ----------------------------------------------------------------------------
5358 -- |--------------------------< get_dated_table_name >-------------------------|
5359 -- Description:
5360 -- ----------------------------------------------------------------------------
5361 FUNCTION get_dated_table_name
5362 (
5363 p_dated_table_id NUMBER
5364 )RETURN VARCHAR2
5365 IS
5366 l_table_name VARCHAR2(80);
5367 CURSOR csr_dated_table_name
5368 IS
5369 SELECT table_name
5370 FROM pay_dated_tables
5371 WHERE dated_table_id = p_dated_table_id;
5372 BEGIN
5373 IF NOT g_dated_tables.exists(p_dated_table_id) THEN
5374 OPEN csr_dated_table_name;
5375 FETCH csr_dated_table_name INTO l_table_name;
5376 CLOSE csr_dated_table_name;
5377 g_dated_tables(p_dated_table_id) := l_table_name;
5378 END IF;
5379
5380 return g_dated_tables(p_dated_table_id);
5381 END get_dated_table_name;
5382
5383
5384 -- ----------------------------------------------------------------------------
5385 -- |----------------------< chk_is_employee_a_leaver >--------------------------|
5386 -- Description: This is to check if the assignment is ending on the effective date
5387 -- p_leaver_date will be the value of the assignment leaver date.
5388 -- ----------------------------------------------------------------------------
5389 FUNCTION chk_is_employee_a_leaver
5390 (
5391 p_assignment_id NUMBER
5392 ,p_effective_date DATE
5393 ,p_leaver_date OUT NOCOPY DATE
5394 ) RETURN VARCHAR2
5395 IS
5396 l_proc varchar2(72) := g_proc_name||'chk_is_employee_a_leaver';
5397 l_leaver VARCHAR2(1) := 'N';
5398 l_pay_assg_status VARCHAR2(20);
5399 CURSOR csr_asg_details_up -- effective first then future rows
5400 (p_assignment_id NUMBER
5401 ,p_effective_date DATE DEFAULT NULL
5402 )
5403 IS
5404 SELECT asg.person_id person_id
5405 ,asg.assignment_id assignment_id
5406 ,asg.business_group_id business_group_id
5407 ,asg.effective_start_date start_date
5408 ,asg.effective_end_date effective_end_date
5409 ,asg.creation_date creation_date
5410 ,asg.assignment_status_type_id status_type_id
5411 ,' ' status_type
5412 FROM per_all_assignments_f asg
5413
5414 WHERE asg.assignment_id = p_assignment_id
5415 AND (( p_effective_date BETWEEN asg.effective_start_date
5416 AND asg.effective_end_date )
5417 OR
5418 ( asg.effective_start_date = p_effective_date + 1 ) -- modified for 115.68
5419 )
5420 ORDER BY asg.effective_start_date ASC; -- effective first then future rows
5421
5422 CURSOR csr_assignment_status
5423 (
5424 p_assignment_status_type_id NUMBER
5425 )
5426 IS
5427 SELECT DECODE(pay_system_status,'D','DO NOT PROCESS','P','PROCESS')
5428 ,per_system_status
5429 FROM per_assignment_status_types
5430 WHERE ASSIGNMENT_STATUS_TYPE_ID = p_assignment_status_type_id
5431 AND primary_flag = 'P';
5432
5433 l_asg_details csr_asg_details_up%ROWTYPE;
5434 l_next_asg_details csr_asg_details_up%ROWTYPE;
5435 BEGIN
5436 debug_enter(l_proc);
5437
5438 OPEN csr_asg_details_up
5439 (p_assignment_id
5440 ,p_effective_date - 1
5441 );
5442 FETCH csr_asg_details_up INTO l_asg_details;
5443 IF csr_asg_details_up%FOUND THEN
5444 debug('Inside IF , found ASG record',30);
5445 -- Get the per_system_status for the assignment_status_type_id
5446 OPEN csr_assignment_status(l_asg_details.status_type_id);
5447 FETCH csr_assignment_status INTO l_pay_assg_status,l_asg_details.status_type;
5448 CLOSE csr_assignment_status;
5449
5450 debug('l_asg_details.status_type: '||l_asg_details.status_type,20);
5451 debug('l_asg_details.effective_start_date: '||l_asg_details.start_date,20);
5452 debug('l_asg_details.effective_end_date: '||l_asg_details.effective_end_date,20);
5453
5454 -- Get the next assignment and compare status type
5455 FETCH csr_asg_details_up INTO l_next_asg_details;
5456 OPEN csr_assignment_status(l_next_asg_details.status_type_id);
5457 FETCH csr_assignment_status INTO l_pay_assg_status,l_next_asg_details.status_type;
5458 CLOSE csr_assignment_status;
5459
5460 debug('After second fetch',40);
5461 debug('l_next_asg_details.status_type: '||l_next_asg_details.status_type,20);
5462 debug('l_next_asg_details.effective_start_date: '||l_next_asg_details.start_date,20);
5463 debug('l_next_asg_details.effective_end_date: '||l_next_asg_details.effective_end_date,20);
5464 IF (csr_asg_details_up%FOUND
5465 AND
5466 l_asg_details.status_type <> l_next_asg_details.status_type
5467 AND
5468 l_next_asg_details.status_type IN ('TERM_ASSIGN','SUSP_ASSIGN','END')
5469 )
5470 OR
5471 -- No future rows found
5472 (csr_asg_details_up%NOTFOUND
5473 AND
5474 -- But the current assignment has been suspended or is Active
5475 -- Added Active as a bugfix as END Employment does not change status
5476 -- when the termination happens on the last day of the payroll period
5477
5478 --l_asg_details.status_type IN ('SUSP_ASSIGN','ACTIVE_ASSIGN')
5479 l_asg_details.effective_end_date = p_effective_date
5480 )
5481 THEN
5482
5483 -- Assignment has been terminated/suspended/ended
5484 l_leaver := 'Y';
5485 p_leaver_date := l_asg_details.effective_end_date;
5486
5487 debug('Assignment is a leaver',50);
5488
5489 END IF; -- csr_asg_details_up%FOUND THEN
5490 END IF; -- IF csr_asg_details_up%FOUND
5491
5492 IF csr_asg_details_up%ISOPEN THEN
5493 CLOSE csr_asg_details_up;
5494 END IF;
5495
5496 debug_exit(l_proc);
5497 return l_leaver;
5498 EXCEPTION
5499 WHEN others THEN
5500 IF SQLCODE <> hr_utility.hr_error_number
5501 THEN
5502 debug_others (l_proc, 10);
5503 IF g_debug
5504 THEN
5505 DEBUG ( 'Leaving: '
5506 || l_proc, -999);
5507 END IF;
5508 fnd_message.raise_error;
5509 ELSE
5510 RAISE;
5511 END IF;
5512 END chk_is_employee_a_leaver;
5513 ------
5514
5515
5516 -- ----------------------------------------------------------------------------
5517 -- |-----------------------< is_proper_claim_date >--------------------------|
5518 -- Description:
5519 -- ----------------------------------------------------------------------------
5520 FUNCTION is_proper_claim_date
5521 (
5522 p_claim_date IN DATE
5523 ,p_element_name IN VARCHAR2
5524 ,p_element_entry_id IN NUMBER
5525 ,p_assg_start_date IN DATE
5526 )RETURN BOOLEAN
5527 IS
5528 l_proc varchar2(72) := g_proc_name||'is_proper_claim_date';
5529 l_temp NUMBER;
5530 l_return BOOLEAN;
5531 l_include VARCHAR2(10) := 'Y';
5532 l_assignment_status_type_id NUMBER;
5533 l_pay_assg_status VARCHAR2(20);
5534 l_per_assg_status per_assignment_status_types.per_system_status%TYPE;
5535 l_curr_person_dtls per_all_people_f%ROWTYPE;
5536 -- this contains the person details on effective date
5537
5538 l_curr_assg_dtls per_all_assignments_f%ROWTYPE;
5539 -- this contains the person details on effective date
5540 CURSOR csr_assignment_status
5541 (
5542 p_assignment_status_type_id NUMBER
5543 )
5544 IS
5545 SELECT DECODE(pay_system_status,'D','DO NOT PROCESS','P','PROCESS')
5546 ,per_system_status
5547 FROM per_assignment_status_types
5548 WHERE ASSIGNMENT_STATUS_TYPE_ID = p_assignment_status_type_id
5549 AND primary_flag = 'P';
5550
5551 BEGIN -- is_future_claim
5552 debug_enter(l_proc);
5553 IF g_debug THEN
5554 debug('Inputs are: ',10);
5555 debug('p_claim_date: '||p_claim_date,10);
5556 debug('p_element_name: '||p_element_name,10);
5557 debug('p_element_entry_id: '||p_element_entry_id,10);
5558 debug('p_assg_start_date: '||p_assg_start_date,10);
5559
5560 debug('g_effective_start_date: '||PQP_GB_PSI_FUNCTIONS.g_effective_start_date);
5561 debug('g_effective_end_date: '||PQP_GB_PSI_FUNCTIONS.g_effective_end_date);
5562 END IF;
5563
5564
5565 IF p_claim_date < p_assg_start_date THEN
5566 -- claim date is before the start date of the person
5567 debug('ERROR: Future Claim Date: '||ben_ext_person.g_chg_surrogate_key);
5568 l_temp := PQP_GB_PSI_FUNCTIONS.raise_extract_error
5569 (p_error_number => 94513
5570 ,p_error_text => 'BEN_94513_EARLY_CLAIM_DATE'
5571 ,p_token1 => p_claim_date
5572 ,p_token2 => SUBSTR(p_element_name
5573 ||'('||p_element_entry_id||')',1,80)
5574 );
5575
5576 debug('Returning FALSE',20);
5577 debug_exit(l_proc);
5578 RETURN FALSE;
5579
5580 END IF; --IF p_claim_date > PQP_GB_PSI_FUNCTIONS.g_effective_end_date THEN
5581
5582 IF p_claim_date > PQP_GB_PSI_FUNCTIONS.g_effective_end_date THEN
5583
5584 debug('ERROR: Future Claim Date: '||ben_ext_person.g_chg_surrogate_key);
5585 l_temp := PQP_GB_PSI_FUNCTIONS.raise_extract_error
5586 (p_error_number => 94512
5587 ,p_error_text => 'BEN_94512_FUTURE_CLAIM_DATE'
5588 ,p_token1 => p_claim_date
5589 ,p_token2 => SUBSTR(p_element_name
5590 ||'('||p_element_entry_id||')',1,80)
5591 );
5592
5593 debug('Returning FALSE',20);
5594 debug_exit(l_proc);
5595 RETURN FALSE;
5596
5597 END IF;
5598
5599 l_assignment_status_type_id := l_curr_assg_dtls.assignment_status_type_id;
5600 OPEN csr_assignment_status(l_assignment_status_type_id);
5601 FETCH csr_assignment_status INTO l_pay_assg_status,l_per_assg_status;
5602 CLOSE csr_assignment_status;
5603
5604 debug('l_assignment_status_type_id: '||l_assignment_status_type_id,20);
5605 debug('l_pay_assg_status: '||l_pay_assg_status,20);
5606 debug('l_per_assg_status: '||l_per_assg_status,20);
5607 IF l_pay_assg_status = 'DO NOT PROCESS'
5608 OR l_per_assg_status IN ('TERM_ASSIGN','SUSP_ASSIGN','END') THEN
5609
5610 debug('ERROR: Assignment does not qualify on the claim date');
5611 l_temp := PQP_GB_PSI_FUNCTIONS.raise_extract_error
5612 (p_error_number => 94539
5613 ,p_error_text => 'BEN_94539_ASG_TERM_CLAIM_DATE'
5614 ,p_token1 => p_claim_date
5615 ,p_token2 => SUBSTR(p_element_name
5616 ||'('||p_element_entry_id||')',1,80)
5617 );
5618 l_include := 'N';
5619 ELSE
5620 debug('Assignment status is a valid one.',30);
5621 l_include := 'Y';
5622 END IF;
5623
5624 IF l_include <> 'N' THEN
5625
5626 l_include := PQP_GB_PSI_FUNCTIONS.chk_penserver_basic_criteria
5627 (p_business_group_id => g_business_group_id
5628 ,p_effective_date => p_claim_date
5629 ,p_assignment_id => g_assignment_id
5630 ,p_person_dtl => l_curr_person_dtls
5631 ,p_assignment_dtl => l_curr_assg_dtls
5632 );
5633
5634 IF l_include = 'N' THEN
5635 debug('ERROR: Assignment does not qualify on the claim date');
5636 l_temp := PQP_GB_PSI_FUNCTIONS.raise_extract_error
5637 (p_error_number => 94542
5638 ,p_error_text => 'BEN_94542_ASG_INV_CLAIM_DATE'
5639 ,p_token1 => p_claim_date
5640 ,p_token2 => SUBSTR(p_element_name
5641 ||'('||p_element_entry_id||')',1,80)
5642 );
5643 l_include := 'N';
5644
5645 END IF;
5646
5647 END IF;
5648 IF l_include = 'N' THEN
5649 l_return := FALSE;
5650 debug('Returning FALSE',20);
5651 ELSE
5652 l_return := TRUE;
5653 debug('Returning TRUE',20);
5654 END IF;
5655
5656 debug_exit(l_proc);
5657 RETURN l_return;
5658 EXCEPTION
5659 WHEN others THEN
5660 IF SQLCODE <> hr_utility.hr_error_number
5661 THEN
5662 debug_others (l_proc, 10);
5663 IF g_debug
5664 THEN
5665 DEBUG ( 'Leaving: '
5666 || l_proc, -999);
5667 END IF;
5668 fnd_message.raise_error;
5669 ELSE
5670 RAISE;
5671 END IF;
5672 END is_proper_claim_date;
5673
5674
5675
5676 -- ----------------------------------------------------------------------------
5677 -- |------------------------< get_elements_of_info_type >----------------------|
5678 -- ----------------------------------------------------------------------------
5679 PROCEDURE get_elements_of_info_type
5680 (p_information_type IN VARCHAR2
5681 ,p_input_value IN VARCHAR2 DEFAULT 'PAY VALUE'
5682 ,p_input_value_mandatory_yn IN VARCHAR2 DEFAULT 'Y'
5683 )
5684 IS
5685 --
5686 l_proc_name VARCHAR2(61):=
5687 g_proc_name||'get_elements_of_info_type';
5688
5689
5690 BEGIN
5691 debug_enter(l_proc_name);
5692 debug ('p_information_type:'||p_information_type);
5693
5694 IF p_input_value_mandatory_yn = 'Y'
5695 THEN
5696
5697 FOR l_elements_rec in csr_get_elements_of_info_type
5698 (c_information_type => p_information_type
5699 ,c_input_value => p_input_value
5700 )
5701 LOOP
5702
5703 IF l_elements_rec.element_type_id IS NOT NULL
5704 THEN
5705 debug('element_type_id : '||l_elements_rec.element_type_id);
5706 debug('element_name : '||l_elements_rec.element_name);
5707 debug('input_value_id : '||l_elements_rec.input_value_id);
5708 debug('processing_type : '||l_elements_rec.processing_type);
5709 debug('eei_information1 : '||l_elements_rec.eei_information1);
5710 debug('eei_information2 : '||l_elements_rec.eei_information2);
5711 debug('eei_information3 : '||l_elements_rec.eei_information3);
5712 debug('eei_information4 : '||l_elements_rec.eei_information4);
5713 debug('eei_information5 : '||l_elements_rec.eei_information5);
5714 debug('eei_information6 : '||l_elements_rec.eei_information6);
5715 debug('eei_information7 : '||l_elements_rec.eei_information7);
5716 debug('eei_information8 : '||l_elements_rec.eei_information8);
5717 debug('eei_information9 : '||l_elements_rec.eei_information9);
5718 debug('eei_information10 : '||l_elements_rec.eei_information10);
5719 debug('retro_summ_ele_id : '||l_elements_rec.retro_summ_ele_id);
5720
5721 g_elements_of_info_type(l_elements_rec.element_type_id) := l_elements_rec;
5722 END IF;
5723
5724 END LOOP;
5725 ELSE
5726 FOR l_elements_rec_no_inp_val in csr_ele_info_type_no_inp_val
5727 (c_information_type => p_information_type
5728 )
5729 LOOP
5730
5731 IF l_elements_rec_no_inp_val.element_type_id IS NOT NULL
5732 THEN
5733 debug('element_type_id : '||l_elements_rec_no_inp_val.element_type_id);
5734 debug('element_name : '||l_elements_rec_no_inp_val.element_name);
5735 debug('processing_type : '||l_elements_rec_no_inp_val.processing_type);
5736 debug('eei_information1 : '||l_elements_rec_no_inp_val.eei_information1);
5737 debug('eei_information2 : '||l_elements_rec_no_inp_val.eei_information2);
5738 debug('eei_information3 : '||l_elements_rec_no_inp_val.eei_information3);
5739 debug('eei_information4 : '||l_elements_rec_no_inp_val.eei_information4);
5740 debug('eei_information5 : '||l_elements_rec_no_inp_val.eei_information5);
5741 debug('eei_information6 : '||l_elements_rec_no_inp_val.eei_information6);
5742 debug('eei_information7 : '||l_elements_rec_no_inp_val.eei_information7);
5743 debug('eei_information8 : '||l_elements_rec_no_inp_val.eei_information8);
5744 debug('eei_information9 : '||l_elements_rec_no_inp_val.eei_information9);
5745 debug('eei_information10 : '||l_elements_rec_no_inp_val.eei_information10);
5746 debug('retro_summ_ele_id : '||l_elements_rec_no_inp_val.retro_summ_ele_id);
5747
5748 g_elements_of_info_type(l_elements_rec_no_inp_val.element_type_id) := l_elements_rec_no_inp_val;
5749 END IF;
5750
5751 END LOOP;
5752 END IF;
5753
5754 debug_exit(l_proc_name);
5755
5756 EXCEPTION
5757 WHEN others THEN
5758 IF SQLCODE <> hr_utility.hr_error_number
5759 THEN
5760 debug_others (l_proc_name, 10);
5761 IF g_debug
5762 THEN
5763 DEBUG ( 'Leaving: '
5764 || l_proc_name, -999);
5765 END IF;
5766 fnd_message.raise_error;
5767 ELSE
5768 RAISE;
5769 END IF;
5770
5771 END get_elements_of_info_type;
5772
5773
5774
5775 -- ----------------------------------------------------------------------------
5776 -- |------------------------< check_if_element_qualifies >----------------------|
5777 -- ----------------------------------------------------------------------------
5778 PROCEDURE check_if_element_qualifies
5779 (p_element_entry_id IN NUMBER
5780 ,p_element_type_id OUT NOCOPY NUMBER
5781 ,p_include OUT NOCOPY VARCHAR2 -- Y/N
5782 ,p_extract_type IN VARCHAR2 DEFAULT 'PERIODIC'
5783 ,p_element_type_id_from_crit IN NUMBER DEFAULT NULL
5784 )
5785 IS
5786 --
5787 l_proc_name VARCHAR2(61):=
5788 g_proc_name||'check_if_element_qualifies';
5789
5790 l_element_type_id NUMBER;
5791
5792 BEGIN
5793 debug_enter(l_proc_name);
5794 debug ('p_element_entry_id:'||p_element_entry_id);
5795
5796 -- check if this element_entry_id has been processed earlier
5797 -- if yes, return data from global collection
5798 IF g_elements_processed.EXISTS(p_element_entry_id)
5799 THEN
5800 debug('found p_element_entry_id in g_elements_processed',10);
5801
5802 p_element_type_id :=
5803 g_elements_processed(p_element_entry_id).element_type_id;
5804
5805 /*
5806 -- if cutover, then dont process the same element twice
5807 -- hence send inclusion flag as 'N' if found in collection
5808 IF p_extract_type = 'CUTOVER'
5809 THEN
5810 p_include := 'N';
5811 ELSE
5812 p_include :=
5813 g_elements_processed(p_element_entry_id).inclusion_flag;
5814 END IF;
5815 */
5816
5817 p_include :=
5818 g_elements_processed(p_element_entry_id).inclusion_flag;
5819
5820 g_curr_element_type_id := p_element_type_id;
5821 g_curr_element_entry_id := p_element_entry_id;
5822
5823 debug('g_curr_element_type_id : '||g_curr_element_type_id, 20);
5824 debug('g_curr_element_entry_id : '||g_curr_element_entry_id, 30);
5825
5826
5827 ELSE -- 1st time processing, not found in g_elements_processed
5828
5829 -- if CUTOVER, implies that this has been called from Payroll_Rule
5830 -- and element_type_id has been passed as p_element_type_id_from_crit
5831 --
5832 debug('first time processing ...');
5833 debug('p_extract_type :' || p_extract_type, 20);
5834 debug('p_element_type_id_from_crit :' || p_element_type_id_from_crit, 30);
5835
5836 IF p_extract_type = 'CUTOVER' -- from cutover rule : element repeating
5837 OR p_element_type_id_from_crit IS NOT NULL -- from periodic rule : element repeating
5838 THEN
5839 p_element_type_id := p_element_type_id_from_crit;
5840 ELSE -- PERIODIC run : person repeating
5841
5842 OPEN csr_get_element_type_id
5843 (c_element_entry_id => p_element_entry_id
5844 );
5845 FETCH csr_get_element_type_id INTO l_element_type_id;
5846 IF csr_get_element_type_id%NOTFOUND
5847 THEN
5848 debug('element_type_id not found', 40);
5849 p_element_type_id := -1; -- returning -1 when not found
5850 p_include := 'N';
5851 ELSE
5852 p_element_type_id := l_element_type_id;
5853 debug('l_element_type_id : ' || l_element_type_id, 50);
5854 END IF; -- csr_get_element_type_id%NOTFOUND
5855 CLOSE csr_get_element_type_id;
5856
5857 END IF;
5858 --
5859
5860 -- now check if this element_type_id exists in the global collection
5861 IF g_elements_of_info_type.EXISTS(p_element_type_id)
5862 THEN
5863 p_include := 'Y';
5864 ELSE
5865 p_include := 'N';
5866 END IF;
5867 debug('p_include : ' || p_include, 60);
5868
5869 -- store in a collection for future use in the beginning IF statement
5870 g_elements_processed(p_element_entry_id).element_type_id := p_element_type_id;
5871 g_elements_processed(p_element_entry_id).inclusion_flag := p_include;
5872
5873 g_curr_element_type_id := p_element_type_id;
5874 g_curr_element_entry_id := p_element_entry_id;
5875
5876 debug('g_curr_element_type_id : '||g_curr_element_type_id, 70);
5877 debug('g_curr_element_entry_id : '||g_curr_element_entry_id, 80);
5878
5879 END IF; -- g_elements_processed.EXISTS(p_element_entry_id)
5880
5881
5882 debug_exit(l_proc_name);
5883 EXCEPTION
5884 WHEN others THEN
5885 IF SQLCODE <> hr_utility.hr_error_number
5886 THEN
5887 debug_others (l_proc_name, 10);
5888 IF g_debug
5889 THEN
5890 DEBUG ( 'Leaving: '
5891 || l_proc_name, -999);
5892 END IF;
5893 fnd_message.raise_error;
5894 ELSE
5895 RAISE;
5896 END IF;
5897
5898 END check_if_element_qualifies;
5899
5900
5901
5902
5903 -- ----------------------------------------------------------------------------
5904 -- |------------------------< calc_payment_by_run_rslt >----------------------|
5905 -- ----------------------------------------------------------------------------
5906 -- to return the run result value for the assignment
5907
5908 FUNCTION calc_payment_by_run_rslt
5909 (p_assignment_id IN NUMBER
5910 ,p_element_entry_id IN NUMBER
5911 ,p_element_type_id IN NUMBER
5912 ,p_date_earned IN DATE
5913 ) RETURN NUMBER
5914 IS
5915
5916 l_proc_name VARCHAR2(61):=
5917 g_proc_name||'calc_payment_by_run_rslt';
5918
5919
5920 l_asg_act_id NUMBER := NULL;
5921 l_retro_asg_act_id NUMBER := NULL;
5922
5923 l_run_result_value NUMBER := NULL;
5924 l_retro_run_result_value NUMBER := 0;
5925 l_run_result_id NUMBER;
5926
5927 l_element_type_id NUMBER;
5928 l_input_value_id NUMBER;
5929
5930 l_retro_element_type_id NUMBER;
5931
5932 -- cursor to find retro_element_type_id
5933 CURSOR csr_get_retro_ele_type_id
5934 IS
5935 select retro_summ_ele_id
5936 from pay_element_types_f
5937 where element_type_id = p_element_type_id
5938 and rownum=1;
5939
5940
5941 BEGIN
5942 debug_enter(l_proc_name);
5943
5944 debug('p_assignment_id :' || p_assignment_id);
5945 debug('p_element_entry_id :'||p_element_entry_id);
5946 debug('p_element_type_id :'||p_element_type_id);
5947 debug('p_date_earned :' || p_date_earned);
5948
5949
5950 -- Step 1) get assignment action id
5951 OPEN csr_get_asg_act_id
5952 ( p_assignment_id => p_assignment_id
5953 ,p_date_earned => p_date_earned
5954 );
5955 LOOP -- 115.60 : loop thru all assignment actions
5956
5957 FETCH csr_get_asg_act_id INTO l_asg_act_id;
5958 EXIT WHEN csr_get_asg_act_id%NOTFOUND;
5959
5960 debug('l_asg_act_id : '||l_asg_act_id, 15);
5961 debug('call csr_get_run_result_value for this assignment action id ...',17);
5962
5963 -- Step 2) find run_results for this assignment_action, element entry and input value
5964 OPEN csr_get_run_result_value
5965 (p_element_entry_id => p_element_entry_id -- p_element_type_id
5966 ,p_input_value_id =>
5967 g_elements_of_info_type(p_element_type_id).input_value_id
5968 ,p_asg_act_id => l_asg_act_id
5969 );
5970 FETCH csr_get_run_result_value INTO l_run_result_value, l_run_result_id;
5971 IF csr_get_run_result_value%FOUND
5972 THEN
5973 debug('l_run_result_value found....',20);
5974 debug('l_run_result_value : '||l_run_result_value);
5975 CLOSE csr_get_run_result_value;
5976 EXIT; -- if the run result was found in this assignment_action_id,
5977 -- then exit
5978 -- else go for next assignment_action_id
5979 END IF;
5980 debug('l_run_result_value not found yet',25);
5981 CLOSE csr_get_run_result_value;
5982
5983 END LOOP;
5984 CLOSE csr_get_asg_act_id;
5985
5986 --
5987 -- added as part of 115.58 (3)
5988 --
5989 -- BLOCK for retro payments
5990
5991 -- 1) find if this element has a retro element
5992 IF g_elements_of_info_type(p_element_type_id).retro_summ_ele_id IS NOT NULL
5993 THEN -- retro element is attached to this element
5994
5995 debug('this main element has a retro element ',40);
5996
5997 l_retro_element_type_id :=
5998 g_elements_of_info_type(p_element_type_id).retro_summ_ele_id;
5999 debug('l_retro_element_type_id :' || l_retro_element_type_id,50);
6000
6001 -- 2) retro element has been found for this main element,
6002 -- now find retro assignment action id
6003
6004 OPEN csr_get_asg_act_id_retro
6005 ( p_assignment_id => p_assignment_id
6006 ,p_date_earned => p_date_earned
6007 );
6008 LOOP
6009 FETCH csr_get_asg_act_id_retro INTO l_retro_asg_act_id;
6010 EXIT WHEN csr_get_asg_act_id_retro%NOTFOUND;
6011
6012 debug('l_retro_asg_act_id : '||l_retro_asg_act_id, 35);
6013
6014 -- 3) now find and add retro payments which were earned in this month
6015 FOR l_retro_run_results IN csr_get_retro_run_value
6016 (p_assignment_action_id => l_retro_asg_act_id
6017 ,p_effective_date => ben_ext_person.g_effective_date
6018 )
6019 LOOP
6020 debug('input_value_id : '|| l_retro_run_results.input_value_id,60);
6021 debug('result_value : '|| l_retro_run_results.result_value);
6022 debug('effective_date : '|| l_retro_run_results.effective_date);
6023 debug('element_entry_id : '|| l_retro_run_results.element_entry_id);
6024 debug('element_type_id : '|| l_retro_run_results.element_type_id);
6025 debug('effective_start_date : '|| l_retro_run_results.effective_start_date);
6026 debug('effective_end_date : '|| l_retro_run_results.effective_end_date);
6027 debug('Element source_id : '|| l_retro_run_results.ee_source_id);
6028 debug('Run Result source_id : '|| l_retro_run_results.rr_source_id);
6029 debug('status : '|| l_retro_run_results.status);
6030 debug('source_type : '|| l_retro_run_results.source_type);
6031
6032
6033 IF l_retro_run_results.result_value IS NOT NULL
6034 and l_retro_run_results.element_type_id = l_retro_element_type_id
6035 and l_retro_run_results.ee_source_id = l_run_result_id
6036 THEN -- run result is not empty
6037 -- and element_type_id of retro element = retro_summ_ele_id of main element
6038 -- 3) add all retro values of this element and this payroll period
6039 l_retro_run_result_value :=
6040 l_retro_run_result_value + l_retro_run_results.result_value;
6041
6042 debug('l_retro_run_result_value : '|| l_retro_run_result_value);
6043 END IF;
6044 END LOOP;
6045
6046 END LOOP; -- OPEN csr_get_asg_act_id_retro
6047 CLOSE csr_get_asg_act_id_retro;
6048
6049 END IF; -- IF g_elements_of_info_type(p_element_type_id).retro_summ_ele_id IS NOT NULL
6050
6051
6052 debug('l_run_result_value : ' || l_run_result_value,70);
6053 debug('l_retro_run_result_value : ' || l_retro_run_result_value,80);
6054 -- add the run results and retro results
6055 IF l_run_result_value IS NOT NULL
6056 OR l_retro_run_result_value IS NOT NULL
6057 THEN
6058 l_run_result_value := nvl(l_run_result_value,0) + nvl(l_retro_run_result_value,0);
6059 END IF;
6060
6061 debug('l_run_result_value : ' || l_run_result_value,90);
6062
6063 debug_exit(l_proc_name);
6064
6065 return l_run_result_value;
6066
6067 EXCEPTION
6068 WHEN others THEN
6069 IF SQLCODE <> hr_utility.hr_error_number
6070 THEN
6071 debug_others (l_proc_name, 10);
6072 IF g_debug
6073 THEN
6074 DEBUG ( 'Leaving: '
6075 || l_proc_name, -999);
6076 END IF;
6077 fnd_message.raise_error;
6078 ELSE
6079 RAISE;
6080 END IF;
6081
6082 END calc_payment_by_run_rslt;
6083
6084
6085 -- ----------------------------------------------------------------------------
6086 -- |------------------------< get_element_payment >---------------------------|
6087 -- ----------------------------------------------------------------------------
6088
6089 FUNCTION get_element_payment
6090 (p_assignment_id IN NUMBER
6091 ,p_element_entry_id IN NUMBER
6092 ,p_element_type_id IN NUMBER
6093 ,p_effective_date IN DATE
6094 ) RETURN NUMBER
6095 IS
6096
6097
6098 l_proc_name VARCHAR2(61):=
6099 g_proc_name||'get_element_payment';
6100
6101 l_date_earned DATE;
6102 l_payment NUMBER := NULL;
6103
6104 BEGIN
6105
6106 debug_enter(l_proc_name);
6107 debug('p_assignment_id :' || p_assignment_id) ;
6108 debug('p_effective_date :' ||to_char(p_effective_date,'DD/MM/YYYY')) ;
6109
6110 OPEN csr_get_next_payroll_date
6111 ( p_assignment_id => p_assignment_id
6112 ,p_effective_date => p_effective_date
6113 );
6114 FETCH csr_get_next_payroll_date INTO l_date_earned;
6115
6116 IF csr_get_next_payroll_date%FOUND THEN
6117
6118 debug('l_date_earned :' ||to_char(l_date_earned,'DD/MM/YYYY')) ;
6119 l_payment := calc_payment_by_run_rslt
6120 ( p_assignment_id => p_assignment_id
6121 ,p_element_entry_id => p_element_entry_id
6122 ,p_element_type_id => p_element_type_id
6123 ,p_date_earned => l_date_earned
6124 );
6125 debug('l_payment :' || l_payment);
6126
6127 ELSE
6128 debug('csr_get_next_payroll_date not found') ;
6129 --l_payment := 0;
6130 END IF;
6131
6132 CLOSE csr_get_next_payroll_date;
6133
6134 debug_exit(l_proc_name);
6135 return l_payment;
6136
6137 EXCEPTION
6138 WHEN others THEN
6139 IF SQLCODE <> hr_utility.hr_error_number
6140 THEN
6141 debug_others (l_proc_name, 10);
6142 IF g_debug
6143 THEN
6144 DEBUG ( 'Leaving: '
6145 || l_proc_name, -999);
6146 END IF;
6147 fnd_message.raise_error;
6148 ELSE
6149 RAISE;
6150 END IF;
6151
6152 END get_element_payment;
6153
6154
6155
6156 -- ----------------------------------------------------------------------------
6157 -- |------------------------< get_value_from_balance >----------------------|
6158 -- ----------------------------------------------------------------------------
6159 -- to return the balance value of an assignment, date earned, element entry
6160 FUNCTION get_value_from_balance
6161 (p_assignment_id IN NUMBER
6162 ,p_element_entry_id IN NUMBER
6163 ,p_balance_type_id IN NUMBER
6164 ,p_date_earned IN DATE
6165 ,p_asg_act_id OUT NOCOPY NUMBER
6166 ,p_retro_asg_act_id OUT NOCOPY NUMBER
6167 ) RETURN NUMBER
6168 IS
6169
6170 l_proc_name VARCHAR2(61):=
6171 g_proc_name||'get_value_from_balance';
6172
6173 l_asg_act_id NUMBER := NULL;
6174 l_source_asg_act_id NUMBER := NULL;
6175 l_balance_value NUMBER := NULL;
6176
6177 BEGIN
6178
6179 debug_enter(l_proc_name);
6180
6181 -- Step 1) get assignment action id
6182 OPEN csr_get_all_asg_act_id
6183 ( p_assignment_id => p_assignment_id
6184 ,p_date_earned => p_date_earned
6185 ,p_element_entry_id => p_element_entry_id
6186 );
6187 LOOP -- loop thru all assignment actions
6188
6189 FETCH csr_get_all_asg_act_id INTO l_asg_act_id, l_source_asg_act_id;
6190 EXIT WHEN csr_get_all_asg_act_id%NOTFOUND;
6191
6192 debug('l_asg_act_id : '||l_asg_act_id, 15);
6193 debug('l_source_asg_act_id : '||l_source_asg_act_id, 16);
6194 debug('call hr_gbbal.calc_element_ptd_bal for this assignment action id ...',17);
6195
6196 -- Step 2) fetch from balance for this assignment_action and element entry
6197 l_balance_value :=
6198 hr_gbbal.calc_element_ptd_bal(p_assignment_action_id => l_asg_act_id
6199 ,p_balance_type_id => p_balance_type_id
6200 ,p_source_id => p_element_entry_id);
6201
6202
6203 IF l_balance_value IS NOT NULL
6204 THEN
6205
6206 debug('l_balance_value found....',20);
6207 debug('l_balance_value : '||l_balance_value,21);
6208 debug('l_asg_act_id : '||l_asg_act_id, 22);
6209 debug('l_source_asg_act_id : '||l_source_asg_act_id, 23);
6210 p_asg_act_id := l_asg_act_id;
6211 p_retro_asg_act_id := l_source_asg_act_id;
6212
6213 EXIT; -- if the run result was found in this assignment_action_id,
6214 -- then exit
6215 -- else go for next assignment_action_id
6216 END IF;
6217 debug('l_balance_value not found yet',25);
6218
6219 END LOOP;
6220 CLOSE csr_get_all_asg_act_id;
6221
6222 debug_exit(l_proc_name);
6223
6224 return l_balance_value;
6225
6226 EXCEPTION
6227 WHEN others THEN
6228 IF SQLCODE <> hr_utility.hr_error_number
6229 THEN
6230 debug_others (l_proc_name, 10);
6231 IF g_debug
6232 THEN
6233 DEBUG ( 'Leaving: '
6234 || l_proc_name, -999);
6235 END IF;
6236 fnd_message.raise_error;
6237 ELSE
6238 RAISE;
6239 END IF;
6240
6241 END get_value_from_balance;
6242
6243
6244
6245 -- ----------------------------------------------------------------------------
6246 -- |------------------------< calc_payment_from_balance >----------------------|
6247 -- ----------------------------------------------------------------------------
6248 -- to return the run result value for the assignment
6249
6250 FUNCTION calc_payment_from_balance
6251 (p_assignment_id IN NUMBER
6252 ,p_element_entry_id IN NUMBER
6253 ,p_element_type_id IN NUMBER
6254 ,p_balance_type_id IN NUMBER
6255 ,p_date_earned IN DATE
6256 ) RETURN NUMBER
6257 IS
6258
6259 l_proc_name VARCHAR2(61):=
6260 g_proc_name||'calc_payment_from_balance';
6261
6262
6263 l_asg_act_id NUMBER := NULL;
6264 l_retro_asg_act_id NUMBER := NULL;
6265 l_number NUMBER := NULL;
6266
6267 l_balance_ele_value NUMBER := NULL;
6268 l_retro_balance_ele_value NUMBER := NULL;
6269 l_total_retro_bal_ele_value NUMBER := 0;
6270
6271
6272 l_run_results_dtls csr_run_rslt_indirect_ele%rowtype;
6273 l_retro_ele csr_retro_ele%rowtype;
6274
6275 -- For Bug 9150874
6276 l_retro_ele_check csr_retro_ele_check%rowtype;
6277
6278 -- cursor to find retro_element_type_id
6279 CURSOR csr_get_retro_ele_type_id
6280 IS
6281 select retro_summ_ele_id
6282 from pay_element_types_f
6283 where element_type_id = p_element_type_id
6284 and rownum=1;
6285
6286
6287 BEGIN
6288 debug_enter(l_proc_name);
6289
6290 debug('p_assignment_id :' || p_assignment_id);
6291 debug('p_element_entry_id :'||p_element_entry_id);
6292 debug('p_element_type_id :'||p_element_type_id);
6293 debug('p_date_earned :' || p_date_earned);
6294
6295 -- get the balance value for this element and its indirects
6296 l_balance_ele_value := get_value_from_balance
6297 (p_assignment_id => p_assignment_id
6298 ,p_element_entry_id => p_element_entry_id
6299 ,p_balance_type_id => p_balance_type_id
6300 ,p_date_earned => p_date_earned
6301 ,p_asg_act_id => l_asg_act_id -- OUT
6302 ,p_retro_asg_act_id => l_retro_asg_act_id -- OUT
6303 );
6304
6305
6306 --
6307 -- BLOCK for retro payments
6308 --
6309
6310 -- Step 1) get data from pay_run_results
6311 -- for this element_entry_id and assignment action
6312 -- Note : l_asg_act_id is the assignment_action which had returned
6313 -- the balance value in the call above
6314 IF l_asg_act_id IS NOT NULL
6315 and
6316 l_retro_asg_act_id IS NOT NULL
6317 THEN
6318
6319 -- get run_result details for this element entry and its indirect elements
6320 OPEN csr_run_rslt_indirect_ele
6321 (p_source_id => p_element_entry_id
6322 ,p_asg_act_id => l_asg_act_id
6323 );
6324 LOOP -- loop thru all the run_result_ids
6325 FETCH csr_run_rslt_indirect_ele INTO l_run_results_dtls;
6326 EXIT WHEN csr_run_rslt_indirect_ele%NOTFOUND;
6327
6328 debug('l_run_results_dtls.run_result_id : '||l_run_results_dtls.run_result_id, 30);
6329 debug('ELEMENT_TYPE_ID : '||l_run_results_dtls.run_result_id, 30);
6330 debug('ASSIGNMENT_ACTION_ID : '||l_run_results_dtls.assignment_action_id, 30);
6331 debug('ENTRY_TYPE : '||l_run_results_dtls.entry_type, 30);
6332 debug('SOURCE_ID : '||l_run_results_dtls.source_id, 30);
6333 debug('SOURCE_TYPE : '||l_run_results_dtls.source_type, 30);
6334 debug('STATUS : '||l_run_results_dtls.status, 30);
6335 debug('ELEMENT_ENTRY_ID : '||l_run_results_dtls.element_entry_id, 30);
6336
6337 debug('l_run_results_dtls.run_result_id : ' || l_run_results_dtls.run_result_id);
6338 debug('l_retro_asg_act_id : ' || l_retro_asg_act_id );
6339 debug('ben_ext_person.g_effective_date : ' || ben_ext_person.g_effective_date );
6340
6341 -- fetch retro elements using this main elements run_result_id
6342 -- For bug 8652303, Added paramater p_ele_enry_id
6343 OPEN csr_retro_ele
6344 (p_assignment_id => p_assignment_id
6345 ,p_source_id => l_run_results_dtls.run_result_id
6346 ,p_source_asg_action_id => l_retro_asg_act_id
6347 ,p_effective_date => ben_ext_person.g_effective_date -- p_date_earned
6348 ,p_ele_entry_id => l_run_results_dtls.element_entry_id
6349 );
6350 LOOP -- loop thru all the retro elements returned
6351 FETCH csr_retro_ele INTO l_retro_ele;
6352 EXIT WHEN csr_retro_ele%NOTFOUND;
6353
6354 debug('l_retro_ele.element_entry_id : '||l_retro_ele.element_entry_id, 40);
6355 debug('effective_start_date : '||l_retro_ele.effective_start_date, 40);
6356 debug('effective_end_date : '||l_retro_ele.effective_end_date, 40);
6357 debug('source_id : '||l_retro_ele.source_id, 40);
6358 debug('source_asg_action_id : '||l_retro_ele.source_asg_action_id, 40);
6359 debug('source_start_date : '||l_retro_ele.source_start_date, 40);
6360 debug('source_end_date : '||l_retro_ele.source_end_date, 40);
6361 debug('element_type_id : '||l_retro_ele.element_type_id, 40);
6362 debug('p_assignment_id : '||p_assignment_id, 40);
6363
6364 -- get the balance value for this element and its indirects
6365 l_retro_balance_ele_value := get_value_from_balance
6366 (p_assignment_id => p_assignment_id
6367 ,p_element_entry_id => l_retro_ele.element_entry_id
6368 ,p_balance_type_id => p_balance_type_id
6369 ,p_date_earned => l_retro_ele.effective_end_date
6370 ,p_asg_act_id => l_number -- OUT
6371 ,p_retro_asg_act_id => l_number -- OUT
6372 );
6373 IF l_retro_balance_ele_value IS NOT NULL
6374 THEN
6375 -- add all retro values of each element returned as retro elements.
6376 -- All retro elements pertaining to the main element's run_Result_id need
6377 -- to be summed up
6378 l_total_retro_bal_ele_value :=
6379 l_total_retro_bal_ele_value + l_retro_balance_ele_value;
6380 END IF;
6381
6382 debug('l_total_retro_bal_ele_value : '||l_total_retro_bal_ele_value, 40);
6383 END LOOP;
6384 CLOSE csr_retro_ele;
6385 --
6386 END LOOP;
6387 CLOSE csr_run_rslt_indirect_ele;
6388
6389 -- For bug 9150874 BEGIN. If the original Bonus element entry id didn't process in the payroll run
6390 -- Check if there was any retro entries and if yes proceed with accumulating the balance values
6391 ELSE
6392
6393 debug('Entered in ELSE PART IF l_asg_act_id IS NOT NULL');
6394 debug('p_element_entry_id : '||p_element_entry_id, 40);
6395
6396 OPEN csr_retro_ele_check(p_assignment_id => p_assignment_id
6397 ,p_effective_end_date => ben_ext_person.g_effective_date -- End date
6398 ,p_effective_start_date => p_date_earned -- p_date_earned
6399 ,p_ele_entry_id => p_element_entry_id
6400 );
6401
6402 LOOP -- loop thru all the retro elements returned
6403 FETCH csr_retro_ele_check INTO l_retro_ele_check;
6404 EXIT WHEN csr_retro_ele_check%NOTFOUND;
6405
6406 debug('l_retro_ele_check.element_entry_id : '||l_retro_ele_check.element_entry_id, 40);
6407 debug('l_retro_ele_check.effective_end_date : '||l_retro_ele_check.effective_end_date, 40);
6408 debug('source_id : '||l_retro_ele.source_id, 40);
6409 debug('source_asg_action_id : '||l_retro_ele.source_asg_action_id, 40);
6410
6411 -- get the balance value for this element and its indirects
6412 l_retro_balance_ele_value := get_value_from_balance
6413 (p_assignment_id => p_assignment_id
6414 ,p_element_entry_id => l_retro_ele_check.element_entry_id
6415 ,p_balance_type_id => p_balance_type_id
6416 ,p_date_earned => l_retro_ele_check.effective_end_date
6417 ,p_asg_act_id => l_number -- OUT
6418 ,p_retro_asg_act_id => l_number -- OUT
6419 );
6420 IF l_retro_balance_ele_value IS NOT NULL
6421 THEN
6422 -- add all retro values of each element returned as retro elements.
6423 -- All retro elements pertaining to the main element's run_Result_id need
6424 -- to be summed up
6425 l_total_retro_bal_ele_value :=
6426 l_total_retro_bal_ele_value + l_retro_balance_ele_value;
6427 END IF;
6428
6429 debug('l_total_retro_bal_ele_value : '||l_total_retro_bal_ele_value, 40);
6430 END LOOP;
6431 CLOSE csr_retro_ele_check;
6432 -- For bug 9150874 END.
6433
6434 END IF; -- l_asg_act_id IS NOT NULL
6435
6436 debug('l_balance_ele_value : ' || l_balance_ele_value,50);
6437 debug('l_total_retro_bal_ele_value : ' || l_total_retro_bal_ele_value,60);
6438
6439 -- add the element balance value and the retro value
6440 IF l_balance_ele_value IS NOT NULL
6441 OR
6442 l_total_retro_bal_ele_value IS NOT NULL
6443 THEN
6444 l_balance_ele_value := nvl(l_balance_ele_value,0) + nvl(l_total_retro_bal_ele_value,0);
6445 END IF;
6446
6447
6448 debug('l_balance_ele_value : ' || l_balance_ele_value,70);
6449
6450 debug_exit(l_proc_name);
6451
6452 return l_balance_ele_value;
6453
6454 EXCEPTION
6455 WHEN others THEN
6456 IF SQLCODE <> hr_utility.hr_error_number
6457 THEN
6458 debug_others (l_proc_name, 10);
6459 IF g_debug
6460 THEN
6461 DEBUG ( 'Leaving: '
6462 || l_proc_name, -999);
6463 END IF;
6464 fnd_message.raise_error;
6465 ELSE
6466 RAISE;
6467 END IF;
6468
6469 END calc_payment_from_balance;
6470
6471
6472
6473 -- ----------------------------------------------------------------------------
6474 -- |------------------------< get_element_payment_balance >--------------------|
6475 -- ----------------------------------------------------------------------------
6476
6477 FUNCTION get_element_payment_balance
6478 (p_assignment_id IN NUMBER
6479 ,p_element_entry_id IN NUMBER
6480 ,p_element_type_id IN NUMBER
6481 ,p_balance_type_id IN NUMBER
6482 ,p_effective_date IN DATE
6483 ) RETURN NUMBER
6484 IS
6485
6486
6487 l_proc_name VARCHAR2(61):=
6488 g_proc_name||'get_element_payment_balance';
6489
6490 l_date_earned DATE;
6491 l_payment NUMBER := NULL;
6492
6493 BEGIN
6494
6495 debug_enter(l_proc_name);
6496 debug('p_assignment_id :' || p_assignment_id) ;
6497 debug('p_effective_date :' ||to_char(p_effective_date,'DD/MM/YYYY')) ;
6498
6499 OPEN csr_get_next_payroll_date
6500 ( p_assignment_id => p_assignment_id
6501 ,p_effective_date => p_effective_date
6502 );
6503 FETCH csr_get_next_payroll_date INTO l_date_earned;
6504
6505 IF csr_get_next_payroll_date%FOUND THEN
6506
6507 debug('l_date_earned :' ||to_char(l_date_earned,'DD/MM/YYYY')) ;
6508 l_payment := calc_payment_from_balance
6509 ( p_assignment_id => p_assignment_id
6510 ,p_element_entry_id => p_element_entry_id
6511 ,p_element_type_id => p_element_type_id
6512 ,p_balance_type_id => p_balance_type_id
6513 ,p_date_earned => l_date_earned
6514 );
6515 debug('l_payment :' || l_payment);
6516
6517 ELSE
6518 debug('csr_get_next_payroll_date not found') ;
6519 --l_payment := 0;
6520 END IF;
6521
6522 CLOSE csr_get_next_payroll_date;
6523
6524 debug_exit(l_proc_name);
6525 return l_payment;
6526
6527 EXCEPTION
6528 WHEN others THEN
6529 IF SQLCODE <> hr_utility.hr_error_number
6530 THEN
6531 debug_others (l_proc_name, 10);
6532 IF g_debug
6533 THEN
6534 DEBUG ( 'Leaving: '
6535 || l_proc_name, -999);
6536 END IF;
6537 fnd_message.raise_error;
6538 ELSE
6539 RAISE;
6540 END IF;
6541
6542 END get_element_payment_balance;
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553 -- ----------------------------------------------------------------------------
6554 -- |--------------------< ele_entry_inp_val_cut_crit >----------------------|
6555 -- Description:
6556 -- ----------------------------------------------------------------------------
6557 FUNCTION ele_entry_inp_val_cut_crit
6558 (
6559 p_ext_pay_input_value IN VARCHAR2
6560 ,p_ext_pay_element_type IN VARCHAR2
6561 ,p_ext_pay_element_entry IN VARCHAR2
6562 ,p_output OUT NOCOPY VARCHAR2
6563 )RETURN VARCHAR2
6564 IS
6565
6566 l_proc_name VARCHAR2(61):=
6567 g_proc_name||'ele_entry_inp_val_cut_crit';
6568
6569 l_include varchar2(1) := 'Y';
6570 l_curr_evt_index NUMBER;
6571 l_input_value_id NUMBER;
6572 l_element_type_id NUMBER;
6573 l_return NUMBER;
6574 BEGIN
6575 debug_enter(l_proc_name);
6576
6577 debug('p_ext_pay_input_value :'|| p_ext_pay_input_value);
6578 debug('p_ext_pay_element_type :'|| p_ext_pay_element_type);
6579 debug('p_ext_pay_element_entry :'|| p_ext_pay_element_entry);
6580
6581
6582 check_if_element_qualifies
6583 (p_element_entry_id => p_ext_pay_element_entry -- IN NUMBER
6584 ,p_element_type_id => l_element_type_id -- OUT NOCOPY NUMBER
6585 ,p_include => p_output -- OUT NOCOPY VARCHAR2 -- Y/N
6586 ,p_extract_type => 'CUTOVER' -- IN VARCHAR2 DEFAULT 'PERIODIC'
6587 ,p_element_type_id_from_crit => p_ext_pay_element_type -- IN NUMBER DEFAULT NULL
6588 );
6589
6590 IF p_output = 'Y' THEN
6591 IF g_elements_of_info_type(g_curr_element_type_id).eei_information4 <> 'Y' THEN
6592 debug('ERROR: Not a Pensionable Allowance, will not be processed.');
6593 l_return := PQP_GB_PSI_FUNCTIONS.raise_extract_error
6594 (p_error_number => 94528
6595 ,p_error_text => 'BEN_94528_NOT_PEN_ALLOWANCE'
6596 ,p_token1 =>
6597 g_elements_of_info_type(g_curr_element_type_id).element_name
6598 );
6599 debug('Returning N ..');
6600 p_output := 'N';
6601
6602 --ELSE
6603 -- debug('Is a Pensionable Allowance');
6604 -- check for dupliate bonus types
6605 -- chk_dup_bon_types();
6606 END IF;
6607 END IF;
6608
6609 debug_exit(l_proc_name);
6610 RETURN p_output;
6611
6612 EXCEPTION
6613 WHEN others THEN
6614 IF SQLCODE <> hr_utility.hr_error_number
6615 THEN
6616 debug_others (l_proc_name, 10);
6617 IF g_debug
6618 THEN
6619 DEBUG ( 'Leaving: '
6620 || l_proc_name, -999);
6621 END IF;
6622 fnd_message.raise_error;
6623 ELSE
6624 RAISE;
6625 END IF;
6626
6627 END ele_entry_inp_val_cut_crit;
6628
6629
6630
6631 -- ----------------------------------------------------------------------------
6632 -- |--------------------< ele_entry_inp_val_per_crit >----------------------|
6633 -- Description:
6634 -- ----------------------------------------------------------------------------
6635 FUNCTION ele_entry_inp_val_per_crit
6636 (
6637 p_ext_pay_input_value IN VARCHAR2
6638 ,p_ext_pay_element_type IN VARCHAR2
6639 ,p_ext_pay_element_entry IN VARCHAR2
6640 ,p_output OUT NOCOPY VARCHAR2
6641 )RETURN VARCHAR2
6642 IS
6643
6644 l_proc_name VARCHAR2(61):=
6645 g_proc_name||'ele_entry_inp_val_per_crit';
6646
6647
6648 CURSOR csr_get_element_entry_id
6649 (p_element_entry_value_id IN NUMBER
6650 )
6651 IS
6652 SELECT element_entry_id
6653 FROM PAY_ELEMENT_ENTRY_VALUES_F
6654 WHERE element_entry_value_id =p_element_entry_value_id
6655 AND ROWNUM=1;
6656
6657
6658 l_include varchar2(1) := 'Y';
6659 l_curr_evt_index NUMBER;
6660 l_input_value_id NUMBER;
6661 l_element_type_id NUMBER;
6662 l_element_entry_id NUMBER;
6663 l_index NUMBER;
6664 l_return NUMBER;
6665
6666 l_chg_table_id NUMBER;
6667 l_chg_column_name VARCHAR2(30);
6668 l_chg_table VARCHAR2(30);
6669 l_chg_type VARCHAR2(10);
6670 l_chg_date DATE;
6671 l_chg_surrogate_key NUMBER;
6672 l_update_type VARCHAR2(5);
6673
6674 l_chg_of_element_yn VARCHAR2(1);
6675 l_report_all VARCHAR2(1);
6676 l_is_terminated VARCHAR2(1) := 'N';
6677 l_is_spread_bonus_yn VARCHAR2(1) := NULL;
6678 l_claim_date VARCHAR2(60);
6679
6680 BEGIN
6681 debug_enter(l_proc_name);
6682
6683 debug('p_ext_pay_input_value :'|| p_ext_pay_input_value);
6684 debug('p_ext_pay_element_type :'|| p_ext_pay_element_type);
6685 debug('p_ext_pay_element_entry :'|| p_ext_pay_element_entry);
6686
6687 /*
6688 PQP_GB_PSI_ASSIGNMENT_STATUS - yes
6689 PQP_GB_PSI_FTE_VALUE - no
6690 PQP_GB_PSI_NEW_HIRE - will go into today_sal_start
6691 PQP_GB_PSI_SAL_CONTRACT - no
6692 PQP_GB_PSI_ALL_ELEMENT_ENTRIES
6693 -- PQP_GB_PSI_SAL_GRADE
6694 PQP_GB_PSI_EMP_TERMINATIONS - yes
6695 */
6696 l_index := ben_ext_person.g_chg_pay_evt_index;
6697
6698 debug('l_index :'|| l_index,20);
6699
6700 l_chg_type := g_pay_proc_evt_tab(l_index).update_type;
6701 debug('l_chg_type : ' || l_chg_type);
6702 l_chg_table_id := g_pay_proc_evt_tab(l_index).dated_table_id;
6703 debug('l_chg_table_id :' || l_chg_table_id);
6704 l_chg_table := get_dated_table_name(l_chg_table_id);
6705 debug('l_chg_table : ' || l_chg_table);
6706 l_chg_date := g_pay_proc_evt_tab(l_index).effective_date;
6707 debug('l_chg_date : ' || l_chg_date);
6708 l_chg_column_name := g_pay_proc_evt_tab(l_index).column_name;
6709 debug('l_chg_column_name : ' || l_chg_column_name);
6710 l_chg_surrogate_key := ben_ext_person.g_chg_surrogate_key;
6711 debug('l_chg_surrogate_key : ' || l_chg_surrogate_key);
6712
6713
6714
6715
6716 IF l_chg_table <> 'PAY_ELEMENT_ENTRIES_F'
6717 AND l_chg_table <> 'PAY_ELEMENT_ENTRY_VALUES_F'
6718 -- OR (l_chg_table = 'PAY_ELEMENT_ENTRIES_F' AND l_chg_type = 'E')
6719 THEN
6720 l_chg_of_element_yn := 'N'; -- event not of element type
6721 ELSE
6722 l_chg_of_element_yn := 'Y';
6723 END IF;
6724
6725
6726
6727 IF is_today_sal_start() = 'Y' THEN -- salary start => report all elements
6728 --g_is_terminated := 'N'; -- change termination status to N
6729 l_is_terminated := 'N'; -- change termination status to N
6730 l_report_all := 'Y';
6731 ELSIF is_today_sal_end() = 'Y' THEN -- salary end => report all
6732 -- g_is_terminated := 'Y'; -- change termination status to 'Y'
6733 l_is_terminated := 'Y'; -- change termination status to 'Y'
6734 l_report_all := 'Y';
6735 ELSIF ( l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
6736 AND l_chg_column_name = 'ASSIGNMENT_STATUS_TYPE_ID') THEN
6737
6738 -- if the event is on assignment_status_type_id
6739 -- reject the event
6740 debug('Salary not Started or Ended Today');
6741 debug('l_chg_table: '||l_chg_table, 15);
6742 debug('l_chg_column_name: '||l_chg_column_name, 20);
6743 debug('Not a valid event, will not be processed',25);
6744 p_output := 'N';
6745 debug_exit(l_proc_name);
6746 RETURN p_output;
6747
6748 ELSIF l_chg_of_element_yn = 'N' THEN -- event not of element_entries/value type => report all
6749 l_is_terminated := NULL;
6750 l_report_all := 'Y';
6751 ELSE -- event of element type, report for that element
6752 l_is_terminated := NULL;
6753 l_report_all := 'N';
6754 END IF;
6755 --
6756 debug('l_is_terminated : ' || l_is_terminated,20);
6757 debug('l_report_all :' || l_report_all, 30);
6758
6759
6760 IF g_is_terminated = 'N'
6761 OR l_is_terminated = 'Y'
6762 OR (l_is_terminated = 'N' AND l_report_all = 'Y') -- Added as part of 115.58 (3)
6763
6764 THEN
6765 --
6766 /* IF is_today_sal_start() = 'Y' -- salary start => report all elements
6767 OR is_today_sal_end () = 'Y' -- salary end => report all
6768 OR l_chg_of_element_yn = 'N' -- event not of element_entries/value type => report all
6769 */
6770
6771 -- check for element end
6772 IF l_chg_table = 'PAY_ELEMENT_ENTRIES_F'
6773 AND l_chg_type = 'E' THEN
6774 debug(' element end event ',25);
6775 g_allowance_has_end_dated := 'Y';
6776 ELSE
6777 g_allowance_has_end_dated := 'N';
6778 END IF;
6779
6780
6781 IF l_report_all = 'Y'
6782 THEN
6783 check_if_element_qualifies
6784 (p_element_entry_id => p_ext_pay_element_entry -- IN NUMBER
6785 ,p_element_type_id => l_element_type_id -- OUT NOCOPY NUMBER
6786 ,p_include => p_output -- OUT NOCOPY VARCHAR2 -- Y/N
6787 ,p_extract_type => 'CUTOVER' -- IN VARCHAR2 DEFAULT 'PERIODIC'
6788 ,p_element_type_id_from_crit => p_ext_pay_element_type -- IN NUMBER DEFAULT NULL
6789 );
6790 ELSE
6791
6792 IF l_chg_table <> 'PAY_ELEMENT_ENTRIES_F'
6793 AND l_chg_type = 'I' THEN
6794
6795 debug('Not a valid event, will not be processed',30);
6796 p_output := 'N';
6797 debug_exit(l_proc_name);
6798 RETURN p_output;
6799 END IF;
6800
6801
6802 -- if correction, implies that it is on screen entry value
6803 -- on pay_element_entry_values_f and the surrogate key is
6804 -- not element_entry_id, but rather element_entry_value_id
6805 IF l_chg_type = 'C'
6806 THEN
6807 debug('correction event');
6808 OPEN csr_get_element_entry_id
6809 (p_element_entry_value_id => l_chg_surrogate_key
6810 );
6811 FETCH csr_get_element_entry_id into l_element_entry_id;
6812 IF csr_get_element_entry_id%NOTFOUND
6813 THEN
6814 debug('element entry id not found for this correction event',40);
6815 p_output := 'N';
6816 l_element_entry_id := NULL;
6817 END IF;
6818 CLOSE csr_get_element_entry_id;
6819 ELSE
6820 debug('not a correction event',50);
6821 l_element_entry_id := l_chg_surrogate_key;
6822 END IF;
6823
6824 IF l_element_entry_id IS NOT NULL
6825 AND p_ext_pay_element_entry = l_element_entry_id
6826 THEN
6827 check_if_element_qualifies
6828 (p_element_entry_id => p_ext_pay_element_entry -- IN NUMBER
6829 ,p_element_type_id => l_element_type_id -- OUT NOCOPY NUMBER
6830 ,p_include => p_output -- OUT NOCOPY VARCHAR2 -- Y/N
6831 ,p_extract_type => 'PERIODIC' -- IN VARCHAR2 DEFAULT 'PERIODIC'
6832 ,p_element_type_id_from_crit => p_ext_pay_element_type -- IN NUMBER DEFAULT NULL
6833 );
6834 END IF;
6835
6836 END IF;
6837
6838
6839 ELSIF g_elements_of_info_type.EXISTS(p_ext_pay_element_type) THEN -- this is in the terminated state
6840 -- but it exists in collection
6841 debug('this is in the terminated state, but it exists in collection',70);
6842 l_is_spread_bonus_yn -- get spread bonus flag
6843 := g_elements_of_info_type(p_ext_pay_element_type).eei_information6;
6844
6845 IF l_is_spread_bonus_yn IS NULL
6846 THEN
6847 l_is_spread_bonus_yn := 'N';
6848 END IF;
6849 debug('l_is_spread_bonus_yn :'|| l_is_spread_bonus_yn,80);
6850
6851 debug('now fetch the claim date for this element',75);
6852
6853 IF l_is_spread_bonus_yn = 'Y' THEN
6854 OPEN PQP_GB_PSI_ALLOWANCE_HISTORY.csr_get_entry_value
6855 (c_effective_date => g_effective_date
6856 ,c_element_entry_id => p_ext_pay_element_entry
6857 ,c_input_value => 'CLAIM DATE' -- DEFAULT 'PAY VALUE'
6858 );
6859 FETCH PQP_GB_PSI_ALLOWANCE_HISTORY.csr_get_entry_value INTO l_claim_date;
6860 IF PQP_GB_PSI_ALLOWANCE_HISTORY.csr_get_entry_value%NOTFOUND
6861 OR l_claim_date IS NULL
6862 THEN
6863 l_return := raise_extract_error
6864 (p_error_number => 94532
6865 ,p_error_text => 'BEN_94532_NO_ENTRY_VALUE'
6866 ,p_token1 =>
6867 g_elements_of_info_type(p_ext_pay_element_type).element_name
6868 || '(Spread Bonus)'
6869 ,p_token2 => 'CLAIM DATE'
6870 ,p_token3 => to_char(g_effective_date,'DD/MM/YYYY')
6871 );
6872
6873 p_output := 'N';
6874 ELSE
6875 IF is_proper_claim_date -- function to check valid claim date
6876 (p_claim_date => fnd_date.canonical_to_date(l_claim_date)
6877 ,p_element_name => g_elements_of_info_type(p_ext_pay_element_type).element_name
6878 ,p_element_entry_id => p_ext_pay_element_entry
6879 ,p_assg_start_date => PQP_GB_PSI_ALLOWANCE_HISTORY.g_assg_start_date
6880 )
6881 THEN
6882 g_curr_element_type_id := p_ext_pay_element_type;
6883 g_curr_element_entry_id := p_ext_pay_element_entry;
6884
6885 p_output := 'Y'; -- this element is spread_bonus and valid claim date
6886 debug('this element is spread_bonus and valid claim date',90);
6887 ELSE
6888 p_output := 'N'; -- either not a spread bonus, or claim date didnt qualify
6889 debug('either not a spread bonus, or claim date didnt qualify',110);
6890 END IF;
6891 END IF;
6892 CLOSE PQP_GB_PSI_ALLOWANCE_HISTORY.csr_get_entry_value;
6893
6894 END IF;
6895
6896 ELSE -- IF g_is_terminated = 'N' and not a spread bonus
6897 p_output := 'N'; -- reject as assignment is in ternminated state
6898 debug('p_output : '|| p_output, 120);
6899 END IF; -- IF g_is_terminated = 'N'
6900
6901
6902 -- check for pensionable flag
6903 debug('now checking for pensionable flag status ',130);
6904 IF p_output = 'Y' THEN
6905 IF g_elements_of_info_type(g_curr_element_type_id).eei_information4 <> 'Y' THEN
6906 debug('ERROR: Not a Pensionable Allowance, will not be processed.',60);
6907 l_return := raise_extract_error
6908 (p_error_number => 94528
6909 ,p_error_text => 'BEN_94528_NOT_PEN_ALLOWANCE'
6910 ,p_token1 =>
6911 g_elements_of_info_type(g_curr_element_type_id).element_name
6912 );
6913 debug('Returning N ..');
6914 p_output := 'N';
6915
6916 END IF;
6917 END IF;
6918
6919
6920
6921 IF l_is_terminated IS NOT NULL
6922 THEN
6923 g_is_terminated := l_is_terminated;
6924 END IF;
6925
6926
6927 debug_exit(l_proc_name);
6928 RETURN p_output;
6929
6930 EXCEPTION
6931 WHEN others THEN
6932 IF SQLCODE <> hr_utility.hr_error_number
6933 THEN
6934 debug_others (l_proc_name, 10);
6935 IF g_debug
6936 THEN
6937 DEBUG ( 'Leaving: '
6938 || l_proc_name, -999);
6939 END IF;
6940 fnd_message.raise_error;
6941 ELSE
6942 RAISE;
6943 END IF;
6944
6945 END ele_entry_inp_val_per_crit;
6946
6947
6948 -- ----------------------------------------------------------------------------
6949 -- |--------------------------< is_today_sal_end >-----------------------------|
6950 -- Description: This Procedure is to check if salary is ending on the current
6951 -- processing date.
6952 -- Salary is considered to be terminatied if assignment status
6953 -- is changed to one with 'No Payroll process'
6954 -- ----------------------------------------------------------------------------
6955 FUNCTION is_today_sal_end RETURN VARCHAR2
6956 IS
6957 l_proc varchar2(72) := g_proc_name||'.is_today_sal_end';
6958 l_chg_column_name VARCHAR2(30);
6959 l_chg_table VARCHAR2(30);
6960 l_chg_table_id NUMBER;
6961 l_assignment_status_type_id NUMBER;
6962 l_chg_date DATE;
6963 l_update_type VARCHAR2(10);
6964 l_salary_ended VARCHAR2(1);
6965 l_index NUMBER;
6966 l_elements_exist VARCHAR2(1);
6967 l_assignment_status VARCHAR2(20);
6968 l_per_assg_status VARCHAR2(80);
6969 l_leaver_date DATE;
6970 BEGIN
6971 debug_enter(l_proc);
6972 debug('g_effective_date: '||g_effective_date);
6973 debug('g_salary_end_date: '||g_salary_end_date);
6974
6975 IF g_salary_end_date = (g_effective_date - 1) THEN
6976 -- current date has been process by another event
6977 -- and today is set as end date previously.
6978 g_salary_ended_today := 'Y';
6979
6980 debug('Returning Y'||10);
6981 debug_exit(l_proc);
6982 RETURN 'Y';
6983 END IF;
6984
6985 l_index := ben_ext_person.g_chg_pay_evt_index;
6986 LOOP
6987 l_chg_column_name := g_pay_proc_evt_tab(l_index).column_name;
6988 l_chg_table_id := g_pay_proc_evt_tab(l_index).dated_table_id;
6989 l_chg_date := g_pay_proc_evt_tab(l_index).effective_date;
6990 l_update_type := g_pay_proc_evt_tab(l_index).update_type;
6991
6992 l_chg_table := get_dated_table_name(l_chg_table_id);
6993
6994 IF g_effective_date < l_chg_date THEN
6995 debug('finished processing all the events on g_effective_date');
6996 EXIT;
6997 END IF;
6998
6999 -- check for changes on assignment status
7000 IF l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7001 AND (l_chg_column_name = 'ASSIGNMENT_STATUS_TYPE_ID'
7002 OR l_update_type = 'E') THEN
7003
7004 IF PQP_GB_PSI_FUNCTIONS.chk_is_employee_a_leaver
7005 (
7006 p_assignment_id => g_assignment_id
7007 ,p_effective_date => l_chg_date
7008 ,p_leaver_date => l_leaver_date
7009 ) = 'Y' THEN
7010
7011 -- set today as salary end date.
7012 debug('l_leaver_date: '||l_leaver_date,20);
7013 g_salary_end_date := l_leaver_date;
7014 g_salary_ended_today := 'Y';
7015
7016 debug('Returning Y');
7017 debug_exit(l_proc);
7018 RETURN 'Y';
7019
7020 END IF;
7021
7022 l_assignment_status_type_id := g_pay_proc_evt_tab(l_index).new_value;
7023 OPEN csr_assignment_status(l_assignment_status_type_id);
7024 FETCH csr_assignment_status INTO l_assignment_status,l_per_assg_status;
7025 CLOSE csr_assignment_status;
7026 IF l_assignment_status <> 'PROCESS' THEN
7027
7028 debug('Returning Y as assignemnt status is changed to: '||l_assignment_status);
7029 -- set today as salary end date.
7030 g_salary_end_date := g_effective_date-1;
7031 g_salary_ended_today := 'Y';
7032
7033 debug('Returning Y');
7034 debug_exit(l_proc);
7035 RETURN 'Y';
7036
7037 END IF; --IF l_assignment_status <> 'PROCESS'
7038
7039 END IF;--IF (l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7040
7041 -- looping condition
7042 IF l_index = g_pay_proc_evt_tab.LAST THEN
7043 EXIT;
7044 ELSE
7045 l_index := g_pay_proc_evt_tab.NEXT(l_index);
7046 END IF; --IF l_index = g_pay_proc_evt_tab.LAST
7047
7048 END LOOP; -- LOOP
7049
7050 g_salary_ended_today := 'N';
7051 debug('Returning N');
7052 debug_exit(l_proc);
7053 return 'N';
7054 END is_today_sal_end;
7055 ---
7056 -- ----------------------------------------------------------------------------
7057 -- |--------------------------< is_curr_sal_end >-----------------------------|
7058 -- Description: This Procedure is to check if salary is ending on the current
7059 -- processing event.
7060 -- ----------------------------------------------------------------------------
7061 FUNCTION is_curr_sal_end RETURN VARCHAR2
7062 IS
7063 l_proc varchar2(72) := g_proc_name||'.is_curr_sal_end';
7064 l_chg_column_name VARCHAR2(30);
7065 l_chg_table VARCHAR2(30);
7066 l_assignment_status_type_id NUMBER;
7067 BEGIN
7068 debug_enter(l_proc);
7069 l_chg_column_name := ben_ext_person.g_chg_pay_column;
7070 l_chg_table := ben_ext_person.g_chg_pay_table;
7071
7072 -- check for changes on assignment status
7073 IF (l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7074 AND l_chg_column_name = 'ASSIGNMENT_STATUS_TYPE_ID') THEN
7075
7076 debug('Returning Y for the event on assignment_status_type_id');
7077 debug_exit(l_proc);
7078 RETURN 'Y';
7079
7080 END IF; --IF (l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7081
7082 debug('Returning N');
7083 debug_exit(l_proc);
7084 return 'N';
7085 END is_curr_sal_end;
7086 ---
7087 -- ----------------------------------------------------------------------------
7088 -- |--------------------------< is_today_sal_start >--------------------------|
7089 -- ----------------------------------------------------------------------------
7090 FUNCTION is_today_sal_start RETURN VARCHAR2
7091 IS
7092 l_proc varchar2(72) := g_proc_name||'.is_today_sal_start';
7093 l_chg_column_name VARCHAR2(30);
7094 l_chg_table VARCHAR2(30);
7095 l_chg_table_id NUMBER;
7096 l_assignment_status_type_id NUMBER;
7097 l_salary_ended VARCHAR2(1);
7098 l_elements_exist VARCHAR2(1);
7099 l_index NUMBER;
7100 l_assignment_status VARCHAR2(20);
7101 l_per_assg_status VARCHAR2(80);
7102 l_update_type VARCHAR2(10);
7103
7104 BEGIN
7105 debug_enter(l_proc);
7106
7107 l_index := ben_ext_person.g_chg_pay_evt_index;
7108 LOOP
7109 l_chg_column_name := g_pay_proc_evt_tab(l_index).column_name;
7110 l_chg_table_id := g_pay_proc_evt_tab(l_index).dated_table_id;
7111 l_chg_table := get_dated_table_name(l_chg_table_id);
7112 l_update_type := g_pay_proc_evt_tab(l_index).update_type;
7113
7114 debug('g_effective_date :' || g_effective_date, 009);
7115
7116 IF g_effective_date < g_pay_proc_evt_tab(l_index).effective_date THEN
7117 debug('finished processing all the events on g_effective_date',30);
7118 EXIT;
7119 END IF; --IF g_effective_date
7120
7121 -- check for changes on assignment status
7122 IF l_chg_table = 'PER_ALL_ASSIGNMENTS_F' THEN
7123
7124 IF l_chg_column_name = 'ASSIGNMENT_STATUS_TYPE_ID' THEN
7125
7126 l_assignment_status_type_id := g_pay_proc_evt_tab(l_index).new_value;
7127 debug('l_assignment_status_type_id: '||l_assignment_status_type_id,40);
7128 OPEN csr_assignment_status(l_assignment_status_type_id);
7129 FETCH csr_assignment_status INTO l_assignment_status,l_per_assg_status;
7130 CLOSE csr_assignment_status;
7131 debug('l_assignment_status: '||l_assignment_status);
7132 debug('l_per_assg_status: '||l_per_assg_status);
7133 IF l_assignment_status = 'PROCESS'
7134 AND l_per_assg_status NOT IN ('TERM_ASSIGN','SUSP_ASSIGN','END') THEN
7135
7136 debug('Returning Y as assignemnt status is : '||l_assignment_status,50);
7137 g_salary_ended_today := 'N';
7138 debug_exit(l_proc);
7139 RETURN 'Y';
7140
7141 ELSE
7142 debug('Returning N as assignemnt status is : '||l_assignment_status,50);
7143 debug_exit(l_proc);
7144 RETURN 'N';
7145
7146 END IF; -- IF l_assignment_status <> 'PROCESS'
7147 ELSIF l_update_type = 'I' THEN
7148 debug('Returning Y , Insert event on assignments ',40);
7149 g_salary_ended_today := 'N';
7150 debug_exit(l_proc);
7151 RETURN 'Y';
7152 END IF;
7153
7154 END IF; --IF (l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7155
7156
7157 -- looping condition
7158 IF l_index = g_pay_proc_evt_tab.LAST THEN
7159 EXIT;
7160 ELSE
7161 l_index := g_pay_proc_evt_tab.NEXT(l_index);
7162 END IF;--IF l_index = g_pay_proc_evt_tab.LAST
7163
7164 END LOOP; -- LOOP
7165
7166 debug('Returning N');
7167 debug_exit(l_proc);
7168 return 'N';
7169 END is_today_sal_start;
7170 ---
7171 ---
7172 -- ----------------------------------------------------------------------------
7173 -- |--------------------------< is_today_sal_ele_end >-----------------------------|
7174 -- Description: This Procedure is to check if salary element ending on the current
7175 -- processing date.
7176 -- ----------------------------------------------------------------------------
7177 FUNCTION is_today_sal_ele_end RETURN VARCHAR2
7178 IS
7179 l_proc varchar2(72) := g_proc_name||'.is_today_sal_ele_end';
7180 l_sal_ele_end VARCHAR2(1) := 'N';
7181 l_index NUMBER;
7182 l_chg_table_id NUMBER;
7183 l_chg_column_name VARCHAR2(30);
7184 l_chg_table VARCHAR2(30);
7185 l_chg_type VARCHAR2(10);
7186 l_chg_date DATE;
7187 l_chg_surrogate_key NUMBER;
7188 l_is_fte_abv VARCHAR2(1);
7189
7190 --Bug 7611963: Added new variable
7191 l_ele_end_date DATE;
7192
7193 BEGIN
7194 debug_enter(l_proc);
7195 debug('g_effective_date: '||g_effective_date);
7196 debug('g_salary_ele_end_date: '||g_salary_ele_end_date);
7197 debug('g_non_salary_ele_end_date: '||g_non_salary_ele_end_date);
7198
7199 IF g_salary_ele_end_date = g_effective_date THEN
7200 -- if current event date is already processed
7201 debug('g_sal_chg_event_exists: '||g_sal_chg_event_exists);
7202 debug('Returning: Y');
7203 debug_exit(l_proc);
7204 return 'Y';
7205 END IF;
7206
7207 IF g_non_salary_ele_end_date = g_effective_date THEN
7208 -- if current event date is already processed
7209 debug('g_sal_chg_event_exists: '||g_sal_chg_event_exists);
7210 debug('Returning: N');
7211 debug_exit(l_proc);
7212 return 'N';
7213 END IF;
7214
7215 -- reset g_sal_chg_event_exists
7216 g_sal_chg_event_exists := 'N';
7217
7218 l_index := ben_ext_person.g_chg_pay_evt_index;
7219 LOOP
7220 l_chg_type := g_pay_proc_evt_tab(l_index).update_type;
7221 l_chg_table_id := g_pay_proc_evt_tab(l_index).dated_table_id;
7222 l_chg_table := get_dated_table_name(l_chg_table_id);
7223 l_chg_date := g_pay_proc_evt_tab(l_index).effective_date;
7224 l_chg_column_name := g_pay_proc_evt_tab(l_index).column_name;
7225
7226 debug('l_chg_date: '||l_chg_date);
7227 debug('l_chg_table: '||l_chg_table);
7228 debug('l_chg_column_name: '||l_chg_column_name);
7229 debug('l_chg_type: '||l_chg_type);
7230
7231 IF g_effective_date < g_pay_proc_evt_tab(l_index).effective_date THEN
7232 debug('finished processing all the events on g_effective_date');
7233 EXIT;
7234 END IF; --IF g_effective_date
7235 debug('l_chg_table: '||l_chg_table||' l_chg_type: '||l_chg_type);
7236
7237 -- check for salary element end
7238 IF l_chg_table = 'PAY_ELEMENT_ENTRIES_F'
7239 AND l_chg_type = 'E'
7240 THEN
7241 --Bug 7611963: Check if ele end date is still valid
7242 OPEN csr_get_ele_end_date(g_pay_proc_evt_tab(l_index).surrogate_key);
7243 FETCH csr_get_ele_end_date INTO l_ele_end_date;
7244 CLOSE csr_get_ele_end_date;
7245
7246 debug('l_ele_end_date:'||l_ele_end_date);
7247 debug('g_effective_date:'||g_effective_date);
7248
7249 IF g_effective_date = l_ele_end_date
7250 THEN
7251 debug('Salary element end event ');
7252 g_salary_ele_end_date := g_effective_date;
7253 l_sal_ele_end := 'Y';
7254 END IF;
7255 --Bug 7611963: End
7256 END IF;
7257
7258 IF (l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7259 AND (l_chg_column_name IN ('GRADE_ID','NORMAL_HOURS') OR l_chg_type = 'I'))
7260 OR (l_chg_table = 'PQP_ASSIGNMENT_ATTRIBUTES_F'
7261 AND (l_chg_column_name = 'CONTRACT_TYPE' OR l_chg_type = 'I'))
7262 OR (l_chg_table = 'PAY_ELEMENT_ENTRIES_F'
7263 AND l_chg_type <> 'E')
7264 OR (l_chg_table = 'PAY_ELEMENT_ENTRY_VALUES_F') THEN
7265
7266 g_sal_chg_event_exists := 'Y';
7267
7268 END IF; --IF (l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7269
7270 IF (l_chg_table = 'PER_ASSIGNMENT_BUDGET_VALUES_F'
7271 AND (l_chg_column_name = 'VALUE' OR l_chg_type = 'I' )) THEN
7272
7273 l_chg_surrogate_key := g_pay_proc_evt_tab(l_index).surrogate_key;
7274 debug('l_chg_surrogate_key: '||l_chg_surrogate_key);
7275 OPEN csr_is_fte_abv
7276 (
7277 p_assignment_budget_value_id => l_chg_surrogate_key
7278 );
7279 FETCH csr_is_fte_abv INTO l_is_fte_abv;
7280 CLOSE csr_is_fte_abv;
7281 debug('l_is_fte_abv: '||l_is_fte_abv);
7282 IF NVL(l_is_fte_abv,' ') = 'Y' THEN
7283 debug('Change on FTE Value');
7284 g_sal_chg_event_exists := 'Y';
7285
7286 END IF;
7287
7288 END IF;
7289 -- looping condition
7290 IF l_index = g_pay_proc_evt_tab.LAST THEN
7291 EXIT;
7292 ELSE
7293 l_index := g_pay_proc_evt_tab.NEXT(l_index);
7294 END IF;
7295 END LOOP; -- LOOP
7296
7297 IF l_sal_ele_end = 'N' THEN
7298 -- current date does not have a sal ele end event
7299 g_non_salary_ele_end_date := g_effective_date;
7300 END IF;
7301
7302 debug('g_sal_chg_event_exists: '||g_sal_chg_event_exists);
7303 debug('Returning: '||l_sal_ele_end);
7304 debug_exit(l_proc);
7305 return l_sal_ele_end;
7306 END is_today_sal_ele_end;
7307 ---
7308 -- ----------------------------------------------------------------------------
7309 -- |------------------------< is_curr_sal_ele_end >---------------------------|
7310 -- Description: This procedure is to check whether the current event is a
7311 -- salary element end event.
7312 -- ----------------------------------------------------------------------------
7313 FUNCTION is_curr_sal_ele_end RETURN VARCHAR2
7314 IS
7315 l_proc varchar2(72) := g_proc_name||'.is_curr_sal_ele_end';
7316 l_chg_table VARCHAR2(30);
7317 l_chg_type VARCHAR2(10);
7318
7319 --Bug 7611963: Added variable
7320 l_ele_end_date DATE;
7321
7322 BEGIN
7323 debug_enter(l_proc);
7324 l_chg_type := ben_ext_person.g_chg_update_type;
7325 l_chg_table := ben_ext_person.g_chg_pay_table;
7326 debug('l_chg_table: '||l_chg_table||' l_chg_type: '||l_chg_type);
7327
7328 IF l_chg_table = 'PAY_ELEMENT_ENTRIES_F'
7329 AND l_chg_type = 'E'
7330 THEN
7331 --Bug 7611963: Chk is ele end date is still valid
7332 OPEN csr_get_ele_end_date(ben_ext_person.g_chg_surrogate_key);
7333 FETCH csr_get_ele_end_date INTO l_ele_end_date;
7334 CLOSE csr_get_ele_end_date;
7335
7336 debug('l_ele_end_date:'||l_ele_end_date);
7337 debug('g_effective_date:'||g_effective_date);
7338
7339 IF g_effective_date = l_ele_end_date
7340 THEN
7341 debug('Returning Y ');
7342 debug_exit(l_proc);
7343 RETURN 'Y';
7344 END IF;
7345 --Bug 7611963: End
7346 END IF; --IF l_chg_table = 'PAY_ELEMENT_ENTRIES_F'
7347
7348 debug('Returning N ');
7349 debug_exit(l_proc);
7350 RETURN 'N';
7351 END is_curr_sal_ele_end;
7352
7353 --Bug 7611963
7354 -- ----------------------------------------------------------------------------
7355 -- |--------------------------< get_next_valid_event_date >--------------------------|
7356 --This procedure is called from is_next_sal_end and ignores the events recorded
7357 --due to reverse termination.
7358 -- ----------------------------------------------------------------------------
7359 PROCEDURE get_next_valid_event_date
7360 (p_index IN OUT NOCOPY NUMBER
7361 ,p_next_chg_date IN OUT NOCOPY DATE
7362 )
7363 IS
7364 Cursor csr_get_abv_end_date(p_assignment_budget_value_id IN NUMBER)
7365 Is
7366 Select max(effective_end_date)
7367 From per_assignment_budget_values_f
7368 Where assignment_budget_value_id = p_assignment_budget_value_id;
7369
7370 l_chg_table_id NUMBER;
7371 l_update_type VARCHAR2(10);
7372 l_chg_column_name VARCHAR2(30);
7373 l_chg_table VARCHAR2(30);
7374
7375 l_rev_term_index NUMBER;
7376 l_chg_date_rev_term DATE;
7377 l_old_asg_status_typ_id NUMBER;
7378 l_old_assignment_status VARCHAR2(20);
7379 l_old_per_assg_status VARCHAR2(80);
7380 l_found_rev_term_event VARCHAR2(5) := 'N';
7381
7382 l_ele_end_date DATE;
7383 l_abv_end_date DATE;
7384 BEGIN
7385 debug('Entering: get_next_valid_event_date');
7386 debug('p_index: '||p_index);
7387 debug('p_next_chg_date: '||p_next_chg_date);
7388
7389 l_rev_term_index := p_index;
7390
7391 LOOP
7392 l_chg_table_id := g_pay_proc_evt_tab(l_rev_term_index).dated_table_id;
7393 l_update_type := g_pay_proc_evt_tab(l_rev_term_index).update_type;
7394 l_chg_column_name := g_pay_proc_evt_tab(l_rev_term_index).column_name;
7395
7396 l_chg_table := get_dated_table_name(l_chg_table_id);
7397 l_chg_date_rev_term := g_pay_proc_evt_tab(l_rev_term_index).effective_date;
7398
7399 debug('l_chg_table:'||l_chg_table);
7400 debug('l_chg_column_name:'||l_chg_column_name);
7401 debug('l_update_type:'||l_update_type);
7402 debug('l_chg_date_rev_term:'||l_chg_date_rev_term);
7403
7404 IF l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7405 AND l_chg_column_name = 'ASSIGNMENT_STATUS_TYPE_ID'
7406 AND l_update_type = 'C'
7407 THEN
7408 debug('Found Reverse Term event');
7409 l_found_rev_term_event := 'Y';
7410 ELSIF l_chg_table = 'PAY_ELEMENT_ENTRIES_F'
7411 AND l_chg_column_name = 'EFFECTIVE_END_DATE'
7412 AND l_update_type = 'E'
7413 THEN
7414 l_ele_end_date := NULL;
7415
7416 debug('g_pay_proc_evt_tab(l_rev_term_index).surrogate_key:'||g_pay_proc_evt_tab(l_rev_term_index).surrogate_key);
7417
7418 OPEN csr_get_ele_end_date(g_pay_proc_evt_tab(l_rev_term_index).surrogate_key);
7419 FETCH csr_get_ele_end_date INTO l_ele_end_date;
7420 CLOSE csr_get_ele_end_date;
7421
7422 debug('l_ele_end_date:'||l_ele_end_date);
7423
7424 IF l_chg_date_rev_term <> l_ele_end_date
7425 THEN
7426 debug('Found Reverse Term event');
7427 l_found_rev_term_event := 'Y';
7428 END IF;
7429 ELSIF l_chg_table = 'PER_ASSIGNMENT_BUDGET_VALUES_F'
7430 AND l_chg_column_name = 'EFFECTIVE_END_DATE'
7431 AND l_update_type = 'C'
7432 THEN
7433 l_abv_end_date := NULL;
7434
7435 debug('g_pay_proc_evt_tab(l_rev_term_index).surrogate_key:'||g_pay_proc_evt_tab(l_rev_term_index).surrogate_key);
7436
7437 OPEN csr_get_abv_end_date(g_pay_proc_evt_tab(l_rev_term_index).surrogate_key);
7438 FETCH csr_get_abv_end_date INTO l_abv_end_date;
7439 CLOSE csr_get_abv_end_date;
7440
7441 debug('l_abv_end_date:'||l_abv_end_date);
7442
7443 IF l_chg_date_rev_term <> l_abv_end_date
7444 THEN
7445 debug('Found Reverse Term event');
7446 l_found_rev_term_event := 'Y';
7447 END IF;
7448 ELSE
7449 debug('Event other than Reverse Term found');
7450 p_index := l_rev_term_index;
7451 p_next_chg_date := l_chg_date_rev_term;
7452 EXIT;
7453 END IF;
7454
7455 IF l_rev_term_index = g_pay_proc_evt_tab.LAST
7456 THEN
7457 p_index := p_index;
7458 p_next_chg_date := p_next_chg_date;
7459 EXIT;
7460 ELSE
7461 l_rev_term_index := g_pay_proc_evt_tab.NEXT(l_rev_term_index);
7462 END IF;
7463 END LOOP;
7464
7465 debug('p_index: '||p_index);
7466 debug('p_next_chg_date: '||p_next_chg_date);
7467 debug('Leaving: get_next_valid_event_date');
7468 END get_next_valid_event_date;
7469
7470 ---
7471 ---
7472 -- ----------------------------------------------------------------------------
7473 -- |--------------------------< is_next_sal_end >--------------------------|
7474 -- ----------------------------------------------------------------------------
7475 FUNCTION is_next_sal_end
7476 (
7477 p_end_date OUT NOCOPY DATE
7478 )RETURN VARCHAR2
7479 IS
7480 l_proc varchar2(72) := g_proc_name||'.is_next_sal_end';
7481 l_next_event_date DATE;
7482 l_assignment_status_type_id NUMBER;
7483 l_index NUMBER;
7484 l_chg_column_name VARCHAR2(30);
7485 l_chg_table VARCHAR2(30);
7486 l_chg_table_id NUMBER;
7487 l_chg_date DATE;
7488 l_leaver_date DATE;
7489 l_update_type VARCHAR2(10);
7490 l_sal_ele_end_evt_exist VARCHAR2(1) := 'Y';
7491 l_other_event_exist VARCHAR2(1) := 'N';
7492 l_is_fte_abv VARCHAR2(1);
7493 l_chg_surrogate_key NUMBER;
7494 l_assignment_status VARCHAR2(20);
7495 l_per_assg_status VARCHAR2(80);
7496 l_return VARCHAR2(1) := 'N';
7497 --Bug 7611963: Added variable
7498 l_ele_end_date DATE;
7499
7500 BEGIN
7501 debug_enter(l_proc);
7502 p_end_date := NULL;
7503 -- loop till the next event date
7504 l_index := ben_ext_person.g_chg_pay_evt_index;
7505 LOOP
7506 l_update_type := g_pay_proc_evt_tab(l_index).update_type;
7507 l_chg_table_id := g_pay_proc_evt_tab(l_index).dated_table_id;
7508 l_chg_table := get_dated_table_name(l_chg_table_id);
7509 l_chg_date := g_pay_proc_evt_tab(l_index).effective_date;
7510
7511 IF g_effective_date < l_chg_date THEN
7512 debug('finished processing all the events on g_effective_date');
7513 EXIT;
7514 END IF; --IF g_effective_date
7515 debug('l_chg_date: '||l_chg_date);
7516
7517 -- looping condition
7518 IF l_index = g_pay_proc_evt_tab.LAST THEN
7519 EXIT;
7520 ELSE
7521 l_index := g_pay_proc_evt_tab.NEXT(l_index);
7522 END IF;
7523 END LOOP;
7524
7525 -- loop for next event date
7526 IF l_chg_date > g_effective_date
7527 THEN
7528
7529 --Bug 7611963: Call procedure for ignoring Reverser Term events
7530 get_next_valid_event_date
7531 ( p_index => l_index
7532 ,p_next_chg_date => l_chg_date
7533 );
7534
7535 l_next_event_date := l_chg_date;
7536 debug('Looping through the events on next event date');
7537 LOOP
7538 l_chg_table_id := g_pay_proc_evt_tab(l_index).dated_table_id;
7539 l_update_type := g_pay_proc_evt_tab(l_index).update_type;
7540 l_chg_column_name := g_pay_proc_evt_tab(l_index).column_name;
7541
7542 l_chg_table := get_dated_table_name(l_chg_table_id);
7543 l_chg_date := g_pay_proc_evt_tab(l_index).effective_date;
7544
7545 -- looping condition
7546 IF l_next_event_date < l_chg_date THEN
7547 debug('finished processing all the events on g_effective_date');
7548 EXIT;
7549 END IF; --IF g_effective_date
7550
7551 debug('l_chg_table: '||l_chg_table||' l_chg_date: '||l_chg_date||
7552 ' l_update_type: '||l_update_type||' l_chg_column_name: '||l_chg_column_name);
7553
7554 IF l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7555 AND (l_chg_column_name = 'ASSIGNMENT_STATUS_TYPE_ID'
7556 OR l_update_type = 'E') THEN
7557
7558 IF PQP_GB_PSI_FUNCTIONS.chk_is_employee_a_leaver
7559 (
7560 p_assignment_id => g_assignment_id
7561 ,p_effective_date => l_chg_date
7562 ,p_leaver_date => l_leaver_date
7563 ) = 'Y' THEN
7564
7565 -- set today as salary end date.
7566 debug('l_leaver_date: '||l_leaver_date,20);
7567 g_salary_end_date := l_leaver_date;
7568 p_end_date := l_leaver_date;
7569 debug('Returning Y');
7570 debug_exit(l_proc);
7571 RETURN 'Y';
7572
7573 END IF;
7574
7575 l_assignment_status_type_id := g_pay_proc_evt_tab(l_index).new_value;
7576 OPEN csr_assignment_status(l_assignment_status_type_id);
7577 FETCH csr_assignment_status INTO l_assignment_status,l_per_assg_status;
7578 CLOSE csr_assignment_status;
7579 IF l_assignment_status <> 'PROCESS' THEN
7580
7581 debug('Returning Y as assignemnt status is changed to: '||l_assignment_status);
7582 -- set today as salary end date.
7583 g_salary_end_date := l_chg_date-1;
7584 p_end_date := l_chg_date-1;
7585 debug('Returning Y');
7586 debug_exit(l_proc);
7587 RETURN 'Y';
7588
7589 END IF; --IF l_assignment_status <> 'PROCESS'
7590 ELSIF l_chg_table = 'PAY_ELEMENT_ENTRIES_F'
7591 AND l_update_type = 'E'
7592 THEN
7593 --Bug 7611963:Chk if ele end date is valid
7594 l_ele_end_date := NULL;
7595
7596 OPEN csr_get_ele_end_date(g_pay_proc_evt_tab(l_index).surrogate_key);
7597 FETCH csr_get_ele_end_date INTO l_ele_end_date;
7598 CLOSE csr_get_ele_end_date;
7599
7600 debug('l_ele_end_date:'||l_ele_end_date);
7601 debug('l_chg_date:'||l_chg_date);
7602
7603 IF l_chg_date = l_ele_end_date
7604 THEN
7605 -- if there is a element entry end.
7606 l_sal_ele_end_evt_exist := 'Y';
7607 ELSE
7608 l_sal_ele_end_evt_exist := 'N';
7609 END IF;
7610 --Bug 7611963: End
7611
7612 ELSIF (l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7613 AND (l_chg_column_name IN ('GRADE_ID','NORMAL_HOURS') OR l_update_type = 'I'))
7614 OR (l_chg_table = 'PQP_ASSIGNMENT_ATTRIBUTES_F'
7615 AND (l_chg_column_name = 'CONTRACT_TYPE' OR l_update_type = 'I'))
7616 OR (l_chg_table = 'PAY_ELEMENT_ENTRY_VALUES_F') THEN
7617
7618 l_other_event_exist := 'Y';
7619
7620 ELSIF (l_chg_table = 'PER_ASSIGNMENT_BUDGET_VALUES_F'
7621 AND (l_chg_column_name = 'VALUE' OR l_update_type = 'I' )) THEN
7622
7623 l_chg_surrogate_key := ben_ext_person.g_chg_surrogate_key;
7624 debug('l_chg_surrogate_key: '||l_chg_surrogate_key);
7625 OPEN csr_is_fte_abv
7626 (
7627 p_assignment_budget_value_id => l_chg_surrogate_key
7628 );
7629 FETCH csr_is_fte_abv INTO l_is_fte_abv;
7630 CLOSE csr_is_fte_abv;
7631
7632 IF l_is_fte_abv IS NOT NULL
7633 AND l_is_fte_abv = 'Y' THEN
7634
7635 l_other_event_exist := 'Y';
7636
7637 END IF;--IF l_is_fte_abv IS NOT NULL
7638
7639 END IF;--IF l_chg_table =
7640
7641 -- looping condition
7642 IF l_index = g_pay_proc_evt_tab.LAST THEN
7643 EXIT;
7644 ELSE
7645 l_index := g_pay_proc_evt_tab.NEXT(l_index);
7646 END IF;--IF l_index = g_pay_proc_evt_tab.LAST
7647
7648 END LOOP;
7649
7650 END IF;--IF l_chg_date > g_effective_date
7651
7652 IF l_sal_ele_end_evt_exist = 'Y'
7653 AND l_other_event_exist = 'N' THEN
7654 -- if on the next event date, there is a salary element end
7655 -- and there are no other salary change events, we have to check on the next event date + 1.
7656 -- if this next event date + 1 is a salary end event, this date should be reported as end date
7657 -- on the current event date.
7658 IF l_chg_date = (l_next_event_date + 1) THEN
7659 -- if the next event is on the very next day
7660 -- then check employee is a leaver on that date
7661 l_chg_table_id := g_pay_proc_evt_tab(l_index).dated_table_id;
7662 l_update_type := g_pay_proc_evt_tab(l_index).update_type;
7663 l_chg_column_name := g_pay_proc_evt_tab(l_index).column_name;
7664
7665 IF l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7666 AND (l_chg_column_name = 'ASSIGNMENT_STATUS_TYPE_ID'
7667 OR l_update_type = 'E') THEN
7668
7669 IF PQP_GB_PSI_FUNCTIONS.chk_is_employee_a_leaver
7670 (
7671 p_assignment_id => g_assignment_id
7672 ,p_effective_date => l_chg_date
7673 ,p_leaver_date => l_leaver_date
7674 ) = 'Y' THEN
7675
7676 -- set today as salary end date.
7677 debug('l_leaver_date: '||l_leaver_date,20);
7678 g_salary_end_date := l_leaver_date;
7679 p_end_date := l_leaver_date;
7680 debug('Returning Y');
7681 debug_exit(l_proc);
7682 RETURN 'Y';
7683
7684 END IF;
7685
7686 l_assignment_status_type_id := g_pay_proc_evt_tab(l_index).new_value;
7687 OPEN csr_assignment_status(l_assignment_status_type_id);
7688 FETCH csr_assignment_status INTO l_assignment_status,l_per_assg_status;
7689 CLOSE csr_assignment_status;
7690 IF l_assignment_status <> 'PROCESS' THEN
7691
7692 debug('Returning Y as assignemnt status is changed to: '||l_assignment_status);
7693 -- set today as salary end date.
7694 g_salary_end_date := l_chg_date-1;
7695 p_end_date := l_chg_date-1;
7696 debug('Returning Y');
7697 debug_exit(l_proc);
7698 RETURN 'Y';
7699
7700 END IF; --IF l_assignment_status <> 'PROCESS'
7701
7702 END IF; -- IF l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7703
7704 END IF; -- IF l_chg_date = (l_next_event_date + 1)
7705
7706 END IF; --IF l_sal_ele_end_evt_exist = 'Y'
7707
7708
7709 debug('p_end_date: '||p_end_date);
7710 debug_exit(l_proc);
7711 RETURN l_return;
7712 END is_next_sal_end;
7713 ---
7714 -- ----------------------------------------------------------------------------
7715 -- |--------------------------< is_curr_sal_change_event >--------------------------|
7716 -- ----------------------------------------------------------------------------
7717 FUNCTION is_curr_sal_change_event RETURN VARCHAR2
7718 IS
7719
7720 --For Bug 7013325: Added cursor to fetch mapped DFF segment
7721 CURSOR csr_get_configured_dff_segment(c_business_group_id NUMBER)
7722 IS
7723 SELECT trim(nvl(pcv_information3,'NULLCOLUMN'))
7724 FROM pqp_configuration_values
7725 WHERE pcv_information_category='PQP_GB_PENSERVER_ELIGBLTY_CONF'
7726 AND business_group_id = c_business_group_id;
7727
7728 --For Bug 9110093: Added cursor to fetch Uniform Grade Mapping
7729 CURSOR csr_get_uni_grade_config(c_business_group_id NUMBER)
7730 IS
7731 SELECT PCV_INFORMATION1, PCV_INFORMATION2, PCV_INFORMATION3, PCV_INFORMATION4
7732 FROM pqp_configuration_values
7733 WHERE pcv_information_category like 'PQP_GB_PENSERVER_UNIGRD_MAP'
7734 AND business_group_id = c_business_group_id;
7735
7736 TYPE get_uni_grd_oldval_ref_csr_typ IS REF CURSOR;
7737 c_get_uni_grd_old_val get_uni_grd_oldval_ref_csr_typ;
7738
7739 TYPE get_uni_grd_newval_ref_csr_typ IS REF CURSOR;
7740 c_get_uni_grd_new_val get_uni_grd_newval_ref_csr_typ;
7741
7742
7743 l_proc varchar2(72) := g_proc_name||'.is_curr_sal_change_event';
7744 l_next_event_date DATE;
7745 l_next_pay_event_rec ben_ext_person.t_detailed_output_tab_rec;
7746 l_chg_column_name VARCHAR2(30);
7747 l_chg_table VARCHAR2(30);
7748 l_chg_type VARCHAR2(10);
7749 l_chg_date DATE;
7750 l_chg_surrogate_key NUMBER;
7751 l_is_fte_abv VARCHAR2(1);
7752 --For Bug 7013325: Added Variable
7753 l_configured_dff_segment VARCHAR2(30);
7754
7755 --For Bug 9110093:Added Variables
7756 l_unigrade_source VARCHAR2(30);
7757 l_assignment_context VARCHAR2(30);
7758 l_assignment_column VARCHAR2(30);
7759 l_people_group_column VARCHAR2(30);
7760
7761 l_uni_grade_old_val_query VARCHAR2(1000);
7762 l_uni_grd_old_value VARCHAR2(50);
7763 l_uni_grade_new_val_query VARCHAR2(1000);
7764 l_uni_grd_new_value VARCHAR2(50);
7765
7766 l_change_value varchar2(80);
7767 l_old_value VARCHAR2(20);
7768 l_new_value VARCHAR2(20);
7769 l_arrow_pos NUMBER;
7770
7771 BEGIN
7772 debug_enter(l_proc);
7773
7774 l_chg_type := ben_ext_person.g_chg_update_type;
7775 l_chg_table := ben_ext_person.g_chg_pay_table;
7776 l_chg_date := ben_ext_person.g_chg_eff_dt;
7777 l_chg_column_name := ben_ext_person.g_chg_pay_column;
7778
7779 debug('l_chg_table: '||l_chg_table);
7780 debug('l_chg_date: '||l_chg_date);
7781 debug('l_chg_type: '||l_chg_type);
7782 debug('l_chg_column_name: '||l_chg_column_name);
7783
7784 --For Bug 7013325
7785 OPEN csr_get_configured_dff_segment(g_business_group_id);
7786 FETCH csr_get_configured_dff_segment INTO l_configured_dff_segment;
7787 CLOSE csr_get_configured_dff_segment;
7788
7789 IF(l_configured_dff_segment='NULLCOLUMN')
7790 THEN
7791 debug('Customer specific DFF Segment not mapped on configuration page');
7792 debug('Refer to bug 7013325 for setup details');
7793 ELSE
7794 debug('l_configured_dff_segment: '||l_configured_dff_segment);
7795 debug('g_business_group_id: '||g_business_group_id);
7796 END IF;
7797 --For Bug 7013325
7798
7799
7800 --For Bug 5998108: Added new column EMPLOYMENT_CATEGORY
7801 --For bug 7013325: Added new column l_configured_dff_segment
7802 IF (l_chg_table = 'PAY_ELEMENT_ENTRIES_F'
7803 AND l_chg_type <> 'E')
7804 OR (l_chg_table = 'PAY_ELEMENT_ENTRY_VALUES_F')
7805 OR (l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7806 AND (l_chg_column_name IN ('GRADE_ID','NORMAL_HOURS','EMPLOYMENT_CATEGORY',l_configured_dff_segment) OR l_chg_type = 'I'))
7807 OR (l_chg_table = 'PQP_ASSIGNMENT_ATTRIBUTES_F'
7808 AND (l_chg_column_name = 'CONTRACT_TYPE' OR l_chg_type = 'I'))THEN
7809
7810 debug('Returning Y');
7811 debug_exit(l_proc);
7812 RETURN 'Y';
7813
7814 END IF; --IF (l_chg_table = 'PER_ALL_ASSIGNMENTS_F'
7815
7816 IF (l_chg_table = 'PER_ASSIGNMENT_BUDGET_VALUES_F'
7817 AND (l_chg_column_name = 'VALUE' OR l_chg_type = 'I' )) THEN
7818
7819 l_chg_surrogate_key := ben_ext_person.g_chg_surrogate_key;
7820 debug('l_chg_surrogate_key: '||l_chg_surrogate_key);
7821 OPEN csr_is_fte_abv
7822 (
7823 p_assignment_budget_value_id => l_chg_surrogate_key
7824 );
7825 FETCH csr_is_fte_abv INTO l_is_fte_abv;
7826 CLOSE csr_is_fte_abv;
7827
7828 IF l_is_fte_abv IS NOT NULL
7829 AND l_is_fte_abv = 'Y' THEN
7830
7831 debug('Returning Y');
7832 debug_exit(l_proc);
7833 RETURN 'Y';
7834
7835 END IF;
7836
7837 END IF;
7838
7839 --For Bug 9110093:Logic for tracking Uniform grade change events
7840 OPEN csr_get_uni_grade_config(g_business_group_id);
7841 FETCH csr_get_uni_grade_config INTO l_unigrade_source, l_assignment_context,
7842 l_assignment_column, l_people_group_column ;
7843 CLOSE csr_get_uni_grade_config;
7844
7845 debug('l_unigrade_source: '||l_unigrade_source);
7846 debug('l_assignment_context: '||l_assignment_context);
7847 debug('l_assignment_column: '||l_assignment_column);
7848 debug('l_people_group_column: '||l_people_group_column);
7849
7850 IF l_unigrade_source = 'PEOPLE_GROUP' AND l_people_group_column IS NOT NULL
7851 THEN
7852 IF(l_chg_table= 'PER_ALL_ASSIGNMENTS_F'
7853 AND l_chg_column_name= 'PEOPLE_GROUP_ID')
7854 THEN
7855 --Compare the new and old value of uni grade segment
7856 l_change_value := ben_ext_person.g_pay_proc_evt_tab(ben_ext_person.g_chg_pay_evt_index).change_values;
7857 l_old_value := ben_ext_person.g_pay_proc_evt_tab(ben_ext_person.g_chg_pay_evt_index).old_value;
7858 l_new_value := ben_ext_person.g_pay_proc_evt_tab(ben_ext_person.g_chg_pay_evt_index).new_value;
7859
7860 debug('l_chg_type: '||l_chg_type);
7861 debug('l_change_value: '||l_change_value);
7862 debug('l_old_value: '||l_old_value);
7863 debug('l_new_value: '||l_new_value);
7864
7865 IF l_chg_type = 'C'
7866 THEN
7867 debug('For correction type pick the value by parsing change_values');
7868 l_arrow_pos := instr(l_change_value,'->');
7869 l_old_value := ltrim(rtrim(SUBSTR(l_change_value,1,l_arrow_pos-1)));
7870 l_new_value := ltrim(rtrim(SUBSTR(l_change_value,l_arrow_pos+2)));
7871
7872 debug('l_old_value: '||l_old_value);
7873 debug('l_new_value: '||l_new_value);
7874 END IF;
7875
7876 IF ((l_old_value IS NULL) OR l_old_value = '<null>' OR l_old_value = '<NULL>')
7877 THEN
7878 l_uni_grd_old_value := 'NULLValue';
7879 ELSE
7880 l_uni_grade_old_val_query := 'select '||l_people_group_column||' '||
7881 'from pay_people_groups'||' '||
7882 'where PEOPLE_GROUP_ID = '||l_old_value;
7883 debug('l_uni_grade_old_val_query: '||l_uni_grade_old_val_query);
7884
7885 OPEN c_get_uni_grd_old_val FOR l_uni_grade_old_val_query;
7886 FETCH c_get_uni_grd_old_val INTO l_uni_grd_old_value;
7887 CLOSE c_get_uni_grd_old_val;
7888
7889 IF l_uni_grd_old_value IS NULL
7890 THEN
7891 l_uni_grd_old_value := 'NULLValue';
7892 END IF;
7893 END IF;
7894
7895 IF ((l_new_value IS NULL) OR l_new_value = '<null>' OR l_new_value = '<NULL>')
7896 THEN
7897 l_uni_grd_new_value := 'NULLValue';
7898 ELSE
7899 l_uni_grade_new_val_query := 'select '||l_people_group_column||' '||
7900 'from pay_people_groups'||' '||
7901 'where PEOPLE_GROUP_ID = '||l_new_value;
7902 debug('l_uni_grade_new_val_query: '||l_uni_grade_new_val_query);
7903
7904 OPEN c_get_uni_grd_new_val FOR l_uni_grade_new_val_query;
7905 FETCH c_get_uni_grd_new_val INTO l_uni_grd_new_value;
7906 CLOSE c_get_uni_grd_new_val;
7907
7908 IF l_uni_grd_new_value IS NULL
7909 THEN
7910 l_uni_grd_new_value := 'NULLValue';
7911 END IF;
7912 END IF;
7913
7914 debug('l_uni_grd_old_value: '||l_uni_grd_old_value);
7915 debug('l_uni_grd_new_value: '||l_uni_grd_new_value);
7916
7917 IF l_uni_grd_old_value <> l_uni_grd_new_value
7918 THEN
7919 debug('Returning Y');
7920 debug_exit(l_proc);
7921 RETURN 'Y';
7922 END IF;
7923 END IF;
7924
7925 ELSIF l_unigrade_source = 'ASSIGNMENT' AND l_assignment_column IS NOT NULL
7926 THEN
7927 IF (l_chg_table= 'PER_ALL_ASSIGNMENTS_F' AND l_chg_column_name= trim(l_assignment_column))
7928 THEN
7929 debug('Returning Y');
7930 debug_exit(l_proc);
7931 RETURN 'Y';
7932 END IF;
7933 END IF;
7934
7935 debug('Returning N');
7936 debug_exit(l_proc);
7937 RETURN 'N';
7938 END is_curr_sal_change_event;
7939 ---
7940 -- ----------------------------------------------------------------------------
7941 -- |---------------------< get_start_end_date >------------------------|
7942 -- ----------------------------------------------------------------------------
7943 FUNCTION get_start_end_date
7944 (
7945 p_assignment_id NUMBER
7946 ,p_business_group_id NUMBER
7947 ,p_effective_date DATE
7948 ,p_start_date OUT NOCOPY DATE
7949 ,p_end_date OUT NOCOPY DATE
7950 )RETURN NUMBER
7951 IS
7952 l_proc varchar2(72) := g_proc_name||'.get_start_end_date';
7953 l_temp_date DATE;
7954 l_error NUMBER;
7955 l_return VARCHAR2(10);
7956 BEGIN --get_start_end_date
7957 debug_enter(l_proc);
7958
7959 IF g_effective_date <> p_effective_date THEN
7960 -- reset globals for every new date
7961 g_salary_ele_end_date := c_highest_date;
7962 g_non_salary_ele_end_date := c_highest_date;
7963 g_sal_chg_event_exists := 'N';
7964 END IF;
7965
7966 g_effective_date := p_effective_date;
7967
7968 IF g_salary_ended = 'Y' AND is_today_sal_start() = 'Y' THEN
7969 p_start_date := g_effective_date;
7970 l_return := is_next_sal_end
7971 (
7972 p_end_date => g_salary_end_date
7973 );
7974 IF g_salary_end_date IS NULL THEN
7975 g_salary_ended := 'N';
7976 g_salary_started := 'Y';
7977 END IF;
7978 p_end_date := g_salary_end_date;
7979 debug('p_start_date: '||p_start_date||' p_end_date: '||p_end_date);
7980 debug_exit(l_proc);
7981 RETURN 0;
7982 END IF;
7983
7984 -- Check if the current event is salary end event.
7985 IF is_today_sal_end() = 'Y' THEN
7986 /*IF is_curr_sal_end() = 'Y' THEN
7987 p_start_date := NULL;
7988 g_salary_end_date := NULL;
7989 debug('p_start_date: '||p_start_date||' g_salary_end_date: '||g_salary_end_date);
7990 ELSE
7991 p_start_date := g_effective_date;
7992 g_salary_end_date := g_effective_date;
7993 debug('p_start_date: '||p_start_date||' g_salary_end_date: '||g_salary_end_date);
7994 END IF;*/
7995 p_start_date := NULL;
7996 g_salary_end_date := NULL;
7997 g_salary_ended := 'Y';
7998 g_salary_started := 'N';
7999 p_end_date := g_salary_end_date;
8000 debug('p_start_date: '||p_start_date||' p_end_date: '||p_end_date);
8001 debug_exit(l_proc);
8002 RETURN 0;
8003 END IF;
8004
8005 IF g_salary_started = 'Y' THEN
8006
8007 IF is_today_sal_ele_end = 'Y' THEN
8008 IF is_curr_sal_ele_end = 'Y' THEN
8009 debug('g_sal_chg_event_exists: '||g_sal_chg_event_exists);
8010 IF g_sal_chg_event_exists = 'Y' THEN
8011 p_start_date := g_effective_date;
8012 g_salary_end_date := NULL;
8013
8014 ELSE
8015 p_start_date := g_effective_date+1;
8016 l_return := is_next_sal_end
8017 (
8018 p_end_date => g_salary_end_date
8019 );
8020 END IF;
8021
8022 ELSE
8023 p_start_date := g_effective_date+1;
8024 l_return := is_next_sal_end
8025 (
8026 p_end_date => g_salary_end_date
8027 );
8028
8029
8030 END IF; --IF is_curr_sal_ele_end() = 'Y'
8031 p_end_date := g_salary_end_date;
8032 debug('p_start_date: '||p_start_date||' p_end_date: '||p_end_date);
8033 debug_exit(l_proc);
8034 RETURN 0;
8035 END IF; -- IF is_today_sal_ele_end() = 'Y'
8036
8037 IF is_curr_sal_change_event() = 'Y' THEN
8038 p_start_date := g_effective_date;
8039 l_return := is_next_sal_end
8040 (
8041 p_end_date => g_salary_end_date
8042 );
8043 ELSE
8044 p_start_date := NULL;
8045 g_salary_end_date := NULL;
8046 END IF;--IF is_curr_sal_change_event() = 'Y'
8047 p_end_date := g_salary_end_date;
8048 debug('p_start_date: '||p_start_date||' p_end_date: '||p_end_date);
8049 debug_exit(l_proc);
8050 return 0;
8051
8052 ELSE -- IF g_salary_started = 'Y'
8053 p_start_date := NULL;
8054 g_salary_end_date := NULL;
8055 p_end_date := g_salary_end_date;
8056 debug('p_start_date: '||p_start_date||' p_end_date: '||p_end_date);
8057 debug_exit(l_proc);
8058 RETURN 0;
8059 END IF; -- IF g_salary_started = 'Y'
8060
8061 p_end_date := g_salary_end_date;
8062 debug('p_start_date: '||p_start_date||' p_end_date: '||p_end_date);
8063 debug_exit(l_proc);
8064 RETURN 0;
8065 END get_start_end_date;
8066 ---
8067 -- ----------------------------------------------------------------------------
8068 -- |-------------------------< get_contract_type >-----------------------------|
8069 -- ----------------------------------------------------------------------------
8070 FUNCTION get_contract_type
8071 (
8072 p_assignment_id NUMBER
8073 ,p_business_group_id NUMBER
8074 ,p_effective_date IN DATE
8075 ,p_contract_type OUT NOCOPY VARCHAR2
8076 ) RETURN NUMBER
8077 IS
8078 l_proc varchar2(72) := g_proc_name||'.get_contract_type';
8079 l_contract_type pqp_assignment_attributes_f.contract_type%type;
8080 l_work_pattern pqp_assignment_attributes_f.work_pattern%type;
8081 l_period_divisor VARCHAR2(10);
8082 l_error_msg VARCHAR2(100);
8083 l_err_no NUMBER;
8084 l_error NUMBER;
8085 BEGIN
8086 debug_enter(l_proc);
8087 /* Currently for all MOD employees the contract type will be 'M'*/
8088 p_contract_type := 'M';
8089
8090 /* The following code should be uncommented if contract type will
8091 not be a hard-coded value*/
8092
8093 /*IF g_penserver_contract_type IS NOT NULL
8094 AND g_contract_type_effective_date = p_effective_date THEN
8095 p_contract_type := g_penserver_contract_type;
8096 ELSE
8097 OPEN csr_get_contract_type
8098 (
8099 p_effective_date => p_effective_date
8100 );
8101 FETCH csr_get_contract_type INTO l_contract_type;
8102 CLOSE csr_get_contract_type;
8103
8104 IF l_contract_type IS NULL THEN
8105 -- Raise warning that the contract type is missing
8106 debug('WARNING: Contract type for the person is missing',20);
8107 l_error := PQP_GB_PSI_FUNCTIONS.raise_extract_warning
8108 (p_error_number => 94441
8109 ,p_error_text => 'BEN_94441_NO_CONTRACT_TYPE'
8110 ,p_token1 => to_char(g_effective_date,'dd-MON-yyyy')
8111 );
8112 ELSE
8113 debug('l_contract_type: '||l_contract_type,20);
8114 l_err_no := pqp_utilities.pqp_gb_get_table_value(
8115 p_business_group_id => p_business_group_id
8116 ,p_effective_date => p_effective_date
8117 ,p_table_name => 'PQP_CONTRACT_TYPES'
8118 ,p_column_name => 'PenServer Contract Type'
8119 ,p_row_name => l_contract_type
8120 ,p_value => p_contract_type
8121 ,p_error_msg => l_error_msg
8122 ,p_refresh_cache => 'N'
8123 );
8124 IF p_output IS NULL THEN
8125 -- raise warning that the PenServer Contract Type is missing in the UDT PQP_CONTRACT_TYPES for the contract
8126 debug('WARNING: PenServer Contract Type is missing in the'||
8127 'UDT PQP_CONTRACT_TYPES for the contract: '||l_contract_type,20);
8128 l_error := PQP_GB_PSI_FUNCTIONS.raise_extract_warning
8129 (p_error_number => 94442
8130 ,p_error_text => 'BEN_94442_NO_PEN_CONTRACT_TYPE'
8131 ,p_token1 => to_char(g_effective_date,'dd-MON-yyyy')
8132 );
8133 ELSE
8134 p_output := upper(p_output);
8135 g_contract_type := l_contract_type;
8136 g_penserver_contract_type := p_contract_type;
8137 g_contract_type_effective_date := p_effective_date;
8138 END IF; -- IF p_output IS NULL
8139 END IF; -- IF l_contract_type IS NULL
8140 END IF; -- IF g_penserver_contract_type IS NOT NULL*/
8141
8142 debug('PenServer Contract Type: '||p_contract_type);
8143 debug_exit(l_proc);
8144 return l_error;
8145 END get_contract_type;
8146 ---
8147 ----------------------------------------------------------------------------
8148 -- |------------------------< get_element_attribution >--------------------------|
8149 -- ----------------------------------------------------------------------------
8150 PROCEDURE get_element_attribution
8151 (
8152 p_element_name VARCHAR2
8153 ,p_ele_attribution OUT NOCOPY r_ele_attribution
8154 )
8155 IS
8156 l_proc varchar2(72) := g_proc_name||'get_element_attribution';
8157 l_element_type_id NUMBER;
8158 l_ele_attribution r_ele_attribution;
8159
8160 CURSOR csr_get_ele_type_id
8161 IS
8162 SELECT element_type_id
8163 FROM pay_element_types_f
8164 WHERE element_name = p_element_name
8165 AND rownum=1;
8166
8167 CURSOR csr_get_ele_attribution
8168 (
8169 p_element_type_id NUMBER
8170 )
8171 IS
8172 SELECT pei.eei_information1 from_time_dimension
8173 ,pei.eei_information2 pay_source_value
8174 ,pei.eei_information3 qualifier
8175 ,pei.eei_information4 fte
8176 ,pei.eei_information5 termtime
8177 ,pei.eei_information7 calc_type
8178 ,pei.eei_information8 calc_value
8179 ,pei.eei_information9 input_value
8180 ,NVL(pei.eei_information10
8181 ,decode(pei.eei_information2,'IV','Y','N')) link_to_assign
8182 ,NVL(pei.eei_information12,'Y') term_time_yes_no -- ! be careful
8183 ,NVL(pei.eei_information13,'N') sum_multiple_entries_yn
8184 ,NVL(pei.eei_information14,'N') lookup_input_values_yn
8185 ,pei.eei_information16 column_name_source_type
8186 ,pei.eei_information17 column_name_source_name
8187 ,pei.eei_information18 row_name_source_type
8188 ,pei.eei_information19 row_name_source_name
8189 FROM -- pay_element_types_f pet
8190 pay_element_type_extra_info pei
8191 WHERE pei.element_type_id = p_element_type_id
8192 AND pei.information_type = 'PQP_UK_ELEMENT_ATTRIBUTION';
8193 BEGIN
8194 debug_enter(l_proc);
8195
8196 OPEN csr_get_ele_type_id;
8197 FETCH csr_get_ele_type_id INTO l_element_type_id;
8198 CLOSE csr_get_ele_type_id;
8199
8200 debug('l_element_type_id: '||l_element_type_id);
8201
8202 IF g_ele_attribution.exists(l_element_type_id) THEN
8203 debug('Element attribution is already fetched for this element: '||p_element_name);
8204 p_ele_attribution := g_ele_attribution(l_element_type_id);
8205 ELSE
8206 debug('Fetch the Element attribution for this element: '||p_element_name);
8207 OPEN csr_get_ele_attribution(l_element_type_id);
8208 FETCH csr_get_ele_attribution INTO l_ele_attribution;
8209 IF csr_get_ele_attribution%FOUND THEN
8210 g_ele_attribution(l_element_type_id) := l_ele_attribution;
8211 p_ele_attribution := l_ele_attribution;
8212 END IF;
8213 CLOSE csr_get_ele_attribution;
8214 END IF;
8215
8216 debug_exit(l_proc);
8217 END get_element_attribution;
8218 ------------------------------------------------------------------------------
8219 --|-------------------------< get_notional_pay >-----------------------|
8220 -- ----------------------------------------------------------------------------
8221 FUNCTION get_notional_pay
8222 (
8223 p_assignment_id IN NUMBER
8224 ,p_business_group_id IN NUMBER
8225 ,p_effective_date IN DATE
8226 ,p_name IN VARCHAR2
8227 ,p_rt_element IN VARCHAR2
8228 ,p_rate IN OUT NOCOPY NUMBER
8229 ,p_custom_function IN VARCHAR2
8230 ,p_allowance_code IN VARCHAR2
8231 ,p_allowance_pet_id IN NUMBER
8232 ) RETURN NUMBER
8233 IS
8234 l_proc varchar2(72) := g_proc_name||'.get_notional_pay';
8235 l_contract_type VARCHAR2(1);
8236 l_to_time_dim VARCHAR2(1);
8237 l_basic_sal_rate VARCHAR2(80);
8238 l_err_no NUMBER;
8239 l_err_msg VARCHAR2(100);
8240 l_assignment_category VARCHAR2(20);
8241 l_fte VARCHAR2(1) := 'Y';
8242 l_notional_pay NUMBER;
8243 l_error NUMBER;
8244 l_sqlstr VARCHAR2(2000);
8245 l_user_rate NUMBER := 0;
8246 l_ele_attribution r_ele_attribution;
8247 l_fte_value NUMBER;
8248 BEGIN
8249 debug_enter(l_proc);
8250
8251 debug('Parameters: ');
8252 debug('p_business_group_id:' || p_business_group_id,10);
8253 debug('p_assignment_id:' || p_assignment_id,10);
8254 debug('p_effective_date:' || p_effective_date,10);
8255 debug('p_name:' || p_name,10);
8256 debug('p_rt_element:' || p_rt_element,10);
8257 -- get contract type
8258 l_error := get_contract_type
8259 (
8260 p_assignment_id => p_assignment_id
8261 ,p_business_group_id => p_business_group_id
8262 ,p_effective_date => p_effective_date
8263 ,p_contract_type => l_contract_type
8264 );
8265 IF l_contract_type IS NOT NULL THEN
8266 -- depending on the contract type the to-time-dimension is decided
8267 IF l_contract_type = '5' OR l_contract_type = '6' THEN
8268 l_to_time_dim := 'W';
8269 ELSE
8270 l_to_time_dim := 'A';
8271 END IF;
8272
8273 debug('l_to_time_dim:' || l_to_time_dim,10);
8274
8275
8276 l_err_no := pqp_rates_history_calc.rates_history
8277 (p_assignment_id => p_assignment_id
8278 ,p_calculation_date => p_effective_date
8279 ,p_name => p_name
8280 ,p_rt_element => p_rt_element
8281 ,p_to_time_dim => l_to_time_dim
8282 ,p_rate => l_notional_pay
8283 ,p_error_message => l_err_msg
8284 --,p_contract_type => g_contract_type
8285 --,p_contract_type_usage => 'OVERRIDE'
8286 );
8287
8288 if l_err_no <> -1 then
8289
8290 -- 115.60
8291 IF p_rt_element = 'E' THEN
8292 -- for element mode call check for the FTE attribution
8293 -- and reverse it.
8294 get_element_attribution
8295 (
8296 p_element_name => p_name
8297 ,p_ele_attribution => l_ele_attribution
8298 );
8299 IF l_ele_attribution.fte <> 'N' THEN
8300 --if fte attribution is other than 'N'
8301 -- fetch the FTE value of that date and reverse
8302 -- the fte value in the notional pay value;
8303 l_fte_value := get_fte_value
8304 (
8305 p_assignment_id => g_assignment_id
8306 ,p_effective_date => p_effective_date
8307 );
8308 debug('l_fte_value: '||l_fte_value);
8309 IF l_fte_value > 0 THEN
8310 -- fte value is returned as -1 when the value is not there.
8311 l_notional_pay := l_notional_pay/nvl(l_fte_value,1);
8312 END IF;
8313 END IF;
8314 END IF;
8315 -- get the user notional pay value
8316 IF p_custom_function IS NOT NULL THEN
8317 BEGIN
8318 -- build the call to the user function.
8319 l_sqlstr :=
8320 'BEGIN '
8321 || p_custom_function
8322 || '( :assignment_id,:business_group_id,:effective_date,'
8323 || ':source_name,:source_qualifier,:to_time_dim,:notional_rate,:allowance_code,'
8324 || ':allowance_pet_id,:user_rate);'
8325 || 'END;';
8326
8327 IF g_debug
8328 THEN
8329 debug('l_sqlstr: ' || l_sqlstr);
8330 END IF;
8331
8332 EXECUTE IMMEDIATE l_sqlstr
8333 USING p_assignment_id
8334 , p_business_group_id
8335 , p_effective_date
8336 , p_name -- name of the element or rate type
8337 , p_rt_element -- 'R' / 'E'
8338 , l_to_time_dim -- 'W' / 'A'
8339 , l_notional_pay -- Historic Rates values
8340 , p_allowance_code
8341 , p_allowance_pet_id
8342 ,OUT l_user_rate; -- value returned by the user function
8343
8344 p_rate := NVL(l_user_rate,0);
8345 EXCEPTION
8346 WHEN others THEN
8347 IF SQLCODE <> hr_utility.hr_error_number
8348 THEN
8349 debug_others (l_proc, 10);
8350 IF g_debug
8351 THEN
8352 DEBUG ( 'Leaving: '
8353 || l_proc, -999);
8354 END IF;
8355 debug('ERROR: Error Raised during calculation of Notional Pay',20);
8356 l_error := PQP_GB_PSI_FUNCTIONS.raise_extract_error
8357 (p_error_number => 94541
8358 ,p_error_text => 'BEN_94541_ERR_USR_NOTIONAL_PAY'
8359 ,p_token1 => p_custom_function
8360 );
8361 ELSE
8362 RAISE;
8363 END IF;
8364 END;
8365 ELSE
8366 debug('Without using the callout fucntion.',30);
8367 p_rate := NVL(l_notional_pay,0);
8368 END IF; --IF p_custom_function IS NOT NULL THEN
8369 else
8370 debug('ERROR: Error Raised during calculation of Notional Pay',20);
8371 l_error := PQP_GB_PSI_FUNCTIONS.raise_extract_error
8372 (p_error_number => 94456
8373 ,p_error_text => 'BEN_94456_ERR_NOTIONAL_PAY'
8374 ,p_token1 => SUBSTR(l_err_msg,1,30)
8375 );
8376 p_rate := 0;
8377 end if; --if l_err_no <> -1
8378
8379 END IF; --IF l_contract_type IS NOT NULL
8380
8381 debug('Notional Pay: '||p_rate,10);
8382 debug_exit(l_proc);
8383 return 0;
8384 END get_notional_pay;
8385 ---
8386 ----------------------------------------------------------------------------
8387 -- |------------------------< get_fte_value >--------------------------|
8388 -- ----------------------------------------------------------------------------
8389 FUNCTION get_fte_value
8390 (
8391 p_assignment_id NUMBER
8392 ,p_effective_date DATE
8393 )RETURN NUMBER
8394 IS
8395 l_proc varchar2(72) := g_proc_name||'.get_fte_value';
8396 l_fte_value NUMBER;
8397 CURSOR csr_get_fte_value
8398 IS
8399 SELECT value
8400 FROM PER_ASSIGNMENT_BUDGET_VALUES_F
8401 WHERE assignment_id = p_assignment_id
8402 AND UNIT = 'FTE'
8403 AND p_effective_date between effective_start_date
8404 AND effective_end_date;
8405 BEGIN
8406 debug_enter(l_proc);
8407 OPEN csr_get_fte_value;
8408 FETCH csr_get_fte_value INTO l_fte_value;
8409 CLOSE csr_get_fte_value;
8410 IF l_fte_value IS NOT NULL THEN
8411 return l_fte_value;
8412 END IF;
8413 return -1;
8414 debug_exit(l_proc);
8415 END get_fte_value;
8416 ---
8417 -- ----------------------------------------------------------------------------
8418 -- |------------------------< get_actual_pay >--------------------------|
8419 -- ----------------------------------------------------------------------------
8420 FUNCTION get_actual_pay
8421 (
8422 p_assignment_id IN NUMBER
8423 ,p_notional_pay IN NUMBER
8424 ,p_effective_date IN DATE
8425 ,p_output OUT NOCOPY VARCHAR2
8426 )RETURN NUMBER
8427 IS
8428 l_proc varchar2(72) := g_proc_name||'.get_actual_pay';
8429 l_assignment_category VARCHAR2(20);
8430 l_fte_value NUMBER;
8431 l_error NUMBER;
8432 BEGIN
8433 debug_enter(l_proc);
8434 l_fte_value := get_fte_value(p_assignment_id,p_effective_date);
8435 IF l_fte_value <> -1 THEN
8436 debug('Par-time employee.. FTE value is less than 1',10);
8437 IF l_fte_value < 1 THEN
8438 p_output := (p_notional_pay * l_fte_value);
8439 debug('Actual pay: '||to_char(p_output),20);
8440 END IF;
8441 ELSE
8442 -- data error.
8443 debug('Data Error: FTE value for the person is missing on: '||to_char(g_effective_date,'dd/mm/yyyy'),20);
8444 l_error := PQP_GB_PSI_FUNCTIONS.raise_extract_warning
8445 (p_error_number => 94449
8446 ,p_error_text => 'BEN_94449_NO_FTE_VALUE'
8447 ,p_token1 => to_char(g_effective_date,'dd-MON-yyyy')
8448 );
8449 END IF;
8450 debug_exit(l_proc);
8451 return 0;
8452 END get_actual_pay;
8453 ---
8454 -- ----------------------------------------------------------------------------
8455 -- |------------------------< init_st_end_date_glob --------------------------|
8456 -- ----------------------------------------------------------------------------
8457 PROCEDURE init_st_end_date_glob
8458 IS
8459 l_proc varchar2(72) := g_proc_name||'.init_st_end_date_glob';
8460 BEGIN
8461 debug_enter(l_proc);
8462
8463 -- reset assignment level globals
8464 g_pay_proc_evt_tab := ben_ext_person.g_pay_proc_evt_tab;
8465 g_salary_ended := 'N';
8466 g_salary_started := 'Y';
8467 g_salary_ele_end_date := c_highest_date;
8468 g_non_salary_ele_end_date := c_highest_date;
8469 g_sal_chg_event_exists := 'N';
8470 g_salary_end_date := NULL;
8471 g_is_terminated := 'N';
8472 g_salary_ended_today := 'N';
8473 g_allowance_has_end_dated := 'N';
8474
8475 debug_exit(l_proc);
8476 END init_st_end_date_glob;
8477 ---
8478 ---
8479 -- ----------------------------------------------------------------------------
8480 -- |-------------------< get_first_retro_event_date --------------------------|
8481 -- ----------------------------------------------------------------------------
8482 FUNCTION get_first_retro_event_date
8483 (
8484 p_assignment_id IN NUMBER
8485 ,p_retro_event_date OUT NOCOPY DATE
8486 )RETURN NUMBER
8487 IS
8488 l_proc varchar2(72) := g_proc_name||'get_first_retro_event_date';
8489 BEGIN
8490 debug_enter(l_proc);
8491
8492 IF g_min_effective_date.EXISTS(p_assignment_id)
8493 THEN
8494 debug('g_min_effective_date(g_assignment_id): '||g_min_effective_date(p_assignment_id),20);
8495 p_retro_event_date := g_min_effective_date(p_assignment_id);
8496
8497 g_retro_event_date_reported := TRUE;
8498
8499 debug('p_retro_event_date: '||p_retro_event_date,10);
8500 END IF;
8501
8502 debug_exit(l_proc);
8503 RETURN 0;
8504 END get_first_retro_event_date;
8505 ---
8506
8507 ---
8508 -- ----------------------------------------------------------------------------
8509 -- |------------------------< get_rate_usr_func_name >--------------------------|
8510 -- ----------------------------------------------------------------------------
8511 PROCEDURE get_rate_usr_func_name
8512 (
8513 p_business_group_id NUMBER
8514 ,p_legislation_code VARCHAR2
8515 ,p_interface_name VARCHAR2 -- expected to be SALARY / ALLOWANCE
8516 ,p_rate_name OUT NOCOPY VARCHAR2
8517 ,p_rate_code OUT NOCOPY VARCHAR2
8518 ,p_usr_rate_function OUT NOCOPY VARCHAR2
8519 ,p_sal_ele_fte_attr OUT NOCOPY VARCHAR2 -- 115.60
8520 )
8521 IS
8522 c_seeded_basic_sal_rate_name CONSTANT VARCHAR2(80) := 'PenServer Pensionable Salary';
8523 c_seeded_basic_sal_rate_code CONSTANT VARCHAR2(80) := 'PEN_SALARY';
8524 l_rate_code VARCHAR2(80);
8525 l_rate_name VARCHAR2(80);
8526 l_config_value PQP_UTILITIES.t_config_values;
8527 l_proc varchar2(72) := g_proc_name||'get_rate_usr_func_name';
8528 l_itr NUMBER;
8529 BEGIN
8530 debug_enter(l_proc);
8531
8532 debug('p_business_group_id: '||p_business_group_id,10);
8533 debug('p_legislation_code: '||p_legislation_code,10);
8534 debug('p_interface_name: '||p_interface_name,10);
8535
8536
8537 PQP_UTILITIES.get_config_type_values(
8538 p_configuration_type => 'PQP_GB_PENSERVER_RATE_TYPES'
8539 ,p_business_group_id => p_business_group_id
8540 ,p_legislation_code => p_legislation_code
8541 ,p_tab_config_values => l_config_value
8542 );
8543 IF l_config_value.COUNT > 0 THEN
8544 FOR i in 1..l_config_value.COUNT
8545 LOOP
8546 IF i = 1 THEN
8547 l_itr := l_config_value.FIRST;
8548 ELSE
8549 l_itr := l_config_value.NEXT(l_itr);
8550 END IF;
8551 IF p_interface_name = 'SALARY' AND l_config_value(l_itr).pcv_information1 = 'BAS_SALARY' THEN
8552 p_rate_code := l_config_value(l_itr).pcv_information2;
8553 p_usr_rate_function := l_config_value(l_itr).pcv_information3;
8554 p_sal_ele_fte_attr := l_config_value(l_itr).pcv_information4;
8555 EXIT;
8556 ELSIF p_interface_name = 'ALLOWANCE' AND l_config_value(l_itr).pcv_information1 = 'ALLOWANCE' THEN
8557 --p_rate_code := l_config_value(l_itr).pcv_information2;
8558 p_usr_rate_function := l_config_value(l_itr).pcv_information3;
8559 EXIT;
8560 END IF;
8561 END LOOP;
8562 END IF;
8563
8564 IF p_rate_code IS NOT NULL THEN
8565 p_rate_name := HR_GENERAL.DECODE_LOOKUP
8566 (
8567 p_lookup_type => 'PQP_RATE_TYPE'
8568 ,p_lookup_code => p_rate_code
8569 );
8570
8571 END IF;
8572
8573 debug('p_rate_name: '||p_rate_name);
8574 debug('p_rate_code: '||p_rate_code);
8575 debug('p_usr_rate_function: '||p_usr_rate_function);
8576 debug('p_sal_ele_fte_attr: '||p_sal_ele_fte_attr);
8577 debug_exit(l_proc);
8578 END get_rate_usr_func_name;
8579 ---
8580
8581 END PQP_GB_PSI_FUNCTIONS;