Question Add "total By" To A Variable

JoseKreif

Member
I'm would like to get the total and save it to a variable to use outside of the display command.

For example
Code:
For each customer where age = 21  break by state:
  display  Customer state balance(total by state).
end.

FYI This is purely a fictional example

In the example, I would list customers by state and total the balance for all customers by state. How do I set a variable with the value of that total ?

This simply does not work

Code:
someVar = balance(total by state) .

Do I need to manually accumulate the totals inside the "for each" loop?
 

JoseKreif

Member
I think I found a solution. Something like this might work

Code:
      if last-of(state) THEN do:
        accumulate balance(total).
        someVar = (accum total balance) .
      end.
 
I'm would like to get the total and save it to a variable to use outside of the display command.

For example
Code:
For each customer where age = 21  break by state:
  display  Customer state balance(total by state).
end.

FYI This is purely a fictional example

In the example, I would list customers by state and total the balance for all customers by state. How do I set a variable with the value of that total ?

This simply does not work

Code:
someVar = balance(total by state) .

Do I need to manually accumulate the totals inside the "for each" loop?


for each ld_det no-lock
break by ld_part:
accum ld_qty_oh (TOTAL BY ld_part).
end.
display accum TOTAL ld_qty_oh.
 
Top