1 Package Body ame_itu_del as
2 /* $Header: amiturhi.pkb 120.6 2006/10/05 16:11:40 pvelugul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ame_itu_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 ame_itu_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 ame_item_class_usages
72 where item_class_id = p_rec.item_class_id
73 and application_id = p_rec.application_id
74 and start_date = p_validation_start_date;
75 --
76 --
77 /*Else
78 --
79 --
80 -- Delete the row(s) where the effective start date is greater than
81 -- or equal to the validation start date.
82 --
83 delete from ame_item_class_usages
84 where item_class_id = p_rec.item_class_id
85 and application_id = p_rec.application_id
86 and start_date >= p_validation_start_date;*/
87 --
88 --
89 End If;
90 --
91 hr_utility.set_location(' Leaving:'||l_proc, 20);
92 --
93 End dt_delete_dml;
94 --
95 -- ----------------------------------------------------------------------------
96 -- |------------------------------< delete_dml >------------------------------|
97 -- ----------------------------------------------------------------------------
98 Procedure delete_dml
99 (p_rec in out nocopy ame_itu_shd.g_rec_type
100 ,p_effective_date in date
101 ,p_datetrack_mode in varchar2
102 ,p_validation_start_date in date
103 ,p_validation_end_date in date
104 ) is
105 --
106 l_proc varchar2(72) := g_package||'delete_dml';
107 --
108 Begin
109 hr_utility.set_location('Entering:'||l_proc, 5);
110 --
111 ame_itu_del.dt_delete_dml
112 (p_rec => p_rec
113 ,p_effective_date => p_effective_date
114 ,p_datetrack_mode => p_datetrack_mode
115 ,p_validation_start_date => p_validation_start_date
116 ,p_validation_end_date => p_validation_end_date
117 );
118 --
119 hr_utility.set_location(' Leaving:'||l_proc, 10);
120 End delete_dml;
121 --
122 -- ----------------------------------------------------------------------------
123 -- |----------------------------< dt_pre_delete >-----------------------------|
124 -- ----------------------------------------------------------------------------
125 -- {Start Of Comments}
126 --
127 -- Description:
128 -- The dt_pre_delete process controls the execution of dml
129 -- for the datetrack modes: DELETE, FUTURE_CHANGE
130 -- and DELETE_NEXT_CHANGE only.
131 --
132 -- Prerequisites:
133 -- This is an internal procedure which is called from the pre_delete
134 -- procedure.
135 --
136 -- In Parameters:
137 -- A Pl/Sql record structure.
138 --
139 -- Post Success:
140 -- Processing continues.
141 --
142 -- Post Failure:
143 -- If an error has occurred, an error message and exception will be raised
144 -- but not handled.
145 --
146 -- Developer Implementation Notes:
147 -- This is an internal procedure which is required by Datetrack. Don't
148 -- remove or modify.
149 --
150 -- Access Status:
151 -- Internal Row Handler Use Only.
152 --
153 -- {End Of Comments}
154 -- ----------------------------------------------------------------------------
155 Procedure dt_pre_delete
156 (p_rec in out nocopy ame_itu_shd.g_rec_type
157 ,p_effective_date in date
158 ,p_datetrack_mode in varchar2
159 ,p_validation_start_date in date
160 ,p_validation_end_date in date
161 ) is
162 --
163 l_proc varchar2(72) := g_package||'dt_pre_delete';
164 --
165 Begin
166 hr_utility.set_location('Entering:'||l_proc, 5);
167 --
168 If (p_datetrack_mode <> hr_api.g_zap) then
169 --
170 p_rec.start_date
171 := ame_itu_shd.g_old_rec.start_date;
172 --
173 If (p_datetrack_mode = hr_api.g_delete) then
174 p_rec.end_date := p_validation_start_date;
175 Else
176 p_rec.end_date := p_validation_end_date;
177 End If;
178 --
179 -- Update the current effective end date record
180 --
181 ame_itu_shd.upd_effective_end_date
182 (p_effective_date => p_effective_date
183 ,p_item_class_id => p_rec.item_class_id
184 ,p_application_id => p_rec.application_id
185 ,p_new_effective_end_date => p_rec.end_date
186 ,p_validation_start_date => p_validation_start_date
187 ,p_validation_end_date => p_validation_end_date
188 ,p_object_version_number => p_rec.object_version_number
189 );
190 Else
191 p_rec.start_date := null;
192 p_rec.end_date := null;
193 End If;
194 hr_utility.set_location(' Leaving:'||l_proc, 10);
195 End dt_pre_delete;
196 --
197 -- ----------------------------------------------------------------------------
198 -- |------------------------------< pre_delete >------------------------------|
199 -- ----------------------------------------------------------------------------
200 -- {Start Of Comments}
201 --
202 -- Description:
203 -- This private procedure contains any processing which is required before
204 -- the delete dml.
205 --
206 -- Prerequisites:
207 -- This is an internal procedure which is called from the del procedure.
208 --
209 -- In Parameters:
210 -- A Pl/Sql record structure.
211 --
212 -- Post Success:
213 -- Processing continues.
214 --
215 -- Post Failure:
216 -- If an error has occurred, an error message and exception will be raised
217 -- but not handled.
218 --
219 -- Developer Implementation Notes:
220 -- Any pre-processing required before the delete dml is issued should be
221 -- coded within this procedure. It is important to note that any 3rd party
222 -- maintenance should be reviewed before placing in this procedure. The call
223 -- to the dt_delete_dml procedure should NOT be removed.
224 --
225 -- Access Status:
226 -- Internal Row Handler Use Only.
227 --
228 -- {End Of Comments}
229 -- ----------------------------------------------------------------------------
230 Procedure pre_delete
231 (p_rec in out nocopy ame_itu_shd.g_rec_type
232 ,p_effective_date in date
233 ,p_datetrack_mode in varchar2
234 ,p_validation_start_date in date
235 ,p_validation_end_date in date
236 ) is
237 --
238 l_proc varchar2(72) := g_package||'pre_delete';
239 --
240 --
241 --
242 Begin
243 hr_utility.set_location('Entering:'||l_proc, 5);
244 --
245 --
246 --
247 ame_itu_del.dt_pre_delete
248 (p_rec => p_rec
249 ,p_effective_date => p_effective_date
250 ,p_datetrack_mode => p_datetrack_mode
251 ,p_validation_start_date => p_validation_start_date
252 ,p_validation_end_date => p_validation_end_date
253 );
254 --
255 hr_utility.set_location(' Leaving:'||l_proc, 10);
256 End pre_delete;
257 --
258 -- ----------------------------------------------------------------------------
259 -- |----------------------------< post_delete >-------------------------------|
260 -- ----------------------------------------------------------------------------
261 -- {Start Of Comments}
262 --
263 -- Description:
264 -- This private procedure contains any processing which is required after
265 -- the delete dml.
266 --
267 -- Prerequisites:
268 -- This is an internal procedure which is called from the del procedure.
269 --
270 -- In Parameters:
271 -- A Pl/Sql record structure.
272 --
273 -- Post Success:
274 -- Processing continues.
275 --
276 -- Post Failure:
277 -- If an error has occurred, an error message and exception will be raised
278 -- but not handled.
279 --
280 -- Developer Implementation Notes:
281 -- Any post-processing required after the delete dml is issued should be
282 -- coded within this procedure. It is important to note that any 3rd party
283 -- maintenance should be reviewed before placing in this procedure.
284 --
285 -- Access Status:
286 -- Internal Row Handler Use Only.
287 --
288 -- {End Of Comments}
289 -- ----------------------------------------------------------------------------
290 Procedure post_delete
291 (p_rec in ame_itu_shd.g_rec_type
292 ,p_effective_date in date
293 ,p_datetrack_mode in varchar2
294 ,p_validation_start_date in date
295 ,p_validation_end_date in date
296 ) is
297 --
298 l_proc varchar2(72) := g_package||'post_delete';
299 --
300 Begin
301 hr_utility.set_location('Entering:'||l_proc, 5);
302 begin
303 --
304 ame_itu_rkd.after_delete
305 (p_effective_date => p_effective_date
306 ,p_datetrack_mode => p_datetrack_mode
307 ,p_validation_start_date => p_validation_start_date
308 ,p_validation_end_date => p_validation_end_date
309 ,p_application_id => p_rec.application_id
310 ,p_item_class_id => p_rec.item_class_id
311 ,p_start_date => p_rec.start_date
312 ,p_end_date => p_rec.end_date
313 ,p_item_id_query_o => ame_itu_shd.g_old_rec.item_id_query
314 ,p_item_class_order_number_o => ame_itu_shd.g_old_rec.item_class_order_number
315 ,p_item_class_par_mode_o => ame_itu_shd.g_old_rec.item_class_par_mode
316 ,p_item_class_sublist_mode_o => ame_itu_shd.g_old_rec.item_class_sublist_mode
317 ,p_start_date_o => ame_itu_shd.g_old_rec.start_date
318 ,p_end_date_o => ame_itu_shd.g_old_rec.end_date
319 ,p_object_version_number_o => ame_itu_shd.g_old_rec.object_version_number
320 );
321 --
322 exception
323 --
324 when hr_api.cannot_find_prog_unit then
325 --
326 hr_api.cannot_find_prog_unit_error
327 (p_module_name => 'AME_ITEM_CLASS_USAGES'
328 ,p_hook_type => 'AD');
329 --
330 end;
331 --
332 hr_utility.set_location(' Leaving:'||l_proc, 10);
333 End post_delete;
334 --
335 -- ----------------------------------------------------------------------------
336 -- |---------------------------------< del >----------------------------------|
337 -- ----------------------------------------------------------------------------
338 Procedure del
339 (p_effective_date in date
340 ,p_datetrack_mode in varchar2
341 ,p_rec in out nocopy ame_itu_shd.g_rec_type
342 ) is
343 --
344 l_proc varchar2(72) := g_package||'del';
345 l_validation_start_date date;
346 l_validation_end_date date;
347 --
348 Begin
349 hr_utility.set_location('Entering:'||l_proc, 5);
350 --
351 -- Ensure that the DateTrack delete mode is valid
352 --
353 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
354 --
355 -- We must lock the row which we need to delete.
356 --
357 ame_itu_shd.lck
358 (p_effective_date => p_effective_date
359 ,p_datetrack_mode => p_datetrack_mode
360 ,p_item_class_id => p_rec.item_class_id
361 ,p_application_id => p_rec.application_id
362 ,p_object_version_number => p_rec.object_version_number
363 ,p_validation_start_date => l_validation_start_date
364 ,p_validation_end_date => l_validation_end_date
365 );
366 --
367 -- Call the supporting delete validate operation
368 --
369 ame_itu_bus.delete_validate
370 (p_rec => p_rec
371 ,p_effective_date => p_effective_date
372 ,p_datetrack_mode => p_datetrack_mode
373 ,p_validation_start_date => l_validation_start_date
374 ,p_validation_end_date => l_validation_end_date
375 );
376 --
377 -- Call to raise any errors on multi-message list
378 hr_multi_message.end_validation_set;
379 --
380 -- Call the supporting pre-delete operation
381 --
382 ame_itu_del.pre_delete
383 (p_rec => p_rec
384 ,p_effective_date => p_effective_date
385 ,p_datetrack_mode => p_datetrack_mode
386 ,p_validation_start_date => l_validation_start_date
387 ,p_validation_end_date => l_validation_end_date
388 );
389 --
390 -- Delete the row.
391 --
392 ame_itu_del.delete_dml
393 (p_rec => p_rec
394 ,p_effective_date => p_effective_date
395 ,p_datetrack_mode => p_datetrack_mode
396 ,p_validation_start_date => l_validation_start_date
397 ,p_validation_end_date => l_validation_end_date
398 );
399 -- Call the supporting post-delete operation
400 --
404 ,p_datetrack_mode => p_datetrack_mode
401 ame_itu_del.post_delete
402 (p_rec => p_rec
403 ,p_effective_date => p_effective_date
405 ,p_validation_start_date => l_validation_start_date
406 ,p_validation_end_date => l_validation_end_date
407 );
408 --
409 -- Call to raise any errors on multi-message list
410 hr_multi_message.end_validation_set;
411 --
412 hr_utility.set_location(' Leaving:'||l_proc, 5);
413 End del;
414 --
415 -- ----------------------------------------------------------------------------
416 -- |--------------------------------< del >-----------------------------------|
417 -- ----------------------------------------------------------------------------
418 Procedure del
419 (p_effective_date in date
420 ,p_datetrack_mode in varchar2
421 ,p_application_id in number
422 ,p_item_class_id in number
423 ,p_object_version_number in out nocopy number
424 ,p_start_date out nocopy date
425 ,p_end_date out nocopy date
426 ) is
427 --
428 l_rec ame_itu_shd.g_rec_type;
429 l_proc varchar2(72) := g_package||'del';
430 --
431 Begin
432 hr_utility.set_location('Entering:'||l_proc, 5);
433 --
434 -- As the delete procedure accepts a plsql record structure we do need to
435 -- convert the arguments into the record structure.
436 -- We don't need to call the supplied conversion argument routine as we
437 -- only need a few attributes.
438 --
439 l_rec.item_class_id := p_item_class_id;
440 l_rec.application_id := p_application_id;
441 l_rec.start_date := p_start_date;
442 l_rec.end_date := p_end_date;
443 l_rec.object_version_number:= p_object_version_number;
444 --
445 -- Having converted the arguments into the ame_itu_rec
446 -- plsql record structure we must call the corresponding entity
447 -- business process
448 --
449 ame_itu_del.del
450 (p_effective_date
451 ,p_datetrack_mode
452 ,l_rec
453 );
454 --
455 --
456 -- Set the out arguments
457 --
458 p_object_version_number := l_rec.object_version_number;
459 p_start_date := l_rec.start_date;
460 p_end_date := l_rec.end_date;
461 --
462 hr_utility.set_location(' Leaving:'||l_proc, 10);
463 End del;
464 --
465 end ame_itu_del;