Skip to Content
Author's profile photo Ramesh Vodela

Xamarin Native IPhone and Apple Watch for Plant Stock – Part1

Very Recently I had written a Plant StockNative application using Xamarin for Andorid

http://scn.sap.com/community/developer-center/mobility-platform/blog/2015/05/22/xamarin-andorid-native-application-for-plant-stock-transaction-mmbemobile-version

With all the buzz on apple Watch I wanted to develop Apple Watch application for SAP Plant Stock – I wanted to use the same Backend REST services that I had developed for my earlier android application.

When you want to develop an Apple Watch application ( as of version 1.0 of Apple Watch you have to have an iPhone app and watch app.  The Watch app

communicates with Phone app to get the data which is displayed on the watch.  So I decided to write an IPhone app using Xamarin and then extend this to Apple Watch in (Part 2 http://scn.sap.com/community/developer-center/mobility-platform/blog/2015/06/12/xamarin-native-iphone-and-apple-watch-for-plant-stock–part2).  If only wanted to develop an Watch app alone my Phone app need have any Great UI and handle interactions – As I wanted to have a

fully working iPhone App as well I created a new IPhone Project using Xamarin Studio.

/wp-content/uploads/2015/06/image1_724242.png

I choose a single View Application and double click on Main.storyboard file to open the Xamarin designer and added the tableView controller and couple of view controller, navigation controller and tool bar button –  For detailed description of app development check out on  Xamarin.com, youtube and github.

I have added nugets for SQLite, Newtonsoft json, ZXING bar code component from Xamarin Components – Added references to System.Net.Http.

/wp-content/uploads/2015/06/image2_724243.png

When the Appstarts in Appdelegate.cs file I have set up SQLite database that w will save Plant Stock so that you don’t have to call SAP for the Same Selection Criteria.    The View Controller that is connected to the navigation controller is displayed on the phone

/wp-content/uploads/2015/06/image3_724301.png

In the Select Screen for the Plant and Location I have two Picker controls that are populated by an REST Call to SAP – For Material and Batch I have to textfields. For the Scan Barcode button I have code that calls ZXING component to scan using Iphone Camera – When you click on the get button –

a REST call is made to SAP to get Stock Records which are populated into an SQLite Database and is displayed on the tableview Controller.  For the table view Controller  I have custom cell with four lables.

1) in the table View Controller – you have to set TableView.Source to a class that implements UITableViewSource Interface methods.

2) When you click on Select the Select View Controller is called – This has two pickers – For the pickers to display the dropdown you have implement UIPickerModel for Plant and Loctions and then assign to the respective picker model.

3) When the Get Button is clicked make a REST Call to SAP to get the stock records and then call PopViewConrller to get back to the TableView Contoller as the seque that is called when you click the button performs a push.

In the next part I will extend this to work on Apple Watch

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Enio Rafael
      Enio Rafael

      Hi @Ramesh Vodela

      Very interesting post, I'm a sap abap developer either and I'm trying to develop some things with xamarin forms either.

       

      Thank you.