Example 2: keyed-sequential retrieval—backward (KSDS, RRDS)

This example differs from the previous one in that a POINT macro is issued to the last record in the data set and the records are retrieved in a backward direction.
INPUT   ACB    DDNAME=INPUT,                                            x
               EXLST=EXLST1
 
RETRVE  RPL    ACB=INPUT,       Define RPL for last record positioning  x
               AREA=IN,         and backward processing.                x
               AREALEN=100,                                             x
               OPTCD=(KEY,SEQ,                                          x
               LRD,BWD)
 
EXLST1  EXLST  EODAD=EOD        Define end of data.
 
        POINT  RPL=RETRVE       Position to last record (no argument
                                is required).
        LTR    15,15
        BNZ    ERROR
LOOP    GET    RPL=RETRVE       Get previous record.
        LTR    15,15
        BNZ    ERROR
        .
        B      LOOP
EOD     EQU    *                Come here for end of data.
ERROR   ...                     Request failed.
        .
IN      DS     CL100            Area for retrieved record.