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