Register Login

How to copy a portion of an internal table to another.

Updated May 18, 2018

There are two ways to do that:

  1. Append line
  2. Insert line

By using append line the rows of a table are copied to the end of another table.

By using insert line the rows of a table are copied to any position other than the end of another table.

Both are written before loop at statement.

To insert a single line into a database table, use the following:

insert into itab values wa.
The contents of the work area what are written to the database table dbtab. It is a good idea to define the work area with reference to the structure of the database table.

To insert several lines into a database table, use the following:

insert wa from table into itab.
This writes all lines of the internal table itab to the database table in one single operation. If one or more lines cannot be inserted because the database already contains a line with the same primary key, a runtime error occurs. You can prevent the runtime error occurring by using the addition ACCEPTING DUPLICATE KEYS.

look at this code:

loop at itab assigning where field = value.
append to newITab.
endloop.

OR

do n times.
read bla bla.
append bla bla.
enddo.
 


×