SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Internal Tables → Processing Statements for Internal Tables → INSERT itab →
INSERT - line_spec
Syntax
... wa
| {INITIAL LINE}
| {LINES OF jtab [FROM idx1] [TO idx2] [USING KEY keyname]} ... .
Alternatives:
1. ... wa
2. ... INITIAL LINE
3. ... LINES OF jtab [FROM idx1] [TO idx2] [USING KEY keyname]
Effect
Either a work area wa, an initial row INITIAL LINE, or multiple rows of an internal table jtab can be appended.
... wa
Effect
A new row is created to which the content of the work area wa is assigned. wa is a general expression position. To insert using the table key, wa must be compatible with the row type of the internal table. To insert using the table index, wa must be incompatible with the row type of the internal table. wa is converted to the relevant row type, in accordance with the conversion rules. If an arithmetic expression is specified for wa, the row type of the internal table is respected when determining the calculation type.
When inserting individual rows into an internal table with non-unique
table keys, the order of the duplicate rows in relation
to these keys is determined in accordance with the insertion order of the individual rows. In the case of secondary table keys, this order is determined place during the
lazy update.
Notes
... INITIAL LINE
Effect
A new row is created in which every component contains the type-specific initial value.
Example
Inserting an initial row which is also linked to a field symbol by the ASSIGNING addition. This means that initial rows can be processed directly.
DATA itab TYPE TABLE OF spfli.
FIELD-SYMBOLS <line> LIKE LINE OF itab.
INSERT INITIAL LINE INTO itab INDEX 1 ASSIGNING <line>.
<line>-carrid = '...'.
...
... LINES OF jtab [FROM idx1] [TO idx2] [USING KEY keyname]
Effect
The rows of an internal table jtab are added as a block. jtab is a functional operand position. The row types of itab and jtab must be compatible when inserting using the table key and must be convertible when inserting using the index.
The inserted rows are sequentially taken from the table jtab. The order in which the rows are taken is the same as for the statement LOOP and can also be influenced by specifying a table key keyname after USING KEY. The additions FROM idx1 and TO idx2 have, in relation to jtab, the same syntax and effect as for LOOP.
When inserting rows as a block into an internal table with non-unique
table keys, the order of the duplicate rows in relation
to these keys is retained. If there is already a duplicate entry in the target table, the duplicates of the source block are inserted in their original order in front of the first duplicate in the target table.
Note
If there is a conflict with an existing unique table key, a handleable exception is raised when inserting multiple rows from an internal table.