Select language:

Procedure documentation Adding StrictXml2PlainBean (XML to Text) in the Module Processor 

Use

You use this module to convert an XML document, which is in the main payload of the XI message to text format.

You can define whether a recordset type in the document is displayed as text with a fixed field width, or in a separate list with a user-defined separator.

Within an XML document, different recordset types can be displayed either separately or with a fixed field length (mixed display).

The structure of the document is checked based on the entries you make in the module. If any structures are found in document that do not correspond to your definition, a processing error is triggered at runtime.

You can use the module in receiver adapters.

For example, you can use the module in the receiver file/FTP adapter in place of the File Content Conversion message protocol. The module provides more conversion options and a check of the structure that is to be converted.

More information: Converting XML in the Receiver File /FTP Adapter to Text Format

Procedure

Add the Module in the Processing Sequence

...

  1.  Insert the module in front of the adapter module.

If the adapter comprises multiple modules, for information about the position of the module, see: Extending the Module Chain for SAP Adapters in the Module Processor

  Enter the module name AF_Modules/StrictXml2PlainBean.

  Select the module type Local Enterprise Bean.

The default module key is displayed.

Add Parameters in the Module Configuration

  2.  In the module configuration, enter the parameter names and parameter values for the module key of the module.

  3.  Make entries for the type of conversion of the XML document.

You must specify exactly one parameter, which excludes you from specifying the other parameter.

  If you want to define a different type of conversion for each recordset type that occurs in the XML document, specify the following:

  Under Parameter Name, enter recordTypes.

  Under Parameter Value, enter the complete, comma-separated list of all names of recordset types that occur in the document to be converted.

For example, you could name the recordset types as follows: RecordType1,RecordType2,RecordType3.

  If you want to define the same type of conversion for all recordset types that occur in the XML document, specify the following:

  Under Parameter Name, enter singleRecordType.

  Under Parameter Value, enter the name of a recordset type that is to be used to convert all elements that occur in the XML document.

  4.  You define further parameters for each recordset type.

In the remainder of this documentation the parameters are specified by the prefix <RecordType>. In your configuration, replace this name with the name of the recordset type.

Specify Conversion Type List with Separators

  5.  For parameter <RecordType>.fieldSeparator, enter the field separator that is written between the individual fields of a record.

This specification is mandatory.

Specify Conversion Type List with Fixed Field Length

  6.  For parameter <RecordType>.fieldLengths, specify a character string that contains a list of fixed field lengths that are separated by commas and which determines the number and the length of fields generated in the text file.

Example

For example, you want to write a recordset with three elements that have field widths of five, ten, and fifteen characters. Specify the following:

<RecordType>.fieldLengths = 5,10,15

This specification is mandatory.

  7.  For <RecordType>.fieldLengthExceeded, specify how fields that exceed the configured field length are to be handled. Permitted values for the parameter value are:

  error (default)

Interrupts processing of message with error

  cut

Cuts off superfluous characters

  ignore

Ignores the field length restriction

Make Other Entries

  8.  For <RecordType>.beginSeparator, enter a character string.

The string is placed in front of the first field of a recordset.

  9.  For <RecordType>.endSeparator, enter a character string.

The string is appended to the last field of a recordset as a concluding character. The default is \r\n.

Enter a string. The string is appended to the last field of a recordset as a concluding character. The default is \r\n.

  10.  For contentType, enter the MIME type of the converted payload.

The default value is text/plain.

  11.  For addHeaderLine, define whether a header line is to be added to the result of the conversion.

Only define this parameter if you have already defined singleRecordType.

Define whether a header line is to be added to the result of the conversion.

  none (default)

Does not insert a header line

  fromXML

The header line is generated from the element name of the first recordset of the XML document

  fromConfiguration

The header line is determined by the configuration parameter headerLine.

  12.  If you enter a value for headerLine, it is placed in front of the result of the conversion as a header line.

Only define this parameter if you have already set addHeaderLine=fromConfiguration.

  13.  For fixedLineWidth, enter the maximum line length n (in characters) that can be written to the resulting document.

A separator specified by lineSeparator is inserted in the resulting document every n characters.

  14.  For lineSeparator, specify the string that is written to the resulting document at the end of each line that is written with fixedLineWidth.

The default is \r\n.

Only define this parameter if you have already defined fixedLineWidth.

Use Special Characters

  15.  You can use special characters in the following parameters: <RecordType>.fieldSeparator, <RecordType>.beginSeparator, <RecordType>.endSeparator, headerLine, and lineSeparator.

  Tabulator: \t

  Carriage Return (CR): \r

  Line Feed (LF): \n

  Arbitrary character: \x<code>

<code>indicates the hexadecimal character code of the character to be displayed.

Example

A document to be converted has exactly three levels. The recordset types are on the second level, while the actual data is on the third level.

 

<root>

  <RecordType1>

  <column-name1>column-value</column-name1>

  <column-name2>column-value</column-name2>

  <column-name3>column-value</column-name3>

  </RecordType1>

  <RecordType2>

  <data>column-value</data>

  <data2>column-value</data2>

  <data3>column-value</data3>

  </RecordType2>

</root>

For this document, you can define a configuration for the recordset types RecordType1 and RecordType2. Specify in addition: recordTypes=RecordType1,RecordType2

You then have the option of defining a different conversion for each recordset type.

If you use the parameter singleRecordType, both recordset types are converted in the same way.

 

Was this page helpful to you?