DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BEC_UPD

Source


1 Package Body ben_bec_upd as
2 /* $Header: bebecrhi.pkb 120.0 2005/05/28 00:37:26 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_bec_upd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< update_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml update logic. The processing of
17 --   this procedure is:
18 --   1) Increment the object_version_number by 1 if the object_version_number
19 --      is defined as an attribute for this entity.
20 --   2) To set and unset the g_api_dml status as required (as we are about to
21 --      perform dml).
22 --   3) To update the specified row in the schema using the primary key in
23 --      the predicates.
24 --   4) To trap any constraint violations that may have occurred.
25 --   5) To raise any other errors.
26 --
27 -- Prerequisites:
28 --   This is an internal private procedure which must be called from the upd
29 --   procedure.
30 --
31 -- In Parameters:
32 --   A Pl/Sql record structre.
33 --
34 -- Post Success:
35 --   The specified row will be updated in the schema.
36 --
37 -- Post Failure:
38 --   On the update dml failure it is important to note that we always reset the
39 --   g_api_dml status to false.
40 --   If a check, unique or parent integrity constraint violation is raised the
41 --   constraint_error procedure will be called.
42 --   If any other error is reported, the error will be raised after the
43 --   g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 --   The update 'set' attribute list should be modified if any of your
47 --   attributes are not updateable.
48 --
49 -- Access Status:
50 --   Internal Row Handler Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure update_dml(p_rec in out nocopy ben_bec_shd.g_rec_type) is
55 --
56   l_proc  varchar2(72) := g_package||'update_dml';
57 --
58 Begin
59   hr_utility.set_location('Entering:'||l_proc, 5);
60   --
61   -- Increment the object version
62   --
63   p_rec.object_version_number := p_rec.object_version_number + 1;
64   --
65   ben_bec_shd.g_api_dml := true;  -- Set the api dml status
66   --
67   -- Update the ben_batch_elctbl_chc_info Row
68   --
69   update ben_batch_elctbl_chc_info
70   set
71   batch_elctbl_id                   = p_rec.batch_elctbl_id,
72   benefit_action_id                 = p_rec.benefit_action_id,
73   person_id                         = p_rec.person_id,
74   pgm_id                            = p_rec.pgm_id,
75   pl_id                             = p_rec.pl_id,
76   oipl_id                           = p_rec.oipl_id,
77   enrt_cvg_strt_dt                  = p_rec.enrt_cvg_strt_dt,
78   enrt_perd_strt_dt                 = p_rec.enrt_perd_strt_dt,
79   enrt_perd_end_dt                  = p_rec.enrt_perd_end_dt,
80   erlst_deenrt_dt                   = p_rec.erlst_deenrt_dt,
81   dflt_enrt_dt                      = p_rec.dflt_enrt_dt,
82   enrt_typ_cycl_cd                  = p_rec.enrt_typ_cycl_cd,
83   comp_lvl_cd                       = p_rec.comp_lvl_cd,
84   mndtry_flag                       = p_rec.mndtry_flag,
85   dflt_flag                         = p_rec.dflt_flag,
86   business_group_id                 = p_rec.business_group_id,
87   object_version_number             = p_rec.object_version_number
88   where batch_elctbl_id = p_rec.batch_elctbl_id;
89   --
90   ben_bec_shd.g_api_dml := false;   -- Unset the api dml status
91   --
92   hr_utility.set_location(' Leaving:'||l_proc, 10);
93 --
94 Exception
95   When hr_api.check_integrity_violated Then
96     -- A check constraint has been violated
97     ben_bec_shd.g_api_dml := false;   -- Unset the api dml status
98     ben_bec_shd.constraint_error
99       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100   When hr_api.parent_integrity_violated Then
101     -- Parent integrity has been violated
102     ben_bec_shd.g_api_dml := false;   -- Unset the api dml status
103     ben_bec_shd.constraint_error
104       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105   When hr_api.unique_integrity_violated Then
106     -- Unique integrity has been violated
107     ben_bec_shd.g_api_dml := false;   -- Unset the api dml status
108     ben_bec_shd.constraint_error
109       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110   When Others Then
111     ben_bec_shd.g_api_dml := false;   -- Unset the api dml status
112     Raise;
113 End update_dml;
114 --
115 -- ----------------------------------------------------------------------------
116 -- |------------------------------< pre_update >------------------------------|
117 -- ----------------------------------------------------------------------------
118 -- {Start Of Comments}
119 --
120 -- Description:
121 --   This private procedure contains any processing which is required before
122 --   the update dml.
123 --
124 -- Prerequisites:
125 --   This is an internal procedure which is called from the upd procedure.
126 --
127 -- In Parameters:
128 --   A Pl/Sql record structre.
129 --
130 -- Post Success:
131 --   Processing continues.
132 --
133 -- Post Failure:
134 --   If an error has occurred, an error message and exception will be raised
135 --   but not handled.
136 --
137 -- Developer Implementation Notes:
138 --   Any pre-processing required before the update dml is issued should be
139 --   coded within this procedure. It is important to note that any 3rd party
140 --   maintenance should be reviewed before placing in this procedure.
141 --
142 -- Access Status:
143 --   Internal Row Handler Use Only.
144 --
145 -- {End Of Comments}
146 -- ----------------------------------------------------------------------------
147 Procedure pre_update(p_rec in ben_bec_shd.g_rec_type) is
148 --
149   l_proc  varchar2(72) := g_package||'pre_update';
150 --
151 Begin
152   hr_utility.set_location('Entering:'||l_proc, 5);
153   --
154   hr_utility.set_location(' Leaving:'||l_proc, 10);
155 End pre_update;
156 --
157 -- ----------------------------------------------------------------------------
158 -- |-----------------------------< post_update >------------------------------|
159 -- ----------------------------------------------------------------------------
160 -- {Start Of Comments}
161 --
162 -- Description:
163 --   This private procedure contains any processing which is required after the
164 --   update dml.
165 --
166 -- Prerequisites:
167 --   This is an internal procedure which is called from the upd procedure.
168 --
169 -- In Parameters:
170 --   A Pl/Sql record structre.
171 --
172 -- Post Success:
173 --   Processing continues.
174 --
175 -- Post Failure:
176 --   If an error has occurred, an error message and exception will be raised
177 --   but not handled.
178 --
179 -- Developer Implementation Notes:
180 --   Any post-processing required after the update dml is issued should be
181 --   coded within this procedure. It is important to note that any 3rd party
182 --   maintenance should be reviewed before placing in this procedure.
183 --
184 -- Access Status:
185 --   Internal Row Handler Use Only.
186 --
187 -- {End Of Comments}
188 -- ----------------------------------------------------------------------------
189 Procedure post_update(p_effective_date in date,
190                       p_rec            in ben_bec_shd.g_rec_type) is
191 --
192   l_proc  varchar2(72) := g_package||'post_update';
193 --
194 Begin
195   hr_utility.set_location('Entering:'||l_proc, 5);
196 --
197   --
198   -- Start of API User Hook for post_update.
199   --
200   begin
201     --
202     ben_bec_rku.after_update
203       (p_batch_elctbl_id         =>p_rec.batch_elctbl_id
204       ,p_benefit_action_id       =>p_rec.benefit_action_id
205       ,p_person_id               =>p_rec.person_id
206       ,p_pgm_id                  =>p_rec.pgm_id
207       ,p_pl_id                   =>p_rec.pl_id
208       ,p_oipl_id                 =>p_rec.oipl_id
209       ,p_enrt_cvg_strt_dt        =>p_rec.enrt_cvg_strt_dt
210       ,p_enrt_perd_strt_dt       =>p_rec.enrt_perd_strt_dt
211       ,p_enrt_perd_end_dt        =>p_rec.enrt_perd_end_dt
212       ,p_erlst_deenrt_dt         =>p_rec.erlst_deenrt_dt
213       ,p_dflt_enrt_dt            =>p_rec.dflt_enrt_dt
214       ,p_enrt_typ_cycl_cd        =>p_rec.enrt_typ_cycl_cd
215       ,p_comp_lvl_cd             =>p_rec.comp_lvl_cd
216       ,p_mndtry_flag             =>p_rec.mndtry_flag
217       ,p_dflt_flag               =>p_rec.dflt_flag
218       ,p_business_group_id       =>p_rec.business_group_id
219       ,p_object_version_number   =>p_rec.object_version_number
220       ,p_effective_date          =>p_effective_date
221       ,p_benefit_action_id_o     =>ben_bec_shd.g_old_rec.benefit_action_id
222       ,p_person_id_o             =>ben_bec_shd.g_old_rec.person_id
223       ,p_pgm_id_o                =>ben_bec_shd.g_old_rec.pgm_id
224       ,p_pl_id_o                 =>ben_bec_shd.g_old_rec.pl_id
225       ,p_oipl_id_o               =>ben_bec_shd.g_old_rec.oipl_id
226       ,p_enrt_cvg_strt_dt_o      =>ben_bec_shd.g_old_rec.enrt_cvg_strt_dt
227       ,p_enrt_perd_strt_dt_o     =>ben_bec_shd.g_old_rec.enrt_perd_strt_dt
228       ,p_enrt_perd_end_dt_o      =>ben_bec_shd.g_old_rec.enrt_perd_end_dt
229       ,p_erlst_deenrt_dt_o       =>ben_bec_shd.g_old_rec.erlst_deenrt_dt
230       ,p_dflt_enrt_dt_o          =>ben_bec_shd.g_old_rec.dflt_enrt_dt
231       ,p_enrt_typ_cycl_cd_o      =>ben_bec_shd.g_old_rec.enrt_typ_cycl_cd
232       ,p_comp_lvl_cd_o           =>ben_bec_shd.g_old_rec.comp_lvl_cd
233       ,p_mndtry_flag_o           =>ben_bec_shd.g_old_rec.mndtry_flag
234       ,p_dflt_flag_o             =>ben_bec_shd.g_old_rec.dflt_flag
235       ,p_business_group_id_o     =>ben_bec_shd.g_old_rec.business_group_id
236       ,p_object_version_number_o =>ben_bec_shd.g_old_rec.object_version_number);
237     --
238   exception
239     --
240     when hr_api.cannot_find_prog_unit then
241       --
242       hr_api.cannot_find_prog_unit_error
243         (p_module_name => 'ben_batch_elctbl_chc_info'
244         ,p_hook_type   => 'AU');
245       --
246   end;
247   --
248   -- End of API User Hook for post_update.
249   --
250   hr_utility.set_location(' Leaving:'||l_proc, 10);
251 End post_update;
252 --
253 -- ----------------------------------------------------------------------------
254 -- |-----------------------------< convert_defs >-----------------------------|
255 -- ----------------------------------------------------------------------------
256 -- {Start Of Comments}
257 --
258 -- Description:
259 --   The Convert_Defs procedure has one very important function:
260 --   It must return the record structure for the row with all system defaulted
261 --   values converted into its corresponding parameter value for update. When
262 --   we attempt to update a row through the Upd process , certain
263 --   parameters can be defaulted which enables flexibility in the calling of
264 --   the upd process (e.g. only attributes which need to be updated need to be
265 --   specified). For the upd process to determine which attributes
266 --   have NOT been specified we need to check if the parameter has a reserved
267 --   system default value. Therefore, for all parameters which have a
268 --   corresponding reserved system default mechanism specified we need to
269 --   check if a system default is being used. If a system default is being
270 --   used then we convert the defaulted value into its corresponding attribute
271 --   value held in the g_old_rec data structure.
272 --
273 -- Prerequisites:
274 --   This private function can only be called from the upd process.
275 --
276 -- In Parameters:
277 --   A Pl/Sql record structre.
278 --
279 -- Post Success:
280 --   The record structure will be returned with all system defaulted parameter
281 --   values converted into its current row attribute value.
282 --
283 -- Post Failure:
284 --   No direct error handling is required within this function. Any possible
285 --   errors within this procedure will be a PL/SQL value error due to conversion
286 --   of datatypes or data lengths.
287 --
288 -- Developer Implementation Notes:
289 --   None.
290 --
291 -- Access Status:
292 --   Internal Row Handler Use Only.
293 --
294 -- {End Of Comments}
295 -- ----------------------------------------------------------------------------
296 Procedure convert_defs(p_rec in out nocopy ben_bec_shd.g_rec_type) is
297 --
298   l_proc  varchar2(72) := g_package||'convert_defs';
299 --
300 Begin
301   --
302   hr_utility.set_location('Entering:'||l_proc, 5);
303   --
304   -- We must now examine each argument value in the
305   -- p_rec plsql record structure
306   -- to see if a system default is being used. If a system default
307   -- is being used then we must set to the 'current' argument value.
308   --
309   If (p_rec.benefit_action_id = hr_api.g_number) then
310     p_rec.benefit_action_id :=
311     ben_bec_shd.g_old_rec.benefit_action_id;
312   End If;
313   If (p_rec.person_id = hr_api.g_number) then
314     p_rec.person_id :=
315     ben_bec_shd.g_old_rec.person_id;
316   End If;
317   If (p_rec.pgm_id = hr_api.g_number) then
318     p_rec.pgm_id :=
319     ben_bec_shd.g_old_rec.pgm_id;
320   End If;
321   If (p_rec.pl_id = hr_api.g_number) then
322     p_rec.pl_id :=
323     ben_bec_shd.g_old_rec.pl_id;
324   End If;
325   If (p_rec.oipl_id = hr_api.g_number) then
326     p_rec.oipl_id :=
327     ben_bec_shd.g_old_rec.oipl_id;
328   End If;
329   If (p_rec.enrt_cvg_strt_dt = hr_api.g_date) then
330     p_rec.enrt_cvg_strt_dt :=
331     ben_bec_shd.g_old_rec.enrt_cvg_strt_dt;
332   End If;
333   If (p_rec.enrt_perd_strt_dt = hr_api.g_date) then
334     p_rec.enrt_perd_strt_dt :=
335     ben_bec_shd.g_old_rec.enrt_perd_strt_dt;
336   End If;
337   If (p_rec.enrt_perd_end_dt = hr_api.g_date) then
338     p_rec.enrt_perd_end_dt :=
339     ben_bec_shd.g_old_rec.enrt_perd_end_dt;
340   End If;
341   If (p_rec.erlst_deenrt_dt = hr_api.g_date) then
342     p_rec.erlst_deenrt_dt :=
343     ben_bec_shd.g_old_rec.erlst_deenrt_dt;
344   End If;
345   If (p_rec.dflt_enrt_dt = hr_api.g_date) then
346     p_rec.dflt_enrt_dt :=
347     ben_bec_shd.g_old_rec.dflt_enrt_dt;
348   End If;
349   If (p_rec.enrt_typ_cycl_cd = hr_api.g_varchar2) then
350     p_rec.enrt_typ_cycl_cd :=
351     ben_bec_shd.g_old_rec.enrt_typ_cycl_cd;
352   End If;
353   If (p_rec.comp_lvl_cd = hr_api.g_varchar2) then
354     p_rec.comp_lvl_cd :=
355     ben_bec_shd.g_old_rec.comp_lvl_cd;
356   End If;
357   If (p_rec.mndtry_flag = hr_api.g_varchar2) then
358     p_rec.mndtry_flag :=
359     ben_bec_shd.g_old_rec.mndtry_flag;
360   End If;
361   If (p_rec.dflt_flag = hr_api.g_varchar2) then
362     p_rec.dflt_flag :=
363     ben_bec_shd.g_old_rec.dflt_flag;
364   End If;
365   If (p_rec.business_group_id = hr_api.g_number) then
366     p_rec.business_group_id :=
367     ben_bec_shd.g_old_rec.business_group_id;
368   End If;
369   --
370   hr_utility.set_location(' Leaving:'||l_proc, 10);
371 --
372 End convert_defs;
373 --
374 -- ----------------------------------------------------------------------------
375 -- |---------------------------------< upd >----------------------------------|
376 -- ----------------------------------------------------------------------------
377 Procedure upd
378   (
379   p_effective_date in date,
380   p_rec        in out nocopy ben_bec_shd.g_rec_type
381   ) is
382 --
383   l_proc  varchar2(72) := g_package||'upd';
384 --
385 Begin
386   hr_utility.set_location('Entering:'||l_proc, 5);
387   --
388   -- We must lock the row which we need to update.
389   --
390   ben_bec_shd.lck
391 	(
392 	p_rec.batch_elctbl_id,
393 	p_rec.object_version_number
394 	);
395   --
396   -- 1. During an update system defaults are used to determine if
397   --    arguments have been defaulted or not. We must therefore
398   --    derive the full record structure values to be updated.
399   --
400   -- 2. Call the supporting update validate operations.
401   --
402   convert_defs(p_rec);
403   ben_bec_bus.update_validate(p_rec,p_effective_date);
404   --
405   -- Call the supporting pre-update operation
406   --
407   pre_update(p_rec);
408   --
409   -- Update the row.
410   --
411   update_dml(p_rec);
412   --
413   -- Call the supporting post-update operation
414   --
415   post_update(p_effective_date,p_rec);
416   --
417 End upd;
418 --
419 -- ----------------------------------------------------------------------------
420 -- |---------------------------------< upd >----------------------------------|
421 -- ----------------------------------------------------------------------------
422 Procedure upd
423   (
424   p_effective_date in date,
425   p_batch_elctbl_id              in number,
426   p_benefit_action_id            in number           default hr_api.g_number,
427   p_person_id                    in number           default hr_api.g_number,
428   p_pgm_id                       in number           default hr_api.g_number,
429   p_pl_id                        in number           default hr_api.g_number,
430   p_oipl_id                      in number           default hr_api.g_number,
431   p_enrt_cvg_strt_dt             in date             default hr_api.g_date,
432   p_enrt_perd_strt_dt            in date             default hr_api.g_date,
433   p_enrt_perd_end_dt             in date             default hr_api.g_date,
434   p_erlst_deenrt_dt              in date             default hr_api.g_date,
435   p_dflt_enrt_dt                 in date             default hr_api.g_date,
436   p_enrt_typ_cycl_cd             in varchar2         default hr_api.g_varchar2,
437   p_comp_lvl_cd                  in varchar2         default hr_api.g_varchar2,
438   p_mndtry_flag                  in varchar2         default hr_api.g_varchar2,
439   p_dflt_flag                    in varchar2         default hr_api.g_varchar2,
440   p_business_group_id            in number           default hr_api.g_number,
441   p_object_version_number        in out nocopy number
442   ) is
443 --
444   l_rec	  ben_bec_shd.g_rec_type;
445   l_proc  varchar2(72) := g_package||'upd';
446 --
447 Begin
448   hr_utility.set_location('Entering:'||l_proc, 5);
449   --
450   -- Call conversion function to turn arguments into the
451   -- l_rec structure.
452   --
453   l_rec :=
454   ben_bec_shd.convert_args
455   (
456   p_batch_elctbl_id,
457   p_benefit_action_id,
458   p_person_id,
459   p_pgm_id,
460   p_pl_id,
461   p_oipl_id,
462   p_enrt_cvg_strt_dt,
463   p_enrt_perd_strt_dt,
464   p_enrt_perd_end_dt,
465   p_erlst_deenrt_dt,
466   p_dflt_enrt_dt,
467   p_enrt_typ_cycl_cd,
468   p_comp_lvl_cd,
469   p_mndtry_flag,
470   p_dflt_flag,
471   p_business_group_id,
472   p_object_version_number
473   );
474   --
475   -- Having converted the arguments into the
476   -- plsql record structure we call the corresponding record
477   -- business process.
478   --
479   upd(p_effective_date,l_rec);
480   p_object_version_number := l_rec.object_version_number;
481   --
482   hr_utility.set_location(' Leaving:'||l_proc, 10);
483 End upd;
484 --
485 end ben_bec_upd;