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