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.

SAP Versions used in the illustration:

  • SAP PO 7.5

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.

 

26 thoughts on “Parametarized Mapping Example in SAP PI/PO

  1. Swathi says:

    Hi I’m Swathi and I’m new to PI. Can anyone please explain the business cases to go for parameterized mapping

    • Isuru Fernando says:

      Hi Swathi,

      I used it in a previous project to split the target message based on incoming message segment count. Requirement was create multiple iDocs based on number of segments in the incoming message. For example one iDoc for every 100 line items of the incoming message. I wanted number of line items to be configurable. Therefore, if in future client wanted to change the number of line items to 200 or any other value they can do it easily without changing the mapping program. Also it can be used for RFC/JDBC lookup implementations.

      • Rahul says:

        Hi ,
        AM using file to idoc . In every idoc i have to pass only 999 lines . If i get more than 999 line times i have to create new idoc. Please for this requirement how i can achieve this using parameterized mapping. I achieved this with direct mapping logics but just to know how its working with parameterized mapping.

        Thanks in Advance !!!

        • Isuru Fernando says:

          Hi Rahul,

          In this instance you must have hard coded the number of line items as ‘999’ in the mapping program. Using a parametarized mapping, you can make the number of line items configurable. You can maintain number of line items as a single value in ICO and use it in the mapping program. If in future you need to change the number of line items you need to collect, you can easily change in using a configuration without changing the mapping program.

          Cheers!
          Isuru

      • Vinay says:

        Hi Isuru,

        What is the difference between Replacewith and Parameterized Mapping i mean the above said requirement of yours (1 to 10 Level_1 Att1 = 10) can we achieved with replace with, then why do you want us to go with complex Parameterzied Mapping? please advise.

        • Isuru Fernando says:

          Hello Viny,

          Parameterized mapping can be used to import values from configuration time. You can maintain the values in ID/iFLow and import them to the mapping program. Replacewith can only transform values in the source message in the mapping program.

          Cheers!

      • Vinay says:

        Hi Isuru,

        What is the difference between Replacewith and Parameterized Mapping i mean the above said requirement of yours (1 to 10 Level_1 Att1 = 10) can be achieved with replace with, then why do you want us to go with complex Parameterzied Mapping? please advise.

  2. Krishna says:

    Hi
    I am new to PI. I am just wondering if there is any way that we can use the export parameter on the receiver channel end. I mean for example NFS Adapter, can access export parameter so that i can use it in OS Command section

  3. Raghav says:

    HI ISURU,
    I am new for pi. Can you please provide an in-detail steps to configure B2B concept.

    Thanks in Advance.
    Raghav

    • Isuru Fernando says:

      Hello Yoppy,

      Do you want to send messages to different target systems based on certain values from the input message? Or do you want to do it based on a parameter? Please provide more detail on your scenario.

      Cheers!
      Isuru

      • Yoppy says:

        Actually I want to send messages to different target systems based on certain values.
        My senior teach me to use parameters, but not working. My senior has resigned.

      • Yoppy says:

        Actually I want to send messages to different target systems based on certain values, but my senior teach for using the parameters. But not working for now and my senior has resigned. I am new in PI.

  4. Yoppy says:

    Actually I want to send messages to different target systems based on certain values, but my senior teach for using the parameters. But not working for now and my senior has resigned. I am new in PI.

  5. Yoppy says:

    Actually I want to send messages to different target systems based on certain values, but my senior teach for using the parameters. But not working for now and my senior has resigned. I am new in PI..

  6. Ayushi says:

    Hi, Could you please provide me an example of export parameters in Parameterized mapping.How to use it and business scenario.

Leave a Reply

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