-
BUILD SAP HANA CLOUD APPLICATIONS
WHICH INTEGRATE WITH ON-PREMISE
SYSTEMS
CD166
Timo Lakner, Nikolai Tankov, Markus Tolksdorf, Daniel Vladinov
SAP AG
Getting started with your session Login credentials and group
numbers can be found in the My Reservation tab on the SAP TechEd
Virtual Hands-On Workshops website
(https://saptechedhandson.sap.com/). Important: Some of the
sessions use place holders for users (e.g. CD300_XX) or objects
(e.g. ZCD400_Exercise_##). The place holders XX or ## must be
replaced with your assigned group number, which you find in the My
Reservation tab on the above mentioned website.
-
TABLE OF CONTENTS
Before you start
..........................................................................................................................................
3
1 Creating developer account and deploying application
..........................................................................
5
1.1 Creating a free developer account
.....................................................................................................
6
1.2 Deploying Web Shop application to the cloud
...................................................................................
9
2 Configuring destinations of the cloud application
...................................................................................
13
2.1 Configuring destinations with the Destination Editor
.........................................................................
14
3 Using connectivity service API in the application
...................................................................................
16
3.1 Configuring destination as JNDI resource
.........................................................................................
17
3.2 Using destination API to call remote HTTP service
...........................................................................
19
3.3 Redeploying application changes
......................................................................................................
21
4 Installing and configuring the SAP HANA Cloud
Connector...................................................................
22
4.1 Installing the SAP HANA Cloud Connector
.......................................................................................
24
4.2 Connecting the SAP HANA Cloud Connector to an account
............................................................ 25
4.3 Configuring access control
................................................................................................................
26
4.4 Configuring a system certificate
.........................................................................................................
28
4.5 Testing the application
.......................................................................................................................
29
5 Using Java Connector and RFC to access the ABAP system
................................................................
32
5.1 Configuring an RFC destination
.........................................................................................................
33
5.2 Using JCo to call an ABAP function module
......................................................................................
35
5.3 Configuring an ABAP function module in SAP HANA Cloud
Connector ........................................... 36
5.4 Testing the application
.......................................................................................................................
39
6 Summary and Further information
..........................................................................................................
40
Copyright
....................................................................................................................................................
1
-
3
BEFORE YOU START
SAP HANA Cloud Platform is the platform-as-a-service offering by
SAP that enables SAP partners and customers to deploy and use Java
EE and HANA XS applications in a cloud environment. In this
hands-on session, you will learn how you can use the SAP HANA Cloud
connectivity service to integrate a Java cloud application with an
on-premise backend system. To take advantage from the cloud
benefits like low TCO, high flexibility, fast development cycles,
etc., companies are more and more interested in using the cloud. At
the same time, they want to safeguard their investments in their
existing heterogeneous on-premise IT landscape, and so they are
looking for ways how to smoothly migrate and transform their
businesses into the cloud. It is therefore a common scenario to
develop an application in the cloud which extends a legacy system
running on-premise. In this Hands-on session, you will learn how to
develop an on-demand Java application which uses services via HTTP
and RFC running in an on-premise network. This is done using the
SAP HANA Cloud connectivity service and the SAP HANA Cloud
connector. As scenario, a Web Shop application is used which allows
end users to browse through a product catalog and to buy products.
The Web Shop application retrieves its product catalog from an ABAP
system running locally on the TechEd training laptops which
simulate isolated on-premise networks. In this session, you will
setup the SAP HANA Cloud connector on your TechEd laptop, configure
it and configure the Web Shop application in the cloud
appropriately so that the access of the ABAP system works
end-to-end. The following image shows the overall landscape
relevant for the scenario:
The picture shows the SAP HANA Cloud Platform at the top, and
the on-premise landscape simulated by your TechEd laptop - at the
bottom. Both landscapes are isolated networks, protected by
firewalls and DMZs, i.e. not directly accessible from outside. On
the cloud side, the Web Shop application is deployed and
configured. It reads data from an ABAP 7.40 system in a RESTful way
via the built-in SAP NetWeaver Gateway component. The technical
connectivity between the on-premise system (i.e. laptop) and the
cloud application is established by the SAP HANA Cloud connector,
which is running on the laptop as on-premise agent and establishes
a secure SSL VPN connection to your specific cloud account.
-
The Hands-on session will guide you through 5 exercises. We
strongly recommend going through the exercises in the given order
to make sure that you will reach the final step running the Web
Shop application successfully - without issues. Exercise 1:
Creating developer account and deploying application Register with
the SAP ID service and create a free SAP HANA Cloud Platform
developer account. Deploy the prepared Web Shop application into
your account and run it in a browser. Exercise 2: Configuring
destinations of the cloud application Configure the destinations
needed by the Web Shop application to communicate with the ABAP
on-premise backend, using the SAP HANA Cloud Platform Customer
Cockpit. Exercise 3: Using connectivity service API in the
application Complement the application code relevant for
connectivity by adding prepared code snippets. Exercise 4:
Installing and configuring the SAP HANA Cloud Connector Download
the SAP HANA Cloud Connector (shortly, SCC) from the SAP HANA Cloud
Update Site, install it on your TechEd laptop and configure it to
connect to your cloud account. Configure the ABAP services which
shall be accessible for the Web Shop application. Exercise 5: Using
Java Connector and RFC protocol to access the ABAP system Extend
the Web Shop application with data coming from the ABAP backend by
calling a remote enabled ABAP function module directly using
JCo.
-
5
1 CREATING DEVELOPER ACCOUNT AND DEPLOYING APPLICATION
Estimated time: 15 min Objective Goal of this exercise is to
prepare the environment needed for the further steps of the
Hands-on session. As first step, you will register for a free
developer account on the SAP HANA Cloud trial landscape. As second
step, you will deploy the already prepared Web Shop application
into the newly created developer account. In the overall scenario
picture, this exercise will address following parts of the cloud
landscape highlighted in red:
What you will learn
how to register for a free developer account
how to deploy and run applications in your account
how to use the Cloud Cockpit to manage your account
Exercise description
In Exercise 1.1 you will create a free developer account.
In Exercise 1.2 you will deploy the prepared Web Shop
application to your cloud account and run the application in its
initial state in the cloud.
-
1.1 Creating a free developer account
As first step, you need to get a free developer account on the
HANA Cloud trial landscape that will be used in the subsequent
exercises. The account is the top-level entity on the SAP HANA
Cloud Platform that is required to deploy, configure and
administrate applications, account users, services, and alike. A
free developer account has restrictions, like a quota limit of one
application that can be started at a time or missing
service-level-agreements (SLAs), and is thus not meant for
productive usage. To create an account on HCP, you need to have a
user registered at the SAP ID Service. The SAP ID Service is the
identity provider used by SAPs on-demand services and platforms,
like SAP Developer Network, Business ByDesign, HANA Cloud Platform
and others. Depending on whether you already have a user registered
in the SAP ID Service or not, you need to go through one of the
following two cases. Case 1: You have a user registered in SAP ID
Service (e.g. SDN user exists)
Explanation Screenshot
Open https://account.hanatrial.ondemand.com/cockpit in a
browser. This brings up the login screen shown in the screenshot.
Enter your SAP ID Service user and password and click Log On.
After successful logon, you need to accept a Legal Disclaimer
for the first time when accessing the HANA Cloud Platform. Click
the checkbox and then the Accept button.
On the next screen, select the database which you want to use
for the newly created account. This step is only temporarily needed
and will be removed in the future. Select SAP HANA Database and
click Continue.
-
7
Explanation Screenshot
You get now to the Cloud Cockpit. The Cloud Cockpit is the
central administration UI for your account.
Case 2: You dont have a user registered at SAP ID Service To
register a new SAP ID user, you require access to an email account
(e.g. of a public email provider of your choice, like gmail, gmx,
etc.). If this is the case, please continue with the screenshots in
the table below. If this is not the case, we have prepared a set of
developer accounts, which you can use for the further exercise.
Please contact your trainer to get the details of a prepared
developer account and skip the rest of the steps below.
Explanation Screenshot
Open https://account.hana.ondemand.com in a browser and click
the Register button.
-
Explanation Screenshot
Fill out the Registration form in the upcoming popup. After
finishing the registration, an email is sent to your provided email
account, which includes an activation link. Click the link in the
email to activate your user.
On the next screen, you have to select the database, which is
used for the newly created account. This step is only temporarily
needed and will be removed in the future. Select SAP HANA Database
and click Continue.
You get now to the Cloud Cockpit. The Cloud Cockpit is the
central administration tool for your HCP account. The account name
is displayed under Account in the upper left-side area of the user
interface, and the user ID is visible in the header. In the
screenshot, the account name is p1940079614trial, and user name is
p1940079614. Note down the account and user name somewhere as they
will be needed in the next step again.
You have now created a free developer account on SAP HANA Cloud
Platform. In the future, you can administrate your account using
the Cloud Cockpit by URL
https://account.hanatrial.ondemand.com/cockpit.
-
9
1.2 Deploying Web Shop application to the cloud
As next step, you will deploy the already prepared Web Shop
application into your newly created account.
Explanation Screenshot
Open Eclipse via Start > Program Files > Eclipse >
CD166.
This starts Eclipse with workspace
D:\Files\Session\CD166\workspace preselected. The two projects
relevant for the Web Shop application are already available in the
Eclipse workspace as shown in the screenshot.
Click on espm-ui-shopping-web with the right mouse button.
-
Explanation Screenshot
Click the Run As > Run on Server menu item.
Select the Manually define a new server radio button. In the
server type tree, select SAP > SAP HANA Cloud. Verify that
hanatrial.ondemand.com is entered as Server's host name: It
specifies that the HANA Cloud trial landscape should be used for
the deployment. Click the Next button.
-
11
Explanation Screenshot
Fill out the fields as shown in the screenshot, using your
developer account name and your SAP ID user ID. Application name:
webshop Account name: User name: Password: Click Next button to
start the deployment.
Click Finish. This will start the deployment of the application
which will take 1 to 2 minutes to complete.
-
Explanation Screenshot
After successful deployment, the application is started in the
embedded Eclipse browser. At this stage, the application does not
show any product data, but displays the message An error occured
during retrieval of data: HTTP request failed in the application
message area. Reason for this is that the required backend
connectivity for the application is not yet configured. This will
be subject of the subsequent exercises.
As last step, use the Cloud Cockpit to verify that the
application is deployed. Open the Cloud Cockpit via
https://account.hanatrial.ondemand.com/cockpit. Click on
Applications in the navigation area on the left hand-side and
verify that the webshop application is visible in the list of
applications in state STARTED.
Summary After this exercise, you have created a developer
account and deployed the Web Shop application into this account in
the cloud. You have also gathered first hands-on experience with
the Cloud Cockpit used to administrate your account and
applications. If you want to learn more about the HANA Cloud
Platform, its account types, the deployment of applications, or the
Cloud Cockpit have a look at following online resources: [1]
Product Overview [2] Getting an Account [3] Signing up for a
Developer Account [4] Account Types [5] Deploying Applications [6]
Cloud Cockpit
-
13
2 CONFIGURING DESTINATIONS OF THE CLOUD APPLICATION
Estimated time: 10 min Objective Goal of this exercise is to
configure the connection details needed by the Web Shop application
in the cloud. Connections are configured on the HANA Cloud Platform
using so-called destinations. A destination represents the
configuration of the targeted backend service, i.e. in case of HTTP
protocol it consists for instance of a URL, authentication
credentials for the backend and other related data. You have
multiple options to configure a destination. You can do this via
the neo command line tool (link), via Eclipse (link), or via the
Destination Editor in the Cloud Cockpit (link). We will use the
Cloud Cockpit in this exercise. Looking at our overall landscape
picture, you will now work on the following cloud parts highlighted
in red:
As shown in the image, the Web Shop application uses
destinations for the remote communication with the backend services
and the destination configuration is stored transparently for the
user in a database. What you will learn
how to use the Destination Editor UI in the Cloud Cockpit
how to configure an HTTP destination
Exercise description
In Exercise 2.1 you will use the Cloud Cockpit and its
Destination Editor to configure an HTTP destination.
-
2.1 Configuring destinations with the Destination Editor
In this exercise, you will use the Cloud Cockpit and its
Destination Editor to configure two destinations needed by the Web
Shop application.
Explanation Screenshot
Open Cloud Cockpit:
https://account.hanatrial.ondemand.com/cockpit. Select Applications
in the navigation area on the left side. From the list of
applications select the webshop application. This will drill down
into the application view for the Web Shop application.
Select Destinations in the navigation area. This will open the
Destination Editor for the webshop application.
In the Destination Editor, click the New Destination button and
chose Import from File in the submenu. In the upcoming file
browser, select
D:\Files\Session\CD166\resources\destination\abapbackend. The
abapbackend destination is now being imported.
-
15
Explanation Screenshot
Once the imported destination properties are displayed in the
Destination Editor, click the Save button. This stores the imported
destination transparently in a database. Note: Once an application
has read a destination, it stores the destination in a runtime
cache with an expiration time of 5 minutes. When you change the
destination configuration afterwards again e.g. using the
Destination Editor, it takes up to 5 minutes until the changes
become effective.
Lets have a closer look into the destination configuration: it
shows an example of an HTTP service configuration and consists
of
an application-wide unique destination name, in this case
abapbackend, which identifies the destination at runtime.
a type, specifying the protocol to be used, in this case HTTP is
used as protocol.
the URL to the targeted remote service. In this example, the URL
points to a SAP NetWeaver Gateway service. Note that espm:50000 is
used as host and port. You will find this host and port again later
on, when we configure the backend service in the SAP HANA Cloud
connector.
authentication properties needed for the authentication against
the backend. In this example, BasicAuthentication is used with
service user EPM_TEST.
Repeat the destination import steps with abapbackendimages. The
second destination is located under
D:\Files\Session\CD166\resources\destination\abapbackendimages.
Summary In this exercise, you have configured two destinations
needed by the Web Shop application. By this, the Web Shop
application "knows" the connection details of the targeted backend
services. If you refresh the Web Shop application in the browser,
you will notice that there is still no product data shown in the UI
and the message An error occured during retrieval of data: HTTP
request failed is still displayed. One reason for this is that the
application coding related to connectivity is not yet complete. In
the next step, we will therefore complement the application code.
If you want to learn more about destinations and its configuration
have a look at following online resources: [1] Using Destinations
[2] HTTP Destinations
-
3 USING CONNECTIVITY SERVICE API IN THE APPLICATION
Estimated time: 10 min Objective Goal of this exercise is to
complete the Web Shop application with coding snippets related to
connectivity. This includes the usage of the destination API and
the destination declaration as a JNDI resource of the Web
application. After this step, the application is fully prepared for
final usage on the cloud side. What you will learn
how to declare a destination as a JNDI resource in the Web
application
how to use the destination API in a Web application
how to redeploy the changed application to the cloud
Exercise description
In Exercise 3.1 you will configure the destination factory as a
JNDI resource.
In Exercise 3.2 you will add a coding snippet to the application
that demonstrates the usage of the destination API.
In Exercise 3.3 you will redeploy the changed application to the
cloud.
-
17
3.1 Configuring destination as JNDI resource
In Java EE applications, resources that are used in a Web
application are deployed externally to the Web application. To use
external resources in the Web application, you resolve the JNDI
resource name that the application uses with the global JNDI
resource name using the web.xml deployment descriptor.
HTTP destinations are such kind of external resources, which
need to be declared in the web.xml of a Web application in order to
access them from the global JDNI resources. This is done in the
following steps.
Explanation Screenshot
In the Eclipse Project Explorer, navigate into
espm-ui-shopping-web > src > main > webapp > WEB-INF
folder and double-click the web.xml file to open it in the
editor.
-
Explanation Screenshot
In the we.xml editor, navigate to the Source tab and search for
the string "CD166". This brings you to a commented code block.
Remove the comments , so that the following declaration becomes
active:
connectivity/DestinationFactory
com.sap.core.connectivity.api.
DestinationFactory
It declares that the Web application needs the resource
connectivity/DestinationFactory of type
com.sap.core.connectivity.api.DestinationF
actory from the global JNDI tree. Save the changes made in the
web.xml file by clicking the Disk icon.
-
19
3.2 Using destination API to call remote HTTP service
As next step, you will complement the coding of the Web Shop
application that demonstrates how to use the destination API.
Explanation Screenshot
In the Eclipse Project Explorer, navigate to
espm-ui-shopping-web > src > main > java > com > sap
> cloudlabs > connectivity > proxy and double-click the
ProxyServlet.java class. This opens the class in the Java
editor.
-
Explanation Screenshot
In the Java Editor, search for string "CD166" which brings you
to the method
getDestination(String) which
contains a commented code block. Comment out the return null;
statement and remove the comments in the code block below. Note:
The code block shows how the
DestinationFactory class is
looked up in the JNDI registry and how it is used to retrieve a
named destination.
Open the context menu and click Source > Organize
Imports.
Double click on the entry javax.naming.Context to select it.
Afterwards, save the changes in the coding by clicking the Disk
icon.
-
21
3.3 Redeploying application changes
After you have changed the application coding, you need to
redeploy the application to your developer account.
Explanation Screenshot
Go to the Eclipse Servers view and select the server adapter of
the webshop application.
Click the Republish button to re-deploy the application. This
will again take 1 or 2 minutes to complete.
Summary You have now added the missing coding to the Web Shop
application which takes care of the remote calls from the
application to the backend. You also deployed the changed
application again to the cloud. From cloud perspective, the
application is now fully set up and ready for final usage. However,
when you refresh the application in the browser, it still does not
show any data in the UI. The reason for this is that it has no
physical connection yet to the ABAP system. We will fix this in the
next exercise by establishing the connection to the backend using
the SAP HANA Cloud connector. If you want to learn more about how
to use the destination API, have a look at following resources: [1]
Exchanging Data via HTTP Protocol [2] Connectivity Service API
-
4 INSTALLING AND CONFIGURING THE SAP HANA CLOUD CONNECTOR
Estimated time: 25 min Objective Goal of this exercise is to
install the SAP HANA Cloud connector (shortly, SCC) as on-premise
agent on your TechEd laptop. The SCC is used to establish a secure
SSL VPN connection to your developer account in the cloud and is
the recommended approach for point-to-point connections between SAP
HANA Cloud Platform applications and on-premise systems. The TechEd
laptop hosts a local ABAP system, which is used as backend for the
Web Shop application. It provides services to read a product
catalog and to drill down into product details. Besides this, it
provides images for each of the products. For the purpose of this
training the laptop thus simulates a complete, isolated on-premise
network. Of course, the backend systems and the SCC will usually
run on different machines. Looking at the overall landscape
picture, we are now addressing following parts high-lighted in
red:
What you will learn
how to install the SCC
how to connect the SCC against your developer account
how to configure the SCC so that it allows access to the
required backend services
how to configure the SCC so that it authenticates itself via a
X.509 client certificate against the ABAP backend
-
23
Exercise description
In Exercise 4.1 you will install the SCC on your TechEd laptop
image.
In Exercise 4.2 you will connect the SCC against your developer
account.
In Exercise 4.3 you will configure the backend services in the
SCC.
In Exercise 4.4 you will upload the system certificate to the
SCC.
In Exercise 4.5 you will test the Web Shop application in its
final stage.
-
4.1 Installing the SAP HANA Cloud Connector
You will now install the SAP HANA Cloud connector (SCC) on your
TechEd laptop image. Download the SCC Windows installer from
https://tools.hana.ondemand.com/#cloud. Choose the latest version
of the
sapcc-2.1.x-windows-x64.msi file available on the Cloud Tools
page
Note: In case the Internet connection in the TechEd laptop image
is slow, you can also download the latest version of the SCC by
choosing Student (share) on the desktop and navigating to
CD166\scc. During installation you get asked for
the installation directory. Choose D:\Files\Session\CD166\scc as
directory.
the port used by the SCC Administration UI. Change the suggested
default port to 9443, as port 8443 is already used by the local
ABAP system on the TechEd laptops.
After installation, open the SCC Administration UI with URL
https://localhost:9443 in a browser which will bring up the SCC
logon screen.
-
25
4.2 Connecting the SAP HANA Cloud Connector to an account
The next step is to go through the initial configuration steps
of the freshly installed SCC. This consists of the first logon,
changing the initial password, and connecting the SCC to a cloud
account.
Explanation Screenshot
Logon to the SCC Administration UI with user Administrator and
initial password manage. After the first logon, the SCC UI guides
you through two mandatory steps, first to change the inital
password, and second to connect your SCC to your SAP HANA Cloud
Platform account.
Change initial password to abcd1234 or another password you can
easily remember for the duration of this Hands-on session. Click
the Save button.
In the Set Up Initial Configuration view, enter: Landscape Host:
hanatrial.ondemand.com Account Name: User Name: Password: As HTTPS
Proxy settings, enter: Host: proxy Port: 8080 Click Apply.
You should now be directed to the Home tab of the SCC
Administration UI, and the Connector State should be connected.
This means an SSL VPN tunnel to your cloud account has been
established and you are now able to make calls from applications
running in your account through this tunnel. Under the Overview
group, you can see your account name, next to some other
information.
-
4.3 Configuring access control
Now that the SCC is connected to your account, the next step is
to configure the resources/services which shall be made accessible
to the applications in your account. Each resource that shall be
accessible for applications in your account must be explicitly
configured in a whitelist, as the default behavior of the SCC is to
block all requests to any services which are not defined as
accessible resources.
Explanation Screenshot
To configure accessible resources, navigate to the Access
Control tab in the SCC Administration UI. As first step, define the
system which hosts the service you like to make accessible: On the
Resources tab, click the Add button on the menu bar of the Mapping
Virtual To Internal System group.
Enter following values in the Add System Mapping popup: Virtual
Host: espm Virtual Port: 50000 Internal Host: localhost Internal
Port: 8443 Protocol: HTTPS Backend Type: SAP NetWeaver Gateway
Note: This configuration defines that the localhost on port 8443
can be accessed by the cloud account under the virtual host and
port espm:50000. Remember that this was the host and port used in
the destination URLs which we had configured before. Click
Save.
Select the table row with the newly created system mapping. This
brings up a details view in which you can define the resources
(a.k.a. services in case of HTTP), which shall be used on the
related system.
Click Add in the Resources Accessible On localhost:8443
view.
-
27
Explanation Screenshot
Enter the following values in the Add Resource popup window: URL
Path: /sap/opu/odata/sap/Z_TUT_ESPM_DEVELOPER_SCENARIO_SRV Access
Policy: Path and all subpaths Click Save. Note: The resource paths
are case sensitive!
Add another resource with the following values: URL Path:
/SAP/PUBLIC/BC/NWDEMO_MODEL/IMAGES Access Policy: Path and all
subpaths Click Save.
The Access Control view should now look as shown in the
screenshot. You have now configured the services which are needed
by the Web Shop application. You can now optionally click the Check
button to test whether the specified system can be accessed by the
SCC. This should be the case, i.e. the State field of the specified
system should turn into a green light. Note that the SCC must be
able to directly access the specified systems, i.e. the usage of a
proxy between SCC and a configured system is currently not
supported.
-
4.4 Configuring a system certificate
As final step of the SCC configuration, you will now upload the
so-called System Certificate to the SCC. The System Certificate is
a X.509 client certificate used for the authentication of the SCC
towards the backend systems. The backend systems need to be
prepared accordingly to trust the used client certificate. This
trust relationship has already been configured in the local ABAP
system.
Explanation Screenshot
In the SCC Administration UI, open the Settings dialog in the
top-level menu bar. The Settings popup window comes up in which you
can define general settings of the SCC, like the connection
configuration, the Administrator password, configuration of a local
LDAP for authenticating named users, and others. In the Settings
dialog, you can also upload the System Certificate.
Go into the System Certificate tab and click Browse. Select the
file
D:\Files\Session\CD166\resources\backend_cfg\scc_teched2013.p12 in
the file browser. This is a PKCS#12 file containing the key pair
used as System Certificate. In the Password field type in abcd as
encryption password for the PKCS#12 file. Click Apply. This should
upload the specified certificate as system certificate to the SCC.
Afterwards, click Close to close the Settings popup.
On the Home tab of the SCC Administration UI, you should now see
in the Overview group the information that a System Certificate has
been configured. Note that the UI also checks if the certificate is
still valid. Once it expires it will show a warning sign.
-
29
4.5 Testing the application
After you established a secure SSL connection from your laptop
to the cloud, configured the backend services which are needed by
the Web Shop application and the system certificate for
authentication, it is now time to test the application.
Explanation Screenshot
Refresh the application in a browser. It should now come up with
product data displayed as shown in the screenshot. Select one of
the products, like Tablets. This should drill into the product
catalog of the selected product category.
In the product list, select one product and click Details to
drill into the product details.
-
Explanation Screenshot
The Details view should come up and show a product image, loaded
from the backend, and more product details. You can now also play
around with your SCC: E.g. disconnect the SCC from your account
using the Disconnect button on the Home tab. If you then refresh
the webshop application again in your browser, the data is again
not visible. If you re-connect the SCC by clicking the Connect
button on the Home tab, the data appears again after a browser
refresh of the application.
Summary Congratulations! You have now successfully installed and
configured the SAP HANA Cloud connector and used two backend
services in your Web Shop application to read a product catalog and
product details. All pieces of the overall landscape picture are
now set up and working:
Lets recapture the steps of an administrator who has to deploy
and configure an application which requires on-premise backend
connectivity:
1. You deploy the application into your account. 2. You
configure the destinations of the application using the Cloud
Cockpit.
-
31
3. You install the SAP HANA Cloud connector and connect it to
your cloud account as a one-time task. 4. You configure the backend
services in the SAP HANA Cloud connector which are needed by the
application. This might
comprise the configuration of trust relationships using X.509
certificates, i.e. configuration of a system certificate in the
Cloud Connector, and establishing trust to this certificate in the
backend.
5. You test the application and its data access.
If you want to learn more about the SAP HANA Cloud Connector,
have a look at following online resource: [1] Using the Cloud
Connector More details on SAP NetWeaver Gateway, as well as on how
to configure trust in the ABAP system with a client can be found
here: [2] SAP NetWeaver Gateway 2.0 [3] Configuring the AS ABAP to
Use X.509 Client Certificates
-
5 USING JAVA CONNECTOR AND RFC TO ACCESS THE ABAP SYSTEM
Estimated time: 15 min Objective Goal of this exercise is to
show an alternative approach how an on-premise ABAP system can be
accessed from your cloud application. Until now, HTTP has been used
as protocol for the communication between the Web Shop application
and the backend, and the SAP NetWeaver Gateway component was used
on the ABAP 7.40 system to provide RESTful services on top of the
ABAP functions. Now we will use RFC as protocol and Java Connector
(JCo) as Java API in the Web Shop application in order to call some
BAPIs from the ABAP system directly. Calling the ABAP system
directly makes sense when no application proxies like SAP NetWeaver
Gateway or Enterprise Services are available or shall be used due
to performance reasons. Besides this, the access via JCo and RFC
works for any ABAP system release in a uniform manner. The
Connectivity Service tunnels the RFC call from the application to
the SAP HANA Cloud connector via the SSL tunnel, i.e. via an
encrypted channel. From the SCC to the backend, the user has the
option to use RFC or RFC with SNC (Secure Network Communication)
being turned on. What you will learn
how to configure an RFC destination for a cloud application
how to use the JCo API in the cloud application and that this is
the well-known approach as for JCo standalone 3.0
how to configure a function module in the SAP HANA Cloud
connector
Exercise description
In Exercise 5.1 you will configure an RFC destination needed by
the Web Shop application using the Connectivity Editor.
In Exercise 5.2 you will use the JCo API in the Web Shop
application to make a call to an ABAP function module.
In Exercise 5.3 you will configure the needed function module in
the SCC.
In Exercise 5.4 you will test the extended application.
-
33
5.1 Configuring an RFC destination
In this exercise, you will use the Cloud Cockpit and its
Destination Editor to configure an RFC destination needed by the
Web Shop application.
Explanation Screenshot
Open again the Cloud Cockpit via
https://account.hanatrial.ondemand.com/cockpit Drill down into the
webshop application.
Click Destinations to open the Destination Editor.
Click New Destination > Import from File.
Select the RFC destination from
D:\Files\Session\CD166\resources\destinations\abapjcoDestination.
Click Open.
-
Explanation Screenshot
The imported RFC destination is now displayed in the Destination
Editor. Click Save to store the destination.
-
35
5.2 Using JCo to call an ABAP function module
In this step, you will add coding in the Web Shop application
that demonstrates how to use the JCo API. In general, the JCo API
in the cloud is the same as the well-known JCo 7.x API from
NetWeaver AS Java or from JCo 3.0 standalone. Using it does not
feel different.
Explanation Screenshot
In the Eclipse Project Explorer, navigate into
espm-ui-shopping-web > src > main > java > com > sap
> teched > connectivity > jco and double-click
JCoServlet.java. This will open the class in the Java Editor.
In the Java Editor, search for string CD166, which will bring
you to the coding shown in the screenshot. Comment out the throw
new JCoException; statement. Remove the comments from the code
block below. This code block makes use of the JCo API.
After the change, the method should look as shown in the
screenshot. Save the code changes by clicking the Disk icon.
Redeploy the webshop application to the cloud: Go again into the
Eclipse Servers view and click the republish button.
-
5.3 Configuring an ABAP function module in SAP HANA Cloud
Connector
As for HTTP services, each ABAP function module that should be
made accessible to your cloud account must be configured in the
SCC. Function modules not listed in the resources for a system
cannot be invoked. In this exercise, we do this for the function
module needed by the Web Shop application.
Explanation Screenshot
To configure accessible resources, navigate to the Access
Control tab in the SCC Administration UI. As first step, define the
system which hosts the function module you like to make accessible:
On the Resources tab, click the Add button on the menu bar of the
Mapping Virtual To Internal System group.
Enter following values in the Add System Mapping popup: Virtual
Host: espm_appserver Virtual Port: sapgw23 Internal Host: localhost
Internal Port: sapgw00 Protocol: RFC Backend Type: ABAP System
Note: This configuration defines that the ABAP application server
on localhost with service sapgw00 can be accessed by the cloud
account under the virtual host and port espm_appserver with service
sapgw23. Remember that these were the jco.client.ashost and
jco.client.sysnr properties used in the RFC destination, which we
had configured before (sapgw23 maps to system number 23). Click
Save.
Select the table row with the newly created system mapping. This
brings up a details view in which you can define the resources
(a.k.a. function module in case of RFC), which shall be used on the
related system.
-
37
Explanation Screenshot
Click Add in the Resources Accessible On localhost:8443
view.
Enter the following values in the Add Resource popup window:
Function Name: ZSEPM_TOPSELLER_GET Naming Policy: Exact Name Click
Save.
-
Explanation Screenshot
The Access Control view should now look as shown in the
screenshot. You have now configured the services which are needed
by the Web Shop application.
-
39
5.4 Testing the application
The application is now set up to use the ABAP function module.
Next step is to test the Web Shop application again. Go into your
browser and refresh the application. Navigate to the Top 5 Selling
Products tab. It should show a table with the 5 top selling
products. The underlying data is retrieved from the used ABAP
function module.
Summary You have now learned how to use an on-premise ABAP
function module directly from a cloud application. If you want to
learn more about usage of JCo and RFC in the SAP HANA Cloud
Platform, have a look at following online resources: [1] Invoking
ABAP function modules via RFC protocol [2] SAP Java Connector
(Standalone Version)
-
6 SUMMARY AND FURTHER INFORMATION
In this Hands-on session you have practiced the usage of the SAP
HANA Cloud connectivity service to integrate an on-demand Web Shop
application with an on-premise ABAP system. This is a typical
scenario which shows how companies can use the cloud to build
extensions on top of their existing heterogeneous on-premise IT
landscape and integrate them via point-to-point connections. The
used Web Shop application is documented as a SAP HANA Cloud
Platform reference application in SDN: [1]
http://wiki.sdn.sap.com/wiki/display/EmTech/Developers+Scenarios+using+SAP+HANA+Cloud
[2] http://scn.sap.com/docs/DOC-41491 You can also try it out at
home. Thank you for participating in this SAP TechEd Virtual
Hands-On Workshop! Please, take a few minutes to answer a couple of
feedback questions concerning your session.
Find a shortcut to the survey on the desktop of your virtual
laptop image or visit
https://www.sapsurvey.com/cgi-bin/qwebcorporate.dll?idx=FSQCZ7
-
COPYRIGHT
2013 by SAP AG or an SAP affiliate company. All rights reserved.
No part of this publication may be reproduced or transmitted in any
form or for any purpose without the express permission of SAP AG.
The information contained herein may be changed without prior
notice. Some software products marketed by SAP AG and its
distributors contain proprietary software components of other
software vendors. National product specifications may vary. These
materials are provided by SAP AG and its affiliated companies (SAP
Group) for informational purposes only, without representation or
warranty of any kind, and SAP Group shall not be liable for errors
or omissions with respect to the materials. The only warranties for
SAP Group products and services are those that are set forth in the
express warranty statements accompanying such products and
services, if any. Nothing herein should be construed as
constituting an additional warranty. SAP and other SAP products and
services mentioned herein as well as their respective logos are
trademarks or registered trademarks of SAP AG in Germany and other
countries. Please see
http://www.sap.com/corporate-en/legal/copyright/index.epx#trademark
for additional trademark information and notices.