Building the message model for the IDoc parser

To use WebSphere Message Broker's capability to transform SAP IDoc data, you must model the segment data of the IDoc in WebSphere Message Broker.

The messages sent to and received from SAP applications are processed by the IDoc parser, which requires a message model to interpret the data correctly. This topic documents how to build the message model. An example prebuilt version of a message model is provided in SupportPac IA0F.

Obtaining the IDoc

Use the following procedure to create an import file of the required IDoc data for the Message Brokers Toolkit to use:
  1. Logon to a SAP system
  2. Run the supplied transaction we60 that extracts the IDoc data as a C header file:
    1. For ObjectName select the IDoc type of interest, for example MATMAS02.
    2. Select the version of the record type. A version 4 IDoc is type 3.
    3. Select C-header from the Documentation menu.
    4. Enter the filename for the output from the transaction when prompted. The C representation of the IDoc is saved to this file.
  3. Use the Perl script hdrfiddle.pl, supplied in SupportPac IA0F, to ensure that the output file form you created is of the correct format to import into the Message Brokers Toolkit.

Modeling the IDoc

Use the following procedure to create your message model:

  1. Use the New Message Set Project wizard to create a message set for your IDoc, for example matmas02, and to create a Custom Wire Format (CWF) physical format.
  2. Use the message set editor to change the message set Runtime Parser property to IDOC.
  3. Use the New Message Definition File wizard or the mqsicreatemsgdefs command to import the C representation of the IDoc into the new message set. When you are using the wizard or command, specify the following settings:
    • Create messages for the segments that appear in the IDoc.
    • Use the String Encoding option to import char arrays as fixed length strings.
    • Use the Padding Char for String option to make space (" ") the padding character used.
    Importing from C contains information on using the New Message Definition File wizard.
  4. Rename each message to be the name of the segment it represents in uppercase letters. For example, for a segment called E2MARAMM the message must be named E2MARAMM.

The message set must be added to a broker archive file and deployed to a broker execution group, because the IDoc parser uses the MRM parser to parse the IDoc segments you have defined.

The Runtime Parser property, the message set name, and the Custom Wire Format name are used when you create a message flow to process an IDoc. They appear as the values of the Message Domain, Message Set and Message Format properties respectively of an MQinput node. Do not supply a Message Type property on the MQInput node, because the IDoc parser uses the contents of the SAP defined IDoc DD field segnam to provide the name of the message.

Accessing fields of the IDoc using ESQL

Use the ESQL editor Content Assist to fill in the SAP-defined fields of the IDoc. Invoke Content Assist from the Edit menu or, on some systems, by pressing Ctrl+Space if that has not been assigned to another function.

When you get to the sdatatag tag in an ESQL statement, the next tag is MRM, which must be entered manually, and then the field name to be manipulated. Specify the name of the field within the message segment here, instead of the name of the message segment.

For example, the following code sets the segment name of the IDoc:

SET OutputRoot.IDOC.DD[I].segnam  = 'E2MAKTM001';
The following example sets the msgfn field within the E2MAKTM001 segment:
SET OutputRoot.IDOC.DD[I].sdatatag.MRM.msgfn = '006';