ABAP Keyword Documentation → ABAP − Reference → Declarations → Declaration Statements → Data Types and Data Objects → Types and Objects - Overview → Data Objects → References
Object References
Object references can point to instances of
classes. The static type of their reference variables is either a class or an interface. Both types
can be used to create objects with the statement CREATE OBJECT
.
- Class reference variables allow access to all visible components of a class.
- Interface reference variables restrict the view of the interface components of a class.
If an attempt is made to access an instance attribute with an object reference variable that contains the null reference, a non-handleable exception is raised. On calling an instance method, a handleable exception is raised.
Object references are always heap references.
Other versions: 7.31 | 7.40 | 7.54
Note
For more information, see Object References.
Example
Inline declaration of an object reference variable out
with the static type
IF_DEMO_OUTPUT on the left side of an object of the class CL_DEMO_OUTPUT created using its factory method NEW. Calls the method DISPLAY using the object component selector.
DATA(out) = cl_demo_output=>new( ).
out->display( `Hello` ).