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 MEMORY

Former Member
0 Likes
1,767

Hello friends,

Below is the code I am using.

IMPORT flag_linked FROM MEMORY ID 'ZLINKED_FLAG'.

IF flag_linked NE 'X'.

flag_linked = 'X'.

EXPORT flag_linked TO MEMORY ID 'ZLINKED_FLAG'.

.........code.....

endif.

When I am execuing the program for the first time everything works fine and the Import statement fails. However when I am executing the program the second time the Import statement is successful in the first attempt.

Its a exit so will trigger couple iof times. So how would i clear the memory when the program is executed completely.

Madhu..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,625

Hi,

WHen the program is completed the memory values will automatically be erased..as these values are stored in the ABAP memory...And not in SAP memory..

Also please check the documentation for detailed explanation of IMPORT and EXPORT statement..

Thanks,

Naren

9 REPLIES 9
Read only

suresh_datti
Active Contributor
0 Likes
1,625

use the statement FREE MEMORY ID 'ZLINKED_FLAG'.

~Suresh

Read only

Former Member
0 Likes
1,626

Hi,

WHen the program is completed the memory values will automatically be erased..as these values are stored in the ABAP memory...And not in SAP memory..

Also please check the documentation for detailed explanation of IMPORT and EXPORT statement..

Thanks,

Naren

Read only

0 Likes
1,625

Thanks,

So Naren you mean to say once the program is completely executed the value in the field flag_linked will be blank.

I also assumed so but i dont know why I see the value after the Import statement is triggered.

The exits trigger when a PO is created. However when i close the window and execute it it looks fine.

Any suggestions.

Madhu.

Read only

former_member195032
Active Contributor
0 Likes
1,625

Hi Madhu,

Please see link

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3bf8358411d1829f0000e829fbfe/content.htm

To delete data clusters, you can use the following statements:

· FREE MEMORY deletes all data cluster from the ABAP memory

· DELETE FROM ... ID id deletes a data cluster with the identification id, which was stored in the ABAP memory of a database table, or in an application buffer of an application server.

regards,Nishant

Please reward points if this helps

Read only

Former Member
0 Likes
1,625

Hi Madhu,

Please use FREE MEMORY statement to clear memory.

or

move space to flag_linked.

EXPORT flag_linked TO MEMORY ID 'ZLINKED_FLAG'.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
1,625

Hi,

Yes..Once the program is completed..The value in the memory will be blank..But to make to sure..you can give FREE MEMORY ID 'xxxx'.

Try this simple report...Execute the report more than once...It will show no memory...But you have to completely go out of the transaction SE38...To make it work..

DATA: v_value(2) VALUE '99'.

DATA: v_value_get(2).

IMPORT v_value = v_value_get FROM MEMORY ID 'ZTEST'.

IF sy-subrc = 0.

WRITE: / v_value_get.

ELSE.

WRITE: / 'No memory'.

ENDIF.

v_value_get = '89'.

EXPORT v_value = v_value_get TO MEMORY ID 'ZTEST'.

WRITE: / sy-subrc.

Also to be on the safer side...You can use FREE MEMORY ID 'ZTEST' to clear it immediately...

Thanks,

Naren

Read only

0 Likes
1,625

Thanks Naren.

I cant use free memory in my case because the exit is triggered many times and i cant free memory in between. If i need to i should free only when the exit would be triggered for the last time, but i dont know when would it trigger the last time.

Madhu...

Read only

Former Member
0 Likes
1,625

Hi,

If we don't when exactly to free the memory...Then leave it as is..

As I mentioned earlier..the memory will automatically get refreshed for new transactions..

BTW...are you using IMPORT and EXPORT in the same user exit..

Instead you can use STATICS..

Example

-


STATICS: V_FLAG TYPE C.

IF V_FLAG IS INITIAL. " First time..

V_FLAG = 'X'.

ENDIF.

IF V_FLAG = 'X'. " Subsequent times.

..

ENDIF.

Thanks,

Naren

Read only

Former Member
0 Likes
1,625

Hi Madhu,

if v_flag ne 'X'.
  IMPORT flag_linked FROM MEMORY ID 'ZLINKED_FLAG'.
  v_flag = 'X'.
endif.
if v_flag = 'X' .
IF flag_linked NE 'X'.
flag_linked = 'X'.
EXPORT flag_linked TO MEMORY ID 'ZLINKED_FLAG'.

.........code.....
endif.
endif.

I guess this works

Regards

Naresh