Start of Content Area

This graphic is explained in the accompanying text Examples of Content Conversion Using MessageTransformBean  Locate the document in its SAP Library structure

The MessageTransformBean module enables conversion of XML files to flat files and vice versa. You can use this module in the sender and receiver communication channels.

For both sender and receiver channel, you can choose either simple or complex transformation. In simple transformation all rows of the input file have the same structure. If each row of the input file has a different structure, then it is referred to as complex transformation.

All transformations can handle Character-Separated-Value (CSV) structures and structures with fixed field length.

Conversion in the Sender Communication Channel

The following example describes simple and complex conversion using the MessageTransformBean module in the sender communication channel.

Module Name

Type

Module Key

localejbs/AF_Modules/MessageTransformBean

L

<Plain2XML>

localejbs/CallSapAdapter

L

<ForwardToMS>

Note

The names of the module keys are arbitrary. You can choose any name. However, for the parameter configuration you must refer to the same module key name that you have assigned to the MessageTransformBean module.

Do not enter any spaces after parameter names or values in your configuration.

Simple Conversion

Consider a simple file structure containing two rows with three fields of three bytes each as follows:

AAABBBCCC

111222333

Specifications in the Module Configuration of Module Pocessor

Module Key

Parameter Name

Parameter Value

Plain2XML

Transform.Class

com.sap.aii.messaging.adapter.Conversion

Plain2XML

Transform.ContentType

text/xml;charset=utf-8

Plain2XML

xml.conversionType

SimplePlain2XML

Plain2XML

xml.processFieldNames

fromConfiguration

Plain2XML

xml.documentName

Document

Plain2XML

xml.documentNamespace

http://xi.com/test

Plain2XML

xml.structureTitle

Title

Plain2XML

xml.fieldNames

field-name1,field-name2,field-name3

Plain2XML

xml.fieldFixedLengths

3,3,3

Note

If you have a CSV file, you use the parameter xml.fieldSeparator instead of xml.fieldFixedLengths.

The result of this conversion is as follows:

<ns:Document xmlns:ns="http://xi.com/test">

<Title>

<field-name1>AAA</field-name1>

<field-name2>BBB</field-name2>

<field-name3>CCC</field-name3>

</Title>

<Title>

<field-name1>111</field-name1>

<field-name2>222</field-name2>

<field-name3>333</field-name3>

</Title>

</ns:Document>

Complex Conversion

Consider a file with four rows. Each row has a two byte key field. The first row has a second field with ten bytes. The structure of the second and third rows is the same and comprises two additional fields with three bytes each. The last row has a second field with five bytes.

AA1234567890

BBABCABC

BBXYZXYZ

CC12345

Specifications in the Module Configuration of the Module Processor

Module Key

Parameter Name

Parameter Value

Plain2XML

Transform.Class

com.sap.aii.messaging.adapter.Conversion

Plain2XML

Transform.ContentType

text/xml;charset=utf-8

Plain2XML

xml.conversionType

StructPlain2XML

Plain2XML

xml.processFieldNames

fromConfiguration

Plain2XML

xml.documentName

Document

Plain2XML

xml.documentNamespace

http://xi.com/test

Plain2XML

xml.recordsetName

Recordset

Plain2XML

xml.recordsetStructure

NameA,1,NameB,*,NameC,1

Plain2XML

xml.keyFieldName

Key

Plain2XML

xml.keyFieldType

CaseSensitiveString

Plain2XML

xml.NameA.fieldNames

Key,field-nameA

Plain2XML

xml.NameA.fieldFixedLengths

2,10

Plain2XML

xml.NameA.keyFieldValue

AA

Plain2XML

xml.NameB.fieldNames

Key,field-nameB1,field-nameB2

Plain2XML

xml.NameB.fieldFixedLengths

2,3,3

Plain2XML

xml.NameB.keyFieldValue

BB

Plain2XML

xml.NameC.fieldNames

Key,field-nameC

Plain2XML

xml.NameC.fieldFixedLengths

2,5

Plain2XML

xml.NameC.keyFieldValue

CC

Note

In xml.recordsetStructure, you can add a name for each different structure followed by the number of occurrences or an asterisk for unbounded occurrences. For each structure name, you can configure the structure separately in a separate namespace such as xml.NameA.fieldNames.

If your source file is a CSV file, replace each xml.<NameX>.fieldFixedLengths parameter with xml.<XXX>.fieldSeparator.

The result of this conversion is as follows:

<ns:Document xmlns:ns="http://xi.com/test">

<Recordset>

<NameA>

<Key>AA</Key>

<field-nameA>1234567890</field-nameA>

</NameA>

<NameB>

<Key>BB</Key>

<field-nameB1>ABC</field-nameB1>

<field-nameB2>ABC</field-nameB2>

</NameB>

<NameB>

<Key>BB</Key>

<field-nameB1>XYZ</field-nameB1>

<field-nameB2>XYZ</field-nameB2>

</NameB>

<NameC>

<Key>CC</Key>

<field-nameC>12345</field-nameC>

</NameC>

</Recordset>

</ns:Document>

Conversion in the Receiver Communication Channel

The following example describes simple and complex conversion using the MessageTransformBean module in receiver communication channel.

Module Name

Type

Module Key

localejbs/AF_Modules/MessageTransformBean

L

<XML2Plain>

Note

The name of the module key is arbitrary. You can choose any name. However, for the parameter configuration you must refer to the same module key name that you have assigned to the MessageTransformBean module.

Do not enter any spaces after parameter names or values in your configuration.

Simple Conversion

The XML structure of the source file should follow the same structure as the result of the SimplePlain2XML conversion.

<resultset>

<row>

<column-name1>ABC</column-name1>

<column-name2>12345</column-name2>

<column-name3>Text1</column-name3>

</row>

<row>

<column-name1>XYZ</column-name1>

<column-name2>67890</column-name2>

<column-name3>Text2 Text3</column-name3>

</row>

</resultset>

Note

The names of the tags are arbitrary. You can choose any name. As the tags are not identified by name, do not miss any tag.

Specifications in the Module Configuration of the Module Processor

Module Key

Parameter Name

Parameter Value

XML2Plain

Transform.Class

com.sap.aii.messaging.adapter.Conversion

XML2Plain

Transform.ContentType

text/plain;charset=utf-8

XML2Plain

xml.conversionType

SimpleXML2Plain

XML2Plain

xml.addHeaderLine

0

XML2Plain

xml.fieldFixedLengths

3,5,10

XML2Plain

xml.fixedLengthTooShortHandling

Cut

The result of this conversion is as follows:

ABC12345Text1

XYZ67890Text2 Text

Complex Conversion

In a receiver communication channel, you can map an XML file to a complex plain file with different lines. The XML structure of the source file should follow the same structure as the result of the SimplePlain2XML conversion.

<resultset>

<row>

<NameA>

<field-nameA1>1234567890</field-nameA1>

<field-nameA2>XYZ</field-nameA2>

</NameA>

</row>

<row>

<NameB>

<field-nameB1>ABC</field-nameB1>

<field-nameB2>DEF</field-nameB2>

<field-nameB3>GHI</field-nameB3>

</NameB>

</row>

<row>

<NameB>

<field-nameB1>OPQ</field-nameB1>

<field-nameB2>RST</field-nameB2>

<field-nameB3>UVW</field-nameB3>

</NameB>

</row>

<row>

<NameC>

<field-nameC>12345</field-nameC>

</NameC>

</row>

</resultset>

Note

The tag names NameA, NameB, and NameC are arbitrary. You can choose any name for the tags, but the structure should be identical.

Specifications in the Module Configuration of the Module Processor

Module

Key

Parameter Name

Parameter Value

XML2Plain

Transform.Class

com.sap.aii.messaging.adapter.Conversion

XML2Plain

Transform.ContentType

text/plain;charset=utf-8

XML2Plain

xml.conversionType

StructXML2Plain

XML2Plain

xml.addHeaderLine

0

XML2Plain

xml.recordsetStructure

NameA,NameB,NameC

XML2Plain

xml.NameA.fieldFixedLengths

3,3

XML2Plain

xml.NameA.fixedLengthTooShortHandling

Cut

XML2Plain

xml.NameB.fieldFixedLengths

3,3,3

XML2Plain

xml.NameC.fieldFixedLengths

5

Note

If you want to create a CSV file, use parameter xml.NameA.fieldSeparator instead of xml.fieldFixedLengths.

The result of this conversion is as follows:

123XYZ

ABCDEFGHI

OPQRSTUVW

12345

 

 

 

End of Content Area