With GuiXT controls you can modify special SAP GUI controls by using the GUI Scripting in VB.NET, e.g. the "grid control" or "tree control". You can read and set values and customize layout supported by SAP GUI scripting.

Please note:  SAP GUI scripting must be activated on the server and in SAP GUI.

We will use the keyword CallVBAsync instead of CallVB, meaning that we call the VB.NET function asynchronously. This is necessary because the SAP GUI windows including special controls it not built up while the GuiXT script is running, as the script can alter the layout in a way different to what the SAP standard defines.

We also need the asynchronous call CallVBAsync in our InputScript when we access the SAP controls, because the instructions in the Inputscript run before the SAP GUI builds up the screen.
 

As an example we add a pushbutton "display material" to the transaction MM60 (Material List): The user can choose a material in the "grid control" and on clicking on the new pushbutton the transaction MM03 (Display Material) for the selected material is displayed:

 

We use the following GuiXT script:

if Q[Transaction=MM60]
  
Pushbutton (toolbar) "Display material" process="material_display.txt"
endif

The InputScript "material_display.txt" calls a VB.NET function:

CallVBAsync utilities.material.material_list_display_single

We read the selected material number in the VB.NET function "material_list_display_single" and start the transaction MM03 in a new mode, whereby we call a second Inputscript:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Imports guinet
Imports SAPFEWSELib


Public Class material

    Private guixt As New guinet.guixt

  
    Sub material_list_display_single()


        Dim SapGrid As GuiGridView = guixt.GuiSession.GuiGridView

        ' Material selected?    
        If SapGrid.CurrentCellRow = -1 Then
            Exit Sub
        End If

        ' read material number from grid cell
        Dim matnr
        matnr = SapGrid.GetCellValue(SapGrid.CurrentCellRow, "MATNR")

        ' start InputScript to display the material
        guixt.input("U[MATNR]:" + matnr)
        guixt.input("OK:/OMM03,process=MM03_display_single.txt")


    End Sub


End Class

The called InputScript  "MM03_display_single.txt" displays the material master records:

Parameter MATNR

// initial screen of MM03
Screen
saplmgmm.0060
 
Set F[RMMG1-MATNR] "&U[MATNR]"
 
Enter /5

// select a view
Screen
saplmgmm.0070
 
Set cell[Table,0,1] "X"
 
Enter