0% found this document useful (0 votes)
71 views2 pages

Passing Data From One ABAP Program To Another

This document discusses how to pass data between ABAP programs using EXPORT and IMPORT statements. It provides an example of exporting a field D_MEMORY to memory using EXPORT, then importing it back into the same field using IMPORT. The memory is freed using FREE MEMORY. It also shows how to export from one program to memory, then import from memory into another program to pass data between programs.

Uploaded by

arda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views2 pages

Passing Data From One ABAP Program To Another

This document discusses how to pass data between ABAP programs using EXPORT and IMPORT statements. It provides an example of exporting a field D_MEMORY to memory using EXPORT, then importing it back into the same field using IMPORT. The memory is freed using FREE MEMORY. It also shows how to export from one program to memory, then import from memory into another program to pass data between programs.

Uploaded by

arda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Many a times it is required to pass data from one ABAP program to another.

This can
be done using the EXPORT and IMPORT statement in ABAP. Please find the examples
given below.

REPORT ZEX_MEMORY .

Data: D_MEMORY(20) value 'BEFORE EXPORT',


MEMID(5) value 'MEMID'.

write:/ D_MEMORY.

EXPORT D_MEMORY to MEMORY ID MEMID.

D_MEMORY = 'MOVED BEFORE IMPORT'.

write:/ '"Value before import"', D_MEMORY.

EXPORT D_MEMORY to MEMORY ID MEMID.

write:/ sy-subrc, ' "Value after import"', D_MEMORY.

FREE MEMORY ID MEMID.

IMPORT D_MEMORY from MEMORY ID MEMID.

write:/ sy-subrc, ' "Value after freeing memory"', D_MEMORY.

As you can see from the above example the field D_MEMORY can be exported to memory
and then imported back. Once you are done with importing the value you need to FREE
the memory ID. Please make sure that you free only the MEMORY ID exported by you.

Here we are using the syntax given below.

EXPORT filed1 to MEMORY ID MEMID.


IMPORT filed1 from MEMORY ID MEMID.
FREE MEMORY ID MEMID.

You can also export field contents to memory from one program and import them in
another program. Please see the code given below.

PROGRAM1 Passing Values from one program to other in SAP ABAP


REPORT ZEX_MEMORYEXPORT .

Data: D_MEMORY1(100) value 'Exportfromprog1'.

EXPORT D_MEMORY1
D_MEMORY2 FROM 'EXPORTING THIS FROM PROGRAM1'
TO MEMORY ID 'MEMID1'.

SUBMIT ZEX_MEMORY1 and RETURN.

write:/ sy-subrc, D_MEMORY1.


The above program will call the following program, since the value 'EXPORTING THIS
FROM PROGRAM1' has already been exported to ABAP Memory it can be retrieved as
shown in the program given below.

PROGRAM 2 Passing Values from one program to other in SAP ABAP

REPORT ZEX_MEMORY1 .

Data: D_MEMORY1(100).

EXPORT D_MEMORY1 TO MEMORY ID 'MEMID1'.

IMPORT D_MEMORY2 TO D_MEMORY1 FROM MEMORY ID 'MEMID1'.

WRITE: / SY-SUBRC, D_MEMORY1.

As shown in program 1 and 2 the value 'EXPORTING THIS FROM PROGRAM1' is passed from
ABAP memory from one program to the other.

You might also like