Ansicht
Dokumentation

ABENBUILT_IN_TYPES_GENERIC - BUILT IN TYPES GENERIC

ABENBUILT_IN_TYPES_GENERIC - BUILT IN TYPES GENERIC

CPI1466 during Backup   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

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
any Any data type
any table Internal table with any table type
c Text field with a generic length
clike Character-like (c, n, and string, as well as the date/time types d, t and character-like flat structures)
csequence Text-like (c, string)
data Any data type
decfloat Decimal floating point number (decfloat16, decfloat34)
hashed table Hashed table
index table Index table
n Numeric text with generic length
numeric Numeric ((b, s), i, int8, p, decfloat16, decfloat34, f)
object Any object type (root class of the inheritance hierarchy)
p Packed number with generic length and generic number of decimal places
simple Elementary data type including enumerated types and structured types with exclusively character-like flat components
sorted table Sorted table
standard table Standard table
table Standard table
x Byte field with generic length
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 self-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.

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.

Example

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.






General Data in Customer Master   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.

Length: 11608 Date: 20240425 Time: 121518     sap01-206 ( 148 ms )