Upload XLSX file in WebDynpro ABAP and view its content
You can see many posts in WebDynpro ABAP Form about reading an Excel file and showing its content in a WebDynpro ABAP Table, however many of them would be closed unanswered since it was not directly possible.
Now it is possible with this interesting and collaborative project ABAP2XLSX!!! Way to go guys for innovative thinking by starting this project!!!
- Install SAPLINK 1.4 or higher version http://code.google.com/p/saplink/downloads/list
- Import and activate needed plug-ins for DDIC , Function Group, Dev Class, Interfaces , WebDynpro ABAP http://code.google.com/p/saplink-plugins/downloads/list or https://cw.sdn.sap.com/cw/docs/DOC-145448
- Import most important Plug-in ABAP2XLSX https://cw.sdn.sap.com/cw/releases/86?container=1016 Installation guide https://cw.sdn.sap.com/cw/docs/DOC-137513
- An XLSX excel file with some data.
- Join ABAP2XLSX and SAPLINKGroup for more updates on these awsome discoveries https://cw.sdn.sap.com/cw/groups/saplink and https://cw.sdn.sap.com/cw/groups/abap2xlsx
Create a WD Component with File upload UI Element:
- Create a WD Component in SE80 with a window and a view
- In View controller, create a node” upload_content” and an attribute “file_content” to store Uploaded Excel file data in XSTRING format.
- Create a File Upload UI Element and bind its datasource property to XSTRING attribute.
- Create a Button and assign an action upload to it, when an excel file will be uploaded
- And here comes the magical code to read the excel 2007 (.xlsx) file.
METHOD onactionupload .
lo_current_controller ?= wd_this->wd_get_api( ).
* navigate from <CONTEXT> to <UPLOAD_CONTENT> via lead selection
* get element via lead selection
* get all declared attributes
worksheet = excel->get_active_worksheet( ).
WHILE row <= highest_row.
CATCHzcx_excel INTO ex. ” Exceptions for ABAP2XLSX
* report message
Sample Excel file Content
Sample WebDynpro ABAP Application accepting xlsx file:
Feel free to share your experience with Excel upload in WDA.