Dynamic Reference Type in Message Mapping in SAP Cloud Integration

Estimated read time 6 min read

In SAP Cloud Integration, Message Mapping plays a crucial role. While most of us are familiar with configuring the “Static Reference Type” within Message Mapping, it’s important to note that there’s also a powerful feature called “Dynamic Reference Type” available. This functionality often goes unnoticed but can significantly enhance mapping flexibility.

Rather than hardcoding message mappings or configurations, you can dynamically assign them at runtime using headers, properties, or variables. This approach enhances the adaptability, efficiency, and reusability of your integration flows.

What is Dynamic Reference Type?
In SAP Cloud Platform Integration (CPI), the Dynamic Reference Type enables the runtime assignment and execution of different message mapping artifacts within a single integration flow. This feature is especially valuable when mapping logic needs to adapt to runtime conditions such as headers, properties, or partner-specific configurations.

This feature enables:

Dynamic Message Mapping Selection: Enable runtime selection of message mappings using expressions such as ref:<message_mapping_id> within headers or properties.Adaptive Integration Flows: Design flexible integration scenarios where different mappings are triggered based on runtime conditions or values.Partner-Specific Configuration Support: Utilize the partner directory to dynamically select mappings based on partner-specific settings using the format pd:<Partner ID>:<Parameter ID>.

Why it matters?

Eliminates Rigid Dependencies: Promotes loosely coupled designs for greater flexibility.Adapts Seamlessly to Business Contexts: Tailors integration flows to meet diverse operational needs.Enhances Reusability and Maintainability: Simplifies updates and encourages modular design.Drives Innovation: Speeds up the development of creative and efficient integration solutions.

In today’s fast-paced digital landscape, mastering this capability can significantly elevate CPI solutions and provide integration designs with a competitive edge.

We will delve into this topic by implementing a basic example to illustrate the concept.

Example: Dynamic Mapping Selection Based on Country Code

Scenario: Dynamically call a different mapping at runtime based on the CountryCode in
the source message, using the same source XSD format. 

Step 1: Create two Message Mapping artifacts

Mapping 1: For Country Code INMapping 2: For Country Code US

Mapping 1: For Country Code IN

Mapping 2: For Country Code US

Here, we will do the same one-to-one mapping for both the Message Mapping as shown:

Step 2: Create a main Integration Flow

Extract CountryCode from the source payload

Step 3: 

Evaluate which Message Mapping to be used based on the CountryCodeStore the selected mapping ID in Message Header or Exchange Propery (e.g., MapVar). The camel expression has been used for the Source Value. 

The expression I have used for this example is “ref:MM_${header.CountryCode}_CountryData”. I have called the CountryCode from the Message Header that is created in the previous Content Modifier.

Step 4: Invoke the Message Mapping dynamically at runtime by using the value stored in MapVar.

 

Test Cases:

Test Case 1: If the CountryCode = IN, the IFlow will call the IN mapping

Test Case 2: If the CountryCode = US, the IFlow will call the US mapping

We can use this capability if we want to reuse the same Integration Flow for multiple scenarios. This enables flexibility and modularity, especially in complex integrations where different partners or message types require different mappings.

Hope you find this article valuable and helpful.

 

​ In SAP Cloud Integration, Message Mapping plays a crucial role. While most of us are familiar with configuring the “Static Reference Type” within Message Mapping, it’s important to note that there’s also a powerful feature called “Dynamic Reference Type” available. This functionality often goes unnoticed but can significantly enhance mapping flexibility.Rather than hardcoding message mappings or configurations, you can dynamically assign them at runtime using headers, properties, or variables. This approach enhances the adaptability, efficiency, and reusability of your integration flows.What is Dynamic Reference Type?In SAP Cloud Platform Integration (CPI), the Dynamic Reference Type enables the runtime assignment and execution of different message mapping artifacts within a single integration flow. This feature is especially valuable when mapping logic needs to adapt to runtime conditions such as headers, properties, or partner-specific configurations.This feature enables:Dynamic Message Mapping Selection: Enable runtime selection of message mappings using expressions such as ref:<message_mapping_id> within headers or properties.Adaptive Integration Flows: Design flexible integration scenarios where different mappings are triggered based on runtime conditions or values.Partner-Specific Configuration Support: Utilize the partner directory to dynamically select mappings based on partner-specific settings using the format pd:<Partner ID>:<Parameter ID>.Why it matters?Eliminates Rigid Dependencies: Promotes loosely coupled designs for greater flexibility.Adapts Seamlessly to Business Contexts: Tailors integration flows to meet diverse operational needs.Enhances Reusability and Maintainability: Simplifies updates and encourages modular design.Drives Innovation: Speeds up the development of creative and efficient integration solutions.In today’s fast-paced digital landscape, mastering this capability can significantly elevate CPI solutions and provide integration designs with a competitive edge.We will delve into this topic by implementing a basic example to illustrate the concept.Example: Dynamic Mapping Selection Based on Country CodeScenario: Dynamically call a different mapping at runtime based on the CountryCode inthe source message, using the same source XSD format. Step 1: Create two Message Mapping artifactsMapping 1: For Country Code INMapping 2: For Country Code USMapping 1: For Country Code INMapping 2: For Country Code USHere, we will do the same one-to-one mapping for both the Message Mapping as shown:Step 2: Create a main Integration FlowExtract CountryCode from the source payloadStep 3: Evaluate which Message Mapping to be used based on the CountryCodeStore the selected mapping ID in Message Header or Exchange Propery (e.g., MapVar). The camel expression has been used for the Source Value. The expression I have used for this example is “ref:MM_${header.CountryCode}_CountryData”. I have called the CountryCode from the Message Header that is created in the previous Content Modifier.Step 4: Invoke the Message Mapping dynamically at runtime by using the value stored in MapVar. Test Cases:Test Case 1: If the CountryCode = IN, the IFlow will call the IN mappingTest Case 2: If the CountryCode = US, the IFlow will call the US mappingWe can use this capability if we want to reuse the same Integration Flow for multiple scenarios. This enables flexibility and modularity, especially in complex integrations where different partners or message types require different mappings.Hope you find this article valuable and helpful.   Read More Technology Blog Posts by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author