on 05-11-2018 10:23 AM
Hi Experts,
I have been trying to automate one of the screen using the script. The problem I am facing is the id is getting changed Frequently. Please see the below example for reference.
Line = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-EBELP[1," & Row &"]").text
The bold part of the upper code is getting changed frequently. sometime it is 10 and sometime it is 16,19,15.
Can you please suggest any way to make it dynamic?
Hello Vivek,
you can loop over your elements in the user screen (usr) to detect the name.
Set UserArea = session.findById("wnd[0]/usr")
For i = 0 To UserArea.Children.Count - 1
If Instr(UserArea.Children(CInt(i)).Name, "SAPLMEGUI:") Then
SubName = UserArea.Children(CInt(i)).Name
End If
Next
Set SubArea = session.findById("wnd[0]/usr/sub" & SubName)
MsgBox SubArea.Name
We set the variable UserArea and loop over all elements. If one elements name contains SAPLMEGUI: we get it. On this way you can detect which screen do you use, 10 or 15 or 16 or 19. The variable SubName contains SUB0:SAPLMEGUI:0010 and you can now use this variable in your IDs.
Let us know your results.
Cheers
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay, I think I have figured this out. It's not as elegant as Stefan's code but it works:
User = session.findById("wnd[0]/usr")
count = User.Children.Count - 1
user3 = User.Children(int(count)).Name
print(user3)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I tried to use that method to solve a similar problem in my SAP scripting + vba code.
but i don't know how to concatenate "subarea" with my script.
could someone help me?
Set UserArea = session.findById("wnd[0]/usr")
For i = 0 To UserArea.Children.Count - 1
If InStr(UserArea.Children(CInt(i)).Name, "SAPLMEGUI:") Then
SubName = UserArea.Children(CInt(i)).Name
End If
Next
Set SubArea = session.findById("wnd[0]/usr/sub" & SubName)
SubArea/subSUB2:SAPLMEVIEWS:1100/subSUB2:S...
Hi All,
would be anybody so kind to support in translating this code in python?
Thank you in advance!
Best wishes,
Karl
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stefan,
Thank you so much the solution worked.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.