Thursday, 14 December 2017

SAP PI UDF is working in SAP HCI


Will the UDF created in SAP PI will work in SAP HCI as well? If this is your question, then answer is YES.
Let see how to import SAP PI mapping with UDF created in SAP PI to HCI.



Configure the Repository Connection in the SAP HCI on Preference, then Right click on your project and
Select Import, from that select ES Repository content- 
Click next select Message mapping and select your mapping from the list which you created in the SAP PI then ok.

Simple Iflow for demo in SAP HCI:


Now message mapping is imported with the UDF as below.



Note: there is a drawback which you can’t edit your UDF in HCI, again need to edit from SAP PI and then need to import it.




Tuesday, 12 December 2017

Access the HTTP URL in Content Modifier using CamelHttpUrl


We discuss about how to access the HTTP URL from the Sender HTTP channel.
IFLOW:



HTTP Channel Settings:



Enter the below details in the Content Modifier –Header:



When tested from POSTMAN/Restlet Client the URL provided will be displayed as below:


Configuration is done. After testing, view the payload before content modifier in HCI.






SAP API call (api.sap.com) from SAP HCI (SCPI):


I had tried out multiple sites/blog for the reference to develop this integration between SAP HCI and SAP provided API. But No Luck!!!
Then started to develop this iflow to translate the given text from one language to other language. There is pre packed API available in the SAP API portal. Just I am trying to access the API from HCI as translated output.
Here you can either pass the data in the file or content modifier. I will show you in the content modifier for input data passing to API.

IFLOW in SAP HCI:



Whenever the iflow is deployed Start Event triggered and content from the content modifier sends to SAP API for the translation.
Content Modifier:
In Header, the parameters need to pass as below:

Will let you know where to take this API key and the Content Type need to be provided as  application/json, else you will get an error.

  • If you are giving Content-Type as application/xml , will get error code : 415
  • If no input is given to this API and triggered the iflow, will get the error code: 411
  • If no API key is given to this API and triggered the iflow, will get the error code: 401

Content Modifier: Body input text:
Can specify the source and target language as shown below for translation.
{
  "sourceLanguage": "en",
  "targetLanguages": [
    "de"
  ],
  "units": [
    {
      "value": "I would like to analyze my sales data."
    }
  ]
}
HTTP Channel with Request Reply:

As the API call is synchronous, so used Request Reply step for send and get a response immediately.

HTTP Channel Configuration:
This HTTP channel parameter required the API Request Address where it took from SAP API portal.
Method: POST
Authentication: None


Receiver can be anything you required. This ends the configuration in SAP HCI. Next can look in the SAP API Sandbox portal which is free for usage.

URL for accessing the Portal:  https://api.sap.com


There are several API developed and placed in the Portal as below: Will look into SAP Leandro Machine Learning-Functional Services for Translation.



Click on Artifacts – Click on Translation API

Select Expand Operations as highlighted below:

We have a provision to test the API in the portal itself as shown.
Click on Click to set the parameter value this gives the input  in the body column then you can click on Try it button. Response of the API appears below.

Below mentioned Request URL will be given as the HCI HTTP channel address:
Response also appeared below.


Right corner of the screen we have the API Key, this is used in the Content modifier as shown below in screenshot:


Same input is gives as shown above and received the response in HCI output:



Hence this end. Happy Learning!!!