4 -- ----------------------------------------------------------------------------
1 Package Body pay_pgr_del as
2 /* $Header: pypgrrhi.pkb 120.6.12020000.2 2013/01/17 09:39:34 sclakkar ship $ */
3 --
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_pgr_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_pgr_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_pgr_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_grade_rules_f
72 where grade_rule_id = p_rec.grade_rule_id
73 and effective_start_date = p_validation_start_date;
74 --
75 pay_pgr_shd.g_api_dml := false; -- Unset the api dml status
76 Else
77 pay_pgr_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_grade_rules_f
83 where grade_rule_id = p_rec.grade_rule_id
84 and effective_start_date >= p_validation_start_date;
85 --
86 pay_pgr_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_pgr_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_pgr_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_pgr_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:
139 -- In Parameters:
136 -- This is an internal procedure which is called from the pre_delete
137 -- procedure.
138 --
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_pgr_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 l_return varchar2(30);
168 --
169 Begin
170 hr_utility.set_location('Entering:'||l_proc, 5);
171 --
172
173 --
174 -- Call pqh_gsp_sync_compensation_obj.delete_std_rt_for_grade_rule
175 --
176 --
177 l_return := pqh_gsp_sync_compensation_obj.delete_std_rt_for_grade_rule
178 (p_rate_type => p_rec.rate_type
179 ,p_grade_or_spinal_point_id => p_rec.grade_or_spinal_point_id
180 ,p_grade_rule_id => p_rec.grade_rule_id
181 ,p_effective_date => p_effective_date
182 ,p_datetrack_mode => p_datetrack_mode
183 );
184 --
185 if l_return <> 'SUCCESS' Then
186 fnd_message.set_name('PER','PER_289563_DEL_PLAN_FOR_GRADE');
187 fnd_message.set_token('ERR_CODE','-9');
188 --
189 fnd_message.raise_error;
190 End if;
191 hr_utility.trace('pqh_gsp_sync_compensation_obj.delete_std_for_grade_rule : '
192 || l_return);
193
194 If (p_datetrack_mode <> hr_api.g_zap) then
195 --
196 p_rec.effective_start_date
197 := pay_pgr_shd.g_old_rec.effective_start_date;
198 --
199 If (p_datetrack_mode = hr_api.g_delete) then
200 p_rec.effective_end_date := p_validation_start_date - 1;
201 Else
202 p_rec.effective_end_date := p_validation_end_date;
203 End If;
204 --
205 -- Update the current effective end date record
206 --
207 pay_pgr_shd.upd_effective_end_date
208 (p_effective_date => p_effective_date
209 ,p_base_key_value => p_rec.grade_rule_id
210 ,p_new_effective_end_date => p_rec.effective_end_date
211 ,p_validation_start_date => p_validation_start_date
212 ,p_validation_end_date => p_validation_end_date
213 ,p_object_version_number => p_rec.object_version_number
214 );
215 Else
216 p_rec.effective_start_date := null;
217 p_rec.effective_end_date := null;
218 End If;
219 hr_utility.set_location(' Leaving:'||l_proc, 10);
220 End dt_pre_delete;
221 --
222 -- ----------------------------------------------------------------------------
223 -- |------------------------------< pre_delete >------------------------------|
224 -- ----------------------------------------------------------------------------
225 -- {Start Of Comments}
226 --
227 -- Description:
228 -- This private procedure contains any processing which is required before
229 -- the delete dml.
230 --
231 -- Prerequisites:
232 -- This is an internal procedure which is called from the del procedure.
233 --
234 -- In Parameters:
235 -- A Pl/Sql record structure.
236 --
237 -- Post Success:
238 -- Processing continues.
239 --
240 -- Post Failure:
241 -- If an error has occurred, an error message and exception will be raised
242 -- but not handled.
243 --
244 -- Developer Implementation Notes:
245 -- Any pre-processing required before the delete dml is issued should be
246 -- coded within this procedure. It is important to note that any 3rd party
247 -- maintenance should be reviewed before placing in this procedure. The call
248 -- to the dt_delete_dml procedure should NOT be removed.
249 --
250 -- Access Status:
251 -- Internal Row Handler Use Only.
252 --
253 -- {End Of Comments}
254 -- ----------------------------------------------------------------------------
255 Procedure pre_delete
256 (p_rec in out nocopy pay_pgr_shd.g_rec_type
257 ,p_effective_date in date
258 ,p_datetrack_mode in varchar2
259 ,p_validation_start_date in date
260 ,p_validation_end_date in date
261 ) is
262 --
263 l_proc varchar2(72) := g_package||'pre_delete';
264 --
265 --
266 --
267 Begin
268 hr_utility.set_location('Entering:'||l_proc, 5);
269 --
270 --
271 --
272 pay_pgr_del.dt_pre_delete
273 (p_rec => p_rec
274 ,p_effective_date => p_effective_date
275 ,p_datetrack_mode => p_datetrack_mode
276 ,p_validation_start_date => p_validation_start_date
277 ,p_validation_end_date => p_validation_end_date
278 );
279 --
280 hr_utility.set_location(' Leaving:'||l_proc, 10);
281 End pre_delete;
282 --
283 -- ----------------------------------------------------------------------------
284 -- |----------------------------< post_delete >-------------------------------|
288 -- Description:
285 -- ----------------------------------------------------------------------------
286 -- {Start Of Comments}
287 --
289 -- This private procedure contains any processing which is required after
290 -- the delete dml.
291 --
292 -- Prerequisites:
293 -- This is an internal procedure which is called from the del procedure.
294 --
295 -- In Parameters:
296 -- A Pl/Sql record structure.
297 --
298 -- Post Success:
299 -- Processing continues.
300 --
301 -- Post Failure:
302 -- If an error has occurred, an error message and exception will be raised
303 -- but not handled.
304 --
305 -- Developer Implementation Notes:
306 -- Any post-processing required after the delete dml is issued should be
307 -- coded within this procedure. It is important to note that any 3rd party
308 -- maintenance should be reviewed before placing in this procedure.
309 --
310 -- Access Status:
311 -- Internal Row Handler Use Only.
312 --
313 -- {End Of Comments}
314 -- ----------------------------------------------------------------------------
315 Procedure post_delete
316 (p_rec in pay_pgr_shd.g_rec_type
317 ,p_effective_date in date
318 ,p_datetrack_mode in varchar2
319 ,p_validation_start_date in date
320 ,p_validation_end_date in date
321 ) is
322 --
323 l_proc varchar2(72) := g_package||'post_delete';
324 --
325 Begin
326 hr_utility.set_location('Entering:'||l_proc, 5);
327 begin
328 --
329 pay_pgr_rkd.after_delete
330 (p_effective_date
331 => p_effective_date
332 ,p_datetrack_mode
333 => p_datetrack_mode
334 ,p_validation_start_date
335 => p_validation_start_date
336 ,p_validation_end_date
337 => p_validation_end_date
338 ,p_grade_rule_id
339 => p_rec.grade_rule_id
340 ,p_effective_start_date
341 => p_rec.effective_start_date
342 ,p_effective_end_date
343 => p_rec.effective_end_date
344 ,p_effective_start_date_o
345 => pay_pgr_shd.g_old_rec.effective_start_date
346 ,p_effective_end_date_o
347 => pay_pgr_shd.g_old_rec.effective_end_date
348 ,p_business_group_id_o
349 => pay_pgr_shd.g_old_rec.business_group_id
350 ,p_rate_id_o
351 => pay_pgr_shd.g_old_rec.rate_id
352 ,p_grade_or_spinal_point_id_o
353 => pay_pgr_shd.g_old_rec.grade_or_spinal_point_id
354 ,p_rate_type_o
355 => pay_pgr_shd.g_old_rec.rate_type
356 ,p_maximum_o
357 => pay_pgr_shd.g_old_rec.maximum
358 ,p_mid_value_o
359 => pay_pgr_shd.g_old_rec.mid_value
360 ,p_minimum_o
361 => pay_pgr_shd.g_old_rec.minimum
362 ,p_sequence_o
363 => pay_pgr_shd.g_old_rec.sequence
364 ,p_value_o
365 => pay_pgr_shd.g_old_rec.value
366 ,p_request_id_o
367 => pay_pgr_shd.g_old_rec.request_id
368 ,p_program_application_id_o
369 => pay_pgr_shd.g_old_rec.program_application_id
370 ,p_program_id_o
371 => pay_pgr_shd.g_old_rec.program_id
372 ,p_program_update_date_o
373 => pay_pgr_shd.g_old_rec.program_update_date
374 ,p_object_version_number_o
375 => pay_pgr_shd.g_old_rec.object_version_number
376 ,p_currency_code_o
377 => pay_pgr_shd.g_old_rec.currency_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_GRADE_RULES_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_pgr_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_pgr_shd.lck
416 (p_effective_date => p_effective_date
417 ,p_datetrack_mode => p_datetrack_mode
418 ,p_grade_rule_id => p_rec.grade_rule_id
419 ,p_object_version_number => p_rec.object_version_number
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_pgr_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 --
437 -- Call the supporting pre-delete operation
434 -- Call to raise any errors on multi-message list
435 hr_multi_message.end_validation_set;
436 --
438 --
439 pay_pgr_del.pre_delete
440 (p_rec => p_rec
441 ,p_effective_date => p_effective_date
442 ,p_datetrack_mode => p_datetrack_mode
443 ,p_validation_start_date => l_validation_start_date
444 ,p_validation_end_date => l_validation_end_date
445 );
446 --
447 -- Delete the row.
448 --
449 pay_pgr_del.delete_dml
450 (p_rec => p_rec
451 ,p_effective_date => p_effective_date
452 ,p_datetrack_mode => p_datetrack_mode
453 ,p_validation_start_date => l_validation_start_date
454 ,p_validation_end_date => l_validation_end_date
455 );
456 -- Call the supporting post-delete operation
457 --
458 pay_pgr_del.post_delete
459 (p_rec => p_rec
460 ,p_effective_date => p_effective_date
461 ,p_datetrack_mode => p_datetrack_mode
462 ,p_validation_start_date => l_validation_start_date
463 ,p_validation_end_date => l_validation_end_date
464 );
465 --
466 -- Call to raise any errors on multi-message list
467 hr_multi_message.end_validation_set;
468 --
469 hr_utility.set_location(' Leaving:'||l_proc, 5);
470 End del;
471 --
472 -- ----------------------------------------------------------------------------
473 -- |--------------------------------< del >-----------------------------------|
474 -- ----------------------------------------------------------------------------
475 Procedure del
476 (p_effective_date in date
477 ,p_datetrack_mode in varchar2
478 ,p_grade_rule_id in number
479 ,p_object_version_number in out nocopy number
480 ,p_effective_start_date out nocopy date
481 ,p_effective_end_date out nocopy date
482 ) is
483 --
484 l_rec pay_pgr_shd.g_rec_type;
485 l_proc varchar2(72) := g_package||'del';
486 --
487 Begin
488 hr_utility.set_location('Entering:'||l_proc, 5);
489 --
490 -- As the delete procedure accepts a plsql record structure we do need to
491 -- convert the arguments into the record structure.
492 -- We don't need to call the supplied conversion argument routine as we
493 -- only need a few attributes.
494 --
495 l_rec.grade_rule_id := p_grade_rule_id;
496 l_rec.object_version_number := p_object_version_number;
497 --
498 -- Having converted the arguments into the pay_pgr_rec
499 -- plsql record structure we must call the corresponding entity
500 -- business process
501 --
502 pay_pgr_del.del
503 (p_effective_date
504 ,p_datetrack_mode
505 ,l_rec
506 );
507 --
508 --
509 -- Set the out arguments
510 --
511 p_object_version_number := l_rec.object_version_number;
512 p_effective_start_date := l_rec.effective_start_date;
513 p_effective_end_date := l_rec.effective_end_date;
514 --
515 hr_utility.set_location(' Leaving:'||l_proc, 10);
516 End del;
517 --
518 end pay_pgr_del;