Hi All,
I am not sure if i am at the right platform to ask this question.
1) I will like to know if there is any place that i can read up on the respective property or function of the syntax.
For example, session.findById("wnd[0]").maximize, I extracted this from the output of the Script recording, I will like to know, what other function is there, or findById is the only function?
2) I will also like to check, if it is possible for me to use VBA to loop through all the element in the SAPGUI and return a value.
For example,
Dim X as object
For each X in Session.
If X.Text = "New Entries" then
....
End If
....
My objective is to find if whether the element exist on the screen or it is still loading.
Regards
David
Request clarification before answering.
This a chunk, not directly GUI related, but during the logon process to retrieve the list of systems in the logon pad.
It has some for each looping.
Function SAPUILandscape(system)
Dim fpath As String
Dim sapfiles As String
Dim SAPUILandscapefile As String
Dim ConnString As String
Dim id As Variant
Dim isValid As Boolean
Dim testing As Boolean
Dim AttribName As String
Dim AttribServer As String
Dim CurrentXpath As String
Dim xmlDoc As MSXML2.DOMDocument60
Dim xmlSelection As MSXML2.IXMLDOMSelection
Dim xmlAttributes As MSXML2.IXMLDOMNamedNodeMap
Dim xmlItems As MSXML2.IXMLDOMAttribute
Set xmlDoc = New MSXML2.DOMDocument60
testing = False
'xml structures
AttribName = "name"
AttribServer = "server"
'alt AttribTag = "systemid"
CurrentXpath = "//Landscape/Services/Service[@" & AttribName & "='" & system & "']"
'find SAPUILandscape.xml
fpath = Environ$("AppData")
sapfiles = "SAP\Common\"
SAPUILandscapefile = "SAPUILandscape.xml"
If Right(fpath, 1) <> "\" Then
fpath = fpath & "\"
End If
fpath = fpath & sapfiles & SAPUILandscapefile
xmlDoc.async = False
If xmlDoc.Load(fpath) Then
'successfully loaded xml
Set xmlSelection = xmlDoc.SelectNodes(CurrentXpath)
If xmlSelection.Length = 0 Then
'path not found
isValid = False
Else:
Set xmlAttributes = xmlSelection.Item(0).Attributes
For Each xmlItems In xmlAttributes
If xmlItems.BaseName = AttribServer Then
ConnString = xmlItems.NodeValue
isValid = True
Exit For
End If
Next xmlItems
End If
Else:
If testing = True Then
' The document failed to load.
Dim strErrText As String
Dim xPE As IXMLDOMParseError
' Obtain the ParseError object
Set xPE = xmlDoc.parseError
With xPE
strErrText = "Your XML Document failed to load" & _
"due the following error." & vbCrLf & _
"Error #: " & .ErrorCode & ": " & xPE.reason & _
"Line #: " & .Line & vbCrLf & _
"Line Position: " & .linepos & vbCrLf & _
"Position In File: " & .filepos & vbCrLf & _
"Source Text: " & .srcText & vbCrLf & _
"Document URL: " & .Url
End With
MsgBox strErrText, vbExclamation
isValid = False
Else:
isValid = False
End If
End If
If isValid = True Then
'connection found in landscape
SAPUILandscape = formatConnString(ConnString)
Else:
'connection not found in landscape
SAPUILandscape = ""
End If
End Function
for the SAP gui, I dont have a sample quickly to hand sorry, but you can declare the variables as the specific types, then you can loop for each child object,
Dim tobj As SAPFEWSELib.GuiTableControl
Dim tObjChild As SAPFEWSELib.GuiComponentCollection
then for each loop
For Each tObjChild In tObj
'logic here
Next tObjChild
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I managed to find the SAP GUI Scripting help file and sapfewse.ocx.
but I really keen to learn how to loop through the element/object in SAP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
https://answers.sap.com/questions/13039407/how-to-upload-sap-table-from-excel-64x-with-vba.html
Stefan has a nicely clean example here.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.