I have a requirement in which duplicate fields in a record as well as the whole file must be eliminated and the first one retained as well.
Each field is considered to be 6 bytes
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Escapa/Sambhaji,
You do NOT need to specify 6 blanks for the constant. You just need one blank. DFSORT will pad CH constants on the right with blanks to match the length of the field.
Code:
OMIT COND=(1,6,CH,EQ,C' ')
will work fine. This becomes important for fields with large lengths; for example, you wouldn't want to have to code 40 blanks for a 40-byte CH field.
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
The TS originally wanted the output as:
Code:
111111222222333333
555555
777777888888
in case the TS lost spacing, and wanted it like this:
Code:
111111222222333333
555555
777777888888
i created a little 19 part icetool job, to get what he wanted, and more.
though the return from Escapa's solution makes the most logic sense.
I have many sysouts used in debugging,
they and the TOOLIN operators used to populate can also be deleted.
I also added a few extra input items to check all my code.
also, in as a BUILD parm, what is the shortcut from
Code:
OUTFIL BUILD=(01,06,C' ',SEQNUM,8,ZD,C' 1B'/,
so the literal C'-with 24 spaces' can be shorter?
I have used symnames in the past, but there must be a shortcut notation.
I have also not bothered to show the output, this post is long enough.
for me, it was a nice, relaxing, coding experience.
Code:
//STEP0100 EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//SORTMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SORTIN DD *
222222111111333333111111
666666111111888888
666666444444555555222222
111111444444555555777777
333333666666
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(75,50)),
// DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(75,50)),
// DISP=(MOD,PASS)
//T3 DD DSN=&&T3,UNIT=SYSDA,SPACE=(CYL,(75,50)),
// DISP=(MOD,PASS)
//T4 DD DSN=&&T4,UNIT=SYSDA,SPACE=(CYL,(75,50)),
// DISP=(MOD,PASS)
//T5 DD DSN=&&T5,UNIT=SYSDA,SPACE=(CYL,(75,50)),
// DISP=(MOD,PASS)
//T6 DD DSN=&&T6,UNIT=SYSDA,SPACE=(CYL,(75,50)),
// DISP=(MOD,PASS)
//TA DD DSN=&&TA,UNIT=SYSDA,SPACE=(CYL,(75,50)),
// DISP=(MOD,PASS)
//SORTOUT DD SYSOUT=*
//SORTT1 DD SYSOUT=*
//SORTT2 DD SYSOUT=*
//SORTT3 DD SYSOUT=*
//SORTT4 DD SYSOUT=*
//SORTT5 DD SYSOUT=*
//SORTT6 DD SYSOUT=*
//SORTTA DD SYSOUT=*
//TOOLOUT DD SYSOUT=*
//SYSIN DD *
//TOOLIN DD *
* SPLIT INPUT INTO 4 RECORDS REF IS ALWAYS IN POS 1
COPY FROM(SORTIN) TO(T1) USING(CTL1)
* SPLIT INPUT INTO 4 RECORDS REF IS IN POS
COPY FROM(SORTIN) TO(TA) USING(CTLA)
*
* REMOVE DUPLICATES OF REF IN POS 1
COPY FROM(T1) TO(T2) USING(CTL2)
*
* SAVE THE TEMP DDS TO SYSOUT
COPY FROM(T2) TO(SORTT2) USING(CTL5)
COPY FROM(TA) TO(SORTTA) USING(CTL5)
*
* JOINKEYS, 4 RECORDS REF IS IN POS
COPY JKFROM TO(T3) USING(CTL3)
*
* SAVE THE TEMP DDS TO SYSOUT
COPY FROM(T3) TO(SORTT3) USING(CTL5)
*
SPLICE FROM(T3) TO(T4) ON(31,08,CH) WITHANY KEEPNODUPS-
WITH(01,6) WITH(07,6) WITH(13,6) WITH(19,6)
*
* SAVE THE TEMP DDS TO SYSOUT
COPY FROM(T4) TO(SORTT4) USING(CTL5)
*
* FORMAT WITHOUT LEFT JUSTIFY
COPY FROM(T4) TO(T5) USING(CTL7)
*
* FORMAT WITH LEFT JUSTIFY
COPY FROM(T4) TO(T6) USING(CTL8)
*
* SAVE THE TEMP DDS TO SYSOUT
COPY FROM(T5) TO(SORTT5) USING(CTL5)
COPY FROM(T6) TO(SORTT6) USING(CTL5)
/*
//CTLACNTL DD *
OPTION COPY
OUTFIL BUILD=(01,06,C' ',SEQNUM,8,ZD,C' 1A'/,
C' ',07,06,C' ',SEQNUM,8,ZD,C' 2A'/,
C' ',13,06,C' ',SEQNUM,8,ZD,C' 3A'/,
C' ',19,06,C' ',SEQNUM,8,ZD,C' 4A')
/*
//CTL1CNTL DD *
OPTION COPY
OUTFIL BUILD=(01,06,C' ',SEQNUM,8,ZD,C' 1B'/,
07,06,C' ',SEQNUM,8,ZD,C' 2B'/,
13,06,C' ',SEQNUM,8,ZD,C' 3B'/,
19,06,C' ',SEQNUM,8,ZD,C' 4B')
/*
//CTL2CNTL DD *
OMIT COND=(1,6,CH,EQ,C' ')
SORT FIELDS=(1,6,CH,A)
SUM FIELDS=(NONE)
/*
//CTL3CNTL DD *
*JOINKEYS
JOINKEYS F1=T2,FIELDS=(31,10,A)
JOINKEYS F2=TA,FIELDS=(31,10,A)
REFORMAT FIELDS=(F2:1,41)
/*
//CTL4CNTL DD *
SORT FIELDS=(35,10,CH,A)
/*
//CTL5CNTL DD *
OPTION COPY
/*
//CTL7CNTL DD *
OPTION COPY
INREC PARSE=(%01=(ABSPOS=1,FIXLEN=24)),
BUILD=(1:%01)
/*
//CTL8CNTL DD *
OPTION COPY
INREC PARSE=(%01=(ABSPOS=1,FIXLEN=24)),
BUILD=(1:%01,SQZ=(SHIFT=LEFT))
/*
What am I missing here ? The following DFSORT/JCL with 3 passes of data will give you the desired results. You don't have to use additional passes to route the temp files to sysout. You can use OUTFIL FNAMES and write out to multiples files at the same time.
pass1out and t1 will have output from the copy operation
pass2out and t2 will have output from the select operator removing the duplicates