code pal for ABAP > Documentation > Constants Interface Check
This check is meant to prevent the creation of interfaces whose sole purpose is to define constants. You should usually prefer enumeration classes to interfaces that only declare constants.
The check searches for interfaces containing only constants.
Use enumeration classes instead.
In exceptional cases, you can suppress this finding by using the pseudo comment "#EC CONS_INTF
which should be placed right after the class definition header:
INTERFACE interface_name. "#EC CONS_INTF
CONSTANTS two TYPE i VALUE 2.
ENDINTERFACE.
Before the check:
INTERFACE /dirty/message_severity.
CONSTANTS:
error TYPE symsgty VALUE 'E',
warning TYPE symsgty VALUE 'W',
notification TYPE symsgty VALUE 'N'.
ENDINTERFACE.
After the check:
CLASS /clean/message_severity DEFINITION PUBLIC ABSTRACT FINAL.
PUBLIC SECTION.
CONSTANTS:
error TYPE symsgty VALUE 'E',
warning TYPE symsgty VALUE 'W',
notification TYPE symsgty VALUE 'N'.
ENDCLASS.
or
CLASS /clean/message_severity DEFINITION PUBLIC CREATE PRIVATE FINAL.
PUBLIC SECTION.
CLASS-DATA:
error TYPE REF TO /clean/message_severity READ-ONLY,
warning TYPE REF TO /clean/message_severity READ-ONLY,
notification TYPE REF TO /clean/message_severity READ-ONLY.
" ...
ENDCLASS.