1 Package Body ame_cnu_bus as
2 /* $Header: amcnurhi.pkb 120.4 2005/11/22 03:15 santosin noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ame_cnu_bus.'; -- Global package name
9 --
10 -- ---------------------------------------------------------------------------
11 -- |------------------------<chk_condition_id >-----------------------------|
12 -- ---------------------------------------------------------------------------
13 --
14 -- {Start Of Comments}
15 --
16 -- Description:
17 -- Validates that the condition_id is a foreign key to ame_conditions.condition_id.
18 -- Check that an attribute usage exists for the attribute this condition is based on
19 -- within the specified transaction type.
20 --
21 -- Prerequisites:
22 -- None.
23 --
24 -- In Parameters:
25 -- p_condition_id
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_condition_id
43 (p_condition_id in number,
44 p_effective_date in date) is
45 l_proc varchar2(72) := g_package||'chk_condition_id';
46 tempCount integer;
47 cursor c_sel1 is
48 select null
49 from ame_conditions
50 where
51 condition_id = p_condition_id and
52 p_effective_date between start_date and
53 nvl(end_date - ame_util.oneSecond, p_effective_date) ;
54 l_exists varchar2(1);
55 begin
56 open c_sel1;
57 fetch c_sel1 into l_exists;
58 if c_sel1%notfound then
59 close c_sel1;
60 fnd_message.set_name('PER','AME_400479_INV_CONDITION_ID');
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 => 'CONDITION_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_condition_id;
73 -- ---------------------------------------------------------------------------
74 -- |----------------------<chk_rule_id >--------------------------|
75 -- ---------------------------------------------------------------------------
76 --
77 -- {Start Of Comments}
78 --
79 -- Description:
80 -- Validates that the rule_id is a foreign key to ame_rules.rule_id.
81 --
82 -- Prerequisites:
83 -- None.
84 --
85 -- In Parameters:
86 -- p_rule_id
87 -- p_effective_date
88 --
89 -- Post Success:
90 -- Processing continues.
91 --
92 -- Post Failure:
93 -- Log the error message.
94 --
95 -- Developer Implementation Notes:
96 -- None.
97 --
98 -- Access Status:
99 -- Internal Row Handler Use Only.
100 --
101 -- {End Of Comments}
102 -- ----------------------------------------------------------------------------
103 procedure chk_rule_id
104 (p_rule_id in number,
105 p_effective_date in date) is
106 l_proc varchar2(72) := g_package||'chk_rule_id';
107 tempCount integer;
108 cursor c_sel1 is
109 select null
110 from ame_rules
111 where
112 rule_id = p_rule_id and
113 ((p_effective_date between start_date and
114 nvl(end_date - ame_util.oneSecond, p_effective_date)) or
115 (p_effective_date < start_date and
116 start_date < nvl(end_date,start_date + ame_util.oneSecond)));
117 l_exists varchar2(1);
118 begin
119 open c_sel1;
120 fetch c_sel1 into l_exists;
121 if c_sel1%notfound then
122 close c_sel1;
123 fnd_message.set_name('PER','AME_400480_INV_RULE_ID');
124 fnd_message.raise_error;
125 end if;
126 close c_sel1;
127 exception
128 when app_exception.application_exception then
129 if hr_multi_message.exception_add
130 (p_associated_column1 => 'RULE_ID') then
131 hr_utility.set_location(' Leaving:'|| l_proc, 50);
132 raise;
133 end if;
134 hr_utility.set_location(' Leaving:'|| l_proc, 60);
135 end chk_rule_id;
136 -- ----------------------------------------------------------------------------
137 -- |-----------------------< chk_non_updateable_args >------------------------|
138 -- ----------------------------------------------------------------------------
139 -- {Start Of Comments}
140 --
141 -- Description:
142 -- This procedure is used to ensure that non updateable attributes have
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.
155 -- changed.
152 --
153 -- Post Success:
154 -- Processing continues if all the non updateable attributes have not
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_cnu_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_cnu_shd.api_updating
176 (p_condition_id => p_rec.condition_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 --
190 End chk_non_updateable_args;
191 --
192 -- ----------------------------------------------------------------------------
193 -- |--------------------------< dt_update_validate >--------------------------|
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_datetrack_mode in varchar2
223 ,p_validation_start_date in date
224 ,p_validation_end_date in date
225 ) Is
226 --
227 l_proc varchar2(72) := g_package||'dt_update_validate';
228 --
229 Begin
230 --
231 -- Ensure that the p_datetrack_mode argument is not null
232 --
233 hr_api.mandatory_arg_error
234 (p_api_name => l_proc
235 ,p_argument => 'datetrack_mode'
236 ,p_argument_value => p_datetrack_mode
237 );
238 --
239 -- Mode will be valid, as this is checked at the start of the upd.
240 --
241 -- Ensure the arguments are not null
242 --
243 hr_api.mandatory_arg_error
244 (p_api_name => l_proc
245 ,p_argument => 'validation_start_date'
246 ,p_argument_value => p_validation_start_date
247 );
248 --
249 /*hr_api.mandatory_arg_error
250 (p_api_name => l_proc
251 ,p_argument => 'validation_end_date'
252 ,p_argument_value => p_validation_end_date
253 );*/
254 --
255 Exception
256 When Others Then
257 --
258 -- An unhandled or unexpected error has occurred which
259 -- we must report
260 --
261 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
262 fnd_message.set_token('PROCEDURE', l_proc);
263 fnd_message.set_token('STEP','15');
264 fnd_message.raise_error;
265 End dt_update_validate;
266 --
267 -- ----------------------------------------------------------------------------
268 -- |--------------------------< dt_delete_validate >--------------------------|
269 -- ----------------------------------------------------------------------------
270 -- {Start Of Comments}
271 --
272 -- Description:
273 -- This procedure is used for referential integrity of datetracked
274 -- child entities when either a datetrack DELETE or ZAP is in operation
275 -- and where there is no cascading of delete defined for this entity.
276 -- For the datetrack mode of DELETE or ZAP we must ensure that no
277 -- datetracked child rows exist between the validation start and end
278 -- dates.
279 --
280 -- Prerequisites:
281 -- This procedure is called from the delete_validate.
282 --
283 -- In Parameters:
284 --
285 -- Post Success:
286 -- Processing continues.
287 --
288 -- Post Failure:
289 -- If a row exists by determining the returning Boolean value from the
290 -- generic dt_api.rows_exist function then we must supply an error via
291 -- the use of the local exception handler l_rows_exist.
292 --
293 -- Developer Implementation Notes:
294 -- This procedure should not need maintenance unless the HR Schema model
295 -- changes.
296 --
297 -- Access Status:
298 -- Internal Row Handler Use Only.
299 --
300 -- {End Of Comments}
301 -- ----------------------------------------------------------------------------
302 Procedure dt_delete_validate
303 (p_rule_id in number
304 ,p_condition_id in number
305 ,p_datetrack_mode in varchar2
309 --
306 ,p_validation_start_date in date
307 ,p_validation_end_date in date
308 ) Is
310 l_proc varchar2(72) := g_package||'dt_delete_validate';
311 --
312 Begin
313 --
314 -- Ensure that the p_datetrack_mode argument is not null
315 --
316 hr_api.mandatory_arg_error
317 (p_api_name => l_proc
318 ,p_argument => 'datetrack_mode'
319 ,p_argument_value => p_datetrack_mode
320 );
321 --
322 -- Only perform the validation if the datetrack mode is either
323 -- DELETE or ZAP
324 --
325 If (p_datetrack_mode = hr_api.g_delete or
326 p_datetrack_mode = hr_api.g_zap) then
327 --
328 --
329 -- Ensure the arguments are not null
330 --
331 hr_api.mandatory_arg_error
332 (p_api_name => l_proc
333 ,p_argument => 'validation_start_date'
334 ,p_argument_value => p_validation_start_date
335 );
336 --
337 /*hr_api.mandatory_arg_error
338 (p_api_name => l_proc
339 ,p_argument => 'validation_end_date'
340 ,p_argument_value => p_validation_end_date
341 );*/
342 --
343 hr_api.mandatory_arg_error
344 (p_api_name => l_proc
345 ,p_argument => 'condition_id'
346 ,p_argument_value => p_condition_id
347 );
348 --
349 --
350 --
351 End If;
352 --
353 Exception
354 When Others Then
355 --
356 -- An unhandled or unexpected error has occurred which
357 -- we must report
358 --
359 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
360 fnd_message.set_token('PROCEDURE', l_proc);
361 fnd_message.set_token('STEP','15');
362 fnd_message.raise_error;
363 --
364 End dt_delete_validate;
365 --
366 -- ----------------------------------------------------------------------------
367 -- |---------------------------< insert_validate >----------------------------|
368 -- ----------------------------------------------------------------------------
369 Procedure insert_validate
370 (p_rec in ame_cnu_shd.g_rec_type
371 ,p_effective_date in date
372 ,p_datetrack_mode in varchar2
373 ,p_validation_start_date in date
374 ,p_validation_end_date in date
375 ) is
376 --
377 l_proc varchar2(72) := g_package||'insert_validate';
378 --
379 Begin
380 hr_utility.set_location('Entering:'||l_proc, 5);
381 --
382 chk_rule_id(p_rule_id => p_rec.rule_id
383 ,p_effective_date => p_effective_date);
384 --
385 chk_condition_id(p_condition_id => p_rec.condition_id
386 ,p_effective_date => p_effective_date);
387 --
388 -- Validate Dependent Attributes
389 --
390 --
391 hr_utility.set_location(' Leaving:'||l_proc, 10);
392 End insert_validate;
393 --
394 -- ----------------------------------------------------------------------------
395 -- |---------------------------< update_validate >----------------------------|
396 -- ----------------------------------------------------------------------------
397 Procedure update_validate
398 (p_rec in ame_cnu_shd.g_rec_type
399 ,p_effective_date in date
400 ,p_datetrack_mode in varchar2
401 ,p_validation_start_date in date
402 ,p_validation_end_date in date
403 ) is
404 --
405 l_proc varchar2(72) := g_package||'update_validate';
406 --
407 Begin
408 hr_utility.set_location('Entering:'||l_proc, 5);
409 --
410 -- Validate Dependent Attributes
411 --
412 -- Call the datetrack update integrity operation
413 --
414 dt_update_validate
415 (p_datetrack_mode => p_datetrack_mode
416 ,p_validation_start_date => p_validation_start_date
417 ,p_validation_end_date => p_validation_end_date
418 );
419 --
420 chk_non_updateable_args
421 (p_effective_date => p_effective_date
422 ,p_rec => p_rec
423 );
424 --
425 --
426 hr_utility.set_location(' Leaving:'||l_proc, 10);
427 End update_validate;
428 --
429 -- ----------------------------------------------------------------------------
430 -- |---------------------------< delete_validate >----------------------------|
431 -- ----------------------------------------------------------------------------
432 Procedure delete_validate
433 (p_rec in ame_cnu_shd.g_rec_type
434 ,p_effective_date in date
435 ,p_datetrack_mode in varchar2
436 ,p_validation_start_date in date
437 ,p_validation_end_date in date
438 ) is
439 --
440 l_proc varchar2(72) := g_package||'delete_validate';
441 --
442 Begin
443 hr_utility.set_location('Entering:'||l_proc, 5);
444 --
445 -- Call all supporting business operations
446 --
447 dt_delete_validate
448 (p_datetrack_mode => p_datetrack_mode
449 ,p_validation_start_date => p_validation_start_date
450 ,p_validation_end_date => p_validation_end_date
451 ,p_condition_id => p_rec.condition_id
452 ,p_rule_id => p_rec.rule_id
453 );
454 --
455 hr_utility.set_location(' Leaving:'||l_proc, 10);
456 End delete_validate;
457 --
458 end ame_cnu_bus;