Skip to Content
Technical Articles
Author's profile photo Shubham Kumar

How to use key for filtering and show description in smartfilter through annotations

App running on multiple languages has different descriptions to be shown based on the user language. We use common key which will be same in all languages  but description may differ based on user language. As shown in below example key are same in both the language but description differs.

 

Key English Description German Description
A Approve Genehmigen
R Reject Ablehnen

There is a smartfilter with controlType as dropdownList and dispalyBehaviour as descriptionOnly for field “PO Type” in smartfilter bar.

To Show the value in dropdown we are having an entityset called “ POTypeSet” having two properties “POTypeKey” and “POTypeDesc”

We have used Common.ValueList in annotation for POType field of POHeader (main entity) to show entries for PO Type smartfilter dropdown. POTypeKey is used for Common.ValueListParameterInOut, and POTypeDesc for Common.ValueListParameterDisplayOnly. Since POTypeKey is Common.ValueListParameterInOut, it will be considered for all operations.  It will show POTypeKey in drop-down when we select any value from drop-down and will show all the keys in drop-down instead of descriptions.

But we want to show POTypeDesc in drop-down. For showing description in drop-down we have to define text annotation (sap:text) for property POTypeKey in MPC_EXT class program of OData service.

After regenerating run time object, we can see  sap:text=”POTypeDesc” for property POTypeKey of Entity “POType” in the metadata.

Now we can see description showing in smartfilter instead of key and when we select any POType description and press enter. It will send POTypeKey  for the filter POType in payload.

In this way, we are able to show descriptions in smartfilter drop-down which would be language dependent and using key for filter operation which is common for all language.

 

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jyotsna Singam
      Jyotsna Singam

      Hi Shubam,

      Can we add both key and description in dropdown here?

      Author's profile photo Jayakrishnan Chandramohan
      Jayakrishnan Chandramohan

      Hi Shubam,

      Thanks for your blog. But i tried the same way, it is not working. I still able to see the ID in my case not description.

      My Scenario, i need to show the Status in the drop down, in the Value List entityset it has two property

      Status and Name.

      But i doubt two things in my application development.

      1. i did the sap: text annotations in the web ide annotation modeler. not via backend

      2. My Header Collection and Value List Collection Property in same name.

      Header Collection : Status.

      ValueHelp Collection : Status, Name

      I do not know because of this i am not getting the Description?

       

      Thanks.

      Jayakrishnan.