-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_template.py
50 lines (40 loc) · 1.42 KB
/
main_template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import win32com.client
def SAP_OP():
SapGuiAuto = win32com.client.GetObject("SAPGUI")
if not type(SapGuiAuto) == win32com.client.CDispatch:
return
else:
print('SAPGUI Initialized')
application = SapGuiAuto.GetScriptingEngine
if not type(application) == win32com.client.CDispatch:
SapGuiAuto = None
return
else:
print('Application Found')
connection = application.Children(0)
if not type(connection) == win32com.client.CDispatch:
application = None
SapGuiAuto = None
return
else:
print('Connected to Application')
session = connection.Children(0)
if not type(session) == win32com.client.CDispatch:
connection = None
application = None
SapGuiAuto = None
return
else:
print('Connected to Session')
### START OF GUI AUTOMATION - change anything below this line until the END
# These 4 lines maximize the session window, navigates to tcode SU01, and places the text HELLO in the User field
session.findById("wnd[0]").maximize()
session.findById("wnd[0]/tbar[0]/okcd").text = "su01"
session.findById("wnd[0]").sendVKey(0)
session.findById("wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME").text = "HELLO"
### END OF GUI AUTOMATION - change anything above this line until the START
session = None
connection = None
application = None
SapGuiAuto = None
SAP_OP()