This function can be used to transfer the CSV to an internal table.
The CSV file should be given as a string and the internal table should be provided as empty parameters to this function. In some CSV files, delimiters can vary between commas and semicolons. These differences are also considered by the function. By default, semicolons are used.

  
function zcsv_to_itab.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(CSV) TYPE  STRING OPTIONAL
*"     REFERENCE(HEADER) TYPE  CHAR1 DEFAULT 'X'
*"     REFERENCE(SEPARATE) TYPE  CHAR1 DEFAULT ';'
*"  TABLES
*"      ITAB_DATA
*"----------------------------------------------------------------------

  data : lt_csv   type standard table of string,
         lt_lines type standard table of string.

  field-symbols : <fs_itab_value> type any.

  split csv at cl_abap_char_utilities=>newline into table lt_csv.

  loop at lt_csv into data(ls_csv).
    if sy-tabix eq 1 and header = 'X'.
      continue.
    endif.
    split ls_csv at separate into table lt_lines.
    append initial line to itab_data assigning field-symbol(<fs_itab_data>).
    loop at lt_lines into data(ls_line).
      data(lv_comp_index) = sy-tabix + 1.
      assign component lv_comp_index of structure <fs_itab_data> to <fs_itab_value> .
      if sy-subrc eq 0.
        <fs_itab_value> = ls_line.
      endif.
    endloop.
  endloop.

endfunction.