Defining variable-length records

To define VSAM records as variable length, use one of these coding options.

Table 1. Definition of VSAM variable-length records
RECORD clause Clause format Maximum record length Comments
Code RECORD IS VARYING FROM integer-6 TO integer-7. 3 integer-7 bytes The lengths of the level-01 record description entries associated with the file do not matter.
Code RECORD IS VARYING. 3 Size of the largest level-01 record description entry associated with the file The compiler determines the maximum record length.
Code RECORD CONTAINS integer-4 TO integer-5. 2 integer-5 bytes The minimum record length is integer-4 bytes.
Omit the RECORD clause, but code multiple level-01 records that are associated with the file and are of different sizes or contain an OCCURS DEPENDING ON clause.   Size of the largest level-01 record description entry associated with the file The compiler determines the maximum record length.

When you specify a READ INTO statement for a format-V file, the record size that is read for that file is used in the MOVE statement generated by the compiler. Consequently, you might not get the result you expect if the record read in does not correspond to the level-01 record description. All other rules of the MOVE statement apply. For example, when you specify a MOVE statement for a format-V record read in by the READ statement, the size of the record corresponds to its level-01 record description.

related references  
RECORD clause (Enterprise COBOL for z/OS® Language Reference)