DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BER_UPD

Source


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