DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PEL_DEL

Source


1 Package Body pay_pel_del as
2 /* $Header: pypelrhi.pkb 120.7.12010000.3 2008/10/03 08:41:56 ankagarw ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_pel_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_pel_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     pay_pel_shd.g_api_dml := true;  -- Set the api dml status
67     --
68     -- Delete the where the effective start date is equal
69     -- to the validation end date.
70     --
71     delete from pay_element_links_f
72     where       element_link_id = p_rec.element_link_id
73     and   effective_start_date = p_validation_start_date;
74     --
75     pay_pel_shd.g_api_dml := false;   -- Unset the api dml status
76   Else
77     pay_pel_shd.g_api_dml := true;  -- Set the api dml status
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_links_f
83     where        element_link_id = p_rec.element_link_id
84     and   effective_start_date >= p_validation_start_date;
85     --
86     pay_pel_shd.g_api_dml := false;   -- Unset the api dml status
87   End If;
88   --
89   hr_utility.set_location(' Leaving:'||l_proc, 20);
90 --
91 Exception
92   When Others Then
93     pay_pel_shd.g_api_dml := false;   -- Unset the api dml status
94     Raise;
95 --
96 End dt_delete_dml;
97 --
98 -- ----------------------------------------------------------------------------
99 -- |------------------------------< delete_dml >------------------------------|
100 -- ----------------------------------------------------------------------------
101 Procedure delete_dml
102   (p_rec                     in out nocopy pay_pel_shd.g_rec_type
103   ,p_effective_date          in date
104   ,p_datetrack_mode          in varchar2
105   ,p_validation_start_date   in date
106   ,p_validation_end_date     in date
107   ) is
108 --
109   l_proc        varchar2(72) := g_package||'delete_dml';
110 --
111 Begin
112   hr_utility.set_location('Entering:'||l_proc, 5);
113   --
114   pay_pel_del.dt_delete_dml
115     (p_rec                   => p_rec
116     ,p_effective_date        => p_effective_date
117     ,p_datetrack_mode        => p_datetrack_mode
118     ,p_validation_start_date => p_validation_start_date
119     ,p_validation_end_date   => p_validation_end_date
120     );
121   --
122   hr_utility.set_location(' Leaving:'||l_proc, 10);
123 End delete_dml;
124 --
125 -- ----------------------------------------------------------------------------
126 -- |----------------------------< dt_pre_delete >-----------------------------|
127 -- ----------------------------------------------------------------------------
128 -- {Start Of Comments}
129 --
130 -- Description:
131 --   The dt_pre_delete process controls the execution of dml
132 --   for the datetrack modes: DELETE, FUTURE_CHANGE
133 --   and DELETE_NEXT_CHANGE only.
134 --
135 -- Prerequisites:
136 --   This is an internal procedure which is called from the pre_delete
137 --   procedure.
138 --
139 -- In Parameters:
140 --   A Pl/Sql record structure.
141 --
142 -- Post Success:
143 --   Processing continues.
144 --
145 -- Post Failure:
146 --   If an error has occurred, an error message and exception will be raised
147 --   but not handled.
148 --
149 -- Developer Implementation Notes:
150 --   This is an internal procedure which is required by Datetrack. Don't
151 --   remove or modify.
152 --
153 -- Access Status:
154 --   Internal Row Handler Use Only.
155 --
156 -- {End Of Comments}
157 -- ----------------------------------------------------------------------------
158 Procedure dt_pre_delete
159   (p_rec                     in out nocopy pay_pel_shd.g_rec_type
160   ,p_effective_date          in date
161   ,p_datetrack_mode          in varchar2
162   ,p_validation_start_date   in date
163   ,p_validation_end_date     in date
164   ) is
165 --
166   l_proc        varchar2(72) := g_package||'dt_pre_delete';
167 --
168 Begin
169   hr_utility.set_location('Entering:'||l_proc, 5);
170   --
171   If (p_datetrack_mode <> hr_api.g_zap) then
172     --
173     p_rec.effective_start_date
174       := pay_pel_shd.g_old_rec.effective_start_date;
175     --
176     If (p_datetrack_mode = hr_api.g_delete) then
177       p_rec.effective_end_date := p_validation_start_date - 1;
178     Else
179       p_rec.effective_end_date := p_validation_end_date;
180     End If;
181     --
182     -- Update the current effective end date record
183     --
184     pay_pel_shd.upd_effective_end_date
185       (p_effective_date         => p_effective_date
186       ,p_base_key_value         => p_rec.element_link_id
187       ,p_new_effective_end_date => p_rec.effective_end_date
188       ,p_validation_start_date  => p_validation_start_date
189       ,p_validation_end_date    => p_validation_end_date
190       ,p_object_version_number  => p_rec.object_version_number
191       );
192   Else
193     p_rec.effective_start_date := null;
194     p_rec.effective_end_date   := null;
195   End If;
196   hr_utility.set_location(' Leaving:'||l_proc, 10);
197 End dt_pre_delete;
198 --
199 -- ----------------------------------------------------------------------------
200 -- |------------------------------< pre_delete >------------------------------|
201 -- ----------------------------------------------------------------------------
202 -- {Start Of Comments}
203 --
204 -- Description:
205 --   This private procedure contains any processing which is required before
206 --   the delete dml.
207 --
208 -- Prerequisites:
209 --   This is an internal procedure which is called from the del procedure.
210 --
211 -- In Parameters:
212 --   A Pl/Sql record structure.
213 --
214 -- Post Success:
215 --   Processing continues.
216 --
217 -- Post Failure:
218 --   If an error has occurred, an error message and exception will be raised
219 --   but not handled.
220 --
221 -- Developer Implementation Notes:
222 --   Any pre-processing required before the delete dml is issued should be
223 --   coded within this procedure. It is important to note that any 3rd party
224 --   maintenance should be reviewed before placing in this procedure. The call
225 --   to the dt_delete_dml procedure should NOT be removed.
226 --
227 -- Access Status:
228 --   Internal Row Handler Use Only.
229 --
230 -- {End Of Comments}
231 -- ----------------------------------------------------------------------------
232 Procedure pre_delete
233   (p_rec                   in out nocopy pay_pel_shd.g_rec_type
234   ,p_effective_date        in date
235   ,p_datetrack_mode        in varchar2
236   ,p_validation_start_date in date
237   ,p_validation_end_date   in date
238   ) is
239 --
240   l_proc        varchar2(72) := g_package||'pre_delete';
241 --
242 -- Cursor C_Sel1 select comments to be deleted
243 --
244   Cursor C_Sel1 is
245     select t1.comment_id
246     from   pay_element_links_f t1
247     where  t1.comment_id is not null
248     and    t1.element_link_id = p_rec.element_link_id
249     and    t1.effective_start_date <= p_validation_end_date
250     and    t1.effective_end_date   >= p_validation_start_date
251     and    not exists
252            (select 1
253             from   pay_element_links_f t2
254             where  t2.comment_id = t1.comment_id
255             and    t2.element_link_id = t1.element_link_id
256             and   (t2.effective_start_date > p_validation_end_date
257             or    t2.effective_end_date   < p_validation_start_date));
258 --
259 --
260 Begin
261   hr_utility.set_location('Entering:'||l_proc, 5);
262   --
263   --
264   -- Delete any possible comments
265   --
266   For Comm_Del In C_Sel1 Loop
267     hr_comm_api.del(p_comment_id        => Comm_Del.comment_id);
268   End Loop;
269   --
270   --
271   pay_pel_del.dt_pre_delete
272     (p_rec                   => p_rec
273     ,p_effective_date        => p_effective_date
274     ,p_datetrack_mode        => p_datetrack_mode
275     ,p_validation_start_date => p_validation_start_date
276     ,p_validation_end_date   => p_validation_end_date
277     );
278   --
279   hr_utility.set_location(' Leaving:'||l_proc, 10);
280 End pre_delete;
281 --
282 -- ----------------------------------------------------------------------------
283 -- |----------------------------< post_delete >-------------------------------|
284 -- ----------------------------------------------------------------------------
285 -- {Start Of Comments}
286 --
287 -- Description:
288 --   This private procedure contains any processing which is required after
289 --   the delete dml.
290 --
291 -- Prerequisites:
292 --   This is an internal procedure which is called from the del procedure.
293 --
294 -- In Parameters:
295 --   A Pl/Sql record structure.
296 --
297 -- Post Success:
298 --   Processing continues.
299 --
300 -- Post Failure:
301 --   If an error has occurred, an error message and exception will be raised
302 --   but not handled.
303 --
304 -- Developer Implementation Notes:
305 --   Any post-processing required after the delete dml is issued should be
306 --   coded within this procedure. It is important to note that any 3rd party
307 --   maintenance should be reviewed before placing in this procedure.
308 --
309 -- Access Status:
310 --   Internal Row Handler Use Only.
311 --
312 -- {End Of Comments}
313 -- ----------------------------------------------------------------------------
314 Procedure post_delete
315   (p_rec                   in pay_pel_shd.g_rec_type
316   ,p_effective_date        in date
317   ,p_datetrack_mode        in varchar2
318   ,p_validation_start_date in date
319   ,p_validation_end_date   in date
320   ) is
321 --
322   l_proc        varchar2(72) := g_package||'post_delete';
323 --
324 Begin
325   hr_utility.set_location('Entering:'||l_proc, 5);
326    begin
327     --
328     pay_pel_rkd.after_delete
329       (p_effective_date
330       => p_effective_date
331       ,p_datetrack_mode
332       => p_datetrack_mode
333       ,p_validation_start_date
334       => p_validation_start_date
335       ,p_validation_end_date
336       => p_validation_end_date
337       ,p_element_link_id
338       => p_rec.element_link_id
339       ,p_effective_start_date
340       => p_rec.effective_start_date
341       ,p_effective_end_date
342       => p_rec.effective_end_date
343       ,p_effective_start_date_o
344       => pay_pel_shd.g_old_rec.effective_start_date
345       ,p_effective_end_date_o
346       => pay_pel_shd.g_old_rec.effective_end_date
347       ,p_payroll_id_o
348       => pay_pel_shd.g_old_rec.payroll_id
349       ,p_job_id_o
350       => pay_pel_shd.g_old_rec.job_id
351       ,p_position_id_o
352       => pay_pel_shd.g_old_rec.position_id
353       ,p_people_group_id_o
354       => pay_pel_shd.g_old_rec.people_group_id
355       ,p_cost_allocation_keyflex_id_o
356       => pay_pel_shd.g_old_rec.cost_allocation_keyflex_id
357       ,p_organization_id_o
358       => pay_pel_shd.g_old_rec.organization_id
359       ,p_element_type_id_o
360       => pay_pel_shd.g_old_rec.element_type_id
361       ,p_location_id_o
362       => pay_pel_shd.g_old_rec.location_id
363       ,p_grade_id_o
364       => pay_pel_shd.g_old_rec.grade_id
365       ,p_balancing_keyflex_id_o
366       => pay_pel_shd.g_old_rec.balancing_keyflex_id
367       ,p_business_group_id_o
368       => pay_pel_shd.g_old_rec.business_group_id
369       ,p_element_set_id_o
370       => pay_pel_shd.g_old_rec.element_set_id
371       ,p_pay_basis_id_o
372       => pay_pel_shd.g_old_rec.pay_basis_id
373       ,p_costable_type_o
377       ,p_multiply_value_flag_o
374       => pay_pel_shd.g_old_rec.costable_type
375       ,p_link_to_all_payrolls_flag_o
376       => pay_pel_shd.g_old_rec.link_to_all_payrolls_flag
378       => pay_pel_shd.g_old_rec.multiply_value_flag
379       ,p_standard_link_flag_o
380       => pay_pel_shd.g_old_rec.standard_link_flag
381       ,p_transfer_to_gl_flag_o
382       => pay_pel_shd.g_old_rec.transfer_to_gl_flag
383       ,p_comment_id_o
384       => pay_pel_shd.g_old_rec.comment_id
385       ,p_comments_o
386       => pay_pel_shd.g_old_rec.comments
387       ,p_employment_category_o
388       => pay_pel_shd.g_old_rec.employment_category
389       ,p_qualifying_age_o
390       => pay_pel_shd.g_old_rec.qualifying_age
391       ,p_qualifying_length_of_servi_o
392       => pay_pel_shd.g_old_rec.qualifying_length_of_service
393       ,p_qualifying_units_o
394       => pay_pel_shd.g_old_rec.qualifying_units
395       ,p_attribute_category_o
396       => pay_pel_shd.g_old_rec.attribute_category
397       ,p_attribute1_o
398       => pay_pel_shd.g_old_rec.attribute1
399       ,p_attribute2_o
400       => pay_pel_shd.g_old_rec.attribute2
401       ,p_attribute3_o
402       => pay_pel_shd.g_old_rec.attribute3
403       ,p_attribute4_o
404       => pay_pel_shd.g_old_rec.attribute4
405       ,p_attribute5_o
406       => pay_pel_shd.g_old_rec.attribute5
407       ,p_attribute6_o
408       => pay_pel_shd.g_old_rec.attribute6
409       ,p_attribute7_o
410       => pay_pel_shd.g_old_rec.attribute7
411       ,p_attribute8_o
412       => pay_pel_shd.g_old_rec.attribute8
413       ,p_attribute9_o
414       => pay_pel_shd.g_old_rec.attribute9
415       ,p_attribute10_o
416       => pay_pel_shd.g_old_rec.attribute10
417       ,p_attribute11_o
418       => pay_pel_shd.g_old_rec.attribute11
419       ,p_attribute12_o
420       => pay_pel_shd.g_old_rec.attribute12
421       ,p_attribute13_o
422       => pay_pel_shd.g_old_rec.attribute13
423       ,p_attribute14_o
424       => pay_pel_shd.g_old_rec.attribute14
425       ,p_attribute15_o
426       => pay_pel_shd.g_old_rec.attribute15
427       ,p_attribute16_o
428       => pay_pel_shd.g_old_rec.attribute16
429       ,p_attribute17_o
430       => pay_pel_shd.g_old_rec.attribute17
431       ,p_attribute18_o
432       => pay_pel_shd.g_old_rec.attribute18
433       ,p_attribute19_o
434       => pay_pel_shd.g_old_rec.attribute19
435       ,p_attribute20_o
436       => pay_pel_shd.g_old_rec.attribute20
437       ,p_object_version_number_o
438       => pay_pel_shd.g_old_rec.object_version_number
439       );
440     --
441   exception
442     --
443     when hr_api.cannot_find_prog_unit then
444       --
445       hr_api.cannot_find_prog_unit_error
446         (p_module_name => 'PAY_ELEMENT_LINKS_F'
447         ,p_hook_type   => 'AD');
448       --
449   end;
450   --
451   hr_utility.set_location(' Leaving:'||l_proc, 10);
452 End post_delete;
453 --
454 -- ----------------------------------------------------------------------------
455 -- |---------------------------------< del >----------------------------------|
456 -- ----------------------------------------------------------------------------
457 Procedure del
458   (p_effective_date in     date
459   ,p_datetrack_mode in     varchar2
460   ,p_rec            in out nocopy pay_pel_shd.g_rec_type
461   ) is
462 --
463   l_proc                        varchar2(72) := g_package||'del';
464   l_validation_start_date       date;
465   l_validation_end_date         date;
466 --
467 Begin
468   hr_utility.set_location('Entering:'||l_proc, 5);
469   --
470   -- Ensure that the DateTrack delete mode is valid
471   --
472   dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
473 
474   --
475   -- We must lock the row which we need to delete.
476   --
477   pay_pel_shd.lck
478     (p_effective_date                   => p_effective_date
479     ,p_datetrack_mode                   => p_datetrack_mode
480     ,p_element_link_id                  => p_rec.element_link_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     ,p_enforce_foreign_locking          => true
485     );
486 
487   --
488   -- Call the supporting delete validate operation
489   --
490   pay_pel_bus.delete_validate
491     (p_rec                              => p_rec
492     ,p_effective_date                   => p_effective_date
493     ,p_datetrack_mode                   => p_datetrack_mode
494     ,p_validation_start_date            => l_validation_start_date
495     ,p_validation_end_date              => l_validation_end_date
496     );
497   --
498   -- Call to raise any errors on multi-message list
499   hr_multi_message.end_validation_set;
500   --
501   -- Call the supporting pre-delete operation
502   --
503   pay_pel_del.pre_delete
504     (p_rec                              => p_rec
505     ,p_effective_date                   => p_effective_date
506     ,p_datetrack_mode                   => p_datetrack_mode
507     ,p_validation_start_date            => l_validation_start_date
511   -- Delete the row.
508     ,p_validation_end_date              => l_validation_end_date
509     );
510   --
512   --
513   pay_pel_del.delete_dml
514     (p_rec                              => p_rec
515     ,p_effective_date                   => p_effective_date
516     ,p_datetrack_mode                   => p_datetrack_mode
517     ,p_validation_start_date            => l_validation_start_date
518     ,p_validation_end_date              => l_validation_end_date
519     );
520   -- Call the supporting post-delete operation
521   --
522   pay_pel_del.post_delete
523     (p_rec                              => p_rec
524     ,p_effective_date                   => p_effective_date
525     ,p_datetrack_mode                   => p_datetrack_mode
526     ,p_validation_start_date            => l_validation_start_date
527     ,p_validation_end_date              => l_validation_end_date
528     );
529   --
530   -- Call to raise any errors on multi-message list
531   hr_multi_message.end_validation_set;
532   --
533   hr_utility.set_location(' Leaving:'||l_proc, 5);
534 End del;
535 --
536 -- ----------------------------------------------------------------------------
537 -- |--------------------------------< del >-----------------------------------|
538 -- ----------------------------------------------------------------------------
539 Procedure del
540   (p_effective_date                  in    date
541   ,p_element_link_id		     in    number
542   ,p_datetrack_delete_mode	     in    varchar2
543   ,p_object_version_number	     in out nocopy    number
544   ,p_effective_start_date	     out nocopy   date
545   ,p_effective_end_date		     out nocopy   date
546   ,p_warning			     out nocopy   boolean
547   ) is
548 --
549   l_rec         pay_pel_shd.g_rec_type;
550   l_proc        varchar2(72) := g_package||'del';
551 --
552 Begin
553   hr_utility.set_location('Entering:'||l_proc, 5);
554   --
555   -- As the delete procedure accepts a plsql record structure we do need to
556   -- convert the  arguments into the record structure.
557   -- We don't need to call the supplied conversion argument routine as we
558   -- only need a few attributes.
559   --
560   l_rec.element_link_id          := p_element_link_id ;
561   l_rec.object_version_number     := p_object_version_number;
562   --
563   -- Having converted the arguments into the pay_pel_rec
564   -- plsql record structure we must call the corresponding entity
565   -- business process
566   --
567 
568   -- Warn the user for recurring entries if the mode is Date Effective delete
569   if p_datetrack_delete_mode = hr_api.g_delete then
570     p_warning := TRUE;
571   else
572     p_warning := FALSE;
573   end if;
574 
575   pay_pel_del.del
576      (p_effective_date
577      ,p_datetrack_delete_mode
578      ,l_rec
579      );
580   --
581   --
582   -- Set the out arguments
583   --
584   p_effective_start_date             := l_rec.effective_start_date;
585   p_effective_end_date               := l_rec.effective_end_date;
586   p_object_version_number 	     := l_rec.object_version_number;
587   --
588   hr_utility.set_location(' Leaving:'||l_proc, 10);
589 End del;
590 --
591 end pay_pel_del;