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: 

How to avoid memory freeing in dynamic programs

Former Member
0 Kudos

Hello,

i have written a abap code statement which dynamically generates a transient abap program!

This dynamic generated program has a return structure, which will be filled inside the dynamic program.

After calling the program from a normal abap program, the return structure has the status "freed stack".

The reason is clear: the resources of the program are "freed" after completion of the program.

What can I do to avoid this process and use the data received from the dynamic generated program?

Thanx in advance...

Florian

1 ACCEPTED SOLUTION

edemey
Explorer
0 Kudos

Hi Florian,

I solved the Problem by copying the old reference variable in a global new referrence variable:

data: lo_data_ref TYPE REF TO CL_ABAP_DATADESCR.

lo_data_ref ?= CL_ABAP_DATADESCR=>describe_by_data_ref(
              p_data_ref = ADD_EVENT_DATA ).

          CREATE DATA wd_this->mr_bo_data type HANDLE lo_data_ref.

          assign  wd_this->mr_bo_data->* to <ls_add_event_data>.

          assign ADD_EVENT_DATA->* to <ls_add_event_data_copy>.

          <ls_add_event_data> = <ls_add_event_data_copy>.

ADD_EVENT_DATA is the local old refernce variable which was ´freed.

BR, Edgar

5 REPLIES 5

naimesh_patel
Active Contributor
0 Kudos

Hello,

In your dynamic generated program, you can use EXPORT itab = itab TO MEMORY. and in you main program you can receive that data by IMPORT from memory.

Hope this will slove your problem.

Regards,

Naimesh.

Reward points, if it is useful..!

Former Member
0 Kudos

Hi Naimesh,

thanks for your reply and your suggestion.

Unfortunately i have a reference in this structure and i cannot use "export" and/or "import" statements.

(I get an error: "Cannot export references")

Florian

0 Kudos

Hello Florian,

Have you been able to solve your problem?

I have a similar problem, loosing a reference

to a class. Would be interested how you

solved this problem.

Thanks,

Rolf

edemey
Explorer
0 Kudos

Hi Florian,

I solved the Problem by copying the old reference variable in a global new referrence variable:

data: lo_data_ref TYPE REF TO CL_ABAP_DATADESCR.

lo_data_ref ?= CL_ABAP_DATADESCR=>describe_by_data_ref(
              p_data_ref = ADD_EVENT_DATA ).

          CREATE DATA wd_this->mr_bo_data type HANDLE lo_data_ref.

          assign  wd_this->mr_bo_data->* to <ls_add_event_data>.

          assign ADD_EVENT_DATA->* to <ls_add_event_data_copy>.

          <ls_add_event_data> = <ls_add_event_data_copy>.

ADD_EVENT_DATA is the local old refernce variable which was ´freed.

BR, Edgar

Former Member
0 Kudos

Hi Edgar,

This sounds correct but I have not tested it.... 7 years is a long time and I can't remember the project

Thanks for sharing this.