Admin Production rocket
Current Publication

Example of Extended File Status Codes

Enterprise Developer for Eclipse (including UNIX Components) V7.0
Rocket® Enterprise Developer (formerly a product of Micro Focus or formerly a product of Open Text) documentation, created before Rocket Software acquired certain products from OpenText, may include outdated references to "Micro Focus" or "OpenText", both of which are trademarks of OpenText or its affiliates. Rocket Software is not affiliated with Micro Focus or OpenText and has since rebranded these products as Rocket® products. You may also encounter outdated links in this documentation. If you do, please contact Rocket Support (support@rocketsoftware.com) for assistance.

Example of Extended File Status Codes

The example code that follows illustrates how to redefine a standard file status so that it can be used as an extended file status. Assume for this example that the input file does not exist - when the OPEN INPUT statement is executed, a file status of 9/013 ("file not found") is returned.

 select in-file
     assign to "user.dat".
     file status is file-status.
  ...
 working-storage section.
 01 file-status.
     05 status-key-1     pic x.
     05 status-key-2     pic x.
     05 status-key-2-binary redefines status-key-2 pic 99 comp-x.
  ...
 procedure division.
     open input in-file
     if file-status not = "00"
     if status-key-1 = "9"
     if status-key-2-binary = 13
         display "File not found"
  ...

If you want to display the extended file status code, you need to move the second byte of the file status data item to a display field large enough to hold the maximum value 255:

 select in-file
     assign to "user.dat"
     file status is file-status.
  ...
 working-storage section.
 01 ans74-file-status.
     05 status-key-1    pic x.
     05 status-key-2    pic x.
     05 status-key-2-binary redefines status-key-2 pic 99 comp-x.
 01 display-ext-status
     05 filler          pic xx value "9/"
     05 display-key 2   pic 999
  ...
 procedure division.
     open input in-file
     if file-status not = "00"
         display "Error. File status =" with no advancing
         if status-key-1 = "9"
             move status-key-2-binary to display-key-2
             display display-ext-status
         else
             display file-status
         end-if
  ...