Thursday, 21 September 2017

ABAP: Define variable using LIKE keyword

If you already defined a variable, you can define other variable by referring the existing one.

Ex:
DATA: first_name TYPE STRING,
      last_name LIKE first_name.

As you see above snippet, last_name is declared by using LIKE operator.

Z_HELLO_WORLD
*&---------------------------------------------------------------------*
*& Report Z_HELLO_WORLD
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z_HELLO_WORLD.

* Defining Variables
DATA: first_name TYPE STRING,
      last_name LIKE first_name,
      age TYPE I.

first_name = 'Hari Krishna'.
last_name = 'Gurram'.
age = 28.

Write first_name.
Write / last_name.
Write / age.



Previous                                                 Next                                                 Home

No comments:

Post a Comment