Hello again,
Once more it's that time of the year, and I come bearing questions for all the good (and bad) boys and girls out there.
Ii this case, basically, I was wondering if anyone could confirm whether or not it's possible to use the COM interface to work with SAP. if so:
- Is anyone familiar with it? How do I create the COM object?
- Could anyone point me to resources regarding this? (something like the MS Excel Object Model Reference libraries)
I've been looking around but information seems pretty scarce (or I just don't know where to look)... so any help would be appreciated.
Thanks in advance.
SAP through COM?
Re: SAP through COM?
hi,
There are few examples on how to automate SAP via COM using AutoIt over the internet.
I tried to learn COM for SAP exactly year ago. What got me back then is that I was told by our SAP admins that they aren't gonna enable SAP GUI Scripting.
After exactly one year I'm gonna fight back.
There are few examples on how to automate SAP via COM using AutoIt over the internet.
I tried to learn COM for SAP exactly year ago. What got me back then is that I was told by our SAP admins that they aren't gonna enable SAP GUI Scripting.
After exactly one year I'm gonna fight back.
Re: SAP through COM?
Hmm... ok, so I confirmed that GUI Scripting is enabled, so that shouldn't be a problem. So know of any resources for this? Even if it's for VB or something, I think I can manage to translate it (more or less) ![Wink ;)](./images/smilies/icon_e_wink.gif)
![Wink ;)](./images/smilies/icon_e_wink.gif)
Re: SAP through COM?
Cool. Good for you that your company doesn't have the kind of we-know-it-all-best admins.
Try to rewrite and run this example.
Try to rewrite and run this example.
Code: Select all
Opt("WinTitleMatchMode", 2)
WinWaitActive("SAP Easy Access")
;>>>>>>>>Session attachment>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$SapGuiAuto = ObjGet("SAPGUI")
$application = $SapGuiAuto.GetScriptingEngine
$connection = $application.Children(0)
$session = $connection.Children(0)
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$session.findById("wnd[0]/tbar[0]/okcd").text = "FD32"
$session.findById("wnd[0]").sendVKey (0)
Re: SAP through COM?
any luck? zebuddha
-
- Posts: 264
- Joined: 09 Mar 2019, 01:52
- Location: Germany
- Contact:
Re: SAP through COM?
Hi @phaleth
I'd tried your script. But it doesn't work.
I'd tried your script. But it doesn't work.
Code: Select all
#if WinActive("SAP Easy Access")
;>>>>>>>>Session attachment>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$SapGuiAuto = ObjGet("SAPGUI")
$application = $SapGuiAuto.GetScriptingEngine
$connection = $application.Children(0)
$session = $connection.Children(0)
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$session.findById("wnd[0]/tbar[0]/okcd").text = "mm02"
$session.findById("wnd[0]").sendVKey (0)
$session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").text = "DEBIECAS106"
$session.findById("wnd[0]").sendVKey (0)
Re: SAP through COM?
That's a code from AutoIt.
Try something like the following while on the SAP Easy Access screen:
Try something like the following while on the SAP Easy Access screen:
Code: Select all
;>>>>>>>>Session attachment>>>>>>>>>>>>>>>>>>>>>>>>>>>>
sapGui = ComObjGet("SAPGUI")
MsgBox, 0, debugging, % isObject(sapGuiAuto) ; this should display 1
application = sapGui.GetScriptingEngine
connection = application.Children(0)
session = connection.Children(0)
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
session.findById("wnd[0]/tbar[0]/okcd").text := "mm02"
session.findById("wnd[0]").sendVKey(0)
Last edited by phaleth on 27 May 2019, 13:08, edited 1 time in total.
-
- Posts: 264
- Joined: 09 Mar 2019, 01:52
- Location: Germany
- Contact:
Re: SAP through COM?
yeah! I wondered why there are "$" in front of the lines. I don't get my head around this issue. I have this little script, that helps me to get the ID of the elements.
I think I'm a section to deep or to high. Or the ".text" doesn't work with AHK.
But I can't get the fields set.
Code: Select all
session.FindById("wnd[0]/tbar[0]/okcd").text = "mm02"
Re: SAP through COM?
Code: Select all
session.FindById("wnd[0]/tbar[0]/okcd").text := "mm02"
= must be :=
and when you record some commands with arguments they must be set into ()
Also it may be better to use "/nmm02"
Re: SAP through COM?
Yep, the assignment operator i used is wrong for sure.
Hard to do any coding at all without being able to test. I should try fixing my post.
Btw, the dollar signs in front of vars might still work for ahk, that wasn't the issue anyway.
Hard to do any coding at all without being able to test. I should try fixing my post.
Btw, the dollar signs in front of vars might still work for ahk, that wasn't the issue anyway.
-
- Posts: 264
- Joined: 09 Mar 2019, 01:52
- Location: Germany
- Contact:
Re: SAP through COM?
Days ago I tried with the ":=" as assignment. It didn't work. So I thought, that "=" was the right way. But both don't work.
I'll try the next days. If I found a solution, I'll post it.
I'll try the next days. If I found a solution, I'll post it.
- WalkerOfTheDay
- Posts: 710
- Joined: 24 Mar 2016, 03:01
Re: SAP through COM?
Would be interesting to know if it is really possible indeed.
We use SAP Business One at work, and I have written several scripts for it, but unfortunately have had
to use a lot of ImageSearches, PixelSearches and such...
We use SAP Business One at work, and I have written several scripts for it, but unfortunately have had
to use a lot of ImageSearches, PixelSearches and such...
-
- Posts: 264
- Joined: 09 Mar 2019, 01:52
- Location: Germany
- Contact:
Re: SAP through COM?
Got it. A lunch break is very inspiring. =)
This works. To find the "path" of the element you can use the sap_controls_check.ahk from a few posts ago.
This works. To find the "path" of the element you can use the sap_controls_check.ahk from a few posts ago.
Code: Select all
SetTitleMatchMode, 2
WinWaitActive, SAP Easy Access
;>>>>>>>>>>>>>>>>>>>>>>>>>>
_oSAP := ComObjGet("SAPGUI").GetScriptingEngine ; Get the Already Running Instance
Session := _oSAP.ActiveSession
;>>>>>>>>>>>>>>>>>>>>>>>>>>
session.FindById("wnd[0]/tbar[0]/okcd").text := "/nmm03"
session.FindById("wnd[0]").sendVKey(0)
Sleep, 1000
session.findById("/app/con[0]/ses[0]/wnd[0]/usr/ctxtRMMG1-MATNR").text := "DEBIECAS106"
session.findById("wnd[0]").sendVKey(0)
Re: SAP through COM?
Great, I imagine the MsgBox in the code i posted above spoiled it for you.
MsgBoxes is what you might wanna avoid when dealing with references to apps external to ahk.
MsgBoxes is what you might wanna avoid when dealing with references to apps external to ahk.
Re: SAP through COM?
SAP Gui Scripting works quite wonderful
here a perhaps helpful link for recording a script:
https://blogs.sap.com/2014/08/04/script-recording-playback-for-dummies/
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
here a perhaps helpful link for recording a script:
https://blogs.sap.com/2014/08/04/script-recording-playback-for-dummies/
-
- Posts: 264
- Joined: 09 Mar 2019, 01:52
- Location: Germany
- Contact:
Re: SAP through COM?
Yeah. Found this blog post too. It helps a lot! Thank you.aifritz wrote: ↑28 May 2019, 14:02SAP Gui Scripting works quite wonderful![]()
here a perhaps helpful link for recording a script:
https://blogs.sap.com/2014/08/04/script-recording-playback-for-dummies/