SAP CPI: Control your messages with custom header

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




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)”.

custom header sap cpi


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?


ABAP developer and SAP integration consultant, SAP SDN contributor

Leave a Reply

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


ul. Bednarska 1
60-571 Poznan, Poland



Write to us