Using the Fixed-Form Call Operations
- Identify the object to be called in the Factor 2 entry.
- Optionally code an error indicator (positions 73 and 74) or an
LR indicator (positions 75 and 76) or both.
When a called object ends in error the error indicator, if specified, is set on. Similarly, if the called object returns with LR on, the LR indicator, if specified, is set on.
- To pass parameters to the called object, either specify a PLIST in the Result field of the call operation or follow the call operation immediately by PARM operations.
Either operation transfers control from the calling to the called object. After the called object is run, control returns to the first operation that can be processed after the call operation in the calling program or procedure.
- The Factor 2 entry can be a variable, literal, or named constant.
Note that the entry is case-sensitive.
For CALL only: The Factor 2 entry can be library name⁄program name, for example, MYLIB/PGM1. If no library name is specified, then the library list is used to find the program. The name of the called program can be provided at run time by specifying a character variable in the Factor 2 entry.
For CALLB only: To make a procedure pointer call you specify the name of the procedure pointer which contains the address of the procedure to be called.
- A procedure can contain multiple calls to the same object with the same or different PLISTs specified.
- When an ILE RPG procedure (including a program entry procedure) is first called, the fields are initialized and the procedure is given control. On subsequent calls to the same procedure, if it did not end on the previous call, then all fields, indicators, and files in the called procedure are the same as they were when it returned on the preceding call.
- The system records the names of all programs called within an
RPG procedure. When an RPG procedure is bound into a program (*PGM)
you can query these names using DSPPGMREF, although you cannot tell
which procedure or module is doing the call.
If you call a program using a variable, you will see an entry with the name *VARIABLE (and no library name).
For a module, you can query the names of procedures called using DSPMOD DETAIL(*IMPORT). Some procedures on this list will be system procedures; the names of these will usually begin with underscores or contain blanks and you do not have to be concerned with these.
- For CALLB
only: The compiler creates an operational descriptor indicating
the number of parameters passed on the CALLB operation and places
this value in the *PARMS field of the called procedure's program status
data structure. This number includes any parameters which are designated
as omitted (*OMIT on the PARM operation).
If the (D) operation extender is used with the CALLB operation the compiler also creates an operational descriptor for each character and graphic field and subfield.
For more information on operational descriptors, see Using Operational Descriptors.
- There are further restrictions that apply when using the CALL or CALLB operation codes. For a detailed description of these restrictions, see the IBM® Rational® Development Studio for i: ILE RPG Reference.