*&---------------------------------------------------------------------*
*& Report Z_GET_TABLE_COLUMNNAME
*& get component structure by RTTS.(Runtime Type Servcies)
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z_GET_TABLE_COLUMNNAME.
TYPES: BEGIN OF typ_itab,
sex(20) TYPE c,
tigh TYPE i,
salary TYPE p LENGTH 12 DECIMALS 3,
name type string,
END OF typ_itab.
DATA: i_itab TYPE TABLE OF typ_itab , "if has with header line,exceptin happend
l_tabledescr_ref TYPE REF TO cl_abap_tabledescr,
l_descr_ref TYPE REF TO cl_abap_structdescr,
wa_table TYPE abap_compdescr.
l_tabledescr_ref ?= cl_abap_typedescr=>describe_by_data( i_itab ).
l_descr_ref ?= l_tabledescr_ref->get_table_line_type( ).
LOOP AT l_descr_ref->components INTO wa_table .
WRITE: / wa_table-name,wa_table-type_kind,
wa_table-length,wa_table-decimals.
ENDLOOP.