DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BER_BUS

Source


1 Package Body ben_ber_bus as
2 /* $Header: beberrhi.pkb 120.1.12010000.2 2008/08/05 14:08:07 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ben_ber_bus.';  -- Global package name
9 --
10 -- The following two global variables are only to be
11 -- used by the return_legislation_code function.
12 --
13 g_legislation_code            varchar2(150)  default null;
14 g_elig_rslt_id                number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_elig_rslt_id                         in number
22   ,p_associated_column1                   in varchar2 default null
23   ) is
24   --
25   -- Declare cursor
26   --
27   cursor csr_sec_grp is
28     select pbg.security_group_id,
29            pbg.legislation_code
30       from per_business_groups_perf pbg
31          , ben_elig_rslt_f ber
32      where ber.elig_rslt_id = p_elig_rslt_id
33        and pbg.business_group_id = ber.business_group_id;
34   --
35   -- Declare local variables
36   --
37   l_security_group_id number;
38   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
39   l_legislation_code  varchar2(150);
40   --
41 begin
42   --
43   hr_utility.set_location('Entering:'|| l_proc, 10);
44   --
45   -- Ensure that all the mandatory parameter are not null
46   --
47   hr_api.mandatory_arg_error
48     (p_api_name           => l_proc
49     ,p_argument           => 'elig_rslt_id'
50     ,p_argument_value     => p_elig_rslt_id
51     );
52   --
53   open csr_sec_grp;
54   fetch csr_sec_grp into l_security_group_id
55                        , l_legislation_code;
56   --
57   if csr_sec_grp%notfound then
58      --
59      close csr_sec_grp;
60      --
61      -- The primary key is invalid therefore we must error
62      --
63      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
67        );
64      hr_multi_message.add
65        (p_associated_column1
66          => nvl(p_associated_column1,'ELIG_RSLT_ID')
68      --
69   else
70     close csr_sec_grp;
71     --
72     -- Set the security_group_id in CLIENT_INFO
73     --
74     hr_api.set_security_group_id
75       (p_security_group_id => l_security_group_id
76       );
77     --
78     -- Set the sessions legislation context in HR_SESSION_DATA
79     --
80     hr_api.set_legislation_context(l_legislation_code);
81   end if;
82   --
83   hr_utility.set_location(' Leaving:'|| l_proc, 20);
84   --
85 end set_security_group_id;
86 --
87 --  ---------------------------------------------------------------------------
88 --  |---------------------< return_legislation_code >-------------------------|
89 --  ---------------------------------------------------------------------------
90 --
91 Function return_legislation_code
92   (p_elig_rslt_id                         in     number
93   )
94   Return Varchar2 Is
95   --
96   -- Declare cursor
97   --
98  cursor csr_leg_code is
99     select pbg.legislation_code
100       from per_business_groups_perf pbg
101          , ben_elig_rslt_f ber
102      where ber.elig_rslt_id = p_elig_rslt_id
103        and pbg.business_group_id = ber.business_group_id;
104   --
105   -- Declare local variables
106   --
107   l_legislation_code  varchar2(150);
108   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
109   --
110 Begin
111   --
112   hr_utility.set_location('Entering:'|| l_proc, 10);
113   --
114   -- Ensure that all the mandatory parameter are not null
115   --
116   hr_api.mandatory_arg_error
117     (p_api_name           => l_proc
118     ,p_argument           => 'elig_rslt_id'
119     ,p_argument_value     => p_elig_rslt_id
120     );
121   --
122   if ( nvl(ben_ber_bus.g_elig_rslt_id, hr_api.g_number)
123        = p_elig_rslt_id) then
124     --
125     -- The legislation code has already been found with a previous
126     -- call to this function. Just return the value in the global
127     -- variable.
128     --
129     l_legislation_code := ben_ber_bus.g_legislation_code;
130     hr_utility.set_location(l_proc, 20);
131   else
132     --
133     -- The ID is different to the last call to this function
134     -- or this is the first call to this function.
135     --
136     open csr_leg_code;
137     fetch csr_leg_code into l_legislation_code;
138     --
139     if csr_leg_code%notfound then
140       --
141       -- The primary key is invalid therefore we must error
142       --
143       close csr_leg_code;
144       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
145       fnd_message.raise_error;
146     end if;
147     hr_utility.set_location(l_proc,30);
148     --
149     -- Set the global variables so the values are
150     -- available for the next call to this function.
151     --
152     close csr_leg_code;
153     ben_ber_bus.g_elig_rslt_id                := p_elig_rslt_id;
154     ben_ber_bus.g_legislation_code  := l_legislation_code;
155   end if;
156   hr_utility.set_location(' Leaving:'|| l_proc, 40);
157   return l_legislation_code;
158 end return_legislation_code;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |-----------------------< chk_non_updateable_args >------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 --   This procedure is used to ensure that non updateable attributes have
167 --   not been updated. If an attribute has been updated an error is generated.
168 --
169 -- Pre Conditions:
170 --   g_old_rec has been populated with details of the values currently in
171 --   the database.
172 --
173 -- In Arguments:
174 --   p_rec has been populated with the updated values the user would like the
175 --   record set to.
176 --
177 -- Post Success:
178 --   Processing continues if all the non updateable attributes have not
179 --   changed.
180 --
181 -- Post Failure:
182 --   An application error is raised if any of the non updatable attributes
183 --   have been altered.
184 --
185 -- {End Of Comments}
186 -- ----------------------------------------------------------------------------
187 Procedure chk_non_updateable_args
188   (p_effective_date  in date
189   ,p_rec             in ben_ber_shd.g_rec_type
190   ) IS
191 --
192   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
193 --
194 Begin
195   --
196   -- Only proceed with the validation if a row exists for the current
197   -- record in the HR Schema.
198   --
199   IF NOT ben_ber_shd.api_updating
200       (p_elig_rslt_id                     => p_rec.elig_rslt_id
201       ,p_effective_date                   => p_effective_date
202       ,p_object_version_number            => p_rec.object_version_number
203       ) THEN
204      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
205      fnd_message.set_token('PROCEDURE ', l_proc);
206      fnd_message.set_token('STEP ', '5');
207      fnd_message.raise_error;
208   END IF;
209   --
210   -- EDIT_HERE: Add checks to ensure non-updateable args have
211   --            not been updated.
212   --
213 End chk_non_updateable_args;
214 --
215 -- ----------------------------------------------------------------------------
216 -- |--------------------------< dt_update_validate >--------------------------|
220 -- Description:
217 -- ----------------------------------------------------------------------------
218 -- {Start Of Comments}
219 --
221 --   This procedure is used for referential integrity of datetracked
222 --   parent entities when a datetrack update operation is taking place
223 --   and where there is no cascading of update defined for this entity.
224 --
225 -- Prerequisites:
226 --   This procedure is called from the update_validate.
227 --
228 -- In Parameters:
229 --
230 -- Post Success:
231 --   Processing continues.
232 --
233 -- Post Failure:
234 --
235 -- Developer Implementation Notes:
236 --   This procedure should not need maintenance unless the HR Schema model
237 --   changes.
238 --
239 -- Access Status:
240 --   Internal Row Handler Use Only.
241 --
242 -- {End Of Comments}
243 -- ----------------------------------------------------------------------------
244 Procedure dt_update_validate
245   (p_elig_obj_id                   in number default hr_api.g_number
246   ,p_datetrack_mode                in varchar2
247   ,p_validation_start_date         in date
248   ,p_validation_end_date           in date
249   ) Is
250 --
251   l_proc  varchar2(72) := g_package||'dt_update_validate';
252 --
253 Begin
254   --
255   -- Ensure that the p_datetrack_mode argument is not null
256   --
257   hr_api.mandatory_arg_error
258     (p_api_name       => l_proc
259     ,p_argument       => 'datetrack_mode'
260     ,p_argument_value => p_datetrack_mode
261     );
262   --
263   -- Mode will be valid, as this is checked at the start of the upd.
264   --
265   -- Ensure the arguments are not null
266   --
267   hr_api.mandatory_arg_error
268     (p_api_name       => l_proc
269     ,p_argument       => 'validation_start_date'
270     ,p_argument_value => p_validation_start_date
271     );
272   --
273   hr_api.mandatory_arg_error
274     (p_api_name       => l_proc
275     ,p_argument       => 'validation_end_date'
276     ,p_argument_value => p_validation_end_date
277     );
278   --
279   If ((nvl(p_elig_obj_id, hr_api.g_number) <> hr_api.g_number) and
280       NOT (dt_api.check_min_max_dates
281             (p_base_table_name => 'ben_elig_obj_f'
282             ,p_base_key_column => 'ELIG_OBJ_ID'
283             ,p_base_key_value  => p_elig_obj_id
284             ,p_from_date       => p_validation_start_date
285             ,p_to_date         => p_validation_end_date))) Then
286      fnd_message.set_name('PAY', 'HR_7216_DT_UPD_INTEGRITY_ERR');
287      fnd_message.set_token('TABLE_NAME','eligy prfl');
288      hr_multi_message.add
289        (p_associated_column1 => ben_ber_shd.g_tab_nam || '.ELIG_OBJ_ID');
290   End If;
291   --
292 Exception
293   When Others Then
294     --
295     -- An unhandled or unexpected error has occurred which
296     -- we must report
297     --
298     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
299     fnd_message.set_token('PROCEDURE', l_proc);
300     fnd_message.set_token('STEP','15');
301     fnd_message.raise_error;
302 End dt_update_validate;
303 --
304 -- ----------------------------------------------------------------------------
305 -- |--------------------------< dt_delete_validate >--------------------------|
306 -- ----------------------------------------------------------------------------
307 -- {Start Of Comments}
308 --
309 -- Description:
310 --   This procedure is used for referential integrity of datetracked
311 --   child entities when either a datetrack DELETE or ZAP is in operation
312 --   and where there is no cascading of delete defined for this entity.
313 --   For the datetrack mode of DELETE or ZAP we must ensure that no
314 --   datetracked child rows exist between the validation start and end
315 --   dates.
316 --
317 -- Prerequisites:
318 --   This procedure is called from the delete_validate.
319 --
320 -- In Parameters:
321 --
322 -- Post Success:
323 --   Processing continues.
324 --
325 -- Post Failure:
326 --   If a row exists by determining the returning Boolean value from the
327 --   generic dt_api.rows_exist function then we must supply an error via
328 --   the use of the local exception handler l_rows_exist.
329 --
330 -- Developer Implementation Notes:
331 --   This procedure should not need maintenance unless the HR Schema model
332 --   changes.
333 --
334 -- Access Status:
335 --   Internal Row Handler Use Only.
336 --
337 -- {End Of Comments}
338 -- ----------------------------------------------------------------------------
339 Procedure dt_delete_validate
340   (p_elig_rslt_id                     in number
341   ,p_datetrack_mode                   in varchar2
342   ,p_validation_start_date            in date
343   ,p_validation_end_date              in date
344   ) Is
345 --
346   l_proc        varchar2(72)    := g_package||'dt_delete_validate';
347 --
348 Begin
349   --
350   -- Ensure that the p_datetrack_mode argument is not null
351   --
352   hr_api.mandatory_arg_error
353     (p_api_name       => l_proc
354     ,p_argument       => 'datetrack_mode'
355     ,p_argument_value => p_datetrack_mode
356     );
357   --
358   -- Only perform the validation if the datetrack mode is either
359   -- DELETE or ZAP
360   --
361   If (p_datetrack_mode = hr_api.g_delete or
362       p_datetrack_mode = hr_api.g_zap) then
363     --
364     --
365     -- Ensure the arguments are not null
366     --
370       ,p_argument_value => p_validation_start_date
367     hr_api.mandatory_arg_error
368       (p_api_name       => l_proc
369       ,p_argument       => 'validation_start_date'
371       );
372     --
373     hr_api.mandatory_arg_error
374       (p_api_name       => l_proc
375       ,p_argument       => 'validation_end_date'
376       ,p_argument_value => p_validation_end_date
377       );
378     --
379     hr_api.mandatory_arg_error
380       (p_api_name       => l_proc
381       ,p_argument       => 'elig_rslt_id'
382       ,p_argument_value => p_elig_rslt_id
383       );
384     --
385   --
386     --
387   End If;
388   --
389 Exception
390   When Others Then
391     --
392     -- An unhandled or unexpected error has occurred which
393     -- we must report
394     --
395     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
396     fnd_message.set_token('PROCEDURE', l_proc);
397     fnd_message.set_token('STEP','15');
398     fnd_message.raise_error;
399   --
400 End dt_delete_validate;
401 --
402 -- ----------------------------------------------------------------------------
403 -- |---------------------------< insert_validate >----------------------------|
404 -- ----------------------------------------------------------------------------
405 Procedure insert_validate
406   (p_rec                   in ben_ber_shd.g_rec_type
407   ,p_effective_date        in date
408   ,p_datetrack_mode        in varchar2
409   ,p_validation_start_date in date
410   ,p_validation_end_date   in date
411   ) is
412 --
413   l_proc        varchar2(72) := g_package||'insert_validate';
414 --
415 Begin
416   hr_utility.set_location('Entering:'||l_proc, 5);
417   --
418   -- Call all supporting business operations
419   --
420   hr_api.validate_bus_grp_id
421     (p_business_group_id => p_rec.business_group_id
422     ,p_associated_column1 => ben_ber_shd.g_tab_nam
423                               || '.BUSINESS_GROUP_ID');
424   --
425   -- After validating the set of important attributes,
426   -- if Multiple Message detection is enabled and at least
427   -- one error has been found then abort further validation.
428   --
429   hr_multi_message.end_validation_set;
430   --
431   hr_utility.set_location(' Leaving:'||l_proc, 10);
432 End insert_validate;
433 --
434 -- ----------------------------------------------------------------------------
435 -- |---------------------------< update_validate >----------------------------|
436 -- ----------------------------------------------------------------------------
437 Procedure update_validate
438   (p_rec                     in ben_ber_shd.g_rec_type
439   ,p_effective_date          in date
440   ,p_datetrack_mode          in varchar2
441   ,p_validation_start_date   in date
442   ,p_validation_end_date     in date
443   ) is
444 --
445   l_proc        varchar2(72) := g_package||'update_validate';
446 --
447 Begin
448   hr_utility.set_location('Entering:'||l_proc, 5);
449   --
450   -- Call all supporting business operations
451   --
452   hr_api.validate_bus_grp_id
453     (p_business_group_id => p_rec.business_group_id
454     ,p_associated_column1 => ben_ber_shd.g_tab_nam
455                               || '.BUSINESS_GROUP_ID');
456   --
457   -- After validating the set of important attributes,
458   -- if Multiple Message detection is enabled and at least
459   -- one error has been found then abort further validation.
460   --
461   hr_multi_message.end_validation_set;
462   --
463   -- Validate Dependent Attributes
464   --
465   -- Call the datetrack update integrity operation
466   --
467   dt_update_validate
468     (p_elig_obj_id                    => p_rec.elig_obj_id
469     ,p_datetrack_mode                 => p_datetrack_mode
470     ,p_validation_start_date          => p_validation_start_date
471     ,p_validation_end_date            => p_validation_end_date
472     );
473   --
474   chk_non_updateable_args
475     (p_effective_date  => p_effective_date
476     ,p_rec             => p_rec
477     );
478   --
479   hr_utility.set_location(' Leaving:'||l_proc, 10);
480 End update_validate;
481 --
482 -- ----------------------------------------------------------------------------
483 -- |---------------------------< delete_validate >----------------------------|
484 -- ----------------------------------------------------------------------------
485 Procedure delete_validate
486   (p_rec                    in ben_ber_shd.g_rec_type
487   ,p_effective_date         in date
488   ,p_datetrack_mode         in varchar2
489   ,p_validation_start_date  in date
490   ,p_validation_end_date    in date
491   ) is
492 --
493   l_proc        varchar2(72) := g_package||'delete_validate';
494 --
495 Begin
496   hr_utility.set_location('Entering:'||l_proc, 5);
497   --
498   -- Call all supporting business operations
499   --
500   dt_delete_validate
501     (p_datetrack_mode                   => p_datetrack_mode
502     ,p_validation_start_date            => p_validation_start_date
503     ,p_validation_end_date              => p_validation_end_date
504     ,p_elig_rslt_id                     => p_rec.elig_rslt_id
505     );
506   --
507   hr_utility.set_location(' Leaving:'||l_proc, 10);
508 End delete_validate;
509 --
510 end ben_ber_bus;