DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_BVR_UPD

Source


1 Package Body pqh_bvr_upd as
2 /* $Header: pqbvrrhi.pkb 115.10 2002/12/05 19:30:27 rpasapul ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_bvr_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_bvr_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_versions Row
64   --
65   update pqh_budget_versions
66   set
67   budget_version_id                 = p_rec.budget_version_id,
68   budget_id                         = p_rec.budget_id,
69   version_number                    = p_rec.version_number,
70   date_from                         = p_rec.date_from,
71   date_to                           = p_rec.date_to,
72   transfered_to_gl_flag             = p_rec.transfered_to_gl_flag,
73   gl_status                         = p_rec.gl_status,
74   xfer_to_other_apps_cd             = p_rec.xfer_to_other_apps_cd,
75   object_version_number             = p_rec.object_version_number,
76   budget_unit1_value                = p_rec.budget_unit1_value,
77   budget_unit2_value                = p_rec.budget_unit2_value,
78   budget_unit3_value                = p_rec.budget_unit3_value,
79   budget_unit1_available            = p_rec.budget_unit1_available,
80   budget_unit2_available            = p_rec.budget_unit2_available,
81   budget_unit3_available            = p_rec.budget_unit3_available
82   where budget_version_id = p_rec.budget_version_id;
83   --
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     pqh_bvr_shd.constraint_error
91       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
92   When hr_api.parent_integrity_violated Then
93     -- Parent integrity has been violated
94     pqh_bvr_shd.constraint_error
95       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
96   When hr_api.unique_integrity_violated Then
97     -- Unique integrity has been violated
98     pqh_bvr_shd.constraint_error
99       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100   When Others Then
101     Raise;
102 End update_dml;
103 --
104 -- ----------------------------------------------------------------------------
105 -- |------------------------------< pre_update >------------------------------|
106 -- ----------------------------------------------------------------------------
107 -- {Start Of Comments}
108 --
109 -- Description:
110 --   This private procedure contains any processing which is required before
111 --   the update dml.
112 --
113 -- Prerequisites:
114 --   This is an internal procedure which is called from the upd procedure.
115 --
116 -- In Parameters:
117 --   A Pl/Sql record structre.
118 --
119 -- Post Success:
120 --   Processing continues.
121 --
122 -- Post Failure:
123 --   If an error has occurred, an error message and exception will be raised
124 --   but not handled.
125 --
126 -- Developer Implementation Notes:
127 --   Any pre-processing required before the update dml is issued should be
128 --   coded within this procedure. It is important to note that any 3rd party
129 --   maintenance should be reviewed before placing in this procedure.
130 --
131 -- Access Status:
132 --   Internal Row Handler Use Only.
133 --
134 -- {End Of Comments}
135 -- ----------------------------------------------------------------------------
136 Procedure pre_update(p_rec in pqh_bvr_shd.g_rec_type) is
137 --
138   l_proc  varchar2(72) := g_package||'pre_update';
139 --
140 Begin
141   hr_utility.set_location('Entering:'||l_proc, 5);
142   --
143   hr_utility.set_location(' Leaving:'||l_proc, 10);
144 End pre_update;
145 --
146 -- ----------------------------------------------------------------------------
147 -- |-----------------------------< post_update >------------------------------|
148 -- ----------------------------------------------------------------------------
149 -- {Start Of Comments}
150 --
151 -- Description:
152 --   This private procedure contains any processing which is required after the
153 --   update dml.
154 --
155 -- Prerequisites:
156 --   This is an internal procedure which is called from the upd procedure.
157 --
158 -- In Parameters:
159 --   A Pl/Sql record structre.
160 --
161 -- Post Success:
162 --   Processing continues.
163 --
164 -- Post Failure:
165 --   If an error has occurred, an error message and exception will be raised
166 --   but not handled.
167 --
168 -- Developer Implementation Notes:
169 --   Any post-processing required after the update dml is issued should be
170 --   coded within this procedure. It is important to note that any 3rd party
171 --   maintenance should be reviewed before placing in this procedure.
172 --
173 -- Access Status:
174 --   Internal Row Handler Use Only.
175 --
176 -- {End Of Comments}
177 -- ----------------------------------------------------------------------------
178 Procedure post_update(
179 p_effective_date in date,p_rec in pqh_bvr_shd.g_rec_type) is
180 --
181   l_proc  varchar2(72) := g_package||'post_update';
182 
183 
184 --
185 
186  l_budgets_rec   pqh_budgets%ROWTYPE;
187 
188  cursor csr_budget(p_budget_id IN number) is
189  select *
190  from pqh_budgets
191  where budget_id = p_budget_id
192    and nvl(status,'X') <> 'FROZEN';
193 
194  l_object_version_number   number(9);
195 
196 --
197 
198 --
199 Begin
200   hr_utility.set_location('Entering:'||l_proc, 5);
201 --
202   --
203   -- Start of API User Hook for post_update.
204   --
205   begin
206     --
207   /*
208      Set the budget status to FROZEN . When budget is forzen, user cannot change UOM in budget
209    */
210     --
211       OPEN csr_budget(p_budget_id =>  p_rec.budget_id);
212         LOOP
213           FETCH csr_budget INTO l_budgets_rec;
214           EXIT WHEN csr_budget%NOTFOUND;
215 
216              hr_utility.set_location('Budget Status :'||l_budgets_rec.status, 6);
217 
218              -- call update API of budget to update the budget status to frozen
219 
220                l_object_version_number := l_budgets_rec.object_version_number;
221 
222                pqh_budgets_api.update_budget
223                (
224                 p_budget_id               => l_budgets_rec.budget_id,
225                 p_object_version_number   => l_object_version_number,
226                 p_status                  => 'FROZEN',
227                 p_effective_date          => sysdate
228                );
229         END LOOP;
230       CLOSE csr_budget;
231 
232 
233     --
234 
235     --
236     pqh_bvr_rku.after_update
237       (
238   p_budget_version_id             =>p_rec.budget_version_id
239  ,p_budget_id                     =>p_rec.budget_id
240  ,p_version_number                =>p_rec.version_number
241  ,p_date_from                     =>p_rec.date_from
242  ,p_date_to                       =>p_rec.date_to
243  ,p_transfered_to_gl_flag         =>p_rec.transfered_to_gl_flag
244  ,p_gl_status                     =>p_rec.gl_status
245  ,p_xfer_to_other_apps_cd         =>p_rec.xfer_to_other_apps_cd
246  ,p_object_version_number         =>p_rec.object_version_number
247  ,p_budget_unit1_value            =>p_rec.budget_unit1_value
248  ,p_budget_unit2_value            =>p_rec.budget_unit2_value
249  ,p_budget_unit3_value            =>p_rec.budget_unit3_value
250  ,p_budget_unit1_available        =>p_rec.budget_unit1_available
251  ,p_budget_unit2_available        =>p_rec.budget_unit2_available
252  ,p_budget_unit3_available        =>p_rec.budget_unit3_available
253  ,p_effective_date                =>p_effective_date
254  ,p_budget_id_o                   =>pqh_bvr_shd.g_old_rec.budget_id
255  ,p_version_number_o              =>pqh_bvr_shd.g_old_rec.version_number
256  ,p_date_from_o                   =>pqh_bvr_shd.g_old_rec.date_from
257  ,p_date_to_o                     =>pqh_bvr_shd.g_old_rec.date_to
258  ,p_transfered_to_gl_flag_o       =>pqh_bvr_shd.g_old_rec.transfered_to_gl_flag
259  ,p_gl_status_o                   =>pqh_bvr_shd.g_old_rec.gl_status
260  ,p_xfer_to_other_apps_cd_o       =>pqh_bvr_shd.g_old_rec.xfer_to_other_apps_cd
261  ,p_object_version_number_o       =>pqh_bvr_shd.g_old_rec.object_version_number
262  ,p_budget_unit1_value_o          =>pqh_bvr_shd.g_old_rec.budget_unit1_value
263  ,p_budget_unit2_value_o          =>pqh_bvr_shd.g_old_rec.budget_unit2_value
264  ,p_budget_unit3_value_o          =>pqh_bvr_shd.g_old_rec.budget_unit3_value
265  ,p_budget_unit1_available_o      =>pqh_bvr_shd.g_old_rec.budget_unit1_available
266  ,p_budget_unit2_available_o      =>pqh_bvr_shd.g_old_rec.budget_unit2_available
267  ,p_budget_unit3_available_o      =>pqh_bvr_shd.g_old_rec.budget_unit3_available
268       );
269     --
270   exception
271     --
272     when hr_api.cannot_find_prog_unit then
273       --
274       hr_api.cannot_find_prog_unit_error
275         (p_module_name => 'pqh_budget_versions'
276         ,p_hook_type   => 'AU');
277       --
278   end;
279   --
280   -- End of API User Hook for post_update.
281   --
282   --
283   hr_utility.set_location(' Leaving:'||l_proc, 10);
284 End post_update;
285 --
286 -- ----------------------------------------------------------------------------
287 -- |-----------------------------< convert_defs >-----------------------------|
288 -- ----------------------------------------------------------------------------
289 -- {Start Of Comments}
290 --
291 -- Description:
292 --   The Convert_Defs procedure has one very important function:
293 --   It must return the record structure for the row with all system defaulted
294 --   values converted into its corresponding parameter value for update. When
295 --   we attempt to update a row through the Upd process , certain
296 --   parameters can be defaulted which enables flexibility in the calling of
297 --   the upd process (e.g. only attributes which need to be updated need to be
298 --   specified). For the upd process to determine which attributes
299 --   have NOT been specified we need to check if the parameter has a reserved
300 --   system default value. Therefore, for all parameters which have a
301 --   corresponding reserved system default mechanism specified we need to
302 --   check if a system default is being used. If a system default is being
303 --   used then we convert the defaulted value into its corresponding attribute
304 --   value held in the g_old_rec data structure.
305 --
306 -- Prerequisites:
307 --   This private function can only be called from the upd process.
308 --
309 -- In Parameters:
310 --   A Pl/Sql record structre.
311 --
312 -- Post Success:
313 --   The record structure will be returned with all system defaulted parameter
314 --   values converted into its current row attribute value.
315 --
316 -- Post Failure:
317 --   No direct error handling is required within this function. Any possible
318 --   errors within this procedure will be a PL/SQL value error due to conversion
319 --   of datatypes or data lengths.
320 --
321 -- Developer Implementation Notes:
322 --   None.
323 --
324 -- Access Status:
325 --   Internal Row Handler Use Only.
326 --
327 -- {End Of Comments}
328 -- ----------------------------------------------------------------------------
329 Procedure convert_defs(p_rec in out nocopy pqh_bvr_shd.g_rec_type) is
330 --
331   l_proc  varchar2(72) := g_package||'convert_defs';
332 --
333 Begin
334   --
335   hr_utility.set_location('Entering:'||l_proc, 5);
336   --
337   -- We must now examine each argument value in the
338   -- p_rec plsql record structure
339   -- to see if a system default is being used. If a system default
340   -- is being used then we must set to the 'current' argument value.
341   --
342   If (p_rec.budget_id = hr_api.g_number) then
343     p_rec.budget_id :=
344     pqh_bvr_shd.g_old_rec.budget_id;
345   End If;
346   If (p_rec.version_number = hr_api.g_number) then
347     p_rec.version_number :=
348     pqh_bvr_shd.g_old_rec.version_number;
349   End If;
350   If (p_rec.date_from = hr_api.g_date) then
351     p_rec.date_from :=
352     pqh_bvr_shd.g_old_rec.date_from;
353   End If;
354   If (p_rec.date_to = hr_api.g_date) then
355     p_rec.date_to :=
356     pqh_bvr_shd.g_old_rec.date_to;
357   End If;
358   If (p_rec.transfered_to_gl_flag = hr_api.g_varchar2) then
359     p_rec.transfered_to_gl_flag :=
360     pqh_bvr_shd.g_old_rec.transfered_to_gl_flag;
361   End If;
362   If (p_rec.gl_status  = hr_api.g_varchar2) then
363     p_rec.gl_status  :=
364     pqh_bvr_shd.g_old_rec.gl_status;
365   End If;
366   If (p_rec.xfer_to_other_apps_cd = hr_api.g_varchar2) then
367     p_rec.xfer_to_other_apps_cd :=
368     pqh_bvr_shd.g_old_rec.xfer_to_other_apps_cd;
369   End If;
370   If (p_rec.budget_unit1_value = hr_api.g_number) then
371     p_rec.budget_unit1_value :=
372     pqh_bvr_shd.g_old_rec.budget_unit1_value;
373   End If;
374   If (p_rec.budget_unit2_value = hr_api.g_number) then
375     p_rec.budget_unit2_value :=
376     pqh_bvr_shd.g_old_rec.budget_unit2_value;
377   End If;
378   If (p_rec.budget_unit3_value = hr_api.g_number) then
379     p_rec.budget_unit3_value :=
380     pqh_bvr_shd.g_old_rec.budget_unit3_value;
381   End If;
382   If (p_rec.budget_unit1_available = hr_api.g_number) then
383     p_rec.budget_unit1_available :=
384     pqh_bvr_shd.g_old_rec.budget_unit1_available;
385   End If;
386   If (p_rec.budget_unit2_available = hr_api.g_number) then
387     p_rec.budget_unit2_available :=
388     pqh_bvr_shd.g_old_rec.budget_unit2_available;
389   End If;
390   If (p_rec.budget_unit3_available = hr_api.g_number) then
391     p_rec.budget_unit3_available :=
392     pqh_bvr_shd.g_old_rec.budget_unit3_available;
393   End If;
394   --
395   hr_utility.set_location(' Leaving:'||l_proc, 10);
396 --
397 End convert_defs;
398 --
399 -- ----------------------------------------------------------------------------
400 -- |---------------------------------< upd >----------------------------------|
401 -- ----------------------------------------------------------------------------
402 Procedure upd
403   (
404   p_effective_date in date,
405   p_rec        in out nocopy pqh_bvr_shd.g_rec_type
406   ) is
407 --
408   l_proc  varchar2(72) := g_package||'upd';
409 --
410 Begin
411   hr_utility.set_location('Entering:'||l_proc, 5);
412   --
413   -- We must lock the row which we need to update.
414   --
415   pqh_bvr_shd.lck
416 	(
417 	p_rec.budget_version_id,
418 	p_rec.object_version_number
419 	);
420   --
421   -- 1. During an update system defaults are used to determine if
422   --    arguments have been defaulted or not. We must therefore
423   --    derive the full record structure values to be updated.
424   --
425   -- 2. Call the supporting update validate operations.
426   --
427   convert_defs(p_rec);
428   pqh_bvr_bus.update_validate(p_rec
429   ,p_effective_date);
430   --
431   -- Call the supporting pre-update operation
432   --
433   pre_update(p_rec);
434   --
435   -- Update the row.
436   --
437   update_dml(p_rec);
438   --
439   -- Call the supporting post-update operation
440   --
441   post_update(
442 p_effective_date,p_rec);
443 End upd;
444 --
445 -- ----------------------------------------------------------------------------
446 -- |---------------------------------< upd >----------------------------------|
447 -- ----------------------------------------------------------------------------
448 Procedure upd
449   (
450   p_effective_date in date,
451   p_budget_version_id            in number,
452   p_budget_id                    in number           default hr_api.g_number,
453   p_version_number               in number           default hr_api.g_number,
454   p_date_from                    in date             default hr_api.g_date,
455   p_date_to                      in date             default hr_api.g_date,
456   p_transfered_to_gl_flag        in varchar2         default hr_api.g_varchar2,
457   p_gl_status                    in varchar2         default hr_api.g_varchar2,
458   p_xfer_to_other_apps_cd        in varchar2         default hr_api.g_varchar2,
459   p_object_version_number        in out nocopy number,
460   p_budget_unit1_value           in number           default hr_api.g_number,
461   p_budget_unit2_value           in number           default hr_api.g_number,
462   p_budget_unit3_value           in number           default hr_api.g_number,
463   p_budget_unit1_available       in number           default hr_api.g_number,
464   p_budget_unit2_available       in number           default hr_api.g_number,
465   p_budget_unit3_available       in number           default hr_api.g_number
466   ) is
467 --
468   l_rec	  pqh_bvr_shd.g_rec_type;
469   l_proc  varchar2(72) := g_package||'upd';
470 --
471 Begin
472   hr_utility.set_location('Entering:'||l_proc, 5);
473   --
474   -- Call conversion function to turn arguments into the
475   -- l_rec structure.
476   --
477   l_rec :=
478   pqh_bvr_shd.convert_args
479   (
480   p_budget_version_id,
481   p_budget_id,
482   p_version_number,
483   p_date_from,
484   p_date_to,
485   p_transfered_to_gl_flag,
486   p_gl_status,
487   p_xfer_to_other_apps_cd,
488   p_object_version_number,
489   p_budget_unit1_value,
490   p_budget_unit2_value,
491   p_budget_unit3_value,
492   p_budget_unit1_available,
493   p_budget_unit2_available,
494   p_budget_unit3_available
495   );
496   --
497   -- Having converted the arguments into the
498   -- plsql record structure we call the corresponding record
499   -- business process.
500   --
501   upd(
502     p_effective_date,l_rec);
503   p_object_version_number := l_rec.object_version_number;
504   --
505   hr_utility.set_location(' Leaving:'||l_proc, 10);
506 End upd;
507 --
508 end pqh_bvr_upd;