How to make your custom code cloud-ready and upgrade-stable
Hopefully you have already heard the news that the SAP S/4HANA 2022 release is out now for on premise and private cloud customers including the new ABAP cloud development approach for ABAP custom extensions. As the Chief Product Owner of the ABAP Platform Boris Gebhardt outlined in the blog post How to use Embedded Steampunk in SAP S/4HANA Cloud, private edition and in on-premise – The new ABAP extensibility guide we have now the same extensibility capabilities in SAP S/4HANA 2022 on premise and SAP S/4HANA 2022 Private Cloud Edition as in SAP S/4HANA 2208 Public Cloud.
The new on-stack developer extensibility option (Embedded Steampunk) allows customers and partners to create cloud-ready and upgrade-stable ABAP extensions. The details about this new extensibility option can be found in the new ABAP Extensibility guide. The new ABAP cloud development model is important both for new customers and partners to create new extensions and for existing customers and partners to start a new extension project.
In the chapter 6 of the new ABAP Extensibility guide we also outline how customers and partners with existing custom code can transform their extensions in a step-by-step approach towards the new ABAP cloud development model. It can be achieved by separating custom code from the SAP core application and implementing all accesses to SAP business objects only through well defined, cloud-ready and upgrade-stable interfaces.
The focus of this blog is on the custom code, which is tightly coupled with the core application logic of SAP S/4HANA and can be renovated or innovated on-stack directly on the SAP S/4HANA ABAP platform using Embedded Steampunk. The side-by-side renovation or innovation of custom code on SAP BTP ABAP Environment (Steampunk) is covered in the blogs How to bring your ABAP custom code to SAP BTP ABAP Environment and Semi-automatic custom code adaptation for SAP BTP ABAP Environment.
With this blog post we want to demonstrate with a very simple example (Hello World like) which tools are offered to ease the adaptation of existing custom code towards the new extensibility option with Embedded Steampunk.
Now let’s make a custom code object in your SAP S/4HANA 2022 system cloud-ready.
Check your custom code for cloud readiness
First, we need to check the custom code object (class ZCL_MATERIAL_INFORMATION in our example) for cloud readiness. For this just execute ABAP Test Cockpit (ATC) in the ABAP Development Tools in Eclipse with the cloud readiness checks over this class:
The results related to the cloud issues in the custom code are displayed in the ATC Problems View. The findings marked with the yellow light bulb can be fixed with Quick Fixes.
Apply Quick Fixes in the ADT in Eclipse
Therefore, we can start adapting the code using the mass-enabled Quick Fixes (just select all findings and apply the Recommended Quick Fixes context menu):
Before we agree to the Quick Fixes proposals, we can review the proposed cloud readiness changes in the corresponding “before” (Original Source) and “after” (Refactored Source) editors:
In this example the custom boolean data type boole_d needs to be replaced with the only released for the usage in the cloud the ABAP_BOOLEAN data type, the access to the SY structure fields must be done not directly but using the corresponding API, you need to escape with @ the host variables and use the assignment operator instead of the MOVE statement. Finally press the Finish button to apply the Quick Fixes.
After applying the Quick Fixes if we run again ABAP Test Cockpit with the cloud readiness checks over our custom code object ZCL_MATERIAL_INFORMATION, the remaining cloud issues will be displayed in the ATC Problems View:
Use released APIs
Let’s take a closer look at the ATC findings list. The selected finding shows for example, that our custom code uses the not released application API. It means, it accesses the table T006 directly whereby the direct access to the table T006 is not permitted in the cloud and the released application API, the CDS view I_UNITOFMEASURE, must be used instead. In this way you see that the information about the successor released object is provided directly in the details of an ATC finding and you can use it for the correction.
After applying the necessary implementation changes to the custom code object ZCL_MATERIAL_INFORMATION in order to use the I_UNITOFMEASURE CDS view to access the table T006 we can proceed the same way for other remaining ATC findings. Finally, after we execute again the ABAP Test Cockpit cloud readiness checks we will get the empty ATC findings list:
Now our class ZCL_MATERIAL_INFORMATION is cloud ready.
In the near future we plan also to provide the information about the successor released APIs in the analysis results, when using Custom Code Migration app on SAP BTP for the remote check of an on-premise SAP system. This information will also support you to find the appropriate cloud ready succesor for the not released APIs in your custom code on the SAP releases before the SAP S/4HANA 2022.
Support for older SAP S/4HANA releases
If your SAP S/4HANA system is on the older release, then the information about the successor released object is not available in the details of an ATC finding, and you will get only the notification, that your code uses not released API, e.g. direct access to the application table MARA:
Therefore for the releases bevor SAP S/4HANA 2022 we offer a temporary solution for the detection of the released API. You can find out which released application API should be used to access the table MARA by using the corresponding SAP Note 3088062 – Identifying local APIs for S/4HANA Cloud. In this SAP Note there is the Excel table in the attachment which will help to identify the successor object (which is released for the cloud) for the access to the table MARA.
Just open the Excel table and search there for „MARA“. As you will see in the search result, the CDS view I_PRODUCT must be used instead of direct access to the MARA.