DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_RLU_BUS

Source


1 Package Body ame_rlu_bus as
2 /* $Header: amrlurhi.pkb 120.5 2005/11/22 03:19 santosin noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ame_rlu_bus.';  -- Global package name
9 --
10 --  ---------------------------------------------------------------------------
11 --  |----------------------<chk_approver_category  >--------------------------|
12 --  ---------------------------------------------------------------------------
13 --
14 --  {Start Of Comments}
15 --
16 -- Description:
17 --   Check that approver category is one of the valid values:
18 --          ame_util.approvalApproverCategory
19 --          ame_util.fyiApproverCategory
20 --
21 -- Prerequisites:
22 --   None.
23 --
24 -- In Parameters:
25 --   p_approver_category
26 --   p_effective_date
27 --
28 -- Post Success:
29 --   Processing continues.
30 --
31 -- Post Failure:
32 --   Log the error message.
33 --
34 -- Developer Implementation Notes:
35 --   None.
36 --
37 -- Access Status:
38 --   Internal Row Handler Use Only.
39 --
40 -- {End Of Comments}
41 -- ----------------------------------------------------------------------------
42 procedure chk_approver_category
43   (p_approver_category     in varchar2,
44    p_effective_date        in date) is
45   l_proc              varchar2(72)  :=  g_package||'chk_approver_category';
46 begin
47   if not (p_approver_category = ame_util.approvalApproverCategory or
48           p_approver_category = ame_util.fyiApproverCategory) then
49     fnd_message.set_name('PER','AME_400481_INV_APP_CAT');
50     fnd_message.raise_error;
51   end if;
52 exception
53    when app_exception.application_exception then
54      if hr_multi_message.exception_add
55        (p_associated_column1 => 'APPROVER_CATEGORY') then
56        hr_utility.set_location(' Leaving:'|| l_proc, 50);
57        raise;
58      end if;
59      hr_utility.set_location(' Leaving:'|| l_proc, 60);
60 end chk_approver_category;
61 --
62 --  ---------------------------------------------------------------------------
63 --  |------------------------<chk_item_id  >-----------------------------|
64 --  ---------------------------------------------------------------------------
65 --
66 --  {Start Of Comments}
67 --
68 -- Description:
69 --   Validates that the condition_id is a foreign key to ame_calling_apps.application_id.
70 --
71 -- Prerequisites:
72 --   None.
73 --
74 -- In Parameters:
75 --   p_item_id
76 --   p_effective_date
77 --
78 -- Post Success:
79 --   Processing continues.
80 --
81 -- Post Failure:
82 --   Log the error message.
83 --
84 -- Developer Implementation Notes:
85 --   None.
86 --
87 -- Access Status:
88 --   Internal Row Handler Use Only.
89 --
90 -- {End Of Comments}
91 -- ----------------------------------------------------------------------------
92 procedure chk_item_id
93   (p_item_id   in number,
94    p_effective_date        in date) is
95   l_proc              varchar2(72)  :=  g_package||'chk_item_id';
96   tempCount integer;
97   cursor c_sel1 is
98     select null
99       from ame_calling_apps
100       where
101         application_id = p_item_id and
102         p_effective_date between start_date and
103                  nvl(end_date - ame_util.oneSecond, p_effective_date) ;
104   l_exists varchar2(1);
105 begin
106   open c_sel1;
107   fetch  c_sel1 into l_exists;
108   if c_sel1%notfound then
109     close c_sel1;
110     fnd_message.set_name('PER','AME_400474_INV_APPLICATION_ID');
111     fnd_message.raise_error;
112   end if;
113   close c_sel1;
114 exception
115    when app_exception.application_exception then
116      if hr_multi_message.exception_add
117        (p_associated_column1 => 'ITEM_ID') then
118        hr_utility.set_location(' Leaving:'|| l_proc, 50);
119        raise;
120      end if;
121      hr_utility.set_location(' Leaving:'|| l_proc, 60);
122 end chk_item_id;
123 --
124 --  ---------------------------------------------------------------------------
125 --  |----------------------<chk_rule_usg_dates     >--------------------------|
126 --  ---------------------------------------------------------------------------
127 --
128 --  {Start Of Comments}
129 --
130 -- Description:
131 --   Validates that the start_date and end_date are valid for the usage.
132 --
133 -- Prerequisites:
134 --   None.
135 --
136 -- In Parameters:
137 --   p_start_date
138 --   p_end_date
139 --
140 -- Post Success:
141 --   Processing continues.
142 --
143 -- Post Failure:
144 --   Log the error message.
145 --
146 -- Developer Implementation Notes:
147 --   None.
148 --
149 -- Access Status:
150 --   Internal Row Handler Use Only.
151 --
152 -- {End Of Comments}
153 -- ----------------------------------------------------------------------------
154 procedure chk_rule_usg_dates(p_start_date     in date
155                             ,p_end_date       in date
156                             ,p_effective_date in date) is
157 begin
158   if p_start_date < p_effective_date then
159       fnd_message.set_name('PER','AME_400213_RUL_STRT_GRTR_CUR');
160       hr_multi_message.add (p_associated_column1 => 'START_DATE');
161   end if;
162   if p_end_date < p_effective_date then
163       fnd_message.set_name('PER','AME_400706_PAS_END_DATE');
164       hr_multi_message.add (p_associated_column1 => 'END_DATE');
165   end if;
166   if p_start_date > p_end_date then
167       fnd_message.set_name('PER','AME_400214_RUL_STRT_LESS_END');
168       hr_multi_message.add (p_associated_column1 => 'START_DATE');
169   end if;
170 end chk_rule_usg_dates;
171 --
172 --  ---------------------------------------------------------------------------
173 --  |----------------------<chk_rule_id     >--------------------------|
174 --  ---------------------------------------------------------------------------
175 --
176 --  {Start Of Comments}
177 --
178 -- Description:
179 --   Validates that the rule_id is a foreign key to ame_rules.rule_id.
180 --
181 -- Prerequisites:
182 --   None.
183 --
184 -- In Parameters:
185 --   p_rule_id
186 --   p_effective_date
187 --
188 -- Post Success:
189 --   Processing continues.
190 --
191 -- Post Failure:
192 --   Log the error message.
193 --
194 -- Developer Implementation Notes:
195 --   None.
196 --
197 -- Access Status:
198 --   Internal Row Handler Use Only.
199 --
200 -- {End Of Comments}
201 -- ----------------------------------------------------------------------------
202 procedure chk_rule_id
203   (p_rule_id   in number,
204    p_effective_date        in date) is
205   l_proc              varchar2(72)  :=  g_package||'chk_rule_id';
206   tempCount integer;
207   cursor c_sel1 is
208     select null
209       from ame_rules
210       where
211         rule_id = p_rule_id and
212          ((p_effective_date between start_date and
213             nvl(end_date - ame_util.oneSecond, p_effective_date)) or
214         (p_effective_date < start_date and
215             start_date < nvl(end_date,start_date + ame_util.oneSecond)));
216   l_exists varchar2(1);
217 begin
218   open c_sel1;
219   fetch  c_sel1 into l_exists;
220   if c_sel1%notfound then
221     close c_sel1;
222     fnd_message.set_name('PER','AME_400480_INV_RULE_ID');
223     fnd_message.raise_error;
224   end if;
225   close c_sel1;
226 exception
227    when app_exception.application_exception then
228      if hr_multi_message.exception_add
229        (p_associated_column1 => 'RULE_ID') then
230        hr_utility.set_location(' Leaving:'|| l_proc, 50);
231        raise;
232      end if;
233      hr_utility.set_location(' Leaving:'|| l_proc, 60);
234 end chk_rule_id;
235 --
236 --
237 -- ----------------------------------------------------------------------------
238 -- |-----------------------< chk_non_updateable_args >------------------------|
239 -- ----------------------------------------------------------------------------
240 -- {Start Of Comments}
241 --
242 -- Description:
243 --   This procedure is used to ensure that non updateable attributes have
244 --   not been updated. If an attribute has been updated an error is generated.
245 --
246 -- Pre Conditions:
247 --   g_old_rec has been populated with details of the values currently in
248 --   the database.
249 --
250 -- In Arguments:
251 --   p_rec has been populated with the updated values the user would like the
252 --   record set to.
253 --
254 -- Post Success:
255 --   Processing continues if all the non updateable attributes have not
256 --   changed.
257 --
258 -- Post Failure:
259 --   An application error is raised if any of the non updatable attributes
260 --   have been altered.
261 --
262 -- {End Of Comments}
263 -- ----------------------------------------------------------------------------
264 Procedure chk_non_updateable_args
265   (p_effective_date  in date
266   ,p_rec             in ame_rlu_shd.g_rec_type
267   ) IS
268 --
269   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
270 --
271 Begin
272   --
273   -- Only proceed with the validation if a row exists for the current
274   -- record in the HR Schema.
275   --
276   IF NOT ame_rlu_shd.api_updating
277       (p_rule_id =>  p_rec.rule_id
278  ,p_item_id =>  p_rec.item_id
279       ,p_effective_date                   => p_effective_date
280       ,p_object_version_number            => p_rec.object_version_number
281       ) THEN
282      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
283      fnd_message.set_token('PROCEDURE ', l_proc);
287   --
284      fnd_message.set_token('STEP ', '5');
285      fnd_message.raise_error;
286   END IF;
288   -- EDIT_HERE: Add checks to ensure non-updateable args have
289   --            not been updated.
290   --
291 End chk_non_updateable_args;
292 --
293 -- ----------------------------------------------------------------------------
294 -- |--------------------------< dt_update_validate >--------------------------|
295 -- ----------------------------------------------------------------------------
296 -- {Start Of Comments}
297 --
298 -- Description:
299 --   This procedure is used for referential integrity of datetracked
300 --   parent entities when a datetrack update operation is taking place
301 --   and where there is no cascading of update defined for this entity.
302 --
303 -- Prerequisites:
304 --   This procedure is called from the update_validate.
305 --
306 -- In Parameters:
307 --
308 -- Post Success:
309 --   Processing continues.
310 --
311 -- Post Failure:
312 --
313 -- Developer Implementation Notes:
314 --   This procedure should not need maintenance unless the HR Schema model
315 --   changes.
316 --
317 -- Access Status:
318 --   Internal Row Handler Use Only.
319 --
320 -- {End Of Comments}
321 -- ----------------------------------------------------------------------------
322 Procedure dt_update_validate
323   (p_rule_id                       in number default hr_api.g_number
324   ,p_datetrack_mode                in varchar2
325   ,p_validation_start_date         in date
326   ,p_validation_end_date           in date
327   ) Is
328 --
329   l_proc  varchar2(72) := g_package||'dt_update_validate';
330 --
331 Begin
332   --
333   -- Ensure that the p_datetrack_mode argument is not null
334   --
335   hr_api.mandatory_arg_error
336     (p_api_name       => l_proc
337     ,p_argument       => 'datetrack_mode'
338     ,p_argument_value => p_datetrack_mode
339     );
340   --
341   -- Mode will be valid, as this is checked at the start of the upd.
342   --
343   -- Ensure the arguments are not null
344   --
345   hr_api.mandatory_arg_error
346     (p_api_name       => l_proc
347     ,p_argument       => 'validation_start_date'
348     ,p_argument_value => p_validation_start_date
349     );
350   --
351   /*hr_api.mandatory_arg_error
352     (p_api_name       => l_proc
353     ,p_argument       => 'validation_end_date'
354     ,p_argument_value => p_validation_end_date
355     );*/
356   --
357 Exception
358   When Others Then
359     --
360     -- An unhandled or unexpected error has occurred which
361     -- we must report
362     --
363     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
364     fnd_message.set_token('PROCEDURE', l_proc);
365     fnd_message.set_token('STEP','15');
366     fnd_message.raise_error;
367 End dt_update_validate;
368 --
369 -- ----------------------------------------------------------------------------
370 -- |--------------------------< dt_delete_validate >--------------------------|
371 -- ----------------------------------------------------------------------------
372 -- {Start Of Comments}
373 --
374 -- Description:
375 --   This procedure is used for referential integrity of datetracked
376 --   child entities when either a datetrack DELETE or ZAP is in operation
377 --   and where there is no cascading of delete defined for this entity.
378 --   For the datetrack mode of DELETE or ZAP we must ensure that no
379 --   datetracked child rows exist between the validation start and end
380 --   dates.
381 --
382 -- Prerequisites:
383 --   This procedure is called from the delete_validate.
384 --
385 -- In Parameters:
386 --
387 -- Post Success:
388 --   Processing continues.
389 --
390 -- Post Failure:
391 --   If a row exists by determining the returning Boolean value from the
392 --   generic dt_api.rows_exist function then we must supply an error via
393 --   the use of the local exception handler l_rows_exist.
394 --
395 -- Developer Implementation Notes:
396 --   This procedure should not need maintenance unless the HR Schema model
397 --   changes.
398 --
399 -- Access Status:
400 --   Internal Row Handler Use Only.
401 --
402 -- {End Of Comments}
403 -- ----------------------------------------------------------------------------
404 Procedure dt_delete_validate
405   (p_item_id                          in number
406   ,p_rule_id                          in number
407   ,p_datetrack_mode                   in varchar2
408   ,p_validation_start_date            in date
409   ,p_validation_end_date              in date
410   ) Is
411 --
412   l_proc        varchar2(72)    := g_package||'dt_delete_validate';
413 --
414 Begin
415   --
416   -- Ensure that the p_datetrack_mode argument is not null
417   --
418   hr_api.mandatory_arg_error
419     (p_api_name       => l_proc
420     ,p_argument       => 'datetrack_mode'
421     ,p_argument_value => p_datetrack_mode
422     );
423   --
424   -- Only perform the validation if the datetrack mode is either
425   -- DELETE or ZAP
426   --
427   If (p_datetrack_mode = hr_api.g_delete or
428       p_datetrack_mode = hr_api.g_zap) then
429     --
430     --
431     -- Ensure the arguments are not null
432     --
433     hr_api.mandatory_arg_error
434       (p_api_name       => l_proc
435       ,p_argument       => 'validation_start_date'
436       ,p_argument_value => p_validation_start_date
437       );
438     --
439     /*hr_api.mandatory_arg_error
440       (p_api_name       => l_proc
441       ,p_argument       => 'validation_end_date'
442       ,p_argument_value => p_validation_end_date
443       );*/
444     --
445     hr_api.mandatory_arg_error
446       (p_api_name       => l_proc
447       ,p_argument       => 'rule_id'
448       ,p_argument_value => p_rule_id
449       );
450     --
451     --
452     --
453   End If;
454   --
455 Exception
456   When Others Then
457     --
458     -- An unhandled or unexpected error has occurred which
459     -- we must report
460     --
461     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
462     fnd_message.set_token('PROCEDURE', l_proc);
463     fnd_message.set_token('STEP','15');
464     fnd_message.raise_error;
465   --
466 End dt_delete_validate;
467 --
468 -- ----------------------------------------------------------------------------
469 -- |---------------------------< insert_validate >----------------------------|
470 -- ----------------------------------------------------------------------------
471 Procedure insert_validate
472   (p_rec                   in ame_rlu_shd.g_rec_type
473   ,p_effective_date        in date
474   ,p_datetrack_mode        in varchar2
475   ,p_validation_start_date in date
476   ,p_validation_end_date   in date
477   ) is
478 --
479   l_proc        varchar2(72) := g_package||'insert_validate';
480 --
481 Begin
482   hr_utility.set_location('Entering:'||l_proc, 5);
483   --
484   --
485   chk_rule_id(p_rule_id   => p_rec.rule_id
486              ,p_effective_date  => p_effective_date);
487   --
488   chk_item_id(p_item_id   => p_rec.item_id
489              ,p_effective_date  => p_effective_date);
490   --
491   chk_approver_category(p_approver_category  => p_rec.approver_category
492                        ,p_effective_date     => p_effective_date);
493   --
494   chk_rule_usg_dates(p_start_date     => p_rec.start_date
495                     ,p_end_date       => p_rec.end_date
496                     ,p_effective_date => p_effective_date);
497   --
498   -- Validate Dependent Attributes
499   --
500   --
501   hr_utility.set_location(' Leaving:'||l_proc, 10);
502 End insert_validate;
503 --
504 -- ----------------------------------------------------------------------------
505 -- |---------------------------< update_validate >----------------------------|
506 -- ----------------------------------------------------------------------------
507 Procedure update_validate
508   (p_rec                     in ame_rlu_shd.g_rec_type
509   ,p_effective_date          in date
510   ,p_datetrack_mode          in varchar2
511   ,p_validation_start_date   in date
512   ,p_validation_end_date     in date
513   ) is
514 --
515   l_proc        varchar2(72) := g_package||'update_validate';
516 --
517 Begin
518   hr_utility.set_location('Entering:'||l_proc, 5);
519   --
520   chk_approver_category(p_approver_category  => p_rec.approver_category
521                        ,p_effective_date     => p_effective_date);
522   --
523   chk_rule_usg_dates(p_start_date     => p_rec.start_date
524                     ,p_end_date       => p_rec.end_date
525                     ,p_effective_date => p_effective_date);
526   --
527   -- Validate Dependent Attributes
528   --
529   -- Call the datetrack update integrity operation
530   --
531   dt_update_validate
532     (p_rule_id                        => p_rec.rule_id
533     ,p_datetrack_mode                 => p_datetrack_mode
534     ,p_validation_start_date          => p_validation_start_date
535     ,p_validation_end_date            => p_validation_end_date
536     );
537   --
538   chk_non_updateable_args
539     (p_effective_date  => p_effective_date
540     ,p_rec             => p_rec
541     );
542   --
543   --
544   hr_utility.set_location(' Leaving:'||l_proc, 10);
545 End update_validate;
546 --
547 -- ----------------------------------------------------------------------------
548 -- |---------------------------< delete_validate >----------------------------|
549 -- ----------------------------------------------------------------------------
550 Procedure delete_validate
551   (p_rec                    in ame_rlu_shd.g_rec_type
552   ,p_effective_date         in date
553   ,p_datetrack_mode         in varchar2
554   ,p_validation_start_date  in date
555   ,p_validation_end_date    in date
556   ) is
557 --
558   l_proc        varchar2(72) := g_package||'delete_validate';
559 --
560 Begin
561   hr_utility.set_location('Entering:'||l_proc, 5);
562   --
563   -- Call all supporting business operations
564   --
565   dt_delete_validate
566     (p_datetrack_mode                   => p_datetrack_mode
567     ,p_validation_start_date            => p_validation_start_date
568     ,p_validation_end_date              => p_validation_end_date
569     ,p_rule_id =>  p_rec.rule_id
570  ,p_item_id =>  p_rec.item_id
571     );
572   --
573   hr_utility.set_location(' Leaving:'||l_proc, 10);
574 End delete_validate;
575 --
576 end ame_rlu_bus;