Using scratchpad areas in LocalEnvironment

The LocalEnvironment tree includes a subtree called Variables. This is always created, but is never populated by the message flow. You can use this area for your own purposes, for example to pass information from one node to another.

We recommend that you include all your information in this subtree. However, you can create other subtrees in the LocalEnvironment tree if you choose.

The advantage of creating your own data in a scratchpad in the LocalEnvironment is that this data is propagated as part of the logical tree to subsequent nodes in the message flow. If you create a new output message in a Compute node, you can also include all or part of the LocalEnvironment tree in the input message in the new output message.

However, any data updates or additions that you make in one node are not retained if the message flows back through the message flow (for example, if an exception is thrown, or if the message is processed through the second terminal of the FlowOrder node). If you want to create your own data, and want that data to be preserved throughout the message flow, you must use the Environment tree.

You can set values in the Variables subtree in a Compute node that are used later by another node (Compute, Database, or Filter) for some purpose that you determine when you configure the message flow.

For example, you might use this to determine the destination of an output message. Your first Compute node could determine in some way that the output messages from this message flow must go to WebSphere MQ queues. Include the following ESQL to insert this information into the LocalEnvironment scratchpad area.
SET LocalEnvironment.Variables.OutputLocation = 'MQ';
Your second Compute node can access this information, then write the required destinations in the Destination subtree to ensure that the output message that it propagates to an MQOutput node is sent to the list of queues that it has created there. Configure the MQOutput node to use the destination list, by setting property Destination Mode to Destination List.
IF LocalEnvironment.Variables.OutputLocation = 'MQ' THEN
DO;
   SET LocalEnvironment.Destination.MQ.DestinationData.queueManagerName = 'myQManagerName';
   SET LocalEnvironment.Destination.MQ.DestinationData.queueName = 'myQueueName';
END IF; 

For information about the full list of elements in the DestinationData subtree, see Data types for elements in the DestinationData subtree.

Related concepts
Message flows
LocalEnvironment tree
ESQL
Message modeling

Related tasks
Designing a message flow
Defining message flow content
Managing ESQL files

Related reference
Compute node
Database node
Filter node
Data types for elements in the DestinationData subtree
ESQL
IF statement
SET statement