My desired output file is to have only one of the first three records that start with 0, all of the records that start with 1 and only one of the last three records that start with 9, however that one last record needs to have the sum of the values that are represented in those records. Output data below:
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
From what you've shown, it would be possible to INCLUDE= for the "1"s, and use OUTFIL reporting featers, HEADER1,REMOVECC and create the header and trailers. There is a COUNT field available for TRAILERn, you can even modify it if you don't want to count header or trailer or both.
The date on your header depends what you want. One way would be a JPn symbol to take a PARM from the JCL if your SyncSORT supports it.
Another is to make a symbol file (dictionary SyncSORT calls them) from one step (OPTION STOPAFT=1) and use that in the second step. Other ways are hard-coding and more, depending on your actual requirement.
Isn't INCLUDE for '1's will lose all '9's for the TOT? also TS may need sum on the values associated with '9's instead of counting all '1's. please correct me.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
The header and trailer on the file can be ignored if they can be recreated. The trailer is easy. A 9, some blanks, and a TOT/TOTAL, adjusted if necessary. TRAILER1 can do that.
HEADER1 can do a header, it does need a source for the date-like bit of data.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Yes. That is the point of the INCLUDE. The original 9-type records are redundant. Only one of the three is required, and the data required for one is constant (according to the sample) plus a count of the records.
Count of the records in an OUTFIL group is what TOT/TOTAL does. So the entire trailer record can be generated by TRAILERn.
The header is constant plus-some-data. The only issuer for HEADERn is the source of plus-some-data.
Perhaps I should read the question again when I have time :-)
Three differently handled group of records do require three separate output files, within the same SYNCSORT step.
the TS ( Topic Starter ) requirement was
Quote:
My desired output file (*) is to have only one of the first three records that start with 0, all of the records that start with 1 and only one of the last three records that start with 9 ... ... ...
My desired output file (*) is to have only one of the first three records that start with 0, all of the records that start with 1 and only one of the last three records that start with 9 ... ... ...
1) The requirements was: "last record needs to have the sum of the values that are represented in those records".
Parameter TRAILER calculates the total number of type-1 records (that is 6 in this example), while it needs to summarize all the field values from type-9 records (that is 000000003+000000001+000000002=000000006).
2) Statement OMIT just eliminates all type-9 records on input; so there is nothing to summarize from type-9 as required.
Indeed, you're spot-on.
Yet, going by the data shared, it seemed that the 'number' present in the trailer was the count of records minus the header present. If you notice, there are 3 'xxx1' records, 2 'xxx2' records and 1 'xxx3' record. TS has not specified the significance of the number in trailer, since it matched my assumption, hence the usage of COUNT operator; though, it CAN be further trimmed with a bit more logic; kindly refer Mr. Woodger's earlier post which enunciates this.
I think,all that matter is # of passes and the least in either case is better otherwise both the solution should work, Unless TS is really serious and wants to confirm how trailer is to be determined COUNT/TOT choice would remain open point.