View previous topic :: View next topic
Author
Message
vissubhai New User Joined: 07 Nov 2007Posts: 12 Location: Hyderabad
Hi All... This is Viswanath. Nice to see various complex Sort problems here and their solutions. This stuff is great.
Coming to my problem I have an input file with as:
AAABBB3
AAABBB2
AAABBB4
BBBCCC1
BBBCCC5
BBBCCC2
XXXYYY7
XXXYYZ4
XXXYYZ3
And my output file should be as follows:
AAABBB4
BBBCCC5
XXXYYY7
XXXYYZ4
That is the output file should be sorted on first six fields and if there are any duplicates, they should be eliminated and the record which contains the largest value in seventh byte should be present.
Awaiting for the response.
Thanks in Advance,
Vissubhai.
Back to top
murmohk1 Senior Member Joined: 29 Jun 2006Posts: 1436 Location: Bangalore,India
Viswanath,
May be you are looking for this
Code:
//SORTIN DD *
AAABBB3
ZZZZZZ1
AAABBB2
AAABBB4
BBBCCC1
BBBCCC5
BBBCCC2
XXXYYY7
XXXYYZ4
ZZZZZZ3
XXXYYZ3
ZZZZZZ2
ZZZZZZ4
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,6,CH,A,7,1,CH,D)
OUTREC OVERLAY=(20:SEQNUM,8,ZD,RESTART=(1,6))
OUTFIL OMIT=(20,8,ZD,NE,+1),BUILD=(1,19)
/*
O/P:
Code:
AAABBB4
BBBCCC5
XXXYYY7
XXXYYZ4
ZZZZZZ4
i/p file lrecl assumed 19. Change according to your req.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Vissubhai,
Here's a DFSORT/ICETOOL job that will do what you asked for:
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,6,CH) FIRST USING(CTL1)
/*
//CTL1CNTL DD *
SORT FIELDS=(1,6,CH,A,7,1,CH,D)
/*
Back to top
vissubhai New User Joined: 07 Nov 2007Posts: 12 Location: Hyderabad
Thank you so much Frank and Murmohk1
You guyz Rock...
Back to top
Please enable JavaScript!