1 Package Body pay_grr_del as
2 /* $Header: pygrrrhi.pkb 115.4 2002/12/10 09:48:17 pkakar ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_grr_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_CHANGES 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 -- Pre Conditions:
29 -- This is an internal private procedure which must be called from the
30 -- delete_dml procedure.
31 --
32 -- In Arguments:
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 Table Handler USe Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure dt_delete_dml
54 (p_rec in out nocopy pay_grr_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 pay_grr_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_grade_rules_f
72 where grade_rule_id = p_rec.grade_rule_id
73 and effective_start_date = p_validation_start_date;
74 --
75 pay_grr_shd.g_api_dml := false; -- Unset the api dml status
76 Else
77 hr_utility.set_location(l_proc, 15);
78 pay_grr_shd.g_api_dml := true; -- Set the api dml status
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 pay_grade_rules_f
84 where grade_rule_id = p_rec.grade_rule_id
85 and effective_start_date >= p_validation_start_date;
86 --
87 pay_grr_shd.g_api_dml := false; -- Unset the api dml status
88 End If;
89 --
90 -- 40.1 change a start.
91 --
92 -- Moved 'ZAP' effective_[start|end]_date processing to dt_pre_delete.
93 --
94 -- 40.1 change a end.
95 --
96 hr_utility.set_location(' Leaving:'||l_proc, 20);
97 --
98 Exception
99 When Others Then
100 pay_grr_shd.g_api_dml := false; -- Unset the api dml status
101 Raise;
102 End dt_delete_dml;
103 --
104 -- ----------------------------------------------------------------------------
105 -- |------------------------------< delete_dml >------------------------------|
106 -- ----------------------------------------------------------------------------
107 Procedure delete_dml
108 (p_rec in out nocopy pay_grr_shd.g_rec_type,
109 p_effective_date in date,
110 p_datetrack_mode in varchar2,
111 p_validation_start_date in date,
112 p_validation_end_date in date) is
113 --
114 l_proc varchar2(72) := g_package||'delete_dml';
115 --
116 Begin
117 hr_utility.set_location('Entering:'||l_proc, 5);
118 --
119 dt_delete_dml(p_rec => p_rec,
120 p_effective_date => p_effective_date,
121 p_datetrack_mode => p_datetrack_mode,
122 p_validation_start_date => p_validation_start_date,
123 p_validation_end_date => p_validation_end_date);
124 --
125 hr_utility.set_location(' Leaving:'||l_proc, 10);
126 End delete_dml;
127 --
128 -- ----------------------------------------------------------------------------
129 -- |----------------------------< dt_pre_delete >-----------------------------|
130 -- ----------------------------------------------------------------------------
131 -- {Start Of Comments}
132 --
133 -- Description:
134 -- The dt_pre_delete process controls the execution of dml
135 -- for the datetrack modes: DELETE, DELETE_FUTURE_CHANGES
136 -- and DELETE_NEXT_CHANGE only.
137 --
138 -- Pre Conditions:
139 -- This is an internal procedure which is called from the pre_delete
140 -- procedure.
141 --
142 -- In Arguments:
143 -- A Pl/Sql record structre.
144 --
145 -- Post Success:
146 -- Processing continues.
147 --
148 -- Post Failure:
149 -- If an error has occurred, an error message and exception will be raised
150 -- but not handled.
151 --
152 -- Developer Implementation Notes:
153 -- This is an internal procedure which is required by Datetrack. Don't
154 -- remove or modify.
155 --
156 -- Access Status:
157 -- Internal Table Handler USe Only.
158 --
159 -- {End Of Comments}
160 -- ----------------------------------------------------------------------------
161 Procedure dt_pre_delete
162 (p_rec in out nocopy pay_grr_shd.g_rec_type,
163 p_effective_date in date,
164 p_datetrack_mode in varchar2,
165 p_validation_start_date in date,
166 p_validation_end_date in date) is
167 --
168 l_proc varchar2(72) := g_package||'dt_pre_delete';
169 --
170 Begin
171 hr_utility.set_location('Entering:'||l_proc, 5);
172 --
173 If (p_datetrack_mode <> 'ZAP') then
174 --
175 --
176 -- 40.1 change a start.
177 --
178 p_rec.effective_start_date := pay_grr_shd.g_old_rec.effective_start_date;
179 --
180 -- 40.1 change a end.
181 --
182 If (p_datetrack_mode = 'DELETE') then
183 p_rec.effective_end_date := p_validation_start_date - 1;
184 Else
185 p_rec.effective_end_date := p_validation_end_date;
186 End If;
187 --
188 -- Update the current effective end date record
189 --
190 pay_grr_shd.upd_effective_end_date
191 (p_effective_date => p_effective_date,
192 p_base_key_value => p_rec.grade_rule_id,
193 p_new_effective_end_date => p_rec.effective_end_date,
194 p_validation_start_date => p_validation_start_date,
195 p_validation_end_date => p_validation_end_date,
196 p_object_version_number => p_rec.object_version_number);
197 --
198 -- 40.1 change a start.
199 --
200 Else
201 p_rec.effective_start_date := null;
202 p_rec.effective_end_date := null;
203 --
204 -- 40.1 change a end.
205 --
206 End If;
207 hr_utility.set_location(' Leaving:'||l_proc, 10);
208 End dt_pre_delete;
209 --
210 -- ----------------------------------------------------------------------------
211 -- |------------------------------< pre_delete >------------------------------|
212 -- ----------------------------------------------------------------------------
213 -- {Start Of Comments}
214 --
215 -- Description:
216 -- This private procedure contains any processing which is required before
217 -- the delete dml.
218 --
219 -- Pre Conditions:
220 -- This is an internal procedure which is called from the del procedure.
221 --
222 -- In Arguments:
223 -- A Pl/Sql record structre.
224 --
225 -- Post Success:
226 -- Processing continues.
227 --
228 -- Post Failure:
229 -- If an error has occurred, an error message and exception will be raised
230 -- but not handled.
231 --
232 -- Developer Implementation Notes:
233 -- Any pre-processing required before the delete dml is issued should be
234 -- coded within this procedure. It is important to note that any 3rd party
235 -- maintenance should be reviewed before placing in this procedure. The call
236 -- to the dt_delete_dml procedure should NOT be removed.
237 --
238 -- Access Status:
239 -- Internal Table Handler USe Only.
240 --
241 -- {End Of Comments}
242 -- ----------------------------------------------------------------------------
243 Procedure pre_delete
244 (p_rec in out nocopy pay_grr_shd.g_rec_type,
245 p_effective_date in date,
246 p_datetrack_mode in varchar2,
247 p_validation_start_date in date,
248 p_validation_end_date in date) is
249 --
250 l_proc varchar2(72) := g_package||'pre_delete';
251 --
252 --
253 --
254 Begin
255 hr_utility.set_location('Entering:'||l_proc, 5);
256 --
257 --
258 --
259 dt_pre_delete
260 (p_rec => p_rec,
261 p_effective_date => p_effective_date,
262 p_datetrack_mode => p_datetrack_mode,
263 p_validation_start_date => p_validation_start_date,
264 p_validation_end_date => p_validation_end_date);
265 --
266 hr_utility.set_location(' Leaving:'||l_proc, 10);
267 End pre_delete;
268 --
269 -- ----------------------------------------------------------------------------
270 -- |-----------------------------< post_delete >------------------------------|
271 -- ----------------------------------------------------------------------------
272 -- {Start Of Comments}
273 --
274 -- Description:
275 -- This private procedure contains any processing which is required after the
276 -- delete dml.
277 --
278 -- Pre Conditions:
279 -- This is an internal procedure which is called from the del procedure.
280 --
281 -- In Arguments:
282 -- A Pl/Sql record structre.
283 --
284 -- Post Success:
285 -- Processing continues.
286 --
287 -- Post Failure:
288 -- If an error has occurred, an error message and exception will be raised
289 -- but not handled.
290 --
291 -- Developer Implementation Notes:
292 -- Any post-processing required after the delete dml is issued should be
293 -- coded within this procedure. It is important to note that any 3rd party
294 -- maintenance should be reviewed before placing in this procedure.
295 --
296 -- Access Status:
297 -- Internal Table Handler USe Only.
298 --
299 -- {End Of Comments}
300 -- ----------------------------------------------------------------------------
301 Procedure post_delete
302 (p_rec in pay_grr_shd.g_rec_type,
303 p_effective_date in date,
304 p_datetrack_mode in varchar2,
305 p_validation_start_date in date,
306 p_validation_end_date in date) is
307 --
308 l_proc varchar2(72) := g_package||'post_delete';
309 --
310 Begin
311 hr_utility.set_location('Entering:'||l_proc, 5);
312 --
313 hr_utility.set_location(' Leaving:'||l_proc, 10);
314 End post_delete;
315 --
316 -- ----------------------------------------------------------------------------
317 -- |---------------------------------< del >----------------------------------|
318 -- ----------------------------------------------------------------------------
319 Procedure del
320 (
321 p_rec in out nocopy pay_grr_shd.g_rec_type,
322 p_effective_date in date,
323 p_datetrack_mode in varchar2,
324 p_validate in boolean default false
325 ) is
326 --
327 l_proc varchar2(72) := g_package||'del';
328 l_validation_start_date date;
329 l_validation_end_date date;
330 --
331 Begin
332 hr_utility.set_location('Entering:'||l_proc, 5);
333 --
334 -- Ensure that the DateTrack delete mode is valid
335 --
336 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
337 --
338 -- Determine if the business process is to be validated.
339 --
340 If p_validate then
341 --
342 -- Issue the savepoint.
343 --
344 SAVEPOINT del_pay_grr;
345 End If;
346 --
347 -- We must lock the row which we need to delete.
348 --
349 pay_grr_shd.lck
350 (p_effective_date => p_effective_date,
351 p_datetrack_mode => p_datetrack_mode,
352 p_grade_rule_id => p_rec.grade_rule_id,
353 p_object_version_number => p_rec.object_version_number,
354 p_validation_start_date => l_validation_start_date,
355 p_validation_end_date => l_validation_end_date);
356 --
357 -- Call the supporting delete validate operation
358 --
359 pay_grr_bus.delete_validate
360 (p_rec => p_rec,
361 p_effective_date => p_effective_date,
362 p_datetrack_mode => p_datetrack_mode,
363 p_validation_start_date => l_validation_start_date,
364 p_validation_end_date => l_validation_end_date);
365 --
366 -- Call the supporting pre-delete operation
367 --
368 pre_delete
369 (p_rec => p_rec,
370 p_effective_date => p_effective_date,
371 p_datetrack_mode => p_datetrack_mode,
372 p_validation_start_date => l_validation_start_date,
373 p_validation_end_date => l_validation_end_date);
374 --
375 -- Delete the row.
376 --
377 delete_dml
378 (p_rec => p_rec,
379 p_effective_date => p_effective_date,
380 p_datetrack_mode => p_datetrack_mode,
381 p_validation_start_date => l_validation_start_date,
382 p_validation_end_date => l_validation_end_date);
383 --
384 -- Call the supporting post-delete operation
385 --
386 post_delete
387 (p_rec => p_rec,
388 p_effective_date => p_effective_date,
389 p_datetrack_mode => p_datetrack_mode,
390 p_validation_start_date => l_validation_start_date,
391 p_validation_end_date => l_validation_end_date);
392 --
393 -- If we are validating then raise the Validate_Enabled exception
394 --
395 If p_validate then
396 Raise HR_Api.Validate_Enabled;
397 End If;
398 --
399 hr_utility.set_location(' Leaving:'||l_proc, 10);
400 Exception
401 When HR_Api.Validate_Enabled Then
402 --
403 -- As the Validate_Enabled exception has been raised
404 -- we must rollback to the savepoint
405 --
406 ROLLBACK TO del_pay_grr;
407 End del;
408 --
409 -- ----------------------------------------------------------------------------
410 -- |---------------------------------< del >----------------------------------|
411 -- ----------------------------------------------------------------------------
412 Procedure del
413 (
414 p_grade_rule_id in number,
415 p_effective_start_date out nocopy date,
416 p_effective_end_date out nocopy date,
417 p_object_version_number in out nocopy number,
418 p_effective_date in date,
419 p_datetrack_mode in varchar2,
420 p_validate in boolean default false
421 ) is
422 --
423 l_rec pay_grr_shd.g_rec_type;
424 l_proc varchar2(72) := g_package||'del';
425 --
426 Begin
427 hr_utility.set_location('Entering:'||l_proc, 5);
428 --
429 -- As the delete procedure accepts a plsql record structure we do need to
430 -- convert the arguments into the record structure.
431 -- We don't need to call the supplied conversion argument routine as we
432 -- only need a few attributes.
433 --
434 l_rec.grade_rule_id := p_grade_rule_id;
435 l_rec.object_version_number := p_object_version_number;
436 --
437 -- Having converted the arguments into the pay_grr_rec
438 -- plsql record structure we must call the corresponding entity
439 -- business process
440 --
441 del(l_rec, p_effective_date, p_datetrack_mode, p_validate);
442 --
443 -- Set the out arguments
444 --
445 p_object_version_number := l_rec.object_version_number;
446 p_effective_start_date := l_rec.effective_start_date;
447 p_effective_end_date := l_rec.effective_end_date;
448 --
449 hr_utility.set_location(' Leaving:'||l_proc, 10);
450 End del;
451 --
452 end pay_grr_del;