DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PCR_BUS

Source


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