DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EPL_BUS

Source


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