Code for the SMB's with us
At this moment you probably know that we are going to host a Hackathon on the first day of each SMB Innovation Summit 2019. This will be an extremely creative session in which you will be able to experiment developing solutions for the Intelligent Enterprise. You just need to register to the event, bring your laptop and most important: fuel your imagination.
To make your life easier, we are developing building blocks based on technologies available on
SAP Cloud Platform, such as blockchain, mobile, internet of things, machine learning, chatbot, and much more.
Master the mobile technology
This blog is meant to discuss the building block regarding the development of native mobile solutions for iOS devices connecting to
SAP Business One and
SAP Business ByDesign backend.
All of us agree that starting whatever solution from the scratch takes quite some time, so our SAP colleagues have done a very good job developing tools to help us out on:
- Setting up your mobile app in the SAP Cloud Platform;
- Generating an Xcode project based on the Fiori iOS SDK that consumes the mobile settings from SAP Cloud Platform.
Experience the SDK and the Assistant
To get started with it, and before finish reading this blog, you must go through
this tutorial. It will show you how to use the tools mentioned above and you will learn more about the SCP mobile services, the Xcode project folder structure, its files and components.
Prepare the CORE
So, now that you're familiarised with the Assistant, the settings on SCP and the Xcode project, our goal is to do run the Assistant, however now replacing the OData
sample service (that you saw on the tutorial above) by the
CORE ERP services.
Working with the SMB's, you might want to connect to the
SAP Business One Service Layer, or to the
SAP Business ByDesign OData API.
Whilst using the Assistant, you noticed you can provide the metadata file for the services you want to have the proxy classes generated for. So, here in this blog I will provide a sample metadata for Sales Orders and Purchase Orders from SAP Business One and Sales Orders and Items from SAP Business ByDesign systems. Download the
custom B1 metadata and
custom ByD metadata.
Alternatively, you might want to generate and adapt your own metadata files from your CORE ERPs.
Option 1: Connecting to the SAP Business One Service Layer
If you wish to connect your app to the SAP Business One backend, a good option is to use the B1 Service Layer, which since SAP Business One 9.3 supports OData v3(
https://host:port/b1s/v1) and v4 (
https://host:port/b1s/v2).
The SDK takes advantage of the
SAPOData component to handle requests and responses, and it's compatible with OData v2 and v4 as well. The obvious match then is to use the OData v4, so that the mobile app will be able to easily consume SAP Business One business objects from the iOS app using the SAPOData component.
Here comes the tip: adjust the metadata file from the service layer (
https://host:port/b1s/v2/$metadata) for the entities you need, otherwise the assistant might fail generating the proxy classes for the whole set of entities available.
Option 2: Connecting to the SAP Business ByDesign OData Services
If you wish to connect your app to the SAP Business ByDesign backend, a good option is to use the ByD OData API, which supports OData v2.
The ByD OData API The SDK takes advantage of the
SAPOData component to handle requests and responses, and it's compatible with OData v2 and v4.
So the obvious match here is to use the OData v2, so that the mobile app will be able to easily consumeSAP Business ByDesign objects from the iOS app using the SAPOData component.
All that you need to do is to have an OData service available in your SAP Business ByDesign backend. If you don't know how to create and expose an OData service,
follow the Step 1 of this blog.
Once you have access to the OData service, then save the metadata file locally, and make sure to copy the URL of the service.
Connect to the CORE
Run the assistant to create a new app.
At the step 3, add a new destination and fill the "Backend URL" accordingly:
Still in the same step, fill the authentication type as "Basic Authentication" and provide the username and password. For the B1 Service Layer, the username field should be comprised of a JSON containing the CompanyDB and the UserName such as
{"UserName": "manager","CompanyDB": "SBODEMOUS"}. See the sample below:
At the step 6, hover the mouse over the specific destination and click
"Edit..." :
Make sure to give a same for the service class and for the prefix, and most important: select the metadata file you saved on your local system. This is important so that if by any chance the Assistant cannot find the online metadata, it will use the local file.
Follow the next steps and wait for the Assistant to create the Xcode project based on those data. It will automatically open the Xcode project.
Run it
Run your project. You should see something like this when it loads the app:
Tap the entries and see that you get live data from your CORE ERP, and adapt the project code adding other
Fiori elements such as search bars and alike.
Check the code!
If you don't want to run the assistant, instead you can clone the repositories with the functional apps, import the SCP configuration for the mobile service and change the destination settings for your own core ERPs:
Stay tuned and join us in the SMB Innovation Summits!