View previous topic :: View next topic
Author
Message
ovreddy Active User Joined: 06 Dec 2004Posts: 211 Location: Keane Inc., Minneapolis USA.
Hi All,
I want to sort only first 2 columns of a Dataset. But not the entire record using DFSORT.
The input is as follows...
103 Raju 5000
102 Raghu 4600
101 Renu 7800
Output should be as follows....
101 Renu 5000 (Last column is not sorted)
102 Raghu 4600
103 Raju 7800
Please let me know the option with an exmple to do this.
Thanks,
Reddy.
Back to top
MGIndaco Active User Joined: 10 Mar 2005Posts: 432 Location: Milan, Italy
Can this work for your needs?
Code:
//STEP010S EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=B
//TOOLMSG DD SYSOUT=B
//DFSPARM DD *
ABEND
//IN1 DD *
103 RAJU 5000
102 RAGHU 4600
101 RENU 7800
//T1 DD SPACE=(CYL,(1,1),RLSE),DSN=&&T1
//T2 DD SPACE=(CYL,(1,1),RLSE),DSN=&&T2,DISP=(MOD,PASS)
//OU1 DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(T1) TO(T2) USING(CTL2)
COPY FROM(IN1) TO(T2) USING(CTL3)
SPLICE FROM(T2) TO(OU1) ON(81,5,ZD) -
WITHEACH WITH(11,5) USING(CTL4)
//CTL1CNTL DD *
INREC FIELDS=(1,10,70X)
SORT FIELDS=(1,3,CH,A,5,6,CH,A)
//CTL2CNTL DD *
INREC FIELDS=(1,80,81:SEQNUM,5,ZD)
//CTL3CNTL DD *
INREC FIELDS=(10X,11,70,81:SEQNUM,5,ZD)
//CTL4CNTL DD *
OUTFIL FNAMES=OU1,BUILD=(1,80)
I suppose that there are other method but I hope in this suggest.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Reddy,
Here's a better way to do it with DFSORT/ICETOOL. I assumed your input file has RECFM=FB and LRECL=80, but you can change the job appropriately for other attributes.
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=... output file (FB/80)
//TOOLIN DD *
* IN->T1: Sort by field1 and field2 and add seqnums.
SORT FROM(IN) TO(T1) USING(CTL1)
* IN->T1: Copy field3 and add seqnums.
COPY FROM(IN) TO(T1) USING(CTL2)
* T1->OUT: Splice field1 and field2 from sort with
* field3 from copy. Remove seqnums.
SPLICE FROM(T1) TO(OUT) ON(81,8,ZD) WITH(11,4) USING(CTL3)
//CTL1CNTL DD *
SORT FIELDS=(1,3,CH,A,5,5,CH,A)
OUTREC OVERLAY=(81:SEQNUM,8,ZD)
/*
//CTL2CNTL DD *
OUTREC OVERLAY=(81:SEQNUM,8,ZD)
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,BUILD=(1,80)
/*
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Reddy,
In the future, please ask DFSORT questions in the "VSAM and DFSORT" topic rather than in the JCL topic.
Back to top
Please enable JavaScript!