1 Package Body hxc_hac_upd as
2 /* $Header: hxchacrhi.pkb 120.4 2006/06/13 08:42:23 gsirigin noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_hac_upd.'; -- Global package name
9 g_debug boolean := hr_utility.debug_enabled;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------------< update_dml >------------------------------|
13 -- ----------------------------------------------------------------------------
14 -- {Start Of Comments}
15 --
16 -- Description:
17 -- This procedure controls the actual dml update logic. The processing of
18 -- this procedure is:
19 -- 1) Increment the object_version_number by 1 if the object_version_number
20 -- is defined as an attribute for this entity.
21 -- 2) To set and unset the g_api_dml status as required (as we are about to
22 -- perform dml).
23 -- 3) To update the specified row in the schema using the primary key in
24 -- the predicates.
25 -- 4) To trap any constraint violations that may have occurred.
26 -- 5) To raise any other errors.
27 --
28 -- Prerequisites:
29 -- This is an internal private procedure which must be called from the upd
30 -- procedure.
31 --
32 -- In Parameters:
33 -- A Pl/Sql record structre.
34 --
35 -- Post Success:
36 -- The specified row will be updated in the schema.
37 --
38 -- Post Failure:
39 -- On the update dml failure it is important to note that we always reset the
40 -- g_api_dml status to false.
41 -- If a check, unique or parent integrity constraint violation is raised the
42 -- constraint_error procedure will be called.
43 -- If any other error is reported, the error will be raised after the
44 -- g_api_dml status is reset.
45 --
46 -- Developer Implementation Notes:
47 -- The update 'set' attribute list should be modified if any of your
48 -- attributes are not updateable.
49 --
50 -- Access Status:
51 -- Internal Row Handler Use Only.
52 --
53 -- {End Of Comments}
54 -- ----------------------------------------------------------------------------
55 Procedure update_dml
56 (p_rec in out nocopy hxc_hac_shd.g_rec_type
57 ) is
58 --
59 l_proc varchar2(72);
60 --
61 Begin
62 if g_debug then
63 l_proc := g_package||'update_dml';
64 hr_utility.set_location('Entering:'||l_proc, 5);
65 end if;
66 --
67 -- Increment the object version
68 p_rec.object_version_number := p_rec.object_version_number + 1;
69 --
70 hxc_hac_shd.g_api_dml := true; -- Set the api dml status
71 --
72 -- Update the hxc_approval_comps Row
73 --
74 update hxc_approval_comps
75 set
76 approval_comp_id = p_rec.approval_comp_id
77 ,approval_style_id = p_rec.approval_style_id
78 ,time_recipient_id = p_rec.time_recipient_id
79 ,approval_mechanism = p_rec.approval_mechanism
80 ,approval_mechanism_id = p_rec.approval_mechanism_id
81 ,wf_item_type = p_rec.wf_item_type
82 ,wf_name = p_rec.wf_name
83 ,start_date = p_rec.start_date
84 ,end_date = p_rec.end_date
85 ,object_version_number = p_rec.object_version_number
86 ,approval_order = p_rec.approval_order
87 ,time_category_id = p_rec.time_category_id
88 ,parent_comp_id = p_rec.parent_comp_id
89 ,parent_comp_ovn = p_rec.parent_comp_ovn
90 ,run_recipient_extensions = p_rec.run_recipient_extensions
91 ,last_updated_by = fnd_global.user_id
92 ,last_update_date = sysdate
93 ,last_update_login = fnd_global.login_id
94
95 where approval_comp_id = p_rec.approval_comp_id;
96
97 IF p_rec.approval_mechanism = 'ENTRY_LEVEL_APPROVAL' then
98 update hxc_approval_comps
99 set parent_comp_ovn = p_rec.object_version_number
100 where parent_comp_id = p_rec.approval_comp_id and
101 parent_comp_ovn = p_rec.object_version_number - 1 ;
102 ELSE
103
104 delete hxc_approval_comps
105 where parent_comp_id = p_rec.approval_comp_id and
106 parent_comp_ovn = p_rec.object_version_number - 1 ;
107
108 END IF;
109
110
111 --
112 hxc_hac_shd.g_api_dml := false; -- Unset the api dml status
113 --
114 if g_debug then
115 hr_utility.set_location(' Leaving:'||l_proc, 10);
116 end if;
117 --
118 Exception
119 When hr_api.check_integrity_violated Then
120 -- A check constraint has been violated
121 hxc_hac_shd.g_api_dml := false; -- Unset the api dml status
122 hxc_hac_shd.constraint_error
123 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
124 When hr_api.parent_integrity_violated Then
125 -- Parent integrity has been violated
126 hxc_hac_shd.g_api_dml := false; -- Unset the api dml status
127 hxc_hac_shd.constraint_error
128 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
129 When hr_api.unique_integrity_violated Then
130 -- Unique integrity has been violated
131 hxc_hac_shd.g_api_dml := false; -- Unset the api dml status
132 hxc_hac_shd.constraint_error
133 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
134 When Others Then
135 hxc_hac_shd.g_api_dml := false; -- Unset the api dml status
136 Raise;
137 End update_dml;
138 --
139 -- ----------------------------------------------------------------------------
140 -- |------------------------------< pre_update >------------------------------|
141 -- ----------------------------------------------------------------------------
142 -- {Start Of Comments}
143 --
144 -- Description:
145 -- This private procedure contains any processing which is required before
146 -- the update dml.
147 --
148 -- Prerequisites:
149 -- This is an internal procedure which is called from the upd procedure.
150 --
151 -- In Parameters:
152 -- A Pl/Sql record structure.
153 --
154 -- Post Success:
155 -- Processing continues.
156 --
157 -- Post Failure:
158 -- If an error has occurred, an error message and exception wil be raised
159 -- but not handled.
160 --
161 -- Developer Implementation Notes:
162 -- Any pre-processing required before the update dml is issued should be
163 -- coded within this procedure. It is important to note that any 3rd party
164 -- maintenance should be reviewed before placing in this procedure.
165 --
166 -- Access Status:
167 -- Internal Row Handler Use Only.
168 --
169 -- {End Of Comments}
170 -- ----------------------------------------------------------------------------
171 Procedure pre_update
172 (p_rec in hxc_hac_shd.g_rec_type
173 ) is
174 --
175 l_proc varchar2(72);
176 --
177 Begin
178 if g_debug then
179 l_proc := g_package||'pre_update';
180 hr_utility.set_location('Entering:'||l_proc, 5);
181 --
182 hr_utility.set_location(' Leaving:'||l_proc, 10);
183 end if;
184 End pre_update;
185 --
186 -- ----------------------------------------------------------------------------
187 -- |-----------------------------< post_update >------------------------------|
188 -- ----------------------------------------------------------------------------
189 -- {Start Of Comments}
190 --
191 -- Description:
192 -- This private procedure contains any processing which is required after the
193 -- update dml.
194 --
195 -- Prerequisites:
196 -- This is an internal procedure which is called from the upd procedure.
197 --
198 -- In Parameters:
199 -- A Pl/Sql record structure.
200 --
201 -- Post Success:
202 -- Processing continues.
203 --
204 -- Post Failure:
205 -- If an error has occurred, an error message and exception will be raised
206 -- but not handled.
207 --
208 -- Developer Implementation Notes:
209 -- Any post-processing required after the update dml is issued should be
210 -- coded within this procedure. It is important to note that any 3rd party
211 -- maintenance should be reviewed before placing in this procedure.
212 --
213 -- Access Status:
214 -- Internal Row Handler Use Only.
215 --
216 -- {End Of Comments}
217 -- ----------------------------------------------------------------------------
218 Procedure post_update
219 (p_effective_date in date
220 ,p_rec in hxc_hac_shd.g_rec_type
221 ) is
222 --
223 l_proc varchar2(72);
224 --
225 Begin
226 if g_debug then
227 l_proc := g_package||'post_update';
228 hr_utility.set_location('Entering:'||l_proc, 5);
229 end if;
230 begin
231 --
232 update hxc_app_comp_notif_usages
233 set
234 approval_comp_ovn=p_rec.object_version_number where
235 approval_comp_id=p_rec.approval_comp_id and
236 approval_comp_ovn=hxc_hac_shd.g_old_rec.object_version_number;
237
238
239 hxc_hac_rku.after_update
240 (p_effective_date => p_effective_date
241 ,p_approval_comp_id
242 => p_rec.approval_comp_id
243 ,p_approval_style_id
244 => p_rec.approval_style_id
245 ,p_time_recipient_id
246 => p_rec.time_recipient_id
247 ,p_approval_mechanism
248 => p_rec.approval_mechanism
249 ,p_approval_mechanism_id
250 => p_rec.approval_mechanism_id
251 ,p_wf_item_type
252 => p_rec.wf_item_type
253 ,p_wf_name
254 => p_rec.wf_name
255 ,p_start_date
256 => p_rec.start_date
257 ,p_end_date
258 => p_rec.end_date
259 ,p_object_version_number
260 => p_rec.object_version_number
261 ,p_approval_order
262 => p_rec.approval_order
263 ,p_time_category_id
264 => p_rec.time_category_id
265 ,p_parent_comp_id
266 => p_rec.parent_comp_id
267 ,p_parent_comp_ovn
268 => p_rec.parent_comp_ovn
269 ,p_run_recipient_extensions =>p_rec.run_recipient_extensions
270 ,p_approval_style_id_o
271 => hxc_hac_shd.g_old_rec.approval_style_id
272 ,p_time_recipient_id_o
273 => hxc_hac_shd.g_old_rec.time_recipient_id
274 ,p_approval_mechanism_o
275 => hxc_hac_shd.g_old_rec.approval_mechanism
276 ,p_approval_mechanism_id_o
277 => hxc_hac_shd.g_old_rec.approval_mechanism_id
278 ,p_wf_item_type_o
279 => hxc_hac_shd.g_old_rec.wf_item_type
280 ,p_wf_name_o
281 => hxc_hac_shd.g_old_rec.wf_name
282 ,p_start_date_o
283 => hxc_hac_shd.g_old_rec.start_date
284 ,p_end_date_o
285 => hxc_hac_shd.g_old_rec.end_date
286 ,p_object_version_number_o
287 => hxc_hac_shd.g_old_rec.object_version_number
288 ,p_approval_order_o
289 => hxc_hac_shd.g_old_rec.approval_order
290 ,p_time_category_id_o
291 => hxc_hac_shd.g_old_rec.time_category_id
292 ,p_parent_comp_id_o
293 => hxc_hac_shd.g_old_rec.parent_comp_id
294 ,p_parent_comp_ovn_o
295 => hxc_hac_shd.g_old_rec.parent_comp_ovn
296 ,p_run_recipient_extensions_o =>hxc_hac_shd.g_old_rec.run_recipient_extensions
297
298 );
299 --
300 exception
301 --
302 when hr_api.cannot_find_prog_unit then
303 --
304 hr_api.cannot_find_prog_unit_error
305 (p_module_name => 'HXC_APPROVAL_COMPS'
306 ,p_hook_type => 'AU');
307 --
308 end;
309 --
310 if g_debug then
311 hr_utility.set_location(' Leaving:'||l_proc, 10);
312 end if;
313 End post_update;
314 --
315 -- ----------------------------------------------------------------------------
316 -- |-----------------------------< convert_defs >-----------------------------|
317 -- ----------------------------------------------------------------------------
318 -- {Start Of Comments}
319 --
320 -- Description:
321 -- The Convert_Defs procedure has one very important function:
322 -- It must return the record structure for the row with all system defaulted
323 -- values converted into its corresponding parameter value for update. When
324 -- we attempt to update a row through the Upd process , certain
325 -- parameters can be defaulted which enables flexibility in the calling of
326 -- the upd process (e.g. only attributes which need to be updated need to be
327 -- specified). For the upd process to determine which attributes
328 -- have NOT been specified we need to check if the parameter has a reserved
329 -- system default value. Therefore, for all parameters which have a
330 -- corresponding reserved system default mechanism specified we need to
331 -- check if a system default is being used. If a system default is being
332 -- used then we convert the defaulted value into its corresponding attribute
333 -- value held in the g_old_rec data structure.
334 --
335 -- Prerequisites:
336 -- This private function can only be called from the upd process.
337 --
338 -- In Parameters:
339 -- A Pl/Sql record structure.
340 --
341 -- Post Success:
342 -- The record structure will be returned with all system defaulted parameter
343 -- values converted into its current row attribute value.
344 --
345 -- Post Failure:
346 -- No direct error handling is required within this function. Any possible
347 -- errors within this procedure will be a PL/SQL value error due to
348 -- conversion of datatypes or data lengths.
349 --
350 -- Developer Implementation Notes:
351 -- None.
352 --
353 -- Access Status:
354 -- Internal Row Handler Use Only.
355 --
356 -- {End Of Comments}
357 -- ----------------------------------------------------------------------------
358 Procedure convert_defs
359 (p_rec in out nocopy hxc_hac_shd.g_rec_type
360 ) is
361 --
362 Begin
363 --
364 -- We must now examine each argument value in the
365 -- p_rec plsql record structure
366 -- to see if a system default is being used. If a system default
367 -- is being used then we must set to the 'current' argument value.
368 --
369 If (p_rec.approval_style_id = hr_api.g_number) then
370 p_rec.approval_style_id :=
371 hxc_hac_shd.g_old_rec.approval_style_id;
372 End If;
373 If (p_rec.time_recipient_id = hr_api.g_number) then
374 p_rec.time_recipient_id :=
375 hxc_hac_shd.g_old_rec.time_recipient_id;
376 End If;
377 If (p_rec.approval_mechanism = hr_api.g_varchar2) then
378 p_rec.approval_mechanism :=
379 hxc_hac_shd.g_old_rec.approval_mechanism;
380 End If;
381 If (p_rec.approval_mechanism_id = hr_api.g_number) then
382 p_rec.approval_mechanism_id :=
383 hxc_hac_shd.g_old_rec.approval_mechanism_id;
384 End If;
385 If (p_rec.wf_item_type = hr_api.g_varchar2) then
386 p_rec.wf_item_type :=
387 hxc_hac_shd.g_old_rec.wf_item_type;
388 End If;
389 If (p_rec.wf_name = hr_api.g_varchar2) then
390 p_rec.wf_name :=
391 hxc_hac_shd.g_old_rec.wf_name;
392 End If;
393 If (p_rec.start_date = hr_api.g_date) then
394 p_rec.start_date :=
395 hxc_hac_shd.g_old_rec.start_date;
396 End If;
397 If (p_rec.end_date = hr_api.g_date) then
398 p_rec.end_date :=
399 hxc_hac_shd.g_old_rec.end_date;
400 End If;
401 If (p_rec.approval_order = hr_api.g_number) then
402 p_rec.approval_order :=
403 hxc_hac_shd.g_old_rec.approval_order;
404 End If;
405 If (p_rec.time_category_id = hr_api.g_number) then
406 p_rec.time_category_id :=
407 hxc_hac_shd.g_old_rec.time_category_id;
408 End If;
409 If (p_rec.parent_comp_id = hr_api.g_number) then
410 p_rec.parent_comp_id :=
411 hxc_hac_shd.g_old_rec.parent_comp_id;
412 End If;
413 If (p_rec.parent_comp_ovn = hr_api.g_number) then
414 p_rec.parent_comp_ovn :=
415 hxc_hac_shd.g_old_rec.parent_comp_ovn;
416 End If;
417 If (p_rec.run_recipient_extensions = hr_api.g_varchar2) then
418 p_rec.run_recipient_extensions :=
419 hxc_hac_shd.g_old_rec.run_recipient_extensions;
420 End If;
421 --
422 End convert_defs;
423 --
424 -- ----------------------------------------------------------------------------
425 -- |---------------------------------< upd >----------------------------------|
426 -- ----------------------------------------------------------------------------
427 Procedure upd
428 (p_effective_date in date
429 ,p_rec in out nocopy hxc_hac_shd.g_rec_type
430 ) is
431 --
432 l_proc varchar2(72);
433 --
434 Begin
435 g_debug:=hr_utility.debug_enabled;
436 if g_debug then
437 l_proc := g_package||'upd';
438 hr_utility.set_location('Entering:'||l_proc, 5);
439 end if;
440 --
441 -- We must lock the row which we need to update.
442 --
443 hxc_hac_shd.lck
444 (p_rec.approval_comp_id
445 ,p_rec.object_version_number
446 );
447 --
448 -- 1. During an update system defaults are used to determine if
449 -- arguments have been defaulted or not. We must therefore
450 -- derive the full record structure values to be updated.
451 --
452 -- 2. Call the supporting update validate operations.
453 --
454 convert_defs(p_rec);
455 hxc_hac_bus.update_validate
456 (p_effective_date
457 ,p_rec
458 );
459 --
460 -- Call the supporting pre-update operation
461 --
462 hxc_hac_upd.pre_update(p_rec);
463 --
464 -- Update the row.
465 --
466 hxc_hac_upd.update_dml(p_rec);
467 --
468 -- Call the supporting post-update operation
469 --
470 hxc_hac_upd.post_update
471 (p_effective_date
472 ,p_rec
473 );
474 End upd;
475 --
476 -- ----------------------------------------------------------------------------
477 -- |---------------------------------< upd >----------------------------------|
478 -- ----------------------------------------------------------------------------
479 Procedure upd
480 (p_effective_date in date
481 ,p_approval_comp_id in number
482 ,p_object_version_number in out nocopy number
483 ,p_approval_style_id in number default hr_api.g_number
484 ,p_time_recipient_id in number default hr_api.g_number
485 ,p_approval_mechanism in varchar2 default hr_api.g_varchar2
486 ,p_start_date in date default hr_api.g_date
487 ,p_end_date in date default hr_api.g_date
488 ,p_approval_mechanism_id in number default hr_api.g_number
489 ,p_wf_item_type in varchar2 default hr_api.g_varchar2
490 ,p_wf_name in varchar2 default hr_api.g_varchar2
491 ,p_approval_order in number default hr_api.g_number
492 ,p_time_category_id in number default hr_api.g_number
493 ,p_parent_comp_id in number default hr_api.g_number
494 ,p_parent_comp_ovn in number default hr_api.g_number
495 ,p_run_recipient_extensions in varchar2 default hr_api.g_varchar2
496
497 ) is
498 --
499 l_rec hxc_hac_shd.g_rec_type;
500 l_proc varchar2(72);
501 --
502 Begin
503 g_debug:=hr_utility.debug_enabled;
504 if g_debug then
505 l_proc := g_package||'upd';
506 hr_utility.set_location('Entering:'||l_proc, 5);
507 end if;
508 --
509 -- Call conversion function to turn arguments into the
510 -- l_rec structure.
511 --
512 l_rec :=
513 hxc_hac_shd.convert_args
514 (p_approval_comp_id
515 ,p_approval_style_id
516 ,p_time_recipient_id
517 ,p_approval_mechanism
518 ,p_approval_mechanism_id
519 ,p_wf_item_type
520 ,p_wf_name
521 ,p_start_date
522 ,p_end_date
523 ,p_object_version_number
524 ,p_approval_order
525 ,p_time_category_id
526 ,p_parent_comp_id
527 ,p_parent_comp_ovn
528 ,p_run_recipient_extensions
529 );
530 --
531 -- Having converted the arguments into the
532 -- plsql record structure we call the corresponding record
533 -- business process.
534 --
535 hxc_hac_upd.upd
536 (p_effective_date
537 ,l_rec
538 );
539 p_object_version_number := l_rec.object_version_number;
540 --
541 if g_debug then
542 hr_utility.set_location(' Leaving:'||l_proc, 10);
543 end if;
544 End upd;
545 --
546 end hxc_hac_upd;