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!!!






Monday, 23 October 2017

Easy way to create the bulk records of value mapping in SAP HCI/HCP

As I faced the issue when creating the value mapping in the WEBUI, created manually some of them. Then I had a 300 value mapping, so manually creating all takes huge time. So we can achieve this by adding that in the value_mapping.xml file as per below structure.

<vm>
    <group id="1">
        <entry>
            <agency>ORACLEID</agency>
            <schema>Nationality</schema>
            <value>101</value>
        </entry>
        <entry>
            <agency>C4CID</agency>
            <schema>Nationality</schema>
            <value>AF</value>
        </entry>
    </group>
    <group id="2">
        <entry>
            <agency>ORACLEID</agency>
            <schema>Nationality</schema>
            <value>172</value>
        </entry>
        <entry>
            <agency>C4CID</agency>
            <schema>Nationality</schema>
            <value>AX</value>
        </entry>
For placing the 300 entries in the above structure, I have created one more Iflow which will give the table to this above xml stucture.


IMG 0006

Then copy all the output file and remove the entry1 as entry and append this in the earlier value mapping file which is deployed. Then again deploy it.




Save the payload in the SAP HCI/HCP WEBUI using Groovy script

For the future reference, we have a script to save the payload in the iflow and that can be viewed in the Tenant WEBUI/Eclipse of SAP HCI/HCP.

In WEB UI monitoring - Logs - MPL Attachment - Click on "C4CRequestPayload" to view the payload for this example.

Groovy Script:

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
    def body = message.getBody(java.lang.String) as String;
    def messageLog = messageLogFactory.getMessageLog(message);
    if(messageLog != null){
        messageLog.setStringProperty("Logging#1", "Printing Payload As Attachment")
        messageLog.addAttachmentAsString("C4CRequestPayload:", body, "text/plain");
     }
    return message;
}





Groovy/Java Script for XML alignment from Oracle system(Database)

(Oracle) system is sending the data in different JSON format which needs to convert to actual JSON format for passing to the mapping. Below are the source and target data, highlighted the modification shown below. After this conversion if we convert to xml then it can be passed to add the logic's in mapping.

Eg:

INPUT:
{
  "Root": {
    "items": {
      "count": "17",
      "tableName": "Table0",
      "columnNames": [
        "ContactId",
        "Salutation",
],
      "rows": [
        {
          "1906569"
          "Ms",}]
}

OUTPUT:
{
  "Root": {
    "items": {
      "count": "17",
      "tableName": "Table0",
      "columnNames": [
        "ContactId",
        "Salutation",
],
      "rows": [
        {
          "ContactId": "1906569"
          "Salutation": "Ms",}]

}



REST API from the Oracle system URL issue:

There is no REST adapter now in SAP HCI, so you can convert the URL to the specific format then only this will be allowed in HTTP adapter.

This is the initial URL provided from the Source system:

https://domain/services/rest/connect/v1.1/queryResults/?query=Select A.Id Availability,I.IntakeID, C.CampusId From Availability A join A.IntakeID I join A.CampusID C where C.CampusId='<CAMPUS_ID>'

Convert this URL as below:


Use this in the HTTP adapter as:

Address:  https://domain/services/rest/connect/v1.1/queryResults/

Query: query=Select%20A.Id%20Availability,I.IntakeID,%20C.CampusId%20From%20Availability%20A%20join%20A.IntakeID%20I%20join%20A.CampusID%20C%20where%20C.CampusId=%27%3CCAMPUS_ID%3E%27
Proxy Type: Internet

Method:  GET

Reference (URI Codes for changes in URL)

ASCII Encoding Reference
Your browser will encode input, according to the character-set used in your page.
The default character-set in HTML5 is UTF-8.

Character From Windows-1252 From UTF-8
space 20% 20%
! 21% 21%
" 22% 22%
# 23% 23%
$ 24% 24%
% 25% 25%
& 26% 26%
' 27% 27%
( 28% 28%
) 29% 29%
* %2A %2A
+ %2B %2B
, %2C %2C
- %2D %2D
. %2E %2E
/ %2F %2F
0 30% 30%
1 31% 31%
2 32% 32%
3 33% 33%
4 34% 34%
5 35% 35%
6 36% 36%
7 37% 37%
8 38% 38%
9 39% 39%
: %3A %3A
; %3B %3B
%3C %3C
= %3D %3D
%3E %3E
? %3F %3F
@ 40% 40%
A 41% 41%
B 42% 42%
C 43% 43%
D 44% 44%
E 45% 45%
F 46% 46%
G 47% 47%
H 48% 48%
I 49% 49%
J %4A %4A
K %4B %4B
L %4C %4C
M %4D %4D
N %4E %4E
O %4F %4F
P 50% 50%
Q 51% 51%
R 52% 52%
S 53% 53%
T 54% 54%
U 55% 55%
V 56% 56%
W 57% 57%
X 58% 58%
Y 59% 59%
Z %5A %5A
[ %5B %5B
\ %5C %5C
] %5D %5D
^ %5E %5E
_ %5F %5F
` 60% 60%
a 61% 61%
b 62% 62%
c 63% 63%
d 64% 64%
e 65% 65%
f 66% 66%
g 67% 67%
h 68% 68%
i 69% 69%
j %6A %6A
k %6B %6B
l %6C %6C
m %6D %6D
n %6E %6E
o %6F %6F
p 70% 70%
q 71% 71%
r 72% 72%
s 73% 73%
t 74% 74%
u 75% 75%
v 76% 76%
w 77% 77%
x 78% 78%
y 79% 79%
z %7A %7A
{ %7B %7B
| %7C %7C
} %7D %7D
~ %7E %7E
%7F %7F
` 80% %E2%82%AC
 81% 81%
82% %E2%80%9A
ƒ 83% %C6%92
84% %E2%80%9E
85% %E2%80%A6
86% %E2%80%A0
87% %E2%80%A1
ˆ 88% %CB%86
89% %E2%80%B0
Š %8A %C5%A0
%8B %E2%80%B9
Œ %8C %C5%92
 %8D %C5%8D
Ž %8E %C5%BD
 %8F %8F
 90% %C2%90
91% %E2%80%98
92% %E2%80%99
93% %E2%80%9C
94% %E2%80%9D
95% %E2%80%A2
96% %E2%80%93
97% %E2%80%94
˜ 98% %CB%9C
99% %E2%84
š %9A %C5%A1
%9B %E2%80
œ %9C %C5%93
 %9D %9D
ž %9E %C5%BE
Ÿ %9F %C5%B8
%A0 %C2%A0
¡ %A1 %C2%A1
¢ %A2 %C2%A2
£ %A3 %C2%A3
¤ %A4 %C2%A4
¥ %A5 %C2%A5
¦ %A6 %C2%A6
§ %A7 %C2%A7
¨ %A8 %C2%A8
© %A9 %C2%A9
ª %AA %C2%AA
« %AB %C2%AB
¬ %AC %C2%AC
%AD %C2%AD
® %AE %C2%AE
¯ %AF %C2%AF
° %B0 %C2%B0
± %B1 %C2%B1
² %B2 %C2%B2
³ %B3 %C2%B3
´ %B4 %C2%B4
µ %B5 %C2%B5
%B6 %C2%B6
· %B7 %C2%B7
¸ %B8 %C2%B8
¹ %B9 %C2%B9
º %BA %C2%BA
» %BB %C2%BB
¼ %BC %C2%BC
½ %BD %C2%BD
¾ %BE %C2%BE
¿ %BF %C2%BF
À %C0 %C3%80
Á %C1 %C3%81
 %C2 %C3%82
à %C3 %C3%83
Ä %C4 %C3%84
Å %C5 %C3%85
Æ %C6 %C3%86
Ç %C7 %C3%87
È %C8 %C3%88
É %C9 %C3%89
Ê %CA %C3%8A
Ë %CB %C3%8B
Ì %CC %C3%8C
Í %CD %C3%8D
Î %CE %C3%8E
Ï %CF %C3%8F
Ð %D0 %C3%90
Ñ %D1 %C3%91
Ò %D2 %C3%92
Ó %D3 %C3%93
Ô %D4 %C3%94
Õ %D5 %C3%95
Ö %D6 %C3%96
× %D7 %C3%97
Ø %D8 %C3%98
Ù %D9 %C3%99
Ú %DA %C3%9A
Û %DB %C3%9B
Ü %DC %C3%9C
Ý %DD %C3%9D
Þ %DE %C3%9E
ß %DF %C3%9F
à %E0 %C3%A0
á %E1 %C3%A1
â %E2 %C3%A2
ã %E3 %C3%A3
ä %E4 %C3%A4
å %E5 %C3%A5
æ %E6 %C3%A6
ç %E7 %C3%A7
è %E8 %C3%A8
é %E9 %C3%A9
ê %EA %C3%AA
ë %EB %C3%AB
ì %EC %C3%AC
í %ED %C3%AD
î %EE %C3%AE
ï %EF %C3%AF
ð %F0 %C3%B0
ñ %F1 %C3%B1
ò %F2 %C3%B2
ó %F3 %C3%B3
ô %F4 %C3%B4
õ %F5 %C3%B5
ö %F6 %C3%B6
÷ %F7 %C3%B7
ø %F8 %C3%B8
ù %F9 %C3%B9
ú %FA %C3%BA
û %FB %C3%BB
ü %FC %C3%BC
ý %FD %C3%BD
þ %FE %C3%BE
ÿ %FF %C3%BF