1 Package Body pay_rtu_del as
2 /* $Header: pyrturhi.pkb 115.3 2002/12/09 15:08:35 divicker noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_rtu_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_rtu_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_run_type_usages_f
72 where run_type_usage_id = p_rec.run_type_usage_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_run_type_usages_f
83 where run_type_usage_id = p_rec.run_type_usage_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_rtu_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_rtu_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_rtu_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_rtu_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_rtu_shd.upd_effective_end_date
217 (p_effective_date => p_effective_date
218 ,p_base_key_value => p_rec.run_type_usage_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_rtu_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_rtu_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 the
299 -- 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_rtu_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 -- RET added call to delete ownerships
339 --
340 -- Delete ownerships if applicable
341 --
342 delete_app_ownerships
343 ('RUN_TYPE_USAGE_ID'
344 ,p_rec.run_type_usage_id
345 ,p_datetrack_mode);
346 --
347 pay_rtu_rkd.after_delete
348 (p_effective_date
349 => p_effective_date
350 ,p_datetrack_mode
351 => p_datetrack_mode
352 ,p_validation_start_date
353 => p_validation_start_date
354 ,p_validation_end_date
355 => p_validation_end_date
356 ,p_effective_start_date
357 => p_rec.effective_start_date
358 ,p_effective_end_date
359 => p_rec.effective_end_date
360 ,p_run_type_usage_id
361 => p_rec.run_type_usage_id
362 ,p_parent_run_type_id_o
363 => pay_rtu_shd.g_old_rec.parent_run_type_id
364 ,p_child_run_type_id_o
365 => pay_rtu_shd.g_old_rec.child_run_type_id
366 ,p_effective_start_date_o
367 => pay_rtu_shd.g_old_rec.effective_start_date
368 ,p_effective_end_date_o
369 => pay_rtu_shd.g_old_rec.effective_end_date
370 ,p_sequence_o
371 => pay_rtu_shd.g_old_rec.sequence
372 ,p_object_version_number_o
373 => pay_rtu_shd.g_old_rec.object_version_number
374 ,p_business_group_id_o
375 => pay_rtu_shd.g_old_rec.business_group_id
376 ,p_legislation_code_o
377 => pay_rtu_shd.g_old_rec.legislation_code
378 );
379 --
380 exception
381 --
382 when hr_api.cannot_find_prog_unit then
383 --
384 hr_api.cannot_find_prog_unit_error
385 (p_module_name => 'PAY_RUN_TYPE_USAGES_F'
386 ,p_hook_type => 'AD');
387 --
388 end;
389 --
390 hr_utility.set_location(' Leaving:'||l_proc, 10);
391 End post_delete;
392 --
393 -- ----------------------------------------------------------------------------
394 -- |---------------------------------< del >----------------------------------|
395 -- ----------------------------------------------------------------------------
396 Procedure del
397 (p_effective_date in date
398 ,p_datetrack_mode in varchar2
399 ,p_rec in out nocopy pay_rtu_shd.g_rec_type
400 ) is
401 --
402 l_proc varchar2(72) := g_package||'del';
403 l_validation_start_date date;
404 l_validation_end_date date;
405 --
406 Begin
407 hr_utility.set_location('Entering:'||l_proc, 5);
408 --
409 -- Ensure that the DateTrack delete mode is valid
410 --
411 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
412 --
413 -- We must lock the row which we need to delete.
414 --
415 pay_rtu_shd.lck
419 ,p_object_version_number => p_rec.object_version_number
416 (p_effective_date => p_effective_date
417 ,p_datetrack_mode => p_datetrack_mode
418 ,p_run_type_usage_id => p_rec.run_type_usage_id
420 ,p_validation_start_date => l_validation_start_date
421 ,p_validation_end_date => l_validation_end_date
422 );
423 --
424 -- Call the supporting delete validate operation
425 --
426 pay_rtu_bus.delete_validate
427 (p_rec => p_rec
428 ,p_effective_date => p_effective_date
429 ,p_datetrack_mode => p_datetrack_mode
430 ,p_validation_start_date => l_validation_start_date
431 ,p_validation_end_date => l_validation_end_date
432 );
433 --
434 -- Call the supporting pre-delete operation
435 --
436 pay_rtu_del.pre_delete
437 (p_rec => p_rec
438 ,p_effective_date => p_effective_date
439 ,p_datetrack_mode => p_datetrack_mode
440 ,p_validation_start_date => l_validation_start_date
441 ,p_validation_end_date => l_validation_end_date
442 );
443 --
444 -- Delete the row.
445 --
446 pay_rtu_del.delete_dml
447 (p_rec => p_rec
448 ,p_effective_date => p_effective_date
449 ,p_datetrack_mode => p_datetrack_mode
450 ,p_validation_start_date => l_validation_start_date
451 ,p_validation_end_date => l_validation_end_date
452 );
453 -- Call the supporting post-delete operation
454 --
455 pay_rtu_del.post_delete
456 (p_rec => p_rec
457 ,p_effective_date => p_effective_date
458 ,p_datetrack_mode => p_datetrack_mode
459 ,p_validation_start_date => l_validation_start_date
460 ,p_validation_end_date => l_validation_end_date
461 );
462 --
463 hr_utility.set_location(' Leaving:'||l_proc, 5);
464 End del;
465 --
466 -- ----------------------------------------------------------------------------
467 -- |--------------------------------< del >-----------------------------------|
468 -- ----------------------------------------------------------------------------
469 Procedure del
470 (p_effective_date in date
471 ,p_datetrack_mode in varchar2
475 ,p_effective_end_date out nocopy date
472 ,p_run_type_usage_id in number
473 ,p_object_version_number in out nocopy number
474 ,p_effective_start_date out nocopy date
476 ) is
477 --
478 l_rec pay_rtu_shd.g_rec_type;
479 l_proc varchar2(72) := g_package||'del';
480 --
481 Begin
482 hr_utility.set_location('Entering:'||l_proc, 5);
483 --
484 -- As the delete procedure accepts a plsql record structure we do need to
485 -- convert the arguments into the record structure.
486 -- We don't need to call the supplied conversion argument routine as we
487 -- only need a few attributes.
488 --
489 l_rec.run_type_usage_id := p_run_type_usage_id;
490 l_rec.object_version_number := p_object_version_number;
491 --
492 -- Having converted the arguments into the pay_rtu_rec
493 -- plsql record structure we must call the corresponding entity
494 -- business process
495 --
496 pay_rtu_del.del
497 (p_effective_date
498 ,p_datetrack_mode
499 ,l_rec
500 );
501 --
502 -- Set the out arguments
503 --
504 p_object_version_number := l_rec.object_version_number;
505 p_effective_start_date := l_rec.effective_start_date;
506 p_effective_end_date := l_rec.effective_end_date;
507 --
508 hr_utility.set_location(' Leaving:'||l_proc, 10);
509 End del;
510 --
511 end pay_rtu_del;