I made this following code but failed.
Private Sub ProductionOrder_InsertValue(ByVal DocDate As Date, ByVal oProductionOrderDocEntry As String, ByVal oProductionOrderDocNum As String, ByVal oProductOrder As String, ByRef IsError As Boolean, ByVal SBO_Application As SAPbouiCOM.Application, ByVal oCompany As SAPbobsCOM.Company)
Dim oRec As SAPbobsCOM.Recordset
oRec = CType(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset), SAPbobsCOM.Recordset)
Dim lRetCode As Integer = 0
Dim lErrCode As Integer = 0
Dim sErrMsg As String = ""
Dim MainProductCode As String = ""
Dim oResource As Decimal = 0
oRec.DoQuery("select ItemCode from OWOR where DocEntry= '" & oProductionOrderDocEntry & "'")
MainProductCode = oRec.Fields.Item("ItemCode").Value.ToString
oRec.DoQuery("exec GetValueResourceActual """ + MainProductCode + """,""" + oProductionOrderDocNum + """")
oResource = oRec.Fields.Item("ResourceAmount").Value.ToString
'-Production Order
Dim oProdOrder As SAPbobsCOM.ProductionOrders
Dim isLineExist As Boolean = False
oProdOrder = CType(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders), SAPbobsCOM.ProductionOrders)
If Round(oResource, 2) <> 0 Then
oProdOrder.UserFields.Fields.Item("U_ActualCap").Value = oResource
isLineExist = True
End If
If isLineExist Then
lRetCode = oProdOrder.Update()
If lRetCode <> 0 Then
IsError = True
oCompany.GetLastError(lErrCode, sErrMsg)
SBO_Application.MessageBox(lErrCode.ToString & " : " & sErrMsg)
Else
IsError = False
If oProdOrder.GetByKey(CInt(oCompany.GetNewObjectKey)) Then
oProductOrder = oProdOrder.DocNum.ToString
End If
End If
End If
oProdOrder = Nothing
End Sub
How can I use the above code to insert its result in the UDF by using the SAP SDK?
Pls help to solve this issue.
THank you
Regards,
Steve