View previous topic :: View next topic
|
Author |
Message |
aditya_gorti
New User
Joined: 21 Dec 2005 Posts: 19
|
|
|
|
Hi,
I have a file with the following layout
lrecl=22
Input data:
0000000000100000000001
0000000000400000000003
0000000000500000000009
0000000000600000000002
I need the output as:
0000000000100000000001
0000000000400000000002
0000000000500000000003
0000000000600000000009
I need the first 11 to be sorted independently and then the 2 11 bytes independently.
This might be a very silly question.. Can you please help me?
Thanks
Adi |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Why is it desirable to swap values between the records?
If you explain just what this is to accomplish, we (i) might be better able to suggest something. |
|
Back to top |
|
|
aditya_gorti
New User
Joined: 21 Dec 2005 Posts: 19
|
|
|
|
The 22 bytes are actually 2 different sets of keys which are combined..
I need to get the max vaue of first key(position 1-11) and also the maximum of 2nd key (position 12-22) to be used further..
I was thinking of icetool to split the keys into separate files and then merging them back.. but was not sure if there was an easier way to do it.. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Add a sequence number before sort -> Step 1
Add a sequence number after sort -> Step 2
Join output of Step 1 & Step 2 based on Sequence number
You would get the desired results |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
How many pairs of keys will be processed? |
|
Back to top |
|
|
aditya_gorti
New User
Joined: 21 Dec 2005 Posts: 19
|
|
|
|
Only 2 sets of keys. One from the 1st 11 bytes and 1 key from 2nd 11 bytes.. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Only 2 sets of keys. |
Your original post shows 4 sets of keys.
How many will there be "for real"? |
|
Back to top |
|
|
aditya_gorti
New User
Joined: 21 Dec 2005 Posts: 19
|
|
|
|
I am sorry.. there would be close to 1.5 million sets of keys.. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I am sorry.. there would be close to 1.5 million sets of keys.. |
Not to worry
Might take a couple of iterations, but we get there
If all you want is the 2 highest values (regardless of which "other" value), suggest you consider a tiny bit of Easytrieve or COBOL code.
This code would read each record only once and if the incoming value was greater than the previous "highest value", store it. There would be 2 "highest values - left side and right side.
Only 1 pass of the data and no sorting to find the "winners". |
|
Back to top |
|
|
aditya_gorti
New User
Joined: 21 Dec 2005 Posts: 19
|
|
|
|
Yupp probably I will just do it in a cobol program..
Thank you! |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
use the following DFSORT JCL which will give you the desired results. The trick here is to use the same file twice but treating the keys differently using JNF1 and JNF2
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
0000000000100000000001
0000000000400000000003
0000000000500000000009
0000000000600000000002
//INB DD *
0000000000100000000001
0000000000400000000003
0000000000500000000009
0000000000600000000002
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS F1=INA,FIELDS=(1,12,A)
JOINKEYS F2=INB,FIELDS=(1,12,A)
REFORMAT FIELDS=(F1:1,12,F2:1,12,?)
JOIN UNPAIRED
INREC BUILD=(2,11,14,11,X,SEQNUM,8,ZD,RESTART=(25,1))
SORT FIELDS=(24,8,CH,A),EQUALS
OUTREC IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(1,11))
OUTFIL OMIT=(12,1,CH,EQ,C' '),BUILD=(1,22)
//*
//JNF1CNTL DD *
INREC BUILD=(C'1',1,11)
//*
//JNF2CNTL DD *
INREC BUILD=(C'2',12,11)
//* |
|
|
Back to top |
|
|
|