Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 

FM FILE_READ_AND_CONVERT_SAP_DATA - file is being opened

0 Kudos

Dear experts,

I'm using the FILE_READ_AND_CONVERT_SAP_DATA FM in order to upload an Excel file into an internal table and for some reason, the file itself is being opened and the user is required to close its instance. I didn't see any parameter which handles it.

Does anyone have an idea how I can make this Excel not open?


Active Contributor
0 Kudos

Hi shmuliks

I am note sure any parameter to handle this. However you can do as follows:

Call the following function to confirm the file is open / close and instruct the user to close it.

DATA: return TYPE i.
    ss_wavfile     = <File name>
    ss_wavfilepath = <file path>
    ss_ret         = return.
IF return = 1.  
  MESSAGE 'Your File is already open, Please close it' TYPE 'E' DISPLAY LIKE 'S'.

Note : Filepath either you can fix it a predefined place, or you can extract it from the file selection routine.



Active Contributor
0 Kudos

Probably this function module works using OLE, it opens Excel (whatever it's in background or foreground of Windows) to read the Excel file.

Why Excel is choosing to open in foreground or background is something that is beyond my knowledge (ask a Windows developer), but if you want to avoid that, you can choose community tool abap2xlsx which is not based on OLE.

Active Contributor

Excel most likely opens because this fm is one of the many who use OLE2 to control an Excel instance on the PC in order to extract data, which is... not a terribly efficient way to do it, in my opinion.

You could try with abap2xlsx, which is able to read and write real XLSX files and also works in background without requiring a real Excel installation. It comes with plenty of sample programs to get you started. It is the best kept secret in the ABAP world, it's our Fight Club 😄