Kebap Posted December 17, 2009 Share Posted December 17, 2009 (edited) Hi all, since the other forum does not want to be considered a general support forum, but merely a place to share working scripts, I will cross-post my questions again here. Please look at this thread: http://www.autoitscript.com/forum/index.php?showtopic=86574 (My posting starts on page 3) On the last page, there is a detailed description of my problem. In short, I can connect the SAP UDF to my SAP, but then get a weird error message, that I do not understand how to fix... Even the author thought it should work just fine, but has not responded anymore for some weeks and months now. Now I am new to all this AutoIt but eager to learn more and would like any of the more experienced users to please have a look at this and suggest some advice. Thanks in advance! Edited January 5, 2010 by Kebap Link to comment Share on other sites More sharing options...
Teltech Posted December 29, 2009 Share Posted December 29, 2009 Hi all,since the other forum does not want to be considered a general support forum, but merely a place to share working scripts, I will cross-post my questions again here. Please look at this thread:http://www.autoitscript.com/forum/index.php?showtopic=86574On the last page, there is a detailed description of my problem. In short, I can connect the SAP UDF to my SAP, but then get a weird error message, that I do not understand how to fix... Even the author thought it should work just fine, but has not responded anymore for some weeks and months now.Now I am new to all this AutoIt but eager to learn more and would like any of the more experienced users to please have a look at this and suggest some advice.Thanks in advance! What is the error message you're getting?. Link to comment Share on other sites More sharing options...
Kebap Posted December 30, 2009 Author Share Posted December 30, 2009 Hi Teltech, thanks for replying! My error is this: Variable must be of type "Object". And here is a copy of the status quo from the other thread, for your convenience: ... 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. 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. 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. Thanks in advance for your time reading through all this! Link to comment Share on other sites More sharing options...
Teltech Posted January 5, 2010 Share Posted January 5, 2010 Hi Teltech, thanks for replying! My error is this: Variable must be of type "Object".And here is a copy of the status quo from the other thread, for your convenience:Thanks in advance for your time reading through all this! You've got me stumped, sean went over exactly what I would've done. If you're running one of the example scripts I can assume only two things. One is the example script was changed. Two, it's something to do with SAP 710 because it works fine on my machine with 640.Do any of the other examples work? Link to comment Share on other sites More sharing options...
Kebap Posted January 5, 2010 Author Share Posted January 5, 2010 (edited) No, none of the other examples work. I tried them all out, to some slightly different errors, as you can read below. Also, I tried the previous SAP.au3 version v0.3, result: The same error message as before, but a different line mentioned (158). I will call this error number e2. So I tested one by one all the examples provided in the other thread's main post. Here are the results: * _SAPSessCreate.au3 - Result: same error as always before. I will call that error number e1, because it was the original error. * _SAPVKeysSend.au3 - Result: new error (error number e3) Line 236 (File "...\SAP.au3"): $sap_session.findById("wnd[" & $sap_window_num & "]").sendVKey($vkey_id) $sap_session^ ERROR Error: Variable must be of type "Object".* _SAPVKeysSendUntilWinExists.au3 - Result: error e3 * _SAPObjSelect.au3 - Result: error e3 * _SAPObjValueSet.au3 - Result: new error e4: Line 446 (File "...\SAP.au3"): $sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).text = $object_value $sap_session^ ERROR Error: Variable must be of type "Object".* _SAPObjValueGet.au3 - Result: also error e4 * _SAPObjPropertySet.au3 - Result: also error e4 * _SAPObjPropertyGet.au3 - Result: also error e4 * _SAPWinExists.au3 - Result: back to error e1 * _SAPWinClose.au3 - Result: error e1 As far as your assumptions go... 1) The example scripts provided in the other thread may have been changed in the past. But I tried the most simple other examples, provided by sean etc. (see above) and still get the same results. 2) There was someone in the other thread stating he uses the UDF with his SAP 710, so in theory it should work at my place too? maybe I have a no. 3) Is it possible for my employee to have some security or obscurity installed, that may hinder my AutoIt to connect to my Sap client? I know we did a lot of changes to the Sap to better suit our companys needs. However, as I still don't understand the errors I am getting here, I don't know if maybe those changes somehow affect all this. Maybe someone has any additional ideas on how I can test this and further clarify the exact error that is happening here. Edited January 5, 2010 by Kebap Link to comment Share on other sites More sharing options...
Teltech Posted January 7, 2010 Share Posted January 7, 2010 No, none of the other examples work. I tried them all out, to some slightly different errors, as you can read below. Also, I tried the previous SAP.au3 version v0.3, result: The same error message as before, but a different line mentioned (158). I will call this error number e2. So I tested one by one all the examples provided in the other thread's main post. Here are the results: * _SAPSessCreate.au3 - Result: same error as always before. I will call that error number e1, because it was the original error. * _SAPVKeysSend.au3 - Result: new error (error number e3) Line 236 (File "...\SAP.au3"): $sap_session.findById("wnd[" & $sap_window_num & "]").sendVKey($vkey_id) $sap_session^ ERROR Error: Variable must be of type "Object".* _SAPVKeysSendUntilWinExists.au3 - Result: error e3 * _SAPObjSelect.au3 - Result: error e3 * _SAPObjValueSet.au3 - Result: new error e4: Line 446 (File "...\SAP.au3"): $sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).text = $object_value $sap_session^ ERROR Error: Variable must be of type "Object".* _SAPObjValueGet.au3 - Result: also error e4 * _SAPObjPropertySet.au3 - Result: also error e4 * _SAPObjPropertyGet.au3 - Result: also error e4 * _SAPWinExists.au3 - Result: back to error e1 * _SAPWinClose.au3 - Result: error e1 As far as your assumptions go... 1) The example scripts provided in the other thread may have been changed in the past. But I tried the most simple other examples, provided by sean etc. (see above) and still get the same results. 2) There was someone in the other thread stating he uses the UDF with his SAP 710, so in theory it should work at my place too? maybe I have a no. 3) Is it possible for my employee to have some security or obscurity installed, that may hinder my AutoIt to connect to my Sap client? I know we did a lot of changes to the Sap to better suit our companys needs. However, as I still don't understand the errors I am getting here, I don't know if maybe those changes somehow affect all this. Maybe someone has any additional ideas on how I can test this and further clarify the exact error that is happening here. It's possible that scripting is not installed on the server, or has been disabled. Link to comment Share on other sites More sharing options...
SeF Posted January 7, 2010 Share Posted January 7, 2010 Have you tryed using only COM Object commands instead of SAP UDF? Like: Opt("WinTitleMatchMode", 2) WinWaitActive("SAP Easy Access") ;>>>>>>>>Use this instead of _SAPSessAttach()>>>>>>>>> $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) Link to comment Share on other sites More sharing options...
Kebap Posted January 7, 2010 Author Share Posted January 7, 2010 (edited) Hi Teltech, It's possible that scripting is not installed on the server, or has been disabled. You are referring to this, right? > To enable the SAP GUI Scripting interface: > From the SAP GUI, select the "Customize Local Layout" button on the toolbar > Select "Options". > Select the "Scripting" tab. > If the message "Scripting is installed!" is not displayed, then contact your SAP administrators to have SAP GUI Scripting installed. Well, my message clearly states: "Scripting is installed". Is it still possible to be somehow disabled and how can I test it? Hi SeF, thanks for the script! When I try to run it via AutoIT, a new error appears (e5): Line 8 (File "...\SeF.au3"): $session = $connection.Children(0) $session = $connection.Children(0)^ ERROR Error: The requested action with this object has failed. I will try to read up on how to access COM objects without using AutoIT... as this is also new to me. *sigh* Edited January 7, 2010 by Kebap Link to comment Share on other sites More sharing options...
SeF Posted January 8, 2010 Share Posted January 8, 2010 Have you already tryed recording a macro using the 'script recording and playback' from the own SAP? Link to comment Share on other sites More sharing options...
Kebap Posted January 8, 2010 Author Share Posted January 8, 2010 (edited) No SeF, I didn't know it existed. Now I looked for it and it is greyed out. I then tried the menu entry "Script Development Tools" below. And there I found out that "Scripting is not activated on server". Geez, now what? I just wanted AutoIT to do some clicks and entries in my client window. I don't understand how that can be impossible b/c some entry on the server...? The client is on my desktop, and I can click it, so AutoIT should be able as well? Edited January 8, 2010 by Kebap Link to comment Share on other sites More sharing options...
SeF Posted January 9, 2010 Share Posted January 9, 2010 No SeF, I didn't know it existed. Now I looked for it and it is greyed out. I then tried the menu entry "Script Development Tools" below. And there I found out that "Scripting is not activated on server". Geez, now what? I just wanted AutoIT to do some clicks and entries in my client window. I don't understand how that can be impossible b/c some entry on the server...? The client is on my desktop, and I can click it, so AutoIT should be able as well?Strange. It seems that is installed, but not activated.Try activating somehow. See If that helps: http://sapport.blogspot.com/2008/10/activating-scripting-in-sap-gui.htmlOr you will need to manage your SAP by using AutoIt's commands only, and forget about SAP Scripting/SAP UDF.My advice is that you try hard to use Scripting in your SAP, it's much better and faster Link to comment Share on other sites More sharing options...
jormatus Posted January 18, 2010 Share Posted January 18, 2010 Hi guys! Do you have any problems with SAP "living" objects? My problem stated on original post's last page. In short, SAP scripting objects might change their names on each logon. So it gets difficult to Set Object Value if object doesn't exists. How can I check if and what (SAP) object exists before calling them?? Probably really simple but being AutoIt newbie I don't get it. Link to comment Share on other sites More sharing options...
water Posted August 6, 2010 Share Posted August 6, 2010 Just for the records:I'm using the SAP UDF with SAPGUI 7.20 and Windows 7 without problems (so far).I had problems running Scripting on SAPGUI 7.10 on Windows XP SP2 at all. Even the SAPGUI record and playback function didn't work and always returned (Error)(03.08.10 16:08:57.262): LoadLibrary failed for sapfewse.ocx (Error) : CMainFrame::RecordScript: pSessionDispatch is NULL Not sure if this is a problem with our installation or with SAPGUI. Could not find anything related on SAP OSSTo make scripting run i had to set a server parameter: "In order to use scripting within SAP GUI you need to activate several settings. First one is on level of your SAP application server by instance profile parameter: sapgui/user_scripting = TRUE This parameter is set to false by default. You can do this modification via TA RZ11."And last but not least: Thank you Sean for this great UDF! My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Kebap Posted August 9, 2010 Author Share Posted August 9, 2010 Or you will need to manage your SAP by using AutoIt's commands only, and forget about SAP Scripting/SAP UDF.Can somebody please explain to me, what that is supposed to mean? I am willing to try every suggestion.My advice is that you try hard to use Scripting in your SAP, it's much better and faster I think so, too, however my employer (=SAP admin) does not seem to think so. So I can't change the server's settings. Link to comment Share on other sites More sharing options...
water Posted August 9, 2010 Share Posted August 9, 2010 (edited) Or you will need to manage your SAP by using AutoIt's commands only, and forget about SAP Scripting/SAP UDF.That means to automate SAP as you would automate any other application. Send keystrokes or - if possbible - send data to controls.... however my employer (=SAP admin) does not seem to think so. So I can't change the server's settings.The server option does not do anything on the server. It's only a global setting to allow/disallow scripting on the clients side.There is no security issue with scripting as you can only do what you can do manually.There is a security guide available from SAP.So, try to convince your SAP admin. Edited August 9, 2010 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now