sapdev logo background
sapdev logo sapdev logo
Comments

ABAP APPEND LINESPEC Statement syntax, information and example SAP source code



Return to Statement index



APPEND - line_spec

Short Reference

ABAP Syntax ABAP_KEY ... wa
| {INITIAL LINE}
| {LINES OF jtab [FROM idx1] [TO idx2] [USING KEY keyname ]} ... .

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

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

ABAP_ALTERNATIVE_1 ... wa

What does it do? A new row 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 row type of the internal table and, if necessary, is converted to the 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
.
Latest notes: If a conflict occurs with an existing unique primary table type, this raises a non-handleable exception when appending a single row. In the case of a conflict with a unique secondary table key, a handleable exception of the class CX_SY_ITAB_DUPLICATE_KEY is raised.

Specifying a calculation expression for wa is usually only a good idea for elementary row types.

With the exception, an obsolete short form
is possible where wa TO can be omitted, if the internal table has a header line itab with the same name. The statement then uses the header line as the work area implicitly.

Example ABAP Coding Appending square numbers to a sorted table with elementary row type.
DATA: int TYPE i,
itab LIKE SORTED TABLE OF int
WITH UNIQUE KEY table_line.

DO 10 TIMES.
int = sy-index ** 2.
APPEND int TO itab.
ENDDO.

ABAP_ALTERNATIVE_2 ... INITIAL LINE

What does it do? A new row is added in which every component contains the type-specific initial value.
.

Example ABAP Coding Attaching 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.

APPEND INITIAL LINE TO itab ASSIGNING <(><<)>line>.
<(><<)>line>-carrid = '...'.
...

ABAP_ALTERNATIVE_3 ... LINES OF jtab [FROM idx1] [TO idx2] [USING KEY keyname]

What does it do? The rows of an internal table jtab are added as a block. jtab is a functional operand position .
The inserted rows are sequentially taken from the table jtab . The row type of jtab can be incompatible with the row type of the internal table itab and it is converted to the row type of the target table (if necessary), in accordance with the conversion rules .
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 .
Latest notes: If a conflict with existing primary or secondary table keys occurs, this always raises a non-handleable exception when multiple rows
are appended.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




APPEND
APPEND_RESULT




comments powered by Disqus