Skip to Content
avatar image
Former Member

date in filter option of the sapui5 list report

Hi Experts,

I have created sapui5 list report using list report template, i have one field "As on Date" in the selection fields of the report. this fields is showing as Multiinput instead of Datepicker on the screen. I want to show that field in

- There is no annotation coming from backend system.

- filed is type date (Edm.DateTime) in the backend.

- in metdata file i have maintained sap:display-format="Date" property

-Metadata file:

<Property Name="Dmdt" Type="Edm.DateTime" Nullable="false" Precision="7" sap:label="As on date" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:display-format="Date"/>

I want to show field as Datepicker.

Please suggest way forward.

Regards,

Saurabh

Add comment
10|10000 characters needed characters exceeded

  • Hello Saurabh,

    I checked the smart filter bar code and it looks for display-format annotation. Can you share the snippet of the code to check further.

    Thanks and Regards,

    Veera

  • Former Member Veeraraghavan Narasimhan

    Hi,

    Below is the snippet:

    this is my metadata file:

    I have added display-format ="Date" for date field but it is not showing me 'Datepicker' on the selection screen

    snippet.jpg (41.6 kB)
  • Get RSS Feed

4 Answers

  • Jan 23 at 02:53 PM

    Hello Saurabh,

    Did you figure it out ?

    Thank you mate !

    Olivier

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 04 at 01:02 PM

    (In case anyone stumbles across this in the future)

    If this is the type of field you are looking for it can be achieved by adding an additional annotation via a redefinition of the DEFINE Method in the implementing class.

    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 = 'ZSomeODataServiceType' ).
    lo_property ?= lo_entity_type->get_property( iv_property_name = 'SomeDateField' ).
    
    CALL METHOD lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation
      EXPORTING
        iv_annotation_namespace = /iwbep/if_mgw_med_odata_types=>gc_sap_namespace
      RECEIVING
        ro_annotation           = lo_annotation.
    
    lo_annotation->add( iv_key = 'filter-restriction' iv_value = 'interval' ).

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 09 at 10:34 PM

    Hello,

    I'm with this very same problem. I created both annotations "display-format" and "filter-restriction" to my DateTime field and my smart filter does not change.

    Any solutions?

    Add comment
    10|10000 characters needed characters exceeded

  • Hi,

    As Mark Castle mentioned, you can use filter restrictions. If you want to show a date picker instead of date range selection, use filter-restriction value as Single.

    Sample CDS annotation:

    Common.FilterExpressionRestrictions: [{ Property: <your Date Field>, AllowedExpressions: #SingleInterval } ]

    hope it helps.

    Regards,

    Vinod

    Add comment
    10|10000 characters needed characters exceeded