Skip to Content
0
Aug 11, 2016 at 10:00 AM

Error creating the Issue for Production

156 Views

Hello everybody,

I'm doing a development DI-API to generate a issue for production and I have the following error:

"This entry already exists in the following tables (ODBC -2035)"


The problem happens when emissions contain resources to which they were assigned costs in the Resource Master Data.



If I put the costs at 0, no problems. I have version 9.2 PL03 and when I had the version 9.1 PL04 the development work.


The following is an example of my code:

Dim Cantidad As Double = 5
 Dim lr As Long
 Dim oDoc As SAPbobsCOM.Documents = Nothing
 Dim sKey As String = ""
 Dim oRcs As SAPbobsCOM.Recordset
 Dim ls As String = ""

 try
 oDoc = oCompany.GetBusinessObject(oInventoryGenExit)
 oDoc.DocDate = GetFechaContable()
 oDoc.DocDueDate = Now.Date
 oDoc.DocumentsOwner = “Operario”
 oDoc.Comments = "Marcaje Final Operario: Operario " & Now.ToString("dd/MM/yyyy HH:mm:ss")
 If Cantidad <> 0 Then
 ls = ""
 ls = ls & "SELECT T1.wareHouse, T1.LineNum "
 ls = ls & "FROM OWOR T0 INNER JOIN WOR1 T1 ON T0.DocEntry=T1.DocEntry "
 ls = ls & "LEFT JOIN OITM T3 ON T1.ItemCode = T3.ItemCode "
 ls = ls & "INNER JOIN OWHS T4 ON T1.wareHouse= T4.WhsCode "
 ls = ls & "LEFT JOIN OITW T5 ON T1.ItemCode = T5.Itemcode AND T1.wareHouse=T5.WhsCode "
 ls = ls & "INNER JOIN OITM T6 ON T0.ItemCode = T6.ItemCode "
 ls = ls & "LEFT JOIN ORSC T7 ON T1.ItemCode = T7.ResCode "
 ls = ls & "WHERE T1.DocEntry=" & Me.DocEntryOF
 ls = ls & " AND T1.ItemCode = '" & NullToText(Me.txtFase.Text) & "'"

 oRcs = oCompany.GetBusinessObject(BoRecordset)
 oRcs.DoQuery(ls)

 If Not oRcs.EoF Then
 oDoc.Lines.SetCurrentLine(0)
 oDoc.Lines.BaseType = 0 ' WorkOrders (O.F)
 oDoc.Lines.BaseEntry = Me.DocEntryOF
 oDoc.Lines.BaseLine = NullToInt(oRcs.Fields.Item(1).Value)
 oDoc.Lines.WarehouseCode = NullToText(oRcs.Fields.Item(0).Value)
 oDoc.Lines.Quantity = Cantidad
 End If
 End If

 If Cantidad <> 0 Then
 lr = oDoc.Add

 If lr = 0 Then

 PrintLinea("Marcaje Final Operario: Operario ")
 Else
 Throw New Exception(RecuperarErrorSap())
 End If
 End If

 Catch ex As Exception
 Throw New Exception("Emisión " & ex.Message)
        End Try


Kind regards.

Attachments

Captura1.JPG (49.9 kB)