VSAM - Defining record lengths for VSAM files - www.cadcobol.com.br



Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

Defining record lengths for VSAM files

Enterprise COBOL for z/OS, Version 4.2, Programming Guide


You can define VSAM records to be fixed or variable in length.
COBOL determines the record format from the RECORD clause and the record descriptions that are associated with the FD entry for a file.

Because the concept of blocking has no meaning for VSAM files, you can omit the BLOCK CONTAINS clause.
The clause is syntax-checked, but it has no effect on how the program runs.

Defining fixed-length records

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

RECORD clause Clause format Record length Comments
RECORD CONTAINS integer. 1 Fixed in size with a length of integer-3 bytes The lengths of the level-01 record description entries associated with the file do not matter.
Omit the RECORD clause, but code all level-01 records that are associated with the file as the same size; and code none with an OCCURS DEPENDING ON clause. The fixed size that you coded

Defining variable-length records

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

RECORD clause Clause format Maximum record length Comments
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.
RECORD IS VARYING. 3 Size of the largest level-01 record description entry associated with the file The compiler determines the maximum record length.
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.


© Copyright IBM Corp.