Writing Data to SAP
K2 connect can be used to update data within a selected BAPI. With SAP, however, a procedure must be followed to maintain system security. The data is manipulated using the following steps:
- The records within the BAPI are locked.
- The record is updated using a custom function prepared by the developer to manipulate the BAPI Data.
- The records within the BAPI are released.
When you need to write data to SAP, be aware that you may need to "chain" several BAPIs together to update data. SAP has BAPIs that are used to "lock" a record so that it can be updated and other BAPIs that are used to "unlock" a record after changes have been applied.
Normally you call the ENQUEUE BAPI for the object that you are about to update, then call the BAPI that actually does the update, and then call the DEQUEUE BAPI for the same object to "commit" the changed data
Consider the screen shot below, where we are adding a new address for an employee with the BAPI_EMPADDRESS_CREATE BAPI. Notice that we are "wrapping" this BAPI between the BAPI_EMPLOYEET_ENQUEUE and BAPI_EMPLOYEET_DEQUEUE BAPIs so that the data can be written to the EMPLOYEE object.
When you use these BAPIs, also note that you would normally have to pass the ID of the record being updated to each of the BAPIs. This is achieved by using the mapping screen to re-use the ID input parameter in all of the chained BAPI calls, as shown in the example below