TSO-ISPF JCL COBOL VSAM DB2 CICS Tools Articles Job Portal Forum Quiz Interview Q&A

COBOL - CALL Statement

A Program can call another program/s to perform a set of tasks. In this case, the program which calls other programs we call that as CALLING Program (sometimes, also called as Main Program) while the program which is called in called as CALLED program or Sub Program.

COBOL CALL Statement is used to call another program.

There are 2 types of calls –
  1. STATIC CALL
  2. DYNAMIC CALL

STATIC CALL:

In case of STATIC CALLS, if we have 2 programs MAIN-PROGRAM and SUB-PROGRAM then both the Programs are compiled as a separate PDS member but are link edited together at the same time. This is the reason, STATIC CALLS are faster compared to DYNAMIC CALLS.

  • If we modify the sub program SUB-PROGRAM, we need to compile SUB-PROGRAM and the Calling program MAIN-PROGRAM as well in order to link back to this newly compiled module.

  • STATIC CALLS occupy more storage but take less time for execution compared to DYNAMIC CALLS.

  • NODYNAM compiler option is used in case of STATIC CALLS. To check your compiler option, please check with your mainframe support/admin group.

  • If the called program is very small then we can go for a static call, otherwise, the dynamic call will be better because, in static calls, the CALLED program is embedded into CALLING program’s load module.

DYNAMIC CALL:

In case of DYNAMIC CALLS, if we have 2 programs MAIN-PROGRAM and SUB-PROGRAM then both Programs are compiled as a separate PDS member and link edited separately as well.
  • DYNAMIC CALLS occupy less storage as a compiled module is loaded into memory only when it is called but takes more time for execution compared to STATIC CALLS.

  • DYNAM compiler option is used for DYNAMIC CALLS.

  • Dynamically called programs are much easier to manage than static programs

The parameters(variables) can be passed between programs in two ways −
  1. By Reference
  2. By Content

Call By Reference - If the values of variables in the called program are modified, then their new values will reflect in the calling program. If BY clause is not specified, then variables are always passed by reference.

Following is the syntax of calling subroutine by reference −

CALL sub-prog-name USING variable-1, variable-2.....

Call By Content - If the values of variables in the called program are modified, then their new values will not reflect in the calling program.

Following is the syntax of calling subroutine by content −

CALL sub-prog-name USING BY CONTENT variable-1, BY CONTENT variable-2......

Now time to see some examples for CALL statement in next chapter..

If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal