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


Example 4: keyed-sequential insertion (fixed-length RRDS)

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

In this example, a PUT macro is used to insert twenty 100-byte records into empty slots of a previously loaded fixed-length RRDS. If the slot is empty when the PUT is issued, the record is stored and the slot number (returned in the argument field) is stored in a table. If the slot is not empty when the PUT is issued, a duplicate record error indication is returned. When a duplicate record is indicated, the PUT is reissued until the record is successfully stored in an empty slot in the data set.
OUTACB  ACB    MACRF=(KEY,SEQ,                                         x
        .      OUT)
        .
        GENCB  BLK=RPL,         Generate a request parameter list.     x
               ACB=OUTACB,                                             x
               AREA=WORK,                                              x
               AREALEN=100,                                            x
               ARG=RCDNO,                                              x
               OPTCD=(KEY,SEQ)
 
        LTR    15,15
        BNZ    GENERR
        LR     6,1              Save the address of the RPL.
        LA     4,RRNTBLE+80     Initialize address of end of table.
 
        LA     3,RRNTBLE        Initialize index to relative record    x
                                number table.
WRITERCD ...                    Move record into work area.
         .
         .
        PUT    RPL=(6)
        LTR    15,15
        BZ     STRCDNO          Branch, if PUT is successful.
        LA     10,8
        CLR    10,15            Test for logical error.
        BNE    PUTERR
        TESTCB RPL=(6),FDBK=8,  Test for duplicate record.             x
               ERET=TESTERR
 
        BE     WRITERCD         Branch, if duplicate record, and try   x
                                to store record in next slot.
        B      PUTERR
STRDCNO        ...
        MVC    0(4,3)RCDNO      Store relative record number in        x
                                RRNTABLE.
        LA     3,4(3)           Increment to next table entry.
        CLR    3,4
        BE     RETURN           If table full, return to caller.
        B      WRITERCD         Write next record.
 
GENERR  ...                     Error routine for GENCB macro.
 
TESTERR ...                     Error routine for TESTCB macro.
PUTERR  ...                     Error routine for PUT macro.
 
RETURN  ...                     Return to caller or terminate program.
 
RCDNO   DS     CL4              4-byte relative record number          x
                                (argument) field.
RRNTBLE DS     20F              Relative record number table.
 
WORK    DS     CL100            100-byte work area that contains       x
                                record to be stored by PUT macro.

Each record is stored in the next available slot in the data set. When a record is successfully stored, its relative record number is recorded in a table.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014