DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BPI_UPD

Source


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