Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

RFC-client with .net connector 3.0

Hello.

I need help in working with the RFC.

I'm trying to write a client to connect to SAP system using an example.

 
using System;
using System.Collections.Generic;
using System.Text;
//using System.Linq;
using SAP.Middleware.Connector;

namespace ConsoleApplication1
{

     public class MyBackendConfig : IDestinationConfiguration
    {
       public static void Main(string[] args)
       {
           RfcDestinationManager.RegisterDestinationConfiguration(new
                MyBackendConfig());//1
           RfcDestination prd = RfcDestinationManager.
              GetDestination("PRD_000");//2
           try
           {

               RfcRepository repo = prd.Repository;//3                    
               IRfcFunction companyBapi =
                  repo.CreateFunction
                 ("BAPI_COMPANY_GETDETAIL");//4              
               companyBapi.SetValue("COMPANYID", "001000"); //5
               companyBapi.Invoke(prd); //6
               IRfcStructure detail = companyBapi.GetStructure("COMPANY_DETAIL");
               String companyName = detail.GetString("NAME1");//7                
               Console.WriteLine(companyName);
               Console.Read();
           }
           catch { }
           // next you should handle all the relevant exceptions, but
           // we will not do this here
           // some exception handling 

       }
       public RfcConfigParameters GetParameters(String destinationName)
        {
            if ("PRD_000".Equals(destinationName))
            {
                RfcConfigParameters parms = new RfcConfigParameters();
                parms.Add(RfcConfigParameters.AppServerHost, "111.111.111.111");
                parms.Add(RfcConfigParameters.SystemNumber, "00");
                parms.Add(RfcConfigParameters.SystemID, "IDS");
                parms.Add(RfcConfigParameters.User, "USER");
                parms.Add(RfcConfigParameters.Password, "PASW");
                parms.Add(RfcConfigParameters.Client, "100");
                parms.Add(RfcConfigParameters.Language, "EN");
                parms.Add(RfcConfigParameters.PoolSize, "5");
                parms.Add(RfcConfigParameters.MaxPoolSize, "10");
                parms.Add(RfcConfigParameters.IdleTimeout, "600");
                return parms;
            }
            else return null;
        }
        // The following two are not used in this example:
        public bool ChangeEventsSupported()
        {
            return false;
        }
        public event RfcDestinationManager.ConfigurationChangeHandler
        ConfigurationChanged ;
    }

}

Connection is not happening.

Returning:

 
  u0432 SAP.Middleware.Connector.RfcConnection.ConnectAsClient(RfcConfigParameters options)
   u0432 SAP.Middleware.Connector.RfcConnectionPool..ctor(RfcDestination d, Boolean forRepositoryCalls, String uniqueKey)
   u0432 SAP.Middleware.Connector.RfcConnectionManager.GetClient(RfcDestination destination, Boolean forRepository)
   u0432 SAP.Middleware.Connector.RfcDestination.GetClient(Boolean forRepository)
   u0432 SAP.Middleware.Connector.RfcDestination.SetAttributeValues(RfcSystemAttributes attribs)
   u0432 SAP.Middleware.Connector.RfcDestination.get_SystemAttributes()
   u0432 SAP.Middleware.Connector.RfcRepositoryManager.GetRepository(RfcDestination destination)
   u0432 SAP.Middleware.Connector.RfcDestination.get_Repository()
   u0432 ConsoleApplication1.MyBackendConfig.Main(String[] args) u0432 C:\Users\sinekopova\documents\visual studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:string 21

Tell me whether you need to configure an incoming connection RFC destination in SM59? If yes, how?

Edited by: VS on May 31, 2011 9:48 AM

Not what you were looking for? View more on this topic or Ask a question