Mobile Development for IOS using Xamarin on Visual Studio(C#) using StoryBoard

In my earlier article http://scn.sap.com/community/interoperability-microsoft-net/blog/2014/01/17/sap-and-xamarin-for-c-mobile-cross-platform-development-tutorialI had explained in detail on mobile development using Xamain.  In that article I had explained for Android and Windows phone.      I wanted to include IOS as well – I found that Xamarin came with new Release Xamarin 3 that includes Storyboard on Visual Studio ( Which I found makes it easy for C# developers who want to do IOS programming in C#).

Xamarin 3 has many more new Features such as Xamarin Form which make things very easy to develop mobile applications and shared Projects for cross platform development.  Check out how cool this is

webinar recording: https://xamarin.wistia.com/medias/dnm9rouaer

Webinar slides: http://www.slideshare.net/Xamarin/say-hello-to-xamarin-3


  The current article explores the Storyboard feature for IOS in Visual Studio

The Process of exposing SAP ABAP calls has been covered in my earlier article.  This article assumes that the ABAP REST Service is available and will develop IPhone App using Xamarin on Visual Studio using Storyboard.

In order to use this you have to follow the install procedure listed by Xamarin and have a Mac as well as.  Visual Studio Xamarin Storyboard uses Mac for Rendering( Mac has to be paired with Visual Studio running on Windows). Windows could be ruining on VM ware on Mac or be available  on the network.

1)      Start a new Project in Visual Studio and choose IOS – Iphone Storyboard – Single View Application and name it HelloSAP

See Image1 Below

Image1.png

Image1


2)      In the Solution Explorer double click on the MainStoryBoard.storyboard to open up the GUI Designer(Mac has to be Paired otherwise this will not work)

3)      In The toolbox you have all the mac controls – just drag and drop any of the controls that you required on the view controller that is present on the storyboard – In this case we drop couple of Textboxes for usename,password, a Button to call SAP and Lable to display Message from SAP.   See the image Below

4)      In the Solution Explorer Right Click on Components, Choose Get More Components and choose Json.NET and add this to application as we will use Json Format to send and receive data from SAP.

See image2 below

/wp-content/uploads/2014/05/image2_464813.png

5)      Create A New Folder and write the C# code for making the REST Service to call SAP – this is provided in my earlier article

6)      Write the code in the ViewController– write code in the ViewDidLoad – Call SAP in the Button TouchUpInside delegate

As shown below

         

When you Click the Button – A Rest Service Call is Made to SAP which lookups the company Code(username and Password are stored in the Rest Service Call not shown in code).  The Company Name is returned by SAP which is displayed at the bottom of the Screen.

public void CallSAP(object sender, EventArgs e)

        {

            this.ActivityInd.StartAnimating();

            RestClient rc = new RestClient();

            rc.Method = HttpVerb.POST;

            rc.EndPoint = “http://compurl:port/sap/zxamarin/”;

            Company Com = new Company();

            Com.Bukrs = this.TxtCode.Text;

            rc.PostData = Newtonsoft.Json.JsonConvert.SerializeObject(Com);

            try

            {

                string message = rc.MakeRequest(“CCODE/CCODE/?sap-client=800”);

                Com = (Company)Newtonsoft.Json.JsonConvert.DeserializeObject(message, typeof(Company));

                this.LblMessage.Text = “Hello SAP From  Company ” + Com.Name;

            }

            catch (Exception Ex)

            {

                new UIAlertView(“Exception Occured“, Ex.Message, null, “OK”);

            }

        }

See Image 3 Below

/wp-content/uploads/2014/05/image3_464814.png

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