SAP APPEND LINESPEC ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• INITIAL LINE APPEND
• USING KEY APPEND
• LINES OF APPEND
• FROM idx APPEND
• TO idx APPEND
• STEP APPEND

APPEND, line_spec
Short Reference

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

ABAP_ALTERNATIVES:
1 ... wa
2 ... INITIAL LINE
3 ... LINES OF jtab $[FROM idx1$] $[TO idx2$] $[STEP n$] $[USING KEY keyname$]

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

ABAP Alternative 1 ... wa

What does it do?
A new line is appended to which the content of the work area wa is assigned. wa is a general expression position. wa may be incompatible with the line type of the internal table and, if necessary, is converted to the line type in accordance with the conversion rules. If a conversion error occurs here, 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 the calculation type.



Latest notes:

If a conflict occurs with an existing unique primary table type, this raises an uncatchable exception when appending a single line. 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.
Specifying a calculation expression for wa is usually only useful for elementary line types.
NON_V5_HINTS
Outside of classes, there is also an obsolete short form where wa TO 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.
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Appending of square numbers to a sorted table with elementary line type.
ABEXA 00007
ABAP_EXAMPLE_END

ABAP Alternative 2 ... INITIAL LINE

What does it do?
A new line is appended in which every component contains the type-dependent initial value.

ABAP_EXAMPLE_VX5
Appending of an initial line that simultaneously is linked to a field symbol using the addition ASSIGNING . This means that initial lines can be processed directly.
ABEXA 00008
ABAP_EXAMPLE_END

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

What does it do?
The lines of an internal table jtab are appended as a block. jtab is a functional operand position.
The lines to be inserted are taken sequentially from the table jtab . The line type of jtab can be incompatible with the line type of the internal table itab and is converted to the line type of the target table, if necessary, in accordance with the conversion rules. If a conversion error occurs here, the exception cannot be handled using CX_SY_CONVERSION_ERROR and the associated runtime error occurs instead.
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.
If a conflict with existing primary or secondary table keys occurs, this always raises an uncatchable exception when multiple lines are appended from an internal table.



Latest notes:

When a standard table is constructed, the constructor operators NEW and VALUE can also append multiple lines from a table to the target table using LINES OF.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Appending of the lines of an internal table itab2 to the standard table itab1.
ABEXA 00009
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
Appending of the lines of an internal table jtab to the standard table itab with the additions FROM, TO, and STEP.
ABEXA 01634
ABAP_EXAMPLE_END

Return to menu