Hi,
is possible use table name in FOR EACH statement as variable?
For example something like following:
DEFINE VARIABLE tbl AS CHARACTER.
tbl = "table1" (or get it by PROMPT-FOR)
FOR EACH tbl ...
DEFINE VARIABLE tbl AS CHARACTER.
tbl = "table1" (or get it by PROMPT-FOR)
DEFINE VARIABLE tblbuff AS HANDLE NO-UNDO.
CREATE BUFFER tblbuff FOR TABLE tbl.
DEFINE VARIABLE q AS HANDLE NO-UNDO.
CREATE QUERY q.
q:SET-BUFFERS(tblbuff).
q:QUERY-PREPARE("FOR EACH " + tbl ...).
q:QUERY-OPEN().
q:GET-FIRST().
DO WHILE tblbuff:AVAIL:
/* your actions should be here */
q:GET-NEXT().
END.
DELETE OBJECT q.
DELETE OBJECT tblbuff.
If it is a simple FOR EACH statement then you have a number of options.
1) FOR EACH {&tableName} , use a preprocessor and change the tablename on-the-fly
FIND tableName WHERE fieldName = {&preField} NO-LOCK.
Earlier in your code block define {&preField} value ie on-the-fly.
Something like;
&SCOPED-DEFINE preField pantsString
Hope you can work out from this how to apply.
def var pantsString as char no-undo.
&SCOPED-DEFINE preTable pantsString
FIND {&preTable} NO-LOCK.