DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HRP_UPD

Source


1 Package Body hxc_hrp_upd as
2 /* $Header: hxchrprhi.pkb 120.2 2005/09/23 10:43:21 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hxc_hrp_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_hrp_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   --
71   --
72   -- Update the hxc_recurring_periods Row
73   --
74   update hxc_recurring_periods
75     set
76      recurring_period_id             = p_rec.recurring_period_id
77     ,name                            = p_rec.name
78     ,start_date                      = p_rec.start_date
79     ,end_date                        = p_rec.end_date
80     ,period_type                     = p_rec.period_type
81     ,duration_in_days                = p_rec.duration_in_days
82     ,object_version_number           = p_rec.object_version_number
83         ,last_updated_by		     = fnd_global.user_id
84     ,last_update_date		     = sysdate
85     ,last_update_login	             = fnd_global.login_id
86 
87     where recurring_period_id = p_rec.recurring_period_id;
88   --
89   --
90   --
91   if g_debug then
92 	hr_utility.set_location(' Leaving:'||l_proc, 10);
93   end if;
94 --
95 Exception
96   When hr_api.check_integrity_violated Then
97     -- A check constraint has been violated
98     --
99     hxc_hrp_shd.constraint_error
100       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
101   When hr_api.parent_integrity_violated Then
102     -- Parent integrity has been violated
103     --
104     hxc_hrp_shd.constraint_error
105       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106   When hr_api.unique_integrity_violated Then
107     -- Unique integrity has been violated
108     --
109     hxc_hrp_shd.constraint_error
110       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
111   When Others Then
112     --
113     Raise;
114 End update_dml;
115 --
116 -- ----------------------------------------------------------------------------
117 -- |------------------------------< pre_update >------------------------------|
118 -- ----------------------------------------------------------------------------
119 -- {Start Of Comments}
120 --
121 -- Description:
122 --   This private procedure contains any processing which is required before
123 --   the update dml.
124 --
125 -- Prerequisites:
126 --   This is an internal procedure which is called from the upd procedure.
127 --
128 -- In Parameters:
129 --   A Pl/Sql record structure.
130 --
131 -- Post Success:
132 --   Processing continues.
133 --
134 -- Post Failure:
135 --   If an error has occurred, an error message and exception wil be raised
136 --   but not handled.
137 --
138 -- Developer Implementation Notes:
139 --   Any pre-processing required before the update dml is issued should be
140 --   coded within this procedure. It is important to note that any 3rd party
141 --   maintenance should be reviewed before placing in this procedure.
142 --
143 -- Access Status:
144 --   Internal Row Handler Use Only.
145 --
146 -- {End Of Comments}
147 -- ----------------------------------------------------------------------------
148 Procedure pre_update
149   (p_rec in hxc_hrp_shd.g_rec_type
150   ) is
151 --
152   l_proc  varchar2(72);
153 --
154 Begin
155   if g_debug then
156 	l_proc := g_package||'pre_update';
157 	hr_utility.set_location('Entering:'||l_proc, 5);
158 	--
159 	hr_utility.set_location(' Leaving:'||l_proc, 10);
160   end if;
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 structure.
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
197   ,p_rec                          in hxc_hrp_shd.g_rec_type
198   ) is
199 --
200   l_proc  varchar2(72);
201 --
202 Begin
203   if g_debug then
204 	l_proc := g_package||'post_update';
205 	hr_utility.set_location('Entering:'||l_proc, 5);
206   end if;
207   begin
208     --
209     hxc_hrp_rku.after_update
210       (p_effective_date              => p_effective_date
211       ,p_recurring_period_id
212       => p_rec.recurring_period_id
213       ,p_name
214       => p_rec.name
215       ,p_start_date
216       => p_rec.start_date
217       ,p_end_date
218       => p_rec.end_date
219       ,p_period_type
220       => p_rec.period_type
221       ,p_duration_in_days
222       => p_rec.duration_in_days
223       ,p_object_version_number
224       => p_rec.object_version_number
225       ,p_name_o
226       => hxc_hrp_shd.g_old_rec.name
227       ,p_start_date_o
228       => hxc_hrp_shd.g_old_rec.start_date
229       ,p_end_date_o
230       => hxc_hrp_shd.g_old_rec.end_date
231       ,p_period_type_o
232       => hxc_hrp_shd.g_old_rec.period_type
233       ,p_duration_in_days_o
234       => hxc_hrp_shd.g_old_rec.duration_in_days
235       ,p_object_version_number_o
236       => hxc_hrp_shd.g_old_rec.object_version_number
237       );
238     --
239   exception
240     --
241     when hr_api.cannot_find_prog_unit then
242       --
243       hr_api.cannot_find_prog_unit_error
244         (p_module_name => 'HXC_RECURRING_PERIODS'
245         ,p_hook_type   => 'AU');
246       --
247   end;
248   --
249   if g_debug then
250 	hr_utility.set_location(' Leaving:'||l_proc, 10);
251   end if;
252 End post_update;
253 --
254 -- ----------------------------------------------------------------------------
255 -- |-----------------------------< convert_defs >-----------------------------|
256 -- ----------------------------------------------------------------------------
257 -- {Start Of Comments}
258 --
259 -- Description:
260 --   The Convert_Defs procedure has one very important function:
261 --   It must return the record structure for the row with all system defaulted
262 --   values converted into its corresponding parameter value for update. When
263 --   we attempt to update a row through the Upd process , certain
264 --   parameters can be defaulted which enables flexibility in the calling of
265 --   the upd process (e.g. only attributes which need to be updated need to be
266 --   specified). For the upd process to determine which attributes
267 --   have NOT been specified we need to check if the parameter has a reserved
268 --   system default value. Therefore, for all parameters which have a
269 --   corresponding reserved system default mechanism specified we need to
270 --   check if a system default is being used. If a system default is being
271 --   used then we convert the defaulted value into its corresponding attribute
272 --   value held in the g_old_rec data structure.
273 --
274 -- Prerequisites:
275 --   This private function can only be called from the upd process.
276 --
277 -- In Parameters:
278 --   A Pl/Sql record structure.
279 --
280 -- Post Success:
281 --   The record structure will be returned with all system defaulted parameter
282 --   values converted into its current row attribute value.
283 --
284 -- Post Failure:
285 --   No direct error handling is required within this function. Any possible
286 --   errors within this procedure will be a PL/SQL value error due to
287 --   conversion of datatypes or data lengths.
288 --
289 -- Developer Implementation Notes:
290 --   None.
291 --
292 -- Access Status:
293 --   Internal Row Handler Use Only.
294 --
295 -- {End Of Comments}
296 -- ----------------------------------------------------------------------------
297 Procedure convert_defs
298   (p_rec in out nocopy hxc_hrp_shd.g_rec_type
299   ) is
300 --
301 Begin
302   --
303   -- We must now examine each argument value in the
304   -- p_rec plsql record structure
305   -- to see if a system default is being used. If a system default
306   -- is being used then we must set to the 'current' argument value.
307   --
308   If (p_rec.name = hr_api.g_varchar2) then
309     p_rec.name :=
310     hxc_hrp_shd.g_old_rec.name;
311   End If;
312   If (p_rec.start_date = hr_api.g_date) then
313     p_rec.start_date :=
314     hxc_hrp_shd.g_old_rec.start_date;
315   End If;
316   If (p_rec.end_date = hr_api.g_date) then
317     p_rec.end_date :=
318     hxc_hrp_shd.g_old_rec.end_date;
319   End If;
320   If (p_rec.period_type = hr_api.g_varchar2) then
321     p_rec.period_type :=
322     hxc_hrp_shd.g_old_rec.period_type;
323   End If;
324   If (p_rec.duration_in_days = hr_api.g_number) then
325     p_rec.duration_in_days :=
326     hxc_hrp_shd.g_old_rec.duration_in_days;
327   End If;
328   --
329 End convert_defs;
330 --
331 -- ----------------------------------------------------------------------------
332 -- |---------------------------------< upd >----------------------------------|
333 -- ----------------------------------------------------------------------------
334 Procedure upd
335   (p_effective_date               in date
336   ,p_rec                          in out nocopy hxc_hrp_shd.g_rec_type
337   ) is
338 --
339   l_proc  varchar2(72);
340 --
341 Begin
342   g_debug:=hr_utility.debug_enabled;
343   if g_debug then
344 	l_proc := g_package||'upd';
345 	hr_utility.set_location('Entering:'||l_proc, 5);
346   end if;
347   --
348   -- We must lock the row which we need to update.
349   --
350   hxc_hrp_shd.lck
351     (p_rec.recurring_period_id
352     ,p_rec.object_version_number
353     );
354   --
355   -- 1. During an update system defaults are used to determine if
356   --    arguments have been defaulted or not. We must therefore
357   --    derive the full record structure values to be updated.
358   --
359   -- 2. Call the supporting update validate operations.
360   --
361   convert_defs(p_rec);
362   hxc_hrp_bus.update_validate
363      (p_effective_date
364      ,p_rec
365      );
366   --
367   -- Call the supporting pre-update operation
368   --
369   hxc_hrp_upd.pre_update(p_rec);
370   --
371   -- Update the row.
372   --
373   hxc_hrp_upd.update_dml(p_rec);
374   --
375   -- Call the supporting post-update operation
376   --
377   hxc_hrp_upd.post_update
378      (p_effective_date
379      ,p_rec
380      );
381 End upd;
382 --
383 -- ----------------------------------------------------------------------------
384 -- |---------------------------------< upd >----------------------------------|
385 -- ----------------------------------------------------------------------------
386 Procedure upd
387   (p_effective_date               in     date
388   ,p_recurring_period_id          in     number
389   ,p_object_version_number        in out nocopy number
390   ,p_name                         in     varchar2  default hr_api.g_varchar2
391   ,p_start_date                   in     date      default hr_api.g_date
392   ,p_end_date                     in     date      default hr_api.g_date
393   ,p_period_type                  in     varchar2  default hr_api.g_varchar2
394   ,p_duration_in_days             in     number    default hr_api.g_number
395   ) is
396 --
397   l_rec	  hxc_hrp_shd.g_rec_type;
398   l_proc  varchar2(72);
399 --
400 Begin
401   g_debug:=hr_utility.debug_enabled;
402   if g_debug then
403 	l_proc := g_package||'upd';
404 	hr_utility.set_location('Entering:'||l_proc, 5);
405   end if;
406   --
407   -- Call conversion function to turn arguments into the
408   -- l_rec structure.
409   --
410   l_rec :=
411   hxc_hrp_shd.convert_args
412   (p_recurring_period_id
413   ,p_name
414   ,p_start_date
415   ,p_end_date
416   ,p_period_type
417   ,p_duration_in_days
418   ,p_object_version_number
419   );
420   --
421   -- Having converted the arguments into the
422   -- plsql record structure we call the corresponding record
423   -- business process.
424   --
425   hxc_hrp_upd.upd
426      (p_effective_date
427      ,l_rec
428      );
429   p_object_version_number := l_rec.object_version_number;
430   --
431   if g_debug then
432 	hr_utility.set_location(' Leaving:'||l_proc, 10);
433   end if;
434 End upd;
435 --
436 end hxc_hrp_upd;