Ansicht
Dokumentation

ABAPDATA_REFERENCES - DATA REFERENCES

ABAPDATA_REFERENCES - DATA REFERENCES

Vendor Master (General Section)   ABAP Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

DATA, REF TO

Short Reference



DATA ref ${ ${TYPE REF TO type$}
         $| ${LIKE REF TO dobj$} $}
         $[VALUE IS INITIAL$]
         $[READ-ONLY$].

Effect

The addition REF TO declares a reference variable ref. The static type of the reference variable is specified after REF TO. The static type limits the set of objects to which ref can point. The dynamic type of a reference variable is the data type or the class to which it currently points. The static type is always more general or the same as the dynamic type (see also the conversion rule for reference variables).

The syntax and meaning of the additions TYPE and LIKE are the same as the definition of reference types in the section TYPES - REF TO, but here they are used to create a bound reference type.

Only IS INITIAL can be specified as a start value after the addition VALUE.

Notes

  • Reference variables are opaque, which means their content cannot be accessed directly. A reference consists of the address of an object and other administrative information.
  • 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 if it points to deleted objects. A heap reference that points to a line in an internal table can become invalid if the line is deleted. A stack reference can become invalid if the referenced data object is removed from the stack.

Example

In this example, an object reference oref and two data references dref1 and dref2 are declared. Both data reference variables are typed fully and can be dereferenced using the dereferencing operator ->* in operand positions.








BAL_S_LOG - Application Log: Log header data   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 3214 Date: 20240623 Time: 201636     sap01-206 ( 78 ms )