DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_LAR_BUS

Source


4 -- ----------------------------------------------------------------------------
1 Package Body ben_lar_bus as
2 /* $Header: belarrhi.pkb 120.0 2005/05/28 03:14:52 appldev noship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_lar_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_loa_rsn_rt_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 --   loa_rsn_rt_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_loa_rsn_rt_id(p_loa_rsn_rt_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_loa_rsn_rt_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_lar_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_loa_rsn_rt_id                => p_loa_rsn_rt_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_loa_rsn_rt_id,hr_api.g_number)
55      <>  ben_lar_shd.g_old_rec.loa_rsn_rt_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_lar_shd.constraint_error('BEN_LOA_RSN_RT_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_loa_rsn_rt_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_lar_shd.constraint_error('BEN_LOA_RSN_RT_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_loa_rsn_rt_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |------< chk_loa_rsn_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 --   loa_rsn_rt_id PK of record being inserted or updated.
91 --   loa_rsn_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_loa_rsn_cd(p_loa_rsn_rt_id                in number,
106                          p_loa_rsn_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_loa_rsn_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_lar_shd.api_updating
118     (p_loa_rsn_rt_id                => p_loa_rsn_rt_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_loa_rsn_cd
124       <> nvl(ben_lar_shd.g_old_rec.loa_rsn_cd,hr_api.g_varchar2)
125       or not l_api_updating)
126       and p_loa_rsn_cd is not null then
127     --
128     -- check if value of lookup falls within lookup type.
129     --
130     --
134            p_effective_date => p_effective_date) then
131     if hr_api.not_exists_in_hr_lookups
132           (p_lookup_type    => 'ABSENCE_REASON',
133            p_lookup_code    => p_loa_rsn_cd,
135       --
136       -- raise error as does not exist as lookup
137       --
138       fnd_message.set_name('PAY','HR_LOOKUP_DOES_NOT_EXIST');
139       fnd_message.raise_error;
140       --
141     end if;
142     --
143   end if;
144   --
145   --
146   --
147   hr_utility.set_location('Leaving:'||l_proc,10);
148   --
149 end chk_loa_rsn_cd;
150 
151 --
152 -- ----------------------------------------------------------------------------
153 -- |------< chk_dup_record >------|
154 -- ----------------------------------------------------------------------------
155 --
156 -- Description
157 --   This procedure is used to check that there is no duplicate record
158 --
159 -- Pre Conditions
160 --   None.
161 --
162 -- In Parameters
163 --   p_loa_rsn_rt_id	     PK of record being inserted or updated.
164 --   p_loa_rsn_cd   	     Value of lookup code.
165 --   p_vrbl_rt_prfl_id	     FK of the record
166 --   p_effective_date 	     effective date
167 --   p_object_version_number Object version number of record being
168 --                           inserted or updated.
169 --   p_business_group_id     business_group_id of the record
170 --   p_validation_start_date validation_start_date of record
171 --   p_validation_end_date   validation_end_date of record
172 --
173 -- Post Success
174 --   Processing continues
175 --
176 -- Post Failure
177 --   Error handled by procedure
178 --
179 -- Access Status
180 --   Internal table handler use only.
181 --
182 Procedure chk_dup_record
183 		     (p_loa_rsn_rt_id         in number,
184                       p_loa_rsn_cd            in varchar2,
185                       p_absence_attendance_type_id  in number,
186 		      p_abs_attendance_reason_id    in number,
187 		      p_vrbl_rt_prfl_id	      in number,
188                       p_effective_date        in date,
189                       p_object_version_number in number,
190                       p_business_group_id     in number,
191 		      p_validation_start_date in date,
192 		      p_validation_end_date   in date )
193 is
194 --
195 l_proc         varchar2(72) := g_package||'chk_dup_record';
196 l_api_updating boolean;
197 l_exists       varchar2(1);
198 --
199 cursor c_dup is
200 select null
201 from ben_loa_rsn_rt_f
202 where  -- loa_rsn_cd = p_loa_rsn_cd and
203 absence_attendance_type_id  = p_absence_attendance_type_id
204 and nvl(abs_attendance_reason_id,-1)  = nvl(p_abs_attendance_reason_id,-1)
205 and vrbl_rt_prfl_id = p_vrbl_rt_prfl_id
206 and loa_rsn_rt_id <> nvl(p_loa_rsn_rt_id,hr_api.g_number)
207 and business_group_id + 0 = p_business_group_id
208 and p_validation_start_date <= effective_end_date
209 and p_validation_end_date >= effective_start_date;
210 --
211 BEGIN
212 --
213   hr_utility.set_location('Entering:'||l_proc, 5);
214   --
215   l_api_updating := ben_lar_shd.api_updating
216     (p_loa_rsn_rt_id               => p_loa_rsn_rt_id,
217      p_effective_date              => p_effective_date,
218      p_object_version_number       => p_object_version_number);
219   --
220   if (l_api_updating
221       and ( -- p_loa_rsn_cd <> nvl(ben_lar_shd.g_old_rec.loa_rsn_cd,hr_api.g_varchar2) or
222       p_absence_attendance_type_id <> nvl(ben_lar_shd.g_old_rec.absence_attendance_type_id,hr_api.g_number)
223       or nvl(p_abs_attendance_reason_id,hr_api.g_number) <> nvl(ben_lar_shd.g_old_rec.abs_attendance_reason_id,hr_api.g_number))
224       or not l_api_updating) then
225 
226       	open c_dup;
227  	fetch c_dup into l_exists;
228 	if c_dup%found then
229     		close c_dup;
230    		--
231    		-- raise error as this Leave of Absence criteria already exists for this profile
232    		--
233    		fnd_message.set_name('BEN', 'BEN_92992_DUPS_ROW');
234    		fnd_message.set_token('VAR1','Leave of Absence criteria',TRUE);
235    		fnd_message.set_token('VAR2','Variable Rate Profile',TRUE);
236    		fnd_message.raise_error;
237   		--
238 	end if;
239 	close c_dup;
240 	--
241   end if;
242   hr_utility.set_location('Leaving:'||l_proc,10);
243   --
244 END chk_dup_record;
245 
246 --
247 -- |--------------------< chk_duplicate_ordr_num >----------------------------|
248 -- ----------------------------------------------------------------------------
249 --
250 -- Description
251 --
252 -- Pre Conditions
253 --   None.
254 --
255 -- In Parameters
256 --    p_vrbl_rt_prfl_id
257 --    p_ordr_num
258 --    p_effective_date
259 --    p_business_group_id
260 --
261 -- Post Success
262 --   Processing continues
263 --
264 -- Post Failure
265 --   Errors handled by the procedure
266 --
267 -- Access Status
268 --   Internal table handler use only.
269 --
270 -- ----------------------------------------------------------------------------
271 procedure chk_duplicate_ordr_num
272           (p_vrbl_rt_prfl_id in number
273            ,p_ordr_num in number
274            ,p_effective_date in date
275            ,p_business_group_id in number
276            ,p_loa_rsn_rt_id  in number)
277 is
278    l_proc   varchar2(72) := g_package||' chk_duplicate_ordr_num ';
279    l_dummy    char(1);
280    cursor c1 is select null
281                   from ben_loa_rsn_rt_f
282                  where vrbl_rt_prfl_id = p_vrbl_rt_prfl_id
283                    and loa_rsn_rt_id<> nvl(p_loa_rsn_rt_id,-1)
284                    and p_effective_date between effective_start_date
288 --
285                                             and effective_end_date
286                    and business_group_id + 0 = p_business_group_id
287                    and ordr_num = p_ordr_num;
289 Begin
290    hr_utility.set_location('Entering:'||l_proc, 5);
291 
292    --
293    open c1;
294    fetch c1 into l_dummy;
295    --
296    if c1%found then
297       fnd_message.set_name('BEN','BEN_91001_SEQ_NOT_UNIQUE');
298       fnd_message.raise_error;
299    end if;
300    close c1;
301    --
302    hr_utility.set_location('Leaving:'||l_proc, 15);
303 End chk_duplicate_ordr_num;
304 
305 -- ----------------------------------------------------------------------------
306 -- |------< chk_excld_flag >------|
307 -- ----------------------------------------------------------------------------
308 --
309 -- Description
310 --   This procedure is used to check that the lookup value is valid.
311 --
312 -- Pre Conditions
313 --   None.
314 --
315 -- In Parameters
316 --   loa_rsn_rt_id PK of record being inserted or updated.
317 --   excld_flag Value of lookup code.
318 --   effective_date effective date
319 --   object_version_number Object version number of record being
320 --                         inserted or updated.
321 --
322 -- Post Success
323 --   Processing continues
324 --
325 -- Post Failure
326 --   Error handled by procedure
327 --
328 -- Access Status
329 --   Internal table handler use only.
330 --
331 Procedure chk_excld_flag(p_loa_rsn_rt_id                in number,
332                             p_excld_flag               in varchar2,
333                             p_effective_date              in date,
334                             p_object_version_number       in number) is
335   --
336   l_proc         varchar2(72) := g_package||'chk_excld_flag';
337   l_api_updating boolean;
338   --
339 Begin
340   --
341   hr_utility.set_location('Entering:'||l_proc, 5);
342   --
343   l_api_updating := ben_lar_shd.api_updating
344     (p_loa_rsn_rt_id                => p_loa_rsn_rt_id,
345      p_effective_date              => p_effective_date,
346      p_object_version_number       => p_object_version_number);
347   --
348   if (l_api_updating
349       and p_excld_flag
350       <> nvl(ben_lar_shd.g_old_rec.excld_flag,hr_api.g_varchar2)
351       or not l_api_updating) then
352     --
353     -- check if value of lookup falls within lookup type.
354     --
355     --
356     if hr_api.not_exists_in_hr_lookups
357           (p_lookup_type    => 'YES_NO',
358            p_lookup_code    => p_excld_flag,
359            p_effective_date => p_effective_date) then
360       --
361       -- raise error as does not exist as lookup
362       --
363       fnd_message.set_name('PAY','HR_LOOKUP_DOES_NOT_EXIST');
364       fnd_message.raise_error;
365       --
366     end if;
367     --
368   end if;
369   --
370   hr_utility.set_location('Leaving:'||l_proc,10);
371   --
372 end chk_excld_flag;
373 -- ----------------------------------------------------------------------------
374 -- |------< chk_absence_attendance_type_id>------|
375 -- ----------------------------------------------------------------------------
376 --
377 -- Description
378 --   This procedure checks that a referenced foreign key actually exists
379 --   in the referenced table.
380 --
381 -- Pre-Conditions
382 --   None.
383 --
384 -- In Parameters
385 --   p_loa_rsn_rt_id PK
386 --   p_absence_attendance_type_id of FK column
387 --   p_object_version_number object version number
388 --
389 -- Post Success
390 --   Processing continues
391 --
392 -- Post Failure
393 --   Error raised.
394 --
395 -- Access Status
396 --   Internal table handler use only.
397 --
398 Procedure chk_absence_attendance_type_id (p_loa_rsn_rt_id  in number,
399                             p_absence_attendance_type_id   in number,
400                             p_object_version_number        in number,
401                             p_effective_date               in date,
402                             p_business_group_id            in number) is
403   --
404   l_proc         varchar2(72) := g_package||'chk_absence_attendance_type_id';
405   l_api_updating boolean;
406   l_dummy        varchar2(1);
407   --
408   cursor c1 is
409     select null
410     from   per_absence_attendance_types abs
411     where  abs.absence_attendance_type_id = p_absence_attendance_type_id
412     and abs.business_group_id = p_business_group_id;
413   --
414 Begin
415   --
416   hr_utility.set_location('Entering:'||l_proc,5);
417   --
418   l_api_updating := ben_lar_shd.api_updating
419      (p_loa_rsn_rt_id         => p_loa_rsn_rt_id,
420       p_effective_date        => p_effective_date,
421       p_object_version_number => p_object_version_number);
422   --
423   if (l_api_updating
424      and nvl(p_absence_attendance_type_id,hr_api.g_number)
425      <> nvl(ben_lar_shd.g_old_rec.absence_attendance_type_id,hr_api.g_number)
426      or not l_api_updating)
427      and p_absence_attendance_type_id is not null then
428     --
429     -- check if absence_attendance_type_id value exists in
430     -- per_absence_attendance_type table
431     --
432     open c1;
433       --
434       fetch c1 into l_dummy;
435       if c1%notfound then
436         --
437         close c1;
438         --
439         -- raise error as FK does not relate to PK in
440         -- per_absence_attendance_types table.
441         --
442         ben_lar_shd.constraint_error('BEN_LOA_RSN_RT_F_FK2');
443         --
447     --
444       end if;
445       --
446     close c1;
448   end if;
449   --
450   hr_utility.set_location('Leaving:'||l_proc,10);
451   --
452 End chk_absence_attendance_type_id;
453 --
454 -- ----------------------------------------------------------------------------
455 -- |------< chk_abs_attendance_reason_id>------|
456 -- ----------------------------------------------------------------------------
457 --
458 -- Description
459 --   This procedure checks that a referenced foreign key actually exists
460 --   in the referenced table.
461 --
462 -- Pre-Conditions
463 --   None.
464 --
465 -- In Parameters
466 --   p_loa_rsn_rt_id PK
467 --   p_abs_attendance_reason_id of FK column
468 --   p_object_version_number object version number
469 --
470 -- Post Success
471 --   Processing continues
472 --
473 -- Post Failure
474 --   Error raised.
475 --
476 -- Access Status
477 --   Internal table handler use only.
478 --
479 Procedure chk_abs_attendance_reason_id(p_loa_rsn_rt_id in number,
480                             p_abs_attendance_reason_id in number,
481                             p_object_version_number    in number,
482                             p_effective_date           in date,
483                             p_business_group_id        in number) is
484   --
485   l_proc         varchar2(72) := g_package||'chk_abs_attendance_reason_id';
486   l_api_updating boolean;
487   l_dummy        varchar2(1);
488   --
489   cursor c1 is
490     select null
491     from   per_abs_attendance_reasons abr
492     where  abr.abs_attendance_reason_id = p_abs_attendance_reason_id
493     and    abr.business_group_id = p_business_group_id;
494   --
495 Begin
496   --
497   hr_utility.set_location('Entering:'||l_proc,5);
498   --
499   l_api_updating := ben_lar_shd.api_updating
500      (p_loa_rsn_rt_id         => p_loa_rsn_rt_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_abs_attendance_reason_id,hr_api.g_number)
506      <> nvl(ben_lar_shd.g_old_rec.abs_attendance_reason_id,hr_api.g_number)
507      or not l_api_updating)
508      and p_abs_attendance_reason_id is not null then
509     --
510     -- check if abs_attendance_reason_id value exists in
511     --
512     open c1;
513       --
514       fetch c1 into l_dummy;
515       if c1%notfound then
516         --
517         close c1;
518         --
519         -- raise error as FK does not relate to PK in
520         -- per_abs_attendance_reasons table.
521         --
522         ben_lar_shd.constraint_error('BEN_LOA_RSN_RT_F_FK3');
523         --
524       end if;
525       --
526     close c1;
527     --
528   end if;
529   --
530   hr_utility.set_location('Leaving:'||l_proc,10);
531   --
532 End chk_abs_attendance_reason_id;
533 --
534 --
535 -- ----------------------------------------------------------------------------
536 -- |--------------------------< dt_update_validate >--------------------------|
537 -- ----------------------------------------------------------------------------
538 -- {Start Of Comments}
539 --
540 -- Description:
541 --   This procedure is used for referential integrity of datetracked
542 --   parent entities when a datetrack update operation is taking place
543 --   and where there is no cascading of update defined for this entity.
544 --
545 -- Prerequisites:
546 --   This procedure is called from the update_validate.
547 --
548 -- In Parameters:
549 --
550 -- Post Success:
551 --   Processing continues.
552 --
553 -- Post Failure:
554 --
555 -- Developer Implementation Notes:
556 --   This procedure should not need maintenance unless the HR Schema model
557 --   changes.
558 --
559 -- Access Status:
560 --   Internal Row Handler Use Only.
561 --
562 -- {End Of Comments}
563 -- ----------------------------------------------------------------------------
564 Procedure dt_update_validate
565             (p_vrbl_rt_prfl_id               in number default hr_api.g_number,
566 	     p_datetrack_mode		     in varchar2,
567              p_validation_start_date	     in date,
568 	     p_validation_end_date	     in date) Is
569 --
570   l_proc	    varchar2(72) := g_package||'dt_update_validate';
571   l_integrity_error Exception;
572   l_table_name	    all_tables.table_name%TYPE;
573 --
574 Begin
575   hr_utility.set_location('Entering:'||l_proc, 5);
576   --
577   -- Ensure that the p_datetrack_mode argument is not null
578   --
579   hr_api.mandatory_arg_error
580     (p_api_name       => l_proc,
581      p_argument       => 'datetrack_mode',
582      p_argument_value => p_datetrack_mode);
583   --
584   -- Only perform the validation if the datetrack update mode is valid
585   --
586   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
587     --
588     --
589     -- Ensure the arguments are not null
590     --
591     hr_api.mandatory_arg_error
592       (p_api_name       => l_proc,
593        p_argument       => 'validation_start_date',
594        p_argument_value => p_validation_start_date);
595     --
596     hr_api.mandatory_arg_error
597       (p_api_name       => l_proc,
598        p_argument       => 'validation_end_date',
599        p_argument_value => p_validation_end_date);
600     --
601     --
602     If ((nvl(p_vrbl_rt_prfl_id, hr_api.g_number) <> hr_api.g_number) and
603       NOT (dt_api.check_min_max_dates
604             (p_base_table_name => 'ben_vrbl_rt_prfl_f',
608              p_to_date         => p_validation_end_date)))  Then
605              p_base_key_column => 'vrbl_rt_prfl_id',
606              p_base_key_value  => p_vrbl_rt_prfl_id,
607              p_from_date       => p_validation_start_date,
609       l_table_name := 'ben_vrbl_rt_prfl_f';
610       Raise l_integrity_error;
611     End If;
612     --
613   End If;
614   --
615   hr_utility.set_location(' Leaving:'||l_proc, 10);
616 Exception
617   When l_integrity_error Then
618     --
619     -- A referential integrity check was violated therefore
620     -- we must error
621     --
622        ben_utility.parent_integrity_error (p_table_name => l_table_name);
623   When Others Then
624     --
625     -- An unhandled or unexpected error has occurred which
626     -- we must report
627     --
628     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
629     fnd_message.set_token('PROCEDURE', l_proc);
630     fnd_message.set_token('STEP','15');
631     fnd_message.raise_error;
632 End dt_update_validate;
633 --
634 -- ----------------------------------------------------------------------------
635 -- |--------------------------< dt_delete_validate >--------------------------|
636 -- ----------------------------------------------------------------------------
637 -- {Start Of Comments}
638 --
639 -- Description:
640 --   This procedure is used for referential integrity of datetracked
641 --   child entities when either a datetrack DELETE or ZAP is in operation
642 --   and where there is no cascading of delete defined for this entity.
643 --   For the datetrack mode of DELETE or ZAP we must ensure that no
644 --   datetracked child rows exist between the validation start and end
645 --   dates.
646 --
647 -- Prerequisites:
648 --   This procedure is called from the delete_validate.
649 --
650 -- In Parameters:
651 --
652 -- Post Success:
653 --   Processing continues.
654 --
655 -- Post Failure:
656 --   If a row exists by determining the returning Boolean value from the
657 --   generic dt_api.rows_exist function then we must supply an error via
658 --   the use of the local exception handler l_rows_exist.
659 --
660 -- Developer Implementation Notes:
661 --   This procedure should not need maintenance unless the HR Schema model
662 --   changes.
663 --
664 -- Access Status:
665 --   Internal Row Handler Use Only.
666 --
667 -- {End Of Comments}
668 -- ----------------------------------------------------------------------------
669 Procedure dt_delete_validate
670             (p_loa_rsn_rt_id		in number,
671              p_datetrack_mode		in varchar2,
672 	     p_validation_start_date	in date,
673 	     p_validation_end_date	in date) Is
674 --
675   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
676   l_rows_exist	Exception;
677   l_table_name	all_tables.table_name%TYPE;
678 --
679 Begin
680   hr_utility.set_location('Entering:'||l_proc, 5);
681   --
682   -- Ensure that the p_datetrack_mode argument is not null
683   --
684   hr_api.mandatory_arg_error
685     (p_api_name       => l_proc,
686      p_argument       => 'datetrack_mode',
687      p_argument_value => p_datetrack_mode);
688   --
689   -- Only perform the validation if the datetrack mode is either
690   -- DELETE or ZAP
691   --
692   If (p_datetrack_mode = 'DELETE' or
693       p_datetrack_mode = 'ZAP') then
694     --
695     --
696     -- Ensure the arguments are not null
697     --
698     hr_api.mandatory_arg_error
699       (p_api_name       => l_proc,
700        p_argument       => 'validation_start_date',
701        p_argument_value => p_validation_start_date);
702     --
703     hr_api.mandatory_arg_error
704       (p_api_name       => l_proc,
705        p_argument       => 'validation_end_date',
706        p_argument_value => p_validation_end_date);
707     --
708     hr_api.mandatory_arg_error
709       (p_api_name       => l_proc,
710        p_argument       => 'loa_rsn_rt_id',
711        p_argument_value => p_loa_rsn_rt_id);
712     --
713     --
714     --
715   End If;
716   --
717   hr_utility.set_location(' Leaving:'||l_proc, 10);
718 Exception
719   When l_rows_exist Then
720     --
721     -- A referential integrity check was violated therefore
722     -- we must error
723     --
724     fnd_message.set_name('PAY', 'HR_7215_DT_CHILD_EXISTS');
725     fnd_message.set_token('TABLE_NAME', l_table_name);
726     fnd_message.raise_error;
727   When Others Then
728     --
729     -- An unhandled or unexpected error has occurred which
730     -- we must report
731     --
732     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
733     fnd_message.set_token('PROCEDURE', l_proc);
734     fnd_message.set_token('STEP','15');
735     fnd_message.raise_error;
736 End dt_delete_validate;
737 --
738 -- ----------------------------------------------------------------------------
739 -- |---------------------------< insert_validate >----------------------------|
740 -- ----------------------------------------------------------------------------
741 Procedure insert_validate
742 	(p_rec 			 in ben_lar_shd.g_rec_type,
743 	 p_effective_date	 in date,
744 	 p_datetrack_mode	 in varchar2,
745 	 p_validation_start_date in date,
746 	 p_validation_end_date	 in date) is
747 --
748   l_proc	varchar2(72) := g_package||'insert_validate';
749 --
750 Begin
751   hr_utility.set_location('Entering:'||l_proc, 5);
752   --
756   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
753   -- Call all supporting business operations
754   --
755   --
757   --
758   chk_loa_rsn_rt_id
759   (p_loa_rsn_rt_id          => p_rec.loa_rsn_rt_id,
760    p_effective_date        => p_effective_date,
761    p_object_version_number => p_rec.object_version_number);
762   --
763   chk_loa_rsn_cd
764   (p_loa_rsn_rt_id          => p_rec.loa_rsn_rt_id,
765    p_loa_rsn_cd             => p_rec.loa_rsn_cd,
766    p_effective_date         => p_effective_date,
767    p_object_version_number  => p_rec.object_version_number);
768   --
769   chk_excld_flag
770   (p_loa_rsn_rt_id          => p_rec.loa_rsn_rt_id,
771    p_excld_flag             => p_rec.excld_flag,
772    p_effective_date         => p_effective_date,
773    p_object_version_number  => p_rec.object_version_number);
774   --
775   chk_absence_attendance_type_id
776   (p_loa_rsn_rt_id              => p_rec.loa_rsn_rt_id,
777    p_absence_attendance_type_id => p_rec.absence_attendance_type_id,
778    p_object_version_number      => p_rec.object_version_number,
779    p_effective_date             => p_effective_date,
780    p_business_group_id          => p_rec.business_group_id);
781   --
782   chk_abs_attendance_reason_id
783   (p_loa_rsn_rt_id              => p_rec.loa_rsn_rt_id,
784    p_abs_attendance_reason_id   => p_rec.abs_attendance_reason_id,
785    p_object_version_number      => p_rec.object_version_number,
786    p_effective_date             => p_effective_date,
787    p_business_group_id          => p_rec.business_group_id);
788   --
789   chk_dup_record
790   (p_loa_rsn_rt_id         => p_rec.loa_rsn_rt_id,
791    p_loa_rsn_cd  	   => p_rec.loa_rsn_cd,
792    p_absence_attendance_type_id => p_rec.absence_attendance_type_id,
793    p_abs_attendance_reason_id   => p_rec.abs_attendance_reason_id,
794    p_vrbl_rt_prfl_id	   => p_rec.vrbl_rt_prfl_id,
795    p_effective_date        => p_effective_date,
796    p_object_version_number => p_rec.object_version_number,
797    p_business_group_id     => p_rec.business_group_id,
798    p_validation_start_date => p_validation_start_date,
799    p_validation_end_date   => p_validation_end_date);
800   --
801 chk_duplicate_ordr_num
802           (p_vrbl_rt_prfl_id      => p_rec.vrbl_rt_prfl_id
803            ,p_ordr_num            => p_rec.ordr_num
804            ,p_effective_date      => p_effective_date
805            ,p_business_group_id   => p_rec.business_group_id
806            ,p_loa_rsn_rt_id	  => p_rec.loa_rsn_rt_id);
807 --
808   hr_utility.set_location(' Leaving:'||l_proc, 10);
809 End insert_validate;
810 --
811 -- ----------------------------------------------------------------------------
812 -- |---------------------------< update_validate >----------------------------|
813 -- ----------------------------------------------------------------------------
814 Procedure update_validate
815 	(p_rec 			 in ben_lar_shd.g_rec_type,
816 	 p_effective_date	 in date,
817 	 p_datetrack_mode	 in varchar2,
818 	 p_validation_start_date in date,
819 	 p_validation_end_date	 in date) is
820 --
821   l_proc	varchar2(72) := g_package||'update_validate';
822 --
823 Begin
824   hr_utility.set_location('Entering:'||l_proc, 5);
825   --
826   -- Call all supporting business operations
827   --
828   --
829   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
830   --
831   chk_loa_rsn_rt_id
832   (p_loa_rsn_rt_id          => p_rec.loa_rsn_rt_id,
833    p_effective_date        => p_effective_date,
834    p_object_version_number => p_rec.object_version_number);
835   --
836   chk_loa_rsn_cd
837   (p_loa_rsn_rt_id          => p_rec.loa_rsn_rt_id,
838    p_loa_rsn_cd             => p_rec.loa_rsn_cd,
839    p_effective_date         => p_effective_date,
840    p_object_version_number  => p_rec.object_version_number);
841   --
842   chk_excld_flag
843   (p_loa_rsn_rt_id          => p_rec.loa_rsn_rt_id,
844    p_excld_flag             => p_rec.excld_flag,
845    p_effective_date         => p_effective_date,
846    p_object_version_number  => p_rec.object_version_number);
847   --
848   chk_absence_attendance_type_id
849   (p_loa_rsn_rt_id              => p_rec.loa_rsn_rt_id,
850    p_absence_attendance_type_id => p_rec.absence_attendance_type_id,
851    p_object_version_number      => p_rec.object_version_number,
852    p_effective_date             => p_effective_date,
853    p_business_group_id          => p_rec.business_group_id);
854   --
855   chk_abs_attendance_reason_id
856   (p_loa_rsn_rt_id              => p_rec.loa_rsn_rt_id,
857    p_abs_attendance_reason_id   => p_rec.abs_attendance_reason_id,
858    p_object_version_number      => p_rec.object_version_number,
859    p_effective_date             => p_effective_date,
860    p_business_group_id          => p_rec.business_group_id);
861   --
862   chk_dup_record
863   (p_loa_rsn_rt_id         => p_rec.loa_rsn_rt_id,
864    p_loa_rsn_cd  	   => p_rec.loa_rsn_cd,
865    p_absence_attendance_type_id => p_rec.absence_attendance_type_id,
866    p_abs_attendance_reason_id   => p_rec.abs_attendance_reason_id,
867    p_vrbl_rt_prfl_id	   => p_rec.vrbl_rt_prfl_id,
868    p_effective_date        => p_effective_date,
869    p_object_version_number => p_rec.object_version_number,
870    p_business_group_id     => p_rec.business_group_id,
871    p_validation_start_date => p_validation_start_date,
872    p_validation_end_date   => p_validation_end_date);
873   --
874   -- Call the datetrack update integrity operation
875   --
876   dt_update_validate
877     (
878      p_datetrack_mode                => p_datetrack_mode,
879      p_validation_start_date	     => p_validation_start_date,
880      p_validation_end_date	     => p_validation_end_date);
881   --
882 chk_duplicate_ordr_num
883           (p_vrbl_rt_prfl_id      => p_rec.vrbl_rt_prfl_id
884            ,p_ordr_num            => p_rec.ordr_num
885            ,p_effective_date      => p_effective_date
886            ,p_business_group_id   => p_rec.business_group_id
887            ,p_loa_rsn_rt_id	  => p_rec.loa_rsn_rt_id);
888 --
889   hr_utility.set_location(' Leaving:'||l_proc, 10);
890 End update_validate;
891 --
892 -- ----------------------------------------------------------------------------
893 -- |---------------------------< delete_validate >----------------------------|
894 -- ----------------------------------------------------------------------------
895 Procedure delete_validate
896 	(p_rec 			 in ben_lar_shd.g_rec_type,
897 	 p_effective_date	 in date,
898 	 p_datetrack_mode	 in varchar2,
899 	 p_validation_start_date in date,
900 	 p_validation_end_date	 in date) is
901 --
902   l_proc	varchar2(72) := g_package||'delete_validate';
903 --
904 Begin
905   hr_utility.set_location('Entering:'||l_proc, 5);
906   --
907   -- Call all supporting business operations
908   --
909   dt_delete_validate
910     (p_datetrack_mode		=> p_datetrack_mode,
911      p_validation_start_date	=> p_validation_start_date,
912      p_validation_end_date	=> p_validation_end_date,
913      p_loa_rsn_rt_id		=> p_rec.loa_rsn_rt_id);
914   --
915   hr_utility.set_location(' Leaving:'||l_proc, 10);
916 End delete_validate;
917 --
918 --
919 --  ---------------------------------------------------------------------------
920 --  |---------------------< return_legislation_code >-------------------------|
921 --  ---------------------------------------------------------------------------
922 --
923 function return_legislation_code
924   (p_loa_rsn_rt_id in number) return varchar2 is
925   --
926   -- Declare cursor
927   --
928   cursor csr_leg_code is
929     select a.legislation_code
930     from   per_business_groups a,
931            ben_loa_rsn_rt_f b
932     where b.loa_rsn_rt_id      = p_loa_rsn_rt_id
933     and   a.business_group_id = b.business_group_id;
934   --
935   -- Declare local variables
936   --
937   l_legislation_code  varchar2(150);
938   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
939   --
940 begin
941   --
942   hr_utility.set_location('Entering:'|| l_proc, 10);
943   --
944   -- Ensure that all the mandatory parameter are not null
945   --
946   hr_api.mandatory_arg_error(p_api_name       => l_proc,
947                              p_argument       => 'loa_rsn_rt_id',
948                              p_argument_value => p_loa_rsn_rt_id);
949   --
950   open csr_leg_code;
951     --
952     fetch csr_leg_code into l_legislation_code;
953     --
954     if csr_leg_code%notfound then
955       --
956       close csr_leg_code;
957       --
958       -- The primary key is invalid therefore we must error
959       --
960       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
961       fnd_message.raise_error;
962       --
963     end if;
964     --
965   close csr_leg_code;
966   --
967   hr_utility.set_location(' Leaving:'|| l_proc, 20);
968   --
969   return l_legislation_code;
970   --
971 end return_legislation_code;
972 --
973 end ben_lar_bus;