DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_FRR_BUS

Source


1 Package Body pay_frr_bus as
2 /* $Header: pyfrrrhi.pkb 120.0 2005/05/29 05:07:54 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_frr_bus.';  -- Global package name
9 --
10 -- The following two global variables are only to be
11 -- used by the return_legislation_code function.
12 --
13 g_legislation_code            varchar2(150)  default null;
14 g_formula_result_rule_id      number         default null;
15 --
16 -- This global variable would be used in the chk_ procedures
17 --
18 g_exists                      varchar2(1)    default null;
19 --
20 --  ---------------------------------------------------------------------------
21 --  |----------------------< set_security_group_id >--------------------------|
22 --  ---------------------------------------------------------------------------
23 --
24 Procedure set_security_group_id
25   (p_formula_result_rule_id               in number
26   ,p_associated_column1                   in varchar2 default null
27   ) is
28   --
29   -- Declare cursor
30   --
31   cursor csr_sec_grp is
32     select pbg.security_group_id,
33            pbg.legislation_code
34       from per_business_groups_perf pbg
35          , pay_formula_result_rules_f frr
36      where frr.formula_result_rule_id = p_formula_result_rule_id
37        and pbg.business_group_id (+) = frr.business_group_id;
38   --
39   -- Declare local variables
40   --
41   l_security_group_id number;
42   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
43   l_legislation_code  varchar2(150);
44   --
45 begin
46   --
47   hr_utility.set_location('Entering:'|| l_proc, 10);
48   --
49   -- Ensure that all the mandatory parameter are not null
50   --
51   hr_api.mandatory_arg_error
52     (p_api_name           => l_proc
53     ,p_argument           => 'formula_result_rule_id'
54     ,p_argument_value     => p_formula_result_rule_id
55     );
56   --
57   open csr_sec_grp;
58   fetch csr_sec_grp into l_security_group_id
59                        , l_legislation_code;
60   --
61   if csr_sec_grp%notfound then
62      --
63      close csr_sec_grp;
64      --
65      -- The primary key is invalid therefore we must error
66      --
67      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
68      hr_multi_message.add
69        (p_associated_column1
70          => nvl(p_associated_column1,'FORMULA_RESULT_RULE_ID')
71        );
72      --
73   else
74     close csr_sec_grp;
75     --
76     -- Set the security_group_id in CLIENT_INFO
77     --
78     hr_api.set_security_group_id
79       (p_security_group_id => l_security_group_id
80       );
81     --
82     -- Set the sessions legislation context in HR_SESSION_DATA
83     --
84     hr_api.set_legislation_context(l_legislation_code);
85   end if;
86   --
87   hr_utility.set_location(' Leaving:'|| l_proc, 20);
88   --
89 end set_security_group_id;
90 --
91 --  ---------------------------------------------------------------------------
92 --  |---------------------< return_legislation_code >-------------------------|
93 --  ---------------------------------------------------------------------------
94 --
95 Function return_legislation_code
96   (p_formula_result_rule_id               in     number
97   )
98   Return Varchar2 Is
99   --
100   -- Declare cursor
101   --
102   cursor csr_leg_code is
103     select pbg.legislation_code
104       from per_business_groups_perf pbg
105          , pay_formula_result_rules_f frr
106      where frr.formula_result_rule_id = p_formula_result_rule_id
107        and pbg.business_group_id (+) = frr.business_group_id;
108   --
109   -- Declare local variables
110   --
111   l_legislation_code  varchar2(150);
112   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
113   --
114 Begin
115   --
116   hr_utility.set_location('Entering:'|| l_proc, 10);
117   --
118   -- Ensure that all the mandatory parameter are not null
119   --
120   hr_api.mandatory_arg_error
121     (p_api_name           => l_proc
122     ,p_argument           => 'formula_result_rule_id'
123     ,p_argument_value     => p_formula_result_rule_id
124     );
125   --
126   if ( nvl(pay_frr_bus.g_formula_result_rule_id, hr_api.g_number)
127        = p_formula_result_rule_id) then
128     --
129     -- The legislation code has already been found with a previous
130     -- call to this function. Just return the value in the global
131     -- variable.
132     --
133     l_legislation_code := pay_frr_bus.g_legislation_code;
134     hr_utility.set_location(l_proc, 20);
135   else
136     --
137     -- The ID is different to the last call to this function
138     -- or this is the first call to this function.
139     --
140     open csr_leg_code;
141     fetch csr_leg_code into l_legislation_code;
142     --
143     if csr_leg_code%notfound then
144       --
145       -- The primary key is invalid therefore we must error
146       --
147       close csr_leg_code;
148       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
149       fnd_message.raise_error;
150     end if;
151     hr_utility.set_location(l_proc,30);
152     --
153     -- Set the global variables so the values are
154     -- available for the next call to this function.
155     --
156     close csr_leg_code;
157     pay_frr_bus.g_formula_result_rule_id      := p_formula_result_rule_id;
158     pay_frr_bus.g_legislation_code  := l_legislation_code;
159   end if;
160   hr_utility.set_location(' Leaving:'|| l_proc, 40);
161   return l_legislation_code;
162 end return_legislation_code;
163 --
164 -- ----------------------------------------------------------------------------
165 -- |-----------------------< chk_non_updateable_args >------------------------|
166 -- ----------------------------------------------------------------------------
167 -- {Start Of Comments}
168 --
169 -- Description:
170 --   This procedure is used to ensure that non updateable attributes have
171 --   not been updated. If an attribute has been updated an error is generated.
172 --
173 -- Pre Conditions:
174 --   g_old_rec has been populated with details of the values currently in
175 --   the database.
176 --
177 -- In Arguments:
178 --   p_rec has been populated with the updated values the user would like the
179 --   record set to.
180 --
181 -- Post Success:
182 --   Processing continues if all the non updateable attributes have not
183 --   changed.
184 --
185 -- Post Failure:
186 --   An application error is raised if any of the non updatable attributes
187 --   have been altered.
188 --
189 -- {End Of Comments}
190 -- ----------------------------------------------------------------------------
191 Procedure chk_non_updateable_args
192   (p_effective_date  in date
193   ,p_rec             in pay_frr_shd.g_rec_type
194   ) IS
195 --
196   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
197   l_error    exception;
198   l_argument varchar2(30);
199 --
200 Begin
201   --
202   -- Only proceed with the validation if a row exists for the current
203   -- record in the HR Schema.
204   --
205   IF NOT pay_frr_shd.api_updating
206       (p_formula_result_rule_id           => p_rec.formula_result_rule_id
207       ,p_effective_date                   => p_effective_date
208       ,p_object_version_number            => p_rec.object_version_number
209       ) THEN
210      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
211      fnd_message.set_token('PROCEDURE ', l_proc);
212      fnd_message.set_token('STEP ', '5');
213      fnd_message.raise_error;
214   END IF;
215   --
216   -- Ensure that the following attributes are not updated.
217   --
218   If nvl(p_rec.business_group_id,hr_api.g_number) <>
219      nvl(pay_frr_shd.g_old_rec.business_group_id,hr_api.g_number) then
220     --
221     l_argument := 'business_group_id';
222     raise l_error;
223     --
224   End if;
225   --
226   If nvl(p_rec.legislation_code,hr_api.g_varchar2) <>
227      nvl(pay_frr_shd.g_old_rec.legislation_code,hr_api.g_varchar2) then
228     --
229     l_argument := 'legislation_code';
230     raise l_error;
231     --
232   End if;
233   --
234   If nvl(p_rec.status_processing_rule_id,hr_api.g_number) <>
235      nvl(pay_frr_shd.g_old_rec.status_processing_rule_id,hr_api.g_number) then
236     --
237     l_argument := 'status_processing_rule_id';
238     raise l_error;
239     --
240   End if;
241   --
242   If nvl(p_rec.result_name,hr_api.g_varchar2) <>
243      nvl(pay_frr_shd.g_old_rec.result_name,hr_api.g_varchar2) then
244     --
245     l_argument := 'result_name';
246     raise l_error;
247     --
248   End if;
249   --
250   If nvl(p_rec.legislation_subgroup,hr_api.g_varchar2) <>
251      nvl(pay_frr_shd.g_old_rec.legislation_subgroup,hr_api.g_varchar2) then
252     --
253     l_argument := 'legislation_subgroup';
254     raise l_error;
255     --
256   End if;
257   --
258 EXCEPTION
259   WHEN l_error THEN
260       hr_api.argument_changed_error
261          (p_api_name => l_proc
262          ,p_argument => l_argument);
263   WHEN OTHERS THEN
264       RAISE;
265 End chk_non_updateable_args;
266 --
267 -- ----------------------------------------------------------------------------
268 -- |--------------------------< dt_update_validate >--------------------------|
269 -- ----------------------------------------------------------------------------
270 -- {Start Of Comments}
271 --
272 -- Description:
273 --   This procedure is used for referential integrity of datetracked
274 --   parent entities when a datetrack update operation is taking place
275 --   and where there is no cascading of update defined for this entity.
276 --
277 -- Prerequisites:
278 --   This procedure is called from the update_validate.
279 --
280 -- In Parameters:
281 --
282 -- Post Success:
283 --   Processing continues.
284 --
285 -- Post Failure:
286 --
287 -- Developer Implementation Notes:
288 --   This procedure should not need maintenance unless the HR Schema model
289 --   changes.
290 --
291 -- Access Status:
292 --   Internal Row Handler Use Only.
293 --
294 -- {End Of Comments}
295 -- ----------------------------------------------------------------------------
296 Procedure dt_update_validate
297   (p_datetrack_mode                in varchar2
298   ,p_validation_start_date         in date
299   ,p_validation_end_date           in date
300   ) Is
301 --
302   l_proc  varchar2(72) := g_package||'dt_update_validate';
303 --
304 Begin
305   --
306   -- Ensure that the p_datetrack_mode argument is not null
307   --
308   hr_api.mandatory_arg_error
309     (p_api_name       => l_proc
310     ,p_argument       => 'datetrack_mode'
311     ,p_argument_value => p_datetrack_mode
312     );
313   --
314   -- Mode will be valid, as this is checked at the start of the upd.
315   --
316   -- Ensure the arguments are not null
317   --
318   hr_api.mandatory_arg_error
319     (p_api_name       => l_proc
320     ,p_argument       => 'validation_start_date'
321     ,p_argument_value => p_validation_start_date
322     );
323   --
324   hr_api.mandatory_arg_error
325     (p_api_name       => l_proc
326     ,p_argument       => 'validation_end_date'
327     ,p_argument_value => p_validation_end_date
328     );
329   --
330     --
331   --
332 Exception
333   When Others Then
334     --
335     -- An unhandled or unexpected error has occurred which
336     -- we must report
337     --
338     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
339     fnd_message.set_token('PROCEDURE', l_proc);
340     fnd_message.set_token('STEP','15');
341     fnd_message.raise_error;
342 End dt_update_validate;
343 --
344 -- ----------------------------------------------------------------------------
345 -- |--------------------------< dt_delete_validate >--------------------------|
346 -- ----------------------------------------------------------------------------
347 -- {Start Of Comments}
348 --
349 -- Description:
350 --   This procedure is used for referential integrity of datetracked
351 --   child entities when either a datetrack DELETE or ZAP is in operation
352 --   and where there is no cascading of delete defined for this entity.
353 --   For the datetrack mode of DELETE or ZAP we must ensure that no
354 --   datetracked child rows exist between the validation start and end
355 --   dates.
356 --
357 -- Prerequisites:
358 --   This procedure is called from the delete_validate.
359 --
360 -- In Parameters:
361 --
362 -- Post Success:
363 --   Processing continues.
364 --
365 -- Post Failure:
366 --   If a row exists by determining the returning Boolean value from the
367 --   generic dt_api.rows_exist function then we must supply an error via
368 --   the use of the local exception handler l_rows_exist.
369 --
370 -- Developer Implementation Notes:
371 --   This procedure should not need maintenance unless the HR Schema model
372 --   changes.
373 --
374 -- Access Status:
375 --   Internal Row Handler Use Only.
376 --
377 -- {End Of Comments}
378 -- ----------------------------------------------------------------------------
379 Procedure dt_delete_validate
380   (p_formula_result_rule_id           in number
381   ,p_datetrack_mode                   in varchar2
382   ,p_validation_start_date            in date
383   ,p_validation_end_date              in date
384   ) Is
385 --
386   l_proc        varchar2(72)    := g_package||'dt_delete_validate';
387 --
388 Begin
389   --
390   -- Ensure that the p_datetrack_mode argument is not null
391   --
392   hr_api.mandatory_arg_error
393     (p_api_name       => l_proc
394     ,p_argument       => 'datetrack_mode'
395     ,p_argument_value => p_datetrack_mode
396     );
397   --
398   -- Only perform the validation if the datetrack mode is either
399   -- DELETE or ZAP
400   --
401   If (p_datetrack_mode = hr_api.g_delete or
402       p_datetrack_mode = hr_api.g_zap) then
403     --
404     --
405     -- Ensure the arguments are not null
406     --
407     hr_api.mandatory_arg_error
408       (p_api_name       => l_proc
409       ,p_argument       => 'validation_start_date'
410       ,p_argument_value => p_validation_start_date
411       );
412     --
413     hr_api.mandatory_arg_error
414       (p_api_name       => l_proc
415       ,p_argument       => 'validation_end_date'
416       ,p_argument_value => p_validation_end_date
417       );
418     --
419     hr_api.mandatory_arg_error
420       (p_api_name       => l_proc
421       ,p_argument       => 'formula_result_rule_id'
422       ,p_argument_value => p_formula_result_rule_id
423       );
424     --
425   --
426     --
427   End If;
428   --
429 Exception
430   When Others Then
431     --
432     -- An unhandled or unexpected error has occurred which
433     -- we must report
434     --
435     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
436     fnd_message.set_token('PROCEDURE', l_proc);
437     fnd_message.set_token('STEP','15');
438     fnd_message.raise_error;
439   --
440 End dt_delete_validate;
441 --
442 -- ----------------------------------------------------------------------------
443 -- |------------------------< chk_legislation_code >--------------------------|
444 -- ----------------------------------------------------------------------------
445 --
446 -- Description:
447 --   This procedure is used to validate the legislation code against the
448 --   parent table
449 --
450 -- ----------------------------------------------------------------------------
451 Procedure chk_legislation_code
452   (p_legislation_code  in varchar2)
453   is
454 --
455   l_proc        varchar2(72) := g_package||'chk_legislation_code';
456 
457   Cursor c_chk_leg_code
458   is
459     select null
460       from fnd_territories
461      where territory_code = p_legislation_code;
462 --
463 Begin
464   hr_utility.set_location('Entering:'||l_proc, 5);
465   --
466   If p_legislation_code is not null then
467 
468     Open c_chk_leg_code;
469     Fetch c_chk_leg_code into g_exists;
470     If c_chk_leg_code%notfound Then
471       --
472       Close c_chk_leg_code;
473       fnd_message.set_name('PAY','PAY_33085_INVALID_FK');
474       fnd_message.set_token('COLUMN','LEGISLATION_CODE');
475       fnd_message.set_token('TABLE','FND_TERRITORIES');
476       fnd_message.raise_error;
477       --
478     End If;
479     Close c_chk_leg_code;
480 
481   End If;
482   --
483   hr_utility.set_location('Leaving:'||l_proc, 10);
484 End;
485 --
486 -- ----------------------------------------------------------------------------
487 -- |------------------------< chk_element_type_id >---------------------------|
488 -- ----------------------------------------------------------------------------
489 --
490 -- Description:
491 --   This procedure is used to validate the element type id against the
492 --   parent table and to check whether the business group and legislation code
493 --   are consistent with those of the element type.
494 --
495 -- ----------------------------------------------------------------------------
496 Procedure chk_element_type_id
497   (p_effective_date    in date
498   ,p_element_type_id   in number
499   ,p_business_group_id in number
500   ,p_legislation_code  in varchar2
501   ) is
502 --
503   l_proc        varchar2(72) := g_package||'chk_element_type_id';
504 
505   Cursor c_chk_element_type
506   is
507     select null
508       from pay_element_types_f pet
509      where pet.element_type_id = p_element_type_id
510        and p_effective_date between pet.effective_start_date
511        and pet.effective_end_date
512        and ((p_business_group_id is not null and
513             ((pet.business_group_id = p_business_group_id)
514              or
515              (pet.legislation_code =
516               hr_api.return_legislation_code(p_business_group_id))
517             ))
518            --
519            or
520             (p_legislation_code is not null
521              and pet.legislation_code = p_legislation_code
522             ));
523 --
524 Begin
525   hr_utility.set_location('Entering:'||l_proc, 5);
526   --
527   open c_chk_element_type;
528   fetch c_chk_element_type into g_exists;
529   if c_chk_element_type%notfound then
530     close c_chk_element_type;
531     fnd_message.set_name('PAY','PAY_34171_FRR_INVALID_FK');
532     fnd_message.set_token('1','element type');
533     fnd_message.raise_error;
534   end if;
535   close c_chk_element_type;
536   --
537   hr_utility.set_location('Leaving:'||l_proc, 10);
538 End;
539 --
540 -- ----------------------------------------------------------------------------
541 -- |--------------------< chk_status_processing_rule_id >---------------------|
542 -- ----------------------------------------------------------------------------
543 --
544 -- Description:
545 --   This procedure is used to validate the status_processing_rule_id against
546 --   the parent table and to check whether the business group and legislation
547 --   code are consistent with those of the SPR.
548 --
549 -- ----------------------------------------------------------------------------
550 Procedure chk_status_processing_rule_id
551   (p_effective_date            in date
552   ,p_status_processing_rule_id in number
553   ,p_business_group_id         in number
554   ,p_legislation_code          in varchar2
555   ) is
556 --
557   l_proc        varchar2(72) := g_package||'chk_spr_id';
558 
559   Cursor c_chk_spr
560   is
561     select null
562       from pay_status_processing_rules_f spr
563      where spr.status_processing_rule_id = p_status_processing_rule_id
564        and p_effective_date between spr.effective_start_date
565        and spr.effective_end_date
566        and ((p_business_group_id is not null and
567              ((spr.business_group_id = p_business_group_id)
568              or
569              (spr.legislation_code =
570               hr_api.return_legislation_code(p_business_group_id))
571              ))
572            --
573            or
574            (p_legislation_code is not null and
575              (spr.legislation_code = p_legislation_code)
576            ));
577 --
578 Begin
579   hr_utility.set_location('Entering:'||l_proc, 5);
580   --
581   open c_chk_spr;
582   fetch c_chk_spr into g_exists;
583   if c_chk_spr%notfound then
584     close c_chk_spr;
585     fnd_message.set_name('PAY','PAY_34171_FRR_INVALID_FK');
586     fnd_message.set_token('1','status processing rule');
587     fnd_message.raise_error;
588   end if;
589   close c_chk_spr;
590   --
591   hr_utility.set_location('Leaving:'||l_proc, 10);
592 End;
593 --
594 -- ----------------------------------------------------------------------------
595 -- |---------------------------< chk_result_name >----------------------------|
596 -- ----------------------------------------------------------------------------
597 --
598 -- Description:
599 --   This procedure is used to check whether the result name is same as the
600 --   item name in formula dictionary and the item is either output or both
601 --   (input and output).
602 --
603 -- ----------------------------------------------------------------------------
604 Procedure chk_result_name
605   (p_effective_date            in date
606   ,p_status_processing_rule_id in number
607   ,p_result_name               in varchar2
608   ) is
609 --
610   l_proc        varchar2(72) := g_package||'chk_result_name';
611   --
612   Cursor c_chk_result_name
613   is
614     select null
615       from ff_fdi_usages_f fdu
616           ,pay_status_processing_rules_f spr
617      where spr.status_processing_rule_id = p_status_processing_rule_id
618        and fdu.formula_id = spr.formula_id
619        and fdu.usage in ('O', 'B')
620        and fdu.item_name = p_result_name
621        and p_effective_date between spr.effective_start_date
622        and spr.effective_end_date
623        and p_effective_date between fdu.effective_start_date
624        and fdu.effective_end_date;
625 --
626 Begin
627   hr_utility.set_location('Entering:'||l_proc, 5);
628   --
629   open c_chk_result_name;
630   fetch c_chk_result_name into g_exists;
631   if c_chk_result_name%notfound then
632     close c_chk_result_name;
633     fnd_message.set_name('PAY','PAY_34156_FRR_NAME_INVALID');
634     fnd_message.raise_error;
635   end if;
636   close c_chk_result_name;
637   --
638   hr_utility.set_location('Leaving:'||l_proc, 10);
639 End;
640 --
641 --
642 -- ----------------------------------------------------------------------------
643 -- |-------------------------< chk_common_rules >-----------------------------|
644 -- ----------------------------------------------------------------------------
645 --
646 -- Description:
647 --   This procedure is used to check the dependent attributes of different
648 --   result rule types.
649 --
650 -- ----------------------------------------------------------------------------
651 Procedure chk_common_rules
652   (p_element_type_id           in number     default null
653   ,p_result_rule_type          in varchar2
654   ,p_severity_level            in varchar2   default null
655   ,p_input_value_id            in number     default null
656   ) is
657 --
658   l_proc             varchar2(72) := g_package||'chk_common_rules';
659 --
660 Begin
661   hr_utility.set_location('Entering:'||l_proc, 5);
662   --
663   If p_result_rule_type <> 'M' then -- message
664       --
665       -- severity must be entered
666       --
667       If p_severity_level is not null then
668         --
669         fnd_message.set_name('PAY','PAY_34168_FRR_NO_SEVERITY');
670         fnd_message.raise_error;
671         --
672       End If;
673       --
674       If p_result_rule_type in ('I','O','U','S') then -- others
675         --
676         -- element type must be entered
677         --
678         If p_element_type_id is null then
679           --
680           fnd_message.set_name('PAY','PAY_34158_FRR_ELEMENT_REQD');
681           fnd_message.raise_error;
682           --
683         End If;
684         --
685         If p_result_rule_type in ('I','U') then
686           --
687           -- input value must be entered for indirect and update recurring
688           -- rules.
689           --
690           If p_input_value_id is null then
691             --
695           End If;
692             fnd_message.set_name('PAY','PAY_34159_FRR_INPUT_VALUE_REQD');
693             fnd_message.raise_error;
694             --
696           --
697         Else
698           --
699           -- input value must be null for other rules.
700           --
701           If p_input_value_id is not null then
702             --
703             fnd_message.set_name('PAY','PAY_34169_FRR_NO_INPUT_VALUE');
704             fnd_message.raise_error;
705             --
706           End If;
707           --
708         End If;
709         --
710       Elsif p_result_rule_type = 'D' then
711         --
712         -- input value must be entered for direct rule
713         --
714         If p_input_value_id is null then
715           --
716           fnd_message.set_name('PAY','PAY_34159_FRR_INPUT_VALUE_REQD');
717           fnd_message.raise_error;
718           --
719         End If;
720         --
721       End If;
722       --
723   End If;
724   --
725   hr_utility.set_location('Leaving:'||l_proc, 10);
726 End;
727 --
728 -- ----------------------------------------------------------------------------
729 -- |-------------------------< chk_result_rule_type >-------------------------|
730 -- ----------------------------------------------------------------------------
731 --
732 -- Description:
733 --   This procedure is used to validate the result rule type against the
734 --   business rules.
735 -- ----------------------------------------------------------------------------
736 Procedure chk_result_rule_type
737   (p_effective_date            in date
738   ,p_element_type_id           in number
739   ,p_status_processing_rule_id in number
740   ,p_result_name               in varchar2
741   ,p_result_rule_type          in varchar2
742   ,p_severity_level            in varchar2
743   ,p_input_value_id            in number
744   ) is
745   --
746   l_proc             varchar2(72) := g_package||'chk_result_rule_type';
747   l_spr_element_id   pay_element_types_f.element_type_id%type;
748   --
749   Cursor c_element_dets(p_element_type_id number)
750   is
751     select pet.processing_type
752           ,pet.third_party_pay_only_flag
753           ,pet.processing_priority
754           ,pet.multiple_entries_allowed_flag
755       from pay_element_types_f pet
756      where pet.element_type_id = p_element_type_id
757        and p_effective_date between pet.effective_start_date
758        and pet.effective_end_date;
759   --
760   Cursor c_spr_element
761   is
762     select spr.element_type_id
763       from pay_status_processing_rules_f spr
764      where spr.status_processing_rule_id = p_status_processing_rule_id
765        and p_effective_date between spr.effective_start_date
766        and spr.effective_end_date;
767  --
768  l_element_dets     c_element_dets%rowtype;
769  l_spr_element_dets c_element_dets%rowtype;
770  --
771 
772 Begin
773   hr_utility.set_location('Entering:'||l_proc, 5);
774   --
775   If hr_api.not_exists_in_hr_lookups
776     (p_effective_date
777     ,'RESULT_RULE_TYPE'
778     ,p_result_rule_type) Then
779     --
780     fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
781     fnd_message.set_token('COLUMN','RESULT_RULE_TYPE');
782     fnd_message.set_token('LOOKUP_TYPE','RESULT_RULE_TYPE');
783     fnd_message.raise_error;
784     --
785   End If;
786   --
787   If p_element_type_id is not null then
788     Open c_element_dets (p_element_type_id);
789     Fetch c_element_dets into l_element_dets;
790     Close c_element_dets;
791   End If;
792   --
793   Open c_spr_element;
794   Fetch c_spr_element into l_spr_element_id;
795   Close c_spr_element;
796   --
797   Open c_element_dets (l_spr_element_id);
798   Fetch c_element_dets into l_spr_element_dets;
799   Close c_element_dets;
800   --
801   chk_common_rules
802     (p_element_type_id
803     ,p_result_rule_type
804     ,p_severity_level
805     ,p_input_value_id);
806   --
807   If p_result_rule_type in ('I','O') then -- indirect or order indirect
808       --
809       -- the priority of the non-recurring element providing the input
810       -- value must be same as or lower (ie. same or higher number) than
811       -- that of the element for which this is the formula result rule
812       -- for the lifetime of the formula result rule.
813       --
814       If (l_spr_element_dets.processing_priority
815           > l_element_dets.processing_priority) then
816         --
817         fnd_message.set_name('PAY','PAY_34163_FRR_PRIORITY');
818         fnd_message.raise_error;
819         --
820       End If;
821       --
822       -- the element must be non-recurring and non-third party.
823       --
824       If (l_element_dets.processing_type <> 'N')
825       or (nvl(l_element_dets.third_party_pay_only_flag,'N') <> 'N') then
826         --
827         fnd_message.set_name('PAY','PAY_34160_FRR_INDIRECT_RULE');
828         fnd_message.raise_error;
829         --
830       End If;
831       --
832   Elsif p_result_rule_type in ('U','S') then -- update recurring or stop entry
833       --
834       -- the element must be recurring
835       --
836       If l_element_dets.processing_type <> 'R' then
837         --
838         fnd_message.set_name('PAY','PAY_34161_FRR_RECURRING');
839         fnd_message.raise_error;
840         --
841       End If;
842       --
843       -- if the element allows multiple entries then it
844       -- can only be the target of such a rule if it is also the source.
845       --
846       If (l_element_dets.multiple_entries_allowed_flag = 'Y'
850         fnd_message.raise_error;
847          and l_spr_element_id <> p_element_type_id) then
848         --
849         fnd_message.set_name('PAY','PAY_34164_FRR_NO_MULTI_ENTRIES');
851         --
852       End If;
853       --
854   Elsif p_result_rule_type = 'M' then -- message
855       --
856       -- severity must be entered
857       --
858       If p_severity_level is null then
859         --
860         fnd_message.set_name('PAY','PAY_34167_FRR_SEVERITY_REQD');
861         fnd_message.raise_error;
862         --
863       End If;
864       --
865       -- no element or input value can be entered
866       --
867       If (p_element_type_id is not null
868          or p_input_value_id is not null) then
869         --
870         fnd_message.set_name('PAY','PAY_34157_FRR_MSG_NO_ELEMENT');
871         fnd_message.raise_error;
872         --
873       End If;
874       --
875   End If;
876   --
877   hr_utility.set_location('Leaving:'||l_proc, 10);
878 End;
879 --
880 -- ----------------------------------------------------------------------------
881 -- |-------------------------< chk_severity_level >---------------------------|
882 -- ----------------------------------------------------------------------------
883 --
884 -- Description:
885 --   This procedure is used to validate the severity level against the
886 --   lookup 'FORMULA_RESULT_MESSAGE_LEVEL'.
887 --
888 -- ----------------------------------------------------------------------------
889 Procedure chk_severity_level
890   (p_effective_date  in date
891   ,p_severity_level  in varchar2
892   ) is
893   --
894   l_proc        varchar2(72) := g_package||'chk_severity_level';
895   --
896 Begin
897   hr_utility.set_location('Entering:'||l_proc, 5);
898   --
899   If hr_api.not_exists_in_hr_lookups
900       (p_effective_date
901       ,'FORMULA_RESULT_MESSAGE_LEVEL'
902       ,p_severity_level) Then
903       --
904       fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
905       fnd_message.set_token('COLUMN','SEVERITY_LEVEL');
906       fnd_message.set_token('LOOKUP_TYPE','FORMULA_RESULT_MESSAGE_LEVEL');
907       fnd_message.raise_error;
908       --
909   End If;
910   --
911   hr_utility.set_location('Leaving:'||l_proc, 10);
912 End;
913 --
914 -- ----------------------------------------------------------------------------
915 -- |-------------------------< chk_input_value_id >---------------------------|
916 -- ----------------------------------------------------------------------------
917 --
918 -- Description:
919 --   This procedure is used to check whether the UOM of the input value matches
920 --   the datatype of the formula result.
921 -- ----------------------------------------------------------------------------
922 Procedure chk_input_value_id
923   (p_effective_date            in date
924   ,p_element_type_id           in number
925   ,p_status_processing_rule_id in number
926   ,p_result_name               in varchar2
927   ,p_result_rule_type          in varchar2
928   ,p_input_value_id            in number
929   ) is
930   --
931   l_proc        varchar2(72) := g_package||'chk_input_value_id';
932   l_uom         pay_input_values_f.uom%type;
933   l_op_datatype ff_fdi_usages_f.data_type%type;
934   --
935   Cursor c_chk_input_value is
936     select uom
937       from pay_input_values_f piv
938      where piv.input_value_id = p_input_value_id
939        and piv.element_type_id = p_element_type_id
940        and p_effective_date between piv.effective_start_date
941        and piv.effective_end_date;
942   --
943   Cursor c_result_dtype is
944     select fdu.data_type
945       from ff_fdi_usages_f fdu
946           ,pay_status_processing_rules_f spr
947      where spr.status_processing_rule_id = p_status_processing_rule_id
948        and fdu.formula_id = spr.formula_id
949        and fdu.usage in ('O', 'B')
950        and fdu.item_name = p_result_name
951        and p_effective_date between spr.effective_start_date
952        and spr.effective_end_date
953        and p_effective_date between fdu.effective_start_date
954        and fdu.effective_end_date;
955 --
956 Begin
957   hr_utility.set_location('Entering:'||l_proc, 5);
958   --
959   Open c_result_dtype;
960   Fetch c_result_dtype into l_op_datatype;
961   Close c_result_dtype;
962   --
963   If p_input_value_id is not null then
964     --
965     Open c_chk_input_value;
966     Fetch c_chk_input_value into l_uom;
967     If c_chk_input_value%notfound then
968       Close c_chk_input_value;
969       fnd_message.set_name('PAY','PAY_33085_INVALID_FK');
970       fnd_message.set_token('COLUMN','INPUT_VALUE_ID');
971       fnd_message.set_token('TABLE','PAY_INPUT_VALUES_F');
972       fnd_message.raise_error;
973     End If;
974     Close c_chk_input_value;
975     --
976     If l_op_datatype = 'D' then -- date
977       If substr(l_uom,1,1) <> 'D' then
978         fnd_message.set_name('PAY','PAY_34162_FRR_INVALID_UOM');
979         fnd_message.raise_error;
980       End If;
981     --
982     Elsif l_op_datatype = 'T' then -- text
983       If l_uom <> 'C' then
984         fnd_message.set_name('PAY','PAY_34162_FRR_INVALID_UOM');
985         fnd_message.raise_error;
986       End If;
987     --
988     Elsif l_op_datatype = 'N' then -- numeric
989       If (substr(l_uom,1,1) not in ('H','I','M','N')) then
990         fnd_message.set_name('PAY','PAY_34162_FRR_INVALID_UOM');
991         fnd_message.raise_error;
992       End If;
993     --
994     End If;
995     --
996   End If;
997   --
998   If (p_result_rule_type = 'O' and l_op_datatype <> 'N') then
1002     fnd_message.set_token('TYPE','Numeric');
999     --
1000     fnd_message.set_name('PAY','PAY_34170_FRR_DATATYP_MISMATCH');
1001     fnd_message.set_token('RULE','Order Indirect');
1003     fnd_message.raise_error;
1004     --
1005   Elsif (p_result_rule_type = 'M' and l_op_datatype <> 'T') then
1006     --
1007     fnd_message.set_name('PAY','PAY_34170_FRR_DATATYP_MISMATCH');
1008     fnd_message.set_token('RULE','Message');
1009     fnd_message.set_token('TYPE','Text');
1010     fnd_message.raise_error;
1011     --
1012   End If;
1013   --
1014   hr_utility.set_location('Leaving:'||l_proc, 10);
1015 End;
1016 --
1017 -- ----------------------------------------------------------------------------
1018 -- |-------------------------< chk_unique_rules >-----------------------------|
1019 -- ----------------------------------------------------------------------------
1020 --
1021 -- Description:
1022 --   This procedure is used to check whether the formula result rule being
1023 --   created is a duplicate rule.
1024 -- ----------------------------------------------------------------------------
1025 Procedure chk_unique_rules
1026   (p_effective_date            in date
1027   ,p_status_processing_rule_id in number
1028   ,p_result_rule_type          in varchar2
1029   ,p_result_name               in varchar2
1030   ,p_element_type_id           in number
1031   ,p_input_value_id            in number
1032   ,p_formula_result_rule_id    in number default null
1033   ) is
1034   --
1035   l_proc        varchar2(72) := g_package||'chk_unique_rules';
1036   --
1037   function message_rule_not_unique
1038     --
1039     -- Returns TRUE if the tested message rule already exists
1040     -- Only one message rule is allowed for each SPR/result name combination
1041     return boolean is
1042     --
1043     v_duplicate_found       boolean := FALSE;
1044     --
1045     cursor c_duplicate_rule
1046     is
1047       select '1'
1048         from pay_formula_result_rules_f
1049        where status_processing_rule_id = p_status_processing_rule_id
1050          and result_rule_type          = 'M'
1051          and result_name               = p_result_name
1052          and p_effective_date between effective_start_date
1053          and effective_end_date
1054          and formula_result_rule_id <> nvl(p_formula_result_rule_id,-1);
1055   --
1056   begin
1057       --
1058       hr_utility.set_location('Entering:'||l_proc, 2);
1059       --
1060       open c_duplicate_rule;
1061       fetch c_duplicate_rule into g_exists;
1062       v_duplicate_found := c_duplicate_rule%found;
1063       close c_duplicate_rule;
1064       --
1065       hr_utility.set_location('Leaving:'||l_proc, 3);
1066       --
1067       return v_duplicate_found;
1068       --
1069   end message_rule_not_unique;
1070   --
1071   function recurring_rule_not_unique
1072     -- Returns TRUE if the tested stop-entry/update-recurring rule already
1073     -- exists.
1074     -- Only one stop-entry/update-recurring rule is allowed for each
1075     -- combination of result name, SPR and element type
1076     return boolean is
1077     --
1078     v_duplicate_found       boolean := FALSE;
1079     --
1080     cursor c_duplicate_rule
1081     is
1082       select '1'
1083         from pay_formula_result_rules_f
1084        where status_processing_rule_id = p_status_processing_rule_id
1085          and result_rule_type          in ('S','U')
1086          and result_name               = p_result_name
1087          and element_type_id           = p_element_type_id
1088          and p_effective_date between effective_start_date
1089          and effective_end_date
1090          and formula_result_rule_id <> nvl(p_formula_result_rule_id,-1);
1091   --
1092   begin
1093       --
1094       hr_utility.set_location('Entering:'||l_proc, 4);
1095       --
1096       open c_duplicate_rule;
1097       fetch c_duplicate_rule into g_exists;
1098       v_duplicate_found := c_duplicate_rule%found;
1099       close c_duplicate_rule;
1100       --
1101       hr_utility.set_location('Leaving:'||l_proc, 5);
1102       --
1103       return v_duplicate_found;
1104       --
1105   end recurring_rule_not_unique;
1106   --
1107   function other_rule_type_not_unique
1108     -- Returns TRUE if any duplicate rule/rule-type/input-value is found
1109     -- Only one indirect or direct is allowed for each
1110     -- combination of SPR, result name and input value
1111     return boolean is
1112     --
1113     v_duplicate_found       boolean := FALSE;
1114     --
1115     cursor c_duplicate_rule
1116     is
1117       select '1'
1118         from pay_formula_result_rules_f
1119        where status_processing_rule_id = p_status_processing_rule_id
1120          and result_rule_type          = p_result_rule_type
1121          and result_name               = p_result_name
1122          and input_value_id            = p_input_value_id
1123          and p_effective_date between effective_start_date
1124          and effective_end_date
1125          and formula_result_rule_id <> nvl(p_formula_result_rule_id,-1);
1126   --
1127   begin
1128       --
1129       hr_utility.set_location('Entering:'||l_proc, 6);
1130       --
1131       open c_duplicate_rule;
1132       fetch c_duplicate_rule into g_exists;
1133       v_duplicate_found := c_duplicate_rule%found;
1134       close c_duplicate_rule;
1135       --
1136       hr_utility.set_location('Leaving:'||l_proc, 7);
1137       --
1138       return v_duplicate_found;
1139       --
1140   end other_rule_type_not_unique;
1141   --
1142   -- Main procedure starts
1143   --
1144 Begin
1145   hr_utility.set_location('Entering:'||l_proc, 1);
1146   --
1147   If (p_result_rule_type = 'M' and message_rule_not_unique)
1151     fnd_message.set_name('PAY','HR_6478_FF_UNI_FRR');
1148     or (p_result_rule_type in ('S','U') and recurring_rule_not_unique)
1149     or (p_result_rule_type in ('I','D') and other_rule_type_not_unique) then
1150     --
1152     fnd_message.raise_error;
1153     --
1154   End If;
1155   --
1156   hr_utility.set_location('Leaving:'||l_proc, 10);
1157 End;
1158 --
1159 -- ----------------------------------------------------------------------------
1160 -- |------------------------< set_effective_end_date >------------------------|
1161 -- ----------------------------------------------------------------------------
1162 --
1163 -- Description:
1164 --   This procedure is used to set the effective end date of the formula result
1165 --   based on the result rule types.
1166 -- ----------------------------------------------------------------------------
1167 Procedure set_effective_end_date
1168   (p_effective_date             in  date
1169   ,p_result_rule_type           in  varchar2
1170   ,p_result_name                in  varchar2
1171   ,p_status_processing_rule_id  in  number
1172   ,p_element_type_id            in  number
1173   ,p_input_value_id             in  number
1174   ,p_datetrack_mode             in  varchar2 default null
1175   ,p_formula_result_rule_id     in  number   default null
1176   ,p_validation_end_date        in out nocopy date
1177   ) is
1178   --
1179   l_proc                    varchar2(72) := g_package||'set_eff_end_date';
1180   l_future_rule_end_date    date;
1181   l_max_spr_end_date        date;
1182   l_max_end_date_of_element date;
1183   l_max_end_date_of_target  date;
1184   l_spr_formula_id          pay_status_processing_rules_f.formula_id%type;
1185   l_spr_element_type_id     pay_status_processing_rules_f.element_type_id%type;
1186   --
1187   Cursor c_spr_element
1188   is
1189     select spr.formula_id,spr.element_type_id
1190       from pay_status_processing_rules_f spr
1191      where spr.status_processing_rule_id = p_status_processing_rule_id
1192        and p_effective_date between spr.effective_start_date
1193        and spr.effective_end_date;
1194   --
1195 Begin
1196   hr_utility.set_location('Entering:'||l_proc, 5);
1197   --
1198   open c_spr_element;
1199   fetch c_spr_element into l_spr_formula_id, l_spr_element_type_id;
1200   close c_spr_element;
1201   --
1202   -- get the maximum end date of the spr
1203   --
1204   l_max_spr_end_date := pay_status_rules_pkg.spr_end_date
1205                           (p_status_processing_rule_id
1206                           ,l_spr_formula_id);
1207   hr_utility.set_location('l_max_spr_end_date '||to_char(l_max_spr_end_date),6);
1208   --
1209   -- get the maximum end date of the source element type
1210   --
1211   l_max_end_date_of_element := pay_element_types_pkg.element_end_date
1212                                  (l_spr_element_type_id);
1213   hr_utility.set_location('l_max_end_date_of_element '||to_char(l_max_end_date_of_element),7);
1214   --
1215   -- get the maximum end date of the target element type
1216   --
1217   l_max_end_date_of_target := pay_element_types_pkg.element_end_date
1218                                 (p_element_type_id);
1219   hr_utility.set_location('l_max_end_date_of_target '||to_char(l_max_end_date_of_target),8);
1220   --
1221   -- get the maximum end date of a similar rule if it exists in the future.
1222   --
1223   l_future_rule_end_date := pay_formula_result_rules_pkg.result_rule_end_date
1224                               (p_formula_result_rule_id
1225                               ,p_result_rule_type
1226                               ,p_result_name
1227                               ,p_status_processing_rule_id
1228                               ,p_element_type_id
1229                               ,p_input_value_id
1230                               ,p_effective_date
1231                               ,l_max_spr_end_date);
1232   hr_utility.set_location('l_future_rule_end_date '||to_char(l_future_rule_end_date),8);
1233   --
1234   hr_utility.set_location('before set-p_validation_end_date '||to_char(p_validation_end_date),9);
1235   --
1236   if (p_result_rule_type in ('I','U','S'))
1237   or (p_datetrack_mode = hr_api.g_delete_next_change) then
1238     p_validation_end_date := least (l_max_end_date_of_element
1239                                    ,l_max_spr_end_date
1240                                    ,l_max_end_date_of_target
1241                                    ,l_future_rule_end_date);
1242   else
1243     p_validation_end_date := least (l_max_end_date_of_element
1244                                    ,l_max_spr_end_date
1245                                    ,l_future_rule_end_date);
1246   end if;
1247   --
1248   hr_utility.set_location('after set-p_validation_end_date '||to_char(p_validation_end_date),10);
1249   --
1250   hr_utility.set_location('Leaving:'||l_proc, 10);
1251 End;
1252 --
1253 -- ----------------------------------------------------------------------------
1254 -- |----------------------< chk_startup_action >------------------------------|
1255 -- ----------------------------------------------------------------------------
1256 --
1257 -- Description:
1258 --  This procedure will check that the current action is allowed according
1259 --  to the current startup mode.
1260 --
1261 -- ----------------------------------------------------------------------------
1262 PROCEDURE chk_startup_action
1263   (p_insert               IN boolean
1264   ,p_business_group_id    IN number
1265   ,p_legislation_code     IN varchar2
1266   ,p_legislation_subgroup IN varchar2 DEFAULT NULL) IS
1267 --
1268 BEGIN
1269   --
1270   -- Call the supporting procedure to check startup mode
1271   --
1272   IF (p_insert) THEN
1273     hr_startup_data_api_support.chk_startup_action
1274       (p_generic_allowed   => FALSE
1275       ,p_startup_allowed   => TRUE
1276       ,p_user_allowed      => TRUE
1280       );
1277       ,p_business_group_id => p_business_group_id
1278       ,p_legislation_code  => p_legislation_code
1279       ,p_legislation_subgroup => p_legislation_subgroup
1281   ELSE
1282     hr_startup_data_api_support.chk_upd_del_startup_action
1283       (p_generic_allowed   => FALSE
1284       ,p_startup_allowed   => TRUE
1285       ,p_user_allowed      => TRUE
1286       ,p_business_group_id => p_business_group_id
1287       ,p_legislation_code  => p_legislation_code
1288       ,p_legislation_subgroup => p_legislation_subgroup
1289       );
1290   END IF;
1291   --
1292 END chk_startup_action;
1293 --
1294 -- ----------------------------------------------------------------------------
1295 -- |---------------------------< insert_validate >----------------------------|
1296 -- ----------------------------------------------------------------------------
1297 Procedure insert_validate
1298   (p_rec                   in pay_frr_shd.g_rec_type
1299   ,p_effective_date        in date
1300   ,p_datetrack_mode        in varchar2
1301   ,p_validation_start_date in date
1302   ,p_validation_end_date   in date
1303   ) is
1304 --
1305   l_proc        varchar2(72) := g_package||'insert_validate';
1306 --
1307 Begin
1308   hr_utility.set_location('Entering:'||l_proc, 5);
1309   --
1310   -- Call all supporting business operations
1311   --
1312   --
1313   chk_startup_action(true
1314                     ,p_rec.business_group_id
1315                     ,p_rec.legislation_code
1316                     );
1317   IF hr_startup_data_api_support.g_startup_mode
1318                      NOT IN ('GENERIC','STARTUP') THEN
1319      --
1320      -- Validate Important Attributes
1321      --
1322      hr_api.validate_bus_grp_id
1323        (p_business_group_id => p_rec.business_group_id
1324        ,p_associated_column1 => pay_frr_shd.g_tab_nam
1325                                 || '.BUSINESS_GROUP_ID');
1326      --
1327      -- after validating the set of important attributes,
1328      -- if Multiple Message Detection is enabled and at least
1329      -- one error has been found then abort further validation.
1330      --
1331      hr_multi_message.end_validation_set;
1332   END IF;
1333   --
1334   --
1335   -- Validate Dependent Attributes
1336   --
1337   --
1338   If p_rec.legislation_code is not null then
1339     chk_legislation_code
1340       (p_legislation_code => p_rec.legislation_code);
1341   End if;
1342   --
1343   If p_rec.element_type_id is not null then
1344     chk_element_type_id
1345       (p_effective_date    => p_effective_date
1346       ,p_element_type_id   => p_rec.element_type_id
1347       ,p_business_group_id => p_rec.business_group_id
1348       ,p_legislation_code  => p_rec.legislation_code
1349       );
1350   End if;
1351   --
1352   chk_status_processing_rule_id
1353     (p_effective_date            => p_effective_date
1354     ,p_status_processing_rule_id => p_rec.status_processing_rule_id
1355     ,p_business_group_id         => p_rec.business_group_id
1356     ,p_legislation_code          => p_rec.legislation_code
1357     );
1358   --
1359   chk_result_name
1360     (p_effective_date            => p_effective_date
1361     ,p_status_processing_rule_id => p_rec.status_processing_rule_id
1362     ,p_result_name               => p_rec.result_name
1363     );
1364   --
1365   chk_result_rule_type
1366     (p_effective_date            => p_effective_date
1367     ,p_element_type_id           => p_rec.element_type_id
1368     ,p_status_processing_rule_id => p_rec.status_processing_rule_id
1369     ,p_result_name               => p_rec.result_name
1370     ,p_result_rule_type          => p_rec.result_rule_type
1371     ,p_severity_level            => p_rec.severity_level
1372     ,p_input_value_id            => p_rec.input_value_id
1373     );
1374   --
1375   If p_rec.severity_level is not null then
1376     chk_severity_level
1377       (p_effective_date => p_effective_date
1378       ,p_severity_level => p_rec.severity_level
1379       );
1380   End if;
1381   --
1382   chk_input_value_id
1383     (p_effective_date            => p_effective_date
1384     ,p_element_type_id           => p_rec.element_type_id
1385     ,p_status_processing_rule_id => p_rec.status_processing_rule_id
1386     ,p_result_name               => p_rec.result_name
1387     ,p_result_rule_type          => p_rec.result_rule_type
1388     ,p_input_value_id            => p_rec.input_value_id
1389     );
1390   --
1391   chk_unique_rules
1392     (p_effective_date            => p_effective_date
1393     ,p_element_type_id           => p_rec.element_type_id
1394     ,p_status_processing_rule_id => p_rec.status_processing_rule_id
1395     ,p_result_name               => p_rec.result_name
1396     ,p_result_rule_type          => p_rec.result_rule_type
1397     ,p_input_value_id            => p_rec.input_value_id
1398     );
1399   --
1400   --
1401   hr_utility.set_location(' Leaving:'||l_proc, 10);
1402 End insert_validate;
1403 --
1404 -- ----------------------------------------------------------------------------
1405 -- |---------------------------< update_validate >----------------------------|
1406 -- ----------------------------------------------------------------------------
1407 Procedure update_validate
1408   (p_rec                     in pay_frr_shd.g_rec_type
1409   ,p_effective_date          in date
1410   ,p_datetrack_mode          in varchar2
1411   ,p_validation_start_date   in date
1412   ,p_validation_end_date     in date
1413   ) is
1414 --
1415   l_proc        varchar2(72) := g_package||'update_validate';
1416 --
1417 Begin
1418   hr_utility.set_location('Entering:'||l_proc, 5);
1419   --
1420   -- Call all supporting business operations
1421   --
1422   --
1423   chk_startup_action(false
1427   IF hr_startup_data_api_support.g_startup_mode
1424                     ,p_rec.business_group_id
1425                     ,p_rec.legislation_code
1426                     );
1428                      NOT IN ('GENERIC','STARTUP') THEN
1429      --
1430      -- Validate Important Attributes
1431      --
1432      hr_api.validate_bus_grp_id
1433        (p_business_group_id => p_rec.business_group_id
1434        ,p_associated_column1 => pay_frr_shd.g_tab_nam
1435                                 || '.BUSINESS_GROUP_ID');
1436      --
1437      -- After validating the set of important attributes,
1438      -- if Multiple Message Detection is enabled and at least
1439      -- one error has been found then abort further validation.
1440      --
1441      hr_multi_message.end_validation_set;
1442   END IF;
1443   --
1444   -- Validate Dependent Attributes
1445   --
1446   If p_rec.element_type_id is not null then
1447     chk_element_type_id
1448       (p_effective_date    => p_effective_date
1449       ,p_element_type_id   => p_rec.element_type_id
1450       ,p_business_group_id => p_rec.business_group_id
1451       ,p_legislation_code  => p_rec.legislation_code
1452       );
1453   End if;
1454   --
1455   chk_result_rule_type
1456     (p_effective_date            => p_effective_date
1457     ,p_element_type_id           => p_rec.element_type_id
1458     ,p_status_processing_rule_id => p_rec.status_processing_rule_id
1459     ,p_result_name               => p_rec.result_name
1460     ,p_result_rule_type          => p_rec.result_rule_type
1461     ,p_severity_level            => p_rec.severity_level
1462     ,p_input_value_id            => p_rec.input_value_id
1463     );
1464   --
1465   If p_rec.severity_level is not null then
1466     chk_severity_level
1467       (p_effective_date => p_effective_date
1468       ,p_severity_level => p_rec.severity_level
1469       );
1470   End if;
1471   --
1472   chk_input_value_id
1473     (p_effective_date            => p_effective_date
1474     ,p_element_type_id           => p_rec.element_type_id
1475     ,p_status_processing_rule_id => p_rec.status_processing_rule_id
1476     ,p_result_name               => p_rec.result_name
1477     ,p_result_rule_type          => p_rec.result_rule_type
1478     ,p_input_value_id            => p_rec.input_value_id
1479     );
1480   --
1481   chk_unique_rules
1482     (p_effective_date            => p_effective_date
1483     ,p_element_type_id           => p_rec.element_type_id
1484     ,p_status_processing_rule_id => p_rec.status_processing_rule_id
1485     ,p_result_name               => p_rec.result_name
1486     ,p_result_rule_type          => p_rec.result_rule_type
1487     ,p_input_value_id            => p_rec.input_value_id
1488     ,p_formula_result_rule_id    => p_rec.formula_result_rule_id
1489     );
1490   --
1491   -- Call the datetrack update integrity operation
1492   --
1493   dt_update_validate
1494     (p_datetrack_mode                 => p_datetrack_mode
1495     ,p_validation_start_date          => p_validation_start_date
1496     ,p_validation_end_date            => p_validation_end_date
1497     );
1498   --
1499   chk_non_updateable_args
1500     (p_effective_date  => p_effective_date
1501     ,p_rec             => p_rec
1502     );
1503   --
1504   --
1505   hr_utility.set_location(' Leaving:'||l_proc, 10);
1506 End update_validate;
1507 --
1508 -- ----------------------------------------------------------------------------
1509 -- |---------------------------< delete_validate >----------------------------|
1510 -- ----------------------------------------------------------------------------
1511 Procedure delete_validate
1512   (p_rec                    in pay_frr_shd.g_rec_type
1513   ,p_effective_date         in date
1514   ,p_datetrack_mode         in varchar2
1515   ,p_validation_start_date  in date
1516   ,p_validation_end_date    in date
1517   ) is
1518 --
1519   l_proc        varchar2(72) := g_package||'delete_validate';
1520 --
1521 Begin
1522   hr_utility.set_location('Entering:'||l_proc, 5);
1523   --
1524     --
1525   chk_startup_action(false
1526                     ,pay_frr_shd.g_old_rec.business_group_id
1527                     ,pay_frr_shd.g_old_rec.legislation_code
1528                     );
1529   IF hr_startup_data_api_support.g_startup_mode
1530                      NOT IN ('GENERIC','STARTUP') THEN
1531      --
1532      -- Validate Important Attributes
1533      --
1534      --
1535      -- After validating the set of important attributes,
1536      -- if Multiple Message Detection is enabled and at least
1537      -- one error has been found then abort further validation.
1538      --
1539      hr_multi_message.end_validation_set;
1540   END IF;
1541   --
1542   -- Call all supporting business operations
1543   --
1544   dt_delete_validate
1545     (p_datetrack_mode                   => p_datetrack_mode
1546     ,p_validation_start_date            => p_validation_start_date
1547     ,p_validation_end_date              => p_validation_end_date
1548     ,p_formula_result_rule_id           => p_rec.formula_result_rule_id
1549     );
1550   --
1551   hr_utility.set_location(' Leaving:'||l_proc, 10);
1552 End delete_validate;
1553 --
1554 end pay_frr_bus;