I am trying to save data from Sales Order entry in Sage to one of UDT created in Sage itself. I created some of the fields in the UDT and want to store some of the data while creating new Sales Order on Accept click in to the UDT. Here is the code that I am trying to use to update the UDT but it is not working. Any body can help me out? hMyUDT = oSession.GetObject("CM_UDTMaint_bus", "SO_UDT_PRODUCTION") If hMyUDT = 0 Then Exit Sub End If Set oMyUDT = oSession.AsObject(hMyUDT) retVal = oMyUDT.MoveLast() udtKey = "" retval = oMyUDT.GETValue("SO_SALESORDERNO",udtKey) udtKey = Str(Int(udtKey)+1) retVal = 0MyUDT.SetKey(udtKey) retVal = oBusObj.GetValue("UDF_YEAR$",year) oMyUDT.SetValue("YEAR",year) retVal = oBusObj.GetValue("UDF_MAKE$",make) oMyUDT.SetValue("YEAR",make) retVal = oBusObj.GetValue("UDF_VIN$",vin) oMyUDT.SetValue("VIN",vin) retVal = oBusObj.GetValue("UDF_MODEL$",model) oMyUDT.SetValue("MODEL",model) retVal = oBusObj.GetValue("UDF_STATUS$",status) oMyUDT.SetValue("STATUS",status) retVal = oBusObj.GetValue("UDF_SALESMAN$",salesman) oMyUDT.SetValue("SALESMAN",salesman) retVal = oBusObj.GetValue("UDF_SHIP_DATE$",deliverdate) oMyUDT.SetValue("SHIP_DATE",deliverdate) retVal = oBusObj.GetValue("ShipExpireDate$",shipdate) oMyUDT.SetValue("SHIP_DATE",shipdate) retVal = oBusObj.GetValue("ConfirmTo$",shipto) oMyUDT.SetValue("SHIP_TO",shipto) retVal = oBusObj.GetValue("CustomerNo$",customerno) oMyUDT.SetValue("CUSTOMER_NO",customerno) retVal = oBusObj.GetValue("ORDERDATE$",orderdate) oMyUDT.SetValue("ORDER_DATE",orderdate) retVal = oBusObj.GetValue("BillToName$",customername) oMyUDT.SetValue("CUSTOMER_NAME",customername) retVal = oBusObj.GetValue("CUSTOMERPONO$",customerpono) oMyUDT.SetValue("CUSTOMER_PO",customerpono) retVal = oBusObj.GetValue("SalesOrderNo$",workorderno) oMyUDT.SetValue("SO_SALESORDERNO",workorderno) If ItemType = 1 then retVal = oItem.Find(itemCode) ItemCode = 0 retVal = oSO_SalesOrderDetail.GetValue("ExtensionAmt",amount) oMyUDT.SetValue("AMOUNT",amount) retVal = oSO_SalesOrderDetail.GetValue("QuantityOrdered",quantity) oMyUDT.SetValue("QUANTITY",quantity) Set oMyUDT = Nothing oSession.DropObject("CM_UDTMaint_bus") End If
↧