This is part 3 of my series on creating an iOS application that connects to an SAP system using the Sybase Unwired Platform.
We are going to use our model from part 2 to enable our iOS app to communicate with our back-end SAP system (using the function modules from part 1) through the Sybase Unwired Platform.
First we need to do a little bit of groundwork on our Sybase Unwired Platform server. Go to your Sybase control centre (usually https://supServerURL:8283/scc) and login (default credentials supAdmin and s3pAdmin) and go to the applications area listed along the left side of the console. Under the application connections tab we now need to create a new entry for our device. We do this by selecting “Register”.
The user I am using is “supTut1”. My template should have been automatically created for me and in my case is SupTut1_preConfLogin. The only other setting I am worried about is my activation code (password) which I have specified to be the very secure “123”.
There may be some extra configuration required in your “Application Connection Template” for your app to work correctly and these settings are generally environment specific. For more information on these configurations please visit the Sybase info-center.
Now we are ready to start coding our app. Rather than go through a process that is pretty well documented on the Sybase info-centre, the first step is to setup a new iOS project in Xcode called “SUPTut” by following the instructions for “Developing an iOS application” as can be found here:
Make sure to continue and follow the next section on “Adding source code files, libs and resources” which can be found here:
Next, follow the instructions for “Configure Build Settings” found here:
Finally, you will need a file called a “CallbackHandler” which handles all of the messages received from the Sybase Unwired Platform during communications. Sample files can be found for this here.
Once all these steps are complete, the next step is to add our generated code to our project. This is the code we ended up with at the end of part 2 of this series. This code represents the ability for us to access the data we need via the SUP libraries that you included in your Xcode project.
So we are now ready to start getting our app ready for its first connection. For ease of coding I create a new “NSObject” subclass called “ConnectionController”. This class will take care of all of the connection APIs.
My ConnectionController.h file will have defined a single static method to trigger our connection.
Our ConnectionController.m will contain our static method implementation as well as a single instance method. But first, lets start with our imports:
Next we need to define any properties we will need which in our case is one. This will be our “CallbackHandler”.
As we only reference this class statically we need a static instance to reference as follows:
Next we can implement our static method “beginApplicationSetup”. The method will first check if this class has been instantiated before, if not it will create a new instance to be stored in our static variable. Finally it will call our (yet to be defined) instance method for connecting to the server.
Now we must define our instance method, which we will call “setupApplicationConnection”. The first thing we will do in this method is to setup a “SUPApplication” object and set our callback handler for the app.
Next we setup our connection properties. This is generally over port 5001 on your unwired server and is called “Message Based Synchronisation” or MBS. All SUP connections are initiated using MBS over this port. At this stage of the registration the application is identifying itself to the server and checking if it is able to register using the credentials we created on the SUP server earlier. We also create our local database on our device at this stage.
Our next step is to setup our synchronization profile. This is the profile used for actual data synchronization. The protocol used is called Replication based synchronization and usually takes place over ports 2480/2481 (insecure/secure).
Our final step here just prior to connection is to setup our callback handler on our database and then set our configured “SUPApplication” object on our database class.
So now we are ready for our connection code, which goes at the end of this instance method:
For this tutorial we are going to go for a simple UI on our application and rely on the Xcode debugger for most of the important information. Our application will have 4 buttons.
Start Connection:
Synchronise:
Find All:
And finally, Create new Entry. Simply taking the class of the MBO in our case “SupTut1BusinessData” and calling the method “getInstance” create new entries. Once we have set any properties on this new instance of a line of our “BusinessData” MBO we call “save” on it. Once saved, we call “submitPending” which, submits all pending operations on our MBO line. Finally for good measure we call synchronise.
And that is it; once you have added these actions to your view and hooked up your buttons you can give your app a try. On first launch, you will need to register your device for the first time. This can take about 30 seconds.
If all of this works then congratulations you now have a fully working SUP/SAP sample iOS application, which both receives and sends data.
This tutorial is a small snapshot of how to get an end-to-end Sybase Unwired Platform based SAP mobile app working. There are a lot more options, configurations and options available under the hood and I recommend checking out the Sybase documentation for more information on these.
In the meantime - Happy coding!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
9 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |