Manivel Posted March 8, 2017 Share Posted March 8, 2017 Hi, We are trying to automate the SAP applications. For automating that we are using sap.au3 wrapper file. Facing some issues with the dynamic control values example: Please consider the highlighted values. ("usr/subSUB0:SAPLMEGUI:0015/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT3") ("usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT13") While in execution we are getting either 15 or 19 and some times 13 also. How to handle this in autoit. What i though was through autoit regular expression we can ? but didn't get the proper guidelines and time to implement. If you have any idea how to handle this issue, please let me know. Thanks Manivel P Link to comment Share on other sites More sharing options...
jguinch Posted March 8, 2017 Share Posted March 8, 2017 You want to extract the value ? Local $sString = '("usr/subSUB0:SAPLMEGUI:0015/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT3")' Local $aval = StringRegExp($sString, "SAPLMEGUI:00(\d+)", 1) MsgBox(0, "", $aval[0]) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Manivel Posted March 9, 2017 Author Share Posted March 9, 2017 (edited) Actually its SAP Control property value. property values changed based on the selections. That value is belong to one of the menu option. for example - in outlook we have home, Send/Receive, Folder, View extra right. Same thing. if the particular menu selected by default - then the property id is usr/subSUB0:SAPLMEGUI:0015............................ if some other tab is selected or expanded, then we need to select the expected menu means - the property id is usr/subSUB0:SAPLMEGUI:0019... Not sure about the default selection. Its based on the users. so we need to handle this id's in regular expression. Thank you Edited March 9, 2017 by Manivel Link to comment Share on other sites More sharing options...
iamtheky Posted March 12, 2017 Share Posted March 12, 2017 you don't need regular expressions provided the data is always in the same model $sString = '("usr/subSUB0:SAPLMEGUI:0015/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT3")' msgbox(0, '' , number(stringsplit(stringsplit($sString , "/" ,2)[1] , ":" , 2)[2])) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
mikell Posted March 12, 2017 Share Posted March 12, 2017 $sString = '("usr/subSUB0:SAPLMEGUI:0015/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT3")' msgbox(0, '' , number(StringMid($sString, StringInStr($sString, "SAPLMEGUI")+10, 4)) ) iamtheky 1 Link to comment Share on other sites More sharing options...
iamtheky Posted March 12, 2017 Share Posted March 12, 2017 nice, I like bringing you to the darkside mikell 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
mikell Posted March 13, 2017 Share Posted March 13, 2017 Yes. but don't go wrong. Still with me the Rx force is Link to comment Share on other sites More sharing options...
Manivel Posted March 13, 2017 Author Share Posted March 13, 2017 9 hours ago, iamtheky said: you don't need regular expressions provided the data is always in the same model $sString = '("usr/subSUB0:SAPLMEGUI:0015/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT3")' msgbox(0, '' , number(stringsplit(stringsplit($sString , "/" ,2)[1] , ":" , 2)[2])) my concern is the values what you are showing in msg box is dynamic value. it may be 15 or 13 or 19 or any value. Its a control [button]. I need to click that button. The property value might be 15 or any value. Through sub string we can get the value. How to replace that value. Because the expected value is dynamic. thats why i thought of asking about regular expression. Link to comment Share on other sites More sharing options...
iamtheky Posted March 13, 2017 Share Posted March 13, 2017 It totally doesn't matter what the value is, all the solutions provided would facilitate identifying the target. And replacing it is trivial with any of the solutions, but hopefully this is the part where everyone encourages you to try and work through the provided answers and post code when you have issues, rather than us just handing you functional code. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Manivel Posted March 13, 2017 Author Share Posted March 13, 2017 Thanks for update. Will try to handle this. Link to comment Share on other sites More sharing options...
Khrauser Posted July 31, 2018 Share Posted July 31, 2018 Hello. Was there a solution for this? I'm having the exact same problem and I can't find anything to identify which ID it's the correct one at the moment. Autoit it's crashing if the ID doesn't exist and can't continue with the rest of the script. Link to comment Share on other sites More sharing options...
Developers Jos Posted July 31, 2018 Developers Share Posted July 31, 2018 Show us an example of the script that demonstrates your issue please, else it's hard to know what is going wrong. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Khrauser Posted July 31, 2018 Share Posted July 31, 2018 Sure, This is one of my issues, I need to select "Delivery/Invoice" everytime I access to SAP: One ID for Delivery/Invoice is: "wnd[0]/usr/subSUB0:SAPLMEGUI:0018/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT1", however can change to 10 or 13 as well, but I have no way to identify which one is active everytime I log in. I can use keystrokes but that will be my very last option. I did try several options, not only IsObj with no luck. I did read so many threads from here as well but nothing that can help me as well. If AutoIt can only keep going instead of crashing if the ID is not there, that will be awesome since it will just continue unitl it finds the one that exists. The code I'm using so far is: expandcollapse popupLocal $oSapGuiAuto, $Application, $Connection, $Session Local $Info $oSapGuiAuto = ObjGet("SAPGUI") If Not IsObj($oSapGuiAuto) Or @error Then Exit EndIf $Application = $oSapGuiAuto.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 ; Accessing ME23N Transaction $Session.findById("wnd[0]/tbar[0]/okcd").text = "me23n" $Session.findById("wnd[0]").sendVKey(0) Opt("WinTitleMatchMode", 2) WinWaitActive("Standard PO", "") ; Selecting the proper tab $SAPSupplier10 = "wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT1" $SAPSupplier13 = "wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT1" $SAPSupplier18 = "wnd[0]/usr/subSUB0:SAPLMEGUI:0018/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT1" If IsObj($SAPSupplier10) Then $Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT1").select EndIf If IsObj($SAPSupplier13) Then $Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT1").select EndIf If IsObj($SAPSupplier18) Then $Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0018/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT1").select EndIf This is the error I'm getting if the ID does not exist: "C:\Autoit\Test.au3" (73) : ==> The requested action with this object has failed.: $Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0017/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT1").select $Session^ ERROR ->14:49:02 AutoIt3.exe ended.rc:1 +>14:49:02 AutoIt3Wrapper Finished. Thanks!! Link to comment Share on other sites More sharing options...
jitb Posted July 31, 2018 Share Posted July 31, 2018 in vba Sub test10() If Not IsObject(App) Then Set SapGuiAuto = GetObject("SAPGUI") Set App = SapGuiAuto.GetScriptingEngine End If If Not IsObject(Connection) Then Set Connection = App.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]").resizeWorkingPane 102, 31, False Set Dummy01 = session.findById("wnd[0]/usr/").Children Dummy02 = Dummy01.Item(1).ID End Sub Link to comment Share on other sites More sharing options...
Khrauser Posted August 2, 2018 Share Posted August 2, 2018 Thanks for the reply!!, I'm not really that pro to understand the last part of the code without some additional information however I did find another way to "identify" which ID is the correct and continue, basically I did create 1 VBS script file per ID and I did run them with RunWait like this: RunWait('cscript.exe "' & @ScriptDir & '\Scripts\DeliveryInvoiceTab 10.vbs"', "", @SW_HIDE) RunWait('cscript.exe "' & @ScriptDir & '\Scripts\DeliveryInvoiceTab 13.vbs"', "", @SW_HIDE) RunWait('cscript.exe "' & @ScriptDir & '\Scripts\DeliveryInvoiceTab 18.vbs"', "", @SW_HIDE) This works like a charm if I just need to select something however I'm not able to extract data from a SAP field to an AutoIt Variable through VBS. Should I need to open a new thread regarding this issue? Thanks again. Link to comment Share on other sites More sharing options...
jitb Posted August 3, 2018 Share Posted August 3, 2018 (edited) Sorry was in a hurry Dummy02 = "/app/con[0]/ses[0]/wnd[0]/usr/subSUB0:SAPLMEGUI:0015" Should be easy to convert to Autoit, if not will work on it Monday (if you have excel paste in into a VB modal and step thru (f8) viewing the Locals Window) Let me know if you don't understand and I will elucidate on Monday. I think you will only add 1 line. How many sessions do you have open at a time? Do you want the fish or to know how to get it? Edited August 3, 2018 by jitb Make it a little clearer, I hope :-) Link to comment Share on other sites More sharing options...
jitb Posted August 12, 2018 Share Posted August 12, 2018 On 8/2/2018 at 5:16 PM, jitb said: Do you want the fish or to know how to get it? Well it seems neither how sad :-( 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