1 Package Body pay_cnu_upd as
2 /* $Header: pycnurhi.pkb 120.0 2005/05/29 04:04:56 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_cnu_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_cnu_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_fr_contribution_usages Row
69 --
70 update pay_fr_contribution_usages
71 set
72 date_to = p_rec.date_to
73 ,contribution_code = p_rec.contribution_code
74 ,contribution_type = p_rec.contribution_type
75 ,retro_contribution_code = p_rec.retro_contribution_code
76 ,object_version_number = p_rec.object_version_number
77 ,code_rate_id = p_rec.code_rate_id
78 where contribution_usage_id = p_rec.contribution_usage_id
79 and contribution_usage_type= p_rec.contribution_usage_type ;
80 --
81 --
82 --
83 hr_utility.set_location(' Leaving:'||l_proc, 10);
84 --
85 Exception
86 When hr_api.check_integrity_violated Then
87 -- A check constraint has been violated
88 --
89 pay_cnu_shd.constraint_error
90 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
91 When hr_api.parent_integrity_violated Then
92 -- Parent integrity has been violated
93 --
94 pay_cnu_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 --
99 pay_cnu_shd.constraint_error
100 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
101 When Others Then
102 --
103 Raise;
104 End update_dml;
105 --
106 -- ----------------------------------------------------------------------------
107 -- |------------------------------< pre_update >------------------------------|
108 -- ----------------------------------------------------------------------------
109 -- {Start Of Comments}
110 --
111 -- Description:
112 -- This private procedure contains any processing which is required before
113 -- the update dml.
114 --
115 -- Prerequisites:
116 -- This is an internal procedure which is called from the upd procedure.
117 --
118 -- In Parameters:
119 -- A Pl/Sql record structure.
120 --
121 -- Post Success:
122 -- Processing continues.
123 --
124 -- Post Failure:
125 -- If an error has occurred, an error message and exception wil be raised
126 -- but not handled.
127 --
128 -- Developer Implementation Notes:
129 -- Any pre-processing required before the update dml is issued should be
130 -- coded within this procedure. It is important to note that any 3rd party
131 -- maintenance should be reviewed before placing in this procedure.
132 --
133 -- Access Status:
134 -- Internal Row Handler Use Only.
135 --
136 -- {End Of Comments}
137 -- ----------------------------------------------------------------------------
138 Procedure pre_update
139 (p_rec in pay_cnu_shd.g_rec_type
140 ) is
141 --
142 l_proc varchar2(72) := g_package||'pre_update';
143 --
144 Begin
145 hr_utility.set_location('Entering:'||l_proc, 5);
146 --
147 hr_utility.set_location(' Leaving:'||l_proc, 10);
148 End pre_update;
149 --
150 -- ----------------------------------------------------------------------------
151 -- |-----------------------------< post_update >------------------------------|
152 -- ----------------------------------------------------------------------------
153 -- {Start Of Comments}
154 --
155 -- Description:
156 -- This private procedure contains any processing which is required after the
157 -- update dml.
158 --
159 -- Prerequisites:
160 -- This is an internal procedure which is called from the upd procedure.
161 --
162 -- In Parameters:
163 -- A Pl/Sql record structure.
164 --
165 -- Post Success:
166 -- Processing continues.
167 --
168 -- Post Failure:
169 -- If an error has occurred, an error message and exception will be raised
170 -- but not handled.
171 --
172 -- Developer Implementation Notes:
173 -- Any post-processing required after the update dml is issued should be
174 -- coded within this procedure. It is important to note that any 3rd party
175 -- maintenance should be reviewed before placing in this procedure.
176 --
177 -- Access Status:
178 -- Internal Row Handler Use Only.
179 --
180 -- {End Of Comments}
181 -- ----------------------------------------------------------------------------
182 Procedure post_update
183 (p_rec in pay_cnu_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 begin
191 --
192 pay_cnu_rku.after_update
193 (p_contribution_usage_id => p_rec.contribution_usage_id
194 ,p_date_to => p_rec.date_to
195 ,p_retro_contribution_code => p_rec.retro_contribution_code
196 ,p_object_version_number => p_rec.object_version_number
197 ,p_date_from_o => pay_cnu_shd.g_old_rec.date_from
198 ,p_date_to_o => pay_cnu_shd.g_old_rec.date_to
199 ,p_group_code_o => pay_cnu_shd.g_old_rec.group_code
200 ,p_process_type_o => pay_cnu_shd.g_old_rec.process_type
201 ,p_element_name_o => pay_cnu_shd.g_old_rec.element_name
202 ,p_rate_type_o => pay_cnu_shd.g_old_rec.rate_type
203 ,p_contribution_code_o => pay_cnu_shd.g_old_rec.contribution_code
204 ,p_retro_contribution_code_o => pay_cnu_shd.g_old_rec.retro_contribution_code
205 ,p_contribution_type_o => pay_cnu_shd.g_old_rec.contribution_type
206 ,p_contribution_usage_type_o => pay_cnu_shd.g_old_rec.contribution_usage_type
207 ,p_rate_category_o => pay_cnu_shd.g_old_rec.rate_category
208 ,p_business_group_id_o => pay_cnu_shd.g_old_rec.business_group_id
209 ,p_object_version_number_o => pay_cnu_shd.g_old_rec.object_version_number
210 ,p_code_rate_id_o => pay_cnu_shd.g_old_rec.code_Rate_id
211 );
212 --
213 exception
214 --
215 when hr_api.cannot_find_prog_unit then
216 --
217 hr_api.cannot_find_prog_unit_error
218 (p_module_name => 'PAY_FR_CONTRIBUTION_USAGES'
219 ,p_hook_type => 'AU');
220 --
221 end;
222 --
223 hr_utility.set_location(' Leaving:'||l_proc, 10);
224 End post_update;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |-----------------------------< convert_defs >-----------------------------|
228 -- ----------------------------------------------------------------------------
229 -- {Start Of Comments}
230 --
231 -- Description:
232 -- The Convert_Defs procedure has one very important function:
233 -- It must return the record structure for the row with all system defaulted
234 -- values converted into its corresponding parameter value for update. When
235 -- we attempt to update a row through the Upd process , certain
236 -- parameters can be defaulted which enables flexibility in the calling of
237 -- the upd process (e.g. only attributes which need to be updated need to be
238 -- specified). For the upd process to determine which attributes
239 -- have NOT been specified we need to check if the parameter has a reserved
240 -- system default value. Therefore, for all parameters which have a
241 -- corresponding reserved system default mechanism specified we need to
242 -- check if a system default is being used. If a system default is being
243 -- used then we convert the defaulted value into its corresponding attribute
244 -- value held in the g_old_rec data structure.
245 --
246 -- Prerequisites:
247 -- This private function can only be called from the upd process.
248 --
249 -- In Parameters:
250 -- A Pl/Sql record structure.
251 --
252 -- Post Success:
253 -- The record structure will be returned with all system defaulted parameter
254 -- values converted into its current row attribute value.
255 --
256 -- Post Failure:
257 -- No direct error handling is required within this function. Any possible
258 -- errors within this procedure will be a PL/SQL value error due to
259 -- conversion of datatypes or data lengths.
260 --
261 -- Developer Implementation Notes:
262 -- None.
263 --
264 -- Access Status:
265 -- Internal Row Handler Use Only.
266 --
267 -- {End Of Comments}
268 -- ----------------------------------------------------------------------------
269 Procedure convert_defs
270 (p_rec in out nocopy pay_cnu_shd.g_rec_type
271 ) is
272 --
273 Begin
274 --
275 -- We must now examine each argument value in the
276 -- p_rec plsql record structure
277 -- to see if a system default is being used. If a system default
278 -- is being used then we must set to the 'current' argument value.
279 --
280 If (p_rec.date_from = hr_api.g_date) then
281 p_rec.date_from :=
282 pay_cnu_shd.g_old_rec.date_from;
283 End If;
284 If (p_rec.date_to = hr_api.g_date) then
285 p_rec.date_to :=
286 pay_cnu_shd.g_old_rec.date_to;
287 End If;
288 If (p_rec.group_code = hr_api.g_varchar2) then
289 p_rec.group_code :=
290 pay_cnu_shd.g_old_rec.group_code;
291 End If;
292 If (p_rec.process_type = hr_api.g_varchar2) then
293 p_rec.process_type :=
294 pay_cnu_shd.g_old_rec.process_type;
295 End If;
296 If (p_rec.element_name = hr_api.g_varchar2) then
297 p_rec.element_name :=
298 pay_cnu_shd.g_old_rec.element_name;
299 End If;
300 If (p_rec.rate_type = hr_api.g_varchar2) then
301 p_rec.rate_type :=
302 pay_cnu_shd.g_old_rec.rate_type;
303 End If;
304 If (p_rec.contribution_code = hr_api.g_varchar2) then
305 p_rec.contribution_code :=
306 pay_cnu_shd.g_old_rec.contribution_code;
307 End If;
308 If (p_rec.retro_contribution_code = hr_api.g_varchar2) then
309 p_rec.retro_contribution_code :=
310 pay_cnu_shd.g_old_rec.retro_contribution_code;
311 End If;
312 If (p_rec.contribution_type = hr_api.g_varchar2) then
313 p_rec.contribution_type :=
314 pay_cnu_shd.g_old_rec.contribution_type;
315 End If;
316 If (p_rec.contribution_usage_type = hr_api.g_varchar2) then
317 p_rec.contribution_usage_type :=
318 pay_cnu_shd.g_old_rec.contribution_usage_type;
319 End If;
320 If (p_rec.rate_category = hr_api.g_varchar2) then
321 p_rec.rate_category :=
322 pay_cnu_shd.g_old_rec.rate_category;
323 End If;
324 If (p_rec.business_group_id = hr_api.g_number) then
325 p_rec.business_group_id :=
326 pay_cnu_shd.g_old_rec.business_group_id;
327 End If;
328 If (p_rec.code_rate_id = hr_api.g_number) then
329 p_rec.code_Rate_id :=
330 pay_cnu_shd.g_old_rec.code_rate_id;
331 End If;
332 --
333 End convert_defs;
334 --
335 -- ----------------------------------------------------------------------------
336 -- |---------------------------------< upd >----------------------------------|
337 -- ----------------------------------------------------------------------------
338 Procedure upd
339 (p_effective_date in date
340 ,p_rec in out nocopy pay_cnu_shd.g_rec_type
341 ) is
342 --
343 l_proc varchar2(72) := g_package||'upd';
344 --
345 Begin
346 hr_utility.set_location('Entering:'||l_proc, 5);
347 --
348 -- We must lock the row which we need to update.
349 --
350 pay_cnu_shd.lck
351 (p_rec.contribution_usage_id
352 ,p_rec.object_version_number
353 );
354 --
355 -- 1. During an update system defaults are used to determine if
356 -- arguments have been defaulted or not. We must therefore
357 -- derive the full record structure values to be updated.
358 --
359 -- 2. Call the supporting update validate operations.
360 --
361 convert_defs(p_rec);
362 pay_cnu_bus.update_validate
363 ( p_effective_date
364 ,p_rec
365 );
366 --
367 -- Call the supporting pre-update operation
368 --
369 pay_cnu_upd.pre_update(p_rec);
370 --
371 -- Update the row.
372 --
373 pay_cnu_upd.update_dml(p_rec);
374 --
375 -- Call the supporting post-update operation
376 --
377 pay_cnu_upd.post_update
378 (p_rec
379 );
380 End upd;
381 --
382 -- ----------------------------------------------------------------------------
383 -- |---------------------------------< upd >----------------------------------|
384 -- ----------------------------------------------------------------------------
385 Procedure upd
386 (p_effective_date in date
387 ,p_contribution_usage_id in number
388 ,p_object_version_number in out nocopy number
389 ,p_date_to in date default hr_api.g_date
390 ,p_contribution_code IN varchar2
391 ,p_contribution_type IN varchar2
392 ,p_retro_contribution_code in varchar2 default hr_api.g_varchar2
393 ,p_code_rate_id in varchar2
394 ) is
395 --
396 l_rec pay_cnu_shd.g_rec_type;
397 l_proc varchar2(72) := g_package||'upd';
398 --
399 Begin
400 hr_utility.set_location('Entering:'||l_proc, 5);
401 --
402 -- Call conversion function to turn arguments into the
403 -- l_rec structure.
404 --
405 l_rec :=
406 pay_cnu_shd.convert_args
407 (p_contribution_usage_id
408 ,hr_api.g_date
409 ,p_date_to
410 ,hr_api.g_varchar2
411 ,hr_api.g_varchar2
412 ,hr_api.g_varchar2
413 ,hr_api.g_varchar2
414 ,p_contribution_code
415 ,p_retro_contribution_code
416 ,p_contribution_type
417 ,hr_api.g_varchar2
418 ,hr_api.g_varchar2
419 ,hr_api.g_number
420 ,p_object_version_number
421 ,to_number(p_code_rate_id)
422 );
423 --
424 -- Having converted the arguments into the
425 -- plsql record structure we call the corresponding record
426 -- business process.
427 --
428 hr_utility.set_location(' Step:'|| l_proc, 20);
429 --
430 pay_cnu_upd.upd
431 ( p_effective_date
432 ,l_rec
433 );
434 p_object_version_number := l_rec.object_version_number;
435 --
436 hr_utility.set_location(' Leaving:'||l_proc, 30);
437 End upd;
438 --
439 end pay_cnu_upd;