I’ve been pulling my hair out for the last few hours trying to work out what was wrong with my SAPUI5 demo application. I finally worked it out and want to quickly share what the problem was in case others fall into the same issue.
Back at the end of last year I had downloaded the SAPUI5 Trial version (at the time version 1.4.3) and had written a very basic MVC demo app to get familiar with how things worked in SAPUI5. I had the usual issues with CORS (Cross Origin Resource Sharing) – you will find lots of posts about solutions for that in the discussions on SCN, but finally got a basic example working, calling an ODATA service from the SAP Enterprise Workplace system. All was good, I was a happy chap 😀 . Then things got busy, and I only came back to this example a few days ago when I wanted to get the same example working from a “real” SAP system where we recently installed the SAP UI Add-On 1.0 and Gateway.
So I wanted to keep it simple, I used the same method to create a new SAPUI5 application to read a simple ODATA service from my SAP system and put the data into a table. Everything looked the same, I could see (in the developer tools) the first request being sent to the ODATA service on the SAP server and I could see the response coming back, it all looked good, but I was getting “No data” in my table…
So what was going on? I spent a while checking my code for stupid syntax mistakes… nothing. I had no idea. As far as I could tell the only difference between the new and the old app was the version of the SAPUI5 I was using. The version on my SAP server was 1.8.4 (the old one was 1.4.3). I then decided to set up a direct comparison. I updated my local Tomcat server with both the 1.8.4 and the older 1.4.3 versions of SAPUI5 and ran them side by side. I then switched the bootloader statement in my app to use one or the other. What I found was that when I used the 1.4.3 version my code worked fine and the table was populated with data:
When I then switched to use version 1.8.4 it stopped working and I got “No data” again. So I concluded it must be the version.
So how to fix it? I could find lots of posts about not getting any data into tables, but mostly it was due to the CORS issue, I knew that wasn’t the problem. So I went to the release notes in desperation 😏 . Now reading release notes isn’t that much fun, but I started with version 1.4.3 and worked up to see if anything might mention a change that was causing the problem… and there it was…
CHANGE: Databinding syntax changed, so that absolute bindings now must have a leading slash. For compatibility reasons, method setLegacySyntax() can be used to enable the old binding syntax.
What the hell I thought, lets try to add a forward slash to the oTable.bindRows(“/SOHeaders”) statement and what do you know, suddenly it worked and no more “No data”! 🙂
Here is a little video that shows the problem and the solution:
So if you are trying out SAPUI5 and you are following some of the older tutorials or blog posts from people here on SCN and you are getting “No data” in your tables it might be a CORS issue but it might also be that you are missing the leading slash “/” in your binding statement. I hope this post will save you some time and let you get on with more interesting bits of SAPUI5.
Please share your comments and thoughts below.