Jump to content

SAP UDF


seangriffin
 Share

Recommended Posts

Hi, i`m new on scripting and SAP, i use Create Support Message to create tickets, and how can i fill the fields ?

does anyone know how to ? or were i can find tutorials ?

thanks in advance.

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...

bienmexicano: As far as I know, SAP GUI is downward compatible, so there should be no problems in theory... Also, on the last page, someone stated that he uses it with 710 without problems. Btw: Where can I find out the version of my Gui?

On to my topic now:

I am really happy I found this UDF to control SAP, but sadly I cannot get it to work yet. I tried to execute the example from the first post and it really connected to my SAP, then I got this AutoIt Error:

Line 188 (File "~\Include\SAP.au3"):

$sap_session.CreateSession

$sap_session^ ERROR

Error: Variable must be of type "Object".

What does this mean? May I have to adjust some code to better suit my SAP installation? I don't know, I am new to AutoIT and automating SAP, also just using SAP as a user. But I can see for example, the name of my standard SAP menu is not just "SAP Easy Access" but followed by the name of my employer. Maybe I should try and change this in sap.au3

edit: No, when I check sap.au3 it clearly states:

The window "SAP Easy Access" is used if one isn't provided. This may be a substring of the full window title.

Therefore, it should be able to find the window, even if the title is longer than that.

Now, are my assumptions correct? Or what am I missing? How can I solve this?

Please point me to any possible errors, as I am new to AutoIt and eager to learn. :D

Edited by Kebap
Link to comment
Share on other sites

  • 3 weeks later...

Hi, i`m new on scripting and SAP, i use Create Support Message to create tickets, and how can i fill the fields ?

does anyone know how to ? or were i can find tutorials ?

thanks in advance.

Hi Azeon. I hadn't heard of "Create Support Message" before. I went to Google and did a search, and I see that it can be accessed via the Help -> Create Support Message menu item in the SAP client. When I do so however, I get the following SAP information popup:

Customizing for feedback functionality missing

Most likely because I am in a testing environment, and this feature has been disabled.

Sorry I can't help :)

Edited by seangriffin

Cheers, Sean.

See my other UDFs:

Chrome UDF - Automate Chrome | SAP UDF - Automate SAP | Java UDF - Automate Java Applications & Applets | Tesseract (OCR) UDF - Capture text from applications, controls and the desktop | Textract (OCR) UDF - Capture text from applications and controls | FileSystemMonitor UDF - File, Folder, Drive and Shell Monitoring | VLC (Media Player) UDF - Creating and controlling a VLC control in AutoIT | Google Maps UDF - Creating and controlling Google Maps (inc. GE) in AutoIT | SAPIListBox (Speech Recognition) UDF - Speech Recognition via the Microsoft Speech (SAPI) ListBox | eBay UDF - Automate eBay using the eBay API | ChildProc (Parallel Processing) UDF - Parallel processing functions for AutoIT | HyperCam (Screen Recording) UDF - Automate the HyperCam screen recorder | Twitter UDF - Automate Twitter using OAuth and the Twitter API | cURL UDF - a UDF for transferring data with URL syntax

See my other Tools:

Rapid Menu Writer - Add menus to DVDs in seconds | TV Player - Automates the process of playing videos on an external TV / Monitor | Rapid Video Converter - A tool for resizing and reformatting videos | [topic130531]Rapid DVD Creator - Convert videos to DVD fast and for free | ZapPF - A tool for killing processes and recycling files | Sean's eBay Bargain Hunter - Find last minute bargains in eBay using AutoIT | Sean's GUI Inspector - A scripting tool for querying GUIs | TransLink Journey Planner with maps - Incorporating Google Maps into an Australian Journey Planner | Automate Qt and QWidgets | Brisbane City Council Event Viewer - See what's going on in Brisbane, Australia
Link to comment
Share on other sites

Hi, is someone still using this? It looks really promising to me. However, if I want to test it, it does not work. I can provide better descriptions, if someone is willing to listen and answer. :)

Hi Kebap. Are you still there? I have a little time on my hands to help at the moment.

Cheers, Sean.

See my other UDFs:

Chrome UDF - Automate Chrome | SAP UDF - Automate SAP | Java UDF - Automate Java Applications & Applets | Tesseract (OCR) UDF - Capture text from applications, controls and the desktop | Textract (OCR) UDF - Capture text from applications and controls | FileSystemMonitor UDF - File, Folder, Drive and Shell Monitoring | VLC (Media Player) UDF - Creating and controlling a VLC control in AutoIT | Google Maps UDF - Creating and controlling Google Maps (inc. GE) in AutoIT | SAPIListBox (Speech Recognition) UDF - Speech Recognition via the Microsoft Speech (SAPI) ListBox | eBay UDF - Automate eBay using the eBay API | ChildProc (Parallel Processing) UDF - Parallel processing functions for AutoIT | HyperCam (Screen Recording) UDF - Automate the HyperCam screen recorder | Twitter UDF - Automate Twitter using OAuth and the Twitter API | cURL UDF - a UDF for transferring data with URL syntax

See my other Tools:

Rapid Menu Writer - Add menus to DVDs in seconds | TV Player - Automates the process of playing videos on an external TV / Monitor | Rapid Video Converter - A tool for resizing and reformatting videos | [topic130531]Rapid DVD Creator - Convert videos to DVD fast and for free | ZapPF - A tool for killing processes and recycling files | Sean's eBay Bargain Hunter - Find last minute bargains in eBay using AutoIT | Sean's GUI Inspector - A scripting tool for querying GUIs | TransLink Journey Planner with maps - Incorporating Google Maps into an Australian Journey Planner | Automate Qt and QWidgets | Brisbane City Council Event Viewer - See what's going on in Brisbane, Australia
Link to comment
Share on other sites

bienmexicano: As far as I know, SAP GUI is downward compatible, so there should be no problems in theory... Also, on the last page, someone stated that he uses it with 710 without problems. Btw: Where can I find out the version of my Gui?

Yes it should work with v7.10, but I haven't used this version myself.

To get the version of your SAP client, go to the SAP Logon window, and click the button in the top-left corner of the window, and click About SAP Logon....

Mine displays this kind of information:

Name............: saplogon.exe

Description.....: SAP Logon for Windows

Product version.: 640 Final Release

File version....: 6404.4.17.1016

Build number....: 814550

Cheers, Sean.

See my other UDFs:

Chrome UDF - Automate Chrome | SAP UDF - Automate SAP | Java UDF - Automate Java Applications & Applets | Tesseract (OCR) UDF - Capture text from applications, controls and the desktop | Textract (OCR) UDF - Capture text from applications and controls | FileSystemMonitor UDF - File, Folder, Drive and Shell Monitoring | VLC (Media Player) UDF - Creating and controlling a VLC control in AutoIT | Google Maps UDF - Creating and controlling Google Maps (inc. GE) in AutoIT | SAPIListBox (Speech Recognition) UDF - Speech Recognition via the Microsoft Speech (SAPI) ListBox | eBay UDF - Automate eBay using the eBay API | ChildProc (Parallel Processing) UDF - Parallel processing functions for AutoIT | HyperCam (Screen Recording) UDF - Automate the HyperCam screen recorder | Twitter UDF - Automate Twitter using OAuth and the Twitter API | cURL UDF - a UDF for transferring data with URL syntax

See my other Tools:

Rapid Menu Writer - Add menus to DVDs in seconds | TV Player - Automates the process of playing videos on an external TV / Monitor | Rapid Video Converter - A tool for resizing and reformatting videos | [topic130531]Rapid DVD Creator - Convert videos to DVD fast and for free | ZapPF - A tool for killing processes and recycling files | Sean's eBay Bargain Hunter - Find last minute bargains in eBay using AutoIT | Sean's GUI Inspector - A scripting tool for querying GUIs | TransLink Journey Planner with maps - Incorporating Google Maps into an Australian Journey Planner | Automate Qt and QWidgets | Brisbane City Council Event Viewer - See what's going on in Brisbane, Australia
Link to comment
Share on other sites

bienmexicano: As far as I know, SAP GUI is downward compatible, so there should be no problems in theory... Also, on the last page, someone stated that he uses it with 710 without problems. Btw: Where can I find out the version of my Gui?

On to my topic now:

I am really happy I found this UDF to control SAP, but sadly I cannot get it to work yet. I tried to execute the example from the first post and it really connected to my SAP, then I got this AutoIt Error:

What does this mean? May I have to adjust some code to better suit my SAP installation? I don't know, I am new to AutoIT and automating SAP, also just using SAP as a user. But I can see for example, the name of my standard SAP menu is not just "SAP Easy Access" but followed by the name of my employer. Maybe I should try and change this in sap.au3

edit: No, when I check sap.au3 it clearly states:

Therefore, it should be able to find the window, even if the title is longer than that.

Now, are my assumptions correct? Or what am I missing? How can I solve this?

Please point me to any possible errors, as I am new to AutoIt and eager to learn. :)

Hi Kebap,

The problem would appear to be in your script. You haven't posted your script, but I can tell from the error (Line 188 (File "~\Include\SAP.au3")) that you are trying to call the _SAPSessCreate() function in your script. If you look in the Remarks section of this function, you'll see it says:

A prerequisite is that the function "_SAPSessAttach" has already been executed.

You will need to call _SAPSessAttach() prior to calling _SAPSessCreate(), because _SAPSessAttach() is the function that makes the first connection to the SAP client. If you call _SAPSessAttach() without any parameters, it will look for a window named "SAP Easy Access" only. If your window isn't named this (as you say it has the name of your employer), then you'll need to provide this value. For example:

_SAPSessAttach("SAP Easy Access - The World Bank")

It looks like you are trying to write a script that simply opens another session. Here is my example. Maybe it matches your script?

#include <SAP.au3>

_SAPSessAttach()
_SAPSessCreate()

This works for me. If you continue to get errors then you may not have SAP GUI Scripting enabled in your client? Go back to the first page of this topic, and follow the steps in the REQUIREMENTS section to make sure you have scripting enabled. Without it enabled, the SAP UDF won't work.

Edited by seangriffin

Cheers, Sean.

See my other UDFs:

Chrome UDF - Automate Chrome | SAP UDF - Automate SAP | Java UDF - Automate Java Applications & Applets | Tesseract (OCR) UDF - Capture text from applications, controls and the desktop | Textract (OCR) UDF - Capture text from applications and controls | FileSystemMonitor UDF - File, Folder, Drive and Shell Monitoring | VLC (Media Player) UDF - Creating and controlling a VLC control in AutoIT | Google Maps UDF - Creating and controlling Google Maps (inc. GE) in AutoIT | SAPIListBox (Speech Recognition) UDF - Speech Recognition via the Microsoft Speech (SAPI) ListBox | eBay UDF - Automate eBay using the eBay API | ChildProc (Parallel Processing) UDF - Parallel processing functions for AutoIT | HyperCam (Screen Recording) UDF - Automate the HyperCam screen recorder | Twitter UDF - Automate Twitter using OAuth and the Twitter API | cURL UDF - a UDF for transferring data with URL syntax

See my other Tools:

Rapid Menu Writer - Add menus to DVDs in seconds | TV Player - Automates the process of playing videos on an external TV / Monitor | Rapid Video Converter - A tool for resizing and reformatting videos | [topic130531]Rapid DVD Creator - Convert videos to DVD fast and for free | ZapPF - A tool for killing processes and recycling files | Sean's eBay Bargain Hunter - Find last minute bargains in eBay using AutoIT | Sean's GUI Inspector - A scripting tool for querying GUIs | TransLink Journey Planner with maps - Incorporating Google Maps into an Australian Journey Planner | Automate Qt and QWidgets | Brisbane City Council Event Viewer - See what's going on in Brisbane, Australia
Link to comment
Share on other sites

  • 3 weeks later...

Hi Sean, thank you very much for your reply!

You are right, I forgot to mention what script I was exactly trying to use... d'oh.

All I was trying to execute was your example script "_SAPSessAttach.au3" provided in the first post.

Funny you assume, I should call _SAPSessAttach() prior.

Now I am new to all this AutoIt, but this seems not reasonable.

Now I tried your new 3 line example script, to the same effect.

First my SAP asks me if it is okay for a script to connect to SAP GUI. I click okay.

Yeah, I did not turn off these notifications yet, due to debugging and general getting to know all of this.

All of this until now even happens if I do not explicitly add the name of my employer to the window title. But I also did try that.

Then a long time nothing seems to happen at all (~10sec)

Afterwards, that aforementioned error message is displayed.

Yes I have scripting turned on in my Sap Client.

I am using this version of SAP:

Product version.: 710 Final Release

File version....: 7100.2.7.1038

Build number....: 971593

Please tell me any more questions or suggestions you may have, as I am eager to master this, but got too little info to dig into it myself.

Edited by Kebap
Link to comment
Share on other sites

  • 4 weeks later...

Hi Sean!

First of all, great UDF! ;)

I'm trying to use it, but getting no results :/

Here is my code:

#include <SAP.au3>

_SAPSessAttach("SAP Easy Access")

_SAPObjValueSet("tbar[0]/okcd", "XD02")

_SAPVKeysSend("Enter")

sleep(1000)

_SAPSessAttach("Cliente modificar: 1ª tela")

_SAPObjValueSet("usr/ctxtRF02D-KUNNR", "123456")

Here is screen:

Posted Image

What I'm doing wrong? (I've already tryed to use without _SAPSessAttach and _SAPObjSelect)

Also, I discovered that script tool from SAP (the "macro recorder"). Great tool!

I will first try to use just 'AutoIt + SAP UDF' then all 3 of them! :)

Link to comment
Share on other sites

  • 5 weeks later...

Hi all!

Is anyone still reading this who would like to try and help us with our problems?

Any help is greatly appreciated! ;)

edit: I created a new thread in the support forum for this here: http://www.autoitscript.com/forum/index.php?showtopic=107000

Edited by Kebap
Link to comment
Share on other sites

Greetings everyone,

I'm sad to say that I no longer have access to a SAP environment that I can use to further develop this UDF ;)

I knew the day would eventually come. I first layed eyes on SAP back in Jan 2008, and after nearly a year of using it manually (as frustrating as it was at times), I eventually discovered how to incorporate it's GUI Scripting capability into AutoIT, and the UDF was born.

The UDF has been great, and has helped me enormously in my day job working in IT. I'm now working for another client using different products.

If my work does take me back to SAP, then I dare say that there will be a need to pickup where I left off with this UDF. Whereever there is SAP I think there is a need for automation. It's one of those products that can very tedious to use at times.

Thanks everyone for your wonderful comments and positive feedback. It really spurred me on, and drove me to invest more time into this UDF.

Sean.

Edited by seangriffin

Cheers, Sean.

See my other UDFs:

Chrome UDF - Automate Chrome | SAP UDF - Automate SAP | Java UDF - Automate Java Applications & Applets | Tesseract (OCR) UDF - Capture text from applications, controls and the desktop | Textract (OCR) UDF - Capture text from applications and controls | FileSystemMonitor UDF - File, Folder, Drive and Shell Monitoring | VLC (Media Player) UDF - Creating and controlling a VLC control in AutoIT | Google Maps UDF - Creating and controlling Google Maps (inc. GE) in AutoIT | SAPIListBox (Speech Recognition) UDF - Speech Recognition via the Microsoft Speech (SAPI) ListBox | eBay UDF - Automate eBay using the eBay API | ChildProc (Parallel Processing) UDF - Parallel processing functions for AutoIT | HyperCam (Screen Recording) UDF - Automate the HyperCam screen recorder | Twitter UDF - Automate Twitter using OAuth and the Twitter API | cURL UDF - a UDF for transferring data with URL syntax

See my other Tools:

Rapid Menu Writer - Add menus to DVDs in seconds | TV Player - Automates the process of playing videos on an external TV / Monitor | Rapid Video Converter - A tool for resizing and reformatting videos | [topic130531]Rapid DVD Creator - Convert videos to DVD fast and for free | ZapPF - A tool for killing processes and recycling files | Sean's eBay Bargain Hunter - Find last minute bargains in eBay using AutoIT | Sean's GUI Inspector - A scripting tool for querying GUIs | TransLink Journey Planner with maps - Incorporating Google Maps into an Australian Journey Planner | Automate Qt and QWidgets | Brisbane City Council Event Viewer - See what's going on in Brisbane, Australia
Link to comment
Share on other sites

  • 2 weeks later...

Thanks again for the UDF Sean!

It's too bad under the circumstances.

Kebap,

I'm getting an error message on a similar style screen.

C:\Program Files\AutoIt3\Include\SAP.au3 (446) : ==> The requested action with this object has failed.:

$sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).text = $object_value

$sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id)^ ERROR

I have a feeling that there's a problem with the window titles, because the rear window title is the same as the foreground window title it can't find the object (or text box) to input the data you're trying to put in.

This is where i've always gotten stuck, if the window title is different I'm fine.

Sean, I know you don't have SAP but maybe you can recall off the top of your head are there any tricks to having two window called the same thing?

Edited by Teltech
Link to comment
Share on other sites

Firts post. Yey! ;)

First I need to thank you seangriffin for this great project!

I've been playing with it and worked great so far.

I ran to one big problem thought. Some scripting objects are dymamic and get chnaged for every SAP session.

Here's object I need to handle,

/app/con[0]/ses[0]/wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB0:SAPLMEGUI:0030/subSUB1:SAPLMEGUI:1105/txtMEPO_TOPLINE-EBELN

The problem is first SAPLMEGUI. It's value changes for every session. It's always get value between 01 and 20.

I'm getting value from it with _SAPObjValueGet() but for next session code wont work as there are different SAPLEGUI value... :evil:

Is there way to firts find out correct SAPLMEGUI, something like _SAPObjExist()?

Cheers!

Link to comment
Share on other sites

  • 2 weeks later...

Hi I'm a friend of seans (in the real world) and ironically

i've been pulled into the SAP vortex..

This forum has moved to :

http://www.autoitscript.com/forum/index.php?showtopic=107000

please note to get the SAP UDF to WORK

you must also in the 'customise layout menu' of the SAP easy access GUI ..not have the 'Script Recording and playback' menu greyed out

which means server scripting is turned off.

To confirm this further whether you have server scripting turned off..

go

SAP easy access GUI -> customise layout menu - > Script development tools -> Troubleshoot SAP GUI -> Scripting at the server is disabled!

thanks to the SAP wizard (GUI 710) - he quickly tells you what you can't do!

if server scripting is turned off

you will get the error

Unable to find the window with title "SAP Easy Access" to attach to.

C:Program FilesAutoIt3IncludeSAP.au3 (446) : ==> Variable must be of

type "Object".:

$sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).text =

$object_value

$sap_session^ ERROR

to turn on gui scripting use transaction rz11 talk to your sap system support, not sure the actually paramter name to set..sry.

if you want to find more about SAP GUI scripting

http://www.synactive.com/download/sap%20gui%20scripting/sap%20gui%20scripting%20userguide.pdf

Thanks to SEAN ALL HAIL THE GRIFFIN!

Edited by ozmike
Link to comment
Share on other sites

  • 2 months later...

Hi Sean,

I am new to AutoIT. I want to do the following things in SAP using AutoIT.

1. To handle the Mouse Click Events.

2. To enter the Key Board Combinations which includes Function Keys.

For Eg: I Would like to do the key cominations like Control + Shift + F10 from Dictionary: Display Table(SE11) screen

3. To Choose the from Menus like Utilities->Table Contents->Display Table from Dictionary: Display Table(SE11) screen.

Whether it is possible?

Thanks & Regards,

SenthilPandi

Link to comment
Share on other sites

  • 2 months later...

Dear All,

I have record and find out that, these thing does not content in SAP.au3 at func _SAPObjSelect($object_id)

session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").pressToolbarContextButton "&MB_EXPORT"
session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").selectContextMenuItem "&PC"

So, how I can adjust the SAP.au3 and use it.

Tks,

Le Van Duyet

Link to comment
Share on other sites

Dear All,

I have found out

func _SAPObjSelect($object_id)
    Local $SubString
    $sap_object_id = $object_id

    Select

        ; GuiButtons
        Case    StringInStr($object_id, "/btn") > 0

            $sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).press

        ; GuiRadioButton
        Case    StringInStr($object_id, "/rad") > 0

            $sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).select

        ; GuiCheckBox
        Case    StringInStr($object_id, "/rad") > 0 Or _
                StringInStr($object_id, "/chk") > 0

            $sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).selected = True

        ; GuiMenubar
        Case    StringInStr($object_id, "mbar/") > 0

            $sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).select

        ; GuiToolbarContextButton, Duyet add more date: 14.06.2010
        ; So the user must call _SAPObjSelect("/usr/cntlCONTAINER/shellcont/shell,&MB_EXPORT,1 ~~> pressToolbarContextButton
        ; So the user must call _SAPObjSelect("/usr/cntlCONTAINER/shellcont/shell,&MB_EXPORT,2 ~~> pressContextMenuItem
    Case    StringInStr($object_id, "shellcont/shell") >0
            $SubString=StringSplit($object_id,",",1)
            ;If it's ToolbarContextButton
            If $SubString[0]=3 and $SubString[3]=1 Then
                ;session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").pressToolbarContextButton "&MB_EXPORT"
                $sap_session.findById("wnd[" & $sap_window_num & "]/" & $SubString[1] ).pressToolbarContextButton($SubString[2])
            ElseIf $SubString[0]=3 and $SubString[3]=2 Then
                ;session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").selectContextMenuItem "&PC"
                $sap_session.findById("wnd[" & $sap_window_num & "]/" & $SubString[1] ).selectContextMenuItem($SubString[2])
            EndIf

        ; GuiLabel
        Case    StringInStr($object_id, "/lbl") > 0

            ; If the GuiLabel is not an expanded twistie, then select it (for a GuiLabel twistie, this will expand it)
            if StringCompare($sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).text, "5") <> 0 Then

                $sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).setFocus
                $sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).caretPosition = 1
                _SAPVKeysSend("F2")
            EndIf
    EndSelect

    Return 1
EndFunc

But the red one shown error:

D:\Study_All\Learning_AutoIt\SAP.au3 (392) : ==> The requested action with this object has failed.:
$sap_session.findById("wnd[" & $sap_window_num & "]/" & $SubString[1] ).selectContextMenuItem($SubString[2])
$sap_session.findById("wnd[" & $sap_window_num & "]/" & $SubString[1] )^ ERROR

Anyone know.

Tks,

Le Van Duyet

Edited by levanduyet
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...