DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_BGM_UPD

Source


1 Package Body pqh_bgm_upd as
2 /* $Header: pqbgmrhi.pkb 115.3 2002/12/05 16:33:25 rpasapul ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_bgm_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 --      perform dml).
21 --   3) To update the specified row in the schema using the primary key in
22 --      the predicates.
23 --   4) To trap any constraint violations that may have occurred.
24 --   5) To raise any other errors.
25 --
26 -- Prerequisites:
27 --   This is an internal private procedure which must be called from the upd
28 --   procedure.
29 --
30 -- In Parameters:
31 --   A Pl/Sql record structre.
32 --
33 -- Post Success:
34 --   The specified row will be updated in the schema.
35 --
36 -- Post Failure:
37 --   On the update dml failure it is important to note that we always reset the
38 --   If a check, unique or parent integrity constraint violation is raised the
39 --   constraint_error procedure will be called.
40 --   If any other error is reported, the error will be raised after the
41 --
42 -- Developer Implementation Notes:
43 --   The update 'set' attribute list should be modified if any of your
44 --   attributes are not updateable.
45 --
46 -- Access Status:
47 --   Internal Row Handler Use Only.
48 --
49 -- {End Of Comments}
50 -- ----------------------------------------------------------------------------
51 Procedure update_dml(p_rec in out nocopy pqh_bgm_shd.g_rec_type) is
52 --
53   l_proc  varchar2(72) := g_package||'update_dml';
54 --
55 Begin
56   hr_utility.set_location('Entering:'||l_proc, 5);
57   --
58   -- Increment the object version
59   --
60   p_rec.object_version_number := p_rec.object_version_number + 1;
61   --
62   --
63   -- Update the pqh_budget_gl_flex_maps Row
64   --
65   update pqh_budget_gl_flex_maps
66   set
67   budget_gl_flex_map_id             = p_rec.budget_gl_flex_map_id,
68   budget_id                         = p_rec.budget_id,
69   gl_account_segment                = p_rec.gl_account_segment,
70   payroll_cost_segment              = p_rec.payroll_cost_segment,
71   object_version_number             = p_rec.object_version_number
72   where budget_gl_flex_map_id = p_rec.budget_gl_flex_map_id;
73   --
74   --
75   hr_utility.set_location(' Leaving:'||l_proc, 10);
76 --
77 Exception
78   When hr_api.check_integrity_violated Then
79     -- A check constraint has been violated
80     pqh_bgm_shd.constraint_error
81       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
82   When hr_api.parent_integrity_violated Then
83     -- Parent integrity has been violated
84     pqh_bgm_shd.constraint_error
85       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
86   When hr_api.unique_integrity_violated Then
87     -- Unique integrity has been violated
88     pqh_bgm_shd.constraint_error
89       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
90   When Others Then
91     Raise;
92 End update_dml;
93 --
94 -- ----------------------------------------------------------------------------
95 -- |------------------------------< pre_update >------------------------------|
96 -- ----------------------------------------------------------------------------
97 -- {Start Of Comments}
98 --
99 -- Description:
100 --   This private procedure contains any processing which is required before
101 --   the update dml.
102 --
103 -- Prerequisites:
104 --   This is an internal procedure which is called from the upd procedure.
105 --
106 -- In Parameters:
107 --   A Pl/Sql record structre.
108 --
109 -- Post Success:
110 --   Processing continues.
111 --
112 -- Post Failure:
113 --   If an error has occurred, an error message and exception will be raised
114 --   but not handled.
115 --
116 -- Developer Implementation Notes:
117 --   Any pre-processing required before the update dml is issued should be
118 --   coded within this procedure. It is important to note that any 3rd party
119 --   maintenance should be reviewed before placing in this procedure.
120 --
121 -- Access Status:
122 --   Internal Row Handler Use Only.
123 --
124 -- {End Of Comments}
125 -- ----------------------------------------------------------------------------
126 Procedure pre_update(p_rec in pqh_bgm_shd.g_rec_type) is
127 --
128   l_proc  varchar2(72) := g_package||'pre_update';
129 --
130 Begin
131   hr_utility.set_location('Entering:'||l_proc, 5);
132   --
133   hr_utility.set_location(' Leaving:'||l_proc, 10);
134 End pre_update;
135 --
136 -- ----------------------------------------------------------------------------
137 -- |-----------------------------< post_update >------------------------------|
138 -- ----------------------------------------------------------------------------
139 -- {Start Of Comments}
140 --
141 -- Description:
142 --   This private procedure contains any processing which is required after the
143 --   update dml.
144 --
145 -- Prerequisites:
146 --   This is an internal procedure which is called from the upd procedure.
147 --
148 -- In Parameters:
149 --   A Pl/Sql record structre.
150 --
151 -- Post Success:
152 --   Processing continues.
153 --
154 -- Post Failure:
155 --   If an error has occurred, an error message and exception will be raised
156 --   but not handled.
157 --
158 -- Developer Implementation Notes:
159 --   Any post-processing required after the update dml is issued should be
160 --   coded within this procedure. It is important to note that any 3rd party
161 --   maintenance should be reviewed before placing in this procedure.
162 --
163 -- Access Status:
164 --   Internal Row Handler Use Only.
165 --
166 -- {End Of Comments}
167 -- ----------------------------------------------------------------------------
168 Procedure post_update(p_rec in pqh_bgm_shd.g_rec_type) is
169 --
170   l_proc  varchar2(72) := g_package||'post_update';
171 --
172 Begin
173   hr_utility.set_location('Entering:'||l_proc, 5);
174 --
175   --
176   -- Start of API User Hook for post_update.
177   --
178   begin
179     --
180     pqh_bgm_rku.after_update
181       (
182   p_budget_gl_flex_map_id         =>p_rec.budget_gl_flex_map_id
183  ,p_budget_id                     =>p_rec.budget_id
184  ,p_gl_account_segment            =>p_rec.gl_account_segment
185  ,p_payroll_cost_segment          =>p_rec.payroll_cost_segment
186  ,p_object_version_number         =>p_rec.object_version_number
187  ,p_budget_id_o                   =>pqh_bgm_shd.g_old_rec.budget_id
188  ,p_gl_account_segment_o          =>pqh_bgm_shd.g_old_rec.gl_account_segment
189  ,p_payroll_cost_segment_o        =>pqh_bgm_shd.g_old_rec.payroll_cost_segment
190  ,p_object_version_number_o       =>pqh_bgm_shd.g_old_rec.object_version_number
191       );
192     --
193   exception
194     --
195     when hr_api.cannot_find_prog_unit then
196       --
197       hr_api.cannot_find_prog_unit_error
198         (p_module_name => 'pqh_budget_gl_flex_maps'
199         ,p_hook_type   => 'AU');
200       --
201   end;
202   --
203   -- End of API User Hook for post_update.
204   --
205   --
206   hr_utility.set_location(' Leaving:'||l_proc, 10);
207 End post_update;
208 --
209 -- ----------------------------------------------------------------------------
210 -- |-----------------------------< convert_defs >-----------------------------|
211 -- ----------------------------------------------------------------------------
212 -- {Start Of Comments}
213 --
214 -- Description:
215 --   The Convert_Defs procedure has one very important function:
216 --   It must return the record structure for the row with all system defaulted
217 --   values converted into its corresponding parameter value for update. When
218 --   we attempt to update a row through the Upd process , certain
219 --   parameters can be defaulted which enables flexibility in the calling of
220 --   the upd process (e.g. only attributes which need to be updated need to be
221 --   specified). For the upd process to determine which attributes
222 --   have NOT been specified we need to check if the parameter has a reserved
223 --   system default value. Therefore, for all parameters which have a
224 --   corresponding reserved system default mechanism specified we need to
225 --   check if a system default is being used. If a system default is being
226 --   used then we convert the defaulted value into its corresponding attribute
227 --   value held in the g_old_rec data structure.
228 --
229 -- Prerequisites:
230 --   This private function can only be called from the upd process.
231 --
232 -- In Parameters:
233 --   A Pl/Sql record structre.
234 --
235 -- Post Success:
236 --   The record structure will be returned with all system defaulted parameter
237 --   values converted into its current row attribute value.
238 --
239 -- Post Failure:
240 --   No direct error handling is required within this function. Any possible
241 --   errors within this procedure will be a PL/SQL value error due to conversion
242 --   of datatypes or data lengths.
243 --
244 -- Developer Implementation Notes:
245 --   None.
246 --
247 -- Access Status:
248 --   Internal Row Handler Use Only.
249 --
250 -- {End Of Comments}
251 -- ----------------------------------------------------------------------------
252 Procedure convert_defs(p_rec in out nocopy pqh_bgm_shd.g_rec_type) is
253 --
254   l_proc  varchar2(72) := g_package||'convert_defs';
255 --
256 Begin
257   --
258   hr_utility.set_location('Entering:'||l_proc, 5);
259   --
260   -- We must now examine each argument value in the
261   -- p_rec plsql record structure
262   -- to see if a system default is being used. If a system default
263   -- is being used then we must set to the 'current' argument value.
264   --
265   If (p_rec.budget_id = hr_api.g_number) then
266     p_rec.budget_id :=
267     pqh_bgm_shd.g_old_rec.budget_id;
268   End If;
269   If (p_rec.gl_account_segment = hr_api.g_varchar2) then
270     p_rec.gl_account_segment :=
271     pqh_bgm_shd.g_old_rec.gl_account_segment;
272   End If;
273   If (p_rec.payroll_cost_segment = hr_api.g_varchar2) then
274     p_rec.payroll_cost_segment :=
275     pqh_bgm_shd.g_old_rec.payroll_cost_segment;
276   End If;
277 
278   --
279   hr_utility.set_location(' Leaving:'||l_proc, 10);
280 --
281 End convert_defs;
282 --
283 -- ----------------------------------------------------------------------------
284 -- |---------------------------------< upd >----------------------------------|
285 -- ----------------------------------------------------------------------------
286 Procedure upd
287   (
288   p_rec        in out nocopy pqh_bgm_shd.g_rec_type
289   ) is
290 --
291   l_proc  varchar2(72) := g_package||'upd';
292 --
293 Begin
294   hr_utility.set_location('Entering:'||l_proc, 5);
295   --
296   -- We must lock the row which we need to update.
297   --
298   pqh_bgm_shd.lck
299 	(
300 	p_rec.budget_gl_flex_map_id,
301 	p_rec.object_version_number
302 	);
303   --
304   -- 1. During an update system defaults are used to determine if
305   --    arguments have been defaulted or not. We must therefore
306   --    derive the full record structure values to be updated.
307   --
308   -- 2. Call the supporting update validate operations.
309   --
310   convert_defs(p_rec);
311   pqh_bgm_bus.update_validate(p_rec);
312   --
313   -- Call the supporting pre-update operation
314   --
315   pre_update(p_rec);
316   --
317   -- Update the row.
318   --
319   update_dml(p_rec);
320   --
321   -- Call the supporting post-update operation
322   --
323   post_update(p_rec);
324 End upd;
325 --
326 -- ----------------------------------------------------------------------------
327 -- |---------------------------------< upd >----------------------------------|
328 -- ----------------------------------------------------------------------------
329 Procedure upd
330   (
331   p_budget_gl_flex_map_id        in number,
332   p_budget_id                    in number           default hr_api.g_number,
333   p_gl_account_segment           in varchar2         default hr_api.g_varchar2,
334   p_payroll_cost_segment         in varchar2         default hr_api.g_varchar2,
335   p_object_version_number        in out nocopy number
336   ) is
337 --
338   l_rec	  pqh_bgm_shd.g_rec_type;
339   l_proc  varchar2(72) := g_package||'upd';
340 --
341 Begin
342   hr_utility.set_location('Entering:'||l_proc, 5);
343   --
344   -- Call conversion function to turn arguments into the
345   -- l_rec structure.
346   --
347   l_rec :=
348   pqh_bgm_shd.convert_args
349   (
350   p_budget_gl_flex_map_id,
351   p_budget_id,
352   p_gl_account_segment,
353   p_payroll_cost_segment,
354   p_object_version_number
355   );
356   --
357   -- Having converted the arguments into the
358   -- plsql record structure we call the corresponding record
359   -- business process.
360   --
361   upd(l_rec);
362   p_object_version_number := l_rec.object_version_number;
363   --
364   hr_utility.set_location(' Leaving:'||l_proc, 10);
365 End upd;
366 --
367 end pqh_bgm_upd;