1 Package Body pay_rcu_upd as
2 /* $Header: pyrcurhi.pkb 120.1.12020000.2 2012/09/23 07:50:52 jkvallab ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_rcu_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_rcu_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_retro_component_usages Row
69 --
70 update pay_retro_component_usages
71 set
72 retro_component_usage_id = p_rec.retro_component_usage_id
73 ,retro_component_id = p_rec.retro_component_id
74 ,creator_id = p_rec.creator_id
75 ,creator_type = p_rec.creator_type
76 ,default_component = p_rec.default_component
77 ,reprocess_type = p_rec.reprocess_type
78 ,object_version_number = p_rec.object_version_number
79 ,replace_run_flag = p_rec.replace_run_flag
80 ,use_override_dates = p_rec.use_override_dates
81 where retro_component_usage_id = p_rec.retro_component_usage_id;
82 --
83 --
84 --
85 hr_utility.set_location(' Leaving:'||l_proc, 10);
86 --
87 Exception
88 When hr_api.check_integrity_violated Then
89 -- A check constraint has been violated
90 --
91 pay_rcu_shd.constraint_error
92 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
93 When hr_api.parent_integrity_violated Then
94 -- Parent integrity has been violated
95 --
96 pay_rcu_shd.constraint_error
97 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98 When hr_api.unique_integrity_violated Then
99 -- Unique integrity has been violated
100 --
101 pay_rcu_shd.constraint_error
102 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103 When Others Then
104 --
105 Raise;
106 End update_dml;
107 --
108 -- ----------------------------------------------------------------------------
109 -- |------------------------------< pre_update >------------------------------|
110 -- ----------------------------------------------------------------------------
111 -- {Start Of Comments}
112 --
113 -- Description:
114 -- This private procedure contains any processing which is required before
115 -- the update dml.
116 --
117 -- Prerequisites:
118 -- This is an internal procedure which is called from the upd procedure.
119 --
120 -- In Parameters:
121 -- A Pl/Sql record structure.
122 --
123 -- Post Success:
124 -- Processing continues.
125 --
126 -- Post Failure:
127 -- If an error has occurred, an error message and exception wil be raised
128 -- but not handled.
129 --
130 -- Developer Implementation Notes:
131 -- Any pre-processing required before the update dml is issued should be
132 -- coded within this procedure. It is important to note that any 3rd party
133 -- maintenance should be reviewed before placing in this procedure.
134 --
135 -- Access Status:
136 -- Internal Row Handler Use Only.
137 --
138 -- {End Of Comments}
139 -- ----------------------------------------------------------------------------
140 Procedure pre_update
141 (p_rec in pay_rcu_shd.g_rec_type
142 ) is
143 --
144 l_proc varchar2(72) := g_package||'pre_update';
145 --
146 Begin
147 hr_utility.set_location('Entering:'||l_proc, 5);
148 --
149 hr_utility.set_location(' Leaving:'||l_proc, 10);
150 End pre_update;
151 --
152 -- ----------------------------------------------------------------------------
153 -- |-----------------------------< post_update >------------------------------|
154 -- ----------------------------------------------------------------------------
155 -- {Start Of Comments}
156 --
157 -- Description:
158 -- This private procedure contains any processing which is required after
159 -- the update dml.
160 --
161 -- Prerequisites:
162 -- This is an internal procedure which is called from the upd procedure.
163 --
164 -- In Parameters:
165 -- A Pl/Sql record structure.
166 --
167 -- Post Success:
168 -- Processing continues.
169 --
170 -- Post Failure:
171 -- If an error has occurred, an error message and exception will be raised
172 -- but not handled.
173 --
174 -- Developer Implementation Notes:
175 -- Any post-processing required after the update dml is issued should be
176 -- coded within this procedure. It is important to note that any 3rd party
177 -- maintenance should be reviewed before placing in this procedure.
178 --
179 -- Access Status:
180 -- Internal Row Handler Use Only.
181 --
182 -- {End Of Comments}
183 -- ----------------------------------------------------------------------------
184 Procedure post_update
185 (p_effective_date in date
186 ,p_rec in pay_rcu_shd.g_rec_type
187 ) is
188 --
189 l_proc varchar2(72) := g_package||'post_update';
190 p_element_type_id pay_entry_process_details.source_element_type_id%type;
191 l_retro_component_id pay_retro_component_usages.retro_component_id%type;
192 --
193 Begin
194 hr_utility.set_location('Entering:'||l_proc, 5);
195 begin
196 --
197 pay_rcu_rku.after_update
198 (p_effective_date => p_effective_date
199 ,p_retro_component_usage_id
200 => p_rec.retro_component_usage_id
201 ,p_business_group_id
202 => p_rec.business_group_id
203 ,p_legislation_code
204 => p_rec.legislation_code
205 ,p_retro_component_id
206 => p_rec.retro_component_id
207 ,p_creator_id
208 => p_rec.creator_id
209 ,p_creator_type
210 => p_rec.creator_type
211 ,p_default_component
212 => p_rec.default_component
213 ,p_reprocess_type
214 => p_rec.reprocess_type
215 ,p_object_version_number
216 => p_rec.object_version_number
217 ,p_replace_run_flag
218 => p_rec.replace_run_flag
219 ,p_use_override_dates
220 => p_rec.use_override_dates
221 ,p_business_group_id_o
222 => pay_rcu_shd.g_old_rec.business_group_id
223 ,p_legislation_code_o
224 => pay_rcu_shd.g_old_rec.legislation_code
225 ,p_retro_component_id_o
226 => pay_rcu_shd.g_old_rec.retro_component_id
227 ,p_creator_id_o
228 => pay_rcu_shd.g_old_rec.creator_id
229 ,p_creator_type_o
230 => pay_rcu_shd.g_old_rec.creator_type
231 ,p_default_component_o
232 => pay_rcu_shd.g_old_rec.default_component
233 ,p_reprocess_type_o
234 => pay_rcu_shd.g_old_rec.reprocess_type
235 ,p_object_version_number_o
236 => pay_rcu_shd.g_old_rec.object_version_number
237 ,p_replace_run_flag_o
238 => pay_rcu_shd.g_old_rec.replace_run_flag
239 ,p_use_override_dates_o
240 => pay_rcu_shd.g_old_rec.use_override_dates
241 );
242 --
243 exception
244 --
245 when hr_api.cannot_find_prog_unit then
246 --
247 hr_api.cannot_find_prog_unit_error
248 (p_module_name => 'PAY_RETRO_COMPONENT_USAGES'
249 ,p_hook_type => 'AU');
250 --
251 end;
252 --
253 -- Start of bug 13795438
254 /*
255 Need to check if the element for which retro-component-id is being created has already
256 been processed in Retropay_by_Element.
257 If True then we need to update corresponding entry in PEPD, with respective retro_component_id
258 If there are more than one retro-components for an element type, we use the
259 defualt retro_component_id
260 */
261 begin
262 select distinct(source_element_type_id) into p_element_type_id from pay_entry_process_details pepd
263 where pepd.RETRO_COMPONENT_ID is null and source_element_type_id = p_rec.creator_id;
264
265 if p_element_type_id is not null then
266 if p_rec.default_component <> 'Y' then
267 select RETRO_COMPONENT_ID into l_retro_component_id from pay_retro_component_usages where
268 creator_id = p_rec.creator_id and default_component = 'Y' and
269 (( business_group_id = p_rec.business_group_id and
270 legislation_code is null )
271 or
272 (legislation_code = p_rec.legislation_code and business_group_id is null )
273 or
274 (legislation_code is null and business_group_id is null )
275 );
276 -- If there is no default component, we don't update the retro_component_id in PEPD
277 update pay_entry_process_details set RETRO_COMPONENT_ID = l_retro_component_id
278 where RETRO_COMPONENT_ID is null and source_element_type_id = p_rec.creator_id;
279 else
280 update pay_entry_process_details set RETRO_COMPONENT_ID = p_rec.retro_component_id
281 where RETRO_COMPONENT_ID is null and source_element_type_id = p_rec.creator_id;
282 end if;
283 end if;
284 exception
285
286 when NO_DATA_FOUND then -- no data to update in PEPD
287 null;
288 end;
289
290 -- End of bug 13795438
291 hr_utility.set_location(' Leaving:'||l_proc, 10);
292 End post_update;
293 --
294 -- ----------------------------------------------------------------------------
295 -- |-----------------------------< convert_defs >-----------------------------|
296 -- ----------------------------------------------------------------------------
297 -- {Start Of Comments}
298 --
299 -- Description:
300 -- The Convert_Defs procedure has one very important function:
301 -- It must return the record structure for the row with all system defaulted
302 -- values converted into its corresponding parameter value for update. When
303 -- we attempt to update a row through the Upd process , certain
304 -- parameters can be defaulted which enables flexibility in the calling of
305 -- the upd process (e.g. only attributes which need to be updated need to be
306 -- specified). For the upd process to determine which attributes
307 -- have NOT been specified we need to check if the parameter has a reserved
308 -- system default value. Therefore, for all parameters which have a
309 -- corresponding reserved system default mechanism specified we need to
310 -- check if a system default is being used. If a system default is being
311 -- used then we convert the defaulted value into its corresponding attribute
312 -- value held in the g_old_rec data structure.
313 --
314 -- Prerequisites:
315 -- This private function can only be called from the upd process.
316 --
317 -- In Parameters:
318 -- A Pl/Sql record structure.
319 --
320 -- Post Success:
321 -- The record structure will be returned with all system defaulted parameter
322 -- values converted into its current row attribute value.
323 --
324 -- Post Failure:
325 -- No direct error handling is required within this function. Any possible
326 -- errors within this procedure will be a PL/SQL value error due to
327 -- conversion of datatypes or data lengths.
328 --
329 -- Developer Implementation Notes:
330 -- None.
331 --
332 -- Access Status:
333 -- Internal Row Handler Use Only.
334 --
335 -- {End Of Comments}
336 -- ----------------------------------------------------------------------------
337 Procedure convert_defs
338 (p_rec in out nocopy pay_rcu_shd.g_rec_type
339 ) is
340 --
341 Begin
342 --
343 -- We must now examine each argument value in the
344 -- p_rec plsql record structure
345 -- to see if a system default is being used. If a system default
346 -- is being used then we must set to the 'current' argument value.
347 --
348 If (p_rec.business_group_id = hr_api.g_number) then
349 p_rec.business_group_id :=
350 pay_rcu_shd.g_old_rec.business_group_id;
351 End If;
352 If (p_rec.legislation_code = hr_api.g_varchar2) then
353 p_rec.legislation_code :=
354 pay_rcu_shd.g_old_rec.legislation_code;
355 End If;
356 If (p_rec.retro_component_id = hr_api.g_number) then
357 p_rec.retro_component_id :=
358 pay_rcu_shd.g_old_rec.retro_component_id;
359 End If;
360 If (p_rec.creator_id = hr_api.g_number) then
361 p_rec.creator_id :=
362 pay_rcu_shd.g_old_rec.creator_id;
363 End If;
364 If (p_rec.creator_type = hr_api.g_varchar2) then
365 p_rec.creator_type :=
366 pay_rcu_shd.g_old_rec.creator_type;
367 End If;
368 If (p_rec.default_component = hr_api.g_varchar2) then
369 p_rec.default_component :=
370 pay_rcu_shd.g_old_rec.default_component;
371 End If;
372 If (p_rec.reprocess_type = hr_api.g_varchar2) then
373 p_rec.reprocess_type :=
374 pay_rcu_shd.g_old_rec.reprocess_type;
375 End If;
376 If (p_rec.replace_run_flag = hr_api.g_varchar2) then
377 p_rec.replace_run_flag :=
378 pay_rcu_shd.g_old_rec.replace_run_flag;
379 End If;
380 If (p_rec.use_override_dates = hr_api.g_varchar2) then
381 p_rec.use_override_dates :=
382 pay_rcu_shd.g_old_rec.use_override_dates;
383 End If;
384 --
385 End convert_defs;
386 --
387 -- ----------------------------------------------------------------------------
388 -- |---------------------------------< upd >----------------------------------|
389 -- ----------------------------------------------------------------------------
390 Procedure upd
391 (p_effective_date in date
392 ,p_rec in out nocopy pay_rcu_shd.g_rec_type
393 ) is
394 --
395 l_proc varchar2(72) := g_package||'upd';
396 --
397 Begin
398 hr_utility.set_location('Entering:'||l_proc, 5);
399 --
400 -- We must lock the row which we need to update.
401 --
402 pay_rcu_shd.lck
403 (p_rec.retro_component_usage_id
404 ,p_rec.object_version_number
405 );
406 --
407 -- 1. During an update system defaults are used to determine if
408 -- arguments have been defaulted or not. We must therefore
409 -- derive the full record structure values to be updated.
410 --
411 -- 2. Call the supporting update validate operations.
412 --
413 convert_defs(p_rec);
414 pay_rcu_bus.update_validate
415 (p_effective_date
416 ,p_rec
417 );
418 --
419 -- Call to raise any errors on multi-message list
420 hr_multi_message.end_validation_set;
421 --
422 -- Call the supporting pre-update operation
423 --
424 pay_rcu_upd.pre_update(p_rec);
425 --
426 -- Update the row.
427 --
428 pay_rcu_upd.update_dml(p_rec);
429 --
430 -- Call the supporting post-update operation
431 --
432 pay_rcu_upd.post_update
433 (p_effective_date
434 ,p_rec
435 );
436 --
437 -- Call to raise any errors on multi-message list
438 hr_multi_message.end_validation_set;
439 End upd;
440 --
441 -- ----------------------------------------------------------------------------
442 -- |---------------------------------< upd >----------------------------------|
443 -- ----------------------------------------------------------------------------
444 Procedure upd
445 (p_effective_date in date
446 ,p_retro_component_usage_id in number
447 ,p_object_version_number in out nocopy number
448 ,p_retro_component_id in number default hr_api.g_number
449 ,p_creator_id in number default hr_api.g_number
450 ,p_creator_type in varchar2 default hr_api.g_varchar2
451 ,p_default_component in varchar2 default hr_api.g_varchar2
452 ,p_reprocess_type in varchar2 default hr_api.g_varchar2
453 ,p_replace_run_flag in varchar2 default hr_api.g_varchar2
454 ,p_use_override_dates in varchar2 default hr_api.g_varchar2
455 ) is
456 --
457 l_rec pay_rcu_shd.g_rec_type;
458 l_proc varchar2(72) := g_package||'upd';
459 --
460 Begin
461 hr_utility.set_location('Entering:'||l_proc, 5);
462 --
463 -- Call conversion function to turn arguments into the
464 -- l_rec structure.
465 --
466 l_rec :=
467 pay_rcu_shd.convert_args
468 (p_retro_component_usage_id
469 ,hr_api.g_number
470 ,hr_api.g_varchar2
471 ,p_retro_component_id
472 ,p_creator_id
473 ,p_creator_type
474 ,p_default_component
475 ,p_reprocess_type
476 ,p_object_version_number
477 ,p_replace_run_flag
478 ,p_use_override_dates
479 );
480 --
481 -- Having converted the arguments into the
482 -- plsql record structure we call the corresponding record
483 -- business process.
484 --
485 pay_rcu_upd.upd
486 (p_effective_date
487 ,l_rec
488 );
489 p_object_version_number := l_rec.object_version_number;
490 --
491 hr_utility.set_location(' Leaving:'||l_proc, 10);
492 End upd;
493 --
494 end pay_rcu_upd;