[ABAP] Interne Tabelle in CSV wandeln / speichern

Variante 1 (cl_icf_csv)

DATA: it_mara TYPE STANDARD TABLE OF mara.

...

* iTab nach CSV-Datei konvertieren und speichern
cl_icf_csv=>request_for_write_into_csv( it_data = it_mara
                                        iv_hdr_struct_name = 'MARA'
                                        iv_init_dir = 'c:\temp'
                                        iv_file_name = 'test.csv' ).

Variante 2 (SAP_CONVERT_TO_CSV_FORMAT)

DATA: it_csv_output TYPE truxs_t_text_data.

SELECT FROM sflight
  FIELDS *
  WHERE CARRID = 'AA'
  INTO TABLE @DATA(it_sflight).

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
  EXPORTING
    i_field_seperator    = ';'
*   I_LINE_HEADER        =
*   I_FILENAME           =
*   I_APPL_KEEP          = ' '
  TABLES
    i_tab_sap_data       = it_sflight
  CHANGING
    i_tab_converted_data = it_csv_output
  EXCEPTIONS
    conversion_failed    = 1
    OTHERS               = 2.

IF sy-subrc = 0.
  cl_demo_output=>write_data( it_csv_output ).
  cl_demo_output=>display( ).
ENDIF.