[Home] [Help]
PACKAGE BODY: APPS.BEN_BRG_BUS
Source
1 Package Body ben_brg_bus as
2 /* $Header: bebrgrhi.pkb 120.0.12010000.3 2008/08/25 14:13:28 ppentapa ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_brg_bus.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_benfts_grp_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 -- benfts_grp_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_benfts_grp_rt_id(p_benfts_grp_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_benfts_grp_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_brg_shd.api_updating
49 (p_effective_date => p_effective_date,
50 p_benfts_grp_rt_id => p_benfts_grp_rt_id,
51 p_object_version_number => p_object_version_number);
52 --
53 if (l_api_updating
54 and nvl(p_benfts_grp_rt_id,hr_api.g_number)
55 <> ben_brg_shd.g_old_rec.benfts_grp_rt_id) then
56 --
57 -- raise error as PK has changed
58 --
59 ben_brg_shd.constraint_error('BEN_BENFTS_GRP_RT_F_PK');
60 --
61 elsif not l_api_updating then
62 --
63 -- check if PK is null
64 --
65 if p_benfts_grp_rt_id is not null then
66 --
67 -- raise error as PK is not null
68 --
69 ben_brg_shd.constraint_error('BEN_BENFTS_GRP_RT_F_PK');
70 --
71 end if;
72 --
73 end if;
74 --
75 hr_utility.set_location('Leaving:'||l_proc, 10);
76 --
77 End chk_benfts_grp_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_benfts_grp_id in number
106 ,p_ordr_num in number
107 ,p_effective_date in date
108 ,p_business_group_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_benfts_grp_rt_f
114 where vrbl_rt_prfl_id = p_vrbl_rt_prfl_id
115 and benfts_grp_id <> nvl(p_benfts_grp_id,-1)
116 and p_effective_date between effective_start_date
117 and effective_end_date
118 and business_group_id + 0 = p_business_group_id
119 and ordr_num = p_ordr_num;
120 --
124 --
121 Begin
122 hr_utility.set_location('Entering:'||l_proc, 5);
123
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 -- benfts_grp_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_benfts_grp_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_brg_shd.api_updating
177 (p_benfts_grp_rt_id => p_benfts_grp_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_brg_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,
192 p_effective_date => p_effective_date) then
193 --
194 -- raise error as does not exist as lookup
195 --
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_benfts_grp_id >----------------------------|
209 -- ----------------------------------------------------------------------------
210 --
211 -- Description
212 -- This procedure is used to check that the foreign key for the table
213 -- is created properly. a corresponding record should exist in the
214 -- BEN_BENFTS_GRP table.
215 --
216 -- Pre Conditions
217 -- None.
218 --
219 -- In Parameters
220 -- benfts_grp_id FK of pointing to BEN_BENFTS_GRP tables.
221 -- business_group_id or record being inserted or updated
222 --
223 -- Post Success
224 -- Processing continues
225 --
226 -- Post Failure
227 -- Errors handled by the procedure
228 --
229 -- Access Status
230 -- Internal table handler use only.
231 --
232 Procedure chk_benfts_grp_id(p_benfts_grp_id in number,
233 p_business_group_id in number) is
234 --
235 l_proc varchar2(72) := g_package||'chk_benfts_grp_id';
236 l_dummy varchar2(1);
237 cursor c1 is select null
238 from BEN_BENFTS_GRP
239 where benfts_grp_id = p_benfts_grp_id
240 and business_group_id = p_business_group_id;
241 --
242
243 Begin
244 --
245 hr_utility.set_location('Entering:'||l_proc, 5);
246 --
247 if p_benfts_grp_id is not null then
248 open c1;
249 fetch c1 into l_dummy;
250 if c1%notfound then
251 hr_utility.set_message(801,'Benfts_Grp_NotExist');
252 hr_utility.raise_error;
253 end if;
254 close c1;
255 end if;
256 --
257 hr_utility.set_location('Leaving:'||l_proc, 10);
258 --
259 End chk_benfts_grp_id;
260
261 --
262 -- ----------------------------------------------------------------------------
263 -- |------< chk_dup_record >------|
264 -- ----------------------------------------------------------------------------
265 --
266 -- Description
267 -- This procedure is used to check that there is no duplicate record
268 --
269 -- Pre Conditions
270 -- None.
271 --
272 -- In Parameters
273 -- p_benfts_grp_rt_id PK of record being inserted or updated.
274 -- p_benfts_grp_id Value of FK.
275 -- p_vrbl_rt_prfl_id FK of the record
276 -- p_effective_date effective date
277 -- p_object_version_number Object version number of record being
278 -- inserted or updated.
279 -- p_business_group_id business_group_id of the record
280 -- p_validation_start_date validation_start_date of record
281 -- p_validation_end_date validation_end_date of record
282 --
286 -- Post Failure
283 -- Post Success
284 -- Processing continues
285 --
287 -- Error handled by procedure
288 --
289 -- Access Status
290 -- Internal table handler use only.
291 --
292 Procedure chk_dup_record
293 (p_benfts_grp_rt_id in number,
294 p_benfts_grp_id in number,
295 p_vrbl_rt_prfl_id in number,
296 p_effective_date in date,
297 p_object_version_number in number,
298 p_business_group_id in number,
299 p_validation_start_date in date,
300 p_validation_end_date in date )
301 is
302 --
303 l_proc varchar2(72) := g_package||'chk_dup_record';
304 l_api_updating boolean;
305 l_exists varchar2(1);
306 --
307 cursor c_dup is
308 select null
309 from ben_benfts_grp_rt_f
310 where benfts_grp_id = p_benfts_grp_id
311 and vrbl_rt_prfl_id = p_vrbl_rt_prfl_id
312 and benfts_grp_rt_id <> nvl(p_benfts_grp_rt_id,hr_api.g_number)
313 and business_group_id + 0 = p_business_group_id
314 and p_validation_start_date <= effective_end_date
315 and p_validation_end_date >= effective_start_date;
316 --
317 BEGIN
318 --
319 hr_utility.set_location('Entering:'||l_proc, 5);
320 --
321 l_api_updating := ben_brg_shd.api_updating
322 (p_benfts_grp_rt_id => p_benfts_grp_rt_id,
323 p_effective_date => p_effective_date,
324 p_object_version_number => p_object_version_number);
325 --
326 if (l_api_updating
327 and p_benfts_grp_id <> nvl(ben_brg_shd.g_old_rec.benfts_grp_id,hr_api.g_number)
328 or not l_api_updating) then
329
330 open c_dup;
331 fetch c_dup into l_exists;
332 if c_dup%found then
333 close c_dup;
334 --
335 -- raise error as this Benefits Group criteria already exists for this profile
336 --
337 fnd_message.set_name('BEN', 'BEN_92992_DUPS_ROW');
338 fnd_message.set_token('VAR1','Benefits Group criteria',TRUE);
339 fnd_message.set_token('VAR2','Variable Rate Profile',TRUE);
340 fnd_message.raise_error;
341 --
342 end if;
343 close c_dup;
344 --
345 end if;
346 hr_utility.set_location('Leaving:'||l_proc,10);
347 --
348 END chk_dup_record;
349
350 --
351 -- ----------------------------------------------------------------------------
352 -- |--------------------------< dt_update_validate >--------------------------|
353 -- ----------------------------------------------------------------------------
354 -- {Start Of Comments}
355 --
356 -- Description:
357 -- This procedure is used for referential integrity of datetracked
358 -- parent entities when a datetrack update operation is taking place
359 -- and where there is no cascading of update defined for this entity.
360 --
361 -- Prerequisites:
362 -- This procedure is called from the update_validate.
363 --
364 -- In Parameters:
365 --
366 -- Post Success:
367 -- Processing continues.
368 --
369 -- Post Failure:
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}
382 p_datetrack_mode in varchar2,
379 -- ----------------------------------------------------------------------------
380 Procedure dt_update_validate
381 (p_vrbl_rt_prfl_id in number default hr_api.g_number,
383 p_validation_start_date in date,
384 p_validation_end_date in date) Is
385 --
386 l_proc varchar2(72) := g_package||'dt_update_validate';
387 l_integrity_error 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 update mode is valid
401 --
402 If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
403 --
404 --
405 -- Ensure the arguments are not null
406 --
410 p_argument_value => p_validation_start_date);
407 hr_api.mandatory_arg_error
408 (p_api_name => l_proc,
409 p_argument => 'validation_start_date',
411 --
412 hr_api.mandatory_arg_error
413 (p_api_name => l_proc,
414 p_argument => 'validation_end_date',
415 p_argument_value => p_validation_end_date);
416 --
417 If ((nvl(p_vrbl_rt_prfl_id, hr_api.g_number) <> hr_api.g_number) and
418 NOT (dt_api.check_min_max_dates
419 (p_base_table_name => 'ben_vrbl_rt_prfl_f',
420 p_base_key_column => 'vrbl_rt_prfl_id',
421 p_base_key_value => p_vrbl_rt_prfl_id,
422 p_from_date => p_validation_start_date,
423 p_to_date => p_validation_end_date))) Then
424 l_table_name := 'ben_vrbl_rt_prfl_f';
425 Raise l_integrity_error;
426 End If;
427 --
428 End If;
429 --
430 hr_utility.set_location(' Leaving:'||l_proc, 10);
431 Exception
432 When l_integrity_error Then
433 --
434 -- A referential integrity check was violated therefore
435 -- we must error
436 --
437 ben_utility.parent_integrity_error (p_table_name => l_table_name);
438 --
439 When Others Then
440 --
441 -- An unhandled or unexpected error has occurred which
442 -- we must report
443 --
444 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
445 hr_utility.set_message_token('PROCEDURE', l_proc);
446 hr_utility.set_message_token('STEP','15');
447 hr_utility.raise_error;
448 End dt_update_validate;
449 --
450 -- ----------------------------------------------------------------------------
451 -- |--------------------------< dt_delete_validate >--------------------------|
452 -- ----------------------------------------------------------------------------
453 -- {Start Of Comments}
454 --
455 -- Description:
456 -- This procedure is used for referential integrity of datetracked
457 -- child entities when either a datetrack DELETE or ZAP is in operation
458 -- and where there is no cascading of delete defined for this entity.
459 -- For the datetrack mode of DELETE or ZAP we must ensure that no
460 -- datetracked child rows exist between the validation start and end
461 -- dates.
462 --
463 -- Prerequisites:
464 -- This procedure is called from the delete_validate.
465 --
466 -- In Parameters:
467 --
468 -- Post Success:
469 -- Processing continues.
470 --
471 -- Post Failure:
472 -- If a row exists by determining the returning Boolean value from the
473 -- generic dt_api.rows_exist function then we must supply an error via
474 -- the use of the local exception handler l_rows_exist.
475 --
476 -- Developer Implementation Notes:
477 -- This procedure should not need maintenance unless the HR Schema model
478 -- changes.
479 --
480 -- Access Status:
481 -- Internal Row Handler Use Only.
482 --
483 -- {End Of Comments}
484 -- ----------------------------------------------------------------------------
485 Procedure dt_delete_validate
486 (p_benfts_grp_rt_id in number,
487 p_datetrack_mode in varchar2,
488 p_validation_start_date in date,
489 p_validation_end_date in date) Is
490 --
491 l_proc varchar2(72) := g_package||'dt_delete_validate';
492 l_rows_exist Exception;
493 l_table_name all_tables.table_name%TYPE;
494 --
495 Begin
496 hr_utility.set_location('Entering:'||l_proc, 5);
497 --
498 -- Ensure that the p_datetrack_mode argument is not null
499 --
500 hr_api.mandatory_arg_error
501 (p_api_name => l_proc,
502 p_argument => 'datetrack_mode',
503 p_argument_value => p_datetrack_mode);
504 --
505 -- Only perform the validation if the datetrack mode is either
506 -- DELETE or ZAP
507 --
508 If (p_datetrack_mode = 'DELETE' or
509 p_datetrack_mode = 'ZAP') then
510 --
511 --
512 -- Ensure the arguments are not null
513 --
514 hr_api.mandatory_arg_error
515 (p_api_name => l_proc,
516 p_argument => 'validation_start_date',
517 p_argument_value => p_validation_start_date);
518 --
519 hr_api.mandatory_arg_error
520 (p_api_name => l_proc,
521 p_argument => 'validation_end_date',
522 p_argument_value => p_validation_end_date);
523 --
524 hr_api.mandatory_arg_error
525 (p_api_name => l_proc,
526 p_argument => 'benfts_grp_rt_id',
527 p_argument_value => p_benfts_grp_rt_id);
528 --
529 --
530 --
531 End If;
532 --
533 hr_utility.set_location(' Leaving:'||l_proc, 10);
534 Exception
535 When l_rows_exist Then
536 --
537 -- A referential integrity check was violated therefore
538 -- we must error
539 --
540 hr_utility.set_message(801, 'HR_7215_DT_CHILD_EXISTS');
541 hr_utility.set_message_token('TABLE_NAME', l_table_name);
542 hr_utility.raise_error;
543 When Others Then
544 --
545 -- An unhandled or unexpected error has occurred which
546 -- we must report
547 --
551 hr_utility.raise_error;
548 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
549 hr_utility.set_message_token('PROCEDURE', l_proc);
550 hr_utility.set_message_token('STEP','15');
552 End dt_delete_validate;
553 --
554 -- ----------------------------------------------------------------------------
558 (p_rec in ben_brg_shd.g_rec_type,
555 -- |---------------------------< insert_validate >----------------------------|
556 -- ----------------------------------------------------------------------------
557 Procedure insert_validate
559 p_effective_date in date,
560 p_datetrack_mode in varchar2,
561 p_validation_start_date in date,
562 p_validation_end_date in date) is
563 --
564 l_proc varchar2(72) := g_package||'insert_validate';
565 --
566 Begin
567 hr_utility.set_location('Entering:'||l_proc, 5);
568 --
569 -- Call all supporting business operations
570 --
571 --
572 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
573 --
574 chk_benfts_grp_rt_id
575 (p_benfts_grp_rt_id => p_rec.benfts_grp_rt_id,
576 p_effective_date => p_effective_date,
577 p_object_version_number => p_rec.object_version_number);
578 --
579 chk_excld_flag
580 (p_benfts_grp_rt_id => p_rec.benfts_grp_rt_id,
581 p_excld_flag => p_rec.excld_flag,
582 p_effective_date => p_effective_date,
583 p_object_version_number => p_rec.object_version_number);
584 --
585 chk_benfts_grp_id
586 (p_benfts_grp_id => p_rec.benfts_grp_id,
587 p_business_group_id => p_rec.business_group_id);
588 --
589 chk_dup_record
590 (p_benfts_grp_rt_id => p_rec.benfts_grp_rt_id,
591 p_benfts_grp_id => p_rec.benfts_grp_id,
592 p_vrbl_rt_prfl_id => p_rec.vrbl_rt_prfl_id,
593 p_effective_date => p_effective_date,
594 p_object_version_number => p_rec.object_version_number,
595 p_business_group_id => p_rec.business_group_id,
596 p_validation_start_date => p_validation_start_date,
597 p_validation_end_date => p_validation_end_date);
598 --
599 chk_duplicate_ordr_num
600 (p_vrbl_rt_prfl_id => p_rec.vrbl_rt_prfl_id
601 ,p_benfts_grp_id => p_rec.benfts_grp_id
602 ,p_ordr_num => p_rec.ordr_num
603 ,p_effective_date => p_effective_date
604 ,p_business_group_id => p_rec.business_group_id);
605 --
606 hr_utility.set_location(' Leaving:'||l_proc, 10);
607 End insert_validate;
608 --
609 -- ----------------------------------------------------------------------------
610 -- |---------------------------< update_validate >----------------------------|
611 -- ----------------------------------------------------------------------------
612 Procedure update_validate
613 (p_rec in ben_brg_shd.g_rec_type,
614 p_effective_date in date,
615 p_datetrack_mode in varchar2,
616 p_validation_start_date in date,
617 p_validation_end_date in date) is
618 --
619 l_proc varchar2(72) := g_package||'update_validate';
620 --
621 Begin
622 hr_utility.set_location('Entering:'||l_proc, 5);
623 --
624 -- Call all supporting business operations
625 --
626 --
627 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
628 --
629 chk_benfts_grp_rt_id
630 (p_benfts_grp_rt_id => p_rec.benfts_grp_rt_id,
631 p_effective_date => p_effective_date,
632 p_object_version_number => p_rec.object_version_number);
633 --
634 chk_excld_flag
635 (p_benfts_grp_rt_id => p_rec.benfts_grp_rt_id,
636 p_excld_flag => p_rec.excld_flag,
637 p_effective_date => p_effective_date,
638 p_object_version_number => p_rec.object_version_number);
639 --
640 chk_benfts_grp_id
641 (p_benfts_grp_id => p_rec.benfts_grp_id,
642 p_business_group_id => p_rec.business_group_id);
643 --
644 chk_dup_record
645 (p_benfts_grp_rt_id => p_rec.benfts_grp_rt_id,
646 p_benfts_grp_id => p_rec.benfts_grp_id,
647 p_vrbl_rt_prfl_id => p_rec.vrbl_rt_prfl_id,
648 p_effective_date => p_effective_date,
649 p_object_version_number => p_rec.object_version_number,
650 p_business_group_id => p_rec.business_group_id,
651 p_validation_start_date => p_validation_start_date,
652 p_validation_end_date => p_validation_end_date);
653
654 --
655 -- Call the datetrack update integrity operation
656 --
657 dt_update_validate
658 (
659 p_datetrack_mode => p_datetrack_mode,
660 p_validation_start_date => p_validation_start_date,
661 p_validation_end_date => p_validation_end_date);
662 --
666 ,p_ordr_num => p_rec.ordr_num
663 chk_duplicate_ordr_num
664 (p_vrbl_rt_prfl_id => p_rec.vrbl_rt_prfl_id
665 ,p_benfts_grp_id => p_rec.benfts_grp_id
667 ,p_effective_date => p_effective_date
668 ,p_business_group_id => p_rec.business_group_id);
669 --
670 hr_utility.set_location(' Leaving:'||l_proc, 10);
671 End update_validate;
672 --
673 -- ----------------------------------------------------------------------------
674 -- |---------------------------< delete_validate >----------------------------|
675 -- ----------------------------------------------------------------------------
676 Procedure delete_validate
677 (p_rec in ben_brg_shd.g_rec_type,
678 p_effective_date in date,
679 p_datetrack_mode in varchar2,
680 p_validation_start_date in date,
681 p_validation_end_date in date) is
682 --
683 l_proc varchar2(72) := g_package||'delete_validate';
684 --
685 Begin
686 hr_utility.set_location('Entering:'||l_proc, 5);
687 --
688 -- Call all supporting business operations
689 --
690 dt_delete_validate
691 (p_datetrack_mode => p_datetrack_mode,
692 p_validation_start_date => p_validation_start_date,
693 p_validation_end_date => p_validation_end_date,
694 p_benfts_grp_rt_id => p_rec.benfts_grp_rt_id);
695 --
696 hr_utility.set_location(' Leaving:'||l_proc, 10);
697 End delete_validate;
698 --
699 --
700 -- ---------------------------------------------------------------------------
701 -- |---------------------< return_legislation_code >-------------------------|
702 -- ---------------------------------------------------------------------------
703 --
704 function return_legislation_code
705 (p_benfts_grp_rt_id in number) return varchar2 is
706 --
707 -- Declare cursor
708 --
709 cursor csr_leg_code is
710 select a.legislation_code
711 from per_business_groups a,
712 ben_benfts_grp_rt_f b
713 where b.benfts_grp_rt_id = p_benfts_grp_rt_id
714 and a.business_group_id = b.business_group_id;
715 --
716 -- Declare local variables
717 --
718 l_legislation_code varchar2(150);
719 l_proc varchar2(72) := g_package||'return_legislation_code';
720 --
721 begin
722 --
723 hr_utility.set_location('Entering:'|| l_proc, 10);
724 --
725 -- Ensure that all the mandatory parameter are not null
726 --
727 hr_api.mandatory_arg_error(p_api_name => l_proc,
728 p_argument => 'benfts_grp_rt_id',
729 p_argument_value => p_benfts_grp_rt_id);
730 --
731 open csr_leg_code;
732 --
733 fetch csr_leg_code into l_legislation_code;
734 --
735 if csr_leg_code%notfound then
736 --
737 close csr_leg_code;
738 --
739 -- The primary key is invalid therefore we must error
740 --
741 hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
742 hr_utility.raise_error;
743 --
744 end if;
745 --
746 close csr_leg_code;
747 --
748 hr_utility.set_location(' Leaving:'|| l_proc, 20);
749 --
750 return l_legislation_code;
751 --
752 end return_legislation_code;
753 --
754 end ben_brg_bus;