Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to annotate a DateTime field as simply Date

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

Former Member
replied

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

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question