Skip to Content
Technical Articles
Author's profile photo Daniel Wroblewski

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

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).

  1. Best to set up a technical user for accessing the APIs.
  2. 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).
  3. 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).
  4. 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.

  1. 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).
  2. 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.

  1. Go to the Auth tab.
  2. 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.

  1. 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.

  2. On the list page, create the following UI:

  3. Create page variables for the alphabetize and filter values, as well as a variable for the current page number.

  4. Create a data variable from the business partner resource (one of the entities we defined from our destination).

    In the logic canvas, add a standard Get record collection and set data variable flow functions, and make them run whenever the page is mounted or one of our filter variables is changed.

  5. 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.

Assigned Tags

      15 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Murali Shanmugham
      Murali Shanmugham

      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

      Author's profile photo Daniel Wroblewski
      Daniel Wroblewski
      Blog Post Author

      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.

      Author's profile photo Prasanth Padmanabhan Menon
      Prasanth Padmanabhan Menon

      Was about to comment this. This is an excellent update.

      Author's profile photo Kevin Hu
      Kevin Hu

      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.

      Author's profile photo Aocheng Yang
      Aocheng Yang

      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

      Author's profile photo Daniel Wroblewski
      Daniel Wroblewski
      Blog Post Author

      I believe this some sort of bug or oversight ... have you found a solution?

      Author's profile photo Sumi Kang
      Sumi Kang

      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.

      Author's profile photo Daniel Wroblewski
      Daniel Wroblewski
      Blog Post Author

      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).

      Author's profile photo Sruti Nayak
      Sruti Nayak

      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

      Author's profile photo Daniel Wroblewski
      Daniel Wroblewski
      Blog Post Author

      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).

      Author's profile photo Sruti Nayak
      Sruti Nayak

      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. 🙂

      Author's profile photo Naveen Jain
      Naveen Jain

      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

      Author's profile photo Daniel Wroblewski
      Daniel Wroblewski
      Blog Post Author

      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/

       

      Author's profile photo Nichole Tam
      Nichole Tam

      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)?

      Author's profile photo Daniel Wroblewski
      Daniel Wroblewski
      Blog Post Author

      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.