The Repository 
The usual case is that the .NET Connector reads the necessary metadata information from the data dictionary (DDIC) of a connected SAP backend system. An SAP backend system is represented by the class RfcDestination. Consequently, you can obtain a repository from an RfcDestination object. The repository object then gives you access to both metadata descriptions (needed only, if you want to explore the layout of unknown function modules, structures and tables dynamically) and data containers (needed for executing RFC client calls, as well as for processing incoming RFC requests in a server program). A repository is represented by the class RfcRepository and provides the following functionality:
public class RfcRepository
public IRfcFunction CreateFunction(String name)
This function is the one that you’ll be using most. It automatically takes the metadata description of the requested function module and constructs a corresponding data container from it. Data containers for structures or tables that are used by this function module internally, are created “on demand”, meaning they are created, when you first try to read from or write into it.
public RfcStructureMetadataGetStructureMetadata(String name)
Reads the definition of a structure from the repository. The name has to be specified as given in the ABAP DDIC (SE11). This function first checks, whether the metadata for the given structure is already stored in the internal cache, and if yes returns it. If not, it executes an RFC lookup into the SAP backend corresponding to the Rfc Destination to which this repository is connected. This function is rarely needed.
public RfcTableMetadata GetTableMetadata(String name)
Reads the definition of a table from the repository. The name has to be specified as given in the ABAP DDIC (SE11). This function first checks, whether the metadata for the given table is already stored in the internal cache, and if yes returns it. If not, it executes an RFC lookup into the SAP backend corresponding to the Rfc Destination to which this repository is connected. This function is rarely needed.
public RfcFunctionMetadata GetFunctionMetadata(String name)
Reads the definition of a function module from the repository. The function name has to be specified as given in the ABAP Function Builder (SE37). This function first checks, whether the metadata for the given function module is already stored in the internal cache, and if yes returns it. If not, it makes an RFC lookup into the SAP backend corresponding to the RfcDestination to which this repository is connected. This function is rarely needed.
public RfcAbapObjectMetadata GetAbapObjectMetadata(String name)
Reads the definition of an ABAP class from the repository. The class name has to be specified as given in the ABAP Class Builder (SE24). This function first checks, whether the metadata for the given ABAP class is already stored in the internal cache, and if yes returns it. If not, it makes an RFC lookup into the SAP backend corresponding to the RfcDestination to which this repository is connected. This function is rarely needed.
public void RemoveStructureMetadata(String name)
Removes a structure definition from the cache. This can be useful, if you have a long-running .NET process, and during its lifetime this structure is modified on ABAP side (e.g. by adding or removing fields). If your .NET program would continue using the cached metadata information, you would run into inconsistencies including data corruption or data loss. By removing the metadata from the cache, the .NET Connector is forced to repeat the DDIC lookup in the backend system the next time this structure is needed. This ensures that it then loads the updated metadata information into its cache.
public void RemoveTableMetadata(String name)
Removes a table definition from the cache. For more information see RemoveStructureMetadata().
public void RemoveFunctionMetadata(String name)
Removes a function definition from the cache. For more information see RemoveStructureMetadata().
public void RemoveAbapObjectMetadata(String name)
Removes an ABAP class definition from the cache. For more information see RemoveStructureMetadata().
public void ClearAllMetadata()
Removes all metadata from all caches. For more information see RemoveStructureMetadata().
public void ClearStructureMetadata()
Removes all structure definitions from the cache. For more information see RemoveStructureMetadata().
public void ClearTableMetadata()
Removes all table definitions from the cache. For more information see RemoveStructureMetadata().
public void ClearFunctionMetadata()
Removes all function definitions from the cache. For more information see RemoveStructureMetadata().
public void ClearAbapObjectMetadata()
Removes all class definitions from the cache. For more information see RemoveStructureMetadata().
Note
The internal cache used by an RfcRepository object is shared between all repositories that are connected to the same backend system. Even if you have several different RfcDestination objects, which are distinguished only by different user logon information, but refer to the same backend system, the repositories obtained from these destinations have only one common cache for their metadata descriptions.
Exceptions: the first five functions can throw the following exceptions: RfcCommunicationException, RfcSystemException, RfcLogonException, RfcInternalError, RfcABAPException.
The remaining five functions throw no exceptions.
If you want to work with hard-coded metadata, for example because you want to write a server application, that either can be run without logon credentials for the backend or wants to provide function modules that do not exist in the backend’s DDIC, then you have to create a “custom repository”. A custom repository can be used to store your home-made metadata in. Optionally you can assign a destination to the custom repository, if you want to provide only a few function descriptions of your own and have the custom repository lookup the rest from a DDIC.
public class RfcCustomRepository:RfcRepository
public static RfcCustomRepository Create()
Creates one of these animals.
public void SetDestination(RfcDestination destination)
If you provide this optional destination, the custom repository will use it for DDIC lookups for all metadata descriptions that it can’t find in its cache.
public void AddStructureMetadata(RfcStructureMetadata structureDesc)
Adds the definition of a structure to this repository.
public void AddTableMetadata(RfcTableMetadata tableDesc)
Adds the definition of a table to this repository.
public void AddFunctionMetadata(RfcFunctionMetadata functionDesc)
Adds the definition of a function module to this repository.
public void AddAbapObjectMetadata(RfcAbapObjectMetadata classDesc)
Adds the definition of an ABAP object (i.e. class) to this repository. In case you really need to work with the metadata objects, here they are.
Basically there are two kinds of metadata:
Element metadata, which are used for fields of structures, parameters of function modules and attributes of ABAP classes. They contain information like the data type of a field (CHAR, FLOAT, INT, etc.) and its length.
Container metadata, which are used to describe composite types like structures (which are collections of various fields) and function modules (which are collections of their parameters and exceptions)