2017 Aug 15 10:31 PM
Hi all,
I'm trying to convert an internal table to .CSV using the 'SAP_CONVERT_TO_CSV_FORMAT' function. How can I add the header (title) columns to the output table?
Thanks beforehand,
Regards,
Luis
2017 Aug 16 6:00 AM
Pass I_LINE_HEADER = 'X' and add the header column/field names as the first row of the internal table.
2017 Aug 16 6:00 AM
Pass I_LINE_HEADER = 'X' and add the header column/field names as the first row of the internal table.
2017 Aug 16 1:20 PM
Sinu,
Thanks for your answer. I had already passed I_LINE_HEADER = 'X' without success. I did not imagine that the function was so restricted in its functionality.
I accept that's the way things are, nevertheless, it seems to me a little bit kludgy way to do things...
Thanks again,
Luis
2017 Aug 16 2:53 PM
2017 Aug 16 3:29 PM
2017 Aug 16 3:48 PM
DATA: lo_struct_descr TYPE REF TO cl_abap_structdescr,
lo_elem_descr TYPE REF TO cl_abap_elemdescr,
ls_line TYPE string,
lc_char TYPE char40,
lt_file TYPE STANDARD TABLE OF string.
*-- Get RTTI object for the local structure
lo_struct_descr ?= cl_abap_typedescr=>describe_by_name( iv_objtype ). " iv_objtype ----> table/structure name
*-- Get the components of the structure
DATA(lt_struct_fields) = lo_struct_descr->get_components( ).
LOOP AT lt_struct_fields INTO DATA(lwa_struct_field).
lo_elem_descr ?= lwa_struct_field-type.
DATA(long) = lo_elem_descr->get_ddic_field( )-scrtext_l. " Long text is used to fill the header line
*-- Prepare Unix file headings
CONCATENATE ls_line long INTO ls_line SEPARATED BY iv_delim.
CLEAR long.
ENDLOOP.
*-- Append file header
APPEND ls_line TO lt_file.
CLEAR ls_line.
2017 Aug 16 4:55 PM