DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_AGF_BUS

Source


4 -- ----------------------------------------------------------------------------
1 Package Body ben_agf_bus as
2 /* $Header: beagfrhi.pkb 120.0 2005/05/28 00:23:13 appldev noship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_agf_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_age_fctr_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 --   age_fctr_id PK of record being inserted or updated.
24 --   object_version_number Object version number of record being
25 --                         inserted or updated.
26 --
27 -- Post Success
28 --   Processing continues
29 --
30 -- Post Failure
31 --   Errors handled by the procedure
32 --
33 -- Access Status
34 --   Internal table handler use only.
35 --
36 Procedure chk_age_fctr_id(p_age_fctr_id                in number,
37                            p_object_version_number       in number) is
38   --
39   l_proc         varchar2(72) := g_package||'chk_age_fctr_id';
40   l_api_updating boolean;
41   --
42 Begin
43   --
44   hr_utility.set_location('Entering:'||l_proc, 5);
45   --
46   l_api_updating := ben_agf_shd.api_updating
47     (p_age_fctr_id                => p_age_fctr_id,
48      p_object_version_number       => p_object_version_number);
49   --
50   if (l_api_updating
51      and nvl(p_age_fctr_id,hr_api.g_number)
52      <>  ben_agf_shd.g_old_rec.age_fctr_id) then
53     --
54     -- raise error as PK has changed
55     --
56     ben_agf_shd.constraint_error('BEN_AGE_FCTR_PK');
57     --
58   elsif not l_api_updating then
59     --
60     -- check if PK is null
61     --
62     if p_age_fctr_id is not null then
63       --
64       -- raise error as PK is not null
65       --
66       ben_agf_shd.constraint_error('BEN_AGE_FCTR_PK');
67       --
68     end if;
69     --
70   end if;
71   --
72   hr_utility.set_location('Leaving:'||l_proc, 10);
73   --
74 End chk_age_fctr_id;
75 --
76 /*
77 -- ----------------------------------------------------------------------------
78 -- |------< chk_organization_id >------|
79 -- ----------------------------------------------------------------------------
80 --
81 -- Description
82 --   This procedure checks that a referenced foreign key actually exists
83 --   in the referenced table.
84 --
85 -- Pre-Conditions
86 --   None.
87 --
88 -- In Parameters
89 --   p_age_fctr_id PK
90 --   p_organization_id ID of FK column
91 --   p_object_version_number object version number
92 --
93 -- Post Success
97 --   Error raised.
94 --   Processing continues
95 --
96 -- Post Failure
98 --
99 -- Access Status
100 --   Internal table handler use only.
101 --
102 Procedure chk_organization_id (p_age_fctr_id          in number,
103                             p_organization_id          in number,
104                             p_object_version_number in number) is
105   --
106   l_proc         varchar2(72) := g_package||'chk_organization_id';
107   l_api_updating boolean;
108   l_dummy        varchar2(1);
109   --
110   cursor c1 is
111     select null
112     from   hr_all_organization_units a
113     where  a.organization_id = p_organization_id;
114   --
115 Begin
116   --
117   hr_utility.set_location('Entering:'||l_proc,5);
118   --
119   l_api_updating := ben_agf_shd.api_updating
120      (p_age_fctr_id            => p_age_fctr_id,
121       p_object_version_number   => p_object_version_number);
122   --
123   if (l_api_updating
124      and nvl(p_organization_id,hr_api.g_number)
125      <> nvl(ben_agf_shd.g_old_rec.organization_id,hr_api.g_number)
126      or not l_api_updating) then
127     --
128     -- check if organization_id value exists in hr_all_organization_units table
129     --
130     open c1;
131       --
132       fetch c1 into l_dummy;
133       if c1%notfound then
134         --
135         close c1;
136         --
137         -- raise error as FK does not relate to PK in hr_all_organization_units
138         -- table.
139         --
140         ben_agf_shd.constraint_error('BEN_AGE_FCTR_FK1');
141         --
142       end if;
143       --
144     close c1;
145     --
146   end if;
147   --
148   hr_utility.set_location('Leaving:'||l_proc,10);
149   --
150 End chk_organization_id;
151 */
152 --
153 -- ----------------------------------------------------------------------------
154 -- |----------------------< chk_age_to_use_cd >----------------------------|
155 -- ----------------------------------------------------------------------------
156 --
157 -- Description
158 --   This procedure is used to check that the lookup value is valid.
159 --
160 -- Pre Conditions
161 --   None.
162 --
163 -- In Parameters
164 --   age_fctr_id PK of record being inserted or updated.
165 --   age_to_use_cd Value of lookup code.
166 --   effective_date effective date
167 --   object_version_number Object version number of record being
168 --                         inserted or updated.
169 --
170 -- Post Success
171 --   Processing continues
172 --
173 -- Post Failure
174 --   Error handled by procedure
175 --
176 -- Access Status
177 --   Internal table handler use only.
178 --
179 Procedure chk_age_to_use_cd(p_age_fctr_id                in number,
180                             p_age_to_use_cd               in varchar2,
181                             p_effective_date              in date,
182                             p_object_version_number       in number) is
183   --
184   l_proc         varchar2(72) := g_package||'chk_age_to_use_cd';
185   l_api_updating boolean;
186   --
187 Begin
188   --
189   hr_utility.set_location('Entering:'||l_proc, 5);
190   --
191   l_api_updating := ben_agf_shd.api_updating
192     (p_age_fctr_id                => p_age_fctr_id,
193      p_object_version_number       => p_object_version_number);
194   --
195   if (l_api_updating
196       and p_age_to_use_cd
197       <> nvl(ben_agf_shd.g_old_rec.age_to_use_cd,hr_api.g_varchar2)
198       or not l_api_updating) and p_age_to_use_cd is not null then
199     --
200     -- check if value of lookup falls within lookup type.
201     --
202     --
203     if hr_api.not_exists_in_hr_lookups
204           (p_lookup_type    => 'BEN_AGE_TO_USE_CD',
205            p_lookup_code    => p_age_to_use_cd,
206            p_effective_date => p_effective_date) then
207       --
208       -- raise error as does not exist as lookup
209       --
210       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
211       fnd_message.set_token('FIELD', 'p_age_to_use_cd');
212       fnd_message.set_token('TYPE', 'BEN_AGE_TO_USE_CD');
213       fnd_message.raise_error;
214       --
215     end if;
216     --
217   end if;
218   --
219   hr_utility.set_location('Leaving:'||l_proc,10);
220   --
221 end chk_age_to_use_cd;
222 --
223 -- ----------------------------------------------------------------------------
224 -- |------< chk_rndg_rl >------|
225 -- ----------------------------------------------------------------------------
226 --
227 -- Description
228 --   This procedure is used to check that the Formula Rule is valid.
229 --
230 -- Pre Conditions
231 --   None.
232 --
233 -- In Parameters
234 --   age_fctr_id PK of record being inserted or updated.
235 --   rndg_rl Value of formula rule id.
236 --   effective_date effective date
237 --   object_version_number Object version number of record being
238 --                                      inserted or updated.
239 --
240 -- Post Success
241 --   Processing continues
242 --
243 -- Post Failure
244 --   Error handled by procedure
245 --
246 -- Access Status
247 --   Internal table handler use only.
248 --
249 Procedure chk_rndg_rl(p_age_fctr_id                 in number,
250                       p_rndg_rl                     in number,
251    	              p_rndg_cd                in varchar2,                -- Bug No 4242978
252                       p_business_group_id           in number,
256   l_proc         varchar2(72) := g_package||'chk_rndg_rl';
253                       p_effective_date              in date,
254                       p_object_version_number       in number) is
255   --
257   l_api_updating boolean;
258   --
259 Begin
260   --
261   hr_utility.set_location('Entering:'||l_proc, 5);
262   --
263   l_api_updating := ben_agf_shd.api_updating
264     (p_age_fctr_id                 => p_age_fctr_id,
265      p_object_version_number       => p_object_version_number);
266   --
267   if (l_api_updating
268       and nvl(p_rndg_rl,hr_api.g_number)
269       <> ben_agf_shd.g_old_rec.rndg_rl
270       or not l_api_updating)
271       and p_rndg_rl is not null then
272     --
273     -- check if value of formula rule is valid.
274     --
275     if not benutils.formula_exists
276        (p_formula_id        => p_rndg_rl,
277         p_formula_type_id   => -169,
278         p_business_group_id => p_business_group_id,
279         p_effective_date    => p_effective_date) then
280       --
281       -- raise error
282       --
283       fnd_message.set_name('BEN','BEN_91471_FORMULA_NOT_FOUND');
284       fnd_message.set_token('ID',p_rndg_rl);
285       fnd_message.set_token('TYPE_ID',-169);
286       fnd_message.raise_error;
287       --
288     end if;
289     --
290   end if;
291   --
292   --  Bug No 4242978
293   -- Unless Rounding Code = Rule, Rounding rule must be blank.
294   if  nvl(p_rndg_cd,hr_api.g_varchar2)  <> 'RL' and p_rndg_rl is not null then
295       --
296       fnd_message.set_name('BEN', 'BEN_91043_RNDG_RL_NOT_NULL');
297       fnd_message.raise_error;
298       --
299   elsif  nvl(p_rndg_cd,hr_api.g_varchar2) = 'RL' and p_rndg_rl is null then
300       --
301       fnd_message.set_name('BEN', 'BEN_92340_RNDG_RL_NULL');
302       fnd_message.raise_error;
303       --
304   end if;
305   --
306   hr_utility.set_location('Leaving:'||l_proc,10);
307   --
308 end chk_rndg_rl;
309 --
310 -- ----------------------------------------------------------------------------
311 -- |-----------------------------< chk_age_calc_rl >--------------------------|
312 -- ----------------------------------------------------------------------------
313 --
314 -- Description
315 --   This procedure is used to check that the Formula Rule is valid.
316 --
317 -- Pre Conditions
318 --   None.
319 --
320 -- In Parameters
321 --   age_fctr_id PK of record being inserted or updated.
322 --   age_calc_rl Value of formula rule id.
323 --   effective_date effective date
324 --   object_version_number Object version number of record being
325 --                                      inserted or updated.
326 --
327 -- Post Success
328 --   Processing continues
329 --
330 -- Post Failure
331 --   Error handled by procedure
332 --
333 -- Access Status
334 --   Internal table handler use only.
335 --
336 Procedure chk_age_calc_rl(p_age_fctr_id                 in number,
337                           p_age_calc_rl                 in number,
338                           p_business_group_id           in number,
339                           p_effective_date              in date,
340                           p_object_version_number       in number) is
341   --
342   l_proc         varchar2(72) := g_package||'chk_age_calc_rl';
343   l_api_updating boolean;
344   --
345 Begin
346   --
347   hr_utility.set_location('Entering:'||l_proc, 5);
348   --
349   l_api_updating := ben_agf_shd.api_updating
350     (p_age_fctr_id                 => p_age_fctr_id,
351      p_object_version_number       => p_object_version_number);
352   --
353   if (l_api_updating
354       and nvl(p_age_calc_rl,hr_api.g_number)
355       <> ben_agf_shd.g_old_rec.age_calc_rl
356       or not l_api_updating)
357       and p_age_calc_rl is not null then
358     --
359     -- check if value of formula rule is valid.
360     --
361     if not benutils.formula_exists
362        (p_formula_id        => p_age_calc_rl,
363         p_formula_type_id   => -500,
364         p_business_group_id => p_business_group_id,
365         p_effective_date    => p_effective_date) then
366       --
367       -- raise error
368       --
369       fnd_message.set_name('BEN','BEN_91471_FORMULA_NOT_FOUND');
370       fnd_message.set_token('ID',p_age_calc_rl);
371       fnd_message.set_token('TYPE_ID',-169);
372       fnd_message.raise_error;
373       --
374     end if;
375     --
376   end if;
377   --
378   hr_utility.set_location('Leaving:'||l_proc,10);
379   --
380 end chk_age_calc_rl;
381 -- ----------------------------------------------------------------------------
382 -- |-----------------------------< chk_age_code_rule >------------------------|
383 -- ----------------------------------------------------------------------------
384 --
385 -- Description
386 --   This procedure is used to check that the age_to_use_cd is populated or
387 --   the age_calc_rl is populated.
388 --
389 -- Pre Conditions
390 --   None.
391 --
392 -- In Parameters
393 --   age_to_use_cd value of lookup
394 --   age_calc_rl Value of formula rule id.
395 --
396 -- Post Success
397 --   Processing continues
398 --
399 -- Post Failure
400 --   Error handled by procedure
401 --
402 -- Access Status
403 --   Internal table handler use only.
404 --
405 Procedure chk_age_code_rule(p_age_to_use_cd               in varchar2,
406                             p_age_calc_rl                 in number) is
410 Begin
407   --
408   l_proc         varchar2(72) := g_package||'chk_age_code_rule';
409   --
411   --
412   hr_utility.set_location('Entering:'||l_proc, 5);
413   --
414   if p_age_to_use_cd is null and
415     p_age_calc_rl is null or
416     p_age_to_use_cd is not null and
417     p_age_calc_rl is not null then
418     --
419     -- raise error
420     --
421     fnd_message.set_name('BEN','BEN_92557_CODE_AGE_RULE');
422     fnd_message.raise_error;
423     --
424   end if;
425   --
426   hr_utility.set_location('Leaving:'||l_proc,10);
427   --
428 end chk_age_code_rule;
429 -- ----------------------------------------------------------------------------
430 -- |------< chk_rndg_cd >------|
431 -- ----------------------------------------------------------------------------
432 --
433 -- Description
434 --   This procedure is used to check that the lookup value is valid.
435 --
436 -- Pre Conditions
437 --   None.
438 --
439 -- In Parameters
440 --   age_fctr_id PK of record being inserted or updated.
441 --   rndg_cd Value of lookup code.
442 --   effective_date effective date
443 --   object_version_number Object version number of record being
444 --                         inserted or updated.
445 --
446 -- Post Success
447 --   Processing continues
448 --
449 -- Post Failure
450 --   Error handled by procedure
451 --
452 -- Access Status
453 --   Internal table handler use only.
454 --
455 Procedure chk_rndg_cd(p_age_fctr_id                in number,
456                             p_rndg_cd               in varchar2,
457                             p_effective_date              in date,
458                             p_object_version_number       in number) is
459   --
460   l_proc         varchar2(72) := g_package||'chk_rndg_cd';
461   l_api_updating boolean;
462   --
463 Begin
464   --
465   hr_utility.set_location('Entering:'||l_proc, 5);
466   --
467   l_api_updating := ben_agf_shd.api_updating
468     (p_age_fctr_id                => p_age_fctr_id,
469      p_object_version_number       => p_object_version_number);
470   --
471   if (l_api_updating
472       and p_rndg_cd
473       <> nvl(ben_agf_shd.g_old_rec.rndg_cd,hr_api.g_varchar2)
474       or not l_api_updating)
475       and p_rndg_cd is not null then
476     --
477     -- check if value of lookup falls within lookup type.
478     --
479     if hr_api.not_exists_in_hr_lookups
480           (p_lookup_type    => 'BEN_RNDG',
481            p_lookup_code    => p_rndg_cd,
482            p_effective_date => p_effective_date) then
483       --
484       -- raise error as does not exist as lookup
485       --
486       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
487       fnd_message.set_token('FIELD', 'p_rndg_cd');
488       fnd_message.set_token('TYPE', 'BEN_RNDG');
489       fnd_message.raise_error;
490       --
491     end if;
492     --
493   end if;
494   --
495   hr_utility.set_location('Leaving:'||l_proc,10);
496   --
497 end chk_rndg_cd;
498 --
499 -- ----------------------------------------------------------------------------
500 -- |------< chk_age_det_rl >------|
501 -- ----------------------------------------------------------------------------
502 --
503 -- Description
504 --   This procedure is used to check that the Formula Rule is valid.
505 --
506 -- Pre Conditions
507 --   None.
508 --
509 -- In Parameters
510 --   age_fctr_id PK of record being inserted or updated.
511 --   age_det_cd Determination Code
512 --   age_det_rl Value of formula rule id.
513 --   effective_date effective date
514 --   object_version_number Object version number of record being
515 --                                      inserted or updated.
516 --
517 -- Post Success
518 --   Processing continues
519 --
520 -- Post Failure
521 --   Error handled by procedure
522 --
523 -- Access Status
524 --   Internal table handler use only.
525 --
526 Procedure chk_age_det_rl(p_age_fctr_id                 in number,
527                          p_age_det_rl                  in number,
528                          p_age_det_cd                in varchar2,                          -- Bug No 4242978
529                          p_business_group_id           in number,
530                          p_effective_date              in date,
531                          p_object_version_number       in number) is
532   --
533   l_proc         varchar2(72) := g_package||'chk_age_det_rl';
534   l_api_updating boolean;
535   --
536 Begin
537   --
538   hr_utility.set_location('Entering:'||l_proc, 5);
539   --
540   l_api_updating := ben_agf_shd.api_updating
541     (p_age_fctr_id                 => p_age_fctr_id,
542      p_object_version_number       => p_object_version_number);
543   --
544   if (l_api_updating
545       and nvl(p_age_det_rl,hr_api.g_number)
546       <> ben_agf_shd.g_old_rec.age_det_rl
547       or not l_api_updating)
548       and p_age_det_rl is not null then
549     --
550     -- check if value of formula rule is valid.
551     --
552     if not benutils.formula_exists
553        (p_formula_id        => p_age_det_rl,
554         p_formula_type_id   => -145,
555         p_business_group_id => p_business_group_id,
556         p_effective_date    => p_effective_date) then
557       --
558       -- raise error
559       --
560       fnd_message.set_name('BEN','BEN_91471_FORMULA_NOT_FOUND');
561       fnd_message.set_token('ID',p_age_det_rl);
562       fnd_message.set_token('TYPE_ID',-145);
566     --
563       fnd_message.raise_error;
564       --
565     end if;
567   end if;
568   --
569   -- Bug No 4242978 Added validations for determination rule not null when
570   --				det code is RL and det rule should be null when det code not RL
571   --
572   -- Unless AGE determination  Code = Rule,  AGE determination rule must be blank.
573       if  nvl(p_age_det_cd,hr_api.g_varchar2)  <> 'RL' and p_age_det_rl is not null then
574       --
575       fnd_message.set_name('BEN', 'BEN_91046_AGE_DET_RL_NOT_NULL');
576       fnd_message.raise_error;
577       --
578       elsif  nvl(p_age_det_cd,hr_api.g_varchar2) = 'RL' and p_age_det_rl is null then
579       --
580       fnd_message.set_name('BEN', 'BEN_91096_AGE_DET_RL_NULL');
581       fnd_message.raise_error;
582       --
583      end if;
584      --
585   hr_utility.set_location('Leaving:'||l_proc,10);
586   --
587 end chk_age_det_rl;
588 --
589 -- ----------------------------------------------------------------------------
590 -- |------< chk_age_det_cd >------|
591 -- ----------------------------------------------------------------------------
592 --
593 -- Description
594 --   This procedure is used to check that the lookup value is valid.
595 --
596 -- Pre Conditions
597 --   None.
598 --
599 -- In Parameters
600 --   age_fctr_id PK of record being inserted or updated.
601 --   age_det_cd Value of lookup code.
602 --   effective_date effective date
603 --   object_version_number Object version number of record being
604 --                         inserted or updated.
605 --
606 -- Post Success
607 --   Processing continues
608 --
609 -- Post Failure
610 --   Error handled by procedure
611 --
612 -- Access Status
613 --   Internal table handler use only.
614 --
615 Procedure chk_age_det_cd(p_age_fctr_id                in number,
616                             p_age_det_cd               in varchar2,
617                             p_effective_date              in date,
618                             p_object_version_number       in number) is
619   --
620   l_proc         varchar2(72) := g_package||'chk_age_det_cd';
621   l_api_updating boolean;
622   --
623 Begin
624   --
625   hr_utility.set_location('Entering:'||l_proc, 5);
626   --
627   l_api_updating := ben_agf_shd.api_updating
628     (p_age_fctr_id                => p_age_fctr_id,
629      p_object_version_number       => p_object_version_number);
630   --
631   if (l_api_updating
632       and p_age_det_cd
633       <> nvl(ben_agf_shd.g_old_rec.age_det_cd,hr_api.g_varchar2)
634       or not l_api_updating)
635       and p_age_det_cd is not null then
636     --
637     -- check if value of lookup falls within lookup type.
638     --
639     if hr_api.not_exists_in_hr_lookups
640           (p_lookup_type    => 'BEN_AGE_DET',
641            p_lookup_code    => p_age_det_cd,
642            p_effective_date => p_effective_date) then
643       --
644       -- raise error as does not exist as lookup
645       --
646       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
647       fnd_message.set_token('FIELD', 'p_age_det_cd');
648       fnd_message.set_token('TYPE', 'AGE_DET');
649       fnd_message.raise_error;
650       --
651     end if;
652     --
653   end if;
654   --
655   hr_utility.set_location('Leaving:'||l_proc,10);
656   --
657 end chk_age_det_cd;
658 --
659 -- ----------------------------------------------------------------------------
660 -- |------< chk_no_mx_age_flag >------|
661 -- ----------------------------------------------------------------------------
662 --
663 -- Description
664 --   This procedure is used to check that the lookup value is valid.
665 --
666 -- Pre Conditions
667 --   None.
668 --
669 -- In Parameters
670 --   age_fctr_id PK of record being inserted or updated.
671 --   no_mx_age_flag Value of lookup code.
672 --   effective_date effective date
673 --   object_version_number Object version number of record being
674 --                         inserted or updated.
675 --
676 -- Post Success
677 --   Processing continues
678 --
679 -- Post Failure
680 --   Error handled by procedure
681 --
682 -- Access Status
683 --   Internal table handler use only.
684 --
685 Procedure chk_no_mx_age_flag(p_age_fctr_id                in number,
686                             p_no_mx_age_flag               in varchar2,
687                             p_effective_date              in date,
688                             p_object_version_number       in number) is
689   --
690   l_proc         varchar2(72) := g_package||'chk_no_mx_age_flag';
691   l_api_updating boolean;
692   --
693 Begin
694   --
695   hr_utility.set_location('Entering:'||l_proc, 5);
696   --
697   l_api_updating := ben_agf_shd.api_updating
698     (p_age_fctr_id                => p_age_fctr_id,
699      p_object_version_number       => p_object_version_number);
700   --
701   if (l_api_updating
702       and p_no_mx_age_flag
703       <> nvl(ben_agf_shd.g_old_rec.no_mx_age_flag,hr_api.g_varchar2)
704       or not l_api_updating) then
705     --
706     -- check if value of lookup falls within lookup type.
707     --
708     --
709     if hr_api.not_exists_in_hr_lookups
710           (p_lookup_type    => 'YES_NO',
711            p_lookup_code    => p_no_mx_age_flag,
712            p_effective_date => p_effective_date) then
713       --
714       -- raise error as does not exist as lookup
715       --
716       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
717       fnd_message.set_token('FIELD', 'p_no_mx_age_flag');
721     end if;
718       fnd_message.set_token('TYPE', 'YES_NO');
719       fnd_message.raise_error;
720       --
722     --
723   end if;
724   --
725   hr_utility.set_location('Leaving:'||l_proc,10);
726   --
727 end chk_no_mx_age_flag;
728 --
729 -- ----------------------------------------------------------------------------
730 -- |------< chk_no_mn_age_flag >------|
731 -- ----------------------------------------------------------------------------
732 --
733 -- Description
734 --   This procedure is used to check that the lookup value is valid.
735 --
736 -- Pre Conditions
737 --   None.
738 --
739 -- In Parameters
740 --   age_fctr_id PK of record being inserted or updated.
741 --   no_mn_age_flag Value of lookup code.
742 --   effective_date effective date
743 --   object_version_number Object version number of record being
744 --                         inserted or updated.
745 --
746 -- Post Success
747 --   Processing continues
748 --
749 -- Post Failure
750 --   Error handled by procedure
751 --
752 -- Access Status
753 --   Internal table handler use only.
754 --
755 Procedure chk_no_mn_age_flag(p_age_fctr_id                in number,
756                             p_no_mn_age_flag               in varchar2,
757                             p_effective_date              in date,
758                             p_object_version_number       in number) is
759   --
760   l_proc         varchar2(72) := g_package||'chk_no_mn_age_flag';
761   l_api_updating boolean;
762   --
763 Begin
764   --
765   hr_utility.set_location('Entering:'||l_proc, 5);
766   --
767   l_api_updating := ben_agf_shd.api_updating
768     (p_age_fctr_id                => p_age_fctr_id,
769      p_object_version_number       => p_object_version_number);
770   --
771   if (l_api_updating
772       and p_no_mn_age_flag
773       <> nvl(ben_agf_shd.g_old_rec.no_mn_age_flag,hr_api.g_varchar2)
774       or not l_api_updating) then
775     --
776     -- check if value of lookup falls within lookup type.
777     --
778     --
779     if hr_api.not_exists_in_hr_lookups
780           (p_lookup_type    => 'YES_NO',
781            p_lookup_code    => p_no_mn_age_flag,
782            p_effective_date => p_effective_date) then
783       --
784       -- raise error as does not exist as lookup
785       --
786       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
787       fnd_message.set_token('FIELD', 'p_no_mn_age_flag');
788       fnd_message.set_token('TYPE', 'YES_NO');
789       fnd_message.raise_error;
790       --
791     end if;
792     --
793   end if;
794   --
795   hr_utility.set_location('Leaving:'||l_proc,10);
796   --
797 end chk_no_mn_age_flag;
798 --
799 -- ----------------------------------------------------------------------------
800 -- |------< chk_age_uom >------|
801 -- ----------------------------------------------------------------------------
802 --
803 -- Description
804 --   This procedure is used to check that the lookup value is valid.
805 --
806 -- Pre Conditions
807 --   None.
808 --
809 -- In Parameters
810 --   age_fctr_id PK of record being inserted or updated.
811 --   age_uom Value of lookup code.
812 --   effective_date effective date
813 --   object_version_number Object version number of record being
814 --                         inserted or updated.
815 --
816 -- Post Success
817 --   Processing continues
818 --
819 -- Post Failure
820 --   Error handled by procedure
821 --
822 -- Access Status
823 --   Internal table handler use only.
824 --
825 Procedure chk_age_uom(p_age_fctr_id                in number,
826                             p_age_uom               in varchar2,
827                             p_effective_date              in date,
828                             p_object_version_number       in number) is
829   --
830   l_proc         varchar2(72) := g_package||'chk_age_uom';
831   l_api_updating boolean;
832   --
833 Begin
834   --
835   hr_utility.set_location('Entering:'||l_proc, 5);
836   --
837   l_api_updating := ben_agf_shd.api_updating
838     (p_age_fctr_id                => p_age_fctr_id,
839      p_object_version_number       => p_object_version_number);
840   --
841   if (l_api_updating
842       and p_age_uom
843       <> nvl(ben_agf_shd.g_old_rec.age_uom,hr_api.g_varchar2)
844       or not l_api_updating)
845       and p_age_uom is not null then
846     --
847     -- check if value of lookup falls within lookup type.
848     --
849     if hr_api.not_exists_in_hr_lookups
850           (p_lookup_type    => 'BEN_TM_UOM',
851            p_lookup_code    => p_age_uom,
852            p_effective_date => p_effective_date) then
853       --
854       -- raise error as does not exist as lookup
855       --
856       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
857       fnd_message.set_token('FIELD', 'p_age_uom');
858       fnd_message.set_token('TYPE', 'BEN_TM_UOM');
859       fnd_message.raise_error;
860       --
861     end if;
862     --
863   end if;
864   --
865   hr_utility.set_location('Leaving:'||l_proc,10);
866   --
867 end chk_age_uom;
868 --
869 ------------------------------------------------------------------------
870 ----
871 -- |------< chk_mn_mx_age_num >------|
872 --
873 ------------------------------------------------------------------------
874 ----
875 --
876 -- Description
877 --   This procedure is used to check that minimum age nuumber is always less than
878 --    max age number.
879 --
880 -- Pre Conditions
884 --   age_fctr_id PK of record being inserted or updated.
881 --   None.
882 --
883 -- In Parameters
885 --   mn_age_num Value of Minimum age.
886 --   mx_age_num Value of Maximum age.
887 --   effective_date effective date
888 --   object_version_number Object version number of record being
889 --                         inserted or updated.
890 --
891 -- Post Success
892 --   Processing continues
893 --
894 -- Post Failure
895 --   Error handled by procedure
896 --
897 -- Access Status
898 --   Internal table handler use only.
899 --
900 Procedure chk_mn_mx_age_num(p_age_fctr_id                in number,
901                          p_no_mn_age_flag  in varchar2,
902                          p_mn_age_num                 in number,
903                          p_no_mx_age_flag  in varchar2,
904                          p_mx_age_num                   in number,
905                          p_object_version_number       in number) is
906   --
907   l_proc   varchar2(72)  := g_package || 'chk_mn_mx_age_num';
908   l_api_updating   boolean;
909   l_dummy  varchar2(1);
910   --
911 Begin
912   --
913   hr_utility.set_location('Entering:'||l_proc, 5);
914   --
915   -- Minimum Age Number must be < Maximum Age Number,
916   -- if both are used.
917   --
918   if p_mn_age_num is not null and p_mx_age_num is not null then
919       --
920       -- raise error if max value not greater than min value
921       --
922     -- Bug fix 1873685 : UNABLE TO DEFINE AGE BANDS OF ONLY ONE YEAR AFTER BEN D APPLIED
923     --
924     -- if  (p_mx_age_num <= p_mn_age_num)  then
925     if  (p_mx_age_num < p_mn_age_num)  then
926     -- end of fix 1873685
927       fnd_message.set_name('BEN','BEN_91069_INVALID_MIN_MAX');
928       fnd_message.raise_error;
929     end if;
930       --
931       --
932   end if;
933     --
934       -- If No Minimum age flag set to "on" (Y),
935       --    then minimum age number must be blank.
936       --
937     if  nvl( p_no_mn_age_flag, hr_api.g_varchar2)  = 'Y'
938          and p_mn_age_num is not null
939     then
940       fnd_message.set_name('BEN','BEN_91054_MIN_VAL_NOT_NULL');
941       fnd_message.raise_error;
942     elsif  nvl( p_no_mn_age_flag, hr_api.g_varchar2)  = 'N'
943          and p_mn_age_num is null
944     then
945       fnd_message.set_name('BEN','BEN_91055_MIN_VAL_REQUIRED');
946       fnd_message.raise_error;
947     end if;
948       --
949       -- If No Maximum age flag set to "on" (Y),
950       --    then maximum age number must be blank.
951       --
952     if  nvl( p_no_mx_age_flag, hr_api.g_varchar2)  = 'Y'
953          and p_mx_age_num is not null
954     then
955       fnd_message.set_name('BEN','BEN_91056_MAX_VAL_NOT_NULL');
956       fnd_message.raise_error;
957     elsif  nvl( p_no_mx_age_flag, hr_api.g_varchar2)  = 'N'
958          and p_mx_age_num is null
959     then
960       fnd_message.set_name('BEN','BEN_91057_MAX_VAL_REQUIRED');
961       fnd_message.raise_error;
962     end if;
963    --
964   hr_utility.set_location('Leaving:'||l_proc,10);
965   --
966 end chk_mn_mx_age_num;
967 ------------------------------------------------------------------------
968 ----
969 -- |------< chk_name >------|
970 --
971 ------------------------------------------------------------------------
972 ----
973 --
974 -- Description
975 --   This procedure is used to check that the Name is unique in a business group.
976 --
977 -- Pre Conditions
978 --   None.
979 --
980 -- In Parameters
981 --   age_fctr_id PK of record being inserted or updated.
982 --   name Value of Name.
983 --   effective_date effective date
984 --   object_version_number Object version number of record being
985 --                         inserted or updated.
986 --
987 -- Post Success
988 --   Processing continues
989 --
990 -- Post Failure
991 --   Error handled by procedure
992 --
993 -- Access Status
994 --   Internal table handler use only.
995 --
996 Procedure chk_name(p_age_fctr_id                in number,
997                          p_business_group_id                in number,
998                          p_name                    in varchar2,
999                          p_effective_date              in date,
1000                          p_object_version_number       in number) is
1001   --
1002   l_proc         varchar2(72):= g_package||'chk_name';
1003   l_api_updating boolean;
1004   l_dummy        varchar2(1);
1005   --
1006   cursor c1 is
1007     select null
1008     from   ben_age_fctr  agf
1009     where  agf.business_group_id = p_business_group_id and
1010                  agf.name = p_name;
1011 Begin
1012   --
1013   hr_utility.set_location('Entering:'||l_proc, 5);
1014   --
1015   l_api_updating := ben_agf_shd.api_updating
1016     (p_age_fctr_id                => p_age_fctr_id,
1017      -- p_effective_date              => p_effective_date,
1018      p_object_version_number       => p_object_version_number);
1019   --
1020   if (l_api_updating
1021       and nvl(p_name,hr_api.g_varchar2)
1022       <> ben_agf_shd.g_old_rec.name
1023       or not l_api_updating)
1024       and p_name is not null then
1025     --
1026     -- check if name already used.
1027     --
1028    open c1;
1029       --
1030       -- fetch value from cursor if it returns a record then the
1031       -- name is invalid otherwise its valid
1032       --
1033       fetch c1 into l_dummy;
1034       if c1%found then
1035         --
1036         close c1;
1037         --
1038         -- raise error
1039         --
1043       end if;
1040         fnd_message.set_name('BEN','BEN_91009_NAME_NOT_UNIQUE');
1041         fnd_message.raise_error;
1042         --
1044       --
1045     close c1;
1046   end if;
1047   --
1048   hr_utility.set_location('Leaving:'||l_proc,10);
1049   --
1050 end chk_name;
1051   --
1052 
1053 -- ----------------------------------------------------------------------- --
1054 -- -----------------------< chk_child_records >-----------------------------|
1055 -- -------------------------------------------------------------------------
1056 --
1057 -- Description
1058 --   This procedure is used to check that age factor records do not exist in the
1059 --   ben_cmbn_age_los_fctr table when the user deletes the record in the ben_
1060 --   age_fctr table.
1061 --
1062 -- Pre Conditions
1063 --   None.
1064 --
1065 -- In Parameters
1066 --   age_fctr_id        PK of record being inserted or updated.
1067 --
1068 -- Post Success
1069 --   Processing continues
1070 --
1071 -- Post Failure
1072 --   Error handled by procedure
1073 --
1074 -- Access Status
1075 --   Internal table handler use only.
1076 --
1077 procedure chk_child_records(p_age_fctr_id  in number) is
1078   --
1079   l_proc         varchar2(72):= g_package||'chk_child_records';
1080 
1081   --
1082    cursor chk_cmbn_age_los_fctr is select null
1083                                    from   ben_cmbn_age_los_fctr cla
1084                                    where  cla.age_fctr_id = p_age_fctr_id;
1085 
1086 begin
1087   --
1088   hr_utility.set_location('Entering:'||l_proc, 5);
1089   --
1090     -- check if age factor record exists in the ben_cmbn_age_los_fctr table
1091     --
1092   /* open chk_cmbn_age_los_fctr;
1093      --
1094      -- fetch value from cursor if it returns a record then the
1095      -- the user cannot delete the age factor
1096      --
1097    fetch chk_cmbn_age_los_fctr into v_dummy;
1098    if chk_cmbn_age_los_fctr%found then
1099         close chk_cmbn_age_los_fctr;
1100         --
1101         -- raise error
1102         --
1103         fnd_message.set_name('BEN','BEN_91738_AGE_CHLD_RCD_EXISTS');
1104         fnd_message.raise_error;
1105         --
1106    end if;
1107    --
1108    close chk_cmbn_age_los_fctr;*/ --Bug 2978945 used the common function rows_exist
1109    --
1110 --Bug 2978945
1111   If (ben_batch_utils.rows_exist
1112           (p_base_table_name => 'ben_cmbn_age_los_fctr',
1113            p_base_key_column => 'age_fctr_id',
1114            p_base_key_value  => p_age_fctr_id
1115           )) Then
1116 	     ben_utility.child_exists_error('ben_cmbn_age_los_fctr');
1117   End If;
1118 
1119   If (ben_batch_utils.rows_exist
1120           (p_base_table_name => 'ben_age_rt_f',
1121            p_base_key_column => 'age_fctr_id',
1122            p_base_key_value  => p_age_fctr_id
1123           )) Then
1124 	     ben_utility.child_exists_error('ben_age_rt_f');
1125   End If;
1126 
1127   If (ben_batch_utils.rows_exist
1128           (p_base_table_name => 'ben_elig_age_cvg_f',
1129            p_base_key_column => 'age_fctr_id',
1130            p_base_key_value  => p_age_fctr_id
1131           )) Then
1132 	     ben_utility.child_exists_error('ben_elig_age_cvg_f');
1133   End If;
1134 
1135   If (ben_batch_utils.rows_exist
1136           (p_base_table_name => 'ben_elig_age_prte_f',
1137            p_base_key_column => 'age_fctr_id',
1138            p_base_key_value  => p_age_fctr_id
1139           )) Then
1140 	     ben_utility.child_exists_error('ben_elig_age_prte_f');
1141   End If;
1142 
1143   If (ben_batch_utils.rows_exist
1144           (p_base_table_name => 'ben_vstg_age_rqmt',
1145            p_base_key_column => 'age_fctr_id',
1146            p_base_key_value  => p_age_fctr_id
1147           )) Then
1148 	     ben_utility.child_exists_error('ben_vstg_age_rqmt');
1149   End If;
1150 
1151 
1152 --Bug 2978945
1153 
1154   hr_utility.set_location('Leaving:'||l_proc,10);
1155   --
1156 
1157 end chk_child_records;
1158 
1159 
1160 
1161 --
1162 -- ----------------------------------------------------------------------------
1163 -- |---------------------------< insert_validate >----------------------------|
1164 -- ----------------------------------------------------------------------------
1165 Procedure insert_validate(p_rec in ben_agf_shd.g_rec_type
1166                          ,p_effective_date in date) is
1167 --
1168   l_proc  varchar2(72) := g_package||'insert_validate';
1169 --
1170 Begin
1171   hr_utility.set_location('Entering:'||l_proc, 5);
1172   --
1173   -- Call all supporting business operations
1174   --
1175   --
1176   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
1177   --
1178   chk_age_fctr_id
1179   (p_age_fctr_id          => p_rec.age_fctr_id,
1180    p_object_version_number => p_rec.object_version_number);
1181   --
1182 /*
1183   chk_organization_id
1184   (p_age_fctr_id          => p_rec.age_fctr_id,
1185    p_organization_id          => p_rec.organization_id,
1186    p_object_version_number => p_rec.object_version_number);
1187 */
1188   --
1189   chk_age_to_use_cd
1190   (p_age_fctr_id          => p_rec.age_fctr_id,
1191    p_age_to_use_cd         => p_rec.age_to_use_cd,
1192    p_effective_date        => p_effective_date,
1193    p_object_version_number => p_rec.object_version_number);
1194   --
1195   chk_rndg_rl
1196   (p_age_fctr_id           => p_rec.age_fctr_id,
1197    p_rndg_rl               => p_rec.rndg_rl,
1198    p_rndg_cd     =>  p_rec.rndg_cd,                              -- Bug 4242978
1199    p_business_group_id     => p_rec.business_group_id,
1203   chk_age_calc_rl
1200    p_effective_date        => p_effective_date,
1201    p_object_version_number => p_rec.object_version_number);
1202   --
1204   (p_age_fctr_id           => p_rec.age_fctr_id,
1205    p_age_calc_rl           => p_rec.age_calc_rl,
1206    p_business_group_id     => p_rec.business_group_id,
1207    p_effective_date        => p_effective_date,
1208    p_object_version_number => p_rec.object_version_number);
1209   --
1210   chk_rndg_cd
1211   (p_age_fctr_id          => p_rec.age_fctr_id,
1212    p_rndg_cd         => p_rec.rndg_cd,
1213    p_effective_date        => p_effective_date,
1214    p_object_version_number => p_rec.object_version_number);
1215   --
1216   chk_age_det_rl
1217   (p_age_fctr_id           => p_rec.age_fctr_id,
1218    p_age_det_rl            => p_rec.age_det_rl,
1219    p_age_det_cd            => p_rec.age_det_cd,               -- Bug No 4242978
1220    p_business_group_id     => p_rec.business_group_id,
1221    p_effective_date        => p_effective_date,
1222    p_object_version_number => p_rec.object_version_number);
1223   --
1224   chk_age_det_cd
1225   (p_age_fctr_id          => p_rec.age_fctr_id,
1226    p_age_det_cd         => p_rec.age_det_cd,
1227    p_effective_date        => p_effective_date,
1228    p_object_version_number => p_rec.object_version_number);
1229   --
1230   chk_no_mx_age_flag
1231   (p_age_fctr_id          => p_rec.age_fctr_id,
1232    p_no_mx_age_flag         => p_rec.no_mx_age_flag,
1233    p_effective_date        => p_effective_date,
1234    p_object_version_number => p_rec.object_version_number);
1235   --
1236   chk_no_mn_age_flag
1237   (p_age_fctr_id          => p_rec.age_fctr_id,
1238    p_no_mn_age_flag         => p_rec.no_mn_age_flag,
1239    p_effective_date        => p_effective_date,
1240    p_object_version_number => p_rec.object_version_number);
1241   --
1242   chk_age_uom
1243   (p_age_fctr_id          => p_rec.age_fctr_id,
1244    p_age_uom         => p_rec.age_uom,
1245    p_effective_date        => p_effective_date,
1246    p_object_version_number => p_rec.object_version_number);
1247   --
1248  chk_mn_mx_age_num
1249   (p_age_fctr_id          => p_rec.age_fctr_id,
1250    p_no_mn_age_flag   => p_rec.no_mn_age_flag,
1251    p_mn_age_num        => p_rec.mn_age_num,
1252    p_no_mx_age_flag   => p_rec.no_mx_age_flag,
1253    p_mx_age_num        => p_rec.mx_age_num,
1254    p_object_version_number => p_rec.object_version_number);
1255   --
1256   chk_name
1257   (p_age_fctr_id          => p_rec.age_fctr_id,
1258    p_business_group_id         => p_rec.business_group_id,
1259    p_name         => p_rec.name,
1260    p_effective_date        => p_effective_date,
1261    p_object_version_number => p_rec.object_version_number);
1262   --
1263   chk_age_code_rule
1264   (p_age_to_use_cd         => p_rec.age_to_use_cd,
1265    p_age_calc_rl           => p_rec.age_calc_rl);
1266   --
1267   hr_utility.set_location(' Leaving:'||l_proc, 10);
1268 End insert_validate;
1269 --
1270 -- ----------------------------------------------------------------------------
1271 -- |---------------------------< update_validate >----------------------------|
1272 -- ----------------------------------------------------------------------------
1273 Procedure update_validate(p_rec in ben_agf_shd.g_rec_type
1274                          ,p_effective_date in date) is
1275 --
1276   l_proc  varchar2(72) := g_package||'update_validate';
1277 --
1278 Begin
1279   hr_utility.set_location('Entering:'||l_proc, 5);
1280   --
1281   -- Call all supporting business operations
1282   --
1283   --
1284   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
1285   --
1286   chk_age_fctr_id
1287   (p_age_fctr_id          => p_rec.age_fctr_id,
1288    p_object_version_number => p_rec.object_version_number);
1289   --
1290 /*
1291   chk_organization_id
1292   (p_age_fctr_id          => p_rec.age_fctr_id,
1293    p_organization_id          => p_rec.organization_id,
1294    p_object_version_number => p_rec.object_version_number);
1295 */
1296   --
1297   chk_age_to_use_cd
1298   (p_age_fctr_id          => p_rec.age_fctr_id,
1299    p_age_to_use_cd         => p_rec.age_to_use_cd,
1300    p_effective_date        => p_effective_date,
1301    p_object_version_number => p_rec.object_version_number);
1302   --
1303   chk_rndg_rl
1304   (p_age_fctr_id           => p_rec.age_fctr_id,
1305    p_rndg_rl               => p_rec.rndg_rl,
1306    p_rndg_cd     =>  p_rec.rndg_cd,                                 -- Bug 4242978
1307    p_business_group_id     => p_rec.business_group_id,
1308    p_effective_date        => p_effective_date,
1309    p_object_version_number => p_rec.object_version_number);
1310   --
1311   chk_age_calc_rl
1312   (p_age_fctr_id           => p_rec.age_fctr_id,
1313    p_age_calc_rl           => p_rec.age_calc_rl,
1314    p_business_group_id     => p_rec.business_group_id,
1315    p_effective_date        => p_effective_date,
1316    p_object_version_number => p_rec.object_version_number);
1317   --
1318   chk_rndg_cd
1319   (p_age_fctr_id           => p_rec.age_fctr_id,
1320    p_rndg_cd               => p_rec.rndg_cd,
1321    p_effective_date        => p_effective_date,
1322    p_object_version_number => p_rec.object_version_number);
1323   --
1324   chk_age_det_rl
1325   (p_age_fctr_id           => p_rec.age_fctr_id,
1326    p_age_det_rl            => p_rec.age_det_rl,
1327    p_age_det_cd            => p_rec.age_det_cd,               -- Bug No 4242978
1328    p_business_group_id     => p_rec.business_group_id,
1329    p_effective_date        => p_effective_date,
1330    p_object_version_number => p_rec.object_version_number);
1331   --
1332   chk_age_det_cd
1333   (p_age_fctr_id           => p_rec.age_fctr_id,
1337   --
1334    p_age_det_cd            => p_rec.age_det_cd,
1335    p_effective_date        => p_effective_date,
1336    p_object_version_number => p_rec.object_version_number);
1338   chk_no_mx_age_flag
1339   (p_age_fctr_id          => p_rec.age_fctr_id,
1340    p_no_mx_age_flag         => p_rec.no_mx_age_flag,
1341    p_effective_date        => p_effective_date,
1342    p_object_version_number => p_rec.object_version_number);
1343   --
1344   chk_no_mn_age_flag
1345   (p_age_fctr_id          => p_rec.age_fctr_id,
1346    p_no_mn_age_flag         => p_rec.no_mn_age_flag,
1347    p_effective_date        => p_effective_date,
1348    p_object_version_number => p_rec.object_version_number);
1349   --
1350   chk_age_uom
1351   (p_age_fctr_id          => p_rec.age_fctr_id,
1352    p_age_uom         => p_rec.age_uom,
1353    p_effective_date        => p_effective_date,
1354    p_object_version_number => p_rec.object_version_number);
1355   --
1356  chk_mn_mx_age_num
1357   (p_age_fctr_id          => p_rec.age_fctr_id,
1358    p_no_mn_age_flag   => p_rec.no_mn_age_flag,
1359    p_mn_age_num        => p_rec.mn_age_num,
1360    p_no_mx_age_flag   => p_rec.no_mx_age_flag,
1361    p_mx_age_num        => p_rec.mx_age_num,
1362    p_object_version_number => p_rec.object_version_number);
1363   --
1364  chk_name
1365   (p_age_fctr_id          => p_rec.age_fctr_id,
1366    p_business_group_id         => p_rec.business_group_id,
1367    p_name         => p_rec.name,
1368    p_effective_date        => p_effective_date,
1369    p_object_version_number => p_rec.object_version_number);
1370   --
1371   chk_age_code_rule
1372   (p_age_to_use_cd         => p_rec.age_to_use_cd,
1373    p_age_calc_rl           => p_rec.age_calc_rl);
1374   --
1375   hr_utility.set_location(' Leaving:'||l_proc, 10);
1376 End update_validate;
1377 --
1378 -- ----------------------------------------------------------------------------
1379 -- |---------------------------< delete_validate >----------------------------|
1380 -- ----------------------------------------------------------------------------
1381 Procedure delete_validate(p_rec in ben_agf_shd.g_rec_type
1382                          ,p_effective_date in date) is
1383 --
1384   l_proc  varchar2(72) := g_package||'delete_validate';
1385 --
1386 Begin
1387   hr_utility.set_location('Entering:'||l_proc, 5);
1388   --
1389   -- Call all supporting business operations
1390   chk_child_records(p_age_fctr_id => p_rec.age_fctr_id);
1391   --
1392   hr_utility.set_location(' Leaving:'||l_proc, 10);
1393 End delete_validate;
1394 --
1395 --
1396 --  ---------------------------------------------------------------------------
1397 --  |---------------------< return_legislation_code >-------------------------|
1398 --  ---------------------------------------------------------------------------
1399 --
1400 function return_legislation_code
1401   (p_age_fctr_id in number) return varchar2 is
1402   --
1403   -- Declare cursor
1404   --
1405   cursor csr_leg_code is
1406     select a.legislation_code
1407     from   per_business_groups a,
1408            ben_age_fctr b
1409     where b.age_fctr_id      = p_age_fctr_id
1410     and   a.business_group_id = b.business_group_id;
1411   --
1412   -- Declare local variables
1413   --
1414   l_legislation_code  varchar2(150);
1415   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
1416   --
1417 begin
1418   --
1419   hr_utility.set_location('Entering:'|| l_proc, 10);
1420   --
1421   -- Ensure that all the mandatory parameter are not null
1422   --
1423   hr_api.mandatory_arg_error(p_api_name       => l_proc,
1424                              p_argument       => 'age_fctr_id',
1425                              p_argument_value => p_age_fctr_id);
1426   --
1427   open csr_leg_code;
1428     --
1429     fetch csr_leg_code into l_legislation_code;
1430     --
1431     if csr_leg_code%notfound then
1432       --
1433       close csr_leg_code;
1434       --
1435       -- The primary key is invalid therefore we must error
1436       --
1437       hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
1438       hr_utility.raise_error;
1439       --
1440     end if;
1441     --
1442   close csr_leg_code;
1443   --
1444   hr_utility.set_location(' Leaving:'|| l_proc, 20);
1445   --
1446   return l_legislation_code;
1447   --
1448 end return_legislation_code;
1449 --
1450 end ben_agf_bus;