1 Package Body ssp_ern_upd as
2 /* $Header: spernrhi.pkb 120.8 2010/07/07 13:26:55 pbalu ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ssp_ern_upd.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< update_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description:
15 -- This procedure controls the actual dml update logic. The processing of
16 -- this procedure is:
17 -- 1) Increment the object_version_number by 1 if the object_version_number
18 -- is defined as an attribute for this entity.
19 -- 2) To set and unset the g_api_dml status as required (as we are about to
20 -- perform dml).
21 -- 3) To update the specified row in the schema using the primary key in
22 -- the predicates.
23 -- 4) To trap any constraint violations that may have occurred.
24 -- 5) To raise any other errors.
25 --
26 -- Pre Conditions:
27 -- This is an internal private procedure which must be called from the upd
28 -- procedure.
29 --
30 -- In Parameters:
31 -- A Pl/Sql record structre.
32 --
33 -- Post Success:
34 -- The specified row will be updated in the schema.
35 --
36 -- Post Failure:
37 -- On the update dml failure it is important to note that we always reset the
38 -- g_api_dml status to false.
39 -- If a check, unique or parent integrity constraint violation is raised the
40 -- constraint_error procedure will be called.
41 -- If any other error is reported, the error will be raised after the
42 -- g_api_dml status is reset.
43 --
44 -- Developer Implementation Notes:
45 -- The update 'set' attribute list should be modified if any of your
46 -- attributes are not updateable.
47 --
48 -- Access Status:
49 -- Internal Table Handler Use Only.
50 --
51 -- ----------------------------------------------------------------------------
52 Procedure update_dml(p_rec in out nocopy ssp_ern_shd.g_rec_type) is
53 --
54 l_proc varchar2(72) := g_package||'update_dml';
55 --
56 Begin
57 hr_utility.set_location('Entering:'||l_proc, 1);
58 --
59 -- Increment the object version
60 --
61 p_rec.object_version_number := p_rec.object_version_number + 1;
62 --
63 ssp_ern_shd.g_api_dml := true; -- Set the api dml status
64 --
65 -- Update the ssp_earnings_calculations Row
66 --
67 update ssp_earnings_calculations
68 set earnings_calculations_id = p_rec.earnings_calculations_id,
69 object_version_number = p_rec.object_version_number,
70 average_earnings_amount = p_rec.average_earnings_amount,
71 user_entered = p_rec.user_entered,
72 payment_periods = p_rec.payment_periods
73 where earnings_calculations_id = p_rec.earnings_calculations_id;
74 --
75 ssp_ern_shd.g_api_dml := false; -- Unset the api dml status
76 --
77 hr_utility.set_location('Leaving :'||l_proc, 100);
78 --
79 Exception
80 When hr_api.check_integrity_violated Then
81 -- A check constraint has been violated
82 ssp_ern_shd.g_api_dml := false; -- Unset the api dml status
83 ssp_ern_shd.constraint_error
84 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
85 When hr_api.parent_integrity_violated Then
86 -- Parent integrity has been violated
87 ssp_ern_shd.g_api_dml := false; -- Unset the api dml status
88 ssp_ern_shd.constraint_error
89 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
90 When hr_api.unique_integrity_violated Then
91 -- Unique integrity has been violated
92 ssp_ern_shd.g_api_dml := false; -- Unset the api dml status
93 ssp_ern_shd.constraint_error
94 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
95 When Others Then
96 ssp_ern_shd.g_api_dml := false; -- Unset the api dml status
97 Raise;
98 End update_dml;
99 --
100 -- ----------------------------------------------------------------------------
101 -- |------------------------------< pre_update >------------------------------|
102 -- ----------------------------------------------------------------------------
103 --
104 -- Description:
105 -- This private procedure contains any processing which is required before
106 -- the update dml.
107 --
108 -- Pre Conditions:
109 -- This is an internal procedure which is called from the upd procedure.
110 --
111 -- In Parameters:
112 -- A Pl/Sql record structre.
113 --
114 -- Post Success:
115 -- Processing continues.
116 --
117 -- Post Failure:
118 -- If an error has occurred, an error message and exception will be raised
119 -- but not handled.
120 --
121 -- Developer Implementation Notes:
122 -- Any pre-processing required before the update dml is issued should be
123 -- coded within this procedure. It is important to note that any 3rd party
124 -- maintenance should be reviewed before placing in this procedure.
125 --
126 -- Access Status:
127 -- Internal Table Handler Use Only.
128 --
129 -- ----------------------------------------------------------------------------
130 Procedure pre_update(p_rec in ssp_ern_shd.g_rec_type) is
131 --
132 l_proc varchar2(72) := g_package||'pre_update';
133 --
134 Begin
135 hr_utility.set_location('Entering:'||l_proc, 1);
136 --
137 hr_utility.set_location('Leaving :'||l_proc, 100);
138 End pre_update;
139 --
140 -- ----------------------------------------------------------------------------
141 -- |-----------------------------< post_update >------------------------------|
142 -- ----------------------------------------------------------------------------
143 --
144 -- Description:
145 -- This private procedure contains any processing which is required after the
146 -- update dml.
147 --
148 -- Pre Conditions:
149 -- This is an internal procedure which is called from the upd procedure.
150 --
151 -- In Parameters:
152 -- A Pl/Sql record structre.
153 --
154 -- Post Success:
155 -- Processing continues.
156 --
157 -- Post Failure:
158 -- If an error has occurred, an error message and exception will be raised
159 -- but not handled.
160 --
161 -- Developer Implementation Notes:
162 -- Any post-processing required after 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 Table Handler Use Only.
168 --
169 -- ----------------------------------------------------------------------------
170 Procedure post_update(p_rec in ssp_ern_shd.g_rec_type) is
171 --
172 l_proc varchar2(72) := g_package||'post_update';
173 --
174 Begin
175 hr_utility.set_location('Entering:'||l_proc, 1);
176 --
177 hr_utility.set_location('Leaving :'||l_proc, 100);
178 End post_update;
179 --
180 -- ----------------------------------------------------------------------------
181 -- |-----------------------------< convert_defs >-----------------------------|
182 -- ----------------------------------------------------------------------------
183 --
184 -- Description:
185 -- The Convert_Defs procedure has one very important function:
186 -- It must return the record structure for the row with all system defaulted
187 -- values converted into its corresponding parameter value for update. When
188 -- we attempt to update a row through the Upd process , certain
189 -- parameters can be defaulted which enables flexibility in the calling of
190 -- the upd process (e.g. only attributes which need to be updated need to be
191 -- specified). For the upd process to determine which attributes
192 -- have NOT been specified we need to check if the parameter has a reserved
193 -- system default value. Therefore, for all parameters which have a
194 -- corresponding reserved system default mechanism specified we need to
195 -- check if a system default is being used. If a system default is being
196 -- used then we convert the defaulted value into its corresponding attribute
197 -- value held in the g_old_rec data structure.
198 --
199 -- Pre Conditions:
200 -- This private function can only be called from the upd process.
201 --
202 -- In Parameters:
203 -- A Pl/Sql record structre.
204 --
205 -- Post Success:
206 -- The record structure will be returned with all system defaulted parameter
207 -- values converted into its current row attribute value.
208 --
209 -- Post Failure:
210 -- No direct error handling is required within this function. Any possible
211 -- errors within this procedure will be a PL/SQL value error due to con 1304683version
212
213 -- of datatypes or data lengths.
214 --
215 -- Developer Implementation Notes:
216 -- None.
217 --
218 -- Access Status:
219 -- Internal Table Handler Use Only.
220 --
221 -- ----------------------------------------------------------------------------
222 Procedure convert_defs(p_rec in out nocopy ssp_ern_shd.g_rec_type) is
223 --
224 l_proc varchar2(72) := g_package||'convert_defs';
225 --
226 Begin
227 hr_utility.set_location('Entering:'||l_proc, 1);
228 --
229 -- We must now examine each argument value in the p_rec plsql record structure
230 -- to see if a system default is being used. If a system default is being used
231 -- then we must set to the 'current' argument value.
232 --
233 If (p_rec.person_id = hr_api.g_number) then
234 p_rec.person_id := ssp_ern_shd.g_old_rec.person_id;
235 End If;
236 If (p_rec.effective_date = hr_api.g_date) then
237 p_rec.effective_date := ssp_ern_shd.g_old_rec.effective_date;
238 End If;
239 If (p_rec.average_earnings_amount = hr_api.g_number) then
240 p_rec.average_earnings_amount :=
241 ssp_ern_shd.g_old_rec.average_earnings_amount;
242 End If;
243 If (p_rec.user_entered = hr_api.g_varchar2) then
244 p_rec.user_entered := ssp_ern_shd.g_old_rec.user_entered;
245 End If;
246 --
247 hr_utility.set_location('Leaving :'||l_proc, 100);
248 --
249 End convert_defs;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |---------------------------------< upd >----------------------------------|
253 -- ----------------------------------------------------------------------------
254 --
255 Procedure upd
256 (
257 p_rec in out nocopy ssp_ern_shd.g_rec_type,
258 p_validate in boolean default false
259 ) is
260 --
261 l_proc varchar2(72) := g_package||'upd';
262 --
263 Begin
264 hr_utility.set_location('Entering:'||l_proc, 1);
265 --
266 -- Determine if the business process is to be validated.
267 --
268 If p_validate then
269 --
270 -- Issue the savepoint.
271 --
272 SAVEPOINT upd_ssp_ern;
273 End If;
274 --
275 -- We must lock the row which we need to update.
276 --
277 ssp_ern_shd.lck
278 (
279 p_rec.earnings_calculations_id,
280 p_rec.object_version_number
281 );
282 --
283 -- 1. During an update system defaults are used to determine if
284 -- arguments have been defaulted or not. We must therefore
285 -- derive the full record structure values to be updated.
286 --
287 -- 2. Call the supporting update validate operations.
288 --
289 convert_defs(p_rec);
290 ssp_ern_bus.update_validate(p_rec);
291 --
292 -- Call the supporting pre-update operation if p_rec.average_earnings_amount
293 -- is not null
294 --
295 if p_rec.average_earnings_amount is not null then
296 pre_update(p_rec);
297 --
298 -- Update the row.
299 --
300 update_dml(p_rec);
301 --
302 -- Call the supporting post-update operation
303 --
304 post_update(p_rec);
305 end if;
306 --
307 -- If we are validating then raise the Validate_Enabled exception
308 --
309 If p_validate then
310 Raise HR_Api.Validate_Enabled;
311 End If;
312 --
313 hr_utility.set_location('Leaving :'||l_proc, 100);
314 Exception
315 When HR_Api.Validate_Enabled Then
316 --
317 -- As the Validate_Enabled exception has been raised
318 -- we must rollback to the savepoint
319 --
320 ROLLBACK TO upd_ssp_ern;
321 End upd;
322 --
323 -- ----------------------------------------------------------------------------
324 -- ----------------------------------< upd >-----------------------------------
325 -- ----------------------------------------------------------------------------
326 --
327 -- Old version used to be called from SSPWSENT, left if called
328 -- from anywhere else.
329 --
330 Procedure upd
331 (
332 p_earnings_calculations_id in number,
333 p_object_version_number in out nocopy number,
334 p_average_earnings_amount in out nocopy number ,
335 p_validate in boolean default false
336 ) is
337 --
338 l_rec ssp_ern_shd.g_rec_type;
339 l_proc varchar2(72) := g_package||'upd (old)';
340 --
341 Begin
342 hr_utility.set_location('Entering:'||l_proc, 1);
343 --
344 -- Call conversion function to turn arguments into the l_rec structure.
345 --
346 l_rec := ssp_ern_shd.convert_args (p_earnings_calculations_id,
347 p_object_version_number,
348 hr_api.g_number,
349 hr_api.g_date,
350 p_average_earnings_amount,
351 hr_api.g_varchar2,
352 'S', -- DFoster 1304683 Default to sickness
353 NULL);
354 --
355 -- Having converted the arguments into the plsql record structure we call
356 -- the corresponding record business process.
357 --
358 upd(l_rec, p_validate);
359 p_object_version_number := l_rec.object_version_number;
360 --
361 p_average_earnings_amount := l_rec.average_earnings_amount;
362 --
363 hr_utility.set_location('Leaving :'||l_proc, 100);
364 End upd;
365 --
366 -- ----------------------------------------------------------------------------
367 -- ----------------------------------< upd >-----------------------------------
368 -- ----------------------------------------------------------------------------
369 --
370 -- New version called from SSPWSENT, with user_entered and payment periods for
371 -- update.
372 --
373 Procedure upd
374 (
375 p_earnings_calculations_id in number,
376 p_object_version_number in out nocopy number,
377 p_average_earnings_amount in out nocopy number,
378 p_user_entered in out nocopy varchar2,
379 p_absence_category in out nocopy varchar2, --DFoster 1304683
380 p_payment_periods in out nocopy number,
381 p_validate in boolean default false
382 ) is
383 --
384 l_rec ssp_ern_shd.g_rec_type;
385 l_proc varchar2(72) := g_package||'upd';
386 --
387 Begin
388 hr_utility.set_location('Entering:'||l_proc, 1);
389 --
390 -- Call conversion function to turn arguments into the l_rec structure.
391 --
392 l_rec := ssp_ern_shd.convert_args (p_earnings_calculations_id,
393 p_object_version_number,
394 hr_api.g_number,
395 hr_api.g_date,
396 p_average_earnings_amount,
397 p_user_entered,
398 p_absence_category, --DFoster 1304683
399 p_payment_periods);
400 --
401 -- Having converted the arguments into the plsql record structure we call
402 -- the corresponding record business process.
403 --
404 upd(l_rec, p_validate);
405 --
406 p_object_version_number := l_rec.object_version_number;
407 p_average_earnings_amount := l_rec.average_earnings_amount;
408 p_payment_periods := l_rec.payment_periods;
409 --
410 hr_utility.set_location('Leaving :'||l_proc, 100);
411 End upd;
412 --
413 end ssp_ern_upd;