1 Package Body ghr_cah_bus as
2 /* $Header: ghcahrhi.pkb 115.1 2003/01/30 19:24:56 asubrahm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ghr_cah_bus.'; -- Global package name
9 --
10 -- The following two global variables are only to be
11 -- used by the return_legislation_code function.
12 --
13 g_legislation_code varchar2(150) default null;
14 g_compl_ca_header_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_compl_ca_header_id in number
22 ) is
23 --
24 -- Declare cursor
25 --
26 -- EDIT_HERE In the following cursor statement add join(s) between
27 -- ghr_compl_ca_headers and PER_BUSINESS_GROUPS
28 -- so that the security_group_id for
29 -- the current business group context can be derived.
30 -- Remove this comment when the edit has been completed.
31 cursor csr_sec_grp is
32 select pbg.security_group_id
33 from per_business_groups pbg
34 , ghr_compl_ca_headers cah
35 -- , EDIT_HERE table_name(s) 333
36 where cah.compl_ca_header_id = p_compl_ca_header_id;
37 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
38 --
39 -- Declare local variables
40 --
41 l_security_group_id number;
42 l_proc varchar2(72) := g_package||'set_security_group_id';
43 --
44 begin
45 --
46 hr_utility.set_location('Entering:'|| l_proc, 10);
47 --
48 -- Ensure that all the mandatory parameter are not null
49 --
50 hr_api.mandatory_arg_error
51 (p_api_name => l_proc
52 ,p_argument => 'compl_ca_header_id'
53 ,p_argument_value => p_compl_ca_header_id
54 );
55 --
56 open csr_sec_grp;
57 fetch csr_sec_grp into l_security_group_id;
58 --
59 if csr_sec_grp%notfound then
60 --
61 close csr_sec_grp;
62 --
63 -- The primary key is invalid therefore we must error
64 --
65 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
66 fnd_message.raise_error;
67 --
68 end if;
69 close csr_sec_grp;
70 --
71 -- Set the security_group_id in CLIENT_INFO
72 --
73 hr_api.set_security_group_id
74 (p_security_group_id => l_security_group_id
75 );
76 --
77 hr_utility.set_location(' Leaving:'|| l_proc, 20);
78 --
79 end set_security_group_id;
80 --
81 -- ---------------------------------------------------------------------------
82 -- |---------------------< return_legislation_code >-------------------------|
83 -- ---------------------------------------------------------------------------
84 --
85 Function return_legislation_code
86 (p_compl_ca_header_id in number
87 )
88 Return Varchar2 Is
89 --
90 -- Declare cursor
91 --
92 -- EDIT_HERE In the following cursor statement add join(s) between
93 -- ghr_compl_ca_headers and PER_BUSINESS_GROUPS
94 -- so that the legislation_code for
95 -- the current business group context can be derived.
96 -- Remove this comment when the edit has been completed.
97 cursor csr_leg_code is
98 select pbg.legislation_code
99 from per_business_groups pbg
100 , ghr_compl_ca_headers cah
101 -- , EDIT_HERE table_name(s) 333
102 where cah.compl_ca_header_id = p_compl_ca_header_id;
103 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
104 --
105 -- Declare local variables
106 --
107 l_legislation_code varchar2(150);
108 l_proc varchar2(72) := g_package||'return_legislation_code';
109 --
110 Begin
111 --
112 hr_utility.set_location('Entering:'|| l_proc, 10);
113 --
114 -- Ensure that all the mandatory parameter are not null
115 --
116 hr_api.mandatory_arg_error
117 (p_api_name => l_proc
118 ,p_argument => 'compl_ca_header_id'
119 ,p_argument_value => p_compl_ca_header_id
120 );
121 --
122 if ( nvl(ghr_cah_bus.g_compl_ca_header_id, hr_api.g_number)
123 = p_compl_ca_header_id) then
124 --
125 -- The legislation code has already been found with a previous
126 -- call to this function. Just return the value in the global
127 -- variable.
128 --
129 l_legislation_code := ghr_cah_bus.g_legislation_code;
130 hr_utility.set_location(l_proc, 20);
131 else
132 --
133 -- The ID is different to the last call to this function
134 -- or this is the first call to this function.
135 --
136 open csr_leg_code;
137 fetch csr_leg_code into l_legislation_code;
138 --
139 if csr_leg_code%notfound then
140 --
141 -- The primary key is invalid therefore we must error
142 --
143 close csr_leg_code;
144 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
145 fnd_message.raise_error;
146 end if;
147 hr_utility.set_location(l_proc,30);
148 --
149 -- Set the global variables so the values are
150 -- available for the next call to this function.
151 --
152 close csr_leg_code;
153 ghr_cah_bus.g_compl_ca_header_id := p_compl_ca_header_id;
154 ghr_cah_bus.g_legislation_code := l_legislation_code;
155 end if;
156 hr_utility.set_location(' Leaving:'|| l_proc, 40);
157 return l_legislation_code;
158 end return_legislation_code;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |-----------------------< chk_non_updateable_args >------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 -- This procedure is used to ensure that non updateable attributes have
167 -- not been updated. If an attribute has been updated an error is generated.
168 --
169 -- Pre Conditions:
170 -- g_old_rec has been populated with details of the values currently in
171 -- the database.
172 --
173 -- In Arguments:
174 -- p_rec has been populated with the updated values the user would like the
175 -- record set to.
176 --
177 -- Post Success:
178 -- Processing continues if all the non updateable attributes have not
179 -- changed.
180 --
181 -- Post Failure:
182 -- An application error is raised if any of the non updatable attributes
183 -- have been altered.
184 --
185 -- {End Of Comments}
186 -- ----------------------------------------------------------------------------
187 Procedure chk_non_updateable_args
188 (p_effective_date in date
189 ,p_rec in ghr_cah_shd.g_rec_type
190 ) IS
191 --
192 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
193 l_error EXCEPTION;
194 l_argument varchar2(30);
195 --
196 Begin
197 --
198 -- Only proceed with the validation if a row exists for the current
199 -- record in the HR Schema.
200 --
201 IF NOT ghr_cah_shd.api_updating
202 (p_compl_ca_header_id => p_rec.compl_ca_header_id
203 ,p_object_version_number => p_rec.object_version_number
204 ) THEN
205 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
206 fnd_message.set_token('PROCEDURE ', l_proc);
207 fnd_message.set_token('STEP ', '5');
208 fnd_message.raise_error;
209 END IF;
210 --
211 -- EDIT_HERE: Add checks to ensure non-updateable args have
212 -- not been updated.
213 --
214 EXCEPTION
215 WHEN l_error THEN
216 hr_api.argument_changed_error
217 (p_api_name => l_proc
218 ,p_argument => l_argument);
219 WHEN OTHERS THEN
220 RAISE;
221 End chk_non_updateable_args;
222 --
223
224 --
225 -----------------------------<chk_ca_source>------------------------------
226 --
227 --
228
229 PROCEDURE chk_ca_source(p_compl_ca_header_id in ghr_compl_ca_headers.compl_ca_header_id%TYPE,
230 p_ca_source in ghr_compl_ca_headers.ca_source%TYPE,
231 p_effective_date in date,
232 p_object_version_number in number)
233
234 IS
235
236 l_proc varchar2(72) := g_package||'chk_ca_source';
237 l_api_updating boolean;
238
239
240 BEGIN
241
242 hr_utility.set_location('Entering: '|| l_proc, 10);
243
244 -- Check Mandatory Parameters are set
245
246 hr_api.mandatory_arg_error
247 (p_api_name => l_proc,
248 p_argument => 'effective date',
249 p_argument_value => p_effective_date
250 );
251
252 --
253 -- Only Proceed with the validation if:
254 --
255 -- a) The current g_old_rec is current and
256 -- b) The ca_source value has changed
257 -- c) A record is being inserted.
258 --
259
260 l_api_updating := ghr_cah_shd.api_updating(
261 p_compl_ca_header_id => p_compl_ca_header_id,
262 p_object_version_number => p_object_version_number);
263
264 IF (l_api_updating
265 AND
266 ((nvl(ghr_cah_shd.g_old_rec.ca_source,hr_api.g_varchar2)
267 <> nvl(p_ca_source,hr_api.g_varchar2))))
268 OR
269 NOT l_api_updating THEN
270
271 --
272 hr_utility.set_location(l_proc,20);
273 --
274 -- If ca_source is not null then
275 -- Check if the ca_source value exists in fnd_lookups
276 -- Where the look up type is 'GHR_US_COMPLAINT_SOURCE'
277 --
278
279 IF p_ca_source is NOT NULL THEN
280
281 IF hr_api.not_exists_in_hr_lookups
282 (p_effective_date => p_effective_date,
283 p_lookup_type => 'GHR_US_COMPLAINT_SOURCE',
284 p_lookup_code => p_ca_source
285 ) THEN
286
287 -- Error: Invalid Subject to IA Action
288
289 -- New Message
290
291 hr_utility.set_message(8301,'GHR_38701_INV_COMPLAINT_SOURCE');
292 hr_utility.raise_error;
293 END IF;
294 hr_utility.set_location(l_proc,30);
295
296 END IF;
297
298 END IF;
299
300 hr_utility.set_location('Leaving: '|| l_proc, 40);
301
302 END chk_ca_source;
303
304 --
305 -----------------------------<chk_comrep_noncom_req>------------------------------
306 --
307 --
308
309 PROCEDURE chk_comrep_noncom_req(p_compl_ca_header_id in ghr_compl_ca_headers.compl_ca_header_id%TYPE,
310 p_comrep_noncom_req in ghr_compl_ca_headers.comrep_noncom_req%TYPE,
311 p_effective_date in date,
312 p_object_version_number in number)
313
314 IS
315
316 l_proc varchar2(72) := g_package||'chk_comrep_noncom_req';
317 l_api_updating boolean;
318
319
320 BEGIN
321
322 hr_utility.set_location('Entering: '|| l_proc, 10);
323
324 -- Check Mandatory Parameters are set
325
326 hr_api.mandatory_arg_error
327 (p_api_name => l_proc,
328 p_argument => 'effective date',
329 p_argument_value => p_effective_date
330 );
331
332 --
333 -- Only Proceed with the validation if:
334 --
335 -- a) The current g_old_rec is current and
336 -- b) The comrep_noncom_req value has changed
337 -- c) A record is being inserted.
338 --
339
340 l_api_updating := ghr_cah_shd.api_updating(
341 p_compl_ca_header_id => p_compl_ca_header_id,
342 p_object_version_number => p_object_version_number);
343
344 IF (l_api_updating
345 AND
346 ((nvl(ghr_cah_shd.g_old_rec.comrep_noncom_req,hr_api.g_varchar2)
347 <> nvl(p_comrep_noncom_req,hr_api.g_varchar2))))
348 OR
349 NOT l_api_updating THEN
350
351 --
352 hr_utility.set_location(l_proc,20);
353 --
354 -- If comrep_noncom_req is not null then
355 -- Check if the comrep_noncom_req value exists in fnd_lookups
356 -- Where the look up type is 'GHR_US_REQUEST'
357 --
358
359 IF p_comrep_noncom_req is NOT NULL THEN
360
361 IF hr_api.not_exists_in_hr_lookups
362 (p_effective_date => p_effective_date,
363 p_lookup_type => 'GHR_US_REQUEST',
364 p_lookup_code => p_comrep_noncom_req
365 ) THEN
366
367 -- Error: Invalid Subject to IA Action
368
369 -- New Message
370
371 hr_utility.set_message(8301,'GHR_38702_INV_COMP_REQUEST');
372 hr_utility.raise_error;
373 END IF;
374 hr_utility.set_location(l_proc,30);
375
376 END IF;
377
378 END IF;
379
380 hr_utility.set_location('Leaving: '|| l_proc, 40);
381
382 END chk_comrep_noncom_req;
383
384 --
385 -----------------------------<chk_stage_complaint_reinstated>------------------------------
386 --
387 --
388
389 PROCEDURE chk_stage_complaint_reinstated(p_compl_ca_header_id in ghr_compl_ca_headers.compl_ca_header_id%TYPE,
390 p_stage_complaint_reinstated in ghr_compl_ca_headers.stage_complaint_reinstated%TYPE,
391 p_effective_date in date,
392 p_object_version_number in number)
393
394 IS
395
396 l_proc varchar2(72) := g_package||'chk_stage_complaint_reinstated';
397 l_api_updating boolean;
398
399 BEGIN
400
401 hr_utility.set_location('Entering: '|| l_proc, 10);
402
403 -- Check Mandatory Parameters are set
404
405 hr_api.mandatory_arg_error
406 (p_api_name => l_proc,
407 p_argument => 'effective date',
408 p_argument_value => p_effective_date
409 );
410
411 --
412 -- Only Proceed with the validation if:
413 --
414 -- a) The current g_old_rec is current and
415 -- b) The stage_complaint_reinstated value has changed
416 -- c) A record is being inserted.
417 --
418
419 l_api_updating := ghr_cah_shd.api_updating(
423 IF (l_api_updating
420 p_compl_ca_header_id => p_compl_ca_header_id,
421 p_object_version_number => p_object_version_number);
422
424 AND
425 ((nvl(ghr_cah_shd.g_old_rec.stage_complaint_reinstated,hr_api.g_varchar2)
426 <> nvl(p_stage_complaint_reinstated,hr_api.g_varchar2))))
427 OR
428 NOT l_api_updating THEN
429
430 --
431 hr_utility.set_location(l_proc,20);
432 --
433 -- If stage_complaint_reinstated is not null then
434 -- Check if the stage_complaint_reinstated value exists in fnd_lookups
435 -- Where the look up type is 'GHR_US_STAGE'
436 --
437
438 IF p_stage_complaint_reinstated is NOT NULL THEN
439
440 IF hr_api.not_exists_in_hr_lookups
441 (p_effective_date => p_effective_date,
442 p_lookup_type => 'GHR_US_STAGE',
443 p_lookup_code => p_stage_complaint_reinstated
444 ) THEN
445
446 -- Error: Invalid Subject to IA Action
447
448 -- New Message
449
450 hr_utility.set_message(8301,'GHR_38703_INV_COMP_STAGE');
451 hr_utility.raise_error;
452 END IF;
453 hr_utility.set_location(l_proc,30);
454
455 END IF;
456
457 END IF;
458
459 hr_utility.set_location('Leaving: '|| l_proc, 40);
460
461 END chk_stage_complaint_reinstated;
462
463 --
464 -- ----------------------------------------------------------------------------
465 -- |---------------------------< insert_validate >----------------------------|
466 -- ----------------------------------------------------------------------------
467 Procedure insert_validate
468 (p_effective_date in date
469 ,p_rec in ghr_cah_shd.g_rec_type
470 ) is
471 --
472 l_proc varchar2(72) := g_package||'insert_validate';
473 --
474 Begin
475 hr_utility.set_location('Entering:'||l_proc, 5);
476 --
477 -- Call all supporting business operations
478 --
479 --
480 -- EDIT_HERE: As this table does not have a mandatory business_group_id
481 -- column, ensure client_info is populated by calling a suitable
482 -- ???_???_bus.set_security_group_id procedure, or add one of the following
483 -- comments:
484 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
485 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
486 --
487 --
488
489 chk_ca_source(p_compl_ca_header_id => p_rec.compl_ca_header_id
490 ,p_ca_source => p_rec.ca_source
491 ,p_effective_date => p_effective_date
492 ,p_object_version_number => p_rec.object_version_number);
493
494 chk_comrep_noncom_req(p_compl_ca_header_id => p_rec.compl_ca_header_id
495 ,p_comrep_noncom_req => p_rec.comrep_noncom_req
496 ,p_effective_date => p_effective_date
497 ,p_object_version_number => p_rec.object_version_number);
498
499 chk_stage_complaint_reinstated(p_compl_ca_header_id => p_rec.compl_ca_header_id
500 ,p_stage_complaint_reinstated => p_rec.stage_complaint_reinstated
501 ,p_effective_date => p_effective_date
502 ,p_object_version_number => p_rec.object_version_number);
503
504 hr_utility.set_location(' Leaving:'||l_proc, 10);
505 End insert_validate;
506 --
507 -- ----------------------------------------------------------------------------
508 -- |---------------------------< update_validate >----------------------------|
509 -- ----------------------------------------------------------------------------
510 Procedure update_validate
511 (p_effective_date in date
512 ,p_rec in ghr_cah_shd.g_rec_type
513 ) is
514 --
515 l_proc varchar2(72) := g_package||'update_validate';
516 --
517 Begin
518 hr_utility.set_location('Entering:'||l_proc, 5);
519 --
520 -- Call all supporting business operations
521 --
522 --
523 -- EDIT_HERE: As this table does not have a mandatory business_group_id
524 -- column, ensure client_info is populated by calling a suitable
525 -- ???_???_bus.set_security_group_id procedure, or add one of the following
526 -- comments:
527 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
528 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
529 --
530 chk_non_updateable_args
531 (p_effective_date => p_effective_date
532 ,p_rec => p_rec
533 );
534
535 chk_ca_source(p_compl_ca_header_id => p_rec.compl_ca_header_id
536 ,p_ca_source => p_rec.ca_source
537 ,p_effective_date => p_effective_date
538 ,p_object_version_number => p_rec.object_version_number);
539
540 chk_comrep_noncom_req(p_compl_ca_header_id => p_rec.compl_ca_header_id
541 ,p_comrep_noncom_req => p_rec.comrep_noncom_req
542 ,p_effective_date => p_effective_date
543 ,p_object_version_number => p_rec.object_version_number);
544
545 chk_stage_complaint_reinstated(p_compl_ca_header_id => p_rec.compl_ca_header_id
546 ,p_stage_complaint_reinstated => p_rec.stage_complaint_reinstated
547 ,p_effective_date => p_effective_date
548 ,p_object_version_number => p_rec.object_version_number);
549
550 --
551 --
552 hr_utility.set_location(' Leaving:'||l_proc, 10);
553 End update_validate;
554 --
555 -- ----------------------------------------------------------------------------
556 -- |---------------------------< delete_validate >----------------------------|
557 -- ----------------------------------------------------------------------------
558 Procedure delete_validate
559 (p_rec in ghr_cah_shd.g_rec_type
560 ) is
561 --
562 l_proc varchar2(72) := g_package||'delete_validate';
563 --
564 Begin
565 hr_utility.set_location('Entering:'||l_proc, 5);
566 --
567 -- Call all supporting business operations
568 --
569 hr_utility.set_location(' Leaving:'||l_proc, 10);
570 End delete_validate;
571 --
572 end ghr_cah_bus;