DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_SBC_BUS

Source


1 Package Body pay_sbc_bus as
2 /* $Header: pysbcrhi.pkb 120.0 2005/05/29 08:33:44 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_sbc_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |-----------------------< chk_non_updateable_args >------------------------|
12 -- ----------------------------------------------------------------------------
13 Procedure chk_non_updateable_args
14   (p_rec     in     pay_sbc_shd.g_rec_type
15   ) is
16   --
17   -- Cursor to disallow update if a core balance classification has been
18   -- generated from this shadow balance classification.
19   --
20   cursor csr_disallow_update is
21   select null
22   from   pay_template_core_objects tco
23   where  tco.core_object_type = pay_tco_shd.g_sbc_lookup_type
24   and    tco.shadow_object_id = p_rec.balance_classification_id;
25 --
26   l_proc  varchar2(72) := g_package||'chk_non_updateable_args';
27   l_updating boolean;
28   l_error    exception;
29   l_argument varchar2(30);
30   l_api_updating boolean;
31   l_disallow     varchar2(1);
32 --
33 Begin
34   hr_utility.set_location('Entering:'||l_proc, 5);
35   l_api_updating := pay_sbc_shd.api_updating
36     (p_balance_classification_id => p_rec.balance_classification_id
37     ,p_object_version_number     => p_rec.object_version_number
38     );
39   if not l_api_updating then
40     hr_utility.set_message(801,'HR_6153_ALL_PROCEDURE_FAIL');
41     hr_utility.set_message_token('PROCEDURE', l_proc);
42     hr_utility.set_message_token('STEP', '10');
43     hr_utility.raise_error;
44   end if;
45   --
46   hr_utility.set_location(l_proc, 15);
47   --
48   -- Check that the update is actually allowed.
49   --
50   open csr_disallow_update;
51   fetch csr_disallow_update into l_disallow;
52   if csr_disallow_update%found then
53     hr_utility.set_location(l_proc, 20);
54     close csr_disallow_update;
55     fnd_message.set_name('PAY', 'PAY_50085_SBC_CORE_ROW_EXISTS');
56     fnd_message.raise_error;
57   end if;
58   close csr_disallow_update;
59   --
60   -- p_balance_type_id
61   --
62   if nvl(p_rec.balance_type_id, hr_api.g_number) <>
63      nvl(pay_sbc_shd.g_old_rec.balance_type_id, hr_api.g_number)
64   then
65     hr_utility.set_location(l_proc, 20);
66     l_argument := 'p_balance_type_id';
67     raise l_error;
68   end if;
69   hr_utility.set_location(' Leaving:'||l_proc, 25);
70 exception
71     when l_error then
72        hr_utility.set_location('Leaving:'||l_proc, 30);
73        hr_api.argument_changed_error
74          (p_api_name => l_proc
75          ,p_argument => l_argument);
76     when others then
77        hr_utility.set_location('Leaving:'||l_proc, 35);
78        raise;
79 End chk_non_updateable_args;
80 -- ----------------------------------------------------------------------------
81 -- |-------------------------< chk_exclusion_rule_id >------------------------|
82 -- ----------------------------------------------------------------------------
83 Procedure chk_exclusion_rule_id
84   (p_exclusion_rule_id         in     number
85   ,p_balance_type_id           in     number
86   ,p_balance_classification_id in     number
87   ,p_object_version_number     in     number
88   ) is
89   --
90   -- Cursor to check that the exclusion_rule_id is valid.
91   --
92   cursor csr_exclusion_rule_id_valid is
93   select null
94   from  pay_template_exclusion_rules ter
95   ,     pay_shadow_balance_types bt
96   where bt.balance_type_id = p_balance_type_id
97   and   ter.exclusion_rule_id = p_exclusion_rule_id
98   and   ter.template_id = bt.template_id
99   ;
100 --
101   l_proc  varchar2(72) := g_package||'chk_exclusion_rule_id';
102   l_api_updating boolean;
103   l_valid        varchar2(1);
104 --
105 Begin
106   hr_utility.set_location('Entering:'||l_proc, 5);
107   l_api_updating := pay_sbc_shd.api_updating
108   (p_balance_classification_id => p_balance_classification_id
109   ,p_object_version_number     => p_object_version_number
110   );
111   if (l_api_updating and nvl(p_exclusion_rule_id, hr_api.g_number) <>
112       nvl(pay_sbc_shd.g_old_rec.exclusion_rule_id, hr_api.g_number)) or
113      not l_api_updating
114   then
115     if p_exclusion_rule_id is not null then
116       open csr_exclusion_rule_id_valid;
117       fetch csr_exclusion_rule_id_valid into l_valid;
118       if csr_exclusion_rule_id_valid%notfound then
119         hr_utility.set_location('Leaving:'||l_proc, 10);
120         close csr_exclusion_rule_id_valid;
121         fnd_message.set_name('PAY', 'PAY_50100_ETM_INVALID_EXC_RULE');
122         fnd_message.raise_error;
123       end if;
124       close csr_exclusion_rule_id_valid;
125     end if;
126   end if;
127   hr_utility.set_location('Leaving:'||l_proc, 5);
128 end chk_exclusion_rule_id;
129 -- ----------------------------------------------------------------------------
130 -- |--------------------------< chk_balance_type_id >-------------------------|
131 -- ----------------------------------------------------------------------------
132 Procedure chk_balance_type_id
133   (p_balance_type_id     in     number
134   ) is
135   --
136   -- Cursor to check that the balance type exists.
137   --
138   cursor csr_balance_type_exists is
139   select null
140   from   pay_shadow_balance_types sbt
141   where  sbt.balance_type_id = p_balance_type_id;
142 --
143   l_proc  varchar2(72) := g_package||'chk_balance_type_id';
144   l_exists varchar2(1);
145 --
146 Begin
147   hr_utility.set_location('Entering:'||l_proc, 5);
148   --
149   -- Check that the balance type is not null.
150   --
151   hr_api.mandatory_arg_error
152   (p_api_name       => l_proc
153   ,p_argument       => 'p_balance_type_id'
154   ,p_argument_value => p_balance_type_id
155   );
156   --
157   -- Check that the balance type exists.
158   --
159   open csr_balance_type_exists;
160   fetch csr_balance_type_exists into l_exists;
161   if csr_balance_type_exists%notfound then
162     hr_utility.set_location(' Leaving:'||l_proc, 10);
163     close csr_balance_type_exists;
164     fnd_message.set_name('PAY', 'PAY_50086_ETM_INVALID_BAL_TYPE');
165     fnd_message.raise_error;
166   end if;
167   close csr_balance_type_exists;
168   hr_utility.set_location(' Leaving:'||l_proc, 15);
169 End chk_balance_type_id;
170 -- ----------------------------------------------------------------------------
171 -- |------------------------< chk_ele_classification >------------------------|
172 -- ----------------------------------------------------------------------------
173 Procedure chk_ele_classification
174   (p_element_classification      in     varchar2
175   ,p_balance_type_id             in     number
176   ,p_balance_classification_id   in     number
177   ,p_object_version_number       in     number
178   ) is
179   --
180   -- Cursor to check the combination of element classification and
181   -- balance type is unique.
182   --
183   cursor csr_bal_class_exists is
184   select null
185   from   pay_shadow_balance_classi sbc
186   where  sbc.balance_type_id = p_balance_type_id
187   and    upper(sbc.element_classification) = upper(p_element_classification);
188 --
189   l_proc  varchar2(72) := g_package||'chk_ele_classification';
190   l_api_updating boolean;
191   l_exists       varchar2(1);
192 --
193 Begin
194   hr_utility.set_location('Entering:'||l_proc, 5);
195   l_api_updating := pay_sbc_shd.api_updating
196   (p_balance_classification_id => p_balance_classification_id
197   ,p_object_version_number     => p_object_version_number
198   );
199   if (l_api_updating and nvl(p_element_classification, hr_api.g_varchar2)
200      <> nvl(pay_sbc_shd.g_old_rec.element_classification, hr_api.g_varchar2))
201      or not l_api_updating
202   then
203     --
204     -- Check that the element classification is not null.
205     --
206     hr_api.mandatory_arg_error
207     (p_api_name       => l_proc
208     ,p_argument       => 'p_element_classification'
209     ,p_argument_value => p_element_classification
210     );
211     --
212     -- Check that the balance classification is unique.
213     --
214     open csr_bal_class_exists;
215     fetch csr_bal_class_exists into l_exists;
216     if csr_bal_class_exists%found then
217       hr_utility.set_location(' Leaving:'||l_proc, 10);
218       close csr_bal_class_exists;
219       fnd_message.set_name('PAY', 'PAY_50087_SBC_BAL_CLASS_EXISTS');
220       fnd_message.raise_error;
221     end if;
222     close csr_bal_class_exists;
223   end if;
224   hr_utility.set_location(' Leaving:'||l_proc, 25);
225 End chk_ele_classification;
226 -- ----------------------------------------------------------------------------
227 -- |------------------------------< chk_delete >------------------------------|
228 -- ----------------------------------------------------------------------------
229 Procedure chk_delete
230   (p_balance_classification_id     in     number
231   ) is
232   --
233   -- Cursors to check for rows referencing the balance classification.
234   --
235   cursor csr_core_objects is
236   select null
237   from   pay_template_core_objects tco
238   where  tco.core_object_type = pay_tco_shd.g_sbc_lookup_type
239   and    tco.shadow_object_id = p_balance_classification_id;
240 --
241   l_proc  varchar2(72) := g_package||'chk_delete';
242   l_error  exception;
243   l_exists varchar2(1);
244 --
245 Begin
246   hr_utility.set_location('Entering:'||l_proc, 5);
247   --
248   open csr_core_objects;
249   fetch csr_core_objects into l_exists;
250   if csr_core_objects%found then
251     hr_utility.set_location(' Leaving:'||l_proc, 10);
252     close csr_core_objects;
253     raise l_error;
254   end if;
255   close csr_core_objects;
256   hr_utility.set_location(' Leaving:'||l_proc, 15);
257 exception
258   when l_error then
259     fnd_message.set_name('PAY', 'PAY_50088_SBC_INVALID_DELETE');
260     fnd_message.raise_error;
261   when others then
262     hr_utility.set_location(' Leaving:'||l_proc, 20);
263     raise;
264 End chk_delete;
265 -- ----------------------------------------------------------------------------
266 -- |-----------------------------< chk_scale >--------------------------------|
267 -- ----------------------------------------------------------------------------
268 Procedure chk_scale
269   (p_scale                     in number
270   ,p_balance_classification_id in number
271   ,p_object_version_number     in number
272   ) is
273   l_proc  varchar2(72) := g_package||'chk_scale';
274   l_api_updating boolean;
275 --
276 Begin
277   hr_utility.set_location('Entering:'||l_proc, 5);
278   l_api_updating := pay_sbc_shd.api_updating
279   (p_balance_classification_id => p_balance_classification_id
280   ,p_object_version_number     => p_object_version_number
281   );
282   if (l_api_updating and nvl(p_scale, hr_api.g_number) <>
283       nvl(pay_sbc_shd.g_old_rec.scale, hr_api.g_number)) or
284       not l_api_updating
285   then
286     --
287     -- Check that scale is not null.
288     --
289     hr_api.mandatory_arg_error
290     (p_api_name       => l_proc
291     ,p_argument       => 'p_scale'
292     ,p_argument_value => p_scale
293     );
294     --
295     -- Check that scale is valid.
296     --
297     if p_scale <> 1 and p_scale <> -1 then
298       hr_utility.set_location(' Leaving:'||l_proc, 10);
299       fnd_message.set_name('PAY', 'PAY_50089_ETM_INVALID_SCALE');
300       fnd_message.set_token('POSITIVE', 1);
301       fnd_message.set_token('NEGATIVE', -1);
302       fnd_message.raise_error;
303     end if;
304   end if;
305   hr_utility.set_location(' Leaving:'||l_proc, 15);
306 End chk_scale;
307 -- ----------------------------------------------------------------------------
308 -- |---------------------------< insert_validate >----------------------------|
309 -- ----------------------------------------------------------------------------
310 Procedure insert_validate(p_rec in pay_sbc_shd.g_rec_type) is
311 --
312   l_proc  varchar2(72) := g_package||'insert_validate';
313   l_template_id number;
314 --
315 Begin
316   hr_utility.set_location('Entering:'||l_proc, 5);
317   --
318   -- Call all supporting business operations
319   --
320   chk_balance_type_id(p_balance_type_id => p_rec.balance_type_id);
321   --
322   chk_ele_classification
323   (p_element_classification    => p_rec.element_classification
324   ,p_balance_type_id           => p_rec.balance_type_id
325   ,p_balance_classification_id => p_rec.balance_classification_id
326   ,p_object_version_number     => p_rec.object_version_number
327   );
328   --
329   chk_scale
330   (p_scale                     => p_rec.scale
331   ,p_balance_classification_id => p_rec.balance_classification_id
332   ,p_object_version_number     => p_rec.object_version_number
333   );
334   --
335   chk_exclusion_rule_id
336   (p_exclusion_rule_id         => p_rec.exclusion_rule_id
337   ,p_balance_type_id           => p_rec.balance_type_id
338   ,p_balance_classification_id => p_rec.balance_classification_id
339   ,p_object_version_number     => p_rec.object_version_number
340   );
341   hr_utility.set_location(' Leaving:'||l_proc, 10);
342 End insert_validate;
343 --
344 -- ----------------------------------------------------------------------------
345 -- |---------------------------< update_validate >----------------------------|
346 -- ----------------------------------------------------------------------------
347 Procedure update_validate(p_rec in pay_sbc_shd.g_rec_type) is
348 --
349   l_proc  varchar2(72) := g_package||'update_validate';
350 --
351 Begin
352   hr_utility.set_location('Entering:'||l_proc, 5);
353   --
354   -- Call all supporting business operations
355   --
356   chk_non_updateable_args(p_rec);
357   --
358   chk_ele_classification
359   (p_element_classification    => p_rec.element_classification
360   ,p_balance_type_id           => p_rec.balance_type_id
361   ,p_balance_classification_id => p_rec.balance_classification_id
362   ,p_object_version_number     => p_rec.object_version_number
363   );
364   --
365   chk_scale
366   (p_scale                     => p_rec.scale
367   ,p_balance_classification_id => p_rec.balance_classification_id
368   ,p_object_version_number     => p_rec.object_version_number
369   );
370   --
371   chk_exclusion_rule_id
372   (p_exclusion_rule_id         => p_rec.exclusion_rule_id
373   ,p_balance_type_id           => p_rec.balance_type_id
374   ,p_balance_classification_id => p_rec.balance_classification_id
375   ,p_object_version_number     => p_rec.object_version_number
376   );
377   hr_utility.set_location(' Leaving:'||l_proc, 10);
378 End update_validate;
379 --
380 -- ----------------------------------------------------------------------------
381 -- |---------------------------< delete_validate >----------------------------|
382 -- ----------------------------------------------------------------------------
383 Procedure delete_validate(p_rec in pay_sbc_shd.g_rec_type) is
384 --
385   l_proc  varchar2(72) := g_package||'delete_validate';
386 --
387 Begin
388   hr_utility.set_location('Entering:'||l_proc, 5);
389   --
390   -- Call all supporting business operations
391   --
392   chk_delete(p_rec.balance_classification_id);
393   --
394   hr_utility.set_location(' Leaving:'||l_proc, 10);
395 End delete_validate;
396 --
397 end pay_sbc_bus;