consuming data with hana xs

40
Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com Internet of Things Using SAP HANA Lesson Four: Consuming Data With HANA XS

Upload: blackvard

Post on 14-Apr-2017

438 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Consuming Data With HANA XS

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Internet of Things Using SAP HANA

Lesson Four: Consuming Data With HANA XS

Page 2: Consuming Data With HANA XS

Course Overview

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Release Date: March 18, 2016

Release Date:March 31, 2016

Coming Soon…

Now Available!

Internet of Things Using SAP HANALesson Four: Consuming Data With HANA XS

Learn More @ http://www.blackvard.com/iot-overview/

Release Date:April 14, 2016

Lesson One

•Introduction To Internet of Things

Lesson Two

•XS Trial Application Prerequisites & Setup

Lesson Three

•HANA XS Web Service

Lesson Four

•Consuming Data With HANA XS

Lesson Five

•Sample Application

Release Date:May 26, 2016

Page 3: Consuming Data With HANA XS

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Agenda

What Will Be Covered:

1. Consuming Data With HANA XS

1. Creating An OData Service

2. INSERT.XSJS Service

3. Granting Authorizations

4. Creating A Sequence

2. About us

Page 4: Consuming Data With HANA XS

Creating An OData Service (1/11)

Open Eclipse in Project Explorer view to access the connectivity project you created in lesson three of the Internet of Things Using SAP HANA: HANA XS Web Service.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 5: Consuming Data With HANA XS

Creating An OData Service (2/11)

Let’s create a new folder. Select the connectivity project; right-click on it. Follow menu path New - > Folder to begin creating a new folder.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 6: Consuming Data With HANA XS

Creating An OData Service (3/11)

Give the new folder the Folder name: services2, in order to distinguish the folder from user interfaces, server-side logic, etc.

Select the Finish button.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 7: Consuming Data With HANA XS

Creating An OData Service (4/11)

Now create an OData Service that will expose the business partner table. Begin by creating a new File. Select the services2 folder; right-click it. Follow menu path New - > File.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 8: Consuming Data With HANA XS

Creating An OData Service (5/11)

Name the File name: analysis.xsodata; click Finish.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 9: Consuming Data With HANA XS

Creating An OData Service (6/11)

Insert the Service Namespace Syntax seen below into the Eclipse text editor. Supply the namespace for documentation purposes, inside the services itself. Doesn’t control or generate anything in the system.

Add the OData service content; including the name of the database artifact you wish to expose (tables/views/analytic views, etc.).

For this lesson, in our schema, we have a table called ANALYSIS which we want to expose in this service.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 10: Consuming Data With HANA XS

Creating An OData Service (7/11)

After entering the syntax click Save.

Copyright © Blackvard Management Consulting – All rights reserved

www.blackvard.com

Page 11: Consuming Data With HANA XS

Creating An OData Service (8/11)

Now Commit the file syntax. Select the services2 folder, right-click it. Follow menu path Team - > Commit to commit the syntax to the repository

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.comwww.blackvard.com

Page 12: Consuming Data With HANA XS

Creating An OData Service (9/11)

Now Activate it. Select the services2 folder; right-click it. Follow the menu path Team - > Activate.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 13: Consuming Data With HANA XS

Creating An OData Service (10/11)

We’re ready to test the service in our web browser, using the URL below. https://s12hanaxs.hanatrial.ondemand.com/p1941908884trial/zhanaxs/connectivity/services2/analysis.xsodata/

The screenshot below displays a document, listing a small definition file that shows the name of the exposed entities in very simple XML documentation.

You can expose multiple entities & relationships between entities (e.g. All Columns, etc.).

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 14: Consuming Data With HANA XS

Creating An OData Service (11/11)

Add /$metadata to the URL to inspect the service interface & data types. https://

s12hanaxs.hanatrial.ondemand.com/p1941908884trial/zhanaxs/connectivity/services2/analysis.xsodata/$metadata

Other programming languages can utilize the service interface and gather all the required information needed to dynamically call and process the service.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 15: Consuming Data With HANA XS

Creating INSERT.XSJS Service (1/9)

Let’s create the INSERT.XSJS service; return to the Project Explorer view. Select the services2 folder again, right-click it. Follow menu path New - > File.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 16: Consuming Data With HANA XS

Creating INSERT.XSJS Service (2/9)

Insert the File name of: insert.xsjs; click Finish.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 17: Consuming Data With HANA XS

Creating INSERT.XSJS Service (3/9)

Insert the following XSJS JavaScript coding into the Eclipse text editor. NOTE: This is quite a bit of coding, so let’s review what each line of the

text communicates to the system. See lines 1 – 12 below, with explanation:

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Lines 1 - 12: This function getRequestParameters() will parse each URL parameter and store them in an Array.

This array list will be returned.

Page 18: Consuming Data With HANA XS

Creating INSERT.XSJS Service (4/9)

See lines 13 – 32 below, with explanation:

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Lines 13 – 32:The function doGet() calls the previously defined method getRequestParameters() to get a list of all URL parameters from the provided URL string.

In the next step, we are ensuring that each paramsObject itself is not empty, and then we ensure that each of its attributes: tour, car, alt, and long are NOT empty or not provided.

If they do not contain any data (“ .length <= 0”) or were not provided ( == NULL), we abort this script.

Page 19: Consuming Data With HANA XS

Creating INSERT.XSJS Service (5/9)

See lines 33 – 46 below, with explanation:

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Lines 33 – 46: If our given URL string contains all required parameters and values, we create a new output in Line 33 and initialize the data within Line 34.

In Line 35, we create a new timestamp.

Line 36, we prepare our database connection that executes in Line 37, including mapping to our own SCHEMA.

In Line 38, the SQL statement is prepared, which will insert the values in the table ANALYSIS.

Notice the sequence id_seq_2. This is our first column value. The four question marks are placeholders for the upcoming values we are providing in Lines 42 to 45.

Page 20: Consuming Data With HANA XS

Creating INSERT.XSJS Service (6/9)

See lines 47 – 60 below, with explanation:

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Lines 47 – 60:In Line 47, we execute the entire command that has been prepared before. A final commit, in Line 48, for our database statement will persist the data in the database.

Line 49 creates a new Array and in the Lines 50 – 53, we push each parameter at the end of the Array.

Line 54 will print all the previously added parameters for the user (in our sample, this is not required).

Finally, in Line 55, we close the entire database connection and show with the statement in Line 57 that everything was successfully inserted in the table.

Page 21: Consuming Data With HANA XS

Creating INSERT.XSJS Service (7/9)

See lines 61 – 66 below, with explanation:

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Lines 61 – 66:This is our main program call. We only allow GET URL parameters (just in case you want to exclude POST).

If we receive a GET call, and only then, the main method doGET() is called, and will start the parsing process.

Otherwise, we abort and return an error.

Page 22: Consuming Data With HANA XS

Creating INSERT.XSJS Service (8/9)

After inserting the XSJS JavaScript coding, click the Save icon to save it.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 23: Consuming Data With HANA XS

Creating INSERT.XSJS Service (9/9)

Click the Activate SAP HANA Development Object icon to activate the service.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 24: Consuming Data With HANA XS

Granting Authorizations (1/4)

Now Grant an Authorization to the user (INSERT rights to PUBLIC). Please note: granting public rights could be a security risk within your organization.

Return to the Systems view, select your system; right-click it. Select Open SQL Console.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 25: Consuming Data With HANA XS

Granting Authorizations (2/4)

In the SQL Console, enter the coding seen below. Please note: granting public rights could be a security risk within your organization.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 26: Consuming Data With HANA XS

Granting Authorizations (3/4)

Right-click on the coding, & select Execute to execute the SQL script.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 27: Consuming Data With HANA XS

Granting Authorizations (4/4)

A confirmation message that the statement was successfully executed appears.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 28: Consuming Data With HANA XS

Creating A Sequence (1/8)

Now Create a Sequence. In Systems view, select the SAP HANA Administration Console perspective. If it is not already open, click the Open Perspective icon to open it.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 29: Consuming Data With HANA XS

Creating A Sequence (2/8)

Scroll down to SAP HANA Administration Console. Select SAP HANA Administration Console. Click OK to open that perspective.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 30: Consuming Data With HANA XS

Creating A Sequence (3/8)

Return to the Systems view in Eclipse. In your project, follow the menu path: Catalog - > <Your SAP HANA Cloud

Developer ID> - > Sequences.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 31: Consuming Data With HANA XS

Creating A Sequence (4/8)

To create the new sequence, select the Sequences folder, right-click it. Select the New Sequence option.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 32: Consuming Data With HANA XS

Creating A Sequence (5/8)

Enter the Sequence Name as ID_SEQ_2. Enter the Start with value as 1. Enter the Increment By value as 1. Enter the Minimum Value as 1.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 33: Consuming Data With HANA XS

Creating A Sequence (6/8)

Click the green Execute icon to execute the new sequence.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 34: Consuming Data With HANA XS

Creating A Sequence (7/8)

The below success message will appear, letting you know the sequence has been successfully added.

Also, the ID_SEQ_2 sequence now appears in the Sequences folder.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 35: Consuming Data With HANA XS

Creating A Sequence (8/8)

Ensure the sequence values have been added successfully. Call the following URL in your web browser:

https://s12hanaxs.hanatrial.ondemand.com/p1941908884trial/zhanaxs/connectivity/services2/insert.xsjs?car=2&tour=1&alt=1&long=1

The “Data inserted successfully!” message should appear.

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Page 36: Consuming Data With HANA XS

Success – You Completed The Lesson!

10/10Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Congratulations, you completed the lesson!

In this lesson you successfully learned: – Consuming Data With HANA XS

• Creating OData Service• INSERT.XSJS Service• Granting An Authorization• Creating A Sequence

Page 37: Consuming Data With HANA XS

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Want to learn more about connecting your devices?

Contact us today for your FREE consultation with our experts.

Email: [email protected]

Require A Consultation?

Page 38: Consuming Data With HANA XS

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Technical project leads and ABAP architects responsible for quality in technical scope and budget in global roll-outs of SAP Logistics applications (SAP LE / LO)

Conducted multiple SAP ABAP, SAP HANA®, and SAP Fiori® trainings for various US companies

Implementation of a standard SAP software solution for Spend Management within SAP AG & ARIBA (annual spend volume 3 Bill. EUR) which can be used in all SAP systems

Improved claims management using SAP FS-CM which is generating annual savings of 15 Mio € for a huge German public healthcare organization

Implemented a global solution for procurement processes at BMW AG using SAP SRM / B2B

Blueprinting and implementation of SAP software for banking credit cancelations for VOLKSWAGEN

Key Achievements of Blackvard Management Consulting in Previous Projects

What We’ve Accomplished

Page 39: Consuming Data With HANA XS

Blackvard Management Consultants

www.blackvard.comCopyright © Blackvard Management Consulting – All rights reserved

Short Bio:

Lukas M. Dietzsch is managing director at Blackvard Management Consulting, LLC. He is holding a Master’s degree in Information Technology and is an experienced IT solution architect and project lead.

His strong background in adapting to requirements and standards in different industries and on various platforms are valuable assets for Blackvard customers.

He is repeatedly commended by customers for driving efficient solutions for complex problems in globally distributed team environments and meeting tough deadlines.

For further information please visit:

www.blackvard.com

Lukas M. Dietzsch

[email protected]

Copyright © Blackvard Management Consulting- All rights reserved www.blackvard.com

Managing Director

Page 40: Consuming Data With HANA XS

Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

An overview of current and previous customers:

Customers That Recommend Blackvard