Data Types 

The following graphic shows the different data types that are used in ABAP. Data types form a part of the ABAP Type Hierarchy.

Data types can be divided into elementary, reference, and complex types.

Elementary Types

Elementary types are the smallest indivisible unit of types. They can be grouped as those with fixed length and those with variable length.

Fixed-Length Elementary Types

There are eight predefined types in ABAP with fixed length:

Character (C), Numeric character (N), Date (D), and Time (T).

Byte field (X).

Integer (I), Floating-point number (F) and Packed number (P).

 

Variable-Length Elementary Types

There are two predefined types in ABAP with variable length:

Reference Types

Reference types describe data objects that contain references (pointers) to other objects (data objects and objects in ABAP Objects). There is a hierarchy of reference types that describes the hierarchy of objects to which the references can point. There are no predefined references - you must define them yourself in a program.

Complex Types

Complex types are made up of other types. They allow you to manage and process semantically-related data under a single name. You can access a complex data object either as a whole or by individual component. There are no predefined complex data types in ABAP. You must define them either in your ABAP programs or in the ABAP Dictionary. Structured types are divided further into structures and internal tables.

Structures

A structure is a sequence of any elementary types, reference types, or complex data types.

You use structures in ABAP programs to group work areas that logically belong together. Since the elements of a structure can have any data type, structures can have a large range of uses. For example, you can use a structure with elementary data types to display lines from a database table within a program. You can also use structures containing aggregated elements to include all of the attributes of a screen or control in a single data object.

The following terms are important when we talk about structures:

A nested structure is a structure that contains one or more other structures as components. Flat structures contain only elementary data types with a fixed length (no internal tables, reference types, or strings). The term deep structure can apply regardless of whether the structure is nested or not. Nested structures are flat so long as none of the above types is contained in any nesting level.

Any structure that contains at least one internal table, reference type, or string as a component (regardless of nesting) is a deep structure. Accordingly, internal tables, references, and strings are also known as deep data types. The technical difference between deep structures and all others is as follows. When you create a deep structure, the system creates a pointer in memory that points to the real field contents or other administrative information. When you create a flat data type, the actual field contents are stored with the type in memory. Since the field contents are not stored with the field descriptions in the case of deep structures, assignments, offset and length specifications and other operations are handled differently from flat structures.

Internal Tables

Internal tables consists of a series of lines that all have the same data type. Internal tables are characterized by:

You should use internal tables whenever you need to use structured data within a program. One imprint use is to store data from the database within a program.

Examples for Complex Data Types

The following list contains examples of complex data types in ascending order of complexity:

  1. Structures consisting of a series of elementary data types of fixed length (non-nested, flat structures)
  2. An internal table whose line type is an elementary type (vector).
  3. Internal tables whose line type is a non-nested structure ('real' table)
  4. Structures with structures as components (nested structures, flat or deep)
  5. structures containing internal tables as components (deep structures)
  6. Internal tables whose line type contains further internal tables.

The graphic shows how elementary fields can be combined to form complex types.

Further Information About Data Types

You can define data types at various levels in the R/3 System. For more information, refer to

Defining Data Types.

 

Some ABAP statements allow you to use the TYPE addition to refer to an existing data type. The data types must be visible in the program for this to work. For more information, refer to

Visibility of Data Types.

 

When working with data, it is important to know whether data types are compatible or not. For more information, refer to

Compatibility of Data Types.