I need this kind of report...

101 UNAIDS 10 10
ER 2 8
ET 4 4

102 WHO 10 14
ER 4 10
ET 2 8

What happens is UNAIDS first gave 10 items. The donation is identified by 101 (incominginovoiceid). THe next 10 is the balance. Since it was the first donation, the balance is the same.

Then from those 10 items given, ER took 2 items. So we have 8 in store. Then ET took 4 from the 8 items. So, we have 4 in store.

Then WHO gave 10 items. Now since we had 4 items in store already [the 4 left from UNAIDS], the balance is 14. Now from the 14, ER took 4 so we remain with 10. FRom this 10, ET took 2 so we end up with 8.

I have used group headers to group them as in the above and it looks great. My approach was to create a forumula that would sum up total items taken in single batch first (i.e. 4 +2=6 for first, then again 4+2=6 for second), subtract from balance of that specific batch. So, the formula gave 6 for first batch which is correct. While for the second one it gave 6 as well which is wrong. It gave 6 because the balance is 10, not 14.

NOw, back to my question, how can i pass the remaining items from previous batch to the batch that is following? I.E. the 6 items of UNAIDS to the 10 newly WHO-donated items?

here is the method i tried but failed...

SHARED numberVar looper=0;

SHARED numberVar totalTaken;

SHARED numberVar pretotalTaken;

SHARED numberVar activein;

GLOBAL numberVar prein=0;

SHARED stringVar k;


if recordnumber=1 then



 //@remainITems is the formula that calculates total remaining items 

 //first record. so the balance is same as the exact no of items donated

else (
 //row contined.
if prein<>activein then (
 //if dealing with different donation

ToText({@remainItems} + {DSSMP_RPT_StockItem;1.originaltotal});

//originaltotal is the total donated for that specific donation

i kno it is a lot to ask but can u give me some insight on how to do this.