My objective of this blog is to explain the SAP.NET connectivity. ie, connecting to SAP from a .NET web Service. Prerequisites for achieving the connectivity are:
- Microsoft visual studio 2003
- SAP.NET connector 2.0
- Java runtime environment
- SAP client (Optional)
Perform the following steps:
- Install SAP.NET Connector 2.0 (Ensure that Microsoft Visual Studio .NET 2003 is already installed on the PC before installing SAP.NET Connector)
- Install Java runtime environment (j2sdk-1_4_2_05-windows-i586-p.exe)
Note: Java Runtime Environment require for generating SAP proxy. - Open .NET solution (Here I’m explaining with respect to Web service)
- Open Server explorer from the .NET Solution and you can see SAP addin appearing on the Server explorer. Note: SAP addin will appear on server explorer only after the installation of SAP.NET Connector 2.0
- Expand SAP addin in the server explorer and Select Application Server and Right click - “Add an application server”.
- Configure application server :
Destination type : Custom logon settings
AppServerHost : 10.222.21.35
SystemNumber : 0
UserName : mmdemo
password : ******
client : 200
Language : EN - Expand application server – Functions – “Add Function Filter…” – and add the following filters
GroupFilter : *
NameFilter : * - Expand Functions after setting function filters and you will get the list of BAPIs (Business APIs) on the server explorer
- Add a new SAP connector proxy class to the solution from the solution explorer.
- drag and drop particular BAPI on to the design view of Proxy class.
- Build the solution after retrieving data
- Go to the design view of design view of ASMX file. And select Toolbox - SAP Proxy
- Drag and drop the proxy from the toolbox to the design view of ASMX file.
- Create web method that makes use of the proxy.
//SAP Connectionstring
public string _CONNECTIONSTRING="ashost=10.222.21.35 sysnr=0 client=200 passwd=newuser type=3 user=mmdemo";
//SAP proxy
private wsSAPdotnet.MySAPProxy mySAPProxy1;
[WebMethod]
public DataSet GetData()
{
DataSet dsData=new DataSet();
//Initialize SAP proxy
mySAPProxy1=new MySAPProxy(_CONNECTIONSTRING);
//Open proxy connection
mySAPProxy1.Connection.Open();
//Parameters for the BAPI
ZBAPIMATGRPTable Matgrp_List=new ZBAPIMATGRPTable();
ZBAPIPLANTTable Plant_List=new ZBAPIPLANTTable();
ZBAPIPURGRPTable Purgrp_List=new ZBAPIPURGRPTable();
BAPIRETURNTable Return0=new BAPIRETURNTable();
//Invoke BAPI and the result will be present in
//the 4 parameters
mySAPProxy1.Bapi_Plant_Mat_Pur_Grp(
ref Matgrp_List,
ref Plant_List,
ref Purgrp_List,
ref Return0);
//Close proxy connection
mySAPProxy1.Connection.Close();
//Convert SAPTable to DataTable and add it to dataset
dsData.Tables.Add(Matgrp_List.ToADODataTable());
dsData.Tables.Add(Plant_List.ToADODataTable());
dsData.Tables.Add(Purgrp_List.ToADODataTable());
return dsData;
} - Compile the solution and execute it
- Invoke web method GetData and which returns the data from SAP.
p.s : Here is your webservice !! And you can access SAP just by
invoking the webmethod which we'd creaded just now!!
And
Thanks to SAP for providing the SAP.NET Connector and special
thanks to Ram(PM,L&T) for giving me the wonderful opportunity to make my hand dirty by doing the integration between Microsoft.NET and SAP!!
8 comments:
xcellent idea... i was waiting for such a blog.. and i tnk its frm u tht ive gt a liking towards POC's ;-) (remembr Ujju nd Ram's POC hunts... )
Keep posting... nd b prepared to clear doubts too...
Neat blog...keep it always simple ur lay out also ur contents...gud one..all te best..
Hey nice one dear.. from now... i can say that i know "SAP.NET Connectivity".
earlier we used to here POC POC n only POC in office but now :( anyways good work dude!!!!
pls dont motivate Arun bhai to write tech blog.. u know na middleware underwear issue!!!!
One of my friend sojesh used to say : "I believe in KISS : Keep It Simple Stupid"
:)
congrads dear, keep going..wish u all the good wishes for this gr8 endeavour..:-)
Thanks for mentioning my name in your blog..;-)
I have found it on this website called [url=http://tipswift.com]tip swift[/url]. You can find it there.
cheers
edit: wrong post
nice read. I would love to follow you on twitter.
Hello everyone, thanx a lot for this article ....... This was exactly what I was looking for.
Post a Comment