DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BNB_BUS

Source


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