SAP Builders Blog Posts
Learn from peers about their low-code journey and write your own blog posts to share your thoughts and experiences as you become an SAP Builder.
cancel
Showing results for 
Search instead for 
Did you mean: 
Dan_Wroblewski
Developer Advocate
Developer Advocate
2,559

Most people I know who need to connect to S/4HANA data have a system to get it from. But sometimes there are connection issues, sometimes it's unavailable, and some people simply don't have one yet.

Here's how to quickly connect to demo data. Most is contained in this video:

 

NOTE: For the most part, you will not be able to update the demo data.

 

Get Account and Key

First go to SAP Business Accelerator Hub and make an account, or log into your existing account. If you are logged in, you will see your name in the top right.

dan_wroblewski_0-1695196059280.png

Click on the dropdown arrow, and select Settings.

On the settings screen, click Show API Key.

dan_wroblewski_1-1695196153812.png

A pop-up opens with your key. Put the key aside.

Create a Destination

For the sake of this blog post (@qmacro 😉), I will use the URL to the Sales Order API, which is an OData API, but you could go through all the APIs for all the products and use whatever you want (I'll show you how below).

Go to your BTP cockpit – I will use my trial account on which I already installed SAP Build Apps.

Go to Connectivity → Destinations, and then create a destination with the following values. 

dan_wroblewski_0-1695197026659.png

The basic fields are:

NameAccelerator-Hub-Sales-Order
TypeHTTP
URLhttps://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrder
Proxy TypeInternet
AuthenticationNoAuthentication

The additional properties are:

Appgyver.Enabledtrue
HTML5.DynamicDestinationtrue
URL.headers.apiKey<your API key>

The important thing is that you have to pass the API key as a header, and you can do that with the Additional Property URL.headers.apiKey (you can send other headers, just change the last part of the property name).

 

Using in SAP Build Apps

At this point, the process in SAP Build Apps is the same as when you use any destination in SAP BTP.

Enable SAP BTP Authentication in the Auth tab.

dan_wroblewski_0-1695198326012.png

In the Data tab, go to Add Integrations → BTP Destinations, and then select your destination.

dan_wroblewski_2-1695198489096.png

After selecting, you will see all the entities for the OData service.

dan_wroblewski_1-1695198436430.png

Now do the following:

  1. Click Install Integration.
  2. Select the entities you want and, and for each click Enable Data Entity.
  3. Click Browse Real Data to check that you are getting back data.
  4. Click Save in the upper right.

Click the UI Canvas tab, and click Variables and create a data variable for the Sales Order entity.

dan_wroblewski_3-1695198799389.png

IMPORTANT: When I checked, there were 368,976 records in the entity – you can see this when you browse the data – so if you try to bring them all back, your app will crash (or get stuck). In the logic of your data variable, configure paging for the Get Record Collection flow function, to bring back just 10 records per page.

Go back to the View slider, add a list view, and bind the data variable to your primary and secondary fields. I used SoldToParty and TotalNetAmount.

Run the app, and you will see a list of sales orders, with the customer and the amount.

dan_wroblewski_4-1695199017784.png

 

Getting API URL from SAP Business Accelerator Hub

Once you get to the SAP Business Accelerator Hub, you can navigate to the product of your choice, say S/4HANA Cloud.

dan_wroblewski_0-1695199416566.png

The you can click APIs, then the type of API, for example, OData V2, and then you can search for what you want, for example, Sales Orders.

dan_wroblewski_1-1695199507887.png

And on the Overview tab of the API you are interested in, click Configuration Details and you will see the URL to that API.

dan_wroblewski_2-1695199743831.png

I'm sure (no guarantees) in the not-too-distant future, you will be able to access all this API information from within SAP Build Apps.

😺

 

 

 

6 Comments
Summitt12
Participant

Great blog, thanks for sharing

How to filter the data based on Soild to Party (partnerID)

Is it possible to pass partnerID in the URL that can then filter the list?

shantanusharma
Product and Topic Expert
Product and Topic Expert

Very useful. Thank you.

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

@Summitt12 Thanks for the question and of course we can filter by partner ID.

If you use a "Get record collection", you will get a filter option.

Dan_Wroblewski_0-1710057479017.png

If you click the X next to "Filter condition", and then select "Object with properties", you will be able to filter by a specific SoldToParty.

Dan_Wroblewski_1-1710057571311.png

And this filter an be dynamic, so you can ask the user for the partner ID and then store in page variable. The filter can instead of getting a static text can refer to the page variable.

Hope this helps.

 

 

 

RaghavaReddy
Discoverer
0 Kudos

I am receiving the 401 (unauthorized) connection error with the configuration details you have advised. PLease see the screen shot below. Can you please let me know what is causing this error?

RaghavaReddy_0-1732197546152.png

 

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

@RaghavaReddy This "error" is actually shown as a success because all that the "Check Connection" does is check if it can reach the server. It is not sending the additional properties, at least for authentication purposes. You can ignore this message.

See this tutorial: https://developers.sap.com/tutorials/codejam-08-action-get.html#8a675953-6a5c-47be-b174-37d08a6193f8

RaghavaReddy
Discoverer
0 Kudos

Thank you for the pointers. I need help with the following scenario please ...

I have created a trial account on SAP S/4 HANA public cloud. Would you be able to guide me on how to create a POST request to create a sales order (with a set of predefined fields) from my build process automation project? I am successfully be able to create a destination in my BTP account pointing to the HANA public cloud end point. However, not able to figure out the API endpoint that I should consider while creating a POST request. For business accelerator hub, the API documentation is clear. Can you please advise for a trial account on S/4 HANA public cloud, where can I find the API documentation? Thank you.