Example 1: keyed-sequential retrieval—forward (KSDS, RRDS)

In this example, a GET macro is used to sequentially retrieve records by key. Retrieval is in a forward direction. Fixed-length, 100-byte records are moved to a work area. Processing is synchronous.
INPUT   ACB    MACRF=(KEY,      All MACRF and OPTCD subparameters         x
               SEQ.IN)          specified are defaults and could have     x
                                been omitted.
 
RETRVE  RPL    ACB=INPUT,                                                 x
               AREA=IN,                                                   x
               AREALEN=100,                                               x
        .      OPTCD=(KEY,SEQ,                                            x
        .      SYN,NUP,MVE)
        .
LOOP    GET    RPL=RETRVE       This GET or identical GETs can be issued, x
                                with no change in the RPL, to retrieve    x
                                subsequent records in key sequence.
        LTR    15,15
        BNZ    ERROR
        .
        B      LOOP
ERROR   ...                     Request was not accepted, or failed.
        .
IN      DS     CL100            IN contains a data record after GET is    x
                                completed.

The records are retrieved in key sequence in a forward direction. No search argument has to be specified; VSAM is positioned at the first record in key sequence when the data set is opened, and the next record is retrieved automatically as each GET is issued. The branch to ERROR can be taken if the end of the data set is reached.

If the data set is a variable-length RRDS, supply the record length in the RECLEN field in the RPL.