Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3353

PythonWin and SAPGUI Scripting

$
0
0

I was hoping that somebody else might have posted some examples of SAPGUI scripting and Python(Win) - but I couldn't find any.

 

Here is a very small example of SAPGUI Scripting with PythonWin. It might serve as a quick start for others who might also share an interest in Python and GUIscripting.

 

In short - I've got so far as to get basic manipulation working.

 

 

import win32com.client

False, True = 0 , -1

app = win32com.client.Dispatch("Sapgui.ScriptingCtrl.1")

conn = app.OpenConnection("D47", True)

At this point the SAPGUI opens with the initial logon screen of the system. A connection has been created. I enter my user ID and password

>>> print conn.Id

returns /app/con[0]

>>> ses = app.FindById("ses[0]")

>>> ses.CreateSession() "opens up a new session Good!

>>> ses.SendCommand(Command="/nIW31") "starts Tx IW31

>>> ses.StartTransaction(Transaction="IW31") "start IW31 also

 

>>> window = ses.activeWindow

>>> print window.Id

/app/con[0]/ses[0]/wnd[0]

start SE38...

>>> field = window.FindByName(Name="RS38M-PROGRAMM", Type="GuiCTextField")

>>> print field.Id

/app/con[0]/ses[0]/wnd[0]/usr/ctxtRS38M-PROGRAMM

 

So - it seems that basic manipulation works OK

 

Next step is to try some useful...

 

I'll let you know how it goes..

 

Andrew

 

 

Message was edited by: Andrew Barnard

 

Incorporated successful code and removed some questions which I've now solved myself. (The successful code covers the questions!).

 

 


Viewing all articles
Browse latest Browse all 3353

Trending Articles