DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PEI_UPD

Source


1 Package Body ben_pei_upd as
2 /* $Header: bepeirhi.pkb 120.0 2005/05/28 10:33:49 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)    := '  ben_pei_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_pei_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_extract_identifier_f',
78        p_base_key_column    => 'pl_extract_identifier_id',
79        p_base_key_value     => p_rec.pl_extract_identifier_id);
80     --
81     ben_pei_shd.g_api_dml := true;  -- Set the api dml status
82     --
83     -- Update the ben_pl_f Row
84     --
85     update  ben_pl_extract_identifier_f
86     set
87     pl_id                          = p_rec.pl_id
88     ,plip_id                  	   = p_rec.plip_id
89     ,oipl_id                  	   = p_rec.oipl_id
90     ,third_party_identifier   	   = p_rec.third_party_identifier
91     ,organization_id          	   = p_rec.organization_id
92     ,job_id                   	   = p_rec.job_id
93     ,position_id              	   = p_rec.position_id
94     ,people_group_id          	   = p_rec.people_group_id
95     ,grade_id                 	   = p_rec.grade_id
96     ,payroll_id               	   = p_rec.payroll_id
97     ,home_state               	   = p_rec.home_state
98     ,home_zip                 	   = p_rec.home_zip
99     ,object_version_number	   = p_rec.object_version_number
100     ,business_group_id		   = p_rec.business_group_id
101     where   pl_extract_identifier_id = p_rec.pl_extract_identifier_id
102     and     effective_start_date = p_validation_start_date
103     and     effective_end_date   = p_validation_end_date;
104     --
105     ben_pei_shd.g_api_dml := false;   -- Unset the api dml status
106     --
107     -- Set the effective start and end dates
108     --
109     p_rec.effective_start_date := p_validation_start_date;
110     p_rec.effective_end_date   := p_validation_end_date;
111   End If;
112 --
113 hr_utility.set_location(' Leaving:'||l_proc, 15);
114 Exception
115   When hr_api.check_integrity_violated Then
116     -- A check constraint has been violated
117     ben_pei_shd.g_api_dml := false;   -- Unset the api dml status
118     ben_pei_shd.constraint_error
119       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120   When hr_api.unique_integrity_violated Then
121     -- Unique integrity has been violated
122     ben_pei_shd.g_api_dml := false;   -- Unset the api dml status
123     ben_pei_shd.constraint_error
124       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
125   When Others Then
126     ben_pei_shd.g_api_dml := false;   -- Unset the api dml status
127     Raise;
128 End dt_update_dml;
129 --
130 -- ----------------------------------------------------------------------------
131 -- |------------------------------< update_dml >------------------------------|
132 -- ----------------------------------------------------------------------------
133 -- {Start Of Comments}
134 --
135 -- Description:
136 --   This procedure calls the dt_update_dml control logic which handles
137 --   the actual datetrack dml.
138 --
139 -- Prerequisites:
140 --   This is an internal private procedure which must be called from the upd
141 --   procedure.
142 --
143 -- In Parameters:
144 --   A Pl/Sql record structre.
145 --
146 -- Post Success:
147 --   Processing contines.
148 --
149 -- Post Failure:
150 --   No specific error handling is required within this procedure.
151 --
152 -- Developer Implementation Notes:
153 --   The update 'set' arguments list should be modified if any of your
154 --   attributes are not updateable.
155 --
156 -- Access Status:
157 --   Internal Row Handler Use Only.
158 --
159 -- {End Of Comments}
160 -- ----------------------------------------------------------------------------
161 Procedure update_dml
162     (p_rec			in out nocopy ben_pei_shd.g_rec_type,
163      p_effective_date		in    date,
164      p_datetrack_mode		in    varchar2,
165      p_validation_start_date	in    date,
166      p_validation_end_date      in    date) is
167 --
168   l_proc    varchar2(72) := g_package||'update_dml';
169 --
170 Begin
171   hr_utility.set_location('Entering:'||l_proc, 5);
172   --
173   dt_update_dml(p_rec			=> p_rec,
174                 p_effective_date	=> p_effective_date,
175 		p_datetrack_mode	=> p_datetrack_mode,
176                 p_validation_start_date => p_validation_start_date,
177 		p_validation_end_date   => p_validation_end_date);
178   --
179   hr_utility.set_location(' Leaving:'||l_proc, 10);
180 End update_dml;
181 --
182 -- ----------------------------------------------------------------------------
183 -- |----------------------------< dt_pre_update >-----------------------------|
184 -- ----------------------------------------------------------------------------
185 -- {Start Of Comments}
186 --
187 -- Description:
188 --   The dt_pre_update procedure controls the execution
189 --   of dml for the datetrack modes of: UPDATE, UPDATE_OVERRIDE
190 --   and UPDATE_CHANGE_INSERT only. The execution required is as
191 --   follows:
192 --
193 --   1) Providing the datetrack update mode is not 'CORRECTION'
194 --      then set the effective end date of the current row (this
195 --      will be the validation_start_date - 1).
196 --   2) If the datetrack mode is 'UPDATE_OVERRIDE' then call the
197 --      corresponding delete_dml process to delete any future rows
198 --      where the effective_start_date is greater than or equal to
199 --    the validation_start_date.
200 --   3) Call the insert_dml process to insert the new updated row
201 --      details..
202 --
203 -- Prerequisites:
204 --   This is an internal procedure which is called from the
205 --   pre_update procedure.
206 --
207 -- In Parameters:
208 --
209 -- Post Success:
210 --   Processing continues.
211 --
212 -- Post Failure:
213 --   If an error has occurred, an error message and exception will be raised
214 --   but not handled.
215 --
216 -- Developer Implementation Notes:
217 --   This is an internal procedure which is required by Datetrack. Don't
218 --   remove or modify.
219 --
220 -- Access Status:
221 --   Internal Row Handler Use Only.
222 --
223 -- {End Of Comments}
224 -- ----------------------------------------------------------------------------
225 Procedure dt_pre_update
226     (p_rec			in out nocopy    ben_pei_shd.g_rec_type,
227      p_effective_date		in    date,
228      p_datetrack_mode		in    varchar2,
229      p_validation_start_date	in    date,
230      p_validation_end_date      in    date) is
231 --
232   l_proc             varchar2(72) := g_package||'dt_pre_update';
233   l_dummy_version_number number;
234 --
235 Begin
236   hr_utility.set_location('Entering:'||l_proc, 5);
237   If (p_datetrack_mode <> 'CORRECTION') then
238     hr_utility.set_location(l_proc, 10);
239     --
240     -- Update the current effective end date
241     --
242     ben_pei_shd.upd_effective_end_date
243      (p_effective_date         => p_effective_date,
244       p_base_key_value         => p_rec.pl_extract_identifier_id,
245       p_new_effective_end_date => (p_validation_start_date - 1),
246       p_validation_start_date  => p_validation_start_date,
247       p_validation_end_date    => p_validation_end_date,
248       p_object_version_number  => l_dummy_version_number);
249     --
250     If (p_datetrack_mode = 'UPDATE_OVERRIDE') then
251       hr_utility.set_location(l_proc, 15);
252       --
253       -- As the datetrack mode is 'UPDATE_OVERRIDE' then we must
254       -- delete any future rows
255       --
256       ben_pei_del.delete_dml
257         (p_rec			 => p_rec,
258          p_effective_date	 => p_effective_date,
259          p_datetrack_mode	 => p_datetrack_mode,
260          p_validation_start_date => p_validation_start_date,
261          p_validation_end_date   => p_validation_end_date);
262       --
263     End If;
264     hr_utility.set_location(l_proc, 20);
265     --
266     -- We must now insert the updated row
267     --
268     ben_pei_ins.insert_dml
269       (p_rec			=> p_rec,
270        p_effective_date         => p_effective_date,
271        p_datetrack_mode         => p_datetrack_mode,
272        p_validation_start_date  => p_validation_start_date,
273        p_validation_end_date    => p_validation_end_date);
274   End If;
275   hr_utility.set_location(' Leaving:'||l_proc, 20);
276 End dt_pre_update;
277 --
278 -- ----------------------------------------------------------------------------
279 -- |------------------------------< pre_update >------------------------------|
280 -- ----------------------------------------------------------------------------
281 -- {Start Of Comments}
282 --
283 -- Description:
284 --   This private procedure contains any processing which is required before
285 --   the update dml.
286 --
287 -- Prerequisites:
288 --   This is an internal procedure which is called from the upd procedure.
289 --
290 -- In Parameters:
291 --   A Pl/Sql record structre.
292 --
293 -- Post Success:
294 --   Processing continues.
295 --
296 -- Post Failure:
297 --   If an error has occurred, an error message and exception will be raised
298 --   but not handled.
299 --
300 -- Developer Implementation Notes:
301 --   Any pre-processing required before the update dml is issued should be
302 --   coded within this procedure. It is important to note that any 3rd party
303 --   maintenance should be reviewed before placing in this procedure. The call
304 --   to the dt_update_dml procedure should NOT be removed.
305 --
306 -- Access Status:
307 --   Internal Row Handler Use Only.
308 --
309 -- {End Of Comments}
310 -- ----------------------------------------------------------------------------
311 Procedure pre_update
312     (p_rec			in out nocopy    ben_pei_shd.g_rec_type,
313      p_effective_date		in    date,
314      p_datetrack_mode		in    varchar2,
315      p_validation_start_date	in    date,
316      p_validation_end_date      in    date) is
317 --
318   l_proc    varchar2(72) := g_package||'pre_update';
319 --
320 Begin
321   hr_utility.set_location('Entering:'||l_proc, 5);
322   --
323   --
324   --
325   dt_pre_update
326     (p_rec                    => p_rec,
327      p_effective_date         => p_effective_date,
328      p_datetrack_mode         => p_datetrack_mode,
329      p_validation_start_date  => p_validation_start_date,
330      p_validation_end_date    => p_validation_end_date);
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 structre.
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
355 --   but not handled.
356 --
357 -- Developer Implementation Notes:
358 --   Any post-processing required after the update dml is issued should be
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 ben_pei_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) is
373 --
374   l_proc    varchar2(72) := g_package||'post_update';
375 --
376 Begin
377   hr_utility.set_location('Entering:'||l_proc, 5);
378   --
379   -- Start of API User Hook for post_update.
380   --
381   begin
382     --
383     --
384     ben_pei_rku.after_update
385     (
386      p_pl_extract_identifier_id    =>  p_rec.pl_extract_identifier_id
387      ,p_pl_id                       =>  p_rec.pl_id
388      ,p_plip_id                     =>  p_rec.plip_id
389      ,p_oipl_id                     =>  p_rec.oipl_id
390      ,p_third_party_identifier      =>  p_rec.third_party_identifier
391      ,p_organization_id             =>  p_rec.organization_id
392      ,p_job_id                      =>  p_rec.job_id
393      ,p_position_id                 =>  p_rec.position_id
394      ,p_people_group_id             =>  p_rec.people_group_id
395      ,p_grade_id                    =>  p_rec.grade_id
396      ,p_payroll_id                  =>  p_rec.payroll_id
397      ,p_home_state                  =>  p_rec.home_state
398      ,p_home_zip                    =>  p_rec.home_zip
399      ,p_effective_start_date        =>  p_rec.effective_start_date
400      ,p_effective_end_date          =>  p_rec.effective_end_date
401      ,p_object_version_number       =>  p_rec.object_version_number
402      ,p_business_group_id           =>  p_rec.business_group_id
403      ,p_effective_date              =>  p_effective_date
404      ,p_datetrack_mode              =>  p_datetrack_mode
405      ,p_validation_start_date       =>  p_validation_start_date
406      ,p_validation_end_date         =>  p_validation_end_date
407      ,p_pl_id_o                     =>  ben_pei_shd.g_old_rec.pl_id
408      ,p_plip_id_o                   =>  ben_pei_shd.g_old_rec.plip_id
409      ,p_oipl_id_o                   =>  ben_pei_shd.g_old_rec.oipl_id
410      ,p_third_party_identifier_o    =>  ben_pei_shd.g_old_rec.third_party_identifier
411      ,p_organization_id_o           =>  ben_pei_shd.g_old_rec.organization_id
412      ,p_job_id_o                    =>  ben_pei_shd.g_old_rec.job_id
413      ,p_position_id_o               =>  ben_pei_shd.g_old_rec.position_id
414      ,p_people_group_id_o           =>  ben_pei_shd.g_old_rec.people_group_id
415      ,p_grade_id_o                  =>  ben_pei_shd.g_old_rec.grade_id
416      ,p_payroll_id_o                =>  ben_pei_shd.g_old_rec.payroll_id
417      ,p_home_state_o                =>  ben_pei_shd.g_old_rec.home_state
418      ,p_home_zip_o                  =>  ben_pei_shd.g_old_rec.home_zip
419      ,p_effective_start_date_o      =>  ben_pei_shd.g_old_rec.effective_start_date
420      ,p_effective_end_date_o        =>  ben_pei_shd.g_old_rec.effective_end_date
421      ,p_object_version_number_o     =>  ben_pei_shd.g_old_rec.object_version_number
422      ,p_business_group_id_o         =>  ben_pei_shd.g_old_rec.business_group_id
423     );
424     --
425   exception
426     --
427     when hr_api.cannot_find_prog_unit then
428       --
429       hr_api.cannot_find_prog_unit_error
430         (p_module_name => 'ben_pl_extract_identifier_f'
431         ,p_hook_type   => 'AU');
432       --
433   end;
434   --
435   -- End of API User Hook for post_update.
436   --
437   hr_utility.set_location(' Leaving:'||l_proc, 10);
438 End post_update;
439 --
440 --
441 -- ----------------------------------------------------------------------------
442 -- |---------------------------------< upd >----------------------------------|
443 -- ----------------------------------------------------------------------------
444 Procedure upd
445   (
446   p_rec            in out nocopy     ben_pei_shd.g_rec_type,
447   p_effective_date    in     date,
448   p_datetrack_mode    in     varchar2
449   ) is
450 --
451   l_proc            varchar2(72) := g_package||'upd';
452   l_validation_start_date    date;
453   l_validation_end_date        date;
454 --
455 Begin
456   hr_utility.set_location('Entering:'||l_proc, 5);
457   --
458   -- Ensure that the DateTrack update mode is valid
459   --
460   dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode);
461   --
462   -- We must lock the row which we need to update.
463   --
464   ben_pei_shd.lck
465           (p_effective_date		=> p_effective_date,
466            p_datetrack_mode		=> p_datetrack_mode,
467            p_pl_extract_identifier_id   => p_rec.pl_extract_identifier_id,
468            p_object_version_number	=> p_rec.object_version_number,
469            p_validation_start_date	=> l_validation_start_date,
470            p_validation_end_date	=> l_validation_end_date);
471   --
472   -- 1. During an update system defaults are used to determine if
473   --    arguments have been defaulted or not. We must therefore
474   --    derive the full record structure values to be updated.
475   --
476   -- 2. Call the supporting update validate operations.
477   --
478   ben_pei_upd2.convert_defs(p_rec);
479   ben_pei_bus.update_validate
480     (p_rec			=> p_rec,
481      p_effective_date		=> p_effective_date,
482      p_datetrack_mode		=> p_datetrack_mode,
483      p_validation_start_date	=> l_validation_start_date,
484      p_validation_end_date      => l_validation_end_date);
485   --
486   -- Call the supporting pre-update operation
487   --
488   pre_update
489     (p_rec			=> p_rec,
490      p_effective_date		=> p_effective_date,
491      p_datetrack_mode		=> p_datetrack_mode,
492      p_validation_start_date	=> l_validation_start_date,
493      p_validation_end_date      => l_validation_end_date);
494   --
495   -- Update the row.
496   --
497   update_dml
498     (p_rec			=> p_rec,
499      p_effective_date		=> p_effective_date,
500      p_datetrack_mode		=> p_datetrack_mode,
501      p_validation_start_date	=> l_validation_start_date,
502      p_validation_end_date      => l_validation_end_date);
503   --
504   -- Call the supporting post-update operation
505   --
506   post_update
507     (p_rec			=> p_rec,
508      p_effective_date		=> p_effective_date,
509      p_datetrack_mode		=> p_datetrack_mode,
510      p_validation_start_date	=> l_validation_start_date,
511      p_validation_end_date      => l_validation_end_date);
512 End upd;
513 --
514 -- ----------------------------------------------------------------------------
515 -- |---------------------------------< upd >----------------------------------|
516 -- ----------------------------------------------------------------------------
517 Procedure upd
518   (
519    p_pl_extract_identifier_id    in  number,
520    p_effective_start_date        out nocopy date,
521    p_effective_end_date          out nocopy date,
522    p_pl_id                       in  number    default hr_api.g_number,
523    p_plip_id                     in  number    default hr_api.g_number,
524    p_oipl_id                     in  number    default hr_api.g_number,
525    p_third_party_identifier      in  varchar2  default hr_api.g_varchar2,
526    p_organization_id             in  number    default hr_api.g_number,
527    p_job_id                      in  number    default hr_api.g_number,
528    p_position_id                 in  number    default hr_api.g_number,
529    p_people_group_id             in  number    default hr_api.g_number,
530    p_grade_id                    in  number    default hr_api.g_number,
531    p_payroll_id                  in  number    default hr_api.g_number,
532    p_home_state                  in  varchar2  default hr_api.g_varchar2,
533    p_home_zip                    in  varchar2  default hr_api.g_varchar2,
534    p_business_group_id           in  number    default hr_api.g_number,
535    p_object_version_number       in  out nocopy number,
536    p_effective_date              in  date,
537    p_datetrack_mode	       in  varchar2
538   ) is
539 --
540   l_rec     ben_pei_shd.g_rec_type;
541   l_proc    varchar2(72) := g_package||'upd';
542 --
543 Begin
544   hr_utility.set_location('Entering:'||l_proc, 5);
545   --
546   -- Call conversion function to turn arguments into the
547   -- l_rec structure.
548   --
549   l_rec :=
550      ben_pei_shd.convert_args
551      (
552        p_pl_extract_identifier_id
553        ,p_pl_id
554        ,p_plip_id
555        ,p_oipl_id
556        ,p_third_party_identifier
557        ,p_organization_id
558        ,p_job_id
559        ,p_position_id
560        ,p_people_group_id
561        ,p_grade_id
562        ,p_payroll_id
563        ,p_home_state
564        ,p_home_zip
565        ,null
566        ,null
567        ,p_object_version_number
568        ,p_business_group_id
569      );
570   --
571   -- Having converted the arguments into the
572   -- plsql record structure we call the corresponding record
573   -- business process.
574   --
575   upd(l_rec, p_effective_date, p_datetrack_mode);
576   p_object_version_number       := l_rec.object_version_number;
577   p_effective_start_date        := l_rec.effective_start_date;
578   p_effective_end_date          := l_rec.effective_end_date;
579   --
580   --
581   hr_utility.set_location(' Leaving:'||l_proc, 10);
582 End upd;
583 --
584 end ben_pei_upd;