ABAP Quality Rules and Categories

The quality rules used by the Analyze ABAP Quality action are defined in the file specified for the action’s Quality Rule File property. By default, this property refers to the default_quality_rules.xml file stored in the <LiveCompare install dir>\web\shared\data\ABAP Quality directory on the LiveCompare server.

The default quality rules file defines a number of rules that check for various tokens in the ABAP source code to be analyzed. Depending upon the rule definition, tokens may be checked for anywhere in the ABAP source code, or within a particular structure or statement. Each rule is assigned to a category, and may be of one of the following classes:

  • Rules in the Error class indicate a definite problem or inefficiency in the ABAP source code.
  • Rules in the Warning class indicate a potential inefficiency in the ABAP source code, or that the ABAP source code should be reviewed manually.
  • Rules in the ^ ABOVE TRIGGERED BY ^ class are triggered by post processing rules listed earlier in the Analyze ABAP Quality action’s results.

The default_quality_rules.xml file defines the following rules:

Category: 700+ kernel systems

Cannot Enter Length Less Than or Equal to Zero when Accessing Fields

This rule in the Warning class checks whether the regular expression \+OFF.*\(\s*(0|-.*)\s*\)occurs within a MOVE statement.

Incorrect Transaction Call

This rule in the Warning class checks whether the regular expression TRANSACTION.*USING.*AND SKIP FIRST SCREEN occurs within a CALL statement.

Category: ABAP Failures

ABAP failures assign offset

This rule in the Error class checks whether any code matching the regular expression OFFSET occurs within an ASSIGN statement.

ABAP failures by token

This rule in the Error class checks whether the tokens BREAK or BREAK-POINT occur anywhere within a line of ABAP source code. If the Analyze ABAP Quality action’s Expand Includes property is set to ‘true’, the token BREAK-POINT will be detected for each line in which the BREAK token is detected. This is because BREAK is implemented internally by SAP as follows:

IF SY-UNAME = 'userid'. BREAK-POINT.

ABAP failures call function bapi

This rule in the Warning class checks whether any code matching the regular expression \bFUNCTION\b.*'BAPI occurs within a CALL statement.

ABAP failures e071k objfunc

This rule in the Error class checks whether any code matching the regular expression \bE071K\b.*OBJFUNC occurs anywhere within a line of ABAP source code.

ABAP failures get run time

This rule in the Error class checks whether the token GET RUN TIME occur in sequence anywhere within a line of ABAP source code.

ABAP failures no database selection

This rule in the Error class checks whether the token NO DATABASE SELECTION occur in sequence anywhere within a line of ABAP source code.

Category: ABAP Objects

Cannot Convert Dates

This rule in the Warning class checks whether the token CONVERT DATE occurs within a METHOD structure.

Cannot Convert Inverted Dates

This rule in the Warning class checks whether the token CONVERT INVERTED-DATE occurs within a METHOD structure.

Cannot Use *-CORRESPONDING

This rule in the Warning class checks whether the tokens ADD-CORRESPONDING, SUBTRACT-CORRESPONDING, MULTIPLY-CORRESPONDING or DIVIDE-CORRESPONDING occur within a METHOD structure.

Cannot Use INFOTYPES

This rule in the Warning class checks whether the token INFOTYPES occurs within a METHOD structure.

Cannot Use MARK

This rule in the Warning class checks whether the token MARK occurs within a METHOD structure.

Cannot Use NODES Statement

This rule in the Warning class checks whether the token NODES occurs within a METHOD structure.

Cannot Use Obsolete Key Declaration with TABLE LINE

This rule in the Warning class checks whether the token TABLE LINE occurs within a METHOD structure.

Cannot Use PACK

This rule in the Warning class checks whether the token PACK occurs within a METHOD structure.

Cannot Use RANGES

This rule in the Warning class checks whether the token RANGES occurs within a METHOD structure.

Cannot Use REJECT

This rule in the Warning class checks whether the token REJECT occurs within a METHOD structure.

Cannot Use STOP

This rule in the Warning class checks whether the token STOP occurs within a METHOD structure.

Cannot Use TABLES Statement

This rule in the Warning class checks whether code matching the regular expression ^TABLES occurs within a METHOD structure.

No Definition of Field Groups in Methods

This rule in the Warning class checks whether the token FIELD-GROUPS occurs within a METHOD structure.

No local copies using ASSIGN

This rule in the Warning class checks whether the token ASSIGN LOCAL COPY occurs within a METHOD structure.

No Obsolete Casting for Interface Parameters

This rule in the Warning class checks whether the token STRUCTURE occurs within a METHODS statement.

No search limitations with dynamic ASSIGN

This rule in the Warning class checks whether the token ASSIGN TABLE FIELD occurs within a METHOD structure.

Obsolete Automatic Calculations

This rule in the Warning class checks whether the tokens MAXIMUM, MINIMUM or SUMMING occur within a METHOD structure.

ON CHANGE OF - ENDON not Permitted

This rule in the Warning class checks whether the token ON CHANGE OF occurs within a METHOD structure.

Category: BDC Interfaces

Call Dialog

This rule in the Error class checks whether the token CALL DIALOG occurs anywhere within a line of ABAP source code.

Call Transaction

This rule in the Error class checks whether the token CALL TRANSACTION occurs anywhere within a line of ABAP source code.

Category: Complexity

Avoid artifacts with long lines

This rule in the Warning class checks for artifacts with long source code lines. The maximum line length allowed (in characters) is set in the Analyze ABAP Quality action’s Parameter Default Overrides table as the MaxLineLength value. The default value is 80.

Avoid Classes Where All Data Members Not Private

This rule in the Warning class checks for classes where none of the data members are private.

Avoid Classes With Too Many Data Members

This rule in the Warning class checks for classes with too many data members. The maximum number of data members allowed is set in the Analyze ABAP Quality action’s Parameter Default Overrides table as the MaxClassDataMembers value. The default value is 10.

Avoid Classes With Too Many Interfaces

This rule in the Warning class checks for classes with too many interfaces. The maximum number of interfaces allowed is set in the Analyze ABAP Quality action’s Parameter Default Overrides table as the MaxClassInterfaces value. The default value is 10.

Avoid Classes With Too Many Methods

This rule in the Warning class checks for classes with too many methods. The maximum number of methods allowed is set in the Analyze ABAP Quality action’s Parameter Default Overrides table as the MaxClassMethods value. The default value is 10.

Avoid Function Groups With Too Many Functions

This rule in the Warning class checks for function groups with too many functions. The maximum number of functions allowed is set in the Analyze ABAP Quality action’s Parameter Default Overrides table as the MaxFunctionsInFunctionGroup value. The default value is 20.

Avoid large programs

This rule in the warning class checks for programs with too many source lines. The maximum number of source lines allowed is set in the Analyze ABAP Quality action’s Parameter Default Overrides table as the MaxSourceLines value. The default value is 500.

Avoid programs / includes with too many forms

This rule in the Warning class checks for programs or includes with too many forms. The maximum number of forms allowed is set in the Analyze ABAP Quality action’s Parameter Default Overrides table as the MaxForms value. The default value is 30.

Avoid programs / includes with too many includes

This rule in the Warning class checks for programs or includes with too many includes. The maximum number of includes allowed is set in the Analyze ABAP Quality action’s Parameter Default Overrides table as the MaxForms value. The default value is 30.

Avoid Recursive Function Calls

This rule in the Warning class checks for functions that call themselves directly.

Calculate Complexity

This rule in the Warning class calculates the complexity of ABAP source code.

Category: Developer Impact Analysis

Local Test Class

This rule in the Info class checks for the string DEFINITION FOR TESTING anywhere with a class.

Category: Documentation

Avoid objects with low comment/code ratio

This rule in the warning class checks for objects with a low ratio of full-line comments to code. The minimum percentage of comment lines required is set in the Analyze ABAP Quality action’s Parameter Default Overrides table as the MaxSourceLines value. The default value is 10.

Non-comment documentation

This rule in the Error class checks for documentation that is not part of a comment.

Category: Fan-in / Fan-out

Check Fan-In

This rule in the Error class checks for objects (excluding Classes, Web DYNPROs and BSP Applications) that are referenced by too many other objects. Multiple references from the same object are counted as one access, and BREAK statements are excluded from the analysis. The maximum number of references allowed is set in the Analyze ABAP Quality action’s Parameter Default Overrides table as the MaxFanin value. The default value is 5.

Check Fan-Out

This rule in the Error class checks for objects (excluding Classes, Web DYNPROs and BSP Applications) that reference too many other objects. Multiple references to the same object are counted as one access, and BREAK statements are excluded from the analysis. The maximum number of references allowed is set in the Analyze ABAP Quality action’s Parameter Default Overrides table as the MaxFanout value. The default value is 5.

Category: Find Authority Check

Authority Check

This rule in the Info class checks for OBJECT <name> entries within AUTHORITY-CHECK statements.

Category: HANA

CL_SQL_STATEMENT

This rule in the Warning class checks whether any code matching the regular expression CL_SQL occurs anywhere within a line of ABAP source code.

CX_SQL_STATEMENT

This rule in the Warning class checks whether any code matching the regular expression CX_SQL occurs anywhere within a line of ABAP source code.

DB Hints

This rule in the Error class checks whether any code matching the regular expression % _HINTS occurs anywhere within a line of ABAP source code.

DB_EXISTS_INDEX

This rule in the red class checks whether any code matching the regular expression \bFUNCTION\b.*'DB_EXISTS occurs within CALL statement.

DD_INDEX_NAME

This rule in the Error class checks whether any code matching the regular expression \bFUNCTION\b.*'DD_INDEX_NAME occurs within a CALL statement.

Depooling Declustering (select)

This rule in the ^ ABOVE TRIGGERED BY ^ class checks for SELECT statements (excluding SELECT SINGLE statements) that do not contain an ORDER BY clause. If a match is found, the appropriate table name is stored in a capture group, and each of the HANA post processing rules in the rule’s <PostRules> section is executed.

The post processing rules scan the source file for matches that include the captured table name. The ^ ABOVE TRIGGERED BY ^ class name indicates that any matching post processing rule occur earlier in the Analyze ABAP Quality action’s results than the main rule that triggered them.

EXEC SQL

This rule in the Error class checks whether the token EXEC SQL occurs anywhere within a line of ABAP source code.

Obsolete ABAP variable declarations (INCLUDE STRUCTURE)

This rule in the Warning class checks for obsolete ABAP variable declarations using the token INCLUDE STRUCTURE. Obsolete ABAP variable declarations (LIKE)

This rule in the Warning class checks for obsolete ABAP variable declarations using the token LIKE, followed by a Data Dictionary element.

Search DB Operations in Pool/Cluster Tables

This rule in the Error class checks for SELECT … FROM statements that are performed for cluster tables.

SELECT Statements with BYPASSING BUFFER

This rule in the Warning class checks whether the code BYPASSING BUFFER occurs within a SELECT statement.

SELECT Statements with Subsequent CHECK

This rule in the Warning class checks whether the token CHECK occurs within a SELECT statement.

SELECT Statements with Subsequent DELETE

This rule in the Warning class checks whether the token DELETE occurs within a SELECT statement.

Category: HANA_POST_PROCESSING

These rules are used in the <Post Rules> section of the Depooling Declustering (select) rule described above, and are not available for selection in an AAQ Select List parameter. They are invoked using a captured table name if a match occurs in the main part of either rule.

$HANA PP BINARY SEARCH

This rule in the Error class checks whether any code matching the regular expression BINARY SEARCH occurs within a READ TABLE statement.

$HANA PP CONCATENATE LINES OF

This rule in the Error class checks whether the token INTO occurs within a CONCATENATE statement.

$HANA PP DELETE ADJACENT

This rule in the Error class checks whether any code matching the regular expression for ADJACENT DUPLICATES occurs within a DELETE statement.

$HANA PP DELETE FROM

This rule in the Error class checks whether any code matching the regular expression \bFROM\b.*TO occurs within a DELETE statement.

$HANA PP DELETE INDEX

This rule in the Error class checks whether the token INDEX occurs within a DELETE statement.

$HANA PP FIND IN TABLE

This rule in the Error class checks whether any code matching the regular expression IN TABLE occurs within a FIND statement.

$HANA PP LOOP

This rule in the Error class checks whether the tokens NEW, END, FIRST, LAST, EXIT, RETURN or LEAVE occur within a LOOP structure.

$HANA PP LOOP AT

This rule in the Error class checks whether any code matching the regular expression \bFROM\b.*TO occurs within a LOOP statement.

$HANA PP MODIFY INDEX

This rule in the Error class checks whether the token INDEX occurs within a MODIFY statement.

$HANA PP PROVIDE

This rule in the Error class checks for PROVIDE statements.

$HANA PP READ TABLE

This rule in the Error class checks whether the token INDEX occurs within a READ statement.

$HANA PP REPLACE IN TABLE

This rule in the Error class checks whether any code matching the regular expression \bIN.*TABLE\b.*WITH occurs within a REPLACE statement.

$HANA PP SEARCH

This rule in the Error class checks whether the token FOR occurs within a SEARCH statement.

Category: Missing Code

Empty case

This rule in the Error class checks for empty CASE structures.

Empty Catch Blocks

This rule in the Warning class checks for empty CATCH statements.

Empty else

This rule in the Error class checks for empty ELSE statements.

Empty elseif

This rule in the Error class checks for empty ELSEIF statements.

Empty function/form/module check

This rule in the Warning class checks for empty FORM, FUNCTION and MODULE structures.

Empty if

This rule in the Error class checks for empty IF structures.

Empty include check

This rule in the Warning class checks for INCLUDEs that are empty, and INCLUDEs that contain comments only. INCLUDEs that contain text only are not treated as empty. In the Analyze ABAP Quality action’s Object Quality Scorecard dataset, the Status column is set to ‘No ABAP’ for an INCLUDE that contains no ABAP code, or to ‘no code’ for an INCLUDE that is not completely empty but contains no code.

Empty program check

This rule in the Warning class checks for programs that contain no statements.

Empty select statement

This rule in the Error class checks for empty SELECT structures, where there is no code between the SELECT and ENDSELECT statements. This rule excludes SELECT statements containing the tokens SINGLE or INTO TABLE, and SELECT statements containing an UP TO 1 ROWS clause.

Empty when

This rule in the Error class checks for empty WHEN statements.

Missing WHEN OTHERS

This rule in the Warning class checks for CASE statements that do not have WHEN OTHERS clauses.

Missing where restriction in select

This rule in the Warning class checks for SELECT statements that do not have WHERE clauses.

Category: Obsolete Features

CALL TRANSACTION Without AUTHORITY-CHECK addition

This rule in the Error class checks for CALL TRANSACTION statements that do not include an AUTHORITY-CHECK token.

Obsolete Automatic Calculations

This rule in the Warning class checks whether the tokens MAXIMUM, MINIMUM or SUMMING occur within a METHOD structure.

Obsolete field *sys*

This rule in the Error class checks whether any code matching the regular expression \*SYS\* occurs anywhere within a line of ABAP source code.

Obsolete system field

This rule in the Error class checks whether any tokens from a set of obsolete system fields occur anywhere within a line of ABAP source code. The default obsolete system fields to check for are defined in the <LiveCompare install dir>\web\shared\data\ABAP Quality\default_obsolete_system_fields.xml file on the LiveCompare server.

Category: Performance

Avoid Empty Loops

This rule in the Warning class checks for empty LOOP, DO or WHILE structures.

Avoid FOR ALL ENTRIES without emptiness check

This rule in the Warning class checks for FOR ALL ENTRIES statements that do not explicitly check the emptiness of the internal table used in the statement. The following emptiness checks are recognized:

  • CHECK NOT ts_table[] IS INITIAL.
  • IF NOT ts_table[] IS INITIAL.

This metric applies only to extremely large database tables (XXL tables).

Avoid GROUP BY

This rule in the Warning class checks for SELECT statements that include a GROUP BY clause.

Avoid MOVE-CORRESPONDING

This rule in the Warning class checks whether the token MOVE-CORRESPONDING occurs anywhere within a line of source code.

Avoid READ TABLE without BINARY SEARCH

This rule in the Warning class checks for READ TABLE statements that do not include the token BINARY SEARCH.

Avoid SELECT .. ENDSELECT without UP TO n ROWS

This rule in the Warning class checks for SELECT statements that do not include an UP TO clause.

Avoid SELECT ... ORDER BY

This rule in the Warning Class checks for SELECT statements that include an ORDER BY clause.

Avoid SELECT DISTINCT

This rule in the Warning class checks for SELECT DISTINCT statements.

Avoid SELECT INTO CORRESPONDING FIELDS OF

This rule in the Warning class checks whether any code matching the regular expression INTO CORRESPONDING FIELDS OF occurs within a SELECT statement.

Avoid sub-queries

This rule in the Warning class checks whether the tokens SELECT, UPDATE or DELETE occur within a SELECT statement.

Commit work in a loop

This rule in the Warning class checks whether the token COMMIT WORK occurs within a LOOP, DO or WHILE structure.

Database modification in loop

This rule in the Warning class checks whether the tokens UPDATE or DELETE occur within a LOOP, DO or WHILE structure. UPDATE TASK statements, and DELETE and UPDATE statements for internal tables are not considered.

Inefficient append in loop

This rule in the Warning class checks whether the token APPEND occurs within a LOOP, DO or WHILE structure.

Inefficient append in select

This rule in the Error class checks whether the token APPEND occurs within a SELECT structure.

Inefficient insert in loop

This rule in the Error class checks whether the token INSERT occurs within a LOOP, DO or WHILE structure.

Inefficient insert in select

This rule in the Error class checks whether the token INSERT occurs within a SELECT structure.

Inefficient select in loop

This rule in the Error class checks whether the token SELECT occurs within a LOOP, DO or WHILE structure.

Inefficient submit in loop

This rule in the Error class checks whether the token SUBMIT occurs within a LOOP, DO or WHILE structure.

Nested loop

This rule in the Warning class checks whether the tokens LOOP, DO or WHILE occur within a LOOP, DO or WHILE structure.

Nested select

This rule in the Warning class checks whether the token SELECT occurs within a SELECT structure.

Query on more than 4 tables

This rule in the Warning class checks for SELECT statements that perform joins on more than four tables.

Use of check in loop

This rule in the Warning class checks whether the token INTO occurs within a LOOP, DO or WHILE structure.

Select statements that do not use an active index

This rule in the Warning class identifies SELECT statements referring to SAP tables that do not use an active index.

Use of check in select

This rule in the Warning class checks whether the token CHECK occurs within a SELECT structure.

Use of into in loop

This rule in the Warning class checks whether the token INTO occurs within a LOOP, DO or WHILE structure.

Use of like in delete

This rule in the Warning class checks whether the token LIKE occurs within a DELETE statement.

Use of like in select

This rule in the Warning class checks whether the token LIKE occurs within a SELECT statement.

Use of like in update

This rule in the Warning class checks whether the token LIKE occurs within an UPDATE statement.

Use of not equals in select

This rule in the Warning class checks whether the tokens <> or NE occur within a SELECT statement.

Use of select *

This rule in the Warning class checks for SELECT * statements.

Use of select single *

This rule in the Warning class checks for SELECT SINGLE * statements.

Use of wait

This rule in the Warning class checks whether the token WAIT occurs anywhere within a line of ABAP source code.

Category: Reliability

Avoid string literals in assignments

This rule in the Warning class checks for the use of literal values (identified by the ‘ regular expression) anywhere in a line of ABAP source code. Literal values in CONSTANT, IF and ELSEIF statements are permitted.

Avoid Processing level breaks in LOOP AT

This rule in the Error class checks for LOOP AT … WHERE constructs that also include any of the following AT events: AT FIRST, AT NEW, AT END or AT LAST.

Avoid unchecked return code

This rule in the Error class checks for SELECT, UPDATE, INSERT, DELETE or MODIFY statements that are not followed by the token SY-SUBRC or SYST-SUBRC. Queries containing COUNT in their SELECT clause are not considered.

Avoid unchecked return code READ DATASET

This rule in the Error class checks for READ DATASET statements that are not followed by the token SY-SUBRC or SYST-SUBRC.

Avoid unchecked return code READ TABLE

This rule in the Error class checks for READ TABLE statements that are not followed by the token SY-SUBRC or SYST-SUBRC.

Category: Runtime Error

Negative static output position

This rule in the Error class checks for negative numeric values in POSITION or SKIP statements.

Negative static write position

This rule in the Error class checks for negative offsets in WRITE or WRITE AT statements.

Category: SAP Internal use token

SAP Internal use system field

This rule in the Warning class checks whether any tokens from a set of internal system field occur anywhere within a line of ABAP source code. The default internal system fields to check for are defined in the <LiveCompare install dir>\web\shared\data\ABAP Quality\default_internal_system_fields.xml file on the LiveCompare server.

Update of system table

This rule in the Error class checks for system tables that are modified using UPDATE, MODIFY, INSERT INTO or DELETE FROM statements.

Category: Security

authority-check

This rule in the Warning class checks for missing AUTHORITY-CHECK statements in Program (PROG) objects to identify ABAP code that does not perform the required security checking.

CALL TRANSACTION without AUTHORITY-CHECK

This rule in the Error class checks for CALL TRANSACTION statements that do not include a WITH AUTHORITY-CHECK token.

Check calls to auth_switch_objects

This rule in the Error class checks for the token ‘AUTH_SWITCH_OBJECTS’ in CALL statements.

FUNCTION without AUTHORITY-CHECK

This rule in the Error class checks for functions that do not include the AUTHORITY-CHECK token.

Category: Unreferenced Objects

Avoid Unreferenced Functions

This rule in the Warning class checks for functions that are not referenced by any other artifacts.

Avoid Unreferenced Includes

This rule in the Warning class checks for includes that are not reference by any other artifacts.

Analyze ABAP Quality Actions