HP 3000 Manuals

Displaying File Status Items [ Micro Focus COBOL System Reference, Volume 2 ] MPE/iX 5.0 Documentation


Micro Focus COBOL System Reference, Volume 2

Displaying File Status Items 

If you want to display this status with its correct decimal value,
careful redefinition of data-items is required in order to avoid
truncation of the value.  This is because the facility that enables the
storage of a non-numeric value greater than decimal 99 as a hexadecimal
value is an extension to the ANSI COBOL standard X3.23 (1974) but the
rules for moving or manipulating such data are restricted by the standard
to a maximum of decimal 99.  Alternatively, you can redefine the second
status byte as a PIC 99 COMP-X item.

The example program 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.

      000010 environment division.
     000020 input-output section.
     000030 file-control.
     000040 select file1
     000050    assign tst.fil
     000060    status is file1-stat
     000070 data division.
     000080 file section.
     000090 fd file1
     000100 01 f1-rec                        pic x(80)
     000110 working-storage section.
     000120 01 file1-stat.
     000130    03 s1                 pic x.
     000140    03 s2                 pic x.
     000150 01 stat-bin redefines file1-stat pic 9(4) comp.
     000160 01 disply-stat.
     000170    03 s1-displ           pic x.
     000180    03 filler             pic x(3).
     000190    03 s2-displpic        pic zz9.
     000200 procedure division.
     000210 start-test.
     000220    open input file1
     000230    move s1 to s1-displ
     000240    if s1 not= 9
     000250        move s2 to s2-displpic
     000260    else
     000270        move low-values to s1
     000280        move stat-bin to s2-displpic
     000290    end if
     000300    display disply-stat
     000310    stop run.

If you have not specified file status item in the SELECT clause of the
File-Control paragraph in a program, file errors with a first byte value
of 9 will result in a run-time error being output.



MPE/iX 5.0 Documentation