ILE COBOL Programmer's Guide

Returning Control from an ILE RPG Program or Procedure

When returning from an ILE RPG main procedure, the RETURN operation code causes control to be returned to the caller. If, prior to executing the RETURN operation code, the SETON operation code is used to set the LR indicator, the called ILE RPG program is reset to its initial state upon return to the caller. Otherwise, the called ILE RPG program is left in its last used state.

When returning from an ILE RPG subprocedure, the RETURN operation code causes control to be returned to the caller. If the procedure returns a value, the returned value is specified in the extended factor 2 of the RETURN operation. If the subprocedure returns a value, the COBOL CALL statement should have a RETURNING phrase.

Note:
The LR indicator has no meaning when returning from a subprocedure.

Control is returned to your ILE COBOL program at the next statement after the CALL statement if the called program ends without an exception. If the called program ends with an exception then control is returned to the exception handling procedure identified in your ILE COBOL program. Refer to ILE COBOL Error and Exception Handling for a full description of transferring control to an exception handling procedure.

The called program can also send an escape message past the calling ILE COBOL program skipping it altogether. In this case, the invocation of the ILE COBOL program is canceled. Canceling the invocation is similar to returning from the ILE COBOL program.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]