Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
NaotoSakai
Advisor
Advisor
I recently received an interesting inquiry:"Is it possible to connect to SAP from Unity ?"

He wants to create a kind of metaverse. And he wants to use SAP functions in it.

I responded that it should be possible to do this, and it is possible, but I had to check to make sure.

This is a memorandum of that.

 
SAP exposes most of its functionality as REST APIs and OData. Or you can expose them using BTP.

The basic code for access from Unity is as follows

For now, let's access the API of the sandbox environment.


using UnityEngine.Networking;
// I placed a button on scene for this test.
void OnClick()
{
Debug.Log("Button Push!");
StartCoroutine(GetProductDesc());

}

IEnumerator GetProductDesc()
{
UnityWebRequest request = UnityWebRequest.Get("https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_PRODUCT_SRV/A_ProductDescription?$top=50&$filter=Language%20eq%20%27EN%27&$inlinecount=allpages&$orderby=Product");
request.SetRequestHeader("apikey", "<replace to your api key>");
yield return request.SendWebRequest();
if (request.isNetworkError || request.isHttpError)
{
Debug.Log(request.error);
}
else
{
// Print resopnse to debug console.
Debug.Log(request.downloadHandler.text);
//This is returned in XML and will need to be properly parsed and used.
}
}


We have tested it and confirmed that the results can be transferred successfully.

 
Since we are using Unity, let's have a little fun with it by modifying the Unity sample TPS, placing assets (some of which are paid for), and creating a field that looks like a store.



I will place an avatar of a shop staff, and when I talk to him (collide with him in Unity terms), he will give you a list of items he is selling.





(I won't write the code as in the case of Unity, the code structure is complex, but this is how I was able to do it.)


It's kind of like the Metaverse. I only play board games like Mahjong on PC/Smartphone , I don't have latest game machine.

I am not an expert on the metaverse, so I can't say this is correctly so. I don't know if you can build a perfect metaverse this way.

But if it is just a demo, I think I can make a metaverse "demo" in conjunction with SAP.


As I was building it, I thought, this requires a different talent than programming. I don't think I could build a world. 🙂