Parametarized Mapping Example in SAP PI/PO

Parameterized mapping is a great way to leverage your mapping program to have multiple applications. SAP introduced this technique first in SAP PI version 7.1. Parameterized mapping allows you to transfer values to mapping program or values from the mapping program. Similar to how we use import and export parameters in a function, parameters can be added to SAP PI/PO mapping programs using parameterized mapping technique.

Parameterized mappings are supported in Graphical Message Mappings, Java Mappings and XSLT Mappings.

 

Types of Parameters in Parameterized Mapping:

  • Import: Values can be passed to mapping program using import parameters before the mapping program is executed. Values for import parameters can be assigned from transformation steps or interface determination.

 

  • Export: Export parameters allow us to transfer values from the mapping program after it has been executed by the integration pipeline process or by monitoring. You can only assign values to Export parameters using User Defined Functions (UDF).

 

Categories of Parameters in Parameterized Mapping:

  • Simple Type: Simple types can be used as either import or export parameters. Data types of parameters of Simple Type are xsd:string and xsd:integer.

 

  • Adapter: Parameter category “Adapter” can be only used as an Import parameter. Adapter parameters are mainly used when you are implementing a mapping lookup. For example, in a JDBC look up scenario you can set the JDBC communication channel name which is used for JDBC look up function in the interface determination.

 

parameterized-mapping-element-hierarchy
Parameterized mapping element hierarchy

 

Step by Step Guide on Parameterized Mapping Configuration:

 

Example Scenario:

Lets create a simple file to file scenario with two parameters. We will use the import parameter “Parameter_1” to assign a value to output data structure field “Att1“. Value for import parameter “Parameter_1” will be maintained in the Integration Configuration Object (ICO) at design time of Integration Directory.

parameterized-mapping-output
Output data structure

 

Step 1 – Create Parameters in Mapping Program.

Go to Signature tab of the mapping program and create parameters.

Go to Message Mapping signature in ESR
Go to Message Mapping signature

 

Click Message Mapping parameters under Definition tab
Click Message Mapping parameters under Definition tab

 

Here I have created two parameters but we will only be using import parameter “Parameter_1“.

Create import export parameters. Simple type import parameter 'Parameter_1' and Simple Type export parameter 'Parameter_2'
Create import export parameters using ‘Add’ button

 

Step 2 – Map the Import Parameter to Required Output Field.

Graphical mapping element constant can be used to assign import parameter to required output element. Select properties of constant mapping element to select the parameter name from the drop down menu.

Select parameter name from the 'Constant' element settings drop down list. Mapping Import Parameter 'Parameter_1', select parameter name from drop down of content element
Select parameter name from the ‘Constant’ element settings drop down list.

 

Map import parameter "<em>Parameter_1</em>" to "<em>Att1"</em> field of receiver
Map import parameter “Parameter_1” to “Att1″ field of receiver

 

Step 3 – Create Parameters in Operation Mapping.

Since massage mapping is executed by PI/PO runtime through a corresponding Operation Mapping, we need to create parameters in Operation Mapping and bind them or map them to message mapping parameters.

Create Operation Mapping Parameters:

Select Parameters in Operation Mapping definition tab ESR
Select Parameters in Operation Mapping definition tab

 

Again, we will be creating two parameters, but we’ll only use “Import_p1” import parameter for this example.

Create 'Import_p1' Simple Type Import parameter and 'Export_p1' Simple Type xsd:string export parameter
Create ‘Import_p1’ Simple Type Import parameter and ‘Export_p1’ Simple Type xsd:string export parameter

 

Step 4 – Bind Operation Mapping Parameters with Message Mapping Parameters.

 

Select binding and map Operation Mapping parameters with Message Mapping Parameters.

Select binding from Operation Mapping
Select binding from Operation Mapping

 

Map Message Mapping parameters with Operation Mapping  parameters.

Bind Message Mapping parameters with Operation Mapping Parameters
Bind Message Mapping parameters with Operation Mapping parameters

 

Step 5 – Set Value to Import Parameter at Design Time.

Go to Integration Directory and assign a value to import parameter in Integration Configuration Object (ICO) or Receiver Determination (in dual stack).

Set parameter value in Integration Configuration Object (ICO) at Design time
Set parameter value in Integration Configuration Object (ICO) at Design time

In newer Single stack version of PI or PO, parameters can be accessed under the Receiver Interfaces tab of Integration Configuration Object (ICO).

Let’s assign constant value “10” to import parameter “Import_p1” which is mapped to Message Mapping parameter “Parameter_1”.

 

Test Result:

Test message.

Test Integration Scenario using Send Test Message tool in PI/PO monitoring
Test Integration Scenario

Value “10” maintained in the ICO for Import parameter ‘Import_p1‘ is assigned to attribute “Att1”.

Parameterized Mapping output. Value of Import parameter 'Parameter_1' assigned to output data structure element <em>Att1</em>.
Parameterized Mapping output. Value of Import parameter ‘Parameter_1’ assigned to output data structure element Att1.

 

If you have any questions about Parameterized Message technique or need clarifications on any of the steps, please leave a comment below.

 

8 Comments

Add a Comment

Your email address will not be published. Required fields are marked *