Use BADI to Do Additional Checks and Operations During Import some Records into S4HC by APIs
Recently, a customer approached me and asked a question “is it feasible to do some checks and operations on the fields from the screen when import some records with APIs”? The background for this customer asking this question is the SAP Cloud Platform is not ready to sell for the market the that customer is from.
This question is quite often mentioned by the customer from on premise ERP/ECC/S4HANA world. I guess most of us have on premise experience are always very happy and confident to give a “Yes” to this question when we do on premise projects. That’s because there are various kinds of enhancement approaches to achieve this such as using BADIs etc. However, when we talk about S/4HANA Cloud(MTE) , i guess many of us sometimes are not that confident like before to answer this question due to the limitation of public cloud product, although S4HC offers two types of extensions in-app and side-by-side.
Luckily, for some of the business context like purchase order, sales order etc. which SAP offers few BADIs to do the enhancement like on premise. Although there are restricted ABAP syntaxes such as the following, we can still use the current available ways to fulfill some requirements like the question mentioned above.
- Any database operation except selects from released views
- Tweaking new tasks
- Dynamic programming
- Obsolete ABAP statements
- Code generation
- Only whitelisted (released) APIs can be used.
In order to prove we indeed can do some enhancements with using BADI during import the records by APIs, i did the simple test, see below:
1. Use one of the purchase order ODATA API in Postman to send a update request to S4HC like below:
2. Use BADI “Modification of Purchase Order Header” to update the field “document status”.(the screen below just shows its technical name). This BADI is actually triggered when the record gets imported in system.
3. When go to purchase order, the field “Document Status” is updated with value “Successful”.
Through the testing above, we can see we can even do the similar enhancements like we do in on-premise. I think this would might offer one more approach to do some specific requirements to those customers who currently don’t use or don’t have chance to use SAP Cloud Platform.For those customer using SAP Cloud Platform, they can easily and more flexible to achieve this by SAP CPI where using iFlows.
One point has to be mentioned that the BADI “Modification of Purchase Order Header” mentioned above is currently only support update custom fields at current stage. It would be useful if it can also support standard fields in future release.
Hope this would give a little bit help.
Thanks & Regards,