DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_ACU_BUS

Source


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