Prefer BETWEEN for Inclusive Range Checks
WarningClean ABAP & Modern Syntax#EC PREF_BETWEENRemote Enabled
Overview
Prefer BETWEEN for inclusive range checks.
ATC Finding Message:
Combine the duplicated range comparison with BETWEEN
Rationale
lv_amount >= lv_min AND lv_amount <= lv_max repeats the same operand and spells out a single inclusive range. BETWEEN expresses the intent directly, removes the duplicated operand and makes off-by-one mistakes easier to spot. The rule only reports inclusive >=/<= pairs by default; strict >/< pairs are optional because they are not semantically equivalent for fractional values.
Non-Compliant
abap
IF lv_amount >= lv_min AND lv_amount <= lv_max.
approve( ).
ENDIF.Compliant
abap
IF lv_amount BETWEEN lv_min AND lv_max.
approve( ).
ENDIF.Configuration & Thresholds
This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:
| Parameter Name | Data Type | Default Value | Description & Guidance |
|---|---|---|---|
STRICT_RANGE | Boolean | false | Also suggest BETWEEN for strict >/< pairs, which is not equivalent for decimals (default: disabled) |
Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC PREF_BETWEEN
" SAP CI_ prefix format:
... "#EC CI_PREF_BETWEENRelated Rules
- Limit Boolean Expression Complexity in Conditional Statements —
#EC MAX_BOOL_EXPR - Remove redundant parentheses —
#EC NO_MANY_PARENS - Avoid Duplicate Branch Conditions —
#EC NO_DUP_COND
Technical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_BETWEEN - Implementation File: zcl_skylint_pref_between.clas.abap