DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_APV_BUS

Source


1 Package Body ben_apv_bus as
2 /* $Header: beapvrhi.pkb 120.0.12010000.2 2008/08/05 14:03:38 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_apv_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_actl_prem_vrbl_rt_id >------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description
15 --   This procedure is used to check that the primary key for the table
16 --   is created properly. It should be null on insert and
17 --   should not be able to be updated.
18 --
19 -- Pre Conditions
20 --   None.
21 --
22 -- In Parameters
23 --   actl_prem_vrbl_rt_id PK of record being inserted or updated.
24 --   effective_date Effective Date of session
25 --   object_version_number Object version number of record being
26 --                         inserted or updated.
27 --
28 -- Post Success
29 --   Processing continues
30 --
31 -- Post Failure
32 --   Errors handled by the procedure
33 --
34 -- Access Status
35 --   Internal table handler use only.
36 --
37 Procedure chk_actl_prem_vrbl_rt_id(p_actl_prem_vrbl_rt_id                in number,
38                            p_effective_date              in date,
39                            p_object_version_number       in number) is
40   --
41   l_proc         varchar2(72) := g_package||'chk_actl_prem_vrbl_rt_id';
42   l_api_updating boolean;
43   --
44 Begin
45   --
46   hr_utility.set_location('Entering:'||l_proc, 5);
47   --
48   l_api_updating := ben_apv_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_actl_prem_vrbl_rt_id                => p_actl_prem_vrbl_rt_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_actl_prem_vrbl_rt_id,hr_api.g_number)
55      <>  ben_apv_shd.g_old_rec.actl_prem_vrbl_rt_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_apv_shd.constraint_error('BEN_ACTL_PREM_VRBL_RT_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_actl_prem_vrbl_rt_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_apv_shd.constraint_error('BEN_ACTL_PREM_VRBL_RT_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_actl_prem_vrbl_rt_id;
78 -- ----------------------------------------------------------------------------
79 -- |------------------------< chk_vrr_vrp_mutexcl >--------------------------|
80 -- ----------------------------------------------------------------------------
81 --
82 -- Description
83 --   This procedure is used to check that the profile is mutually exclusive for the
84 --   actl_prem_id. A rule cannot exist with this actl_prem_id due to the ARC
85 --   relationship on ben_actl_prem_f.
86 --
87 -- Pre Conditions
88 --   None.
89 --
90 -- In Parameters
91 --   actl_prem_vrbl_rt_id     PK of record being inserted or updated.
92 --   actl_prem_id             actl_prem_id.
93 --   effective_date           Session date of record.
94 --   business_group_id        Business group id of record being inserted.
95 --   object_version_number    Object version number of record being
96 --                            inserted or updated.
97 --
98 -- Post Success
99 --   Processing continues
100 --
101 -- Post Failure
102 --   Errors handled by the procedure
103 --
104 -- Access Status
105 --   Internal table handler use only.
106 --
107 Procedure chk_vrr_vrp_mutexcl(p_actl_prem_vrbl_rt_id   in number,
108                                p_actl_prem_id               in number,
109                                p_effective_date            in date,
110                                p_business_group_id         in number,
111                                p_object_version_number     in number) is
112   --
113   l_proc         varchar2(72) := g_package||'chk_vrr_vrp_mutexcl';
114   l_api_updating boolean;
115   l_dummy varchar2(1);
116   --
117   cursor c1 is
118     select null
119     from   ben_actl_prem_vrbl_rt_rl_f a
120     where  a.business_group_id +0 = p_business_group_id
121     and    a.actl_prem_id = p_actl_prem_id
122     and    p_effective_date
123            between a.effective_start_date
124            and     a.effective_end_date;
125   --
126 Begin
127   --
128   hr_utility.set_location('Entering:'||l_proc, 5);
129   --
130   l_api_updating := ben_apv_shd.api_updating
131     (p_effective_date              => p_effective_date,
132      p_actl_prem_vrbl_rt_id        => p_actl_prem_vrbl_rt_id,
133      p_object_version_number       => p_object_version_number);
134   --
135   if (l_api_updating or not l_api_updating)
136      and p_actl_prem_id is not null then
137     --
138     -- Check if actl_prem_id is mutually exclusive.
139     --
140     open c1;
141       --
142       fetch c1 into l_dummy;
143       if c1%found then
144         --
145         close c1;
146         --
147         -- raise an error as this actl_prem_id has been assigned to rule(s).
148         --
149         fnd_message.set_name('BEN','BEN_91613_VRR_VRP_EXCL2');
150         fnd_message.raise_error;
151         --
152       end if;
153       --
154     close c1;
155     --
156   end if;
157   --
158   hr_utility.set_location('Leaving:'||l_proc, 10);
159   --
160 End chk_vrr_vrp_mutexcl;
161 --
162 -- ---------------------------------------------------------------------------
163 -- |-----------------------< chk_ordr_num_unique >---------------------------|
164 -- ---------------------------------------------------------------------------
165 --
166 -- Description
167 --   ensure that the Sequence Number is unique
168 --   within business_group
169 --
170 -- Pre Conditions
171 --   None.
172 --
173 -- In Parameters
174 --     p_ordr_num                Sequence Number
175 --     p_actl_prem_vrbl_rt_id    Primary Key of BEN_ACTL_PREM_VRBL_RT_F
176 --     p_actl_prem_id            Foreign Key to BEN_ACTL_PREM_F
177 --     p_business_group_id
178 --
179 -- Post Success
180 --   Processing continues
181 --
182 -- Post Failure
183 --   Errors handled by the procedure
184 --
185 -- Access Status
186 --   Internal table handler use only.
187 --
188 -- ----------------------------------------------------------------------------
189 Procedure chk_ordr_num_unique
190           ( p_actl_prem_vrbl_rt_id      in   number
191            ,p_actl_prem_id              in   number
192            ,p_ordr_num                  in   number
193            ,p_business_group_id         in   number)
194 is
195 l_proc      varchar2(72) := g_package||'chk_ordr_num_unique';
196 l_dummy    char(1);
197 cursor c1 is select null
198              from   ben_actl_prem_vrbl_rt_f
199              Where  actl_prem_vrbl_rt_id <> nvl(p_actl_prem_vrbl_rt_id,-1)
200              and    actl_prem_id = p_actl_prem_id
201              and    ordr_num = p_ordr_num
202              and    business_group_id = p_business_group_id;
203 --
204 Begin
205   hr_utility.set_location('Entering:'||l_proc, 5);
206   --
207   open c1;
208   fetch c1 into l_dummy;
209   if c1%found then
210       close c1;
211       fnd_message.set_name('BEN','BEN_91001_SEQ_NOT_UNIQUE');
212       fnd_message.raise_error;
213   end if;
214   --
215   hr_utility.set_location('Leaving:'||l_proc, 15);
216 End chk_ordr_num_unique;
217 --
218 -- ----------------------------------------------------------------------------
219 -- |--------------------------< dt_update_validate >--------------------------|
220 -- ----------------------------------------------------------------------------
221 -- {Start Of Comments}
222 --
223 -- Description:
224 --   This procedure is used for referential integrity of datetracked
225 --   parent entities when a datetrack update operation is taking place
226 --   and where there is no cascading of update defined for this entity.
227 --
228 -- Prerequisites:
229 --   This procedure is called from the update_validate.
230 --
231 -- In Parameters:
232 --
233 -- Post Success:
234 --   Processing continues.
235 --
236 -- Post Failure:
237 --
238 -- Developer Implementation Notes:
239 --   This procedure should not need maintenance unless the HR Schema model
240 --   changes.
241 --
242 -- Access Status:
243 --   Internal Row Handler Use Only.
244 --
245 -- {End Of Comments}
246 -- ----------------------------------------------------------------------------
247 Procedure dt_update_validate
248             (p_vrbl_rt_prfl_id               in number default hr_api.g_number,
249              p_actl_prem_id                  in number default hr_api.g_number,
250 	     p_datetrack_mode		     in varchar2,
251              p_validation_start_date	     in date,
252 	     p_validation_end_date	     in date) Is
253 --
254   l_proc	    varchar2(72) := g_package||'dt_update_validate';
255   l_integrity_error Exception;
256   l_table_name	    all_tables.table_name%TYPE;
257 --
258 Begin
259   hr_utility.set_location('Entering:'||l_proc, 5);
260   --
261   -- Ensure that the p_datetrack_mode argument is not null
262   --
263   hr_api.mandatory_arg_error
264     (p_api_name       => l_proc,
265      p_argument       => 'datetrack_mode',
266      p_argument_value => p_datetrack_mode);
267   --
268   -- Only perform the validation if the datetrack update mode is valid
269   --
270   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
271     --
272     --
273     -- Ensure the arguments are not null
274     --
275     hr_api.mandatory_arg_error
276       (p_api_name       => l_proc,
277        p_argument       => 'validation_start_date',
278        p_argument_value => p_validation_start_date);
279     --
280     hr_api.mandatory_arg_error
281       (p_api_name       => l_proc,
282        p_argument       => 'validation_end_date',
283        p_argument_value => p_validation_end_date);
284     --
285     If ((nvl(p_vrbl_rt_prfl_id, hr_api.g_number) <> hr_api.g_number) and
286       NOT (dt_api.check_min_max_dates
287             (p_base_table_name => 'ben_vrbl_rt_prfl_f',
288              p_base_key_column => 'vrbl_rt_prfl_id',
289              p_base_key_value  => p_vrbl_rt_prfl_id,
290              p_from_date       => p_validation_start_date,
291              p_to_date         => p_validation_end_date)))  Then
292       l_table_name := 'ben_vrbl_rt_prfl_f';
293       Raise l_integrity_error;
294     End If;
295     If ((nvl(p_actl_prem_id, hr_api.g_number) <> hr_api.g_number) and
296       NOT (dt_api.check_min_max_dates
297             (p_base_table_name => 'ben_actl_prem_f',
298              p_base_key_column => 'actl_prem_id',
299              p_base_key_value  => p_actl_prem_id,
300              p_from_date       => p_validation_start_date,
301              p_to_date         => p_validation_end_date)))  Then
302       l_table_name := 'ben_actl_prem_f';
303       Raise l_integrity_error;
304     End If;
305     --
306   End If;
307   --
308   hr_utility.set_location(' Leaving:'||l_proc, 10);
309 Exception
310   When l_integrity_error Then
311     --
312     -- A referential integrity check was violated therefore
313     -- we must error
314     --
315     ben_utility.parent_integrity_error(p_table_name => l_table_name);
316   When Others Then
317     --
318     -- An unhandled or unexpected error has occurred which
319     -- we must report
320     --
321     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
322     fnd_message.set_token('PROCEDURE', l_proc);
323     fnd_message.set_token('STEP','15');
324     fnd_message.raise_error;
325 End dt_update_validate;
326 --
327 -- ----------------------------------------------------------------------------
328 -- |--------------------------< dt_delete_validate >--------------------------|
329 -- ----------------------------------------------------------------------------
330 -- {Start Of Comments}
331 --
332 -- Description:
333 --   This procedure is used for referential integrity of datetracked
334 --   child entities when either a datetrack DELETE or ZAP is in operation
335 --   and where there is no cascading of delete defined for this entity.
336 --   For the datetrack mode of DELETE or ZAP we must ensure that no
337 --   datetracked child rows exist between the validation start and end
338 --   dates.
339 --
340 -- Prerequisites:
341 --   This procedure is called from the delete_validate.
342 --
343 -- In Parameters:
344 --
345 -- Post Success:
346 --   Processing continues.
347 --
348 -- Post Failure:
349 --   If a row exists by determining the returning Boolean value from the
350 --   generic dt_api.rows_exist function then we must supply an error via
351 --   the use of the local exception handler l_rows_exist.
352 --
353 -- Developer Implementation Notes:
354 --   This procedure should not need maintenance unless the HR Schema model
355 --   changes.
356 --
357 -- Access Status:
358 --   Internal Row Handler Use Only.
359 --
360 -- {End Of Comments}
361 -- ----------------------------------------------------------------------------
362 Procedure dt_delete_validate
363             (p_actl_prem_vrbl_rt_id		in number,
364              p_datetrack_mode		in varchar2,
365 	     p_validation_start_date	in date,
366 	     p_validation_end_date	in date) Is
367 --
368   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
369   l_rows_exist	Exception;
370   l_table_name	all_tables.table_name%TYPE;
371 --
372 Begin
373   hr_utility.set_location('Entering:'||l_proc, 5);
374   --
375   -- Ensure that the p_datetrack_mode argument is not null
376   --
377   hr_api.mandatory_arg_error
378     (p_api_name       => l_proc,
379      p_argument       => 'datetrack_mode',
380      p_argument_value => p_datetrack_mode);
381   --
382   -- Only perform the validation if the datetrack mode is either
383   -- DELETE or ZAP
384   --
385   If (p_datetrack_mode = 'DELETE' or
386       p_datetrack_mode = 'ZAP') then
387     --
388     --
389     -- Ensure the arguments are not null
390     --
391     hr_api.mandatory_arg_error
392       (p_api_name       => l_proc,
393        p_argument       => 'validation_start_date',
394        p_argument_value => p_validation_start_date);
395     --
396     hr_api.mandatory_arg_error
397       (p_api_name       => l_proc,
398        p_argument       => 'validation_end_date',
399        p_argument_value => p_validation_end_date);
400     --
401     hr_api.mandatory_arg_error
402       (p_api_name       => l_proc,
403        p_argument       => 'actl_prem_vrbl_rt_id',
404        p_argument_value => p_actl_prem_vrbl_rt_id);
405     --
406     --
407     --
408   End If;
409   --
410   hr_utility.set_location(' Leaving:'||l_proc, 10);
411 Exception
412   When l_rows_exist Then
413     --
414     -- A referential integrity check was violated therefore
415     -- we must error
416     --
417     ben_utility.child_exists_error(p_table_name => l_table_name);
418   When Others Then
419     --
420     -- An unhandled or unexpected error has occurred which
421     -- we must report
422     --
423     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
424     fnd_message.set_token('PROCEDURE', l_proc);
425     fnd_message.set_token('STEP','15');
426     fnd_message.raise_error;
427 End dt_delete_validate;
428 --
429 -- ----------------------------------------------------------------------------
430 -- |---------------------------< insert_validate >----------------------------|
431 -- ----------------------------------------------------------------------------
432 Procedure insert_validate
433 	(p_rec 			 in ben_apv_shd.g_rec_type,
434 	 p_effective_date	 in date,
435 	 p_datetrack_mode	 in varchar2,
436 	 p_validation_start_date in date,
437 	 p_validation_end_date	 in date) is
438 --
439   l_proc	varchar2(72) := g_package||'insert_validate';
440 --
441 Begin
442   hr_utility.set_location('Entering:'||l_proc, 5);
443   --
444   -- Call all supporting business operations
445   --
446   --
447   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
448   --
449   chk_actl_prem_vrbl_rt_id
450   (p_actl_prem_vrbl_rt_id          => p_rec.actl_prem_vrbl_rt_id,
451    p_effective_date        => p_effective_date,
452    p_object_version_number => p_rec.object_version_number);
453   --
454   chk_vrr_vrp_mutexcl
455   (p_actl_prem_vrbl_rt_id      => p_rec.actl_prem_vrbl_rt_id,
456    p_actl_prem_id              => p_rec.actl_prem_id,
457    p_effective_date            => p_effective_date,
458    p_business_group_id         => p_rec.business_group_id,
459    p_object_version_number     => p_rec.object_version_number);
460   --
461   chk_ordr_num_unique
462   (p_actl_prem_vrbl_rt_id   => p_rec.actl_prem_vrbl_rt_id,
463    p_actl_prem_id           => p_rec.actl_prem_id,
464    p_ordr_num               => p_rec.ordr_num,
465    p_business_group_id      => p_rec.business_group_id);
466   --
467   hr_utility.set_location(' Leaving:'||l_proc, 10);
468 End insert_validate;
469 --
470 -- ----------------------------------------------------------------------------
471 -- |---------------------------< update_validate >----------------------------|
472 -- ----------------------------------------------------------------------------
473 Procedure update_validate
474 	(p_rec 			 in ben_apv_shd.g_rec_type,
475 	 p_effective_date	 in date,
476 	 p_datetrack_mode	 in varchar2,
477 	 p_validation_start_date in date,
478 	 p_validation_end_date	 in date) is
479 --
480   l_proc	varchar2(72) := g_package||'update_validate';
481 --
482 Begin
483   hr_utility.set_location('Entering:'||l_proc, 5);
484   --
485   -- Call all supporting business operations
486   --
487   --
488   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
489   --
490   chk_actl_prem_vrbl_rt_id
491   (p_actl_prem_vrbl_rt_id          => p_rec.actl_prem_vrbl_rt_id,
492    p_effective_date        => p_effective_date,
493    p_object_version_number => p_rec.object_version_number);
494   --
495   chk_vrr_vrp_mutexcl
496   (p_actl_prem_vrbl_rt_id      => p_rec.actl_prem_vrbl_rt_id,
497    p_actl_prem_id              => p_rec.actl_prem_id,
498    p_effective_date            => p_effective_date,
499    p_business_group_id         => p_rec.business_group_id,
500    p_object_version_number     => p_rec.object_version_number);
501   --
502   chk_ordr_num_unique
503   (p_actl_prem_vrbl_rt_id   => p_rec.actl_prem_vrbl_rt_id,
504    p_actl_prem_id           => p_rec.actl_prem_id,
505    p_ordr_num               => p_rec.ordr_num,
506    p_business_group_id      => p_rec.business_group_id);
507   --
508   -- Call the datetrack update integrity operation
509   --
510   dt_update_validate
511     (p_vrbl_rt_prfl_id               => p_rec.vrbl_rt_prfl_id,
512              p_actl_prem_id                  => p_rec.actl_prem_id,
513      p_datetrack_mode                => p_datetrack_mode,
514      p_validation_start_date	     => p_validation_start_date,
515      p_validation_end_date	     => p_validation_end_date);
516   --
517   hr_utility.set_location(' Leaving:'||l_proc, 10);
518 End update_validate;
519 --
520 -- ----------------------------------------------------------------------------
521 -- |---------------------------< delete_validate >----------------------------|
522 -- ----------------------------------------------------------------------------
523 Procedure delete_validate
524 	(p_rec 			 in ben_apv_shd.g_rec_type,
525 	 p_effective_date	 in date,
526 	 p_datetrack_mode	 in varchar2,
527 	 p_validation_start_date in date,
528 	 p_validation_end_date	 in date) is
529 --
530   l_proc	varchar2(72) := g_package||'delete_validate';
531 --
532 Begin
533   hr_utility.set_location('Entering:'||l_proc, 5);
534   --
535   -- Call all supporting business operations
536   --
537   dt_delete_validate
538     (p_datetrack_mode		=> p_datetrack_mode,
539      p_validation_start_date	=> p_validation_start_date,
540      p_validation_end_date	=> p_validation_end_date,
541      p_actl_prem_vrbl_rt_id		=> p_rec.actl_prem_vrbl_rt_id);
542   --
543   hr_utility.set_location(' Leaving:'||l_proc, 10);
544 End delete_validate;
545 --
546 --
547 --  ---------------------------------------------------------------------------
548 --  |---------------------< return_legislation_code >-------------------------|
549 --  ---------------------------------------------------------------------------
550 --
551 function return_legislation_code
552   (p_actl_prem_vrbl_rt_id in number) return varchar2 is
553   --
554   -- Declare cursor
555   --
556   cursor csr_leg_code is
557     select a.legislation_code
558     from   per_business_groups a,
559            ben_actl_prem_vrbl_rt_f b
560     where b.actl_prem_vrbl_rt_id      = p_actl_prem_vrbl_rt_id
561     and   a.business_group_id = b.business_group_id;
562   --
563   -- Declare local variables
564   --
565   l_legislation_code  varchar2(150);
566   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
567   --
568 begin
569   --
570   hr_utility.set_location('Entering:'|| l_proc, 10);
571   --
572   -- Ensure that all the mandatory parameter are not null
573   --
574   hr_api.mandatory_arg_error(p_api_name       => l_proc,
575                              p_argument       => 'actl_prem_vrbl_rt_id',
576                              p_argument_value => p_actl_prem_vrbl_rt_id);
577   --
578   open csr_leg_code;
579     --
580     fetch csr_leg_code into l_legislation_code;
581     --
582     if csr_leg_code%notfound then
583       --
584       close csr_leg_code;
585       --
586       -- The primary key is invalid therefore we must error
587       --
588       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
589       fnd_message.raise_error;
590       --
591     end if;
592     --
593   close csr_leg_code;
594   --
595   hr_utility.set_location(' Leaving:'|| l_proc, 20);
596   --
597   return l_legislation_code;
598   --
599 end return_legislation_code;
600 --
601 end ben_apv_bus;