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