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_CONDRelated Rules
- Prefer COND #( ) Expression over IF/ELSEIF/ELSE —
#EC PREF_COND - Prefer SWITCH #( ) Expression over CASE Statement —
#EC PREF_SWITCH - Limit Control Flow Nesting Depth (Guard Clause Enforcement) —
#EC MAX_NESTING
Technical Details
- Native ATC Class:
ZCL_SKYLINT_NO_NESTED_COND - Implementation File: zcl_skylint_no_nested_cond.clas.abap