This article is intended to share the experience using SAP Business Technology Platform (BTP) to create mobile applications on various platforms including iOS and Android as well as to give detailed information about how to start developing extensions for S/4HANA Cloud. I would cover only BTP and Xcode technology stack and will go through the steps to create mobile application.
Essentially SAP BTP provides a rich set of tools and APIs available on SAP API Business Hub at https://api.sap.com to get full integration with SAP products available on BTP and related business processes.
The main focus of this article will be on Mobile Services available on SAP BTP. Basically SAP Mobile Services on BTP provide the following benefits for the developers and architects:
- Application analytics: Usage statistics that are displayed graphically in the SAP BTP cockpit
- App resources: Containers of dynamic configurations, styles, or content that are downloaded by native applications
- Onboarding: Authentication of users who are registering through SAP Mobile Place
- HTTP/HTTPS configuration: Open standards for client communications
- Life cycle management: Managing and deploying multiple versions of an application
- Offline oData service: Optimizes data transport between the back end and the client offline store
- Push notifications: Native notifications sent from back-end systems to the server, which forwards them on to the clients
- SAP BTP cockpit: Deploys, manages, and monitors applications
- Supportability: Logs for monitoring system health and troubleshooting
As an example of such integration i will choose Purchase Order API available in Sourcing and Procurement for S/4HANA. It would be possible to apply Purchase Order(PO) API in mobile application to create, view and modify PO using standard OData protocol accessible via SAP provided framework in Xcode.
Purchase Order API is available on API Business Hub using the link https://api.sap.com/api/API_PURCHASEORDER_PROCESS_SRV/overview and could be easily tested using S/4 Sandbox or S/4HANA Cloud demo system available for trial use. Below you will find instructions on how to register for demo S/4HANA Cloud system and connect it to your trial BTP account.
In the scenario shown below, all services on SAP BTP are used in Trial mode and available after registration on SAP BTP.
1. Prepare MacOS environment for mobile applications development on BTP
To get started you should install BTP SDK for iOS following the link. SDK includes important tools such as SAP BTP Assistant for iOS that bootstraps new projects by generating onboarding, authentication, security, and data layer Swift code.
2. Get an account on SAP BTP platform and create trial account.
Register on SAP BTP using the link https://cockpit.hanatrial.ondemand.com
3. Create subaccount on BTP and enable Cloud Foundry environment
- In your global account in the SAP BTP cockpit, create a new subaccount. In the New Subaccount dialog, don’t select Neo Environment.
- In the overview of your newly created subaccount, choose Enable Cloud Foundry to create a Cloud Foundry organization.
- To create a new space, choose Create Space.
- From the navigation pane in your global account, choose Entitlements -> Subaccount Assignments.
- From the drop-down menu, select your subaccount and choose Go.
- From the navigation pane in your subaccount, choose Subscriptions.
- Select SAP Cloud Portal and choose Subscribe.
- Go back to Subscriptions and subscribe to SAP Business Application Studio.
In this example i have created subaccount on AWS like shown on picture below.
4. Create a trial instance of S/4HANA system
You may register a trial instance of S/4HANA system using the link https://www.sap.com/products/s4hana-erp/trial.html
5. Connect trial instance of S/4HANA to your BTP trial account
You may follow detailed instructions here to create connection between S/4HANA Cloud and BTP trial account or you may search for “Extend SAP S/4HANA Cloud on SAP BTP, Cloud Foundry Environment” scenario given on developers.sap.com.
In order to register S/4HANA Cloud system go to BTP cockpit, click on subaccount created during the step 3 above, click on “Systems” and click on “Register System” to connect your BTP account to S/4HANA Cloud system. Please check the picture below for details.
After successful registration you should have S/4HANA Cloud system listed under “Resource Providers”. Please check the picture below.
6. Create an instance of Mobile Services on SAP BTP.
Click on subaccount and open “Service Marketplace” to create an instance of “Mobile Services” like shown on the picture below.
7. Create mobile application using Mobile Services cockpit.
Go to “Mobile Services” cockpit, click on “Create” and enter details of sample mobile app like shown on the picture below.
The wizard will open a windows to enter details of mobile application like shown below on the picture. You should enter ID and Name properties and select XSUAA Service for authentication, in this case i select default authentication service. In practice you may chose any authentication service prepared, but configuration of additional authentication services is outside the scope of this article.
The next step requires to select features available to the mobile application, please select default features like shown on the picture below.
The most important feature for this scenario is “Mobile Connectivity” that actually provides proxy service available to the mobile application and exposed as OData service that connects mobile application with S/4HANA Cloud CDS views.
Basically SAP BTP provides two options to connect to S/4HANA Cloud backend:
- “Destination” in the subaccount to make use of SAP Cloud SDK API to access S/4HANA backend via mobile applications deployed in the BTP and not accessible via Internet
- “Mobile Services” destination service that is accessible over Internet and proxies all requests to the selected S/4HANA backend.
8. Create communication user for S/4HANA Cloud.
You can create default communication user via scenario during the step 5 using the link.
Communication user is created automatically based on communication scenario preconfigured in S/4HANA. In order to manage Purchase Order API the following communication scenario used – SAP_COM_0053.
The manual process to set up a communication user with S/4HANA Cloud makes possible to select custom CDS view with new properties exposed via OData protocol with CRUD(Create, Update, Delete) support and also desired authentication option: OAuth, SAML2, Basic.
In that scenario I have created a sample user account BTP_MOBILE_USER in S/4HANA system with autogenerated password and used default communication scenario SAP_COM_0053. Please make sure to save communication user name and password created during this step.
9. Create destination on BTP to access S/4HANA via OData protocol
You need to establish trust configuration between BTP subaccount and “Mobile Services” instance to be able to use API key authentication working with destination using OData protocol. You may check SAP note 3052553 for details.
In this scenario i will use anonymous API key authentication to access Purchase Order API via destination configured in mobile application.
To establish trust configuration you should go to “Mobile Services” cockpit, “Settings”->”Security” and click on “Metadata download” to download trust configuration xml file, please check the picture below.
Then you need to upload this xml file into “Security”->”Trust configuration” on the BTP subaccount homepage and click “New Trust Configuration”, please check the picture below.
Afterwards you will be able to use anonymous authentication with API key or Basic authentication using your trial BTP user name.
10. Prepare iOS Xcode environment to start mobile application development.
During the step 1 it is required to install BTP SDK for iOS that contains iOS Assistant application. In order to create a sample project with all required frameworks to communicate with OData services, please run iOS Assistant and create new mobile application.
10.1. Run iOS Assistant.
10.2 Select “Create New Application”
10.3 Register “Mobile Services” instance
10.4 Assign mobile application id, name and chose “API Key Only” authentication.
10.5 Select destination service for mobile application.
10.6 Enter password for communication user created during step 8.
The next steps will help to prepare Xcode project with all configured frameworks required to connect to S/4HANA Cloud.