Search code examples
c#sap-erpsaprfcbapi

SAP get Sales Orders BAPISDORDER_GETDETAILEDLIST


I'm trying to call BAPISDORDER_GETDETAILEDLIST to get the sales orders form SAP into my C# application, but for some reason headerTable doesn't return any information.

Any clues?

This is how I do it:

public DataTable getVariantConfiguratioin(String ordernumber)
        {
            IRfcFunction testfn = repo.CreateFunction("BAPISDORDER_GETDETAILEDLIST");


            IRfcStructure data = testfn.GetStructure("I_BAPI_VIEW");
            IRfcTable salesDocuments = testfn.GetTable("SALES_DOCUMENTS");
            IRfcTable headerTable = testfn.GetTable("ORDER_HEADERS_OUT");
           
            data.SetValue("HEADER", "X");
            data.SetValue("ITEM", "X");
            data.SetValue("SDCOND", "X");

            
            salesDocuments.Append();
            salesDocuments.SetValue("VBELN", ordernumber);

            testfn.Invoke(dest);


            DataTable headerTableDT = headerTable.ToDataTable("headerTableDT");

            return headerTableDT;

        }

Solution

  • make sure youa have left 0 padded your order number exemple to the correct length of VBELN in your system . example:

    salesDocuments.setValue("VBELN", "0000001258")
    

    please also check after invoke headerTable.RowCount

    Witch version of sap connector youre using ... i dont have IRfcTable.toDataTable in 3.0 ?