Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Export Import Internal tables across two z programs

Former Member
0 Kudos

Hi Group,

I have an internal table (itab) which I fill in program Z1. Now I want to export this itab to a memory id and then in program Z2 I will import this table in the initialization event. Any idea how can I do this ?

Ankur Bhandari

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI,

If import export is not working . You can try using

global SAP memory.

DATA: REPID(8) VALUE 'RFSCHU01'.

SET PARAMETER ID 'RID' FIELD REPID.

Get PARAMETER ID 'RID' FIELD REPID.

Double Click on 'RID' it will create global paramter id

Regards

Amole

12 REPLIES 12

Former Member
0 Kudos

Hi,

EXPORT obj1 ... objn TO MEMORY.

IMPORT obj1 ... FROM MEMORY.

Hope this may be helpful

Regards

Amole

Former Member
0 Kudos

In prog Z1:

export itab to memory id 'ZZPROG'.

In prog Z2:

import itab from memory id 'ZZPROG'.

Itab must be declared the same way in both programs!

<b>Thanks for the reward</b>

0 Kudos

This doesnt work. Please confirm.

Ankur Bhandari

p.s This works with normal variables, but I have an internal table with 100 rows and 4 columns

Message was edited by: Ankur Bhandari

Former Member
0 Kudos

Hi,

U can export using the EXPORT/IMPORT options.

Ex:

TABLES INDX.

DATA : BEGIN OF ITAB OCCURS 0,

f1,f2...

END OF ITAB.

Fill ITAB with values...

For Exporting,

CLEAR INDX.

INDX-AEDAT = SY-DATUM.

INDX-USERA = SY-UNAME.

INDX-PGMID = SY-REPID.

EXPORT ITAB TO DATABASE INDX(HK) ID 'Table'.

For importing,

IMPORT ITAB TO JTAB FROM DATABASE INDX(HK) ID 'Table'.

JTAB should have the same structure as ITAB

Sreedhar

Message was edited by: Sreedhar Kanchanapalli

0 Kudos

What is the importance of 'HK' or it can be anything ? How can I free this id ? I used to use free memory id earlier ?

0 Kudos

Tried this , this doesn't work. Any one can share a working code ?

Ankur Bhandari

0 Kudos

HI Ankur

You can use below code.

Define below variables in both the programs.

<b>DATA: w_indxkey TYPE indx-srtfd VALUE 'TABLE'.

DATA: wa_indx TYPE indx.</b>

Define internal table with reference to DB structure so that in future if you want make some changes in internal table then it will be reflected in both the programs.

<b>data itab type table of ddic_structure.</b>

<b>

EXPORT itab FROM itab

TO DATABASE indx(st)

FROM wa_indx

ID w_indxkey.

IMPORT itab TO itab

FROM DATABASE indx(st)

ID w_indxkey

TO wa_indx.

FREE MEMORY ID w_indxkey.</b>

Regards,

Atish

Former Member
0 Kudos

HI,

If import export is not working . You can try using

global SAP memory.

DATA: REPID(8) VALUE 'RFSCHU01'.

SET PARAMETER ID 'RID' FIELD REPID.

Get PARAMETER ID 'RID' FIELD REPID.

Double Click on 'RID' it will create global paramter id

Regards

Amole

Former Member
0 Kudos

Hi Ankur,

INDX is cluster table for index. HK is a area in that table where u r going to store ur Itab entries temporarily. U can use also different area for that...Pls chk the INDX table entries.

To clear Memory...use FREE MEMORY..statement only...

Sreedhar

Former Member
0 Kudos

Hi,

It is the well executed code in our project...

May i know how u are executing the other program after excporting from one program..

Sreedhar

Former Member
0 Kudos

Hi,

try create a database table with same structure and

write the data to this table from progran Z1.

Read this table from program Z2.

Regards

Amole

Lakshmant1
Active Contributor
0 Kudos

Hi Ankur,

Have a look at demo programs

DEMO_DATA_EXT_CLUSTER_IMPORT

DEMO_DATA_EXT_CLUSTER_EXPORT

Hope these progrmas gives some inputs.

Thanks

Lakshman