DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PRY_DEL

Source


1 Package Body ben_pry_del as
2 /* $Header: bepryrhi.pkb 120.7 2008/04/29 07:14:34 sagnanas noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ben_pry_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
25 --      than or equal to the validation start date.
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
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 ben_pry_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     ben_pry_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 ben_prtt_rmt_aprvd_fr_pymt_f
72     where       prtt_rmt_aprvd_fr_pymt_id = p_rec.prtt_rmt_aprvd_fr_pymt_id
73     and   effective_start_date = p_validation_start_date;
74     --
75     ben_pry_shd.g_api_dml := false;   -- Unset the api dml status
76   Else
77     ben_pry_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 ben_prtt_rmt_aprvd_fr_pymt_f
83     where        prtt_rmt_aprvd_fr_pymt_id = p_rec.prtt_rmt_aprvd_fr_pymt_id
84     and   effective_start_date >= p_validation_start_date;
85     --
86     ben_pry_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     ben_pry_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 ben_pry_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   ben_pry_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 ben_pry_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       := ben_pry_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     ben_pry_shd.upd_effective_end_date
185       (p_effective_date         => p_effective_date
186       ,p_base_key_value         => p_rec.prtt_rmt_aprvd_fr_pymt_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 ben_pry_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   --
243 --
244 Begin
245   hr_utility.set_location('Entering:'||l_proc, 5);
246   --
247 --
248   --
249   ben_pry_del.dt_pre_delete
250     (p_rec                   => p_rec
251     ,p_effective_date        => p_effective_date
252     ,p_datetrack_mode        => p_datetrack_mode
253     ,p_validation_start_date => p_validation_start_date
254     ,p_validation_end_date   => p_validation_end_date
255     );
256   --
257   hr_utility.set_location(' Leaving:'||l_proc, 10);
258 End pre_delete;
259 --
260 -- ----------------------------------------------------------------------------
261 -- |----------------------------< post_delete >-------------------------------|
262 -- ----------------------------------------------------------------------------
263 -- {Start Of Comments}
264 --
265 -- Description:
266 --   This private procedure contains any processing which is required after
267 --   the delete dml.
268 --
269 -- Prerequisites:
270 --   This is an internal procedure which is called from the del procedure.
271 --
272 -- In Parameters:
273 --   A Pl/Sql record structure.
274 --
275 -- Post Success:
276 --   Processing continues.
277 --
278 -- Post Failure:
279 --   If an error has occurred, an error message and exception will be raised
280 --   but not handled.
281 --
282 -- Developer Implementation Notes:
283 --   Any post-processing required after the delete dml is issued should be
284 --   coded within this procedure. It is important to note that any 3rd party
285 --   maintenance should be reviewed before placing in this procedure.
286 --
287 -- Access Status:
288 --   Internal Row Handler Use Only.
289 --
290 -- {End Of Comments}
291 -- ----------------------------------------------------------------------------
292 Procedure post_delete
293   (p_rec                   in ben_pry_shd.g_rec_type
294   ,p_effective_date        in date
295   ,p_datetrack_mode        in varchar2
296   ,p_validation_start_date in date
297   ,p_validation_end_date   in date
298   ) is
299 --
300   l_proc        varchar2(72) := g_package||'post_delete';
301 --
302 Begin
303   hr_utility.set_location('Entering:'||l_proc, 5);
304    begin
305     --
306     ben_pry_rkd.after_delete
307       (p_effective_date
308       => p_effective_date
309       ,p_datetrack_mode
310       => p_datetrack_mode
311       ,p_validation_start_date
312       => p_validation_start_date
313       ,p_validation_end_date
314       => p_validation_end_date
315       ,p_prtt_rmt_aprvd_fr_pymt_id
316       => p_rec.prtt_rmt_aprvd_fr_pymt_id
317       ,p_effective_start_date
318       => p_rec.effective_start_date
319       ,p_effective_end_date
320       => p_rec.effective_end_date
321       ,p_prtt_reimbmt_rqst_id_o
322       => ben_pry_shd.g_old_rec.prtt_reimbmt_rqst_id
323       ,p_effective_start_date_o
324       => ben_pry_shd.g_old_rec.effective_start_date
325       ,p_effective_end_date_o
326       => ben_pry_shd.g_old_rec.effective_end_date
327       ,p_apprvd_fr_pymt_num_o
328       => ben_pry_shd.g_old_rec.apprvd_fr_pymt_num
329       ,p_adjmt_flag_o
330       => ben_pry_shd.g_old_rec.adjmt_flag
331       ,p_aprvd_fr_pymt_amt_o
332       => ben_pry_shd.g_old_rec.aprvd_fr_pymt_amt
333       ,p_pymt_stat_cd_o
334       => ben_pry_shd.g_old_rec.pymt_stat_cd
335       ,p_pymt_stat_rsn_cd_o
336       => ben_pry_shd.g_old_rec.pymt_stat_rsn_cd
337       ,p_pymt_stat_ovrdn_rsn_cd_o
338       => ben_pry_shd.g_old_rec.pymt_stat_ovrdn_rsn_cd
339       ,p_pymt_stat_prr_to_ovrd_cd_o
340       => ben_pry_shd.g_old_rec.pymt_stat_prr_to_ovrd_cd
341       ,p_business_group_id_o
342       => ben_pry_shd.g_old_rec.business_group_id
343       ,p_element_entry_value_id_o => ben_pry_shd.g_old_rec.element_entry_value_id
344       ,p_pry_attribute_category_o
345       => ben_pry_shd.g_old_rec.pry_attribute_category
346       ,p_pry_attribute1_o
347       => ben_pry_shd.g_old_rec.pry_attribute1
348       ,p_pry_attribute2_o
349       => ben_pry_shd.g_old_rec.pry_attribute2
350       ,p_pry_attribute3_o
351       => ben_pry_shd.g_old_rec.pry_attribute3
352       ,p_pry_attribute4_o
353       => ben_pry_shd.g_old_rec.pry_attribute4
354       ,p_pry_attribute5_o
355       => ben_pry_shd.g_old_rec.pry_attribute5
356       ,p_pry_attribute6_o
357       => ben_pry_shd.g_old_rec.pry_attribute6
358       ,p_pry_attribute7_o
359       => ben_pry_shd.g_old_rec.pry_attribute7
360       ,p_pry_attribute8_o
361       => ben_pry_shd.g_old_rec.pry_attribute8
362       ,p_pry_attribute9_o
363       => ben_pry_shd.g_old_rec.pry_attribute9
364       ,p_pry_attribute10_o
365       => ben_pry_shd.g_old_rec.pry_attribute10
366       ,p_pry_attribute11_o
367       => ben_pry_shd.g_old_rec.pry_attribute11
368       ,p_pry_attribute12_o
369       => ben_pry_shd.g_old_rec.pry_attribute12
370       ,p_pry_attribute13_o
371       => ben_pry_shd.g_old_rec.pry_attribute13
372       ,p_pry_attribute14_o
373       => ben_pry_shd.g_old_rec.pry_attribute14
374       ,p_pry_attribute15_o
375       => ben_pry_shd.g_old_rec.pry_attribute15
376       ,p_pry_attribute16_o
377       => ben_pry_shd.g_old_rec.pry_attribute16
378       ,p_pry_attribute17_o
379       => ben_pry_shd.g_old_rec.pry_attribute17
380       ,p_pry_attribute18_o
381       => ben_pry_shd.g_old_rec.pry_attribute18
382       ,p_pry_attribute19_o
383       => ben_pry_shd.g_old_rec.pry_attribute19
384       ,p_pry_attribute20_o
385       => ben_pry_shd.g_old_rec.pry_attribute20
386       ,p_pry_attribute21_o
387       => ben_pry_shd.g_old_rec.pry_attribute21
388       ,p_pry_attribute22_o
389       => ben_pry_shd.g_old_rec.pry_attribute22
390       ,p_pry_attribute23_o
391       => ben_pry_shd.g_old_rec.pry_attribute23
392       ,p_pry_attribute24_o
393       => ben_pry_shd.g_old_rec.pry_attribute24
394       ,p_pry_attribute25_o
395       => ben_pry_shd.g_old_rec.pry_attribute25
396       ,p_pry_attribute26_o
397       => ben_pry_shd.g_old_rec.pry_attribute26
398       ,p_pry_attribute27_o
399       => ben_pry_shd.g_old_rec.pry_attribute27
400       ,p_pry_attribute28_o
401       => ben_pry_shd.g_old_rec.pry_attribute28
402       ,p_pry_attribute29_o
403       => ben_pry_shd.g_old_rec.pry_attribute29
404       ,p_pry_attribute30_o
405       => ben_pry_shd.g_old_rec.pry_attribute30
406       ,p_object_version_number_o
407       => ben_pry_shd.g_old_rec.object_version_number
408       );
409     --
410   exception
411     --
412     when hr_api.cannot_find_prog_unit then
413       --
414       hr_api.cannot_find_prog_unit_error
415         (p_module_name => 'BEN_PRTT_RMT_APRVD_FR_PYMT_F'
416         ,p_hook_type   => 'AD');
417       --
418   end;
419   --
420   hr_utility.set_location(' Leaving:'||l_proc, 10);
421 End post_delete;
422 --
423 -- ----------------------------------------------------------------------------
424 -- |---------------------------------< del >----------------------------------|
425 -- ----------------------------------------------------------------------------
426 Procedure del
427   (p_effective_date in     date
428   ,p_datetrack_mode in     varchar2
429   ,p_rec            in out nocopy ben_pry_shd.g_rec_type
430   ) is
431 --
432   l_proc                        varchar2(72) := g_package||'del';
433   l_validation_start_date       date;
434   l_validation_end_date         date;
435 --
436 Begin
437   hr_utility.set_location('Entering:'||l_proc, 5);
438   --
439   -- Ensure that the DateTrack delete mode is valid
440   --
441   dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
442   --
443   -- We must lock the row which we need to delete.
444   --
445   ben_pry_shd.lck
446     (p_effective_date                   => p_effective_date
447     ,p_datetrack_mode                   => p_datetrack_mode
448     ,p_prtt_rmt_aprvd_fr_pymt_id        => p_rec.prtt_rmt_aprvd_fr_pymt_id
449     ,p_object_version_number            => p_rec.object_version_number
450     ,p_validation_start_date            => l_validation_start_date
451     ,p_validation_end_date              => l_validation_end_date
452     );
453   --
454   -- Call the supporting delete validate operation
455   --
456   ben_pry_bus.delete_validate
457     (p_rec                              => p_rec
458     ,p_effective_date                   => p_effective_date
459     ,p_datetrack_mode                   => p_datetrack_mode
460     ,p_validation_start_date            => l_validation_start_date
461     ,p_validation_end_date              => l_validation_end_date
462     );
463   --
464   -- Call the supporting pre-delete operation
465   --
466   ben_pry_del.pre_delete
467     (p_rec                              => p_rec
468     ,p_effective_date                   => p_effective_date
469     ,p_datetrack_mode                   => p_datetrack_mode
470     ,p_validation_start_date            => l_validation_start_date
471     ,p_validation_end_date              => l_validation_end_date
472     );
473   --
474   -- Delete the row.
475   --
476   ben_pry_del.delete_dml
477     (p_rec                              => p_rec
478     ,p_effective_date                   => p_effective_date
479     ,p_datetrack_mode                   => p_datetrack_mode
480     ,p_validation_start_date            => l_validation_start_date
481     ,p_validation_end_date              => l_validation_end_date
482     );
483   -- Call the supporting post-delete operation
484   --
485   ben_pry_del.post_delete
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   hr_utility.set_location(' Leaving:'||l_proc, 5);
494 End del;
495 --
496 -- ----------------------------------------------------------------------------
497 -- |--------------------------------< del >-----------------------------------|
498 -- ----------------------------------------------------------------------------
499 Procedure del
500   (p_effective_date                   in     date
501   ,p_datetrack_mode                   in     varchar2
502   ,p_prtt_rmt_aprvd_fr_pymt_id        in     number
503   ,p_object_version_number            in out nocopy number
504   ,p_effective_start_date                out nocopy date
505   ,p_effective_end_date                  out nocopy date
506   ) is
507 --
508   l_rec         ben_pry_shd.g_rec_type;
509   l_proc        varchar2(72) := g_package||'del';
510 --
511 Begin
512   hr_utility.set_location('Entering:'||l_proc, 5);
513   --
514   -- As the delete procedure accepts a plsql record structure we do need to
515   -- convert the  arguments into the record structure.
516   -- We don't need to call the supplied conversion argument routine as we
517   -- only need a few attributes.
518   --
519   l_rec.prtt_rmt_aprvd_fr_pymt_id          := p_prtt_rmt_aprvd_fr_pymt_id;
520   l_rec.object_version_number     := p_object_version_number;
521   --
522   -- Having converted the arguments into the ben_pry_rec
523   -- plsql record structure we must call the corresponding entity
524   -- business process
525   --
526   ben_pry_del.del
527      (p_effective_date
528      ,p_datetrack_mode
529      ,l_rec
530      );
531   --
532   --
533   -- Set the out arguments
534   --
535   p_object_version_number            := l_rec.object_version_number;
536   p_effective_start_date             := l_rec.effective_start_date;
537   p_effective_end_date               := l_rec.effective_end_date;
538   --
539   hr_utility.set_location(' Leaving:'||l_proc, 10);
540 End del;
541 --
542 end ben_pry_del;