Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
Mariatha pe Simpatie.ro
Femeie
25 ani
Prahova
cauta Barbat
25 - 52 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [SAP] Check with VBS which Transaction You Are In Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 739
I have 2 different SAP servers with different names.

I use the following line of code in VBS to extract the system name:

Session.Info.SystemName

That displays something like AAA (1) 300, or BBB (1) 500 for the second system.

Actually I need only the first 3 letters from the left to compare, so I used:

If Left(Session.Info.SystemName, 3) = "AAA" Then
'DO SOMETHING
Else
'DO SOMETHING ELSE
End If


Other options from SAP from down there, besides System.Info.SystemName, are:

System.Info.SessionNumber
System.Info.SystemNumber
System.Info.SystemSessionID
System.Info.Client
System.Info.Transaction
System.Info.Program


You can also use SAP.Children(0).Children(0).Info..... instead of System.Info.


pus acum 7 luni
   
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 739
Under Excel, you would have to rename "Session" to "SAP_Session" or something different than just "Session".

Something like:


Sub NAME_OF_SUB()

Application.ScreenUpdating = False

If Not IsObject(SAP_Application) Then
        On Error Resume Next
    Set SapGuiAuto = GetObject("SAPGUI")
    If SapGuiAuto Is Nothing Then
        MsgBox "Deschide mai intai SAP"
        Exit Sub
    End If
       
        On Error Resume Next
    Set SAP_Application = SapGuiAuto.GetScriptingEngine
    If SAP_Application Is Nothing Then
        MsgBox "Deschide mai intai SAP"
        Exit Sub
    End If
    On Error GoTo 0
End If

If Not IsObject(oConnection) Then
        On Error Resume Next
    Set oConnection = SAP_Application.Children(0)
    If oConnection Is Nothing Then
        MsgBox "Deschide mai intai SAP"
        Exit Sub
    End If
End If

If Not IsObject(SAP_Session) Then
    Set SAP_Session = oConnection.Children(0)
End If

If IsObject(WScript) Then
    WScript.ConnectObject SAP_Session, "on"
    WScript.ConnectObject SAP_Application, "on"
End If

If SAP_Session.Info.Transaction = "TRANSACTION_NAME" Then
    MsgBox "You already opened " & SAP_Session.Info.Transaction & ", this subroutine is now closing."
    Exit Sub
End If

' DO SOMETHING

Application.ScreenUpdating = True

End Sub


pus acum 7 luni
   
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 739
Updated also with .Program

pus acum 2 luni
   
Pagini: 1  

Mergi la