Code: Alles auswählen.
FIELD-SYMBOLS:
<dyn_rec> TYPE any,
<dyn_tab> TYPE STANDARD TABLE.
DATA:
l_ref_type_descr_ddic TYPE REF TO cl_abap_typedescr,
l_ref_type_descr_line TYPE REF TO cl_abap_typedescr,
l_ref_struct_descr_line TYPE REF TO cl_abap_structdescr,
l_tab_component TYPE cl_abap_structdescr=>component_table.
DATA:
lop_tabledescr TYPE REF TO cl_abap_tabledescr,
ldp_dynaic_record TYPE REF TO data,
ldp_dyn_table TYPE REF TO data,
lop_strucdescr TYPE REF TO cl_abap_structdescr.
..... "LT_TAB füllen
LOOP AT lt_tab ASSIGNING FIELD-SYMBOL(<ls_tab>).
l_ref_type_descr_ddic = cl_abap_typedescr=>describe_by_name( <ls_tab>-tab_name ).
l_ref_struct_descr_line ?= l_ref_type_descr_ddic.
l_tab_component = l_ref_struct_descr_line->get_components( ).
lop_strucdescr = cl_abap_structdescr=>create( l_tab_component ).
CREATE DATA ldp_dynaic_record TYPE HANDLE lop_strucdescr.
lop_tabledescr ?= cl_abap_tabledescr=>create( p_line_type = lop_strucdescr ).
CREATE DATA ldp_dyn_table TYPE HANDLE lop_tabledescr.
ASSIGN ldp_dynaic_record->* TO <dyn_rec>.
ASSIGN ldp_dyn_table->* TO <dyn_tab>.
ENDLOOP.
Code: Alles auswählen.
TYPES: BEGIN OF dynamic_table,
name TYPE tabname,
content_ref TYPE REF TO data,
END OF dynamic_table.
FIELD-SYMBOLS:
<dyn_rec> TYPE any,
<dyn_tab> TYPE STANDARD TABLE.
DATA:
l_ref_type_descr_ddic TYPE REF TO cl_abap_typedescr,
l_ref_type_descr_line TYPE REF TO cl_abap_typedescr,
l_ref_struct_descr_line TYPE REF TO cl_abap_structdescr,
l_tab_component TYPE cl_abap_structdescr=>component_table.
DATA:
lop_tabledescr TYPE REF TO cl_abap_tabledescr,
ldp_dynaic_record TYPE REF TO data,
ldp_dyn_table TYPE REF TO data,
lop_strucdescr TYPE REF TO cl_abap_structdescr.
dynamic_table_store TYPE HASHED TABLE OF dynamic_table WITH UNIQUE KEY name.
LOOP AT lt_tab ASSIGNING FIELD-SYMBOL(<ls_tab>).
l_ref_type_descr_ddic = cl_abap_typedescr=>describe_by_name( <ls_tab>-tab_name ).
l_ref_struct_descr_line ?= l_ref_type_descr_ddic.
l_tab_component = l_ref_struct_descr_line->get_components( ).
lop_strucdescr = cl_abap_structdescr=>create( l_tab_component ).
lop_tabledescr ?= cl_abap_tabledescr=>create( p_line_type = lop_strucdescr ).
CREATE DATA ldp_dyn_table TYPE HANDLE lop_tabledescr.
INSERT VALUE #( name = <ls_tab>-tab_name content_ref = ldp_dyn_table ) INTO TABLE dynamic_table_store.
ENDLOOP.
LOOP AT lt_tab ASSIGNING FIELD-SYMBOL(<ls_tab>).
DATA(content_ref) = dynamic_table_store[ name = <ls_tab>-tab_name ]-content_ref.
ASSIGN content_ref->* TO <dyn_tab>.
lop_strucdescr = cl_abap_structdescr=>create( l_tab_component ).
CREATE DATA ldp_dynaic_record TYPE HANDLE lop_strucdescr.
ASSIGN ldp_dynaic_record->* TO <dyn_rec>.
" ...
ENDLOOP.
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
qyurryus