Example: sapgui_grid_get_current_cell_column

The following example uses sapgui_grid_get_current_cell_row and sapgui_grid_get_current_cell_column to retrieve the location of the selected cell.

// Put the Grid ID in a variable to make the code more readable
lr_save_string
    ("usr/cntlBCALVC_TOOLBAR_D100_C1/shellcont/shell",
    "GridID");
//Select header (row -1) of Column 2
sapgui_grid_select_cell("-1, Connection number", 
        "{GridID}", 
        "-1", 
        "CONNID", 
        BEGIN_OPTIONAL, 
            "AdditionalInfo=sapgui1017", 
        END_OPTIONAL);
sapgui_grid_get_current_cell_column("Get Column", 
        "{GridID}", 
        "CurrentCellColumn", LAST );

sapgui_grid_get_current_cell_row("Current Row", 
        "{GridID}", 
        "CurrentCellRow", LAST );
sapgui_grid_get_cell_data("CellData", 
        "{GridID}", 
        "{CurrentCellRow}", 
        "{CurrentCellColumn}", 
        "CurrentCellData", 
        LAST );
// Output: "Current Cell Row: '-1', Column: 'CONNID', Data: 'No.'"
lr_output_message
    ("Current Cell Row: '%s', Column: '%s', Data: '%s'",
        lr_eval_string("{CurrentCellRow}"),
        lr_eval_string("{CurrentCellColumn}"),
        lr_eval_string("{CurrentCellData}"));

// Select first data row in column 
sapgui_grid_select_cell("-1, Connection number", 
        "usr/cntlBCALVC_TOOLBAR_D100_C1/shellcont/shell", 
        "0", "CONNID", LAST );
sapgui_grid_get_current_cell_column("Get Column", 
        "{GridID}", "CurrentCellColumn", LAST );

sapgui_grid_get_current_cell_row("Current Row", 
        "{GridID}", "CurrentCellRow", LAST );

sapgui_grid_get_cell_data("CellData", 
        "{GridID}", "{CurrentCellRow}", 
        "{CurrentCellColumn}", "CurrentCellData", LAST );
// Output: "Current Cell Row: '0', Column: 'CONNID', Data: '17'"
lr_output_message
    ("Current Cell Row: '%s', Column: '%s', Data: '%s'",
        lr_eval_string("{CurrentCellRow}"),
        lr_eval_string("{CurrentCellColumn}"),
        lr_eval_string("{CurrentCellData}"));