How to make values into variables?

rocopsa
Member Posts: 38
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!!!
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
-
I'm not sure I have understood you completly.
Why not add a field "Value" to to the variable table. then the function could look like this:
recVarTable.GET(VarName);
EXIT(recVarTable.Value);0 -
no...you can't do such a thing...a variable name can't be retrieved from a 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 doEXIT(myvariable[mytable.varindex]);
0 -
Thanks, Belias,
It works fine if I turned all the variables in the table as integers.
Thanks a bunch!0 -
Dear Belias,
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!0 -
rocopsa wrote:Dear Belias,
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!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions