Skip to content

Prefer IS [NOT] INITIAL over lines( ) or Literal Comparisons ​

WarningClean ABAP & Modern SyntaxQuickFix Ready#EC PREF_INITRemote Enabled

Overview ​

Prefer IS [NOT] INITIAL over lines( ) or empty literals.

ATC Finding Message: Use IS [NOT] INITIAL instead of lines( ) or empty literal comparison

Rationale ​

Comparing lines( ) to zero or a string to an empty literal asks an indirect question. IS INITIAL states emptiness directly and works for tables, strings, structures, and elementary values. It also avoids counting overhead and literal edge cases.

Non-Compliant ​

abap
IF lines( lt_items ) > 0.
  process( ).
ENDIF.

Compliant ​

abap
IF lt_items IS NOT INITIAL.
  process( ).
ENDIF.

Automated QuickFix ​

This rule provides an automated QuickFix directly in Eclipse ABAP Development Tools (ADT):

  1. Position the cursor on the flagged statement.
  2. Press Ctrl + 1 (Quick Assist).
  3. Select the automated refactoring to apply the clean syntax immediately.

Suppression ​

To suppress findings for this rule, append the pseudo-comment to the statement:

abap
" Standard pseudo-comment:
... "#EC PREF_INIT

" SAP CI_ prefix format:
... "#EC CI_PREF_INIT

Technical Details ​

Released under the MIT License.