Skip to Content

Change SmartFilterBar input from Multi to Single Value

We are developing an ALP app in WebIDE which consumes xsodata. We want one of the filters on the Smart Filter Bar to only accept a single value instead of multiples. The Smart Filter Bar is automatically rendered by the annotations based on the metadata, however we are unable to add the v2 annotation sap:filter-restriction="single-value" which supposedly controls this area.

Upon checking the SmartFilterBar control on the API Reference (, I saw that we could add the v4 annotation to the annotations on the app and set AllowedExpressions to SingleValue. However, I couldn't find that annotation on the Annotation Modeler. Additionally, when checking the content of the Vocabulary (, I noticed that the annotation FilterExpressionRestriction suggested by the API Reference is actually deprecated, being replaced by Capabilities.FilterRestrictions. But this Vocabulary doesn't mention anything about single/multi values (

Could someone shed some light on how I can set a single field on the filter to allow only a single value?

Best regards,


Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Sep 18, 2018 at 01:48 PM

    Have you tried a redefinition of the DEFINE method in the implementing class of the OData service?

    If you do something like this (this example is for a date field):

    method DEFINE.
    DATA: lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
              lo_property    TYPE REF TO /iwbep/cl_mgw_odata_property,
              lo_annotation  TYPE REF TO /iwbep/if_mgw_odata_annotation.
        super->define( ).
        lo_entity_type = model->get_entity_type( iv_entity_name = '[ODataServiceName]Type' ).
        lo_property ?= lo_entity_type->get_property( iv_property_name = '[FieldYouWantToFilter]' ).
        CALL METHOD lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation
            iv_annotation_namespace = /iwbep/if_mgw_med_odata_types=>gc_sap_namespace
            ro_annotation           = lo_annotation.
        lo_annotation->add( iv_key = 'display-format' iv_value = 'Date' ).
        lo_annotation->add( iv_key = 'filter-restriction' iv_value = 'single-value' ).
        CALL METHOD lo_property->/iwbep/if_mgw_odata_property~set_type_edm_datetime.
        CALL METHOD lo_property->/iwbep/if_mgw_odata_property~set_internal_type
            iv_type = cl_abap_typedescr=>typekind_date.

    You'll end up with this in your ALP filter.

    capture.png (6.4 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • May 21 at 03:03 PM


    Can you please share, How to add the same annotation in the CDS itself?



    Add comment
    10|10000 characters needed characters exceeded