CICS CALLCICS Program execution from another program CICS Link Statement
CALL command is very similar to the call of other programs in Cobol.
If the CALL is used to call the subprogram, then the load module will be attached to the calling module.
For the programs used in CALL statement doesn’t require any PPT entries.
If the subprogram modified, then the calling program required to be recompile hence CALL will use the static calling of the sub programs.
Static calling was not allowed in CICS environments.
When a particular task needs to be performed in more than one program, it is better to write a subprogram.
The need of CALL statement is to call the subprogram to perform the task.
CALL statement transfers the control from one object program to another object to complete a particular task.
The program which had a CALL statement in it called as CALLING program/Main program.
The program name in CALL statement called as CALLED program/Sub program.
A program can contain as many CALLs required and no restriction on it. In other words, CALLING program can CALL as many subprograms required.
CALLED may not have the CALL statement to call another program.
The CALL statement creates a tree structure if programs create a chain of CALLs and control will always return to the CALLING program.
Let’s discuss how the CALL in Main program and sub program.
Main program / CALLING program which had the CALL statement.
In CICS environment, the calling of the program would be always in dynamic mode.
Dynamic call can be decided based on the syntax of the CALL statement.
In the above syntax, WS-PGM-NAME is the working storage field name and the called module name should to pass to the above working-storage field before CALL.
Compiler Option for Dynamic call is DYNAM.
Calling Program (main program) and Called program (sub program) loads are available separately.
It occupies less memory while loading to main memory hence the size of load module is small.
Processing will be a bit slow because main program calling Subprogram then main program will be replaced with subprogram in the memory and once sub program completes execution again main program will be loaded. Loading and unloading will decrease speed of execution.
If sub program modified, no need to recompile the main program again.
Sub Program (CALLED program):
Sub program/ CALLED program which name had associated with CALL statement.
As we discussed earlier LINKAGE SECTION uses to receive the external data.
Sub program uses the LINKAGE SECTION to declare variables in Sub program to receive the data form main program.
The name of the variable in sub program need not be the same as main program.
Once the variables declared in LINKAGE SECTION, the same can be coded in PROCEDURE DIVISION USAGE Clause.
The order of the parameters should be same as the main program CALL.
Sub program should not be coded with STOP RUN which will not return the control to main program.
Sub program can be coded with EXIT PROGRAM or GOBACK to return the control to the main program once the sub program execution completed.
If any questions on the above, post your queries on CICS Discussion forum
CICS Program execution from another program CICS Link Statement