DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_ACT_UPD

Source


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