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