Blog > SAP CPI: Control your messages with custom header

SAP CPI: Control your messages with custom header

Andrzej Halicki SAP Integration Consultant
icon__calendar 2019-08-12


Recently I encountered a basic router scenario. However the information I could use as a condition was not included in the message itself. I had to pass it to CPI, but didn’t want to enrich the message and mess it up. I figured out that custom header would be the great solution, however as it occurred, it wasn’t so easy (now it is of course).


So you would like to pass a custom header to CPI.


In SoapUI you would pass it on like this:

SAP CPI custom header SoapUISoapUI SAP CPI



In ABAP it is possible thanks to the best library cl_http_client:

        name  CustomHeader
        value 100 ).


This is the most important step – you need to enable custom headers so CPI can accept them. Just go to your iFlow, click on the white space behind the flow and you will be displayed a “Integration Flow” menu. Go to “Runtime Configuration” and fillAllowed Header(s)”.

SAP cpi integration flow


You could also type *. In this case CPI would accept all incoming headers.

Read your header

Now your custom header will be visible in CPI. In order to read the value use the expression

${header.CustomHeader}. Of course you could get access to any header using such expression. In my case I would use it in router step.


SAP CPI read header


I think it is a smarter and safer way to control your message flow. Instead of messing with payload you “hide” your controls in different part of message exchange. What do you think?


Andrzej Halicki SAP Integration Consultant
Andrzej Halicki is an SAP integration consultant and developer. He has strong experience in ABAP development across local and international projects. Andrzej works with the latest solutions like ABAP for HANA and Cloud Platform Integration. Author of many technical articles that are available online in the SAP Community and Int4 website.