[Home] [Help]
PACKAGE BODY: APPS.PQH_WKS_BUS
Source
1 Package Body pqh_wks_bus as
2 /* $Header: pqwksrhi.pkb 120.0 2005/05/29 03:01:44 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_wks_bus.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_worksheet_id >------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description
15 -- This procedure is used to check that the primary key for the table
16 -- is created properly. It should be null on insert and
17 -- should not be able to be updated.
18 --
19 -- Pre Conditions
20 -- None.
21 --
22 -- In Parameters
23 -- worksheet_id PK of record being inserted or updated.
24 -- object_version_number Object version number of record being
25 -- inserted or updated.
26 --
27 -- Post Success
28 -- Processing continues
29 --
30 -- Post Failure
31 -- Errors handled by the procedure
32 --
33 -- Access Status
34 -- Internal table handler use only.
35 --
36 Procedure chk_worksheet_id(p_worksheet_id in number,
37 p_object_version_number in number) is
38 --
39 l_proc varchar2(72) := g_package||'chk_worksheet_id';
40 l_api_updating boolean;
41 --
42 Begin
43 --
44 hr_utility.set_location('Entering:'||l_proc, 5);
45 --
46 l_api_updating := pqh_wks_shd.api_updating
47 (p_worksheet_id => p_worksheet_id,
48 p_object_version_number => p_object_version_number);
49 --
50 if (l_api_updating
51 and nvl(p_worksheet_id,hr_api.g_number)
52 <> pqh_wks_shd.g_old_rec.worksheet_id) then
53 --
54 -- raise error as PK has changed
55 --
56 pqh_wks_shd.constraint_error('PQH_WORKSHEETS_PK');
57 --
58 elsif not l_api_updating then
59 --
60 -- check if PK is null
61 --
62 if p_worksheet_id is not null then
63 --
64 -- raise error as PK is not null
65 --
66 pqh_wks_shd.constraint_error('PQH_WORKSHEETS_PK');
67 --
68 end if;
69 --
70 end if;
71 --
72 hr_utility.set_location('Leaving:'||l_proc, 10);
73 --
74 End chk_worksheet_id;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |------< chk_budget_version_id >------|
78 -- ----------------------------------------------------------------------------
79 --
80 -- Description
81 -- This procedure checks that a referenced foreign key actually exists
82 -- in the referenced table.
83 --
84 -- Pre-Conditions
85 -- None.
86 --
87 -- In Parameters
88 -- p_worksheet_id PK
89 -- p_budget_version_id ID of FK column
90 -- p_object_version_number object version number
91 --
92 -- Post Success
93 -- Processing continues
94 --
95 -- Post Failure
96 -- Error raised.
97 --
98 -- Access Status
99 -- Internal table handler use only.
100 --
101 Procedure chk_budget_version_id (p_worksheet_id in number,
102 p_budget_version_id in number,
103 p_object_version_number in number) is
104 --
105 l_proc varchar2(72) := g_package||'chk_budget_version_id';
106 l_api_updating boolean;
107 l_dummy varchar2(1);
108 --
109 cursor c1 is
110 select null
111 from pqh_budget_versions a
112 where a.budget_version_id = p_budget_version_id;
113 --
114 Begin
115 --
116 hr_utility.set_location('Entering:'||l_proc,5);
117 --
118 l_api_updating := pqh_wks_shd.api_updating
119 (p_worksheet_id => p_worksheet_id,
120 p_object_version_number => p_object_version_number);
121 --
122 if (l_api_updating
123 and nvl(p_budget_version_id,hr_api.g_number)
124 <> nvl(pqh_wks_shd.g_old_rec.budget_version_id,hr_api.g_number)
125 or not l_api_updating) then
126 --
127 -- check if budget_version_id value exists in pqh_budget_versions table
128 --
129 open c1;
130 --
131 fetch c1 into l_dummy;
132 if c1%notfound then
133 --
134 close c1;
135 --
136 -- raise error as FK does not relate to PK in pqh_budget_versions
137 -- table.
138 --
139 pqh_wks_shd.constraint_error('PQH_WORKSHEETS_FK2');
140 --
141 end if;
142 --
143 close c1;
144 --
145 end if;
146 --
147 hr_utility.set_location('Leaving:'||l_proc,10);
148 --
149 End chk_budget_version_id;
150 --
151 -- ----------------------------------------------------------------------------
152 -- |------< chk_budget_id >------|
153 -- ----------------------------------------------------------------------------
154 --
155 -- Description
156 -- This procedure checks that a referenced foreign key actually exists
157 -- in the referenced table.
158 --
159 -- Pre-Conditions
160 -- None.
161 --
162 -- In Parameters
163 -- p_worksheet_id PK
164 -- p_budget_id ID of FK column
165 -- p_object_version_number object version number
166 --
167 -- Post Success
168 -- Processing continues
169 --
170 -- Post Failure
171 -- Error raised.
172 --
173 -- Access Status
174 -- Internal table handler use only.
175 --
176 Procedure chk_budget_id (p_worksheet_id in number,
177 p_budget_id in number,
178 p_object_version_number in number) is
179 --
180 l_proc varchar2(72) := g_package||'chk_budget_id';
181 l_api_updating boolean;
182 l_dummy varchar2(1);
183 --
184 cursor c1 is
185 select null
186 from pqh_budgets a
187 where a.budget_id = p_budget_id;
188 --
189 Begin
190 --
191 hr_utility.set_location('Entering:'||l_proc,5);
192 --
193 l_api_updating := pqh_wks_shd.api_updating
194 (p_worksheet_id => p_worksheet_id,
195 p_object_version_number => p_object_version_number);
196 --
197 if (l_api_updating
198 and nvl(p_budget_id,hr_api.g_number)
199 <> nvl(pqh_wks_shd.g_old_rec.budget_id,hr_api.g_number)
200 or not l_api_updating) then
201 --
202 -- check if budget_id value exists in pqh_budgets table
203 --
204 open c1;
205 --
206 fetch c1 into l_dummy;
207 if c1%notfound then
208 --
209 close c1;
210 --
211 -- raise error as FK does not relate to PK in pqh_budgets
212 -- table.
213 --
214 pqh_wks_shd.constraint_error('PQH_WORKSHEETS_FK1');
215 --
216 end if;
217 --
218 close c1;
219 --
220 end if;
221 --
222 hr_utility.set_location('Leaving:'||l_proc,10);
223 --
224 End chk_budget_id;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |------< chk_worksheet_mode_cd >------|
228 -- ----------------------------------------------------------------------------
229 --
230 -- Description
231 -- This procedure is used to check that the lookup value is valid.
232 --
233 -- Pre Conditions
234 -- None.
235 --
236 -- In Parameters
237 -- worksheet_id PK of record being inserted or updated.
238 -- worksheet_mode_cd Value of lookup code.
239 -- effective_date effective date
240 -- object_version_number Object version number of record being
241 -- inserted or updated.
242 --
243 -- Post Success
244 -- Processing continues
245 --
246 -- Post Failure
247 -- Error handled by procedure
248 --
249 -- Access Status
250 -- Internal table handler use only.
251 --
252 Procedure chk_worksheet_mode_cd(p_worksheet_id in number,
253 p_worksheet_mode_cd in varchar2,
254 p_effective_date in date,
255 p_object_version_number in number) is
256 --
257 l_proc varchar2(72) := g_package||'chk_worksheet_mode_cd';
258 l_api_updating boolean;
259 --
260 Begin
261 --
262 hr_utility.set_location('Entering:'||l_proc, 5);
263 --
264 l_api_updating := pqh_wks_shd.api_updating
265 (p_worksheet_id => p_worksheet_id,
266 p_object_version_number => p_object_version_number);
267 --
268 if (l_api_updating
269 and p_worksheet_mode_cd
270 <> nvl(pqh_wks_shd.g_old_rec.worksheet_mode_cd,hr_api.g_varchar2)
271 or not l_api_updating)
272 and p_worksheet_mode_cd is not null then
273 --
274 -- check if value of lookup falls within lookup type.
275 --
276 if hr_api.not_exists_in_hr_lookups
277 (p_lookup_type => 'PQH_WORKSHEET_MODE',
278 p_lookup_code => p_worksheet_mode_cd,
279 p_effective_date => p_effective_date) then
280 --
281 -- raise error as does not exist as lookup
282 --
283 hr_utility.set_message(801,'HR_LOOKUP_DOES_NOT_EXIST');
284 hr_utility.raise_error;
285 --
286 end if;
287 --
288 end if;
289 --
290 hr_utility.set_location('Leaving:'||l_proc,10);
291 --
292 end chk_worksheet_mode_cd;
293 --
294 -- ----------------------------------------------------------------------------
295 -- |------< chk_transaction_status >------|
296 -- ----------------------------------------------------------------------------
297 --
298 -- Description
299 -- This procedure is used to check that the lookup value is valid.
300 --
301 -- Pre Conditions
302 -- None.
303 --
304 -- In Parameters
305 -- worksheet_id PK of record being inserted or updated.
306 -- transaction_status Value of lookup code.
307 -- effective_date effective date
308 -- object_version_number Object version number of record being
309 -- inserted or updated.
310 --
311 -- Post Success
312 -- Processing continues
313 --
314 -- Post Failure
315 -- Error handled by procedure
316 --
317 -- Access Status
318 -- Internal table handler use only.
319 --
320 Procedure chk_transaction_status(p_worksheet_id in number,
321 p_transaction_status in varchar2,
322 p_effective_date in date,
323 p_object_version_number in number) is
324 --
325 l_proc varchar2(72) := g_package||'chk_transaction_status';
326 l_api_updating boolean;
327 --
328 Begin
329 --
330 hr_utility.set_location('Entering:'||l_proc, 5);
331 --
332 l_api_updating := pqh_wks_shd.api_updating
333 (p_worksheet_id => p_worksheet_id,
334 p_object_version_number => p_object_version_number);
335 --
336 if (l_api_updating
337 and p_transaction_status
338 <> nvl(pqh_wks_shd.g_old_rec.transaction_status,hr_api.g_varchar2)
339 or not l_api_updating)
340 and p_transaction_status is not null then
341 --
342 -- check if value of lookup falls within lookup type.
343 --
344 if hr_api.not_exists_in_hr_lookups
345 (p_lookup_type => 'PQH_TRANSACTION_STATUS',
346 p_lookup_code => p_transaction_status,
347 p_effective_date => p_effective_date) then
348 --
349 -- raise error as does not exist as lookup
350 --
351 hr_utility.set_message(801,'HR_LOOKUP_DOES_NOT_EXIST');
352 hr_utility.raise_error;
353 --
354 end if;
355 --
356 end if;
357 --
358 hr_utility.set_location('Leaving:'||l_proc,10);
359 --
360 end chk_transaction_status;
361 --
362 -- ----------------------------------------------------------------------------
363 -- |------< chk_propagation_method >------|
364 -- ----------------------------------------------------------------------------
365 --
366 -- Description
367 -- This procedure is used to check that the lookup value is valid.
368 --
369 -- Pre Conditions
370 -- None.
371 --
372 -- In Parameters
373 -- worksheet_id PK of record being inserted or updated.
374 -- propagation_method Value of lookup code.
375 -- effective_date effective date
376 -- object_version_number Object version number of record being
377 -- inserted or updated.
378 --
379 -- Post Success
380 -- Processing continues
381 --
382 -- Post Failure
383 -- Error handled by procedure
384 --
385 -- Access Status
386 -- Internal table handler use only.
387 --
388 Procedure chk_propagation_method(p_worksheet_id in number,
389 p_propagation_method in varchar2,
390 p_effective_date in date,
391 p_object_version_number in number) is
392 --
393 l_proc varchar2(72) := g_package||'chk_propagation_method';
394 l_api_updating boolean;
395 --
396 Begin
397 --
398 hr_utility.set_location('Entering:'||l_proc, 5);
399 --
400 l_api_updating := pqh_wks_shd.api_updating
401 (p_worksheet_id => p_worksheet_id,
402 p_object_version_number => p_object_version_number);
403 --
404 if (l_api_updating
405 and p_propagation_method
406 <> nvl(pqh_wks_shd.g_old_rec.propagation_method,hr_api.g_varchar2)
407 or not l_api_updating)
408 and p_propagation_method is not null then
409 --
410 -- check if value of lookup falls within lookup type.
411 --
412 if hr_api.not_exists_in_hr_lookups
413 (p_lookup_type => 'PQH_WORKSHEET_PROPAGATE_METHOD',
414 p_lookup_code => p_propagation_method,
415 p_effective_date => p_effective_date) then
416 --
417 -- raise error as does not exist as lookup
418 --
419 hr_utility.set_message(801,'HR_LOOKUP_DOES_NOT_EXIST');
420 hr_utility.raise_error;
421 --
422 end if;
423 --
424 end if;
425 --
426 hr_utility.set_location('Leaving:'||l_proc,10);
427 --
428 end chk_propagation_method;
429 --
430 -- ----------------------------------------------------------------------------
431 -- |------< chk_version_number >------|
432 -- ----------------------------------------------------------------------------
433 --
434 -- Description
435 -- This procedure is used to check that the version numberis valid.
436 --
437 -- Pre Conditions
438 -- None.
439 --
440 -- In Parameters
444 -- effective_date effective date
441 -- worksheet_id PK of record being inserted or updated.
442 -- budget_id FK of record being inserted or updated.
443 -- version_number of budget_id being inserted or updated.
445 -- object_version_number Object version number of record being
446 -- inserted or updated.
447 --
448 -- Post Success
449 -- Processing continues
450 --
451 -- Post Failure
452 -- Error handled by procedure
453 --
454 -- Access Status
455 -- Internal table handler use only.
456 --
457 Procedure chk_version_number(p_worksheet_id in number,
458 p_budget_id in number,
459 p_version_number in number,
460 p_effective_date in date,
461 p_object_version_number in number) is
462 --
463 l_proc varchar2(72) := g_package||'chk_version_number';
464 l_api_updating boolean;
465 l_dummy varchar2(1);
466 --
467 Cursor c1 is
468 Select null
469 from pqh_budget_versions a
470 where a.budget_id = p_budget_id
471 AND a.version_number = p_version_number;
472 Begin
473 --
474 hr_utility.set_location('Entering:'||l_proc, 5);
475 --
476 l_api_updating := pqh_wks_shd.api_updating
477 (p_worksheet_id => p_worksheet_id,
478 p_object_version_number => p_object_version_number);
479 --
480 if (l_api_updating
481 and p_version_number
482 <> nvl(pqh_wks_shd.g_old_rec.version_number,hr_api.g_number)
483 or not l_api_updating)
484 and p_version_number is not null then
485 --
486 -- check if value of lookup falls within lookup type.
487 --
488 If p_budget_id IS NULL then
489 --
490 -- There can be no version number without budget id
491 --
492 hr_utility.set_message(8302,'PQH_NO_BDGT_ID_FOR_VERSION_NO');
493 hr_utility.raise_error;
494 Else
495 --
496 -- Check if the version exists for the budget id.
497 --
498 Open c1;
499 --
500 Fetch c1 into l_dummy;
501 --
502 If c1%notfound then
503 --
504 Close c1;
505 hr_utility.set_message(8302,'PQH_INVALID_VERSION_FOR_BDGT');
506 hr_utility.raise_error;
507 --
508 End if;
509 --
510 Close c1;
511 --
512 End if;
513 --
514 end if;
515 --
516 hr_utility.set_location('Leaving:'||l_proc,10);
517 --
518 end chk_version_number;
519 --
520 -- ----------------------------------------------------------------------------
521 -- |------< chk_dates >------|
522 -- ----------------------------------------------------------------------------
523 --
524 -- Description
525 -- This procedure is used to check that the version numberis valid.
526 --
527 -- Pre Conditions
528 -- None.
529 --
530 -- In Parameters
531 -- worksheet_id PK of record being inserted or updated.
532 -- dates of budget_id being inserted or updated.
533 -- effective_date effective date
534 -- object_version_number Object version number of record being
535 -- inserted or updated.
536 --
537 -- Post Success
538 -- Processing continues
539 --
540 -- Post Failure
541 -- Error handled by procedure
542 --
543 -- Access Status
544 -- Internal table handler use only.
545 --
546 Procedure chk_dates(p_worksheet_id in number,
547 p_date_from in date,
548 p_date_to in date,
549 p_effective_date in date,
550 p_object_version_number in number) is
551 --
552 l_proc varchar2(72) := g_package||'chk_dates';
553 l_api_updating boolean;
554 --
555 Begin
556 --
557 hr_utility.set_location('Entering:'||l_proc, 5);
558 --
559 If nvl(p_date_to,to_date('31/12/4712','dd/mm/RRRR')) <
560 nvl(p_date_from,to_date('31/12/4712','dd/mm/RRRR')) then
561 --
562 hr_utility.set_message(8302,'PQH_TO_DT_LESS_THAN_FROM_DT');
563 hr_utility.raise_error;
564 end if;
565 --
566 hr_utility.set_location('Leaving:'||l_proc,10);
567 --
568 end chk_dates;
569 --
570 -- ----------------------------------------------------------------------------
571 -- |---------------------------< insert_validate >----------------------------|
572 -- ----------------------------------------------------------------------------
573 Procedure insert_validate(p_rec in pqh_wks_shd.g_rec_type
574 ,p_effective_date in date) is
575 --
576 l_proc varchar2(72) := g_package||'insert_validate';
577 --
578 Begin
579 hr_utility.set_location('Entering:'||l_proc, 5);
580 --
581 -- Call all supporting business operations
582 --
583 chk_worksheet_id
584 (p_worksheet_id => p_rec.worksheet_id,
588 (p_worksheet_id => p_rec.worksheet_id,
585 p_object_version_number => p_rec.object_version_number);
586 --
587 chk_budget_version_id
589 p_budget_version_id => p_rec.budget_version_id,
590 p_object_version_number => p_rec.object_version_number);
591 --
592 chk_budget_id
593 (p_worksheet_id => p_rec.worksheet_id,
594 p_budget_id => p_rec.budget_id,
595 p_object_version_number => p_rec.object_version_number);
596 --
597 chk_worksheet_mode_cd
598 (p_worksheet_id => p_rec.worksheet_id,
599 p_worksheet_mode_cd => p_rec.worksheet_mode_cd,
600 p_effective_date => p_effective_date,
601 p_object_version_number => p_rec.object_version_number);
602 --
603 chk_propagation_method
604 (p_worksheet_id => p_rec.worksheet_id,
605 p_propagation_method => p_rec.propagation_method,
606 p_effective_date => p_effective_date,
607 p_object_version_number => p_rec.object_version_number);
608 --
609 chk_transaction_status
610 (p_worksheet_id => p_rec.worksheet_id,
611 p_transaction_status => p_rec.transaction_status,
612 p_effective_date => p_effective_date,
613 p_object_version_number => p_rec.object_version_number);
614 --
615 chk_version_number
616 (p_worksheet_id => p_rec.worksheet_id,
617 p_budget_id => p_rec.budget_id,
618 p_version_number => p_rec.version_number,
619 p_effective_date => p_effective_date,
620 p_object_version_number => p_rec.object_version_number);
621 --
622 chk_dates
623 (p_worksheet_id => p_rec.worksheet_id,
624 p_date_from => p_rec.date_from,
625 p_date_to => p_rec.date_to,
626 p_effective_date => p_effective_date,
627 p_object_version_number => p_rec.object_version_number);
628 --
629 --
630 hr_utility.set_location(' Leaving:'||l_proc, 10);
631 End insert_validate;
632 --
633 -- ----------------------------------------------------------------------------
634 -- |---------------------------< update_validate >----------------------------|
635 -- ----------------------------------------------------------------------------
636 Procedure update_validate(p_rec in pqh_wks_shd.g_rec_type
637 ,p_effective_date in date) is
638 --
639 l_proc varchar2(72) := g_package||'update_validate';
640 --
641 Begin
642 hr_utility.set_location('Entering:'||l_proc, 5);
643 --
644 -- Call all supporting business operations
645 --
646 chk_worksheet_id
647 (p_worksheet_id => p_rec.worksheet_id,
648 p_object_version_number => p_rec.object_version_number);
649 --
650 chk_budget_version_id
651 (p_worksheet_id => p_rec.worksheet_id,
652 p_budget_version_id => p_rec.budget_version_id,
653 p_object_version_number => p_rec.object_version_number);
654 --
655 chk_budget_id
656 (p_worksheet_id => p_rec.worksheet_id,
657 p_budget_id => p_rec.budget_id,
658 p_object_version_number => p_rec.object_version_number);
659 --
660 chk_worksheet_mode_cd
661 (p_worksheet_id => p_rec.worksheet_id,
662 p_worksheet_mode_cd => p_rec.worksheet_mode_cd,
663 p_effective_date => p_effective_date,
664 p_object_version_number => p_rec.object_version_number);
665 --
666 chk_propagation_method
667 (p_worksheet_id => p_rec.worksheet_id,
668 p_propagation_method => p_rec.propagation_method,
669 p_effective_date => p_effective_date,
670 p_object_version_number => p_rec.object_version_number);
671 --
672 --
673 chk_transaction_status
674 (p_worksheet_id => p_rec.worksheet_id,
675 p_transaction_status => p_rec.transaction_status,
676 p_effective_date => p_effective_date,
677 p_object_version_number => p_rec.object_version_number);
678 --
679 chk_version_number
680 (p_worksheet_id => p_rec.worksheet_id,
681 p_budget_id => p_rec.budget_id,
682 p_version_number => p_rec.version_number,
683 p_effective_date => p_effective_date,
684 p_object_version_number => p_rec.object_version_number);
685 --
686 chk_dates
687 (p_worksheet_id => p_rec.worksheet_id,
688 p_date_from => p_rec.date_from,
689 p_date_to => p_rec.date_to,
690 p_effective_date => p_effective_date,
691 p_object_version_number => p_rec.object_version_number);
692 --
693 --
694 --
695 hr_utility.set_location(' Leaving:'||l_proc, 10);
696 End update_validate;
697 --
698 -- ----------------------------------------------------------------------------
699 -- |---------------------------< delete_validate >----------------------------|
700 -- ----------------------------------------------------------------------------
701 Procedure delete_validate(p_rec in pqh_wks_shd.g_rec_type
702 ,p_effective_date in date) is
703 --
704 l_proc varchar2(72) := g_package||'delete_validate';
705 --
706 Begin
707 hr_utility.set_location('Entering:'||l_proc, 5);
708 --
709 -- Call all supporting business operations
710 --
711 hr_utility.set_location(' Leaving:'||l_proc, 10);
712 End delete_validate;
713 --
714 end pqh_wks_bus;