cancel
Showing results for 
Search instead for 
Did you mean: 

How to annotate a DateTime field as simply Date

Former Member
0 Kudos

Hi,

I would like to return my ABAP date fields as simple Dates, with no time aspect.

My understanding is that I need to add an annotation of "sap:display-format="Date".

Do I add this annotation in the MPC class?  Do someone have a link to a procedure on how to do this?

Thank you for any input.

Kevin

Accepted Solutions (1)

Accepted Solutions (1)

JyotiD
Active Participant

Hi Kevin,

There are multiple documents available on annotation in Gateway.

Check these link if helps.

Maintain Annotation Models - SAP Gateway Foundation (SAP_GWFND) - SAP Library

Working with Annotations - SAP Gateway Foundation (SAP_GWFND) - SAP Library

You can add annotation at code level also in Model class using method /IWBEP/IF_MGW_ODATA_MODEL->CREATE_ANNOTATION.

Add this piece of logic for your property.

DATA lo_annotation   TYPE REF TO /iwbep/if_mgw_odata_annotation.

  lo_annotation = lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation

  ( /iwbep/if_mgw_med_odata_types=>gc_sap_namespace ).

  lo_annotation->add( iv_key = 'display-format' iv_value = 'Date ).

Clear cache and check metadata for same.

Regards,

Tarun

Former Member
0 Kudos

Thank you, Tarun.   That worked great!

JyotiD
Active Participant
0 Kudos

Great Kevin. If you find your answer then please close the thread.

Regards,

Tarun

Answers (0)