z/OS DFSMS Using Data Sets
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Sequential Retrieval and Update

z/OS DFSMS Using Data Sets
SC23-6855-00

To sequentially retrieve and update records in an indexed sequential data set, take the following actions:

  1. Code DSORG=IS or DSORG=ISU to agree with what you specified when you allocated the data set, and MACRF=GL, MACRF=SK, or MACRF=PU in the DCB macro.
  2. Code a DD statement for retrieving the data set. The data set characteristics and options are as defined when the data set was allocated.
  3. Open the data set.
  4. Set the beginning of sequential retrieval (SETL).
  5. Retrieve records and process as required, marking records for deletion as required.
  6. Return records to the data set.
  7. Use ESETL to end sequential retrieval as required and reset the starting point.
  8. Close the data set to end all retrieval.

Using the data set allocated in Figure 1, assume that you are to retrieve all records whose keys begin with 915. Those records with a date (positions 13 through 16) before the current date are to be deleted. The date is in the standard form as returned by the system in response to the TIME macro, that is, packed decimal 0cyyddds. Overflow records can be logically deleted even though they cannot be physically deleted from the data set.

Figure 1 shows how to update an indexed sequential data set sequentially.

Figure 1. Sequentially Updating an Indexed Sequential Data Set
//INDEXDD   DD        DSNAME=SLATE.DICT,---
            ...
ISRETR      START     0
            DCBD      DSORG=IS
ISRETR      CSECT
            ...
            USING     IHADCB,3
            LA        3,ISDATA
            OPEN      (ISDATA)
            SETL      ISDATA,KC,KEYADDR    Set scan limit
            TIME      ,                    Today's date in register 1
            ST        1,TODAY
NEXTREC     GET       ISDATA               Locate mode
            CLC       19(10,1),LIMIT
            BNL       ENDJOB
            CP        12(4,1),TODAY        Compare for old date
            BNL       NEXTREC
            MVI       0(1),X'FF'           Flag old record for
                                            deletion
            PUTX      ISDATA               Return delete record
            B         NEXTREC
TODAY       DS        F
KEYADDR     DC        C'915'               Key prefix
            DC        XL7'0'               Key padding
LIMIT       DC        C'916'
            DC        XL7'0'
            ...
CHECKERR
 

Test DCBEXCD1 and DCBEXDE2 for error indication: Error Routines 

ENDJOB      CLOSE     (ISDATA)
            ...
ISDATA      DCB       DDNAME=INDEXDD,DSORG=IS,MACRF=(GL,SK,PU),      C
            ...       SYNAD=CHECKRR

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014