Skip to content

Avoid Hardcoding System & Tenant Environment Checks (sy-sysid, sy-mandt) ​

WarningSecurity & Robustness#EC NO_HARDCODED_ENVRemote Enabled

Overview ​

Avoid reading environment system fields (sy-sysid, etc.).

ATC Finding Message: Avoid reading environment system fields (sy-sysid, sy-uname, etc.)

Rationale ​

Branching business logic on hardcoded SAP System IDs (sy-sysid = 'PRD'), client numbers (sy-mandt = '100'), or server hostnames makes ABAP code fragile, untestable in sandbox environments, and incompatible with cloud transports. In multi-tenant ABAP Cloud systems (BTP), hardcoding client numbers breaks tenant isolation and violates SAP Clean Core guidelines.

Best Practice: Encapsulate environment configurations in feature toggles, custom configuration tables, or standard SAP BPF/BTP environment services.

Non-Compliant ​

abap
" Anti-pattern: Hardcoded environment and client checks
IF sy-sysid = 'PRD' AND sy-mandt = '100'.
  send_live_bank_order( is_payment ).
ELSEIF sy-sysid = 'DEV'.
  mock_bank_response( ).
ENDIF.

Compliant ​

abap
" Clean ABAP: Feature toggle or environment service configuration
IF mo_env_service->is_live_payment_active( ) = abap_true.
  send_live_bank_order( is_payment ).
ELSE.
  mock_bank_response( ).
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
CHECK_SYSIDBooleantrueDetect hardcoded checks against sy-sysid
CHECK_MANDTBooleantrueDetect hardcoded client number comparisons against sy-mandt
CHECK_HOSTBooleantrueDetect hardcoded server hostnames (sy-host)
CHECK_DBSYSBooleantrueDetect database system checks (sy-dbsys)
CHECK_OPSYSBooleantrueDetect operating system checks (sy-opsys)
CHECK_UNAMEBooleantrueDetect hardcoded user names (sy-uname) in conditional branches
ONLY_CONDITIONALBooleanfalseOnly flag occurrences when used inside conditional comparisons (IF, CASE)

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.