Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DFSORT - SELECT Operator FIRST

Status
Not open for further replies.

rajesh082

Programmer
Dec 18, 2007
38
0
0
DK
Hi,

It's a long time I have written anything using the DFSORT and I am a little rusty.
My requirement is to get all the first occurences of duplicate records plus the single records.
In addition to this, I have to modify a flag for the duplicate records.

Input File:
Code:
Key       Flag   Balance      Extra fields
10001703        010100104     XXXXXXXXXXXX
10001745        010100104     XXXXXXXXXXXX
10002694        010100104     XXXXXXXXXXXX
11614135        069999999     XXXXXXXXXXXX
11614135        050000000     XXXXXXXXXXXX 
12299954        070000000     XXXXXXXXXXXX
12299954        090000000     XXXXXXXXXXXX

Output File:
Code:
Key       Flag   Balance      Extra fields
10001703        010100104     XXXXXXXXXXXX
10001745        010100104     XXXXXXXXXXXX
10002694        010100104     XXXXXXXXXXXX
11614135   1    069999999     XXXXXXXXXXXX
12299954   1    090000000     XXXXXXXXXXXX


This is what i have written:
Code:
SELECT FROM(SORTINP1) TO(SORTEMP1) ON(001,008,CH)                    -
                                   ALLDUPS                           -
                                   DISCARD(DISCARD1)                 -
                                   USING(CTL1)                        
SELECT FROM(SORTEMP1) TO(SORTOUT1) ON(001,008,CH)                    -
                                   FIRST               
                                   
//CTL1CNTL DD *                   
  SORT FIELDS=(001,008,CH,A,                                         -
               020,009,PD,A)
  INREC OVERLAY=(010:C'1')

And then I merge SORTOUT1 and DISCARD1 file.
This is working right now, but I just wanted to know if this ccan be done any simpler.


 
One way to eliminate duplicates using DFSORT is to specify:
SUM FIELDS=NONE
 
And to make sure that you get the first of the duplicates in your output use OPTIONS EQUAL. You can use OUTREC processing with IFTHEN to overlay the '1' on the required records. All in one execution of DFSORT - not ICETOOL


Nic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top