[Home] [Help]
PACKAGE BODY: APPS.HR_CANCEL_HIRE_API
Source
1 Package Body hr_cancel_hire_api as
2 /* $Header: pecahapi.pkb 120.1.12000000.2 2007/04/10 10:25:41 asgugupt ship $ */
3 --
4 -- Package Variables
5 --
6 g_package varchar2(33) := 'hr_cancel_hire_api.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |--------------------------< cancel_hire >---------------------------------|
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 -- Declare cursors and local variables
28 --
29
30 --
31 -- Fetches various person details to call the existing code.
32 --
33 CURSOR csr_get_per_details IS
34 SELECT DISTINCT
35 paa.business_group_id
36 ,pos.period_of_service_id
37 ,pos.date_start
38 FROM per_periods_of_service pos
39 ,per_all_assignments_f paa
40 WHERE paa.person_id = p_person_id
41 AND p_effective_date BETWEEN
42 paa.effective_start_date AND paa.effective_end_date
43 AND paa.person_id = pos.person_id
44 --
45 -- 115.3 (START)
46 --
47 AND pos.date_start IN
48 (SELECT MAX(pos2.date_start)
49 FROM per_periods_of_service pos2
50 WHERE pos2.person_id = p_person_id)
51 --
52 -- 115.3 (END)
53 --
54 AND paa.period_of_service_id = pos.period_of_service_id;
55
56 --bug no 5105026 starts here
57 CURSOR csr_old_prd_srvc IS
58 SELECT DISTINCT
59 paa.business_group_id
60 ,pos.period_of_service_id
61 ,pos.date_start
62 FROM per_periods_of_service pos
63 ,per_all_assignments_f paa
64 WHERE paa.person_id = p_person_id
65 AND p_effective_date BETWEEN
66 paa.effective_start_date AND paa.effective_end_date
67 AND paa.person_id = pos.person_id
68 AND paa.period_of_service_id = pos.period_of_service_id;
69 --bug no 5105026 ends here
70
71 l_proc VARCHAR2(72) := g_package||'cancel_hire';
72 l_system_person_type per_person_types.system_person_type%TYPE;
73 l_business_group_id NUMBER;
74 l_period_of_service_id NUMBER;
75 l_date_start DATE;
76 l_effective_date DATE;
77 l_cancel_type VARCHAR2(10) := 'HIRE';
78 l_where VARCHAR2(30) := 'BEGIN';
79 l_supervisor_warning BOOLEAN := FALSE;
80 l_recruiter_warning BOOLEAN := FALSE;
81 l_event_warning BOOLEAN := FALSE;
82 l_interview_warning BOOLEAN := FALSE;
83 l_review_warning BOOLEAN := FALSE;
84 l_vacancy_warning BOOLEAN := FALSE;
85 l_requisition_warning BOOLEAN := FALSE;
86 l_budget_warning BOOLEAN := FALSE;
87 l_payment_warning BOOLEAN := FALSE;
88
89 --
90 begin
91
92 hr_utility.set_location('Entering:'|| l_proc, 10);
93 --
94 -- Issue a savepoint
95 --
96 savepoint cancel_hire;
97 --
98 -- Truncate the time portion from all IN date parameters
99 --
100 l_effective_date := trunc(p_effective_date);
101 --
102 -- Initialise local variables
103 --
104 OPEN csr_get_per_details;
105 FETCH csr_get_per_details INTO l_business_group_id
106 ,l_period_of_service_id
107 ,l_date_start;
108 CLOSE csr_get_per_details;
109
110 IF l_business_group_id IS NULL
111 OR l_period_of_service_id IS NULL
112 OR l_date_start IS NULL THEN
113 --
114 -- This person does not have a valid period of service.
115 --
116 --bug no 5105026 starts here
117 OPEN csr_old_prd_srvc;
118 FETCH csr_old_prd_srvc INTO l_business_group_id
119 ,l_period_of_service_id
120 ,l_date_start;
121 CLOSE csr_old_prd_srvc;
122 IF l_business_group_id IS NULL
123 OR l_period_of_service_id IS NULL
124 OR l_date_start IS NULL THEN
125
126 fnd_message.set_name('PER','HR_6346_EMP_ASS_NO_POS');
127 fnd_message.raise_error;
128 else
129 hr_utility.set_message(800,'HR_449773_POS_NOT_CRRNT');
130 hr_utility.raise_error;
131 end if;
132 --bug no 5105026 ends here
133 END IF;
134
135 --
136 -- Call Before Process User Hook
137 --
138 begin
139 hr_cancel_hire_bk1.cancel_hire_b
140 (p_person_id => p_person_id
141 ,p_effective_date => l_effective_date
142 );
143 exception
144 when hr_api.cannot_find_prog_unit then
145 hr_api.cannot_find_prog_unit_error
146 (p_module_name => 'cancel_hire'
147 ,p_hook_type => 'BP'
148 );
149 end;
150
151 --
152 -- Lock the appropriate rows.
153 --
154 per_cancel_hire_or_apl_pkg.lock_per_rows
155 (p_person_id => p_person_id
156 ,p_primary_id => l_period_of_service_id
157 ,p_primary_date => l_date_start
158 ,p_business_group_id => l_business_group_id
159 ,p_person_type => 'EMP');
160
161 --
162 -- Validation in addition to Row Handlers. There is one loop
163 -- to the validation server side package per warning.
164 --
165 LOOP
166
167 EXIT WHEN l_where = 'END';
168
169 per_cancel_hire_or_apl_pkg.pre_cancel_checks
170 (
171 p_person_id => p_person_id
172 ,p_where => l_where
173 ,p_business_group_id => l_business_group_id
174 ,p_system_person_type => 'EMP'
175 ,p_primary_id => l_period_of_service_id
176 ,p_primary_date => l_date_start
177 ,p_cancel_type => l_cancel_type
178 );
179
180 IF l_where IN ('SUPERVISOR','RECRUITER','EVENT','INTERVIEW'
181 ,'REVIEW','VACANCY','REQUISITION','BUDGET_VALUE'
182 ,'PAYMENT') THEN
183
184 if l_where = 'SUPERVISOR' then
185 l_supervisor_warning := TRUE;
186 l_where := 'RECRUITER';
187 elsif l_where = 'RECRUITER' then
188 l_recruiter_warning := TRUE;
189 l_where := 'EVENT';
190 elsif l_where = 'EVENT' then
191 l_event_warning := TRUE;
192 l_where := 'INTERVIEW';
193 elsif l_where = 'INTERVIEW' then
194 l_interview_warning := TRUE;
195 l_where := 'REVIEW';
196 elsif l_where = 'REVIEW' then
197 l_review_warning := TRUE;
198 l_where := 'VACANCY';
199 elsif l_where = 'VACANCY' then
200 l_vacancy_warning := TRUE;
201 l_where := 'REQUISITION';
202 elsif l_where = 'REQUISITION' then
203 l_requisition_warning := TRUE;
204 l_where := 'BUDGET_VALUE';
205 elsif l_where = 'BUDGET_VALUE' then
206 l_budget_warning := TRUE;
207 l_where := 'PAYMENT';
208 elsif l_where = 'PAYMENT' then
209 l_payment_warning := TRUE;
210 l_where := 'END';
211 elsif l_where <> 'END' then
212 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
213 fnd_message.set_token('PROCEDURE','cancel_hire',false);
214 fnd_message.set_token('STEP','1');
215 fnd_message.raise_error;
216 end if;
217
218 END IF;
219
220 END LOOP;
221
222 --
223 -- Process Logic. Perform the cancel hire.
224 --
225 per_cancel_hire_or_apl_pkg.do_cancel_hire
226 (
227 p_person_id => p_person_id
228 ,p_date_start => l_date_start
229 ,p_end_of_time => hr_api.g_eot
230 ,p_business_group_id => l_business_group_id
231 ,p_period_of_service_id => l_period_of_service_id
232 );
233 --
234 -- 115.3 (START)
235 --
236 --
237 -- Manage overlapping PDS condition if any
238 --
239 hr_employee_api.manage_rehire_primary_asgs
240 (p_person_id
241 ,l_date_start
242 ,'Y'
243 );
244 --
245 -- 115.3 (END)
246 --
247 --
248 -- Call After Process User Hook
249 --
250 begin
251 hr_cancel_hire_bk1.cancel_hire_a
252 (p_person_id => p_person_id
253 ,p_effective_date => l_effective_date
254 ,p_supervisor_warning => l_supervisor_warning
255 ,p_recruiter_warning => l_recruiter_warning
256 ,p_event_warning => l_event_warning
257 ,p_interview_warning => l_interview_warning
258 ,p_review_warning => l_review_warning
259 ,p_vacancy_warning => l_vacancy_warning
260 ,p_requisition_warning => l_requisition_warning
261 ,p_budget_warning => l_budget_warning
262 ,p_payment_warning => l_payment_warning
263 );
264 exception
265 when hr_api.cannot_find_prog_unit then
266 hr_api.cannot_find_prog_unit_error
267 (p_module_name => 'cancel_hire'
268 ,p_hook_type => 'AP'
269 );
270 end;
271 --
272 -- When in validation only mode raise the Validate_Enabled exception
273 --
274 if p_validate then
275 raise hr_api.validate_enabled;
276 end if;
277 --
278 -- Set all output arguments
279 --
280 p_supervisor_warning := l_supervisor_warning;
281 p_recruiter_warning := l_recruiter_warning;
282 p_event_warning := l_event_warning;
283 p_interview_warning := l_interview_warning;
284 p_review_warning := l_review_warning;
285 p_vacancy_warning := l_vacancy_warning;
286 p_requisition_warning := l_requisition_warning;
287 p_budget_warning := l_budget_warning;
288 p_payment_warning := l_payment_warning;
289
290 hr_utility.set_location(' Leaving:'||l_proc, 70);
291
292 exception
293 when hr_api.validate_enabled then
294 --
295 -- As the Validate_Enabled exception has been raised
296 -- we must rollback to the savepoint
297 --
298 rollback to cancel_hire;
299 --
300 -- Only set output warning arguments
301 -- (Any key or derived arguments must be set to null
302 -- when validation only mode is being used.)
303 --
304 hr_utility.set_location(' Leaving:'||l_proc, 80);
305 when others then
306 --
307 -- A validation or unexpected error has occured
308 --
309 rollback to cancel_hire;
310 hr_utility.set_location(' Leaving:'||l_proc, 90);
311 raise;
312
313 end cancel_hire;
314 --
315 end hr_cancel_hire_api;