Microsoft KB Archive/43533

GLOBAL Clause Used in WORKING-STORAGE SECTION to Pass Data

PSS ID Number: Q43533 Article last modified on 04-20-1993

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

Summary: The GLOBAL clause in the WORKING-STORAGE SECTION can be used to pass data items between nested COBOL programs communicating through the CALL statement. The GLOBAL clause is an ANSI 85 standard. NESTCALL and ANS85 compiler directives are required to use the GLOBAL clause. To make a data item GLOBAL, the GLOBAL clause needs to be included for the data item in the “driver” program. The CALLed nested programs do not need to reference the data item in the WORKING-STORAGE SECTION. The syntax of the GLOBAL clause is on Page 10-26 of the “Microsoft COBOL Compiler Version 3.0: Language Reference Manual.” If a data item is GLOBAL, it does not need to be included in the LINKAGE SECTION, and it is not passed as a parameter in the CALL USING statement. The GLOBAL clause cannot be used to communicate between CHAINED programs or between two programs that are CALLed externally.

More Information: The following programs demonstrate the GLOBAL clause. DRIVER CALLs SUB1, which has the data item PASSED-VAR in common through the GLOBAL clause. The compile and link steps are as follows: COBOL DRIVER.CBL ; LINK DRIVER.OBJ; $SET NESTCALL ANS85 IDENTIFICATION DIVISION. PROGRAM-ID. DRIVER. DATA DIVISION. WORKING-STORAGE SECTION. 01 PASSED-VAR GLOBAL PIC X(30). PROCEDURE DIVISION. MOVE “DATA NAME WAS PASSED” TO PASSED-VAR. CALL “SUB1”. STOP RUN. * THIS IS THE NESTED PROGRAM IDENTIFICATION DIVISION. PROGRAM-ID. SUB1. ENVIRONMENT DIVISION. WORKING-STORAGE SECTION. PROCEDURE DIVISION. DISPLAY PASSED-VAR. END PROGRAM SUB1. END PROGRAM DRIVER.

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.