[Home] [Help]
PACKAGE BODY: APPS.BEN_CLR_BUS
Source
1 Package Body ben_clr_bus as
2 /* $Header: beclrrhi.pkb 115.8 2002/12/31 23:56:57 mmudigon ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_clr_bus.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_comp_lvl_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 -- comp_lvl_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_comp_lvl_rt_id(p_comp_lvl_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_comp_lvl_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_clr_shd.api_updating
49 (p_effective_date => p_effective_date,
50 p_comp_lvl_rt_id => p_comp_lvl_rt_id,
51 p_object_version_number => p_object_version_number);
52 --
53 if (l_api_updating
54 and nvl(p_comp_lvl_rt_id,hr_api.g_number)
55 <> ben_clr_shd.g_old_rec.comp_lvl_rt_id) then
56 --
57 -- raise error as PK has changed
58 --
59 ben_clr_shd.constraint_error('BEN_COMP_LVL_RT_F_PK');
60 --
61 elsif not l_api_updating then
62 --
63 -- check if PK is null
64 --
65 if p_comp_lvl_rt_id is not null then
66 --
67 -- raise error as PK is not null
68 --
69 ben_clr_shd.constraint_error('BEN_COMP_LVL_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_comp_lvl_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_comp_lvl_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_comp_lvl_rt_f
114 where vrbl_rt_prfl_id = p_vrbl_rt_prfl_id
115 and comp_lvl_rt_id <> nvl(p_comp_lvl_rt_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 --
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
133 --
129 fnd_message.set_name('BEN','BEN_91001_SEQ_NOT_UNIQUE');
130 fnd_message.raise_error;
131 end if;
132 close c1;
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 -- comp_lvl_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_comp_lvl_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_clr_shd.api_updating
177 (p_comp_lvl_rt_id => p_comp_lvl_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_clr_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
193 --
190 (p_lookup_type => 'YES_NO',
191 p_lookup_code => p_excld_flag,
192 p_effective_date => p_effective_date) then
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_comp_lvl_fctr_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_COMP_LVL_FCTR table.
215 --
216 -- Pre Conditions
217 -- None.
218 --
219 -- In Parameters
220 -- comp_lvl_fctr_id FK of pointing to BEN_COMP_LVL_FCTR 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_comp_lvl_fctr_id(p_comp_lvl_fctr_id in number,
233 p_business_group_id in number) is
234 --
235 l_proc varchar2(72) := g_package||'chk_comp_lvl_fctr_id';
236 l_dummy varchar2(1);
237 cursor c1 is select null
238 from BEN_COMP_LVL_FCTR
239 where comp_lvl_fctr_id = p_comp_lvl_fctr_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_comp_lvl_fctr_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,'Comp_Lvl_Fctr_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_comp_lvl_fctr_id;
260
264 --
261 -- ----------------------------------------------------------------------------
262 -- |------< chk_dup_record >------|
263 -- ----------------------------------------------------------------------------
265 -- Description
266 -- This procedure is used to check that there is no duplicate record
267 --
268 -- Pre Conditions
269 -- None.
270 --
271 -- In Parameters
272 -- p_comp_lvl_rt_id PK of record being inserted or updated.
273 -- p_comp_lvl_fctr_id Value of FK
274 -- p_vrbl_rt_prfl_id FK of the record
275 -- p_effective_date effective date
276 -- p_object_version_number Object version number of record being
277 -- inserted or updated.
278 -- p_business_group_id business_group_id of the record
279 -- p_validation_start_date validation_start_date of record
280 -- p_validation_end_date validation_end_date of record
281 --
282 -- Post Success
283 -- Processing continues
284 --
285 -- Post Failure
286 -- Error handled by procedure
287 --
288 -- Access Status
289 -- Internal table handler use only.
290 --
291 Procedure chk_dup_record
292 (p_comp_lvl_rt_id in number,
293 p_comp_lvl_fctr_id in number,
294 p_vrbl_rt_prfl_id in number,
295 p_effective_date in date,
296 p_object_version_number in number,
297 p_business_group_id in number,
298 p_validation_start_date in date,
299 p_validation_end_date in date )
300 is
301 --
302 l_proc varchar2(72) := g_package||'chk_dup_record';
303 l_api_updating boolean;
304 l_exists varchar2(1);
305 --
306 cursor c_dup is
307 select null
308 from ben_comp_lvl_rt_f
309 where comp_lvl_fctr_id = p_comp_lvl_fctr_id
310 and vrbl_rt_prfl_id = p_vrbl_rt_prfl_id
311 and comp_lvl_rt_id <> nvl(p_comp_lvl_rt_id,hr_api.g_number)
312 and business_group_id + 0 = p_business_group_id
313 and p_validation_start_date <= effective_end_date
314 and p_validation_end_date >= effective_start_date;
315 --
316 BEGIN
317 --
318 hr_utility.set_location('Entering:'||l_proc, 5);
319 --
320 l_api_updating := ben_clr_shd.api_updating
321 (p_comp_lvl_rt_id => p_comp_lvl_rt_id,
322 p_effective_date => p_effective_date,
323 p_object_version_number => p_object_version_number);
324 --
325 if (l_api_updating
326 and p_comp_lvl_fctr_id <> nvl(ben_clr_shd.g_old_rec.comp_lvl_fctr_id,hr_api.g_number)
327 or not l_api_updating) then
328
329 open c_dup;
330 fetch c_dup into l_exists;
331 if c_dup%found then
332 close c_dup;
333 --
334 -- raise error as this Compensation Level already exists for this profile
335 --
336 fnd_message.set_name('BEN', 'BEN_92992_DUPS_ROW');
337 fnd_message.set_token('VAR1','Compensation Level criteria',TRUE);
338 fnd_message.set_token('VAR2','Variable Rate Profile',TRUE);
339 fnd_message.raise_error;
340 --
341 end if;
342 close c_dup;
343 --
344 end if;
345 hr_utility.set_location('Leaving:'||l_proc,10);
346 --
347 END chk_dup_record;
348
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}
379 -- ----------------------------------------------------------------------------
380 Procedure dt_update_validate
381 (p_vrbl_rt_prfl_id in number default hr_api.g_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_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 --
407 hr_api.mandatory_arg_error
408 (p_api_name => l_proc,
409 p_argument => 'validation_start_date',
410 p_argument_value => p_validation_start_date);
411 --
412 hr_api.mandatory_arg_error
413 (p_api_name => l_proc,
414 p_argument => 'validation_end_date',
418 NOT (dt_api.check_min_max_dates
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
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_comp_lvl_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 => 'comp_lvl_rt_id',
527 p_argument_value => p_comp_lvl_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 ben_utility.child_exists_error(p_table_name => l_table_name);
541 --
542 When Others Then
543 --
544 -- An unhandled or unexpected error has occurred which
545 -- we must report
546 --
547 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
548 hr_utility.set_message_token('PROCEDURE', l_proc);
549 hr_utility.set_message_token('STEP','15');
550 hr_utility.raise_error;
551 End dt_delete_validate;
552 --
553 -- ----------------------------------------------------------------------------
554 -- |---------------------------< insert_validate >----------------------------|
555 -- ----------------------------------------------------------------------------
556 Procedure insert_validate
557 (p_rec in ben_clr_shd.g_rec_type,
558 p_effective_date in date,
559 p_datetrack_mode in varchar2,
563 l_proc varchar2(72) := g_package||'insert_validate';
560 p_validation_start_date in date,
561 p_validation_end_date in date) is
562 --
564 --
565 Begin
566 hr_utility.set_location('Entering:'||l_proc, 5);
567 --
568 -- Call all supporting business operations
569 --
570 --
571 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
572 --
573 chk_comp_lvl_rt_id
574 (p_comp_lvl_rt_id => p_rec.comp_lvl_rt_id,
575 p_effective_date => p_effective_date,
576 p_object_version_number => p_rec.object_version_number);
577 --
578 chk_excld_flag
579 (p_comp_lvl_rt_id => p_rec.comp_lvl_rt_id,
580 p_excld_flag => p_rec.excld_flag,
581 p_effective_date => p_effective_date,
582 p_object_version_number => p_rec.object_version_number);
583 --
584 chk_comp_lvl_fctr_id(p_comp_lvl_fctr_id => p_rec.comp_lvl_fctr_id,
585 p_business_group_id => p_rec.business_group_id);
586 --
587 chk_dup_record
588 (p_comp_lvl_rt_id => p_rec.comp_lvl_rt_id,
589 p_comp_lvl_fctr_id => p_rec.comp_lvl_fctr_id,
590 p_vrbl_rt_prfl_id => p_rec.vrbl_rt_prfl_id,
591 p_effective_date => p_effective_date,
592 p_object_version_number => p_rec.object_version_number,
593 p_business_group_id => p_rec.business_group_id,
594 p_validation_start_date => p_validation_start_date,
595 p_validation_end_date => p_validation_end_date);
596 --
597 chk_duplicate_ordr_num
598 (p_vrbl_rt_prfl_id => p_rec.vrbl_rt_prfl_id
599 ,p_ordr_num => p_rec.ordr_num
600 ,p_effective_date => p_effective_date
601 ,p_business_group_id => p_rec.business_group_id
602 ,p_comp_lvl_rt_id => p_rec.comp_lvl_rt_id);
603 --
604 hr_utility.set_location(' Leaving:'||l_proc, 10);
605 End insert_validate;
606 --
607 -- ----------------------------------------------------------------------------
608 -- |---------------------------< update_validate >----------------------------|
609 -- ----------------------------------------------------------------------------
610 Procedure update_validate
611 (p_rec in ben_clr_shd.g_rec_type,
612 p_effective_date in date,
613 p_datetrack_mode in varchar2,
614 p_validation_start_date in date,
615 p_validation_end_date in date) is
616 --
617 l_proc varchar2(72) := g_package||'update_validate';
618 --
619 Begin
620 hr_utility.set_location('Entering:'||l_proc, 5);
621 --
622 -- Call all supporting business operations
623 --
624 --
625 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
626 --
627 chk_comp_lvl_rt_id
628 (p_comp_lvl_rt_id => p_rec.comp_lvl_rt_id,
629 p_effective_date => p_effective_date,
630 p_object_version_number => p_rec.object_version_number);
631 --
632 chk_excld_flag
633 (p_comp_lvl_rt_id => p_rec.comp_lvl_rt_id,
634 p_excld_flag => p_rec.excld_flag,
635 p_effective_date => p_effective_date,
636 p_object_version_number => p_rec.object_version_number);
637 --
638 chk_comp_lvl_fctr_id(p_comp_lvl_fctr_id => p_rec.comp_lvl_fctr_id,
639 p_business_group_id => p_rec.business_group_id);
640 --
641 chk_dup_record
642 (p_comp_lvl_rt_id => p_rec.comp_lvl_rt_id,
643 p_comp_lvl_fctr_id => p_rec.comp_lvl_fctr_id,
644 p_vrbl_rt_prfl_id => p_rec.vrbl_rt_prfl_id,
645 p_effective_date => p_effective_date,
646 p_object_version_number => p_rec.object_version_number,
647 p_business_group_id => p_rec.business_group_id,
648 p_validation_start_date => p_validation_start_date,
649 p_validation_end_date => p_validation_end_date);
650 --
651 -- Call the datetrack update integrity operation
652 --
653 dt_update_validate
654 (
655 p_datetrack_mode => p_datetrack_mode,
656 p_validation_start_date => p_validation_start_date,
657 p_validation_end_date => p_validation_end_date);
658 --
659 chk_duplicate_ordr_num
660 (p_vrbl_rt_prfl_id => p_rec.vrbl_rt_prfl_id
661 ,p_ordr_num => p_rec.ordr_num
662 ,p_effective_date => p_effective_date
663 ,p_business_group_id => p_rec.business_group_id
664 ,p_comp_lvl_rt_id => p_rec.comp_lvl_rt_id);
665 --
666 hr_utility.set_location(' Leaving:'||l_proc, 10);
667 End update_validate;
668 --
669 -- ----------------------------------------------------------------------------
670 -- |---------------------------< delete_validate >----------------------------|
671 -- ----------------------------------------------------------------------------
672 Procedure delete_validate
673 (p_rec in ben_clr_shd.g_rec_type,
674 p_effective_date in date,
675 p_datetrack_mode in varchar2,
676 p_validation_start_date in date,
677 p_validation_end_date in date) is
678 --
679 l_proc varchar2(72) := g_package||'delete_validate';
680 --
681 Begin
682 hr_utility.set_location('Entering:'||l_proc, 5);
683 --
684 -- Call all supporting business operations
685 --
686 dt_delete_validate
687 (p_datetrack_mode => p_datetrack_mode,
688 p_validation_start_date => p_validation_start_date,
689 p_validation_end_date => p_validation_end_date,
690 p_comp_lvl_rt_id => p_rec.comp_lvl_rt_id);
691 --
692 hr_utility.set_location(' Leaving:'||l_proc, 10);
693 End delete_validate;
694 --
695 --
696 -- ---------------------------------------------------------------------------
700 function return_legislation_code
697 -- |---------------------< return_legislation_code >-------------------------|
698 -- ---------------------------------------------------------------------------
699 --
701 (p_comp_lvl_rt_id in number) return varchar2 is
702 --
703 -- Declare cursor
704 --
705 cursor csr_leg_code is
706 select a.legislation_code
707 from per_business_groups a,
708 ben_comp_lvl_rt_f b
709 where b.comp_lvl_rt_id = p_comp_lvl_rt_id
710 and a.business_group_id = b.business_group_id;
711 --
712 -- Declare local variables
713 --
714 l_legislation_code varchar2(150);
715 l_proc varchar2(72) := g_package||'return_legislation_code';
716 --
717 begin
718 --
719 hr_utility.set_location('Entering:'|| l_proc, 10);
720 --
721 -- Ensure that all the mandatory parameter are not null
722 --
723 hr_api.mandatory_arg_error(p_api_name => l_proc,
724 p_argument => 'comp_lvl_rt_id',
725 p_argument_value => p_comp_lvl_rt_id);
726 --
727 open csr_leg_code;
728 --
729 fetch csr_leg_code into l_legislation_code;
730 --
731 if csr_leg_code%notfound then
732 --
733 close csr_leg_code;
734 --
735 -- The primary key is invalid therefore we must error
736 --
737 hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
738 hr_utility.raise_error;
739 --
740 end if;
741 --
742 close csr_leg_code;
743 --
744 hr_utility.set_location(' Leaving:'|| l_proc, 20);
745 --
746 return l_legislation_code;
747 --
748 end return_legislation_code;
749 --
750 end ben_clr_bus;