DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CPT_BUS

Source


1 Package Body ben_cpt_bus as
2 /* $Header: becptrhi.pkb 115.5 2002/12/13 06:20:31 hmani ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_cpt_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_cmbn_ptip_opt_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 --   cmbn_ptip_opt_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 --
37 Procedure chk_cmbn_ptip_opt_id(p_cmbn_ptip_opt_id                in number,
34 -- Access Status
35 --   Internal table handler use only.
36 --
38                            p_effective_date              in date,
39                            p_object_version_number       in number) is
40   --
41   l_proc         varchar2(72) := g_package||'chk_cmbn_ptip_opt_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_cpt_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_cmbn_ptip_opt_id                => p_cmbn_ptip_opt_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_cmbn_ptip_opt_id,hr_api.g_number)
55      <>  ben_cpt_shd.g_old_rec.cmbn_ptip_opt_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_cpt_shd.constraint_error('BEN_CMBN_PTIP_OPT_F_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_cmbn_ptip_opt_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_cpt_shd.constraint_error('BEN_CMBN_PTIP_OPT_F_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_cmbn_ptip_opt_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |--------------------------< dt_update_validate >--------------------------|
81 -- ----------------------------------------------------------------------------
82 -- {Start Of Comments}
83 --
84 -- Description:
85 --   This procedure is used for referential integrity of datetracked
86 --   parent entities when a datetrack update operation is taking place
87 --   and where there is no cascading of update defined for this entity.
88 --
89 -- Prerequisites:
90 --   This procedure is called from the update_validate.
91 --
92 -- In Parameters:
93 --
94 -- Post Success:
95 --   Processing continues.
96 --
97 -- Post Failure:
98 --
99 -- Developer Implementation Notes:
100 --   This procedure should not need maintenance unless the HR Schema model
101 --   changes.
102 --
103 -- Access Status:
104 --   Internal Row Handler Use Only.
105 --
106 -- {End Of Comments}
107 -- ----------------------------------------------------------------------------
108 Procedure dt_update_validate
109             (
110 	     p_datetrack_mode		     in varchar2,
111              p_validation_start_date	     in date,
112 	     p_validation_end_date	     in date) Is
113 --
114   l_proc	    varchar2(72) := g_package||'dt_update_validate';
115   l_integrity_error Exception;
116   l_table_name	    all_tables.table_name%TYPE;
117 --
118 Begin
119   hr_utility.set_location('Entering:'||l_proc, 5);
120   --
121   -- Ensure that the p_datetrack_mode argument is not null
122   --
123   hr_api.mandatory_arg_error
124     (p_api_name       => l_proc,
125      p_argument       => 'datetrack_mode',
126      p_argument_value => p_datetrack_mode);
127   --
128   -- Only perform the validation if the datetrack update mode is valid
129   --
130   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
131     --
132     --
133     -- Ensure the arguments are not null
134     --
135     hr_api.mandatory_arg_error
136       (p_api_name       => l_proc,
137        p_argument       => 'validation_start_date',
138        p_argument_value => p_validation_start_date);
139     --
140     hr_api.mandatory_arg_error
141       (p_api_name       => l_proc,
142        p_argument       => 'validation_end_date',
143        p_argument_value => p_validation_end_date);
144     --
145     --
146     --
147   End If;
148   --
149   hr_utility.set_location(' Leaving:'||l_proc, 10);
150 Exception
151   When l_integrity_error Then
152     --
153     -- A referential integrity check was violated therefore
154     -- we must error
155     --
156     hr_utility.set_message(801, 'HR_7216_DT_UPD_INTEGRITY_ERR');
157     hr_utility.set_message_token('TABLE_NAME', l_table_name);
158     hr_utility.raise_error;
159   When Others Then
160     --
161     -- An unhandled or unexpected error has occurred which
162     -- we must report
163     --
164     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
165     hr_utility.set_message_token('PROCEDURE', l_proc);
166     hr_utility.set_message_token('STEP','15');
167     hr_utility.raise_error;
168 End dt_update_validate;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |--------------------------< dt_delete_validate >--------------------------|
172 -- ----------------------------------------------------------------------------
173 -- {Start Of Comments}
174 --
175 -- Description:
176 --   This procedure is used for referential integrity of datetracked
177 --   child entities when either a datetrack DELETE or ZAP is in operation
178 --   and where there is no cascading of delete defined for this entity.
179 --   For the datetrack mode of DELETE or ZAP we must ensure that no
180 --   datetracked child rows exist between the validation start and end
181 --   dates.
182 --
183 -- Prerequisites:
184 --   This procedure is called from the delete_validate.
185 --
186 -- In Parameters:
187 --
188 -- Post Success:
189 --   Processing continues.
190 --
191 -- Post Failure:
195 --
192 --   If a row exists by determining the returning Boolean value from the
193 --   generic dt_api.rows_exist function then we must supply an error via
194 --   the use of the local exception handler l_rows_exist.
196 -- Developer Implementation Notes:
197 --   This procedure should not need maintenance unless the HR Schema model
198 --   changes.
199 --
200 -- Access Status:
201 --   Internal Row Handler Use Only.
202 --
203 -- {End Of Comments}
204 -- ----------------------------------------------------------------------------
205 Procedure dt_delete_validate
206             (p_cmbn_ptip_opt_id		in number,
207              p_datetrack_mode		in varchar2,
208 	     p_validation_start_date	in date,
209 	     p_validation_end_date	in date) Is
210 --
211   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
212   l_rows_exist	Exception;
213   l_table_name	all_tables.table_name%TYPE;
214 --
215 Begin
216   hr_utility.set_location('Entering:'||l_proc, 5);
217   --
218   -- Ensure that the p_datetrack_mode argument is not null
219   --
220   hr_api.mandatory_arg_error
221     (p_api_name       => l_proc,
222      p_argument       => 'datetrack_mode',
223      p_argument_value => p_datetrack_mode);
224   --
225   -- Only perform the validation if the datetrack mode is either
226   -- DELETE or ZAP
227   --
228   If (p_datetrack_mode = 'DELETE' or
229       p_datetrack_mode = 'ZAP') then
230     --
231     --
232     -- Ensure the arguments are not null
233     --
234     hr_api.mandatory_arg_error
235       (p_api_name       => l_proc,
236        p_argument       => 'validation_start_date',
237        p_argument_value => p_validation_start_date);
238     --
239     hr_api.mandatory_arg_error
240       (p_api_name       => l_proc,
241        p_argument       => 'validation_end_date',
242        p_argument_value => p_validation_end_date);
243     --
244     hr_api.mandatory_arg_error
245       (p_api_name       => l_proc,
246        p_argument       => 'cmbn_ptip_opt_id',
247        p_argument_value => p_cmbn_ptip_opt_id);
248     --
249     If (dt_api.rows_exist
250           (p_base_table_name => 'ben_ptip_f',
251            p_base_key_column => 'cmbn_ptip_opt_id',
252            p_base_key_value  => p_cmbn_ptip_opt_id,
253            p_from_date       => p_validation_start_date,
254            p_to_date         => p_validation_end_date)) Then
255       l_table_name := 'ben_ptip_f';
256       Raise l_rows_exist;
257     End If;
258     If (dt_api.rows_exist
259           (p_base_table_name => 'ben_opt_f',
260            p_base_key_column => 'cmbn_ptip_opt_id',
261            p_base_key_value  => p_cmbn_ptip_opt_id,
262            p_from_date       => p_validation_start_date,
263            p_to_date         => p_validation_end_date)) Then
264       l_table_name := 'ben_opt_f';
265       Raise l_rows_exist;
266     End If;
267     If (dt_api.rows_exist
268           (p_base_table_name => 'ben_bnft_prvdr_pool_f',
269            p_base_key_column => 'cmbn_ptip_opt_id',
270            p_base_key_value  => p_cmbn_ptip_opt_id,
271            p_from_date       => p_validation_start_date,
272            p_to_date         => p_validation_end_date)) Then
273       l_table_name := 'ben_bnft_prvdr_pool_f';
274       Raise l_rows_exist;
275     End If;
276     If (dt_api.rows_exist
277           (p_base_table_name => 'ben_acty_base_rt_f',
278            p_base_key_column => 'cmbn_ptip_opt_id',
279            p_base_key_value  => p_cmbn_ptip_opt_id,
280            p_from_date       => p_validation_start_date,
281            p_to_date         => p_validation_end_date)) Then
282       l_table_name := 'ben_acty_base_rt_f';
283       Raise l_rows_exist;
284     End If;
285     --
286   End If;
287   --
288   hr_utility.set_location(' Leaving:'||l_proc, 10);
289 Exception
290   When l_rows_exist Then
291     --
292     -- A referential integrity check was violated therefore
293     -- we must error
294     --
295     hr_utility.set_message(801, 'HR_7215_DT_CHILD_EXISTS');
296     hr_utility.set_message_token('TABLE_NAME', l_table_name);
297     hr_utility.raise_error;
298   When Others Then
299     --
300     -- An unhandled or unexpected error has occurred which
301     -- we must report
302     --
303     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
304     hr_utility.set_message_token('PROCEDURE', l_proc);
305     hr_utility.set_message_token('STEP','15');
306     hr_utility.raise_error;
307 End dt_delete_validate;
308 --
309 -- ----------------------------------------------------------------------------
310 -- |---------------------------< insert_validate >----------------------------|
311 -- ----------------------------------------------------------------------------
312 Procedure insert_validate
313 	(p_rec 			 in ben_cpt_shd.g_rec_type,
314 	 p_effective_date	 in date,
315 	 p_datetrack_mode	 in varchar2,
316 	 p_validation_start_date in date,
317 	 p_validation_end_date	 in date) is
318 --
319   l_proc	varchar2(72) := g_package||'insert_validate';
320 --
321 Begin
322   hr_utility.set_location('Entering:'||l_proc, 5);
323   --
324   -- Call all supporting business operations
325   --
326   --
327   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
328   --
329   chk_cmbn_ptip_opt_id
330   (p_cmbn_ptip_opt_id          => p_rec.cmbn_ptip_opt_id,
331    p_effective_date        => p_effective_date,
332    p_object_version_number => p_rec.object_version_number);
333   --
334   hr_utility.set_location(' Leaving:'||l_proc, 10);
335 End insert_validate;
336 --
337 -- ----------------------------------------------------------------------------
338 -- |---------------------------< update_validate >----------------------------|
339 -- ----------------------------------------------------------------------------
340 Procedure update_validate
341 	(p_rec 			 in ben_cpt_shd.g_rec_type,
342 	 p_effective_date	 in date,
343 	 p_datetrack_mode	 in varchar2,
344 	 p_validation_start_date in date,
345 	 p_validation_end_date	 in date) is
346 --
347   l_proc	varchar2(72) := g_package||'update_validate';
348 --
349 Begin
350   hr_utility.set_location('Entering:'||l_proc, 5);
351   --
352   -- Call all supporting business operations
353   --
354   --
355   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
356   --
357   chk_cmbn_ptip_opt_id
358   (p_cmbn_ptip_opt_id          => p_rec.cmbn_ptip_opt_id,
359    p_effective_date        => p_effective_date,
360    p_object_version_number => p_rec.object_version_number);
361   --
362   -- Call the datetrack update integrity operation
363   --
364   dt_update_validate
365     (
366      p_datetrack_mode                => p_datetrack_mode,
367      p_validation_start_date	     => p_validation_start_date,
368      p_validation_end_date	     => p_validation_end_date);
369   --
370   hr_utility.set_location(' Leaving:'||l_proc, 10);
371 End update_validate;
372 --
373 -- ----------------------------------------------------------------------------
374 -- |---------------------------< delete_validate >----------------------------|
375 -- ----------------------------------------------------------------------------
376 Procedure delete_validate
377 	(p_rec 			 in ben_cpt_shd.g_rec_type,
378 	 p_effective_date	 in date,
379 	 p_datetrack_mode	 in varchar2,
380 	 p_validation_start_date in date,
381 	 p_validation_end_date	 in date) is
382 --
383   l_proc	varchar2(72) := g_package||'delete_validate';
384 --
385 Begin
386   hr_utility.set_location('Entering:'||l_proc, 5);
387   --
388   -- Call all supporting business operations
389   --
390   dt_delete_validate
391     (p_datetrack_mode		=> p_datetrack_mode,
392      p_validation_start_date	=> p_validation_start_date,
393      p_validation_end_date	=> p_validation_end_date,
394      p_cmbn_ptip_opt_id		=> p_rec.cmbn_ptip_opt_id);
395   --
396   hr_utility.set_location(' Leaving:'||l_proc, 10);
397 End delete_validate;
398 --
399 --
400 --  ---------------------------------------------------------------------------
401 --  |---------------------< return_legislation_code >-------------------------|
402 --  ---------------------------------------------------------------------------
403 --
404 function return_legislation_code
405   (p_cmbn_ptip_opt_id in number) return varchar2 is
406   --
407   -- Declare cursor
408   --
409   cursor csr_leg_code is
410     select a.legislation_code
411     from   per_business_groups a,
412            ben_cmbn_ptip_opt_f b
413     where b.cmbn_ptip_opt_id      = p_cmbn_ptip_opt_id
414     and   a.business_group_id = b.business_group_id;
415   --
416   -- Declare local variables
417   --
418   l_legislation_code  varchar2(150);
419   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
420   --
421 begin
422   --
423   hr_utility.set_location('Entering:'|| l_proc, 10);
424   --
425   -- Ensure that all the mandatory parameter are not null
426   --
427   hr_api.mandatory_arg_error(p_api_name       => l_proc,
428                              p_argument       => 'cmbn_ptip_opt_id',
429                              p_argument_value => p_cmbn_ptip_opt_id);
430   --
431   open csr_leg_code;
432     --
433     fetch csr_leg_code into l_legislation_code;
434     --
435     if csr_leg_code%notfound then
436       --
437       close csr_leg_code;
438       --
439       -- The primary key is invalid therefore we must error
440       --
441       hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
442       hr_utility.raise_error;
443       --
444     end if;
445     --
446   close csr_leg_code;
447   --
448   hr_utility.set_location(' Leaving:'|| l_proc, 20);
449   --
450   return l_legislation_code;
451   --
452 end return_legislation_code;
453 --
454 end ben_cpt_bus;