What it means
DUPREC is RESP 14 with RESP2 150 on WRITE. It means the record's key already exists in the file, or in a path over the file that has the UNIQUEKEY attribute.
The default action is to end the task abnormally.
Typical causes
- The key being written already exists in the file.
- The WRITE goes through a path with the UNIQUEKEY attribute and the key already exists.
- On a coupling facility data table using the contention model, DUPREC is raised even if another task has read the record with that key for update.
How to fix it
- Test RESP after the WRITE and treat DUPREC as 'record already exists'.
- Check how the key is generated and whether it can repeat.
- Code RESP so the task does not end abnormally.
Example
Illustrative only; names and values are invented.
EXEC CICS WRITE FILE('CUSTFIL') FROM(WS-CUST) RIDFLD(WS-KEY)
RESP(WS-RESP) RESP2(WS-RESP2) END-EXEC
IF WS-RESP = DFHRESP(DUPREC)
MOVE 'CUSTOMER ALREADY EXISTS' TO MSGO
END-IF