1 Package Body ff_fgl_del as
2 /* $Header: fffglrhi.pkb 120.0.12000000.1 2007/03/20 11:52:47 ckesanap noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ff_fgl_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 ff_fgl_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 ff_fgl_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 ff_globals_f
72 where global_id = p_rec.global_id
73 and effective_start_date = p_validation_start_date;
74 --
75 ff_fgl_shd.g_api_dml := false; -- Unset the api dml status
76 Else
77 ff_fgl_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 ff_globals_f
83 where global_id = p_rec.global_id
84 and effective_start_date >= p_validation_start_date;
85 --
86 ff_fgl_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 ff_fgl_shd.g_api_dml := false; -- Unset the api dml status
94 Raise;
95 --
96 End dt_delete_dml;
97 --
98 -- ----------------------------------------------------------------------------
99 -- ----------------------< delete_app_ownerships >----------------------------|
100 -- ----------------------------------------------------------------------------
101 --
102 -- Description:
103 -- Deletes row(s) from hr_application_ownerships depending on the mode that
104 -- the row handler has been called in.
105 --
106 -- ----------------------------------------------------------------------------
107 PROCEDURE delete_app_ownerships(p_pk_column IN varchar2
108 ,p_pk_value IN varchar2
109 ,p_datetrack_mode IN varchar2) IS
110 --
111 BEGIN
112 --
113 IF ((hr_startup_data_api_support.return_startup_mode
114 IN ('STARTUP','GENERIC')) AND
115 p_datetrack_mode = 'ZAP') THEN
116 --
117 DELETE FROM hr_application_ownerships
118 WHERE key_name = p_pk_column
119 AND key_value = p_pk_value;
120 --
121 END IF;
122 END delete_app_ownerships;
123 --
124 -- ----------------------------------------------------------------------------
125 -- ----------------------< delete_app_ownerships >----------------------------|
126 -- ----------------------------------------------------------------------------
127 PROCEDURE delete_app_ownerships(p_pk_column IN varchar2
128 ,p_pk_value IN number
129 ,p_datetrack_mode IN varchar2) IS
130 --
131 BEGIN
132 delete_app_ownerships(p_pk_column,
133 to_char(p_pk_value),
134 p_datetrack_mode
135 );
136 END delete_app_ownerships;
137 --
138 -- ----------------------------------------------------------------------------
139 -- |------------------------------< delete_dml >------------------------------|
140 -- ----------------------------------------------------------------------------
141 Procedure delete_dml
142 (p_rec in out nocopy ff_fgl_shd.g_rec_type
143 ,p_effective_date in date
144 ,p_datetrack_mode in varchar2
145 ,p_validation_start_date in date
146 ,p_validation_end_date in date
147 ) is
148 --
149 l_proc varchar2(72) := g_package||'delete_dml';
150 --
151 Begin
152 hr_utility.set_location('Entering:'||l_proc, 5);
153 --
154 ff_fgl_del.dt_delete_dml
155 (p_rec => p_rec
156 ,p_effective_date => p_effective_date
157 ,p_datetrack_mode => p_datetrack_mode
158 ,p_validation_start_date => p_validation_start_date
159 ,p_validation_end_date => p_validation_end_date
160 );
161 --
162 hr_utility.set_location(' Leaving:'||l_proc, 10);
163 End delete_dml;
164 --
165 -- ----------------------------------------------------------------------------
166 -- |----------------------------< dt_pre_delete >-----------------------------|
167 -- ----------------------------------------------------------------------------
168 -- {Start Of Comments}
169 --
170 -- Description:
171 -- The dt_pre_delete process controls the execution of dml
172 -- for the datetrack modes: DELETE, FUTURE_CHANGE
173 -- and DELETE_NEXT_CHANGE only.
174 --
175 -- Prerequisites:
176 -- This is an internal procedure which is called from the pre_delete
177 -- procedure.
178 --
179 -- In Parameters:
180 -- A Pl/Sql record structure.
181 --
182 -- Post Success:
183 -- Processing continues.
184 --
185 -- Post Failure:
186 -- If an error has occurred, an error message and exception will be raised
187 -- but not handled.
188 --
189 -- Developer Implementation Notes:
190 -- This is an internal procedure which is required by Datetrack. Don't
191 -- remove or modify.
192 --
193 -- Access Status:
194 -- Internal Row Handler Use Only.
195 --
196 -- {End Of Comments}
197 -- ----------------------------------------------------------------------------
198 Procedure dt_pre_delete
199 (p_rec in out nocopy ff_fgl_shd.g_rec_type
200 ,p_effective_date in date
201 ,p_datetrack_mode in varchar2
202 ,p_validation_start_date in date
203 ,p_validation_end_date in date
204 ) is
205 --
206 l_proc varchar2(72) := g_package||'dt_pre_delete';
207 --
208 Begin
209 hr_utility.set_location('Entering:'||l_proc, 5);
210 --
211 If (p_datetrack_mode <> hr_api.g_zap) then
212 --
213 p_rec.effective_start_date
214 := ff_fgl_shd.g_old_rec.effective_start_date;
215 --
216 If (p_datetrack_mode = hr_api.g_delete) then
217 p_rec.effective_end_date := p_validation_start_date - 1;
218 Else
219 p_rec.effective_end_date := p_validation_end_date;
220 End If;
221 --
222 -- Update the current effective end date record
223 --
224 ff_fgl_shd.upd_effective_end_date
225 (p_effective_date => p_effective_date
226 ,p_base_key_value => p_rec.global_id
227 ,p_new_effective_end_date => p_rec.effective_end_date
228 ,p_validation_start_date => p_validation_start_date
229 ,p_validation_end_date => p_validation_end_date
230 ,p_object_version_number => p_rec.object_version_number
231 );
232 Else
233 p_rec.effective_start_date := null;
234 p_rec.effective_end_date := null;
235 End If;
236 hr_utility.set_location(' Leaving:'||l_proc, 10);
237 End dt_pre_delete;
238 --
239 -- ----------------------------------------------------------------------------
240 -- |------------------------------< pre_delete >------------------------------|
241 -- ----------------------------------------------------------------------------
242 -- {Start Of Comments}
243 --
244 -- Description:
245 -- This private procedure contains any processing which is required before
246 -- the delete dml.
247 --
248 -- Prerequisites:
249 -- This is an internal procedure which is called from the del procedure.
250 --
251 -- In Parameters:
252 -- A Pl/Sql record structure.
253 --
254 -- Post Success:
255 -- Processing continues.
256 --
257 -- Post Failure:
258 -- If an error has occurred, an error message and exception will be raised
259 -- but not handled.
260 --
261 -- Developer Implementation Notes:
262 -- Any pre-processing required before the delete dml is issued should be
263 -- coded within this procedure. It is important to note that any 3rd party
264 -- maintenance should be reviewed before placing in this procedure. The call
265 -- to the dt_delete_dml procedure should NOT be removed.
266 --
267 -- Access Status:
268 -- Internal Row Handler Use Only.
269 --
270 -- {End Of Comments}
271 -- ----------------------------------------------------------------------------
272 Procedure pre_delete
273 (p_rec in out nocopy ff_fgl_shd.g_rec_type
274 ,p_effective_date in date
275 ,p_datetrack_mode in varchar2
276 ,p_validation_start_date in date
277 ,p_validation_end_date in date
278 ) is
279 --
280 l_proc varchar2(72) := g_package||'pre_delete';
281 --
282 --
283 --
284 Begin
285 hr_utility.set_location('Entering:'||l_proc, 5);
286 --
287 --
288 --
289 ff_fgl_del.dt_pre_delete
290 (p_rec => p_rec
291 ,p_effective_date => p_effective_date
292 ,p_datetrack_mode => p_datetrack_mode
293 ,p_validation_start_date => p_validation_start_date
294 ,p_validation_end_date => p_validation_end_date
295 );
296 --
297 hr_utility.set_location(' Leaving:'||l_proc, 10);
298 End pre_delete;
299 --
300 -- ----------------------------------------------------------------------------
301 -- |----------------------------< post_delete >-------------------------------|
302 -- ----------------------------------------------------------------------------
303 -- {Start Of Comments}
304 --
305 -- Description:
306 -- This private procedure contains any processing which is required after
307 -- the delete dml.
308 --
309 -- Prerequisites:
310 -- This is an internal procedure which is called from the del procedure.
311 --
312 -- In Parameters:
313 -- A Pl/Sql record structure.
314 --
315 -- Post Success:
316 -- Processing continues.
317 --
318 -- Post Failure:
319 -- If an error has occurred, an error message and exception will be raised
320 -- but not handled.
321 --
322 -- Developer Implementation Notes:
323 -- Any post-processing required after the delete dml is issued should be
324 -- coded within this procedure. It is important to note that any 3rd party
325 -- maintenance should be reviewed before placing in this procedure.
326 --
327 -- Access Status:
328 -- Internal Row Handler Use Only.
329 --
330 -- {End Of Comments}
331 -- ----------------------------------------------------------------------------
332 Procedure post_delete
333 (p_rec in ff_fgl_shd.g_rec_type
334 ,p_effective_date in date
335 ,p_datetrack_mode in varchar2
336 ,p_validation_start_date in date
337 ,p_validation_end_date in date
338 ) is
339 --
340 l_proc varchar2(72) := g_package||'post_delete';
341 --
342 Begin
343 hr_utility.set_location('Entering:'||l_proc, 5);
344 begin
345 --
346 -- Delete ownerships if applicable
347 delete_app_ownerships
348 ('GLOBAL_ID', p_rec.global_id
349 ,p_datetrack_mode
350 );
351 --
352 ff_fgl_rkd.after_delete
353 (p_effective_date
354 => p_effective_date
355 ,p_datetrack_mode
356 => p_datetrack_mode
357 ,p_validation_start_date
358 => p_validation_start_date
359 ,p_validation_end_date
360 => p_validation_end_date
361 ,p_global_id
362 => p_rec.global_id
363 ,p_effective_start_date
364 => p_rec.effective_start_date
365 ,p_effective_end_date
366 => p_rec.effective_end_date
367 ,p_effective_start_date_o
368 => ff_fgl_shd.g_old_rec.effective_start_date
369 ,p_effective_end_date_o
370 => ff_fgl_shd.g_old_rec.effective_end_date
371 ,p_business_group_id_o
372 => ff_fgl_shd.g_old_rec.business_group_id
373 ,p_legislation_code_o
374 => ff_fgl_shd.g_old_rec.legislation_code
375 ,p_data_type_o
376 => ff_fgl_shd.g_old_rec.data_type
377 ,p_global_name_o
378 => ff_fgl_shd.g_old_rec.global_name
379 ,p_global_description_o
380 => ff_fgl_shd.g_old_rec.global_description
381 ,p_global_value_o
382 => ff_fgl_shd.g_old_rec.global_value
383 ,p_object_version_number_o
384 => ff_fgl_shd.g_old_rec.object_version_number
385 );
386 --
387 exception
388 --
389 when hr_api.cannot_find_prog_unit then
390 --
391 hr_api.cannot_find_prog_unit_error
392 (p_module_name => 'FF_GLOBALS_F'
393 ,p_hook_type => 'AD');
394 --
395 end;
396 --
397 hr_utility.set_location(' Leaving:'||l_proc, 10);
398 End post_delete;
399 --
400 -- ----------------------------------------------------------------------------
401 -- |---------------------------------< del >----------------------------------|
402 -- ----------------------------------------------------------------------------
403 Procedure del
404 (p_effective_date in date
405 ,p_datetrack_mode in varchar2
406 ,p_rec in out nocopy ff_fgl_shd.g_rec_type
407 ) is
408 --
409 l_proc varchar2(72) := g_package||'del';
410 l_validation_start_date date;
411 l_validation_end_date date;
412
413 --
414 Begin
415 hr_utility.set_location('Entering:'||l_proc, 5);
416 --
417 -- Ensure that the DateTrack delete mode is valid
418 --
419 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
420
421 -- added to check that Only PURGE option is selected. If other Options
422 -- like DELETE, FUTURE_CHANGE, DELETE_NEXT_CHANGE the raise error
423 -- saying invalid datetrack option.
424
425 if p_datetrack_mode <> 'ZAP' then
426 fnd_message.set_name('PAY', 'HR_7204_DT_DEL_MODE_INVALID');
427 fnd_message.raise_error;
428 end if;
429 --
430 -- We must lock the row which we need to delete.
431 ff_fgl_shd.lck
432 (p_effective_date => p_effective_date
433 ,p_datetrack_mode => p_datetrack_mode
434 ,p_global_id => p_rec.global_id
435 ,p_object_version_number => p_rec.object_version_number
436 ,p_validation_start_date => l_validation_start_date
437 ,p_validation_end_date => l_validation_end_date
438 );
439 --
440 -- Call the supporting delete validate operation
441 --
442 ff_fgl_bus.delete_validate
443 (p_rec => p_rec
444 ,p_effective_date => p_effective_date
445 ,p_datetrack_mode => p_datetrack_mode
446 ,p_validation_start_date => l_validation_start_date
447 ,p_validation_end_date => l_validation_end_date
448 );
449 --
450 -- Call to raise any errors on multi-message list
451 hr_multi_message.end_validation_set;
452 --
453 -- Call the supporting pre-delete operation
454 --
455 ff_fgl_del.pre_delete
456 (p_rec => p_rec
457 ,p_effective_date => p_effective_date
458 ,p_datetrack_mode => p_datetrack_mode
459 ,p_validation_start_date => l_validation_start_date
460 ,p_validation_end_date => l_validation_end_date
461 );
462 --
463 -- Delete the row.
464 --
465 ff_fgl_del.delete_dml
466 (p_rec => p_rec
467 ,p_effective_date => p_effective_date
468 ,p_datetrack_mode => p_datetrack_mode
469 ,p_validation_start_date => l_validation_start_date
470 ,p_validation_end_date => l_validation_end_date
471 );
472 -- Call the supporting post-delete operation
473 --
474 ff_fgl_del.post_delete
475 (p_rec => p_rec
476 ,p_effective_date => p_effective_date
477 ,p_datetrack_mode => p_datetrack_mode
478 ,p_validation_start_date => l_validation_start_date
479 ,p_validation_end_date => l_validation_end_date
480 );
481 --
482 -- Call to raise any errors on multi-message list
483 hr_multi_message.end_validation_set;
484 --
485 hr_utility.set_location(' Leaving:'||l_proc, 5);
486 End del;
487 --
488 -- ----------------------------------------------------------------------------
489 -- |--------------------------------< del >-----------------------------------|
490 -- ----------------------------------------------------------------------------
491 Procedure del
492 (p_effective_date in date
493 ,p_datetrack_mode in varchar2
494 ,p_global_id in number
495 ,p_object_version_number in out nocopy number
496 ,p_effective_start_date out nocopy date
497 ,p_effective_end_date out nocopy date
498 ) is
499 --
500 l_rec ff_fgl_shd.g_rec_type;
501 l_proc varchar2(72) := g_package||'del';
502 --
503 Begin
504 hr_utility.set_location('Entering:'||l_proc, 5);
505 --
506 -- As the delete procedure accepts a plsql record structure we do need to
507 -- convert the arguments into the record structure.
508 -- We don't need to call the supplied conversion argument routine as we
509 -- only need a few attributes.
510 --
511 l_rec.global_id := p_global_id;
512 l_rec.object_version_number := p_object_version_number;
513 --
514 -- Having converted the arguments into the ff_pay_rec
515 -- plsql record structure we must call the corresponding entity
516 -- business process
517 --
518 ff_fgl_del.del
522 );
519 (p_effective_date
520 ,p_datetrack_mode
521 ,l_rec
523 --
524 --
525 -- Set the out arguments
526 --
527 p_object_version_number := l_rec.object_version_number;
528 p_effective_start_date := l_rec.effective_start_date;
529 p_effective_end_date := l_rec.effective_end_date;
530 --
531 hr_utility.set_location(' Leaving:'||l_proc, 10);
532 End del;
533 --
534 end ff_fgl_del;