详细内容看参考
1.代码如下:
using System;
using SAP.Middleware.Connector;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
RfcConfigParameters config = new RfcConfigParameters();
config.Add(RfcConfigParameters.Name, "SAP");
config.Add(RfcConfigParameters.AppServerHost, "192.168.1.15");
config.Add(RfcConfigParameters.SystemNumber, "00");
config.Add(RfcConfigParameters.User, "baba");
config.Add(RfcConfigParameters.Password, "t12t");
config.Add(RfcConfigParameters.Client, "905");
config.Add(RfcConfigParameters.Language, "ZH");
RfcDestination destination = RfcDestinationManager.GetDestination(config);
RfcRepository respository = destination.Repository;
IRfcFunction function = respository.CreateFunction("Z_GET_SCAR");
function.SetValue("I_CARRID", "AC");
try
{
function.Invoke(destination);
string name = function.GetString("E_CARRNAME");
Console.WriteLine(name);
}
catch(RfcAbapException ex)
{
if (ex.Key == "CARR_NOT_FOUND")
Console.WriteLine("Airline company not found with given id.");
}
Console.ReadLine();
}
}
}