Code: Alles auswählen.
REPORT zdz_test_struct NO STANDARD PAGE HEADING LINE-SIZE 80.
TYPES:
BEGIN OF my_struct,
comp_a TYPE i,
comp_b TYPE char10,
END OF my_struct.
DATA:
my_data TYPE my_struct,
descr_ref TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS:
<comp_wa> TYPE abap_compdescr,
<comp_abap_parmdescr> TYPE abap_parmdescr.
START-OF-SELECTION.
descr_ref ?= cl_abap_typedescr=>describe_by_data( my_data ).
WRITE: / 'Typename :', descr_ref->absolute_name.
WRITE: / 'Kind :', descr_ref->type_kind.
WRITE: / 'Length :', descr_ref->length.
WRITE: / 'Decimals :', descr_ref->decimals.
WRITE: / 'Struct Kind :', descr_ref->struct_kind.
WRITE: / 'Components'.
WRITE: / 'Name Kind Length Decimals'.
LOOP AT descr_ref->components ASSIGNING <comp_wa>.
WRITE: /
<comp_wa>-name,
<comp_wa>-type_kind,
<comp_wa>-length,
<comp_wa>-decimals.
ENDLOOP.