z/OS DFSMS Using Data Sets
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Handling Exceptional Conditions on Tape

z/OS DFSMS Using Data Sets
SC23-6855-00

In this topic an exceptional condition is any READ or WRITE macro that did not have normal completion.

Most programs do not care about how much data in the data set is on each volume and if there is a failure, they do not care what the failure was. A person is more likely to want to know the cause of the failure.

In some cases you might want to take special actions before some of the system's normal processing of an exceptional condition. One such exceptional condition is reading a tape mark and another such exceptional condition is writing at the end of the tape.

With BSAM, your program can detect when it has reached the end of a magnetic tape and do some processing before BSAM's normal processing to go to another volume. To do that, do the following:

  1. Instead of issuing the CHECK macro, issue the WAIT or EVENTS macro. Use the ECB, which is the first word in the DECB. The first byte is called the post code. As a minor performance enhancement, you can skip all three macros if the second bit of the post code already is 1.
  2. Inspect the post code. Do one of the following:
    1. Post code is X'7F': The READ or WRITE is successful. If you are reading and either the tape label type is AL or OPTCD=Q is in effect, then you must issue the CHECK macro to convert between ASCII and EBCDIC. Otherwise, the CHECK is optional and you can continue normal processing as if your program had issued the CHECK macro.
    2. Post code is not X'7F': You cannot issue another READ or WRITE successfully unless you take one of the following actions. All later READs or WRITEs that you issued for the DCB have post codes that you cannot predict, but they are guaranteed not to have started. If your only reason to issue WAIT or EVENTS is to wait for multiple events, then issue CHECK to handle the exceptional condition. If part or all of your purpose was to handle a certain exceptional condition, such as a full volume, take one of the following actions:
      • If the post code is X'41' and the status indicators show unit exception and an error status, you read a tape mark or wrote at the end of the volume. Coincidentally, however, you got an input or output error that prevented reading or writing to the block. You can still take one of the preceding actions. Issuance of CHECK causes entry to your SYNAD routine or issuance of an ABEND. You can issue CLOSE to bypass the SYNAD routine, but CLOSE might detect another input or output error and issue an ABEND.
      • If the post code and the status indicators are different from the preceding ones, the system probably did not read or write to the data block. Issue CHECK or CLOSE. CHECK causes entry to your SYNAD routine or the issuance of an ABEND. The system discards all other WRITEs with an unpredictable post code or no post code.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014