DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PDL_BUS

Source


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