COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-29
CALL
°
Each program opens the file as an internal file with a separate file connector.
°
The file name has the GLOBAL attribute.
°
The file is declared in any program and is given the EXTERNAL attribute. Then
the file belongs to the run unit, and any program in the run unit that declares
the same file with the EXTERNAL attribute can share in its manipulation.
Difference Between X/Open CALL Statement and ENTER Statement
The X/Open CALL statement reports an error if the types of the actual and formal
parameters do not match; the ENTER statement attempts to convert the actual
parameters into the types of the formal parameters.
Example 9-8. Called Program That Calls Another Program (page 1 of 3)
Main Program (source $DATA.MYSUBVOL.MAINSRC, object
$DATA.MYSUBVOL.MAINOBJ)
IDENTIFICATION DIVISION.
PROGRAM-ID. COBOLMAIN.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. HP System.
OBJECT-COMPUTER. HP System.
SPECIAL-NAMES.
FILE "$DATA.MYSUBVOL.SUB1OBJ" IS SUB1.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 DATA-OUT PIC X(80) VALUE "I'M THE MAIN AND I'M ALIVE".
77 PARM1 PIC 99 VALUE 10.
77 PARM2 PIC XX VALUE "AB".
01 MAIN-TABLE.
05 TABLE-DATA PIC X
OCCURS 10 TIMES
INDEXED BY TABLE-INDEX.
01 SAVE-TABLE-INDEX PIC 999.
PROCEDURE DIVISION.
START-PROGRAM.
DISPLAY DATA-OUT
SET TABLE-INDEX TO 5
SET SAVE-TABLE-INDEX TO TABLE-INDEX
DISPLAY "SAVE-TABLE-INDEX = " SAVE-TABLE-INDEX
CALL COBSUB1 OF SUB1 USING PARM1
PARM2
MAIN-TABLE
SAVE-TABLE-INDEX
END-CALL
DISPLAY "PROGRAM END"
STOP RUN.