Ansicht
Dokumentation

ABAPINSERT_ITAB_LINESPEC - INSERT ITAB LINESPEC

ABAPINSERT_ITAB_LINESPEC - INSERT ITAB LINESPEC

Fill RESBD Structure from EBP Component Structure   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.
SAP E-Book

INSERT, line_spec

Short Reference



... wa
  $| ${INITIAL LINE$}
  $| ${LINES OF jtab $[FROM idx1$] $[TO idx2$] $[STEP n$] $[USING KEY keyname$]$} ...

Alternatives:

1. ... wa

2. ... INITIAL LINE

3. ... LINES OF jtab $[FROM idx1$] $[TO idx2$] $[STEP n$] $[USING KEY keyname$]

Effect

Either a work area wa, an initial line INITIAL LINE, or multiple lines of an internal table jtab can be appended.

Alternative 1

... wa


Effect

A new line is created to which the content of the work area wa is assigned. wa is a general expression position. The following applies here:

  • When inserting using the table key, wa must be compatible with the line type of the internal table. Exceptions to this rule are any constructor expressions whose result type can be incompatible with the line type and whose result is converted to the line type if possible.
  • When inserting using the table index, wa can be incompatible with the line type of the internal table and is, if necessary, converted to the relevant line type, in accordance with the conversion rules.

If a conversion error occurs in the conversion, the exception cannot be handled using CX_SY_CONVERSION_ERROR and the associated runtime error occurs instead. If an arithmetic expression is specified for wa, the line type of the internal table is used to determine calculation type.

When inserting individual lines into an internal table with non-unique table keys, the order of the duplicate lines in relation to these keys is determined by the insertion order of the individual lines. In the case of secondary table keys, this occurs during the lazy update.

If there is a conflict with the existing unique primary table key, no line is inserted. If a key access occurs, sy-subrc is set to 4. In an index access, however, an uncatchable exception is raised. In the case of a conflict with a unique secondary table key, a catchable exception of the class CX_SY_ITAB_DUPLICATE_KEY is raised.

Notes

  • When inserting using the table key, incompatible work areas can be converted to the line type using the conversion operator CONV.
  • Outside of classes, an obsolete short form is possible where wa INTO can be omitted if the internal table has an identically named header line itab. The statement then uses the header line as the work area implicitly.

Example

Insertion of a structure constructed using the value operator VALUE into an internal table.

Alternative 2

... INITIAL LINE


Effect

A new line is created in which every component contains its type-dependent initial value.

Example

Insertion of an initial line that is simultaneously linked to a field symbol using the addition ASSIGNING. This means that the initial line can be processed directly.

Alternative 3

... LINES OF jtab $[FROM idx1$] $[TO idx2$] $[STEP n$] $[USING KEY keyname$]


Effect

The lines of an internal table jtab are appended as a block. jtab is a functional operand position. The line types of itab and jtab must be compatible when inserting using the table key and convertible when inserting using the index.

The lines to be inserted are taken sequentially from the table jtab. The order in which the lines are taken is the same as for the statement LOOP and can also be affected by specifying a table key keyname after USING KEY. The additions FROM idx1 and TO idx2 have the same syntax and effect as for LOOP with respect to jtab. STEP n has the same syntax and effect as for LOOP with the exception that the value of n must be positive.

When inserting lines as a block into an internal table with non-unique primary table keys, the order of the duplicate lines in relation to this primary key is preserved. This does not apply to secondary keys.

  • If there is already a duplicate entry in a sorted target table, the duplicates of the source block are inserted in their original order in front of the first duplicate in the target table.
  • When inserting in standard tables, however, INSERT always works like the statement APPEND and the lines are appended in their original order after the last line as in the addition LINES OF.

If there is a conflict with an existing unique table key, a catchable exception is raised when inserting multiple lines from an internal table. If a conversion error occurs when lines are inserted, the exception cannot be handled using CX_SY_CONVERSION_ERROR and the associated runtime error occurs instead.

Note

When an internal table is constructed, the constructor operators NEW and VALUE can also insert multiple lines from a table into the target table using LINES OF.

Insertion of the lines of an internal table itab into the same table. The lines are inserted in front of the existing first line and in ascending order due to the specification of the sorted secondary key skey being specified.

Insertion of the lines of an internal table itab into the same table. The lines are inserted in front of the existing first line and in ascending order due to the specification of the sorted secondary key skey being specified.

Insertion of the lines of an internal table itab into the same table, defined by FROM, TO, and STEP. The lines are inserted in front of the existing first line and in ascending order due to the specification of the sorted secondary key skey being specified.






RFUMSV00 - Advance Return for Tax on Sales/Purchases   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 9561 Date: 20240614 Time: 054855     sap01-206 ( 152 ms )