Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

BLOCK CONTAINS clause

Function

The BLOCK CONTAINS clause specifies the maximum size of a physical block.

Format


BLOCK CONTAINS [integer-1 TO ] integer-2 {CHARACTERS | RECORDS }


Syntax rules

  1. A block must contain at least 20 bytes and must not exceed a maximum length of 32763 bytes.

  2. The CHARACTERS or RECORDS phrase indicates whether block length is to be specified as a multiple of bytes or logical records.

  3. If neither CHARACTERS nor RECORDS is specified, CHARACTERS will be assumed.

  4. integer-1 TO integer-2 indicates the number of bytes or records in a given block, depending on the phrase used (either CHARACTERS or RECORDS).

  5. When only integer-2 is specified, it refers to the maximum size of the block. When integer-1 and integer-2 are specified, they refer to the minimum and maximum size of the block, respectively. However, integer-1, when specified, is used only for documentation purposes and is treated as a comment by the compiler.

    The maximum block size specified by this clause has the following meaning:

    The blocks of the file must not be longer but can be shorter than the specified length. This is frequently the case with unblocked or blocked records whose length is variable.

  6. When the CHARACTERS phrase is used, the block size has to be specified in terms of the number of bytes contained within the block. In this case, both integer-1 and integer2 must include slack bytes and 4 bytes for the record length field of each record of the block.

  7. When the CHARACTERS phrase is used, and only integer-2 is specified, integer-2 indicates the exact length of the physical block. When both integer-1 and integer-2 are specified, they refer to the minimum or maximum physical block length, respectively.

  8. When the RECORDS phrase is used, the block size is specified in terms of logical records. In this case, the compiler calculates the block size by multiplying the number of bytes in the maximum size logical record by the value specified in integer-2. In the case of variable-length records, 4 bytes are added for the record length field.

  9. When the BLOCK CONTAINS clause is omitted, the compiler assumes that the records are not blocked, i.e. BLOCK CONTAINS 1 RECORDS is assumed.

    Note:
    The BLOCK CONTAINS clause may therefore be omitted when all blocks of the file contain one, and only one, record.

General rules

  1. The following table shows how the compiler calculates the block sizes in terms of bytes and includes the appropriate phrases contained in the BLOCK CONTAINS clause.

     

    Legend for table 10

    F

    = fixed-length records

    V

    = variable-length records

    BL

    = block length

    RL

    = record length

    RLmax

    = maximum record length

    BLF

    = block length field (has the value 4)

    RLF

    = record length field (has the value 4)

    n

    = integer

    Record format

    BLOCK CONTAINS [integer-1 TO] integer-2

    CHARACTERS

    RECORDS

    Fixed length

    BL = integer-2
    (integer-2 = n * RL)

    BL = integer-2 * RL

    Variable length

    BL = integer-2 + BLF

    BL = integer-2 * (RLmax + RLF) + BLF

    Table 10: Calculation of the maximum block size

  2. If the BLOCK CONTAINS clause is specified for an external file, the BLOCK CONTAINS clause must be specified in all programs that describe this external file; the block length calculated from the information specified in the BLOCK CONTAINS clause must be the same, regardless of whether it results from the number of "RECORDS" or the number of "CHARACTERS".

Note:
The CHARACTERS phrase should be used if the RECORDS phrase would produce a block size that is not accurate enough.
Let us assume, for example, that a block contains 4 records consisting of one 50-character record and three 100-character records. If BLOCK CONTAINS 4 RECORDS is specified, and the maximum record length is defined as 100 bytes, the compiler will calculate a block size of 4*(100+4)+4 = 420 bytes (including the block length field). In this case, however, since each block actually requires only (50+4)+3*(100+4)+4 = 366 bytes (without the block length field), the exact block size could be specified by using the following clause instead:
BLOCK CONTAINS 366 CHARACTERS.