DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EGR_BUS

Source


1 Package Body ben_egr_bus as
2 /* $Header: beegrrhi.pkb 120.2 2006/02/27 00:25:14 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_egr_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_elig_grd_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_grd_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_grd_prte_id(p_elig_grd_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_grd_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_egr_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_elig_grd_prte_id                => p_elig_grd_prte_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_elig_grd_prte_id,hr_api.g_number)
55      <>  ben_egr_shd.g_old_rec.elig_grd_prte_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_egr_shd.constraint_error('BEN_ELIG_GRD_PRTE_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_elig_grd_prte_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_egr_shd.constraint_error('BEN_ELIG_GRD_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_grd_prte_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |------< chk_grade_id >------|
81 -- ----------------------------------------------------------------------------
82 --
83 -- Description
84 --   This procedure checks that a referenced foreign key actually exists
85 --   in the referenced table.
86 --
87 -- Pre-Conditions
88 --   None.
89 --
90 -- In Parameters
91 --   p_elig_grd_prte_id PK
92 --   p_grade_id ID of FK column
93 --   p_effective_date session date
94 --   p_object_version_number object version number
95 --
96 -- Post Success
97 --   Processing continues
98 --
99 -- Post Failure
100 --   Error raised.
101 --
102 -- Access Status
103 --   Internal table handler use only.
104 --
105 Procedure chk_grade_id (p_elig_grd_prte_id          in number,
106                             p_grade_id          in number,
107                             p_eligy_prfl_id         in number,
108                             p_validation_start_date in date,
109                             p_validation_end_date   in date,
110                             p_effective_date        in date,
111                             p_business_group_id     in number,
112                             p_object_version_number in number) is
113   --
114   l_proc         varchar2(72) := g_package||'chk_grade_id';
115   l_api_updating boolean;
116   l_dummy        varchar2(1);
117   l_exists       varchar2(1);
118   --
119   cursor c1 is
120     select null
121     from   per_grades a
122     where  a.grade_id = p_grade_id
123       and  a.business_group_id + 0 = p_business_group_id
124       and  p_effective_date between a.date_from
125                             and nvl(date_to, p_effective_date);
126   --
127   --
128   cursor c3 is
129      select null
130        from ben_elig_grd_prte_f
131          where grade_id = p_grade_id
132            and eligy_prfl_id = p_eligy_prfl_id
133            and elig_grd_prte_id <> nvl(p_elig_grd_prte_id,hr_api.g_number)
134            and business_group_id + 0 = p_business_group_id
135            and p_validation_start_date <= effective_end_date
136            and p_validation_end_date >= effective_start_date
137            ;
138   --
139 Begin
140   --
141   hr_utility.set_location('Entering:'||l_proc,5);
142   --
143   l_api_updating := ben_egr_shd.api_updating
144      (p_elig_grd_prte_id            => p_elig_grd_prte_id,
145       p_effective_date          => p_effective_date,
146       p_object_version_number   => p_object_version_number);
147   --
148   if (l_api_updating
149      and nvl(p_grade_id,hr_api.g_number)
150      <> nvl(ben_egr_shd.g_old_rec.grade_id,hr_api.g_number)
151      or not l_api_updating) then
152     --
153     -- check if grade_id value exists in per_grades table
154     --
155     open c1;
156       --
157       fetch c1 into l_dummy;
158       if c1%notfound then
159         --
160         close c1;
161         --
162         -- raise error as FK does not relate to PK in per_grades
163         -- table.
164         --
165         ben_egr_shd.constraint_error('BEN_ELIG_GRD_PRTE_FK2');
166         --
167       end if;
168       --
169     close c1;
170     --
171   end if;
172   --
173   hr_utility.set_location('Leaving:'||l_proc,10);
174   --
175 End chk_grade_id;
176 --
177 -- ----------------------------------------------------------------------------
178 -- |------< chk_excld_flag >------|
179 -- ----------------------------------------------------------------------------
180 --
181 -- Description
182 --   This procedure is used to check that the lookup value is valid.
183 --
184 -- Pre Conditions
185 --   None.
186 --
187 -- In Parameters
188 --   elig_grd_prte_id PK of record being inserted or updated.
189 --   excld_flag Value of lookup code.
190 --   effective_date effective date
191 --   object_version_number Object version number of record being
192 --                         inserted or updated.
193 --
194 -- Post Success
195 --   Processing continues
196 --
197 -- Post Failure
198 --   Error handled by procedure
199 --
200 -- Access Status
201 --   Internal table handler use only.
202 --
203 Procedure chk_excld_flag(p_elig_grd_prte_id                in number,
204                             p_excld_flag               in varchar2,
205                             p_effective_date              in date,
206                             p_object_version_number       in number) is
207   --
208   l_proc         varchar2(72) := g_package||'chk_excld_flag';
209   l_api_updating boolean;
210   --
211 Begin
212   --
213   hr_utility.set_location('Entering:'||l_proc, 5);
214   --
215   l_api_updating := ben_egr_shd.api_updating
216     (p_elig_grd_prte_id                => p_elig_grd_prte_id,
217      p_effective_date              => p_effective_date,
218      p_object_version_number       => p_object_version_number);
219   --
220   if (l_api_updating
221       and p_excld_flag
222       <> nvl(ben_egr_shd.g_old_rec.excld_flag,hr_api.g_varchar2)
223       or not l_api_updating) then
224     --
225     -- check if value of lookup falls within lookup type.
226     --
227     --
228     if hr_api.not_exists_in_hr_lookups
229           (p_lookup_type    => 'YES_NO',
230            p_lookup_code    => p_excld_flag,
231            p_effective_date => p_effective_date) then
232       --
233       -- raise error as does not exist as lookup
234       --
235       fnd_message.set_name('PAY','HR_LOOKUP_DOES_NOT_EXIST');
236       fnd_message.raise_error;
237       --
238     end if;
239     --
240   end if;
241   --
242   hr_utility.set_location('Leaving:'||l_proc,10);
243   --
244 end chk_excld_flag;
245 --
246 --Bug:5054189
247 -- ---------------------------------------------------------------------------
248 -- |-----------------------< chk_duplicate_ordr_num >---------------------------|
249 -- ---------------------------------------------------------------------------
250 --
251 -- Description
252 --   Ensure that the Sequence Number is unique
253 --   within business_group
254 --
255 -- Pre Conditions
256 --   None.
257 --
258 -- In Parameters
259 --   p_elig_grd_prte_id          elig_grd_prte_id
260 --   p_eligy_prfl_id             eligy_prfl_id
261 --   p_ordr_num                  Sequence Number
262 --   p_business_group_id
263 --
264 -- Post Success
265 --   Processing continues
266 --
267 -- Post Failure
268 --   Errors handled by the procedure
269 --
270 -- Access Status
271 --   Internal table handler use only
272 --
273 
274 Procedure chk_duplicate_ordr_num
275           ( p_elig_grd_prte_id            in   number
276            ,p_eligy_prfl_id               in   number
277            ,p_ordr_num                    in   number
278            ,p_business_group_id           in   number)
279 is
280   l_proc     varchar2(72) := g_package||'chk_duplicate_ordr_num';
281   l_dummy    char(1);
282   cursor c1 is
283     select null
284     from   ben_elig_grd_prte_f
285     where  elig_grd_prte_id <> nvl(p_elig_grd_prte_id,-1)
286     and    eligy_prfl_id = p_eligy_prfl_id
287     and    ordr_num = p_ordr_num
288     and    business_group_id = p_business_group_id;
289 --
290 Begin
291   hr_utility.set_location('Entering:'||l_proc, 5);
292   --
293   open c1;
294   fetch c1 into l_dummy;
295   if c1%found then
296     close c1;
297     fnd_message.set_name('BEN','BEN_91001_SEQ_NOT_UNIQUE');
298     fnd_message.raise_error;
299   end if;
300   close c1;
301   --
302   hr_utility.set_location('Leaving:'||l_proc, 15);
303 End chk_duplicate_ordr_num;
304 -- ----------------------------------------------------------------------------
305 -- |--------------------------< dt_update_validate >--------------------------|
306 -- ----------------------------------------------------------------------------
307 -- {Start Of Comments}
308 --
309 -- Description:
310 --   This procedure is used for referential integrity of datetracked
311 --   parent entities when a datetrack update operation is taking place
312 --   and where there is no cascading of update defined for this entity.
313 --
314 -- Prerequisites:
315 --   This procedure is called from the update_validate.
316 --
317 -- In Parameters:
318 --
319 -- Post Success:
320 --   Processing continues.
321 --
322 -- Post Failure:
323 --
324 -- Developer Implementation Notes:
325 --   This procedure should not need maintenance unless the HR Schema model
326 --   changes.
327 --
328 -- Access Status:
329 --   Internal Row Handler Use Only.
330 --
331 -- {End Of Comments}
332 -- ----------------------------------------------------------------------------
333 Procedure dt_update_validate
334             (p_eligy_prfl_id                 in number default hr_api.g_number,
335 	     p_datetrack_mode		     in varchar2,
336              p_validation_start_date	     in date,
337 	     p_validation_end_date	     in date) Is
338 --
339   l_proc	    varchar2(72) := g_package||'dt_update_validate';
340   l_integrity_error Exception;
341   l_table_name	    all_tables.table_name%TYPE;
342 --
343 Begin
344   hr_utility.set_location('Entering:'||l_proc, 5);
345   --
346   -- Ensure that the p_datetrack_mode argument is not null
347   --
348   hr_api.mandatory_arg_error
349     (p_api_name       => l_proc,
350      p_argument       => 'datetrack_mode',
351      p_argument_value => p_datetrack_mode);
352   --
353   -- Only perform the validation if the datetrack update mode is valid
354   --
355   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
356     --
357     --
358     -- Ensure the arguments are not null
359     --
360     hr_api.mandatory_arg_error
361       (p_api_name       => l_proc,
362        p_argument       => 'validation_start_date',
363        p_argument_value => p_validation_start_date);
364     --
365     hr_api.mandatory_arg_error
366       (p_api_name       => l_proc,
367        p_argument       => 'validation_end_date',
368        p_argument_value => p_validation_end_date);
369     --
370     If ((nvl(p_eligy_prfl_id, hr_api.g_number) <> hr_api.g_number) and
371       NOT (dt_api.check_min_max_dates
372             (p_base_table_name => 'ben_eligy_prfl_f',
373              p_base_key_column => 'eligy_prfl_id',
374              p_base_key_value  => p_eligy_prfl_id,
375              p_from_date       => p_validation_start_date,
376              p_to_date         => p_validation_end_date)))  Then
377       l_table_name := 'ben_eligy_prfl_f';
378       Raise l_integrity_error;
379     End If;
380     --
381   End If;
382   --
383   hr_utility.set_location(' Leaving:'||l_proc, 10);
384 Exception
388     -- we must error
385   When l_integrity_error Then
386     --
387     -- A referential integrity check was violated therefore
389     --
390        ben_utility.parent_integrity_error(p_table_name => l_table_name);
391     --
392   When Others Then
393     --
394     -- An unhandled or unexpected error has occurred which
395     -- we must report
396     --
397     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
398     fnd_message.set_token('PROCEDURE', l_proc);
399     fnd_message.set_token('STEP','15');
400     fnd_message.raise_error;
401 End dt_update_validate;
402 --
403 -- ----------------------------------------------------------------------------
404 -- |--------------------------< dt_delete_validate >--------------------------|
405 -- ----------------------------------------------------------------------------
406 -- {Start Of Comments}
407 --
408 -- Description:
409 --   This procedure is used for referential integrity of datetracked
410 --   child entities when either a datetrack DELETE or ZAP is in operation
411 --   and where there is no cascading of delete defined for this entity.
412 --   For the datetrack mode of DELETE or ZAP we must ensure that no
413 --   datetracked child rows exist between the validation start and end
414 --   dates.
415 --
416 -- Prerequisites:
417 --   This procedure is called from the delete_validate.
418 --
419 -- In Parameters:
420 --
421 -- Post Success:
422 --   Processing continues.
423 --
424 -- Post Failure:
425 --   If a row exists by determining the returning Boolean value from the
426 --   generic dt_api.rows_exist function then we must supply an error via
427 --   the use of the local exception handler l_rows_exist.
428 --
429 -- Developer Implementation Notes:
430 --   This procedure should not need maintenance unless the HR Schema model
431 --   changes.
432 --
433 -- Access Status:
434 --   Internal Row Handler Use Only.
435 --
436 -- {End Of Comments}
437 -- ----------------------------------------------------------------------------
438 Procedure dt_delete_validate
439             (p_elig_grd_prte_id		in number,
440              p_datetrack_mode		in varchar2,
441 	     p_validation_start_date	in date,
442 	     p_validation_end_date	in date) Is
443 --
444   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
445   l_rows_exist	Exception;
446   l_table_name	all_tables.table_name%TYPE;
447 --
448 Begin
449   hr_utility.set_location('Entering:'||l_proc, 5);
450   --
451   -- Ensure that the p_datetrack_mode argument is not null
452   --
453   hr_api.mandatory_arg_error
454     (p_api_name       => l_proc,
455      p_argument       => 'datetrack_mode',
456      p_argument_value => p_datetrack_mode);
457   --
458   -- Only perform the validation if the datetrack mode is either
459   -- DELETE or ZAP
460   --
461   If (p_datetrack_mode = 'DELETE' or
462       p_datetrack_mode = 'ZAP') then
463     --
464     --
465     -- Ensure the arguments are not null
466     --
467     hr_api.mandatory_arg_error
468       (p_api_name       => l_proc,
469        p_argument       => 'validation_start_date',
470        p_argument_value => p_validation_start_date);
471     --
472     hr_api.mandatory_arg_error
473       (p_api_name       => l_proc,
474        p_argument       => 'validation_end_date',
475        p_argument_value => p_validation_end_date);
476     --
477     hr_api.mandatory_arg_error
478       (p_api_name       => l_proc,
479        p_argument       => 'elig_grd_prte_id',
480        p_argument_value => p_elig_grd_prte_id);
481     --
482     --
483     --
484   End If;
485   --
486   hr_utility.set_location(' Leaving:'||l_proc, 10);
487 Exception
488   When l_rows_exist Then
489     --
490     -- A referential integrity check was violated therefore
491     -- we must error
492     --
493        ben_utility.child_exists_error(p_table_name => l_table_name);
494     --
495   When Others Then
496     --
497     -- An unhandled or unexpected error has occurred which
498     -- we must report
499     --
500     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
501     fnd_message.set_token('PROCEDURE', l_proc);
502     fnd_message.set_token('STEP','15');
503     fnd_message.raise_error;
504 End dt_delete_validate;
505 --
506 -- ----------------------------------------------------------------------------
507 -- |---------------------------< insert_validate >----------------------------|
508 -- ----------------------------------------------------------------------------
509 Procedure insert_validate
510 	(p_rec 			 in ben_egr_shd.g_rec_type,
511 	 p_effective_date	 in date,
512 	 p_datetrack_mode	 in varchar2,
513 	 p_validation_start_date in date,
514 	 p_validation_end_date	 in date) is
515 --
516   l_proc	varchar2(72) := g_package||'insert_validate';
517 --
518 Begin
519   hr_utility.set_location('Entering:'||l_proc, 5);
520   --
521   -- Call all supporting business operations
522   --
523   --
524   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
525   --
526   chk_elig_grd_prte_id
527   (p_elig_grd_prte_id          => p_rec.elig_grd_prte_id,
528    p_effective_date        => p_effective_date,
529    p_object_version_number => p_rec.object_version_number);
530   --
531   chk_grade_id
532   (p_elig_grd_prte_id          => p_rec.elig_grd_prte_id,
533    p_grade_id              => p_rec.grade_id,
534    p_eligy_prfl_id         => p_rec.eligy_prfl_id,
535    p_validation_start_date => p_validation_start_date,
536    p_validation_end_date   => p_validation_end_date,
537    p_effective_date        => p_effective_date,
538    p_business_group_id     => p_rec.business_group_id,
539    p_object_version_number => p_rec.object_version_number);
540   --
541   chk_excld_flag
542   (p_elig_grd_prte_id          => p_rec.elig_grd_prte_id,
543    p_excld_flag         => p_rec.excld_flag,
544    p_effective_date        => p_effective_date,
545    p_object_version_number => p_rec.object_version_number);
546   --
547  chk_duplicate_ordr_num
548 ( p_elig_grd_prte_id             => p_rec.elig_grd_prte_id
549  ,p_eligy_prfl_id             	 => p_rec.eligy_prfl_id
550  ,p_ordr_num                  	 => p_rec.ordr_num
551  ,p_business_group_id         	 => p_rec.business_group_id);
552  --
553   hr_utility.set_location(' Leaving:'||l_proc, 10);
554 End insert_validate;
555 --
556 -- ----------------------------------------------------------------------------
557 -- |---------------------------< update_validate >----------------------------|
558 -- ----------------------------------------------------------------------------
559 Procedure update_validate
560 	(p_rec 			 in ben_egr_shd.g_rec_type,
561 	 p_effective_date	 in date,
562 	 p_datetrack_mode	 in varchar2,
563 	 p_validation_start_date in date,
564 	 p_validation_end_date	 in date) is
565 --
566   l_proc	varchar2(72) := g_package||'update_validate';
567 --
568 Begin
569   hr_utility.set_location('Entering:'||l_proc, 5);
570   --
571   -- Call all supporting business operations
572   --
573   --
574   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
575   --
576   chk_elig_grd_prte_id
577   (p_elig_grd_prte_id          => p_rec.elig_grd_prte_id,
578    p_effective_date        => p_effective_date,
579    p_object_version_number => p_rec.object_version_number);
580   --
581   chk_grade_id
582   (p_elig_grd_prte_id          => p_rec.elig_grd_prte_id,
583    p_grade_id              => p_rec.grade_id,
584    p_eligy_prfl_id         => p_rec.eligy_prfl_id,
585    p_validation_start_date => p_validation_start_date,
586    p_validation_end_date   => p_validation_end_date,
587    p_effective_date        => p_effective_date,
588    p_business_group_id     => p_rec.business_group_id,
589    p_object_version_number => p_rec.object_version_number);
590   --
591   chk_excld_flag
592   (p_elig_grd_prte_id          => p_rec.elig_grd_prte_id,
593    p_excld_flag         => p_rec.excld_flag,
594    p_effective_date        => p_effective_date,
595    p_object_version_number => p_rec.object_version_number);
596   --
597  chk_duplicate_ordr_num
598 ( p_elig_grd_prte_id             => p_rec.elig_grd_prte_id
599  ,p_eligy_prfl_id             	 => p_rec.eligy_prfl_id
600  ,p_ordr_num                  	 => p_rec.ordr_num
601  ,p_business_group_id         	 => p_rec.business_group_id);
602  --
603  -- Call the datetrack update integrity operation
604   --
605   dt_update_validate
606     (p_eligy_prfl_id                 => p_rec.eligy_prfl_id,
607      p_datetrack_mode                => p_datetrack_mode,
608      p_validation_start_date	     => p_validation_start_date,
609      p_validation_end_date	     => p_validation_end_date);
610   --
611   hr_utility.set_location(' Leaving:'||l_proc, 10);
612 End update_validate;
613 --
614 -- ----------------------------------------------------------------------------
615 -- |---------------------------< delete_validate >----------------------------|
616 -- ----------------------------------------------------------------------------
617 Procedure delete_validate
618 	(p_rec 			 in ben_egr_shd.g_rec_type,
619 	 p_effective_date	 in date,
620 	 p_datetrack_mode	 in varchar2,
621 	 p_validation_start_date in date,
622 	 p_validation_end_date	 in date) is
623 --
624   l_proc	varchar2(72) := g_package||'delete_validate';
625 --
626 Begin
627   hr_utility.set_location('Entering:'||l_proc, 5);
628   --
629   -- Call all supporting business operations
630   --
631   dt_delete_validate
632     (p_datetrack_mode		=> p_datetrack_mode,
633      p_validation_start_date	=> p_validation_start_date,
634      p_validation_end_date	=> p_validation_end_date,
635      p_elig_grd_prte_id		=> p_rec.elig_grd_prte_id);
636   --
637   hr_utility.set_location(' Leaving:'||l_proc, 10);
638 End delete_validate;
639 --
640 --
641 --  ---------------------------------------------------------------------------
642 --  |---------------------< return_legislation_code >-------------------------|
643 --  ---------------------------------------------------------------------------
644 --
645 function return_legislation_code
646   (p_elig_grd_prte_id in number) return varchar2 is
647   --
648   -- Declare cursor
649   --
650   cursor csr_leg_code is
651     select a.legislation_code
652     from   per_business_groups a,
653            ben_elig_grd_prte_f b
654     where b.elig_grd_prte_id      = p_elig_grd_prte_id
655     and   a.business_group_id = b.business_group_id;
656   --
657   -- Declare local variables
658   --
659   l_legislation_code  varchar2(150);
660   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
661   --
662 begin
663   --
664   hr_utility.set_location('Entering:'|| l_proc, 10);
665   --
666   -- Ensure that all the mandatory parameter are not null
667   --
668   hr_api.mandatory_arg_error(p_api_name       => l_proc,
669                              p_argument       => 'elig_grd_prte_id',
670                              p_argument_value => p_elig_grd_prte_id);
671   --
672   open csr_leg_code;
673     --
674     fetch csr_leg_code into l_legislation_code;
675     --
676     if csr_leg_code%notfound then
677       --
678       close csr_leg_code;
679       --
680       -- The primary key is invalid therefore we must error
681       --
682       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
683       fnd_message.raise_error;
684       --
685     end if;
686     --
687   close csr_leg_code;
688   --
689   hr_utility.set_location(' Leaving:'|| l_proc, 20);
690   --
691   return l_legislation_code;
692   --
693 end return_legislation_code;
694 --
695 end ben_egr_bus;