Skip to content

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 NameData TypeDefault ValueDescription & Guidance
STRICT_RANGEBooleanfalseAlso 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_BETWEEN

Technical Details ​

Released under the MIT License.