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: 

exporting internal table to memory variable

Former Member
0 Kudos

I need to extract some data within a program into an internal table. Then I need to export the internal table into a memory variable

Then in another program i need to import this memory variable into another internal table

How to do the import export into a memory variable

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You can use EXPORT ..IMPORT..

Ex..


data: t_data type standard table of string.

* Export to memory
EXPORT t_data TO MEMORY ID 'ZMY_ID'.


* Import from memory
IMPORT t_data FROM MEMORY ID 'ZMY_ID'.

Thanks,

Naren

8 REPLIES 8

Former Member
0 Kudos

Hi,

You can use EXPORT ..IMPORT..

Ex..


data: t_data type standard table of string.

* Export to memory
EXPORT t_data TO MEMORY ID 'ZMY_ID'.


* Import from memory
IMPORT t_data FROM MEMORY ID 'ZMY_ID'.

Thanks,

Naren

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
export itab[] = itab[] to memory id 'ZTEST'.


import itab[] = itab[] from memory id 'ZTEST'.

Regards,

RIch Heilman

Former Member
0 Kudos

I tried both the above ways and they dont work.

Using export t_data[] = t_data[] to memory id 'my_id'.

gives error In Unicode programs, the "[" character cannot appear in names, as it

does here in the name "T_DATA[]".

IMPORT t_data to MEMORY ID 'my_id'.

IMPORT t_data from MEMORY ID 'my_id'. does not work

0 Kudos

Oh, well maybe you don't need the [], Naren's solution should work if you are exporting and importing within the same internal session. So if you are bouceing around different work processes, then no it will not work.

Give the memory ids as uppercase, not sure it makes a difference and make sure that T_DATA is defined exactly the same in both programs.

Regards,

Rich Heilman

Former Member
0 Kudos

See the simple example :

REPORT ZTEST_AMEM1.

tables : lfa1.

data : begin of i_lfa1 occurs 0 ,

lifnr like lfa1-lifnr,

name1 like lfa1-name1,

land1 like lfa1-land1,

end of i_lfa1.

start-of-selection.

select lifnr

name1

land1 from lfa1

into table i_lfa1 up to 100 rows.

  • Export

export i_lfa1 to memory id 'SAP'.

submit ztest_amem2 and return.

write:/ 'hello'.

&----


*& Report ZTEST_AMEM2

*&

&----


*&

*&

&----


REPORT ZTEST_AMEM2.

data : begin of j_lfa1 occurs 0,

lifnr like lfa1-lifnr,

name1 like lfa1-name1,

land1 like lfa1-land1,

end of j_lfa1.

start-of-selection.

import i_lfa1 to j_lfa1 from memory id 'SAP'.

loop at j_lfa1.

write:/ j_lfa1-lifnr,j_lfa1-name1,j_lfa1-land1.

endloop.

Former Member
0 Kudos

Seshu ... your code does not work. Narender has the same problem.

I put sy-subrc after IMPORT, and it outputs 4.

tables : lfa1.
data : begin of i_lfa1 occurs 0 ,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
land1 like lfa1-land1,
end of i_lfa1.

start-of-selection.
select lifnr
name1
land1 from lfa1
into table i_lfa1 up to 100 rows.

* Export
export i_lfa1 to memory id 'SAP'.

submit Z_SD_TEST2 and return.
write:/ 'hello'.


data : begin of j_lfa1 occurs 0,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
land1 like lfa1-land1,
end of j_lfa1.
start-of-selection.

import i_lfa1 to j_lfa1 from memory id 'SAP'.
write sy-subrc.
loop at j_lfa1.
write:/ j_lfa1-lifnr,j_lfa1-name1,j_lfa1-land1.
endloop. 

Message was edited by:

Megan Flores

Message was edited by:

Megan Flores

0 Kudos

I have tested at my system and it works great ..

This is one program :

report x.

tables : lfa1.

data : begin of i_lfa1 occurs 0 ,

lifnr like lfa1-lifnr,

name1 like lfa1-name1,

land1 like lfa1-land1,

end of i_lfa1.

start-of-selection.

select lifnr

name1

land1 from lfa1

into table i_lfa1 up to 100 rows.

  • Export

export i_lfa1 to memory id 'SAP'.

submit Z_SD_TEST2 and return.

write:/ 'hello'.

You need to create one more program :

Program name : Z_SD_TEST2

in this program :

data : begin of j_lfa1 occurs 0,

lifnr like lfa1-lifnr,

name1 like lfa1-name1,

land1 like lfa1-land1,

end of j_lfa1.

start-of-selection.

import i_lfa1 to j_lfa1 from memory id 'SAP'.

write sy-subrc.

loop at j_lfa1.

write:/ j_lfa1-lifnr,j_lfa1-name1,j_lfa1-land1.

endloop.

I have seen sy-subrc = 0 and even j_lfa1 internal has 100 records..

Former Member
0 Kudos

Hi folks .. I have been able to implement this now .. I was running the two programs in different sessions and that is the reason why it was not working. Thanks for your help