View previous topic :: View next topic
|
Author |
Message |
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
I have 5 records in a PS file. How can we write it in a file in the reverse order using SORT.
Sample Input File :
KEVIN
SMITH
JAMES
JONE
ANTONY
Expected Output File :
ANTONY
JONE
JAMES
SMITH
KEVIN
Input file need not be in sorted order. But we have to reverse the contents.
Regards
R KARTHIK |
|
Back to top |
|
|
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
Hi,
I got the code from previous forums.
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
* Add seqnum.
INREC OVERLAY=(81:SEQNUM,8,ZD)
* Sort on seqnum descending.
SORT FIELDS=(81,8,ZD,D)
* Remove seqnum.
OUTREC BUILD=(1,80)
/*
|
|
|
Back to top |
|
|
Vasukip Currently Banned New User
Joined: 17 Jun 2008 Posts: 48 Location: Chennai
|
|
|
|
Hi Can you explain this code ? you said the Input file is not in sorted order ,without sorting do we have to reverse the data ? |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
vasu,
Quote: |
Hi Can you explain this code |
INREC OVERLAY=(81:SEQNUM,8,ZD) - 8 byte sequence no is overlaid in the 81st column. so first record wud have 00000001, second record 00000002, third record 00000003 and so on
SORT FIELDS=(81,8,ZD,D) - then sorting is done based on the sequence no (descending order)
OUTREC BUILD=(1,80) - seq no's are removed
comments are there in the code.
Quote: |
you said the Input file is not in sorted order ,without sorting do we have to reverse the data ? |
data is not reversed the order of the records is reversed. |
|
Back to top |
|
|
Vasukip Currently Banned New User
Joined: 17 Jun 2008 Posts: 48 Location: Chennai
|
|
|
|
Hello Six,
Thank you so much for ur gr8 expalnation ! I'm a novice Mainframe- Developer . |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Vasu,
Not a problem and you are welcome. |
|
Back to top |
|
|
|