Here’s the real meaning and usage for Global, Initial, External, and Common COBOL programs. Here, I’ve also covered how to use EXTERNAL working-storage variables.
GLOBAL
01 Data-1 PIC 9(5) is Global value zero.
You can use it in all included programs. Only at 01 Level, FD, RD entries. In included programs, you can use a similar data name without Global, which means it is local to that program.
INITIAL & COMMON
PROGRAM-ID. PROGRAM-NAME IS COMMON PROGRAM
INITIAL
Common program can be called by all programs. But initial programs can be called only from the program that contains it. (INITIAL program when it calls all the Special registers will be initialized.)
Here is more information online here on GLOBAL, External and Initial parameters.
EXTERNAL Variable
In the run unit, any COBOL program or method that has the same data description for the item as the program that contains the item can access and process that item. For example, suppose program A has the following data description:
01 EXT-ITEM1 EXTERNAL PIC 99.
Program B can access that data item if it has the identical data description in its WORKING-STORAGE SECTION.
That means in B program, you need to define the same variable.
Any program that has access to an EXTERNAL data item can change the value of that item. Therefore do not use this clause for data items that you need to protect.
It is similar to Global. You can not give value clause. Not to mention in REDEFINES.
Related Posts