Monday, 20 April 2020

Semi-automatic custom code adaptation for SAP Cloud Platform ABAP Environment

If you intend to use SAP Cloud Platform ABAP Environment and want to bring your custom code application to the Cloud the time will come, when you will need to adapt your custom code for Cloud on your brand new ABAP system running in the SAP Cloud Platform ABAP Environment.

For this purpose, you will run the proven tool ABAP Test Cockpit with the SAP_CP_READINESS check variant in ABAP Development Tools in Eclipse on your ABAP system in the SAP Cloud Platform ABAP Environment and will get a worklist of ATC findings which you will need to fix.

In order to minimize your custom code adaptation efforts for Cloud, we offer automatic code adaptations using the Quick Fixes (or Ctrl +1 shortcut) feature of ABAP Development Tools in Eclipse.

Prerequisites


Client: ABAP Development Tools (ADT) >= 3.4

Backend: ABAP system, running in the SAP Cloud Platform ABAP Environment.

Before you execute an ATC run over your custom code objects, they must be activated (despite of syntax errors).

Use cases for Quick Fixes


Currently we offer Quick Fixes for the following use cases.

ABAP Language Version 5 (Cloud)

If your custom code uses ABAP language statements which are not released for Cloud (which are not contained in the ABAP Language Version 5 (Cloud)), e.g. using MOVE statement instead of assignment, then your code will run into a syntax error in the SAP Cloud Platform ABAP Environment:

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform

The old language statements must be replaced by ABAP Language Version 5 (Cloud):

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform

Deprecated Data Elements

If your custom code is using e.g. a data element, which is not released for Cloud but there is an alternative, which must be used in the Cloud. For example, if your code contains not released boolean data types, then it will run into a syntax error in the SAP Cloud Platform ABAP Environment:

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform

These boolean data types must be replaced with the released data type ABAP_BOOLEAN:

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform
SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform

API calls instead of direct access to SY fields

If your custom code is using e.g. SY fields, which are not released for Cloud, your code will run into syntax errors in the SAP Cloud Platform ABAP Environment:

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform

Direct access to the SY fields must be replaced by the provided corresponding API calls:

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform

Available Quick Fixes for ABAP Language Version 5 (Cloud)


Currently the following ADT Quick Fixes are available for ABAP Language Version 5 (Cloud):

Original ABAP statement ABAP statement after Quick Fix 
ADD += or + 
DIVIDE  /= or / 
MULTIPLY   *= or * 
SUBTRACT  -= or – 
COMPUTE   = 
MOVE   = 
DESCRIBE TABLE LINES   LINES()
FREE  CLEAR 
REFRESH  CLEAR
MESSAGE  MESSAGE INTO
(only if MESSAGE is used for where-used list in IF 1 = 0. … ENDIF) 
CLASS-DEFINITION-LOAD   Statement deleted 
INTERFACE-LOAD   Statement deleted 
Old Open SQL syntax   New Open SQL syntax 
$SY-READ (SY-ZONLO)   cl_abap_context_info=>get_user_time_zone( ) 
$SY-READ (SY-DATUM)   cl_abap_context_info=>get_system_date( ) 
$SY-READ (SY-UZEIT)   cl_abap_context_info=>get_system_time( ) 

Applying a Quick Fix


Note: ATC findings that can be fixed with a Quick Fix are displayed with a lightbulb

There are two possibilities for applying Quick Fixes.

You can select an ATC finding from the ATC worklist and choose Quick Fix (or Ctrl + 1 shortcut) in the context menu:

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform

Then select the displayed Quick Fix in the popup and choose Finish:

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform

Recommendation: If there is more than one Quick Fix available for an ATC finding, we recommend to select the first Quick Fix displayed.

Alternatively, you can jump to the affected source code line by double clicking the corresponding ATC finding and choose Quick Fix in the context menu (or Ctrl + 1 shortcut). Double click the Quick Fix in the popup to apply it to the affected source code line.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform

That’s it. You can activate your source code and rerun ATC.

Using mass-enabled Quick Fixes 


You can use mass-enabled Quick Fixes to adapt full packages or software components in one shot and in this way drastically reduce your custom code adaptation efforts for Cloud.

Just select multiple ATC findings in your ATC result and use the context menu Recommended Quick Fixes…

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform

The wizard with recommended Quick Fixes for your selected ATC findings starts:

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform

On the next screen (Next button) you can see for each of your custom objects which changes are suggested by the Quick Fix in a convenient way in two editors displaying the original and refactored source side by side.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Prep, SAP Cloud Platform

If you click Finish button, you apply the Quick Fixes at one shot for all your selected ATC findings, for which the Quick Fixes are available.

No comments:

Post a Comment