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

Import / Export TO/FROM SHARED MEMORY only works during debug

Former Member
0 Likes
11,248

Hi Experts,

My code works fine during debug but when ran without breakpoints (not in debug), it's not working. Here's my code:

   IMPORT ws_c_var FROM SHARED MEMORY indx(xy) ID  ws_c_var.

   EXPORT ws_c_var TO SHARED MEMORY indx(xy) ID  ws_c_var.

I'm not really sure why it's working when being debugged but not in foreground. Please help.

Thanks

Vanessa

15 REPLIES 15
Read only

Former Member
0 Likes
5,405

hello,

Are you running the program as abckground job then the IMPORT/EXPORT to meory would not work.

See below threads for the same -

http://scn.sap.com/message/7656176

http://help.sap.com/saphelp_45b/helpdata/en/34/8e73a36df74873e10000009b38f9b8/content.htm

http://scn.sap.com/thread/1311374

best regards,

swanand

Read only

former_member491621
Contributor
0 Likes
5,405

Hi Vanessa,

You can try using the statements as below

   IMPORT ws_c_var FROM SHARED MEMORY indx(xy) ID  'VAR1'.

   EXPORT ws_c_var TO SHARED MEMORY indx(xy) ID  'VAR1'.

If it does not work, can you please tell me what is the content of ws_c_var(the value you are using as MEMORY ID)?

Also, you can check the below links for reference

http://help.sap.com/saphelp_45b/helpdata/en/34/8e73aa6df74873e10000009b38f9b8/content.htm

http://help.sap.com/saphelp_45b/helpdata/en/34/8e73a36df74873e10000009b38f9b8/content.htm

Read only

Former Member
0 Likes
5,405

Hi Vanessa,

use:

export ws_c_var to shared buffer indx(st) id
ws_c_var .

import ws_c_var from shared buffer indx(st) id ws_c_var.

Hope it will work.....

Thanks

Sabyasachi

Read only

0 Likes
5,405

Hi All,

Thank you so much for your replies.

I'm using it in a function module. I'm not running it in background. I'm running it in foreground.

This is how I do it, I open two windows of SE37 and ran my FM simultaneously. During debug I can see that whatever my first FM places on the MEMORY, the second FM retrieves.

But in foreground its not happening.

I already tried the SHARED BUFFER as well, its not working too.

The memory ID name I'm using is the handling unit number.

Looking forward for more help.

Thanks,

Vanessa

Read only

0 Likes
5,405

Instead of simultaneous, try one after another.

Read only

0 Likes
5,405

Hi Vanessa ,

I too faced a similar issue once.

Actually data transfer was not happening using memory id technique in one of my report.

But when I executed that report once using debugger then for later executions it started working perfectly al right.

Though I didn't bother about that after , hope your thread will help me find answer .

Read only

0 Likes
5,405

Hi Vanessa,

You are passing the unit number to MEMORY ID 'unit number'.

Why don't you try hardcoding the MEMORY ID 'unit number' to some text value like 'TEST'??

Read only

0 Likes
5,405

Hi Vanessa,

Please read the below comments. They might help you

Alternative 3

... MEMORY ID id


Effect

If MEMORY is specified, the data cluster is written in to ABAP Memory with the ID specified in id. id expects a flat character-like data object containing a case-sensitive ID with a maximum of 60 characters. Any existing data clusters with the same ID id are completely overwritten. The ID in id identifies a data cluster in the repository and can be read again using the same identification.

Read only

0 Likes
5,405

Hi Vanessa,

Instead of using Export & Import why dont you declare the variable in the function group top inculde which will be available for both the function modules?.Or you can create a function module with a function group to store the value and call in both the FM's

With regards,

Read only

0 Likes
5,405

Hi Kesavadas,

I also tried that. I gave the first FM a 5 second interval before running the second FM. Still not working.

Hi Sijin,

Me too, I hope I could find the answer for this query.

Hi Aniket,

I need a memory id that is based on the handling unit number, since this will be my checking if the the HU being modified by the 2 running FM is the same. If its the same, the first FM should be able to process it successfully. After 5 seconds, the second FM should get a lock error. The first and second FMs were just the same FM. They were just launched twice.

Vanessa

Read only

0 Likes
5,405

Hi Naveen,

Apologies as I was not able to clearly explain. The FM i was talking about were launched twice and were just modifying the same record. I'm expecting the first FM to save the HU number to the SHARED MEMORY, so that after 5seconds the second FM will retrieve the HU from the shared memory and will not proceed with processing, since the shared memory is already filled up.

This happens when being debugged, but without debug, it's not working.

Thanks!

Vanessa

Read only

0 Likes
5,405

Hi

Try using SET PARAMETER ID and GET PARAMETER ID instead of EXPORT & IMPORT statements. sometimes it works.

br...

Dwaraka

Read only

0 Likes
5,405

I don't really understand the problem in changing the MEMORY ID. It is just the identification/pointer to some place/space in the shared memory which is carrying the data you require.

For checking if the same HU is modified or not, you can always use the data in the memory id.

I hope i'm on the right track

Read only

0 Likes
5,405

Hi Aniket,

I also don't understand why its not working in foreground.

Hi Dwaraka,

I also tried SET and GET, but its also not working.

Thanks!

Vanessa

Read only

0 Likes
5,405

Hi Venessa,

Create a function module with a function group.Declare a global variable at the top include which you need to share .In the FM both import and export parameter would be the same variable which is required to be shared and use the below code in the source code of FM.

if i_var is not initial." import parameter in FM

g_var = i_var. "assign import to global variable

else.

e_var = g_var. "assign global variable to export parameter.

endif.

Both the parameters are optional in the FM.Call the FM in your first function module by passing value to the import parrameter of the FM.In the second FM call the same FM but with only export parameter.In this way the variable can be stored in a memory and passed to another program in the runtime.

With regards,