DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_ABP_BUS

Source


1 Package Body ben_abp_bus as
2 /* $Header: beabprhi.pkb 120.0.12010000.3 2008/08/25 13:56:55 ppentapa ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_abp_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_aplcn_to_bnft_pool_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 --   aplcn_to_bnft_pool_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_aplcn_to_bnft_pool_id(p_aplcn_to_bnft_pool_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_aplcn_to_bnft_pool_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_abp_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_aplcn_to_bnft_pool_id                => p_aplcn_to_bnft_pool_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_aplcn_to_bnft_pool_id,hr_api.g_number)
55      <>  ben_abp_shd.g_old_rec.aplcn_to_bnft_pool_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_abp_shd.constraint_error('BEN_APLCN_TO_BNFT_POOL_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_aplcn_to_bnft_pool_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_abp_shd.constraint_error('BEN_APLCN_TO_BNFT_POOL_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_aplcn_to_bnft_pool_id;
78 
79 
80 --
81 -- ----------------------------------------------------------------------------
82 -- |--------------------------< chk_abr_dups >--------------------------|
83 -- ----------------------------------------------------------------------------
84 Procedure chk_abr_dups
85             (p_acty_base_rt_id               in number default hr_api.g_number,
86              p_bnft_prvdr_pool_id            in number default hr_api.g_number,
87              p_aplcn_to_bnft_pool_id         in number default hr_api.g_number,
88              p_effective_date                in date
89              ) Is
90 
91 l_proc            varchar2(72) := g_package||'chk_abr_dups';
92 
93 cursor c_abp is
94  select 'x'
95  from  ben_aplcn_to_bnft_pool_f
96  where bnft_prvdr_pool_id = p_bnft_prvdr_pool_id
97    and acty_base_rt_id    = p_acty_base_rt_id
98    and aplcn_to_bnft_pool_id <> nvl(p_aplcn_to_bnft_pool_id,-1)
99    and p_effective_date  between effective_start_date
100        and effective_end_date   ;
101 
102 l_dummy_var  varchar2(1) ;
103 
104 begin
105 
106   hr_utility.set_location('Entering:'||l_proc, 5);
107   hr_utility.set_location('p_acty_base_rt_id:'||p_acty_base_rt_id, 5);
108   hr_utility.set_location('bnft_prvdr_pool_id:'||p_bnft_prvdr_pool_id, 5);
109   hr_utility.set_location('aplcn_to_bnft_pool_id:'||p_aplcn_to_bnft_pool_id, 5);
110   hr_utility.set_location('effective_date:'||p_effective_date , 5);
111    open c_abp ;
112    fetch c_abp into l_dummy_var ;
113    if c_abp%found then
114       hr_utility.set_location('dupes:'||l_proc, 5);
115      close c_abp ;
116      fnd_message.set_name('BEN', 'BEN_92992_DUPS_ROW');
117      fnd_message.set_token('VAR1', 'Application');
118      fnd_message.set_token('VAR2','Benefit Pool');
119      fnd_message.raise_error;
120    end if ;
121    close c_abp ;
122 
123    hr_utility.set_location('Leaving:'||l_proc, 10);
124 
125 end chk_abr_dups ;
126 
127 
128 --
129 -- ----------------------------------------------------------------------------
130 -- |--------------------------< dt_update_validate >--------------------------|
131 -- ----------------------------------------------------------------------------
132 -- {Start Of Comments}
133 --
134 -- Description:
135 --   This procedure is used for referential integrity of datetracked
136 --   parent entities when a datetrack update operation is taking place
137 --   and where there is no cascading of update defined for this entity.
138 --
139 -- Prerequisites:
140 --   This procedure is called from the update_validate.
141 --
142 -- In Parameters:
143 --
144 -- Post Success:
145 --   Processing continues.
146 --
147 -- Post Failure:
148 --
149 -- Developer Implementation Notes:
150 --   This procedure should not need maintenance unless the HR Schema model
151 --   changes.
152 --
153 -- Access Status:
154 --   Internal Row Handler Use Only.
155 --
156 -- {End Of Comments}
157 -- ----------------------------------------------------------------------------
158 Procedure dt_update_validate
159             (p_acty_base_rt_id               in number default hr_api.g_number,
160              p_bnft_prvdr_pool_id            in number default hr_api.g_number,
161 	     p_datetrack_mode		     in varchar2,
162              p_validation_start_date	     in date,
163 	     p_validation_end_date	     in date) Is
164 --
165   l_proc	    varchar2(72) := g_package||'dt_update_validate';
166   l_integrity_error Exception;
167   l_table_name	    all_tables.table_name%TYPE;
168 --
169 Begin
170   hr_utility.set_location('Entering:'||l_proc, 5);
171   --
172   -- Ensure that the p_datetrack_mode argument is not null
173   --
174   hr_api.mandatory_arg_error
175     (p_api_name       => l_proc,
176      p_argument       => 'datetrack_mode',
177      p_argument_value => p_datetrack_mode);
178   --
179   -- Only perform the validation if the datetrack update mode is valid
180   --
181   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
182     --
183     --
184     -- Ensure the arguments are not null
185     --
186     hr_api.mandatory_arg_error
187       (p_api_name       => l_proc,
188        p_argument       => 'validation_start_date',
189        p_argument_value => p_validation_start_date);
190     --
191     hr_api.mandatory_arg_error
192       (p_api_name       => l_proc,
193        p_argument       => 'validation_end_date',
194        p_argument_value => p_validation_end_date);
195     --
196     If ((nvl(p_acty_base_rt_id, hr_api.g_number) <> hr_api.g_number) and
197       NOT (dt_api.check_min_max_dates
198             (p_base_table_name => 'ben_acty_base_rt_f',
199              p_base_key_column => 'acty_base_rt_id',
200              p_base_key_value  => p_acty_base_rt_id,
201              p_from_date       => p_validation_start_date,
202              p_to_date         => p_validation_end_date)))  Then
203       l_table_name := 'ben_acty_base_rt_f';
204       Raise l_integrity_error;
205     End If;
206     If ((nvl(p_bnft_prvdr_pool_id, hr_api.g_number) <> hr_api.g_number) and
207       NOT (dt_api.check_min_max_dates
208             (p_base_table_name => 'ben_bnft_prvdr_pool_f',
209              p_base_key_column => 'bnft_prvdr_pool_id',
210              p_base_key_value  => p_bnft_prvdr_pool_id,
211              p_from_date       => p_validation_start_date,
212              p_to_date         => p_validation_end_date)))  Then
213       l_table_name := 'ben_bnft_prvdr_pool_f';
214       Raise l_integrity_error;
215     End If;
216     --
217   End If;
218   --
219   hr_utility.set_location(' Leaving:'||l_proc, 10);
220 Exception
221   When l_integrity_error Then
222     --
223     -- A referential integrity check was violated therefore
224     -- we must error
225     --
226     ben_utility.parent_integrity_error(p_table_name => l_table_name);
227     --
228   When Others Then
229     --
230     -- An unhandled or unexpected error has occurred which
231     -- we must report
232     --
233     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
234     fnd_message.set_token('PROCEDURE', l_proc);
235     fnd_message.set_token('STEP','15');
236     fnd_message.raise_error;
237 End dt_update_validate;
238 --
239 -- ----------------------------------------------------------------------------
240 -- |--------------------------< dt_delete_validate >--------------------------|
241 -- ----------------------------------------------------------------------------
242 -- {Start Of Comments}
243 --
244 -- Description:
245 --   This procedure is used for referential integrity of datetracked
246 --   child entities when either a datetrack DELETE or ZAP is in operation
247 --   and where there is no cascading of delete defined for this entity.
248 --   For the datetrack mode of DELETE or ZAP we must ensure that no
249 --   datetracked child rows exist between the validation start and end
250 --   dates.
251 --
252 -- Prerequisites:
253 --   This procedure is called from the delete_validate.
254 --
255 -- In Parameters:
256 --
257 -- Post Success:
258 --   Processing continues.
259 --
260 -- Post Failure:
261 --   If a row exists by determining the returning Boolean value from the
262 --   generic dt_api.rows_exist function then we must supply an error via
263 --   the use of the local exception handler l_rows_exist.
264 --
265 -- Developer Implementation Notes:
266 --   This procedure should not need maintenance unless the HR Schema model
267 --   changes.
268 --
269 -- Access Status:
270 --   Internal Row Handler Use Only.
271 --
272 -- {End Of Comments}
273 -- ----------------------------------------------------------------------------
274 Procedure dt_delete_validate
275             (p_aplcn_to_bnft_pool_id		in number,
276              p_datetrack_mode		in varchar2,
277 	     p_validation_start_date	in date,
278 	     p_validation_end_date	in date) Is
279 --
280   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
281   l_rows_exist	Exception;
282   l_table_name	all_tables.table_name%TYPE;
283 --
284 Begin
285   hr_utility.set_location('Entering:'||l_proc, 5);
286   --
287   -- Ensure that the p_datetrack_mode argument is not null
288   --
289   hr_api.mandatory_arg_error
290     (p_api_name       => l_proc,
291      p_argument       => 'datetrack_mode',
292      p_argument_value => p_datetrack_mode);
293   --
294   -- Only perform the validation if the datetrack mode is either
295   -- DELETE or ZAP
296   --
297   If (p_datetrack_mode = 'DELETE' or
298       p_datetrack_mode = 'ZAP') then
299     --
300     --
301     -- Ensure the arguments are not null
302     --
303     hr_api.mandatory_arg_error
304       (p_api_name       => l_proc,
305        p_argument       => 'validation_start_date',
306        p_argument_value => p_validation_start_date);
307     --
308     hr_api.mandatory_arg_error
309       (p_api_name       => l_proc,
310        p_argument       => 'validation_end_date',
311        p_argument_value => p_validation_end_date);
312     --
313     hr_api.mandatory_arg_error
314       (p_api_name       => l_proc,
315        p_argument       => 'aplcn_to_bnft_pool_id',
316        p_argument_value => p_aplcn_to_bnft_pool_id);
317     --
318     --
319     --
320   End If;
321   --
322   hr_utility.set_location(' Leaving:'||l_proc, 10);
323 Exception
324   When l_rows_exist Then
325     --
326     -- A referential integrity check was violated therefore
327     -- we must error
328     --
329     ben_utility.child_exists_error(p_table_name => l_table_name);
330     --
331   When Others Then
332     --
333     -- An unhandled or unexpected error has occurred which
334     -- we must report
335     --
336     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
337     fnd_message.set_token('PROCEDURE', l_proc);
338     fnd_message.set_token('STEP','15');
339     fnd_message.raise_error;
340 End dt_delete_validate;
341 --
342 -- ----------------------------------------------------------------------------
343 -- |---------------------------< insert_validate >----------------------------|
344 -- ----------------------------------------------------------------------------
345 Procedure insert_validate
346 	(p_rec 			 in ben_abp_shd.g_rec_type,
347 	 p_effective_date	 in date,
348 	 p_datetrack_mode	 in varchar2,
349 	 p_validation_start_date in date,
350 	 p_validation_end_date	 in date) is
351 --
352   l_proc	varchar2(72) := g_package||'insert_validate';
353 --
354 Begin
355   hr_utility.set_location('Entering:'||l_proc, 5);
356   --
357   -- Call all supporting business operations
358   --
359   --
360   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
361   --
362   chk_aplcn_to_bnft_pool_id
363   (p_aplcn_to_bnft_pool_id          => p_rec.aplcn_to_bnft_pool_id,
364    p_effective_date        => p_effective_date,
365    p_object_version_number => p_rec.object_version_number);
366 
367   chk_abr_dups
368             (p_acty_base_rt_id           => p_rec.acty_base_rt_id,
369              p_bnft_prvdr_pool_id        => p_rec.bnft_prvdr_pool_id,
370              p_aplcn_to_bnft_pool_id     => p_rec.aplcn_to_bnft_pool_id,
371              p_effective_date            => p_effective_date );
372   --
373 
374 
375   hr_utility.set_location(' Leaving:'||l_proc, 10);
376 End insert_validate;
377 --
378 -- ----------------------------------------------------------------------------
379 -- |---------------------------< update_validate >----------------------------|
380 -- ----------------------------------------------------------------------------
381 Procedure update_validate
382 	(p_rec 			 in ben_abp_shd.g_rec_type,
383 	 p_effective_date	 in date,
384 	 p_datetrack_mode	 in varchar2,
385 	 p_validation_start_date in date,
386 	 p_validation_end_date	 in date) is
387 --
388   l_proc	varchar2(72) := g_package||'update_validate';
389 --
390 Begin
391   hr_utility.set_location('Entering:'||l_proc, 5);
392   --
393   -- Call all supporting business operations
394   --
395   --
396   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
397   --
398   chk_aplcn_to_bnft_pool_id
399   (p_aplcn_to_bnft_pool_id          => p_rec.aplcn_to_bnft_pool_id,
400    p_effective_date        => p_effective_date,
401    p_object_version_number => p_rec.object_version_number);
402   --
403   -- Call the datetrack update integrity operation
404   --
405   dt_update_validate
406     (p_acty_base_rt_id               => p_rec.acty_base_rt_id,
407              p_bnft_prvdr_pool_id            => p_rec.bnft_prvdr_pool_id,
408      p_datetrack_mode                => p_datetrack_mode,
409      p_validation_start_date	     => p_validation_start_date,
410      p_validation_end_date	     => p_validation_end_date);
411 
412    chk_abr_dups
413             (p_acty_base_rt_id           => p_rec.acty_base_rt_id,
414              p_bnft_prvdr_pool_id        => p_rec.bnft_prvdr_pool_id,
415              p_aplcn_to_bnft_pool_id     => p_rec.aplcn_to_bnft_pool_id,
416              p_effective_date            => p_effective_date );
417   --
418 
419   --
420   hr_utility.set_location(' Leaving:'||l_proc, 10);
421 End update_validate;
422 --
423 -- ----------------------------------------------------------------------------
424 -- |---------------------------< delete_validate >----------------------------|
425 -- ----------------------------------------------------------------------------
426 Procedure delete_validate
427 	(p_rec 			 in ben_abp_shd.g_rec_type,
428 	 p_effective_date	 in date,
429 	 p_datetrack_mode	 in varchar2,
430 	 p_validation_start_date in date,
431 	 p_validation_end_date	 in date) is
432 --
433   l_proc	varchar2(72) := g_package||'delete_validate';
434 --
435 Begin
436   hr_utility.set_location('Entering:'||l_proc, 5);
437   --
438   -- Call all supporting business operations
439   --
440   dt_delete_validate
441     (p_datetrack_mode		=> p_datetrack_mode,
442      p_validation_start_date	=> p_validation_start_date,
443      p_validation_end_date	=> p_validation_end_date,
444      p_aplcn_to_bnft_pool_id		=> p_rec.aplcn_to_bnft_pool_id);
445   --
446   hr_utility.set_location(' Leaving:'||l_proc, 10);
447 End delete_validate;
448 --
449 --
450 --  ---------------------------------------------------------------------------
451 --  |---------------------< return_legislation_code >-------------------------|
452 --  ---------------------------------------------------------------------------
453 --
454 function return_legislation_code
455   (p_aplcn_to_bnft_pool_id in number) return varchar2 is
456   --
457   -- Declare cursor
458   --
459   cursor csr_leg_code is
460     select a.legislation_code
461     from   per_business_groups a,
462            ben_aplcn_to_bnft_pool_f b
463     where b.aplcn_to_bnft_pool_id      = p_aplcn_to_bnft_pool_id
464     and   a.business_group_id = b.business_group_id;
465   --
466   -- Declare local variables
467   --
468   l_legislation_code  varchar2(150);
469   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
470   --
471 begin
472   --
473   hr_utility.set_location('Entering:'|| l_proc, 10);
474   --
475   -- Ensure that all the mandatory parameter are not null
476   --
477   hr_api.mandatory_arg_error(p_api_name       => l_proc,
478                              p_argument       => 'aplcn_to_bnft_pool_id',
479                              p_argument_value => p_aplcn_to_bnft_pool_id);
480   --
481   open csr_leg_code;
482     --
483     fetch csr_leg_code into l_legislation_code;
484     --
485     if csr_leg_code%notfound then
486       --
487       close csr_leg_code;
488       --
489       -- The primary key is invalid therefore we must error
490       --
491       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
492       fnd_message.raise_error;
493       --
494     end if;
495     --
496   close csr_leg_code;
497   --
498   hr_utility.set_location(' Leaving:'|| l_proc, 20);
499   --
500   return l_legislation_code;
501   --
502 end return_legislation_code;
503 --
504 end ben_abp_bus;