Skip to Content

Di Api Linking Goods receipt to Purchase Orders error -2028 - No matching records found (ODBC -2028)

Jan 19 at 04:47 PM


avatar image


I'm working on an application to make goods receipt simpler for our company using SAP business one 9.2

I already got it working so far that I can add a new goods receipt via DI API. The following C# code does this for me:

Company company = _sapService.GetCompany();

var oPurchaseDeliveryNotes = (Documents) company.GetBusinessObject(BoObjectTypes.oPurchaseDeliveryNotes);

// required fields
oPurchaseDeliveryNotes.CardCode = GetCardCode(
oPurchaseDeliveryNotes.PaymentGroupCode = -1;

// order lines
var i = 0;
foreach (OrderLineViewModel model in models.Where(model => model.RecQuantity != 0))
      if (IsScanSerialNumber(model.ItemCode))
          // Serial Numbers
          var j = 0;
          foreach (string serialNumber in model.SerialNumbers)
              oPurchaseDeliveryNotes.Lines.SerialNumbers.ManufacturerSerialNumber = serialNumber;
              oPurchaseDeliveryNotes.Lines.SerialNumbers.InternalSerialNumber = serialNumber;

              // Go to next line and add
   // Other line information
   oPurchaseDeliveryNotes.Lines.ItemCode = model.ItemCode;              
   oPurchaseDeliveryNotes.Lines.ItemDescription = model.Dscription;
   oPurchaseDeliveryNotes.Lines.Quantity = (double) model.RecQuantity;
   oPurchaseDeliveryNotes.Lines.ShipDate = DateTime.Now;
   oPurchaseDeliveryNotes.Lines.VendorNum = model.VendorNum;

   // Go to next line and add

int result = oPurchaseDeliveryNotes.Add();
if (result == 0)
     // success

int errorCode;
string errorDesc;
company.GetLastError(out errorCode, out errorDesc);
throw new Exception($"{errorCode} - {errorDesc}");

The above code works, but does not link the Goods Receipt to the Purchase Order.

I read in other topics that I have to set BaseEntry, BaseType and BaseLine to make the link work like this:

// Link to PO info
oPurchaseDeliveryNotes.Lines.BaseEntry = GetPurchaseOrderEntry(model.DocNum);
oPurchaseDeliveryNotes.Lines.BaseType = 22;
oPurchaseDeliveryNotes.Lines.BaseLine = GetPruchchaseOrderLineCode(model.DocNum, model.ItemCode);

However now I get the following error: '-2028 - No matching records found (ODBC -2028)'

Can anyone help me figure out what I'm doing wrong?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Luuk Jensen Jan 23 at 01:16 PM

I already found the answer.

I set the values for fields that DI Api fills automatically. (Line.ItemCode, Line.VendorNum, Line.ItemDescription, Line.ShipDate and PaymentGroupCode).

Now I only set the quantity, and now it works.

I hope this helps others that have the same problem.

10 |10000 characters needed characters left characters exceeded