on 08-01-2014 2:18 PM
Hello,
I would like to know how I can identify object that appears in SAP. Based on data entered I have different situations where tables popup. Currently as a work around I just write button clicks even if they dont appear, however it slows down whole process, so I was wondering if there is a way to identify if popup appears and only then apply the action.
For example in below situation, after focusingthe input to the field, I apply 2 other actions that are not necessarily needed. Is there a way to identify popped up objects?
for x = 0 To keycount_Enter
session.findById("wnd[0]").sendVKey 0 - FOCUS ACTION
session.findById("wnd[0]").sendVKey 0 ' not always needed
session.findById("wnd[0]/usr/btnBUT2").press ' does not always appear
BR,
Gedis
Edit. Table picture as below for example
Hi again,
after playing around I found neither issue works.
1. Object suggestion always returns true, so it basically runs buttons regardless if there is a popup or not. It does not detect if there are 5 popups after each other, does action and moves on to the next one. I could not find a way so it detects popup after each button press and presses again if needed.
2. subwindow category doesnt detect popups either. Like 1st option, it just does the action, regardless if there is a subwindow or not
BR,
Gedis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here you go. I removed .name, because otherwise window is not even detected. Problem is that it does 2 actions for each popup and exits for statement.
Second problem is that if I go to shipping tab to do adjustments for routes, I get same popup for BTN2, however that one is not even detected, even if ID is exactly the same (recorded in SAP). So either in shipping tab it does not recognize it as a subwindow or I do not know.
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUISERVER")
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
on error resume next
dim order(0)
dim ETA(0)
dim Route(0)
dim text(0)
dim Print(0)
dim ALE(0)
dim Contact(0)
order(0) = 120370732
ETA(0) = "05.09.2014"
text(0) = "PP: Sweden"
Route(0) = "SE0145"
Print(0) = "4"
ALE(0) = "3"
Contact(0) = "Uruguay OC;"
dim itemNo
itemNo = 0
dim itemInput
session.findById("wnd[0]").maximize
for i=0 to 0
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").text = order(i)
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 0
itemNo = 0
do
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-ETDAT[11," & ItemNo & "]").text = ETA(i)
itemNo = itemNo + 1
loop Until itemNo = 3 ' rows
session.findById("wnd[0]").sendVKey 0 ' focusing entered data and multiple popups start to appear
For Each subWindow In Session.Children ' runs 2 times each line and exits
If subWindow = "wnd[1]" Then session.findById("wnd[1]/tbar[0]/btn[0]").press '- ok press for popup1
If subWindow = "wnd[0]" Then session.findById("wnd[0]/usr/btnBUT2").press '- ok press for popup2
Next
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\06").select ' goes to another tab
itemNo = 0
do
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\06/ssubSUBSCREEN_BODY:SAPMV45A:4403/subSUBSCREEN_TC:SAPMV45A:4921/tblSAPMV45ATCTRL_UEIN_VERSAND/ctxtVBAP-ROUTE[10," & ItemNo & "]").text = Route(i)
itemNo = itemNo + 1
loop Until itemNo = 3 ' rows
session.findById("wnd[0]").sendVKey 0 ' focusing entered data and multiple popups start to appear
For Each subWindow In Session.Children 'Goes to If statement, but no action is done
If subWindow = "wnd[0]" Then session.findById("wnd[0]/usr/btnBUT2").press '- ok press for popup2 - DOES NOT DETECT
Next
Next
Hi both,
thanks for your input. Since I tried Thomas suggestion first and it worked so i stuck with it. Only thing i changed was if isObject(session.findbyId("wnd[1]/usr/btnBUT2",True)) Then , as not and false didint seem to work.
Though I found out that slow part was actually sending enter key, which could have been replaced by clicking specific button - session.findById("wnd[1]/tbar[0]/btn[0]"). If such button does not exist system goes for next statement. and I found its same time as if it checked IF statement. I guess this option works only with on error resume next statement, otherwise if statement lets to avoid error. That is very good thing to know!
thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello.
Another Option is to check Session childrens at specific Point of coding. If an popup appear required Action can initiated.
For Each subWindow In Session.Children
If subWindow.Name = "wnd[1]" Then Session.FindById("wnd[1]").sendVKey 0
Next
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gedis,
yes there is a way to find out ... 😉
if you put it up that way:
if not isObject(session.findbyId("wnd[1]/usr/btnBUT2",false)) Then
session.findbyid("wnd[1]/usr/btnBUT2").press
end if
Perhaps this
session.TestToolMode = 1
can help that way too
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.