DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_BTH_UPD

Source


1 Package Body pay_bth_upd as
2 /* $Header: pybthrhi.pkb 120.2 2005/06/12 16:19:52 susivasu noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_bth_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_bth_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_bth_shd.g_api_dml := true;  -- Set the api dml status
67   --
68   -- Update the pay_batch_headers Row
69   --
70   update pay_batch_headers
71     set
72      batch_id                        = p_rec.batch_id
73     ,batch_name                      = p_rec.batch_name
74     ,batch_status                    = p_rec.batch_status
75     ,action_if_exists                = p_rec.action_if_exists
76     ,batch_reference                 = p_rec.batch_reference
77     ,batch_source                    = p_rec.batch_source
78     ,batch_type                      = p_rec.batch_type
79     ,comments                        = p_rec.comments
80     ,date_effective_changes          = p_rec.date_effective_changes
81     ,purge_after_transfer            = p_rec.purge_after_transfer
82     ,reject_if_future_changes        = p_rec.reject_if_future_changes
83     ,object_version_number           = p_rec.object_version_number
84     ,reject_if_results_exists        = p_rec.reject_if_results_exists
85     ,purge_after_rollback            = p_rec.purge_after_rollback
86     ,REJECT_ENTRY_NOT_REMOVED        = p_rec.REJECT_ENTRY_NOT_REMOVED
87     ,ROLLBACK_ENTRY_UPDATES          = p_rec.ROLLBACK_ENTRY_UPDATES
88     where batch_id = p_rec.batch_id;
89   --
90   pay_bth_shd.g_api_dml := false;   -- Unset the api dml status
91   --
92   hr_utility.set_location(' Leaving:'||l_proc, 10);
93 --
94 Exception
95   When hr_api.check_integrity_violated Then
96     -- A check constraint has been violated
97     pay_bth_shd.g_api_dml := false;   -- Unset the api dml status
98     pay_bth_shd.constraint_error
99       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100   When hr_api.parent_integrity_violated Then
101     -- Parent integrity has been violated
102     pay_bth_shd.g_api_dml := false;   -- Unset the api dml status
103     pay_bth_shd.constraint_error
104       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105   When hr_api.unique_integrity_violated Then
106     -- Unique integrity has been violated
107     pay_bth_shd.g_api_dml := false;   -- Unset the api dml status
108     pay_bth_shd.constraint_error
109       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110   When Others Then
111     pay_bth_shd.g_api_dml := false;   -- Unset the api dml status
112     Raise;
113 End update_dml;
114 --
115 -- ----------------------------------------------------------------------------
116 -- |------------------------------< pre_update >------------------------------|
117 -- ----------------------------------------------------------------------------
118 -- {Start Of Comments}
119 --
120 -- Description:
121 --   This private procedure contains any processing which is required before
122 --   the update dml.
123 --
124 -- Prerequisites:
125 --   This is an internal procedure which is called from the upd procedure.
126 --
127 -- In Parameters:
128 --   A Pl/Sql record structure.
129 --
130 -- Post Success:
131 --   Processing continues.
132 --
133 -- Post Failure:
134 --   If an error has occurred, an error message and exception wil be raised
135 --   but not handled.
136 --
137 -- Developer Implementation Notes:
138 --   Any pre-processing required before the update dml is issued should be
139 --   coded within this procedure. It is important to note that any 3rd party
140 --   maintenance should be reviewed before placing in this procedure.
141 --
142 -- Access Status:
143 --   Internal Row Handler Use Only.
144 --
145 -- {End Of Comments}
146 -- ----------------------------------------------------------------------------
147 Procedure pre_update
148   (p_rec in pay_bth_shd.g_rec_type
149   ) 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 structure.
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_session_date                 in date
193   ,p_rec                          in pay_bth_shd.g_rec_type
194   ) is
195 --
196   l_proc  varchar2(72) := g_package||'post_update';
197 --
198 Begin
199   hr_utility.set_location('Entering:'||l_proc, 5);
200   begin
201     --
202     pay_bth_rku.after_update
203       (p_session_date
204       => p_session_date
205       ,p_batch_id
206       => p_rec.batch_id
207       ,p_batch_name
208       => p_rec.batch_name
209       ,p_batch_status
210       => p_rec.batch_status
211       ,p_action_if_exists
212       => p_rec.action_if_exists
213       ,p_batch_reference
214       => p_rec.batch_reference
215       ,p_batch_source
216       => p_rec.batch_source
217       ,p_batch_type
218       => p_rec.batch_type
219       ,p_comments
220       => p_rec.comments
221       ,p_date_effective_changes
222       => p_rec.date_effective_changes
223       ,p_purge_after_transfer
224       => p_rec.purge_after_transfer
225       ,p_reject_if_future_changes
226       => p_rec.reject_if_future_changes
227       ,p_object_version_number
228       => p_rec.object_version_number
229       ,p_reject_if_results_exists
230       => p_rec.reject_if_results_exists
231       ,p_purge_after_rollback
232       => p_rec.purge_after_rollback
233       ,p_REJECT_ENTRY_NOT_REMOVED
234       => p_rec.REJECT_ENTRY_NOT_REMOVED
235       ,p_ROLLBACK_ENTRY_UPDATES
236       => p_rec.ROLLBACK_ENTRY_UPDATES
237       ,p_business_group_id_o
238       => pay_bth_shd.g_old_rec.business_group_id
239       ,p_batch_name_o
240       => pay_bth_shd.g_old_rec.batch_name
241       ,p_batch_status_o
242       => pay_bth_shd.g_old_rec.batch_status
243       ,p_action_if_exists_o
244       => pay_bth_shd.g_old_rec.action_if_exists
245       ,p_batch_reference_o
246       => pay_bth_shd.g_old_rec.batch_reference
247       ,p_batch_source_o
248       => pay_bth_shd.g_old_rec.batch_source
249       ,p_batch_type_o
250       => pay_bth_shd.g_old_rec.batch_type
251       ,p_comments_o
252       => pay_bth_shd.g_old_rec.comments
253       ,p_date_effective_changes_o
254       => pay_bth_shd.g_old_rec.date_effective_changes
255       ,p_purge_after_transfer_o
256       => pay_bth_shd.g_old_rec.purge_after_transfer
257       ,p_reject_if_future_changes_o
258       => pay_bth_shd.g_old_rec.reject_if_future_changes
259       ,p_object_version_number_o
260       => pay_bth_shd.g_old_rec.object_version_number
261       ,p_reject_if_results_exists_o
262       => pay_bth_shd.g_old_rec.reject_if_results_exists
263       ,p_purge_after_rollback_o
264       => pay_bth_shd.g_old_rec.purge_after_rollback
265       ,p_REJECT_ENTRY_NOT_REMOVED_o
266       => pay_bth_shd.g_old_rec.REJECT_ENTRY_NOT_REMOVED
267       ,p_ROLLBACK_ENTRY_UPDATES_o
268       => pay_bth_shd.g_old_rec.ROLLBACK_ENTRY_UPDATES
269       );
270     --
271   exception
272     --
273     when hr_api.cannot_find_prog_unit then
274       --
275       hr_api.cannot_find_prog_unit_error
276         (p_module_name => 'PAY_BATCH_HEADERS'
277         ,p_hook_type   => 'AU');
278       --
279   end;
280   --
281   hr_utility.set_location(' Leaving:'||l_proc, 10);
282 End post_update;
283 --
284 -- ----------------------------------------------------------------------------
285 -- |-----------------------------< convert_defs >-----------------------------|
286 -- ----------------------------------------------------------------------------
287 -- {Start Of Comments}
288 --
289 -- Description:
290 --   The Convert_Defs procedure has one very important function:
291 --   It must return the record structure for the row with all system defaulted
292 --   values converted into its corresponding parameter value for update. When
293 --   we attempt to update a row through the Upd process , certain
294 --   parameters can be defaulted which enables flexibility in the calling of
295 --   the upd process (e.g. only attributes which need to be updated need to be
296 --   specified). For the upd process to determine which attributes
297 --   have NOT been specified we need to check if the parameter has a reserved
298 --   system default value. Therefore, for all parameters which have a
299 --   corresponding reserved system default mechanism specified we need to
300 --   check if a system default is being used. If a system default is being
301 --   used then we convert the defaulted value into its corresponding attribute
302 --   value held in the g_old_rec data structure.
303 --
304 -- Prerequisites:
305 --   This private function can only be called from the upd process.
306 --
307 -- In Parameters:
308 --   A Pl/Sql record structure.
309 --
310 -- Post Success:
311 --   The record structure will be returned with all system defaulted parameter
312 --   values converted into its current row attribute value.
313 --
314 -- Post Failure:
315 --   No direct error handling is required within this function. Any possible
316 --   errors within this procedure will be a PL/SQL value error due to
317 --   conversion of datatypes or data lengths.
318 --
319 -- Developer Implementation Notes:
320 --   None.
321 --
322 -- Access Status:
323 --   Internal Row Handler Use Only.
324 --
325 -- {End Of Comments}
326 -- ----------------------------------------------------------------------------
327 Procedure convert_defs
328   (p_rec in out nocopy pay_bth_shd.g_rec_type
329   ) is
330 --
331 Begin
332   --
333   -- We must now examine each argument value in the
334   -- p_rec plsql record structure
335   -- to see if a system default is being used. If a system default
336   -- is being used then we must set to the 'current' argument value.
337   --
338   If (p_rec.business_group_id = hr_api.g_number) then
339     p_rec.business_group_id :=
340     pay_bth_shd.g_old_rec.business_group_id;
341   End If;
342   If (p_rec.batch_name = hr_api.g_varchar2) then
343     p_rec.batch_name :=
344     pay_bth_shd.g_old_rec.batch_name;
345   End If;
346   If (p_rec.batch_status = hr_api.g_varchar2) then
347     p_rec.batch_status :=
348     pay_bth_shd.g_old_rec.batch_status;
349   End If;
350   If (p_rec.action_if_exists = hr_api.g_varchar2) then
351     p_rec.action_if_exists :=
352     pay_bth_shd.g_old_rec.action_if_exists;
353   End If;
354   If (p_rec.batch_reference = hr_api.g_varchar2) then
355     p_rec.batch_reference :=
356     pay_bth_shd.g_old_rec.batch_reference;
357   End If;
358   If (p_rec.batch_source = hr_api.g_varchar2) then
359     p_rec.batch_source :=
360     pay_bth_shd.g_old_rec.batch_source;
361   End If;
362   If (p_rec.batch_type = hr_api.g_varchar2) then
363     p_rec.batch_type :=
364     pay_bth_shd.g_old_rec.batch_type;
365   End If;
366   If (p_rec.comments = hr_api.g_varchar2) then
367     p_rec.comments :=
368     pay_bth_shd.g_old_rec.comments;
369   End If;
370   If (p_rec.date_effective_changes = hr_api.g_varchar2) then
371     p_rec.date_effective_changes :=
372     pay_bth_shd.g_old_rec.date_effective_changes;
373   End If;
374   If (p_rec.purge_after_transfer = hr_api.g_varchar2) then
375     p_rec.purge_after_transfer :=
376     pay_bth_shd.g_old_rec.purge_after_transfer;
377   End If;
378   If (p_rec.reject_if_future_changes = hr_api.g_varchar2) then
379     p_rec.reject_if_future_changes :=
380     pay_bth_shd.g_old_rec.reject_if_future_changes;
381   End If;
382   If (p_rec.reject_if_results_exists = hr_api.g_varchar2) then
383     p_rec.reject_if_results_exists :=
384     pay_bth_shd.g_old_rec.reject_if_results_exists;
385   End If;
386   If (p_rec.purge_after_rollback = hr_api.g_varchar2) then
387     p_rec.purge_after_rollback :=
388     pay_bth_shd.g_old_rec.purge_after_rollback;
389   End If;
390   If (p_rec.REJECT_ENTRY_NOT_REMOVED = hr_api.g_varchar2) then
391     p_rec.REJECT_ENTRY_NOT_REMOVED :=
392     pay_bth_shd.g_old_rec.REJECT_ENTRY_NOT_REMOVED;
393   End If;
394   If (p_rec.ROLLBACK_ENTRY_UPDATES = hr_api.g_varchar2) then
395     p_rec.ROLLBACK_ENTRY_UPDATES :=
396     pay_bth_shd.g_old_rec.ROLLBACK_ENTRY_UPDATES;
397   End If;
398   --
399 End convert_defs;
400 --
401 -- ----------------------------------------------------------------------------
402 -- |---------------------------------< upd >----------------------------------|
403 -- ----------------------------------------------------------------------------
404 Procedure upd
405   (p_session_date                 in     date
406   ,p_rec                          in out nocopy pay_bth_shd.g_rec_type
407   ) is
408 --
409   l_proc  varchar2(72) := g_package||'upd';
410 --
411 Begin
412   hr_utility.set_location('Entering:'||l_proc, 5);
413   --
414   -- We must lock the row which we need to update.
415   --
416   pay_bth_shd.lck
417     (p_rec.batch_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   pay_bth_bus.update_validate
429      (p_session_date,
430       p_rec
431      );
432   --
433   -- Call the supporting pre-update operation
434   --
435   pay_bth_upd.pre_update(p_rec);
436   --
437   -- Update the row.
438   --
439   pay_bth_upd.update_dml(p_rec);
440   --
441   -- Call the supporting post-update operation
442   --
443   pay_bth_upd.post_update
444      (p_session_date
445      ,p_rec
446      );
447 End upd;
448 --
449 -- ----------------------------------------------------------------------------
450 -- |---------------------------------< upd >----------------------------------|
451 -- ----------------------------------------------------------------------------
452 Procedure upd
453   (p_session_date                 in     date
454   ,p_batch_id                     in     number
455   ,p_object_version_number        in out nocopy number
456   ,p_batch_name                   in     varchar2  default hr_api.g_varchar2
457   ,p_batch_status                 in     varchar2  default hr_api.g_varchar2
458   ,p_action_if_exists             in     varchar2  default hr_api.g_varchar2
459   ,p_batch_reference              in     varchar2  default hr_api.g_varchar2
460   ,p_batch_source                 in     varchar2  default hr_api.g_varchar2
461   ,p_batch_type                   in     varchar2  default hr_api.g_varchar2
462   ,p_comments                     in     varchar2  default hr_api.g_varchar2
463   ,p_date_effective_changes       in     varchar2  default hr_api.g_varchar2
464   ,p_purge_after_transfer         in     varchar2  default hr_api.g_varchar2
465   ,p_reject_if_future_changes     in     varchar2  default hr_api.g_varchar2
466   ,p_reject_if_results_exists     in     varchar2  default hr_api.g_varchar2
467   ,p_purge_after_rollback         in     varchar2  default hr_api.g_varchar2
468   ,p_REJECT_ENTRY_NOT_REMOVED     in     varchar2  default hr_api.g_varchar2
469   ,p_ROLLBACK_ENTRY_UPDATES       in     varchar2  default hr_api.g_varchar2
470   ) is
471 --
472   l_rec	  pay_bth_shd.g_rec_type;
473   l_proc  varchar2(72) := g_package||'upd';
474 --
475 Begin
476   hr_utility.set_location('Entering:'||l_proc, 5);
477   --
478   -- Call conversion function to turn arguments into the
479   -- l_rec structure.
480   --
481   l_rec :=
482   pay_bth_shd.convert_args
483   (p_batch_id
484   ,hr_api.g_number
485   ,p_batch_name
486   ,p_batch_status
487   ,p_action_if_exists
488   ,p_batch_reference
489   ,p_batch_source
490   ,p_batch_type
491   ,p_comments
492   ,p_date_effective_changes
493   ,p_purge_after_transfer
494   ,p_reject_if_future_changes
495   ,p_reject_if_results_exists
496   ,p_purge_after_rollback
497   ,p_REJECT_ENTRY_NOT_REMOVED
498   ,p_ROLLBACK_ENTRY_UPDATES
499   ,p_object_version_number
500   );
501   --
502   -- Having converted the arguments into the
503   -- plsql record structure we call the corresponding record
504   -- business process.
505   --
506   pay_bth_upd.upd
507      (p_session_date,
508       l_rec
509      );
510   p_object_version_number := l_rec.object_version_number;
511   --
512   hr_utility.set_location(' Leaving:'||l_proc, 10);
513 End upd;
514 --
515 end pay_bth_upd;