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: 

Passing Dynamic Internal Tables to Memory

Former Member
0 Kudos

I have a bit of a conundrum right now that I can't seem to correct. I am working on adding an ALV report to an existing report program. I was able to write a simple helper program that builds a custom object that I defined that translates my raw data into two seperate dynamic tables, and then builds an ALV grid and outputs it. The reason I wrote this in a simple helper program was so that I could use SUBMIT ... EXPORTING LIST TO MEMORY from my primary report program and capture the input so I can later write it out under our company's standard ABAP list format as if I were using WRITE statements.

The output of the report itself is working beautifully. We have included functionality to automatically take the output, produce an HTML file from it, and then FTP it directly to a webserver so our clients can get easy access to it. What I want to be able to do though is give the clients two tab-delimited files that contain the raw data that was used to build the report. We have an interface in place to do that, but I somehow need to be able to pass these two dynamic internal tables which I have field-symbols to reference back to my calling program.

Here is what I am trying to do:


CALL METHOD OBJ_ALV_MR_EST_REASONS->PRODUCE_ESTIMATION_REPORT
    IMPORTING
      RPT_DATA_BY_REASON   = ref_it_estreason
      RPT_DATA_BY_DISTRICT = ref_it_district.

*   Assign the field symbols
  ASSIGN ref_it_estreason->* TO <it_estreason>.
  ASSIGN ref_it_district->* TO <it_district>.

* Export the two internal tables to memory so they can be
* retrieved by the calling program
  EXPORT reason = <it_estreason>[]
         district = <it_district>[]
  TO MEMORY ID 'ZCR_ESTIMATION_REASON_RPT'.

As you can see, my method returns two references to dynamic internal tables. I have used the memory debugger to see that these tables are being correctly written to the ABAP memory.

However, back in my parent program when I try to do the following,


CREATE DATA ref_it_estreason TYPE REF TO DATA.
      CREATE DATA ref_it_district TYPE REF TO DATA.
      ASSIGN ref_it_estreason->* TO <it_estreason>.
      ASSIGN ref_it_district->* TO <it_district>.
      IMPORT reason = <it_estreason>
             district = <it_district>
      FROM MEMORY ID 'ZCR_ESTIMATION_REASON_RPT'.

I get the REFS_NOT_SUPPORTED_YET exception which says that "For the statement Export/Import ..." object references, interface references, and data references are currently not supported".

I have tried multiple other ways of defining my field-symbols or my reference pointers but they all result in exceptions of some sort. Is there any way for me to get this data passed back? It seems like there must be a way to get the data from memory since I know it's being correctly stored there.

Thanks in advance.

1 ACCEPTED SOLUTION

satinder_singh
Participant
0 Kudos

Though I do not have acces to the SAP system right now, but looking at the message it is apparent that the <FS> is not support for IMPORT/EXPORT in OO context. So what I would recommend is to write a small FM to get the value from memory to itab and then pass it to the class.

3 REPLIES 3

satinder_singh
Participant
0 Kudos

Though I do not have acces to the SAP system right now, but looking at the message it is apparent that the <FS> is not support for IMPORT/EXPORT in OO context. So what I would recommend is to write a small FM to get the value from memory to itab and then pass it to the class.

0 Kudos

Shortly after posting this, I had an idea which I was able to implement to actually get this to work.

I decided that I would simply pass the FIELDCAT tables for each of my dynamic tables into the same memory ID as the tables themselves.


  EXPORT reason_fcat = it_estreason_fcat
         district_fcat = it_district_fcat
         reason = <it_estreason>[]
         district = <it_district>[]
  TO MEMORY ID 'ZCR_ESTIMATION_REASON_RPT'.

Then, back in my calling program I execute the following code. This retrieves the FIELDCAT tables, builds two empty dynamic table type reference variables and then lets me create field-symbols to reference those components.


*     Retrieve the fieldcat internal tables first
      IMPORT reason_fcat = it_estreason_fcat
             district_fcat = it_district_fcat
      FROM MEMORY ID 'ZCR_ESTIMATION_REASON_RPT'.

*     Generate an internal table type assigned to each
*     reference variable based on the fieldcat listings we
*     retrieve
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_estreason_fcat
        IMPORTING
          ep_table        = ref_it_estreason.

      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_district_fcat
        IMPORTING
          ep_table        = ref_it_district.

*     Assign the field symbols
      ASSIGN ref_it_estreason->* TO <it_estreason>.
      ASSIGN ref_it_district->* TO <it_district>.
      CREATE DATA ref_wa_estreason LIKE LINE OF <it_estreason>.
      CREATE DATA ref_wa_district LIKE LINE OF <it_district>.
      ASSIGN ref_wa_estreason->* TO <wa_estreason>.
      ASSIGN ref_wa_district->* TO <wa_district>.

*     Finally, we can retrieve the data from memory and assign
*     to the internal tables referenced by our field-symbols
      IMPORT reason = <it_estreason>[]
             district = <it_district>[]
      FROM MEMORY ID 'ZCR_ESTIMATION_REASON_RPT'.

This worked beautifully and saved me from having to do a major redesign. I don't know how helpful it would be for ABAP Objects to be passed to memory (I believe some type of serialization would need to be in order there), but for dynamically typed internal tables it worked like a dream with little overhead.

0 Kudos

I've never used this productively (in real developments) yet, but I believe the Shared Memory Objects concept allows you to do this (export data references, object references, etc.). It's an OO improvement over the EXPORT/IMPORT concept. With this, you would not need to assign the tables to field symbols, but you could put in shared memory the reference itself.

Help on the subject: http://help.sap.com/saphelp_nw70/helpdata/en/c5/85634e53d422409f0975aa9a551297/content.htm

Also, get this file which explains this topic with detail: https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/900e3d9d-559e-2910-9dae-b132157a...

Regards