Skip to Content
Technical Articles
Author's profile photo Facundo Ferrer

Down the rabbit hole: How to get current sap-client programmatically from a controller within SAPUI5.

Hi everyone!

As a sapui5/abap-rap developer I found my self a couple of times on the situation where I needed to know the sap client of the current system. I’ve taken different approaches through the years, but recently a found what seems to be a better path. I hope that sharing my experience and solution can help other developers who are facing similar challenges. Also do please comment if you feel this new approach is better or if it feels kind of “hacky” to you.

So I was building an utility tool to automate recurring tasks and needed to call an standard sap odata service that required the sap-client as an URL parameter.

My first idea was to build a new entity set on the oData service with a single record to keep environment variables and then expose sy-mandt from there. I’ve taken this approach before and I know it works quite well and is clean.

From a technical point of view it was not really a challenge. However I wasn’t 100% comfortable with it. I mean standard apps, do figure out the sap-client some how, don’t they? Why re-invent the wheel with an additional OData entity.

I did a little research online but coudn’t find a good article on how to get it. I explored using sap.ushell.Container. It had helped me before to get the current User ID, but no luck there either.

I even asked ChatGPT about it, cause, why not?

Same idea I had: build a custom service. It seems ChatGPT likes CAPM.

So went ahead and open the fiori launchpad, navigated to a standard SAP app and opened the google inspector on the network tab. Refreshed the view and got a list of all the requests:

To my surprise on the 15th call there was a call to “manifest.appdescr” with the urlParameter “sap-client=100”. So it had to happen before that.

start_up sounded like a good candidate. But no, no sap-client info was provided from the backend on body or headers.

And here is the deal: none of the other calls are odata service calls.

With a bit of luck I ended up going to ui.html. The second call on the list.

And then it showed up. A meta tag on the header.

With this in mind… it was quite easy to retrieve the sap-client.

I hope someone finds this handy.

So I came up with a new approach for obtaining the SAP client by inspecting the UI HTML of SAP app in the Fiori Launchpad rather than building a custom entity on an oData service. What do you think? Is this solution “hacky”? Should I take the building the custom entity path? Please share your feedback and thoughts on the comments section. Please share your feedback or thoughts in the comments section.

To stay updated on similar content and topics, follow my profile.

Follow the SAP Fiori environment Topic page on the SAP Community, post and answer questions on SAP Answers, and read other posts on the topic on the SAP Blogs.



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Shai Sinai
      Shai Sinai

      I wonder if this meta attribute is officially supported by SAP and if it is available also on standalone apps (not launched via the Fiori launchpad).

      Author's profile photo Facundo Ferrer
      Facundo Ferrer
      Blog Post Author

      Hi Shai, I don't think it is officially supported by SAP in any way, that's why I think is kind of "hacky". I just felt that building an entity set with a single record to get this value was an overkill and standard apps don't actually do that. I've actually seen several standard apps that have this head meta tag.

      Also I just checked a standalone app and it is showing the tag.



      Author's profile photo Shai Sinai
      Shai Sinai


      I can confirm I've also seen the sap-client attribute for standalone apps in my own tests.