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