Code: Alles auswählen.
DATA:
lo_struct_type TYPE REF TO cl_abap_structdescr,
lo_dref TYPE REF TO data,
lv_fieldname TYPE text60,
lt_components TYPE cl_abap_structdescr=>component_table,
lt_fieldcat TYPE kkblo_t_fieldcat.
"Auswahl der auszugebenden Felder
LOOP AT lt_fieldcat[] ASSIGNING FIELD-SYMBOL(<ls_fieldcat>) WHERE no_out EQ abap_false.
INSERT INITIAL LINE INTO TABLE lt_components[] ASSIGNING FIELD-SYMBOL(<ls_component>).
<ls_component>-name = <ls_fieldcat>-fieldname.
lv_fieldname = '<ls_data>-' && <ls_fieldcat>-fieldname.
ASSIGN (lv_fieldname) TO <lv_field>.
<ls_component>-type ?= cl_abap_elemdescr=>describe_by_data( <lv_field> ).
ENDLOOP.
"Erzeugung der dynamischen Struktur
TRY.
CLEAR: lo_dref.
lo_struct_type = cl_abap_structdescr=>get( EXPORTING p_components = lt_components[] ). "<- Hier wird die Exception cx_sy_struct_creation geworfen
CREATE DATA lo_dref TYPE HANDLE lo_struct_type.
CATCH cx_sy_struct_creation.
"Fehlerbehandlung noch nicht implementiert
ENDTRY.
ASSIGN lo_dref->* TO <ls_struc>.
"Zuweisung der auszugebenden Daten
MOVE-CORRESPONDING <ls_data> TO <ls_struc>.
Code: Alles auswählen.
TYPES:
BEGIN OF INFO,
Marker type Char1,
Descr type text50,
END of INFO,
BEGIN of MyDATA,
Nutzfeld1 type i,
Moredata type info,
end of MyDATA,
MyDaten type standard table of Mydata.
DATA:
MyTable type MyDaten.