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