COBOL – Global, Initial, External,Common

Here’s is the real meaning and usage for Global, Initial, External, and Common in 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.

This can be used in all included programs. Only at 01 level, FD, RD entries. In the included programs, we can use similar data name without Global, means that is local to that program.

EXTERNAL

01 Data-2   PIC 9(5) is External

It is similar to Global. You can not give value clause. Not to mention in REDEFINES.

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.

You can read more information online here on GLOBAL, External and Initial parameters of COBOL.

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.

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.