What does it do? These alternatives specify the position in the internal table itab > at which lines are inserted. In the variant with the addition TABLE>, the position of the insert is specified using the primary table key. In any of the other variants, a line number from the primary table index is used. The latter is only possible for index tables>.
Latest notes: The insert position is determined exclusively using either the primary table key> or the primary table index> only. For the secondary table keys> in the internal table, the system checks for uniqueness and adds the new table line to the corresponding administration (hash administration, secondary table index). In the case of secondary keys, the administration is updated before the next access; for non-unique secondary keys, it is updated before the secondary key is used again. NON_V5_HINTS ABAP_HINT_END
ABAP Alternative 1 ... TABLE itab>
What does it do? The lines to be inserted line_spec> > must be compatible> with the line type of the internal table. Depending on the table category, each line is inserted as follows:
For standard tables>, each new line is appended as the last line to the internal table regardless of the primary table key.
For sorted tables>, each new line is inserted into the sort order of the internal table in accordance with its key values with respect to the primary key. The line numbers in the primary table index of the following lines are increased by one. If the internal table has a non-unique key, duplicate entries are inserted before the existing line.
In hashed tables>, each new line is inserted into the internal table by the hash administration in accordance with its key values with respect to the primary key. If the internal table has one or more unique table keys, no entries are inserted that would produce duplicate entries in one of the unique table keys. When single lines are inserted, sy-subrc> is set to 4 if a duplicate entry with respect to the primary key were to be produced, and a catchable exception of the class CX_SY_ITAB_DUPLICATE_KEY> is raised if a duplicate entry with respect to a secondary key were to be produced. If multiple lines are inserted, an uncatchable exception is raised.
Latest notes: If the primary table key is used, it should be noted that this key can be the standard key> that covers all character-like and byte-like components if the line type is structured. An empty standard key is possible only for standard tables. In these tables, INSERT> always works like APPEND> in this variant. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Filling of an internal table connection_tab> with data from the database table spfli>. Single lines are inserted using the primary table key and are filled with the content of the work area connection>. Since the internal table has a unique primary key, any duplicate entries are discarded. The better performing SELECT>> statement, in which the internal table is specified directly after INTO TABLE>>, could raise an exception due to the uniqueness of the primary table key. ABEXA 00342 ABAP_EXAMPLE_END