DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CCT_BUS

Source


1 Package Body ben_cct_bus as
2 /* $Header: becctrhi.pkb 120.0.12020000.4 2012/07/03 11:57:28 amnaraya ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_cct_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< chk_cm_typ_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 --   cm_typ_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_cm_typ_id(p_cm_typ_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_cm_typ_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_cct_shd.api_updating
49     (p_effective_date           => p_effective_date,
50      p_cm_typ_id                => p_cm_typ_id,
51      p_object_version_number    => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_cm_typ_id,hr_api.g_number)
55      <>  ben_cct_shd.g_old_rec.cm_typ_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_cct_shd.constraint_error('BEN_CM_TYP_F_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_cm_typ_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_cct_shd.constraint_error('BEN_CM_TYP_F_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_cm_typ_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |------------------------< chk_name_unique >-------------------------------|
81 -- ----------------------------------------------------------------------------
82 --
83 -- Description
84 --   ensure that the  Name is unique
85 --
86 -- Pre Conditions
87 --   None.
88 --
89 -- In Parameters
90 --     p_name is  name
91 --     p_benfts_grp_id is benfts_grp_id
92 --     p_business_group_id
93 --
94 -- Post Success
95 --   Processing continues
96 --
97 -- Post Failure
98 --   Errors handled by the procedure
99 --
100 -- Access Status
101 --   Internal table handler use only.
102 ---- ----------------------------------------------------------------------------
103 Procedure chk_name_unique
104           ( p_cm_typ_id            in   number
105            ,p_name                 in   varchar2
106            ,p_business_group_id    in   number) is
107   --
108   l_proc      varchar2(72) := g_package||'chk_name_unique';
109   l_dummy    char(1);
110   cursor c1 is
111     select null
112     from   ben_cm_typ_f
113     where  name = p_name
114     and    cm_typ_id <> nvl(p_cm_typ_id,-1)
115     and    business_group_id = p_business_group_id;
116 --
117 Begin
118   hr_utility.set_location('Entering:'||l_proc, 5);
119   --
120   open c1;
121   fetch c1 into l_dummy;
122   if c1%found then
123       close c1;
124       fnd_message.set_name('BEN','BEN_91009_NAME_NOT_UNIQUE');
125       fnd_message.raise_error;
126   end if;
127   --
128   hr_utility.set_location('Leaving:'||l_proc, 15);
129 End chk_name_unique;
130 --
131 -- ----------------------------------------------------------------------------
132 -- |------------------------< chk_rcpent_cd >-------------------------|
133 -- ----------------------------------------------------------------------------
134 --
135 -- Description
136 --   This procedure is used to check that the lookup value is valid.
137 --
138 -- Pre Conditions
139 --   None.
140 --
141 -- In Parameters
142 --   cm_typ_id PK of record being inserted or updated.
143 --   rcpent_cd Value of lookup code.
144 --   effective_date effective date
148 -- Post Success
145 --   object_version_number Object version number of record being
146 --                         inserted or updated.
147 --
149 --   Processing continues
150 --
151 -- Post Failure
152 --   Error handled by procedure
153 --
154 -- Access Status
155 --   Internal table handler use only.
156 --
157 Procedure chk_rcpent_cd(p_cm_typ_id                in number,
158                         p_rcpent_cd                in varchar2,
159                         p_effective_date           in date,
160                         p_object_version_number    in number) is
161   --
162   l_proc         varchar2(72) := g_package||'chk_rcpent_cd';
163   l_api_updating boolean;
164   --
165 Begin
166   --
167   hr_utility.set_location('Entering:'||l_proc, 5);
168   --
169   l_api_updating := ben_cct_shd.api_updating
170     (p_cm_typ_id                => p_cm_typ_id,
171      p_effective_date           => p_effective_date,
172      p_object_version_number    => p_object_version_number);
173   --
174   if (l_api_updating
175       and p_rcpent_cd
176       <> nvl(ben_cct_shd.g_old_rec.rcpent_cd,hr_api.g_varchar2)
177       or not l_api_updating) then
178     --
179     -- check if value of lookup falls within lookup type.
180     --
181     --
182     if p_rcpent_cd is not null and hr_api.not_exists_in_hr_lookups
183           (p_lookup_type    => 'BEN_RCPENT',
184            p_lookup_code    => p_rcpent_cd,
185            p_effective_date => p_effective_date) then
186       --
187       -- raise error as does not exist as lookup
188       --
189       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
190       fnd_message.set_token('FIELD','p_rcpent_cd');
191       fnd_message.set_token('TYPE','BEN_RCPENT');
192       fnd_message.raise_error;
193       --
194     end if;
195     --
196   end if;
197   --
198   hr_utility.set_location('Leaving:'||l_proc,10);
199   --
200 end chk_rcpent_cd;
201 --
202 -- ----------------------------------------------------------------------------
203 -- |-------------------------< chk_inspn_rqd_rl >-----------------------------|
204 -- ----------------------------------------------------------------------------
205 --
206 -- Description
207 --   This procedure is used to check that the Formula Rule is valid.
208 --
209 -- Pre Conditions
210 --   None.
211 --
212 -- In Parameters
213 --   cm_typ_id PK of record being inserted or updated.
214 --   inspn_rqd_rl Value of formula rule id.
215 --   effective_date effective date
216 --   object_version_number Object version number of record being
217 --                         inserted or updated.
218 --
219 -- Post Success
220 --   Processing continues
221 --
222 -- Post Failure
223 --   Error handled by procedure
224 --
225 -- Access Status
226 --   Internal table handler use only.
227 --
228 Procedure chk_inspn_rqd_rl(p_cm_typ_id                in number,
229                            p_inspn_rqd_rl             in number,
230                            p_effective_date           in date,
231                            p_business_group_id        in number,
232                            p_object_version_number    in number) is
233   --
234   l_proc         varchar2(72) := g_package||'chk_inspn_rqd_rl';
235   l_api_updating boolean;
236   --
237 Begin
238   --
239   hr_utility.set_location('Entering:'||l_proc, 5);
240   --
241   l_api_updating := ben_cct_shd.api_updating
242     (p_cm_typ_id                => p_cm_typ_id,
243      p_effective_date           => p_effective_date,
244      p_object_version_number    => p_object_version_number);
245   --
246   if (l_api_updating
247       and nvl(p_inspn_rqd_rl,hr_api.g_number)
248       <> ben_cct_shd.g_old_rec.inspn_rqd_rl
249       or not l_api_updating)
250       and p_inspn_rqd_rl is not null then
251     --
252     -- check if value of formula rule is valid.
253     --
254     if not benutils.formula_exists
255          (p_formula_id        => p_inspn_rqd_rl,
256           p_formula_type_id   => -313,
257           p_business_group_id => p_business_group_id,
258           p_effective_date    => p_effective_date) then
259       --
260       fnd_message.set_name('BEN','BEN_91471_FORMULA_NOT_FOUND');
261       fnd_message.set_token('ID',p_inspn_rqd_rl);
262       fnd_message.set_token('TYPE_ID',-313);
263       fnd_message.raise_error;
264       --
265     end if;
266     --
267   end if;
268   --
269   hr_utility.set_location('Leaving:'||l_proc,10);
270   --
271 end chk_inspn_rqd_rl;
272 --
273 -- ----------------------------------------------------------------------------
274 -- |-----------------------< chk_inspn_rqd_flag >-----------------------------|
275 -- ----------------------------------------------------------------------------
276 --
277 -- Description
278 --   This procedure is used to check that the lookup value is valid.
279 --
280 -- Pre Conditions
281 --   None.
282 --
283 -- In Parameters
284 --   cm_typ_id PK of record being inserted or updated.
285 --   inspn_rqd_flag Value of lookup code.
286 --   effective_date effective date
287 --   object_version_number Object version number of record being
288 --                         inserted or updated.
289 --
290 -- Post Success
291 --   Processing continues
292 --
293 -- Post Failure
294 --   Error handled by procedure
295 --
296 -- Access Status
297 --   Internal table handler use only.
298 --
299 Procedure chk_inspn_rqd_flag(p_cm_typ_id                in number,
300                              p_inspn_rqd_flag           in varchar2,
304   l_proc         varchar2(72) := g_package||'chk_inspn_rqd_flag';
301                              p_effective_date           in date,
302                              p_object_version_number    in number) is
303   --
305   l_api_updating boolean;
306   --
307 Begin
308   --
309   hr_utility.set_location('Entering:'||l_proc, 5);
310   --
311   l_api_updating := ben_cct_shd.api_updating
312     (p_cm_typ_id                => p_cm_typ_id,
313      p_effective_date           => p_effective_date,
314      p_object_version_number    => p_object_version_number);
315   --
316   if (l_api_updating
317       and p_inspn_rqd_flag
318       <> nvl(ben_cct_shd.g_old_rec.inspn_rqd_flag,hr_api.g_varchar2)
319       or not l_api_updating) then
320     --
321     -- check if value of lookup falls within lookup type.
322     --
323     if hr_api.not_exists_in_hr_lookups
324           (p_lookup_type    => 'YES_NO',
325            p_lookup_code    => p_inspn_rqd_flag,
326            p_effective_date => p_effective_date) then
327       --
328       -- raise error as does not exist as lookup
329       --
330       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
331       fnd_message.set_token('FIELD','p_inspn_rqd_flag');
332       fnd_message.set_token('TYPE','YES_NO');
333       fnd_message.raise_error;
334       --
335     end if;
336     --
337   end if;
338   --
339   hr_utility.set_location('Leaving:'||l_proc,10);
340   --
341 end chk_inspn_rqd_flag;
342 --
343 -- ----------------------------------------------------------------------------
344 -- |----------------------< chk_to_be_sent_dt_rl >----------------------------|
345 -- ----------------------------------------------------------------------------
346 --
347 -- Description
348 --   This procedure is used to check that the Formula Rule is valid.
349 --
350 -- Pre Conditions
351 --   None.
352 --
353 -- In Parameters
354 --   cm_typ_id PK of record being inserted or updated.
355 --   to_be_sent_dt_rl Value of formula rule id.
356 --   effective_date effective date
357 --   object_version_number Object version number of record being
358 --                         inserted or updated.
359 --
360 -- Post Success
361 --   Processing continues
362 --
363 -- Post Failure
364 --   Error handled by procedure
365 --
366 -- Access Status
367 --   Internal table handler use only.
368 --
369 Procedure chk_to_be_sent_dt_rl(p_cm_typ_id                in number,
370                                p_to_be_sent_dt_rl         in number,
371                                p_effective_date           in date,
372                                p_business_group_id        in number,
373                                p_object_version_number    in number) is
374   --
375   l_proc         varchar2(72) := g_package||'chk_to_be_sent_dt_rl';
376   l_api_updating boolean;
377   --
378 Begin
379   --
380   hr_utility.set_location('Entering:'||l_proc, 5);
381   --
382   l_api_updating := ben_cct_shd.api_updating
383     (p_cm_typ_id                => p_cm_typ_id,
384      p_effective_date           => p_effective_date,
385      p_object_version_number    => p_object_version_number);
386   --
387   if (l_api_updating
388       and nvl(p_to_be_sent_dt_rl,hr_api.g_number)
389       <> ben_cct_shd.g_old_rec.to_be_sent_dt_rl
390       or not l_api_updating)
391       and p_to_be_sent_dt_rl is not null then
392     --
393     -- check if value of formula rule is valid.
394     --
395     if not benutils.formula_exists
396          (p_formula_id        => p_to_be_sent_dt_rl,
397           p_formula_type_id   => -45,
398           p_business_group_id => p_business_group_id,
399           p_effective_date    => p_effective_date) then
400       --
401       fnd_message.set_name('BEN','BEN_91471_FORMULA_NOT_FOUND');
402       fnd_message.set_token('ID',p_to_be_sent_dt_rl);
403       fnd_message.set_token('TYPE_ID',-45);
404       fnd_message.raise_error;
405       --
406     end if;
407     --
408   end if;
409   --
410   hr_utility.set_location('Leaving:'||l_proc,10);
411   --
412 end chk_to_be_sent_dt_rl;
413 --
414 -- ----------------------------------------------------------------------------
415 -- |------------------------< chk_to_be_sent_dt_cd >--------------------------|
416 -- ----------------------------------------------------------------------------
417 --
418 -- Description
419 --   This procedure is used to check that the lookup value is valid.
420 --
421 -- Pre Conditions
422 --   None.
423 --
424 -- In Parameters
425 --   cm_typ_id PK of record being inserted or updated.
426 --   to_be_sent_dt_cd Value of lookup code.
427 --   effective_date effective date
428 --   object_version_number Object version number of record being
429 --                         inserted or updated.
430 --
431 -- Post Success
432 --   Processing continues
433 --
434 -- Post Failure
435 --   Error handled by procedure
436 --
437 -- Access Status
438 --   Internal table handler use only.
439 --
440 Procedure chk_to_be_sent_dt_cd(p_cm_typ_id                in number,
441                                p_to_be_sent_dt_cd         in varchar2,
442                                p_effective_date           in date,
443                                p_object_version_number    in number) is
444   --
445   l_proc         varchar2(72) := g_package||'chk_to_be_sent_dt_cd';
446   l_api_updating boolean;
447   --
448 Begin
449   --
450   hr_utility.set_location('Entering:'||l_proc, 5);
451   --
452   l_api_updating := ben_cct_shd.api_updating
453     (p_cm_typ_id                => p_cm_typ_id,
457   if (l_api_updating
454      p_effective_date           => p_effective_date,
455      p_object_version_number    => p_object_version_number);
456   --
458       and p_to_be_sent_dt_cd
459       <> nvl(ben_cct_shd.g_old_rec.to_be_sent_dt_cd,hr_api.g_varchar2)
460       or not l_api_updating) then
461     --
462     -- check if value of lookup falls within lookup type.
463     --
464     --
465     if hr_api.not_exists_in_hr_lookups
466           (p_lookup_type    => 'BEN_TO_BE_SENT_DT',
467            p_lookup_code    => p_to_be_sent_dt_cd,
468            p_effective_date => p_effective_date)  or p_to_be_sent_dt_cd is null
469       then
470       --
471       -- raise error as does not exist as lookup
472       --
473       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
474       fnd_message.set_token('FIELD',p_to_be_sent_dt_cd);
475       fnd_message.set_token('TYPE','BEN_TO_BE_SENT_DT');
476       fnd_message.raise_error;
477       --
478     end if;
479     --
480   end if;
481   --
482   hr_utility.set_location('Leaving:'||l_proc,10);
483   --
484 end chk_to_be_sent_dt_cd;
485 --
486 -- ----------------------------------------------------------------------------
487 -- |---------------------------< chk_trk_mlg_flag >---------------------------|
488 -- ----------------------------------------------------------------------------
489 --
490 -- Description
491 --   This procedure is used to check that the lookup value is valid.
492 --
493 -- Pre Conditions
494 --   None.
495 --
496 -- In Parameters
497 --   cm_typ_id PK of record being inserted or updated.
498 --   trk_mlg_flag Value of lookup code.
499 --   effective_date effective date
500 --   object_version_number Object version number of record being
501 --                         inserted or updated.
502 --
503 -- Post Success
504 --   Processing continues
505 --
506 -- Post Failure
507 --   Error handled by procedure
508 --
509 -- Access Status
510 --   Internal table handler use only.
511 --
512 Procedure chk_trk_mlg_flag(p_cm_typ_id                in number,
513                            p_trk_mlg_flag             in varchar2,
514                            p_effective_date           in date,
515                            p_object_version_number    in number) is
516   --
517   l_proc         varchar2(72) := g_package||'chk_trk_mlg_flag';
518   l_api_updating boolean;
519   --
520 Begin
521   --
522   hr_utility.set_location('Entering:'||l_proc, 5);
523   --
524   l_api_updating := ben_cct_shd.api_updating
525     (p_cm_typ_id                => p_cm_typ_id,
526      p_effective_date           => p_effective_date,
527      p_object_version_number    => p_object_version_number);
528   --
529   if (l_api_updating
530       and p_trk_mlg_flag
531       <> nvl(ben_cct_shd.g_old_rec.trk_mlg_flag,hr_api.g_varchar2)
532       or not l_api_updating) then
533     --
534     -- check if value of lookup falls within lookup type.
535     --
536     --
537     if hr_api.not_exists_in_hr_lookups
538           (p_lookup_type    => 'YES_NO',
539            p_lookup_code    => p_trk_mlg_flag,
540            p_effective_date => p_effective_date) then
541       --
542       -- raise error as does not exist as lookup
543       --
544       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
545       fnd_message.set_token('FIELD',p_trk_mlg_flag);
546       fnd_message.set_token('TYPE','YES_NO');
547       fnd_message.raise_error;
548       --
549     end if;
550     --
551   end if;
552   --
553   hr_utility.set_location('Leaving:'||l_proc,10);
554   --
555 end chk_trk_mlg_flag;
556 --
557 -- ----------------------------------------------------------------------------
558 -- |----------------------------< chk_pc_kit_cd >-----------------------------|
559 -- ----------------------------------------------------------------------------
560 --
561 -- Description
562 --   This procedure is used to check that the lookup value is valid.
563 --
564 -- Pre Conditions
565 --   None.
566 --
567 -- In Parameters
568 --   cm_typ_id PK of record being inserted or updated.
569 --   pc_kit_cd Value of lookup code.
570 --   effective_date effective date
571 --   object_version_number Object version number of record being
572 --                         inserted or updated.
573 --
574 -- Post Success
575 --   Processing continues
576 --
577 -- Post Failure
578 --   Error handled by procedure
579 --
580 -- Access Status
581 --   Internal table handler use only.
582 --
583 Procedure chk_pc_kit_cd(p_cm_typ_id               in number,
584                         p_pc_kit_cd               in varchar2,
585                         p_effective_date          in date,
586                         p_object_version_number   in number) is
587   --
588   l_proc         varchar2(72) := g_package||'chk_pc_kit_cd';
589   l_api_updating boolean;
590   --
591 Begin
592   --
593   hr_utility.set_location('Entering:'||l_proc, 5);
594   --
595   l_api_updating := ben_cct_shd.api_updating
596     (p_cm_typ_id                => p_cm_typ_id,
597      p_effective_date           => p_effective_date,
598      p_object_version_number    => p_object_version_number);
599   --
600   if (l_api_updating
601       and p_pc_kit_cd
602       <> nvl(ben_cct_shd.g_old_rec.pc_kit_cd,hr_api.g_varchar2)
603       or not l_api_updating)
604       and p_pc_kit_cd is not null then
605     --
606     -- check if value of lookup falls within lookup type.
607     --
608     if hr_api.not_exists_in_hr_lookups
609           (p_lookup_type    => 'BEN_PC_KIT',
613       -- raise error as does not exist as lookup
610            p_lookup_code    => p_pc_kit_cd,
611            p_effective_date => p_effective_date) then
612       --
614       --
615       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
616       fnd_message.set_token('FIELD',p_pc_kit_cd);
617       fnd_message.set_token('TYPE','BEN_PC_KIT');
618       fnd_message.raise_error;
619       --
620     end if;
621     --
622   end if;
623   --
624   hr_utility.set_location('Leaving:'||l_proc,10);
625   --
626 end chk_pc_kit_cd;
627 --
628 -- ----------------------------------------------------------------------------
629 -- |-------------------------< chk_whnvr_trgrd_flag >-------------------------|
630 -- ----------------------------------------------------------------------------
631 --
632 -- Description
633 --   This procedure is used to check that the lookup value is valid.
634 --
635 -- Pre Conditions
636 --   None.
637 --
638 -- In Parameters
639 --   cm_typ_id PK of record being inserted or updated.
640 --   whnvr_trgrd_flag Value of lookup code.
641 --   effective_date effective date
642 --   object_version_number Object version number of record being
643 --                         inserted or updated.
644 --
645 -- Post Success
646 --   Processing continues
647 --
648 -- Post Failure
649 --   Error handled by procedure
650 --
651 -- Access Status
652 --   Internal table handler use only.
653 --
654 Procedure chk_whnvr_trgrd_flag(p_cm_typ_id                in number,
655                                p_whnvr_trgrd_flag         in varchar2,
656                                p_effective_date           in date,
657                                p_object_version_number    in number) is
658   --
659   l_proc         varchar2(72) := g_package||'chk_whnvr_trgrd_flag';
660   l_api_updating boolean;
661   --
662 Begin
663   --
664   hr_utility.set_location('Entering:'||l_proc, 5);
665   --
666   l_api_updating := ben_cct_shd.api_updating
667     (p_cm_typ_id                => p_cm_typ_id,
668      p_effective_date           => p_effective_date,
669      p_object_version_number    => p_object_version_number);
670   --
671   if (l_api_updating
672       and p_whnvr_trgrd_flag
673       <> nvl(ben_cct_shd.g_old_rec.whnvr_trgrd_flag,hr_api.g_varchar2)
674       or not l_api_updating) then
675     --
676     -- check if value of lookup falls within lookup type.
677     --
678     --
679     if hr_api.not_exists_in_hr_lookups
680           (p_lookup_type    => 'YES_NO',
681            p_lookup_code    => p_whnvr_trgrd_flag,
682            p_effective_date => p_effective_date) then
683       --
684       -- raise error as does not exist as lookup
685       --
686       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
687       fnd_message.set_token('FIELD','p_whnvr_trgrd_flag');
688       fnd_message.set_token('TYPE','YES_NO');
689       fnd_message.raise_error;
690       --
691     end if;
692     --
693   end if;
694   --
695   hr_utility.set_location('Leaving:'||l_proc,10);
696   --
697 end chk_whnvr_trgrd_flag;
698 --
699 -- ----------------------------------------------------------------------------
700 -- |--------------------------< chk_cm_usg_cd >-------------------------------|
701 -- ----------------------------------------------------------------------------
702 --
703 -- Description
704 --   This procedure is used to check that the lookup value is valid.
705 --
706 -- Pre Conditions
707 --   None.
708 --
709 -- In Parameters
710 --   cm_typ_id PK of record being inserted or updated.
711 --   cm_usg_cd Value of lookup code.
712 --   effective_date effective date
713 --   object_version_number Object version number of record being
714 --                         inserted or updated.
715 --
716 -- Post Success
717 --   Processing continues
718 --
719 -- Post Failure
720 --   Error handled by procedure
721 --
722 -- Access Status
723 --   Internal table handler use only.
724 --
725 Procedure chk_cm_usg_cd(p_cm_typ_id              in number,
726                      p_cm_usg_cd                 in varchar2,
727                      p_effective_date         in date,
728                      p_object_version_number  in number,
729                      p_to_be_sent_dt_cd       in varchar2  ) is
730   --
731   l_proc         varchar2(72) := g_package||'chk_cm_usg_cd';
732   l_api_updating boolean;
733   --
734 Begin
735   --
736   hr_utility.set_location('Entering:'||l_proc, 5);
737   --
738   l_api_updating := ben_cct_shd.api_updating
739     (p_cm_typ_id                => p_cm_typ_id,
740      p_effective_date           => p_effective_date,
741      p_object_version_number    => p_object_version_number);
742   --
743   if (l_api_updating
744       and p_cm_usg_cd
745       <> nvl(ben_cct_shd.g_old_rec.cm_usg_cd,hr_api.g_varchar2)
746       or not l_api_updating)
747       and p_cm_usg_cd is not null then
748     --
749     -- check if value of lookup falls within lookup type.
750     --
751     if hr_api.not_exists_in_hr_lookups
752           (p_lookup_type    => 'BEN_CM_USG',
753            p_lookup_code    => p_cm_usg_cd,
754            p_effective_date => p_effective_date) then
755       --
756       -- raise error as does not exist as lookup
757       --
758       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
759       fnd_message.set_token('FIELD','p_cm_usg_cd');
760       fnd_message.set_token('TYPE','BEN_USG');
761       fnd_message.raise_error;
762       --
763     end if;
764     --
765   end if;
769      (p_to_be_sent_dt_cd='NA' and nvl(p_cm_usg_cd,' ') <> 'SSIT')  then
766   --
767   -- bug 1384583 when the cm_usg_cod is 'SSIT' then validate p_to_be_sent dt for  'NA'
768   if (p_cm_usg_cd = 'SSIT' and p_to_be_sent_dt_cd <>  'NA') or
770     fnd_message.set_name('BEN','BEN_92654_SENT_DATE_FOR_USAGE');
771     fnd_message.set_token('TYPE','BEN_TO_BE_SENT_DT');
772     fnd_message.raise_error;
773   End if ;
774 
775 
776   hr_utility.set_location('Leaving:'||l_proc,10);
777   --
778 end chk_cm_usg_cd;
779 --
780 -- ----------------------------------------------------------------------------
781 -- |---------------------------< chk_cm_typ_rl >------------------------------|
782 -- ----------------------------------------------------------------------------
783 --
784 -- Description
785 --   This procedure is used to check that the Formula Rule is valid.
786 --
787 -- Pre Conditions
788 --   None.
789 --
790 -- In Parameters
791 --   cm_typ_id PK of record being inserted or updated.
792 --   cm_typ_rl Value of formula rule id.
793 --   effective_date effective date
794 --   object_version_number Object version number of record being
795 --                         inserted or updated.
796 --
797 -- Post Success
798 --   Processing continues
799 --
800 -- Post Failure
801 --   Error handled by procedure
802 --
803 -- Access Status
804 --   Internal table handler use only.
805 --
806 Procedure chk_cm_typ_rl(p_cm_typ_id              in number,
807                         p_cm_typ_rl              in number,
808                         p_effective_date         in date,
809                         p_business_group_id      in number,
810                         p_object_version_number  in number) is
811   --
812   l_proc         varchar2(72) := g_package||'chk_cm_typ_rl';
813   l_api_updating boolean;
814   --
815 Begin
816   --
817   hr_utility.set_location('Entering:'||l_proc, 5);
818   --
819   l_api_updating := ben_cct_shd.api_updating
820     (p_cm_typ_id                => p_cm_typ_id,
821      p_effective_date           => p_effective_date,
822      p_object_version_number    => p_object_version_number);
823   --
824   if (l_api_updating
825       and nvl(p_cm_typ_rl,hr_api.g_number)
826       <> ben_cct_shd.g_old_rec.cm_typ_rl
827       or not l_api_updating)
828       and p_cm_typ_rl is not null then
829     --
830     -- check if value of formula rule is valid.
831     --
832     if not benutils.formula_exists
833          (p_formula_id        => p_cm_typ_rl,
834           p_formula_type_id   => -332,
835           p_business_group_id => p_business_group_id,
836           p_effective_date    => p_effective_date) then
837       --
838       fnd_message.set_name('BEN','BEN_91471_FORMULA_NOT_FOUND');
839       fnd_message.set_token('ID',p_cm_typ_rl);
840       fnd_message.set_token('TYPE_ID',-332);
841       fnd_message.raise_error;
842       --
843     end if;
844     --
845   end if;
846   --
847   hr_utility.set_location('Leaving:'||l_proc,10);
848   --
849 end chk_cm_typ_rl;
850 --
851 -- ----------------------------------------------------------------------------
852 -- |--------------------------< dt_update_validate >--------------------------|
853 -- ----------------------------------------------------------------------------
854 -- {Start Of Comments}
855 --
856 -- Description:
857 --   This procedure is used for referential integrity of datetracked
858 --   parent entities when a datetrack update operation is taking place
859 --   and where there is no cascading of update defined for this entity.
860 --
861 -- Prerequisites:
862 --   This procedure is called from the update_validate.
863 --
864 -- In Parameters:
865 --
866 -- Post Success:
867 --   Processing continues.
868 --
869 -- Post Failure:
870 --
871 -- Developer Implementation Notes:
872 --   This procedure should not need maintenance unless the HR Schema model
873 --   changes.
874 --
875 -- Access Status:
876 --   Internal Row Handler Use Only.
877 --
878 -- {End Of Comments}
879 -- ----------------------------------------------------------------------------
880 Procedure dt_update_validate
881             (p_cm_typ_id                     in number default hr_api.g_number,
882 	     p_datetrack_mode		     in varchar2,
883              p_validation_start_date	     in date,
884 	     p_validation_end_date	     in date) Is
885 --
886   l_proc	    varchar2(72) := g_package||'dt_update_validate';
887   l_integrity_error Exception;
888   l_table_name	    all_tables.table_name%TYPE;
889 --
890 Begin
891   hr_utility.set_location('Entering:'||l_proc, 5);
892   --
893   -- Ensure that the p_datetrack_mode argument is not null
894   --
895   hr_api.mandatory_arg_error
896     (p_api_name       => l_proc,
897      p_argument       => 'datetrack_mode',
898      p_argument_value => p_datetrack_mode);
899   --
900   -- Only perform the validation if the datetrack update mode is valid
901   --
902   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
903     --
904     --
905     -- Ensure the arguments are not null
906     --
907     hr_api.mandatory_arg_error
908       (p_api_name       => l_proc,
909        p_argument       => 'validation_start_date',
910        p_argument_value => p_validation_start_date);
911     --
912     hr_api.mandatory_arg_error
913       (p_api_name       => l_proc,
914        p_argument       => 'validation_end_date',
915        p_argument_value => p_validation_end_date);
916     --
917 hr_utility.set_location('*******b4 check min/max dates', 5);
921              p_base_key_column => 'cm_typ_id',
918     If ((nvl(p_cm_typ_id, hr_api.g_number) <> hr_api.g_number) and
919       NOT (dt_api.check_min_max_dates
920             (p_base_table_name => 'ben_cm_typ_f',
922              p_base_key_value  => p_cm_typ_id,
923              p_from_date       => p_validation_start_date,
924              p_to_date         => p_validation_end_date)))  Then
925       l_table_name := 'ben_cm_typ_f';
926       Raise l_integrity_error;
927     End If;
928 hr_utility.set_location('*******after check min/max dates', 5);
929     --
930   End If;
931   --
932   hr_utility.set_location(' Leaving:'||l_proc, 10);
933 Exception
934   When l_integrity_error Then
935     --
936     -- A referential integrity check was violated therefore
937     -- we must error
938     --
939     ben_utility.parent_integrity_error(p_table_name => l_table_name);
940   When Others Then
941     --
942     -- An unhandled or unexpected error has occurred which
943     -- we must report
944     --
945     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
946     hr_utility.set_message_token('PROCEDURE', l_proc);
947     hr_utility.set_message_token('STEP','15');
948     hr_utility.raise_error;
949 End dt_update_validate;
950 --
951 -- ----------------------------------------------------------------------------
952 -- |--------------------------< dt_delete_validate >--------------------------|
953 -- ----------------------------------------------------------------------------
954 -- {Start Of Comments}
955 --
956 -- Description:
957 --   This procedure is used for referential integrity of datetracked
958 --   child entities when either a datetrack DELETE or ZAP is in operation
959 --   and where there is no cascading of delete defined for this entity.
960 --   For the datetrack mode of DELETE or ZAP we must ensure that no
961 --   datetracked child rows exist between the validation start and end
962 --   dates.
963 --
964 -- Prerequisites:
965 --   This procedure is called from the delete_validate.
966 --
967 -- In Parameters:
968 --
969 -- Post Success:
970 --   Processing continues.
971 --
972 -- Post Failure:
973 --   If a row exists by determining the returning Boolean value from the
974 --   generic dt_api.rows_exist function then we must supply an error via
975 --   the use of the local exception handler l_rows_exist.
976 --
977 -- Developer Implementation Notes:
978 --   This procedure should not need maintenance unless the HR Schema model
979 --   changes.
980 --
981 -- Access Status:
982 --   Internal Row Handler Use Only.
983 --
984 -- {End Of Comments}
985 -- ----------------------------------------------------------------------------
986 Procedure dt_delete_validate
987             (p_cm_typ_id		in number,
988              p_datetrack_mode		in varchar2,
989 	     p_validation_start_date	in date,
990 	     p_validation_end_date	in date) Is
991 --
992   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
993   l_rows_exist	Exception;
994   l_table_name	all_tables.table_name%TYPE;
995 --
996 Begin
997   hr_utility.set_location('Entering:'||l_proc, 5);
998   --
999   -- Ensure that the p_datetrack_mode argument is not null
1000   --
1001   hr_api.mandatory_arg_error
1002     (p_api_name       => l_proc,
1003      p_argument       => 'datetrack_mode',
1004      p_argument_value => p_datetrack_mode);
1005   --
1006   -- Only perform the validation if the datetrack mode is either
1007   -- DELETE or ZAP
1008   --
1009   If (p_datetrack_mode = 'DELETE' or
1010       p_datetrack_mode = 'ZAP') then
1011     --
1012     --
1013     -- Ensure the arguments are not null
1014     --
1015     hr_api.mandatory_arg_error
1016       (p_api_name       => l_proc,
1017        p_argument       => 'validation_start_date',
1018        p_argument_value => p_validation_start_date);
1019     --
1020     hr_api.mandatory_arg_error
1021       (p_api_name       => l_proc,
1022        p_argument       => 'validation_end_date',
1023        p_argument_value => p_validation_end_date);
1024     --
1025     hr_api.mandatory_arg_error
1026       (p_api_name       => l_proc,
1027        p_argument       => 'cm_typ_id',
1028        p_argument_value => p_cm_typ_id);
1029     --
1030 hr_utility.set_location('*******b4 check rows exist', 5);
1031     If (dt_api.rows_exist
1032           (p_base_table_name => 'ben_cm_typ_f',
1033            p_base_key_column => 'parnt_cm_typ_id',
1034            p_base_key_value  => p_cm_typ_id,
1035            p_from_date       => p_validation_start_date,
1036            p_to_date         => p_validation_end_date)) Then
1037       l_table_name := 'ben_cm_typ_f';
1038       Raise l_rows_exist;
1039     End If;
1040 hr_utility.set_location('*******after check rows exist', 5);
1041     If (dt_api.rows_exist
1042           (p_base_table_name => 'ben_cm_typ_trgr_f',
1043            p_base_key_column => 'cm_typ_id',
1044            p_base_key_value  => p_cm_typ_id,
1045            p_from_date       => p_validation_start_date,
1046            p_to_date         => p_validation_end_date)) Then
1047       l_table_name := 'ben_cm_typ_trgr_f';
1048       Raise l_rows_exist;
1049     End If;
1050     If (dt_api.rows_exist
1051           (p_base_table_name => 'ben_cm_typ_usg_f',
1052            p_base_key_column => 'cm_typ_id',
1053            p_base_key_value  => p_cm_typ_id,
1054            p_from_date       => p_validation_start_date,
1058     End If;
1055            p_to_date         => p_validation_end_date)) Then
1056       l_table_name := 'ben_cm_typ_usg_f';
1057       Raise l_rows_exist;
1059     If (dt_api.rows_exist
1060           (p_base_table_name => 'ben_per_cm_f',
1061            p_base_key_column => 'cm_typ_id',
1062            p_base_key_value  => p_cm_typ_id,
1063            p_from_date       => p_validation_start_date,
1064            p_to_date         => p_validation_end_date)) Then
1065       l_table_name := 'ben_per_cm_f';
1066       Raise l_rows_exist;
1067     End If;
1068     --
1069   End If;
1070   --
1071   hr_utility.set_location(' Leaving:'||l_proc, 10);
1072 Exception
1073   When l_rows_exist Then
1074     --
1075     -- A referential integrity check was violated therefore
1076     -- we must error
1077     --
1078   ben_utility.child_exists_error(p_table_name => l_table_name);
1079   When Others Then
1080     --
1081     -- An unhandled or unexpected error has occurred which
1082     -- we must report
1083     --
1084     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1085     hr_utility.set_message_token('PROCEDURE', l_proc);
1086     hr_utility.set_message_token('STEP','15');
1087     hr_utility.raise_error;
1088 End dt_delete_validate;
1089 --
1090 -- ----------------------------------------------------------------------------
1091 -- |---------------------------< insert_validate >----------------------------|
1092 -- ----------------------------------------------------------------------------
1093 Procedure insert_validate
1094 	(p_rec 			 in ben_cct_shd.g_rec_type,
1095 	 p_effective_date	 in date,
1096 	 p_datetrack_mode	 in varchar2,
1097 	 p_validation_start_date in date,
1098 	 p_validation_end_date	 in date) is
1099 --
1100   l_proc	varchar2(72) := g_package||'insert_validate';
1101 --
1102 Begin
1103   hr_utility.set_location('Entering:'||l_proc, 5);
1104   --
1105   -- Call all supporting business operations
1106   --
1107   --
1108   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
1109   --
1110   chk_cm_typ_id
1111   (p_cm_typ_id             => p_rec.cm_typ_id,
1112    p_effective_date        => p_effective_date,
1113    p_object_version_number => p_rec.object_version_number);
1114   --
1115 chk_name_unique
1116      ( p_cm_typ_id           => p_rec.cm_typ_id
1117       ,p_name                => p_rec.name
1118       ,p_business_group_id   => p_rec.business_group_id);
1119 --
1120   chk_rcpent_cd
1121   (p_cm_typ_id             => p_rec.cm_typ_id,
1122    p_rcpent_cd             => p_rec.rcpent_cd,
1123    p_effective_date        => p_effective_date,
1124    p_object_version_number => p_rec.object_version_number);
1125   --
1126   chk_inspn_rqd_rl
1127   (p_cm_typ_id             => p_rec.cm_typ_id,
1128    p_inspn_rqd_rl          => p_rec.inspn_rqd_rl,
1129    p_effective_date        => p_effective_date,
1130    p_business_group_id     => p_rec.business_group_id,
1131    p_object_version_number => p_rec.object_version_number);
1132   --
1133   chk_inspn_rqd_flag
1134   (p_cm_typ_id             => p_rec.cm_typ_id,
1135    p_inspn_rqd_flag        => p_rec.inspn_rqd_flag,
1136    p_effective_date        => p_effective_date,
1137    p_object_version_number => p_rec.object_version_number);
1138   --
1139   chk_to_be_sent_dt_rl
1140   (p_cm_typ_id             => p_rec.cm_typ_id,
1141    p_to_be_sent_dt_rl      => p_rec.to_be_sent_dt_rl,
1142    p_effective_date        => p_effective_date,
1143    p_business_group_id     => p_rec.business_group_id,
1144    p_object_version_number => p_rec.object_version_number);
1145   --
1146   chk_to_be_sent_dt_cd
1147   (p_cm_typ_id             => p_rec.cm_typ_id,
1148    p_to_be_sent_dt_cd      => p_rec.to_be_sent_dt_cd,
1149    p_effective_date        => p_effective_date,
1150    p_object_version_number => p_rec.object_version_number);
1151   --
1152   chk_trk_mlg_flag
1153   (p_cm_typ_id             => p_rec.cm_typ_id,
1154    p_trk_mlg_flag          => p_rec.trk_mlg_flag,
1155    p_effective_date        => p_effective_date,
1156    p_object_version_number => p_rec.object_version_number);
1157   --
1158   chk_pc_kit_cd
1159   (p_cm_typ_id             => p_rec.cm_typ_id,
1160    p_pc_kit_cd             => p_rec.pc_kit_cd,
1161    p_effective_date        => p_effective_date,
1162    p_object_version_number => p_rec.object_version_number);
1163   --
1164   chk_whnvr_trgrd_flag
1165   (p_cm_typ_id             => p_rec.cm_typ_id,
1166    p_whnvr_trgrd_flag      => p_rec.whnvr_trgrd_flag,
1167    p_effective_date        => p_effective_date,
1168    p_object_version_number => p_rec.object_version_number);
1169   --
1170   chk_cm_usg_cd
1171   (p_cm_typ_id             => p_rec.cm_typ_id,
1172    p_cm_usg_cd             => p_rec.cm_usg_cd,
1173    p_effective_date        => p_effective_date,
1174    p_object_version_number => p_rec.object_version_number,
1175    p_to_be_sent_dt_cd      => p_rec.to_be_sent_dt_cd );
1176   --
1177   chk_cm_typ_rl
1178   (p_cm_typ_id             => p_rec.cm_typ_id,
1179    p_cm_typ_rl             => p_rec.cm_typ_rl,
1180    p_effective_date        => p_effective_date,
1181    p_business_group_id     => p_rec.business_group_id,
1182    p_object_version_number => p_rec.object_version_number);
1183   --
1184   hr_utility.set_location(' Leaving:'||l_proc, 10);
1185 End insert_validate;
1186 --
1187 -- ----------------------------------------------------------------------------
1188 -- |---------------------------< update_validate >----------------------------|
1189 -- ----------------------------------------------------------------------------
1190 Procedure update_validate
1191 	(p_rec 			 in ben_cct_shd.g_rec_type,
1192 	 p_effective_date	 in date,
1193 	 p_datetrack_mode	 in varchar2,
1194 	 p_validation_start_date in date,
1198 --
1195 	 p_validation_end_date	 in date) is
1196 --
1197   l_proc	varchar2(72) := g_package||'update_validate';
1199 Begin
1200   hr_utility.set_location('Entering:'||l_proc, 5);
1201   --
1202   -- Call all supporting business operations
1203   --
1204   --
1205   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
1206   --
1207   chk_cm_typ_id
1208   (p_cm_typ_id             => p_rec.cm_typ_id,
1209    p_effective_date        => p_effective_date,
1210    p_object_version_number => p_rec.object_version_number);
1211   --
1212 chk_name_unique
1213      ( p_cm_typ_id           => p_rec.cm_typ_id
1214       ,p_name                => p_rec.name
1215       ,p_business_group_id   => p_rec.business_group_id);
1216 
1217 --
1218   chk_rcpent_cd
1219   (p_cm_typ_id             => p_rec.cm_typ_id,
1220    p_rcpent_cd             => p_rec.rcpent_cd,
1221    p_effective_date        => p_effective_date,
1222    p_object_version_number => p_rec.object_version_number);
1223   --
1224   chk_inspn_rqd_rl
1225   (p_cm_typ_id             => p_rec.cm_typ_id,
1226    p_inspn_rqd_rl          => p_rec.inspn_rqd_rl,
1227    p_effective_date        => p_effective_date,
1228    p_business_group_id     => p_rec.business_group_id,
1229    p_object_version_number => p_rec.object_version_number);
1230   --
1231   chk_inspn_rqd_flag
1232   (p_cm_typ_id             => p_rec.cm_typ_id,
1233    p_inspn_rqd_flag        => p_rec.inspn_rqd_flag,
1234    p_effective_date        => p_effective_date,
1235    p_object_version_number => p_rec.object_version_number);
1236   --
1237   chk_to_be_sent_dt_rl
1238   (p_cm_typ_id             => p_rec.cm_typ_id,
1239    p_to_be_sent_dt_rl      => p_rec.to_be_sent_dt_rl,
1240    p_effective_date        => p_effective_date,
1241    p_business_group_id     => p_rec.business_group_id,
1242    p_object_version_number => p_rec.object_version_number);
1243   --
1244   chk_to_be_sent_dt_cd
1245   (p_cm_typ_id             => p_rec.cm_typ_id,
1246    p_to_be_sent_dt_cd      => p_rec.to_be_sent_dt_cd,
1247    p_effective_date        => p_effective_date,
1248    p_object_version_number => p_rec.object_version_number);
1249   --
1250   chk_trk_mlg_flag
1251   (p_cm_typ_id             => p_rec.cm_typ_id,
1252    p_trk_mlg_flag          => p_rec.trk_mlg_flag,
1253    p_effective_date        => p_effective_date,
1254    p_object_version_number => p_rec.object_version_number);
1255   --
1256   chk_pc_kit_cd
1257   (p_cm_typ_id             => p_rec.cm_typ_id,
1258    p_pc_kit_cd             => p_rec.pc_kit_cd,
1259    p_effective_date        => p_effective_date,
1260    p_object_version_number => p_rec.object_version_number);
1261   --
1262   chk_whnvr_trgrd_flag
1263   (p_cm_typ_id             => p_rec.cm_typ_id,
1264    p_whnvr_trgrd_flag      => p_rec.whnvr_trgrd_flag,
1265    p_effective_date        => p_effective_date,
1266    p_object_version_number => p_rec.object_version_number);
1267   --
1268   chk_cm_usg_cd
1269   (p_cm_typ_id             => p_rec.cm_typ_id,
1270    p_cm_usg_cd             => p_rec.cm_usg_cd,
1271    p_effective_date        => p_effective_date,
1272    p_object_version_number => p_rec.object_version_number,
1273    p_to_be_sent_dt_cd      => p_rec.to_be_sent_dt_cd );
1274   --
1275   chk_cm_typ_rl
1276   (p_cm_typ_id             => p_rec.cm_typ_id,
1277    p_cm_typ_rl             => p_rec.cm_typ_rl,
1278    p_effective_date        => p_effective_date,
1279    p_business_group_id     => p_rec.business_group_id,
1280    p_object_version_number => p_rec.object_version_number);
1281   --
1282   -- Call the datetrack update integrity operation
1283   --
1284   dt_update_validate
1285     (p_cm_typ_id                     => p_rec.cm_typ_id,
1286      p_datetrack_mode                => p_datetrack_mode,
1287      p_validation_start_date	     => p_validation_start_date,
1288      p_validation_end_date	     => p_validation_end_date);
1289   --
1290   hr_utility.set_location(' Leaving:'||l_proc, 10);
1291 End update_validate;
1292 --
1293 -- ----------------------------------------------------------------------------
1294 -- |---------------------------< delete_validate >----------------------------|
1295 -- ----------------------------------------------------------------------------
1296 Procedure delete_validate
1297 	(p_rec 			 in ben_cct_shd.g_rec_type,
1298 	 p_effective_date	 in date,
1299 	 p_datetrack_mode	 in varchar2,
1300 	 p_validation_start_date in date,
1301 	 p_validation_end_date	 in date) is
1302 --
1303   l_proc	varchar2(72) := g_package||'delete_validate';
1304 --
1305 Begin
1306   hr_utility.set_location('Entering:'||l_proc, 5);
1307   --
1308   -- Call all supporting business operations
1309   --
1310   dt_delete_validate
1311     (p_datetrack_mode		=> p_datetrack_mode,
1312      p_validation_start_date	=> p_validation_start_date,
1313      p_validation_end_date	=> p_validation_end_date,
1314      p_cm_typ_id		=> p_rec.cm_typ_id);
1315   --
1316   hr_utility.set_location(' Leaving:'||l_proc, 10);
1317 End delete_validate;
1318 --
1319 --
1320 --  ---------------------------------------------------------------------------
1321 --  |---------------------< return_legislation_code >-------------------------|
1322 --  ---------------------------------------------------------------------------
1323 --
1324 function return_legislation_code
1325   (p_cm_typ_id in number) return varchar2 is
1326   --
1327   -- Declare cursor
1328   --
1329   cursor csr_leg_code is
1330     select a.legislation_code
1331     from   per_business_groups a,
1332            ben_cm_typ_f b
1333     where b.cm_typ_id      = p_cm_typ_id
1334     and   a.business_group_id = b.business_group_id;
1335   --
1336   -- Declare local variables
1337   --
1338   l_legislation_code  varchar2(150);
1342   --
1339   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
1340   --
1341 begin
1343   hr_utility.set_location('Entering:'|| l_proc, 10);
1344   --
1345   -- Ensure that all the mandatory parameter are not null
1346   --
1347   hr_api.mandatory_arg_error(p_api_name       => l_proc,
1348                              p_argument       => 'cm_typ_id',
1349                              p_argument_value => p_cm_typ_id);
1350   --
1351   open csr_leg_code;
1352     --
1353     fetch csr_leg_code into l_legislation_code;
1354     --
1355     if csr_leg_code%notfound then
1356       --
1357       close csr_leg_code;
1358       --
1359       -- The primary key is invalid therefore we must error
1360       --
1361       hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
1362       hr_utility.raise_error;
1363       --
1364     end if;
1365     --
1366   close csr_leg_code;
1367   --
1368   hr_utility.set_location(' Leaving:'|| l_proc, 20);
1369   --
1370   return l_legislation_code;
1371   --
1372 end return_legislation_code;
1373 --
1374 end ben_cct_bus;