DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BEI_UPD

Source


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