DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PRG_UPD

Source


1 Package Body ben_prg_upd as
2 /* $Header: beprgrhi.pkb 120.1 2008/02/05 09:42:42 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_prg_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 structre.
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_prg_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) is
63 --
64   l_proc	varchar2(72) := g_package||'dt_update_dml';
65 --
66 Begin
67   hr_utility.set_location('Entering:'||l_proc, 5);
68   --
69   If (p_datetrack_mode = 'CORRECTION') then
70     hr_utility.set_location(l_proc, 10);
71     --
72     -- Because we are updating a row we must get the next object
73     -- version number.
74     --
75     p_rec.object_version_number :=
76       dt_api.get_object_version_number
77 	  (p_base_table_name	=> 'ben_pl_regn_f',
78 	   p_base_key_column	=> 'pl_regn_id',
79 	   p_base_key_value	=> p_rec.pl_regn_id);
80     --
81     ben_prg_shd.g_api_dml := true;  -- Set the api dml status
82     --
83     -- Update the ben_pl_regn_f Row
84     --
85     update  ben_pl_regn_f
86     set
87     pl_regn_id                      = p_rec.pl_regn_id,
88     business_group_id               = p_rec.business_group_id,
89     regn_id                         = p_rec.regn_id,
90     pl_id                           = p_rec.pl_id,
91     rptg_grp_id                     = p_rec.rptg_grp_id,
92     hghly_compd_det_rl              = p_rec.hghly_compd_det_rl,
93     key_ee_det_rl                   = p_rec.key_ee_det_rl,
94     cntr_nndscrn_rl                 = p_rec.cntr_nndscrn_rl,
95     cvg_nndscrn_rl                  = p_rec.cvg_nndscrn_rl,
96     five_pct_ownr_rl                = p_rec.five_pct_ownr_rl,
97     regy_pl_typ_cd                  = p_rec.regy_pl_typ_cd,
98     prg_attribute_category          = p_rec.prg_attribute_category,
99     prg_attribute1                  = p_rec.prg_attribute1,
100     prg_attribute2                  = p_rec.prg_attribute2,
101     prg_attribute3                  = p_rec.prg_attribute3,
102     prg_attribute4                  = p_rec.prg_attribute4,
103     prg_attribute5                  = p_rec.prg_attribute5,
104     prg_attribute6                  = p_rec.prg_attribute6,
105     prg_attribute7                  = p_rec.prg_attribute7,
106     prg_attribute8                  = p_rec.prg_attribute8,
107     prg_attribute9                  = p_rec.prg_attribute9,
108     prg_attribute10                 = p_rec.prg_attribute10,
109     prg_attribute11                 = p_rec.prg_attribute11,
110     prg_attribute12                 = p_rec.prg_attribute12,
111     prg_attribute13                 = p_rec.prg_attribute13,
112     prg_attribute14                 = p_rec.prg_attribute14,
113     prg_attribute15                 = p_rec.prg_attribute15,
114     prg_attribute16                 = p_rec.prg_attribute16,
115     prg_attribute17                 = p_rec.prg_attribute17,
116     prg_attribute18                 = p_rec.prg_attribute18,
117     prg_attribute19                 = p_rec.prg_attribute19,
118     prg_attribute20                 = p_rec.prg_attribute20,
119     prg_attribute21                 = p_rec.prg_attribute21,
120     prg_attribute22                 = p_rec.prg_attribute22,
121     prg_attribute23                 = p_rec.prg_attribute23,
122     prg_attribute24                 = p_rec.prg_attribute24,
123     prg_attribute25                 = p_rec.prg_attribute25,
124     prg_attribute26                 = p_rec.prg_attribute26,
125     prg_attribute27                 = p_rec.prg_attribute27,
126     prg_attribute28                 = p_rec.prg_attribute28,
127     prg_attribute29                 = p_rec.prg_attribute29,
128     prg_attribute30                 = p_rec.prg_attribute30,
129     object_version_number           = p_rec.object_version_number
130     where   pl_regn_id = p_rec.pl_regn_id
131     and     effective_start_date = p_validation_start_date
132     and     effective_end_date   = p_validation_end_date;
133     --
134     ben_prg_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_prg_shd.g_api_dml := false;   -- Unset the api dml status
147     ben_prg_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_prg_shd.g_api_dml := false;   -- Unset the api dml status
152     ben_prg_shd.constraint_error
153       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
154   When Others Then
155     ben_prg_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_prg_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) is
196 --
197   l_proc	varchar2(72) := g_package||'update_dml';
198 --
199 Begin
200   hr_utility.set_location('Entering:'||l_proc, 5);
201   --
202   dt_update_dml(p_rec			=> p_rec,
203 		p_effective_date	=> p_effective_date,
204 		p_datetrack_mode	=> p_datetrack_mode,
205        		p_validation_start_date	=> p_validation_start_date,
206 		p_validation_end_date	=> p_validation_end_date);
207   --
208   hr_utility.set_location(' Leaving:'||l_proc, 10);
209 End update_dml;
210 --
211 -- ----------------------------------------------------------------------------
212 -- |----------------------------< dt_pre_update >-----------------------------|
213 -- ----------------------------------------------------------------------------
214 -- {Start Of Comments}
215 --
216 -- Description:
217 --   The dt_pre_update procedure controls the execution
218 --   of dml for the datetrack modes of: UPDATE, UPDATE_OVERRIDE
219 --   and UPDATE_CHANGE_INSERT only. The execution required is as
220 --   follows:
221 --
222 --   1) Providing the datetrack update mode is not 'CORRECTION'
223 --      then set the effective end date of the current row (this
224 --      will be the validation_start_date - 1).
225 --   2) If the datetrack mode is 'UPDATE_OVERRIDE' then call the
226 --      corresponding delete_dml process to delete any future rows
227 --      where the effective_start_date is greater than or equal to
228 --	the validation_start_date.
229 --   3) Call the insert_dml process to insert the new updated row
230 --      details..
231 --
232 -- Prerequisites:
233 --   This is an internal procedure which is called from the
234 --   pre_update procedure.
235 --
236 -- In Parameters:
237 --
238 -- Post Success:
239 --   Processing continues.
240 --
241 -- Post Failure:
242 --   If an error has occurred, an error message and exception will be raised
243 --   but not handled.
244 --
245 -- Developer Implementation Notes:
246 --   This is an internal procedure which is required by Datetrack. Don't
247 --   remove or modify.
248 --
249 -- Access Status:
250 --   Internal Row Handler Use Only.
251 --
252 -- {End Of Comments}
253 -- ----------------------------------------------------------------------------
254 Procedure dt_pre_update
255 	(p_rec 			 in out nocopy ben_prg_shd.g_rec_type,
256 	 p_effective_date	 in	date,
257 	 p_datetrack_mode	 in	varchar2,
258 	 p_validation_start_date in	date,
259 	 p_validation_end_date	 in	date) is
260 --
261   l_proc	         varchar2(72) := g_package||'dt_pre_update';
262   l_dummy_version_number number;
263 --
264 Begin
265   hr_utility.set_location('Entering:'||l_proc, 5);
266   If (p_datetrack_mode <> 'CORRECTION') then
267     hr_utility.set_location(l_proc, 10);
268     --
269     -- Update the current effective end date
270     --
271     ben_prg_shd.upd_effective_end_date
272      (p_effective_date	       => p_effective_date,
273       p_base_key_value	       => p_rec.pl_regn_id,
274       p_new_effective_end_date => (p_validation_start_date - 1),
275       p_validation_start_date  => p_validation_start_date,
276       p_validation_end_date    => p_validation_end_date,
277       p_object_version_number  => l_dummy_version_number);
278     --
279     If (p_datetrack_mode = 'UPDATE_OVERRIDE') then
280       hr_utility.set_location(l_proc, 15);
281       --
282       -- As the datetrack mode is 'UPDATE_OVERRIDE' then we must
283       -- delete any future rows
284       --
285       ben_prg_del.delete_dml
286         (p_rec			 => p_rec,
287 	 p_effective_date	 => p_effective_date,
288 	 p_datetrack_mode	 => p_datetrack_mode,
289 	 p_validation_start_date => p_validation_start_date,
290 	 p_validation_end_date   => p_validation_end_date);
291     End If;
292     hr_utility.set_location(l_proc, 20);
293     --
294     -- We must now insert the updated row
295     --
296     ben_prg_ins.insert_dml
297       (p_rec			=> p_rec,
298        p_effective_date		=> p_effective_date,
299        p_datetrack_mode		=> p_datetrack_mode,
300        p_validation_start_date	=> p_validation_start_date,
301        p_validation_end_date	=> p_validation_end_date);
302   End If;
303   hr_utility.set_location(' Leaving:'||l_proc, 20);
304 End dt_pre_update;
305 --
306 -- ----------------------------------------------------------------------------
307 -- |------------------------------< pre_update >------------------------------|
308 -- ----------------------------------------------------------------------------
309 -- {Start Of Comments}
310 --
311 -- Description:
312 --   This private procedure contains any processing which is required before
313 --   the update dml.
314 --
315 -- Prerequisites:
316 --   This is an internal procedure which is called from the upd procedure.
317 --
318 -- In Parameters:
319 --   A Pl/Sql record structre.
320 --
321 -- Post Success:
322 --   Processing continues.
323 --
324 -- Post Failure:
325 --   If an error has occurred, an error message and exception will be raised
326 --   but not handled.
327 --
328 -- Developer Implementation Notes:
329 --   Any pre-processing required before the update dml is issued should be
330 --   coded within this procedure. It is important to note that any 3rd party
331 --   maintenance should be reviewed before placing in this procedure. The call
332 --   to the dt_update_dml procedure should NOT be removed.
333 --
334 -- Access Status:
335 --   Internal Row Handler Use Only.
336 --
337 -- {End Of Comments}
338 -- ----------------------------------------------------------------------------
339 Procedure pre_update
340 	(p_rec 			 in out nocopy ben_prg_shd.g_rec_type,
341 	 p_effective_date	 in	date,
342 	 p_datetrack_mode	 in	varchar2,
343 	 p_validation_start_date in	date,
344 	 p_validation_end_date	 in	date) is
345 --
346   l_proc	varchar2(72) := g_package||'pre_update';
347 --
348 Begin
349   hr_utility.set_location('Entering:'||l_proc, 5);
350   --
351   --
352   --
353   dt_pre_update
354     (p_rec 		     => p_rec,
355      p_effective_date	     => p_effective_date,
356      p_datetrack_mode	     => p_datetrack_mode,
357      p_validation_start_date => p_validation_start_date,
358      p_validation_end_date   => p_validation_end_date);
359   --
360   hr_utility.set_location(' Leaving:'||l_proc, 10);
361 End pre_update;
362 --
363 -- ----------------------------------------------------------------------------
364 -- |-----------------------------< post_update >------------------------------|
365 -- ----------------------------------------------------------------------------
366 -- {Start Of Comments}
367 --
368 -- Description:
369 --   This private procedure contains any processing which is required after the
370 --   update dml.
371 --
372 -- Prerequisites:
373 --   This is an internal procedure which is called from the upd procedure.
374 --
375 -- In Parameters:
376 --   A Pl/Sql record structre.
377 --
378 -- Post Success:
379 --   Processing continues.
380 --
381 -- Post Failure:
382 --   If an error has occurred, an error message and exception will be raised
383 --   but not handled.
384 --
385 -- Developer Implementation Notes:
386 --   Any post-processing required after the update dml is issued should be
387 --   coded within this procedure. It is important to note that any 3rd party
388 --   maintenance should be reviewed before placing in this procedure.
389 --
390 -- Access Status:
391 --   Internal Row Handler Use Only.
392 --
393 -- {End Of Comments}
394 -- ----------------------------------------------------------------------------
395 Procedure post_update
396 	(p_rec 			 in ben_prg_shd.g_rec_type,
397 	 p_effective_date	 in date,
398 	 p_datetrack_mode	 in varchar2,
399 	 p_validation_start_date in date,
400 	 p_validation_end_date	 in date) is
401 --
402   l_proc	varchar2(72) := g_package||'post_update';
403 --
404 Begin
405   hr_utility.set_location('Entering:'||l_proc, 5);
406   --
407   -- Start of API User Hook for post_update.
408   --
409   begin
410     --
411     ben_prg_rku.after_update
412       (
413       p_pl_regn_id               => p_rec.pl_regn_id
414      ,p_effective_end_date       => p_rec.effective_start_date
415      ,p_effective_start_date     => p_rec.effective_end_date
416      ,p_business_group_id        => p_rec.business_group_id
417      ,p_regn_id                  => p_rec.regn_id
418      ,p_pl_id                    => p_rec.pl_id
419      ,p_rptg_grp_id              => p_rec.rptg_grp_id
420      ,p_hghly_compd_det_rl       => p_rec.hghly_compd_det_rl
421      ,p_key_ee_det_rl            => p_rec.key_ee_det_rl
422      ,p_cntr_nndscrn_rl          => p_rec.cntr_nndscrn_rl
423      ,p_cvg_nndscrn_rl           => p_rec.cvg_nndscrn_rl
424      ,p_five_pct_ownr_rl         => p_rec.five_pct_ownr_rl
425      ,p_regy_pl_typ_cd           => p_rec.regy_pl_typ_cd
426      ,p_prg_attribute_category   => p_rec.prg_attribute_category
427      ,p_prg_attribute1           => p_rec.prg_attribute1
428      ,p_prg_attribute2           => p_rec.prg_attribute2
429      ,p_prg_attribute3           => p_rec.prg_attribute3
430      ,p_prg_attribute4           => p_rec.prg_attribute4
431      ,p_prg_attribute5           => p_rec.prg_attribute5
432      ,p_prg_attribute6           => p_rec.prg_attribute6
433      ,p_prg_attribute7           => p_rec.prg_attribute7
434      ,p_prg_attribute8           => p_rec.prg_attribute8
435      ,p_prg_attribute9           => p_rec.prg_attribute9
436      ,p_prg_attribute10          => p_rec.prg_attribute10
437      ,p_prg_attribute11          => p_rec.prg_attribute11
438      ,p_prg_attribute12          => p_rec.prg_attribute12
439      ,p_prg_attribute13          => p_rec.prg_attribute13
440      ,p_prg_attribute14          => p_rec.prg_attribute14
441      ,p_prg_attribute15          => p_rec.prg_attribute15
442      ,p_prg_attribute16          => p_rec.prg_attribute16
443      ,p_prg_attribute17          => p_rec.prg_attribute17
444      ,p_prg_attribute18          => p_rec.prg_attribute18
445      ,p_prg_attribute19          => p_rec.prg_attribute19
446      ,p_prg_attribute20          => p_rec.prg_attribute20
447      ,p_prg_attribute21          => p_rec.prg_attribute21
448      ,p_prg_attribute22          => p_rec.prg_attribute22
449      ,p_prg_attribute23          => p_rec.prg_attribute23
450      ,p_prg_attribute24          => p_rec.prg_attribute24
451      ,p_prg_attribute25          => p_rec.prg_attribute25
452      ,p_prg_attribute26          => p_rec.prg_attribute26
453      ,p_prg_attribute27          => p_rec.prg_attribute27
454      ,p_prg_attribute28          => p_rec.prg_attribute28
455      ,p_prg_attribute29          => p_rec.prg_attribute29
456      ,p_prg_attribute30          => p_rec.prg_attribute30
457      ,p_object_version_number    => p_rec.object_version_number
458      ,p_effective_date           => p_effective_date
459      ,p_datetrack_mode           => p_datetrack_mode
460      ,p_validation_start_date    => p_validation_start_date
461      ,p_validation_end_date      => p_validation_end_date
462      ,p_effective_end_date_o     => ben_prg_shd.g_old_rec.effective_end_date
463      ,p_effective_start_date_o   => ben_prg_shd.g_old_rec.effective_start_date
464      ,p_business_group_id_o      => ben_prg_shd.g_old_rec.business_group_id
465      ,p_regn_id_o                => ben_prg_shd.g_old_rec.regn_id
466      ,p_pl_id_o                  => ben_prg_shd.g_old_rec.pl_id
467      ,p_rptg_grp_id_o            => ben_prg_shd.g_old_rec.rptg_grp_id
468      ,p_hghly_compd_det_rl_o     => ben_prg_shd.g_old_rec.hghly_compd_det_rl
469      ,p_key_ee_det_rl_o          => ben_prg_shd.g_old_rec.key_ee_det_rl
470      ,p_cntr_nndscrn_rl_o        => ben_prg_shd.g_old_rec.cntr_nndscrn_rl
471      ,p_cvg_nndscrn_rl_o         => ben_prg_shd.g_old_rec.cvg_nndscrn_rl
472      ,p_five_pct_ownr_rl_o       => ben_prg_shd.g_old_rec.five_pct_ownr_rl
473      ,p_regy_pl_typ_cd_o         => ben_prg_shd.g_old_rec.regy_pl_typ_cd
474      ,p_prg_attribute_category_o => ben_prg_shd.g_old_rec.prg_attribute_category
475      ,p_prg_attribute1_o         => ben_prg_shd.g_old_rec.prg_attribute1
476      ,p_prg_attribute2_o         => ben_prg_shd.g_old_rec.prg_attribute2
477      ,p_prg_attribute3_o         => ben_prg_shd.g_old_rec.prg_attribute3
478      ,p_prg_attribute4_o         => ben_prg_shd.g_old_rec.prg_attribute4
479      ,p_prg_attribute5_o         => ben_prg_shd.g_old_rec.prg_attribute5
480      ,p_prg_attribute6_o         => ben_prg_shd.g_old_rec.prg_attribute6
481      ,p_prg_attribute7_o         => ben_prg_shd.g_old_rec.prg_attribute7
482      ,p_prg_attribute8_o         => ben_prg_shd.g_old_rec.prg_attribute8
483      ,p_prg_attribute9_o         => ben_prg_shd.g_old_rec.prg_attribute9
484      ,p_prg_attribute10_o        => ben_prg_shd.g_old_rec.prg_attribute10
485      ,p_prg_attribute11_o        => ben_prg_shd.g_old_rec.prg_attribute11
486      ,p_prg_attribute12_o        => ben_prg_shd.g_old_rec.prg_attribute12
487      ,p_prg_attribute13_o        => ben_prg_shd.g_old_rec.prg_attribute13
488      ,p_prg_attribute14_o        => ben_prg_shd.g_old_rec.prg_attribute14
489      ,p_prg_attribute15_o        => ben_prg_shd.g_old_rec.prg_attribute15
490      ,p_prg_attribute16_o        => ben_prg_shd.g_old_rec.prg_attribute16
491      ,p_prg_attribute17_o        => ben_prg_shd.g_old_rec.prg_attribute17
492      ,p_prg_attribute18_o        => ben_prg_shd.g_old_rec.prg_attribute18
493      ,p_prg_attribute19_o        => ben_prg_shd.g_old_rec.prg_attribute19
494      ,p_prg_attribute20_o        => ben_prg_shd.g_old_rec.prg_attribute20
495      ,p_prg_attribute21_o        => ben_prg_shd.g_old_rec.prg_attribute21
496      ,p_prg_attribute22_o        => ben_prg_shd.g_old_rec.prg_attribute22
497      ,p_prg_attribute23_o        => ben_prg_shd.g_old_rec.prg_attribute23
498      ,p_prg_attribute24_o        => ben_prg_shd.g_old_rec.prg_attribute24
499      ,p_prg_attribute25_o        => ben_prg_shd.g_old_rec.prg_attribute25
500      ,p_prg_attribute26_o        => ben_prg_shd.g_old_rec.prg_attribute26
501      ,p_prg_attribute27_o        => ben_prg_shd.g_old_rec.prg_attribute27
502      ,p_prg_attribute28_o        => ben_prg_shd.g_old_rec.prg_attribute28
503      ,p_prg_attribute29_o        => ben_prg_shd.g_old_rec.prg_attribute29
504      ,p_prg_attribute30_o        => ben_prg_shd.g_old_rec.prg_attribute30
505      ,p_object_version_number_o  => ben_prg_shd.g_old_rec.object_version_number
506      );
507     --
508   exception
509     --
510     when hr_api.cannot_find_prog_unit then
511       --
512       hr_api.cannot_find_prog_unit_error
513         (p_module_name => 'ben_pl_regn_f'
514         ,p_hook_type   => 'AU');
515       --
516   end;
517   --
518   -- End of API User Hook for post_update.
519   --
520   hr_utility.set_location(' Leaving:'||l_proc, 10);
521 End post_update;
522 --
523 -- ----------------------------------------------------------------------------
524 -- |-----------------------------< convert_defs >-----------------------------|
525 -- ----------------------------------------------------------------------------
526 -- {Start Of Comments}
527 --
528 -- Description:
529 --   The Convert_Defs procedure has one very important function:
530 --   It must return the record structure for the row with all system defaulted
531 --   values converted into its corresponding parameter value for update. When
532 --   we attempt to update a row through the Upd process , certain
533 --   parameters can be defaulted which enables flexibility in the calling of
534 --   the upd process (e.g. only attributes which need to be updated need to be
535 --   specified). For the upd process to determine which attributes
536 --   have NOT been specified we need to check if the parameter has a reserved
537 --   system default value. Therefore, for all parameters which have a
538 --   corresponding reserved system default mechanism specified we need to
539 --   check if a system default is being used. If a system default is being
540 --   used then we convert the defaulted value into its corresponding attribute
541 --   value held in the g_old_rec data structure.
542 --
543 -- Prerequisites:
544 --   This private function can only be called from the upd process.
545 --
546 -- In Parameters:
547 --   A Pl/Sql record structre.
548 --
549 -- Post Success:
550 --   The record structure will be returned with all system defaulted parameter
551 --   values converted into its current row attribute value.
552 --
553 -- Post Failure:
554 --   No direct error handling is required within this function. Any possible
555 --   errors within this procedure will be a PL/SQL value error due to conversion
556 --   of datatypes or data lengths.
557 --
558 -- Developer Implementation Notes:
559 --   None.
560 --
561 -- Access Status:
562 --   Internal Row Handler Use Only.
563 --
564 -- {End Of Comments}
565 -- ----------------------------------------------------------------------------
566 Procedure convert_defs(p_rec in out nocopy ben_prg_shd.g_rec_type) is
567 --
568   l_proc  varchar2(72) := g_package||'convert_defs';
569 --
570 Begin
571   --
572   hr_utility.set_location('Entering:'||l_proc, 5);
573   --
574   -- We must now examine each argument value in the
575   -- p_rec plsql record structure
576   -- to see if a system default is being used. If a system default
577   -- is being used then we must set to the 'current' argument value.
578   --
579   If (p_rec.business_group_id = hr_api.g_number) then
580     p_rec.business_group_id :=
581     ben_prg_shd.g_old_rec.business_group_id;
582   End If;
583   If (p_rec.regn_id = hr_api.g_number) then
584     p_rec.regn_id :=
585     ben_prg_shd.g_old_rec.regn_id;
586   End If;
587   If (p_rec.pl_id = hr_api.g_number) then
588     p_rec.pl_id :=
589     ben_prg_shd.g_old_rec.pl_id;
590   End If;
591   If (p_rec.rptg_grp_id = hr_api.g_number) then
592     p_rec.rptg_grp_id :=
593     ben_prg_shd.g_old_rec.rptg_grp_id;
594   End If;
595   If (p_rec.hghly_compd_det_rl = hr_api.g_number) then
596     p_rec.hghly_compd_det_rl :=
597     ben_prg_shd.g_old_rec.hghly_compd_det_rl;
598   End If;
599   If (p_rec.key_ee_det_rl = hr_api.g_number) then
600     p_rec.key_ee_det_rl :=
601     ben_prg_shd.g_old_rec.key_ee_det_rl;
602   End If;
603   If (p_rec.cntr_nndscrn_rl = hr_api.g_number) then
604     p_rec.cntr_nndscrn_rl :=
605     ben_prg_shd.g_old_rec.cntr_nndscrn_rl;
606   End If;
607   If (p_rec.cvg_nndscrn_rl = hr_api.g_number) then
608     p_rec.cvg_nndscrn_rl :=
609     ben_prg_shd.g_old_rec.cvg_nndscrn_rl;
610   End If;
611   If (p_rec.five_pct_ownr_rl = hr_api.g_number) then
612     p_rec.five_pct_ownr_rl :=
613     ben_prg_shd.g_old_rec.five_pct_ownr_rl;
614   End If;
615   If (p_rec.regy_pl_typ_cd = hr_api.g_varchar2) then
616     p_rec.regy_pl_typ_cd :=
617     ben_prg_shd.g_old_rec.regy_pl_typ_cd;
618   End If;
619   If (p_rec.prg_attribute_category = hr_api.g_varchar2) then
620     p_rec.prg_attribute_category :=
621     ben_prg_shd.g_old_rec.prg_attribute_category;
622   End If;
623   If (p_rec.prg_attribute1 = hr_api.g_varchar2) then
624     p_rec.prg_attribute1 :=
625     ben_prg_shd.g_old_rec.prg_attribute1;
626   End If;
627   If (p_rec.prg_attribute2 = hr_api.g_varchar2) then
628     p_rec.prg_attribute2 :=
629     ben_prg_shd.g_old_rec.prg_attribute2;
630   End If;
631   If (p_rec.prg_attribute3 = hr_api.g_varchar2) then
632     p_rec.prg_attribute3 :=
633     ben_prg_shd.g_old_rec.prg_attribute3;
634   End If;
635   If (p_rec.prg_attribute4 = hr_api.g_varchar2) then
636     p_rec.prg_attribute4 :=
637     ben_prg_shd.g_old_rec.prg_attribute4;
638   End If;
639   If (p_rec.prg_attribute5 = hr_api.g_varchar2) then
640     p_rec.prg_attribute5 :=
641     ben_prg_shd.g_old_rec.prg_attribute5;
642   End If;
643   If (p_rec.prg_attribute6 = hr_api.g_varchar2) then
644     p_rec.prg_attribute6 :=
645     ben_prg_shd.g_old_rec.prg_attribute6;
646   End If;
647   If (p_rec.prg_attribute7 = hr_api.g_varchar2) then
648     p_rec.prg_attribute7 :=
649     ben_prg_shd.g_old_rec.prg_attribute7;
650   End If;
651   If (p_rec.prg_attribute8 = hr_api.g_varchar2) then
652     p_rec.prg_attribute8 :=
653     ben_prg_shd.g_old_rec.prg_attribute8;
654   End If;
655   If (p_rec.prg_attribute9 = hr_api.g_varchar2) then
656     p_rec.prg_attribute9 :=
657     ben_prg_shd.g_old_rec.prg_attribute9;
658   End If;
659   If (p_rec.prg_attribute10 = hr_api.g_varchar2) then
660     p_rec.prg_attribute10 :=
661     ben_prg_shd.g_old_rec.prg_attribute10;
662   End If;
663   If (p_rec.prg_attribute11 = hr_api.g_varchar2) then
664     p_rec.prg_attribute11 :=
665     ben_prg_shd.g_old_rec.prg_attribute11;
666   End If;
667   If (p_rec.prg_attribute12 = hr_api.g_varchar2) then
668     p_rec.prg_attribute12 :=
669     ben_prg_shd.g_old_rec.prg_attribute12;
670   End If;
671   If (p_rec.prg_attribute13 = hr_api.g_varchar2) then
672     p_rec.prg_attribute13 :=
673     ben_prg_shd.g_old_rec.prg_attribute13;
674   End If;
675   If (p_rec.prg_attribute14 = hr_api.g_varchar2) then
676     p_rec.prg_attribute14 :=
677     ben_prg_shd.g_old_rec.prg_attribute14;
678   End If;
679   If (p_rec.prg_attribute15 = hr_api.g_varchar2) then
680     p_rec.prg_attribute15 :=
681     ben_prg_shd.g_old_rec.prg_attribute15;
682   End If;
683   If (p_rec.prg_attribute16 = hr_api.g_varchar2) then
684     p_rec.prg_attribute16 :=
685     ben_prg_shd.g_old_rec.prg_attribute16;
686   End If;
687   If (p_rec.prg_attribute17 = hr_api.g_varchar2) then
688     p_rec.prg_attribute17 :=
689     ben_prg_shd.g_old_rec.prg_attribute17;
690   End If;
691   If (p_rec.prg_attribute18 = hr_api.g_varchar2) then
692     p_rec.prg_attribute18 :=
693     ben_prg_shd.g_old_rec.prg_attribute18;
694   End If;
695   If (p_rec.prg_attribute19 = hr_api.g_varchar2) then
696     p_rec.prg_attribute19 :=
697     ben_prg_shd.g_old_rec.prg_attribute19;
698   End If;
699   If (p_rec.prg_attribute20 = hr_api.g_varchar2) then
700     p_rec.prg_attribute20 :=
701     ben_prg_shd.g_old_rec.prg_attribute20;
702   End If;
703   If (p_rec.prg_attribute21 = hr_api.g_varchar2) then
704     p_rec.prg_attribute21 :=
705     ben_prg_shd.g_old_rec.prg_attribute21;
706   End If;
707   If (p_rec.prg_attribute22 = hr_api.g_varchar2) then
708     p_rec.prg_attribute22 :=
709     ben_prg_shd.g_old_rec.prg_attribute22;
710   End If;
711   If (p_rec.prg_attribute23 = hr_api.g_varchar2) then
712     p_rec.prg_attribute23 :=
713     ben_prg_shd.g_old_rec.prg_attribute23;
714   End If;
715   If (p_rec.prg_attribute24 = hr_api.g_varchar2) then
716     p_rec.prg_attribute24 :=
717     ben_prg_shd.g_old_rec.prg_attribute24;
718   End If;
719   If (p_rec.prg_attribute25 = hr_api.g_varchar2) then
720     p_rec.prg_attribute25 :=
721     ben_prg_shd.g_old_rec.prg_attribute25;
722   End If;
723   If (p_rec.prg_attribute26 = hr_api.g_varchar2) then
724     p_rec.prg_attribute26 :=
725     ben_prg_shd.g_old_rec.prg_attribute26;
726   End If;
727   If (p_rec.prg_attribute27 = hr_api.g_varchar2) then
728     p_rec.prg_attribute27 :=
729     ben_prg_shd.g_old_rec.prg_attribute27;
730   End If;
731   If (p_rec.prg_attribute28 = hr_api.g_varchar2) then
732     p_rec.prg_attribute28 :=
733     ben_prg_shd.g_old_rec.prg_attribute28;
734   End If;
735   If (p_rec.prg_attribute29 = hr_api.g_varchar2) then
736     p_rec.prg_attribute29 :=
737     ben_prg_shd.g_old_rec.prg_attribute29;
738   End If;
739   If (p_rec.prg_attribute30 = hr_api.g_varchar2) then
740     p_rec.prg_attribute30 :=
741     ben_prg_shd.g_old_rec.prg_attribute30;
742   End If;
743 
744   --
745   hr_utility.set_location(' Leaving:'||l_proc, 10);
746 --
747 End convert_defs;
748 --
749 -- ----------------------------------------------------------------------------
750 -- |---------------------------------< upd >----------------------------------|
751 -- ----------------------------------------------------------------------------
752 Procedure upd
753   (
754   p_rec			in out nocopy 	ben_prg_shd.g_rec_type,
755   p_effective_date	in 	date,
756   p_datetrack_mode	in 	varchar2
757   ) is
758 --
759   l_proc			varchar2(72) := g_package||'upd';
760   l_validation_start_date	date;
761   l_validation_end_date		date;
762 --
763 Begin
764   hr_utility.set_location('Entering:'||l_proc, 5);
765   --
766   -- Ensure that the DateTrack update mode is valid
767   --
768   dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode);
769   --
770   -- We must lock the row which we need to update.
771   --
772   ben_prg_shd.lck
773 	(p_effective_date	 => p_effective_date,
774       	 p_datetrack_mode	 => p_datetrack_mode,
775       	 p_pl_regn_id	         => p_rec.pl_regn_id,
776       	 p_object_version_number => p_rec.object_version_number,
777       	 p_validation_start_date => l_validation_start_date,
778       	 p_validation_end_date	 => l_validation_end_date);
779   --
780   -- 1. During an update system defaults are used to determine if
781   --    arguments have been defaulted or not. We must therefore
782   --    derive the full record structure values to be updated.
783   --
784   -- 2. Call the supporting update validate operations.
785   --
786   convert_defs(p_rec);
787   ben_prg_bus.update_validate
788 	(p_rec			 => p_rec,
789 	 p_effective_date	 => p_effective_date,
790 	 p_datetrack_mode  	 => p_datetrack_mode,
791 	 p_validation_start_date => l_validation_start_date,
792 	 p_validation_end_date	 => l_validation_end_date);
793   --
794   -- Call the supporting pre-update operation
795   --
796   pre_update
797 	(p_rec			 => p_rec,
798 	 p_effective_date	 => p_effective_date,
799 	 p_datetrack_mode	 => p_datetrack_mode,
800 	 p_validation_start_date => l_validation_start_date,
801 	 p_validation_end_date	 => l_validation_end_date);
802   --
803   -- Update the row.
804   --
805   update_dml
806 	(p_rec			 => p_rec,
807 	 p_effective_date	 => p_effective_date,
808 	 p_datetrack_mode	 => p_datetrack_mode,
809 	 p_validation_start_date => l_validation_start_date,
810 	 p_validation_end_date	 => l_validation_end_date);
811   --
812   -- Call the supporting post-update operation
813   --
814   post_update
815 	(p_rec			 => p_rec,
816 	 p_effective_date	 => p_effective_date,
817 	 p_datetrack_mode	 => p_datetrack_mode,
818 	 p_validation_start_date => l_validation_start_date,
819 	 p_validation_end_date	 => l_validation_end_date);
820 End upd;
821 --
822 -- ----------------------------------------------------------------------------
823 -- |---------------------------------< upd >----------------------------------|
824 -- ----------------------------------------------------------------------------
825 Procedure upd
826   (
827   p_pl_regn_id                   in number,
828   p_effective_end_date           out nocopy date,
829   p_effective_start_date         out nocopy date,
830   p_business_group_id            in number           default hr_api.g_number,
831   p_regn_id                      in number           default hr_api.g_number,
832   p_pl_id                        in number           default hr_api.g_number,
833   p_rptg_grp_id                  in number           default hr_api.g_number,
834   p_hghly_compd_det_rl           in number           default hr_api.g_number,
835   p_key_ee_det_rl                in number           default hr_api.g_number,
836   p_cntr_nndscrn_rl              in number           default hr_api.g_number,
837   p_cvg_nndscrn_rl               in number           default hr_api.g_number,
838   p_five_pct_ownr_rl             in number           default hr_api.g_number,
839   p_regy_pl_typ_cd               in varchar2         default hr_api.g_varchar2,
840   p_prg_attribute_category       in varchar2         default hr_api.g_varchar2,
841   p_prg_attribute1               in varchar2         default hr_api.g_varchar2,
842   p_prg_attribute2               in varchar2         default hr_api.g_varchar2,
843   p_prg_attribute3               in varchar2         default hr_api.g_varchar2,
844   p_prg_attribute4               in varchar2         default hr_api.g_varchar2,
845   p_prg_attribute5               in varchar2         default hr_api.g_varchar2,
846   p_prg_attribute6               in varchar2         default hr_api.g_varchar2,
847   p_prg_attribute7               in varchar2         default hr_api.g_varchar2,
848   p_prg_attribute8               in varchar2         default hr_api.g_varchar2,
849   p_prg_attribute9               in varchar2         default hr_api.g_varchar2,
850   p_prg_attribute10              in varchar2         default hr_api.g_varchar2,
851   p_prg_attribute11              in varchar2         default hr_api.g_varchar2,
852   p_prg_attribute12              in varchar2         default hr_api.g_varchar2,
853   p_prg_attribute13              in varchar2         default hr_api.g_varchar2,
854   p_prg_attribute14              in varchar2         default hr_api.g_varchar2,
855   p_prg_attribute15              in varchar2         default hr_api.g_varchar2,
856   p_prg_attribute16              in varchar2         default hr_api.g_varchar2,
857   p_prg_attribute17              in varchar2         default hr_api.g_varchar2,
858   p_prg_attribute18              in varchar2         default hr_api.g_varchar2,
859   p_prg_attribute19              in varchar2         default hr_api.g_varchar2,
860   p_prg_attribute20              in varchar2         default hr_api.g_varchar2,
861   p_prg_attribute21              in varchar2         default hr_api.g_varchar2,
862   p_prg_attribute22              in varchar2         default hr_api.g_varchar2,
863   p_prg_attribute23              in varchar2         default hr_api.g_varchar2,
864   p_prg_attribute24              in varchar2         default hr_api.g_varchar2,
865   p_prg_attribute25              in varchar2         default hr_api.g_varchar2,
866   p_prg_attribute26              in varchar2         default hr_api.g_varchar2,
867   p_prg_attribute27              in varchar2         default hr_api.g_varchar2,
868   p_prg_attribute28              in varchar2         default hr_api.g_varchar2,
869   p_prg_attribute29              in varchar2         default hr_api.g_varchar2,
870   p_prg_attribute30              in varchar2         default hr_api.g_varchar2,
871   p_object_version_number        in out nocopy number,
872   p_effective_date		 in date,
873   p_datetrack_mode		 in varchar2
874   ) is
875 --
876   l_rec		ben_prg_shd.g_rec_type;
877   l_proc	varchar2(72) := g_package||'upd';
878 --
879 Begin
880   hr_utility.set_location('Entering:'||l_proc, 5);
881   --
882   -- Call conversion function to turn arguments into the
883   -- l_rec structure.
884   --
885   l_rec :=
886   ben_prg_shd.convert_args
887   (
888   p_pl_regn_id,
889   null,
890   null,
891   p_business_group_id,
892   p_regn_id,
893   p_pl_id,
894   p_rptg_grp_id,
895   p_hghly_compd_det_rl,
896   p_key_ee_det_rl,
897   p_cntr_nndscrn_rl,
898   p_cvg_nndscrn_rl,
899   p_five_pct_ownr_rl,
900   p_regy_pl_typ_cd,
901   p_prg_attribute_category,
902   p_prg_attribute1,
903   p_prg_attribute2,
904   p_prg_attribute3,
905   p_prg_attribute4,
906   p_prg_attribute5,
907   p_prg_attribute6,
908   p_prg_attribute7,
909   p_prg_attribute8,
910   p_prg_attribute9,
911   p_prg_attribute10,
912   p_prg_attribute11,
913   p_prg_attribute12,
914   p_prg_attribute13,
915   p_prg_attribute14,
916   p_prg_attribute15,
917   p_prg_attribute16,
918   p_prg_attribute17,
919   p_prg_attribute18,
920   p_prg_attribute19,
921   p_prg_attribute20,
922   p_prg_attribute21,
923   p_prg_attribute22,
924   p_prg_attribute23,
925   p_prg_attribute24,
926   p_prg_attribute25,
927   p_prg_attribute26,
928   p_prg_attribute27,
929   p_prg_attribute28,
930   p_prg_attribute29,
931   p_prg_attribute30,
932   p_object_version_number
933   );
934   --
935   -- Having converted the arguments into the
936   -- plsql record structure we call the corresponding record
937   -- business process.
938   --
939   upd(l_rec, p_effective_date, p_datetrack_mode);
940   p_object_version_number       := l_rec.object_version_number;
941   p_effective_start_date        := l_rec.effective_start_date;
942   p_effective_end_date          := l_rec.effective_end_date;
943   --
944   --
945   hr_utility.set_location(' Leaving:'||l_proc, 10);
946 End upd;
947 --
948 end ben_prg_upd;