DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_RTU_UPD

Source


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