Skip to content

Avoid DATA Attributes in Interfaces ​

WarningAnti-Patterns & Bad Practices#EC INTF_DATARemote Enabled

Overview ​

Avoid mutable DATA in interfaces; allow only CONSTANTS.

ATC Finding Message: Avoid mutable DATA in interfaces; declare CONSTANTS or move to class

Rationale ​

Interfaces describe behavior and should not introduce mutable state into their contract. A DATA attribute in an interface exposes implementation details and can create shared state across all implementers. Use methods to expose state and constants for immutable values.

Non-Compliant ​

abap
INTERFACE if_customer.
  DATA mv_state TYPE i.
ENDINTERFACE.

Compliant ​

abap
INTERFACE if_customer.
  CONSTANTS c_default_status TYPE i VALUE 1.
  METHODS get_state RETURNING VALUE(rv_state) TYPE i.
ENDINTERFACE.

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.