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

Problem in Importing Internal Table

Former Member
0 Likes
711

Dear All,

I am exporting Internal table from Program1 as follows:

REPORT ZEXPORT_TEST .

TYPES: BEGIN OF ITAB,

MATNR TYPE MARA-MATNR,

MATKL TYPE MARA-MATKL,

END OF ITAB.

DATA:IT TYPE TABLE OF ITAB .

SELECT MATNR MATKL FROM MARA INTO TABLE IT UP TO 10 ROWS.

EXPORT IT TO MEMORY ID 'EAI1'.

WRITE:/'Exported Successfully'.

And I am Importing same internal table into program2

REPORT ZIMPORT_TEST .

TYPES: BEGIN OF ITAB,

MATNR TYPE MARA-MATNR,

MATKL TYPE MARA-MATKL,

END OF ITAB.

DATA:IT TYPE TABLE OF ITAB,

IT1 TYPE TABLE OF ITAB,

WA TYPE ITAB.

IMPORT IT1 FROM MEMORY ID 'EAI1'.

IT[] = IT1[].

LOOP AT IT INTO WA.

WRITE:/ wa-matnr,

/ WA-MATKL.

ENDLOOP.

WRITE:/'Imported Successfully'.

But progam1 exporting correctly the return code is 0 but program2 is not importing sucessfully return code is 4.

Kindly help me to import.

Thanks in Advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
667

Hi Murugaperumal,

You need to try below

import IT = IT  FROM MEMORY ID 'EAI1'.

here your destination IT should be same as source internal table

hope it helps

Regards!

4 REPLIES 4
Read only

Former Member
0 Likes
668

Hi Murugaperumal,

You need to try below

import IT = IT  FROM MEMORY ID 'EAI1'.

here your destination IT should be same as source internal table

hope it helps

Regards!

Read only

Sougata
Active Contributor
0 Likes
667

Hi,

The internal table (object) name must be the same when exporting and importing. You are exporting internal table IT to the ABAP memory but want to import internal table IT1 from the ABAP memory!

Try this (in the second program):


REPORT  zsctest2.

TYPES: BEGIN OF itab,
        matnr TYPE mara-matnr,
        matkl TYPE mara-matkl,
       END OF itab.

DATA:  it  TYPE TABLE OF itab,
       wa  TYPE itab.

IMPORT it FROM MEMORY ID 'EAI1'.

LOOP AT it INTO wa.
  WRITE:/ wa-matnr,
          wa-matkl.
ENDLOOP.

CHECK sy-subrc = 0.
SKIP.
WRITE:/'Imported Successfully'.

Hope this solves your issue.

Cheers,

Sougata.

Read only

Former Member
0 Likes
667

Hi,

instead of changing the variable name of the internal table from it1 to it....

use the following syntax,

import it to it1 from memory id 'MID'.

Regards,

Siddarth

Read only

awin_prabhu
Active Contributor
0 Likes
667

Hi friend,

When u use 'Export' and 'Import' statements, it refers local sap memory.

So u need to use SUBMIT ZIMPORT_TEST AND RETURN statement immediately after 'Export'.

i.e.

Report ZEXPORT_TEST.

EXPORT IT TO MEMORY ID 'EAI1'. < -


Exported to common local sap memory

SUBMIT ZIMPORT_TEST AND RETURN . <---- Controls goes to next program, within same session.

Report ZIMPORT_TEST.

IMPORT IT from MEMORY ID 'EAI1'. <----


Imports data from common local sap memory.

If u want to run two independent reports one exporting, another importing, then u have to use

'SET' and 'GET' parameter concept which refers global sap memory.

Thanks..

Edited by: Sap Fan on Feb 27, 2009 4:56 AM

Edited by: Sap Fan on Feb 27, 2009 4:56 AM