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