DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XDF_BUS

Source


1 Package Body ben_xdf_bus as
2 /* $Header: bexdfrhi.pkb 120.6 2006/07/10 21:53:55 tjesumic ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_xdf_bus.';  -- Global package name
9 --
10 --
11 --  ---------------------------------------------------------------------------
12 --  |----------------------< set_security_group_id >--------------------------|
13 --  ---------------------------------------------------------------------------
14 --
15 Procedure set_security_group_id
16   (p_ext_dfn_id                in number
17   ) is
18   --
19   -- Declare cursor
20   --
21   cursor csr_sec_grp is
22     select pbg.security_group_id
23       from per_business_groups_perf pbg
24          , ben_ext_dfn dfn
25      where dfn.ext_dfn_id = p_ext_dfn_id
26        and pbg.business_group_id = dfn.business_group_id;
27   --
28   -- Declare local variables
29   --
30   l_security_group_id number;
31   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
32   --
33 begin
34   --
35   hr_utility.set_location('Entering:'|| l_proc, 10);
36   --
37   -- Ensure that all the mandatory parameter are not null
38   --
39   hr_api.mandatory_arg_error
40     (p_api_name           => l_proc
41     ,p_argument           => 'ext_dfn_id'
42     ,p_argument_value     => p_ext_dfn_id
43     );
44   --
45   open csr_sec_grp;
46   fetch csr_sec_grp into l_security_group_id;
47 
48   if csr_sec_grp%notfound then
49      --
50      close csr_sec_grp;
51      --
52      -- The primary key is invalid therefore we must error
53      --
54      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
55      fnd_message.raise_error;
56      --
57   end if;
58   close csr_sec_grp;
59   --
60   -- Set the security_group_id in CLIENT_INFO
61   --
62   hr_api.set_security_group_id
63     (p_security_group_id => l_security_group_id
64     );
65   --
66   hr_utility.set_location(' Leaving:'|| l_proc, 20);
67   --
68 end set_security_group_id;
69 --
70 -- ----------------------------------------------------------------------------
71 -- |------< chk_ext_dfn_id >------|
72 -- ----------------------------------------------------------------------------
73 --
74 -- Description
75 --   This procedure is used to check that the primary key for the table
76 --   is created properly. It should be null on insert and
77 --   should not be able to be updated.
78 --r
79 -- Pre Conditions
80 --   None.
81 --
82 -- In Parameters
83 --   ext_dfn_id PK of record being inserted or updated.
84 --   object_version_number Object version number of record being
85 --                         inserted or updated.
86 --
87 -- Post Success
88 --   Processing continues
89 --
90 -- Post Failure
91 --   Errors handled by the procedure
92 --
93 -- Access Status
94 --   Internal table handler use only.
95 --
96 Procedure chk_ext_dfn_id(p_ext_dfn_id                in number,
97                            p_object_version_number       in number) is
98   --
99   l_proc         varchar2(72) := g_package||'chk_ext_dfn_id';
100   l_api_updating boolean;
101   --
102 Begin
103   --
104   hr_utility.set_location('Entering:'||l_proc, 5);
105   --
106   l_api_updating := ben_xdf_shd.api_updating
107     (p_ext_dfn_id                => p_ext_dfn_id,
108      p_object_version_number       => p_object_version_number);
109   --
110   if (l_api_updating
111      and nvl(p_ext_dfn_id,hr_api.g_number)
112      <>  ben_xdf_shd.g_old_rec.ext_dfn_id) then
113     --
114     -- raise error as PK has changed
115     --
116     ben_xdf_shd.constraint_error('BEN_EXT_DFN_PK');
117     --
118   elsif not l_api_updating then
119     --
120     -- check if PK is null
121     --
122     if p_ext_dfn_id is not null then
123       --
124       -- raise error as PK is not null
125       --
126       ben_xdf_shd.constraint_error('BEN_EXT_DFN_PK');
127       --
128     end if;
129     --
130   end if;
131   --
132   hr_utility.set_location('Leaving:'||l_proc, 10);
133   --
134 End chk_ext_dfn_id;
135 --
136 -- ----------------------------------------------------------------------------
137 -- |------< chk_ext_file_id >------|
138 -- ----------------------------------------------------------------------------
139 --
140 -- Description
141 --   This procedure checks that a referenced foreign key actually exists
142 --   in the referenced table.
143 --
144 -- Pre-Conditions
145 --   None.
146 --
147 -- In Parameters
148 --   p_ext_dfn_id PK
149 --   p_ext_file_id ID of FK column
150 --   p_object_version_number object version number
151 --
152 -- Post Success
153 --   Processing continues
154 --
155 -- Post Failure
156 --   Error raised.
157 --
158 -- Access Status
159 --   Internal table handler use only.
160 --
161 Procedure chk_ext_file_id (p_ext_dfn_id          in number,
162                             p_ext_file_id          in number,
163                             p_object_version_number in number) is
164   --
165   l_proc         varchar2(72) := g_package||'chk_ext_file_id';
166   l_api_updating boolean;
167   l_dummy        varchar2(1);
168   --
169   cursor c1 is
170     select null
171     from   ben_ext_file a
172     where  a.ext_file_id = p_ext_file_id;
173   --
174 Begin
175   --
176   hr_utility.set_location('Entering:'||l_proc,5);
177   --
178   l_api_updating := ben_xdf_shd.api_updating
179      (p_ext_dfn_id            => p_ext_dfn_id,
180       p_object_version_number   => p_object_version_number);
181   --
182   if (l_api_updating
183      and nvl(p_ext_file_id,hr_api.g_number)
184      <> nvl(ben_xdf_shd.g_old_rec.ext_file_id,hr_api.g_number)
185      or not l_api_updating) and
186      p_ext_file_id is not null then
187     --
188     -- check if ext_file_id value exists in ben_ext_file table
189     --
190     open c1;
191       --
192       fetch c1 into l_dummy;
193       if c1%notfound then
194         --
195         close c1;
196         --
197         -- raise error as FK does not relate to PK in ben_ext_file
198         -- table.
199         --
200         ben_xdf_shd.constraint_error('BEN_EXT_DFN_FK2');
201         --
202       end if;
203       --
204     close c1;
205     --
206   end if;
207   --
208   hr_utility.set_location('Leaving:'||l_proc,10);
209   --
210 End chk_ext_file_id;
211 --
212 -- ----------------------------------------------------------------------------
213 -- |------< chk_ext_crit_prfl_id >------|
214 -- ----------------------------------------------------------------------------
215 --
216 -- Description
217 --   This procedure checks that a referenced foreign key actually exists
218 --   in the referenced table.
219 --
220 -- Pre-Conditions
221 --   None.
222 --
223 -- In Parameters
224 --   p_ext_dfn_id PK
225 --   p_ext_crit_prfl_id ID of FK column
226 --   p_object_version_number object version number
227 --
228 -- Post Success
229 --   Processing continues
230 --
231 -- Post Failure
232 --   Error raised.
233 --
234 -- Access Status
235 --   Internal table handler use only.
236 --
237 Procedure chk_ext_crit_prfl_id (p_ext_dfn_id          in number,
238                             p_ext_crit_prfl_id          in number,
239                             p_object_version_number in number) is
240   --
241   l_proc         varchar2(72) := g_package||'chk_ext_crit_prfl_id';
242   l_api_updating boolean;
243   l_dummy        varchar2(1);
244   --
245   cursor c1 is
246     select null
247     from   ben_ext_crit_prfl a
248     where  a.ext_crit_prfl_id = p_ext_crit_prfl_id;
249   --
250 Begin
251   --
252   hr_utility.set_location('Entering:'||l_proc,5);
253   --
254   l_api_updating := ben_xdf_shd.api_updating
255      (p_ext_dfn_id            => p_ext_dfn_id,
256       p_object_version_number   => p_object_version_number);
257   --
258   if (l_api_updating
259      and nvl(p_ext_crit_prfl_id,hr_api.g_number)
260      <> nvl(ben_xdf_shd.g_old_rec.ext_crit_prfl_id,hr_api.g_number)
261      or not l_api_updating) and
262      p_ext_crit_prfl_id is not null then
263     --
264     -- check if ext_crit_prfl_id value exists in ben_ext_crit_prfl table
265     --
266     open c1;
267       --
268       fetch c1 into l_dummy;
269       if c1%notfound then
270         --
271         close c1;
272         --
273         -- raise error as FK does not relate to PK in ben_ext_crit_prfl
274         -- table.
275         --
276         ben_xdf_shd.constraint_error('BEN_EXT_DFN_FK1');
277         --
278       end if;
279       --
280     close c1;
281     --
282   end if;
283   --
284   hr_utility.set_location('Leaving:'||l_proc,10);
285   --
286 End chk_ext_crit_prfl_id;
287 --
288 -- ----------------------------------------------------------------------------
289 -- |------< chk_data_typ_cd >------|
290 -- ----------------------------------------------------------------------------
291 --
292 -- Description
293 --   This procedure is used to check that the lookup value is valid.
294 --
295 -- Pre Conditions
296 --   None.
297 --
298 -- In Parameters
299 --   ext_dfn_id PK of record being inserted or updated.
300 --   data_typ_cd Value of lookup code.
301 --   effective_date effective date
302 --   object_version_number Object version number of record being
303 --                         inserted or updated.
304 --
305 -- Post Success
306 --   Processing continues
307 --
308 -- Post Failure
309 --   Error handled by procedure
310 --
311 -- Access Status
312 --   Internal table handler use only.
313 --
314 Procedure chk_data_typ_cd(p_ext_dfn_id                in number,
315                             p_data_typ_cd               in varchar2,
316 			    p_ext_crit_prfl_id		in number,
317                             p_effective_date              in date,
318                             p_business_group_id           in number,
319                             p_object_version_number       in number) is
320   --
321   l_proc         varchar2(72) := g_package||'chk_data_typ_cd';
322   l_api_updating boolean;
323   --
324 Begin
325   --
326   hr_utility.set_location('Entering:'||l_proc, 5);
327   --
328   l_api_updating := ben_xdf_shd.api_updating
329     (p_ext_dfn_id                => p_ext_dfn_id,
330      p_object_version_number       => p_object_version_number);
331   --
332   if p_data_typ_cd is null then
333       fnd_message.set_name('BEN','BEN_91784_DATA_NULL');
334       fnd_message.raise_error;
335   end if;
336   if (l_api_updating
337       and p_data_typ_cd
338       <> nvl(ben_xdf_shd.g_old_rec.data_typ_cd,hr_api.g_varchar2)
339       or not l_api_updating)
340       and p_data_typ_cd is not null then
341     --
342     -- check if value of lookup falls within lookup type.
343     --
344 
345     if p_business_group_id is not null then
346     --
347       if hr_api.not_exists_in_hr_lookups
348           (p_lookup_type    => 'BEN_EXT_DATA_TYP',
349            p_lookup_code    => p_data_typ_cd,
350            p_effective_date => p_effective_date) then
351         --
352         -- raise error as does not exist as lookup
353         --
354         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
355         fnd_message.set_token('FIELD','p_data_typ_cd');
356         fnd_message.set_token('TYPE','BEN_EXT_DATA_TYP');
357         fnd_message.raise_error;
358         --
359       end if;
360     --
361     else
362     --
363       if hr_api.not_exists_in_hrstanlookups
364           (p_lookup_type    => 'BEN_EXT_DATA_TYP',
365            p_lookup_code    => p_data_typ_cd,
366            p_effective_date => p_effective_date) then
367         --
368         -- raise error as does not exist as lookup
369         --
370         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
371         fnd_message.set_token('FIELD','p_data_typ_cd');
372         fnd_message.set_token('TYPE','BEN_EXT_DATA_TYP');
373         fnd_message.raise_error;
374       --
375       end if;
376     --
377     end if;
378     --
379    if p_data_typ_cd = 'C' then
380 	if p_ext_crit_prfl_id is null then
381          fnd_message.set_name('BEN','BEN_91782_EXT_CRIT_PRFL_NULL');
382          fnd_message.raise_error;
383 	end if;
384    end if;
385   end if;
386   --
387   hr_utility.set_location('Leaving:'||l_proc,10);
388   --
389 end chk_data_typ_cd;
390 --
391 -- ----------------------------------------------------------------------------
392 -- |------< chk_apnd_rqst_id_flag >------|
393 -- ----------------------------------------------------------------------------
394 --
395 -- Description
396 --   This procedure is used to check that the lookup value is valid.
397 --   It also checks if output filename is null when apnd_rqst_id_flag=yes.
398 -- Pre Conditions
399 --   None.
400 --
401 -- In Parameters
402 --   ext_dfn_id PK of record being inserted or updated.
403 --   apnd_rqst_id_flag Value of lookup code.
404 --   effective_date effective date
405 --   object_version_number Object version number of record being
406 --                         inserted or updated.
407 --
408 -- Post Success
409 --   Processing continues
410 --
411 -- Post Failure
412 --   Error handled by procedure
413 --
414 -- Access Status
415 --   Internal table handler use only.
416 --
417 Procedure chk_apnd_rqst_id_flag(p_ext_dfn_id                in number,
418 				p_output_name		    in varchar2,
419                             p_apnd_rqst_id_flag               in varchar2,
420                             p_effective_date              in date,
421                             p_business_group_id           in number,
422                             p_object_version_number       in number) is
423   --
424   l_proc         varchar2(72) := g_package||'chk_apnd_rqst_id_flag';
425   l_api_updating boolean;
426   --
427 Begin
428   --
429   hr_utility.set_location('Entering:'||l_proc, 5);
430   --
431   l_api_updating := ben_xdf_shd.api_updating
432     (p_ext_dfn_id                => p_ext_dfn_id,
433      p_object_version_number       => p_object_version_number);
434   --
435   if (l_api_updating
436       and p_apnd_rqst_id_flag
437       <> nvl(ben_xdf_shd.g_old_rec.apnd_rqst_id_flag,hr_api.g_varchar2)
438       or not l_api_updating)
439       and p_apnd_rqst_id_flag is not null then
440     --
441     -- check if value of lookup falls within lookup type.
442     --
443 
444     if p_business_group_id is not null then
445     --
446       if hr_api.not_exists_in_hr_lookups
447           (p_lookup_type    => 'YES_NO',
448            p_lookup_code    => p_apnd_rqst_id_flag,
449            p_effective_date => p_effective_date) then
450         --
451         -- raise error as does not exist as lookup
452         --
453         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
454         fnd_message.set_token('FIELD','p_apnd_rqst_id_flag');
455         fnd_message.set_token('TYPE','YES_NO');
456         fnd_message.raise_error;
457       --
458       end if;
459     --
460     else
461     --
462       if hr_api.not_exists_in_hrstanlookups
463           (p_lookup_type    => 'YES_NO',
464            p_lookup_code    => p_apnd_rqst_id_flag,
465            p_effective_date => p_effective_date) then
466         --
467         -- raise error as does not exist as lookup
468         --
469         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
470         fnd_message.set_token('FIELD','p_apnd_rqst_id_flag');
471         fnd_message.set_token('TYPE','YES_NO');
472         fnd_message.raise_error;
473       --
474       end if;
475     --
476     end if;
477 
478     --
479   end if;
480 
481   if p_apnd_rqst_id_flag = 'Y' then
482         if p_output_name is null then
483          fnd_message.set_name('BEN','BEN_91774_OUTPUT_NAME_NULL');
484          fnd_message.raise_error;
485         end if;
486    end if;
487 
488   --
489   hr_utility.set_location('Leaving:'||l_proc,10);
490   --
491 end chk_apnd_rqst_id_flag;
492 --
493 -- ----------------------------------------------------------------------------
494 -- |------< chk_kickoff_wrt_prc_flag >------|
495 -- ----------------------------------------------------------------------------
496 --
497 -- Description
498 --   This procedure is used to check that the lookup value is valid.
499 -- Pre Conditions
500 --   None.
501 --
502 -- In Parameters
503 --   ext_dfn_id PK of record being inserted or updated.
504 --   kickoff_wrt_prc_flag Value of lookup code.
505 --   effective_date effective date
506 --   object_version_number Object version number of record being
507 --                         inserted or updated.
508 --
509 -- Post Success
510 --   Processing continues
511 --
512 -- Post Failure
513 --   Error handled by procedure
514 --
515 -- Access Status
516 --   Internal table handler use only.
517 --
518 Procedure chk_kickoff_wrt_prc_flag(p_ext_dfn_id           in number,
519                             p_kickoff_wrt_prc_flag        in varchar2,
520                             p_effective_date              in date,
521                             p_business_group_id           in number,
522                             p_object_version_number       in number) is
523   --
524   l_proc         varchar2(72) := g_package||'chk_kickoff_wrt_prc_flag';
525   l_api_updating boolean;
526   --
527 Begin
528   --
529   hr_utility.set_location('Entering:'||l_proc, 5);
530   --
531   l_api_updating := ben_xdf_shd.api_updating
532     (p_ext_dfn_id                => p_ext_dfn_id,
533      p_object_version_number       => p_object_version_number);
534   --
535   if (l_api_updating
536       and p_kickoff_wrt_prc_flag
537       <> nvl(ben_xdf_shd.g_old_rec.kickoff_wrt_prc_flag,hr_api.g_varchar2)
538       or not l_api_updating)
539       and p_kickoff_wrt_prc_flag is not null then
540     --
541     -- check if value of lookup falls within lookup type.
542     --
543     if p_business_group_id is not null then
544     --
545       if hr_api.not_exists_in_hr_lookups
546             (p_lookup_type    => 'YES_NO',
547              p_lookup_code    => p_kickoff_wrt_prc_flag,
548              p_effective_date => p_effective_date) then
549         --
550         -- raise error as does not exist as lookup
551         --
552         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
553         fnd_message.set_token('FIELD','p_kickoff_wrt_prc_flag');
554         fnd_message.set_token('TYPE','YES_NO');
555         fnd_message.raise_error;
556       --
557       end if;
558     --
559     else
560     --
561       if hr_api.not_exists_in_hrstanlookups
562             (p_lookup_type    => 'YES_NO',
563              p_lookup_code    => p_kickoff_wrt_prc_flag,
564              p_effective_date => p_effective_date) then
565         --
566         -- raise error as does not exist as lookup
567         --
568         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
569         fnd_message.set_token('FIELD','p_kickoff_wrt_prc_flag');
570         fnd_message.set_token('TYPE','YES_NO');
571         fnd_message.raise_error;
572       --
573       end if;
574     --
575     end if;
576   end if;
577   --
578   hr_utility.set_location('Leaving:'||l_proc,10);
579   --
580 end chk_kickoff_wrt_prc_flag;
581 --
582 -- ----------------------------------------------------------------------------
583 -- |------< chk_spcl_hndl_flag >------|
584 -- ----------------------------------------------------------------------------
585 --
586 -- Description
587 --   This procedure is used to check that the lookup value is valid.
588 -- Pre Conditions
589 --   None.
590 --
591 -- In Parameters
592 --   ext_dfn_id PK of record being inserted or updated.
593 --   spcl_hndl_flag Value of lookup code.
594 --   effective_date effective date
595 --   object_version_number Object version number of record being
596 --                         inserted or updated.
597 --
598 -- Post Success
599 --   Processing continues
600 --
601 -- Post Failure
602 --   Error handled by procedure
603 --
604 -- Access Status
605 --   Internal table handler use only.
606 --
607 Procedure chk_spcl_hndl_flag(p_ext_dfn_id           in number,
608                             p_spcl_hndl_flag        in varchar2,
609                             p_effective_date              in date,
610                             p_business_group_id           in number,
611                             p_object_version_number       in number) is
612   --
613   l_proc         varchar2(72) := g_package||'chk_spcl_hndl_flag';
614   l_api_updating boolean;
615   --
616 Begin
617   --
618   hr_utility.set_location('Entering:'||l_proc, 5);
619   --
620   l_api_updating := ben_xdf_shd.api_updating
621     (p_ext_dfn_id                => p_ext_dfn_id,
622      p_object_version_number       => p_object_version_number);
623   --
624   if (l_api_updating
625       and p_spcl_hndl_flag
626       <> nvl(ben_xdf_shd.g_old_rec.spcl_hndl_flag,hr_api.g_varchar2)
627       or not l_api_updating)
628       and p_spcl_hndl_flag is not null then
629     --
630     -- check if value of lookup falls within lookup type.
631     --
632     if p_business_group_id is not null then
633     --
634       if hr_api.not_exists_in_hr_lookups
635           (p_lookup_type    => 'YES_NO',
636            p_lookup_code    => p_spcl_hndl_flag,
637            p_effective_date => p_effective_date) then
638         --
639         -- raise error as does not exist as lookup
640         --
641         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
642         fnd_message.set_token('FIELD','p_spcl_hndl_flag');
643         fnd_message.set_token('TYPE','YES_NO');
644         fnd_message.raise_error;
645       --
646       end if;
647     --
648     else
649     --
650       if hr_api.not_exists_in_hrstanlookups
651           (p_lookup_type    => 'YES_NO',
652            p_lookup_code    => p_spcl_hndl_flag,
653            p_effective_date => p_effective_date) then
654         --
655         -- raise error as does not exist as lookup
656         --
657         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
658         fnd_message.set_token('FIELD','p_spcl_hndl_flag');
659         fnd_message.set_token('TYPE','YES_NO');
660         fnd_message.raise_error;
661       --
662       end if;
663     --
664     end if;
665   end if;
666   --
667   hr_utility.set_location('Leaving:'||l_proc,10);
668   --
669 end chk_spcl_hndl_flag;
670 --
671 
672 
673 
674 Procedure chk_ext_global_flag(p_ext_dfn_id           in number,
675                             p_ext_global_flag        in varchar2,
676                             p_effective_date              in date,
677                             p_business_group_id           in number,
678                             p_object_version_number       in number) is
679   --
680   l_proc         varchar2(72) := g_package||'chk_ext_global_flag';
681   l_api_updating boolean;
682   --
683 Begin
684   --
685   hr_utility.set_location('Entering:'||l_proc, 5);
686   --
687   l_api_updating := ben_xdf_shd.api_updating
688     (p_ext_dfn_id                => p_ext_dfn_id,
689      p_object_version_number       => p_object_version_number);
690   --
691   if (l_api_updating
692       and p_ext_global_flag
693       <> nvl(ben_xdf_shd.g_old_rec.ext_global_flag,hr_api.g_varchar2)
694       or not l_api_updating)
695       and p_ext_global_flag is not null then
696     --
697     -- check if value of lookup falls within lookup type.
698     --
699     if p_business_group_id is not null then
700     --
701       if hr_api.not_exists_in_hr_lookups
702           (p_lookup_type    => 'YES_NO',
703            p_lookup_code    => p_ext_global_flag,
704            p_effective_date => p_effective_date) then
705         --
706         -- raise error as does not exist as lookup
707         --
708         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
709         fnd_message.set_token('FIELD','p_ext_global_flag');
710         fnd_message.set_token('TYPE','YES_NO');
711         fnd_message.raise_error;
712       --
713       end if;
714     --
715     else
716     --
717       if hr_api.not_exists_in_hrstanlookups
718           (p_lookup_type    => 'YES_NO',
719            p_lookup_code    => p_ext_global_flag,
720            p_effective_date => p_effective_date) then
721         --
722         -- raise error as does not exist as lookup
723         --
724         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
725         fnd_message.set_token('FIELD','p_ext_global_flag');
726         fnd_message.set_token('TYPE','YES_NO');
727         fnd_message.raise_error;
728       --
729       end if;
730     --
731     end if;
732   end if;
733   --
734   hr_utility.set_location('Leaving:'||l_proc,10);
735   --
736 end chk_ext_global_flag;
737 
738 
739 
740 
741 Procedure chk_cm_display_flag(p_ext_dfn_id           in number,
742                             p_cm_display_flag        in varchar2,
743                             p_effective_date              in date,
744                             p_business_group_id           in number,
745                             p_object_version_number       in number) is
746   --
747   l_proc         varchar2(72) := g_package||'chk_cm_display_flag';
748   l_api_updating boolean;
749   --
750 Begin
751   --
752   hr_utility.set_location('Entering:'||l_proc, 5);
753   --
754   l_api_updating := ben_xdf_shd.api_updating
755     (p_ext_dfn_id                => p_ext_dfn_id,
756      p_object_version_number       => p_object_version_number);
757   --
758   if (l_api_updating
759       and p_cm_display_flag
760       <> nvl(ben_xdf_shd.g_old_rec.cm_display_flag,hr_api.g_varchar2)
761       or not l_api_updating)
762       and p_cm_display_flag is not null then
763     --
764     -- check if value of lookup falls within lookup type.
765     --
766     if p_business_group_id is not null then
767     --
768       if hr_api.not_exists_in_hr_lookups
769           (p_lookup_type    => 'YES_NO',
770            p_lookup_code    => p_cm_display_flag,
771            p_effective_date => p_effective_date) then
772         --
773         -- raise error as does not exist as lookup
774         --
775         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
776         fnd_message.set_token('FIELD','p_cm_display_flag');
777         fnd_message.set_token('TYPE','YES_NO');
778         fnd_message.raise_error;
779       --
780       end if;
781     --
782     else
783     --
784       if hr_api.not_exists_in_hrstanlookups
785           (p_lookup_type    => 'YES_NO',
786            p_lookup_code    => p_cm_display_flag,
787            p_effective_date => p_effective_date) then
788         --
789         -- raise error as does not exist as lookup
790         --
791         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
792         fnd_message.set_token('FIELD','cm_display_flag');
793         fnd_message.set_token('TYPE','YES_NO');
794         fnd_message.raise_error;
795       --
796       end if;
797     --
798     end if;
799   end if;
800   --
801   hr_utility.set_location('Leaving:'||l_proc,10);
802   --
803 end chk_cm_display_flag;
804 
805 
806 -- ----------------------------------------------------------------------------
807 -- |------< chk_upd_cm_sent_dt_flag >------|
808 -- ----------------------------------------------------------------------------
809 --
810 -- Description
811 --   This procedure is used to check that the lookup value is valid.
812 -- Pre Conditions
813 --   None.
814 --
815 -- In Parameters
816 --   ext_dfn_id PK of record being inserted or updated.
817 --   upd_cm_sent_dt_flag Value of lookup code.
818 --   effective_date effective date
819 --   object_version_number Object version number of record being
820 --                         inserted or updated.
821 --
822 -- Post Success
823 --   Processing continues
824 --
825 -- Post Failure
826 --   Error handled by procedure
827 --
828 -- Access Status
829 --   Internal table handler use only.
830 --
831 Procedure chk_upd_cm_sent_dt_flag(p_ext_dfn_id           in number,
832                             p_upd_cm_sent_dt_flag        in varchar2,
833                             p_effective_date              in date,
834                             p_business_group_id           in number,
835                             p_object_version_number       in number) is
836   --
837   l_proc         varchar2(72) := g_package||'chk_upd_cm_sent_dt_flag';
838   l_api_updating boolean;
839   --
840 Begin
841   --
842   hr_utility.set_location('Entering:'||l_proc, 5);
843   --
844   l_api_updating := ben_xdf_shd.api_updating
845     (p_ext_dfn_id                => p_ext_dfn_id,
846      p_object_version_number       => p_object_version_number);
847   --
848   if (l_api_updating
849       and p_upd_cm_sent_dt_flag
850       <> nvl(ben_xdf_shd.g_old_rec.upd_cm_sent_dt_flag,hr_api.g_varchar2)
851       or not l_api_updating)
852       and p_upd_cm_sent_dt_flag is not null then
853     --
854     -- check if value of lookup falls within lookup type.
855     --
856     if p_business_group_id is not null then
857     --
858       if hr_api.not_exists_in_hr_lookups
859           (p_lookup_type    => 'YES_NO',
860            p_lookup_code    => p_upd_cm_sent_dt_flag,
861            p_effective_date => p_effective_date) then
862         --
863         -- raise error as does not exist as lookup
864         --
865         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
866         fnd_message.set_token('FIELD','p_upd_cm_sent_dt_flag');
867         fnd_message.set_token('TYPE','YES_NO');
868         fnd_message.raise_error;
869       --
870       end if;
871     --
872     else
873     --
874       if hr_api.not_exists_in_hrstanlookups
875           (p_lookup_type    => 'YES_NO',
876            p_lookup_code    => p_upd_cm_sent_dt_flag,
877            p_effective_date => p_effective_date) then
878         --
879         -- raise error as does not exist as lookup
880         --
881         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
882         fnd_message.set_token('FIELD','p_upd_cm_sent_dt_flag');
883         fnd_message.set_token('TYPE','YES_NO');
884         fnd_message.raise_error;
885       --
886       end if;
887     --
888     end if;
889   end if;
890   --
891   hr_utility.set_location('Leaving:'||l_proc,10);
892   --
893 end chk_upd_cm_sent_dt_flag;
894 --
895 /*
896 -- ----------------------------------------------------------------------------
897 -- |------< chk_use_eff_dt_for_chgs_flag >------|
898 -- ----------------------------------------------------------------------------
899 --
900 -- Description
901 --   This procedure is used to check that the lookup value is valid.
902 -- Pre Conditions
903 --   None.
904 --
905 -- In Parameters
906 --   ext_dfn_id PK of record being inserted or updated.
907 --   use_eff_dt_for_chgs_flag Value of lookup code.
908 --   effective_date effective date
909 --   object_version_number Object version number of record being
910 --                         inserted or updated.
911 --
912 -- Post Success
913 --   Processing continues
914 --
915 -- Post Failure
916 --   Error handled by procedure
917 --
918 -- Access Status
919 --   Internal table handler use only.
920 --
921 Procedure chk_use_eff_dt_for_chgs_flag(p_ext_dfn_id           in number,
922                             p_use_eff_dt_for_chgs_flag        in varchar2,
923                             p_effective_date              in date,
924                             p_business_group_id           in number,
925                             p_object_version_number       in number) is
926   --
927   l_proc         varchar2(72) := g_package||'chk_use_eff_dt_for_chgs_flag';
928   l_api_updating boolean;
929   --
930 Begin
931   --
932   hr_utility.set_location('Entering:'||l_proc, 5);
933   --
934   l_api_updating := ben_xdf_shd.api_updating
935     (p_ext_dfn_id                => p_ext_dfn_id,
936      p_object_version_number       => p_object_version_number);
937   --
938   if (l_api_updating
939       and p_use_eff_dt_for_chgs_flag
940       <> nvl(ben_xdf_shd.g_old_rec.use_eff_dt_for_chgs_flag,hr_api.g_varchar2)
941       or not l_api_updating)
942       and p_use_eff_dt_for_chgs_flag is not null then
943     --
944     -- check if value of lookup falls within lookup type.
945     --
946     if p_business_group_id is not null then
947     --
948       if hr_api.not_exists_in_hr_lookups
949           (p_lookup_type    => 'YES_NO',
950            p_lookup_code    => p_use_eff_dt_for_chgs_flag,
951            p_effective_date => p_effective_date) then
952         --
953         -- raise error as does not exist as lookup
954         --
955         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
956         fnd_message.set_token('FIELD','p_use_eff_dt_for_chgs_flag');
957         fnd_message.set_token('TYPE','YES_NO');
958         fnd_message.raise_error;
959        --
960       end if;
961     --
962     else
963     --
964       if hr_api.not_exists_in_hrstanlookups
965           (p_lookup_type    => 'YES_NO',
966            p_lookup_code    => p_use_eff_dt_for_chgs_flag,
967            p_effective_date => p_effective_date) then
968         --
969         -- raise error as does not exist as lookup
970         --
971         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
972         fnd_message.set_token('FIELD','p_use_eff_dt_for_chgs_flag');
973         fnd_message.set_token('TYPE','YES_NO');
974         fnd_message.raise_error;
975        --
976       end if;
977     --
978     end if;
979   end if;
980   --
981   hr_utility.set_location('Leaving:'||l_proc,10);
982   --
983 end chk_use_eff_dt_for_chgs_flag;
984 --
985 */
986 /*
987 -- ----------------------------------------------------------------------------
988 -- |------< chk_dates >------|
989 -- ----------------------------------------------------------------------------
990 --
991 -- Description
992 --   This procedure is used to check if the lookup value is valid
993 --   and if not whether it is a valid oracle date.
994 --   It also checks if extract type is FULL PROFILE then startdate is required and
995 --   enddate should be NULL and if extract type is COMMUNICATIONS or CHANGES ONLY
996 --   then both dates are required.
997 --
998 -- Pre Conditions
999 --   None.
1000 --
1001 -- In Parameters
1002 --   ext_dfn_id PK of record being inserted or updated.
1003 --   data_typ_cd .
1004 --   strt_dt Value of lookup code.
1005 --   end_dt Value of lookup code.
1006 --   effective_date effective date
1007 --   object_version_number Object version number of record being
1008 --                         inserted or updated.
1009 --
1010 -- Post Success
1011 --   Processing continues
1012 --
1013 -- Post Failure
1014 --   Error handled by procedure x
1015 --
1016 -- Access Status
1017 --   Internal table handler use only.
1018 --
1019 Procedure chk_dates(p_ext_dfn_id                in number,
1020                             p_data_typ_cd       in varchar2,
1021                             p_strt_dt           in varchar2,
1022                             p_end_dt            in varchar2,
1023                             p_effective_date    in date,
1024                             p_business_group_id           in number,
1025                             p_object_version_number in number) is
1026   --
1027   l_proc         varchar2(72) := g_package||'chk_dates';
1028   l_api_updating boolean;
1029   l_dummy	date;
1030   --
1031 Begin
1032   --
1033   hr_utility.set_location('Entering:'||l_proc, 5);
1034   --
1035   l_api_updating := ben_xdf_shd.api_updating
1036     (p_ext_dfn_id                => p_ext_dfn_id,
1037      p_object_version_number       => p_object_version_number);
1038   --
1039   if p_data_typ_cd = 'F' then
1040     if not (p_strt_dt is not null
1041       and p_end_dt is null) then
1042       fnd_message.set_name('BEN','BEN_91776_END_DT_NULL');
1043       fnd_message.raise_error;
1044     end if;
1045   end if;
1046   --
1047   if p_data_typ_cd in ('C', 'CM') then
1048     if not (p_strt_dt is not null
1049       and p_end_dt is not null) then
1050       fnd_message.set_name('BEN','BEN_91780_STRT_DT_NULL');
1051       fnd_message.raise_error;
1052     end if;
1053   end if;
1054   --
1055   if (l_api_updating
1056       and p_strt_dt
1057       <> nvl(ben_xdf_shd.g_old_rec.strt_dt,hr_api.g_varchar2)
1058       or not l_api_updating)
1059       and p_strt_dt is not null then
1060 
1061      if substr(p_strt_dt,1,1) in ('0','1','2','3','4','5','6','7','8','9') then
1062 
1063        begin
1064 --
1065 	l_dummy := to_date(p_strt_dt,'DD/MM/YYYY');
1066         exception
1067           when others then
1068             fnd_message.set_name('BEN','BEN_91826_INVALID_DT');
1069             fnd_message.raise_error;
1070 	end;
1071     else
1072     -- check if value of lookup falls within lookup type.
1073     --
1074 
1075     if p_business_group_id is not null then
1076     --
1077       if hr_api.not_exists_in_hr_lookups
1078           (p_lookup_type    => 'BEN_EXT_DT',
1079            p_lookup_code    => p_strt_dt,
1080            p_effective_date => p_effective_date) then
1081         --
1082         -- raise error
1083 
1084         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
1085         fnd_message.set_token('FIELD','p_strt_dt');
1086         fnd_message.set_token('TYPE','BEN_EXT_DT');
1087         fnd_message.raise_error;
1088       --
1089       end if;
1090     --
1091     else
1092     --
1093       if hr_api.not_exists_in_hrstanlookups
1094           (p_lookup_type    => 'BEN_EXT_DT',
1095            p_lookup_code    => p_strt_dt,
1096            p_effective_date => p_effective_date) then
1097         --
1098         -- raise error
1099 
1100         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
1101         fnd_message.set_token('FIELD','p_strt_dt');
1102         fnd_message.set_token('TYPE','BEN_EXT_DT');
1103         fnd_message.raise_error;
1104       --
1105       end if;
1106     --
1107     end if;
1108     --
1109     end if;
1110   end if;
1111   --
1112   if (l_api_updating
1113       and p_end_dt
1114       <> nvl(ben_xdf_shd.g_old_rec.end_dt,hr_api.g_varchar2)
1115       or not l_api_updating)
1116       and p_end_dt is not null then
1117 	if substr(p_end_dt,1,1) in ('0','1','2','3','4','5','6','7','8','9') then
1118        begin
1119 --
1120 	l_dummy := to_date(p_end_dt,'DD/MM/YYYY');
1121         exception
1122           when others then
1123             fnd_message.set_name('BEN','BEN_91826_INVALID_DT');
1124             fnd_message.raise_error;
1125 	end;
1126 
1127    else
1128     -- check if value of lookup falls within lookup type.
1129     --
1130     if p_business_group_id is not null then
1131     --
1132       if hr_api.not_exists_in_hr_lookups
1133           (p_lookup_type    => 'BEN_EXT_DT',
1134            p_lookup_code    => p_end_dt,
1135            p_effective_date => p_effective_date) then
1136         --
1137         -- raise error
1138 
1139         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
1140         fnd_message.set_token('FIELD','p_end_dt');
1141         fnd_message.set_token('TYPE','BEN_EXT_DT');
1142         fnd_message.raise_error;
1143       --
1144       end if;
1145     --
1146     else
1147     --
1148       if hr_api.not_exists_in_hrstanlookups
1149           (p_lookup_type    => 'BEN_EXT_DT',
1150            p_lookup_code    => p_end_dt,
1151            p_effective_date => p_effective_date) then
1152         --
1153         -- raise error
1154 
1155         fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
1156         fnd_message.set_token('FIELD','p_end_dt');
1157         fnd_message.set_token('TYPE','BEN_EXT_DT');
1158         fnd_message.raise_error;
1159       --
1160       end if;
1161     --
1162     end if;
1163     --
1164   end if;
1165   end if;
1166   hr_utility.set_location('Leaving:'||l_proc,10);
1167   --
1168 end chk_dates;
1169 
1170 --
1171 */
1172 -- ----------------------------------------------------------------------------
1173 -- |------------------------< chk_output_file >---------------------------------|
1174 -- ----------------------------------------------------------------------------
1175 --
1176 -- Description
1177 --   ensure that output file names do not have blank spaces.
1178 --
1179 -- Pre Conditions
1180 --   None.
1181 --
1182 -- In Parameters
1183 --     p_output_name is output file name
1184 --     p_drctry_name is drctry file name
1185 --
1186 -- Post Success
1187 --   Processing continues
1188 --
1189 -- Post Failure
1190 --   Errors handled by the procedure
1191 --
1192 -- Access Status
1193 --   Internal table handler use only.
1194 --
1195 -- ----------------------------------------------------------------------------
1196 Procedure chk_output_file
1197            (p_output_name                 in   varchar2
1198            ,p_drctry_name                 in   varchar2)
1199 is
1200 l_proc	    varchar2(72) := g_package||'chk_output_file';
1201 l_dummy    char(1);
1202 --
1203 Begin
1204   hr_utility.set_location('Entering:'||l_proc, 5);
1205   --
1206   if instr(p_output_name,' ') > 0 or instr(p_drctry_name,' ') > 0 then
1207       fnd_message.set_name('BEN','BEN_91955_NAME_HAS_SPACE');
1208       fnd_message.raise_error;
1209   end if;
1210   --
1211   hr_utility.set_location('Leaving:'||l_proc, 15);
1212 End chk_output_file;
1213 
1214 
1215 
1216 
1217 
1218 Procedure chk_xdo_template_id
1219            (p_output_type                 in   varchar2
1220            ,p_xdo_template_id             in   number
1221            ,p_cm_display_flag             in   varchar2 )
1222 is
1223 l_proc      varchar2(72) := g_package||'chk_xdo_template_id';
1224 l_dummy    char(1);
1225 --
1226  cursor c is
1227  select data_source_code
1228  from xdo_templates_b
1229  where template_id = p_xdo_template_id ;
1230 
1231  l_source_code  xdo_templates_b.data_source_code%type ;
1232 
1233 Begin
1234   hr_utility.set_location('Entering:'||l_proc, 5);
1235   --
1236   if (  (not nvl(p_output_type,'F')  in ( 'F' , 'X' ) )  and p_xdo_template_id is null )
1237      or ( p_xdo_template_id is not null and (  p_output_type in ('F' , 'X') ) )
1238      then
1239       fnd_message.set_name('BEN','BEN_94036_EXT_XDO_PDF_NULL');
1240       fnd_message.raise_error;
1241   end if;
1242 
1243   if  p_xdo_template_id is not null then
1244       open c ;
1245       fetch c into l_source_code   ;
1246       if c%notfound then
1247           close c ;
1248           fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
1249           fnd_message.set_token('PROCEDURE', l_proc);
1250           fnd_message.set_token('CONSTRAINT_NAME', 'XDO_TEMPLATE_ID');
1251           fnd_message.raise_error;
1252       end if ;
1253       close c ;
1254 
1255       -- make sure correct template attched to correct extract defintionm
1256       -- display on must be attached to BENXMLWRIT
1257       -- display off must be attached to BENXWRIT
1258 
1259       if (p_cm_display_flag = 'Y' and  l_source_code <> 'BENXMLWRIT' ) OR
1260          (p_cm_display_flag <> 'Y' and  l_source_code =  'BENXMLWRIT' )  then
1261 
1262           fnd_message.set_name('BEN', 'BEN_94499_EXT_WRONG_XDO');
1263           fnd_message.raise_error;
1264 
1265       end if ;
1266 
1267 
1268   end if  ;
1269   --
1270   hr_utility.set_location('Leaving:'||l_proc, 15);
1271 End chk_xdo_template_id;
1272 
1273 
1274 --
1275 -- ----------------------------------------------------------------------------
1276 -- |------------------------< chk_name_unique >---------------------------------|
1277 -- ----------------------------------------------------------------------------
1278 --
1279 -- Description
1280 --   ensure that an extract must have a name and not two extracts have the same name
1281 --
1282 -- Pre Conditions
1283 --   None.
1284 --
1285 -- In Parameters
1286 --     p_name is extract name
1287 --     p_ext_dfn_id is extract definition id
1288 --     p_business_group_id
1289 --
1290 -- Post Success
1291 --   Processing continues
1292 --
1293 -- Post Failure
1294 --   Errors handled by the procedure
1295 --
1296 -- Access Status
1297 --   Internal table handler use only.
1298 --
1299 -- ----------------------------------------------------------------------------
1300 Procedure chk_name_unique
1301           ( p_ext_dfn_id               in number
1302            ,p_name                 in   varchar2
1303            ,p_business_group_id    in   number
1304            ,p_legislation_code     in   varchar2)
1305 is
1306 l_proc	    varchar2(72) := g_package||'chk_name_unique';
1307 l_dummy    char(1);
1308 cursor c1 is select null
1309                from ben_ext_dfn
1310               Where ext_dfn_id <> nvl(p_ext_dfn_id,-1)
1311               and name = p_name
1312               and ((business_group_id is null and legislation_code is null) or
1313               (legislation_code is not null and
1314                business_group_id is null and
1315                legislation_code = p_legislation_code) or
1316               (business_group_id is not null and
1317                business_group_id = p_business_group_id));
1318 --
1319 Begin
1320   hr_utility.set_location('Entering:'||l_proc, 5);
1321   --
1322   if p_name is null then
1323       fnd_message.set_name('BEN','BEN_91783_NAME_NULL');
1324       fnd_message.raise_error;
1325   end if;
1326   open c1;
1327   fetch c1 into l_dummy;
1328   if c1%found then
1329       close c1;
1330       fnd_message.set_name('BEN','BEN_91009_NAME_NOT_UNIQUE');
1331       fnd_message.raise_error;
1332   end if;
1333   --
1334   hr_utility.set_location('Leaving:'||l_proc, 15);
1335 End chk_name_unique;
1336 --
1337 --
1338 -- ----------------------------------------------------------------------------
1339 -- |----------------------< chk_startup_action >------------------------------|
1340 -- ----------------------------------------------------------------------------
1341 --
1342 -- Description:
1343 --  This procedure will check that the current action is allowed according
1344 --  to the current startup mode.
1345 --
1346 -- ----------------------------------------------------------------------------
1347 PROCEDURE chk_startup_action
1348   (p_insert               IN boolean
1349   ,p_business_group_id    IN number
1350   ,p_legislation_code     IN varchar2
1351   ,p_legislation_subgroup IN varchar2 DEFAULT NULL) IS
1352 --
1353 BEGIN
1354   --
1355   -- Call the supporting procedure to check startup mode
1356   --
1357   IF (p_insert) THEN
1358     --
1359     -- Call procedure to check startup_action for inserts.
1360     --
1361     hr_startup_data_api_support.chk_startup_action
1362       (p_generic_allowed   => TRUE
1363       ,p_startup_allowed   => TRUE
1364       ,p_user_allowed      => TRUE
1365       ,p_business_group_id => p_business_group_id
1366       ,p_legislation_code  => p_legislation_code
1367       ,p_legislation_subgroup => p_legislation_subgroup
1368       );
1369   ELSE
1370     --
1371     -- Call procedure to check startup_action for updates and deletes.
1372     --
1373 hr_utility.trace('Call hr_startup_data_api_support.chk_upd_del_startup_action');
1374 hr_utility.trace('BG = '||to_char(p_business_group_id));
1375 hr_utility.trace('LC = '||p_legislation_code);
1376 
1377     hr_startup_data_api_support.chk_upd_del_startup_action
1378       (p_generic_allowed   => TRUE
1379       ,p_startup_allowed   => TRUE
1380       ,p_user_allowed      => TRUE
1381       ,p_business_group_id => p_business_group_id
1382       ,p_legislation_code  => p_legislation_code
1383       ,p_legislation_subgroup => p_legislation_subgroup
1384       );
1385   END IF;
1386   --
1387 END chk_startup_action;
1388 --
1389 
1390 Procedure chk_child_recs(p_ext_dfn_id        in number
1391                          ) is
1392   --
1393   l_proc         varchar2(72) := g_package||'chk_child_recs';
1394 
1395 
1396   cursor c_ext_rslt is
1397   select 'x'
1398   from   ben_ext_rslt
1399   where  ext_dfn_id  = p_ext_dfn_id ;
1400 
1401   l_dummy  varchar2(1) ;
1402 
1403   --
1404 Begin
1405   --
1406   hr_utility.set_location('Entering:'||l_proc, 5);
1407   --
1408     open c_ext_rslt;
1409     fetch c_ext_rslt into l_dummy ;
1410     close c_ext_rslt;
1411 
1412     if l_dummy  is not null then
1413       fnd_message.set_name('PER','HR_7215_DT_CHILD_EXISTS');
1414       fnd_message.set_token('TABLE_NAME','Extract Results');
1415       fnd_message.raise_error;
1416 
1417     end if;
1418 
1419   --
1420   hr_utility.set_location('Leaving:'||l_proc,10);
1421   --
1422 end chk_child_recs;
1423 
1424 
1425 -- ----------------------------------------------------------------------------
1426 -- |---------------------------< insert_validate >----------------------------|
1427 -- ----------------------------------------------------------------------------
1428 Procedure insert_validate(p_rec in ben_xdf_shd.g_rec_type
1429                          ,p_effective_date in date) is
1430 --
1431   l_proc  varchar2(72) := g_package||'insert_validate';
1432 --
1433 Begin
1434   hr_utility.set_location('Entering:'||l_proc, 5);
1435   --
1436   chk_startup_action(True
1437                     ,p_rec.business_group_id
1438                     ,p_rec.legislation_code);
1439   IF hr_startup_data_api_support.g_startup_mode NOT IN ('GENERIC','STARTUP') THEN
1440   --
1441      hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate bus_grp
1442   --
1443   END IF;
1444 
1445   --
1446   -- Call all supporting business operations
1447   --
1448   chk_ext_dfn_id
1449   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1450    p_object_version_number => p_rec.object_version_number);
1451   --
1452   chk_ext_file_id
1453   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1454    p_ext_file_id          => p_rec.ext_file_id,
1455    p_object_version_number => p_rec.object_version_number);
1456   --
1457   chk_ext_crit_prfl_id
1458   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1459    p_ext_crit_prfl_id          => p_rec.ext_crit_prfl_id,
1460    p_object_version_number => p_rec.object_version_number);
1461   --
1462   chk_apnd_rqst_id_flag
1463   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1464    p_output_name         => p_rec.output_name,
1465    p_apnd_rqst_id_flag         => p_rec.apnd_rqst_id_flag,
1466    p_effective_date        => p_effective_date,
1467    p_business_group_id     => p_rec.business_group_id,
1468    p_object_version_number => p_rec.object_version_number);
1469   --
1470   chk_data_typ_cd
1471   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1472    p_data_typ_cd         => p_rec.data_typ_cd,
1473    p_ext_crit_prfl_id          => p_rec.ext_crit_prfl_id,
1474    p_effective_date        => p_effective_date,
1475    p_business_group_id     => p_rec.business_group_id,
1476    p_object_version_number => p_rec.object_version_number);
1477   --
1478   chk_kickoff_wrt_prc_flag
1479   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1480    p_kickoff_wrt_prc_flag         => p_rec.kickoff_wrt_prc_flag,
1481    p_effective_date        => p_effective_date,
1482    p_business_group_id     => p_rec.business_group_id,
1483    p_object_version_number => p_rec.object_version_number);
1484   --
1485 /*
1486   chk_use_eff_dt_for_chgs_flag
1487   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1488    p_use_eff_dt_for_chgs_flag         => p_rec.use_eff_dt_for_chgs_flag,
1489    p_effective_date        => p_effective_date,
1490    p_business_group_id     => p_rec.business_group_id,
1491    p_object_version_number => p_rec.object_version_number);
1492 */
1493   --
1494   chk_spcl_hndl_flag
1495   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1496    p_spcl_hndl_flag         => p_rec.spcl_hndl_flag,
1497    p_effective_date        => p_effective_date,
1498    p_business_group_id     => p_rec.business_group_id,
1499    p_object_version_number => p_rec.object_version_number);
1500   --
1501   chk_ext_global_flag
1502   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1503    p_ext_global_flag         => p_rec.ext_global_flag,
1504    p_effective_date        => p_effective_date,
1505    p_business_group_id     => p_rec.business_group_id,
1506    p_object_version_number => p_rec.object_version_number);
1507   --
1508 
1509   chk_cm_display_flag
1510   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1511    p_cm_display_flag         => p_rec.cm_display_flag,
1512    p_effective_date        => p_effective_date,
1513    p_business_group_id     => p_rec.business_group_id,
1514    p_object_version_number => p_rec.object_version_number);
1515 
1516   chk_upd_cm_sent_dt_flag
1517   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1518    p_upd_cm_sent_dt_flag         => p_rec.upd_cm_sent_dt_flag,
1519    p_effective_date        => p_effective_date,
1520    p_business_group_id     => p_rec.business_group_id,
1521    p_object_version_number => p_rec.object_version_number);
1522   --
1523   chk_name_unique
1524   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1525   p_name                 => p_rec.name,
1526   p_business_group_id    => p_rec.business_group_id,
1527   p_legislation_code     => p_rec.legislation_code);
1528   --
1529 /*
1530   chk_dates
1531   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1532    p_data_typ_cd         => p_rec.data_typ_cd,
1533    p_strt_dt             => p_rec.strt_dt,
1534    p_end_dt              => p_rec.end_dt,
1535    p_effective_date        => p_effective_date,
1536    p_business_group_id     => p_rec.business_group_id,
1537    p_object_version_number => p_rec.object_version_number);
1538 */
1539   --
1540   chk_output_file
1541   (p_output_name	=>p_rec.output_name
1542   ,p_drctry_name	=>p_rec.drctry_name);
1543   --
1544   chk_xdo_template_id
1545   (p_output_type        =>p_rec.output_type
1546   ,p_xdo_template_id    =>p_rec.xdo_template_id
1547   ,p_cm_display_flag    =>p_rec.cm_display_flag
1548   );
1549 
1550   hr_utility.set_location(' Leaving:'||l_proc, 10);
1551 End insert_validate;
1552 --
1553 -- ----------------------------------------------------------------------------
1554 -- |---------------------------< update_validate >----------------------------|
1555 -- ----------------------------------------------------------------------------
1556 Procedure update_validate(p_rec in ben_xdf_shd.g_rec_type
1557                          ,p_effective_date in date) is
1558 --
1559   l_proc  varchar2(72) := g_package||'update_validate';
1560 --
1561 Begin
1562   hr_utility.set_location('Entering:'||l_proc, 5);
1563   --
1564 
1565   chk_startup_action(False
1566                     ,p_rec.business_group_id
1567                     ,p_rec.legislation_code);
1568   IF hr_startup_data_api_support.g_startup_mode NOT IN ('GENERIC','STARTUP') THEN
1569   --
1570     hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate bus_grp
1571   --
1572   END IF;
1573 
1574   --
1575   -- Call all supporting business operations
1576   --
1577   chk_ext_dfn_id
1578   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1579    p_object_version_number => p_rec.object_version_number);
1580   --
1581   chk_ext_file_id
1582   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1583    p_ext_file_id          => p_rec.ext_file_id,
1584    p_object_version_number => p_rec.object_version_number);
1585   --
1586   chk_ext_crit_prfl_id
1587   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1588    p_ext_crit_prfl_id          => p_rec.ext_crit_prfl_id,
1589    p_object_version_number => p_rec.object_version_number);
1590   --
1591   chk_apnd_rqst_id_flag
1592   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1593    p_output_name         => p_rec.output_name,
1594    p_apnd_rqst_id_flag         => p_rec.apnd_rqst_id_flag,
1595    p_effective_date        => p_effective_date,
1596    p_business_group_id     => p_rec.business_group_id,
1597    p_object_version_number => p_rec.object_version_number);
1598   --
1599   chk_data_typ_cd
1600   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1601    p_data_typ_cd         => p_rec.data_typ_cd,
1602    p_ext_crit_prfl_id          => p_rec.ext_crit_prfl_id,
1603    p_effective_date        => p_effective_date,
1604    p_business_group_id     => p_rec.business_group_id,
1605    p_object_version_number => p_rec.object_version_number);
1606   --
1607   chk_kickoff_wrt_prc_flag
1608   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1609    p_kickoff_wrt_prc_flag         => p_rec.kickoff_wrt_prc_flag,
1610    p_effective_date        => p_effective_date,
1611    p_business_group_id     => p_rec.business_group_id,
1612    p_object_version_number => p_rec.object_version_number);
1613   --
1614 /*
1615   chk_use_eff_dt_for_chgs_flag
1616   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1617    p_use_eff_dt_for_chgs_flag         => p_rec.use_eff_dt_for_chgs_flag,
1618    p_effective_date        => p_effective_date,
1619    p_business_group_id     => p_rec.business_group_id,
1620    p_object_version_number => p_rec.object_version_number);
1621 */
1622   --
1623   chk_spcl_hndl_flag
1624   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1625    p_spcl_hndl_flag         => p_rec.spcl_hndl_flag,
1626    p_effective_date        => p_effective_date,
1627    p_business_group_id     => p_rec.business_group_id,
1628    p_object_version_number => p_rec.object_version_number);
1629   --
1630    chk_ext_global_flag
1631   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1632    p_ext_global_flag        => p_rec.ext_global_flag,
1633    p_effective_date        => p_effective_date,
1634    p_business_group_id     => p_rec.business_group_id,
1635    p_object_version_number => p_rec.object_version_number);
1636   ---
1637    chk_cm_display_flag
1638   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1639    p_cm_display_flag         => p_rec.cm_display_flag,
1640    p_effective_date        => p_effective_date,
1641    p_business_group_id     => p_rec.business_group_id,
1642    p_object_version_number => p_rec.object_version_number);
1643   ---
1644   chk_upd_cm_sent_dt_flag
1645   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1646    p_upd_cm_sent_dt_flag         => p_rec.upd_cm_sent_dt_flag,
1647    p_effective_date        => p_effective_date,
1648    p_business_group_id     => p_rec.business_group_id,
1649    p_object_version_number => p_rec.object_version_number);
1650   --
1651   chk_name_unique
1652   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1653   p_name                 => p_rec.name,
1654   p_business_group_id    => p_rec.business_group_id,
1655   p_legislation_code     => p_rec.legislation_code);
1656   --
1657 /*
1658   chk_dates
1659   (p_ext_dfn_id          => p_rec.ext_dfn_id,
1660    p_data_typ_cd         => p_rec.data_typ_cd,
1661    p_strt_dt         => p_rec.strt_dt,
1662    p_end_dt         => p_rec.end_dt,
1663    p_effective_date        => p_effective_date,
1664    p_business_group_id     => p_rec.business_group_id,
1665    p_object_version_number => p_rec.object_version_number);
1666 */
1667   --
1668   chk_output_file
1669   (p_output_name	=>p_rec.output_name
1670   ,p_drctry_name	=>p_rec.drctry_name);
1671   --
1672   chk_xdo_template_id
1673   (p_output_type        =>p_rec.output_type
1674   ,p_xdo_template_id    =>p_rec.xdo_template_id
1675   ,p_cm_display_flag    =>p_rec.cm_display_flag
1676   );
1677 
1678   hr_utility.set_location(' Leaving:'||l_proc, 10);
1679 End update_validate;
1680 --
1681 -- ----------------------------------------------------------------------------
1682 -- |---------------------------< delete_validate >----------------------------|
1683 -- ----------------------------------------------------------------------------
1684 Procedure delete_validate(p_rec in ben_xdf_shd.g_rec_type
1685                          ,p_effective_date in date) is
1686 --
1687   l_proc  varchar2(72) := g_package||'delete_validate';
1688 --
1689 Begin
1690   hr_utility.set_location('Entering:'||l_proc, 5);
1691   --
1692   chk_child_recs ( p_rec.ext_dfn_id);
1693   -- Call all supporting business operations
1694   --
1695   chk_startup_action(False
1696                     ,ben_xdf_shd.g_old_rec.business_group_id
1697                     ,ben_xdf_shd.g_old_rec.legislation_code);
1698 
1699   hr_utility.set_location(' Leaving:'||l_proc, 10);
1700 End delete_validate;
1701 --
1702 --
1703 --  ---------------------------------------------------------------------------
1704 --  |---------------------< return_legislation_code >-------------------------|
1705 --  ---------------------------------------------------------------------------
1706 --
1707 function return_legislation_code
1708   (p_ext_dfn_id in number) return varchar2 is
1709   --
1710   -- Declare cursor
1711   --
1712   cursor csr_leg_code is
1713     select b.business_group_id
1714     from  ben_ext_dfn b
1715     where b.ext_dfn_id      = p_ext_dfn_id
1716     ;
1717   --
1718   -- Declare local variables
1719   --
1720   l_business_group_id  number ;
1721   l_legislation_code  varchar2(150);
1722   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
1723   --
1724 begin
1725   --
1726   hr_utility.set_location('Entering:'|| l_proc, 10);
1727   --
1728   -- Ensure that all the mandatory parameter are not null
1729   --
1730   hr_api.mandatory_arg_error(p_api_name       => l_proc,
1731                              p_argument       => 'ext_dfn_id',
1732                              p_argument_value => p_ext_dfn_id);
1733   --
1734   open csr_leg_code;
1735     --
1736     fetch csr_leg_code into l_business_group_id ;
1737     --
1738     if csr_leg_code%notfound then
1739       --
1740       close csr_leg_code;
1741       --
1742       -- The primary key is invalid therefore we must error
1743       --
1744       hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
1745       hr_utility.raise_error;
1746       --
1747     end if;
1748     l_legislation_code  :=  hr_api.return_legislation_code(l_business_group_id) ;
1749 
1750     --
1751   close csr_leg_code;
1752   --
1753   hr_utility.set_location(' Leaving:'|| l_proc, 20);
1754   --
1755   return l_legislation_code;
1756   --
1757 end return_legislation_code;
1758 --
1759 end ben_xdf_bus;