File status 43: REWRITE or DELETE without a prior READ
File status 43 means a REWRITE or DELETE on a file in sequential access mode wasn't directly preceded by a successful READ. COBOL needs that READ to know which record to change.
Other names for this code
Also written as FS 43, file status code 43, COBOL status 43, VSAM status 43, REWRITE without READ, status key 43, SK43.
What it means
Status 43 is a logic error. In sequential access, REWRITE and DELETE act on the record most recently read. IBM requires the last input-output statement on that file before the REWRITE or DELETE to be a successful READ. If it wasn't, the statement fails with 43.
It applies to QSAM files on disk opened I-O, where REWRITE updates a record in place, and to indexed and relative files with ACCESS MODE SEQUENTIAL. With random or dynamic access, a REWRITE or DELETE on an indexed or relative file finds its record by key, so no prior READ is needed. Line-sequential files don't allow REWRITE or DELETE at all.
VSAM has a matching rule of its own. An update or erase without a prior GET for update gives register 15 = 8 with feedback code 92 (X'5C'). Under the older CMPR2 behavior, status 43 was reported as 92.
Common causes
- The READ before the REWRITE failed, with 10 or 46, and the program didn't check, so it went ahead with the REWRITE.
- Another statement on the same file ran between the READ and the REWRITE, such as a START or a failed READ, so the successful READ is no longer the last one.
- The program issued REWRITE twice for the same record.
- A file declared ACCESS MODE SEQUENTIAL is treated as random. The key is filled in and REWRITE or DELETE is issued without reading the record first.
How to find the problem
- DISPLAY the status of the READ that should come before the REWRITE or DELETE.
- List every statement that touches the file between that READ and the failing statement. A START, a failed READ or an earlier REWRITE or DELETE in between breaks the pairing. A successful look-ahead READ doesn't give 43, but the REWRITE then replaces the newer record.
- Check the ACCESS MODE in the SELECT clause.
How to fix it
- Only REWRITE or DELETE after a READ that returned a status starting with 0.
- Restructure look-ahead logic so the REWRITE always follows the READ of the same record.
- For keyed updates in any order, use ACCESS MODE RANDOM or DYNAMIC, where REWRITE and DELETE work by key.
IBM documentation
IBM Enterprise COBOL documentation. Use the documentation for your installed release.
This link opens the relevant IBM reference library or lookup instructions. Match the complete code and your installed product release; it is not a code-specific review.
Related codes
Questions
Does file status 43 apply in random access mode?
No. In random access, REWRITE and DELETE find the record by key, so they don't need a READ first.
What is the difference between 43 and 49?
49 means the file isn't open I-O, so updates aren't allowed at all. 43 means it is open I-O, but the REWRITE or DELETE didn't follow a successful READ.
Does a READ that returned 02 count as successful?
Yes. Any status starting with 0 is a successful READ, so a REWRITE after it is allowed.