BLOCK CONTAINS Clause
The BLOCK CONTAINS clause specifies the size of the physical records.
BLOCK CONTAINS Clause - Format >>-BLOCK--+----------+--+----------------+--integer-2-----------> '-CONTAINS-' '-integer-1-- TO-' >--+------------+---------------------------------------------->< +-CHARACTERS-+ '-RECORDS----'
This clause can be omitted when each physical record contains only one complete logical record.
- integer-1, integer-2
- Must be nonzero unsigned integers. They specify the number of characters or records. If integer-2 is zero, the system will determine the blocking size.
- CHARACTERS
- Specifies the number of character positions required to store the physical
record, no matter what USAGE the characters have within the data record.
If only integer-2 is specified, it specifies the exact character size of the physical record. When integer-1 and integer-2 are both specified, they represent, respectively, the minimum and maximum character sizes of the physical record.
Integer-1 and integer-2 must include any control bytes and padding contained in the physical record. (Logical records do not include padding.)
For non-tape files, only integer-2 controls the blocking factor. If integer-2 is zero, the system default blocking factor applies.
The CHARACTERS phrase is the default. CHARACTERS must be specified when the physical record contains padding.
In general, the length of a variable length record on a RELEASE, REWRITE, or WRITE statement is determined by data-name-1, if specified. If data-name-1 is not specified and the record description does not contain a table, the length is the number of characters in the record description. If data-name-1 is not specified and the record contains a table, the length is the sum of the fixed part of the record and the current length of the table.
When variable length records are used for disk files, the BLOCK CONTAINS clause specifies the size of the block. The size of the actual record is contained in data-name-1 after a READ operation. To WRITE a variable length record, data-name-1 must be set to the length of the record.
For tape files, each variable record contains a four-byte header and each block contains a four-byte header when the data is transferred to tape. However, these four-byte headers are provided by the system and are of no concern to the COBOL user except that the maximum size of a variable record is restricted to 32 764.
When variable records are used for tape files, the BLOCK CONTAINS clause specifies the maximum physical record length, while the logical record length for each record is inferred by the compiler from the record name used in a WRITE statement. If an explicit length is required after a READ statement, the user can obtain it through the I-O-FEEDBACK mnemonic-name.
- RECORDS
- Specifies the number of logical records contained in each physical record.
Maximum record size is 32 767; maximum block size is 32 767. These maximums include any control bytes required for variable blocked records; thus, the maximum size data record for a variable-blocked record is 32 759.
