Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3510

Re: Sap Standard Screen Selection

$
0
0

Thanks, i have used your code to develop a work around,

 

Problem:

VBA will crash the SapGui when interacting with certain items contained in a Tab Strip Sub Screen,

 

Solution:

VBS scripts do not cause this behavior use VBA to Write VBS Script file and launch the file using the ShellandWait function CPearson Shell And Wait

 

 

Section in VBA Code

  1. Q = 0
  2.    
  3.     For i = 0 To session.findById("wnd[0]/usr").Children.Count() - 1
  4. ReFindTabs:
  5.       Set Tabs = session.findById("wnd[0]/usr").Children.Item(CLng(i))
  6.       If Tabs.Type() = "GuiTabStrip" Then
  7.         For J = Q To Tabs.Children.Count() - 1
  8.           Tabs.Children.Item(CLng(J)).Select
  9.         EmptyTextFields session
  10.         Call ShellAndWait("cscript ""C:\Test\TabStrip.VBS""", 0, vbHide, PromptUser)
  11.         Q = Q + 1
  12.         GoTo ReFindTabs
  13.         Next
  14.       End If
  15.     Next

 

 

VBS Code File (Thanks to Stefan Schnell for the content)

 

  1. If Not IsObject(application) Then
  2.    Set SapGuiAuto  = GetObject("SAPGUI")
  3.    Set application = SapGuiAuto.GetScriptingEngine
  4. End If
  5. If Not IsObject(connection) Then
  6. Set connection = application.Children(SapApp.Children.Count - 1)
  7. End If
  8. If Not IsObject(session) Then
  9.    Set session    = application..Children(SapApp.Children.Count - 1).sessions(SapApp.Children(SapApp.Children.Count - 1).sessions.Count - 1)
  10. End If
  11. If IsObject(WScript) Then
  12.    WScript.ConnectObject session,     "on"
  13.    WScript.ConnectObject application, "on"
  14. End If
  15.         Dim cntObj, i, Child
  16.       On Error Resume Next  
  17.       cntObj = obj.Children.Count()  
  18.       If cntObj > 0 Then  
  19.         For i = 0 To cntObj - 1  
  20.           Set Child = obj.Children.Item(CLng(i))  
  21.           EmptyPushEntries Child  
  22.           If InStr(Child.ID(), "/usr/") Then  
  23.             If InStr(Child.ID(), "-VALU_PUSH") Then  
  24.               If Child.IconName() = "BGMORE" Then 
  25.                 Child.Press() 
  26.                 session.findById("wnd[1]").sendVKey 16 
  27.                 session.findById("wnd[1]").sendVKey 8 
  28.               End If 
  29.             End If  
  30.           End If  
  31.         Next  
  32.       End If  
  33.       On Error Goto 0  
  34.      End Sub  

Viewing all articles
Browse latest Browse all 3510

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>