Dynamic HTTP or Odata Adapter –ntication for Flow Processing in
Dynamic HTTP or Odata Adapter –ntication for Flow Processing in
In this blog, I aim to simplify the use of dynamic resources/querying in Odata or HTTP.
You need to perform a GET request in Odata on the S4hana Public Cloud, S4hana
Private Cloud, or S4hana On-Premise, and you want to use the query options in a very
dynamic and simple way.
Examples of queries:
https://myXXXXXX-api.s4hana.cloud.sap/sap/opu/odata/sap/
API_BUSINESS_PARTNER/A_BusinessPartner('17300002')
https://myXXXXXX-api.s4hana.cloud.sap/sap/opu/odata/sap/
API_BUSINESS_PARTNER/A_BusinessPartner?
$filter=BusinessPartnerGrouping eq 'BP03'
Many times, we want to call SAP Cloud Integration - CPI from a SAP or non-SAP
system, passing these parameters. How can we make CPI accept this without giving an
HTTP 404 error?
This is what I will teach you step-by-step in this blog, using the Odata
Adapter and HTTP Adapter.
The first thing we will do is put an asterisk '*' in the Address field of our HTTP adapter.
Example: /testURL*
With this in the CPI monitor, we will have a URL like the one below:
https://9265fbe0trial.it-cpitrial05-rt.cfapps.us10-
001.hana.ondemand.com/http/testURL*
Step 2º:
Step 3º:
Inside the local Integration Process, we will create a router. In this Router, we will check
a standard CPI Header. If CPI is called with the URL below, it fills the CamelHttpPath.
https://myXXXXXX-api.s4hana.cloud.sap/sap/opu/odata/sap/
API_BUSINESS_PARTNER/A_BusinessPartner('17300002')
In this case, we are searching for a record by its key field. So we will use the READ
route.
Step 5º:
If you don't have an S4hana environment to use, you can use the Sandbox from SAP
Business Accelerator Hub.
If you have doubts about using the SAP Business Accelerator Hub, here are links to
explanatory videos:
In the Address field, you either put the address of your S4hana environment or the SAP
Sandbox.
https://myXXXXXX-api.s4hana.cloud.sap/sap/opu/odata/sap/
API_BUSINESS_PARTNER
https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/
API_BUSINESS_PARTNER/A_BusinessPartner
You should create your credentials in CPI, whether they are Basic, Oauth2, or even API
Key (the latter should be passed in the header as Authorization).
In the Processing tab, select Operation Detail as READ(GET).
In the Resource Path, add the entity plus the header that contains the key field data.
Example: A_BusinessPartner${header.CamelHttpPath}
Step 7º:
Now we will practically repeat the step to create another Request Reply and odata
adapter.
The only additional point is that we will add a Groovy script to check if
the CamelHttpQuery header is empty. If it is empty, we will create a property
called isEmptyHeader and set it to ‘true’; otherwise, it will be ‘false’.
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
message.setProperty("isHeaderEmpty", isEmptyHeader)
return message;
}
the Router we check this property.
If it follows the empty route, then we will create this header with a blank value using the
content modifier.
This header is filled automatically when we send a URL like the one below, which is
done when we pass a FILTER in the URL.
https://myXXXXXX-api.s4hana.cloud.sap/sap/opu/odata/sap/
API_BUSINESS_PARTNER/A_BusinessPartner?$filt... eq 'BP03'
The oData part is now done. Now let’s see how it works with HTTP.
Step 8º:
Now we will create the Local Integration Process to use with the HTTP adapter.
In this Content Modifier, the CamelHttpPath header is being deleted. This step is
mandatory; if not done, it will cause an error in the HTTP call. I recommend you test
without deleting it to understand why we remove it.
Step 9º:
Now we will add a Request Reply and use the HTTP adapter.
In the HTTP adapter, we will configure it as follows. It will be the address of your
S4hana endpoint or Sandbox, as we saw earlier, plus the property we created in the
Content Modifier.
https://myXXXXXX-api.s4hana.cloud.sap/sap/opu/odata/sap/
API_BUSINESS_PARTNER/A_BusinessPartner${prop...
Add the credentials to access the environment. If using an API Key, add
the Authorization header.
Our development is now complete.
Test 1º:
We will call the Odata adapter without passing any parameters or filters. In this case, we
want the Odata to return all the records in the database.
Test 2º:
Calling by passing the key field in the URL. In this case, it will follow the READ route.
Test 3º:
In this test, we are testing the HTTP adapter without sending any filter or key. We
expect the return to be all BP records from S4hana.
Test 5º:
In this test, we will test the HTTP adapter by passing a Key in the URL to return only
one record. The adapter should perform a "READ".
Important: In this test, the CamelHttpPath header is filled, which is why we delete
it in the Content Modifier. The HTTP adapter uses it automatically if it exists. Test
to form your own conclusions!
Test 6º:
YouTube Channel:
https://www.youtube.com/@NeylonSAP
Instagram:
https://www.instagram.com/neylonsap/
Linkedin:
https://www.linkedin.com/in/neylonsap/
https://www.linkedin.com/company/neylon-silva-cpi/?viewAsMember=true