Skip to main content
Module 6 · Lesson 2 of 212/16 in the course~16 min
Module lessons (2/2)

Subprograms: CALL, LINKAGE SECTION and GOBACK

Lesson preview5 hands-on exercises readyCourse COBOL · Module 6 — Strings, INSPECT and Subroutines

Invoke static or dynamic external modules with BY REFERENCE vs BY CONTENT, map parameters to LINKAGE SECTION and distinguish GOBACK from STOP RUN.

What you'll learn in this lesson

  • Invoke external COBOL programs via CALL by consciously choosing between BY REFERENCE (mutable) and BY CONTENT (read-only) step.
  • Receive and return parameters in the called program by configuring LINKAGE SECTION and PROCEDURE DIVISION USING.
  • Avoid premature termination of the entire batch job by distinguishing GOBACK. / EXIT PROGRAM. (return to caller) from STOP RUN. (terminate process).

Overview

While PERFORM calls a paragraph in the same source file without formal parameters, CALL calls a separately compiled COBOL program passing it typed arguments.

The subprogram declares the parameters received inside the LINKAGE SECTION. (after WORKING-STORAGE) without allocating new physical memory (the address comes from the caller) and lists them in the header of PROCEDURE DIVISION USING:

Sections covered in this lesson

  1. 11. Calling side: CALL static vs dynamic
  2. 22. BY REFERENCE vs BY CONTENT vs BY VALUE
  3. 33. Called side: LINKAGE SECTION. and PROCEDURE DIVISION USING
  4. 44. GOBACK. / EXIT PROGRAM. vs STOP RUN.
  5. 5Try it yourself
Pro Lesson · Module 6 — Strings, INSPECT and Subroutines

Unlock "Subprograms: CALL, LINKAGE SECTION and GOBACK" and the full Course COBOL curriculum

Invoke static or dynamic external modules with BY REFERENCE vs BY CONTENT, map parameters to LINKAGE SECTION and distinguish GOBACK from STOP RUN.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Course COBOL plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.