Example: sapgui_grid_press_toolbar_button

The following example uses sapgui_grid_press_toolbar_button to sort and sum columns in a grid.

Example 1: Sort a column

// Save the Grid ID in variable "GridID"
lr_save_string(
	"/app/con[0]/ses[0]/wnd[0]/usr/cntlBCALV_GRID_DEMO_0100_CONT1/shellcont/shell",
       "GridID");
sapgui_grid_select_columns("'Overview'", 
        "{GridID}", 
        "CONNID", 
        BEGIN_OPTIONAL, 
            "AdditionalInfo=sapgui1019", 
        END_OPTIONAL);        
sapgui_grid_press_toolbar_button("'Sort in ascend. order'", 
        "{GridID}", 
        "&SORT_ASC", // Button ID
        BEGIN_OPTIONAL, 
            "AdditionalInfo=sapgui1020", 
        END_OPTIONAL);

Example 2: Total a column

sapgui_grid_select_columns("(CtrlGrid)", 
        "{GridID}", 
        "PAYMENTSUM", 
        BEGIN_OPTIONAL, 
            "AdditionalInfo=sapgui1028", 
        END_OPTIONAL);        
sapgui_grid_press_toolbar_button("'Total'", 
        "{GridID}", 
        "&MB_SUM", 
        BEGIN_OPTIONAL, 
            "AdditionalInfo=sapgui1029", 
        END_OPTIONAL);