on 08-08-2011 9:17 AM
Are we suppose to create the RFC Destination "PRD_000" in SM59 for the following code? If yes, then how?
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)
{
Console.WriteLine("Test1");
RfcDestinationManager.RegisterDestinationConfiguration(new
MyBackendConfig());//1
RfcDestination prd = RfcDestinationManager.
GetDestination("PRD_000");//2
Console.WriteLine("Test2");
try
{
Console.WriteLine("Test3");
RfcRepository repo = prd.Repository;//3
Console.WriteLine("Test4");
IRfcFunction companyBapi =
repo.CreateFunction
("BAPI_COMPANY_GETDETAIL");//4
Console.WriteLine("Test5");
companyBapi.SetValue("COMPANYID", "00001"); //5
Console.WriteLine("Test6");
companyBapi.Invoke(prd); //6
Console.WriteLine("Test7");
IRfcStructure detail = companyBapi.GetStructure("COMPANY_DETAIL");
Console.WriteLine("Test8");
String companyName = detail.GetString("NAME1");//7
Console.WriteLine("Test9");
Console.WriteLine(companyName);
Console.WriteLine("Test10");
Console.Read();
Console.WriteLine("Test11");
}
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.11.111.11");
parms.Add(RfcConfigParameters.SystemNumber, "00");
parms.Add(RfcConfigParameters.SystemID, "PRD");
parms.Add(RfcConfigParameters.User, "user");
parms.Add(RfcConfigParameters.Password, "password");
parms.Add(RfcConfigParameters.Client, "300");
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;
}
}
Hi,
No need to create the destination to SAP. It is just a reference in your code to the connection parameters.
RfcDestination prd = RfcDestinationManager.
GetDestination("PRD_000");//2
...
public RfcConfigParameters GetParameters(String destinationName)
{
if ("PRD_000".Equals(destinationName))
....
else return null;
jani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.