This is part 2 of my 3 part series in which we are creating a simple read and write SAP based iOS app using the Sybase Unwired Platform.
In part 1 we covered the creation of our function modules for accessing and creating data on SAP. In this part we are going to create our SUP model, which will utilize our function modules and allow us to generate our native code for our iOS application.
The version of Sybase Unwired Platform SDK I am using is 2.1 ESD#3 patch 1, which at the time of writing was the latest version. Previous versions should not be all that different.
First lets open our SDK and create a new Mobile Application Project.
In this case I am calling my project SupTut1. Once you have completed the new project wizard you should end up with a new project in your workspace structured as follows:
As our first step we need to create our first and only MBO. An MBO is a mobile business object. It represents the structure of the data we intend to interact with in our mobile application. MBOs also have operations, which are one of four types:
Operations are linked to back-end functions such as our CREATE function that we defined in part 1 of this series.
So in our case we need to create 1 MBO called “BusinessData”, which has a single operation and is linked to our SAP back end. To create an MBO – right click on the “Mobile Business Object” node in your project structure and select “ADD MOBILE BUSINESS OBJECT”.
You will be brought into the wizard for MBO creation. We must first name and put a description on our new MBO, which in our case will be “BusinessData” and a suitable description.
Next we must select where our data is going to come from. So in our case we are coming from SAP, and my ECC system is setup on my workspace as ER19. (The workspace will verify your connection works at this stage so you need to be able to connect to your SAP system on your current network).
Next you come to the “SAP Definition” screen. Here we need to define our read function for our data – so select “Browse” to search for our function module that we created earlier.
This might take a minute or two, as at this stage the workspace is going to connect to your SAP system and read the Business Objects Repository – my only advice here is do this on a stable connection and not on a train (like I am trying to do as I write this!).
Search for our function from part 1 “Z_SUPTUT_DATA_GET”
Once we have selected our function we can select what data we want from its outputs. We select our table ET_DATA and continue the wizard.
When prompted, select the field “TKEY” as our primary key and finish our wizard. We are now left with our “BusinessData” MBO.
We have one more thing to do before our MBO is ready. We must add our create operation.
So next, right click on the MBO you have just created, and select New->Operation. The name of the operation is going to be create as will the operation type. You can provide a suitable comment at this stage as well (something I would recommend for a standard business project for the sanity of future developers).
Click next to select our function “Z_SUPTUT_DATA_CREATE” which we also created during part 1 of this series. Once you have selected the function, click next to map our parameters.
We will select our single importing parameter (our text) and a single exporting parameter, which is a table of the newly created data (ET_DATA).
Now we move onto the parameters for our function. Here we select that our text import parameter is filled from our MBO attribute “text”. The reason for this is that, as we create new entries in our MBO on the device, the data entered should be passed back to SAP as our importing parameter (This will make more sense during the iOS coding).
Finally we need to map the parameters from the exporting table from SAP to our attributes of our MBO. In our case this is simply a straight mapping.
Now that we have created our MBO and our create operation we need to adjust the settings that control how often our SUP server will cache the data on SAP.
Our model is a definition for our SUP server as to what data it will need to cache and how often it should cache that data. For more information on how cache groups and synchronization groups work please check the Sybase documentation.
For our purposes we will use the standard “Default” cache group provided.
In the properties of this group we select that our group is “on-demand” (data will only be refreshed if a device requests it), the minimum time between refreshes of our data from SAP should be set to 30 seconds.
Finally we set the cache group to be partitioned by requester and device identity. This means that every device that connects to the server will have its own unique copy of the data on SAP (useful for user specific data).
So we are nearly done, one two steps left to complete. Firstly we need to deploy our model to our SUP server. So we right click on our project and select the “Deploy Project” option.
Follow the wizard through noting the following. You will need to select the correct domain on your SUP server. For me, I have a domain I use specifically for POCs. The default domain on a SUP server is “default”.
Your security configuration should match how you intend to authenticate with your SUP server. In my case I have a configuration, which has a few pre-configured logons that I use for POCs. The default is “admin”
The rest of the wizard deals with your app ID (accept the default here) and which SAP connection you app should use. (If you do not have your SAP connection setup the wizard will allow you to create a connection based on the one you have used in your SDK).
Our final step will be to generate our code to be used in our iOS app. To do this, right click on our project and select “Generate Code”. You will be taken through another wizard.
Make sure you select the MBO we have created to include in the code.
On the final screen you will be prompted for some parameters. For our purposes we will be using the “Objective C” language on the “iOS” platform. You can select your own unwired server and domain here again.
And that is it! Your generated code should be placed in the folder called “Generated Code” within the location of your SUP project. We are now ready to get our App up and running in part 3.