Skip to Content

Add SAP Fiori Elements UIs

This tutorial shows you how to create an SAP Fiori elements application on top of your previously created CAP application.
You will learn
  • How to generate the UI with an SAP Fiori elements template
  • How to modify the UI with the SAP Fiori page editor

Prerequisites

You have built your CAP application. Follow the steps in the Build a CAP application tutorial that is part of the Develop a Full-Stack CAP Application Following SAP BTP Developer’s Guide tutorial group.

This tutorial follows the guidance provided in the SAP BTP Developer’s Guide.

  • Step 1

    SAP Fiori elements provides designs for UI patterns and predefined floorplans for common application use cases. Application developers can use SAP Fiori elements to create SAP Fiori applications based on OData services and annotations that don’t need JavaScript UI coding. The resulting application uses predefined views and controllers that are provided centrally. This means no application-specific view instances are required. SAPUI5 interprets the metadata and the annotations of the underlying OData service and uses the corresponding views for the SAP Fiori application at startup.

    By following one of the SAP Fiori elements floorplans, you:

    • Boost your development productivity
    • Get future-proof UX consistency
    • Get enterprise readiness

    To learn more about each of these points, see Why Use SAP Fiori Elements?.

  • Step 2
    1. In SAP Business Application Studio, go to your IncidentManagement dev space.

      Make sure the IncidentManagement dev space is in status RUNNING.

    2. Choose the burger menu and then choose ViewCommand Palette.

      You can also invoke the Command Palette quickly using the following key combination:

      • For macOS: Command + Shift + P
      • For Windows: Ctrl + Shift + P
    3. Type Fiori: Open Application Generator in the field and select this entry from the list.

    4. In the Template Selection step:

      • Choose the List Report Page template tile.

      • Choose Next.

        V4 Template
    5. In the Data Source and Service Selection step:

      • In the Data source dropdown menu, select Use a Local CAP Project.

      • In the Choose your CAP project dropdown menu, select the incident-management project.

      • In the OData service dropdown menu, select the ProcessorService (Node.js) (or ProcessorService (Java) if you’re developing a CAP Java application).

      • Choose Next.

        CAPpro
    6. In the Entity Selection step:

      • In the Main entity dropdown menu, select Incidents.

      • Leave the Navigation entity value as none, and then select Yes to add table columns automatically.

      • In the Table Type dropdown menu, select Responsive.

      • Choose Next.

        Entity selection
    7. In the Project Attributes step:

      • In the Module name field, enter incidents.

      • In the Application title field, enter Incident-Management.

      • In the Application namespace field, enter ns.

      • Leave the default values for all the other settings and choose Finish.

        Project names

      The application is now generated and in a few seconds you can see the application’s incidents folder in the app folder of your incident-management project. It contains a webapp folder with a Component.js file that is typical for an SAPUI5 application. However, the source code of this application is minimal. It inherits its logic from the sap/fe/core/AppComponent class. This class is managed centrally by SAP Fiori elements and provides all the services that are required (routing, edit flow) so that the building blocks and the templates work properly.

    Which SAP Fiori Elements template did you use to generate the UI of the app:

  • Step 3

    You can create a CAP project in either Node.js or Java. You have to choose one way or the other and follow through. The tabs Node.js and Java provide detailed steps for each alternative way.

  • Step 4

    In this section, you’ll modify the List View Page of the UI with the SAP Fiori page editor.

    Add filter fields

    1. In the Application Info - incidents tab, choose the Open Page Map option.

      Page Map

      The page map of the incidents application opens in a new tab within SAP Business Application Studio. You will see the properties on the right side of the page map. You can edit these properties to update the UI of the application.

      Page Map properties

      In case the Application Info - incidents tab is closed:

      1. Invoke the Command Palette - ViewCommand Palette or Command + Shift + P for macOS / Ctrl + Shift + P for Windows.
      2. Choose Fiori: Open Application Info.
    2. In the List Report tile, choose the Pencil icon next to the title. The page editor is opened.

      List Report Page Config
    3. In the Filter Bar section of the page editor, choose Filter Fields and then choose the Plus icon to add filter fields. Then, select Add Filter Fields in the dropdown menu.

      Add Filter Fields
    4. In the Add Filter Fields popup:

      • Select the status_code and urgency_code checkboxes in the Filter Field dropdown menu.
      • Choose Add. Your application will be updated to show the new filters.
      New Filters Added

      This this is how you define which properties are exposed as search fields in the header bar above the list.

    Edit filter fields

    The filter labels are text strings. It’s a good idea to update them so they are compliant with internationalization standards (i18n).

    1. Change the urgency_code filter label. In the Label field, change the value to Urgency. Press Enter to confirm the change.

      Update filter label
    2. Choose the Globe icon to generate a translatable text key and choose Apply.

      Generate Translatable Text Key
    3. Choose the status_code filter. In the Label field, change the value to Status. Press Enter to confirm the change.

    4. Choose the Globe icon to generate a translatable text key and choose Apply.

    5. For both the Urgency and Status filters, in the Display Type dropdown menu, select Value Help. A popup shows up.

      Value help display type
    6. In the Define Value Help Properties for Urgency/Status popup:

      • Choose the dropdown menu in the Value Description Property field.
      • Select descr.
      • Choose Apply.
      Value desc property

    Edit columns

    1. Expand the Columns section under Table and delete the columns customer_ID, urgency_code and status_code.

      Delete Columns
    2. In TableColumns, choose the Plus icon to add columns. Choose Add Basic Columns.

      Add Basic Columns
    3. In the Add Basic Columns popup, choose the dropdown menu in the Columns field and:

      • Select the statusdescr checkbox.
      • Select the urgencydescr checkbox.
      • Select the customername checkbox and add the columns.
      Add Basic Columns popup
    4. Select the name column and choose ^ to move the column up just under the Title column.

      Reorder Columns
    5. Choose the Title column, choose the Globe icon in the Label field to generate a translatable text key, and apply the changes.

      The filter labels are text strings. It’s a good idea to update them so they are compliant with internationalization standards (i18n).

      Learn more about how internationalization works for the backend part in Where to Place Text Bundles? in the CAP documentation.

    6. For each of the name, Description (status/descr), and Description (urgency/descr) columns:

      • In the Label field, change the value to Customer, Status, and Urgency, respectively.
      • Press Enter to confirm the change.
      • Choose the Globe icon in the Label field to generate a translatable text key.
      Update Columns

    Configure tables

    1. Choose Table and in the Initial Load dropdown menu, select Enabled to load the data automatically.

      Enable Data Auto Load
    2. In the Type dropdown menu, select ResponsiveTable to make the table responsive.

      Responsive table
    3. Navigate to TableColumnsStatus and in the Criticality dropdown menu, select status/criticality.

      Add Status Criticality

    Check the result

    1. The list page of the Incident Management application should look like this:

      Incident Management App’s List Page
    2. Navigate back to the page editor and choose Page Map in the top left. This takes you back to the overview of the incidents application.

  • Step 5

    In this section, you’ll modify the Incident Object Page of the UI with the SAP Fiori page editor.

    Edit header

    1. Make sure the SAP Fiori page editor is open. If you closed it, choose the Open Page Map option in the Application Info - incidents tab.

      To open the Application Info - incidents tab:

      1. Invoke the Command Palette - ViewCommand Palette or Command + Shift + P for macOS / Ctrl + Shift + P for Windows.
      2. Choose Fiori: Open Application Info.
    2. In the Incident Object Page tile, choose the Pencil icon next to the title.

      Edit object page
    3. Choose Header and in the Title dropdown menu, select title.

      Select Title
    4. In the Description Type dropdown menu, select Property. A popup opens.

      Select property
    5. In the Define Property popup, choose the dropdown menu in the Description field and:

      • Select customername.
      • Choose Apply.
      Apply Name
    6. In the Icon URL field, enter sap-icon://alert.

      Icon URL

    Add Overview section

    1. Choose Sections and then choose the Plus icon to add more sections. Choose Add Group Section.

      Add Group Section
    2. In the Add Group Section popup:

      • Enter Overview in the Label field.
      • Choose the Globe icon to generate a translatable text key.
      • Choose Add.
      Add Overview Section

    Add Details subsection

    1. Navigate to SectionsOverviewSubsections.

    2. Choose the Plus icon to add more sections and choose Add Form Section.

      Add Subsection
    3. In the Add Form Section popup:

      • Enter Details in the Label field.
      • Choose the Globe icon to generate a translatable text key.
      • Choose Add.
      Add Details Subsection

    Configure fields

    1. Choose SectionsGeneral Information and choose the Globe icon in the Label field for General Information to generate a translatable text key.

      General information label
    2. Navigate to SectionsGeneral InformationFormFields and delete the urgency_code and status_code fields.

      Delete Fields
    3. For the customer_ID field:

      • Move the field down just under the Title field.
      • In the Label field, change the value to Customer.
      • Press Enter to confirm the change.
      • Choose the Globe icon in the Label field to generate a translatable text key.
      Customer field update label
    4. For the Customer field, select customer/name in the Text dropdown menu, select Text Only in the Text Arrangement dropdown menu, and then select the hyperlink Edit properties for Value Help under Display Type. A popup opens.

      Customer properties update
    5. In the Define Value Help Properties for Customer popup:

      • Select None in the Value Description Property dropdown.
      • Switch off Display as Dropdown.
      • Under Result List, choose Add Column and add columns name and email.
      • Choose Apply.
      Define Value Help Properties for Customer

      If there are already some columns in the result list, then delete them and keep only the columns name and email.

    6. Navigate to Sections, drag the General Information and drop it in the OverviewSubsections node.

      Customer properties update
    7. Navigate to SectionsOverviewSubsectionsDetailsFormFields, choose the Plus icon to add more fields, and then choose Add Basic Fields.

      Add Basic Fields
    8. In the Add Basic Fields popup

      • From the dropdown menu in the Fields field, select status_code and urgency_code.
      • Choose Add.
      Add Basic Fields popup
    9. For the Status field, select status/descr in the Text dropdown menu and then select Value Help in the Display Type dropdown menu. A popup opens.

      Status properties update
    10. In the Define Value Help Properties for Status popup:

      • Select Status in the Value Source Entity dropdown menu.
      • Select code in the Value Source Property dropdown menu.
      • Select descr in the Value Description Property dropdown menu.
      • Leave the default values for the rest of the properties and choose Apply.
      Status value help
    11. For the Urgency field, select urgency/descr in the Text dropdown menu and then select Value Help in the Display Type dropdown menu. A popup opens.

      Urgency properties update
    12. In the Define Value Help Properties for Urgency popup:

      • Select Urgency in the Value Source Entity dropdown menu.
      • Select code in the Value Source Property dropdown menu.
      • Select descr in the Value Description Property dropdown menu.
      • Leave the rest of the properties with the default values and choose Apply.
      Urgency value help

    Add Conversation section

    1. Navigate to Sections and then choose the Plus icon to add more sections. Select Add Table Section in the dropdown menu.

    2. Choose Add Table Section. A popup appears.

      Add Table section
    3. In the Add Table Section popup:

      • Enter Conversation in the Label field.
      • Choose the Globe icon to generate a translatable text key.
      • Select conversation in the Source Value dropdown menu and choose Add.
      Add Conversation Label

    Configure columns

    1. Navigate to ConversationTableColumns and choose the Plus icon to add columns.

    2. Choose Add Basic Columns. A popup appears.

      Add Conversation columns
    3. In the Add Basic Columns popup:

      • In the Columns dropdown menu, select author, message, and timestamp.
      • Choose Add.
      Add Basic Columns popup
    4. For each of the CreatedBy, message, and CreatedOn columns:

      • In the Label field, change the value to Author, Message, and Date, respectively.
      • Press Enter to confirm the change.
      • Choose the Globe icon in the Label field to generate a translatable text key.
      Update column labels

    Configure table and check the result

    1. For Table, in the Type dropdown menu, select ResponsiveTable to make the table responsive.

      Responsive table
    2. In the Creation Mode: Name dropdown menu, select Inline.

      Table creation mode
    3. The complete list object page looks like this:

      Complete List Object Page
  • Step 6

    SAP Fiori supports editing business entities with draft states stored on the server, so users can interrupt editing and continue later on, possibly from different places and devices. CAP, as well as SAP Fiori elements, provides out-of-the-box support for drafts. We recommend that you always use draft when your SAP Fiori application needs data input by end users.

    Enabling a draft for an entity allows the users to edit the entities. To enable a draft for an entity exposed by a service, follow these steps:

    1. Open the srv/services.cds file.

    2. Annotate the file with @odata.draft.enabled like this:

      CDS
      Copy
      service ProcessorService { 
      ...
      }
      ...
      annotate ProcessorService.Incidents with @odata.draft.enabled; 
      
    3. Start creating a new incident but leave the Customer, Status, and Urgency fields empty.

      Draft incident with empty fields
    4. Go back to the list view page without creating the incident. You should be able to see the incident draft there with the empty fields.

      List view page with draft incident
    5. Try to access it again to continue the creation from where you stopped.

      Draft incident, continue editing
Back to top