csv_to_itab

in src/zgoog_i_bqtr_gen_repl_objl_im2.prog.abap [0:0]


  METHOD csv_to_itab.

    TYPES: BEGIN OF lty_tab,
             rec(1000) TYPE c,
           END OF lty_tab.
    DATA: lt_tab  TYPE TABLE OF lty_tab,
          ls_data TYPE lcl_tool=>mty_data.

    FIELD-SYMBOLS:  <ls_tab> TYPE lty_tab.


    cl_gui_frontend_services=>gui_upload(
      EXPORTING
        filename                = iv_file
      CHANGING
        data_tab                = lt_tab
      EXCEPTIONS
        file_open_error         = 1                " File does not exist and cannot be opened
        file_read_error         = 2                " Error when reading file
        no_batch                = 3                " Front-End Function Cannot Be Executed in Backgrnd
        gui_refuse_filetransfer = 4                " Incorrect front end or error on front end
        invalid_type            = 5                " Incorrect parameter FILETYPE
        no_authority            = 6                " No Upload Authorization
        unknown_error           = 7                " Unknown error
        bad_data_format         = 8                " Cannot Interpret Data in File
        header_not_allowed      = 9                " Invalid header
        separator_not_allowed   = 10               " Invalid separator
        header_too_long         = 11               " Header information currently restricted to 1023 bytes
        unknown_dp_error        = 12               " Error when calling data provider
        access_denied           = 13               " Access to File Denied
        dp_out_of_memory        = 14               " Not Enough Memory in DataProvider
        disk_full               = 15               " Storage Medium full
        dp_timeout              = 16               " Timeout of DataProvider
        not_supported_by_gui    = 17               " GUI does not support this
        error_no_gui            = 18               " GUI not available
        OTHERS                  = 19
    ).
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

    DELETE lt_tab INDEX 1.

    LOOP AT lt_tab ASSIGNING <ls_tab>.

      CLEAR ls_data.

      SPLIT <ls_tab>-rec AT ',' INTO  ls_data-trkey
                                      ls_data-dsname
                                      ls_data-ds
                                      ls_data-logsy
                                      ls_data-appl
                                      ls_data-iobj
                                      ls_data-odso
                                      ls_data-chain
                                      ls_data-trig
                                      ls_data-info
                                      ls_data-mfnam
                                      ls_data-active.
      APPEND ls_data TO ct_table.

    ENDLOOP.