Skip to Content
0
May 30, 2011 at 01:50 PM

RFC-client with .net connector 3.0

109 Views

ello.

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. Do not fill out the parameter repository.

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