Create a UI5 Integration Card that Displays Data from the Northwind Demo System
- How to create a card for SAP Build Work Zone using SAP Business Application Studio (BAS)
- What the main elements of the Integration card are and understand their roles
Prerequisites
- Please note that if you are following this tutorial as part of a workshop, you can skip these prerequisites.
- You have created a dev space. See Create a Dev Space for SAP Fiori Apps.
- To deploy a UI5 Integration card in the SAP Build Work Zone, you should have a subaccount in SAP BTP that includes a subscription to the SAP Build Work Zone service. Additionally, you have to configure a destination for SAP Build Work Zone instance. See Development Tools for SAP Build Work Zone.
IMPORTANT: SAP Build Work Zone is not available in a trial account. If you only have a trial account and you want to learn more about the Integration cards you can follow this tutorial from steps 1 to 5.
Integration cards are UI elements which display concise pieces of information in a limited-space container. Cards are small previews of application content, and each card represents a specific topic, task, or perspective. As a card developer, you only need to configure a descriptor (manifest.json file) and as a result you get fully functional and reusable card.
- Step 1
If you are following this tutorial as part of a workshop, please skip this step.
-
In SAP Business Application Studio, stop the dev space if it is not already stopped.
-
Edit the dev space by selecting the Edit button.
-
Ensure that the Development Tools for SAP Build Work Zone extension is checked and save the changes.
-
- Step 2
-
Open the dev space (If the dev space is not running, you first have to start it).
-
Select Start from template.
-
Choose the UI Integration Card template and select Start.
-
Fill-in the required project details. Use the Highlight Card template, which creates an Integration card of type List and select Finish.
If you are following this tutorial as part of a workshop, please give your card a unique name. In this case your card name should be
wz<your unique identifier>_orders_by_shipper.Description Value Project Name orders_by_shipperIf you’re taking part in a workshop, please add your unique identifier to the project name like this:<your unique identifier>_orders_by_shipper.Name Space nsSelect a Card Sample (dropdown menu) Highlight CardTitle Orders by ShipperSubtitle UI5 Integration Card of Type ListCompatible with SAP Mobile Cards (dropdown menu) False -
To see the card, right-click on
manifest.jsonand select UI Integration Card: Preview. -
Currently the card displays only static data:
-
Open the
manifest.jsonfile. Everything needed to render the card is described in this file.The
manifest.jsonis a simple JSON file and has the following structure (check the picture below to see where each part is located):-
sap.appnamespace declaration. Thetype: carddefines that this is a manifest for a card. Each card has a unique ID. -
sap.cardsection:- Card type (List): Defines how the card is displayed. It could be one of the available content types - Adaptive, Component, Analytical, List, etc.
- Header: Displays general information about the card. Using its properties, you can configure the title, subtitle, status text, and icon.
- Content: This is the main section of the displayed card.
- Card type (List): Defines how the card is displayed. It could be one of the available content types - Adaptive, Component, Analytical, List, etc.
-
datasections: Define how the card handles its data. It can provide static data (see thejsonobject below) or define required parameters for a data request to a backend system. Can be set on different levels (card, header, filter-definition, or content). The inner level data sections take precedence. In the example below the data section is defined on content level.
-
In the next steps you edit the
manifest.jsonfile to configure the card. -
- Step 3
By connecting your card to the public Northwind demo service, you’re enabling the card to display dynamic data. Card destinations are used for outbound communication to a remote resource and contain the required connection information.
-
To set a destination, add the following
configurationsection in thesap.cardsection after thetypesubsection.JSONCopy"configuration": { "destinations": { "Northwind": { "name": "Northwind", "label": "Northwind V4 Service URL", "defaultUrl": "https://services.odata.org/V4/Northwind/Northwind.svc" } } }, -
To configure a data request pointing to the Northwind demo service, add a new
datasection after theconfiguration. In this way thedatasection will be defined on a card level. Note, that our destination is referred here using the double-bracket syntax{{destinations.Northwind}}.JSONCopy"sap.card": { "data": { "request": { "url": "{{destinations.Northwind}}/Orders" }, "path": "/value" } },
IMPORTANT: Due to an issue with the UI Integration Card: Preview option, you may need to replace {{destinations.Northwind}} with “https://services.odata.org/V4/Northwind/Northwind.svc” !
Finally, to display the dynamically requested data, replace the static
contentsection with the following one. Thetitle,description, andinfoproperties are now dynamically requested.```JSON "content": { "item": { "title": "{ShipName}", "description": "{ShipAddress}", "info": { "value": "{ShipCountry}" } } } ``` <!-- border -->Results after Step 3:
The application displays dynamic data loaded from the Northwind demo service. Note, that the actual displayed products may differ depending on the current data provided by the Northwind demo service. You can also check the manifest.json file at this step. To learn more, see the Destinations and Data sections in the Card Explorer.
If you would like to deploy the card and see how it looks on SAP Build Work Zone, you can skip to Step 6 and deploy it. In the next steps you add card capabilities that can make your card more interactive.
-
- Step 4
Manifest parameters provide dynamic values for card attributes. They are replaced during manifest processing and can be used from the
parametersmodel, for example:{parameters>/city/value}. As an example, in this step you will add parameters to set the header (title) property and the number (maxItems) of displayed items in the content.If you are following this tutorial as part of a workshop and run out of time, you can skip steps 4,5,6 and create a simpler card. You can later read the steps you missed.
-
To define parameters - add the following
parameterssubsection in themanifest.jsonin theconfigurationsection (note the comma which divides the entries).JSONCopy"parameters": { "title" : { "value": "Orders by Shipper" }, "maxOrdersShown": { "value": "4", "type": "integer", "label": "Numbers of orders", "description": "How many orders to show in the list." } } -
To use the new
maxOrdersShownparameter, add it as shown below:JSONCopy"maxItems": "{parameters>/maxOrdersShown/value}" -
Update the data request as follows:
JSONCopy"data": { "request":{ "url": "{{destinations.Northwind_V4}}/Orders", "parameters": { "$top": "{parameters>/maxOrdersShown/value}" }, "path": "/value/" } }
IMPORTANT: Due to an issue with the UI Integration Card: Preview option, you may need to replace {{destinations.Northwind}} with “https://services.odata.org/V4/Northwind/Northwind.svc” !
Finally, let’s also use the new parameters in the
headersection. Use theparameterssyntax and edit (or replace) the header, so it looks like this:```JSON "header": { "title": "{parameters>/title/value}", "icon": { "src": "sap-icon://desktop-mobile" }, "status": { "text": "{parameters>/maxOrdersShown/value}" } }, ``` <!-- border -->Results after Step 4:
In this step, you have learned how to declare configurable parameters and use them to achieve the desired dynamic behavior. The application now displays a list of 4 items according to the
parametersproperty (maxOrdersShown value: 4).To learn more, see the Manifest Parameters section in the Card Explorer.
-
- Step 5
You can make the card even more dynamic when using filters. Filters appear as a dropdown under the card header, and users can interact to customize the data shown by the card. The value of each filter can be used inside a data request definition by using the
{filters>/myFilter/value}placeholder. When the end user selects different value from the dropdown - a new data request is made with the updated value. As an example, in this step you will add a filter that enables users to filter the orders by a selected shipper.-
Add a
filterssubsection in theconfigurationsection. It defines a dropdown list with product categories, which are received by a data request.JSONCopy"filters": { "shipper": { "value": "{parameters>/selectedShipperID/value}", "type": "Select", "label": "Shipper", "item": { "path": "/value", "template": { "key": "{ShipperID}", "title": "{CompanyName}" } }, "data": { "request": { "url": "{{destinations.Northwind}}/Shippers" } } } }, -
Add
selectedShipperIDsubsection in theparameterssection. This is the shipper that is initially selected in the filter. Later, the user can change it from the dropdown list.JSONCopy"selectedShipperID": { "value": 3, "label": "The default selected shipper" } -
Add
parametersin the maindatasection >requestsubsection, after theurlproperty as shown below. The$filterparameter will be used in a data request for the orders withshipperthat is equal to the one selected by the user in the filter’s dropdown list.JSONCopy"request": { "url": "https://services.odata.org/V4/Northwind/Northwind.svc/Orders", "parameters": { "$top": "{parameters>/maxOrdersShown/value}", "$filter": "Shipper/ShipperID eq {filters>/shipper/value}" } } -
Finally, replace the title in the
headeradding the{filters>/shipper/selectedItem/title}parameter, which will show the selected category:JSONCopy"title": "Orders by Shipper {filters>/shipper/selectedItem/title}",
Results after Step 5:
If you have any issues you can check the manifest.json file at this step. It is configured with destinations, parameters, and a filter.
The application displays the products from the selected category:
To learn more, see the Card Filters section in the Card Explorer.
-
- Step 6
-
Select the
dt/configuration.jsfile (in the Explorer view on the left). -
Replace the content with the code below:
JAVASCRIPTCopysap.ui.define(["sap/ui/integration/Designtime"], function ( Designtime ) { "use strict"; return function () { return new Designtime({ "form": { "items": { "maxItems": { "manifestpath": "/sap.card/configuration/parameters/maxOrdersShown/value", "type": "integer", "label": "Maximum Items", "translatable": false, "description": "Defines how many items will be displayed at most." } } }, "preview": { "modes": "LiveAbstract" } }); }; });The
dt/configuration.jsnow looks like: -
- Step 7
If you are using SAP Build Work Zone, advanced edition, please continue following this tutorial to deploy your card.
If you are using SAP Build Work Zone, standard edition, you will first have to create a Content Package before you can deploy the card. Please skip this step and follow the tutorial that explains how to create the content package: Create a Content Package with Your UI Integration Card
-
Right-click on the
manifest.jsonfile (in the Explorer view on the left) and select the UI Integration Card:Deploy to SAP Build Work Zone option from the dropdown menu. -
Select the target SAP Build Work Zone destination.
-
In the right-bottom corner, confirm to Continue and wait to see the successful message.
Now the basic UI5 card deployment is done!
To learn more about the Integration cards and their functionalities, see the Card Explorer page.
-