[ad_1]
Overcome data integration challenges: Meet SAP Graph as a unified solution for multiple business systems
- Business problem — You have multiple business systems e.g. SAP S/4 HANA Cloud / SAP SuccessFactors / SAP S/4 HANA System on Premise but it is challenging to get data from these systems using one Unified service but that change has got a wonderful solution and that is SAP chart
SAP chart
“providing developers with a single connected and unified view of all their business data“
“One endpoint for all purposes: streamlining functionality”
Sources:
- Thanks SAP HANA Academy for such a great YouTube Series on SAP Graph, follow this for building your solutions end-2-end.
- You can also follow the SAP Graph tag on SAP Community and blog series on SAP Graph
Requirements:
- BTP Cockpit trial account or paid account
- SAP chart Free tier Services (See SAP Discovery Center for more information)
- Create Graph instance and Key Service Key (download and save)
- Graph Instance Parameters – (Download and save) More details about HANA Academy git hub – > SAP Graph
- Go to PowerShell or VS Code and install the graphctl tool for graph connect
Set up chart environment:
Download your free service level from SAP Discovery Center and add it to your BTP subaccount
Download your chart key and save it somewhere in your system (I won’t go into detail as there are already few blogs and series on how to set it up but this is necessary to get started so add it to get connected )
Destination Configuration:
Get your API Key and API url from SAP' API Sandbox system. Business Acceleration Hub - https://api.sap.com/api/businesspartner/overview Login with your credentials - go to -> Settings -> Show API Key - Copy and Save it Somewhere Create destination in BTP Cockpit Destination Config will look like this :-
Log in to your SAP Graph instance: ( CF LOGIN -a )
-
Connect your BTP Subaccount - Enter your registered email ID and Password and select working Dev Space
- Install the graphctl tool using npm: Run command – npm i @sap/graph-toolkit
Login to graph instance: ( GRAPHCTL LOGIN -F REGISTRATIONS)

Generate Config for Graph Instance: ( GRAPHCTL GENERATE CONFIG PASS DESINTATION )


Activate Config: ( GRAPHCTL ENABLE CONFIG )
graphctl activate config -f “C:\Users\Yoga\Desktop\graph\instance-parameters.json” –force
List Configuration: ( GRAPHCTL LIST CONFIG ) 
Graph is now ready for server -> Generate your service keys on graph instance and test graph API
sap.graph successfully serves the cloud for customer entities here – you can choose/select any entity and use or bind your application directly
this is the power of SAP Graph – Amazing technology with amazing results
to test:
Graph URL (https:///api/v1/sap.graph )
Authorization: Choose Oauth 2.0 Credentials
Execute GET Request on Graph Endpoint:
Let’s GET company information from Graph
Result:
“Graph Environment Setup: Integrate with SAP Graph and SAP CX Sales Cloud APIs, Generate Business Data Graphs and Successfully Test Graph APIs in POSTMAN Client”
Congratulations on your successful setup of the graphical environment! It’s great to hear that you’ve successfully integrated SAP Graph with SAP CX Sales Cloud APIs. In addition, generating a business data graph for consumption and running successful tests of the Graph APIs in the POSTMAN client show significant progress. Well done!
Part 2: CAP Wrapper for Graph API:
Architecture
“Architecture diagram explains that we have two business systems connected to SAP Graph & SAP Graph is shown as an endpoint (destination in BTP) and the CAP app will use that destination and expose the business data with it”
What all we need ?
-
Node in your VS Code / BAS
-
Destination for Graph endpoint in BTP Cockpit
-
Authentication , Destination and connectivity services in CAP
Create a destination in BTP Cockpit the same way we did for Cloud for Customer APIs – Get the client ID and secret from the Graph Service Key file
-
Create Simple CAP Application either in BAS or in VS Code , I am using VS Code
-
Lets Create one Folder in your workspace in VS Code Name it like getBusinessData
-
Open VS Terminal and execute
cds init
cds add mta
Add these in package.json Add this CDS Section
"cds": {
"requires": {
"shagraph": {
"kind": "odata-v4",
"credentials": {
"destination": "shagraph",
"path": "/sap.graph"
}
}
}
}
Add sales.cds file in srv folder and add the below snippet , I have created on function import which will be returning the dynamically generated results from SAP Graph API.
@protocol: 'rest'
service root {
@open
type object {};
function graph(name:String) returns array of object;
}
Add the sale.js file to the srv folder
const get = require("./handlers/GET/getSales");
module.exports = cds.service.impl(async function () {
this.on("graph", get.graph);
});
handler for chart.
const graph = async (req) => {
const srv = await cds.connect.to("shagraph");
if (req.data.name !== null && req.data.name != undefined) {
req.query = SELECT.from(req.data.name);
} else {
req.query = SELECT.from(`sap.graph`);
req.query.SELECT.from.ref[0] = "";
}
return await srv.run(req.query);
};
module.exports = {
graph
};
Execute these Commands
cds build
cds bind -2 destination-srv:key
cds bind -2 uaa-srv:key
cds watch --profile Hyrbrind ( to run locally your App )
End-2-end implementation of CAP Wrapper for Graph API:
Note: Just made this little video for making calls to the graphics API instead of posting screenshots
Here CAP Endpoint serves sap.graph first and then we pass through entities exposed using business data graph and then it comes to an end.
I hope you enjoyed reading and feel free to post any comments or questions
Thank you Shivam
|
Sources 2/ https://blogs.sap.com/2023/07/05/cap-meeting-sap-graph-embrace-the-power-of-sap-business-technology-platform/ The mention sources can contact us to remove/changing this article |
[ad_2]







