Posted: Wed Feb 16, 2005 5:17 am Post subject: Keeping the highest version for a key
Hi,
i need to keep the records with the highest version number for a particular key in my output.
My key starts at position 1 and is of lenghth 13 while the version number starts at position 14.
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Wed Feb 16, 2005 11:12 am Post subject:
Jeff,
The following DFSORT/ICETOOL jcl will give you the desired results. If you have syncsort at your shop then change the pgm name to synctool. I assumed that your input has the following attributes
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Thu Feb 17, 2005 8:39 am Post subject:
Quote:
But it is working for only those keys which are numeric.
i m not getting the desired result if the key is something like
.
jeff01,
I suggested the solution based on the sample data you provided. Since your key also had character data, the solution will not work. Try this JCL which takes care of the character data also.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Feb 17, 2005 12:53 pm Post subject:
Here's another way to do it with the new KEEPBASE parameter of DFSORT's ICETOOL available with z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004). For complete information on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
// DD DSN=*.T2,VOL=REF=*.T2,DISP=(OLD,PASS)
//OUT DD DSN=... output file
//TOOLIN DD *
* IN->T1: Last record with each 1,13 key - add '11' id at end
* IN->T2: Discarded records - add '22' id at end
SELECT FROM(IN) TO(T1) ON(1,13,CH) LAST DISCARD(T2) USING(CTL1)
* T1/T2->OUT: Splice records and first byte of id - omit records
* with '22' id. Remove id.
SPLICE FROM(CON) TO(OUT) ON(1,15,CH) -
WITHALL WITH(1,81) KEEPBASE KEEPNODUPS USING(CTL2)
/*
//CTL1CNTL DD *
SORT FIELDS=(1,13,CH,A,14,2,CH,A)
OUTFIL FNAMES=T1,OUTREC=(1,80,81:C'11')
OUTFIL FNAMES=T2,OUTREC=(1,80,81:C'22')
/*
//CTL2CNTL DD *
OUTFIL FNAMES=OUT,OMIT=(81,2,CH,EQ,C'22'),
OUTREC=(1,80)
/*
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum