DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XIC_UPD

Source


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