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

How could i create Unique memory id.

former_member196331
Active Contributor
0 Likes
4,249

hi,
I have one problem.there is one user exit is there, this will trigger, once posting Goods receipt, Which are posted for Production order, this will trigger.
This exit should validate some data, but that goods receipt data details ,exit is not showing. So, i was used export and import method.
First
Goods receipt

Now Enhancement point will trigger, here i have goods receipt details
then now i create a custom structure and exporting to memory id like.

Export curr_tab to memory id 'CAB'.

then custom exit will trigger.
here i am importing the data.
Import curr_tab to curr_tb from memory id 'CAB'.

But here i have some question.if the two users are doing the goods receipt same time
may i know what will happens.
i mean, both users are using memory id 'cab', what will happens, they might be post different order no and diff material and qty.

Is both are collid each other.Could any body tell me what will happens, now.

I was thought wrong, so, i used. memory id as sy-uname, User id will be unique.
If you are in the same situation ,What will you do. Need valuable suggestions.

hi,
I have one problem.there is one user exit is there, this will trigger, once posting Goods receipt, Which are posted for Production order, this will trigger.
This exit should validate some data, but that goods receipt data details ,exit is not showing. So, i was used export and import method.
First
Goods receipt

Now Enhancement point will trigger, here i have goods receipt details
then now i create a custom structure and exporting to memory id like.

Export curr_tab to memory id 'CAB'.

then custom exit will trigger.
here i am importing the data.
Import curr_tab to curr_tb from memory id 'CAB'.

But here i have some question.if the two users are doing the goods receipt same time
may i know what will happens.
i mean, both users are using memory id 'cab', what will happens, they might be post different order no and diff material and qty.

Is both are collid each other.Could any body tell me what will happens, now.

I was thought wrong, so, i used. memory id as sy-uname, User id will be unique.
If you are in the same situation ,What will you do. Need valuable suggestions.

3 REPLIES 3
Read only

SimoneMilesi
Active Contributor
2,868

Enjoy the reading about Memory usage and segregation (cannot insert as link 😕 )

https://wiki.scn.sap.com/wiki/display/Community/ABAP+MEMORY+AND+SAP+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.
Read only

Former Member
0 Likes
2,868

Hello.

You can try create a dynamic id for memory, like using the sy-uname or any variavel point.

But like Milesi said the export and import should be at the same session or program. Else you need use the export to memory database.

By example:

data: lv_name2 TYPE sy-uname,
      l_export TYPE c length 50.
" CREATE THE ID FOR MEMORY
DATA(lv_name) = cl_abap_syst=>get_user_name( ).
CONCATENATE lv_name
            sy-datum
       INTO l_export.
" EXPORT TO MEMORY
EXPORT lv_name TO MEMORY ID l_export.
" RECOVERY VALUE FROM MEMORY
IMPORT lv_name TO lv_name2 FROM MEMORY ID l_export.
Read only

Sergiu
Contributor
0 Likes
2,868

Tracking external session number in submitted internal session with the code below.

The statement from the link is not true for external sessions as mentioned by simone.milesi.

https://belajarabap.wordpress.com/2013/07/26/a-unique-name-of-memory-id/

The use of memory id must be extra careful. Remember that it is possible for one user to open several sessions which may run the same program/tcode. If in the program there is an export-import memory id, how can the program determine that the data in the memory id of session 1 will not be confused with session 2 even though the name of the memory id is the same!
So, naming memory id must be specific. To avoid the above case, you can use the following syntax:

REPORT ZREP1.
*EXPORTING MEMORY ID
  DATA: 
        LD_MEMORY_EXP(40),
*        LD_MEMORY_IMP(40),
        LD_TCODE LIKE SY-TCODE,
        LD_MODNO TYPE C LENGTH 5.

  CLEAR LD_MODNO.
  MOVE SY-MODNO TO LD_MODNO.
  CONCATENATE 'PUTYOURUNIQUETEXTHERE' SY-UNAME LD_TCODE LD_MODNO INTO LD_MEMORY_EXP.
  FREE MEMORY ID 'Z_ID_UPD'.
  EXPORT LD_MEMORY FROM LD_MEMORY_EXP TO MEMORY ID 'Z_ID_UPD'.
  WRITE: / LD_MEMORY_EXP.
  SUBMIT ZREP2

REPORT ZREP2.
  DATA:
*        LD_MEMORY_EXP(40),
        LD_MEMORY_IMP(40),
        LD_TCODE LIKE SY-TCODE,
        LD_MODNO TYPE C LENGTH 5.

*IMPORTING MEMORY ID
  CLEAR LD_MODNO.
  MOVE SY-MODNO TO LD_MODNO.
  CONCATENATE 'PUTYOURUNIQUETEXTHERE' SY-UNAME LD_TCODE LD_MODNO INTO LD_MEMORY.
  IMPORT LD_MEMORY TO LD_MEMORY_IMP FROM MEMORY ID 'Z_ID_UPD'.
  WRITE: / LD_MEMORY_IMP.