Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
jeroenvandera
Contributor

openSAP: Next Steps in Software Development on SAP HANA – my thoughts after week 4

This week we looked at OData and ways to consume the data. The OData protocol allows you to create, read or update  and delete data via an URL.

The OData protocol is a powerful part as it is an endpoint that allows access to the SAP HANA data database. This access can be from a xsjs or html file on the HANA server, but it can also be from somewhere else.

Source: OData.org

In SAP HANA you have functions to do aggregations, can define associations, associations can be picked up later by SAPUI5 components for added functionality. (look for the purchase order header and item sample)

And typical for sap was also the OData4SAP Annotations. Typical as when you enable this extension it will deliver you the label, the unit and the text (but not the currency)

What I don’t remember from the initial HANA course, but apparently available since SP06 are SQLSCRIPT extensions. These extensions are procedures that are triggered by the OData service. The input is basically the data that is passed from the OData service i.e. the new to be created record or the update of a record.

What you can do in the trigger is validation, but if you want you can get creative and think of other things such as an online ticket sales procedure that checks the timestamp of the order to look which place in the virtual line the prospect buyer has for the final ticket of that important concert of <insert your favorite music here>

This is an improvement over the earlier version as I can remember that previously you had either a straight OData service with nothing else or a xsjs service.

Another part of this week was Batch requests and deep insertions. The latter was interesting as this provided a way to maintain relationships between two tables. For example if you have purchase order headers and items, the item table needs the foreign key ordernumber to keep a relation to the header file.

The deep insert functionality creates an ID place holder that will be replaced by the actual ordernumber ID in the end. It’s a shame that SAPUI5 doesn’t support it yet. The example was a concatenation of string variables to manually create an OData Request.

Exercises:

In this week we had to type A LOT for the exercises. (I know you can cut&paste but I like to type it in at least for a part, to better digest the lessons).  Especially interesting was using the SAPUI5 for creating a table using the OData source. It takes a little getting used to as the entire setup of SAPUI5 is that you declare variables based on objects.

You set properties in a Json variable :


Var myButtonproperties = ({text:"Hello World!",tooltip:"Hello Tooltip!"}

Then you create a new instance using those properties :

var myButton = new sap.ui.commons.Button (myButtonproperties);

you can set properties via methods :

myButton.setText("Hello World!");

and finally you can attach functions to events :


myButton.attachPress(function(){$("#btn").fadeOut()});

and if you want to have more buttons you can try something like this :           


var namearr = ["btn1", "btn2", "btn3"];
                var textarr = ["text1", "text2", "text3"];
                var buttons = new array
              
                for (i = 0; i < namearr.length; i++) {
                                buttons.push(new sap.ui.commons.Button(namearr[i]));
                                buttons[i].setText(textarr[i]);
                                               buttons[i].attachPress(function(){$(namearr[i]).fadeOut();})}

This will give you an array of buttons that you can place all over your document.

But admittedly the last was a bit of playtime after the exercises J

Labels in this area