DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_TFU_UPD

Source


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