DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PBM_BUS

Source


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