Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Declarations →  Declaration Statements →  Classes and Interfaces →  ABAP Objects - Overview →  Classes →  Components of Classes 

Class Attributes

Attributes are internal data objects of any ABAP data type within a class. The content of the attributes specifies the state of the object. Reference variables can also be defined, which can then be used to create and address objects. This allows objects to be accessed within classes.

Attributes are defined in the declaration part of a class. Public attributes are completely visible from outside the class and as such are part of the interface between objects and their user. To encapsulate the state of the object, protected, package-visible, or private attributes must be used. The modifiability of non-private attributes can also be restricted using the addition READ-ONLY in the declaration.

Other versions: 7.31 | 7.40 | 7.54

Instance Attributes

The content of instance attributes forms the instance-specific state of the object. Instance attributes are declared using the DATA statement. The addition COMMON PART cannot be used in classes.

Static Attributes

The content of static attributes forms the instance-independent state of the object, which is valid for all instances of the class. Static attributes are available once for each class. They are declared using the statement CLASS-DATA and are retained throughout the entire runtime. All the objects within a class can access its static attributes. Changes to a static attribute in an object are visible to all other objects within that class.

Data Types of Attributes

The data types of all attributes including the instance attributes and in particular the bound data types belong to the static properties of a class. Therefore, in a LIKE addition, the class component selector or reference variables can be used to refer to visible attributes of a class, without first creating an object. In this way, the access to the properties of the public static attributes of global classes is possible in each program.


Reference to the data type of an instance attribute attr of a global class cl_global.

DATA dref TYPE REF TO cl_global.

DATA:  f1 LIKE cl_global=>attr,
       f2 LIKE dref->attr.

Boxed Components

Attributes declared as structures can be declared as static boxes using the addition BOXED, like substructures of nested structures. In static boxes, initial value sharing causes less memory to be used for little used structures of much used objects. A static box used as a boxed component is a deep component administered using an internal reference, like strings and internal tables.