DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EMC_BUS

Source


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