07-03-2012 5:28 AM
i have a task to communication between SAP and .Net winform application plz does anyone have a sample code snippet
with help of RFC and BAPI
07-03-2012 4:13 PM
Start here:
Spotlight on .NET Connector 3.0
Overview document here requires S-Number login: LINK.
Basically, in your .NET application, you set the parameter values using "SetValue" method. You use "Invoke" to invoke the RFC. Finally you get the return values using "GetString" or "GetValue."
Sample C#
RfcRepository rep = "";
RfcDestination yourSAP = ""; // see links for creating the connection to SAP
IRfcFunction companyBapi = rep.CreateFunction("BAPI_COMPANY_GETDETAIL");
companyBapi.SetValue("COMPANYID", "001000");
companyBapi.Invoke(yourSAP);
IRfcStructure detail = companyBapi.GetStructure("COMPANY_DETAIL");
String companyName = detail.GetString("NAME1");
Sample VB.NET
Dim rep As RfcRepository = [...]
Dim yourSAP As RfcDestination = [...] 'see links for creating the connection to SAP
Dim companyBapi As IRfcFunction = rep.CreateFunction("BAPI_COMPANY_GETDETAIL")
companyBapi.SetValue("COMPANYID", "001000")
companyBapi.Invoke(yourSAP)
Dim detail As IRfcStructure = companyBapi.GetStructure("COMPANY_DETAIL")
Dim companyName As [String] = detail.GetString("NAME1")
07-03-2012 5:54 AM
Hi Sachin,
There are some good codes avialbale.Pleae check else post.
Regards,
Madhu.
07-05-2012 5:43 AM
07-03-2012 4:13 PM
Start here:
Spotlight on .NET Connector 3.0
Overview document here requires S-Number login: LINK.
Basically, in your .NET application, you set the parameter values using "SetValue" method. You use "Invoke" to invoke the RFC. Finally you get the return values using "GetString" or "GetValue."
Sample C#
RfcRepository rep = "";
RfcDestination yourSAP = ""; // see links for creating the connection to SAP
IRfcFunction companyBapi = rep.CreateFunction("BAPI_COMPANY_GETDETAIL");
companyBapi.SetValue("COMPANYID", "001000");
companyBapi.Invoke(yourSAP);
IRfcStructure detail = companyBapi.GetStructure("COMPANY_DETAIL");
String companyName = detail.GetString("NAME1");
Sample VB.NET
Dim rep As RfcRepository = [...]
Dim yourSAP As RfcDestination = [...] 'see links for creating the connection to SAP
Dim companyBapi As IRfcFunction = rep.CreateFunction("BAPI_COMPANY_GETDETAIL")
companyBapi.SetValue("COMPANYID", "001000")
companyBapi.Invoke(yourSAP)
Dim detail As IRfcStructure = companyBapi.GetStructure("COMPANY_DETAIL")
Dim companyName As [String] = detail.GetString("NAME1")
07-05-2012 5:43 AM
07-05-2012 5:45 AM
i got some alternative to .net connector i.e ERPConnect s/w. but how useful it is?