DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_ESC_BUS

Source


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