6

How to make your custom code cloud-ready and upgrade-stable

 1 year ago
source link: https://blogs.sap.com/2022/10/26/how-to-make-your-custom-code-cloud-ready-and-upgrade-stable/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
October 26, 2022 4 minute read

How to make your custom code cloud-ready and upgrade-stable

After an SAP S/4HANA transition and adaptation of your custom code to the simplifications of the SAP S/4HANA it is recommendable to reinforce a clean core for your system by further optimization of your custom code. 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. See also the new ABAP Extensibility guide (chapter 6) for more details on how to transform your existing custom code after an SAP S/4HANA system conversion.

Just imagine, you want to apply a clean core principle for your SAP S/4HANA system and therefore you need to optimize your custom code to make it cloud-ready and upgrade-stable.

This blog demonstrates with a small example how you can achieve this. Let’s make a custom code object in your SAP S/4HANA 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:

cc_embed_1.png

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.

cc_embed_2-1.png

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):

cc_embed_3.png

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:

cc_embed_4-3.png

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:

cc_embed_5-1.png

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 application table MARA directly whereby the direct access to the table MARA is not permitted in the cloud and the released application API must be used instead.

cc_embed_6-1.png

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.

cc_embed_7-1.png

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.

cc_embed_8-1.png

After applying the necessary implementation changes to the custom code object ZCL_MATERIAL_INFORMATION in order to use the I_PRODUCT CDS view to access the table MARA, and finally executing again the ABAP Test Cockpit cloud readiness checks we will get the empty ATC findings list:

cc_embed_9-1.png

Now our class ZCL_MATERIAL_INFORMATION is cloud-ready.

By the way, if you have a new SAP S/4HANA 2022 system, then the information about the successor released API is provided directly in the Details of Analysis of the ATC finding. In the following example the direct access to the table T006 must be replaced with the released CDS Entity I_UNITOFMEASURE:

cc_embed_10-2.png

In the near future we plan also to provide the information about the successor released APIs  in the analysis results, when using the Custom Code Migration app on SAP BTP for the remote check of an on-premise SAP system. This information can also support you in detecting the appropriate cloud ready successor for the not released APIs in your custom code on the SAP releases before the SAP S/4HANA 2022.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK