DBA Data[Home] [Help]
Skip to content

PACKAGE BODY: APPS.BEN_CCT_DEL

Source


1 Package Body ben_cct_del as
2 /* $Header: becctrhi.pkb 120.0.12020000.4 2012/07/03 11:57:28 amnaraya ship $ */
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,
117 --
114 	 p_datetrack_mode	 in	varchar2,
115 	 p_validation_start_date in	date,
116 	 p_validation_end_date	 in	date) is
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:
271 -- Prerequisites:
268 --   This private procedure contains any processing which is required after the
269 --   delete dml.
270 --
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_inactive_flag_o                  =>ben_cct_shd.g_old_rec.inactive_flag
323       ,p_cm_typ_rl_o                   =>ben_cct_shd.g_old_rec.cm_typ_rl
324       ,p_cm_usg_cd_o                   =>ben_cct_shd.g_old_rec.cm_usg_cd
325       ,p_whnvr_trgrd_flag_o            =>ben_cct_shd.g_old_rec.whnvr_trgrd_flag
326       ,p_shrt_name_o                   =>ben_cct_shd.g_old_rec.shrt_name
327       ,p_pc_kit_cd_o                   =>ben_cct_shd.g_old_rec.pc_kit_cd
328       ,p_trk_mlg_flag_o                =>ben_cct_shd.g_old_rec.trk_mlg_flag
329       ,p_mx_num_avlbl_val_o            =>ben_cct_shd.g_old_rec.mx_num_avlbl_val
330       ,p_to_be_sent_dt_cd_o            =>ben_cct_shd.g_old_rec.to_be_sent_dt_cd
331       ,p_to_be_sent_dt_rl_o            =>ben_cct_shd.g_old_rec.to_be_sent_dt_rl
332       ,p_inspn_rqd_flag_o              =>ben_cct_shd.g_old_rec.inspn_rqd_flag
333       ,p_inspn_rqd_rl_o                =>ben_cct_shd.g_old_rec.inspn_rqd_rl
334       ,p_rcpent_cd_o                   =>ben_cct_shd.g_old_rec.rcpent_cd
335       ,p_parnt_cm_typ_id_o             =>ben_cct_shd.g_old_rec.parnt_cm_typ_id
336       ,p_business_group_id_o           =>ben_cct_shd.g_old_rec.business_group_id
337       ,p_cct_attribute_category_o      =>ben_cct_shd.g_old_rec.cct_attribute_category
338       ,p_cct_attribute1_o              =>ben_cct_shd.g_old_rec.cct_attribute1
339       ,p_cct_attribute10_o             =>ben_cct_shd.g_old_rec.cct_attribute10
340       ,p_cct_attribute11_o             =>ben_cct_shd.g_old_rec.cct_attribute11
341       ,p_cct_attribute12_o             =>ben_cct_shd.g_old_rec.cct_attribute12
342       ,p_cct_attribute13_o             =>ben_cct_shd.g_old_rec.cct_attribute13
343       ,p_cct_attribute14_o             =>ben_cct_shd.g_old_rec.cct_attribute14
344       ,p_cct_attribute15_o             =>ben_cct_shd.g_old_rec.cct_attribute15
345       ,p_cct_attribute16_o             =>ben_cct_shd.g_old_rec.cct_attribute16
346       ,p_cct_attribute17_o             =>ben_cct_shd.g_old_rec.cct_attribute17
347       ,p_cct_attribute18_o             =>ben_cct_shd.g_old_rec.cct_attribute18
348       ,p_cct_attribute19_o             =>ben_cct_shd.g_old_rec.cct_attribute19
349       ,p_cct_attribute2_o              =>ben_cct_shd.g_old_rec.cct_attribute2
350       ,p_cct_attribute20_o             =>ben_cct_shd.g_old_rec.cct_attribute20
351       ,p_cct_attribute21_o             =>ben_cct_shd.g_old_rec.cct_attribute21
352       ,p_cct_attribute22_o             =>ben_cct_shd.g_old_rec.cct_attribute22
353       ,p_cct_attribute23_o             =>ben_cct_shd.g_old_rec.cct_attribute23
354       ,p_cct_attribute24_o             =>ben_cct_shd.g_old_rec.cct_attribute24
355       ,p_cct_attribute25_o             =>ben_cct_shd.g_old_rec.cct_attribute25
356       ,p_cct_attribute26_o             =>ben_cct_shd.g_old_rec.cct_attribute26
357       ,p_cct_attribute27_o             =>ben_cct_shd.g_old_rec.cct_attribute27
358       ,p_cct_attribute28_o             =>ben_cct_shd.g_old_rec.cct_attribute28
359       ,p_cct_attribute29_o             =>ben_cct_shd.g_old_rec.cct_attribute29
360       ,p_cct_attribute3_o              =>ben_cct_shd.g_old_rec.cct_attribute3
361       ,p_cct_attribute30_o             =>ben_cct_shd.g_old_rec.cct_attribute30
362       ,p_cct_attribute4_o              =>ben_cct_shd.g_old_rec.cct_attribute4
363       ,p_cct_attribute5_o              =>ben_cct_shd.g_old_rec.cct_attribute5
364       ,p_cct_attribute6_o              =>ben_cct_shd.g_old_rec.cct_attribute6
365       ,p_cct_attribute7_o              =>ben_cct_shd.g_old_rec.cct_attribute7
366       ,p_cct_attribute8_o              =>ben_cct_shd.g_old_rec.cct_attribute8
367       ,p_cct_attribute9_o              =>ben_cct_shd.g_old_rec.cct_attribute9
368       ,p_object_version_number_o       =>ben_cct_shd.g_old_rec.object_version_number);
369     --
370   exception
371     --
372     when hr_api.cannot_find_prog_unit then
376         ,p_hook_type   => 'AD');
373       --
374       hr_api.cannot_find_prog_unit_error
375         (p_module_name => 'ben_cm_typ_f'
377       --
378   end;
379   --
380   -- End of API User Hook for post_delete.
381   --
382   --
383   hr_utility.set_location(' Leaving:'||l_proc, 10);
384 End post_delete;
385 --
386 -- ----------------------------------------------------------------------------
387 -- |---------------------------------< del >----------------------------------|
388 -- ----------------------------------------------------------------------------
389 Procedure del
390   (
391   p_rec			in out nocopy 	ben_cct_shd.g_rec_type,
392   p_effective_date	in 	date,
393   p_datetrack_mode	in 	varchar2
394   ) is
395 --
396   l_proc			varchar2(72) := g_package||'del';
397   l_validation_start_date	date;
398   l_validation_end_date		date;
399 --
400 Begin
401   hr_utility.set_location('Entering:'||l_proc, 5);
402   --
403   -- Ensure that the DateTrack delete mode is valid
404   --
405   dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
406   --
407   -- We must lock the row which we need to delete.
408   --
409   ben_cct_shd.lck
410 	(p_effective_date	 => p_effective_date,
411       	 p_datetrack_mode	 => p_datetrack_mode,
412       	 p_cm_typ_id	 => p_rec.cm_typ_id,
413       	 p_object_version_number => p_rec.object_version_number,
414       	 p_validation_start_date => l_validation_start_date,
415       	 p_validation_end_date	 => l_validation_end_date);
416   --
417   -- Call the supporting delete validate operation
418   --
419   ben_cct_bus.delete_validate
420 	(p_rec			 => p_rec,
421 	 p_effective_date	 => p_effective_date,
422 	 p_datetrack_mode	 => p_datetrack_mode,
423 	 p_validation_start_date => l_validation_start_date,
424 	 p_validation_end_date	 => l_validation_end_date);
425   --
426   -- Call the supporting pre-delete operation
427   --
428   pre_delete
429 	(p_rec			 => p_rec,
430 	 p_effective_date	 => p_effective_date,
431 	 p_datetrack_mode	 => p_datetrack_mode,
432 	 p_validation_start_date => l_validation_start_date,
433 	 p_validation_end_date	 => l_validation_end_date);
434   --
435   -- Delete the row.
436   --
437   delete_dml
438 	(p_rec			 => p_rec,
439 	 p_effective_date	 => p_effective_date,
440 	 p_datetrack_mode	 => p_datetrack_mode,
441 	 p_validation_start_date => l_validation_start_date,
442 	 p_validation_end_date	 => l_validation_end_date);
443   --
444   -- Call the supporting post-delete operation
445   --
446   post_delete
447 	(p_rec			 => p_rec,
448 	 p_effective_date	 => p_effective_date,
449 	 p_datetrack_mode	 => p_datetrack_mode,
450 	 p_validation_start_date => l_validation_start_date,
451 	 p_validation_end_date	 => l_validation_end_date);
452 End del;
453 --
454 -- ----------------------------------------------------------------------------
455 -- |---------------------------------< del >----------------------------------|
456 -- ----------------------------------------------------------------------------
457 Procedure del
458   (
459   p_cm_typ_id	  in 	 number,
460   p_effective_start_date     out nocopy date,
461   p_effective_end_date	     out nocopy date,
462   p_object_version_number in out nocopy number,
463   p_effective_date	  in     date,
464   p_datetrack_mode  	  in     varchar2
465   ) is
466 --
467   l_rec		ben_cct_shd.g_rec_type;
468   l_proc	varchar2(72) := g_package||'del';
469 --
470 Begin
471   hr_utility.set_location('Entering:'||l_proc, 5);
472   --
473   -- As the delete procedure accepts a plsql record structure we do need to
474   -- convert the  arguments into the record structure.
475   -- We don't need to call the supplied conversion argument routine as we
476   -- only need a few attributes.
477   --
478   l_rec.cm_typ_id		:= p_cm_typ_id;
482   -- plsql record structure we must call the corresponding entity
479   l_rec.object_version_number 	:= p_object_version_number;
480   --
481   -- Having converted the arguments into the ben_cct_rec
483   -- business process
484   --
485   del(l_rec, p_effective_date, p_datetrack_mode);
486   --
487   -- Set the out arguments
488   --
489   p_object_version_number := l_rec.object_version_number;
490   p_effective_start_date  := l_rec.effective_start_date;
491   p_effective_end_date    := l_rec.effective_end_date;
492   --
493   hr_utility.set_location(' Leaving:'||l_proc, 10);
494 End del;
495 --
496 end ben_cct_del;