Skip to Content
0

SAP dialog processing via VBA

Nov 22, 2016 at 08:13 AM

87

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers