Mapping File for Generic RFC Mode

The mapping file for the RFC Input adapter running in generic RFC mode specifies mapping definitions for RFCs. The mapping file for the RFC Output adapter running in generic RFC mode specifies how ESP stream columns map to RFC parameters.

You can also use the schema discovery functionality in SAP Sybase Event Stream Processor Studio to automatically create a mapping file. See Discovering Schema and Creating a Mapping File for the SAP RFC Adapter in the Studio Users Guide for detailed instructions on creating a mapping file in SAP Sybase Event Stream Processor Studio. If you use Studio to create the mapping file, edit the generated mapping file by adding the <variables> and <input> elements as they are not included.

Input Adapter

In this mode, a mapping definition for the RFC Input adapter starts with an <rfc> element which includes a name attribute that indicates the RFC the definition is for. A sample mapping file for the input adapter is included in the $ESP_HOME/adapters/rfc/examples/polling_input directory. For example:

<rfc name="ESP_RFC_1">
	<variables>
		<variable name="var1">100</variable>
	</variables>
	<input>
		<import>
			<parameter name="IMPORT_TAB" valueType="table">
				<parameter name="I">99999</parameter>
				<parameter name="C">X</parameter>
				<parameter name="STR">Test Table String 1</parameter>
			</parameter>
			<parameter name="IMPORT_TAB" valueType="table">
				<parameter name="I">88888</parameter>
				<parameter name="C">Y</parameter>
				<parameter name="STR">Test Table String 2</parameter>
			</parameter>
		</import>
		<changing>
				<parameter name="IMPORTSTRUCT.I">54321</parameter>
				<parameter name="IMPORTSTRUCT.C">Z</parameter>
				<parameter name="IMPORTSTRUCT.STR">Test String</parameter>
				<parameter name=”COUNTER” valueType=”variable”>var1</parameter>
		</changing>
	</input>
	<mapping>
		<export>
			<fieldMapping name="RESPTEXT" espField="Column1"/>
			<fieldMapping name="EXPORT_TAB.I" espField="Column2"/>
			<fieldMapping name="EXPORT_TAB.STR" espField="Column3"/>
		</export>
		<changing>
			<fieldMapping name=”COUNTER” espField=”Column4” saveToVariable=”var1”/>
		</changing>
	</mapping>
</rfc>

The mapping definition contains three sections: variables, input, and mapping. In generic RFC mode, the adapter can store output values from an RFC into temporary storage called variables. These variables can be subsequently used as input values for invoking RFCs.

Each variable definition consists of a <variable> element which contains a name attribute and the content of that element. The content value for the variable definition is considered the initial value of the variable. This value can be overwritten after an RFC is invoked if any of the RFC output parameters are mapped to this variable. The variable can be used as input for a parameter by specifying the valueType attribute of the parameter to variable and the value to the name of the variable.You cannot save RFC structure or table parameters to a variable.

New values are stored to the variable definitions when RFC output is mapped with a saveToVariable attribute set to the variable name on the <fieldMapping> entry. In the example, a variable named “var1” is defined, with the initial value set to 100. Its value is used as input for the changing parameter COUNTER. After the RFC is executed, the updated value of COUNTER is stored to var1, so in the next invocation of the RFC, the new value in var1 is used as input to COUNTER.

Input for the RFC is listed under the <input> section. Valid parameter types for this section are <import>, <changing>, and <table>. Under each parameter type element, include a <parameter> element to specify input for the RFC. Each <parameter> element contains a name attribute which indicates the name of the RFC parameter that should be populated with the content of the <parameter> element.

This mode also supports structure parameters, which are a collection of fields and parameters packed in a particular order, and table parameters, which can contain multiple structure parameters. Structures can be nested. To reference nested or subfields of a structure or table, use a dot notation to build the full name of the parameter. For example, the parameter name IMPORTSTRUCT.I references the field “I” of a structure named “IMPORTSTRUCT”. Fields “I”, “C” and “STR” of the structure parameter “IMPORTSTRUCT” are set with values 54321, Z, and Test String.
<changing>
				<parameter name="IMPORTSTRUCT.I">54321</parameter>
				<parameter name="IMPORTSTRUCT.C">Z</parameter>
				<parameter name="IMPORTSTRUCT.STR">Test String</parameter>
				<parameter name=”COUNTER” valueType=”variable”>var1</parameter>
		</changing>

For table parameters, use the dot notation to reference up to the name of the table parameter itself, and set the attribute named valueType on the parameter to “table”. This indicates that that particular <parameter> entry represents a row of a table parameter, and all the child <parameter> elements are considered subfield values for that table entry. Multiple table entries can be defined for the same table parameter to provide more than one entry. In the example, two rows are set to the table parameter named “IMPORT_TAB”, with values of {99999, X, Test Table String 1} and {88888, Y, Test Table String 2}.

Under the <mapping> section, use the <fieldMapping> element specify the ESP stream column to which RFC output is published. Each <fieldMapping> entry represents a mapping of a parameter field to a stream column, with the name attribute indicating the RFC parameter name and the espField attribute the ESP stream column name respectively.

Similar to the <input> section, field mapping entries are grouped according to parameter type. The <mapping> section includes the <export>, <changing>, and <tables> parameter types. In the example above, the export RFC parameter RESPTEXT is mapping to Column1 in the ESP stream, and EXPORT_TAB subfield I and STR are maping to Column2 and Column3.

When a field of a table parameter is being mapped to an ESP field, multiple ESP rows can be returned as a result since the table parameter can contain multiple rows. The result is a product of all the rows in the table parameters. For example, an RFC returns the following output, with PARAM2 and PARAM3 being tables with two subfields each (PARAM21, PARAM22, PARAM31 and PARAM32):
PARAM1 PARAM2 PARAM3
1 {1, “string 1”} {10, “string 10”}
  {2, “string 2”} {20, “string 20”}
Both of the PARAM2 and PARAM3 tables contains two rows. If PARAM1, PARAM21, and PARAM32 map to a stream, the following four rows will be the result:
{1, 1, “string 10”}
{1, 1, “string 20”}
{1, 2, “string 10”}
{1, 2, “string 20”}

Output Adapter

Here is an example of a mapping entry for an RFC Output adapter running in generic RFC mode:
<rfc name="ESP_DEV_INSERT_TABLE">
	<variables>
		<variable name="var1">1</variable>
	</variables>
	<input>
		<import>
			<parameter name="PI_INT1" valueType="variable">var1</parameter>
			<parameter name=”PI_STR2”>Static Text</parameter>
		</import>
	</input>
	<mapping>
		<import>
			<fieldMapping name="PI_INT2" espField="Column2"/>
			<fieldMapping name="PI_STR2" espField="Column1"/>
		</import>
		<export>
			<fieldMapping name="PE_INT" saveToVariable="var1"/>
		</export>
	</mapping>
</rfc>

Define static data under the <input> element in the same way as the input for the RFC Input adapter. Valid parameter types are <import>, <changing>, and <table>.

Define dynamic data coming from an ESP stream under the <mapping> element using <fieldMapping> entries. The format of the <mapping> element is similar to the RFC Input adapter <mapping> element. The <fieldMapping> entries are grouped under the parameter types of <import>, <changing>, and <tables> as these are the parameter types from which an RFC obtains input values. The name attribute indicates the RFC parameter to which that the value should be set, and the espField attribute indicates which ESP column the data value is from.  

You can also save an output RFC parameter to a variable. In this case, the <fieldMapping> entry would have the name of the RFC parameter and the variable to which the value should be saved. In the example above, the adapter maps data from ESP column Column1 to RFC import parameter PI_STR2, and from ESP column Column2 to RFC import parameter PI_INT2. It saves off the output value from export parameter PE_INT to variable var1.