DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_MAN_UPD

Source


1 Package Body ame_man_upd as
2 /* $Header: ammanrhi.pkb 120.5 2005/11/22 03:18 santosin noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ame_man_upd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |----------------------------< dt_update_dml >-----------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the execution of dml from the datetrack mode
17 --   of CORRECTION only. It is important to note that the object version
18 --   number is only increment by 1 because the datetrack correction is
19 --   soley for one datetracked row.
20 --   This procedure controls the actual dml update logic. The functions of
21 --   this procedure are as follows:
22 --   1) Get the next object_version_number.
23 --   2) To set and unset the g_api_dml status as required (as we are about to
24 --      perform dml).
25 --   3) To update the specified row in the schema using the primary key in
26 --      the predicates.
27 --   4) To trap any constraint violations that may have occurred.
28 --   5) To raise any other errors.
29 --
30 -- Prerequisites:
31 --   This is an internal private procedure which must be called from the
32 --   update_dml procedure.
33 --
34 -- In Parameters:
35 --   A Pl/Sql record structure.
36 --
37 -- Post Success:
38 --   The specified row will be updated in the schema.
39 --
40 -- Post Failure:
41 --   On the update dml failure it is important to note that we always reset the
42 --   g_api_dml status to false.
43 --   If a check or unique integrity constraint violation is raised the
44 --   constraint_error procedure will be called.
45 --   If any other error is reported, the error will be raised after the
46 --   g_api_dml status is reset.
47 --
48 -- Developer Implementation Notes:
49 --   The update 'set' arguments list should be modified if any of your
50 --   attributes are not updateable.
51 --
52 -- Access Status:
53 --   Internal Row Handler Use Only.
54 --
55 -- {End Of Comments}
56 -- ----------------------------------------------------------------------------
57 Procedure dt_update_dml
58   (p_rec                   in out nocopy ame_man_shd.g_rec_type
59   ,p_effective_date        in date
60   ,p_datetrack_mode        in varchar2
61   ,p_validation_start_date in date
62   ,p_validation_end_date   in date
63   ) is
64 --
65   l_proc        varchar2(72) := g_package||'dt_update_dml';
66 --
67 Begin
68   hr_utility.set_location('Entering:'||l_proc, 5);
69   --
70   If (p_datetrack_mode = hr_api.g_correction) then
71     hr_utility.set_location(l_proc, 10);
72     --
73     -- Because we are updating a row we must get the next object
74     -- version number.
75     --
76     p_rec.object_version_number :=
77      ame_man_shd.get_object_version_number
78         (p_attribute_id =>  p_rec.attribute_id
79  ,p_action_type_id =>  p_rec.action_type_id
80       );
81     --
82     --
83     --
84     -- Update the ame_mandatory_attributes Row
85     --
86     update  ame_mandatory_attributes
87     set
88      attribute_id                         = p_rec.attribute_id
89     ,action_type_id                       = p_rec.action_type_id
90     ,security_group_id                    = p_rec.security_group_id
91     ,object_version_number                = p_rec.object_version_number
92     where   attribute_id  =   p_rec.attribute_id
93   and action_type_id  =   p_rec.action_type_id
94     and     start_date = p_validation_start_date
95     and    ((p_validation_end_date is null and end_date is null) or
96               (end_date  = p_validation_end_date));
97     --
98     --
99     --
100     -- Set the effective start and end dates
101     --
102     p_rec.start_date := p_validation_start_date;
103     p_rec.end_date   := p_validation_end_date;
104   End If;
105 --
106 hr_utility.set_location(' Leaving:'||l_proc, 15);
107 Exception
108   When hr_api.check_integrity_violated Then
109     -- A check constraint has been violated
110     --
111     ame_man_shd.constraint_error
112       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
113   When hr_api.unique_integrity_violated Then
114     -- Unique integrity has been violated
115     --
116     ame_man_shd.constraint_error
117       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
118   When Others Then
119     --
120     Raise;
121 End dt_update_dml;
122 --
123 -- ----------------------------------------------------------------------------
124 -- |------------------------------< update_dml >------------------------------|
125 -- ----------------------------------------------------------------------------
126 -- {Start Of Comments}
127 --
128 -- Description:
129 --   This procedure calls the dt_update_dml control logic which handles
130 --   the actual datetrack dml.
131 --
132 -- Prerequisites:
133 --   This is an internal private procedure which must be called from the upd
134 --   procedure.
135 --
136 -- In Parameters:
137 --   A Pl/Sql record structre.
138 --
139 -- Post Success:
140 --   Processing contines.
141 --
142 -- Post Failure:
143 --   No specific error handling is required within this procedure.
144 --
145 -- Developer Implementation Notes:
146 --   The update 'set' arguments list should be modified if any of your
147 --   attributes are not updateable.
148 --
149 -- Access Status:
150 --   Internal Row Handler Use Only.
151 --
152 -- {End Of Comments}
153 -- ----------------------------------------------------------------------------
154 Procedure update_dml
155   (p_rec                      in out nocopy ame_man_shd.g_rec_type
156   ,p_effective_date           in date
157   ,p_datetrack_mode           in varchar2
158   ,p_validation_start_date    in date
159   ,p_validation_end_date      in date
160   ) is
161 --
162   l_proc        varchar2(72) := g_package||'update_dml';
163 --
164 Begin
165   hr_utility.set_location('Entering:'||l_proc, 5);
166   --
167   ame_man_upd.dt_update_dml
168     (p_rec                   => p_rec
169     ,p_effective_date        => p_effective_date
170     ,p_datetrack_mode        => p_datetrack_mode
171     ,p_validation_start_date => p_validation_start_date
172     ,p_validation_end_date   => p_validation_end_date
173     );
174   --
175   hr_utility.set_location(' Leaving:'||l_proc, 10);
176 End update_dml;
177 --
178 -- ----------------------------------------------------------------------------
179 -- |----------------------------< dt_pre_update >-----------------------------|
180 -- ----------------------------------------------------------------------------
181 -- {Start Of Comments}
182 --
183 -- Description:
184 --   The dt_pre_update procedure controls the execution
185 --   of dml for the datetrack modes of: UPDATE, UPDATE_OVERRIDE
186 --   and UPDATE_CHANGE_INSERT only. The execution required is as
187 --   follows:
188 --
189 --   1) Providing the datetrack update mode is not 'CORRECTION'
190 --      then set the effective end date of the current row (this
191 --      will be the validation_start_date - 1).
192 --   2) If the datetrack mode is 'UPDATE_OVERRIDE' then call the
193 --      corresponding delete_dml process to delete any future rows
194 --      where the effective_start_date is greater than or equal to
195 --      the validation_start_date.
196 --   3) Call the insert_dml process to insert the new updated row
197 --      details.
198 --
199 -- Prerequisites:
200 --   This is an internal procedure which is called from the
201 --   pre_update procedure.
202 --
203 -- In Parameters:
204 --
205 -- Post Success:
206 --   Processing continues.
207 --
208 -- Post Failure:
209 --   If an error has occurred, an error message and exception will be raised
210 --   but not handled.
211 --
212 -- Developer Implementation Notes:
213 --   This is an internal procedure which is required by Datetrack. Don't
214 --   remove or modify.
215 --
216 -- Access Status:
217 --   Internal Row Handler Use Only.
218 --
219 -- {End Of Comments}
220 -- ----------------------------------------------------------------------------
221 Procedure dt_pre_update
222   (p_rec                     in out  nocopy   ame_man_shd.g_rec_type
223   ,p_effective_date          in date
224   ,p_datetrack_mode          in varchar2
225   ,p_validation_start_date   in date
226   ,p_validation_end_date     in date
227   ) is
228 --
229   l_proc                 varchar2(72) := g_package||'dt_pre_update';
230   l_dummy_version_number number;
231 --
232 Begin
233   hr_utility.set_location('Entering:'||l_proc, 5);
234   If (p_datetrack_mode <> hr_api.g_correction) then
235     --
236     -- Update the current effective end date
237     --
238     ame_man_shd.upd_end_date
239       (p_effective_date         => p_effective_date
240       ,p_attribute_id =>  p_rec.attribute_id
241  ,p_action_type_id =>  p_rec.action_type_id
242       ,p_new_end_date => p_validation_start_date
243       ,p_validation_start_date  => p_validation_start_date
244       ,p_validation_end_date    => p_validation_end_date
245       ,p_object_version_number  => l_dummy_version_number
246       );
247     --
248     If (p_datetrack_mode = hr_api.g_update_override) then
249       --
250       -- As the datetrack mode is 'UPDATE_OVERRIDE' then we must
251       -- delete any future rows
252       --
253       ame_man_del.delete_dml
254         (p_rec                   => p_rec
255         ,p_effective_date        => p_effective_date
256         ,p_datetrack_mode        => p_datetrack_mode
257         ,p_validation_start_date => p_validation_start_date
258         ,p_validation_end_date   => p_validation_end_date
259         );
260     End If;
261     --
262     -- We must now insert the updated row
263     --
264     ame_man_ins.insert_dml
265       (p_rec                    => p_rec
266       ,p_effective_date         => p_effective_date
267       ,p_datetrack_mode         => p_datetrack_mode
268       ,p_validation_start_date  => p_validation_start_date
269       ,p_validation_end_date    => p_validation_end_date
270       );
271   End If;
272   hr_utility.set_location(' Leaving:'||l_proc, 20);
273 End dt_pre_update;
274 --
275 -- ----------------------------------------------------------------------------
276 -- |------------------------------< pre_update >------------------------------|
277 -- ----------------------------------------------------------------------------
278 -- {Start Of Comments}
279 --
280 -- Description:
281 --   This private procedure contains any processing which is required before
282 --   the update dml.
283 --
284 -- Prerequisites:
285 --   This is an internal procedure which is called from the upd procedure.
286 --
287 -- In Parameters:
288 --   A Pl/Sql record structure.
289 --
290 -- Post Success:
291 --   Processing continues.
292 --
293 -- Post Failure:
294 --   If an error has occurred, an error message and exception will be raised
295 --   but not handled.
296 -- Developer Implementation Notes:
297 --   Any pre-processing required before the update dml is issued should be
298 --   coded within this procedure. It is important to note that any 3rd party
299 --   maintenance should be reviewed before placing in this procedure. The call
300 --   to the dt_update_dml procedure should NOT be removed.
301 --
302 -- Access Status:
303 --   Internal Row Handler Use Only.
304 --
305 -- {End Of Comments}
306 -- ----------------------------------------------------------------------------
307 Procedure pre_update
308   (p_rec                   in out nocopy ame_man_shd.g_rec_type
309   ,p_effective_date        in date
310   ,p_datetrack_mode        in varchar2
311   ,p_validation_start_date in date
312   ,p_validation_end_date   in date
313   ) is
314 --
315   l_proc        varchar2(72) := g_package||'pre_update';
316 --
317 Begin
318   hr_utility.set_location('Entering:'||l_proc, 5);
319   --
320   --
321   --
322   dt_pre_update
323     (p_rec                   => p_rec
324     ,p_effective_date        => p_effective_date
325     ,p_datetrack_mode        => p_datetrack_mode
326     ,p_validation_start_date => p_validation_start_date
327     ,p_validation_end_date   => p_validation_end_date
328     );
329   --
330   hr_utility.set_location(' Leaving:'||l_proc, 10);
331 End pre_update;
332 --
333 -- ----------------------------------------------------------------------------
334 -- |----------------------------< post_update >-------------------------------|
335 -- ----------------------------------------------------------------------------
336 -- {Start Of Comments}
337 --
338 -- Description:
339 --   This private procedure contains any processing which is required after
340 --   the update dml.
341 --
342 -- Prerequisites:
343 --   This is an internal procedure which is called from the upd procedure.
344 --
345 -- In Parameters:
346 --   A Pl/Sql record structure.
347 --
348 -- Post Success:
349 --   Processing continues.
350 --
351 -- Post Failure:
352 --   If an error has occurred, an error message and exception will be raised
353 --   but not handled.
354 --
355 -- Developer Implementation Notes:
356 --   Any post-processing required after the update dml is issued should be
357 --   coded within this procedure. It is important to note that any 3rd party
358 --   maintenance should be reviewed before placing in this procedure.
359 --
360 -- Access Status:
361 --   Internal Row Handler Use Only.
362 --
363 -- {End Of Comments}
364 -- ----------------------------------------------------------------------------
365 Procedure post_update
366   (p_rec                   in ame_man_shd.g_rec_type
367   ,p_effective_date        in date
368   ,p_datetrack_mode        in varchar2
369   ,p_validation_start_date in date
370   ,p_validation_end_date   in date
371   ) is
372 --
373   l_proc        varchar2(72) := g_package||'post_update';
374 --
375 Begin
376   hr_utility.set_location('Entering:'||l_proc, 5);
377   begin
378     --
379     ame_man_rku.after_update
380       (p_effective_date
381       => p_effective_date
382       ,p_datetrack_mode
383       => p_datetrack_mode
384       ,p_validation_start_date
385       => p_validation_start_date
386       ,p_validation_end_date
387       => p_validation_end_date
388       ,p_attribute_id
389       => p_rec.attribute_id
390       ,p_action_type_id
391       => p_rec.action_type_id
392       ,p_start_date
393       => p_rec.start_date
394       ,p_end_date
395       => p_rec.end_date
396       ,p_security_group_id
397       => p_rec.security_group_id
398       ,p_object_version_number
399       => p_rec.object_version_number
400       ,p_start_date_o
401       => ame_man_shd.g_old_rec.start_date
402       ,p_end_date_o
403       => ame_man_shd.g_old_rec.end_date
404       ,p_security_group_id_o
405       => ame_man_shd.g_old_rec.security_group_id
406       ,p_object_version_number_o
407       => ame_man_shd.g_old_rec.object_version_number
408       );
409     --
410   exception
411     --
412     when hr_api.cannot_find_prog_unit then
413       --
414       hr_api.cannot_find_prog_unit_error
415         (p_module_name => 'AME_MANDATORY_ATTRIBUTES'
416         ,p_hook_type   => 'AU');
417       --
418   end;
419   --
420   hr_utility.set_location(' Leaving:'||l_proc, 10);
421 End post_update;
422 --
423 -- ----------------------------------------------------------------------------
424 -- |-----------------------------< convert_defs >-----------------------------|
425 -- ----------------------------------------------------------------------------
426 -- {Start Of Comments}
427 --
428 -- Description:
429 --   The Convert_Defs procedure has one very important function:
430 --   It must return the record structure for the row with all system defaulted
431 --   values converted into its corresponding parameter value for update. When
432 --   we attempt to update a row through the Upd process , certain
433 --   parameters can be defaulted which enables flexibility in the calling of
434 --   the upd process (e.g. only attributes which need to be updated need to be
435 --   specified). For the upd process to determine which attributes
436 --   have NOT been specified we need to check if the parameter has a reserved
437 --   system default value. Therefore, for all parameters which have a
438 --   corresponding reserved system default mechanism specified we need to
439 --   check if a system default is being used. If a system default is being
440 --   used then we convert the defaulted value into its corresponding attribute
441 --   value held in the g_old_rec data structure.
442 --
443 -- Prerequisites:
444 --   This private function can only be called from the upd process.
445 --
446 -- In Parameters:
447 --   A Pl/Sql record structure.
448 --
449 -- Post Success:
450 --   The record structure will be returned with all system defaulted parameter
451 --   values converted into its current row attribute value.
452 --
453 -- Post Failure:
454 --   No direct error handling is required within this function. Any possible
455 --   errors within this procedure will be a PL/SQL value error due to
456 --   conversion of datatypes or data lengths.
457 --
458 -- Developer Implementation Notes:
459 --   None.
460 --
461 -- Access Status:
462 --   Internal Row Handler Use Only.
463 --
464 -- {End Of Comments}
465 -- ----------------------------------------------------------------------------
466 Procedure convert_defs
467   (p_rec in out nocopy ame_man_shd.g_rec_type
468   ) is
469 --
470 Begin
471   --
472   -- We must now examine each argument value in the
473   -- p_rec plsql record structure
474   -- to see if a system default is being used. If a system default
475   -- is being used then we must set to the 'current' argument value.
476   --
477   If (p_rec.security_group_id = hr_api.g_number) then
478     p_rec.security_group_id :=
479     ame_man_shd.g_old_rec.security_group_id;
480   End If;
481   --
482 End convert_defs;
483 --
484 -- ----------------------------------------------------------------------------
485 -- |---------------------------------< upd >----------------------------------|
486 -- ----------------------------------------------------------------------------
487 Procedure upd
488   (p_effective_date in     date
489   ,p_datetrack_mode in     varchar2
490   ,p_rec            in out nocopy ame_man_shd.g_rec_type
491   ) is
492 --
493   l_proc                        varchar2(72) := g_package||'upd';
494   l_validation_start_date       date;
495   l_validation_end_date         date;
496 --
497 Begin
498   hr_utility.set_location('Entering:'||l_proc, 5);
499   --
500   -- Ensure that the DateTrack update mode is valid
501   --
502   dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode);
503   --
504   -- We must lock the row which we need to update.
505   --
506   ame_man_shd.lck
507     (p_effective_date                   => p_effective_date
508     ,p_datetrack_mode                   => p_datetrack_mode
509     ,p_attribute_id =>  p_rec.attribute_id
510  ,p_action_type_id =>  p_rec.action_type_id
511     ,p_object_version_number            => p_rec.object_version_number
512     ,p_validation_start_date            => l_validation_start_date
513     ,p_validation_end_date              => l_validation_end_date
514     );
515   --
516   -- 1. During an update system defaults are used to determine if
517   --    arguments have been defaulted or not. We must therefore
518   --    derive the full record structure values to be updated.
519   --
520   -- 2. Call the supporting update validate operations.
521   --
522   ame_man_upd.convert_defs(p_rec);
523   --
524   ame_man_bus.update_validate
525     (p_rec                              => p_rec
526     ,p_effective_date                   => p_effective_date
527     ,p_datetrack_mode                   => p_datetrack_mode
528     ,p_validation_start_date            => l_validation_start_date
529     ,p_validation_end_date              => l_validation_end_date
530     );
531   --
532   -- Call to raise any errors on multi-message list
533   hr_multi_message.end_validation_set;
534   --
535   -- Call the supporting pre-update operation
536   --
537   pre_update
538     (p_rec                              => p_rec
539     ,p_effective_date                   => p_effective_date
540     ,p_datetrack_mode                   => p_datetrack_mode
541     ,p_validation_start_date            => l_validation_start_date
542     ,p_validation_end_date              => l_validation_end_date
543     );
544   --
545   -- Update the row.
546   --
547   update_dml
548     (p_rec                              => p_rec
549     ,p_effective_date                   => p_effective_date
550     ,p_datetrack_mode                   => p_datetrack_mode
551     ,p_validation_start_date            => l_validation_start_date
552     ,p_validation_end_date                  => l_validation_end_date
553     );
554   --
555   -- Call the supporting post-update operation
556   --
557   post_update
558     (p_rec                              => p_rec
559     ,p_effective_date                   => p_effective_date
560     ,p_datetrack_mode                   => p_datetrack_mode
561     ,p_validation_start_date            => l_validation_start_date
562     ,p_validation_end_date              => l_validation_end_date
563     );
564   --
565   -- Call to raise any errors on multi-message list
566   hr_multi_message.end_validation_set;
567 End upd;
568 --
569 -- ----------------------------------------------------------------------------
570 -- |------------------------------< upd >-------------------------------------|
571 -- ----------------------------------------------------------------------------
572 Procedure upd
573   (p_effective_date               in     date
574   ,p_datetrack_mode               in     varchar2
575   ,p_attribute_id                 in     number
576   ,p_action_type_id               in     number
577   ,p_object_version_number        in out nocopy number
578   ,p_security_group_id            in     number    default hr_api.g_number
579   ,p_start_date                      out nocopy date
580   ,p_end_date                        out nocopy date
581   ) is
582 --
583   l_rec         ame_man_shd.g_rec_type;
584   l_proc        varchar2(72) := g_package||'upd';
585 --
586 Begin
587   hr_utility.set_location('Entering:'||l_proc, 5);
588   --
589   -- Call conversion function to turn arguments into the
590   -- l_rec structure.
591   --
592   l_rec :=
593   ame_man_shd.convert_args
594     (p_attribute_id
595     ,p_action_type_id
596     ,null
597     ,null
598     ,p_security_group_id
599     ,p_object_version_number
600     );
601   --
602   -- Having converted the arguments into the
603   -- plsql record structure we call the corresponding record
604   -- business process.
605   --
606   ame_man_upd.upd
607     (p_effective_date
608     ,p_datetrack_mode
609     ,l_rec
610     );
611   --
612   -- Set the out parameters
613   --
614   p_object_version_number            := l_rec.object_version_number;
615   p_start_date             := l_rec.start_date;
616   p_end_date               := l_rec.end_date;
617   --
618   --
619   hr_utility.set_location(' Leaving:'||l_proc, 10);
620 End upd;
621 --
622 end ame_man_upd;