I want to get some data from an SAP Server to my C# Programm in Visual Studio. The connection between the SAP and the program is already working but I don't really know how to get the data from the Server into the program.
namespace ConsoleApp1
{
class Program //: IDestinationConfiguration
{
static void Main(string[] args)
{
fn f = new fn();
RfcDestination destination = f.GetRfcDestination("vhcalnplci", "brachi", "Abap2017", "001", "EN", "vhcalnplci", "00", "20", "10");
RfcSessionManager.BeginContext(destination);
destination.Ping();
IRfcFunction function = destination.Repository.CreateFunction("/BODS/RFC_READ_TABLE");
IRfcTable addresses = function["ADDRESSES"].GetTable();
Console.WriteLine("STREET");
for (int index = 0;
index < addresses.RowCount;
++index)
{
Console.WriteLine(addresses[index]["STREET"].GetString());
}
}
}
}
As you can see I have already written some code but unfortunately when I am trying to execute this program i get the following error:
SAP.Middleware.Connector.RfcInvalidParameterException: "Element ADDRESSES of container metadata /BODS/RFC_READ_TABLE unknown"
At the following line of code:
IRfcTable addresses = function["ADDRESSES"].GetTable();
I know the error is because the element is not existing in the RFC_READ_TABLE module, but as I said I don't really know how to get data and what code I really need for that part of the program. I already looked through the programming guide from SAP but maybe it will help someone help me: .NET Connector Programming Guide