Skip to Content
0
Former Member
Jul 26, 2016 at 08:12 AM

Document Delivery (Note) based on existing open order (-2010 "Internal Error")

99 Views

Dear experts,

I'm using the DI API version 9.0 on a SAP 9.0.

I'm trying to add a new document delivery based on an open order which contains multiple rows.

On addition attempt I receive the following error: Internal Error (-2010) occured.

The problem occurs only when the document delivery contains multiple lines, i.e, more than 1 line.

Code sample:

try
{
     // Header
     oDocument                            = oCompany.GetBusinessObject(BoObjectTypes.oDeliveryNotes) as Documents;     
     oDocument.DocNum              = 12345;
     oDocument.CardCode            = "CUSTOMER123";
     oDocument.SalesPersonCode = -1;
     oDocument.DocType              = BoDocumentTypes.dDocument_Items;
     oDocument.Comments           = "Test insertion";                               
     oDocument.DiscountPercent   = 0.0;                   
     oDocument.PickRemark         = "Test insertion for pickup remark";                                   
     oDocument.Confirmed            = BoYesNoEnum.tYES;  

     // Lines
     foreach (ODocumentDeliveryDetails line in DocumentDeliveryDetailsList)
     {
          oDocument.Lines.SetCurrentLine(line.LineNumber); 
          oDocument.Lines.ItemCode             = line.ItemCode;
          oDocument.Lines.Quantity               = line.Quantity;
          oDocument.Lines.LineType              = BoDocLineType.dlt_Regular;
          oDocument.Lines.DiscountPercent   = 0.0;                                                                           
          oDocument.Lines.UnitPrice              = line.UnitPrice;
          oDocument.Lines.Price                    = line.LinePrice;
          oDocument.Lines.SalesPersonCode = -1; 
          oDocument.Lines.WarehouseCode   = "01";

if (DocumentDeliveryHeader.BaseNumber > 0) { // Optional oDocument.Lines.BaseType = (int) SAPbobsCOM.BoObjectTypes.oOrders; oDocument.Lines.BaseEntry = DocumentDeliveryHeader.BaseNumber; oDocument.Lines.BaseLine = line.LineNumber; } // Add line oDocument.Lines.Add(); } // Add document delivery int addResult = oDocument.Add(); if (addResult != 0) { MessageBox.Show("Error occurred"); } } catch (Exception ex) { MessageBox.Show("Error occurred"); }

I can't seem to find an explanation to the problem.

Would be more than glad to have your assistance.

Kind regards,