infor.com
concierge
infor u
developer portal
documentation central
customer center
Posts
Categories
Groups
ERPs
CSD
FSM/HRT
LN
M3
Syteline/ CSI
Hubs
Developer
Healthcare
Hospitality
Public Sector
Onboarding
Release Center
CloudSuites
Aerospace & Defense (LN)
Automotive (LN)
Chemicals (M3)
Corporate (FSM/HRT)
Distribution (Sx.e/CSD)
Distribution Enterprise (M3)
Engineering & Construction (LN)
Fashion (M3)
Food & Beverage (M3)
Healthcare (FSM/HRT)
Industrial (Syteline/CSI)
Industrial Enterprise (LN)
Manufacturing (M3)
Public Sector (FSM/HRT)
Solutions
Supply Chain Management (SCM)
Human Capital Management (HCM)
Events
Groups
User Groups
Your Groups
About
Email Community Support
Infor News
Migrated Forums
Home
Clovertech
Clovertech Archive
Read Only Archives
Cloverleaf
Cloverleaf
Access Global variable
System
Originally posted by Rick Pritchett
Is there any way to access a global variable created by a proc in an xlate?
Find more posts tagged with
Clovertech
Comments
Jim Kosloskey
Rick,
Where do you want to reference it from?
System
Originally posted by Rick Pritchett
I want to create the global in a proc and access it in a copy command inside the xlate tool if possible. The proc is located in the pre-xlate.
Jim Kosloskey
Rick,
I am not sure if that will work however, this should work:
In the pre_xlate proc place the data you want in the metadata USERDATA field (I use a keyed list but you can do whatever you want). Then get the value for the keyed list enty from the USERDATA metadata field of the message in the Xlate with an xltp type proc.
Charlie Bursell
Yes it will work since they run in the same interprter. You can access the variable by declarining it global in both places or giving it a namespace path like ::gvar.
I have done this on many occasions
Jim Kosloskey
Charlie,
Thanks that is good to know. I have never had a need to do what Rick is trying but I have used the USERDATA when I wanted something I set in the inbound thread to be known in an outbound thread.
System
Originally posted by Rick Pritchett
thank guys ! One last thing do i need to null out the global once i am finished with it.
Charlie Bursell
Depends on what you mean by null out.
To set to empty string: set ::gvar ""
To destroy it: unset -nocomplain ::gvar
Jim Kosloskey
Rick,
Do you want to reset with each message or after some event has occurred?
System
Originally posted by Rick Pritchett
after i use it in the xalte
Charlie Bursell
Regarding my answer to Jim Koslosky concerning the use of globals in the Xlate thread, I got this response from one of the developers:
FYI, this will not work in 5.8. The interp used in the xlate was hardcoded which killed things in threaded xlates so Tcl fragments in the xlate no longer run in the same interp as the pre/post Tps.
Therefore, for forward compatibility, you best choice to communicate would be as Jim suggested and use the USERDATA meta field of the message.
Russ Ross
I was going to mention that using a global variable solution is riskier and less robust because it makes an assumption that creates a denpendancy that might not hold up over time.
Now that Charlie has already come up with such an example I'm willing to add my voice to this concern.
Here is a URL with a tanglible example to help show how to value the USERDATA metatadata in an xlate and retrieve the value in an outbound thread that is even in a different process.
template for using metadata
System
Originally posted by Rick Pritchett
Thanks guys!!
Dennis Pfeifer
An instance where I have used a global in the Xlate thread, was in using a global across multiple interfaces, but all in the same process. My specific example was tracking patients' room and bed. I could have used a file on disk, or database, but instead, I used memory. Updates were written to disk (to support startup), but 'reads' came from the global which was shared across multiple 'Xlates' .... saved some disk I/O.
Dennis
Dennis Pfeifer
Oh, Ya, after reading another 'thread' .. I realized that we also do this for database connections...
If the connection exisits, we use the global... which is shared amoungst all Xlates in the same process.
Dennis