DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EPG_BUS

Source


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