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