MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to read the records from bottom to top

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
sivarao
Beginner


Joined: 21 Aug 2008
Posts: 6
Topics: 1

PostPosted: Mon Aug 25, 2008 7:14 am    Post subject: how to read the records from bottom to top Reply with quote

Hi ,

I would like to read the records from bottom to top through COBOL logic.
Assu that the file KSDS.

Regards,
Siva
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Mon Aug 25, 2008 1:39 pm    Post subject: Reply with quote

Can't be done with COBOL.

Take a look at using Assembler or File-Aid instead.
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Mon Aug 25, 2008 4:15 pm    Post subject: Reply with quote

I'm wondering why you would want to do this.

If you're processing every record, or most records, you could REPRO the KSDS to a flat file, sort it by the key in descending order, and code a COBOL pgm to process the resulting sorted file.

In theory, you could use a START KEY IS LESS THAN followed by a single READ. The key from each READ would then be used as the key in the next START KEY IS LESS THAN. I suspect the performance would be horrible. I would not recommend this option, but just mention it as a possibility.
Back to top
View user's profile Send private message
sivarao
Beginner


Joined: 21 Aug 2008
Posts: 6
Topics: 1

PostPosted: Mon Aug 25, 2008 11:51 pm    Post subject: Reply with quote

thanks for your suggestyions.
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Tue Aug 26, 2008 6:23 am    Post subject: Reply with quote

jsharon1248 wrote:
I'm wondering why you would want to do this.


I second this comment. sivarao, why would you want to do this?
Back to top
View user's profile Send private message
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Tue Aug 26, 2008 8:04 pm    Post subject: Reply with quote

If you really need to do this, this should work :

In your SELECT statement, use 'ACCESS IS SEQUENTIAL' :

Code:
FILE-CONTROL.                         
    SELECT VSAM-FILE ASSIGN TO VSAMFILE
       ORGANIZATION IS INDEXED         
       RECORD KEY IS VSAM-KEY         
       ACCESS IS SEQUENTIAL           
       FILE STATUS IS VSAM-STATUS.     


In the PROCEDURE-DIVISION, code:

Code:
OPEN INPUT  VSAM-FILE.                       
PERFORM UNTIL VSAM-STATUS  > '00'           
    READ VSAM-FILE   NEXT RECORD             
    DISPLAY 'NEXT RECORD: ' VSAM-RECORD 
END-PERFORM.                                 
CLOSE VSAM-FILE.         
Back to top
View user's profile Send private message
sivarao
Beginner


Joined: 21 Aug 2008
Posts: 6
Topics: 1

PostPosted: Wed Aug 27, 2008 1:37 am    Post subject: Reply with quote

I just wanted to check whether we can do this logic in COBOL.
any way thanks for your suggestions and code.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group