Skip to Content

Introducing:

Based on this blog and an upcomming customer project it was necessary to try out how we can use the SAP Cloud Connector with SAP Cloud Platform Integration.

An i know there a for sure still other blogs, how we can use the SAP Cloud Connector but i´ve no blog found how we can use it with an SAP HANA OnPrem System and especially with an xsodata service.

I will show in the next lines an in a little end2end scenario how we can use this togehter.

Some HANA stuff:

As reference check also this Tutorial.

First of all we need to develop our “backend” where we want to store our data.

In the SAP HANA WebIDE we create a new package where we want to develop/store our artifacts:

In this package, we create now an empty xs application:

Additional i changed in the “.xsaccess” file the following:

“prevent_xsrf”: false, this is required if we want to post data to our service w/o an xsrf token in the http header.

Please check this for more details

 

Afterwards we can remove afterwards the index.html file which is not required for this demo.

Now we create some files to define our db table and to store our data:

.xsprivileges

{
 "privileges" :
 [
	{ "name" : "Execute", "description" : "Basic execution privilege" },
	{ "name" : "Admin", "description" : "Administration privilege" }
 ]
}

cpi_scc_hana_demo.hdbdd

namespace development.cpi_scc_hana_demo;
@Schema: 'FABIAN'
context cpi_scc_hana_demo {
 type SDate : UTCTimestamp;
 type tt_error {
 HTTP_STATUS_CODE: Integer;
 ERROR_MESSAGE: String(100);
 DETAIL: String(200);
 };
type tt_message {
 ID: Integer;
 TIMESTAMP: SDate;
 MESSAGE: String(100);
 
 };
@Catalog.tableType : #COLUMN
Entity message {
 key ID: Integer;
 TIMESTAMP: SDate;
 MESSAGE: String(100);
 };
};

cpi_scc_hana_demo_id_seq.hdbsequence

schema="FABIAN";
start_with=1;
minvalue=1;
cycles=false;
depends_on_table="development.cpi_scc_hana_demo::cpi_scc_hana_demo.message";

cpi_scc_hana_demo_message.hdbprocedure

PROCEDURE "FABIAN"."development.cpi_scc_hana_demo::cpi_scc_hana_demo_message" ( 
IN row "development.cpi_scc_hana_demo::cpi_scc_hana_demo.tt_message",
OUT error "development.cpi_scc_hana_demo::cpi_scc_hana_demo.tt_error" )
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
DEFAULT SCHEMA FABIAN
AS
BEGIN
declare lv_message string;
select MESSAGE into lv_message from :row;

 if :lv_message = ' ' then
 error = select 400 as http_status_code,
 'invalid date' as error_message,
 'Invalid response from sap cp' as detail from dummy;
 else
insert into "FABIAN"."development.cpi_scc_hana_demo::cpi_scc_hana_demo.message" values 
("FABIAN"."development.cpi_scc_hana_demo::cpi_scc_hana_demo_id_seq".NEXTVAL, now(),
lv_message);
end if;
END;

Now we create the “cpi_scc_hana_demo.xsodata” service to post data to our HANA:

service namespace "development.cpi_scc_hana_demo"
{ 
"FABIAN"."development.cpi_scc_hana_demo::cpi_scc_hana_demo.message" 
as "MESSAGE" create using "development.cpi_scc_hana_demo::cpi_scc_hana_demo_message";
}

Result (metadata of our new xsodata service):

Internal Test

So lets try it out an post a message to our .xsodata service with e.g. postman:

And woohooooooo…it works for now:

OData Exlporer:

DB Table:

 

The Cloud Connector

Now its time to setup the Cloud Connetor, beacuse we do not want to post our data only internal.

For details on the installation and setup of the SAP Cloud Connector please check this tutorial here.

Additional this blog can help if u want connect multiple SCC´s to your SAP Cloud Platform Integration subaccount

After this steps are done we cann see our successful connection to the SCP:

….futhemore we´ve defined how the internal host is exposed:

Virtual Host: myhanahost:8001

Accessible Path: /development/cpi_scc_hana_demo

In the SCP cockpit we can still now see our SCC with Location ID “FL200” which i used here for my  local SCC.

Integration, Integration…..still SAP CP Integration ;o)

In fact that we are now able to connect our OnPrem HANA system, its now time to model a simple Integration Flow.

The Sender Connection Details
Adapter Type: HTTPS
Address: <endpoint wich we use to post our data to SAP CP Integration>
Authorization: User Role
User Role:   ESBMessaging.send
The Receiver Connection Details
Adapter Type: HTTP *
Addresss http://virirtualhost:virtulalport><path>
Proxy Type: On-Premise
Location ID: <SCC Location ID>
Method: POST
Authentification: BASIC
Credential Name: <deployed credential for our HANA>

*= Please Note: We use here HTTP for the connection between SAP CP Intergation and SCC

The Content Modifier

In the Content Modifier we define only the message header.

Action: Create
Name: Content-Type
Type: Constant
Data Type: N/A
Value: application/json
Default: N/A

If this is not defined you will got the following error, also my first mistake ;o)

 ResponseBody= <?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code/><message xml:lang="en-US">
Invalid value for HTTP header field 'Content-Type': 
Empty value not allowed.
</message>
</error>

Final Test….

Finally we can now post a message again via postman to our HTTP endpoint from SAP Cloud Platform Integration. In the Authorization settings please enter the user credential which is allowed to send messages to SAP CP Integration:

URL: https://<IFLMAPURL>.hana.ondemand.com/http/hanapost

SAP CP Integration Monitoring…..just green ;o):

SAP SCC Monitoring:

SAP HANA check:

Whoot! Message is stored at HANA:

 

Conclusion

Hopefully this blog will not be to boring, because i think there are a lot of other blogs around the SAP Cloud Connector and how this works.

But nevertheless from my perspective, its always helpful to see the parts togehther and have an full end-2-end example.

And during my investigation, i do not found a blog about this scenario.

Cheers,

Fabian

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply