IBM AS/400 Frozen Dessert Maker User Manual


 
*-----------------------------------------------------------------*
* Access the product master file using the transaction product *
* number. *
*-----------------------------------------------------------------*
C TRNPRDNO CHAIN PRDREC 10
*-----------------------------------------------------------------*
* If the record is found, update the quantity in the master file. *
*-----------------------------------------------------------------*
C IF NOT *IN10
C SUB TRNQTY PRDQTY
C UPDATE PRDREC
*-----------------------------------------------------------------*
* If the record is not found, write to the error report *
*-----------------------------------------------------------------*
C ELSE
C EXCEPT NOTFOUND
C ENDIF
C SETON LR
*-----------------------------------------------------------------*
* Error handling routine. *
*-----------------------------------------------------------------*
C PrdInfsr BEGSR
*-----------------------------------------------------------------*
* If the master record is currently locked, write the transaction *
* record to the back log file and skip to next transaction. *
*-----------------------------------------------------------------*
C PrdStatus DSPLY
C IF (PrdStatus = ErrRecLock)
C WRITE TRNBREC
C MOVE '*GETIN' ReturnPt 6
*-----------------------------------------------------------------*
* If unexpected error occurs, cause inquiry message to be issued. *
*-----------------------------------------------------------------*
C ELSE
C MOVE *BLANK ReturnPt
C ENDIF
C ENDSR ReturnPt
*-----------------------------------------------------------------*
* Error report format. *
*-----------------------------------------------------------------*
OPRINT E NOTFOUND
O TRNPRDNO
O 29 'NOT IN PRDMAS FILE'
Figure 111 (Part 2 of 2). Example of File Exception Handling
When control is passed to the error subroutine, the following occurs:
If the error is due to a record lock, then the record is written to a backlog file
and control returns to the main part with the next transaction (via *GETIN as
the return point).
If the error is due to some other reason, then blanks are moved to ReturnPt.
This will result in the RPG default handler receiving control. The recovery action
at that point will depend on the nature of the error.
Note that the check for a record lock error is done by matching the *STATUS sub-
field of the INFDS for PRDMAS against the field ErrRecLock which is defined with
the value of the record lock status code. The INFSR could be extended to handle
other types of I/O errors by defining other errors, checking for them, and then
taking an appropriate action.
Chapter 12. Handling Exceptions 231