0% found this document useful (0 votes)
25 views2 pages

30 - SAP ABAP - Copying Internal Tables

The document explains how to copy records from an internal table in SAP ABAP using the MOVE and MOVE-CORRESPONDING statements. It provides examples of both methods, demonstrating how to transfer data from a database table to an internal table while ensuring matching field names and data types. The document emphasizes the efficiency of using MOVE-CORRESPONDING for transferring multiple fields at once.

Uploaded by

akhter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

30 - SAP ABAP - Copying Internal Tables

The document explains how to copy records from an internal table in SAP ABAP using the MOVE and MOVE-CORRESPONDING statements. It provides examples of both methods, demonstrating how to transfer data from a database table to an internal table while ensuring matching field names and data types. The document emphasizes the efficiency of using MOVE-CORRESPONDING for transferring multiple fields at once.

Uploaded by

akhter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Page 1 of 2

SAP ABAP - Copying Internal Tables


When we read a record from an internal table with a header line, that record is moved
from the table itself into the header line. It is then the header line that our program
works with. The same applies while creating a new record. It is the header line with
which you work with and from which the new record is sent to the table body itself.

To copy the records, we can use a SELECT statement to select all of the records from the
table and then use MOVE statement that will move the records from the original table
into the new internal table into the fields where the names correspond.

Following is the syntax for MOVE statement −

MOVE <table_field> TO <internal_tab_field>.

Example

REPORT ZCUSLIST1.
TABLES: ZCUSTOMERS1.
DATA: BEGIN OF itab01 Occurs 0,
name LIKE ZCUSTOMERS1-name,
dob LIKE ZCUSTOMERS1-dob,
END OF itab01.

Select * FROM ZCUSTOMERS1.


MOVE ZCUSTOMERS1-name TO itab01-name.
MOVE ZCUSTOMERS1-dob TO itab01-dob.
ENDSELECT.

Write: / itab01-name, itab01-dob.

The above code produces the following output −

MARGARET 02.11.1994

The select loop fills each field one at a time, using the MOVE statement to move the data
from one table’s field to the other. In the above example, MOVE statements were used to
move the contents of the ZCUSTOMERS1 table to the corresponding fields in the internal
table. You can accomplish this action with just one line of code. You can use the
MOVECORRESPONDING statement.

Following is the syntax for MOVE-CORRESPONDING statement −

https://www.tutorialspoint.com/sap_abap/sap_abap_copying_internal_tables.htm 1/2
Page 2 of 2

MOVE-CORRESPONDING <table_name> TO <internal_tab>.

It tells the system to move the data from the fields of ZCUSTOMERS1 to their
corresponding fields in itab01.

Example

REPORT ZCUSTOMERLIST.
TABLES: ZCUSTOMERS1.
DATA: Begin of itab01 occurs 0,
customer LIKE ZCUSTOMERS1-customer,
name LIKE ZCUSTOMERS1-name,
title LIKE ZCUSTOMERS1-title,
dob LIKE ZCUSTOMERS1-dob,
END OF itab01.

SELECT * from ZCUSTOMERS1.


MOVE-Corresponding ZCUSTOMERS1 TO itab01.
APPEND itab01.
ENDSELECT.
LOOP AT itab01.
Write: / itab01-name, itab01-dob.
ENDLOOP.

The above code produces the following output −

MARK 21.05.1981
JAMES 14.08.1977
AURIELE 19.06.1990
STEPHEN 22.07.1985
MARGARET 02.11.1994

This is made possible by the fact that both have matching field names. When making use
of this statement, you need to make sure that both fields have matching data types and
lengths. It has been done here with the LIKE statement previously.

https://www.tutorialspoint.com/sap_abap/sap_abap_copying_internal_tables.htm 2/2

You might also like