2007 Jul 09 1:58 PM
Hi All,
I want to use an internal table of one program in another in runtime only, Program A will call Program B and the internal table in Program A have to be used in Program B.
Can anyone tell me how to use the complete internal table in that way if it is at all possible?
Please help ASAP.
Regards
Siddhartha Sengupta
2007 Jul 09 2:01 PM
Hi
Use EXPORT/IMPORT FROM/TO MEMORY
EPORT Z1.
DATA: BEGIN OF ITAB OCCURS 0,
FIELD1,
FIELD2,
END OF ITAB.
EXPORT ITAB TO MEMORY ID 'ZMY'.
SUBMIT REPORT Z2 AND RETURN.
REPORT Z2.
DATA: BEGIN OF ITAB OCCURS 0,
FIELD1,
FIELD2,
END OF ITAB.
IMPORT ITAB FROM MEMORY ID 'ZMY'.
Max
2007 Jul 09 2:01 PM
Hi
Use EXPORT/IMPORT FROM/TO MEMORY
EPORT Z1.
DATA: BEGIN OF ITAB OCCURS 0,
FIELD1,
FIELD2,
END OF ITAB.
EXPORT ITAB TO MEMORY ID 'ZMY'.
SUBMIT REPORT Z2 AND RETURN.
REPORT Z2.
DATA: BEGIN OF ITAB OCCURS 0,
FIELD1,
FIELD2,
END OF ITAB.
IMPORT ITAB FROM MEMORY ID 'ZMY'.
Max
2007 Jul 09 4:25 PM
Hi Max,
the code that u have given is not working, its asking for the FROM TO field name.
what should i do?
Regards
Siddhartha Senguptsa
2007 Jul 09 4:33 PM
Hi
the name is the variable, I don't know.
The comands you need to use are:
-1) Export the table to memory:
EXPORT <TABLE> TO MEMORY ID <LABEL>.
-2) Import the table from memory:
IMPORT <TABLE> FROM MEMORY ID <LABEL>.
In my code I've export the table in report Z1 and import it in the report Z2.
The table ITAB to be exported/imported has to be defined in both reports.
DATA: BEGIN OF ITAB OCCURS 0,
FIELD1,
FIELD2,
END OF ITAB.
EXPORT ITAB TO MEMORY ID 'ZMY'.
SUBMIT Z2 AND RETURN.
*------------------------------------------------*
REPORT Z2.
DATA: BEGIN OF ITAB OCCURS 0,
FIELD1,
FIELD2,
END OF ITAB.
IMPORT ITAB FROM MEMORY ID 'ZMY'.
It's important you assign a label to the memory area to be used, here I've used ZMY, but you can use every label you want.
I don't get any error in my system.
Max
2007 Jul 09 2:02 PM
Hi,
The SAP Memory is a user-specific memory area of the application server, which is accessed by all main sessions of a user session at once. ABAP programs have access to SPA/GPA parameters stored in the SAP Memory (also called SET/GET parameters).
e.g.
Using Set parameter
you can give value of variable (dobj) to parameter ID 'pid'. This will store value in SAP memory
SET PARAMETER ID pid FIELD dobj.
When you want to use that value stored in SAP memory
you can use GET parameter.
GET PARAMETER ID pid FIELD dobj.
The above cannot be used for internal table. Supported data types are (data type C, N, D or T).
Memory-ID is used to save and retrieve the last entered data in the field.
Eg.
EXPORT (ITAB) TO MEMORY ID 'itab'. " in Program A.
IMPORT (ITAB) FROM MEMORY ID 'itab'. " in Program B
Shared memory is the area that can be used to share data between different processes.
Regards,
Vinodh
2007 Jul 09 2:02 PM
use EXPORT / IMPORT statements
EXPORT (ITAB) TO MEMORY ID 'ABC'. " in Program A.
IMPORT (ITAB) FROM MEMORY ID 'ABC'. " in Program B