Skip to Content

Using SAP .Net Connector to Call RFC

I have used the SAP .Net Connector on multiple projects in the past.  I will say that I am very impressed with it’s robust ability to handle large volumes of data.  I will insert a small video demo of how to create a very simple RFC call to an RFC function module.  The function I will call is in all SAP implementations and is already configured as an RFC.  The function module is called: FLIGHT_LIST.  The full source code for the web page is also included here. 

Output of running this example:


Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO

Public Class FLIGHT_LIST1
    Inherits System.Web.UI.Page

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ‘Put user code to initialize the page here
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim conStr As String = “ASHOST=<your server> SYSNR=?? CLIENT=?? USER=???????? PASSWD=????????”

        Dim ERR_MSG As String
        Dim O_MSG As String
        Dim O_WDR_FLIGHTSTable As New WDR_FLIGHTSTable
        Dim RFC_FLIGHT_LIST As New FLIGHT_LIST(conStr)

            RFC_FLIGHT_LIST.Flight_List1(“FRANKFURT”, “NEW YORK”, “18000101”, “20120101”, O_MSG, O_WDR_FLIGHTSTable)
            If Not O_WDR_FLIGHTSTable Is Nothing And O_WDR_FLIGHTSTable.Count > 0 Then
                DataGrid1.DataSource = array_to_ds(O_WDR_FLIGHTSTable)
            End If
        Catch ex As Exception
            ERR_MSG = ex.Message
        End Try
    End Sub

    Public Function array_to_ds(ByVal array_in As Object) As DataSet
        Dim ds As New DataSet
        Dim xmlSerializer As XmlSerializer = New XmlSerializer(array_in.GetType)
        Dim writer As StringWriter = New StringWriter
        xmlSerializer.Serialize(writer, array_in)
        Dim reader As StringReader = New StringReader(writer.ToString)

        Return ds
    End Function

End Class

You must be Logged on to comment or reply to a post.
  • Hi Philip,

    Can we use SAP.Net Connector and RFC technology to access data from SAP Esourcing system (version 9.0)? I have doubts as it is a Java based system.



    • Hi Fizza,

      instead of using the comments section of this blog, I sugest that you create your own dedicated thread for your question.

      Also the question is a bit "too general"... In your thread you should provide a few more details, e.g: what exactly are you trying to achieve, have you read the .NET Connector documentation yet, what have you tried so far and what errors did you get?

      Regards, Ulrich