DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_JRT_DEL

Source


1 Package Body ben_jrt_del as
2 /* $Header: bejrtrhi.pkb 120.2 2006/03/30 23:48:52 gsehgal noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ben_jrt_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 ben_jrt_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     --
67     --
68     -- Delete the where the effective start date is equal
69     -- to the validation end date.
70     --
71     delete from ben_job_rt_f
72     where       job_rt_id = p_rec.job_rt_id
73     and   effective_start_date = p_validation_start_date;
74     --
75     --
76   Else
77     --
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_job_rt_f
83     where        job_rt_id = p_rec.job_rt_id
84     and   effective_start_date >= p_validation_start_date;
85     --
86     --
87   End If;
88   --
89   hr_utility.set_location(' Leaving:'||l_proc, 20);
90 --
91 End dt_delete_dml;
92 --
93 -- ----------------------------------------------------------------------------
94 -- |------------------------------< delete_dml >------------------------------|
95 -- ----------------------------------------------------------------------------
96 Procedure delete_dml
97   (p_rec                     in out nocopy ben_jrt_shd.g_rec_type
98   ,p_effective_date          in date
99   ,p_datetrack_mode          in varchar2
100   ,p_validation_start_date   in date
101   ,p_validation_end_date     in date
102   ) is
103 --
104   l_proc        varchar2(72) := g_package||'delete_dml';
105 --
106 Begin
107   hr_utility.set_location('Entering:'||l_proc, 5);
108   --
109   ben_jrt_del.dt_delete_dml
110     (p_rec                   => p_rec
111     ,p_effective_date        => p_effective_date
112     ,p_datetrack_mode        => p_datetrack_mode
113     ,p_validation_start_date => p_validation_start_date
114     ,p_validation_end_date   => p_validation_end_date
115     );
116   --
117   hr_utility.set_location(' Leaving:'||l_proc, 10);
118 End delete_dml;
119 --
120 -- ----------------------------------------------------------------------------
121 -- |----------------------------< dt_pre_delete >-----------------------------|
122 -- ----------------------------------------------------------------------------
123 -- {Start Of Comments}
124 --
125 -- Description:
126 --   The dt_pre_delete process controls the execution of dml
127 --   for the datetrack modes: DELETE, FUTURE_CHANGE
128 --   and DELETE_NEXT_CHANGE only.
129 --
130 -- Prerequisites:
131 --   This is an internal procedure which is called from the pre_delete
132 --   procedure.
133 --
134 -- In Parameters:
135 --   A Pl/Sql record structure.
136 --
137 -- Post Success:
138 --   Processing continues.
139 --
140 -- Post Failure:
141 --   If an error has occurred, an error message and exception will be raised
142 --   but not handled.
143 --
144 -- Developer Implementation Notes:
145 --   This is an internal procedure which is required by Datetrack. Don't
146 --   remove or modify.
147 --
148 -- Access Status:
149 --   Internal Row Handler Use Only.
150 --
151 -- {End Of Comments}
152 -- ----------------------------------------------------------------------------
153 Procedure dt_pre_delete
154   (p_rec                     in out nocopy ben_jrt_shd.g_rec_type
155   ,p_effective_date          in date
156   ,p_datetrack_mode          in varchar2
157   ,p_validation_start_date   in date
158   ,p_validation_end_date     in date
159   ) is
160 --
161   l_proc        varchar2(72) := g_package||'dt_pre_delete';
162 --
163 Begin
164   hr_utility.set_location('Entering:'||l_proc, 5);
165   --
166   If (p_datetrack_mode <> hr_api.g_zap) then
167     --
168     p_rec.effective_start_date
169       := ben_jrt_shd.g_old_rec.effective_start_date;
170     --
171     If (p_datetrack_mode = hr_api.g_delete) then
172       p_rec.effective_end_date := p_validation_start_date - 1;
173     Else
174       p_rec.effective_end_date := p_validation_end_date;
175     End If;
176     --
177     -- Update the current effective end date record
178     --
179     ben_jrt_shd.upd_effective_end_date
180       (p_effective_date         => p_effective_date
181       ,p_base_key_value         => p_rec.job_rt_id
182       ,p_new_effective_end_date => p_rec.effective_end_date
183       ,p_validation_start_date  => p_validation_start_date
184       ,p_validation_end_date    => p_validation_end_date
185       ,p_object_version_number            => p_rec.object_version_number
186       );
187   Else
188     p_rec.effective_start_date := null;
189     p_rec.effective_end_date   := null;
190   End If;
191   hr_utility.set_location(' Leaving:'||l_proc, 10);
192 End dt_pre_delete;
193 --
194 -- ----------------------------------------------------------------------------
195 -- |------------------------------< pre_delete >------------------------------|
196 -- ----------------------------------------------------------------------------
197 -- {Start Of Comments}
198 --
199 -- Description:
200 --   This private procedure contains any processing which is required before
201 --   the delete dml.
202 --
203 -- Prerequisites:
204 --   This is an internal procedure which is called from the del procedure.
205 --
206 -- In Parameters:
207 --   A Pl/Sql record structure.
208 --
209 -- Post Success:
210 --   Processing continues.
211 --
212 -- Post Failure:
213 --   If an error has occurred, an error message and exception will be raised
214 --   but not handled.
215 --
216 -- Developer Implementation Notes:
217 --   Any pre-processing required before the delete dml is issued should be
218 --   coded within this procedure. It is important to note that any 3rd party
219 --   maintenance should be reviewed before placing in this procedure. The call
220 --   to the dt_delete_dml procedure should NOT be removed.
221 --
222 -- Access Status:
223 --   Internal Row Handler Use Only.
224 --
225 -- {End Of Comments}
226 -- ----------------------------------------------------------------------------
227 Procedure pre_delete
228   (p_rec                   in out nocopy ben_jrt_shd.g_rec_type
229   ,p_effective_date        in date
230   ,p_datetrack_mode        in varchar2
231   ,p_validation_start_date in date
232   ,p_validation_end_date   in date
233   ) is
234 --
235   l_proc        varchar2(72) := g_package||'pre_delete';
236 --
237   --
238 --
239 Begin
240   hr_utility.set_location('Entering:'||l_proc, 5);
241   --
242 --
243   --
244   ben_jrt_del.dt_pre_delete
245     (p_rec                   => p_rec
246     ,p_effective_date        => p_effective_date
247     ,p_datetrack_mode        => p_datetrack_mode
248     ,p_validation_start_date => p_validation_start_date
249     ,p_validation_end_date   => p_validation_end_date
250     );
251   --
252   hr_utility.set_location(' Leaving:'||l_proc, 10);
253 End pre_delete;
254 --
255 -- ----------------------------------------------------------------------------
256 -- |----------------------------< post_delete >-------------------------------|
257 -- ----------------------------------------------------------------------------
258 -- {Start Of Comments}
259 --
260 -- Description:
261 --   This private procedure contains any processing which is required after
262 --   the delete dml.
263 --
264 -- Prerequisites:
265 --   This is an internal procedure which is called from the del procedure.
266 --
267 -- In Parameters:
268 --   A Pl/Sql record structure.
269 --
270 -- Post Success:
271 --   Processing continues.
272 --
273 -- Post Failure:
274 --   If an error has occurred, an error message and exception will be raised
275 --   but not handled.
276 --
277 -- Developer Implementation Notes:
278 --   Any post-processing required after the delete dml is issued should be
279 --   coded within this procedure. It is important to note that any 3rd party
280 --   maintenance should be reviewed before placing in this procedure.
281 --
282 -- Access Status:
283 --   Internal Row Handler Use Only.
284 --
285 -- {End Of Comments}
286 -- ----------------------------------------------------------------------------
287 Procedure post_delete
288   (p_rec                   in ben_jrt_shd.g_rec_type
289   ,p_effective_date        in date
290   ,p_datetrack_mode        in varchar2
291   ,p_validation_start_date in date
292   ,p_validation_end_date   in date
293   ) is
294 --
295   l_proc        varchar2(72) := g_package||'post_delete';
296 --
297 Begin
298   hr_utility.set_location('Entering:'||l_proc, 5);
299    begin
300     --
301     ben_jrt_rkd.after_delete
302       (p_effective_date
303       => p_effective_date
304       ,p_datetrack_mode
305       => p_datetrack_mode
306       ,p_validation_start_date
307       => p_validation_start_date
308       ,p_validation_end_date
309       => p_validation_end_date
310       ,p_job_rt_id
311       => p_rec.job_rt_id
312       ,p_effective_start_date
313       => p_rec.effective_start_date
314       ,p_effective_end_date
315       => p_rec.effective_end_date
316       ,p_effective_start_date_o
317       => ben_jrt_shd.g_old_rec.effective_start_date
318       ,p_effective_end_date_o
319       => ben_jrt_shd.g_old_rec.effective_end_date
320       ,p_job_id_o
321       => ben_jrt_shd.g_old_rec.job_id
322       ,p_excld_flag_o
323       => ben_jrt_shd.g_old_rec.excld_flag
324       ,p_business_group_id_o
325       => ben_jrt_shd.g_old_rec.business_group_id
326       ,p_vrbl_rt_prfl_id_o
327       => ben_jrt_shd.g_old_rec.vrbl_rt_prfl_id
328       ,p_object_version_number_o
329       => ben_jrt_shd.g_old_rec.object_version_number
330       ,p_ordr_num_o
331       => ben_jrt_shd.g_old_rec.ordr_num
332       ,p_jrt_attribute_category_o
333       => ben_jrt_shd.g_old_rec.jrt_attribute_category
334       ,p_jrt_attribute1_o
335       => ben_jrt_shd.g_old_rec.jrt_attribute1
336       ,p_jrt_attribute2_o
337       => ben_jrt_shd.g_old_rec.jrt_attribute2
338       ,p_jrt_attribute3_o
339       => ben_jrt_shd.g_old_rec.jrt_attribute3
340       ,p_jrt_attribute4_o
341       => ben_jrt_shd.g_old_rec.jrt_attribute4
342       ,p_jrt_attribute5_o
343       => ben_jrt_shd.g_old_rec.jrt_attribute5
344       ,p_jrt_attribute6_o
345       => ben_jrt_shd.g_old_rec.jrt_attribute6
346       ,p_jrt_attribute7_o
347       => ben_jrt_shd.g_old_rec.jrt_attribute7
348       ,p_jrt_attribute8_o
349       => ben_jrt_shd.g_old_rec.jrt_attribute8
350       ,p_jrt_attribute9_o
351       => ben_jrt_shd.g_old_rec.jrt_attribute9
352       ,p_jrt_attribute10_o
353       => ben_jrt_shd.g_old_rec.jrt_attribute10
354       ,p_jrt_attribute11_o
355       => ben_jrt_shd.g_old_rec.jrt_attribute11
356       ,p_jrt_attribute12_o
357       => ben_jrt_shd.g_old_rec.jrt_attribute12
358       ,p_jrt_attribute13_o
359       => ben_jrt_shd.g_old_rec.jrt_attribute13
360       ,p_jrt_attribute14_o
361       => ben_jrt_shd.g_old_rec.jrt_attribute14
362       ,p_jrt_attribute15_o
363       => ben_jrt_shd.g_old_rec.jrt_attribute15
364       ,p_jrt_attribute16_o
365       => ben_jrt_shd.g_old_rec.jrt_attribute16
366       ,p_jrt_attribute17_o
367       => ben_jrt_shd.g_old_rec.jrt_attribute17
368       ,p_jrt_attribute18_o
369       => ben_jrt_shd.g_old_rec.jrt_attribute18
370       ,p_jrt_attribute19_o
371       => ben_jrt_shd.g_old_rec.jrt_attribute19
372       ,p_jrt_attribute20_o
373       => ben_jrt_shd.g_old_rec.jrt_attribute20
374       ,p_jrt_attribute21_o
375       => ben_jrt_shd.g_old_rec.jrt_attribute21
376       ,p_jrt_attribute22_o
377       => ben_jrt_shd.g_old_rec.jrt_attribute22
378       ,p_jrt_attribute23_o
379       => ben_jrt_shd.g_old_rec.jrt_attribute23
380       ,p_jrt_attribute24_o
381       => ben_jrt_shd.g_old_rec.jrt_attribute24
382       ,p_jrt_attribute25_o
383       => ben_jrt_shd.g_old_rec.jrt_attribute25
384       ,p_jrt_attribute26_o
385       => ben_jrt_shd.g_old_rec.jrt_attribute26
386       ,p_jrt_attribute27_o
387       => ben_jrt_shd.g_old_rec.jrt_attribute27
388       ,p_jrt_attribute28_o
389       => ben_jrt_shd.g_old_rec.jrt_attribute28
390       ,p_jrt_attribute29_o
391       => ben_jrt_shd.g_old_rec.jrt_attribute29
392       ,p_jrt_attribute30_o
393       => ben_jrt_shd.g_old_rec.jrt_attribute30
394       );
395     --
396   exception
397     --
398     when hr_api.cannot_find_prog_unit then
399       --
400       hr_api.cannot_find_prog_unit_error
401         (p_module_name => 'BEN_JOB_RT_F'
402         ,p_hook_type   => 'AD');
403       --
404   end;
405   --
406   hr_utility.set_location(' Leaving:'||l_proc, 10);
407 End post_delete;
408 --
409 -- ----------------------------------------------------------------------------
410 -- |---------------------------------< del >----------------------------------|
411 -- ----------------------------------------------------------------------------
412 Procedure del
413   (p_effective_date in     date
414   ,p_datetrack_mode in     varchar2
415   ,p_rec            in out nocopy ben_jrt_shd.g_rec_type
416   ) is
417 --
418   l_proc                        varchar2(72) := g_package||'del';
419   l_validation_start_date       date;
420   l_validation_end_date         date;
421 --
422 Begin
423   hr_utility.set_location('Entering:'||l_proc, 5);
424   --
425   -- Ensure that the DateTrack delete mode is valid
426   --
427   dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
428   --
429   -- We must lock the row which we need to delete.
430   --
431   ben_jrt_shd.lck
432     (p_effective_date                   => p_effective_date
433     ,p_datetrack_mode                   => p_datetrack_mode
434     ,p_job_rt_id                        => p_rec.job_rt_id
435     ,p_object_version_number            => p_rec.object_version_number
436     ,p_validation_start_date            => l_validation_start_date
437     ,p_validation_end_date              => l_validation_end_date
438     );
439   --
440   -- Call the supporting delete validate operation
441   --
442   ben_jrt_bus.delete_validate
443     (p_rec                              => p_rec
444     ,p_effective_date                   => p_effective_date
445     ,p_datetrack_mode                   => p_datetrack_mode
446     ,p_validation_start_date            => l_validation_start_date
447     ,p_validation_end_date              => l_validation_end_date
448     );
449   --
450   -- Call to raise any errors on multi-message list
451   hr_multi_message.end_validation_set;
452   --
453   -- Call the supporting pre-delete operation
454   --
455   ben_jrt_del.pre_delete
456     (p_rec                              => p_rec
457     ,p_effective_date                   => p_effective_date
458     ,p_datetrack_mode                   => p_datetrack_mode
459     ,p_validation_start_date            => l_validation_start_date
460     ,p_validation_end_date              => l_validation_end_date
461     );
462   --
463   -- Delete the row.
464   --
465   ben_jrt_del.delete_dml
466     (p_rec                              => p_rec
467     ,p_effective_date                   => p_effective_date
468     ,p_datetrack_mode                   => p_datetrack_mode
469     ,p_validation_start_date            => l_validation_start_date
470     ,p_validation_end_date              => l_validation_end_date
471     );
472   -- Call the supporting post-delete operation
473   --
474   ben_jrt_del.post_delete
475     (p_rec                              => p_rec
476     ,p_effective_date                   => p_effective_date
477     ,p_datetrack_mode                   => p_datetrack_mode
478     ,p_validation_start_date            => l_validation_start_date
479     ,p_validation_end_date              => l_validation_end_date
480     );
481   --
482   -- Call to raise any errors on multi-message list
483   hr_multi_message.end_validation_set;
484   --
485   hr_utility.set_location(' Leaving:'||l_proc, 5);
486 End del;
487 --
488 -- ----------------------------------------------------------------------------
489 -- |--------------------------------< del >-----------------------------------|
490 -- ----------------------------------------------------------------------------
491 Procedure del
492   (p_effective_date                   in     date
493   ,p_datetrack_mode                   in     varchar2
494   ,p_job_rt_id                        in     number
495   ,p_object_version_number            in out nocopy number
496   ,p_effective_start_date                out nocopy date
497   ,p_effective_end_date                  out nocopy date
498   ) is
499 --
500   l_rec         ben_jrt_shd.g_rec_type;
501   l_proc        varchar2(72) := g_package||'del';
502 --
503 Begin
504   hr_utility.set_location('Entering:'||l_proc, 5);
505   --
506   -- As the delete procedure accepts a plsql record structure we do need to
507   -- convert the  arguments into the record structure.
508   -- We don't need to call the supplied conversion argument routine as we
509   -- only need a few attributes.
510   --
511   l_rec.job_rt_id          := p_job_rt_id;
512   l_rec.object_version_number     := p_object_version_number;
513   --
514   -- Having converted the arguments into the ben_jrt_rec
515   -- plsql record structure we must call the corresponding entity
516   -- business process
517   --
518   ben_jrt_del.del
519      (p_effective_date
520      ,p_datetrack_mode
521      ,l_rec
522      );
523   --
524   --
525   -- Set the out arguments
526   --
527   p_object_version_number            := l_rec.object_version_number;
528   p_effective_start_date             := l_rec.effective_start_date;
529   p_effective_end_date               := l_rec.effective_end_date;
530   --
531   hr_utility.set_location(' Leaving:'||l_proc, 10);
532 End del;
533 --
534 end ben_jrt_del;