Tried to check. But it has no any option to understand that duplicate key was the reason
 
The value of errno may be set to:  ValueMeaningENOTWRITEThe file is not open for write operations.ETRUNCTruncation occurred on an I/O operation.EIOERRORA non-recoverable I/O error occurred.EIORECERRA recoverable I/O error occurred.
 
With duplicate key, _Rwrite sets errno to 3102 (EIORECERR - I/O exception recoverable error). I suppose _Rwrite can set such errno in many other cases. 
By the way, _Rreadk sets errno to 3102 when trying to read and lock the record that is locked by someone, so I think 3102 is much more general error description than my specific cause.
 
Regards
Alexei
 
-------- Original Message --------
Subject : [C400-L] _Rwrite and _RIOFB_T->dup_key
From    : Chris Hird chrish@xxxxxxxxxxxxxxxxxx
To      : Alexei Baranov <alexei.baranov@xxxxxxxxxx>, "Bare Metal Programming IBM i\
\
 (AS/400 and iSeries)" <C400-L@xxxxxxxxxxxxxxxxxx>
Cc      : 
Date    : Friday, December 13, 2024 16:43
Alex
Check errno if bytes written == 0. It will give you the reason. That way a successful write will not check for an error. 
Get Outlook for iOS 
From: Alexei Baranov <alexei.baranov@xxxxxxxxxx>
Sent: Friday, December 13, 2024 8:38:09 AM
To: Chris Hird <chrish@xxxxxxxxxxxxxxxxxx>; Bare Metal Programming IBM i (AS/400 and iSeries) <C400-L@xxxxxxxxxxxxxxxxxx>
Subject: Re: [C400-L] _Rwrite and _RIOFB_T->dup_key
 
Chris, bytes_written==0 points to a symptom - unable to write record to file, but I need to know the cause. exception_handler for _C2_MH_NOTIFY CPF5034 explain the reason - duplicate key.
Thank you for point to CHGMSG to remove message from the job log
-------- Original Message --------
Subject : [C400-L] _Rwrite and _RIOFB_T->dup_key
From    : Chris Hird chrish@xxxxxxxxxxxxxxxxxx
To      : "Bare Metal Programming IBM i (AS/400 and iSeries)" <C400-L@xxxxxxxxxxxxxxxxxx>
Cc      : 
Date    : Friday, December 13, 2024 16:30
Just check fp->bytes_written against what you expected to be written. Then use the CHGMSG API to remove from the job log?
Chris
Get Outlook for iOS<
https://aka.ms/o0ukef>
 
As an Amazon Associate we earn from qualifying purchases.