Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

1 Scenario

XI 3.0 SP9 provides a new function in the Adapter Framework. You can now use a conversion module in the various adapters, which enables you to convert XML files to flatstructures and the other way around.This guide shows you example configuration files. It does not describe all possible parameters. For more information, see the online documentation.

2 Introduction

In the Adapter Framework, all adapters are developed as modules. These modules canbe combined with other standard or user-defined modules. In the communicationchannel configuration, you can use the Module tab page to enter additional modules foreach receiver or sender channel. In SP9, there is a standard module MessageTransformBean for specific conversion routines, particularly in the JMS adapter. You can use this module in sender and receivercommunication channels. For sender channels, you can choose either a simple transformation to handle files inwhich all rows have the same structure, or a more complex transformation for files inwhich the rows can have different structures.For receiver channels, you can only use the simple transformation. All transformations can handle comma-separated-value (CSV) structures or structures with fixed field length. The options are very similar to the FCC adapter.

3 The Step-By-Step Solution

The first step for each configuration is to add the conversion module to the communication channel. Open the communication channel, select the Module tab page, and add the conversionmodule to the provided JMS adapter modules as follows:

Module Sequence in the Sender Channel

No.

Module Name

T

Module Key

1

localejbs/SAP XI JMS Adapter/ConvertJMSMessageToBinary

L

ReceiveMsg

2

localejbs/SAP XI JMS Adapter/ConvertBinaryToXMBMessage

L

ConvertMsg

3

localejbs/AF_Modules/MessageTransformBean

L

Plain2XML

4

localejbs/CallSapAdapter

L

ForwardToMS

Module Sequence in the Receiver Channel

No.

Module Name

T

Module Key

1

localejbs/AF_Modules/MessageTransformBean

L

XML2Plain

2

localejbs/SAP XI JMS Adapter/ConvertMessageToBinary

L

CallJMSService

3

localejbs/SAP XI JMS Adapter/SendBinarytoXIJMSService

L

Exit


The names of the module keys are only examples. You can choose any name. However,for the parameter configuration you must refer to the module key name you have assigned to the module MessageTransformBean. Make sure that you do not enter any spaces after parameter names or values in yourconfiguration, especially after copying values to the configuration from text files.The field length for the parameter values is only 256 bytes; this may mean you have touse short names for the XML field names. (With SP12 there is no restriction any more)


 

3.1 Example of a Simple Conversion in a Sender Communication Channel

Let us assume that we have a very simple file structure containing three fields with threebytes each, and a sample file with two rows:

Example

AAABBBCCC111222333

This leads to the following entries 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

SimplePlain2XML

Plain2XML

xml.processFieldNames

fromConfiguration

Plain2XML

xml.documentName

MyDocument

Plain2XML

xml.documentNamespace

 http://xi.com/test

Plain2XML

xml.structureTitle

MyTitle

Plain2XML

xml.fieldNames

 field-name1,field-name2,field-name3

Plain2XML

xml.fieldFixedLengths

3,3,3


 

The result of this conversion looks like this:

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

<MyTitle>

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

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

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

</MyTitle>

<MyTitle>

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

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

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

</MyTitle>

</ns:MyDocument>

If you have a CSV file, you use the parameter xml.fieldSeparator (with parameter value",") instead of xml.fieldFixedLengths.

3.2 Structure Conversion in a Sender Communication Channel

The structure conversion can handle files containing rows with different structures. Ineach row there is a key field to identify the structure. The rows with identical key fields ofcourse have identical structures.Let us assume that we have a sample file with four rows. Each row has a two-byte keyfield; the first row has a second field with ten bytes; the structure of the second and thirdrows is the same and comprises two additional fields with three bytes each; the last rowhas a second field with five bytes:

AA1234567890BBABCABCBBXYZXYZCC12345

The configuration for the conversion could look like this:

Module Configuration

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 MyDocument

Plain2XML xml.documentNamespace http://xi.com/test

Plain2XML xml.recordsetName MyRecordset

Plain2XML xml.recordsetStructure NameA,1,NameB,*,NameC,1

Plain2XML xml.keyFieldName MyKey

Plain2XML xml.keyFieldType CaseSensitiveString

Plain2XML xml.NameA.fieldNames MyKey,field-nameA

Plain2XML xml.NameA.fieldFixedLengths 2,10

Plain2XML xml.NameA.keyFieldValue AA

Plain2XML xml.NameB.fieldNames MyKey,field-nameB1,field-nameB2

Plain2XML xml.NameB.fieldFixedLengths 2,3,3

Plain2XML xml.NameB.keyFieldValue BB

Plain2XML xml.NameC.fieldNames MyKey,field-nameC

Plain2XML xml.NameC.fieldFixedLengths 2,5

Plain2XML xml.NameC.keyFieldValue CC

In xml.recordsetStructure, you add a name for each different structure followed by thennumber of occurrences or an asterisk for unbounded occurrences. For each structurename, you configure the structure separately in a separate namespace such as xml.NameA.fieldNames and so on. If your source file is a CSV file, replace each xml.XXX.fieldFixedLengths with xml.XXX.fieldSeparator.

The result of this conversion looks like this:

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

<MyRecordset>

<NameA>

<MyKey>AA</MyKey>

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

</NameA>

<NameB><MyKey>BB</MyKey>

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

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

</NameB>

<NameB>

<MyKey>BB</MyKey>

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

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

</NameB>

<NameC>

<MyKey>CC</MyKey>

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

</NameC>

</MyRecordset>

</ns:MyDocument>

3.3 Simple Conversion in a Receiver Communication Channel

For a receiver channel, only the simple conversion is available. The XML structure of thesource file has to follow the same structure as the result of the SimplePlain2XMLconversion:

<resultset>

<row>

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

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

<column-name3>My Text</column-name3>

</row>

<row>

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

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

<column-name3>This Text is too long</column-name3>

</row>

</resultset>

Module Configuration

ModuleKeyParameter 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 looks like this:

ABC12345My Text

XYZ67890This Text

If you want to create a CSV file, use parameter xml.fieldSeparator instead ofxml.fieldFixedLengths.Note: The names of the tags are examples. You can choose any name you like. As the tags are not identified by name, you have to assure that no tag is missing.

3.4 Structure Conversion in a Receiver Communication Channel

In a receiver communication channel, we want to map an XML file to a complex plain filewith different lines. The XML structure of the source file has to follow the same structureas 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>

Module Configuration

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

The result of this conversion looks like this:

123ABCABCDEFGHIOPQRSTUVW12345

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

The tag names NameA, NameB, and NameC are just examples; you can choose anynames for the tags, but you must make sure that the structure is identical.

NOTE: You can also use the .endSeparator parameter to control the line termination behavior similar to the function by the same name in the FCC adapter.

==

N.B., this is the content from the How To guide - 'How to Use the Content Conversion Module with the XI 3.0 J2EE JMS Adapter' which is no longer available on SDN.