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.
- Creating an RFC Enabled Function in SAP
- Next step is to convert this into a Web Service so that it can be called from outside SAP
- 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.
- 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
- 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.
- 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
- Consume it in .Net (Visual Basic Application ) – Step III – Code Snippet
- 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.
- The output is not being shown here purposely.
Great article, thanks for sharing.
Good to know this... Thanks for sharing
No worries at all. I am glad you all like it.
Thanks for your nice feedback!
Nice document for Web services..:)
Very Nice Article.Thanks for sharing it!
Very useful Article!!!
Very useful document! helped me 🙂
Hi, How would like to now consume BPIRET2 format service inside c# is there any different way to consume
i tried to use the tutorial to get this running in an outllok formregion (in Mail). There is no system.web.ui.page . I think this is because it is not a page. it's an vsto addin. Does anyone know wthat to do???
nice article. I had tried the above example in my dot net application its giving error like request was aborted or cancelled. after giving the correct user ID and password. How can i fix this issue. Can you guide me.
Seems like a connection/network issue to me. Check the user configuration and the connection please.
Great Article. Very much informative.