DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_LSR_BUS

Source


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