DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_ERL_BUS

Source


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