Native Microsoft Windows dialogs in SAP

In one of my articles I showed You how to turn off the pop up message boxes in Accessibility & Scripting options , but didn’t really describe about the 3rd checkbox below Enable scripting. In this article I’m going to show You how Show native Microsoft Windows dialogs works in SAP.

The easiest way to compare will be to show You how the dialog presents depending on the option is on or off. To do that I’ll go to the MVKE table in SAP, type random product to see any data and try to save this as spreadsheet.

Show native Microsoft Windows dialogs – ON

As the first case I consider the Windows native dialogs.

After choosing the spreadsheet save option the dialog popped up.

It looks like standard Windows Save As dialog window.

I tried also to record this using SAP Script Recorder, but there were only lines “before” the dialog, nothing else.

session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/cntlRESULT_LIST/shellcont/shell").pressToolbarContextButton "&MB_EXPORT"
session.findById("wnd[0]/usr/cntlRESULT_LIST/shellcont/shell").selectContextMenuItem "&XXL"

Show native Microsoft Windows dialogs – OFF

Later on, still staying in the MVKE table, I turned off the native Windows dialogs.

So after choosing the spreadsheet I could see SAP GUI dialog.

I used also the Script Recorder to record the dialog and the Generate button click.

session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/cntlRESULT_LIST/shellcont/shell").pressToolbarContextButton "&MB_EXPORT"
session.findById("wnd[0]/usr/cntlRESULT_LIST/shellcont/shell").selectContextMenuItem "&XXL"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "export3.XLSX"
session.findById("wnd[1]/usr/ctxtDY_PATH").setFocus
session.findById("wnd[1]/usr/ctxtDY_PATH").caretPosition = 40
session.findById("wnd[1]/tbar[0]/btn[0]").press

The SAP GUI dialog actions were recorded.

Summary

The best summary would be the quote from SAP Help site:
Since Microsoft Windows’ native system dialogs (Save As Open) cannot be recorded when a script is run, they are replaced automatically with predefined SAP GUI dialogs. You can disable this procedure by selecting option, Show Native Microsoft Windows Dialog. The native dialog boxes are then displayed, but cannot be accessed via SAP GUI scripting.

Author: Tomasz Płociński

I'm very advanced in VBA, Excel, also easily linking VBA with other Office applications (e.g. PowerPoint) and external applications (e.g. SAP). I take part also in RPA processes (WebQuery, DataCache, IBM Access Client Solutions) where I can also use my SQL basic skillset. I'm trying now to widen my knowledge into TypeScript/JavaScript direction.

18 thoughts on “Native Microsoft Windows dialogs in SAP”

  1. That works for “Export” action but for example I need to “Create attachment” and this still open native Microsoft windows even with the “Show…” option disabled.

  2. Thanks for the explanation anyways. I hope you can help me with my issue. This web is so helpfull.

    1. Hello Javier
      Could You describe more about “Create attachment” thing and how could I help You? 🙂

      1. I also have this issue with transaction OAAD, which I can use to manually attach files to existing Workflow change requests. See my code below:

        session.findById(“wnd[0]/tbar[0]/okcd”).Text = “/nOAAD”
        session.findById(“wnd[0]”).sendVKey 0
        session.findById(“wnd[0]/usr/btnTOA_OAAD-EA_CREA”).press
        session.findById(“wnd[0]/usr/ctxtTOAOM-SAP_OBJECT”).Text = “BUS2250”
        session.findById(“wnd[0]/usr/ctxtTOAOM-AR_OBJECT”).Text = myType
        session.findById(“wnd[0]/tbar[1]/btn[8]”).press
        session.findById(“wnd[1]/usr/sub:SAPLOA12:0200/ctxtOBJID-VALUE[0,21]”).Text = myCR
        session.findById(“wnd[1]/usr/sub:SAPLOA12:0200/ctxtOBJID-VALUE[1,21]”).Text = “1”
        Set WShell = CreateObject(“WScript.Shell”)
        session.findById(“wnd[1]/tbar[0]/btn[0]”).press
        ‘Command above opens up a native Windows dialog for the selection of what file I want to attach
        ‘But the code itself hangs here.
        ‘If I put a pause on the next line below before execution, run the code, and manually close and re-open the dialog windows while paused, then resume the code, it will find the dialog and execute next steps.
        Do Until Success = True
        Success = WShell.AppActivate(“Storing Files in Documents”)
        Loop

        WShell.AppActivate (“Storing Files in Documents”)
        WShell.SendKeys “+{TAB 4}”
        WShell.SendKeys “” & myFolder
        WShell.SendKeys “{TAB 5}”
        WShell.SendKeys “” & myFile

        Obviously, having to pause the code to close and reopen the dialog pretty defeats the purpose of executing the script.

        1. Have You tried to record Save as dialog window according to article?

          1. Yes, I did. It did not change this aspect of the coding. I guess it affects “SaveAs” dialog but not this one.

          2. I am sorry, but I don’t have access to this transaction and I can’t reproduce your case =(

          3. Thanks for trying. If anyone else know how to solve this, please share. And BTW, the same dialog opens with t-code FB03, by which you can also attach files to FI document. The code for this would look like below:

            session.findById(“wnd[0]”).resizeWorkingPane 187, 30, False
            session.findById(“wnd[0]/tbar[0]/okcd”).Text = “/nfb03”
            session.findById(“wnd[0]”).sendVKey 0
            session.findById(“wnd[0]/usr/txtRF05L-BELNR”).Text = “???”
            session.findById(“wnd[0]/usr/ctxtRF05L-BUKRS”).Text = “???”
            session.findById(“wnd[0]/usr/txtRF05L-GJAHR”).Text = “2022”
            session.findById(“wnd[0]”).sendVKey 0
            session.findById(“wnd[0]/titl/shellcont/shell”).pressContextButton “%GOS_TOOLBOX”
            session.findById(“wnd[0]/titl/shellcont/shell”).selectContextMenuItem “%GOS_VIEW_ATTA”
            session.findById(“wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell”).pressToolbarContextButton “%ATTA_CREATE”
            session.findById(“wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell”).selectContextMenuItem “%GOS_ARL_LINK”
            session.findById(“wnd[2]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell”).hierarchyHeaderWidth = 268
            session.findById(“wnd[2]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell”).selectItem “0000000017”, “HITLIST”
            session.findById(“wnd[2]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell”).ensureVisibleHorizontalItem “0000000017”, “HITLIST”
            session.findById(“wnd[2]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell”).doubleClickItem “0000000017”, “HITLIST”
            ‘Dialog opens and code hauts here
            session.findById(“wnd[3]/usr/sub:SAPLSPO4:0300/txtSVALD-VALUE[1,21]”).Text = “Test”
            session.findById(“wnd[3]/tbar[0]/btn[0]”).press
            session.findById(“wnd[2]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[1]/shell”).setSelectionIndexes 86, 112
            session.findById(“wnd[2]/tbar[0]/btn[0]”).press

  3. Hello Tomasz,

    If I would like to use the MS dialog box (for example the Save as dialog box) and be able to control that, how do I do it?

    Thanks for the reply.

  4. I want to print the pdf documents from SAP CV04N to my local pdf file.
    It will also pop up windows “save as dialogue” when I press “print” button, so how could I know the codes for defining file name and generate save button?

    1. Is that what I wrote in the article not helpful at all?
      I already described there how to define file name and click the button.

  5. Boa noite,
    Tenho um problema que está difícil de resolver!
    Quando eu gero uma planilha com base no SAP, após baixar ele abre automaticamente a planilha baixada.
    Gostaria de fechar essa planilha ou que apenas salve e não abra.
    Poderia me ajudar por favor?

  6. Hi Tomasz

    I unchecked the “show native windows dialogs” button however native windows dialogs still appear even while recording a script. Do you think this is an application error, should I reinstall SAP GUI?

    Thank you

    1. Hello Yair
      but what is up with the recording? Apart that got everything You want?

      1. Hi Tomasz

        Thanks for replying

        I’m trying to create a simple script to download a list into a spreadsheet however even though the “show native windows dialogs” box is unchecked whenever I try to export to an spreadsheet the native windows dialog pops up anyway and the script recording stops and can’t export the file

Leave a Reply

Your email address will not be published. Required fields are marked *