Skip to Content

Getting started with SAP Gateway for Microsoft Developer Trial

You have probably heard that SAP Gateway for Microsoft is now available via a Developer Trial. In this blog post, I want to outline all the steps that are required to get you started: you can use the Developer Trial and the Visual Studio Community Edition -- that is all to quickly build your first .NET application consuming SAP data in an enterprise ready manner.

At first you need to have Visual Studio Installed. Luckily Microsoft has a Community Edition: Go to http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx and Select the Community 2013 with Update 4 (you should not select the 90 day free trial, because then you can only use it for 90 days :-))

(if you want to use one of the Outlook / Excel templates from SAP Gateway for Microsoft, plesae make sure to install the following two components as well:


  1. Visual Studio 2010 Tools for Office Runtime - http://www.microsoft.com/en-in/download/details.aspx?id=44074
  2. OfficeToolsForVS2013Update - http://aka.ms/officedevtoolsforvs2013

Then click on "Install now" to download and start the installation

The installation process is as simple as it can be: just continue to click Next

Install:

And done:

When you launch Visual Studio for the first time you are asked to sign in (which you can skip).

Then you have to select your default profile. Since SAP Gateway for Microsoft is using C# it is recommended that you select this as the default (although you can easily switch this later on)

Now Visual Studio is running for the first time:

As a next step you have to download SAP Gateway for Microsoft Developer Trial:

Head over to the SAP Store and click on "Trial Version"

You will need to complete and confirm some information

and soon after you will receive an email with a unique download link

That's it. Now you can download the SAP Gateway for Microsoft Developer Trial

and start Setup.exe to run the installation

Very much link with the Visual Studio installation, just continue to click "Next" and leave the default settings:

Great! Now we are ready to start Visual Studio and create our first project:

Click on New Project and to start with select a Windows Forms Application (under Visual C#):

You can enlarge the default view

And by Right-Clicking on the Solution you can select "Add SAP Service Reference"

Now you are using SAP Gateway for Microsoft for the first time and have to Explore Services:

In order to do that you have to connect to a SAP Gateway system. In our scenario we will use the public SAP Developer Center Gateway system located at:

sapes1.sapdevcenter.com. You will need a username and password which you can request following the instructions here: http://scn.sap.com/docs/DOC-40986

Now we can browse for available OData services. For this quick "Getting started" we select the ZGWSAMPLE_SRV service:

As a result quite a lot of classes are generated!

One thing that was created is a new App.config file which contains all the connection details. In order to generate and use this project later on, we have to delete the "old" App.config file.

Now we can start creating the View. For that lets select a DataGridView and drag it in the Form1:

... and a Button which will trigger the OData call later on:

Now we have to add the code behind the button. So Double-Click on the button and add the following source code:

            List<ZGWSAMPLE_SRV.BusinessPartner> businessPartnerList = new List<ZGWSAMPLE_SRV.BusinessPartner>();

            try

            {

                Logger.Log(Severity.Verbose, Categories.ServiceCall, " BusinessPartnerWindowsFormApp::button1_Click()");

                ApplicationConfigReader.ConfigFilePath = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath;

                ServiceDetails serviceDetail = ConfigurationReaderHandler.Instance.GetServiceDetails("ZGWSAMPLE_SRV");

                ZGWSAMPLE_SRV.ZGWSAMPLE_SRV serviceContext = new ZGWSAMPLE_SRV.ZGWSAMPLE_SRV(new Uri(serviceDetail.Url));

                Logger.Log(Severity.Verbose, Categories.ServiceCall, "Fetching data from SAP System");

                foreach (ZGWSAMPLE_SRV.BusinessPartner businessPartner in serviceContext.BusinessPartnerCollection)

                {

                    businessPartnerList.Add(businessPartner);

                }

                this.dataGridView1.DataSource = businessPartnerList;

            }

            catch (Exception ex)

            {

                Logger.LogException(Severity.Error, Categories.ServiceCall, ex);

                Logger.Log(Severity.Error, Categories.ServiceCall, "Failed to fetch data from SAP system");

                throw;

            }

As you can see there are some errors, which can easily be resolved by adding the required "using xxx" statements.

As a last step -- since we cannot use SSO to the SAP Gateway Developer Center system -- we have to add a username & password. For this open the BusinessConnectivityHelper class and go to HandleSAPConnectivity.

Here add again the username and password that you got from your registration.

That's it. Now we can run the project. When you click on the Button...

... then you should see the data coming from the SAP system in your .NET application.

That's it :-) Of course this is only a very simple example, but I hope it helps you to get started. You can continue to experience SAP Gateway for Microsoft and develop your first Outlook or Excel integration as well. We will soon publish more related guides to get you started!

Tags:
Former Member