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