Explaining the Need for Variables

Objectives

After completing this lesson, you will be able to:

  • Describe the need for variables
  • Discuss the key use cases for variables

Variables

Variables provide a place in your app to store temporary data until you need to display or read it or send it somewhere else, for example, to a back-end system.

For example, let's consider that you have an application that is a calculator. You will need to store the operands (the numbers the user enters to be added or multiplied) and the result of the calculation. Once the data is stored in a variable, you can display the answer in a text field so the user can see the result.

You can use the variables to store:

  • Data retrieved from an external data resource
  • Information about the current user (such as name, E-mail)
  • User’s preferences for the app while the app is running (such as preferred home page, favorite baseball team)
  • Information about the current product that is being displayed on the current page

Key Use Cases for Variables

Types of Variables

SAP Build Apps includes different types of variables for various purposes.

Types of Variables

TypePurpose
App VariableIt is used to store the information that needs to be accessible throughout the app.
Page VariableIt is used to store the information that needs to be accessible only for the current page.
Page ParameterIt is used to store the information that is required to open the current page. For example, if you have a product details page that displays information about the current product, the page requires an ID for the product to display its data.
Data Variable

It is used to store the information retrieved from an external data resource. A data variable can be configured to either store a single record or a list of records.

Page parameters and data variables have specific use cases, but app variables and page variables essentially store data. You may wonder when you use one or the other.

You could store all your data in app variables, but all app variables are display together, and you might have so many that it would be difficult to keep track of your long list of app variables.

It would be easy for you–and anyone helping you develop your app–to store the data you need for individual pages in those pages and not lump them together as app variables. This way, each page could manage its own page variables, and you would better know the purpose of each variable.

Define Variables

The default state of a page is View, which shows the layout of the page with all its components. If you want to define variables, change the state to Variables.

Changing the Status

Here you will find a place to define the different types of variables. Choose the type and then choose ADD APP VARIABLE to start defining a variable.

Choosing ADD APP VARIABLE

Log in to track your progress & complete quizzes