Register Login

Creating a Variable and assigning values to variable in ABAP

Updated May 18, 2018

Hello Friends,

To Create a variable in abap:
1)Type SE38 in commandline and enter
2)Give some program name say YPROGRAM1
3)Click on the create button,opens a screen.
4)Give some title for the program : Program to create a variable in ABAP
5)Select the program type as executable.
6)Now it opens a screen as where to store this program,since we dint go for creating packages
we can type /tmp or you can select local object push button .
7)save it(ctrl+s) and enter.

Now this will open a screen where you need to type the code to create variable.
To create variables first we shud declare the variable in abap.
DATA V1 TYPE I.
DATA TEXT(30) TYPE C.

Data is the keyword we use to declare/create variables.so here the variables v1,text(30) are created with type I(integer) and C(charecter)
respectively.Now you can see one number 30 inside the brackets this specifies the length of the variable you created.

so TEXT(30) here means upto 30 spaces are alloted for the variable TEXT.
Instead of declaring the variables in 2 lines we can also declare them as
DATA : V1 TYPE I,TEXT(30) TYPE C.
so colon in abap combines 2 or more statements


×