Math Functions

Hey Again! I had another question? How do you sum up or get the total for a whole column/field. This is what I tried:

sum(TRANS-AMT)

But that didn’t work. The name of the field that is used in my DISPLAY statement is CHK.TRANS-AMT. Thanks in advance for your help.

NatBeginner

I presume it is your management that thinks you can simply learn Natural on your own. They are WRONG.

As far as your question goes, there is a SUM function. It is only permitted in special clauses like AT BREAK, AT END OF DATA, PERFORM BREAK.

Thus, assuming TRANS-AMT is a database field, the following code might be appropriate:

FIND …
process record

AT END OF DATA
WRITE ‘sum of trans amounts is:’ sum (trans-amt)
end-enddata
end-find

steve

check out the discussion “Multiple reports on a page” under “Mainframe Basics” forum. [/url]

Thanks for the comments and replies. They are very helpful. The MAIN BASICS forum has alot of good information. Once again thanks.

NatBeginner