Dynamic SAP Fiori Tiles using variants in SAP S/4HANA 1909
It’s been a while since I had the chance to write a blog post about something product related and semi-technical so it’s good to be able to squeeze this in before the end of the year and as an added bonus it’s my first blog post as an SAP Employee!
If you’ve used SAP S/4HANA you will probably already know about some of the neat features that allow users to personalize their experience. In case you haven’t or you need a reminder, I will start with a brief description of them so that we are all on the same page.
Creating views (a.k.a. variants, I use the two interchangeably in this post) for example for List Reports. This allows you as a user to save a set of filters for the list report so that you can quickly apply the same filter in the future. You can even share your views by making them public so that other people can use them too.
In addition you can also save the view as a tile and add it to your SAP Fiori Launchpad, this will create a tile for you in your Home group, with a counter showing you the number of results that match your filter criteria. When you click on this tile the List Report will open with the filter already applied.
These two neat features in effect let you set up smart shortcuts on your homepage that let you quickly see if something needs your attention and then drill down to do something about it. Good old “Insight to Action” in full effect 😉
Recently I was asked if it was possible as an administrator to do the same thing and add these tiles to catalogs and groups so that they could be pushed out to users via their roles? This is a good question… after a bit of pondering, digging around and hints from my colleague Jocelyn Dart I worked out how to do this and thought I’d share it with you in this post as I think it is something that will be useful during all SAP S/4HANA implementations*.
So to give this a bit more context and start with the end in mind I will explain the scenario in a bit more detail. Imagine for a moment that you are a Maintenance Planner and in your role you would like to be able to quickly see how many “High” and “Very High” priority maintenance notifications there currently are for you.
One way to do this is to launch the SAP Fiori Elements based List Report app Find Maintenance Notifications from your SAP Fiori Launchpad and create a couple of variants, one for Priority = 1 (Very High) and one for Priority = 2 (High), you can then save each of those as a tile that will display on your home page. Of course you realise that these tiles would also be really useful for your fellow planners, wouldn’t it be cool if they were just available to you and all your colleagues by default…
So now to the guts of this blog post, as an Administrator you can now make this a reality, thanks to a feature in SAPUI5 for Managing Variants. Here are the steps you need to do:
Go into your own SAP Fiori Launchpad and start the application (you will need to make sure you are assigned the same app as will be used by the end users), in this case it is the Find Maintenance Notifications app. These same steps should work for any SAP Fiori Elements based List Report or Analytical List page.
Create the variants/views you want by setting the filters (in this case I have set Priority = 1 (Very High) and then saving them.
Make sure you save them as “Public” and set them to “Apply Automatically”
To get the Variant IDs that you will need later on you can use the Developer Console in your browser, when you save the view/variant you will see a request to /sap/bc/lrep/variants and in the response body you will see the variant ID
Next save your views as tiles by clicking on the Share icon and choosing “Save as Tile”.
When you navigate back to your SAP Fiori Launchpad home page you should two new tiles in your Home group.
You will notice that these tiles have a count on them to show the count of maintenance notifications based on the priority filter. Again if you check the network trace in your browser developer tools you should be able to see the HTTP request that makes the call for that count. You can copy that for using later too.
Ok, now so I hope you are still following along (well done if you are) we are nearly done. So armed with the Variant ID and the URL for the count you should go to the SAP Fiori Launchpad Designer, go to the catalog you want to assign the tile to and create a new Dynamic Tile (App Launcher Dynamic) you should make sure that the semantic navigation Object and Action parameters match the original tile for the launching the app – in my example below this is MaintenanceNotification-displayFactSheetDemo.
Then go ahead and insert the Variant ID and URL as shown below. The URL parameter used to pass the variant ID is sap-ui-fe-variant-id so it will look something like this sap-ui-fe-variant-id=<insert your variant ID>.
For the URL you can make it relative, something like this
That’s it, if you log on as a user who has the role with the new tiles you’ve just created they should be able to see the dynamic tiles showing the count and when you click them it should launch the Find Maintenance Notifications app and automatically apply the filter.
Here’s a little demo
I hope you find this useful, if you have any comments or feedback don’t hesitate to leave a comment below. In the meantime I will see if I can lobby for this to be streamlined and included as a feature request in the standard product (no promises)… if you think this is useful please let me know in the comments below as it will help my case 😉
*Note: you can use this method as of SAP S/4HANA OP 1909 as the ability to pass a variant ID in the URL has been available since SAPUI5 version 1.65.0