Application Development and Automation 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: 
Read only

Create dynamic table from existing one

Former Member
0 Likes
1,656

Dear experts,

I have following internal table:

Is there any possibility in ABAP (Framework, Class, etc), so I can fast create a new internal table at runtime which would look like this:

Would appreciate any kind of help.

Thanks and BR.

6 REPLIES 6
Read only

matt
Active Contributor
0 Likes
1,529

Yes. There is. It's called RTTS.

Read only

former_member593648
Active Participant
Read only

Former Member
0 Likes
1,529

Hi guys,

thanks for your fast responce!

RTTS looks as a good way. I've tried this:

DATA(vbeln_descriptor) = CAST cl_abap_datadescr( cl_abap_typedescr=>describe_by_name( 'VBELN' ) ).
      DATA(posnr_descriptor) = CAST cl_abap_datadescr( cl_abap_typedescr=>describe_by_name( 'POSNR' ) ).


      DATA(components) = VALUE abap_component_tab( ( name = 'VBELN'
                                                     type = vbeln_descriptor )
                                                   ( name = 'POSNR'
                                                     type = posnr_descriptor ) ).


*      DATA(value_descriptor) = CAST cl_abap_typedescr( cl_abap_typedescr=>describe_by_name( 'VALUE' ) ).
      DATA(value_descriptor) = CAST cl_abap_datadescr( cl_abap_typedescr=>describe_by_name( 'VALUE' ) ).


      LOOP AT mt_so_itm_qppd_attr INTO DATA(vbeln_row).
        INSERT VALUE #(
            name = vbeln_row-element
            type = value_descriptor )
          INTO TABLE components.
      ENDLOOP.


      DATA(row_descriptor) = cl_abap_structdescr=>get( components ).
      DATA(table_descriptor) = cl_abap_tabledescr=>create( row_descriptor ).


      DATA itab TYPE REF TO data.
      CREATE DATA itab TYPE HANDLE table_descriptor.

But it still not doing what I expect.

Do yu have any Idea where the mistake could be?

Thanks and BR.

Read only

0 Likes
1,529

Yeah, at least in our dev. system

DATA(row_descriptor)= cl_abap_structdescr=>get(components).

schould be

DATA(row_descriptor)= cl_abap_structdescr=>create(components).

Kind regards
Stefan

Read only

Former Member
0 Likes
1,529

Thanks for reply Stefan!

yes, the table now looks good, but I asking myself why the values were not taken into it. Was it in your case the same?

BR. Denis.

Read only

0 Likes
1,529

Yes because you have created an empty table now. So you should populate it with your data 😉

Kind regards
Stefan