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: 

Examples for SAP Memory and ABAP Memory

Former Member
0 Kudos

Hi all,

can u give me one example of sap memory and abap memory.

Ranjith

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

A simple example of ABAP memory is using the EXPORT/IMPORT statements. Here in this program, I get the data, export it to memory, clear out the internal table in my progam, then reimport the data into it and write out the data. You probably wounldn't do this in a normal program, but this is how you can pass data from program a to program b when A Submits program B.



report zrich_0002 .

data: it001 type table of t001 with header line.

select * into table it001 from t001.

export it001 = it001 to memory id 'ZRICH_TEST'.

clear it001. refresh it001.

import it001 = it001 from memory id 'ZRICH_TEST'.

loop at it001.
  write:/ it001-bukrs, it001-butxt.
endloop.

Regards,

Rich Heilman

15 REPLIES 15

Former Member

SAP Memory

SAP memory is a memory area to which all main sessions within a SAPgui have access. You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another. Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters). These parameters can be set either for a particular user or for a particular program using the SET PARAMETER statement. Other ABAP programs can then retrieve the set parameters using the GET PARAMETER statement. The most frequent use of SPA/GPA parameters is to fill input fields on screens

ABAP/4 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.

SAP memory

The SAP memory, otherwise known as the global memory, is available to a user during the entire duration of a terminal session. Its contents are retained across transaction boundaries as well as external and internal sessions. The SET PARAMETER and GET PARAMETER statements allow you to write to, or read from, the SAP memory.

ABAP/4 memory

The contents of the ABAP/4 memory are retained only during the lifetime of an external session (see also Organization of Modularization Units). You can retain or pass data across internal sessions. The EXPORT TO MEMORY and IMPORT FROM MEMORY statements allow you to write data to, or read data from, the ABAP memory.

Prakash.

0 Kudos

Hi Prakash,

I want exampes for SAP Memory and abap memory

Can you please send it

Ranjith

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

A quick example of using SAP memory is setting the paramater id before calling a transaction. In this case I am passing the sales document number and callin the va03 transaction.



report zrich_0002 .


set parameter id 'AUN' field '12345'.

call transaction 'VA03' and skip first screen.

Regards,

Rich Heilman

0 Kudos

HI Rich Heilman

Thanks for your answer, Can you even please send it to ABAP Memory

Ranjith

0 Kudos

For example:

EXPORT ws_anlage_pod TO MEMORY ID 'anlage_pod'.

IMPORT ws_anlage_pod FROM MEMORY ID 'anlage_pod'.

Regards,

Prakash.

0 Kudos

Hi,

I have one problem with similar case of use.

From standard transacction S_ALR_87013019 (is one report) I select order.  The target is list all open items of this order. To see them the starndard code selects KOB1 transacction and then calls with this source code.

CALL TRANSACTION ld_tcode AND SKIPT FIRST SCREEN.

But the sistem not filter for this order before selected. Select all orders then KOB1 is too slow o finish in dump.

In the same programa berfore of call I have the possibility to change the way to make call transacction. And I change in debug to the program do not skip first screen. I can see the selection screen in this case and de order came fill in the selection screen. But KOB1 do not filter for the order.

Is it necesary some authorization o user parameter to use memory in the system? I do not understand why one data filled in one selection screen is not used in one standard program.

Thanks and regards. David.

Former Member

Hi,

<b>SAP Memory</b>

SAP memory is a memory area to which all main sessions within a SAPgui have access. You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another. Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters). These parameters can be set either for a particular user or for a particular program at the time of logon using the SET PARAMETER statement. Other ABAP programs can then retrieve the set parameters using the GET PARAMETER statement. The most frequent use of SPA/GPA parameters is to fill input fields on screens .

<b>example:</b>

ABAP programs can access the parameters using the SET PARAMETER and GET PARAMETERstatements.

To fill one, use:

SET PARAMETER ID pid FIELD f

.

This statement saves the contents of field f under the ID pid in the SAP memory. The ID pid can be up to 20 characters long. If there was already a value stored under pid, this statement overwrites it. If you double-click pid in the ABAP Editor, parameters that do not exist can be created as a Repository object.

To read an SPA/GPA parameter, use:

GET PARAMETER ID pid FIELD f.

This statement places the value stored under the pid ID into the variable f. If the system does not find any value for pid in the SAP memory, sy-subrc is set to 4. Otherwise, it sets the value to 0.

<b>ABAP Memory</b>

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 memory area remains throughout a sequence of program calls, with the exception of LEAVE TO TRANSACTION. To pass data to a program that you are calling, the data needs to be placed in ABAP memory before the call is made from the internal calling session using the EXPORT statement. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory using the IMPORT statement. If control is then returned to the program that made the initial call, the same procedure operates in reverse.If a transaction is called using LEAVE TO TRANSACTION, the ABAP memory and the call stack are deleted. They cannot be used for data transfer.

Since objects belonging to ABAP objects can only be accessed within an internal session, it does not make sense and is therefore forbidden (from a syntax point of view) to pass a reference to an object to a calling program through the ABAP memory.

<b>Example:</b>

Export hello to memory id 'Hello_world'.
Import hello from memory id 'Hello_world'

.

Regards

Sudheer

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

A simple example of ABAP memory is using the EXPORT/IMPORT statements. Here in this program, I get the data, export it to memory, clear out the internal table in my progam, then reimport the data into it and write out the data. You probably wounldn't do this in a normal program, but this is how you can pass data from program a to program b when A Submits program B.



report zrich_0002 .

data: it001 type table of t001 with header line.

select * into table it001 from t001.

export it001 = it001 to memory id 'ZRICH_TEST'.

clear it001. refresh it001.

import it001 = it001 from memory id 'ZRICH_TEST'.

loop at it001.
  write:/ it001-bukrs, it001-butxt.
endloop.

Regards,

Rich Heilman

0 Kudos

Hi Rich Heilman

Thanks for your exampes

Ranjith

0 Kudos

You are quite welcome.

Regards,

Rich Heilman

0 Kudos

Hi

Can anybody pls let me know, where exactly SAP memory contents will be stored (Eg. RAM or in some SAP tables or in Application Server etc.). And also ABAP memory.

Thanks in advance.

Raghav

0 Kudos

I believe that both will be stored in memeory on the application server.

Regards,

Rich Heilman

0 Kudos

Hi,

Thank you very much for your quick reply.

Regards

Raghav

Former Member
0 Kudos

Hi,

DATA: v_export TYPE char1.

DATA: V_VBELN(10).

v_export = 'A'.

EXPORT v_export TO MEMORY ID 'EXPORT'.

IMPORT v_export FROM MEMORY ID 'EXPORT'.

WRITE: / V_EXPORT.

SET PARAMETER ID 'AUN' FIELD '1234567890'.

GET PARAMETER ID 'AUN' FIELD V_VBELN.

WRITE: / V_VBELN.

Thanks,

Naren

0 Kudos

I want to clear the value in my global memory. How will I do that.

Set parameter id 'ZBUD' field lguid.

Before setting this I want to clear the value of zbud in global memory. What is the syntax for this.