Application Development 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: 

Erasure of memory variables

Former Member
0 Kudos
538

Hi,

I'm working with memory variables inside a BADI of the migo tranasction. The development worked fine for a couple of month, but right now these variables aren't been erased.

the sentence are like this:

program 1:

EXPORT it_stocklibre = it_stocklibre TO MEMORY ID 'SUB'.

prgram 2:

IMPORT it_stocklibre = it_stocklibre FROM MEMORY ID 'SUB'.

FREE MEMORY ID 'SUB'.

Does anyone has any idea why the memory variable 'SUB' isn't getting free.

Regards,

Eric

1 ACCEPTED SOLUTION

Former Member
0 Kudos
402

Hi,

Try this solution..

Create a function group..

Declare the variable in the TOP INCLUDE of the function group..

Have three FMs..

1. To read the values from the top include variable and pass it to the FUnction module exporting parameter..

2. To write the values to the top include variable that is passed from the importing parameter of the FM..

3. To clear the variable in the Top include..

In the first program use the FM 2 to export the values..

In the second program use the FM 1 to read the values ..Then call the FM 3 to initialize the values..

Meanwhile I will check for any documentation which talks about EXPORT / IMPORT..

Thanks,

Naren

Thanks,

Naren

18 REPLIES 18

Former Member
0 Kudos
402

FREE MEMORY ID 'SUB'.

Check for sy-subrc = 0 after this statment.

Regards,

Prakash.

0 Kudos
402

Hi Prakash,

I already check the sy-subrc and returns 0, but it isn't freeing the variable.

Regards,

Eric

Former Member
0 Kudos
402

Hi Eric,

Can you try using DELETE FROM MEMORY ID <id>.

Cheers

0 Kudos
402

Hi Vin,

I try it, i still get the sy-subrc = 0. But the result is the same, the variable is not getting erased.

Regards,

eric

Former Member
0 Kudos
402

Hi,

If you want the variable value to be erased..

Do an export again with the blank value..

Thanks,

Naren

0 Kudos
402

Hi Naren,

I try it and i still have the same problem.

Regards,

Eric

ferry_lianto
Active Contributor
0 Kudos
402

Hi Eric,

Please try to use FREE MEMORY statement.

This will delete the entire ABAP/4 memory , including data exported with EXPORT TO MEMORY ID key

...
FREE MEMORY.

Hope this will work.

Regards,

Ferry Lianto

Former Member
0 Kudos
402

Hi,

Is the value getting carried over for the next transaction also...I think it is getting stored in the SAP memory..

Thanks,

Naren

Message was edited by: Narendran Muthukumaran

0 Kudos
402

Hi Naren,

The values are getting carried for one program to another correctly, the problem is when i finished the procces and start with the next one i still read the values that belong to the last process.

If I leave the transaction and enter to it again, the variable is correctly erase... I also tried with a Commit but i get a dump every time a try to put a commit inside de MB_MIGO_BADI.

Regards,

Eric

Former Member
0 Kudos
403

Hi,

Try this solution..

Create a function group..

Declare the variable in the TOP INCLUDE of the function group..

Have three FMs..

1. To read the values from the top include variable and pass it to the FUnction module exporting parameter..

2. To write the values to the top include variable that is passed from the importing parameter of the FM..

3. To clear the variable in the Top include..

In the first program use the FM 2 to export the values..

In the second program use the FM 1 to read the values ..Then call the FM 3 to initialize the values..

Meanwhile I will check for any documentation which talks about EXPORT / IMPORT..

Thanks,

Naren

Thanks,

Naren

0 Kudos
402

Hi Naren,

The problem was resolved with your FM tip.

I want to give thanks to all the people who dedicated time in order to help me with the solution of this problem.

Regards,

Eric

PD. I couldn't reply this on friday because of Internet problems.

Former Member
0 Kudos
402

Hi,

I Tried this..It is working fine for me..As soon as you import the value..Export it with a blank value..

DATA: V_VBELN TYPE VBELN VALUE '1234567890'.

  • First time

EXPORT V_VBELN TO MEMORY ID 'TEST_MEM'.

CLEAR: V_VBELN.

IMPORT V_VBELN FROM MEMORY ID 'TEST_MEM'.

WRITE: / 'FIRST - ', V_VBELN.

  • Second time..

CLEAR: V_VBELN.

EXPORT V_VBELN TO MEMORY ID 'TEST_MEM'.

IMPORT V_VBELN FROM MEMORY ID 'TEST_MEM'.

WRITE: / 'SECOND - ', V_VBELN.

Thanks,

Naren

0 Kudos
402

Hi Naren,

I already try to clean it and export it again, but it didn't work. Also, i tried to overwrite the data, but since that variable is a internal table I realize that the data its append to it instead of overwriten it.

I can't use the free memory sentence in order to erase every variable from de memory because i'm inside a badi and it forces me to specify de name of the variable.

I'm starting to think that I may replace those memory variables for Ztables in order to resolve the problem.

Thanks in advance for all your support,

Eric

0 Kudos
402

Hi all,

Somebody told me that there is a function that set free all the memory...

Does anybody knows it?

Regards,

Eric

Former Member
0 Kudos
402

Hi,

Try using the FM technique as I mentioned above..

Thanks,

Naren

Former Member
0 Kudos
402

Hi,

I tried this..It's working fine for me for the internal table..Are you clearing the header line and body of the internal table before passing the blank internal table using EXPORT???

DATA: V_VBELN TYPE STANDARD TABLE OF VBELN WITH HEADER LINE.

DATA: V_VBELN1 TYPE STANDARD TABLE OF VBELN WITH HEADER LINE .

V_VBELN = '1234567890'.

APPEND V_VBELN.

  • First time

EXPORT V_VBELN TO MEMORY ID 'TEST_MEM'.

CLEAR: V_VBELN.

IMPORT V_VBELN TO V_VBELN1 FROM MEMORY ID 'TEST_MEM'.

READ TABLE V_VBELN1 INDEX 1.

WRITE: / 'FIRST - ', V_VBELN1.

  • Second time..

CLEAR: V_VBELN1.

CLEAR: V_VBELN.

REFRESH: V_VBELN, V_VBELN1.

EXPORT V_VBELN TO MEMORY ID 'TEST_MEM'.

IMPORT V_VBELN TO V_VBELN1 FROM MEMORY ID 'TEST_MEM' .

READ TABLE V_VBELN1 INDEX 1.

WRITE: / 'SECOND - ', V_VBELN1.

Thanks,

Naren

0 Kudos
402

Hi Naren,

This isn't work either. i gonna try your FM Technique.

Thanks in advance,

Eric

Message was edited by: Eric Hernandez Pardo

Former Member
0 Kudos
402

This may be irrelevant, but:

Change the name of your memory id to something longer and more unique. Most SAP Memory IDs are 15 characters long with names like 'SDFGHJ8889355Y '. That way there is no chance another progran will try to use the same memory id with unintended concequences.

You could create a dynamic memory id based on the user id. Then the memory id only contains data from the previous call / submit.

As you cannot debug the BADI why not try writting a Info message with the values you want to see.

MattG.