DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PTR_BUS

Source


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