
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, _
ByVal e As System.EventArgs) _
Handles btnStart.Click
Dim sOut As String
Dim oSAP As New SAPLink.Login.Component()
If Not oSAP.Connected Then oSAP.Login()
If oSAP.Connected Then
sOut = oSAP.ABAP_ReadTables(, "Finanzkreise")
MsgBox(sOut, MsgBoxStyle.Information, _
"Get Tablenames with 'Finanzkreise' in description")
Try
Dim oStreamWriter As StreamWriter = New StreamWriter("c:\temp.txt", True)
oStreamWriter.Write(oSAP.ExecuteABAPfromFile("file:///c:/abap.txt">c:\abap.txt"))
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")
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")
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")
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:

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:
in any other case visit http://www.ibis-thome.com or mailto: frede@ibisness.de
History
25 Aug 2003 - updated demo app.