
MainframeSupports tip week 27/2008:
As you probably know it is possible to write records longer than the maximum
logical blocksize which is 27998 when the installation emulates a 3390 disc.
Such records are known as spanned records. A spanned record has a maximum length of
32760 bytes and is only available for reading and writing using variable blocked (VB)
datasets. When LRECL=32760 the record can only contain 32756 bytes as the first four
bytes of any variable length record is used for length information. Spanned records
are mainly used for AFP and SMF data.
In COBOL you may declare a file for spanned records like this:
FD SPANNED
RECORDING MODE V
BLOCK CONTAINS 0 RECORDS
RECORD VARYING FROM 1 TO 32756 DEPENDING ON SPANNED-LENGTH
The variable SPANNED-LENGTH is normally declared in working-storage as a positive
numeric data type of some kind for example PIC 9(5).
Depending on the version of COBOL and Language Environment (LE) there might occur
substantial performance problems when writing records declared with a maximum VARYING
length of more than 27992 bytes. Instead of examining the actual length in SPANNED-LENGTH
COBOL assumes that the record is completely filled with data (which it seldom is) and
performs an I/O for each record instead of waiting for the buffer to fill up.
Fortunately the above problem may be avoided by adding an APPLY WRITE-ONLY ON
SPANNED in paragraph I-O-CONTROL in the INPUT-OUTPUT SECTION in the ENVIRONMENT DIVISION.
This addition ensures that COBOL only performs I/O when the buffer is filled up
regardless of the maximum record length. Therefore it is a good idea to use APPLY
WRITE-ONLY to all files writing VB records regardless of the length.
Previous tip in english
Sidste danske tip
Tip list
|