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