Sequential retrieval and update
To sequentially retrieve and update records in an indexed sequential data set, take the following actions:
- 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.
- Code a DD statement for retrieving the data set. The data set characteristics and options are as defined when the data set was allocated.
- Open the data set.
- Set the beginning of sequential retrieval (SETL).
- Retrieve records and process as required, marking records for deletion as required.
- Return records to the data set.
- Use ESETL to end sequential retrieval as required and reset the starting point.
- 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.
//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