DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PEV_UPD

Source


1 Package Body pay_pev_upd as
2 /* $Header: pypperhi.pkb 120.1.12010000.1 2008/07/27 23:25:17 appldev ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_pev_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
55   (p_rec in out nocopy pay_pev_shd.g_rec_type
56   ) is
57 --
58   l_proc  varchar2(72) := g_package||'update_dml';
59 --
60 Begin
61   hr_utility.set_location('Entering:'||l_proc, 5);
62   --
63   -- Increment the object version
64   p_rec.object_version_number := p_rec.object_version_number + 1;
65   --
66   pay_pev_shd.g_api_dml := true;  -- Set the api dml status
67   --
68   -- Update the pay_process_events Row
69   --
70   update pay_process_events
71     set
72      process_event_id                = p_rec.process_event_id
73     ,assignment_id                   = p_rec.assignment_id
74     ,effective_date                  = p_rec.effective_date
75     ,change_type                     = p_rec.change_type
76     ,status                          = p_rec.status
77     ,description                     = p_rec.description
78     ,event_update_id                 = p_rec.event_update_id
79     ,business_group_id               = p_rec.business_group_id
80     ,org_process_event_group_id      = p_rec.org_process_event_group_id
81     ,surrogate_key                   = p_rec.surrogate_key
82     ,object_version_number           = p_rec.object_version_number
83     ,calculation_date                = p_rec.calculation_date
84     ,retroactive_status              = p_rec.retroactive_status
85     ,noted_value                     = p_rec.noted_value
86     where process_event_id = p_rec.process_event_id;
87   --
88   pay_pev_shd.g_api_dml := false;   -- Unset the api dml status
89   --
90   hr_utility.set_location(' Leaving:'||l_proc, 10);
91 --
92 Exception
93   When hr_api.check_integrity_violated Then
94     -- A check constraint has been violated
95     pay_pev_shd.g_api_dml := false;   -- Unset the api dml status
96     pay_pev_shd.constraint_error
97       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98   When hr_api.parent_integrity_violated Then
99     -- Parent integrity has been violated
100     pay_pev_shd.g_api_dml := false;   -- Unset the api dml status
101     pay_pev_shd.constraint_error
102       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103   When hr_api.unique_integrity_violated Then
104     -- Unique integrity has been violated
105     pay_pev_shd.g_api_dml := false;   -- Unset the api dml status
106     pay_pev_shd.constraint_error
107       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
108   When Others Then
109     pay_pev_shd.g_api_dml := false;   -- Unset the api dml status
110     Raise;
111 End update_dml;
112 --
113 -- ----------------------------------------------------------------------------
114 -- |------------------------------< pre_update >------------------------------|
115 -- ----------------------------------------------------------------------------
116 -- {Start Of Comments}
117 --
118 -- Description:
119 --   This private procedure contains any processing which is required before
120 --   the update dml.
121 --
122 -- Prerequisites:
123 --   This is an internal procedure which is called from the upd procedure.
124 --
125 -- In Parameters:
126 --   A Pl/Sql record structure.
127 --
128 -- Post Success:
129 --   Processing continues.
130 --
131 -- Post Failure:
132 --   If an error has occurred, an error message and exception wil be raised
133 --   but not handled.
134 --
135 -- Developer Implementation Notes:
136 --   Any pre-processing required before the update dml is issued should be
137 --   coded within this procedure. It is important to note that any 3rd party
138 --   maintenance should be reviewed before placing in this procedure.
139 --
140 -- Access Status:
141 --   Internal Row Handler Use Only.
142 --
143 -- {End Of Comments}
144 -- ----------------------------------------------------------------------------
145 Procedure pre_update
146   (p_rec in pay_pev_shd.g_rec_type
147   ) is
148 --
149   l_proc  varchar2(72) := g_package||'pre_update';
150 --
151 Begin
152   hr_utility.set_location('Entering:'||l_proc, 5);
153   --
154   hr_utility.set_location(' Leaving:'||l_proc, 10);
155 End pre_update;
156 --
157 -- ----------------------------------------------------------------------------
158 -- |-----------------------------< post_update >------------------------------|
159 -- ----------------------------------------------------------------------------
160 -- {Start Of Comments}
161 --
162 -- Description:
163 --   This private procedure contains any processing which is required after the
164 --   update dml.
165 --
166 -- Prerequisites:
167 --   This is an internal procedure which is called from the upd procedure.
168 --
169 -- In Parameters:
170 --   A Pl/Sql record structure.
171 --
172 -- Post Success:
173 --   Processing continues.
174 --
175 -- Post Failure:
176 --   If an error has occurred, an error message and exception will be raised
177 --   but not handled.
178 --
179 -- Developer Implementation Notes:
180 --   Any post-processing required after the update dml is issued should be
181 --   coded within this procedure. It is important to note that any 3rd party
182 --   maintenance should be reviewed before placing in this procedure.
183 --
184 -- Access Status:
185 --   Internal Row Handler Use Only.
186 --
187 -- {End Of Comments}
188 -- ----------------------------------------------------------------------------
189 Procedure post_update
190   (p_rec                          in pay_pev_shd.g_rec_type
191   ) is
192 --
193   l_proc  varchar2(72) := g_package||'post_update';
194 --
195 Begin
196   hr_utility.set_location('Entering:'||l_proc, 5);
197   begin
198     --
199     pay_pev_rku.after_update
200       (p_process_event_id
201       => p_rec.process_event_id
202       ,p_assignment_id
203       => p_rec.assignment_id
204       ,p_effective_date
205       => p_rec.effective_date
206       ,p_change_type
207       => p_rec.change_type
208       ,p_status
209       => p_rec.status
210       ,p_description
211       => p_rec.description
212       ,p_event_update_id
213       => p_rec.event_update_id
214       ,p_business_group_id
215       => p_rec.business_group_id
216       ,p_org_process_event_group_id
217       => p_rec.org_process_event_group_id
218       ,p_surrogate_key
219       => p_rec.surrogate_key
220       ,p_object_version_number
221       => p_rec.object_version_number
222       ,p_calculation_date
223       => p_rec.calculation_date
224       ,p_retroactive_status
225       => p_rec.retroactive_status
226       ,p_noted_value
227       => p_rec.noted_value
228       ,p_assignment_id_o
229       => pay_pev_shd.g_old_rec.assignment_id
230       ,p_effective_date_o
231       => pay_pev_shd.g_old_rec.effective_date
232       ,p_change_type_o
233       => pay_pev_shd.g_old_rec.change_type
234       ,p_status_o
235       => pay_pev_shd.g_old_rec.status
236       ,p_description_o
237       => pay_pev_shd.g_old_rec.description
238       ,p_event_update_id_o
239       => pay_pev_shd.g_old_rec.event_update_id
240       ,p_business_group_id_o
241       => pay_pev_shd.g_old_rec.business_group_id
242       ,p_org_process_event_group_id_o
243       => pay_pev_shd.g_old_rec.org_process_event_group_id
244       ,p_surrogate_key_o
245       => pay_pev_shd.g_old_rec.surrogate_key
246       ,p_object_version_number_o
247       => pay_pev_shd.g_old_rec.object_version_number
248       ,p_calculation_date_o
249       => pay_pev_shd.g_old_rec.calculation_date
250       ,p_retroactive_status_o
251       => pay_pev_shd.g_old_rec.retroactive_status
252       ,p_noted_value_o
253       => pay_pev_shd.g_old_rec.noted_value
254       );
255     --
256   exception
257     --
258     when hr_api.cannot_find_prog_unit then
259       --
260       hr_api.cannot_find_prog_unit_error
261         (p_module_name => 'PAY_PROCESS_EVENTS'
262         ,p_hook_type   => 'AU');
263       --
264   end;
265   --
266   hr_utility.set_location(' Leaving:'||l_proc, 10);
267 End post_update;
268 --
269 -- ----------------------------------------------------------------------------
270 -- |-----------------------------< convert_defs >-----------------------------|
271 -- ----------------------------------------------------------------------------
272 -- {Start Of Comments}
273 --
274 -- Description:
275 --   The Convert_Defs procedure has one very important function:
276 --   It must return the record structure for the row with all system defaulted
277 --   values converted into its corresponding parameter value for update. When
278 --   we attempt to update a row through the Upd process , certain
279 --   parameters can be defaulted which enables flexibility in the calling of
280 --   the upd process (e.g. only attributes which need to be updated need to be
281 --   specified). For the upd process to determine which attributes
282 --   have NOT been specified we need to check if the parameter has a reserved
283 --   system default value. Therefore, for all parameters which have a
284 --   corresponding reserved system default mechanism specified we need to
285 --   check if a system default is being used. If a system default is being
286 --   used then we convert the defaulted value into its corresponding attribute
287 --   value held in the g_old_rec data structure.
288 --
289 -- Prerequisites:
290 --   This private function can only be called from the upd process.
291 --
292 -- In Parameters:
293 --   A Pl/Sql record structure.
294 --
295 -- Post Success:
296 --   The record structure will be returned with all system defaulted parameter
297 --   values converted into its current row attribute value.
298 --
299 -- Post Failure:
300 --   No direct error handling is required within this function. Any possible
301 --   errors within this procedure will be a PL/SQL value error due to
302 --   conversion of datatypes or data lengths.
303 --
304 -- Developer Implementation Notes:
305 --   None.
306 --
307 -- Access Status:
308 --   Internal Row Handler Use Only.
309 --
310 -- {End Of Comments}
311 -- ----------------------------------------------------------------------------
312 Procedure convert_defs
313   (p_rec in out nocopy pay_pev_shd.g_rec_type
314   ) is
315 --
316 Begin
317   --
318   -- We must now examine each argument value in the
319   -- p_rec plsql record structure
320   -- to see if a system default is being used. If a system default
321   -- is being used then we must set to the 'current' argument value.
322   --
323   If (p_rec.assignment_id = hr_api.g_number) then
324     p_rec.assignment_id :=
325     pay_pev_shd.g_old_rec.assignment_id;
326   End If;
327   If (p_rec.effective_date = hr_api.g_date) then
328     p_rec.effective_date :=
329     pay_pev_shd.g_old_rec.effective_date;
330   End If;
331   If (p_rec.change_type = hr_api.g_varchar2) then
332     p_rec.change_type :=
333     pay_pev_shd.g_old_rec.change_type;
334   End If;
335   If (p_rec.status = hr_api.g_varchar2) then
336     p_rec.status :=
337     pay_pev_shd.g_old_rec.status;
338   End If;
339   If (p_rec.description = hr_api.g_varchar2) then
340     p_rec.description :=
341     pay_pev_shd.g_old_rec.description;
342   End If;
343   If (p_rec.event_update_id = hr_api.g_number) then
344     p_rec.event_update_id :=
345     pay_pev_shd.g_old_rec.event_update_id;
346   End If;
347   If (p_rec.business_group_id = hr_api.g_number) then
348     p_rec.business_group_id :=
349     pay_pev_shd.g_old_rec.business_group_id;
350   End If;
351   If (p_rec.org_process_event_group_id = hr_api.g_number) then
352     p_rec.org_process_event_group_id :=
353     pay_pev_shd.g_old_rec.org_process_event_group_id;
354   End If;
355   If (p_rec.surrogate_key = hr_api.g_varchar2) then
356     p_rec.surrogate_key :=
357     pay_pev_shd.g_old_rec.surrogate_key;
358   End If;
359   If (p_rec.calculation_date = hr_api.g_date) then
360     p_rec.calculation_date :=
361     pay_pev_shd.g_old_rec.calculation_date;
362   End If;
363   If (p_rec.retroactive_status = hr_api.g_varchar2) then
364     p_rec.retroactive_status :=
365     pay_pev_shd.g_old_rec.retroactive_status;
366   End If;
367   If (p_rec.noted_value = hr_api.g_varchar2) then
368     p_rec.noted_value :=
369     pay_pev_shd.g_old_rec.noted_value;
370   End If;
371   --
372 End convert_defs;
373 --
374 -- ----------------------------------------------------------------------------
375 -- |---------------------------------< upd >----------------------------------|
376 -- ----------------------------------------------------------------------------
377 Procedure upd
378   (p_rec                          in out nocopy pay_pev_shd.g_rec_type
379   ) is
380 --
381   l_proc  varchar2(72) := g_package||'upd';
382 --
383 Begin
384   hr_utility.set_location('Entering:'||l_proc, 5);
385   --
386   -- We must lock the row which we need to update.
387   --
388   pay_pev_shd.lck
389     (p_rec.process_event_id
390     ,p_rec.object_version_number
391     );
392   --
393   -- 1. During an update system defaults are used to determine if
394   --    arguments have been defaulted or not. We must therefore
395   --    derive the full record structure values to be updated.
396   --
397   -- 2. Call the supporting update validate operations.
398   --
399   convert_defs(p_rec);
400   pay_pev_bus.update_validate
401      (p_rec
402      );
403   --
404   -- Call the supporting pre-update operation
405   --
406   pay_pev_upd.pre_update(p_rec);
407   --
408   -- Update the row.
409   --
410   pay_pev_upd.update_dml(p_rec);
411   --
412   -- Call the supporting post-update operation
413   --
414   pay_pev_upd.post_update
415      (p_rec
416      );
417 End upd;
418 --
419 -- ----------------------------------------------------------------------------
420 -- |---------------------------------< upd >----------------------------------|
421 -- ----------------------------------------------------------------------------
422 Procedure upd
423   (p_process_event_id             in     number
424   ,p_object_version_number        in out nocopy    number
425   ,p_assignment_id                in     number    default hr_api.g_number
426   ,p_effective_date               in     date      default hr_api.g_date
427   ,p_change_type                  in     varchar2  default hr_api.g_varchar2
428   ,p_status                       in     varchar2  default hr_api.g_varchar2
429   ,p_description                  in     varchar2  default hr_api.g_varchar2
430   ,p_event_update_id              in     number    default hr_api.g_number
431   ,p_business_group_id            in     number    default hr_api.g_number
432   ,p_org_process_event_group_id   in     number    default hr_api.g_number
433   ,p_surrogate_key                in     varchar2  default hr_api.g_varchar2
434   ,p_calculation_date             in     date      default hr_api.g_date
435   ,p_retroactive_status           in     varchar2  default hr_api.g_varchar2
436   ,p_noted_value                  in     varchar2  default hr_api.g_varchar2
437   ) is
438 --
439   l_rec	  pay_pev_shd.g_rec_type;
440   l_proc  varchar2(72) := g_package||'upd';
441 --
442 Begin
443   hr_utility.set_location('Entering:'||l_proc, 5);
444   --
445   -- Call conversion function to turn arguments into the
446   -- l_rec structure.
447   --
448   l_rec :=
449   pay_pev_shd.convert_args
450   (p_process_event_id
451   ,p_assignment_id
452   ,p_effective_date
453   ,p_change_type
454   ,p_status
455   ,p_description
456   ,p_event_update_id
457   ,p_business_group_id
458   ,p_org_process_event_group_id
459   ,p_surrogate_key
460   ,p_object_version_number
461   ,p_calculation_date
462   ,p_retroactive_status
463   ,p_noted_value
464   );
465   --
466   -- Having converted the arguments into the
467   -- plsql record structure we call the corresponding record
468   -- business process.
469   --
470   pay_pev_upd.upd
471      (l_rec
472      );
473   p_object_version_number := l_rec.object_version_number;
474   --
475   hr_utility.set_location(' Leaving:'||l_proc, 10);
476 End upd;
477 --
478 end pay_pev_upd;