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