Ansicht
Dokumentation

ABAPGET_REFERENCE - GET REFERENCE

ABAPGET_REFERENCE - GET REFERENCE

ROGBILLS - Synchronize billing plans   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.
SAP E-Book

GET REFERENCE

Short Reference



GET REFERENCE OF dobj INTO dref.

Effect

This statement sets the reference in the reference variable dref so that it points to the data object dobj. The following can be specified for dref:

  • An inline declaration DATA(var) or FINAL(var). This declares a data reference variable whose static type is the data type of dobj. The data type of dobj must be known statically as a complete type or as the generic type data. Field symbols and formal parameters with other generic types, in particular any, are not possible.

The data object is specified directly and in accordance with the rules described in the section Read Positions. If offsets/lengths (+off(len)) are specified, the data type dobj here cannot be string or xstring.

Notes

  • In addition to the reference operator REF and the addition REFERENCE INTO, the statement GET REFERENCE is the only option for internal table statements to create stack references. Stack references can become invalid if the referenced data object is deleted.
  • When applied to data objects in the heap GET REFERENCE creates memory-retaining heap references.
  • The content of two reference variables filled with GET REFERENCE is only the same if the remaining administration information is the same, apart from the referenced data objects. For example, a reference that is obtained directly by specifying the data object is not the same as a reference that is obtained by specifying a field symbol if it has a different data type due to a casting.
  • For an internal table with a header line, a data reference variable can only point to this or the table body. In the statement GET REFERENCE, the name of an internal table with a header line addresses the header line. To address the table body, [] must be appended to the name as usual. A dereferenced data reference to which a table body is assigned behaves in the same way in operand positions as a table without a header line.
  • If references are set using GET REFERENCE, permission to access the corresponding data object is only checked at the position of the statement. The references can then be passed on to any destination and can be used to access the associated data objects from any position using the references. To prevent access to private and read-only attributes using references outside classes, do not publish references to these attributes externally. A constant or read-only input parameter, however, can never be made modifiable by passing its reference.

Example

Creation of data references to the individual characters of a data object text and storing them in an internal table. Direct dereferencing at an operand position is possible because the data reference is completely typed. After the output, an alternative implementation with an iteration expression and the reference operator REF is shown that has the same result.

Exceptions

Non-Catchable Exceptions

  • Cause: The data object specified after INTO is not a reference variable.
    Runtime Error: GET_REF_REFERENCE_EXPECTED
  • Cause: GET REFERENCE is not allowed for a substring.
    Runtime Error: ILLEGAL_SUBSTRING_PARAMETER








General Data in Customer Master   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.

Length: 6886 Date: 20240616 Time: 114301     sap01-206 ( 111 ms )