I would like to SUM fields of my file. The file was created using a cobol program is VB Lrecl 425. The field is PIC S9(9)V99 comp-3 can be negative or positive.
Output can be FB or VB should be like this:
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
A bit more information, please.
In the VB file, will the number to sum always begin in pos 115?
Is all of the data to be copied as well as creating the TOTAL line? If all of the data is to be copied into the output file, should the TOTAL be placed at the end of the output file or in a different place?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
adushkin,
Here's a DFSORT job that will do what you asked for. I assumed that your starting position of 115 included the RDW in positions 1-4. If not, change 115 to 119 to account for the RDW. If the format of the total is not what you want, you can change the edit mask accordingly.
Input:
Field A pos 85:14
Field B pos 76:9
Field C pos 115:6 (com-3)
output
Output:
Field A Field B Field C
----+----1----+----2----+----3----+----4
***************************** Top of Dat
HEADER 1 HEADER 2 AMOUNT
-------------- -------- -----------
YYY NNNNNNN703 00AAAAAAA 0.46
YYY NNNNNNN703 00BBBBBBB -0.14
YYY NNNNNNN703 00CCCCCCC 0.00
Sub total: 0.32
YYY PPPPPPP703 00AAAAAAA -1310.78
Sub total: -1310.78
YYY RRRRRRR701 00AAAAAAA -1940.00
YYY RRRRRRR701 00BBBBBBB -0.66
Sub total: -1940.66
TOTAL: -3251.12