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 and Export to Memory

Former Member
0 Likes
4,267

hi guys, im currently making a program that imports and exports data into a memory so that when the user logs out that would still remain in the memory. The data would be use for the slection screen but i can't seem to make it work. Could you please help me. Or if you have other ideas on how to store data that would also be ok. The thing is when Im running the program through se38 its working fine but if i run it through its transaction code the import does not work. Please help.

here is my code:


DATA: begin of i_memory, 
             memory_id(31), 
           end of i_memory. 



initialization. 
 IF p_prem IS INITIAL. 
     CONCATENATE c_memory_id sy-uname into v_memory_id 
                 SEPARATED BY c_underscore. 
     IMPORT i_memory FROM MEMORY ID v_memory_id. 
     IF sy-subrc = 0. 
        p_prem = i_memory-memory_id. 
     ELSE. 
        p_prem = '0.04'. 
     Endif. 
  ENDIF. 



at selection-screen. 
  i_memory-memory_id = v_memory_obj. 
  CONCATENATE c_memory_id sy-uname into v_memory_id 
              SEPARATED BY c_underscore. 

  EXPORT i_memory to MEMORY ID v_memory_id. 
  IF sy-subrc = 0. 
  Endif.

Please help. Thanks in advance guys.

1 ACCEPTED SOLUTION
Read only

Former Member
3,075

Hello,

Use 'FREE MEMORY ID' to free the memory when you do not want ABAP to hold the data in memory anymore.

http://help.sap.com/saphelp_erp2004/helpdata/en/fc/eb3beb358411d1829f0000e829fbfe/content.htm

Regards, Murugesh AS

12 REPLIES 12
Read only

Former Member
3,076

Hello,

Use 'FREE MEMORY ID' to free the memory when you do not want ABAP to hold the data in memory anymore.

http://help.sap.com/saphelp_erp2004/helpdata/en/fc/eb3beb358411d1829f0000e829fbfe/content.htm

Regards, Murugesh AS

Read only

Former Member
0 Likes
3,075

Actually i don't need to free the memory. I need to retrieve data from the memory but its not working. Please help.

Read only

andreas_mann3
Active Contributor
0 Likes
3,075

Hi,

try it with <a href="http://help.sap.com/saphelp_47x200/helpdata/en/9f/dba6eb35c111d1829f0000e829fbfe/frameset.htm">SPA/GPA</a>

Andreas

Read only

Former Member
0 Likes
3,075

Hi,

C the following code to free memory,

FREE MEMORY ID <gv_memratio>.

Regs,

Venkat

Read only

manuel_bassani
Contributor
0 Likes
3,075

Hi Ferdinand,

i tried to write a sample prog. with your code ...

what does variable v_memory_obj contain ?

It seems it is always blank, maybe some code lines are missing...

regards, Manuel

Read only

0 Likes
3,075

hi manuel,

the variable contains the input of the user from the selection screen. if i put in let's say '1' then that would be its value. Ü

Read only

Former Member
0 Likes
3,075

Hello,

Declare the following data.

data : i_selection_table like rsparams occurs 0,

v_rsvar like rsvar-report.

Call this function module

call function 'RS_REFRESH_FROM_SELECTOPTIONS'

exporting

curr_report = v_rsvar

  • IMPORTING

  • SP =

tables

selection_table = i_selection_table

exceptions

not_found = 1

no_report = 2

others = 3

Now i_selection_table will contain the user input parameters now use the export and import to save this table and download it from memory

Variant 5

EXPORT (itab) TO ... .

Effect

Specifies the objects you want to export in the internal table itab. You can use this dynamic variant instead of the static one in any of variants 1 to 4. All additions that you can use with the static form are also allowed with the dynamic form. The table itab must not have the type HASHED TABLE or ANY TABLE.

Note

Structure of the internal table itab:

The first column of the table contains the object names in the data cluster (corresponds to the static obj1, ..., objn). The second column contains the different name in the program (if necessary), which corresponds to the field f in the = f or FROM f addition. If the table only has one column, or the second column contains only spaces, this corresponds to a static EXPORT without a = or FROM addition. The first and second columns of the internal table should have the type character.

Regards,

Shekhar Kulkarni

Read only

0 Likes
3,075

hi,

i was just wondering if its still going to work if i log off. because when i tried logging off the data from the memory was erased..

Read only

0 Likes
3,075

Try to Use the concept of Saving Data Objects in Cluster Databases .

Use the following syntax

EXPORT <f1> [FROM <g 1>] <f 2> [FROM <g 2>] ...

TO DATABASE <dbtab>(<ar>) [CLIENT <cli>] ID <key>.

Use Table INDX for this purpose .

Hope this will be useful .

Thanks & Regards,

Raj

Read only

0 Likes
3,075

You should try to use IMPORT/EXPORT TO DATABASE instead of IMPORT/EXPORT FROM MEMORY...

import/export from memory is often used to pass data from a program to another (for example: before and after a submit statement). ABAP memory is deleted after logoff.

Using a cluster table (like table INDX) allows to import/export data also after user logoff (store information in a table)

I hope this will help,

regards, Manuel

Read only

Juwin
Active Contributor
0 Likes
3,075

Hi,

As "Ferdinand Catabian" rightly pointed out, if you just export to the memory, then it will be automatically erased, when you log off from the system.

Since you want the data not to be erased, like that, EXPORT/ IMPORT using DATABASE (i.e., using a cluster table). In this case, even if the user logs off, your data will reside in the database, and the next time user logs on, you will be able to retrieve the data.

~Juwin.

Read only

0 Likes
3,075

Shekhar Kulkarni

I need help understanding your code.

Im trying to do same thing as you described in the post.

My main purpose is to IMPORT variant contents from cluster table VARI for all the selection screen variables dynamically.

I can IMPORT individual screen variables :: For ex :

st_key-report = 'ZNIDHS20'.

st_key-variant = 'TEST_VAR'.

IMPORT slsin_p TO TMP_VAR FROM DATABASE VARI(VA) ID ST_KEY.

This will get me the contents of slsin_p parameter in variant TEST_VAR of program ZNIDHS20.

But If I use same statement in a loop, im not able to get the data. : see below

LOOP AT i_selection_table..

IMPORT i_selection_table-name TO TMP_VAR FROM DATABASE VARI(VA) ID ST_KEY.

ENDLOOP.

I found your post interesting and started to test this way....As said, I have extracted selection screen variable table, and then tried to EXPORT the contents to Share Memory from database table VARI(VA), unfortunately program fails. Pls see code below....Pls see if you can help me out...

DATA: BEGIN OF st_key,

report LIKE rsvar-report,

variant LIKE rsvar-variant,

END OF st_key.

data : i_selection_table like rsparams occurs 0 WITH HEADER LINE,

v_rsvar like rsvar-report.

st_key-report = 'ZNIDHS20'.

st_key-variant = 'VJ_TEST'.

V_RSVAR = 'ZNIDHS20'.

data : begin of itab occurs 0,

COL1(40) type c,

COL2(40) TYPE C,

end of itab.

CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'

EXPORTING

CURR_REPORT = V_RSVAR

TABLES

SELECTION_TABLE = i_selection_table

EXCEPTIONS

NOT_FOUND = 1

NO_REPORT = 2

OTHERS = 3.

LOOP AT I_SELECTION_TABLE.

MOVE I_SELECTION_TABLE-SELNAME TO ITAB-COL1.

APPEND ITAB.

ENDLOOP.

EXPORT (ITAB) TO SHARED MEMORY VARI(VA) ID ST_KEY.

IMPORT ITAB = JTAB FROM SHARED MEMORY VARI(VA) ID ST_KEY.

Pls help.....