'-Begin-----------------------------------------------------------------
'-Directives------------------------------------------------------------
Option Explicit
'-Sub Action------------------------------------------------------------
'-
'- Starts external script with the connection and session number
'- as parameters
'-
'-----------------------------------------------------------------------
Sub Action(con, ses, TAC)
Dim objShell, RegEx, Matches, con_no, ses_no
'-Extracts connection and session number------------------------------
Set RegEx = New RegExp
RegEx.Pattern = "[\d]+"
Set Matches = RegEx.Execute(con)
con_no = Matches(0).Value
Set Matches = RegEx.Execute(ses)
ses_no = Matches(0).Value
'-Executes the external script----------------------------------------
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run "YourScript." + TAC + ".vbs " + con_no + " " + ses_no
End Sub
'-Function GetSession---------------------------------------------------
'-
'- Detects a session by transaction code (TAC)
'-
'-----------------------------------------------------------------------
Function GetSession(connection, TAC)
Dim sessions, session, sessionInfo, j, i
Set sessions = connection.Sessions()
'-Loop over sessions--------------------------------------------------
For Each session In sessions
If session.Busy() = vbFalse Then
Set sessionInfo = session.Info()
If sessionInfo.Transaction() = TAC Then
Set GetSession = session
End If
End If
Next
End Function
'-Sub Main--------------------------------------------------------------
Sub Main()
Dim SapGuiAuto, app, connection, session
Dim session_SE16, session_SE37
Dim arr
Set SapGuiAuto = GetObject("SAPGUI")
If Not IsObject(SapGuiAuto) Then
Exit Sub
End If
Set app = SapGuiAuto.GetScriptingEngine
If Not IsObject(app) Then
Exit Sub
End If
Set connection = app.Children(0)
If Not IsObject(connection) Then
Exit Sub
End If
If connection.DisabledByServer = True Then
Exit Sub
End If
Set session = connection.Children(0)
If Not IsObject(session) Then
Exit Sub
End If
If session.Info.IsLowSpeedConnection = True Then
Exit Sub
End If
'-Open different sessions with different TACs-------------------------
session.findById("wnd[0]/tbar[0]/okcd").text = "/oSE16"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/okcd").text = "/oSE37"
session.findById("wnd[0]").sendVKey 0
WScript.Sleep 500
'-Detects the session with TAC SE16 and calls an external script------
Set session_SE16 = GetSession(connection, "SE16")
arr = Split(session_SE16.ID, "/")
Action arr(2), arr(3), "SE16"
'-Detects the session with TAC SE37 and calls an external script------
Set session_SE37 = GetSession(connection, "SE37")
arr = Split(session_SE37.ID, "/")
Action arr(2), arr(3), "SE37"
End Sub
'-Main------------------------------------------------------------------
Main()
'-End-------------------------------------------------------------------
'-Begin------------------------------------------------------------------
Set Args = WScript.Arguments
con = Args(0)
ses = Args(1)
Set SapGuiAuto = GetObject("SAPGUI")
If Not IsObject(SapGuiAuto) Then
WScript.Quit
End If
Set app = SapGuiAuto.GetScriptingEngine
If Not IsObject(app) Then
WScript.Quit
End If
Set connection = app.Children(CLng(con))
If Not IsObject(connection) Then
WScript.Quit
End If
Set session = connection.Children(CLng(ses))
If Not IsObject(session) Then
WScript.Quit
End If
For i = 1 To 50
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = "TADIR"
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").caretPosition = 5
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 31
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
Next
'-End--------------------------------------------------------------------
'-Begin------------------------------------------------------------------
Set Args = WScript.Arguments
con = Args(0)
ses = Args(1)
Set SapGuiAuto = GetObject("SAPGUI")
If Not IsObject(SapGuiAuto) Then
WScript.Quit
End If
Set app = SapGuiAuto.GetScriptingEngine
If Not IsObject(app) Then
WScript.Quit
End If
Set connection = app.Children(CLng(con))
If Not IsObject(connection) Then
WScript.Quit
End If
Set session = connection.Children(CLng(ses))
If Not IsObject(session) Then
WScript.Quit
End If
For i = 1 To 25
session.findById("wnd[0]/usr/ctxtRS38L-NAME").text = "RFC_READ_TABLE"
session.findById("wnd[0]/usr/ctxtRS38L-NAME").caretPosition = 14
session.findById("wnd[0]/usr/btnBUT3").press
session.findById("wnd[0]/usr/tabsFUNC_TAB_STRIP/tabpHEADER").select
session.findById("wnd[0]/usr/tabsFUNC_TAB_STRIP/tabpIMPORT").select
session.findById("wnd[0]/usr/tabsFUNC_TAB_STRIP/tabpEXPORT").select
session.findById("wnd[0]/usr/tabsFUNC_TAB_STRIP/tabpCHANGE").select
session.findById("wnd[0]/usr/tabsFUNC_TAB_STRIP/tabpTABLES").select
session.findById("wnd[0]/usr/tabsFUNC_TAB_STRIP/tabpEXCEPT").select
session.findById("wnd[0]/tbar[0]/btn[3]").press
Next
'-End--------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
12 | |
5 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |