DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HAD_UPD

Source


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