Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Transfer Excel file to internal table

Former Member
0 Kudos

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

7 REPLIES 7

vinoth_aruldass
Contributor
0 Kudos

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

0 Kudos

Hi,

unfortunatly i do not have class zcl_import_excel in my system.

As far as i see cl_gui_frontend_services=>gui_upload this is only one way and it doesn;t work correct.

BR

Aleksandr

0 Kudos

hi,

Please refer the link you need to create zcl_import_excel.

http://wiki.sdn.sap.com/wiki/display/Snippets/Import+MS-Excel+file+directly+into+SAP+Table

hope it helps,

Vinoth

Former Member
0 Kudos

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

0 Kudos

hi ,

check with

KCD_EXCEL_OLE_TO_INT_CONVERT

thr?

0 Kudos

Hi Aleksandr,

Check excel file and internal table both fields are write in same manner then call gui_upload method .

Regards

Vivek

0 Kudos

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