Master Mainframe Technologies - COBOL, JCL, DB2, VSAM, CICS & More
ABEND Codes SQLCODEs File Status Interview Prep Contact
💻 COBOL

COBOL CALL Statement

Intermediate 🕑 10 min read 👁 0 views

15

Code Example


## COBOL CALL Statement

The CALL statement transfers control to another program (subprogram), passing data via parameters.

### Syntax

\`\`\`cobol
CALL 'program-name'/identifier
    [USING [BY REFERENCE/CONTENT/VALUE] parameter-1...]
    [ON EXCEPTION imperative-statement]
    [NOT ON EXCEPTION imperative-statement]
[END-CALL]
\`\`\`

### Parameter Passing Methods

1. **BY REFERENCE** (default): Passes address; changes affect calling program
2. **BY CONTENT**: Passes copy; changes don't affect calling program
3. **BY VALUE**: Passes actual value; for C-compatible interfaces

### Subprogram Structure

\`\`\`cobol
PROCEDURE DIVISION USING parameter-1 parameter-2...
\`\`\`

### Static vs Dynamic Calls

- **Static**: Program name as literal, linked at compile
- **Dynamic**: Program name in variable, loaded at runtime

### RETURN-CODE

Special register containing value set by called program via RETURN-CODE or MOVE to RETURN-CODE.

### GOBACK vs STOP RUN

- **GOBACK**: Return to calling program
- **STOP RUN**: Terminate entire run unit