Create an SAP desktop flow with Power Automate Desktop

Screenshot of Power Automate Desktop designer window with a UI flow with two steps run application and wait.

  1. To create a desktop flow, open Power Automate Desktop, and then select New flow.

  2. Enter a name for the desktop flow, and then select Create.

    Screenshot of Power Automate Desktop dialog for naming a new flow.

  3. Select Variables in the Power Automate Desktop designer.

    Screenshot of Power Automate Desktop variables icon on the right of the screen.

  4. Select the plus sign (+), and then select Input.

    You'll create several input variables which will be passed into this desktop flow from a cloud flow.

    Screenshot of the create variable UI in Power Automate Desktop.

  5. First, we'll create a few technical SAP variables, which will be needed in almost all SAP-based automation flows. For each variable in the following list, enter the Variable name, External name and Description, and then select Update.

    • SAPPassword

    • SAPUser

    • SAPClient

    • SAPSystemId

    Screenshot of Add a new variable dialog.

  6. Next, create the following use-case-specific variables.

    • EmployeeId

    • AddressType

    • EffectiveDate

    • Street

    • City

    • State

    • ZipCode

    • CountryCode

    Screenshot of the variables windows with the created variable names.

  7. Next, we'll create our first process action. Search for, and then drag the Run application action onto the design surface.

    Screenshot of a Run Application action dialog that has been added to the authoring canvas.

  8. Enter the following information into the parameter list, and then select Save.

    • Application Path: C:\Program Files (x86)\SAP\FrontEnd\SapGui\sapshcut.exe

    • Command line arguments: start -system=%SAPSystemId% -client=%SAPClient% -user=%SAPUser% -pw=%SAPPassword% -maxgui

    • Window style: Maximized

    • After application launch: Wait for application to complete

    Screenshot of Run Application dialog with parameters entered.

  9. Search for the Wait action, drag it onto the designer, enter 10 (seconds) into the Duration field, and then select Save.

    Screenshot of the Power Automate Desktop designer window with a Wait action dialog open.

  10. Now, open SAP GUI and sign in to your system of choice.

  11. In Power Automate Desktop, search for the populate action in the Actions search box, and then drag the Populate text field in window action onto the canvas.

    Screenshot of adding the Populate text field in window action after the Wait action in the Power Automate Desktop designer window.

  12. Select Add new UI element.

    Screenshot of the Populate text field in window dialog with Add a new UI element button.

  13. The Tracking session dialog opens, which tracks the individual controls you select on a screen.

    Screenshot of the Tracking session dialog.

  14. Select the SAP main window to give it focus.

    Screenshot of the SAP Easy Access window.

  15. Hover over the transaction code field. When a red frame surrounds Gui Ok Code Field, hold down Ctrl while you click. This adds the control to the UI elements list in the Add UI elements dialog in Power Automate Desktop.

    Screenshot of the SAP Easy Access window with transaction code field selected.

    Screenshot of the Tracking session dialog with the GUI O K Code Field o k c d added to it.

  16. In the SAP window, hover over the green check mark button, and then hold down Ctrl and click.

    Screenshot of the SAP Easy Access window with the check mark next to the transaction code field selected.

  17. Enter transaction code PA30 into the list box, and then select the green check mark button.

    Screenshot of the SAP Easy Access window with PA30 entered into the transaction code field and the field selected.

  18. We'll continue our field selection process on the next screen.

    Screenshot of the Maintain HR Master Data window of the SAP Easy Access application.

  19. Select the following fields and button:

    Screenshot of the Maintain HR Master Data window of the SAP Easy Access application. The Personnel number field is selected.

    Screenshot of the Maintain HR Master Data window of the SAP Easy Access application. In the Period area of the screen the From field is selected.

    Screenshot of the Maintain HR Master Data window of the SAP Easy Access application In the Direct Selection area of the screen the Infotype field is selected.

    Screenshot of the Maintain HR Master Data window of the SAP Easy Access application. In the Direct Selection area of the screen the STy field is selected.

    Screenshot of the Maintain HR Master Data window of the SAP Easy Access application The Document icon button is selected.

  20. Verify that the dialog includes the following control names now. Select Done to close the dialog and to return to the design canvas.

    Screenshot of the Tracking session dialog with the UI elements from the SAP Easy Access windows added to it.

  21. This is the dialog you should see after you've closed the previous dialog.

    Screenshot of the Populate text field in window dialog with GUI button selected.

  22. Open the Text box dropdown menu, select Gui Ok Field 'okcd, and then select Select.

    Screenshot of the Populate text field in window dialog with the Text box dropdown menu open and the available UI elements showing.

  23. Enter the transaction code PA30, and then select Save.

    Screenshot of the Populate text field in window dialog with PA30 added in the Text to fill in box.

  24. On the right pane, select the UI elements icon. Select each control in the list and rename it.

    Tip

    This step isn't required, but it's highly recommended because your control library might include dozens of controls, making it difficult to identify them by their system names.

    Screenshot of the UI elements pane in the Power Automate Desktop designer window with the Rename UI element menu item selected for GUI Main Window.

  25. Here's the renamed control list.

    Screenshot of all the UI elements renamed with meaningful names for Maintain HR Master Data in the UI elements pane.

  26. Enter press button into the Action search box, and then drag the Press button in window action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with Press button in Window being added from the Actions pane below wait 10 seconds.

  27. Select Continue.

    Screenshot of the Power Automate Desktop designer window with Press button in Window dialog open and the UI elements dropdown menu open.

  28. Select Save.

    Screenshot of Press button in Window dialog with Continue button selected and Save highlighted.

  29. Enter wait for into the Actions search box, and then drag the Wait for window content action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with the Wait for window control action being added from the Actions page.

  30. Under UI element select Employee id, and then select Select.

    Screenshot of the Power Automate Desktop designer window with Wait for window content dialog open and the UI element drop down open.

  31. Select Save.

    Screenshot of Wait for window content dialog.

  32. Enter populate into the Actions search box, and then drag the Populate text field window action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with Populate text field in Window being added from the Actions pane after Wait for window content.

  33. Under UI element select Employee id, and then select Select.

    Screenshot of the Power Automate Desktop designer window with Populate text field in Window dialog open and the UI elements drop down open.

  34. Select the The Variables icon button. icon, which is in the Text to fill-in text box, and then select EmployeeId.

    Screenshot of the Power Automate Desktop designer window with Populate text field in Window dialog open and the variables list open.

  35. Select Save.

    Screenshot the Populate text field in Window dialog.

  36. Repeat from step 33 through 35 for controls Infotype, Info subtype, and Effective date, and select the variables or provide a fixed value as shown in the following images.

    Screenshot of the Populate text field in Window dialog with Text box field set to Infotype and text to fill in set to 0006.

    Screenshot of the Populate text field in Window dialog with Text box field set to Info subtype and text to fill in set to AddressType.

    Screenshot of the Populate text field in Window dialog with Text box field set to Effective Date and text to fill in set to EffectiveDate.

  37. Enter press button into the Actions search box, and then drag the Press button in window action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with Press button in Window being added from the Actions pane after Effective Date.

  38. Under UI element, select New address, and then select Save.

    Screenshot of the Press button in Window dialog with the UI element field set to New address button.

  39. Select Save, and then select OK.

    Screenshot of the Power Automate Desktop designer with the Saved successfully message box open.

  40. Enter wait for into the Actions search box, and then drag the Wait for window content action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with Wait for window content being added from the Actions pane after New address button.

  41. Select UI element, and then select the Add new UI element button to bring up the Tracking session dialog.

    Screenshot of Wait for window content dialog with the UI elements drop down open.

  42. The Tracking session dialog appears.

    Screenshot of the Tracking session dialog.

    Important

    For the following steps, you'll need valid SAP reference test data as outlined in step 5 of the SAP GUI scripting configuration prerequisites.

  43. Enter values for Personnel number, Period From, Infotype (always provide 0006, because this is a standard type in SAP systems), STy (this is the Infotype subtype), and then select Create (F5).

    Screenshot of the HR Master Data window in SAP Easy Access.

  44. Hover over Address line 1. A red frame surrounds the field Gui Ok Text Field. Hold down Ctrl, and then click to add the control to the UI elements list, which shows up in the Tracking session dialog.

    Screenshot of the Create addresses window in SAP Easy Access with highlight on the Address Line 1 field in the Address area.

  45. Repeat step 44 for these fields as well: City/county, State, Zip code, Country key, and the Save (Ctrl+S) button.

    Screenshot of the Create addresses window in SAP Easy Access with highlight on the City County field in the Address area.

    Screenshot of the Create addresses window in SAP Easy Access with highlight on the State field in the Address area.

    Screenshot of the Create addresses window in SAP Easy Access with highlight on the Zip Code field in the Address area.

    Screenshot of the Create addresses window in SAP Easy Access with highlight on the Country Key field in the Address area.

    Screenshot of the Create addresses window in SAP Easy Access with highlight on the Save button.

  46. In the Tracking session dialog, select Done.

    Important

    Be sure to leave the SAP form open.

    Screenshot showing the SAP Easy Access window with the Power Automate Desktop Tracking Session window.

  47. Select UI element and then select Gui Text Field 'P0006-STRAS", and then select Save to close the dialog.

    Screenshot of Wait for window content dialog open and the UI elements drop down open.

  48. On the right pane, select the UI elements icon. Select each of the newly added controls in the list, and then rename them. This isn't mandatory but highly recommended because your control library might include dozens of controls, making it difficult to identify them by their system names.

    Screenshot of all the UI elements in the UI elements pane.

    Screenshot of the UI elements pane in the Power Automate Desktop designer window with the Rename UI element menu item selected.

    Screenshot of all the UI elements renamed with meaningful names in the UI elements pane.

  49. Enter populate in the Actions search box, and then drag the Populate text field window action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with Populate text field in Window being added from the Actions pane.

  50. Select UI element, and then select Street.

    Screenshot of the Populate text field in window dialog with the Text box drop down open and the available UI elements displayed.

  51. On the Text to fill-in box, select the fx icon, and then double-click to select the Street variable.

    Screenshot of Populate text field in Window dialog and the variables list open then selecting the Street variable.

  52. Select Save.

    Screenshot of Populate text field in Window dialog with Street variable in Text to fill in field.

  53. Repeat steps 50 and 52 with these controls: City, State, and ZipCode.

    Screenshot of Populate text field in Window dialog with City in the Text box field and the City variable in Text to fill in field.

    Screenshot of Populate text field in Window dialog with State in the Text box field and the State variable in Text to fill in field.

    Screenshot of Populate text field in Window dialog with ZipCode in the Text box field and the ZipCode variable in Text to fill in field.

    Note

    SAP GUI combo boxes need special handling, which requires us to use a combination of actions to select the correct list items within combo boxes.

  54. Enter click UI into the Actions search box, and then drag the Click UI element in window action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with Click UI element in Window being added from the Actions pane.

  55. Select UI element, and then Country.

    Screenshot of the Power Automate Desktop designer window with Click UI element in Window dialog open and the variables list open.

  56. Keep the default value for Click type.

    Screenshot of the Power Automate Desktop designer window with click UI element in window and left click type.

  57. Enter send keys into the Actions search box, and then drag the Click UI element in window action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with Send keys being added added after Country.

  58. In the Text to send field, select the fx icon, and then double-click to select CountryCode.

    Screenshot of the Power Automate Desktop designer window with Send keys dialog open and the variables list open.

  59. Amend the %CountryCode% text by typing {Enter} right after the variable name. The {Enter} reference mimics an Enter keystroke on your keyboard.

    Screenshot of Send Keys dialog with CountryCode Enter in the Text to send field.

  60. Drag another Send keys action onto the end of the flow.

    Screenshot of the Power Automate Desktop designer window with Send keys being added.

  61. Enter {Enter} into the Text to send field, and then select Save.

    Screenshot of Send keys dialog with Enter in the Text to send field.

  62. Enter press button into the Actions search box, and then drag the Press button in window action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with Press button in Window being added from the Actions pane.

  63. Under UI element, select Save.

    Screenshot of the Power Automate Desktop designer window with Press button in Window dialog open and the variables list open and Save button selected.

  64. Select Save.

    Screenshot of Press button in window dialog.

    Important

    Confirm that the save operation is complete for the SAP record before you interact with other controls or windows.To make sure the operation is complete, add a Wait action to wait for a control to become visible.

  65. Enter wait into the Actions search box, and then drag the Wait for window content action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with Wait for window content being added from the Actions pane.

  66. Under UI element, select Employee id, and then select Select.

    Screenshot of the Power Automate Desktop designer window with Wait for window content dialog open and the variables list open.

  67. Select Save.

    Screenshot of Wait for window content dialog.

  68. Enter press button into the Actions search box, and then drag the Press button in window action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with Press button in Window being added from the Actions pane after Employee ID.

  69. Under UI element, select Add new UI element.

    Screenshot of the Power Automate Desktop designer window with Press button in Window dialog open and the variables list open.

  70. Hover over the Back (F3) button.

    Screenshot of Back button in Create Addresses window in SAP Easy Access.

  1. Hold down Ctrl while clicking to add the control to the UI elements list in the Tracking session dialog. (Note: we kept this form open in step 46.)

    Screenshot of the Create Addresses window in SAP Easy Access with the Back button highlighted.

  2. Now, select the Back button (without the Ctrl key) to go back to the previous screen.

    If you see a "Data will be lost" message, confirm by selecting Yes.

    Screenshot of Data will be lost message box in Create Addresses window in SAP Easy Access.

  3. You should be on the following screen now. In the Tracking session dialog, select Done.

    Screenshot of Maintain HR Master Data window in SAP Easy Access alongside the Tracking session window from Power Automate Desktop.

  4. Select Save.

    Screenshot of Press button in Window dialog.

  5. Rename the button we've just added to the control library to Back button.

    Screenshot of renaming the new button UI elements in the UI elements pane.

    Screenshot of UI elements pane with UI elements renamed.

  6. Enter close window into the Actions search box, and then drag the Close window action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with Close Window being added from the Actions pane.

  7. Under UI element, select Window "SAP Easy Access", and then select Save.

    Screenshot of the Power Automate Desktop designer window with Close Window dialog open and the variables list open and Windows SAP Easy Access selected.

  8. Enter close window into the Actions search box, and then drag the Close window action onto the canvas.

    Screenshot of the Power Automate Desktop designer window with Close window being added from the Actions pane.

  9. Under Window, select Add a new UI element.

    Screenshot of the Power Automate Desktop designer window with Close Window dialog open and the variables list open.

  10. Hover over the outer window frame of the SAP Logon 760 window. Hold down Ctrl and click to add the window element to the UI elements list, which appears in the Tracking session dialog.

    Screenshot of the SAP Logon 760 screen with a surrounding red bordered box and a Power Automate Desktop tracking session window.

  11. Under UI element, select Window "SAP Logon 760" (the number 760 reflects the SAP GUI version, so this might differ in your environment), and then select Save.

    Screenshot of the Power Automate Desktop designer window with Close Window dialog open and the variables list open and Window SAP Login 760 selected.

  12. Select Save.

    Screenshot of Close Window dialog.

  13. Select Save to save the flow.

    Screenshot of the Power Automate Desktop designer window with Save dialog open.