cancel
Showing results for 
Search instead for 
Did you mean: 

SAP GUI Scripting - Export to MHTML

Former Member
0 Kudos

Hi guys.

I've been trying to export SAP tables via SAP GUI scripting however it seems the recorder cannot export the tables in MHTML format. It stops at the pop-up and that's it. I did try the export to local file but there is an extra column and extra row that is unneeded. Currently, I export the tables through txt format but I encountered I problem later on when importing the file in Print Image format because apparently, the field lengths in SAP change from time to time, at least in our case. So the best approach will be to use the MHTML format. So can anyone help me how to export the table in MHTML and save it. Thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Stefan,

Red corner brackets appear. The thin ones but not the red thick boxes from your analyzer so I guess it's not possible. Thanks anyway.

Brit

Former Member
0 Kudos

Hey Brit,

just a guess:

Maybe the problem is that the export dialogue is not gui-modal in your SAP Basis release. If this is the case, i propose a workaround using windows api functions, see here:

Hope that helps!

Stefan

stefan_schnell
Active Contributor
0 Kudos

Hello Brit,

welcome to the Scripting Languages forum.

In my case it works on this way, to export data from an ALV grid to MHTML format.

Here the code:

'Opens export dialog on SE16 with ALV grid

session.findById("wnd[0]/tbar[1]/btn[43]").press

'Selects MHTML

session.findById("wnd[1]/usr/radRB_1").setFocus

session.findById("wnd[1]/usr/radRB_1").select

session.findById("wnd[1]/tbar[0]/btn[0]").press

'Sets path and file

session.findById("wnd[1]/usr/ctxtDY_PATH").text = "C:\Users\Bambi\Documents\SAP\SAP GUI\"

session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "export.MHTML"

'Exports data to file

session.findById("wnd[1]/tbar[0]/btn[0]").press


Please try it and let us know your results.


Cheers

Stefan


Former Member
0 Kudos

Hi Stefan,

thanks for the reply. I added the script up to the up the list view and ended up with the save prompt screen and then it stopped there. I tried to change the directory in the script but it appears I can't because it goes to a default folder then you have to go the directory folder you want and then click save. this is in contrast to the export command where you specifically identify your folder path and file name. The thing is I want to automate everything up to saving of the table and then going back to the main screen and then doing it again for another 3 tables.

The current solution I am seeing is that I have export it as a spreadsheet and then launch an excel macro to clean up the spreadsheet before importing to ACL.

Currently my script works in the .txt format and importing it to ACL as a print image but it appears that field lengths change and the import script is affected.

stefan_schnell
Active Contributor
0 Kudos

Hello Brit,

thanks for your reply. It is possible for you to use Scripting Tracker from here to analyze your SAP GUI for Windows environment? Open the dialog, start Scripting Tracker and scan all scripting objects.

If you see your environment like this example above, it should be possible for you to set the path, the file name and to press a button automatically. If you don't see wnd[1] in the object hierarchy of Scripting Tracker, you can't set the fields and press the buttons.

Let us know your results.

Cheers

Stefan