Calculation Builder

The calculation builder can be used to create complex expressions that combine numeric constants and variables with arithmetic and logical operators. The expressions can be entered using a visual editor or a text editor with three available layout options.

Usage

Use the calculation builder if:

  • You need to create or edit complex arithmetic expressions.
  • You need to define or modify business KPIs.
  • You need to keep the dependencies of the underlying calculations and to be able to expand them.

Responsiveness

The calculation builder is fully responsive, and uses 100% of the width provided by the container in which it is embedded. For size S, it is mandatory to use 100% of the page width.

Depending on the available width, the calculation content is broken into separate lines in order to keep the native vertical scrolling for the whole page.

Calculation builder - Size L
Calculation builder - Size L
Calculation Builder - Size M
Calculation Builder - Size M
Calculation builder - Size S
Calculation builder - Size S

Layout

The calculation builder provides three different types of layout:

  • By default, the header toolbar and both the visual and textual editors are displayed. The header toolbar includes a toggle button for hiding or displaying the textual editor.
  • Only the header toolbar and the textual editor are displayed, making the calculation builder a text-only control.
  • The header toolbar and visual editor are displayed. The header toolbar includes buttons for arithmetic and logical operators, as well as variables. The toolbar buttons show the user which operations and variables are supported.
Header toolbar + visual editor + textual editor (default)
Header toolbar + visual editor + textual editor (default)
Header toolbar + textual editor only
Header toolbar + textual editor only
Header toolbar (with operators and variables) + visual editor
Header toolbar (with operators and variables) + visual editor

Layout Examples

The following examples show how the different layout types appear on the UI.

Default layout
Default layout
Header toolbar with expression operators and textual editor
Header toolbar with expression operators and textual editor
Header toolbar with textual editor only
Header toolbar with textual editor only

Components

The calculation builder can include thee components:

  • A header toolbar
  • A visual editor
  • A textual editor

Header Toolbar

A – Title: Provides a short and meaningful summary of the expression.

B – Textual Editor Toggle: Enables the user to hide the Expression Output section and work with the visual editor only

C – Expand All Variables: Allows the user to expand all the variables included in the expression and see all the underlying calculations used to compose the variable.

D – Full Screen: Toggles the full screen view.

E – Divider Line: The divider separates the header toolbar from the content below.

Header toolbar
Header toolbar

Visual Editor

A – Functions: Functions require brackets. The initial bracket is automatically inserted after the function name. Only a limited subset of functions is supported by default. However, you can define any custom function you need using the API.

B – Variables: A custom set of available KPIs, such as revenue, assets, or expenses. KPIs are predefined by each application.

C – Constants: Enables user to type the values directly as standalone constants or as part of a function.

D – Operators: Arithmetic, logical, and comparison operators are available.

E – New Element: The default button of each expression triggers a dialog to add a new function, variable, operator, or constant.

Visual editor
Visual editor

Textual Editor

The textual editor contains a plain text representation of the expression entered in the visual editor.

If the user copies an arithmetic expression from an external application and pastes it to the textual editor, the expression displayed in the visual editor will be updated automatically. The same applies the other way round: if the user enters an expression using the visual editor, the textual editor gets updated, which can be used to copy the expression to an external application.

Textual editor
Textual editor

Behavior and Interaction

Inserting New Calculation Elements

The user has two options for adding an operator, constant, variable, function, or reference to an expression:

  • By clicking the New Element button
  • By typing it directly into the textual editor field, which makes it appear in the visual editor as well.

The New Element button triggers a dialog with the selection of all available calculation elements.

Developer Hint
You can customize the calculation elements available to your users, add custom functions, load a specific list of variables, or disable any of the default calculation elements.
Selecting a reference
Selecting a reference
'New Element' dialog
'New Element' dialog
Selecting a variable
Selecting a variable
Selecting a function
Selecting a function
Selecting an operator
Selecting an operator

Expanding Variables

There are two ways a user can expand a variable to see the underlying structure of the variable.

  • Expand an individual variable by clicking the Expand Variable button.
  • Expand all variables by clicking the Expand All Variables button in the header toolbar.

In both cases, a confirmation message is displayed warning the user that this action is irreversible and variables cannot be collapsed back.

When a variable is expanded, the user can also remove the dependency on the original variable, if needed.

Warning
Expanding a variable is currently an irreversible action, and the dependency on the original variable can only be restored if you insert the original variable again as a new calculation element.
Selecting a variable to expand
Selecting a variable to expand
Confirming the variable expansion
Confirming the variable expansion

Guidelines

When the default layout is used, displaying both the visual and textual editors, we advise against adding the editor buttons for operators, constants, functions, and variables to the header toolbar.

Resources

Want to dive deeper? Follow the links below to find out more about related controls, the SAPUI5 implementation, and the visual design.

Elements and Controls

Implementation

PDF Viewer

The PDF viewer control displays PDF documents within your app. It can be embedded in your page layout, or you can set it to open in a popup dialog. In addition, this control allows you to print and download the PDF documents it displays.

Usage

Use the PDF viewer control if:

  • You want your app to display PDF files on all devices and platforms.
  • You want the users of your app to be able to preview their documents as PDF files right inside your app.
  • You need to ensure the consistent behavior of PDF files across all SAP Fiori apps.
  • You need to work with events (loaded, validation, error) provided by the PDF viewer.

Do not use the PDF viewer if:

  • You need to provide an interactive PDF file (such as a data input form).

Responsiveness

The PDF viewer control is fully responsive on large-screen devices (size L). The range of responsive behavior available on desktop devices depends on the display mode.

  • When the PDF viewer opens in a dialog popup:
    By default, the dialog supports two or more actions, such as Close and Download. On large-screen (desktop) devices, the action buttons are right-aligned. Use compact mode to ensure optimal padding and margins on desktop devices.
    If the content height is increased beyond the screen height, the dialog height cannot go beyond 4 rem from the top and bottom of the screen.
    The dialog popup must be resized automatically and cannot support dragging or custom resizing.

 

  • When the PDF viewer is embedded in a container on the app page:
    The dimensions of the frame in which the PDF file is displayed are defined by the PDF viewer properties.
    The control in which the PDF viewer is embedded must have at least 1 rem (16 px) padding to set it apart from the rest of the content.
    Only vertical scrolling is allowed. The behavior of desktop touch devices should follow the default behavior of the device or platform.

On mobile devices (smartphones and tablets), the PDF viewer control renders a toolbar with the title and a download icon, which behaves as a standard device/browser file link.

If required, you can customize the behavior for mobile devices and trigger the default device action for the file link from a different anchor in the application.

Size L - Popup mode
Size L - Popup mode
Size L - Embedded mode
Size L - Embedded mode
Size M - Tablet
Size M - Tablet
Size S - Mobile
Size S - Mobile

Layout

Displaying PDF Files in a Dialog

The dialog is positioned in the center of the screen. It opens in a modal window to attract the user’s attention when it displays emergency states. The dialog consists of:

  • A dialog header
  • A dialog PDF content
  • A dialog footer

Displaying Embedded PDF Files

The secondary mode of the PDF viewer displays PDF files directly on the page. The application owner, using the PDF viewer control, provides the dimensions of the frame in which the PDF file is embedded. The container should have at least 1 rem (16px) padding from the other content on the page to allow users to distinguish between the embedded PDF and the rest of the page’s content.

When the PDF viewer is embedded on the page, it comprises:

  • An overflow toolbar header
  • A container for rendering the PDF file (determined by the application owner)
Schematic visualization of popup mode
Schematic visualization of popup mode
Schematic visualization of embedded mode
Schematic visualization of embedded mode
Developer Hint
The footer can be extended by any desired buttons. However, both the Close and Download buttons must be displayed. This is to ensure that the accessibility requirements are fulfilled. Additional information about action placement and order can be found in the Action Placement article.

Components

The PDF viewer in popup mode is rendered within a Dialog and consists of:

Title(Header): The title text appears in the dialog header.

Content: This area contains the actual PDF file displayed within the content of the dialog.

Footer with actions: The footer contains two mandatory buttons: Close and Download. Other actions can be added to the footer as well.

 

The PDF viewer in embedded mode can be rendered in any container desired by the application.

The title is displayed within the Toolbar (Overflow Toolbar).

Developer Hint
Use a Flexbox container to wrap the embedded mode of the PDF viewer inside the application.

Behavior and Interaction

All the interactions for the PDF files themselves must remain the same across platforms and browsers: paging, scrolling, zooming, and print must all be available.

Download – For accessibility reasons, the PDF viewer always provides an additional download button for downloading the displayed PDF file and gives users the option to download the embedded PDF renderer on a specific device or system (not all PDF reader plugins have their own download button).

Popup mode interactions:

  • No custom resizing of the dialog
  • No dragging of the dialog

Guidelines

To avoid the risk of performance issues, do not embed more than three instances of the PDF viewer per page. You may embed more instances of the PDF viewer in one page if the number of PDFs does not affect performance. Carry out benchmark tests to ensure that performance will not be affected.

The PDF viewer can be used within other sap.m components, such as carousel and panel, respecting the specific guidelines of these components.

The embedded mode of the PDF viewer can be used on the Object Page if the container is as wide as the object page. If this is not the case, use the popup mode of the PDF viewer instead.

The PDF viewer can provide accessibility options when used with screen readers and other accessibility software. To ensure that all the accessibility options are supported, you need to have Adobe PDF Reader installed.

Resources

Want to dive deeper? Follow the links below to find out more about related controls, the SAPUI5 implementation, and the visual design.

Elements and Controls

Implementation

Calculation Builder

The calculation builder can be used to create complex expressions that combine numeric constants and variables with arithmetic and logical operators. The expressions can be entered using a visual editor or a text editor with three available layout options.

Usage

Use the calculation builder if:

  • You need to create or edit complex arithmetic expressions.
  • You need to define or modify business KPIs.
  • You need to keep the dependencies of the underlying calculations and to be able to expand them.

Responsiveness

The calculation builder is fully responsive, and uses 100% of the width provided by the container in which it is embedded. For size S, it is mandatory to use 100% of the page width.

Depending on the available width, the calculation content is broken into separate lines in order to keep the native vertical scrolling for the whole page.

Calculation Builder - Size M
Calculation Builder - Size M
Calculation builder - Size L
Calculation builder - Size L
Calculation builder - Size S
Calculation builder - Size S

Layout

The calculation builder provides three different types of layout:

  • By default, the header toolbar and both the visual and textual editors are displayed. The header toolbar includes a toggle button for hiding or displaying the textual editor.
  • Only the header toolbar and the textual editor are displayed, making the calculation builder a text-only control.
  • The header toolbar and visual editor are displayed. The header toolbar includes buttons for arithmetic and logical operators, as well as variables. The toolbar buttons show the user which operations and variables are supported.
Header toolbar + visual editor + textual editor (default)
Header toolbar + visual editor + textual editor (default)
Header toolbar + textual editor only
Header toolbar + textual editor only
Header toolbar (with operators and variables) + visual editor
Header toolbar (with operators and variables) + visual editor

Layout Examples

The following examples show how the different layout types appear on the UI.

Default layout
Default layout
Header toolbar with expression operators and textual editor
Header toolbar with expression operators and textual editor
Header toolbar with textual editor only
Header toolbar with textual editor only

Components

The calculation builder can include thee components:

  • A header toolbar
  • A visual editor
  • A textual editor

Header Toolbar

A – Title: Provides a short and meaningful summary of the expression.

B – Textual Editor Toggle: Enables the user to hide the Expression Output section and work with the visual editor only

C – Expand All Variables: Allows the user to expand all the variables included in the expression and see all the underlying calculations used to compose the variable.

D – Full Screen: Toggles the full screen view.

Visual Editor

A – Functions: Functions require brackets. The initial bracket is automatically inserted after the function name. Only a limited subset of functions is supported by default. However, you can define any custom function you need using the API.

B – Variables: A custom set of available KPIs, such as revenue, assets, or expenses. KPIs are predefined by each application.

C – Constants: Enables user to type the values directly as standalone constants or as part of a function.

D – Operators: Arithmetic, logical, and comparison operators are available.

E – New Element: The default button of each expression triggers a dialog to add a new function, variable, operator, or constant.

Textual Editor

The textual editor contains a plain text representation of the expression entered in the visual editor.

If the user copies an arithmetic expression from an external application and pastes it to the textual editor, the expression displayed in the visual editor will be updated automatically. The same applies the other way round: if the user enters an expression using the visual editor, the textual editor gets updated, which can be used to copy the expression to an external application.

Header toolbar
Header toolbar
Visual editor
Visual editor
Textual editor
Textual editor

Behavior and Interaction

Inserting New Calculation Elements

The user has two options for adding an operator, constant, variable, or function to an expression:

  • By clicking the New Element button
  • By typing it directly into the textual editor field, which makes it appear in the visual editor as well.

The New Element button triggers a dialog with the selection of all available calculation elements.

Developer Hint
You can customize the calculation elements available to your users, add custom functions, load a specific list of variables, or disable any of the default calculation elements.
Selecting a constant
Selecting a constant
'New Element' dialog
'New Element' dialog
Selecting a variable
Selecting a variable
Selecting a function
Selecting a function
Selecting an operator
Selecting an operator

Expanding Variables

There are two ways a user can expand a variable to see the underlying structure of the variable.

  • Expand an individual variable by clicking the Expand Variable button.
  • Expand all variables by clicking the Expand All Variables button in the header toolbar.

In both cases, a confirmation message is displayed warning the user that this action is irreversible and variables cannot be collapsed back.

When a variable is expanded, the user can also remove the dependency on the original variable, if needed.

Warning
Expanding a variable is currently an irreversible action, and the dependency on the original variable can only be restored if you insert the original variable again as a new calculation element.
Selecting a variable to expand
Selecting a variable to expand
Confirming the variable expansion
Confirming the variable expansion

Guidelines

When the default layout is used, displaying both the visual and textual editors, we advise against adding the editor buttons for operators, constants, functions, and variables to the header toolbar.

Resources

Want to dive deeper? Follow the links below to find out more about related controls, the SAPUI5 implementation, and the visual design.

Elements and Controls

Implementation

PDF Viewer

The PDF viewer control displays PDF documents within your app. It can be embedded in your page layout, or you can set it to open in a popup dialog. In addition, this control allows you to print and download the PDF documents it displays.

Usage

Use the PDF viewer control if:

  • You want your app to display PDF files on all devices and platforms.
  • You want the users of your app to be able to preview their documents as PDF files right inside your app.
  • You need to ensure the consistent behavior of PDF files across all SAP Fiori apps.
  • You need to work with events (loaded, validation, error) provided by the PDF viewer.

Do not use the PDF viewer if:

  • You need to provide an interactive PDF file (such as a data input form).

Responsiveness

The PDF viewer control is fully responsive on large-screen devices (size L). The range of responsive behavior available on desktop devices depends on the display mode.

  • When the PDF viewer opens in a dialog popup:
    By default, the dialog supports two or more actions, such as Close and Download. On large-screen (desktop) devices, the action buttons are right-aligned. Use compact mode to ensure optimal padding and margins on desktop devices.
    If the content height is increased beyond the screen height, the dialog height cannot go beyond 4 rem from the top and bottom of the screen.
    The dialog popup must be resized automatically and cannot support dragging or custom resizing.

 

  • When the PDF viewer is embedded in a container on the app page:
    The dimensions of the frame in which the PDF file is displayed are defined by the PDF viewer properties.
    The control in which the PDF viewer is embedded must have at least 1 rem (16 px) padding to set it apart from the rest of the content.
    Only vertical scrolling is allowed. The behavior of desktop touch devices should follow the default behavior of the device or platform.

On mobile devices (smartphones and tablets), the PDF viewer control renders a toolbar with the title and a download icon, which behaves as a standard device/browser file link.

If required, you can customize the behavior for mobile devices and trigger the default device action for the file link from a different anchor in the application.

Size L - Popup mode
Size L - Popup mode
Size L - Embedded mode
Size L - Embedded mode
Size M - Tablet
Size M - Tablet
Size S - Mobile
Size S - Mobile

Layout

Displaying PDF Files in a Dialog

The dialog is positioned in the center of the screen. It opens in a modal window to attract the user’s attention when it displays emergency states. The dialog consists of:

  • A dialog header
  • A dialog PDF content
  • A dialog footer

Displaying Embedded PDF Files

The secondary mode of the PDF viewer displays PDF files directly on the page. The application owner, using the PDF viewer control, provides the dimensions of the frame in which the PDF file is embedded. The container should have at least 1 rem (16px) padding from the other content on the page to allow users to distinguish between the embedded PDF and the rest of the page’s content.

When the PDF viewer is embedded on the page, it comprises:

  • An overflow toolbar header
  • A container for rendering the PDF file (determined by the application owner)
Schematic visualization of popup mode
Schematic visualization of popup mode
Schematic visualization of embedded mode
Schematic visualization of embedded mode
Developer Hint
The footer can be extended by any desired buttons. However, both the Close and Download buttons must be displayed. This is to ensure that the accessibility requirements are fulfilled. Additional information about action placement and order can be found in the Action Placement article.

Components

The PDF viewer in popup mode is rendered within a Dialog and consists of:

Title(Header): The title text appears in the dialog header.

Content: This area contains the actual PDF file displayed within the content of the dialog.

Footer with actions: The footer contains two mandatory buttons: Close and Download. Other actions can be added to the footer as well.

 

The PDF viewer in embedded mode can be rendered in any container desired by the application.

The title is displayed within the Toolbar (Overflow Toolbar).

Developer Hint
Use a Flexbox container to wrap the embedded mode of the PDF viewer inside the application.

Behavior and Interaction

All the interactions for the PDF files themselves must remain the same across platforms and browsers: paging, scrolling, zooming, and print must all be available.

Download – For accessibility reasons, the PDF viewer always provides an additional download button for downloading the displayed PDF file and gives users the option to download the embedded PDF renderer on a specific device or system (not all PDF reader plugins have their own download button).

Popup mode interactions:

  • No custom resizing of the dialog
  • No dragging of the dialog

Guidelines

To avoid the risk of performance issues, do not embed more than three instances of the PDF viewer per page. You may embed more instances of the PDF viewer in one page if the number of PDFs does not affect performance. Carry out benchmark tests to ensure that performance will not be affected.

The PDF viewer can be used within other sap.m components, such as carousel and panel, respecting the specific guidelines of these components.

The embedded mode of the PDF viewer can be used on the Object Page if the container is as wide as the object page. If this is not the case, use the popup mode of the PDF viewer instead.

The PDF viewer can provide accessibility options when used with screen readers and other accessibility software. To ensure that all the accessibility options are supported, you need to have Adobe PDF Reader installed.

Resources

Want to dive deeper? Follow the links below to find out more about related controls, the SAPUI5 implementation, and the visual design.

Elements and Controls

Implementation

PDF Viewer

The PDF viewer control displays PDF documents within your app. It can be embedded in your page layout, or you can set it to open in a popup dialog. In addition, this control allows you to print and download the PDF documents it displays.

Usage

Use the PDF viewer control if:

  • You want your app to display PDF files on all devices and platforms.
  • You want the users of your app to be able to preview their documents as PDF files right inside your app.
  • You need to ensure the consistent behavior of PDF files across all SAP Fiori apps.
  • You need to work with events (loaded, validation, error) provided by the PDF viewer.

Do not use the PDF viewer if:

  • You need to provide an interactive PDF file (such as a data input form).

Responsiveness

The PDF viewer control is fully responsive on large-screen devices (size L). The range of responsive behavior available on desktop devices depends on the display mode.

  • When the PDF viewer opens in a dialog popup:
    By default, the dialog supports two or more actions, such as Close and Download. On large-screen (desktop) devices, the action buttons are right-aligned. Use compact mode to ensure optimal padding and margins on desktop devices.
    If the content height is increased beyond the screen height, the dialog height cannot go beyond 4 rem from the top and bottom of the screen.
    The dialog popup must be resized automatically and cannot support dragging or custom resizing.

 

  • When the PDF viewer is embedded in a container on the app page:
    The dimensions of the frame in which the PDF file is displayed are defined by the PDF viewer properties.
    The control in which the PDF viewer is embedded must have at least 1 rem (16 px) padding to set it apart from the rest of the content.
    Only vertical scrolling is allowed. The behavior of desktop touch devices should follow the default behavior of the device or platform.

On mobile devices (smartphones and tablets), the PDF viewer control renders a toolbar with the title and a download icon, which behaves as a standard device/browser file link.

If required, you can customize the behavior for mobile devices and trigger the default device action for the file link from a different anchor in the application.

Size L - popup mode
Size L - popup mode
Size L - embedded mode
Size L - embedded mode
Size M - tablet
Size M - tablet
Size S - mobile
Size S - mobile

Layout

Displaying PDF Files in a Dialog

The dialog is positioned in the center of the screen. It opens in a modal window to attract the user’s attention when it displays emergency states. The dialog consists of:

  • A dialog header
  • A dialog PDF content
  • A dialog footer

Displaying Embedded PDF Files

The secondary mode of the PDF viewer displays PDF files directly on the page. The application owner, using the PDF viewer control, provides the dimensions of the frame in which the PDF file is embedded. The container should have at least 1 rem (16px) padding from the other content on the page to allow users to distinguish between the embedded PDF and the rest of the page’s content.

When the PDF viewer is embedded on the page, it comprises:

  • An overflow toolbar header
  • A container for rendering the PDF file (determined by the application owner)
Schematic visualization of popup mode
Schematic visualization of popup mode
Schematic visualization of embedded mode
Schematic visualization of embedded mode
Developer Hint
The footer can be extended by any desired buttons. However, both the Close and Download buttons must be displayed. This is to ensure that the accessibility requirements are fulfilled. Additional information about action placement and order can be found in the Action Placement article.

Components

The PDF viewer in popup mode is rendered within a Dialog and consists of:

Title(Header): The title text appears in the dialog header.

Content: This area contains the actual PDF file displayed within the content of the dialog.

Footer with actions: The footer contains two mandatory buttons: Close and Download. Other actions can be added to the footer as well.

 

The PDF viewer in embedded mode can be rendered in any container desired by the application.

The title is displayed within the Toolbar (Overflow Toolbar).

Developer Hint
Use a Flexbox container to wrap the embedded mode of the PDF viewer inside the application.

Behavior and Interaction

All the interactions for the PDF files themselves must remain the same across platforms and browsers: paging, scrolling, zooming, and print must all be available.

Download – For accessibility reasons, the PDF viewer always provides an additional download button for downloading the displayed PDF file and gives users the option to download the embedded PDF renderer on a specific device or system (not all PDF reader plugins have their own download button).

Popup mode interactions:

  • No custom resizing of the dialog
  • No dragging of the dialog

Guidelines

To avoid the risk of performance issues, do not embed more than three instances of the PDF viewer per page. You may embed more instances of the PDF viewer in one page if the number of PDFs does not affect performance. Carry out benchmark tests to ensure that performance will not be affected.

The PDF viewer can be used within other sap.m components, such as carousel and panel, respecting the specific guidelines of these components.

The embedded mode of the PDF viewer can be used on the Object Page if the container is as wide as the object page. If this is not the case, use the popup mode of the PDF viewer instead.

The PDF viewer can provide accessibility options when used with screen readers and other accessibility software. To ensure that all the accessibility options are supported, you need to have Adobe PDF Reader installed.

Resources

Want to dive deeper? Follow the links below to find out more about related controls, the SAPUI5 implementation, and the visual design.

Elements and Controls

Implementation