ABAPAPPEND_LINESPEC - APPEND LINESPEC

ABAP Short Reference   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

APPEND - line_spec

Short Reference



Syntax

... wa
  | {INITIAL LINE}
  | {LINES OF jtab [FROM idx1] [TO idx2] [USING KEYkeyname]} ... .

Alternatives:

1. ... wa

2. ... INITIAL LINE

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

Effect

You can append either a workarea wa, an inital row INITIAL LINE or several rows of an internal table jtab.

Alternative 1

... wa


Effect

A new row is appended to which the content of the workarea wa is assigned. wa is afunctionaloperand position. wa can be incompatible with the line type of the internal table and is converted in accordance with theconversion rules to the relevant line type (if necessary).

Notes

  • If a conflict occurs with an existing unique primary table type, this causes an unhandled exceptionwhen appending a single line. In the case of a conflict with a unique secondary table key, a treatable exception of the class CX_SY_ITAB_DUPLICATE_KEYoccurs.

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


Alternative 2

... INITIAL LINE


Effect

A new line is added in which every component contains the type-specific initial value.

Example

Attaching an initial row which is also linked to a field symbol by the ASSIGNINGaddition. This means that initial lines 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 = '...'.
...

Alternative 3

... 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 afunctional operand position.

The inserted lines are sequentially taken from the table jtab. The row type of jtab canbe 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 theconversion rules.

The sequence in which the lines are taken is the same as for the statement LOOPand can also be influenced by specifying a table key keynameafter USING KEY. The additions FROM idx1 and TO idx2 have, in relation to jtab,the same syntax and effect as for LOOP.

Note

If a conflict with existing primary or secondary table keys occurs, this always causes an unhandled exception when you append multiple lines.

Example

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.




Addresses (Business Address Services)   General Data in Customer Master  
This documentation is copyright by SAP AG.


Length: 5515 Date: 20120518 Time: 191051     triton ( 178 ms )