on 12-05-2006 5:23 AM
Hello World,
I need to call a BAPI from a .Net application. Any standard built-in BAPI would be fine. Just need to prove it's workable in the project environment by passing some values and getting the response. A DIRECT call w/o XI involved.
Any code snippets or links would be appreciated.
P.S. I did try to access the link below to get some WSDLs that i got from a pdf doc called "SAP RFC via Web Services", but the page just couldn't get displayed.
http://myhost.mydomain.com:8000/sap/bc/bsp/sap/WebServiceBrowser/search.html
Regards,
Steve
Message was edited by:
steve peng
Hi Steve,
How are you doing ?
the links above are a gr8 guide.
here is some code for writing a web service invoking an RFC [Bapi_Vendor_Getdetail] in C#
the connection related class method are specified in a related thread
with respect,
amit
[WebMethod]
public DataSet GetVendorDetails(string strCompanyCode, string strVendorNo, string strConnection)
{
DataSet dsxVendor;
dsxVendor = null;
//connection string : "CLIENT=100 USER=chawathe PASSWD=amit LANG=en ASHOST=chawathe.realtech.co.nz SYSNR=0"
SAPConnect myConnector = new SAPConnect();
if(strVendorNo.Trim() !="")
{
SAP.Connector.Connection con2SAP;
con2SAP = myConnector.conEstablishConnection(strConnection);
if (con2SAP != null)
{
prxVendor prxVendorDetails = new prxVendor();
BAPIRET1 brtVendor = new BAPIRET1();
BAPIVENDOR_06Table zptBank = new BAPIVENDOR_06Table();
BAPIVENDOR_04 zpsVendor = new BAPIVENDOR_04();
BAPIVENDOR_05 zpsCompany = new BAPIVENDOR_05();
DataFormatConverter myDFC = new DataFormatConverter();
string strRFCReturnStatus;
try
{
con2SAP.Open();
prxVendorDetails.Connection = con2SAP;
prxVendorDetails.Bapi_Vendor_Getdetail(strCompanyCode,strVendorNo,out zpsCompany, out zpsVendor, out brtVendor, ref zptBank);
// check if details were retrieved
strRFCReturnStatus = brtVendor.Type.Trim();
switch(strRFCReturnStatus)
{
case "E":
case "A":
case "W":
// do not proceed with extraction of the result
// error, abort, warning
break;
case "S":
case "I":
default:
// proceed with extraction of the result
// output dataset creator
DataSetStructureCreator myDSSC = new DataSetStructureCreator();
dsxVendor = myDSSC.dsxCreateStructure(iConst.DS_VEN_OUT);
DataRow drxDetails;
drxDetails = null;
drxDetails = dsxVendor.Tables[iConst.DT_VEN_DET].NewRow();
drxDetails[iConst.DC_VG_LIFNR] = zpsVendor.Vendor.ToString().Trim();
drxDetails[iConst.DC_VG_NAME1] = zpsVendor.Name.ToString().Trim();
dsxVendor.Tables[iConst.DT_VEN_DET].Rows.Add(drxDetails);
drxDetails = null;
drxDetails = dsxVendor.Tables[iConst.DT_VCO_DET].NewRow();
drxDetails[iConst.DC_VC_LIFNR]= zpsCompany.Vendor.ToString().Trim();
drxDetails[iConst.DC_VC_BUKRS]= zpsCompany.Comp_Code.ToString().Trim();
dsxVendor.Tables[iConst.DT_VCO_DET].Rows.Add(drxDetails);
break;
}
}
catch (Exception ex)
{
string strError;
strError = ex.Message.Trim();
dsxVendor = null;
}
finally
{
if (con2SAP.IsOpen)
{
// close connection
con2SAP.Close();
}
// return to pool
myConnector.conReturnConnection(con2SAP);
}
}
}
return dsxVendor;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Hope tis code will help you out.
After creating a SAPProxy drag the Bapi "RFC_CUSTOMER_GET " onto it.Now on the aspx page drag a button,datagrid.
Set the datasource proerty of the datagrid to the respective table of the bapi.
Then write the following code:
To call RFC_CUSTOMER_GET and return results, write code in the Button1_Click event handler, as shown below.
private void Button1_Click(object sender, System.EventArgs e)
{
sapProxy11.Rfc_Customer_Get();
this.DataBind();
}
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Steve,
there is a detailed whitepaper from my CTSC colleagues from Microsoft available that describes what you are searching for:
http://www.microsoft-sap.com/pdf/SAPNetweaverWebServicesVS2005.pdf
Best regards,
André
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.