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

Problem in ABAP memory

Former Member
0 Likes
634

Hi Experts,

This is problem about ABAP memory.

I have two programs. Program-A & Program-B

Program-A sets value to variable and EXPORT command is used to set this variable in memory.

EXPORT variable TO DATABASE indx(st) ID 'KEYVALUE'.

Program-B gets variable using IMPORT command from memory.

IMPORT variable FROM DATABASE indx(st) ID 'KEYVALUE'.

User runs Program-A in SE38. Program-A calls Program-B using a button click event (SUBMIT).

The scenario is..

User1 executes the Program-A,

which set the variable = User1 in memory.

User2 executes the Program-A,

which set the variable = User2 in memory.

User2 clicks button to call Program-B,

which imports variable = User2 from memory.

User1 clicks button to call Program-B,

which imports variable = User2 from memory.

(But User1 expects the variable = User1).

So User1 gets wrong variable value set by another User.

How to handle this situation?. How to set memory variables user specific? I will appriciate all helpful answers.

Thanks in advance

Hari.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
590

The problem can easily be resolved by qualifying the key....in Program A

lKey = Sy-uname.

EXPORT variable TO DATABASE indx(st) ID lKEY.

And in Program B.

lkey = Sy-Uname.

IMPORT variable FROM Database indx(st) ID Lkey.

Regards

Anurag

5 REPLIES 5
Read only

Former Member
0 Likes
590

Hi

One way is, to have the <b>Userid</b> as the memoryID for both Export and Import statements.

Regards,

Raj

Read only

0 Likes
590

Instead of exporting a variable you can export an internal table to memory. So everytime you export do an import and check if there is an internal table in the memory, if there is then append the record. To identify who created create a field in the internal table with the user-name, so that you know who created the memory reference.

hith

Sunil Achyut

Read only

suresh_datti
Active Contributor
0 Likes
590

Instead of exporting to DATABASE use

EXPORT to MEMORY

~Suresh

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
590

What you are using is global memory, if you don't want other sessions to see it, then you have to use a memeory id instead. This will work when submittin program b using the SUBMIT statement.

export variable to memory id 'ZRICHTEST'.

import variable from memory id 'ZRICHTEST'.

Or you can simply make your KEYVALUE unique by giving the USERID as part of it.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
591

The problem can easily be resolved by qualifying the key....in Program A

lKey = Sy-uname.

EXPORT variable TO DATABASE indx(st) ID lKEY.

And in Program B.

lkey = Sy-Uname.

IMPORT variable FROM Database indx(st) ID Lkey.

Regards

Anurag