DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CCT_DEL

Source


1 Package Body ben_cct_del as
2 /* $Header: becctrhi.pkb 120.0 2005/05/28 00:58:57 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_cct_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 structre.
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 ben_cct_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) is
59 --
60   l_proc	varchar2(72) := g_package||'dt_delete_dml';
61 --
62 Begin
63   hr_utility.set_location('Entering:'||l_proc, 5);
64   If (p_datetrack_mode = 'DELETE_NEXT_CHANGE') then
65     hr_utility.set_location(l_proc, 10);
66     ben_cct_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 ben_cm_typ_f
72     where       cm_typ_id = p_rec.cm_typ_id
73     and	  effective_start_date = p_validation_start_date;
74     --
75     --  Delete from MLS table.
76     --
77     delete from ben_cm_typ_f_tl
78     where       cm_typ_id = p_rec.cm_typ_id
79     and	  effective_start_date = p_validation_start_date;
80     --
81     ben_cct_shd.g_api_dml := false;   -- Unset the api dml status
82   Else
83     hr_utility.set_location(l_proc, 15);
84     ben_cct_shd.g_api_dml := true;  -- Set the api dml status
85     --
86     -- Delete the row(s) where the effective start date is greater than
87     -- or equal to the validation start date.
88     --
89     delete from ben_cm_typ_f
90     where        cm_typ_id = p_rec.cm_typ_id
91     and	  effective_start_date >= p_validation_start_date;
92     --
93     delete from ben_cm_typ_f_tl
94     where        cm_typ_id = p_rec.cm_typ_id
95     and	  effective_start_date >= p_validation_start_date;
96     --
97     ben_cct_shd.g_api_dml := false;   -- Unset the api dml status
98   End If;
99   --
100   hr_utility.set_location(' Leaving:'||l_proc, 20);
101 --
102 Exception
103   When Others Then
104     ben_cct_shd.g_api_dml := false;   -- Unset the api dml status
105     Raise;
106 End dt_delete_dml;
107 --
108 -- ----------------------------------------------------------------------------
109 -- |------------------------------< delete_dml >------------------------------|
110 -- ----------------------------------------------------------------------------
111 Procedure delete_dml
112 	(p_rec 			 in out nocopy ben_cct_shd.g_rec_type,
113 	 p_effective_date	 in	date,
114 	 p_datetrack_mode	 in	varchar2,
115 	 p_validation_start_date in	date,
116 	 p_validation_end_date	 in	date) is
117 --
118   l_proc	varchar2(72) := g_package||'delete_dml';
119 --
120 Begin
121   hr_utility.set_location('Entering:'||l_proc, 5);
122   --
123   dt_delete_dml(p_rec			=> p_rec,
124 		p_effective_date	=> p_effective_date,
125 		p_datetrack_mode	=> p_datetrack_mode,
126        		p_validation_start_date	=> p_validation_start_date,
127 		p_validation_end_date	=> p_validation_end_date);
128   --
129   hr_utility.set_location(' Leaving:'||l_proc, 10);
130 End delete_dml;
131 --
132 -- ----------------------------------------------------------------------------
133 -- |----------------------------< dt_pre_delete >-----------------------------|
134 -- ----------------------------------------------------------------------------
135 -- {Start Of Comments}
136 --
137 -- Description:
138 --   The dt_pre_delete process controls the execution of dml
139 --   for the datetrack modes: DELETE, FUTURE_CHANGE
140 --   and DELETE_NEXT_CHANGE only.
141 --
142 -- Prerequisites:
143 --   This is an internal procedure which is called from the pre_delete
144 --   procedure.
145 --
146 -- In Parameters:
147 --   A Pl/Sql record structre.
148 --
149 -- Post Success:
150 --   Processing continues.
151 --
152 -- Post Failure:
153 --   If an error has occurred, an error message and exception will be raised
154 --   but not handled.
155 --
156 -- Developer Implementation Notes:
157 --   This is an internal procedure which is required by Datetrack. Don't
158 --   remove or modify.
159 --
160 -- Access Status:
161 --   Internal Row Handler Use Only.
162 --
163 -- {End Of Comments}
164 -- ----------------------------------------------------------------------------
165 Procedure dt_pre_delete
166 	(p_rec 			 in out nocopy ben_cct_shd.g_rec_type,
167 	 p_effective_date	 in	date,
168 	 p_datetrack_mode	 in	varchar2,
169 	 p_validation_start_date in	date,
170 	 p_validation_end_date	 in	date) is
171 --
172   l_proc	varchar2(72) := g_package||'dt_pre_delete';
173 --
174 Begin
175   hr_utility.set_location('Entering:'||l_proc, 5);
176   --
177   If (p_datetrack_mode <> 'ZAP') then
178     --
179     p_rec.effective_start_date := ben_cct_shd.g_old_rec.effective_start_date;
180     --
181     If (p_datetrack_mode = 'DELETE') then
182       p_rec.effective_end_date := p_validation_start_date - 1;
183     Else
184       p_rec.effective_end_date := p_validation_end_date;
185     End If;
186     --
187     -- Update the current effective end date record
188     --
189     ben_cct_shd.upd_effective_end_date
190       (p_effective_date	        => p_effective_date,
191        p_base_key_value	        => p_rec.cm_typ_id,
192        p_new_effective_end_date => p_rec.effective_end_date,
193        p_validation_start_date  => p_validation_start_date,
194        p_validation_end_date	=> p_validation_end_date,
195        p_object_version_number  => p_rec.object_version_number);
196   Else
197     p_rec.effective_start_date := null;
198     p_rec.effective_end_date   := null;
199   End If;
200   hr_utility.set_location(' Leaving:'||l_proc, 10);
201 End dt_pre_delete;
202 --
203 -- ----------------------------------------------------------------------------
204 -- |------------------------------< pre_delete >------------------------------|
205 -- ----------------------------------------------------------------------------
206 -- {Start Of Comments}
207 --
208 -- Description:
209 --   This private procedure contains any processing which is required before
210 --   the delete dml.
211 --
212 -- Prerequisites:
213 --   This is an internal procedure which is called from the del procedure.
214 --
215 -- In Parameters:
216 --   A Pl/Sql record structre.
217 --
218 -- Post Success:
219 --   Processing continues.
220 --
221 -- Post Failure:
222 --   If an error has occurred, an error message and exception will be raised
223 --   but not handled.
224 --
225 -- Developer Implementation Notes:
226 --   Any pre-processing required before the delete dml is issued should be
227 --   coded within this procedure. It is important to note that any 3rd party
228 --   maintenance should be reviewed before placing in this procedure. The call
229 --   to the dt_delete_dml procedure should NOT be removed.
230 --
231 -- Access Status:
232 --   Internal Row Handler Use Only.
233 --
234 -- {End Of Comments}
235 -- ----------------------------------------------------------------------------
236 Procedure pre_delete
237 	(p_rec 			 in out nocopy ben_cct_shd.g_rec_type,
238 	 p_effective_date	 in	date,
239 	 p_datetrack_mode	 in	varchar2,
240 	 p_validation_start_date in	date,
241 	 p_validation_end_date	 in	date) is
242 --
243   l_proc	varchar2(72) := g_package||'pre_delete';
244 --
245   --
246 --
247 Begin
248   hr_utility.set_location('Entering:'||l_proc, 5);
249   --
250   --
251   --
252   dt_pre_delete
253     (p_rec 		     => p_rec,
254      p_effective_date	     => p_effective_date,
255      p_datetrack_mode	     => p_datetrack_mode,
256      p_validation_start_date => p_validation_start_date,
257      p_validation_end_date   => p_validation_end_date);
258   --
259   hr_utility.set_location(' Leaving:'||l_proc, 10);
260 End pre_delete;
261 --
262 -- ----------------------------------------------------------------------------
263 -- |-----------------------------< post_delete >------------------------------|
264 -- ----------------------------------------------------------------------------
265 -- {Start Of Comments}
266 --
267 -- Description:
268 --   This private procedure contains any processing which is required after the
269 --   delete dml.
270 --
271 -- Prerequisites:
272 --   This is an internal procedure which is called from the del procedure.
273 --
274 -- In Parameters:
275 --   A Pl/Sql record structre.
276 --
277 -- Post Success:
278 --   Processing continues.
279 --
280 -- Post Failure:
281 --   If an error has occurred, an error message and exception will be raised
282 --   but not handled.
283 --
284 -- Developer Implementation Notes:
285 --   Any post-processing required after the delete dml is issued should be
286 --   coded within this procedure. It is important to note that any 3rd party
287 --   maintenance should be reviewed before placing in this procedure.
288 --
289 -- Access Status:
290 --   Internal Row Handler Use Only.
291 --
292 -- {End Of Comments}
293 -- ----------------------------------------------------------------------------
294 Procedure post_delete
295 	(p_rec 			 in ben_cct_shd.g_rec_type,
296 	 p_effective_date	 in date,
297 	 p_datetrack_mode	 in varchar2,
298 	 p_validation_start_date in date,
299 	 p_validation_end_date	 in date) is
300 --
301   l_proc	varchar2(72) := g_package||'post_delete';
302 --
303 Begin
304   hr_utility.set_location('Entering:'||l_proc, 5);
305 --
306   --
307   -- Start of API User Hook for post_delete.
308   --
309   begin
310     --
311     ben_cct_rkd.after_delete
312       (p_cm_typ_id                     =>p_rec.cm_typ_id
313       ,p_datetrack_mode                =>p_datetrack_mode
314       ,p_validation_start_date         =>p_validation_start_date
315       ,p_validation_end_date           =>p_validation_end_date
316       ,p_effective_start_date          =>p_rec.effective_start_date
317       ,p_effective_end_date            =>p_rec.effective_end_date
318       ,p_effective_start_date_o        =>ben_cct_shd.g_old_rec.effective_start_date
319       ,p_effective_end_date_o          =>ben_cct_shd.g_old_rec.effective_end_date
320       ,p_name_o                        =>ben_cct_shd.g_old_rec.name
321       ,p_desc_txt_o                    =>ben_cct_shd.g_old_rec.desc_txt
322       ,p_cm_typ_rl_o                   =>ben_cct_shd.g_old_rec.cm_typ_rl
323       ,p_cm_usg_cd_o                   =>ben_cct_shd.g_old_rec.cm_usg_cd
324       ,p_whnvr_trgrd_flag_o            =>ben_cct_shd.g_old_rec.whnvr_trgrd_flag
325       ,p_shrt_name_o                   =>ben_cct_shd.g_old_rec.shrt_name
326       ,p_pc_kit_cd_o                   =>ben_cct_shd.g_old_rec.pc_kit_cd
327       ,p_trk_mlg_flag_o                =>ben_cct_shd.g_old_rec.trk_mlg_flag
328       ,p_mx_num_avlbl_val_o            =>ben_cct_shd.g_old_rec.mx_num_avlbl_val
329       ,p_to_be_sent_dt_cd_o            =>ben_cct_shd.g_old_rec.to_be_sent_dt_cd
330       ,p_to_be_sent_dt_rl_o            =>ben_cct_shd.g_old_rec.to_be_sent_dt_rl
331       ,p_inspn_rqd_flag_o              =>ben_cct_shd.g_old_rec.inspn_rqd_flag
332       ,p_inspn_rqd_rl_o                =>ben_cct_shd.g_old_rec.inspn_rqd_rl
333       ,p_rcpent_cd_o                   =>ben_cct_shd.g_old_rec.rcpent_cd
334       ,p_parnt_cm_typ_id_o             =>ben_cct_shd.g_old_rec.parnt_cm_typ_id
335       ,p_business_group_id_o           =>ben_cct_shd.g_old_rec.business_group_id
336       ,p_cct_attribute_category_o      =>ben_cct_shd.g_old_rec.cct_attribute_category
337       ,p_cct_attribute1_o              =>ben_cct_shd.g_old_rec.cct_attribute1
338       ,p_cct_attribute10_o             =>ben_cct_shd.g_old_rec.cct_attribute10
339       ,p_cct_attribute11_o             =>ben_cct_shd.g_old_rec.cct_attribute11
340       ,p_cct_attribute12_o             =>ben_cct_shd.g_old_rec.cct_attribute12
341       ,p_cct_attribute13_o             =>ben_cct_shd.g_old_rec.cct_attribute13
342       ,p_cct_attribute14_o             =>ben_cct_shd.g_old_rec.cct_attribute14
343       ,p_cct_attribute15_o             =>ben_cct_shd.g_old_rec.cct_attribute15
344       ,p_cct_attribute16_o             =>ben_cct_shd.g_old_rec.cct_attribute16
345       ,p_cct_attribute17_o             =>ben_cct_shd.g_old_rec.cct_attribute17
346       ,p_cct_attribute18_o             =>ben_cct_shd.g_old_rec.cct_attribute18
347       ,p_cct_attribute19_o             =>ben_cct_shd.g_old_rec.cct_attribute19
348       ,p_cct_attribute2_o              =>ben_cct_shd.g_old_rec.cct_attribute2
349       ,p_cct_attribute20_o             =>ben_cct_shd.g_old_rec.cct_attribute20
350       ,p_cct_attribute21_o             =>ben_cct_shd.g_old_rec.cct_attribute21
351       ,p_cct_attribute22_o             =>ben_cct_shd.g_old_rec.cct_attribute22
352       ,p_cct_attribute23_o             =>ben_cct_shd.g_old_rec.cct_attribute23
353       ,p_cct_attribute24_o             =>ben_cct_shd.g_old_rec.cct_attribute24
354       ,p_cct_attribute25_o             =>ben_cct_shd.g_old_rec.cct_attribute25
355       ,p_cct_attribute26_o             =>ben_cct_shd.g_old_rec.cct_attribute26
356       ,p_cct_attribute27_o             =>ben_cct_shd.g_old_rec.cct_attribute27
357       ,p_cct_attribute28_o             =>ben_cct_shd.g_old_rec.cct_attribute28
358       ,p_cct_attribute29_o             =>ben_cct_shd.g_old_rec.cct_attribute29
359       ,p_cct_attribute3_o              =>ben_cct_shd.g_old_rec.cct_attribute3
360       ,p_cct_attribute30_o             =>ben_cct_shd.g_old_rec.cct_attribute30
361       ,p_cct_attribute4_o              =>ben_cct_shd.g_old_rec.cct_attribute4
362       ,p_cct_attribute5_o              =>ben_cct_shd.g_old_rec.cct_attribute5
363       ,p_cct_attribute6_o              =>ben_cct_shd.g_old_rec.cct_attribute6
364       ,p_cct_attribute7_o              =>ben_cct_shd.g_old_rec.cct_attribute7
365       ,p_cct_attribute8_o              =>ben_cct_shd.g_old_rec.cct_attribute8
366       ,p_cct_attribute9_o              =>ben_cct_shd.g_old_rec.cct_attribute9
367       ,p_object_version_number_o       =>ben_cct_shd.g_old_rec.object_version_number);
368     --
369   exception
370     --
371     when hr_api.cannot_find_prog_unit then
372       --
373       hr_api.cannot_find_prog_unit_error
374         (p_module_name => 'ben_cm_typ_f'
375         ,p_hook_type   => 'AD');
376       --
377   end;
378   --
379   -- End of API User Hook for post_delete.
380   --
381   --
385 -- ----------------------------------------------------------------------------
382   hr_utility.set_location(' Leaving:'||l_proc, 10);
383 End post_delete;
384 --
386 -- |---------------------------------< del >----------------------------------|
387 -- ----------------------------------------------------------------------------
388 Procedure del
389   (
390   p_rec			in out nocopy 	ben_cct_shd.g_rec_type,
391   p_effective_date	in 	date,
392   p_datetrack_mode	in 	varchar2
393   ) is
394 --
395   l_proc			varchar2(72) := g_package||'del';
396   l_validation_start_date	date;
397   l_validation_end_date		date;
398 --
399 Begin
400   hr_utility.set_location('Entering:'||l_proc, 5);
401   --
402   -- Ensure that the DateTrack delete mode is valid
403   --
404   dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
405   --
406   -- We must lock the row which we need to delete.
407   --
408   ben_cct_shd.lck
409 	(p_effective_date	 => p_effective_date,
410       	 p_datetrack_mode	 => p_datetrack_mode,
411       	 p_cm_typ_id	 => p_rec.cm_typ_id,
412       	 p_object_version_number => p_rec.object_version_number,
413       	 p_validation_start_date => l_validation_start_date,
414       	 p_validation_end_date	 => l_validation_end_date);
415   --
416   -- Call the supporting delete validate operation
417   --
418   ben_cct_bus.delete_validate
419 	(p_rec			 => p_rec,
420 	 p_effective_date	 => p_effective_date,
421 	 p_datetrack_mode	 => p_datetrack_mode,
422 	 p_validation_start_date => l_validation_start_date,
423 	 p_validation_end_date	 => l_validation_end_date);
424   --
425   -- Call the supporting pre-delete operation
426   --
427   pre_delete
428 	(p_rec			 => p_rec,
429 	 p_effective_date	 => p_effective_date,
430 	 p_datetrack_mode	 => p_datetrack_mode,
431 	 p_validation_start_date => l_validation_start_date,
432 	 p_validation_end_date	 => l_validation_end_date);
433   --
434   -- Delete the row.
435   --
436   delete_dml
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   -- Call the supporting post-delete operation
444   --
445   post_delete
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 End del;
452 --
453 -- ----------------------------------------------------------------------------
454 -- |---------------------------------< del >----------------------------------|
455 -- ----------------------------------------------------------------------------
456 Procedure del
457   (
458   p_cm_typ_id	  in 	 number,
459   p_effective_start_date     out nocopy date,
460   p_effective_end_date	     out nocopy date,
461   p_object_version_number in out nocopy number,
462   p_effective_date	  in     date,
463   p_datetrack_mode  	  in     varchar2
464   ) is
465 --
466   l_rec		ben_cct_shd.g_rec_type;
467   l_proc	varchar2(72) := g_package||'del';
468 --
469 Begin
470   hr_utility.set_location('Entering:'||l_proc, 5);
471   --
472   -- As the delete procedure accepts a plsql record structure we do need to
473   -- convert the  arguments into the record structure.
474   -- We don't need to call the supplied conversion argument routine as we
475   -- only need a few attributes.
476   --
477   l_rec.cm_typ_id		:= p_cm_typ_id;
478   l_rec.object_version_number 	:= p_object_version_number;
479   --
480   -- Having converted the arguments into the ben_cct_rec
481   -- plsql record structure we must call the corresponding entity
482   -- business process
483   --
484   del(l_rec, p_effective_date, p_datetrack_mode);
485   --
486   -- Set the out arguments
487   --
488   p_object_version_number := l_rec.object_version_number;
489   p_effective_start_date  := l_rec.effective_start_date;
490   p_effective_end_date    := l_rec.effective_end_date;
491   --
492   hr_utility.set_location(' Leaving:'||l_proc, 10);
493 End del;
494 --
495 end ben_cct_del;