SapGuiSetOption Function

Action

This function allows setting certain SapGui specific runtime settings such as timeouts during replay or enabling certain log options.

Include file

SapGui.bdh

Syntax

SapGuiSetOption( in nOption : number,
                 in nValue  : number ) : boolean;
Parameter Description
nOption

The SapGui runtime option to be set. Available options are:

  • SAPGUI_OPT_TIMEOUT - Set this option to the amount of seconds after which a timeout should occur. If an SapGui API function call takes longer than the specified amount of seconds, the SapGui replay process is considered stuck and gets restarted automatically. Additionally an error of severity SEVERITY_TRANS_EXIT is raised.
  • SAPGUI_OPT_LOGCONTROLS - Set this option to 1 to enable control logging. Note that logging controls has a severe impact on the SapGui client performance. Therefore, it is usually recommended that you disable this option.
  • SAPGUI_OPT_LOGCONTROLS_ON_ERROR - Set this option to 1 to enable control logging in case of an error. Logging controls has a severe impact on the SapGui client performance. Therefore, general logging is usually disabled. This option can be used to have controls logged only in case of an error.
  • SAPGUI_OPT_LOGSCREENSHOTS - Set this option to 1 to enable the logging of a screenshot for each new window during replay. This option only applies if the UI is displayed during replay.
  • SAPGUI_OPT_LOGSCREENSHOTS_ACTION - Set this option to 1 to enable the logging of screenshots for each individual action during replay. This option only applies if the UI is displayed during replay.
  • SAPGUI_OPT_LOGLEVEL - Set this option to specify the amount of data that is written to the Virtual User Log File. Possible values are:
    • 0 (Disabled) - Does not generate any log output.
    • 1 (Normal) - Generates some log output.
    • 2 (Debug) - Generate verbose log output.
  • SAPGUI_OPT_LOGON_BEHAVIOR - Set this option to specify how multiple login attempts of the same user account are handled. Possible values are:
    • 0 - Do not handle multiple login attempts automatically.
    • 1 - Do no allow multiple login attempts.
    • 2 - Allow multiple login attempts.
    • 3 - Allow multiple login attempt, but kill the existing sessions.
nValue The value to be set for the specified option.

Return value

  • true if successful
  • false otherwise

Example

transaction TMain
  var
  begin
    // Connecting to SAP
    SapGuiSetOption(SAPGUI_OPT_LOGCONTROLS_ON_ERROR, 1);
    SapGuiOpenConnection(" /SAP_CODEPAGE=1100 /FULLMENU lab77 00 /3");
    SapGuiSetActiveConnection("/app/con[0]");
    SapGuiSetActiveSession("ses[0]");

    // SAP
    SapGuiSetActiveWindow("wnd[0]", "SAP", SAPGUI_MATCH_Exact);
    SapGuiWindowResize(117, 28, false);

    // Logon to SAP System
    // Before running a test you have to customize the password parameter!
    ThinkTime(5.3);
    SapGuiLogon("bcuser", "*******", "000", "");

    // Copyright
    SapGuiSetActiveWindow("wnd[1]", "Copyright", SAPGUI_MATCH_Exact);
  end TMain;