DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_APL_BUS

Source


1 Package Body ben_apl_bus as
2 /* $Header: beaplrhi.pkb 120.0.12010000.3 2008/08/25 14:06:41 ppentapa ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_apl_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_acty_rt_ptd_lmt_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 --   acty_rt_ptd_lmt_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_acty_rt_ptd_lmt_id(p_acty_rt_ptd_lmt_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_acty_rt_ptd_lmt_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_apl_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_acty_rt_ptd_lmt_id                => p_acty_rt_ptd_lmt_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_acty_rt_ptd_lmt_id,hr_api.g_number)
55      <>  ben_apl_shd.g_old_rec.acty_rt_ptd_lmt_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_apl_shd.constraint_error('BEN_ACTY_RT_PTD_LMT_F_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_acty_rt_ptd_lmt_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_apl_shd.constraint_error('BEN_ACTY_RT_PTD_LMT_F_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_acty_rt_ptd_lmt_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_acty_base_rt_id               in number default hr_api.g_number,
110               p_ptd_lmt_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_acty_base_rt_id, hr_api.g_number) <> hr_api.g_number) and
147       NOT (dt_api.check_min_max_dates
148             (p_base_table_name => 'ben_acty_base_rt_f',
149              p_base_key_column => 'acty_base_rt_id',
150              p_base_key_value  => p_acty_base_rt_id,
151              p_from_date       => p_validation_start_date,
152              p_to_date         => p_validation_end_date)))  Then
153       l_table_name := 'ben_acty_base_rt_f';
154       Raise l_integrity_error;
155     End If;
156     --
157      If ((nvl(p_ptd_lmt_id, hr_api.g_number) <> hr_api.g_number) and
158        NOT (dt_api.check_min_max_dates
159              (p_base_table_name => 'ben_ptd_lmt_f',
160               p_base_key_column => 'ptd_lmt_id',
161               p_base_key_value  => p_ptd_lmt_id,
162               p_from_date       => p_validation_start_date,
163               p_to_date         => p_validation_end_date)))  Then
164        l_table_name := 'ben_ptd_lmt_f';
165        Raise l_integrity_error;
166      End If;
167     --
168   End If;
169   --
170   hr_utility.set_location(' Leaving:'||l_proc, 10);
171 Exception
172   When l_integrity_error Then
173     --
174     -- A referential integrity check was violated therefore
175     -- we must error
176     --
177     ben_utility.parent_integrity_error(p_table_name => l_table_name);
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_acty_rt_ptd_lmt_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       => 'acty_rt_ptd_lmt_id',
266        p_argument_value => p_acty_rt_ptd_lmt_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     ben_utility.child_exists_error(p_table_name => l_table_name);
283   When Others Then
284     --
285     -- An unhandled or unexpected error has occurred which
286     -- we must report
287     --
288     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
289     fnd_message.set_token('PROCEDURE', l_proc);
290     fnd_message.set_token('STEP','15');
291     fnd_message.raise_error;
292 End dt_delete_validate;
293 --
294 -- ----------------------------------------------------------------------------
295 -- |---------------------------< insert_validate >----------------------------|
296 -- ----------------------------------------------------------------------------
297 Procedure insert_validate
298 	(p_rec 			 in ben_apl_shd.g_rec_type,
299 	 p_effective_date	 in date,
300 	 p_datetrack_mode	 in varchar2,
301 	 p_validation_start_date in date,
302 	 p_validation_end_date	 in date) is
303 --
304   l_proc	varchar2(72) := g_package||'insert_validate';
305 --
306 Begin
307   hr_utility.set_location('Entering:'||l_proc, 5);
308   --
309   -- Call all supporting business operations
310   --
311   --
312   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
313   --
314   chk_acty_rt_ptd_lmt_id
315   (p_acty_rt_ptd_lmt_id          => p_rec.acty_rt_ptd_lmt_id,
316    p_effective_date        => p_effective_date,
317    p_object_version_number => p_rec.object_version_number);
318   --
319   hr_utility.set_location(' Leaving:'||l_proc, 10);
320 End insert_validate;
321 --
322 -- ----------------------------------------------------------------------------
323 -- |---------------------------< update_validate >----------------------------|
324 -- ----------------------------------------------------------------------------
325 Procedure update_validate
326 	(p_rec 			 in ben_apl_shd.g_rec_type,
327 	 p_effective_date	 in date,
328 	 p_datetrack_mode	 in varchar2,
329 	 p_validation_start_date in date,
330 	 p_validation_end_date	 in date) is
331 --
332   l_proc	varchar2(72) := g_package||'update_validate';
333 --
334 Begin
335   hr_utility.set_location('Entering:'||l_proc, 5);
336   --
337   -- Call all supporting business operations
338   --
339   --
340   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
341   --
342   chk_acty_rt_ptd_lmt_id
343   (p_acty_rt_ptd_lmt_id          => p_rec.acty_rt_ptd_lmt_id,
344    p_effective_date        => p_effective_date,
345    p_object_version_number => p_rec.object_version_number);
346   --
347   -- Call the datetrack update integrity operation
348   --
349   dt_update_validate
350     (p_acty_base_rt_id               => p_rec.acty_base_rt_id,
351      p_ptd_lmt_id                    => p_rec.ptd_lmt_id,
352      p_datetrack_mode                => p_datetrack_mode,
353      p_validation_start_date	     => p_validation_start_date,
354      p_validation_end_date	     => p_validation_end_date);
355   --
356   hr_utility.set_location(' Leaving:'||l_proc, 10);
357 End update_validate;
358 --
359 -- ----------------------------------------------------------------------------
360 -- |---------------------------< delete_validate >----------------------------|
361 -- ----------------------------------------------------------------------------
362 Procedure delete_validate
363 	(p_rec 			 in ben_apl_shd.g_rec_type,
364 	 p_effective_date	 in date,
365 	 p_datetrack_mode	 in varchar2,
366 	 p_validation_start_date in date,
367 	 p_validation_end_date	 in date) is
368 --
369   l_proc	varchar2(72) := g_package||'delete_validate';
370 --
371 Begin
372   hr_utility.set_location('Entering:'||l_proc, 5);
373   --
374   -- Call all supporting business operations
375   --
376   dt_delete_validate
377     (p_datetrack_mode		=> p_datetrack_mode,
378      p_validation_start_date	=> p_validation_start_date,
379      p_validation_end_date	=> p_validation_end_date,
380      p_acty_rt_ptd_lmt_id		=> p_rec.acty_rt_ptd_lmt_id);
381   --
382   hr_utility.set_location(' Leaving:'||l_proc, 10);
383 End delete_validate;
384 --
385 --
386 --  ---------------------------------------------------------------------------
387 --  |---------------------< return_legislation_code >-------------------------|
388 --  ---------------------------------------------------------------------------
389 --
390 function return_legislation_code
391   (p_acty_rt_ptd_lmt_id in number) return varchar2 is
392   --
393   -- Declare cursor
394   --
395   cursor csr_leg_code is
396     select a.legislation_code
397     from   per_business_groups a,
398            ben_acty_rt_ptd_lmt_f b
399     where b.acty_rt_ptd_lmt_id      = p_acty_rt_ptd_lmt_id
400     and   a.business_group_id = b.business_group_id;
401   --
402   -- Declare local variables
403   --
404   l_legislation_code  varchar2(150);
405   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
406   --
407 begin
408   --
409   hr_utility.set_location('Entering:'|| l_proc, 10);
410   --
411   -- Ensure that all the mandatory parameter are not null
412   --
413   hr_api.mandatory_arg_error(p_api_name       => l_proc,
414                              p_argument       => 'acty_rt_ptd_lmt_id',
415                              p_argument_value => p_acty_rt_ptd_lmt_id);
416   --
417   open csr_leg_code;
418     --
419     fetch csr_leg_code into l_legislation_code;
420     --
421     if csr_leg_code%notfound then
422       --
423       close csr_leg_code;
424       --
425       -- The primary key is invalid therefore we must error
426       --
427       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
428       fnd_message.raise_error;
429       --
430     end if;
431     --
432   close csr_leg_code;
433   --
434   hr_utility.set_location(' Leaving:'|| l_proc, 20);
435   --
436   return l_legislation_code;
437   --
438 end return_legislation_code;
439 --
440 end ben_apl_bus;