Technical Articles
Scripting Tracker – Development Tool for SAP GUI Scripting
Over two years ago I presented here the lite version of Scripting Tracker. Scripting Tracker is a utility and a replacement to the SAP GUI Scripting Development Tools. It is a SAP GUI analyzer and recorder on SAP GUI Scripting base. Now I decided to make all features of Scripting Tracker free available. In this case it means that the recording module is also free available from now.
The analyzer shows a clearly arranged tree with all SAP sessions and its scripting objects. Also it shows for each scripting object, after the selection in the tree with a single mouse click, a lot of technical details like e.g. ID, position etc.
With the recorder the program offers the possibility to record, edit and execute your SAP GUI activities in PowerShell Windows and PowerShell Core, Visual Basic on Windows Scripting Host, AutoIt or Python script language. Also it is possible to record your activities in Java language. E.g. with the + button you enriches the source with information comment lines about the transaction, title, dynpro – program name and screen number – and the session number. With Scripting Tracker you have full visual control about the creating code, now it couldn’t be easier to use SAP GUI Scripting.
The Scripting API viewer shows the complete SAP GUI Scripting API in an organized tree, analogous to the SAP GUI Scripting API help file. It is possible with a double click to copy the signature in the clipboard to use it in your code. Also it shows the methods and properties vis-à-vis, this means you can find a method or property and the classes where they are available.
With the Comparator you can compare screen elements of different screens to find differences.
The DumpState delivers a hierarchy of collections with detailed information about the state of an object.
You can find Scripting Tracker here.
2020/02/08 Update 4.35 of Scripting Tracker is available
- Switch to JShell instead Java code generation
- Checked with JDK 13.0.2
- Checked with PowerShell Core 7.0.0 Release Candidate 2
- Checked with Python 3.8.1
- For more transparency added OutputDebugString for external program calls
- For more transparency the recorder control dialog is now no longer an invisible window
- Many improvements in details
- Minor bug fixing
2020/01/25 Update 4.30 of Scripting Tracker is available
- Checked with SAP GUI for Windows 7.60 Patch Level 4
- Checked with PowerShell Core 7.0.0 Release Candidate 1
- Corrections of the PowerShell Core 7 COM integration
- Added SAP GUI Scripting registry settings in the customizing tab
- Integration of the new SAP GUI for Windows 7.60 HTML help file
- More content in the help file
- Many more improvements in details
- Minor bug fixing
2019/11/21 Update 4.20 of Scripting Tracker is available
- Implementation of PowerShell Core support
- Extension of help file with integration scenarios of UiPath RPA and SAP GUI Scripting with different programming languages
- Many improvements in details
- Minor bug fixing
2018/10/28 Update 4.10 of Scripting Tracker is available
- Many improvements in details
- Minor bug fixing.
2018/06/01 Update 4.01 of Scripting Tracker is available
- Integration of code composer.
- Extension of the snippets with WebUI automation examples.
- Export of analyser tree.
- Many improvements in details.
- Minor bug fixing.
2017/09/21 Update 3.25 of Scripting Tracker is available
- Implementation of Python code recording
For integrative tasks, with the perspective of test automation, the Python support was implemented. To use SAP GUI Scripting in the context of Python you need PyWin32 extension. - Adding a Note tab as textual memory.
- Many improvements in details
- Minor bug fixing.
2017/09/03 Update 3.21 of Scripting Tracker is available
- Includes AutoItX
Scripting Tacker includes now AutoItX to use it seamlessly in the context of SAP GUI Scripting. It is a fabulous addition e.g. to control non SAP GUI dialogs. - Many improvements in details
2017/07/24 Update 3.20 of Scripting Tracker is available
- Implementation of DumpState
The DumpState delivers a hierarchy of collections with detailed information about the state of an object. - Implementation of another perspective to the SAP GUI Scripting API
Now it shows the methods and properties vis-à-vis, this means you can find a method or property and the classes where they are available. - Many improvements in details
- Check with SAP GUI for Windows 7.50 PL 1
- Check with Windows 10 and 7
2017/03/31 Update 3.15 of Scripting Tracker is available
- Implementation of Java™ code recording
More and more is the SAP GUI for Windows not longer the primary UI for the user activities in the context of SAP. With the perspective of UI5 and START I implement the Java™ code recording possibility, to offer an integration with other UI technologies e.g. via Selenium.
Hint: To use SAP GUI Scripting in the context of Java™ you need the Java COM Bridge (JACOB).
2016/12/13 Update 3.11 of Scripting Tracker is available
- Implementation of a ROT viewer
2016/10/02 Update 3.10 of Scripting Tracker is available
- Removal of VBScript control, because the relevance is insignificant now and the possibilities are limited. Use instead Windows Scripting Host (WSH) with VBScript.
- For such reasons removal of VBScript debugging via WSH.
- PowerShell is now the major language.
- Scripting Tracker uses now UTF-8 as standard.
- Codepage additions for Windows Scripting Host (WSH), because WSH is not able to use UTF-8 encoded files.
2016/07/20 Update 3.00 of Scripting Tracker is available
- Implemetation of an object browser which shows the classes, methods, properties, enumerations and constants of the SAP GUI Scripting API
- Minor changes
2016/03/12 Update 2.30 of Scripting Tracker is available
- Complete redesign of the recorder module
- Native PowerShell code generation
2016/02/25 Update 2.23 of Scripting Tracker is available
- Help file return to CHM format
- Minor changes
2015/10/24 Update 2.22 of Scripting Tracker is available
- Actualization of the recorder module to GUI 7.40
- Minor bug fixing
2015/09/05 Update 2.20 of Scripting Tracker is available
- Add the Comparator tab, to compare screens with its elements and find differences between them easily.
- Disable the possibility to export list of screen elements as CSV file.
2015/03/29 Update 2.12 of Scripting Tracker is available
- Integration of AutoIt recorder now possible
- Add the possibility to save a complete source file via shift and save button
- Disable support of MiniRobot, because it has no relevance
- Minor bug fixing
Comments are welcome.
Thank you Stefan for all your work. Its very powerful tool and useful tool.
I actually have a question for you, which scripting language do you think is best to use for recording SAPGUI transaction/activities?
-Adelina
Hello Adelina,
thanks for your reply.
Your question is not easy to answer, because it depends from the perspective I think.
I mean each language has advantages and disadvantages. Take your language decision in dependent to your problem or mix the languages and take the best from each of them.
My list of favorites is
Hope my explanation helps a little bit for your decision.
Cheers
Stefan
Hello Stefan,
I discovered your videos about the Scripting Tracker and SAP's ability to automate using vbscript a few weeks ago. Thank you so much!!! You have been the answer to my prayers. I've been working diligently (10hrs per day) trying to automate the VA01 sales order process ever since learning about these tools.
Reading through all the SAP forums Online has been extremely helpful and I'm almost at the finish line. The only remaining part where I'm completely lost is the scroll bar (GuiTableControl)
I read through yours and Sayuti's examples on this topic and tried every combination over and over and still cannot place more than 16 rows of data in the SAP table before it crashes and we sometimes receive sales orders that require up to 99 rows!
(16 rows are what is visible before moving the scroll bar.) Am I missing a step from your instructions? Do I need to declare an Object that activates the scrollbar?
I should also note that the scroll bar doesn't even appear until after at least one line item and quantity is placed on a row and you press enter. Is there a way around this? Ideally I would love to just open SAP and have the Scrollbar available already.
I replied to one of Sayuti's threads about this...but since the thread was answered a couple years ago...not sure if he can see it. I really need your guidance on this one...I'm sleep deprived and stressed out.
The photo above is the table I'm using. Notice: there is no scroll bar and there are 16 visible rows.
Below is my code. I used the example from the thread "VA02 Sales Order Automation" http://scn.sap.com/thread/3437497 but it does not work for me. I should also note TotalRow and VisibleRow both = 16 So my BlankRow is always = 0. Thanks a TON!!!
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
Dim SapGuiApp, Connection, Session, FileObject, oFile, Counter
Dim ApplicationPath, CredentialsPath, ServerPath, FilePath
Dim ExcelApp, ExcelWorkbook, ExcelSheet
Dim sRow, eRow, J
Dim BlankRow, TotalRow, VisibleRow, Scroll
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelWorkbook = ExcelApp.Workbooks.Open("C:\Personal\01654\Desktop\SAP Automation\TestOrder00.xlsx")
Set ExcelSheet = ExcelWorkbook.Worksheets(1)
eRow = 1
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").text = "VA01"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtVBAK-AUART").text = "ZWO"
session.findById("wnd[0]/usr/ctxtVBAK-VTWEG").text = "10"
session.findById("wnd[0]/usr/ctxtVBAK-VTWEG").setFocus
session.findById("wnd[0]/usr/ctxtVBAK-VTWEG").caretPosition = 2
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4021/txtVBKD-BSTKD").text = ExcelSheet.Range("F5").value
session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4021/subPART-SUB:SAPMV45A:4701/ctxtKUAGV-KUNNR").text = ExcelSheet.Range("F4").value
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/ctxtRV45A-KETDAT").text = ExcelSheet.Range("F6").value
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/ctxtRV45A-DWERK").text = ExcelSheet.Range("F7").value
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").VerticalScrollbar.position = 0
TotalRow = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").RowCount
VisibleRow = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").VisibleRowCount
BlankRow = TotalRow - VisibleRow
If BlankRow > VisibleRow Then
Scroll = BlankRow - VisibleRow + 1
sRow = VisibleRow - 1
Else
Scroll = 0
sRow = BlankRow
End If
For J = 1 To 30
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").VerticalScrollbar.position = Scroll
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-MABNR[1,"& sRow & "]").text = ExcelSheet.Cells(eRow, 2)
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/txtRV45A-KWMENG[2,"& sRow & "]").text = ExcelSheet.Cells(eRow, 1)
eRow = eRow + 1
sRow = sRow + 1
Next
Hello Leonard,
thanks for your reply about Scripting Tracker.
If I could really help you, I would, but I have no access to a system which offers VA02 functionality completely. In my company we have our own namespaces and we develop special health insurance solutions as add-on on the SAP standard - no SD-SLS. So I can give you only untested advices.
Anyway, I hope I can help you - as best I can.
I look for a similar, from the behavior, transaction and I found SR13 (Setting Variants for Help). The table object offers in my case 21 lines and after 21 lines of adding new entries, via SAP GUI Scripting, I get an error. So I check out, what to do if I do the same activity manually and I recorded it. With this knowledge I create an SAP GUI Script like this:
For j = 1 To 4
For i = 0 To 15
session.findById("txtSADM2D-NAME[0," + CStr(i) + "]").text = "HUGO" + CStr(i + i * j)
session.findById("ctxtSADM2D-PLATFORM[1," + CStr(i) + "]").text = "NONE"
session.findById("ctxtSADM2D-AREA[2," + CStr(i) + "]").text = "IWBTRAIN"
session.findById("ctxtSADM2D-SHLPLANG[4," + CStr(i) + "]").text = "DE"
If (i Mod 16 = 0) And (i <> 0) Then
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[1]/btn[2]").press
session.findById("wnd[0]/tbar[1]/btn[16]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[1]/btn[6]").press
End If
Next
Next
I add 64 entries in four blocks á 16 entries and after a 16 entries block I save the new entries on a transport.
My tip for you is: Look what you do manually if your customer send an order with more than 16 entries and do the same with your SAP GUI Scripting program. Break your oders into parts and proceed it step by step, or block by block.
Sorry for my abstract approach, but it is all I can say about it.
Cheers
Stefan
Hi Stefan, It's a little hard to tell if this is still an active blog, given the dates of the posts. But I have successfully used scripting tracker to run and play back AutoIT scripts (from scripting Tracker only); What I am having difficulty with is running these scripts from AutoIT, Powershell, or another tool, because the $session variable value is not included or set in the script. I am particularly needing the Python scripts to work, as I want to integrate with Robot Framework. If anyone has solved this, and can post script or links, I would appreciate it.
Many Thanks!
Steve
Hi Steve,
please post your question here to receive help by community members: https://answers.sap.com/questions/ask.html
Thanks.
Mynyna (SAP Community moderator)
Hi Stefan,
Scripting tracker is very good tool..!! Thanks for sharing it.
I have a small problem here, hope you can explain it to me.
When I use recorder part of tool and try to save some part where a dialog box pops up - "SAVE AS LOCAL" that part is not getting recorded by tool.
Below is my small example.
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").text = "/nstrustsso2"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/shellcont/shell").selectedNode = "SSLSDFAULT"
session.findById("wnd[0]/shellcont/shell").doubleClickNode "SSLSDFAULT"
session.findById("wnd[0]/shellcont/shell").doubleClickNode "SSLSDFAULT"
session.findById("wnd[0]/usr/txtPSE-OWNCERT-SUBJECT").setFocus
session.findById("wnd[0]/usr/txtPSE-OWNCERT-SUBJECT").caretPosition = 2
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]/usr/btnREQUEST").press
Once this part runs there is a button on top extreme right "save as local file" and functionality after that is not getting captured in tool.
What I m trying to do here is to save that file to local dekstop - so that when ever script runs it generates the file always on my dekstop.
Waiting for your expert suggestions.
Regards
Deepak
Hello Deepak,
welcome in this forum and thanks for your request.
The SSO dialog is in the main thing a text edit control and the toolbar is part of this control. As far as I know it is not possible to record activities of this toolbar via SAP GUI Scripting.
Tip: Take a look at AutoIt, and you can try this:
Scripting Tracker supports AutoIt, so you can combine activities via SAP GUI Scripting and AutoIt recorder very easily. AutoIt is a powerful scripting language and in combination with SAP GUI Scripting you can nearly do what you want.
Cheers
Stefan
Hi Stefan,
Many thanks for your reply, you made me learn more about scripting today.
What I tried today is below
Tried to code sap part as VB script by scripting tracker tool:
session.findById("wnd[0]/tbar[0]/okcd").text = "/nstrustsso2"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/shellcont/shell").selectedNode = "SSLSDFAULT"
session.findById("wnd[0]/shellcont/shell").doubleClickNode "SSLSDFAULT"
session.findById("wnd[0]/usr/txtPSE-OWNCERT-SUBJECT").setFocus
session.findById("wnd[0]/usr/txtPSE-OWNCERT-SUBJECT").caretPosition = 2
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]/usr/btnREQUEST").press
session.findById("wnd[1]/usr/cntlTEXTEDITCTRL/shellcont/shell").setSelectionIndexes 42, 42
And remaining part which was not getting captured earlier captured it by autoit and got below.
WinWaitActivate("Certificate Request","")
MouseClick("left",222,37,1)
WinWaitActivate("Save As","")
MouseClick("left",51,225,1)
MouseClick("left",49,141,1)
MouseClick("left",231,359,1)
Send("jgdjgd.txt")
MouseClick("left",516,360,1)
WinWaitActivate("Certificate Request","")
MouseClick("left",546,588,1)
But now I have a quick question again: I tried to put both the code in sequence in single VBS script but still it didn't worked - got error as invalid character and some compilations error
Advice if autoit code can be used in scripter tracker ??
Regards
Deepak
Hello Deepak,
AutoIt is an own scripting language, it is not part of Windows, you can find it here. You must download it and install them explicite.
It is not really possible to mix VBScript and AutoIt in one script, so use one of them.
Now a short description how to use AutoIt with Scripting Tracker:
AutoIt = C:\Language\AutoIt\AutoIt3.exe
AutoItRecorder = C:\Language\AutoIt\Au3Record.exe
If you look at my code above you see the $ sign before session, this means it is an AutoIt variable and this code doesn't work with VBScript.
Let us know your results.
Cheers
Stefan
Hi Stefan,
Thanks again..!!
I will try it today and will get back with results soon.
Regards
Deepak
Hi Stefan,
Below are my results.
1) I thought that scripting tracker with new "use autoit script" will record the "save as" local part of screen, but its also not capturing the same.
2) So I tried to this way
a) Captured SAP part with "use autoit script"
b) Captured "save as local" part with autoit recorder part.
c) Combined them in one single script just like you said and used "playback script" but I got an error msg in that too.
Combined script
$session.findById("wnd[0]").resizeWorkingPane(98, 17, 0)
$session.findById("wnd[0]/tbar[0]/okcd").text = "/nstrustsso2"
$session.findById("wnd[0]").sendVKey(0)
$session.findById("wnd[0]/shellcont/shell").selectedNode = "SSLSDFAULT"
$session.findById("wnd[0]/shellcont/shell").doubleClickNode("SSLSDFAULT")
$session.findById("wnd[0]/usr/btnREQUEST").press()
WinWaitActivate("Certificate Request","Control Container")
MouseClick("left",225,45,1)
WinWaitActivate("Save As","Save as &type:")
MouseClick("left",48,148,1)
Send("certificate.txt")
MouseClick("left",495,364,1)
WinWaitActivate("Certificate Request","Control Container")
MouseClick("left",548,584,1)
3) Apart from this: I did noticed one more small problem with "use autoid script" tab.
Problem is when script is recorded and playback - it works fine but
When I save it on local machine and try to run it it gives another error like "variable used without been declared" this I do not see if I do same for VB script.
Regards
Deepak
Hello Deepak,
it seems that the AutoIt recorder uses old commands, change WinWaitActivate to WinWait and all will work well.
You are right, it seems to be a bug in the save routine, you need the following header to execute the AutoIt script correct - thanks for your hint.
And after this code follows your code and all should be run well - I hope.
Cheers
Stefan
Hi Stefan,
Made changes and did playback but still not working perfect as needed
$session.findById("wnd[0]").maximize()
$session.findById("wnd[0]/tbar[0]/okcd").text = "/n"
$session.findById("wnd[0]").sendVKey(0)
$session.findById("wnd[0]/tbar[0]/okcd").text = "/nstrustsso2"
$session.findById("wnd[0]").sendVKey(0)
$session.findById("wnd[0]/shellcont/shell").selectedNode = "SSLSDFAULT"
$session.findById("wnd[0]/shellcont/shell").doubleClickNode("SSLSDFAULT")
$session.findById("wnd[0]/usr/btnREQUEST").press()
WinWait("Certificate Request","")
MouseClick("left",280,13,1)
MouseClick("left",223,46,1)
WinWait("Save As","")
Send("ttt.txt")
MouseClick("left",508,364,1)
To me it looks like once the autoit rec. script comes to action things starts getting messing up and didn't work as expected.(Local save as window opens and never save it as expected)
If you have time - give a shot and try above code or create simillar situation(you know my req.) and try play back.
Regards
Deepak
Hello Deepak,
here the complete code:
Your code is commented because I have another language version.
Cheers
Stefan
Hi Stefan,
Many thanks..!! Works good.
But I would like to learn this stuff...atleast this one as its small and basic.
Please let me know how you get this code and if its done by you please explain and how to get this.
Mine:
WinWait("Certificate Request","")
MouseClick("left",280,13,1)
MouseClick("left",223,46,1)
WinWait("Save As","")
Send("ttt.txt")
MouseClick("left",508,364,1)
Yours:
WinWait("Certificate Request", "")
Local $hWnd = WinGetHandle("Certificate Request")
Local $WinPos = WinGetPos("Certificate Request")
MouseClick("left", $WinPos[0] + 225, $WinPos[1] + 45, 1)
WinWait("Save As", "")
Send("{ALTDOWN}n{ALTUP}test.txt{ALTDOWN}s{ALTUP}")
Regards
Deepak
Hello Deepak,
thank your very much 🙂
It is not so easy to explain, how to get this code, it is experience on the one hand and as well as trial and error on the other. What I can advise you to learn a programming language is to try, try and try again. It is important to never give up and to involve the community, with questions and with your experience, to give tips and answers.
Cheers
Stefan
Hi Stefan,
Thanks..!! and it was nice talking to you always 🙂
Kind words and thanks for motivation too.
Seriouly last 3 days I have learned so manything on scripting and I'll try to keep my learning graph curve up.
Regards
Deepak
Hello community,
I check the actual release of Scripting Tracker in the context of Windows 10 x64 and it works well and as expected.
Enjoy it.
Cheers
Stefan
P.S. Scripting Tracker is now over 3 years available - at first as light version and later the full version. 🙂
This is a wonderful tool. Thanks a lot!
Hello Stefan,
First I would like to congratulate you for the excellent application "Tracker".
In short time of use could already get good results, thank you.
But today when trying to write a script I'm not identify the name of the vertical scroll bar on the transaction QM02, could you help me please.
Thank you.
Hello Marcio,
thank you.
You can find an answer to your question here.
Cheers
Stefan
Hi Stefan! Where I can find the previous versions of Scripting Tracker?
Hello Manuel,
there are no previous versions of Scripting Tracker available.
Do you have any problems?
Cheers
Stefan
Hi Stefan! I don't have any problem only curiosity.
Great Program, works excellent!
Thanks for do it!
Hi Stefan,
thank you for this tool. I wanted to download it but i can't access your website.
Thanks,
Helge
Hello Helge,
thank you very much for your reply. I checked the access to my website via my company account and it works without any problems. I download Scripting Tracker and check the sha256-sum and all works correct. Please try it again and let me know your results.
Thanks and best regards
Stefan
Thank you Stefan. It worked in the meanwhile. Just saw your comment now.
Não é o foco deste post, mas talvez alguém possa me ajudar. Numa aplicação C# utilizando o SAP Scripting, as listas suspensas estão sendo carregadas vazias. Assim ao tentar preencher qualquer informação neste campo, é apresentado um erro impedindo a execução do script. Alguém pode me dizer o que está acontecendo?
Hello Marcos,
I assume you are writing in Portuguese, sorry but I don't understand this. Here the translation from Google translator:
"It's not the focus of this post, but maybe someone can help me. In a C # application using SAP Scripting, the drop-down lists are being loaded empty. So while trying to fill in any information in this field, an error is displayed preventing the script from running. Can anyone tell me what's going on?"
Please open a new question at the SAP GUI for Windows forum to answer this.
Abra uma nova pergunta na SAP GUI para o fórum do Windows para responder a isso.
Best regards
Stefan
Hello Friends,
I am getting the below error while executing my script " The control could not be found by id"
i have pasted the script below. Can you please help.
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
Dim objExcel
Dim objSheet, intRow, i
Set objExcel = GetObject(, "Excel.Application")
Set objSheet = objExcel.ActiveWorkbook.ActiveSheet
For i = 2 to objSheet.UsedRange.Rows.Count
COL1 = Trim(CStr(objSheet.Cells(i, 1).Value)) 'column1
COL2 = Trim(CStr(objSheet.Cells(i, 2).Value)) 'column2
COL3 = Trim(CStr(objSheet.Cells(i, 3).Value)) 'column3
COL4 = Trim(CStr(objSheet.Cells(i, 4).Value)) 'column4
COL5 = Trim(CStr(objSheet.Cells(i, 5).Value)) 'column5
session.findById("wnd[0]/tbar[0]/okcd").text = "/nfpp2"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/usr/ctxtBUS_JOEL_MAIN-OPEN_NUMBER").text = COL1
session.findById("wnd[1]/usr/ctxtBUS_JOEL_MAIN-OPEN_NUMBER").caretPosition = 10
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2036/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_01/ssubSCREEN_1100_TABSTRIP_AREA:SAPLBUSS:0028/ssubGENSUB:SAPLBUSS:7016/subA05P01:SAPLBUA0:0400/subADDRESS:SAPLSZA1:0300/subCOUNTRY_SCREEN:SAPLSZA1:0304/ctxtADDR1_DATA-STREET").text = "PO BOX 2440"
session.findById("wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2036/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_01/ssubSCREEN_1100_TABSTRIP_AREA:SAPLBUSS:0028/ssubGENSUB:SAPLBUSS:7016/subA05P01:SAPLBUA0:0400/subADDRESS:SAPLSZA1:0300/subCOUNTRY_SCREEN:SAPLSZA1:0304/ctxtADDR1_DATA-CITY1").text = "SPOKANE"
session.findById("wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2036/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_01/ssubSCREEN_1100_TABSTRIP_AREA:SAPLBUSS:0028/ssubGENSUB:SAPLBUSS:7016/subA05P01:SAPLBUA0:0400/subADDRESS:SAPLSZA1:0300/subCOUNTRY_SCREEN:SAPLSZA1:0304/ctxtADDR1_DATA-REGION").text = "WA"
session.findById("wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2036/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_01/ssubSCREEN_1100_TABSTRIP_AREA:SAPLBUSS:0028/ssubGENSUB:SAPLBUSS:7016/subA05P01:SAPLBUA0:0400/subADDRESS:SAPLSZA1:0300/subCOUNTRY_SCREEN:SAPLSZA1:0304/txtADDR1_DATA-POST_CODE1").text = "99210-2440"
session.findById("wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2036/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_01/ssubSCREEN_1100_TABSTRIP_AREA:SAPLBUSS:0028/ssubGENSUB:SAPLBUSS:7016/subA05P01:SAPLBUA0:0400/subADDRESS:SAPLSZA1:0300/subCOUNTRY_SCREEN:SAPLSZA1:0304/txtADDR1_DATA-POST_CODE1").setFocus
session.findById("wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2036/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_01/ssubSCREEN_1100_TABSTRIP_AREA:SAPLBUSS:0028/ssubGENSUB:SAPLBUSS:7016/subA05P01:SAPLBUA0:0400/subADDRESS:SAPLSZA1:0300/subCOUNTRY_SCREEN:SAPLSZA1:0304/txtADDR1_DATA-POST_CODE1").caretPosition = 2
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
aux=col1 & " " & col2 & " " & col3 & " " & col4 & " " & col5
CreateObject("WScript.Shell").run("cmd /c @echo %date% %time% " & aux & " >> C:\SCRIPT\PlOrCreationLog.txt")
next
msgbox "Process Completed"
Hello Stefan,
Thank you for releasing such a wonderful tool. Its of great help while scripting. While analyzing the SAP GUI window, i am unable to view the analysis of win[1] window . It only shows me the analysis of win[0] window. Do i need to take care of any steps to analyze the win[1] window?
Regards,
Kaushal
Hello Kaushal,
thank you very much for your kindful words.
In a normal case are multiple windows no problem. Here an example:
Are your really sure that the additional window is a SAP GUI window? Could it be possible that this is a native Windows dialog? Please let us know more details about your scenario.
Best regards
Stefan
Hi Stefan,
I’m currently using Scripter Tool which has been very helpful while automating the SAP GUI using Python. Thanks for such an Awesome tool.
I’m currently stuck with a problem where i would like to capture the text of Shell object
Hello Raghavendran,
thanks for your comment.
You can try this to get the content of a field inside an ALV grid:
The example is in VBScript but I hope this helps you.
This could look in your case like this:
Let us know your results.
Best regards
Stefan
Hi Stefan,
Thanks for your response, I have tried the code and getting the below error - (I'm still trying to understand the root cause) meanwhile sharing the error message -
Traceback (most recent call last):
File "C:/Users/rrama3/PycharmProjects/SAPGUI_Automation/com/nike/tests/testBusinessComponents/coupaPOCheck.py", line 74, in <module>
Columns = table.columnOrder()
File "C:\Users\rrama3\venv\sapguiautomate\lib\site-packages\win32com\client\dynamic.py", line 197, in __call__
return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (618, 'sapfewse', 'Bad index type for collection access.', None, 0, 0), None)
Hello Raghavendran,
delete the brackets and it will work.
Best regards
Stefan
Hi Stefan,
Thanks alot for your timely respone, as mentioned by you removing the brackets solved my issue.
Scripting Tracker tool has simplified my major efforts to automate the SAP GUI flows.
Thanks again.
Hi Stefan,
I tried the below code from Scripting Tracker for selecting tab. But it is throwing an error. I also tried selecting through menu bar and it’s throwing the same error. Need help with the selection of tabs.
Error:
Invoke of: findById
Source: SAP Frontend Server
Description: The control could not be found by id.
Code to select tab:
Obj = new ActiveXComponent(Session.invoke(“findById”, “wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\11”).toDispatch());
Obj.invoke(“select”);
Code to select through menu:
Obj = new ActiveXComponent(Session.invoke(“findById”, “wnd[0]/mbar/menu[2]/menu[1]/menu[12]”).toDispatch());
Obj.invoke(“select”);
Hello Neha,
I don’t know what your problem is. I tried it and it works in my case without any problems.
Cheers
Stefan
Hi Stefan,
I would like to download/dump the information from "Scripting Tracker Tool" Analyser tab to a text file , in order to get all ID and Names.
I'm trying to get this, so that i can create locaters (similar to Page Object model in java) in python and use them and not hardcode during my scripting.
Please let me know if you can help me with this request.
Thanks,
Raghav
Hi Stefan,
I'm trying to handle parallel execution of SAP GUI with same user and different systems in the same PC.
I would like to know if i can use the Handle id as highlighted in below screenshot to find the connection details like '/app/con[0]/ses[0]' or vice-versa ?
Please let me know if i can get this handle id using python scripting , currently i'm able to iterate over username and system name to find the connection detail of SAP GUI before running my script (while running multiple scripts) , but would like to know if i can use this handle id to get the connection details (like '/app/con[0]/ses[0]') ???
Hello Raghavendran,
it is absolut no problem to use different SAP GUI sessions, with different systems, parallel on one frontend server with SAP GUI Scripting on SAP GUI for Windows.
To your questions:
Sure is that possible. Write a routine with an input parameter handle. This routine loops over all sessions, detects the main window and compares the handle of the main window with the parameter.
Sorry, I am not a Pyhton programmer and I have no snippet, but you can find an example in VBS here.
Best regards
Stefan
Hi Stefan,
Thanks for your response for my queries, i was able to use the example shared by you and was able to come up with below method to help me out, just sharing the python version if it helps anyone else -
Hello Raghavendran,
sorry but it is not clear for me what do you want to do. As far as I can see you loop over all connections and sessions to find a session I assume, but your function calls set_connection. What contains the parameter self? It seems to be a structure. Also you use the function verifyElementExists, what is it doing? Please explain more what your target is.
Best regards
Stefan
Hi Stefan,
Apologies for delayed response (was out on vacation), Let me try to explain n brief what I’m trying to achieve.
Scenario – Parallel SAP GUI automation executed by individual python test scripts
Problem – Parallel SAP control not feasible due to same GUI.exe being executed by different script at same time and finding unique SAP GUI to create session for it is another challenge that i faced
Solution – Start Python scripts to test SAP GUI in parallel -> Create a Login class (which has FileLock to a temporary file) which can only be access by one script at a time making Login a sequential process -> Once first script performs login release FileLock, so that second script can continue Login and so on.
Login Class Structure -
Login Class Process -
With your help i was able to achieve set_connection() method, again thank you for helping out ?
Please let me know if more information would be required to explain the target that i achieved.
Hello Raghavendran Ramasubramanian,
thanks for your reply, sounds all very good.
Best regards
Stefan
May I ask your help to check How to user Python to save the excel file ,since it stub a new windows to same save ,the tracker could not record it .thanks!
Banie Liang
Hello Banie,
I am not an expert in automation of applications with Python but maybe you can solve your problem with pywinauto.
Let us know your experience.
Best regards
Stefan
Hi Stefan
I have a question, SAP GUI display different lines to adapt different monitor , how can I know exact lines as I need the number as a variable,thanks.
Hello bin qiao,
welcome in the SAP Community.
Sorry but I don't understand your question. Which lines do you mean? Lines of a table? Please explain more in detail what do you want to detect.
Best regards
Stefan
Stefan, bin heute auf dein Tool aufmerksam geworden aber deine Seite ist momentan nicht erreichbar. Ist das nur ein temporaeres Problem? Wuerde den Scripting Tracker gern nutzen.
Hallo Martin,
vielen Dank für Deine Nachricht.
Die Seite ist erreichbar, sowohl die Hauptseite wie auch die Subdomain, habe es eben überprüft. Bitte einfach nochmal versuchen.
For all:
Martin Krupka wrotes about accessibility problems of my website. This appeared to be a temporary problem of the provider. All works well.
Best regards
Stefan
Hi Stefan,
Thanks for sharing this.
I’m currently learning SAP scripting and this is a great help but unfortunately, I can’t download the scripting tracker tool due to restrictions in my work laptop.
I’m creating a simple automation about material product hierarchy configuration but I don’t know how to get the value searched thru Position button to compare if it is equal to the input value since even if the value is not existing, it will still display the closest value on the first row.
So I wanted to add some validation after my code to check if the searched value is exactly equal to the input value.
Do you have any idea how to code this kind of validation?
Looking forward to your response. Thank you!
Hello Dan,
which transaction code do you use? How do you get to the dialog?
As far as I can see it is a GuiTableControl. After pressing ok in the "Another entry" dialog box, detect with CurrentRow the active row and use GetCell to read the content. Now you can compare if it is your entry or not and you can decide what to do.
Best regards
Stefan
Hi Stefan,
Thanks for your reply.
I'm using transaction code v/76
Tried using CurrentRow and the result is always 0 probably because it always points to the the first row? But I can't make the GetCell work, just used the Msgbox to see the return value.
Hi Stefan,
I am automating SAP using Java, It is a great tool.
I can track the elements using tracker but the recorder option is not visible. I can capture the session and find the elements. Any reasons for this.
I am using the latest version of tracker.
Sap Version :
Release 750 final release
Version 7500.2.4.1141
Build 1817102
Windows 10
Hello MOHAMED RIFAD
the visibility of the Recorder tab is depend on the availability of…
It seems that your installation do not meet one or more of these requirements. Please check your installation.
Best regards
Stefan
Thanks, Stefan,
After extracting the tracker few files went missing related to the recorder,That caused this issue.I have copied them back again.
Thanks for your reply MOHAMED RIFAD great to hear that everything works.
Dear Stefan,
I have loved your work regarding SAP Gui scripting and it has indeed helped me a lot in my work. Thank you!
Just recently I have been up against a strange issue. My script (please refer below) was working absolutely fine but now it has started throwing me an error : Object required:'ActiveWorkbook'-
I am not able to figure out why it so because it was working absolutely fine a day back.
If you could please help me here then that would be really great.
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
Dim objExcel
Dim objSheet, intRow, i
Set objExcel = GetObject(,"Excel.Application")
Set objSheet = objExcel.ActiveWorkbook.ActiveSheet
For i = 2 to objSheet.UsedRange.Rows.Count
COL1 = Trim(CStr(objSheet.Cells(i, 1).Value))
COL3 = Trim(CStr(objSheet.Cells(i, 3).Value))
session.findById("wnd[0]/tbar[0]/okcd").text = "/nsu01"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME").text = COL1
session.findById("wnd[0]/tbar[1]/btn[7]").press
session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpDBMS").select
session.findById("wnd[0]/tbar[1]/btn[19]").press
session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpDBMS/ssubMAINAREA:SAPLSUID_MAINTENANCE:1121/chkSUID_ST_NODE_DBMS_USER-IS_KERBEROS_ENABLED").setFocus
session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpDBMS/ssubMAINAREA:SAPLSUID_MAINTENANCE:1121/chkSUID_ST_NODE_DBMS_USER-IS_KERBEROS_ENABLED").selected = true
session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpDBMS/ssubMAINAREA:SAPLSUID_MAINTENANCE:1121/txtSUID_ST_NODE_DBMS_USER-EXTERNAL_IDENTITY").text = COL3
session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpDBMS/ssubMAINAREA:SAPLSUID_MAINTENANCE:1121/txtSUID_ST_NODE_DBMS_USER-EXTERNAL_IDENTITY").setFocus
session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpDBMS/ssubMAINAREA:SAPLSUID_MAINTENANCE:1121/txtSUID_ST_NODE_DBMS_USER-EXTERNAL_IDENTITY").caretPosition = 21
session.findById("wnd[0]/tbar[0]/btn[11]").press
next
msgbox "Process Completed"
Regards,
Akash Prabhu
Hello Akash,
thanks for your kindful words.
It seems that an invisible Excel instance runs on your system without an open workbook. Open your task manager and search for open Excel instances. Or use PowerShell:
GetObject takes this instance and ActiveWorkBook fails. This can happen, if an Excel instance opened with CreateObject, does not ended respectively closed correctly.
Best regards
Stefan
Dear Stefan,
Thank you so much for your quick and precise response.
We use citrix environment for our SAP and excel applications and hence, based on your guidance, I tried to run the script in QA citrix rather than Prod citrix and it ran successfully.
Hence as you have correctly mentioned it was due to unwanted Excel instance running in background, after resetting my citrix profile now I am able to run my scripts again!
Thank you very much and keep guiding !
Regards,
Akash Prabhu
Hi Stefan, thank you so much for such a great tool.
I have been using this for SAP ECC with no issues, but when I started using this with SAP S4/HANA, it is acting strange with the Analyser tracker, it doesn't track the correct field that you clicked, for example screen below, i was clicking the gross weight field, but the red frame is tracking Authorization group box, greatly appreciated if you can help me to see what's going wrong.
This is an amazing tool, thank you for sharing it with the world... I have a question...
Is it possible to get the tooltip value in a variable? Using VBScripting... I can get the text value of an element but I'm not sure if I can get the ToolTip Value the same way... I was looking at the Scripting API section and under AccToolTIp it has a method named "GetCurrentTollTipText () As BStr" but I don't know how to use it...
Thank you Stefan Schnell for this great tool. I have been using it since a a year or two and it made my life really easier !
Though since the last SAP update the tracker is loosing the connection with the client window after the connection page. I was wondering if you know about this behavior and if a patch would be an option if possible ?
Have a great day
Hello Julien Lamandé,
thanks for your hint, I will try that.
Best regards
Stefan
Hello Stefan,
this issue I am facing might be linked to an SAP privilege modification preventing me to use any kind of SAP recorder. For example embedded "Script Recording and Playback.." functionality is greyed out. I will investigate furthermore and let you know.
Have a good day
Julien
Dear, I download the Scripting Tracker (tried both X86 and X64), run it but capture nothing from the SAP gui,
I run Scripting Tracker using user mode, not admin mode,
and I'm have no admin right in SAP.
I attached the picture of the config,
what's the reason for this? thanks advanced.
the "script recorder and payback" cannot b
re:
pls ignore this question couse the script function is disabled by admin,