I'm trying to create an internal table, which contains a lot of components of existing tables, but not all.
So i tried to get the type description of the existing table, delete the not needed fields and create a new table by RTTS.
Here is my code:
REPORT ZCA_SW_DYNAMIC_TYPES. data: dref type ref to data, desc_table type ref to cl_abap_tabledescr, desc_struc type ref to cl_abap_structdescr, it_components type abap_component_tab, wa_components type abap_componentdescr. FIELD-SYMBOLS: <it_out> type STANDARD TABLE. START-OF-SELECTION. desc_struc ?= cl_abap_typedescr=>describe_by_name( 'T001' ). it_components = desc_struc->get_components( ). delete it_components WHERE name = 'MANDT'. desc_struc = cl_abap_structdescr=>create( it_components ). desc_table = cl_abap_tabledescr=>create( desc_struc ). create data dref type HANDLE desc_table. assign dref->* to <it_out>. select * from t001 into CORRESPONDING FIELDS OF TABLE <it_out>. write:/ 'Done'.
This works fine, but now i'm stucked. The reason is that it_components does not contain all compoents by name, T001 has an include and an append, and these are not resolved in the table it_components. If i want to delete the component BUKRS_GLOB i cant do that cause its in an include.
How can i get it_componets filled so that only elementary compoents are given and resulting includes are resolved?