SAPUI5 Getting Started (SAP HANA): Unterschied zwischen den Versionen
Matt (Diskussion | Beiträge) |
Matt (Diskussion | Beiträge) |
||
Zeile 67: | Zeile 67: | ||
|} | |} | ||
== App Skeleton for | == App Skeleton for OData from SAP == | ||
Source: https://github.com/SAP-samples/hana-xsa-opensap-hana7/blob/snippets_2.3.2/ex4/odataBasic.zip | Source: https://github.com/SAP-samples/hana-xsa-opensap-hana7/blob/snippets_2.3.2/ex4/odataBasic.zip | ||
Tasks to be done: | The file contains all necessary subfolders and should be imported in your project into this module: | ||
/web/resources | |||
This will create a subfolder for the skeleton app named: | |||
/web/resources/odataBasic | |||
Tasks to be done in order to bind an OData service to the skeleton app: | |||
{| class="wikitable" | |||
! File !! Section !! Task | |||
|- | |||
| manifest.json || "sap.app" || | |||
* Specify data source | |||
* Define model | |||
|- | |||
| manifest.json || "models" || | |||
* Create model | |||
* Bind model to data source defined above | |||
|- | |||
| controller/App.controller.js || onInit || | |||
* Set model created above to oTable table control | |||
* Specify visible fields for SmartTable | |||
|} | |||
== Text Bundles == | == Text Bundles == |
Version vom 25. November 2020, 16:44 Uhr
This page contains basic knowledge on how to start with SAPUI5 development on SAP HANA development stack and also how the SAPUI5 application looks like.
SAPUI5 App Structure
We create an app odataView. All of its files will be located inside
/web/resources/odataView/
Content:
Relative Path | File | Function |
---|---|---|
./ | index.html |
|
./ | Component.js |
|
./ | manifest.json |
Specifies:
|
./i18n/ | i18n_en.properties |
|
./view/ | App.view.xml |
Contains:
|
./view/ | MRead.fragment.xml |
Contains:
|
./view/ | MTableHead.fragment.xml |
|
./view/ | MTableItem.fragment.xml |
|
./controller/ | App.controller.js |
Contains methods:
|
./controller/ | Base.controller.js |
Base controllers can contain functions and share them to multiple app controllers. |
./model/ | formatter.js, grouper.js, GroupSortState.js, models.js |
Model subdirectory contains reusable functions like formatters |
App Skeleton for OData from SAP
Source: https://github.com/SAP-samples/hana-xsa-opensap-hana7/blob/snippets_2.3.2/ex4/odataBasic.zip
The file contains all necessary subfolders and should be imported in your project into this module:
/web/resources
This will create a subfolder for the skeleton app named:
/web/resources/odataBasic
Tasks to be done in order to bind an OData service to the skeleton app:
File | Section | Task |
---|---|---|
manifest.json | "sap.app" |
|
manifest.json | "models" |
|
controller/App.controller.js | onInit |
|
Text Bundles
Text bundles are best located in a subfolder of:
/web/resources/
Contents:
Relative Path | File | Function |
---|---|---|
./i18n/ | messagebundle.properties | Default language message bundle |
./i18n/ | messagebundle_de.properties | Language DE message bundle |
Add code:
/* Language Resource Loader */
jQuery.sap.require("jquery.sap.resources");
var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
var oBundle = jQuery.sap.resources({url: "./i18n/messagebundle.properties", locale: sLocale});
// create the button instance
var myButton = new sap.m.Button("btn");
// set properties, e.g. the text (there is also a shorter way of setting several properties)
// myButton.setText("Hello World!");
myButton.setText(oBundle.getText("helloworld"));
Listing: https://github.com/mattxdev/opensap-hana7/blob/master/web/resources/index.html
Local SAPUI5 Micro Service
SAPUI5 libraries can be used from the public SAPUI5 libraries.
Since SAP HANA 2.0 SPS 03 XS Advanced is capable of providing a micro service itself for local consumption.
A local micro service can be created either in XS Advanced Cockpit at
- HANAExpress -> development space -> Services -> Service Marketplace -> sapui5_sb
or via command line with:
xs create-service sapui5_sb sapui5-1.52 openSAPHANA_00-ui5
The service has to be added in:
Path | File | Function |
---|---|---|
/ | mta.yaml | Create new resource and add it to modules |
/web/ | xs-app.json | Use replace capability of app router to insert UI5 service URL dynamically |
/web/ | index.html | Fetch bootstrap from resource by utilizing variable |