Hello,
arya_starc wrote:...but getting output as single record only
'SUM FIELDS' does precisely that (and more) - it sums the fields and produces unique records basis the SORT key specified in 'SORT FIELDS' statement.
A quote from the DFSORT programming guide; have highlighted the relevant portion:
The SUM control statement specifies that, whenever two records are found with
equal sort or merge control fields, the contents of their summary fields are to be
added, the sum is to be placed in one of the records, and the other record is to be
deleted.
Since you have not shown what you had tried for OUTFIL/TRAILER1, it is difficult to recommend a correction for the RC- 16.
A hint:
a. Code a SORT FIELDS=COPY --> since you do not want records to be sorted, instead you just want a new summation record added
b. Use a simple OUTFIL REMOVECC, BUILD --> OUTFIL, to process output records prior getting written to outpit DS; REMOVECC, to remove carriage control character which will be inserted while using TRAILER1 reporting feature; BUILD to build the actual output
c. Couple this with TRAILER1 operator of OUTFIL, and TOTAL or TOT sub-operator of TRAILER1
Have a look at
DFSORT Application Programming Guide for detailed description of these operators.
If you're looking for a quick code snippet, search the aforementioned operators, there are hundreds of working examples for this.