-
Notifications
You must be signed in to change notification settings - Fork 479
Description
Relevant sections of the style guide
[> Please link here to all relevant sections of the Clean ABAP guide
](https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-insert-into-table-to-append-to)
Description
Remove
Use APPEND TO only if you use a STANDARD table in an array-like fashion, if you want to stress that the added entry shall be the last row.
Examples
When using a STANDARD table is changed to a SORTED or HASED table - which is quite common during code optimisation - you get a dump which is only detected at run time.
Since INSERT .. INTO TABLE with a STANDARD table puts the new record at the end, there's really no need for APPEND; except perhaps it's a bit more explicit.
To be really explicit you could use the rather wordier
DATA(pos) = lines( itab ) + 1.
INSERT was INTO itab INDEX pos.
In the past (oh shoot) 28 years of doing ABAP I've occasionally needed to insert a record at the last position - for example, with error log processing. But I've far more frequently encountered a dump when a SORTED or HASHED table has hit an APPEND.
Frankly, I wish ABAP syntax check would just warn about APPEND. :-)