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