DELETE ACB MACRF=(KEY,DIR, x
OUT)
LIST RPL ACB=DELETE, x
AREA=WORK, x
AREALEN=50, x
ARG=KEYFIELD, x
OPTCD=(KEY,DIR, x
. SYN,UPD, UPD indicates deletion. x
. MVE,FKS, x
. KEQ)
.
LOOP MVC KEYFIELD,source Search argument for retrieval, x
from table or transaction record.
GET RPL=LIST
LTR 15,15
BNZ ERROR
Decide whether to delete the record:
BE LOOP No; retrieve the next record.
ERASE RPL=LIST Yes; delete the record.
LTR 15,15
BNZ ERROR
B LOOP
ERROR ... Request not accepted, or failed.
WORK DS CL50 Examine the data record here.
KEYFIELD DS CL5 Search argument.
When you retrieve a record for deletion (OPTCD=UPD, same as retrieval for update), VSAM is positioned at the record retrieved, in anticipation of a succeeding ERASE (or PUT) request for that record. However, you are not required to issue such a request. Another GET request nullifies any previous positioning for deletion or update.
Keyed-sequential retrieval for deletion varies from direct in that it does not use a search argument (except for possible use of the POINT macro). Skip-sequential retrieval for deletion (OPTCD=(SKP,UPD)) has the same effect as direct, but it is faster or slower depending on the number of control intervals separating the records being retrieved.