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: 

sap Memory variable

Former Member
0 Kudos

Hi

any body tell me how to declare one memory variable and transfer the value from one session to another session

using set and get parameters

1 ACCEPTED SOLUTION

anversha_s
Active Contributor
0 Kudos

hi srinivas.

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 zxy_0002 .

data: it001 type table of t001 with header line.

select * into table it001 from t001.

export it001 = it001 to memory id 'ZXY_TEST'.

clear it001. refresh it001.

import it001 = it001 from memory id 'ZXY_TEST'.

loop at it001.

write:/ it001-bukrs, it001-butxt.

endloop.

regrds

anver.

if hlped mark points

4 REPLIES 4

Former Member
0 Kudos

yeah.

GET PARAMETER

Basic form 3

GET PARAMETER ID pid FIELD f.

In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See ABAP Unicode - Other Changes

Effect

First, the value stored under the key pid is transferred from the local SAP memory into the field f. If this key is not available in the local SAP memory, the value stored under the same key pid is transferred from the global user-related SAP memory to the field f.

A parameter ID can have up to 20 characters. You can find an overview of the keys (parameters) used in the SAP system description or the appropriate function in the ABAP Workbench.

The Return Code is set as follows:

SY-SUBRC = 0: A value was read from SAP memory. SY-SUBRC = 4: No value was found in SAP memory under the specified key.

Notes

The global user-related SAP memory is available to each user for the entire duration of a terminal session. For this reason, set values are retained when you leave a program.

You should not use SAP memory for temporary storage because a user's parallel sessions use the same global memory.

Example

Read the program name from SAP memory:

DATA : REPID LIKE SY-REPID.

GET PARAMETER ID 'RID' FIELD REPID.

Related

SET PARAMETER

Fill Initial Screens with SPA/GPA Parameters

Regards

Prabhu

anversha_s
Active Contributor
0 Kudos

hi srinivas.

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 zxy_0002 .

data: it001 type table of t001 with header line.

select * into table it001 from t001.

export it001 = it001 to memory id 'ZXY_TEST'.

clear it001. refresh it001.

import it001 = it001 from memory id 'ZXY_TEST'.

loop at it001.

write:/ it001-bukrs, it001-butxt.

endloop.

regrds

anver.

if hlped mark points

Former Member
0 Kudos

Hi Srinivas,

Following is some code for SET PARAMETER:

SELECT single VKORG

FROM VBAK

INTO l_vkorg where vbeln = s_vbeln.

SET PARAMETER ID 'G_VKORG' FIELD l_vbeln.

This statement will declare a variable called "G_VKORG" having value l_vbeln and it can be retrieved from another session using GET PARAMETER.

GET PARAMETER ID 'G_VKORG' FIELD l_vbeln1.

IF sy-subrc <> 0.

MESSAGE 'Parameter not found' TYPE 'I'.

ENDIF.

0 Kudos

Hi

Incase you need to create a new custom parameter-id you can do that using FM: RS_PARAMETER_ADD.

After creating the parameter-id we can use that while defining data elements or directly in programs.

Kind Regards

Eswar