Comparing Local and Global Data

The concept of local and global data applies only to nested programs.

Local data is accessible only from within the program in which the local data is declared. Local data is not visible or accessible to any program outside of the one where it is declared; this includes both contained and containing programs.

All data is considered to be local data unless it is explicitly declared as being global data.

Global data is accessible from within the program in which the global data is declared or from within any other nested programs which are directly or indirectly contained in the program that declared the global data.

Data-names, file-names and record-names can be declared as global.

To declare a data-name as global, specify the GLOBAL clause either in the data description entry by which the data-name is declared or in another entry to which that data description entry is subordinate.

To declare a file-name as global, specify the GLOBAL clause in the file description entry for that file-name.

To declare a record-name as global, specify the GLOBAL clause in the record description entry by which the record-name is declared or, in the case of record description entries in the File Section, specify the GLOBAL clause in the file description entry for the file-name associated with the record description entry.

For a detailed description of the GLOBAL clause, refer to the IBM® Rational® Development Studio for i: ILE COBOL Reference.