[Home] [Help]
PACKAGE BODY: APPS.BEN_BEI_BUS
Source
1 Package Body ben_bei_bus as
2 /* $Header: bebeirhi.pkb 120.0 2005/05/28 00:38:07 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_bei_bus.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< chk_batch_elig_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 -- batch_elig_id PK of record being inserted or updated.
24 -- object_version_number Object version number of record being
25 -- inserted or updated.
26 --
27 -- Post Success
28 -- Processing continues
29 --
30 -- Post Failure
31 -- Errors handled by the procedure
32 --
33 -- Access Status
34 -- Internal table handler use only.
35 --
36 Procedure chk_batch_elig_id(p_batch_elig_id in number,
37 p_object_version_number in number) is
38 --
39 l_proc varchar2(72) := g_package||'chk_batch_elig_id';
40 l_api_updating boolean;
41 --
42 Begin
43 --
44 hr_utility.set_location('Entering:'||l_proc, 5);
45 --
46 l_api_updating := ben_bei_shd.api_updating
47 (p_batch_elig_id => p_batch_elig_id,
48 p_object_version_number => p_object_version_number);
49 --
50 if (l_api_updating
51 and nvl(p_batch_elig_id,hr_api.g_number)
52 <> ben_bei_shd.g_old_rec.batch_elig_id) then
53 --
54 -- raise error as PK has changed
55 --
56 ben_bei_shd.constraint_error('BEN_BATCH_ELIG_INFO_PK');
57 --
58 elsif not l_api_updating then
59 --
60 -- check if PK is null
61 --
62 if p_batch_elig_id is not null then
63 --
64 -- raise error as PK is not null
65 --
66 ben_bei_shd.constraint_error('BEN_BATCH_ELIG_INFO_PK');
67 --
68 end if;
69 --
70 end if;
71 --
72 hr_utility.set_location('Leaving:'||l_proc, 10);
73 --
74 End chk_batch_elig_id;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |----------------------------< chk_oipl_id >-------------------------------|
78 -- ----------------------------------------------------------------------------
79 --
80 -- Description
81 -- This procedure checks that a referenced foreign key actually exists
82 -- in the referenced table.
83 --
84 -- Pre-Conditions
85 -- None.
86 --
87 -- In Parameters
88 -- p_batch_elig_id PK
89 -- p_oipl_id ID of FK column
90 -- p_effective_date Session Date of record
91 -- p_object_version_number object version number
92 --
93 -- Post Success
94 -- Processing continues
95 --
96 -- Post Failure
97 -- Error raised.
98 --
99 -- Access Status
100 -- Internal table handler use only.
101 --
102 Procedure chk_oipl_id (p_batch_elig_id in number,
103 p_oipl_id in number,
104 p_effective_date in date,
105 p_object_version_number in number) is
106 --
107 l_proc varchar2(72) := g_package||'chk_oipl_id';
108 l_api_updating boolean;
109 l_dummy varchar2(1);
110 --
111 cursor c1 is
112 select null
113 from ben_oipl_f a
114 where a.oipl_id = p_oipl_id
115 and p_effective_date
116 between a.effective_start_date
117 and a.effective_end_date;
118 --
119 Begin
120 --
121 hr_utility.set_location('Entering:'||l_proc,5);
122 --
123 l_api_updating := ben_bei_shd.api_updating
124 (p_batch_elig_id => p_batch_elig_id,
125 p_object_version_number => p_object_version_number);
126 --
127 if (l_api_updating
128 and nvl(p_oipl_id,hr_api.g_number)
129 <> nvl(ben_bei_shd.g_old_rec.oipl_id,hr_api.g_number)
130 or not l_api_updating)
131 and p_oipl_id is not null then
132 --
133 -- check if oipl_id value exists in ben_oipl_f table
134 --
135 open c1;
136 --
137 fetch c1 into l_dummy;
138 if c1%notfound then
139 --
140 close c1;
141 --
142 -- raise error as FK does not relate to PK in ben_oipl_f
143 -- table.
144 --
145 ben_bei_shd.constraint_error('BEN_BATCH_ELIG_INFO_DT4');
146 --
147 end if;
148 --
149 close c1;
150 --
151 end if;
152 --
153 hr_utility.set_location('Leaving:'||l_proc,10);
154 --
155 End chk_oipl_id;
156 --
157 -- ----------------------------------------------------------------------------
158 -- |----------------------------< chk_pl_id >---------------------------------|
159 -- ----------------------------------------------------------------------------
160 --
161 -- Description
162 -- This procedure checks that a referenced foreign key actually exists
163 -- in the referenced table.
164 --
165 -- Pre-Conditions
166 -- None.
167 --
168 -- In Parameters
169 -- p_batch_elig_id PK
170 -- p_pl_id ID of FK column
171 -- p_effective_date Session Date of record
172 -- p_object_version_number object version number
173 --
174 -- Post Success
175 -- Processing continues
176 --
177 -- Post Failure
178 -- Error raised.
179 --
180 -- Access Status
181 -- Internal table handler use only.
182 --
183 Procedure chk_pl_id (p_batch_elig_id in number,
184 p_pl_id in number,
185 p_effective_date in date,
186 p_object_version_number in number) is
187 --
188 l_proc varchar2(72) := g_package||'chk_pl_id';
189 l_api_updating boolean;
190 l_dummy varchar2(1);
191 --
192 cursor c1 is
193 select null
194 from ben_pl_f a
195 where a.pl_id = p_pl_id
196 and p_effective_date
197 between a.effective_start_date
198 and a.effective_end_date;
199 --
200 Begin
201 --
202 hr_utility.set_location('Entering:'||l_proc,5);
203 --
204 l_api_updating := ben_bei_shd.api_updating
205 (p_batch_elig_id => p_batch_elig_id,
206 p_object_version_number => p_object_version_number);
207 --
208 if (l_api_updating
209 and nvl(p_pl_id,hr_api.g_number)
210 <> nvl(ben_bei_shd.g_old_rec.pl_id,hr_api.g_number)
211 or not l_api_updating)
212 and p_pl_id is not null then
213 --
214 -- check if pl_id value exists in ben_pl_f table
215 --
216 open c1;
217 --
218 fetch c1 into l_dummy;
219 if c1%notfound then
220 --
221 close c1;
222 --
223 -- raise error as FK does not relate to PK in ben_pl_f
224 -- table.
225 --
226 ben_bei_shd.constraint_error('BEN_BATCH_ELIG_INFO_DT3');
227 --
228 end if;
229 --
230 close c1;
231 --
232 end if;
233 --
234 hr_utility.set_location('Leaving:'||l_proc,10);
235 --
236 End chk_pl_id;
237 --
238 -- ----------------------------------------------------------------------------
239 -- |-------------------------------< chk_pgm_id >-----------------------------|
240 -- ----------------------------------------------------------------------------
241 --
242 -- Description
243 -- This procedure checks that a referenced foreign key actually exists
244 -- in the referenced table.
245 --
246 -- Pre-Conditions
247 -- None.
248 --
249 -- In Parameters
250 -- p_batch_elig_id PK
251 -- p_pgm_id ID of FK column
252 -- p_effective_date Session Date of record
253 -- p_object_version_number object version number
254 --
255 -- Post Success
256 -- Processing continues
257 --
258 -- Post Failure
259 -- Error raised.
260 --
261 -- Access Status
262 -- Internal table handler use only.
263 --
264 Procedure chk_pgm_id (p_batch_elig_id in number,
265 p_pgm_id in number,
266 p_effective_date in date,
267 p_object_version_number in number) is
268 --
269 l_proc varchar2(72) := g_package||'chk_pgm_id';
270 l_api_updating boolean;
271 l_dummy varchar2(1);
272 --
273 cursor c1 is
274 select null
275 from ben_pgm_f a
276 where a.pgm_id = p_pgm_id
277 and p_effective_date
278 between a.effective_start_date
279 and a.effective_end_date;
280 --
281 Begin
282 --
283 hr_utility.set_location('Entering:'||l_proc,5);
284 --
285 l_api_updating := ben_bei_shd.api_updating
286 (p_batch_elig_id => p_batch_elig_id,
287 p_object_version_number => p_object_version_number);
288 --
289 if (l_api_updating
290 and nvl(p_pgm_id,hr_api.g_number)
291 <> nvl(ben_bei_shd.g_old_rec.pgm_id,hr_api.g_number)
292 or not l_api_updating)
293 and p_pgm_id is not null then
294 --
295 -- check if pgm_id value exists in ben_pgm_f table
296 --
297 open c1;
298 --
299 fetch c1 into l_dummy;
300 if c1%notfound then
301 --
302 close c1;
303 --
304 -- raise error as FK does not relate to PK in ben_pgm_f
305 -- table.
306 --
307 ben_bei_shd.constraint_error('BEN_BATCH_ELIG_INFO_DT2');
308 --
309 end if;
310 --
311 close c1;
312 --
313 end if;
314 --
315 hr_utility.set_location('Leaving:'||l_proc,10);
316 --
317 End chk_pgm_id;
318 --
319 -- ----------------------------------------------------------------------------
320 -- |-------------------------< chk_person_id >--------------------------------|
321 -- ----------------------------------------------------------------------------
322 --
323 -- Description
324 -- This procedure checks that a referenced foreign key actually exists
325 -- in the referenced table.
326 --
327 -- Pre-Conditions
328 -- None.
329 --
330 -- In Parameters
331 -- p_batch_elig_id PK
332 -- p_person_id ID of FK column
333 -- p_effective_date Session Date of record
334 -- p_object_version_number object version number
335 --
336 -- Post Success
337 -- Processing continues
338 --
339 -- Post Failure
340 -- Error raised.
341 --
342 -- Access Status
343 -- Internal table handler use only.
344 --
345 Procedure chk_person_id (p_batch_elig_id in number,
346 p_person_id in number,
347 p_effective_date in date,
348 p_object_version_number in number) is
349 --
350 l_proc varchar2(72) := g_package||'chk_person_id';
351 l_api_updating boolean;
352 l_dummy varchar2(1);
353 --
354 cursor c1 is
355 select null
356 from per_all_people_f a
357 where a.person_id = p_person_id
358 and p_effective_date
359 between a.effective_start_date
360 and a.effective_end_date;
361 --
362 Begin
363 --
364 hr_utility.set_location('Entering:'||l_proc,5);
365 --
366 l_api_updating := ben_bei_shd.api_updating
367 (p_batch_elig_id => p_batch_elig_id,
368 p_object_version_number => p_object_version_number);
369 --
370 if (l_api_updating
371 and nvl(p_person_id,hr_api.g_number)
372 <> nvl(ben_bei_shd.g_old_rec.person_id,hr_api.g_number)
373 or not l_api_updating) then
374 --
375 -- check if person_id value exists in per_all_people_f table
376 --
377 open c1;
378 --
379 fetch c1 into l_dummy;
380 if c1%notfound then
381 --
382 close c1;
383 --
384 -- raise error as FK does not relate to PK in per_all_people_f
385 -- table.
386 --
387 ben_bei_shd.constraint_error('BEN_BATCH_ELIG_INFO_DT1');
388 --
389 end if;
390 --
391 close c1;
392 --
393 end if;
394 --
395 hr_utility.set_location('Leaving:'||l_proc,10);
396 --
397 End chk_person_id;
398 --
399 -- ----------------------------------------------------------------------------
400 -- |--------------------------< chk_benefit_action_id >-----------------------|
401 -- ----------------------------------------------------------------------------
402 --
403 -- Description
404 -- This procedure checks that a referenced foreign key actually exists
405 -- in the referenced table.
406 --
407 -- Pre-Conditions
408 -- None.
409 --
410 -- In Parameters
411 -- p_batch_elig_id PK
412 -- p_benefit_action_id ID of FK column
413 -- p_object_version_number object version number
414 --
415 -- Post Success
416 -- Processing continues
417 --
418 -- Post Failure
419 -- Error raised.
420 --
421 -- Access Status
422 -- Internal table handler use only.
423 --
424 Procedure chk_benefit_action_id (p_batch_elig_id in number,
425 p_benefit_action_id in number,
426 p_object_version_number in number) is
427 --
428 l_proc varchar2(72) := g_package||'chk_benefit_action_id';
429 l_api_updating boolean;
430 l_dummy varchar2(1);
431 --
432 cursor c1 is
433 select null
434 from ben_benefit_actions a
435 where a.benefit_action_id = p_benefit_action_id;
436 --
437 Begin
438 --
439 hr_utility.set_location('Entering:'||l_proc,5);
440 --
441 l_api_updating := ben_bei_shd.api_updating
442 (p_batch_elig_id => p_batch_elig_id,
443 p_object_version_number => p_object_version_number);
444 --
445 if (l_api_updating
446 and nvl(p_benefit_action_id,hr_api.g_number)
447 <> nvl(ben_bei_shd.g_old_rec.benefit_action_id,hr_api.g_number)
448 or not l_api_updating) then
449 --
450 -- check if benefit_action_id value exists in ben_benefit_actions table
451 --
452 open c1;
453 --
454 fetch c1 into l_dummy;
455 if c1%notfound then
456 --
457 close c1;
458 --
459 -- raise error as FK does not relate to PK in ben_benefit_actions
460 -- table.
461 --
462 ben_bei_shd.constraint_error('BEN_BATCH_ELIG_INFO_FK1');
463 --
464 end if;
465 --
466 close c1;
467 --
468 end if;
469 --
470 hr_utility.set_location('Leaving:'||l_proc,10);
471 --
472 End chk_benefit_action_id;
473 --
474 -- ----------------------------------------------------------------------------
475 -- |--------------------------< chk_elig_flag >-------------------------------|
476 -- ----------------------------------------------------------------------------
477 --
478 -- Description
479 -- This procedure is used to check that the lookup value is valid.
480 --
481 -- Pre Conditions
482 -- None.
483 --
484 -- In Parameters
485 -- batch_elig_id PK of record being inserted or updated.
486 -- elig_flag Value of lookup code.
487 -- effective_date effective date
488 -- object_version_number Object version number of record being
489 -- inserted or updated.
490 --
491 -- Post Success
492 -- Processing continues
493 --
494 -- Post Failure
495 -- Error handled by procedure
496 --
497 -- Access Status
498 -- Internal table handler use only.
499 --
500 Procedure chk_elig_flag(p_batch_elig_id in number,
501 p_elig_flag in varchar2,
502 p_effective_date in date,
503 p_object_version_number in number) is
504 --
505 l_proc varchar2(72) := g_package||'chk_elig_flag';
506 l_api_updating boolean;
507 --
508 Begin
509 --
510 hr_utility.set_location('Entering:'||l_proc, 5);
511 --
512 l_api_updating := ben_bei_shd.api_updating
513 (p_batch_elig_id => p_batch_elig_id,
514 p_object_version_number => p_object_version_number);
515 --
516 if (l_api_updating
517 and p_elig_flag
518 <> nvl(ben_bei_shd.g_old_rec.elig_flag,hr_api.g_varchar2)
519 or not l_api_updating) then
520 --
521 -- check if value of lookup falls within lookup type.
522 --
523 --
524 if hr_api.not_exists_in_hr_lookups
525 (p_lookup_type => 'YES_NO',
526 p_lookup_code => p_elig_flag,
527 p_effective_date => p_effective_date) then
528 --
529 -- raise error as does not exist as lookup
530 --
531 fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
532 fnd_message.set_token('FIELD','p_elig_flag');
533 fnd_message.set_token('TYPE','YES_NO');
534 fnd_message.raise_error;
535 --
536 end if;
537 --
538 end if;
539 --
540 hr_utility.set_location('Leaving:'||l_proc,10);
541 --
542 end chk_elig_flag;
543 --
544 -- ----------------------------------------------------------------------------
545 -- |---------------------------< insert_validate >----------------------------|
546 -- ----------------------------------------------------------------------------
547 Procedure insert_validate(p_rec in ben_bei_shd.g_rec_type
548 ,p_effective_date in date) is
549 --
550 l_proc varchar2(72) := g_package||'insert_validate';
551 --
552 Begin
553 hr_utility.set_location('Entering:'||l_proc, 5);
554 --
555 -- Call all supporting business operations
556 --
557 --
558 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
559 --
560 chk_batch_elig_id
561 (p_batch_elig_id => p_rec.batch_elig_id,
562 p_object_version_number => p_rec.object_version_number);
563 --
564 chk_oipl_id
565 (p_batch_elig_id => p_rec.batch_elig_id,
566 p_oipl_id => p_rec.oipl_id,
567 p_effective_date => p_effective_date,
568 p_object_version_number => p_rec.object_version_number);
569 --
570 chk_pl_id
571 (p_batch_elig_id => p_rec.batch_elig_id,
572 p_pl_id => p_rec.pl_id,
573 p_effective_date => p_effective_date,
574 p_object_version_number => p_rec.object_version_number);
575 --
576 chk_pgm_id
577 (p_batch_elig_id => p_rec.batch_elig_id,
578 p_pgm_id => p_rec.pgm_id,
579 p_effective_date => p_effective_date,
580 p_object_version_number => p_rec.object_version_number);
581 --
582 chk_person_id
583 (p_batch_elig_id => p_rec.batch_elig_id,
584 p_person_id => p_rec.person_id,
585 p_effective_date => p_effective_date,
586 p_object_version_number => p_rec.object_version_number);
587 --
588 chk_benefit_action_id
589 (p_batch_elig_id => p_rec.batch_elig_id,
590 p_benefit_action_id => p_rec.benefit_action_id,
591 p_object_version_number => p_rec.object_version_number);
592 --
593 chk_elig_flag
594 (p_batch_elig_id => p_rec.batch_elig_id,
595 p_elig_flag => p_rec.elig_flag,
596 p_effective_date => p_effective_date,
600 End insert_validate;
597 p_object_version_number => p_rec.object_version_number);
598 --
599 hr_utility.set_location(' Leaving:'||l_proc, 10);
601 --
602 -- ----------------------------------------------------------------------------
603 -- |---------------------------< update_validate >----------------------------|
604 -- ----------------------------------------------------------------------------
605 Procedure update_validate(p_rec in ben_bei_shd.g_rec_type
606 ,p_effective_date in date) is
607 --
608 l_proc varchar2(72) := g_package||'update_validate';
609 --
610 Begin
611 hr_utility.set_location('Entering:'||l_proc, 5);
612 --
613 -- Call all supporting business operations
614 --
615 --
616 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
617 --
618 chk_batch_elig_id
619 (p_batch_elig_id => p_rec.batch_elig_id,
620 p_object_version_number => p_rec.object_version_number);
621 --
622 chk_oipl_id
623 (p_batch_elig_id => p_rec.batch_elig_id,
624 p_oipl_id => p_rec.oipl_id,
625 p_effective_date => p_effective_date,
626 p_object_version_number => p_rec.object_version_number);
627 --
628 chk_pl_id
629 (p_batch_elig_id => p_rec.batch_elig_id,
630 p_pl_id => p_rec.pl_id,
631 p_effective_date => p_effective_date,
632 p_object_version_number => p_rec.object_version_number);
633 --
634 chk_pgm_id
635 (p_batch_elig_id => p_rec.batch_elig_id,
636 p_pgm_id => p_rec.pgm_id,
637 p_effective_date => p_effective_date,
638 p_object_version_number => p_rec.object_version_number);
639 --
640 chk_person_id
641 (p_batch_elig_id => p_rec.batch_elig_id,
642 p_person_id => p_rec.person_id,
643 p_effective_date => p_effective_date,
644 p_object_version_number => p_rec.object_version_number);
645 --
646 chk_benefit_action_id
647 (p_batch_elig_id => p_rec.batch_elig_id,
648 p_benefit_action_id => p_rec.benefit_action_id,
649 p_object_version_number => p_rec.object_version_number);
650 --
651 chk_elig_flag
652 (p_batch_elig_id => p_rec.batch_elig_id,
653 p_elig_flag => p_rec.elig_flag,
654 p_effective_date => p_effective_date,
655 p_object_version_number => p_rec.object_version_number);
656 --
657 hr_utility.set_location(' Leaving:'||l_proc, 10);
658 End update_validate;
659 --
660 -- ----------------------------------------------------------------------------
661 -- |---------------------------< delete_validate >----------------------------|
662 -- ----------------------------------------------------------------------------
663 Procedure delete_validate(p_rec in ben_bei_shd.g_rec_type
664 ,p_effective_date in date) is
665 --
666 l_proc varchar2(72) := g_package||'delete_validate';
667 --
668 Begin
669 hr_utility.set_location('Entering:'||l_proc, 5);
670 --
671 -- Call all supporting business operations
672 --
673 hr_utility.set_location(' Leaving:'||l_proc, 10);
674 End delete_validate;
675 --
676 --
677 -- ---------------------------------------------------------------------------
678 -- |---------------------< return_legislation_code >-------------------------|
679 -- ---------------------------------------------------------------------------
680 --
681 function return_legislation_code
682 (p_batch_elig_id in number) return varchar2 is
683 --
684 -- Declare cursor
685 --
686 cursor csr_leg_code is
687 select a.legislation_code
688 from per_business_groups a,
689 ben_batch_elig_info b
690 where b.batch_elig_id = p_batch_elig_id
691 and a.business_group_id = b.business_group_id;
692 --
693 -- Declare local variables
694 --
695 l_legislation_code varchar2(150);
696 l_proc varchar2(72) := g_package||'return_legislation_code';
697 --
698 begin
699 --
700 hr_utility.set_location('Entering:'|| l_proc, 10);
701 --
702 -- Ensure that all the mandatory parameter are not null
703 --
704 hr_api.mandatory_arg_error(p_api_name => l_proc,
705 p_argument => 'batch_elig_id',
706 p_argument_value => p_batch_elig_id);
707 --
708 open csr_leg_code;
709 --
710 fetch csr_leg_code into l_legislation_code;
711 --
712 if csr_leg_code%notfound then
713 --
714 close csr_leg_code;
715 --
716 -- The primary key is invalid therefore we must error
717 --
718 hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
719 hr_utility.raise_error;
720 --
721 end if;
722 --
723 close csr_leg_code;
724 --
725 hr_utility.set_location(' Leaving:'|| l_proc, 20);
726 --
727 return l_legislation_code;
728 --
729 end return_legislation_code;
730 --
731 end ben_bei_bus;