Skip to Content
avatar image
Former Member

How to avoid memory freeing in dynamic programs

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    Oct 30, 2013 at 11:13 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • Apr 10, 2006 at 11:03 AM

    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..!

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 10, 2006 at 11:35 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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