Excel XLSX Upload – Unified approach for older ABAP Version

It is all about XLSX files and a unified approach to upload XLSX files into SAP GUI and Webdynpro ABAP / Floor Plan Manager using XSL Transformation.

In this document, I explained the steps to import the XLSX file.

View Document

If you are on the higher version, you can make use of the APIs

METHOD import. CHECK ip_xlsx_filename IS NOT INITIAL. TRY. DATA(lv_xlsx_data) = cl_openxml_helper=>load_local_file( ip_xlsx_filename ). DATA(lo_xlsx_data) = load_xlsx_data( ip_xlsx_data = lv_xlsx_data ip_xlsx_filename = ip_xlsx_filename ). IF lo_xlsx_data IS BOUND. rt_jobdoc_data = me->do_mapping_import( lo_xlsx_data ). ENDIF. CATCH cx_openxml_not_found. ENDTRY. ENDMETHOD. METHOD load_xlsx_data. TRY. DATA(lo_xlsx_ref) = NEW cl_fdt_xl_spreadsheet( document_name = ip_xlsx_filename xdocument = ip_xlsx_data ). IF lo_xlsx_ref IS BOUND. lo_xlsx_ref->if_fdt_doc_spreadsheet~get_worksheet_names( IMPORTING worksheet_names = DATA(lt_worksheets) ). ro_xlsx_data = lo_xlsx_ref->if_fdt_doc_spreadsheet~get_itab_from_worksheet( CONV #( text-001 ) ). ENDIF. CATCH cx_openxml_not_found cx_fdt_excel_core. ENDTRY. ENDMETHOD. METHOD do_mapping_import. DATA: ls_jobdoc_data TYPE if_jsm_jobdoc_mass_maintenance=>ts_jobdoc_master, lt_jobmon_data TYPE if_jsm_jobdoc_mass_maintenance=>tt_jobdoc_master, lv_language_iso TYPE char2, lv_language_sap TYPE lang1. FIELD-SYMBOLS: <lt_worksheet_data> TYPE STANDARD TABLE, <lv_data> TYPE string. ASSIGN it_data->* TO <lt_worksheet_data>. LOOP AT <lt_worksheet_data> ASSIGNING FIELD-SYMBOL(<ls_worksheet_data>) FROM 2. APPEND INITIAL LINE TO lt_jobmon_data ASSIGNING FIELD-SYMBOL(<ls_jobdoc_data>). DO 52 TIMES. ASSIGN COMPONENT sy-index OF STRUCTURE <ls_worksheet_data> TO <lv_data>. ASSIGN COMPONENT sy-index OF STRUCTURE <ls_jobdoc_data> TO FIELD-SYMBOL(<lv_value>). <lv_value> = <lv_data>. ENDDO. ENDLOOP.
...
... ENDMETHOD