Some BAPI remote functions commit database changes, but some don’t have a commit implemented in their code. By default, OutSystems Platform creates a new transaction for each SAP remote function call, and commits changes before closing it.
However, there are situations where you need to make several calls to SAP remote functions in the same transaction.
To achieve this, you need an extension module to manage stateful calls in SAP:
You want to lock the record of a patient before updating it, to avoid that others modify it at the same time. After the record is updated, you want to remove the lock from the record.
In the Forge, you can find component 'SAP Utilities'. It's a sample with an extension module for SAP, with actions for handling stateful calls. Get it here.
Because this extension makes use of the SAP Extensibility API, make sure you fill the requirements described in here.
Publish the extension.
To implement stateful calls in your application, add dependencies to the following actions in the extension:
Learn more about how to add dependencies.
Use SAP remote functions together with actions from the extension to implement a stateful call.
First, consume the following remote functions from SAP:
See how to consume SAP remote functions.
Implement stateful call in an action with the following flow (see picture):
In the flow to handle exceptions (see picture):
SAP Remote Function | SAP Extensibility API