Calling a Sub-Program
The Main Module in a COBOL Application can reference another external sub-programthat has been separately compiled, by employing
Statement.Very often, different applications often require the same functionality. If there is a sub-routine that offers this functionality, it can be re-used, shared by many applications,instead of having to write it from scratch, from a fresh slate. Thus, you don’t have to re-invent the wheel.
Sub-modules act as re-usable software components.
A program containing the
Statement is called
. The sub-programbeing called is said to be the
. When you transfer control to a sub-program, there are 2 ways to do it :
At the beginning of the sub-program
At a particular point in the sub-programIn COBOL, the phenomenon of Recursion, where one COBOL Program calls itself, is notallowed. Moreover, circular calls are also not allowed(A calls B, B calls C, C calls A).
statement has the following syntax :
Given below is application, which consists of a Main Module
, which calls two sub-modules
Program – INDIA Program calling BRAZIL and CHINA