Most Common Use Case of ABAP2XLSX: Excel File to Internal Table

Aditya Aufar
2 min readNov 5, 2023

There are many ways ABAP can achieve transforming Excel File into Internal Table. However in this article I want to share one that I prefer by using the Open Source library using ABAP2XLSX.

The source code of this libary can be found here: https://github.com/abap2xlsx/abap2xlsx

The installation guide of this library to your SAP system can be found here: https://abap2xlsx.github.io/abap2xlsx/abapGit-installation

After the library has been installed to your SAP system, you can follow below steps and codes to transform your Excel file into Internal table. The codes below are the simplified version but still works as intended. I will share the complete demo sample program at the end of this article.

1. Set up an Internal Table that holds the data from the Excel file. As sample data, I create a simple Excel file as follows. It has 5 columns and 3 rows of data.

A variable that holds the number of rows is also declared because the transformation mechanism will involve loop row by row. More on this on step 5.

2. Set up a selection screen with a parameter to browse the Excel file.

3. Add AT SELECTION-SCREEN ON VALUE-REQUEST Event to the parameter after its declaration. This will enhance the parameter functionality further to make it able to browse the Excel file in the local PC.

4. Initialize the necessary variables and objects from the ABAP2XLSX library.

5. This is the main code on how to use the library to transform the data from Excel file to Internal Table. After the maximum row number from the Excel file obtained from the previous step, it loops row by row and uses the gv_row variable to hold the current index or loop count.

Now the Internal table gt_upload filled with the data from the Excel file.

Here’s the complete code.

This is just the tip of the iceberg of what ABAP2XLSX can do. Otherwise surely the preparation steps are too much just for uploading Excel files to the Internal table.

You can find all the demos of what ABAP2XLSX can do here:
https://github.com/abap2xlsx/demos

I hope this article is useful in any way.

--

--