BTP Integration – Process email Attachment to Post Deep insert using odata on Premise ECC

There are different integration scenarios  where we would like send to an email with attachment of contents (XML or json) which can be read and sent to ECC to post a transaction identified by the integration.   To achieve this we have to perform the following Steps

  1. Configure ECC and cloud connector for http
  2. check connectivity for IMAP download and import the certificates into Integration Suite key Store
  3. Create the BTP Integration iflow to process inbound email to read the attachment and invoke the configured odata service and send result email or exception process email
  4. Test the end to end process

We describe in detail each of these in derail

  1.  Configure cloud connector for the on Premise ECC system as shown below ( cloud to on Premise or your subaccount )      Make sure the connection works
  2. Check  in Integration suite Operations View Connectivity test for IMAP for the email provider as shown below –  I have created a folder CPI in my yahoo account to which I will move the emails with attachments of XML odata to create deep insert for Sales Order      Download the Certificates and import all the certificate files into the key store in the Operations View.
  3. Create the iflow which will read the inbound email with attachment – Using the groovy script read the attachment and transfer to message body (XM).  The odata service have chosen for this blog is http://s4h2:80001/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/SalesOrderSet.  This involves a deep insert consisting of Sales Order header and items.  The Iflow consists of main process and exception sub process the result sent to email as shown below We will show the settings for each of the components below                                                        3A) inbound email settings  3B) Odata Adapter Settings as as shown below  3c) Main odata POST process response outbound email configuration is as shown below  3D) include an Exception sub process – Add a content Modifier  with body showing the exception message and connect the email to email.  For this integration I have copied the same the same email settings and changed the title to indicate exception.  The Content Modifier settings are as shown    Groovy%20Script%20CodeSave and deploy the iflow                                                                                                             4) Test the filow                                                                                                                              4A) Once the iflow is deployed we need to test end to end for successful post to validate the main process;  To do this first we have to create XML data so that the format matches the metadata for SalesOrderSet of the odata service..  This is as shown bleow

<Note>EPM DG: SO ID SAP CPI Blog Test</Note>
<Note>EPM DG: SO ID 0500000000 Item 0000000010</Note>

Save a file with the above consents and send this file as an attachment to the email address configured in the inbound email settings in the iflow.  Once the email is received in your inbox move it to the CPI folder ( or the folder you have configured in the inbound email processing settings).  Recollect that we have set the scheduler to poll the folder every minute – the file will be picked up and contents transferred to the body of the message which is then passed to odata payload to make a deep insert to post sales order.  The Status and response is sent to by emaill configured in the outbound email The response email is as shown below 4B) Exception sub process email  To test this we change url port to 8001 and redeploy and repeat the process of sending the email attachment and copy to the CPI folder that we configured in the inbound email processing We now get an exception email as shown below

We have seen how we can process inbound email attachment – transfer the attachment contents to message body and send this to odata adapter to invoke on Premise ECC odata service to perform deep insert and then send the response or exception to the configured email address in the outbound email configuration.