Share this page

# Example: sapgui_grid_select_toolbar_menu

The following example uses sapgui_grid_select_toolbar_menu to delete a row from a grid.

    // Load the sample
            sapgui_set_ok_code("/nme51n", LAST );
            sapgui_send_vkey(ENTER, LAST );

    // Save the Grid ID to make code more readable
    	lr_save_string( "usr/subSUB0:SAPLMEGUI:0016/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell",
    	        "GridID");

    /* If the grid we want to work with isn't visible
            click the button to display it.     */

        if (!sapgui_is_object_available("{GridID}", LAST ))
            sapgui_press_button("Expand", "usr/subSUB0:SAPLMEGUI:0016/subSUB2:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4001/btnDYN_4000-BUTTON", LAST );

    // Enter some data

        sapgui_grid_set_cell_data("(0, Material)", "{GridID}", "0", "MATNR", "1", LAST );

    /* When ENTER is pressed, a detail tab control pops up and the grid ID changes. */

        sapgui_grid_press_ENTER("ENTER", "{GridID}",
            "BEGIN_OPTIONAL", "AdditionalInfo=sapgui1017",
            "END_OPTIONAL");

        // Save the new ID

        lr_save_string( "usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell",
            "GridID");

        // Select the row to delete

         sapgui_grid_select_rows("0", "{GridID}", "0", LAST );

        // Delete using grid toolbar context menu

        sapgui_grid_select_toolbar_menu("(CtrlGrid)", "usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell",
            "&MEREQDELETE",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1067",
            END_OPTIONAL);

        // Confirm deletion

        sapgui_select_active_window("wnd[1]");

        sapgui_press_button("Yes", "usr/btnSPOP-OPTION1", LAST );

Tips to improve your search results... VuGen Function Reference Version 25.1-25.3 Function Reference 25.1-25.3 All View Local Help Center View Online Help Center Version: