[Stackoverflow] [Progress OpenEdge ABL] How can I dynamically change the where conditions of a for each loop?

Status
Not open for further replies.
R

Roger Waterhouse

Guest
I have a table of records that has two logical flags, holdn and holdl. I want to loop through this table with 3 different criteria.

Either flag is TRUE - We want to see everything that is on hold

Flag holdl is TRUE - We only want see items that are on hold for this one reason

Flag holdn is TRUE - We only want to see items that are on hold for this other reason.

I cannot figure out how to dynamically change the for each loop based on this. What I have tried so far is to set the value of a variable based on these conditions and then use the content of the variable as one of the where parameters. This does not work as Progress complains that there is a data mismatch. The variable is a string, the flags are logical, so that does make sense. See sample code below. This is a snippet of the actual code with the the table name changed. The which-hold, order-from, etc variables are defined and set in a different module which calls this one.

DEFINE VARIABLE which-hold# AS CHARACTER FORMAT "x(30)" NO-UNDO.

CASE which-hold:
WHEN "B" THEN which-hold# = "(widget.holdn or widget.holdl)".
WHEN "L" THEN which-hold# = "widget.holdl".
WHEN "N" THEN which-hold# = "widget.holdn".
END CASE.


for each widget where which-hold# and
widget.order-no >= order-from and widget.order-no <= order-thru and
widget.line-no >= line-from and widget.line-no <= line-thru and
widget.joint-no >= joint-from and widget.joint-no <= joint-thru
no-lock:

A bunch of code to make a nice report with the retrieved records...

end.


Self taught Progress programmer here, who has inherited a huge, poorly documented application. Please be gentle.

Continue reading...
 
Status
Not open for further replies.
Top