DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_LRR_BUS

Source


4 -- ----------------------------------------------------------------------------
1 Package Body ben_lrr_bus as
2 /* $Header: belrrrhi.pkb 115.6 2002/12/16 17:38:03 glingapp ship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_lrr_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_lee_rsn_rl_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 --   lee_rsn_rl_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_lee_rsn_rl_id(p_lee_rsn_rl_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_lee_rsn_rl_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_lrr_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_lee_rsn_rl_id                => p_lee_rsn_rl_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_lee_rsn_rl_id,hr_api.g_number)
55      <>  ben_lrr_shd.g_old_rec.lee_rsn_rl_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_lrr_shd.constraint_error('BEN_LER_RL_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_lee_rsn_rl_id is not null then
66       --
67       -- raise error as PK is not null
68       --
72     --
69       ben_lrr_shd.constraint_error('BEN_LER_RL_PK');
70       --
71     end if;
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_lee_rsn_rl_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |------< chk_ordr_to_aply_num >------|
81 -- ----------------------------------------------------------------------------
82 --
83 -- Description
84 --   This procedure is used to ensure that the value is unique within parent
85 --   and within bus grp.
86 --
87 -- Pre Conditions
88 --   None.
89 --
90 -- In Parameters
91 --   effective_date effective date
92 --   object_version_number Object version number of record being
93 --                         inserted or updated.
94 --
95 -- Post Success
96 --   Processing continues
97 --
98 -- Post Failure
99 --   Error handled by procedure
100 --
101 -- Access Status
102 --   Internal table handler use only.
103 --
104 Procedure chk_ordr_to_aply_num(p_lee_rsn_rl_id in number,
105                             p_lee_rsn_id in number,
106                             p_ordr_to_aply_num              in number,
107                             p_effective_date              in date,
108 				    p_validation_start_date         in date,
109                             p_validation_end_date           in date,
110                             p_business_group_id           in number,
111                             p_object_version_number       in number) is
112 
113 
114  --
115   l_proc         varchar2(72) := g_package||'chk_ler_id';
116   l_api_updating boolean;
117   l_exists       varchar2(1);
118   --
119   -- unique in bg, parent, and eff dates
120   --
121   cursor chk_unique is
122      select null
123         from ben_lee_rsn_rl_f
124         where ordr_to_aply_num = p_ordr_to_aply_num
125           and lee_rsn_rl_id <> nvl(p_lee_rsn_rl_id, hr_api.g_number)
126           and lee_rsn_id = p_lee_rsn_id  --parent
127           and business_group_id + 0 = p_business_group_id
128           and p_validation_start_date <= effective_end_date
129           and p_validation_end_date >= effective_start_date;
130   --
131 Begin
132   --
133   hr_utility.set_location('Entering:'||l_proc, 5);
134   --
135   l_api_updating := ben_lrr_shd.api_updating
136     (p_lee_rsn_rl_id   => p_lee_rsn_rl_id  ,
137      p_effective_date              => p_effective_date,
138      p_object_version_number       => p_object_version_number);
139   --
140   if (l_api_updating
141       and p_ordr_to_aply_num
142       <> nvl(ben_lrr_shd.g_old_rec.ordr_to_aply_num,hr_api.g_number)
143       or not l_api_updating) then
144     --
145     -- this value must be unique
146     --
147     open chk_unique;
148     fetch chk_unique into l_exists;
149     if chk_unique%found then
150       close chk_unique;
151       --
152       -- raise error as UK1 is violated
153       --
154       fnd_message.set_name('PAY','VALUE IS NOT UNIQUE');
155       fnd_message.raise_error;
156       --
157     end if;
158     --
159     close chk_unique;
160     --
161   end if;
162   --
163   hr_utility.set_location('Leaving:'||l_proc,10);
164   --
165 end chk_ordr_to_aply_num;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |------< chk_formula_id >------|
169 -- ----------------------------------------------------------------------------
170 --
171 -- Description
172 --   This procedure is used to ensure that the value is unique within parent
173 --   and within bus grp.
174 --
175 -- Pre Conditions
176 --   None.
177 --
178 -- In Parameters
179 --   effective_date effective date
180 --   object_version_number Object version number of record being
181 --                         inserted or updated.
182 --
183 -- Post Success
184 --   Processing continues
185 --
186 -- Post Failure
187 --   Error handled by procedure
188 --
189 -- Access Status
190 --   Internal table handler use only.
191 --
195                             p_effective_date             in date,
192 Procedure chk_formula_id(p_lee_rsn_rl_id                 in number,
193                             p_lee_rsn_id                 in number,
194                             p_formula_id                 in number,
196 			    p_validation_start_date      in date,
197                             p_validation_end_date        in date,
198                             p_business_group_id          in number,
199                             p_object_version_number      in number) is
200 
201 
202  --
203   l_proc         varchar2(72) := g_package||'chk_ler_id';
204   l_api_updating boolean;
205   l_exists       varchar2(1);
206   l_dummy        varchar2(1);
207   --
208   cursor c1 is
209     select null
210     from   ff_formulas_f ff
211             ,per_business_groups pbg
212     where  ff.formula_id = p_formula_id
213     and    ff.formula_type_id = -393
214     and    pbg.business_group_id = p_business_group_id
215     and    nvl(ff.business_group_id, p_business_group_id) = p_business_group_id
216     and    nvl(ff.legislation_code, pbg.legislation_code) = pbg.legislation_code
217     and    p_effective_date
218            between ff.effective_start_date
219            and     ff.effective_end_date;
220   --
221   -- unique in bg, parent, and eff dates
222   --
223   cursor chk_unique is
224      select null
225         from ben_lee_rsn_rl_f
226         where formula_id = p_formula_id
227           and lee_rsn_rl_id <> nvl(p_lee_rsn_rl_id, hr_api.g_number)
228           and lee_rsn_id = p_lee_rsn_id  --parent
229           and business_group_id + 0 = p_business_group_id
230           and p_validation_start_date <= effective_end_date
231           and p_validation_end_date >= effective_start_date;
232   --
233 Begin
234   --
235   hr_utility.set_location('Entering:'||l_proc, 5);
236   --
237   l_api_updating := ben_lrr_shd.api_updating
238     (p_lee_rsn_rl_id               => p_lee_rsn_rl_id  ,
239      p_effective_date              => p_effective_date,
240      p_object_version_number       => p_object_version_number);
241   --
242   if (l_api_updating
243       and p_formula_id
244       <> nvl(ben_lrr_shd.g_old_rec.formula_id,hr_api.g_number)
245       or not l_api_updating)
246       and p_formula_id is not null then
247     --
248     -- check if value of lookup falls within lookup type.
249     --
250     open c1;
251       -- fetch value from cursor if it returns a record then the
252       -- formula is valid otherwise its invalid
253       fetch c1 into l_dummy;
254       if c1%notfound then
255         close c1;
256         -- raise error
257         fnd_message.set_name('BEN','BEN_91471_FORMULA_NOT_FOUND');
258         fnd_message.set_token('ID',p_formula_id);
259         fnd_message.set_token('TYPE_ID',-393);
260         fnd_message.raise_error;
261         --
262       end if;
263     close c1;
264     --
265     -- this value must be unique
266     --
267     open chk_unique;
268     fetch chk_unique into l_exists;
269     if chk_unique%found then
270       close chk_unique;
271       --
272       -- raise error as UK1 is violated
273       --
274       fnd_message.set_name('PAY','VALUE IS NOT UNIQUE');
275       fnd_message.raise_error;
276       --
277     end if;
278     --
279     close chk_unique;
280     --
281   end if;
282   --
283   hr_utility.set_location('Leaving:'||l_proc,10);
284   --
285 end chk_formula_id;
286 --
287 
288 -- ----------------------------------------------------------------------------
289 -- |--------------------------< dt_update_validate >--------------------------|
290 -- ----------------------------------------------------------------------------
291 -- {Start Of Comments}
292 --
293 -- Description:
297 --
294 --   This procedure is used for referential integrity of datetracked
295 --   parent entities when a datetrack update operation is taking place
296 --   and where there is no cascading of update defined for this entity.
298 -- Prerequisites:
299 --   This procedure is called from the update_validate.
300 --
301 -- In Parameters:
302 --
303 -- Post Success:
304 --   Processing continues.
305 --
306 -- Post Failure:
307 --
308 -- Developer Implementation Notes:
309 --   This procedure should not need maintenance unless the HR Schema model
310 --   changes.
311 --
312 -- Access Status:
313 --   Internal Row Handler Use Only.
314 --
315 -- {End Of Comments}
316 -- ----------------------------------------------------------------------------
317 Procedure dt_update_validate
318             (p_formula_id           in number default hr_api.g_number,
319              p_lee_rsn_id                    in number default hr_api.g_number,
320 	     p_datetrack_mode		     in varchar2,
321              p_validation_start_date	     in date,
322 	     p_validation_end_date	     in date) Is
323 --
324   l_proc	    varchar2(72) := g_package||'dt_update_validate';
325   l_integrity_error Exception;
326   l_table_name	    all_tables.table_name%TYPE;
327 --
328 Begin
329   hr_utility.set_location('Entering:'||l_proc, 5);
330   --
331   -- Ensure that the p_datetrack_mode argument is not null
332   --
333   hr_api.mandatory_arg_error
334     (p_api_name       => l_proc,
335      p_argument       => 'datetrack_mode',
336      p_argument_value => p_datetrack_mode);
337   --
338   -- Only perform the validation if the datetrack update mode is valid
339   --
340   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
341     --
342     --
343     -- Ensure the arguments are not null
344     --
345     hr_api.mandatory_arg_error
346       (p_api_name       => l_proc,
347        p_argument       => 'validation_start_date',
348        p_argument_value => p_validation_start_date);
349     --
350     hr_api.mandatory_arg_error
351       (p_api_name       => l_proc,
352        p_argument       => 'validation_end_date',
353        p_argument_value => p_validation_end_date);
354     --
355     If ((nvl(p_formula_id, hr_api.g_number) <> hr_api.g_number) and
356       NOT (dt_api.check_min_max_dates
357             (p_base_table_name => 'ff_formulas_f',
358              p_base_key_column => 'formula_id',
359              p_base_key_value  => p_formula_id,
360              p_from_date       => p_validation_start_date,
361              p_to_date         => p_validation_end_date)))  Then
362       l_table_name := 'ff_formulas_f';
363       Raise l_integrity_error;
364     End If;
365     If ((nvl(p_lee_rsn_id, hr_api.g_number) <> hr_api.g_number) and
366       NOT (dt_api.check_min_max_dates
367             (p_base_table_name => 'ben_lee_rsn_f',
368              p_base_key_column => 'lee_rsn_id',
369              p_base_key_value  => p_lee_rsn_id,
370              p_from_date       => p_validation_start_date,
371              p_to_date         => p_validation_end_date)))  Then
372       l_table_name := 'ben_lee_rsn_f';
373       Raise l_integrity_error;
374     End If;
375     --
376   End If;
377   --
378   hr_utility.set_location(' Leaving:'||l_proc, 10);
379 Exception
380   When l_integrity_error Then
381     --
382     -- A referential integrity check was violated therefore
383     -- we must error
384     --
385     ben_utility.parent_integrity_error(p_table_name => l_table_name);
386   When Others Then
387     --
388     -- An unhandled or unexpected error has occurred which
389     -- we must report
390     --
391     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
392     fnd_message.set_token('PROCEDURE', l_proc);
393     fnd_message.set_token('STEP','15');
394     fnd_message.raise_error;
395 End dt_update_validate;
396 --
397 -- ----------------------------------------------------------------------------
398 -- |--------------------------< dt_delete_validate >--------------------------|
399 -- ----------------------------------------------------------------------------
400 -- {Start Of Comments}
401 --
402 -- Description:
403 --   This procedure is used for referential integrity of datetracked
404 --   child entities when either a datetrack DELETE or ZAP is in operation
405 --   and where there is no cascading of delete defined for this entity.
406 --   For the datetrack mode of DELETE or ZAP we must ensure that no
407 --   datetracked child rows exist between the validation start and end
408 --   dates.
409 --
410 -- Prerequisites:
411 --   This procedure is called from the delete_validate.
412 --
413 -- In Parameters:
414 --
415 -- Post Success:
416 --   Processing continues.
417 --
418 -- Post Failure:
419 --   If a row exists by determining the returning Boolean value from the
420 --   generic dt_api.rows_exist function then we must supply an error via
421 --   the use of the local exception handler l_rows_exist.
422 --
423 -- Developer Implementation Notes:
424 --   This procedure should not need maintenance unless the HR Schema model
425 --   changes.
426 --
427 -- Access Status:
428 --   Internal Row Handler Use Only.
429 --
430 -- {End Of Comments}
431 -- ----------------------------------------------------------------------------
432 Procedure dt_delete_validate
433             (p_lee_rsn_rl_id		in number,
434              p_datetrack_mode		in varchar2,
435 	     p_validation_start_date	in date,
436 	     p_validation_end_date	in date) Is
437 --
438   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
442 Begin
439   l_rows_exist	Exception;
440   l_table_name	all_tables.table_name%TYPE;
441 --
443   hr_utility.set_location('Entering:'||l_proc, 5);
444   --
445   -- Ensure that the p_datetrack_mode argument is not null
446   --
447   hr_api.mandatory_arg_error
448     (p_api_name       => l_proc,
449      p_argument       => 'datetrack_mode',
450      p_argument_value => p_datetrack_mode);
451   --
452   -- Only perform the validation if the datetrack mode is either
453   -- DELETE or ZAP
454   --
455   If (p_datetrack_mode = 'DELETE' or
456       p_datetrack_mode = 'ZAP') then
457     --
458     --
459     -- Ensure the arguments are not null
460     --
461     hr_api.mandatory_arg_error
462       (p_api_name       => l_proc,
463        p_argument       => 'validation_start_date',
464        p_argument_value => p_validation_start_date);
465     --
466     hr_api.mandatory_arg_error
467       (p_api_name       => l_proc,
468        p_argument       => 'validation_end_date',
469        p_argument_value => p_validation_end_date);
470     --
471     hr_api.mandatory_arg_error
472       (p_api_name       => l_proc,
473        p_argument       => 'lee_rsn_rl_id',
474        p_argument_value => p_lee_rsn_rl_id);
475     --
476     --
477     --
478   End If;
479   --
480   hr_utility.set_location(' Leaving:'||l_proc, 10);
481 Exception
482   When l_rows_exist Then
483     --
484     -- A referential integrity check was violated therefore
485     -- we must error
486     --
487     ben_utility.child_exists_error(p_table_name => l_table_name);
488   When Others Then
489     --
490     -- An unhandled or unexpected error has occurred which
491     -- we must report
492     --
493     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
494     fnd_message.set_token('PROCEDURE', l_proc);
495     fnd_message.set_token('STEP','15');
496     fnd_message.raise_error;
497 End dt_delete_validate;
498 --
499 -- ----------------------------------------------------------------------------
500 -- |---------------------------< insert_validate >----------------------------|
501 -- ----------------------------------------------------------------------------
502 Procedure insert_validate
503 	(p_rec 			 in ben_lrr_shd.g_rec_type,
504 	 p_effective_date	 in date,
505 	 p_datetrack_mode	 in varchar2,
506 	 p_validation_start_date in date,
507 	 p_validation_end_date	 in date) is
508 --
509   l_proc	varchar2(72) := g_package||'insert_validate';
510 --
511 Begin
512   hr_utility.set_location('Entering:'||l_proc, 5);
513   --
514   -- Call all supporting business operations
515   --
516   --
517   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
518   --
519   chk_lee_rsn_rl_id
520   (p_lee_rsn_rl_id          => p_rec.lee_rsn_rl_id,
521    p_effective_date        => p_effective_date,
522    p_object_version_number => p_rec.object_version_number);
523   --
524   chk_ordr_to_aply_num
525   (p_lee_rsn_rl_id     => p_rec.lee_rsn_rl_id,
526    p_lee_rsn_id     => p_rec.lee_rsn_id,
527    p_ordr_to_aply_num        => p_rec.ordr_to_aply_num,
528    p_effective_date        => p_effective_date,
529    p_validation_start_date  =>    p_validation_start_date,
530    p_validation_end_date      =>  p_validation_end_date,
531    p_business_group_id        =>  p_rec.business_group_id,
532    p_object_version_number => p_rec.object_version_number);
533   --
534   chk_formula_id
535   (p_lee_rsn_rl_id     => p_rec.lee_rsn_rl_id,
536    p_lee_rsn_id     => p_rec.lee_rsn_id,
537    p_formula_id        => p_rec.formula_id,
538    p_effective_date        => p_effective_date,
539    p_validation_start_date  =>    p_validation_start_date,
540    p_validation_end_date      =>  p_validation_end_date,
541    p_business_group_id        =>  p_rec.business_group_id,
542    p_object_version_number => p_rec.object_version_number);
543   --
544   hr_utility.set_location(' Leaving:'||l_proc, 10);
545 End insert_validate;
546 --
547 -- ----------------------------------------------------------------------------
548 -- |---------------------------< update_validate >----------------------------|
549 -- ----------------------------------------------------------------------------
550 Procedure update_validate
551 	(p_rec 			 in ben_lrr_shd.g_rec_type,
552 	 p_effective_date	 in date,
553 	 p_datetrack_mode	 in varchar2,
554 	 p_validation_start_date in date,
555 	 p_validation_end_date	 in date) is
556 --
557   l_proc	varchar2(72) := g_package||'update_validate';
558 --
559 Begin
560   hr_utility.set_location('Entering:'||l_proc, 5);
561   --
562   -- Call all supporting business operations
563   --
564   --
565   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
566   --
567   chk_lee_rsn_rl_id
568   (p_lee_rsn_rl_id          => p_rec.lee_rsn_rl_id,
569    p_effective_date        => p_effective_date,
570    p_object_version_number => p_rec.object_version_number);
571   --
572   chk_ordr_to_aply_num
573   (p_lee_rsn_rl_id     => p_rec.lee_rsn_rl_id,
574    p_lee_rsn_id     => p_rec.lee_rsn_id,
575    p_ordr_to_aply_num        => p_rec.ordr_to_aply_num,
576    p_effective_date        => p_effective_date,
577    p_validation_start_date  =>    p_validation_start_date,
578    p_validation_end_date      =>  p_validation_end_date,
579    p_business_group_id        =>  p_rec.business_group_id,
580    p_object_version_number => p_rec.object_version_number);
581   --
582   chk_formula_id
583   (p_lee_rsn_rl_id     => p_rec.lee_rsn_rl_id,
584    p_lee_rsn_id     => p_rec.lee_rsn_id,
588    p_validation_end_date      =>  p_validation_end_date,
585    p_formula_id        => p_rec.formula_id,
586    p_effective_date        => p_effective_date,
587    p_validation_start_date  =>    p_validation_start_date,
589    p_business_group_id        =>  p_rec.business_group_id,
590    p_object_version_number => p_rec.object_version_number);
591   --
592   -- Call the datetrack update integrity operation
593   --
594   dt_update_validate
595     (p_formula_id           => p_rec.formula_id,
596              p_lee_rsn_id                    => p_rec.lee_rsn_id,
597      p_datetrack_mode                => p_datetrack_mode,
598      p_validation_start_date	     => p_validation_start_date,
599      p_validation_end_date	     => p_validation_end_date);
600   --
601   hr_utility.set_location(' Leaving:'||l_proc, 10);
602 End update_validate;
603 --
604 -- ----------------------------------------------------------------------------
605 -- |---------------------------< delete_validate >----------------------------|
606 -- ----------------------------------------------------------------------------
607 Procedure delete_validate
608 	(p_rec 			 in ben_lrr_shd.g_rec_type,
609 	 p_effective_date	 in date,
610 	 p_datetrack_mode	 in varchar2,
611 	 p_validation_start_date in date,
612 	 p_validation_end_date	 in date) is
613 --
614   l_proc	varchar2(72) := g_package||'delete_validate';
615 --
616 Begin
617   hr_utility.set_location('Entering:'||l_proc, 5);
618   --
619   -- Call all supporting business operations
620   --
621   dt_delete_validate
622     (p_datetrack_mode		=> p_datetrack_mode,
623      p_validation_start_date	=> p_validation_start_date,
624      p_validation_end_date	=> p_validation_end_date,
625      p_lee_rsn_rl_id		=> p_rec.lee_rsn_rl_id);
626   --
627   hr_utility.set_location(' Leaving:'||l_proc, 10);
628 End delete_validate;
629 --
630 --
631 --  ---------------------------------------------------------------------------
632 --  |---------------------< return_legislation_code >-------------------------|
633 --  ---------------------------------------------------------------------------
634 --
635 function return_legislation_code
636   (p_lee_rsn_rl_id in number) return varchar2 is
637   --
638   -- Declare cursor
639   --
640   cursor csr_leg_code is
641     select a.legislation_code
642     from   per_business_groups a,
643            ben_lee_rsn_rl_f b
644     where b.lee_rsn_rl_id      = p_lee_rsn_rl_id
645     and   a.business_group_id = b.business_group_id;
646   --
647   -- Declare local variables
648   --
649   l_legislation_code  varchar2(150);
650   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
651   --
652 begin
653   --
654   hr_utility.set_location('Entering:'|| l_proc, 10);
655   --
656   -- Ensure that all the mandatory parameter are not null
657   --
658   hr_api.mandatory_arg_error(p_api_name       => l_proc,
659                              p_argument       => 'lee_rsn_rl_id',
660                              p_argument_value => p_lee_rsn_rl_id);
661   --
662   open csr_leg_code;
663     --
664     fetch csr_leg_code into l_legislation_code;
665     --
666     if csr_leg_code%notfound then
667       --
668       close csr_leg_code;
669       --
670       -- The primary key is invalid therefore we must error
671       --
672       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
673       fnd_message.raise_error;
674       --
675     end if;
676     --
677   close csr_leg_code;
678   --
679   hr_utility.set_location(' Leaving:'|| l_proc, 20);
680   --
681   return l_legislation_code;
682   --
683 end return_legislation_code;
684 --
685 end ben_lrr_bus;