DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XRF_UPD

Source


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