Skip to Content
0
Former Member
May 17, 2005 at 09:55 AM

Copying a document of a company A in a company B

17 Views

Hi,

I'm trying to copy an orders document of one company, for example, A, into another company, for example, B. But when adding the document it gives me the error code -2028. Could someone tell me what does this error means?

The code is in VB. Here is it:

Dim oPedidoA As SAPbobsCOM.Documents
Dim oPedidoB As SAPbobsCOM.Documents
Dim lineasA As SAPbobsCOM.Document_Lines
Dim lineasB As SAPbobsCOM.Document_Lines
oPedidoA = companiaA.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
oPedidoA.GetByKey(txtCodigo.Text)
lineasA = oPedidoA.Lines
oPedidoB = companiaB.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
lineasB = oPedidoB.Lines
With oPedidoA
    oPedidoB.DocType = .DocType
    oPedidoB.CardCode = .CardCode
    oPedidoB.DocDueDate = .DocDueDate
    oPedidoB.Comments = .Comments
    Dim i, fin As Integer
    fin = lineasA.Count
    For i = 0 To (fin - 1)
        lineasA.SetCurrentLine(i)
        lineasB.SetCurrentLine(i)
        lineasB.ItemCode = lineasA.ItemCode
        lineasB.ItemDescription = lineasA.ItemDescription
        lineasB.Quantity = lineasA.Quantity
        lineasB.DiscountPercent = lineasA.DiscountPercent
        If i <> (fin - 1) Then
             lineasB.Add()
        End If
    Next
End With
Dim n As Integer
n = oPedidoB.Add()
If n <> 0 Then
   MessageBox.Show("Not introduced")
Else
   MessageBox.Show("Introduced")
End If
MessageBox.Show(n)

Thanks in advance,

Vane