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: 

Create dynamic table from existing one

0 Kudos

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

matt
Active Contributor
0 Kudos

Yes. There is. It's called RTTS.

0 Kudos

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.

0 Kudos

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

0 Kudos

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.

0 Kudos

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

Kind regards
Stefan