DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EPS_BUS

Source


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