Hi!
I have problems in creating a correction invoice reversal. I usually get the error "invalid document structure" that tells nothing to me. I tried different variations, but wasn't able to figure out how to solve the problem. I could not find any samples, nor any topics in this issue, please help me.
My sample code creates a very simple invoice, then a correction invoice, and at last the corr. reversal. This last step fails.
I will post it in three parts because this forum cannot display properly that much lines in one code block.
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim vDocEntry As Integer
Dim vInvoice As SAPbobsCOM.Documents
vInvoice = vCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
vInvoice.CardCode = "V00001"
vInvoice.DocDate = DateTime.Now()
vInvoice.Lines.ItemCode = "00012"
vInvoice.Lines.Price = 10
vInvoice.Lines.Quantity = 10
RetVal = vInvoice.Add
If RetVal <> 0 Then
vCmp.GetLastError(ErrCode, ErrMsg)
MsgBox(ErrCode + " " + ErrMsg)
Else
vCmp.GetNewObjectCode(vDocEntry)
Dim vCorrInvoice As SAPbobsCOM.Documents
vCorrInvoice = vCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oCorrectionInvoice)
vCorrInvoice.CardCode = "V00001"
vCorrInvoice.DocDate = DateTime.Now()
vCorrInvoice.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items
'vCorrInvoice.Lines.ItemCode = "00012"
vCorrInvoice.Lines.LineTotal = 90
'vCorrInvoice.Lines.Quantity = 10
vCorrInvoice.Lines.CorrectionInvoiceItem = SAPbobsCOM.BoCorInvItemStatus.ciis_ShouldBe
vCorrInvoice.Lines.BaseType = 13
vCorrInvoice.Lines.BaseEntry = vDocEntry
vCorrInvoice.Lines.BaseLine = 0
vCorrInvoice.Lines.Add()