CHECK_99 - Minimum number of WHENs in a CASEImprove this page
CASE statement should have a minimum number of
WHEN branches. If there is only one branch, it would be better to
FORM foo. DATA lv_bar TYPE i. CASE lv_bar. WHEN 1. WRITE: / 'hello world'. ENDCASE. ENDFORM.
can be replaced by
FORM foo. DATA lv_bar TYPE i. IF lv_bar = 1. WRITE: / 'hello world'. ENDIF. ENDFORM.
WHEN branches don’t count.
When setting the minimum number, please consider the recommendations in SAP’s styleguide for Clean ABAP: Prefer CASE to ELSE IF for multiple alternative conditions
The minium number of
WHEN branches is by default 2, but can be configured: