1 Package Body pay_evc_upd as
2 /* $Header: pyevcrhi.pkb 115.6 2003/05/27 17:21:31 jford noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_evc_upd.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |----------------------------< dt_update_dml >-----------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 -- This procedure controls the execution of dml from the datetrack mode
17 -- of CORRECTION only. It is important to note that the object version
18 -- number is only increment by 1 because the datetrack correction is
19 -- soley for one datetracked row.
20 -- This procedure controls the actual dml update logic. The functions of
21 -- this procedure are as follows:
22 -- 1) Get the next object_version_number.
23 -- 2) To set and unset the g_api_dml status as required (as we are about to
24 -- perform dml).
25 -- 3) To update the specified row in the schema using the primary key in
26 -- the predicates.
27 -- 4) To trap any constraint violations that may have occurred.
28 -- 5) To raise any other errors.
29 --
30 -- Prerequisites:
31 -- This is an internal private procedure which must be called from the
32 -- update_dml procedure.
33 --
34 -- In Parameters:
35 -- A Pl/Sql record structure.
36 --
37 -- Post Success:
38 -- The specified row will be updated in the schema.
39 --
40 -- Post Failure:
41 -- On the update dml failure it is important to note that we always reset the
42 -- g_api_dml status to false.
43 -- If a check or unique integrity constraint violation is raised the
44 -- constraint_error procedure will be called.
45 -- If any other error is reported, the error will be raised after the
46 -- g_api_dml status is reset.
47 --
48 -- Developer Implementation Notes:
49 -- The update 'set' arguments list should be modified if any of your
50 -- attributes are not updateable.
51 --
52 -- Access Status:
53 -- Internal Row Handler Use Only.
54 --
55 -- {End Of Comments}
56 -- ----------------------------------------------------------------------------
57 Procedure dt_update_dml
58 (p_rec in out nocopy pay_evc_shd.g_rec_type
59 ,p_effective_date in date
60 ,p_datetrack_mode in varchar2
61 ,p_validation_start_date in date
62 ,p_validation_end_date in date
63 ) is
64 --
65 l_proc varchar2(72) := g_package||'dt_update_dml';
66 --
67 Begin
68 hr_utility.set_location('Entering:'||l_proc, 5);
69 --
70 If (p_datetrack_mode = hr_api.g_correction) then
71 hr_utility.set_location(l_proc, 10);
72 --
73 -- Because we are updating a row we must get the next object
74 -- version number.
75 --
76 p_rec.object_version_number :=
77 dt_api.get_object_version_number
78 (p_base_table_name => 'pay_event_value_changes_f'
79 ,p_base_key_column => 'event_value_change_id'
80 ,p_base_key_value => p_rec.event_value_change_id
81 );
82 --
83 --
84 --
85 -- Update the pay_event_value_changes_f Row
86 --
87 update pay_event_value_changes_f
88 set
89 event_value_change_id = p_rec.event_value_change_id
90 ,event_qualifier_id = p_rec.event_qualifier_id
91 ,datetracked_event_id = p_rec.datetracked_event_id
92 ,default_event = p_rec.default_event
93 ,valid_event = p_rec.valid_event
94 ,business_group_id = p_rec.business_group_id
95 ,legislation_code = p_rec.legislation_code
96 ,from_value = p_rec.from_value
97 ,to_value = p_rec.to_value
98 ,proration_style = p_rec.proration_style
99 ,qualifier_value = p_rec.qualifier_value
100 ,object_version_number = p_rec.object_version_number
101 where event_value_change_id = p_rec.event_value_change_id
102 and effective_start_date = p_validation_start_date
103 and effective_end_date = p_validation_end_date;
104 --
105 --
106 --
107 -- Set the effective start and end dates
108 --
109 p_rec.effective_start_date := p_validation_start_date;
110 p_rec.effective_end_date := p_validation_end_date;
111 End If;
112 --
113 hr_utility.set_location(' Leaving:'||l_proc, 15);
114 Exception
115 When hr_api.check_integrity_violated Then
116 -- A check constraint has been violated
117 --
118 pay_evc_shd.constraint_error
119 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120 When hr_api.unique_integrity_violated Then
121 -- Unique integrity has been violated
122 --
123 pay_evc_shd.constraint_error
124 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
125 When Others Then
126 --
127 Raise;
128 End dt_update_dml;
129 --
130 -- ----------------------------------------------------------------------------
131 -- |------------------------------< update_dml >------------------------------|
132 -- ----------------------------------------------------------------------------
133 -- {Start Of Comments}
134 --
135 -- Description:
136 -- This procedure calls the dt_update_dml control logic which handles
137 -- the actual datetrack dml.
138 --
139 -- Prerequisites:
140 -- This is an internal private procedure which must be called from the upd
141 -- procedure.
142 --
143 -- In Parameters:
144 -- A Pl/Sql record structre.
145 --
146 -- Post Success:
147 -- Processing contines.
148 --
149 -- Post Failure:
150 -- No specific error handling is required within this procedure.
151 --
152 -- Developer Implementation Notes:
153 -- The update 'set' arguments list should be modified if any of your
154 -- attributes are not updateable.
155 --
156 -- Access Status:
157 -- Internal Row Handler Use Only.
158 --
159 -- {End Of Comments}
160 -- ----------------------------------------------------------------------------
161 Procedure update_dml
162 (p_rec in out nocopy pay_evc_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
167 ) is
168 --
169 l_proc varchar2(72) := g_package||'update_dml';
170 --
171 Begin
172 hr_utility.set_location('Entering:'||l_proc, 5);
173 --
174 pay_evc_upd.dt_update_dml
175 (p_rec => p_rec
176 ,p_effective_date => p_effective_date
177 ,p_datetrack_mode => p_datetrack_mode
178 ,p_validation_start_date => p_validation_start_date
179 ,p_validation_end_date => p_validation_end_date
180 );
181 --
182 hr_utility.set_location(' Leaving:'||l_proc, 10);
183 End update_dml;
184 --
185 -- ----------------------------------------------------------------------------
186 -- |----------------------------< dt_pre_update >-----------------------------|
187 -- ----------------------------------------------------------------------------
188 -- {Start Of Comments}
189 --
190 -- Description:
191 -- The dt_pre_update procedure controls the execution
192 -- of dml for the datetrack modes of: UPDATE, UPDATE_OVERRIDE
193 -- and UPDATE_CHANGE_INSERT only. The execution required is as
194 -- follows:
195 --
196 -- 1) Providing the datetrack update mode is not 'CORRECTION'
197 -- then set the effective end date of the current row (this
198 -- will be the validation_start_date - 1).
199 -- 2) If the datetrack mode is 'UPDATE_OVERRIDE' then call the
200 -- corresponding delete_dml process to delete any future rows
201 -- where the effective_start_date is greater than or equal to
202 -- the validation_start_date.
203 -- 3) Call the insert_dml process to insert the new updated row
204 -- details.
205 --
206 -- Prerequisites:
207 -- This is an internal procedure which is called from the
208 -- pre_update procedure.
209 --
210 -- In Parameters:
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 -- This is an internal procedure which is required by Datetrack. Don't
221 -- remove or modify.
222 --
223 -- Access Status:
224 -- Internal Row Handler Use Only.
225 --
226 -- {End Of Comments}
227 -- ----------------------------------------------------------------------------
228 Procedure dt_pre_update
229 (p_rec in out nocopy pay_evc_shd.g_rec_type
230 ,p_effective_date in date
231 ,p_datetrack_mode in varchar2
232 ,p_validation_start_date in date
233 ,p_validation_end_date in date
234 ) is
235 --
236 l_proc varchar2(72) := g_package||'dt_pre_update';
237 l_dummy_version_number number;
238 --
239 Begin
240 hr_utility.set_location('Entering:'||l_proc, 5);
241 If (p_datetrack_mode <> hr_api.g_correction) then
242 --
243 -- Update the current effective end date
244 --
245 pay_evc_shd.upd_effective_end_date
246 (p_effective_date => p_effective_date
247 ,p_base_key_value => p_rec.event_value_change_id
248 ,p_new_effective_end_date => (p_validation_start_date - 1)
249 ,p_validation_start_date => p_validation_start_date
250 ,p_validation_end_date => p_validation_end_date
251 ,p_object_version_number => l_dummy_version_number
252 );
253 --
254 If (p_datetrack_mode = hr_api.g_update_override) then
255 --
256 -- As the datetrack mode is 'UPDATE_OVERRIDE' then we must
257 -- delete any future rows
258 --
259 pay_evc_del.delete_dml
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 End If;
267 --
268 -- We must now insert the updated row
269 --
270 pay_evc_ins.insert_dml
271 (p_rec => p_rec
272 ,p_effective_date => p_effective_date
273 ,p_datetrack_mode => p_datetrack_mode
274 ,p_validation_start_date => p_validation_start_date
275 ,p_validation_end_date => p_validation_end_date
276 );
277 End If;
278 hr_utility.set_location(' Leaving:'||l_proc, 20);
279 End dt_pre_update;
280 --
281 -- ----------------------------------------------------------------------------
282 -- |------------------------------< pre_update >------------------------------|
283 -- ----------------------------------------------------------------------------
284 -- {Start Of Comments}
285 --
286 -- Description:
287 -- This private procedure contains any processing which is required before
288 -- the update dml.
289 --
290 -- Prerequisites:
291 -- This is an internal procedure which is called from the upd procedure.
292 --
293 -- In Parameters:
294 -- A Pl/Sql record structure.
295 --
296 -- Post Success:
297 -- Processing continues.
298 --
299 -- Post Failure:
300 -- If an error has occurred, an error message and exception will be raised
301 -- but not handled.
302 -- Developer Implementation Notes:
303 -- Any pre-processing required before the update dml is issued should be
304 -- coded within this procedure. It is important to note that any 3rd party
305 -- maintenance should be reviewed before placing in this procedure. The call
306 -- to the dt_update_dml procedure should NOT be removed.
307 --
308 -- Access Status:
309 -- Internal Row Handler Use Only.
310 --
311 -- {End Of Comments}
312 -- ----------------------------------------------------------------------------
313 Procedure pre_update
314 (p_rec in out nocopy pay_evc_shd.g_rec_type
315 ,p_effective_date in date
316 ,p_datetrack_mode in varchar2
317 ,p_validation_start_date in date
318 ,p_validation_end_date in date
319 ) is
320 --
321 l_proc varchar2(72) := g_package||'pre_update';
322 --
323 Begin
324 hr_utility.set_location('Entering:'||l_proc, 5);
325 --
326 --
327 --
328 dt_pre_update
329 (p_rec => p_rec
330 ,p_effective_date => p_effective_date
331 ,p_datetrack_mode => p_datetrack_mode
332 ,p_validation_start_date => p_validation_start_date
333 ,p_validation_end_date => p_validation_end_date
334 );
335 --
336 hr_utility.set_location(' Leaving:'||l_proc, 10);
337 End pre_update;
338 --
339 -- ----------------------------------------------------------------------------
340 -- |----------------------------< post_update >-------------------------------|
341 -- ----------------------------------------------------------------------------
342 -- {Start Of Comments}
343 --
344 -- Description:
345 -- This private procedure contains any processing which is required after
346 -- the update dml.
347 --
348 -- Prerequisites:
349 -- This is an internal procedure which is called from the upd procedure.
350 --
351 -- In Parameters:
352 -- A Pl/Sql record structure.
353 --
354 -- Post Success:
355 -- Processing continues.
356 --
357 -- Post Failure:
358 -- If an error has occurred, an error message and exception will be raised
359 -- but not handled.
360 --
361 -- Developer Implementation Notes:
362 -- Any post-processing required after the update dml is issued should be
363 -- coded within this procedure. It is important to note that any 3rd party
364 -- maintenance should be reviewed before placing in this procedure.
365 --
366 -- Access Status:
367 -- Internal Row Handler Use Only.
368 --
369 -- {End Of Comments}
370 -- ----------------------------------------------------------------------------
371 Procedure post_update
372 (p_rec in pay_evc_shd.g_rec_type
373 ,p_effective_date in date
374 ,p_datetrack_mode in varchar2
375 ,p_validation_start_date in date
376 ,p_validation_end_date in date
377 ) is
378 --
379 l_proc varchar2(72) := g_package||'post_update';
380 --
381 Begin
382 hr_utility.set_location('Entering:'||l_proc, 5);
383 begin
384 --
385 pay_evc_rku.after_update
386 (p_effective_date
387 => p_effective_date
388 ,p_datetrack_mode
389 => p_datetrack_mode
390 ,p_validation_start_date
391 => p_validation_start_date
392 ,p_validation_end_date
393 => p_validation_end_date
394 ,p_event_value_change_id
395 => p_rec.event_value_change_id
396 ,p_effective_start_date
397 => p_rec.effective_start_date
398 ,p_effective_end_date
399 => p_rec.effective_end_date
400 ,p_from_value
401 => p_rec.from_value
402 ,p_to_value
403 => p_rec.to_value
404 ,p_proration_style
405 => p_rec.proration_style
406 ,p_qualifier_value
407 => p_rec.qualifier_value
408 ,p_object_version_number
409 => p_rec.object_version_number
410 ,p_effective_start_date_o
411 => pay_evc_shd.g_old_rec.effective_start_date
412 ,p_effective_end_date_o
413 => pay_evc_shd.g_old_rec.effective_end_date
414 ,p_event_qualifier_id_o
415 => pay_evc_shd.g_old_rec.event_qualifier_id
416 ,p_datetracked_event_id_o
417 => pay_evc_shd.g_old_rec.datetracked_event_id
418 ,p_default_event_o
419 => pay_evc_shd.g_old_rec.default_event
420 ,p_valid_event_o
421 => pay_evc_shd.g_old_rec.valid_event
422 ,p_business_group_id_o
423 => pay_evc_shd.g_old_rec.business_group_id
424 ,p_legislation_code_o
425 => pay_evc_shd.g_old_rec.legislation_code
426 ,p_from_value_o
427 => pay_evc_shd.g_old_rec.from_value
428 ,p_to_value_o
429 => pay_evc_shd.g_old_rec.to_value
430 ,p_proration_style_o
431 => pay_evc_shd.g_old_rec.proration_style
432 ,p_qualifier_value_o
433 => pay_evc_shd.g_old_rec.qualifier_value
434 ,p_object_version_number_o
435 => pay_evc_shd.g_old_rec.object_version_number
436 );
437 --
438 exception
439 --
440 when hr_api.cannot_find_prog_unit then
441 --
442 hr_api.cannot_find_prog_unit_error
443 (p_module_name => 'PAY_EVENT_VALUE_CHANGES_F'
444 ,p_hook_type => 'AU');
445 --
446 end;
447 --
448 hr_utility.set_location(' Leaving:'||l_proc, 10);
449 End post_update;
450 --
451 -- ----------------------------------------------------------------------------
452 -- |-----------------------------< convert_defs >-----------------------------|
453 -- ----------------------------------------------------------------------------
454 -- {Start Of Comments}
455 --
456 -- Description:
457 -- The Convert_Defs procedure has one very important function:
458 -- It must return the record structure for the row with all system defaulted
459 -- values converted into its corresponding parameter value for update. When
460 -- we attempt to update a row through the Upd process , certain
461 -- parameters can be defaulted which enables flexibility in the calling of
462 -- the upd process (e.g. only attributes which need to be updated need to be
463 -- specified). For the upd process to determine which attributes
464 -- have NOT been specified we need to check if the parameter has a reserved
465 -- system default value. Therefore, for all parameters which have a
466 -- corresponding reserved system default mechanism specified we need to
467 -- check if a system default is being used. If a system default is being
468 -- used then we convert the defaulted value into its corresponding attribute
469 -- value held in the g_old_rec data structure.
470 --
471 -- Prerequisites:
472 -- This private function can only be called from the upd process.
473 --
474 -- In Parameters:
475 -- A Pl/Sql record structure.
476 --
477 -- Post Success:
478 -- The record structure will be returned with all system defaulted parameter
479 -- values converted into its current row attribute value.
480 --
481 -- Post Failure:
482 -- No direct error handling is required within this function. Any possible
483 -- errors within this procedure will be a PL/SQL value error due to
484 -- conversion of datatypes or data lengths.
485 --
486 -- Developer Implementation Notes:
487 -- None.
488 --
489 -- Access Status:
490 -- Internal Row Handler Use Only.
491 --
492 -- {End Of Comments}
493 -- ----------------------------------------------------------------------------
494 Procedure convert_defs
495 (p_rec in out nocopy pay_evc_shd.g_rec_type
496 ) is
497 --
498 Begin
499 --
500 -- We must now examine each argument value in the
501 -- p_rec plsql record structure
502 -- to see if a system default is being used. If a system default
503 -- is being used then we must set to the 'current' argument value.
504 --
505 If (p_rec.event_qualifier_id = hr_api.g_number) then
506 p_rec.event_qualifier_id :=
507 pay_evc_shd.g_old_rec.event_qualifier_id;
508 End If;
509 If (p_rec.datetracked_event_id = hr_api.g_number) then
510 p_rec.datetracked_event_id :=
511 pay_evc_shd.g_old_rec.datetracked_event_id;
512 End If;
513 If (p_rec.default_event = hr_api.g_varchar2) then
514 p_rec.default_event :=
515 pay_evc_shd.g_old_rec.default_event;
516 End If;
517 If (p_rec.valid_event = hr_api.g_varchar2) then
518 p_rec.valid_event :=
519 pay_evc_shd.g_old_rec.valid_event;
520 End If;
521 If (p_rec.business_group_id = hr_api.g_number) then
522 p_rec.business_group_id :=
523 pay_evc_shd.g_old_rec.business_group_id;
524 End If;
525 If (p_rec.legislation_code = hr_api.g_varchar2) then
526 p_rec.legislation_code :=
527 pay_evc_shd.g_old_rec.legislation_code;
528 End If;
529 If (p_rec.from_value = hr_api.g_varchar2) then
530 p_rec.from_value :=
531 pay_evc_shd.g_old_rec.from_value;
532 End If;
533 If (p_rec.to_value = hr_api.g_varchar2) then
534 p_rec.to_value :=
535 pay_evc_shd.g_old_rec.to_value;
536 End If;
537 If (p_rec.proration_style = hr_api.g_varchar2) then
538 p_rec.proration_style :=
539 pay_evc_shd.g_old_rec.proration_style;
540 End If;
541 If (p_rec.qualifier_value = hr_api.g_varchar2) then
542 p_rec.qualifier_value :=
543 pay_evc_shd.g_old_rec.qualifier_value;
544 End If;
545 --
546 End convert_defs;
547 --
548 -- ----------------------------------------------------------------------------
549 -- |---------------------------------< upd >----------------------------------|
550 -- ----------------------------------------------------------------------------
551 Procedure upd
552 (p_effective_date in date
553 ,p_datetrack_mode in varchar2
554 ,p_rec in out nocopy pay_evc_shd.g_rec_type
555 ) is
556 --
557 l_proc varchar2(72) := g_package||'upd';
558 l_validation_start_date date;
559 l_validation_end_date date;
560 --
561 Begin
562 hr_utility.set_location('Entering:'||l_proc, 5);
563 --
564 -- Ensure that the DateTrack update mode is valid
565 --
566 dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode);
567 --
568 -- We must lock the row which we need to update.
569 --
570 pay_evc_shd.lck
571 (p_effective_date => p_effective_date
572 ,p_datetrack_mode => p_datetrack_mode
573 ,p_event_value_change_id => p_rec.event_value_change_id
574 ,p_object_version_number => p_rec.object_version_number
575 ,p_validation_start_date => l_validation_start_date
576 ,p_validation_end_date => l_validation_end_date
577 );
578 --
579 -- 1. During an update system defaults are used to determine if
580 -- arguments have been defaulted or not. We must therefore
581 -- derive the full record structure values to be updated.
582 --
583 -- 2. Call the supporting update validate operations.
584 --
585 pay_evc_upd.convert_defs(p_rec);
586 --
587 pay_evc_bus.update_validate
588 (p_rec => p_rec
589 ,p_effective_date => p_effective_date
590 ,p_datetrack_mode => p_datetrack_mode
591 ,p_validation_start_date => l_validation_start_date
592 ,p_validation_end_date => l_validation_end_date
593 );
594 --
595 -- Call to raise any errors on multi-message list
596 hr_multi_message.end_validation_set;
597 --
598 -- Call the supporting pre-update operation
599 --
600 pre_update
601 (p_rec => p_rec
602 ,p_effective_date => p_effective_date
603 ,p_datetrack_mode => p_datetrack_mode
604 ,p_validation_start_date => l_validation_start_date
605 ,p_validation_end_date => l_validation_end_date
606 );
607 --
608 -- Update the row.
609 --
610 update_dml
611 (p_rec => p_rec
612 ,p_effective_date => p_effective_date
613 ,p_datetrack_mode => p_datetrack_mode
614 ,p_validation_start_date => l_validation_start_date
615 ,p_validation_end_date => l_validation_end_date
616 );
617 --
618 -- Call the supporting post-update operation
619 --
620 post_update
621 (p_rec => p_rec
622 ,p_effective_date => p_effective_date
623 ,p_datetrack_mode => p_datetrack_mode
624 ,p_validation_start_date => l_validation_start_date
625 ,p_validation_end_date => l_validation_end_date
626 );
627 --
628 -- Call to raise any errors on multi-message list
629 hr_multi_message.end_validation_set;
630 End upd;
631 --
632 -- ----------------------------------------------------------------------------
633 -- |------------------------------< upd >-------------------------------------|
634 -- ----------------------------------------------------------------------------
635 Procedure upd
636 (p_effective_date in date
637 ,p_datetrack_mode in varchar2
638 ,p_event_value_change_id in number
639 ,p_object_version_number in out nocopy number
640 ,p_from_value in varchar2 default hr_api.g_varchar2
641 ,p_to_value in varchar2 default hr_api.g_varchar2
642 ,p_valid_event in varchar2 default hr_api.g_varchar2
643 ,p_proration_style in varchar2 default hr_api.g_varchar2
644 ,p_qualifier_value in varchar2 default hr_api.g_varchar2
645 ,p_effective_start_date out nocopy date
646 ,p_effective_end_date out nocopy date
647 ) is
648 --
649 l_rec pay_evc_shd.g_rec_type;
650 l_proc varchar2(72) := g_package||'upd';
651 --
652 Begin
653 hr_utility.set_location('Entering:'||l_proc, 5);
654 --
655 -- Call conversion function to turn arguments into the
656 -- l_rec structure.
657 --
658 l_rec :=
659 pay_evc_shd.convert_args
660 (p_event_value_change_id
661 ,null
662 ,null
663 ,hr_api.g_number
664 ,hr_api.g_number
665 ,hr_api.g_varchar2
666 ,p_valid_event
667 ,hr_api.g_number
668 ,hr_api.g_varchar2
669 ,p_from_value
670 ,p_to_value
671 ,p_proration_style
672 ,p_qualifier_value
673 ,p_object_version_number
674 );
675 --
676 -- Having converted the arguments into the
677 -- plsql record structure we call the corresponding record
678 -- business process.
679 --
680 pay_evc_upd.upd
681 (p_effective_date
682 ,p_datetrack_mode
683 ,l_rec
684 );
685 --
686 -- Set the out parameters
687 --
688 p_object_version_number := l_rec.object_version_number;
689 p_effective_start_date := l_rec.effective_start_date;
690 p_effective_end_date := l_rec.effective_end_date;
691 --
692 --
693 hr_utility.set_location(' Leaving:'||l_proc, 10);
694 End upd;
695 --
696 end pay_evc_upd;