Bridging between SAP and other systems using the adapter framework; Part 2
Last time I wrote about how easy it was to execute an arbitrary BAPI using the adapter framework and get meaningful results back as XML. At the simplest level, that’s pretty much all you really need to integrate with SAP. Unless…
There’s always something that doesn’t easily fit into a simple workflow, so there are additional supporting components that can help with SAP integration. Today I’ll just talk about how to ensure that multiple BAPI calls can share the same RFC connection. Generally speaking, when inserting data using a BAPI, there are no guarantees that data inserted by that BAPI will be available for the next BAPI call unless the same underlying connection is re-used which leads us to what SAP calls a stateful function call with JCo.
Stateful RFC Calls
So to manage a stateful sequence of RFC calls, then you need to use RfcServiceListStatefulSessionStart and StatefulSessionEnd. These classes ensure that the underlying RFC connection is kept open during message processing and the same connection is re-used by all JCo services in the list.
Here, we are calling the function BAPI_COMPANYCODE_GETLIST and then for each company id that is returned we will execute BAPI_COMPANYCODE_GETDETAIL. Each of those records will end up with the company details written out to SampleQ1.
Building up complexity in the adapter framework is simply a matter of deciding which pieces you want, and adding them into the workflow. It can be as simple or as complicated as you like.