1 Package Body per_cei_upd as
2 /* $Header: peceirhi.pkb 120.1 2006/10/18 08:58:46 grreddy noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_cei_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 per_cei_shd.g_rec_type
56 ) is
57 --
58 l_proc varchar2(72) := g_package||'update_dml';
59 l_last_update_date per_cagr_entitlement_items.last_update_date%TYPE;
60 l_last_updated_by per_cagr_entitlement_items.last_updated_by%TYPE;
61 l_last_update_login per_cagr_entitlement_items.last_update_login%TYPE;
62 --
63 Begin
64 hr_utility.set_location('Entering:'||l_proc, 5);
65 --
66 -- Increment the object version
67 --
68 p_rec.object_version_number := p_rec.object_version_number + 1;
69 --
70 -- Set the who columns
71 --
72 l_last_update_date := sysdate;
73 l_last_updated_by := fnd_global.user_id;
74 l_last_update_login := fnd_global.login_id;
75 --
76 -- Update the per_cagr_entitlement_items Row
77 --
78 --
79 update per_cagr_entitlement_items
80 set
81 cagr_entitlement_item_id = p_rec.cagr_entitlement_item_id
82 ,item_name = p_rec.item_name
83 ,element_type_id = p_rec.element_type_id
84 ,input_value_id = p_rec.input_value_id
85 ,column_type = p_rec.column_type
86 ,column_size = p_rec.column_size
87 ,legislation_code = p_rec.legislation_code
88 ,cagr_api_id = p_rec.cagr_api_id
89 ,cagr_api_param_id = p_rec.cagr_api_param_id
90 ,business_group_id = p_rec.business_group_id
91 ,beneficial_rule = p_rec.beneficial_rule
92 ,category_name = p_rec.category_name
93 ,uom = p_rec.uom
94 ,flex_value_set_id = p_rec.flex_value_set_id
95 ,beneficial_formula_id = p_rec.beneficial_formula_id
96 ,object_version_number = p_rec.object_version_number
97 ,last_update_date = l_last_update_date
98 ,last_updated_by = l_last_updated_by
99 ,last_update_login = l_last_update_login
100 ,beneficial_rule_value_set_id = p_rec.ben_rule_value_set_id
101 ,multiple_entries_allowed_flag = p_rec.mult_entries_allowed_flag
102 ,auto_create_entries_flag = p_rec.auto_create_entries_flag -- CEI Enh
103 where cagr_entitlement_item_id = p_rec.cagr_entitlement_item_id;
104 --
105 hr_utility.set_location(' Leaving:'||l_proc, 10);
106 --
107 Exception
108 When hr_api.check_integrity_violated Then
109 -- A check constraint has been violated
110 --
111 per_cei_shd.constraint_error
112 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
113 When hr_api.parent_integrity_violated Then
114 -- Parent integrity has been violated
115 --
116 per_cei_shd.constraint_error
117 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
118 When hr_api.unique_integrity_violated Then
119 -- Unique integrity has been violated
120 --
121 per_cei_shd.constraint_error
122 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
123 When Others Then
124 --
125 Raise;
126 End update_dml;
127 --
128 -- ----------------------------------------------------------------------------
129 -- |------------------------------< pre_update >------------------------------|
130 -- ----------------------------------------------------------------------------
131 -- {Start Of Comments}
132 --
133 -- Description:
134 -- This private procedure contains any processing which is required before
135 -- the update dml.
136 --
137 -- Prerequisites:
138 -- This is an internal procedure which is called from the upd procedure.
139 --
140 -- In Parameters:
141 -- A Pl/Sql record structure.
142 --
143 -- Post Success:
144 -- Processing continues.
145 --
146 -- Post Failure:
147 -- If an error has occurred, an error message and exception wil be raised
148 -- but not handled.
149 --
150 -- Developer Implementation Notes:
151 -- Any pre-processing required before the update dml is issued should be
152 -- coded within this procedure. It is important to note that any 3rd party
153 -- maintenance should be reviewed before placing in this procedure.
154 --
155 -- Access Status:
156 -- Internal Row Handler Use Only.
157 --
158 -- {End Of Comments}
159 -- ----------------------------------------------------------------------------
160 Procedure pre_update
161 (p_rec in per_cei_shd.g_rec_type
162 ) is
163 --
164 l_proc varchar2(72) := g_package||'pre_update';
165 --
166 Begin
167 hr_utility.set_location('Entering:'||l_proc, 5);
168 --
169 hr_utility.set_location(' Leaving:'||l_proc, 10);
170 End pre_update;
171 --
172 -- ----------------------------------------------------------------------------
173 -- |-----------------------------< post_update >------------------------------|
174 -- ----------------------------------------------------------------------------
175 -- {Start Of Comments}
176 --
177 -- Description:
178 -- This private procedure contains any processing which is required after the
179 -- update dml.
180 --
181 -- Prerequisites:
182 -- This is an internal procedure which is called from the upd procedure.
183 --
184 -- In Parameters:
185 -- A Pl/Sql record structure.
186 --
187 -- Post Success:
188 -- Processing continues.
189 --
190 -- Post Failure:
191 -- If an error has occurred, an error message and exception will be raised
192 -- but not handled.
193 --
194 -- Developer Implementation Notes:
195 -- Any post-processing required after the update dml is issued should be
196 -- coded within this procedure. It is important to note that any 3rd party
197 -- maintenance should be reviewed before placing in this procedure.
198 --
199 -- Access Status:
200 -- Internal Row Handler Use Only.
201 --
202 -- {End Of Comments}
203 -- ----------------------------------------------------------------------------
204 Procedure post_update
205 (p_effective_date in date
206 ,p_rec in per_cei_shd.g_rec_type
207 ) is
208 --
209 l_proc varchar2(72) := g_package||'post_update';
210 --
211 Begin
212 hr_utility.set_location('Entering:'||l_proc, 5);
213 begin
214 --
215 per_cei_rku.after_update
216 (p_effective_date => p_effective_date
217 ,p_cagr_entitlement_item_id => p_rec.cagr_entitlement_item_id
218 ,p_item_name => p_rec.item_name
219 ,p_element_type_id => p_rec.element_type_id
220 ,p_input_value_id => p_rec.input_value_id
221 ,p_column_type => p_rec.column_type
222 ,p_column_size => p_rec.column_size
223 ,p_legislation_code => p_rec.legislation_code
224 ,p_cagr_api_id => p_rec.cagr_api_id
225 ,p_cagr_api_param_id => p_rec.cagr_api_param_id
226 ,p_beneficial_formula_id => p_rec.beneficial_formula_id
227 ,p_business_group_id => p_rec.business_group_id
228 ,p_beneficial_rule => p_rec.beneficial_rule
229 ,p_category_name => p_rec.category_name
230 ,p_uom => p_rec.uom
231 ,p_flex_value_set_id => p_rec.flex_value_set_id
232 ,p_object_version_number => p_rec.object_version_number
233 ,p_ben_rule_value_set_id => p_rec.ben_rule_value_set_id
234 ,p_mult_entries_allowed_flag => p_rec.mult_entries_allowed_flag
235 ,p_auto_create_entries_flag => p_rec.auto_create_entries_flag -- CEI Enh
236 ,p_opt_id => p_rec.opt_id
237 ,p_item_name_o => per_cei_shd.g_old_rec.item_name
238 ,p_element_type_id_o => per_cei_shd.g_old_rec.element_type_id
239 ,p_input_value_id_o => per_cei_shd.g_old_rec.input_value_id
240 ,p_column_type_o => per_cei_shd.g_old_rec.column_type
241 ,p_column_size_o => per_cei_shd.g_old_rec.column_size
242 ,p_legislation_code_o => per_cei_shd.g_old_rec.legislation_code
243 ,p_cagr_api_id_o => per_cei_shd.g_old_rec.cagr_api_id
244 ,p_cagr_api_param_id_o => per_cei_shd.g_old_rec.cagr_api_param_id
245 ,p_beneficial_formula_id_o => per_cei_shd.g_old_rec.beneficial_formula_id
246 ,p_business_group_id_o => per_cei_shd.g_old_rec.business_group_id
247 ,p_beneficial_rule_o => per_cei_shd.g_old_rec.beneficial_rule
248 ,p_category_name_o => per_cei_shd.g_old_rec.category_name
249 ,p_uom_o => per_cei_shd.g_old_rec.uom
250 ,p_flex_value_set_id_o => per_cei_shd.g_old_rec.flex_value_set_id
251 ,p_object_version_number_o => per_cei_shd.g_old_rec.object_version_number
252 ,p_ben_rule_value_set_id_o => per_cei_shd.g_old_rec.ben_rule_value_set_id
253 ,p_mult_entries_allowed_flag_o => per_cei_shd.g_old_rec.mult_entries_allowed_flag
254 ,p_auto_create_entries_flag_o => per_cei_shd.g_old_rec.auto_create_entries_flag -- CEI Enh
255 ,p_opt_id_o => per_cei_shd.g_old_rec.opt_id
256 );
257 --
258 exception
259 --
260 when hr_api.cannot_find_prog_unit then
261 --
262 hr_api.cannot_find_prog_unit_error
263 (p_module_name => 'PER_CAGR_ENTITLEMENT_ITEMS'
264 ,p_hook_type => 'AU');
265 --
266 end;
267 --
268 hr_utility.set_location(' Leaving:'||l_proc, 10);
269 End post_update;
270 --
271 -- ----------------------------------------------------------------------------
272 -- |-----------------------------< convert_defs >-----------------------------|
273 -- ----------------------------------------------------------------------------
274 -- {Start Of Comments}
275 --
276 -- Description:
277 -- The Convert_Defs procedure has one very important function:
278 -- It must return the record structure for the row with all system defaulted
279 -- values converted into its corresponding parameter value for update. When
280 -- we attempt to update a row through the Upd process , certain
281 -- parameters can be defaulted which enables flexibility in the calling of
282 -- the upd process (e.g. only attributes which need to be updated need to be
283 -- specified). For the upd process to determine which attributes
284 -- have NOT been specified we need to check if the parameter has a reserved
285 -- system default value. Therefore, for all parameters which have a
286 -- corresponding reserved system default mechanism specified we need to
287 -- check if a system default is being used. If a system default is being
288 -- used then we convert the defaulted value into its corresponding attribute
289 -- value held in the g_old_rec data structure.
290 --
291 -- Prerequisites:
292 -- This private function can only be called from the upd process.
293 --
294 -- In Parameters:
295 -- A Pl/Sql record structure.
296 --
297 -- Post Success:
298 -- The record structure will be returned with all system defaulted parameter
299 -- values converted into its current row attribute value.
300 --
301 -- Post Failure:
302 -- No direct error handling is required within this function. Any possible
303 -- errors within this procedure will be a PL/SQL value error due to
304 -- conversion of datatypes or data lengths.
305 --
306 -- Developer Implementation Notes:
307 -- None.
308 --
309 -- Access Status:
310 -- Internal Row Handler Use Only.
311 --
312 -- {End Of Comments}
313 -- ----------------------------------------------------------------------------
314 Procedure convert_defs
315 (p_rec in out nocopy per_cei_shd.g_rec_type
316 ) is
317 --
318 Begin
319 --
320 -- We must now examine each argument value in the
321 -- p_rec plsql record structure
322 -- to see if a system default is being used. If a system default
323 -- is being used then we must set to the 'current' argument value.
324 --
325 If (p_rec.item_name = hr_api.g_varchar2) then
326 p_rec.item_name :=
327 per_cei_shd.g_old_rec.item_name;
328 End If;
329 If (p_rec.element_type_id = hr_api.g_number) then
330 p_rec.element_type_id :=
331 per_cei_shd.g_old_rec.element_type_id;
332 End If;
333 If (p_rec.input_value_id = hr_api.g_varchar2) then
334 p_rec.input_value_id :=
335 per_cei_shd.g_old_rec.input_value_id;
336 End If;
337 --
338 If (p_rec.column_type = hr_api.g_varchar2) then
339 p_rec.column_type :=
340 per_cei_shd.g_old_rec.column_type;
341 End If;
342 --
343 If (p_rec.column_size = hr_api.g_number) then
344 p_rec.column_size :=
345 per_cei_shd.g_old_rec.column_size;
346 End If;
347 --
348 If (p_rec.legislation_code = hr_api.g_varchar2) then
349 p_rec.legislation_code :=
350 per_cei_shd.g_old_rec.legislation_code;
351 End If;
352 If (p_rec.beneficial_rule = hr_api.g_varchar2) then
353 p_rec.beneficial_rule :=
354 per_cei_shd.g_old_rec.beneficial_rule;
355 End If;
356 If (p_rec.cagr_api_id = hr_api.g_number) then
357 p_rec.cagr_api_id :=
358 per_cei_shd.g_old_rec.cagr_api_id;
359 End If;
360 If (p_rec.cagr_api_param_id = hr_api.g_number) then
361 p_rec.cagr_api_param_id :=
362 per_cei_shd.g_old_rec.cagr_api_param_id;
363 End If;
364
365 If (p_rec.business_group_id = hr_api.g_number) then
366 p_rec.business_group_id :=
367 per_cei_shd.g_old_rec.business_group_id;
368 End If;
369 If (p_rec.beneficial_rule = hr_api.g_varchar2) then
370 p_rec.beneficial_rule :=
371 per_cei_shd.g_old_rec.beneficial_rule;
372 End If;
373 If (p_rec.category_name = hr_api.g_varchar2) then
374 p_rec.category_name :=
375 per_cei_shd.g_old_rec.category_name;
376 End If;
380 End If;
377 If (p_rec.uom = hr_api.g_varchar2) then
378 p_rec.uom :=
379 per_cei_shd.g_old_rec.uom;
381 If (p_rec.flex_value_set_id = hr_api.g_number) then
382 p_rec.flex_value_set_id :=
383 per_cei_shd.g_old_rec.flex_value_set_id;
384 End If;
385
386 If (p_rec.beneficial_formula_id = hr_api.g_number) then
387 p_rec.beneficial_formula_id :=
388 per_cei_shd.g_old_rec.beneficial_formula_id;
389 End If;
390 --
391
392 If (p_rec.ben_rule_value_set_id = hr_api.g_number) then
393 p_rec.ben_rule_value_set_id :=
394 per_cei_shd.g_old_rec.ben_rule_value_set_id;
395 End If;
396 --
397
398 If (p_rec.mult_entries_allowed_flag = hr_api.g_varchar2) then
399 p_rec.mult_entries_allowed_flag :=
400 per_cei_shd.g_old_rec.mult_entries_allowed_flag;
401 End If;
402 -- -- CEI Enh
403 IF (p_rec.auto_create_entries_flag = hr_api.g_varchar2) THEN -- CEI Enh
404 p_rec.auto_create_entries_flag := -- CEI Enh
405 per_cei_shd.g_old_rec.auto_create_entries_flag; -- CEI Enh
406 END IF; -- CEI Enh
407 --
408 If (p_rec.opt_id = hr_api.g_number) then
409 p_rec.opt_id := per_cei_shd.g_old_rec.opt_id;
410 End If;
411 --
412 End convert_defs;
413 --
414 -- ----------------------------------------------------------------------------
415 -- |---------------------------------< upd >----------------------------------|
416 -- ----------------------------------------------------------------------------
417 Procedure upd
418 (p_effective_date in date
419 ,p_rec in out nocopy per_cei_shd.g_rec_type
420 ) is
421 --
422 l_proc varchar2(72) := g_package||'upd';
423 --
424 Begin
425 hr_utility.set_location('Entering:'||l_proc, 5);
426 --
427 -- We must lock the row which we need to update.
428 --
429 per_cei_shd.lck
430 (p_rec.cagr_entitlement_item_id,
431 p_rec.object_version_number
432 );
433 --
434 -- 1. During an update system defaults are used to determine if
435 -- arguments have been defaulted or not. We must therefore
436 -- derive the full record structure values to be updated.
437 --
438 -- 2. Call the supporting update validate operations.
439 --
440 convert_defs(p_rec);
441 --
442 per_cei_bus.update_validate
443 (p_effective_date
444 ,p_rec
445 );
446 --
447 -- Call the supporting pre-update operation
448 --
449 per_cei_upd.pre_update(p_rec);
450 --
451 -- Update the row.
452 --
453 per_cei_upd.update_dml(p_rec);
454 --
455 -- Call the supporting post-update operation
456 --
457 per_cei_upd.post_update
458 (p_effective_date
459 ,p_rec
460 );
461 End upd;
462 --
463 -- ----------------------------------------------------------------------------
464 -- |---------------------------------< upd >----------------------------------|
465 -- ----------------------------------------------------------------------------
466 Procedure upd
467 (p_effective_date in date
468 ,p_cagr_entitlement_item_id in number
469 ,p_object_Version_number in number
470 ,p_item_name in varchar2 default hr_api.g_varchar2
471 ,p_legislation_code in varchar2 default hr_api.g_varchar2
472 ,p_business_group_id in number default hr_api.g_number
473 ,p_category_name in varchar2 default hr_api.g_varchar2
474 ,p_uom in varchar2 default hr_api.g_varchar2
475 ,p_flex_value_set_id in number default hr_api.g_number
476 ,p_element_type_id in number default hr_api.g_number
477 ,p_input_value_id in varchar2 default hr_api.g_varchar2
478 ,p_column_type in varchar2 default hr_api.g_varchar2
479 ,p_column_size in number default hr_api.g_number
480 ,p_cagr_api_id in number default hr_api.g_number
481 ,p_cagr_api_param_id in number default hr_api.g_number
482 ,p_beneficial_formula_id in number default hr_api.g_number
483 ,p_beneficial_rule in varchar2 default hr_api.g_varchar2
484 ,p_ben_rule_value_set_id in number default hr_api.g_number
485 ,p_mult_entries_allowed_flag in varchar2 default hr_api.g_varchar2
486 ,p_auto_create_entries_flag in varchar2 default hr_api.g_varchar2 -- CEI Enh
487
488 ) is
489 --
490 l_rec per_cei_shd.g_rec_type;
491 l_proc varchar2(72) := g_package||'upd';
492 --
493 Begin
494 hr_utility.set_location('Entering:'||l_proc, 5);
495 --
496 -- Call conversion function to turn arguments into the
497 -- l_rec structure.
498 --
499 l_rec := per_cei_shd.convert_args
500 (p_cagr_entitlement_item_id
501 ,p_item_name
502 ,p_element_type_id
503 ,p_input_value_id
504 ,p_column_type
505 ,p_column_size
506 ,p_legislation_code
507 ,p_cagr_api_id
508 ,p_cagr_api_param_id
509 ,p_business_group_id
510 ,p_beneficial_rule
511 ,p_category_name
512 ,p_uom
513 ,p_flex_value_set_id
514 ,p_beneficial_formula_id
515 ,p_object_version_number
516 ,p_ben_rule_value_set_id
517 ,p_mult_entries_allowed_flag
518 ,p_auto_create_entries_flag -- CEI Enh
519 ,hr_api.g_number -- opt_id
520 ) ;
521 --
522 -- Having converted the arguments into the
523 -- plsql record structure we call the corresponding record
524 -- business process.
525 --
526 per_cei_upd.upd
527 (p_effective_date
528 ,l_rec
529 );
530 --
531 --
532 hr_utility.set_location(' Leaving:'||l_proc, 10);
533 End upd;
534 --
535 end per_cei_upd;