global variables are created / reference / incremented in formulas.
Typically the formulas come in groups of 3, reset, increment, display
reset, usually in a group header:
global numbervar aTotal := 0;
"" //hides the reset
increment, usually in detail, but in a group footer this time:
global numbervar aTotal;
//if there was a condition, you would put that here, but if this is straight summing without a condition...
aTotal := aTotal + {table.field};
"" // to hide the running total
display, usually in a group footer:
global numbervar aTotal
that pretty much is a primer on global variables. That easiest place to make mistakes is that := is the assignment operator while = is the comparator.
HTH