[Home] [Help]
PACKAGE BODY: APPS.HR_PERSON_TYPE_USAGE_API
Source
1 Package Body hr_person_type_usage_api as
2 /* $Header: peptuapi.pkb 120.0 2005/05/31 15:53:03 appldev noship $ */
3 --
4 -- Package Variables
5 --
6 g_package varchar2(33) := ' per_person_type_usage_api.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |------------------------< update_person_type_usage >--- ------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure update_person_type_usage
13 (p_validate in boolean default false
14 ,p_person_type_usage_id in number
15 ,p_effective_date in date
16 ,p_datetrack_mode in varchar2
17 ,p_object_version_number in out nocopy number
18 ,p_person_type_id in number default hr_api.g_number
19 ,p_attribute_category in varchar2 default hr_api.g_varchar2
20 ,p_attribute1 in varchar2 default hr_api.g_varchar2
21 ,p_attribute2 in varchar2 default hr_api.g_varchar2
22 ,p_attribute3 in varchar2 default hr_api.g_varchar2
23 ,p_attribute4 in varchar2 default hr_api.g_varchar2
24 ,p_attribute5 in varchar2 default hr_api.g_varchar2
25 ,p_attribute6 in varchar2 default hr_api.g_varchar2
26 ,p_attribute7 in varchar2 default hr_api.g_varchar2
27 ,p_attribute8 in varchar2 default hr_api.g_varchar2
28 ,p_attribute9 in varchar2 default hr_api.g_varchar2
29 ,p_attribute10 in varchar2 default hr_api.g_varchar2
30 ,p_attribute11 in varchar2 default hr_api.g_varchar2
31 ,p_attribute12 in varchar2 default hr_api.g_varchar2
32 ,p_attribute13 in varchar2 default hr_api.g_varchar2
33 ,p_attribute14 in varchar2 default hr_api.g_varchar2
34 ,p_attribute15 in varchar2 default hr_api.g_varchar2
35 ,p_attribute16 in varchar2 default hr_api.g_varchar2
36 ,p_attribute17 in varchar2 default hr_api.g_varchar2
37 ,p_attribute18 in varchar2 default hr_api.g_varchar2
38 ,p_attribute19 in varchar2 default hr_api.g_varchar2
39 ,p_attribute20 in varchar2 default hr_api.g_varchar2
40 ,p_attribute21 in varchar2 default hr_api.g_varchar2
41 ,p_attribute22 in varchar2 default hr_api.g_varchar2
42 ,p_attribute23 in varchar2 default hr_api.g_varchar2
43 ,p_attribute24 in varchar2 default hr_api.g_varchar2
44 ,p_attribute25 in varchar2 default hr_api.g_varchar2
45 ,p_attribute26 in varchar2 default hr_api.g_varchar2
46 ,p_attribute27 in varchar2 default hr_api.g_varchar2
47 ,p_attribute28 in varchar2 default hr_api.g_varchar2
48 ,p_attribute29 in varchar2 default hr_api.g_varchar2
49 ,p_attribute30 in varchar2 default hr_api.g_varchar2
50 ,p_effective_start_date out nocopy date
51 ,p_effective_end_date out nocopy date
52 ) is
53 --
54 -- Declare cursors and local variables
55 --
56 l_proc varchar2(72) := g_package||'update_person_type_usage';
57 l_object_version_number per_person_type_usages_f.object_version_number%TYPE;
58 l_effective_start_date per_person_type_usages_f.effective_start_date%TYPE;
59 l_effective_end_date per_person_type_usages_f.effective_end_date%TYPE;
60 l_effective_date date;
61 --
62 begin
63 --
64 hr_utility.set_location('Entering:'|| l_proc, 10);
65 --
66 -- Issue a savepoint if operating in validation only mode
67 --
68 if p_validate then
69 savepoint update_person_type_usage;
70 end if;
71 --
72 hr_utility.set_location(l_proc, 20);
73 --
74 -- Process Logic
75 --
76 l_object_version_number := p_object_version_number;
77 l_effective_date := trunc(p_effective_date);
78 --
79 begin
80 --
81 -- Start of API User Hook for the before hook of update_person_type_usage
82 --
83 hr_person_type_usage_bk1.update_person_type_usage_b
84 (
85 p_person_type_usage_id => p_person_type_usage_id
86 ,p_object_version_number => p_object_version_number
87 ,p_attribute_category => p_attribute_category
88 ,p_attribute1 => p_attribute1
89 ,p_attribute2 => p_attribute2
90 ,p_attribute3 => p_attribute3
91 ,p_attribute4 => p_attribute4
92 ,p_attribute5 => p_attribute5
93 ,p_attribute6 => p_attribute6
94 ,p_attribute7 => p_attribute7
95 ,p_attribute8 => p_attribute8
96 ,p_attribute9 => p_attribute9
97 ,p_attribute10 => p_attribute10
98 ,p_attribute11 => p_attribute11
99 ,p_attribute12 => p_attribute12
100 ,p_attribute13 => p_attribute13
101 ,p_attribute14 => p_attribute14
102 ,p_attribute15 => p_attribute15
103 ,p_attribute16 => p_attribute16
104 ,p_attribute17 => p_attribute17
105 ,p_attribute18 => p_attribute18
106 ,p_attribute19 => p_attribute19
107 ,p_attribute20 => p_attribute20
108 ,p_attribute21 => p_attribute21
109 ,p_attribute22 => p_attribute22
110 ,p_attribute23 => p_attribute23
111 ,p_attribute24 => p_attribute24
112 ,p_attribute25 => p_attribute25
113 ,p_attribute26 => p_attribute26
114 ,p_attribute27 => p_attribute27
115 ,p_attribute28 => p_attribute28
116 ,p_attribute29 => p_attribute29
117 ,p_attribute30 => p_attribute30
118 ,p_effective_date => l_effective_date
119 ,p_datetrack_mode => p_datetrack_mode
120 );
121 exception
122 when hr_api.cannot_find_prog_unit then
123 hr_api.cannot_find_prog_unit_error
124 (p_module_name => 'UPDATE_person_type_usage'
125 ,p_hook_type => 'BP'
126 );
127 --
128 -- End of API User Hook for the before hook of update_person_type_usage
129 --
130 end;
131 --
132 -- For first release, datetrack update mode must be 'CORRECTION'
133 -- Commented as part of PTU changes
134 -- if ( p_datetrack_mode <> 'CORRECTION') then
135 -- hr_utility.set_message(801, 'HR_52363_PTU_INV_DT_UPD_MODE');
136 -- hr_utility.raise_error;
137 -- end if;
138 --
139 --
140 per_ptu_upd.upd
141 (
142 p_person_type_usage_id => p_person_type_usage_id
143 ,p_person_type_id => p_person_type_id
144 ,p_effective_start_date => l_effective_start_date
145 ,p_effective_end_date => l_effective_end_date
146 ,p_object_version_number => l_object_version_number
147 ,p_attribute_category => p_attribute_category
148 ,p_attribute1 => p_attribute1
149 ,p_attribute2 => p_attribute2
150 ,p_attribute3 => p_attribute3
151 ,p_attribute4 => p_attribute4
152 ,p_attribute5 => p_attribute5
153 ,p_attribute6 => p_attribute6
154 ,p_attribute7 => p_attribute7
155 ,p_attribute8 => p_attribute8
156 ,p_attribute9 => p_attribute9
157 ,p_attribute10 => p_attribute10
158 ,p_attribute11 => p_attribute11
159 ,p_attribute12 => p_attribute12
160 ,p_attribute13 => p_attribute13
161 ,p_attribute14 => p_attribute14
162 ,p_attribute15 => p_attribute15
163 ,p_attribute16 => p_attribute16
164 ,p_attribute17 => p_attribute17
165 ,p_attribute18 => p_attribute18
166 ,p_attribute19 => p_attribute19
167 ,p_attribute20 => p_attribute20
168 ,p_attribute21 => p_attribute21
169 ,p_attribute22 => p_attribute22
170 ,p_attribute23 => p_attribute23
171 ,p_attribute24 => p_attribute24
172 ,p_attribute25 => p_attribute25
173 ,p_attribute26 => p_attribute26
174 ,p_attribute27 => p_attribute27
175 ,p_attribute28 => p_attribute28
176 ,p_attribute29 => p_attribute29
177 ,p_attribute30 => p_attribute30
178 ,p_effective_date => l_effective_date
179 ,p_datetrack_mode => p_datetrack_mode
180 );
181 --
182 begin
183 --
184 -- Start of API User Hook for the after hook of update_person_type_usage
185 --
186 hr_person_type_usage_bk1.update_person_type_usage_a
187 (
188 p_person_type_usage_id => p_person_type_usage_id
189 ,p_effective_start_date => l_effective_start_date
190 ,p_effective_end_date => l_effective_end_date
191 ,p_object_version_number => l_object_version_number
192 ,p_attribute_category => p_attribute_category
193 ,p_attribute1 => p_attribute1
194 ,p_attribute2 => p_attribute2
195 ,p_attribute3 => p_attribute3
196 ,p_attribute4 => p_attribute4
197 ,p_attribute5 => p_attribute5
198 ,p_attribute6 => p_attribute6
199 ,p_attribute7 => p_attribute7
200 ,p_attribute8 => p_attribute8
201 ,p_attribute9 => p_attribute9
202 ,p_attribute10 => p_attribute10
203 ,p_attribute11 => p_attribute11
204 ,p_attribute12 => p_attribute12
205 ,p_attribute13 => p_attribute13
206 ,p_attribute14 => p_attribute14
207 ,p_attribute15 => p_attribute15
208 ,p_attribute16 => p_attribute16
209 ,p_attribute17 => p_attribute17
210 ,p_attribute18 => p_attribute18
211 ,p_attribute19 => p_attribute19
212 ,p_attribute20 => p_attribute20
213 ,p_attribute21 => p_attribute21
214 ,p_attribute22 => p_attribute22
215 ,p_attribute23 => p_attribute23
216 ,p_attribute24 => p_attribute24
217 ,p_attribute25 => p_attribute25
218 ,p_attribute26 => p_attribute26
219 ,p_attribute27 => p_attribute27
220 ,p_attribute28 => p_attribute28
221 ,p_attribute29 => p_attribute29
222 ,p_attribute30 => p_attribute30
223 ,p_effective_date => l_effective_date
224 ,p_datetrack_mode => p_datetrack_mode
225 );
226 exception
227 when hr_api.cannot_find_prog_unit then
228 hr_api.cannot_find_prog_unit_error
229 (p_module_name => 'UPDATE_person_type_usage'
230 ,p_hook_type => 'AP'
231 );
232 --
233 -- End of API User Hook for the after hook of update_person_type_usage
234 --
235 end;
236 --
237 hr_utility.set_location(l_proc, 60);
238 --
239 -- When in validation only mode raise the Validate_Enabled exception
240 --
241 if p_validate then
242 raise hr_api.validate_enabled;
243 end if;
244 --
245 -- Set all output arguments
246 --
247 p_object_version_number := l_object_version_number;
248 p_effective_start_date := l_effective_start_date;
249 p_effective_end_date := l_effective_end_date;
250 --
251 hr_utility.set_location(' Leaving:'||l_proc, 70);
252 --
253 exception
254 --
255 when hr_api.validate_enabled then
256 --
257 -- As the Validate_Enabled exception has been raised
258 -- we must rollback to the savepoint
259 --
260 ROLLBACK TO update_person_type_usage;
261 --
262 -- Only set output warning arguments
263 -- (Any key or derived arguments must be set to null
264 -- when validation only mode is being used.)
265 --
266 hr_utility.set_location(' Leaving:'||l_proc, 80);
267 --
268 end update_person_type_usage;
269 -- ----------------------------------------------------------------------------
270 -- |------------------------< check_person_type >-----------------------------|
271 -- ----------------------------------------------------------------------------
272 function check_person_type
273 (
274 p_person_id in number
275 ,p_effective_date in date
276 ,p_person_type in varchar2
277 ) return boolean is
278 --
279 -- Declare cursors and local variables
280 --
281 l_proc varchar2(72) := g_package||'check_per_type_on_specific_day';
282 l_result varchar2(4);
283 l_temp_type per_person_types.system_person_type%type;
284 l_temp_id number;
285 --
286 cursor check_person_type is
287 select system_person_type
288 from per_person_types ppt
289 where p_person_type = system_person_type;
290 --
291 cursor check_person_id is
292 select person_id
293 from per_all_people_f
294 where person_id = p_person_id;
295 --
296 cursor current_person_type is
297 select 'Y'
298 from per_person_types ppt,
299 per_person_type_usages_f ptu
300 where ptu.person_id = p_person_id
301 and ptu.effective_start_date <= p_effective_date
302 and ptu.effective_end_date >= p_effective_date
303 and ptu.person_type_id = ppt.person_type_id
304 and ppt.system_person_type = p_person_type;
305
306 begin
307 --
308 hr_utility.set_location('Entering:'|| l_proc, 5);
309 --
310 -- Check that the person type is valid.
311 --
312 open check_person_type;
313 fetch check_person_type into l_temp_type;
314 if check_person_type%notfound then
315 close check_person_type;
316 hr_utility.set_message(801, 'HR_52366_PTU_INV_PERSON_TYPE');
317 hr_utility.raise_error;
318 end if;
319 --
320 close check_person_type;
321 --
322 -- Check that the type passed in isn't an 'EX' type or a combination of
323 -- old types
324 --
325 if ( p_person_type = 'EX_EMP' or
326 p_person_type = 'EX_APL' or
327 p_person_type = 'EMP_APL' or
328 p_person_type = 'EX_EMP_APL' or
329 p_person_type = 'APL_EX_APL') then
330 hr_utility.set_message(801, 'HR_52366_PTU_INV_PERSON_TYPE');
331 hr_utility.raise_error;
332 end if;
333 --
334 --
335 -- Check that the person id is valid.
336 --
337 open check_person_id;
338 fetch check_person_id into l_temp_id;
339 if check_person_id%notfound then
340 close check_person_id;
341 hr_utility.set_message(801, 'HR_52365_PTU_NO_PERSON_EXISTS');
342 hr_utility.raise_error;
343 end if;
344 --
345 close check_person_id;
346 --
347 open current_person_type;
348 fetch current_person_type into l_result;
349 if current_person_type%found then
350 close current_person_type;
351 hr_utility.set_location('Leaving:'|| l_proc, 10);
352 return TRUE;
353 end if;
354 --
355 close current_person_type;
356 --
357 hr_utility.set_location('Leaving:'|| l_proc, 20);
358 --
359 return FALSE;
360 --
361 end check_person_type;
362 --
363 -- ----------------------------------------------------------------------------
364 -- |------------------------< check_person_ex_type >--------------------------|
365 -- ----------------------------------------------------------------------------
366 function check_person_ex_type
367 (
368 p_person_id in number
369 ,p_effective_date in date
370 ,p_person_type in varchar2
371 ) return boolean is
372 --
373 -- Declare cursors and local variables
374 --
375 cursor check_person_type is
376 select system_person_type
377 from per_person_types ppt
378 where p_person_type = system_person_type;
379 --
380 cursor check_person_id is
381 select person_id
382 from per_all_people_f
383 where person_id = p_person_id;
384 --
385 cursor check_person_ex_type is
386 select 'Y'
387 from per_person_types ppt,
388 per_person_type_usages_f ptu
389 where ptu.person_id = p_person_id
390 and ppt.system_person_type = p_person_type
391 and ptu.effective_end_date < p_effective_date
392 and ptu.person_type_id = ppt.person_type_id
393 and not exists (select 'Y' from per_person_types ppt1,
394 per_person_type_usages_f ptu1
395 where ptu1.person_id = p_person_id
396 and ppt1.system_person_type = p_person_type
397 and ptu1.effective_end_date >= p_effective_date
398 and ptu1.effective_start_date <= p_effective_date
399 and ptu1.person_type_id = ppt1.person_type_id);
400 --
401 --
402 l_proc varchar2(72) := g_package||'check_person_ex_type';
403 l_temp_type per_person_types.system_person_type%type;
404 l_temp_id number;
405 l_result varchar2(4);
406 --
407 begin
408 --
409 hr_utility.set_location('Entering:'|| l_proc, 5);
410 --
411 -- Check that the person type is valid.
412 --
413 open check_person_type;
414 fetch check_person_type into l_temp_type;
415 if check_person_type%notfound then
416 close check_person_type;
417 hr_utility.set_message(801, 'HR_52366_PTU_INV_PERSON_TYPE');
418 hr_utility.raise_error;
419 end if;
420 --
421 -- Check that the type passed in isn't an 'EX' type or a combination of
422 -- old types
423 --
424 if ( p_person_type = 'EX_EMP' or
425 p_person_type = 'EX_APL' or
426 p_person_type = 'EMP_APL' or
427 p_person_type = 'EX_EMP_APL' or
428 p_person_type = 'APL_EX_APL') then
429 hr_utility.set_message(801, 'HR_52366_PTU_INV_PERSON_TYPE');
430 hr_utility.raise_error;
431 end if;
432 --
433 close check_person_type;
434 --
435 -- Check that the person id is valid.
436 --
437 open check_person_id;
438 fetch check_person_id into l_temp_id;
439 if check_person_id%notfound then
440 close check_person_id;
441 hr_utility.set_message(801, 'HR_52365_PTU_NO_PERSON_EXISTS');
442 hr_utility.raise_error;
443 end if;
444 --
445 close check_person_id;
446 --
447 -- Check that there exist rows of the person type previous to the
448 -- effective_date.
449 --
450 open check_person_ex_type;
451 fetch check_person_ex_type into l_result;
452 if check_person_ex_type%found then
453 close check_person_ex_type;
454 hr_utility.set_location('Leaving:'|| l_proc, 10);
455 return TRUE;
456 end if;
457
458 close check_person_ex_type;
459 hr_utility.set_location('Leaving:'|| l_proc, 20);
460 return FALSE;
461 --
462 end check_person_ex_type;
463 --
464 --
465 -- ----------------------------------------------------------------------------
466 -- |------------------------< create_person_type_usage >----------------------|
467 -- ----------------------------------------------------------------------------
468 procedure create_person_type_usage
469 ( p_validate in boolean default false
470 ,p_person_id in number
471 ,p_person_type_id in number
472 ,p_effective_date in date
473 ,p_attribute_category in varchar2 default null
474 ,p_attribute1 in varchar2 default null
475 ,p_attribute2 in varchar2 default null
476 ,p_attribute3 in varchar2 default null
477 ,p_attribute4 in varchar2 default null
478 ,p_attribute5 in varchar2 default null
479 ,p_attribute6 in varchar2 default null
480 ,p_attribute7 in varchar2 default null
481 ,p_attribute8 in varchar2 default null
482 ,p_attribute9 in varchar2 default null
483 ,p_attribute10 in varchar2 default null
484 ,p_attribute11 in varchar2 default null
485 ,p_attribute12 in varchar2 default null
486 ,p_attribute13 in varchar2 default null
487 ,p_attribute14 in varchar2 default null
488 ,p_attribute15 in varchar2 default null
489 ,p_attribute16 in varchar2 default null
490 ,p_attribute17 in varchar2 default null
491 ,p_attribute18 in varchar2 default null
492 ,p_attribute19 in varchar2 default null
493 ,p_attribute20 in varchar2 default null
494 ,p_attribute21 in varchar2 default null
495 ,p_attribute22 in varchar2 default null
496 ,p_attribute23 in varchar2 default null
497 ,p_attribute24 in varchar2 default null
498 ,p_attribute25 in varchar2 default null
499 ,p_attribute26 in varchar2 default null
500 ,p_attribute27 in varchar2 default null
501 ,p_attribute28 in varchar2 default null
502 ,p_attribute29 in varchar2 default null
503 ,p_attribute30 in varchar2 default null
504 ,p_person_type_usage_id out nocopy number
505 ,p_object_version_number out nocopy number
506 ,p_effective_start_date out nocopy date
507 ,p_effective_end_date out nocopy date
508 ) is
509 l_proc varchar2(80) := g_package||'create_person_type_usage';
510 l_person_type per_person_types.system_person_type%TYPE;
511 l_person_type_usage_id per_person_type_usages_f.person_type_usage_id%TYPE;
512 l_effective_start_date per_person_type_usages_f.effective_start_date%TYPE;
513 l_effective_end_date per_person_type_usages_f.effective_end_date%TYPE;
514 l_object_version_number per_person_type_usages_f.object_version_number%TYPE;
515 --
516 -- Setup cursor for valid person type check
517 --
518 cursor csr_valid_person_type
519 is
520 select system_person_type
521 from per_person_types
522 where person_type_id = p_person_type_id;
523 --
524 begin
525 --
526 hr_utility.set_location('Entering:'|| l_proc, 10);
527 --
528 -- Issue a savepoint if operating in validation only mode
529 --
530 if p_validate then
531 savepoint create_person_type_usage;
532 end if;
533 --
534 hr_utility.set_location(l_proc, 20);
535 --
536 -- Process Logic
537 --
538 --
539 -----------------------------------
540 -- Check person type id is valid --
541 -----------------------------------
542 open csr_valid_person_type;
543 fetch csr_valid_person_type into l_person_type;
544 if csr_valid_person_type%notfound then
545 close csr_valid_person_type;
546 fnd_message.set_name('PER', 'HR_52362_PTU_INV_PER_TYPE_ID');
547 fnd_message.raise_error;
548 end if;
549 close csr_valid_person_type;
550
551 hr_utility.set_location('At: '||l_proc,15);
552
553 --
554 -- Must not exist in hr_standard_lookups where lookup_type is
555 -- HR_SYS_PTU
556 --
557 if not hr_api.not_exists_in_hrstanlookups
558 (p_effective_date => p_effective_date
559 ,p_lookup_type => 'HR_SYS_PTU'
560 ,p_lookup_code => l_person_type
561 ) then
562 fnd_message.set_name('PER', 'HR_52362_PTU_INV_PER_TYPE_ID');
563 fnd_message.raise_error;
564 end if;
565
566 hr_utility.set_location('At: '||l_proc,20);
567
568 begin
569 --
570 -- Start of API User Hook for the before hook of create_person_type_usage
571 --
572 hr_person_type_usage_bk2.create_person_type_usage_b
573 (p_person_id => p_person_id
574 ,p_person_type_id => p_person_type_id
575 ,p_effective_date => p_effective_date
576 ,p_attribute_category => p_attribute_category
577 ,p_attribute1 => p_attribute1
578 ,p_attribute2 => p_attribute2
579 ,p_attribute3 => p_attribute3
580 ,p_attribute4 => p_attribute4
581 ,p_attribute5 => p_attribute5
582 ,p_attribute6 => p_attribute6
583 ,p_attribute7 => p_attribute7
584 ,p_attribute8 => p_attribute8
585 ,p_attribute9 => p_attribute9
586 ,p_attribute10 => p_attribute10
587 ,p_attribute11 => p_attribute11
588 ,p_attribute12 => p_attribute12
589 ,p_attribute13 => p_attribute13
590 ,p_attribute14 => p_attribute14
591 ,p_attribute15 => p_attribute15
592 ,p_attribute16 => p_attribute16
593 ,p_attribute17 => p_attribute17
594 ,p_attribute18 => p_attribute18
595 ,p_attribute19 => p_attribute19
596 ,p_attribute20 => p_attribute20
597 ,p_attribute21 => p_attribute21
598 ,p_attribute22 => p_attribute22
599 ,p_attribute23 => p_attribute23
600 ,p_attribute24 => p_attribute24
601 ,p_attribute25 => p_attribute25
602 ,p_attribute26 => p_attribute26
603 ,p_attribute27 => p_attribute27
604 ,p_attribute28 => p_attribute28
605 ,p_attribute29 => p_attribute29
606 ,p_attribute30 => p_attribute30
607 );
608
609 exception
610 when hr_api.cannot_find_prog_unit then
611 hr_api.cannot_find_prog_unit_error
612 (p_module_name => 'CREATE_person_type_usage'
613 ,p_hook_type => 'BP'
614 );
615 --
616 -- End of API User Hook for the before hook of create_person_type_usage
617 --
618 end;
619
620 hr_per_type_usage_internal.create_person_type_usage
621 (p_validate => FALSE
622 ,p_person_id => p_person_id
623 ,p_person_type_id => p_person_type_id
624 ,p_effective_date => p_effective_date
625 ,p_attribute_category => p_attribute_category
626 ,p_attribute1 => p_attribute1
627 ,p_attribute2 => p_attribute2
628 ,p_attribute3 => p_attribute3
629 ,p_attribute4 => p_attribute4
630 ,p_attribute5 => p_attribute5
631 ,p_attribute6 => p_attribute6
632 ,p_attribute7 => p_attribute7
633 ,p_attribute8 => p_attribute8
634 ,p_attribute9 => p_attribute9
635 ,p_attribute10 => p_attribute10
636 ,p_attribute11 => p_attribute11
637 ,p_attribute12 => p_attribute12
638 ,p_attribute13 => p_attribute13
639 ,p_attribute14 => p_attribute14
640 ,p_attribute15 => p_attribute15
641 ,p_attribute16 => p_attribute16
642 ,p_attribute17 => p_attribute17
643 ,p_attribute18 => p_attribute18
644 ,p_attribute19 => p_attribute19
645 ,p_attribute20 => p_attribute20
646 ,p_attribute21 => p_attribute21
647 ,p_attribute22 => p_attribute22
648 ,p_attribute23 => p_attribute23
649 ,p_attribute24 => p_attribute24
650 ,p_attribute25 => p_attribute25
651 ,p_attribute26 => p_attribute26
652 ,p_attribute27 => p_attribute27
653 ,p_attribute28 => p_attribute28
654 ,p_attribute29 => p_attribute29
655 ,p_attribute30 => p_attribute30
656 ,p_person_type_usage_id => l_person_type_usage_id
657 ,p_object_version_number => l_object_version_number
658 ,p_effective_start_date => l_effective_start_date
659 ,p_effective_end_date => l_effective_end_date);
660
661 --
662 --
663 hr_utility.set_location(l_proc, 60);
664 begin
665 --
666 -- Start of API User Hook for the after hook of create_person_type_usage
667 --
668 -- Out paramters are being passed as they are being set to the correct value in
669 -- create_person_type_usage_internal.
670
671 hr_person_type_usage_bk2.create_person_type_usage_a
672 (p_person_id => p_person_id
673 ,p_person_type_id => p_person_type_id
674 ,p_effective_date => p_effective_date
675 ,p_attribute_category => p_attribute_category
676 ,p_attribute1 => p_attribute1
677 ,p_attribute2 => p_attribute2
678 ,p_attribute3 => p_attribute3
679 ,p_attribute4 => p_attribute4
680 ,p_attribute5 => p_attribute5
681 ,p_attribute6 => p_attribute6
682 ,p_attribute7 => p_attribute7
683 ,p_attribute8 => p_attribute8
684 ,p_attribute9 => p_attribute9
685 ,p_attribute10 => p_attribute10
686 ,p_attribute11 => p_attribute11
687 ,p_attribute12 => p_attribute12
688 ,p_attribute13 => p_attribute13
689 ,p_attribute14 => p_attribute14
690 ,p_attribute15 => p_attribute15
691 ,p_attribute16 => p_attribute16
692 ,p_attribute17 => p_attribute17
693 ,p_attribute18 => p_attribute18
694 ,p_attribute19 => p_attribute19
695 ,p_attribute20 => p_attribute20
696 ,p_attribute21 => p_attribute21
697 ,p_attribute22 => p_attribute22
698 ,p_attribute23 => p_attribute23
699 ,p_attribute24 => p_attribute24
700 ,p_attribute25 => p_attribute25
701 ,p_attribute26 => p_attribute26
702 ,p_attribute27 => p_attribute27
703 ,p_attribute28 => p_attribute28
704 ,p_attribute29 => p_attribute29
705 ,p_attribute30 => p_attribute30
706 ,p_person_type_usage_id => l_person_type_usage_id
707 ,p_object_version_number => l_object_version_number
708 ,p_effective_start_date => l_effective_start_date
709 ,p_effective_end_date => l_effective_end_date
710 );
711
712 exception
713 when hr_api.cannot_find_prog_unit then
714 hr_api.cannot_find_prog_unit_error
715 (p_module_name => 'CREATE_person_type_usage'
716 ,p_hook_type => 'AP'
717 );
718 --
719 -- End of API User Hook for the after hook of create_person_type_usage
720 --
721 end;
722 --
723 -- When in validation only mode raise the Validate_Enabled exception
724 --
725 if p_validate then
726 raise hr_api.validate_enabled;
727 end if;
728 --
729 -- Set all output arguments
730 --
731 p_person_type_usage_id := l_person_type_usage_id;
732 p_effective_start_date := l_effective_start_date;
733 p_effective_end_date := l_effective_end_date;
734 p_object_version_number := l_object_version_number;
735 --
736 hr_utility.set_location(' Leaving:'||l_proc, 70);
737 --
738 exception
739 --
740 when hr_api.validate_enabled then
741 --
742 -- As the Validate_Enabled exception has been raised
743 -- we must rollback to the savepoint
744 --
745 ROLLBACK TO create_person_type_usage;
746 --
747 -- Only set output warning arguments
748 -- (Any key or derived arguments must be set to null
749 -- when validation only mode is being used.)
750 p_person_type_usage_id := null;
751 p_effective_start_date := null;
752 p_effective_end_date := null;
753 p_object_version_number := null;
754 hr_utility.set_location(' Leaving:'||l_proc, 80);
755 --
756 end create_person_type_usage;
757 --
758 -- ----------------------------------------------------------------------------
759 -- |------------------------< delete_person_type_usage >----------------------|
760 -- ----------------------------------------------------------------------------
761 procedure delete_person_type_usage
762 ( p_validate in boolean default false
763 ,p_person_type_usage_id in number
764 ,p_effective_date in date
765 ,p_datetrack_mode in varchar2
766 ,p_object_version_number in out nocopy number
767 ,p_effective_start_date out nocopy date
768 ,p_effective_end_date out nocopy date
769 ) is
770
771 l_proc varchar2(80) := g_package||'delete_person_type_usage';
772 l_system_person_type per_person_types.system_person_type%TYPE;
773 l_object_version_number per_person_type_usages_f.object_version_number%TYPE;
774 l_effective_start_date per_person_type_usages_f.effective_start_date%TYPE;
775 l_effective_end_date per_person_type_usages_f.effective_end_date%TYPE;
776
777 cursor csr_ptu
778 is
779 select ppt.system_person_type
780 from per_person_type_usages_f ptu , per_person_types ppt
781 where ptu.person_type_usage_id = p_person_type_usage_id
782 and ptu.person_type_id = ppt.person_type_id
783 and ( p_effective_date between
784 ptu.effective_start_date and ptu.effective_end_date);
785
786 begin
787 --
788 hr_utility.set_location('Entering:'|| l_proc, 10);
789 --
790 -- Issue a savepoint if operating in validation only mode
791 --
792 if p_validate then
793 savepoint delete_person_type_usage;
794 end if;
795 --
796 hr_utility.set_location('At:'||l_proc, 20);
797 --
798 -- Process Logic
799 --
800 --
801
802 l_object_version_number := p_object_version_number;
803
804 OPEN csr_ptu;
805 FETCH csr_ptu INTO l_system_person_type;
806 IF csr_ptu%NOTFOUND THEN
807 --
808 -- The primary key is invalid therefore we must error
809 --
810 CLOSE csr_ptu;
811 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
812 hr_utility.raise_error;
813 END IF;
814 CLOSE csr_ptu;
815
816 --
817 -- Must not exist in hr_standard_lookups where lookup_type is
818 -- HR_SYS_PTU
819 --
820 -- PTU Changes
821 --
822 -- if not hr_api.not_exists_in_hrstanlookups
823 -- (p_effective_date => p_effective_date
824 -- ,p_lookup_type => 'HR_SYS_PTU'
825 -- ,p_lookup_code => l_system_person_type
826 -- ) then
827 -- fnd_message.set_name('PER', 'HR_52658_PTU_INVALID_DELETE');
828 -- fnd_message.raise_error;
829 -- end if;
830 --
831 -- End of PTU Changes
832 --
833 --
834 hr_utility.set_location('At: '||l_proc,40);
835 begin
836 --
837 -- Start of API User Hook for the before hook of delete_person_type_usage
838 --
839 hr_person_type_usage_bk3.delete_person_type_usage_b
840 (p_person_type_usage_id => p_person_type_usage_id
841 ,p_effective_date => p_effective_date
842 ,p_datetrack_mode => p_datetrack_mode
843 ,p_object_version_number => l_object_version_number
844 );
845
846 exception
847 when hr_api.cannot_find_prog_unit then
848 hr_api.cannot_find_prog_unit_error
849 (p_module_name => 'DELETE_person_type_usage'
850 ,p_hook_type => 'BP'
851 );
852 --
853 -- End of API User Hook for the before hook of delete_person_type_usage
854 --
855 end;
856
857 hr_utility.set_location('At: '||l_proc,30);
858
859 hr_per_type_usage_internal.delete_person_type_usage
860 (p_validate => FALSE
861 ,p_person_type_usage_id => p_person_type_usage_id
862 ,p_effective_date => p_effective_date
863 ,p_datetrack_mode => p_datetrack_mode
864 ,p_object_version_number => l_object_version_number
865 ,p_effective_start_date => l_effective_start_date
866 ,p_effective_end_date => l_effective_end_date
867 );
868
869 --
870 --
871 hr_utility.set_location(l_proc, 60);
872 --
873 begin
874 --
875 -- Start of API User Hook for the after hook of delete_person_type_usage
876 --
877 -- Out paramters are being passed as they are being set to the correct value in
878 -- delete_person_type_usage_internal.
879
880 hr_person_type_usage_bk3.delete_person_type_usage_a
881 (p_person_type_usage_id => p_person_type_usage_id
882 ,p_effective_date => p_effective_date
883 ,p_datetrack_mode => p_datetrack_mode
884 ,p_object_version_number => l_object_version_number
885 ,p_effective_start_date => l_effective_start_date
886 ,p_effective_end_date => l_effective_end_date
887 );
888
889 exception
890 when hr_api.cannot_find_prog_unit then
891 hr_api.cannot_find_prog_unit_error
892 (p_module_name => 'DELETE_person_type_usage'
893 ,p_hook_type => 'AP'
894 );
895 --
896 -- End of API User Hook for the after hook of delete_person_type_usage
897 --
898 end;
899 --
900 -- When in validation only mode raise the Validate_Enabled exception
901 --
902 if p_validate then
903 raise hr_api.validate_enabled;
904 end if;
905 p_effective_start_date := l_effective_start_date;
906 p_effective_end_date := l_effective_end_date;
907 p_object_version_number := l_object_version_number;
908 --
909 hr_utility.set_location(' Leaving:'||l_proc, 70);
910 --
911 exception
912 --
913 when hr_api.validate_enabled then
914 --
915 -- As the Validate_Enabled exception has been raised
916 -- we must rollback to the savepoint
917 --
918 ROLLBACK TO delete_person_type_usage;
919 --
920 -- Only set output warning arguments
921 -- (Any key or derived arguments must be set to null
922 -- when validation only mode is being used.)
923 --
924 p_effective_start_date := null;
925 p_effective_end_date := null;
926 end delete_person_type_usage;
927 end hr_person_type_usage_api;