Skip to main content

Problem:

Received an error when trying to open a file.  The file status returned is '9 '.  What does this mean?

Resolution:

There are several different file status code values that can be returned from an I/O operation.   The default file status codes for this version of COBOL is ANSI'85 (Please read the documentation on the ANS85 compiler directive in the on-line help).  The values returned from an I/O operation are in the range '00' through to '49'.  The values are returned into a 2 character field.

However, the Micro Focus file system also has an extended version of file status codes. To activate these, the NOANS85 compiler directive must be set.  The values returned from an I/O operation are returned into a field where the first character is defined as pic x, and the second is defined as pic x comp-x (i.e. hex storage).  When an I/O operation fails the first field will always be 9 and the second will always contain a hex value.

In this case the file status field you have specified will be something like:  

  

                                 01  file-stat     pic xx.

So change that to:   01  file-stat.

                                      05  fs1        pic x.

                                      05  fs2        pic x comp x.

Then, if a file I/O operation fails, fs1 will contain 9 and fs2 will contain a value anywhere between 001 and 255.   Look at the Extended File Status Codes in the on-line help for an interpretation of the value returned.   For example, if you try to open a file INPUT and the file does not exist the extended file status code returned will be 9/013 - where 013 is the extended value.  The equivalent ANSI'85 status returned is 35.  However the difference is that the extended file status code are much more informative.  ANSI'85 code 35 covers many different operations where as the extended file status code 013 is specific to one operation only.

Please read the sections on Extended File Status Codes and Example of Extended File Status Codes in the on-line help for further information.

Old KB# 7002

#ServerExpress
#COBOL
#netexpress
#RMCOBOL
#AcuCobol