1 Package Body pay_evc_del as
2 /* $Header: pyevcrhi.pkb 115.6 2003/05/27 17:21:31 jford noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_evc_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 structure.
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 pay_evc_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
59 ) is
60 --
61 l_proc varchar2(72) := g_package||'dt_delete_dml';
62 --
63 Begin
64 hr_utility.set_location('Entering:'||l_proc, 5);
65 If (p_datetrack_mode = hr_api.g_delete_next_change) then
66 --
67 --
68 -- Delete the where the effective start date is equal
69 -- to the validation end date.
70 --
71 delete from pay_event_value_changes_f
72 where event_value_change_id = p_rec.event_value_change_id
73 and effective_start_date = p_validation_start_date;
74 --
75 --
76 Else
77 --
78 --
79 -- Delete the row(s) where the effective start date is greater than
80 -- or equal to the validation start date.
81 --
82 delete from pay_event_value_changes_f
83 where event_value_change_id = p_rec.event_value_change_id
84 and effective_start_date >= p_validation_start_date;
85 --
86 --
87 End If;
88 --
89 hr_utility.set_location(' Leaving:'||l_proc, 20);
90 --
91 End dt_delete_dml;
92 --
93 -- ----------------------------------------------------------------------------
94 -- ----------------------< delete_app_ownerships >----------------------------|
95 -- ----------------------------------------------------------------------------
96 --
97 -- Description:
98 -- Deletes row(s) from hr_application_ownerships depending on the mode that
99 -- the row handler has been called in.
100 --
101 -- ----------------------------------------------------------------------------
102 PROCEDURE delete_app_ownerships(p_pk_column IN varchar2
103 ,p_pk_value IN varchar2
104 ,p_datetrack_mode IN varchar2) IS
105 --
106 BEGIN
107 --
108 IF ((hr_startup_data_api_support.return_startup_mode
109 IN ('STARTUP','GENERIC')) AND
110 p_datetrack_mode = hr_api.g_zap) THEN
111 --
112 DELETE FROM hr_application_ownerships
113 WHERE key_name = p_pk_column
114 AND key_value = p_pk_value;
115 --
116 END IF;
117 END delete_app_ownerships;
118 --
119 -- ----------------------------------------------------------------------------
120 -- ----------------------< delete_app_ownerships >----------------------------|
121 -- ----------------------------------------------------------------------------
122 PROCEDURE delete_app_ownerships(p_pk_column IN varchar2
123 ,p_pk_value IN number
124 ,p_datetrack_mode IN varchar2) IS
125 --
126 BEGIN
127 delete_app_ownerships(p_pk_column, to_char(p_pk_value), p_datetrack_mode);
128 END delete_app_ownerships;
129 --
130 -- ----------------------------------------------------------------------------
131 -- |------------------------------< delete_dml >------------------------------|
132 -- ----------------------------------------------------------------------------
133 Procedure delete_dml
134 (p_rec in out nocopy pay_evc_shd.g_rec_type
135 ,p_effective_date in date
136 ,p_datetrack_mode in varchar2
137 ,p_validation_start_date in date
138 ,p_validation_end_date in date
139 ) is
140 --
141 l_proc varchar2(72) := g_package||'delete_dml';
142 --
143 Begin
144 hr_utility.set_location('Entering:'||l_proc, 5);
145 --
146 pay_evc_del.dt_delete_dml
147 (p_rec => p_rec
148 ,p_effective_date => p_effective_date
149 ,p_datetrack_mode => p_datetrack_mode
150 ,p_validation_start_date => p_validation_start_date
151 ,p_validation_end_date => p_validation_end_date
152 );
153 --
154 hr_utility.set_location(' Leaving:'||l_proc, 10);
155 End delete_dml;
156 --
157 -- ----------------------------------------------------------------------------
158 -- |----------------------------< dt_pre_delete >-----------------------------|
159 -- ----------------------------------------------------------------------------
160 -- {Start Of Comments}
161 --
162 -- Description:
163 -- The dt_pre_delete process controls the execution of dml
164 -- for the datetrack modes: DELETE, FUTURE_CHANGE
165 -- and DELETE_NEXT_CHANGE only.
166 --
167 -- Prerequisites:
168 -- This is an internal procedure which is called from the pre_delete
169 -- procedure.
170 --
171 -- In Parameters:
172 -- A Pl/Sql record structure.
173 --
174 -- Post Success:
175 -- Processing continues.
176 --
177 -- Post Failure:
178 -- If an error has occurred, an error message and exception will be raised
179 -- but not handled.
180 --
181 -- Developer Implementation Notes:
182 -- This is an internal procedure which is required by Datetrack. Don't
183 -- remove or modify.
184 --
185 -- Access Status:
186 -- Internal Row Handler Use Only.
187 --
188 -- {End Of Comments}
189 -- ----------------------------------------------------------------------------
190 Procedure dt_pre_delete
191 (p_rec in out nocopy pay_evc_shd.g_rec_type
192 ,p_effective_date in date
193 ,p_datetrack_mode in varchar2
194 ,p_validation_start_date in date
195 ,p_validation_end_date in date
196 ) is
197 --
198 l_proc varchar2(72) := g_package||'dt_pre_delete';
199 --
200 Begin
201 hr_utility.set_location('Entering:'||l_proc, 5);
202 --
203 If (p_datetrack_mode <> hr_api.g_zap) then
204 --
205 p_rec.effective_start_date
206 := pay_evc_shd.g_old_rec.effective_start_date;
207 --
208 If (p_datetrack_mode = hr_api.g_delete) then
209 p_rec.effective_end_date := p_validation_start_date - 1;
210 Else
211 p_rec.effective_end_date := p_validation_end_date;
212 End If;
213 --
214 -- Update the current effective end date record
215 --
216 pay_evc_shd.upd_effective_end_date
217 (p_effective_date => p_effective_date
218 ,p_base_key_value => p_rec.event_value_change_id
219 ,p_new_effective_end_date => p_rec.effective_end_date
220 ,p_validation_start_date => p_validation_start_date
221 ,p_validation_end_date => p_validation_end_date
222 ,p_object_version_number => p_rec.object_version_number
223 );
224 Else
225 p_rec.effective_start_date := null;
226 p_rec.effective_end_date := null;
227 End If;
228 hr_utility.set_location(' Leaving:'||l_proc, 10);
229 End dt_pre_delete;
230 --
231 -- ----------------------------------------------------------------------------
232 -- |------------------------------< pre_delete >------------------------------|
233 -- ----------------------------------------------------------------------------
234 -- {Start Of Comments}
235 --
236 -- Description:
237 -- This private procedure contains any processing which is required before
238 -- the delete dml.
239 --
240 -- Prerequisites:
241 -- This is an internal procedure which is called from the del procedure.
242 --
243 -- In Parameters:
244 -- A Pl/Sql record structure.
245 --
246 -- Post Success:
247 -- Processing continues.
248 --
249 -- Post Failure:
250 -- If an error has occurred, an error message and exception will be raised
251 -- but not handled.
252 --
253 -- Developer Implementation Notes:
254 -- Any pre-processing required before the delete dml is issued should be
255 -- coded within this procedure. It is important to note that any 3rd party
256 -- maintenance should be reviewed before placing in this procedure. The call
257 -- to the dt_delete_dml procedure should NOT be removed.
258 --
259 -- Access Status:
260 -- Internal Row Handler Use Only.
261 --
262 -- {End Of Comments}
263 -- ----------------------------------------------------------------------------
264 Procedure pre_delete
265 (p_rec in out nocopy pay_evc_shd.g_rec_type
266 ,p_effective_date in date
267 ,p_datetrack_mode in varchar2
268 ,p_validation_start_date in date
269 ,p_validation_end_date in date
270 ) is
271 --
272 l_proc varchar2(72) := g_package||'pre_delete';
273 --
274 --
275 --
276 Begin
277 hr_utility.set_location('Entering:'||l_proc, 5);
278 --
279 --
280 --
281 pay_evc_del.dt_pre_delete
282 (p_rec => p_rec
283 ,p_effective_date => p_effective_date
284 ,p_datetrack_mode => p_datetrack_mode
285 ,p_validation_start_date => p_validation_start_date
286 ,p_validation_end_date => p_validation_end_date
287 );
288 --
289 hr_utility.set_location(' Leaving:'||l_proc, 10);
290 End pre_delete;
291 --
292 -- ----------------------------------------------------------------------------
293 -- |----------------------------< post_delete >-------------------------------|
294 -- ----------------------------------------------------------------------------
295 -- {Start Of Comments}
296 --
297 -- Description:
298 -- This private procedure contains any processing which is required after
299 -- the delete dml.
300 --
301 -- Prerequisites:
302 -- This is an internal procedure which is called from the del procedure.
303 --
304 -- In Parameters:
305 -- A Pl/Sql record structure.
306 --
307 -- Post Success:
308 -- Processing continues.
309 --
310 -- Post Failure:
311 -- If an error has occurred, an error message and exception will be raised
312 -- but not handled.
313 --
314 -- Developer Implementation Notes:
315 -- Any post-processing required after the delete dml is issued should be
316 -- coded within this procedure. It is important to note that any 3rd party
317 -- maintenance should be reviewed before placing in this procedure.
318 --
319 -- Access Status:
320 -- Internal Row Handler Use Only.
321 --
322 -- {End Of Comments}
323 -- ----------------------------------------------------------------------------
324 Procedure post_delete
325 (p_rec in pay_evc_shd.g_rec_type
326 ,p_effective_date in date
327 ,p_datetrack_mode in varchar2
328 ,p_validation_start_date in date
329 ,p_validation_end_date in date
330 ) is
331 --
332 l_proc varchar2(72) := g_package||'post_delete';
333 --
334 Begin
335 hr_utility.set_location('Entering:'||l_proc, 5);
336 begin
337 --
338 -- Delete ownerships if applicable
339 delete_app_ownerships
340 ('EVENT_VALUE_CHANGE_ID'
341 ,p_rec.event_value_change_id
342 ,p_datetrack_mode
343 );
344 --
345 pay_evc_rkd.after_delete
346 (p_effective_date
347 => p_effective_date
348 ,p_datetrack_mode
349 => p_datetrack_mode
350 ,p_validation_start_date
351 => p_validation_start_date
352 ,p_validation_end_date
353 => p_validation_end_date
354 ,p_event_value_change_id
355 => p_rec.event_value_change_id
356 ,p_effective_start_date
357 => p_rec.effective_start_date
358 ,p_effective_end_date
359 => p_rec.effective_end_date
360 ,p_effective_start_date_o
361 => pay_evc_shd.g_old_rec.effective_start_date
362 ,p_effective_end_date_o
363 => pay_evc_shd.g_old_rec.effective_end_date
364 ,p_event_qualifier_id_o
365 => pay_evc_shd.g_old_rec.event_qualifier_id
366 ,p_datetracked_event_id_o
367 => pay_evc_shd.g_old_rec.datetracked_event_id
368 ,p_default_event_o
369 => pay_evc_shd.g_old_rec.default_event
370 ,p_valid_event_o
371 => pay_evc_shd.g_old_rec.valid_event
372 ,p_business_group_id_o
373 => pay_evc_shd.g_old_rec.business_group_id
374 ,p_legislation_code_o
375 => pay_evc_shd.g_old_rec.legislation_code
376 ,p_from_value_o
377 => pay_evc_shd.g_old_rec.from_value
378 ,p_to_value_o
379 => pay_evc_shd.g_old_rec.to_value
380 ,p_proration_style_o
381 => pay_evc_shd.g_old_rec.proration_style
382 ,p_qualifier_value_o
383 => pay_evc_shd.g_old_rec.qualifier_value
384 ,p_object_version_number_o
385 => pay_evc_shd.g_old_rec.object_version_number
386 );
387 --
388 exception
389 --
390 when hr_api.cannot_find_prog_unit then
391 --
392 hr_api.cannot_find_prog_unit_error
393 (p_module_name => 'PAY_EVENT_VALUE_CHANGES_F'
394 ,p_hook_type => 'AD');
395 --
396 end;
397 --
398 hr_utility.set_location(' Leaving:'||l_proc, 10);
399 End post_delete;
400 --
401 -- ----------------------------------------------------------------------------
402 -- |---------------------------------< del >----------------------------------|
403 -- ----------------------------------------------------------------------------
404 Procedure del
405 (p_effective_date in date
406 ,p_datetrack_mode in varchar2
407 ,p_rec in out nocopy pay_evc_shd.g_rec_type
408 ) is
409 --
410 l_proc varchar2(72) := g_package||'del';
411 l_validation_start_date date;
412 l_validation_end_date date;
413 --
414 Begin
415 hr_utility.set_location('Entering:'||l_proc, 5);
416 --
417 -- Ensure that the DateTrack delete mode is valid
418 --
419 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
420 --
421 -- We must lock the row which we need to delete.
422 --
423 pay_evc_shd.lck
424 (p_effective_date => p_effective_date
425 ,p_datetrack_mode => p_datetrack_mode
426 ,p_event_value_change_id => p_rec.event_value_change_id
427 ,p_object_version_number => p_rec.object_version_number
428 ,p_validation_start_date => l_validation_start_date
429 ,p_validation_end_date => l_validation_end_date
430 );
431 --
432 -- Call the supporting delete validate operation
433 --
434 pay_evc_bus.delete_validate
435 (p_rec => p_rec
436 ,p_effective_date => p_effective_date
437 ,p_datetrack_mode => p_datetrack_mode
438 ,p_validation_start_date => l_validation_start_date
439 ,p_validation_end_date => l_validation_end_date
440 );
441 --
442 -- Call to raise any errors on multi-message list
443 hr_multi_message.end_validation_set;
444 --
445 -- Call the supporting pre-delete operation
446 --
447 pay_evc_del.pre_delete
448 (p_rec => p_rec
449 ,p_effective_date => p_effective_date
450 ,p_datetrack_mode => p_datetrack_mode
451 ,p_validation_start_date => l_validation_start_date
452 ,p_validation_end_date => l_validation_end_date
453 );
454 --
455 -- Delete the row.
456 --
457 pay_evc_del.delete_dml
458 (p_rec => p_rec
459 ,p_effective_date => p_effective_date
460 ,p_datetrack_mode => p_datetrack_mode
461 ,p_validation_start_date => l_validation_start_date
462 ,p_validation_end_date => l_validation_end_date
463 );
464 -- Call the supporting post-delete operation
465 --
466 pay_evc_del.post_delete
467 (p_rec => p_rec
468 ,p_effective_date => p_effective_date
469 ,p_datetrack_mode => p_datetrack_mode
470 ,p_validation_start_date => l_validation_start_date
471 ,p_validation_end_date => l_validation_end_date
472 );
473 --
474 -- Call to raise any errors on multi-message list
475 hr_multi_message.end_validation_set;
476 --
477 hr_utility.set_location(' Leaving:'||l_proc, 5);
478 End del;
479 --
480 -- ----------------------------------------------------------------------------
481 -- |--------------------------------< del >-----------------------------------|
482 -- ----------------------------------------------------------------------------
483 Procedure del
484 (p_effective_date in date
485 ,p_datetrack_mode in varchar2
486 ,p_event_value_change_id in number
487 ,p_object_version_number in out nocopy number
488 ,p_effective_start_date out nocopy date
489 ,p_effective_end_date out nocopy date
490 ) is
491 --
492 l_rec pay_evc_shd.g_rec_type;
493 l_proc varchar2(72) := g_package||'del';
494 --
495 Begin
496 hr_utility.set_location('Entering:'||l_proc, 5);
497 --
498 -- As the delete procedure accepts a plsql record structure we do need to
499 -- convert the arguments into the record structure.
500 -- We don't need to call the supplied conversion argument routine as we
501 -- only need a few attributes.
502 --
503 l_rec.event_value_change_id := p_event_value_change_id;
504 l_rec.object_version_number := p_object_version_number;
505 --
506 -- Having converted the arguments into the pay_evc_rec
507 -- plsql record structure we must call the corresponding entity
508 -- business process
509 --
510 pay_evc_del.del
511 (p_effective_date
512 ,p_datetrack_mode
513 ,l_rec
514 );
515 --
516 --
517 -- Set the out arguments
518 --
519 p_object_version_number := l_rec.object_version_number;
520 p_effective_start_date := l_rec.effective_start_date;
521 p_effective_end_date := l_rec.effective_end_date;
522 --
523 hr_utility.set_location(' Leaving:'||l_proc, 10);
524 End del;
525 --
526 end pay_evc_del;