Data objects are always defined with the DATA key word.
You can use an ABAP standard type, a local type, or a global type to type a data object.
You can refer to an already defined data object when defining additional variables (LIKE addition).
If the type information is missing in a variable definition, the standard type C is assumed.
In contrast, if the length is missing, then the appropriate default length for the (incomplete) standard type is used.
The "DATA myvar." statement without type or length information thus defines a character variable with a length of 1 as the default length of type C is one.
Literals and constants belong to the fixed data objects.
You can use literals to specify fixed values in your programs.
There are numericliterals (specified without quotation marks) and text literals (specified with quotation marks).
You define constants using the CONSTANTS statement.
You can use the MOVE statement to transfer the contents of a data object to another data object.
The following two syntax variants have the same effect:
MOVE var1 TO var2.
var2 = var1.
If both data objects var1 and var2 are of different types, then there is a typeconflict.
In this case, a type conversion is carried out automatically, if a conversion rule exists.
For detailed information on copying and the conversion rules, refer to the keyword documentation for the MOVE statement.
The CLEAR statement resets the contents of a data object to the type-specific initial value.
Video Lesson 4.1: Working With Elementary Data Objects
Lesson Overview
In this lesson you will become familiar with the difference between data types and data objects and you will learn how to define and use these in a program. You will also learn some basic ABAP statements.
You will be working with structures and internal tables, as well as program flow control and logical expressions.
Data Types and Data Objects
A formal variable description is called data type. In contrast, a variable concretely defined by means of a data type is called data object.
Let's have a look at the ABAP standard types predefined by SAP (implemented types) first.
These are divided into two groups:
Complete and
incomplete types.
The following implemented ABAP standard types are complete.
This means that they already contain the type-related, fixed length information:
Complete ABAP standard types
D
Type for date(D), format: YYYYMMDD, length 8 (fixed)
T
Type for time (Time), Format: HHMMSS, length 6 (fixed)
I
Type for integer (I), length 4 (fixed)
F
Type for floating point number (F), length 8 (fixed)
STRING
Type for dynamic length character string
XSTRING
Type for dynamic length byte sequence (HeXadecimal string)
The following standard types do not contain a fixed length (incomplete). With these, the length of the variable has to be specified for data object definitions.
C
Type for character string (Character) for which the fixed length is to be specified
N
Type for numerical character string (Numerical character) for which the fixed length is to be specified
X
Type for byte sequence (HeXadecimal string) for which the fixed length is to be specified
P
Type for packed number (Packed number) for which the fixed length is to be specified. (In the definition of a packed number, the number of decimal points may also be specified.)
For more information on predefined ABAP types, refer to the keyword documentation on the TYPES or DATA statement.