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 and export

Former Member
0 Likes
1,223

can someone give me sample code for import and export to memory id.... the reason io need it is that i have to write a routine and based on one condtion value i have to change another condtion . i need to pass a value...any suggestions?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,183

Hi

Export:

Export two fields and an internal table to the database table INDX :

TABLES INDX.

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

F1(4), F2 TYPE P,

BEGIN OF ITAB3 OCCURS 2,

CONT(4),

END OF ITAB3.

  • Before the export, the data fields in

  • front of CLUSTR are filled.

INDX-AEDAT = SY-DATUM.

INDX-USERA = SY-UNAME.

  • Export der Daten.

EXPORT F1 F2 ITAB3 TO

DATABASE INDX(ST) ID INDXKEY.

Import:

TABLES INDX.

DATA: INDXKEY LIKE INDX-SRTFD,

F1(4), F2 TYPE P,

BEGIN OF TAB3 OCCURS 10,

CONT(4),

END OF TAB3,

BEGIN OF DIRTAB OCCURS 10.

INCLUDE STRUCTURE CDIR.

DATA END OF DIRTAB.

INDXKEY = 'INDXKEY'.

EXPORT F1 F2 TAB3 TO

DATABASE INDX(ST) ID INDXKEY. " TAB3 has 17 entries

...

IMPORT DIRECTORY INTO DIRTAB FROM DATABASE INDX(ST) ID INDXKEY.

Regards,

Raj

9 REPLIES 9
Read only

Former Member
0 Likes
1,184

Hi

Export:

Export two fields and an internal table to the database table INDX :

TABLES INDX.

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

F1(4), F2 TYPE P,

BEGIN OF ITAB3 OCCURS 2,

CONT(4),

END OF ITAB3.

  • Before the export, the data fields in

  • front of CLUSTR are filled.

INDX-AEDAT = SY-DATUM.

INDX-USERA = SY-UNAME.

  • Export der Daten.

EXPORT F1 F2 ITAB3 TO

DATABASE INDX(ST) ID INDXKEY.

Import:

TABLES INDX.

DATA: INDXKEY LIKE INDX-SRTFD,

F1(4), F2 TYPE P,

BEGIN OF TAB3 OCCURS 10,

CONT(4),

END OF TAB3,

BEGIN OF DIRTAB OCCURS 10.

INCLUDE STRUCTURE CDIR.

DATA END OF DIRTAB.

INDXKEY = 'INDXKEY'.

EXPORT F1 F2 TAB3 TO

DATABASE INDX(ST) ID INDXKEY. " TAB3 has 17 entries

...

IMPORT DIRECTORY INTO DIRTAB FROM DATABASE INDX(ST) ID INDXKEY.

Regards,

Raj

Read only

0 Likes
1,183

the problem is this routine is in purchase order. i have to export from the first section and then import in the second. when i import sy-subrc is 0 but still data does not get transfered. note: both this section get executed in the PO itself.

data: zpb1 like komv occurs 1 with header line.

data: wa_zpb1 like line of zpb1.

data: spb1 type komv-kwert.

BREAK CVSNAVID.

************************

first section

********************

IF XKOMV-KSCHL = 'ZPB1'.

IF XKOMV-kwert IS NOT INITIAL.

.

data: tkomv like komv occurs 1 with header line..

move xkomv to tkomv.

append tkomv.

export tkomv[] TO MEMORY ID 'ZPB1'.

ENDIF.

ENDIF.

****************

second section

**************

if xkomv-kschl = 'JVRD'.

CLEAR: ZPB1,spb1.

IMPORT ZPB1[] FROM MEMORY ID 'ZPB1'.

ENDIF.

Read only

0 Likes
1,183

HI Navid,

The name of the internal tables in the import and export should be same.

<b>export tkomv[] TO MEMORY ID 'ZPB1'.</b>

<b>IMPORT tkomv[] FROM MEMORY ID 'ZPB1'.</b>

Regard,

Read only

0 Likes
1,183

Hi Wasim.

Your answer helped me a lot..

Thanx a ton.

Read only

Former Member
0 Likes
1,183

Hi,

<b>Program A :</b>

SELECT-OPTIONS: S_BELNR FOR BKPF-BELNR.

EXPORT S_BELNR TO MEMORY ID 'ZXC9'.

<b>Program B :</b>

DATA: BEGIN OF S_BELNR OCCURS 10.

INCLUDE STRUCTURE STRUC1.

DATA: LOW LIKE BKPF-BELNR,

HIGH LIKE BKPF-BELNR.

DATA: END OF S_BELNR.

IMPORT S_BELNR FROM MEMORY ID 'ZXC9'.

For EXPORT: http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/export01.htm

For IMPORT: http://www.geocities.com/siliconvalley/campus/6345/import01.htm

Hope this helps

Regards

Sudheer

Read only

Former Member
0 Likes
1,183

hi,

export matnr to memory id 'TEST'.

import matnr from memory id 'TEST '

free memory id 'TEST'.

matnr defined in export and import should be of same

type and length

Regards

Amole

Read only

Former Member
0 Likes
1,183

Hello Navid,

You may see this standard code at ABAPDOCU transaction:

<b>REPORT demo_data_ext_cluster_import.

DATA text1(10) TYPE c VALUE 'Exporting'.

DATA: itab TYPE TABLE OF sbook,

wa_itab LIKE LINE OF itab.

DO 5 TIMES.

wa_itab-bookid = 100 + sy-index.

APPEND wa_itab TO itab.

ENDDO.

EXPORT text1

text2 FROM 'Literal'

TO MEMORY ID 'text'.

EXPORT itab

TO MEMORY ID 'table'.

SUBMIT demo_data_ext_cluster_import2 AND RETURN.

SUBMIT demo_data_ext_cluster_import3.</b>

Read only

dani_mn
Active Contributor
0 Likes
1,183

HI,

<b>REPORT ZTEST2 .

data: it_bkpf type table of bkpf with header line.

SELECT * FROM bkpf into table it_bkpf.



EXPORT it_bkpf[] TO MEMORY ID 'MID'.

refresh it_bkpf.

IMPORT it_bkpf[] FROM MEMORY ID 'MID'.

LOOP AT It_bkpf.
write:/ it_bkpf-belnr, 'found' color col_positive.
ENDLOOP.</b>

REgards,

Read only

Former Member
0 Likes
1,183

Hi Navid,

here an simple example:

REPORT ZGRO_EXPORT.

*

DATA: TEST(10) VALUE 'Export'.

*

START-OF-SELECTION.

*

EXPORT TEST TO MEMORY ID 'TEXT'.

*

WRITE: / SY-REPID, TEST.

*

SUBMIT ZGRO_TESTT AND RETURN.

*

IMPORT TEST FROM MEMORY ID 'TEXT'.

*

WRITE: / SY-REPID, TEST.

*

END-OF-SELECTION.

REPORT ZGRO_IMPORT MESSAGE-ID ZZ.

*

DATA: TEST(10).

*

START-OF-SELECTION.

*

IMPORT TEST FROM MEMORY ID 'TEXT'.

*

WRITE: / SY-REPID, TEST.

*

Test = 'Back'.

*

export TEST TO MEMORY ID 'TEXT'.

*

WRITE: / SY-REPID, TEST.

*

END-OF-SELECTION.

Regards, Dieter