Skip to Content
Technical Articles
Author's profile photo Stephanie Lewellen

Part 6: Construct an SAP Graph Business Data Graph


INFO: This blog is part of a tutorial series for the standalone SAP Graph service on SAP BTP. Recently, SAP released a version of Graph in SAP Integration Suite with better user experience and functional enhancements (see this blog for details: https://blogs.sap.com/2023/02/22/announcing-graph-in-sap-integration-suite).


 

Hello! 

In this sixth part of the tutorial on SAP Graph – the new API for connecting to your business data – we will discuss the concepts and configuration of the Business Data Graph. Please refer to the information map to see all parts of this tutorial series. The documentation on Help Portal provides an in-depth look at many of the concepts featured in this part. 

What makes the “graph” in SAP Graph? 

SAP Graph offers an API for developers, providing them one connection to your business data in the form of a connected graph of business entities which we call the Business Data Graph. The business data graph is constructed by SAP Graph through discovery of the landscape and reflects the connected data entities available in the landscape, including custom fields.  

Part 5 introduced the roles of administrator and key user, and how to configure a landscape and the corresponding SAP Graph service with these responsibilities. This part (six) completes the process of creating a business data graph for the configured landscape.  

Instead of experiencing a lengthy and convoluted handover of system-specific information, you can hand the developer the URL and credentials to the business data graph as an abstracted representation of the landscape. Development time is focused more on application building and less on knowledge transfer. 

Configuring the Business Data Graph 

We pick up from where we left off at the end of part 5. You created destinations to data source endpoints, added an SAP Graph service, and assigned yourself the key user role. Also, you generated and downloaded the credentials text file, which we will need in the next steps. Here is the process we will follow: 

  1. Install the SAP Graph command-line configuration tool 
  2. Generate a business data graph configuration file 
  3. Edit the configuration file 
  4. Activate a business data graph with the configuration file  

Step 1: Install the SAP Graph configuration tool (graphctl)

Open a console (here we will use Windows and have created the subdirectory C:\demo, but this also works on other operating systems) and enter:

npm i -g @sap/graph-toolkit 

To check that the installation was successful, enter:

graphctl -v 

Step 2: Log into the SAP Graph configuration tool

Provide the credentials text file that you generated previously as a parameter to the login command. Enter:

graphctl login -f <credentials file> 

A browser tab or window will open and require you to log in. Upon successful authentication you will see: 

Close the browser window and return to the console. 

Step 3: Generate the SAP Graph configuration file

Now is when the unique business data graph is constructed through a discovery of the landscape. The generated configuration file is effectively a recommended default configuration, that you can choose to adapt or fine tune.  

In your console enter:

graphctl generate config -f <config.json> 

It may take some time for the configuration output to be generated. 

The graphctl tool has generated a default business data graph configuration file. Here is what the first few lines look like: 

Lines 5-16 show the discovered data sources, based on the two destinations we created in part 5 of the tutorial series. Line 17 starts the data locating policy. This part specifies the rules that determine where SAP Graph looks for data. For instance, lines 28-30 specify that entities within the sap.graph namespace default to the s4″ data source, unless overwritten by a more specific rule, such as the rule in lines 32-34, which specify that sap.graph/CorporateAccount will actually be found in the cxsales” data source. 

Often, the generated default configuration file, based on heuristics, is all you need. In more complex use cases, it may need to be tweaked. You can also learn more about this topic in the documentation on Help Portal. 

Just for fun, let’s change just one small thing: go ahead and replace the default string v1″ in line 2 with something else, for instance dev”. 

Step 4: Activate the configuration of the business data graph

In your console enter:

graphctl activate config -f <config.json> 

This may take a little time. Eventually, you will see: 

Congratulations, you have successfully configured a business data graph!  

Using your data 

So, what now? Now comes the fun part! 

Remember how in part 3 we wrote:  

A file containing [business data graph credentials], credentials.json, is created during the process of setting up and configuring the business data graph. You receive this file and the business data graph identifier from the SAP BTP administrator or key user who configured the specific business data graph you want to access. 

Well, that is exactly what we just did. We have our own credentials file and we generated a business data graph, which now has the identifier dev”. To test that everything works, go back to part 3 and: 

  1. Copy the credentials file you used for login into the src folder and rename it credentials.json 
  2. Change the value of the dataGraphId on line 4 of graph.js to “dev“: 
const dataGraphId = "dev"; 

And run the application again. Hurray! 

In summary

This part of the tutorial series concludes the basic introduction to SAP Graph. In part 5 we learned how to set up a landscape for SAP Graph, which we used in this part (six) to create a business data graph. In part 3 of this series we learned how a developer creates a rudimentary application used by authenticated users to access the data in the business data graph. Note how the developer, in part 3, did not need to know anything about setting up landscapes or business data graphs – the developer only required the credentials file and the business data graph identifier. 


Stephanie Lewellen, Product Manager – SAP Graph

Learn more about SAP Graph, or contact us at sap.graph@sap.com 


 

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Marco Viva
      Marco Viva

      The credentials file that was created in part 5 doesn't work, instead of Login, it shows only a red SAP-Cloud, in it written is "invalid redirect" and so on what am i doing wrong, what am i missing?

      Author's profile photo Stephanie Lewellen
      Stephanie Lewellen
      Blog Post Author

      Hi Marco,

      Thanks for getting hands-on with SAP Graph! I'm sorry to hear that you are running into issues. The team has tried to reproduce the issue you've experienced, but we aren't able to. Do you mind shooting us a quick mail to sap.graph@sap.com, so we can ask you more questions about the steps you took before getting the error?

      Best regards,
      Stephanie

      Author's profile photo VISHNU VARDHAN REDDY
      VISHNU VARDHAN REDDY

      Hi Stephanie,

       

      In Step 2,

      When I am using the credentials file that was created in part 5 and run the command " graphctl login -f <credentials file>" then It is opening the new window. But, Showing the error

      HTTP Status 400 – Bad Request

      What may be the issue? Can you please help me with this?

      Author's profile photo Stephanie Lewellen
      Stephanie Lewellen
      Blog Post Author

      Hi Vishnu,

      Thanks for trying out the tutorial series, and sorry you're running into issues. Can you send me an email at stephanie.lewellen@sap.com so we can retrace your steps together?

      Best regards,
      Stephanie