DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_VRP_BUS

Source


1 Package Body ben_vrp_bus as
2 /* $Header: bevrprhi.pkb 120.0.12010000.3 2008/08/05 15:45:59 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_vrp_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_vald_rlshp_for_reimb_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 --   vald_rlshp_for_reimb_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_vald_rlshp_for_reimb_id(p_vald_rlshp_for_reimb_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_vald_rlshp_for_reimb_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_vrp_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_vald_rlshp_for_reimb_id                => p_vald_rlshp_for_reimb_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_vald_rlshp_for_reimb_id,hr_api.g_number)
55      <>  ben_vrp_shd.g_old_rec.vald_rlshp_for_reimb_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_vrp_shd.constraint_error('BEN_VALD_RLSHP_FOR_REIMB_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_vald_rlshp_for_reimb_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_vrp_shd.constraint_error('BEN_VALD_RLSHP_FOR_REIMB_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_vald_rlshp_for_reimb_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |------< chk_rlshp_typ_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 --   vald_rlshp_for_reimb_id PK of record being inserted or updated.
91 --   rlshp_typ_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_rlshp_typ_cd(p_vald_rlshp_for_reimb_id                in number,
106                             p_rlshp_typ_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_rlshp_typ_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_vrp_shd.api_updating
118     (p_vald_rlshp_for_reimb_id                => p_vald_rlshp_for_reimb_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_rlshp_typ_cd
124       <> nvl(ben_vrp_shd.g_old_rec.rlshp_typ_cd,hr_api.g_varchar2)
125       or not l_api_updating)
126       and p_rlshp_typ_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    => 'CONTACT',
132            p_lookup_code    => p_rlshp_typ_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_rlshp_typ_cd;
147 --
148 -- ----------------------------------------------------------------------------
149 -- |--------------------------< dt_update_validate >--------------------------|
150 -- ----------------------------------------------------------------------------
151 -- {Start Of Comments}
152 --
153 -- Description:
154 --   This procedure is used for referential integrity of datetracked
155 --   parent entities when a datetrack update operation is taking place
156 --   and where there is no cascading of update defined for this entity.
157 --
158 -- Prerequisites:
159 --   This procedure is called from the update_validate.
160 --
161 -- In Parameters:
162 --
163 -- Post Success:
164 --   Processing continues.
165 --
166 -- Post Failure:
167 --
168 -- Developer Implementation Notes:
169 --   This procedure should not need maintenance unless the HR Schema model
170 --   changes.
171 --
172 -- Access Status:
173 --   Internal Row Handler Use Only.
174 --
175 -- {End Of Comments}
176 -- ----------------------------------------------------------------------------
177 Procedure dt_update_validate
178             (p_pl_id                         in number default hr_api.g_number,
179 	     p_datetrack_mode		     in varchar2,
180              p_validation_start_date	     in date,
181 	     p_validation_end_date	     in date) Is
182 --
183   l_proc	    varchar2(72) := g_package||'dt_update_validate';
184   l_integrity_error Exception;
185   l_table_name	    all_tables.table_name%TYPE;
186 --
187 Begin
188   hr_utility.set_location('Entering:'||l_proc, 5);
189   --
190   -- Ensure that the p_datetrack_mode argument is not null
191   --
192   hr_api.mandatory_arg_error
193     (p_api_name       => l_proc,
194      p_argument       => 'datetrack_mode',
195      p_argument_value => p_datetrack_mode);
196   --
197   -- Only perform the validation if the datetrack update mode is valid
198   --
199   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
200     --
201     --
202     -- Ensure the arguments are not null
203     --
204     hr_api.mandatory_arg_error
205       (p_api_name       => l_proc,
206        p_argument       => 'validation_start_date',
207        p_argument_value => p_validation_start_date);
208     --
209     hr_api.mandatory_arg_error
210       (p_api_name       => l_proc,
211        p_argument       => 'validation_end_date',
212        p_argument_value => p_validation_end_date);
213     --
214     If ((nvl(p_pl_id, hr_api.g_number) <> hr_api.g_number) and
215       NOT (dt_api.check_min_max_dates
216             (p_base_table_name => 'ben_pl_f',
217              p_base_key_column => 'pl_id',
218              p_base_key_value  => p_pl_id,
219              p_from_date       => p_validation_start_date,
220              p_to_date         => p_validation_end_date)))  Then
221       l_table_name := 'ben_pl_f';
222       Raise l_integrity_error;
223     End If;
224     --
225   End If;
226   --
227   hr_utility.set_location(' Leaving:'||l_proc, 10);
228 Exception
229   When l_integrity_error Then
230     --
231     -- A referential integrity check was violated therefore
232     -- we must error
233     --
234     hr_utility.set_message(801, 'HR_7216_DT_UPD_INTEGRITY_ERR');
235     hr_utility.set_message_token('TABLE_NAME', l_table_name);
236     hr_utility.raise_error;
237   When Others Then
238     --
239     -- An unhandled or unexpected error has occurred which
240     -- we must report
241     --
242     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
243     hr_utility.set_message_token('PROCEDURE', l_proc);
244     hr_utility.set_message_token('STEP','15');
245     hr_utility.raise_error;
246 End dt_update_validate;
247 --
248 -- ----------------------------------------------------------------------------
249 -- |--------------------------< dt_delete_validate >--------------------------|
250 -- ----------------------------------------------------------------------------
251 -- {Start Of Comments}
252 --
253 -- Description:
254 --   This procedure is used for referential integrity of datetracked
255 --   child entities when either a datetrack DELETE or ZAP is in operation
256 --   and where there is no cascading of delete defined for this entity.
257 --   For the datetrack mode of DELETE or ZAP we must ensure that no
258 --   datetracked child rows exist between the validation start and end
259 --   dates.
260 --
261 -- Prerequisites:
262 --   This procedure is called from the delete_validate.
263 --
264 -- In Parameters:
265 --
266 -- Post Success:
267 --   Processing continues.
268 --
269 -- Post Failure:
270 --   If a row exists by determining the returning Boolean value from the
271 --   generic dt_api.rows_exist function then we must supply an error via
272 --   the use of the local exception handler l_rows_exist.
273 --
274 -- Developer Implementation Notes:
275 --   This procedure should not need maintenance unless the HR Schema model
276 --   changes.
277 --
278 -- Access Status:
279 --   Internal Row Handler Use Only.
280 --
281 -- {End Of Comments}
282 -- ----------------------------------------------------------------------------
283 Procedure dt_delete_validate
284             (p_vald_rlshp_for_reimb_id		in number,
285              p_datetrack_mode		in varchar2,
286 	     p_validation_start_date	in date,
287 	     p_validation_end_date	in date) Is
288 --
289   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
290   l_rows_exist	Exception;
291   l_table_name	all_tables.table_name%TYPE;
292 --
293 Begin
294   hr_utility.set_location('Entering:'||l_proc, 5);
295   --
296   -- Ensure that the p_datetrack_mode argument is not null
297   --
298   hr_api.mandatory_arg_error
299     (p_api_name       => l_proc,
300      p_argument       => 'datetrack_mode',
301      p_argument_value => p_datetrack_mode);
302   --
303   -- Only perform the validation if the datetrack mode is either
304   -- DELETE or ZAP
305   --
306   If (p_datetrack_mode = 'DELETE' or
307       p_datetrack_mode = 'ZAP') then
308     --
309     --
310     -- Ensure the arguments are not null
311     --
312     hr_api.mandatory_arg_error
313       (p_api_name       => l_proc,
314        p_argument       => 'validation_start_date',
315        p_argument_value => p_validation_start_date);
316     --
317     hr_api.mandatory_arg_error
318       (p_api_name       => l_proc,
319        p_argument       => 'validation_end_date',
320        p_argument_value => p_validation_end_date);
321     --
322     hr_api.mandatory_arg_error
323       (p_api_name       => l_proc,
324        p_argument       => 'vald_rlshp_for_reimb_id',
325        p_argument_value => p_vald_rlshp_for_reimb_id);
326     --
327     --
328     --
329   End If;
330   --
331   hr_utility.set_location(' Leaving:'||l_proc, 10);
332 Exception
333   When l_rows_exist Then
334     --
335     -- A referential integrity check was violated therefore
336     -- we must error
337     --
338     hr_utility.set_message(801, 'HR_7215_DT_CHILD_EXISTS');
339     hr_utility.set_message_token('TABLE_NAME', l_table_name);
340     hr_utility.raise_error;
341   When Others Then
342     --
343     -- An unhandled or unexpected error has occurred which
344     -- we must report
345     --
346     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
347     hr_utility.set_message_token('PROCEDURE', l_proc);
348     hr_utility.set_message_token('STEP','15');
349     hr_utility.raise_error;
350 End dt_delete_validate;
351 --
352 -- ----------------------------------------------------------------------------
353 -- |---------------------------< insert_validate >----------------------------|
354 -- ----------------------------------------------------------------------------
355 Procedure insert_validate
356 	(p_rec 			 in ben_vrp_shd.g_rec_type,
357 	 p_effective_date	 in date,
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||'insert_validate';
363 --
364 Begin
365   hr_utility.set_location('Entering:'||l_proc, 5);
366   --
367   -- Call all supporting business operations
368   --
369   --
370   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
371   --
372   chk_vald_rlshp_for_reimb_id
373   (p_vald_rlshp_for_reimb_id          => p_rec.vald_rlshp_for_reimb_id,
374    p_effective_date        => p_effective_date,
375    p_object_version_number => p_rec.object_version_number);
376   --
377   chk_rlshp_typ_cd
378   (p_vald_rlshp_for_reimb_id          => p_rec.vald_rlshp_for_reimb_id,
379    p_rlshp_typ_cd         => p_rec.rlshp_typ_cd,
380    p_effective_date        => p_effective_date,
381    p_object_version_number => p_rec.object_version_number);
382   --
383   hr_utility.set_location(' Leaving:'||l_proc, 10);
384 End insert_validate;
385 --
386 -- ----------------------------------------------------------------------------
387 -- |---------------------------< update_validate >----------------------------|
388 -- ----------------------------------------------------------------------------
389 Procedure update_validate
390 	(p_rec 			 in ben_vrp_shd.g_rec_type,
391 	 p_effective_date	 in date,
392 	 p_datetrack_mode	 in varchar2,
393 	 p_validation_start_date in date,
394 	 p_validation_end_date	 in date) is
395 --
396   l_proc	varchar2(72) := g_package||'update_validate';
397 --
398 Begin
399   hr_utility.set_location('Entering:'||l_proc, 5);
400   --
401   -- Call all supporting business operations
402   --
403   --
404   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
405   --
406   chk_vald_rlshp_for_reimb_id
407   (p_vald_rlshp_for_reimb_id          => p_rec.vald_rlshp_for_reimb_id,
408    p_effective_date        => p_effective_date,
409    p_object_version_number => p_rec.object_version_number);
410   --
411   chk_rlshp_typ_cd
412   (p_vald_rlshp_for_reimb_id          => p_rec.vald_rlshp_for_reimb_id,
413    p_rlshp_typ_cd         => p_rec.rlshp_typ_cd,
414    p_effective_date        => p_effective_date,
415    p_object_version_number => p_rec.object_version_number);
416   --
417   -- Call the datetrack update integrity operation
418   --
419   dt_update_validate
420     (p_pl_id                         => p_rec.pl_id,
421      p_datetrack_mode                => p_datetrack_mode,
422      p_validation_start_date	     => p_validation_start_date,
423      p_validation_end_date	     => p_validation_end_date);
424   --
425   hr_utility.set_location(' Leaving:'||l_proc, 10);
426 End update_validate;
427 --
428 -- ----------------------------------------------------------------------------
429 -- |---------------------------< delete_validate >----------------------------|
430 -- ----------------------------------------------------------------------------
431 Procedure delete_validate
432 	(p_rec 			 in ben_vrp_shd.g_rec_type,
433 	 p_effective_date	 in date,
434 	 p_datetrack_mode	 in varchar2,
435 	 p_validation_start_date in date,
436 	 p_validation_end_date	 in date) is
437 --
438   l_proc	varchar2(72) := g_package||'delete_validate';
439 --
440 Begin
441   hr_utility.set_location('Entering:'||l_proc, 5);
442   --
443   -- Call all supporting business operations
444   --
445   dt_delete_validate
446     (p_datetrack_mode		=> p_datetrack_mode,
447      p_validation_start_date	=> p_validation_start_date,
448      p_validation_end_date	=> p_validation_end_date,
449      p_vald_rlshp_for_reimb_id		=> p_rec.vald_rlshp_for_reimb_id);
450   --
451   hr_utility.set_location(' Leaving:'||l_proc, 10);
452 End delete_validate;
453 --
454 --
455 --  ---------------------------------------------------------------------------
456 --  |---------------------< return_legislation_code >-------------------------|
457 --  ---------------------------------------------------------------------------
458 --
459 function return_legislation_code
460   (p_vald_rlshp_for_reimb_id in number) return varchar2 is
461   --
462   -- Declare cursor
463   --
464   cursor csr_leg_code is
465     select a.legislation_code
466     from   per_business_groups a,
467            ben_vald_rlshp_for_reimb_f b
468     where b.vald_rlshp_for_reimb_id      = p_vald_rlshp_for_reimb_id
469     and   a.business_group_id = b.business_group_id;
470   --
471   -- Declare local variables
472   --
473   l_legislation_code  varchar2(150);
474   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
475   --
476 begin
477   --
478   hr_utility.set_location('Entering:'|| l_proc, 10);
479   --
480   -- Ensure that all the mandatory parameter are not null
481   --
482   hr_api.mandatory_arg_error(p_api_name       => l_proc,
483                              p_argument       => 'vald_rlshp_for_reimb_id',
484                              p_argument_value => p_vald_rlshp_for_reimb_id);
485   --
486   open csr_leg_code;
487     --
488     fetch csr_leg_code into l_legislation_code;
489     --
490     if csr_leg_code%notfound then
491       --
492       close csr_leg_code;
493       --
494       -- The primary key is invalid therefore we must error
495       --
496       hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
497       hr_utility.raise_error;
498       --
499     end if;
500     --
501   close csr_leg_code;
502   --
503   hr_utility.set_location(' Leaving:'|| l_proc, 20);
504   --
505   return l_legislation_code;
506   --
507 end return_legislation_code;
508 --
509 end ben_vrp_bus;