Skip to Content
0
Former Member
Dec 18, 2012 at 10:17 AM

Check if SAP-Login successful

91 Views

Hey there!

i want to check if my login to SAP was successful. I use this script:

Public Sub partSAP()

i = 0

Range("B:B").Clear

Protokoll "Starte..."

On Error GoTo Err

'Variablen

Dim SapGuiApp As Object

Dim oConnection As Object

Dim Session As Object

Dim SAPguiAuto As Object

If SapGuiApp Is Nothing Then Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")

If oConnection Is Nothing Then Set oConnection = SapGuiApp.OpenConnection(sapSystem, True)

If Session Is Nothing Then Set Session = oConnection.Children(0)

'wenn SAP schon steht

' Set SAPguiAuto = GetObject("SAPGUI")

' If SapGuiApp Is Nothing Then Set SapGuiApp = SAPguiAuto.GetScriptingEngine

' Set oConnection = SapGuiApp.Children(0)

' If SAPSession Is Nothing Then Set SAPSession = oConnection.Children(0)

'Fenstergröße anpassen

Session.findById("wnd[0]").Restore

Session.findById("wnd[0]").ResizeWorkingPane 111, 18, False

'SAP-Login

Session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "330"

Session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = SAPForm.BoxUser.Text

Session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = SAPForm.BoxPass.Text

Session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "DE"

Session.findById("wnd[0]").sendVKey 0

'Systemnachricht wegklicken

On Error Resume Next

Session.findById("wnd[1]/tbar[0]/btn[0]").press

Session.findById("wnd[1]/tbar[0]/btn[0]").press

Session.findById("wnd[1]/tbar[0]/btn[0]").press

On Error GoTo Err

'Transaktion ausführen

Session.findById("wnd[0]/tbar[0]/okcd").Text = "/n/SIE/AD_ZPP_PRIO"

Session.findById("wnd[0]").sendVKey 0

'Daten eingeben

ErrLogin = True

Session.findById("wnd[0]/usr/ctxtS_FEVOR-LOW").Text = ""

ErrLogin = False

Session.findById("wnd[0]/usr/ctxtS_DISPO-LOW").Text = "L03"

Session.findById("wnd[0]/usr/txtS_WERKS-LOW").Text = "1"

Session.findById("wnd[0]").sendVKey 8

.

.

.

How can i check if the login was succsessful or not?