DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_IREC_ICD_ENRLL_PROCESS

Source


1 Package body PER_IREC_ICD_ENRLL_PROCESS as
2 /* $Header: periricd.pkb 120.15 2007/07/30 14:08:32 gaukumar noship $ */
3 
4 g_package  varchar2(80) := 'PER_IREC_ICD_ENRLL_PROCESS';
5 
6 -- ----------------------------------------------------------------------------
7 -- CURSORS
8 -- ----------------------------------------------------------------------------
9 
10 -- ***************************************************************************
11 -- Cursor to get persons and vacancies in a business group employed in the BG
12 -- and not yet enrolled.
13 -- ***************************************************************************
14 cursor vacancypersonQuery(pBGId in number) is
15   SELECT
16     vac.VACANCY_ID,paaf.person_id,paaf.assignment_id,
17     PIL.PER_IN_LER_ID, PAAF.BUSINESS_GROUP_ID
18   FROM
19     PER_ALL_VACANCIES vac, per_all_assignments_f paaf,
20     BEN_PER_IN_LER pil, ben_ler_f ler
21   WHERE
22     vac.BUSINESS_GROUP_ID = pBGId and
23     paaf.BUSINESS_GROUP_ID = vac.BUSINESS_GROUP_ID and
24     pil.BUSINESS_GROUP_ID = paaf.BUSINESS_GROUP_ID and
25     ler.BUSINESS_GROUP_ID = paaf.BUSINESS_GROUP_ID and
26     paaf.vacancy_id = vac.Vacancy_Id and
27     paaf.assignment_type = 'E' AND
28     paaf.primary_flag='Y' and
29     sysdate BETWEEN paaf.effective_start_date AND paaf.effective_end_date AND
30     NOT EXISTS ( SELECT ben.person_id FROM ben_prtt_enrt_rslt_f ben
31                   where paaf.person_id = ben.person_id) AND
32     ler.typ_cd = 'IREC' AND
33     pil.LF_EVT_OCRD_DT BETWEEN ler.effective_start_date(+) AND ler.effective_end_date(+) and
34     ler.ler_id = pil.ler_id AND
35     pil.person_id=paaf.person_id AND
36     pil.PER_IN_LER_STAT_CD='STRTD' AND
37     pil.assignment_id = paaf.assignment_id
38   order by
39     vac.vacancy_id,paaf.person_id;
40 
41 -- ***************************************************************************
42 -- Cursor to get all persons employed for the vacancy and not yet enrolled
43 -- ***************************************************************************
44 cursor personQuery(pVacancyId in number) is
45   SELECT
46     paaf.person_id, paaf.assignment_id, PIL.PER_IN_LER_ID,
47     PAAF.BUSINESS_GROUP_ID
48   FROM
49     per_all_assignments_f paaf,BEN_PER_IN_LER pil, ben_ler_f ler
50   WHERE
51      pil.BUSINESS_GROUP_ID = paaf.BUSINESS_GROUP_ID and
52      ler.BUSINESS_GROUP_ID = paaf.BUSINESS_GROUP_ID and
53      paaf.vacancy_id = pVacancyId and
54      paaf.assignment_type = 'E' AND
55      paaf.primary_flag='Y' and
56      sysdate BETWEEN paaf.effective_start_date AND paaf.effective_end_date AND
57      NOT EXISTS ( SELECT ben.person_id FROM ben_prtt_enrt_rslt_f ben
58                   where paaf.person_id = ben.person_id) and
59     ler.typ_cd = 'IREC' AND
60     pil.LF_EVT_OCRD_DT BETWEEN ler.effective_start_date(+) AND ler.effective_end_date(+) and
61     ler.ler_id = pil.ler_id AND
62     pil.person_id=paaf.person_id AND
63     pil.PER_IN_LER_STAT_CD='STRTD' AND
64     pil.assignment_id = paaf.assignment_id
65   order by
66     paaf.person_id;
67 
68 -- ***************************************************************************
69 -- Functions to get the names for Person, Vacancy, Business Group
70 -- ***************************************************************************
71 --
72 function get_person_hire_date(p_person_id number)
73 return DATE is
74 --
75 l_dummy DATE;
76 cursor c_person_period_service is
77       select DATE_START
78         from PER_PERIODS_OF_SERVICE
79        where person_id = p_person_id;
80 --
81 begin
82 --
83   open c_person_period_service;
84     fetch c_person_period_service into l_dummy;
85     if c_person_period_service%FOUND then
86       close c_person_period_service;
87       return l_dummy;
88     else
89       close c_person_period_service;
90       return null;
91     end if;
92 --
93 end get_person_hire_date;
94 function get_person_full_name(p_person_id number)
95 return varchar2 is
96 --
97 l_dummy varchar2(240);
98 cursor c_person_name is
99       select full_name
100         from per_all_people_f
101        where person_id = p_person_id
102        AND SYSDATE BETWEEN effective_start_date AND effective_end_date;
103 --
104 begin
105 --
106   open c_person_name;
107     fetch c_person_name into l_dummy;
108     if c_person_name%FOUND then
109       close c_person_name;
110       return l_dummy;
111     else
112       close c_person_name;
113       return '  ';
114     end if;
115 --
116 end get_person_full_name;
117 
118 function get_vacancy_name(p_vacancy_id number)
119 return varchar2 is
120 --
121 l_dummy varchar2(30);
122 cursor c_vacancy_name is
123       select name
124         from per_all_vacancies
125        where vacancy_id = p_vacancy_id;
126 --
127 begin
128 --
129   open c_vacancy_name;
130     fetch c_vacancy_name into l_dummy;
131     if c_vacancy_name%FOUND then
132       close c_vacancy_name;
133       return l_dummy;
134     else
135       close c_vacancy_name;
136       return '  ';
137     end if;
138 --
139 end get_vacancy_name;
140 
141 function get_business_group_name(p_bg_id number)
142 return varchar2 is
143 --
144 l_dummy varchar2(240);
145 cursor c_bg_name is
146   SELECT haou.NAME
147   FROM HR_ORGANIZATION_UNITS haou, HR_ORGANIZATION_INFORMATION haoi
148   WHERE
149     haou.organization_id = haoi.organization_id AND
150     haoi.org_information_context = 'CLASS' AND
151     haoi.org_information1 = 'HR_BG' AND
152     haoi.org_information2 = 'Y' AND
153     not exists (select 1 from HR_ORGANIZATION_INFORMATION haoi2
154       where haou.organization_id=haoi2.organization_id
155       and haoi2.org_information_context='BG Recruitment'
156       and haoi2.org_information9='Y') AND
157     BUSINESS_GROUP_ID=p_bg_id;
158 --
159 begin
160 --
161   open c_bg_name;
162     fetch c_bg_name into l_dummy;
163     if c_bg_name%FOUND then
164       close c_bg_name;
165       return l_dummy;
166     else
167       close c_bg_name;
168       return '  ';
169     end if;
170 --
171 end get_business_group_name;
172 
173 --
174 --
175 -- ----------------------------------------------------------------------------
176 --  is_offer_accepted_or_extended
177 --
178 --
179 -- ----------------------------------------------------------------------------
180 --
181 function is_offer_accepted_or_extended
182             (  pPersonId     in     number
183              , pAssignmentId in     number)
184 return Boolean
185 is
186 --
187   l_proc varchar2(80) default g_package||'.is_offer_accepted_or_extended';
188   l_person_name_with_id varchar2(300);
189   l_description varchar2(500);
190   l_offer_status irc_offer_status_history.offer_status%TYPE;
191   l_change_reason irc_offer_status_history.change_reason%TYPE;
192   l_decline_reason irc_offer_status_history.decline_reason%TYPE;
193   cursor csr_offer_status is
194          select * from(
195          select ofrhis.offer_status, ofrhis.change_reason, ofrhis.decline_reason
196          from irc_offer_status_history ofrhis, irc_offers ofr, per_all_assignments_f paaf
197          where paaf.assignment_id = pAssignmentId and ofr.applicant_assignment_id = paaf.assignment_id
198          and ofrhis.offer_id = ofr.offer_id and ofr.latest_offer='Y'
199          and sysdate between paaf.effective_start_date and paaf.effective_end_date order by status_change_date desc)
200          where rownum<2;
201 --
202 BEGIN
203 --
204   hr_utility.set_location('Entering'||l_proc, 10);
205   l_person_name_with_id:=get_person_full_name(pPersonId)||'(person_id='||pPersonId||')';
206   open  csr_offer_status;
207   fetch csr_offer_status into l_offer_status,
208                               l_change_reason,
209                               l_decline_reason;
210   --
211   if csr_offer_status%notfound then
212     --
213     close csr_offer_status;
214     --
215     return false;
216   else
217     close csr_offer_status;
218 
219 -- check if the offer is in accepted state
220     if (l_offer_status='CLOSED' and l_change_reason='APL_ACCEPTED')
221       or l_offer_status='EXTENDED' THEN
222       return true;
223     end if;
224 
225     fnd_message.set_name('PER','IRC_412236_INV_OFFER_STATUS');
226     fnd_message.set_token('PERSON_NAME',l_person_name_with_id);
227     l_description:=substrb(fnd_message.get,1,500);
228     fnd_message.clear;
229 
230     fnd_file.put_line(fnd_file.log,l_description);
231 --REVIEW : The enrollment process did not run for AAAAAA for the following reason.
232 --         The person did not have an offer extended OR
233 --         The person declined the offer.
234     return false;
235     hr_utility.set_location(' Leaving:'||l_proc, 130);
236   end if;
237 --
238 END is_offer_accepted_or_extended;
239 --
240 --
241 --
242 --
243 -- ----------------------------------------------------------------------------
244 --  is_person_future_terminated
245 --
246 --
247 -- ----------------------------------------------------------------------------
248 --
249 function is_person_future_terminated
250             (  pPersonId     in     number)
251 return Boolean
252 is
253 --
254   l_proc varchar2(80) default g_package||'.is_person_future_terminated';
255   l_person_name varchar2(300);
256   l_description varchar2(500);
257 
258   cursor csr_future_person_rec is
259     SELECT ppf.full_name
260     FROM per_all_people_f ppf
261     WHERE ppf.person_id = pPersonId and
262           ppf.effective_end_date > To_Date('30-12-4712','dd-mm-yyyy') and
263           ppf.current_employee_flag IS null;
264 --
265 BEGIN
266 --
267   hr_utility.set_location('Entering'||l_proc, 10);
268 
269   open  csr_future_person_rec;
270   fetch csr_future_person_rec into l_person_name;
271   --
272   if csr_future_person_rec%notfound then
273     --
274     close csr_future_person_rec;
275     --
276     return false;
277   else
278     close csr_future_person_rec;
279 
280     fnd_message.set_name('PER','IRC_412243_INVALID_PERSON_ID');
281     fnd_message.set_token('PERSON_NAME',l_person_name||'(person_id='||pPersonId||')');
282     l_description:=substrb(fnd_message.get,1,500);
283     fnd_message.clear;
284 
285     fnd_file.put_line(fnd_file.log,l_description);
286     return true;
287   end if;
288 --
289 END is_person_future_terminated;
290 --
291 --
292 --
293 -- ----------------------------------------------------------------------------
294 --  populate_pay_elements
295 --     called from concurrent process to populate Pay Elements :
296 --
297 -- ----------------------------------------------------------------------------
298 --
299 PROCEDURE populate_pay_elements
300             (  errbuf    out nocopy  varchar2
301              , retcode   out nocopy  number
302              , pBgId      in         number
303              , pVacancyid in         number   default null
304              , pPersonId  in         number   default null)
305  is
306 --
307   l_proc               varchar2(80) default g_package||'.populate_pay_elements';
308   l_person_name        varchar2(240);
309   l_vacancy_name       varchar2(30);
310   l_bg_name            varchar2(240);
311   l_description_start  varchar2(500);
312   l_description_end    varchar2(500);
313 --
314 BEGIN
315   hr_utility.set_location('Entering'||l_proc,10);
316   hr_utility.set_location(' Person Id:'||pPersonId||' Vacancy Id:'||pVacancyid||' BusinessGroup Id:'||pBgId, 20);
317 
318   hr_utility.set_location('Calling the CP with UserName:'||fnd_global.user_name||',UserId='||fnd_global.user_id,30);
319   hr_utility.set_location('Responsibility Application Id:'||fnd_global.resp_appl_id||',Responsibility Id:'||fnd_global.resp_id,40);
320   hr_utility.set_location('Security Group Id:'||fnd_global.security_group_id, 50);
321 
322     fnd_message.set_name('PER','IRC_412237_CRT_ENRLM_STRTD');
323     l_description_start:=substrb(fnd_message.get,1,500);
324     fnd_message.clear;
325 
326     fnd_message.set_name('PER','IRC_412238_CRT_ENRLM_CMPLTD');
327     l_description_end:=substrb(fnd_message.get,1,500);
328     fnd_message.clear;
329 
330   if pPersonId is not null THEN
331     l_person_name:=get_person_full_name(pPersonId);
332     l_vacancy_name:=get_vacancy_name(pVacancyid);
333     l_bg_name:=get_business_group_name(pBgId);
334     fnd_file.put_line(fnd_file.log,l_description_start||
335 '
336 Person    :'||l_person_name||
337 '
338 Person Id :'||pPersonId);
339     fnd_file.put_line(fnd_file.log,
340 'Vacancy    :'||l_vacancy_name||
341 '
342 Vacancy Id :'||pVacancyId);
343     fnd_file.put_line(fnd_file.log,
344 'Business Group    :'||l_bg_name||
345 '
346 Business Group Id :'||pBgId);
347     fnd_file.put_line(fnd_file.log,
348 '+---------------------------------------------------------------------------+');
349 --REVIEW: The iRecruitment Create Enrollment process is started.
350 --        Person    : XXXXXX
351 --        Person Id : 121212
352     populate_for_person(errbuf, retcode, pPersonId);
353     fnd_file.put_line(fnd_file.log, l_description_end);
354 --REVIEW: The iRecruitment Create Enrollment process is completed.
355 
356   else
357     if pVacancyid is not null THEN
358       l_vacancy_name:=get_vacancy_name(pVacancyid);
359       l_bg_name:=get_business_group_name(pBgId);
360       fnd_file.put_line(fnd_file.log,l_description_start||
361 '
362 Vacancy    :'||l_vacancy_name||
363 '
364 Vacancy Id :'||pVacancyid);
365       fnd_file.put_line(fnd_file.log,
366 'Business Group    :'||l_bg_name||
367 '
368 Business Group Id :'||pBgId);
369       fnd_file.put_line(fnd_file.log,
370 '+---------------------------------------------------------------------------+');
371       populate_for_vacancy(errbuf, retcode, pVacancyid);
372       fnd_file.put_line(fnd_file.log, l_description_end);
373     else
374       if pBgId is not null THEN
375         l_bg_name:=get_business_group_name(pBgId);
376         fnd_file.put_line(fnd_file.log,l_description_start||
377 '
378 Business Group    :'||l_bg_name||
379 '
380 Business Group Id :'||pBgId);
381     fnd_file.put_line(fnd_file.log,
382 '+---------------------------------------------------------------------------+');
383         populate_for_bg(errbuf, retcode, pBgId);
384         fnd_file.put_line(fnd_file.log, l_description_end);
385       else
386         fnd_message.set_name('PER','HR_289541_PJU_INV_BG_ID');
390   end if;
387         fnd_message.raise_error;
388       end if;
389     end if;
391   hr_utility.set_location('retcode='||retcode||' and errbuf='||errbuf, 60);
392   hr_utility.set_location(' Leaving:'||l_proc, 70);
393 --
394 END populate_Pay_Elements;
395 --
396 
397 --
398 --
399 -- ----------------------------------------------------------------------------
400 --  populate_for_bg
401 --
402 --
403 -- ----------------------------------------------------------------------------
404 --
405 PROCEDURE populate_for_bg
406             (  errbuf    out nocopy varchar2
407              , retcode   out nocopy number
408              , pBgId      in         number)
409 is
410 --
411   l_proc varchar2(80) default    g_package||'.populate_for_bg';
412 --
413 BEGIN
414 --
415   hr_utility.set_location('Entering'||l_proc, 10);
416 for vacancypersonQuery_rec in vacancypersonQuery(pBgId) LOOP
417   fnd_file.put_line(fnd_file.log,
418 '+---------------------------------------------------------------------------+');
419   if is_person_future_terminated(vacancypersonQuery_rec.person_id) then
420     --do not run the process if the person is terminated in future.
421     hr_utility.set_location('Entering'||l_proc, 20);
422   else
423     if is_offer_accepted_or_extended(
424                              vacancypersonQuery_rec.person_id,
425                              vacancypersonQuery_rec.assignment_id)
426     then
427       run_enrollment(errbuf, retcode,
428                      vacancypersonQuery_rec.person_id,
429                      vacancypersonQuery_rec.assignment_id,
430                      vacancypersonQuery_rec.PER_IN_LER_id,
431                      vacancypersonQuery_rec.BUSINESS_GROUP_id);
432     end if;
433   end if;
434   fnd_file.put_line(fnd_file.log,
435 '+---------------------------------------------------------------------------+');
436 end loop;
437   hr_utility.set_location(' Leaving:'||l_proc, 20);
438 --
439 END populate_for_bg;
440 --
441 
442 --
443 --
444 -- ----------------------------------------------------------------------------
445 --  populate_for_vacancy
446 --
447 --
448 -- ----------------------------------------------------------------------------
449 --
450 PROCEDURE populate_for_vacancy
451             (  errbuf    out nocopy varchar2
452              , retcode   out nocopy number
453              , pVacancyId      in         number)
454 is
455 --
456   l_proc varchar2(80) default    g_package||'.populate_for_vacancy';
457 --
458 BEGIN
459 --
460   hr_utility.set_location('Entering'||l_proc, 10);
461 for personQuery_rec in personQuery(pVacancyId) LOOP
462   fnd_file.put_line(fnd_file.log,
463 '+---------------------------------------------------------------------------+');
464 
465   if is_person_future_terminated(personQuery_rec.person_id) then
466     --do not run the process if the person is terminated in future.
467     hr_utility.set_location('Entering'||l_proc, 20);
468   else
469     if is_offer_accepted_or_extended(
470                              personQuery_rec.person_id,
471                              personQuery_rec.assignment_id)
472     then
473       run_enrollment(errbuf, retcode,
474                            personQuery_rec.person_id,
475                            personQuery_rec.assignment_id,
476                            personQuery_rec.PER_IN_LER_id,
477                            personQuery_rec.BUSINESS_GROUP_id);
478     end if;
479   end if;
480   fnd_file.put_line(fnd_file.log,
481 '+---------------------------------------------------------------------------+');
482 
483 end loop;
484 hr_utility.set_location(' Leaving:'||l_proc, 20);
485 --
486 END populate_for_vacancy;
487 --
488 
489 --
490 --
491 -- ----------------------------------------------------------------------------
492 --  populate_for_person
493 --
494 --
495 -- ----------------------------------------------------------------------------
496 --
497 PROCEDURE populate_for_person
498             (  errbuf    out nocopy varchar2
499              , retcode   out nocopy number
500              , pPersonId in         number)
501 is
502 --
503   l_proc varchar2(80) default    g_package||'.populate_for_person';
504   l_assignment_id      number;
505   l_per_in_ler_id      NUMBER;
506   l_business_group_id  NUMBER;
507   l_description        varchar2(500);
508   cursor csr_assignment is
509          select PAAF.assignment_id,PAAF.BUSINESS_GROUP_ID,PIL.PER_IN_LER_ID
510          from per_all_assignments_f PAAF, BEN_PER_IN_LER pil, ben_ler_f ler
511          where PAAF.person_id = pPersonId and PAAF.assignment_type='E' and
512                paaf.primary_flag='Y' and
513                pil.BUSINESS_GROUP_ID = paaf.BUSINESS_GROUP_ID and
514                ler.BUSINESS_GROUP_ID = paaf.BUSINESS_GROUP_ID and
515                SYSDATE BETWEEN PAAF.effective_start_date AND PAAF.effective_end_date AND
516                NOT EXISTS ( SELECT ben.person_id FROM ben_prtt_enrt_rslt_f ben
517                  where paaf.person_id = ben.person_id AND ROWNUM = 1) AND
518                ler.typ_cd = 'IREC' AND
522                pil.assignment_id = paaf.assignment_id;
519                pil.LF_EVT_OCRD_DT BETWEEN ler.effective_start_date(+) AND ler.effective_end_date(+) and
520                ler.ler_id = pil.ler_id AND pil.person_id=paaf.person_id AND
521                pil.PER_IN_LER_STAT_CD='STRTD' AND
523 --
524 BEGIN
525 --
526   hr_utility.set_location('Entering'||l_proc, 10);
527         fnd_file.put_line(fnd_file.log,
528 '+---------------------------------------------------------------------------+');
529 
530   open  csr_assignment;
531   fetch csr_assignment into l_assignment_id,l_business_group_id,l_per_in_ler_id;
532   --
533   if csr_assignment%notfound then
534   --
535     close csr_assignment;
536     fnd_message.set_name('PER','IRC_412239_INV_OFFER_COMP');
537     fnd_message.set_token('PERSON_NAME',get_person_full_name(pPersonId)||'(person_id='||pPersonId||')');
538     l_description:=substrb(fnd_message.get,1,500);
539     fnd_message.clear;
540 
541     fnd_file.put_line(fnd_file.log,l_description);
542     hr_utility.set_location(l_proc,20);
543   --
544   else
545     close csr_assignment;
546 
547     if is_person_future_terminated(pPersonid) then
548       --do not run the process if the person is terminated in future.
549       hr_utility.set_location(l_proc,30);
550     else
551       if is_offer_accepted_or_extended(pPersonid,l_assignment_id) then
552         run_enrollment(errbuf, retcode,
553                      pPersonId,
554                      l_assignment_id,
555                      l_per_in_ler_id,
556                      l_business_group_id);
557       end if;
558     end if;
559   end if;
560   hr_utility.set_location(' Leaving:'||l_proc, 30);
561           fnd_file.put_line(fnd_file.log,
562 '+---------------------------------------------------------------------------+');
563 --
564 END populate_for_person;
565 --
566 
567 --
568 --
569 -- ----------------------------------------------------------------------------
570 --  run_enrollment
571 --
572 --
573 -- ----------------------------------------------------------------------------
574 --
575 PROCEDURE run_enrollment
576             (  errbuf    out nocopy varchar2
577              , retcode   out nocopy number
578              , pPersonId     in     number
579              , pAssignmentId in     number
580              , pPerInLerId   in     number
581              , pBgId         in     number)
582 is
583 --
584 l_person_name          varchar2(240);
585 l_prt_id               number(15);
586 l_person_name_with_id  varchar2(260);
587 l_description          VARCHAR2(500);
588 l_hire_date            DATE;
589 l_proc varchar2(80) default    g_package||'.run_enrollment';
590 cursor c_participation is
591     select prtt_enrt_rslt_id
592     from ben_prtt_enrt_rslt_f
593     where person_id = pPersonId;
594 BEGIN
595 --
596   hr_utility.set_location('Entering '||l_proc, 10);
597   l_person_name_with_id:=get_person_full_name(pPersonId)||'(person_id='||pPersonId||')';
598   l_person_name:=get_person_full_name(pPersonId);
599   l_hire_date:=get_person_hire_date(pPersonId);
600 
601   fnd_message.set_name('PER','IRC_412240_CRT_ENRLM_INITIAT');
602   fnd_message.set_token('PERSON_NAME',l_person_name_with_id);
603   fnd_message.set_token('HIRE_DATE',l_hire_date);
604   l_description:=substrb(fnd_message.get,1,500);
605   fnd_message.clear;
606 
607   fnd_file.put_line(fnd_file.log, l_description);
608 
609   ben_irec_process.create_enrollment_for_irec(
610                                     p_irec_per_in_ler_id  => pPerInLerId
611                                     ,p_person_id          => pPersonId
612                                     ,p_business_group_id  => pBgId
613                                     ,p_effective_date     => l_hire_date);
614   open c_participation;
615   fetch c_participation into l_prt_id;
616 --
617   if c_participation%FOUND then
618 --
619     close c_participation;
620     -- as the life event run is enrolled successfully set the life_run status to PROCD
621     update ben_per_in_ler
622     set per_in_ler_stat_cd = 'PROCD',
623         PROCD_DT           = Trunc(sysdate)
624     where per_in_ler_id    = pPerInLerId;
625     -- issue commit so that data is committed.
626     commit;
627 
628     fnd_message.set_name('PER','IRC_412241_CRT_ENRLM_SUCCESS');
632 
629     fnd_message.set_token('PERSON_NAME',l_person_name);
630     l_description:=substrb(fnd_message.get,1,500);
631     fnd_message.clear;
633     fnd_file.put_line(fnd_file.log, l_description);
634 --
635   else
636 --
637     close c_participation;
638     -- Set the return parameters to indicate failure
639     errbuf:=fnd_message.get;
640 
641     fnd_message.set_name('PER','IRC_412242_CRT_ENRLM_ERRORED');
642     fnd_message.set_token('PERSON_NAME',l_person_name);
643     l_description:=substrb(fnd_message.get,1,500);
644     fnd_message.clear;
645 
646     fnd_file.put_line(fnd_file.log, l_description||
647 '
648 '||errbuf);
649     retcode := 2;
650 --
651   end if;
652 --
653 --
654   hr_utility.set_location('Leaving '||l_proc, 20);
655 EXCEPTION
656 --
657   when others then
658     --
659     hr_utility.set_location(substr(SQLERRM,1,30),1234);
660     hr_utility.set_location(substr(SQLERRM,31,60),1235);
661     hr_utility.set_location(substr(SQLERRM,61,90),1236);
662     hr_utility.set_location(substr(SQLERRM,91,120),1237);
663     errbuf:=fnd_message.get;
664     --
665     -- Set the return parameters to indicate failure
666     --
667     fnd_message.set_name('PER','IRC_412242_CRT_ENRLM_ERRORED');
668     fnd_message.set_token('PERSON_NAME',l_person_name);
669     l_description:=substrb(fnd_message.get,1,500);
670     fnd_message.clear;
671 
672     fnd_file.put_line(fnd_file.log, l_description||
673 '
674 '||errbuf);
675 --REVIEW : The enrollment process errored out for the person XXXXXXX with the following message.
676 --         ERROR :  <TOKEN FOR ERROR MESSAGE>
677 
678     retcode := 2;
679     hr_utility.set_location('Leaving '||l_proc, 30);
680 END run_enrollment;
681 --
682 --
683 END PER_IREC_ICD_ENRLL_PROCESS;