RECORD clause - Format 2

Format 2 is the recommended format when dealing with variable records.

Read syntax diagramSkip visual syntax diagram
RECORD Clause - Format 2

>>-RECORD--+----+--VARYING--+----+--+------+-------------------->
           '-IS-'           '-IN-'  '-SIZE-'   

>--+---------------------+--+---------------+--+------------+--->
   '-+------+--integer-4-'  '-TO--integer-5-'  '-CHARACTERS-'   
     '-FROM-'                                                   

>--+--------------------------------+--------------------------><
   '-DEPENDING--+----+--data-name-1-'   
                '-ON-'                  

integer-4
Specifies the minimum number of character positions to be contained in any record of the file. If integer-4 is not specified, the minimum number of character positions to be contained in any record of the file is equal to the smallest number of character positions described for a record in that file. If specified, integer-4 must be nonzero and less than integer-5.
integer-5
Specifies the maximum number of character positions in any record of the file. If integer-5 is not specified, the maximum number of character positions in any record of the file is equal to the greatest number of character positions described for a record in that file.
data-name-1
Must be an elementary unsigned integer.
If data-name-1 is specified:
  • The number of character positions in the record must be placed into the data item referenced by data-name-1 before any RELEASE, REWRITE, or WRITE statement is executed for the file.
  • The execution of a DELETE, RELEASE, REWRITE, START, or WRITE statement or the unsuccessful execution of a READ or RETURN statement does not alter the contents of the data item referenced by data-name-1.
  • After the successful execution of a READ or RETURN statement for the file, the contents of the data item referenced by data-name-1 indicate the number of character positions in the record just read.

The number of character positions associated with a record description is determined by the sum of the number of character positions in all elementary data items (excluding redefinitions and renamings), plus any implicit FILLER due to synchronization.

If a table is specified, the minimum and maximum number of table elements described in the record are used in the summation above, to determine the minimum and maximum number of character positions associated with the record description.

If the number of character positions in the logical record to be written is less than integer-4 or greater than integer-5, the output statement is unsuccessful and, except during execution of a RELEASE statement, the associated I-O status key is set to a value indicating the cause of the condition.

During the execution of a RELEASE, REWRITE, or WRITE statement, the number of character positions in the record is determined by the following conditions:
  • If data-name-1 is specified, by the content of the data item referenced by data-name-1.
  • If data-name-1 is not specified and the record does not contain a variable occurrence data item, by the number of character positions in the record.
  • If data-name-1 is not specified and the record contains a variable occurrence data item, by the sum of the fixed portion and that portion of the table described by the number of occurrences at the time of execution of the output statement.
During the execution of a READ ... INTO or RETURN ... INTO statement, the number of character positions in the current record that participate as the sending data items in the implicit MOVE statement is determined by the following conditions:
  • If data-name-1 is specified, by the content of the data item referenced by data-name-1.
  • If data-name-1 is not specified, by the value that would have been moved into the data item referenced by data-name-1 had data-name-1 been specified.