DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_EVQ_DEL

Source


1 Package Body pay_evq_del as
2 /* $Header: pyevqrhi.pkb 120.0 2005/05/29 04:49:50 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_evq_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_evq_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     --
70     --
67     --
68     -- Delete the where the effective start date is equal
69     -- to the validation end date.
71     delete from pay_event_qualifiers_f
72     where       event_qualifier_id = p_rec.event_qualifier_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_event_qualifiers_f
83     where        event_qualifier_id = p_rec.event_qualifier_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_evq_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_evq_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_evq_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_evq_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     --
217       (p_effective_date         => p_effective_date
214     -- Update the current effective end date record
215     --
216     pay_evq_shd.upd_effective_end_date
218       ,p_base_key_value         => p_rec.event_qualifier_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_evq_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_evq_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
299 --   the 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_evq_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     delete_app_ownerships
340       ('EVENT_QUALIFIER_ID'
341       ,p_rec.event_qualifier_id
342       ,p_datetrack_mode
343       );
344     --
345     pay_evq_rkd.after_delete
346       (p_effective_date
347       => p_effective_date
348       ,p_datetrack_mode
349       => p_datetrack_mode
350       ,p_validation_start_date
351       => p_validation_start_date
352       ,p_validation_end_date
353       => p_validation_end_date
354       ,p_event_qualifier_id
355       => p_rec.event_qualifier_id
356       ,p_effective_start_date
357       => p_rec.effective_start_date
358       ,p_effective_end_date
359       => p_rec.effective_end_date
360       ,p_effective_start_date_o
361       => pay_evq_shd.g_old_rec.effective_start_date
362       ,p_effective_end_date_o
363       => pay_evq_shd.g_old_rec.effective_end_date
367       => pay_evq_shd.g_old_rec.column_name
364       ,p_dated_table_id_o
365       => pay_evq_shd.g_old_rec.dated_table_id
366       ,p_column_name_o
368       ,p_qualifier_name_o
369       => pay_evq_shd.g_old_rec.qualifier_name
370       ,p_legislation_code_o
371       => pay_evq_shd.g_old_rec.legislation_code
372       ,p_business_group_id_o
373       => pay_evq_shd.g_old_rec.business_group_id
374       ,p_comparison_column_o
375       => pay_evq_shd.g_old_rec.comparison_column
376       ,p_qualifier_definition_o
377       => pay_evq_shd.g_old_rec.qualifier_definition
378       ,p_qualifier_where_clause_o
379       => pay_evq_shd.g_old_rec.qualifier_where_clause
380       ,p_entry_qualification_o
381       => pay_evq_shd.g_old_rec.entry_qualification
382       ,p_assignment_qualification_o
383       => pay_evq_shd.g_old_rec.assignment_qualification
384       ,p_multi_event_sql_o
385       => pay_evq_shd.g_old_rec.multi_event_sql
386       ,p_object_version_number_o
387       => pay_evq_shd.g_old_rec.object_version_number
388       );
389     --
390   exception
391     --
392     when hr_api.cannot_find_prog_unit then
393       --
394       hr_api.cannot_find_prog_unit_error
395         (p_module_name => 'PAY_EVENT_QUALIFIERS_F'
396         ,p_hook_type   => 'AD');
397       --
398   end;
399   --
400   hr_utility.set_location(' Leaving:'||l_proc, 10);
401 End post_delete;
402 --
403 -- ----------------------------------------------------------------------------
404 -- |---------------------------------< del >----------------------------------|
405 -- ----------------------------------------------------------------------------
406 Procedure del
407   (p_effective_date in     date
408   ,p_datetrack_mode in     varchar2
409   ,p_rec            in out nocopy pay_evq_shd.g_rec_type
410   ) is
411 --
412   l_proc                        varchar2(72) := g_package||'del';
413   l_validation_start_date       date;
414   l_validation_end_date         date;
415 --
416 Begin
417   hr_utility.set_location('Entering:'||l_proc, 5);
418   --
419   -- Ensure that the DateTrack delete mode is valid
420   --
421   dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
422   --
423   -- We must lock the row which we need to delete.
424   --
425   pay_evq_shd.lck
426     (p_effective_date                   => p_effective_date
427     ,p_datetrack_mode                   => p_datetrack_mode
428     ,p_event_qualifier_id               => p_rec.event_qualifier_id
429     ,p_object_version_number            => p_rec.object_version_number
430     ,p_validation_start_date            => l_validation_start_date
431     ,p_validation_end_date              => l_validation_end_date
432     );
433   --
434   -- Call the supporting delete validate operation
435   --
436   pay_evq_bus.delete_validate
437     (p_rec                              => p_rec
438     ,p_effective_date                   => p_effective_date
439     ,p_datetrack_mode                   => p_datetrack_mode
440     ,p_validation_start_date            => l_validation_start_date
441     ,p_validation_end_date              => l_validation_end_date
442     );
443   --
444   -- Call to raise any errors on multi-message list
445   hr_multi_message.end_validation_set;
446   --
447   -- Call the supporting pre-delete operation
448   --
449   pay_evq_del.pre_delete
450     (p_rec                              => p_rec
451     ,p_effective_date                   => p_effective_date
452     ,p_datetrack_mode                   => p_datetrack_mode
453     ,p_validation_start_date            => l_validation_start_date
454     ,p_validation_end_date              => l_validation_end_date
455     );
456   --
457   -- Delete the row.
458   --
459   pay_evq_del.delete_dml
460     (p_rec                              => p_rec
461     ,p_effective_date                   => p_effective_date
462     ,p_datetrack_mode                   => p_datetrack_mode
463     ,p_validation_start_date            => l_validation_start_date
464     ,p_validation_end_date              => l_validation_end_date
465     );
466   -- Call the supporting post-delete operation
467   --
468   pay_evq_del.post_delete
469     (p_rec                              => p_rec
470     ,p_effective_date                   => p_effective_date
471     ,p_datetrack_mode                   => p_datetrack_mode
472     ,p_validation_start_date            => l_validation_start_date
473     ,p_validation_end_date              => l_validation_end_date
474     );
475   --
476   -- Call to raise any errors on multi-message list
477   hr_multi_message.end_validation_set;
478   --
479   hr_utility.set_location(' Leaving:'||l_proc, 5);
480 End del;
481 --
482 -- ----------------------------------------------------------------------------
483 -- |--------------------------------< del >-----------------------------------|
484 -- ----------------------------------------------------------------------------
485 Procedure del
486   (p_effective_date                   in     date
487   ,p_datetrack_mode                   in     varchar2
488   ,p_event_qualifier_id               in     number
489   ,p_object_version_number            in out nocopy number
490   ,p_effective_start_date                out nocopy date
491   ,p_effective_end_date                  out nocopy date
492   ) is
493 --
494   l_rec         pay_evq_shd.g_rec_type;
495   l_proc        varchar2(72) := g_package||'del';
496 --
497 Begin
498   hr_utility.set_location('Entering:'||l_proc, 5);
499   --
500   -- As the delete procedure accepts a plsql record structure we do need to
501   -- convert the  arguments into the record structure.
502   -- We don't need to call the supplied conversion argument routine as we
503   -- only need a few attributes.
504   --
505   l_rec.event_qualifier_id          := p_event_qualifier_id;
506   l_rec.object_version_number     := p_object_version_number;
507   --
508   -- Having converted the arguments into the pay_evq_rec
509   -- plsql record structure we must call the corresponding entity
510   -- business process
511   --
512   pay_evq_del.del
513      (p_effective_date
514      ,p_datetrack_mode
515      ,l_rec
516      );
517   --
518   --
519   -- Set the out arguments
520   --
521   p_object_version_number            := l_rec.object_version_number;
522   p_effective_start_date             := l_rec.effective_start_date;
523   p_effective_end_date               := l_rec.effective_end_date;
524   --
525   hr_utility.set_location(' Leaving:'||l_proc, 10);
526 End del;
527 --
528 end pay_evq_del;