SAP Save As Dialogue won't respond to UIPath

@bingshui-hl @LIM_ENG_KEONG @LevKushnir

Hello Bingshui, Lim and Lev,

it is definitely a question of the version of the SAP_BASIS component.

I analyzed the ABAP code and I found the difference in the method FILE_SAVE_DIALOG from the class CL_GUI_FRONTEND_SERVICES, which is called from the function module XML_EXPORT_DIALOG from the method DOWNLOAD from the class CL_SALV_EXPORT_XML_DIALOG.

Here the differentiating ABAP code:

 call method IS_SCRIPTING_ACTIVE receiving result = rt_value EXCEPTIONS others = 1.
 if rt_value = 1.

*   check the registry key
    call method cl_gui_frontend_services=>registry_get_dword_value
      exporting root = cl_gui_frontend_services=>HKEY_CURRENT_USER
                key = 'Software\SAP\SAPGUI Front\SAP Frontend Server\Scripting'
                value = 'ShowNativeWinDlgs'
      importing reg_value = RCCU
      exceptions
        others = 1.

    call method cl_gui_frontend_services=>registry_get_dword_value
      exporting root = cl_gui_frontend_services=>HKEY_LOCAL_MACHINE
                key = 'Software\SAP\SAPGUI Front\SAP Frontend Server\Scripting'
                value = 'ShowNativeWinDlgs'
      importing reg_value = RCLM
      exceptions
        others = 1.

    call method cl_gui_cfw=>flush.

    if RCCU = 0 or ( RCCU ne 1 and RCLM ne 1 ) .

      RT_VALUE = 'X'.
      call FUNCTION 'GUI_FILE_SAVE_DIALOG'
        exporting
          WINDOW_TITLE      = WINDOW_TITLE
          DEFAULT_EXTENSION = DEFAULT_EXTENSION
          DEFAULT_FILE_NAME = DEFAULT_FILE_NAME
          WITH_ENCODING     = WITH_ENCODING
          INITIAL_DIRECTORY = INITIAL_DIRECTORY
          FILE_FILTER       = FILTER
        importing
          FULLPATH      = FULLPATH
          FILE_ENCODING = FILE_ENCODING
          USER_ACTION   = USER_ACTION.
    endif.
 endif.

As you can see at first a method is called which detects is scripting is active or not. If it is active it call the function module GUI_FILE_SAVE_DIALOG instead of FileSaveDialog of the SAPInfo Control module, which calls the native Windows dialog. This works independently from the SAP GUI for Windows version and from its settings.

Bingshui and Lim, which version of the SAP_BASIS package do you use?
You can detect the version as I described above.

Now we know the reason and we see that the behavior of the SAP GUI for Windows it is also dependent from the SAP backend, in this case from the SAP_BASIS component.

Best regards
Stefan

Addition
01.05.2021
The function Module XML_EXPORT_DIALOG contains an input parameter I_APPLICATION, if a related application can be detected it will be opened after the download. The method GET_PC_APPLICATION of the class CL_SALV_GUI_DATA_PUBLISHER do that.

method get_pc_application.

  check cl_salv_gui_data_publisher=>c_gui_type_windows EQ gui_type.

  if platform eq cl_gui_frontend_services=>platform_mac
  or platform eq cl_gui_frontend_services=>platform_macosx
  or platform eq cl_gui_frontend_services=>platform_linux.  "Linux
    exit.
  endif.

  if frontend eq cl_alv_bds=>mc_excel_frontend
  or frontend eq cl_alv_bds=>mc_xlsx_frontend
  or frontend eq cl_alv_bds=>mc_mhtml_frontend.
    data excel_file type string.
    call method cl_gui_frontend_services=>registry_get_value
      exporting
        root      = cl_gui_frontend_services=>hkey_classes_root
        key       = 'ExcelWorksheet\protocol\StdFileEditing\server'
        value     = ''
      importing
        reg_value = excel_file.
  endif.
  value = excel_file.
endmethod.

As we can see it detects, in case of Excel download, via a registry entry the Excel application and the FM XML_EXPORT_DIALOG starts the application via cl_gui_frontend_services=>execute.

What does this mean: An automation workflow that downloads Excel data from an SAP back-end system behaves differently in dependency if an Excel application is installed or not.

Addition
09.07.2021
Today I found an SAP OSS Note 2038061 - File open dialogs cannot be handled in SAP GUI Scripting, which describes this point. The solution is an update of the SAP_BASIS component.

1 Like

Hi Stefan,
Thank you for your support. I am using SAP_BASIS 740.

So how can we move forward?

1 Like

@LIM_ENG_KEONG

Hello Lim,

thanks for your reply.

Now we know that between SAP_BASIS release 740 PL3 and 751 PL19 a change has been made to the dialog for XML export in ALV whether SAP GUI Scripting is used or not. This is a very important insight @LevKushnir.

How many records do you want to export from your table?

I tried the same approach as you and it works so far, as long as the dialog appears within the timeout of 30 seconds. The Save as… dialog is a normal window and can also be treated with the same automatisms. The only difference here is that the SAP backend prepares the data for export. If you have a lot of data, this also takes a lot of time. If you exceed the timeout, the error message will appear.

So I assume you want to export a larger amount of data and you are reaching the timeout before the SAP backend prepared the data. If this is the case you can find a great discussion, to handle this kind of requirement, here: How to Pause Automation Until Required Window Appears.

@bingshui-hl could that also been the reason for you?

Let us know your results.

Best regards
Stefan

1 Like

Hello Stefan
my component version as attached

image

Maybe I’m not descript my problem clearly, my Save as dialog can popup, after that I want to us “type into” active to write file name in Save as dialog. my exact problem is type into active not work. The process stay at Save as dialog, no stop and no error message.

1 Like

Hello Stefan and Lev
Good news, I use right “click” instead " Select Menu Item" active to download data, than the process go smoothly.

1 Like

Hi Stefan,
In my sample code, only < 10 records to be export. The Save As dialog actually prompted almost immediately after the menu selection. The problem is the automation process just stop when the Save As dialog box prompt, and then nothing happened. the TypeInto (change file name) and Click (Save) event is not carry out. seems like the robot is not able to control the Save As dialog box…

1 Like

hello Lim
Do you also use SAP activities? Or you can try others instead.

1 Like

Hi BingShui,
For the menu i am using SAP activity. after the Save As dialog box, i just use the normal TypeInto and Click activities.
What other activities i can use to download data from SAP into Excel file in UIPath?

1 Like

right click the data you want to download, select local file/spreadsheet…
use click instead SAP activities.

1 Like

Hi BingShui,
I see. Ok i will try this out. Thanks for your advise.

1 Like

@bingshui-hl @LIM_ENG_KEONG

Hello Bingshui and Lim,
I tried that and it works without any problems. Here my approach.

The Save as… dialog is in the context of the download of XML files from an SAP system no problem.

Please post the parts of you XAML file which contains the error, so we can take a look at it.

Best regards
Stefan

Hi BingShui,
I am able to call the Save As dialog box using the right mouse click method. However still i cannot input the file name. I use TypeInto event to change the file name directly but nothing happen. Then i use the Send Hot Key event (Alt+n) to move the cursor to the file name column. But the robot automatically save the default file name “Export.xlsx” and system prompt me “Export.xlsx” already existed error although i actually use TypeInto event to replace the filename. Did you change the file name when you export to Excel? how do you did it?
image

Good day all,
It is working by using the right click options.
thank you for your help.

1 Like

I have tried with both right click approach and using menu item.
SAP behaves weirdly.
Some time it shows SAP popup; Sometimes it shows the windows popup

HI @MariaJosephina

the behaviour you are describing in correct.

  1. perform this settings SAP Save As Dialogue won't respond to UIPath - #5 by LevKushnir

  2. This is how SAP works, see the Modal settings in the point 1

  • when open Popup with your hands, you will get Windows Popup
  • when open Popup with Robots, you will get SAP Popup

Best regards, Lev

1 Like

The SAP version I am using is 740.
There I cannot see these menu option to change settings.
Could you please help

From the SAP Easy Access window, click Settings under the Help menu.

1 Like

@LevKushnir
Even after following that, i am getting the same windows poopup.
image

To be able to understand your automation challenge better, please share following information:

  • SAP WinGUI version
  • SAP WinGUI transaction
  • UiPath Studio version
  • UiPath UiAutomation Activity version

In addition share the following screenshots:

  • SAP WinGUI screenshot - Full screen (you can blurry the business information)
  • SAP UiPath Studio - selectors of SAP element

Best regards, Lev

1 Like

Iam able to find selectors for the sap window popup, after trying with uiframeworks : Active accessibility and UI automation (from Ui Explorer window).
Also find below the details you requested for.
Also do you have any idea on why SAP poup window is getting changed to windows popup (while downloading files from SAP)

  • SAP WinGUI version :740
  • SAP WinGUI transaction : ZEMPMASTER,ZATTENDANCE, ZPUNCHING_DATE
  • UiPath Studio version 2020.10.6
  • UiPath UiAutomation Activity version 20.10.9

SAP WinGUI screenshot