If you have got FILEAID, you can do it quite easily:
//STEP002 EXEC PGM=FILEAID
//SYSPRINT DD SYSOUT=*
//DD01 DD DSN=userid.input.file,DISP=SHR
//DD01O DD DSN=userid.output.file,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(1,1),RLSE),
// DCB=(RECFM=FB,LRECL=82)
//DD02 DD DSN=*.DD01,DISP=SHR
//DD02O DD DSN=*.DD01O,DISP=(MOD,KEEP,KEEP),
// VOL=REF=*.DD01O
//SYSIN DD *
$$DD01 COPY OUT=1
$$DD02 COPYBACK OUT=1
/*
If you don't have FILEAID, SYNCTOOL (or ICETOOL) too can be used, taking advantage of the FIRST and LAST options for duplicates:
//STEP0100 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//SSMSG DD SYSOUT=*
//IN1 DD DSN=userid.input.file,DISP=SHR
//TEMP1 DD DSN=&TEMP1,DISP=(,PASS),SPACE=(CYL,(2,2),RLSE)
//TEMP2 DD DSN=&TEMP2,DISP=(,PASS),SPACE=(CYL,(2,2),RLSE)
//TEMP3 DD DSN=&TEMP3,DISP=(,PASS),SPACE=(CYL,(2,2),RLSE)
//TEMP4 DD DSN=*.TEMP2,DISP=(OLD,PASS),VOL=REF=*.TEMP2
// DD DSN=*.TEMP3,DISP=(OLD,PASS),VOL=REF=*.TEMP3
//OUT1 DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) USING(CNT1)
SELECT FROM(TEMP1) TO(TEMP2) ON(601,1,CH) FIRST
SELECT FROM(TEMP1) TO(TEMP3) ON(601,1,CH) LAST
COPY FROM(TEMP4) USING(CNT2)
//CNT1CNTL DD *
* Adding a constant at the end of the record structure, on which
* we can sort the entire file; ensuring duplicates. Now we just
* need to extract the first and the last duplicates!
OUTFIL FNAMES=TEMP1,OUTREC=(1,600,C'1')
//CNT2CNTL DD *
* Remove the constant that was temporarily added.
OUTFIL FNAMES=OUT1,OUTREC=(1,600)
/*
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.