' 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,
Requires Free Membership to View
When you register, you will start receiving targeted emails from my award-winning team of editorial writers. Our goal is to keep you informed on the hottest topics and biggest challenges faced by SAP professionals today.
Hannah Smalltree, Editorial Director 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
Join the conversationComment
Share
Comments
Results
Contribute to the conversation