Using XML templates can improve the performance of your application by loading the complete object hierarchy from an XML file.
How to Create an XML Template #
The ERPConnect installation package includes the tool Function-Template-Generator that generates reusable XML templates for Function Modules and BAPIs.
- To start the Function-Template-Generator, run the FunctionTemplateGenerator.exe in the ERPConnect directory
C:\Program Files\ERPConnect
. - Enter the name of a Function Module or BAPI that you want to use as a template and click [Generate XML Template].
- The window “SAP Login” opens. Enter your SAP credentials and click [OK].
- Save the XML file to your local hard drive.
How to Use XML Templates #
- Create an XML template using the tool FunctionTemplateGenerator.exe located in the ERPConnect directory.
- Add the XML file to your project as a resource.
- Load the XML file into your program as shown in the C# example code below.
Now you can use the FRFCFunction-object instead of using the CreateFunction/CreateBAPI methods.
using (R3Connection con = new R3Connection("SAPServer", 00, "SAPUser", "Password", "EN", "800"))
{
RFCFunction f = new RFCFunction("BAPI_CUSTOMER_GETDETAIL");
f.Connection = con;
StreamReader reader = new StreamReader(
System.Reflection.Assembly.GetExecutingAssembly().
GetManifestResourceStream
("PocketGetCustomer.BAPI_CUSTOMER_GETDETAIL.xml"));
f.LoadFromXML(reader);
}