DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_APT_DEL

Source


1 Package Body ame_apt_del as
2 /* $Header: amaptrhi.pkb 120.1 2006/04/21 08:44 avarri noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ame_apt_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      ame_apt_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 ame_approver_types
72     where       approver_type_id  =   p_rec.approver_type_id
73     and   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 ame_approver_types
83     where        approver_type_id  =   p_rec.approver_type_id
84     and   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      ame_apt_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   ame_apt_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       ame_apt_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.start_date
169       := ame_apt_shd.g_old_rec.start_date;
170     --
171     If (p_datetrack_mode = hr_api.g_delete) then
175     End If;
172       p_rec.end_date := p_validation_start_date;
173     Else
174       p_rec.end_date := p_validation_end_date;
176     --
177     -- Update the current effective end date record
178     --
179     ame_apt_shd.upd_effective_end_date
180       (p_effective_date            => p_effective_date
181       ,p_approver_type_id          => p_rec.approver_type_id
182       ,p_new_effective_end_date    => p_rec.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.start_date := null;
189     p_rec.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:
220 --   to the dt_delete_dml procedure should NOT be removed.
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
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  ame_apt_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 Begin
238   hr_utility.set_location('Entering:'||l_proc, 5);
239   --
240   --
241   ame_apt_del.dt_pre_delete
242     (p_rec                   => p_rec
243     ,p_effective_date        => p_effective_date
244     ,p_datetrack_mode        => p_datetrack_mode
245     ,p_validation_start_date => p_validation_start_date
246     ,p_validation_end_date   => p_validation_end_date
247     );
248   --
249   hr_utility.set_location(' Leaving:'||l_proc, 10);
250 End pre_delete;
251 --
252 -- ----------------------------------------------------------------------------
253 -- |----------------------------< post_delete >-------------------------------|
254 -- ----------------------------------------------------------------------------
255 -- {Start Of Comments}
256 --
257 -- Description:
258 --   This private procedure contains any processing which is required after
259 --   the delete dml.
260 --
261 -- Prerequisites:
262 --   This is an internal procedure which is called from the del procedure.
263 --
264 -- In Parameters:
265 --   A Pl/Sql record structure.
266 --
267 -- Post Success:
268 --   Processing continues.
269 --
270 -- Post Failure:
271 --   If an error has occurred, an error message and exception will be raised
272 --   but not handled.
273 --
274 -- Developer Implementation Notes:
275 --   Any post-processing required after the delete dml is issued should be
276 --   coded within this procedure. It is important to note that any 3rd party
277 --   maintenance should be reviewed before placing in this procedure.
278 --
279 -- Access Status:
280 --   Internal Row Handler Use Only.
281 --
282 -- {End Of Comments}
283 -- ----------------------------------------------------------------------------
284 Procedure post_delete
285   (p_rec                   in ame_apt_shd.g_rec_type
286   ,p_effective_date        in date
287   ,p_datetrack_mode        in varchar2
288   ,p_validation_start_date in date
289   ,p_validation_end_date   in date
290   ) is
291 --
292   l_proc        varchar2(72) := g_package||'post_delete';
293 --
294 Begin
295   hr_utility.set_location('Entering:'||l_proc, 5);
296    begin
297     --
298     ame_apt_rkd.after_delete
299       (p_effective_date                    => p_effective_date
300       ,p_datetrack_mode                    => p_datetrack_mode
301       ,p_validation_start_date             => p_validation_start_date
302       ,p_validation_end_date               => p_validation_end_date
303       ,p_approver_type_id                  => p_rec.approver_type_id
304       ,p_start_date                        => p_rec.start_date
305       ,p_end_date                          => p_rec.end_date
306       ,p_orig_system_o                     => ame_apt_shd.g_old_rec.orig_system
307       ,p_query_variable_1_label_o          => ame_apt_shd.g_old_rec.query_variable_1_label
308       ,p_query_variable_2_label_o          => ame_apt_shd.g_old_rec.query_variable_2_label
309       ,p_query_variable_3_label_o          => ame_apt_shd.g_old_rec.query_variable_3_label
310       ,p_query_variable_4_label_o          => ame_apt_shd.g_old_rec.query_variable_4_label
311       ,p_query_variable_5_label_o          => ame_apt_shd.g_old_rec.query_variable_5_label
312       ,p_variable_1_lov_query_o            => ame_apt_shd.g_old_rec.variable_1_lov_query
313       ,p_variable_2_lov_query_o            => ame_apt_shd.g_old_rec.variable_2_lov_query
314       ,p_variable_3_lov_query_o            => ame_apt_shd.g_old_rec.variable_3_lov_query
315       ,p_variable_4_lov_query_o            => ame_apt_shd.g_old_rec.variable_4_lov_query
316       ,p_variable_5_lov_query_o            => ame_apt_shd.g_old_rec.variable_5_lov_query
317       ,p_query_procedure_o                 => ame_apt_shd.g_old_rec.query_procedure
318       ,p_start_date_o                      => ame_apt_shd.g_old_rec.start_date
319       ,p_end_date_o                        => ame_apt_shd.g_old_rec.end_date
320       ,p_object_version_number_o           => ame_apt_shd.g_old_rec.object_version_number
321       );
322     --
323   exception
324     --
325     when hr_api.cannot_find_prog_unit then
326       --
327       hr_api.cannot_find_prog_unit_error
328         (p_module_name => 'ame_approver_types'
332   --
329         ,p_hook_type   => 'AD');
330       --
331   end;
333   hr_utility.set_location(' Leaving:'||l_proc, 10);
334 End post_delete;
335 --
336 -- ----------------------------------------------------------------------------
337 -- |---------------------------------< del >----------------------------------|
338 -- ----------------------------------------------------------------------------
339 Procedure del
340   (p_effective_date in                   date
341   ,p_datetrack_mode in                   varchar2
342   ,p_rec            in out nocopy        ame_apt_shd.g_rec_type
343   ) is
344 --
345   l_proc                        varchar2(72) := g_package||'del';
346   l_validation_start_date       date;
347   l_validation_end_date         date;
348 --
349 Begin
350   hr_utility.set_location('Entering:'||l_proc, 5);
351   --
352   -- Ensure that the DateTrack delete mode is valid
353   --
354   dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
355   --
356   -- We must lock the row which we need to delete.
357   --
358   ame_apt_shd.lck
359     (p_effective_date                   => p_effective_date
363     ,p_object_version_number            => p_rec.object_version_number
360     ,p_datetrack_mode                   => p_datetrack_mode
361     ,p_approver_type_id                 => p_rec.approver_type_id
362     ,p_orig_system                      => p_rec.orig_system
364     ,p_validation_start_date            => l_validation_start_date
365     ,p_validation_end_date              => l_validation_end_date
366     );
367   --
368   -- Call the supporting delete validate operation
369   --
370   ame_apt_bus.delete_validate
371     (p_rec                              => p_rec
372     ,p_effective_date                   => p_effective_date
373     ,p_datetrack_mode                   => p_datetrack_mode
374     ,p_validation_start_date            => l_validation_start_date
375     ,p_validation_end_date              => l_validation_end_date
376     );
377   --
378   -- Call to raise any errors on multi-message list
379   hr_multi_message.end_validation_set;
380   --
381   -- Call the supporting pre-delete operation
382   --
383   ame_apt_del.pre_delete
384     (p_rec                              => p_rec
385     ,p_effective_date                   => p_effective_date
386     ,p_datetrack_mode                   => p_datetrack_mode
387     ,p_validation_start_date            => l_validation_start_date
388     ,p_validation_end_date              => l_validation_end_date
389     );
390   --
391   -- Delete the row.
392   --
393   ame_apt_del.delete_dml
394     (p_rec                              => p_rec
395     ,p_effective_date                   => p_effective_date
396     ,p_datetrack_mode                   => p_datetrack_mode
397     ,p_validation_start_date            => l_validation_start_date
398     ,p_validation_end_date              => l_validation_end_date
399     );
400   -- Call the supporting post-delete operation
401   --
402   ame_apt_del.post_delete
403     (p_rec                              => p_rec
404     ,p_effective_date                   => p_effective_date
405     ,p_datetrack_mode                   => p_datetrack_mode
406     ,p_validation_start_date            => l_validation_start_date
407     ,p_validation_end_date              => l_validation_end_date
408     );
409   --
410   -- Call to raise any errors on multi-message list
411   hr_multi_message.end_validation_set;
412   --
413   hr_utility.set_location(' Leaving:'||l_proc, 5);
414 End del;
415 --
416 -- ----------------------------------------------------------------------------
417 -- |--------------------------------< del >-----------------------------------|
418 -- ----------------------------------------------------------------------------
419 Procedure del
420   (p_effective_date                   in                date
421   ,p_datetrack_mode                   in                varchar2
422   ,p_approver_type_id                 in                number
423   ,p_object_version_number            in out nocopy     number
424   ,p_start_date                          out nocopy     date
425   ,p_end_date                            out nocopy     date
426   ) is
427 --
428   l_rec         ame_apt_shd.g_rec_type;
429   l_proc        varchar2(72) := g_package||'del';
430 --
431 Begin
432   hr_utility.set_location('Entering:'||l_proc, 5);
433   --
434   -- As the delete procedure accepts a plsql record structure we do need to
435   -- convert the  arguments into the record structure.
436   -- We don't need to call the supplied conversion argument routine as we
437   -- only need a few attributes.
438   --
439  l_rec.approver_type_id       := p_approver_type_id;
440  l_rec.start_date             := p_start_date;
441  l_rec.end_date               := p_end_date;
442  l_rec.object_version_number  := p_object_version_number;
443   -- Having converted the arguments into the ame_apt_rec
444   -- plsql record structure we must call the corresponding entity
445   -- business process
446   --
447   ame_apt_del.del
448      (p_effective_date
449      ,p_datetrack_mode
450      ,l_rec
451      );
452   --
453   --
454   -- Set the out arguments
455   --
456   p_object_version_number  := l_rec.object_version_number;
457   p_start_date             := l_rec.start_date;
458   p_end_date               := l_rec.end_date;
459   --
460   hr_utility.set_location(' Leaving:'||l_proc, 10);
461 End del;
462 --
463 end ame_apt_del;