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