Add variables to your VBScript

In this step of the RPA Playbook for SAP GUI Automation with Power Automate tutorial, before we switch over to Power Automate Desktop, let's review all the hard-coded value references in your VBScript and decide which ones to replace with dynamic input variables.

Identify hard-coded values

Variables are used within desktop flow processes to store data for further processing, and their names are enclosed within percentage signs, %. Almost every action receives at least one variable as input or produces a variable as output. Every variable has a unique name. Variable names can contain letters, numbers, and underscore ( _ ) characters, and aren't case-sensitive.

Some variable naming examples include:

  • %NewVar%

  • %file_path%

  • %Street%

The following image shows an example of replacing a hard-coded value with a variable.

Screenshot of VBScript code showing a hard-coded field value being replaced with an input variable

Screenshot showing a line of code that reads
session.findById("wnd[0]/usr/txtP0006-STRAS).text = "My Street 13"
The next line of code has removed "My Street 13" and replaced it with "%Street%" .

Your script should look like the following after you've introduced variables.

Screenshot of code where user input has been replaced with a series of variables.