[Home] [Help]
PACKAGE BODY: APPS.HR_AMD_BUS
Source
1 Package Body hr_amd_bus as
2 /* $Header: hramdrhi.pkb 115.6 2002/12/03 16:08:21 apholt ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_amd_bus.'; -- Global package name
9 --
10 -- -----------------------------------------------------------------
11 -- |-----------------------< chk_non_updateable_args >--------------|
12 -- -----------------------------------------------------------------
13 --
14 Procedure chk_non_updateable_args
15 (p_rec in hr_amd_shd.g_rec_type
16 ) is
17 --
18 l_proc varchar2(72) := g_package||'chk_non_updateable_args';
19 l_error exception;
20 l_argument varchar2(30);
21 --
22 Begin
23 hr_utility.set_location('Entering:'||l_proc, 10);
24 --
25 -- Only proceed with validation if a row exists for
26 -- the current record in the HR Schema
27 --
28 if not hr_amd_shd.api_updating
29 (p_api_module_id => p_rec.api_module_id
30 ) then
31 hr_utility.set_message(800, 'HR_6153_ALL_PROCEDURE_FAIL');
32 hr_utility.set_message_token('PROCEDURE', l_proc);
33 hr_utility.set_message_token('STEP', '20');
34 end if;
35 hr_utility.set_location(l_proc, 30);
36 --
37 if nvl(p_rec.api_module_type, hr_api.g_varchar2) <>
38 nvl(hr_amd_shd.g_old_rec.api_module_type
39 ,hr_api.g_varchar2
40 ) then
41 l_argument := 'api_module_type';
42 raise l_error;
43 end if;
44 --
45 --
46 if nvl(p_rec.legislation_code, hr_api.g_varchar2) <>
47 nvl(hr_amd_shd.g_old_rec.legislation_code
48 ,hr_api.g_varchar2
49 ) then
50 l_argument := 'legislation_code';
51 raise l_error;
52 end if;
53 --
54 hr_utility.set_location(l_proc, 40);
55 exception
56 when l_error then
57 hr_api.argument_changed_error
58 (p_api_name => l_proc
59 ,p_argument => l_argument
60 );
61 when others then
62 raise;
63 hr_utility.set_location(' Leaving:'||l_proc, 50);
64 end chk_non_updateable_args;
65 --
66 -- -----------------------------------------------------------------
67 -- |-----------------------< chk_api_module_type >-------------------------|
68 -- -----------------------------------------------------------------
69 --
70 -- Description:
71 -- Checks that the module type is not null and takes a valid value.
72 --
73 -- Pre-Requisites:
74 -- None
75 --
76 -- In Parameters:
77 -- p_api_module_id
78 -- p_api_module_type
79 --
80 -- Post Success:
81 -- Processing continues if the module_type is valid.
82 --
83 -- Post Failure:
84 -- An application error is raised and processing is terminated if
85 -- the module_type is invalid.
86 --
87 -- Access Status:
88 -- Internal Row Handler Use Only.
89 --
90 Procedure chk_api_module_type
91 (p_api_module_id in number,
92 p_api_module_type in varchar2,
93 p_effective_date in date
94 ) is
95 --
96 -- Local declarations
97 l_proc varchar2(72) := g_package||' chk_api_module_type';
98 l_api_updating boolean;
99 --
100 begin
101 hr_utility.set_location('Entering: '||l_proc,5);
102 --
103 --------------------------------
104 -- Check module type not null --
105 --------------------------------
106 hr_api.mandatory_arg_error
107 (p_api_name => l_proc,
108 p_argument => 'p_api_module_type',
109 p_argument_value => p_api_module_type);
110 --------------------------------
111 -- Check module type is valid --
112 --------------------------------
113 if hr_api.not_exists_in_hr_lookups
114 (p_effective_date => p_effective_date,
115 p_lookup_type => 'API_MODULE_TYPE',
116 p_lookup_code => p_api_module_type) then
117 hr_amd_shd.constraint_error('HR_API_MODULES_CK1');
118 end if;
119
120 hr_utility.set_location('Leaving: '||l_proc,10);
121 end chk_api_module_type;
122 --
123 --
124 --
125 --
126 -- -----------------------------------------------------------------
127 -- |-----------------------< chk_module_name >-------------------------|
128 -- -----------------------------------------------------------------
129 --
130 -- Description:
131 -- Validates that the module_name is not null, entered in upper case and
132 -- that the combination of name and package is unique on the table.
133 --
134 -- Pre-Requisites:
135 -- None
136 --
137 -- In Parameters:
138 -- p_api_module_id
139 -- p_api_module_type
140 -- p_module_name
141 --
142 -- Post Success:
143 -- Processing continues if the module_name is valid.
144 --
145 -- Post Failure:
146 -- An application error is raised and processing is terminated if
147 -- the is module_name invalid.
148 --
149 -- Access Status:
150 -- Internal Row Handler Use Only.
151 --
152 Procedure chk_module_name
153 (p_api_module_id in number,
154 p_api_module_type in varchar2,
155 p_module_name in varchar2
156 ) is
157 --
158 -- Local declarations
159 l_proc varchar2(72) := g_package||'chk_module_name';
160 l_module_name varchar2(30) := p_module_name;
161 l_module_type varchar2(30);
162 l_module_id number := 0;
163 l_api_updating boolean;
164 --
165 -- Declare a cursor that will check whether the passed
166 -- in module type and module name form a unique combination
167 cursor csr_valid_combo is
168 select api_module_id from hr_api_modules ham
169 where ham.module_name = p_module_name
170 and ham.api_module_type = p_api_module_type;
171
172 begin
173 hr_utility.set_location('Entering: '||l_proc,5);
174
175 -- check if the module is being updated or inserted.
176 l_api_updating := hr_amd_shd.api_updating
177 (p_api_module_id => p_api_module_id);
178 --
179 -- Proceed with validation based on outcome of api_updating call.
180
181 if ((l_api_updating and
182 hr_amd_shd.g_old_rec.module_name <> nvl(p_module_name,hr_api.g_varchar2)) or
183 (not l_api_updating)) then
184 --------------------------------
185 -- Check module name not null --
186 --------------------------------
187 hr_api.mandatory_arg_error
188 (p_api_name => l_proc,
189 p_argument => 'p_module_name',
190 p_argument_value => p_module_name);
191
192 ---------------------------------------------------------------
193 -- Check that the module name has been entered in upper case --
194 ---------------------------------------------------------------
195
196 if( p_module_name <> upper(l_module_name) ) then
197 hr_utility.set_message(800, 'PER_52118_AMD_MOD_NAME_NOT_UPP');
198 hr_utility.raise_error;
199 end if;
200
201 --------------------------------------------------------
202 -- Check for unique Module name and module type combo --
203 --------------------------------------------------------
204 open csr_valid_combo;
205 fetch csr_valid_combo into l_module_id;
206
207 if csr_valid_combo%found then
208 close csr_valid_combo;
209 hr_amd_shd.constraint_error('HR_API_MODULES_UK1');
210 end if;
211
212 close csr_valid_combo;
213 end if;
214 hr_utility.set_location('Leaving: '||l_proc,10);
215 end chk_module_name;
216 --
217 --
218 --
219 -- -----------------------------------------------------------------
220 -- |-----------------------< chk_data_within_business_group >------|
221 -- -----------------------------------------------------------------
222 --
223 -- Description:
224 -- Checks that data_within_business_group is valid and non null.
225 --
226 -- Pre-Requisites:
227 -- None
228 --
229 -- In Parameters:
230 -- p_api_module_id
231 -- p_data_within_business_group
232 -- p_effective_date
233 --
234 -- Post Success:
235 -- Processing continues if the data_within_business_group is valid.
236 --
237 -- Post Failure:
238 -- An application error is raised and processing is terminated if
239 -- the data_within_business_group is invalid.
240 --
241 -- Access Status:
242 -- Internal Row Handler Use Only.
243 --
244 Procedure chk_data_within_business_group
245 (p_api_module_id in number,
246 p_data_within_business_group in varchar2,
247 p_effective_date in date
248 ) is
249 --
250 -- Local declarations
251 l_proc varchar2(72) := g_package||'chk_data_within_business_group';
252 l_application_id hr_lookups.application_id%TYPE;
253 --
254 -- Cursor and local variable to control changing data_within business_group
255 -- from Yes to No
256 --
257 l_exists varchar2(1);
258 --
259 Cursor csr_legislation_data is
260 select null
261 from hr_api_hooks hk
262 where hk.api_module_id = p_api_module_id
263 and (legislation_package is not null
264 or legislation_function is not null) ;
265 --
266 begin
267 hr_utility.set_location('Entering: '||l_proc,5);
268
269 ----------------------------------------
270 -- Check data within bus grp not null --
271 ----------------------------------------
272 hr_api.mandatory_arg_error
273 (p_api_name => l_proc,
274 p_argument => 'p_data_within_business_group',
275 p_argument_value => p_data_within_business_group);
276 --------------------------------
277 -- Check module type is valid --
278 --------------------------------
279 if (p_api_module_id is not null) and
280 (hr_amd_shd.g_old_rec.data_within_business_group
281 <> p_data_within_business_group) or
282 (p_api_module_id is null) then
283 --
284 -- do look up validation
285 --
286 if hr_api.not_exists_in_hr_lookups
287 (p_effective_date => p_effective_date,
288 p_lookup_type => 'YES_NO',
289 p_lookup_code => p_data_within_business_group) then
290 -- Error, invalid value.
291 hr_amd_shd.constraint_error('HR_API_MODULES_CK2');
292 end if;
293 --
294 if ((p_api_module_id is not null)
295 and hr_amd_shd.g_old_rec.data_within_business_group ='Y'
296 and p_data_within_business_group = 'N') then
297 open csr_legislation_data;
298 fetch csr_legislation_data into l_exists;
299 if csr_legislation_data%found then
300 close csr_legislation_data;
301 hr_utility.set_message(800, 'PER_74019_LEG_CODE');
302 hr_utility.raise_error;
303 end if;
304 hr_utility.set_location('Entering: '||l_proc,7);
305 close csr_legislation_data;
306 end if;
307 --
308 end if;
309 --
310 hr_utility.set_location('Leaving: '||l_proc,10);
311 end chk_data_within_business_group;
312 --
313 --
314 --
315 -- -----------------------------------------------------------------
316 -- |-----------------------< chk_legislation_code >----------------|
317 -- -----------------------------------------------------------------
318 --
319 -- Description:
320 -- Check that the legislation_code is valid within FND_TERRITORIES
321 --
322 -- Pre-Requisites:
323 -- None
324 --
325 -- In Parameters:
326 -- p_api_module_id
327 -- p_legislation_code
328 --
329 -- Post Success:
330 -- Processing continues if legislation_code the is valid.
331 --
332 -- Post Failure:
333 -- An application error is raised and processing is terminated if
334 -- the is legislation_code invalid.
335 --
336 -- Access Status:
337 -- Internal Row Handler Use Only.
338 --
339 Procedure chk_legislation_code
340 (p_api_module_id in number,
341 p_legislation_code in varchar2
342 ) is
343 --
344 -- Local declarations
345 l_proc varchar2(72) := g_package||'chk_legislation_code';
346 l_territory_code fnd_territories.territory_code%TYPE;
347 --
348 -- Setup cursor for valid legislation code check
349 cursor csr_valid_legislation_code is
350 select territory_code
351 from fnd_territories ft
352 where ft.territory_code = p_legislation_code;
353
354 --
355 --
356 begin
357 hr_utility.set_location('Entering: '||l_proc,5);
358
359 --------------------------------
360 -- Check legislation code is valid --
361 --------------------------------
362 if p_legislation_code is not null then
363 open csr_valid_legislation_code;
364 fetch csr_valid_legislation_code into l_territory_code;
365
366 if csr_valid_legislation_code%notfound then
367 close csr_valid_legislation_code;
368 hr_utility.set_message(800,'PER_52123_AMD_LEG_CODE_INV');
369 hr_utility.raise_error;
370 end if; -- End cursor if
371
372 close csr_valid_legislation_code;
373 end if; -- end check
374
375 hr_utility.set_location('Leaving: '||l_proc,10);
376 end chk_legislation_code;
377 --
378 --
379 --
380 -- -----------------------------------------------------------------
381 -- |-----------------------< chk_module_package >------------------|
382 -- -----------------------------------------------------------------
383 --
384 -- Description:
385 -- Checks that the module_package is entered in upper case and that the
386 -- combination of module_package and module_type is valid.
387 --
388 -- Pre-Requisites:
389 -- None
390 --
391 -- In Parameters:
392 -- p_api_module_id
393 -- p_api_module_type
394 -- p_module_package
395 --
396 -- Post Success:
397 -- Processing continues if the module_package is valid.
398 --
399 -- Post Failure:
400 -- An application error is raised and processing is terminated if
401 -- the is module_package invalid.
402 --
403 -- Access Status:
404 -- Internal Row Handler Use Only.
405 --
406 Procedure chk_module_package
407 (p_api_module_id in number,
408 p_api_module_type in varchar2,
409 p_module_package in varchar2
410 ) is
411 --
412 -- Local declarations
413 l_proc varchar2(72) := g_package||'chk_module_package';
414 l_module_package varchar2(30) := p_module_package;
415 l_api_updating boolean;
416 --
417 begin
418 hr_utility.set_location('Entering: '||l_proc,5);
419 -- Check if module is being updated
420 l_api_updating := hr_amd_shd.api_updating
421 (p_api_module_id => p_api_module_id);
422
423 -- Proceed with validation based on outcome of api_updating call.
424 -- Have to convert null values of module_package (a null value is
425 -- valid for this parm) otherwise the comparison will always
426 -- return false.
427 if ((l_api_updating and
431 -- Check the Module Package and Module Type Combo is valid --
428 nvl(hr_amd_shd.g_old_rec.module_package,'X') <> nvl(p_module_package,'X')) or
429 (not l_api_updating)) then
430 -------------------------------------------------------------
432 -------------------------------------------------------------
433
434 if p_api_module_type = 'BP' and p_module_package is null then
435 hr_utility.set_message(800, 'PER_52124_AMD_MOD_PACK_INV1');
436 hr_utility.raise_error;
437 elsif p_api_module_type = 'RH' and p_module_package is not null then
438 hr_utility.set_message(800, 'PER_52125_AMD_MOD_PACK_INV2');
439 hr_utility.raise_error;
440 end if;
441
442 ---------------------------------------------------------------
443 -- Check that the module name has been entered in upper case --
444 ---------------------------------------------------------------
445
446 if( p_module_package <> upper(l_module_package) ) then
447 hr_utility.set_message(800, 'PER_52120_AMD_MOD_PACK_NOT_UPP');
448 hr_utility.raise_error;
449 end if;
450 end if;
451
452 hr_utility.set_location('Leaving: '||l_proc,10);
453 end chk_module_package;
454 --
455 --
456 -- -----------------------------------------------------------------
457 -- |-----------------------< chk_delete >-------------------------|
458 -- -----------------------------------------------------------------
459 --
460 -- Description:
461 -- Prevents deletion of a row if it has children
462 --
463 -- Pre-Requisites:
464 -- None
465 --
466 -- In Parameters:
467 -- p_api_module_id
468 --
469 -- Post Success:
470 -- Processing continues if the row has no children
471 --
472 -- Post Failure:
473 -- An application error is raised and processing is terminated if
474 -- the row has children.
475 --
476 -- Access Status:
477 -- Internal Row Handler Use Only.
478 --
479 Procedure chk_delete
480 (p_api_module_id in number
481 ) is
482 --
483 -- Local declarations
484 l_proc varchar2(72) := g_package||'chk_delete';
485 l_api_module_id number;
486 --
487 -- Setup cursor to check for children
488 cursor csr_check_for_child is
489 select api_module_id
490 from hr_api_hooks hah
491 where hah.api_module_id = p_api_module_id;
492 --
493 --
494 begin
495 hr_utility.set_location('Entering: '||l_proc,5);
496
497 -- We don't have to check for valid module id as this is done by the lck proc
498 --------------------------------------
499 -- Check if module has any children --
500 --------------------------------------
501
502 open csr_check_for_child;
503 fetch csr_check_for_child into l_api_module_id;
504
505 if csr_check_for_child%found then
506 close csr_check_for_child;
507 hr_utility.set_message(800,'PER_52155_AMD_CANNOT_DEL_ROW');
508 hr_utility.raise_error;
509 end if;
510
511 close csr_check_for_child;
512
513 hr_utility.set_location('Leaving: '||l_proc,10);
514 end chk_delete;
515 --
516 --
517 -- ----------------------------------------------------------------------------
518 -- |---------------------------< insert_validate >----------------------------|
519 -- ----------------------------------------------------------------------------
520 Procedure insert_validate(p_rec in hr_amd_shd.g_rec_type,
521 p_effective_date in date ) is
522 --
523 l_proc varchar2(72) := g_package||'insert_validate';
524 --
525 Begin
526 hr_utility.set_location('Entering:'||l_proc, 5);
527 --
528 -- As this data is not within the context of a business group
529 -- the set_security_group_id procedure has zero passed
530 -- to it as the default security_group_id.
531 --
532 hr_api.set_security_group_id(p_security_group_id => 0);
533 --
534 --
535 hr_utility.set_location('Entering:'||l_proc, 7);
536 --
537 -- Call all supporting business operations
538 --
539 -- Validate Module Type
540 chk_api_module_type
541 (p_api_module_id => p_rec.api_module_id,
542 p_api_module_type => p_rec.api_module_type,
543 p_effective_date => p_effective_date
544 );
545 --
546 -- Validate Module Name
547 chk_module_name
548 (p_api_module_id => p_rec.api_module_id,
549 p_api_module_type => p_rec.api_module_type,
550 p_module_name => p_rec.module_name
551 );
552 --
553 -- Validate Data within Business Group
554 chk_data_within_business_group
555 (p_api_module_id => p_rec.api_module_id,
556 p_data_within_business_group => p_rec.data_within_business_group,
557 p_effective_date => p_effective_date
558 );
559 --
560 -- Validate Legislation Code
561 chk_legislation_code
562 (p_api_module_id => p_rec.api_module_id,
563 p_legislation_code => p_rec.legislation_code
564 );
565 --
566 -- Validate Module Package
567 chk_module_package
568 (p_api_module_id => p_rec.api_module_id,
569 p_api_module_type => p_rec.api_module_type,
570 p_module_package => p_rec.module_package
571 );
572 hr_utility.set_location(' Leaving:'||l_proc, 10);
573 End insert_validate;
574 --
575 -- ----------------------------------------------------------------------------
576 -- -----------------------------< update_validate >----------------------------|
577 -- ----------------------------------------------------------------------------
578 Procedure update_validate(p_rec in hr_amd_shd.g_rec_type,
579 p_effective_date in date) is
580 --
581 l_proc varchar2(72) := g_package||'update_validate';
582 --
583 Begin
584 hr_utility.set_location('Entering:'||l_proc, 5);
585 --
586 -- As this data is not within the context of a business group
587 -- the set_security_group_id procedure has zero passed
588 -- to it as the default security_group_id.
589 --
590 hr_api.set_security_group_id(p_security_group_id => 0);
591 --
592 -- Check that all non-updateable args have in fact not been modified.
593 --
594 hr_utility.set_location('Entering:'||l_proc, 7);
595 --
596 hr_amd_bus.chk_non_updateable_args(p_rec => p_rec);
597 --
598 -- Call all supporting business operations
599 --
600 -- Validate Module Name
601 chk_module_name
602 (p_api_module_id => p_rec.api_module_id,
603 p_api_module_type => p_rec.api_module_type,
604 p_module_name => p_rec.module_name
605 );
606 --
607 -- Validate Data within Business Group
608 chk_data_within_business_group
609 (p_api_module_id => p_rec.api_module_id,
610 p_data_within_business_group => p_rec.data_within_business_group,
611 p_effective_date => p_effective_date
612 );
613 --
614 -- Validate Module Package
615 chk_module_package
616 (p_api_module_id => p_rec.api_module_id,
617 p_api_module_type => p_rec.api_module_type,
618 p_module_package => p_rec.module_package
619 );
620 --
621 --
622 hr_utility.set_location(' Leaving:'||l_proc, 10);
623 End update_validate;
624 --
625 -- ----------------------------------------------------------------------------
626 -- |---------------------------< delete_validate >----------------------------|
627 -- ----------------------------------------------------------------------------
628 Procedure delete_validate(p_rec in hr_amd_shd.g_rec_type) is
629 --
630 l_proc varchar2(72) := g_package||'delete_validate';
631 --
632 Begin
633 hr_utility.set_location('Entering:'||l_proc, 5);
634 --
635 -- Call all supporting business operations
636 chk_delete(p_api_module_id => p_rec.api_module_id);
637 --
638 hr_utility.set_location(' Leaving:'||l_proc, 10);
639 End delete_validate;
640 --
641 end hr_amd_bus;