Introduction:
Sometime back, I had the opportunity to delve into the world of Fiori Elements, documenting my understandings in a blog post that highlighted key features such as Side Effects, Custom Actions and Dynamic Expression (here). Building upon that exploration, in this blogpost, I aim to explain different options available for presenting table in a List Report and how can we use these features to enhance user experience when showcasing data in a tabular format.
Example of POC Scenario and Its resources:
We will use the sample project “cap-fe-lr-table-views” that I have shared on GitHub here to explain the concepts. Let’s briefly examine the project and some of its essential files.
Folder or File | Purpose | |
db/ | Data model is defined in schema.cds | |
srv/ |
|
|
app/ | This has 5 ui frontends. | |
app/ui01 | Single Table – Segmented View scenario | |
app/ui02 | Multiple Table – Tab View scenario | |
app/ui03 | Multiple Table & Chart – Tab View scenario | |
app/ui04 | Multiple Table – Tab & Segmented View scneario | |
app/ui05 | Multiple Table – Multiple EntitySet scenario |
Service “cap_fe_lr_table_views_service” proivides following data set: Orders, Order Items, Order Types, Customers, Products, ItemTotals, CustomerTotals.
Please be aware that in this blog post, my emphasis is on illustrating the functionality of presenting tables in various configurations. It’s worth noting that the service utilized for demonstration purposes may not be flawless and is solely used to explain the functionalities.
Detailed Explanation:
Before diving into various combination of configurations to achieve different visualizations, it is crucial to understand following couple of things:
1. Relevant Annotations:
In addition to annotations mentioned above, some configurations are also added in Application Descriptor File (manifest.json).
Note: @UI.LineItem and @UI.Chart annotation are used to bring up tables and charts respectively in SAP Fiori Elements.
2.Table Modes:
Now Let’s look at some examples to understand a bit more.
Scenario 1: Single Table – Segmented View
In this scenario, single insatnce of table is used to offer a segmented view. For example, within a segmented view of sales orders, one view displays return orders, while another view showcases other types of orders.
To achieve above functionality following anotations and configirations are added:
/app/ui01/annotations.cds
|
/app/ui01/webapp/manifest.json
|
Here we have defined two selection variants labeled as #SelVarRO and #SelVarSO using annotations. These variants incorporate select options that are essentially act as filters on the defined entityset. These are subsequently added to the table configuration under quickVariantSelection in the manifest.json file. Additionally, you have the option to specify whether each view should indicate the number of rows it displays by setting showCounts to true.
Note that, multiple filters defined as ranges can be provided in select option.
Scenario 2: Multiple Table – Tab View
In this scenario, multiple instances of the table are employed to provide a tabbed view. If there are n views, then n instances of the table are utilized. However, only one view is rendered at a time. An icon tab is presented to facilitate switching between views. For instance, in a tab view of sales orders, one view shows return orders, while another view highlights other types of orders.
To achieve above functionality following anotations and configirations are added:
|
/app/ui02/webapp/manifest.json
|
Here we have used two selection presentation variants labeled as #SelPreVarRO and #SelPreVarSO using annotations. Each of these variants incorporates selection variant and presentation variant. Each presentation variant includes references to visualizations @UI.LineItem labeled with #SOrders and #ROrders, along with specified sort order and group-by settings. These selection presentation variants are subsequently added to the table configuration under views in the manifest.json file.
Scenario 3: Multiple Table & Chart – Tab View
This scenario is simillar to previous scenario. In this scenario, one table and one chart is displayed in a tabbed view.
To achieve above functionality following anotations and configirations are added:
/app/ui03/annotations.cds
|
|
|
|
/app/ui03/webapp/manifest.json
|
Here one sepection presentation variant contains a chart visualization as shown above. Rest of the settings remain same.
Scenario 4: Multiple Table – Tab & Segmented View
In this scenario, we combine scenario 1 and 2, incorporating multiple tables within a tabbed view, and one of the views includes a segmented view within itself.
Similar to the annotations explained earlier, two selection presentation variants labeled as #SPVSO and #SPVRO are defined which referrs to two tables with labels #SO and #RO respectively. Additionally, there are three selection variants defined with labels #SVSS, #SVCS, #SVRS. |
/app/ui04/webapp/manifest.json
|
Annotations are applied in same way as previous scenario. The only difference is in configurations added in manifest.json. Selection presentation variants are added in views and selection variants are added in quickVariantSelection. However, quickVariantSelection is added under the table configuration labelled as “@com.sap.vocabularies.UI.v1.LineItem#SO”.
Scenario 5: Multiple Table – Multiple EntitySet
In this final scenario, all the previously mentioned scenarios are combined. Furthermore, different datasets are showcased. For instance, the first tab view displays a list of orders, the second one presents the total orders by item, and the last one exhibits order totals by customers.
To achieve above functionality following anotations and configirations are added:
Annotations are applied in the same manner as previously demonstrated. However, they are defined for different entity sets such as Orders, ItemTotals, and CustomerTotals. Additionally, configurations are incorporated in manifest.json. Since selection presentation variants are relevant to different datasets, the entitySet property must be specified for each variant in manifest.json (as highlighted in red).
Conclusion:
In this blog post, we have explored how various annotations and configurations can be utilized to depict diverse datasets through multiple views in a List Report.
Together, the Cloud Application Programming Model and Fiori Elements improve developer experience while also boosting productivity and accelerating the development of enterprise-ready applications.
More information about Fiori Elements with cloud application programming model can be found here. You can follow my profile to get notification of the next blog post on CAP or Fiori Elements. Please feel free to provide any feedback you have in the comments section below and ask your questions about the topic in sap community using this link.