[Home] [Help]
PACKAGE BODY: APPS.BEN_BPL_DEL
Source
1 Package Body ben_bpl_del as
2 /* $Header: bebplrhi.pkb 120.1.12010000.2 2008/09/18 04:35:40 sallumwa ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_bpl_del.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |----------------------------< dt_delete_dml >-----------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 -- This procedure controls the actual dml delete logic for the datetrack
17 -- delete modes: ZAP, DELETE, FUTURE_CHANGE and DELETE_NEXT_CHANGE. The
18 -- execution is as follows:
19 -- 1) To set and unset the g_api_dml status as required (as we are about to
20 -- perform dml).
21 -- 2) If the delete mode is DELETE_NEXT_CHANGE then delete where the
22 -- effective start date is equal to the validation start date.
23 -- 3) If the delete mode is not DELETE_NEXT_CHANGE then delete
24 -- all rows for the entity where the effective start date is greater
25 -- than or equal to the validation start date.
26 -- 4) To raise any errors.
27 --
28 -- Prerequisites:
29 -- This is an internal private procedure which must be called from the
30 -- delete_dml procedure.
31 --
32 -- In Parameters:
33 -- A Pl/Sql record structre.
34 --
35 -- Post Success:
36 -- The specified row will be delete from the schema.
37 --
38 -- Post Failure:
39 -- On the delete dml failure it is important to note that we always reset the
40 -- g_api_dml status to false.
41 -- If any other error is reported, the error will be raised after the
42 -- g_api_dml status is reset.
43 --
44 -- Developer Implementation Notes:
45 -- This is an internal private procedure which must be called from the
46 -- delete_dml procedure.
47 --
48 -- Access Status:
49 -- Internal Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure dt_delete_dml
54 (p_rec in out nocopy ben_bpl_shd.g_rec_type,
55 p_effective_date in date,
56 p_datetrack_mode in varchar2,
57 p_validation_start_date in date,
58 p_validation_end_date in date) is
59 --
60 l_proc varchar2(72) := g_package||'dt_delete_dml';
61 --
62 Begin
63 hr_utility.set_location('Entering:'||l_proc, 5);
64 If (p_datetrack_mode = 'DELETE_NEXT_CHANGE') then
65 hr_utility.set_location(l_proc, 10);
66 ben_bpl_shd.g_api_dml := true; -- Set the api dml status
67 --
68 -- Delete the where the effective start date is equal
69 -- to the validation end date.
70 --
71 delete from ben_bnft_prvdd_ldgr_f
72 where bnft_prvdd_ldgr_id = p_rec.bnft_prvdd_ldgr_id
73 and effective_start_date = p_validation_start_date;
74 --
75 ben_bpl_shd.g_api_dml := false; -- Unset the api dml status
76 Else
77 hr_utility.set_location(l_proc, 15);
78 ben_bpl_shd.g_api_dml := true; -- Set the api dml status
79 --
80 -- Delete the row(s) where the effective start date is greater than
81 -- or equal to the validation start date.
82 --
83 delete from ben_bnft_prvdd_ldgr_f
84 where bnft_prvdd_ldgr_id = p_rec.bnft_prvdd_ldgr_id
85 and effective_start_date >= p_validation_start_date;
86 --
87 ben_bpl_shd.g_api_dml := false; -- Unset the api dml status
88 End If;
89 --
90 hr_utility.set_location(' Leaving:'||l_proc, 20);
91 --
92 Exception
93 When Others Then
94 ben_bpl_shd.g_api_dml := false; -- Unset the api dml status
95 Raise;
96 End dt_delete_dml;
97 --
98 -- ----------------------------------------------------------------------------
99 -- |------------------------------< delete_dml >------------------------------|
100 -- ----------------------------------------------------------------------------
101 Procedure delete_dml
102 (p_rec in out nocopy ben_bpl_shd.g_rec_type,
103 p_effective_date in date,
104 p_datetrack_mode in varchar2,
105 p_validation_start_date in date,
106 p_validation_end_date in date) is
107 --
108 l_proc varchar2(72) := g_package||'delete_dml';
109 --
110 Begin
111 hr_utility.set_location('Entering:'||l_proc, 5);
112 --
113 dt_delete_dml(p_rec => p_rec,
114 p_effective_date => p_effective_date,
115 p_datetrack_mode => p_datetrack_mode,
116 p_validation_start_date => p_validation_start_date,
117 p_validation_end_date => p_validation_end_date);
118 --
119 hr_utility.set_location(' Leaving:'||l_proc, 10);
120 End delete_dml;
121 --
122 -- ----------------------------------------------------------------------------
123 -- |----------------------------< dt_pre_delete >-----------------------------|
124 -- ----------------------------------------------------------------------------
125 -- {Start Of Comments}
126 --
127 -- Description:
128 -- The dt_pre_delete process controls the execution of dml
129 -- for the datetrack modes: DELETE, FUTURE_CHANGE
130 -- and DELETE_NEXT_CHANGE only.
131 --
132 -- Prerequisites:
133 -- This is an internal procedure which is called from the pre_delete
134 -- procedure.
135 --
136 -- In Parameters:
137 -- A Pl/Sql record structre.
138 --
139 -- Post Success:
140 -- Processing continues.
141 --
142 -- Post Failure:
143 -- If an error has occurred, an error message and exception will be raised
144 -- but not handled.
145 --
146 -- Developer Implementation Notes:
147 -- This is an internal procedure which is required by Datetrack. Don't
148 -- remove or modify.
149 --
150 -- Access Status:
151 -- Internal Row Handler Use Only.
152 --
153 -- {End Of Comments}
154 -- ----------------------------------------------------------------------------
155 Procedure dt_pre_delete
156 (p_rec in out nocopy ben_bpl_shd.g_rec_type,
157 p_effective_date in date,
158 p_datetrack_mode in varchar2,
159 p_validation_start_date in date,
160 p_validation_end_date in date) is
161 --
162 l_proc varchar2(72) := g_package||'dt_pre_delete';
163 --
164 Begin
165 hr_utility.set_location('Entering:'||l_proc, 5);
166 --
167 If (p_datetrack_mode <> 'ZAP') then
168 --
169 p_rec.effective_start_date := ben_bpl_shd.g_old_rec.effective_start_date;
170 --
171 If (p_datetrack_mode = 'DELETE') then
172 p_rec.effective_end_date := p_validation_start_date - 1;
173 Else
174 p_rec.effective_end_date := p_validation_end_date;
175 End If;
176 --
177 -- Update the current effective end date record
178 --
179 ben_bpl_shd.upd_effective_end_date
180 (p_effective_date => p_effective_date,
181 p_base_key_value => p_rec.bnft_prvdd_ldgr_id,
182 p_new_effective_end_date => p_rec.effective_end_date,
183 p_validation_start_date => p_validation_start_date,
184 p_validation_end_date => p_validation_end_date,
185 p_object_version_number => p_rec.object_version_number);
186 Else
187 p_rec.effective_start_date := null;
188 p_rec.effective_end_date := null;
189 End If;
190 hr_utility.set_location(' Leaving:'||l_proc, 10);
191 End dt_pre_delete;
192 --
193 -- ----------------------------------------------------------------------------
194 -- |------------------------------< pre_delete >------------------------------|
195 -- ----------------------------------------------------------------------------
196 -- {Start Of Comments}
197 --
198 -- Description:
199 -- This private procedure contains any processing which is required before
200 -- the delete dml.
201 --
202 -- Prerequisites:
203 -- This is an internal procedure which is called from the del procedure.
204 --
205 -- In Parameters:
206 -- A Pl/Sql record structre.
207 --
208 -- Post Success:
209 -- Processing continues.
210 --
211 -- Post Failure:
212 -- If an error has occurred, an error message and exception will be raised
213 -- but not handled.
214 --
215 -- Developer Implementation Notes:
216 -- Any pre-processing required before the delete dml is issued should be
217 -- coded within this procedure. It is important to note that any 3rd party
218 -- maintenance should be reviewed before placing in this procedure. The call
219 -- to the dt_delete_dml procedure should NOT be removed.
220 --
221 -- Access Status:
222 -- Internal Row Handler Use Only.
223 --
224 -- {End Of Comments}
225 -- ----------------------------------------------------------------------------
226 Procedure pre_delete
227 (p_rec in out nocopy ben_bpl_shd.g_rec_type,
228 p_effective_date in date,
229 p_datetrack_mode in varchar2,
230 p_validation_start_date in date,
231 p_validation_end_date in date) is
232 --
233 l_proc varchar2(72) := g_package||'pre_delete';
234 --
235 --
236 --
237 Begin
238 hr_utility.set_location('Entering:'||l_proc, 5);
239 --
240 --
241 --
242 hr_utility.set_location(p_rec.USED_VAL || '*' ||
243 p_rec.FRFTD_VAL || '*' ||
244 p_rec.PRVDD_VAL || '*' ||
245 p_rec.CASH_RECD_VAL , 99);
246 --
247 hr_utility.set_location(p_rec.ACTY_BASE_RT_ID || '*' ||
248 p_rec.PRTT_RO_OF_UNUSD_AMT_FLAG, 99);
249 --
250 dt_pre_delete
251 (p_rec => p_rec,
252 p_effective_date => p_effective_date,
253 p_datetrack_mode => p_datetrack_mode,
254 p_validation_start_date => p_validation_start_date,
255 p_validation_end_date => p_validation_end_date);
256 --
257 hr_utility.set_location(' Leaving:'||l_proc, 10);
258 End pre_delete;
259 --
260 -- ----------------------------------------------------------------------------
261 -- |-----------------------------< post_delete >------------------------------|
262 -- ----------------------------------------------------------------------------
263 -- {Start Of Comments}
264 --
265 -- Description:
266 -- This private procedure contains any processing which is required after the
267 -- delete dml.
268 --
269 -- Prerequisites:
270 -- This is an internal procedure which is called from the del procedure.
271 --
272 -- In Parameters:
273 -- A Pl/Sql record structre.
274 --
275 -- Post Success:
276 -- Processing continues.
277 --
278 -- Post Failure:
279 -- If an error has occurred, an error message and exception will be raised
280 -- but not handled.
281 --
282 -- Developer Implementation Notes:
283 -- Any post-processing required after the delete dml is issued should be
284 -- coded within this procedure. It is important to note that any 3rd party
285 -- maintenance should be reviewed before placing in this procedure.
286 --
287 -- Access Status:
288 -- Internal Row Handler Use Only.
289 --
290 -- {End Of Comments}
291 -- ----------------------------------------------------------------------------
292 Procedure post_delete
293 (p_rec in ben_bpl_shd.g_rec_type,
294 p_effective_date in date,
295 p_datetrack_mode in varchar2,
296 p_validation_start_date in date,
297 p_validation_end_date in date) is
298 --
299 l_proc varchar2(72) := g_package||'post_delete';
300 --
301 -- Bug 5500864
302 CURSOR c_curr_pil
303 IS
304 SELECT pil_new.per_in_ler_id
305 FROM ben_per_in_ler pil_old, ben_per_in_ler pil_new
306 WHERE pil_old.person_id = pil_new.person_id
307 AND pil_old.per_in_ler_id = ben_bpl_shd.g_old_rec.per_in_ler_id
308 AND pil_new.per_in_ler_stat_cd in ('STRTD','PROCD') -- Bug 7380983
309 ORDER BY pil_new.lf_evt_ocrd_dt desc; -- Bug 7380983
310
311 --
312 l_per_in_ler_id NUMBER (30);
313 --
314 --
315 Begin
316 hr_utility.set_location('Entering:'||l_proc, 5);
317 --
318 -- Bug 5500864
319 --
320 if p_datetrack_mode = hr_api.g_delete
321 then
322 --
323 open c_curr_pil;
324 fetch c_curr_pil into l_per_in_ler_id;
325 close c_curr_pil;
326 --
327 INSERT INTO ben_le_clsn_n_rstr
328 (
329 bkup_tbl_id,
330 bkup_tbl_typ_cd,
331 per_in_ler_id,
332 effective_start_date,
333 effective_end_date,
334 object_version_number
335 )
336 VALUES
337 (
338 p_rec.bnft_prvdd_ldgr_id,
339 'BEN_BNFT_PRVDD_LDGR_F',
340 l_per_in_ler_id,
341 ben_bpl_shd.g_old_rec.effective_start_date ,
342 ben_bpl_shd.g_old_rec.effective_end_date ,
343 ben_bpl_shd.g_old_rec.object_version_number + 1
344 );
345 --
346 end if;
347 --
348 -- Bug 5500864
349 --
350 -- Start of API User Hook for post_delete.
351 --
352 begin
353 --
354 ben_bpl_rkd.after_delete
355 (
356 p_bnft_prvdd_ldgr_id =>p_rec.bnft_prvdd_ldgr_id
357 ,p_datetrack_mode =>p_datetrack_mode
358 ,p_validation_start_date =>p_validation_start_date
359 ,p_validation_end_date =>p_validation_end_date
360 ,p_effective_start_date =>p_rec.effective_start_date
361 ,p_effective_end_date =>p_rec.effective_end_date
362 ,p_effective_start_date_o =>ben_bpl_shd.g_old_rec.effective_start_date
363 ,p_effective_end_date_o =>ben_bpl_shd.g_old_rec.effective_end_date
364 ,p_prtt_ro_of_unusd_amt_flag_o =>ben_bpl_shd.g_old_rec.prtt_ro_of_unusd_amt_flag
365 ,p_frftd_val_o =>ben_bpl_shd.g_old_rec.frftd_val
366 ,p_prvdd_val_o =>ben_bpl_shd.g_old_rec.prvdd_val
367 ,p_used_val_o =>ben_bpl_shd.g_old_rec.used_val
368 ,p_bnft_prvdr_pool_id_o =>ben_bpl_shd.g_old_rec.bnft_prvdr_pool_id
369 ,p_acty_base_rt_id_o =>ben_bpl_shd.g_old_rec.acty_base_rt_id
370 ,p_per_in_ler_id_o =>ben_bpl_shd.g_old_rec.per_in_ler_id
371 ,p_prtt_enrt_rslt_id_o =>ben_bpl_shd.g_old_rec.prtt_enrt_rslt_id
372 ,p_business_group_id_o =>ben_bpl_shd.g_old_rec.business_group_id
373 ,p_bpl_attribute_category_o =>ben_bpl_shd.g_old_rec.bpl_attribute_category
374 ,p_bpl_attribute1_o =>ben_bpl_shd.g_old_rec.bpl_attribute1
375 ,p_bpl_attribute2_o =>ben_bpl_shd.g_old_rec.bpl_attribute2
376 ,p_bpl_attribute3_o =>ben_bpl_shd.g_old_rec.bpl_attribute3
377 ,p_bpl_attribute4_o =>ben_bpl_shd.g_old_rec.bpl_attribute4
378 ,p_bpl_attribute5_o =>ben_bpl_shd.g_old_rec.bpl_attribute5
379 ,p_bpl_attribute6_o =>ben_bpl_shd.g_old_rec.bpl_attribute6
380 ,p_bpl_attribute7_o =>ben_bpl_shd.g_old_rec.bpl_attribute7
381 ,p_bpl_attribute8_o =>ben_bpl_shd.g_old_rec.bpl_attribute8
382 ,p_bpl_attribute9_o =>ben_bpl_shd.g_old_rec.bpl_attribute9
383 ,p_bpl_attribute10_o =>ben_bpl_shd.g_old_rec.bpl_attribute10
384 ,p_bpl_attribute11_o =>ben_bpl_shd.g_old_rec.bpl_attribute11
385 ,p_bpl_attribute12_o =>ben_bpl_shd.g_old_rec.bpl_attribute12
386 ,p_bpl_attribute13_o =>ben_bpl_shd.g_old_rec.bpl_attribute13
387 ,p_bpl_attribute14_o =>ben_bpl_shd.g_old_rec.bpl_attribute14
388 ,p_bpl_attribute15_o =>ben_bpl_shd.g_old_rec.bpl_attribute15
389 ,p_bpl_attribute16_o =>ben_bpl_shd.g_old_rec.bpl_attribute16
390 ,p_bpl_attribute17_o =>ben_bpl_shd.g_old_rec.bpl_attribute17
391 ,p_bpl_attribute18_o =>ben_bpl_shd.g_old_rec.bpl_attribute18
392 ,p_bpl_attribute19_o =>ben_bpl_shd.g_old_rec.bpl_attribute19
393 ,p_bpl_attribute20_o =>ben_bpl_shd.g_old_rec.bpl_attribute20
394 ,p_bpl_attribute21_o =>ben_bpl_shd.g_old_rec.bpl_attribute21
395 ,p_bpl_attribute22_o =>ben_bpl_shd.g_old_rec.bpl_attribute22
396 ,p_bpl_attribute23_o =>ben_bpl_shd.g_old_rec.bpl_attribute23
397 ,p_bpl_attribute24_o =>ben_bpl_shd.g_old_rec.bpl_attribute24
398 ,p_bpl_attribute25_o =>ben_bpl_shd.g_old_rec.bpl_attribute25
399 ,p_bpl_attribute26_o =>ben_bpl_shd.g_old_rec.bpl_attribute26
400 ,p_bpl_attribute27_o =>ben_bpl_shd.g_old_rec.bpl_attribute27
401 ,p_bpl_attribute28_o =>ben_bpl_shd.g_old_rec.bpl_attribute28
402 ,p_bpl_attribute29_o =>ben_bpl_shd.g_old_rec.bpl_attribute29
403 ,p_bpl_attribute30_o =>ben_bpl_shd.g_old_rec.bpl_attribute30
404 ,p_object_version_number_o =>ben_bpl_shd.g_old_rec.object_version_number
405 ,p_cash_recd_val_o =>ben_bpl_shd.g_old_rec.cash_recd_val
406 ,p_rld_up_val_o =>ben_bpl_shd.g_old_rec.rld_up_val,
407 p_acty_ref_perd_cd_o => ben_bpl_shd.g_old_rec.acty_ref_perd_cd,
408 p_cmcd_frftd_val_o => ben_bpl_shd.g_old_rec.cmcd_frftd_val,
409 p_cmcd_prvdd_val_o => ben_bpl_shd.g_old_rec.cmcd_prvdd_val,
410 p_cmcd_rld_up_val_o => ben_bpl_shd.g_old_rec.cmcd_rld_up_val,
411 p_cmcd_used_val_o => ben_bpl_shd.g_old_rec.cmcd_used_val,
412 p_cmcd_cash_recd_val_o => ben_bpl_shd.g_old_rec.cmcd_cash_recd_val,
413 p_cmcd_ref_perd_cd_o => ben_bpl_shd.g_old_rec.cmcd_ref_perd_cd,
414 p_ann_frftd_val_o => ben_bpl_shd.g_old_rec.ann_frftd_val,
415 p_ann_prvdd_val_o => ben_bpl_shd.g_old_rec.ann_prvdd_val,
416 p_ann_rld_up_val_o => ben_bpl_shd.g_old_rec.ann_rld_up_val,
417 p_ann_used_val_o => ben_bpl_shd.g_old_rec.ann_used_val,
418 p_ann_cash_recd_val_o => ben_bpl_shd.g_old_rec.ann_cash_recd_val
419 );
420 --
421 exception
422 --
423 when hr_api.cannot_find_prog_unit then
424 --
425 hr_api.cannot_find_prog_unit_error
426 (p_module_name => 'ben_bnft_prvdd_ldgr_f'
427 ,p_hook_type => 'AD');
428 --
429 end;
430 --
431 -- End of API User Hook for post_delete.
432 --
433 --
434 hr_utility.set_location(' Leaving:'||l_proc, 10);
435 End post_delete;
436 --
437 -- ----------------------------------------------------------------------------
438 -- |---------------------------------< del >----------------------------------|
439 -- ----------------------------------------------------------------------------
440 Procedure del
441 (
442 p_rec in out nocopy ben_bpl_shd.g_rec_type,
443 p_effective_date in date,
444 p_datetrack_mode in varchar2
445 ) is
446 --
447 l_proc varchar2(72) := g_package||'del';
448 l_validation_start_date date;
449 l_validation_end_date date;
450 --
451 Begin
452 hr_utility.set_location('Entering:'||l_proc, 5);
453 --
454 -- Ensure that the DateTrack delete mode is valid
455 --
456 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
457 --
458 -- We must lock the row which we need to delete.
459 --
460 ben_bpl_shd.lck
461 (p_effective_date => p_effective_date,
462 p_datetrack_mode => p_datetrack_mode,
463 p_bnft_prvdd_ldgr_id => p_rec.bnft_prvdd_ldgr_id,
464 p_object_version_number => p_rec.object_version_number,
465 p_validation_start_date => l_validation_start_date,
466 p_validation_end_date => l_validation_end_date);
467 --
468 -- Call the supporting delete validate operation
469 --
470 ben_bpl_bus.delete_validate
471 (p_rec => p_rec,
472 p_effective_date => p_effective_date,
473 p_datetrack_mode => p_datetrack_mode,
474 p_validation_start_date => l_validation_start_date,
475 p_validation_end_date => l_validation_end_date);
476 --
477 -- Call the supporting pre-delete operation
478 --
479 pre_delete
480 (p_rec => p_rec,
481 p_effective_date => p_effective_date,
482 p_datetrack_mode => p_datetrack_mode,
483 p_validation_start_date => l_validation_start_date,
484 p_validation_end_date => l_validation_end_date);
485 --
486 -- Delete the row.
487 --
488 delete_dml
489 (p_rec => p_rec,
490 p_effective_date => p_effective_date,
491 p_datetrack_mode => p_datetrack_mode,
492 p_validation_start_date => l_validation_start_date,
493 p_validation_end_date => l_validation_end_date);
494 --
495 -- Call the supporting post-delete operation
496 --
497 post_delete
498 (p_rec => p_rec,
499 p_effective_date => p_effective_date,
500 p_datetrack_mode => p_datetrack_mode,
501 p_validation_start_date => l_validation_start_date,
502 p_validation_end_date => l_validation_end_date);
503 End del;
504 --
505 -- ----------------------------------------------------------------------------
506 -- |---------------------------------< del >----------------------------------|
507 -- ----------------------------------------------------------------------------
508 Procedure del
509 (
510 p_bnft_prvdd_ldgr_id in number,
511 p_effective_start_date out nocopy date,
512 p_effective_end_date out nocopy date,
513 p_object_version_number in out nocopy number,
514 p_effective_date in date,
515 p_datetrack_mode in varchar2
516 ) is
517 --
518 l_rec ben_bpl_shd.g_rec_type;
519 l_proc varchar2(72) := g_package||'del';
520 --
524 -- As the delete procedure accepts a plsql record structure we do need to
521 Begin
522 hr_utility.set_location('Entering:'||l_proc, 5);
523 --
525 -- convert the arguments into the record structure.
526 -- We don't need to call the supplied conversion argument routine as we
527 -- only need a few attributes.
528 --
529 l_rec.bnft_prvdd_ldgr_id := p_bnft_prvdd_ldgr_id;
530 l_rec.object_version_number := p_object_version_number;
531 --
532 -- Having converted the arguments into the ben_bpl_rec
533 -- plsql record structure we must call the corresponding entity
534 -- business process
535 --
536 del(l_rec, p_effective_date, p_datetrack_mode);
537 --
538 -- Set the out arguments
539 --
540 p_object_version_number := l_rec.object_version_number;
541 p_effective_start_date := l_rec.effective_start_date;
542 p_effective_end_date := l_rec.effective_end_date;
543 --
544 hr_utility.set_location(' Leaving:'||l_proc, 10);
545 End del;
546 --
547 end ben_bpl_del;