References are pointers to instances. Pointers to data objects are known as data references. Pointers to instances of classes are known as object references. In ABAP, references occur as the content of reference variables. Reference variables are data objects whose data type is a reference type.
The reference type is the static type of a reference variable. It defines the types of the instances its references can point to. The dynamic type of a reference variable is the type from which an object (to which a reference variable points) was instanced. The static type is always more general than or the same as the dynamic type. A dynamic type can be a data type or a class. A reference type or static type can be a type for a data reference variable or object reference variable. The latter is subdivided into class reference variables and interface reference variables.
Special conversion rules apply for assignments between reference variables, depending on the static type. These rules ensure that the dynamic type is never more general than the static type (up cast, down cast).
- From a technical point of view, a reference in ABAP does not refer directly to an object; instead it refers to what is known as a header that contains the address of the actual object as well as additional information. See also Memory Management of Deep Data Objects.
- As well as the regular references in reference variables, weak references represented by objects from a system class can also be used.