Skip to Content
Former Member
Jun 15, 2016 at 03:23 PM

Control Cannot be Found by ID - C# SAP GUI SCRIPTING


Hello everyone,

I'm having the following issue:

I've was able to link my C# application to an open SAP Session, select the transaction (VA01), and fill some fields - the ones at the beginning of the overview window. But:

the problem occurs in the same overview page, there is a sub-window with different tabs (Sales, Item Overview, etc).

When I run the macro script I get the following code:


session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4021/txtVBKD-BSTKD").text = "12345"

session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/ctxtVBAK-ZZOPRECDATE").text = "15.06.2016"


session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/ctxtVBAK-ZZOPRECDATE").caretPosition = 10

This code is translated in my C# code like so:

((GuiTextField)GlobalVariables.SAPSession.ActiveWindow.FindById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4021/txtVBKD-BSTKD")).Text = EmployeeID_VALUE.Text;

((GuiTextField)GlobalVariables.SAPSession.ActiveWindow.FindById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/ctxtVBAK-ZZOPRECDATE")).Text = DateTime.Today.ToString("dd.MM.yyyy");

The first line is a field located at the top of the overview page, the second one is inside the tabbed window. The first line runs fine, an employee ID is entered in the SAP GUI application, but the code fails on the 2nd line, where the field inside the tabbed window is located.

Here's a picture of the window (the one marked red is the one that fails in code):

Any ideas as to what might be wrong in the code or configuration?