I'm creating a report that will display potential product shortages as the product appears on orders.
I have a sub report that calculates the item's available quantity (based on several conditions - inventory, damaged, ordered, on hold, etc) Because the SKUs do not appear in the report sequentially, I need to maintain
a running count of available quantity per SKU and calculate against ordered quantity.
(Ref SKU "B" below)
Order# SKU Available Qty Ordered Bal
001 A 0 375 -375
001 B 775 25 75
001 C 100 193 - 93
001 D 0 5 - 5
002 B 750 75 - 25
002 F 200 200 0
I attempted to create two "synchronized" shared arrays in the subreport - one to hold the SKU and the other to hold the quantity. (Below)
evaluateafter({@Available});
stringvar array SKU_Array;
numbervar array Qty_Array;
shared numbervar NewQty;
numbervar max;
numbervar sCounter;
if not({tbl.sku} in SKU_Array )then
(sCounter := sCounter +1;
(Redim Preserve SKU_Array[sCounter];
(Redim Preserve Qty_Array[sCounter];
(SKU_Array[sCounter] := {tbl.sku};
(NewQty := {@Available};
(Qty_Array[sCounter] := NewQty
)))))
else
max := ubound(SKU_Array);
While sCounter < max Do
(sCounter:=sCounter+1;
(if{tbl.sku} = SKU_Array[sCounter] then
(NewQty := Qty_Array[sCounter]-{tbl.order_qty};
(Redim Preserve Qty_Array[sCounter];
(Qty_Array[sCounter] := NewQty)))));
NewQty;
What I've got here is: If the SKU is not in the SKU array, I want to add it, and add the Available quantity to the Quantity array at the same position. If the SKU IS in the array, I want to find its position, then look up the quantity in the Quantity Array and change its value. Then use the variable "NewQty" in the report as the new Available Quantity. The problem is with the lookup array. Even if I run the formula after "else" in a separate formula, it returns 0 and the position value (sCounter) returns the incremental counter value.
So, after all of that... Am I missing something? Anyone have an alternative method of achieving this?
Using Informix Database, Crystal 9, Windows 2000
I have a sub report that calculates the item's available quantity (based on several conditions - inventory, damaged, ordered, on hold, etc) Because the SKUs do not appear in the report sequentially, I need to maintain
a running count of available quantity per SKU and calculate against ordered quantity.
(Ref SKU "B" below)
Order# SKU Available Qty Ordered Bal
001 A 0 375 -375
001 B 775 25 75
001 C 100 193 - 93
001 D 0 5 - 5
002 B 750 75 - 25
002 F 200 200 0
I attempted to create two "synchronized" shared arrays in the subreport - one to hold the SKU and the other to hold the quantity. (Below)
evaluateafter({@Available});
stringvar array SKU_Array;
numbervar array Qty_Array;
shared numbervar NewQty;
numbervar max;
numbervar sCounter;
if not({tbl.sku} in SKU_Array )then
(sCounter := sCounter +1;
(Redim Preserve SKU_Array[sCounter];
(Redim Preserve Qty_Array[sCounter];
(SKU_Array[sCounter] := {tbl.sku};
(NewQty := {@Available};
(Qty_Array[sCounter] := NewQty
else
max := ubound(SKU_Array);
While sCounter < max Do
(sCounter:=sCounter+1;
(if{tbl.sku} = SKU_Array[sCounter] then
(NewQty := Qty_Array[sCounter]-{tbl.order_qty};
(Redim Preserve Qty_Array[sCounter];
(Qty_Array[sCounter] := NewQty)))));
NewQty;
What I've got here is: If the SKU is not in the SKU array, I want to add it, and add the Available quantity to the Quantity array at the same position. If the SKU IS in the array, I want to find its position, then look up the quantity in the Quantity Array and change its value. Then use the variable "NewQty" in the report as the new Available Quantity. The problem is with the lookup array. Even if I run the formula after "else" in a separate formula, it returns 0 and the position value (sCounter) returns the incremental counter value.
So, after all of that... Am I missing something? Anyone have an alternative method of achieving this?
Using Informix Database, Crystal 9, Windows 2000