06-07-2007 4:46 PM
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
06-07-2007 4:48 PM
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
06-07-2007 4:48 PM
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
06-07-2007 4:49 PM
06-07-2007 5:17 PM
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
06-07-2007 5:20 PM
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
06-07-2007 5:21 PM
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.
06-07-2007 5:32 PM
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
06-07-2007 5:55 PM
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..
06-07-2007 6:45 PM
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