DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_TDF_UPD

Source


1 Package Body pay_tdf_upd as
2 /* $Header: pytdfrhi.pkb 120.4 2005/09/20 06:56 adkumar noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_tdf_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_tdf_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_tdf_shd.g_api_dml := true;  -- Set the api dml status
67   --
68   -- Update the pay_time_definitions Row
69   --
70   update pay_time_definitions
71     set
72      time_definition_id              = p_rec.time_definition_id
73     ,short_name                      = p_rec.short_name
74     ,definition_name                 = p_rec.definition_name
75     ,period_type                     = p_rec.period_type
76     ,period_unit                     = p_rec.period_unit
77     ,day_adjustment                  = p_rec.day_adjustment
78     ,dynamic_code                    = p_rec.dynamic_code
79     ,business_group_id               = p_rec.business_group_id
80     ,legislation_code                = p_rec.legislation_code
81     ,definition_type                 = p_rec.definition_type
82     ,number_of_years                 = p_rec.number_of_years
83     ,start_date                      = p_rec.start_date
84     ,period_time_definition_id       = p_rec.period_time_definition_id
85     ,creator_id                      = p_rec.creator_id
86     ,creator_type                    = p_rec.creator_type
87     ,object_version_number           = p_rec.object_version_number
88     where time_definition_id = p_rec.time_definition_id;
89   --
90   pay_tdf_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_tdf_shd.g_api_dml := false;   -- Unset the api dml status
98     pay_tdf_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_tdf_shd.g_api_dml := false;   -- Unset the api dml status
103     pay_tdf_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_tdf_shd.g_api_dml := false;   -- Unset the api dml status
108     pay_tdf_shd.constraint_error
109       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110   When Others Then
111     pay_tdf_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_tdf_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
166 --   the 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_effective_date               in date
193   ,p_rec                          in pay_tdf_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_tdf_rku.after_update
203       (p_effective_date              => p_effective_date
204       ,p_time_definition_id
205       => p_rec.time_definition_id
206       ,p_short_name
207       => p_rec.short_name
208       ,p_definition_name
209       => p_rec.definition_name
210       ,p_period_type
211       => p_rec.period_type
212       ,p_period_unit
213       => p_rec.period_unit
214       ,p_day_adjustment
215       => p_rec.day_adjustment
216       ,p_dynamic_code
217       => p_rec.dynamic_code
218       ,p_business_group_id
219       => p_rec.business_group_id
220       ,p_legislation_code
221       => p_rec.legislation_code
222       ,p_definition_type
223       => p_rec.definition_type
224       ,p_number_of_years
225       => p_rec.number_of_years
226       ,p_start_date
227       => p_rec.start_date
228       ,p_period_time_definition_id
229       => p_rec.period_time_definition_id
230       ,p_creator_id
231       => p_rec.creator_id
232       ,p_creator_type
233       => p_rec.creator_type
234       ,p_object_version_number
235       => p_rec.object_version_number
236       ,p_short_name_o
237       => pay_tdf_shd.g_old_rec.short_name
238       ,p_definition_name_o
239       => pay_tdf_shd.g_old_rec.definition_name
240       ,p_period_type_o
241       => pay_tdf_shd.g_old_rec.period_type
242       ,p_period_unit_o
243       => pay_tdf_shd.g_old_rec.period_unit
244       ,p_day_adjustment_o
245       => pay_tdf_shd.g_old_rec.day_adjustment
246       ,p_dynamic_code_o
247       => pay_tdf_shd.g_old_rec.dynamic_code
248       ,p_business_group_id_o
249       => pay_tdf_shd.g_old_rec.business_group_id
250       ,p_legislation_code_o
251       => pay_tdf_shd.g_old_rec.legislation_code
252       ,p_definition_type_o
253       => pay_tdf_shd.g_old_rec.definition_type
254       ,p_number_of_years_o
255       => pay_tdf_shd.g_old_rec.number_of_years
256       ,p_start_date_o
257       => pay_tdf_shd.g_old_rec.start_date
258       ,p_period_time_definition_id_o
259       => pay_tdf_shd.g_old_rec.period_time_definition_id
260       ,p_creator_id_o
261       => pay_tdf_shd.g_old_rec.creator_id
262       ,p_creator_type_o
263       => pay_tdf_shd.g_old_rec.creator_type
264       ,p_object_version_number_o
265       => pay_tdf_shd.g_old_rec.object_version_number
266       );
267     --
268   exception
269     --
270     when hr_api.cannot_find_prog_unit then
271       --
272       hr_api.cannot_find_prog_unit_error
273         (p_module_name => 'PAY_TIME_DEFINITIONS'
274         ,p_hook_type   => 'AU');
275       --
276   end;
277   --
278   hr_utility.set_location(' Leaving:'||l_proc, 10);
279 End post_update;
280 --
281 -- ----------------------------------------------------------------------------
282 -- |-----------------------------< convert_defs >-----------------------------|
283 -- ----------------------------------------------------------------------------
284 -- {Start Of Comments}
285 --
286 -- Description:
287 --   The Convert_Defs procedure has one very important function:
288 --   It must return the record structure for the row with all system defaulted
289 --   values converted into its corresponding parameter value for update. When
290 --   we attempt to update a row through the Upd process , certain
291 --   parameters can be defaulted which enables flexibility in the calling of
292 --   the upd process (e.g. only attributes which need to be updated need to be
293 --   specified). For the upd process to determine which attributes
294 --   have NOT been specified we need to check if the parameter has a reserved
295 --   system default value. Therefore, for all parameters which have a
296 --   corresponding reserved system default mechanism specified we need to
297 --   check if a system default is being used. If a system default is being
298 --   used then we convert the defaulted value into its corresponding attribute
299 --   value held in the g_old_rec data structure.
300 --
301 -- Prerequisites:
302 --   This private function can only be called from the upd process.
303 --
304 -- In Parameters:
305 --   A Pl/Sql record structure.
306 --
307 -- Post Success:
308 --   The record structure will be returned with all system defaulted parameter
309 --   values converted into its current row attribute value.
310 --
311 -- Post Failure:
312 --   No direct error handling is required within this function. Any possible
313 --   errors within this procedure will be a PL/SQL value error due to
314 --   conversion of datatypes or data lengths.
315 --
316 -- Developer Implementation Notes:
317 --   None.
318 --
319 -- Access Status:
320 --   Internal Row Handler Use Only.
321 --
322 -- {End Of Comments}
323 -- ----------------------------------------------------------------------------
324 Procedure convert_defs
325   (p_rec in out nocopy pay_tdf_shd.g_rec_type
326   ) is
327 --
328 Begin
329   --
330   -- We must now examine each argument value in the
331   -- p_rec plsql record structure
332   -- to see if a system default is being used. If a system default
333   -- is being used then we must set to the 'current' argument value.
334   --
335   If (p_rec.short_name = hr_api.g_varchar2) then
336     p_rec.short_name :=
337     pay_tdf_shd.g_old_rec.short_name;
338   End If;
339   If (p_rec.definition_name = hr_api.g_varchar2) then
340     p_rec.definition_name :=
341     pay_tdf_shd.g_old_rec.definition_name;
342   End If;
343   If (p_rec.period_type = hr_api.g_varchar2) then
344     p_rec.period_type :=
345     pay_tdf_shd.g_old_rec.period_type;
346   End If;
347   If (p_rec.period_unit = hr_api.g_varchar2) then
348     p_rec.period_unit :=
349     pay_tdf_shd.g_old_rec.period_unit;
350   End If;
351   If (p_rec.day_adjustment = hr_api.g_varchar2) then
352     p_rec.day_adjustment :=
353     pay_tdf_shd.g_old_rec.day_adjustment;
354   End If;
355   If (p_rec.dynamic_code = hr_api.g_varchar2) then
356     p_rec.dynamic_code :=
357     pay_tdf_shd.g_old_rec.dynamic_code;
358   End If;
359   If (p_rec.business_group_id = hr_api.g_number) then
360     p_rec.business_group_id :=
361     pay_tdf_shd.g_old_rec.business_group_id;
362   End If;
363   If (p_rec.legislation_code = hr_api.g_varchar2) then
364     p_rec.legislation_code :=
365     pay_tdf_shd.g_old_rec.legislation_code;
366   End If;
367   If (p_rec.definition_type = hr_api.g_varchar2) then
368     p_rec.definition_type :=
369     pay_tdf_shd.g_old_rec.definition_type;
370   End If;
371   If (p_rec.number_of_years = hr_api.g_number) then
372     p_rec.number_of_years :=
373     pay_tdf_shd.g_old_rec.number_of_years;
374   End If;
375   If (p_rec.start_date = hr_api.g_date) then
376     p_rec.start_date :=
377     pay_tdf_shd.g_old_rec.start_date;
378   End If;
379   If (p_rec.period_time_definition_id = hr_api.g_number) then
380     p_rec.period_time_definition_id :=
381     pay_tdf_shd.g_old_rec.period_time_definition_id;
382   End If;
383   If (p_rec.creator_id = hr_api.g_number) then
384     p_rec.creator_id :=
385     pay_tdf_shd.g_old_rec.creator_id;
386   End If;
387   If (p_rec.creator_type = hr_api.g_varchar2) then
388     p_rec.creator_type :=
389     pay_tdf_shd.g_old_rec.creator_type;
390   End If;
391   --
392 End convert_defs;
393 --
394 -- ----------------------------------------------------------------------------
395 -- |---------------------------------< upd >----------------------------------|
396 -- ----------------------------------------------------------------------------
397 Procedure upd
398   (p_effective_date               in date
399   ,p_rec                          in out nocopy pay_tdf_shd.g_rec_type
400   ,p_regenerate_periods              out nocopy boolean
401   ,p_delete_periods                  out nocopy boolean
402   ) is
403 --
404   l_proc  varchar2(72) := g_package||'upd';
405 --
406 Begin
407   hr_utility.set_location('Entering:'||l_proc, 5);
408   --
409   -- We must lock the row which we need to update.
410   --
411   pay_tdf_shd.lck
412     (p_rec.time_definition_id
413     ,p_rec.object_version_number
414     );
415   --
416   -- 1. During an update system defaults are used to determine if
417   --    arguments have been defaulted or not. We must therefore
418   --    derive the full record structure values to be updated.
419   --
420   -- 2. Call the supporting update validate operations.
421   --
422   convert_defs(p_rec);
423   pay_tdf_bus.update_validate
424      (p_effective_date
425      ,p_rec
426      ,p_regenerate_periods
427      ,p_delete_periods
428      );
429   --
430   -- Call to raise any errors on multi-message list
431   hr_multi_message.end_validation_set;
432   --
433   -- Call the supporting pre-update operation
434   --
435   pay_tdf_upd.pre_update(p_rec);
436   --
437   -- Update the row.
438   --
439   pay_tdf_upd.update_dml(p_rec);
440   --
441   -- Call the supporting post-update operation
442   --
443   pay_tdf_upd.post_update
444      (p_effective_date
445      ,p_rec
446      );
447   --
448   -- Call to raise any errors on multi-message list
449   hr_multi_message.end_validation_set;
450 End upd;
451 --
452 -- ----------------------------------------------------------------------------
453 -- |---------------------------------< upd >----------------------------------|
454 -- ----------------------------------------------------------------------------
455 Procedure upd
456   (p_effective_date               in     date
457   ,p_time_definition_id           in     number
458   ,p_object_version_number        in out nocopy number
459   ,p_regenerate_periods           out nocopy boolean
460   ,p_delete_periods               out nocopy boolean
461   ,p_short_name                   in     varchar2  default hr_api.g_varchar2
462   ,p_definition_name              in     varchar2  default hr_api.g_varchar2
463   ,p_period_type                  in     varchar2  default hr_api.g_varchar2
464   ,p_period_unit                  in     varchar2  default hr_api.g_varchar2
465   ,p_day_adjustment               in     varchar2  default hr_api.g_varchar2
466   ,p_dynamic_code                 in     varchar2  default hr_api.g_varchar2
467   ,p_business_group_id            in     number    default hr_api.g_number
468   ,p_legislation_code             in     varchar2  default hr_api.g_varchar2
469   ,p_definition_type              in     varchar2  default hr_api.g_varchar2
470   ,p_number_of_years              in     number    default hr_api.g_number
471   ,p_start_date                   in     date      default hr_api.g_date
472   ,p_period_time_definition_id    in     number    default hr_api.g_number
473   ,p_creator_id                   in     number    default hr_api.g_number
474   ,p_creator_type                 in     varchar2  default hr_api.g_varchar2
475   ) is
476 --
477   l_rec   pay_tdf_shd.g_rec_type;
478   l_proc  varchar2(72) := g_package||'upd';
479 --
480 Begin
481   hr_utility.set_location('Entering:'||l_proc, 5);
482   --
483   -- Call conversion function to turn arguments into the
484   -- l_rec structure.
485   --
486   l_rec :=
487   pay_tdf_shd.convert_args
488   (p_time_definition_id
489   ,p_short_name
490   ,p_definition_name
491   ,p_period_type
492   ,p_period_unit
493   ,p_day_adjustment
494   ,p_dynamic_code
495   ,p_business_group_id
496   ,p_legislation_code
497   ,p_definition_type
498   ,p_number_of_years
499   ,p_start_date
500   ,p_period_time_definition_id
501   ,p_creator_id
502   ,p_creator_type
503   ,p_object_version_number
504   );
505   --
506   -- Having converted the arguments into the
507   -- plsql record structure we call the corresponding record
508   -- business process.
509   --
510   pay_tdf_upd.upd
511      (p_effective_date
512      ,l_rec
513      ,p_regenerate_periods
514      ,p_delete_periods
515      );
516 
517   p_object_version_number := l_rec.object_version_number;
518   --
519   hr_utility.set_location(' Leaving:'||l_proc, 10);
520 End upd;
521 --
522 end pay_tdf_upd;