2023 Sep 01 12:39 PM
Hi folks
I'm building a header line from my SALV table to use it in my CSV-File by this method.
METHOD get_headerline_from_salv.
* build a header line
LOOP AT i_salv->get_columns( )->get( ) INTO DATA(ls_col).
r_result = |{ r_result }{ ls_col-r_column->get_long_text( ) }{ i_sep }|.
ENDLOOP.
ENDMETHOD.
Most of the time this works fine, especially when I debug and try to find the bug it is always perfectly fine. But if I don't watch, sometimes the colums are in a wrong order?!?
Any idea why? What can I do about it?
Cheers Jan
2023 Sep 01 1:51 PM
It's really strange that this is not stable.
I would rather start from the table (VBAK in my example) and use the technical field names...
DATA: r_type_desr TYPE REF TO cl_abap_structdescr,
s_vbak TYPE vbak,
v_string TYPE string.
r_type_desr ?= cl_abap_typedescr=>describe_by_data( s_vbak ).
LOOP AT r_type_desr->components INTO DATA(s_components).
IF v_string IS INITIAL.
v_string = s_components-name.
ELSE.
v_string = |{ v_string }', '{ s_components-name }|.
ENDIF.
ENDLOOP.
WRITE v_string.
2023 Sep 01 1:51 PM
It's really strange that this is not stable.
I would rather start from the table (VBAK in my example) and use the technical field names...
DATA: r_type_desr TYPE REF TO cl_abap_structdescr,
s_vbak TYPE vbak,
v_string TYPE string.
r_type_desr ?= cl_abap_typedescr=>describe_by_data( s_vbak ).
LOOP AT r_type_desr->components INTO DATA(s_components).
IF v_string IS INITIAL.
v_string = s_components-name.
ELSE.
v_string = |{ v_string }', '{ s_components-name }|.
ENDIF.
ENDLOOP.
WRITE v_string.
2023 Sep 01 7:18 PM
Weird. Check the SAP notes.
(but I would think that you are in a special case, but I can't say without any further description/steps to reproduce)