DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PPE_BUS

Source


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