View previous topic :: View next topic
|
Author |
Message |
v.suresh
New User
Joined: 29 Jun 2007 Posts: 5 Location: Bangalore
|
|
|
|
Hi Friends,
How to find whether the file is sorted or not in cobol?Plz give explanation with coding? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 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.
Code: |
01 WS-PREV-REC PIC X(??) VALUE SPACES.
01 WS-CURR-REC PIC X(??).
|
Code: |
READ FILE INTO WS-CURR-REC
IF WS-CURR-REC > WS-PREV-REC
THEN
MOVE WS-CURR-REC
TO WS-PREV-REC
ELSE
DISPLAY 'RECORDS NOT SORTED'
GOBACK
END-IF
|
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
v.suresh,
I would not advertise that you work for IBM, India, if I were you. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
When a file is sorted, it is usually sorted by one or more "sort keys" (rather than the entire record).
Code (similar to the example posted) needs to check "this" sort key(s) against the previous sort key(s) to detemine if the file is "in sequence". |
|
Back to top |
|
|
|