You want to embed your own Windows Forms applications in the SAP screen and react to keystrokes there, especially those that are normally handled by the SAP GUI.
In this example we show how you can allow the user to switch between individual inputfields using the Tab key, just like on the SAP screen.
First, create a Windows Forms application in the usual way. Please specify the .NET framework version 4.x as target framework here. Then define the tab index in the application, i.e. the order in which the elements can be selected with the tab key.
You can test this straight away, but the Tab key does not work in the usual way if you embed the application in the SAP GUI, because the SAP GUI intercepts these commands and does not forward them directly to the control.
However, we can insert event handlers for all elements used and then check whether the Tab key has been pressed. If this is the case, we call the SelectNextControl() function, which sets the focus to the next element. This function also has a direction parameter that you can set to backwards or false if the user has pressed Shift + Tab.
Unfortunately, Windows plays a system sound at this point. We can suppress this by suppressing further event handling with the following code:
Script for creating an order:
In this example, we want to create an order directly from the embedded control. Therefore, when you click on the corresponding button, several GuiXT variables are filled and an InputScript is started:
del (0,0) (100,100)
Control (0,0) (11.5,99.0) progid="Shell.Explorer" name="r1" initflag="r1init"
// embed control
callvb simple_form.create_order.embed "&V[r1]"
// Create Sales Order: Initial Screen
Set F[Order Type] "&U[ORDERTYPE]"
// Create Standard Order: Overview
Set F[Sold-To Party] "&V[customerno]"
Set F[PO Number] "&V[orderno]"
Set cell[All items,Material,1] "&V[matno]"
Set cell[All items,Order Quantity,1] "&V[quant]"
Download the .NET project with source-code:
Components InputAssistant + Controls