In the past, APPEND TO
was my go-to for adding new entries to an Internal Table (itab).
Revisiting my coding style, I will use INSERT
from now on.
Using INSERT INTO TABLE
instead
In general, the INSERT
statement expresses the intention better. After all, the goal is to insert entries into the table and not appending them.
INSERT VALUE #( ... ) INTO TABLE itab.
Using INSERT ... INTO TABLE
works with all table types. It does not matter if a table is declared as STANDARD
, SORTED
, or HASHED
table.
When requirements change you can focus on optimizing table key types. The INSERT
statements will still work fine.
When using APPEND TO
is the right choice
Use APPEND TO
if you want to stress that this entry should be the last row. For example when an itab is used in an array-like fashion.
Reminder: APPEND TO
only works (safely) for itabs defined as STANDARD TABLE
.