Introduction
The below blog provides an overview of setting up a simple CPI integration to post data to a SAP BW/4HANA on-premise instance. I have included an explanation of how to achieve this in both postman and SAP Cloud Integration. I have also included references to helpful blogs you can refer to for additional details.
Set up in BW
Create DSO in BW
Ensure ‘Write Interface Enabled’ attribute is set.
Add fields to DSO
Download URL’s shown on DSO
Get Structure
https://server:port/sap/bw4/v1/push/dataStores/da_maze
Get Sample Data
https://server:port/sap/bw4/v1/push/dataStores/da_maze/sampleData{?records,seed}
Send Data
https://server:port/sap/bw4/v1/push/dataStores/da_maze/dataSend{?request,datapid}
Open Request
https://server:port/sap/bw4/v1/push/dataStores/da_maze/requests
Close Request
https://server:port/sap/bw4/v1/push/dataStores/da_maze/requests/{request}/close{?error}
Using DSO in Postman
For Info can query DSO structure
Or see an example json payload
Post data in postman:
Step 1: Fetch CSRF token
Add header for x-csrf-token = fetch, set Authorization to basic Auth
Response header will contain the csrf token
Step 2: Send Data to BW
Add header x-csrf-token and set value returned by call in Step 1 (found in the response header)
Set body to message to post to BW (xml in this example)
Response back
Example JSON POST
Data Post example in CPI
The process below mirrors the process done previously in postman to post data to BW
Against the Integration flow set HTTP session
Start Timer – Schedule set to Run OnceSet Csrf token header
3. Make http call to get csrf token returned (note that in this example an on-premise BW is being called so virtual host/port have been set in cloud connector)
Make sure Headers are both passed to the call and returned
4. Handle Cookies – The initial csrf call returns an header called ‘set-cookie’, unfortunately the call to post the data requires an header called ‘cookie’. The groovy script converts the format and name. More details can be found in https://help.sap.com/docs/SUPPORT_CONTENT/sci/3361897820.html?locale=en-US
import com.sap.gateway.ip.core.customdev.util.Message;
def Message processData(Message message) {
def headers = message.getHeaders();
def cookies = headers.get(“set-cookie”);
message.setHeader(“cookie”, String.join(“; “, cookies));
return message;
}
5. Set content type and payload of data post
6. HTTP call to post data to BW
Referenced Blogs:
Integrating with BW
Example CPI to BW
Issues with x-csrf not working see below:
https://help.sap.com/docs/SUPPORT_CONTENT/sci/3361897820.html?locale=en-US
IntroductionThe below blog provides an overview of setting up a simple CPI integration to post data to a SAP BW/4HANA on-premise instance. I have included an explanation of how to achieve this in both postman and SAP Cloud Integration. I have also included references to helpful blogs you can refer to for additional details.Set up in BWCreate DSO in BWEnsure ‘Write Interface Enabled’ attribute is set.Add fields to DSO Download URL’s shown on DSOGet Structurehttps://server:port/sap/bw4/v1/push/dataStores/da_mazeGet Sample Datahttps://server:port/sap/bw4/v1/push/dataStores/da_maze/sampleData{?records,seed}Send Datahttps://server:port/sap/bw4/v1/push/dataStores/da_maze/dataSend{?request,datapid}Open Requesthttps://server:port/sap/bw4/v1/push/dataStores/da_maze/requestsClose Requesthttps://server:port/sap/bw4/v1/push/dataStores/da_maze/requests/{request}/close{?error} Using DSO in PostmanFor Info can query DSO structureOr see an example json payload Post data in postman:Step 1: Fetch CSRF tokenAdd header for x-csrf-token = fetch, set Authorization to basic AuthResponse header will contain the csrf tokenStep 2: Send Data to BWAdd header x-csrf-token and set value returned by call in Step 1 (found in the response header)Set body to message to post to BW (xml in this example)Response backExample JSON POST Data Post example in CPIThe process below mirrors the process done previously in postman to post data to BW Against the Integration flow set HTTP session Start Timer – Schedule set to Run OnceSet Csrf token header3. Make http call to get csrf token returned (note that in this example an on-premise BW is being called so virtual host/port have been set in cloud connector)Make sure Headers are both passed to the call and returned4. Handle Cookies – The initial csrf call returns an header called ‘set-cookie’, unfortunately the call to post the data requires an header called ‘cookie’. The groovy script converts the format and name. More details can be found in https://help.sap.com/docs/SUPPORT_CONTENT/sci/3361897820.html?locale=en-USimport com.sap.gateway.ip.core.customdev.util.Message;def Message processData(Message message) { def headers = message.getHeaders(); def cookies = headers.get(“set-cookie”); message.setHeader(“cookie”, String.join(“; “, cookies));return message;} 5. Set content type and payload of data post6. HTTP call to post data to BW Referenced Blogs:Integrating with BWFrom <https://community.sap.com/t5/technology-blog-posts-by-sap/sap-bw-4hana-write-interface-enabled-adso-connected-to-a-3rd-party-tool/ba-p/13482277>Example CPI to BWhttps://community.sap.com/t5/technology-blog-posts-by-sap/sap-cloud-platform-integration-cpi-to-push-data-into-sap-bw-4hana/ba-p/13418310Issues with x-csrf not working see below:https://community.sap.com/t5/technology-blog-posts-by-members/x-csrf-token-with-on-premises-sap-system-using-http-receiver-adapter/ba-p/13533518https://help.sap.com/docs/SUPPORT_CONTENT/sci/3361897820.html?locale=en-US Read More Technology Blog Posts by Members articles
#SAP
#SAPTechnologyblog