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
- OData and SAP Netweaver Gateway. Part I. Introduction
- OData and SAP Netweaver Gateway. Part II. Create your first OData Service
- OData and SAP Netweaver Gateway. Part III. Query Options in OData Service URI
- OData and SAP Netweaver Gateway. Part IV. Association and Navigation in OData Service
- OData and SAP Netweaver Gateway. Part V. CRUD Operations in OData Services
- OData and SAP Netweaver Gateway. Part VI. Frequently Asked Questions
- OData and SAP Netweaver Gateway. Part VII. Debugging, Trace, Cache Cleanup and F4 Help
- OData and SAP Netweaver Gateway. Part VIII. SAPβs Love for OData β a Tale of the Friendly ABAPer
- CDS Part 3. Expose CDS Views as OData Service through Annotation
- OData and SAP Netweaver Gateway. Part IX. How to Add Multiple Entities in One Operation in OData Service
- OData and SAP Netweaver Gateway. Part X. How to Delete OData Service from Service Catalog?
- OData and SAP Netweaver Gateway. Part XI. Query Options & HTTP Status Code Summary
- SAP Netweaver Gateway and OData. Part XII. Media Handling using OData GatewaysΒ Β Β
- SAP Netweaver Gateway and OData. Part XIII. Entity Tags in SAP OData Gateways
- SAP Netweaver Gateway and OData. Part XIV. OData Service using RFC
- Free Video Course β Introduction to SAP Netweaver Gateway & OData
- SAPUI5 for ABAPers – Consuming OData Service from SAPUI5 Application – CRUD Operations
- Advance SAPUI5 – 2- Push Notification in SAP – ABAP Push Channel, ABAP Messaging Channel in SAPUI5 – a Real Time Interaction
- CDS Part 11. How to Consume CDS View in Smart Business Service KPI Fiori Apps?
- XSOData and Hana Database Views for Beginners
- OData Service from CDS Annotation Not Working in Browser Mode
- SAPUI5 – Custom Control in UI5
- Using Postman to “POST” without modifying ~CHECK_CSRF_TOKEN in ICF settings.
- ABAP Programming Model for SAP Fiori – 4 – OData Service Creation
- ABAP Programming Model for SAP Fiori – 5 – OData Service Generation
- CDS Part 20 β Virtual Elements (ABAP Functions) in CDS
- UI5 Tooling – Develop UI5 Apps in the Editor of your Choice – 1
- UI5 Tooling – Consume OData Service via UI5-Middleware-SimpleProxy – 2
- SAP OData. Part 15 – Expected type is ‘Edm.DateTimeOffset’ Error
- CDS – 26: Analyzing CDS with Analytical Annotation and Manipulating its Filter Options