Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Pull a list of Functional Location from SAP using BAPI

I have to pull a list of Functional Location from SAP using BAPI. I have written below code however when I run this, it returns an empty table.

Dim sapFunc As New SAPFunctionsOCX.SAPFunctions

    Dim objServer = sapFunc.Connection

    objServer.Client = "101"

    objServer.User = "UserName"

    objServer.Ticket = "MyKey"

    objServer.system = "PEC"

    objServer.MessageServer = "MyMessagerServer"

    objServer.GroupName = "PUBLIC"

    If objServer.logon(0, True) <> True Then

        MsgBox("Rejected")

        Exit Sub

    End If

    Dim objRfcFunc As SAPFunctionsOCX.Function

    objRfcFunc = sapFunc.Add("BAPI_FUNCLOC_GETLIST")

    'System.Console.Write(objRfcFunc.Description)

    If objRfcFunc.Call = False Then

        MsgBox("Error- " & objRfcFunc.Exception)

        Exit Sub

    End If

    Dim tab = objRfcFunc.Tables("FUNCLOC_LIST")

    System.Console.WriteLine("Input start:")

    For I = 1 To tab.RowCount

        For j = 1 To tab.ColumnCount

            System.Console.Write(tab.ColumnName(j) + ":")

            System.Console.WriteLine(tab.Cell(I, j))

        Next

    Next

    System.Console.WriteLine("Input end.")


1 Answer
Anil SAP Gupta

After you set objRfcFunc, try this before you call this and this will include these parameters.

With objRfcFunc.tables("funcloc_ra")

    If .RowCount < 1 Then .Rows.Add

    .cell(1, 1) = "I"

    .cell(1, 2) = "EQ"

    .cell(1, 3) = "Your Func Loc"

End With

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.