Open table access to SAP R/3 with .NET

Retrieving table content with the SAP .NET connector is very difficult. Not so with this handy little dll!

Retrieving table content with the SAP .NET connector is very difficult. Not so with this handy little dll!
'  SAPLink.NET / SAPLink.ocx / ASPSaplink.dll    
 
 
2002-2003 SAPLink - Solutions for your systems  
 
 

.NET Example 


Imports System.IO
Imports System.Data.SqlClient 
Imports SAPLINK 
Public Class Form2 

Inherits System.Windows.Forms.Form 
Private oSAP As New SAPLINK.Component 


Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 
btnStart.Click  
Dim sOut As String 
'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("c:abap.txt"))  
        oStreamWriter.Close()  
    I    f oSAP.ABAPError <> "" Then MsgBox(oSAP.ABAPError)  
    Catch ex As Exception  
    End Try  
    MsgBox("c:temp.txt written", MsgBoxStyle.Information, "Executing existing ABAP and write 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 
Private Sub btnEnd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnd.Click 
If oSAP.Connected Then oSAP.CloseConnection() 
End 
End Sub
This was first published in June 2003
This Content Component encountered an error

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close