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 -->

Introduction

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
    Try
      Dim oStreamWriter As StreamWriter = New StreamWriter("c:\temp.txt", True)
      oStreamWriter.Write(oSAP.ExecuteABAPfromFile("<A href="file:///c:/abap.txt">c:\abap.txt</A>"))
      oStreamWriter.Close()
      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
    sOut = oSAP.ExecuteToXML("SELECT * FROM MARA WHERE ERSDA < SY-DATUM")
    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
    Next
    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("SELECT * FROM DD02T WHERE DDLANGUAGE = SY-LANGU AND " & 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")

  Else
    MsgBox(oSAP.ABAPError)
  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 http://www.sap-web.de

Notes

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 http://www.ibis-thome.com or mailto: frede@ibisness.de

History

25 Aug 2003 - updated demo app.

License

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

Share

About the Author

dfrede

Germany Germany
No Biography provided

Comments and Discussions

 
GeneralCall RFC Pinmemberjjuniorc20-Jul-07 8:51 
NewsSAP Connector for Visual Studio 2005 Is Available! PinmemberPablo Telmo29-Jun-06 11:33 
GeneralDownload Link changed to http://link4sap.inetconnector.com/ Pinmemberdfrede18-Aug-05 22:50 
GeneralServerSAP PinmemberJames Vago18-Aug-05 5:12 
Generaldownload PinmemberJames Vago18-Aug-05 4:40 
Generaldownload PinmemberJames Vago18-Aug-05 4:40 
GeneralSaplogon.ini Pinsussrmuthiahsamy5-Feb-04 20: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 | Mobile
Web03 | 2.8.141015.1 | Last Updated 25 Aug 2003
Article Copyright 2003 by dfrede
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid