‎2008 Feb 28 4:23 AM
hi
i am trying to connect sap bapi function using asp.net ,any one can help on this
thanks
kanishka
‎2008 Feb 28 4:47 AM
Hi ,
I have used this and its successfully inserted data in R/3.
So you follow this method:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter
Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.OleDbDataAdapter1 = New System.Data.OleDb.OleDbDataAdapter
Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(224, 72)
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 0
Me.Label1.Text = "EMPID"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(224, 136)
Me.Label2.Name = "Label2"
Me.Label2.TabIndex = 1
Me.Label2.Text = "EMPSTATUS"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(224, 208)
Me.Label3.Name = "Label3"
Me.Label3.TabIndex = 2
Me.Label3.Text = "EMPNAME"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(384, 72)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(384, 136)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(256, 20)
Me.TextBox2.TabIndex = 4
Me.TextBox2.Text = ""
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(384, 205)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(256, 20)
Me.TextBox3.TabIndex = 5
Me.TextBox3.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(336, 296)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(120, 23)
Me.Button1.TabIndex = 6
Me.Button1.Text = "SAVE TO R/3"
'
'OleDbDataAdapter1
'
Me.OleDbDataAdapter1.InsertCommand = Me.OleDbInsertCommand1
Me.OleDbDataAdapter1.SelectCommand = Me.OleDbSelectCommand1
Me.OleDbDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "ZPA_EMP", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("EMPID", "EMPID"), New System.Data.Common.DataColumnMapping("EMPNAME", "EMPNAME"), New System.Data.Common.DataColumnMapping("EMPSTATUS", "EMPSTATUS")})})
'
'OleDbSelectCommand1
'
Me.OleDbSelectCommand1.CommandText = "SELECT EMPID, EMPNAME, EMPSTATUS FROM ZPA_EMP"
Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1
'
'OleDbInsertCommand1
'
Me.OleDbInsertCommand1.CommandText = "INSERT INTO ZPA_EMP(EMPID, EMPNAME, EMPSTATUS) VALUES (?, ?, ?); SELECT EMPID, EM" & _
"PNAME, EMPSTATUS FROM ZPA_EMP"
Me.OleDbInsertCommand1.Connection = Me.OleDbConnection1
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("EMPID", System.Data.OleDb.OleDbType.Integer, 4, "EMPID"))
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("EMPNAME", System.Data.OleDb.OleDbType.VarChar, 50, "EMPNAME"))
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("EMPSTATUS", System.Data.OleDb.OleDbType.VarChar, 50, "EMPSTATUS"))
'
'OleDbConnection1
'
Me.OleDbConnection1.ConnectionString = "Integrated Security=SSPI;Packet Size=4096;Data Source=PC3;Tag with column collati" & _
"on when possible=False;Initial Catalog=master;Use Procedure for Prepare=1;Auto T" & _
"ranslate=True;Persist Security Info=False;Provider=""SQLOLEDB.1"";Workstation ID=P" & _
"C3;Use Encryption for Data=False"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(792, 462)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Dim R3 As Object
Dim FBFunc As Object
Dim returnFunc As Boolean
Dim connected As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
R3 = CreateObject("SAP.Functions")
R3.Connection.Client = "800"
R3.Connection.User = "PARESH"
R3.Connection.Password = "patel"
R3.Connection.Language = "EN"
R3.Connection.System = "EC5"
R3.Connection.Applicationserver = "192.168.3.15" ' IP-adress of the application server
connected = R3.Connection.Logon(0, True) ' True=Autologon
If connected = True Then
FBFunc = R3.add("ZPA_INSERT_DATA") ' RFC IN ABAP
' BELOW ALL ARE IMPORTING PARAMETERS OF RFC
FBFunc.exports("EMPID") = TextBox1.Text
FBFunc.exports("EMPSTATUS") = TextBox2.Text
FBFunc.exports("EMPNAME") = TextBox3.Text
returnFunc = FBFunc.Call()
End If
If returnFunc = True Then
MessageBox.Show("NEW RECORD HAS BEEN ADDED TO SAP R/3 DATABASE !!!", "ADDING RECORDS!!!")
End If
End Sub
End Class
Also Look this links
Thanks & Regards,
Dhruv Shah
‎2008 Feb 28 5:29 AM
hi Dhruv .
thanks for the details,i ma trying to do that code,i'll get back to you..
thanks
kanishka
‎2008 Feb 28 5:46 AM
‎2008 Feb 28 6:04 AM
Hi,
Yes you have to create RFC in abap.
Its mentioned in the Code buddy.
Also if you dont understand then use the following links.
[http://www.sapgenie.com/interfaces/netconnector.htm]
[http://www.sapgenie.com/faq/dotnet.htm]
[https://media.sdn.sap.com/html/submitted_docs/dotnet/Programming%20with%20PDK%20for%20.NET%5CConnecting%20to%20SAP%20NetWeaver%20Systems%5CUsing%20SAP%20.NET%20Connector.htm]
[http://help.sap.com/saphelp_nw04/helpdata/en/51/d5470940fd564b888f4beb9523fa6c/content.htm]
[http://help.sap.com/saphelp_erp2005/helpdata/en/51/d5470940fd564b888f4beb9523fa6c/frameset.htm]
[http://help.sap.com/saphelp_erp2005/helpdata/en/22/042eb0488911d189490000e829fbbd/frameset.htm]
Regards,
Dhruv Shah
‎2015 Mar 17 6:59 AM
‎2015 Mar 17 9:02 AM
Hi Patel,
I think you are asking how to connect asp.net from SAP..?
For such thing you want to expose a web service in SAP side....
From a functional module you can easily create a Web service on SAP.
Regards,
Pathum.