Attributes

Attributes are internal data fields of any ABAP data type within a class. The content of the attributes specifies the status of the object. You can also define reference variables, which you can then use 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 status of the object, you need to use private attributes. You can also limit the changeability of attributes using the READ-ONLY addition. When you declare attributes, note that the LIKE addition can be used within classes only for references to other attributes within the class. You must use the TYPE addition to reference data types from the ABAP dictionary.

Instance Attributes

The content of instance attributes forms the instance-specific statusof the object. Instance attributes are declared using the DATA statement. You cannot use the COMMON PART addition in a class, nor can you use the TABLES or NODES statement in the declaration part of the class.

Static Attributes

The content of static attributes forms the instance-independent statusof the object, which is valid for all instances of the class. Static attributes are available once for each class. They are declared using the CLASS-DATA statement 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.

The technical properties of instance attributes belong to the static properties of a class. Therefore, in a LIKE addition, you can use the class component selector or reference variables to refer to the visible attributes of a class without first creating an object.