Skip to Content
Technical Articles
Author's profile photo Matthew Shaw

SAP Analytics Cloud Export Data API Sample Scripts

I’ve written a bunch of Sample Scripts, in Postman, that demonstrate how the ‘export data’ API retrieves data from models stored inside SAP Analytics Cloud. These samples are now available.

This blog first takes a step back and provides an overview of other means and ways to extract data before then introducing the sample scripts themselves. If you are thinking of using the export data API, then these samples and the associated User Guide can remove some barriers to adopting the API since much of the code and logic can easily be re-used and they provide a useful insight into how the API works and behaves.

A number of, currently undocumented but supported features, also form part of these samples. It means the samples and this associated User Guide provide a practical starting point to ensure your coding project gets off to the best start possible.

Overview

SAP Analytics Cloud is often chosen as an enterprise planning solution. The planning data, held in SAP Analytics Cloud, occasionally needs to be further integrated in other systems to complete the business planning process in some way or another. This new ‘export data’ API provides another option to the many already existing options that is described now.

There are many means and ways to export data from SAP Analytics Cloud to other systems and these include using the:

A new method is available with SAP Analytics Cloud Q2 2022 Quarterly Release called the ‘export data’ API. This is an extension to the OData standard and allows the retrieval of all the data from acquired models (both analytic and planning models) on a ‘pull’ basis, unlike the above methods which operate on a ‘push’ basis. The official documentation describes it as

… a PULL based API data extraction API that helps with data integration from SAP Analytics Cloud to SAP Data Warehouse Cloud, SAP BW, SAP HANA, and other third-party tools. The API doesn’t have a dedicated user-interface, and simply extracts data and information about providers.

Sample Scripts

These sample scripts, written in Postman, demonstrates each of the API endpoints. The samples are provided on an ‘as is’ basis and they only retrieve data from SAP Analytics Cloud models, they don’t do anything with the data once it’s been retrieved. Though, some of the samples writes the data to the console, but that’s it. It means these samples are just to demonstrate the API endpoints along with many aspects such as how:

  • sessions and errors can be managed
  • ‘pages’ of data can be retrieved when multiple pages are available (the samples automatically fetch all the pages of data)
  • optional request parameters can be used

If you’re using an SAP connector then there’s no code to develop, it’s just plug and play:

Target system that will pull data from SAC: Related article:
Data Warehouse Cloud and Data Intelligence blog
SAP HANA, SAP BW on HANA, SAP BW/4HANA blog

However, if you are using your own custom application then you will need to write code.

Postman, which is freely available, is a commonly used tool for implementing API workflows. Postman provides a good basis to demonstrate how requests are made to the API, and optionally export code snippets in various languages, such as Java, Python, C, PHP, Node.js and many others. This means development time can be reduced, but nevertheless you will need to adapt the scripts for your own use, either to process the data or upload it to a target data source for further processing.

The list of the samples I’ve provided are:

  • Export Data 761-Test-Environment Setup
  • Export Data 762-Metadata
  • Export Data 763-Namespaces (sets Environment ExportData_NamespaceID)
  • Export Data 764-Namespaces ID
  • Export Data 765-Namespaces ID Provider
  • Export Data 766-Fcj-Provider Metadata
  • Export Data 767-Fcj-Service Document
  • Export Data 768-Fcj-Fact Data
  • Export Data 769-Fcj-Master Data
  • Export Data 770-Fcj-Audit Data
  • Export Data 771-Fcj-Dimension Master Data

Resources

SAP Analytics Cloud Export Data API Sample Scripts User Guide Version 0.7.1 – August 2022
.pdf Download
.pdf Preview
Samples (the code) Version 0.7.1 – August 2022
Github (zip downloadChange log

Frequently Asked Questions

Q1: When retrieving a dimension the columns ‘read’ and ‘write’ (that are used by SAP Analytics Cloud for Data Access Controls) are not returned, why is this?

A1: Data Access Controls and Data Locks are not part of the master data but an extension to the dimension metadata for use only by SAP Analytics Cloud, they have a dependency on them. They are not available for data retrieval and they don’t form part of the API. There are no plans to change this.

 

Q2: When retrieving a dimension the column ‘parent‘ (that is used by SAP Analytics Cloud for hierarchical data structures) are not returned, why is this?

A2: The hierarchy is part of an internal hierarchy extension and doesn’t form part of the data retrieval and they don’t form part of the API. There are no plans to change this.

 

Q3: Calculated measures are not retrieved, why is this?

A3: The API is for data retrieval only and a calculated measure is out of scope for this reason (the API is only for data retrieval not for any form of ‘query’ aspect). They are not available for data retrieval and they don’t form part of the API. There are no plans to change this. As a workaround, these measures could be materialised via a data action making them then retrievable.

 

Feedback

I’ve invested a great deal of time and effort into these materials and so your feedback is very welcome and will help judge if I should continue to create these kind of resources

Please do:

  • Comment if you use these resources in anyway (or if you’re shy, just hit the like button!)
  • Share which sample scripts you’ve used. Other customers would love to hear if you’ve used the scripts. It will give them a sense of how reliable they are! 😉
  • Share your experience
  • Share how much time you saved because of these resources, would you had been as successfully without them?

Before posting any questions please:

  • Do read the contents of the User Guide. I appreciate you may not have the time to read it all. If you’re looking for a quick answer and don’t have the time, feel free to post a question to the community rather than here, it will help keep the number of questions here reduced and it will help others find answers easier (than searching this blogs’ Q and A). You can always ‘@tag’ me in your post so I get a notification, and you can always post a link to your question from a comment to this blog if you think that might help others.
  • If you’ve got a question about the API in general, then post a question to the community rather than here

Feel free to follow this blog post for updates. I’ll update the version numbers in this blog post when there’s one to update.

Many thanks

Matthew Shaw @MattShaw_on_BI

https://people.sap.com/matthew.shaw/#content:blogposts

Assigned Tags

      7 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Fabian Runge
      Fabian Runge

      Hi Matthew,

      the new API looks super promising and our first test worked very well but unfortunately we didn't find a way to export calculated measures from SAC models via this method.

       

      Are there any ways to access these measures?

       

      If not are there plans on offering this functionality in the future?

       

      Best

      Fabian

      Author's profile photo Matthew Shaw
      Matthew Shaw
      Blog Post Author

      Hello Fabian

      I've just added an FAQ section to this blog post which captures your question and the answer.

      All the best, Matthew

      Author's profile photo Matthew Shaw
      Matthew Shaw
      Blog Post Author

      Just updated the documentation to reflect the support for 3-legged OAuth as it is now supported 🙂

      Author's profile photo Matthew Shaw
      Matthew Shaw
      Blog Post Author

      I've just added a duplicate set of Samples that support 3-legged OAuth. The 3-legged OAuth sample scripts start with an '8' rather than a '7' for example the 3-legged OAuth version of sample '765' is '865' etc. Whilst the user guide will be updated later, a few short instructions to get these 3-legged OAuth samples to work:

      • You need to create a new SAC OAuth client as this new OAuth client must have the 'Redirect URI' to be 'https://oauth.pstmn.io/v1/callback'.
      • Your web browser must allow pop-ups and re-directs for 'oauth.pstmn.io'
      • and finally the user you use to login to SAP Analytics Cloud needs to be a non-admin user, assuming you want that user to see a restricted set of models/data.

      And don't forget you need to press the 'Get New Access Token' in the 'Authorization' tab of the request.

      Hope you find them helpful. Matthew

      Author's profile photo Matteo Spagnoli
      Matteo Spagnoli

      Hi Matthew,

      thanks for the blog post. It is indeed a very promising feature especially to avoid exporting SAC model's data to flatfiles.

      I have a question: do you think it is possible to use this API as a OData source for SAP BusinessObjects unx? And if yes, what should the service root uri look like? I'm currently testing on a 4.3 SP1 release but it doesn't seem to work properly:

      Test%20Api%20with%20generic%20odata%20driver

      Many thanks for any suggestion you would like to share.

      Best Regards.

      Test Api with generic odata driver

      Author's profile photo Matthew Shaw
      Matthew Shaw
      Blog Post Author

      Hi Matteo

      Good thinking, I like it, Sadly though this API doesn't conform to the right requirements for BusinessObjects to consume it 🙁

      All the best, Matthew

      Author's profile photo Matteo Spagnoli
      Matteo Spagnoli

      Hi Matthew,

      ok. This is indeed quite unfortunate.

      Thanks, by the way, for your quick reply.

      Best Regards.