Using SAP connection pools

Using SAP connection pools

By using Integration Studio you can easily create an extension that connects to a SAP server. In a nutshell, the generated code converts all Service Studio parameters to SAP parameters, opens a connection to the SAP server, invokes the BAPI, closes the connection and converts the results back to Service Studio.

This usually works fine, but in scenarios where a lot of BAPIs are invoked in the same request, you may run into performance problems. These performance problems might be associated with opening and closing the connection to SAP each time you invoke a BAPI. To overcome this, you can use connection pooling.

To do this, edit the source code of the extension and find the places where the code opens the connection to SAP. This will be something like:
_Tmp_proxy.Connection = new SAP.Connector.SAPConnection(_Tmp_destination);


Replace this code with the following, and your code will start using connection pools:
_Tmp_proxy.Connection = SAP.Connector.SAPConnectionPool.GetConnectionFromPool(_Tmp_destination.ConnectionString);

You also need to change the way the connections are closed. Find the code that looks like this:

And replace with:

From this point onward your extension will start using a SAP connection pool, avoiding the expense of opening and closing a SAP connection for each BAPI call.