1 Package Body pay_bct_upd as
2 /* $Header: pybctrhi.pkb 120.0.12000000.4 2007/08/20 08:21:49 ayegappa noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_bct_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_bct_shd.g_rec_type
56 ) is
57 --
58 l_proc varchar2(72) := g_package||'update_dml';
59 l_range_flag varchar2(2) := 'F';
60 l_control_total_dup1 pay_batch_control_totals.control_total%TYPE;
61 --
62 Begin
63 hr_utility.set_location('Entering:'||l_proc, 5);
64 --
65 -- Increment the object version
66 p_rec.object_version_number := p_rec.object_version_number + 1;
67 --
68 pay_bct_shd.g_api_dml := true; -- Set the api dml status
69 --
70 -- added for bug 6013383
71 -- convert the Number format from Display format( 99,999.99 OR 99.999,99) to
72 -- database format (99999.99)
73 --
74 hr_utility.set_location('Converting Control total from display format to database format: ' ||l_proc,6) ;
75 --
76 l_control_total_dup1 := p_rec.control_total;
77
78
79 hr_chkfmt.checkformat (p_rec.control_total ,
80 'NUMBER' ,
81 l_control_total_dup1,
82 null ,
83 null ,
84 'N' ,
85 l_range_flag,
86 null );
87 p_rec.control_total := l_control_total_dup1;
88 --
89 -- Update the pay_batch_control_totals Row
90
91 update pay_batch_control_totals
92 set
93 batch_control_id = p_rec.batch_control_id
94 ,control_status = p_rec.control_status
95 ,control_total = p_rec.control_total
96 ,control_type = p_rec.control_type
97 ,object_version_number = p_rec.object_version_number
98 where batch_control_id = p_rec.batch_control_id;
99 --
100 pay_bct_shd.g_api_dml := false; -- Unset the api dml status
101 --
102 hr_utility.set_location(' Leaving:'||l_proc, 10);
103 --
104 Exception
105 When hr_api.check_integrity_violated Then
106 -- A check constraint has been violated
107 pay_bct_shd.g_api_dml := false; -- Unset the api dml status
108 pay_bct_shd.constraint_error
109 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110 When hr_api.parent_integrity_violated Then
111 -- Parent integrity has been violated
112 pay_bct_shd.g_api_dml := false; -- Unset the api dml status
113 pay_bct_shd.constraint_error
114 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
115 When hr_api.unique_integrity_violated Then
116 -- Unique integrity has been violated
117 pay_bct_shd.g_api_dml := false; -- Unset the api dml status
118 pay_bct_shd.constraint_error
119 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120 When Others Then
121 pay_bct_shd.g_api_dml := false; -- Unset the api dml status
122 Raise;
123 End update_dml;
124 --
125 -- ----------------------------------------------------------------------------
126 -- |------------------------------< pre_update >------------------------------|
127 -- ----------------------------------------------------------------------------
128 -- {Start Of Comments}
129 --
130 -- Description:
131 -- This private procedure contains any processing which is required before
132 -- the update dml.
133 --
134 -- Prerequisites:
135 -- This is an internal procedure which is called from the upd procedure.
136 --
137 -- In Parameters:
138 -- A Pl/Sql record structure.
139 --
140 -- Post Success:
141 -- Processing continues.
142 --
143 -- Post Failure:
144 -- If an error has occurred, an error message and exception wil be raised
145 -- but not handled.
146 --
147 -- Developer Implementation Notes:
148 -- Any pre-processing required before the update dml is issued should be
149 -- coded within this procedure. It is important to note that any 3rd party
150 -- maintenance should be reviewed before placing in this procedure.
151 --
152 -- Access Status:
153 -- Internal Row Handler Use Only.
154 --
155 -- {End Of Comments}
156 -- ----------------------------------------------------------------------------
157 Procedure pre_update
158 (p_rec in pay_bct_shd.g_rec_type
159 ) is
160 --
161 l_proc varchar2(72) := g_package||'pre_update';
162 --
163 Begin
164 hr_utility.set_location('Entering:'||l_proc, 5);
165 --
166 hr_utility.set_location(' Leaving:'||l_proc, 10);
167 End pre_update;
168 --
169 -- ----------------------------------------------------------------------------
170 -- |-----------------------------< post_update >------------------------------|
171 -- ----------------------------------------------------------------------------
172 -- {Start Of Comments}
173 --
174 -- Description:
175 -- This private procedure contains any processing which is required after the
176 -- update dml.
177 --
178 -- Prerequisites:
179 -- This is an internal procedure which is called from the upd procedure.
180 --
181 -- In Parameters:
182 -- A Pl/Sql record structure.
183 --
184 -- Post Success:
185 -- Processing continues.
186 --
187 -- Post Failure:
188 -- If an error has occurred, an error message and exception will be raised
189 -- but not handled.
190 --
191 -- Developer Implementation Notes:
192 -- Any post-processing required after the update dml is issued should be
193 -- coded within this procedure. It is important to note that any 3rd party
194 -- maintenance should be reviewed before placing in this procedure.
195 --
196 -- Access Status:
197 -- Internal Row Handler Use Only.
198 --
199 -- {End Of Comments}
200 -- ----------------------------------------------------------------------------
201 Procedure post_update
202 (p_session_date in date
203 ,p_rec in pay_bct_shd.g_rec_type
204 ) is
205 --
206 l_proc varchar2(72) := g_package||'post_update';
207 --
208 Begin
209 hr_utility.set_location('Entering:'||l_proc, 5);
210 begin
211 --
212 pay_bct_rku.after_update
213 (p_session_date
214 => p_session_date
215 ,p_batch_control_id
216 => p_rec.batch_control_id
217 ,p_control_status
218 => p_rec.control_status
219 ,p_control_total
220 => p_rec.control_total
221 ,p_control_type
222 => p_rec.control_type
223 ,p_object_version_number
224 => p_rec.object_version_number
225 ,p_batch_id_o
226 => pay_bct_shd.g_old_rec.batch_id
227 ,p_control_status_o
228 => pay_bct_shd.g_old_rec.control_status
229 ,p_control_total_o
230 => pay_bct_shd.g_old_rec.control_total
231 ,p_control_type_o
232 => pay_bct_shd.g_old_rec.control_type
233 ,p_object_version_number_o
234 => pay_bct_shd.g_old_rec.object_version_number
235 );
236 --
237 exception
238 --
239 when hr_api.cannot_find_prog_unit then
240 --
241 hr_api.cannot_find_prog_unit_error
242 (p_module_name => 'PAY_BATCH_CONTROL_TOTALS'
243 ,p_hook_type => 'AU');
244 --
245 end;
246 --
247 hr_utility.set_location(' Leaving:'||l_proc, 10);
248 End post_update;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |-----------------------------< convert_defs >-----------------------------|
252 -- ----------------------------------------------------------------------------
253 -- {Start Of Comments}
254 --
255 -- Description:
256 -- The Convert_Defs procedure has one very important function:
257 -- It must return the record structure for the row with all system defaulted
258 -- values converted into its corresponding parameter value for update. When
259 -- we attempt to update a row through the Upd process , certain
260 -- parameters can be defaulted which enables flexibility in the calling of
261 -- the upd process (e.g. only attributes which need to be updated need to be
262 -- specified). For the upd process to determine which attributes
263 -- have NOT been specified we need to check if the parameter has a reserved
264 -- system default value. Therefore, for all parameters which have a
265 -- corresponding reserved system default mechanism specified we need to
266 -- check if a system default is being used. If a system default is being
267 -- used then we convert the defaulted value into its corresponding attribute
268 -- value held in the g_old_rec data structure.
269 --
270 -- Prerequisites:
271 -- This private function can only be called from the upd process.
272 --
273 -- In Parameters:
274 -- A Pl/Sql record structure.
275 --
276 -- Post Success:
277 -- The record structure will be returned with all system defaulted parameter
278 -- values converted into its current row attribute value.
279 --
280 -- Post Failure:
281 -- No direct error handling is required within this function. Any possible
282 -- errors within this procedure will be a PL/SQL value error due to
283 -- conversion of datatypes or data lengths.
284 --
285 -- Developer Implementation Notes:
286 -- None.
287 --
288 -- Access Status:
289 -- Internal Row Handler Use Only.
290 --
291 -- {End Of Comments}
292 -- ----------------------------------------------------------------------------
293 Procedure convert_defs
294 (p_rec in out nocopy pay_bct_shd.g_rec_type
295 ) is
296 --
297 Begin
298 --
299 -- We must now examine each argument value in the
300 -- p_rec plsql record structure
301 -- to see if a system default is being used. If a system default
302 -- is being used then we must set to the 'current' argument value.
303 --
304 If (p_rec.batch_id = hr_api.g_number) then
305 p_rec.batch_id :=
306 pay_bct_shd.g_old_rec.batch_id;
307 End If;
308 If (p_rec.control_status = hr_api.g_varchar2) then
309 p_rec.control_status :=
310 pay_bct_shd.g_old_rec.control_status;
311 End If;
312 If (p_rec.control_total = hr_api.g_varchar2) then
313 p_rec.control_total :=
314 pay_bct_shd.g_old_rec.control_total;
315 End If;
316 If (p_rec.control_type = hr_api.g_varchar2) then
317 p_rec.control_type :=
318 pay_bct_shd.g_old_rec.control_type;
319 End If;
320 --
321 End convert_defs;
322 --
323 -- ----------------------------------------------------------------------------
324 -- |---------------------------------< upd >----------------------------------|
325 -- ----------------------------------------------------------------------------
326 Procedure upd
327 (p_session_date in date
328 ,p_rec in out nocopy pay_bct_shd.g_rec_type
329 ) is
330 --
331 l_proc varchar2(72) := g_package||'upd';
332 --
333 Begin
334 hr_utility.set_location('Entering:'||l_proc, 5);
335 --
336 -- We must lock the row which we need to update.
337 --
338 pay_bct_shd.lck
339 (p_rec.batch_control_id
340 ,p_rec.object_version_number
341 );
342 --
343 -- 1. During an update system defaults are used to determine if
344 -- arguments have been defaulted or not. We must therefore
345 -- derive the full record structure values to be updated.
346 --
347 -- 2. Call the supporting update validate operations.
348 --
349 convert_defs(p_rec);
350 pay_bct_bus.update_validate
351 (p_session_date,
352 p_rec
353 );
354 --
355 -- Call the supporting pre-update operation
356 --
357 pay_bct_upd.pre_update(p_rec);
358 --
359 -- Update the row.
360 --
361 pay_bct_upd.update_dml(p_rec);
362 --
363 -- Call the supporting post-update operation
364 --
365 pay_bct_upd.post_update
366 (p_session_date
367 ,p_rec
368 );
369 End upd;
370 --
371 -- ----------------------------------------------------------------------------
372 -- |---------------------------------< upd >----------------------------------|
373 -- ----------------------------------------------------------------------------
374 Procedure upd
375 (p_session_date in date
376 ,p_batch_control_id in number
377 ,p_object_version_number in out nocopy number
378 ,p_control_status in varchar2 default hr_api.g_varchar2
379 ,p_control_total in varchar2 default hr_api.g_varchar2
380 ,p_control_type in varchar2 default hr_api.g_varchar2
381 ) is
382 --
383 l_rec pay_bct_shd.g_rec_type;
384 l_proc varchar2(72) := g_package||'upd';
385 --
386 Begin
387 hr_utility.set_location('Entering:'||l_proc, 5);
388 --
389 -- Call conversion function to turn arguments into the
390 -- l_rec structure.
391 --
392 l_rec :=
393 pay_bct_shd.convert_args
394 (p_batch_control_id
395 ,hr_api.g_number
396 ,p_control_status
397 ,p_control_total
398 ,p_control_type
399 ,p_object_version_number
400 );
401 --
402 -- Having converted the arguments into the
403 -- plsql record structure we call the corresponding record
404 -- business process.
405 --
406 pay_bct_upd.upd
407 (p_session_date,
408 l_rec
409 );
410 p_object_version_number := l_rec.object_version_number;
411 --
412 hr_utility.set_location(' Leaving:'||l_proc, 10);
413 End upd;
414 --
415 end pay_bct_upd;