Share this page

# sapgui_apogrid_scroll_to_row

APO Grid Functions

Scrolls to a specified row in the APO grid.

    int sapgui_apogrid_scroll_to_row( const char *description, const char *gridID, const char *row, [args,]  LAST ) ;

description | User entered text to aid in understanding script
gridID | Object ID string
row | Grid row number. The first row is numbered zero (0).
args | Optional Arguments
LAST | A marker indicating the end of the argument list. Not required if Optional Arguments are used.

sapgui_apogrid_scroll_to_row emulates a user scrolling to a row in an APO grid. The row is not selected by this function.

## Return Values

This function returns -1 on success or 0 on failure.

## Parameterization

You can parameterize all string (char type) arguments.

## Mill Demo Example

This example requires that the Mill Demo be available when the action starts to run. To navigate to this point, use the Sample vuser_init section for loading the Mill Demo.

    Select()
    {

        /* To make the example more readable,
        we use a variable to pass the Grid ID */
        char gridID[]= "usr/subSUB_MAIN:/SAPAPO/SAPLMSDP_SDP:0027"
             "/cntlSDP_CUSTOM_CONTROL/shellcont/shell/"
             "shellcont[0]/shell/shellcont[0]/shell" ;
        int rc;
        int row;
        char sRow[10];

        /*Select entire grid*/
        sapgui_apogrid_select_all("Select entire grid", gridID, LAST );

        /*Deselect grid*/
        sapgui_apogrid_clear_selection("Deselect entire grid", gridID, LAST );

        /* Scrolling to a row does not select it */
        sapgui_apogrid_scroll_to_row("Scroll one above to Forecast",
            gridID, "11", LAST );

        /* Select a row */
        sapgui_apogrid_select_row("(Forecast)",
            gridID,
            "12",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1035",
            END_OPTIONAL);

        /* Deselect it*/
        sapgui_apogrid_deselect_row("Deselect Forecast)",
            gridID,
            "12",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1035",
            END_OPTIONAL);

        // Are labels changeable?
        rc = sapgui_apogrid_is_cell_changeable("Check top corner with labels",
            gridID,
            "0", "0", LAST );

        lr_message("Corner cell changeable = %d", rc);

        /* Double click on the label row */
        sapgui_apogrid_double_click("(0, Customers Forecast)",
            gridID,
            "0",
            "38",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1050",
            END_OPTIONAL);

        /* Get the message resulting from the double click */
        sapgui_status_bar_get_text("paramStatusBarText",
            BEGIN_OPTIONAL,
                "Recorded status bar text: Key figure of the row cannot be fixed",
            END_OPTIONAL);

        // Get the format and tool tip for the row handle
        sapgui_apogrid_get_cell_format("Row handle format",
            gridID,
            "12", "0",
            "cellAttrib",
            LAST );
        lr_message("Row handle format is %s",
            lr_eval_string("{cellAttrib}"));

        /* Get the tool tip */
        sapgui_apogrid_get_cell_tooltip("Row handle tool tip",
            gridID,
            "12", "0",
            "cellAttrib",
            LAST );
        lr_message("Row handle tool tip is %s",
            lr_eval_string("{cellAttrib}"));

        /* Get the current value of the cell */
        sapgui_apogrid_get_cell_data("Get data in cell", gridID,
            "12",
            "38",
            "cellData",
            LAST );
        lr_message("Initial data in 12, 38 is %s",
            lr_eval_string("{cellData}"));

        /* For illustrative purposes, find an editable cell.
            Of course, in a real script, you know what you
            need to edit */
        rc = 0;
        for (row = 1; rc == 0; row++)
        {
            sprintf(sRow,"%d", row);

            // Is data cell changeable?
            rc = sapgui_apogrid_is_cell_changeable("Check a data cell",
                gridID,
                sRow, "38", LAST );
        }

        row--;

        lr_message("Data cell (%s, 38 )changeable = %d", sRow, rc);

        /* Clear existing selections and select a cell */
        sapgui_apogrid_clear_selection("Deselect entire grid", gridID, LAST );

        sapgui_apogrid_select_cell("( M 11.2003, Forecast)",
            gridID,
            sRow,
            "38",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1039",
            END_OPTIONAL);

        /* Enter data in the cell */
        sapgui_apogrid_set_cell_data("( M 11.2003, Forecast)",
            gridID,
            sRow,
            "38",
            "12300",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1040",
            END_OPTIONAL);

        /* Press the Enter key. */
        sapgui_apogrid_press_ENTER("shell",
            gridID,
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1041",
            END_OPTIONAL);

        /* Confirm that the data was entered */
        sapgui_apogrid_get_cell_data("Get data in cell", gridID,
            sRow,
            "38",
            "cellData",
            LAST );
        lr_message("After set_cell_data, data in %d, 38 is %s",
            row,
            lr_eval_string("{cellData}"));

        /* Remove focus from cell */
            sapgui_apogrid_deselect_cell("Deselect M 11.2003, Forecast)",
            gridID,
            sRow,
            "38",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1039",
            END_OPTIONAL);

        /* Scrolling to a column does not select it */
        sapgui_apogrid_scroll_to_column("Scroll to 39",
            gridID,
            "39",
            LAST );

        /* Select a column */
        sapgui_apogrid_select_column("Select Col 40",
            gridID,
            "40",
            LAST );

        /* Deselect it */
        sapgui_apogrid_deselect_column("deselect Col 40",
            gridID,
            "40",
            LAST );

        /*Right click Row 5: Last Years Quantity, Column m11.2003
          and choose "fix" from context menu*/
        sapgui_apogrid_open_cell_context_menu("( M 11.2003, Last Years Quantity)",
            gridID,
            "5",
            "38",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1074",
            END_OPTIONAL);

        sapgui_apogrid_select_context_menu_item("shell",
            gridID,
            "MAGC_LOCK_CELLS",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1077",
            END_OPTIONAL);

        return 0;
    }

## Sample vuser_init section for loading the Mill Demo

The following is a sample vuser_init section for loading the Mill Demo.

Copy code

    vuser_init()
    {

        sapgui_open_connection_ex(" /SAP_CODEPAGE=1100 /FULLMENU accent 00 /3",
            "APO - Demo Server",
            "con[0]");

        sapgui_select_active_connection("con[0]");
        sapgui_select_active_session("ses[0]");
        sapgui_select_active_window("wnd[0]");
        sapgui_window_maximize(
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui104",
            END_OPTIONAL);

        sapgui_logon("MILL_DEMO",
            "demo-password",
            "720",
            "EN",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1017",
            END_OPTIONAL);

    /* Get the APO grid */
        sapgui_tree_set_selected_node("/SAPAPO/SDP94 - Demand Planning -> Planning -> Interactive Demand Planni",
            "usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell",
            "F00004",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1018",
            END_OPTIONAL);

        sapgui_tree_double_click_node("/SAPAPO/SDP94 - Demand Planning -> Planning -> Interactive Demand Planni",
            "usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell",
            "F00004",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1019",
            END_OPTIONAL);

        sapgui_tree_set_hierarchy_header_width("352",
            "shellcont/shell/shellcont[2]/shell/shellcont[1]/shell",
            "352",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1022",
            END_OPTIONAL);

        sapgui_tree_set_hierarchy_header_width("335",
            "shellcont/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell",
            "335",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1023",
            END_OPTIONAL);

        sapgui_tree_select_item("SALES MM EU, COLUMN_SELID",
            "shellcont/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell",
            " 2",
            "COLUMN_SELID",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1024",
            END_OPTIONAL);

        sapgui_tree_scroll_to_item("SALES MM EU, COLUMN_SELID",
            "shellcont/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell",
            " 2",
            "COLUMN_SELID",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1025",
            END_OPTIONAL);

        sapgui_tree_double_click_item("SALES MM EU, COLUMN_SELID",
            "shellcont/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell",
            " 2",
            "COLUMN_SELID",
            BEGIN_OPTIONAL,
                "AdditionalInfo=sapgui1026",
            END_OPTIONAL);
        return 0;
    }

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: