BLOCK CONTAINS clause

The BLOCK CONTAINS clause specifies the size of the physical records.

The CHARACTERS phrase indicates that the integer specified in the BLOCK CONTAINS clause reflects the number of bytes in the record. For example, if you have a block with 10 DBCS characters or 10 national characters, the BLOCK CONTAINS clause should say BLOCK CONTAINS 20 CHARACTERS.

If the records in the file are not blocked, the BLOCK CONTAINS clause can be omitted. When it is omitted, the compiler assumes that records are not blocked. Even if each physical record contains only one complete logical record, coding BLOCK CONTAINS 1 RECORD would result in fixed blocked records.

The BLOCK CONTAINS clause can be omitted when the associated file-control entry specifies a VSAM file. The concept of blocking has no meaning for VSAM files. The BLOCK CONTAINS clause is syntax checked but has no effect on the execution of the program.

For external files, the value of all BLOCK CONTAINS clauses of corresponding external files must match within the run unit. This conformance is in terms of bytes and does not depend upon whether the value was specified as CHARACTERS or as RECORDS.

integer-1 , integer-2
Must be unsigned integers. They specify:
CHARACTERS
Specifies the number of bytes required to store the physical record, no matter what USAGE the data items have within the data record.

If only integer-2 is specified, it specifies the exact number of bytes in the physical record. When integer-1 and integer-2 are both specified, they represent the minimum and maximum number of bytes in the physical record, respectively.

integer-1 and integer-2 must include any control bytes and padding contained in the physical record. (Logical records do not include padding.)

The CHARACTERS phrase is the default. CHARACTERS must be specified when:

  • The physical record contains padding.
  • Logical records are grouped so that an inaccurate physical record size could be implied. For example, suppose you describe a variable-length record of 100 bytes, yet each time you write a block of 4, one 50-byte record is written followed by three 100-byte records. If the RECORDS phrase were specified, the compiler would calculate the block size as 420 bytes instead of the actual size, 370 bytes. (This calculation includes block and record descriptors.)
RECORDS
Specifies the number of logical records contained in each physical record.

The compiler assumes that the block size must provide for integer-2 records of maximum size, and provides any additional space needed for control bytes.

BLOCK CONTAINS 0 can be specified for QSAM files. If BLOCK CONTAINS 0 is specified for a QSAM file, then:

  • The block size is determined at run time from the DD parameters or the data set label of the file. For output data sets, the DCB used by Language Environment® will have a zero block size value. When the DCB has a zero block size value, the operating system might select a system-determined block size (SDB). See the operating system specifications for further information about SDB.

    BLOCK CONTAINS can be omitted for SYSIN files and for SYSOUT files. The blocking is determined by the operating system.

For a way to apply BLOCK CONTAINS 0 to QSAM files that do not already have a BLOCK CONTAINS clause, see the description of the compiler option, BLOCK0 in the Enterprise COBOL Programming Guide.

The BLOCK CONTAINS clause is syntax checked but has no effect on the execution of the program when specified under an SD.

The BLOCK CONTAINS clause cannot be used with the RECORDING MODE U clause.