COBOL Manual for TNS and TNS/R Programs
Source Program Organization and Format
HP COBOL Manual for TNS and TNS/R Programs—522555-006
2-20
Shared Data
* Storage 1. W of Bbb, w of Ccc, and w of Sub all refer to one location
* Allocation
* 2. Z of Mane and z of Sub each refer to one location.
*
* 3. All other identifiers refer to unique locations.
/
?main Mane
IDENTIFICATION DIVISION.
PROGRAM-ID. Mane.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 w PICTURE 99 VALUE 3.
01 y PICTURE 99 GLOBAL VALUE 1.
01 z picture 99 GLOBAL EXTERNAL.
PROCEDURE DIVISION.
m.
DISPLAY "Mane begin"
MOVE 25 to z
PERFORM show-me
CALL Aaa PERFORM show-me
CALL Bbb PERFORM show-me
CALL Sub PERFORM show-me
CALL Sub PERFORM show-me
DISPLAY "Mane end"
stop run
.
show-me.
DISPLAY "in Mane, w=/" w "/ y=/" y "/ z=/" z "/"
.
IDENTIFICATION DIVISION.
PROGRAM-ID. Aaa.
PROCEDURE DIVISION.
a.
DISPLAY " Aaa begin"
PERFORM show-me
DISPLAY " Aaa adding 2 to y"
ADD 2 TO y PERFORM show-me
CALL Bbb PERFORM show-me
DISPLAY " Aaa end"
EXIT PROGRAM
.
show-me.
DISPLAY " y (global from Mane)=/" y "/"
" z (global from Mane)=/" z "/"
.
END PROGRAM Aaa.
IDENTIFICATION DIVISION.
PROGRAM-ID. Bbb COMMON.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 x PICTURE 99 GLOBAL VALUE 0.
01 w PICTURE 99 EXTERNAL.
Example 2-2. Programs With Shared Data (page 2 of 4)