cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to Handle Sap GUI GRID using python script

Former Member
0 Likes
5,936

I need to click on first row and enter Material using python , I tried to perform like this , session.FindById("ses[0]/wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-MABNR[1,1]").text = "M0097987"

i am getting following error:

line 18, in <module> session.FindById("ses[0]/wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-MABNR[1,1]").text = "MM0001" File "<COMObject FindById>", line 3, in FindById pywintypes.com_error: (-2147352567, 'Exception occurred.', (619, 'SAP Frontend Server', 'The control could not be found by id.', 'C:\\Program Files (x86)\\SAP\\FrontEnd\\SAPgui\\sapfront.HLP', 393215, 0), None) Process finished with exit code 1

Please help me on this, how i can handle grid using python for sap gui scripting?

Accepted Solutions (0)

Answers (4)

Answers (4)

This point "tabpT\01" change "tabpT\\01"

So,sap session will grab

good bye

rspecht
Explorer

There is a problem with SAP GUI Scripting in SAP GUI 7.50 Patch-Level 4 Hotfix 1. With this SAP GUI-Version no use of scripting is possible. Please check your SAP GUI-Version.

Former Member
0 Likes

My SAP GUI version in 7.30

mbov
Explorer
0 Likes

"The control could not be found by id." suggests there is an error in "wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/txtRV45A-MABNR[1,0]". The "tabpT\01" look suspicious. \ is an espace character in Phyton. Try checking the ID carefully and use a verbatim string.

Stefan-Schnell
Active Contributor
0 Likes

Hello Azharuddin,

I assume you have three errors in your Python line, here an example which works with another GuiTable:

session.findById("wnd[0]/usr/tblSAPMBIBSTC538B/txtLOOP5302-F2[1,0]").text = "M0097987"
  1. Your ID contains ses[0], this is not necessary, because you set it to your session with session.FindById.
  2. Your ID contains [1,1], but the first line has 0 as index, so [1,0] should be correct.
  3. Your ID contains ctxt, but this is a combo box, it should named as txt, a text field.

Please try:

session.FindById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/txtRV45A-MABNR[1,0]").text = "M0097987"

Let us know your results.

Cheers
Stefan

Former Member
0 Likes

getting error Again:

C:\Users\SESA443020\PycharmProjects\SAP_PYTHON\venv\Scripts\python.exe C:/Users/SESA443020/PycharmProjects/SAP_PYTHON/SAP_PYTHON_Connection.py <COMObject FindById> Traceback (most recent call last): File "C:/Users/SESA443020/PycharmProjects/SAP_PYTHON/SAP_PYTHON_Connection.py", line 18, in <module> session.FindById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/txtRV45A-MABNR[1,0]").text = "M0097987" File "<COMObject FindById>", line 3, in FindById pywintypes.com_error: (-2147352567, 'Exception occurred.', (619, 'SAP Frontend Server', 'The control could not be found by id.', 'C:\\Program Files (x86)\\SAP\\FrontEnd\\SAPgui\\sapfront.HLP', 393215, 0), None)