By your mention, I make a test........
Yes, you are right, the error is happen when the last one record needed delete.
As you described:
your code is reading the VSAM file next record and at end it is moving "Y" to SW-VSAMFIL-END flag. When the actual end of file occurs, this move will happen and since there is no branching happening and as a fall through, it will execute the code below, which is the delete record "DELETE JCVKYFPF". The condition just above this statement "IF YFPF-INS-DATE <= WA-L12D-DATE " may be true because of improper initialization of "YFPF-INS-DATE".
The test result re-generate the VSAM status key 23, and because the record has been
deleted, it will finish normal in the next time run.
I will pass this message and ask programmer to fix this logic problem.
Many thanks for your detail description and help !!!