Hi experts,
I have a table (TableA) storing the desired variable names (Var1, Var2) by cases.
TableA:
(Fieldname: Case - Var)
Case1 - Var1
Case2 - Var2
Case3 - Var1
...etc.
Then, in report, Var1 and Var2 are registered in G/AL Globals as variables and the values are defined as VarValue1 and VarValue2.
My desired result in report is:
Case1 - VarValue1
Case2 - VarValue2
Case3 - VarValue1
By the following function, I can have the above result. Yet, it will be very clumsy as there are plenty of Var1, Var2,....
CASE TableA.Var OF
'Var1': EXIT(Var1);
'Var2': EXIT(Var2);
END;
How can I code it smartly without the need to do the above declaration? (as TableA.Var already telling what variable to return).
I've tried the following but it just give me texts of 'Var1' and 'Var2' but not VarValue1 and VarValue2.
EXIT(TableA.Var);
Please help! #-o
Thanks in advance!!!
0
Comments
Why not add a field "Value" to to the variable table. then the function could look like this:
recVarTable.GET(VarName);
EXIT(recVarTable.Value);
'Var1' is a text value and if you "exit" it, you're exiting the text 'Var1' not the variable named Var1
BUT
You can use an array, for example, if you insert in your table (mytable) integer values (field varindex)
you can then do
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
It works fine if I turned all the variables in the table as integers.
Thanks a bunch!
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Yes, I added a variant (varResult) with Array in the Report and changed all the Var1, Var2 in TableA into integers 1, 2.
Then, replace the variable name Var1, Var2 in Report as varResult[1], varResult[2], etc.
It then works fine with:
EXIT(varResult[TableA.Var]);
Just one line then I can save all the clumsy declarations in Report!
Thanks again for such a great idea!
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog