[Home] [Help]
PACKAGE BODY: APPS.BEN_TUR_BUS
Source
1 Package Body ben_tur_bus as
2 /* $Header: beturrhi.pkb 120.1 2008/02/05 08:20:57 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_tur_bus.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_tbco_use_rt_id >------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description
15 -- This procedure is used to check that the primary key for the table
16 -- is created properly. It should be null on insert and
17 -- should not be able to be updated.
18 --
19 -- Pre Conditions
20 -- None.
21 --
22 -- In Parameters
23 -- tbco_use_rt_id PK of record being inserted or updated.
24 -- effective_date Effective Date of session
25 -- object_version_number Object version number of record being
26 -- inserted or updated.
27 --
28 -- Post Success
29 -- Processing continues
30 --
31 -- Post Failure
32 -- Errors handled by the procedure
33 --
34 -- Access Status
35 -- Internal table handler use only.
36 --
37 Procedure chk_tbco_use_rt_id(p_tbco_use_rt_id in number,
38 p_effective_date in date,
39 p_object_version_number in number) is
40 --
41 l_proc varchar2(72) := g_package||'chk_tbco_use_rt_id';
42 l_api_updating boolean;
43 --
44 Begin
45 --
46 hr_utility.set_location('Entering:'||l_proc, 5);
47 --
48 l_api_updating := ben_tur_shd.api_updating
49 (p_effective_date => p_effective_date,
50 p_tbco_use_rt_id => p_tbco_use_rt_id,
51 p_object_version_number => p_object_version_number);
52 --
53 if (l_api_updating
54 and nvl(p_tbco_use_rt_id,hr_api.g_number)
55 <> ben_tur_shd.g_old_rec.tbco_use_rt_id) then
56 --
57 -- raise error as PK has changed
58 --
59 ben_tur_shd.constraint_error('BEN_TBCO_USE_RT_PK');
60 --
61 elsif not l_api_updating then
62 --
63 -- check if PK is null
64 --
65 if p_tbco_use_rt_id is not null then
66 --
67 -- raise error as PK is not null
68 --
69 ben_tur_shd.constraint_error('BEN_TBCO_USE_RT_PK');
70 --
71 end if;
72 --
73 end if;
74 --
75 hr_utility.set_location('Leaving:'||l_proc, 10);
76 --
77 End chk_tbco_use_rt_id;
78 --
79 -- |--------------------< chk_duplicate_ordr_num >----------------------------|
80 -- ----------------------------------------------------------------------------
81 --
82 -- Description
83 --
84 -- Pre Conditions
85 -- None.
86 --
87 -- In Parameters
88 -- p_vrbl_rt_prfl_id
89 -- p_ordr_num
90 -- p_effective_date
91 -- p_business_group_id
92 --
93 -- Post Success
94 -- Processing continues
95 --
96 -- Post Failure
97 -- Errors handled by the procedure
98 --
99 -- Access Status
100 -- Internal table handler use only.
101 --
102 -- ----------------------------------------------------------------------------
103 procedure chk_duplicate_ordr_num
104 (p_vrbl_rt_prfl_id in number
105 ,p_ordr_num in number
106 ,p_effective_date in date
107 ,p_business_group_id in number
108 ,p_tbco_use_rt_id in number)
109 is
110 l_proc varchar2(72) := g_package||' chk_duplicate_ordr_num ';
111 l_dummy char(1);
112 cursor c1 is select null
113 from ben_tbco_use_rt_f
114 where vrbl_rt_prfl_id = p_vrbl_rt_prfl_id
115 and tbco_use_rt_id <> nvl(p_tbco_use_rt_id,-1)
116 and p_effective_date between effective_start_date
117 and effective_end_date
118 and business_group_id + 0 = p_business_group_id
119 and ordr_num = p_ordr_num;
120 --
121 Begin
122 hr_utility.set_location('Entering:'||l_proc, 5);
123
124 --
125 open c1;
126 fetch c1 into l_dummy;
127 --
128 if c1%found then
129 fnd_message.set_name('BEN','BEN_91001_SEQ_NOT_UNIQUE');
130 fnd_message.raise_error;
131 end if;
132 close c1;
133 --
134 hr_utility.set_location('Leaving:'||l_proc, 15);
135 End chk_duplicate_ordr_num;
136
137 --
138 -- ----------------------------------------------------------------------------
139 -- |------< chk_excld_flag >------|
140 -- ----------------------------------------------------------------------------
141 --
142 -- Description
143 -- This procedure is used to check that the lookup value is valid.
144 --
145 -- Pre Conditions
146 -- None.
147 --
148 -- In Parameters
149 -- tbco_use_rt_id PK of record being inserted or updated.
150 -- excld_flag Value of lookup code.
151 -- effective_date effective date
152 -- object_version_number Object version number of record being
153 -- inserted or updated.
154 --
155 -- Post Success
156 -- Processing continues
157 --
158 -- Post Failure
159 -- Error handled by procedure
160 --
161 -- Access Status
162 -- Internal table handler use only.
163 --
164 Procedure chk_excld_flag(p_tbco_use_rt_id in number,
165 p_excld_flag in varchar2,
166 p_effective_date in date,
167 p_object_version_number in number) is
168 --
169 l_proc varchar2(72) := g_package||'chk_excld_flag';
170 l_api_updating boolean;
171 --
172 Begin
173 --
174 hr_utility.set_location('Entering:'||l_proc, 5);
175 --
176 l_api_updating := ben_tur_shd.api_updating
177 (p_tbco_use_rt_id => p_tbco_use_rt_id,
178 p_effective_date => p_effective_date,
179 p_object_version_number => p_object_version_number);
180 --
181 if (l_api_updating
182 and p_excld_flag
183 <> nvl(ben_tur_shd.g_old_rec.excld_flag,hr_api.g_varchar2)
184 or not l_api_updating) then
185 --
186 -- check if value of lookup falls within lookup type.
187 --
188 --
189 if hr_api.not_exists_in_hr_lookups
190 (p_lookup_type => 'YES_NO',
191 p_lookup_code => p_excld_flag,
192 p_effective_date => p_effective_date) then
193 --
194 -- raise error as does not exist as lookup
195 --
196 hr_utility.set_message(801,'HR_LOOKUP_DOES_NOT_EXIST');
197 hr_utility.raise_error;
198 --
199 end if;
200 --
201 end if;
202 --
203 hr_utility.set_location('Leaving:'||l_proc,10);
204 --
205 end chk_excld_flag;
206 --
207 -- ----------------------------------------------------------------------------
208 -- |------< chk_uses_tbco_flag >------|
209 -- ----------------------------------------------------------------------------
210 --
211 -- Description
212 -- This procedure is used to check that the lookup value is valid.
213 --
214 -- Pre Conditions
215 -- None.
216 --
217 -- In Parameters
218 -- tbco_use_rt_id PK of record being inserted or updated.
219 -- uses_tbco_flag Value of lookup code.
220 -- effective_date effective date
221 -- object_version_number Object version number of record being
222 -- inserted or updated.
223 --
224 -- Post Success
225 -- Processing continues
226 --
227 -- Post Failure
228 -- Error handled by procedure
229 --
230 -- Access Status
231 -- Internal table handler use only.
232 --
233 Procedure chk_uses_tbco_flag(p_tbco_use_rt_id in number,
234 p_uses_tbco_flag in varchar2,
235 p_effective_date in date,
236 p_object_version_number in number,
237 p_vrbl_rt_prfl_id in number,
238 p_business_group_id in number,
239 p_validation_start_date in date,
240 p_validation_end_date in date) is
241 --
242 l_proc varchar2(72) := g_package||'chk_uses_tbco_flag';
243 l_api_updating boolean;
244 l_exists varchar2(1);
245 --
246 -- begin bug # 2452735
247 cursor c_dup is
248 select null
249 from ben_tbco_use_rt_f
250 where uses_tbco_flag = p_uses_tbco_flag
251 and vrbl_rt_prfl_id = p_vrbl_rt_prfl_id
252 and tbco_use_rt_id <> nvl(p_tbco_use_rt_id,hr_api.g_number)
253 and business_group_id + 0 = p_business_group_id
254 and p_validation_start_date <= effective_end_date
255 and p_validation_end_date >= effective_start_date;
256 -- end bug # 2452735
257 Begin
258 --
259 hr_utility.set_location('Entering:'||l_proc, 5);
260 --
261 l_api_updating := ben_tur_shd.api_updating
262 (p_tbco_use_rt_id => p_tbco_use_rt_id,
263 p_effective_date => p_effective_date,
264 p_object_version_number => p_object_version_number);
265 --
266 if (l_api_updating
267 and p_uses_tbco_flag
268 <> nvl(ben_tur_shd.g_old_rec.uses_tbco_flag,hr_api.g_varchar2)
269 or not l_api_updating) then
270 --
271 -- check if value of lookup falls within lookup type.
272 --
273 --
274 if hr_api.not_exists_in_hr_lookups
275 (p_lookup_type => 'TOBACCO_USER',
276 p_lookup_code => p_uses_tbco_flag,
277 p_effective_date => p_effective_date) then
278 --
279 -- raise error as does not exist as lookup
280 --
281 hr_utility.set_message(801,'HR_LOOKUP_DOES_NOT_EXIST');
282 hr_utility.raise_error;
283 --
284 end if;
285 --
286 -- begin bug # 2452735
287 open c_dup;
288 fetch c_dup into l_exists;
289 if c_dup%found then
290 close c_dup;
291 --
292 -- raise error as this tobacco usage already exists for this profile
293 --
294 fnd_message.set_name('BEN', 'BEN_92992_DUPS_ROW');
295 fnd_message.set_token('VAR1','Tobacco Use criteria');
296 fnd_message.set_token('VAR2','Variable Rate Profile');
297 fnd_message.raise_error;
298 --
299 end if;
300 close c_dup;
301 -- end bug # 2452735
302 end if;
303 --
304 hr_utility.set_location('Leaving:'||l_proc,10);
305 --
306 end chk_uses_tbco_flag;
307 --
308 -- ----------------------------------------------------------------------------
309 -- |--------------------------< dt_update_validate >--------------------------|
310 -- ----------------------------------------------------------------------------
311 -- {Start Of Comments}
312 --
313 -- Description:
314 -- This procedure is used for referential integrity of datetracked
315 -- parent entities when a datetrack update operation is taking place
316 -- and where there is no cascading of update defined for this entity.
317 --
318 -- Prerequisites:
319 -- This procedure is called from the update_validate.
320 --
321 -- In Parameters:
322 --
323 -- Post Success:
324 -- Processing continues.
325 --
326 -- Post Failure:
327 --
328 -- Developer Implementation Notes:
329 -- This procedure should not need maintenance unless the HR Schema model
330 -- changes.
331 --
332 -- Access Status:
333 -- Internal Row Handler Use Only.
334 --
335 -- {End Of Comments}
336 -- ----------------------------------------------------------------------------
337 Procedure dt_update_validate
338 (p_vrbl_rt_prfl_id in number default hr_api.g_number,
339 p_datetrack_mode in varchar2,
340 p_validation_start_date in date,
341 p_validation_end_date in date) Is
342 --
343 l_proc varchar2(72) := g_package||'dt_update_validate';
344 l_integrity_error Exception;
345 l_table_name all_tables.table_name%TYPE;
346 --
347 Begin
348 hr_utility.set_location('Entering:'||l_proc, 5);
349 --
350 -- Ensure that the p_datetrack_mode argument is not null
351 --
352 hr_api.mandatory_arg_error
353 (p_api_name => l_proc,
354 p_argument => 'datetrack_mode',
355 p_argument_value => p_datetrack_mode);
356 --
357 -- Only perform the validation if the datetrack update mode is valid
358 --
359 If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
360 --
361 --
362 -- Ensure the arguments are not null
363 --
364 hr_api.mandatory_arg_error
365 (p_api_name => l_proc,
366 p_argument => 'validation_start_date',
367 p_argument_value => p_validation_start_date);
368 --
369 hr_api.mandatory_arg_error
370 (p_api_name => l_proc,
371 p_argument => 'validation_end_date',
372 p_argument_value => p_validation_end_date);
373 --
374 If ((nvl(p_vrbl_rt_prfl_id, hr_api.g_number) <> hr_api.g_number) and
375 NOT (dt_api.check_min_max_dates
376 (p_base_table_name => 'ben_vrbl_rt_prfl_f',
377 p_base_key_column => 'vrbl_rt_prfl_id',
378 p_base_key_value => p_vrbl_rt_prfl_id,
379 p_from_date => p_validation_start_date,
380 p_to_date => p_validation_end_date))) Then
381 l_table_name := 'ben_vrbl_rt_prfl_f';
382 Raise l_integrity_error;
383 End If;
384 --
385 End If;
386 --
387 hr_utility.set_location(' Leaving:'||l_proc, 10);
388 Exception
389 When l_integrity_error Then
390 --
391 -- A referential integrity check was violated therefore
392 -- we must error
393 --
394 ben_utility.parent_integrity_error (p_table_name => l_table_name);
395 --
396 When Others Then
397 --
398 -- An unhandled or unexpected error has occurred which
399 -- we must report
400 --
401 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
402 hr_utility.set_message_token('PROCEDURE', l_proc);
403 hr_utility.set_message_token('STEP','15');
404 hr_utility.raise_error;
405 End dt_update_validate;
406 --
407 -- ----------------------------------------------------------------------------
408 -- |--------------------------< dt_delete_validate >--------------------------|
409 -- ----------------------------------------------------------------------------
410 -- {Start Of Comments}
411 --
412 -- Description:
413 -- This procedure is used for referential integrity of datetracked
414 -- child entities when either a datetrack DELETE or ZAP is in operation
415 -- and where there is no cascading of delete defined for this entity.
416 -- For the datetrack mode of DELETE or ZAP we must ensure that no
417 -- datetracked child rows exist between the validation start and end
418 -- dates.
419 --
420 -- Prerequisites:
421 -- This procedure is called from the delete_validate.
422 --
423 -- In Parameters:
424 --
425 -- Post Success:
426 -- Processing continues.
427 --
428 -- Post Failure:
429 -- If a row exists by determining the returning Boolean value from the
430 -- generic dt_api.rows_exist function then we must supply an error via
431 -- the use of the local exception handler l_rows_exist.
432 --
433 -- Developer Implementation Notes:
434 -- This procedure should not need maintenance unless the HR Schema model
435 -- changes.
436 --
437 -- Access Status:
438 -- Internal Row Handler Use Only.
439 --
440 -- {End Of Comments}
441 -- ----------------------------------------------------------------------------
442 Procedure dt_delete_validate
443 (p_tbco_use_rt_id in number,
444 p_datetrack_mode in varchar2,
445 p_validation_start_date in date,
446 p_validation_end_date in date) Is
447 --
448 l_proc varchar2(72) := g_package||'dt_delete_validate';
449 l_rows_exist Exception;
450 l_table_name all_tables.table_name%TYPE;
451 --
452 Begin
453 hr_utility.set_location('Entering:'||l_proc, 5);
454 --
455 -- Ensure that the p_datetrack_mode argument is not null
456 --
457 hr_api.mandatory_arg_error
458 (p_api_name => l_proc,
459 p_argument => 'datetrack_mode',
460 p_argument_value => p_datetrack_mode);
461 --
462 -- Only perform the validation if the datetrack mode is either
463 -- DELETE or ZAP
464 --
465 If (p_datetrack_mode = 'DELETE' or
466 p_datetrack_mode = 'ZAP') then
467 --
468 --
469 -- Ensure the arguments are not null
470 --
471 hr_api.mandatory_arg_error
472 (p_api_name => l_proc,
473 p_argument => 'validation_start_date',
474 p_argument_value => p_validation_start_date);
475 --
476 hr_api.mandatory_arg_error
477 (p_api_name => l_proc,
478 p_argument => 'validation_end_date',
479 p_argument_value => p_validation_end_date);
480 --
481 hr_api.mandatory_arg_error
482 (p_api_name => l_proc,
483 p_argument => 'tbco_use_rt_id',
484 p_argument_value => p_tbco_use_rt_id);
485 --
486 --
487 --
488 End If;
489 --
490 hr_utility.set_location(' Leaving:'||l_proc, 10);
491 Exception
492 When l_rows_exist Then
493 --
494 -- A referential integrity check was violated therefore
495 -- we must error
496 --
497 hr_utility.set_message(801, 'HR_7215_DT_CHILD_EXISTS');
498 hr_utility.set_message_token('TABLE_NAME', l_table_name);
499 hr_utility.raise_error;
500 When Others Then
501 --
502 -- An unhandled or unexpected error has occurred which
503 -- we must report
504 --
505 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
506 hr_utility.set_message_token('PROCEDURE', l_proc);
507 hr_utility.set_message_token('STEP','15');
508 hr_utility.raise_error;
509 End dt_delete_validate;
510 --
511 -- ----------------------------------------------------------------------------
512 -- |---------------------------< insert_validate >----------------------------|
513 -- ----------------------------------------------------------------------------
514 Procedure insert_validate
515 (p_rec in ben_tur_shd.g_rec_type,
516 p_effective_date in date,
517 p_datetrack_mode in varchar2,
518 p_validation_start_date in date,
519 p_validation_end_date in date) is
520 --
521 l_proc varchar2(72) := g_package||'insert_validate';
522 --
523 Begin
524 hr_utility.set_location('Entering:'||l_proc, 5);
525 --
526 -- Call all supporting business operations
527 --
528 --
529 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
530 --
531 chk_tbco_use_rt_id
532 (p_tbco_use_rt_id => p_rec.tbco_use_rt_id,
533 p_effective_date => p_effective_date,
534 p_object_version_number => p_rec.object_version_number);
535 --
536 chk_excld_flag
537 (p_tbco_use_rt_id => p_rec.tbco_use_rt_id,
538 p_excld_flag => p_rec.excld_flag,
539 p_effective_date => p_effective_date,
540 p_object_version_number => p_rec.object_version_number);
541 --
542 chk_uses_tbco_flag
543 (p_tbco_use_rt_id => p_rec.tbco_use_rt_id,
544 p_uses_tbco_flag => p_rec.uses_tbco_flag,
545 p_effective_date => p_effective_date,
546 p_object_version_number => p_rec.object_version_number,
547 p_vrbl_rt_prfl_id => p_rec.vrbl_rt_prfl_id,
548 p_business_group_id => p_rec.business_group_id,
549 p_validation_start_date => p_validation_start_date,
550 p_validation_end_date => p_validation_end_date);
551 --
552 chk_duplicate_ordr_num
553 (p_vrbl_rt_prfl_id => p_rec.vrbl_rt_prfl_id
554 ,p_ordr_num => p_rec.ordr_num
555 ,p_effective_date => p_effective_date
556 ,p_business_group_id => p_rec.business_group_id
557 ,p_tbco_use_rt_id => p_rec.tbco_use_rt_id);
558 --
559 hr_utility.set_location(' Leaving:'||l_proc, 10);
560 End insert_validate;
561 --
562 -- ----------------------------------------------------------------------------
563 -- |---------------------------< update_validate >----------------------------|
564 -- ----------------------------------------------------------------------------
565 Procedure update_validate
566 (p_rec in ben_tur_shd.g_rec_type,
567 p_effective_date in date,
568 p_datetrack_mode in varchar2,
569 p_validation_start_date in date,
570 p_validation_end_date in date) is
571 --
572 l_proc varchar2(72) := g_package||'update_validate';
573 --
574 Begin
575 hr_utility.set_location('Entering:'||l_proc, 5);
576 --
577 -- Call all supporting business operations
578 --
579 --
580 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
581 --
582 chk_tbco_use_rt_id
583 (p_tbco_use_rt_id => p_rec.tbco_use_rt_id,
584 p_effective_date => p_effective_date,
585 p_object_version_number => p_rec.object_version_number);
586 --
587 chk_excld_flag
588 (p_tbco_use_rt_id => p_rec.tbco_use_rt_id,
589 p_excld_flag => p_rec.excld_flag,
590 p_effective_date => p_effective_date,
591 p_object_version_number => p_rec.object_version_number);
592 --
593 chk_uses_tbco_flag
594 (p_tbco_use_rt_id => p_rec.tbco_use_rt_id,
595 p_uses_tbco_flag => p_rec.uses_tbco_flag,
596 p_effective_date => p_effective_date,
597 p_object_version_number => p_rec.object_version_number,
598 p_vrbl_rt_prfl_id => p_rec.vrbl_rt_prfl_id,
599 p_business_group_id => p_rec.business_group_id,
600 p_validation_start_date => p_validation_start_date,
601 p_validation_end_date => p_validation_end_date);
602 --
603 -- Call the datetrack update integrity operation
604 --
605 dt_update_validate
606 (
607 p_datetrack_mode => p_datetrack_mode,
608 p_validation_start_date => p_validation_start_date,
609 p_validation_end_date => p_validation_end_date);
610 --
611 chk_duplicate_ordr_num
612 (p_vrbl_rt_prfl_id => p_rec.vrbl_rt_prfl_id
613 ,p_ordr_num => p_rec.ordr_num
614 ,p_effective_date => p_effective_date
615 ,p_business_group_id => p_rec.business_group_id
616 ,p_tbco_use_rt_id => p_rec.tbco_use_rt_id);
617 --
618 hr_utility.set_location(' Leaving:'||l_proc, 10);
619 End update_validate;
620 --
621 -- ----------------------------------------------------------------------------
622 -- |---------------------------< delete_validate >----------------------------|
623 -- ----------------------------------------------------------------------------
624 Procedure delete_validate
625 (p_rec in ben_tur_shd.g_rec_type,
626 p_effective_date in date,
627 p_datetrack_mode in varchar2,
628 p_validation_start_date in date,
629 p_validation_end_date in date) is
630 --
631 l_proc varchar2(72) := g_package||'delete_validate';
632 --
633 Begin
634 hr_utility.set_location('Entering:'||l_proc, 5);
635 --
636 -- Call all supporting business operations
637 --
638 dt_delete_validate
639 (p_datetrack_mode => p_datetrack_mode,
640 p_validation_start_date => p_validation_start_date,
641 p_validation_end_date => p_validation_end_date,
642 p_tbco_use_rt_id => p_rec.tbco_use_rt_id);
643 --
644 hr_utility.set_location(' Leaving:'||l_proc, 10);
645 End delete_validate;
646 --
647 --
648 -- ---------------------------------------------------------------------------
649 -- |---------------------< return_legislation_code >-------------------------|
650 -- ---------------------------------------------------------------------------
651 --
652 function return_legislation_code
653 (p_tbco_use_rt_id in number) return varchar2 is
654 --
655 -- Declare cursor
656 --
657 cursor csr_leg_code is
658 select a.legislation_code
659 from per_business_groups a,
660 ben_tbco_use_rt_f b
661 where b.tbco_use_rt_id = p_tbco_use_rt_id
662 and a.business_group_id = b.business_group_id;
663 --
664 -- Declare local variables
665 --
666 l_legislation_code varchar2(150);
667 l_proc varchar2(72) := g_package||'return_legislation_code';
668 --
669 begin
670 --
671 hr_utility.set_location('Entering:'|| l_proc, 10);
672 --
673 -- Ensure that all the mandatory parameter are not null
674 --
675 hr_api.mandatory_arg_error(p_api_name => l_proc,
676 p_argument => 'tbco_use_rt_id',
677 p_argument_value => p_tbco_use_rt_id);
678 --
679 open csr_leg_code;
680 --
681 fetch csr_leg_code into l_legislation_code;
682 --
683 if csr_leg_code%notfound then
684 --
685 close csr_leg_code;
686 --
687 -- The primary key is invalid therefore we must error
688 --
689 hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
690 hr_utility.raise_error;
691 --
692 end if;
693 --
694 close csr_leg_code;
695 --
696 hr_utility.set_location(' Leaving:'|| l_proc, 20);
697 --
698 return l_legislation_code;
699 --
700 end return_legislation_code;
701 --
702 end ben_tur_bus;