WSO2 Products 4 min

Configuring the WSO2 SAP Adapter – part 2

Thijs Volders
Thijs Volders
Strategic Technology Officer

SAP.pngIn my previous post I guided you through the various screen within the SAP system to find all the parameters needed to configure the WSO2 SAP adapter. This new post will teach you on how to use the SAP adapter. Specifically setting up the adapter and an IDOC receiver and using it as an IDOC sender.
SAP can send IDocs to other systems easily. Its actually an out of the box feature available in SAP systems.

Given that WSO2 have developed an SAP adapter it provides us with the ability to consider the SAP server as ‘just another integration component’.

You can develop your integrations using the products available on the WSO2 platform and output your data to a SAP system. But thats not all, of course you’ll also need to be able to interact with SAP where SAP will produce some output which needs to be handled through your ESB for instance.

There are two ways to exchange data with a SAP system. There is IDoc, which is meant as a fire-and-forget integration pattern and there is BAPI which is synchronous request-reply.

In this post I’ll introduce the receiving and sending of IDocs.

Receiving IDocs

Ok, so lets start off with setting up WSO2 as an IDoc server so that you can receive IDoc within WSO2. Assuming you read and executed the previous post you should now have the SAPSYS01.dest and SAPSYS01.server files. To setup WSO2 as an IDoc server you need only the SAPSYS01.server configuration file in [WSO2_HOME]/repository/conf/sap.

Make sure that your axis2.xml (which is located in [WSO2_HOME]/repository/conf/axis2) has the SAPTransportListener named IDoc and the SAPTransportSender named IDoc uncommented/enabled.

Please create a proxy service. Use the Custom proxy type and give it contents similar to the following:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns=http://ws.apache.org/ns/synapse name="SAPAdapterProxy"
transports="idoc" statistics="enable" trace="enable" startOnLoad="true">
<log level="full"/>
<drop />
<log level="full"/>
<parameter name="transport.sap.enableTIDHandler">enabled</parameter>
<parameter name="transport.sap.serverName">SAPSYS01</parameter>


The magical parts are in bold.

First tell WSO2 to start listening with an IDoc transport listener by setting the transports attribute value to “IDoc”.

Then to configure the TransportListener you must set the two parameters which are highlighted at the bottom of the proxy. The first being the transactionHandler which needs to be enabled and the second needs tob e the servername of the SAP server you have a configuration setup for. In our case that is the SAPSYS01.server configuration file or SAPSYS01 SAP system name.

When you deploy this proxy then you should see a message in the log indicating that WSO2 is listening for incoming IDocs.

TID: [0] [ESB] [2014-02-04 11:28:44,474] [localhost-startStop-1] DEBUG {org.wso2.carbon.transports.sap.idoc.IDocEndpoint} - Engaging the default TID handler for : SAPSYS01 {org.wso2.carbon.transports.sap.idoc.IDocEndpoint}

TID: [0] [ESB] [2014-02-04 11:28:44,481] [localhost-startStop-1] INFO {org.wso2.carbon.transports.sap.idoc.IDocEndpoint} – IDoc server started with server name : SAPSYS01 and program ID : JCOSERVER01 {org.wso2.carbon.transports.sap.idoc.IDocEndpoint}

Within your SAP system you should be able to see that an RFC connection to WSO2 is alive.

When you now send an IDoc over the new RFC connection to the registered programID (which is JCOSERVER01 as can be seen from the logstatements above) it will end up in the WSO2 proxy and the log-mediator will show you the IDOC received from SAP.

When you don’t get the IDoc in the proxy then fiddle around a bit with the unicode setting in SAP. Experience showed me that enabling or disabling that at the SAP side fixes the connection and the IDoc is received properly.

Sending IDocs

Sending IDOCs is actually rather easier than receiving them. To send IDOCs to SAP you need to have the SAPSYS01.dest configuration file setup. Please see my previous post for more details.

Lets create a custom proxy again with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns=http://ws.apache.org/ns/synapse name="SAPSenderProxy"transports="http" startOnLoad="true" trace="enable" statistics="enable">
<log level="full"/>
<endpoint name="sapidocendpoint">
<address uri="idoc:/SAPSYS01"/>

<parameter name="serviceType">proxy</parameter>

This proxy has been configured as an ordinary one where you send your data to it over the HTTP transport. The special part is in the address of the send-mediator’s endpoint. You must configure it to use the IDoc transport and set the hostname-part of the URI to your SAP systems name.

You should now be up and running with your IDoc connections.

Please come back later for the BAPI-call alternative.

If you have any questions about this blogpost contact us via the comments section of this blog. View also our WSO2 Tutorialswebinars or white papers for more technical information. Need support? We do deliver WSO2 Product Support, WSO2 Development SupportWSO2 Operational Support and WSO2 Training Programs.


Full API lifecycle Management Selection Guide


smartmockups l0qqucke