Get Example source ABAP code based on a different SAP table
• LINE OF ABAP_TYPING • REF TO ABAP_TYPING • REF TO METHODS • REF TO CLASS-METHODS • REF TO EVENTS • REF TO CLASS-EVENTS • REF TO FIELD-SYMBOLS • LINE OF METHODS • LINE OF CLASS-METHODS • LINE OF EVENTS • LINE OF CLASS-EVENTS • LINE OF FIELD-SYMBOLS • LINE OF FORM • REF TO FORM
typing> Addition, complete_type> Short Reference > BEGIN_SECTION VERSION 5 OUT END_SECTION VERSION 5 OUT
ABAP_SYNTAX ... ${ TYPE ${$[LINE OF$] complete_type$}> $| ${REF TO type$} $}> $| ${ LIKE ${$[LINE OF$] dobj$}> $| ${REF TO dobj$} $} ...>
What does it do? To completely type a formal parameter or a field symbol:
Any non-generic type complete_type> can be specified after TYPE>. complete_type> can be a non-generic data type from the ABAP Dictionary or ABAP CDS, a non-generic public data type from a global class, a non-generic program-local type already defined using TYPES>>, or a non-generic built-in ABAP type>.
A data object dobj> can be specified after LIKE>. dobj > according to the rules TYPES ... LIKE >>. The bound type of the data object is transferred. If field symbols and formal parameters are specified for dobj>, they must be completely typed to create the corresponding complete typing. If complete_type> or the data type of dobj> is table-like, LINE OF> can be used to refer to the appropriate line type. REF TO> types the formal parameter or field symbol as a reference variable, whereby the same rules apply as to the definition of reference types in TYPES> >. Typing with TYPE REF TO data> or TYPE REF TO object> is also considered a complete typing. If an actual parameter or a memory area is assigned to completely typed formal parameters or field symbols, the technical properties of the specified data type must match the typing exactly (see Typing Check>), except when passing literals. Completely typed formal parameters or field symbols can be used in the same operand positions as data objects of the corresponding data type. Type properties specified by the typing are used during both static and dynamic access to a completely typed formal parameter or field symbol.
Latest notes:
The data types that can be referred to with TYPE> include specifically the CDS entities > (CDS views>, CDS table functions>, CDS hierarchies>, and CDS abstract entities>) and the CDS types> (CDS simple types>).
Complete data types, which can be referred to with TYPE>, or indirectly using LIKE>, also include enumerated types>.
LIKE> can be used to refer to data objects, including the public attributes of global classes.
In a LIKE> reference to an internal table with a header line>, the header line is used. To refer to the table type, []> must be appended to the name as per usual. A formal parameter (with the exception of table parameters>) or a field symbol can be typed only with reference to the header line or to the table type.
The predefined generic data type any >> cannot currently be specified after REF TO>. NON_V5_HINTS
Outside classes, LIKE> can also be used for an obsolete type reference>. ABAP_HINT_END
ABAP_EXAMPLE_VX5 In the following example, the field symbol < spfli>> is completely typed with the structured data type spfli> from the ABAP Dictionary, and can therefore be used like a structure of this data type. FIELD-SYMBOLS < spfli> TYPE spfli.> ...> < spfli>-carrid = ...> ABAP_EXAMPLE_END