Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to check whether the file is sorted or not?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
v.suresh

New User


Joined: 29 Jun 2007
Posts: 5
Location: Bangalore

PostPosted: Tue Aug 28, 2007 6:46 pm    Post subject: How to check whether the file is sorted or not?
Reply with quote

Hi Friends,

How to find whether the file is sorted or not in cobol?Plz give explanation with coding?
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Tue Aug 28, 2007 6:56 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Tue Aug 28, 2007 6:58 pm    Post subject:
Reply with quote

v.suresh,

I would not advertise that you work for IBM, India, if I were you.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Aug 28, 2007 7:11 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us