Ansicht
Dokumentation

ABENCLASS_ATTRIBUTES - CLASS ATTRIBUTES

ABENCLASS_ATTRIBUTES - CLASS ATTRIBUTES

Vendor Master (General Section)   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.
SAP E-Book

- Attributes of Classes

Attributes are internal data objects of a class of any ABAP data type. The content of the attributes determines 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 visible from outside the class without restrictions and as such are part of the interface between objects and their users. To encapsulate the state of the object, protected, package-visible, or private attributes must be used. In addition to the visibility, the modifiability of non-private attributes can also be restricted using the addition READ-ONLY in the declaration.

Instance Attributes

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

Note

The attempt to access an instance attribute via an initial object reference variable, in contrast to the call of an instance method, results in an exception that is not catchable.

Static Attributes

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

Data Types of Attributes

The data types of all attributes, including instance attributes and, in particular, 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 the visible attributes of a class, without first creating an object. In this way, the public static properties of global classes can be accessed in every program.

Example

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

Like substructures of nested structures, attributes declared as structures can be declared as static boxes using the addition BOXED. In static boxes, initial value sharing takes effect, which leads to fewer memory requirements for little used structures of frequently used objects. A static box used as a boxed component is a deep component that is managed using an internal reference, such as strings and internal tables.






rdisp/max_wprun_time - Maximum work process run time   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.

Length: 3795 Date: 20240419 Time: 183753     sap01-206 ( 71 ms )