Quantcast
Channel: SAP Gateway
Viewing all articles
Browse latest Browse all 253

Build a SAPUI5 app with the AppBuilder consuming a NW Gateway service - series 2 of 2

$
0
0

Thanks for moving on to the 2nd blog in this series. For those just joined; this blog is the second in a serie of 2. The first can be found here. In the first blog we build a NetWeaver Gateway service exposing flight data.

In this 2nd part we will consume this data in a mobile app. We will build this app with the just released appBuilder. A WYSIWYG editor which is one of the ways to build a SAPUI5 application. The first time I saw the AppBuilder in a real live demo was when it was presented and demo-ed by Roel van den Berge on the SAP Inside Track Netherlands 2013.

 

Of course there are also other ways to build a SAPUI5 app. Since this blog assumes no handson experience yet with SAPUI5 or NetWeaver Gateway. The appBuilder is an easy way to get aquanted with the topic.

 

Install appBuilder

 

No need to repeat, it is all explained here; Installation is real easy. Basically it means; install node.js and download and run the appbuilder.

The editor runs in your browser.

 

Create project

 

Start the appbuilder, and it will open a url similar to this in your browser:


startscherm.JPG

A start screen will appear with several test apps and also the option to create a new project.

 

Create a new project for a tablet;

 

2. create project.JPG

 

After creating the project in the appbuilder, you will see an empty ipad screen.

Before we can show data on here we need to define the datasource.

 

Define datasource

 

To consume data we need to define the OData service from part 1 of this blog series as a datasource;

 

Open the pane on the left to view datasources. Use the 'new datasource' button to add a new one.

 

Use the full url to your service (without filter or collection).

Note:This is service we tested in the gateway client in blog series 1. To get the full url including hostname, go to your gatewaysystem and use /iwnfd/maint-service and use 'call in browser' to get the full url to your service.

 

Example

http://<NetWeaver GatewaySystemHost>:<Port>/sap/opu/odata/sap/ZSCN_FLIGHTDEMO_SRV

 

4a create datasource odataservice.jpg

 

Define superlist metadata

 

To show the list of flight on the screen we need to connect our datasource to a superlist. The first step for a superlist is to define the superlist metafile.

Create it via the 'designers' menu on top.

 

5.JPG

 

6 create superlist.JPG

 

A superlist .slmeta file is added into our project, it can be further configured by checking the right pane and click on datastructure.

7. open datastructure in right panel.JPG

 

We need to select the datasource first, this is our ODataService flight with in there, the FlightSet.

 

8 select datasource.JPG

Select and add columns

 

Select the columns which you would like to add to your list view.

Select them by choosing the 'label' control for those columns, leave the others to 'none'.

Do pick 'label' for: curr/ price/ deptime/ cityto / cityfrom / flightdate / airline

 

select fields.png

 

After clicking confirm,view the right pane and set the alignment to 'horizontal' instead of 'vertical'

10 set alignmetn to horizontal.JPG

 

In the middle of the browser screen we see the layout of the future listscreen

Select the flightdate column and view its properties in the right pane.

Set it to these values;

 

11 reorder columns and click per field example for flightdate.JPG

Reorder the columns (by drag and drop on the screen) to the following order. And also set the width on the other columns:

1) flightdateset 'flightdate' to dateformat: 'shortdate', width 12%

2) depttime to width 10%

3) airline to 12 %

4) cityfrom to 18%

5) city to 20%

6) price to 8%

7) curr to  4%

 

Hint: Since we already connected the data to the screen, you could already press preview to get an indication how your list will look showing flight data.

 

Add an image

 

Click on 'save' and 'return'.

This will return you the 'home' screen.

In left pane select 'project' and browse to the 'img' folder and select this.

In the 'file' menu upload a picture to show along the flightlist.

12 upload image.JPG

Again in the project in the left pane, browse through our files and select the flightlist.slmeta and open it.

 

In the left pane select the image icon, and drag it onto the superlist table and position it as it is the most left column.

 

12b add img tag ontolist.JPG

 

Select the image when it is dropped onto the screen and view its properties in the right pane.

 

Click the button at the 'src' property and in here set the path to your image in the \img folder.

 

13 set image to image on slmeta.JPG

Set the 'width' of the image to 3%

 

 

We can preview the data now including our image. It will look like this;

 

14 preview slmeta incl image.JPG

 

 

The superlist meta definition is fully done now. 'Save' and press 'return' to move back to the home screen.

 

Add the list to the homepage

 

Check in the project on the left and browse to the 'view' folder and make sure the HomePage.view.html screen is currently opened (blue).

14b move back to homescreen.JPG

 

In the toolbox menu select the superlist icon and drag it onto the homescreen. Adjust the size to the surround screen.

 

15 in the toolbox, add a superlist to the home screen by dragging.jpg


View the superlist element properties in the right pane and click on the select metafile.

Select your flightlist.slmeta file and use confirm.

 

16 in the right pane, view the superlist properties and select the metafile by clicking and choosing your flightlist-meta. jpg.JPG

 

The page will refresh now and it will show the flightlist on the homescreen.

 

Test

 

Click on 'run' in the top right of the window.

It will open in a new browser window and give you the ability to view portrait or landscape mode and zoom in or out.

 

The result will look like this:

 

end result.png

 

Closure

 

Congratulations (again) on succesfully completing these steps! Thanks for reading until the end of this blog. Thanks for joining this blog series,

 

Stay tuned for more on SAPUI5 and NetWeaver Gateway.

 

Shout out to Twan van den Broek Yes, scrollable it is.


Viewing all articles
Browse latest Browse all 253

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>