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.8 2012/01/19 07:36:34 rpahune noship $ */
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
317                                      ,p_error_text          =>    'BEN_94526_DUP_BON_TYPE'
318                                      ,p_token1              =>    to_char(p_effective_date,'dd/mm/yyyy')
319                                      );
320                 ELSE
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                 -- For Bug 9503728
420 		    IF l_chg_table = 'PAY_ELEMENT_ENTRY_VALUES_F'
421 		    THEN
422                    OPEN csr_get_ee_id(g_curr_element_entry_id);
423                    FETCH csr_get_ee_id INTO g_curr_element_entry_id;
424                    CLOSE csr_get_ee_id;
425                    debug('element_entry_id: '||g_curr_element_entry_id,20);
426 		    END IF;
427             END IF;
428         ELSE
429             g_curr_element_entry_id  :=  ben_ext_person.g_element_entry_id;
430         END IF;
431 
432         debug('g_curr_element_entry_id: '||g_curr_element_entry_id,10);
433         debug('g_curr_element_type_id: '||g_curr_element_type_id,10);
434         debug('g_curr_ee_start_date: '||g_curr_ee_start_date,10);
435         debug('g_curr_ee_end_date: '||g_curr_ee_end_date,10);
436 
437         IF g_current_layout = 'PERIODIC' THEN
438             PQP_GB_PSI_FUNCTIONS.check_if_element_qualifies
439                                   (p_element_entry_id   =>  g_curr_element_entry_id
440                                   ,p_element_type_id    =>  g_curr_element_type_id
441                                   ,p_include            =>  l_include
442                                   );
443 
444             IF l_include = 'N'  THEN
445                 debug('Rejected by check_if_element_qualifies',30);
446                 debug('Returning FALSE',30);
447 
448 --For BUG 5998129
449                 -- Setting the No flag for the elements of non bonus type
450                 -- use to check before the call pqp_gb_psi_functions.process_retro_event
451                 l_element_of_bonus_type := 'N';
452 --END For BUG 5998129
453 
454                 debug_exit(l_proc);
455                 RETURN FALSE;
456             END IF;
457         END IF; --g_current_layout = 'PERIODIC' THEN
458 
459         IF PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type.exists(g_curr_element_type_id) THEN
460 
461             g_curr_element_type_name
462                 :=  PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type(g_curr_element_type_id).element_name;
463             --check if non-recurring element
464             IF PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type(g_curr_element_type_id).processing_type = 'R' THEN
465                   debug('ERROR: Recurring element, will not be processed.',30);
466                   l_return :=  PQP_GB_PSI_FUNCTIONS.raise_extract_error --Bug fix 5015173
467                                (p_error_number        =>    94530
468                                ,p_error_text          =>    'BEN_94530_REC_BON_ELEMENT'
469                                ,p_token1              =>
470                                     pqp_gb_psi_functions.g_elements_of_info_type(g_curr_element_type_id).element_name
471                                );
472                   debug('Returning FALSE',30);
473                   debug_exit(l_proc);
474                   RETURN FALSE;
475             ELSE
476                   debug('Is a non-recurring element',20);
477             END IF;
478 
479             --check if pensionable bonus
480             IF PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type(g_curr_element_type_id).eei_information4 <> 'Y' THEN
481                   debug('ERROR: Not a Pensionable Bonus, will not be processed.',30);
482                   l_return :=  PQP_GB_PSI_FUNCTIONS.raise_extract_error
483                                (p_error_number        =>    94527
484                                ,p_error_text          =>    'BEN_94527_NOT_PEN_BONUS'
485                                ,p_token1              =>
486                                     pqp_gb_psi_functions.g_elements_of_info_type(g_curr_element_type_id).element_name
487                                );
488                   debug('Returning FALSE',30);
489                   debug_exit(l_proc);
490                   RETURN FALSE;
491             ELSE
492                   debug('Is a Pensionable Bonus',20);
493             END IF;
494         ELSE
495             debug('Not a valid element type',20);
496             debug('Returning FALSE',20);
497             debug_exit(l_proc);
498             RETURN FALSE;
499         END IF;
500 
501         -- check for dupliate bonus types
502         chk_dup_bon_types();
503         debug('Returning TRUE',10);
504         debug_exit(l_proc);
505         RETURN TRUE;
506     EXCEPTION
507            WHEN others THEN
508                IF SQLCODE <> hr_utility.hr_error_number
509                THEN
510                    debug_others (l_proc, 10);
511                    IF g_debug
512                    THEN
513                      DEBUG (   'Leaving: '
514                             || l_proc, -999);
515                     END IF;
516                     fnd_message.raise_error;
517                 ELSE
518                     RAISE;
519                 END IF;
520     END set_curr_row_values;
521     ----
522     -- ----------------------------------------------------------------------------
523     -- |--------------------< bonus_cutover_ext_criteria >----------------------|
524     -- Description:
525     -- ----------------------------------------------------------------------------
526     FUNCTION bonus_cutover_ext_criteria
527                 (
528                 p_business_group_id      IN NUMBER
529                 ,p_assignment_id         IN NUMBER
530                 ,p_effective_date        IN DATE
531                 )RETURN VARCHAR2
532     IS
533         l_proc varchar2(72) := g_package||'.bonus_cutover_ext_criteria';
534         l_include  varchar2(1) :=  'Y';
535         l_cutover_date  DATE;
536     BEGIN
537         debug_enter(l_proc);
538         g_current_layout  :=  'CUTOVER';
539 
540         debug_enter(l_proc);
541         debug('Inputs are: ');
542         debug('p_business_group_id: '||p_business_group_id,10);
543         debug('p_assignment_id: '||p_assignment_id,10);
544         debug('p_effective_date: '||to_char(p_effective_date,'dd/mm/yyyy'),10);
545 
546 
547         IF g_business_group_id IS NULL
548            OR p_business_group_id <> nvl(g_business_group_id,0) THEN
549 
550             g_business_group_id :=  p_business_group_id;
551             -- set the global debug value
552             g_debug :=  pqp_gb_psi_functions.check_debug(to_char(g_business_group_id));
553             debug_enter(l_proc);
554             debug('Inputs are: ');
555             debug('p_business_group_id: '||p_business_group_id);
556             debug('p_assignment_id: '||p_assignment_id);
557             debug('p_effective_date: '||to_char(p_effective_date,'dd/mm/yyyy'));
558 
559             PQP_GB_PSI_FUNCTIONS.set_shared_globals
560                  (p_business_group_id => p_business_group_id
561                  ,p_paypoint          => g_paypoint
562                  ,p_cutover_date      => l_cutover_date
563                  ,p_ext_dfn_id        => g_ext_dfn_id
564                  );
565 
566             g_effective_date  :=  p_effective_date;
567 
568             set_bonus_history_globals
569                     (
570                     p_business_group_id     =>    p_business_group_id
571                     ,p_assignment_id        =>    p_assignment_id
572                     ,p_effective_date       =>    p_effective_date
573                     );
574 
575             --Raise extract exceptions which are stored while checking for the setup
576             debug('Raising the set-up errors, with input parameter as S',10);
577             PQP_GB_PSI_FUNCTIONS.raise_extract_exceptions('S');
578         END IF; --IF g_business_group_id IS NULL
579 
580         IF l_include <> 'N' THEN
581 
582             IF g_assignment_id IS NULL
583                OR p_assignment_id <> nvl(g_assignment_id,0) THEN
584 
585                 -- dummy call to basic criteria to set the globals in common package.
586                 l_include :=  PQP_GB_PSI_FUNCTIONS.chk_penserver_basic_criteria
587                       (p_business_group_id        =>  p_business_group_id
588                       ,p_effective_date           =>  p_effective_date
589                       ,p_assignment_id            =>  p_assignment_id
590                       ,p_person_dtl               =>  g_curr_person_dtls
591                       ,p_assignment_dtl           =>  g_curr_assg_dtls
592                       );
593                 --l_include is set to 'Y' because basic criteria will be called again for
594                 --  claim date.
595                 l_include :=  'Y';
596 
597                 set_assignment_globals
598                       (
599                       p_assignment_id         =>    p_assignment_id
600                       ,p_effective_date       =>    p_effective_date
601                       );
602             END IF;
603 
604         END IF; --IF l_include <> 'N' THEN
605 
606         pqp_gb_psi_functions.g_effective_date :=  p_effective_date;
607 
608         debug('l_include: '||l_include);
609         debug_exit(l_proc);
610         RETURN l_include;
611     EXCEPTION
612            WHEN others THEN
613                IF SQLCODE <> hr_utility.hr_error_number
614                THEN
615                    debug_others (l_proc, 10);
616                    IF g_debug
617                    THEN
618                      DEBUG (   'Leaving: '
619                             || l_proc, -999);
620                     END IF;
621                     fnd_message.raise_error;
622                 ELSE
623                     RAISE;
624                 END IF;
625     END bonus_cutover_ext_criteria;
626     ---
627     -- ----------------------------------------------------------------------------
628     -- |--------------------< bonus_periodic_ext_criteria >----------------------|
629     -- Description:
630     -- ----------------------------------------------------------------------------
631     FUNCTION bonus_periodic_ext_criteria
632                 (
633                 p_business_group_id      IN NUMBER
634                 ,p_assignment_id         IN NUMBER
635                 ,p_effective_date        IN DATE
636                 )RETURN VARCHAR2
637     IS
638         l_proc varchar2(72) := g_package||'.bonus_periodic_ext_criteria';
639         l_include  varchar2(1) :=  'Y';
640         l_cutover_date        DATE;
641         l_curr_evt_index        NUMBER;
642 
643 --For BUG 5998129
644         l_bon_effective_date DATE;
645         l_bon_curr_evt_index NUMBER;
646         -- l_first_eff_date BOOLEAN; /* For Bug: 6791275 */
647 
648 
649     BEGIN
650         debug_enter(l_proc);
651         g_current_layout  :=  'PERIODIC';
652         g_effective_date := p_effective_date;
653 
654 --For BUG 5998129
655         l_element_of_bonus_type := 'Y';
656 
657         debug_enter(l_proc);
658         debug('Inputs are: ');
659         debug('p_business_group_id: '||p_business_group_id,10);
660         debug('p_assignment_id: '||p_assignment_id,10);
661         debug('p_effective_date: '||to_char(p_effective_date,'dd/mm/yyyy'),10);
662 
663 
664         IF g_business_group_id IS NULL
665            OR p_business_group_id <> nvl(g_business_group_id,0) THEN
666 
667             g_business_group_id :=  p_business_group_id;
668             -- set the global debug value
669             g_debug :=  pqp_gb_psi_functions.check_debug(to_char(g_business_group_id));
670             debug_enter(l_proc);
671             debug('Inputs are: ');
672             debug('p_business_group_id: '||p_business_group_id);
673             debug('p_assignment_id: '||p_assignment_id);
674             debug('p_effective_date: '||to_char(p_effective_date,'dd/mm/yyyy'));
675 
676             PQP_GB_PSI_FUNCTIONS.set_shared_globals
677                  (p_business_group_id => p_business_group_id
678                  ,p_paypoint          => g_paypoint
679                  ,p_cutover_date      => l_cutover_date
680                  ,p_ext_dfn_id        => g_ext_dfn_id
681                  );
682 
683             set_bonus_history_globals
684                     (
685                     p_business_group_id     =>    p_business_group_id
686                     ,p_assignment_id        =>    p_assignment_id
687                     ,p_effective_date       =>    p_effective_date
688                     );
689             --Raise extract exceptions which are stored while checking for the setup
690             debug('Raising the set-up errors, with input parameter as S',10);
691             PQP_GB_PSI_FUNCTIONS.raise_extract_exceptions('S');
692         END IF; --IF g_business_group_id IS NULL
693 
694         IF l_include <> 'N' THEN
695 
696             IF g_assignment_id IS NULL
697                OR p_assignment_id <> nvl(g_assignment_id,0) THEN
698 
699                 -- dummy call to basic criteria to set the globals in common package.
700                 l_include :=  PQP_GB_PSI_FUNCTIONS.chk_penserver_basic_criteria
701                       (p_business_group_id        =>  p_business_group_id
702                       ,p_effective_date           =>  p_effective_date
703                       ,p_assignment_id            =>  p_assignment_id
704                       ,p_person_dtl               =>  g_curr_person_dtls
705                       ,p_assignment_dtl           =>  g_curr_assg_dtls
706                       );
707                 --l_include is set to 'Y' because basic criteria will be called again for
708                 --  claim date.
709                 l_include :=  'Y';
710 
711 --For BUG 5998129
712 
713                 g_first_eff_date := TRUE; /* For Bug: 6791275 */
714 
715                 set_assignment_globals
716                       (
717                       p_assignment_id         =>    p_assignment_id
718                       ,p_effective_date       =>    p_effective_date
719                       );
720 --For BUG 5998129
721                  -- store in l_bon_curr_evt_index, so that we can restore
722                  -- ben_ext_person.g_chg_pay_evt_index with current value later on
723                  l_bon_effective_date := NULL;
724                  l_bon_curr_evt_index    :=    ben_ext_person.g_chg_pay_evt_index;
725 
726                  debug('l_bon_effective_date : '||l_bon_effective_date);
727                  debug('total events : '||g_pay_proc_evt_tab.count);
728                  debug('l_bon_curr_evt_index : '||l_bon_curr_evt_index);
729 
730                   FOR i in l_bon_curr_evt_index..g_pay_proc_evt_tab.count
731                   LOOP
732                              l_include := pqp_gb_psi_functions.include_event
733                                           (p_actual_date => g_pay_proc_evt_tab(i).actual_date
734                                           ,p_effective_date => g_pay_proc_evt_tab(i).effective_date
735                                           );
736 
737                     IF l_include = 'Y' -- AND PQP_GB_PSI_FUNCTIONS.g_min_eff_date_exists = 'Y'
738                     THEN
739 
740                       -- if retro event was found, store retro date details in globals
741                       IF PQP_GB_PSI_FUNCTIONS.g_min_eff_date_exists = 'Y'
742                       THEN
743                        debug('first retro event found');
744                         -- retro event
745                         l_bon_effective_date := g_pay_proc_evt_tab(i).effective_date; --p_effective_date;
746                         g_first_retro_event  := g_pay_proc_evt_tab(i).effective_date; --p_effective_date;
747                         g_first_approved_event := g_pay_proc_evt_tab(i).effective_date; --p_effective_date;
748 
749                         l_bon_effective_date := trunc(l_bon_effective_date,'MM');
750                         g_first_retro_event_start := l_bon_effective_date;
751 
752                        debug('p_effective_date :' ||p_effective_date);
753 
754                        debug('first retro event date :' ||g_first_retro_event);
755                        debug('first retro event start date :' ||g_first_retro_event_start);
756 
757                       ELSE
758                         debug('first normal event found ');
759                          g_first_approved_event := g_pay_proc_evt_tab(i).effective_date;
760                         debug('first normal event date '||g_first_approved_event);
761 
762                       END IF;
763 
764                       EXIT;
765 
766                     END IF;
767 
768                      debug('i value :'||i);
769                      -- incrementing ben_ext_person.g_chg_pay_evt_index now,
770                      -- will be restored after the FOR loop
771                      ben_ext_person.g_chg_pay_evt_index := ben_ext_person.g_chg_pay_evt_index + 1;
772                   END LOOP;
773 
774                  debug('after loop l_bon_effective_date :'||l_bon_effective_date);
775 
776                  -- restoring ben_ext_person.g_chg_pay_evt_index
777                  ben_ext_person.g_chg_pay_evt_index := l_bon_curr_evt_index;
778 --END For BUG 5998129
779             END IF;
780 
781             l_curr_evt_index    :=    ben_ext_person.g_chg_pay_evt_index;
782             debug('----------');
783             debug('Record :'||l_curr_evt_index);
784             debug('----------');
785             debug('surrogate_key     :'||g_pay_proc_evt_tab(l_curr_evt_index).surrogate_key    ,20);
786             debug('update_type       :'||g_pay_proc_evt_tab(l_curr_evt_index).update_type      ,20);
787             debug('effective_date    :'||to_char(g_pay_proc_evt_tab(l_curr_evt_index).effective_date,'DD/MM/YYYY'),20);
788             debug('actual_date       :'||to_char(g_pay_proc_evt_tab(l_curr_evt_index).actual_date,'DD/MM/YYYY'),20);
789             debug('----------');
790 
791 
792 --For BUG 5998129
793             -- events till first 'Y' have already been evaluated above, when the first event was found
794             IF g_first_retro_event IS NOT NULL
795             THEN
796 
797                 -- for use by process_retro_event function
798                 PQP_GB_PSI_FUNCTIONS.g_min_effective_date(g_assignment_id) := g_first_retro_event_start;
799 
800                 -- reject all events till start of retro-event-month
801                 IF (g_pay_proc_evt_tab(l_curr_evt_index).effective_date < g_first_retro_event_start)
802                 THEN
803                   l_include := 'N';
804                 ELSIF (g_pay_proc_evt_tab(l_curr_evt_index).effective_date <= g_first_retro_event)
805                 THEN
806                   l_include := 'Y';
807                 ELSE -- include event has to be called here onwards
808 
809                   debug('Calling the common include event proc');
810                   l_include := pqp_gb_psi_functions.include_event
811                                (p_actual_date => g_pay_proc_evt_tab(l_curr_evt_index).actual_date
812                                ,p_effective_date => g_pay_proc_evt_tab(l_curr_evt_index).effective_date
813                                );
814                   debug('include_event returned: '||l_include);
815                 END IF;
816 
817             ELSE -- no retro events, so reject all events till g_first_approved_event
818 
819                 IF g_first_approved_event IS NULL
820                 THEN
821 
822                   l_include := 'N';
823 
824                 ELSIF (g_pay_proc_evt_tab(l_curr_evt_index).effective_date < g_first_approved_event)
825                 THEN
826 
827                   l_include := 'N';
828 
829                 ELSE -- include event has to be called here onwards
830 
831                   debug('Calling the common include event proc');
832                   l_include := pqp_gb_psi_functions.include_event
833                                (p_actual_date => g_pay_proc_evt_tab(l_curr_evt_index).actual_date
834                                ,p_effective_date => g_pay_proc_evt_tab(l_curr_evt_index).effective_date
835                                );
836                   debug('include_event returned: '||l_include);
837                 END IF;
838             END IF;
839 
840             -- For first p_effective_date, make the include flag set to 'Y', since
841             -- this date might get rejected as curr_event already processed .
842             IF g_first_eff_date
843             THEN
844                -- l_first_eff_date := FALSE; /* For Bug: 6791275 */
845                IF g_first_retro_event_start IS NOT NULL
846                   OR g_first_approved_event IS NOT NULL
847                THEN
848                   IF p_effective_date = NVL(g_first_retro_event,g_first_approved_event)
849                   THEN
850                      l_include := 'Y';
851 		     g_first_eff_date := FALSE; /* For Bug: 6791275 */
852                   END IF;
853                END IF;
854             END IF;
855 
856             --- call set_curr_row_values() for all events only after g_first_retro_event_start
857             --- or g_first_approved_event
858             IF p_effective_date >= NVL(g_first_retro_event_start,g_first_approved_event)
859             THEN
860                IF NOT set_curr_row_values()
861                   OR l_include = 'N'
862                THEN
863                   --current event is not accepted
864                   l_include := 'N';
865                END IF;
866             ELSE
867                l_include := 'N';
868             END IF;
869 --END For BUG 5998129
870 
871         END IF; --IF l_include <> 'N' THEN
872 
873         pqp_gb_psi_functions.g_effective_date :=  p_effective_date;
874 
875 --For BUG 5998129
876         debug('l_element_of_bonus_type: '||l_element_of_bonus_type);
877         IF g_first_retro_event_start IS NOT NULL
878         THEN
879           IF l_element_of_bonus_type = 'Y' AND p_effective_date >= g_first_retro_event_start
880           THEN
881               pqp_gb_psi_functions.process_retro_event(l_include);
882            END IF;
883          END IF;
884 --END For BUG 5998129
885 
886         debug('l_include: '||l_include);
887         debug_exit(l_proc);
888         return l_include;
889     EXCEPTION
890            WHEN others THEN
891                IF SQLCODE <> hr_utility.hr_error_number
892                THEN
893                    debug_others (l_proc, 10);
894                    IF g_debug
895                    THEN
896                      DEBUG (   'Leaving: '
897                             || l_proc, -999);
898                     END IF;
899                     fnd_message.raise_error;
900                 ELSE
901                     RAISE;
902                 END IF;
903     END bonus_periodic_ext_criteria;
904     ---
905     -- ----------------------------------------------------------------------------
906     -- |--------------------< bonus_history_data_ele_val >----------------------|
907     -- Description:
908     -- ----------------------------------------------------------------------------
909     FUNCTION bonus_history_data_ele_val
910                  (
911                  p_ext_user_value     IN VARCHAR2
912                  ,p_output_value       OUT NOCOPY VARCHAR2
913                  ) RETURN NUMBER
914     IS
915         l_proc varchar2(72) := g_package||'.bonus_history_data_ele_val';
916         l_include  NUMBER  :=  0;
917         -- ----------------------------------------------------------------------------
918         -- |---------------------------< get_effective_date >--------------------------|
919         -- Description:
920         -- ----------------------------------------------------------------------------
921         FUNCTION get_effective_date
922                     (
923                     p_output_value       OUT NOCOPY VARCHAR2
924                     )RETURN NUMBER
925         IS
926             l_proc varchar2(72) := g_package||'.get_effective_date';
927             l_date_char     VARCHAR2(20);
928             l_claim_date    DATE;
929             l_return        NUMBER;
930 
931             CURSOR csr_get_claim_date
932             IS
933                SELECT  peev.screen_entry_value
934               FROM pay_element_entry_values_f peev
935                   ,pay_input_values_f piv
936               WHERE peev.element_entry_id = g_curr_element_entry_id
937               AND peev.input_value_id = piv.input_value_id
938               AND UPPER(piv.NAME) = 'CLAIM DATE'
939               --AND peev.effective_start_date = p_effective_date
940               ORDER BY piv.name;
941         BEGIN
942             debug_enter(l_proc);
943 
944             /*IF g_current_layout = 'CUTOVER' THEN
945                 p_output_value  :=  to_char(ben_ext_person.g_element_entry_eff_start_date,'dd/mm/yyyy');
946             ELSE
947                 p_output_value  :=  to_char(g_effective_date,'dd/mm/yyyy');
948             END IF;*/
949 
950             OPEN csr_get_claim_date;
951             FETCH csr_get_claim_date INTO l_date_char;
952             CLOSE csr_get_claim_date;
953 
954             IF l_date_char IS null THEN
955                 -- raise error - no claim date value
956                 l_return :=  PQP_GB_PSI_FUNCTIONS.raise_extract_error
957                                (p_error_number        =>    94683
958                                ,p_error_text          =>    'BEN_94683_BON_NO_CLM_DT_VAL'
959                                ,p_token1              =>
960                                     pqp_gb_psi_functions.g_elements_of_info_type(g_curr_element_type_id).element_name
961                                ,p_token2              =>    to_char(g_effective_date,'dd/mm/yyyy')
962                                );
963             ELSE
964                 --
965                 l_claim_date  :=  fnd_date.canonical_to_date(l_date_char);
966                 IF pqp_gb_psi_functions.is_proper_claim_date
967                             (l_claim_date
968                             ,g_curr_element_type_name
969                             ,g_curr_element_entry_id
970                             ,g_assg_start_date
971                             ) THEN
972                      -- is a proper claim date
973                      debug('the claim date is proper');
974                      p_output_value := to_char(l_claim_date,'dd/mm/yyyy');
975                  ELSE
976                     debug('the claim date is not proper');
977                  END IF;
978             END IF;
979             debug_exit(l_proc);
980             return 0;
981         EXCEPTION
982            WHEN others THEN
983                IF SQLCODE <> hr_utility.hr_error_number
984                THEN
985                    debug_others (l_proc, 10);
986                    IF g_debug
987                    THEN
988                      DEBUG (   'Leaving: '
989                             || l_proc, -999);
990                     END IF;
991                     fnd_message.raise_error;
992                 ELSE
993                     RAISE;
994                 END IF;
995         END get_effective_date;
996         ---
997         -- ----------------------------------------------------------------------------
998         -- |---------------------------< get_bonus_code >--------------------------|
999         -- Description:
1000         -- ----------------------------------------------------------------------------
1001         FUNCTION get_bonus_code
1002                     (
1003                     p_output_value       OUT NOCOPY VARCHAR2
1004                     )RETURN NUMBER
1005         IS
1006             l_proc varchar2(72) := g_package||'.get_bonus_code';
1007             l_return    NUMBER;
1008         BEGIN
1009             debug_enter(l_proc);
1010 
1011             IF PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type.exists(g_curr_element_type_id) THEN
1012                 p_output_value
1013                     :=  PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type(g_curr_element_type_id).eei_information2;
1014             END IF;
1015 
1016             IF NOT pqp_gb_psi_functions.is_alphanumeric(p_output_value) THEN
1017                 -- Bug Fix 5015236
1018                debug('ERROR: the bonus code is non-alphanumeric',20);
1019                l_return :=  PQP_GB_PSI_FUNCTIONS.raise_extract_error
1020                                (p_error_number        =>    94557
1021                                ,p_error_text          =>    'BEN_94557_INVALID_CODE'
1022                                ,p_token1              =>    'Bonus'
1023                                ,p_token2              =>
1024                                     pqp_gb_psi_functions.g_elements_of_info_type(g_curr_element_type_id).element_name
1025                                ,p_token3              =>    p_output_value
1026                                );
1027             END IF;
1028 
1029             debug_exit(l_proc);
1030             return 0;
1031         EXCEPTION
1032            WHEN others THEN
1033                IF SQLCODE <> hr_utility.hr_error_number
1034                THEN
1035                    debug_others (l_proc, 10);
1036                    IF g_debug
1037                    THEN
1038                      DEBUG (   'Leaving: '
1039                             || l_proc, -999);
1040                     END IF;
1041                     fnd_message.raise_error;
1042                 ELSE
1043                     RAISE;
1044                 END IF;
1045         END get_bonus_code;
1046         ---
1047         -- ----------------------------------------------------------------------------
1048         -- |----------------------------< get_bonus_amount >-----------------------------|
1049         -- Description:
1050         -- ----------------------------------------------------------------------------
1051         FUNCTION get_bonus_amount
1052                     (
1053                     p_output_value       OUT NOCOPY VARCHAR2
1054                     )RETURN NUMBER
1055         IS
1056             l_proc varchar2(72) := g_package||'.get_bonus_amount';
1057             l_include  NUMBER  :=  0;
1058             l_bonus_amount  NUMBER;
1059         BEGIN
1060             debug_enter(l_proc);
1061 
1062             l_bonus_amount    :=  pqp_gb_psi_functions.get_element_payment_balance
1063                                                 (p_assignment_id       =>  g_assignment_id
1064                                                  ,p_element_entry_id   =>  g_curr_element_entry_id
1065                                                  ,p_element_type_id    =>  g_curr_element_type_id
1066                                                  ,p_balance_type_id    =>  g_bon_bal_type_id
1067                                                  ,p_effective_date     =>  g_effective_date
1068                                                  );
1069             /*l_bonus_amount  :=  pqp_gb_psi_functions.get_element_payment
1070                                             (p_assignment_id          =>  g_assignment_id
1071                                             ,p_element_entry_id   =>  g_curr_element_entry_id
1072                                             ,p_element_type_id    =>  g_curr_element_type_id
1073                                             ,p_effective_date     =>  g_effective_date
1074                                             );*/
1075             IF l_bonus_amount IS NULL THEN
1076                 -- raise error that the bonus amount is null and value will not be reported.
1077                 debug('ERROR: No Bonus Amount',20);
1078                 l_include :=  PQP_GB_PSI_FUNCTIONS.raise_extract_error
1079                                  (p_error_number        =>    94531
1080                                  ,p_error_text          =>    'BEN_94531_NO_BONUS_AMOUNT'
1081                                  ,p_token1              =>    g_curr_element_type_name
1082                                                                  ||'('||g_curr_element_entry_id||')'
1083                                  ,p_token2              =>    to_char(g_effective_date,'dd/mm/yyyy')
1084                                  );
1085             ELSIF NOT ( l_bonus_amount >= -99999999.99 AND l_bonus_amount <= 999999999.99 ) THEN
1086                 -- raise error that the bonus amount is out of range
1087                 -- bug fix 4998232
1088                 debug('ERROR: Bonus Amount out of range: '||l_bonus_amount,20);
1089                 l_include :=  PQP_GB_PSI_FUNCTIONS.raise_extract_error
1090                                  (p_error_number        =>    94567
1091                                  ,p_error_text          =>    'BEN_94567_INVALID_BONUS_AMOUNT'
1092                                  ,p_token1              =>    g_curr_element_type_name
1093                                                                  ||'('||g_curr_element_entry_id||')'
1094                                  ,p_token2              =>    to_char(g_effective_date,'dd/mm/yyyy')
1095                                  ,p_token3              =>    l_bonus_amount
1096                                  );
1097                p_output_value :=  l_bonus_amount;
1098             ELSE
1099                 -- bug fix 5026913.
1100                 IF l_bonus_amount < 0 THEN
1101                     p_output_value  :=  ltrim(rtrim(to_char(l_bonus_amount,'S09999999D99')));
1102                 ELSE
1103                     p_output_value  :=  ltrim(rtrim(to_char(l_bonus_amount,'099999999D99')));
1104                 END IF;
1105             END IF;
1106 
1107             debug_exit(l_proc);
1108             return l_include;
1109         EXCEPTION
1110            WHEN others THEN
1111                IF SQLCODE <> hr_utility.hr_error_number
1112                THEN
1113                    debug_others (l_proc, 10);
1114                    IF g_debug
1115                    THEN
1116                      DEBUG (   'Leaving: '
1117                             || l_proc, -999);
1118                     END IF;
1119                     fnd_message.raise_error;
1120                 ELSE
1121                     RAISE;
1122                 END IF;
1123         END get_bonus_amount;
1124         ---
1125         -- ----------------------------------------------------------------------------
1126         -- |---------------------------< get_ind_flag >--------------------------|
1127         -- Description:
1128         -- ----------------------------------------------------------------------------
1129         FUNCTION get_ind_flag
1130                     (
1131                     p_output_value       OUT NOCOPY VARCHAR2
1132                     )RETURN NUMBER
1133         IS
1134             l_proc varchar2(72) := g_package||'.get_ind_flag';
1135         BEGIN
1136             debug_enter(l_proc);
1137 
1138             IF PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type.exists(g_curr_element_type_id) THEN
1139                 p_output_value
1140                     :=  PQP_GB_PSI_FUNCTIONS.g_elements_of_info_type(g_curr_element_type_id).eei_information5;
1141             END IF;
1142 
1143             debug_exit(l_proc);
1144             return 0;
1145         EXCEPTION
1146            WHEN others THEN
1147                IF SQLCODE <> hr_utility.hr_error_number
1148                THEN
1149                    debug_others (l_proc, 10);
1150                    IF g_debug
1151                    THEN
1152                      DEBUG (   'Leaving: '
1153                             || l_proc, -999);
1154                     END IF;
1155                     fnd_message.raise_error;
1156                 ELSE
1157                     RAISE;
1158                 END IF;
1159         END get_ind_flag;
1160         ---
1161         -- ----------------------------------------------------------------------------
1162         -- |---------------------------< get_bonus_ee_id >--------------------------|
1163         -- Description:
1164         -- ----------------------------------------------------------------------------
1165         FUNCTION get_bonus_ee_id
1166                     (
1167                     p_output_value       OUT NOCOPY VARCHAR2
1168                     )RETURN NUMBER
1169         IS
1170             l_proc varchar2(72) := g_package||'.get_bonus_ee_id';
1171         BEGIN
1172             debug_enter(l_proc);
1173 
1174             p_output_value :=  g_curr_element_entry_id;
1175 
1176             debug_exit(l_proc);
1177             return 0;
1178         EXCEPTION
1179            WHEN others THEN
1180                IF SQLCODE <> hr_utility.hr_error_number
1181                THEN
1182                    debug_others (l_proc, 10);
1183                    IF g_debug
1184                    THEN
1185                      DEBUG (   'Leaving: '
1186                             || l_proc, -999);
1187                     END IF;
1188                     fnd_message.raise_error;
1189                 ELSE
1190                     RAISE;
1191                 END IF;
1192         END get_bonus_ee_id;
1193         ---
1194     BEGIN  --bonus_history_data_ele_val
1195         debug_enter(l_proc);
1196         debug('p_ext_user_value: '||p_ext_user_value,10);
1197 
1198         IF g_current_layout = 'CUTOVER' THEN
1199             IF p_ext_user_value = 'BonusEffectiveDate' THEN
1200               debug('For Cutover run, for effective date element',20);
1201               IF NOT set_curr_row_values() THEN
1202                 --current event is not accepted
1203                 g_include_current_row :=  FALSE;
1204                 p_output_value  :=  NULL;
1205                 debug('Returning : '||l_include,20);
1206                 debug_exit(l_proc);
1207                 return l_include;
1208             ELSE
1209                 g_include_current_row :=  TRUE;
1210             END IF;
1211 
1212           END IF; --IF p_ext_user_value = 'BonusEffectiveDate'
1213         ELSE
1214             -- for periodic
1215             debug('For Periodic run g_include_current_row is always true.',20);
1216             g_include_current_row :=  TRUE;
1217         END IF;
1218 
1219         IF g_include_current_row THEN
1220           debug('g_include_current_row is true.',20);
1221           IF p_ext_user_value = 'BonusEffectiveDate' THEN
1222              l_include :=  get_effective_date
1223                             (
1224                             p_output_value  =>  p_output_value
1225                             );
1226           ELSIF p_ext_user_value = 'BonusCode' THEN
1227              l_include :=  get_bonus_code
1228                             (
1229                             p_output_value  =>  p_output_value
1230                             );
1231           ELSIF p_ext_user_value = 'BonusAmount' THEN
1232              l_include :=  get_bonus_amount
1233                             (
1234                             p_output_value  =>  p_output_value
1235                             );
1236           ELSIF p_ext_user_value = 'BonusIndFlag' THEN
1237              l_include :=  get_ind_flag
1238                             (
1239                             p_output_value  =>  p_output_value
1240                             );
1241           ELSIF p_ext_user_value = 'BonusEEId' THEN
1242              l_include :=  get_bonus_ee_id
1243                             (
1244                             p_output_value  =>  p_output_value
1245                             );
1246           END IF; -- IF p_ext_user_value =
1247 
1248         ELSE
1249 
1250             debug('g_include_current_row is true.',20);
1251 
1252         END IF; --IF g_include_current_row THEN
1253 
1254         debug('p_output_value : '||p_output_value,10);
1255         debug_exit(l_proc);
1256         return l_include;
1257     EXCEPTION
1258            WHEN others THEN
1259                IF SQLCODE <> hr_utility.hr_error_number
1260                THEN
1261                    debug_others (l_proc, 10);
1262                    IF g_debug
1263                    THEN
1264                      DEBUG (   'Leaving: '
1265                             || l_proc, -999);
1266                     END IF;
1267                     fnd_message.raise_error;
1268                 ELSE
1269                     RAISE;
1270                 END IF;
1271     END bonus_history_data_ele_val;
1272     ---
1273     -- ----------------------------------------------------------------------------
1274     -- |----------------------< bonus_history_post_proc >--------------------------|
1275     --  Description:  This is the post-processing rule  for the BONUS History.
1276     -- ----------------------------------------------------------------------------
1277     FUNCTION bonus_history_post_proc RETURN VARCHAR2
1278     IS
1279         l_proc varchar2(72) := g_package||'.bonus_history_post_proc';
1280     BEGIN
1281         debug_enter(l_proc);
1282 
1283         --Raise extract exceptions which are stored while processing the data elements
1284         --PQP_GB_PSI_FUNCTIONS.raise_extract_exceptions();
1285 
1286         PQP_GB_PSI_FUNCTIONS.common_post_process(g_business_group_id);
1287 
1288         debug_exit(l_proc);
1289         return 'Y';
1290     EXCEPTION
1291            WHEN others THEN
1292                IF SQLCODE <> hr_utility.hr_error_number
1293                THEN
1294                    debug_others (l_proc, 10);
1295                    IF g_debug
1296                    THEN
1297                      DEBUG (   'Leaving: '
1298                             || l_proc, -999);
1299                     END IF;
1300                     fnd_message.raise_error;
1301                 ELSE
1302                     RAISE;
1303                 END IF;
1304     END bonus_history_post_proc;
1305     ------
1306 END PQP_GB_PSI_BON_HISTORY;