1 Package Body hxc_han_bus as
2 /* $Header: hxchanrhi.pkb 120.2 2006/07/10 10:09:56 gsirigin noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_han_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_comp_notification_id number default null;
16 g_object_version_number number default null;
17 --
18 -- ---------------------------------------------------------------------------
19 -- |----------------------< set_security_group_id >--------------------------|
20 -- ---------------------------------------------------------------------------
21 --
22 Procedure set_security_group_id
23 (p_comp_notification_id in number
24 ,p_object_version_number in number
25 ,p_associated_column1 in varchar2 default null
26 ,p_associated_column2 in varchar2 default null
27 ) is
28 --
29 -- Declare cursor
30 --
31 -- EDIT_HERE In the following cursor statement add join(s) between
32 -- hxc_app_comp_notifications and PER_BUSINESS_GROUPS_PERF
33 -- so that the security_group_id for
34 -- the current business group context can be derived.
35 -- Remove this comment when the edit has been completed.
36 cursor csr_sec_grp is
37 select pbg.security_group_id,
38 pbg.legislation_code
39 from per_business_groups_perf pbg
40 , hxc_app_comp_notifications han
41 -- , EDIT_HERE table_name(s) 333
42 where han.comp_notification_id = p_comp_notification_id
43 and han.object_version_number = p_object_version_number;
44 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
45 --
46 -- Declare local variables
47 --
48 l_security_group_id number;
49 l_proc varchar2(72) := g_package||'set_security_group_id';
50 l_legislation_code varchar2(150);
51 --
52 begin
53 --
54 if g_debug then
55 hr_utility.set_location('Entering:'|| l_proc, 10);
56 end if;
57 --
58 -- Ensure that all the mandatory parameter are not null
59 --
60 hr_api.mandatory_arg_error
61 (p_api_name => l_proc
62 ,p_argument => 'comp_notification_id'
63 ,p_argument_value => p_comp_notification_id
64 );
65 hr_api.mandatory_arg_error
66 (p_api_name => l_proc
67 ,p_argument => 'object_version_number'
68 ,p_argument_value => p_object_version_number
69 );
70 --
71 open csr_sec_grp;
72 fetch csr_sec_grp into l_security_group_id
73 , l_legislation_code;
74 --
75 if csr_sec_grp%notfound then
76 --
77 close csr_sec_grp;
78 --
79 -- The primary key is invalid therefore we must error
80 --
81 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
82 hr_multi_message.add
83 (p_associated_column1
84 => nvl(p_associated_column1,'COMP_notification_ID')
85 ,p_associated_column2
86 => nvl(p_associated_column2,'OBJECT_VERSION_NUMBER')
87 );
88 --
89 else
90 close csr_sec_grp;
91 --
92 -- Set the security_group_id in CLIENT_INFO
93 --
94 hr_api.set_security_group_id
95 (p_security_group_id => l_security_group_id
96 );
97 --
98 -- Set the sessions legislation context in HR_SESSION_DATA
99 --
100 hr_api.set_legislation_context(l_legislation_code);
101 end if;
102 --
103 if g_debug then
104 hr_utility.set_location(' Leaving:'|| l_proc, 20);
105 end if;
106 --
107 end set_security_group_id;
108 --
109 -- ---------------------------------------------------------------------------
110 -- |---------------------< return_legislation_code >-------------------------|
111 -- ---------------------------------------------------------------------------
112 --
113 Function return_legislation_code
114 (p_comp_notification_id in number
115 ,p_object_version_number in number
116 )
117 Return Varchar2 Is
118 --
119 -- Declare cursor
120 --
121 -- EDIT_HERE In the following cursor statement add join(s) between
122 -- hxc_app_comp_notifications and PER_BUSINESS_GROUPS_PERF
123 -- so that the legislation_code for
124 -- the current business group context can be derived.
125 -- Remove this comment when the edit has been completed.
126 cursor csr_leg_code is
127 select pbg.legislation_code
128 from per_business_groups_perf pbg
129 , hxc_app_comp_notifications han
130 -- , EDIT_HERE table_name(s) 333
131 where han.comp_notification_id = p_comp_notification_id
132 and han.object_version_number = p_object_version_number;
133 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
134 --
135 -- Declare local variables
136 --
137 l_legislation_code varchar2(150);
138 l_proc varchar2(72) := g_package||'return_legislation_code';
139 --
140 Begin
141 --
142 if g_debug then
143 hr_utility.set_location('Entering:'|| l_proc, 10);
144 end if;
145 --
146 -- Ensure that all the mandatory parameter are not null
147 --
148 hr_api.mandatory_arg_error
149 (p_api_name => l_proc
150 ,p_argument => 'comp_notification_id'
151 ,p_argument_value => p_comp_notification_id
152 );
153 hr_api.mandatory_arg_error
154 (p_api_name => l_proc
155 ,p_argument => 'object_version_number'
156 ,p_argument_value => p_object_version_number
157 );
158 --
159 if (( nvl(hxc_han_bus.g_comp_notification_id, hr_api.g_number)
160 = p_comp_notification_id)
161 and ( nvl(hxc_han_bus.g_object_version_number, hr_api.g_number)
162 = p_object_version_number)) then
163 --
164 -- The legislation code has already been found with a previous
165 -- call to this function. Just return the value in the global
166 -- variable.
167 --
168 l_legislation_code := hxc_han_bus.g_legislation_code;
169 if g_debug then
170 hr_utility.set_location(l_proc, 20);
171 end if;
172 else
173 --
174 -- The ID is different to the last call to this function
175 -- or this is the first call to this function.
176 --
177 open csr_leg_code;
178 fetch csr_leg_code into l_legislation_code;
179 --
180 if csr_leg_code%notfound then
181 --
182 -- The primary key is invalid therefore we must error
183 --
184 close csr_leg_code;
185 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
186 fnd_message.raise_error;
187 end if;
188 if g_debug then
189 hr_utility.set_location(l_proc,30);
190 end if;
191 --
192 -- Set the global variables so the values are
193 -- available for the next call to this function.
194 --
195 close csr_leg_code;
196 hxc_han_bus.g_comp_notification_id := p_comp_notification_id;
197 hxc_han_bus.g_object_version_number := p_object_version_number;
198 hxc_han_bus.g_legislation_code := l_legislation_code;
199 end if;
200 if g_debug then
201 hr_utility.set_location(' Leaving:'|| l_proc, 40);
202 end if;
203 return l_legislation_code;
204 end return_legislation_code;
205 --
206 -- ----------------------------------------------------------------------------
207 -- |-----------------------< chk_non_updateable_args >------------------------|
208 -- ----------------------------------------------------------------------------
209 -- {Start Of Comments}
210 --
211 -- Description:
212 -- This procedure is used to ensure that non updateable attributes have
213 -- not been updated. If an attribute has been updated an error is generated.
214 --
215 -- Pre Conditions:
216 -- g_old_rec has been populated with details of the values currently in
217 -- the database.
218 --
219 -- In Arguments:
220 -- p_rec has been populated with the updated values the user would like the
221 -- record set to.
222 --
223 -- Post Success:
224 -- Processing continues if all the non updateable attributes have not
225 -- changed.
226 --
227 -- Post Failure:
228 -- An application error is raised if any of the non updatable attributes
229 -- have been altered.
230 --
231 -- {End Of Comments}
232 -- ----------------------------------------------------------------------------
233 Procedure chk_non_updateable_args
234 (p_rec in hxc_han_shd.g_rec_type
235 ) IS
236 --
237 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
238 --
239 Begin
240 --
241 -- Only proceed with the validation if a row exists for the current
242 -- record in the HR Schema.
243 --
244 IF NOT hxc_han_shd.api_updating
245 (p_comp_notification_id => p_rec.comp_notification_id
246 ,p_object_version_number => p_rec.object_version_number
247 ) THEN
248 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
249 fnd_message.set_token('PROCEDURE ', l_proc);
250 fnd_message.set_token('STEP ', '5');
251 fnd_message.raise_error;
252 END IF;
253 --
254 -- EDIT_HERE: Add checks to ensure non-updateable args have
255 -- not been updated.
256 --
257
258 --
259 --Check to see that notification_action_code is not updated
260 --
261 If (p_rec.notification_action_code <> hxc_han_shd.g_old_rec.notification_action_code) then
262 fnd_message.set_name('PER', 'NOTIOFICATION_ACTION_CODE cannot be changed');
263 fnd_message.raise_error;
264 End If;
265 --
266 --Check to see that notification_recipient_code is not updated
267 --
268 If (p_rec.notification_recipient_code<>hxc_han_shd.g_old_rec.notification_recipient_code) then
269 fnd_message.set_name('PER', 'RECIPIENT_ACTION_CODE cannot be changed');
270 fnd_message.raise_error;
271 End If;
272 End chk_non_updateable_args;
273 --
274 -- ----------------------------------------------------------------------------
275 -- |---------------------------< chk_notification_num_retries >------------|
276 -- ----------------------------------------------------------------------------
277 --
278 PROCEDURE chk_notification_num_retries (
279 p_notification_number_retries IN NUMBER,
280 p_notification_action_code IN VARCHAR2
281 )
282 IS
283 BEGIN
284
285 IF (p_notification_action_code <>
286 hxc_app_comp_notifications_api.c_action_request_appr_resend
287 )
288 THEN
289 IF (p_notification_number_retries <> 0)
290 THEN
291 hr_utility.set_message (809, 'HXC_RETRIES_NOT_ZERO');
292 hr_utility.raise_error;
293 END IF;
294 ELSE
295 IF ( p_notification_number_retries < 0
296 OR p_notification_number_retries > 999
297 )
298 THEN
299 hr_utility.set_message (809, 'HXC_INAVALID_NUM_RETRIES');
300 hr_utility.raise_error;
301 END IF;
302 END IF;
303
304 END chk_notification_num_retries;
305
306
307 --
308 -- ----------------------------------------------------------------------------
309 -- |---------------------------< chk_notification_timeout_value >------------|
310 -- ----------------------------------------------------------------------------
311 --
312 PROCEDURE chk_notification_timeout_value (p_notification_timeout_value IN NUMBER)
313 IS
314 BEGIN
315 IF ( p_notification_timeout_value < 0
316 OR p_notification_timeout_value > 999999
317 )
318 THEN
319 hr_utility.set_message (809, 'HXC_TIMEOUT_VALUE');
320 hr_utility.raise_error;
321 END IF;
322 END chk_notification_timeout_value;
323
324 --
325 -- ----------------------------------------------------------------------------
326 -- |---------------------------< chk_notification_action_code >---------------|
327 -- ----------------------------------------------------------------------------
328 --
329 Procedure
330 chk_notification_action_code
331 ( p_notification_action_code in varchar2
332 ) is
333 begin
334 if p_notification_action_code not in
335 (
336 hxc_app_comp_notifications_api.C_ACTION_APPROVED
337 ,hxc_app_comp_notifications_api.C_ACTION_AUTO_APPROVE
338 ,hxc_app_comp_notifications_api.C_ACTION_ERROR
339 ,hxc_app_comp_notifications_api.C_ACTION_REJECTED
340 ,hxc_app_comp_notifications_api.C_ACTION_REQUEST_APPROVAL
341 ,hxc_app_comp_notifications_api.C_ACTION_REQUEST_APPR_RESEND
342 ,hxc_app_comp_notifications_api.C_ACTION_SUBMISSION
343 ,hxc_app_comp_notifications_api.C_ACTION_TRANSFER
347 hr_utility.raise_error;
344 )
345 then
346 hr_utility.set_message(809,'HXC_ACTION_CODE');
348 end if;
349 end chk_notification_action_code;
350 --
351 -- ----------------------------------------------------------------------------
352 -- |---------------------------< chk_notification_recip_code >----------------|
353 -- ----------------------------------------------------------------------------
354 --
355 Procedure
356 chk_notification_recip_code
357 ( p_notification_recipient_code in varchar2
358 ) is
359 begin
360 if p_notification_recipient_code not in
361 (
362 hxc_app_comp_notifications_api.C_RECIPIENT_ADMIN
363 ,hxc_app_comp_notifications_api.C_RECIPIENT_APPROVER
364 ,hxc_app_comp_notifications_api.C_RECIPIENT_ERROR_ADMIN
365 ,hxc_app_comp_notifications_api.C_RECIPIENT_PREPARER
366 ,hxc_app_comp_notifications_api.C_RECIPIENT_SUPERVISOR
367 ,hxc_app_comp_notifications_api.C_RECIPIENT_WORKER
368 )
369 then
370 hr_utility.set_message(809,'HXC_RECIPIENT_CODE');
371 hr_utility.raise_error;
372 end if;
373 end chk_notification_recip_code;
374
375
376 --
377 -- ----------------------------------------------------------------------------
378 -- |---------------------------< insert_validate >----------------------------|
379 -- ----------------------------------------------------------------------------
380 Procedure insert_validate
381 (p_rec in hxc_han_shd.g_rec_type
382 ) is
383 --
384 l_proc varchar2(72) := g_package||'insert_validate';
385 --
386 Begin
387 g_debug:=hr_utility.debug_enabled;
388 if g_debug then
389 l_proc := g_package||'insert_validate';
390 hr_utility.set_location('Entering:'||l_proc, 5);
391 end if;
392 --
393 -- Call all supporting business operations
394 --
395 --
396 --Check for notification_number_retries
397 --
398 if g_debug then
399 hr_utility.set_location('Processing:'||l_proc, 10);
400 end if;
401
402 chk_notification_num_retries
403 ( p_notification_number_retries =>p_rec.notification_number_retries
404 ,p_notification_action_code =>p_rec.notification_action_code
405 );
406
407 if g_debug then
408 hr_utility.set_location(' Leaving:'||l_proc, 10);
409 end if;
410 --
411 --Check for notification_timeout_value
412 --
413 if g_debug then
414 hr_utility.set_location('Processing:'||l_proc, 15);
415 end if;
416 --
417
418
419 chk_notification_timeout_value
420 (
421 p_notification_timeout_value => p_rec.notification_timeout_value
422 );
423
424 --
425 if g_debug then
426 hr_utility.set_location(' Leaving:'||l_proc, 15);
427 end if;
428 --
429 --Check for notification_action_code
430 --
431 if g_debug then
432 hr_utility.set_location('Processing:'||l_proc, 20);
433 end if;
434 chk_notification_action_code
435 (p_notification_action_code =>p_rec.notification_action_code);
436 if g_debug then
437 hr_utility.set_location(' Leaving:'||l_proc, 20);
438 end if;
439 --
440 --Check for notification_recipient_code
441 --
442 if g_debug then
443 hr_utility.set_location('Processing:'||l_proc, 25);
444 end if;
445 chk_notification_recip_code
446 (p_notification_recipient_code =>p_rec.notification_recipient_code);
447 if g_debug then
448 hr_utility.set_location(' Leaving:'||l_proc, 25);
449 end if;
450
451
452 -- Validate Dependent Attributes
453 --
454 --
455 if g_debug then
456 hr_utility.set_location(' Leaving:'||l_proc, 10);
457 end if;
458
459 End insert_validate;
460 --
461 -- ----------------------------------------------------------------------------
462 -- |---------------------------< update_validate >----------------------------|
463 -- ----------------------------------------------------------------------------
464 Procedure update_validate
465 (p_rec in hxc_han_shd.g_rec_type
466 ) is
467 --
468 l_proc varchar2(72) := g_package||'update_validate';
469 --
470 Begin
471 if g_debug then
472 hr_utility.set_location('Entering:'||l_proc, 5);
473 end if;
474 --
475 -- Call all supporting business operations
476 --
477 --
478 --Check for notification_number_retries
479 --
480 if g_debug then
481 hr_utility.set_location('Processing:'||l_proc, 10);
482 end if;
483
484 chk_notification_num_retries
485 ( p_notification_number_retries =>p_rec.notification_number_retries
486 ,p_notification_action_code =>p_rec.notification_action_code
487 );
488 if g_debug then
489 hr_utility.set_location(' Leaving:'||l_proc, 10);
490 end if;
491 --
492 --Check for notification_timeout_value
493 --
494 if g_debug then
495 hr_utility.set_location('Processing:'||l_proc, 15);
496 end if;
497 --
498 chk_notification_timeout_value
499 (
500 p_notification_timeout_value => p_rec.notification_timeout_value
501 );
502 --
503 if g_debug then
504 hr_utility.set_location(' Leaving:'||l_proc, 15);
505 end if;
506 if g_debug then
507 hr_utility.set_location('Processing:'||l_proc, 20);
508 end if;
509 chk_non_updateable_args
510 (p_rec => p_rec
511 );
512 if g_debug then
513 hr_utility.set_location(' Leaving:'||l_proc, 20);
514 end if;
515
516 End update_validate;
517 --
518 -- ----------------------------------------------------------------------------
519 -- |---------------------------< delete_validate >----------------------------|
520 -- ----------------------------------------------------------------------------
521 Procedure delete_validate
522 (p_rec in hxc_han_shd.g_rec_type
523 ) is
524 --
525 l_proc varchar2(72) := g_package||'delete_validate';
526 --
527 Begin
528 if g_debug then
529 hr_utility.set_location('Entering:'||l_proc, 5);
530 end if;
531 --
532 -- Call all supporting business operations
533 --
534 if g_debug then
535 hr_utility.set_location(' Leaving:'||l_proc, 10);
536 end if;
537 End delete_validate;
538 --
539 end hxc_han_bus;