SAP CPI: Control your messages with custom header
Introduction
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).
Steps
So you would like to pass a custom header to CPI.
SoapUI
In SoapUI you would pass it on like this:
ABAP
In ABAP it is possible thanks to the best library cl_http_client:
lo_httpclient->request->set_header_field(
name = ‘CustomHeader‘
value = ‘100‘ ).
SAP CPI
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 fill “Allowed Header(s)”.
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.
Summary
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?
Popular tags
ABAP int4 INT4 IFTT Int4Interview S/4HANA SAP AIF SAP CPI sap integration