DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EPY_BUS

Source


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