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