SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Consume a Basic OData Service

Consume a Basic OData Service within UI5 binding the service to a Table

Overview

🎓 intermediate 15 min. SAP HANAIntermediateHTML5OdataSapui5Express Edition
Thomas Jung T Thomas Jung November 1, 2022
Created by September 6, 2016
Contributors

Prerequisites

Prerequisites

  • This tutorial is designed for SAP HANA on premise and SAP HANA, express edition. It is not designed for SAP HANA Cloud.
  • Proficiency: Intermediate
  • Tutorials: SAPUI5 User Interface

Steps

Step 1 Import Template Project
โ€”

We have prepared a skeleton application for you with several sections that need to be completed marked To-Do.

Import this this template into web/resources folder from the following URL: https://github.com/SAP-samples/hana-xsa-opensap-hana7/raw/snippets_2.4.0/ex4/odataBasic.zip

Create a folder named odataBasic within the web/resources folder

new folder
new folder

new structure
new structure

After the import, please check to see if you have a /web/resources/common folder with a file startup.js within it. This could have been created earlier if you completed tutorial SAP HANA XS Advanced - Asynchronous Non-Blocking I/O within Node.js SAP HANA applications. If you do not have this file, you can create it now without having to perform the entire previous tutorial. Here is the source code of startup.js.

JavaScript
/*eslint no-console: 0, no-unused-vars: 0, no-use-before-define: 0, no-redeclare: 0, no-shadow:0*/
function onLoadSession(myJSON) {
	try {
		var result = JSON.parse(myJSON);
		if (result.session.length > 0) {
			if (result.session[0].familyName !== "") {
				return result.session[0].givenName + " " + result.session[0].familyName;
			} else {
				return result.session[0].UserName;
			}
		}
	} catch (e) {
		return "";
	}
	return "";
}

function getSessionInfo() {
	var aUrl = "/node/getSessionInfo";

	return onLoadSession(
		jQuery.ajax({
			url: aUrl,
			method: "GET",
			dataType: "json",
			async: false
		}).responseText);
}

function localShellStartup(name) {

	sap.ui.getCore().attachInit(function () {
		var ComponentContainer = new sap.ui.core.ComponentContainer({
			height: "100%"
		});
		var username = "Test User";
		// create a shell
		new sap.ui.unified.Shell({
			id: "myShell",
			icon: "/images/sap_18.png",
			headEndItems: new sap.ui.unified.ShellHeadItem({
				icon: "sap-icon://log",
				tooltip: "Logoff",
				press: function () {
					window.location.href = "/my/logout";
				}
			}),
			user: new sap.ui.unified.ShellHeadUserItem({
				image: "sap-icon://person-placeholder",
				username: username
			}),
			content: ComponentContainer
		}).placeAt("content");

		var oComponent = sap.ui.component({
			id: "comp",
			name: name,
			manifestFirst: true,
			async: true
		}).then(function (oComponent) {
			ComponentContainer.setComponent(oComponent);
		});

	});
}
Step 2 Understanding the code - fill in the `To-Dos` to create a model from a data source
+
Step 3 Fill in the `To-Do` in the controller
+
Step 4 Save and Run
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 4
1. Import Template Project 2. Understanding the code - fill in the `To-Dos` to create a model from a data source 3. Fill in the `To-Do` in the controller 4. Save and Run

Learn more →