Dear Experts,
Could somebody help me how to update an user field in production order ? Please guys!
Example U_Info in the OWOR. The value is "C"
How do I save records in these fields using the SAP SDK?
I made this following code but failed.
Private Sub UpdateProduction(ByVal sForm As String, ByVal SBO_Application As SAPbouiCOM.Application, ByVal oCompany As SAPbobsCOM.Company)
Dim oForm As SAPbouiCOM.Form
Dim oProductionOrderDocEntry As String = ""
Dim oProductionOrderDocNum As String = ""
Dim oProductionOrderSeries As String = ""
Dim oProductionOrderDocDate As String
Dim IsError As Boolean = False
Dim IsError2 As Boolean = False
Dim MainProductCode As String = ""
Dim lRetCode As Integer = 0
Dim lErrCode As Integer = 0
Dim sErrMsg As String = ""
Try
oForm = SBO_Application.Forms.Item(sForm)
oCompany.StartTransaction()
If oForm.DataSources.DBDataSources.Item("OWOR").GetValue("U_NEWENTRY", 0) = "Y" And oForm.DataSources.DBDataSources.Item("OWOR").GetValue("Status", 0) = "L" Then
oProductionOrderDocEntry = oForm.DataSources.DBDataSources.Item("OWOR").GetValue("DocEntry", 0)
oProductionOrderDocNum = oForm.DataSources.DBDataSources.Item("OWOR").GetValue("DocNum", 0)
oProductionOrderSeries = oForm.DataSources.DBDataSources.Item("OWOR").GetValue("Series", 0)
oProductionOrderDocDate = oForm.DataSources.DBDataSources.Item("OWOR").GetValue("CloseDate", 0)
MainProductCode = oForm.DataSources.DBDataSources.Item("OWOR").GetValue("ItemCode", 0)
Dim oProductionOrder As SAPbobsCOM.ProductionOrders
oProductionOrder = CType(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders), SAPbobsCOM.ProductionOrders)
If Not IsError2 Then 'OpprId
oProductionOrder.UserFields.Fields.Item("U_INFO").Value = "C"
lRetCode = oProductionOrder.Update()
If lRetCode <> 0 Then
oCompany.GetLastError(lErrCode, sErrMsg)
MessageBox.Show(sErrMsg)
End If
End If
If Not IsError Then
Dim oRec2 As SAPbobsCOM.Recordset
oRec2 = CType(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset), SAPbobsCOM.Recordset)
oRec2.DoQuery("UPDATE [@PROD_ORDER] set Code = 'C' where DocEntry = '" + oProductionOrderDocEntry + "'")
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit)
SBO_Application.MessageBox("Done")
Else
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
End If
End If
'End If
Catch ex As Exception
SBO_Application.MessageBox(ex.Message)
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
End Try
End Sub
Thank you.
Regards,
Steve