Technical Articles
How to build the iOS App that displays SAP S/4HANA data as AR 3D object (1/2)
I build the iOS app that displays SAP S/4HANA data as AR 3D object. I’d like to share detail steps I took.
Architecture
Procedure
1. Implement GetEntitySet method of OData on SAP S/4HANA
2. Generate an Xcode Project with SCP SDK for iOS Assistant
3. Implement the AR function to generated Xcode Project on step2
This post is introduce Step1-2, and Step3 in next post.
Preference
Back-End:
- SAP S/4HANA 1709 (On-Premise)
(Connecting SCP account by SAP HANA Cloud Connector)
Cloud:
- SAP Cloud Platform (NEO)
Front-End:
- iPhone7 Plus
- iOS12.1
Implement OData on SAP S/4HANA
First I create an OData project from Tr-code SEGW.
This time, I will implement acquiring store inventory data of products in SAP S/4HANA.
Create a OData Project
Click the [CreateProject] button on the upper left of the screen.
Enter the Project name and Description and click the [Continue] button.
(Please enter an appropriate value for the package and user name according to the environment.)
Create entity types.
Right-click to Data Model> Create> Entity Type.
Enter the EntityType name (in this case “StockInfo”).
In order to create EntitySet at the same time, turn on [Create Related Entity Set] and click [Continue].
Register Property of EntityType.
(In this case, it’s a simple structure consist of the material number and its store inventory quantity.)
Name | Key | EdmCoreType | Prec | Scale | Max | Label | ABAP Type |
---|---|---|---|---|---|---|---|
Matnr | X | Edm.String | 0 | 0 | 40 | Material Number | MATNR |
Quan | Edm.Decimal | 13 | 0 | 0 | Amount | QUAN | |
Unit | Edm.String | 0 | 0 | 3 | Unit | UNIT |
Turn on “Addrable of EntitySet.
Click the [Activate] button to activate ODataProject.
Enter the Model Provider Class Name and Data Provider Class Name and click [Continue] to automatically generate each class.
After defining the data model, I will implement the acquisition method.
From Service Implementation, right-click the GetEntitySet method of StockInfoSet and select [Go to ABAP workbench].
Switch to change mode, place the cursor on the method to implement [STOCKINFOSET_GET_ENTITTYSET], and click the upper right [Redefine] button in the list.
Implement data acquisition process with ABAP.
In this case, for simplicity, the stock information is stored in the dummy add-on table (YTEST0001), and the process of only acquiring data from there is implemented.
##Stock information Table (YTEST0001)
Activate OData Service
Next, register the implemented OData as a service.
Add the service from transaction code “/IWFND/MAINT_SERVICE”. Click “Add service”.
Enter the service name etc. and click [Continue].
If successful, the following message will be displayed. Click [Continue].The OData service is now registered.
Generate an Xcode Project
Next, generate an iOS application that displays the OData EntitySet data using the SCP SDK for iOS.
SCP account settings
First, set up the account of SCP in advance. Click [Manage Accounts].
Click the [Add New ..] button and enter the SCP Mobile Service URL information.
For the value to be entered, open SCP Mobile Service from a browser and refer to the URL described in the menu [Important Link].
(If you click [Direct URL Import], it will be entered automatically.)
Generate Xcode Project
Next, create an Xcode project. Click [Create New] button.
Click “Create new Application”.
Select the the SCP account information. (Please enter your SCP credentials as the login screen will pop up.)
Enter the application name & Identifier etc. (your favorite name). These will be the application information registered on the SCP Mobile Service.
Next, create backend connection information. Click [Add New …].
Enter the URL of the OData service created above in BackEndURL.
Enter the authentication information used for back-end connection in [AuthentificationType]. In this case, select “BasicAuthentification” and enter the S/4 HANA login user & pass. (It is necessary to set according to the Cloud Connecter authentication setting etc.)
Select the connection information I created and click Next.
Configure settings for the app. (In this case, default settings)
Enter the project name, organization name, etc. (as you like). These will be the information of the Xcode project to be generated from now on.
Select the backend connection information I created earlier to create ProxyClass.
Select the app’s UI type. In this case, select “Master/Detail View”.
The setting is now complete. Click the [Finish] button.
If successful, Xcode is launched and the generated project is opened.
An iOS app connected to the back end via SCP was automatically created at once.
Build Check
Let’s check of the generated Xcode project.
Since Team information is blank at the automatically generated stage, set your own team information and Click the upper left build button.
After authentication steps etc., a list screen is displayed.
I can confirm that the OData EntitySet name (StockInfoSet) is displayed.
When StockInfoSet is selected, I can confirm that the table record (stock information in dummy table) on S/4HANA is displayed
Summary
I generated an iOS application that is connected to the back end S/4HANA system using SCP SDK for iOS. It’s great to be able to easily make a implementation.
In next post, I will implement the AR function by updating generated Xcode project.