DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_OTP_UPD

Source


1 Package Body ben_otp_upd as
2 /* $Header: beotprhi.pkb 115.3 2003/09/25 00:30:57 rpgupta noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_otp_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 ben_otp_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       dt_api.get_object_version_number
78         (p_base_table_name => 'ben_optip_f'
79         ,p_base_key_column => 'optip_id'
80         ,p_base_key_value  => p_rec.optip_id
81         );
82     --
83     ben_otp_shd.g_api_dml := true;  -- Set the api dml status
84     --
85     -- Update the ben_optip_f Row
86     --
87     update  ben_optip_f
88     set
89      optip_id                             = p_rec.optip_id
90     ,business_group_id                    = p_rec.business_group_id
91     ,pgm_id                               = p_rec.pgm_id
92     ,ptip_id                              = p_rec.ptip_id
93     ,pl_typ_id                            = p_rec.pl_typ_id
94     ,opt_id                               = p_rec.opt_id
95     ,cmbn_ptip_opt_id                     = p_rec.cmbn_ptip_opt_id
96     ,legislation_code               = p_rec.legislation_code
97     ,legislation_subgroup               = p_rec.legislation_subgroup
98     ,otp_attribute_category               = p_rec.otp_attribute_category
99     ,otp_attribute1                       = p_rec.otp_attribute1
100     ,otp_attribute2                       = p_rec.otp_attribute2
101     ,otp_attribute3                       = p_rec.otp_attribute3
102     ,otp_attribute4                       = p_rec.otp_attribute4
103     ,otp_attribute5                       = p_rec.otp_attribute5
104     ,otp_attribute6                       = p_rec.otp_attribute6
105     ,otp_attribute7                       = p_rec.otp_attribute7
106     ,otp_attribute8                       = p_rec.otp_attribute8
107     ,otp_attribute9                       = p_rec.otp_attribute9
108     ,otp_attribute10                      = p_rec.otp_attribute10
109     ,otp_attribute11                      = p_rec.otp_attribute11
110     ,otp_attribute12                      = p_rec.otp_attribute12
111     ,otp_attribute13                      = p_rec.otp_attribute13
112     ,otp_attribute14                      = p_rec.otp_attribute14
113     ,otp_attribute15                      = p_rec.otp_attribute15
114     ,otp_attribute16                      = p_rec.otp_attribute16
115     ,otp_attribute17                      = p_rec.otp_attribute17
116     ,otp_attribute18                      = p_rec.otp_attribute18
117     ,otp_attribute19                      = p_rec.otp_attribute19
118     ,otp_attribute20                      = p_rec.otp_attribute20
119     ,otp_attribute21                      = p_rec.otp_attribute21
120     ,otp_attribute22                      = p_rec.otp_attribute22
121     ,otp_attribute23                      = p_rec.otp_attribute23
122     ,otp_attribute24                      = p_rec.otp_attribute24
123     ,otp_attribute25                      = p_rec.otp_attribute25
124     ,otp_attribute26                      = p_rec.otp_attribute26
125     ,otp_attribute27                      = p_rec.otp_attribute27
126     ,otp_attribute28                      = p_rec.otp_attribute28
127     ,otp_attribute29                      = p_rec.otp_attribute29
128     ,otp_attribute30                      = p_rec.otp_attribute30
129     ,object_version_number                = p_rec.object_version_number
130     where   optip_id = p_rec.optip_id
131     and     effective_start_date = p_validation_start_date
132     and     effective_end_date   = p_validation_end_date;
133     --
134     ben_otp_shd.g_api_dml := false;   -- Unset the api dml status
135     --
136     -- Set the effective start and end dates
137     --
138     p_rec.effective_start_date := p_validation_start_date;
139     p_rec.effective_end_date   := p_validation_end_date;
140   End If;
141 --
142 hr_utility.set_location(' Leaving:'||l_proc, 15);
143 Exception
144   When hr_api.check_integrity_violated Then
145     -- A check constraint has been violated
146     ben_otp_shd.g_api_dml := false;   -- Unset the api dml status
147     ben_otp_shd.constraint_error
148       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
149   When hr_api.unique_integrity_violated Then
150     -- Unique integrity has been violated
151     ben_otp_shd.g_api_dml := false;   -- Unset the api dml status
152     ben_otp_shd.constraint_error
153       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
154   When Others Then
155     ben_otp_shd.g_api_dml := false;   -- Unset the api dml status
156     Raise;
157 End dt_update_dml;
158 --
159 -- ----------------------------------------------------------------------------
160 -- |------------------------------< update_dml >------------------------------|
161 -- ----------------------------------------------------------------------------
162 -- {Start Of Comments}
163 --
164 -- Description:
165 --   This procedure calls the dt_update_dml control logic which handles
166 --   the actual datetrack dml.
167 --
168 -- Prerequisites:
169 --   This is an internal private procedure which must be called from the upd
170 --   procedure.
171 --
172 -- In Parameters:
173 --   A Pl/Sql record structre.
174 --
175 -- Post Success:
176 --   Processing contines.
177 --
178 -- Post Failure:
179 --   No specific error handling is required within this procedure.
180 --
181 -- Developer Implementation Notes:
182 --   The update 'set' arguments list should be modified if any of your
183 --   attributes are not updateable.
184 --
185 -- Access Status:
186 --   Internal Row Handler Use Only.
187 --
188 -- {End Of Comments}
189 -- ----------------------------------------------------------------------------
190 Procedure update_dml
191   (p_rec                      in out nocopy ben_otp_shd.g_rec_type
192   ,p_effective_date           in date
193   ,p_datetrack_mode           in varchar2
194   ,p_validation_start_date    in date
195   ,p_validation_end_date      in date
196   ) is
197 --
198   l_proc	varchar2(72) := g_package||'update_dml';
199 --
200 Begin
201   hr_utility.set_location('Entering:'||l_proc, 5);
202   --
203   ben_otp_upd.dt_update_dml
204     (p_rec                   => p_rec
205     ,p_effective_date        => p_effective_date
206     ,p_datetrack_mode        => p_datetrack_mode
207     ,p_validation_start_date => p_validation_start_date
208     ,p_validation_end_date   => p_validation_end_date
209     );
210   --
211   hr_utility.set_location(' Leaving:'||l_proc, 10);
212 End update_dml;
213 --
214 -- ----------------------------------------------------------------------------
215 -- |----------------------------< dt_pre_update >-----------------------------|
216 -- ----------------------------------------------------------------------------
217 -- {Start Of Comments}
218 --
219 -- Description:
220 --   The dt_pre_update procedure controls the execution
221 --   of dml for the datetrack modes of: UPDATE, UPDATE_OVERRIDE
222 --   and UPDATE_CHANGE_INSERT only. The execution required is as
223 --   follows:
224 --
225 --   1) Providing the datetrack update mode is not 'CORRECTION'
226 --      then set the effective end date of the current row (this
227 --      will be the validation_start_date - 1).
228 --   2) If the datetrack mode is 'UPDATE_OVERRIDE' then call the
229 --      corresponding delete_dml process to delete any future rows
230 --      where the effective_start_date is greater than or equal to
231 --	the validation_start_date.
232 --   3) Call the insert_dml process to insert the new updated row
233 --      details.
234 --
235 -- Prerequisites:
236 --   This is an internal procedure which is called from the
237 --   pre_update procedure.
238 --
239 -- In Parameters:
240 --
241 -- Post Success:
242 --   Processing continues.
243 --
244 -- Post Failure:
245 --   If an error has occurred, an error message and exception will be raised
246 --   but not handled.
247 --
248 -- Developer Implementation Notes:
249 --   This is an internal procedure which is required by Datetrack. Don't
250 --   remove or modify.
251 --
252 -- Access Status:
253 --   Internal Row Handler Use Only.
254 --
255 -- {End Of Comments}
256 -- ----------------------------------------------------------------------------
257 Procedure dt_pre_update
258   (p_rec                     in out nocopy ben_otp_shd.g_rec_type
259   ,p_effective_date          in date
260   ,p_datetrack_mode          in varchar2
261   ,p_validation_start_date   in date
262   ,p_validation_end_date     in date
263   ) is
264 --
265   l_proc	         varchar2(72) := g_package||'dt_pre_update';
266   l_dummy_version_number number;
267 --
268 Begin
269   hr_utility.set_location('Entering:'||l_proc, 5);
270   If (p_datetrack_mode <> hr_api.g_correction) then
271     --
272     -- Update the current effective end date
273     --
274     ben_otp_shd.upd_effective_end_date
275       (p_effective_date         => p_effective_date
276       ,p_base_key_value	        => p_rec.optip_id
277       ,p_new_effective_end_date => (p_validation_start_date - 1)
278       ,p_validation_start_date  => p_validation_start_date
279       ,p_validation_end_date    => p_validation_end_date
280       ,p_object_version_number  => l_dummy_version_number
281       );
282     --
283     If (p_datetrack_mode = hr_api.g_update_override) then
284       --
285       -- As the datetrack mode is 'UPDATE_OVERRIDE' then we must
286       -- delete any future rows
287       --
288       ben_otp_del.delete_dml
289         (p_rec                   => p_rec
290         ,p_effective_date        => p_effective_date
291         ,p_datetrack_mode        => p_datetrack_mode
292         ,p_validation_start_date => p_validation_start_date
293         ,p_validation_end_date   => p_validation_end_date
294         );
295     End If;
296     --
297     -- We must now insert the updated row
298     --
299     ben_otp_ins.insert_dml
300       (p_rec                    => p_rec
301       ,p_effective_date	        => p_effective_date
302       ,p_datetrack_mode	        => p_datetrack_mode
303       ,p_validation_start_date  => p_validation_start_date
304       ,p_validation_end_date    => p_validation_end_date
305       );
306   End If;
307   hr_utility.set_location(' Leaving:'||l_proc, 20);
308 End dt_pre_update;
309 --
310 -- ----------------------------------------------------------------------------
311 -- |------------------------------< pre_update >------------------------------|
312 -- ----------------------------------------------------------------------------
313 -- {Start Of Comments}
314 --
315 -- Description:
316 --   This private procedure contains any processing which is required before
317 --   the update dml.
318 --
319 -- Prerequisites:
320 --   This is an internal procedure which is called from the upd procedure.
321 --
322 -- In Parameters:
323 --   A Pl/Sql record structure.
324 --
325 -- Post Success:
326 --   Processing continues.
327 --
328 -- Post Failure:
329 --   If an error has occurred, an error message and exception will be raised
330 --   but not handled.
331 --
332 -- Developer Implementation Notes:
333 --   Any pre-processing required before the update dml is issued should be
334 --   coded within this procedure. It is important to note that any 3rd party
335 --   maintenance should be reviewed before placing in this procedure. The call
336 --   to the dt_update_dml procedure should NOT be removed.
337 --
338 -- Access Status:
339 --   Internal Row Handler Use Only.
340 --
341 -- {End Of Comments}
342 -- ----------------------------------------------------------------------------
343 Procedure pre_update
344   (p_rec                   in out nocopy ben_otp_shd.g_rec_type
345   ,p_effective_date        in date
346   ,p_datetrack_mode        in varchar2
347   ,p_validation_start_date in date
348   ,p_validation_end_date   in date
349   ) is
350 --
351   l_proc	varchar2(72) := g_package||'pre_update';
352 --
353 Begin
354   hr_utility.set_location('Entering:'||l_proc, 5);
355   --
356   --
357   --
358   dt_pre_update
359     (p_rec                   => p_rec
360     ,p_effective_date	     => p_effective_date
361     ,p_datetrack_mode	     => p_datetrack_mode
362     ,p_validation_start_date => p_validation_start_date
363     ,p_validation_end_date   => p_validation_end_date
364     );
365   --
366   hr_utility.set_location(' Leaving:'||l_proc, 10);
367 End pre_update;
368 --
369 -- ----------------------------------------------------------------------------
370 -- |----------------------------< post_update >-------------------------------|
371 -- ----------------------------------------------------------------------------
372 -- {Start Of Comments}
373 --
374 -- Description:
375 --   This private procedure contains any processing which is required after the
376 --   update dml.
377 --
378 -- Prerequisites:
379 --   This is an internal procedure which is called from the upd procedure.
380 --
381 -- In Parameters:
382 --   A Pl/Sql record structure.
383 --
384 -- Post Success:
385 --   Processing continues.
386 --
387 -- Post Failure:
388 --   If an error has occurred, an error message and exception will be raised
389 --   but not handled.
390 --
391 -- Developer Implementation Notes:
392 --   Any post-processing required after the update dml is issued should be
393 --   coded within this procedure. It is important to note that any 3rd party
394 --   maintenance should be reviewed before placing in this procedure.
395 --
396 -- Access Status:
397 --   Internal Row Handler Use Only.
398 --
399 -- {End Of Comments}
400 -- ----------------------------------------------------------------------------
401 Procedure post_update
402   (p_rec                   in ben_otp_shd.g_rec_type
403   ,p_effective_date        in date
404   ,p_datetrack_mode        in varchar2
405   ,p_validation_start_date in date
406   ,p_validation_end_date   in date
407   ) is
408 --
409   l_proc	varchar2(72) := g_package||'post_update';
410 --
411 Begin
412   hr_utility.set_location('Entering:'||l_proc, 5);
413   begin
414     --
415     ben_otp_rku.after_update
416       (p_effective_date
417       => p_effective_date
418       ,p_datetrack_mode
419       => p_datetrack_mode
420       ,p_validation_start_date
421       => p_validation_start_date
422       ,p_validation_end_date
423       => p_validation_end_date
424       ,p_optip_id
425       => p_rec.optip_id
426       ,p_effective_start_date
427       => p_rec.effective_start_date
428       ,p_effective_end_date
429       => p_rec.effective_end_date
430       ,p_business_group_id
431       => p_rec.business_group_id
432       ,p_pgm_id
433       => p_rec.pgm_id
434       ,p_ptip_id
435       => p_rec.ptip_id
436       ,p_pl_typ_id
437       => p_rec.pl_typ_id
438       ,p_opt_id
439       => p_rec.opt_id
440       ,p_cmbn_ptip_opt_id
441       => p_rec.cmbn_ptip_opt_id
442       ,p_legislation_code
443       => p_rec.legislation_code
444       ,p_legislation_subgroup
445       => p_rec.legislation_subgroup
446       ,p_otp_attribute_category
447       => p_rec.otp_attribute_category
448       ,p_otp_attribute1
449       => p_rec.otp_attribute1
450       ,p_otp_attribute2
451       => p_rec.otp_attribute2
452       ,p_otp_attribute3
453       => p_rec.otp_attribute3
454       ,p_otp_attribute4
455       => p_rec.otp_attribute4
456       ,p_otp_attribute5
457       => p_rec.otp_attribute5
458       ,p_otp_attribute6
459       => p_rec.otp_attribute6
460       ,p_otp_attribute7
461       => p_rec.otp_attribute7
462       ,p_otp_attribute8
463       => p_rec.otp_attribute8
464       ,p_otp_attribute9
465       => p_rec.otp_attribute9
466       ,p_otp_attribute10
467       => p_rec.otp_attribute10
468       ,p_otp_attribute11
469       => p_rec.otp_attribute11
470       ,p_otp_attribute12
471       => p_rec.otp_attribute12
472       ,p_otp_attribute13
473       => p_rec.otp_attribute13
474       ,p_otp_attribute14
475       => p_rec.otp_attribute14
476       ,p_otp_attribute15
477       => p_rec.otp_attribute15
478       ,p_otp_attribute16
479       => p_rec.otp_attribute16
480       ,p_otp_attribute17
481       => p_rec.otp_attribute17
482       ,p_otp_attribute18
483       => p_rec.otp_attribute18
484       ,p_otp_attribute19
485       => p_rec.otp_attribute19
486       ,p_otp_attribute20
487       => p_rec.otp_attribute20
488       ,p_otp_attribute21
489       => p_rec.otp_attribute21
490       ,p_otp_attribute22
491       => p_rec.otp_attribute22
492       ,p_otp_attribute23
493       => p_rec.otp_attribute23
494       ,p_otp_attribute24
495       => p_rec.otp_attribute24
496       ,p_otp_attribute25
497       => p_rec.otp_attribute25
498       ,p_otp_attribute26
499       => p_rec.otp_attribute26
500       ,p_otp_attribute27
501       => p_rec.otp_attribute27
502       ,p_otp_attribute28
503       => p_rec.otp_attribute28
504       ,p_otp_attribute29
505       => p_rec.otp_attribute29
506       ,p_otp_attribute30
507       => p_rec.otp_attribute30
508       ,p_object_version_number
509       => p_rec.object_version_number
510       ,p_effective_start_date_o
511       => ben_otp_shd.g_old_rec.effective_start_date
512       ,p_effective_end_date_o
513       => ben_otp_shd.g_old_rec.effective_end_date
514       ,p_business_group_id_o
515       => ben_otp_shd.g_old_rec.business_group_id
516       ,p_pgm_id_o
517       => ben_otp_shd.g_old_rec.pgm_id
518       ,p_ptip_id_o
519       => ben_otp_shd.g_old_rec.ptip_id
520       ,p_pl_typ_id_o
521       => ben_otp_shd.g_old_rec.pl_typ_id
522       ,p_opt_id_o
523       => ben_otp_shd.g_old_rec.opt_id
524       ,p_cmbn_ptip_opt_id_o
525       => ben_otp_shd.g_old_rec.cmbn_ptip_opt_id
526       ,p_legislation_code_o
527       => ben_otp_shd.g_old_rec.legislation_code
528       ,p_legislation_subgroup_o
529       => ben_otp_shd.g_old_rec.legislation_subgroup
530       ,p_otp_attribute_category_o
531       => ben_otp_shd.g_old_rec.otp_attribute_category
532       ,p_otp_attribute1_o
533       => ben_otp_shd.g_old_rec.otp_attribute1
534       ,p_otp_attribute2_o
535       => ben_otp_shd.g_old_rec.otp_attribute2
536       ,p_otp_attribute3_o
537       => ben_otp_shd.g_old_rec.otp_attribute3
538       ,p_otp_attribute4_o
539       => ben_otp_shd.g_old_rec.otp_attribute4
540       ,p_otp_attribute5_o
541       => ben_otp_shd.g_old_rec.otp_attribute5
542       ,p_otp_attribute6_o
543       => ben_otp_shd.g_old_rec.otp_attribute6
544       ,p_otp_attribute7_o
545       => ben_otp_shd.g_old_rec.otp_attribute7
546       ,p_otp_attribute8_o
547       => ben_otp_shd.g_old_rec.otp_attribute8
548       ,p_otp_attribute9_o
549       => ben_otp_shd.g_old_rec.otp_attribute9
550       ,p_otp_attribute10_o
551       => ben_otp_shd.g_old_rec.otp_attribute10
552       ,p_otp_attribute11_o
553       => ben_otp_shd.g_old_rec.otp_attribute11
554       ,p_otp_attribute12_o
555       => ben_otp_shd.g_old_rec.otp_attribute12
556       ,p_otp_attribute13_o
557       => ben_otp_shd.g_old_rec.otp_attribute13
558       ,p_otp_attribute14_o
559       => ben_otp_shd.g_old_rec.otp_attribute14
560       ,p_otp_attribute15_o
561       => ben_otp_shd.g_old_rec.otp_attribute15
562       ,p_otp_attribute16_o
563       => ben_otp_shd.g_old_rec.otp_attribute16
564       ,p_otp_attribute17_o
565       => ben_otp_shd.g_old_rec.otp_attribute17
566       ,p_otp_attribute18_o
567       => ben_otp_shd.g_old_rec.otp_attribute18
568       ,p_otp_attribute19_o
569       => ben_otp_shd.g_old_rec.otp_attribute19
570       ,p_otp_attribute20_o
571       => ben_otp_shd.g_old_rec.otp_attribute20
572       ,p_otp_attribute21_o
573       => ben_otp_shd.g_old_rec.otp_attribute21
574       ,p_otp_attribute22_o
575       => ben_otp_shd.g_old_rec.otp_attribute22
576       ,p_otp_attribute23_o
577       => ben_otp_shd.g_old_rec.otp_attribute23
578       ,p_otp_attribute24_o
579       => ben_otp_shd.g_old_rec.otp_attribute24
580       ,p_otp_attribute25_o
581       => ben_otp_shd.g_old_rec.otp_attribute25
582       ,p_otp_attribute26_o
583       => ben_otp_shd.g_old_rec.otp_attribute26
584       ,p_otp_attribute27_o
585       => ben_otp_shd.g_old_rec.otp_attribute27
586       ,p_otp_attribute28_o
587       => ben_otp_shd.g_old_rec.otp_attribute28
588       ,p_otp_attribute29_o
589       => ben_otp_shd.g_old_rec.otp_attribute29
590       ,p_otp_attribute30_o
591       => ben_otp_shd.g_old_rec.otp_attribute30
592       ,p_object_version_number_o
593       => ben_otp_shd.g_old_rec.object_version_number
594       );
595     --
596   exception
597     --
598     when hr_api.cannot_find_prog_unit then
599       --
600       hr_api.cannot_find_prog_unit_error
601         (p_module_name => 'BEN_OPTIP_F'
602         ,p_hook_type   => 'AU');
603       --
604   end;
605   --
606   hr_utility.set_location(' Leaving:'||l_proc, 10);
607 End post_update;
608 --
609 -- ----------------------------------------------------------------------------
610 -- |-----------------------------< convert_defs >-----------------------------|
611 -- ----------------------------------------------------------------------------
612 -- {Start Of Comments}
613 --
614 -- Description:
615 --   The Convert_Defs procedure has one very important function:
616 --   It must return the record structure for the row with all system defaulted
617 --   values converted into its corresponding parameter value for update. When
618 --   we attempt to update a row through the Upd process , certain
619 --   parameters can be defaulted which enables flexibility in the calling of
620 --   the upd process (e.g. only attributes which need to be updated need to be
621 --   specified). For the upd process to determine which attributes
622 --   have NOT been specified we need to check if the parameter has a reserved
623 --   system default value. Therefore, for all parameters which have a
624 --   corresponding reserved system default mechanism specified we need to
625 --   check if a system default is being used. If a system default is being
626 --   used then we convert the defaulted value into its corresponding attribute
627 --   value held in the g_old_rec data structure.
628 --
629 -- Prerequisites:
630 --   This private function can only be called from the upd process.
631 --
632 -- In Parameters:
633 --   A Pl/Sql record structure.
634 --
635 -- Post Success:
636 --   The record structure will be returned with all system defaulted parameter
637 --   values converted into its current row attribute value.
638 --
639 -- Post Failure:
640 --   No direct error handling is required within this function. Any possible
641 --   errors within this procedure will be a PL/SQL value error due to
642 --   conversion of datatypes or data lengths.
643 --
644 -- Developer Implementation Notes:
645 --   None.
646 --
647 -- Access Status:
648 --   Internal Row Handler Use Only.
649 --
650 -- {End Of Comments}
651 -- ----------------------------------------------------------------------------
652 Procedure convert_defs
653   (p_rec in out nocopy ben_otp_shd.g_rec_type
654   ) is
655 --
656 Begin
657   --
658   -- We must now examine each argument value in the
659   -- p_rec plsql record structure
660   -- to see if a system default is being used. If a system default
661   -- is being used then we must set to the 'current' argument value.
662   --
663   If (p_rec.business_group_id = hr_api.g_number) then
664     p_rec.business_group_id :=
665     ben_otp_shd.g_old_rec.business_group_id;
666   End If;
667   If (p_rec.pgm_id = hr_api.g_number) then
668     p_rec.pgm_id :=
669     ben_otp_shd.g_old_rec.pgm_id;
670   End If;
671   If (p_rec.ptip_id = hr_api.g_number) then
672     p_rec.ptip_id :=
673     ben_otp_shd.g_old_rec.ptip_id;
674   End If;
675   If (p_rec.pl_typ_id = hr_api.g_number) then
676     p_rec.pl_typ_id :=
677     ben_otp_shd.g_old_rec.pl_typ_id;
678   End If;
679   If (p_rec.opt_id = hr_api.g_number) then
680     p_rec.opt_id :=
681     ben_otp_shd.g_old_rec.opt_id;
682   End If;
683   If (p_rec.cmbn_ptip_opt_id = hr_api.g_number) then
684     p_rec.cmbn_ptip_opt_id :=
685     ben_otp_shd.g_old_rec.cmbn_ptip_opt_id;
686   End If;
687   If (p_rec.legislation_code = hr_api.g_varchar2) then
688     p_rec.legislation_code :=
689     ben_otp_shd.g_old_rec.legislation_code;
690   End If;
691   If (p_rec.legislation_subgroup = hr_api.g_varchar2) then
692     p_rec.legislation_subgroup :=
693     ben_otp_shd.g_old_rec.legislation_subgroup;
694   End If;
695   If (p_rec.otp_attribute_category = hr_api.g_varchar2) then
696     p_rec.otp_attribute_category :=
697     ben_otp_shd.g_old_rec.otp_attribute_category;
698   End If;
699   If (p_rec.otp_attribute1 = hr_api.g_varchar2) then
700     p_rec.otp_attribute1 :=
701     ben_otp_shd.g_old_rec.otp_attribute1;
702   End If;
703   If (p_rec.otp_attribute2 = hr_api.g_varchar2) then
704     p_rec.otp_attribute2 :=
705     ben_otp_shd.g_old_rec.otp_attribute2;
706   End If;
707   If (p_rec.otp_attribute3 = hr_api.g_varchar2) then
708     p_rec.otp_attribute3 :=
709     ben_otp_shd.g_old_rec.otp_attribute3;
710   End If;
711   If (p_rec.otp_attribute4 = hr_api.g_varchar2) then
712     p_rec.otp_attribute4 :=
713     ben_otp_shd.g_old_rec.otp_attribute4;
714   End If;
715   If (p_rec.otp_attribute5 = hr_api.g_varchar2) then
716     p_rec.otp_attribute5 :=
717     ben_otp_shd.g_old_rec.otp_attribute5;
718   End If;
719   If (p_rec.otp_attribute6 = hr_api.g_varchar2) then
720     p_rec.otp_attribute6 :=
721     ben_otp_shd.g_old_rec.otp_attribute6;
722   End If;
723   If (p_rec.otp_attribute7 = hr_api.g_varchar2) then
724     p_rec.otp_attribute7 :=
725     ben_otp_shd.g_old_rec.otp_attribute7;
726   End If;
727   If (p_rec.otp_attribute8 = hr_api.g_varchar2) then
728     p_rec.otp_attribute8 :=
729     ben_otp_shd.g_old_rec.otp_attribute8;
730   End If;
731   If (p_rec.otp_attribute9 = hr_api.g_varchar2) then
732     p_rec.otp_attribute9 :=
733     ben_otp_shd.g_old_rec.otp_attribute9;
734   End If;
735   If (p_rec.otp_attribute10 = hr_api.g_varchar2) then
736     p_rec.otp_attribute10 :=
737     ben_otp_shd.g_old_rec.otp_attribute10;
738   End If;
739   If (p_rec.otp_attribute11 = hr_api.g_varchar2) then
740     p_rec.otp_attribute11 :=
741     ben_otp_shd.g_old_rec.otp_attribute11;
742   End If;
743   If (p_rec.otp_attribute12 = hr_api.g_varchar2) then
744     p_rec.otp_attribute12 :=
745     ben_otp_shd.g_old_rec.otp_attribute12;
746   End If;
747   If (p_rec.otp_attribute13 = hr_api.g_varchar2) then
748     p_rec.otp_attribute13 :=
749     ben_otp_shd.g_old_rec.otp_attribute13;
750   End If;
751   If (p_rec.otp_attribute14 = hr_api.g_varchar2) then
752     p_rec.otp_attribute14 :=
753     ben_otp_shd.g_old_rec.otp_attribute14;
754   End If;
755   If (p_rec.otp_attribute15 = hr_api.g_varchar2) then
756     p_rec.otp_attribute15 :=
757     ben_otp_shd.g_old_rec.otp_attribute15;
758   End If;
759   If (p_rec.otp_attribute16 = hr_api.g_varchar2) then
760     p_rec.otp_attribute16 :=
761     ben_otp_shd.g_old_rec.otp_attribute16;
762   End If;
763   If (p_rec.otp_attribute17 = hr_api.g_varchar2) then
764     p_rec.otp_attribute17 :=
765     ben_otp_shd.g_old_rec.otp_attribute17;
766   End If;
767   If (p_rec.otp_attribute18 = hr_api.g_varchar2) then
768     p_rec.otp_attribute18 :=
769     ben_otp_shd.g_old_rec.otp_attribute18;
770   End If;
771   If (p_rec.otp_attribute19 = hr_api.g_varchar2) then
772     p_rec.otp_attribute19 :=
773     ben_otp_shd.g_old_rec.otp_attribute19;
774   End If;
775   If (p_rec.otp_attribute20 = hr_api.g_varchar2) then
776     p_rec.otp_attribute20 :=
777     ben_otp_shd.g_old_rec.otp_attribute20;
778   End If;
779   If (p_rec.otp_attribute21 = hr_api.g_varchar2) then
780     p_rec.otp_attribute21 :=
781     ben_otp_shd.g_old_rec.otp_attribute21;
782   End If;
783   If (p_rec.otp_attribute22 = hr_api.g_varchar2) then
784     p_rec.otp_attribute22 :=
785     ben_otp_shd.g_old_rec.otp_attribute22;
786   End If;
787   If (p_rec.otp_attribute23 = hr_api.g_varchar2) then
788     p_rec.otp_attribute23 :=
789     ben_otp_shd.g_old_rec.otp_attribute23;
790   End If;
791   If (p_rec.otp_attribute24 = hr_api.g_varchar2) then
792     p_rec.otp_attribute24 :=
793     ben_otp_shd.g_old_rec.otp_attribute24;
794   End If;
795   If (p_rec.otp_attribute25 = hr_api.g_varchar2) then
796     p_rec.otp_attribute25 :=
797     ben_otp_shd.g_old_rec.otp_attribute25;
798   End If;
799   If (p_rec.otp_attribute26 = hr_api.g_varchar2) then
800     p_rec.otp_attribute26 :=
801     ben_otp_shd.g_old_rec.otp_attribute26;
802   End If;
803   If (p_rec.otp_attribute27 = hr_api.g_varchar2) then
804     p_rec.otp_attribute27 :=
805     ben_otp_shd.g_old_rec.otp_attribute27;
806   End If;
807   If (p_rec.otp_attribute28 = hr_api.g_varchar2) then
808     p_rec.otp_attribute28 :=
809     ben_otp_shd.g_old_rec.otp_attribute28;
810   End If;
811   If (p_rec.otp_attribute29 = hr_api.g_varchar2) then
812     p_rec.otp_attribute29 :=
813     ben_otp_shd.g_old_rec.otp_attribute29;
814   End If;
815   If (p_rec.otp_attribute30 = hr_api.g_varchar2) then
816     p_rec.otp_attribute30 :=
817     ben_otp_shd.g_old_rec.otp_attribute30;
818   End If;
819   --
820 End convert_defs;
821 --
822 -- ----------------------------------------------------------------------------
823 -- |---------------------------------< upd >----------------------------------|
824 -- ----------------------------------------------------------------------------
825 Procedure upd
826   (p_effective_date in     date
827   ,p_datetrack_mode in     varchar2
828   ,p_rec            in out nocopy ben_otp_shd.g_rec_type
829   ) is
830 --
831   l_proc			varchar2(72) := g_package||'upd';
832   l_validation_start_date	date;
833   l_validation_end_date		date;
834 --
835 Begin
836   hr_utility.set_location('Entering:'||l_proc, 5);
837   --
838   -- Ensure that the DateTrack update mode is valid
839   --
840   dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode);
841   --
842   -- We must lock the row which we need to update.
843   --
844   ben_otp_shd.lck
845     (p_effective_date                   => p_effective_date
846     ,p_datetrack_mode                   => p_datetrack_mode
847     ,p_optip_id                         => p_rec.optip_id
848     ,p_object_version_number            => p_rec.object_version_number
849     ,p_validation_start_date            => l_validation_start_date
850     ,p_validation_end_date              => l_validation_end_date
851     );
852   --
853   -- 1. During an update system defaults are used to determine if
854   --    arguments have been defaulted or not. We must therefore
855   --    derive the full record structure values to be updated.
856   --
857   -- 2. Call the supporting update validate operations.
858   --
859   ben_otp_upd.convert_defs(p_rec);
860   --
861   ben_otp_bus.update_validate
862     (p_rec                              => p_rec
863     ,p_effective_date                   => p_effective_date
864     ,p_datetrack_mode                   => p_datetrack_mode
865     ,p_validation_start_date            => l_validation_start_date
866     ,p_validation_end_date              => l_validation_end_date
867     );
868   --
869   -- Call the supporting pre-update operation
870   --
871   pre_update
872     (p_rec                              => p_rec
873     ,p_effective_date                   => p_effective_date
874     ,p_datetrack_mode                   => p_datetrack_mode
875     ,p_validation_start_date            => l_validation_start_date
876     ,p_validation_end_date              => l_validation_end_date
877     );
878   --
879   -- Update the row.
880   --
881   update_dml
882     (p_rec                              => p_rec
883     ,p_effective_date                   => p_effective_date
884     ,p_datetrack_mode                   => p_datetrack_mode
885     ,p_validation_start_date            => l_validation_start_date
886     ,p_validation_end_date	            => l_validation_end_date
887     );
888   --
889   -- Call the supporting post-update operation
890   --
891   post_update
892     (p_rec                              => p_rec
893     ,p_effective_date                   => p_effective_date
894     ,p_datetrack_mode                   => p_datetrack_mode
895     ,p_validation_start_date            => l_validation_start_date
896     ,p_validation_end_date              => l_validation_end_date
897     );
898 End upd;
899 --
900 -- ----------------------------------------------------------------------------
901 -- |------------------------------< upd >-------------------------------------|
902 -- ----------------------------------------------------------------------------
903 Procedure upd
904   (p_effective_date               in     date
905   ,p_datetrack_mode               in     varchar2
906   ,p_optip_id                     in     number
907   ,p_object_version_number        in out nocopy number
908   ,p_business_group_id            in     number    default hr_api.g_number
909   ,p_pgm_id                       in     number    default hr_api.g_number
910   ,p_ptip_id                      in     number    default hr_api.g_number
911   ,p_pl_typ_id                    in     number    default hr_api.g_number
912   ,p_opt_id                       in     number    default hr_api.g_number
913   ,p_cmbn_ptip_opt_id             in     number    default hr_api.g_number
914   ,p_legislation_code       in     varchar2  default hr_api.g_varchar2
915   ,p_legislation_subgroup       in     varchar2  default hr_api.g_varchar2
916   ,p_otp_attribute_category       in     varchar2  default hr_api.g_varchar2
917   ,p_otp_attribute1               in     varchar2  default hr_api.g_varchar2
918   ,p_otp_attribute2               in     varchar2  default hr_api.g_varchar2
919   ,p_otp_attribute3               in     varchar2  default hr_api.g_varchar2
920   ,p_otp_attribute4               in     varchar2  default hr_api.g_varchar2
921   ,p_otp_attribute5               in     varchar2  default hr_api.g_varchar2
922   ,p_otp_attribute6               in     varchar2  default hr_api.g_varchar2
923   ,p_otp_attribute7               in     varchar2  default hr_api.g_varchar2
924   ,p_otp_attribute8               in     varchar2  default hr_api.g_varchar2
925   ,p_otp_attribute9               in     varchar2  default hr_api.g_varchar2
926   ,p_otp_attribute10              in     varchar2  default hr_api.g_varchar2
927   ,p_otp_attribute11              in     varchar2  default hr_api.g_varchar2
928   ,p_otp_attribute12              in     varchar2  default hr_api.g_varchar2
929   ,p_otp_attribute13              in     varchar2  default hr_api.g_varchar2
930   ,p_otp_attribute14              in     varchar2  default hr_api.g_varchar2
931   ,p_otp_attribute15              in     varchar2  default hr_api.g_varchar2
932   ,p_otp_attribute16              in     varchar2  default hr_api.g_varchar2
933   ,p_otp_attribute17              in     varchar2  default hr_api.g_varchar2
934   ,p_otp_attribute18              in     varchar2  default hr_api.g_varchar2
935   ,p_otp_attribute19              in     varchar2  default hr_api.g_varchar2
936   ,p_otp_attribute20              in     varchar2  default hr_api.g_varchar2
937   ,p_otp_attribute21              in     varchar2  default hr_api.g_varchar2
938   ,p_otp_attribute22              in     varchar2  default hr_api.g_varchar2
939   ,p_otp_attribute23              in     varchar2  default hr_api.g_varchar2
940   ,p_otp_attribute24              in     varchar2  default hr_api.g_varchar2
941   ,p_otp_attribute25              in     varchar2  default hr_api.g_varchar2
942   ,p_otp_attribute26              in     varchar2  default hr_api.g_varchar2
943   ,p_otp_attribute27              in     varchar2  default hr_api.g_varchar2
944   ,p_otp_attribute28              in     varchar2  default hr_api.g_varchar2
945   ,p_otp_attribute29              in     varchar2  default hr_api.g_varchar2
946   ,p_otp_attribute30              in     varchar2  default hr_api.g_varchar2
947   ,p_effective_start_date            out nocopy date
948   ,p_effective_end_date              out nocopy date
949   ) is
950 --
951   l_rec		ben_otp_shd.g_rec_type;
952   l_proc	varchar2(72) := g_package||'upd';
953 --
954 Begin
955   hr_utility.set_location('Entering:'||l_proc, 5);
956   --
957   -- Call conversion function to turn arguments into the
958   -- l_rec structure.
959   --
960   l_rec :=
961   ben_otp_shd.convert_args
962     (p_optip_id
963     ,null
964     ,null
965     ,p_business_group_id
966     ,p_pgm_id
967     ,p_ptip_id
968     ,p_pl_typ_id
969     ,p_opt_id
970     ,p_cmbn_ptip_opt_id
971     ,p_legislation_code
972     ,p_legislation_subgroup
973     ,p_otp_attribute_category
974     ,p_otp_attribute1
975     ,p_otp_attribute2
976     ,p_otp_attribute3
977     ,p_otp_attribute4
978     ,p_otp_attribute5
979     ,p_otp_attribute6
980     ,p_otp_attribute7
981     ,p_otp_attribute8
982     ,p_otp_attribute9
983     ,p_otp_attribute10
984     ,p_otp_attribute11
985     ,p_otp_attribute12
986     ,p_otp_attribute13
987     ,p_otp_attribute14
988     ,p_otp_attribute15
989     ,p_otp_attribute16
990     ,p_otp_attribute17
991     ,p_otp_attribute18
992     ,p_otp_attribute19
993     ,p_otp_attribute20
994     ,p_otp_attribute21
995     ,p_otp_attribute22
996     ,p_otp_attribute23
997     ,p_otp_attribute24
998     ,p_otp_attribute25
999     ,p_otp_attribute26
1000     ,p_otp_attribute27
1001     ,p_otp_attribute28
1002     ,p_otp_attribute29
1003     ,p_otp_attribute30
1004     ,p_object_version_number
1005     );
1006   --
1007   -- Having converted the arguments into the
1008   -- plsql record structure we call the corresponding record
1009   -- business process.
1010   --
1011   ben_otp_upd.upd
1012     (p_effective_date
1013     ,p_datetrack_mode
1014     ,l_rec
1015     );
1016   --
1017   -- Set the out parameters
1018   --
1019   p_object_version_number            := l_rec.object_version_number;
1020   p_effective_start_date             := l_rec.effective_start_date;
1021   p_effective_end_date               := l_rec.effective_end_date;
1022   --
1023   --
1024   hr_utility.set_location(' Leaving:'||l_proc, 10);
1025 End upd;
1026 --
1027 end ben_otp_upd;