Skip to Content
0
Former Member
Jan 09, 2006 at 05:34 AM

HELP !!!!

24 Views

What is wrong here?

I got error - 2028 BaseDoc Missmatch.

Private Sub ConvertDO()


        Dim oGRPO As SAPbobsCOM.Documents
        Dim oRS As SAPbobsCOM.Recordset

        Dim sqlStr As String
        Dim i As Integer


        oDO = m_company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes)
        oRS = m_company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

        sqlStr = "SELECT T0.DocEntry,T0.DocNum, T0.DocType FROM ODLN  T0 Where T0.DocStatus = 'O'"
        oRS.DoQuery(sqlStr)

        While Not (oRS.EoF)
            If oDO.GetByKey(oRS.Fields.Item("DocEntry").Value) Then
                '
                oGRPO = m_company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)

                oGRPO.CardCode = oDO.CardCode

                oGRPO.DocDate = oDO.DocDate
                oGRPO.DocDueDate = oDO.DocDueDate
                oGRPO.DiscountPercent = oDO.DiscountPercent
                oGRPO.HandWritten = SAPbobsCOM.BoYesNoEnum.tYES
                oGRPO.DocNum = oDO.DocNum

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

                    oDO.Lines.SetCurrentLine(i)

                    oGRPO.Lines.ItemCode = oDO.Lines.ItemCode
                    oGRPO.Lines.Quantity = oDO.Lines.Quantity
                    oGRPO.Lines.WarehouseCode = oDO.Lines.WarehouseCode
                    oGRPO.Lines.Price = oDO.Lines.Price

                    oGRPO.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oDeliveryNotes
                    oGRPO.Lines.BaseEntry = CInt(oRS.Fields.Item("DocNum").Value)  'oDraft.Lines.BaseEntry
                    oGRPO.Lines.BaseLine = oDO.Lines.LineNum

                    If i < oDO.Lines.Count - 1 Then
                        oGRPO.Lines.Add()
                    End If

                Next i

                'Add the GRPO
                lRetCode = oGRPO.Add
                If lRetCode <> 0 Then
                    m_company.GetLastError(lRetCode, sErrMsg)
                    MsgBox(lRetCode & "  " & sErrMsg)

                End If

            End If

            'Move to the next record
            oRS.MoveNext()
        End While

        MsgBox("Done")

    End Sub