1 Package Body pay_cal_del as
2 /* $Header: pycalrhi.pkb 120.1.12020000.2 2012/07/04 21:43:33 amnaraya ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_cal_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_cal_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 pay_cal_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 pay_cost_allocations_f
72 where cost_allocation_id = p_rec.cost_allocation_id
73 and effective_start_date = p_validation_start_date;
74 --
75 pay_cal_shd.g_api_dml := false; -- Unset the api dml status
76 Else
77 pay_cal_shd.g_api_dml := true; -- Set the api dml status
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_cost_allocations_f
83 where cost_allocation_id = p_rec.cost_allocation_id
84 and effective_start_date >= p_validation_start_date;
85 --
86 pay_cal_shd.g_api_dml := false; -- Unset the api dml status
87 End If;
88 --
89 hr_utility.set_location(' Leaving:'||l_proc, 20);
90 --
91 Exception
92 When Others Then
93 pay_cal_shd.g_api_dml := false; -- Unset the api dml status
94 Raise;
95 --
96 End dt_delete_dml;
97 --
98 -- ----------------------------------------------------------------------------
99 -- |------------------------------< delete_dml >------------------------------|
100 -- ----------------------------------------------------------------------------
101 Procedure delete_dml
102 (p_rec in out nocopy pay_cal_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
107 ) is
108 --
109 l_proc varchar2(72) := g_package||'delete_dml';
110 --
111 Begin
112 hr_utility.set_location('Entering:'||l_proc, 5);
113 --
114 pay_cal_del.dt_delete_dml
115 (p_rec => p_rec
116 ,p_effective_date => p_effective_date
117 ,p_datetrack_mode => p_datetrack_mode
118 ,p_validation_start_date => p_validation_start_date
119 ,p_validation_end_date => p_validation_end_date
120 );
121 --
122 hr_utility.set_location(' Leaving:'||l_proc, 10);
123 End delete_dml;
124 --
125 -- ----------------------------------------------------------------------------
126 -- |----------------------------< dt_pre_delete >-----------------------------|
127 -- ----------------------------------------------------------------------------
128 -- {Start Of Comments}
129 --
130 -- Description:
131 -- The dt_pre_delete process controls the execution of dml
132 -- for the datetrack modes: DELETE, FUTURE_CHANGE
133 -- and DELETE_NEXT_CHANGE only.
134 --
135 -- Prerequisites:
136 -- This is an internal procedure which is called from the pre_delete
137 -- procedure.
138 --
139 -- In Parameters:
140 -- A Pl/Sql record structure.
141 --
142 -- Post Success:
143 -- Processing continues.
144 --
145 -- Post Failure:
146 -- If an error has occurred, an error message and exception will be raised
147 -- but not handled.
148 --
149 -- Developer Implementation Notes:
150 -- This is an internal procedure which is required by Datetrack. Don't
151 -- remove or modify.
152 --
153 -- Access Status:
154 -- Internal Row Handler Use Only.
155 --
156 -- {End Of Comments}
157 -- ----------------------------------------------------------------------------
158 Procedure dt_pre_delete
159 (p_rec in out nocopy pay_cal_shd.g_rec_type
160 ,p_effective_date in date
161 ,p_datetrack_mode in varchar2
162 ,p_validation_start_date in date
163 ,p_validation_end_date in date
164 ) is
165 --
166 l_proc varchar2(72) := g_package||'dt_pre_delete';
167 --
168 Begin
169 hr_utility.set_location('Entering:'||l_proc, 5);
170 --
171 If (p_datetrack_mode <> hr_api.g_zap) then
172 --
173 p_rec.effective_start_date
174 := pay_cal_shd.g_old_rec.effective_start_date;
175 --
176 If (p_datetrack_mode = hr_api.g_delete) then
177 /* Bug : 13951697 . The validation start date is being passed as effective date + 1
178 but we need to update the old record to effective date -1
179 which is nothing but validation_start_date -2 */
180
181 p_rec.effective_end_date := p_validation_start_date - 2;
182 Else
183 p_rec.effective_end_date := p_validation_end_date;
184 End If;
185 --
186 -- Update the current effective end date record
187 --
188 pay_cal_shd.upd_effective_end_date
189 (p_effective_date => p_effective_date
190 ,p_base_key_value => p_rec.cost_allocation_id
191 ,p_new_effective_end_date => p_rec.effective_end_date
192 ,p_validation_start_date => p_validation_start_date
193 ,p_validation_end_date => p_validation_end_date
194 ,p_object_version_number => p_rec.object_version_number
195 );
196 Else
197 p_rec.effective_start_date := null;
198 p_rec.effective_end_date := null;
199 End If;
200 hr_utility.set_location(' Leaving:'||l_proc, 10);
201 End dt_pre_delete;
202 --
203 -- ----------------------------------------------------------------------------
204 -- |------------------------------< pre_delete >------------------------------|
205 -- ----------------------------------------------------------------------------
206 -- {Start Of Comments}
207 --
208 -- Description:
209 -- This private procedure contains any processing which is required before
210 -- the delete dml.
211 --
212 -- Prerequisites:
213 -- This is an internal procedure which is called from the del procedure.
214 --
215 -- In Parameters:
216 -- A Pl/Sql record structure.
217 --
218 -- Post Success:
219 -- Processing continues.
220 --
221 -- Post Failure:
222 -- If an error has occurred, an error message and exception will be raised
223 -- but not handled.
224 --
225 -- Developer Implementation Notes:
226 -- Any pre-processing required before the delete dml is issued should be
227 -- coded within this procedure. It is important to note that any 3rd party
228 -- maintenance should be reviewed before placing in this procedure. The call
229 -- to the dt_delete_dml procedure should NOT be removed.
230 --
231 -- Access Status:
232 -- Internal Row Handler Use Only.
233 --
234 -- {End Of Comments}
235 -- ----------------------------------------------------------------------------
236 Procedure pre_delete
237 (p_rec in out nocopy pay_cal_shd.g_rec_type
238 ,p_effective_date in date
239 ,p_datetrack_mode in varchar2
240 ,p_validation_start_date in date
241 ,p_validation_end_date in date
242 ) is
243 --
244 l_proc varchar2(72) := g_package||'pre_delete';
245 --
246 --
247 --
248 Begin
249 hr_utility.set_location('Entering:'||l_proc, 5);
250 --
251 --
252 --
253 pay_cal_del.dt_pre_delete
254 (p_rec => p_rec
255 ,p_effective_date => p_effective_date
256 ,p_datetrack_mode => p_datetrack_mode
257 ,p_validation_start_date => p_validation_start_date
258 ,p_validation_end_date => p_validation_end_date
259 );
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
271 -- the 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 structure.
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 pay_cal_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
302 ) is
303 --
304 l_proc varchar2(72) := g_package||'post_delete';
305 --
306 Begin
307 hr_utility.set_location('Entering:'||l_proc, 5);
308 begin
309 --
310 pay_cal_rkd.after_delete
311 (p_effective_date
312 => p_effective_date
313 ,p_datetrack_mode
314 => p_datetrack_mode
315 ,p_validation_start_date
316 => p_validation_start_date
317 ,p_validation_end_date
318 => p_validation_end_date
319 ,p_cost_allocation_id
320 => p_rec.cost_allocation_id
321 ,p_effective_start_date
322 => p_rec.effective_start_date
323 ,p_effective_end_date
324 => p_rec.effective_end_date
325 ,p_effective_start_date_o
326 => pay_cal_shd.g_old_rec.effective_start_date
327 ,p_effective_end_date_o
328 => pay_cal_shd.g_old_rec.effective_end_date
329 ,p_business_group_id_o
330 => pay_cal_shd.g_old_rec.business_group_id
331 ,p_cost_allocation_keyflex_id_o
332 => pay_cal_shd.g_old_rec.cost_allocation_keyflex_id
333 ,p_assignment_id_o
334 => pay_cal_shd.g_old_rec.assignment_id
335 ,p_proportion_o
336 => pay_cal_shd.g_old_rec.proportion
337 ,p_request_id_o
338 => pay_cal_shd.g_old_rec.request_id
339 ,p_program_application_id_o
340 => pay_cal_shd.g_old_rec.program_application_id
341 ,p_program_id_o
342 => pay_cal_shd.g_old_rec.program_id
343 ,p_program_update_date_o
344 => pay_cal_shd.g_old_rec.program_update_date
345 ,p_object_version_number_o
346 => pay_cal_shd.g_old_rec.object_version_number
347 );
348 --
349 exception
350 --
351 when hr_api.cannot_find_prog_unit then
352 --
353 hr_api.cannot_find_prog_unit_error
354 (p_module_name => 'PAY_COST_ALLOCATIONS_F'
355 ,p_hook_type => 'AD');
356 --
357 end;
358 --
359 hr_utility.set_location(' Leaving:'||l_proc, 10);
360 End post_delete;
361 --
362 -- ----------------------------------------------------------------------------
363 -- |---------------------------------< del >----------------------------------|
364 -- ----------------------------------------------------------------------------
365 Procedure del
366 (p_effective_date in date
367 ,p_datetrack_mode in varchar2
368 ,p_rec in out nocopy pay_cal_shd.g_rec_type
369 ) is
370 --
371 l_proc varchar2(72) := g_package||'del';
372 l_validation_start_date date;
373 l_validation_end_date date;
374 --
375 Begin
376 hr_utility.set_location('Entering:'||l_proc, 5);
377 --
378 -- Ensure that the DateTrack delete mode is valid
379 --
380 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
381 --
382 -- We must lock the row which we need to delete.
383 --
384 pay_cal_shd.lck
385 (p_effective_date => p_effective_date
386 ,p_datetrack_mode => p_datetrack_mode
387 ,p_cost_allocation_id => p_rec.cost_allocation_id
388 ,p_object_version_number => p_rec.object_version_number
389 ,p_validation_start_date => l_validation_start_date
390 ,p_validation_end_date => l_validation_end_date
391 );
392 --
393 -- Call the supporting delete validate operation
394 --
395 pay_cal_bus.delete_validate
396 (p_rec => p_rec
397 ,p_effective_date => p_effective_date
398 ,p_datetrack_mode => p_datetrack_mode
399 ,p_validation_start_date => l_validation_start_date
400 ,p_validation_end_date => l_validation_end_date
401 );
402 --
403 -- Call to raise any errors on multi-message list
404 hr_multi_message.end_validation_set;
405 --
406 -- Call the supporting pre-delete operation
407 --
408 pay_cal_del.pre_delete
409 (p_rec => p_rec
410 ,p_effective_date => p_effective_date
411 ,p_datetrack_mode => p_datetrack_mode
412 ,p_validation_start_date => l_validation_start_date
413 ,p_validation_end_date => l_validation_end_date
414 );
415 --
416 -- Delete the row.
417 --
418 pay_cal_del.delete_dml
419 (p_rec => p_rec
420 ,p_effective_date => p_effective_date
421 ,p_datetrack_mode => p_datetrack_mode
422 ,p_validation_start_date => l_validation_start_date
423 ,p_validation_end_date => l_validation_end_date
424 );
425 -- Call the supporting post-delete operation
426 --
427 pay_cal_del.post_delete
428 (p_rec => p_rec
429 ,p_effective_date => p_effective_date
430 ,p_datetrack_mode => p_datetrack_mode
431 ,p_validation_start_date => l_validation_start_date
432 ,p_validation_end_date => l_validation_end_date
433 );
434 --
435 -- Call to raise any errors on multi-message list
436 hr_multi_message.end_validation_set;
437 --
438 hr_utility.set_location(' Leaving:'||l_proc, 5);
439 End del;
440 --
441 -- ----------------------------------------------------------------------------
442 -- |--------------------------------< del >-----------------------------------|
443 -- ----------------------------------------------------------------------------
444 Procedure del
445 (p_effective_date in date
446 ,p_datetrack_mode in varchar2
447 ,p_cost_allocation_id in number
448 ,p_object_version_number in out nocopy number
449 ,p_effective_start_date out nocopy date
450 ,p_effective_end_date out nocopy date
451 ) is
452 --
453 l_rec pay_cal_shd.g_rec_type;
454 l_proc varchar2(72) := g_package||'del';
455 --
456 Begin
457 hr_utility.set_location('Entering:'||l_proc, 5);
458 --
459 -- As the delete procedure accepts a plsql record structure we do need to
460 -- convert the arguments into the record structure.
461 -- We don't need to call the supplied conversion argument routine as we
462 -- only need a few attributes.
463 --
464 l_rec.cost_allocation_id := p_cost_allocation_id;
465 l_rec.object_version_number := p_object_version_number;
466 --
467 -- Having converted the arguments into the pay_cal_rec
468 -- plsql record structure we must call the corresponding entity
469 -- business process
470 --
471 pay_cal_del.del
472 (p_effective_date
473 ,p_datetrack_mode
474 ,l_rec
475 );
476 --
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 pay_cal_del;