My problem...

audie

New Member
I seem to always get stuck in a situation like this and I do not know exactly how to program it other then to break it out into a load of temp-tables.. So I'm looking for some advice.. I have records looking like this..

Tran-id item# qty

so 1-00 5
fj 1-00 1
fk 1-00 1
ik 1-00 1
ij 1-00 3
so 5-00 4
wr 5-00 1
fj 5-00 2
fk 5-00 3
ik 7-00 1
ij 7-00 2

So this is all in the same table.. I need to add by item all the so + wr......the fj + fk...... ik+ij......not all items have all trans-id and like I said I need to do it by item...(remember all in the same table).. How do I say this in progress?? Thanks
 

cmorgan

New Member
There are many ways to skin a cat, but this is an example (untested) of how I might do it....

Code:
Define variable SOTotal as decimal no-undo.
Define variable WRTotal as decimal no-undo.

for each tablename no-lock break by tablename.item:

  if tablename.trans-id eq "so" then
    assign SOTotal = SOTotal + tablename.qty.
  else if tablename.trans-id eq "wr" then
    assign WRTotal = WRTotal + tablename.qty.

  if last-of( tablename.item ) then
  do:
     display tablename.item SOTotal WRTotal.
     assign SOTotal = 0   WRTotal = 0.
  end.

end.  /**  for each tablename  **/

HTH :)
 
Top