GLOBAL clause

The GLOBAL clause specifies that a data-name is available to every program contained within the program that defines it, as long as the contained program does not itself have a definition for that name. All data-names subordinate to or condition-names or indexes associated with a global name are global names.

A data-name is global if the GLOBAL clause is specified either in the data description entry by which the data-name is defined or in another entry to which that data description entry is subordinate. The GLOBAL clause can be specified in the WORKING-STORAGE SECTION, the FILE SECTION, the LINKAGE SECTION, and the LOCAL-STORAGE SECTION, but only in data description entries whose level-number is 01.

In the same DATA DIVISION, the data description entries for any two data items for which the same data-name is specified must not include the GLOBAL clause.

A statement in a program contained directly or indirectly within a program that describes a global name can reference that name without describing it again.

Two programs in a run unit can reference common data in the following circumstances:

  • The data content of an external data record can be referenced from any program that describes the data record as external.
  • If a program is contained within another program, both programs can refer to data that possesses the global attribute either in the containing program or in any program that directly or indirectly contains the containing program.