View previous topic :: View next topic
|
Author |
Message |
rmd3003
New User
Joined: 03 Jul 2006 Posts: 55
|
|
|
|
I knwo how to do what i need in two steps but maybe SORT gurus can show me if it's possible in one step.
I have one input file
Code: |
ITEM TYPE
----+----1----+----2----+----3----+----4----+----5----+--
111110003801049 9361COV11111FOV03611111TD 11111111 10
111110003801049 9361COV11111FOV03611111TD 11111111 20
111110003801049 9361COV11111FOV03611111TD 11111111 30
111110003801049 9361COV11111FOV03611111TD 11111111 30
222220003801049 9361COV11111FOV03611111TD 21111111 10
222220003801049 9361COV11111FOV03611111TD 21111111 20
333330003801049 9361COV11111FOV03611111TD 31111111 10
333330003801049 9361COV11111FOV03611111TD 31111111 20
333330003801049 9361COV11111FOV03611111TD 31111111 30 |
Key is - ITEM in pos ITEM(1:15). There is another field which i have to use - TYPE in pos (77:2).
I want to see on my output only one record with TYPE = '10' if there is no matching TYPE='30' record within group.
Basically from test data above i have to have on my output file only one record because this group doesn't have matching record TYPE='30'
Code: |
ITEM TYPE
----+----1----+----2----+----3----+----4----+----5----+--
222220003801049 9361COV11111FOV03611111TD 21111111 10
|
|
|
Back to top |
|
|
rmd3003
New User
Joined: 03 Jul 2006 Posts: 55
|
|
|
|
That's how I did it.
First step using this control:
Code: |
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,15,CH) USING(CTL1) LAST
//CTL1CNTL DD *
INCLUDE COND=(77,2,CH,NE,C'20') |
Second step eliminated all TYPE '30's records
Code: |
SORT FIELDS=COPY
INCLUDE COND=(77,2,CH,EQ,C'10') |
|
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT/ICETOOL job that does in one pass what you're doing in two passes. Since your input records appear to already be in sorted order, I used OPTION COPY to do a COPY for the SELECT instead of a SORT:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//OUT DD DSN=... output file
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,15,CH) USING(CTL1) LAST
/*
//CTL1CNTL DD *
OPTION COPY
INCLUDE COND=(77,2,CH,NE,C'20')
OUTFIL FNAMES=OUT,INCLUDE=(77,2,CH,EQ,C'10')
/*
|
|
|
Back to top |
|
|
rmd3003
New User
Joined: 03 Jul 2006 Posts: 55
|
|
|
|
Frank, thanks a lot. Yes you are right, file comes presorted.
Dummy me, how I couldn't figure it out, it's so simple...... |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
Dummy me, how I couldn't figure it out, it's so simple...... |
Actually, I was impressed with the logic of your solution. Doing it in one pass was just extra credit. |
|
Back to top |
|
|
|