| IBM MAINFRAME HELP & SUPPORT FORUMS Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
|
| View previous topic :: View next topic |
| Author |
Message |
SCARCEBOYZ
Joined: 16 May 2005
Posts: 24
Location: Millenium Business Park, Mumbai
|
| Posted: Tue Aug 05, 2008 6:04 pm Post subject: When first 3 records are matching then remove the duplicates |
|
|
Hello All,
I have a dataset -
Code: DUNS DSTBR CID CTRYCDE AMT
----------------------------------------------------
A B C CAN 4.0
A B C USA 0.89
A B C USA 4.00
000000000111111111122222222223333333333444444444455555555555
123456789012345678901234567890123456789012345678901234567890
My requirement is -
1-) When first three records are matching , then remove the duplicate entry.Keep USA entry only and remove CAN.
2-) In the above example, A, B, C are matching so I need to remove CAN entry here.
3-) To implement this I am writing 2 sort steps.In first I will sort the dataset in descending order so that USA entry comes first and then I will remove the duplicate in next step.
a-) First sort will change the order so that CTRY Code field is in descending order.
Code: //******************************************************
//*** ELIMINATE DUPLICATES OF TOTAL SALES
//***********************************************************
//STEP105 EXEC SORT,REGION=5M,
// COND=(4,LT)
//S.SORTIN DD DSN=I@X4113.FSDST01.FSDT114B.TOTAL.SALES,
// DISP=SHR
//S.SORTOUT DD DSN=I@X4113.FSDST01.FSDT114B.TOTAL.SALES.SORT,
// DISP=(,CATLG,DELETE),
// UNIT=SYSTEMP,
// SPACE=(CYL,(1000,120),RLSE),
// DCB=(LRECL=125,RECFM=FB,BLKSIZE=0)
//S.CNTL DD *
FIELDS=(1,11,A,12,10,A,22,10,A,51,3,D),FORMAT=CH,FILSZ=E500000
SORT FIELDS=COPY
END
//*
b-) To remove the duplicate entries
Code: //******************************************************
//*** ELIMINATE DUPLICATES ON TOTAL.SALES.SORT
//***************************************************************
//STEP106 EXEC SORT,REGION=5M,
// COND=(4,LT)
//S.SORTIN DD DSN=I@X4113.FSDST01.FSDT114B.TOTAL.SALES.SORT,
// DISP=SHR
//S.SORTOUT DD DSN=I@X4113.FSDST01.FSDT114B.TOTAL.SALES.SORT1,
// DISP=(,CATLG,DELETE),
// UNIT=SYSTEMP,
// SPACE=(CYL,(1000,120),RLSE),
// DCB=(LRECL=125,RECFM=FB,BLKSIZE=0)
//S.CNTL DD *
FIELDS=(1,11,A,12,10,A,22,10,A),FORMAT=CH,FILSZ=E500000
SUM FIELDS=NONE
END
//*
I just wanted to know if there is a way to perform this in one sort step instead of 2.Please help.
Regards,
Vivek |
|
| Back to top |
|
Frank Yaeger
Joined: 15 Feb 2005
Posts: 4613
Location: San Jose, CA
|
| Posted: Tue Aug 05, 2008 10:32 pm Post subject: |
|
|
Here's a DFSORT/ICETOOL job that will do what you want in one pass:
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,31,CH) FIRST USING(CTL1)
/*
//CTL1CNTL DD *
SORT FIELDS=(1,31,CH,A,51,3,CH,D)
/*
|
|
| Back to top |
|
| |
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM
|