Skip to Content
avatar image
Former Member

Transfer Excel file to internal table

Hi Experts,

I have one question to you. What i need -> open excel file and put content of it to internal table. I'm using for that

CALL METHOD cl_gui_frontend_services=>gui_upload

    EXPORTING

      filename = lv_fname <- path to file

     filetype = 'ASC'

    CHANGING

      data_tab = istr[].

At the end i can see, that istr[] has a content, but it is unreadible and looks like:

###-W###Ail###EZ#V###>⟂Q#exa##|I#########GH2'##6##§݊#rnT##N#'#

Could you please help me to solve this issue?

Please notice, that in EWM system i can't use FM such as

TEXT_CONVERT_XLS_TO_SAP,

ALSM_EXCEL_TO_INTERNAL_TABLE.

Thank you very much for help 😊

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Dec 24, 2012 at 10:43 AM

    hi,

    You can try this,

    * import ms-excel file into sap table

      CALL METHOD zcl_import_excel=>import_xls

        EXPORTING

          i_filename           = pa_file

          i_tablename          = so_tabl-low

        IMPORTING

          e_processed          = i_processed

        EXCEPTIONS

          error_import_excel   = 1

          error_updating_table = 2

          OTHERS               = 3.

      IF sy-subrc <> 0.

        IF NOT sy-msgno IS INITIAL.

          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

        ELSE.

          MESSAGE ID 'ZCONK' TYPE 'E' NUMBER '000'

          WITH 'Unknow error importing MS-Excel data'(m01).

        ENDIF.

      ELSE.

    *   show results on screen

        WRITE:/ 'Import table:'(t01), so_tabl-low.

        WRITE:/ 'Data source:'(t02), pa_file.

        WRITE:/ 'Number of created/changed records:'(t03), i_processed.

      ENDIF.

    hope it helps,

    Vinoth

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 24, 2012 at 11:17 AM

    Hi Vinoth,

    As far as i see from Method implementation, CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP' usus.

    I do not have this FM in my system, so how will this class and method work?

    Best Regards,

    Aleksandr

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Vinoth,

      As i said KCD_EXCEL_OLE_TO_INT_CONVERT doesn't exist (because i check all possible FM's 😊).

      @Vivek: I'm not sure that type of internal table influense on encoding.

      i've tried the same code but with .TXT and .CSV files and it shows data very good. Problem only with XLS and XLSX