cancel
Showing results for 
Search instead for 
Did you mean: 

How to capture text using SAP Gui Scripting?

0 Kudos

sap-capture-1.png

sap-capture-2.png

sap-capture-3.png

I am using Python to automate an SAP Logon process by modifying recorded script.
But I have run into a problem. I do not know how to extract the text data I find on SAP.


One process that I am doing is to extract information from Inbox line-by-line.
How can I capture the text using scripting? (Info record, vendor, material, etc)


I tried to record most steps but I have no idea how to capture the .text field.
The record does not pinpoint to that section.

 session.findById("wnd[0]").resizeWorkingPane(184, 30, 0) session.findById("wnd[0]/tbar[1]/btn[36]").press() session.findById("wnd[0]/usr/cntlSINWP_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = " 2" # Selects Inbox

session.findById("wnd[0]/usr/cntlSINWP_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[0]/shell").selectedRows = "0" # Selects First Row
        session.findById("wnd[0]/usr/cntlSINWP_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[0]/shell").selectionChanged()
        print(session.findById("wnd[0]/usr/cntlSINWP_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[0]/shell").text) 
# This thing prints "SAPGUI.GridViewCtrl.1"......
        session.findById("wnd[0]/usr/cntlSINWP_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[0]/shell").pressToolbarButton("DISP") 
      
        session.findById("wnd[0]/usr/tabsSO33_TAB1/tabpTAB1").select()
        print(session.findById("wnd[0]/usr/tabsSO33_TAB1/tabpTAB1").text)

# This thing prints "Doc. contents" ......I need to get (Info record, vendor, material, etc)


If you look at SAP_Capture_3.png photo, I have identified the shell. But I cannot get the text data of it...

print(session.findByID("wnd[0]/usr/cntlSINWP_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell").text)

Above code only gives me "SAP.HTMLControl.1"...........I want the contents.

Help me please.

Sandra_Rossi
Active Contributor

That's a problem. The GuiHtmlViewer object has very few methods and properties and you can't read the displayed text. I guess you could do it by accessing directly the OLE object named "Microsoft Web Browser" used underneath, but I only see stefan.schnell who can help you.

0 Kudos

Yes.... I never succeeded in reading displayed text.
I used to resort to downloading the entire data for reading.
But that really complicates things.

I do not know the exact script to use OLE object....
I would definitely seek help from Stefan Schnell.

View Entire Topic
stefan_schnell
Active Contributor
0 Kudos

Hello rainmankim,

let us know how your alternative path by downloading and reading the data.

Thanks and best regards
Stefan

waddoum81
Explorer
0 Kudos

Hi stefan.schnell , I know this thread is a bit old but I thought i try... I have an SAP transaction that generates a list (BoM) unfortunately there's no option to download/save the data except with ctrl+y mark text then copy/paste... my challenge now is i'm trying to automate some data retrieval using SAP scripting and the script doesn't capture this ctrl+y... any suggestions?

Note: i tried list> save (option is greyed out).. i also tried right click to save table to spreadsheet (option doesn't exist).

Thanks a lot!!

BR/Wissam