Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

While ... Do Loop Question

Status
Not open for further replies.

rdjehn

MIS
Jul 31, 2011
2
US
I am working in Crystal Reports X. I am trying to modify a report that displays component shortages using Bill of Materials/Inventory tables from Great Plains (SQL). Our Purchasing Agent has asked me to modify the report to show multiple formulas (BOMs) simultaneously with the intent to sum component parts at the bottom of the report so they have a handle on all the raw material needs.

So, that means working with parameter arrays. I need to be able to enter a list of multiple formulae (BOMs) and enter a list of multiple different quantities associated with each different formula. For example, I enter formula1, formula2, formula3, and quantity1, quantity2, quantity3, each of those six data points being unique.

Here is the formula I am using to try to calculate extended quantities for each line item listed for each BOM:

Code:
global numbervar lQty := 1;
global numbervar Demand := 0;
While lQty < count({?Item}) and Demand = 0 Do (
If ({BM00111.ITEMNMBR} = {?Item}[lQty]) then Demand = ({BM00111.Design_Qty}*{?Qty}[lQty]);
lQty = lQty + 1;
If lQty = Count({?Item}) Then Exit While;
);
Demand
I get this error:

"A loop was evaluated more than the maximum times allowed."

I would really like to solve this and I am not really much of a programmer. Any help would be deeply appreciated.

Richard Jehn
 
I can't really follow what you are trying to do, but you are missing some colons here:

global numbervar lQty := 1;
global numbervar Demand := 0;
While lQty < count({?Item}) and
Demand = 0 Do (
If ({BM00111.ITEMNMBR} = {?Item}[lQty]) then
Demand [red]:=[/red]({BM00111.Design_Qty}*{?Qty}[lQty]);
lQty [red]:=[/red] lQty + 1;
If lQty = Count({?Item}) Then
Exit While;
);
Demand

-LB
 
Thank you, thank you, thank you !!! That appears to have resolved the issue. I had a feeling it might be something very simple ....

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top