DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BDI_UPD

Source


1 Package Body ben_bdi_upd as
2 /* $Header: bebdirhi.pkb 120.0.12000000.2 2007/09/11 12:48:32 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_bdi_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_bdi_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_bdi_shd.g_api_dml := true;  -- Set the api dml status
66   --
67   -- Update the ben_batch_dpnt_info Row
68   --
69   update ben_batch_dpnt_info
70   set
71   batch_dpnt_id                     = p_rec.batch_dpnt_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   contact_typ_cd                    = p_rec.contact_typ_cd,
78   dpnt_person_id                    = p_rec.dpnt_person_id,
79   business_group_id                 = p_rec.business_group_id,
80   object_version_number             = p_rec.object_version_number,
81   enrt_cvg_strt_dt                  = p_rec.enrt_cvg_strt_dt,
82   enrt_cvg_thru_dt                  = p_rec.enrt_cvg_thru_dt,
83   actn_cd                           = p_rec.actn_cd
84   where batch_dpnt_id = p_rec.batch_dpnt_id;
85   --
86   ben_bdi_shd.g_api_dml := false;   -- Unset the api dml status
87   --
88   hr_utility.set_location(' Leaving:'||l_proc, 10);
89 --
90 Exception
91   When hr_api.check_integrity_violated Then
92     -- A check constraint has been violated
93     ben_bdi_shd.g_api_dml := false;   -- Unset the api dml status
94     ben_bdi_shd.constraint_error
95       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
96   When hr_api.parent_integrity_violated Then
97     -- Parent integrity has been violated
98     ben_bdi_shd.g_api_dml := false;   -- Unset the api dml status
99     ben_bdi_shd.constraint_error
100       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
101   When hr_api.unique_integrity_violated Then
102     -- Unique integrity has been violated
103     ben_bdi_shd.g_api_dml := false;   -- Unset the api dml status
104     ben_bdi_shd.constraint_error
105       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106   When Others Then
107     ben_bdi_shd.g_api_dml := false;   -- Unset the api dml status
108     Raise;
109 End update_dml;
110 --
111 -- ----------------------------------------------------------------------------
112 -- |------------------------------< pre_update >------------------------------|
113 -- ----------------------------------------------------------------------------
114 -- {Start Of Comments}
115 --
116 -- Description:
117 --   This private procedure contains any processing which is required before
118 --   the update dml.
119 --
120 -- Prerequisites:
121 --   This is an internal procedure which is called from the upd procedure.
122 --
123 -- In Parameters:
124 --   A Pl/Sql record structre.
125 --
126 -- Post Success:
127 --   Processing continues.
128 --
129 -- Post Failure:
130 --   If an error has occurred, an error message and exception will be raised
131 --   but not handled.
132 --
133 -- Developer Implementation Notes:
134 --   Any pre-processing required before the update dml is issued should be
135 --   coded within this procedure. It is important to note that any 3rd party
136 --   maintenance should be reviewed before placing in this procedure.
137 --
138 -- Access Status:
139 --   Internal Row Handler Use Only.
140 --
141 -- {End Of Comments}
142 -- ----------------------------------------------------------------------------
143 Procedure pre_update(p_rec in ben_bdi_shd.g_rec_type) is
144 --
145   l_proc  varchar2(72) := g_package||'pre_update';
146 --
147 Begin
148   hr_utility.set_location('Entering:'||l_proc, 5);
149   --
150   hr_utility.set_location(' Leaving:'||l_proc, 10);
151 End pre_update;
152 --
153 -- ----------------------------------------------------------------------------
154 -- |-----------------------------< post_update >------------------------------|
155 -- ----------------------------------------------------------------------------
156 -- {Start Of Comments}
157 --
158 -- Description:
159 --   This private procedure contains any processing which is required after the
160 --   update dml.
161 --
162 -- Prerequisites:
163 --   This is an internal procedure which is called from the upd procedure.
164 --
165 -- In Parameters:
166 --   A Pl/Sql record structre.
167 --
168 -- Post Success:
169 --   Processing continues.
170 --
171 -- Post Failure:
172 --   If an error has occurred, an error message and exception will be raised
173 --   but not handled.
174 --
175 -- Developer Implementation Notes:
176 --   Any post-processing required after the update dml is issued should be
177 --   coded within this procedure. It is important to note that any 3rd party
178 --   maintenance should be reviewed before placing in this procedure.
179 --
180 -- Access Status:
181 --   Internal Row Handler Use Only.
182 --
183 -- {End Of Comments}
184 -- ----------------------------------------------------------------------------
185 Procedure post_update(p_effective_date in date,
186                       p_rec            in ben_bdi_shd.g_rec_type) is
187 --
188   l_proc  varchar2(72) := g_package||'post_update';
189 --
190 Begin
191   hr_utility.set_location('Entering:'||l_proc, 5);
192 --
193   --
194   -- Start of API User Hook for post_update.
195   --
196   begin
197     --
198     ben_bdi_rku.after_update
199       (p_batch_dpnt_id           =>p_rec.batch_dpnt_id
200       ,p_benefit_action_id       =>p_rec.benefit_action_id
201       ,p_person_id               =>p_rec.person_id
202       ,p_pgm_id                  =>p_rec.pgm_id
203       ,p_pl_id                   =>p_rec.pl_id
204       ,p_oipl_id                 =>p_rec.oipl_id
205       ,p_contact_typ_cd          =>p_rec.contact_typ_cd
206       ,p_dpnt_person_id          =>p_rec.dpnt_person_id
207       ,p_business_group_id       =>p_rec.business_group_id
208       ,p_object_version_number   =>p_rec.object_version_number
209       ,p_enrt_cvg_strt_dt        =>p_rec.enrt_cvg_strt_dt
210       ,p_enrt_cvg_thru_dt        =>p_rec.enrt_cvg_thru_dt
211       ,p_actn_cd                 =>p_rec.actn_cd
212       ,p_effective_date          =>p_effective_date
213       ,p_benefit_action_id_o     =>ben_bdi_shd.g_old_rec.benefit_action_id
214       ,p_person_id_o             =>ben_bdi_shd.g_old_rec.person_id
215       ,p_pgm_id_o                =>ben_bdi_shd.g_old_rec.pgm_id
216       ,p_pl_id_o                 =>ben_bdi_shd.g_old_rec.pl_id
217       ,p_oipl_id_o               =>ben_bdi_shd.g_old_rec.oipl_id
218       ,p_contact_typ_cd_o        =>ben_bdi_shd.g_old_rec.contact_typ_cd
219       ,p_dpnt_person_id_o        =>ben_bdi_shd.g_old_rec.dpnt_person_id
220       ,p_business_group_id_o     =>ben_bdi_shd.g_old_rec.business_group_id
221       ,p_object_version_number_o =>ben_bdi_shd.g_old_rec.object_version_number
222       ,p_enrt_cvg_strt_dt_o            =>ben_bdi_shd.g_old_rec.enrt_cvg_strt_dt
223       ,p_enrt_cvg_thru_dt_o            =>ben_bdi_shd.g_old_rec.enrt_cvg_thru_dt
224       ,p_actn_cd_o                     =>ben_bdi_shd.g_old_rec.actn_cd
225       );
226     --
227   exception
228     --
229     when hr_api.cannot_find_prog_unit then
230       --
231       hr_api.cannot_find_prog_unit_error
232         (p_module_name => 'ben_batch_dpnt_info'
233         ,p_hook_type   => 'AU');
234       --
235   end;
236   --
237   -- End of API User Hook for post_update.
238   --
239   --
240   hr_utility.set_location(' Leaving:'||l_proc, 10);
241 End post_update;
242 --
243 -- ----------------------------------------------------------------------------
244 -- |-----------------------------< convert_defs >-----------------------------|
245 -- ----------------------------------------------------------------------------
246 -- {Start Of Comments}
247 --
248 -- Description:
249 --   The Convert_Defs procedure has one very important function:
250 --   It must return the record structure for the row with all system defaulted
251 --   values converted into its corresponding parameter value for update. When
252 --   we attempt to update a row through the Upd process , certain
253 --   parameters can be defaulted which enables flexibility in the calling of
254 --   the upd process (e.g. only attributes which need to be updated need to be
255 --   specified). For the upd process to determine which attributes
256 --   have NOT been specified we need to check if the parameter has a reserved
257 --   system default value. Therefore, for all parameters which have a
258 --   corresponding reserved system default mechanism specified we need to
259 --   check if a system default is being used. If a system default is being
260 --   used then we convert the defaulted value into its corresponding attribute
261 --   value held in the g_old_rec data structure.
262 --
263 -- Prerequisites:
264 --   This private function can only be called from the upd process.
265 --
266 -- In Parameters:
267 --   A Pl/Sql record structre.
268 --
269 -- Post Success:
270 --   The record structure will be returned with all system defaulted parameter
271 --   values converted into its current row attribute value.
272 --
273 -- Post Failure:
274 --   No direct error handling is required within this function. Any possible
275 --   errors within this procedure will be a PL/SQL value error due to conversion
276 --   of datatypes or data lengths.
277 --
278 -- Developer Implementation Notes:
279 --   None.
280 --
281 -- Access Status:
282 --   Internal Row Handler Use Only.
283 --
284 -- {End Of Comments}
285 -- ----------------------------------------------------------------------------
286 Procedure convert_defs(p_rec in out nocopy ben_bdi_shd.g_rec_type) is
287 --
288   l_proc  varchar2(72) := g_package||'convert_defs';
289 --
290 Begin
291   --
292   hr_utility.set_location('Entering:'||l_proc, 5);
293   --
294   -- We must now examine each argument value in the
295   -- p_rec plsql record structure
296   -- to see if a system default is being used. If a system default
297   -- is being used then we must set to the 'current' argument value.
298   --
299   If (p_rec.benefit_action_id = hr_api.g_number) then
300     p_rec.benefit_action_id :=
301     ben_bdi_shd.g_old_rec.benefit_action_id;
302   End If;
303   If (p_rec.person_id = hr_api.g_number) then
304     p_rec.person_id :=
305     ben_bdi_shd.g_old_rec.person_id;
306   End If;
307   If (p_rec.pgm_id = hr_api.g_number) then
308     p_rec.pgm_id :=
309     ben_bdi_shd.g_old_rec.pgm_id;
310   End If;
311   If (p_rec.pl_id = hr_api.g_number) then
312     p_rec.pl_id :=
313     ben_bdi_shd.g_old_rec.pl_id;
314   End If;
315   If (p_rec.oipl_id = hr_api.g_number) then
316     p_rec.oipl_id :=
317     ben_bdi_shd.g_old_rec.oipl_id;
318   End If;
319   If (p_rec.contact_typ_cd = hr_api.g_varchar2) then
320     p_rec.contact_typ_cd :=
321     ben_bdi_shd.g_old_rec.contact_typ_cd;
322   End If;
323   If (p_rec.dpnt_person_id = hr_api.g_number) then
324     p_rec.dpnt_person_id :=
325     ben_bdi_shd.g_old_rec.dpnt_person_id;
326   End If;
327   If (p_rec.business_group_id = hr_api.g_number) then
328     p_rec.business_group_id :=
329     ben_bdi_shd.g_old_rec.business_group_id;
330   End If;
331   If (p_rec.enrt_cvg_strt_dt = hr_api.g_date) then
332     p_rec.enrt_cvg_strt_dt :=
333     ben_bdi_shd.g_old_rec.enrt_cvg_strt_dt;
334   End If;
335   If (p_rec.enrt_cvg_thru_dt = hr_api.g_date) then
336     p_rec.enrt_cvg_thru_dt :=
337     ben_bdi_shd.g_old_rec.enrt_cvg_thru_dt;
338   End If;
339   If (p_rec.actn_cd = hr_api.g_varchar2) then
340     p_rec.actn_cd :=
341     ben_bdi_shd.g_old_rec.actn_cd;
342   End If;
343   --
344   hr_utility.set_location(' Leaving:'||l_proc, 10);
345 --
346 End convert_defs;
347 --
348 -- ----------------------------------------------------------------------------
349 -- |---------------------------------< upd >----------------------------------|
350 -- ----------------------------------------------------------------------------
351 Procedure upd
352   (
353   p_effective_date in date,
354   p_rec        in out nocopy ben_bdi_shd.g_rec_type
355   ) is
356 --
357   l_proc  varchar2(72) := g_package||'upd';
358 --
359 Begin
360   hr_utility.set_location('Entering:'||l_proc, 5);
361   --
362   -- We must lock the row which we need to update.
363   --
364   ben_bdi_shd.lck
365 	(
366 	p_rec.batch_dpnt_id,
367 	p_rec.object_version_number
368 	);
369   --
370   -- 1. During an update system defaults are used to determine if
371   --    arguments have been defaulted or not. We must therefore
372   --    derive the full record structure values to be updated.
373   --
374   -- 2. Call the supporting update validate operations.
375   --
376   convert_defs(p_rec);
377   ben_bdi_bus.update_validate(p_rec,p_effective_date);
378   --
379   -- Call the supporting pre-update operation
380   --
381   pre_update(p_rec);
382   --
383   -- Update the row.
384   --
385   update_dml(p_rec);
386   --
387   -- Call the supporting post-update operation
388   --
389   post_update(p_effective_date,p_rec);
390 End upd;
391 --
392 -- ----------------------------------------------------------------------------
393 -- |---------------------------------< upd >----------------------------------|
394 -- ----------------------------------------------------------------------------
395 Procedure upd
396   (
397   p_effective_date in date,
398   p_batch_dpnt_id                in number,
399   p_benefit_action_id            in number           default hr_api.g_number,
400   p_person_id                    in number           default hr_api.g_number,
401   p_pgm_id                       in number           default hr_api.g_number,
402   p_pl_id                        in number           default hr_api.g_number,
403   p_oipl_id                      in number           default hr_api.g_number,
404   p_contact_typ_cd               in varchar2         default hr_api.g_varchar2,
405   p_dpnt_person_id               in number           default hr_api.g_number,
406   p_business_group_id            in number           default hr_api.g_number,
407   p_object_version_number        in out nocopy varchar2,
408   p_enrt_cvg_strt_dt             in date             default hr_api.g_date,
409   p_enrt_cvg_thru_dt             in date             default hr_api.g_date,
410   p_actn_cd                      in varchar2         default hr_api.g_varchar2
411   ) is
412 --
413   l_rec	  ben_bdi_shd.g_rec_type;
414   l_proc  varchar2(72) := g_package||'upd';
415 --
416 Begin
417   hr_utility.set_location('Entering:'||l_proc, 5);
418   --
419   -- Call conversion function to turn arguments into the
420   -- l_rec structure.
421   --
422   l_rec :=
423   ben_bdi_shd.convert_args
424   (
425   p_batch_dpnt_id,
426   p_benefit_action_id,
427   p_person_id,
428   p_pgm_id,
429   p_pl_id,
430   p_oipl_id,
431   p_contact_typ_cd,
432   p_dpnt_person_id,
433   p_business_group_id,
434   p_object_version_number,
435   p_enrt_cvg_strt_dt,
436   p_enrt_cvg_thru_dt,
437   p_actn_cd
438   );
439   --
440   -- Having converted the arguments into the
441   -- plsql record structure we call the corresponding record
442   -- business process.
443   --
444   upd(p_effective_date,l_rec);
445   p_object_version_number := l_rec.object_version_number;
446   --
447   hr_utility.set_location(' Leaving:'||l_proc, 10);
448 End upd;
449 --
450 end ben_bdi_upd;