Sap came with a new version (3.0) of SAP Connector for Dotnet last Dec. It made the SAP connectivity from Dotnet easier compared to the Last Version (SAPConnector 2.0). Earlier the connector only worked with C# in VS 2003. It created a proxy for the SAP RFC ( Remote Function Call) beign called and so at any point of time if the RFC was modified the proxy needs to be re-generated. Now with 3.0 it is much easier to code with. Reference the "sapnco.dll" and the "sapnco_utils.dll" in your VS project (version doesnot matter, it can be 2K3/2K5/2K8).
Add the following code
const string ABAP_AS_POOLED = "DV";
RfcDestination destination = RfcDestinationManager.GetDestination(ABAP_AS_POOLED);
IRfcFunction function = null;
RfcSessionManager.BeginContext(destination);
try
{
function = destination.Repository.CreateFunction(Your RFC Function);
function.SetValue(RFC Import Parameter, Value to be Passed);
function.Invoke(destination);
IRfcTable detail = function[RFC Function Out Table].GetTable();
for (int i = 0; i < detail.RowCount; i++)
{
//set the current row - the row used for Get*/Set* operations
Response.Write(detail.GetValue(i));
}
}
catch (RfcBaseException ex)
{
Response.Write(ex.ToString());
return;
}
The above code just gives a brief idea of how to call a RFC.
For binding the output with a DataGrid/GridView, One has to create a datatable and update it and then bind the data table with the DataGrid/GridView.
Link to SAP Blog Help
http://weblogs.sdn.sap.com/cs/blank/view/wlg/23051
No comments:
Post a Comment