Preface – This post is part of the ABAP Beginner series.
Table of Contents
Data Types
ABAP Data types are the one which tell us about the technical characteristics of a Variable.
By technical characteristics we mean the type of variable (Integer or Character) and its length.
In SAP we can either use Global Variables created with the help of SE11 or can create local variables using these Data Types.
Following are the Data Types (or Elementary Data Types) provided by SAP:
DATA TYPE | Description | Default Length | Default Value |
C | Character | 1 | ‘ ’ |
N | Numeric | 1 | 0 |
I | Integer | 4 | 0 |
F | Float | 8 | 0 |
P | Packed | 8 | 0 |
D | Date | 8 | 00000000 |
T | Time | 6 | 000000 |
X | Hexa Decimal | 1 | X’0’ |
STRING | Variable Length String | – | – |
XSTRING | Variable Length Raw Byte Array | – | – |
Constants
Just like other languages, ABAP also provides benefits of storing some value under constants whose value cannot be altered later in the program. For example you want to store value of PI (π) i.e. 3.14 and which always have this value only, then constants will be a great help to you. The keyword is CONSTANTS.
Example:
CONSTANTS: pi TYPE p DECIMALS 3 VALUE ‘3.142’, No TYPE c VALUE ‘’.
|
User Defined Data Types:
To use the above data types user has to write the given codes with keyword TYPES. To define the lengths of variable type the length next to the variable name in bracket.
Example:
TYPES:ID (10) TYPE n, NAME (20) TYPE c.
|
Structured Data Types:
Just like other programing language where you create structures having several data variable, ABAP also provides same feature. Just like the example mentioned above we create Structured Data Types using Keyword BEGIN OF<Structure Name> and END OF<Structure Name>.
Example:
TYPES: BEGIN OF EMPLOYEE_DETAILS, ID (10) TYPE n, NAME (20) TYPE c, END OF EMPLOYEE_DETAILS.
|
0 Comments