DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_DU_RULES

Source


1 PACKAGE BODY HR_DU_RULES AS
2 /* $Header: perdurul.pkb 120.0 2005/05/31 17:22:43 appldev noship $ */
3 
4 
5 -- ------------------------- API_PRESENT_AND_CORRECT -----------------------
6 -- Description: Double checks that the API name exists in the
7 -- HR_DU_DESCRIPTORS table, and is matched to the api name in header sheet
8 --
9 --  Input Parameters
10 --
11 --	p_upload_header_id - Identifies the API's file for which the process
12 --			     order will be retrieved
13 --
14 -- -------------------------------------------------------------------------
15 PROCEDURE API_PRESENT_AND_CORRECT(p_upload_header_id IN NUMBER,
16 				p_upload_id IN NUMBER) IS
17 
18 --This cursor extracts the api name from the descriptors
19   CURSOR csr_api_name IS
20   SELECT upper(VALUE)
21     FROM hr_du_descriptors
22     WHERE upper(DESCRIPTOR) = 'API'
23     AND UPLOAD_HEADER_ID = p_upload_header_id;
24 
25 --checks the header descriptors to check that the API name matches
26   CURSOR csr_api_header IS
27   SELECT upper(DESCRIPTOR)
28     FROM hr_du_descriptors
29     WHERE DESCRIPTOR_TYPE = 'F'
30     AND UPLOAD_ID = p_upload_id
31     AND upload_header_id IS NULL;
32 
33 
34   e_fatal_error 	EXCEPTION;
35   l_fatal_error_message	VARCHAR2(2000);
36   l_api_name		VARCHAR2(2000);
37   l_file_name		VARCHAR2(2000);
38   l_api_header		VARCHAR2(2000);
39 
40 
41 BEGIN
42 --
43   hr_du_utility.message('ROUT','entry:hr_du_rules.api_present_and_correct', 5);
44   hr_du_utility.message('PARA', '(p_upload_header_id - ' || p_upload_header_id || ')' , 10);
45 --
46 
47   OPEN csr_api_name;
48     FETCH csr_api_name INTO l_api_name;
49     IF csr_api_name%NOTFOUND THEN
50     --
51       l_file_name := RETURN_UPLOAD_HEADER_FILE(p_upload_header_id);
52       l_fatal_error_message := 'Unable to retieve the API name from the ' ||
53                                'file ' || l_file_name;
54       RAISE e_fatal_error;
55     --
56     ELSE
57       OPEN csr_api_header;
58       LOOP
59         FETCH csr_api_header INTO l_api_header;
60         IF csr_api_header%NOTFOUND THEN
61         --
62           l_file_name := RETURN_UPLOAD_HEADER_FILE(p_upload_header_id);
63           l_fatal_error_message := 'Unable to match api name ' || l_api_name ||
64                                    ' in the file ' || l_file_name || ' to an' ||
65                                    ' API name on the header sheet';
66           RAISE e_fatal_error;
67         --
68         ELSIF l_api_header = l_api_name THEN
69           EXIT;
70         END IF;
71       END LOOP;
72       CLOSE csr_api_header;
73     END IF;
74   CLOSE csr_api_name;
75 
76 --
77   hr_du_utility.message('ROUT','exit:hr_du_rules.api_present_and_correct', 15);
78 --
79 
80 EXCEPTION
81   WHEN e_fatal_error THEN
82     hr_du_utility.error(SQLCODE, 'hr_du_rules.api_present_and_correct',
83     l_fatal_error_message, 'R');
84     RAISE;
85   WHEN OTHERS THEN
86     hr_du_utility.error(SQLCODE, 'hr_du_rules.api_present_and_correct',
87                        '(none)', 'R');
88     RAISE;
89 --
90 END API_PRESENT_AND_CORRECT;
91 
92 
93 -- ------------------------- PROCESS_ORDER_PRESENT ------------------------
94 -- Description: Double checks that the process order exists in the
95 -- HR_DU_DESCRIPTORS table.
96 --
97 --  Input Parameters
98 --
99 --	p_upload_header_id - Identifies the API's file for which the process
100 --			     order will be retrieved
101 --
102 -- ------------------------------------------------------------------------
103 PROCEDURE PROCESS_ORDER_PRESENT(p_upload_header_id IN NUMBER) IS
104 
105 --This cursor extracts the Process Order from the descriptors
106   CURSOR csr_process_order IS
107   SELECT VALUE
108     FROM hr_du_descriptors
109     WHERE upper(DESCRIPTOR) = 'PROCESS ORDER'
110     AND UPLOAD_HEADER_ID = p_upload_header_id;
111 
112   e_fatal_error 	EXCEPTION;
113   l_fatal_error_message	VARCHAR2(2000);
114   l_process_order	VARCHAR2(2000);
115   l_file_name		VARCHAR2(2000);
116 
117 
118 BEGIN
119 --
120   hr_du_utility.message('ROUT','entry:hr_du_rules.PROCESS_ORDER_PRESENT', 5);
121   hr_du_utility.message('PARA', '(p_upload_header_id - ' || p_upload_header_id || ')' , 10);
122 --
123 
124   OPEN csr_process_order;
125     FETCH csr_process_order INTO l_process_order;
126     IF csr_process_order%NOTFOUND THEN
127     --
128       l_file_name := RETURN_UPLOAD_HEADER_FILE(p_upload_header_id);
129       l_fatal_error_message := 'Unable to retieve the Process Order from the ' ||
130                                'file ' || l_file_name;
131       RAISE e_fatal_error;
132     --
133     END IF;
134   CLOSE csr_process_order;
135 
136 --
137   hr_du_utility.message('ROUT','exit:hr_du_rules.process_order_present', 15);
138 --
139 
140 EXCEPTION
141   WHEN e_fatal_error THEN
142     hr_du_utility.error(SQLCODE, 'hr_du_rules.process_order_present',
143     l_fatal_error_message, 'R');
144     RAISE;
145   WHEN OTHERS THEN
146     hr_du_utility.error(SQLCODE, 'hr_du_rules.process_order_present',
147                        '(none)', 'R');
148     RAISE;
149 --
150 END PROCESS_ORDER_PRESENT;
151 
152 
153 -- ----------------------- RETURN_UPLOAD_HEADER_FILE -----------------------
154 -- Description: Simply takes an upload_header_id and figure out the file
155 -- name associated with the API file to infor the user.
156 --
157 --  Input Parameters
158 --
159 --	p_upload_header_id - Identifies the API's file for which the file
160 --			     name will be retrieved
161 --
162 -- ------------------------------------------------------------------------
163 FUNCTION RETURN_UPLOAD_HEADER_FILE(p_upload_header_id IN NUMBER)
164 				    RETURN VARCHAR2
165 IS
166 
167   CURSOR csr_api_file IS
168   SELECT des2.value
169   FROM   hr_du_descriptors     des1,
170          hr_du_descriptors     des2,
171          hr_du_upload_headers  head,
172          hr_du_uploads	       uplo
173   WHERE  head.upload_header_id = p_upload_header_id
174   AND    head.upload_id = uplo.upload_id
175   AND    head.upload_header_id = des1.upload_header_id
176   AND    des1.descriptor = 'API'
177   AND    uplo.upload_id = des2.upload_id
178   AND    upper(des2.descriptor) = upper(des1.value);
179 
180 
181   e_fatal_error 	EXCEPTION;
182   l_fatal_error_message	VARCHAR2(2000);
183   l_file_name	 	VARCHAR2(2000);
184 
185 
186 BEGIN
187 --
188   hr_du_utility.message('ROUT','entry:hr_du_rules.return_upload_header_file', 5);
189   hr_du_utility.message('PARA', '(p_upload_header_id - ' || p_upload_header_id || ')' , 10);
190 --
191 
192   OPEN csr_api_file;
193     FETCH csr_api_file INTO l_file_name;
194     IF csr_api_file%NOTFOUND THEN
195       l_fatal_error_message := 'Unable to retieve the file name for the ' ||
196 			       'UPLOAD HEADER ' || p_upload_header_id ||
197 			       ' Possible API name mismatch';
198       RAISE e_fatal_error;
199     END IF;
200   CLOSE csr_api_file;
201 
202   RETURN l_file_name;
203 
204 --
205   hr_du_utility.message('ROUT','exit:hr_du_rules.return_upload_header_file', 15);
206   hr_du_utility.message('PARA', '(l_file_name - ' || l_file_name || ')'
207                         , 20);
208 --
209 
210 EXCEPTION
211   WHEN e_fatal_error THEN
212     hr_du_utility.error(SQLCODE, 'hr_du_rules.return_upload_header_file',
213     l_fatal_error_message, 'R');
214     RAISE;
215   WHEN OTHERS THEN
216     hr_du_utility.error(SQLCODE, 'hr_du_rules.return_upload_header_file',
217                        '(none)', 'R');
218     RAISE;
219 --
220 END RETURN_UPLOAD_HEADER_FILE;
221 
222 
223 
224 -- ------------------------ VALIDATE_USER_KEY_SETUP -----------------------
225 -- Description: This function validates the user key supplied with each
226 -- API file, the user key has set properties which must all be checked here.
227 --
228 --  Input Parameters
229 --
230 --	p_upload_header_id - Identifies the API's file where the user key
231 --			     will be validated.
232 --
233 -- ------------------------------------------------------------------------
234 PROCEDURE VALIDATE_USER_KEY_SETUP(p_upload_header_id IN NUMBER, p_upload_id IN NUMBER)
235 IS
236 
237 
238 --This cursor extracts the user key from the upload table
239   CURSOR csr_user_key IS
240   SELECT VALUE
241     FROM hr_du_descriptors
242     WHERE upper(DESCRIPTOR) = 'USER KEY'
243     AND UPLOAD_HEADER_ID = p_upload_header_id;
244 
245   e_fatal_error EXCEPTION;
246   l_fatal_error_message	VARCHAR2(2000);
247   l_user_key	 	VARCHAR2(2000);
248   l_file_name		VARCHAR2(2000);
249 
250 
251 BEGIN
252 --
253   hr_du_utility.message('ROUT','entry:hr_du_rules.validate_user_key_setup', 5);
254   hr_du_utility.message('PARA', '(p_upload_header_id - ' || p_upload_header_id || ')' , 10);
255 --
256 
257   OPEN csr_user_key;
258     FETCH csr_user_key INTO l_user_key;
259     IF csr_user_key%NOTFOUND THEN
260     --
261       INSERT INTO HR_DU_DESCRIPTORS(
262            DESCRIPTOR_ID, UPLOAD_ID, UPLOAD_HEADER_ID,
263   	   DESCRIPTOR, VALUE, DESCRIPTOR_TYPE, LAST_UPDATE_DATE,
264 	   LAST_UPDATED_BY, LAST_UPDATE_LOGIN, CREATED_BY,
265 	   CREATION_DATE)
266       VALUES(
267           HR_DU_DESCRIPTORS_S.nextval,
268           p_upload_id,
269           p_upload_header_id,
270           'USER KEY',
271           '%NONE%',
272           'D',
273           sysdate,
274           1,
275           1,
276           1,
277           sysdate);
278       COMMIT;
279     --
280     ELSE
281       PERFORM_USER_KEY_CHECKS(l_user_key, p_upload_header_id);
282     END IF;
283   CLOSE csr_user_key;
284 
285 --
286   hr_du_utility.message('ROUT','exit:hr_du_rules.validate_user_key_setup', 15);
287 --
288 
289 EXCEPTION
290   WHEN e_fatal_error THEN
291     hr_du_utility.error(SQLCODE, 'hr_du_rules.validate_user_key_setup',
292     l_fatal_error_message, 'R');
293     RAISE;
294   WHEN OTHERS THEN
295     hr_du_utility.error(SQLCODE, 'hr_du_rules.validate_user_key_setup',
296                        '(none)', 'R');
297     RAISE;
298 --
299 END VALIDATE_USER_KEY_SETUP;
300 
301 
302 -- ------------------------ PERFORM_USER_KEY_CHECKS -----------------------
303 -- Description: Holds all the checks that are run on the user key to make
304 -- sure its valid. The main points are no user keys, user keys pointing
305 -- to descriptors, and text and normal column headings
306 --
307 --  Input Parameters
308 --
309 --	p_user_key         - Actual string stored in the flat file
310 --
311 --	p_upload_header_id - Identifies the correct upload_header the
312 --                           user_key is associated with so that the
313 --			     appropriate area of the column_mappings
314 --			     is checked.
315 -- ------------------------------------------------------------------------
316 PROCEDURE PERFORM_USER_KEY_CHECKS(p_user_key IN VARCHAR2,
317                                   p_upload_header_id IN NUMBER)
318 IS
319 
320  e_fatal_error 	EXCEPTION;
321   l_fatal_error_message	VARCHAR2(2000);
322   l_number_keys 	NUMBER;
323   l_pval_value		VARCHAR2(2000);
324   l_position		NUMBER;
325   l_temp		VARCHAR2(2000);
326 
327 --Cursor compares the user key word to HR_DU_COLUMN_MAPPINGS
328 --in the main header for all API's
329   CURSOR csr_dollar_key IS
330   SELECT des.VALUE
331   FROM 	 hr_du_descriptors     des,
332          hr_du_upload_headers  head
333   WHERE  head.upload_header_id = p_upload_header_id
334     AND  head.upload_id = des.upload_id
335     AND  des.upload_header_id IS NULL
336     AND  upper(des.descriptor) = upper(l_pval_value);
337 
338 --Cursor compares the user key word to HR_DU_COLUMN_MAPPINGS
339 --in the specific API header
340   CURSOR csr_dollar_key_api IS
341   SELECT VALUE
342   FROM 	 hr_du_descriptors
343   WHERE  upload_header_id = p_upload_header_id
344     AND  upper(descriptor) = upper(l_pval_value);
345 
346 
347 --Cursor compares the user key word to HR_DU_COLUMN_MAPPINGS
348   CURSOR csr_user_key IS
349   SELECT column_name
350   FROM hr_du_column_mappings  col,
351        hr_du_upload_headers   head
352   WHERE upper(col.column_name) = upper(l_pval_value)
353     AND head.upload_header_id = p_upload_header_id
354     AND head.api_module_id = col.api_module_id;
355 
356 BEGIN
357 --
358   hr_du_utility.message('ROUT','entry:hr_du_rules.perform_user_key_checks', 5);
359   hr_du_utility.message('PARA', '(p_user_key  - ' || p_user_key ||
360  		         ')(p_upload_header_id - ' || p_upload_header_id || ')'
361                               , 10);
362 
363 --
364   IF upper(p_user_key) <> 'NONE' THEN
365   --
366     hr_du_di_insert.g_current_delimiter   := ':';
367     hr_du_di_insert.g_delimiter_count := hr_du_di_insert.Num_Delimiters(p_user_key);
368     l_number_keys := hr_du_di_insert.WORDS_ON_LINE(p_user_key);
369 
370     FOR j IN 1..l_number_keys LOOP
371     --
372       hr_du_di_insert.g_current_delimiter   := ':';
373       l_pval_value := hr_du_di_insert.Return_Word(p_user_key, j);
374 
375       l_position := INSTRB(l_pval_value, '%');
376 
377       IF l_position = 0 THEN
378         --Not quoted string so it's will be treated as a column heading
379         --checks this against the HR_DU_COLUMN_MAPPINGS
380         OPEN csr_user_key;
381           FETCH csr_user_key INTO l_temp;
382           IF csr_user_key%NOTFOUND THEN
383             l_fatal_error_message := 'Column on user key does not exist in '||
384                                      'HR_DU_COLUMN_MAPPINGS';
385             RAISE e_fatal_error;
386           END IF;
387         CLOSE csr_user_key;
388       --
389       ELSIF l_position > 1 THEN
390         --Error the first quote should be at position one
391         l_fatal_error_message := 'First Quote on the User Key is in the wrong position';
392         RAISE e_fatal_error;
393       ELSE
394         --check is made to find the closing quote
395         l_position := INSTRB(l_pval_value, '%', (l_position + 1));
396         IF l_position = 0 THEN
397           --Error the second quote should be present
398           l_fatal_error_message := 'End Quote on the User Key is not present ';
399           RAISE e_fatal_error;
400         ELSE
401           hr_du_di_insert.g_current_delimiter   := '%';
402           hr_du_di_insert.g_delimiter_count := hr_du_di_insert.Num_Delimiters(p_user_key);
403           l_pval_value := hr_du_di_insert.Return_Word(l_pval_value, 2);
404 
405           --Checks begin to see if there are any pointers to DESCRIPTORS
406           l_position := INSTRB(l_pval_value, '$');
407           --
408           IF l_position = 1 THEN
409           --
410             hr_du_di_insert.g_current_delimiter   := '$';
411             hr_du_di_insert.g_delimiter_count := hr_du_di_insert.Num_Delimiters(p_user_key);
412             l_pval_value := hr_du_di_insert.Return_Word(l_pval_value, 2);
413             OPEN csr_dollar_key;
414               FETCH csr_dollar_key INTO l_temp;
415               IF csr_dollar_key%NOTFOUND THEN
416               --
417                 --this checks the specific headers for the API
418                 OPEN csr_dollar_key_api;
419                   FETCH csr_dollar_key_api INTO l_temp;
420                   IF csr_dollar_key_api%NOTFOUND THEN
421                     l_fatal_error_message := 'User key $ is not a valid descriptor';
422                     RAISE e_fatal_error;
423                   END IF;
424                 CLOSE csr_dollar_key_api;
425               END IF;
426             --
427             CLOSE csr_dollar_key;
428           --
429           END IF;
430         END IF;
431       END IF;
432     --
433     END LOOP;
434   --
435   END IF;
436 
437 --
438   hr_du_utility.message('ROUT','exit:hr_du_rules.perform_user_key_checks', 15);
439 --
440 
441 EXCEPTION
442   WHEN e_fatal_error THEN
443     hr_du_utility.error(SQLCODE, 'hr_du_rules.perform_user_key_checks',
444     l_fatal_error_message, 'R');
445     RAISE;
446   WHEN OTHERS THEN
447     hr_du_utility.error(SQLCODE, 'hr_du_rules.perform_user_key_checks',
448                        '(none)', 'R');
449     RAISE;
450 --
451 END PERFORM_USER_KEY_CHECKS;
452 --
453 
454 
455 -- ------------------------ VALIDATE_STARTING_POINT ----------------------
456 -- Description: Holds all the checks that are run on the referencing type
457 -- to make ensure their validity.
458 --
459 --  Input Parameters
460 --	p_upload_header_id    -
461 --
462 --	p_upload_id    -
463 -- ------------------------------------------------------------------------
464 PROCEDURE VALIDATE_STARTING_POINT(p_upload_header_id IN NUMBER,
465 				  p_upload_id IN NUMBER)
466 IS
467 
468 --This cursor extracts the starting point from the descriptors if its
469 --present
470   CURSOR csr_starting_point IS
471   SELECT VALUE
472     FROM hr_du_descriptors
473     WHERE upper(DESCRIPTOR) = 'STARTING POINT'
474     AND UPLOAD_header_ID = p_upload_header_id;
475 
476 
477 --exception to raise
478   e_fatal_error EXCEPTION;
479 --string to input the error message
480   l_fatal_error_message		VARCHAR2(2000);
481   l_starting_point		VARCHAR(2000);
482   l_file_name			VARCHAR2(2000);
483 
484 BEGIN
485 --
486 hr_du_utility.message('ROUT','entry:hr_du_rules.validate_starting_point', 5);
487 hr_du_utility.message('PARA', '(p_upload_header_id  - ' ||
488                       p_upload_header_id || ')', 10);
489 --
490   OPEN csr_starting_point;
491   FETCH csr_starting_point INTO l_starting_point;
492   IF csr_starting_point%NOTFOUND THEN
493   --
494     INSERT INTO HR_DU_DESCRIPTORS(
495            DESCRIPTOR_ID, UPLOAD_ID, UPLOAD_HEADER_ID,
496   	   DESCRIPTOR, VALUE, DESCRIPTOR_TYPE, LAST_UPDATE_DATE,
497 	   LAST_UPDATED_BY, LAST_UPDATE_LOGIN, CREATED_BY,
498 	   CREATION_DATE)
499         VALUES(
500           HR_DU_DESCRIPTORS_S.nextval,
501           p_upload_id,
502           p_upload_header_id,
503           'STARTING POINT',
504           'NO',
505           'D',
506           sysdate,
507           1,
508           1,
509           1,
510           sysdate);
511     COMMIT;
512   --
513   ELSIF (upper(l_starting_point) <> 'YES') AND (upper(l_starting_point) <> 'NO') THEN
514     l_file_name := RETURN_UPLOAD_HEADER_FILE(p_upload_header_id);
515     l_fatal_error_message := 'The Starting Point Value is not ' ||
516 			'YES or NO in the file ' || l_file_name;
517     RAISE e_fatal_error;
518   END IF;
519   CLOSE csr_starting_point;
520 
521 --
522 hr_du_utility.message('ROUT','exit:hr_du_rules.validate_starting_point', 15);
523 hr_du_utility.message('PARA','(none)', 30);
524 --
525 
526 EXCEPTION
527   WHEN e_fatal_error THEN
528     hr_du_utility.error(SQLCODE, 'hr_du_rules.validate_starting_point',
529     l_fatal_error_message, 'R');
530     RAISE;
531   WHEN OTHERS THEN
532     hr_du_utility.error(SQLCODE, 'hr_du_rules.validate_starting_point',
533                        '(none)', 'R');
534     RAISE;
535 --
536 END VALIDATE_STARTING_POINT;
537 --
538 
539 
540 
541 
542 -- ------------------------ VALIDATE_REFERENCING -----------------------
543 -- Description: Holds all the checks that are run on the referencing type
544 -- to make ensure their validity.
545 --
546 --  Input Parameters
547 --	p_upload_header_id    -
548 -- ------------------------------------------------------------------------
549 FUNCTION VALIDATE_REFERENCING(p_upload_header_id IN NUMBER,
550 				  p_upload_id IN NUMBER)
551 				  RETURN VARCHAR2
552 IS
553 
554 --This cursor extracts the Referencing value from the descriptors if its
555 --present
556   CURSOR csr_referencing IS
557   SELECT VALUE
558     FROM hr_du_descriptors
559     WHERE upper(DESCRIPTOR) = 'REFERENCING'
560     AND UPLOAD_header_ID = p_upload_header_id;
561 
562 --exception to raise
563   e_fatal_error EXCEPTION;
564 --string to input the error message
565   l_fatal_error_message		VARCHAR2(2000);
566   l_referencing			VARCHAR(2000);
567   l_file_name			VARCHAR2(2000);
568 
569 BEGIN
570 --
571 hr_du_utility.message('ROUT','entry:hr_du_rules.validate_referencing', 5);
572 hr_du_utility.message('PARA', '(p_upload_header_id  - ' ||
573                       p_upload_header_id || ')', 10);
574 --
575 
576   OPEN csr_referencing;
577   FETCH csr_referencing INTO l_referencing;
578   IF csr_referencing%NOTFOUND THEN
579   --
580     INSERT INTO HR_DU_DESCRIPTORS(
581            DESCRIPTOR_ID, UPLOAD_ID, UPLOAD_HEADER_ID,
582   	   DESCRIPTOR, VALUE, DESCRIPTOR_TYPE, LAST_UPDATE_DATE,
583 	   LAST_UPDATED_BY, LAST_UPDATE_LOGIN, CREATED_BY,
584 	   CREATION_DATE)
585         VALUES(
586           HR_DU_DESCRIPTORS_S.nextval,
587           p_upload_id,
588           p_upload_header_id,
589           'REFERENCING',
590           'CP',
591           'D',
592           sysdate,
593           1,
594           1,
595           1,
596           sysdate);
597     COMMIT;
598     l_referencing := 'CP';
599   --
600   ELSIF (upper(l_referencing) <> 'PC') AND (upper(l_referencing) <> 'CP') THEN
601     l_file_name := RETURN_UPLOAD_HEADER_FILE(p_upload_header_id);
602     l_fatal_error_message := 'The Referencing Descriptor is not ' ||
603 			'PC or CP in the file ' || l_file_name;
604     RAISE e_fatal_error;
605   END IF;
606   CLOSE csr_referencing;
607 
608 --
609 hr_du_utility.message('ROUT','exit:hr_du_rules.validate_referencing', 15);
610 hr_du_utility.message('PARA','(none)', 30);
611 --
612 
613   RETURN l_referencing;
614 
615 EXCEPTION
616   WHEN e_fatal_error THEN
617     hr_du_utility.error(SQLCODE, 'hr_du_rules.validate_referencing',
618     l_fatal_error_message, 'R');
619     RAISE;
620   WHEN OTHERS THEN
621     hr_du_utility.error(SQLCODE, 'hr_du_rules.validate_referencing',
622                        '(none)', 'R');
623     RAISE;
624 --
625 END VALIDATE_REFERENCING;
626 --
627 
628 
629 
630 -- ------------------------ VALIDATE_BUSINESS_GROUP -----------------------
631 -- Description: Holds all the checks that are run on the business group
632 -- names to make ensure their validity.
633 --
634 --  Input Parameters
635 --
636 --	p_business_group_profile - value read from profile
637 --
638 --	p_business_group_file    - value read from file
639 -- ------------------------------------------------------------------------
640 PROCEDURE VALIDATE_BUSINESS_GROUP(p_business_group_profile IN VARCHAR2,
641                                   p_business_group_file IN VARCHAR2)
642 IS
643 
644 --exception to raise
645   e_fatal_error EXCEPTION;
646 --string to input the error message
647   l_fatal_error_message		VARCHAR2(2000);
648 
649 BEGIN
650 --
651 hr_du_utility.message('ROUT','entry:hr_du_rules.validate_business_group', 5);
652 hr_du_utility.message('PARA', '(p_business_group_profile  - ' ||
653                       p_business_group_profile ||
654  	              ')(p_business_group_file - ' || p_business_group_file
655                       || ')', 10);
656 --
657 
658 IF p_business_group_profile IS NULL THEN
659   l_fatal_error_message := 'Error the HR:BUSINESS GROUP profile option ' ||
660                            'has not been set';
661   RAISE e_fatal_error;
662 END IF;
663 
664 IF p_business_group_profile <>
665                      NVL(p_business_group_file, 'HRDU null value')
666   AND p_business_group_file is not null THEN
667   l_fatal_error_message := 'Error the BUSINESS GROUP value supplied in ' ||
668                            'the file does not match the value read from' ||
669                            ' the HR:BUSINESS GROUP profile option.';
670   RAISE e_fatal_error;
671 END IF;
672 
673 
674 --
675 hr_du_utility.message('INFO','Business group names validated', 15);
676 hr_du_utility.message('SUMM','Business group names validated', 20);
677 hr_du_utility.message('ROUT','exit:hr_du_rules.validate_business_group', 15);
678 hr_du_utility.message('PARA','(none)', 30);
679 --
680 
681 EXCEPTION
682   WHEN e_fatal_error THEN
683     hr_du_utility.error(SQLCODE, 'hr_du_rules.validate_business_group',
684     l_fatal_error_message, 'R');
685     RAISE;
686   WHEN OTHERS THEN
687     hr_du_utility.error(SQLCODE, 'hr_du_rules.validate_business_group',
688                        '(none)', 'R');
689     RAISE;
690 --
691 END VALIDATE_BUSINESS_GROUP;
692 --
693 
694 
695 
696 END HR_DU_RULES;