Skip to Content
avatar image
Former Member

How can I log on SAP 730 and download fbl3n data in excel vba

Hi experts!

I currently trying to create a macro that should log on on SAP 730 and connect to fbl3n t-cod and download data in excel... I m searching for 3 days but nothing can be found on internet related this topic.

Could you please be help me? I really appreciate if anyone already use this kind of macro to give me some idea .

Below I wrote my code, but it seems to be blocked , dosen t works!

Sub sap()
    Dim oBook As Workbook
    Dim oSheet As Worksheet
    Dim oBapiCtrl As Object
    Dim oBapiLogon As Object
    Dim oDocumentNo As Object
    Dim oPK As Object
    Dim oReferenceKey1 As Object
    Dim oCoCod As Object
    Dim iIndex As Integer
    Set oBook = Application.ActiveWorkbook
    Set oSheet = oBook.Worksheets(1)
    Set oBapiCtrl = CreateObject("sap.bapi.1")
    Set oBapiLogon = CreateObject("sap.logoncontrol.1")
    oBapiCtrl.Connection = oBapiLogon.NewConnection
    oBapiCtrl.Connection.ApplicationServer = "000.000.000"
    oBapiCtrl.Connection.System = "test"
    oBapiCtrl.Connection.client = "000"
    oBapiCtrl.Connection.User = ""
    oBapiCtrl.Connection.Password = ""
    oBapiCtrl.Connection.Language = ""
    oBapiCtrl.Connection.SystemNumber = ""
   If oBapiCtrl.Connection.logon(0, True) <> True Then
    MsgBox "not connected", vbInformation, "SAP Logon"
    Exit Sub
    MsgBox "Connected!"
   End If
   If oBapiCtrl.Connection.IsConnected Then
  Set SapGuiAuto = GetObject("SAPGUI")  'Get the SAP GUI Scripting object
  Set SAPApp = SapGuiAuto.GetScriptingEngine 'Get the currently running SAP GUI
  Set SAPCon = SAPApp.Children(0) 'Get the first system that is currently connected
  Set session = SAPCon.Children(0) 'Get the first session (window) on that connection

'there should be the code for smooth login SAP and open FBL3N and extract data

End Sub

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Feb 08, 2017 at 09:41 PM

    You better read from the underlying SAP table and RFC result programmatically, instead of reading from t-code result. Even you manage to make it work, the program's result may not be as structured (to parse easily) as you expect.

    Add comment
    10|10000 characters needed characters exceeded