DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_SBA_BUS

Source


1 Package Body pay_sba_bus as
2 /* $Header: pysbarhi.pkb 120.0 2005/05/29 08:33 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_sba_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 -- ----------------------------------------------------------------------------
14 -- |-----------------------< chk_non_updateable_args >------------------------|
15 -- ----------------------------------------------------------------------------
16 -- {Start Of Comments}
17 --
18 -- Description:
19 --   This procedure is used to ensure that non updateable attributes have
20 --   not been updated. If an attribute has been updated an error is generated.
21 --
22 -- Pre Conditions:
23 --   g_old_rec has been populated with details of the values currently in
24 --   the database.
25 --
26 -- In Arguments:
27 --   p_rec has been populated with the updated values the user would like the
28 --   record set to.
29 --
30 -- Post Success:
31 --   Processing continues if all the non updateable attributes have not
32 --   changed.
33 --
34 -- Post Failure:
35 --   An application error is raised if any of the non updatable attributes
36 --   have been altered.
37 --
38 -- {End Of Comments}
39 -- ----------------------------------------------------------------------------
40 Procedure chk_non_updateable_args
41   (p_rec     in     pay_sba_shd.g_rec_type
42   ) is
43   --
44   -- Cursor to disallow update if a core defined balance has been
45   -- generated from this shadow defined balance.
46   --
47   cursor csr_disallow_update is
48   select null
49   from   pay_template_core_objects tco
50   where  tco.core_object_type = pay_tco_shd.g_sba_lookup_type
51   and    tco.shadow_object_id = p_rec.balance_attribute_id;
52 --
53   l_proc  varchar2(72) := g_package||'chk_non_updateable_args';
54   l_updating boolean;
55   l_argument varchar2(30);
56   l_api_updating boolean;
57   l_disallow varchar2(1);
58 --
59 Begin
60   hr_utility.set_location('Entering:'||l_proc, 5);
61   l_api_updating := pay_sba_shd.api_updating
62     (p_balance_attribute_id    => p_rec.balance_attribute_id
63     ,p_object_version_number   => p_rec.object_version_number
64     );
65   if not l_api_updating then
66     hr_utility.set_message(801,'HR_6153_ALL_PROCEDURE_FAIL');
67     hr_utility.set_message_token('PROCEDURE', l_proc);
68     hr_utility.set_message_token('STEP', '10');
69     hr_utility.raise_error;
70   end if;
71   --
72   hr_utility.set_location(l_proc, 15);
73   --
74   -- Check that the update is actually allowed.
75   --
76   open csr_disallow_update;
77   fetch csr_disallow_update into l_disallow;
78   if csr_disallow_update%found then
79     hr_utility.set_location(l_proc, 20);
80     close csr_disallow_update;
81     fnd_message.set_name('PAY', 'PAY_50202_SBA_CORE_ROW_EXISTS');
82     fnd_message.raise_error;
83   end if;
84   close csr_disallow_update;
85   hr_utility.set_location(' Leaving:'||l_proc, 25);
86 exception
87     when others then
88        hr_utility.set_location('Leaving:'||l_proc, 35);
89        raise;
90 End chk_non_updateable_args;
91 -- ----------------------------------------------------------------------------
92 -- |-------------------------< chk_exclusion_rule_id >------------------------|
93 -- ----------------------------------------------------------------------------
94 Procedure chk_exclusion_rule_id
95   (p_exclusion_rule_id     in     number
96   ,p_defined_balance_id    in     number
97   ,p_balance_attribute_id  in     number
98   ,p_object_version_number in     number
99   ) is
100   --
101   -- Cursor to check that the exclusion_rule_id is valid.
102   --
103   cursor csr_exclusion_rule_id_valid is
104   select null
105   from  pay_template_exclusion_rules ter
106   ,     pay_shadow_balance_types bt
107   ,     pay_shadow_defined_balances db
108   where db.defined_balance_id = p_defined_balance_id
109   and   bt.balance_type_id    = db.balance_type_id
110   and   ter.exclusion_rule_id = p_exclusion_rule_id
111   and   ter.template_id = bt.template_id
112   ;
113 --
114   l_proc  varchar2(72) := g_package||'chk_exclusion_rule_id';
115   l_api_updating boolean;
116   l_valid        varchar2(1);
117 --
118 Begin
119   hr_utility.set_location('Entering:'||l_proc, 5);
120   l_api_updating := pay_sba_shd.api_updating
121   (p_balance_attribute_id  => p_balance_attribute_id
122   ,p_object_version_number => p_object_version_number
123   );
124   if (l_api_updating and nvl(p_exclusion_rule_id, hr_api.g_number) <>
125       nvl(pay_sba_shd.g_old_rec.exclusion_rule_id, hr_api.g_number)) or
126      not l_api_updating
127   then
128     if p_exclusion_rule_id is not null then
129       open csr_exclusion_rule_id_valid;
130       fetch csr_exclusion_rule_id_valid into l_valid;
131       if csr_exclusion_rule_id_valid%notfound then
132         hr_utility.set_location('Leaving:'||l_proc, 10);
133         close csr_exclusion_rule_id_valid;
134         fnd_message.set_name('PAY', 'PAY_50100_ETM_INVALID_EXC_RULE');
135         fnd_message.raise_error;
136       end if;
137       close csr_exclusion_rule_id_valid;
138     end if;
139   end if;
140   hr_utility.set_location('Leaving:'||l_proc, 5);
141 end chk_exclusion_rule_id;
142 -- ----------------------------------------------------------------------------
143 -- |------------------------< chk_defined_balance_id >-------------------------|
144 -- ----------------------------------------------------------------------------
145 Procedure chk_defined_balance_id
146   (p_defined_balance_id     in     number
147   ) is
148   --
149   -- Cursor to check that the balance type exists.
150   --
151   cursor csr_defined_balance_exists is
152   select null
153   from   pay_shadow_defined_balances sdb
154   where  sdb.defined_balance_id = p_defined_balance_id;
155 --
156   l_proc  varchar2(72) := g_package||'chk_defined_balance_id';
157   l_exists varchar2(1);
158 --
159 Begin
160   hr_utility.set_location('Entering:'||l_proc, 5);
161   --
162   -- Check that the balance type is not null.
163   --
164   hr_api.mandatory_arg_error
165   (p_api_name       => l_proc
166   ,p_argument       => 'p_defined_balance_id'
167   ,p_argument_value => p_defined_balance_id
168   );
169   --
170   -- Check that the balance type exists.
171   --
172   open csr_defined_balance_exists;
173   fetch csr_defined_balance_exists into l_exists;
174   if csr_defined_balance_exists%notfound then
175     hr_utility.set_location(' Leaving:'||l_proc, 10);
176     close csr_defined_balance_exists;
177     fnd_message.set_name('PAY', 'PAY_50203_ETM_INVALID_DEF_BAL');
178     fnd_message.raise_error;
179   end if;
180   close csr_defined_balance_exists;
181   hr_utility.set_location(' Leaving:'||l_proc, 15);
182 End chk_defined_balance_id;
183 -- ----------------------------------------------------------------------------
184 -- |--------------------------< chk_attribute_name >--------------------------|
185 -- ----------------------------------------------------------------------------
186 Procedure chk_attribute_name
187   (p_attribute_name        in     varchar2
188   ,p_defined_balance_id    in     number
189   ,p_balance_attribute_id  in     number
190   ,p_object_version_number in     number
191   ) is
192   --
193   -- Cursor to check the combination of attribute name and defined balance
194   -- is unique.
195   --
196   cursor csr_balance_attribute_exists is
197   select null
198   from   pay_shadow_bal_attributes sba
199   where  sba.defined_balance_id = p_defined_balance_id
200   and    upper(sba.attribute_name) = upper(p_attribute_name);
201 --
202   l_proc  varchar2(72) := g_package||'chk_attribute_name';
203   l_api_updating boolean;
204   l_exists       varchar2(1);
205 --
206 Begin
207   hr_utility.set_location('Entering:'||l_proc, 5);
208   l_api_updating := pay_sba_shd.api_updating
209   (p_balance_attribute_id  => p_balance_attribute_id
210   ,p_object_version_number => p_object_version_number
211   );
212   if (l_api_updating and nvl(p_attribute_name, hr_api.g_varchar2)
213      <> nvl(pay_sba_shd.g_old_rec.attribute_name, hr_api.g_varchar2))
214      or not l_api_updating
215   then
216     --
217     -- Check that the attribute name is not null.
218     --
219     hr_api.mandatory_arg_error
220     (p_api_name       => l_proc
221     ,p_argument       => 'p_attribute_name'
222     ,p_argument_value => p_attribute_name
223     );
224     --
225     -- Check that the defined balance is unique.
226     --
227     open csr_balance_attribute_exists;
228     fetch csr_balance_attribute_exists into l_exists;
229     if csr_balance_attribute_exists%found then
230       hr_utility.set_location(' Leaving:'||l_proc, 10);
231       close csr_balance_attribute_exists;
232       fnd_message.set_name('PAY', 'PAY_50205_SBA_BAL_ATTR_EXISTS');
233       fnd_message.raise_error;
234     end if;
235     close csr_balance_attribute_exists;
236   end if;
237   hr_utility.set_location(' Leaving:'||l_proc, 25);
238 End chk_attribute_name;
239 -- ----------------------------------------------------------------------------
240 -- |------------------------------< chk_delete >------------------------------|
241 -- ----------------------------------------------------------------------------
242 Procedure chk_delete
243   (p_balance_attribute_id     in     number
244   ) is
245   --
246   -- Cursors to check for rows referencing the balance classification.
247   --
248   cursor csr_core_objects is
249   select null
250   from   pay_template_core_objects tco
251   where  tco.core_object_type = pay_tco_shd.g_sba_lookup_type
252   and    tco.shadow_object_id = p_balance_attribute_id;
253 --
254   l_proc  varchar2(72) := g_package||'chk_delete';
255   l_error  exception;
256   l_exists varchar2(1);
257 --
258 Begin
259   hr_utility.set_location('Entering:'||l_proc, 5);
260   --
261   open csr_core_objects;
262   fetch csr_core_objects into l_exists;
263   if csr_core_objects%found then
264     hr_utility.set_location(' Leaving:'||l_proc, 10);
265     close csr_core_objects;
266     raise l_error;
267   end if;
268   close csr_core_objects;
269   hr_utility.set_location(' Leaving:'||l_proc, 15);
270 exception
271   when l_error then
272     fnd_message.set_name('PAY', 'PAY_50204_SBA_INVALID_DELETE');
273     fnd_message.raise_error;
274   when others then
275     hr_utility.set_location(' Leaving:'||l_proc, 20);
276     raise;
277 End chk_delete;
278 --
279 -- ----------------------------------------------------------------------------
280 -- |---------------------------< insert_validate >----------------------------|
281 -- ----------------------------------------------------------------------------
282 Procedure insert_validate
283   (p_rec                          in pay_sba_shd.g_rec_type
284   ) is
285 --
286   l_proc  varchar2(72) := g_package||'insert_validate';
287 --
288 Begin
289   hr_utility.set_location('Entering:'||l_proc, 5);
290   --
291   -- Call all supporting business operations
292   --
293   -- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS.
294   --
295   -- Validate Dependent Attributes
296   --
297   --
298   chk_attribute_name
299   (p_attribute_name        => p_rec.attribute_name
300   ,p_defined_balance_id    => p_rec.defined_balance_id
301   ,p_balance_attribute_id  => p_rec.balance_attribute_id
302   ,p_object_version_number => p_rec.object_version_number
303   );
304   chk_defined_balance_id
305   (p_defined_balance_id => p_rec.defined_balance_id
306   );
307   chk_exclusion_rule_id
308   (p_exclusion_rule_id     => p_rec.exclusion_rule_id
309   ,p_defined_balance_id    => p_rec.defined_balance_id
310   ,p_balance_attribute_id  => p_rec.balance_attribute_id
311   ,p_object_version_number => p_rec.object_version_number
312   );
313   hr_utility.set_location(' Leaving:'||l_proc, 10);
314 End insert_validate;
315 --
316 -- ----------------------------------------------------------------------------
317 -- |---------------------------< update_validate >----------------------------|
318 -- ----------------------------------------------------------------------------
319 Procedure update_validate
320   (p_rec                          in pay_sba_shd.g_rec_type
321   ) is
322 --
323   l_proc  varchar2(72) := g_package||'update_validate';
324 --
325 Begin
326   hr_utility.set_location('Entering:'||l_proc, 5);
327   --
328   -- Call all supporting business operations
329   --
330   -- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS.
331   --
332   -- Validate Dependent Attributes
333   --
334   chk_non_updateable_args(p_rec => p_rec);
335   --
336   --
337   chk_attribute_name
338   (p_attribute_name        => p_rec.attribute_name
339   ,p_defined_balance_id    => p_rec.defined_balance_id
340   ,p_balance_attribute_id  => p_rec.balance_attribute_id
341   ,p_object_version_number => p_rec.object_version_number
342   );
343   chk_defined_balance_id
344   (p_defined_balance_id => p_rec.defined_balance_id
345   );
346   chk_exclusion_rule_id
347   (p_exclusion_rule_id     => p_rec.exclusion_rule_id
348   ,p_defined_balance_id    => p_rec.defined_balance_id
349   ,p_balance_attribute_id  => p_rec.balance_attribute_id
350   ,p_object_version_number => p_rec.object_version_number
351   );
352   hr_utility.set_location(' Leaving:'||l_proc, 10);
353 End update_validate;
354 --
355 -- ----------------------------------------------------------------------------
356 -- |---------------------------< delete_validate >----------------------------|
357 -- ----------------------------------------------------------------------------
358 Procedure delete_validate
359   (p_rec                          in pay_sba_shd.g_rec_type
360   ) is
361 --
362   l_proc  varchar2(72) := g_package||'delete_validate';
363 --
364 Begin
365   hr_utility.set_location('Entering:'||l_proc, 5);
366   --
367   -- Call all supporting business operations
368   --
369   chk_delete
370   (p_balance_attribute_id => p_rec.balance_attribute_id
371   );
372   hr_utility.set_location(' Leaving:'||l_proc, 10);
373 End delete_validate;
374 --
375 end pay_sba_bus;