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