DBA Data[Home] [Help]

PACKAGE BODY: APPS.FF_FGL_BUS

Source


1 Package Body ff_fgl_bus as
2 /* $Header: fffglrhi.pkb 120.0.12000000.1 2007/03/20 11:52:47 ckesanap noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ff_fgl_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_global_id                   number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_global_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          , ff_globals_f pay
32      where pay.global_id = p_global_id
33        and pbg.business_group_id (+) = pay.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           => 'global_id'
50     ,p_argument_value     => p_global_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');
64      hr_multi_message.add
65        (p_associated_column1
66          => nvl(p_associated_column1,'GLOBAL_ID')
67        );
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_global_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          , ff_globals_f pay
102      where pay.global_id = p_global_id
103        and pbg.business_group_id (+) = pay.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           => 'global_id'
119     ,p_argument_value     => p_global_id
120     );
121   --
122   if ( nvl(ff_fgl_bus.g_global_id, hr_api.g_number)
123        = p_global_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 := ff_fgl_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     ff_fgl_bus.g_global_id                   := p_global_id;
154     ff_fgl_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 ff_fgl_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 ff_fgl_shd.api_updating
200       (p_global_id                        => p_rec.global_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 >--------------------------|
217 -- ----------------------------------------------------------------------------
218 -- {Start Of Comments}
219 --
220 -- Description:
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_datetrack_mode                in varchar2
246   ,p_validation_start_date         in date
247   ,p_validation_end_date           in date
248   ) Is
249 --
250   l_proc  varchar2(72) := g_package||'dt_update_validate';
251 --
252 Begin
253   --
254   -- Ensure that the p_datetrack_mode argument is not null
255   --
256   hr_api.mandatory_arg_error
257     (p_api_name       => l_proc
258     ,p_argument       => 'datetrack_mode'
259     ,p_argument_value => p_datetrack_mode
260     );
261   --
262   -- Mode will be valid, as this is checked at the start of the upd.
263   --
264   -- Ensure the arguments are not null
265   --
266   hr_api.mandatory_arg_error
267     (p_api_name       => l_proc
268     ,p_argument       => 'validation_start_date'
269     ,p_argument_value => p_validation_start_date
270     );
271   --
272   hr_api.mandatory_arg_error
273     (p_api_name       => l_proc
274     ,p_argument       => 'validation_end_date'
275     ,p_argument_value => p_validation_end_date
276     );
277   --
278     --
279   --
280 Exception
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_update_validate;
291 --
292 -- ----------------------------------------------------------------------------
293 -- |--------------------------< dt_delete_validate >--------------------------|
294 -- ----------------------------------------------------------------------------
295 -- {Start Of Comments}
296 --
297 -- Description:
298 --   This procedure is used for referential integrity of datetracked
299 --   child entities when either a datetrack DELETE or ZAP is in operation
300 --   and where there is no cascading of delete defined for this entity.
301 --   For the datetrack mode of DELETE or ZAP we must ensure that no
302 --   datetracked child rows exist between the validation start and end
303 --   dates.
304 --
305 -- Prerequisites:
306 --   This procedure is called from the delete_validate.
307 --
308 -- In Parameters:
309 --
310 -- Post Success:
311 --   Processing continues.
312 --
313 -- Post Failure:
314 --   If a row exists by determining the returning Boolean value from the
315 --   generic dt_api.rows_exist function then we must supply an error via
316 --   the use of the local exception handler l_rows_exist.
317 --
318 -- Developer Implementation Notes:
319 --   This procedure should not need maintenance unless the HR Schema model
320 --   changes.
321 --
322 -- Access Status:
323 --   Internal Row Handler Use Only.
324 --
325 -- {End Of Comments}
326 -- ----------------------------------------------------------------------------
327 Procedure dt_delete_validate
328   (p_global_id                        in number
329   ,p_datetrack_mode                   in varchar2
330   ,p_validation_start_date            in date
331   ,p_validation_end_date              in date
332   ) Is
333 --
334   l_proc        varchar2(72)    := g_package||'dt_delete_validate';
335 --
336 Begin
337   --
338   -- Ensure that the p_datetrack_mode argument is not null
339   --
340   hr_api.mandatory_arg_error
341     (p_api_name       => l_proc
342     ,p_argument       => 'datetrack_mode'
343     ,p_argument_value => p_datetrack_mode
344     );
345   --
346   -- Only perform the validation if the datetrack mode is either
347   -- DELETE or ZAP
348   --
349   If (p_datetrack_mode = hr_api.g_delete or
350       p_datetrack_mode = hr_api.g_zap) then
351     --
352     --
353     -- Ensure the arguments are not null
354     --
355     hr_api.mandatory_arg_error
356       (p_api_name       => l_proc
357       ,p_argument       => 'validation_start_date'
358       ,p_argument_value => p_validation_start_date
359       );
360     --
361     hr_api.mandatory_arg_error
362       (p_api_name       => l_proc
363       ,p_argument       => 'validation_end_date'
364       ,p_argument_value => p_validation_end_date
365       );
366     --
367     hr_api.mandatory_arg_error
368       (p_api_name       => l_proc
369       ,p_argument       => 'global_id'
370       ,p_argument_value => p_global_id
371       );
372     --
373   --
374     --
375   End If;
376   --
377 Exception
378   When Others Then
379     --
380     -- An unhandled or unexpected error has occurred which
381     -- we must report
382     --
383     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
384     fnd_message.set_token('PROCEDURE', l_proc);
385     fnd_message.set_token('STEP','15');
386     fnd_message.raise_error;
387   --
388 End dt_delete_validate;
389 --
390 -- ----------------------------------------------------------------------------
391 -- |----------------------< chk_startup_action >------------------------------|
392 -- ----------------------------------------------------------------------------
393 --
394 -- Description:
395 --  This procedure will check that the current action is allowed according
396 --  to the current startup mode.
397 --
398 -- ----------------------------------------------------------------------------
399 PROCEDURE chk_startup_action
400   (p_insert               IN boolean
401   ,p_business_group_id    IN number
402   ,p_legislation_code     IN varchar2
403   ,p_legislation_subgroup IN varchar2 DEFAULT NULL) IS
404 --
405 BEGIN
406   --
407   -- Call the supporting procedure to check startup mode
408   -- EDIT_HERE: The following call should be edited if certain types of rows
409   -- are not permitted.
410   IF (p_insert) THEN
411     hr_startup_data_api_support.chk_startup_action
412       (p_generic_allowed   => TRUE
413       ,p_startup_allowed   => TRUE
414       ,p_user_allowed      => TRUE
415       ,p_business_group_id => p_business_group_id
416       ,p_legislation_code  => p_legislation_code
417       ,p_legislation_subgroup => p_legislation_subgroup
418       );
419   ELSE
420     hr_startup_data_api_support.chk_upd_del_startup_action
421       (p_generic_allowed   => TRUE
422       ,p_startup_allowed   => TRUE
423       ,p_user_allowed      => TRUE
424       ,p_business_group_id => p_business_group_id
425       ,p_legislation_code  => p_legislation_code
426       ,p_legislation_subgroup => p_legislation_subgroup
427       );
428   END IF;
429   --
430 END chk_startup_action;
431 --
432 -- ----------------------------------------------------------------------------
433 -- |---------------------------< insert_validate >----------------------------|
434 -- ----------------------------------------------------------------------------
435 Procedure insert_validate
436   (p_rec                   in ff_fgl_shd.g_rec_type
437   ,p_effective_date        in date
438   ,p_datetrack_mode        in varchar2
439   ,p_validation_start_date in date
440   ,p_validation_end_date   in date
441   ) is
442 --
443   l_proc        varchar2(72) := g_package||'insert_validate';
444 --
445 Begin
446   hr_utility.set_location('Entering:'||l_proc, 5);
447   --
448   -- Call all supporting business operations
449   --
450   --
451   chk_startup_action(true
452                     ,p_rec.business_group_id
453                     ,p_rec.legislation_code
454                     );
455   IF hr_startup_data_api_support.g_startup_mode
456                      NOT IN ('GENERIC','STARTUP') THEN
457      --
458      -- Validate Important Attributes
459      --
460      hr_api.validate_bus_grp_id
461        (p_business_group_id => p_rec.business_group_id
462        ,p_associated_column1 => ff_fgl_shd.g_tab_nam
463                                 || '.BUSINESS_GROUP_ID');
464      --
465      -- after validating the set of important attributes,
466      -- if Multiple Message Detection is enabled and at least
467      -- one error has been found then abort further validation.
468      --
469      hr_multi_message.end_validation_set;
470   END IF;
471   --
472   --
473   -- Validate Dependent Attributes
474   --
475   --
476   hr_utility.set_location(' Leaving:'||l_proc, 10);
477 End insert_validate;
478 --
479 -- ----------------------------------------------------------------------------
480 -- |---------------------------< update_validate >----------------------------|
481 -- ----------------------------------------------------------------------------
482 Procedure update_validate
483   (p_rec                     in ff_fgl_shd.g_rec_type
484   ,p_effective_date          in date
485   ,p_datetrack_mode          in varchar2
486   ,p_validation_start_date   in date
487   ,p_validation_end_date     in date
488   ) is
489 --
490   l_proc        varchar2(72) := g_package||'update_validate';
491 --
492 Begin
493   hr_utility.set_location('Entering:'||l_proc, 5);
494   --
495   -- Call all supporting business operations
496   --
497   --
498   chk_startup_action(false
499                     ,p_rec.business_group_id
500                     ,p_rec.legislation_code
501                     );
502   IF hr_startup_data_api_support.g_startup_mode
503                      NOT IN ('GENERIC','STARTUP') THEN
504      --
505      -- Validate Important Attributes
506      --
507      hr_api.validate_bus_grp_id
508        (p_business_group_id => p_rec.business_group_id
509        ,p_associated_column1 => ff_fgl_shd.g_tab_nam
510                                 || '.BUSINESS_GROUP_ID');
511      --
512      -- After validating the set of important attributes,
513      -- if Multiple Message Detection is enabled and at least
514      -- one error has been found then abort further validation.
515      --
516      hr_multi_message.end_validation_set;
517   END IF;
518   --
519   --
520   -- Validate Dependent Attributes
521   --
522   -- Call the datetrack update integrity operation
523   --
524   dt_update_validate
525     (p_datetrack_mode                 => p_datetrack_mode
526     ,p_validation_start_date          => p_validation_start_date
527     ,p_validation_end_date            => p_validation_end_date
528     );
529   --
530   chk_non_updateable_args
531     (p_effective_date  => p_effective_date
532     ,p_rec             => p_rec
533     );
534   --
535   --
536   hr_utility.set_location(' Leaving:'||l_proc, 10);
537 End update_validate;
538 --
539 -- ----------------------------------------------------------------------------
540 -- |---------------------------< delete_validate >----------------------------|
541 -- ----------------------------------------------------------------------------
542 Procedure delete_validate
543   (p_rec                    in ff_fgl_shd.g_rec_type
544   ,p_effective_date         in date
545   ,p_datetrack_mode         in varchar2
546   ,p_validation_start_date  in date
547   ,p_validation_end_date    in date
548   ) is
549 --
550   l_proc        varchar2(72) := g_package||'delete_validate';
551 --
552 Begin
553   hr_utility.set_location('Entering:'||l_proc, 5);
554   --
555     --
556   chk_startup_action(false
557                     ,ff_fgl_shd.g_old_rec.business_group_id
558                     ,ff_fgl_shd.g_old_rec.legislation_code
559                     );
560   IF hr_startup_data_api_support.g_startup_mode
561                      NOT IN ('GENERIC','STARTUP') THEN
562      --
563      -- Validate Important Attributes
564      --
565      --
566      -- After validating the set of important attributes,
567      -- if Multiple Message Detection is enabled and at least
568      -- one error has been found then abort further validation.
569      --
570      hr_multi_message.end_validation_set;
571   END IF;
572   --
573   -- Call all supporting business operations
574   --
575   dt_delete_validate
576     (p_datetrack_mode                   => p_datetrack_mode
577     ,p_validation_start_date            => p_validation_start_date
578     ,p_validation_end_date              => p_validation_end_date
579     ,p_global_id                        => p_rec.global_id
580     );
581   --
582   hr_utility.set_location(' Leaving:'||l_proc, 10);
583 End delete_validate;
584 --
585 end ff_fgl_bus;