Monday, July 13, 2009

Connecting SAP to .Net

[Prerequisites]

1. After installing VS.Net Studio 1.1 , Install latest JVM
2. Install SAP .Net Connector 2.0

[/Prerequisites]

1. Open a new Web Application
2. Select -> Add new item -> SAP Connector Proxy
3. Open Server Explorer -> Select Application Server under SAP
4. Right Click it -> Select Add Application Server
5. Provide the SAP Credentials.
Example : Destination Type : Custom Logon Settings;Username:****;Password:****:AppServerHost:[IP Addr];SystemNumber:0;client:335
6. Once Connected, Select the SAP Server -> right click Functions -> Add Filter. Example : ZBAPI*
7. It will list all the corresponding BAPI’s inside the filter.
8. Now drag and drop the required BAPI from the filter to sapproxy.sapwsdl
9. Build the application. It will generate the SAP code automatically.
10. Open the Web form where you need to display the data.
11. Open ToolBox -> Drag and Drop SAP Table Wizard to the WebForm.
12. Now add the structure and BAPIReturn to the web form
13. Now connection code is as follows
[Code]
DataSet dsSapData = new DataSet();
public Sap_Proxies.SAP_Proxy objProxy = new Sap_Proxies.SAP_Proxy();
objProxy.ConnectionString = ConfigurationSettings.AppSettings["sapConn"].ToString();
objProxy.Connection.Open();
objProxy.YourBAPI(param1,param2,.....);
dsSapData.Tables.Add(yourbapitable.ToADODataTable());
[/Code]
14. Now bind the Dataset to Datagrid as follows
[Code]
YourDataGrid.DataSource = dsSapData;
YourDataGrid.DataBind();
[/Code]

No comments:

Post a Comment