Click here to Skip to main content
Click here to Skip to main content

Open Table Access to SAP R/3 with .NET

, 24 Aug 2003
Rate this:
Please Sign up or sign in to vote.
Retrieve R/3 Table Contents or ABAP functionality
<!-- Article image -->

Sample Image - SAPLogonNet.jpg

<!-- Add the rest of your HTML here -->


Using the SAP.Connector is very hard to retrieve real table contents of a R/3 Database and logon to a SAP-System. 

SAPLink provides an easy way to get SAP-Data from any System with RFC-functionality.

Using the code

Download and install SapLink_Trial_Setup.msi 
Open the SAPLink Demo Project from the Desktop 

It is necessary to have a SAPLogon.ini, which describes the available SAP-Servers

Private Sub btnStart_Click(ByVal sender As System.Object, _<BR>                           ByVal e As System.EventArgs) _
                Handles btnStart.Click

  Dim sOut As String
  Dim oSAP As New SAPLink.Login.Component()

  'Show LogonScreen
  If Not oSAP.Connected Then oSAP.Login()

  If oSAP.Connected Then

    'Get Tablenames with "Finanzkreise" in description
    sOut = oSAP.ABAP_ReadTables(, "Finanzkreise")
    MsgBox(sOut, MsgBoxStyle.Information, _
           "Get Tablenames with 'Finanzkreise' in description")

    'Executing existing ABAP and write Output to File
      Dim oStreamWriter As StreamWriter = New StreamWriter("c:\temp.txt", True)
      oStreamWriter.Write(oSAP.ExecuteABAPfromFile("<A href="file:///c:/abap.txt">c:\abap.txt</A>"))
      If oSAP.ABAPError <> "" Then MsgBox(oSAP.ABAPError)
    Catch ex As Exception
    End Try
    MsgBox("c:\temp.txt written", MsgBoxStyle.Information, _
           "Executing existing ABAP and write Output to File")

    'SQL-Select on a SAP-Table with XML-Output
    oSAP.MaxReturnRows = 5
    oSAP.SkipRows = 0
    MsgBox(sOut, MsgBoxStyle.Information, _
           "SQL-Select on a SAP-Table with XML-Output")

    'SQL-Select on a SAP-Table with Dataset-Output
    sOut = ""
    Dim a As Integer

    Dim dt As New DataTable()
    dt = oSAP.Execute("SELECT * FROM T000 WHERE MTEXT <> 'EarlyWatch'")
    For a = 0 To dt.Rows.Count - 1
      sOut += dt.Rows(a).Item("MANDT") & "-" & dt.Rows(a).Item("MTEXT") & vbCrLf
    MsgBox(sOut, MsgBoxStyle.Information, _
           "SQL-Select on a SAP-Table with Dataset-Output")

    'Execute ABAP on the fly
    Dim sb As New System.Text.StringBuilder()

    sb.Append("report ZSAPCON no standard page heading line-size 255." & vbCrLf)
    sb.Append("TABLES: DD02T." & vbCrLf)
    sb.Append("DATA: COUNT TYPE I." & vbCrLf)
    sb.Append("         DDTEXT LIKE '%PLANT%'." & vbCrLf)
    sb.Append("  WRITE: /  DD02T-TABNAME, ',' , DD02T-DDTEXT." & vbCrLf)
    sb.Append("ENDSELECT." & vbCrLf)

    sOut = oSAP.ExecuteABAP(sb.ToString)
    MsgBox(sOut, MsgBoxStyle.Information, "Execute ABAP on the fly")

  End If
End Sub

Points of Interest

Here you see a message box output from the code above:

Sample Image - maximum width is 600 pixels

Download more SAP-Developer OCX for VB 6 and ADO/DAO from


The Saplink.dll is in Version 1.0.0 only for testing.  DO NOT de-comment:

'For Test purposes only to avoid the Trial-Messagebox
'oSAP.I_use_this_control_without_Legal_Copyright = True        

in any other case visit or mailto:


25 Aug 2003 - updated demo app.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author


Germany Germany
No Biography provided

Comments and Discussions

GeneralCall RFC Pinmemberjjuniorc20-Jul-07 9:51 
NewsSAP Connector for Visual Studio 2005 Is Available! PinmemberPablo Telmo29-Jun-06 12:33 
GeneralDownload Link changed to Pinmemberdfrede18-Aug-05 23:50 
GeneralServerSAP PinmemberJames Vago18-Aug-05 6:12 
Generaldownload PinmemberJames Vago18-Aug-05 5:40 
Generaldownload PinmemberJames Vago18-Aug-05 5:40 
GeneralSaplogon.ini Pinsussrmuthiahsamy5-Feb-04 21:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150414.1 | Last Updated 25 Aug 2003
Article Copyright 2003 by dfrede
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid