Data Types
Data types are mere type descriptions with no memory involved. A data type characterizes the technical
properties of all data objects that have this type. Data types occur as attributes of data objects but can also be defined independently.
The definition of independent data types builds on a set of predefined data types. It can be included
in the declaration part of a program using the statements TYPES or defined
generally in the ABAP Dictionary. Independent data types can be used to declare data objects and for type checks in generic operations.
Data types are a subtree of the ABAP type hierarchy:
Hierarchy of ABAP data types
Data types ---- elementary ----fixed length---- C
|
| |-- N
| |
|-- D
|
| |-- T
| |
|
|
| |-- X
| |
|
|
| |-- P
| |
|-- I
|
| |-- F
| |
| |-- var.length
---- STRING
|
|-- XSTRING
|-- reference types
|
|-- complex ---- structured
Data types are subdivided into elementary types, reference types, and complex types.
- Elementary types are atomic, that is they are not a combination of other types. They are subdivided into fixed-length and variable length types.
- ABAP includes eight built-in elementary data types with fixed length:
-
four character-type types: character fields (C), numeric character fields (N), date fields (D), time fields (T)
-
X for byte fields with hexadecimal display
-
three numeric types: integer (I), floating-point numbers (F), and packed numbers (P)
- ABAP includes two variable-length elementary types:
-
STRING for character strings
-
XSTRING for byte sequences
- Reference types describe data objects that include references
to other objects (data objects and objects from ABAP Objects). Reference types form a hierarchy that represents the hierarchy of the objects to which the references point.
- Complex types are combined of other types. They make it possible to manage and process semantically
related data sets under one name. Complex-type data objects can be accessed as a whole or by component.
ABAP does not have any built-in complex data types. A complex data type must either be defined in an
ABAP program or in the ABAP dictionary. Complex data types are subdivided into structures and internal tables.
- A structure (record) is a sequence of any elementary, reference, or complex data types. Structures
are used in ABAP programs to combine work areas that are logically related. Since the individual structure elements can have any data type, structures can be used in many different ways.
- Internal tables consist of a sequence of lines with the same data type. Tables are characterized by:
-
the line type, which can be any elementary data type, a reference type or complex data type
-
a key to identify the table lines. It can be built up from the elementary fields of the lines. Distinction is made between unique and non-unique keys.
-
the access type that defines how ABAP accesses the table. With respect to the access type, distinction
is made between sorted and unsorted index tables and hash tables.
Internal tables are always used when multiple data of a fixed structure are used within the program.
For further information refer to Data Types in the SAP Library.