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