Show TOC

Background documentationDestination Management Locate this document in the navigation structure

 

All RFC destinations of an application are configured centrally using one (singleton) class, the RfcDestinationManager. It manages the logon parameters for all SAP systems to which the application needs access. Basically there are three mutually exclusive ways for an application to provide the logon parameters needed for SAP system access:

  1. Provide the parameters during runtime (e.g. if you get them from a UI).

  2. Define the parameters in the standard .NET configuration file of the executable

  3. Implement and provide a configuration object, which the RfcDestinationManager can “ask”, whenever it needs logon parameters for a particular system. This configuration object can then do whatever it wants (e.g. lookup parameters in a central LDAP system or a database), as long as it comes up with the required parameters.

public class RfcDestinationManager

public static IDestinationConfiguration

Configuration Applications can set this, but only once in the lifetime of a process. This ensures that in server environments no “end user” can override the destination configuration installed by the administrator at startup of the server process. An instance of this class has to be able to provide logon parameters for all SAP systems to which the application(s) need access. As an alternative to providing an instance of this interface, the application can define the logon parameters for its systems in the standard .NET configuration file of the executable. The .NET Connector will read it from there and install a default implementation of IDestinationConfiguration using that information.

public static RfcDestination GetDestination(String name)

Returns the destination object specified by name. The RfcDestinationManager checks, whether that destination has already been created, and if not, asks the Configuration object for the necessary logon parameters and creates one. If no Configuration object has been registered by the application, this throws an exception.

public static RfcDestination GetDestination( Dictionary <String, String> parameters)

This API provides the possibility for applications to directly pass their logon parameters at runtime. The dictionary has to contain the necessary logon information for the SAP system to which to connect. The RfcDestinationManager takes them and creates a destination from them. This API throws an exception, if a Configuration object has been installed! Applications that want to use the “configuration approach” need to implement the following interface and then set an instance on the RfcDestinationManager during application startup.

Alternatively, they can provide AssemblyName and TypeName of the implementation and the .NET Connector will try to load an instance of the given class from the Global Assembly Cache. This object then provides access to the application’s central SAP system configuration.

public interface IDestinationConfiguration

public static String AssemblyName

If you want the .NET Connector to automatically look for an implementation, provide the names of the assembly and of the type that should be attempted to load.

public static String TypeName

If you want the .NET Connector to automatically look for an implementation, provide the names of the assembly and of the type that should be attempted to load.

public Dictionary <String, String> GetParameters( String destinationName)

This function needs to provide all logon parameters and connection pool configuration parameters necessary to connect to the system given by name.

public bool ChangeEventsSupported()

Your application needs to return true or false here, depending on whether your configuration object wants to support configuration change events.

public delegate void ConfigurationChangeHandler(String destinationName, RfcConfigurationArgs args)

Applications can ignore this; it is used by the .NET Connector internally.

public event ConfigurationChangeHandler ConfigurationChanged

If your configuration object says it supports configuration change events, then the .NET connector will register a delegate of type ConfigurationChangeHandler for this event. Then whenever your application wants to change one or more connection parameters for a given SAP system (e.g. using a different hostname or changing the connection pool size), it needs to trigger this event, and the .NET Connector will change the corresponding RfcDestination object correspondingly.

The event arguments for the above event look like this:

public class RfcConfigurationEventArgs:EventArgs

public EventType Type

The type of the configuration change. See below.

public Dictionary <String, String> ChangedParameters

All parameters that have changed and their new values in case Type == CHANGED.

public enum EventType {CHANGED, DELETED}

The following class is a reference to a particular SAP system with particular user and logon information. It encapsulates functionality like connection pooling and the invocation mechanism for synchronous RFCs, tRFCs, qRFCs and bgRFCs.

public class RfcDestination

public Dictionary <String, String> Parameters

A copy of all connection and logon parameters from which this destination has been created. (Except for the password of course.)

public RfcRepository Repository

A reference to the repository used by this destination. Obtain your function module data containers from here. If the destination parameter REPOSITORY_DESTINATION is not provided in the parameters, from which this destination has been created, then this repository will use connections from this destination’s connection pool for any necessary DDIC lookups. If, however, REPOSITORY_DESTINATION has been provided, this repository uses the given destination’s connection pool.

This feature can be used for example for separating the SAP user used for invoking the application function modules from the user used for DDIC lookups. See SAP note 460089 for details.

public void ConfirmTransactionID(RfcTID tid)

Performs the ConfirmTID step of the tRFC/qRFC protocol in the backend system.

Basically this deletes the given transaction ID from the backend’s ARFCRSTATE table.

public void ConfirmUnitID(RfcUnitID uid)

Performs the ConfirmTID step of the bgRFC protocol in the backend system. Basically this deletes the given unit ID from the backend’s bgRFC control tables.

public RfcUnitState GetUnitState(RfcUnitID id)

As long as the bgRFC unit has not yet been confirmed, its current processing state can be retrieved via this function.

public RfcConnectionAttributes Attributes

Returns the RFC connection attributes associated with RFC connections from this pool. Those attributes, which depend on the actual physical connection (like the CPIC conversation ID), are taken from the connection that has last been active.

public void Shutdown(bool abortFctCalls)

Closes all connections in the pool and releases all resources. If abortFctCalls==true, all currently executing function calls are aborted immediately. Otherwise Shutdown() waits for them to complete.

Additionally, for a set of most important parameters, we provide read-only Properties. Additionally, for a set of parameters that can be changed on the fly (pool-size, timeout, username, password) we provide read&write Properties. (Password should be write-only.)

public enum RfcUnitState

{NOT_FOUND, IN_PROCESS, COMMITTED, ROLLED_BACK, CONFIRMED}

This class provides information about the backend on the other side of the connection. It has the following read-only properties of type String (except for sncPartnerKey):

public struct RfcConnectionAttributes

destination

byte[] sncPartnerKey

host

codepage

partnerHost

partnerCodepage

sysNumber

rfcRole

sysID

type

client

partnerType

user

release

language

partnerRelease

isoLanguage

kernelRelease

trace

cpicConversationID

ticket

programName

sncPartnerName