Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C# by sdfrt ( 13 years ago )
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SAP.Middleware.Connector;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
RfcDestination _ecc;
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
try
{
_ecc = RfcDestinationManager.GetDestination("ECDCLNT140");
if (_ecc == null)
{
RfcDestinationManager.RegisterDestinationConfiguration(new ECCDestinationConfig());
_ecc = RfcDestinationManager.GetDestination("ECDCLNT140");
}
}
catch (Exception a)
{
Response.Write(a);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//Set function
IRfcFunction BapiMaterialGetList = SapRfcRepository.CreateFunction("BAPI_MATERIAL_GETLIST");
//Get reference to table object
IRfcTable So_MATNR = BapiMaterialGetList.GetTable("MATNRSELECTION");
}
public static DataTable GetDataTableFromRFCTable(IRfcTable functionRfcTable)
{
DataTable data = new DataTable();
//Create data table.
for (int i = 0; i <= functionRfcTable.ElementCount - 1; i++)
{
RfcElementMetadata metadata = functionRfcTable.GetElementMetadata(i);
data.Columns.Add(metadata.Name);
}
//Transfer rows from rfcTable to .Net table.
foreach (IRfcStructure row in functionRfcTable)
{
DataRow rowAdd = data.NewRow();
for (int j = 0; j <= functionRfcTable.ElementCount - 1; j++)
{
RfcElementMetadata metadata = functionRfcTable.GetElementMetadata(j);
rowAdd(metadata.Name) = row.GetString(metadata.Name);
}
data.Rows.Add(rowAdd);
}
return data;
}
}
Revise this Paste