DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PCD_BUS

Source


1 Package Body ben_pcd_bus as
2 /* $Header: bepcdrhi.pkb 115.9 2002/12/16 11:57:29 vsethi ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_pcd_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_per_cm_prvdd_id >------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description
15 --   This procedure is used to check that the primary key for the table
16 --   is created properly. It should be null on insert and
17 --   should not be able to be updated.
18 --
19 -- Pre Conditions
20 --   None.
21 --
22 -- In Parameters
23 --   per_cm_prvdd_id PK of record being inserted or updated.
24 --   effective_date Effective Date of session
25 --   object_version_number Object version number of record being
26 --                         inserted or updated.
27 --
28 -- Post Success
29 --   Processing continues
30 --
31 -- Post Failure
32 --   Errors handled by the procedure
33 --
34 -- Access Status
35 --   Internal table handler use only.
36 --
37 Procedure chk_per_cm_prvdd_id(p_per_cm_prvdd_id                in number,
38                            p_effective_date              in date,
39                            p_object_version_number       in number) is
40   --
41   l_proc         varchar2(72) := g_package||'chk_per_cm_prvdd_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_pcd_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_per_cm_prvdd_id                => p_per_cm_prvdd_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_per_cm_prvdd_id,hr_api.g_number)
55      <>  ben_pcd_shd.g_old_rec.per_cm_prvdd_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_pcd_shd.constraint_error('BEN_PER_CM_PRVDD_F_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_per_cm_prvdd_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_pcd_shd.constraint_error('BEN_PER_CM_PRVDD_F_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_per_cm_prvdd_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |------< chk_address_id >------|
81 -- ----------------------------------------------------------------------------
82 --
83 -- Description
84 --   This procedure checks that a referenced foreign key actually exists
85 --   in the referenced table.
86 --
87 -- Pre-Conditions
88 --   None.
89 --
90 -- In Parameters
91 --   p_per_cm_prvdd_id PK
92 --   p_address_id ID of FK column
93 --   p_effective_date session date
94 --   p_object_version_number object version number
95 --
96 -- Post Success
97 --   Processing continues
98 --
99 -- Post Failure
100 --   Error raised.
101 --
102 -- Access Status
103 --   Internal table handler use only.
104 --
105 Procedure chk_address_id (p_per_cm_prvdd_id          in number,
106                             p_address_id          in number,
107                             p_effective_date        in date,
108                             p_object_version_number in number) is
109   --
110   l_proc         varchar2(72) := g_package||'chk_address_id';
111   l_api_updating boolean;
112   l_dummy        varchar2(1);
113   --
114   cursor c1 is
115     select null
116     from   per_addresses a
117     where  a.address_id = p_address_id;
118   --
119 Begin
120   --
121   hr_utility.set_location('Entering:'||l_proc,5);
122   --
123   l_api_updating := ben_pcd_shd.api_updating
124      (p_per_cm_prvdd_id            => p_per_cm_prvdd_id,
125       p_effective_date          => p_effective_date,
126       p_object_version_number   => p_object_version_number);
127   --
128   if (l_api_updating
129      and nvl(p_address_id,hr_api.g_number)
130      <> nvl(ben_pcd_shd.g_old_rec.address_id,hr_api.g_number)
131      or not l_api_updating) and
132      p_address_id is not null then
133     --
134     -- check if address_id value exists in per_addresses table
135     --
136     open c1;
137       --
138       fetch c1 into l_dummy;
139       if c1%notfound then
140         --
141         close c1;
142         --
143         -- raise error as FK does not relate to PK in per_addresses
144         -- table.
145         --
146         ben_pcd_shd.constraint_error('BEN_PER_CM_PRVDD_F_FK2');
147         --
148       end if;
149       --
150     close c1;
151     --
152   end if;
153   --
154   hr_utility.set_location('Leaving:'||l_proc,10);
155   --
156 End chk_address_id;
157 --
158 -- ----------------------------------------------------------------------------
159 -- |------< chk_to_be_sent_dt >------|
160 -- ----------------------------------------------------------------------------
161 --
162 -- Description
163 --   This procedure is used to check that the to be sent date is less than or
164 --   equal to today.  You can not create a communication to be sent out before
165 --   today, nothing will send it out!  This is called from insert only.
166 --
167 -- Pre Conditions
168 --   None.
169 --
170 -- In Parameters
171 --   per_cm_prvdd_id PK of record being inserted or updated.
172 --   to_be_sent_dt
173 --   effective_date effective date
174 --   object_version_number Object version number of record being
175 --                         inserted or updated.
176 --
177 -- Post Success
178 --   Processing continues
179 --
180 -- Post Failure
181 --   Error handled by procedure
182 --
183 -- Access Status
184 --   Internal table handler use only.
185 --
186 Procedure chk_to_be_sent_dt(p_per_cm_prvdd_id                in number,
187                             p_to_be_sent_dt               in date,
188                             p_effective_date              in date,
189                             p_object_version_number       in number) is
190   --
191   l_proc         varchar2(72) := g_package||'chk_to_be_sent_dt';
195   --
192   l_api_updating boolean;
193   --
194 Begin
196   hr_utility.set_location('Entering:'||l_proc, 5);
197   --
198   l_api_updating := ben_pcd_shd.api_updating
199     (p_per_cm_prvdd_id                => p_per_cm_prvdd_id,
200      p_effective_date              => p_effective_date,
201      p_object_version_number       => p_object_version_number);
202   --
203   if (l_api_updating
204       and p_to_be_sent_dt
205       <> nvl(ben_pcd_shd.g_old_rec.to_be_sent_dt,hr_api.g_varchar2)
206       or not l_api_updating)
207       and p_to_be_sent_dt is not null then
208     --
209     if p_to_be_sent_dt < p_effective_date then
210       --
211       fnd_message.set_name('BEN','BEN_91882_TO_BE_SENT_DT_ERR');
212       fnd_message.raise_error;
213       --
214     end if;
215     --
216   end if;
217   --
218   hr_utility.set_location('Leaving:'||l_proc,10);
219   --
220 end chk_to_be_sent_dt;
221 --
222 -- ----------------------------------------------------------------------------
223 -- |------< chk_cm_dlvry_mthd_cd >------|
224 -- ----------------------------------------------------------------------------
225 --
226 -- Description
227 --   This procedure is used to check that the lookup value is valid.
228 --
229 -- Pre Conditions
230 --   None.
231 --
232 -- In Parameters
233 --   per_cm_prvdd_id PK of record being inserted or updated.
234 --   cm_dlvry_mthd_cd Value of lookup code.
235 --   effective_date effective date
236 --   object_version_number Object version number of record being
237 --                         inserted or updated.
238 --
239 -- Post Success
240 --   Processing continues
241 --
242 -- Post Failure
243 --   Error handled by procedure
244 --
245 -- Access Status
246 --   Internal table handler use only.
247 --
248 Procedure chk_cm_dlvry_mthd_cd(p_per_cm_prvdd_id                in number,
249                             p_cm_dlvry_mthd_cd               in varchar2,
250                             p_effective_date              in date,
251                             p_object_version_number       in number) is
252   --
253   l_proc         varchar2(72) := g_package||'chk_cm_dlvry_mthd_cd';
254   l_api_updating boolean;
255   --
256 Begin
257   --
258   hr_utility.set_location('Entering:'||l_proc, 5);
259   --
260   l_api_updating := ben_pcd_shd.api_updating
261     (p_per_cm_prvdd_id                => p_per_cm_prvdd_id,
262      p_effective_date              => p_effective_date,
263      p_object_version_number       => p_object_version_number);
264   --
265   if (l_api_updating
266       and p_cm_dlvry_mthd_cd
267       <> nvl(ben_pcd_shd.g_old_rec.cm_dlvry_mthd_cd,hr_api.g_varchar2)
268       or not l_api_updating)
269       and p_cm_dlvry_mthd_cd is not null then
270     --
271     -- check if value of lookup falls within lookup type.
272     --
273     if hr_api.not_exists_in_hr_lookups
274           (p_lookup_type    => 'BEN_DLVRY_MTHD',
275            p_lookup_code    => p_cm_dlvry_mthd_cd,
276            p_effective_date => p_effective_date) then
277       --
278       -- raise error as does not exist as lookup
279       --
280       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
281       fnd_message.set_token('FIELD','p_cm_dlvry_mthd_cd');
282       fnd_message.set_token('TYPE','BEN_DLVRY_MTHD');
283       fnd_message.raise_error;
284       --
285     end if;
286     --
287   end if;
288   --
289   hr_utility.set_location('Leaving:'||l_proc,10);
290   --
291 end chk_cm_dlvry_mthd_cd;
292 --
293 
294 -- ----------------------------------------------------------------------------
295 -- |------< chk_cm_dlvry_med_cd >------|
296 -- ----------------------------------------------------------------------------
297 --
298 -- Description
299 --   This procedure is used to check that the lookup value is valid.
300 --
301 -- Pre Conditions
302 --   None.
303 --
304 -- In Parameters
305 --   per_cm_prvdd_id PK of record being inserted or updated.
306 --   cm_dlvry_med_cd Value of lookup code.
307 --   effective_date effective date
308 --   object_version_number Object version number of record being
309 --                         inserted or updated.
310 --
311 -- Post Success
312 --   Processing continues
313 --
314 -- Post Failure
315 --   Error handled by procedure
316 --
317 -- Access Status
318 --   Internal table handler use only.
319 --
320 Procedure chk_cm_dlvry_med_cd(p_per_cm_prvdd_id                in number,
321                             p_cm_dlvry_med_cd               in varchar2,
322                             p_effective_date              in date,
323                             p_object_version_number       in number) is
324   --
325   l_proc         varchar2(72) := g_package||'chk_cm_dlvry_med_cd';
326   l_api_updating boolean;
327   --
328 Begin
329   --
330   hr_utility.set_location('Entering:'||l_proc, 5);
331   --
332   l_api_updating := ben_pcd_shd.api_updating
333     (p_per_cm_prvdd_id                => p_per_cm_prvdd_id,
334      p_effective_date              => p_effective_date,
335      p_object_version_number       => p_object_version_number);
336   --
337   if (l_api_updating
338       and p_cm_dlvry_med_cd
339       <> nvl(ben_pcd_shd.g_old_rec.cm_dlvry_med_cd,hr_api.g_varchar2)
340       or not l_api_updating)
341       and p_cm_dlvry_med_cd is not null then
342     --
346           (p_lookup_type    => 'BEN_DLVRY_MED',
343     -- check if value of lookup falls within lookup type.
344     --
345     if hr_api.not_exists_in_hr_lookups
347            p_lookup_code    => p_cm_dlvry_med_cd,
348            p_effective_date => p_effective_date) then
349       --
350       -- raise error as does not exist as lookup
351       --
352       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
353       fnd_message.set_token('FIELD','p_cm_dlvry_med_cd');
354       fnd_message.set_token('TYPE','BEN_DLVRY_MED');
355       fnd_message.raise_error;
356       --
357     end if;
358     --
359   end if;
360   --
361   hr_utility.set_location('Leaving:'||l_proc,10);
362   --
363 end chk_cm_dlvry_med_cd;
364 --
365 -- ----------------------------------------------------------------------------
366 -- |------< chk_per_cm_prvdd_stat_cd >------|
367 -- ----------------------------------------------------------------------------
368 --
369 -- Description
370 --   This procedure is used to check that the lookup value is valid.
371 --
372 -- Pre Conditions
373 --   None.
374 --
375 -- In Parameters
376 --   per_cm_prvdd_id PK of record being inserted or updated.
377 --   per_cm_prvdd_stat_cd Value of lookup code.
378 --   effective_date effective date
379 --   object_version_number Object version number of record being
380 --                         inserted or updated.
381 --
382 -- Post Success
383 --   Processing continues
384 --
385 -- Post Failure
386 --   Error handled by procedure
387 --
388 -- Access Status
389 --   Internal table handler use only.
390 --
391 Procedure chk_per_cm_prvdd_stat_cd(p_per_cm_prvdd_id                in number,
392                             p_per_cm_prvdd_stat_cd               in varchar2,
393                             p_effective_date              in date,
394                             p_object_version_number       in number) is
395   --
396   l_proc         varchar2(72) := g_package||'chk_per_cm_prvdd_stat_cd';
397   l_api_updating boolean;
398   --
399 Begin
400   --
401   hr_utility.set_location('Entering:'||l_proc, 5);
402   --
403   l_api_updating := ben_pcd_shd.api_updating
404     (p_per_cm_prvdd_id                => p_per_cm_prvdd_id,
405      p_effective_date              => p_effective_date,
406      p_object_version_number       => p_object_version_number);
407   --
408   if (l_api_updating
409       and p_per_cm_prvdd_stat_cd
410       <> nvl(ben_pcd_shd.g_old_rec.per_cm_prvdd_stat_cd,hr_api.g_varchar2)
411       or not l_api_updating)
412       and p_per_cm_prvdd_stat_cd is not null then
413     --
414     -- check if value of lookup falls within lookup type.
415     --
416     if hr_api.not_exists_in_hr_lookups
417           (p_lookup_type    => 'BEN_PER_CM_PRVDD_STAT',
418            p_lookup_code    => p_per_cm_prvdd_stat_cd,
419            p_effective_date => p_effective_date) then
420       --
421       -- raise error as does not exist as lookup
422       --
423       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
424       fnd_message.set_token('FIELD','p_per_cm_prvdd_stat_cd');
425       fnd_message.set_token('TYPE','BEN_PER_CM_PRVDD_STAT');
426       fnd_message.raise_error;
427       --
428     end if;
429     --
430   end if;
431   --
432   hr_utility.set_location('Leaving:'||l_proc,10);
433   --
434 end chk_per_cm_prvdd_stat_cd;
435 --
436 --
437 -- ----------------------------------------------------------------------------
438 -- |------< chk_resnd_rsn_cd >------|
439 -- ----------------------------------------------------------------------------
440 --
441 -- Description
442 --   This procedure is used to check that the lookup value is valid.
443 --
444 -- Pre Conditions
445 --   None.
446 --
447 -- In Parameters
448 --   per_cm_prvdd_id PK of record being inserted or updated.
449 --   resnd_rsn_cd Value of lookup code.
450 --   effective_date effective date
451 --   object_version_number Object version number of record being
452 --                         inserted or updated.
453 --
454 -- Post Success
455 --   Processing continues
456 --
457 -- Post Failure
458 --   Error handled by procedure
459 --
460 -- Access Status
461 --   Internal table handler use only.
462 --
463 Procedure chk_resnd_rsn_cd(p_per_cm_prvdd_id                in number,
464                             p_resnd_rsn_cd               in varchar2,
465                             p_effective_date              in date,
466                             p_object_version_number       in number) is
467   --
468   l_proc         varchar2(72) := g_package||'chk_resnd_rsn_cd';
469   l_api_updating boolean;
470   --
471 Begin
472   --
473   hr_utility.set_location('Entering:'||l_proc, 5);
474   --
475   l_api_updating := ben_pcd_shd.api_updating
476     (p_per_cm_prvdd_id                => p_per_cm_prvdd_id,
477      p_effective_date              => p_effective_date,
478      p_object_version_number       => p_object_version_number);
479   --
480   if (l_api_updating
481       and p_resnd_rsn_cd
482       <> nvl(ben_pcd_shd.g_old_rec.resnd_rsn_cd,hr_api.g_varchar2)
483       or not l_api_updating)
484       and p_resnd_rsn_cd is not null then
485     --
486     -- check if value of lookup falls within lookup type.
487     --
488     if hr_api.not_exists_in_hr_lookups
489           (p_lookup_type    => 'BEN_RESND_RSN',
490            p_lookup_code    => p_resnd_rsn_cd,
491            p_effective_date => p_effective_date) then
492       --
493       -- raise error as does not exist as lookup
494       --
498       fnd_message.raise_error;
495       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
496       fnd_message.set_token('FIELD','p_resnd_rsn_cd');
497       fnd_message.set_token('TYPE','BEN_RESND_RSN');
499       --
500     end if;
501     --
502   end if;
503   --
504   hr_utility.set_location('Leaving:'||l_proc,10);
505   --
506 end chk_resnd_rsn_cd;
507 -- ----------------------------------------------------------------------------
508 -- |------< chk_inspn_rqd_flag >------|
509 -- ----------------------------------------------------------------------------
510 --
511 -- Description
512 --   This procedure is used to check that the lookup value is valid.
513 --
514 -- Pre Conditions
515 --   None.
516 --
517 -- In Parameters
518 --   per_cm_prvdd_id PK of record being inserted or updated.
519 --   inspn_rqd_flag Value of lookup code.
520 --   effective_date effective date
521 --   object_version_number Object version number of record being
522 --                         inserted or updated.
523 --
524 -- Post Success
525 --   Processing continues
526 --
527 -- Post Failure
528 --   Error handled by procedure
529 --
530 -- Access Status
531 --   Internal table handler use only.
532 --
533 Procedure chk_inspn_rqd_flag(p_per_cm_prvdd_id                in number,
534                             p_inspn_rqd_flag               in varchar2,
535                             p_effective_date              in date,
536                             p_object_version_number       in number) is
537   --
538   l_proc         varchar2(72) := g_package||'chk_inspn_rqd_flag';
539   l_api_updating boolean;
540   --
541 Begin
542   --
543   hr_utility.set_location('Entering:'||l_proc, 5);
544   --
545   l_api_updating := ben_pcd_shd.api_updating
546     (p_per_cm_prvdd_id                => p_per_cm_prvdd_id,
547      p_effective_date              => p_effective_date,
548      p_object_version_number       => p_object_version_number);
549   --
550   if (l_api_updating
551       and p_inspn_rqd_flag
552       <> nvl(ben_pcd_shd.g_old_rec.inspn_rqd_flag,hr_api.g_varchar2)
553       or not l_api_updating) then
554     --
555     -- check if value of lookup falls within lookup type.
556     --
557     --
558     if hr_api.not_exists_in_hr_lookups
559           (p_lookup_type    => 'YES_NO',
560            p_lookup_code    => p_inspn_rqd_flag,
561            p_effective_date => p_effective_date) then
562       --
563       -- raise error as does not exist as lookup
564       --
565       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
566       fnd_message.set_token('FIELD','p_inspn_rqd_flag');
567       fnd_message.set_token('TYPE','YES_NO');
568       fnd_message.raise_error;
569       --
570     end if;
571     --
572   end if;
573   --
574   hr_utility.set_location('Leaving:'||l_proc,10);
575   --
576 end chk_inspn_rqd_flag;
577 --
578 -- ----------------------------------------------------------------------------
579 -- |------< chk_rqstd_flag >------|
580 -- ----------------------------------------------------------------------------
581 --
582 -- Description
583 --   This procedure is used to check that the lookup value is valid.
584 --
585 -- Pre Conditions
586 --   None.
587 --
588 -- In Parameters
589 --   per_cm_prvdd_id PK of record being inserted or updated.
590 --   rqstd_flag Value of lookup code.
591 --   effective_date effective date
592 --   object_version_number Object version number of record being
593 --                         inserted or updated.
594 --
595 -- Post Success
596 --   Processing continues
597 --
598 -- Post Failure
599 --   Error handled by procedure
600 --
601 -- Access Status
602 --   Internal table handler use only.
603 --
604 Procedure chk_rqstd_flag(p_per_cm_prvdd_id                in number,
605                             p_rqstd_flag               in varchar2,
606                             p_effective_date              in date,
607                             p_object_version_number       in number) is
608   --
609   l_proc         varchar2(72) := g_package||'chk_rqstd_flag';
610   l_api_updating boolean;
611   --
612 Begin
613   --
614   hr_utility.set_location('Entering:'||l_proc, 5);
615   --
616   l_api_updating := ben_pcd_shd.api_updating
617     (p_per_cm_prvdd_id                => p_per_cm_prvdd_id,
618      p_effective_date              => p_effective_date,
619      p_object_version_number       => p_object_version_number);
620   --
621   if (l_api_updating
622       and p_rqstd_flag
623       <> nvl(ben_pcd_shd.g_old_rec.rqstd_flag,hr_api.g_varchar2)
624       or not l_api_updating) then
625     --
626     -- check if value of lookup falls within lookup type.
627     --
628     --
629     if hr_api.not_exists_in_hr_lookups
630           (p_lookup_type    => 'YES_NO',
631            p_lookup_code    => p_rqstd_flag,
632            p_effective_date => p_effective_date) then
633       --
634       -- raise error as does not exist as lookup
635       --
636       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
637       fnd_message.set_token('FIELD','p_inspn_rqd_flag');
638       fnd_message.set_token('TYPE','YES_NO');
639       fnd_message.raise_error;
640       --
641     end if;
642     --
643   end if;
644   --
645   hr_utility.set_location('Leaving:'||l_proc,10);
646   --
647 end chk_rqstd_flag;
648 --
649 -- ----------------------------------------------------------------------------
650 -- |--------------------------< dt_update_validate >--------------------------|
654 -- Description:
651 -- ----------------------------------------------------------------------------
652 -- {Start Of Comments}
653 --
655 --   This procedure is used for referential integrity of datetracked
656 --   parent entities when a datetrack update operation is taking place
657 --   and where there is no cascading of update defined for this entity.
658 --
659 -- Prerequisites:
660 --   This procedure is called from the update_validate.
661 --
662 -- In Parameters:
663 --
664 -- Post Success:
665 --   Processing continues.
666 --
667 -- Post Failure:
668 --
669 -- Developer Implementation Notes:
670 --   This procedure should not need maintenance unless the HR Schema model
671 --   changes.
672 --
673 -- Access Status:
674 --   Internal Row Handler Use Only.
675 --
676 -- {End Of Comments}
677 -- ----------------------------------------------------------------------------
678 Procedure dt_update_validate
679             (p_per_cm_id                     in number default hr_api.g_number,
680 	     p_datetrack_mode		     in varchar2,
681              p_validation_start_date	     in date,
682 	     p_validation_end_date	     in date) Is
683 --
684   l_proc	    varchar2(72) := g_package||'dt_update_validate';
685   l_integrity_error Exception;
686   l_table_name	    all_tables.table_name%TYPE;
687 --
688 Begin
689   hr_utility.set_location('Entering:'||l_proc, 5);
690   --
691   -- Ensure that the p_datetrack_mode argument is not null
692   --
693   hr_api.mandatory_arg_error
694     (p_api_name       => l_proc,
695      p_argument       => 'datetrack_mode',
696      p_argument_value => p_datetrack_mode);
697   --
698   -- Only perform the validation if the datetrack update mode is valid
699   --
700   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
701     --
702     --
703     -- Ensure the arguments are not null
704     --
705     hr_api.mandatory_arg_error
706       (p_api_name       => l_proc,
707        p_argument       => 'validation_start_date',
708        p_argument_value => p_validation_start_date);
709     --
710     hr_api.mandatory_arg_error
711       (p_api_name       => l_proc,
712        p_argument       => 'validation_end_date',
713        p_argument_value => p_validation_end_date);
714     --
715     If ((nvl(p_per_cm_id, hr_api.g_number) <> hr_api.g_number) and
716       NOT (dt_api.check_min_max_dates
717             (p_base_table_name => 'ben_per_cm_f',
718              p_base_key_column => 'per_cm_id',
719              p_base_key_value  => p_per_cm_id,
720              p_from_date       => p_validation_start_date,
721              p_to_date         => p_validation_end_date)))  Then
722       l_table_name := 'ben_per_cm_f';
723       Raise l_integrity_error;
724     End If;
725     --
726   End If;
727   --
728   hr_utility.set_location(' Leaving:'||l_proc, 10);
729 Exception
730   When l_integrity_error Then
731     --
732     -- A referential integrity check was violated therefore
733     -- we must error
734     --
735     ben_utility.parent_integrity_error(p_table_name => l_table_name);
736 
737   When Others Then
738     --
739     -- An unhandled or unexpected error has occurred which
740     -- we must report
741     --
742     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
743     fnd_message.set_token('PROCEDURE', l_proc);
744     fnd_message.set_token('STEP','15');
745     fnd_message.raise_error;
746 End dt_update_validate;
747 --
748 -- ----------------------------------------------------------------------------
749 -- |--------------------------< dt_delete_validate >--------------------------|
750 -- ----------------------------------------------------------------------------
751 -- {Start Of Comments}
752 --
753 -- Description:
754 --   This procedure is used for referential integrity of datetracked
755 --   child entities when either a datetrack DELETE or ZAP is in operation
756 --   and where there is no cascading of delete defined for this entity.
757 --   For the datetrack mode of DELETE or ZAP we must ensure that no
758 --   datetracked child rows exist between the validation start and end
759 --   dates.
760 --
761 -- Prerequisites:
762 --   This procedure is called from the delete_validate.
763 --
764 -- In Parameters:
765 --
766 -- Post Success:
767 --   Processing continues.
768 --
769 -- Post Failure:
770 --   If a row exists by determining the returning Boolean value from the
771 --   generic dt_api.rows_exist function then we must supply an error via
772 --   the use of the local exception handler l_rows_exist.
773 --
774 -- Developer Implementation Notes:
775 --   This procedure should not need maintenance unless the HR Schema model
776 --   changes.
777 --
778 -- Access Status:
779 --   Internal Row Handler Use Only.
780 --
781 -- {End Of Comments}
782 -- ----------------------------------------------------------------------------
783 Procedure dt_delete_validate
784             (p_per_cm_prvdd_id		in number,
785              p_datetrack_mode		in varchar2,
786 	     p_validation_start_date	in date,
787 	     p_validation_end_date	in date) Is
788 --
789   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
790   l_rows_exist	Exception;
791   l_table_name	all_tables.table_name%TYPE;
792 --
793 Begin
794   hr_utility.set_location('Entering:'||l_proc, 5);
795   --
796   -- Ensure that the p_datetrack_mode argument is not null
797   --
798   hr_api.mandatory_arg_error
799     (p_api_name       => l_proc,
800      p_argument       => 'datetrack_mode',
801      p_argument_value => p_datetrack_mode);
802   --
803   -- Only perform the validation if the datetrack mode is either
804   -- DELETE or ZAP
805   --
806   If (p_datetrack_mode = 'DELETE' or
807       p_datetrack_mode = 'ZAP') then
808     --
809     --
810     -- Ensure the arguments are not null
811     --
812     hr_api.mandatory_arg_error
813       (p_api_name       => l_proc,
814        p_argument       => 'validation_start_date',
815        p_argument_value => p_validation_start_date);
816     --
817     hr_api.mandatory_arg_error
818       (p_api_name       => l_proc,
819        p_argument       => 'validation_end_date',
820        p_argument_value => p_validation_end_date);
821     --
822     hr_api.mandatory_arg_error
823       (p_api_name       => l_proc,
824        p_argument       => 'per_cm_prvdd_id',
825        p_argument_value => p_per_cm_prvdd_id);
826     --
827     --
828     --
829   End If;
830   --
831   hr_utility.set_location(' Leaving:'||l_proc, 10);
832 Exception
833   When l_rows_exist Then
834     --
835     -- A referential integrity check was violated therefore
836     -- we must error
837     --
838     ben_utility.child_exists_error(p_table_name => l_table_name);
839   When Others Then
840     --
841     -- An unhandled or unexpected error has occurred which
842     -- we must report
843     --
844     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
845     fnd_message.set_token('PROCEDURE', l_proc);
846     fnd_message.set_token('STEP','15');
847     fnd_message.raise_error;
848 End dt_delete_validate;
849 --
850 -- ----------------------------------------------------------------------------
851 -- |---------------------------< insert_validate >----------------------------|
852 -- ----------------------------------------------------------------------------
853 Procedure insert_validate
854 	(p_rec 			 in ben_pcd_shd.g_rec_type,
855 	 p_effective_date	 in date,
856 	 p_datetrack_mode	 in varchar2,
857 	 p_validation_start_date in date,
858 	 p_validation_end_date	 in date) is
859 --
860   l_proc	varchar2(72) := g_package||'insert_validate';
861 --
862 Begin
863   hr_utility.set_location('Entering:'||l_proc, 5);
864   --
865   -- Call all supporting business operations
866   --
867   --
868   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
869   --
870   chk_per_cm_prvdd_id
871   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
872    p_effective_date        => p_effective_date,
873    p_object_version_number => p_rec.object_version_number);
874   --
875   chk_address_id
876   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
877    p_address_id          => p_rec.address_id,
878    p_effective_date        => p_effective_date,
879    p_object_version_number => p_rec.object_version_number);
880   --
881   -- Removed the call as it is possible that the to_be_sent_dt to be less
882   -- than the effective date, considering all the different datecodes we have.
883   --
884   /*
885   chk_to_be_sent_dt
886   (p_per_cm_prvdd_id       => p_rec.per_cm_prvdd_id,
887    p_to_be_sent_dt         => p_rec.to_be_sent_dt,
888    p_effective_date        => p_effective_date,
889    p_object_version_number => p_rec.object_version_number);
890   */
891   --
892   chk_cm_dlvry_mthd_cd
893   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
894    p_cm_dlvry_mthd_cd         => p_rec.cm_dlvry_mthd_cd,
895    p_effective_date        => p_effective_date,
896    p_object_version_number => p_rec.object_version_number);
897   --
898   chk_cm_dlvry_med_cd
899   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
900    p_cm_dlvry_med_cd         => p_rec.cm_dlvry_med_cd,
901    p_effective_date        => p_effective_date,
902    p_object_version_number => p_rec.object_version_number);
903   --
904   chk_per_cm_prvdd_stat_cd
905   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
906    p_per_cm_prvdd_stat_cd         => p_rec.per_cm_prvdd_stat_cd,
907    p_effective_date        => p_effective_date,
908    p_object_version_number => p_rec.object_version_number);
909   --
910   chk_inspn_rqd_flag
911   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
912    p_inspn_rqd_flag         => p_rec.inspn_rqd_flag,
913    p_effective_date        => p_effective_date,
914    p_object_version_number => p_rec.object_version_number);
915   --
916   --
917   chk_resnd_rsn_cd
918   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
919    p_resnd_rsn_cd         => p_rec.resnd_rsn_cd,
920    p_effective_date        => p_effective_date,
921    p_object_version_number => p_rec.object_version_number);
922   --
923   chk_rqstd_flag
924   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
925    p_rqstd_flag         => p_rec.rqstd_flag,
926    p_effective_date        => p_effective_date,
927    p_object_version_number => p_rec.object_version_number);
928   --
929   hr_utility.set_location(' Leaving:'||l_proc, 10);
930 End insert_validate;
931 --
932 -- ----------------------------------------------------------------------------
933 -- |---------------------------< update_validate >----------------------------|
934 -- ----------------------------------------------------------------------------
935 Procedure update_validate
936 	(p_rec 			 in ben_pcd_shd.g_rec_type,
937 	 p_effective_date	 in date,
938 	 p_datetrack_mode	 in varchar2,
939 	 p_validation_start_date in date,
940 	 p_validation_end_date	 in date) is
941 --
942   l_proc	varchar2(72) := g_package||'update_validate';
943 --
944 Begin
945   hr_utility.set_location('Entering:'||l_proc, 5);
946   --
947   -- Call all supporting business operations
948   --
949   --
950   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
951   --
952   chk_per_cm_prvdd_id
953   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
954    p_effective_date        => p_effective_date,
955    p_object_version_number => p_rec.object_version_number);
956   --
957   chk_address_id
958   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
959    p_address_id          => p_rec.address_id,
960    p_effective_date        => p_effective_date,
961    p_object_version_number => p_rec.object_version_number);
962   --
963   chk_cm_dlvry_mthd_cd
964   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
965    p_cm_dlvry_mthd_cd         => p_rec.cm_dlvry_mthd_cd,
966    p_effective_date        => p_effective_date,
967    p_object_version_number => p_rec.object_version_number);
968   --
969   chk_cm_dlvry_med_cd
970   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
971    p_cm_dlvry_med_cd         => p_rec.cm_dlvry_med_cd,
972    p_effective_date        => p_effective_date,
973    p_object_version_number => p_rec.object_version_number);
974   --
975   chk_per_cm_prvdd_stat_cd
976   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
977    p_per_cm_prvdd_stat_cd         => p_rec.per_cm_prvdd_stat_cd,
978    p_effective_date        => p_effective_date,
979    p_object_version_number => p_rec.object_version_number);
980   --
981   chk_inspn_rqd_flag
982   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
983    p_inspn_rqd_flag         => p_rec.inspn_rqd_flag,
984    p_effective_date        => p_effective_date,
985    p_object_version_number => p_rec.object_version_number);
986   --
987   --
988   chk_resnd_rsn_cd
989   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
990    p_resnd_rsn_cd         => p_rec.resnd_rsn_cd,
991    p_effective_date        => p_effective_date,
992    p_object_version_number => p_rec.object_version_number);
993   --
994   chk_rqstd_flag
995   (p_per_cm_prvdd_id          => p_rec.per_cm_prvdd_id,
996    p_rqstd_flag         => p_rec.rqstd_flag,
997    p_effective_date        => p_effective_date,
998    p_object_version_number => p_rec.object_version_number);
999   --
1000   -- Call the datetrack update integrity operation
1001   --
1002   dt_update_validate
1003     (p_per_cm_id                     => p_rec.per_cm_id,
1004      p_datetrack_mode                => p_datetrack_mode,
1005      p_validation_start_date	     => p_validation_start_date,
1006      p_validation_end_date	     => p_validation_end_date);
1007   --
1008   hr_utility.set_location(' Leaving:'||l_proc, 10);
1009 End update_validate;
1010 --
1011 -- ----------------------------------------------------------------------------
1012 -- |---------------------------< delete_validate >----------------------------|
1013 -- ----------------------------------------------------------------------------
1014 Procedure delete_validate
1015 	(p_rec 			 in ben_pcd_shd.g_rec_type,
1016 	 p_effective_date	 in date,
1017 	 p_datetrack_mode	 in varchar2,
1018 	 p_validation_start_date in date,
1019 	 p_validation_end_date	 in date) is
1020 --
1021   l_proc	varchar2(72) := g_package||'delete_validate';
1022 --
1023 Begin
1024   hr_utility.set_location('Entering:'||l_proc, 5);
1025   --
1026   -- Call all supporting business operations
1027   --
1028   dt_delete_validate
1029     (p_datetrack_mode		=> p_datetrack_mode,
1030      p_validation_start_date	=> p_validation_start_date,
1031      p_validation_end_date	=> p_validation_end_date,
1032      p_per_cm_prvdd_id		=> p_rec.per_cm_prvdd_id);
1033   --
1034   hr_utility.set_location(' Leaving:'||l_proc, 10);
1035 End delete_validate;
1036 --
1037 --
1038 --  ---------------------------------------------------------------------------
1039 --  |---------------------< return_legislation_code >-------------------------|
1040 --  ---------------------------------------------------------------------------
1041 --
1042 function return_legislation_code
1043   (p_per_cm_prvdd_id in number) return varchar2 is
1044   --
1045   -- Declare cursor
1046   --
1047   cursor csr_leg_code is
1048     select a.legislation_code
1049     from   per_business_groups a,
1050            ben_per_cm_prvdd_f b
1051     where b.per_cm_prvdd_id      = p_per_cm_prvdd_id
1052     and   a.business_group_id = b.business_group_id;
1053   --
1054   -- Declare local variables
1055   --
1056   l_legislation_code  varchar2(150);
1057   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
1058   --
1059 begin
1060   --
1061   hr_utility.set_location('Entering:'|| l_proc, 10);
1062   --
1063   -- Ensure that all the mandatory parameter are not null
1064   --
1065   hr_api.mandatory_arg_error(p_api_name       => l_proc,
1066                              p_argument       => 'per_cm_prvdd_id',
1067                              p_argument_value => p_per_cm_prvdd_id);
1068   --
1069   open csr_leg_code;
1070     --
1071     fetch csr_leg_code into l_legislation_code;
1072     --
1073     if csr_leg_code%notfound then
1074       --
1075       close csr_leg_code;
1076       --
1077       -- The primary key is invalid therefore we must error
1078       --
1079       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
1080       fnd_message.raise_error;
1081       --
1082     end if;
1083     --
1084   close csr_leg_code;
1085   --
1086   hr_utility.set_location(' Leaving:'|| l_proc, 20);
1087   --
1088   return l_legislation_code;
1089   --
1090 end return_legislation_code;
1091 --
1092 end ben_pcd_bus;