DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PBA_BUS

Source


1 Package Body pay_pba_bus as
2 /* $Header: pypbarhi.pkb 120.1 2005/09/05 06:39:03 adkumar noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_pba_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_balance_attribute_id        number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_balance_attribute_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       from per_business_groups pbg
30          , pay_balance_attributes pba
31      where pba.balance_attribute_id = p_balance_attribute_id
32        and pbg.business_group_id = pba.business_group_id;
33   --
34   -- Declare local variables
35   --
36   l_security_group_id number;
37   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
38   --
39 begin
40   --
41   hr_utility.set_location('Entering:'|| l_proc, 10);
42   --
43   -- Ensure that all the mandatory parameter are not null
44   --
45   hr_api.mandatory_arg_error
46     (p_api_name           => l_proc
47     ,p_argument           => 'balance_attribute_id'
48     ,p_argument_value     => p_balance_attribute_id
49     );
50   --
51   open csr_sec_grp;
52   fetch csr_sec_grp into l_security_group_id;
53   --
54   if csr_sec_grp%notfound then
55      --
56      close csr_sec_grp;
57      --
58      -- The primary key is invalid therefore we must error
59      --
60      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
61      hr_multi_message.add
62        (p_associated_column1
63         => nvl(p_associated_column1,'BALANCE_ATTRIBUTE_ID')
64        );
65      --
66   else
67     close csr_sec_grp;
68     --
69     -- Set the security_group_id in CLIENT_INFO
70     --
71     hr_api.set_security_group_id
72       (p_security_group_id => l_security_group_id
73       );
74   end if;
75   --
76   hr_utility.set_location(' Leaving:'|| l_proc, 20);
77   --
78 end set_security_group_id;
79 --
80 --  ---------------------------------------------------------------------------
81 --  |---------------------< return_legislation_code >-------------------------|
82 --  ---------------------------------------------------------------------------
83 --
84 Function return_legislation_code
85   (p_balance_attribute_id                 in     number
86   )
87   Return Varchar2 Is
88   --
89   -- Declare cursor
90   --
91   cursor csr_leg_code is
92     select pbg.legislation_code
93       from per_business_groups pbg
94          , pay_balance_attributes pba
95      where pba.balance_attribute_id = p_balance_attribute_id
96        and pbg.business_group_id (+) = pba.business_group_id;
97   --
98   -- Declare local variables
99   --
100   l_legislation_code  varchar2(150);
101   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
102   --
103 Begin
104   --
105   hr_utility.set_location('Entering:'|| l_proc, 10);
106   --
107   -- Ensure that all the mandatory parameter are not null
108   --
109   hr_api.mandatory_arg_error
110     (p_api_name           => l_proc
111     ,p_argument           => 'balance_attribute_id'
112     ,p_argument_value     => p_balance_attribute_id
113     );
114   --
115   if ( nvl(pay_pba_bus.g_balance_attribute_id, hr_api.g_number)
116        = p_balance_attribute_id) then
117     --
118     -- The legislation code has already been found with a previous
119     -- call to this function. Just return the value in the global
120     -- variable.
121     --
122     l_legislation_code := pay_pba_bus.g_legislation_code;
123     hr_utility.set_location(l_proc, 20);
124   else
125     --
126     -- The ID is different to the last call to this function
127     -- or this is the first call to this function.
128     --
129     open csr_leg_code;
130     fetch csr_leg_code into l_legislation_code;
131     --
132     if csr_leg_code%notfound then
133       --
134       -- The primary key is invalid therefore we must error
135       --
136       close csr_leg_code;
137       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
138       fnd_message.raise_error;
139     end if;
140     hr_utility.set_location(l_proc,30);
141     --
142     -- Set the global variables so the values are
143     -- available for the next call to this function.
144     --
145     close csr_leg_code;
146     pay_pba_bus.g_balance_attribute_id        := p_balance_attribute_id;
147     pay_pba_bus.g_legislation_code  := l_legislation_code;
148   end if;
149   hr_utility.set_location(' Leaving:'|| l_proc, 40);
150   return l_legislation_code;
151 end return_legislation_code;
152 --
153 -- ----------------------------------------------------------------------------
154 -- |-----------------------------< chk_alterable >----------------------------|
155 -- ----------------------------------------------------------------------------
156 -- {Start Of Comments}
157 --
158 -- Description:
159 --   Special rules apply to insert and delete of rows by users (i.e. in USER
160 --   mode) which depend on the value of the column alterable of the parent
161 --   attribute. STARTUP and GENERIC modes work as regular startup data rows.
162 --
163 --   Mode  Definition type  Alterable  Insert  Delete
164 --   ----  ---------------  ---------  ------  ------
165 --   USER  USER             'Y'        Yes     Yes
166 --   USER  USER             'N'        No      Not inserted, so can't delete
167 --   USER  STARTUP          'Y'        Yes     Yes
168 --   USER  STARTUP          'N'        No      Not inserted, so can't delete
169 --   USER  GENERIC          'Y'        Yes     Yes
170 --   USER  GENERIC          'N'        No      Not inserted, so can't delete
171 --
172 -- Pre Conditions:
173 --   g_old_rec has been populated with details of the values currently in
174 --   the database.
175 --
176 -- In Arguments:
177 --   p_rec has been populated with the updated values the user would like the
178 --   record set to.
179 --
180 -- Post Success:
181 --   Processing continues if a valid attribute_id exists.
182 --
183 -- Post Failure:
184 --   An application error is raised if the attribute_id does not exist.
185 --   entered.
186 --
187 -- {End Of Comments}
188 -- ----------------------------------------------------------------------------
189 function chk_alterable
190   (p_balance_attribute_id in number
191   ,p_attribute_id         in number
192   ,p_business_group_id    in number default null
193   ,p_legislation_code     in varchar2 default null)
194 return boolean IS
195 --
196   l_proc     varchar2(72) := g_package || 'chk_alterable';
197   l_error    EXCEPTION;
198   l_argument varchar2(30);
199   l_attribute_id varchar2(80);
200   --
201   cursor csr_get_alterable(p_att_id number)
202   is
203   select alterable
204   ,      business_group_id
205   ,      legislation_code
206   from   pay_bal_attribute_definitions
207   where  attribute_id = p_att_id;
208   --
209   l_alt pay_bal_attribute_definitions.alterable%type;
210   l_bg  pay_bal_attribute_definitions.business_group_id%type;
211   l_leg pay_bal_attribute_definitions.legislation_code%type;
212   l_allow_ins_del boolean;
213   --
214 BEGIN
215 hr_utility.set_location('Entering '||l_proc, 5);
216 --
217 IF hr_startup_data_api_support.g_startup_mode = 'USER' THEN
218 hr_utility.set_location(l_proc, 10);
219 --
220   open  csr_get_alterable(p_attribute_id);
221   fetch csr_get_alterable into l_alt, l_bg, l_leg;
222   if csr_get_alterable%notfound then
223     close csr_get_alterable;
224     hr_utility.set_location(l_proc, 15);
225     hr_utility.set_message(801, 'PAY_34242_INV_ATTID');
226     hr_utility.raise_error;
227   else
228     if l_leg is null then
229       if l_bg is not null then
230         if l_alt = 'Y' then
231           close csr_get_alterable;
232           return true;
233         else
234           close csr_get_alterable;
235           return false;
236         end if;
237       else -- l_bg is null so generic row
238         if l_alt = 'Y' then
239           close csr_get_alterable;
240           return true;
241         else
242           close csr_get_alterable;
243           return false;
244         end if;
245       end if; -- bg
246     else -- l_leg is not null so startup row
247       if l_alt = 'Y' then
248         close csr_get_alterable;
249         return true;
250       else
251         close csr_get_alterable;
252         return false;
253       end if;
254     end if;
255     --
256   end if;
257 else
258   return true;
259 end if;
260 hr_utility.set_location('Leaving: '||l_proc, 20);
261 --
262 END chk_alterable;
263 -- ----------------------------------------------------------------------------
264 -- |---------------------------< chk_attribute_id >---------------------------|
265 -- ----------------------------------------------------------------------------
266 -- {Start Of Comments}
267 --
268 -- Description:
269 --   This procedure is used to check the validity of the attribute_id
270 --   entered. The following rules apply
271 --
272 --    Mode     Attribute_id Result
273 --    ------   -----------  ---------------------------------------------------
274 --    USER     USER         USER row in balance_attributes
275 --    USER     STARTUP      USER row in balance_attributes
276 --    USER     GENERIC      USER row in balance_attributes
277 --    STARTUP  USER         Error - This mode cannot access USER attributes
278 --    STARTUP  STARTUP      STARTUP row in balance_attributes
279 --    STARTUP  GENERIC      STARTUP row in balance_attributes
280 --    GENERIC  USER         Error - This mode cannot access USER attributes
281 --    GENERIC  STARTUP      Error - This mode cannot access STARTUP attributes
282 --    GENERIC  GENERIC      GENERIC row in balance_attributes
283 --
284 -- Pre Conditions:
285 --   g_old_rec has been populated with details of the values currently in
286 --   the database.
287 --
288 -- In Arguments:
289 --   p_rec has been populated with the updated values the user would like the
290 --   record set to.
291 --
292 -- Post Success:
293 --   Processing continues if a valid attribute_id exists.
294 --
295 -- Post Failure:
296 --   An application error is raised if the attribute_id does not exist.
297 --   entered.
298 --
299 -- {End Of Comments}
300 -- ----------------------------------------------------------------------------
301 Procedure chk_attribute_id
302   (p_balance_attribute_id in number
303   ,p_attribute_id         in number
304   ,p_business_group_id    in number default null
305   ,p_legislation_code     in varchar2 default null) IS
306 --
307   l_proc     varchar2(72) := g_package || 'chk_attribute_id';
308   l_error    EXCEPTION;
309   l_argument varchar2(30);
310   l_attribute_id varchar2(80);
311   --
312   cursor csr_chk_attribute_id_u(p_leg_code varchar2
313                                ,p_bg_id    number)
314   is
315   select 1
316   from   pay_bal_attribute_definitions bad
317   where  bad.attribute_id = p_attribute_id
318   and    ((bad.business_group_id is not null
319          and bad.business_group_id = p_bg_id)
320   or     (bad.legislation_code is not null
321          and bad.legislation_code = p_leg_code)
322   or     (bad.business_group_id is null
323          and bad.legislation_code is null));
324   --
325   cursor csr_chk_attribute_id_s(p_leg_code varchar2)
326   is
327   select 1
328   from   pay_bal_attribute_definitions bad
329   where  bad.attribute_id = p_attribute_id
330   and    bad.business_group_id is null
331   and    ((bad.legislation_code is not null
332          and bad.legislation_code = p_leg_code)
333   or     (bad.legislation_code is null));
334   --
335   cursor csr_chk_attribute_id_g
336   is
337   select 1
338   from pay_bal_attribute_definitions bad
339   where  bad.attribute_id = p_attribute_id
340   and    bad.business_group_id is null
341   and    bad.legislation_code is null;
342   --
343   l_exists number;
344   l_legislation_code pay_balance_attributes.legislation_code%type;
345 Begin
346 --
347 hr_utility.set_location('Entering: '||l_proc,5);
348 --
349 -- Only execute the cursor if absolutely necessary.
350 -- a) During update, the attribute_name has actually changed to another not
351 --    null value, i,e, the value passed to this procedure is different to the
352 --    g_old_rec value.
353 -- b) During insert, the attribute_name is null.
354 -- Can tell the difference between insert and update by looking at the
355 -- primary key value. For update it will be not null. For insert it will be
356 -- null, because pre_inset has not been called yet.
357 --
358 IF (((p_balance_attribute_id is not null) and
359      nvl(pay_pba_shd.g_old_rec.attribute_id, hr_api.g_number) <>
360      nvl(p_attribute_id, hr_api.g_number))
361    or
362     (p_balance_attribute_id is null)) then
363     --
364       hr_utility.set_location(l_proc, 10);
365       --
366       -- Only need to open the cursor if attribute_id is not null
367       --
368       if p_attribute_id is not null then
369       --
370         IF hr_startup_data_api_support.g_startup_mode = 'GENERIC' THEN
371         hr_utility.set_location(l_proc, 15);
372         --
373           OPEN  csr_chk_attribute_id_g;
374           FETCH csr_chk_attribute_id_g into l_exists;
375           IF csr_chk_attribute_id_g%NOTFOUND THEN
376           --
377             CLOSE csr_chk_attribute_id_g;
378             hr_utility.set_message(801, 'PAY_34243_INV_ATTID_4_MODEG');
379             hr_utility.raise_error;
380           END IF;
381           CLOSE csr_chk_attribute_id_g;
382         --
383         elsif hr_startup_data_api_support.g_startup_mode = 'STARTUP' THEN
384         hr_utility.set_location(l_proc, 20);
385         --
386           OPEN  csr_chk_attribute_id_s(p_legislation_code);
387           FETCH csr_chk_attribute_id_s into l_exists;
388           IF csr_chk_attribute_id_s%NOTFOUND THEN
389           --
390             CLOSE csr_chk_attribute_id_s;
391             hr_utility.set_message(801, 'PAY_34244_INV_ATTID_4_MODES');
392             hr_utility.raise_error;
393           END IF;
394           CLOSE csr_chk_attribute_id_s;
395           --
396         ELSIF hr_startup_data_api_support.g_startup_mode = 'USER' THEN
397         hr_utility.set_location(l_proc, 25);
398         --
399           if p_balance_attribute_id is not null then
400             l_legislation_code := pay_pba_bus.return_legislation_code
401                                              (p_balance_attribute_id);
402           else
403             l_legislation_code := hr_api.return_legislation_code
404                                         (p_business_group_id);
405           end if;
406           --
407           OPEN  csr_chk_attribute_id_u(l_legislation_code
408                                       ,p_business_group_id);
409           FETCH csr_chk_attribute_id_u into l_exists;
410           IF csr_chk_attribute_id_u%NOTFOUND THEN
411           --
412             CLOSE csr_chk_attribute_id_u;
413             hr_utility.set_message(801, 'PAY_34245_INV_ATTID_4MODEU');
414             hr_utility.raise_error;
418         END IF;
415           END IF;
416           CLOSE csr_chk_attribute_id_u;
417           --
419         --
420       end if;
421       --
422 end if;
423     --
424 hr_utility.set_location('Leaving: '||l_proc, 20);
425 --
426 END chk_attribute_id;
427 -- ----------------------------------------------------------------------------
428 -- |-----------------------------< chk_def_bal_id >---------------------------|
429 -- ----------------------------------------------------------------------------
430 -- {Start Of Comments}
431 --
432 -- Description:
433 --   This procedure is used to check the validity of the attribute_id
434 --   entered. The following rules apply
435 --
436 --    Mode     Attribute_id Result
437 --    ------   -----------  ---------------------------------------------------
438 --    USER     USER         USER row in balance_attributes
439 --    USER     STARTUP      USER row in balance_attributes
440 --    USER     GENERIC      USER row in balance_attributes
441 --    STARTUP  USER         Error - This mode cannot access USER defined balances
442 --    STARTUP  STARTUP      STARTUP row in balance_attributes
443 --    STARTUP  GENERIC      STARTUP row in balance_attributes
444 --    GENERIC  USER         Error - This mode cannot access USER defined balances
445 --    GENERIC  STARTUP      Error - This mode cannot access STARTUP def balances
446 --    GENERIC  GENERIC      GENERIC row in balance_attributes
447 --
448 -- Pre Conditions:
449 --   g_old_rec has been populated with details of the values currently in
450 --   the database.
451 --
452 -- In Arguments:
453 --   p_rec has been populated with the updated values the user would like the
454 --   record set to.
455 --
456 -- Post Success:
457 --   Processing continues if a valid defined_balance_id exists.
458 --
459 -- Post Failure:
460 --   An application error is raised if the defined_balance_id does not exist.
461 --
462 -- {End Of Comments}
463 -- ----------------------------------------------------------------------------
464 Procedure chk_def_bal_id
465   (p_balance_attribute_id in number
466   ,p_defined_balance_id   in number
467   ,p_business_group_id    in number default null
468   ,p_legislation_code     in varchar2 default null) IS
469 --
470   l_proc     varchar2(72) := g_package || 'chk_def_bal_id';
471   l_error    EXCEPTION;
472   l_argument varchar2(30);
473   l_defined_balance_id varchar2(80);
474   --
475   cursor csr_chk_def_bal_id_u(p_leg_code varchar2
476                              ,p_bg_id    number)
477   is
478   select 1
479   from   pay_defined_balances pdb
480   where  pdb.defined_balance_id = p_defined_balance_id
481   and    ((pdb.business_group_id is not null
482          and pdb.business_group_id = p_bg_id)
483   or     (pdb.legislation_code is not null
484          and pdb.legislation_code = p_leg_code)
485   or     (pdb.business_group_id is null
486          and pdb.legislation_code is null));
487   --
488   cursor csr_chk_def_bal_id_s(p_leg_code varchar2)
489   is
490   select 1
491   from   pay_defined_balances pdb
492   where  pdb.defined_balance_id = p_defined_balance_id
493   and    pdb.business_group_id is null
494   and    ((pdb.legislation_code is not null
495          and pdb.legislation_code = p_leg_code)
496   or     (pdb.legislation_code is null));
497   --
498   cursor csr_chk_def_bal_id_g
499   is
500   select 1
501   from   pay_defined_balances pdb
502   where  pdb.defined_balance_id = p_defined_balance_id
503   and    pdb.business_group_id is null
504   and    pdb.legislation_code is null;
505   --
506   l_exists number;
507   l_legislation_code pay_balance_attributes.legislation_code%type;
508 Begin
509 --
510 hr_utility.set_location('Entering: '||l_proc,5);
511 --
512 -- Only execute the cursor if absolutely necessary.
513 --
514 IF (((p_balance_attribute_id is not null) and
515      nvl(pay_pba_shd.g_old_rec.defined_balance_id, hr_api.g_number) <>
516      nvl(p_defined_balance_id, hr_api.g_number))
517    or
518     (p_balance_attribute_id is null)) then
519     --
520       hr_utility.set_location(l_proc, 10);
521       --
522       -- Only need to open the cursor if defined_balance_id is not null
523       --
524       if p_defined_balance_id is not null then
525       --
526         IF hr_startup_data_api_support.g_startup_mode = 'GENERIC' THEN
527         hr_utility.set_location(l_proc, 15);
528         --
529           OPEN  csr_chk_def_bal_id_g;
530           FETCH csr_chk_def_bal_id_g into l_exists;
531           IF csr_chk_def_bal_id_g%NOTFOUND THEN
532           --
533             CLOSE csr_chk_def_bal_id_g;
534             hr_utility.set_message(801, 'PAY_34246_INV_DEFBAL_4_MODEG');
535             hr_utility.raise_error;
536           END IF;
537           CLOSE csr_chk_def_bal_id_g;
538           --
539         elsif hr_startup_data_api_support.g_startup_mode = 'STARTUP' THEN
540         hr_utility.set_location(l_proc, 20);
541         --
542           OPEN  csr_chk_def_bal_id_s(p_legislation_code);
543           FETCH csr_chk_def_bal_id_s into l_exists;
544           IF csr_chk_def_bal_id_s%NOTFOUND THEN
545           --
546             CLOSE csr_chk_def_bal_id_s;
547             hr_utility.set_message(801, 'PAY_34247_INV_DEFBAL_4_MODES');
551           --
548             hr_utility.raise_error;
549           END IF;
550           CLOSE csr_chk_def_bal_id_s;
552         ELSIF hr_startup_data_api_support.g_startup_mode = 'USER' THEN
553         hr_utility.set_location(l_proc, 25);
554         --
555           if p_balance_attribute_id is not null then
556             l_legislation_code := pay_pba_bus.return_legislation_code
557                                              (p_balance_attribute_id);
558           else
559             l_legislation_code := hr_api.return_legislation_code
560                                         (p_business_group_id);
561           end if;
562           --
563           OPEN  csr_chk_def_bal_id_u(l_legislation_code
564                                       ,p_business_group_id);
565           FETCH csr_chk_def_bal_id_u into l_exists;
566           IF csr_chk_def_bal_id_u%NOTFOUND THEN
567           --
568             CLOSE csr_chk_def_bal_id_u;
569             hr_utility.set_message(801, 'PAY_34248_INV_DEFBAL_4_MODEU');
570             hr_utility.raise_error;
571           END IF;
572           CLOSE csr_chk_def_bal_id_u;
573           --
574         END IF;
575         --
576       end if;
577       --
578 end if;
579 hr_utility.set_location('Leaving: '||l_proc, 20);
580 --
581 END chk_def_bal_id;
582 -- ----------------------------------------------------------------------------
583 -- |-----------------------< chk_non_updateable_args >------------------------|
584 -- ----------------------------------------------------------------------------
585 -- {Start Of Comments}
586 --
587 -- Description:
588 --   This procedure is used to ensure that non updateable attributes have
589 --   not been updated. If an attribute has been updated an error is generated.
590 --
591 -- Pre Conditions:
592 --   g_old_rec has been populated with details of the values currently in
593 --   the database.
594 --
595 -- In Arguments:
596 --   p_rec has been populated with the updated values the user would like the
597 --   record set to.
598 --
599 -- Post Success:
600 --   Processing continues if all the non updateable attributes have not
601 --   changed.
602 --
603 -- Post Failure:
604 --   An application error is raised if any of the non updatable attributes
605 --   have been altered.
606 --
607 -- {End Of Comments}
608 -- ----------------------------------------------------------------------------
609 Procedure chk_non_updateable_args
610   (p_rec in pay_pba_shd.g_rec_type
611   ) IS
612 --
613   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
614   l_error    EXCEPTION;
615   l_argument varchar2(30);
616 --
617 Begin
618   --
619   -- Only proceed with the validation if a row exists for the current
620   -- record in the HR Schema.
621   --
622   IF NOT pay_pba_shd.api_updating
623       (p_balance_attribute_id              => p_rec.balance_attribute_id
624       ) THEN
625      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
626      fnd_message.set_token('PROCEDURE ', l_proc);
627      fnd_message.set_token('STEP ', '5');
628      fnd_message.raise_error;
629   END IF;
630   --
631   if nvl(p_rec.business_group_id, hr_api.g_number) <>
632      nvl(pay_pba_shd.g_old_rec.business_group_id, hr_api.g_number) then
633      l_argument := 'business_group_id';
634      raise l_error;
635   end if;
636   hr_utility.set_location(l_proc, 15);
637   --
638   if p_rec.balance_attribute_id <> pay_pba_shd.g_old_rec.balance_attribute_id
639      then
640      l_argument := 'balance_attribute_id';
641      raise l_error;
642   end if;
643   hr_utility.set_location(l_proc, 20);
644   --
645   if p_rec.attribute_id <> pay_pba_shd.g_old_rec.attribute_id
646      then
647      l_argument := 'attribute_id';
648      raise l_error;
649   end if;
650   hr_utility.set_location(l_proc, 25);
651   --
652   if p_rec.legislation_code <> pay_pba_shd.g_old_rec.legislation_code then
653      l_argument := 'legislation_code';
654      raise l_error;
655   end if;
656   hr_utility.set_location(l_proc, 30);
657   --
658   if p_rec.defined_balance_id <> pay_pba_shd.g_old_rec.defined_balance_id then
659      l_argument := 'defined_balance_id';
660      raise l_error;
661   end if;
662   hr_utility.set_location(l_proc, 35);
663   --
664 End chk_non_updateable_args;
665 --
666 -- ----------------------------------------------------------------------------
667 -- |----------------------< chk_startup_action >------------------------------|
668 -- ----------------------------------------------------------------------------
669 --
670 -- Description:
671 --  This procedure will check that the current action is allowed according
672 --  to the current startup mode.
673 --
674 -- ----------------------------------------------------------------------------
675 PROCEDURE chk_startup_action
676   (p_insert               IN boolean
677   ,p_business_group_id    IN number
678   ,p_legislation_code     IN varchar2
679   ,p_legislation_subgroup IN varchar2 DEFAULT NULL) IS
680 --
681 BEGIN
682   --
683   -- Call the supporting procedure to check startup mode
684   -- EDIT_HERE: The following call should be edited if certain types of rows
685   -- are not permitted.
686   IF (p_insert) THEN
690       ,p_user_allowed      => TRUE
687     hr_startup_data_api_support.chk_startup_action
688       (p_generic_allowed   => TRUE
689       ,p_startup_allowed   => TRUE
691       ,p_business_group_id => p_business_group_id
692       ,p_legislation_code  => p_legislation_code
693       ,p_legislation_subgroup => p_legislation_subgroup
694       );
695   ELSE
696     hr_startup_data_api_support.chk_upd_del_startup_action
697       (p_generic_allowed   => TRUE
698       ,p_startup_allowed   => TRUE
699       ,p_user_allowed      => TRUE
700       ,p_business_group_id => p_business_group_id
701       ,p_legislation_code  => p_legislation_code
702       ,p_legislation_subgroup => p_legislation_subgroup
703       );
704   END IF;
705   --
706 END chk_startup_action;
707 --
708 -- ----------------------------------------------------------------------------
709 -- |---------------------------< insert_validate >----------------------------|
710 -- ----------------------------------------------------------------------------
711 Procedure insert_validate
712   (p_rec                          in pay_pba_shd.g_rec_type
713   ) is
714 --
715   l_proc  varchar2(72) := g_package||'insert_validate';
716 --
717 Begin
718   hr_utility.set_location('Entering:'||l_proc, 5);
719   --
720   -- Call all supporting business operations
721   --
722   --
723   chk_startup_action(true
724                     ,p_rec.business_group_id
725                     ,p_rec.legislation_code
726                     );
727   IF hr_startup_data_api_support.g_startup_mode
728                      NOT IN ('GENERIC','STARTUP') THEN
729      --
730      -- Validate Important Attributes
731      --
732      hr_api.validate_bus_grp_id
733        (p_business_group_id => p_rec.business_group_id
734        ,p_associated_column1 => pay_pba_shd.g_tab_nam
735                                 || '.BUSINESS_GROUP_ID');
736      --
737      -- after validating the set of important attributes,
738      -- if Multiple Message Detection is enabled and at least
739      -- one error has been found then abort further validation.
740      --
741      hr_multi_message.end_validation_set;
742   END IF;
743   --
744   -- Validate Dependent Attributes
745   --
746   pay_pba_bus.chk_attribute_id
747              (p_balance_attribute_id => p_rec.balance_attribute_id
748              ,p_attribute_id         => p_rec.attribute_id
749              ,p_business_group_id    => p_rec.business_group_id
750              ,p_legislation_code     => p_rec.legislation_code
751              );
752   --
753   hr_utility.set_location(l_proc, 10);
754   --
755   if not pay_pba_bus.chk_alterable
756              (p_balance_attribute_id => p_rec.balance_attribute_id
757              ,p_attribute_id         => p_rec.attribute_id
758              ,p_business_group_id    => p_rec.business_group_id
759              ,p_legislation_code     => p_rec.legislation_code
760              ) then
761     hr_utility.set_message(801, 'PAY_34249_INS_NOT_ALLOWED_ALT');
762     hr_utility.raise_error;
763   end if;
764   --
765   hr_utility.set_location(l_proc, 15);
766   --
767   pay_pba_bus.chk_def_bal_id
768              (p_balance_attribute_id => p_rec.balance_attribute_id
769              ,p_defined_balance_id   => p_rec.defined_balance_id
770              ,p_business_group_id    => p_rec.business_group_id
771              ,p_legislation_code     => p_rec.legislation_code
772              );
773   --
774   hr_utility.set_location(' Leaving:'||l_proc, 20);
775 End insert_validate;
776 --
777 -- ----------------------------------------------------------------------------
778 -- |---------------------------< delete_validate >----------------------------|
779 -- ----------------------------------------------------------------------------
780 Procedure delete_validate
781   (p_rec                          in pay_pba_shd.g_rec_type
782   ) is
783 --
784   l_proc  varchar2(72) := g_package||'delete_validate';
785 --
786 Begin
787   hr_utility.set_location('Entering:'||l_proc, 5);
788   --
789   -- NB. need to use g_old_rec, as p_rec is not pupulated with all the columns
790   -- for delete mode.
791   --
792   chk_startup_action(false
793                     ,pay_pba_shd.g_old_rec.business_group_id
794                     ,pay_pba_shd.g_old_rec.legislation_code
795                     );
796   IF hr_startup_data_api_support.g_startup_mode
797                      NOT IN ('GENERIC','STARTUP') THEN
798      --
799      -- Validate Important Attributes
800      --
801      --
802      -- After validating the set of important attributes,
803      -- if Multiple Message Detection is enabled and at least
804      -- one error has been found then abort further validation.
805      --
806      hr_multi_message.end_validation_set;
807   END IF;
808   --
809   -- Call all supporting business operations
810   --
811   if not pay_pba_bus.chk_alterable
812              (p_balance_attribute_id => p_rec.balance_attribute_id
813              ,p_attribute_id         => pay_pba_shd.g_old_rec.attribute_id
814              ,p_business_group_id    => pay_pba_shd.g_old_rec.business_group_id
815              ,p_legislation_code     => pay_pba_shd.g_old_rec.legislation_code
816              ) then
817     hr_utility.set_message(801, 'PAY_34250_DEL_NOT_ALLOWED_ALT');
818     hr_utility.raise_error;
819   end if;
820   --
821   hr_utility.set_location(' Leaving:'||l_proc, 10);
822 End delete_validate;
823 --
824 end pay_pba_bus;