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