Wednesday 17 April 2019

How to guide – Connectivity Setup with ABAP and SAP Cloud Connector

Overview


This how-to guide describes an end-to-end scenario to consume backend data coming from an Netweaver AS ABAP system which is exposing a products catalog via an OData service. The approach of the blog is to provide intuitive guidance with the SAP Cloud Platform Connectivity Service and the SAP Cloud Connector.

Big Picture Scenario


SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

SAP Cloud Connector Configurations


Assuming there is already a working instance of the SAP Cloud Connector, we need to do the following steps after the installation is done:

Change default password:


The default user is the SAP Cloud Connector is Administrator and the default password is manage, the first time you will login in the UI it will request to configure a new password.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Configure the connection to your SAP Cloud Platform subaccount:


After password has been changed the next step is to connect our SAP Cloud Connector from the datacenter (onpremise) to the target SAP Cloud Platform subaccount that is going to be used in the scenario.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

The connection details can be obtained from the subaccount cockpit under Overview tab. See a mapping below:

Region Host Cockpit URL hostname. eu1.hana.ondemand.com 
Subaccount Name Technical Name 
Display Name   Subaccount Name is recommended 
Subaccount User   SAP Cloud Platform admin user 
Password  SAP Cloud Platform admin user password 
Location ID  In case there is more than one Cloud Connector in the landscape, this fields helps to identify to which Cloud Connector the Destination will talk to. In this case we leave it empty since there is only one Cloud Connector in the scenario 
Description <description> 

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Once the connection is done we should see a window as follows, describing some basic information related to the tunnel opened from your Cloud Connector to the SAP CP subaccount:

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Alternatively we can also check the connection from the SAP Cloud Platform subaccount under Connectivity > Cloud Connector:

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Configure Access Control – Cloud To On-Premise Mapping


Now it’s time to configure the mapping between cloud and the on-premise system, which allows to expose backend services throught the SAP Cloud Connector.

Click the “+” button to start the wizard.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

We have a backend service running and a gateway exposing this service so we can select ABAP System.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

HTTPS as a protocol has to be selected

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Next step is to configure the internal host which is the actual host where the service is running in the backend. Since we have our Cloud Connector installed in the same host, we can use localhost as a hostmane under the 44300 port.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

As virtual host we will use an alias or random name. Keep in mind this name needs to match with the URL field on the Destination we will create later on. In this case we use shopapp under port 443.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

For the Principal type we leave this field as None, we are going to use Basic as authentication method so there is no need to configure anything here.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

You can add a Description if it is required.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Finally a summary with the previous configuration is shown on the screen, we can also select the option Check Internal Host which performs a ping to the backend to verify of the system is up an running.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

As a result we will see our new entry in the Mapping Virtual to Internal System and the result of the check as Reachable.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Expose Resources


Now that we have created the mapping between the virtual cloud system and the actual resource, what we need to do is to expose the backend services that are going to be consumed from our application in SAP Cloud Plaform. Use the “+” button to add a new resource:

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

A pop-up will open to configure the resource, for this scenario we are going to expose all the services running in the backend, but we can select a more restrictive configuration if needed. So we use /sap/ as the URL path and the access policy need to be for Path and all sub-paths

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

After Saving the configuration we should see a new entry under the Resources Accesible On shopapp:443 with the information related to this new resource. We can easily deactivate, delete or modify it from the SAP Cloud Connector menu.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Alternatively we can also go back to our SAP Cloud Platform subaccount under Connectivity > Cloud Connectors and check that the virtual host name is exposed with its Resouces available.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

SAP Cloud Platform Configuration


Here we will create a new Destination using the details from the virtual system we created previously in the SAP Cloud Connector. Also we will go through the process of import a SAPUI5 application which will consume the data from the backend and create a binding using the Destination and the WebIDE Full-Stack

Create a Destination


Create a new Destination by clicking the New Destination button.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

A sub-menu will open with a set of properties we need to enter with the details of the destination, such details are:

Name RefAppsBackend. We will use this name for our destination since our Reference App comes configured with this destination name
Type HTTP
Description It is not mandatory but useful to describe the purpose of the destination
Location ID This field appears after we select Onpremise as Proxy Type. This is useful when we have multiple Cloud Connectors connected to our subaccount and serves as a “router” for the Destinations
URL Is the virtual host we configured in the SAP Cloud Connector
Proxy Type Onpremise
Authentication Basic Authentication. Here we need to enter the user and password of the user used in the backend to consume the OData

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Some extra properties are needed to use this Destination from the WebIDE:

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

WebIDEUsage: true

WebIDEUsage: odata_abap,ui5_execute_abap,dev_abap

odata_abap for the OData functionality of Gateway (corresponds to URL path /sap/opu/odata)
ui5_execute_abap   for executing SAPUI5 applications from the SAPUI5 ABAP Repository (corresponds to URL path /sap/bc/ui5_ui5) 
dev_abap  for extensibility scenarios and developing or deploying to SAPUI5 ABAP Repository (corresponds to URL path /sap/bc/adt) 

After Saving the configuration we can do a Check Connection by clicking the button and this will do a ping from SAP Cloud Platform to the backend system via the Destination. Note that no authorization verification is done at this point.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Create Project from Sample Application


Now it’s time to create a new Project from a sample application from the WebIDE.

Open WebIDE from Services > Web IDE Full-Stack > Go to Service

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Open Home from the left menu and select the New Project from Sample Application

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

We choose the Shop application tile from the list, accept the license agreement and Finish

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

We will see the application deployed in our workspace

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Create Data Binding

Now we need to connect our application to the data source by using the Destination created previously, in order to to do that simply open the manifest.json file, delete the mainService binding that already exists and select the “+” button under Data Sources tab.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

A new window will open where we need to select the data souce type. Choose Service Catalog and use the dropdown box to search for the RefAppsBackend destination

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Since we are going to use a Reference App to consume data from the EPM model in ABAP, we need to filter for this specific service , therefore use the search box search for the service EPM_REF_APPS_SHOP_SRV.

We can see also some details about the service we will consume:


SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Use default model and Finish

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Run the Shop App from the WebIDE


Now it´s time to open the application in the WebIDE by choosing the flpSandbox.html from webapp folder > test > Run as Web Application

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

It will open a launchpad with our Shop application tile

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

We can see how data is coming from the back end

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

We can do a little exercise with a product from the catalog. Let’s assume we want to change a price from the Notebook Basic 15 for example. We can select this product and copy the Product ID HT-1000 which has a price of 956.00 USD

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

Then we go back to our backend the SAP Cloud Connector is also running and change the price and setup the new price to 856.00 USD

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

We can see the new price reflected after refreshing the application.

SAP ABAP Certifications, SAP HANA Guides, SAP HANA Learning, SAP ABAP Cloud, SAP ABAP Learning

With this we conclude this blog where we have learnt basics for:

◈ Configure SAP Cloud Connector in our landscape (OnPremise).
◈ Connect SAP Cloud Connector to our cloud recources in SAP Cloud Platform.
◈ Create and configure a Destination and its main capabilities.
◈ Use a Sample application from the WebIDE Full-Stack service in SAP Cloud Platform and bind it to our own data source.

No comments:

Post a Comment