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(); } } }
}