[Home] [Help]
PACKAGE BODY: APPS.BEN_ELS_BUS
Source
1 Package Body ben_els_bus as
2 /* $Header: beelsrhi.pkb 120.1 2006/02/27 02:24:32 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_els_bus.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_elig_los_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_los_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_los_prte_id(p_elig_los_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_los_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_els_shd.api_updating
49 (p_effective_date => p_effective_date,
50 p_elig_los_prte_id => p_elig_los_prte_id,
51 p_object_version_number => p_object_version_number);
52 --
53 if (l_api_updating
54 and nvl(p_elig_los_prte_id,hr_api.g_number)
55 <> ben_els_shd.g_old_rec.elig_los_prte_id) then
56 --
57 -- raise error as PK has changed
58 --
59 ben_els_shd.constraint_error('BEN_ELIG_LOS_PRTE_PK');
60 --
61 elsif not l_api_updating then
62 --
63 -- check if PK is null
64 --
65 if p_elig_los_prte_id is not null then
66 --
67 -- raise error as PK is not null
68 --
69 ben_els_shd.constraint_error('BEN_ELIG_LOS_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_los_prte_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |------< chk_los_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_los_prte_id PK
92 -- p_los_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_los_fctr_id (p_elig_los_prte_id in number,
106 p_los_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_effective_date in date,
111 p_business_group_id in number,
112 p_object_version_number in number) is
113 --
114 l_proc varchar2(72) := g_package||'chk_los_fctr_id';
115 l_api_updating boolean;
116 l_dummy varchar2(1);
117 l_exists varchar2(1);
118 --
119 cursor c3 is
120 select null
121 from ben_elig_los_prte_f
122 where los_fctr_id = p_los_fctr_id
123 and eligy_prfl_id = p_eligy_prfl_id
124 and elig_los_prte_id <> nvl(p_elig_los_prte_id,hr_api.g_number)
125 and business_group_id + 0 = p_business_group_id
126 and p_validation_start_date <= effective_end_date
127 and p_validation_end_date >= effective_start_date
128 ;
129 --
130 --
131 cursor c1 is
132 select null
133 from ben_los_fctr a
134 where a.los_fctr_id = p_los_fctr_id
135 and a.business_group_id + 0 = p_business_group_id;
136 --
137 Begin
138 --
139 hr_utility.set_location('Entering:'||l_proc,5);
140 --
141 l_api_updating := ben_els_shd.api_updating
142 (p_elig_los_prte_id => p_elig_los_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_los_fctr_id,hr_api.g_number)
148 <> nvl(ben_els_shd.g_old_rec.los_fctr_id,hr_api.g_number)
149 or not l_api_updating) then
150 --
151 -- check if los_fctr_id value exists in ben_los_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_los_fctr
161 -- table.
162 --
163 ben_els_shd.constraint_error('BEN_ELIG_LOS_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_los_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_los_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_los_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
224 --
225 hr_utility.set_location('Entering:'||l_proc, 5);
226 --
227 l_api_updating := ben_els_shd.api_updating
228 (p_elig_los_prte_id => p_elig_los_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_els_shd.g_old_rec.excld_flag,hr_api.g_varchar2)
235 or not l_api_updating)
236 and p_excld_flag is not null then
237 --
238 -- check if value of lookup falls within lookup type.
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 fnd_message.set_name('PAY','HR_LOOKUP_DOES_NOT_EXIST');
248 fnd_message.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_los_prte_id elig_los_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_los_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_los_prte_f
297 where elig_los_prte_id <> nvl(p_elig_los_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 --
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',
385 p_base_key_column => 'eligy_prfl_id',
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 fnd_message.set_name('PAY', 'HR_7216_DT_UPD_INTEGRITY_ERR');
403 fnd_message.set_token('TABLE_NAME', l_table_name);
404 fnd_message.raise_error;
405 When Others Then
406 --
407 -- An unhandled or unexpected error has occurred which
408 -- we must report
409 --
410 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
411 fnd_message.set_token('PROCEDURE', l_proc);
412 fnd_message.set_token('STEP','15');
413 fnd_message.raise_error;
414 End dt_update_validate;
415 --
416 -- ----------------------------------------------------------------------------
417 -- |--------------------------< dt_delete_validate >--------------------------|
418 -- ----------------------------------------------------------------------------
419 -- {Start Of Comments}
420 --
421 -- Description:
422 -- This procedure is used for referential integrity of datetracked
423 -- child entities when either a datetrack DELETE or ZAP is in operation
424 -- and where there is no cascading of delete defined for this entity.
425 -- For the datetrack mode of DELETE or ZAP we must ensure that no
426 -- datetracked child rows exist between the validation start and end
427 -- dates.
428 --
429 -- Prerequisites:
430 -- This procedure is called from the delete_validate.
431 --
432 -- In Parameters:
433 --
434 -- Post Success:
435 -- Processing continues.
436 --
440 -- the use of the local exception handler l_rows_exist.
437 -- Post Failure:
438 -- If a row exists by determining the returning Boolean value from the
439 -- generic dt_api.rows_exist function then we must supply an error via
441 --
442 -- Developer Implementation Notes:
443 -- This procedure should not need maintenance unless the HR Schema model
444 -- changes.
445 --
446 -- Access Status:
447 -- Internal Row Handler Use Only.
448 --
449 -- {End Of Comments}
450 -- ----------------------------------------------------------------------------
451 Procedure dt_delete_validate
452 (p_elig_los_prte_id in number,
453 p_datetrack_mode in varchar2,
454 p_validation_start_date in date,
455 p_validation_end_date in date) Is
456 --
457 l_proc varchar2(72) := g_package||'dt_delete_validate';
458 l_rows_exist Exception;
459 l_table_name all_tables.table_name%TYPE;
460 --
461 Begin
462 hr_utility.set_location('Entering:'||l_proc, 5);
463 --
464 -- Ensure that the p_datetrack_mode argument is not null
465 --
466 hr_api.mandatory_arg_error
467 (p_api_name => l_proc,
468 p_argument => 'datetrack_mode',
469 p_argument_value => p_datetrack_mode);
470 --
471 -- Only perform the validation if the datetrack mode is either
472 -- DELETE or ZAP
473 --
474 If (p_datetrack_mode = 'DELETE' or
475 p_datetrack_mode = 'ZAP') then
476 --
477 --
478 -- Ensure the arguments are not null
479 --
480 hr_api.mandatory_arg_error
481 (p_api_name => l_proc,
482 p_argument => 'validation_start_date',
483 p_argument_value => p_validation_start_date);
484 --
485 hr_api.mandatory_arg_error
486 (p_api_name => l_proc,
487 p_argument => 'validation_end_date',
488 p_argument_value => p_validation_end_date);
489 --
490 hr_api.mandatory_arg_error
491 (p_api_name => l_proc,
492 p_argument => 'elig_los_prte_id',
493 p_argument_value => p_elig_los_prte_id);
494 --
495 --
496 --
497 End If;
498 --
499 hr_utility.set_location(' Leaving:'||l_proc, 10);
500 Exception
501 When l_rows_exist Then
502 --
503 -- A referential integrity check was violated therefore
504 -- we must error
505 --
506 fnd_message.set_name('PAY', 'HR_7215_DT_CHILD_EXISTS');
507 fnd_message.set_token('TABLE_NAME', l_table_name);
508 fnd_message.raise_error;
509 When Others Then
510 --
511 -- An unhandled or unexpected error has occurred which
512 -- we must report
513 --
514 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
515 fnd_message.set_token('PROCEDURE', l_proc);
516 fnd_message.set_token('STEP','15');
517 fnd_message.raise_error;
518 End dt_delete_validate;
519 --
520 -- ----------------------------------------------------------------------------
521 -- |---------------------------< insert_validate >----------------------------|
522 -- ----------------------------------------------------------------------------
523 Procedure insert_validate
524 (p_rec in ben_els_shd.g_rec_type,
525 p_effective_date in date,
526 p_datetrack_mode in varchar2,
527 p_validation_start_date in date,
528 p_validation_end_date in date) is
529 --
530 l_proc varchar2(72) := g_package||'insert_validate';
531 --
532 Begin
533 hr_utility.set_location('Entering:'||l_proc, 5);
534 --
535 -- Call all supporting business operations
536 --
537 --
538 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
539 --
540 chk_elig_los_prte_id
541 (p_elig_los_prte_id => p_rec.elig_los_prte_id,
542 p_effective_date => p_effective_date,
543 p_object_version_number => p_rec.object_version_number);
544 --
545 chk_los_fctr_id
546 (p_elig_los_prte_id => p_rec.elig_los_prte_id,
547 p_los_fctr_id => p_rec.los_fctr_id,
548 p_eligy_prfl_id => p_rec.eligy_prfl_id,
549 p_validation_start_date => p_validation_start_date,
550 p_validation_end_date => p_validation_end_date,
551 p_effective_date => p_effective_date,
552 p_business_group_id => p_rec.business_group_id,
553 p_object_version_number => p_rec.object_version_number);
554 --
555 chk_excld_flag
556 (p_elig_los_prte_id => p_rec.elig_los_prte_id,
557 p_excld_flag => p_rec.excld_flag,
558 p_effective_date => p_effective_date,
559 p_object_version_number => p_rec.object_version_number);
560 --
561 chk_duplicate_ordr_num
562 ( p_elig_los_prte_id => p_rec.elig_los_prte_id
563 ,p_eligy_prfl_id => p_rec.eligy_prfl_id
564 ,p_ordr_num => p_rec.ordr_num
565 ,p_business_group_id => p_rec.business_group_id);
566 --
567 hr_utility.set_location(' Leaving:'||l_proc, 10);
568 End insert_validate;
569 --
570 -- ----------------------------------------------------------------------------
571 -- |---------------------------< update_validate >----------------------------|
572 -- ----------------------------------------------------------------------------
573 Procedure update_validate
577 p_validation_start_date in date,
574 (p_rec in ben_els_shd.g_rec_type,
575 p_effective_date in date,
576 p_datetrack_mode in varchar2,
578 p_validation_end_date in date) is
579 --
580 l_proc varchar2(72) := g_package||'update_validate';
581 --
582 Begin
583 hr_utility.set_location('Entering:'||l_proc, 5);
584 --
585 -- Call all supporting business operations
586 --
587 --
588 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
589 --
590 chk_elig_los_prte_id
591 (p_elig_los_prte_id => p_rec.elig_los_prte_id,
592 p_effective_date => p_effective_date,
593 p_object_version_number => p_rec.object_version_number);
594 --
595 chk_los_fctr_id
596 (p_elig_los_prte_id => p_rec.elig_los_prte_id,
597 p_los_fctr_id => p_rec.los_fctr_id,
598 p_eligy_prfl_id => p_rec.eligy_prfl_id,
599 p_validation_start_date => p_validation_start_date,
600 p_validation_end_date => p_validation_end_date,
601 p_effective_date => p_effective_date,
602 p_business_group_id => p_rec.business_group_id,
603 p_object_version_number => p_rec.object_version_number);
604 --
605 chk_excld_flag
606 (p_elig_los_prte_id => p_rec.elig_los_prte_id,
607 p_excld_flag => p_rec.excld_flag,
608 p_effective_date => p_effective_date,
609 p_object_version_number => p_rec.object_version_number);
610 --
611 chk_duplicate_ordr_num
612 ( p_elig_los_prte_id => p_rec.elig_los_prte_id
613 ,p_eligy_prfl_id => p_rec.eligy_prfl_id
614 ,p_ordr_num => p_rec.ordr_num
615 ,p_business_group_id => p_rec.business_group_id);
616 --
617 -- Call the datetrack update integrity operation
618 --
619 dt_update_validate
620 (p_eligy_prfl_id => p_rec.eligy_prfl_id,
621 p_datetrack_mode => p_datetrack_mode,
622 p_validation_start_date => p_validation_start_date,
623 p_validation_end_date => p_validation_end_date);
624 --
625 hr_utility.set_location(' Leaving:'||l_proc, 10);
626 End update_validate;
627 --
628 -- ----------------------------------------------------------------------------
629 -- |---------------------------< delete_validate >----------------------------|
630 -- ----------------------------------------------------------------------------
631 Procedure delete_validate
632 (p_rec in ben_els_shd.g_rec_type,
633 p_effective_date in date,
634 p_datetrack_mode in varchar2,
635 p_validation_start_date in date,
636 p_validation_end_date in date) is
637 --
638 l_proc varchar2(72) := g_package||'delete_validate';
639 --
640 Begin
641 hr_utility.set_location('Entering:'||l_proc, 5);
642 --
643 -- Call all supporting business operations
644 --
645 dt_delete_validate
646 (p_datetrack_mode => p_datetrack_mode,
647 p_validation_start_date => p_validation_start_date,
648 p_validation_end_date => p_validation_end_date,
649 p_elig_los_prte_id => p_rec.elig_los_prte_id);
650 --
651 hr_utility.set_location(' Leaving:'||l_proc, 10);
652 End delete_validate;
653 --
654 --
655 -- ---------------------------------------------------------------------------
656 -- |---------------------< return_legislation_code >-------------------------|
657 -- ---------------------------------------------------------------------------
658 --
659 function return_legislation_code
660 (p_elig_los_prte_id in number) return varchar2 is
661 --
662 -- Declare cursor
663 --
664 cursor csr_leg_code is
665 select a.legislation_code
666 from per_business_groups a,
667 ben_elig_los_prte_f b
668 where b.elig_los_prte_id = p_elig_los_prte_id
669 and a.business_group_id = b.business_group_id;
670 --
671 -- Declare local variables
672 --
673 l_legislation_code varchar2(150);
674 l_proc varchar2(72) := g_package||'return_legislation_code';
675 --
676 begin
677 --
678 hr_utility.set_location('Entering:'|| l_proc, 10);
679 --
680 -- Ensure that all the mandatory parameter are not null
681 --
682 hr_api.mandatory_arg_error(p_api_name => l_proc,
683 p_argument => 'elig_los_prte_id',
684 p_argument_value => p_elig_los_prte_id);
685 --
686 open csr_leg_code;
687 --
688 fetch csr_leg_code into l_legislation_code;
689 --
690 if csr_leg_code%notfound then
691 --
692 close csr_leg_code;
693 --
694 -- The primary key is invalid therefore we must error
695 --
696 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
697 fnd_message.raise_error;
698 --
699 end if;
700 --
701 close csr_leg_code;
702 --
703 hr_utility.set_location(' Leaving:'|| l_proc, 20);
704 --
705 return l_legislation_code;
706 --
707 end return_legislation_code;
708 --
709 end ben_els_bus;