ILE COBOL Programmer's Guide

Returning Control from an ILE C Program or Procedure

The return keyword in ILE C causes control to be returned to the caller. If the ILE C return keyword returns something other than void, the ILE COBOL CALL statement must have a returning phrase. In addition, the data type and length of the item returned from ILE C must match the data type and length of the RETURNING phrase identifier of the COBOL call statement.

When return is issued from an ILE C program, it may cause the ILE activation group in which the called ILE C program is running to end. If the ILE C program was defined to run in a *NEW activation group then when return is issued near a hard control boundary, the activation group in which the ILE C program was running is ended. If the ILE C program was defined to run in a *CALLER activation group or a named activation group then when return is issued, the activation group in which the ILE C program was running remains active. A subsequent call to the ILE C program in this activation group will find the ILE C program in its last used state.

The exit(n) function can cause control to be returned to the nearest control boundary. An exception condition can cause an exception handler to be invoked or cause control to be returned to the nearest control boundary.

When the ILE C program is running in a different named activation group than the calling ILE COBOL program, exit(n) or an unhandled exception cause the following to happen. If exit(n) or an unhandled exception occur near a hard control boundary, the activation group in which the ILE C program is running is ended. If they occur near a soft control boundary, the activation group remains active. If an unhandled exception ends the activation group in which the ILE C program is running, the CEE9901 escape message is raised in the calling ILE COBOL program's activation group.

When the ILE C program and the calling ILE COBOL program are running in the same activation group, exit(n) or an unhandled exception cause the following to happen. If exit(n) or an unhandled exception occur near a hard control boundary, the activation group, including the ILE COBOL program, is ended. If an unhandled exception ends the activation group in which both the ILE C program and the ILE COBOL program are running, the CEE9901 escape message is issued to the program prior to the hard control boundary. If exit(n) or an unhandled exception occur near a soft control boundary, all programs and procedures, including the ILE COBOL program, between the ILE C program from which the exit(n) is made and the program at the soft control boundary, are ended.

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 an exception handling procedure identified in your ILE COBOL program may be invoked. 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 ]