Page 1 of 1

Sorted but want to print all discarded records

PostPosted: Thu Dec 30, 2021 1:28 am
by Everlast
I have code with a primary and secondary sort that removes duplicates based on the primary. What I want to do is print out all the discarded records to another file.

SORT FIELDS=(1,9,CH,A,355,8,CH,A),EQUALS
OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,9),PUSH=(3501:SEQ=8))
OUTFIL BUILD=(1,3500),INCLUDE=(3501,8,ZD,EQ,1)


Any help is appreciated.

Thanks

Re: Sorted but want to print all discarded records

PostPosted: Thu Dec 30, 2021 11:47 pm
by sergeyken
DUPKEYS Control Statement

The DUPKEYS control statement is used to enable special processing for records with equal sort/merge control fields (keys). You can perform the following functions:

• Sum specified numeric fields, place the sum in one record and delete the other records with the same key (SUM)
• Compute the average of specified numeric fields, place the average in one record and delete the other records with the same key (AVG)
• Determine the minimum or maximum value of specified numeric fields, place this value in one record and delete the other records with the same key (MIN,MAX)
• Delete all but one of the records with equal keys (FIELDS=NONE)
• Retain only records with keys that occur more than once (ALLDUPS)
• Retain only the first record of those with keys that occur more than once (FIRSTDUP)
• Retain only the last record of those with keys that occur more than once (LASTDUP)
• Retain only the records with keys that occur only once (NODUPS)

The records deleted by DUPKEYS can optionally be written to a separate file.

The DUPKEYS control statement cannot be used with a SUM control statement, nor when FIELDS=COPY is specified on the SORT or MERGE control statement.

If you need to add other DUPKEYS functionality to an application with a SUM control statement, you must move the SUM specification to the DUPKEYS statement and remove the SUM statement. If XSUM was used, then XDUP should be specified and the JCL changed from using a SORTXSUM DD to a SORTXDUP DD.