DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_WPN_BUS

Source


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