COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

The length you specify in the RECORD CONTAINS clause is the fixed length of the record
area that holds individual records read from or to be written to the file during execution. Each
record description entry can define the record area in a different way, possibly describing a
record of a shorter length than the actual record has in the record area or in the file.
Example of a File with Fixed-Length Records
This explicitly declares a file to have fixed-length records:
RECORD CONTAINS 256 CHARACTERS
Purpose of Variable-Length Records
If you describe a file as having variable-length records, the individual record descriptions for
that file can be of any length from the stated or implied minimum length to the stated or implied
maximum length. The specified minimum size can be less than that implied by the record
description entry defining the smallest number of character positions. The specified maximum
size can be greater than that implied by the record description entry defining the largest
number of character positions; however, only those character positions defined in the record
descriptions are accessible to the program.
If the record you write is smaller than the minimum length, the extra characters are undefined.
Depending Item
When length-var is specified, the data item it references is called the depending item.
Governs the length of the record to be written
The contents of this item, evaluated just before the execution of a REWRITE or WRITE
statement for the file, determine the size of the record to be written.
Contains the length of the record after it has been read
After the successful execution of a READ statement for the file, the contents of the depending
item indicate the size of the item just read.
The size is expressed in characters.
The execution of a DELETE, RELEASE, REWRITE, START, or WRITE statement, or the unsuccessful
execution of a READ statement, does not alter the contents of the depending item.
Establishing the Length of a Variable-Length Record
When the run-time routines execute a REWRITE or WRITE statement referencing a file of
variable-length records, the number of character positions in the record written is determined:
If length-var is specified, by the content of the data item referenced by length-var.
If length-var is not specified and the record does not contain a variable-occurrence
data item, by the number of character positions in the record (as specified in the record
description).
If length-var is not specified and the record contains a variable-occurrence data item,
by the sum of the size 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.
Example 36 Variable-Length Record
RECORD IS VARYING IN SIZE FROM 100 TO 144 CHARACTERS
166 Data Division