You can use the Cast function to define variables in a message map that are defined in the local environment tree Variables folder.
Sometimes you need to use information passed in a variable in the local environment tree. In other instances, you might need to calculate the output value of a different element in the message body based on one of the local environment variables. You can also set variables in the output local environment, and use them for routing later in the message flow. To configure the local environment tree Variables folder so you can use its elements as part of your transformations, complete the following steps:
You have defined one local environment variable that can be used by other message flow nodes in your message flow for routing or filtering.
You can see the element Country under the local environment Variables folder in the message map.
Another example:
If you set in an ESQL compute node two simple fields within the Variables folder of the Local Environment tree by using the following code:
SET Outputlocal environment.Variables.dec = 10.1;
SET Outputlocal environment.Variables.str = 'Some text';
To access these fields in a Mapping node by using the Cast function, you must create a schema file in your integration solution to define the elements and their type. Note that since the ESQL is not using any namespace to qualify these elements, the schema is also defined without a namespace declaration:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="dec" type="xsd:decimal"/>
<xsd:element name="str" type="xsd:string"/>
</xsd:schema>
Once the schema file is saved, you can then select the any element under the Variables section in the Local Environment tree, and use the context menu action Cast to add a Mapping cast for each of the elements "dec" and "str" that are required in the message map. For more information, see Mapping xsd:any on an input or output message.
Define transforms between the input local environment tree and the output local environment tree. For more information, see Specifying a transform (mapping operation) and Transform types in the Graphical Data Mapping editor.