DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQP_GB_PSI_BON_HISTORY

Source


1 PACKAGE BODY PQP_GB_PSI_BON_HISTORY AS
2     --  /* $Header: pqpgbpsibon.pkb 120.5.12010000.2 2008/08/05 14:06:39 ubhat ship $ */
3     --
4     --
5     --
6     --
7     --
8     -- Exceptions
9     hr_application_error exception;
10     pragma exception_init (hr_application_error, -20001);
11 
12     g_nested_level       NUMBER(5) := pqp_utilities.g_nested_level;
13 
14 -- For BUG 5998129
15     l_element_of_bonus_type VARCHAR2(1);
16     -- ----------------------------------------------------------------------------
17     -- |--------------------------------< debug >---------------------------------|
18     -- ----------------------------------------------------------------------------
19 
20        PROCEDURE DEBUG (p_trace_message IN VARCHAR2
21                         , p_trace_location IN NUMBER DEFAULT NULL)
22        IS
23 
24     --
25        BEGIN
26           --
27           IF g_debug THEN
28               pqp_utilities.DEBUG (
29                  p_trace_message               => p_trace_message
30                 ,p_trace_location              => p_trace_location
31               );
32           END IF;
33        --
34        END DEBUG;
35 
36 
37     -- This procedure is used for debug purposes
38     -- debug_enter checks the debug flag and sets the trace on/off
39     --
40     -- ----------------------------------------------------------------------------
41     -- |----------------------------< debug_enter >-------------------------------|
42     -- ----------------------------------------------------------------------------
43 
44        PROCEDURE debug_enter (p_proc_name IN VARCHAR2
45                              ,p_trace_on IN VARCHAR2 DEFAULT NULL)
46        IS
47        BEGIN
48           --
49           IF g_debug THEN
50             IF pqp_utilities.g_nested_level = 0 THEN
51               hr_utility.trace_on(NULL, 'REQID'); -- Pipe name REQIDnnnnn
52             END IF;
53             pqp_utilities.debug_enter (
54               p_proc_name                   => p_proc_name
55              ,p_trace_on                    => p_trace_on
56            );
57           END IF;
58           --
59 
60        END debug_enter;
61 
62 
63     -- This procedure is used for debug purposes
64     --
65     -- ----------------------------------------------------------------------------
66     -- |----------------------------< debug_exit >--------------------------------|
67     -- ----------------------------------------------------------------------------
68 
69        PROCEDURE debug_exit (p_proc_name IN VARCHAR2
70                             ,p_trace_off IN VARCHAR2  DEFAULT NULL )
71        IS
72        BEGIN
73           --
74           IF g_debug THEN
75             pqp_utilities.debug_exit (
76               p_proc_name                   => p_proc_name
77              ,p_trace_off                    => p_trace_off
78            );
79 
80            IF pqp_utilities.g_nested_level = 0 THEN
81               hr_utility.trace_off;
82            END IF;
83           END IF;
84           --
85        END debug_exit;
86 
87 
88     -- This procedure is used for debug purposes
89     --
90     -- ----------------------------------------------------------------------------
91     -- |----------------------------< debug_others >------------------------------|
92     -- ----------------------------------------------------------------------------
93 
94        PROCEDURE debug_others (p_proc_name IN VARCHAR2, p_proc_step IN NUMBER)
95        IS
96        BEGIN
97           --
98           pqp_utilities.debug_others (
99              p_proc_name                   => p_proc_name
100             ,p_proc_step                   => p_proc_step
101           );
102        --
103        END debug_others;
104 
105     ---
106     -- ----------------------------------------------------------------------------
107     -- |---------------< set_bonus_balance_type >-------------------|
108     -- Description:
109     -- ----------------------------------------------------------------------------
110     PROCEDURE set_bonus_balance_type
111     IS
112         l_proc varchar2(72) := g_package||'.set_bonus_balance_type';
113         l_config_values   PQP_UTILITIES.t_config_values;
114     BEGIN
115         debug_enter(l_proc);
116         -- fetch the adj hrs source configuration values
117         PQP_UTILITIES.get_config_type_values(
118                      p_configuration_type   =>    'PQP_GB_PENSERVER_BONBAL_VALUE'
119                     ,p_business_group_id    =>    g_business_group_id
120                     ,p_legislation_code     =>    g_legislation_code
121                     ,p_tab_config_values    =>    l_config_values
122                   );
123         IF l_config_values.COUNT > 0 THEN
124             debug('Configration value exists',20);
125 
126             g_bon_bal_type_id   :=  l_config_values(l_config_values.FIRST).pcv_information1;
127 
128             debug('g_bon_bal_type_id: '||g_bon_bal_type_id,20);
129 
130         ELSE
131             debug('ERROR: Configration value is not present',20);
132             -- raise error
133             PQP_GB_PSI_FUNCTIONS.store_extract_exceptions
134                                (p_extract_type        =>    'BONUS HISTORY'
135                                ,p_error_number        =>    94639
136                                ,p_error_text          =>    'BEN_94639_NO_BON_BAL_CONFIG'
137                                ,p_error_warning_flag  =>    'E'
138                                );
139         END IF;
140         debug_exit(l_proc);
141     EXCEPTION
142            WHEN others THEN
143                IF SQLCODE <> hr_utility.hr_error_number
144                THEN
145                    debug_others (l_proc, 10);
146                    IF g_debug
147                    THEN
148                      DEBUG (   'Leaving: '
149                             || l_proc, -999);
150                     END IF;
151                     fnd_message.raise_error;
152                 ELSE
153                     RAISE;
154                 END IF;
155     END set_bonus_balance_type;
156     ---
157     -- ----------------------------------------------------------------------------
158     -- |---------------< set_bonus_history_globals >-------------------|
159     -- Description:
160     -- ----------------------------------------------------------------------------
161     PROCEDURE set_bonus_history_globals
162               (
163               p_business_group_id     IN NUMBER
164               ,p_assignment_id        IN NUMBER
165               ,p_effective_date       IN DATE
166               )
167     IS
168         l_proc varchar2(72) := g_package||'.set_bonus_history_globals';
169     BEGIN
170         debug_enter(l_proc);
171         -- set global business group id
172         g_business_group_id := p_business_group_id;
173         g_legislation_code  :=  'GB';
174 
175         debug('g_legislation_code: '||g_legislation_code,10);
176         debug('g_business_group_id: '||g_business_group_id,10);
177 
178         -- set the bonus balance type id from the configuration
179         set_bonus_balance_type;
180 
181         -- set the globals in pqp_gb_psi_function for all valid bonus types.
182         PQP_GB_PSI_FUNCTIONS.get_elements_of_info_type
183                                 (p_information_type          =>   'PQP_GB_PENSERV_BONUS_INFO'
184                                 ,p_input_value_mandatory_yn  =>   'N'
185                                 );
186 
187         debug_exit(l_proc);
188     EXCEPTION
189            WHEN others THEN
190                IF SQLCODE <> hr_utility.hr_error_number
191                THEN
192                    debug_others (l_proc, 10);
193                    IF g_debug
194                    THEN
195                      DEBUG (   'Leaving: '
196                             || l_proc, -999);
197                     END IF;
198                     fnd_message.raise_error;
199                 ELSE
200                     RAISE;
201                 END IF;
202     END set_bonus_history_globals;
203     ---
204     -- ----------------------------------------------------------------------------
205     -- |-----------------------< set_assignment_globals >--------------------------|
206     -- ----------------------------------------------------------------------------
207     PROCEDURE set_assignment_globals
208                 (
209                 p_assignment_id         IN NUMBER
210                 ,p_effective_date        IN DATE
211                 )
212     IS
213         l_proc varchar2(72) := g_package||'.set_assignment_globals';
214 
215         CURSOR csr_start_date
216         IS
217             select PPS.DATE_START -- DECODE(PER.CURRENT_EMPLOYEE_FLAG,'Y',PPS.DATE_START,NULL)
218             from per_all_people_f PER, per_periods_of_service PPS
219             where per.person_id = g_person_id
220               and pps.person_id = g_person_id
221               and p_effective_date  between per.effective_start_date
222                        and NVL(per.effective_end_date,hr_api.g_eot)
223               and p_effective_date  between pps.date_start
224                        and NVL(pps.final_process_date,hr_api.g_eot);
225 
226     BEGIN -- set_assignment_globals
227         debug_enter(l_proc);
228         debug('Inputs are: ',10);
229         debug('p_assignment_id: '||p_assignment_id,10);
230         debug('p_effective_date: '||to_char(p_effective_date,'dd/mm/yyyy'),10);
231 
232 --For BUG 5998129
233 
234         -- set the global values to NULL each time when a new assignment processsed.
235         g_first_retro_event             := NULL;
236         g_first_retro_event_start       := NULL;
237         g_first_approved_event          := NULL;
238 
239 
240         -- set the global events table
241         g_pay_proc_evt_tab  :=  ben_ext_person.g_pay_proc_evt_tab;
242         -- clear the global cache for the duplicate bonus codes check
243         g_proc_bon_codes.DELETE;
244 
245         -- set global assignment_id
246         g_assignment_id     := p_assignment_id;
247         debug('g_assignment_id: '||g_assignment_id,10);
248         g_person_id         :=  PQP_GB_PSI_FUNCTIONS.get_current_extract_person
249                               (
250                               p_assignment_id => p_assignment_id
251                               );
252         --set the assignment start date
253         OPEN csr_start_date;
254         FETCH csr_start_date INTO g_assg_start_date;
255         CLOSE csr_start_date;
256 
257         debug_exit(l_proc);
258     EXCEPTION
259            WHEN others THEN
260                IF SQLCODE <> hr_utility.hr_error_number
261                THEN
262                    debug_others (l_proc, 10);
263                    IF g_debug
264                    THEN
265                      DEBUG (   'Leaving: '
266                             || l_proc, -999);
267                     END IF;
268                     fnd_message.raise_error;
269                 ELSE
270                     RAISE;
271                 END IF;
272     END set_assignment_globals;
273     ---
274     -- ----------------------------------------------------------------------------
275     -- |-----------------------< chk_dup_bon_types >--------------------------|
276     -- ----------------------------------------------------------------------------
277     PROCEDURE chk_dup_bon_types
278                   (
279                   p_effective_date  DATE DEFAULT g_effective_date
280                   )
281     IS
282         l_proc varchar2(72) := g_package||'.chk_dup_bon_types';
283         l_return            NUMBER;
284         l_effective_date_no NUMBER;
285         l_curr_bon_code     VARCHAR2(4);
286         l_position          NUMBER;
287         l_element_entry_id  VARCHAR2(20);
288     BEGIN -- set_assignment_globals
289         debug_enter(l_proc);
290 
291         -----
292         l_effective_date_no :=  to_char(p_effective_date,'ddmmyyyy');
293         l_curr_bon_code :=  PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type(g_curr_element_type_id).eei_information2;
294 
295         debug('l_effective_date_no: '||l_effective_date_no);
296         debug('l_curr_bon_code: '||l_curr_bon_code);
297         debug('g_curr_element_entry_id: '||g_curr_element_entry_id);
298         IF g_proc_bon_codes.EXISTS(l_effective_date_no) THEN
299             debug('Value of the string: '||g_proc_bon_codes(l_effective_date_no));
300 
301             l_position  :=  instr(g_proc_bon_codes(l_effective_date_no),RPAD(l_curr_bon_code,4,'*'));
302 
303             IF l_position > 0 THEN
304                 debug('Found similar Bous Code');
305                 l_element_entry_id  :=  SUBSTR(g_proc_bon_codes(l_effective_date_no)
306                                           ,l_position+4
307                                           ,(INSTR(g_proc_bon_codes(l_effective_date_no),';',l_position)-(l_position+4))
308                                           );
309                 debug('Element Entry id of the dup bonus code: '||l_element_entry_id);
310                 IF g_curr_element_entry_id <> to_number(l_element_entry_id) THEN
311                     -- found a similar bonus code with for a different element entry
312                     -- raise a warning;
313                     debug('found a similar bonus code with for a different element entry');
314                     debug('WARNING: Duplicate Bonus Type on same date');
315                     l_return :=  PQP_GB_PSI_FUNCTIONS.raise_extract_warning
316                                      (p_error_number        =>    94526
320                 ELSE
317                                      ,p_error_text          =>    'BEN_94526_DUP_BON_TYPE'
318                                      ,p_token1              =>    to_char(p_effective_date,'dd/mm/yyyy')
319                                      );
321                     -- found a similar bonus code is for the same element entry
322                     -- no warnign will be raised
323                     debug('found a similar bonus code is for the same element entry');
324                 END IF;
325 
326 
327             ELSE
328                 debug('This Bonus type is not processed.');
329                 g_proc_bon_codes(l_effective_date_no) :=  g_proc_bon_codes(l_effective_date_no)
330                                                             ||
331                                                           RPAD(l_curr_bon_code,4,'*')||g_curr_element_entry_id||';' ;
332             END IF;
333         ELSE
334             debug('No entry for the current effective date');
335             g_proc_bon_codes(l_effective_date_no) :=  RPAD(l_curr_bon_code,4,'*')||g_curr_element_entry_id||';' ;
336         END IF;
337         -----
338 
339         debug_exit(l_proc);
340     EXCEPTION
341            WHEN others THEN
342                IF SQLCODE <> hr_utility.hr_error_number
343                THEN
344                    debug_others (l_proc, 10);
345                    IF g_debug
346                    THEN
347                      DEBUG (   'Leaving: '
348                             || l_proc, -999);
349                     END IF;
350                     fnd_message.raise_error;
351                 ELSE
352                     RAISE;
353                 END IF;
354     END chk_dup_bon_types;
355     ---
356     -- ----------------------------------------------------------------------------
357     -- |-----------------------< set_curr_row_values >----------------------------|
358     -- Description:
359     -- ----------------------------------------------------------------------------
360     FUNCTION set_curr_row_values RETURN BOOLEAN
361     IS
362         l_proc varchar2(72) := g_package||'.set_curr_row_values';
363         l_chg_table                 VARCHAR2(30);
364         l_chg_type                  VARCHAR2(30);
365         l_chg_surrogate_key         NUMBER;
366         l_chg_date                  DATE;
367         l_include           VARCHAR2(1);
368         l_return            NUMBER;
369         CURSOR csr_get_ee_id
370                   (
371                   p_ele_entry_value_id    NUMBER
372                   )
373         IS
374             SELECT element_entry_id
375             FROM pay_element_entry_values_f
376             WHERE element_entry_value_id = p_ele_entry_value_id
377             AND ROWNUM = 1;
378     BEGIN
379         debug_enter(l_proc);
380 
381         IF g_current_layout = 'PERIODIC' THEN
382             -- person repeating level
383             l_chg_table         :=  ben_ext_person.g_chg_pay_table;
384             l_chg_type          :=  ben_ext_person.g_chg_update_type;
385             l_chg_surrogate_key :=  ben_ext_person.g_chg_surrogate_key;
386             l_chg_date          :=  ben_ext_person.g_chg_eff_dt;
387             debug('l_chg_table: '||l_chg_table,10);
388             debug('l_chg_type: '||l_chg_type,10);
389             debug('l_chg_surrogate_key: '||l_chg_surrogate_key,10);
390             debug('l_chg_date: '||l_chg_date,10);
391 
392             IF l_chg_table  <> 'PAY_ELEMENT_ENTRIES_F'
393             AND (l_chg_type = 'I' OR l_chg_type = 'C')THEN
394 
395                 debug('Not a valid event, will not be processed',20);
396                 debug('Returning FALSE');
397                 debug_exit(l_proc);
398                 RETURN FALSE;
399 
400             END IF;
401 
402 
403         ELSIF g_current_layout = 'CUTOVER' THEN
404             -- element repeating level
405             g_curr_element_type_id    :=  ben_ext_person.g_element_id;
406             g_curr_ee_start_date      :=  ben_ext_person.g_element_entry_eff_start_date;
407             g_curr_ee_end_date        :=  ben_ext_person.g_element_entry_eff_end_date;
408             g_curr_element_type_name  :=  ben_ext_person.g_element_name;
409         END IF;
410 
411         IF g_current_layout = 'PERIODIC' THEN
412             g_curr_element_entry_id   :=  fnd_number.canonical_to_number(l_chg_surrogate_key);
413 
414             IF l_chg_type = 'C' THEN
415                 -- for correction events on pay_element_entry_values_f
416                 --  the surrogate key is element_entry_value_id
417                 --  this should be re-set to element_entry_id
418                 debug('element_entry_value_id: '||g_curr_element_entry_id,20);
419                 OPEN csr_get_ee_id(g_curr_element_entry_id);
420                 FETCH csr_get_ee_id INTO g_curr_element_entry_id;
421                 CLOSE csr_get_ee_id;
422                 debug('element_entry_id: '||g_curr_element_entry_id,20);
423             END IF;
424         ELSE
425             g_curr_element_entry_id  :=  ben_ext_person.g_element_entry_id;
426         END IF;
427 
428         debug('g_curr_element_entry_id: '||g_curr_element_entry_id,10);
429         debug('g_curr_element_type_id: '||g_curr_element_type_id,10);
430         debug('g_curr_ee_start_date: '||g_curr_ee_start_date,10);
431         debug('g_curr_ee_end_date: '||g_curr_ee_end_date,10);
432 
436                                   ,p_element_type_id    =>  g_curr_element_type_id
433         IF g_current_layout = 'PERIODIC' THEN
434             PQP_GB_PSI_FUNCTIONS.check_if_element_qualifies
435                                   (p_element_entry_id   =>  g_curr_element_entry_id
437                                   ,p_include            =>  l_include
438                                   );
439 
440             IF l_include = 'N'  THEN
441                 debug('Rejected by check_if_element_qualifies',30);
442                 debug('Returning FALSE',30);
443 
444 --For BUG 5998129
445                 -- Setting the No flag for the elements of non bonus type
446                 -- use to check before the call pqp_gb_psi_functions.process_retro_event
447                 l_element_of_bonus_type := 'N';
448 --END For BUG 5998129
449 
450                 debug_exit(l_proc);
451                 RETURN FALSE;
452             END IF;
453         END IF; --g_current_layout = 'PERIODIC' THEN
454 
455         IF PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type.exists(g_curr_element_type_id) THEN
456 
457             g_curr_element_type_name
458                 :=  PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type(g_curr_element_type_id).element_name;
459             --check if non-recurring element
460             IF PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type(g_curr_element_type_id).processing_type = 'R' THEN
461                   debug('ERROR: Recurring element, will not be processed.',30);
462                   l_return :=  PQP_GB_PSI_FUNCTIONS.raise_extract_error --Bug fix 5015173
463                                (p_error_number        =>    94530
464                                ,p_error_text          =>    'BEN_94530_REC_BON_ELEMENT'
465                                ,p_token1              =>
466                                     pqp_gb_psi_functions.g_elements_of_info_type(g_curr_element_type_id).element_name
467                                );
468                   debug('Returning FALSE',30);
469                   debug_exit(l_proc);
470                   RETURN FALSE;
471             ELSE
472                   debug('Is a non-recurring element',20);
473             END IF;
474 
475             --check if pensionable bonus
476             IF PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type(g_curr_element_type_id).eei_information4 <> 'Y' THEN
477                   debug('ERROR: Not a Pensionable Bonus, will not be processed.',30);
478                   l_return :=  PQP_GB_PSI_FUNCTIONS.raise_extract_error
479                                (p_error_number        =>    94527
480                                ,p_error_text          =>    'BEN_94527_NOT_PEN_BONUS'
481                                ,p_token1              =>
482                                     pqp_gb_psi_functions.g_elements_of_info_type(g_curr_element_type_id).element_name
483                                );
484                   debug('Returning FALSE',30);
485                   debug_exit(l_proc);
486                   RETURN FALSE;
487             ELSE
488                   debug('Is a Pensionable Bonus',20);
489             END IF;
490         ELSE
491             debug('Not a valid element type',20);
492             debug('Returning FALSE',20);
493             debug_exit(l_proc);
494             RETURN FALSE;
495         END IF;
496 
497         -- check for dupliate bonus types
498         chk_dup_bon_types();
499         debug('Returning TRUE',10);
500         debug_exit(l_proc);
501         RETURN TRUE;
502     EXCEPTION
503            WHEN others THEN
504                IF SQLCODE <> hr_utility.hr_error_number
505                THEN
506                    debug_others (l_proc, 10);
507                    IF g_debug
508                    THEN
509                      DEBUG (   'Leaving: '
510                             || l_proc, -999);
511                     END IF;
512                     fnd_message.raise_error;
513                 ELSE
514                     RAISE;
515                 END IF;
516     END set_curr_row_values;
517     ----
518     -- ----------------------------------------------------------------------------
519     -- |--------------------< bonus_cutover_ext_criteria >----------------------|
520     -- Description:
521     -- ----------------------------------------------------------------------------
522     FUNCTION bonus_cutover_ext_criteria
523                 (
524                 p_business_group_id      IN NUMBER
525                 ,p_assignment_id         IN NUMBER
526                 ,p_effective_date        IN DATE
527                 )RETURN VARCHAR2
528     IS
529         l_proc varchar2(72) := g_package||'.bonus_cutover_ext_criteria';
530         l_include  varchar2(1) :=  'Y';
531         l_cutover_date  DATE;
532     BEGIN
533         debug_enter(l_proc);
534         g_current_layout  :=  'CUTOVER';
535 
536         debug_enter(l_proc);
537         debug('Inputs are: ');
538         debug('p_business_group_id: '||p_business_group_id,10);
539         debug('p_assignment_id: '||p_assignment_id,10);
540         debug('p_effective_date: '||to_char(p_effective_date,'dd/mm/yyyy'),10);
541 
542 
543         IF g_business_group_id IS NULL
544            OR p_business_group_id <> nvl(g_business_group_id,0) THEN
545 
546             g_business_group_id :=  p_business_group_id;
547             -- set the global debug value
548             g_debug :=  pqp_gb_psi_functions.check_debug(to_char(g_business_group_id));
549             debug_enter(l_proc);
553             debug('p_effective_date: '||to_char(p_effective_date,'dd/mm/yyyy'));
550             debug('Inputs are: ');
551             debug('p_business_group_id: '||p_business_group_id);
552             debug('p_assignment_id: '||p_assignment_id);
554 
555             PQP_GB_PSI_FUNCTIONS.set_shared_globals
556                  (p_business_group_id => p_business_group_id
557                  ,p_paypoint          => g_paypoint
558                  ,p_cutover_date      => l_cutover_date
559                  ,p_ext_dfn_id        => g_ext_dfn_id
560                  );
561 
562             g_effective_date  :=  p_effective_date;
563 
564             set_bonus_history_globals
565                     (
566                     p_business_group_id     =>    p_business_group_id
567                     ,p_assignment_id        =>    p_assignment_id
568                     ,p_effective_date       =>    p_effective_date
569                     );
570 
571             --Raise extract exceptions which are stored while checking for the setup
572             debug('Raising the set-up errors, with input parameter as S',10);
573             PQP_GB_PSI_FUNCTIONS.raise_extract_exceptions('S');
574         END IF; --IF g_business_group_id IS NULL
575 
576         IF l_include <> 'N' THEN
577 
578             IF g_assignment_id IS NULL
579                OR p_assignment_id <> nvl(g_assignment_id,0) THEN
580 
581                 -- dummy call to basic criteria to set the globals in common package.
582                 l_include :=  PQP_GB_PSI_FUNCTIONS.chk_penserver_basic_criteria
583                       (p_business_group_id        =>  p_business_group_id
584                       ,p_effective_date           =>  p_effective_date
585                       ,p_assignment_id            =>  p_assignment_id
586                       ,p_person_dtl               =>  g_curr_person_dtls
587                       ,p_assignment_dtl           =>  g_curr_assg_dtls
588                       );
589                 --l_include is set to 'Y' because basic criteria will be called again for
590                 --  claim date.
591                 l_include :=  'Y';
592 
593                 set_assignment_globals
594                       (
595                       p_assignment_id         =>    p_assignment_id
596                       ,p_effective_date       =>    p_effective_date
597                       );
598             END IF;
599 
600         END IF; --IF l_include <> 'N' THEN
601 
602         pqp_gb_psi_functions.g_effective_date :=  p_effective_date;
603 
604         debug('l_include: '||l_include);
605         debug_exit(l_proc);
606         RETURN l_include;
607     EXCEPTION
608            WHEN others THEN
609                IF SQLCODE <> hr_utility.hr_error_number
610                THEN
611                    debug_others (l_proc, 10);
612                    IF g_debug
613                    THEN
614                      DEBUG (   'Leaving: '
615                             || l_proc, -999);
616                     END IF;
617                     fnd_message.raise_error;
618                 ELSE
619                     RAISE;
620                 END IF;
621     END bonus_cutover_ext_criteria;
622     ---
623     -- ----------------------------------------------------------------------------
624     -- |--------------------< bonus_periodic_ext_criteria >----------------------|
625     -- Description:
626     -- ----------------------------------------------------------------------------
627     FUNCTION bonus_periodic_ext_criteria
628                 (
629                 p_business_group_id      IN NUMBER
630                 ,p_assignment_id         IN NUMBER
631                 ,p_effective_date        IN DATE
632                 )RETURN VARCHAR2
633     IS
634         l_proc varchar2(72) := g_package||'.bonus_periodic_ext_criteria';
635         l_include  varchar2(1) :=  'Y';
636         l_cutover_date        DATE;
637         l_curr_evt_index        NUMBER;
638 
639 --For BUG 5998129
640         l_bon_effective_date DATE;
641         l_bon_curr_evt_index NUMBER;
642         -- l_first_eff_date BOOLEAN; /* For Bug: 6791275 */
643 
644 
645     BEGIN
646         debug_enter(l_proc);
647         g_current_layout  :=  'PERIODIC';
648         g_effective_date := p_effective_date;
649 
650 --For BUG 5998129
651         l_element_of_bonus_type := 'Y';
652 
653         debug_enter(l_proc);
654         debug('Inputs are: ');
655         debug('p_business_group_id: '||p_business_group_id,10);
656         debug('p_assignment_id: '||p_assignment_id,10);
657         debug('p_effective_date: '||to_char(p_effective_date,'dd/mm/yyyy'),10);
658 
659 
660         IF g_business_group_id IS NULL
661            OR p_business_group_id <> nvl(g_business_group_id,0) THEN
662 
663             g_business_group_id :=  p_business_group_id;
664             -- set the global debug value
665             g_debug :=  pqp_gb_psi_functions.check_debug(to_char(g_business_group_id));
666             debug_enter(l_proc);
667             debug('Inputs are: ');
668             debug('p_business_group_id: '||p_business_group_id);
669             debug('p_assignment_id: '||p_assignment_id);
670             debug('p_effective_date: '||to_char(p_effective_date,'dd/mm/yyyy'));
671 
672             PQP_GB_PSI_FUNCTIONS.set_shared_globals
673                  (p_business_group_id => p_business_group_id
677                  );
674                  ,p_paypoint          => g_paypoint
675                  ,p_cutover_date      => l_cutover_date
676                  ,p_ext_dfn_id        => g_ext_dfn_id
678 
679             set_bonus_history_globals
680                     (
681                     p_business_group_id     =>    p_business_group_id
682                     ,p_assignment_id        =>    p_assignment_id
683                     ,p_effective_date       =>    p_effective_date
684                     );
685             --Raise extract exceptions which are stored while checking for the setup
686             debug('Raising the set-up errors, with input parameter as S',10);
687             PQP_GB_PSI_FUNCTIONS.raise_extract_exceptions('S');
688         END IF; --IF g_business_group_id IS NULL
689 
690         IF l_include <> 'N' THEN
691 
692             IF g_assignment_id IS NULL
693                OR p_assignment_id <> nvl(g_assignment_id,0) THEN
694 
695                 -- dummy call to basic criteria to set the globals in common package.
696                 l_include :=  PQP_GB_PSI_FUNCTIONS.chk_penserver_basic_criteria
697                       (p_business_group_id        =>  p_business_group_id
698                       ,p_effective_date           =>  p_effective_date
699                       ,p_assignment_id            =>  p_assignment_id
700                       ,p_person_dtl               =>  g_curr_person_dtls
701                       ,p_assignment_dtl           =>  g_curr_assg_dtls
702                       );
703                 --l_include is set to 'Y' because basic criteria will be called again for
704                 --  claim date.
705                 l_include :=  'Y';
706 
707 --For BUG 5998129
708 
709                 g_first_eff_date := TRUE; /* For Bug: 6791275 */
710 
711                 set_assignment_globals
712                       (
713                       p_assignment_id         =>    p_assignment_id
714                       ,p_effective_date       =>    p_effective_date
715                       );
716 --For BUG 5998129
717                  -- store in l_bon_curr_evt_index, so that we can restore
718                  -- ben_ext_person.g_chg_pay_evt_index with current value later on
719                  l_bon_effective_date := NULL;
720                  l_bon_curr_evt_index    :=    ben_ext_person.g_chg_pay_evt_index;
721 
722                  debug('l_bon_effective_date : '||l_bon_effective_date);
723                  debug('total events : '||g_pay_proc_evt_tab.count);
724                  debug('l_bon_curr_evt_index : '||l_bon_curr_evt_index);
725 
726                   FOR i in l_bon_curr_evt_index..g_pay_proc_evt_tab.count
727                   LOOP
728                              l_include := pqp_gb_psi_functions.include_event
729                                           (p_actual_date => g_pay_proc_evt_tab(i).actual_date
730                                           ,p_effective_date => g_pay_proc_evt_tab(i).effective_date
731                                           );
732 
733                     IF l_include = 'Y' -- AND PQP_GB_PSI_FUNCTIONS.g_min_eff_date_exists = 'Y'
734                     THEN
735 
736                       -- if retro event was found, store retro date details in globals
737                       IF PQP_GB_PSI_FUNCTIONS.g_min_eff_date_exists = 'Y'
738                       THEN
739                        debug('first retro event found');
740                         -- retro event
741                         l_bon_effective_date := g_pay_proc_evt_tab(i).effective_date; --p_effective_date;
742                         g_first_retro_event  := g_pay_proc_evt_tab(i).effective_date; --p_effective_date;
743                         g_first_approved_event := g_pay_proc_evt_tab(i).effective_date; --p_effective_date;
744 
745                         l_bon_effective_date := trunc(l_bon_effective_date,'MM');
746                         g_first_retro_event_start := l_bon_effective_date;
747 
748                        debug('p_effective_date :' ||p_effective_date);
749 
750                        debug('first retro event date :' ||g_first_retro_event);
751                        debug('first retro event start date :' ||g_first_retro_event_start);
752 
753                       ELSE
754                         debug('first normal event found ');
755                          g_first_approved_event := g_pay_proc_evt_tab(i).effective_date;
756                         debug('first normal event date '||g_first_approved_event);
757 
758                       END IF;
759 
760                       EXIT;
761 
762                     END IF;
763 
764                      debug('i value :'||i);
765                      -- incrementing ben_ext_person.g_chg_pay_evt_index now,
766                      -- will be restored after the FOR loop
767                      ben_ext_person.g_chg_pay_evt_index := ben_ext_person.g_chg_pay_evt_index + 1;
768                   END LOOP;
769 
770                  debug('after loop l_bon_effective_date :'||l_bon_effective_date);
771 
772                  -- restoring ben_ext_person.g_chg_pay_evt_index
773                  ben_ext_person.g_chg_pay_evt_index := l_bon_curr_evt_index;
774 --END For BUG 5998129
775             END IF;
776 
777             l_curr_evt_index    :=    ben_ext_person.g_chg_pay_evt_index;
778             debug('----------');
779             debug('Record :'||l_curr_evt_index);
780             debug('----------');
781             debug('surrogate_key     :'||g_pay_proc_evt_tab(l_curr_evt_index).surrogate_key    ,20);
785             debug('----------');
782             debug('update_type       :'||g_pay_proc_evt_tab(l_curr_evt_index).update_type      ,20);
783             debug('effective_date    :'||to_char(g_pay_proc_evt_tab(l_curr_evt_index).effective_date,'DD/MM/YYYY'),20);
784             debug('actual_date       :'||to_char(g_pay_proc_evt_tab(l_curr_evt_index).actual_date,'DD/MM/YYYY'),20);
786 
787 
788 --For BUG 5998129
789             -- events till first 'Y' have already been evaluated above, when the first event was found
790             IF g_first_retro_event IS NOT NULL
791             THEN
792 
793                 -- for use by process_retro_event function
794                 PQP_GB_PSI_FUNCTIONS.g_min_effective_date(g_assignment_id) := g_first_retro_event_start;
795 
796                 -- reject all events till start of retro-event-month
797                 IF (g_pay_proc_evt_tab(l_curr_evt_index).effective_date < g_first_retro_event_start)
798                 THEN
799                   l_include := 'N';
800                 ELSIF (g_pay_proc_evt_tab(l_curr_evt_index).effective_date <= g_first_retro_event)
801                 THEN
802                   l_include := 'Y';
803                 ELSE -- include event has to be called here onwards
804 
805                   debug('Calling the common include event proc');
806                   l_include := pqp_gb_psi_functions.include_event
807                                (p_actual_date => g_pay_proc_evt_tab(l_curr_evt_index).actual_date
808                                ,p_effective_date => g_pay_proc_evt_tab(l_curr_evt_index).effective_date
809                                );
810                   debug('include_event returned: '||l_include);
811                 END IF;
812 
813             ELSE -- no retro events, so reject all events till g_first_approved_event
814 
815                 IF g_first_approved_event IS NULL
816                 THEN
817 
818                   l_include := 'N';
819 
820                 ELSIF (g_pay_proc_evt_tab(l_curr_evt_index).effective_date < g_first_approved_event)
821                 THEN
822 
823                   l_include := 'N';
824 
825                 ELSE -- include event has to be called here onwards
826 
827                   debug('Calling the common include event proc');
828                   l_include := pqp_gb_psi_functions.include_event
829                                (p_actual_date => g_pay_proc_evt_tab(l_curr_evt_index).actual_date
830                                ,p_effective_date => g_pay_proc_evt_tab(l_curr_evt_index).effective_date
831                                );
832                   debug('include_event returned: '||l_include);
833                 END IF;
834             END IF;
835 
836             -- For first p_effective_date, make the include flag set to 'Y', since
837             -- this date might get rejected as curr_event already processed .
838             IF g_first_eff_date
839             THEN
840                -- l_first_eff_date := FALSE; /* For Bug: 6791275 */
841                IF g_first_retro_event_start IS NOT NULL
842                   OR g_first_approved_event IS NOT NULL
843                THEN
844                   IF p_effective_date = NVL(g_first_retro_event,g_first_approved_event)
845                   THEN
846                      l_include := 'Y';
847 		     g_first_eff_date := FALSE; /* For Bug: 6791275 */
848                   END IF;
849                END IF;
850             END IF;
851 
852             --- call set_curr_row_values() for all events only after g_first_retro_event_start
853             --- or g_first_approved_event
854             IF p_effective_date >= NVL(g_first_retro_event_start,g_first_approved_event)
855             THEN
856                IF NOT set_curr_row_values()
857                   OR l_include = 'N'
858                THEN
859                   --current event is not accepted
860                   l_include := 'N';
861                END IF;
862             ELSE
863                l_include := 'N';
864             END IF;
865 --END For BUG 5998129
866 
867         END IF; --IF l_include <> 'N' THEN
868 
869         pqp_gb_psi_functions.g_effective_date :=  p_effective_date;
870 
871 --For BUG 5998129
872         debug('l_element_of_bonus_type: '||l_element_of_bonus_type);
873         IF g_first_retro_event_start IS NOT NULL
874         THEN
875           IF l_element_of_bonus_type = 'Y' AND p_effective_date >= g_first_retro_event_start
876           THEN
877               pqp_gb_psi_functions.process_retro_event(l_include);
878            END IF;
879          END IF;
880 --END For BUG 5998129
881 
882         debug('l_include: '||l_include);
883         debug_exit(l_proc);
884         return l_include;
885     EXCEPTION
886            WHEN others THEN
887                IF SQLCODE <> hr_utility.hr_error_number
888                THEN
889                    debug_others (l_proc, 10);
890                    IF g_debug
891                    THEN
892                      DEBUG (   'Leaving: '
893                             || l_proc, -999);
894                     END IF;
895                     fnd_message.raise_error;
896                 ELSE
897                     RAISE;
898                 END IF;
899     END bonus_periodic_ext_criteria;
900     ---
901     -- ----------------------------------------------------------------------------
902     -- |--------------------< bonus_history_data_ele_val >----------------------|
906                  (
903     -- Description:
904     -- ----------------------------------------------------------------------------
905     FUNCTION bonus_history_data_ele_val
907                  p_ext_user_value     IN VARCHAR2
908                  ,p_output_value       OUT NOCOPY VARCHAR2
909                  ) RETURN NUMBER
910     IS
911         l_proc varchar2(72) := g_package||'.bonus_history_data_ele_val';
912         l_include  NUMBER  :=  0;
913         -- ----------------------------------------------------------------------------
914         -- |---------------------------< get_effective_date >--------------------------|
915         -- Description:
916         -- ----------------------------------------------------------------------------
917         FUNCTION get_effective_date
918                     (
919                     p_output_value       OUT NOCOPY VARCHAR2
920                     )RETURN NUMBER
921         IS
922             l_proc varchar2(72) := g_package||'.get_effective_date';
923             l_date_char     VARCHAR2(20);
924             l_claim_date    DATE;
925             l_return        NUMBER;
926 
927             CURSOR csr_get_claim_date
928             IS
929                SELECT  peev.screen_entry_value
930               FROM pay_element_entry_values_f peev
931                   ,pay_input_values_f piv
932               WHERE peev.element_entry_id = g_curr_element_entry_id
933               AND peev.input_value_id = piv.input_value_id
934               AND UPPER(piv.NAME) = 'CLAIM DATE'
935               --AND peev.effective_start_date = p_effective_date
936               ORDER BY piv.name;
937         BEGIN
938             debug_enter(l_proc);
939 
940             /*IF g_current_layout = 'CUTOVER' THEN
941                 p_output_value  :=  to_char(ben_ext_person.g_element_entry_eff_start_date,'dd/mm/yyyy');
942             ELSE
943                 p_output_value  :=  to_char(g_effective_date,'dd/mm/yyyy');
944             END IF;*/
945 
946             OPEN csr_get_claim_date;
947             FETCH csr_get_claim_date INTO l_date_char;
948             CLOSE csr_get_claim_date;
949 
950             IF l_date_char IS null THEN
951                 -- raise error - no claim date value
952                 l_return :=  PQP_GB_PSI_FUNCTIONS.raise_extract_error
953                                (p_error_number        =>    94683
954                                ,p_error_text          =>    'BEN_94683_BON_NO_CLM_DT_VAL'
955                                ,p_token1              =>
956                                     pqp_gb_psi_functions.g_elements_of_info_type(g_curr_element_type_id).element_name
957                                ,p_token2              =>    to_char(g_effective_date,'dd/mm/yyyy')
958                                );
959             ELSE
960                 --
961                 l_claim_date  :=  fnd_date.canonical_to_date(l_date_char);
962                 IF pqp_gb_psi_functions.is_proper_claim_date
963                             (l_claim_date
964                             ,g_curr_element_type_name
965                             ,g_curr_element_entry_id
966                             ,g_assg_start_date
967                             ) THEN
968                      -- is a proper claim date
969                      debug('the claim date is proper');
970                      p_output_value := to_char(l_claim_date,'dd/mm/yyyy');
971                  ELSE
972                     debug('the claim date is not proper');
973                  END IF;
974             END IF;
975             debug_exit(l_proc);
976             return 0;
977         EXCEPTION
978            WHEN others THEN
979                IF SQLCODE <> hr_utility.hr_error_number
980                THEN
981                    debug_others (l_proc, 10);
982                    IF g_debug
983                    THEN
984                      DEBUG (   'Leaving: '
985                             || l_proc, -999);
986                     END IF;
987                     fnd_message.raise_error;
988                 ELSE
989                     RAISE;
990                 END IF;
991         END get_effective_date;
992         ---
993         -- ----------------------------------------------------------------------------
994         -- |---------------------------< get_bonus_code >--------------------------|
995         -- Description:
996         -- ----------------------------------------------------------------------------
997         FUNCTION get_bonus_code
998                     (
999                     p_output_value       OUT NOCOPY VARCHAR2
1000                     )RETURN NUMBER
1001         IS
1002             l_proc varchar2(72) := g_package||'.get_bonus_code';
1003             l_return    NUMBER;
1004         BEGIN
1005             debug_enter(l_proc);
1006 
1007             IF PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type.exists(g_curr_element_type_id) THEN
1008                 p_output_value
1009                     :=  PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type(g_curr_element_type_id).eei_information2;
1010             END IF;
1011 
1012             IF NOT pqp_gb_psi_functions.is_alphanumeric(p_output_value) THEN
1013                 -- Bug Fix 5015236
1014                debug('ERROR: the bonus code is non-alphanumeric',20);
1015                l_return :=  PQP_GB_PSI_FUNCTIONS.raise_extract_error
1016                                (p_error_number        =>    94557
1017                                ,p_error_text          =>    'BEN_94557_INVALID_CODE'
1021                                ,p_token3              =>    p_output_value
1018                                ,p_token1              =>    'Bonus'
1019                                ,p_token2              =>
1020                                     pqp_gb_psi_functions.g_elements_of_info_type(g_curr_element_type_id).element_name
1022                                );
1023             END IF;
1024 
1025             debug_exit(l_proc);
1026             return 0;
1027         EXCEPTION
1028            WHEN others THEN
1029                IF SQLCODE <> hr_utility.hr_error_number
1030                THEN
1031                    debug_others (l_proc, 10);
1032                    IF g_debug
1033                    THEN
1034                      DEBUG (   'Leaving: '
1035                             || l_proc, -999);
1036                     END IF;
1037                     fnd_message.raise_error;
1038                 ELSE
1039                     RAISE;
1040                 END IF;
1041         END get_bonus_code;
1042         ---
1043         -- ----------------------------------------------------------------------------
1044         -- |----------------------------< get_bonus_amount >-----------------------------|
1045         -- Description:
1046         -- ----------------------------------------------------------------------------
1047         FUNCTION get_bonus_amount
1048                     (
1049                     p_output_value       OUT NOCOPY VARCHAR2
1050                     )RETURN NUMBER
1051         IS
1052             l_proc varchar2(72) := g_package||'.get_bonus_amount';
1053             l_include  NUMBER  :=  0;
1054             l_bonus_amount  NUMBER;
1055         BEGIN
1056             debug_enter(l_proc);
1057 
1058             l_bonus_amount    :=  pqp_gb_psi_functions.get_element_payment_balance
1059                                                 (p_assignment_id       =>  g_assignment_id
1060                                                  ,p_element_entry_id   =>  g_curr_element_entry_id
1061                                                  ,p_element_type_id    =>  g_curr_element_type_id
1062                                                  ,p_balance_type_id    =>  g_bon_bal_type_id
1063                                                  ,p_effective_date     =>  g_effective_date
1064                                                  );
1065             /*l_bonus_amount  :=  pqp_gb_psi_functions.get_element_payment
1066                                             (p_assignment_id          =>  g_assignment_id
1067                                             ,p_element_entry_id   =>  g_curr_element_entry_id
1068                                             ,p_element_type_id    =>  g_curr_element_type_id
1069                                             ,p_effective_date     =>  g_effective_date
1070                                             );*/
1071             IF l_bonus_amount IS NULL THEN
1072                 -- raise error that the bonus amount is null and value will not be reported.
1073                 debug('ERROR: No Bonus Amount',20);
1074                 l_include :=  PQP_GB_PSI_FUNCTIONS.raise_extract_error
1075                                  (p_error_number        =>    94531
1076                                  ,p_error_text          =>    'BEN_94531_NO_BONUS_AMOUNT'
1077                                  ,p_token1              =>    g_curr_element_type_name
1078                                                                  ||'('||g_curr_element_entry_id||')'
1079                                  ,p_token2              =>    to_char(g_effective_date,'dd/mm/yyyy')
1080                                  );
1081             ELSIF NOT ( l_bonus_amount >= -99999999.99 AND l_bonus_amount <= 999999999.99 ) THEN
1082                 -- raise error that the bonus amount is out of range
1083                 -- bug fix 4998232
1084                 debug('ERROR: Bonus Amount out of range: '||l_bonus_amount,20);
1085                 l_include :=  PQP_GB_PSI_FUNCTIONS.raise_extract_error
1086                                  (p_error_number        =>    94567
1087                                  ,p_error_text          =>    'BEN_94567_INVALID_BONUS_AMOUNT'
1088                                  ,p_token1              =>    g_curr_element_type_name
1089                                                                  ||'('||g_curr_element_entry_id||')'
1090                                  ,p_token2              =>    to_char(g_effective_date,'dd/mm/yyyy')
1091                                  ,p_token3              =>    l_bonus_amount
1092                                  );
1093                p_output_value :=  l_bonus_amount;
1094             ELSE
1095                 -- bug fix 5026913.
1096                 IF l_bonus_amount < 0 THEN
1097                     p_output_value  :=  ltrim(rtrim(to_char(l_bonus_amount,'S09999999D99')));
1098                 ELSE
1099                     p_output_value  :=  ltrim(rtrim(to_char(l_bonus_amount,'099999999D99')));
1100                 END IF;
1101             END IF;
1102 
1103             debug_exit(l_proc);
1104             return l_include;
1105         EXCEPTION
1106            WHEN others THEN
1107                IF SQLCODE <> hr_utility.hr_error_number
1108                THEN
1109                    debug_others (l_proc, 10);
1110                    IF g_debug
1111                    THEN
1112                      DEBUG (   'Leaving: '
1113                             || l_proc, -999);
1114                     END IF;
1115                     fnd_message.raise_error;
1116                 ELSE
1117                     RAISE;
1118                 END IF;
1119         END get_bonus_amount;
1123         -- Description:
1120         ---
1121         -- ----------------------------------------------------------------------------
1122         -- |---------------------------< get_ind_flag >--------------------------|
1124         -- ----------------------------------------------------------------------------
1125         FUNCTION get_ind_flag
1126                     (
1127                     p_output_value       OUT NOCOPY VARCHAR2
1128                     )RETURN NUMBER
1129         IS
1130             l_proc varchar2(72) := g_package||'.get_ind_flag';
1131         BEGIN
1132             debug_enter(l_proc);
1133 
1134             IF PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type.exists(g_curr_element_type_id) THEN
1135                 p_output_value
1136                     :=  PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type(g_curr_element_type_id).eei_information5;
1137             END IF;
1138 
1139             debug_exit(l_proc);
1140             return 0;
1141         EXCEPTION
1142            WHEN others THEN
1143                IF SQLCODE <> hr_utility.hr_error_number
1144                THEN
1145                    debug_others (l_proc, 10);
1146                    IF g_debug
1147                    THEN
1148                      DEBUG (   'Leaving: '
1149                             || l_proc, -999);
1150                     END IF;
1151                     fnd_message.raise_error;
1152                 ELSE
1153                     RAISE;
1154                 END IF;
1155         END get_ind_flag;
1156         ---
1157         -- ----------------------------------------------------------------------------
1158         -- |---------------------------< get_bonus_ee_id >--------------------------|
1159         -- Description:
1160         -- ----------------------------------------------------------------------------
1161         FUNCTION get_bonus_ee_id
1162                     (
1163                     p_output_value       OUT NOCOPY VARCHAR2
1164                     )RETURN NUMBER
1165         IS
1166             l_proc varchar2(72) := g_package||'.get_bonus_ee_id';
1167         BEGIN
1168             debug_enter(l_proc);
1169 
1170             p_output_value :=  g_curr_element_entry_id;
1171 
1172             debug_exit(l_proc);
1173             return 0;
1174         EXCEPTION
1175            WHEN others THEN
1176                IF SQLCODE <> hr_utility.hr_error_number
1177                THEN
1178                    debug_others (l_proc, 10);
1179                    IF g_debug
1180                    THEN
1181                      DEBUG (   'Leaving: '
1182                             || l_proc, -999);
1183                     END IF;
1184                     fnd_message.raise_error;
1185                 ELSE
1186                     RAISE;
1187                 END IF;
1188         END get_bonus_ee_id;
1189         ---
1190     BEGIN  --bonus_history_data_ele_val
1191         debug_enter(l_proc);
1192         debug('p_ext_user_value: '||p_ext_user_value,10);
1193 
1194         IF g_current_layout = 'CUTOVER' THEN
1195             IF p_ext_user_value = 'BonusEffectiveDate' THEN
1196               debug('For Cutover run, for effective date element',20);
1197               IF NOT set_curr_row_values() THEN
1198                 --current event is not accepted
1199                 g_include_current_row :=  FALSE;
1200                 p_output_value  :=  NULL;
1201                 debug('Returning : '||l_include,20);
1202                 debug_exit(l_proc);
1203                 return l_include;
1204             ELSE
1205                 g_include_current_row :=  TRUE;
1206             END IF;
1207 
1208           END IF; --IF p_ext_user_value = 'BonusEffectiveDate'
1209         ELSE
1210             -- for periodic
1211             debug('For Periodic run g_include_current_row is always true.',20);
1212             g_include_current_row :=  TRUE;
1213         END IF;
1214 
1215         IF g_include_current_row THEN
1216           debug('g_include_current_row is true.',20);
1217           IF p_ext_user_value = 'BonusEffectiveDate' THEN
1218              l_include :=  get_effective_date
1219                             (
1220                             p_output_value  =>  p_output_value
1221                             );
1222           ELSIF p_ext_user_value = 'BonusCode' THEN
1223              l_include :=  get_bonus_code
1224                             (
1225                             p_output_value  =>  p_output_value
1226                             );
1227           ELSIF p_ext_user_value = 'BonusAmount' THEN
1228              l_include :=  get_bonus_amount
1229                             (
1230                             p_output_value  =>  p_output_value
1231                             );
1232           ELSIF p_ext_user_value = 'BonusIndFlag' THEN
1233              l_include :=  get_ind_flag
1234                             (
1235                             p_output_value  =>  p_output_value
1236                             );
1237           ELSIF p_ext_user_value = 'BonusEEId' THEN
1238              l_include :=  get_bonus_ee_id
1239                             (
1240                             p_output_value  =>  p_output_value
1241                             );
1242           END IF; -- IF p_ext_user_value =
1243 
1244         ELSE
1245 
1246             debug('g_include_current_row is true.',20);
1247 
1248         END IF; --IF g_include_current_row THEN
1249 
1250         debug('p_output_value : '||p_output_value,10);
1251         debug_exit(l_proc);
1252         return l_include;
1253     EXCEPTION
1254            WHEN others THEN
1255                IF SQLCODE <> hr_utility.hr_error_number
1256                THEN
1257                    debug_others (l_proc, 10);
1258                    IF g_debug
1259                    THEN
1260                      DEBUG (   'Leaving: '
1261                             || l_proc, -999);
1262                     END IF;
1263                     fnd_message.raise_error;
1264                 ELSE
1265                     RAISE;
1266                 END IF;
1267     END bonus_history_data_ele_val;
1268     ---
1269     -- ----------------------------------------------------------------------------
1270     -- |----------------------< bonus_history_post_proc >--------------------------|
1271     --  Description:  This is the post-processing rule  for the BONUS History.
1272     -- ----------------------------------------------------------------------------
1273     FUNCTION bonus_history_post_proc RETURN VARCHAR2
1274     IS
1275         l_proc varchar2(72) := g_package||'.bonus_history_post_proc';
1276     BEGIN
1277         debug_enter(l_proc);
1278 
1279         --Raise extract exceptions which are stored while processing the data elements
1280         --PQP_GB_PSI_FUNCTIONS.raise_extract_exceptions();
1281 
1282         PQP_GB_PSI_FUNCTIONS.common_post_process(g_business_group_id);
1283 
1284         debug_exit(l_proc);
1285         return 'Y';
1286     EXCEPTION
1287            WHEN others THEN
1288                IF SQLCODE <> hr_utility.hr_error_number
1289                THEN
1290                    debug_others (l_proc, 10);
1291                    IF g_debug
1292                    THEN
1293                      DEBUG (   'Leaving: '
1294                             || l_proc, -999);
1295                     END IF;
1296                     fnd_message.raise_error;
1297                 ELSE
1298                     RAISE;
1299                 END IF;
1300     END bonus_history_post_proc;
1301     ------
1302 END PQP_GB_PSI_BON_HISTORY;