Menu
CoddyTech

CALL

Part of the Programs That Work Together section of Coddy's COBOL Programming journey. Lesson 3 of 16.

A large job is split into subprograms: separate programs that do one piece of work each. CALL runs one by its PROGRAM-ID, then carries on with the next statement:

CALL "BANNER"
DISPLAY "Batch started"

A subprogram ends with GOBACK, which returns to the program that called it:

PROGRAM-ID. BANNER.
PROCEDURE DIVISION.
    DISPLAY "*** COBOL BANK ***"
    GOBACK.

STOP RUN in a subprogram ends the whole run: the caller never gets its turn back. A subprogram returns with GOBACK.

Here each subprogram is its own file, such as BANNER.cob, compiled and linked with the main program. On a mainframe it is a load module in a library. Many programs can call the same subprogram, so one routine serves the whole shop.

challenge icon

Challenge

Easy

The subprogram in BANNER.cob prints the bank's banner. Call it at the start of the program, so the output begins with *** COBOL BANK ***

Try it yourself

       IDENTIFICATION DIVISION.
       PROGRAM-ID. BATCH.
       PROCEDURE DIVISION.
           *> Call BANNER here
           DISPLAY "Batch started"
           DISPLAY "Batch done"
           STOP RUN.

All lessons in Programs That Work Together