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