DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BRR_BUS

Source


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