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 

Reverse a file in JCL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
Abhi
Beginner


Joined: 03 Dec 2002
Posts: 21
Topics: 4
Location: India, Pune

PostPosted: Fri May 16, 2003 2:27 pm    Post subject: Reverse a file in JCL Reply with quote

There is a file say in the order 1 to 10 and I want it reversed in the order of 10 to 1.
I think it is possible thru FILE-AID (batch) but in the meanwhile if anyone can suggest another way to do this in a JCL. We have SYNCSORT resident at our site in case someone has a solution using SORT.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Fri May 16, 2003 4:13 pm    Post subject: Reply with quote

Abhi,
The following JCL will give you the desired results.I am assuming that your input file is lrecl is 80. we add a seqnum for each record and sort on that seqnum descending.By doing so the order will be reversed. While writting the output we remove the seqnum.

Code:

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


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Abhi
Beginner


Joined: 03 Dec 2002
Posts: 21
Topics: 4
Location: India, Pune

PostPosted: Mon May 19, 2003 11:08 pm    Post subject: Reply with quote

Thanks Kolusu.
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 -> Job Control Language(JCL) 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