DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PBC_DEL

Source


1 Package Body pay_pbc_del as
2 /* $Header: pypbcrhi.pkb 120.0 2005/05/29 07:19:45 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_pbc_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_pbc_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_balance_categories_f
72     where       balance_category_id = p_rec.balance_category_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_balance_categories_f
83     where        balance_category_id = p_rec.balance_category_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_pbc_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_pbc_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_pbc_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_pbc_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_pbc_shd.upd_effective_end_date
217       (p_effective_date         => p_effective_date
218       ,p_base_key_value         => p_rec.balance_category_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_pbc_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_pbc_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_pbc_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       ('BALANCE_CATEGORY_ID'
341       ,p_rec.balance_category_id
342       ,p_datetrack_mode
343       );
344     --
345     pay_pbc_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_balance_category_id
355       => p_rec.balance_category_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_object_version_number
361       => p_rec.object_version_number
362       ,p_category_name_o
363       => pay_pbc_shd.g_old_rec.category_name
364       ,p_effective_start_date_o
365       => pay_pbc_shd.g_old_rec.effective_start_date
366       ,p_effective_end_date_o
367       => pay_pbc_shd.g_old_rec.effective_end_date
368       ,p_legislation_code_o
369       => pay_pbc_shd.g_old_rec.legislation_code
370       ,p_business_group_id_o
371       => pay_pbc_shd.g_old_rec.business_group_id
372       ,p_save_run_balance_enabled_o
373       => pay_pbc_shd.g_old_rec.save_run_balance_enabled
374       ,p_user_category_name_o
375       => pay_pbc_shd.g_old_rec.user_category_name
376       ,p_pbc_information_category_o
377       => pay_pbc_shd.g_old_rec.pbc_information_category
378       ,p_pbc_information1_o
379       => pay_pbc_shd.g_old_rec.pbc_information1
380       ,p_pbc_information2_o
381       => pay_pbc_shd.g_old_rec.pbc_information2
382       ,p_pbc_information3_o
383       => pay_pbc_shd.g_old_rec.pbc_information3
384       ,p_pbc_information4_o
385       => pay_pbc_shd.g_old_rec.pbc_information4
386       ,p_pbc_information5_o
387       => pay_pbc_shd.g_old_rec.pbc_information5
388       ,p_pbc_information6_o
389       => pay_pbc_shd.g_old_rec.pbc_information6
390       ,p_pbc_information7_o
391       => pay_pbc_shd.g_old_rec.pbc_information7
392       ,p_pbc_information8_o
393       => pay_pbc_shd.g_old_rec.pbc_information8
394       ,p_pbc_information9_o
395       => pay_pbc_shd.g_old_rec.pbc_information9
396       ,p_pbc_information10_o
397       => pay_pbc_shd.g_old_rec.pbc_information10
398       ,p_pbc_information11_o
399       => pay_pbc_shd.g_old_rec.pbc_information11
400       ,p_pbc_information12_o
401       => pay_pbc_shd.g_old_rec.pbc_information12
402       ,p_pbc_information13_o
403       => pay_pbc_shd.g_old_rec.pbc_information13
404       ,p_pbc_information14_o
405       => pay_pbc_shd.g_old_rec.pbc_information14
406       ,p_pbc_information15_o
407       => pay_pbc_shd.g_old_rec.pbc_information15
408       ,p_pbc_information16_o
409       => pay_pbc_shd.g_old_rec.pbc_information16
410       ,p_pbc_information17_o
411       => pay_pbc_shd.g_old_rec.pbc_information17
412       ,p_pbc_information18_o
413       => pay_pbc_shd.g_old_rec.pbc_information18
414       ,p_pbc_information19_o
415       => pay_pbc_shd.g_old_rec.pbc_information19
416       ,p_pbc_information20_o
417       => pay_pbc_shd.g_old_rec.pbc_information20
418       ,p_pbc_information21_o
419       => pay_pbc_shd.g_old_rec.pbc_information21
420       ,p_pbc_information22_o
421       => pay_pbc_shd.g_old_rec.pbc_information22
422       ,p_pbc_information23_o
423       => pay_pbc_shd.g_old_rec.pbc_information23
424       ,p_pbc_information24_o
425       => pay_pbc_shd.g_old_rec.pbc_information24
426       ,p_pbc_information25_o
427       => pay_pbc_shd.g_old_rec.pbc_information25
428       ,p_pbc_information26_o
429       => pay_pbc_shd.g_old_rec.pbc_information26
430       ,p_pbc_information27_o
431       => pay_pbc_shd.g_old_rec.pbc_information27
432       ,p_pbc_information28_o
433       => pay_pbc_shd.g_old_rec.pbc_information28
434       ,p_pbc_information29_o
435       => pay_pbc_shd.g_old_rec.pbc_information29
436       ,p_pbc_information30_o
437       => pay_pbc_shd.g_old_rec.pbc_information30
438       ,p_object_version_number_o
439       => pay_pbc_shd.g_old_rec.object_version_number
440       );
441     --
442   exception
443     --
444     when hr_api.cannot_find_prog_unit then
445       --
446       hr_api.cannot_find_prog_unit_error
447         (p_module_name => 'PAY_BALANCE_CATEGORIES_F'
448         ,p_hook_type   => 'AD');
449       --
450   end;
451   --
452   hr_utility.set_location(' Leaving:'||l_proc, 10);
453 End post_delete;
454 --
455 -- ----------------------------------------------------------------------------
456 -- |---------------------------------< del >----------------------------------|
457 -- ----------------------------------------------------------------------------
458 Procedure del
459   (p_effective_date in     date
460   ,p_datetrack_mode in     varchar2
461   ,p_rec            in out nocopy pay_pbc_shd.g_rec_type
462   ) is
463 --
464   l_proc                        varchar2(72) := g_package||'del';
465   l_validation_start_date       date;
466   l_validation_end_date         date;
467 --
468 Begin
469   hr_utility.set_location('Entering:'||l_proc, 5);
470   --
471   -- Ensure that the DateTrack delete mode is valid
472   --
473   dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
474   --
475   -- We must lock the row which we need to delete.
476   --
477   pay_pbc_shd.lck
478     (p_effective_date                   => p_effective_date
479     ,p_datetrack_mode                   => p_datetrack_mode
480     ,p_balance_category_id              => p_rec.balance_category_id
481     ,p_object_version_number            => p_rec.object_version_number
482     ,p_validation_start_date            => l_validation_start_date
483     ,p_validation_end_date              => l_validation_end_date
484     );
485   --
486   -- Call the supporting delete validate operation
487   --
488   pay_pbc_bus.delete_validate
489     (p_rec                              => p_rec
490     ,p_effective_date                   => p_effective_date
491     ,p_datetrack_mode                   => p_datetrack_mode
492     ,p_validation_start_date            => l_validation_start_date
493     ,p_validation_end_date              => l_validation_end_date
494     );
495   --
496   -- Call to raise any errors on multi-message list
497   hr_multi_message.end_validation_set;
498   --
499   -- Call the supporting pre-delete operation
500   --
501   pay_pbc_del.pre_delete
502     (p_rec                              => p_rec
503     ,p_effective_date                   => p_effective_date
504     ,p_datetrack_mode                   => p_datetrack_mode
508   --
505     ,p_validation_start_date            => l_validation_start_date
506     ,p_validation_end_date              => l_validation_end_date
507     );
509   -- Delete the row.
510   --
511   pay_pbc_del.delete_dml
512     (p_rec                              => p_rec
513     ,p_effective_date                   => p_effective_date
514     ,p_datetrack_mode                   => p_datetrack_mode
518   -- Call the supporting post-delete operation
515     ,p_validation_start_date            => l_validation_start_date
516     ,p_validation_end_date              => l_validation_end_date
517     );
519   --
520   pay_pbc_del.post_delete
521     (p_rec                              => p_rec
522     ,p_effective_date                   => p_effective_date
523     ,p_datetrack_mode                   => p_datetrack_mode
524     ,p_validation_start_date            => l_validation_start_date
525     ,p_validation_end_date              => l_validation_end_date
526     );
527   --
528   -- Call to raise any errors on multi-message list
529   hr_multi_message.end_validation_set;
530   --
531   hr_utility.set_location(' Leaving:'||l_proc, 5);
532 End del;
533 --
534 -- ----------------------------------------------------------------------------
535 -- |--------------------------------< del >-----------------------------------|
536 -- ----------------------------------------------------------------------------
537 Procedure del
538   (p_effective_date                   in     date
539   ,p_datetrack_mode                   in     varchar2
540   ,p_balance_category_id              in     number
541   ,p_object_version_number            in out nocopy number
542   ,p_effective_start_date                out nocopy date
543   ,p_effective_end_date                  out nocopy date
544   ) is
545 --
546   l_rec         pay_pbc_shd.g_rec_type;
547   l_proc        varchar2(72) := g_package||'del';
548 --
549 Begin
550   hr_utility.set_location('Entering:'||l_proc, 5);
554   -- We don't need to call the supplied conversion argument routine as we
551   --
552   -- As the delete procedure accepts a plsql record structure we do need to
553   -- convert the  arguments into the record structure.
555   -- only need a few attributes.
556   --
557   l_rec.balance_category_id          := p_balance_category_id;
558   l_rec.object_version_number     := p_object_version_number;
559   --
560   -- Having converted the arguments into the pay_pbc_rec
561   -- plsql record structure we must call the corresponding entity
562   -- business process
563   --
564   pay_pbc_del.del
565      (p_effective_date
566      ,p_datetrack_mode
567      ,l_rec
568      );
569   --
570   --
571   -- Set the out arguments
572   --
573   p_object_version_number            := l_rec.object_version_number;
574   p_effective_start_date             := l_rec.effective_start_date;
575   p_effective_end_date               := l_rec.effective_end_date;
576   --
577   hr_utility.set_location(' Leaving:'||l_proc, 10);
578 End del;
579 --
580 end pay_pbc_del;