Monday, April 15, 2013

0 How to copy one internal table to another in ABAP


Copying an Internal Table into another Internal Table:
If you want to copy the entire contents of one internal table into another in one execution, use the MOVE statement or the assignment operator (=) as follows:
Syntax
MOVE <itab1> TO <itab2>.
This statement is equivalent to:
<itab2> = <itab1>.
Note : above syntax  works only if ITAB2 is Empty
For example if ITAB2 having records at that time we have to use APPEND LINES OF
Syntax :
APPEND LINES OF itab1 TO itab2.

This method of appending lines of one table to another is about 3 to 4 times faster than appending them line by line in a loop. After the APPEND statement, the system field SY-TABIX
contains the index of the last line appended. When you append several lines to a sorted table, you must respect the unique key (if defined), and not violate the sort order. Otherwise, a runtime error will occur.

 

SAP-ABAP Copyright © 2011 - |- Template created by Vishnu - |- Powered by Blogger Templates