EXPORT IMPORT database table(INDX) data
Source : http://abapjoy.blogspot.com
It’s possible to transfer data to other program with EXPORT / IMPORT statement.
EXPORT / IMPORT can handle 3 types of data, which are ABAP memory, shared buffer area, database table.
In this chapter, let’s see how to handle database data with EXPORT / IMPORT.
This method is to save data into INDX table and read data from INDX table, which is very similar to the way we save the data into transparent table.
The below statement describes how to save the data of internal table into INDX table. You can declare the index name freely, which is the area in the table and Key value.
- Export data
|EXPORT GT_ITAB TO DATABASE INDX(ZK) ID ‘EABAP’.|
You can read the data from INDX table and save the data into internal table
- Import data
|IMPORT gt_itab FROM DATABASE INDX(ZK) ID ‘EABAP’|
If the data is transferred to another program, you need to remove unwanted data from INDX table using the delete statement.
- Delete data
|DELETE FROM DATABASE INDX(ZK) ID ‘EABAP’.|
Let’s create 2 programs and check how to transfer data between programs.
DATA GT_ITAB TYPE TABLE OF SFLIGHT.
SELECT * FROM SFLIGHT INTO TABLE GT_ITAB UP TO 5 ROWS.
EXPORT GT_ITAB TO DATABASE INDX(ZK) ID ‘EABAP’.
REPORT = ‘ZIMPORT_01’ .
After execution program 1, the blow data is created in INDX table. If the data volume exceeds the column capacity, the new line is created and the SRTF2 column sequence is increased sequentially.
Now, let’s read the data from INDX table with [ex 2]. As you already know, all sap user can access and use the data in INDX table. So after import data and the data is not needed anymore, you need to delete INDX data.
DATA gt_itab TYPE TABLE OF SFLIGHT.
IMPORT gt_itab FROM DATABASE INDX(ZK) ID ‘EABAP’
DELETE FROM DATABASE INDX(ZK) ID ‘EABAP’.
LOOP AT gt_itab INTO WA.