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