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

Import / Export Problem

Former Member
0 Likes
1,095

Hi,

My problem is:

I have an internal table it_tab in a program zp1.

now from zp1 i want to export it to memory, and then do a 'leave to transaction zp2'. but the problem is that in zp2 i cant do an import from memory as it come out to be blank.

help me to get the value of it_tab exported in zp1 in the program zp2.

please provide code if possible.

Regards,

Gaurav.

7 REPLIES 7
Read only

Former Member
0 Likes
844

Hi,

Take a look at this code from SAP Help.



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.



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.

Regards,

Ravi

Note : Please mark the helpful answers

Read only

Former Member
0 Likes
844

Hi gaurav,

Important:

<b>Keep the name of the variables/internal table

SAME

in both the programs,

other wise, the imported value will be BLANK.</b>

1. in your first program, write

export itab to memory id 'ITAB'.

where itab = your internal table

2. in your other program

import itab from memory id 'ITAB'.

3. MOST IMPORTANT THING :

a) u can use the name of the memory id, whatever

u want

b) BUT, the VARIABLE NAME / ITAB NAME should

be SAME in both programs.

Other wise it won't work.

regards,

amit m.<b></b>

Message was edited by: Amit Mittal

Read only

Former Member
0 Likes
844

Hai Gaurav

Check this syntax

Export the data in some memory location and getting data from that memory Location

Calling:

Export v_matnr to Memoryid 'MATNR'. this can be treated as a pointer to the variable V_matnr.

Called Program:

Import V_matnr from memoryid 'MATNR'. This will return sy-subrc.

Leave to Transaction MM01 this means it kills the current Transaction and branches to new Transaction like 'MM01'.

Thanks & Regards

Sreenivasulu P

Read only

Former Member
0 Likes
844

Yes I know tht calling the new tranasction kills the current program and also the memory. i need a solution to this problem...

abd problaly the code if possible.

Regards,

Gaurav.

Read only

0 Likes
844

Gaurav,

The code that i have given you should work, i am not sure what more you are looking for?

Regards,

Ravi

Read only

Former Member
0 Likes
844

Hello Gaurav,

Use the following code..

REPORT ZTEST123 .

data: begin of i_mara occurs 0,

matnr like mara-matnr,

end of i_mara.

data: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE',

WA_INDX TYPE INDX.

select matnr into i_mara-matnr from mara.

append i_mara.

if sy-dbcnt = 10.

exit.

endif.

endselect.

WA_INDX-AEDAT = SY-DATUM.

WA_INDX-USERA = SY-UNAME.

export i_mara from i_mara to database indx(ST) from wa_indx id indxkey.

submit ztest567.

REPORT ZTEST567 .

data: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE',

WA_INDX TYPE INDX.

data: begin of i_mara occurs 0,

matnr like mara-matnr,

end of i_mara.

import i_mara = i_mara from database indx(ST) iD INDXKEY TO wa_indx.

break-point.

Read only

Former Member
0 Likes
844

Hi Gaurav,

When you use the leave to transaction, you cannot use import and export from memory.

If you want to get the values when you import the table, you have to either use a call transaction statement in your first program or a submit statement. You will be able to import the table values.

If you are particular that you want to use the leave to transaction command, use the set/get parameter statements. However you cannot send a table for this, you will have to send each field separately.

So the better option would be to not use leave to transaction.

Regards,

Susmitha