Skip to Content
avatar image
Former Member

How to Handle Sap GUI GRID using python script

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?

image.png (115.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Mar 02 at 03:27 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 02 at 03:27 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      getting error Again:

      C:\Users\SESA443020\PycharmProjects\SAP_PYTHON\venv\Scripts\python.exe C:/Users/SESA443020/PycharmProjects/SAP_PYTHON/SAP_PYTHON_Connection.py Traceback (most recent call last): File "C:/Users/SESA443020/PycharmProjects/SAP_PYTHON/ SAP_PYTHON_Connection.py", line 18, in 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 " ", 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)