Skip to content

Verify sy-subrc Promptly After System Calls ​

WarningSecurity & Robustness#EC CHECK_SUBRCRemote Enabled

Overview ​

Check sy-subrc after DB, table and string operations.

ATC Finding Message: Check sy-subrc after SELECT SINGLE, READ, AUTHORITY-CHECK, FIND, SEARCH

Rationale ​

Statements such as SELECT SINGLE, READ TABLE, and AUTHORITY-CHECK report success through sy-subrc. If another statement runs first, the return code is overwritten and the failure is silently ignored. Check sy-subrc immediately, or use a modern expression that handles absence explicitly.

Non-Compliant ​

abap
SELECT SINGLE customer_id FROM /dmo/customer
  WHERE customer_id = @lv_id
  INTO @lv_customer_id.
process_customer( lv_customer_id ).

Compliant ​

abap
SELECT SINGLE customer_id FROM /dmo/customer
  WHERE customer_id = @lv_id
  INTO @lv_customer_id.
IF sy-subrc = 0.
  process_customer( lv_customer_id ).
ENDIF.

Configuration & Thresholds ​

This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:

Parameter NameData TypeDefault Value
CHECK_SELECT_SINGLEBooleantrue
CHECK_READ_TABLEBooleantrue
CHECK_AUTHORITY_CHECKBooleantrue
CHECK_FIND_SEARCHBooleantrue
CHECK_ASSIGNBooleantrue

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.