2024 May 17 12:37 PM
Hi, I was able to print the column headers and types, but I could not print the length parameter, can you help me? I am leaving the final version of the code below.
DATA(lr_tabledescr) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( lt_analok ) ).
DATA(lr_structdescr) = CAST cl_abap_structdescr( lr_tabledescr->get_table_line_type( ) ).
DATA(sutun_basliklari) = VALUE fieldname_tab( FOR ls IN lr_structdescr->components ( ls-name ) ).
DATA(sutun_type) = VALUE fieldname_tab( FOR ls IN lr_structdescr->components ( ls-type_kind ) ).
data(leng) = VALUE fieldname_tab( FOR ls IN lr_structdescr->components ( ls-length ) ).
DATA index TYPE i.
index = 1.
LOOP AT sutun_basliklari INTO DATA(ls_st).
WRITE: / index, ' ' , ls_st, ' ' , sutun_type[ index ] , ' ' .
index = index + 1.
ENDLOOP.
cl_demo_output=>display( ).
2024 May 17 4:58 PM
Your internal table LENG contains the lengths of all components. Basically, it works. So what is your actual problem?
2024 May 20 10:53 AM
"LS-LENGTH" and the row type of "LENG" are incompatible. Can you help me get an error?
2024 May 20 11:59 AM
So, you have the error
"LS-LENGTH" and the row type of "LENG" are incompatible.
at this line:
data(leng) = VALUE fieldname_tab( FOR ls IN lr_structdescr->components ( ls-length ) ).
You have defined LENG of type FIELDNAME_TAB, so it's an internal table with all lines of type 30 characters, and you're trying to initialize each line with LS-LENGTH which is numeric.
So you have to CONVERT the number to string, it has been asked hundreds of times in the forum as I can see by searching
abap convert number to character site:sap.com
Now, I doubt that you want LENG to be an internal table of field names, you probably want it to be an internal table of integers, here is how to declare a complete table type which you can use to declare LENG:
TYPES ty_integers TYPE STANDARD TABLE OF i WITH EMPTY KEY.