[Home] [Help]
PACKAGE BODY: APPS.PAY_SGB_BUS
Source
1 Package Body pay_sgb_bus as
2 /* $Header: pysgbrhi.pkb 115.3 2003/02/05 17:11:07 arashid noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_sgb_bus.'; -- Global package name
9 --
10 --
11 -- ----------------------------------------------------------------------------
12 -- |-----------------------< chk_non_updateable_args >------------------------|
13 -- ----------------------------------------------------------------------------
14 -- {Start Of Comments}
15 --
16 -- Description:
17 -- This procedure is used to ensure that non updateable attributes have
18 -- not been updated. If an attribute has been updated an error is generated.
19 --
20 -- Pre Conditions:
21 -- g_old_rec has been populated with details of the values currently in
22 -- the database.
23 --
24 -- In Arguments:
25 -- p_rec has been populated with the updated values the user would like the
26 -- record set to.
27 --
28 -- Post Success:
29 -- Processing continues if all the non updateable attributes have not
30 -- changed.
31 --
32 -- Post Failure:
33 -- An application error is raised if any of the non updatable attributes
34 -- have been altered.
35 --
36 -- {End Of Comments}
37 -- ----------------------------------------------------------------------------
38 Procedure chk_non_updateable_args
39 (p_rec in pay_sgb_shd.g_rec_type
40 ) IS
41 --
42 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
43 l_error EXCEPTION;
44 l_argument varchar2(30);
45 --
46 Begin
47 --
48 -- Only proceed with the validation if a row exists for the current
49 -- record in the HR Schema.
50 --
51 IF NOT pay_sgb_shd.api_updating
52 (p_grossup_balances_id => p_rec.grossup_balances_id
53 ,p_object_version_number => p_rec.object_version_number
54 ) THEN
55 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
56 fnd_message.set_token('PROCEDURE ', l_proc);
57 fnd_message.set_token('STEP ', '5');
58 fnd_message.raise_error;
59 END IF;
60 --
61 -- p_source_id
62 --
63 if nvl(p_rec.source_id, hr_api.g_number) <>
64 nvl(pay_sgb_shd.g_old_rec.source_id, hr_api.g_number)
65 then
66 l_argument := 'p_source_id';
67 raise l_error;
68 end if;
69 --
70 --
71 EXCEPTION
72 WHEN l_error THEN
73 hr_api.argument_changed_error
74 (p_api_name => l_proc
75 ,p_argument => l_argument);
76 WHEN OTHERS THEN
77 RAISE;
78 End chk_non_updateable_args;
79 --
80 -- ----------------------------------------------------------------------------
81 -- |---------------------------< chk_source_id >------------------------------|
82 -- ----------------------------------------------------------------------------
83 Procedure chk_source_id
84 (p_source_id in number
85 ) is
86 --
87 -- Cursor to check that the source_id references an existing element type
88 --
89 cursor c_element_type_exists is
90 select null
91 from pay_shadow_element_types pset
92 where pset.element_type_id = p_source_id;
93 --
94 l_proc varchar2(72) := g_package||'chk_source_id';
95 l_exists varchar2(1);
96 --
97 Begin
98 hr_utility.set_location('Entering:'||l_proc, 5);
99 --
100 -- Check that the source_id is not null.
101 --
102 hr_api.mandatory_arg_error
103 (p_api_name => l_proc
104 ,p_argument => 'SOURCE_ID'
105 ,p_argument_value => p_source_id
106 );
107 --
108 -- Check that the source_id references an existing element type
109 --
110 open c_element_type_exists;
111 fetch c_element_type_exists into l_exists;
112 if c_element_type_exists%notfound then
113 close c_element_type_exists;
114 fnd_message.set_name('PAY', 'PAY_50095_ETM_INVALID_ELE_TYPE');
115 fnd_message.raise_error;
116 end if;
117 close c_element_type_exists;
118 hr_utility.set_location('Leaving:'||l_proc, 10);
119 End chk_source_id;
120 --
121 -- ----------------------------------------------------------------------------
122 -- |---------------------------< chk_source_type >----------------------------|
123 -- ----------------------------------------------------------------------------
124 Procedure chk_source_type
125 (p_source_type in varchar2
126 ) is
127 --
128 l_proc varchar2(72) := g_package||'chk_source_type';
129 --
130 Begin
131 hr_utility.set_location('Entering:'||l_proc, 5);
132 if UPPER(p_source_type) <> 'ET' then
133 fnd_message.set_name('PAY', 'PAY_50120_SGB_BAD_SOURCE_TYPE');
137 hr_utility.set_location('Leaving:'||l_proc, 10);
134 fnd_message.set_token('SOURCE_TYPE', p_source_type);
135 fnd_message.raise_error;
136 end if;
138 End chk_source_type;
139 --
140 -- ----------------------------------------------------------------------------
141 -- |------------------------< chk_balance_type_name >-------------------------|
142 -- ----------------------------------------------------------------------------
143 Procedure chk_balance_type_name
144 (p_balance_type_name in varchar2
145 ,p_balance_type_id in number
146 ) is
147 --
148 l_proc varchar2(72) := g_package||'chk_balance_type_name';
149 --
150 Begin
151 hr_utility.set_location('Entering:'||l_proc, 5);
152 if p_balance_type_id is null then
153 --
154 -- Balance type name is mandatory
155 --
156 hr_api.mandatory_arg_error
157 (p_api_name => l_proc
158 ,p_argument => 'BALANCE_TYPE_NAME'
159 ,p_argument_value => p_balance_type_name
160 );
161 end if;
162 hr_utility.set_location('Leaving:'||l_proc, 10);
163 End chk_balance_type_name;
164 --
165 -- ----------------------------------------------------------------------------
166 -- |-------------------------< chk_balance_type_id >--------------------------|
167 -- ----------------------------------------------------------------------------
168 Procedure chk_balance_type_id
169 (p_balance_type_id in number
170 ,p_balance_type_name in varchar2
171 ,p_source_id in number
172 ,p_grossup_balances_id in number
173 ,p_object_version_number in number
174 ) is
175 --
176 -- Cursor to check that the balance_type_id is valid.
177 --
178 cursor c_bal_type_id_valid is
179 select null
180 from pay_shadow_balance_types sbt
181 , pay_shadow_element_types pset
182 where sbt.balance_type_id = p_balance_type_id
183 and sbt.template_id = pset.template_id
184 and pset.element_type_id = p_source_id;
185 --
186 l_proc varchar2(72) := g_package||'chk_balance_type_id';
187 l_api_updating boolean;
188 l_valid varchar2(1);
189 --
190 Begin
191 hr_utility.set_location('Entering:'||l_proc, 5);
192 l_api_updating := pay_sgb_shd.api_updating
193 (p_grossup_balances_id => p_grossup_balances_id
194 ,p_object_version_number => p_object_version_number
195 );
196 if p_balance_type_name is null then
197 --
198 -- Balance type ID is mandatory
199 --
200 hr_api.mandatory_arg_error
201 (p_api_name => l_proc
202 ,p_argument => 'BALANCE_TYPE_ID'
203 ,p_argument_value => p_balance_type_id
204 );
205 end if;
206 --
207 if (l_api_updating and nvl(p_balance_type_id, hr_api.g_number) <>
208 nvl(pay_sgb_shd.g_old_rec.balance_type_id, hr_api.g_number)) or
209 not l_api_updating
210 then
211 if p_balance_type_id is not null then
212 open c_bal_type_id_valid;
213 fetch c_bal_type_id_valid into l_valid;
214 if c_bal_type_id_valid%notfound then
215 close c_bal_type_id_valid;
216 fnd_message.set_name('PAY', 'PAY_50086_ETM_INVALID_BAL_TYPE');
217 fnd_message.raise_error;
218 end if;
219 close c_bal_type_id_valid;
220 end if;
221 end if;
222 hr_utility.set_location('Leaving:'||l_proc, 10);
223 End chk_balance_type_id;
224 --
225 -- ----------------------------------------------------------------------------
226 -- |-------------------------< chk_exclusion_rule_id >------------------------|
227 -- ----------------------------------------------------------------------------
228 Procedure chk_exclusion_rule_id
229 (p_exclusion_rule_id in number
230 ,p_source_id in number
231 ,p_grossup_balances_id in number
232 ,p_object_version_number in number
233 ) is
234 --
235 -- Cursor to check that the exclusion_rule_id is valid.
236 --
237 cursor c_exclusion_rule_id_valid is
238 select null
239 from pay_shadow_element_types pset
240 , pay_template_exclusion_rules ter
241 where ter.exclusion_rule_id = p_exclusion_rule_id
242 and ter.template_id = pset.template_id
243 and pset.element_type_id = p_source_id;
244 --
245 l_proc varchar2(72) := g_package||'chk_exclusion_rule_id';
246 l_api_updating boolean;
247 l_valid varchar2(1);
248 --
249 Begin
250 hr_utility.set_location('Entering:'||l_proc, 5);
251 l_api_updating := pay_sgb_shd.api_updating
252 (p_grossup_balances_id => p_grossup_balances_id
253 ,p_object_version_number => p_object_version_number
254 );
255 if (l_api_updating and nvl(p_exclusion_rule_id, hr_api.g_number) <>
256 nvl(pay_sgb_shd.g_old_rec.exclusion_rule_id, hr_api.g_number)) or
257 not l_api_updating
258 then
259 if p_exclusion_rule_id is not null then
260 open c_exclusion_rule_id_valid;
261 fetch c_exclusion_rule_id_valid into l_valid;
262 if c_exclusion_rule_id_valid%notfound then
263 close c_exclusion_rule_id_valid;
264 fnd_message.set_name('PAY', 'PAY_50100_ETM_INVALID_EXC_RULE');
265 fnd_message.raise_error;
266 end if;
267 close c_exclusion_rule_id_valid;
268 end if;
269 end if;
270 hr_utility.set_location('Leaving:'||l_proc, 10);
271 End chk_exclusion_rule_id;
272 --
273 -- ----------------------------------------------------------------------------
274 -- |-----------------------------< chk_delete >-------------------------------|
278 ) is
275 -- ----------------------------------------------------------------------------
276 Procedure chk_delete
277 (p_grossup_balances_id in number
279 --
280 -- Cursor to check for rows referencing the balance exclusion
281 --
282 cursor c_core_objects is
283 select null
284 from pay_template_core_objects tco
285 where tco.core_object_type = pay_tco_shd.g_sgb_lookup_type
286 and tco.shadow_object_id = p_grossup_balances_id;
287 --
288 l_proc varchar2(72) := g_package||'chk_delete';
289 l_error exception;
290 l_exists varchar2(1);
291 --
292 Begin
293 hr_utility.set_location('Entering:'||l_proc, 5);
294 --
295 open c_core_objects;
296 fetch c_core_objects into l_exists;
297 if c_core_objects%found then
298 close c_core_objects;
299 raise l_error;
300 end if;
301 close c_core_objects;
302 hr_utility.set_location('Leaving:'||l_proc, 10);
303 exception
304 when l_error then
305 fnd_message.set_name('PAY', 'PAY_50119_SGB_INVALID_DELETE');
306 fnd_message.raise_error;
307 when others then
308 hr_utility.set_location('Leaving:'||l_proc, 15);
309 raise;
310 End chk_delete;
311 --
312 -- ----------------------------------------------------------------------------
313 -- |---------------------------< insert_validate >----------------------------|
314 -- ----------------------------------------------------------------------------
315 Procedure insert_validate
316 (p_effective_date in date
317 ,p_rec in pay_sgb_shd.g_rec_type
318 ) is
319 --
320 l_proc varchar2(72) := g_package||'insert_validate';
321 --
322 Begin
323 hr_utility.set_location('Entering:'||l_proc, 5);
324 --
325 -- Call all supporting business operations
326 --
327 chk_source_id(p_rec.source_id);
328 --
329 chk_source_type(p_rec.source_type);
330 --
331 chk_balance_type_name
332 (p_balance_type_name => p_rec.balance_type_name
333 ,p_balance_type_id => p_rec.balance_type_id
334 );
335 --
336 chk_balance_type_id
337 (p_balance_type_id => p_rec.balance_type_id
338 ,p_balance_type_name => p_rec.balance_type_name
339 ,p_source_id => p_rec.source_id
340 ,p_grossup_balances_id => p_rec.grossup_balances_id
341 ,p_object_version_number => p_rec.object_version_number
342 );
343 --
344 chk_exclusion_rule_id
345 (p_exclusion_rule_id => p_rec.exclusion_rule_id
346 ,p_source_id => p_rec.source_id
347 ,p_grossup_balances_id => p_rec.grossup_balances_id
351 --
348 ,p_object_version_number => p_rec.object_version_number
349 );
350 --
352 hr_utility.set_location(' Leaving:'||l_proc, 10);
353 End insert_validate;
354 --
355 -- ----------------------------------------------------------------------------
356 -- |---------------------------< update_validate >----------------------------|
357 -- ----------------------------------------------------------------------------
358 Procedure update_validate
359 (p_effective_date in date
360 ,p_rec in pay_sgb_shd.g_rec_type
361 ) is
362 --
363 l_proc varchar2(72) := g_package||'update_validate';
364 --
365 Begin
366 hr_utility.set_location('Entering:'||l_proc, 5);
367 --
368 -- Call all supporting business operations
369 --
370 chk_non_updateable_args(p_rec);
371 --
372 chk_source_type(p_rec.source_type);
373 --
374 chk_balance_type_name
375 (p_balance_type_name => p_rec.balance_type_name
376 ,p_balance_type_id => p_rec.balance_type_id
377 );
378 --
379 chk_balance_type_id
380 (p_balance_type_id => p_rec.balance_type_id
381 ,p_balance_type_name => p_rec.balance_type_name
382 ,p_source_id => p_rec.source_id
383 ,p_grossup_balances_id => p_rec.grossup_balances_id
384 ,p_object_version_number => p_rec.object_version_number
385 );
386 --
387 chk_exclusion_rule_id
388 (p_exclusion_rule_id => p_rec.exclusion_rule_id
389 ,p_source_id => p_rec.source_id
390 ,p_grossup_balances_id => p_rec.grossup_balances_id
391 ,p_object_version_number => p_rec.object_version_number
392 );
393 --
394 --
395 hr_utility.set_location(' Leaving:'||l_proc, 10);
396 End update_validate;
397 --
401 Procedure delete_validate
398 -- ----------------------------------------------------------------------------
399 -- |---------------------------< delete_validate >----------------------------|
400 -- ----------------------------------------------------------------------------
402 (p_rec in pay_sgb_shd.g_rec_type
403 ) is
404 --
405 l_proc varchar2(72) := g_package||'delete_validate';
406 --
407 Begin
408 hr_utility.set_location('Entering:'||l_proc, 5);
409 --
410 -- Call all supporting business operations
411 --
412 chk_delete(p_rec.grossup_balances_id);
413 --
414 hr_utility.set_location(' Leaving:'||l_proc, 10);
415 End delete_validate;
416 --
417 end pay_sgb_bus;