cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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]").maximize

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").setFocus

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?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Found it!

In case someone encounters this:

The ID for the tab, returned by the VB Script from the Macro Recorder was "wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01". Even using the Scripting Tracker, I got the same ID.

I managed to navigate successfully to the Overview GuiTabStrip, "wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW". I did a SelectedTab.ID, stored it in a string and noticed that the returned value was "wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\\01"

So there was two "\\" before the "01", instead of just one, like the macro recorder and the Scripting Tracker returned. I added that "\" and now I can access the text field just fine.

Why this happens, I have no idea.

Answers (0)