DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_CANCEL_HIRE_API

Source


1 Package Body hr_cancel_hire_api as
2 /* $Header: pecahapi.pkb 120.9.12020000.2 2012/07/05 01:37:01 amnaraya ship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := 'hr_cancel_hire_api.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |--------------------------< cancel_hire (overloaded >---------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure cancel_hire
13   (p_validate            IN     BOOLEAN  DEFAULT FALSE
14   ,p_person_id           IN     NUMBER
15   ,p_effective_date      IN     DATE
16   ,p_supervisor_warning     OUT NOCOPY BOOLEAN
17   ,p_recruiter_warning      OUT NOCOPY BOOLEAN
18   ,p_event_warning          OUT NOCOPY BOOLEAN
19   ,p_interview_warning      OUT NOCOPY BOOLEAN
20   ,p_review_warning         OUT NOCOPY BOOLEAN
21   ,p_vacancy_warning        OUT NOCOPY BOOLEAN
22   ,p_requisition_warning    OUT NOCOPY BOOLEAN
23   ,p_budget_warning         OUT NOCOPY BOOLEAN
24   ,p_payment_warning        OUT NOCOPY BOOLEAN
25     ) is
26 
27   l_pay_proposal_warning boolean :=FALSE;
28 
29   begin
30 
31   cancel_hire
32   (p_validate               =>p_validate
33   ,p_person_id              =>p_person_id
34   ,p_effective_date         =>p_effective_date
35   ,p_supervisor_warning     =>p_supervisor_warning
36   ,p_recruiter_warning      =>p_recruiter_warning
37   ,p_event_warning          =>p_event_warning
38   ,p_interview_warning      =>p_interview_warning
39   ,p_review_warning         =>p_review_warning
40   ,p_vacancy_warning        =>p_vacancy_warning
41   ,p_requisition_warning    =>p_requisition_warning
42   ,p_budget_warning         =>p_budget_warning
43   ,p_payment_warning        =>p_payment_warning
44   ,p_pay_proposal_warning  => l_pay_proposal_warning );
45 
46   end ;
47 
48 -- -----------------------------------------------------------------------------
49 -- |--------------------------< cancel_hire >-----------------------------------|
50 -- ------------------------------------------------------------------------------
51 procedure cancel_hire
52   (p_validate            IN     BOOLEAN  DEFAULT FALSE
53   ,p_person_id           IN     NUMBER
54   ,p_effective_date      IN     DATE
55   ,p_supervisor_warning     OUT NOCOPY BOOLEAN
56   ,p_recruiter_warning      OUT NOCOPY BOOLEAN
57   ,p_event_warning          OUT NOCOPY BOOLEAN
58   ,p_interview_warning      OUT NOCOPY BOOLEAN
59   ,p_review_warning         OUT NOCOPY BOOLEAN
60   ,p_vacancy_warning        OUT NOCOPY BOOLEAN
61   ,p_requisition_warning    OUT NOCOPY BOOLEAN
62   ,p_budget_warning         OUT NOCOPY BOOLEAN
63   ,p_payment_warning        OUT NOCOPY BOOLEAN
64    ,p_pay_proposal_warning out nocopy boolean ) is
65   --
66   -- Declare cursors and local variables
67   --
68 
69   --
70   -- Fetches various person details to call the existing code.
71   --
72   CURSOR csr_get_per_details IS
73   SELECT DISTINCT
74          paa.business_group_id
75         ,pos.period_of_service_id
76         ,pos.date_start
77   FROM   per_periods_of_service pos
78         ,per_all_assignments_f paa
79   WHERE  paa.person_id = p_person_id
80   AND    p_effective_date BETWEEN
81          paa.effective_start_date AND paa.effective_end_date
82   AND    paa.person_id = pos.person_id
83 --
84 -- 115.3 (START)
85 --
86   AND    pos.date_start IN
87          (SELECT MAX(pos2.date_start)
88           FROM   per_periods_of_service pos2
89           WHERE  pos2.person_id = p_person_id)
90 --
91 -- 115.3 (END)
92 --
93  AND    paa.period_of_service_id = pos.period_of_service_id;
94 
95  --bug no 5105026 starts here
96    CURSOR csr_old_prd_srvc IS
97    SELECT DISTINCT
98           paa.business_group_id
99          ,pos.period_of_service_id
100          ,pos.date_start
101    FROM   per_periods_of_service pos
102          ,per_all_assignments_f paa
103    WHERE  paa.person_id = p_person_id
104    AND    p_effective_date BETWEEN
105           paa.effective_start_date AND paa.effective_end_date
106    AND    paa.person_id = pos.person_id
107    AND    paa.period_of_service_id = pos.period_of_service_id;
108  --bug no 5105026 ends here
109 
110   l_proc                 VARCHAR2(72) := g_package||'cancel_hire';
111   l_system_person_type   per_person_types.system_person_type%TYPE;
112   l_business_group_id    NUMBER;
113   l_period_of_service_id NUMBER;
114   l_date_start           DATE;
115   l_effective_date       DATE;
116   l_cancel_type          VARCHAR2(10)  :=  'HIRE';
117   l_where                VARCHAR2(30)  :=  'BEGIN';
118   l_supervisor_warning   BOOLEAN       := FALSE;
119   l_recruiter_warning    BOOLEAN       := FALSE;
120   l_event_warning        BOOLEAN       := FALSE;
121   l_interview_warning    BOOLEAN       := FALSE;
122   l_review_warning       BOOLEAN       := FALSE;
123   l_vacancy_warning      BOOLEAN       := FALSE;
124   l_requisition_warning  BOOLEAN       := FALSE;
125   l_budget_warning       BOOLEAN       := FALSE;
126   l_payment_warning      BOOLEAN       := FALSE;
127 
128   --
129 -- fix 7001197
130 
131 cursor csr_emp_apl_chk is
132 
133 select max(effective_start_date)
134 from per_person_type_usages_f ppf1
135 where ppf1.person_id =  p_person_id
136 
137 and ppf1.effective_start_date >
138     ( select max(ppf2.effective_start_date)
139     from per_person_type_usages_f ppf2 , per_person_types ppt2
140     where ppf2.person_id = p_person_id
141          and ppt2.person_type_id= ppf2.person_type_id
142         and ppt2.system_person_type='APL'
143         and ppt2.business_group_id = l_business_group_id )
144 
145 and exists (
146 select '1' from
147 per_person_types ppt
148 where ppt.person_type_id= ppf1.person_type_id
149 and ppt.system_person_type='EX_APL'
150 and ppt.business_group_id = l_business_group_id )
151 
152 and not exists (
153 select '1' from
154 per_person_type_usages_f ppf2
155 where ppf2.person_id = p_person_id
156 and ppf2.effective_start_date > ppf1.effective_start_date
157 and ppf2.person_type_id <> ppf1.person_type_id ); -- fix for 9587362
158 
159 cursor csr_rehired_date is
160 select max(effective_start_date)
161 from per_person_type_usages_f pptf
162 where person_id = p_person_id
163 and exists (
164 select '1' from
165 per_person_types ppt
166 where ppt.person_type_id= pptf.person_type_id
167 and ppt.system_person_type='EMP'
168 and ppt.business_group_id = l_business_group_id );
169 
170 cursor csr_apl_date is
171 select max(effective_start_date)
172 from per_person_type_usages_f pptf
173 where person_id = p_person_id
174 and exists (
175 select '1' from
176 per_person_types ppt
177 where ppt.person_type_id= pptf.person_type_id
178 and ppt.system_person_type='APL'
179 and ppt.business_group_id = l_business_group_id );
180 
181 
182  CURSOR csr_person_types
183     (p_effective_date               IN     DATE
184     ,p_person_id                    IN     NUMBER
185     )
186   IS
187     SELECT typ.system_person_type
188       FROM  per_person_types typ
189           ,per_person_type_usages_f ptu
190      WHERE
191         typ.system_person_type IN ('APL','EMP','EX_APL','EX_EMP','CWK','EX_CWK','OTHER')
192        AND typ.person_type_id = ptu.person_type_id
193        AND p_effective_date BETWEEN ptu.effective_start_date
194                                 AND ptu.effective_end_date
195        AND ptu.person_id = p_person_id
196   ORDER BY DECODE(typ.system_person_type
197                  ,'EMP'   ,1
198                  ,'CWK'   ,2
199                  ,'APL'   ,3
200                  ,'EX_EMP',4
201                  ,'EX_CWK',5
202                  ,'EX_APL',6
203                           ,7
204                  );
205 
206 cursor csr_fut_person_check (l_date date) is
207 select '1'
208 from per_person_type_usages_f where
209 person_id=p_person_id and
210 effective_start_date > l_date;
211 
212 l_efd date :=null;
213 
214   cursor future_pay_proposals is
215   select 'exist'
216   from   per_pay_proposals
217   where  assignment_id  in (
218           select distinct (assignment_id)
219           from per_all_assignments_f
220           where person_id= p_person_id
221           and assignment_type ='E'
222           and l_efd -1 between effective_start_date and effective_end_date
223           and primary_flag='Y'
224           )
225           and change_date >= l_efd;
226 
227 l_last_person_type    VARCHAR2(2000);
228 l_exists varchar2(10) :=null;
229 l_fut_exists varchar2(1);
230 l_rehired_date date;
231 l_apl_date date;
232 l_curr_person_type VARCHAR2(2000):=NULL;
233 
234 --
235 -- fix 7001197
236 --
237 
238 -- code added by sathkris for the bug 8504597 starts here
239 
240 cursor csr_chk_prds_of_ser
241     (p_effective_date               IN     DATE
242     ,p_person_id                    IN     NUMBER
243     ) is
244 select 'X' from
245 per_periods_of_service
246 where person_id = p_person_id
247 and actual_termination_date = p_effective_date;
248 
249 p_ser_dummy varchar2(10);
250 
251 l_lastest_hire_date date; -- added for bug 9879782
252 
253 -- code added by sathkris for the bug 8504597 ends here
254 
255 begin
256 
257   hr_utility.set_location('Entering:'|| l_proc, 10);
258   --
259   -- Issue a savepoint
260   --
261   savepoint cancel_hire;
262   --
263   -- Truncate the time portion from all IN date parameters
264   --
265   l_effective_date := trunc(p_effective_date);
266   --
267   -- Initialise local variables
268   --
269   OPEN  csr_get_per_details;
270   FETCH csr_get_per_details INTO l_business_group_id
271                                 ,l_period_of_service_id
272                                 ,l_date_start;
273   CLOSE csr_get_per_details;
274 
275   -- Start change for bug 9879782
276   open csr_rehired_date;
277   fetch csr_rehired_date into l_lastest_hire_date;
278   close csr_rehired_date;
279   -- End change for bug 9879782
280 
281   IF l_business_group_id IS NULL
282   OR l_period_of_service_id IS NULL
283   OR l_date_start IS NULL THEN
284     --
285     -- This person does not have a valid period of service.
286     --
287  --bug no 5105026 starts here
288 	   OPEN csr_old_prd_srvc;
289 	   FETCH csr_old_prd_srvc INTO l_business_group_id
290 					,l_period_of_service_id
291 					,l_date_start;
292 	  CLOSE csr_old_prd_srvc;
293 	  IF l_business_group_id IS NULL
294 	  OR l_period_of_service_id IS NULL
295 	  OR l_date_start IS NULL THEN
296 
297 		    fnd_message.set_name('PER','HR_6346_EMP_ASS_NO_POS');
298 		    fnd_message.raise_error;
299 	   else
300 		   hr_utility.set_message(800,'HR_449773_POS_NOT_CRRNT');
301 		   hr_utility.raise_error;
302 	   end if;
303 --bug no 5105026 ends here
304   END IF;
305 
306   --
307   -- Call Before Process User Hook
308   --
309   begin
310     hr_cancel_hire_bk1.cancel_hire_b
311       (p_person_id                     => p_person_id
312       ,p_effective_date                => l_effective_date
313       );
314   exception
315     when hr_api.cannot_find_prog_unit then
316       hr_api.cannot_find_prog_unit_error
317         (p_module_name => 'cancel_hire'
318         ,p_hook_type   => 'BP'
319         );
320   end;
321 
322   --
323   -- Lock the appropriate rows.
324   --
325   per_cancel_hire_or_apl_pkg.lock_per_rows
326     (p_person_id           => p_person_id
327     ,p_primary_id          => l_period_of_service_id
328     ,p_primary_date        => l_date_start
329     ,p_business_group_id   => l_business_group_id
330     ,p_person_type         => 'EMP');
331 
332   --
333   -- Validation in addition to Row Handlers. There is one loop
334   -- to the validation server side package per warning.
335   --
336    -- BUG 7001197
337   hr_utility.set_location('cancel_hire '||p_person_id,100);
338   hr_utility.set_location('cancel_hire ||p_effective_date '||p_effective_date,100);
339 
340   open csr_emp_apl_chk ;
341   fetch csr_emp_apl_chk into l_efd;
342     if csr_emp_apl_chk%found and l_efd is not null then
343       close csr_emp_apl_chk;
344 
345       -- this cursor returns when the ex apl was made  and with this date
346       -- we can process with our logic of cancelling the emp_apl hire.
347 
348       if l_efd > p_effective_date then
349       -- user is trying to perform cancel hire before the hire was done
350       -- restricting this so that user changes the date to beyond any future
351       -- Person type changes.
352         hr_utility.set_message(801,'HR_7078_EMP_ENTER_CANCEL_TYPE');
353          hr_utility.raise_error;
354       end if;
355 
356        hr_utility.set_location('cancel_hire || l_efd '||l_efd,101);
357 
358 -- to find out the from which person type the hire was made
359 
360   FOR l_person_type IN csr_person_types
361     (p_effective_date               => l_efd-1
362     ,p_person_id                    => p_person_id
363     )
364   LOOP
365     IF (l_last_person_type IS NULL)
366     THEN
367       l_last_person_type := l_person_type.system_person_type;
368     ELSE
369        -- code added by sathkris for the bug 8504597 starts here
370        -- when cancelled the hire for an employe.exapplicant whose
371        -- previos person type was ex employee revert the previous
372        -- person type to ex employee(since the ex employee record will
373        -- be deleted from the per_person_type_usages_f when
374        -- hiring the applicant on the imm next day of terminating him)
375        -- so person type EX_EMP has been hard coded
376 
377        open csr_chk_prds_of_ser
378       (p_effective_date               => l_efd-1 --p_effective_date
379       ,p_person_id                    => p_person_id
380       );
381       fetch csr_chk_prds_of_ser into p_ser_dummy;
382       if csr_chk_prds_of_ser%found then
383        l_last_person_type := 'EX_EMP'||'_'||l_person_type.system_person_type;
384       close csr_chk_prds_of_ser;
385 
386       else
387 	close csr_chk_prds_of_ser;
388         -- code added by sathkris for the bug 8504597 ends here
389 
390       l_last_person_type := l_last_person_type||'_'||l_person_type.system_person_type;
391 
392       end if;
393     END IF;
394   END LOOP;
395 
396    elsif l_efd is null then
397    -- this case is used to handle the case when the emp.apl is hired
398    -- by retaining one application where he will still be an emp.apl after hire
399    -- so changing the logic accordingly to perfrom the cancel hire
400      close csr_emp_apl_chk;
401 
402  hr_utility.set_location('cancel_hire l_efd is null '||l_efd,104);
403 
404 
405 
406     hr_utility.set_location('cancel_hire l_efd is null '||l_efd,102);
407    open csr_rehired_date;
408    fetch csr_rehired_date into l_rehired_date;
409    close csr_rehired_date;
410 
411 
412     open csr_fut_person_check(p_effective_date);
413     fetch csr_fut_person_check into l_fut_exists;
414     if csr_fut_person_check%found then
415 
416         close csr_fut_person_check;
417           hr_utility.set_location('cancel_hire || l_efd '||l_efd,999);
418     	 hr_utility.set_message(801,'HR_7078_EMP_ENTER_CANCEL_TYPE');
419          hr_utility.raise_error;
420     else
421     	close csr_fut_person_check;
422     end if;
423 
424   l_efd:=l_rehired_date;
425 
426   FOR l_person_type IN csr_person_types
427     (p_effective_date               => l_rehired_date -1 --p_effective_date
428     ,p_person_id                    => p_person_id
429     )
430   LOOP
431     IF (l_last_person_type IS NULL)
432     THEN
433       l_last_person_type := l_person_type.system_person_type;
434     ELSE
435       l_last_person_type := l_last_person_type||'_'||l_person_type.system_person_type;
436     END IF;
437   END LOOP;
438 
439      if l_last_person_type ='EMP_APL' then
440        open csr_apl_date;
441        fetch csr_apl_date into l_apl_date;
442        close csr_apl_date ;
443 
444           if l_apl_date > l_rehired_date then
445 
446             hr_utility.set_message(801,'HR_7078_EMP_ENTER_CANCEL_TYPE');
447             hr_utility.raise_error;
448 
449           end if;
450     end if;
451 
452    end if;
453 
454   -- BUG 7001197
455   if csr_emp_apl_chk%isopen then
456   close  csr_emp_apl_chk;
457   end if;
458 
459   if csr_rehired_date%isopen then
460   close csr_person_types;
461   end if;
462 
463  if csr_fut_person_check%isopen then
464  close csr_person_types;
465  end if;
466 
467  if csr_person_types%isopen then
468  close csr_person_types;
469  end if;
470 
471   hr_utility.set_location('l_last_person_type '||l_last_person_type,101);
472 
473    if l_last_person_type  in ('EMP_APL','EMP_APL_EX_CWK') then
474 
475     --  cancelling back to EMP_APL from EMP_EX-APL
476     -- NEW CODE TO FIX THE BUG 7001197
477 
478 
479    hr_utility.set_location('Perform the checks and cancel the hire ',101);
480 
481     hr_utility.set_location('l_last_person_type '||l_last_person_type,101);
482     hr_utility.set_location('l_date_start '||l_date_start,101);
483     hr_utility.set_location('hr_api.g_eot '||hr_api.g_eot,101);
484     hr_utility.set_location(' l_period_of_service_id '||l_period_of_service_id,101);
485 
486      per_cancel_hire_or_apl_pkg.cancel_emp_apl_hire
487      (
488       p_person_id            =>  p_person_id
489      ,p_date_start           =>  l_efd
490      ,p_end_of_time          =>  hr_api.g_eot
491      ,p_business_group_id    =>  l_business_group_id
492      ,p_period_of_service_id =>  l_period_of_service_id
493       );
494 
495 
496    hr_utility.set_location('after performing cancel hire ',102);
497 
498    -- the foll piece of code is to handle the case
499    -- when any cancel hire returns in data corruption
500    -- the basic intention of the cancel hire is to revert back to
501    -- emp-apl person type . this will handle the case of when the Applicant was terminated
502    -- using End Application from and not through the process of Hiring.
503 
504 
505   FOR l_person_type IN csr_person_types
506     (p_effective_date               => p_effective_date
507     ,p_person_id                    => p_person_id
508     )
509   LOOP
510     IF (l_curr_person_type IS NULL)
511     THEN
512       l_curr_person_type := l_person_type.system_person_type;
513     ELSE
514       l_curr_person_type := l_curr_person_type||'_'||l_person_type.system_person_type;
515     END IF;
516   END LOOP;
517 
518    hr_utility.set_location('after performing cancel hire ',103);
519    hr_utility.set_location('l_curr_person_type '||l_curr_person_type,102);
520 
521    if l_curr_person_type  not in ('EMP_APL','EMP_APL_EX_CWK') then
522 
523              hr_utility.set_location('raise the error',102);
524             hr_utility.set_message(801,'HR_7078_EMP_ENTER_CANCEL_TYPE');
525             hr_utility.raise_error;
526 
527    end if;
528 
529   open future_pay_proposals;
530   fetch future_pay_proposals into l_exists;
531   close future_pay_proposals;
532 
533   if l_exists is not null then
534 
535   p_pay_proposal_warning :=TRUE;
536 
537   end if;
538 
539 --
540 --
541 
542   ELSE
543   -- existing CODE which takes care if not cancelling an emp_apl hire.
544   LOOP
545 
546     EXIT WHEN l_where = 'END';
547 
548     per_cancel_hire_or_apl_pkg.pre_cancel_checks
549       (
550        p_person_id           =>  p_person_id
551       ,p_where               =>  l_where
552       ,p_business_group_id   =>  l_business_group_id
553       ,p_system_person_type  =>  'EMP'
554       ,p_primary_id          =>  l_period_of_service_id
555       ,p_primary_date        =>  l_date_start
556       ,p_cancel_type         =>  l_cancel_type
557       );
558 
559     IF l_where IN ('SUPERVISOR','RECRUITER','EVENT','INTERVIEW'
560                   ,'REVIEW','VACANCY','REQUISITION','BUDGET_VALUE'
561                   ,'PAYMENT') THEN
562 
563       if l_where = 'SUPERVISOR' then
564         l_supervisor_warning := TRUE;
565         l_where := 'RECRUITER';
566       elsif l_where = 'RECRUITER' then
567         l_recruiter_warning := TRUE;
568         l_where := 'EVENT';
569       elsif l_where = 'EVENT' then
570         l_event_warning := TRUE;
571         l_where := 'INTERVIEW';
572       elsif l_where = 'INTERVIEW' then
573         l_interview_warning := TRUE;
574         l_where := 'REVIEW';
575       elsif l_where = 'REVIEW' then
576         l_review_warning := TRUE;
577         l_where := 'VACANCY';
578       elsif l_where = 'VACANCY' then
579         l_vacancy_warning := TRUE;
580         l_where := 'REQUISITION';
581       elsif l_where = 'REQUISITION' then
582         l_requisition_warning := TRUE;
583         l_where := 'BUDGET_VALUE';
584       elsif l_where = 'BUDGET_VALUE' then
585         l_budget_warning := TRUE;
586         l_where := 'PAYMENT';
587       elsif l_where = 'PAYMENT' then
588         l_payment_warning := TRUE;
589         l_where := 'END';
590       elsif l_where <> 'END' then
591         fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
592         fnd_message.set_token('PROCEDURE','cancel_hire',false);
593         fnd_message.set_token('STEP','1');
594         fnd_message.raise_error;
595       end if;
596 
597     END IF;
598 
599   END LOOP;
600 
601   --
602   -- Process Logic. Perform the cancel hire.
603   --
604 
605   per_cancel_hire_or_apl_pkg.do_cancel_hire
606     (
607      p_person_id            =>  p_person_id
608     ,p_date_start           =>  l_date_start
609     ,p_end_of_time          =>  hr_api.g_eot
610     ,p_business_group_id    =>  l_business_group_id
611     ,p_period_of_service_id =>  l_period_of_service_id
612     );
613 
614 END IF; --BUG 7001197
615 -- BUG 7001197
616 --
617 -- 115.3 (START)
618   --
619   -- Manage overlapping PDS condition if any
620   --
621   hr_employee_api.manage_rehire_primary_asgs
622     (p_person_id
623     ,l_date_start
624     ,'Y'
625     );
626 --
627 -- 115.3 (END)
628 --
629    -- Start changes for bug 9879782
630 
631    hr_utility.set_location(' l_lastest_hire_date:'||l_lastest_hire_date, 79);
632    per_fnd_attachment_pkg.adjust_irec_docs (
633                             p_person_id            => p_person_id,
634                             p_assignment_id        => null,
635                             p_application_id       => null,
636                             p_old_hire_date        => l_lastest_hire_date,
637                             p_hire_date            => l_lastest_hire_date,
638                             p_transaction_type     => 'COREHR',
639                             p_transaction_status   => 'COMPLETE',
640                             p_status               => 'I',
641                             p_adjustment_type      => 'DELETE');
642   -- End changes for bug 9879782
643   --
644   -- Call After Process User Hook
645   --
646   begin
647     hr_cancel_hire_bk1.cancel_hire_a
648       (p_person_id                     => p_person_id
649       ,p_effective_date                => l_effective_date
650       ,p_supervisor_warning            => l_supervisor_warning
651       ,p_recruiter_warning             => l_recruiter_warning
652       ,p_event_warning                 => l_event_warning
653       ,p_interview_warning             => l_interview_warning
654       ,p_review_warning                => l_review_warning
655       ,p_vacancy_warning               => l_vacancy_warning
656       ,p_requisition_warning           => l_requisition_warning
657       ,p_budget_warning                => l_budget_warning
658       ,p_payment_warning               => l_payment_warning
659       );
660   exception
661     when hr_api.cannot_find_prog_unit then
662       hr_api.cannot_find_prog_unit_error
663         (p_module_name => 'cancel_hire'
664         ,p_hook_type   => 'AP'
665         );
666   end;
667   --
668   -- When in validation only mode raise the Validate_Enabled exception
669   --
670   if p_validate then
671     raise hr_api.validate_enabled;
672   end if;
673   --
674   -- Set all output arguments
675   --
676   p_supervisor_warning  := l_supervisor_warning;
677   p_recruiter_warning   := l_recruiter_warning;
678   p_event_warning       := l_event_warning;
679   p_interview_warning   := l_interview_warning;
680   p_review_warning      := l_review_warning;
681   p_vacancy_warning     := l_vacancy_warning;
682   p_requisition_warning := l_requisition_warning;
683   p_budget_warning      := l_budget_warning;
684   p_payment_warning     := l_payment_warning;
685 
686   hr_utility.set_location(' Leaving:'||l_proc, 70);
687 
688 exception
689   when hr_api.validate_enabled then
690     --
691     -- As the Validate_Enabled exception has been raised
692     -- we must rollback to the savepoint
693     --
694     rollback to cancel_hire;
695     --
696     -- Only set output warning arguments
697     -- (Any key or derived arguments must be set to null
698     -- when validation only mode is being used.)
699     --
700     hr_utility.set_location(' Leaving:'||l_proc, 80);
701   when others then
702     --
703     -- A validation or unexpected error has occured
704     --
705     rollback to cancel_hire;
706     hr_utility.set_location(' Leaving:'||l_proc, 90);
707     raise;
708 
709 end cancel_hire;
710 --
711 end hr_cancel_hire_api;