Analyze ABAP Quality Actions

Analyze ABAP Quality actions retrieve the ABAP source code associated with objects from the specified RFC Destination or LUX, and analyze the source code according to a set of quality metrics. The ABAP code that is analyzed includes source code obtained from the expansion of macros, and source code associated with enhancement points.

Note that in order for enhancement points to be analyzed, their ‘switch’ must be set to ON. Additionally, if the enhancement points are specified in an INCLUDE, the INCLUDE’s parent program must be of type SCAN, with its INCLUDES parameter set to ‘X’.

The rules used by the Analyze ABAP Quality action are organized into the following scenarios and categories:

Scenario: Authorization Note Impact

Category Description
Find Authority Check Finds AUTHORITY-CHECK statements.

Scenario: Developer Impact Analysis

Category Description
Developer Impact Analysis Identifies changing objects with associated ABAP unit tests.

Scenario: Fix My Code

Category Description
HANA Identifies issues specific to SAP HANA ABAP source code.

Scenario: Run and Optimize

Category Description
700+ kernel systems Identifies issues specific to SAP kernel release 700 and later releases.
ABAP Failures Identifies ABAP code that may cause runtime errors in SAP 4.7 or later releases.
ABAP Objects Identifies issues specific to ABAP objects.
Complexity Analyzes the complexity of the ABAP source code.
Documentation Highlights issues relating to ABAP source code documentation.
Fan-in / Fan-out

Highlights objects that have a high fan-in or fan-out value (greater than 5). The fan-in value of an object is the number of other objects that are referencing it. Multiple references from the same object are counted as one access. The fan-out value of an object is the number of other objects that are referenced in it. Multiple references to the same object are counted as one access.

The default fan-in and fan-out threshold values may be modified by editing the ‘Check Fan-in’ and ‘Check Fan-out’ rules in the <LiveCompare install dir>web\Data\ABAP Quality\default_quality_rules.xml file on the LiveCompare server.

Missing Code Identifies ABAP structures or statements that have missing code.
Obsolete Features Identifies obsolete features in the ABAP source code.
Performance Highlights issues that may affect the performance of ABAP source code.
Reliability Highlights issues relating to the reliability of ABAP source code.
Runtime Error Identifies potential runtime errors in the ABAP source code.
SAP Internal use token Identifies ABAP tokens that are intended for SAP internal use only.
Security Highlights security issues in the ABAP source code.
Unreferenced Objects Identifies unreferenced objects.

Scenario: Technical Upgrade

Category Description
ABAP Failures Identifies ABAP code that may cause runtime errors in SAP 4.7 or later releases.
BDC Interfaces Identifies the use of CALL TRANSACTION and CALL DIALOG statements.
Complexity Analyzes the complexity of the ABAP source code.
Runtime Error Identifies potential runtime errors in the ABAP source code.

Scenario: Upgrade

Category Description
700+ kernel systems Identifies issues specific to SAP kernel release 700 and later releases.
ABAP Failures Identifies ABAP code that may cause runtime errors in SAP 4.7 or later releases.
ABAP Objects Identifies issues specific to ABAP objects.
BDC Interfaces Identifies the use of CALL TRANSACTION and CALL DIALOG statements.
Complexity Analyzes the complexity of the ABAP source code.
Documentation Highlights issues relating to ABAP source code documentation.
Fan-in / Fan-out

Highlights objects that have a high fan-in or fan-out value. The fan-in value of an object is the number of other objects that are referencing it. Multiple references from the same object are counted as one access. The fan-out value of an object is the number of other objects that are referenced in it. Multiple references to the same object are counted as one access.

The default fan-in and fan-out threshold values may be modified by editing the ‘Check Fan-in’ and ‘Check Fan-out’ rules in the <LiveCompare install dir>web\Data\ABAP Quality\default_quality_rules.xml file on the LiveCompare server.

HANA Identifies issues specific to SAP HANA ABAP source code.
Missing Code Identifies ABAP structures or statements that have missing code.
Obsolete Features Identifies obsolete features in the ABAP source code.
Performance Highlights issues that may affect the performance of ABAP source code.
Reliability Highlights issues relating to the reliability of ABAP source code.
Runtime Error Identifies potential runtime errors in the ABAP source code.
SAP Internal use token Identifies ABAP tokens that are intended for SAP internal use only.
Security Highlights security issues in the ABAP source code.
Unreferenced Objects Identifies unreferenced objects.

Each category includes a set of rules which are applied to the source code to be analyzed. The action returns a Table dataset that includes a quality score for each object in each of the analyzed categories, a Table dataset listing the ABAP source code for which each of the quality rules that were triggered, and a Table dataset providing a summary of the rule violations for each source object.

The quality rules and categories used by the Analyze ABAP Quality action are defined in .xml files stored in the <LiveCompare install dir>\web\shared\data\ABAP Quality directory on the LiveCompare server.

Action Property Description
AAQ Select List An AAQ Select List parameter or dataset specifying the quality rules to be used in the analysis. Quality rules are organized into categories, and a rule category may be used in one or more analysis scenarios.
Class Exclusions A Table parameter or dataset specifying a set of rule classes that are to be excluded from the analysis. The table should have at least a column named CLASS containing the classes to be excluded. Class names are case-insensitive.
Code Fix A Table dataset listing each of the source objects that triggered a quality rule. The table includes the name, category and class of the triggered rule, and the line of ABAP source code in which the rule violation occurred. The table also includes a replacement line of source code which resolves the rule violation. This dataset is used by the Create ABAP Report action.
Complexity Rank Overrides

A Table parameter or dataset with RANK and THRESHOLD columns which allows one or more of the default complexity values stored Analyze ABAP Quality action’s rules file to be overridden. The RANK column should store a complexity rank, either ‘Good’, ‘Bad’ or ‘Ugly’ (other complexity ranks are ignored). The THRESHOLD value should store the lowest complexity value allowed for the rank.

The default complexity ranks stored in the Analyze ABAP Quality action’s rules file are as follows: Good (0 to 10), Bad (11 to 15), Ugly (16 and above). These values are used if a corresponding RANK is not specified in the Complexity Rank Overrides table.

Exclusions A Table parameter or dataset specifying the quality rules that should be excluded from the analysis for each source object. If this parameter is not set, all the quality rules in the specified categories will be applied to the ABAP code associated with all the source objects.
Expand Blocks A Boolean parameter or dataset specifying whether the blocks of ABAP code in the Rule Break Detail dataset are expanded to display their individual lines of source code. If this parameter is set to ‘true’, code blocks will be expanded in the Rule Break Detail dataset. If the parameter is set to ‘false’, only the line containing the token is shown. The default value for this parameter is ‘false’.
Expand Includes

A Boolean parameter or dataset specifying whether the source code to be analyzed should be expanded to include the contents of INCLUDE files. Set this parameter to ‘true’ to analyze the contents of INCLUDE files, or to ‘false’ to leave INCLUDE files unexpanded. The default value for this parameter is ‘false’. For BSP Application (WAPA), Class (CLAS), Web DYNPRO (WDYN) objects, INCLUDE files are always expanded, regardless of this setting.

With the exception of BSP Applications, Classes and Web DYNPROs, INCLUDE files are not expanded by rules in the Fan-in / Fan-out category when calculating an object’s Fan-in or Fan-out value.

Parameter Default Overrides A Table parameter or dataset with PARAMETER and VALUE columns which allows the default values stored in the Analyze ABAP Quality action’s rules file to be overridden. These values are used in a number of ABAP quality rules. If the parameter is not set, the values stored in the action’s rule file are used as the default.
Object Quality Score Card A Table dataset which provides a quality score for each source object in each of the specified categories.
Quality Rule File

A String parameter or dataset specifying the name of a file that defines the quality rules to be used by the action. The default value is ‘default_quality_rules.xml’; this file is stored in the <LiveCompare install dir>\web\shared\data\ABAP Quality directory on the LiveCompare server.

Note that custom quality rule definition files should be stored in the <LiveCompare user data dir>\public\ABAP Quality directory.

RFC Destination An RFC Destination parameter or dataset referring to the system from which to retrieve the objects to be analyzed. This property should be set if an analysis is to be performed using RFC Destination data.
Rule Break Detail A Table dataset listing each of the source objects that triggered a quality rule. The table includes the name, category and class of the triggered rule, and the line of ABAP source code in which the rule violation occurred.
Rule Break Summary A Table dataset listing the number of violated rules for each of the analyzed objects, grouped by object name and sorted by rule name.
Source A Table parameter or dataset which lists the objects whose source code is to be analyzed. The table should have at least a NAME column containing the name of each object, and a TYPE column specifying each object’s type. Object types should be specified using UPPER CASE. If the Analyze ABAP Quality action is used to analyze LUX data, the Source table may have a NAME column only.
Source Code Out A Table dataset which stores the ABAP source code for each of the source objects. This dataset is used by the Create ABAP Report action.
Table Set

A Table Set dataset containing a set of code tables retrieved from a LUX using the Read LUX Data action. In the UA02 - Analyze Custom Code Quality workflow, the following tables are retrieved:

ABAP_LEVEL_CUST

ABAP_NAMES_CUST

ABAP_SOURCE_CODE_CUST

ABAP_SOURCE_COUNT_CUST

ABAP_STATEMENTS_CUST

ABAP_STRUCTURES_CUST

ABAP_TOKENS_CUST

The Exclusions table should contain the following columns:

Column Description
TYPE The type of an object from the Source table.
NAME The name of the object.
RULE The name of a quality rule to be ignored when analyzing the object’s source code. Rule names are case-insensitive.
LINES This column may contain a single line number, or a comma-separated list of line numbers in the object’s source code. If one or more line numbers are specified, the quality rule is only ignored for the specified line numbers. If a LINES column is blank for any object/rule entry, the specified rule will be ignored for all lines in the object’s source code.

If the TYPE and NAME columns are left blank, the exclusions apply to all input objects.

When a Parameter Default Overrides parameter is created for the action, it stores the following parameter values which match the defaults stored in the default_quality_rules.xml rules file:

Parameter Value Used in Rules
MaxSourceLines 500 Avoid large programs
MaxClassInterfaces 10 Avoid Classes With Too Many Interfaces
MaxClassMethods 10 Avoid Classes With Too Many Methods
MaxInterfaceMethods 10 Avoid Interfaces With Too Many Methods
MaxClassDataMembers 10 Avoid Classes With Too Many Data Members
MaxFunctionsInFunctionGroup 20 Avoid Function Groups With Too Many Functions
MaxForms 30 Avoid programs / includes with too many forms
MaxIncludes 30 Avoid programs / includes with too many includes
MaxLineLength 80 Avoid artifacts with long lines
MinPercentComments 10 Avoid objects with low comment/code ratio
MaxFanin 5 Check Fan-In
MaxFanout 5 Check Fan-Out, Check Fan-Out Class Derivative

The Code Fix dataset has the following columns:

Column Description
TYPE The type of an object from the Source table. If the Source table does not have a TYPE column and an analysis is performed using LUX data, this column contains the value INCL.
NAME The name of the object.
INCLUDE This column appears in the Rule Break Detail dataset if the Expand Includes parameter is set to ‘true’. It contains the name of the INCLUDE file in which the rule violation occurred.
METHOD If the Expand Includes parameter is set to true, this column stores the name of the method in which the rule violation occurred.
RULE The name of a quality rule triggered during the analysis.
TOKEN

The ABAP token or matching Regular Expression string that triggered the rule. If the Expand Blocks parameter is set to ‘true’, the token or matching string is displayed in the row corresponding to the matching line of ABAP source code. If the Expand Blocks parameter is set to ‘false’, only the line matching the token or Regular Expression string is shown. For rules that detect empty statements or structures, where no specific token triggered the rule, the name of the containing statement or structure is shown in square brackets. For example, [SELECT].

For counting rules, for example Check Fan-In and Check Fan-Out, the TOKEN column contains the numerical count value. For the Avoid artifacts with long lines rule, the TOKEN column contains the line length.

SOURCE The ABAP source code in which the rule violation was detected. Complete ABAP statements are shown, excluding their trailing full stops. Continuation lines are excluded from the output; this may result in gaps in line numbering. Each line of source code for a particular rule violation is listed in a separate table row.
NEW_SOURCE A placement line of source code which will resolve the detected rule violation.
SOURCE_LINE The ABAP source code line number in which the rule violation occurred.

Note that in this release, the ‘Obsolete ABAP variable declarations (LIKE)’ quality rule is the only rule that populates the Code Fix dataset.

The Object Quality Score Card dataset has the following columns:

Column Description
TYPE The type of an object from the Source table. If the Source table does not have a TYPE column and an analysis is performed using LUX data, this column contains the value INCL.
NAME The name of the object.
STATUS This column is set to ‘OK’ if the object exists on the system referred to by specified RFC Destination, to ‘not found’ if the object could not be found on the specified SAP system, to ‘error in ABAP’ if the object’s ABAP code contains one or more syntax errors, or to ‘no code’ if the object’s ABAP code contains comments only. If an object from the Source table is not active, its status value is set to ‘no ABAP’.
<Quality Category>

The table includes columns named after each of the quality categories selected for the analysis. Each object is given a quality score for each of the categories. For categories with rules, the quality score is expressed as a percentage and is calculated as follows:

(Number of rules in category - Number of distinct violated rules for this category) / Number of rules in category * 100

For the Complexity category, the results include a complexity ranking in addition to the complexity value. If the default quality rule file is used, complexity values between 0 and 10 are ranked ‘Good’, complexity values between 11 and 15 are ranked ‘Bad’, and complexity values greater than 15 are ranked ‘Ugly’. For compound object types, for example Classes (CLAS), Web DYNPROs (WDYN) or BSP Applications (WAPA), the complexity score is the average of the object’s complexity score, and the complexity scores of its component objects.

For the Fan-in / Fan-out category, the results show the Fan-in and Fan-out values for the object. The fan-in of an object is the number of other objects that are referencing it. Multiple references from the same object are counted as one access. The fan-out of an object is the number of other objects that are referenced in it. Multiple references to the same object are counted as one access.

If the input to the Analyze ABAP Quality action is a LUX, the Fan-in and Fan-out values for each object will be set to 0.

The Rule Break Detail dataset has the following columns:

Column Description
TYPE The type of an object from the Source table. If the Source table does not have a TYPE column and an analysis is performed using LUX data, this column contains the value INCL.
NAME The name of the object.
INCLUDE For Class (CLAS) and Web DYNPRO (WDYN) objects, this contains the name of the INCLUDE file in which the rule violation occurred. For other object types, the INCLUDE name is shown if the Expand Includes parameter is set to ‘true’.
CLASS_TYPE For Web DYNPRO (WDYN) objects, this column stores the type of the controller in which the rule violation occurred.
CLASS_NAME For Web DYNPRO (WDYN) objects, this column stores the name of the controller in which the rule violation occurred.
METHOD For Class (CLAS) and Web DYNPRO objects, this column stores the name of the method in which the rule violation occurred. For other object types, the method name is shown if the Expand Includes parameter is set to ‘true’.
CATEGORY A quality category specified for the analysis.

CLASS

The class of a violated rule from the specified category. In the default rule definitions provided with LiveCompare, rules may be in either the ‘Error’, ‘Warning’ or ‘Info’ class. Error rules indicate a definite problem or inefficiency in the ABAP source code. Warning rules indicate a potential inefficiency in the ABAP source code, or that that the ABAP source code should be reviewed manually. Info rules provide information only.

RULE The name of a quality rule triggered during the analysis.
TOKEN The ABAP token or Regular Expression that triggered the rule. If the Expand Blocks parameter is set to ‘true’, the token or Regular Expression is displayed in the row corresponding to the matching line of ABAP source code. If the Expand Blocks parameter is set to ‘false’, only the line matching the token or Regular Expression is shown. For rules that detect empty statements or structures, where no specific token triggered the rule, the name of the containing statement or structure is shown in square brackets. For example, [SELECT].
LINE NUMBER The ABAP source code line number in which the rule violation was detected. If the INCLUDE column for the rule violation contains a value, the line number refers to a line in the INCLUDE file.

SOURCE

The ABAP source code in which the rule violation was detected. Complete ABAP statements are shown, excluding their trailing full stops. Continuation lines are excluded from the output; this may result in gaps in line numbering. Each line of source code for a particular rule violation is listed in a separate table row.

CAPTURE Some rules use a capture token as part of their processing. This column stores the value of the captured token.
SEQ The first ABAP source code line number in which the violation was detected. For Class (CLAS) and Web DYNPRO (WDYN) objects, or when the Expand Includes parameter is set to ‘true’, this column refers to a line number in the object’s INCLUDE file. This column may be used when sorting the Rule Break Detail dataset to display the violations for each object ordered by line number.

The Rule Break Summary dataset has the following columns:

Column Description
TYPE The type of an object from the Source table. If the Source table does not have a TYPE column and an analysis is performed using LUX data, this column contains the value INCL.
NAME The name of the object.
CATEGORY The category of a rule that was triggered for the source object.
CLASS The class of the violated rule.
RULE The name of the violated rule.
DETECTIONS The number of times the rule was triggered for the source object.

Note that rule violations are not reported for code that is automatically generated by SAP. This does not apply to rule that apply to the object as a whole (for example, the Authority-Check rule).

The Source Code Out dataset has the following columns:

Column Description
TYPE The type of an object from the Source table.
NAME The name of the object.
SOURCE The object’s ABAP source code.

Example (RFC Destination Data):

 

Analyze ABAP Quality action example (RFC Destination Data).

Example (LUX Data):

Analyze ABAP Quality action example (LUX Data).

If you are using the Analyze ABAP Quality action to analyze code objects in a LUX, the Read LUX Data action’s Table Names parameter should be set to the following:

ABAP_LEVEL_CUST

ABAP_NAMES_CUST

ABAP_SOURCE_CODE_CUST

ABAP_SOURCE_COUNT_CUST

ABAP_STATEMENTS_CUST

ABAP_STRUCTURES_CUST

ABAP_TOKENS_CUST

To examine the details for an Analyze ABAP Quality action, double-click the action node, or select ‘View Details’ from the node’s context menu. The Details screen displays the number of source objects that were analyzed and the time taken for the action to complete.

The progress of an Analyze ABAP Quality action may be monitored by viewing the Details screen while the action is running. Time estimates are available after each object has been processed. If an analysis is performed using RFC Destination data, the following details are shown:

Item Description
Total objects The number of Source objects processed.
Remaining objects The number of Source objects that have not yet been processed.
Elapsed time (seconds) The time for which the Analyze ABAP Quality action has been running.
Estimated total time (seconds) The estimated total time required for the action to complete.
Remaining time (seconds) The estimated time remaining for the action to complete.
Total elapsed time hh:mm:ss The time for which the Analyze ABAP Quality action has been running in hours, minutes and seconds.

ABAP Quality Rules and Categories

Create ABAP Report Actions