DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XER_UPD

Source


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