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 

Read file bottom to Top

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> CICS and Middleware
View previous topic :: View next topic  
Author Message
sanat
Beginner


Joined: 15 Feb 2003
Posts: 11
Topics: 7
Location: chennai

PostPosted: Mon Mar 03, 2003 2:09 am    Post subject: Read file bottom to Top Reply with quote

Hi,
I want to browse the file from bottom to top. But how do I set the file pointer to the last record of the file?

Sanat.
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Mar 03, 2003 7:22 am    Post subject: Reply with quote

sanat,

There are many ways to do it. Run a sort or file-aid step to reverse the file.If you have the file on a tape , you can use the clause REVERSED which will read the file from the last record.

SORT solution:
Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//SORTOUT  DD DSN=YOUR.OUTPUT REVERSED FILE,
//            DISP=(NEW,CATLG,DELETE),         
//            UNIT=SYSDA,                       
//            SPACE=(CYL,(X,Y),RLSE)       
//SYSIN DD *
  INREC FIELDS=(1,LRECL,SEQNUM,8,ZD)   $ TOTAL LRECL + 8 BYTE SEQNUM
  SORT FIELDS=(LRECL+1,8,ZD,D)         $ SORT ON SEQNUM DESC
  OUTREC FIELDS=(1,LRECL)              $ REMOVE THE SEQNUM
/*


FILE-AID solution:

Code:

//STEP0100 EXEC PGM=FILEAID                                 
//*                                                         
//SYSLIST  DD SYSOUT=*                                     
//SYSPRINT DD SYSOUT=*                                     
//SYSUDUMP DD SYSOUT=*                                     
//DD01     DD DSN=YOUR INPUT FILE,                         
//            DISP=SHR
//DD01O    DD DSN=OUTPUT.FILE,               
//            DISP=(NEW,CATLG,DELETE),         
//            UNIT=SYSDA,                       
//            SPACE=(CYL,(X,Y),RLSE),       
//            DCB=(RECFM=FB,LRECL=ZZZ,BLKSIZE=0)
//SYSIN    DD *                                             
$$DD01 COPYBACK,OUT=0
/*


COBOL solution:

Use the REVERSED option of the OPEN statement to process tape files in reverse order. Execution of the OPEN statement will then position the file at its end. Subsequent READ statements read the data records in reverse order, starting with the last record. The REVERSED option is supported only for files with fixed-length records.

Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Mon Mar 03, 2003 7:33 am    Post subject: Reply with quote

Hi sanat,

Why have you posted this question in the CICS forum. If you are trying to read a KSDS from a CICS application program from bottom to top, then move HIGH VALUES to the record key (RIDFLD parameter) in the STARTBR command which will position your pointer at the very last record. Use subsequent READPREV to read the file backwards.

If however, you are reading a file in batch, then you can use batch File-Aid as Kolusu has suggested.

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
sanat
Beginner


Joined: 15 Feb 2003
Posts: 11
Topics: 7
Location: chennai

PostPosted: Thu Mar 06, 2003 5:13 am    Post subject: Reply with quote

Hi Kolusu and Manas,
Thanks for the answers.
This was an interview ques.
Sanat.
Back to top
View user's profile Send private message Yahoo Messenger
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Thu Sep 11, 2008 7:44 am    Post subject: OUT=0 does not work. Reply with quote

Hi,

I tried the file-aid solution but it ends with RC 4 ! I got the below error message in sysout:

Code:

$$DD01 COPYBACK,OUT=0               
NO VALID FUNCTION FOUND IN ABOVE CARD
.....SKIPPING TO NEXT $$DD CARD     


Please suggest.

Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Mon Sep 15, 2008 4:17 am    Post subject: works like this Reply with quote

Hi,

I removed comma between CB and OUT and it worked for me.......

Code:

$$DD01 COPYBACK OUT=0


Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Sun Sep 28, 2008 4:39 pm    Post subject: Reply with quote

"This was an interview ques."
Interview questions should be posted in the Interview Q & A forum.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> CICS and Middleware 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