Previous Topic Next topic Print topic


Example of Displaying File Status Codes

The example code that follows illustrates one method of retrieving the values of the second byte of the file status for display purposes. Note how truncation has been avoided by redefining the two status bytes as one numeric data item (length two bytes) capable of storing up to four decimal digits.

 select fd-name
     assign "user.dat"
     status is fd-name-stat.
  ...
 data division.
 file section.
 fd fd-name.
 01 fd-rec    pic x(80)
  ...
 working-storage section.
 01 fd-name-stat.
     03 sk1     pic x.
     03 sk2     pic x.
     03 stat-bin redefines sk2 pic 9(2) comp-x.
 01 disply-stat.
     03 sk1-displ   pic x.
     03 filler    pic x(3).
     03 sk2-displpic  pic zz9.
  ...
 procedure division.
 start-test.
     open input fd-name
     move sk1 to sk1-displ
     if sk1 not= 9
         move sk2 to sk2-displpic
     else
         move stat-bin to sk2-displpic
     end-if
     display disply-stat
     close fd-name
     stop run.
Previous Topic Next topic Print topic