Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Stefan-Schnell
Active Contributor
2,108
Many classes of the SAP GUI Scripting offers the method DumpState. DumpState delivers a hierarchy of collections with detailed information about the state of an object. Here an example how to make this information visible, with different scripting languages.

 

DumpState delivers the following OpCodes with the names and values of an object:

  • GPR = Get Property and Return value

  • MR = Method and Return value

  • GP = Get Property

  • M = Method


The parameter InnerObject may be used to secify for which internal object the data should be dumped. The most complex components supports this parameter. In the most cases it is an empty string.

 

The first source is in PowerShell. It shows from the transaction code SESSION_MANAGER the DumpState of the GuiCustomControl IMAGE_CONTAINER. The recursive function Dump loops over the collection and write all information to the console.
#-Begin--------------------------------------------------------------

#-Includes------------------------------------------------------------
."$PSScriptRoot\COM.ps1"

#-Sub Dump---------------------------------------------------------
Function Dump($Collection) {

ForEach($Item In $Collection) {
If ( $Item -IsNot [System.__ComObject] ) {
Write-Host $Item
} Else {
Dump $Item
}
}

}

#-Sub Main---------------------------------------------------------
Function Main() {

$SapGuiAuto = Get-Object( , "SAPGUI")
If ($SapGuiAuto -IsNot [System.__ComObject]) {
Return
}

$Application = Invoke-Method $SapGuiAuto "GetScriptingEngine"
If ($Application -IsNot [System.__ComObject]) {
Return
}

$Control = Invoke-Method $Application "findById" `
@("/app/con[0]/ses[0]/wnd[0]/usr/cntlIMAGE_CONTAINER")

#-With the method DumpState we get the collection----------------
$Collection = Invoke-Method $Control "DumpState" @("")

#-With the recursive function we get the information-------------
Dump $Collection

}

#-Main-------------------------------------------------------------
Main

#-End----------------------------------------------------------------

 

Here the result in the PowerShell ISE:



 

Now as second source the same example in VBScript:
'-Begin-----------------------------------------------------------------

'-Directives----------------------------------------------------------
Option Explicit

'-Variables-----------------------------------------------------------
Dim OutText

Sub Dump(collection) '------------------------------------------------

'-Variables---------------------------------------------------------
Dim i

For i = 0 To collection.Count() - 1
If IsObject(collection.ElementAt(CLng(i))) Then
Dump collection.ElementAt(CLng(i))
Else
OutText = OutText & collection.ElementAt(CLng(i)) & vbCrLf
End If
Next

End Sub

Sub Main() '----------------------------------------------------------

'-Variables---------------------------------------------------------
Dim SapGuiAuto, application, control, collection

If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If

Set control = application.findById("/app/con[0]/ses[0]/wnd[0]" & _
"/usr/cntlIMAGE_CONTAINER")

Set collection = control.DumpState("")

Dump collection

MsgBox OutText

End Sub

'-Main----------------------------------------------------------------
Main

'-End-------------------------------------------------------------------

 

Here the result:



 

Or you can use Scripting Tracker, that is of course much more comfortable.



 

Also you can use the VBA debugger, but this is, if you don't work with the VBA-IDE, not an efficient alternative.
Labels in this area