View previous topic :: View next topic
|
Author |
Message |
dbecker
New User
Joined: 23 Feb 2009 Posts: 11 Location: Jefferson City MO
|
|
|
|
Here is what I need to do. First 4 bytes in file are M2## followed by a 13 byte numeric.
Example..
Code: |
M2031111111111111
M2041111111111111
M2091111111111111
M2091111111111111
M2091111111111111
M2101111111111111
M2131111111111111
M2191111111111111
M2191111111111111
M2191111111111111
M2191111111111111
M2191111111111111
M2191111111111111
M2191111111111111
M2191111111111111
M2191111111111111
M2191111111111111
M2191111111111111
M2191111111111111
M2032222222222222
M2042222222222222
M2042222222222222
M2132222222222222
M2192222222222222
M2192222222222222
M2192222222222222
M2192222222222222
M2192222222222222
M2192222222222222
M2192222222222222
M2192222222222222
M2192222222222222
M2192222222222222
|
I need to be able to sort these records by the 13 byte numeric starting in column 5 and then sort by the first 4 bytes. Here is the kicker....I need the first 4 bytes sorted in order so that M201, then M202, then M203..etc etc.....BUT I need M204 to always be last and not after M203. I know one could modify the file and change all M204 in pos 1 - 4 to M299 and then sort and then change back to M204. I was hoping there would be a way to do this in a single shot using syncsort.....but I'm not coming up with anything in my search and reading.
Thanks. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
Quote: |
I know one could modify the file and change all M204 in pos 1 - 4 to M299 and then sort and then change back to M204. |
inrec change M204 to M299 -sort- outrec change back to M204 |
|
Back to top |
|
|
dbecker
New User
Joined: 23 Feb 2009 Posts: 11 Location: Jefferson City MO
|
|
|
|
Could you elaborate.....would that be via the FINDREP command you are talking about? |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
Code: |
//SORTIN DD *
M2031111111111111
M2041111111111111
M2091111111111111
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC FINDREP=(INOUT=(C'M204',C'M999'))
SORT FIELDS=(1,4,CH,A)
OUTREC FINDREP=(INOUT=(C'M999',C'M204'))
/* |
|
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
FINDREP doesn't look to be a clean solution, for me at least. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
The swap-in/swap-out is fine as long as the value being changed-to does not exist in the input data.
The FINDREP is... overly dramatic. Just simple IFTHEN=(WHEN=logicalexpression with OVERLAY. |
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
I second Bill and pandora..
This can be easily achieved with IFTHEN and OVERLAY
Thanks and regards,
Chandan |
|
Back to top |
|
|
|