Is there any setting that will cause a READ NEXT after an AT END condition to return a status '10' AND execute the AT END condition.
so if;
READ NEXT AT END MOVE 1 TO WS-VALUE. <-------- IF THIS IS AN END OF FILE CONDITION
READ NEXT AT END MOVE 2 TO WS-VALUE. <-------- I WANT THIS TO RETURN STATUS '10' AND SET WS-VALUE TO 2
Thanks in advance for any help
why do you not use the file status
evaluate file-status
when 10
when 1
when 2
end-evaluate
Is there any setting that will cause a READ NEXT after an AT END condition to return a status '10' AND execute the AT END condition.
so if;
READ NEXT AT END MOVE 1 TO WS-VALUE. <-------- IF THIS IS AN END OF FILE CONDITION
READ NEXT AT END MOVE 2 TO WS-VALUE. <-------- I WANT THIS TO RETURN STATUS '10' AND SET WS-VALUE TO 2
Thanks in advance for any help
If I've followed you, I don't believe it's possible to do what you're asking. (Hoping others will chime in if they have ideas.)
For that first READ NEXT statement, hitting EOF will execute its AT END conditional branch, and set the file status to 10. According to the General Rules for the READ statement:
7. Following the unsuccessful execution of any READ statement, the contents of the associated record area are undefined and the file position indicator is set to indicate that no next record has been established.
From <https://www.microfocus.com/documentation/visual-cobol/vc70/EclUNIX/HRLHLHPDFB02.html>
Because of this, a second attempt to do a READ NEXT, causes a File Status 46:
46
A sequential READ operation has been tried on a file open in the INPUT or I-O mode but no valid next record has been established.
From <https://www.microfocus.com/documentation/visual-cobol/vc70/EclUNIX/HRFLRHFSTA01.html>
and the second READ statement's AT END clause is not triggered.
If I've followed you, I don't believe it's possible to do what you're asking. (Hoping others will chime in if they have ideas.)
For that first READ NEXT statement, hitting EOF will execute its AT END conditional branch, and set the file status to 10. According to the General Rules for the READ statement:
7. Following the unsuccessful execution of any READ statement, the contents of the associated record area are undefined and the file position indicator is set to indicate that no next record has been established.
From <https://www.microfocus.com/documentation/visual-cobol/vc70/EclUNIX/HRLHLHPDFB02.html>
Because of this, a second attempt to do a READ NEXT, causes a File Status 46:
46
A sequential READ operation has been tried on a file open in the INPUT or I-O mode but no valid next record has been established.
From <https://www.microfocus.com/documentation/visual-cobol/vc70/EclUNIX/HRFLRHFSTA01.html>
and the second READ statement's AT END clause is not triggered.
Thank you both for your help. I appreciate it,