Skip to Content
avatar image
Former Member

Create Invoice From Draft - Internal Error

Dear Experts,

I have created one DRAFT Document for Invoice. After Creating this Draft , i want to update some line level data in the draft . After this changes done , I have to  create AR Invoice from this Draft document. But while am UPDATING the Draft , am getting "INTERNAL ERROR (-10)".

My Code :

StrSql = "SELECT DocEntry FROM ODRF WHERE U_RefNo = '" & strReciptNo & "'"


            If objRecset.EoF = False Then

                Dim ODrafts As SAPbobsCOM.Documents

                ODrafts = objSBOAPI.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts)

                If ODrafts.GetByKey(objRecset.Fields.Item("DocEntry").Value) = True Then

                    For i = 0 To ODrafts.Lines.Count - 1


                        Dim BatchQty, RemainQty, TotQty, NumInSales As Double

                        StrItemCode = ODrafts.Lines.ItemCode

                        TotQty = ODrafts.Lines.Quantity

                         ODrafts.Lines.WarehouseCode = StrBranchCode

                          ODrafts.Lines.CostingCode = StrBranchCode

                        ODrafts.Lines.Quantity = TotQty


                        ODrafts.Lines.UnitPrice = ODrafts.Lines.UnitPrice


                    Dim RetCode As Integer

                    Retcode = ODrafts.Update()  



                    If ODrafts.SaveDraftToDocument = 0 Then ' for Adding to draft documents


  End If

            End If

How can solve this issue ?

Thanks in advance


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 30, 2014 at 05:12 PM

    Hi Senthil,

    I don't really understand what you are trying to accomplish. Just something I see :

    - You first set TotQty = ODrafts.Lines.Quantity and then ODrafts.Lines.Quantity = TotQty without changing anything

    - ODrafts.Lines.UnitPrice = ODrafts.Lines.UnitPrice ?

    - WarehouseCode equals CostingCode - is that by purpose  ?

    - try to get your draft again after updating, before SaveDraftToDocument

    - check if RetCode is 0 before SaveDraftToDocument



    Add comment
    10|10000 characters needed characters exceeded