cancel
Showing results for 
Search instead for 
Did you mean: 

Date & Time fields in Import Structure

GK817
Active Contributor
0 Kudos

Hello Experts,

I have gone through the other related posts already asking similar question but still I need more information.

In my SEGW web service, import structure has first three fields as FLD1, EXEC_DATE, EXEC_TIME & these fields comprise the key also. Hence, they are not nullable.

System-default Edm types for date & time are Edm.datetime & Edm.time. There is no such Edm type as Edm.date. Also, values for these types are displayed as 2013-01-02T00:00:00 for date and PT10H10M00S as time.

Do we have any Edm type that would accept date as '2013-01-02' or '20130102' and time as '101000'? Or date & time are to be passed in this format only?

Please help on this. I need more clarity whether I am using correct Edm types & its fine for service to expect date & time in above format.

Thanks in advance

Gaurav K

Accepted Solutions (1)

Accepted Solutions (1)

ChandraMahajan
Active Contributor
0 Kudos

Hi Gaurav,

There is no EDM type available which will take date format as you mentioned. but it is possible to have the format you mentioned at client side. while passing the date to OData service, it should be passed as 2013-01-02T00:00:00 as you mentioned correctly.

also refer this thread and

Also refer ODATA DATE QUERY - Stack Overflow

Regards,

Chandra

GK817
Active Contributor
0 Kudos

Thanks a lot. I had read these blogs. But still wanted a kind of confirmation. Same is the case with time as well??

former_member184867
Active Contributor
0 Kudos

Apart from Edm.Datetime and Edm.DatetimeOffset we have Edm.Time. This represents the time of day with values ranging from 0:00:00.x to 23:59:59.y, where x and y depend upon the precision.Example 1:13:20:00

ChandraMahajan
Active Contributor
0 Kudos

Additionally annotate the date property with sap:display-format="Date" for pure date fields. Read response by Ralf Handl in thread

From OData version 4.0, there will be new edm type for date as Edm.Date and Edm.Duration for time. Please refer What's New in OData Version 4.0

But for that we need to wait as SAP NW Gateway is based on OData version 2.0

Just FYI.

Regards,

Chandra

RalfHandl
Product and Topic Expert
Product and Topic Expert
0 Kudos

Caution: Edm.Time uses the format of a duration, i.e. P13H20M for thirteen hours and twenty minutes.

To make things more interesting Edm.Time only allows durations smaller then 24 hours.

Which is why it was removed in OData 4.0 and two new data types were introduced:

  • Edm.TimeOfDay using hh:mm:ss format for time of day, and
  • Edm.Duration using xs:dayTimeDuration format for arbitrarily long durations.

Which hopefully makes things easier

ChandraMahajan
Active Contributor
0 Kudos

Hi Ralf,

do you know when SAP NW Gateway will support OData version 4.0?

Regards,

Chandra

RalfHandl
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Chandra,

Unfortunately I do not know when Gateway with OData 4.0 support will be available.

Note that Gateway already supports some of the OData 4.0 concepts, e.g. delta links and vocabulary-based annotations.

Regards

--Ralf

GK817
Active Contributor
0 Kudos

Thanks Chandra.

But while developing SAP NW GW service, where can i set this display format property for Date? I see there are flags for different properties but how to set such properties for specific fields?

Regards

Gaurav Karkara

ChandraMahajan
Active Contributor
0 Kudos

Hi Gaurav,

while creating project, you need to select Service with Vocabulary-Based Annotations to use annotations. Please refer Working with Annotations - SAP NetWeaver Gateway Foundation (SAP_GWFND) - SAP Library

Also follow the steps mentioned at Adding Vocabulary-Based Annotations to Data Model Artifacts - SAP NetWeaver Gateway Foundation (SAP_...

Regards,

Chandra

b_punith
Participant
0 Kudos

Hi Chandrashekhar,

I am with NWGW SP09 and new to NWGW.

I am getting the same Warning message as above mentioned when an Entity is created w.r.t DDIC Structure and if it contains Date/Time field.

I have changed the Edm Core Type to Edm.DateTimeOffset of those fields, still I was not able to rectify the warning.

If I change the ABAP Field Name to D, it throws error as it is not a part of Structure.

The same I didn't find in SP06.

Please do help to understand the concept.

Thanks in Advance.

Regards,

Punith

Former Member
0 Kudos

Hi Chandra,

In which vocabulary file does the sap:display-format annotation definition reside?


I have imported all available vocabulary files into my Gateway project, but I am unable to find this specific annotation.

Thank you!

Regards,

Chad

0 Kudos

Hi,

Can you please tell me how you managed to set the display format through the odata service? Thank you

Answers (1)

Answers (1)

RalfHandl
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Gaurav,

The names EXEC_DATE and EXEC_TIME suggest that these two backend fields belong together and combined identify the point in time at which something gets executed.

If that is the case, the best modeling approach here is to combine the two backend fields EXEC_DATE and EXEC_TIME into one OData property ExecDateTime of type Edm.DateTimeOffset (Offset == with time zone information).

That way the real business semantics is visible in the OData model, and the implementation detail of storing the point in time in two ABAP fields is gracefully hidden from the consumer.

Regards!

--Ralf