|
When you read a sequential data set, you can determine the length
of the block in one of the following ways, depending on the access
method and record format of the data set.
For unblocked and undefined record formats, each block contains
one logical record.
- Fixed-length, unblocked records: The length
of all records is the value in the DCBBLKSI field of the DCB without
LBI or the DCBEBLKSI field of the DCBE with LBI. You can use this
method with BSAM or BPAM.
- Variable-length records and Format-D records
with BUFOFF=L: The block descriptor word in the block contains
the length of the block. You can use this method with BSAM or BPAM. Block Descriptor Word (BDW) describes the BDW format.
- Format-D records without BUFOFF=L: The block
length is in DCBLRECL after you issue the CHECK macro. It remains
valid until you again issue a CHECK macro.
- Undefined-length records when using LBI or for
fixed-length blocked: The method described in the following paragraphs
can be used to calculate the block length. You can use this method
with BSAM, BPAM, or BDAM. (It should not be used when using chained
scheduling with format-U records. In that case, the length of a record
cannot be determined.
- After issuing the CHECK macro for the DECB for the READ request,
but before issuing any subsequent data management macros that specify
the DCB for the READ request, obtain the status area address in the
word that is 16 bytes from the start of the DECB.
- If you are not using LBI, take the following steps:
- Obtain the residual count that has been stored in the status area.
The residual count is in the halfword, 14 bytes from the start of
the status area.
- Subtract this residual count from the number of data bytes requested
to be read by the READ macro. If 'S' was coded as the length
parameter of the READ macro, the number of bytes requested is the
value of DCBBLKSI at the time the READ was issued. If the length was
coded in the READ macro, this value is the number of data bytes and
it is contained in the halfword 6 bytes from the beginning of the
DECB. The result of the subtraction is the length of the block read.
If you are using LBI for BSAM or BPAM, subtract 12 from the address
of the status area. This gives the address of the 4 bytes that contain
the length of the block read.
- Undefined-length records when not using LBI: The
actual length of the record that was read is returned in the DCBLRECL
field of the DCB. Because of this use of DCBLRECL, you should omit
LRECL. Use this method only with BSAM, or BPAM or after issuing a
QSAM GET macro.
Figure 1 shows an example of determining the length
of a record when using BSAM to read undefined-length records.
Figure 1. One Method of Determining the Length of a Record when Using BSAM
to Read Undefined-Length or Blocked Records ...
OPEN (DCB,(INPUT))
LA DCBR,DCB
USING IHADCB,DCBR
...
READ DECB1,SF,DCB,AREA1,'S'
READ DECB2,SF,DCB,AREA2,50
...
CHECK DECB1
LH WORK1,DCBBLKSI Block size at time of READ
L WORK2,DECB1+16 Status area address
SH WORK1,14(WORK2) WORK1 has block length
...
CHECK DECB2
LH WORK1,DECB2+6 Length requested
L WORK2,DECB2+16 Status area address
SH WORK1,14(WORK2) WORK1 has block length
...
MVC DCBBLKSI,LENGTH3 Length to be read
READ DECB3,SF,DCB,AREA3
...
CHECK DECB3
LH WORK1,LENGTH3 Block size at time of READ
L WORK2,DECB+16 Status area address
SH WORK1,14(WORK2) WORK1 has block length
...
DCB DCB ...RECFM=U,NCP=2,...
DCBD
...
When you write a short block to an extended-format data
set, the system pads it to full length but retains the value of what
your program said is the length. When you read such a block, be aware
that the system reads as many bytes as the block can have and is not
limited by the length specified for the write. If you know that a
particular block is short and you plan to read it to a short data
area, then you must decrease DCBBLKSI or DCBEBLKSI with LBI to the
length of the short area before the READ.
|