2

I'm using two different BAPIs to get data from SAP ERP. When I use BAPI_SALESORDER_GETLIST, it works perfectly. But when I use BAPI_BILLINGDOC_GETLIST, I get no data. This is how I'm trying to call the BAPI:

DataTable table = null;

SapConfig cfg = new SapConfig();

if (RfcDestinationManager.TryGetDestination("SAP") == null)
    RfcDestinationManager.RegisterDestinationConfiguration(cfg);

RfcDestination dest = RfcDestinationManager.GetDestination("SAP");
RfcRepository repo = dest.Repository;

IRfcFunction fnc = repo.CreateFunction("BAPI_BILLINGDOC_GETLIST");
IRfcStructure param = fnc.GetStructure("REFDOCRANGE");
param.SetValue("SIGN", "I");
param.SetValue("OPTION", "EQ");
param.SetValue("REF_DOC_LOW", salesOrderNumber);
param.SetValue("REF_DOC_HIGH", "");

fnc.Invoke(dest);

table = fnc.GetTable("BILLINGDOCUMENTDETAIL").ToDataTable();

return table;

As far as I can tell, it all looks right. I got with the SAP ERP team and they made sure the account I'm using has access to everything and we ran the BAPI in SAP ERP and it worked fine.

So SAP ERP seems fine. Any ideas on what I'm doing wrong here?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
ernest
  • 1,633
  • 2
  • 30
  • 48
  • are you sure your parameter salesOrderNumber is correct? In some cases, SAP expects document numbers to be submitted with leading zeros. Usually not in official BAPIs, but it's easy enough to check. I'd first try executing the FM in SE37 with the same parameter, see if that yields a result. – Dirk Trilsbeek Mar 08 '16 at 18:32
  • @DirkTrilsbeek We did execute it in SE37 with the actual number, 80000236, and it worked fine. I can see if there are any leading zeroes though and try that. – ernest Mar 08 '16 at 19:21
  • @DirkTrilsbeek Damn it, you're right. I added 2 zeroes to the number and it returned data. Feel free to submit an answer and I'll accept it. Thanks! – ernest Mar 08 '16 at 19:23

1 Answers1

3

Please check if the parameter value is correct. Sometimes SAP function modules expect document numbers to be submitted with leading zeros. You can test function modules in transaction SE37 to check your parameters.

Dirk Trilsbeek
  • 5,873
  • 2
  • 25
  • 23