DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PREMIUM_PLAN_CONCURRENT

Source


1 package body ben_premium_plan_concurrent as
2 /* $Header: benprplc.pkb 120.0 2005/05/28 09:20:13 appldev noship $ */
3 --
4 /* ============================================================================
5 *    Name
6 *       Premium Process Concurrent Manager Processes for Plan Premiums
7 *
8 *    Purpose
9 *       This package simply houses the concurrent manager and multi-thread
10 *       processes for Premium Calculation.
11 *
12 *    History
13 *      Date        Who        Version    What?
14 *      -------     ---------  -------    --------------------------------------
15 *      01-Nov-99   lmcdonal   115.0      Created
16 *      27-Feb-00   lmcdonal   115.1      Better debug messages.  Also, do not fail
17 *                                        if second of 3 processes finds noone to
18 *                                        process.
19 *      30-Dec-02   mmudigon   115.2      NOCOPY
20 *      03-Dec-04   ikasire    115.3      BUg 4046914
21 * -----------------------------------------------------------------------------
22 */
23 --
24 -- Global cursor and variables declaration
25 --
26 g_package                 varchar2(80) := 'Ben_premium_plan_concurrent';
27 g_persons_processed       number(9) := 0;
28 g_persons_ended           number(9) := 0;
29 g_persons_passed          number(9) := 0;
30 g_persons_errored         number(9) := 0;
31 g_max_errors_allowed      number(9) := 200;
32 --
33 -- ============================================================================
34 --                        << Procedure: Do_Multithread >>
35 --  Description:
36 --      this procedure is called from 'process'.  It calls the premium routine.
37 -- ============================================================================
38 procedure do_multithread
39              (errbuf                     out nocopy varchar2
40              ,retcode                    out nocopy number
41              ,p_validate              in     varchar2 default 'N'
42              ,p_benefit_action_id     in     number
43              ,p_thread_id             in     number
44              ,p_effective_date        in     varchar2
45              ,p_business_group_id     in     number
46              ,p_mo_num                in     number
47              ,p_yr_num                in     number
48              ,p_first_day_of_month    in     varchar2
49              ) is
50  --
51  -- Local variable declaration
52  --
53  l_proc                   varchar2(80) := g_package||'.do_multithread';
54  l_person_id              ben_person_actions.person_id%type;
55  l_person_action_id       ben_person_actions.person_action_id%type;
56  l_object_version_number  ben_person_actions.object_version_number%type;
57  l_ler_id                 ben_person_actions.ler_id%type;
58  l_range_id               ben_batch_ranges.range_id%type;
59  l_record_number          number := 0;
60  l_start_person_action_id number := 0;
61  l_end_person_action_id   number := 0;
62  l_actn                   varchar2(80);
63  l_cnt                    number(5):= 0;
64  l_chunk_size             number(15);
65  l_threads                number(15);
66  l_effective_date         date;
67  l_first_day_of_month     date;
68  --
69  -- Cursors declaration
70  --
71  Cursor c_range_thread is
72    Select ran.range_id
73          ,ran.starting_person_action_id
74          ,ran.ending_person_action_id
75      From ben_batch_ranges ran
76     Where ran.range_status_cd = 'U'
77       And ran.BENEFIT_ACTION_ID  = P_BENEFIT_ACTION_ID
78       And rownum < 2
79       For update of ran.range_status_cd
80          ;
81   Cursor c_person_thread is
82     Select ben.person_id
83           ,ben.person_action_id
84           ,ben.object_version_number
85           ,ben.ler_id
86       From ben_person_actions ben
87      Where ben.benefit_action_id = p_benefit_action_id
88        And ben.action_status_cd <> 'P'
89        And ben.person_action_id between
90               l_start_person_action_id and l_end_person_action_id
91      Order by ben.person_action_id
92           ;
93   Cursor c_parameter is
94     Select *
95       From ben_benefit_actions ben
96      Where ben.benefit_action_id = p_benefit_action_id
97           ;
98   l_parm c_parameter%rowtype;
99   l_ovn                number := null;
100   l_commit number;
101   --
102 Begin
103   --
104   hr_utility.set_location ('Entering '||l_proc,05);
105   --
106   /*
107   l_effective_date:=to_date(p_effective_date,'YYYY/MM/DD HH24:MI:SS');
108   l_effective_date:=to_date(to_char(trunc(l_effective_date),'DD/MM/RRRR'),'DD/MM/RRRR');
109   --
110   l_first_day_of_month:=to_date(p_first_day_of_month,'YYYY/MM/DD HH24:MI:SS');
111   l_first_day_of_month:=to_date(to_char(trunc(l_first_day_of_month),'DD/MM/RRRR'),'DD/MM/RRRR');
112   */
113   l_effective_date := trunc(fnd_date.canonical_to_date(p_effective_date));
114   l_first_day_of_month := trunc(fnd_date.canonical_to_date(p_first_day_of_month));
115   -- Put row in fnd_sessions
116   --
117   dt_fndate.change_ses_date
118       (p_ses_date => l_effective_date,
119        p_commit   => l_commit);
120   --
121   l_actn := 'Calling benutils.get_parameter...';
122   -- ?? couldn't this data be passed in?  potential change to benprcon too.
123   benutils.get_parameter(p_business_group_id  => p_business_group_Id
124                         ,p_batch_exe_cd       => 'BENPRCON'
125                         ,p_threads            => l_threads
126                         ,p_chunk_size         => l_chunk_size
127                         ,p_max_errors         => g_max_errors_allowed);
128   --
129   -- Set up benefits environment
130   --
131   ben_env_object.init(p_business_group_id => p_business_group_id,
132                       p_effective_date    => l_effective_date,
133                       p_thread_id         => p_thread_id,
134                       p_chunk_size        => l_chunk_size,
135                       p_threads           => l_threads,
136                       p_max_errors        => g_max_errors_allowed,
137                       p_benefit_action_id => p_benefit_action_id);
138   --
139   l_actn := 'Calling ben_batch_utils.ini...';
140   ben_batch_utils.ini;
141   --
142   -- Copy benefit action id to global in benutils package
143   --
144   benutils.g_benefit_action_id := p_benefit_action_id;
145   benutils.g_thread_id         := p_thread_id;
146   g_persons_errored            := 0;
147   g_persons_processed              := 0;
148   open c_parameter;
149   fetch c_parameter into l_parm;
150   close c_parameter;
151   --
152   l_actn := 'Calling ben_batch_utils.print_parameters...';
153   --
154   ben_batch_utils.print_parameters
155           (p_thread_id                => p_thread_id
156           ,p_benefit_action_id        => p_benefit_action_id
157           ,p_validate                 => p_validate
158           ,p_business_group_id        => p_business_group_id
159           ,p_effective_date           => l_effective_date
160           ,p_person_id                => null
161           ,p_person_selection_rule_id => null
162           ,p_comp_selection_rule_id   => l_parm.comp_selection_rl
163           ,p_pgm_id                   => l_parm.pgm_id
164           ,p_pl_typ_id                => l_parm.pl_typ_id
165           ,p_pl_id                    => l_parm.pl_id
166           ,p_person_type_id           => l_parm.person_type_id
167           ,p_ler_id                   => null
168           ,p_organization_id          => null
169           ,p_benfts_grp_id            => null
170           ,p_location_id              => null
171           ,p_legal_entity_id          => null
172           ,p_payroll_id               => null
173           );
174   --
175   -- While loop to only try and fetch records while they exist
176   -- we always try and fetch the size of the chunk, if we get less
177   -- then we know that the process is finished so we end the while loop.
178   -- The process is as follows :
179   -- 1) Lock the rows that are not processed
180   -- 2) Grab as many rows as we can upto the chunk size
181   -- 3) Put each row into the person cache.
182   -- 4) Process the person cache
183   -- 5) Go to number 1 again.
184   --
185   hr_utility.set_location('About to Loop for c_range_thread',38);
186 
187   Loop
188     l_actn := 'Opening c_range thread and fetch range...';
189     open c_range_thread;
190     fetch c_range_thread into l_range_id
191                              ,l_start_person_action_id
192                              ,l_end_person_action_id;
193     exit when c_range_thread%notfound;
194     close c_range_thread;
195     If(l_range_id is not NULL) then
196       --
197       l_actn := 'Updating ben_batch_ranges row...';
198       --
199       update ben_batch_ranges ran set ran.range_status_cd = 'P'
200          where ran.range_id = l_range_id;
201       commit;
202     End if;
203     --
204     -- Remove all records from cache
205     --
206 
207     --  ?? why is the cache used here, it's not saving any processing time
208     --
209     l_actn := 'Clearing g_cache_person_process cache...';
210     g_cache_person_process.delete;
211     open c_person_thread;
212     l_record_number := 0;
213     hr_utility.set_location('about to loop for c_person_thread',46);
214     Loop
215       --
216       l_actn := 'Loading premium data into g_cache_person_process cache...';
217       --
218       fetch c_person_thread
219         into g_cache_person_process(l_record_number+1).person_id
220             ,g_cache_person_process(l_record_number+1).person_action_id
221             ,g_cache_person_process(l_record_number+1).object_version_number
222             ,g_cache_person_process(l_record_number+1).ler_id;
223       exit when c_person_thread%notfound;
224       l_record_number := l_record_number + 1;
225     End loop;
226 
227     close c_person_thread;
228 
229     l_actn := 'Preparing to default each participant from cache...' ;
230     If l_record_number > 0 then
231       --
232       -- Process the rows from the person process cache
233       --
234       hr_utility.set_location('about to Loop thru premiums....',50);
235       For l_cnt in 1..l_record_number loop
236         Begin
237           ben_prem_pl_oipl_monthly.main
238             (p_validate              => p_validate
239             ,p_actl_prem_id          => g_cache_person_process(l_cnt).person_id
240             ,p_business_group_id     => p_business_group_id
241             ,p_mo_num                => p_mo_num
242             ,p_yr_num                => p_yr_num
243             ,p_first_day_of_month    => l_first_day_of_month
244             ,p_effective_date        => l_effective_date);
245             -- not the user parms  -- but data about premium.
246 --            ,p_pl_typ_id             => g_cache_person_process(l_cnt).pl_typ_id
247  --           ,p_pl_id                 => g_cache_person_process(l_cnt).pl_id
248   --          ,p_opt_id                => g_cache_person_process(l_cnt).opt_id);
249 
250           g_persons_processed := g_persons_processed + 1;
251         Exception
252           When others then
253               g_persons_errored := g_persons_errored + 1;
254               If (g_persons_errored > g_max_errors_allowed) then
255                   hr_utility.set_location ('Errors received exceeds max allowed',05);
256                   fnd_message.raise_error;
257               End if;
258         End;
259       End loop;
260     Else
261       --
262       l_actn := 'Erroring out nocopy since not person is found in range...' ;
263       hr_utility.set_location ('BEN_92452_PREM_NOT_IN_RNG',05);
264       fnd_message.set_name('BEN','BEN_92452_PREM_NOT_IN_RNG');
265       fnd_message.set_token('PROC', l_proc);
266       fnd_message.raise_error;
267     End if;
268 
269     benutils.write_table_and_file(p_table => TRUE, p_file  => FALSE);
270   End loop;
271 
272   hr_utility.set_location('End of loops',70);
273   benutils.write_table_and_file(p_table => TRUE, p_file  => FALSE);
274   --
275   l_actn := 'Calling Log_statistics...';
276   ben_batch_utils.write_logfile(p_num_pers_processed => g_persons_processed
277                                ,p_num_pers_errored   => g_persons_errored
278                                );
279   hr_utility.set_location ('Leaving '||l_proc,70);
280 Exception
281   When others then
282     ben_batch_utils.rpt_error(p_proc       => l_proc
283                              ,p_last_actn  => l_actn
284                              ,p_rpt_flag   => TRUE
285                              );
286     ben_batch_utils.write_logfile(p_num_pers_processed => g_persons_processed
287                                  ,p_num_pers_errored   => g_persons_errored
288                                  );
289     benutils.write_table_and_file(p_table => TRUE, p_file  => TRUE);
290     hr_utility.set_location ('HR_6153_ALL_PROCEDURE_FAIL',05);
291     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
292     fnd_message.set_token('PROCEDURE', l_proc);
293     fnd_message.set_token('STEP',l_actn );
294     fnd_message.raise_error;
295 End do_multithread;
296 -- *************************************************************************
297 -- *                          << Procedure: Process >>
298 -- *************************************************************************
299 --  This is what is called from the concurrent manager screen
300 --
301 procedure process(errbuf                        out nocopy varchar2
302                  ,retcode                       out nocopy number
303                  ,p_benefit_action_id        in     number   default null
304                  ,p_effective_date           in     varchar2
305                  ,p_validate                 in     varchar2 default 'N'
306                  ,p_business_group_id        in     number
307                  ,p_pgm_id                   in     number   default null
308                  ,p_pl_typ_id                in     number   default null
309                  ,p_pl_id                    in     number   default null
310                  ,p_comp_selection_rule_id   in     number   default null
311                  ,p_debug_messages           in     varchar2 default 'N'
312                  ,p_first_day_of_month       in     varchar2
313                  ,p_mo_num                   in     number
314                  ,p_yr_num                   in     number
315                  ,p_threads            in     number
316                  ,p_chunk_size         in     number
317                  ,p_max_errors         in     number
318                  ,p_restart            in     boolean default FALSE ) is
319   --
320   -- Cursors declaration.
321   --
322 
323   -- Premiums to be processed:
324   cursor c_prems (p_effective_date date) is
325     select apr.actl_prem_id, apr.oipl_id, apr.pl_id
326     from   ben_actl_prem_f apr
327     where  apr.prem_asnmt_cd = 'PROC'  -- ENRT are dealt with in benprprm.pkb
328     and    apr.business_group_id = p_business_group_id
329     and    p_effective_date between
330            apr.effective_start_date and apr.effective_end_date;
331    l_prems c_prems%rowtype;
332 
333   l_pl_typ_id number ;
334   l_pl_id     number ;
335   l_opt_id    number ;
336   l_pgm_id    number ;
337   --
338   -- local variable declaration.
339   --
340   l_effective_date         date;
341   l_first_day_of_month     date;
342   l_request_id             number;
343   l_proc                   varchar2(80) := g_package||'.process';
344   l_benefit_action_id      ben_benefit_actions.benefit_action_id%type;
345   l_object_version_number  ben_benefit_actions.object_version_number%type;
346   l_person_action_id       ben_person_actions.person_action_id%type;
347   l_ler_id                 ben_ler_f.ler_id%type;
348   l_range_id               ben_batch_ranges.range_id%type;
349   l_start_person_action_id number := 0;
350   l_end_person_action_id   number := 0;
351   l_prev_person_id         number := 0;
352   rl_ret                   char(1);
353   skip                     boolean;
354   l_person_cnt             number := 0;
355   l_cnt                    number := 0;
356   l_actn                   varchar2(80);
357   l_num_range              number := 0;
358   l_chunk_num              number := 1;
359   l_num_row                number := 0;
360   l_commit number;
361 
362 Begin
363   hr_utility.set_location ('Entering '||l_proc,10);
364   /*
365   l_effective_date:=to_date(p_effective_date,'YYYY/MM/DD HH24:MI:SS');
366   l_effective_date:=to_date(to_char(trunc(l_effective_date),'DD/MM/RRRR'),'DD/MM/RRRR');
367   --
368   l_first_day_of_month:=to_date(p_first_day_of_month,'YYYY/MM/DD HH24:MI:SS');
369   l_first_day_of_month:=to_date(to_char(trunc(l_first_day_of_month),'DD/MM/RRRR'),'DD/MM/RRRR');
370   */
371   l_effective_date := trunc(fnd_date.canonical_to_date(p_effective_date));
372   l_first_day_of_month := trunc(fnd_date.canonical_to_date(p_first_day_of_month));
373   --
374   --
375   --?? l_actn := 'Initialize the ben_batch_utils cache...';
376   --??   ben_batch_utils.ini;
377   --??   l_actn := 'Initialize the ben_batch_utils cache...';
378   --??   ben_batch_utils.ini(p_actn_cd => 'PROC_INFO');
379   --
380   --
381   -- Create actions if we are not doing a restart.
382   --
383   l_benefit_action_id := p_benefit_action_id;
384 
385   If NOT(p_restart) then
386     hr_utility.set_location('Not a Restart',14);
387     --
388     -- Now lets create person actions for all the people we are going to
389     -- process in the Premium Calculation run.
390     --
391     open c_prems(p_effective_date => l_effective_date);
392     l_person_cnt := 0;
393     l_cnt := 0;
394     l_actn := 'Loading person_actions table..';
395     Loop
396       fetch c_prems into l_prems;
397       Exit when c_prems%notfound;
398       l_cnt := l_cnt + 1;
399       l_actn := 'Calling ben_batch_utils.comp_obj_selection_rule...';
400       hr_utility.set_location('l_actl_prem_id='||to_char(l_prems.actl_prem_id)||
401                 ' l_cnt='||to_char(l_cnt),18);
402       --
403       -- if comp_obj_selection_rule is pass, test rule.
404       -- If the rule return 'N' then
405       -- skip that l_actl_prem_id.
406       --
407       skip := FALSE;
408 
409       -- check criteria that the user entered on the submit form.
410 
411       if p_pl_id is not null or p_pl_typ_id is not null or p_pgm_id is not null
412          or p_comp_selection_rule_id is not null then
413          rl_ret := 'Y';
414          ben_prem_pl_oipl_monthly.get_comp_object_info
415              (p_oipl_id        => l_prems.oipl_id
416              ,p_pl_id          => l_prems.pl_id
417              ,p_pgm_id         => p_pgm_id
418              ,p_effective_date => l_effective_date
419              ,p_out_pgm_id     => l_pgm_id
420              ,p_out_pl_typ_id  => l_pl_typ_id
421              ,p_out_pl_id      => l_pl_id
422              ,p_out_opt_id     => l_opt_id);
423 
424          if p_pl_id is not null and p_pl_id <> l_pl_id then
425                rl_ret := 'N';
426          elsif p_pl_typ_id is not null and p_pl_typ_id <> l_pl_typ_id then
427                rl_ret := 'N';
428          elsif p_pgm_id is not null and p_pgm_id <> l_pgm_id then
429                rl_ret := 'N';
430          elsif rl_ret = 'Y' and p_comp_selection_rule_id is not null then
431             l_actn := 'found a comp object rule...';
432             hr_utility.set_location('found a comp object rule',22);
433             rl_ret:=ben_maintain_designee_elig.comp_selection_rule(
434                 p_person_id                => null -- we have no person_id
435                ,p_business_group_id        => p_business_group_id
436                ,p_pgm_id                   => l_pgm_id
437                ,p_pl_id                    => l_pl_id
438                ,p_pl_typ_id                => l_pl_typ_id
439                ,p_opt_id                   => l_opt_id
440                ,p_oipl_id                  => l_prems.oipl_id
441                ,p_ler_id                   => null -- we have no ler_id
442                ,p_comp_selection_rule_id   => p_comp_selection_rule_id
443                ,p_effective_date           => l_effective_date);
444          end if;
445 
446          If (rl_ret = 'N') then
447             skip := TRUE;
448          End if;
449 
450       end if;
451 
452 
453       --
454       -- Store actl_prem_id into person actions table.
455       --
456       If ( not skip) then
457         hr_utility.set_location('not skip...Inserting Ben_person_actions',28);
458         l_actn := 'Inserting Ben_person_actions...';
459         select ben_person_actions_s.nextval
460         into   l_person_action_id
461         from   sys.dual;
462 
463         insert into ben_person_actions
464               (person_action_id,
465                person_id,
466                ler_id,
467                benefit_action_id,
468                action_status_cd,
469                object_version_number,
470                chunk_number,
471                non_person_cd)
472             values
473               (l_person_action_id,
474                l_prems.actl_prem_id,
475                0,
476                p_benefit_action_id,
477                'U',
478                1,
479                l_chunk_num,
480                'PREM');
481 
482         l_num_row := l_num_row + 1;
483         l_person_cnt := l_person_cnt + 1;
484         l_end_person_action_id := l_person_action_id;
485         If l_num_row = 1 then
486           l_start_person_action_id := l_person_action_id;
487         End if;
488         If l_num_row = p_chunk_size then
489           --
490           -- Create a range of data to be multithreaded.
491           --
492           l_actn := 'Inserting Ben_batch_ranges.......';
493           hr_utility.set_location('Inserting Ben_batch_ranges',32);
494           -- Select next sequence number for the range
495           --
496           select ben_batch_ranges_s.nextval
497           into   l_range_id
498           from   sys.dual;
499 
500           insert into ben_batch_ranges
501             (range_id,
502              benefit_action_id,
503              range_status_cd,
504              starting_person_action_id,
505              ending_person_action_id,
506              object_version_number)
507           values
508             (l_range_id,
509              p_benefit_action_id,
510              'U',
511              l_start_person_action_id,
512              l_end_person_action_id,
513              1);
514           l_start_person_action_id := 0;
515           l_end_person_action_id := 0;
516           l_num_row  := 0;
517           l_num_range := l_num_range + 1;
518           l_chunk_num := l_chunk_num + 1;
519         End if;
520       End if;
521     End loop;
522     Close c_prems;
523     hr_utility.set_location('l_num_row='||to_char(l_num_row),34);
524     If (l_num_row <> 0) then
525       l_actn := 'Inserting Final Ben_batch_ranges...';
526       hr_utility.set_location('Inserting Final Ben_batch_ranges',38);
527 
528           select ben_batch_ranges_s.nextval
529           into   l_range_id
530           from   sys.dual;
531 
532           insert into ben_batch_ranges
533             (range_id,
534              benefit_action_id,
535              range_status_cd,
536              starting_person_action_id,
537              ending_person_action_id,
538              object_version_number)
539           values
540             (l_range_id,
541              p_benefit_action_id,
542              'U',
543              l_start_person_action_id,
544              l_end_person_action_id,
545              1);
546       l_num_range := l_num_range + 1;
547     End if;
548   Else
549     hr_utility.set_location('This is a RESTART',42);
550     l_actn := 'Calling Ben_batch_utils.create_restart_person_actions...';
551     Ben_batch_utils.create_restart_person_actions
552       (p_benefit_action_id  => p_benefit_action_id
553       ,p_effective_date     => l_effective_date
554       ,p_chunk_size         => p_chunk_size
555       ,p_threads            => p_threads
556       ,p_num_ranges         => l_num_range
557       ,p_num_persons        => l_person_cnt
558       ,p_non_person_cd      => 'PREM'
559       );
560   End if;
561   commit;
562   --
563   -- Now to multithread the code.
564   --
565   hr_utility.set_location('l_num_range '||to_char(l_num_range),46);
566   If l_num_range > 1 then
567     For l_count in 1..least(p_threads,l_num_range)-1 loop
568       --
569       l_actn := 'Submitting job to con-current manager...';
570       hr_utility.set_location('Submitting BENPRPLC to con-current manager ',50);
571       -- Conncurrent manage needs the effective date in a varchar form.
572       l_request_id := fnd_request.submit_request
573                         (application => 'BEN'
574                         ,program     => 'BENPRPLC'
575                         ,description => NULL
576                         ,sub_request => FALSE
577                         ,argument1   => p_validate
578                         ,argument2   => l_benefit_action_id
579                         ,argument3   => l_count
580                         ,argument4   => p_effective_date
581                         ,argument5   => p_business_group_id
582                         ,argument6   => p_mo_num
583                         ,argument7   => p_yr_num
584                         ,argument8   => p_first_day_of_month
585                         );
586       --
587       -- Store the request id of the concurrent request
588       --
589       ben_batch_utils.g_num_processes := ben_batch_utils.g_num_processes + 1;
590       ben_batch_utils.g_processes_tbl(ben_batch_utils.g_num_processes)
591         := l_request_id;
592     End loop;
593   Elsif (l_num_range = 0 ) then
594     l_actn := 'Calling Ben_batch_utils.print_parameters...';
595     hr_utility.set_location('Calling Ben_batch_utils.print_parameters ',56);
596     Ben_batch_utils.print_parameters
597       (p_thread_id                => 99
598       ,p_benefit_action_id        => l_benefit_action_id
599       ,p_validate                 => p_validate
600       ,p_business_group_id        => p_business_group_id
601       ,p_effective_date           => l_effective_date
602       ,p_mode                     => null
603       ,p_comp_selection_rule_id   => p_comp_selection_rule_id
604       ,p_pgm_id                   => p_pgm_id
605       ,p_pl_typ_id                => p_pl_typ_id
606       ,p_pl_id                    => p_pl_id
607       ,p_popl_enrt_typ_cycl_id    => null
608       ,p_person_id                => null
609       ,p_person_selection_rule_id => null
610       ,p_person_type_id           => null
611       ,p_ler_id                   => null
612       ,p_organization_id          => null
613       ,p_benfts_grp_id            => null
614       ,p_location_id              => null
615       ,p_legal_entity_id          => null
616       ,p_payroll_id               => null
617       );
618 
619      -- Because there  are other processes to run, do not error if first process finds
620      -- noone to process.
621 
622       Ben_batch_utils.write(p_text =>
623           '<< No Process Premiums were selected with above selection criteria >>' );
624       --fnd_message.set_name('BEN','BEN_92453_NO_PREMS_TO_PROCESS');
625       --fnd_message.raise_error;
626   End if;
627 
628   if (l_num_range <> 0 ) then
629 
630     l_actn := 'Calling do_multithread...';
631     hr_utility.set_location('Calling do_multithread ',60);
632     do_multithread(errbuf               => errbuf
633                 ,retcode              => retcode
634                 ,p_validate           => p_validate
635                 ,p_benefit_action_id  => l_benefit_action_id
636                 ,p_thread_id          => p_threads+1
637                 ,p_effective_date     => p_effective_date
638                 ,p_business_group_id  => p_business_group_id
639                 ,p_mo_num             => p_mo_num
640                 ,p_yr_num             => p_yr_num
641                 ,p_first_day_of_month => p_first_day_of_month
642                 );
643     l_actn := 'Calling ben_batch_utils.check_all_slaves_finished...';
644 
645     hr_utility.set_location('Calling ben_batch_utils.check_all_slaves_finished ',64);
646     ben_batch_utils.check_all_slaves_finished(p_rpt_flag => TRUE);
647     ben_batch_utils.end_process(p_benefit_action_id => l_benefit_action_id
648                              ,p_person_selected   => l_person_cnt
649                              ,p_business_group_id => p_business_group_id
650                              ,p_non_person_cd     => 'PREM');
651   end if;
652   hr_utility.set_location ('Leaving '||l_proc,99);
653 --
654 Exception
655   when others then
656      ben_batch_utils.rpt_error(p_proc      => l_proc
657                               ,p_last_actn => l_actn
658                               ,p_rpt_flag  => TRUE   );
659      --
660      benutils.write(p_text => fnd_message.get);
661      benutils.write(p_text => sqlerrm);
662      benutils.write(p_text => 'Big Error Occured');
663      benutils.write_table_and_file(p_table => TRUE, p_file  => TRUE);
664      If (l_num_range > 0) then
665        ben_batch_utils.check_all_slaves_finished(p_rpt_flag => TRUE);
666        ben_batch_utils.end_process(p_benefit_action_id => l_benefit_action_id
667                                   ,p_person_selected   => l_person_cnt
668                                   ,p_business_group_id => p_business_group_id
669        ) ;
670      End if;
671      hr_utility.set_location ('HR_6153_ALL_PROCEDURE_FAIL',25);
672      fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
673      fnd_message.set_token('PROCEDURE', l_proc);
674      fnd_message.set_token('STEP', l_actn );
675      fnd_message.raise_error;
676 End process;
677 --
678 end ben_premium_plan_concurrent;  -- End of Package.