Changing message format

Use the Compute node to copy part of an input message to an output message. The results of such a copy depend on the type of input and output parsers involved.

Like parsers

Where both the source and target messages have the same folder structure at root level, a like-parser-copy is performed. For example:

SET OutputRoot.MQMD = InputRoot.MQMD;

copies all the children in the MQMD folder of the input message to the MQMD folder of the output message.

Another example of a tree structure that supports a like-parser-copy is:

SET OutputRoot.XML.Data.Account = InputRoot.XML.Customer.Bank.Data;
If you want to transform an input message in the MRM domain to an output message also in the MRM domain, you can use either the Compute or the Mapping node. The Mapping node can interpret the action that is required because it knows the format of both messages. Content Assist in the ESQL module for the Compute node can also use the message definitions for those messages. If the messages are not in the same namespace, you must use the Compute node.
Note: To get Content Assist to work with message references, you must set up a project reference from the project containing the ESQL to the project containing the message set. For information about setting up a project reference, see Project references.

If both input and output messages are not in the MRM domain, you must use the Compute node and specify the structure of the messages yourself.

Unlike parsers

Where the source and target messages have different folder structures at root level, you cannot make an exact copy of the message source. Instead, the unlike-parser-copy views the source message as a set of nested folders terminated by a leaf name-value pair. For example, copying the following message from XML to MRM:

<Name3><Name31>Value31</Name31>Value32</Name3>

produces a name element Name3, and a name-value element called Name31 with the value Value31. The second XML pcdata (Value32) cannot be represented and is discarded.

The unlike-parser-copy scans the source tree, and copies folders, also known as name elements, and leaf name-value pairs. Everything else, including elements flagged as special by the source parser, is not copied.

An example of a tree structure resulting in an unlike-parser-copy is:

SET OutputRoot.MRM.Data.Account = InputRoot.XML.Data.Account;

If the algorithm used to make an unlike-parser-copy does not suit your tree structure, you might need to further qualify the source field to restrict the amount of tree copied.

Be careful when you copy information from input messages to output messages in different domains. It is possible to code ESQL that creates a message structure or content that is not completely consistent with the rules of the parser that will process the output message. This can result in an output message not being created, or being created with unexpected content. If you believe that the output message generated by a particular message flow does not contain the correct content, or have the expected form, check the ESQL that creates the output message, and look for potential mismatches of structure, field types, field names, and field values.

When copying trees between unlike parsers, you might also want to set the message format of the target parser. For example, if a message set has been defined with XML and CWF formats the following commands are required to copy an input XML stream to the MRM parser and set the latter to output in CWF format:
-- Copy message to the output, moving from XML to MRM domains
SET OutputRoot.MRM = InputRoot.XML;
		
-- Set the CWF format for output by the MRM domain
SET OutputRoot.Properties.MessageType = '<MessageTypeName>';
SET OutputRoot.Properties.MessageSet = '<MessageSetName>';
SET OutputRoot.Properties.MessageFormat = 'CWF';