Skip to content

Prefer xsdbool( ) for Boolean Assignments ​

WarningClean ABAP & Modern SyntaxQuickFix Ready#EC XSDBOOLRemote Enabled

Overview ​

Prefer xsdbool( ) expression over manual IF-ELSE assignment.

ATC Finding Message: Prefer xsdbool( ) over manual IF-ELSE assignment

Rationale ​

An IF/ELSE whose only task is to assign abap_true or abap_false uses many lines for a single boolean conversion. xsdbool( ) expresses the condition directly and assigns the result in one statement. This removes duplicated branches and makes the relationship between condition and flag obvious.

Non-Compliant ​

abap
IF lv_discount > 0.
  lv_has_discount = abap_true.
ELSE.
  lv_has_discount = abap_false.
ENDIF.

Compliant ​

abap
lv_has_discount = xsdbool( lv_discount > 0 ).

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 XSDBOOL

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

Technical Details ​

Released under the MIT License.