The main program optionally passes parameters to the called parameter. If the called program changes any passed data, the storage area that is available to the caller is also changed. For more information about the difference between main and called programs, see “Program part.”
The called program is either generated by EGL or is considered to be externally defined. For details about how to indicate that the program is externally defined, see the description of the isExternal property in the “Syntax” section of this topic.
The number, type, and sequence of arguments that you pass in a call statement must correspond to the number, type, and sequence of parameters that the called program expects. There is no limit to the number of parameters you can pass on a local call. For remote calls, the number and size of parameters that can be passed are limited. All remote call implementations support passing at least 30 parameters with a combined parameter length of less than 32,000 bytes. If your design requires more than 30 parameters or passing more than 32,000 bytes per call, test with all the required implementations to verify that they support the amount of data you need to pass.
For additional details about using the call statement for service invocation, see “Coding a call statement and callback functions for service access.”
When you call a program that was migrated from VisualAge® Generator, remember that VisualAge Generator developers generally use fixed text variable types. You can control the type of character literals through the textLiteralDefaultIsString property or by specifying a type with the literal. For more information about the textLiteralDefaultIsString property, see textLiteralDefaultIsString; for information about literals, see Literals.

The relevant attribute in the callLink element is pgmType for local calls, or remotePgmType for remote or EJB calls.
This property has two values:
The following table shows the valid calls to or from EGL-generated code.
| Calling object | Called object |
|---|---|
| An EGL-generated Java wrapper in a Java class that is outside of J2EE | An EGL-generated Java program (non-J2EE) |
| An EGL-generated Java program in a J2EE application client | |
| An EGL-generated EJB session bean | |
| An IMS/VS program (generated by EGL or not) | |
| An IMS™ transaction | |
| A CICS program (generated by EGL or not) | |
| An EGL-generated Java wrapper in a J2EE application client | An EGL-generated Java program (non-J2EE) |
| An EGL-generated Java program in a J2EE application client | |
| An EGL-generated EJB session bean | |
| An IMS/VS program (generated by EGL or not) | |
| An IMS transaction | |
| A CICS program (generated by EGL or not) | |
| An EGL-generated Java wrapper in a J2EE web application | An EGL-generated Java program (non-J2EE) |
| An EGL-generated Java program in a J2EE application client | |
| An EGL-generated Java program in the same J2EE web application | |
| An EGL-generated EJB session bean | |
| An IMS/VS program (generated by EGL or not) | |
| An IMS transaction | |
| A CICS program (generated by EGL or not) | |
| An EGL-generated Java program that is outside of J2EE | An EGL Java program (non-J2EE) |
| An EGL Java program in a J2EE application client | |
| An EGL EJB session bean | |
| A Java program on IBM® i | |
| A COBOL program on IBM i | |
| A non-EGL program that was written in C or C++ | |
| An IMS/VS program (generated by EGL or not) | |
| An IMS transaction | |
| A CICS program (generated by EGL or not) | |
| An EGL Java program that is in a J2EE application client | An EGL Java program (non-J2EE) |
| An EGL Java program in a J2EE application client | |
| An EGL EJB session bean | |
| A Java program on IBM i | |
| A COBOL program on IBM i | |
| A non-EGL program that was written in C or C++ | |
| An IMS/VS program (generated by EGL or not) | |
| An IMS transaction | |
| A CICS program (generated by EGL or not) | |
| An EGL Java program in a J2EE web application | An EGL Java program (non-J2EE) |
| An EGL Java program in a J2EE application client | |
| An EGL Java program in the same J2EE web application | |
| A Java program on IBM i | |
| A COBOL program on IBM i | |
| A non-generated program written in C or C++ | |
| A CICS program (generated by EGL or not) | |
| An EGL EJB session bean | An EGL Java program (non-J2EE) |
| An EGL Java program in a J2EE application client | |
| An EGL EJB session bean | |
| A non-generated program written in C or C++ | |
| A CICS program (generated by EGL or not) | |
| An EGL CICS program | A CICS program (generated by EGL or not) |
| An EGL z/OS batch program | |
| An EGL z/OS batch program | A batch program written in any language (including EGL) and running on z/OS (outside of CICS or IMS) |
| A non-EGL CICS program | A CICS COBOL program (generated by EGL or not) |
| A batch program written in any language (including EGL) and running on z/OS (outside of CICS or IMS) | |
| An EGL COBOL program on IBM i | An EGL COBOL program on IBM i |
| A non-EGL program written in any language and running on IBM i | |
| A non-EGL program written in any language and running on IBM i | An EGL COBOL program on IBM i |
| A non-EGL program written in any language and running on IBM i |
To call EGL-generated Java code from non-EGL-generated Java code, use an EGL external type or a Java access function.
The following example shows a called program that calculates interest on a loan:
if (userRequest == "C")
try
call programA(myCustomer, interestRate);
onException(myEx InvocationException)
myErrorHandler(12);
end
end
The number of bytes that are passed in each argument must be the same as the number of bytes that are expected by the receiving parameter. For more information, see "Compatibility."
An exception in a remotely called program never propagates directly to the calling program. Instead, it is wrapped by an InvocationException. If the remotely called program does not handle an exception, the called program ends and the caller throws an InvocationException.
| Platform | Issue |
|---|---|
| Java generation |
|
| COBOL generation | Recursive program calls are permitted for the zSeries only. This support depends upon COBOL allowing the recursion. This is typically not a problem under CICS, but could be a problem in batch mode. Recursive calls must be enabled by setting the symbolic parameter ALLOWRECURSIVEPROGRAMS to YES. For more information, see Predefined symbolic parameters that can be set by the user. |
| CICS | If the number of bytes that are passed in each argument does not equal the number of bytes that are expected by a CICS program, a runtime abend occurs. |
| Rich UI | A version of the call statement is supported, but only to invoke services. For details, see “Coding a call statement and callback function for service access.” |