Share this page

# sapgui_grid_select_context_menu

Grid Functions

Selects an option from a context menu in a grid.

    int sapgui_grid_select_context_menu( const char *description, const char *gridID, const char *functionCode, [args,] LAST );

description | User entered text to aid in understanding script
gridID | Object ID Strings
functionCode | Object ID Strings for the selected menu option
args | Optional Arguments
LAST | A marker indicating the end of the argument list. Not required if Optional Arguments are used.

sapgui_grid_select_context_menu emulates a user selecting an option from a context menu.

When recording, sapgui_grid_open_context_menu is recorded before this function when the user right-clicks to open the menu.

## Return Values

This function returns LR_PASS (0) on success or LR_FAIL (1) on failure.

## Parameterization

You can parameterize all string (char type) arguments.

## Example

The following example uses sapgui_grid_select_context_menu to duplicate a grid row.

        // 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 );

        sapgui_grid_select_cell("Select Cell", "{GridID}", "0", "MATNR", LAST );

        // Put in some data

        sapgui_grid_set_cell_data("(0, Material)",
            "{GridID}",
            "0",
            "MATNR",
            "0",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1015",
            END_OPTIONAL);

    /* 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_Details");

        sapgui_grid_select_cell_column("'Item of requisition'",
            "{GridID_Details}",
            "BNFPO",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1018",
            END_OPTIONAL);

        sapgui_grid_open_context_menu("(CtrlGrid)",
            "{GridID_Details}",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1019",
            END_OPTIONAL);

        /* Choose "Duplicate" from the context menu
            to create a new row with the same data */

        sapgui_grid_select_context_menu("(CtrlGrid)",
            "{GridID_Details}",
            "&MEREQDUPLICATE",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1020",
            END_OPTIONAL);

        sapgui_grid_select_rows("0",
            "{GridID_Details}",
            "0",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1023",
            END_OPTIONAL);

        sapgui_grid_press_toolbar_button("'Delete'",
            "{GridID_Details}",
            "&MEREQDELETE",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1024",
            END_OPTIONAL);

        sapgui_select_active_window("wnd[1]");

        sapgui_press_button("Yes",
            "usr/btnSPOP-OPTION1",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1025",
            END_OPTIONAL);

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