DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_NOC_BUS

Source


1 Package Body ben_noc_bus as
2 /* $Header: benocrhi.pkb 120.0 2005/05/28 09:10:24 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_noc_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_no_othr_cvg_rt_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 --   no_othr_cvg_rt_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_no_othr_cvg_rt_id(p_no_othr_cvg_rt_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_no_othr_cvg_rt_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_noc_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_no_othr_cvg_rt_id                => p_no_othr_cvg_rt_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_no_othr_cvg_rt_id,hr_api.g_number)
55      <>  ben_noc_shd.g_old_rec.no_othr_cvg_rt_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_noc_shd.constraint_error('BEN_NO_OTHR_CVG_RT_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_no_othr_cvg_rt_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_noc_shd.constraint_error('BEN_NO_OTHR_CVG_RT_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_no_othr_cvg_rt_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |------< chk_coord_ben_no_cvg_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 --   no_othr_cvg_rt_id PK of record being inserted or updated.
91 --   coord_ben_no_cvg_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_coord_ben_no_cvg_flag(p_no_othr_cvg_rt_id                in number,
106                             p_coord_ben_no_cvg_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_coord_ben_no_cvg_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_noc_shd.api_updating
118     (p_no_othr_cvg_rt_id                => p_no_othr_cvg_rt_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_coord_ben_no_cvg_flag
124       <> nvl(ben_noc_shd.g_old_rec.coord_ben_no_cvg_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_coord_ben_no_cvg_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_coord_ben_no_cvg_flag');
139       fnd_message.set_token('TYPE','YES_NO');
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_coord_ben_no_cvg_flag;
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_vrbl_rt_prfl_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_vrbl_rt_prfl_id, hr_api.g_number) <> hr_api.g_number) and
217       NOT (dt_api.check_min_max_dates
218             (p_base_table_name => 'ben_vrbl_rt_prfl_f',
219              p_base_key_column => 'vrbl_rt_prfl_id',
220              p_base_key_value  => p_vrbl_rt_prfl_id,
221              p_from_date       => p_validation_start_date,
222              p_to_date         => p_validation_end_date)))  Then
223       l_table_name := 'ben_vrbl_rt_prfl_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     --
236     ben_utility.parent_integrity_error(p_table_name => l_table_name);
237     --
238   When Others Then
239     --
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_no_othr_cvg_rt_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       => 'no_othr_cvg_rt_id',
326        p_argument_value => p_no_othr_cvg_rt_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     fnd_message.set_name('PAY', 'HR_7215_DT_CHILD_EXISTS');
340     fnd_message.set_token('TABLE_NAME', l_table_name);
341     fnd_message.raise_error;
342   When Others Then
343     --
344     -- An unhandled or unexpected error has occurred which
345     -- we must report
346     --
347     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
348     fnd_message.set_token('PROCEDURE', l_proc);
349     fnd_message.set_token('STEP','15');
350     fnd_message.raise_error;
351 End dt_delete_validate;
352 --
353 -- ----------------------------------------------------------------------------
354 -- |---------------------------< insert_validate >----------------------------|
355 -- ----------------------------------------------------------------------------
356 Procedure insert_validate
357 	(p_rec 			 in ben_noc_shd.g_rec_type,
358 	 p_effective_date	 in date,
359 	 p_datetrack_mode	 in varchar2,
360 	 p_validation_start_date in date,
361 	 p_validation_end_date	 in date) is
362 --
363   l_proc	varchar2(72) := g_package||'insert_validate';
364 --
365 Begin
366   hr_utility.set_location('Entering:'||l_proc, 5);
367   --
368   -- Call all supporting business operations
369   --
370   --
371   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
372   --
373   chk_no_othr_cvg_rt_id
374   (p_no_othr_cvg_rt_id          => p_rec.no_othr_cvg_rt_id,
375    p_effective_date        => p_effective_date,
376    p_object_version_number => p_rec.object_version_number);
377   --
378   chk_coord_ben_no_cvg_flag
379   (p_no_othr_cvg_rt_id          => p_rec.no_othr_cvg_rt_id,
380    p_coord_ben_no_cvg_flag         => p_rec.coord_ben_no_cvg_flag,
381    p_effective_date        => p_effective_date,
382    p_object_version_number => p_rec.object_version_number);
383   --
384   hr_utility.set_location(' Leaving:'||l_proc, 10);
385 End insert_validate;
386 --
387 -- ----------------------------------------------------------------------------
388 -- |---------------------------< update_validate >----------------------------|
389 -- ----------------------------------------------------------------------------
390 Procedure update_validate
391 	(p_rec 			 in ben_noc_shd.g_rec_type,
392 	 p_effective_date	 in date,
393 	 p_datetrack_mode	 in varchar2,
394 	 p_validation_start_date in date,
395 	 p_validation_end_date	 in date) is
396 --
397   l_proc	varchar2(72) := g_package||'update_validate';
398 --
399 Begin
400   hr_utility.set_location('Entering:'||l_proc, 5);
401   --
402   -- Call all supporting business operations
403   --
404   --
405   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
406   --
407   chk_no_othr_cvg_rt_id
408   (p_no_othr_cvg_rt_id          => p_rec.no_othr_cvg_rt_id,
409    p_effective_date        => p_effective_date,
410    p_object_version_number => p_rec.object_version_number);
411   --
412   chk_coord_ben_no_cvg_flag
413   (p_no_othr_cvg_rt_id          => p_rec.no_othr_cvg_rt_id,
414    p_coord_ben_no_cvg_flag         => p_rec.coord_ben_no_cvg_flag,
415    p_effective_date        => p_effective_date,
416    p_object_version_number => p_rec.object_version_number);
417   --
418   -- Call the datetrack update integrity operation
419   --
420   dt_update_validate
421     (p_vrbl_rt_prfl_id                 => p_rec.vrbl_rt_prfl_id,
422      p_datetrack_mode                => p_datetrack_mode,
423      p_validation_start_date	     => p_validation_start_date,
424      p_validation_end_date	     => p_validation_end_date);
425   --
426   hr_utility.set_location(' Leaving:'||l_proc, 10);
427 End update_validate;
428 --
429 -- ----------------------------------------------------------------------------
430 -- |---------------------------< delete_validate >----------------------------|
431 -- ----------------------------------------------------------------------------
432 Procedure delete_validate
433 	(p_rec 			 in ben_noc_shd.g_rec_type,
434 	 p_effective_date	 in date,
435 	 p_datetrack_mode	 in varchar2,
436 	 p_validation_start_date in date,
437 	 p_validation_end_date	 in date) is
438 --
439   l_proc	varchar2(72) := g_package||'delete_validate';
440 --
441 Begin
442   hr_utility.set_location('Entering:'||l_proc, 5);
443   --
444   -- Call all supporting business operations
445   --
446   dt_delete_validate
447     (p_datetrack_mode		=> p_datetrack_mode,
448      p_validation_start_date	=> p_validation_start_date,
449      p_validation_end_date	=> p_validation_end_date,
450      p_no_othr_cvg_rt_id		=> p_rec.no_othr_cvg_rt_id);
451   --
452   hr_utility.set_location(' Leaving:'||l_proc, 10);
453 End delete_validate;
454 --
455 --
456 --  ---------------------------------------------------------------------------
457 --  |---------------------< return_legislation_code >-------------------------|
458 --  ---------------------------------------------------------------------------
459 --
460 function return_legislation_code
461   (p_no_othr_cvg_rt_id in number) return varchar2 is
462   --
463   -- Declare cursor
464   --
465   cursor csr_leg_code is
466     select a.legislation_code
467     from   per_business_groups a,
468            ben_no_othr_cvg_rt_f b
469     where b.no_othr_cvg_rt_id      = p_no_othr_cvg_rt_id
470     and   a.business_group_id = b.business_group_id;
471   --
472   -- Declare local variables
473   --
474   l_legislation_code  varchar2(150);
475   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
476   --
477 begin
478   --
479   hr_utility.set_location('Entering:'|| l_proc, 10);
480   --
481   -- Ensure that all the mandatory parameter are not null
482   --
483   hr_api.mandatory_arg_error(p_api_name       => l_proc,
484                              p_argument       => 'no_othr_cvg_rt_id',
485                              p_argument_value => p_no_othr_cvg_rt_id);
486   --
487   open csr_leg_code;
488     --
489     fetch csr_leg_code into l_legislation_code;
490     --
491     if csr_leg_code%notfound then
492       --
493       close csr_leg_code;
494       --
495       -- The primary key is invalid therefore we must error
496       --
497       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
498       fnd_message.raise_error;
499       --
500     end if;
501     --
502   close csr_leg_code;
503   --
504   hr_utility.set_location(' Leaving:'|| l_proc, 20);
505   --
506   return l_legislation_code;
507   --
508 end return_legislation_code;
509 --
510 end ben_noc_bus;