DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PCU_BUS

Source


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