ABAP - Keyword Documentation →  ABAP - Reference →  Declarations →  Declaration Statements →  Classes and Interfaces →  Components in Classes and Interfaces →  Data Types and Attributes → 

CLASS-DATA

Quick Reference

Syntax

CLASS-DATA attr [options].

Effect

The statement CLASS-DATA can only be used in the declaration part of a class or an interface. The statement declares a static attribute attr whose validity is not associated with instances of a class but with the class itself. All instances of the class and its subclasses access the same static attribute.

The naming conventions apply to the name attr. The syntax of the additions options is identical to the statement DATA for instance attributes (only the addition WITH HEADER LINE must not be used).

Notes

Example

In this example, the static attribute text of class c1 is accessed using the class component selector without having created an instance of the class.

CLASS c1 DEFINITION.
  PUBLIC SECTION.
    CLASS-DATA text TYPE string VALUE `Static data`.
ENDCLASS.

START-OF-SELECTION.
  cl_demo_output=>display_text( c1=>text ).