Share this page

# 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 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;
    }

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: