Skip to Content
0
Former Member
Apr 01, 2016 at 10:26 PM

Problem Creating CreditMemo Through SDK

259 Views

Hi All,

In SAP 9.0 PL 5 I have created an order and based on that order I have created delivery, Payment and Invoice. Now when I am trying to add Credit Memo for created invoice Via SDK it is giving the below error:

Quantity cannot exceed the quantity in the base document.

I am linking the document and line correctly and the BaseLine, BaseEntry, and BaseType match the ones on the source document. Also, the quantity is not more then on the source document.

Please Help me give suggestion.

Thanks

Here's my code:

ReturnMat = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oCreditNotes)

ReturnMat.Series = SAPSerie

ReturnMat.CardCode = DTShipper.Rows(0).Item("Customer")

ReturnMat.Comments = Shipper.ToString() & " " & Note.ToString()

For x As Int32 = 0 To DTShipper.Rows.Count - 1

If x > 0 Then ReturnMat.Lines.Add()

ReturnMat.Lines.BaseEntry = DTShipper.Rows(x).Item("InvoiceDocEntry")

ReturnMat.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oInvoices

ReturnMat.Lines.BaseLine = DTShipper.Rows(x).Item("LineNum")

''Lines

ReturnMat.Lines.Quantity = DTShipper.Rows(x).Item("SAPQuantity")

''BatchNumbers

ReturnMat.Lines.BatchNumbers.Add()

ReturnMat.Lines.BatchNumbers.BatchNumber = DTShipper.Rows(x).Item("Serial")

ReturnMat.Lines.BatchNumbers.Quantity = DTShipper.Rows(x).Item("SAPQuantity")

Next

ReturnMat.Add()

oCompany.GetLastError(ErrCode, ErrMsg)

If ErrCode <> 0 Then

MessageBox.Show(ErrMsg)

End If