Preface – This post is part of the ABAP Beginner series.
Table of Contents
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|
|STRING||Variable Length String||–||–|
|XSTRING||Variable Length Raw Byte Array||–||–|
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.
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.
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>.
TYPES: BEGIN OF EMPLOYEE_DETAILS,
ID (10) TYPE n,
NAME (20) TYPE c,
END OF EMPLOYEE_DETAILS.