With GuiXT Controls you can interact with SAP GUI controls such as a grid control or a tree control. Please note: This requires that SAP GUI scripting is activated on the SAP server and in the SAP GUI options. You need to use the keyword CallVBSAsync instead of CallVBS, i.e. you execute the VBScript function asynchronously. The reason you cannot work with synchronous calls via CallVBS is that, at the time when the GuiXT script is processed, the screen is not yet built up by SAP GUI, since the GuIXT script may delete elements, change the screen layout and add new elements. The same holds true for VBScript calls in InputScripts: all script statements after a "Screen" command are executed before the screen elements are created by SAP GUI, and you need an asynchronous call via CallVBSAsync in order to access the elements. When you work with CallVBSAsync, GuiXT uses a separate instance of the script engine. If you need to share information between the synchronous VBScript context and the asynchronous one, you need to use GuiXT variables to store and read the information in VBScript. An alternative to CallVBAsync is the ApplyGUIScript statement. You do not need the "GuiXT Controls" component for ApplyGUIScript, but it offers far fewer possibilities, eg direct access to GuiXT variables. If the SAP GUI screen contains a "SAP Tree Control" or a "SAP Grid Control", you can use the predefined objects "SapTree" and "SapGrid" and apply the SAP GUI scripting methods.
|
As an example we add a toolbar button "Display material" in transaction MM60 (materials list). The user may select a material and then click the pushbutton in order to start transaction MM03 (Display material) for the selected material number:
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 up a VBScript subroutine: CallVBSAsync material_list_display_singleIn the VBScript subroutine "material_list_display_single" we read the selected material number and start transaction MM03 in a new mode, executing a second InputScript:
Sub material_list_display_single The called InputScript "MM03_display_single.txt" displays the material: Parameter MATNR// initial screen of MM03 Set F[RMMG1-MATNR] "&U[MATNR]" Enter /5 // select a view Set cell[Table,0,1] "X" Enter
|