I probably would be able to do this by summarizing and appending a count and then joining with the Original file testing on this count, but kind of hoping it could be a lot simpler.
I thought that if I had this working I could implement it in the existing sort, unfortunately I have no clue.
Sorry for slowfeeding the requirement, was hoping to be able to do it myself.
For those still willing : the Original file has a recordtype as well and a day in which order I need the output to be.
So I need the all the recordtypes 1 which have more then 1 occurrence in a month ordered by date
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Code:
SORT FIELDS=(1,13,A)
DUPKEYS NODUPS,XDUP
This will give you a SORTOUT with only records which had unique keys. All records for keys which were duplicate (two or more records same key) will be excluded.
The XDUP says write all the excluded records to the SORTXDUP DD.
However, this will not give you what you want (requirement creep), because you want to know if there are multiple records for a month, not for a day, which is what you are sorting on.
Another however, the sample data you show is already in order. If this is correct, then why SORT?
Change SORTIN DD to SORTIN01 DD, include SORTXDUP DD
Code:
MERGE FIELDS=(1,11,A)
DUPKEYS NODUPS,XDUP
However (yet again) I don't really understand where the record-type comes into it.
You can still have your two OUTFILs (you can specify SAVE instead of the INCLUDE= with NE) but your SORTXDUP DD will contain a mix of record-types.
You can try to work with that, or show sample output for your (representative) sample input. Include RECFM and LRECL.
I don't have access to SyncSort, so this is theoretical...
I'll give you some background on where the requirement comes from:
The file contains a lot of different info which is input for printing/analysis.
Data recordtype 1: Sales figures per region, month , supplier-begindate, supplier-enddate
Normally there Is only 1 supplier at a given time, but when there are 2 or more I need to do some businesslogic. (<= NEW functionality I'm building)
Code:
Supplier1 goes from 01/01/0001 => 21/1
Supplier2 goes from 14/1 => 99/99/9999
This involves remembering/storing stuff in working-storage arrays .
since this is only 1% of the input file I thought I would extract that 1% and use that as input,
Afterwards I would re-sort/concatenate my outputfile and the "discarded" rest of the input file for the next program.
So yes my Nodups-file contains all kind of things but I really only need them to pass them on.
I can not garantuee that the input file is in the correct order, I typed it so because that is the order in which the print-program (=the last/next program in the chain receives them)
I'll try to get the duplicates with the dupkeys , and re-sort that 1% on day-basis in 2 steps.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
GuyC,
Not sure if I got your problem right. The below Synctool writes all the duplicates for record-type=1 into the 'OUT' dd and the remaining records into the 'DIS' dd.