Blog Post

How to access Header and Properties in Message Mapping in SAP CI?

August 4, 2023

Access Headers and Properties

This is the recommended way to access headers and properties in message mapping. You need to create a Groovy script that contains two functions: get Header() and get Property(). These functions take the header name or property name as input and return the value of the header or property.

Once you have created the script, you need to assign it to the mapping expression in the message mapping. You can do this by clicking on the Functions tab in the message mapping and then selecting the Add button. In the Add Function dialog, select the Custom Function option and then select the script that you created.

Implementation

We will create the iflow in which we will access the headers and properties.

  1. Open the Integration Flow in the edit mode.
  2. Add the headers and Properties in the Content Modifiers. In our case We have added the Exchange Property (Document_Number) which we are getting the source value form the Global Variable.
  1. I have connected the Receiver with Request-Reply using HTTP to fetch some data, In our case this not main objective. We will primarily focusing on Access the exchange Property in Message mapping.
  2. Add the Message Mapping step and add the source and the Target XSD.
  3. This is very basic example, Suppose at the target side there is a node called Document Number but instead of mapping it with source you want to write the value to this node that you have stored in the exchange property.

  1. In such cases, The Custom Functions played a crucial role. To open the Mapping Expression assign Constant to the Document Number.
  1. In the Functions list, Click on the Create.
  1. Provide the name of the Script.
  2. Paste the following script and CLick Ok.

"def String getProperty(String propertyName, MappingContext context) {
   def propertyValue = context.getProperty(propertyName);
   return propertyValue;
}"

  1. Provide the Name of the Property to the Constant and Map it with the Target Node.
  1. Save and Deploy the Integration Flow you Target node will have the value of your Exchange Property.
LinkedIn 
Forbes Technology Council, Official Member (2022)
LinkedIn
Forbes Technology Council, Official Member (2022)

About the Author

Jaspreet is an Executive Consultant with expertise in SAP, SaaS/Cloud Integrations, Cyber Security and Data Science. Jaspreet is hands-On Architect who does Pre-Sales, Solution Architecture, Development, Lead Delivery of Complex Integration programs, Manage disperse teams and Ensure successful Project Go-Live/Goals. He has made a lasting impact on global businesses IT projects including Aflac, Advanced Energy, Donnelley Financial Solutions(DFIN), Dell EMC and many more.

Do you want to
learn more about integration?

We are dedicated to make our knowledge accessible. You can either figure it out by yourself or you can let us give you a hand.

Let us take care of your integration.

We are SAP Certified and we can make your project happen. Explore our services and contact us. We will be happy to take on your project.

View Our Services