‎2019 Feb 16 7:50 AM
Please someone help me to read .Xls(only .Xls not a .xlsx) file from application server (al11).
I tried with this code https://praveensg8.files.wordpress.com/2015/04/reading-excel-file-from-application-server-into-abap-...
and cl_xlxs_document class to do this but it is not working properly.
‎2019 Feb 16 11:44 AM
‎2019 Feb 16 7:07 PM
Matthew is right, the code you tried says it's for both XLS (implied that it means the binary file format) and XLSX, but in fact it works only for XLSX ! The binary file formats can be read only in dialog using OLE (if you use SAP ERP, you may use the function module TEXT_CONVERT_XLS_TO_SAP which does the OLE for you)
.
‎2021 Feb 28 2:23 PM
You can use this code
DATA: lv_app_server_file TYPE rlgrap-filename,
ls_file_data TYPE string,
lt_file_data TYPE truxs_t_text_data,
lv_file_separator TYPE c,
lv_mess TYPE string,
lv_codepage TYPE cpcodepage.
DATA: lt_tab_excel TYPE STANDARD TABLE OF alsmex_tabline.
lv_app_server_file = pa_file.
CALL FUNCTION 'NLS_GET_FRONTEND_CP'
EXPORTING
langu = sy-langu
fetype = 'MS'
IMPORTING
frontend_codepage = lv_codepage
EXCEPTIONS
illegal_syst_codepage = 1
no_frontend_cp_found = 2
internal_or_db_error = 3
OTHERS = 4.
OPEN DATASET lv_app_server_file FOR INPUT IN TEXT MODE ENCODING UTF-8 MESSAGE lv_mess.
DO.
READ DATASET lv_app_server_file INTO ls_file_data.
IF sy-subrc = 0.
APPEND ls_file_data TO lt_file_data.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET lv_app_server_file.
lv_file_separator = ';'.
CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'
EXPORTING
i_field_seperator = lv_file_separator
i_tab_raw_data = lt_file_data
i_line_header = 'X'
TABLES
i_tab_converted_data = gt_tab
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.