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: 

Transform osreftab to internal table

Mattias
Active Participant
0 Kudos

Hello,

I have a table of type osreftab that I have gott from an persistance object using


if_os_ca_persistency~get_persistent_by_query

Is it possible to dynamically convert this into an internal table?

i.e. I would prefer something like


DATA: result_table TYPE osreftab,

           tmp_result TYPE object,

           ls_row TYPE some_internal_table.

result_table = agent->if_os_ca_persistency~get_persistent_by_query( some_Query ).

LOOP AT result_table INTO tmp_result.

     ls_row = *convert tmp_result to ls_row dynamically*

     APPEND ls_row TO lt_row.

ENDLOOP.

instead of:


DATA: result_table TYPE osreftab,

           tmp_result TYPE object,

.          ls_row TYPE some_internal_table,

          tmp_row TYPE REF TO ZCL_PERSISTENT_CLASS.


result_table = agent->if_os_ca_persistency~get_persistent_by_query( some_Query ).

LOOP AT result_table INTO tmp_result.

     tmp_row ?= tmp_result.

     ls_row-field_a = tmp_row->get_field_a( ).

     ls_row-field_b = tmp_row->get_field_b( ).

     ls_row-field_c = tmp_row->get_field_c( ).

     APPEND ls_row TO lt_row.

ENDLOOP.

Regards

Mattias

1 REPLY 1

former_member185998
Active Participant
0 Kudos

Hi Mattias,

I'm sure you've solved this in one way or another by now.

Anyway, while looking for an answer to my question, I ran into your post, still unanswered, and this blog post by Petr Plenkov.

Petr made a smart helper class that returns flat structures/tables rather than object references.

Apparently there's no easy standard way, so he needed to build something like that.