HANDLE (pic x(4) comp-x)    This is the handle returned from CBL_OPEN_FILE or CBL_CREATE_FILE. Once this routine is called, the file handle should not be used in future calls to READ or WRITE or CLOSE, or undefined results will occur, including the possibility of a MAV.


This routine is used for closing files and returns 0 on success and non-zero if an error occurred. The error is a special encoding of the digit 9 with the ANSI-74 error code, or the runtime system error number if no ANSI-74 error code pertains to the error. If RETURN-CODE is non-zero after calling this routine, you must process it as a file status, for example:

01  file-status-group.
    03  file-status     pic xx comp-x. 
    03  redefines file-status. 
        05  fs-byte-1  pic x. 
        05  fs-byte-2  pic x comp-x.
. . . 
call "CBL_CLOSE_FILE" using parameters 
if return-code not = 0 
    move return-code to file-status 
. . .

At this point fs-byte-1 contains "9" and fs-byte-2 contains the ANSI-74 error code, or a runtime system error number.

Note: This routine is written in C and is called via the "direct" method, so it is not possible for the runtime to validate parameters for accuracy. Passing unexpected parameters will result in undefined behavior and possibly even a MAV.