![]() |
VOOZH | about |
Subroutines in COBOL are small programs that are compiled independently but cannot be run directly. Cobol subroutine is a small program that can be compiled independently but cannot be run directly. There are two types of COBOL subroutines- internal subroutines and the external subroutines
Call verb is used especially for transferring the controlling from one program to running another program on it. The program that is sourcing the CALL verb is the directly Calling Program and the program being specially called is called as the Called Program.
Calling program execution will halt until the controlling called program, thus it finishes the execution. Exit Program statement so, working in the Called program for transferring the controlling to back
Call By Reference: If the values of variables mentioned in the called program are modified, then their new values will reflect in the controlling calling program. If the BY clause is not mentioned, then more variables are always passing by reference from within it.
Syntax:
CALL sub-prog-name USING variable-1, variable-2
Call By Content: In call by content, if more values of variables directly in the subprogram(calling program) are controlling mentioned then their new values added will not be reflected in the main calling program(called program).
Syntax:
CALL sub-prog-name USING
BY CONTENT variables-1, BY CONTENT variables-2
Static call: Static call arises controlling mentioned when the compiler compiles a program with NODYNAM option In the static call, all the modules are available in the controlling main memory. Hence, the processing becomes fast and it does not require additional timing to load it. Static call statement working mentioned the subprograms naming as literal, i.e in quotes
Dynamic call: Dynamic calls, are arising when the compiler compiles invoking a program with this DYNAM option. In the dynamic call, calling and added called programs within available loads are available separately. The size of the module is small because it requires controlling less memory while loading into the working main memory call processing is a little slower than static loading and unloading of main programs and subprograms in memory to decrease the speed of execution
Example 1:
Main file:
Subroutine:
Output:
Student Id : 2000 Student Name : Gfg