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


Example 9: keyed-direct update (KSDS, variable-length RRDS)

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

In this example, GET and PUT macros are used to retrieve and update records. The MODCB macro is used to modify record length (RECLEN) in the request parameter list when an update causes the record length to change. The maximum record length is 120 bytes. The search argument is a full key (5 bytes), compared equal.
INPUT   ACB    MACRF=(KEY,DIR,                                        x
               OUT)
 
UPDTE   RPL    ACB=INPUT,       UPD indicates the record may be       x
               AREA=IN,         stored back (or deleted).             x
               AREALEN=120,                                           x
               OPTCD=(KEY,DIR,                                        x
               SYN,UPD,KEQ,                                           x
               FKS,MVE),                                              x
               ARG=KEYAREA,                                           x
        .      KEYLEN=5
        .
Process input and get search argument into KEYAREA; proceed to retrieve a record:
LOOP    GET    RPL=UPDTE
        LTR    15,15
        BNZ    ERROR
 
        SHOWCB RPL=UPDTE,       Display the length of the record.      x
               AREA=RLNGTH,                                            x
               FIELDS=RECLEN,                                          x
               LENGTH=4
 
        LTR    15,15
        BNZ    CHECKO
Update the record. Does the update change the record's length?
        BE     STORE            No; length not changed.
 
        L      5,length         Yes; load new length into register 5.
 
        MODCB  RPL=UPDTE,       Modify length indication in the request x
               RECLEN=(5)       parameter list.
 
        LTR    15,15
        BNZ    CHECKO
STORE   PUT    RPL=UPDTE
        LTR    15,15
        BNZ    ERROR
        B      LOOP
ERROR   ...                    Request was not accepted, or failed.
 
CHECKO  ...                    Display or modification failed.
        .
IN      DS     CL120           Work area for retrieving, updating,     x
                               and storing a record.
KEYAREA DS     CL5             Search argument for retrieving a        x
                               record.
RLNGTH  DS     F               Area for displaying the length of a     x
                               retrieved record.

You cannot update records in the I/O buffer. A direct GET for update positions VSAM at the record retrieved, in anticipation of storing back (or deleting) the record. This positioning also allows you to switch to sequential access to retrieve the next record. VSAM releases exclusive control of a control interval when a PUT DIR is issued following a GET UPD request.

You do not have to store back a record that you retrieve for update, but, if you do not store it back before another retrieval, the current updates are lost.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014