Calling SAP RFC using VB.Net

Calling SAP RFC using VB.Net

Page 1 of 1

8 Replies - 15996 Views - Last Post: 15 May 2012 - 06:51 AM Rate Topic: -----

#1 Girish_Mohokar  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 13-November 07

Calling SAP RFC using VB.Net

Posted 09 June 2010 - 10:52 PM

Dear All,

I want to connect to SAP and call RFC from VB.Net 2008.
I have done it with VB 6.0
But not getting success in VB.Net
I used following code in VB 6.0
------------------------------------------------
Set ctlLogon = CreateObject("SAP.LogonControl.1")
Set oConnection = ctlLogon.NewConnection

oConnection.User = "SIILRFC"
oConnection.Client = "777"
oConnection.Password = "infy@1234"
oConnection.ApplicationServer = "10.250.2.49"
oConnection.Language = "EN"
oConnection.SystemNumber = "00"

booReturn = oConnection.Logon(0, True)

If booReturn <> True Then
gSAPConnect = False
Else
gSAPConnect = True
End If

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set funcControl = CreateObject("SAP.Functions")
funcControl.Connection = oConnection
Set oRFC = funcControl.Add("ZSIILMM002")
Set oText = oRFC.Exports("TEXT1")
Set oWerks = oRFC.Exports("WERKS1")
Set oProduct = oRFC.Exports("PRODUCT")
oText.Value = Data
oWerks.Value = Works
oProduct.Value = Product
If oRFC.Call = True Then
oStatus = oRFC.Imports("STATUS")
If oStatus = 1 Then ' fail
PostCoil = 1
End If
If oStatus = 0 Then ' success
PostCoil = 2
End If
If oStatus = 2 Then ' DATA ALREADY I SAP
PostCoil = 5
End If
Else
PostCoil = 4 ' RFC not executed
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
------------------------------------------------

Please guide me to do it with VB.NET 2008

Is This A Good Question/Topic? 1
  • +

Replies To: Calling SAP RFC using VB.Net

#2 Guest_anand*


Reputation:

Re: Calling SAP RFC using VB.Net

Posted 17 January 2011 - 03:25 AM

Dim connection As Object
Dim bapi As Object

bapi = CreateObject("SAP.Functions")
connection = bapi.Connection
connection.user = "RFCUSER"
connection.password = "india123"
connection.client = "200"
connection.ApplicationServer = "192.168.23.4"
connection.Language = "EN"
'connection.RouterString = "/H/27.54.190.229/S/3299/H/"
If connection.Logon(0, False) Then
Dim codes = bapi.Add("BAPI_SALESORDER_CREATEFROMDAT2")

codes.call()
Dim table As Table
Dim r As Row
table = codes.Tables("Sales_Order")
Dim I As Integer
Dim j As Integer
Dim status As Boolean = False


For I = 1 To table.RowCount
For j = 1 To table.ColumnCount
Dim s As String = table.ColumnName(j) & ":" & table.Cell(I, j)
rct.Text += s + vbCrLf
' Console.Write(table.ColumnName(j) + ":")
'Console.WriteLine(table.Cell(I, j))
Next
Next
For j = 1 To table.ColumnCount
Dim s As String = table.ColumnName(j) ' & ":" & table.Cell(I, j)
rct.Text += s + vbCrLf
' Console.Write(table.ColumnName(j) + ":")
'Console.WriteLine(table.Cell(I, j))
Next
Console.ReadLine()
End If
Was This Post Helpful? 0

#3 muttleychess  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-May 12

Re: Calling SAP RFC using VB.Net

Posted 14 May 2012 - 06:05 AM

View PostGirish_Mohokar, on 09 June 2010 - 10:52 PM, said:

Dear All,

I want to connect to SAP and call RFC from VB.Net 2008.
I have done it with VB 6.0
But not getting success in VB.Net
I used following code in VB 6.0
------------------------------------------------
Set ctlLogon = CreateObject("SAP.LogonControl.1")
Set oConnection = ctlLogon.NewConnection

oConnection.User = "SIILRFC"
oConnection.Client = "777"
oConnection.Password = "infy@1234"
oConnection.ApplicationServer = "10.250.2.49"
oConnection.Language = "EN"
oConnection.SystemNumber = "00"

booReturn = oConnection.Logon(0, True)

If booReturn <> True Then
gSAPConnect = False
Else
gSAPConnect = True
End If

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set funcControl = CreateObject("SAP.Functions")
funcControl.Connection = oConnection
Set oRFC = funcControl.Add("ZSIILMM002")
Set oText = oRFC.Exports("TEXT1")
Set oWerks = oRFC.Exports("WERKS1")
Set oProduct = oRFC.Exports("PRODUCT")
oText.Value = Data
oWerks.Value = Works
oProduct.Value = Product
If oRFC.Call = True Then
oStatus = oRFC.Imports("STATUS")
If oStatus = 1 Then ' fail
PostCoil = 1
End If
If oStatus = 0 Then ' success
PostCoil = 2
End If
If oStatus = 2 Then ' DATA ALREADY I SAP
PostCoil = 5
End If
Else
PostCoil = 4 ' RFC not executed
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
------------------------------------------------

Please guide me to do it with VB.NET 2008



Hi
How can I to call a RFC that return a table using VB6?
Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Calling SAP RFC using VB.Net

Posted 14 May 2012 - 03:21 PM

Girish, you might find this helpful.

muttleychess, you need to go do some more thorough research as I (and maj) told you in your VB6 thread. Your statement that "RFC do not have a OLE DB provider" is simply false, as any amount of routine research will tell you.

This post has been edited by BobRodes: 14 May 2012 - 03:22 PM

Was This Post Helpful? 0
  • +
  • -

#5 muttleychess  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-May 12

Re: Calling SAP RFC using VB.Net

Posted 14 May 2012 - 05:36 PM

View PostBobRodes, on 14 May 2012 - 03:21 PM, said:

Girish, you might find this helpful.

muttleychess, you need to go do some more thorough research as I (and maj) told you in your VB6 thread. Your statement that "RFC do not have a OLE DB provider" is simply false, as any amount of routine research will tell you.

I do not know and SAP too
Was This Post Helpful? 0
  • +
  • -

#6 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Calling SAP RFC using VB.Net

Posted 15 May 2012 - 06:05 AM

Unintelligible.
Was This Post Helpful? 0
  • +
  • -

#7 muttleychess  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-May 12

Re: Calling SAP RFC using VB.Net

Posted 15 May 2012 - 06:21 AM

View PostBobRodes, on 15 May 2012 - 06:05 AM, said:

Unintelligible.

4u of course , thank you :sleep1:
Was This Post Helpful? 0
  • +
  • -

#8 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Calling SAP RFC using VB.Net

Posted 15 May 2012 - 06:35 AM

I freely admit that "I do not know and SAP too" might be intelligible to someone else. Don't all speak up at once...meanwhile, how are you coming on your research into YOUR problem?

This post has been edited by BobRodes: 15 May 2012 - 06:36 AM

Was This Post Helpful? 0
  • +
  • -

#9 muttleychess  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-May 12

Re: Calling SAP RFC using VB.Net

Posted 15 May 2012 - 06:51 AM

View PostBobRodes, on 15 May 2012 - 06:35 AM, said:

I freely admit that "I do not know and SAP too" might be intelligible to someone else. Don't all speak up at once...meanwhile, how are you coming on your research into YOUR problem?

:ban: thank you
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1