Skip to Content

$metadata gets concatenated to OData URI...but why?

Hi Experts,

Apologies up front if this question is placed in the wrong forum. I did research the issue, and became even more confused than before. I'm not a web dev. I'm just a simple abap dev (not an expert), with java/c# roots, who has also spent a little time with PI and basis. A jack of all trades, but master of none, if you will...

So... we've built an application and we're at the point where we need to replace mock data with data from the odata service. The NWGateway system is setup, and the connection works. The service URI looks like this: '<host>:<port>/sap/opu/odata/SAP/Z_EMTIPPSPIEL_SRV'. The desired entity set (/TileCollection?) should be appended at runtime, when we call our dashboard.

The TileCollection entityset should call the method (in the DPC- generated by the gateway service builder) TILECOLLECTION_GET_ENTITYSET.
This method sends xml or json back. It works fine in the HTTP Request/Response tool. My data is returned and all is good in the world, birds sing, the sun is shining etc...

But, when I plug this URI (minus the TileCollection suffix) into my manifest, and run the application...the backend (somewhere...) concatenates a $metadata to my service URI. And I get no data.

I've researched the issue and know enough to be a danger to myself and those nearby. I found out that this isn't a bug, it's a feature!! [WHEW! Thank goodness!]

But wth...how do I get around this. The machine wants to get metadata for the query first. I'm cool with that. But how can I tell it to take the metadata and feed it to the wolves, so that I can call the service and get my TileCollection entity set.

Background info...
all views are xml views. The data binding is in the view. The entire thing was developed in WebIDE, cause I'm not really fluent in the magical world of javascript. I can understand what goes on in the simplest of code, and even compose a few lines...but the stuff that happens behind the curtain...js is just magic to me.

I'd be eternally grateful for any help, or shove in the right direction.

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    Apr 14, 2016 at 10:28 AM

    Hi Sean,

    I must say nicely put question 🤣.

    The SAPUI5 framework is designed in an optimized way which prevents unnecessary backend server calls. To support this a call for $metadata is always sent automatically as a prerequisite before firing other calls from applications to confirm whether the service is available. If the metadata call is successful then the remaining calls are triggered.

    Another optimization which is done is the framework always fires a $count call to check the number of records available in any entity. If its non zero then the actual call to fetch the data is fired.

    In your case, ideally if metadata call is going through and the count is non zero then data should come.

    Can you please attach the screenshots of Network tab showing the calls and the errors(if any)/or data.

    BR.

    Add comment
    10|10000 characters needed characters exceeded