gomu_mm
New User
Joined: 05 Dec 2006 Posts: 19 Location: Chennai
|
|
|
|
Hi,
I have a file. I need to sort the file based on two field.
0001SGHP
0002SGDD
0003SGDP
0004SGHD
I want the file to be sorted on column 8 to have all 'P' first and then 'D'.
Then the file should be sorted to have SGHP, SGDP, SGDD and last SGHD. Basically the file should be in order
SGHP
SGDP
SGDD
SGHD
Thanks,
Gomathi. |
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can use a DFSORT job like the following to do what you asked for:
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
0001SGHP
0002SGDD
0003SGDP
0004SGHD
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=(5,4,CH,EQ,C'SGHP'),OVERLAY=(81:C'0')),
IFTHEN=(WHEN=(5,4,CH,EQ,C'SGDP'),OVERLAY=(81:C'1')),
IFTHEN=(WHEN=(5,4,CH,EQ,C'SGDD'),OVERLAY=(81:C'2')),
IFTHEN=(WHEN=(5,4,CH,EQ,C'SGHD'),OVERLAY=(81:C'3'))
SORT FIELDS=(8,1,CH,D,81,1,CH,A)
OUTREC BUILD=(1,80)
/*
|
Note that you would get the same result by just sorting on the second field. |
|