Open the file index.html under resources. You will find the default code creates a button that fades away when pressed
Default code
Remove the logic for the button
Default code
Step 2Bind the OData model to a table
+
In this previous tutorial, you created an XSJS compatible Node.js module to expose an OData V2 service that provides data from your database module. Consuming that model using SAP UI5 is simplified thanks to the concept of binding.
Take a look at the output of the OData service in JSON format
OData model
Add the following script to your index.html file, where the logics for the button used to be.
JavaScript
<script>varoModel=newsap.ui.model.odata.v2.ODataModel("/xsodata/purchaseOrder.xsodata",true);varoTable=newsap.ui.table.Table({title:"My first table"});oTable.addColumn(newsap.ui.table.Column({label:"PO ID",template:"PURCHASEORDERID"}));oTable.setModel(oModel);oTable.bindRows("/POHeader");oTable.placeAt("uiArea");</script>
More about binding
You are using an OData model that will load data as required by the client and delegate the sorting and filtering operations to the server-side. This model will provide the data from the service you defined before. You are then creating a table and binding the model to the table, so that all changes in the data are reflected also in the table. Check the Help for more information about SAPUI5 and binding
Save and run the HTML5 module. You should get an error. Press F12 in your browser and look at the errors in the console.
Error for validation
Step 3Add missing libraries
+
You can see the available libraries in the Sources tab in the panel. Notice the resources that are loaded:
UI5
Go back and look at the code in index.html .
You are using sap.ui.table and sap.ui.model to display the table. If you compare the libraries you are using to the libraries that are loaded, you will see sap.ui.table is not present as a resource. This is why you are getting the error in the console.
More about these libraries
You will see there is a reference to sap-ui-core.js, a control library (sap.m) and a theme, sap_bluecrystal.
sap-ui-core.js is the bootstrap file for SAPUI5, it contains the minimum required parts of the core library. This will load and initialize the SAPUI5 library as soon as the script is executed by the browser. After its initialization, and because it has been added by default in the index.html, the library sap.m is loaded, together with its dependencies.
Add sap.ui.table to the index.html file as a required library.
UI5
Save and run the web module again. You should see the table with results. Additionally, if you refresh while in the Network tab, you will see the requests, the sequence in which they are called and how long it takes them to load.
UI5
Step 4Add the SAPUI5 service as a dependency
+
Just like with the UAA service, you want to bind the instance you have created to your Multi-Target Application. Open the MTA.yaml file and click add a new resource called ui5.
Use org.cloudfoundry.managed-service as the type and the following key-value pairs under parameters for HANA 2.0 SPS04 (for other releases, use the xs marketplace command to view the available service-plans):
service : sapui5_sb
service-plan : sapui5-1.60
New UI5
Where are the values coming from?
The name of the service instance, the type of service and service plan are use to bind the instance of the UI5 service to the web module. You can see these values under Service Instances in the XS Advanced cockpit or by listing them using the XS CLI with command xs services
Save the yaml file and navigate to the resources tab. Use the drop-down menu to choose the newly created resource.
New UI5
Step 5Adjust the AppRouter replacement
+
Open the file xs-app.json and add the following code at the end of the route declarations
You will need to add a comma before adding the new route with the replacement values, the full file looks as follows:
New UI5
Save the file
What does this mean?
Take a look at the package.json file. You will notice a node module,approuter.js, is called. This module will read the file xs-app.json, use the welcomeFile value to redirect to index.html by default, and interpret the routes requests should take according to the regular expressions in the source key.
It can also replace placeholders in static text resources, such as a placeholder for the URL to the UI5 service in index.html. In this case, the AppRouter finds the service with tag ui5 like you created in step 4, bound to the web application. If you use command xs env APP, where APP is the name of your web application, you will see the configuration details for the UI5 service.VCAP_SERVICESYou can find more information about the AppRouter in the SAP Help portal
Step 6Call the micro-service in your HTML file
+
Open the index.html file and replace the remote URL with the variable {{{sapui5_sb.url}}}.
New UI5
Save and Run the index.html file.
Right-click on the site and use the view source option to see the replacement:
Replacement
Press CTRL + SHIT + ALT + S and wait for the diagnostics window.
Share feedback on this tutorial or join the conversation in SAP Community.
Submit detailed feedbackDiscuss in Community
Steps
Step 1 of 6
1. Remove the default scripts2. Bind the OData model to a table3. Add missing libraries4. Add the SAPUI5 service as a dependency5. Adjust the AppRouter replacement6. Call the micro-service in your HTML file
Joule
AI Notice
Joule is an AI assistant. Generative AI may produce inaccurate, incomplete, or biased information. Always verify important details before acting on them.
Conversations are sent to SAP-hosted large language models for processing. Do not include personal data, credentials, or confidential information in your messages.
Joule's responses are based on the SAP tutorial catalog and may not reflect the latest product changes. For authoritative guidance, consult the linked tutorials and official SAP documentation.