Data management is designed to provide a balance between ease of use, migration to new releases, coexistence with various levels of software and hardware, device independence, exploitation of hardware features, and performance. Sometimes these considerations can conflict. If your program exploits a particular model's features to maximize performance, it might not take full advantage of newer technology.
For these reasons, the operating system has many options. It is not the intent of IBM to require extensive education to use assembly language programming. The purpose of this topic is to show how to read and write sequential data sets simply in High Level Assembler while maximizing ease of use, migration potential, the likelihood of coexistence, and device independence, while getting reasonable performance.
You can use the examples in this topic to read or write sequential data sets and partitioned members. These include ordinary disk data sets, extended format data sets, compressed format data sets, PDS members, PDSE members, UNIX files, UNIX FIFOs, spooled data sets (SYSIN and SYSOUT), real or VM simulated unit record devices, TSO/E terminals, magnetic tapes, dummy data sets, and most combinations of them in a concatenation.
When your program is writing and you omit DCB BLKSIZE and code DCBE BLKSIZE=0, this enables the user to select the block size in the DD statement or dynamic allocation. The user should only do this if there is a reason to do so, such as a reading program cannot accept large blocks. If the user does not specify a block size, OPEN selects one that is valid for the LRECL and RECFM and is optimal for the device. Coding BLKSIZE=0 in the DCBE macro lets OPEN select a block size that exceeds 32 760 bytes if large block interface (LBI) processing is being used, thereby possibly shortening run time significantly. If OPEN might select a block size that is larger than the reading programs can handle, the user can code the BLKSZLIM keyword in the DD statement or the dynamic allocation equivalent or rely on the block size limit in the data class or in the DEVSUPxx PARMLIB member.
If you want to provide your own default for BLKSIZE and not let OPEN do it, you can provide a DCB OPEN exit routine. See DCB OPEN Exit. The installation OPEN exit might override your program's selection of DCB parameters.
With BSAM and BPAM, code MULTSDN and MULTACC in the DCBE macro. See Improving Performance for Sequential Data Sets.
With QSAM, BSAM, and BPAM this generally has no effect on the EXCP count that is reported in SMF type 14, 15, 21, and 30 records. On DASD, this counts blocks that are transferred and not the number of channel programs. This causes the counts to be repeatable and not to depend on random factors in the system.
OPEN (INDCB,INPUT) Open to read
LTR R15,R15 Branch if DD name seems not
BNZ ... to be defined
* Loop to read all the records
LOOP GET INDCB Get address of a record in R1
... Process a record
B LOOP Branch to read next record
* I/O error routine for INDCB
IOERROR SYNADAF ACSMETH=QSAM Get message area
MVI 6(R1),X'80' Set WTO MCS flags
MVC 8(16,R1),=CL16'I/O Error' Put phrase on binary fields
MVC 128(4,R1),=X'00000020' Set ROUTCDE=11 (WTP)
WTO MF=(E,4(R1)) Write message to user
SYNADRLS Release SYNADAF area, fall through
* The GET macro branches here after all records have been read
EOD CLOSE (INDCB) Close the data set
FREEPOOL INDCB Free the QSAM buffer pool
... Rest of program
INDCB DCB DDNAME=INPUT,MACRF=GL,RECFM=VB, Must be format-V *
DCBE=INDCBE
INDCBE DCBE EODAD=EOD,SYNAD=IOERROR,BLKSIZE=0 Request LBI
COPYPROG CSECT
COPYPROG RMODE ANY
COPYPROG AMODE 31
GETMAIN R,LV=Arealen,LOC=(BELOW,64)
LR R11,R1
USING MYAREA,R11
USING IHADCB,InDCB
USING DCBE,INDCBE
MVC IHADCB(AreaLen),MYDCB Copy DCB and DCBE
LA R0,DCBE Point DCB copy to
ST R0,DCBDCBE DCBE copy
OPEN (IHADCB,),MF=(E,INOPEN) Open to read
LTR R15,R15 Branch if DDname seems not
BNZ ... to be defined
* Loop to read all the records
LOOP GET INDCB Get address of a record in R1
... Process a record
B LOOP Branch to read next record
* I/O error routine for INDCB
IOERROR SYNADAF ACSMETH=QSAM Get message area
MVI 6(R1),X'80' Set WTO MCS flags
MVC 8(16,R1),=CL16'I/O Error' Put phrase on binary fields
MVC 128(4,R1),=X'00000020' Set ROUTCDE=11 (WTP)
WTO MF=(E,4(R1)) Write message to user
SYNADRLS Release SYNADAF area, fall through
* The GET macro branches here after all records have been read
EOD CLOSE MF=(E,INOPEN) Close the data set
* FREEPOOL not needed due to RMODE31=BUFF
... Rest of program
MYDCB DCB DDNAME=INPUT,MACRF=GL,RECFM=VB, *
DCBE=MYDCBE
MYDCBE DCBE EODAD=EOD,SYNAD=IOERROR,BLKSIZE=0,RMODE31=BUFF
OPEN (,INPUT),MF=L,MODE=24
AreaLen EQU *-MYDCB
DCBD DSORG=QS,DEVD=DA
IHADCBE Could be above 16 MB line
MYAREA DSECT
INDCB DS XL(DCBLNGQS)
INDCBE DS XL(DCBEEND-DCBE)
INOPEN OPEN (,),MF=L