DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_SSR_BUS

Source


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