

READ TABLE lt_worksheets INTO DATA(lv_woksheetname) INDEX 1.ĭATA(lo_data_ref) = lo_excel_ref->if_fdt_doc_spreadsheet~get_itab_from_worksheet( Lo_excel_ref->if_fdt_doc_spreadsheet~get_worksheet_names( Lo_excel_ref = NEW cl_fdt_xl_spreadsheet(

"as excel file will already be in xstringĭATA : lo_excel_ref TYPE REF TO cl_fdt_xl_spreadsheet. "if you are using cl_fdt_xl_spreadsheet in odata then skips this step READ TABLE lt_file_table INTO ls_file_table INDEX 1. PARAMETERS : p_file TYPE ibipparms-path OBLIGATORY,ĪT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.ĬALL METHOD cl_gui_frontend_services=>file_open_dialog SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
Download excel vba takes files from ftp code#
Obviously, you would have to adapt the code to use it in your application but you get the idea of how it works. I have structured the logic in standalone SE38 program so you can copy-paste and have it ready for testing in your system. In other words, these FMs will only work when you are running your program in SAP WebGUI. Also, this Office Integration solution ( along with a range of other features) is not supported in WebGUI. There are some function modules (TEXT_CONVERT_XLS_TO_SAP) available in SAP which can help you read data from XLS/XLSX file but these are based on Office Integration and requires MS Office installed on your PC. However, if you have data over multiple worksheets then you would have to call method GET_ITAB_FROM_WORKSHEET in the loop for each worksheet. In most of the case, you would read the first worksheet name and call method IF_FDT_DOC_SPREADSHEET~GET_ITAB_FROM_WORKSHEET with worksheet name to get data in a dynamic internal table. Method GET_WORKSHEET_NAMES returns internal table. This processing of file as XSTRING is particularly useful in case of Fiori Apps, OData CREATE_STREAM method pass uploaded file already in XSTRING which can be simply passed on to class CL_FDT_XL_SPREADSHEET constructor.Īfter instantiating the class get list of worksheets in the file using IF_FDT_DOC_SPREADSHEET~GET_WORKSHEET_NAMES. This approach will also work with OData.Ĭode is based on class CL_FDT_XL_SPREADSHEET which can be instantiated using the file name and excel file in XSTRING variable. The method shown in the blog will work in SAP GUI and Webgui (program launched from Fiori Launchpad). ABAP code to upload XLSX file to SAP using ABAP.
