z/OS DFSMSdfp Advanced Services
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Using BSAM or EXCP for Random I/O to a Multivolume Data Set

z/OS DFSMSdfp Advanced Services
SC23-6861-01

If you open a BDAM DCB for a multivolume data set, OPEN links your program to all volumes simultaneously so that your program can ignore volume boundaries and treat all volumes of the data set as one entity. If you open a BSAM or EXCP DCB for a multivolume data set, OPEN gives your program access to only one volume at a time. This is true for both disk and tape. To switch to another volume, your program issues a CHECK or FEOV macro for BSAM or EOV macro for EXCP. To return to a previous volume, you must close and reopen the data set, which would be slow.

Your program can use RDJFCB and OPEN TYPE=J with one DCB per volume to process all the volumes in parallel. Your program must keep track of which DCB is for each volume. Your program uses the RDJFCB macro to read in the JFCB, and uses OPEN with TYPE=J to open each volume of the data set. The coding example in Figure 1 illustrates the procedure with EXCP DCBs.

This technique does not work for a JFCB disposition of NEW because OPEN TYPE=J honors modifications to the JFCB volume sequence number JFCBVLSQ only for tape and only if the JFCB file sequence is also modified.

This technique does not work with a striped data set because OPEN always opens all volumes of a striped data set in parallel as for BDAM.

If you are using BSAM to read non-striped volumes in parallel, you should avoid using the CHECK macro because it can automatically move to the next volume when you reach the end of the current volume. Use WAIT or EVENTS instead of CHECK. Refer to z/OS DFSMS Using Data Sets and z/OS DFSMS Macro Instructions for Data Sets for information about WAIT or EVENTS. If you optimize I/O with the MULTACC parameter of the DCBE macro, you also must issue TRUNC macros.

With tape, you cannot open more than one DCB per allocated drive. You can calculate the number of allocated drives from the TIOT entry length or by issuing the IEFDDSRV macro. IEFDDSRV returns the number of devices in DVAR_NUM_DVENT. Refer to z/OS MVS Programming: Assembler Services Reference IAR-XCT.

If your program does any of the following it will damage the data set:
  • If you use BSAM and the OPEN option is not UPDAT and you issue WRITE macros, you might cause the data set to be extended to new tracks or to the next volume. In the latter case you have two DCBs open to one volume and they can interfere with each other.
  • If you use BSAM and the OPEN option is not UPDAT and the last operation before CLOSE is WRITE (and CHECK, WAIT or EVENTS), then CLOSE marks that volume as being the last volume of the data set. The result might be every volume marked as being the last one. This is true also if you use EXCP and CLOSE finds that bit 0 of DCBOFLGS is on. For EXCP, see Table 1 and Device-Dependent Parameters. If a program later tries to read the volumes of the data set sequentially, such as a program backing it up, that program will not read past the end of this volume. In addition, a later program trying to add records to the end of a volume by opening with the EXTEND or OUTINX option or with the OUTPUT or OUTIN option with DISP=MOD, can add them to the wrong volume.

If the data set is newly allocated on DASD, space has been allocated only on the first volume unless you used the guaranteed space option of SMS. For both DASD and tape, if the data set has not yet been written on the volume, the OPEN fails.

Figure 1. Processing a Multivolume Data Set with EXCP
ALLVOLS  RMODE 24             Because of DCB exit list & JFCB
              RDJFCB DCB1          Read in the JFCB
              LTR   R15,R15        Branch if the DD name
              BNZ   NODD             is not defined
     * Calculate amount of storage for one DCB per volume and get storage.
              SR    R0,R0          Prepare for IC
              IC    R0,JFCBNVOL    Get number of volumes
              LR    R3,R0          Save number of volumes
              MH    R0,=Y(DCBLNGXE) Mult by EXCP DCB length without append.
              STORAGE OBTAIN,LENGTH=(0),LOC=(BELOW,ANY),ADDR=DCBAddrL
              LR    R4,R1          Point to area for first DCB
              LA    R5,1           Set first volume sequence number
     OpenLoop STH   R5,JFCBVLSQ    Tell OPEN which volume to open
              MVC   0(DCBLNGXE,R4),DCB1   Build a DCB
              OPEN  ((R4),UPDAT),TYPE=J   Use TYPE=J for one volume
              LTR   R15,R15        Branch in the unlikely event
              BNZ   OpenFail         that OPEN failed
              LA    R4,DCBLNGXE(,R4)  Point to place for next DCB
              LA    R5,1(R5)       Increment the volume counter
              BCT   R3,OpenLoop    Loop until all volumes are open
              .
              .
              .
     DCB1     DCB   DDNAME=SYSUT1,MACRF=(E),EXLST=ExitL,DSORG=PS
     * The following is a DCB exit list.
     ExitL    DC    0F'0',AL1(EXLLASTE+EXLRJFCB)    Last entry, for JFCB
              DC    AL3(JFCB)      Address of JFCB area
     DCBAddrL DS    A              Address of DCB list
     JFCB     DS    CL176          JFCB READ IN HERE
              ORG   JFCB+70        Go back to remap
     JFCBVLSQ DS    H              Volume sequence number
              ORG   JFCB+117
     JFCBNVOL DS    FL1            Number of volumes allocated
              ORG   ,
     * Mapping macro IEFJFCBN might be used instead.
              DCBD DSORG=XE,DEVD=(DA,TA)  Map an EXCP DCB
              IHAEXLST ,      DCB exit list mapping  

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014