SapGuiContextMenuSelectItemByPosition Function

Action

Selects an item in a context menu by specifying the item's (zero-based) index.

Include file

SapGui.bdh

Syntax

SapGuiContextMenuSelectItemByPosition( sControl  : in string allownull,
                                       sPosition : in string,
                                       sTimer    : in string optional) : boolean;
Parameter Description
sControl The context menu's unique ID
sPosition The menu item's index (zero-based) to be selected from the context menu
sTimer Timer name for measurements

Return value

  • true if successful
  • false otherwise

Example

transaction TMain
  var
  begin
    // Connecting to SAP
    gsConnID := SapGuiOpenConnection("   /SAP_CODEPAGE=1100  /FULLMENU  atlid-test1 00 /3 /UPDOWNLOAD_CP=2",
    "SapGuiOpenConnection");
    SapGuiSetActiveConnection(gsConnID);
    SapGuiSetActiveSession("ses[0]");

    // SAP
    SapGuiSetActiveWindow("wnd[0]", "SAP", SAPGUI_MATCH_ExactNoCase);
    SapGuiWindowAction(SAPGUI_WND_MAXIMIZE, "SapGuiWindowAction\\SAPGUI_WND_MAXIMIZE");

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

    // SAP Easy Access
    SapGuiIgnoreError(SAPENGINE_STATUSBAR_CHANGED, SEVERITY_SUCCESS);
    ThinkTime(2.1);
    SapGuiSetActiveWindow("wnd[0]", "SAP Easy Access", SAPGUI_MATCH_ExactNoCase);

    // NodeName: Office
    // NodePath: 2\1
    SapGuiTreeSelectNode("usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell", "Office", "0000000003", false,
    "SelNode\\Office");

    // NodeName: Office
    // NodePath: 2\1
    SapGuiTreeNodeContextMenu("usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell", "Office", "0000000003",
    "NodeCtxt\\Office");

    ThinkTime(9.9);
    SapGuiContextMenuSelectItemByPosition("usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell", "0");

    // Log off
    ThinkTime(7.9);
    SapGuiSelectMenu("mbar/menu[4]/menu[12]", "SapGuiSelectMenu\\Log off");

    // Log Off
    SapGuiSetActiveWindow("wnd[1]", "Log Off", SAPGUI_MATCH_ExactNoCase);

    // Yes
    SapGuiPressButton("usr/btnSPOP-OPTION1", "SapGuiPressButton\\Yes");
  end TMain;