DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PZR_BUS

Source


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