Get Example source ABAP code based on a different SAP table
TYPES - REF TO
Short Reference • REF TO TYPES
ABAP_BASIC_FORM_3 TYPES dtype { {TYPE REF TO type} | {LIKE REF TO dobj} }.
What does it do? The addition REF TO specifies a data type for a reference variable. The entry behind REF TO specifies the static type of the reference variable. The static type restricts the object quantity to which a reference variable can refer. The dynamic type of a reference variable is the data type and the object class to which it refers. The static type is always more general or the same as the dynamic type (see also assignment rules for reference variables).
Apart from data and object,generic data types can be specified after TYPE REF TO.
Types for Data Reference Variables If, for type, you have specified the predefined generic data type data, the system creates a data type for a data reference variable from the static type data . Such reference variables can refer to any data objects.
If type is specified as any non-generic data type (meaning a non-generic data type from ABAP Dictionary or from the public visibility section of a global class), as a non-generic local program type already defined using TYPES, or as a non-generic predefined ABAP type, a data type is created for a data reference variable with an appropriate static type. Such reference variables can refer to all data objects of the same type.
The same applies to dobj as to TYPES ... LIKE. A data type is created for a data reference variable and the static type of this variable is inherited from the data type of the specified data object. Such reference variables can refer to all data objects of the same type.
A data reference variable can be deferenced in different ways, depending on its static type: A data reference variable typed generically with TYPE REF TO data can be dereferenced only in the ASSIGN statement with the dereferencing operator ->*. A data reference variable typed completely with TYPE REF TO complete_type or LIKE REF TO dobj can be dereferenced in all matching operand positions with the dereferencing operator ->*. If the static data type is structured, the object component selector enables access to the components of the structure with dref->comp .