DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_ETU_DEL

Source


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