In my program I am getting the components of a structure in my program. But
I noticed during debugging that it gives out wrong length. For example, field1
of my structure has a data type of flag which means it is a CHAR with length 1 but
when I use the said method of cl_abap_structdescr my field1 has a length of 2 which
is giving me short dumps.
Below is my code:
TYPES: BEGIN OF gs_file_struct1, col1 TYPE flag, "Indicator col2 TYPE flag, "Transaction type col3 TYPE string, col4 TYPE string, col5 TYPE string, col6 TYPE string, col7 TYPE string, col8 TYPE string, col9 TYPE string, col10 TYPE string, col11 TYPE string, col12 TYPE string, END OF gs_file_struct1.
im_struct_name is 'GS_FILE_STRUCT1' passed to an parameter of a method.
* Get components of structure lcl_sdescr ?= cl_abap_structdescr=>describe_by_name( im_struct_name ). lt_components = lcl_sdescr->components. * Build fieldcatalog based from the components LOOP AT lt_components INTO lw_components. CLEAR lw_fieldcat. lw_fieldcat-fieldname = lw_components-name. lw_fieldcat-datatype = lw_components-type_kind. lw_fieldcat-inttype = lw_components-type_kind. lw_fieldcat-intlen = lw_components-length. lw_fieldcat-decimals = lw_components-decimals. APPEND lw_fieldcat TO lt_fieldcat. CLEAR lw_fieldcat. ENDLOOP.
Now, when I check the length of my COL1, it is shown as length 2 instead of 1!