Need Code Example to Call a SAP Remote Function from C#

M

mike.hudson

I'm looking for an example of how to call a SAP RFC from within a C#
program. If I have a function called "MyFunction" and it takes 1
input parameter and returns one output parameter (a table) how would
it be coded. I have been able to code the connection and it works so
once the connection is established I need to call the funcation. Here
is the code so far.

using System;
using SAP.Connector;
using SAP.Connector.Rfc;
using SAP.Connector.Internal;



namespace ConsoleApplication2
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static void Main(string[] args)
{
SAP.Connector.Destination dest = new SAP.Connector.Destination();
dest.AppServerHost = "NAFTATEST01.SAP.INTRA";
dest.Client = 300;
dest.SystemNumber = 0;
dest.Username = "myusername";
dest.Password = "mypassword";
SAP.Connector.SAPConnection connSAP = new
SAP.Connector.SAPConnection(dest);

using(connSAP)
{
try
{
connSAP.Open();
Console.WriteLine("SAP Connection was opened...");
connSAP.Close();
}
catch(SAP.Connector.RfcException rfcEx)
{
Console.WriteLine("SAP Connection was failed...");
Console.WriteLine( rfcEx.Message
+ rfcEx.StackTrace);
Console.WriteLine();
}
}
}

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top