1 Package Body hxc_rtr_bus as
2 /* $Header: hxcrtrrhi.pkb 120.2 2005/09/23 08:54:01 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_rtr_bus.'; -- Global package name
9
10 g_debug boolean := hr_utility.debug_enabled;
11 --
12 -- The following two global variables are only to be
13 -- used by the return_legislation_code function.
14 --
15 g_legislation_code varchar2(150) default null;
16 g_retrieval_rule_id number default null;
17 --
18 -- ---------------------------------------------------------------------------
19 -- |----------------------< set_security_group_id >--------------------------|
20 -- ---------------------------------------------------------------------------
21 --
22 Procedure set_security_group_id
23 (p_retrieval_rule_id in number
24 ) is
25 --
26 -- Declare cursor
27 --
28 -- EDIT_HERE In the following cursor statement add join(s) between
29 -- hxc_retrieval_rules and PER_BUSINESS_GROUPS
30 -- so that the security_group_id for
31 -- the current business group context can be derived.
32 -- Remove this comment when the edit has been completed.
33 cursor csr_sec_grp is
34 select pbg.security_group_id
35 from per_business_groups pbg
36 , hxc_retrieval_rules rtr
37 -- , EDIT_HERE table_name(s) 333
41 -- Declare local variables
38 where rtr.retrieval_rule_id = p_retrieval_rule_id;
39 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
40 --
42 --
43 l_security_group_id number;
44 l_proc varchar2(72) ;
45 --
46 begin
47 g_debug := hr_utility.debug_enabled;
48
49 --
50 if g_debug then
51 l_proc := g_package||'set_security_group_id';
52 hr_utility.set_location('Entering:'|| l_proc, 10);
53 end if;
54 --
55 -- Ensure that all the mandatory parameter are not null
56 --
57 hr_api.mandatory_arg_error
58 (p_api_name => l_proc
59 ,p_argument => 'retrieval_rule_id'
60 ,p_argument_value => p_retrieval_rule_id
61 );
62 --
63 open csr_sec_grp;
64 fetch csr_sec_grp into l_security_group_id;
65 --
66 if csr_sec_grp%notfound then
67 --
68 close csr_sec_grp;
69 --
70 -- The primary key is invalid therefore we must error
71 --
72 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
73 fnd_message.raise_error;
74 --
75 end if;
76 close csr_sec_grp;
77 --
78 -- Set the security_group_id in CLIENT_INFO
79 --
80 hr_api.set_security_group_id
81 (p_security_group_id => l_security_group_id
82 );
83 --
84 if g_debug then
85 hr_utility.set_location(' Leaving:'|| l_proc, 20);
86 end if;
87 --
88 end set_security_group_id;
89 --
90 -- ---------------------------------------------------------------------------
91 -- |---------------------< return_legislation_code >-------------------------|
92 -- ---------------------------------------------------------------------------
93 --
94 Function return_legislation_code
95 (p_retrieval_rule_id in number
96 )
97 Return Varchar2 Is
98 --
99 -- Declare cursor
100 --
101 -- EDIT_HERE In the following cursor statement add join(s) between
102 -- hxc_retrieval_rules and PER_BUSINESS_GROUPS
103 -- so that the legislation_code for
104 -- the current business group context can be derived.
105 -- Remove this comment when the edit has been completed.
106 cursor csr_leg_code is
107 select pbg.legislation_code
108 from per_business_groups pbg
109 , hxc_retrieval_rules rtr
110 -- , EDIT_HERE table_name(s) 333
111 where rtr.retrieval_rule_id = p_retrieval_rule_id;
112 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
113 --
114 -- Declare local variables
115 --
116 l_legislation_code varchar2(150);
117 l_proc varchar2(72) ;
118 --
119 Begin
120 g_debug := hr_utility.debug_enabled;
121
122 --
123 if g_debug then
124 l_proc := g_package||'return_legislation_code';
125 hr_utility.set_location('Entering:'|| l_proc, 10);
126 end if;
127 --
128 -- Ensure that all the mandatory parameter are not null
129 --
130 hr_api.mandatory_arg_error
131 (p_api_name => l_proc
132 ,p_argument => 'retrieval_rule_id'
133 ,p_argument_value => p_retrieval_rule_id
134 );
135 --
136 if ( nvl(hxc_rtr_bus.g_retrieval_rule_id, hr_api.g_number)
137 = p_retrieval_rule_id) then
138 --
139 -- The legislation code has already been found with a previous
140 -- call to this function. Just return the value in the global
141 -- variable.
142 --
143 l_legislation_code := hxc_rtr_bus.g_legislation_code;
144 if g_debug then
145 hr_utility.set_location(l_proc, 20);
146 end if;
147 else
148 --
149 -- The ID is different to the last call to this function
150 -- or this is the first call to this function.
151 --
152 open csr_leg_code;
153 fetch csr_leg_code into l_legislation_code;
154 --
155 if csr_leg_code%notfound then
156 --
157 -- The primary key is invalid therefore we must error
158 --
159 close csr_leg_code;
160 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
161 fnd_message.raise_error;
162 end if;
163 if g_debug then
164 hr_utility.set_location(l_proc,30);
165 end if;
166 --
167 -- Set the global variables so the values are
168 -- available for the next call to this function.
169 --
170 close csr_leg_code;
171 hxc_rtr_bus.g_retrieval_rule_id := p_retrieval_rule_id;
172 hxc_rtr_bus.g_legislation_code := l_legislation_code;
173 end if;
174 if g_debug then
175 hr_utility.set_location(' Leaving:'|| l_proc, 40);
176 end if;
177 return l_legislation_code;
178 end return_legislation_code;
179 --
180 -- ----------------------------------------------------------------------------
181 -- |-----------------------< chk_non_updateable_args >------------------------|
182 -- ----------------------------------------------------------------------------
183 -- {Start Of Comments}
184 --
185 -- Description:
186 -- This procedure is used to ensure that non updateable attributes have
187 -- not been updated. If an attribute has been updated an error is generated.
188 --
189 -- Pre Conditions:
190 -- g_old_rec has been populated with details of the values currently in
191 -- the database.
192 --
193 -- In Arguments:
197 -- Post Success:
194 -- p_rec has been populated with the updated values the user would like the
195 -- record set to.
196 --
198 -- Processing continues if all the non updateable attributes have not
199 -- changed.
200 --
201 -- Post Failure:
202 -- An application error is raised if any of the non updatable attributes
203 -- have been altered.
204 --
205 -- {End Of Comments}
206 -- ----------------------------------------------------------------------------
207 Procedure chk_non_updateable_args
208 (p_effective_date in date
209 ,p_rec in hxc_rtr_shd.g_rec_type
210 ) IS
211 --
212 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
213 l_error EXCEPTION;
214 l_argument varchar2(30);
215 --
216 Begin
217 --
218 -- Only proceed with the validation if a row exists for the current
219 -- record in the HR Schema.
220 --
221 IF NOT hxc_rtr_shd.api_updating
222 (p_retrieval_rule_id => p_rec.retrieval_rule_id
223 ,p_object_version_number => p_rec.object_version_number
224 ) THEN
225 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
226 fnd_message.set_token('PROCEDURE ', l_proc);
227 fnd_message.set_token('STEP ', '5');
228 fnd_message.raise_error;
229 END IF;
230 --
231 -- EDIT_HERE: Add checks to ensure non-updateable args have
232 -- not been updated.
233 --
234 EXCEPTION
235 WHEN l_error THEN
236 hr_api.argument_changed_error
237 (p_api_name => l_proc
238 ,p_argument => l_argument);
239 WHEN OTHERS THEN
240 RAISE;
241 End chk_non_updateable_args;
242 --
243 -- ----------------------------------------------------------------------------
244 -- |-----------------------------< chk_name >---------------------------------|
245 -- ----------------------------------------------------------------------------
246 -- {Start Of Comments}
247 --
248 -- Description:
249 -- This procedure ensures that a valid and a unique Retrieval Rule Name
250 -- has been entered
251 --
252 -- Pre Conditions:
253 -- None
254 --
255 -- In Arguments:
256 -- name
257 -- object_version_number
258 --
259 -- Post Success:
260 -- Processing continues if a valid and a unique name has been entered
261 --
262 -- Post Failure:
263 -- An application error is raised if the name is not valid
264 --
265 -- {End Of Comments}
266 -- ----------------------------------------------------------------------------
267 Procedure chk_name
268 (
269 p_name in hxc_retrieval_rules.name%TYPE,
270 p_object_version_number in hxc_retrieval_rules.object_version_number%TYPE
271 ) IS
272 --
273 l_proc varchar2(72);
274 --
275 -- cursor to check that a duplicate retrieval rule name is not entered
276 --
277 CURSOR csr_chk_name IS
278 SELECT 'error'
279 FROM sys.dual
280 WHERE EXISTS (
281 SELECT 'x'
282 FROM hxc_retrieval_rules rtr
283 WHERE rtr.name = p_name
284 AND rtr.object_version_number <> NVL(p_object_version_number, -1) );
285 --
286 l_error varchar2(5) := NULL;
287 --
288 BEGIN
289 g_debug := hr_utility.debug_enabled;
290
291 if g_debug then
292 l_proc := g_package||'chk_name';
293 hr_utility.set_location('Entering:'||l_proc, 5);
294 end if;
295 --
296 -- Raise error if name is NULL as it is a mandatory field.
297 --
298 IF p_name IS NULL
299 THEN
300 --
301 hr_utility.set_message(809, 'HXC_0089_RTR_RULE_NAME_MAND');
302 hr_utility.raise_error;
303 --
304 END IF;
305 if g_debug then
306 hr_utility.set_location('Processing:'||l_proc, 10);
307 end if;
308 --
309 -- Raise an error if the retrieval rule name is not unique
310 --
311 OPEN csr_chk_name;
312 FETCH csr_chk_name INTO l_error;
313 CLOSE csr_chk_name;
314 --
315 IF l_error IS NOT NULL
316 THEN
317 --
318 hr_utility.set_message(809, 'HXC_0090_RTR_DUP_RULE_NAME');
319 hr_utility.raise_error;
320 --
321 END IF;
322 --
323 if g_debug then
324 hr_utility.set_location('Leaving:'||l_proc, 20);
325 end if;
326 --
327 END chk_name;
328 --
329 -- ----------------------------------------------------------------------------
330 -- |---------------------------< insert_validate >----------------------------|
331 -- ----------------------------------------------------------------------------
332 Procedure insert_validate
333 (p_effective_date in date
334 ,p_rec in hxc_rtr_shd.g_rec_type
335 ) is
336 --
337 l_proc varchar2(72);
338 --
339 Begin
340 g_debug := hr_utility.debug_enabled;
341
342 if g_debug then
343 l_proc := g_package||'insert_validate';
344 hr_utility.set_location('Entering:'||l_proc, 5);
345 end if;
346 --
347 -- Call all supporting business operations
348 --
349 if g_debug then
350 hr_utility.set_location('Processing:'||l_proc, 10);
351 end if;
352 --
353 chk_name ( p_name => p_rec.name,
354 p_object_version_number => p_rec.object_version_number );
355 --
356 if g_debug then
357 hr_utility.set_location(' Leaving:'||l_proc, 10);
358 end if;
359 --
360 -- EDIT_HERE: As this table does not have a mandatory business_group_id
361 -- column, ensure client_info is populated by calling a suitable
362 -- ???_???_bus.set_security_group_id procedure, or add one of the following
363 -- comments:
364 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
365 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
366 --
367 --
368 if g_debug then
369 hr_utility.set_location(' Leaving:'||l_proc, 10);
370 end if;
371 End insert_validate;
372 --
373 -- ----------------------------------------------------------------------------
374 -- |---------------------------< update_validate >----------------------------|
375 -- ----------------------------------------------------------------------------
376 Procedure update_validate
377 (p_effective_date in date
378 ,p_rec in hxc_rtr_shd.g_rec_type
379 ) is
380 --
381 l_proc varchar2(72);
382 --
383 Begin
384 g_debug := hr_utility.debug_enabled;
385
386 if g_debug then
387 l_proc := g_package||'update_validate';
388 hr_utility.set_location('Entering:'||l_proc, 5);
389 --
390 -- Call all supporting business operations
391 --
392 hr_utility.set_location('Processing:'||l_proc, 10);
393 end if;
394 --
395 chk_name ( p_name => p_rec.name,
396 p_object_version_number => p_rec.object_version_number );
397 --
398 if g_debug then
399 hr_utility.set_location(' Leaving:'||l_proc, 10);
400 end if;
401 --
402 -- EDIT_HERE: As this table does not have a mandatory business_group_id
403 -- column, ensure client_info is populated by calling a suitable
404 -- ???_???_bus.set_security_group_id procedure, or add one of the following
405 -- comments:
406 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
407 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
408 --
409 chk_non_updateable_args
410 (p_effective_date => p_effective_date
411 ,p_rec => p_rec
412 );
413 --
414 --
415 if g_debug then
416 hr_utility.set_location(' Leaving:'||l_proc, 10);
417 end if;
418 End update_validate;
419 --
420 -- ----------------------------------------------------------------------------
421 -- |---------------------------< delete_validate >----------------------------|
422 -- ----------------------------------------------------------------------------
423 Procedure delete_validate
424 (p_rec in hxc_rtr_shd.g_rec_type
425 ) is
426 --
427 l_proc varchar2(72);
428 --
429 Begin
430 g_debug := hr_utility.debug_enabled;
431
432 if g_debug then
433 l_proc := g_package||'delete_validate';
434 hr_utility.set_location('Entering:'||l_proc, 5);
435 --
436 -- Call all supporting business operations
437 --
438 hr_utility.set_location(' Leaving:'||l_proc, 10);
439 end if;
440 End delete_validate;
441 --
442 end hxc_rtr_bus;