1 Package Body pay_opm_del as
2 /* $Header: pyopmrhi.pkb 120.4 2005/11/07 01:38:13 pgongada noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_opm_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_opm_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_opm_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_org_payment_methods_f
72 where org_payment_method_id = p_rec.org_payment_method_id
73 and effective_start_date = p_validation_start_date;
74 --
75 pay_opm_shd.g_api_dml := false; -- Unset the api dml status
76 Else
77 pay_opm_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_org_payment_methods_f
83 where org_payment_method_id = p_rec.org_payment_method_id
84 and effective_start_date >= p_validation_start_date;
85 --
86 pay_opm_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_opm_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_opm_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_opm_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_opm_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_opm_shd.g_old_rec.effective_start_date;
175 --
176 If (p_datetrack_mode = hr_api.g_delete) then
177 p_rec.effective_end_date := p_validation_start_date - 1;
178 Else
179 p_rec.effective_end_date := p_validation_end_date;
180 End If;
181 --
182 -- Update the current effective end date record
183 --
184 pay_opm_shd.upd_effective_end_date
185 (p_effective_date => p_effective_date
186 ,p_base_key_value => p_rec.org_payment_method_id
187 ,p_new_effective_end_date => p_rec.effective_end_date
188 ,p_validation_start_date => p_validation_start_date
189 ,p_validation_end_date => p_validation_end_date
190 ,p_object_version_number => p_rec.object_version_number
191 );
192 Else
193 p_rec.effective_start_date := null;
194 p_rec.effective_end_date := null;
195 End If;
196 hr_utility.set_location(' Leaving:'||l_proc, 10);
197 End dt_pre_delete;
198 --
199 -- ----------------------------------------------------------------------------
200 -- |------------------------------< pre_delete >------------------------------|
201 -- ----------------------------------------------------------------------------
202 -- {Start Of Comments}
203 --
204 -- Description:
205 -- This private procedure contains any processing which is required before
206 -- the delete dml.
207 --
208 -- Prerequisites:
209 -- This is an internal procedure which is called from the del procedure.
210 --
211 -- In Parameters:
212 -- A Pl/Sql record structure.
213 --
214 -- Post Success:
215 -- Processing continues.
216 --
217 -- Post Failure:
218 -- If an error has occurred, an error message and exception will be raised
219 -- but not handled.
220 --
221 -- Developer Implementation Notes:
222 -- Any pre-processing required before the delete dml is issued should be
223 -- coded within this procedure. It is important to note that any 3rd party
224 -- maintenance should be reviewed before placing in this procedure. The call
225 -- to the dt_delete_dml procedure should NOT be removed.
226 --
227 -- Access Status:
228 -- Internal Row Handler Use Only.
229 --
230 -- {End Of Comments}
231 -- ----------------------------------------------------------------------------
232 Procedure pre_delete
233 (p_rec in out nocopy pay_opm_shd.g_rec_type
234 ,p_effective_date in date
235 ,p_datetrack_mode in varchar2
236 ,p_validation_start_date in date
237 ,p_validation_end_date in date
238 ) is
239 --
240 l_proc varchar2(72) := g_package||'pre_delete';
241 --
242 -- Cursor C_Sel1 select comments to be deleted
243 --
244 Cursor C_Sel1 is
245 select distinct t1.comment_id
246 from pay_org_payment_methods_f t1
247 where t1.comment_id is not null
248 and t1.org_payment_method_id = p_rec.org_payment_method_id
249 and t1.effective_start_date <= p_validation_end_date
250 and t1.effective_end_date >= p_validation_start_date
251 and not exists
252 (select 1
253 from pay_org_payment_methods_f t2
254 where t2.comment_id = t1.comment_id
255 and t2.org_payment_method_id = t1.org_payment_method_id
256 and (t2.effective_start_date > p_validation_end_date
257 or t2.effective_end_date < p_validation_start_date));
258 --
259 --
260 Begin
261 hr_utility.set_location('Entering:'||l_proc, 5);
262 --
263 --
264 -- Delete any possible comments
265 --
266 hr_utility.set_location('Start:'||to_char(p_validation_start_date),6);
267 hr_utility.set_location('End:'||to_char(p_validation_end_date),7);
268 --
269 For Comm_Del In C_Sel1 Loop
270 hr_utility.set_location('Comment ID:'||Comm_Del.comment_id,7);
271 hr_comm_api.del(p_comment_id => Comm_Del.comment_id);
272 End Loop;
273 --
274 --
275 pay_opm_del.dt_pre_delete
276 (p_rec => p_rec
277 ,p_effective_date => p_effective_date
278 ,p_datetrack_mode => p_datetrack_mode
279 ,p_validation_start_date => p_validation_start_date
280 ,p_validation_end_date => p_validation_end_date
281 );
282 --
283 hr_utility.set_location(' Leaving:'||l_proc, 10);
284 End pre_delete;
285 --
286 -- ----------------------------------------------------------------------------
287 -- |----------------------------< post_delete >-------------------------------|
288 -- ----------------------------------------------------------------------------
289 -- {Start Of Comments}
290 --
291 -- Description:
292 -- This private procedure contains any processing which is required after the
293 -- delete dml.
294 --
295 -- Prerequisites:
296 -- This is an internal procedure which is called from the del procedure.
297 --
298 -- In Parameters:
299 -- A Pl/Sql record structure.
300 --
301 -- Post Success:
302 -- Processing continues.
303 --
304 -- Post Failure:
305 -- If an error has occurred, an error message and exception will be raised
306 -- but not handled.
307 --
308 -- Developer Implementation Notes:
309 -- Any post-processing required after the delete dml is issued should be
310 -- coded within this procedure. It is important to note that any 3rd party
311 -- maintenance should be reviewed before placing in this procedure.
312 --
313 -- Access Status:
314 -- Internal Row Handler Use Only.
315 --
316 -- {End Of Comments}
317 -- ----------------------------------------------------------------------------
318 Procedure post_delete
319 (p_rec in pay_opm_shd.g_rec_type
320 ,p_effective_date in date
321 ,p_datetrack_mode in varchar2
322 ,p_validation_start_date in date
323 ,p_validation_end_date in date
324 ) is
325 --
326 l_proc varchar2(72) := g_package||'post_delete';
327 --
328 Begin
329 hr_utility.set_location('Entering:'||l_proc, 5);
330 begin
331 --
332 pay_opm_rkd.after_delete
333 (p_effective_date
334 => p_effective_date
335 ,p_datetrack_mode
336 => p_datetrack_mode
337 ,p_validation_start_date
338 => p_validation_start_date
339 ,p_validation_end_date
340 => p_validation_end_date
341 ,p_org_payment_method_id
342 => p_rec.org_payment_method_id
343 ,p_effective_start_date
344 => p_rec.effective_start_date
345 ,p_effective_end_date
346 => p_rec.effective_end_date
347 ,p_effective_start_date_o
348 => pay_opm_shd.g_old_rec.effective_start_date
349 ,p_effective_end_date_o
350 => pay_opm_shd.g_old_rec.effective_end_date
351 ,p_business_group_id_o
352 => pay_opm_shd.g_old_rec.business_group_id
353 ,p_external_account_id_o
354 => pay_opm_shd.g_old_rec.external_account_id
355 ,p_currency_code_o
356 => pay_opm_shd.g_old_rec.currency_code
357 ,p_payment_type_id_o
358 => pay_opm_shd.g_old_rec.payment_type_id
359 ,p_defined_balance_id_o
360 => pay_opm_shd.g_old_rec.defined_balance_id
361 ,p_org_payment_method_name_o
362 => pay_opm_shd.g_old_rec.org_payment_method_name
363 ,p_comment_id_o
364 => pay_opm_shd.g_old_rec.comment_id
365 ,p_comments_o
366 => pay_opm_shd.g_old_rec.comments
367 ,p_attribute_category_o
368 => pay_opm_shd.g_old_rec.attribute_category
369 ,p_attribute1_o
370 => pay_opm_shd.g_old_rec.attribute1
371 ,p_attribute2_o
372 => pay_opm_shd.g_old_rec.attribute2
373 ,p_attribute3_o
374 => pay_opm_shd.g_old_rec.attribute3
375 ,p_attribute4_o
376 => pay_opm_shd.g_old_rec.attribute4
377 ,p_attribute5_o
378 => pay_opm_shd.g_old_rec.attribute5
379 ,p_attribute6_o
380 => pay_opm_shd.g_old_rec.attribute6
381 ,p_attribute7_o
382 => pay_opm_shd.g_old_rec.attribute7
383 ,p_attribute8_o
387 ,p_attribute10_o
384 => pay_opm_shd.g_old_rec.attribute8
385 ,p_attribute9_o
386 => pay_opm_shd.g_old_rec.attribute9
388 => pay_opm_shd.g_old_rec.attribute10
389 ,p_attribute11_o
390 => pay_opm_shd.g_old_rec.attribute11
391 ,p_attribute12_o
392 => pay_opm_shd.g_old_rec.attribute12
393 ,p_attribute13_o
394 => pay_opm_shd.g_old_rec.attribute13
395 ,p_attribute14_o
396 => pay_opm_shd.g_old_rec.attribute14
397 ,p_attribute15_o
398 => pay_opm_shd.g_old_rec.attribute15
399 ,p_attribute16_o
400 => pay_opm_shd.g_old_rec.attribute16
401 ,p_attribute17_o
402 => pay_opm_shd.g_old_rec.attribute17
403 ,p_attribute18_o
404 => pay_opm_shd.g_old_rec.attribute18
405 ,p_attribute19_o
406 => pay_opm_shd.g_old_rec.attribute19
407 ,p_attribute20_o
408 => pay_opm_shd.g_old_rec.attribute20
409 ,p_pmeth_information_category_o
410 => pay_opm_shd.g_old_rec.pmeth_information_category
411 ,p_pmeth_information1_o
412 => pay_opm_shd.g_old_rec.pmeth_information1
413 ,p_pmeth_information2_o
414 => pay_opm_shd.g_old_rec.pmeth_information2
415 ,p_pmeth_information3_o
416 => pay_opm_shd.g_old_rec.pmeth_information3
417 ,p_pmeth_information4_o
418 => pay_opm_shd.g_old_rec.pmeth_information4
419 ,p_pmeth_information5_o
420 => pay_opm_shd.g_old_rec.pmeth_information5
421 ,p_pmeth_information6_o
422 => pay_opm_shd.g_old_rec.pmeth_information6
423 ,p_pmeth_information7_o
424 => pay_opm_shd.g_old_rec.pmeth_information7
425 ,p_pmeth_information8_o
426 => pay_opm_shd.g_old_rec.pmeth_information8
427 ,p_pmeth_information9_o
428 => pay_opm_shd.g_old_rec.pmeth_information9
429 ,p_pmeth_information10_o
430 => pay_opm_shd.g_old_rec.pmeth_information10
431 ,p_pmeth_information11_o
432 => pay_opm_shd.g_old_rec.pmeth_information11
433 ,p_pmeth_information12_o
434 => pay_opm_shd.g_old_rec.pmeth_information12
435 ,p_pmeth_information13_o
436 => pay_opm_shd.g_old_rec.pmeth_information13
437 ,p_pmeth_information14_o
438 => pay_opm_shd.g_old_rec.pmeth_information14
439 ,p_pmeth_information15_o
440 => pay_opm_shd.g_old_rec.pmeth_information15
441 ,p_pmeth_information16_o
442 => pay_opm_shd.g_old_rec.pmeth_information16
443 ,p_pmeth_information17_o
444 => pay_opm_shd.g_old_rec.pmeth_information17
445 ,p_pmeth_information18_o
446 => pay_opm_shd.g_old_rec.pmeth_information18
447 ,p_pmeth_information19_o
448 => pay_opm_shd.g_old_rec.pmeth_information19
449 ,p_pmeth_information20_o
450 => pay_opm_shd.g_old_rec.pmeth_information20
451 ,p_object_version_number_o
452 => pay_opm_shd.g_old_rec.object_version_number
453 ,p_transfer_to_gl_flag_o
454 => pay_opm_shd.g_old_rec.transfer_to_gl_flag
455 ,p_cost_payment_o
456 => pay_opm_shd.g_old_rec.cost_payment
457 ,p_cost_cleared_payment_o
458 => pay_opm_shd.g_old_rec.cost_cleared_payment
459 ,p_cost_cleared_void_payment_o
460 => pay_opm_shd.g_old_rec.cost_cleared_void_payment
461 ,p_exclude_manual_payment_o
462 => pay_opm_shd.g_old_rec.exclude_manual_payment
463 );
464 --
465 exception
466 --
467 when hr_api.cannot_find_prog_unit then
468 --
469 hr_api.cannot_find_prog_unit_error
470 (p_module_name => 'PAY_ORG_PAYMENT_METHODS_F'
471 ,p_hook_type => 'AD');
472 --
473 end;
474 --
475 hr_utility.set_location(' Leaving:'||l_proc, 10);
476 End post_delete;
477 --
478 -- ----------------------------------------------------------------------------
479 -- |---------------------------------< del >----------------------------------|
480 -- ----------------------------------------------------------------------------
481 Procedure del
482 (p_effective_date in date
483 ,p_datetrack_mode in varchar2
484 ,p_rec in out nocopy pay_opm_shd.g_rec_type
485 ) is
486 --
487 l_proc varchar2(72) := g_package||'del';
488 l_validation_start_date date;
489 l_validation_end_date date;
490 --
491 Begin
492 hr_utility.set_location('Entering:'||l_proc, 5);
493 --
494 -- Ensure that the DateTrack delete mode is valid
495 --
496 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
497 --
498 -- We must lock the row which we need to delete.
499 --
500 pay_opm_shd.lck
501 (p_effective_date => p_effective_date
502 ,p_datetrack_mode => p_datetrack_mode
503 ,p_org_payment_method_id => p_rec.org_payment_method_id
504 ,p_object_version_number => p_rec.object_version_number
505 ,p_validation_start_date => l_validation_start_date
506 ,p_validation_end_date => l_validation_end_date
507 );
508 --
509 -- Call the supporting delete validate operation
510 --
511 pay_opm_bus.delete_validate
512 (p_rec => p_rec
513 ,p_effective_date => p_effective_date
517 );
514 ,p_datetrack_mode => p_datetrack_mode
515 ,p_validation_start_date => l_validation_start_date
516 ,p_validation_end_date => l_validation_end_date
518 --
519 -- Call the supporting pre-delete operation
520 --
521 pay_opm_del.pre_delete
522 (p_rec => p_rec
523 ,p_effective_date => p_effective_date
524 ,p_datetrack_mode => p_datetrack_mode
525 ,p_validation_start_date => l_validation_start_date
526 ,p_validation_end_date => l_validation_end_date
527 );
528 --
529 -- Delete the row.
530 --
531 pay_opm_del.delete_dml
532 (p_rec => p_rec
533 ,p_effective_date => p_effective_date
534 ,p_datetrack_mode => p_datetrack_mode
535 ,p_validation_start_date => l_validation_start_date
536 ,p_validation_end_date => l_validation_end_date
537 );
538 -- Call the supporting post-delete operation
539 --
540 pay_opm_del.post_delete
541 (p_rec => p_rec
542 ,p_effective_date => p_effective_date
543 ,p_datetrack_mode => p_datetrack_mode
544 ,p_validation_start_date => l_validation_start_date
545 ,p_validation_end_date => l_validation_end_date
546 );
547 --
548 hr_utility.set_location(' Leaving:'||l_proc, 5);
549 End del;
550 --
551 -- ----------------------------------------------------------------------------
552 -- |--------------------------------< del >-----------------------------------|
553 -- ----------------------------------------------------------------------------
554 Procedure del
555 (p_effective_date in date
556 ,p_datetrack_mode in varchar2
557 ,p_org_payment_method_id in number
558 ,p_object_version_number in out nocopy number
559 ,p_effective_start_date out nocopy date
560 ,p_effective_end_date out nocopy date
561 ) is
562 --
563 cursor csr_bus_grp is
564 select opm.business_group_id
565 from pay_org_payment_methods_f opm
566 where opm.org_payment_method_id = p_org_payment_method_id;
567 --
568 l_rec pay_opm_shd.g_rec_type;
569 l_proc varchar2(72) := g_package||'del';
570 --
571 Begin
572 hr_utility.set_location('Entering:'||l_proc, 5);
573 --
574 -- As the delete procedure accepts a plsql record structure we do need to
575 -- convert the arguments into the record structure.
576 -- We don't need to call the supplied conversion argument routine as we
577 -- only need a few attributes.
578 --
579 l_rec.org_payment_method_id := p_org_payment_method_id;
580 l_rec.object_version_number := p_object_version_number;
581 open csr_bus_grp;
582 fetch csr_bus_grp into l_rec.business_group_id;
583 --
584 if csr_bus_grp%notfound then
585 --
586 close csr_bus_grp;
587 --
588 -- The primary key is invalid therefore we must error
589 --
590 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
591 fnd_message.raise_error;
592 --
593 end if;
594 close csr_bus_grp;
595 --
596 -- Having converted the arguments into the pay_opm_rec
597 -- plsql record structure we must call the corresponding entity
598 -- business process
599 --
600 pay_opm_del.del
601 (p_effective_date
602 ,p_datetrack_mode
603 ,l_rec
604 );
605 --
606 -- Set the out arguments
607 --
608 p_object_version_number := l_rec.object_version_number;
609 p_effective_start_date := l_rec.effective_start_date;
610 p_effective_end_date := l_rec.effective_end_date;
611 --
612 hr_utility.set_location(' Leaving:'||l_proc, 10);
613 End del;
614 --
615 end pay_opm_del;