1 Package Body ben_reg_del as
2 /* $Header: beregrhi.pkb 120.0.12010000.4 2008/08/05 15:26:02 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_reg_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_reg_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_reg_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_regn_f
72 where regn_id = p_rec.regn_id
73 and effective_start_date = p_validation_start_date;
74 --
75 -- Delete from MLS table.
76 --
77 delete from ben_regn_f_tl
78 where regn_id = p_rec.regn_id
79 and effective_start_date = p_validation_start_date;
80 --
81 ben_reg_shd.g_api_dml := false; -- Unset the api dml status
82 Else
83 hr_utility.set_location(l_proc, 15);
84 ben_reg_shd.g_api_dml := true; -- Set the api dml status
85 --
86 -- Delete the row(s) where the effective start date is greater than
87 -- or equal to the validation start date.
88 --
89 delete from ben_regn_f
90 where regn_id = p_rec.regn_id
91 and effective_start_date >= p_validation_start_date;
92 --
93 -- Delete from MLS table.
94 --
95 delete from ben_regn_f_tl
96 where regn_id = p_rec.regn_id
97 and effective_start_date >= p_validation_start_date;
98 --
99 ben_reg_shd.g_api_dml := false; -- Unset the api dml status
100 End If;
101 --
102 hr_utility.set_location(' Leaving:'||l_proc, 20);
103 --
104 Exception
105 When Others Then
106 ben_reg_shd.g_api_dml := false; -- Unset the api dml status
107 Raise;
108 End dt_delete_dml;
109 --
110 -- ----------------------------------------------------------------------------
111 -- |------------------------------< delete_dml >------------------------------|
112 -- ----------------------------------------------------------------------------
113 Procedure delete_dml
114 (p_rec in out nocopy ben_reg_shd.g_rec_type,
115 p_effective_date in date,
116 p_datetrack_mode in varchar2,
117 p_validation_start_date in date,
118 p_validation_end_date in date) is
119 --
120 l_proc varchar2(72) := g_package||'delete_dml';
121 --
122 Begin
123 hr_utility.set_location('Entering:'||l_proc, 5);
124 --
125 dt_delete_dml(p_rec => p_rec,
126 p_effective_date => p_effective_date,
127 p_datetrack_mode => p_datetrack_mode,
128 p_validation_start_date => p_validation_start_date,
129 p_validation_end_date => p_validation_end_date);
130 --
131 hr_utility.set_location(' Leaving:'||l_proc, 10);
132 End delete_dml;
133 --
134 -- ----------------------------------------------------------------------------
135 -- |----------------------------< dt_pre_delete >-----------------------------|
136 -- ----------------------------------------------------------------------------
137 -- {Start Of Comments}
138 --
139 -- Description:
140 -- The dt_pre_delete process controls the execution of dml
141 -- for the datetrack modes: DELETE, FUTURE_CHANGE
142 -- and DELETE_NEXT_CHANGE only.
143 --
144 -- Prerequisites:
145 -- This is an internal procedure which is called from the pre_delete
146 -- procedure.
147 --
148 -- In Parameters:
149 -- A Pl/Sql record structre.
150 --
151 -- Post Success:
152 -- Processing continues.
153 --
154 -- Post Failure:
155 -- If an error has occurred, an error message and exception will be raised
156 -- but not handled.
157 --
158 -- Developer Implementation Notes:
159 -- This is an internal procedure which is required by Datetrack. Don't
160 -- remove or modify.
161 --
162 -- Access Status:
163 -- Internal Row Handler Use Only.
164 --
165 -- {End Of Comments}
166 -- ----------------------------------------------------------------------------
167 Procedure dt_pre_delete
168 (p_rec in out nocopy ben_reg_shd.g_rec_type,
169 p_effective_date in date,
170 p_datetrack_mode in varchar2,
171 p_validation_start_date in date,
172 p_validation_end_date in date) is
173 --
174 l_proc varchar2(72) := g_package||'dt_pre_delete';
175 --
176 Begin
177 hr_utility.set_location('Entering:'||l_proc, 5);
178 --
179 If (p_datetrack_mode <> 'ZAP') then
180 --
181 p_rec.effective_start_date := ben_reg_shd.g_old_rec.effective_start_date;
182 --
183 If (p_datetrack_mode = 'DELETE') then
184 p_rec.effective_end_date := p_validation_start_date - 1;
185 Else
186 p_rec.effective_end_date := p_validation_end_date;
187 End If;
188 --
189 -- Update the current effective end date record
190 --
191 ben_reg_shd.upd_effective_end_date
192 (p_effective_date => p_effective_date,
193 p_base_key_value => p_rec.regn_id,
194 p_new_effective_end_date => p_rec.effective_end_date,
195 p_validation_start_date => p_validation_start_date,
196 p_validation_end_date => p_validation_end_date,
197 p_object_version_number => p_rec.object_version_number);
198 Else
199 p_rec.effective_start_date := null;
200 p_rec.effective_end_date := null;
201 End If;
202 hr_utility.set_location(' Leaving:'||l_proc, 10);
203 End dt_pre_delete;
204 --
205 -- ----------------------------------------------------------------------------
206 -- |------------------------------< pre_delete >------------------------------|
207 -- ----------------------------------------------------------------------------
208 -- {Start Of Comments}
209 --
210 -- Description:
211 -- This private procedure contains any processing which is required before
212 -- the delete dml.
213 --
214 -- Prerequisites:
215 -- This is an internal procedure which is called from the del procedure.
216 --
217 -- In Parameters:
218 -- A Pl/Sql record structre.
219 --
220 -- Post Success:
221 -- Processing continues.
222 --
223 -- Post Failure:
224 -- If an error has occurred, an error message and exception will be raised
225 -- but not handled.
226 --
227 -- Developer Implementation Notes:
228 -- Any pre-processing required before the delete dml is issued should be
229 -- coded within this procedure. It is important to note that any 3rd party
230 -- maintenance should be reviewed before placing in this procedure. The call
231 -- to the dt_delete_dml procedure should NOT be removed.
232 --
233 -- Access Status:
234 -- Internal Row Handler Use Only.
235 --
236 -- {End Of Comments}
237 -- ----------------------------------------------------------------------------
238 Procedure pre_delete
239 (p_rec in out nocopy ben_reg_shd.g_rec_type,
240 p_effective_date in date,
241 p_datetrack_mode in varchar2,
242 p_validation_start_date in date,
243 p_validation_end_date in date) is
244 --
245 l_proc varchar2(72) := g_package||'pre_delete';
246 --
247 --
248 --
249 Begin
250 hr_utility.set_location('Entering:'||l_proc, 5);
251 --
252 --
253 --
254 dt_pre_delete
255 (p_rec => p_rec,
256 p_effective_date => p_effective_date,
257 p_datetrack_mode => p_datetrack_mode,
258 p_validation_start_date => p_validation_start_date,
259 p_validation_end_date => p_validation_end_date);
260 --
261 hr_utility.set_location(' Leaving:'||l_proc, 10);
262 End pre_delete;
263 --
264 -- ----------------------------------------------------------------------------
265 -- |-----------------------------< post_delete >------------------------------|
266 -- ----------------------------------------------------------------------------
267 -- {Start Of Comments}
268 --
269 -- Description:
270 -- This private procedure contains any processing which is required after the
271 -- delete dml.
272 --
273 -- Prerequisites:
274 -- This is an internal procedure which is called from the del procedure.
275 --
276 -- In Parameters:
277 -- A Pl/Sql record structre.
278 --
279 -- Post Success:
280 -- Processing continues.
281 --
282 -- Post Failure:
283 -- If an error has occurred, an error message and exception will be raised
284 -- but not handled.
285 --
286 -- Developer Implementation Notes:
287 -- Any post-processing required after the delete dml is issued should be
288 -- coded within this procedure. It is important to note that any 3rd party
289 -- maintenance should be reviewed before placing in this procedure.
290 --
291 -- Access Status:
292 -- Internal Row Handler Use Only.
293 --
294 -- {End Of Comments}
295 -- ----------------------------------------------------------------------------
296 Procedure post_delete
297 (p_rec in ben_reg_shd.g_rec_type,
298 p_effective_date in date,
299 p_datetrack_mode in varchar2,
300 p_validation_start_date in date,
301 p_validation_end_date in date) is
302 --
303 l_proc varchar2(72) := g_package||'post_delete';
304 --
305 Begin
306 hr_utility.set_location('Entering:'||l_proc, 5);
307 --
308 --
309 -- Start of API User Hook for post_delete.
310 --
311 begin
312 --
313 ben_reg_rkd.after_delete
314 (
315 p_regn_id =>p_rec.regn_id
316 ,p_datetrack_mode =>p_datetrack_mode
317 ,p_validation_start_date =>p_validation_start_date
318 ,p_validation_end_date =>p_validation_end_date
319 ,p_effective_start_date =>p_rec.effective_start_date
320 ,p_effective_end_date =>p_rec.effective_end_date
321 ,p_effective_start_date_o =>ben_reg_shd.g_old_rec.effective_start_date
322 ,p_effective_end_date_o =>ben_reg_shd.g_old_rec.effective_end_date
323 ,p_name_o =>ben_reg_shd.g_old_rec.name
324 ,p_organization_id_o =>ben_reg_shd.g_old_rec.organization_id
325 ,p_business_group_id_o =>ben_reg_shd.g_old_rec.business_group_id
326 ,p_sttry_citn_name_o =>ben_reg_shd.g_old_rec.sttry_citn_name
327 ,p_reg_attribute_category_o =>ben_reg_shd.g_old_rec.reg_attribute_category
328 ,p_reg_attribute1_o =>ben_reg_shd.g_old_rec.reg_attribute1
329 ,p_reg_attribute2_o =>ben_reg_shd.g_old_rec.reg_attribute2
330 ,p_reg_attribute3_o =>ben_reg_shd.g_old_rec.reg_attribute3
331 ,p_reg_attribute4_o =>ben_reg_shd.g_old_rec.reg_attribute4
332 ,p_reg_attribute5_o =>ben_reg_shd.g_old_rec.reg_attribute5
333 ,p_reg_attribute6_o =>ben_reg_shd.g_old_rec.reg_attribute6
334 ,p_reg_attribute7_o =>ben_reg_shd.g_old_rec.reg_attribute7
335 ,p_reg_attribute8_o =>ben_reg_shd.g_old_rec.reg_attribute8
336 ,p_reg_attribute9_o =>ben_reg_shd.g_old_rec.reg_attribute9
337 ,p_reg_attribute10_o =>ben_reg_shd.g_old_rec.reg_attribute10
338 ,p_reg_attribute11_o =>ben_reg_shd.g_old_rec.reg_attribute11
339 ,p_reg_attribute12_o =>ben_reg_shd.g_old_rec.reg_attribute12
340 ,p_reg_attribute13_o =>ben_reg_shd.g_old_rec.reg_attribute13
341 ,p_reg_attribute14_o =>ben_reg_shd.g_old_rec.reg_attribute14
342 ,p_reg_attribute15_o =>ben_reg_shd.g_old_rec.reg_attribute15
343 ,p_reg_attribute16_o =>ben_reg_shd.g_old_rec.reg_attribute16
344 ,p_reg_attribute17_o =>ben_reg_shd.g_old_rec.reg_attribute17
345 ,p_reg_attribute18_o =>ben_reg_shd.g_old_rec.reg_attribute18
346 ,p_reg_attribute19_o =>ben_reg_shd.g_old_rec.reg_attribute19
347 ,p_reg_attribute20_o =>ben_reg_shd.g_old_rec.reg_attribute20
348 ,p_reg_attribute21_o =>ben_reg_shd.g_old_rec.reg_attribute21
349 ,p_reg_attribute22_o =>ben_reg_shd.g_old_rec.reg_attribute22
350 ,p_reg_attribute23_o =>ben_reg_shd.g_old_rec.reg_attribute23
351 ,p_reg_attribute24_o =>ben_reg_shd.g_old_rec.reg_attribute24
352 ,p_reg_attribute25_o =>ben_reg_shd.g_old_rec.reg_attribute25
353 ,p_reg_attribute26_o =>ben_reg_shd.g_old_rec.reg_attribute26
354 ,p_reg_attribute27_o =>ben_reg_shd.g_old_rec.reg_attribute27
355 ,p_reg_attribute28_o =>ben_reg_shd.g_old_rec.reg_attribute28
356 ,p_reg_attribute29_o =>ben_reg_shd.g_old_rec.reg_attribute29
357 ,p_reg_attribute30_o =>ben_reg_shd.g_old_rec.reg_attribute30
358 ,p_object_version_number_o =>ben_reg_shd.g_old_rec.object_version_number
359 );
360 --
361 exception
362 --
363 when hr_api.cannot_find_prog_unit then
364 --
365 hr_api.cannot_find_prog_unit_error
366 (p_module_name => 'ben_regn_f'
367 ,p_hook_type => 'AD');
368 --
369 end;
370 --
371 -- End of API User Hook for post_delete.
372 --
373 --
374 hr_utility.set_location(' Leaving:'||l_proc, 10);
375 End post_delete;
376 --
377 -- ----------------------------------------------------------------------------
378 -- |---------------------------------< del >----------------------------------|
379 -- ----------------------------------------------------------------------------
380 Procedure del
381 (
382 p_rec in out nocopy ben_reg_shd.g_rec_type,
383 p_effective_date in date,
384 p_datetrack_mode in varchar2
385 ) is
386 --
387 l_proc varchar2(72) := g_package||'del';
388 l_validation_start_date date;
389 l_validation_end_date date;
390 --
391 Begin
392 hr_utility.set_location('Entering:'||l_proc, 5);
393 --
394 -- Ensure that the DateTrack delete mode is valid
395 --
396 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
397 --
398 -- We must lock the row which we need to delete.
399 --
400 ben_reg_shd.lck
401 (p_effective_date => p_effective_date,
402 p_datetrack_mode => p_datetrack_mode,
403 p_regn_id => p_rec.regn_id,
404 p_object_version_number => p_rec.object_version_number,
405 p_validation_start_date => l_validation_start_date,
406 p_validation_end_date => l_validation_end_date);
407 --
408 -- Call the supporting delete validate operation
409 --
410 ben_reg_bus.delete_validate
411 (p_rec => p_rec,
412 p_effective_date => p_effective_date,
413 p_datetrack_mode => p_datetrack_mode,
414 p_validation_start_date => l_validation_start_date,
415 p_validation_end_date => l_validation_end_date);
416 --
417 -- Call the supporting pre-delete operation
418 --
419 pre_delete
420 (p_rec => p_rec,
421 p_effective_date => p_effective_date,
422 p_datetrack_mode => p_datetrack_mode,
423 p_validation_start_date => l_validation_start_date,
424 p_validation_end_date => l_validation_end_date);
425 --
426 -- Delete the row.
427 --
428 delete_dml
429 (p_rec => p_rec,
430 p_effective_date => p_effective_date,
431 p_datetrack_mode => p_datetrack_mode,
432 p_validation_start_date => l_validation_start_date,
433 p_validation_end_date => l_validation_end_date);
434 --
435 -- Call the supporting post-delete operation
436 --
437 post_delete
438 (p_rec => p_rec,
439 p_effective_date => p_effective_date,
440 p_datetrack_mode => p_datetrack_mode,
441 p_validation_start_date => l_validation_start_date,
442 p_validation_end_date => l_validation_end_date);
443 End del;
444 --
445 -- ----------------------------------------------------------------------------
446 -- |---------------------------------< del >----------------------------------|
447 -- ----------------------------------------------------------------------------
448 Procedure del
449 (
450 p_regn_id in number,
451 p_effective_start_date out nocopy date,
452 p_effective_end_date out nocopy date,
453 p_object_version_number in out nocopy number,
454 p_effective_date in date,
455 p_datetrack_mode in varchar2
456 ) is
457 --
458 l_rec ben_reg_shd.g_rec_type;
459 l_proc varchar2(72) := g_package||'del';
460 --
461 Begin
462 hr_utility.set_location('Entering:'||l_proc, 5);
463 --
464 -- As the delete procedure accepts a plsql record structure we do need to
465 -- convert the arguments into the record structure.
466 -- We don't need to call the supplied conversion argument routine as we
467 -- only need a few attributes.
468 --
469 l_rec.regn_id := p_regn_id;
470 l_rec.object_version_number := p_object_version_number;
471 --
472 -- Having converted the arguments into the ben_reg_rec
473 -- plsql record structure we must call the corresponding entity
474 -- business process
475 --
476 del(l_rec, p_effective_date, p_datetrack_mode);
477 --
478 -- Set the out arguments
479 --
480 p_object_version_number := l_rec.object_version_number;
481 p_effective_start_date := l_rec.effective_start_date;
482 p_effective_end_date := l_rec.effective_end_date;
483 --
484 hr_utility.set_location(' Leaving:'||l_proc, 10);
485 End del;
486 --
487 end ben_reg_del;