DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_SIV_BUS

Source


1 Package Body pay_siv_bus as
2 /* $Header: pysivrhi.pkb 120.0 2005/05/29 08:52:40 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_siv_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |--------------------------< get_element_info >----------------------------|
12 -- ----------------------------------------------------------------------------
13 Procedure get_element_info
14   (p_element_type_id             in            number
15   ,p_template_id                    out nocopy number
16   ,p_input_currency_code            out nocopy varchar2
17   ) is
18   --
19   -- Cursor to get the template information.
20   --
21   cursor csr_get_element_info is
22   select pet.template_id
23   ,      pset.input_currency_code
24   from   pay_shadow_element_types pset
25   ,      pay_element_templates    pet
26   where  pset.element_type_id = p_element_type_id
27   and    pet.template_id = pset.template_id;
28 --
29   l_proc  varchar2(72) := g_package||'get_element_info';
30   l_api_updating boolean;
31   l_valid        varchar2(1);
32 --
33 Begin
34   hr_utility.set_location('Entering:'||l_proc, 5);
35   open csr_get_element_info;
36   fetch csr_get_element_info
37   into  p_template_id
38   ,     p_input_currency_code;
39   close csr_get_element_info;
40   hr_utility.set_location(' Leaving:'||l_proc, 15);
41 End get_element_info;
42 -- ----------------------------------------------------------------------------
43 -- |---------------------------< get_template_info >--------------------------|
44 -- ----------------------------------------------------------------------------
45 Procedure get_template_info
46   (p_template_id                 in            number
47   ,p_business_group_id           in out nocopy number
48   ,p_legislation_code            in out nocopy varchar2
49   ,p_template_type               in out nocopy varchar2
50   ) is
51   --
52   -- Cursor to get the template information.
53   --
54   cursor csr_get_template_info is
55   select pet.business_group_id
56   ,      pet.legislation_code
57   ,      pet.template_type
58    from   pay_element_templates pet
59   where  pet.template_id = p_template_id;
60 --
61   l_proc  varchar2(72) := g_package||'get_template_info';
62 
63 --
64 Begin
65   hr_utility.set_location('Entering:'||l_proc, 5);
66 
67   open csr_get_template_info;
68 
69   fetch csr_get_template_info
70   into  p_business_group_id
71   ,     p_legislation_code
72   ,     p_template_type;
73 
74   close csr_get_template_info;
75 
76   if p_business_group_id is not null then
77     p_legislation_code := hr_api.return_legislation_code(p_business_group_id);
78   end if;
79 
80   hr_utility.set_location(' Leaving:'||l_proc, 15);
81 End get_template_info;
82 -- ----------------------------------------------------------------------------
83 -- |-----------------------< chk_non_updateable_args >------------------------|
84 -- ----------------------------------------------------------------------------
85 Procedure chk_non_updateable_args
86 (p_rec in pay_siv_shd.g_rec_type
87 ) is
88   --
89   -- Cursor to disallow update if a balance has been generated from
90   -- this shadow balance.
91   --
92   cursor csr_disallow_update is
93   select null
94   from   pay_template_core_objects tco
95   where  tco.core_object_type = pay_tco_shd.g_siv_lookup_type
96   and    tco.shadow_object_id = p_rec.input_value_id;
97   --
98   -- Cursor to disallow update of UOM if balance feeds to this
99   -- balance exists.
100   --
101   cursor csr_disallow_uom is
102   select null
103   from   pay_shadow_balance_feeds sbf
104   where  sbf.input_value_id = p_rec.input_value_id;
105 --
106   l_proc  varchar2(72) := g_package||'chk_non_updateable_args';
107   l_error exception;
108   l_api_updating boolean;
109   l_argument     varchar2(30);
110   l_disallow     varchar2(1);
111 --
112 Begin
113   hr_utility.set_location('Entering:'||l_proc, 5);
114   l_api_updating := pay_siv_shd.api_updating
115     (p_input_value_id        => p_rec.input_value_id
116     ,p_object_version_number => p_rec.object_version_number
117     );
118   if not l_api_updating then
119     hr_utility.set_message(801,'HR_6153_ALL_PROCEDURE_FAIL');
120     hr_utility.set_message_token('PROCEDURE', l_proc);
121     hr_utility.set_message_token('STEP', '10');
122     hr_utility.raise_error;
123   end if;
124   --
125   hr_utility.set_location(l_proc, 15);
126   --
127   -- Check that the update is actually allowed.
128   --
129   open csr_disallow_update;
130   fetch csr_disallow_update into l_disallow;
131   if csr_disallow_update%found then
132     hr_utility.set_location(l_proc, 20);
133     close csr_disallow_update;
134     fnd_message.set_name('PAY', 'PAY_50121_SIV_CORE_ROW_EXISTS');
135     fnd_message.raise_error;
136   end if;
137   close csr_disallow_update;
138   --
139   -- Check the otherwise non-updateable arguments.
140   --
141   -- p_element_type_id
142   --
143   if nvl(p_rec.element_type_id, hr_api.g_number) <>
144      nvl(pay_siv_shd.g_old_rec.element_type_id, hr_api.g_number)
145   then
146     l_argument := 'p_element_type_id';
147     raise l_error;
148   end if;
149   --
150   -- p_uom
151   --
152   if nvl(p_rec.uom, hr_api.g_varchar2) <>
153      nvl(pay_siv_shd.g_old_rec.uom, hr_api.g_varchar2)
154   then
155     --
156     -- Check to see if the update is allowed.
157     --
158     open csr_disallow_uom;
159     fetch csr_disallow_uom into l_disallow;
160     if csr_disallow_uom%found then
161       close csr_disallow_uom;
162       l_argument := 'p_uom';
163       raise l_error;
164     end if;
165     close csr_disallow_uom;
166   end if;
167   hr_utility.set_location('Leaving:'||l_proc, 25);
168 exception
169     when l_error then
170        hr_utility.set_location('Leaving:'||l_proc, 30);
171        hr_api.argument_changed_error
172          (p_api_name => l_proc
173          ,p_argument => l_argument);
174     when others then
175        hr_utility.set_location('Leaving:'||l_proc, 35);
176        raise;
177 End chk_non_updateable_args;
178 -- ----------------------------------------------------------------------------
179 -- |--------------------------< chk_element_type_id >-------------------------|
180 -- ----------------------------------------------------------------------------
181 Procedure chk_element_type_id
182   (p_element_type_id     in     number
183   ,p_exclusion_rule_id   in     number
184   ) is
185   --
186   -- Cursor to check that the element type exists.
187   --
188   cursor csr_element_type_exists is
189   select null
190   from   pay_shadow_element_types pset
191   where  pset.element_type_id = p_element_type_id;
192   --
193   -- Cursor to count the number of input values that the element type
194   -- already has.
195   --
196   cursor csr_input_value_count is
197   select count(siv.input_value_id)
198   from   pay_shadow_input_values siv
199   where  siv.element_type_id = p_element_type_id
200   and    siv.exclusion_rule_id is null
201   ;
202 --
203   l_proc  varchar2(72) := g_package||'chk_element_type_id';
204   l_exists varchar2(1);
205   l_count number;
206   l_max_input_values constant number := 15;
207 --
208 Begin
209   hr_utility.set_location('Entering:'||l_proc, 5);
210   --
211   -- Check that the element type is not null.
212   --
213   hr_api.mandatory_arg_error
214   (p_api_name       => l_proc
215   ,p_argument       => 'p_element_type_id'
216   ,p_argument_value => p_element_type_id
217   );
218   --
219   -- Check that the element type exists.
220   --
221   open csr_element_type_exists;
222   fetch csr_element_type_exists into l_exists;
223   if csr_element_type_exists%notfound then
224     hr_utility.set_location(' Leaving:'||l_proc, 10);
225     close csr_element_type_exists;
226     fnd_message.set_name('PAY', 'PAY_50095_ETM_INVALID_ELE_TYPE');
227     fnd_message.raise_error;
228   end if;
229   close csr_element_type_exists;
230   --
231   -- Count the number of input values for this element type.
232   --
233   open csr_input_value_count;
234   fetch csr_input_value_count into l_count;
235   if p_exclusion_rule_id is null and
236     l_count >= l_max_input_values then
237     hr_utility.set_location(' Leaving:'||l_proc, 15);
238     close csr_input_value_count;
239     fnd_message.set_name('PAY', 'PAY_50122_SIV_TOO_MANY_INPUTS');
240     fnd_message.set_token('MAX', l_max_input_values);
241     fnd_message.raise_error;
242   end if;
243   close csr_input_value_count;
244   hr_utility.set_location(' Leaving:'||l_proc, 20);
245 exception
246   when others then
247     if csr_input_value_count%isopen then
248       close csr_input_value_count;
249     end if;
250     if csr_element_type_exists%isopen then
251       close  csr_element_type_exists;
252     end if;
253     raise;
254 End chk_element_type_id;
255 -- ----------------------------------------------------------------------------
256 -- |------------------------< chk_display_sequence >--------------------------|
257 -- ----------------------------------------------------------------------------
258 Procedure chk_display_sequence
259   (p_display_sequence      in number
260   ,p_input_value_id        in number
261   ,p_object_version_number in number
262   ) is
263   l_proc  varchar2(72) := g_package||'chk_display_sequence';
264   l_api_updating boolean;
265 --
266 Begin
267   hr_utility.set_location('Entering:'||l_proc, 5);
268   l_api_updating := pay_siv_shd.api_updating
269   (p_input_value_id        => p_input_value_id
270   ,p_object_version_number => p_object_version_number
271   );
272   if (l_api_updating and nvl(p_display_sequence, hr_api.g_number) <>
273       nvl(pay_siv_shd.g_old_rec.display_sequence, hr_api.g_number)) or
274       not l_api_updating
275   then
276     --
277     -- Check that display_sequence is not null.
278     --
279     hr_api.mandatory_arg_error
280     (p_api_name       => l_proc
281     ,p_argument       => 'p_display_sequence'
282     ,p_argument_value => p_display_sequence
283     );
284   end if;
285   hr_utility.set_location(' Leaving:'||l_proc, 15);
286 End chk_display_sequence;
287 -- ----------------------------------------------------------------------------
288 -- |-----------------------------< chk_lookups >------------------------------|
289 -- ----------------------------------------------------------------------------
290 Procedure chk_lookups
291   (p_effective_date         in     date
292   ,p_generate_db_items_flag in     varchar2
293   ,p_hot_default_flag       in     varchar2
294   ,p_mandatory_flag         in     varchar2
295   ,p_uom                    in     varchar2
296   ,p_warning_or_error       in     varchar2
297   ,p_input_value_id         in     number
298   ,p_object_version_number  in     number
299   ) is
300 --
301   l_proc  varchar2(72) := g_package||'chk_lookups';
302   l_api_updating boolean;
303 --
304   Procedure chk_lookup
305     (p_effective_date                     in    date
306     ,p_caller                             in    varchar2
307     ,p_argument_name                      in    varchar2
308     ,p_old_lookup_code                    in    varchar2
309     ,p_lookup_code                        in    varchar2
310     ,p_lookup_type                        in    varchar2
311     ,p_mandatory                          in    boolean
312     ,p_updatable                          in    boolean
313     ,p_api_updating                       in    boolean
314     ) is
315   begin
316     if (p_updatable  and p_api_updating and
317         nvl(p_lookup_code, hr_api.g_varchar2) <>
318         nvl(p_old_lookup_code, hr_api.g_varchar2)) or not p_api_updating
319     then
320       --
321       -- Check that mandatory argument is not null.
322       --
323       if p_mandatory then
324         hr_api.mandatory_arg_error
325         (p_api_name       => p_caller
326         ,p_argument       => p_argument_name
327         ,p_argument_value => p_lookup_code
328         );
329       end if;
330       --
331       -- Exit if the argument is null, and not mandatory.
332       --
333       if not p_mandatory and p_lookup_code is null then
334         return;
335       end if;
336       --
337       -- Do the lookup check.
338       --
339       if hr_api.not_exists_in_hr_lookups
340          (p_effective_date => p_effective_date
341          ,p_lookup_type    => p_lookup_type
342          ,p_lookup_code    => p_lookup_code
343          )
344       then
345         fnd_message.set_name('PAY', 'HR_52966_INVALID_LOOKUP');
346         fnd_message.set_token('LOOKUP_TYPE', p_lookup_type);
347         fnd_message.set_token('COLUMN', upper(p_argument_name));
348         fnd_message.raise_error;
349       end if;
350     end if;
351   end chk_lookup;
352 --
353 Begin
354   hr_utility.set_location('Entering:'||l_proc, 5);
355   l_api_updating := pay_siv_shd.api_updating
356   (p_input_value_id        => p_input_value_id
357   ,p_object_version_number => p_object_version_number
358   );
359   --
360   -- generate_db_items_flag
361   --
362   chk_lookup
363   (p_effective_date   => p_effective_date
364   ,p_caller           => l_proc
365   ,p_argument_name    => 'generate_db_items_flag'
366   ,p_old_lookup_code  => pay_siv_shd.g_old_rec.generate_db_items_flag
367   ,p_lookup_code      => p_generate_db_items_flag
368   ,p_lookup_type      => 'YES_NO'
369   ,p_mandatory        => true
370   ,p_updatable        => true
371   ,p_api_updating     => l_api_updating
372   );
373   --
374   -- hot_default_flag
375   --
376   chk_lookup
377   (p_effective_date   => p_effective_date
378   ,p_caller           => l_proc
379   ,p_argument_name    => 'hot_default_flag'
380   ,p_old_lookup_code  => pay_siv_shd.g_old_rec.hot_default_flag
381   ,p_lookup_code      => p_hot_default_flag
382   ,p_lookup_type      => 'YES_NO'
383   ,p_mandatory        => true
384   ,p_updatable        => true
385   ,p_api_updating     => l_api_updating
386   );
387   --
388   -- mandatory_flag
389   --
390   chk_lookup
391   (p_effective_date   => p_effective_date
392   ,p_caller           => l_proc
393   ,p_argument_name    => 'mandatory_flag'
394   ,p_old_lookup_code  => pay_siv_shd.g_old_rec.mandatory_flag
395   ,p_lookup_code      => p_mandatory_flag
396   ,p_lookup_type      => 'YES_NO_NEVER'
397   ,p_mandatory        => true
398   ,p_updatable        => true
399   ,p_api_updating     => l_api_updating
400   );
401   --
402   -- uom
403   --
404   chk_lookup
405   (p_effective_date   => p_effective_date
406   ,p_caller           => l_proc
407   ,p_argument_name    => 'uom'
408   ,p_old_lookup_code  => pay_siv_shd.g_old_rec.uom
409   ,p_lookup_code      => p_uom
410   ,p_lookup_type      => 'UNITS'
411   ,p_mandatory        => true
412   ,p_updatable        => true
413   ,p_api_updating     => l_api_updating
414   );
415   --
416   -- warning_or_error
417   --
418   chk_lookup
419   (p_effective_date   => p_effective_date
420   ,p_caller           => l_proc
421   ,p_argument_name    => 'warning_or_error'
422   ,p_old_lookup_code  => pay_siv_shd.g_old_rec.warning_or_error
423   ,p_lookup_code      => p_warning_or_error
424   ,p_lookup_type      => 'WARNING_ERROR'
425   ,p_mandatory        => false
426   ,p_updatable        => true
427   ,p_api_updating     => l_api_updating
428   );
429   hr_utility.set_location(' Leaving:'||l_proc, 15);
430 End chk_lookups;
431 -- ----------------------------------------------------------------------------
432 -- |--------------------------------< chk_name >------------------------------|
433 -- ----------------------------------------------------------------------------
434 Procedure chk_name
435   (p_name                  in   varchar2
436   ,p_element_type_id       in   number
437   ,p_input_value_id        in   number
438   ,p_object_version_number in   number
439   ) is
440   --
441   -- Cursor to check that the input value name does not exist for the
442   -- element type.
443   --
444   cursor csr_name_exists is
445   select null
446   from   pay_shadow_input_values siv
447   where  siv.element_type_id = p_element_type_id
448   and    upper(siv.name) = upper(p_name);
449 --
450   l_proc  varchar2(72) := g_package||'chk_name';
451   l_api_updating boolean;
452   l_exists       varchar2(1);
453   l_value        varchar2(2000);
454   l_output       varchar2(2000);
455   l_rgeflg       varchar2(2000);
456 --
457 Begin
458   hr_utility.set_location('Entering:'||l_proc, 5);
459   l_api_updating := pay_siv_shd.api_updating
460   (p_input_value_id        => p_input_value_id
461   ,p_object_version_number => p_object_version_number
462   );
463   if (l_api_updating and nvl(p_name, hr_api.g_varchar2) <>
464       nvl(pay_siv_shd.g_old_rec.name, hr_api.g_varchar2)) or
465      not l_api_updating
466   then
467     --
468     -- Check that the name is not already in use.
469     --
470     open csr_name_exists;
471     fetch csr_name_exists into l_exists;
472     if csr_name_exists%found then
473       close csr_name_exists;
474       fnd_message.set_name('PAY', 'PAY_50142_SIV_NAME_EXISTS');
475       fnd_message.set_token('NAME', p_name);
476       fnd_message.raise_error;
477     end if;
478     close csr_name_exists;
479     --
480     -- Check that the name format is correct (not null payroll name).
481     --
482     l_value := p_name;
483     hr_chkfmt.checkformat
484     (value   => l_value
485     ,format  => 'PAY_NAME'
486     ,output  => l_output
487     ,minimum => null
488     ,maximum => null
489     ,nullok  => 'N'
490     ,rgeflg  => l_rgeflg
491     ,curcode => null
492     );
493   end if;
494   hr_utility.set_location(' Leaving:'||l_proc, 20);
495 End chk_name;
496 -- ----------------------------------------------------------------------------
497 -- |---------------------------< chk_lookup_type >----------------------------|
498 -- ----------------------------------------------------------------------------
499 Procedure chk_lookup_type
500   (p_effective_date        in date
501   ,p_lookup_type           in varchar2
502   ,p_uom                   in varchar2
503   ,p_default_value         in varchar2
504   ,p_input_value_id        in number
505   ,p_object_version_number in number
506   ) is
507   --
508   -- Cursor to check that lookup_type is valid.
509   --
510   cursor csr_lookup_type_valid is
511   select null
512   from   hr_lookups hr
513   where  hr.lookup_type = p_lookup_type
514   and    hr.enabled_flag = 'Y'
515   and    p_effective_date between
516          nvl(start_date_active, p_effective_date)
517          and nvl(end_date_active, p_effective_date);
518   --
519   l_proc  varchar2(72) := g_package||'chk_lookup_type';
520   l_valid varchar2(1);
521   l_api_updating boolean;
522   l_uom_changed  boolean;
523   l_chk_default  boolean;
524 --
525 Begin
526   hr_utility.set_location('Entering:'||l_proc, 5);
527   l_api_updating := pay_siv_shd.api_updating
528   (p_input_value_id        => p_input_value_id
529   ,p_object_version_number => p_object_version_number
530   );
531   --
532   -- Has the UOM changed ?
533   --
534   l_uom_changed :=
535   l_api_updating and nvl(p_uom, hr_api.g_varchar2) <>
536                      nvl(pay_siv_shd.g_old_rec.uom, hr_api.g_varchar2);
537   --
538   -- Check the lookup type.
539   --
540   l_chk_default := false;
541   if (l_api_updating and nvl(p_lookup_type, hr_api.g_varchar2) <>
542       nvl(pay_siv_shd.g_old_rec.lookup_type, hr_api.g_varchar2)) or
543       not l_api_updating or
544       l_uom_changed
545   then
546     if p_lookup_type is not null then
547       --
548       -- UOM must be 'C' if lookup type is used for validation.
549       --
550       if p_uom <> 'C' then
551         hr_utility.set_location(' Leaving:'||l_proc, 10);
552         fnd_message.set_name('PAY', 'PAY_50132_SIV_BAD_LOOKUP_UOM');
553         fnd_message.set_token('UOM', 'C');
554         fnd_message.raise_error;
555       end if;
556       --
557       -- Check that the lookup type exists.
558       --
559       open csr_lookup_type_valid;
560       fetch csr_lookup_type_valid into l_valid;
561       if csr_lookup_type_valid%notfound then
562         hr_utility.set_location(' Leaving:'||l_proc, 15);
563         close csr_lookup_type_valid;
564         fnd_message.set_name('PAY', 'PAY_50133_SIV_BAD_LOOKUP_TYPE');
565         fnd_message.set_token('LOOKUP_TYPE', p_lookup_type);
566         fnd_message.raise_error;
567       end if;
568       close csr_lookup_type_valid;
569       --
570       -- Flag the need to recheck the default value.
571       --
572       l_chk_default := true;
573     end if;
574   end if;
575   --
576   -- Check the default value.
577   --
578   if (l_api_updating and nvl(p_default_value, hr_api.g_varchar2) <>
579       nvl(pay_siv_shd.g_old_rec.default_value, hr_api.g_varchar2)) or
580       not l_api_updating or
581       l_chk_default
582   then
583     if p_default_value is not null and p_lookup_type is not null and
584        hr_api.not_exists_in_hr_lookups
585        (p_effective_date => p_effective_date
586        ,p_lookup_type    => p_lookup_type
587        ,p_lookup_code    => p_default_value
588        )
589     then
590       hr_utility.set_location(' Leaving:'||l_proc, 20);
591       fnd_message.set_name('PAY', 'HR_52966_INVALID_LOOKUP');
592       fnd_message.set_token('LOOKUP_TYPE', p_lookup_type);
593       fnd_message.set_token('COLUMN', 'DEFAULT_VALUE');
594       fnd_message.raise_error;
595     end if;
596   end if;
597   hr_utility.set_location(' Leaving:'||l_proc, 25);
598 End chk_lookup_type;
599 -- ----------------------------------------------------------------------------
600 -- |------------------------------< chk_values >------------------------------|
601 -- ----------------------------------------------------------------------------
602 Procedure chk_values
603   (p_effective_date		in     date
604   ,p_input_currency_code	in     varchar2
605   ,p_uom			in     varchar2
606   ,p_lookup_type		in     varchar2
607   ,p_default_value		in     varchar2
608   ,p_min_value			in     varchar2
609   ,p_max_value			in     varchar2
610   ,p_input_value_id		in     number
611   ,p_formula_id			in     number
612   ,p_input_validation_formula   in     varchar2
613   ,p_object_version_number	in     number
614   ) is
615   --
616   -- Cursor to check that lookup_type is valid.
617   --
618   cursor csr_lookup_type_valid is
619   select null
620   from   hr_lookups hr
621   where  hr.lookup_type = p_lookup_type
622   and    hr.enabled_flag = 'Y'
623   and    p_effective_date between
624          nvl(start_date_active, p_effective_date)
625          and nvl(end_date_active, p_effective_date);
626 --
627   l_proc  varchar2(72) := g_package||'chk_values';
628   l_api_updating boolean;
629   l_exists       varchar2(1);
630   l_value        varchar2(2000);
631   l_output       varchar2(2000);
632   l_rgeflg       varchar2(2000);
633   l_min          varchar2(2000);
634   l_min_output   varchar2(2000);
635   l_max          varchar2(2000);
636   l_max_output   varchar2(2000);
637   l_uom          varchar2(2000);
638   l_def          varchar2(2000);
639   l_def_output   varchar2(2000);
640   l_chk_def      boolean := false;
641   l_chk_max      boolean := false;
642   l_chk_min      boolean := false;
643   l_uom_updated  boolean := false;
644   l_do_checks    boolean;
645 --
646 Begin
647   hr_utility.set_location('Entering:'||l_proc, 5);
648   --
649   -- Check against the lookup type (which should have already been
650   -- validated against the default value).
651   --
652   if p_lookup_type is not null then
653     --
654     -- The maximum and minimum values must both be null if lookup type
655     -- is not null.
656     --
657     if p_max_value is not null or p_min_value is not null then
658       hr_utility.set_location('Leaving:'||l_proc, 10);
659       fnd_message.set_name('PAY', 'PAY_50134_SIV_LOOKUP_AND_RANGE');
660       fnd_message.raise_error;
661     end if;
662     --
663     -- The formula_id and input_validation_formula must both be null if
664     -- lookup type is not null.
665     --
666     if p_formula_id is not null or p_input_validation_formula is not null then
667       hr_utility.set_location('Leaving:'||l_proc, 15);
668       fnd_message.set_name('PAY', 'PAY_33184_SIV_VALID_COMB');
669       fnd_message.raise_error;
670     end if;
671     --
672     --
673     hr_utility.set_location('Leaving:'||l_proc, 20);
674     return;
675   end if;
676   --
677   if p_formula_id is not null then
678     --
679     -- The maximum and minimum values must both be null if formula id
680     -- is not null.
681     --
682     if p_max_value is not null or p_min_value is not null then
683       hr_utility.set_location('Leaving:'||l_proc, 25);
684       fnd_message.set_name('PAY', 'PAY_33184_SIV_VALID_COMB');
685       fnd_message.raise_error;
686     end if;
687     --
688     -- The input validation formula must be null when formula id is not null
689     --
690     if p_input_validation_formula is not null then
691       hr_utility.set_location('Leaving:'||l_proc, 30);
692       fnd_message.set_name('PAY', 'PAY_33184_SIV_VALID_COMB');
693       fnd_message.raise_error;
694     end if;
695     --
696     --
697 
698     hr_utility.set_location('Leaving:'||l_proc, 35);
699     return;
700 
701   end if;
702   --
703   if p_input_validation_formula is not null then
704     --
705     -- The maximum and minimum values must both be null if input validation formula
706     -- is not null.
707     --
708     if p_max_value is not null or p_min_value is not null then
709       hr_utility.set_location('Leaving:'||l_proc, 40);
710       fnd_message.set_name('PAY', 'PAY_33184_SIV_VALID_COMB');
711       fnd_message.raise_error;
712     end if;
713 
714     hr_utility.set_location('Leaving:'||l_proc, 45);
715     return;
716 
717   end if;
718   --
719   --
720   -- The code needs to check the minimum, maximum, and default values
721   -- using checkformat and the supplied UOM.
722   --
723   l_api_updating := pay_siv_shd.api_updating
724   (p_input_value_id        => p_input_value_id
725   ,p_object_version_number => p_object_version_number
726   );
727   --
728   -- Did the UOM get updated ? Note: it should have already been checked
729   -- for validity.
730   --
731   if (l_api_updating and nvl(p_uom, hr_api.g_varchar2) <>
732       nvl(pay_siv_shd.g_old_rec.uom, hr_api.g_varchar2)) or
733       not l_api_updating
734   then
735     l_uom_updated := true;
736     l_uom := p_uom;
737   else
738     l_uom := pay_siv_shd.g_old_rec.uom;
739   end if;
740   --
741   -- Decide what needs checking.
742   --
743   if (l_api_updating and nvl(p_default_value, hr_api.g_varchar2) <>
744       nvl(pay_siv_shd.g_old_rec.default_value, hr_api.g_varchar2)) or
745       not l_api_updating
746   then
747     l_chk_def := true;
748     l_def := p_default_value;
749   else
750     l_def := pay_siv_shd.g_old_rec.default_value;
751   end if;
752   --
753   if (l_api_updating and nvl(p_max_value, hr_api.g_varchar2) <>
754       nvl(pay_siv_shd.g_old_rec.max_value, hr_api.g_varchar2)) or
755       not l_api_updating
756   then
757     l_chk_max := true;
758     l_max := p_max_value;
759   else
760     l_max := pay_siv_shd.g_old_rec.max_value;
761   end if;
762   --
763   if (l_api_updating and nvl(p_min_value, hr_api.g_varchar2) <>
764       nvl(pay_siv_shd.g_old_rec.min_value, hr_api.g_varchar2)) or
765       not l_api_updating
766   then
767     l_chk_min := true;
768     l_min := p_min_value;
769   else
770     l_min := pay_siv_shd.g_old_rec.min_value;
771   end if;
772   --
773   -- If anything's changed (or it's the first time) then everything has
774   -- to be checked.
775   --
776   l_do_checks := l_uom_updated or l_chk_def or l_chk_min or l_chk_max;
777   --
778   -- Nothing's changed so return.
779   --
780   if not l_do_checks then
781     hr_utility.set_location('Leaving:'||l_proc, 50);
782     return;
783   end if;
784   -------------
785   -- Minimum/Maximum/Default Value Checks:
786   -- o changeformat expects input value in canonical format for number/date,
787   --   and is used to check that the minimum/maximum and default values are
788   --   in the correct internal format.
789   -- o changeformat converts to output in display format.
790   -- o checkformat expects value in display format, and minimum/maximum values
791   --   in canonical format for number/date, and is used for range checking.
792   -------------
793   --
794   -- Check the minimum value.
795   --
796   l_value := l_min;
797   hr_chkfmt.changeformat
798   (input   => l_value
799   ,output  => l_min_output
800   ,format  => l_uom
801   ,curcode => p_input_currency_code
802   );
803   --
804   -- Check the maximum value.
805   --
806   l_value := l_max;
807   hr_chkfmt.changeformat
808   (input   => l_value
809   ,output  => l_max_output
810   ,format  => l_uom
811   ,curcode => p_input_currency_code
812   );
813   --
814   -- Check the default value.
815   --
816   l_value := l_def;
817   hr_chkfmt.changeformat
818   (input   => l_value
819   ,output  => l_def_output
820   ,format  => l_uom
821   ,curcode => p_input_currency_code
822   );
823   --
824   -- Do the range check (starting with the minimum and maximum values).
825   --
826   l_rgeflg := 'S';
827   --
828   -- Only check maximum and minimum values if both values are not null.
829   --
830   if l_min is not null and l_max is not null then
831     hr_chkfmt.checkformat
832     (value   => l_min_output
833     ,format  => l_uom
834     ,output  => l_output
835     ,minimum => l_min
836     ,maximum => l_max
837     ,nullok  => 'Y'
838     ,rgeflg  => l_rgeflg
839     ,curcode => p_input_currency_code
840     );
841   end if;
842   --
843   -- Only check the default value if the previous check did not fail, if
844   -- the default value is not null, and at least one of l_min or l_max is
845   -- not null.
846   --
847   if l_rgeflg <> 'F' and l_def is not null and
848      (l_min is not null or l_max is not null) then
849     hr_chkfmt.checkformat
850     (value   => l_def_output
851     ,format  => l_uom
852     ,output  => l_output
853     ,minimum => l_min
854     ,maximum => l_max
855     ,nullok  => 'Y'
856     ,rgeflg  => l_rgeflg
857     ,curcode => p_input_currency_code
858     );
859   end if;
860   --
861   if l_rgeflg = 'F' then
862     --
863     -- Range check failed.
864     --
865     hr_utility.set_location('Leaving:'||l_proc, 55);
866     fnd_message.set_name('PAY', 'PAY_50135_SIV_BAD_RANGE_VALUES');
867     fnd_message.raise_error;
868   end if;
869   hr_utility.set_location(' Leaving:'||l_proc, 60);
870 End chk_values;
871 -- ----------------------------------------------------------------------------
872 -- |-----------------------< chk_default_value_column >-----------------------|
873 -- ----------------------------------------------------------------------------
874 Procedure chk_default_value_column
875   (p_default_value_column  in     varchar2
876   ,p_template_id           in     number
877   ,p_uom                   in     varchar2
878   ,p_lookup_type           in     varchar2
879   ,p_input_value_id        in     number
880   ,p_object_version_number in     number
881   ) is
882   --
883   -- Cursor to ensure that the default value column is not being used as
884   -- a flexfield column in PAY_TEMPLATE_EXCLUSION_RULES.
885   --
886   cursor csr_default_value_clash is
887   select null
888   from   pay_template_exclusion_rules ter
889   where  ter.template_id = p_template_id
890   and    upper(ter.flexfield_column) = upper(p_default_value_column);
891   --
892   -- Cursor to make sure that the default value column is being used
893   -- consistently.
894   --
895   cursor csr_inconsistent_def_val is
896   select null
897   from   pay_shadow_element_types pset
898   ,      pay_shadow_input_values psiv
899   where  pset.template_id = p_template_id
900   and    psiv.element_type_id = pset.element_type_id
901   and    nvl(upper(psiv.default_value_column), hr_api.g_varchar2) =
902          upper(p_default_value_column)
903   and    (psiv.uom <> p_uom or nvl(psiv.lookup_type, hr_api.g_varchar2) <>
904           nvl(p_lookup_type, hr_api.g_varchar2));
905 --
906   l_proc  varchar2(72) := g_package||'chk_default_value_column';
907   l_len   number;
908   l_prefix varchar2(2000);
909   l_suffix number;
910   l_error  exception;
911   l_api_updating boolean;
912   l_clash  varchar2(1);
913   l_inconsistent varchar2(1);
914 --
915 Begin
916   hr_utility.set_location('Entering:'||l_proc, 5);
917   l_api_updating := pay_siv_shd.api_updating
918   (p_input_value_id        => p_input_value_id
919   ,p_object_version_number => p_object_version_number
920   );
921   if (l_api_updating and nvl(p_default_value_column, hr_api.g_varchar2) <>
922       nvl(pay_siv_shd.g_old_rec.default_value_column, hr_api.g_varchar2)) or
923      not l_api_updating
924   then
925     if p_default_value_column is not null then
926       --
927       -- Check that the default value column name is valid i.e. in the set
928       -- CONFIGURATION_INFORMATION1 .. CONFIGURATION_INFORMATION30
929       --
930       begin
931         l_len := length('CONFIGURATION_INFORMATION');
932         l_prefix := upper(substr(p_default_value_column, 1, l_len));
933         l_suffix :=
934         fnd_number.canonical_to_number(substr(p_default_value_column, l_len + 1));
935         l_suffix := nvl(l_suffix, -1);
936         if l_prefix <> 'CONFIGURATION_INFORMATION' or
937            (l_suffix < 1 or l_suffix > 30) or
938            (l_suffix <> trunc(l_suffix))
939         then
940           raise l_error;
941         end if;
942       exception
943         --
944         -- All exceptions are due to the name being in the incorrect
945         -- format.
946         --
947         when others then
948           hr_utility.set_location(' Leaving:'||l_proc, 10);
949           fnd_message.set_name('PAY', 'PAY_50130_ETM_BAD_FLEX_COLUMN');
950           fnd_message.set_token('FLEXFIELD_COLUMN', p_default_value_column);
951           fnd_message.raise_error;
952       end;
953       --
954       -- Check that the default value column does not clash with a
955       -- flexfield column on PAY_TEMPLATE_EXCLUSION_RULES.
956       --
957       open csr_default_value_clash;
958       fetch csr_default_value_clash into l_clash;
959       if csr_default_value_clash%found then
960         hr_utility.set_location(' Leaving:'||l_proc, 15);
961         close csr_default_value_clash;
962         fnd_message.set_name('PAY', 'PAY_50131_TER_SIV_CLASH');
963         fnd_message.raise_error;
964       end if;
965       close csr_default_value_clash;
966       --
967       -- Check that there are no consistency problems with the use of
968       -- this default value column.
969       --
970       open csr_inconsistent_def_val;
971       fetch csr_inconsistent_def_val into l_inconsistent;
972       if csr_inconsistent_def_val%found then
973         hr_utility.set_location(' Leaving:'||l_proc, 20);
974         close csr_inconsistent_def_val;
975         fnd_message.set_name('PAY', 'PAY_50136_SIV_DEFVAL_DIFF_UOMS');
976         fnd_message.raise_error;
977       end if;
978       close csr_inconsistent_def_val;
979     end if;
980   end if;
981   hr_utility.set_location(' Leaving:'||l_proc, 25);
982 End chk_default_value_column;
983 -- ----------------------------------------------------------------------------
984 -- |-------------------------< chk_exclusion_rule_id >------------------------|
985 -- ----------------------------------------------------------------------------
986 Procedure chk_exclusion_rule_id
987   (p_exclusion_rule_id     in     number
988   ,p_template_id           in     number
989   ,p_input_value_id        in     number
990   ,p_object_version_number in     number
991   ) is
992   --
993   -- Cursor to check that the exclusion_rule_id is valid.
994   --
995   cursor csr_exclusion_rule_id_valid is
996   select null
997   from pay_template_exclusion_rules ter
998   where ter.exclusion_rule_id = p_exclusion_rule_id
999   and   ter.template_id = p_template_id;
1000 --
1001   l_proc  varchar2(72) := g_package||'chk_exclusion_rule_id';
1002   l_api_updating boolean;
1003   l_valid        varchar2(1);
1004 --
1005 Begin
1006   hr_utility.set_location('Entering:'||l_proc, 5);
1007   l_api_updating := pay_siv_shd.api_updating
1008   (p_input_value_id        => p_input_value_id
1009   ,p_object_version_number => p_object_version_number
1010   );
1011   if (l_api_updating and nvl(p_exclusion_rule_id, hr_api.g_number) <>
1012       nvl(pay_siv_shd.g_old_rec.exclusion_rule_id, hr_api.g_number)) or
1013      not l_api_updating
1014   then
1015     if p_exclusion_rule_id is not null then
1016       open csr_exclusion_rule_id_valid;
1017       fetch csr_exclusion_rule_id_valid into l_valid;
1018       if csr_exclusion_rule_id_valid%notfound then
1019         hr_utility.set_location('Leaving:'||l_proc, 10);
1020         close csr_exclusion_rule_id_valid;
1021         fnd_message.set_name('PAY', 'PAY_50100_ETM_INVALID_EXC_RULE');
1022         fnd_message.raise_error;
1023       end if;
1024       close csr_exclusion_rule_id_valid;
1025     end if;
1026   end if;
1027   hr_utility.set_location(' Leaving:'||l_proc, 15);
1028 End chk_exclusion_rule_id;
1029 -- ----------------------------------------------------------------------------
1030 -- |------------------------------< chk_delete >------------------------------|
1031 -- ----------------------------------------------------------------------------
1032 Procedure chk_delete
1033   (p_input_value_id     in     number
1034   ) is
1035   --
1036   -- Cursors to check for rows referencing the balance classification.
1037   --
1038   cursor csr_core_objects is
1039   select null
1040   from   pay_template_core_objects tco
1041   where  tco.core_object_type = pay_tco_shd.g_siv_lookup_type
1042   and    tco.shadow_object_id = p_input_value_id;
1043   --
1044   cursor csr_balance_feeds is
1045   select null
1046   from   pay_shadow_balance_feeds sbf
1047   where  sbf.input_value_id = p_input_value_id;
1048   --
1049   cursor csr_formula_rules is
1050   select null
1051   from   pay_shadow_formula_rules sfr
1052   where  nvl(sfr.input_value_id, hr_api.g_number) = p_input_value_id;
1053   --
1054   cursor csr_iterative_rules is
1055   select null
1056   from   pay_shadow_iterative_rules sir
1057   where  sir.input_value_id = p_input_value_id;
1058 --
1059   l_proc  varchar2(72) := g_package||'chk_delete';
1060   l_error  exception;
1061   l_exists varchar2(1);
1062 --
1063 Begin
1064   hr_utility.set_location('Entering:'||l_proc, 5);
1065   --
1066   open csr_core_objects;
1067   fetch csr_core_objects into l_exists;
1068   if csr_core_objects%found then
1069     hr_utility.set_location(' Leaving:'||l_proc, 10);
1070     close csr_core_objects;
1071     raise l_error;
1072   end if;
1073   close csr_core_objects;
1074   --
1075   open csr_balance_feeds;
1076   fetch csr_balance_feeds into l_exists;
1077   if csr_balance_feeds%found then
1078     hr_utility.set_location(' Leaving:'||l_proc, 15);
1079     close csr_balance_feeds;
1080     raise l_error;
1081   end if;
1082   close csr_balance_feeds;
1083   --
1084   open csr_formula_rules;
1085   fetch csr_formula_rules into l_exists;
1086   if csr_formula_rules%found then
1087     hr_utility.set_location(' Leaving:'||l_proc, 20);
1088     close csr_formula_rules;
1089     raise l_error;
1090   end if;
1091   close csr_formula_rules;
1092   --
1093   open csr_iterative_rules;
1094   fetch csr_iterative_rules into l_exists;
1095   if csr_iterative_rules%found then
1096     hr_utility.set_location(' Leaving:'||l_proc, 25);
1097     close csr_iterative_rules;
1098     raise l_error;
1099   end if;
1100   close csr_iterative_rules;
1101   hr_utility.set_location(' Leaving:'||l_proc, 30);
1102 exception
1103   when l_error then
1104     fnd_message.set_name('PAY', 'PAY_50123_SIV_INVALID_DELETE');
1105     fnd_message.raise_error;
1106   when others then
1107     hr_utility.set_location(' Leaving:'||l_proc, 35);
1108     raise;
1109 End chk_delete;
1110 -- ----------------------------------------------------------------------------
1111 -- |--------------------------< chk_formula_id >------------------------------|
1112 -- ----------------------------------------------------------------------------
1113 Procedure chk_formula_id
1114   (p_formula_id             in     number
1115   ,p_template_id            in     number
1116   ,p_template_type          in     varchar2
1117   ,p_business_group_id      in     number
1118   ,p_legislation_code       in     varchar2
1119   ,p_input_value_id         in     number
1120   ,p_object_version_number  in     number
1121   ) is
1122 --
1123   --
1124   -- Check that the formula is valid.
1125   --
1126   -- If the shadow element belongs to a template of type 'T' then the formula
1127   -- may be shared with other templates, but the legislative domain of the
1128   -- formula must encompass that of the template.
1129 
1130   cursor csr_T_formula_valid is
1131   select null
1132   from   pay_shadow_formulas sf
1133   where  sf.formula_id = p_formula_id
1134   and    sf.template_type = 'T'
1135   and	 sf.formula_type_name = pay_sf_shd.g_input_val_formula_type
1136   and    ((sf.legislation_code is null and sf.business_group_id is null) or
1137           sf.legislation_code  = p_legislation_code or
1138           sf.business_group_id = p_business_group_id);
1139   --
1140   -- If the shadow element belongs to a template of type 'U' then the formula
1141   -- must not be shared with any other templates to avoid name clashes.
1142   --
1143   cursor csr_U_formula_valid is
1144   select null
1145   from   pay_shadow_formulas sf
1146   where  sf.formula_id = p_formula_id
1147   and    sf.template_type = 'U'
1148   and	 sf.formula_type_name = pay_sf_shd.g_input_val_formula_type
1149   and    sf.business_group_id = p_business_group_id
1150   and    not exists
1151          (select null
1152           from   pay_shadow_input_values psiv , pay_shadow_element_types pset
1153           where  psiv.formula_id = p_formula_id
1154 	  and    pset.element_type_id = psiv.element_type_id
1155           and    pset.template_id <> p_template_id);
1156 --
1157   l_proc  varchar2(72) := g_package||'chk_formula_id';
1158   l_api_updating boolean;
1159   l_valid varchar2(1);
1160 --
1161 Begin
1162 
1163   hr_utility.set_location('Entering:'||l_proc, 5);
1164 
1165   l_api_updating := pay_siv_shd.api_updating
1166   (p_input_value_id       => p_input_value_id
1167   ,p_object_version_number => p_object_version_number
1168   );
1169 
1170   if (l_api_updating and nvl(p_formula_id, hr_api.g_number) <>
1171       nvl(pay_siv_shd.g_old_rec.formula_id, hr_api.g_number)) or
1172      not l_api_updating
1173   then
1174 
1175     if p_formula_id is not null then
1176 
1177 	if p_template_type = 'T' then
1178 
1179 		open csr_T_formula_valid;
1180 	        fetch csr_T_formula_valid into l_valid;
1181 
1182 		if csr_T_formula_valid%notfound then
1183 			hr_utility.set_location(' Leaving:'||l_proc, 10);
1184 			close csr_T_formula_valid;
1185 		        fnd_message.set_name('PAY', 'PAY_33185_SIV_BAD_FORMULA');
1186 		        fnd_message.raise_error;
1187 		end if;
1188 
1189 	        close csr_T_formula_valid;
1190 
1191         elsif p_template_type = 'U' then
1192 
1193 		open csr_U_formula_valid;
1194 	        fetch csr_U_formula_valid into l_valid;
1195 
1196 		if csr_U_formula_valid%notfound then
1197 		        hr_utility.set_location(' Leaving:'||l_proc, 15);
1198 		        close csr_U_formula_valid;
1199 		        fnd_message.set_name('PAY', 'PAY_33185_SIV_BAD_FORMULA');
1200 			fnd_message.raise_error;
1201 	        end if;
1202 
1203 		close csr_U_formula_valid;
1204 	end if;
1205 
1206     end if;
1207 
1208   end if;
1209 
1210   hr_utility.set_location(' Leaving:'||l_proc, 20);
1211 
1212 End chk_formula_id;
1213 --
1214 -- ----------------------------------------------------------------------------
1215 -- |---------------------------< insert_validate >----------------------------|
1216 -- ----------------------------------------------------------------------------
1217 Procedure insert_validate
1218 (p_effective_date in date
1219 ,p_rec in out nocopy pay_siv_shd.g_rec_type
1220 ) is
1221 --
1222   l_proc  varchar2(72) := g_package||'insert_validate';
1223   l_template_id number;
1224   l_input_currency_code varchar2(256);
1225 
1226   l_business_group_id        pay_element_templates.business_group_id%type;
1227   l_legislation_code         pay_element_templates.legislation_code%type;
1228   l_template_type            pay_element_templates.template_type%type;
1229 
1230 --
1231 Begin
1232   hr_utility.set_location('Entering:'||l_proc, 5);
1233   --
1234   -- Call all supporting business operations
1235   --
1236   chk_element_type_id
1237   (p_element_type_id   => p_rec.element_type_id
1238   ,p_exclusion_rule_id => p_rec.exclusion_rule_id
1239   );
1240   --
1241   get_element_info
1242   (p_element_type_id => p_rec.element_type_id
1243   ,p_template_id     => l_template_id
1244   ,p_input_currency_code => l_input_currency_code
1245   );
1246   --
1247   get_template_info
1248   (p_template_id              => l_template_id
1249   ,p_business_group_id        => l_business_group_id
1250   ,p_legislation_code         => l_legislation_code
1251   ,p_template_type            => l_template_type
1252   );
1253   --
1254   chk_name
1255   (p_name                  => p_rec.name
1256   ,p_element_type_id       => p_rec.element_type_id
1257   ,p_input_value_id        => p_rec.input_value_id
1258   ,p_object_version_number => p_rec.object_version_number
1259   );
1260   --
1261   chk_display_sequence
1262   (p_display_sequence      => p_rec.display_sequence
1263   ,p_input_value_id        => p_rec.input_value_id
1264   ,p_object_version_number => p_rec.object_version_number
1265   );
1266   --
1267   chk_lookups
1268   (p_effective_date         => p_effective_date
1269   ,p_generate_db_items_flag => p_rec.generate_db_items_flag
1270   ,p_hot_default_flag       => p_rec.hot_default_flag
1271   ,p_mandatory_flag         => p_rec.mandatory_flag
1272   ,p_uom                    => p_rec.uom
1273   ,p_warning_or_error       => p_rec.warning_or_error
1274   ,p_input_value_id         => p_rec.input_value_id
1275   ,p_object_version_number  => p_rec.object_version_number
1276   );
1277   --
1278   chk_lookup_type
1279   (p_effective_date        => p_effective_date
1280   ,p_lookup_type           => p_rec.lookup_type
1281   ,p_uom                   => p_rec.uom
1282   ,p_default_value         => p_rec.default_value
1283   ,p_input_value_id        => p_rec.input_value_id
1284   ,p_object_version_number => p_rec.object_version_number
1285   );
1286   --
1287   chk_values
1288   (p_effective_date		=> p_effective_date
1289   ,p_input_currency_code	=> l_input_currency_code
1290   ,p_lookup_type		=> p_rec.lookup_type
1291   ,p_uom			=> p_rec.uom
1292   ,p_default_value		=> p_rec.default_value
1293   ,p_min_value			=> p_rec.min_value
1294   ,p_max_value			=> p_rec.max_value
1295   ,p_input_value_id		=> p_rec.input_value_id
1296   ,p_formula_id			=> p_rec.formula_id
1297   ,p_input_validation_formula	=> p_rec.input_validation_formula
1298   ,p_object_version_number	=> p_rec.object_version_number
1299   );
1300   --
1301   chk_default_value_column
1302   (p_default_value_column  => p_rec.default_value_column
1303   ,p_template_id           => l_template_id
1304   ,p_uom                   => p_rec.uom
1305   ,p_lookup_type           => p_rec.lookup_type
1306   ,p_input_value_id        => p_rec.input_value_id
1307   ,p_object_version_number => p_rec.object_version_number
1308   );
1309   --
1310   chk_exclusion_rule_id
1311   (p_exclusion_rule_id     => p_rec.exclusion_rule_id
1312   ,p_template_id           => l_template_id
1313   ,p_input_value_id        => p_rec.input_value_id
1314   ,p_object_version_number => p_rec.object_version_number
1315   );
1316   --
1317   chk_formula_id
1318   (p_formula_id            => p_rec.formula_id
1319   ,p_template_id           => l_template_id
1320   ,p_template_type         => l_template_type
1321   ,p_business_group_id     => l_business_group_id
1322   ,p_legislation_code      => l_legislation_code
1323   ,p_input_value_id        => p_rec.input_value_id
1324   ,p_object_version_number => p_rec.object_version_number
1325   );
1326   --
1327   hr_utility.set_location(' Leaving:'||l_proc, 10);
1328 End insert_validate;
1329 --
1330 -- ----------------------------------------------------------------------------
1331 -- |---------------------------< update_validate >----------------------------|
1332 -- ----------------------------------------------------------------------------
1333 Procedure update_validate
1334 (p_effective_date in date
1335 ,p_rec in out nocopy pay_siv_shd.g_rec_type
1336 ) is
1337 --
1338   l_proc  varchar2(72) := g_package||'update_validate';
1339   l_template_id number;
1340   l_input_currency_code varchar2(256);
1341 
1342   l_business_group_id        pay_element_templates.business_group_id%type;
1343   l_legislation_code         pay_element_templates.legislation_code%type;
1344   l_template_type            pay_element_templates.template_type%type;
1345 
1346 --
1347 Begin
1348   hr_utility.set_location('Entering:'||l_proc, 5);
1349   --
1350   -- Call all supporting business operations
1351   --
1352   get_element_info
1353   (p_element_type_id => p_rec.element_type_id
1354   ,p_template_id     => l_template_id
1355   ,p_input_currency_code => l_input_currency_code
1356   );
1357   --
1358   get_template_info
1359   (p_template_id              => l_template_id
1360   ,p_business_group_id        => l_business_group_id
1361   ,p_legislation_code         => l_legislation_code
1362   ,p_template_type            => l_template_type
1363   );
1364   --
1365   chk_non_updateable_args(p_rec);
1366   --
1367   chk_name
1368   (p_name                  => p_rec.name
1369   ,p_element_type_id       => p_rec.element_type_id
1370   ,p_input_value_id        => p_rec.input_value_id
1371   ,p_object_version_number => p_rec.object_version_number
1372   );
1373   --
1374   chk_display_sequence
1375   (p_display_sequence      => p_rec.display_sequence
1376   ,p_input_value_id        => p_rec.input_value_id
1377   ,p_object_version_number => p_rec.object_version_number
1378   );
1379   --
1380   chk_lookups
1381   (p_effective_date         => p_effective_date
1382   ,p_generate_db_items_flag => p_rec.generate_db_items_flag
1383   ,p_hot_default_flag       => p_rec.hot_default_flag
1384   ,p_mandatory_flag         => p_rec.mandatory_flag
1385   ,p_uom                    => p_rec.uom
1386   ,p_warning_or_error       => p_rec.warning_or_error
1387   ,p_input_value_id         => p_rec.input_value_id
1388   ,p_object_version_number  => p_rec.object_version_number
1389   );
1390   --
1391   chk_lookup_type
1392   (p_effective_date        => p_effective_date
1393   ,p_lookup_type           => p_rec.lookup_type
1394   ,p_uom                   => p_rec.uom
1395   ,p_default_value         => p_rec.default_value
1396   ,p_input_value_id        => p_rec.input_value_id
1397   ,p_object_version_number => p_rec.object_version_number
1398   );
1399   --
1400   chk_values
1401   (p_effective_date		=> p_effective_date
1402   ,p_input_currency_code	=> l_input_currency_code
1403   ,p_lookup_type		=> p_rec.lookup_type
1404   ,p_uom			=> p_rec.uom
1405   ,p_default_value		=> p_rec.default_value
1406   ,p_min_value			=> p_rec.min_value
1407   ,p_max_value			=> p_rec.max_value
1408   ,p_input_value_id		=> p_rec.input_value_id
1409   ,p_formula_id			=> p_rec.formula_id
1410   ,p_input_validation_formula	=> p_rec.input_validation_formula
1411   ,p_object_version_number	=> p_rec.object_version_number
1412   );
1413   --
1414   chk_default_value_column
1415   (p_default_value_column  => p_rec.default_value_column
1416   ,p_template_id           => l_template_id
1417   ,p_uom                   => p_rec.uom
1418   ,p_lookup_type           => p_rec.lookup_type
1419   ,p_input_value_id        => p_rec.input_value_id
1420   ,p_object_version_number => p_rec.object_version_number
1421   );
1422   --
1423   chk_exclusion_rule_id
1424   (p_exclusion_rule_id     => p_rec.exclusion_rule_id
1425   ,p_template_id           => l_template_id
1426   ,p_input_value_id        => p_rec.input_value_id
1427   ,p_object_version_number => p_rec.object_version_number
1428   );
1429   --
1430   chk_formula_id
1431   (p_formula_id            => p_rec.formula_id
1432   ,p_template_id           => l_template_id
1433   ,p_template_type         => l_template_type
1434   ,p_business_group_id     => l_business_group_id
1435   ,p_legislation_code      => l_legislation_code
1436   ,p_input_value_id        => p_rec.input_value_id
1437   ,p_object_version_number => p_rec.object_version_number
1438   );
1439   --
1440   hr_utility.set_location(' Leaving:'||l_proc, 10);
1441 End update_validate;
1442 --
1443 -- ----------------------------------------------------------------------------
1444 -- |---------------------------< delete_validate >----------------------------|
1445 -- ----------------------------------------------------------------------------
1446 Procedure delete_validate(p_rec in pay_siv_shd.g_rec_type) is
1447 --
1448   l_proc  varchar2(72) := g_package||'delete_validate';
1449 --
1450 Begin
1451   hr_utility.set_location('Entering:'||l_proc, 5);
1452   --
1453   -- Call all supporting business operations
1454   --
1455   chk_delete(p_rec.input_value_id);
1456   --
1457   hr_utility.set_location(' Leaving:'||l_proc, 10);
1458 End delete_validate;
1459 --
1460 end pay_siv_bus;