DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PRP_BUS

Source


1 Package Body ben_prp_bus as
2 /* $Header: beprprhi.pkb 120.1 2008/02/05 09:38:47 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_prp_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_pl_regy_prps_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 --   pl_regy_prps_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_pl_regy_prps_id(p_pl_regy_prps_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_pl_regy_prps_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_prp_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_pl_regy_prps_id                => p_pl_regy_prps_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_pl_regy_prps_id,hr_api.g_number)
55      <>  ben_prp_shd.g_old_rec.pl_regy_prps_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_prp_shd.constraint_error('BEN_PL_REGY_PRP_F_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_pl_regy_prps_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_prp_shd.constraint_error('BEN_PL_REGY_PRP_F_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_pl_regy_prps_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |------< chk_pl_regy_prps_cd >------|
81 -- ----------------------------------------------------------------------------
82 --
83 -- Description
84 --   This procedure is used to check that the lookup value is valid.
85 --
89 -- In Parameters
86 -- Pre Conditions
87 --   None.
88 --
90 --   pl_regy_prps_id PK of record being inserted or updated.
91 --   pl_regy_prps_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_pl_regy_prps_cd(p_pl_regy_prps_id                in number,
106                             p_pl_regy_prps_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_pl_regy_prps_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_prp_shd.api_updating
118     (p_pl_regy_prps_id                => p_pl_regy_prps_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_pl_regy_prps_cd
124       <> nvl(ben_prp_shd.g_old_rec.pl_regy_prps_cd,hr_api.g_varchar2)
125       or not l_api_updating)
126       and p_pl_regy_prps_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_REGY_PRPS',
132            p_lookup_code    => p_pl_regy_prps_cd,
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_pl_regy_prps_cd');
139       fnd_message.set_token('TYPE', 'BEN_REGY_PRPS');
140       fnd_message.raise_error;
141       --
142     end if;
143     --
144   end if;
145   --
146   hr_utility.set_location('Leaving:'||l_proc,10);
147   --
148 end chk_pl_regy_prps_cd;
149 --
150 -- ----------------------------------------------------------------------------
151 -- |--------------------------< dt_update_validate >--------------------------|
152 -- ----------------------------------------------------------------------------
153 -- {Start Of Comments}
154 --
155 -- Description:
156 --   This procedure is used for referential integrity of datetracked
157 --   parent entities when a datetrack update operation is taking place
158 --   and where there is no cascading of update defined for this entity.
159 --
160 -- Prerequisites:
161 --   This procedure is called from the update_validate.
162 --
163 -- In Parameters:
164 --
165 -- Post Success:
166 --   Processing continues.
167 --
168 -- Post Failure:
169 --
170 -- Developer Implementation Notes:
171 --   This procedure should not need maintenance unless the HR Schema model
172 --   changes.
173 --
174 -- Access Status:
175 --   Internal Row Handler Use Only.
176 --
177 -- {End Of Comments}
178 -- ----------------------------------------------------------------------------
179 Procedure dt_update_validate
180             (p_pl_regy_bod_id                in number default hr_api.g_number,
181 	     p_datetrack_mode		     in varchar2,
182              p_validation_start_date	     in date,
183 	     p_validation_end_date	     in date) Is
184 --
185   l_proc	    varchar2(72) := g_package||'dt_update_validate';
186   l_integrity_error Exception;
187   l_table_name	    all_tables.table_name%TYPE;
188 --
189 Begin
190   hr_utility.set_location('Entering:'||l_proc, 5);
191   --
192   -- Ensure that the p_datetrack_mode argument is not null
193   --
194   hr_api.mandatory_arg_error
195     (p_api_name       => l_proc,
196      p_argument       => 'datetrack_mode',
197      p_argument_value => p_datetrack_mode);
198   --
199   -- Only perform the validation if the datetrack update mode is valid
200   --
201   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
202     --
203     --
204     -- Ensure the arguments are not null
205     --
206     hr_api.mandatory_arg_error
207       (p_api_name       => l_proc,
208        p_argument       => 'validation_start_date',
209        p_argument_value => p_validation_start_date);
210     --
211     hr_api.mandatory_arg_error
212       (p_api_name       => l_proc,
213        p_argument       => 'validation_end_date',
214        p_argument_value => p_validation_end_date);
215     --
216     If ((nvl(p_pl_regy_bod_id, hr_api.g_number) <> hr_api.g_number) and
217       NOT (dt_api.check_min_max_dates
218             (p_base_table_name => 'ben_pl_regy_bod_f',
219              p_base_key_column => 'pl_regy_bod_id',
220              p_base_key_value  => p_pl_regy_bod_id,
221              p_from_date       => p_validation_start_date,
222              p_to_date         => p_validation_end_date)))  Then
223       l_table_name := 'ben_pl_regy_bod_f';
224       Raise l_integrity_error;
225     End If;
226     --
227   End If;
228   --
229   hr_utility.set_location(' Leaving:'||l_proc, 10);
230 Exception
231   When l_integrity_error Then
232     --
233     -- A referential integrity check was violated therefore
234     -- we must error
235     --
239     --
236     ben_utility.parent_integrity_error(p_table_name => l_table_name);
237     --
238   When Others Then
240     -- An unhandled or unexpected error has occurred which
241     -- we must report
242     --
243     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
244     fnd_message.set_token('PROCEDURE', l_proc);
245     fnd_message.set_token('STEP','15');
246     fnd_message.raise_error;
247 End dt_update_validate;
248 --
249 -- ----------------------------------------------------------------------------
250 -- |--------------------------< dt_delete_validate >--------------------------|
251 -- ----------------------------------------------------------------------------
252 -- {Start Of Comments}
253 --
254 -- Description:
255 --   This procedure is used for referential integrity of datetracked
256 --   child entities when either a datetrack DELETE or ZAP is in operation
257 --   and where there is no cascading of delete defined for this entity.
258 --   For the datetrack mode of DELETE or ZAP we must ensure that no
259 --   datetracked child rows exist between the validation start and end
260 --   dates.
261 --
262 -- Prerequisites:
263 --   This procedure is called from the delete_validate.
264 --
265 -- In Parameters:
266 --
267 -- Post Success:
268 --   Processing continues.
269 --
270 -- Post Failure:
271 --   If a row exists by determining the returning Boolean value from the
272 --   generic dt_api.rows_exist function then we must supply an error via
273 --   the use of the local exception handler l_rows_exist.
274 --
275 -- Developer Implementation Notes:
276 --   This procedure should not need maintenance unless the HR Schema model
277 --   changes.
278 --
279 -- Access Status:
280 --   Internal Row Handler Use Only.
281 --
282 -- {End Of Comments}
283 -- ----------------------------------------------------------------------------
284 Procedure dt_delete_validate
285             (p_pl_regy_prps_id		in number,
286              p_datetrack_mode		in varchar2,
287 	     p_validation_start_date	in date,
288 	     p_validation_end_date	in date) Is
289 --
290   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
291   l_rows_exist	Exception;
292   l_table_name	all_tables.table_name%TYPE;
293 --
294 Begin
295   hr_utility.set_location('Entering:'||l_proc, 5);
296   --
297   -- Ensure that the p_datetrack_mode argument is not null
298   --
299   hr_api.mandatory_arg_error
300     (p_api_name       => l_proc,
301      p_argument       => 'datetrack_mode',
302      p_argument_value => p_datetrack_mode);
303   --
304   -- Only perform the validation if the datetrack mode is either
305   -- DELETE or ZAP
306   --
307   If (p_datetrack_mode = 'DELETE' or
308       p_datetrack_mode = 'ZAP') then
309     --
310     --
311     -- Ensure the arguments are not null
312     --
313     hr_api.mandatory_arg_error
314       (p_api_name       => l_proc,
315        p_argument       => 'validation_start_date',
316        p_argument_value => p_validation_start_date);
317     --
318     hr_api.mandatory_arg_error
319       (p_api_name       => l_proc,
320        p_argument       => 'validation_end_date',
321        p_argument_value => p_validation_end_date);
322     --
323     hr_api.mandatory_arg_error
324       (p_api_name       => l_proc,
325        p_argument       => 'pl_regy_prps_id',
326        p_argument_value => p_pl_regy_prps_id);
327     --
328     --
329     --
330   End If;
331   --
332   hr_utility.set_location(' Leaving:'||l_proc, 10);
333 Exception
334   When l_rows_exist Then
335     --
336     -- A referential integrity check was violated therefore
337     -- we must error
338     --
339     ben_utility.child_exists_error(p_table_name => l_table_name);
340     --
341   When Others Then
342     --
343     -- An unhandled or unexpected error has occurred which
344     -- we must report
345     --
346     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
347     fnd_message.set_token('PROCEDURE', l_proc);
348     fnd_message.set_token('STEP','15');
349     fnd_message.raise_error;
350 End dt_delete_validate;
351 --
352 -- ----------------------------------------------------------------------------
353 -- |---------------------------< insert_validate >----------------------------|
354 -- ----------------------------------------------------------------------------
355 Procedure insert_validate
356 	(p_rec 			 in ben_prp_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_pl_regy_prps_id
373   (p_pl_regy_prps_id          => p_rec.pl_regy_prps_id,
374    p_effective_date        => p_effective_date,
375    p_object_version_number => p_rec.object_version_number);
376   --
377   chk_pl_regy_prps_cd
378   (p_pl_regy_prps_id          => p_rec.pl_regy_prps_id,
379    p_pl_regy_prps_cd         => p_rec.pl_regy_prps_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_prp_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_pl_regy_prps_id
407   (p_pl_regy_prps_id          => p_rec.pl_regy_prps_id,
408    p_effective_date        => p_effective_date,
409    p_object_version_number => p_rec.object_version_number);
410   --
411   chk_pl_regy_prps_cd
412   (p_pl_regy_prps_id          => p_rec.pl_regy_prps_id,
413    p_pl_regy_prps_cd         => p_rec.pl_regy_prps_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_regy_bod_id                => p_rec.pl_regy_bod_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_prp_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_pl_regy_prps_id		=> p_rec.pl_regy_prps_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_pl_regy_prps_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_pl_regy_prp_f b
468     where b.pl_regy_prps_id      = p_pl_regy_prps_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       => 'pl_regy_prps_id',
484                              p_argument_value => p_pl_regy_prps_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       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
497       fnd_message.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_prp_bus;