SAP OData. Part 15 – Expected type is ‘Edm.DateTimeOffset’ Error

0
7256
Edmdatetimeoffset

Every day is a new learning day while working in any technology. You might have been in one field for years, but there is some innovation going on continuously. So, the way you were handling some program yesterday might not work today, although all innovations are supposed to be backward compatible.

Coming to the topic of the day. We will check 2 typical errors we receive when we try to consume SAP OData Service in UI5 App or any other application. Even in /N/IWFND/GW_CLIENT T-code, we get these errors. Lets dig in deeper now.

Issue 1 – Expected type is ‘Edm.DateTimeOffset

In OData, earlier we used to handle the date with key word datetime’YYYY-MM-DDTHH:MM:SS’, but the other day I received error Expected type is ‘Edm.DateTimeOffset’.

The exact error message was Invalid function import parameter type for ‘DateOfBirth’. Expected type is ‘Edm.DateTimeOffset’ In our case, DateOfBirth was the field/property name of the Entity Type.

Earlier we used to handle date with datetime‘YYYY-MM-DDTHH:MM:SS’ like in this example URI – /sap/opu/odata/sap/ZGW_PREQ_SRV/PReqSet?$filter=Erdat gt datetime’2015-01-01T00:00:00’and Ekgrp eq ’17’and Werks eq β€˜4030’.

But that key word was not working. Then we took a step back to look at the properties. Earlier the Edm Core Type for the date field was Edm.DateTime, so the keyword datetime‘YYYY-MM-DDTHH:MM:SS’ worked.

For the current OData Service, we checked the Entity Properties. We can see that the EDM Core Type for this date field is Edm.DateTimeOffset. That makes sense why the datetime keyword did not work.

Assuming the pattern will work, we tried to put the keyword datetimeoffset‘YYYY-MM-DDTHH:MM:DD’ and bingo.. It worked like a charm.

So, our URI looked like /sap/opu/odata/sap/ZE_OData_SRV/POSID_KBA?DrLicense=’12’&DrLicenseRegio=’TX’&DateOfBirth=datetimeoffset’2020-01-10T01:01:01′&Language=”&Middle=”&Name_First=”&Name_Last=”&Name_Last2=”&ResetPOSIDHold=false&SocSecure=”&Trans_No=”

So next time you get this error ‘Expected type is ‘Edm.DateTimeOffset”, you know exactly what to do. πŸ™‚

And if your Entity Type property is Edm.DateTime, you still need to use only datetime keyword. Do NOT add offset to it. πŸ˜›

New Training Announcement

ABAP RESTful Application Programming on Cloud & on Premise – Starts 6th of Feb 2021

Enrollment Link – ABAP RAP
Course Syllabus – ABAP RAP Content
Training Days – 6, 7, 13, 14, 20, 21, 27, 28 Feb, 6 & 7 Mar 2021 IST
Time: 7:30 AM to 9:30 AM IST (GMT+5.5)

Issue 2 – Expected type is ‘Edm.Boolean’

Let us talk about another simple error ‘Expected type is ‘Edm.Boolean’.

Let us check the property of the Entity. It is Edm.Boolean.

Using our reasoning sense, in Edm.DateTimeOffset demands the keyword datetimeoffset, then Edm.Boolean should ask for keyword boolean. Sadly, that does not hold true.

It gave Malformed URI literal syntax error.

So, the right way to handle any boolean property is by passing values true or false.

So, our URI looked like /sap/opu/odata/sap/ZE_OData_SRV/POSID_KBA?DrLicense=’12’&DrLicenseRegio=’TX’&DateOfBirth=datetimeoffset’2020-01-10T01:01:01′&Language=”&Middle=”&Name_First=”&Name_Last=”&Name_Last2=”&ResetPOSIDHold=true&SocSecure=”&Trans_No=”

We can also use false in the above URI for the boolean property.

Did you face any such practical issues? Do share with us in the comments section. We will be happy to put a dedicated post for those issues.

Comments, please.

Please follow our LinkedIn Page,LinkedIn Group, Facebook Page, Facebook Group, Twitter , Instagramand Telegram SAP Technical GroupSignal Group.

Do not forget to SUBSCRIBE to our YouTube Channel for Free Courses and Unconventional Interesting Videos.

Also consider joining SAPYard’s Telegram Channel for SAP Blogs and Tutorials.

Save our number +1-251-727-9273 and send us a Whatsapp message ‘LEARN’ to be part of our Learning Community.

Complete SAP OData & SAP Netweaver Gateway Tutorials

LEAVE A REPLY

Please enter your comment!
Please enter your name here