Benefits of LIKE LINE OF
2012-11-26
Let’s start by assuming that you have some dignity and so you don’t use internal tables with HEADER LINE anymore ;)
Given this, let’s suppose you declare an internal table:
DATA: T_KNA1 TYPE STANDARD TABLE OF KNA1.
If you want to read data of T_KNA1 by doing LOOP or READ TABLE, you need to save the read register in a structure or in a FIELD-SYMBOL. Let’s choose a structure.
Traditionally we would declare it like this:
DATA: S_KNA1 TYPE KNA1.
Instead, my suggestion is that you declare it this way:
DATA: S_KNA1 LIKE LINE OF T_KNA1.
The two main advantages of doing so are:
-
If the register type changes you just need to update it somewhere;
-
It becomes clearer that S_KNA1 is connected to T_KNA1.
Thank you thienzieyung for the photo.
Greetings from Abapinho.