Technical Articles
My first steps with BTP destinations (S/4HANA) in AppGyver
I’m sure you’ve seen Marc Huber’s wonderful blog Using BTP Authentication and Destinations with SAP AppGyver – this is a big step forward for integrating SAP AppGyver in SAP Business Technology Platform, and I think the first of many giant leaps to come.
Now that I’ve gotten to work with the feature, I’d like to offer some tips for using it, and a quick example.
Setting Up Your Destination
I set up both S/4HANA and S/4HANA Cloud destinations. The destinations (with Basic Authentication) are essentially the same, though the setup before the destination is different.
Whatever you do, remember to define the following properties for the destination (without them they won’t appear in AppGyver):
- HTML5.DynamicDestination = true
- WebIDEEnabled = true
- Appgyver.Enabled = true
You must also understand that your destination must point to an OData service. This is different, for example, from SAP Conversational AI where you can have a generic destination pointing to the system and then specify a service and entity when you make specific calls. In other words, with AppGyver, you may need to set up multiple destinations if you call multiple OData services even in the same system (this may change in the future).
Of course, what’s really good is that AppGyver will now read the service metadata and let you discover the entities inside, and even browse the data.
S/4HANA
If your an S/4HANA guru, this may be old hat, but I’d thought I’d just review how I set things up (after getting access to both front-end and backend systems, and getting the administrator role).
- Just to get it up and running quickly, easiest is to set up a technical user for accessing the APIs.
- Give the technical user the permissions for the APIs you want to access (e.g., for sales orders, I needed SAP_BR_INTERNAL_SALES_REP role).
- Set up the cloud connector. It’s pretty simple and there are a lot of blogs/guides for this.
- Add your subaccount (you’ll need BTP administrator access and maybe the cloud connector role)
- Add a Cloud to On-Premise channel to your S/4HANA system (you’ll need the host name and port of your front-end system, which you can get with the SMICM transaction).
- Specify the path you want to open (generally /sap/opu/odata).
- Create a destination:
S/4HANA Cloud
The big difference here is that you don’t have to set up the cloud connector, but there are a few steps for setting up a user.
- Set up the S/4HANA user for accessing the API (the “communication arrangement”). For this, also, there are a lot of blogs/guides.
- Add a user with strong password (Maintain Communication User)
- Add a communication system that points to your S/4HANA system (Communication Systems)
- Add a communication arrangement that specifies what APIs can be called for a specific communication user (Communication Arrangement).
- Create a destination, like the S/4HANA one, but for “Internet” and with the URL to the S/4HANA front end:
Setting Up Destinations in AppGyver
The first thing you need to do is enable BTP authentication.
- Go to the Auth tab.
- Click Enable Authentication, and then select SAP BTP Authentication.
Now you can go into the Data tab, click Add Integrations, and finally select a destination.
From here, you get a screen for selecting the entities you want to work with in your app. In the background, AppGyver sets up the schema and other stuff you need to work with the data resources.
Whenever you go back into the Data tabs, you will see the entities you selected. You can double-click them, which opens the OData service from where they came, and you can select other entities and browse the data of any of them.
Creating the List-Detail App
In Marc’s blog, he used the new data adapter components to build the app, which is great. As an exercise, I am going to do the old-fashioned way.
- Create 2 pages, one for the list of BPs and one for the detail page. The detail page has a page parameter for the BP ID.
- On the list page, create the following UI:
- Create page variables for the alphabetize and filter values, as well as a variable for the current page number.
- Create a data variable from the business partner resource (one of the entities we defined from our destination).
- On the same page, in the properties area on the right, we can define simple filters, sorting and paging based on the page variables we created.
In the end, in just a few minutes, you get something like this using backend data:
Things to Think About
The following are things I want to do that I currently don’t know how or perhaps can’t yet be done:
- No authentication with destinations: This is not possible and may go against the long time idea of having IT create the destinations and make different destinations available to different “citizen developers” based on their permissions and expertise.
- Principal propagation: This apparently already works (I haven’t had a chance to test it).
- Data adapter and manual refresh: I have not found a way to manually refresh data when using data adapter components, except for actually reprogramming the data adapter composite component. This is not that difficult but doesn’t seem like the solution.
- Roles: You cannot currently assign roles to different users within your AppGyver app, but this is something on the roadmap, I am told.
- User Info: You cannot currently get the currently logged-in user, or other user details, but this also is on the roadmap, I am told.
- Run on mobile devices: The apps using destinations and running on BTP could theoretically be run on mobile devices but the tools to make this simple are not currently provided in AppGyver. I’m sure this is being worked on with SAP Mobile Services.
- Direct deployment to BTP: Currently, AppGyver will export to an MTAR file but you need to handle deploying it to BTP (e.g., with the CF CLI). The hope is that sometime soon you will be able to click a button and quickly/easily deploy to BTP.
Thanks for sharing. Saves me from using API Management inbetween to avoid CORS issue.
What I would love to see is a Citizen Developer browsing through all the OData APIs which are available in the SAP system rather than having to depend on IT to setup destination for each API. Not sure if this is possible already
I believe this is under review, to provide a Discovery API, like they had in Web IDE and I assume they have in SAP Business Application Studio.
But since AppGyver is a low-code tool, I think it's not 100% clear what is the best way to expose all those services. For citizen developers, it might be too much to provide all the APIs, plus there may be a desire to assign services based on the user's roles.
Either way, it seems this option might become available in the future. But maybe someone from PM/dev can provide more information.
Was about to comment this. This is an excellent update.
I believe the destination here only needs to be set up once. And all the relevant APIs can be bundled into one custom communication arrangement and exposed via the technical user. Yes, I think it is all about security and authorization in S4 behind it, which for citizen developer might be hard to handle. And I don't believe IT would allow citizen developer to access btp cockpit and create destination either. 🙂
What I do want to see is perhaps more "descriptions" on the appgyver page when browsing the APIs.
Thanks for sharing! Have you tried POST(Create/update record) to OData configured using BTP authentication? I see that fetching data using BTP authentication works but I have problem with Creating new data using the OData. It returns "CSRF token validation failed".
I've posted a question in the community but got no answer yet. https://answers.sap.com/questions/13676401/appgyver-btp-authentication-cors-error-remains-wit.html
I believe this some sort of bug or oversight ... have you found a solution?
Hi, thank you for your helpful content.
May I ask a question?
I wonder that how to do "Best to set up a technical user for accessing the APIs. Give the technical user the permissions for the APIs you want to access "
and "Set up the S/4HANA user for accessing the API (the “communication arrangement”)."
I am a beginner on this topic and can't find related contents.
The communication arrangement for S/4HANA Cloud is described in this tutorial (it's for teaching ABAP Environment but it's the same idea): https://developers.sap.com/tutorials/abap-environment-communication-arrangement.html
And here is documentation: https://help.sap.com/products/BTP/65de2977205c403bbc107264b8eccf4b/889fbe37b7b344deabfbdc78ab16e544.html
But you will need admin permission to do this. I'm not an expert around S/4HANA to be honest.
As for technical user for S/4HANA, this is an admin task. The admin should set this up -- a user, then add the role for the APIs you need to call (e.g., sales manager).
Hello Daniel,
Great blog post. Thank you for sharing.
We are trying to setup Pagination functionality using S4 OData services as explained in your blog post. However, we are not able to show the Total Number of entries from the fetched record collection output.
Does the Total Count output of the record collection get filled when we set Include Total Count = true?
Is there any documentation regarding Total Count?
Thanks,
Sruti
I believe this is a bug ... I also tried this, I also see the total count field but it is undefined for me.
Fairly certain this is the standard count field returned at the start of the OData call -- you can see this in the browser's developer tools.
I am told it will be fixed next month (but no promises from me).
Thank you Daniel Wroblewski for the quick response and update.
Yes, getting undefined too but can see the correct count in developer tools.
Fingers crossed for next month. 🙂
Thanks Denial,
I have already setup a cloud connecter for S/4Hana on-premise and connections are ok.
But still destination not working even northwind not working. please suggest.
Regards
Naveen Jain
Can you send the URLs you set up in the destinations?
Please note that the URL must be to a specific OData service, not to generic system address, for example:
https://services.odata.org/V2/Northwind/Northwind.svc
Not
https://services.odata.org/
Thanks for you blog post Daniel, it was incredibly helpful in setting up the data integration for AppGyver. Are there any plans in the roadmap to accept a generic system address (e.g. http://host:port/sap/opu/odata)?
I believe there were debates about this and it was decided to do it this way. But I think there may be plans to allow a destination with a system address and then in AppGyver to select the service -- reducing the number of destinations needed. I don;t know when that might come.
HI Daniel,
Great Blog!.
One Question:
How do we pass "$expand" to OData service call using BTP destination, or how do we access NavigationProperties for binding in AppGyver?
Thanks,
Prashant
I don't believe you can, currently. See this forum explaining how underneath AppGyver does expand associated entities but it depends on the service definition adding extensions fields. If the fields are defined properly, then you can access the data with a formula.
https://forums.appgyver.com/t/publicly-available-northwind-odata-service-not-displaying-expand-option/17333/11?u=kirill_leventcov
Thanks Daniel, it would help.
Nice Blog.
I have setup a destination on my BTP, and can see the destination in AppGyver.
But when trying to explore the destination I get an error:
"An error occurred while fetching services for this destination"
Any idea on this?
Are you using SAP AppGyver (Classic) or SAP Build Apps?
Can you display the screen you get?
Is this an SAP service or a public service?
SAP Build Apps. I am connecting to an SAP onprem service.
Destinations do not support Cloud Connector to On-Premise yet. I've been told it is a high-priority item on the roadmap, but in the meantime you could use API Management.
Dear Daniel, thanks for this blog. Cannot see that topic on the product roadmap explorer on "SAP Build Apps." Can you roughly estimate when it will be possible to access it also from on-premise cloud connectors?
Tried to access the SAP ES5 Discovery S/4HANA system, which I included as a destination. In SAP Build App Data tab, the destination is listed, but with a red dot and I, which is telling me, "Destination unavailable." Is that the problem, that it is not yet working with on premise cloud connector, or is it a different problem?
Hi Tobias, we now have an updated reply from my colleague Beatrice Pasch in SAP Community. The team is working on the connection of SAP Build Apps to on-prem with priority. We should see this soon, e.g. in SAP Community. I suggest you follow Beatrice & Daniel.
Thanks for your understanding.
So I do. Thanks for the fast response Oliver!