1 Package Body ben_bri_upd as
2 /* $Header: bebrirhi.pkb 120.0 2005/05/28 00:51:44 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_bri_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(p_rec in out nocopy ben_bri_shd.g_rec_type) is
55 --
56 l_proc varchar2(72) := g_package||'update_dml';
57 --
58 Begin
59 hr_utility.set_location('Entering:'||l_proc, 5);
60 --
61 -- Increment the object version
62 --
63 p_rec.object_version_number := p_rec.object_version_number + 1;
64 --
65 ben_bri_shd.g_api_dml := true; -- Set the api dml status
66 --
67 -- Update the ben_batch_rate_info Row
68 --
69 update ben_batch_rate_info
70 set
71 batch_rt_id = p_rec.batch_rt_id,
72 benefit_action_id = p_rec.benefit_action_id,
73 person_id = p_rec.person_id,
74 pgm_id = p_rec.pgm_id,
75 pl_id = p_rec.pl_id,
76 oipl_id = p_rec.oipl_id,
77 bnft_rt_typ_cd = p_rec.bnft_rt_typ_cd,
78 dflt_flag = p_rec.dflt_flag,
79 val = p_rec.val,
80 old_val = p_rec.old_val,
81 tx_typ_cd = p_rec.tx_typ_cd,
82 acty_typ_cd = p_rec.acty_typ_cd,
83 mn_elcn_val = p_rec.mn_elcn_val,
84 mx_elcn_val = p_rec.mx_elcn_val,
85 incrmt_elcn_val = p_rec.incrmt_elcn_val,
86 dflt_val = p_rec.dflt_val,
87 rt_strt_dt = p_rec.rt_strt_dt,
88 business_group_id = p_rec.business_group_id,
89 object_version_number = p_rec.object_version_number,
90 enrt_cvg_strt_dt = p_rec.enrt_cvg_strt_dt,
91 enrt_cvg_thru_dt = p_rec.enrt_cvg_thru_dt,
92 actn_cd = p_rec.actn_cd,
93 close_actn_itm_dt = p_rec.close_actn_itm_dt
94 where batch_rt_id = p_rec.batch_rt_id;
95 --
96 ben_bri_shd.g_api_dml := false; -- Unset the api dml status
97 --
98 hr_utility.set_location(' Leaving:'||l_proc, 10);
99 --
100 Exception
101 When hr_api.check_integrity_violated Then
102 -- A check constraint has been violated
103 ben_bri_shd.g_api_dml := false; -- Unset the api dml status
104 ben_bri_shd.constraint_error
105 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106 When hr_api.parent_integrity_violated Then
107 -- Parent integrity has been violated
108 ben_bri_shd.g_api_dml := false; -- Unset the api dml status
109 ben_bri_shd.constraint_error
110 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
111 When hr_api.unique_integrity_violated Then
112 -- Unique integrity has been violated
113 ben_bri_shd.g_api_dml := false; -- Unset the api dml status
114 ben_bri_shd.constraint_error
115 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
116 When Others Then
117 ben_bri_shd.g_api_dml := false; -- Unset the api dml status
118 Raise;
119 End update_dml;
120 --
121 -- ----------------------------------------------------------------------------
122 -- |------------------------------< pre_update >------------------------------|
123 -- ----------------------------------------------------------------------------
124 -- {Start Of Comments}
125 --
126 -- Description:
127 -- This private procedure contains any processing which is required before
128 -- the update dml.
129 --
130 -- Prerequisites:
131 -- This is an internal procedure which is called from the upd procedure.
132 --
133 -- In Parameters:
134 -- A Pl/Sql record structre.
135 --
136 -- Post Success:
137 -- Processing continues.
138 --
139 -- Post Failure:
140 -- If an error has occurred, an error message and exception will be raised
141 -- but not handled.
142 --
143 -- Developer Implementation Notes:
144 -- Any pre-processing required before the update dml is issued should be
145 -- coded within this procedure. It is important to note that any 3rd party
146 -- maintenance should be reviewed before placing in this procedure.
147 --
148 -- Access Status:
149 -- Internal Row Handler Use Only.
150 --
151 -- {End Of Comments}
152 -- ----------------------------------------------------------------------------
153 Procedure pre_update(p_rec in ben_bri_shd.g_rec_type) is
154 --
155 l_proc varchar2(72) := g_package||'pre_update';
156 --
157 Begin
158 hr_utility.set_location('Entering:'||l_proc, 5);
159 --
160 hr_utility.set_location(' Leaving:'||l_proc, 10);
161 End pre_update;
162 --
163 -- ----------------------------------------------------------------------------
164 -- |-----------------------------< post_update >------------------------------|
165 -- ----------------------------------------------------------------------------
166 -- {Start Of Comments}
167 --
168 -- Description:
169 -- This private procedure contains any processing which is required after the
170 -- update dml.
171 --
172 -- Prerequisites:
173 -- This is an internal procedure which is called from the upd procedure.
174 --
175 -- In Parameters:
176 -- A Pl/Sql record structre.
177 --
178 -- Post Success:
179 -- Processing continues.
180 --
181 -- Post Failure:
182 -- If an error has occurred, an error message and exception will be raised
183 -- but not handled.
184 --
185 -- Developer Implementation Notes:
186 -- Any post-processing required after the update dml is issued should be
187 -- coded within this procedure. It is important to note that any 3rd party
188 -- maintenance should be reviewed before placing in this procedure.
189 --
190 -- Access Status:
191 -- Internal Row Handler Use Only.
192 --
193 -- {End Of Comments}
194 -- ----------------------------------------------------------------------------
195 Procedure post_update(
196 p_effective_date in date,p_rec in ben_bri_shd.g_rec_type) is
197 --
198 l_proc varchar2(72) := g_package||'post_update';
199 --
200 Begin
201 hr_utility.set_location('Entering:'||l_proc, 5);
202 --
203 --
204 -- Start of API User Hook for post_update.
205 --
206 begin
207 --
208 ben_bri_rku.after_update
209 (p_batch_rt_id =>p_rec.batch_rt_id
210 ,p_benefit_action_id =>p_rec.benefit_action_id
211 ,p_person_id =>p_rec.person_id
212 ,p_pgm_id =>p_rec.pgm_id
213 ,p_pl_id =>p_rec.pl_id
214 ,p_oipl_id =>p_rec.oipl_id
215 ,p_bnft_rt_typ_cd =>p_rec.bnft_rt_typ_cd
216 ,p_dflt_flag =>p_rec.dflt_flag
217 ,p_val =>p_rec.val
218 ,p_old_val =>p_rec.old_val
219 ,p_tx_typ_cd =>p_rec.tx_typ_cd
220 ,p_acty_typ_cd =>p_rec.acty_typ_cd
221 ,p_mn_elcn_val =>p_rec.mn_elcn_val
222 ,p_mx_elcn_val =>p_rec.mx_elcn_val
223 ,p_incrmt_elcn_val =>p_rec.incrmt_elcn_val
224 ,p_dflt_val =>p_rec.dflt_val
225 ,p_rt_strt_dt =>p_rec.rt_strt_dt
226 ,p_business_group_id =>p_rec.business_group_id
227 ,p_object_version_number =>p_rec.object_version_number
228 ,p_enrt_cvg_strt_dt =>p_rec.enrt_cvg_strt_dt
229 ,p_enrt_cvg_thru_dt =>p_rec.enrt_cvg_thru_dt
230 ,p_actn_cd =>p_rec.actn_cd
231 ,p_close_actn_itm_dt =>p_rec.close_actn_itm_dt
232 ,p_effective_date =>p_effective_date
233 ,p_benefit_action_id_o =>ben_bri_shd.g_old_rec.benefit_action_id
234 ,p_person_id_o =>ben_bri_shd.g_old_rec.person_id
235 ,p_pgm_id_o =>ben_bri_shd.g_old_rec.pgm_id
236 ,p_pl_id_o =>ben_bri_shd.g_old_rec.pl_id
237 ,p_oipl_id_o =>ben_bri_shd.g_old_rec.oipl_id
238 ,p_bnft_rt_typ_cd_o =>ben_bri_shd.g_old_rec.bnft_rt_typ_cd
239 ,p_dflt_flag_o =>ben_bri_shd.g_old_rec.dflt_flag
240 ,p_val_o =>ben_bri_shd.g_old_rec.val
241 ,p_old_val_o =>ben_bri_shd.g_old_rec.old_val
242 ,p_tx_typ_cd_o =>ben_bri_shd.g_old_rec.tx_typ_cd
243 ,p_acty_typ_cd_o =>ben_bri_shd.g_old_rec.acty_typ_cd
244 ,p_mn_elcn_val_o =>ben_bri_shd.g_old_rec.mn_elcn_val
245 ,p_mx_elcn_val_o =>ben_bri_shd.g_old_rec.mx_elcn_val
246 ,p_incrmt_elcn_val_o =>ben_bri_shd.g_old_rec.incrmt_elcn_val
247 ,p_dflt_val_o =>ben_bri_shd.g_old_rec.dflt_val
248 ,p_rt_strt_dt_o =>ben_bri_shd.g_old_rec.rt_strt_dt
249 ,p_business_group_id_o =>ben_bri_shd.g_old_rec.business_group_id
250 ,p_object_version_number_o =>ben_bri_shd.g_old_rec.object_version_number
251 ,p_enrt_cvg_strt_dt_o =>ben_bri_shd.g_old_rec.enrt_cvg_strt_dt
252 ,p_enrt_cvg_thru_dt_o =>ben_bri_shd.g_old_rec.enrt_cvg_thru_dt
253 ,p_actn_cd_o =>ben_bri_shd.g_old_rec.actn_cd
254 ,p_close_actn_itm_dt_o =>ben_bri_shd.g_old_rec.close_actn_itm_dt
255
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 => 'ben_batch_rate_info'
264 ,p_hook_type => 'AU');
265 --
266 end;
267 --
268 -- End of API User Hook for post_update.
269 --
270 --
271 hr_utility.set_location(' Leaving:'||l_proc, 10);
272 End post_update;
273 --
274 -- ----------------------------------------------------------------------------
275 -- |-----------------------------< convert_defs >-----------------------------|
276 -- ----------------------------------------------------------------------------
277 -- {Start Of Comments}
278 --
279 -- Description:
280 -- The Convert_Defs procedure has one very important function:
281 -- It must return the record structure for the row with all system defaulted
282 -- values converted into its corresponding parameter value for update. When
283 -- we attempt to update a row through the Upd process , certain
284 -- parameters can be defaulted which enables flexibility in the calling of
285 -- the upd process (e.g. only attributes which need to be updated need to be
286 -- specified). For the upd process to determine which attributes
287 -- have NOT been specified we need to check if the parameter has a reserved
288 -- system default value. Therefore, for all parameters which have a
289 -- corresponding reserved system default mechanism specified we need to
290 -- check if a system default is being used. If a system default is being
291 -- used then we convert the defaulted value into its corresponding attribute
292 -- value held in the g_old_rec data structure.
293 --
294 -- Prerequisites:
295 -- This private function can only be called from the upd process.
296 --
297 -- In Parameters:
298 -- A Pl/Sql record structre.
299 --
300 -- Post Success:
301 -- The record structure will be returned with all system defaulted parameter
302 -- values converted into its current row attribute value.
303 --
304 -- Post Failure:
305 -- No direct error handling is required within this function. Any possible
306 -- errors within this procedure will be a PL/SQL value error due to conversion
307 -- of datatypes or data lengths.
308 --
309 -- Developer Implementation Notes:
310 -- None.
311 --
312 -- Access Status:
313 -- Internal Row Handler Use Only.
314 --
315 -- {End Of Comments}
316 -- ----------------------------------------------------------------------------
317 Procedure convert_defs(p_rec in out nocopy ben_bri_shd.g_rec_type) is
318 --
319 l_proc varchar2(72) := g_package||'convert_defs';
320 --
321 Begin
322 --
323 hr_utility.set_location('Entering:'||l_proc, 5);
324 --
325 -- We must now examine each argument value in the
326 -- p_rec plsql record structure
327 -- to see if a system default is being used. If a system default
328 -- is being used then we must set to the 'current' argument value.
329 --
330 If (p_rec.benefit_action_id = hr_api.g_number) then
331 p_rec.benefit_action_id :=
332 ben_bri_shd.g_old_rec.benefit_action_id;
333 End If;
334 If (p_rec.person_id = hr_api.g_number) then
335 p_rec.person_id :=
336 ben_bri_shd.g_old_rec.person_id;
337 End If;
338 If (p_rec.pgm_id = hr_api.g_number) then
339 p_rec.pgm_id :=
340 ben_bri_shd.g_old_rec.pgm_id;
341 End If;
342 If (p_rec.pl_id = hr_api.g_number) then
343 p_rec.pl_id :=
344 ben_bri_shd.g_old_rec.pl_id;
345 End If;
346 If (p_rec.oipl_id = hr_api.g_number) then
347 p_rec.oipl_id :=
348 ben_bri_shd.g_old_rec.oipl_id;
349 End If;
350 If (p_rec.bnft_rt_typ_cd = hr_api.g_varchar2) then
351 p_rec.bnft_rt_typ_cd :=
352 ben_bri_shd.g_old_rec.bnft_rt_typ_cd;
353 End If;
354 If (p_rec.dflt_flag = hr_api.g_varchar2) then
355 p_rec.dflt_flag :=
356 ben_bri_shd.g_old_rec.dflt_flag;
357 End If;
358 If (p_rec.val = hr_api.g_number) then
359 p_rec.val :=
360 ben_bri_shd.g_old_rec.val;
361 End If;
362 if (p_rec.old_val = hr_api.g_number) then
363 p_rec.old_val :=
364 ben_bri_shd.g_old_rec.old_val;
365 End If;
366 If (p_rec.tx_typ_cd = hr_api.g_varchar2) then
367 p_rec.tx_typ_cd :=
368 ben_bri_shd.g_old_rec.tx_typ_cd;
369 End If;
370 If (p_rec.acty_typ_cd = hr_api.g_varchar2) then
371 p_rec.acty_typ_cd :=
372 ben_bri_shd.g_old_rec.acty_typ_cd;
373 End If;
374 If (p_rec.mn_elcn_val = hr_api.g_number) then
375 p_rec.mn_elcn_val :=
376 ben_bri_shd.g_old_rec.mn_elcn_val;
377 End If;
378 If (p_rec.mx_elcn_val = hr_api.g_number) then
379 p_rec.mx_elcn_val :=
380 ben_bri_shd.g_old_rec.mx_elcn_val;
381 End If;
382 If (p_rec.incrmt_elcn_val = hr_api.g_number) then
383 p_rec.incrmt_elcn_val :=
384 ben_bri_shd.g_old_rec.incrmt_elcn_val;
385 End If;
386 If (p_rec.dflt_val = hr_api.g_number) then
387 p_rec.dflt_val :=
388 ben_bri_shd.g_old_rec.dflt_val;
389 End If;
390 If (p_rec.rt_strt_dt = hr_api.g_date) then
391 p_rec.rt_strt_dt :=
392 ben_bri_shd.g_old_rec.rt_strt_dt;
393 End If;
394 If (p_rec.business_group_id = hr_api.g_number) then
395 p_rec.business_group_id :=
396 ben_bri_shd.g_old_rec.business_group_id;
397 End If;
398 If (p_rec.enrt_cvg_strt_dt = hr_api.g_date) then
399 p_rec.enrt_cvg_strt_dt :=
400 ben_bri_shd.g_old_rec.enrt_cvg_strt_dt;
401 End If;
402 If (p_rec.enrt_cvg_thru_dt = hr_api.g_date) then
403 p_rec.enrt_cvg_thru_dt :=
404 ben_bri_shd.g_old_rec.enrt_cvg_thru_dt;
405 End If;
406 If (p_rec.actn_cd = hr_api.g_varchar2) then
407 p_rec.actn_cd :=
408 ben_bri_shd.g_old_rec.actn_cd;
409 End If;
410 If (p_rec.close_actn_itm_dt = hr_api.g_date) then
411 p_rec.close_actn_itm_dt :=
412 ben_bri_shd.g_old_rec.close_actn_itm_dt;
413 End If;
414 --
415 hr_utility.set_location(' Leaving:'||l_proc, 10);
416 --
417 End convert_defs;
418 --
419 -- ----------------------------------------------------------------------------
420 -- |---------------------------------< upd >----------------------------------|
421 -- ----------------------------------------------------------------------------
422 Procedure upd
423 (
424 p_effective_date in date,
425 p_rec in out nocopy ben_bri_shd.g_rec_type
426 ) is
427 --
428 l_proc varchar2(72) := g_package||'upd';
429 --
430 Begin
431 hr_utility.set_location('Entering:'||l_proc, 5);
432 --
433 -- We must lock the row which we need to update.
434 --
435 ben_bri_shd.lck
436 (
437 p_rec.batch_rt_id,
438 p_rec.object_version_number
439 );
440 --
441 -- 1. During an update system defaults are used to determine if
442 -- arguments have been defaulted or not. We must therefore
443 -- derive the full record structure values to be updated.
444 --
445 -- 2. Call the supporting update validate operations.
446 --
447 convert_defs(p_rec);
448 ben_bri_bus.update_validate(p_rec
449 ,p_effective_date);
450 --
451 -- Call the supporting pre-update operation
452 --
453 pre_update(p_rec);
454 --
455 -- Update the row.
456 --
457 update_dml(p_rec);
458 --
459 -- Call the supporting post-update operation
460 --
461 post_update(p_effective_date,p_rec);
462 --
463 End upd;
464 --
465 -- ----------------------------------------------------------------------------
466 -- |---------------------------------< upd >----------------------------------|
467 -- ----------------------------------------------------------------------------
468 Procedure upd
469 (
470 p_effective_date in date,
471 p_batch_rt_id in number,
472 p_benefit_action_id in number default hr_api.g_number,
473 p_person_id in number default hr_api.g_number,
474 p_pgm_id in number default hr_api.g_number,
475 p_pl_id in number default hr_api.g_number,
476 p_oipl_id in number default hr_api.g_number,
477 p_bnft_rt_typ_cd in varchar2 default hr_api.g_varchar2,
478 p_dflt_flag in varchar2 default hr_api.g_varchar2,
479 p_val in number default hr_api.g_number,
480 p_old_val in number default hr_api.g_number,
481 p_tx_typ_cd in varchar2 default hr_api.g_varchar2,
482 p_acty_typ_cd in varchar2 default hr_api.g_varchar2,
483 p_mn_elcn_val in number default hr_api.g_number,
484 p_mx_elcn_val in number default hr_api.g_number,
485 p_incrmt_elcn_val in number default hr_api.g_number,
486 p_dflt_val in number default hr_api.g_number,
487 p_rt_strt_dt in date default hr_api.g_date,
488 p_business_group_id in number default hr_api.g_number,
489 p_object_version_number in out nocopy number,
490 p_enrt_cvg_strt_dt in date default hr_api.g_date,
491 p_enrt_cvg_thru_dt in date default hr_api.g_date,
492 p_actn_cd in varchar2 default hr_api.g_varchar2,
493 p_close_actn_itm_dt in date default hr_api.g_date
494 ) is
495 --
496 l_rec ben_bri_shd.g_rec_type;
497 l_proc varchar2(72) := g_package||'upd';
498 --
499 Begin
500 hr_utility.set_location('Entering:'||l_proc, 5);
501 --
502 -- Call conversion function to turn arguments into the
503 -- l_rec structure.
504 --
505 l_rec :=
506 ben_bri_shd.convert_args
507 (
508 p_batch_rt_id,
509 p_benefit_action_id,
510 p_person_id,
511 p_pgm_id,
512 p_pl_id,
513 p_oipl_id,
514 p_bnft_rt_typ_cd,
515 p_dflt_flag,
516 p_val,
517 p_old_val,
518 p_tx_typ_cd,
519 p_acty_typ_cd,
520 p_mn_elcn_val,
521 p_mx_elcn_val,
522 p_incrmt_elcn_val,
523 p_dflt_val,
524 p_rt_strt_dt,
525 p_business_group_id,
526 p_object_version_number,
527 p_enrt_cvg_strt_dt,
528 p_enrt_cvg_thru_dt,
529 p_actn_cd,
530 p_close_actn_itm_dt
531 );
532 --
533 -- Having converted the arguments into the
534 -- plsql record structure we call the corresponding record
535 -- business process.
536 --
537 upd(p_effective_date,l_rec);
538 p_object_version_number := l_rec.object_version_number;
539 --
540 hr_utility.set_location(' Leaving:'||l_proc, 10);
541 End upd;
542 --
543 end ben_bri_upd;