DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_GCF_UPD

Source


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