DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EOM_BUS

Source


1 Package Body ben_eom_bus as
2 /* $Header: beeomrhi.pkb 115.4 2002/12/16 17:36:42 glingapp ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_eom_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_elig_optd_mdcr_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_optd_mdcr_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_optd_mdcr_prte_id(p_elig_optd_mdcr_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_optd_mdcr_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_eom_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_elig_optd_mdcr_prte_id                => p_elig_optd_mdcr_prte_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_elig_optd_mdcr_prte_id,hr_api.g_number)
55      <>  ben_eom_shd.g_old_rec.elig_optd_mdcr_prte_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_eom_shd.constraint_error('BEN_ELIG_OPTD_MDCR_PRTE_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_elig_optd_mdcr_prte_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_eom_shd.constraint_error('BEN_ELIG_OPTD_MDCR_PRTE_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_elig_optd_mdcr_prte_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |------< chk_exlcd_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_optd_mdcr_prte_id PK of record being inserted or updated.
91 --   exlcd_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_exlcd_flag(p_elig_optd_mdcr_prte_id                in number,
106                             p_exlcd_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_exlcd_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_eom_shd.api_updating
118     (p_elig_optd_mdcr_prte_id                => p_elig_optd_mdcr_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_exlcd_flag
124       <> nvl(ben_eom_shd.g_old_rec.exlcd_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_exlcd_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_excld_flag');
139       fnd_message.set_token('TYPE','YES_NO');
140       fnd_message.raise_error;
141       --
142       --
143     end if;
144     --
145   end if;
146   --
147   hr_utility.set_location('Leaving:'||l_proc,10);
148   --
149 end chk_exlcd_flag;
150 --
151 -- ----------------------------------------------------------------------------
152 -- |------< chk_optd_mdcr_flag >------|
153 -- ----------------------------------------------------------------------------
154 --
155 -- Description
156 --   This procedure is used to check that the lookup value is valid.
157 --
158 -- Pre Conditions
159 --   None.
160 --
161 -- In Parameters
162 --   elig_optd_mdcr_prte_id PK of record being inserted or updated.
163 --   optd_mdcr_flag Value of lookup code.
164 --   effective_date effective date
165 --   object_version_number Object version number of record being
166 --                         inserted or updated.
167 --
168 -- Post Success
169 --   Processing continues
170 --
171 -- Post Failure
172 --   Error handled by procedure
173 --
174 -- Access Status
175 --   Internal table handler use only.
176 --
177 Procedure chk_optd_mdcr_flag(p_elig_optd_mdcr_prte_id                in number,
178                             p_optd_mdcr_flag               in varchar2,
179                             p_effective_date              in date,
180                             p_object_version_number       in number) is
181   --
182   l_proc         varchar2(72) := g_package||'chk_optd_mdcr_flag';
183   l_api_updating boolean;
184   --
185 Begin
186   --
187   hr_utility.set_location('Entering:'||l_proc, 5);
188   --
189   l_api_updating := ben_eom_shd.api_updating
190     (p_elig_optd_mdcr_prte_id                => p_elig_optd_mdcr_prte_id,
191      p_effective_date              => p_effective_date,
192      p_object_version_number       => p_object_version_number);
193   --
194   if (l_api_updating
195       and p_optd_mdcr_flag
196       <> nvl(ben_eom_shd.g_old_rec.optd_mdcr_flag,hr_api.g_varchar2)
197       or not l_api_updating) then
198     --
199     -- check if value of lookup falls within lookup type.
200     --
201     --
202     if hr_api.not_exists_in_hr_lookups
203           (p_lookup_type    => 'YES_NO',
204            p_lookup_code    => p_optd_mdcr_flag,
205            p_effective_date => p_effective_date) then
206       --
207       -- raise error as does not exist as lookup
208       --
209       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
210       fnd_message.set_token('FIELD','p_optd_mdcr_flag');
211       fnd_message.set_token('TYPE','YES_NO');
212       fnd_message.raise_error;
213       --
214       --
215     end if;
216     --
217   end if;
218   --
219   hr_utility.set_location('Leaving:'||l_proc,10);
220   --
221 end chk_optd_mdcr_flag;
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_eligy_prfl_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_eligy_prfl_id, hr_api.g_number) <> hr_api.g_number) and
290       NOT (dt_api.check_min_max_dates
291             (p_base_table_name => 'ben_eligy_prfl_f',
292              p_base_key_column => 'eligy_prfl_id',
293              p_base_key_value  => p_eligy_prfl_id,
294              p_from_date       => p_validation_start_date,
295              p_to_date         => p_validation_end_date)))  Then
296       l_table_name := 'ben_eligy_prfl_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_elig_optd_mdcr_prte_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       => 'elig_optd_mdcr_prte_id',
398        p_argument_value => p_elig_optd_mdcr_prte_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     fnd_message.set_name('PAY', 'HR_7215_DT_CHILD_EXISTS');
412     fnd_message.set_token('TABLE_NAME', l_table_name);
413     fnd_message.raise_error;
414   When Others Then
415     --
416     -- An unhandled or unexpected error has occurred which
417     -- we must report
418     --
419     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
420     fnd_message.set_token('PROCEDURE', l_proc);
421     fnd_message.set_token('STEP','15');
422     fnd_message.raise_error;
423 End dt_delete_validate;
424 --
425 -- ----------------------------------------------------------------------------
429 	(p_rec 			 in ben_eom_shd.g_rec_type,
426 -- |---------------------------< insert_validate >----------------------------|
427 -- ----------------------------------------------------------------------------
428 Procedure insert_validate
430 	 p_effective_date	 in date,
431 	 p_datetrack_mode	 in varchar2,
432 	 p_validation_start_date in date,
433 	 p_validation_end_date	 in date) is
434 --
435   l_proc	varchar2(72) := g_package||'insert_validate';
436 --
437 Begin
438   hr_utility.set_location('Entering:'||l_proc, 5);
439   --
440   -- Call all supporting business operations
441   --
442   --
443   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
444   --
445   chk_elig_optd_mdcr_prte_id
446   (p_elig_optd_mdcr_prte_id          => p_rec.elig_optd_mdcr_prte_id,
447    p_effective_date        => p_effective_date,
448    p_object_version_number => p_rec.object_version_number);
449   --
450   chk_exlcd_flag
451   (p_elig_optd_mdcr_prte_id          => p_rec.elig_optd_mdcr_prte_id,
452    p_exlcd_flag         => p_rec.exlcd_flag,
453    p_effective_date        => p_effective_date,
454    p_object_version_number => p_rec.object_version_number);
455   --
456   chk_optd_mdcr_flag
457   (p_elig_optd_mdcr_prte_id          => p_rec.elig_optd_mdcr_prte_id,
458    p_optd_mdcr_flag         => p_rec.optd_mdcr_flag,
459    p_effective_date        => p_effective_date,
460    p_object_version_number => p_rec.object_version_number);
461   --
462   hr_utility.set_location(' Leaving:'||l_proc, 10);
463 End insert_validate;
464 --
465 -- ----------------------------------------------------------------------------
466 -- |---------------------------< update_validate >----------------------------|
467 -- ----------------------------------------------------------------------------
468 Procedure update_validate
469 	(p_rec 			 in ben_eom_shd.g_rec_type,
470 	 p_effective_date	 in date,
471 	 p_datetrack_mode	 in varchar2,
472 	 p_validation_start_date in date,
473 	 p_validation_end_date	 in date) is
474 --
475   l_proc	varchar2(72) := g_package||'update_validate';
476 --
477 Begin
478   hr_utility.set_location('Entering:'||l_proc, 5);
479   --
480   -- Call all supporting business operations
481   --
482   --
483   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
484   --
485   chk_elig_optd_mdcr_prte_id
486   (p_elig_optd_mdcr_prte_id          => p_rec.elig_optd_mdcr_prte_id,
487    p_effective_date        => p_effective_date,
488    p_object_version_number => p_rec.object_version_number);
489   --
490   chk_exlcd_flag
491   (p_elig_optd_mdcr_prte_id          => p_rec.elig_optd_mdcr_prte_id,
492    p_exlcd_flag         => p_rec.exlcd_flag,
493    p_effective_date        => p_effective_date,
494    p_object_version_number => p_rec.object_version_number);
495   --
496   chk_optd_mdcr_flag
497   (p_elig_optd_mdcr_prte_id          => p_rec.elig_optd_mdcr_prte_id,
498    p_optd_mdcr_flag         => p_rec.optd_mdcr_flag,
499    p_effective_date        => p_effective_date,
500    p_object_version_number => p_rec.object_version_number);
501   --
502   -- Call the datetrack update integrity operation
503   --
504   dt_update_validate
505     (p_eligy_prfl_id                 => p_rec.eligy_prfl_id,
506      p_datetrack_mode                => p_datetrack_mode,
507      p_validation_start_date	     => p_validation_start_date,
508      p_validation_end_date	     => p_validation_end_date);
509   --
510   hr_utility.set_location(' Leaving:'||l_proc, 10);
511 End update_validate;
512 --
513 -- ----------------------------------------------------------------------------
514 -- |---------------------------< delete_validate >----------------------------|
515 -- ----------------------------------------------------------------------------
516 Procedure delete_validate
517 	(p_rec 			 in ben_eom_shd.g_rec_type,
518 	 p_effective_date	 in date,
519 	 p_datetrack_mode	 in varchar2,
520 	 p_validation_start_date in date,
521 	 p_validation_end_date	 in date) is
522 --
523   l_proc	varchar2(72) := g_package||'delete_validate';
524 --
525 Begin
526   hr_utility.set_location('Entering:'||l_proc, 5);
527   --
528   -- Call all supporting business operations
529   --
530   dt_delete_validate
531     (p_datetrack_mode		=> p_datetrack_mode,
532      p_validation_start_date	=> p_validation_start_date,
533      p_validation_end_date	=> p_validation_end_date,
534      p_elig_optd_mdcr_prte_id		=> p_rec.elig_optd_mdcr_prte_id);
535   --
536   hr_utility.set_location(' Leaving:'||l_proc, 10);
537 End delete_validate;
538 --
539 --
540 --  ---------------------------------------------------------------------------
541 --  |---------------------< return_legislation_code >-------------------------|
542 --  ---------------------------------------------------------------------------
543 --
544 function return_legislation_code
545   (p_elig_optd_mdcr_prte_id in number) return varchar2 is
546   --
547   -- Declare cursor
548   --
549   cursor csr_leg_code is
550     select a.legislation_code
551     from   per_business_groups a,
552            ben_elig_optd_mdcr_prte_f b
553     where b.elig_optd_mdcr_prte_id      = p_elig_optd_mdcr_prte_id
554     and   a.business_group_id = b.business_group_id;
555   --
556   -- Declare local variables
557   --
558   l_legislation_code  varchar2(150);
559   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
560   --
561 begin
562   --
563   hr_utility.set_location('Entering:'|| l_proc, 10);
564   --
565   -- Ensure that all the mandatory parameter are not null
566   --
567   hr_api.mandatory_arg_error(p_api_name       => l_proc,
568                              p_argument       => 'elig_optd_mdcr_prte_id',
569                              p_argument_value => p_elig_optd_mdcr_prte_id);
570   --
571   open csr_leg_code;
572     --
573     fetch csr_leg_code into l_legislation_code;
574     --
575     if csr_leg_code%notfound then
576       --
577       close csr_leg_code;
578       --
579       -- The primary key is invalid therefore we must error
580       --
581       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
582       fnd_message.raise_error;
583       --
584     end if;
585     --
586   close csr_leg_code;
587   --
588   hr_utility.set_location(' Leaving:'|| l_proc, 20);
589   --
590   return l_legislation_code;
591   --
592 end return_legislation_code;
593 --
594 end ben_eom_bus;