Joined: 20 Oct 2006 Posts: 6967 Location: porcelain throne
to check whether a file is sorted or not, you have to compare the previous record to the current record. If the previous record (or the key portion of the record) <= the current record then the file is sorted.
01 WS-PREV-REC PIC X(??) VALUE SPACES.
01 WS-CURR-REC PIC X(??).
READ FILE INTO WS-CURR-REC
IF WS-CURR-REC > WS-PREV-REC
DISPLAY 'RECORDS NOT SORTED'