info@yenlo.com
eng
Menu
WSO2 Products 4 min

Configuring the WSO2 SAP Adapter – part 3

Thijs Volders
Thijs Volders
Strategic Technology Officer
SAP

SAP.png In this third and final chapter in the WSO2 ESB SAP adapter blog-series we have reached handling BAPI calls with the WSO2 ESB SAP adapter.

In the previous posts, part 1 and part 2, I talked about configuring and using iDOC with the adapter.

This post will describe how to invoke BAPI RPCs at the SAP side.

Invoking a BAPI at SAP is very similar to sending an iDOC to SAP. You create an endpoint where the protocol is “bapi”. See the folllowing example inSequence which invokes a BAPI RPC:

<inSequence>
<send>
<endpoint name="sapidocendpoint">
<address uri="bapi:/SAPSYS01"/>
</endpoint>
</send>
</inSequence>

This, by itself, doesn’t invoke a BAPI at the SAP side. It merely instructs WSO2 to send the message which is in-flight to the SAP BAPI endpoint.

A BAPI messages to SAP can be either complete structures/tables or can be as simple as a set of parameters. The former being only partially supported by the WSO2 SAP Adapter.

The limitation of the SAP adapter, at the time of writing the adapter version is 1.0.0, is that it can only handle single-level structures. Even though a BAPI allows to create a complex nesting structure you cannot (and probably should not) use it.

When sending a BAPI message from WSO2 to SAP it needs to adhere to the following structure:

<bapirfc name="{rfcFunctionName}">
<import name="{jcoStructureName}">
<structure>
<field name="{fieldName}">{fieldValue_to_set_to_structure_field}</field>
</structure>
<field name="{fieldName}">{fieldValue}</field>
</import>
<tables>
<table name="{tablename}">
<row id="{rowId}"> <!-- collection of rows -->
<field name="{fieldName}">{fieldValue}</field>
</row>
</table>
</tables>
</bapirfc>

The import and table elements are mutually exclusive and you should use either one or the other at the same time.

The simplest form of a BAPI-call is having no import and no tables element. Invoking the SAP standard BAPI GET_USERLIST is as simple as the following message:

<bapirfc name="BAPI_USER_GETLIST"></bapirfc>

Wrap this in the SOAP body of a SOAP envelope and send it to your BAPI-endpoint containing proxy. If your SAP adapter is configured correctly then you should get back something similar to:

<BAPI_USER_GETLIST>
<INPUT>
<MAX_ROWS>0</MAX_ROWS>
<WITH_USERNAME/>
</INPUT>
<OUTPUT>
<ROWS>8</ROWS>
</OUTPUT>
<TABLES>
<RETURN/>
<SELECTION_EXP/>
<SELECTION_RANGE/>
<USERLIST>
<item>
<USERNAME>ALEREMOTE</USERNAME>
<FIRSTNAME/>
<LASTNAME/>
<FULLNAME/>
</item>
%u2026.
</BAPI_USER_GETLIST><

Sending a BAPI with a single parameter could look like:

<bapirfc name="WSO2_GET_DETAIL">
<import>
<field name="FIELDVALUE">123456789</field>
</import>
</bapirfc>

And last but not least an example using a table:

<bapirfc name="WSO2_EAN_CONVERT">
<tables>
<table name="EANTAB">
<row id="0">
<field name="EAN">9789510252697</field>
</row>
</table>
</tables>
</bapirfc>

When using the elements from the structure as shown before you must use the attributes specified with the elements. They are all mandatory on the elements themselves.

If your ESB installation has the SAP adapter version 1.0.0 you will run into an issue when invoking the BAPI call using the tables. The depicted version does not handle the row id’s properly causing the table to stay empty when it is sent to SAP.

We have worked with WSO2 by providing them with a code fix which they have slightly adjusted and implemented. They have provided a patch fort his problem.

When you have an active product support subscription with WSO2 we can provide you with this patched version of the WSO2 SAP Adapter. By providing us with the details of your subscription we can provide you with the patch-JAR.

Please click here to request this patch-JAR

This was the final post in a series of three. The first described where to find the configuration of the SAP adapter in your SAP system, the second described the way to send and receive IDOCs and this post described invoking BAPIs in the SAP system.

Happy SAPping!

 

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.

 

{{cta(‘d8004418-ade6-4e7c-b9b6-e58d0ed55010’)}}

 

eng
Close