Using Data Types 

Objectives
After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Define data types
  • Discover different data types
  • Explain the benefits of data types

Data Types

Data types let you define the type of data you will store in a variable and, therefore, the type of data you expect whenever you update the data in that variable.

For example, if you have a variable that stores the color the user wants for the background, then the data type of the variable would be of type color. You will get an error if you try to store a value not of type color (for example, "#435647") in that variable.

If you have a variable that stores the name of a new To Do item, then the data type of the variable would be of type text, representing the name of the To Do item.

When you define a new variable, you can define the type of the variable on the right side.

Note that data types are used not just for variables but also to define schemas–or the data types and organization of larger sets of data–for data resources. There are fewer data types available for data resource schemas.

Different Data Types

Here are the currently supported data types divided into four groups.

Choose each Data Type to learn more.

Importance of Data Types

Why is it important to define variables with the right data type?

With the correct data type, SAP Build Apps will check whether you are assigning the correct data for that data type. Generally, SAP Build Apps does not prevent you from storing a value that does not conform to the data type, but it will warn you that something is wrong.

For example, if you have a variable of type Number, you could still assign it "Apple" and that value will display. But SAP Build Apps will warn you.

The data types are especially important in two areas: Property Editor and Formula Editor.

Property Editor

When setting values for a variable, the property editor will give you an interface designed for that type. Let’s consider that you have a variable of type Color.

In the example value, you will get a user interface, especially for defining color.

The same would be true if you were setting its value in a flow function in the logic canvas.

Formula Editor

Similarly, the formula editor takes note of the data type and warns you if the result of the formula conforms to the data type of the current property.

Let’s say you have a button and want to use a formula to set the color of the button text.

If the formula does not conform to the data type, the formula editor will display a warning, and the formula will be displayed in red. Also, note that the formula editor at the top shows what data type it expects.

Note that the Save button is still enabled, so you are not prevented from using the formula. Since the data type says to expect a color, you are warned, but SAP Build Apps does not want to tie your hands in case there is a reason you want to set the color variable to a plain string.

Log in to track your progress & complete quizzes