We've all seen how to quickly connect to S/4HANA from SAP Build Apps, and to display a list of sales orders or business partners – see here, here and here, as examples. But what about creating, updating and deleting records. What about handling the complex associations of S/4HANA APIs? And what about handling the many rules within those APIs?
I have created a simple app to show off how to to build a real-world app. The app does the following:
The app is basic, but it's meant to show in general how to handle API calls, including all the CRUD operations as well as the underlying business rules of the data.
I have provided the following:
Business partners is a very simple API, so what kind of problems could happen?
Working on this simple demo I learned a lot about this API:
So you must handle these situations in your app. Below I try to show ways to deal with these issues.
In our app, we build 3 pages. The first is a list of business partners:
The second is a list of addresses for a particular business partner (red indicates the default address):
The third is a form for updating an address or creating a new address:
I have a destination set up to S/4HANA Cloud with permission to the Business Partners API. I do 2 things:
This is a pretty typical list screen, with a List Item component, whose Repeat with property bound to the data variable.
The Component tap event simply opens the addresses page, sending in the selected business partner ID:
The addresses screen is also a simple list, but this time there are some cool features:
IF(IS_EMPTY(repeated.current.to_AddressUsage.results),"","rgba(196,63,63,0.3)" )
The formula checks if the AddressUsage is set (to XXDEFAULT); if so, it sets the color to red.
This page contains the form for either creating a new address or updating an existing one.
A lot of the heavy lifting is done by the data variable. We create a New variable (essentially, just an empty variable with the data schema) for Address data. And we create a logic to set its values.
The logic checks if we are updating an existing address. If yes, we retrieve the data for that address. Either way, we then set the fields of the data variable with a formula.
And at the end of the logic, either for create or update, we check if the address will be / is the default address. If yes, we add the AddressUsage flag.
All the form fields are bound to our data variable.
And the logic of the Save button just checks if we are updating or creating a new field, performs the appropriate flow function, and then navigates to the main addresses page (Screen 2).
The main thing that's required when working with SAP Build Apps and SAP backend data is that you really have to understand the business logic and the API structure in order to make a good app.
It would help if SAP Build Apps was able to display the backend error messages so that the app can explain what went wrong when errors occur (and I'm sure that will be solved soon).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
5 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |