Archived discussions are read-only. Learn more about SAP Q&A

cl_abap_typedescr=>describe_by_name not returning correct length value

Hi,

I am using cl_abap_typedescr=>describe_by_name to get the length and field names of a table. But it is returning incorrect values for length. For example, all character fields and numc fields contain double the correct length

REPORT  ZCA_BOB_CL_ABAP_STRUCTDESCR.

PARAMETERS P_TABNAM type TABNAME OBLIGATORY.

Data: wa_spfli type spfli,
      r_descr type REF TO cl_abap_structdescr,
      wa_comp TYPE abap_compdescr.


** Create references to the needed ALV Global Classes
  data: lr_events type ref to cl_salv_events_table.
  data: gr_table   type ref to cl_salv_table.
  Data: r_grid TYPE REF TO cl_salv_table.
  data: r_title_text TYPE REF TO cl_alv_variant,
        r_grid_title TYPE LVC_TITLE.

Data:  abap_compdescr_tab TYPE STANDARD TABLE OF abap_compdescr
                     WITH KEY name.


START-OF-SELECTION.

**         ?=   means cast
** r_descr ?= cl_abap_typedescr=>describe_by_data( wa_spfli ).
 r_descr ?= cl_abap_typedescr=>describe_by_name( P_TABNAM ).

 Loop at r_descr->components into wa_comp.

*   write:/ wa_comp-name, wa_comp-type_kind, wa_comp-length,
*            wa_comp-decimals.

   append wa_comp to abap_compdescr_tab.

 EndLoop.

Not what you were looking for? View more on this topic or Ask a question