Example 7: addressed-sequential addition (ESDS)

In this example, a PUT macro is used to add variable-length records to a data set. The data set is assumed to be an entry-sequenced data set, because records cannot be inserted into or added to a KSDS with addressed access.
BLOCK   ACB    MACRF=(ADR,SEQ,                                         x
               OUT)
 
LIST    RPL    ACB=BLOCK,                                              x
               AREA=NEWRCD,                                            x
               AREALEN=100,                                            x
               OPTCD=(ADR,SEQ,                                         x
        .      SYN,MVE)
        .
LOOP    ...                      Build the record.
        L      3,source          Put length of record into register 3.
 
        MODCB  RPL=LIST,         Indicate length of new record.        x
               RECLEN=(3)
 
        LTR    15,15
        BNZ    CHECKO
        PUT    RPL=LIST
        LTR    15,15
        BNZ    ERROR
        B      LOOP
CHECKO  ...                      Modification failed.
ERROR   ...                      Request was not accepted, or failed.
        .
NEWRCD  DS     CL100             Build record in this work area.

Each record is stored in the next position after the last record in the data set. You do not have to specify an RBA or do any explicit positioning (with the POINT macro). Addressed addition of records is identical to loading a data set: when additional space is required, VSAM extends the data set.

The only difference between addressed-sequential and addressed-direct addition is when the buffers are written to external storage. The buffer is written to external storage only when it is full for sequential addition; it is written after each record for direct addition. You cannot use direct storage to load records into a data set for the first time; you must use sequential storage.