Subprograms: CALL and USING
| CALL and USING | |
| The LINKAGE SECTION | |
| CANCEL |
CALL and USING
CALL runs another compiled program. USING passes data items by reference by default, so the called program sees the caller's storage, not a copy:
CALL "PAYCALC" USING WS-HOURS WS-RATE WS-PAY.
The LINKAGE SECTION
The called program declares its parameters in the LINKAGE SECTION of DATA DIVISION. No VALUE clause and no storage is allocated here: the caller owns the memory:
DATA DIVISION.
LINKAGE SECTION.
01 LS-HOURS PIC 9(3)V99.
01 LS-PAY PIC 9(7)V99.
CANCEL
CANCEL unloads a subprogram so the next CALL reloads it fresh, which clears any state it kept in WORKING-STORAGE. GOBACK returns from a subprogram; STOP RUN ends the whole run unit.
Next: SQL with EXEC SQL
Article author: Arthur Isaev