Professional Documents
Culture Documents
4 | SAP Blogs
Products
Products Industries
Industries Support
Support Training
Training Community
Community Developer
Developer Partner
Partner
About
About
Ask a Question Write a Blog Post Login
This is a post about how easy it is to release a BEx query for OData consumption.
Let’s say that your Ecommerce solution needs to get the quantity available in stock for a speci c material at
a speci c plant. This can be achieved by making the Ecommerce solution call to an OData enabled BEx query in
your BW.
Most “modern” applications can speak OData, for example SAP Fiori, SAP NW, and Microsoft Azure. More
info and some nice diagrams about OData and BEx queries can be found here.
These are the steps to follow to make a BEx query available for OData consumption:
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 1/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
To demonstrate step 3 I’lll use a ready made solution on the BW side, and a Python program as my
Ecommerce solution.
Security note: in this example I’m using plain text authentication, meaning that the credentials will travel
through the network without encryption. This is not suitable for production use.
Let’s start:
Follow only the three steps in the st part of the note: “I.Con guration of Gateway”.
Note that the following is a simple query that just returns the stock quantity for material and plant, it does
not have any input ready variables. The date is handled via a non input ready variable.
While testing you can put some static lters in your query, like 5 materials, and 2 plants, to avoid getting the
list of all materials and all plants. In the nal version the lter for material and plant will come from the
OData query string.
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 2/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
When saving the query check that there are no error messages, usually those are authorization related.
When you save a query with the OData ag on, the system auto-generates some things related to OData.
Now we need to release the service for OData, we can follow the instructions from here.
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 3/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
Then from the list (if the list is empty you can press “Get services” button) select the line that contains the
query with a _SRV su x and press “Add selected services”
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 4/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
Note: If by any reason you cannot see the new service, you can force the generation of the service
for the query using function module: RSEQ_NAT_GENERATION in SE37. Just ll the the technical name of
the query in the input structure.
And you should be able to see the XML de nition of the query/service:
The relevant information here are the two characteristics from Rows section that can be found by key and
text, with the “_T” su x. The key gures from the Columns section are
A00O2TM5ZRDCVNYBZ57LAF99TM and A00O2TM5ZRDCVNYBZ57LAF99TM_F (the “_F” su x means
formatted, in this case with Unit).
I’ve been playing around with OData in Azure before, and the best client I could nd (this was in November
2015) is: XOData®: OData Visualizer and Explorer – PragmatiQa available here. Note that I’m using the paid
version.
At the end I will also call this OData service from Python.
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 5/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 6/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
Choose OData Metadata URL, then enter the URL of our query, and press Get. Then you can switch to the
next tab.
Here you can see again the elds that the service is returning. Now let’s go the next tab “Query builder”. Play
a little and do a query like this:
In (A) you have the OData query that can be used to get the inventory quantity for a speci c material and
plant. You just need to replace the values in quotes with your material and plant key.
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 7/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
And that’s it, any application that speaks OData can request the inventory quantity for any material and
plant.
I used PyCharm Community Edition and Python 3.5. I also added these two modules with from command
prompt:
import requests
import feedparser
# These are the elds from the XML le in the URL of the query.
elds = {‘d_a0material_t’
‘d_a0material_t’: ”, ‘d_a0material’
‘d_a0material’: ”, ‘d_a0plant’
‘d_a0plant’: ”, ‘d_a0plant_t’
‘d_a0plant_t’: ”,
‘d_a00o2tm5zrdcvnybz57laf99tm_f’: ”}
‘d_a00o2tm5zrdcvnybz57laf99tm_f’
# Replace the values for your host, port, user and password, plant and material
r=
requests.get(‘‘http://host:port/sap/opu/odata/sap/Z_ODATA_INVENTORY_SRV/Z_ODATA_INVENTORYRes
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 8/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
ults?$top=20&$ lter=A0PLANT eq \’
\’YOURPLANT
YOURPLANT\’
\’ and A0MATERIAL eq \’
\’YOURMATERIAL
YOURMATERIAL\’
\’‘‘, auth=
(‘youruser’
‘youruser’, ‘yourpass’
‘yourpass’))
if r.status_code == 200:
d = feedparser.parse(r.content)
data = d[‘entries’
‘entries’][0]
elds[item] = data[item]
print ( elds[item])
else:
else
print(r.status_code)
In line 1 we get the material description, on the next line we see “1.0 PC” that is the formatted quantity, on
line 2 we get the plant description, on line 3 we get the material key, and on line 4 is the plant key.
This is it!
Hope you enjoyed this example. If you have managed to use OAUTH for this queries, please share.
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 9/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
Thanks!
Other great blogs about OData: OData – Everything that you need to know (Part 1)
Assigned tags
View more...
Related Blogs
Using SAP BEx and SAP BO as an alternative to report SAP BPC data for Financial Consolidation
By Fernando Faian , Apr 07, 2017
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 10/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
Related Questions
19 Comments
Former Member
I have marked OData ag in my query, but I can’t see it in /IWFND/MAINT_SERVICE tx, in order to select the service.
When I press “Get services” button appear many services except mine.
I have checked Gateway Con guration and it looks ne. I am working in embedded deployment and my system is Netweaver
7.4 SP8.
Thanks in advance.
Best regards
Cesar Begazo
Like (0)
Former Member
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 11/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
Also make sure that the BEX query designer in your PC is up to date, and pay attention to messages when
saving:
“When saving the query check that there are no error messages, usually those are authorization related. When you save a
query with the OData ag on, the system auto-generates some things related to OData.”
I my case I was lacking some authorization objects, and thus it was not generating the objects when saving, but was showing
some warning in the Bex query designer.
Best regards,
Miguel
Like (0)
Vanessa Martinez
Like (0)
Former Member
I have the same problem. After create the query with the odata ag. I don’t see the service.
Like (0)
Former Member
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 12/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
I have solved the problem. In my case, my query was not in a transport request, because that OData objects
couldn’t be created.
I used transport connection to assign query to a transport request. It resolve the problem.
Best regards
Like (0)
Eduard Sanz
Like (0)
Rachid Kaouass
nice blog, I’ve succeeded to generate my oData service and consume it.
We wanted to get the data from a drilldown as we can do using the BEx Query, however, I don’t see how to
manage the “drilldown” using the oData Service.
Regards,
Rachid
Like (0)
Not sure if I understood you correctly. The drilldown happens at the frontend, if you manage to a write a
frontend that detects when the users does a drilldown, and then generates the new query, that’s it.
Regards,
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 13/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
Miguel
PS.: Check also this: Connect to an OData feed (Power Query) – Excel
Like (0)
Rachid Kaouass
When you execute a Bex Query, you can right-click on the report, on a certain value, and then you can drill
down. So in that case a new column will be displayed and still using the same Query.
Unfortunately, using the generated oData, they are not ways to request this detail with the same Bex Query.
I had to ask to generate a Bex Query that display every column, and then I did in the UI5 application the
aggregation and the drill down.
Best regards,
Rachid
Like (0)
Former Member
Created a BEx query ; enabled the By Odata checkbox ; publsihed using the Tcodea and tests ne in the NW
gateway.
In the browser, I was able to generate the metadata but when I try to do /QuerynameResults,
it throws me
ERROR: Access using a ‘ZERO’ object reference is not possible. (termination: RABAX_STATE)
Searching through all available online sources, I understand that my Odata service is absolutely correct and
could generate the Metadata perfectly ne.
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 14/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
Regards,
Deep
Like (0)
Br,
Miguel
Like (0)
Like (0)
Former Member
I am new to BW/BI, i have the same requirement as your example is, But the problem is that “By
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 15/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
How to enable “By oData” option? Is this because of lower level Support Package?
Regards,
Karthik Sridhar
Like (0)
Arne Witte
you need to update your BI Addon front end tools. Query Designer SP0 is too low. Just take the actual SP,
then the option will be displayed. I have installed SP7 and the option is available.
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 16/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
Regards,
Arne
Like (0)
Former Member
Like (0)
Former Member
I am facing the same problem, I have collected the query in transport request, and i have tried generating
the service via the functional module, i am still not able to generate a service.
Like (0)
Former Member
Thanks, Anders
Like (1)
Wolfgang Lindner
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 17/18
27/1/2019 BEx queries and OData in BW 7.4 | SAP Blogs
Hi all,
the oData enabled query does not supported the central hub architecture.
Is that correct?
My goal is to consume the query with a Fiori frontend by using a separate gateway system as recommended
by SAP.
Regards
Wolfgang
Like (0)
Sangharsh Aggarwal
Like (0)
Sitemap Newsletter
https://blogs.sap.com/2016/02/08/bex-queries-and-odata-in-bw-74/ 18/18