Improving Code Quality using ABAP Test Cockpit
After completing this lesson, you will be able to:After completing this lesson, you will be able to:
- Create ATC check variants
- Perform static code checks with ATC
Static Code Checks
Syntax Check - Extended Check - ABAP Test Cockpit
ABAP Development has several tools to perform static code checks.
Syntax Check
Extended Check
ABAP Test Cockpit
ATC Check Variants
ATC Check Variants
Each execution of an ATC check is controlled by an ATC Check Variant. The check variant determines which checks are performed and provides values for the parameters of the checks.
When you perform an ATC check run, you can either use the global default check variant of your system or you can specify the check variant that you want to use. This can be an existing check variant or a check variant that you created yourself.
From a technical point of view, ATC check variants are ABAP development objects. They belong to development packages and you can transport them to other systems.
How to Create an ATC Check Variant
In this demonstration, you will see how to create an ATC check variant to specify the checks that you want to perform.
Prerequisites
You have an ABAP (Cloud) Project in ADT (ABAP Development Tools in Eclipse).
Your user is assigned to a transport request for development in customer name space.
In your project, you already created package ZS4D401_00.
How to Run an ATC Check and Analyze the Result
In this demonstration, you will see how to execute an ATC check run on an ABAP class and analyze the result.
Prerequisites
You have an ABAP (Cloud) Project, a transport request, package ZS4D401_00.
Your package contains ATC check variant Z00_EXTENDED_CHECK.
Your package contains global class ZCL_00_ATC_UNUSED_VARIABLES, and the class is active.
You display the source code of global class ZCL_00_ATC_UNUSED_VARIABLES (tab Global Class).
Pseudo Comments and Pragmas
Pseudo Comments and Pragmas
Not all ATC findings are critical and you might decide to ignore them. Some others might turn out to be false alarms at a closer look. An example for such a false alarm is a dynamic usage of a variable, which is invisible for the static code check.
ATC has two techniques to suppress findings:
- Pseudo Comments
You can suppress certain ATC findings by adding a specific comment at the end of the source code line with the finding. In the example, the pseudo comment "#EC NEEDED is used. EC stands for Extended Check in this case.
Like any other comment, a pseudo comment is not visible for the ABAP syntax check and the ABAP compiler. We call it a pseudo comment, because it has an influence on the Extended Check and ATC.
- Pragmas
Other findings you can suppress by adding a certain keyword starting with ## to the ABAP statement. These keywords are called Pragmas. It is very important that pragmas are placed inside the ABAP statement, not after it. In the example, pragma ##needed
is used, and it is placed before the period sign that ends the DATA statement.
NoteBecause pragmas are visible to the syntax check, they are also used to suppress certain warnings from the syntax check. This is not possible with pseudo comments.
If you want to know whether you can suppress a given ATC finding, refer to the finding details on the ATC Problems view. Here, you also find the information on which technique you should use.
Save progress to your learning plan by logging in or creating an account
Login or Register