As CRUD operations are possible in SAP UI5 using XSJS services (SAP HANA as database) but as per new versions of Odata Model these operations are possible through ODATA. It reduces considerable lines of code and makes SAP UI5 more friendly for developers.
Following artifacts are used in this Document-
Let us have a look on SAP UI5 Application used in this Demo. Please note that coding part of this application is not discussed here, As this article is focussed only on CRUD operations:
Home Screen of Application
Odata Service
service {
"SCHEMA"."DATA" as "DATA”;
}
Odata READ Operation:
It is simplest operation and already widely used in development. For this, a OdataModel is to be instantiated in Application. Then this Model is to be bind to UI Element, here, Table
var oModel = new sap.ui. model. odata. ODataModel("DATA.xsodata");
Note: Service Path may be different with respect to your package Structure.
This Odata service will load complete data of HANA Table in UI5 Application.
Odata CREATE Operation:
Once user click on “ADD” button on Home Screen, a Dialog will open for New Entry creation in table
Once user Clicks on “Add” in Dialog, it will trigger a function in Controller-
Odata UPDATE Operation:
For this, Use has to select a row to be updated. The values of that row will appear in UPDATE Dialog in editable input fields.
Once user changes values, new values will be updated in HANA Table on clicking “Update” icon, which will call a function as –
Function(odata){} will be be called if Update is successful otherwise, Function(err) will be called. You can show any message in these function (Message Box usage is not mandatory).
Both Success & Error functions are optional to be defined.
Odata DELETE Operation:
For this operation, more than 1 row can be selected simultaneously to be deleted. Once those rows are selected “DELETE” button will trigger a function as-
aBatchtoDelete will hold ‘sPath’ of rows to be deleted. createBatchOperations are performed to Create/Delete Multiple records simultaneously. For more properties, please refer API Reference.
_____________________________________
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
37 | |
10 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
2 | |
2 |