11-20-2006 1:43 PM
Hi all,
I have the following dilemma. I need to pass the contents of an internal table populated in one ABAP program to another ABAP program run subsequently in another session. I have succeeded in storing a single field in SAP memory and used the ' set / get parameter ' syntax to retrieve it. However I cannot find a neat method of easily storing and retrieving an internal table in the same way.
Regards
Glen.
11-20-2006 1:52 PM
If the requirement is just to store internal tables between abap sessions, then you can just use import and export statements.
Example
Import two fields and an internal table from the application buffer with the structure INDX:
TYPES: BEGIN OF ITAB3_LINE,
CONT(4),
END OF ITAB3_LINE.
DATA: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE',
F1(4),
F2(8) TYPE P DECIMALS 0,
ITAB3 TYPE STANDARD TABLE OF ITAB3_LINE,
INDX_WA TYPE INDX.
Import data.
IMPORT F1 = F1 F2 = F2 ITAB3 = ITAB3
FROM SHARED BUFFER INDX(ST) ID INDXKEY TO INDX_WA.
After import, the data fields INDX-AEDAT and
INDX-USERA in front of CLUSTR are filled with
the values in the fields before the EXPORT
statement.
***********************************************************************************************
Example
Exports two fields and an internal table to a data buffer:
TYPES: BEGIN OF ITAB3_TYPE,
CONT(4),
END OF ITAB3_TYPE.
DATA: XSTR TYPE XSTRING,
F1 TYPE C LENGTH 4,
F2 TYPE P,
ITAB3 TYPE STANDARD TABLE OF ITAB3_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 2.
EXPORT F1 FROM F1
F2 FROM F2
ITAB3 FROM ITAB3
TO DATA BUFFER XSTR.
Regards,
ravi
11-20-2006 1:52 PM
If the requirement is just to store internal tables between abap sessions, then you can just use import and export statements.
Example
Import two fields and an internal table from the application buffer with the structure INDX:
TYPES: BEGIN OF ITAB3_LINE,
CONT(4),
END OF ITAB3_LINE.
DATA: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE',
F1(4),
F2(8) TYPE P DECIMALS 0,
ITAB3 TYPE STANDARD TABLE OF ITAB3_LINE,
INDX_WA TYPE INDX.
Import data.
IMPORT F1 = F1 F2 = F2 ITAB3 = ITAB3
FROM SHARED BUFFER INDX(ST) ID INDXKEY TO INDX_WA.
After import, the data fields INDX-AEDAT and
INDX-USERA in front of CLUSTR are filled with
the values in the fields before the EXPORT
statement.
***********************************************************************************************
Example
Exports two fields and an internal table to a data buffer:
TYPES: BEGIN OF ITAB3_TYPE,
CONT(4),
END OF ITAB3_TYPE.
DATA: XSTR TYPE XSTRING,
F1 TYPE C LENGTH 4,
F2 TYPE P,
ITAB3 TYPE STANDARD TABLE OF ITAB3_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 2.
EXPORT F1 FROM F1
F2 FROM F2
ITAB3 FROM ITAB3
TO DATA BUFFER XSTR.
Regards,
ravi
07-31-2013 12:28 PM
How about using a Transparent Table with delivery class 'L' and temporarily storing the data.
11-20-2006 1:52 PM
u need to store data in abap memory..this can be acheived by import/export...u can import or export an internal table from one program to another program.
11-20-2006 1:55 PM
Hi Glen,
You can EXPORT TO MEMORY and IMPORT FROM MEMORY to pass an internal table between programs running in different sessions (but within the same context). If you have multiple contexts, you can use EXPORT TO/IMPORT FROM SHARED MEMORY, which would be global to an application server.
They all work pretty well and are well documented in the ABAP documentation.
MJ
01-04-2011 9:56 AM
Hello Friends ,
I am here giving you the example code :-
Report zprog1.
TYPES : BEGIN OF ty_mara,
matnr TYPE mara-matnr,
meins TYPE mara-meins,
END OF ty_mara.
DATA : wa_mara TYPE ty_mara,
it_mara TYPE STANDARD TABLE OF ty_mara.
wa_mara-matnr = '0009'.
wa_mara-meins = 'KG'.
APPEND wa_mara TO it_mara.
EXPORT it_mara FROM it_mara
TO MEMORY ID 'MY_ID'.
SUBMIT zprog2.
Here this is the first report zprog1 which exports the internal table it_mara into the second report zprog2.
Report zprog2.
TYPES : BEGIN OF ty_mara,
matnr TYPE mara-matnr,
meins TYPE mara-meins,
END OF ty_mara.
DATA : wa_mara TYPE ty_mara,
it_mara TYPE STANDARD TABLE OF ty_mara.
IMPORT it_mara = it_mara
FROM MEMORY ID 'MY_ID'.
LOOP AT it_mara
INTO wa_mara.
WRITE : wa_mara-matnr,wa_mara-meins.
ENDLOOP.
Here after importing the internam table you will get the ouput as : -
matnr - 009 and meins = KG.
which was set into the first report zprog1.
Kind Regards
Inderjeet Singh Kalra