DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_OPP_BUS

Source


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