progress 4gl - how to calculate total balance per state per country using accumulate function in openedge -


i have tried code.

define variable totalbalance decimal     no-undo.  define frame f1      centered three-d size 100 50. each customer no-lock break country frame f1:      accumulate balance(total country).     if first-of(customer.country)         display customer.country.     display customer.state customer.balance.     if last-of(customer.country)     do:             display skip fill("-", 25) @ 50 format "x(25)".          display accum total customer.balance @ 51.          display skip fill("-", 25) @ 50 format "x(25)".     end. end. 

it gives total balance per country want display total balance per state.

you not have "break state" nothing state.

something (not tested):

define frame f1      centered .  each customer no-lock break country state frame f1:      accumulate balance( total country ).     accumulate balance( sub-total state ).      if first-of( customer.country )         display customer.country.      if first-of( customer.state )         display customer.state.      display customer.balance.      if last-of( customer.country )       do:         display skip fill( "-", 25 ) @ 50 format "x(25)".         display accum total customer.balance @ 51.         display skip fill( "-", 25 ) @ 50 format "x(25)".       end.      if last-of( customer.state )       do:         display skip fill( "-", 25 ) @ 80 format "x(25)".         display accum sub-total customer.balance @ 81.         display skip fill( "-", 25 ) @ 80 format "x(25)".       end.  end. 

(that doesn't work... multiple clauses main thing missing.)

personally find accum syntax unpleasant , not worth bothering with. create , manage simple variables. find sort of coding cleaner. unless "gotchya" question on skills test suggest avoid coding in manner. if "gotchya" question move on more suitable prospective employer -- don't want work thinks idea.

i more this:

define variable countrybalance decimal no-undo. define variable statebalance   decimal no-undo.  each customer no-lock break country state frame f1:      if first-of( customer.country )       do:         display customer.country.         countrybalance = 0.       end.      if first-of( customer.state )       do:         display customer.state.         statebalance = 0.       end.      assign       countrybalance = countrybalance + customer.balance       statebalance   = statebalance  + customer.balance     .      display customer.balance.      if last-of( customer.country )       do:         display countrybalance.       end.      if last-of( customer.state )       do:         display statebalance.       end.  end. 

i think whole lot easier read, understand , maintain.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -