ABAP Keyword Documentation → ABAP - Reference → Declarative statemnts → Data Types and Data Objects → Types and Objects - Overview
Data Types
Data types are a subtree of the ABAP type hierarchy. Data types are only type descriptions. Data types do not have any attached memory for storing working data, but they may require space for administration information. A data type characterizes the technical properties of all data objects that have this type. In ABAP, data objects occur as attributes of data objects, but they can also be defined as stand-alone data types.
The definition of stand-alone data types is based on a set of
predefined data types.
Stand-alone data types can either be defined internally in the program using the statement
TYPES
in the global declaration section of a program, in the declaration section of a class, locally in procedures, or for all programs in the
ABAP Dictionary. Data types in the ABAP Dictionary are either created directly as
repository objects or in a type group.
Predefined and self-defined data types can be used to generate data objects and for typing. For the latter in particular, predefined generic data types are available. A generic data type is a data type that does not determine all the properties of a data object. Generic data types can only be used for typing formal parameters and field symbols.
Data types can be divided into elementary, reference, and complex types.
- Elementary types
are 'atomic' in the sense that they are not composed of other types. They are further classified into elementary types of fixed length and of variable length.
- There are ten predefined elementary data types of fixed length in ABAP. There are four
character-type types: text fields
(
c
), numeric text fields (n
), date fields (d
), and time fields (t
). There are five numeric types: Integer (i
), decimal floating point numbers (decfloat16
,decfloat34
), binary floating point numbers (f
) and packed numbers (p
). Byte-like type: Byte fields (x
). The data typesc
,n
,x
, andp
are generic in terms of length. p is also generic in terms of the number of decimal places. The numerical data typesb
ands
cannot be specified directly in programs for short integers.
- There are two predefined elementary data types of variable length in ABAP. There is one
character-type type: Text string (
string
). Byte-like type: Byte string (xstring
).
- Reference types describe data objects that contain references to other objects (data objects and instances of classes), which are known as
reference variables.
There are no predefined reference types in ABAP. A reference type must either be defined in the ABAP
program or in the ABAP Dictionary. Reference types form a hierarchy, which represents the hierarchy of the objects to which the references can point.
- Complex data types
are composed of other types. They enable the administration and processing of semantically related datasets
under one name. A data object of a complex type can be accessed overall or by component. With the exception
of the structure
sy
, there are no predefined complex data types in ABAP. A complex type must either be defined in the ABAP program or in the ABAP Dictionary. There are two types of complex data type:
- A structured type
is a sequence of any elementary reference or complex data types. Structures are used for grouping together work areas that logically belong together.
- Table types consist of a sequence of any number of lines of the same data type. Table types are characterized by a row type, which can be any elementary data type, a reference data type, or a complex data type. They are also characterized by the table type, which defines how tables can be accessed, and by a table key, which is used to identify the table rows.