Data Type describes the technical characteristics of a Variable of that type. Data type is just the blue print of a variable.
Predefined ABAP Types
Data Type | Description | Default Length | Default Value |
---|---|---|---|
C | Character | 1 | ‘ ‘ |
N | Numeric | 1 | 0 |
D | Date | 8 | 00000000 |
T | Time | 6 | 000000 |
X | Hexa Decimal | 1 | X’0′ |
I | Integer | 4 | 0 |
P | Packed | 8 | 0 |
F | Float | 8 | 0 |
User defined data types
Use TYPES keyword to define the data types.
TYPES: name(10) TYPE c, length TYPE p DECIMALS 2, counter TYPE i, id(5) TYPE n.
Structured data types
Structured data type is grouping of several simple data types under one name.
Use the keywords BEGIN OF and END OF to create a structured data type.
TYPES: BEGIN OF student, id(5) TYPE n, name(10) TYPE c, dob TYPE d, place(10) TYPE c, END OF student.
Constants
Constants are used to store a value under a name. We must specify the value when we declare a constant and the value cannot be changed later in the program.
Use CONSTANTS keyword to declare a constant.
CONSTANTS: pi TYPE p DECIMALS 2 VALUE '3.14', yes TYPE c VALUE 'X'.