Recording SAP GUI scripts in SAP GUI

 

When SAP GUI Scripting is enabled on the server side, the user can record and then play SAP GUI scripts directly from EasyInput.
Starting SAP GUI scripts recording can be started directly from EasyInput ribbon menu using Record script  button on EI_Script_GS worksheet. Direct recording has advantage of being able to use the so called TestToolMode option. Test tool mode to be used for recording and playback should be set on EI_Config worksheet. With test tool mode switched on, messages are displayed in a more stable way for recording and later playback, thus it is recommended to use test tool mode for SAP GUI scripts.

SAP GUI script recording ends when the user, presses the Stop script recording button  !

 

Several rules of script recording:

- to make script universal one has to think carefully how the recorded transaction work (in FB50 transaction where there are line items, it is worth to enter the data always to the first row, and add a new row above the preceding to always perform the same pattern for the data line. This will allow to exceed the limit of ten line items visible on screen, and to treat the script for the first line as the script for all data lines)

- During recording it is advisory to enter a value to all fields to which later EasyInput will provide a value (even if the value as default is already given). This will save us time on manually editing recorded script.

- When EasyInput will be to read a value from a field it is advisory during recording to set the cursor on that field (click it with the mouse. This will record cursor “focus” line in the script, where the user will later add read reference.

- the script should be normally recorded without errors and twice – once for test run (with pressing the Cancel icon at the end) and once for actual run usually ended with pressing the post or save button.

 

Manual script adjustments after import to EasyInput

Sometimes the recorded screen can be used without any changes, but such a situation is rare. Usually the recorded script requires some manual adjustment. 

 

The most common script adjustments:

a)       The script lines, that are not needed in our script can be removed or inactivated via entering  „X” in the  „E” column of the script worksheet (EI_Script_GS)

b)      For script rows with script function “text = &&”, for which one wants to enter data from the data sheet adding references in columns K & L is needed. Such lines if not recorded can be introduced to the script manually. To get a screen field name click on it, press F1 and then press the technical information icon. On the bottom of the technical information screen, the Screen Field can be found.

c)       For script rows with script function “setFocus” from which we want to copy data to data sheet adding references in columns K & L is also needed. The field id can be checked the same way as described above.

d)      Removing from the recorded script unnecessary information about repeatable parts e.g. the part referring the second line of the document (usually for such lines the script should contain a part only for one line, that will be repeated as many times as many data rows for the line there are in the data sheet. Remember about pressing inserting a new line to clear the first row in the recorded script to make place for the second row).

e)      Exchanging script function “maximize” with “iconify” will minimize the SAP GUI window while script is running. The maximize function usually appears at the beginning of the script.

f)        For script lines, that are sometimes necessary, and sometimes can cause an error (for example closing optional popup window) one can put “X” in “ignore errors” N column of the “EI_Script_GS” worksheet.

g)       Adding additional script version with cancelling transaction before the save, for testing purposes. To be able to test transaction data it is recommended to prepare two script versions – for testing and actual run. Usually the versions can be identical up to last script screen. The most common change consist of setting on the last screen two action variants:
Example of change in the last script lines dependent on Run type:

Run type

Script object

Script Function

Field name

Field value

C - All run types

("wnd[0]")

sendVKey 0

 

 

T - Test run

("wnd[0]/tbar[0]/btn[12]")

press

 

 

T - Test run

("wnd[1]/usr/btnSPOP-OPTION1")

press

 

 

A - Actual run

("wnd[0]/tbar[0]/btn[11]")

press

 

 

 

Important! When recording a transaction containing several line items it is recommended to:

-          Always insert new line before the first row (for each script line item)

-          Always enter the data into the first row

-          Record only the first line item (if while recording more were recorded, they should be removed from the script)

If these rules are followed the script will be ready to be repeated for any number of line item rows in the data sheet (the repeated script rows should be assigned Level value > 0 - see the description of the Level column of the script)

 

Advanced options

In SAP GUI scripts one can use three special commands, which can be put manually in the script object column. These allow internal script looping (irrespective of looping over data on EI_Data worksheet), and pasting buffer value. They are extremely useful in SAP GUI scripting as in SAP GUI scripting the result read from one line can be used to steer the next script line behavior.

 

Important

The SAP GUI scripting is available from sap Netweaver version 6.20 or higher. To enable SAP GUI scripting on the server side the parameter sapgui/user_scripting should be set to true in the RZ11 transaction.

SAP GUI Scripting help can be accessed from SAP GUI application:

Alternative recording of SAP GUI script within SAP GUI

Alternatively one could prepare the recording on SAP GUI application side using colorful “Customize local layout” icon menu.

Here both the resulting script file (*.vbs) and the file codepage can be set. After pressing the red “record” button, all the user actions are being recorded. Pressing yellow “stop” button stops the script recording. The resulting .vbs file is ready to be imported on EI_Script_GS worksheet. Important: In order to make the button Import script file accessible one should enable it in EasyInput settings: EasyInput Info > Settings > Other via deselecting the Hide advanced script configuration options