[Home] [Help]
PACKAGE BODY: APPS.FF_FFN_BUS
Source
1 Package Body ff_ffn_bus as
2 /* $Header: ffffnrhi.pkb 120.1 2005/10/05 01:50 adkumar noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ff_ffn_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_function_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_function_id in number
22 ,p_associated_column1 in varchar2 default null
23 ) is
24 --
25 -- Declare cursor
26 --
27 cursor csr_sec_grp is
28 select pbg.security_group_id,
29 pbg.legislation_code
30 from per_business_groups_perf pbg
31 , ff_functions ffn
32 where ffn.function_id = p_function_id
33 and pbg.business_group_id (+) = ffn.business_group_id;
34 --
35 -- Declare local variables
36 --
37 l_security_group_id number;
38 l_proc varchar2(72) := g_package||'set_security_group_id';
39 l_legislation_code varchar2(150);
40 --
41 begin
42 --
43 hr_utility.set_location('Entering:'|| l_proc, 10);
44 --
45 -- Ensure that all the mandatory parameter are not null
46 --
47 hr_api.mandatory_arg_error
48 (p_api_name => l_proc
49 ,p_argument => 'function_id'
50 ,p_argument_value => p_function_id
51 );
52 --
53 open csr_sec_grp;
54 fetch csr_sec_grp into l_security_group_id
55 , l_legislation_code;
56 --
57 if csr_sec_grp%notfound then
58 --
59 close csr_sec_grp;
60 --
61 -- The primary key is invalid therefore we must error
62 --
63 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
64 hr_multi_message.add
65 (p_associated_column1
66 => nvl(p_associated_column1,'FUNCTION_ID')
67 );
68 --
69 else
70 close csr_sec_grp;
71 --
72 -- Set the security_group_id in CLIENT_INFO
73 --
74 hr_api.set_security_group_id
75 (p_security_group_id => l_security_group_id
76 );
77 --
78 -- Set the sessions legislation context in HR_SESSION_DATA
79 --
80 hr_api.set_legislation_context(l_legislation_code);
81 end if;
82 --
83 hr_utility.set_location(' Leaving:'|| l_proc, 20);
84 --
85 end set_security_group_id;
86 --
87 -- ---------------------------------------------------------------------------
88 -- |---------------------< return_legislation_code >-------------------------|
89 -- ---------------------------------------------------------------------------
90 --
91 Function return_legislation_code
92 (p_function_id in number
93 )
94 Return Varchar2 Is
95 --
96 -- Declare cursor
97 --
98 cursor csr_leg_code is
99 select pbg.legislation_code
100 from per_business_groups_perf pbg
101 , ff_functions ffn
102 where ffn.function_id = p_function_id
103 and pbg.business_group_id (+) = ffn.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 => 'function_id'
119 ,p_argument_value => p_function_id
120 );
121 --
122 if ( nvl(ff_ffn_bus.g_function_id, hr_api.g_number)
123 = p_function_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 := ff_ffn_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 ff_ffn_bus.g_function_id := p_function_id;
154 ff_ffn_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 -- ----------------------------------------------------------------------------
162 -- |--------------------------< chk_legislation_code>-------------------------|
163 -- ----------------------------------------------------------------------------
164 --
165 -- Description:
166 -- Validates that the legislation code exists in fnd_territories
167 --
168 -- Pre-Requisites:
169 -- None
170 --
171 -- In Parameters:
172 -- p_legislation_code
173 --
174 -- Post Success:
175 -- Processing continues if the legislation_code is valid.
176 --
177 -- Post Failure:
178 -- An application error is raised and processing is terminated if
179 -- the legislation_code is invalid.
180 --
181 -- Developer/Implementation Notes:
182 -- None
183 --
184 -- Access Status:
185 -- Internal Row Handler Use Only
186 --
187 procedure chk_legislation_code
188 ( p_legislation_code in varchar2 )
189 is
190 --
191 cursor csr_legislation_code is
192 select null
193 from fnd_territories
194 where territory_code = p_legislation_code ;
195 --
196 l_exists varchar2(1);
197 l_proc varchar2(100) := g_package || 'chk_legislation_code';
198 begin
199 --
200 hr_utility.set_location('Entering:'|| l_proc, 10);
201
202 open csr_legislation_code;
203 fetch csr_legislation_code into l_exists ;
204
205 if csr_legislation_code%notfound then
206 close csr_legislation_code;
207 fnd_message.set_name('PAY', 'PAY_33177_LEG_CODE_INVALID');
208 fnd_message.raise_error;
209 end if;
210 close csr_legislation_code;
211
212 hr_utility.set_location(' Leaving:'|| l_proc, 20);
213 --
214 exception
215 when app_exception.application_exception then
216 if hr_multi_message.exception_add
217 (p_associated_column1 => 'FF_FUNCTIONS.LEGISLATION_CODE'
218 ) then
219 raise;
220 end if;
221 when others then
222 if csr_legislation_code%isopen then
223 close csr_legislation_code;
224 end if;
225 raise;
226 end chk_legislation_code;
227 --
228 -- ----------------------------------------------------------------------------
229 -- |--------------------------< chk_class >-----------------------------------|
230 -- ----------------------------------------------------------------------------
231 procedure chk_class
232 (p_effective_date in date
233 ,p_class in varchar2
234 ) is
235 --
236 l_proc varchar2(100) := g_package || 'chk_class';
237 --
238 begin
239 --
240 hr_utility.set_location('Entering:'|| l_proc, 10);
241 --
242 -- CLASS is mandatory.
243 --
244 hr_api.mandatory_arg_error
245 (p_api_name => l_proc
246 ,p_argument => 'CLASS'
247 ,p_argument_value => p_class
248 );
249 hr_utility.set_location('Entering:'|| l_proc, 20);
250 if hr_api.not_exists_in_hrstanlookups
251 (p_effective_date => p_effective_date
252 ,p_lookup_type => 'FUNCTION_CLASS'
253 ,p_lookup_code => p_class
254 ) then
255 ff_ffn_shd.constraint_error('FF_FUNC_CLASS_CHK');
256 end if;
257 --
258 hr_utility.set_location('Entering:'|| l_proc, 30);
259 -- User defined functions are not allowed.
260 if (p_class = 'U') then
261 ff_ffn_shd.constraint_error('FF_FUNC_CLASS_CHK');
262 end if;
263 --
264 hr_utility.set_location('Entering:'|| l_proc, 40);
265 --
266 exception
267 when app_exception.application_exception then
268 if hr_multi_message.exception_add
269 (p_associated_column1 => 'FF_FUNCTIONS.CLASS'
270 ) then
271 raise;
272 end if;
273 end chk_class;
274 --
275 -- ----------------------------------------------------------------------------
276 -- |--------------------------< chk_data_type >-------------------------------|
277 -- ----------------------------------------------------------------------------
278 procedure chk_data_type
279 (p_effective_date in date
280 ,p_data_type in varchar2
281 ) is
282 --
283 l_proc varchar2(100) := g_package || 'chk_data_type';
284 --
285 begin
286 --
287 hr_utility.set_location('Entering:'|| l_proc, 10);
288 --
289 -- DATA_TYPE is mandatory.
290 --
291 hr_api.mandatory_arg_error
292 (p_api_name => l_proc
293 ,p_argument => 'DATA_TYPE'
294 ,p_argument_value => p_data_type
295 );
296
297 if hr_api.not_exists_in_hrstanlookups
298 (p_effective_date => p_effective_date
299 ,p_lookup_type => 'DATA_TYPE'
300 ,p_lookup_code => p_data_type
301 ) then
302 ff_ffn_shd.constraint_error('FF_FUNC_DATA_TYPE_CHK');
303 end if;
304 --
305 hr_utility.set_location('Entering:'|| l_proc, 20);
306 --
307 exception
308 when app_exception.application_exception then
309 if hr_multi_message.exception_add
310 (p_associated_column1 => 'FF_FUNCTIONS.DATA_TYPE'
311 ) then
312 raise;
313 end if;
314 end chk_data_type;
315 --
316 -- ----------------------------------------------------------------------------
317 -- |--------------------------< chk_name >------------------------------------|
318 -- ----------------------------------------------------------------------------
319 procedure chk_name
320 (p_name in varchar2
321 ) is
322 --
323 l_proc varchar2(100) := g_package || 'chk_name';
324 dummy varchar2(80);
325 l_name varchar2(80);
326 --
327 begin
328 --
329 hr_utility.set_location('Entering:'|| l_proc, 10);
330 --
331 -- NAME is mandatory.
332 --
333 hr_api.mandatory_arg_error
334 (p_api_name => l_proc
335 ,p_argument => 'NAME'
336 ,p_argument_value => p_name
337 );
338 --
339 if (p_name is not null) then
340 l_name := p_name;
341 hr_chkfmt.checkformat (l_name,
342 'PAY_NAME',
343 dummy,
344 null,
345 null,
346 'N',
347 dummy,
348 null);
349 end if;
350 --
351 hr_utility.set_location('Entering:'|| l_proc, 20);
352 --
353 exception
354 when app_exception.application_exception then
355 if hr_multi_message.exception_add
356 (p_associated_column1 => 'FF_FUNCTIONS.NAME'
357 ) then
358 raise;
359 end if;
360 end chk_name;
361 --
362 -- ----------------------------------------------------------------------------
363 -- |----------------------------< chk_alias_name >----------------------------|
364 -- ----------------------------------------------------------------------------
365 procedure chk_alias_name
366 (p_alias_name in varchar2
367 ,p_name in varchar2
368 ) is
369 --
370 l_proc varchar2(100) := g_package || 'chk_alias_name';
371 dummy varchar2(80);
372 l_name varchar2(80);
373 begin
374
375 --
376 -- The Alias Name cannot be same as Name.
377 --
378 if (p_alias_name = p_name) then
379 fnd_message.set_name('FF','FF_52245_BAD_ALIAS_NAME');
380 fnd_message.raise_error;
381 end if;
382
383 -- Special character can not be used in alias name.
384 --
385 if (p_alias_name is not null) then
386 l_name := p_alias_name;
387 hr_chkfmt.checkformat (l_name,
388 'PAY_NAME',
389 dummy,
390 null,
391 null,
392 'N',
393 dummy,
394 null);
395 end if;
396 --
397 exception
398 when app_exception.application_exception then
399 if hr_multi_message.exception_add
400 (p_associated_column1 => 'FF_FUNCTIONS.ALIAS_NAME'
401 ) then
402 raise;
403 end if;
404 end chk_alias_name;
405 --
406 -- ----------------------------------------------------------------------------
407 -- |-----------------------< chk_non_updateable_args >------------------------|
408 -- ----------------------------------------------------------------------------
409 -- {Start Of Comments}
410 --
411 -- Description:
412 -- This procedure is used to ensure that non updateable attributes have
413 -- not been updated. If an attribute has been updated an error is generated.
414 --
415 -- Pre Conditions:
416 -- g_old_rec has been populated with details of the values currently in
417 -- the database.
418 --
419 -- In Arguments:
420 -- p_rec has been populated with the updated values the user would like the
421 -- record set to.
422 --
423 -- Post Success:
424 -- Processing continues if all the non updateable attributes have not
425 -- changed.
426 --
427 -- Post Failure:
428 -- An application error is raised if any of the non updatable attributes
429 -- have been altered.
430 --
431 -- {End Of Comments}
432 -- ----------------------------------------------------------------------------
433 Procedure chk_non_updateable_args
434 (p_effective_date in date
435 ,p_rec in ff_ffn_shd.g_rec_type
436 ) IS
437 --
438 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
439 --
440 Begin
441 --
442 -- Only proceed with the validation if a row exists for the current
443 -- record in the HR Schema.
444 --
445 IF NOT ff_ffn_shd.api_updating
446 (p_function_id => p_rec.function_id
447 ,p_object_version_number => p_rec.object_version_number
448 ) THEN
452 fnd_message.raise_error;
449 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
450 fnd_message.set_token('PROCEDURE ', l_proc);
451 fnd_message.set_token('STEP ', '5');
453 END IF;
454 --
455 --
456 if nvl(p_rec.business_group_id, hr_api.g_number) <>
457 nvl(ff_ffn_shd.g_old_rec.business_group_id, hr_api.g_number) then
458 hr_api.argument_changed_error
459 (p_api_name => l_proc
460 ,p_argument => 'BUSINESS_GROUP_ID'
461 ,p_base_table => ff_ffn_shd.g_tab_nam
462 );
463 end if;
464 --
465 if nvl(p_rec.legislation_code, hr_api.g_varchar2) <>
466 nvl(ff_ffn_shd.g_old_rec.legislation_code, hr_api.g_varchar2) then
467 hr_api.argument_changed_error
468 (p_api_name => l_proc
469 ,p_argument => 'LEGISLATION_CODE'
470 ,p_base_table => ff_ffn_shd.g_tab_nam
471 );
472 end if;
473
474 if nvl(p_rec.function_id, hr_api.g_number) <>
475 nvl(ff_ffn_shd.g_old_rec.function_id, hr_api.g_number) then
476 hr_api.argument_changed_error
477 (p_api_name => l_proc
478 ,p_argument => 'FUNCTION_ID'
479 ,p_base_table => ff_ffn_shd.g_tab_nam
480 );
481 end if;
482
483 --
484 End chk_non_updateable_args;
485 --
486 -- ----------------------------------------------------------------------------
487 -- |----------------------< chk_startup_action >------------------------------|
488 -- ----------------------------------------------------------------------------
489 --
490 -- Description:
491 -- This procedure will check that the current action is allowed according
492 -- to the current startup mode.
493 --
494 -- ----------------------------------------------------------------------------
495 PROCEDURE chk_startup_action
496 (p_insert IN boolean
497 ,p_business_group_id IN number
498 ,p_legislation_code IN varchar2
499 ,p_legislation_subgroup IN varchar2 DEFAULT NULL) IS
500 --
501 BEGIN
502 --
503 -- Call the supporting procedure to check startup mode
504
505 IF (p_insert) THEN
506
507 if p_business_group_id is not null and p_legislation_code is not null then
508 fnd_message.set_name('PAY', 'PAY_33179_BGLEG_INVALID');
509 fnd_message.raise_error;
510 end if;
511
512 hr_startup_data_api_support.chk_startup_action
513 (p_generic_allowed => TRUE
514 ,p_startup_allowed => TRUE
515 ,p_user_allowed => TRUE
516 ,p_business_group_id => p_business_group_id
517 ,p_legislation_code => p_legislation_code
518 ,p_legislation_subgroup => p_legislation_subgroup
519 );
520 ELSE
521 hr_startup_data_api_support.chk_upd_del_startup_action
522 (p_generic_allowed => TRUE
523 ,p_startup_allowed => TRUE
524 ,p_user_allowed => TRUE
525 ,p_business_group_id => p_business_group_id
526 ,p_legislation_code => p_legislation_code
527 ,p_legislation_subgroup => p_legislation_subgroup
528 );
529 END IF;
530 --
531 END chk_startup_action;
532 --
533 -- ----------------------------------------------------------------------------
534 -- |---------------------------< insert_validate >----------------------------|
535 -- ----------------------------------------------------------------------------
536 Procedure insert_validate
537 (p_effective_date in date
538 ,p_rec in ff_ffn_shd.g_rec_type
539 ) is
540 --
541 l_proc varchar2(72) := g_package||'insert_validate';
542 --
543 Begin
544 hr_utility.set_location('Entering:'||l_proc, 5);
545 --
546 -- Call all supporting business operations
547 --
548 --
549 chk_startup_action(true
550 ,p_rec.business_group_id
551 ,p_rec.legislation_code
552 );
553 IF hr_startup_data_api_support.g_startup_mode
554 NOT IN ('GENERIC','STARTUP') THEN
555 --
556 -- Validate Important Attributes
557 --
558 hr_api.validate_bus_grp_id
559 (p_business_group_id => p_rec.business_group_id
560 ,p_associated_column1 => ff_ffn_shd.g_tab_nam
561 || '.BUSINESS_GROUP_ID');
562 --
563 -- after validating the set of important attributes,
564 -- if Multiple Message Detection is enabled and at least
565 -- one error has been found then abort further validation.
566 --
567 hr_multi_message.end_validation_set;
568 END IF;
569
570 --
571 -- ----------------------------------------------------------------------------
572 IF hr_startup_data_api_support.g_startup_mode
573 IN ('STARTUP') THEN
574
575 chk_legislation_code
576 (p_legislation_code => p_rec.legislation_code);
577 End if;
578 --
579 -- ----------------------------------------------------------------------------
580
581 --
582 --
583 -- Validate Dependent Attributes
584 --
585 -----------------------------------------------------------------------------
586 chk_class(p_effective_date => p_effective_date
587 ,p_class => p_rec.class
588 );
589 -----------------------------------------------------------------------------
590 chk_data_type(p_effective_date => p_effective_date
591 ,p_data_type => p_rec.data_type
592 );
593
594 -----------------------------------------------------------------------------
595 chk_name(p_name => p_rec.name);
596
597 -----------------------------------------------------------------------------
598 chk_alias_name(p_alias_name => p_rec.alias_name
599 ,p_name => p_rec.name
600 );
601 -----------------------------------------------------------------------------
602 --
603 hr_utility.set_location(' Leaving:'||l_proc, 10);
604
605 End insert_validate;
606 --
610 Procedure update_validate
607 -- ----------------------------------------------------------------------------
608 -- |---------------------------< update_validate >----------------------------|
609 -- ----------------------------------------------------------------------------
611 (p_effective_date in date
612 ,p_rec in ff_ffn_shd.g_rec_type
613 ) is
614 --
615 l_proc varchar2(72) := g_package||'update_validate';
616 --
617 Begin
618 hr_utility.set_location('Entering:'||l_proc, 5);
619 --
620 -- Call all supporting business operations
621 --
622 --
623 chk_startup_action(false
624 ,p_rec.business_group_id
625 ,p_rec.legislation_code
626 );
627 IF hr_startup_data_api_support.g_startup_mode
628 NOT IN ('GENERIC','STARTUP') THEN
629 --
630 -- Validate Important Attributes
631 --
632 hr_api.validate_bus_grp_id
633 (p_business_group_id => p_rec.business_group_id
634 ,p_associated_column1 => ff_ffn_shd.g_tab_nam
635 || '.BUSINESS_GROUP_ID');
636 --
637 -- After validating the set of important attributes,
638 -- if Multiple Message Detection is enabled and at least
639 -- one error has been found then abort further validation.
640 --
641 hr_multi_message.end_validation_set;
642 END IF;
643 --
644 --
645 -- Validate Dependent Attributes
646 --
647 chk_non_updateable_args
648 (p_effective_date => p_effective_date
649 ,p_rec => p_rec
650 );
651 -----------------------------------------------------------------------------
652 chk_class(p_effective_date => p_effective_date
653 ,p_class => p_rec.class
654 );
655 -----------------------------------------------------------------------------
656 chk_data_type(p_effective_date => p_effective_date
657 ,p_data_type => p_rec.data_type
658 );
659
660 -----------------------------------------------------------------------------
661 chk_name(p_name => p_rec.name);
662
663 -----------------------------------------------------------------------------
664 chk_alias_name(p_alias_name => p_rec.alias_name
665 ,p_name => p_rec.name
666 );
667 -----------------------------------------------------------------------------
668 --
669 hr_utility.set_location(' Leaving:'||l_proc, 10);
670 End update_validate;
671 --
672 -- ----------------------------------------------------------------------------
673 -- |---------------------------< delete_validate >----------------------------|
674 -- ----------------------------------------------------------------------------
675 Procedure delete_validate
676 (p_rec in ff_ffn_shd.g_rec_type
677 ) is
678 --
679 l_proc varchar2(72) := g_package||'delete_validate';
680 --
681 Begin
682 hr_utility.set_location('Entering:'||l_proc, 5);
683 --
684 --
685 chk_startup_action(false
686 ,ff_ffn_shd.g_old_rec.business_group_id
687 ,ff_ffn_shd.g_old_rec.legislation_code
688 );
689 IF hr_startup_data_api_support.g_startup_mode
690 NOT IN ('GENERIC','STARTUP') THEN
691 --
692 -- Validate Important Attributes
693 --
694 --
695 -- After validating the set of important attributes,
696 -- if Multiple Message Detection is enabled and at least
697 -- one error has been found then abort further validation.
698 --
699 hr_multi_message.end_validation_set;
700 END IF;
701 --
702 -- Call all supporting business operations
703 --
704 hr_utility.set_location(' Leaving:'||l_proc, 10);
705 End delete_validate;
706 --
707 end ff_ffn_bus;