Read an excel file from AL11 Directory

Introduction :

There are scenarios where the user will upload a file in the Application Server which needs to be consumed to manipulate that data (such as updating in a table or sending it as a mail). In that case, we can use the DATASET to read the file in the Application Server.

Problem Statement:

The user uploads an Excel File in the Application Server. That Excel file is picked from the list of files in the Application server and stored in an internal table and then the data is uploaded to a custom table in SAP.

Solution:

Step 1: Know the directory in which the file is stored.

DATA : lv_dir TYPE eps2filnam.
lv_dir = '/VTS/DEV/'.

Step 2: Get the list of files in that Directory path using the Function Module EPS2_GET_DIRECTORY_LISTING

Step 5: Now the excel data is stored in an internal table which can be uploaded into any table of the same structure.

MODIFY ztest FROM it_Tab.

Conclusion:

I hope this blog post helped you to get an idea on how to read an excel from the Application Server and store it in an internal table which can further be used to update a table. Apart from Excel, PDF, as well as an Image, can also be read from the Application Server. It can be stored in an XSTRING format.

Assigned tags

Related Blog Posts

Related Questions

This solution will not read data from a .xlsx or .xls file and allow its manipulation. For that you need abap2xlsx. Or for the data to be saved as csv or tab delimited – which are text files, not Excel files.