Skip to Content

Consume SAP Data in non SAP Applications ( Web Service, .Net )

If you want to consume SAP data through non SAP application then this is a very useful document for you. It gives you a step by step, easy guide to build it yourself. We can, using SAP Web Services, read and write SAP data using non SAP applications. This option has been available for a long time now. Please do remember with the advent of UI5 and Fiori there are now more ways to utilise SAP data externally.

The example here shows how to read the data but can be enhanced to write back to SAP as well. Please check if you have the relevant SAP license.

This example was done on:

1) Microsoft Visual Studio 12

2) SAP ECC 6.0

I am writing down the steps which if followed properly will help you do it yourself.

The example here is to demonstrate how we can read vendors in SAP and pass it on to a .Net Application.

The prerequisites are:

1) Basic knowledge of SAP ABAP, especially RFC

3) Basic knowledge of Visual Basic/C#

Here is a list of, high level, steps on how to do it:

1) Create an RFC Enabled Function Module in SAP

a) In our example, we will create an RFC which accepts a country code and returns all the vendors for that country from an SAP server

2) Create a Web Service for the function module so that it can be consumed by other service based applications

3) Setup the Web Service

4) Create a small Visual Basic Project to show how the country selection be passed to the Web Service and utilise the list of vendors returned from SAP

We will start with a list of activities to be carried out in SAP first.

  1. Creating an RFC Enabled Function in SAP
    1. /wp-content/uploads/2015/09/1a_795161.png
    2. /wp-content/uploads/2015/09/1b_795165.png
    3. /wp-content/uploads/2015/09/1c_795163.png
    4. /wp-content/uploads/2015/09/1d_795164.png
  2. Next step is to convert this into a Web Service so that it can be called from outside SAP
    1. /wp-content/uploads/2015/09/2a_795166.png
    2. /wp-content/uploads/2015/09/2b_795167.png
    3. /wp-content/uploads/2015/09/2c_795168.png
  3. Setup Web Service Step I- Run Transaction – SOAMANAGER – Select Web Service Configuration. Search the newly created Webservice. Click on the search result-> Click on Create Service (The below lines will be created once you have finished creating the service. You may want to look at the next screenshots for details on what to select. Authentication is the main one, we can leave all the rest to default.
    1. /wp-content/uploads/2015/09/3a_795169.png
    2. /wp-content/uploads/2015/09/3b_795170.png
    3. /wp-content/uploads/2015/09/3c_795171.png
  4. Setup Web Service – Step II – Properties setting to be used while creating the service. Click on Open Binding WSDL generation to get the Web Service Link. Copy the WSDL URL for Binding – This will be used in other non SAP application to link to SAP
    1. /wp-content/uploads/2015/09/4a_795172.png
    2. /wp-content/uploads/2015/09/4b_795173.png
    3. /wp-content/uploads/2015/09/4c_795174.png
  5. Consume it in .Net (Visual Basic Application ) – Step I -Start a new project of type WebSite. Add Web Form by right clicking on the Project. Drag a text box, button and labels as show below. We will use the text box to enter country code. The button will trigger the call to SAP function and return the vendors for that country.
    1. /wp-content/uploads/2015/09/5a_795175.png
    2. /wp-content/uploads/2015/09/5b_795176.png
    3. /wp-content/uploads/2015/09/5c_795177.png
  6. Consume it in .Net (Visual Basic Application ) – Step II – Add a Service reference – Most critical part. Click on advanced. Click on Add Web Reference. Put the URL from Web Service screen above and click on go – You might be asked to login to SAP here. In the end the web service will show on the screen. You may change how it should be called in VB Project. Final Output once the FM is added in our example. Click on Add Reference
    1. /wp-content/uploads/2015/09/6a_795178.png
    2. /wp-content/uploads/2015/09/6b_795179.png
    3. /wp-content/uploads/2015/09/6c_795180.png
    4. /wp-content/uploads/2015/09/6d_795181.png
    5. /wp-content/uploads/2015/09/6e_795182.png
  7. Consume it in .Net (Visual Basic Application ) – Step III – Code Snippet
    1. /wp-content/uploads/2015/09/7a_795183.png
  8. Consume it in .Net (Visual Basic Application ) – Step IV – Output  – You can then run the VB application, press the submit button and the result would be fetched from SAP.
    1. /wp-content/uploads/2015/09/8a_795184.png
  9. The output is not being shown here purposely.
You must be Logged on to comment or reply to a post.