Code: Alles auswählen.
FORM new_table CHANGING cz_tab_ptr TYPE REF TO data.
DATA:
lx_tab TYPE REF TO cl_abap_tabledescr,
lx_struc TYPE REF TO cl_abap_structdescr,
lt_components TYPE abap_component_tab,
ls_components TYPE abap_componentdescr.
* Felder aus Struktur
lx_struc ?= cl_abap_typedescr=>describe_by_name( 'T000' ).
lt_components = lx_struc->get_components( ).
* Feld1 (Char 2)
ls_components-name = 'Feld1'.
ls_components-type ?= cl_abap_elemdescr=>get_c( 2 ).
INSERT ls_components INTO TABLE lt_components.
* Feld2 (Integer)
ls_components-name = 'Feld2'.
ls_components-type ?= cl_abap_elemdescr=>get_i( ).
INSERT ls_components INTO TABLE lt_components.
* erweiterte Struktur erzeugen
lx_struc = cl_abap_structdescr=>create( p_components = lt_components ).
* Tabelle erzeugen
lx_tab = cl_abap_tabledescr=>create( p_line_type = lx_struc ).
CREATE DATA cz_tab_ptr TYPE HANDLE lx_tab.
ENDFORM.