on 02-27-2012 1:45 PM
Hello,
I'm using a Sapscript to edit some things in the VA02 transaction in SAP on sales order item level. The script goes through the item lines and finds data to change.
The problem is that the amount of "tabs" in the transaction differs from item to item, so when trying to navigate back to tab 6 in my For/Next code, which in my case is named "Conditions" in VA02, it is placed as tab 5.
So what I want to do here is to get the script to search for a tab named "Conditions" instead of predetermined "6".
This is the current solution, 06 at the end is the position of Conditions at first but later on in the sales orders it sometimes moves to 05 etc.
'---> 'Enter SO item "Conditions" tab
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06").Select
Anyone got a clue on how to fix this?
Thanks,
Mattias
Hi Thomas,
Thanks for your reply! I got some questions:
What is "tabt"? It looks as it is not defined and I'm getting an error referring to it.
The Trim function does not work, it wants a "Then" even though there is one at the end of that line. Is it necessary?
In my For/Next formula, I'm only using tab Conditions and Status which initially is positioned as 06 and 12, should these be specified as
tabid(0) = "06"
tabid(1) = "12"
or
tabid(0) = "Conditions"
tabid(1) = "Status"
If those two are still referring to the positions, it will still not work as they move sometimes...
Thanks,
Mattias
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is "tabt"? It looks as it is not defined and I'm getting an error referring to it.
Oh sorry that was my fault ,...
it should be tabid()
here the correct code:
Public Function FindTabBytext(Byval stext as String) as String
Dim tabid(0 to x) as String) 'max amount of Tabs
tabid(0) = "06"
'....
'for every Tab you could have
On error resume next
For i = 0 to uBound(tabid())-1
If Trim (session.Findbyid(session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\"& Cstr(tabid(i)) &"").text) = stext Then
FindTabByText = tabid(i)
exit for
end if
next
End Function
you can get the id's of evrey Tab with the Coding Wizard or you can Record a Test Macro with the Macro-Recorder in SAP where you click every Tab in that TA...
Greetings
Thomas B
Hello again,
Perfect, it works for my first scenario now which is the ".Select" tab case only, as in your first example above.
I tried putting the same into this other "execute something" scenario, a check on a field inside the tab, the problem here is that it does not understand the commas in the section after "06".
This works but will not work in the long run:
If session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06/ssubSUBSCREEN_BODY:SAPLV69A:6201/tblSAPLV69ATCTRL_KONDITIONEN/ctxtKOMV-KSCHL[1,0]").Text = "PR00" Then
Therefore I tried simply putting this code as in your example instead of 06:
If session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\" & FindTabBytext("Conditions") & "")/ssubSUBSCREEN_BODY:SAPLV69A:6201/tblSAPLV69ATCTRL_KONDITIONEN/ctxtKOMV-KSCHL[1,0]").Text = "PR00" Then
But then VBA expects a Then or GoTo just after the ssubSUBSCREEN_BODY there (it doesn't want the comma).
Is there some way to get it to understand this?
Thanks,
Mattias
Hi Mattias and Thomas,
Sorry that I am interfering. I just wanted to support Thomas in his efforts.
If session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\" & FindTabBytext("Conditions") & "/ssubSUBSCREEN_BODY:SAPLV69A:6201/tblSAPLV69ATCTRL_KONDITIONEN/ctxtKOMV-KSCHL[1,0]").Text = "PR00" Then
Regards,
ScriptMan
Hi Matthias...
had the same Problem
found the solution in a Function which is given the "Caption" of the Tab and returns the "Index"
First of all you need to have all Tabs ("06") ... and so on an their captions
Public Function FindTabBytext(Byval stext as String) as String
Dim tabid(0 to x) as String) 'max amount of Tabs
tabid(0) = "06"
'....
'for every Tab you could have
On error resume next
For i = 0 to uBound(tabt())-1
if Trim session.Findbyid(session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\"& Cstr(tabid(i)) &"").text = tabt(0) Then
FindTabByText = tabid(i)
exit for
end if
next
End Function
Calling it in your code would look like this:
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\" & findTabByText("Conditions") &"" ).Select
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.