You are on page 1of 10

Integrating SAP ERP with

Microsoft .NET windows


application by SAP .NET
Connector

Applies to:
SAP ECC 6.0 and Microsoft .NET 2003 (V 1.1.4322 and SP1).

Summary
This document will provide complete reference and guide for integrating Microsoft C# .NET 1.1/2.0 windows
application with SAP ERP. Integration is being done on SAP .NET connector. This communication is being
done through SAP proxy class in Microsoft .NET 1.1/2.0 and to generate the proxy class used wsdl file which
created from Java Jar file in the SAP .NET connector. As this communication is being done by SAP proxy
class in MS .NET 1.1/2.0 IDE. In the end using the proxy class invocation of RFC will be done and able to
make the transaction in SAP system. Most importantly in this entire integration process SAP .NET connector
wizard only used for create proxy class from the wsdl file and provide the uniformed approach for creating
the same. Its help the practitioner to over come the paint point they face while create the proxy connection,
invoking the call the SAP function module etc.

Author: Charbak Chatterjee


Company: IBM India
Created on: 03 July 2008

Author Bio
Charbak Chatterjee is working in IBM India as Application developer on architecture and
development of composite application using CAF Web Dynpro etc..He also working in
Microsoft Technologies like MS .NET 1.1,2.0 ,Visual Basic 6.0, SQL Server -2005 , Crystal
Report etc and have depth understanding on SOA, Webservices, XML and different
enterprise integration system

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


© 2008 SAP AG 1
Integrating SAP ERP with Microsoft .NET windows application by SAP .NET Connector

able of Contents
Introduction .........................................................................................................................................................3
Architecture Overview .....................................................................................................................................3
1. Identify the RFC in SAP system..................................................................................................................4
2. Create WSDL file for specific RFC..............................................................................................................4
2.1 Reason behind to create WSDL.............................................................................................................................4
2.2 Create WSDL file ...................................................................................................................................................4
3. Create SAP proxy class in Microsoft Visual C# .NET 1.1. environment.....................................................6
3.1 Create SAP proxy class .........................................................................................................................................6
4. Invoke the RFC enabled function module through proxy class ..................................................................8
4.1 Writing code in MS .NET 1.1 using the proxy class ...............................................................................................8
Related Content..................................................................................................................................................9
Disclaimer and Liability Notice..........................................................................................................................10

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


© 2008 SAP AG 2
Integrating SAP ERP with Microsoft .NET windows application by SAP .NET Connector

Introduction
Connecting SAP system through SAP .Net Connector is already defined process but to leverage the same
within existing enterprise landscape there was not good enough article till now. Specifically while creating the
client proxy in MS .NET application in order to invoke SAP RFC’s using correct credential , many time we are
not able to create the same. In this regards we need some generic steps by which we will able to create SAP
proxy classes in MS .NET IDE and able to execute several transaction in SAP system by RFC. To achieve
the goal approach as follows
• Identify the RFC in SAP system
• Create the WSDL file for a specific RFC.
• Create SAP proxy class from the WSDL in the MS .NET application
• Make transaction in SAP system through RFC by the SAP proxy class.

Architecture Overview
Below diagram reflecting the architecture overview of the system.

We are not
following this
path Microsoft .NET 1.1
Application
SAP
SAP .NET
System Connector
Create proxy class

Invoke RFC Class file


enabled function generated e.g.
module from MS SAPProxy1.cs
Create WSDL file .NET windows
using Java jar file application

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


© 2008 SAP AG 3
Integrating SAP ERP with Microsoft .NET windows application by SAP .NET Connector

1. Identify the RFC in SAP system


Identify the RFC enabled function module in the SAP system for which you are about to make the proxy
class in order to execute the task/transaction in the SAP system. In our case we will worked on
“BAPI_BUPR_EMPLO_ADDRESSES_GET” which has already RFC enabled.

Note: You can use any RFC enabled function module.

2. Create WSDL file for specific RFC

2.1 Reason behind to create WSDL


This step is to be the most important steps in this entire exercise. As already discussed that while you using
the SAP .NET connector wizard for creating the proxy class. Several times you might encounter with the
following message, though your input in concern to SAP user authentication etc. was correct.

Note: these message only shows the developer pain point for your reference.

To overcome this situation and make the entire integration process generic we need to create the WSDL file
for this function module and import the same in to the MS .NET application for creating the proxy class for
this function module.

2.2 Create WSDL file


To create the WSDL file you need to go to command prompt , by Start =>RUN => type cmd then click “Ok”.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


© 2008 SAP AG 4
Integrating SAP ERP with Microsoft .NET windows application by SAP .NET Connector

In the dos prompt change to the installation directory where you install the SAP .NET connector for Visual
studio 2003.In this our case it will be “C:\Program Files\SAP\SAP .NET Connector for VisualStudio 2003” .If
you have install SAP .NET connector 2.0 it will be like this “C:\Program Files\SAP\SAP .NET Connector
2.0_1”.

Note: WSDL which is created from SAP .NET connector 2.0 can be used in both MS .NET 1.1 and MS .NET 2.0 version.

Then type the following command in the command prompt and press enter to create the WSDL file in your
desired location.
Command - "C:\Program Files\Java\jre1.5.0_14\bin\java.exe" -Xmx128m -cp
aii_upload_core.jar;aii_upload_sap.jar;aii_util_misc.jar;aii_util_xml.jar;aii_util_rb.jar
;inqmyxml.jar;sapjco.jar;SAPmdi.jar com.sap.aii.upload.tool.RFC2WSDLTool "C:\Documents
and Settings\Administrator\Desktop\SAPProxySll1\metadata.wsdl" <host IP> <id> <client>
"<user id>" "<password>" BAPI_BUPR_EMPLO_ADDRESSES_GET

Note: Please change the SAP system login credential in the above text which is marked by “< .. >”.

Please change the following parameter value

• Host IP
• System ID
• SAP client
• User id
• Password

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


© 2008 SAP AG 5
Integrating SAP ERP with Microsoft .NET windows application by SAP .NET Connector

Note : If you unable to generate the WSDL file please use SAP .NET Connector 2.0. Also assuming that Java runtime
was already installed and the path of the Java Runtime is "C:\Program
Files\Java\jre1.5.0_14\bin\java.exe".

3. Create SAP proxy class in Microsoft Visual C# .NET 1.1. environment


In this step we will create the SAP proxy class which will be used to invoke the RFC and also manage the all
necessary stuff that need to be taken care during time of invocation. In order to create the proxy class please
pursue the following steps.

3.1 Create SAP proxy class


To create the SAP proxy class for the RFC please open the Microsoft Visual Studio .NET 1.1 IDE. Then
create the new project from File =>New=>Project (Fig1)

Fig 1
After create the project select that in solution explorer and open the context menu and click on “Add new
item” Fig2

Fig 2
Then select the item named as “SAP Connector Class” , provide the appropriate name to the class and click
on open to proceed further (Fig3)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


© 2008 SAP AG 6
Integrating SAP ERP with Microsoft .NET windows application by SAP .NET Connector

Fig3
After click on “open” it will ask from where it will generate from . Select the “WSDL file from SAP IFR” and
click on next (Fig 4).

Fig 4
In the next step select the WSDL file that we created earlier and then click on “next” to complete the
generation process of SAP proxy class. The SAP proxy class will be generated and we can start working
with that (Fig 5).SAP proxy class will be generated successfully in the MS .NET 1.1 aplication.

Fig 5

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


© 2008 SAP AG 7
Integrating SAP ERP with Microsoft .NET windows application by SAP .NET Connector

4. Invoke the RFC enabled function module through proxy class


As in the above steps we successfully create the proxy class , now we can start accessing/use the SAP
system through RFC by using the proxy class. Use the following lines of code in order to call the RFC from
MS .NET 1.1/2.0 application. Put the code into one class file and then invoke the same.

4.1 Writing code in MS .NET 1.1 using the proxy class

After executing the RFC return value will be populated into the tables AddressTbl and BapiretTbl and you
can do the further processing with those tables.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


© 2008 SAP AG 8
Integrating SAP ERP with Microsoft .NET windows application by SAP .NET Connector

Related Content
Download SAP connector for Microsoft .NET 1.1/2.0
The SAP .Connector – Architecture and Functionality
SAP .NET connector programmer’s reference

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


© 2008 SAP AG 9
Integrating SAP ERP with Microsoft .NET windows application by SAP .NET Connector

Disclaimer and Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not
supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document,
and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or
code sample, including any liability resulting from incompatibility between the content within this document and the materials and
services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this
document.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


© 2008 SAP AG 10