SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP Programming Guidelines → Robust ABAP → Internal Tables →Output Behavior
Background
Internal tables can be read by accessing individual rows (using READ TABLE or table expressions) or sequentially (using LOOP AT). In both cases, the following output behavior can be defined by using the statements with the following additions:
In the case of table expressions, the output behavior is controlled by the category of the result.
As well as for exports, the ASSIGNING and REFERENCE INTO additions can also be used for the APPEND, COLLECT, INSERT, and MODIFY statements, where they create references to the row being edited.
Rule
Choose appropriate output behavior
When reading rows of internal tables, select an appropriate output behavior. The rule of thumb is:
Details
The criteria for selecting the output behavior are the processing speed, on the one hand, and what is to be done with the read row, on the other hand:
Besides the processing speed, it is also important that the source code can be understood. If the recommendations mentioned are kept, reading a table with the addition ASSIGNING (but also REFERENCE INTO) indicates to the reader that the table content is potentially changed. Reading a table with the INTO addition, on the other hand, indicates that the table will not be modified.
For table expressions, the information here applies to the selection of the appropriate result.
Bad example
The following source code shows the assignment of rows of an internal table to a work area with the aim of modifying the read rows. For this modification, however, an additional statement, MODIFY, is required, and two unnecessary copy processes take place for each loop pass.
Good example
The following source code corrects the above example; here, a field symbol is used for direct access to modify the read rows. No unnecessary copy costs are incurred.