Skip to Content
Technical Articles
Author's profile photo Rashmi Joshi

SAP S4H (IDOC) to SAP CPI – Inbound IDoc Interface

Hi SAPiens,

Below blog explains the steps required to establish the communication between SAP CPI and  on-prem S4Hana. This is for inbound IDoc interface and for demo purpose I am using mail as receiver.

Topics will be covered –>

  1. System Connection between S4H and CPI
  2. Background Configurations required
  3. Configure Idoc Sender Adapter
  4. Search messages in message monitoring based on Idoc Number

To be able to send messages from SAP S4Hana to SAP CPI import CPI certificates in S4Hana STRUST. You can download CPI certificates either from keystore or from any browser.

  1. Login to S4hana system –> Tcode STRUST (Import all 3 CPI certificates) –> Add to Certificate List
  2. Create Logical System for S4H and CPI system in Tcode BD54
  3. Create RFC Destination of Type G –>Host = CPI Tenant, Port = 443, Path Prefix = from Sender Adapter (CPI – IFlow); Logon & Security
  4. RFC Connection test returns HTTP 500 response
  5. Create Port WE21 –> Port Type –> XML HTTP
  6. Partner Profile WE20 –>
    1. Import Outbound Message type with port created in earlier step
  7. In the Custom IFlow, give the same path prefix as given in RFC Destination IDoc Adapter Configuration –>
  8. In-order to be able to search my Iflow in monitoring based on Idoc number, I have configure Content Modifier with Header Values I am using Headers –> SapIDocDbId, SapIDocTransferId, SapIDocType in my mail body and created SAP_ApplicationID to pass Idoc Number from payload which will help me to monitor messaged based on Idoc Number. Value for SAP_ApplicationID is Xpath of my Idoc DOCNUM
  9. Configure Mail adapter and deploy IFlow
  10. Trigger IDoc in S4Hana, WE02 –>
    1. Status = 03 –> Idoc Triggered to CPI
    2. Status = 02 –> Check Iflow status in CPI
  11. CPI –> Message Monitoring
  12. Mail Received Successfully

Thank you,

Rashmi

 

 

 

 

Assigned Tags

      15 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Shrihas Ekbote
      Shrihas Ekbote

      Gud one Rashmi...keep it up...keep sharing such informative docs...

      Author's profile photo Parimal Sarage
      Parimal Sarage

      Very Nicely explained with every single detail ?.

      It will really helpful for the initial phase for a developer ?.

      Thanks for Sharing.

      Author's profile photo Souvik Sinha
      Souvik Sinha

      Helpful blog.

      Thanks for sharing.

      Author's profile photo Keshav Desai
      Keshav Desai

      Good write up Rashmi.

      This however means, for each IDOC type thats flows from S4H to CPI, a separate Type G connection will have to be created [/cxf/matmas or /cxf/debmas....] in SM59. Thats a lot of SM59 connections.

      One could possibly mitigate this by having a generic routing iFlow [/cxf/idoc and thereby having only 1 SM59 connection for IDOCs to this CPI iFlow] and then making process direct calls to individual iFlows processing different IDOC types, depending on field values in the control segment.

      It would be ideal though, if SAP could build something on S4H, which would allow specifying a generic path prefix [/cxf/idoc/<idoctype>] in SM59 connection [so that there is one connection, like in tRFC port for IDOCs between ECC and PO ] and dynamically route the calls [?] to the iFlow endpoints  [ /matmas or /debmas... maintained in Connection of respective iFlows] from S4H.

      Do share your thoughts on this or if there is an alternative way already.

      Thanks.

      Keshav Desai

      Author's profile photo Rashmi Joshi
      Rashmi Joshi
      Blog Post Author

      Hi Keshav,

       

      Yes your understanding is correct. However, you can make a generic RFC destination capture idocs in CPI and then using process direct can push to the next steps.

       

      BR,

      Rashmi

      Author's profile photo Roberto Cantero
      Roberto Cantero

      Hi Rashmi, good article but nothing new from https://blogs.sap.com/2016/08/11/hcihcp-isidoc-adapter-deciphered-part-4-trigger-idoc-from-hci-to-sap-erp-using-basic-authentication/

      At least you can added like reference in your post.

       

       

      Author's profile photo Prakash Jha
      Prakash Jha

      Nicely explained Rashmi. Easy to understand with all required explanation

      Author's profile photo Bharath Sai R
      Bharath Sai R

      Adding this for other's reference.

      In case anyone faces an error of 'Server certificate does not match supplied TargetHostname', 'SSSLERR_SERVER_CERT_MISMATCH' while following this blog, please follow the steps in below blog to fix it.

      https://answers.sap.com/questions/13020758/backend-ecc-connection-to-cpi.html

      Author's profile photo Sushant Shinde
      Sushant Shinde

      Hi Rashmi,

       

      What credentials are getting used in Basic authentication in G type RFC?.

      BR,

      Sushant

      Author's profile photo Rashmi Joshi
      Rashmi Joshi
      Blog Post Author

      Hi Sushant Shinde

      Its CPI credentials.

       

      Regards,

      Rashmi

      Author's profile photo Saurabh Kumbhare
      Saurabh Kumbhare

      Hi Rashmi,

       

      Which CPI credentials are used? From security material or service key (I.e. Clientid and clientsecret)?

       

      Thanks

      Saurabh

      Author's profile photo Nagesh Popalayat
      Nagesh Popalayat

      Awesome Blog.

      Thanks

      Author's profile photo satish b
      satish b

      Hello Rashmi,

       

      Apart form from the content modifier in Iflow, I have followed your steps mentioned above and configured the scenario but getting error as staus 02 in we02.

       

      However, my iflow has deployed successful.

      Regards,

      Satish

      Author's profile photo Ramana Kola
      Ramana Kola

      Hi Rashmi,

      If I maintain my user in the destinations and they will fail when I left my company.

      I have a small question, do we have a specific user for connecting CPI from S4Hana/ ECC which can be used in Destination?

       

       

      Author's profile photo Saurabh Kumbhare
      Saurabh Kumbhare

      Going forward for Cloud Foundry, we should use Certificate based authentication only.Client ID and Client Secret based authentication is not recommended (Except for testing from Postman purposes ).

       

      Unfortunately, Rashmi has not provided what certificates does CPI need to have. I will be writing a more detailed blog if people require.

       

      Thanks

      Saurabh