Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Types and Objects - Overview →  Data Objects 

References

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.

Reference types are always created using the addition REF TO. The content of reference variables can be checked using the predicate expression IS BOUND.

The reference type is the static type of a reference variable. It defines the types of the instances to which its references can point. The dynamic type of a reference variable is the type from which an object (to which a reference variable points) was instantiated. 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 to assignments between reference variables, depending on the static type. These rules ensure that the dynamic type is never more general than the static type (in up casts, and down casts).

Depending on where the object referenced by a reference variable is located, memory-preserving heap references or non-memory-preserving stack references are used. Special weak references, which are represented by objects of a system class, do not keep an object alive.

A reference in a reference variable is valid if it points to an object. In this case the predicate expression IS BOUND is true. A non-initial reference can be invalid it it points to deleted objects. A heap reference that points to a row in an internal table can become invalid if the row is deleted. A stack reference can become invalid if the referenced data object is removed from the stack.

Other versions: 7.31 | 7.40 | 7.54


Notes

  • From a technical point of view, a reference in ABAP does not reference an object directly and instead references what is known as a header, which contains the address of the actual object as well as additional information. See also Memory Management of Deep Data Objects.

Continue

Data References

Object References

Heap references and stack references

Weak References