DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_ESR_BUS

Source


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