RDW

Enables you to find out the length of a record that has just been read from a variable-length sequential file.

Syntax:

 >>-.---.-.----.--RDW-----------------------><  
    +-/-+ +-NO-+

Parameters:

None

Properties:

Default: NORDW
Phase: Syntax check
$SET: Any

Comments:

If you specify the RDW directive, a four-byte record-length field is allocated immediately before the record area for the file. After a READ, the length (in binary) of the record just read is put in the first two bytes of this record area. The length returned includes the record-length field itself, so is four bytes longer than the actual record length.

You can access this field by defining the record area as a table, and using negative or zero subscripts

The RDW directive is intended only for mainframe compatibility; for new programs you should use the RECORD IS VARYING DEPENDING ON phrase of the FD statement.

Example:

 fd  file-1. 
 01  rec-1           pic x(100). 
 01  rec-2. 
     03  rdw-table   pic x(4) occurs 25. 
 Working-storage section. 
 01  rdw-area. 
     03  rec-length  pic 9(4) comp. 
     03  filler      pic 9(4) comp.
 procedure division. 
     ... 
     read file-1 
     move rdw-table (0) to rdw-area 
     ...