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

What is IMPORT/EXORT statements ?please give some example code?

Former Member
0 Likes
1,139

What is IMPORT/EXORT statements ?please give some example code?

What is IMPORT/EXORT statements ?please give some example code?

4 REPLIES 4
Read only

Former Member
0 Likes
682

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

Syntax

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

This statement stores the data objects specified in the list as a cluster in memory. If you do not use the option FROM <f i >, the data object <f i > is saved under its own name. If you use the FROM <g i > option, the data objet <g i > is saved under the name <f i >. The name <key> identifies the cluster in memory. It may be up to 32 characters long.

The EXPORT statement always completely overwrites the contents of any existing data cluster with the same name <key>.

IMPORT :-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.

they are used to save and reterive data in ABAP memory.

here is an example to clear about them.

<b>REPORT ZWA_TEST2 .

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.

ENDLOOP.</b>

Reward points if it is useful.......

Read only

former_member196517
Contributor
Read only

Former Member
0 Likes
682

Check the below code.

DATA: v_flag TYPE i.

START-OF-SELECTION.

v_flag = v_flag + 1.

EXPORT v_flag TO MEMORY ID 'LV_KUM'.

IMPORT v_flag FROM MEMORY ID 'LV_KUM'.

write:/ v_flag.

clear v_flag.

EXPORT v_flag TO MEMORY ID 'LV_KUM'.

IMPORT v_flag FROM MEMORY ID 'LV_KUM'.

write:/ v_flag.

END-OF-SELECTION.

FREE MEMORY ID 'LV_KUM'.

Read only

Former Member
0 Likes
682

You will use EXPORT/IMPORT if you need to transfer data from one program to another within the SAME session (e.g. a report calls another report using SUBMIT... AND RETURN statement). In this case the export data are only store transiently.

Basically in your calling ABAP...

you can use the EXPORT.

EXPORT f1 TO MEMORY.

SUBMIT zrep1 and return.

ZREP1 report.

IMPORT f1 FROM MEMORY.

IMPORT ITAB TO ITAB FROM MEMORY ID 'MOVEMENTS'.

EXPORT ITAB1 TO ITAB1 TO MEMORY ID 'INITINV'.

check the sample code

Check the sample code:

data: ws_anlage_pod LIKE eanl-anlage,

wk_division LIKE eanl-sparte,

ws_anlage = '1212313'.

wk_division = '12'.

EXPORT ws_anlage_pod TO MEMORY ID 'anlage_pod'.

EXPORT wk_division TO MEMORY ID 'division'.

In the importing program declare the sample variable and import it.

data: ws_anlage_pod LIKE eanl-anlage,

wk_division LIKE eanl-sparte.

IMPORT ws_anlage_pod FROM MEMORY ID 'anlage_pod'.

IMPORT wk_division FROM MEMORY ID 'division'.

Message was edited by:

Runal Singh