Application Development 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: 

use of memory

Former Member
0 Kudos

Hi,

whats the use/benefits of exporting and importing from memory...

any simple scenarios and codes to illustrate?

Thanks,

Charles

abap newbie

1 ACCEPTED SOLUTION

Former Member
0 Kudos

ABAP Memory

ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence of program calls. To pass data to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is then returned to the program which made the initial call, the same process operates in reverse.

Regards,

Ruthra

11 REPLIES 11

Former Member
0 Kudos

Hi Charles,

I believe SAP documentations are best explained.

Keep cursor on Key ..<b>EXPORT or IMPORT</b>...in Se38.

Do <b>F1</b> on.. Read details from SAP documentation.

Will learn more about the Options and limitations.

Hope This helps in future.

Manish

Former Member
0 Kudos
To transfer the data from one program to other program we use IMPORT and EXPORT memory ids

TYPES: BEGIN OF OBJ_LINE, 
        CLUSTERNAME(30), 
        PROGRAMNAME(10), 
      END OF OBJ_LINE, 
      BEGIN OF B_LINE, 
        FIELD_1    TYPE I, 
        FIELD_2(1) TYPE N, 
      END OF B_LINE. 

DATA: OBJ_TAB TYPE STANDARD TABLE OF OBJ_LINE, 
      OBJ_WA  TYPE OBJ_LINE, 
      B_PROG  TYPE STANDARD TABLE OF B_LINE, 
      B_WA    TYPE B_LINE, 
      A(10), 
      C_PROG LIKE SYST. 

MOVE:  'A'    TO OBJ_WA-CLUSTERNAME. 
APPEND OBJ_WA TO OBJ_TAB. CLEAR OBJ_WA. 

MOVE:  'B'      TO OBJ_WA-CLUSTERNAME, 
       'B_PROG' TO OBJ_WA-PROGRAMNAME. 
APPEND OBJ_WA TO OBJ_TAB. CLEAR OBJ_WA. 

MOVE:  'C'      TO OBJ_WA-CLUSTERNAME, 
       'C_PROG' TO OBJ_WA-PROGRAMNAME. 
APPEND OBJ_WA TO OBJ_TAB. CLEAR OBJ_WA. 

IMPORT (OBJ_TAB) FROM MEMORY ID 'ABCD'.

Former Member
0 Kudos

Press F1 after writing export/import in code and read help..

these statements r basically for Abap memory..and the scope of the value wil be till session ends , u can not use the value in other sessions as in SET/GET (SAP MEmory)

amit

Former Member
0 Kudos

Hi Charles

<b>Example:</b>

Consider a scenario whereby we are executing two programs and we need some values from the first program to be used in the second one. In this case, we will EXPORT the values of first program to memory and IMPORT in the second program to use it further.

Note:

<b>We need to make sure that the variable or internal table we refer to be declared with the same name, type and length in both programs.</b>

Eg:

REPORT ZPROG1.

data: var type i value 8.

...

EXPORT var TO MEMORY-ID 'MID'.

REPORT ZPROG2.

data: var type i.

....

IMPORT var FROM MEMORY-ID 'MID'.

<---- Here will have value 8 in variable var from program 1.

Hope the above info helps you in some understanding...

Kind Regards

Eswar

Former Member
0 Kudos

ABAP Memory

ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence of program calls. To pass data to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is then returned to the program which made the initial call, the same process operates in reverse.

Regards,

Ruthra

Former Member
0 Kudos

Hi

We would need to use the exporting and importing from memory commands wherein we are not able to access the values in the variable using the normal program flow.. especially like user exits and such...

check out the sap standard program <b>DEMO_DATA_EXT_CLUSTER_IMPORT</b> to get more ideas on how it can be used .

Former Member
0 Kudos

Hi Charles,

There are different ways of passing on data to a program when it is called:

*Through the interface of the called program (interface of a subroutine, function module, or dialog modules, standard selection screen of a report)

*Through the ABAP memory

*Through the SAP memory

*Through database tables

*Through files on your presentation server or application server

1)For more information about transferring data using database tables and the shared buffer, refer to the keyword documentation in the ABAP Editor for EXPORT and IMPORT.

2)For more information about transferring data between an ABAP program and your presentation server, refer to the documentation for the function modules GUI_UPLOAD and GUI_DOWNLOAD.

3)For more information about transferring data between an ABAP program and your application server, refer to the keyword documentation in the ABAP Editor for TRANSFER and READ DATASET.

<b>Data Transfer through the Call Interface</b>

Function modules have an interface for passing data between the calling program and the function module itself (there is also a comparable mechanism for ABAP subroutines).If you are calling an ABAP program that has a standard selection screen, you can pass values to the input fields on the selection screen.. There are two options here:

*You can enter a variant for the call (SUBMIT addition, USING SELECTION-SET).

*You can enter actual values for the input fields on the selection screen during the call.

The SUBMIT addition VIA SELECTION-SCREEN is used to start the called program by displaying its selection screen. If this addition is not specified, the system executes the program without processing its selection screen. In this case, you can still pass values for the input fields of its selection screen to the program (WITH addition; for syntax, see above).

If you use the pattern key in the ABAP Editor to insert a program call using SUBMIT, the system will list – in the inserted command – all the selection screen elements of the program to be called using the WITH addition.

For more information on the WITH addition, see the ABAP Editor keyword documentation for SUBMIT WITH.

<b>Data transfer thorugh ABAP Memory</b>

Using the EXPORT TO MEMORY ID <id> statement, you can copy variables of your program with their current values as data clusters into the ABAP memory. The ID you specify here uniquely identifies the created data cluster (maximum 32 characters).

An export to the same memory ID will overwrite the corresponding data cluster.

Using the IMPORT FROM MEMORY ID <id> statement, you can read data from the specified data cluster into the fields of your ABAP program.

The source and target variables must have the same format in the write and read programs.

The FREE MEMORY ID <id> statement deletes the respective data cluster.

The FREE MEMORY statement without the ID addition deletes the entire ABAP memory of the current external session.

You can use the IMPORT command to read only a few of the variables in the data cluster.

<b>Data through SAP memory</b>

Using the Object Navigator, you can define parameter IDs for the SAP R/3 system (through entries in table TPARA). The ID parameter may not be longer than 20 characters maximum.

Using the SET PARAMETER ID statement, ABAP programs can set a value in the SAP memory of the current session for the specified parameter. This value can be read by all programs of the same session using the GET PARAMETER ID statement.

A parameter in the SAP memory can also be set by a user entry in a screen field. For this purpose, the screen field must be defined through a data element that is linked with the respective parameter ID. In addition, the SET functions must be activated in the screen field properties.

Conversely, a screen input field can display the corresponding parameter value in the SAP memory to the user as an input proposal. The following prerequisites must be fulfilled:

- The screen input field has been defined through a data element that is linked to the corresponding parameter ID.

- The GET functions of the screen field are activated.

- The program supplies the screen field only with the initial value.

In this way, programs and screens can exchange data through the SAP memory during the same session.

For information on the parameter ID linked to an input field, on the input screen point to the field and choose F1 help ->Technical Info

Regards,

Balaji reddy G

***Rewards if answers are helpful

Former Member
0 Kudos

so meaning.. in the case of user exit... we need to find out the memory id from the program that exports... before we can import the value?

Thanks,

Charles

0 Kudos

Yes Charles, you are right to identify.

We need to know the specific MEMORY ID's and the variables and their declarations before we can use them.

Depending on the executions and their sessions, we have various options for EXPORITNG and IMPORTING.

Eg:

Like, to memory which will be useful if executed linearly in the same session & Database Index which will be helpful across the sessions.

Hope this helps.

Kind Regards

Eswar

Former Member
0 Kudos

I'm actually in a user exit (a class) and i find it hard to locate = where it exports and the memory id...

are there gd methods to locate them? especially in messy programs, functions and exits?

Former Member
0 Kudos

I'm actually in a user exit (a class) and i find it hard to locate = where it exports and the memory id...

are there gd methods to locate them? especially in messy programs, functions and exits?