ABAP Data Types and Constants

by | Mar 8, 2018 | ABAP Beginner

Home » SAP » ABAP » ABAP Beginner » ABAP Data Types and Constants

Preface – This post is part of the ABAP Beginner series.

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 TYPEDescriptionDefault LengthDefault Value
CCharacter1‘ ’
NNumeric10
IInteger40
FFloat80
PPacked80
DDate800000000
TTime6000000
XHexa Decimal1X’0’
STRINGVariable Length String
XSTRINGVariable 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.

 

 

Author

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Author