DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_ECU_DEL

Source


1 Package Body pay_ecu_del as
2 /* $Header: pyecurhi.pkb 120.2 2006/02/06 05:37 pgongada noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_ecu_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_ecu_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 pay_element_class_usages_f
72     where       element_class_usage_id = p_rec.element_class_usage_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 pay_element_class_usages_f
83     where        element_class_usage_id = p_rec.element_class_usage_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_app_ownerships >----------------------------|
95 -- ----------------------------------------------------------------------------
96 --
97 -- Description:
98 --   Deletes row(s) from hr_application_ownerships depending on the mode that
99 --   the row handler has been called in.
100 --
101 -- ----------------------------------------------------------------------------
102 PROCEDURE delete_app_ownerships(p_pk_column  IN  varchar2
103                                ,p_pk_value   IN  varchar2
104                                ,p_datetrack_mode IN varchar2) IS
105 --
106 BEGIN
107   --
108   IF ((hr_startup_data_api_support.return_startup_mode
109                            IN ('STARTUP','GENERIC')) AND
110       p_datetrack_mode = 'ZAP') THEN
111      --
112      DELETE FROM hr_application_ownerships
113       WHERE key_name = p_pk_column
114         AND key_value = p_pk_value;
115      --
116   END IF;
117 END delete_app_ownerships;
118 --
119 -- ----------------------------------------------------------------------------
120 -- ----------------------< delete_app_ownerships >----------------------------|
121 -- ----------------------------------------------------------------------------
122 PROCEDURE delete_app_ownerships(p_pk_column IN varchar2
123                                ,p_pk_value  IN number
124                                ,p_datetrack_mode IN varchar2) IS
125 --
126 BEGIN
127   delete_app_ownerships(p_pk_column,
128                         to_char(p_pk_value),
129                         p_datetrack_mode
130                        );
131 END delete_app_ownerships;
132 --
133 -- ----------------------------------------------------------------------------
134 -- |------------------------------< delete_dml >------------------------------|
135 -- ----------------------------------------------------------------------------
136 Procedure delete_dml
137   (p_rec                     in out nocopy pay_ecu_shd.g_rec_type
138   ,p_effective_date          in date
139   ,p_datetrack_mode          in varchar2
140   ,p_validation_start_date   in date
141   ,p_validation_end_date     in date
142   ) is
143 --
144   l_proc        varchar2(72) := g_package||'delete_dml';
145 --
146 Begin
147   hr_utility.set_location('Entering:'||l_proc, 5);
148   --
149   pay_ecu_del.dt_delete_dml
150     (p_rec                   => p_rec
151     ,p_effective_date        => p_effective_date
152     ,p_datetrack_mode        => p_datetrack_mode
153     ,p_validation_start_date => p_validation_start_date
154     ,p_validation_end_date   => p_validation_end_date
155     );
156   --
157   hr_utility.set_location(' Leaving:'||l_proc, 10);
158 End delete_dml;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |----------------------------< dt_pre_delete >-----------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 --   The dt_pre_delete process controls the execution of dml
167 --   for the datetrack modes: DELETE, FUTURE_CHANGE
168 --   and DELETE_NEXT_CHANGE only.
169 --
170 -- Prerequisites:
171 --   This is an internal procedure which is called from the pre_delete
172 --   procedure.
173 --
174 -- In Parameters:
175 --   A Pl/Sql record structure.
176 --
177 -- Post Success:
178 --   Processing continues.
179 --
180 -- Post Failure:
181 --   If an error has occurred, an error message and exception will be raised
182 --   but not handled.
183 --
184 -- Developer Implementation Notes:
185 --   This is an internal procedure which is required by Datetrack. Don't
186 --   remove or modify.
187 --
188 -- Access Status:
189 --   Internal Row Handler Use Only.
190 --
191 -- {End Of Comments}
192 -- ----------------------------------------------------------------------------
193 Procedure dt_pre_delete
194   (p_rec                     in out nocopy pay_ecu_shd.g_rec_type
195   ,p_effective_date          in date
196   ,p_datetrack_mode          in varchar2
197   ,p_validation_start_date   in date
198   ,p_validation_end_date     in date
199   ) is
200 --
201   l_proc        varchar2(72) := g_package||'dt_pre_delete';
202 --
203 Begin
204   hr_utility.set_location('Entering:'||l_proc, 5);
205   --
206   If (p_datetrack_mode <> hr_api.g_zap) then
207     --
208     p_rec.effective_start_date
209       := pay_ecu_shd.g_old_rec.effective_start_date;
210     --
211     If (p_datetrack_mode = hr_api.g_delete) then
212       p_rec.effective_end_date := p_validation_start_date - 1;
213     Else
214       p_rec.effective_end_date := p_validation_end_date;
215     End If;
216     --
217     -- Update the current effective end date record
218     --
219     pay_ecu_shd.upd_effective_end_date
220       (p_effective_date         => p_effective_date
221       ,p_base_key_value         => p_rec.element_class_usage_id
222       ,p_new_effective_end_date => p_rec.effective_end_date
223       ,p_validation_start_date  => p_validation_start_date
224       ,p_validation_end_date    => p_validation_end_date
225       ,p_object_version_number            => p_rec.object_version_number
226       );
227   Else
228     p_rec.effective_start_date := null;
229     p_rec.effective_end_date   := null;
230   End If;
231   hr_utility.set_location(' Leaving:'||l_proc, 10);
232 End dt_pre_delete;
233 --
234 -- ----------------------------------------------------------------------------
235 -- |------------------------------< pre_delete >------------------------------|
236 -- ----------------------------------------------------------------------------
237 -- {Start Of Comments}
238 --
239 -- Description:
240 --   This private procedure contains any processing which is required before
241 --   the delete dml.
242 --
243 -- Prerequisites:
244 --   This is an internal procedure which is called from the del procedure.
245 --
246 -- In Parameters:
247 --   A Pl/Sql record structure.
248 --
249 -- Post Success:
250 --   Processing continues.
251 --
252 -- Post Failure:
253 --   If an error has occurred, an error message and exception will be raised
254 --   but not handled.
255 --
256 -- Developer Implementation Notes:
257 --   Any pre-processing required before the delete dml is issued should be
258 --   coded within this procedure. It is important to note that any 3rd party
259 --   maintenance should be reviewed before placing in this procedure. The call
260 --   to the dt_delete_dml procedure should NOT be removed.
261 --
262 -- Access Status:
263 --   Internal Row Handler Use Only.
264 --
265 -- {End Of Comments}
266 -- ----------------------------------------------------------------------------
267 Procedure pre_delete
268   (p_rec                   in out nocopy pay_ecu_shd.g_rec_type
269   ,p_effective_date        in date
270   ,p_datetrack_mode        in varchar2
271   ,p_validation_start_date in date
272   ,p_validation_end_date   in date
273   ) is
274 --
275   l_proc        varchar2(72) := g_package||'pre_delete';
276 --
277   --
278 --
279 Begin
280   hr_utility.set_location('Entering:'||l_proc, 5);
281   --
282 --
283   --
284   pay_ecu_del.dt_pre_delete
285     (p_rec                   => p_rec
286     ,p_effective_date        => p_effective_date
287     ,p_datetrack_mode        => p_datetrack_mode
288     ,p_validation_start_date => p_validation_start_date
289     ,p_validation_end_date   => p_validation_end_date
290     );
291   --
292   hr_utility.set_location(' Leaving:'||l_proc, 10);
293 End pre_delete;
294 --
295 -- ----------------------------------------------------------------------------
296 -- |----------------------------< post_delete >-------------------------------|
297 -- ----------------------------------------------------------------------------
298 -- {Start Of Comments}
299 --
300 -- Description:
301 --   This private procedure contains any processing which is required after
302 --   the delete dml.
303 --
304 -- Prerequisites:
305 --   This is an internal procedure which is called from the del procedure.
306 --
307 -- In Parameters:
308 --   A Pl/Sql record structure.
309 --
310 -- Post Success:
311 --   Processing continues.
312 --
313 -- Post Failure:
314 --   If an error has occurred, an error message and exception will be raised
315 --   but not handled.
316 --
317 -- Developer Implementation Notes:
318 --   Any post-processing required after the delete dml is issued should be
319 --   coded within this procedure. It is important to note that any 3rd party
320 --   maintenance should be reviewed before placing in this procedure.
321 --
322 -- Access Status:
323 --   Internal Row Handler Use Only.
324 --
325 -- {End Of Comments}
326 -- ----------------------------------------------------------------------------
327 Procedure post_delete
328   (p_rec                   in pay_ecu_shd.g_rec_type
329   ,p_effective_date        in date
330   ,p_datetrack_mode        in varchar2
331   ,p_validation_start_date in date
332   ,p_validation_end_date   in date
333   ) is
334 --
335   l_proc        varchar2(72) := g_package||'post_delete';
336 --
337 Begin
338   hr_utility.set_location('Entering:'||l_proc, 5);
339    begin
340       --
341     -- Delete ownerships if applicable
342     delete_app_ownerships
343       ('ELEMENT_CLASS_USAGE_ID', p_rec.element_class_usage_id
344       ,p_datetrack_mode
345       );
346     --
347     pay_ecu_rkd.after_delete
348       (p_effective_date
352       ,p_validation_start_date
349       => p_effective_date
350       ,p_datetrack_mode
351       => p_datetrack_mode
353       => p_validation_start_date
354       ,p_validation_end_date
355       => p_validation_end_date
356       ,p_element_class_usage_id
357       => p_rec.element_class_usage_id
358       ,p_effective_start_date
359       => p_rec.effective_start_date
360       ,p_effective_end_date
361       => p_rec.effective_end_date
362       ,p_effective_start_date_o
363       => pay_ecu_shd.g_old_rec.effective_start_date
364       ,p_effective_end_date_o
365       => pay_ecu_shd.g_old_rec.effective_end_date
366       ,p_run_type_id_o
367       => pay_ecu_shd.g_old_rec.run_type_id
368       ,p_classification_id_o
369       => pay_ecu_shd.g_old_rec.classification_id
370       ,p_business_group_id_o
371       => pay_ecu_shd.g_old_rec.business_group_id
372       ,p_legislation_code_o
373       => pay_ecu_shd.g_old_rec.legislation_code
374       ,p_object_version_number_o
375       => pay_ecu_shd.g_old_rec.object_version_number
376       );
377     --
378   exception
379     --
380     when hr_api.cannot_find_prog_unit then
381       --
382       hr_api.cannot_find_prog_unit_error
383         (p_module_name => 'PAY_ELEMENT_CLASS_USAGES_F'
384         ,p_hook_type   => 'AD');
385       --
386   end;
387   --
388   hr_utility.set_location(' Leaving:'||l_proc, 10);
389 End post_delete;
390 --
391 -- ----------------------------------------------------------------------------
392 -- |---------------------------------< del >----------------------------------|
393 -- ----------------------------------------------------------------------------
394 Procedure del
395   (p_effective_date in     date
396   ,p_datetrack_mode in     varchar2
397   ,p_rec            in out nocopy pay_ecu_shd.g_rec_type
398   ) is
399 --
400   l_proc                        varchar2(72) := g_package||'del';
401   l_validation_start_date       date;
402   l_validation_end_date         date;
403 --
404 Begin
405   hr_utility.set_location('Entering:'||l_proc, 5);
406   --
407   -- Ensure that the DateTrack delete mode is valid
408   --
409   dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
410   --
411   -- We must lock the row which we need to delete.
412   --
413   pay_ecu_shd.lck
414     (p_effective_date                   => p_effective_date
415     ,p_datetrack_mode                   => p_datetrack_mode
416     ,p_element_class_usage_id           => p_rec.element_class_usage_id
417     ,p_object_version_number            => p_rec.object_version_number
418     ,p_validation_start_date            => l_validation_start_date
419     ,p_validation_end_date              => l_validation_end_date
420     );
421   --
422   -- Call the supporting delete validate operation
423   --
424   pay_ecu_bus.delete_validate
425     (p_rec                              => p_rec
426     ,p_effective_date                   => p_effective_date
427     ,p_datetrack_mode                   => p_datetrack_mode
428     ,p_validation_start_date            => l_validation_start_date
429     ,p_validation_end_date              => l_validation_end_date
430     );
431   --
432   -- Call to raise any errors on multi-message list
433   hr_multi_message.end_validation_set;
434   --
435   -- Call the supporting pre-delete operation
436   --
437   pay_ecu_del.pre_delete
438     (p_rec                              => p_rec
439     ,p_effective_date                   => p_effective_date
440     ,p_datetrack_mode                   => p_datetrack_mode
441     ,p_validation_start_date            => l_validation_start_date
442     ,p_validation_end_date              => l_validation_end_date
443     );
444   --
445   -- Delete the row.
446   --
447   pay_ecu_del.delete_dml
448     (p_rec                              => p_rec
449     ,p_effective_date                   => p_effective_date
450     ,p_datetrack_mode                   => p_datetrack_mode
451     ,p_validation_start_date            => l_validation_start_date
452     ,p_validation_end_date              => l_validation_end_date
453     );
454   -- Call the supporting post-delete operation
455   --
456   pay_ecu_del.post_delete
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 to raise any errors on multi-message list
465   hr_multi_message.end_validation_set;
466   --
467   hr_utility.set_location(' Leaving:'||l_proc, 5);
468 End del;
469 --
470 -- ----------------------------------------------------------------------------
471 -- |--------------------------------< del >-----------------------------------|
472 -- ----------------------------------------------------------------------------
473 Procedure del
474   (p_effective_date                   in     date
475   ,p_datetrack_mode                   in     varchar2
476   ,p_element_class_usage_id           in     number
477   ,p_object_version_number            in out nocopy number
478   ,p_effective_start_date                out nocopy date
479   ,p_effective_end_date                  out nocopy date
480   ) is
481 --
482   l_rec         pay_ecu_shd.g_rec_type;
483   l_proc        varchar2(72) := g_package||'del';
484 --
485 Begin
486   hr_utility.set_location('Entering:'||l_proc, 5);
487   --
488   -- As the delete procedure accepts a plsql record structure we do need to
489   -- convert the  arguments into the record structure.
490   -- We don't need to call the supplied conversion argument routine as we
491   -- only need a few attributes.
492   --
493   l_rec.element_class_usage_id          := p_element_class_usage_id;
494   l_rec.object_version_number     := p_object_version_number;
495   --
496   -- Having converted the arguments into the pay_ecu_rec
497   -- plsql record structure we must call the corresponding entity
498   -- business process
499   --
500   pay_ecu_del.del
501      (p_effective_date
502      ,p_datetrack_mode
503      ,l_rec
504      );
505   --
506   --
507   -- Set the out arguments
508   --
509   p_object_version_number            := l_rec.object_version_number;
510   p_effective_start_date             := l_rec.effective_start_date;
511   p_effective_end_date               := l_rec.effective_end_date;
512   --
513   hr_utility.set_location(' Leaving:'||l_proc, 10);
514 End del;
515 --
516 end pay_ecu_del;