[Home] [Help]
PACKAGE BODY: APPS.BEN_EAP_BUS
Source
4 -- ----------------------------------------------------------------------------
1 Package Body ben_eap_bus as
2 /* $Header: beeaprhi.pkb 120.1 2006/02/27 02:07:31 rtagarra noship $ */
3 --
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_eap_bus.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_elig_age_prte_id >------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description
15 -- This procedure is used to check that the primary key for the table
16 -- is created properly. It should be null on insert and
17 -- should not be able to be updated.
18 --
19 -- Pre Conditions
20 -- None.
21 --
22 -- In Parameters
23 -- elig_age_prte_id PK of record being inserted or updated.
24 -- effective_date Effective Date of session
25 -- object_version_number Object version number of record being
26 -- inserted or updated.
27 --
28 -- Post Success
29 -- Processing continues
30 --
31 -- Post Failure
32 -- Errors handled by the procedure
33 --
34 -- Access Status
35 -- Internal table handler use only.
36 --
37 Procedure chk_elig_age_prte_id(p_elig_age_prte_id in number,
38 p_effective_date in date,
39 p_object_version_number in number) is
40 --
41 l_proc varchar2(72) := g_package||'chk_elig_age_prte_id';
42 l_api_updating boolean;
43 --
44 Begin
45 --
46 hr_utility.set_location('Entering:'||l_proc, 5);
47 --
48 l_api_updating := ben_eap_shd.api_updating
49 (p_effective_date => p_effective_date,
50 p_elig_age_prte_id => p_elig_age_prte_id,
51 p_object_version_number => p_object_version_number);
52 --
53 if (l_api_updating
54 and nvl(p_elig_age_prte_id,hr_api.g_number)
58 --
55 <> ben_eap_shd.g_old_rec.elig_age_prte_id) then
56 --
57 -- raise error as PK has changed
59 ben_eap_shd.constraint_error('BEN_ELIG_AGE_PRTE_PK');
60 --
61 elsif not l_api_updating then
62 --
63 -- check if PK is null
64 --
65 if p_elig_age_prte_id is not null then
66 --
67 -- raise error as PK is not null
68 --
69 ben_eap_shd.constraint_error('BEN_ELIG_AGE_PRTE_PK');
70 --
71 end if;
72 --
73 end if;
74 --
75 hr_utility.set_location('Leaving:'||l_proc, 10);
76 --
77 End chk_elig_age_prte_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |------< chk_age_fctr_id >------|
81 -- ----------------------------------------------------------------------------
82 --
83 -- Description
84 -- This procedure checks that a referenced foreign key actually exists
85 -- in the referenced table.
86 --
87 -- Pre-Conditions
88 -- None.
89 --
90 -- In Parameters
91 -- p_elig_age_prte_id PK
92 -- p_age_fctr_id ID of FK column
93 -- p_effective_date session date
94 -- p_object_version_number object version number
95 --
96 -- Post Success
97 -- Processing continues
98 --
99 -- Post Failure
100 -- Error raised.
101 --
102 -- Access Status
103 -- Internal table handler use only.
104 --
105 Procedure chk_age_fctr_id (p_elig_age_prte_id in number,
106 p_age_fctr_id in number,
107 p_eligy_prfl_id in number,
108 p_validation_start_date in date,
109 p_validation_end_date in date,
110 p_business_group_id in number,
111 p_effective_date in date,
112 p_object_version_number in number) is
113 --
114 l_proc varchar2(72) := g_package||'chk_age_fctr_id';
115 l_api_updating boolean;
116 l_dummy varchar2(1);
117 l_exists varchar2(1);
118 --
119 cursor c1 is
120 select null
121 from ben_age_fctr a
122 where a.age_fctr_id = p_age_fctr_id
123 and a.business_group_id + 0 = p_business_group_id;
124 --
125 --
126 cursor c3 is
127 select null
128 from ben_elig_age_prte_f
129 where age_fctr_id = p_age_fctr_id
130 and eligy_prfl_id = p_eligy_prfl_id
131 and elig_age_prte_id <> nvl(p_elig_age_prte_id,hr_api.g_number)
132 and business_group_id + 0 = p_business_group_id
133 and p_validation_start_date <= effective_end_date
134 and p_validation_end_date >= effective_start_date
135 ;
136 --
137 Begin
138 --
139 hr_utility.set_location('Entering:'||l_proc,5);
140 --
141 l_api_updating := ben_eap_shd.api_updating
142 (p_elig_age_prte_id => p_elig_age_prte_id,
143 p_effective_date => p_effective_date,
144 p_object_version_number => p_object_version_number);
145 --
146 if (l_api_updating
147 and nvl(p_age_fctr_id,hr_api.g_number)
148 <> nvl(ben_eap_shd.g_old_rec.age_fctr_id,hr_api.g_number)
149 or not l_api_updating) then
150 --
151 -- check if age_fctr_id value exists in ben_age_fctr table
152 --
153 open c1;
154 --
155 fetch c1 into l_dummy;
156 if c1%notfound then
157 --
158 close c1;
159 --
160 -- raise error as FK does not relate to PK in ben_age_fctr
161 -- table.
162 --
163 ben_eap_shd.constraint_error('BEN_ELIG_AGE_PRTE_FK1');
164 --
165 end if;
166 --
167 close c1;
168 --
169 --
170 open c3;
171 fetch c3 into l_exists;
172 if c3%found then
173 close c3;
174 --
175 -- raise error as this criteria already exists for this profile
176 --
177 fnd_message.set_name('BEN', 'BEN_91349_DUP_ELIG_CRITERIA');
178 fnd_message.raise_error;
179 --
180 end if;
181 close c3;
182 --
183 end if;
184 --
185 hr_utility.set_location('Leaving:'||l_proc,10);
186 --
187 End chk_age_fctr_id;
188 --
189 -- ----------------------------------------------------------------------------
190 -- |------< chk_excld_flag >------|
191 -- ----------------------------------------------------------------------------
192 --
193 -- Description
194 -- This procedure is used to check that the lookup value is valid.
195 --
196 -- Pre Conditions
197 -- None.
198 --
199 -- In Parameters
200 -- elig_age_prte_id PK of record being inserted or updated.
201 -- excld_flag Value of lookup code.
202 -- effective_date effective date
203 -- object_version_number Object version number of record being
204 -- inserted or updated.
205 --
206 -- Post Success
207 -- Processing continues
208 --
209 -- Post Failure
210 -- Error handled by procedure
211 --
212 -- Access Status
213 -- Internal table handler use only.
214 --
215 Procedure chk_excld_flag(p_elig_age_prte_id in number,
216 p_excld_flag in varchar2,
217 p_effective_date in date,
218 p_object_version_number in number) is
219 --
220 l_proc varchar2(72) := g_package||'chk_excld_flag';
221 l_api_updating boolean;
222 --
223 Begin
227 l_api_updating := ben_eap_shd.api_updating
224 --
225 hr_utility.set_location('Entering:'||l_proc, 5);
226 --
228 (p_elig_age_prte_id => p_elig_age_prte_id,
229 p_effective_date => p_effective_date,
230 p_object_version_number => p_object_version_number);
231 --
232 if (l_api_updating
233 and p_excld_flag
234 <> nvl(ben_eap_shd.g_old_rec.excld_flag,hr_api.g_varchar2)
235 or not l_api_updating) then
236 --
237 -- check if value of lookup falls within lookup type.
238 --
239 --
240 if hr_api.not_exists_in_hr_lookups
241 (p_lookup_type => 'YES_NO',
242 p_lookup_code => p_excld_flag,
243 p_effective_date => p_effective_date) then
244 --
245 -- raise error as does not exist as lookup
246 --
247 hr_utility.set_message(801,'HR_LOOKUP_DOES_NOT_EXIST');
248 hr_utility.raise_error;
249 --
250 end if;
251 --
252 end if;
253 --
254 hr_utility.set_location('Leaving:'||l_proc,10);
255 --
256 end chk_excld_flag;
257 --
258 --Bug:5054189
259 -- ---------------------------------------------------------------------------
260 -- |-----------------------< chk_duplicate_ordr_num >---------------------------|
261 -- ---------------------------------------------------------------------------
262 --
263 -- Description
264 -- Ensure that the Sequence Number is unique
265 -- within business_group
266 --
267 -- Pre Conditions
268 -- None.
269 --
270 -- In Parameters
271 -- p_elig_age_prte_id elig_age_prte_id
272 -- p_eligy_prfl_id eligy_prfl_id
273 -- p_ordr_num Sequence Number
274 -- p_business_group_id
275 --
276 -- Post Success
277 -- Processing continues
278 --
279 -- Post Failure
280 -- Errors handled by the procedure
281 --
282 -- Access Status
283 -- Internal table handler use only
284 --
285
286 Procedure chk_duplicate_ordr_num
287 ( p_elig_age_prte_id in number
288 ,p_eligy_prfl_id in number
289 ,p_ordr_num in number
290 ,p_business_group_id in number)
291 is
292 l_proc varchar2(72) := g_package||'chk_duplicate_ordr_num';
293 l_dummy char(1);
294 cursor c1 is
295 select null
296 from ben_elig_age_prte_f
297 where elig_age_prte_id <> nvl(p_elig_age_prte_id,-1)
298 and eligy_prfl_id = p_eligy_prfl_id
299 and ordr_num = p_ordr_num
300 and business_group_id = p_business_group_id;
301 --
302 Begin
303 hr_utility.set_location('Entering:'||l_proc, 5);
304 --
305 open c1;
306 fetch c1 into l_dummy;
307 if c1%found then
308 close c1;
309 fnd_message.set_name('BEN','BEN_91001_SEQ_NOT_UNIQUE');
310 fnd_message.raise_error;
311 end if;
312 close c1;
313 --
314 hr_utility.set_location('Leaving:'||l_proc, 15);
315 End chk_duplicate_ordr_num;
316 -- ----------------------------------------------------------------------------
317 -- |--------------------------< dt_update_validate >--------------------------|
318 -- ----------------------------------------------------------------------------
319 -- {Start Of Comments}
320 --
321 -- Description:
322 -- This procedure is used for referential integrity of datetracked
323 -- parent entities when a datetrack update operation is taking place
324 -- and where there is no cascading of update defined for this entity.
325 --
326 -- Prerequisites:
327 -- This procedure is called from the update_validate.
328 --
329 -- In Parameters:
330 --
331 -- Post Success:
332 -- Processing continues.
333 --
334 -- Post Failure:
335 --
336 -- Developer Implementation Notes:
337 -- This procedure should not need maintenance unless the HR Schema model
338 -- changes.
339 --
340 -- Access Status:
341 -- Internal Row Handler Use Only.
342 --
343 -- {End Of Comments}
344 -- ----------------------------------------------------------------------------
345 Procedure dt_update_validate
346 (p_eligy_prfl_id in number default hr_api.g_number,
347 p_datetrack_mode in varchar2,
348 p_validation_start_date in date,
349 p_validation_end_date in date) Is
350 --
351 l_proc varchar2(72) := g_package||'dt_update_validate';
352 l_integrity_error Exception;
353 l_table_name all_tables.table_name%TYPE;
354 --
355 Begin
356 hr_utility.set_location('Entering:'||l_proc, 5);
357 --
358 -- Ensure that the p_datetrack_mode argument is not null
359 --
360 hr_api.mandatory_arg_error
361 (p_api_name => l_proc,
362 p_argument => 'datetrack_mode',
363 p_argument_value => p_datetrack_mode);
364 --
365 -- Only perform the validation if the datetrack update mode is valid
366 --
367 If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
368 --
369 --
370 -- Ensure the arguments are not null
371 --
372 hr_api.mandatory_arg_error
373 (p_api_name => l_proc,
374 p_argument => 'validation_start_date',
375 p_argument_value => p_validation_start_date);
376 --
377 hr_api.mandatory_arg_error
378 (p_api_name => l_proc,
379 p_argument => 'validation_end_date',
380 p_argument_value => p_validation_end_date);
381 --
385 p_base_key_column => 'eligy_prfl_id',
382 If ((nvl(p_eligy_prfl_id, hr_api.g_number) <> hr_api.g_number) and
383 NOT (dt_api.check_min_max_dates
384 (p_base_table_name => 'ben_eligy_prfl_f',
386 p_base_key_value => p_eligy_prfl_id,
387 p_from_date => p_validation_start_date,
388 p_to_date => p_validation_end_date))) Then
389 l_table_name := 'ben_eligy_prfl_f';
390 Raise l_integrity_error;
391 End If;
392 --
393 End If;
394 --
395 hr_utility.set_location(' Leaving:'||l_proc, 10);
396 Exception
397 When l_integrity_error Then
398 --
399 -- A referential integrity check was violated therefore
400 -- we must error
401 --
402 ben_utility.parent_integrity_error(p_table_name => l_table_name);
403 --
404 When Others Then
405 --
406 -- An unhandled or unexpected error has occurred which
407 -- we must report
408 --
409 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
410 hr_utility.set_message_token('PROCEDURE', l_proc);
411 hr_utility.set_message_token('STEP','15');
412 hr_utility.raise_error;
413 End dt_update_validate;
414 --
415 -- ----------------------------------------------------------------------------
416 -- |--------------------------< dt_delete_validate >--------------------------|
417 -- ----------------------------------------------------------------------------
418 -- {Start Of Comments}
419 --
420 -- Description:
421 -- This procedure is used for referential integrity of datetracked
422 -- child entities when either a datetrack DELETE or ZAP is in operation
423 -- and where there is no cascading of delete defined for this entity.
424 -- For the datetrack mode of DELETE or ZAP we must ensure that no
425 -- datetracked child rows exist between the validation start and end
426 -- dates.
427 --
428 -- Prerequisites:
429 -- This procedure is called from the delete_validate.
430 --
431 -- In Parameters:
432 --
433 -- Post Success:
434 -- Processing continues.
435 --
436 -- Post Failure:
437 -- If a row exists by determining the returning Boolean value from the
438 -- generic dt_api.rows_exist function then we must supply an error via
439 -- the use of the local exception handler l_rows_exist.
440 --
441 -- Developer Implementation Notes:
442 -- This procedure should not need maintenance unless the HR Schema model
443 -- changes.
444 --
445 -- Access Status:
446 -- Internal Row Handler Use Only.
447 --
448 -- {End Of Comments}
449 -- ----------------------------------------------------------------------------
450 Procedure dt_delete_validate
451 (p_elig_age_prte_id in number,
452 p_datetrack_mode in varchar2,
453 p_validation_start_date in date,
454 p_validation_end_date in date) Is
455 --
456 l_proc varchar2(72) := g_package||'dt_delete_validate';
457 l_rows_exist Exception;
458 l_table_name all_tables.table_name%TYPE;
459 --
460 Begin
461 hr_utility.set_location('Entering:'||l_proc, 5);
462 --
463 -- Ensure that the p_datetrack_mode argument is not null
464 --
465 hr_api.mandatory_arg_error
466 (p_api_name => l_proc,
467 p_argument => 'datetrack_mode',
468 p_argument_value => p_datetrack_mode);
469 --
470 -- Only perform the validation if the datetrack mode is either
471 -- DELETE or ZAP
472 --
473 If (p_datetrack_mode = 'DELETE' or
474 p_datetrack_mode = 'ZAP') then
475 --
476 --
477 -- Ensure the arguments are not null
478 --
479 hr_api.mandatory_arg_error
480 (p_api_name => l_proc,
481 p_argument => 'validation_start_date',
482 p_argument_value => p_validation_start_date);
483 --
484 hr_api.mandatory_arg_error
485 (p_api_name => l_proc,
486 p_argument => 'validation_end_date',
487 p_argument_value => p_validation_end_date);
488 --
489 hr_api.mandatory_arg_error
490 (p_api_name => l_proc,
491 p_argument => 'elig_age_prte_id',
492 p_argument_value => p_elig_age_prte_id);
493 --
494 --
495 --
496 End If;
497 --
498 hr_utility.set_location(' Leaving:'||l_proc, 10);
499 Exception
500 When l_rows_exist Then
501 --
502 -- A referential integrity check was violated therefore
503 -- we must error
504 --
505 ben_utility.child_exists_error(p_table_name => l_table_name);
506 --
507 When Others Then
508 --
509 -- An unhandled or unexpected error has occurred which
510 -- we must report
511 --
512 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
513 hr_utility.set_message_token('PROCEDURE', l_proc);
514 hr_utility.set_message_token('STEP','15');
515 hr_utility.raise_error;
516 End dt_delete_validate;
517 --
518 -- ----------------------------------------------------------------------------
519 -- |---------------------------< insert_validate >----------------------------|
520 -- ----------------------------------------------------------------------------
521 Procedure insert_validate
522 (p_rec in ben_eap_shd.g_rec_type,
523 p_effective_date in date,
524 p_datetrack_mode in varchar2,
525 p_validation_start_date in date,
526 p_validation_end_date in date) is
527 --
528 l_proc varchar2(72) := g_package||'insert_validate';
529 --
530 Begin
531 hr_utility.set_location('Entering:'||l_proc, 5);
532 --
533 -- Call all supporting business operations
534 --
535 --
536 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
537 --
541 p_object_version_number => p_rec.object_version_number);
538 chk_elig_age_prte_id
539 (p_elig_age_prte_id => p_rec.elig_age_prte_id,
540 p_effective_date => p_effective_date,
542 --
543 chk_age_fctr_id
544 (p_elig_age_prte_id => p_rec.elig_age_prte_id,
545 p_age_fctr_id => p_rec.age_fctr_id,
546 p_eligy_prfl_id => p_rec.eligy_prfl_id,
547 p_validation_start_date => p_validation_start_date,
548 p_validation_end_date => p_validation_end_date,
549 p_effective_date => p_effective_date,
550 p_business_group_id => p_rec.business_group_id,
551 p_object_version_number => p_rec.object_version_number);
552 --
553 chk_excld_flag
554 (p_elig_age_prte_id => p_rec.elig_age_prte_id,
555 p_excld_flag => p_rec.excld_flag,
556 p_effective_date => p_effective_date,
557 p_object_version_number => p_rec.object_version_number);
558 --
559 chk_duplicate_ordr_num
560 ( p_elig_age_prte_id => p_rec.elig_age_prte_id
561 ,p_eligy_prfl_id => p_rec.eligy_prfl_id
562 ,p_ordr_num => p_rec.ordr_num
563 ,p_business_group_id => p_rec.business_group_id);
564 --
565 hr_utility.set_location(' Leaving:'||l_proc, 10);
566 End insert_validate;
567 --
568 -- ----------------------------------------------------------------------------
569 -- |---------------------------< update_validate >----------------------------|
570 -- ----------------------------------------------------------------------------
571 Procedure update_validate
572 (p_rec in ben_eap_shd.g_rec_type,
573 p_effective_date in date,
574 p_datetrack_mode in varchar2,
575 p_validation_start_date in date,
576 p_validation_end_date in date) is
577 --
578 l_proc varchar2(72) := g_package||'update_validate';
579 --
580 Begin
581 hr_utility.set_location('Entering:'||l_proc, 5);
582 --
583 -- Call all supporting business operations
584 --
585 --
586 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
587 --
588 chk_elig_age_prte_id
589 (p_elig_age_prte_id => p_rec.elig_age_prte_id,
590 p_effective_date => p_effective_date,
591 p_object_version_number => p_rec.object_version_number);
592 --
593 chk_age_fctr_id
594 (p_elig_age_prte_id => p_rec.elig_age_prte_id,
595 p_age_fctr_id => p_rec.age_fctr_id,
596 p_eligy_prfl_id => p_rec.eligy_prfl_id,
597 p_validation_start_date => p_validation_start_date,
598 p_validation_end_date => p_validation_end_date,
599 p_business_group_id => p_rec.business_group_id,
600 p_effective_date => p_effective_date,
601 p_object_version_number => p_rec.object_version_number);
602 --
603 chk_excld_flag
604 (p_elig_age_prte_id => p_rec.elig_age_prte_id,
605 p_excld_flag => p_rec.excld_flag,
606 p_effective_date => p_effective_date,
607 p_object_version_number => p_rec.object_version_number);
608 --
609 chk_duplicate_ordr_num
610 ( p_elig_age_prte_id => p_rec.elig_age_prte_id
611 ,p_eligy_prfl_id => p_rec.eligy_prfl_id
612 ,p_ordr_num => p_rec.ordr_num
613 ,p_business_group_id => p_rec.business_group_id);
614 --
615 -- Call the datetrack update integrity operation
616 --
617 dt_update_validate
618 (p_eligy_prfl_id => p_rec.eligy_prfl_id,
619 p_datetrack_mode => p_datetrack_mode,
620 p_validation_start_date => p_validation_start_date,
621 p_validation_end_date => p_validation_end_date);
622 --
623 hr_utility.set_location(' Leaving:'||l_proc, 10);
624 End update_validate;
625 --
626 -- ----------------------------------------------------------------------------
627 -- |---------------------------< delete_validate >----------------------------|
628 -- ----------------------------------------------------------------------------
629 Procedure delete_validate
630 (p_rec in ben_eap_shd.g_rec_type,
631 p_effective_date in date,
632 p_datetrack_mode in varchar2,
633 p_validation_start_date in date,
634 p_validation_end_date in date) is
635 --
636 l_proc varchar2(72) := g_package||'delete_validate';
637 --
638 Begin
639 hr_utility.set_location('Entering:'||l_proc, 5);
640 --
641 -- Call all supporting business operations
642 --
643 dt_delete_validate
644 (p_datetrack_mode => p_datetrack_mode,
645 p_validation_start_date => p_validation_start_date,
646 p_validation_end_date => p_validation_end_date,
647 p_elig_age_prte_id => p_rec.elig_age_prte_id);
648 --
649 hr_utility.set_location(' Leaving:'||l_proc, 10);
650 End delete_validate;
651 --
652 --
653 -- ---------------------------------------------------------------------------
654 -- |---------------------< return_legislation_code >-------------------------|
655 -- ---------------------------------------------------------------------------
656 --
657 function return_legislation_code
658 (p_elig_age_prte_id in number) return varchar2 is
659 --
660 -- Declare cursor
661 --
662 cursor csr_leg_code is
663 select a.legislation_code
664 from per_business_groups a,
665 ben_elig_age_prte_f b
666 where b.elig_age_prte_id = p_elig_age_prte_id
667 and a.business_group_id = b.business_group_id;
668 --
669 -- Declare local variables
670 --
671 l_legislation_code varchar2(150);
672 l_proc varchar2(72) := g_package||'return_legislation_code';
673 --
674 begin
675 --
676 hr_utility.set_location('Entering:'|| l_proc, 10);
677 --
678 -- Ensure that all the mandatory parameter are not null
679 --
683 --
680 hr_api.mandatory_arg_error(p_api_name => l_proc,
681 p_argument => 'elig_age_prte_id',
682 p_argument_value => p_elig_age_prte_id);
684 open csr_leg_code;
685 --
686 fetch csr_leg_code into l_legislation_code;
687 --
688 if csr_leg_code%notfound then
689 --
690 close csr_leg_code;
691 --
692 -- The primary key is invalid therefore we must error
693 --
694 hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
695 hr_utility.raise_error;
696 --
697 end if;
698 --
699 close csr_leg_code;
700 --
701 hr_utility.set_location(' Leaving:'|| l_proc, 20);
702 --
703 return l_legislation_code;
704 --
705 end return_legislation_code;
706 --
707 end ben_eap_bus;