View previous topic :: View next topic
Author
Message
cima New User Joined: 22 Mar 2006Posts: 8
Hi all,
I'd like to know if its possible to sort a file, where the keys are not always on the same position.
example:
Input:
ID001.................ID002................ID003 ..10 ....................
ID001.................ID003 ..07 ..............ID004......................
ID001.................ID003 ..02 ..............ID004......................
ID001.................ID002................ID003 ..01 ....................
Output:
ID001.................ID002................ID003..01 ....................
ID001.................ID003..02 ..............ID004......................
ID001.................ID003..07 ..............ID004......................
ID001.................ID002................ID003..10 ....................
Problem: In ID003, there is a subkey (two-digit) which I'd like to sort. However, ID003's position is variable because not all IDs are always present, like the 2nd record, where ID002 is omitted.
Is sorting in this case possible?
Thanks,
cima
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
cima,
Assuming your input is FB recfm and LRECL of 80 , use the following DFSORT JCL which will give you the desired results
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ID001.................ID002................ID003..10...............
ID001.................ID003..07............ID004...................
ID001.................ID003..02............ID004...................
ID001.................ID002................ID003..01...............
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC PARSE=(%00=(STARTAFT=C'ID003..',FIXLEN=2)),BUILD=(1,80,%00)
SORT FIELDS=(1,5,CH,A,81,2,CH,A)
OUTREC BUILD=(1,80)
//*
Back to top
cima New User Joined: 22 Mar 2006Posts: 8
Hi Skolusu,
Thanks for the reply..
Actually its VB and LRECL 29998.. Also the 2 DOTS between ID003 and the 2digit Subkey are just fillers.. They have values like:
ID003 AB 02 abcdefg1234ID004
ID003 CD 07 asdfjkl12341ID004
The bluemarked text can have different values..
Sorry for the incomplete infos..
Thanks,
cima
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
cima wrote:
Hi Skolusu,
Thanks for the reply..
Actually its VB and LRECL 29998.. Also the 2 DOTS between ID003 and the 2digit Subkey are just fillers.. They have values like:
Sorry for the incomplete infos..
Thanks,
cima
Cima,
It would save a lot of time , if you are clear with your requirements. Anyway use the following control cards which will give you the desired results.
Code:
//SYSIN DD *
INREC PARSE=(%00=(STARTAFT=C'ID003',FIXLEN=4)),BUILD=(1,4,%00,5)
SORT FIELDS=(9,5,CH,A,7,2,CH,A),EQUALS
OUTREC BUILD=(1,4,9)
//*
Back to top
Please enable JavaScript!