Author |
Message
|
WMB_User |
Posted: Sun Aug 08, 2010 8:38 am Post subject: Dynamically create a variable name |
|
|
Apprentice
Joined: 17 Nov 2008 Posts: 31
|
WMB 6.1.0.4
I need to construct the name of a variable using some static values and also a value that's been assigned to another variable. Confused ? Perhaps a sample of what I'm trying to accomplish will provide some insight.
Code: |
DECLARE FatalAction_FA1_EmailDistributionList EXTERNAL of CHARACTER 'john.smith@yahoo.com';
DECLARE FatalAction_FA2_EmailDistributionList EXTERNAL CHARACTER 'jane.doe@yahoo.com';
SET OutputRoot.EmailOutputHeader.To = 'FatalAction_' || Environment.FA_Status || '_EmailDistributionList'; |
** where Environment.FA_Status contains either 'FA1' or 'FA2'
I know this sample will only assign the value 'FatalAction_FA1_EmailDistributionList' to EmailOutputHeader.TO rather than the value that the FatalAction_FA1_EmailDistributionList variable contains.
Any thoughts?
Can this be done using the FIELDVALUE function? |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Aug 08, 2010 11:44 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Why?
Can't this be done in other ways?
For example a structure with one field containing the variable name and another with its value. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
WMB_User |
Posted: Sun Aug 08, 2010 12:19 pm Post subject: |
|
|
Apprentice
Joined: 17 Nov 2008 Posts: 31
|
Yes, but I'd prefer doing this with one statement if at all possible.
I seem to remember that there's a way to do it, but can't remember how it was done. |
|
Back to top |
|
 |
mqjeff |
Posted: Sun Aug 08, 2010 2:59 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You mean { } ?
It only works for a single level, so if you need to OutputRoot.X.Y.Z, you need OutputRoot.{XVar}.{YVar}.{ZVar}. |
|
Back to top |
|
 |
inMo |
Posted: Mon Aug 09, 2010 9:24 am Post subject: |
|
|
 Master
Joined: 27 Jun 2009 Posts: 216 Location: NY
|
Have you considered assigning the addrs to a tree structure like Environment.EmailList.FA1 and Environment.EmailList.FA2 and using the contents of that tree for population? |
|
Back to top |
|
 |
Amitha |
Posted: Mon Aug 09, 2010 11:32 am Post subject: |
|
|
 Voyager
Joined: 20 Nov 2009 Posts: 80 Location: Newyork
|
|
Back to top |
|
 |
WMB_User |
Posted: Mon Aug 09, 2010 3:45 pm Post subject: |
|
|
Apprentice
Joined: 17 Nov 2008 Posts: 31
|
That was the solution.
Thanks !
Code: |
SET OutputRoot.EmailOutputHeader.To = EVAL('FatalAction_' || envRef.Enrichment.Status || '_EmailDistributionList'); |
|
|
Back to top |
|
 |
|