COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Although tape devices are capable of handling blocks of 32,767 characters, unstructured
disk files are limited to a block size of 4,096. Furthermore, an unstructured disk file can have
a BLOCKSIZE attribute that is smaller than 4,096. Other devices have their own block size
limitations. See the discussion of the WRITE procedure call in the Guardian Procedure Errors
and Messages Manual for these limits.
Because the compiler cannot determine the block size of the device that is ultimately associated
with a file, you must choose the correct block size and record size or risk getting a run-time
error.
• Blocking and Deblocking for Tape and Unstructured Disk
A BLOCK CONTAINS clause is effective (HP COBOL performs record blocking and deblocking)
only when all of these conditions are met, and the file associated at open time is either a tape
unit or an unstructured disk file:
◦ The file’s organization is sequential.
◦ The file has fixed-length records. This condition is met only when the file description
contains either no RECORD CONTAINS or RECORD VARYING clause or contains a
RECORD CONTAINS clause that specifies only a single record size.
◦ When the block size is specified in characters, it is a multiple of the number of characters
in the logical record size. Also, when a RECORD CONTAINS clause extends the record
size, the block size expressed is a multiple of the number of characters in that specified
record size.
◦ The file is not described with a LINAGE or ALTERNATE RECORD KEY clause.
◦ Tape Files
If the actual file associated with the COBOL file at open time is a tape unit, then
blocking/deblocking always occurs. For an unlabeled tape file, the maximum block size
is the one specified in the BLOCK CONTAINS clause. For a labeled tape file, the maximum
block size specified in the tape label (which must be an exact multiple of the logical
record size) overrides the one specified in the BLOCK CONTAINS clause.
If the file is opened for INPUT, then each physical block on the tape medium must contain
one or more complete logical records. The size of a block must not exceed the maximum
block size; however, any block can be smaller than the maximum block size (can contain
fewer than the potential number of logical records).
◦ Unstructured Disk Files
If the actual file associated with the COBOL file at open time is an unstructured disk file,
then blocking/deblocking occurs if the logical record size is an even number of character
positions or the file has the odd-length access attribute; otherwise the BLOCK CONTAINS
clause is ignored (that is, logical records are physically read or written one at a time).
(To have the odd-length access attribute, a file must be created with FUP CREATE and
ODDUNSTR must be specified.)
Odd-length records are written as even-length unless ODDUNSTR is active.
The compiler issues a warning if blocking is specified when the conditions, other than
variable-length records, are not satisfied.
RECORD CONTAINS Clause
Use the RECORD CONTAINS clause to specify whether the records of a file are of fixed or variable
length and to document the size of the records.
File Section 163










