It is tough to provide solutions with least details. You haven't mentioned anything about
1. The LRECL or RECFM of the Input/Output file
2. The length of each field to be summed.
3. The format of the field to be summed is it display or binary zoned decimal or packed decimal fields?
Assuming your input is display numeric fields(SFF) format, you can follow the below steps to get the desired results.
1. Create Key + 4slots of Packed decimal zeros and put the numeric values at the end say pos 81.
2. Use INREC IFTHEN to check for the values at position 81 for the length of the each field to find a space or plus sign for positive numeric values and then OVERLAY the 1 zero packed decimal slot with the value at 81 treating it as SFF and code HIT=NEXT for validating all the fields
3.Use another IFTHEN to check for the values at position 81 for the length of the each field to find a minus sign for negative numeric values and then OVERLAY the 2nd zero packed decimal slot with the value at 81 treating it as SFF and code HIT=NEXT for validating all the fields
4. Repeat step 2 and 3 for the next field which is at 87.
5. Sort on the key
6. SUM on the 4 PD slots
7. Using OUTREC convert the PD fields to readable format using edit masks
Thank you... the sample I've provided is not actual data - I need just idea for totals... it could be recfm=fb. lrecl=80... positions is irrelevant... need idea, i think I can create something, using your steps... Thanks