StSchnell Posted February 13, 2013 Share Posted February 13, 2013 (edited) Hello community,the SAP GUI for Windows offers an SAP GUI Scripting recorder to record manual activities. Press Alt+F12 to open the Local Layout menu and choose Script recording and playback item to open the recorder. The activities are stored in VBScript language, but it is very easy to use the recording results with AutoIt. It is only necessary to set a $ sign before the session variable and to set a stub in front of the recording results.Here an example for a login:;-Begin----------------------------------------------------------------- ;-Variables----------------------------------------------------------- Dim $SAPROT, $SapGuiAuto, $application, $connection, $session $SAPROT = ObjCreate("SapROTWr.SAPROTWrapper") If Not IsObj($SAPROT) Then Exit EndIf $SapGuiAuto = $SAPROT.GetROTEntry("SAPGUI") If Not IsObj($SapGuiAuto) Then Exit EndIf $application = $SapGuiAuto.GetScriptingEngine() If Not IsObj($application) Then Exit EndIf $connection = $application.Children(0) If Not IsObj($connection) Then Exit EndIf $session = $connection.Children(0) If Not IsObj($session) Then Exit EndIf;-SAP GUI Scripting from recorder starts here---------------------------$session.findById("wnd[0]/usr/txtRSYST-MANDT").text = "099"$session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "Hugo"$session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "Bambi"$session.findById("wnd[0]/usr/txtRSYST-LANGU").text = "DE"$session.findById("wnd[0]/tbar[0]/btn[0]").press();-End-------------------------------------------------------------------The $session.findById code is direct from the SAP GUI Scripting recorder. With a search and replace it is very easy to set a $ in front of session.You find the equivalent posting in the SAP Community Network here.CheersStefan Edited February 13, 2013 by StSchnell Meet me at XING Visit my private homepage Visit my commercial homepage Look at my book inter alia about AutoIt and SAP Link to comment Share on other sites More sharing options...
Tom8SAP Posted October 7, 2013 Share Posted October 7, 2013 Hi Appreciate your post and I have a question that I can't seem to find with google. Tried various ways to accomplish a simple goal of seleting a Tab in SAP trnasaction IW32. See Code. I can often jump from Tab Additional Data to HeaderDate and then to Component Tab but after that everything fails. Do you have Hint that you can give? Below is a simple form with the Tabs I would like to be able to select. After clicking the button you have 3 seconds to select the SAP module. It then connects to SAP and tries to Select the desired Tab. Thanks for any HELP #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #region Global $sapGUI, $sapAPP, $sapConnection, $sapSession #endregion #Region ### START Koda GUI section ### Form=E:ProgramsAutoIt3koda_1.7.3.0FormsSAP_Test.kxf $frmSap_Test = GUICreate("SAP", 158, 182, 487, 200) $cmdHeader = GUICtrlCreateButton("Header Data", 16, 8, 121, 25) $cmdOperation = GUICtrlCreateButton("Operation", 16, 40, 121, 25) $cmdComponents = GUICtrlCreateButton("Components", 16, 72, 121, 25) $cmdPartner = GUICtrlCreateButton("Partner", 16, 104, 121, 25) $cmdLocation = GUICtrlCreateButton("Location", 16, 140, 121, 25) GUISetState(@SW_SHOW) WinSetOnTop($frmSap_Test, "", 1) ConsoleWrite(@CRLF) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cmdHeader Call(_HeaderClick()) Case $cmdOperation Call(_OperationClick()) Case $cmdComponents Call(_ComponentsClick()) Case $cmdPartner Call(_PartnerClick()) Case $cmdLocation Call(_LocationClick()) EndSwitch WEnd Func _ConnectToSAP() Sleep(3000) $sapGUI = ObjGet("SAPGUI") $sapAPP = $sapGUI.GetScriptingEngine $sapConnection = $sapAPP.Children(0) $sapSession = $sapAPP.ActiveSession EndFunc Func _HeaderClick() Call(_ConnectToSAP()) ConsoleWrite("Click Header Tab" & @CRLF) $sapSession.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1100/tabsTS_1100/tabpIHKZ").Select EndFunc Func _OperationClick() Call(_ConnectToSAP()) ConsoleWrite("Click Operation Tab" & @CRLF) $sapSession.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1100/tabsTS_1100/tabpVGUE").Select EndFunc Func _ComponentsClick() Call(_ConnectToSAP()) ConsoleWrite("Click Component Tab" & @CRLF) $sapSession.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1100/tabsTS_1100/tabpMUEB").Select EndFunc Func _PartnerClick() Call(_ConnectToSAP()) ConsoleWrite("Click Partner Tab" & @CRLF) $sapSession.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1100/tabsTS_1100/tabpPARU").Select EndFunc Func _LocationClick() Call(_ConnectToSAP()) ConsoleWrite("Click Location Tab" & @CRLF) $sapSession.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1100/tabsTS_1100/tabpILOA").Select EndFunc Link to comment Share on other sites More sharing options...
water Posted October 8, 2013 Share Posted October 8, 2013 Welcome to AutoIt and the forum! When posting code please add code tags (by using the blue AutoIt icon in the editor). Will greatly enhance readability My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - 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