Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

oData DateTime Error

AJeB
Participant
0 Likes
2,296

Who has already encountered this error. the Data Elements of ANGDT Field and other fields in DDIC are DATS while the EDM Core Type of oData entity set is EDM.DateTime. The Format of DATS is YYYYMMDD(original) MM.DD.YYYY(if view in DDIC ) and its not same in DateTime because it has time format but the available DataTypes is this(see image below) . i tried to change it to string also but i got another error.

i already check this link.
https://answers.sap.com/questions/10374686/rules-for-odata-datetime-properties.html

any solution for this or other links ?

3 REPLIES 3
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,118

As you looked at the other question, you know that we will ask you if you use V2 or V4?

Read only

rpalotai
Participant
0 Likes
2,118

Hi,

use DateTimeOffset at oData side and TIMESTAMP at ABAP side. At UI you can control the visualization of the DateTime field.

Be aware that the timezone of the user's browser can be diferent than the system timezone, so it can happen that the date will be differs at UI from DB!

Read only

ThorstenHoefer
Active Contributor
0 Likes
2,118

Hi Aron,

I have set the Date Format as annotation in the MPC_EXT class.

 DATA: lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
       lo_property    TYPE REF TO /iwbep/if_mgw_odata_property,
       lo_oanno TYPE REF TO /iwbep/if_mgw_odata_annotation.

 TYPES: proptab_type TYPE STANDARD TABLE OF /iwbep/if_mgw_med_odata_types=>ty_e_med_entity_name 
WITH DEFAULT KEY. lo_entity_type = model->get_entity_type( iv_entity_name = gc_xxxx ). DATA(lt_datum) = VALUE proptab_type( ( 'Bdatum' ) ( 'Changedate' ) ). LOOP AT lt_datum INTO DATA(l_datum). lo_property = lo_entity_type->get_property( iv_property_name = l_datum ). "Property to be annotated lo_oanno = lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( /iwbep/if_mgw_med_odata_types=>gc_sap_namespace ). lo_oanno->add( iv_key = 'display-format' iv_value = 'Date' ). ENDLOOP.