cancel
Showing results for 
Search instead for 
Did you mean: 

SAP dialog processing via VBA

Former Member
0 Kudos

Dear community,

I've a VBA code to SAP logon.

But I would like to process some SAP dialog window via VBA if it's possible.

Sub Logon()
 
Dim SapGuiApp As Object
Dim oConnection As Object
Dim session As Object
     
    Set SapGuiApp = GetObject("SAPGUI")
    Set oConnection = SapGuiApp.GetScriptingEngine
If oConnection.Children.Count > 0 Then
    'MsgBox ("Connection already exist")
        GoTo UseActual:
    Else
     
    Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
    Set oConnection = SapGuiApp.OpenConnection("SERVER", True)
    Set session = oConnection.Children(0)
        GoTo Logon:
 
UseActual:
        Set session = Nothing
        Set SAPCon = oConnection.Children(0)
        Set session = SAPCon.Children(0)
             
            GoTo StartTr:
Logon:
    Application.DisplayAlerts = False
     
    session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "100"
    session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "USERNAME"
    session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "PASS"
    session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"
    session.findById("wnd[0]").sendVKey 0
 
 
            GoTo StartTr:
StartTr:
        session.StartTransaction "****"
         
        '................
         
                 
    Application.DisplayAlerts = True
             
        Set session = Nothing
        Set oConnection = Nothing 'SAPCon
        Set SapGuiApp = Nothing
 
End Sub

Couldn't you help me.

In addition: I would like to process SaveAs dialog via VBA to.

Thanks in advance.

Accepted Solutions (0)

Answers (0)