1 Package Body pay_ppr_del as
2 /* $Header: pypprrhi.pkb 115.3 2004/02/25 21:33 adkumar noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_ppr_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_ppr_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_ppr_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_status_processing_rules_f
72 where status_processing_rule_id = p_rec.status_processing_rule_id
73 and effective_start_date = p_validation_start_date;
74 --
75 pay_ppr_shd.g_api_dml := false; -- Unset the api dml status
76 Else
77 pay_ppr_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_status_processing_rules_f
83 where status_processing_rule_id = p_rec.status_processing_rule_id
84 and effective_start_date >= p_validation_start_date;
85 --
86 pay_ppr_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_ppr_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_ppr_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_ppr_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_ppr_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_ppr_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_ppr_shd.upd_effective_end_date
225 (p_effective_date => p_effective_date
226 ,p_base_key_value => p_rec.status_processing_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_ppr_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 -- Cursor C_Sel1 select comments to be deleted
283 --
284 Cursor C_Sel1 is
285 select t1.comment_id
286 from pay_status_processing_rules_f t1
287 where t1.comment_id is not null
288 and t1.status_processing_rule_id = p_rec.status_processing_rule_id
289 and t1.effective_start_date <= p_validation_end_date
290 and t1.effective_end_date >= p_validation_start_date
291 and not exists
292 (select 1
293 from pay_status_processing_rules_f t2
294 where t2.comment_id = t1.comment_id
295 and t2.status_processing_rule_id = t1.status_processing_rule_id
296 and (t2.effective_start_date > p_validation_end_date
297 or t2.effective_end_date < p_validation_start_date));
298 --
299 --
300 Begin
301 hr_utility.set_location('Entering:'||l_proc, 5);
302 --
303 --
304 -- Delete any possible comments
305 --
306 For Comm_Del In C_Sel1 Loop
307 hr_comm_api.del(p_comment_id => Comm_Del.comment_id);
308 End Loop;
309 --
310 --
311 pay_ppr_del.dt_pre_delete
312 (p_rec => p_rec
313 ,p_effective_date => p_effective_date
314 ,p_datetrack_mode => p_datetrack_mode
315 ,p_validation_start_date => p_validation_start_date
316 ,p_validation_end_date => p_validation_end_date
317 );
318 --
319 hr_utility.set_location(' Leaving:'||l_proc, 10);
320 End pre_delete;
321 --
322 -- ----------------------------------------------------------------------------
323 -- |----------------------------< post_delete >-------------------------------|
324 -- ----------------------------------------------------------------------------
325 -- {Start Of Comments}
326 --
327 -- Description:
328 -- This private procedure contains any processing which is required after
329 -- the delete dml.
330 --
331 -- Prerequisites:
332 -- This is an internal procedure which is called from the del procedure.
333 --
334 -- In Parameters:
335 -- A Pl/Sql record structure.
336 --
337 -- Post Success:
338 -- Processing continues.
339 --
340 -- Post Failure:
341 -- If an error has occurred, an error message and exception will be raised
342 -- but not handled.
343 --
344 -- Developer Implementation Notes:
345 -- Any post-processing required after the delete dml is issued should be
346 -- coded within this procedure. It is important to note that any 3rd party
347 -- maintenance should be reviewed before placing in this procedure.
348 --
349 -- Access Status:
350 -- Internal Row Handler Use Only.
351 --
352 -- {End Of Comments}
353 -- ----------------------------------------------------------------------------
354 Procedure post_delete
355 (p_rec in pay_ppr_shd.g_rec_type
356 ,p_effective_date in date
357 ,p_datetrack_mode in varchar2
358 ,p_validation_start_date in date
359 ,p_validation_end_date in date
360 ) is
361 --
362 l_proc varchar2(72) := g_package||'post_delete';
363 --
364 Begin
365 hr_utility.set_location('Entering:'||l_proc, 5);
366 begin
367 --
368 -- Delete ownerships if applicable
369 delete_app_ownerships
370 ('STATUS_PROCESSING_RULE_ID', p_rec.status_processing_rule_id
371 ,p_datetrack_mode
372 );
373 --
374 pay_ppr_rkd.after_delete
375 (p_effective_date
376 => p_effective_date
377 ,p_datetrack_mode
378 => p_datetrack_mode
379 ,p_validation_start_date
380 => p_validation_start_date
381 ,p_validation_end_date
382 => p_validation_end_date
383 ,p_status_processing_rule_id
384 => p_rec.status_processing_rule_id
385 ,p_effective_start_date
386 => p_rec.effective_start_date
387 ,p_effective_end_date
388 => p_rec.effective_end_date
389 ,p_effective_start_date_o
390 => pay_ppr_shd.g_old_rec.effective_start_date
394 => pay_ppr_shd.g_old_rec.business_group_id
391 ,p_effective_end_date_o
392 => pay_ppr_shd.g_old_rec.effective_end_date
393 ,p_business_group_id_o
395 ,p_legislation_code_o
396 => pay_ppr_shd.g_old_rec.legislation_code
397 ,p_element_type_id_o
398 => pay_ppr_shd.g_old_rec.element_type_id
399 ,p_assignment_status_type_id_o
400 => pay_ppr_shd.g_old_rec.assignment_status_type_id
401 ,p_formula_id_o
402 => pay_ppr_shd.g_old_rec.formula_id
403 ,p_processing_rule_o
404 => pay_ppr_shd.g_old_rec.processing_rule
405 ,p_comment_id_o
406 => pay_ppr_shd.g_old_rec.comment_id
407 ,p_comments_o
408 => pay_ppr_shd.g_old_rec.comments
409 ,p_legislation_subgroup_o
410 => pay_ppr_shd.g_old_rec.legislation_subgroup
411 ,p_object_version_number_o
412 => pay_ppr_shd.g_old_rec.object_version_number
413 );
414 --
415 exception
416 --
417 when hr_api.cannot_find_prog_unit then
418 --
419 hr_api.cannot_find_prog_unit_error
420 (p_module_name => 'PAY_STATUS_PROCESSING_RULES_F'
421 ,p_hook_type => 'AD');
422 --
423 end;
424 --
425 hr_utility.set_location(' Leaving:'||l_proc, 10);
426 End post_delete;
427 --
428 -- ----------------------------------------------------------------------------
429 -- |---------------------------------< del >----------------------------------|
430 -- ----------------------------------------------------------------------------
431 Procedure del
432 (p_effective_date in date
433 ,p_datetrack_mode in varchar2
434 ,p_rec in out nocopy pay_ppr_shd.g_rec_type
435 ) is
436 --
437 l_proc varchar2(72) := g_package||'del';
438 l_validation_start_date date;
439 l_validation_end_date date;
440 --
441 Begin
442 hr_utility.set_location('Entering:'||l_proc, 5);
443 --
444 -- Ensure that the DateTrack delete mode is valid
445 --
446 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
447 --
448 -- We must lock the row which we need to delete.
449 --
450 pay_ppr_shd.lck
451 (p_effective_date => p_effective_date
452 ,p_datetrack_mode => p_datetrack_mode
453 ,p_status_processing_rule_id => p_rec.status_processing_rule_id
454 ,p_object_version_number => p_rec.object_version_number
455 ,p_validation_start_date => l_validation_start_date
456 ,p_validation_end_date => l_validation_end_date
457 );
458 --
459 --
460 -- set the effective end date of Status Processing Rule
461 -- according to business rule.
462 -- set end date if it is last record and its end date is EOT.
463 --
464
465 If (p_datetrack_mode = hr_api.g_delete_next_change and
466 l_validation_end_date = hr_api.g_eot) then
467 pay_ppr_bus.set_effective_end_date
468 (p_effective_date => p_effective_date
469 ,p_status_processing_rule_id => p_rec.status_processing_rule_id
470 ,p_element_type_id => pay_ppr_shd.g_old_rec.element_type_id
471 ,p_formula_id => pay_ppr_shd.g_old_rec.formula_id
472 ,p_assignment_status_type_id => pay_ppr_shd.g_old_rec.assignment_status_type_id
473 ,p_processing_rule => pay_ppr_shd.g_old_rec.processing_rule
474 ,p_business_group_id => pay_ppr_shd.g_old_rec.business_group_id
475 ,p_legislation_code => pay_ppr_shd.g_old_rec.legislation_code
476 ,p_datetrack_mode => p_datetrack_mode
477 ,p_validation_start_date => l_validation_start_date
478 ,p_validation_end_date => l_validation_end_date
479 );
480 End If;
481 --
482 --
483 -- Call the supporting delete validate operation
484 --
485 pay_ppr_bus.delete_validate
486 (p_rec => p_rec
487 ,p_effective_date => p_effective_date
488 ,p_datetrack_mode => p_datetrack_mode
489 ,p_validation_start_date => l_validation_start_date
490 ,p_validation_end_date => l_validation_end_date
491 );
492 --
493 -- Call to raise any errors on multi-message list
494 hr_multi_message.end_validation_set;
495 --
496 -- Call the supporting pre-delete operation
497 --
498 pay_ppr_del.pre_delete
499 (p_rec => p_rec
500 ,p_effective_date => p_effective_date
501 ,p_datetrack_mode => p_datetrack_mode
502 ,p_validation_start_date => l_validation_start_date
503 ,p_validation_end_date => l_validation_end_date
504 );
505 --
506 -- Delete the row.
507 --
508 pay_ppr_del.delete_dml
509 (p_rec => p_rec
510 ,p_effective_date => p_effective_date
511 ,p_datetrack_mode => p_datetrack_mode
512 ,p_validation_start_date => l_validation_start_date
513 ,p_validation_end_date => l_validation_end_date
514 );
515 --
516
517 -- Cascade the action to formula result rules for this Status Processing Rule
518 pay_formula_result_rules_pkg.parent_deleted (
519 'PAY_STATUS_PROCESSING_RULES_F',
520 p_rec.status_processing_rule_id,
521 p_effective_date,
522 p_datetrack_mode
523 );
524 --
525
526
527 -- Call the supporting post-delete operation
528 --
529 pay_ppr_del.post_delete
530 (p_rec => p_rec
531 ,p_effective_date => p_effective_date
532 ,p_datetrack_mode => p_datetrack_mode
533 ,p_validation_start_date => l_validation_start_date
534 ,p_validation_end_date => l_validation_end_date
535 );
536 --
537 -- Call to raise any errors on multi-message list
538 hr_multi_message.end_validation_set;
539 --
540 hr_utility.set_location(' Leaving:'||l_proc, 5);
541 End del;
542 --
543 -- ----------------------------------------------------------------------------
544 -- |--------------------------------< del >-----------------------------------|
545 -- ----------------------------------------------------------------------------
546 Procedure del
547 (p_effective_date in date
548 ,p_datetrack_mode in varchar2
549 ,p_status_processing_rule_id in number
550 ,p_object_version_number in out nocopy number
551 ,p_effective_start_date out nocopy date
552 ,p_effective_end_date out nocopy date
553 ) is
554 --
555 l_rec pay_ppr_shd.g_rec_type;
556 l_proc varchar2(72) := g_package||'del';
557 --
558 Begin
559 hr_utility.set_location('Entering:'||l_proc, 5);
560 --
561 -- As the delete procedure accepts a plsql record structure we do need to
562 -- convert the arguments into the record structure.
563 -- We don't need to call the supplied conversion argument routine as we
564 -- only need a few attributes.
565 --
566 l_rec.status_processing_rule_id := p_status_processing_rule_id;
567 l_rec.object_version_number := p_object_version_number;
568 --
569 -- Having converted the arguments into the pay_ppr_rec
570 -- plsql record structure we must call the corresponding entity
571 -- business process
572 --
573 pay_ppr_del.del
574 (p_effective_date
575 ,p_datetrack_mode
576 ,l_rec
577 );
578 --
579 --
580 -- Set the out arguments
581 --
582 p_object_version_number := l_rec.object_version_number;
583 p_effective_start_date := l_rec.effective_start_date;
584 p_effective_end_date := l_rec.effective_end_date;
585 --
586 hr_utility.set_location(' Leaving:'||l_proc, 10);
587 End del;
588 --
589 end pay_ppr_del;