cancel
Showing results for 
Search instead for 
Did you mean: 

SAP .NET Connectivity

Former Member
0 Kudos

Hi there,

I am trying to connect to SAP using .NET. For this I am using SAP Connector. I am able to connect to the server, but when I try to access the RFC RFC_READ_TABLE, I am getting the error “Invalid Method RFC_READ_TABLE”. I tried calling the same RFC from within ABAP and it works fine, which means the function, exists and has no problem executing. But when I try to call the same function from .NET I get the above error.

Basically my main purpose is to extract data from SAP (Tables or Report) in to .NET and further process it based on our needs. I am attaching the entire project directory with this mail so you can get an idea what I am trying to do.

If you can suggest me some other method to accomplish my job, it will do.

I need it very urgently and am very critical for my project so your help would be much appreciated.

Thanks in advance for your help.

Regards,

Shab.

Here is the Code !!

Public Function Rfc_Read_Table( _

ByVal Delimiter As String, _

ByVal No_Data As String, _

ByVal Query_Table As String, _

ByVal Rowcount As Integer, _

ByVal Rowskips As Integer, _

ByRef Data As SAPTable, _

ByRef Fields As SAPTable, _

ByRef Options As SAPTable) As String

Dim results() As Object

Try

results = SAPInvoke("RFC_READ_TABLE ", _

New Object() {Query_Table, Delimiter, No_Data, _

Rowskips, Rowcount, Options, Fields, Data})

Data = CType(results(0), SAPTable)

Fields = CType(results(1), SAPTable)

Options = CType(results(2), SAPTable)

Return String.Empty

Catch ex As Exception

Return ex.Message

End Try

End Function

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hi,

Web services is the best way to connect between SAP and .Net. SAP even came up with.NET connector. .NET connector works well with vs2003 as it was developed in around 2003. but it has certain complication when working with vs2005. Web services will be good option as it does not need any .net connectors to deal with.

check this link for more details about .net and sap connection using web services

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/1615ef47-0a01-0010-a7a8-b8a2a... [original link is broken]

reiner_hille-doering
Active Contributor
0 Kudos

You cannot call SAPInvoke directly. You have to create a proxy and call this.

Former Member
0 Kudos

well - i managed to write my own proxy generator and use the runtime compiler - so i can call any function module just by naming it - everything works but the exceptions:

I only get a RfcAbapException but the error Code is not filled with the ABAP-Exception defined in SE37!

I set all Parameter- and MethodAttributes - but what is the correct Declaration of an Exception?? What else is needed?

public const string NEGATIVE_ARGUMENT = "NEGATIVE_ARGUMENT";

for Z_SQRT e.g. can't be all, doesnt work.

Thanks for a quick answer - this is mission critical because its the only thing left for a fully automated, standard interface to SAP we need for a major client.

Message was edited by:

Oliver Tauth