DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_RCU_BUS

Source


1 Package Body pay_rcu_bus as
2 /* $Header: pyrcurhi.pkb 120.1 2005/06/20 05:01:52 tvankayl noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_rcu_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_retro_component_usage_id    number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_retro_component_usage_id             in number
22   ,p_associated_column1                   in varchar2 default null
23   ) is
24   --
25   -- Declare cursor
26   --
27   cursor csr_sec_grp is
28     select pbg.security_group_id,
29            pbg.legislation_code
30       from per_business_groups_perf pbg
31          , pay_retro_component_usages rcu
32      where rcu.retro_component_usage_id = p_retro_component_usage_id
33        and pbg.business_group_id (+) = rcu.business_group_id;
34   --
35   -- Declare local variables
36   --
37   l_security_group_id number;
38   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
39   l_legislation_code  varchar2(150);
40   --
41 begin
42   --
43   hr_utility.set_location('Entering:'|| l_proc, 10);
44   --
45   -- Ensure that all the mandatory parameter are not null
46   --
47   hr_api.mandatory_arg_error
48     (p_api_name           => l_proc
49     ,p_argument           => 'retro_component_usage_id'
50     ,p_argument_value     => p_retro_component_usage_id
51     );
52   --
53   open csr_sec_grp;
54   fetch csr_sec_grp into l_security_group_id
55                        , l_legislation_code;
56   --
57   if csr_sec_grp%notfound then
58      --
59      close csr_sec_grp;
60      --
61      -- The primary key is invalid therefore we must error
62      --
63      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
64      hr_multi_message.add
65        (p_associated_column1
66         => nvl(p_associated_column1,'RETRO_COMPONENT_USAGE_ID')
67        );
68      --
69   else
70     close csr_sec_grp;
71     --
72     -- Set the security_group_id in CLIENT_INFO
73     --
74     hr_api.set_security_group_id
75       (p_security_group_id => l_security_group_id
76       );
77     --
78     -- Set the sessions legislation context in HR_SESSION_DATA
79     --
80     hr_api.set_legislation_context(l_legislation_code);
81   end if;
82   --
83   hr_utility.set_location(' Leaving:'|| l_proc, 20);
84   --
85 end set_security_group_id;
86 --
87 --  ---------------------------------------------------------------------------
88 --  |---------------------< return_legislation_code >-------------------------|
89 --  ---------------------------------------------------------------------------
90 --
91 Function return_legislation_code
92   (p_retro_component_usage_id             in     number
93   )
94   Return Varchar2 Is
95   --
96   -- Declare cursor
97   --
98   cursor csr_leg_code is
99     select pbg.legislation_code
100       from per_business_groups_perf pbg
101          , pay_retro_component_usages rcu
102      where rcu.retro_component_usage_id = p_retro_component_usage_id
103        and pbg.business_group_id (+) = rcu.business_group_id;
104   --
105   -- Declare local variables
106   --
107   l_legislation_code  varchar2(150);
108   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
109   --
110 Begin
111   --
112   hr_utility.set_location('Entering:'|| l_proc, 10);
113   --
114   -- Ensure that all the mandatory parameter are not null
115   --
116   hr_api.mandatory_arg_error
117     (p_api_name           => l_proc
118     ,p_argument           => 'retro_component_usage_id'
119     ,p_argument_value     => p_retro_component_usage_id
120     );
121   --
122   if ( nvl(pay_rcu_bus.g_retro_component_usage_id, hr_api.g_number)
123        = p_retro_component_usage_id) then
124     --
125     -- The legislation code has already been found with a previous
126     -- call to this function. Just return the value in the global
127     -- variable.
128     --
129     l_legislation_code := pay_rcu_bus.g_legislation_code;
130     hr_utility.set_location(l_proc, 20);
131   else
132     --
133     -- The ID is different to the last call to this function
134     -- or this is the first call to this function.
135     --
136     open csr_leg_code;
137     fetch csr_leg_code into l_legislation_code;
138     --
139     if csr_leg_code%notfound then
140       --
141       -- The primary key is invalid therefore we must error
142       --
143       close csr_leg_code;
144       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
145       fnd_message.raise_error;
146     end if;
147     hr_utility.set_location(l_proc,30);
148     --
149     -- Set the global variables so the values are
150     -- available for the next call to this function.
151     --
152     close csr_leg_code;
153     pay_rcu_bus.g_retro_component_usage_id    := p_retro_component_usage_id;
154     pay_rcu_bus.g_legislation_code  := l_legislation_code;
155   end if;
156   hr_utility.set_location(' Leaving:'|| l_proc, 40);
157   return l_legislation_code;
158 end return_legislation_code;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |-----------------------< chk_non_updateable_args >------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 --   This procedure is used to ensure that non updateable attributes have
167 --   not been updated. If an attribute has been updated an error is generated.
168 --
169 -- Pre Conditions:
170 --   g_old_rec has been populated with details of the values currently in
171 --   the database.
172 --
173 -- In Arguments:
174 --   p_rec has been populated with the updated values the user would like the
175 --   record set to.
176 --
177 -- Post Success:
178 --   Processing continues if all the non updateable attributes have not
179 --   changed.
180 --
181 -- Post Failure:
182 --   An application error is raised if any of the non updatable attributes
183 --   have been altered.
184 --
185 -- {End Of Comments}
186 -- ----------------------------------------------------------------------------
187 Procedure chk_non_updateable_args
188   (p_effective_date               in date
189   ,p_rec in pay_rcu_shd.g_rec_type
190   ) IS
191 --
192   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
193   l_error    exception;
194   l_argument varchar2(30);
195 --
196 Begin
197   --
198   -- Only proceed with the validation if a row exists for the current
199   -- record in the HR Schema.
200   --
201   IF NOT pay_rcu_shd.api_updating
202       (p_retro_component_usage_id          => p_rec.retro_component_usage_id
203       ,p_object_version_number             => p_rec.object_version_number
204       ) THEN
205      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
206      fnd_message.set_token('PROCEDURE ', l_proc);
207      fnd_message.set_token('STEP ', '5');
208      fnd_message.raise_error;
209   END IF;
210   --
211   hr_utility.set_location(l_proc, 10);
212   --
213   if nvl(p_rec.business_group_id, hr_api.g_number) <>
214      nvl(pay_rcu_shd.g_old_rec.business_group_id, hr_api.g_number) then
215     l_argument := 'business_group_id';
216     raise l_error;
217   end if;
218   hr_utility.set_location(l_proc, 15);
219   --
220   if nvl(p_rec.legislation_code, hr_api.g_varchar2) <>
221      nvl(pay_rcu_shd.g_old_rec.legislation_code, hr_api.g_varchar2) then
222     l_argument := 'legislation_code';
223     raise l_error;
224   end if;
225   hr_utility.set_location(l_proc, 20);
226   --
227   if p_rec.retro_component_id <> pay_rcu_shd.g_old_rec.retro_component_id then
228     l_argument := 'retro_component_id';
229     raise l_error;
230   end if;
231   hr_utility.set_location(l_proc, 25);
232   --
233   if p_rec.creator_type <> pay_rcu_shd.g_old_rec.creator_type then
234     l_argument := 'creator_type';
235     raise l_error;
236   end if;
237   hr_utility.set_location(l_proc, 30);
238   --
239   if p_rec.creator_id <> pay_rcu_shd.g_old_rec.creator_id then
240     l_argument := 'creator_id';
241     raise l_error;
242   end if;
243   hr_utility.set_location(l_proc, 35);
244 
245 exception
246   when l_error then
247     hr_api.argument_changed_error
248       (p_api_name => l_proc
249       ,p_argument => l_argument
250       );
251   when others then
252     raise;
253 
254 End chk_non_updateable_args;
255 --
256 -- ----------------------------------------------------------------------------
257 -- |----------------------< chk_startup_action >------------------------------|
258 -- ----------------------------------------------------------------------------
259 --
260 -- Description:
261 --  This procedure will check that the current action is allowed according
262 --  to the current startup mode.
263 --
264 -- ----------------------------------------------------------------------------
265 PROCEDURE chk_startup_action
266   (p_insert               IN boolean
267   ,p_business_group_id    IN number
268   ,p_legislation_code     IN varchar2
269   ,p_legislation_subgroup IN varchar2 DEFAULT NULL) IS
270 --
271 BEGIN
272   --
273   -- Call the supporting procedure to check startup mode
274   IF (p_insert) THEN
275     hr_startup_data_api_support.chk_startup_action
276       (p_generic_allowed   => TRUE
277       ,p_startup_allowed   => TRUE
278       ,p_user_allowed      => TRUE
279       ,p_business_group_id => p_business_group_id
280       ,p_legislation_code  => p_legislation_code
281       ,p_legislation_subgroup => p_legislation_subgroup
282       );
283   ELSE
284     hr_startup_data_api_support.chk_upd_del_startup_action
285       (p_generic_allowed   => TRUE
286       ,p_startup_allowed   => TRUE
287       ,p_user_allowed      => TRUE
288       ,p_business_group_id => p_business_group_id
289       ,p_legislation_code  => p_legislation_code
290       ,p_legislation_subgroup => p_legislation_subgroup
291       );
292   END IF;
293   --
294 END chk_startup_action;
295 
296 --
297 -- -------------------------------------------------------------------------
298 -- |----------------------< chk_retro_component_id >-----------------------|
299 -- -------------------------------------------------------------------------
300 -- {Start Of Comments}
301 --
302 -- Description:
303 --   Validates that the retro component id exists in pay_retro_components.
304 --
305 -- Prerequisites:
306 --   None.
307 --
308 -- In Parameters:
309 --   p_retro_component_id
310 --   p_business_group_id
311 --   p_legislation_code
312 --
313 --
314 -- Post Success:
315 --   Processing continues if the retro component id is valid.
316 --
317 --
318 -- Post Failure:
319 --   An application error is raised and processing is terminated if the
320 --   retro component id is invalid.
321 --
322 -- Access Status:
323 --   Internal Row Handler Use Only.
324 --
325 -- {End Of Comments}
326 --
327 procedure chk_retro_component_id
328   (p_retro_component_id in pay_retro_component_usages.retro_component_id%type
329   ,p_business_group_id  in pay_retro_component_usages.business_group_id%type
330   ,p_legislation_code   in pay_retro_component_usages.legislation_code%type
331   )
332 is
333   --
334   -- Declare local variables
335   --
336   l_proc             varchar2(72) := g_package||'chk_retro_component_id';
337   l_varchar2         varchar2(30) := hr_api.g_varchar2;
338   l_number           number       := hr_api.g_number;
339   l_exists           varchar2(1);
340   l_legislation_code pay_retro_component_usages.legislation_code%type;
341 
342   --
343   -- Cursor to check that a retro component exists.
344   --
345   cursor csr_retro_component is
346     select null
347       from pay_retro_components
348      where retro_component_id = p_retro_component_id
349        and nvl(legislation_code, nvl(l_legislation_code, l_varchar2))
350              = nvl(l_legislation_code, l_varchar2);
351 
352 --
353 begin
354   hr_utility.set_location('Entering:'|| l_proc, 10);
355   --
356   -- Check mandatory parameters have been set
357   --
358   hr_api.mandatory_arg_error
359     (p_api_name       => l_proc
360     ,p_argument       => 'retro_component_id'
361     ,p_argument_value => p_retro_component_id
362     );
363   --
364   -- Set the legislation code
365   --
366   l_legislation_code
367      := nvl(p_legislation_code
368            ,hr_api.return_legislation_code(p_business_group_id));
369   --
370   -- Check if the retro component exists.
371   --
372   hr_utility.set_location(l_proc, 20);
373   open csr_retro_component;
374   fetch csr_retro_component into l_exists;
375   if csr_retro_component%notfound then
376     close csr_retro_component;
377 
378     fnd_message.set_name('PAY','PAY_33167_RCU_INV_RETRO_COMP');
379     fnd_message.raise_error;
380 
381   end if;
382   close csr_retro_component;
383 
384   hr_utility.set_location(' Leaving:'|| l_proc, 50);
385 end chk_retro_component_id;
386 --
387 -- -------------------------------------------------------------------------
388 -- |-------------------< chk_creator_type_creator_id >---------------------|
389 -- -------------------------------------------------------------------------
390 -- {Start Of Comments}
391 --
392 -- Description:
393 --   Validates the combination of creator type and creator id.
394 --   When creator type is ET, then the creator id should be exist in
395 --   pay_element_types_f.
396 --   When creator type is EC, then the creator id should be exist in
397 --   pay_element_classifications.
398 --
399 -- Prerequisites:
400 --   None.
401 --
402 -- In Parameters:
403 --   p_creator_type
404 --   p_creator_Id
405 --   p_business_group_id
406 --   p_legislation_code
407 --   p_effective_date
408 --
409 --
410 -- Post Success:
411 --   Processing continues if the creator type and creator id are valid.
412 --
413 --
414 -- Post Failure:
415 --   An application error is raised and processing is terminated if the
416 --   creator type or creator id is invalid.
417 --
418 -- Access Status:
419 --   Internal Row Handler Use Only.
420 --
421 -- {End Of Comments}
422 --
426   ,p_business_group_id            in     pay_retro_component_usages.business_group_id%type
423 procedure chk_creator_type_creator_id
424   (p_creator_type                 in     pay_retro_component_usages.creator_type%type
425   ,p_creator_id                   in     pay_retro_component_usages.creator_id%type
427   ,p_legislation_code             in     pay_retro_component_usages.legislation_code%type
428   ,p_effective_date               in     date
429   )
430 is
431   --
432   -- Declare local variables
433   --
434   l_proc           varchar2(72) := g_package||'chk_retro_component_id';
435   l_varchar2       varchar2(30) := hr_api.g_varchar2;
436   l_number         number       := hr_api.g_number;
437   l_exists         varchar2(1);
438   l_legislation_code pay_retro_component_usages.legislation_code%type;
439 
440   --
441   -- Cursor to check that an element type exists.
442   --
443   cursor csr_element_type is
444     select null
445       from pay_element_types_f
446      where element_type_id = p_creator_id
447        and p_effective_date between effective_start_date
448        and effective_end_date
449        and nvl(legislation_code, nvl(l_legislation_code, l_varchar2))
450              = nvl(l_legislation_code, l_varchar2)
451        and nvl(business_group_id, nvl(p_business_group_id, l_number))
452              = nvl(p_business_group_id, l_number);
453 
454   --
455   -- Cursor to check that an element classification exists.
456   --
457   cursor csr_classification is
458     select null
459       from pay_element_classifications
460      where classification_id = p_creator_id
461        and nvl(legislation_code, nvl(l_legislation_code, l_varchar2))
462              = nvl(l_legislation_code, l_varchar2)
463        and nvl(business_group_id, nvl(p_business_group_id, l_number))
464              = nvl(p_business_group_id, l_number);
465 --
466 begin
467   hr_utility.set_location('Entering:'|| l_proc, 10);
468   --
469   -- Check mandatory parameters have been set
470   --
471   hr_api.mandatory_arg_error
472     (p_api_name       => l_proc
473     ,p_argument       => 'creator_type'
474     ,p_argument_value => p_creator_type
475     );
476   hr_api.mandatory_arg_error
477     (p_api_name       => l_proc
478     ,p_argument       => 'creator_id'
479     ,p_argument_value => p_creator_id
480     );
481   hr_api.mandatory_arg_error
482     (p_api_name       => l_proc
483     ,p_argument       => 'effective_date'
484     ,p_argument_value => p_effective_date
485     );
486 
487   --
488   -- Set the legislation code
489   --
490   l_legislation_code
491      := nvl(p_legislation_code
492            ,hr_api.return_legislation_code(p_business_group_id));
493 
494   --
495   -- Check the creator type.
496   --
497   hr_utility.set_location(l_proc, 15);
498   if p_creator_type = 'ET' then
499 
500     --
501     -- Check if the element type exists.
502     --
503     hr_utility.set_location(l_proc, 20);
504     open csr_element_type;
505     fetch csr_element_type into l_exists;
506     if csr_element_type%notfound then
507       close csr_element_type;
508 
509     fnd_message.set_name('PAY','PAY_33168_RCU_INV_CRE_ID');
510     fnd_message.set_token('TABLE','PAY_ELEMENT_TYPES_F');
511     fnd_message.set_token('COLUMN','ELEMENT_TYPE_ID');
512     fnd_message.raise_error;
513 
514     end if;
515     close csr_element_type;
516 
517   elsif p_creator_type = 'EC' then
518 
519     --
520     -- Check if the element classification exists.
521     --
522     hr_utility.set_location(l_proc, 25);
523     open csr_classification;
524     fetch csr_classification into l_exists;
525     if csr_classification%notfound then
526       close csr_classification;
527 
528       fnd_message.set_name('PAY','PAY_33168_RCU_INV_CRE_ID');
529       fnd_message.set_token('TABLE','PAY_ELEMENT_CLASSIFICATIONS');
530       fnd_message.set_token('COLUMN','CLASSIFICATION_ID');
531       fnd_message.raise_error;
532 
533     end if;
534     close csr_classification;
535 
536   else
537 
538     fnd_message.set_name('PAY','PAY_33161_RCU_INV_CRE_TYP');
539     fnd_message.raise_error;
540 
541   end if;
542 
543   hr_utility.set_location(' Leaving:'|| l_proc, 50);
544 end chk_creator_type_creator_id;
545 
546 --
547 -- -------------------------------------------------------------------------
548 -- |------------------------< chk_reprocess_type >-------------------------|
552 -- Description:
549 -- -------------------------------------------------------------------------
550 -- {Start Of Comments}
551 --
553 --   Validates that the reprocess type exists in lookup type
554 --   RETRO_REPROCESS_TYPE.
555 --   In addition if the parent retro component is Full Recalculation style,
556 --   reprocess type must be R (Reprocessed).
557 --
558 -- Prerequisites:
559 --   None.
560 --
561 -- In Parameters:
562 --   p_retro_component_usage_id
563 --   p_object_version_number
564 --   p_retro_component_id
565 --   p_reprocess_type
566 --   p_effective_date
567 --
568 --
569 -- Post Success:
570 --   Processing continues if the reprocess type is valid.
571 --
572 --
573 -- Post Failure:
574 --   An application error is raised and processing is terminated if the
575 --   reprocess type is invalid.
576 --
577 -- Access Status:
578 --   Internal Row Handler Use Only.
579 --
580 -- {End Of Comments}
581 --
582 procedure chk_reprocess_type
583   (p_retro_component_usage_id in pay_retro_component_usages.retro_component_usage_id%type
584   ,p_object_version_number    in pay_retro_component_usages.object_version_number%type
585   ,p_retro_component_id       in pay_retro_component_usages.retro_component_id%type
586   ,p_reprocess_type           in pay_retro_component_usages.reprocess_type%type
587   ,p_effective_date           in date
588   )
589 is
590   --
591   -- Declare local variables
592   --
593   l_proc           varchar2(72) := g_package||'chk_reprocess_type';
594   l_api_updating   boolean;
595   l_retro_type     pay_retro_components.retro_type%type;
596 
597   cursor csr_retro_type
598     is
599     select retro_type
600     from pay_retro_components
601     where retro_component_id = p_retro_component_id;
602 
603 --
604 begin
605   hr_utility.set_location('Entering:'|| l_proc, 10);
606   --
607   -- Check mandatory parameters have been set
608   --
609   hr_api.mandatory_arg_error
610     (p_api_name       => l_proc
611     ,p_argument       => 'reprocess_type'
612     ,p_argument_value => p_reprocess_type
613     );
614   hr_api.mandatory_arg_error
615     (p_api_name       => l_proc
616     ,p_argument       => 'effective_date'
617     ,p_argument_value => p_effective_date
618     );
619 
620   hr_utility.set_location(l_proc, 15);
621   --
622   -- Check if the retro component usage is being updated and ensure that
623   -- g_old_rec contains the values for this retro_component_usage_id.
624   --
625   l_api_updating :=
626     pay_rcu_shd.api_updating
627       (p_retro_component_usage_id => p_retro_component_usage_id
628       ,p_object_version_number    => p_object_version_number);
629 
630   hr_utility.set_location(l_proc, 20);
631   --
632   -- Only proceed with validation if:
633   -- a) During update, the value has actually changed to
634   --    another not null value.
635   -- b) During insert.
636   --
637   if ((l_api_updating and
638        pay_rcu_shd.g_old_rec.reprocess_type <> p_reprocess_type)
639      or
640        NOT l_api_updating) then
641      --
642      hr_utility.set_location(l_proc, 30);
643 
644      if hr_api.not_exists_in_hr_lookups
645          (p_effective_date => p_effective_date
646          ,p_lookup_type    => 'RETRO_REPROCESS_TYPE'
647          ,p_lookup_code    => p_reprocess_type
648          ) then
649 
650 
651        fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
652        fnd_message.set_token('COLUMN','REPROCESS_TYPE');
653        fnd_message.set_token('LOOKUP_TYPE','RETRO_REPROCESS_TYPE');
654        fnd_message.raise_error;
655 
656      end if;
657 
658      --
659      -- If parent retro component is Full Recalcuration, the reprocess type
660      -- must be R(Reprocessed).
661      --
662      open csr_retro_type;
663      fetch csr_retro_type into l_retro_type;
664      close csr_retro_type;
665      if l_retro_type = 'F'
666         and p_reprocess_type <> 'R' then
667 
668        fnd_message.set_name('PAY','PAY_33169_RCU_INV_RPRC_TYPE');
669        fnd_message.raise_error;
670 
671      end if;
672 
673   end if;
674 
675   hr_utility.set_location(' Leaving:'|| l_proc, 50);
676 end chk_reprocess_type;
677 --
678 --
679 -- -------------------------------------------------------------------------
680 -- |-----------------------< chk_default_component >-----------------------|
681 -- -------------------------------------------------------------------------
682 -- {Start Of Comments}
683 --
684 -- Description:
685 --   Validates that the default_component exists in lookup type YES_NO.
686 --
687 -- Prerequisites:
688 --   None.
689 --
690 -- In Parameters:
691 --   p_retro_component_usage_id
692 --   p_object_version_number
693 --   p_creator_type
694 --   p_creator_id
695 --   p_default_component
696 --   p_effective_date
697 --   p_business_group_id
698 --   p_legislation_code
699 --
700 --
701 -- Post Success:
705 -- Post Failure:
702 --   Processing continues if the default component is valid.
703 --
704 --
706 --   An application error is raised and processing is terminated if the
707 --   default component is invalid.
708 --
709 -- Access Status:
710 --   Internal Development Use Only.
711 --
712 -- {End Of Comments}
713 --
714 procedure chk_default_component
715   (p_retro_component_usage_id in pay_retro_component_usages.retro_component_usage_id%type
716   ,p_object_version_number    in pay_retro_component_usages.object_version_number%type
717   ,p_creator_type             in pay_retro_component_usages.creator_type%type
718   ,p_creator_id               in pay_retro_component_usages.creator_id%type
719   ,p_default_component        in pay_retro_component_usages.default_component%type
720   ,p_effective_date           in date
721   ,p_business_group_id        in pay_retro_component_usages.business_group_id%type
722   ,p_legislation_code         in pay_retro_component_usages.legislation_code%type
723   )
724 is
725   --
726   -- Declare local variables
727   --
728   l_proc           varchar2(72) := g_package||'chk_default_component';
729   l_api_updating   boolean;
730   l_exists         varchar2(1);
731   l_number         number       := hr_api.g_number;
732 
733   --
734   -- Cursor to check that a default retro component usage exists.
735   --
736   -- Bug 4435617. Consider business_group_id and legislation_code
737   -- while checking for the default component.
738 
739   cursor csr_default_component_usage is
740     select null
741       from pay_retro_component_usages
742      where creator_type = p_creator_type
743        and creator_id = p_creator_id
744        and retro_component_usage_id <> nvl(p_retro_component_usage_id, l_number)
745        and default_component = 'Y'
746        and (( business_group_id = p_business_group_id and
747               legislation_code is null )
748             or
749             (legislation_code = p_legislation_code and
750              business_group_id is null )
751             or
752             (legislation_code is null and
753              business_group_id is null )
754            );
755 
756 
757 begin
758   hr_utility.set_location('Entering:'|| l_proc, 10);
759   --
760   -- Check mandatory parameters have been set
761   --
762   hr_api.mandatory_arg_error
763     (p_api_name       => l_proc
764     ,p_argument       => 'default_component'
765     ,p_argument_value => p_default_component
766     );
767   hr_api.mandatory_arg_error
768     (p_api_name       => l_proc
769     ,p_argument       => 'effective_date'
770     ,p_argument_value => p_effective_date
771     );
772   hr_utility.set_location(l_proc, 15);
773   --
774   -- Check if the retro component usage is being updated and ensure that
775   -- g_old_rec contains the values for this retro_component_usage_id.
776   --
777   l_api_updating :=
778     pay_rcu_shd.api_updating
779       (p_retro_component_usage_id => p_retro_component_usage_id
780       ,p_object_version_number    => p_object_version_number);
781 
782   hr_utility.set_location(l_proc, 20);
783   --
784   -- Only proceed with validation if:
785   -- a) During update, the value has actually changed to
786   --    another not null value.
787   -- b) During insert.
788   --
789   if ((l_api_updating and
790        pay_rcu_shd.g_old_rec.default_component <> p_default_component)
791      or
792        NOT l_api_updating) then
793      --
794      hr_utility.set_location(l_proc, 30);
795 
796      if hr_api.not_exists_in_hr_lookups
797          (p_effective_date => p_effective_date
798          ,p_lookup_type    => 'YES_NO'
799          ,p_lookup_code    => p_default_component
800          ) then
801 
802 
803        fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
804        fnd_message.set_token('COLUMN','DEFAULT_COMPONENT');
805        fnd_message.set_token('LOOKUP_TYPE','YES_NO');
806        fnd_message.raise_error;
807 
808      end if;
809      hr_utility.set_location(l_proc, 35);
810 
811      --
812      -- If the default_component is set to Y, ensure another retro component
813      -- usage does not exist whose default_component being set to Y.
814      --
815      if p_default_component = 'Y' then
816 
817        hr_utility.set_location(l_proc, 40);
818        open csr_default_component_usage;
819        fetch csr_default_component_usage into l_exists;
820        if csr_default_component_usage%found then
821          close csr_default_component_usage;
822 
823          fnd_message.set_name('PAY','PAY_33162_RCU_TOO_MANY_DEF');
824          fnd_message.raise_error;
825 
826        end if;
827        close csr_default_component_usage;
828 
829      end if;
830 
831   end if;
832 
833   hr_utility.set_location(' Leaving:'|| l_proc, 50);
834 end chk_default_component;
835 --
836 --
837 -- -------------------------------------------------------------------------
838 -- |-----------------------< chk_replace_run_flag >------------------------|
839 -- -------------------------------------------------------------------------
840 -- {Start Of Comments}
844 --   the value is allowed for the recalculation_style of the component.
841 --
842 -- Description:
843 --   Validates that replace_run_flag value exists in lookup type YES_NO and
845 --
846 -- Prerequisites:
847 --   None.
848 --
849 -- In Parameters:
850 --   p_retro_component_usage_id
851 --   p_retro_component_id
852 --   p_object_version_number
853 --   p_replace_run_flag
854 --   p_effective_date
855 --
856 --
857 -- Post Success:
858 --   Processing continues if the replace run flag is valid.
859 --
860 --
861 -- Post Failure:
862 --   An application error is raised and processing is terminated if the
863 --   replace run flag is invalid.
864 --
865 -- Access Status:
866 --   Internal Development Use Only.
867 --
868 -- {End Of Comments}
869 --
870 procedure chk_replace_run_flag
871   (p_retro_component_usage_id in pay_retro_component_usages.retro_component_usage_id%type
872   ,p_retro_component_id       in pay_retro_component_usages.retro_component_id%type
873   ,p_object_version_number    in pay_retro_component_usages.object_version_number%type
874   ,p_replace_run_flag         in pay_retro_component_usages.replace_run_flag%type
875   ,p_effective_date           in date
876   )
877 is
878   --
879   -- Declare local variables
880   --
881   l_proc           varchar2(72) := g_package||'chk_replace_run_flag';
882   l_api_updating   boolean;
883   l_recalculation_style pay_retro_components.recalculation_style%type;
884   --
885   --
886   cursor csr_recalculation_style is
887   select recalculation_style
888     from pay_retro_components
889     where retro_component_id = p_retro_component_id;
890   --
891   --
892 begin
893   hr_utility.set_location('Entering:'|| l_proc, 10);
894   --
895   -- Check mandatory parameters have been set
896   --
897   hr_api.mandatory_arg_error
898     (p_api_name       => l_proc
899     ,p_argument       => 'effective_date'
900     ,p_argument_value => p_effective_date
901     );
902   hr_utility.set_location(l_proc, 15);
903   --
904   -- Check if the retro component usage is being updated and ensure that
905   -- g_old_rec contains the values for this retro_component_usage_id.
906   --
907   l_api_updating :=
908     pay_rcu_shd.api_updating
909       (p_retro_component_usage_id => p_retro_component_usage_id
910       ,p_object_version_number    => p_object_version_number);
911 
912   hr_utility.set_location(l_proc, 20);
913   --
914   -- Only proceed with validation if:
915   -- a) During update, the value has actually changed.
916   -- b) During insert.
917   --
918   if ((l_api_updating and
919        pay_rcu_shd.g_old_rec.replace_run_flag <> p_replace_run_flag )
920      or
921        NOT l_api_updating) then
922      --
923      hr_utility.set_location(l_proc, 30);
924 
925      if p_replace_run_flag is not null then
926 
927 	     if p_replace_run_flag = 'Y' then
928 
929 		open csr_recalculation_style;
930 		fetch csr_recalculation_style into l_recalculation_style;
931 		close csr_recalculation_style;
932 
933 		if l_recalculation_style is null or l_recalculation_style <> 'R' then
934 			fnd_message.set_name('PAY','PAY_33194_RCU_INVALID_COMB');
935 			fnd_message.set_token('FLAG','REPLACE_RUN_FLAG');
936 			fnd_message.raise_error;
937 		end if;
938 
939 	     end if;
940 
941 	     if hr_api.not_exists_in_hr_lookups
942 		 (p_effective_date => p_effective_date
943 	         ,p_lookup_type    => 'YES_NO'
944 	         ,p_lookup_code    => p_replace_run_flag
945 		 ) then
946 
947 	       fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
948 	       fnd_message.set_token('COLUMN','REPLACE_RUN_FLAG');
949 	       fnd_message.set_token('LOOKUP_TYPE','YES_NO');
950 	       fnd_message.raise_error;
951 
952 	     end if;
953      end if;
954      hr_utility.set_location(l_proc, 35);
955 
956   end if;
957 
958   hr_utility.set_location(' Leaving:'|| l_proc, 50);
959 end chk_replace_run_flag;
960 --
961 --
962 -- -------------------------------------------------------------------------
963 -- |-----------------------< chk_use_override_dates >----------------------|
964 -- -------------------------------------------------------------------------
965 -- {Start Of Comments}
966 --
967 -- Description:
968 --   Validates that use_override_dates value exists in lookup type YES_NO
969 --   and value is allowed for the recalculation_style of the component.
970 --
971 -- Prerequisites:
972 --   None.
973 --
974 -- In Parameters:
975 --   p_retro_component_usage_id
976 --   p_retro_component_id
977 --   p_object_version_number
978 --   p_use_override_dates
979 --   p_effective_date
980 --
981 --
982 -- Post Success:
983 --   Processing continues if the use_override_dates value is valid.
984 --
985 --
986 -- Post Failure:
987 --   An application error is raised and processing is terminated if the
988 --   use_override_dates value is invalid.
989 --
990 -- Access Status:
991 --   Internal Development Use Only.
992 --
996   (p_retro_component_usage_id in pay_retro_component_usages.retro_component_usage_id%type
993 -- {End Of Comments}
994 --
995 procedure chk_use_override_dates
997   ,p_retro_component_id       in pay_retro_component_usages.retro_component_id%type
998   ,p_object_version_number    in pay_retro_component_usages.object_version_number%type
999   ,p_use_override_dates       in pay_retro_component_usages.use_override_dates%type
1000   ,p_effective_date           in date
1001   )
1002 is
1003   --
1004   -- Declare local variables
1005   --
1006   l_proc           varchar2(72) := g_package||'chk_use_override_dates';
1007   l_api_updating   boolean;
1008   l_recalculation_style pay_retro_components.recalculation_style%type;
1009   --
1010   --
1011   cursor csr_recalculation_style is
1012   select recalculation_style
1013     from pay_retro_components
1014     where retro_component_id = p_retro_component_id;
1015   --
1016   --
1017 begin
1018   hr_utility.set_location('Entering:'|| l_proc, 10);
1019   --
1020   -- Check mandatory parameters have been set
1021   --
1022   hr_api.mandatory_arg_error
1023     (p_api_name       => l_proc
1024     ,p_argument       => 'effective_date'
1025     ,p_argument_value => p_effective_date
1026     );
1027   hr_utility.set_location(l_proc, 15);
1028   --
1029   -- Check if the retro component usage is being updated and ensure that
1030   -- g_old_rec contains the values for this retro_component_usage_id.
1031   --
1032   l_api_updating :=
1033     pay_rcu_shd.api_updating
1034       (p_retro_component_usage_id => p_retro_component_usage_id
1035       ,p_object_version_number    => p_object_version_number);
1036 
1037   hr_utility.set_location(l_proc, 20);
1038   --
1039   -- Only proceed with validation if:
1040   -- a) During update, the value has actually changed.
1041   -- b) During insert.
1042   --
1043   if ((l_api_updating and
1044        pay_rcu_shd.g_old_rec.use_override_dates <> p_use_override_dates )
1045      or
1046        NOT l_api_updating) then
1047      --
1048      hr_utility.set_location(l_proc, 30);
1049 
1050      if p_use_override_dates is not null then
1051 
1052 	     if p_use_override_dates = 'Y' then
1053 
1054 		open csr_recalculation_style;
1055 		fetch csr_recalculation_style into l_recalculation_style;
1056 		close csr_recalculation_style;
1057 
1058 		if l_recalculation_style is null or l_recalculation_style <> 'R' then
1059 			fnd_message.set_name('PAY','PAY_33194_RCU_INVALID_COMB');
1060 			fnd_message.set_token('FLAG','USE_OVERRIDE_DATES');
1061 			fnd_message.raise_error;
1062 		end if;
1063 
1064 	     end if;
1065 
1066 	     if hr_api.not_exists_in_hr_lookups
1067 		 (p_effective_date => p_effective_date
1068 	         ,p_lookup_type    => 'YES_NO'
1069 	         ,p_lookup_code    => p_use_override_dates
1070 		 ) then
1071 
1072 	       fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
1073 	       fnd_message.set_token('COLUMN','USE_OVERRIDE_DATES');
1074 	       fnd_message.set_token('LOOKUP_TYPE','YES_NO');
1075 	       fnd_message.raise_error;
1076 
1077 	     end if;
1078      end if;
1079      hr_utility.set_location(l_proc, 35);
1080 
1081   end if;
1082 
1083   hr_utility.set_location(' Leaving:'|| l_proc, 50);
1084 end chk_use_override_dates;
1085 --
1086 --
1087 -- ----------------------------------------------------------------------------
1088 -- |---------------------------< insert_validate >----------------------------|
1089 -- ----------------------------------------------------------------------------
1090 Procedure insert_validate
1091   (p_effective_date               in date
1092   ,p_rec                          in pay_rcu_shd.g_rec_type
1093   ) is
1094 --
1095   l_proc  varchar2(72) := g_package||'insert_validate';
1096 --
1097 Begin
1098   hr_utility.set_location('Entering:'||l_proc, 5);
1099   --
1100   -- Call all supporting business operations
1101   --
1102   --
1103   chk_startup_action(true
1104                     ,p_rec.business_group_id
1105                     ,p_rec.legislation_code
1106                     );
1107   IF hr_startup_data_api_support.g_startup_mode
1108                      NOT IN ('GENERIC','STARTUP') THEN
1109      --
1110      -- Validate Important Attributes
1111      --
1112      hr_api.validate_bus_grp_id
1113        (p_business_group_id => p_rec.business_group_id
1114        ,p_associated_column1 => pay_rcu_shd.g_tab_nam
1115                                 || '.BUSINESS_GROUP_ID');
1116      --
1117      -- after validating the set of important attributes,
1118      -- if Multiple Message Detection is enabled and at least
1119      -- one error has been found then abort further validation.
1120      --
1121      hr_multi_message.end_validation_set;
1122   END IF;
1123   --
1124   --
1125   -- Validate Dependent Attributes
1126   --
1127 
1128   --
1129   -- Validate Retro Component Id
1130   --
1131   chk_retro_component_id
1132     (p_retro_component_id => p_rec.retro_component_id
1133     ,p_business_group_id => p_rec.business_group_id
1134     ,p_legislation_code  => p_rec.legislation_code
1135     );
1136 
1137   --
1138   -- Validate Creator Type, Creator ID
1139   --
1143     ,p_business_group_id => p_rec.business_group_id
1140   chk_creator_type_creator_id
1141     (p_creator_type      => p_rec.creator_type
1142     ,p_creator_id        => p_rec.creator_id
1144     ,p_legislation_code  => p_rec.legislation_code
1145     ,p_effective_date    => p_effective_date
1146     );
1147 
1148   --
1149   -- Validate Reprocess Type
1150   --
1151   chk_reprocess_type
1152     (p_retro_component_usage_id => p_rec.retro_component_usage_id
1153     ,p_object_version_number    => p_rec.object_version_number
1154     ,p_retro_component_id       => p_rec.retro_component_id
1155     ,p_reprocess_type           => p_rec.reprocess_type
1156     ,p_effective_date           => p_effective_date
1157     );
1158 
1159   --
1160   -- Validate Default Component
1161   --
1162   chk_default_component
1163     (p_retro_component_usage_id => p_rec.retro_component_usage_id
1164     ,p_object_version_number    => p_rec.object_version_number
1165     ,p_creator_type             => p_rec.creator_type
1166     ,p_creator_id               => p_rec.creator_id
1167     ,p_default_component        => p_rec.default_component
1168     ,p_effective_date           => p_effective_date
1169     ,p_business_group_id        => p_rec.business_group_id
1170     ,p_legislation_code         => p_rec.legislation_code
1171     );
1172 
1173   --
1174   -- Validate Replace Run Flag.
1175   --
1176   chk_replace_run_flag
1177     (p_retro_component_usage_id => p_rec.retro_component_usage_id
1178     ,p_retro_component_id	=> p_rec.retro_component_id
1179     ,p_object_version_number    => p_rec.object_version_number
1180     ,p_replace_run_flag         => p_rec.replace_run_flag
1181     ,p_effective_date           => p_effective_date
1182     );
1183 
1184   --
1185   -- Validate Use Override Dates.
1186   --
1187   chk_use_override_dates
1188     (p_retro_component_usage_id => p_rec.retro_component_usage_id
1189     ,p_retro_component_id	=> p_rec.retro_component_id
1190     ,p_object_version_number    => p_rec.object_version_number
1191     ,p_use_override_dates       => p_rec.use_override_dates
1192     ,p_effective_date           => p_effective_date
1193     );
1194 
1195   --
1196   hr_utility.set_location(' Leaving:'||l_proc, 10);
1197 End insert_validate;
1198 --
1199 -- ----------------------------------------------------------------------------
1200 -- |---------------------------< update_validate >----------------------------|
1201 -- ----------------------------------------------------------------------------
1202 Procedure update_validate
1203   (p_effective_date               in date
1204   ,p_rec                          in pay_rcu_shd.g_rec_type
1205   ) is
1206 --
1207   l_proc  varchar2(72) := g_package||'update_validate';
1208 --
1209 Begin
1210   hr_utility.set_location('Entering:'||l_proc, 5);
1211   --
1212   -- Call all supporting business operations
1213   --
1214   --
1215   chk_startup_action(false
1216                     ,p_rec.business_group_id
1217                     ,p_rec.legislation_code
1218                     );
1219   IF hr_startup_data_api_support.g_startup_mode
1220                      NOT IN ('GENERIC','STARTUP') THEN
1221      --
1222      -- Validate Important Attributes
1223      --
1224      hr_api.validate_bus_grp_id
1225        (p_business_group_id => p_rec.business_group_id
1226        ,p_associated_column1 => pay_rcu_shd.g_tab_nam
1227                                 || '.BUSINESS_GROUP_ID');
1228      --
1232      --
1229      -- After validating the set of important attributes,
1230      -- if Multiple Message Detection is enabled and at least
1231      -- one error has been found then abort further validation.
1233      hr_multi_message.end_validation_set;
1234   END IF;
1235   --
1236   --
1237   -- Validate Dependent Attributes
1238   --
1239   chk_non_updateable_args
1240     (p_effective_date              => p_effective_date
1241       ,p_rec              => p_rec
1242     );
1243   --
1244 
1245   --
1246   -- Validate Reprocess Type
1247   --
1248   chk_reprocess_type
1249     (p_retro_component_usage_id => p_rec.retro_component_usage_id
1250     ,p_object_version_number    => p_rec.object_version_number
1251     ,p_retro_component_id       => p_rec.retro_component_id
1252     ,p_reprocess_type           => p_rec.reprocess_type
1253     ,p_effective_date           => p_effective_date
1254     );
1255 
1256   --
1257   -- Validate Default Component
1258   --
1259   chk_default_component
1260     (p_retro_component_usage_id => p_rec.retro_component_usage_id
1261     ,p_object_version_number    => p_rec.object_version_number
1262     ,p_creator_type             => p_rec.creator_type
1263     ,p_creator_id               => p_rec.creator_id
1264     ,p_default_component        => p_rec.default_component
1265     ,p_effective_date           => p_effective_date
1266     ,p_business_group_id        => p_rec.business_group_id
1267     ,p_legislation_code         => p_rec.legislation_code
1268     );
1269 
1270   --
1271   -- Validate Replace Run Flag.
1272   --
1273   chk_replace_run_flag
1274     (p_retro_component_usage_id => p_rec.retro_component_usage_id
1275     ,p_retro_component_id	=> p_rec.retro_component_id
1276     ,p_object_version_number    => p_rec.object_version_number
1277     ,p_replace_run_flag         => p_rec.replace_run_flag
1278     ,p_effective_date           => p_effective_date
1279     );
1280 
1281   --
1282   -- Validate Use Override Dates.
1283   --
1284   chk_use_override_dates
1285     (p_retro_component_usage_id => p_rec.retro_component_usage_id
1286     ,p_retro_component_id	=> p_rec.retro_component_id
1287     ,p_object_version_number    => p_rec.object_version_number
1288     ,p_use_override_dates       => p_rec.use_override_dates
1289     ,p_effective_date           => p_effective_date
1290     );
1291 
1292   --
1293   hr_utility.set_location(' Leaving:'||l_proc, 10);
1294 End update_validate;
1295 --
1296 -- ----------------------------------------------------------------------------
1297 -- |---------------------------< delete_validate >----------------------------|
1298 -- ----------------------------------------------------------------------------
1299 Procedure delete_validate
1300   (p_rec                          in pay_rcu_shd.g_rec_type
1301   ) is
1302 --
1303   l_proc  varchar2(72) := g_package||'delete_validate';
1304 --
1305 Begin
1306   hr_utility.set_location('Entering:'||l_proc, 5);
1307   --
1308     --
1309   chk_startup_action(false
1310                     ,pay_rcu_shd.g_old_rec.business_group_id
1311                     ,pay_rcu_shd.g_old_rec.legislation_code
1312                     );
1313   IF hr_startup_data_api_support.g_startup_mode
1314                      NOT IN ('GENERIC','STARTUP') THEN
1315      --
1316      -- Validate Important Attributes
1317      --
1318      --
1319      -- After validating the set of important attributes,
1320      -- if Multiple Message Detection is enabled and at least
1321      -- one error has been found then abort further validation.
1322      --
1323      hr_multi_message.end_validation_set;
1324   END IF;
1325   --
1326   -- Call all supporting business operations
1327   --
1328   hr_utility.set_location(' Leaving:'||l_proc, 10);
1329 End delete_validate;
1330 --
1331 end pay_rcu_bus;