Skip to Content

There are numerous blogs and how-to videos for the Sybase Unwired Platform however if you work a lot with SAP you might become a little frustrated when you struggle to find SAP specific examples.

In this 3 part tutorial I am going to run through creating a simple read and write SAP based mobile application using the Sybase Unwired Platform and consumed on an iOS device. The three parts will consist of:

  1. Creating two simple remote enabled function modules in SAP (read and write)
  2. Creating our SUP model, which will use the function modules from part 1.
  3. Creating a simple iOS app, which will communicate with our SAP system through SUP.

Our Scenario

First, lets set the scene. In SAP I have a table of business data, very simple data that is. It consists of a primary key provided by SAP and some text, which will be provided by our users.

/wp-content/uploads/2012/11/1_153591.png

Our users will want to view all of this data and add to that data if necessary all through their iOS device. So lets begin.

Getting Started

On my ERP system I have a table called ZSUP101DATA, which contains our business key (which is just an incrementing number) and some corresponding text.

/wp-content/uploads/2012/11/2_153592.png

We will need two ways of interfacing with this data a read function and a write function. Lets start with reading. We create a remote enabled function module called Z_SUPTUT_DATA_GET.

/wp-content/uploads/2012/11/3_153608.png

We will not be needing any importing parameters in this case however we will be returning two tables, one for our data and one standard BAPIRET2 table for any warnings or errors.

/wp-content/uploads/2012/11/4_153609.png

In this case ZSUP101_T is a table type of the same structure used in our table we mentioned earlier.

In terms of the code in the function it could not be simpler – just a “select *” from our table and placing the returned data into our exporting table “ET_DATA”.

/wp-content/uploads/2012/11/5_153610.png

And that is our read function. Next we need a write or create function.  So we need to create another remote enabled function module called Z_SUPTUT_DATA_CREATE.

/wp-content/uploads/2012/11/6_153611.png

We will have a single importing parameter taking the text to be inserted into our data table. We don’t provide a key here as SAP creates our keys for us.

/wp-content/uploads/2012/11/7_153612.png

Our exporting parameters will be a structure containing our new record including the key and a standard return BAPIRET2 table.

/wp-content/uploads/2012/11/8_153613.png

Our code for this function simply detects the highest key number currently in the table and increments it by 1. Then our new record with this key is inserted into the table. Finally this new record is returned in our exporting structure ET_DATA.

/wp-content/uploads/2012/11/9_153614.png

For the sake of this example I have not implemented any error checking however if you were writing this correctly, sufficient error checking would be added.

You should now be able to activate both of these function modules and unit test them to ensure they work.

Next

And that is it – step 1 is complete. Next we are going to move onto Part 2 of this series in which we are going to create our Sybase Unwired Platform model using the Sybase SDK.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply