on 2011 Jan 25 9:14 PM
I am using the SAP .NET Connector 3.0 (.NET Framework 4.0 64-bit) with Visual Studio 2010 Pro on a Windows 7 64-bit computer. I have successfully run the example application from the SAP .NET Connector 3.0 Overview that returned a single company in an exporting variable as a structure and then displayed a single field from the structure.
What I need to be able to do is get a list (table) of the sales orders and work with the rows and fields within the rows. Modifying the example from the Overview document, I tried the following:
static void Main(string[] args)
{
RfcDestinationManager.RegisterDestinationConfiguration(new MyBackendConfig());
RfcDestination prd = RfcDestinationManager.GetDestination("PRD_000");
try
{
RfcRepository repo = prd.Repository;
IRfcFunction salesOrderBapi = repo.CreateFunction("BAPI_SALESORDER_GETLIST");
salesOrderBapi.SetValue("CUSTOMER_NUMBER", "246");
salesOrderBapi.SetValue("SALES_ORGANIZATION", "XXXX");
salesOrderBapi.Invoke(prd);
//IRfcTable table = companyBapi.GetTable("SALES_ORDERS");
IRfcTable table = salesOrderBapi["SALES_ORDERS"].GetTable();
Console.WriteLine("The table has {0} rows.", table.RowCount);
foreach (IRfcStructure row in table)
{
String field = row.GetString("SD_DOC");
Console.WriteLine(field);
}
Console.Read();
}
catch (Exception ex)
{
Console.Write("There was an error... {0}", ex.Message);
throw;
}
}When I execute the function from within the SAP GUI with the given parameters, I get a table with 3 rows in it (which is what I expect from what I know of the data). When I execute it from the .NET program, it says that there are 0 rows and the foreach loop doesn't have anything to loop over so I don't know if that portion will even work.
Can someone point out what I'm doing wrong?? Thanks in advance.
Request clarification before answering.
Something to note here..
When we have a composite Data type, we can do assign it as below.
RfcRepository repo = dst.Repository;
IRfcFunction func = repo.CreateFunction("ZEACT_PASAN_INDEEWARA_TEST_BOM");
IRfcStructure st = func.GetStructure("PWERKS");
st.SetValue("WERKS", "1340");
func.SetValue("PWERKS",st);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.