12-24-2012 10:37 AM
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
ALSM_EXCEL_TO_INTERNAL_TABLE.
Thank you very much for help
12-24-2012 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
12-24-2012 10:56 AM
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
12-24-2012 11:04 AM
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
12-24-2012 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
12-24-2012 11:30 AM
12-24-2012 11:37 AM
Hi Aleksandr,
Check excel file and internal table both fields are write in same manner then call gui_upload method .
Regards
Vivek
12-24-2012 12:16 PM
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