SAP List Report Filter Bar Date Format

You have implemented the Fiori List Report (Fiori elements) but the date field is not showing date picker control? Read more to see how to add the missing annotation.

Redefine you define the method in DPC_EXT class and put following code.

METHOD define. 
   super->define( ) . 
   "Annotation to provide default Date Picker for Date field in Smart Table 
   TRY. 
      DATA(lo_entity_type) = model->get_entity_type( iv_entity_name = 'MaterialRequirement' ). 
      DATA(lo_property) = lo_entity_type->get_property( iv_property_name = 'SupplyDate' ). 
      DATA(lo_annotation) = lo_property-/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ).
      lo_annotation->add( iv_key = 'display-format' iv_value = 'Date' ). 

      "sap:filter-restriction="interval" 
      CLEAR lo_annotation. 
      lo_annotation = lo_property-/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ). 
      lo_annotation->add( iv_key = 'filter-restriction' iv_value = 'interval' ).
      lo_property = lo_entity_type->get_property( iv_property_name = 'DemandDate' ). 
      lo_annotation = lo_property>/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ). 
      lo_annotation->add( iv_key = 'display-format' iv_value = 'Date' ). 

      "sap:filter-restriction="interval" 
      CLEAR lo_annotation. 
      lo_annotation = lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ). 
      lo_annotation->add( iv_key = 'filter-restriction' iv_value = 'interval' ). 
   CATCH /iwbep/cx_mgw_med_exception . 
   ENDTRY. 
ENDMETHOD.

Annotation display-format will give you date picker in the field. Additionally, you can use filter-restriction annotation to turn this filter interval as in from and to style.

smartfilter date picker

Recommended reading

https://www.samplecodeabap.com/value-help-smartfield-odata-annotation/

Update : 17/11/2019

Below annotation seems to do same

@Consumption.filter: { selectionType: #INTERVAL, multipleSelections: false }

3 Replies to “SAP List Report Filter Bar Date Format

  1. Hi Pawan

    I added the above annotation however when running it locally using web idea personal edition(without deploying app to gateway), I still donot see the date box as shown above. Am I missing something, please could you reply.

    Thanks

Leave a Reply