DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_ACA_UPD

Source


1 Package Body ame_aca_upd as
2 /* $Header: amacarhi.pkb 120.4 2006/10/05 15:53:53 pvelugul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ame_aca_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_aca_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_aca_shd.get_object_version_number
78         (p_application_id =>  p_rec.application_id
79       );
80     --
81     --
82     --
83     -- Update the ame_calling_apps Row
84     --
85     update  ame_calling_apps
86     set
87      fnd_application_id                   = p_rec.fnd_application_id
88     ,application_name                     = p_rec.application_name
89     ,transaction_type_id                  = p_rec.transaction_type_id
90     ,application_id                       = p_rec.application_id
91     ,line_item_id_query                   = p_rec.line_item_id_query
92     ,security_group_id                    = p_rec.security_group_id
93     ,object_version_number                = p_rec.object_version_number
94     where   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_aca_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_aca_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_aca_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_aca_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_aca_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_aca_shd.upd_end_date
240       (p_effective_date         => p_effective_date
241       ,p_application_id =>  p_rec.application_id
242       ,p_new_end_date           => p_validation_start_date
243       ,p_object_version_number  => l_dummy_version_number
244       );
245     --
246     If (p_datetrack_mode = hr_api.g_update_override) then
247       --
248       -- As the datetrack mode is 'UPDATE_OVERRIDE' then we must
249       -- delete any future rows
250       --
251       ame_aca_del.delete_dml
252         (p_rec                   => p_rec
253         ,p_effective_date        => p_effective_date
254         ,p_datetrack_mode        => p_datetrack_mode
255         ,p_validation_start_date => p_validation_start_date
256         ,p_validation_end_date   => p_validation_end_date
257         );
258     End If;
259     --
260     -- We must now insert the updated row
261     --
262     ame_aca_ins.insert_dml
263       (p_rec                    => p_rec
264       ,p_effective_date         => p_effective_date
265       ,p_datetrack_mode         => p_datetrack_mode
266       ,p_validation_start_date  => p_validation_start_date
267       ,p_validation_end_date    => p_validation_end_date
268       );
269   End If;
270   hr_utility.set_location(' Leaving:'||l_proc, 20);
271 End dt_pre_update;
272 --
273 -- ----------------------------------------------------------------------------
274 -- |------------------------------< pre_update >------------------------------|
275 -- ----------------------------------------------------------------------------
276 -- {Start Of Comments}
277 --
278 -- Description:
279 --   This private procedure contains any processing which is required before
280 --   the update dml.
281 --
282 -- Prerequisites:
283 --   This is an internal procedure which is called from the upd procedure.
284 --
285 -- In Parameters:
286 --   A Pl/Sql record structure.
287 --
288 -- Post Success:
289 --   Processing continues.
290 --
291 -- Post Failure:
292 --   If an error has occurred, an error message and exception will be raised
293 --   but not handled.
294 -- Developer Implementation Notes:
295 --   Any pre-processing required before the update dml is issued should be
296 --   coded within this procedure. It is important to note that any 3rd party
297 --   maintenance should be reviewed before placing in this procedure. The call
298 --   to the dt_update_dml procedure should NOT be removed.
299 --
300 -- Access Status:
301 --   Internal Row Handler Use Only.
302 --
303 -- {End Of Comments}
304 -- ----------------------------------------------------------------------------
305 Procedure pre_update
306   (p_rec                   in out nocopy ame_aca_shd.g_rec_type
307   ,p_effective_date        in date
308   ,p_datetrack_mode        in varchar2
309   ,p_validation_start_date in date
310   ,p_validation_end_date   in date
311   ) is
312 --
313   l_proc        varchar2(72) := g_package||'pre_update';
314 --
315 Begin
316   hr_utility.set_location('Entering:'||l_proc, 5);
317   --
318   --
319   --
320   dt_pre_update
321     (p_rec                   => p_rec
322     ,p_effective_date        => p_effective_date
323     ,p_datetrack_mode        => p_datetrack_mode
324     ,p_validation_start_date => p_validation_start_date
325     ,p_validation_end_date   => p_validation_end_date
326     );
327   --
328   hr_utility.set_location(' Leaving:'||l_proc, 10);
329 End pre_update;
330 --
331 -- ----------------------------------------------------------------------------
332 -- |----------------------------< post_update >-------------------------------|
333 -- ----------------------------------------------------------------------------
334 -- {Start Of Comments}
335 --
336 -- Description:
337 --   This private procedure contains any processing which is required after
338 --   the update dml.
339 --
340 -- Prerequisites:
341 --   This is an internal procedure which is called from the upd procedure.
342 --
343 -- In Parameters:
344 --   A Pl/Sql record structure.
345 --
346 -- Post Success:
347 --   Processing continues.
348 --
349 -- Post Failure:
350 --   If an error has occurred, an error message and exception will be raised
351 --   but not handled.
352 --
353 -- Developer Implementation Notes:
354 --   Any post-processing required after the update dml is issued should be
355 --   coded within this procedure. It is important to note that any 3rd party
356 --   maintenance should be reviewed before placing in this procedure.
357 --
358 -- Access Status:
359 --   Internal Row Handler Use Only.
360 --
361 -- {End Of Comments}
362 -- ----------------------------------------------------------------------------
363 Procedure post_update
364   (p_rec                   in ame_aca_shd.g_rec_type
365   ,p_effective_date        in date
366   ,p_datetrack_mode        in varchar2
367   ,p_validation_start_date in date
368   ,p_validation_end_date   in date
369   ) is
370 --
371   l_proc        varchar2(72) := g_package||'post_update';
372 --
373 Begin
374   hr_utility.set_location('Entering:'||l_proc, 5);
375   begin
376     --
377     ame_aca_rku.after_update
378       (p_effective_date
379       => p_effective_date
380       ,p_datetrack_mode
381       => p_datetrack_mode
382       ,p_validation_start_date
383       => p_validation_start_date
384       ,p_validation_end_date
385       => p_validation_end_date
386       ,p_fnd_application_id
387       => p_rec.fnd_application_id
388       ,p_application_name
389       => p_rec.application_name
390       ,p_transaction_type_id
391       => p_rec.transaction_type_id
392       ,p_application_id
393       => p_rec.application_id
394       ,p_line_item_id_query
395       => p_rec.line_item_id_query
396       ,p_start_date
397       => p_rec.start_date
398       ,p_end_date
399       => p_rec.end_date
400       ,p_security_group_id
401       => p_rec.security_group_id
402       ,p_object_version_number
403       => p_rec.object_version_number
404       ,p_fnd_application_id_o
405       => ame_aca_shd.g_old_rec.fnd_application_id
406       ,p_application_name_o
407       => ame_aca_shd.g_old_rec.application_name
408       ,p_transaction_type_id_o
409       => ame_aca_shd.g_old_rec.transaction_type_id
410       ,p_line_item_id_query_o
411       => ame_aca_shd.g_old_rec.line_item_id_query
412       ,p_start_date_o
413       => ame_aca_shd.g_old_rec.start_date
414       ,p_end_date_o
415       => ame_aca_shd.g_old_rec.end_date
416       ,p_security_group_id_o
417       => ame_aca_shd.g_old_rec.security_group_id
418       ,p_object_version_number_o
419       => ame_aca_shd.g_old_rec.object_version_number
420       );
421     --
422   exception
423     --
424     when hr_api.cannot_find_prog_unit then
425       --
426       hr_api.cannot_find_prog_unit_error
427         (p_module_name => 'AME_CALLING_APPS'
428         ,p_hook_type   => 'AU');
429       --
430   end;
431   --
432   hr_utility.set_location(' Leaving:'||l_proc, 10);
433 End post_update;
434 --
435 -- ----------------------------------------------------------------------------
436 -- |-----------------------------< convert_defs >-----------------------------|
437 -- ----------------------------------------------------------------------------
438 -- {Start Of Comments}
439 --
440 -- Description:
441 --   The Convert_Defs procedure has one very important function:
442 --   It must return the record structure for the row with all system defaulted
443 --   values converted into its corresponding parameter value for update. When
444 --   we attempt to update a row through the Upd process , certain
445 --   parameters can be defaulted which enables flexibility in the calling of
446 --   the upd process (e.g. only attributes which need to be updated need to be
447 --   specified). For the upd process to determine which attributes
448 --   have NOT been specified we need to check if the parameter has a reserved
449 --   system default value. Therefore, for all parameters which have a
450 --   corresponding reserved system default mechanism specified we need to
451 --   check if a system default is being used. If a system default is being
452 --   used then we convert the defaulted value into its corresponding attribute
453 --   value held in the g_old_rec data structure.
454 --
455 -- Prerequisites:
456 --   This private function can only be called from the upd process.
457 --
458 -- In Parameters:
459 --   A Pl/Sql record structure.
460 --
461 -- Post Success:
462 --   The record structure will be returned with all system defaulted parameter
463 --   values converted into its current row attribute value.
464 --
465 -- Post Failure:
466 --   No direct error handling is required within this function. Any possible
467 --   errors within this procedure will be a PL/SQL value error due to
468 --   conversion of datatypes or data lengths.
469 --
470 -- Developer Implementation Notes:
471 --   None.
472 --
473 -- Access Status:
474 --   Internal Row Handler Use Only.
475 --
476 -- {End Of Comments}
477 -- ----------------------------------------------------------------------------
478 Procedure convert_defs
479   (p_rec in out nocopy ame_aca_shd.g_rec_type
480   ) is
481 --
482 Begin
483   --
484   -- We must now examine each argument value in the
485   -- p_rec plsql record structure
486   -- to see if a system default is being used. If a system default
487   -- is being used then we must set to the 'current' argument value.
488   --
489   If (p_rec.fnd_application_id = hr_api.g_number) then
490     p_rec.fnd_application_id :=
491     ame_aca_shd.g_old_rec.fnd_application_id;
492   End If;
493   If (p_rec.application_name = hr_api.g_varchar2) then
494     p_rec.application_name :=
495     ame_aca_shd.g_old_rec.application_name;
496   End If;
497   If (p_rec.transaction_type_id = hr_api.g_varchar2) then
498     p_rec.transaction_type_id :=
499     ame_aca_shd.g_old_rec.transaction_type_id;
500   End If;
501   If (p_rec.line_item_id_query = hr_api.g_varchar2) then
502     p_rec.line_item_id_query :=
503     ame_aca_shd.g_old_rec.line_item_id_query;
504   End If;
505   If (p_rec.security_group_id = hr_api.g_number) then
506     p_rec.security_group_id :=
507     ame_aca_shd.g_old_rec.security_group_id;
508   End If;
509   --
510 End convert_defs;
511 --
512 -- ----------------------------------------------------------------------------
513 -- |---------------------------------< upd >----------------------------------|
514 -- ----------------------------------------------------------------------------
515 Procedure upd
516   (p_effective_date in     date
517   ,p_datetrack_mode in     varchar2
518   ,p_rec            in out nocopy ame_aca_shd.g_rec_type
519   ) is
520 --
521   l_proc                        varchar2(72) := g_package||'upd';
522   l_validation_start_date       date;
523   l_validation_end_date         date;
524 --
525 Begin
526   hr_utility.set_location('Entering:'||l_proc, 5);
527   --
528   -- Ensure that the DateTrack update mode is valid
529   --
530   dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode);
531   --
532   -- We must lock the row which we need to update.
533   --
534   ame_aca_shd.lck
535     (p_effective_date                   => p_effective_date
536     ,p_datetrack_mode                   => p_datetrack_mode
537     ,p_application_id =>  p_rec.application_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_aca_upd.convert_defs(p_rec);
550   --
551   ame_aca_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_application_id               in     number
603   ,p_object_version_number        in out nocopy number
604   ,p_fnd_application_id           in     number    default hr_api.g_number
605   ,p_application_name             in     varchar2  default hr_api.g_varchar2
606   ,p_transaction_type_id          in     varchar2  default hr_api.g_varchar2
607   ,p_line_item_id_query           in     varchar2  default hr_api.g_varchar2
608   ,p_security_group_id            in     number    default hr_api.g_number
609   ,p_start_date                      out nocopy date
610   ,p_end_date                        out nocopy date
611   ) is
612 --
613   l_rec         ame_aca_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_aca_shd.convert_args
624     (p_fnd_application_id
625     ,p_application_name
626     ,p_transaction_type_id
627     ,p_application_id
628     ,p_line_item_id_query
629     ,null
630     ,null
631     ,p_security_group_id
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_aca_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_aca_upd;