11-06-2018 4:10 PM
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.
11-06-2018 8:02 PM
11-06-2018 11:28 PM
Check the RTTS wiki. Will help
https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=42965
this page in particular
https://wiki.scn.sap.com/wiki/display/Snippets/Creating+a+dynamic+internal+table+based+on+data
11-07-2018 7:05 AM
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.
11-07-2018 9:05 AM
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
11-07-2018 10:09 AM
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.
11-07-2018 11:20 AM
Yes because you have created an empty table now. So you should populate it with your data 😉
Kind regards
Stefan