Get Example source ABAP code based on a different SAP table
• any ABAP_GENERIC_TYPE • any table ABAP_GENERIC_TYPE • c ABAP_GENERIC_TYPE • clike ABAP_GENERIC_TYPE • csequence ABAP_GENERIC_TYPE • data ABAP_GENERIC_TYPE • decfloat ABAP_GENERIC_TYPE • hashed table ABAP_GENERIC_TYPE • index table ABAP_GENERIC_TYPE • n ABAP_GENERIC_TYPE • numeric ABAP_GENERIC_TYPE • object ABAP_GENERIC_TYPE • p ABAP_GENERIC_TYPE • simple ABAP_GENERIC_TYPE • sorted table ABAP_GENERIC_TYPE • standard table ABAP_GENERIC_TYPE • table ABAP_GENERIC_TYPE • x ABAP_GENERIC_TYPE • xsequence ABAP_GENERIC_TYPE
Generic ABAP Types The following table shows the built-in generic ABAP types. A generic data type is an incomplete type specification that covers multiple complete type specifications. Apart from object>, all generic types can be used after TYPE>> for the typing> of field symbols> and formal parameters>. When a data object is assigned to generically typed field symbols using the statement ASSIGN>>, or when a data object is used as an actual parameter> for generically typed formal parameters in procedure calls>, the system checks whether its concrete data type is compatible> with the object, that is, whether the data type is a subset of the generic type. The only generic types that can be used after TYPE REF TO>> are data>, for the generic typing of data references and object>, for the generic typing of object references. Type>Description> ABAP_KEY any>Any data type ABAP_KEY any table>Internal table with any table type ABAP_KEY c>Text field with a generic length ABAP_KEY clike>Character-like (c>, n>, and string>, as well as the date/time types d>, t> and character-like flat structures>) ABAP_KEY csequence>Text-like (c>, string>) ABAP_KEY data>Any data type ABAP_KEY decfloat>Decimal floating point number type> (decfloat16>, decfloat34>) ABAP_KEY hashed table>Hashed table > ABAP_KEY index table>Index table> ABAP_KEY n>Numeric text> with generic length ABAP_KEY numeric>Numeric ((b>, s>), i>, int8>, p>, decfloat16>, decfloat34>, f>) ABAP_KEY object>Any object type (root class of the inheritance hierarchy) ABAP_KEY p>Packed number with generic length and generic number of decimal places> ABAP_KEY simple>Elementary data type including enumerated types> and structured types with exclusively character-like flat components ABAP_KEY sorted table>Sorted table > ABAP_KEY standard table>Standard table> ABAP_KEY table>Standard table ABAP_KEY x>Byte field with generic length ABAP_KEY xsequence>Byte-like (x>, xstring>) A typing with the generic type data> acts like a typing with the generic type any>, with the following exception: No numeric functions>, description functions>, or arithmetic functions> can be passed to a formal parameter typed with the type data>. All other expressions, built-in functions, and functional methods are possible. In addition to the built-in generic types shown in the table above, ABAP currently includes exactly one kind of user-defined generic type. A table type> defined with TYPES - TABLE OF>> or defined in the ABAP Dictionary is generic if the primary table key> is not specified or specified incompletely or if the secondary table key> of the table type is generic.
Latest notes:
When generic types are used for the typing> of field symbols> and formal parameters>, it must be ensured that the correct results are obtained regardless of the actual type used. For example, if csequence> is used, it must be ensured that the possible concrete types c> and string> behave differently with respect to trailing blanks, or that the concrete numeric types that are possible for numeric> in calculations lead to different calculation types>. Especially during generalization of existing types, it may be necessary to adapt the implementation accordingly.
Like all generic types listed here, except data> and object >, the generic type any> can only be specified directly after TYPE>. any> cannot be specified after TYPE REF TO>>. The only generic types allowed here are data> for fully generic data reference variables and object> for fully generic object reference variables. Specifying REF TO any> would define a fully generic reference variable that includes data references and object references, which is currently not possible.
The generic type object> can only be specified after REF TO> and not directly after TYPE>.
The object type object> plays a special role, since it is not actually a real generic type but the empty abstract root class of all object classes of ABAP Objects. An object reference variable typed using REF TO object> can point to any object because of the general property of reference variables where reference variables with the static type of a superclass can point to objects in all related subclasses. When compared with a data reference variable typed using the real generic data type data>, which can point to any data object, it is also possible to classify object> as a generic type.
In the case of the generic type p>, note that when passing functional methods or arithmetic expressions to this type of typed input parameters, the length is always set to 16. With generic types numeric>, simple> and data> or any>, this is only the case for arithmetic expressions.
The elementary data type utclong> is only included in the generic types simple>, data>, and any>.
Regardless of their base type>, enumerative types> are only enclosed by the generic types any>, data> and simple>. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Use of the built-in generic type numeric> to type the input parameters of a method. Parameters with any numeric data types can be passed to the method (but no other data types). METHODS numeric_operation IMPORTING num1 TYPE numeric num2 TYPE numeric RETURNING VALUE(result) TYPE decfloat34.> ABAP_EXAMPLE_END