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