Avoid Hardcoding System & Tenant Environment Checks
WarningSecurity & Robustness#EC 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
Comparing sy-sysid, sy-mandt, or sy-host to literals bakes a specific system landscape into the code. The logic breaks after a client copy, system copy, or cloud tenant move. Use configuration, feature toggles, or authorization objects instead.
Non-Compliant
abap
IF sy-sysid = 'PRD' OR sy-mandt = '100'.
enable_production_mode( ).
ENDIF.Compliant
abap
IF is_feature_enabled( c_features-prod_mode ).
enable_production_mode( ).
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 |
|---|---|---|
CHECK_SYSID | Boolean | true |
CHECK_MANDT | Boolean | true |
CHECK_HOST | Boolean | true |
CHECK_DBSYS | Boolean | true |
CHECK_OPSYS | Boolean | true |
CHECK_UNAME | Boolean | true |
ONLY_CONDITIONAL | Boolean | false |
Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC HARDCODED_ENV
" SAP CI_ prefix format:
... "#EC CI_HARDCODED_ENVTechnical Details
- Native ATC Class:
ZCL_SKYLINT_NO_HARDCODED_ENV - Implementation File: zcl_skylint_no_hardcoded_env.clas.abap