Application Development and Automation 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: 
Read only

Passing One internal Table Between two reports

Former Member
0 Likes
1,888

Hi experts

This is Venky and my question is

how to pass one internal table between two reports using EXPORT IMPORT abap memory.

send me code plz.

thnz in advance.

regds

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,373

hi ,

check this sample

1.

DATA TEXT1(10) VALUE 'Exporting'.
DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
DO 5 TIMES.
ITAB-BOOKID = 100 + SY-INDEX.
APPEND ITAB.
ENDDO.

EXPORT ITAB
TO MEMORY ID 'table'.

2. IMPORTING...

DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.
LOOP AT JTAB.
WRITE / JTAB-BOOKID.
ENDLOOP.

regards

satesh

Hi experts

This is Venky and my question is

how to pass one internal table between two reports using EXPORT IMPORT abap memory.

send me code plz.

thnz in advance.

regds

9 REPLIES 9
Read only

Former Member
0 Likes
1,373

Hi,

Try following sample code.

EXPORT itab[] to memory id 'itab'.

while importing in other report,

declare your internal table as itab with same structure.

Then use..

IMPORT itab[]=itab[] from memory id 'itab'.

Hope it helps..

Regards,

Shashank

Read only

Former Member
0 Likes
1,373

Hi Venky ,

EXPORT obj1 ... objn TO MEMORY.

IMPORT f itab FROM MEMORY.

Try this link

http://www.geocities.com/SiliconValley/Campus/6345/export01.htm

Cheers

Sunny

Read only

Lakshmant1
Active Contributor
0 Likes
1,373

Hi Venkatesh,

Have a look at demo programs

DEMO_DATA_EXT_CLUSTER_IMPORT

DEMO_DATA_EXT_CLUSTER_EXPORT

Hope this helps

Thanks

Lakshman

Read only

Former Member
0 Likes
1,373

YOu can use:

EXPORT INTERNAL TABLE itab.

Read only

Former Member
0 Likes
1,374

hi ,

check this sample

1.

DATA TEXT1(10) VALUE 'Exporting'.
DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
DO 5 TIMES.
ITAB-BOOKID = 100 + SY-INDEX.
APPEND ITAB.
ENDDO.

EXPORT ITAB
TO MEMORY ID 'table'.

2. IMPORTING...

DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.
LOOP AT JTAB.
WRITE / JTAB-BOOKID.
ENDLOOP.

regards

satesh

Read only

0 Likes
1,373

hi satheesh

i awarded points to you.

regds

Read only

Former Member
0 Likes
1,373

Hi Venky,

Sample Code:

You can export the internal table from Program 1 as below:

FREE MEMORY ID 'ID1'.

EXPORT itab TO MEMORY ID 'ID1'.

You can retrieve the same Internal table in another Program using statements:

IMPORT itab FROM MEMORY ID 'ID1'.

FREE MEMORY ID 'ID1'.

Thanks & Regards,

Nirupamaa.

Read only

Former Member
0 Likes
1,373

HI

try using this

EXPORT (itab) TO MEMORY ID id.

IMPORT ITAB = (itab) from memory ID id.

regards

kishore

Read only

Former Member
0 Likes
1,373

hi,

<b>Reading Data Objects from Memory</b>

To read data objects from ABAP memory into an ABAP program, use the following statement:

Syntax

IMPORT <f1> [TO <g 1>] <f 2> [TO <g 2>] ... FROM MEMORY ID <key>.

This statement reads the data objects specified in the list from a cluster in memory. If you do not use the TO <g i > option, the data object <f i > in memory is assigned to the data object in the program with the same name. If you do use the option, the data object <f i > is read from memory into the field <g i >. The name <key> identifies the cluster in memory. It may be up to 32 characters long.

You do not have to read all of the objects stored under a particular name <key>. You can restrict the number of objects by specifying their names. If the memory does not contain any objects under the name <key>, SY-SUBRC is set to 4. If, on the other hand, there is a data cluster in memory with the name <key>, SY-SUBRC is always 0, regardless of whether it contained the data object <f i >. If the cluster does not contain the data object <f i >, the target field remains unchanged.

In this statement, the system does not check whether the structure of the object in memory is compatible with the structure into which you are reading it. The data is transported bit by bit. If the structures are incompatible, the data in the target field may be incorrect.

PROGRAM SAPMZTS1.

DATA TEXT1(10) VALUE 'Exporting'.

DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.

DO 5 TIMES.

ITAB-BOOKID = 100 + SY-INDEX.

APPEND ITAB.

ENDDO.

EXPORT TEXT1

TEXT2 FROM 'Literal'

TO MEMORY ID 'text'.

EXPORT ITAB

TO MEMORY ID 'table'.

SUBMIT SAPMZTS2 AND RETURN.

SUBMIT SAPMZTS3.

The first part of this program is the same as the example in the section Saving Data Objects in Memory. In the example, the programs SAPMZTS1 and SAPMZTS2 are called using SUBMIT. You can create and maintain the programs called using the SUBMIT statement by double-clicking their names in the statement. For further information about the SUBMIT statement, refer to Calling Executable Programs (Reports)

Example for SAPMZTS2:

PROGRAM SAPMZTS2.

DATA: TEXT1(10),

TEXT3 LIKE TEXT1 VALUE 'Initial'.

IMPORT TEXT3 FROM MEMORY ID 'text'.

WRITE: / SY-SUBRC, TEXT3.

IMPORT TEXT2 TO TEXT1 FROM MEMORY ID 'text'.

WRITE: / SY-SUBRC, TEXT1.

Example for SAPMZTS3:

PROGRAM SAPMZTS3.

DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.

IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.

LOOP AT JTAB.

WRITE / JTAB-BOOKID.

ENDLOOP.

The output is displayed on two successive screens and the program SAPMZTS2 attempts to read a data object TEXT3 from the data cluster "text", which does not exist. TEXT3 therefore remains unchanged. The existing data object TEXT2 is placed in TEXT1. In both cases, SY-SUBRC is 0, since the cluster "text" contains data.

The program SAPMZTS3 reads the internal table ITAB from the cluster "table" into the internal table JTAB. Both tables have the same structure, namely that of the ABAP Dictionary table SBOOK.

Message was edited by: Ashok Kumar Prithiviraj