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

abap memory question

Former Member
0 Likes
1,269

hi,guys,i did a example to test the difference between sap memory and abap memory,the result that i did program zmemory1 is : 1111 2223,

but the question is when i did program zmemory2 alone,the result is the same,why i can get test2 with

import statement in different session,below is my code,

thxs in advance!

REPORT zmemory1.

DATA : test1(10) TYPE c,

test2(10) TYPE c.

test1 = '1111'.

test2 = '2223'.

FREE MEMORY ID 'TEST2'.

SET PARAMETER ID 'TEST1' FIELD test1.

EXPORT test2 TO MEMORY ID 'TEST2'.

CALL TRANSACTION 'ZMEMORY2'.

-


REPORT zmemory2.

DATA: test1(10) TYPE c,

test2(10) TYPE c.

GET PARAMETER ID 'TEST1' FIELD test1 .

IMPORT test2 FROM MEMORY ID 'TEST2'.

WRITE:/ test1,test2.

11 REPLIES 11
Read only

Former Member
0 Likes
1,214

what i understood is although i am running zmemory2 report individually also the data is getting from memory

use

FREE MEMORY ID 'TEST2'.

in zmemory 2 as well before using import statement .....

Regards

Sas

Read only

0 Likes
1,214

what u did say is no difference between sap and abap memory,cos both statement i can get the value of memory i sent?

regards

kevin

Read only

0 Likes
1,214

Hi Kelvin,

SAP MEMORY --> It will stay until the application data is there

ABAP memory -->( set import) will stay until u open u r sessions only

Regards

Sas

i am sorry ur words are hard to understand , what i understood i am giving the answer

Read only

Former Member
0 Likes
1,214

Hi Kelvin,

if u use SET/GET parameters it uses SAP memory.

if u use IMPORT/EXPORT paramers, it uses ABAP Memory.

HOpe u understand it.

With Best Regards,

Flavya.

Read only

0 Likes
1,214

i know that,but in book,they say:abap memory is only available in one session,so i did zmemory1,and in it i called zmemory2,i could get test2 cos they were in the same session,but i did zmemory2 alone is absolutly in other new session to the fiist time i ran zmemory1,they are different session,have no idea!

regards

kevin

Read only

0 Likes
1,214

Hello Kevin,

Values stored in ABAP Memory is available in the same session means say you are executing a program so the instance of the program will be running in say session A, at the same time you run a different program which will now be running in a different session say session B. So, session A and session B are different session and you cannot access objects between this two session by using the ABAP memory.

You can only access values between Program A and Program B then submit the program B in program A, so these two programs will be in the same session and can share values/data between.

As soon as the session ends the memory is cleared by Garbage Collector.

Thanks,

Jayant

Read only

0 Likes
1,214

For testing do like this:

- log of all your SAP sessions and log in once again

- First run your Z_MEMORY2 report and see the result (none none)

- then run your Z_MEMORY1 report and see the result (1111 2223)

- then in the same window session switch to Z_MEMORY2 program and execute it. The result is (1111 2223)

- then open new window session and run Z_MEMORY2 once again. The result is (1111 none)

Your understanding of SAP and ABAP memory is good, you just probably tried to run Z_MEMORY2 in same window, which is the same session.

Regards

Marcin

Read only

0 Likes
1,214

hey,jayant,

when the program A end,the session A should be ended automatically,so the parameter i send in program A should be cleared in abap memory,in my case ,but i execute other program getting the paramter in abap memory,the value of this parameter is still here,i counldnt understand!

regars

kevin

Read only

0 Likes
1,214

thxs,Marin,u really did a great help!

i thought once i end the grogram ,the session should be end aslo like i did in other languages~~~

thxs again!!!

Read only

0 Likes
1,214

Hello Kevin,

You can retest the whole thing again.

Execute your program ZMEMORY_1 in which you have chosen EXPORT TO MEMORY-ID -> This will store the value you want to, to a memory space created by name as specified by you.

Execute your Program ZMEMORY_2 in which you have chosen IMPORT FROM MEMORY-ID -> This will get the value you have stored in the memory ID.

In the case you execute the program separately you will not be able to get the value you have stored in memory.

In case you have executed/submitted the program ZMEMORY_2 in program ZMEMORY_1 you will be able to get the values stored in the memory ID.

Please note that Garbage Collector collects/clears the memory as soon as session is ended. May be in some case it would not have been triggred before the execution of the program, I am taking a case on my assumption but generally it does not happens and Garbage Collector does it job well :-).

Hope this helps.

Thanks,

Jayant

Read only

0 Likes
1,214

thxs,jayant,marcin have told me the reason,there are a so-called 'window session' here which caused my problem.

regards guys