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