Example: sapgui_grid_select_context_menu

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