z/OS DFSMS Macro Instructions for Data Sets
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Example 3: skip-sequential retrieval (KSDS, variable-length RRDS)

z/OS DFSMS Macro Instructions for Data Sets
SC23-6852-02

In this example, a GET macro is used to retrieve variable-length records synchronously. Records are processed in the I/O buffer. The search argument is full key, compared greater-than-or-equal; key length is 8 bytes.

The records are retrieved in key sequence, but some records are skipped. Skip-sequential retrieval is similar to keyed-direct retrieval, except that you must retrieve records in ascending sequence (with skips) rather than in a random sequence.

If the data set is a variable-length RRDS, specify the relative record number in the ARG field, and the record length in the RECLEN field in the RPL.
        GENCB  BLK=ACB,          VSAM gets an area in virtual storage   x
               DDNAME=INPUT,     to generate the access method control  x
               MACRF=(KEY,       block and returns the address in       x
               SKP,IN)           register 1.
 
        LTR    15,15
        BNZ    CHECK0
        LR     2,1
        GENCB  BLK=RPL,                                                 x
               ACB=(2),                                                 x
               AREA=RCDADDR,                                            x
               AREALEN=4,                                               x
               ARG=SRCHKEY,                                             x
               OPTCD=(KEY,SKP,                                          x
               SYN,NUP,KGE,                                             x
               FKS,LOC)
        LTR    15,15
        BNZ    CHECK0
        LR     3,1               Address of the request parameter list.
        .
LOOP    MVC    SRCHKEY,source    Search argument for retrieval, moved in
                                 from a table or a transaction record.
        GET    RPL=(3)
        LTR    15,15
        BNZ    ERROR
        SHOWCB AREA=RCDLEN,      Display the length of the record.      x
               FIELDS=RECLEN,                                           x
               LENGTH=4,                                                x
               RPL=(3)
 
        LTR    15,15
        BNZ    CHECK0
        .
        B      LOOP
ERROR   ...                      Request was not accepted, or failed.
CHECK0  ...                      Generation or display failed.
        .
RCDADDR DS     F                 Work area into which VSAM puts the     x
                                 address of a data record within the    x
                                 within the I/O buffer (OPTCD=LOC).
 
SRCHKEY DS     CL8               Search argument for retrieval.
 
RCDLEN  DS     F                 For displaying variable record lengths.
The macros and instructions are as follows:
  • The first GENCB generates an access method control block, which specifies keyed, skip-sequential, and input processing. The address of the access method control block is stored in register 2.
  • The second GENCB generates a request parameter list. The address of the request parameter list is stored in register 3.
  • MVC moves the search argument into SRCHKEY, the area defined for the search argument.
  • GET specifies that the record pointed at by the request parameter list whose address is in register 3 is to be retrieved. Records are retrieved by a skip-sequential search through the sequence set of the index.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014