Skip to content

Avoid Nested COND or SWITCH Expressions ​

WarningClean ABAP & Modern Syntax#EC NO_NESTED_CONDRemote Enabled

Overview ​

Avoid Nested COND or SWITCH Expressions.

ATC Finding Message: Avoid nesting COND or SWITCH expressions inside each other

Rationale ​

Nesting COND or SWITCH constructor expressions inside each other creates deeply indented, hard-to-read expression trees. Modern Clean ABAP guidelines explicitly recommend avoiding nested constructor expressions; instead, separate complex decision branches into focused helper methods or classic CASE constructs.

Non-Compliant ​

abap
lv_val = COND #( WHEN cond1 THEN COND #( WHEN cond2 THEN 'A' ELSE 'B' ) ELSE 'C' ).

Compliant ​

abap
lv_val = COND #( WHEN cond1 AND cond2 THEN 'A'
                 WHEN cond1           THEN 'B'
                 ELSE                      'C' ).

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.