CAP Meeting SAP Graph Embrace the power of SAP Business Technology Platform
source link: https://blogs.sap.com/2023/07/05/cap-meeting-sap-graph-embrace-the-power-of-sap-business-technology-platform/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
-
Overcoming Data Integration Challenges: Introducing SAP Graph as a Unified Solution for Multiple Business Systems
- Business Problem — You got multiple business systems for example SAP S/4 HANA Cloud / SAP SuccessFactors / SAP S/4 HANA System on Premise but bringing data from these systems using one Unified service is a challenge but that Change got a beautiful solution and that is SAP Graph
SAP Graph “providing developers with a single connected and unified view of all their business data“
SAP Graph “A Single Endpoint for All Purposes: Streamlining Functionality”
Resources & Credit:
- Before I get into implementation details, I would like to give credit to SAP HANA Academy for such a great Youtube Series on SAP Graph please follow it for building your solutions end-2-end.
- You can also follow SAP Graph tag on SAP Community and blog series on SAP Graph
Pre-requisites:
- BTP Cockpit trial account or Paid Account
- SAP graph Free tier Services ( Check SAP Discovery Center for more detail )
- Create Graph instance and Key Service Key ( Download and Save it )
- Graph Instance parameters – ( Download and save it ) More details on HANA Academy git hub – > SAP Graph
- Go to PowerShell or VS Code and install graphctl tool for graph connect
Setup Graph Environment:
Get your free tier service from SAP Discovery center and add the entitlement in your BTP Subaccount
Download your graph key and store it somewhere in your system ( I will not go into detail as there are already few blogs and series on how to set it up but this is needed for start hence adding it for connect)
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 :-
Lets go to PowerShell or VS Code whatever suits you
Here is my VSCode window and I will login into my BTP Account
- Enter credentials and connect to your Dev Space
- Install graphctl tool using npm : Execute command – npm i @sap/graph-toolkit
- Login into graph using Graphctl login using credentials saved
Note: It will open web browser for login,please login using BTP Cred and we are connected to Graph Instance at BTP Cockpit now
Let’s see if it is connected correctly
Execute : graphctl generate config -f “C:\Users\Yoga\Desktop\graph\instance-parameters.json” -i cxsales
Lets list the graph config now but before that Activate the config.
Activate Config:
graphctl activate config -f “C:\Users\Yoga\Desktop\graph\instance-parameters.json” –force
List Config:
graphctl list config
We are connected with SAP graph now and this is ready to serve you -> Generate your Service keys on graph instance and go to Postman and you can start testing your graph API
Here are few test case which I have captured:
sap.graph is serving successfully the Cloud for customer entities here – you can choose/select any entity and can consume or bind with your application directly this is the power of SAP Graph – Amazing tech with Amazing Results
lets Choose “Company”
Ok here we are done with the Setup and testing with Postman
lets do some CAP Development Now…
Attaching high level CAP Application Architecture
Go to your VS Code or BAS ( Your Preference ) I am using VS Code for CAP Development
What all we need ?
- Node in your VS Code
- Destination for Graph endpoint in BTP Cockpit
- Authentication , Destination and connectivity services in CAP
Install Node in your VS Code if not done – Follow
Create Destination in BTP Cockpit in the same way as we did for Cloud for Customer APIs – Get Client ID and secret from Graph Service Key file
Go to your VS Code
Execute these command in Sequence
cds init
cds add mta
Go to 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
@protocol: 'rest'
service root {
@open
type object {};
function graph(name:String) returns array of object;
}
Add sale.js file in srv folder
const get = require("./handlers/GET/getSales");
module.exports = cds.service.impl(async function () {
this.on("graph", get.graph);
});
handler for graph.
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
};
Lets try to build it using mbt build and deploy this application to cloud foundry – cf deplpy mtar
Testing of the Application locally in VS Code:
Call the graph:
Call the Entity:
Call the Entity:
Here CAP Endpoint is serving first for sap.graph and after that we are passing entities exposed using business data graph and it comes to an end then.
I hope you have enjoyed the reading and please feel free to post your comments or questions if any
Thanks Shivam
Recommend
-
5
3 Reasons Why Your Business Should Embrace Virtual InternshipsBy Dr. Leigh Anne Taylor Knight, Executive Director and COO, The DeBruce Foundation The internship practice coined a word in 2020 in response to the pandemic: v...
-
8
CEO InsiderHow Leaders Can Embrace New Technology in FilmmakingRussell Aldridge
-
6
Embrace Blockchain for Business Transformation Reading Time: 10 minutes While some industries introduced
-
7
Friday, 17 December 2021 17:15 Why the education system needs to embrace new technology By Guest Writer GUEST OPINION: The way students learn has changed. Blackboard...
-
7
6 Reasons To Embrace Digital Transformation In Your Business Regardless of the industry you belong to, digital technology affects your operations in various ways. As such, ensuring you embrace and integrate digitization can...
-
7
Climate Change Goals Bring New Embrace of Nuclear Power (and Gas in EU) Catch up on stories from th...
-
2
News Three-quarters of business professionals want to embrace the metaverse Study from ne...
-
2
Family Offices Increasingly Embrace Cryptocurrency and Blockchain Technology May 9, 2023
-
8
World’s Biggest Advertisers Embrace the Power of AI: A Paradigm Shift in Advertising K.sabreena
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK