Hi guys, in this article we will explore one more adapter in CPI – Kafka adapter. Particular, we will explore how to send file to Kafka and receive file from Kafka. Yes, It’s same SFTP.
Step 1 Build Kafka service
First, we need build server which install service Kafka. Fortunately, we have one service free trial 30 days on cloud. Kindly go to here to create Kafka service on Cloud.
After created Kafka on cloud, we will have Kafka as below
Download 3 files
- Access key -> Service.key
- Access Certificate -> Service.cert
- CA Certificate -> ca.pem
Step 2 Create key store (file P12)
By using OpenSSL tool, run command line to create key store (P12 file)
pkcs12 -export -name server-cert -in service.cert -inkey service.key -out dev-cpi-server-key-store.p12
Enter password. This password will use in another step.
After done, we will have file in the same folder of service.cert, ca.pem and service.key
Step 3 Create Key Pair in SAP CPI
In this step we will use key store which created in Step 2 and add it into SAP CPI.
Monitor – Keystore
Add – KeyPair
- (1) : File P12 which created in step 2
- (2) : Password in step 2.
Step 4 Down load Server Certificate of Kafka and import into CPI
Next, we will connect to Kafka host with key pair in step 3 to download Kafka certificate and after that import this certificate into CPI
Go to Kafka cloud service and copy host
Go to CPI – Monitor – Connectivity Tests
Use keypair in step 3 with host and port kafka to test connection to kafka service and download server certificate
Import certificate into key store SAP CPI
Monitor – Key Store – Add Certificate
We have to import 2 certificates of server into SAP CPI
Step 5 Test connection Kafka in SAP CPI
Monitor – Connectivity Tests – Kafka
As we see, connection is ok. Go to here we finished connection from SAP CPI to Kafka.
Next, we will create 2 scenarios which will be work with Kafka.
In Kafka, files will have 2 formats:
Binary : we have to convert payload to base64 and after that save it into Kafka with Binary
JSON : We have to convert payload to JSON and after that save it into Kafka with JSON
So, in CPI we also do that by using components to convert base64 or convert JSON from XML format
Kafka Receiver: Send file from S4 to Kafka (Outbound)
Data send from S4/HANA and Save into Kafka with JSON Format
Send Data from S4. Check in WE02
Copy IDOC number: xxxxx35 search in SAP CPI
Check in topic Kafka
Data send from S4/HANA and Save into Kafka with Binary Format
With this format, we will use component Base64 Encode to convert payload XML of S4/HANA to Base64 binary
This scenario, you can try by yourself.
Kafka Sender : Collect data from Kafka to S4 IDOC (Inbound IDOC)
Data in Kafka is XML to Binary
With this format, 3rd system will create payload with Format XML, after that convert XML payload to Base64 and send to Kafka
CPI will collect data in Kafka with Kafka sender adapter and send it to S4/HANA by IDOC Receiver adapter.
Convert to base64 and save to Kafka
Integration Flow with sender is Kafka and Receiver is IDOC
Check log in SAP CPI with Payload
Check on S4/HANA
Data in Kafka is JSON
All step is the same above. You can try by yourself.
After collect data from KAFKA send to S4/HANA, message in Kafka will not deleted, but It will marked with anything and will not send to S4/HANA many times.
This article is talking about integration of SAP CPI and Kafka. Normally, we often using SFTP to handle file up/down S4 through PI/PO/CPI. But today, I want to share one more another way to handle file. It is Kafka, because Kafka is one of adapters which SAP CPI included. Thanks for your reading and any advise, kindly leave your comment on this.