Do you like this blog? Give us a like on Facebook X

XI/PI: Value Mapping Using Graphical Editor

This article explains how to implement value mappings in SAP XI using the graphical mapping editor by means of a simple example.

This article explains the concept of value mappings in SAP XI using a simple example. SAP XI supports two options of value mapping within the Graphical Mapping Editor – FixValues and Value Mapping.

FixValues Function

FixValues Properties

In the FixValues function (Conversions -> FixValues), key-value pairs are maintained within the Integration Repository. Simply, double-click to define the key-value pairs to map source keys to target values as shown.

In the Value Mapping function (Conversions -> Value mapping), you can maintain multiple key value pairs externally e.g. you could maintain them in the Integration Directory. These are picked up at the runtime.

Now, let us understand how to implement Value Mapping. Maintain a value mapping table in your Integration Directory. To do this, open your ID and go to Tools -> Value Mapping in the menu path. Display Value Mapping dialog will open up. Specify Agency and Scheme for source and target. These can be any arbitrary string values. Generally, Party or Business system/service names are preferred for agency while namespaces with some text identifier is preferred for scheme. See the image below.

Open Value Mapping in ID

Click on the Display button. Value mapping table will be displayed. Click on Change button to edit the value mapping table. Specify the source and target values. You can as well specify a Group Name for each value pair.

Define Value Mapping in ID

Groups can be useful if you are maintaining values for more than two systems. For example, the figure above shows a sample value mapping table. A customer 5000006001 in system BS_ER1 refers to customer AF001 in system BS_CR1 and also refers to customer T6001 in system BS_TR1 (not shown in figure). Thus these three values would have a common Group Name say CG1. Group names again are arbitrary string values. Save and activate your change list.

Now, go to Integration Repository and open the mapping program where you wish to use the above created value mapping. Use the standard function Conversions -> Value mapping to map the desired field from source to target.

Value Mapping function in IR

Double click to define function properties. A sample is shown below.

Value Mapping function properties in IR

Since we have maintained value mapping in Integration Directory, under Value Mapping Context specify http://sap.com/xi/XI. Under Agency and Scheme, specify the Agency and Scheme values used in the Integration Directory. If you have used party or Business system/service names as Agency in ID, you can simply choose SenderParty or SenderService for sender and ReceiverParty or ReceiverService for receiver. The dropdown box already has these values to choose from. These values get replaced with actual Party/Business system/service names at runtime.

Value Mapping test

When you locally test the mapping in the IR, you will not be able to see the actual result since values are picked from ID at runtime. Only when you execute the scenario, you will see the transformed values. The image above shows source and target XML that has been transformed via Value Mapping.

Comments

  1. Navneet says:

    Hi Riyaz,

    Thank you so much for your efforts, this blog is really helping us a lot. I have learned many things from your blog.
    Please keep up the good work.

    Thank You.

  2. Abdul says:

    One of the best blogs on SAP PI.
    Thanks alot Riyaz.

  3. thirupathi says:

    Hi Riyaz,
    I want nodefunctions pls write articles on nodefunctions clearly.
    Thanks,
    thirupathi

  4. hari says:

    Hi Riyaz,

    I have learned somuch to your blogs.
    Thanks Riyaz

    Regards
    Hari

  1. Shoukat Ali says:

    Hi Riyaz,

    Really you are helping us a lot.

    Great job..
    Thanks
    Shoukat

  2. Anandh says:

    Hi Vincent,

    As explained in Riyaz’s blog, you can also use Groups that will allow you to enter duplicate entries in IR. If you have two KG to be maintained, define a group and use that value mapping at runtime.

    Regards
    Anandh.B

  3. Riyaz says:

    Hi Vincent,

    Since Value Mappings can work both ways (source agency to target agency and and target to source in different scenarios), they are not truly key value pairs. In fact they are value-value pairs. So you cannot have duplicate entries in value mapping.

    To be able to use duplicate entries, you can either go for FixValues function in IR (as explained in the beginning of this article) or write a User defined function in IR to resolve this.

    Hope this helps.

    Regards,
    Riyaz

  4. Vincent says:

    Hello,

    I have a question about Value Mapping and this is one issue that is bothering me. I need to create a value mapping for Unit of Measurement. Assume I have to make these entries below in the lookup table:

    Key – Value
    ————————-
    AB – KG
    CA – KG
    LS – LS

    Now here, when I try to enter the first two entries for AB and CA, I get an error saying that “KG is already mapped to AB. Do you want to remove that and map KG to CA?”

    I need this kind of entry also for multiple SAP Partner IDs that are mapped to a single GLN (Global Location Number).

    Your help is appretiated.

    Thank you